4 require_once __DIR__
. '/../_inc.php';
6 if ($user['droits']['compta'] < Membres
::DROIT_ADMIN
)
8 throw new UserException("Vous n'avez pas le droit d'accéder à cette page.");
11 $cats = new Compta_Categories
;
13 $id = (int)utils
::get('id');
14 $cat = $cats->get($id);
18 throw new UserException('Cette catégorie n\'existe pas.');
23 if (!empty($_POST['save']))
25 if (!utils
::CSRF_check('compta_edit_cat_'.$cat['id']))
27 $error = 'Une erreur est survenue, merci de renvoyer le formulaire.';
33 $id = $cats->edit($id, [
34 'intitule' => utils
::post('intitule'),
35 'description' => utils
::post('description'),
38 if ($cat['type'] == Compta_Categories
::DEPENSES
)
40 elseif ($cat['type'] == Compta_Categories
::AUTRES
)
45 utils
::redirect('/admin/compta/categories/?'.$type);
47 catch (UserException
$e)
49 $error = $e->getMessage();
54 $tpl->assign('error', $error);
55 $tpl->assign('cat', $cat);
57 $tpl->display('admin/compta/categories/modifier.tpl');