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 rappel manquant.");
16 $rappels = new Rappels
;
18 $rappel = $rappels->get(utils
::get('id'));
22 throw new UserException("Ce rappel n'existe pas.");
25 $cotisations = new Cotisations
;
29 if (!empty($_POST['save']))
31 if (!utils
::CSRF_check('edit_rappel_' . $rappel['id']))
33 $error = 'Une erreur est survenue, merci de renvoyer le formulaire.';
38 if (utils
::post('delai_choix') == 0)
40 elseif (utils
::post('delai_choix') > 0)
41 $delai = (int) utils
::post('delai_post');
43 $delai = -(int) utils
::post('delai_pre');
45 $rappels->edit($rappel['id'], [
46 'sujet' => utils
::post('sujet'),
47 'texte' => utils
::post('texte'),
49 'id_cotisation' => utils
::post('id_cotisation'),
52 utils
::redirect('/admin/membres/cotisations/gestion/rappels.php');
54 catch (UserException
$e)
56 $error = $e->getMessage();
61 $tpl->assign('error', $error);
63 $rappel['delai_pre'] = $rappel['delai_post'] = abs($rappel['delai']) ?
: 30;
64 $rappel['delai_choix'] = $rappel['delai'] == 0 ?
0 : ($rappel['delai'] > 0 ?
1 : -1);
66 $tpl->assign('rappel', $rappel);
67 $tpl->assign('cotisations', $cotisations->listCurrent());
69 $tpl->display('admin/membres/cotisations/gestion/rappel_modifier.tpl');