Ajout du support des écritures ventilées.
[garradin.git] / www / admin / compta / operations / supprimer.php
1 <?php
2 namespace Garradin;
3
4 require_once __DIR__ . '/../_inc.php';
5
6 if ($user['droits']['compta'] < Membres::DROIT_ADMIN)
7 {
8 throw new UserException("Vous n'avez pas le droit d'accéder à cette page.");
9 }
10
11 $journal = new Compta_Journal;
12
13 $operation = $journal->get(utils::get('id'));
14
15 if (!$operation)
16 {
17 throw new UserException("L'opération demandée n'existe pas.");
18 }
19
20 $error = false;
21
22 if (!empty($_POST['delete']))
23 {
24 if (!utils::CSRF_check('compta_supprimer_'.$operation['id']))
25 {
26 $error = 'Une erreur est survenue, merci de renvoyer le formulaire.';
27 }
28 else
29 {
30 try
31 {
32 $journal->delete($operation['id']);
33 utils::redirect('/admin/compta/operations/');
34 }
35 catch (UserException $e)
36 {
37 $error = $e->getMessage();
38 }
39 }
40 }
41
42 $tpl->assign('error', $error);
43
44 $tpl->assign('operation', $operation);
45
46 $tpl->display('admin/compta/operations/supprimer.tpl');
47
48 ?>