init
[garradin.git] / www / admin / membres / cotisations / gestion / rappels.php
1 <?php
2 namespace Garradin;
3
4 require_once __DIR__ . '/../../../_inc.php';
5
6 if ($user['droits']['membres'] < Membres::DROIT_ADMIN)
7 {
8 throw new UserException("Vous n'avez pas le droit d'accéder à cette page.");
9 }
10
11 $rappels = new Rappels;
12 $cotisations = new Cotisations;
13
14 $error = false;
15
16 if (!empty($_POST['save']))
17 {
18 if (!utils::CSRF_check('new_rappel'))
19 {
20 $error = 'Une erreur est survenue, merci de renvoyer le formulaire.';
21 }
22 else
23 {
24 try {
25 if (utils::post('delai_choix') == 0)
26 $delai = 0;
27 elseif (utils::post('delai_choix') > 0)
28 $delai = (int) utils::post('delai_post');
29 else
30 $delai = -(int) utils::post('delai_pre');
31
32 $rappels->add([
33 'sujet' => utils::post('sujet'),
34 'texte' => utils::post('texte'),
35 'delai' => $delai,
36 'id_cotisation' => utils::post('id_cotisation'),
37 ]);
38
39 utils::redirect('/admin/membres/cotisations/gestion/rappels.php');
40 }
41 catch (UserException $e)
42 {
43 $error = $e->getMessage();
44 }
45 }
46 }
47
48 $tpl->assign('error', $error);
49
50 $tpl->assign('liste', $rappels->listByCotisation());
51 $tpl->assign('cotisations', $cotisations->listCurrent());
52
53 $tpl->assign('default_subject', '[#NOM_ASSO] Échéance de cotisation');
54 $tpl->assign('default_text', "Bonjour #IDENTITE,\n\nVotre cotisation arrive à échéance dans #NB_JOURS jours.\n\n"
55 . "Merci de nous contacter pour renouveler votre cotisation.\n\nCordialement.\n\n"
56 . "--\n#NOM_ASSO\n#ADRESSE_ASSO\nE-Mail : #EMAIL_ASSO\nSite web : #SITE_ASSO");
57
58 $tpl->display('admin/membres/cotisations/gestion/rappels.tpl');
59
60 ?>