'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'),
);
}
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:
<td>
<a href="admin/sectors">Secteurs</a>
|
- <a href="admin/networking">Networking</a>
+ <a href="admin/jobs">Entreprises</a>
|
<a href="admin/corps_enum">Corps</a>
|
<a href="admin/sections">Sections</a>
|
<a href="admin/names">Noms</a>
+ |
+ <a href="admin/networking">Networking</a>
</td>
</tr>
<tr class="impair">
--- /dev/null
+{**************************************************************************}
+{* *}
+{* 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 *}
+{* *}
+{**************************************************************************}
+
+<h1>Entreprises</h1>
+
+{if $jobs}
+<p>
+ Liste des entreprises correspondant à ta recherche :
+ <ul>
+ {foreach from=$jobs item=job}
+ <li>{$job.name}{if $job.acronym} ({$job.acronym}){/if}
+ <a href="admin/jobs/{$job.id}">{icon name="page_edit" title="Éditer"}</a></li>
+ {/foreach}
+ </ul>
+{/if}
+
+{if $selectedJob}
+<form action="admin/jobs/{$selectedJob.id}" method="post">
+{xsrf_token_field}
+ <table class="bicol">
+ <tr>
+ <th colspan="2">Entreprise n° {$selectedJob.id}</th>
+ </tr>
+ <tr>
+ <td>Nom</td>
+ <td><input type="text" name="name" value="{$selectedJob.name}" /></td>
+ </tr>
+ <td>Acronyme</td>
+ <td><input type="text" name="acronym" value="{$selectedJob.acronym}" /></td>
+ </tr>
+ </tr>
+ <td>Page web</td>
+ <td><input type="text" name="url" value="{$selectedJob.url}" /></td>
+ </tr>
+ </tr>
+ <td>Adresse email</td>
+ <td><input type="text" name="email" value="{$selectedJob.email}" /></td>
+ </tr>
+ </tr>
+ <td>Code NAF</td>
+ <td><input type="text" name="NAF_code" value="{$selectedJob.NAF_code}" /></td>
+ </tr>
+ </tr>
+ <td>Code AX</td>
+ <td><input type="text" name="AX_code" value="{$selectedJob.AX_code}" /></td>
+ </tr>
+ </tr>
+ <td>Identifiant de la holding</td>
+ <td><input type="text" name="holdingId" value="{$selectedJob.holdingId}" /></td>
+ </tr>
+ </tr>
+ <td>Nom de la holding</td>
+ <td>{$selectedJob.holdingName}</td>
+ </tr>
+ </tr>
+ <td>Acronyme de la holding</td>
+ <td>{$selectedJob.holdingAcronym}</td>
+ </tr>
+ <tr>
+ <td>Remplacer par l'entreprise n°</td>
+ <td><input type="text" name="newJobId" /></td>
+ </tr>
+ </table>
+ <p>
+ Confirmation du remplacement de cette entreprise :
+ <input type="checkbox" name="change" /><br />
+ <input type="submit" name="edit" value="Éditer" />
+ </p>
+</form>
+{/if}
+
+<form action="" method="get">
+ <p>
+ Nom ou acronyme de l'entreprise :
+ <input type="text" name="job" value="{$askedJob}" /><br />
+ <input type="submit" name="search" value="Rechercher" />
+ </p>
+</form>
+
+{* vim:set et sw=2 sts=2 sws=2 enc=utf-8: *}