From 4d336f59bad0da6714bc69fd71aa94056bc455c1 Mon Sep 17 00:00:00 2001 From: =?utf8?q?St=C3=A9phane=20Jacob?= Date: Mon, 30 Mar 2009 22:10:07 +0200 Subject: [PATCH 1/1] Adds entreprises edition interface. --- modules/admin.php | 63 ++++++++++++++++++++++++++++++ templates/admin/index.tpl | 4 +- templates/admin/jobs.tpl | 99 +++++++++++++++++++++++++++++++++++++++++++++++ 3 files changed, 165 insertions(+), 1 deletion(-) create mode 100644 templates/admin/jobs.tpl diff --git a/modules/admin.php b/modules/admin.php index dc580d2..032d02a 100644 --- a/modules/admin.php +++ b/modules/admin.php @@ -48,6 +48,7 @@ class AdminModule extends PLModule 'admin/ipwatch' => $this->make_hook('ipwatch', AUTH_MDP, 'admin'), 'admin/icons' => $this->make_hook('icons', AUTH_MDP, 'admin'), 'admin/accounts' => $this->make_hook('accounts', AUTH_MDP, 'admin'), + 'admin/jobs' => $this->make_hook('jobs', AUTH_MDP, 'admin'), ); } @@ -1254,6 +1255,68 @@ class AdminModule extends PLModule WHERE perms = \'admin\' ORDER BY nom, prenom')); } + + function handler_jobs(&$page, $id = -1) + { + $page->changeTpl('admin/jobs.tpl'); + + if (Env::has('search')) { + $res = XDB::query("SELECT e.id, e.name, e.acronym + FROM profile_job_enum AS e + WHERE e.name LIKE CONCAT('% ', {?}, '%') OR e.acronym LIKE CONCAT('% ', {?}, '%')", + Env::t('job'), Env::t('job')); + + if ($res->numRows() <= 20) { + $page->assign('jobs', $res->fetchAllAssoc()); + } else { + $page->trigError("Il y a trop d'entreprises correspondant à ton choix. Affine-le !"); + } + + $page->assign('askedJob', Env::v('job')); + return; + } + + if (Env::has('edit')) { + S::assert_xsrf_token(); + $selectedJob = Env::has('selectedJob'); + + if (Env::has('change')) { + XDB::execute('UPDATE profile_job + SET jobid = {?} + WHERE jobid = {?}', + Env::i('newJobId'), $id); + XDB::execute('DELETE FROM profile_job_enum + WHERE id = {?}', + $id); + + $page->trigSuccess("L'entreprise a bien été remplacée."); + } else { + XDB::execute('UPDATE profile_job_enum + SET name = {?}, acronym = {?}, url = {?}, email = {?}, + NAF_code = {?}, AX_code = {?}, holdingid = {?} + WHERE id = {?}', + Env::t('name'), Env::t('acronym'), Env::t('url'), Env::t('email'), + Env::t('NAF_code'), Env::i('AX_code'), Env::i('holdingId'), $id); + + $page->trigSuccess("L'entreprise a bien été mise à jour."); + } + } + + if (!Env::has('change') && $id != -1) { + $res = XDB::query('SELECT e.id, e.name, e.acronym, e.url, e.email, e.NAF_code, e.AX_code, + h.id AS holdingId, h.name AS holdingName, h.acronym AS holdingAcronym + FROM profile_job_enum AS e + LEFT JOIN profile_job_enum AS h ON (e.holdingid = h.id) + WHERE e.id = {?}', + $id); + + if ($res->numRows() == 0) { + $page->trigError('Auncune entreprise ne correspond à cet identifiant.'); + } else { + $page->assign('selectedJob', $res->fetchOneAssoc()); + } + } + } } // vim:set et sw=4 sts=4 sws=4 foldmethod=marker enc=utf-8: diff --git a/templates/admin/index.tpl b/templates/admin/index.tpl index 4cb8e87..86cdba5 100644 --- a/templates/admin/index.tpl +++ b/templates/admin/index.tpl @@ -138,7 +138,7 @@ Secteurs   |   - Networking + Entreprises   |   Corps   |   @@ -155,6 +155,8 @@ Sections   |   Noms +   |   + Networking diff --git a/templates/admin/jobs.tpl b/templates/admin/jobs.tpl new file mode 100644 index 0000000..02e5787 --- /dev/null +++ b/templates/admin/jobs.tpl @@ -0,0 +1,99 @@ +{**************************************************************************} +{* *} +{* Copyright (C) 2003-2009 Polytechnique.org *} +{* http://opensource.polytechnique.org/ *} +{* *} +{* This program is free software; you can redistribute it and/or modify *} +{* it under the terms of the GNU General Public License as published by *} +{* the Free Software Foundation; either version 2 of the License, or *} +{* (at your option) any later version. *} +{* *} +{* This program is distributed in the hope that it will be useful, *} +{* but WITHOUT ANY WARRANTY; without even the implied warranty of *} +{* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the *} +{* GNU General Public License for more details. *} +{* *} +{* You should have received a copy of the GNU General Public License *} +{* along with this program; if not, write to the Free Software *} +{* Foundation, Inc., *} +{* 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA *} +{* *} +{**************************************************************************} + +

Entreprises

+ +{if $jobs} +

+ Liste des entreprises correspondant à ta recherche : +

+{/if} + +{if $selectedJob} +
+{xsrf_token_field} + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
Entreprise n° {$selectedJob.id}
Nom
Acronyme
Page web
Adresse email
Code NAF
Code AX
Identifiant de la holding
Nom de la holding{$selectedJob.holdingName}
Acronyme de la holding{$selectedJob.holdingAcronym}
Remplacer par l'entreprise n°
+

+ Confirmation du remplacement de cette entreprise :  +
+ +

+
+{/if} + +
+

+ Nom ou acronyme de l'entreprise : +
+ +

+
+ +{* vim:set et sw=2 sts=2 sws=2 enc=utf-8: *} -- 2.1.4