4 require_once __DIR__
. '/../../../_inc.php';
6 if ($user['droits']['membres'] < Membres
::DROIT_ADMIN
)
8 throw new UserException("Vous n'avez pas le droit d'accéder à cette page.");
11 if (!utils
::get('id') ||
!is_numeric(utils
::get('id')))
13 throw new UserException("Argument du numéro de cotisation manquant.");
16 $cotisations = new Cotisations
;
18 $co = $cotisations->get(utils
::get('id'));
19 $cats = new Compta_Categories
;
23 throw new UserException("Cette cotisation n'existe pas.");
28 if (!empty($_POST['save']))
30 if (!utils
::CSRF_check('edit_co_' . $co['id']))
32 $error = 'Une erreur est survenue, merci de renvoyer le formulaire.';
37 $duree = utils
::post('periodicite') == 'jours' ?
(int) utils
::post('duree') : null;
38 $debut = utils
::post('periodicite') == 'date' ? utils
::post('debut') : null;
39 $fin = utils
::post('periodicite') == 'date' ? utils
::post('fin') : null;
40 $id_cat = utils
::post('categorie') ?
(int) utils
::post('id_categorie_compta') : null;
42 $cotisations->edit($co['id'], [
43 'intitule' => utils
::post('intitule'),
44 'description' => utils
::post('description'),
45 'montant' => (float) utils
::post('montant'),
49 'id_categorie_compta'=> $id_cat,
52 utils
::redirect('/admin/membres/cotisations/');
54 catch (UserException
$e)
56 $error = $e->getMessage();
61 $tpl->assign('error', $error);
63 $co['periodicite'] = $co['duree'] ?
'jours' : ($co['debut'] ?
'date' : 'ponctuel');
64 $co['categorie'] = $co['id_categorie_compta'] ?
1 : 0;
66 $tpl->assign('cotisation', $co);
67 $tpl->assign('categories', $cats->getList(Compta_Categories
::RECETTES
));
69 $tpl->display('admin/membres/cotisations/gestion/modifier.tpl');