Overview
Comment: | Modification d'exercice |
---|---|
Downloads: | Tarball | ZIP archive | SQL archive |
Timelines: | family | ancestors | descendants | both | trunk |
Files: | files | file ages | folders |
SHA1: |
aaff552f5eeae0dcf3280a92130cc349 |
User & Date: | bohwaz on 2012-10-15 01:05:32 |
Other Links: | manifest | tags |
Context
2012-10-15
| ||
01:13 | Suppression d'exercice check-in: 7581683c14 user: bohwaz tags: trunk | |
01:05 | Modification d'exercice check-in: aaff552f5e user: bohwaz tags: trunk | |
00:57 | Correction des droits, il faut le droit admin pour modifier ou supprimer une opération, le droit écriture ne permet que d'ajouter des opérations check-in: 3cff2afeea user: bohwaz tags: trunk | |
Changes
Modified include/class.compta_exercices.php from [7148b6946a] to [5cfc97fc59].
︙ | ︙ | |||
31 32 33 34 35 36 37 38 39 40 41 42 43 44 | public function edit($id, $data) { $db = Garradin_DB::getInstance(); $this->_checkFields($data); if ($db->simpleQuerySingle('SELECT 1 FROM compta_exercices WHERE id != :id AND ((debut <= :debut AND fin >= :debut) OR (debut <= :fin AND fin >= :fin));', false, array('debut' => $data['debut'], 'fin' => $data['fin'], 'id' => (int) $id))) { throw new UserException('La date de début ou de fin se recoupe avec un autre exercice.'); } | > > > > > > > > > > > > > > | | 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 | public function edit($id, $data) { $db = Garradin_DB::getInstance(); $this->_checkFields($data); // Evitons que les exercices se croisent if ($db->simpleQuerySingle('SELECT 1 FROM compta_exercices WHERE id != :id AND ((debut <= :debut AND fin >= :debut) OR (debut <= :fin AND fin >= :fin));', false, array('debut' => $data['debut'], 'fin' => $data['fin'], 'id' => (int) $id))) { throw new UserException('La date de début ou de fin se recoupe avec un autre exercice.'); } // On vérifie qu'on ne va pas mettre des opérations en dehors de tout exercice if ($db->simpleQuerySingle('SELECT 1 FROM compta_journal WHERE id_exercice = ? AND date < ? LIMIT 1;', false, (int)$id, $data['debut'])) { throw new UserException('Des opérations de cet exercice ont une date antérieure à la date de début de l\'exercice.'); } if ($db->simpleQuerySingle('SELECT 1 FROM compta_journal WHERE id_exercice = ? AND date > ? LIMIT 1;', false, (int)$id, $data['fin'])) { throw new UserException('Des opérations de cet exercice ont une date postérieure à la date de fin de l\'exercice.'); } $db->simpleUpdate('compta_exercices', array( 'libelle' => trim($data['libelle']), 'debut' => $data['debut'], 'fin' => $data['fin'], ), 'id = \''.(int)$id.'\''); return true; } |
︙ | ︙ |
Added templates/admin/compta/exercice_modifier.tpl version [eb9b21bb41].
> > > > > > > > > > > > > > > > > > > > > > > > > > > > > > | 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 | {include file="admin/_head.tpl" title="Modifier un exercice" current="compta/exercices"} {if $error} <p class="error"> {$error|escape} </p> {/if} <form method="post" action="{$self_url|escape}"> <fieldset> <legend>Modifier un exercice</legend> <dl> <dt><label for="f_libelle">Libellé</label> <b title="(Champ obligatoire)">obligatoire</b></dt> <dd><input type="text" name="libelle" id="f_libelle" value="{form_field name=libelle data=$exercice}" /></dd> <dt><label for="f_debut">Début de l'exercice</label> <b title="(Champ obligatoire)">obligatoire</b></dt> <dd><input type="date" name="debut" id="f_debut" value="{form_field name=debut default=$exercice.debut|date_fr:'Y-m-d'}" size="10" /></dd> <dt><label for="f_fin">Fin de l'exercice</label> <b title="(Champ obligatoire)">obligatoire</b></dt> <dd><input type="date" name="fin" id="f_fin" value="{form_field name=fin default=$exercice.fin|date_fr:'Y-m-d'}" size="10" /></dd> </dl> </fieldset> <p class="submit"> {csrf_field key="compta_ajout_exercice"} <input type="submit" name="add" value="Enregistrer →" /> </p> </form> {include file="admin/_foot.tpl"} |
Added www/admin/compta/exercice_modifier.php version [e32b2cc8f3].
> > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > | 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 | <?php require_once __DIR__ . '/_inc.php'; if ($user['droits']['compta'] < Garradin_Membres::DROIT_ADMIN) { throw new UserException("Vous n'avez pas le droit d'accéder à cette page."); } require_once GARRADIN_ROOT . '/include/class.compta_exercices.php'; $e = new Garradin_Compta_Exercices; $exercice = $e->get((int)utils::get('id')); if (!$exercice) { throw new UserException('Exercice inconnu.'); } $error = false; if (!empty($_POST['add'])) { if (!utils::CSRF_check('compta_ajout_exercice')) { $error = 'Une erreur est survenue, merci de renvoyer le formulaire.'; } else { try { $id = $e->edit($exercice['id'], array( 'libelle' => utils::post('libelle'), 'debut' => utils::post('debut'), 'fin' => utils::post('fin'), )); utils::redirect('/admin/compta/exercices.php'); } catch (UserException $e) { $error = $e->getMessage(); } } } $tpl->assign('error', $error); $tpl->assign('exercice', $exercice); $tpl->assign('custom_js', array('datepickr.js')); $tpl->display('admin/compta/exercice_modifier.tpl'); ?> |