4 require_once __DIR__
. '/../../_inc.php';
6 if ($user['droits']['membres'] < Membres
::DROIT_ECRITURE
)
8 throw new UserException("Vous n'avez pas le droit d'accéder à cette page.");
13 if (!empty($_GET['id']) && is_numeric($_GET['id']))
15 $membre = $membres->get((int) $_GET['id']);
19 throw new UserException("Ce membre n'existe pas.");
22 $cats = new Membres_Categories
;
23 $categorie = $cats->get($membre['id_categorie']);
27 $categorie = ['id_cotisation_obligatoire' => false];
30 $cotisations = new Cotisations
;
31 $m_cotisations = new Cotisations_Membres
;
33 $cats = new Compta_Categories
;
34 $banques = new Compta_Comptes_Bancaires
;
38 if (!empty($_POST['add']))
40 if (!utils
::CSRF_check('add_cotisation'))
42 $error = 'Une erreur est survenue, merci de renvoyer le formulaire.';
48 'date' => utils
::post('date'),
49 'id_cotisation' => utils
::post('id_cotisation'),
50 'id_membre' => utils
::post('id_membre'),
51 'id_auteur' => $user['id'],
52 'montant' => utils
::post('montant'),
53 'moyen_paiement' => utils
::post('moyen_paiement'),
54 'numero_cheque' => utils
::post('numero_cheque'),
55 'banque' => utils
::post('banque'),
58 $m_cotisations->add($data);
60 utils
::redirect('/admin/membres/cotisations.php?id=' . (int)utils
::post('id_membre'));
62 catch (UserException
$e)
64 $error = $e->getMessage();
69 $tpl->assign('error', $error);
70 $tpl->assign('membre', $membre);
72 $tpl->assign('cotisations', $cotisations->listCurrent());
74 $tpl->assign('default_co', null);
75 $tpl->assign('default_amount', 0.00);
76 $tpl->assign('default_date', date('Y-m-d'));
77 $tpl->assign('default_compta', null);
79 $tpl->assign('moyens_paiement', $cats->listMoyensPaiement());
80 $tpl->assign('moyen_paiement', utils
::post('moyen_paiement') ?
: 'ES');
81 $tpl->assign('comptes_bancaires', $banques->getList());
82 $tpl->assign('banque', utils
::post('banque'));
85 if (utils
::get('cotisation'))
87 $co = $cotisations->get(utils
::get('cotisation'));
91 throw new UserException("La cotisation indiquée en paramètre n'existe pas.");
94 $tpl->assign('default_co', $co['id']);
95 $tpl->assign('default_compta', $co['id_categorie_compta']);
96 $tpl->assign('default_amount', $co['montant']);
100 if (!empty($categorie['id_cotisation_obligatoire']))
102 $co = $cotisations->get($categorie['id_cotisation_obligatoire']);
104 $tpl->assign('default_co', $co['id']);
105 $tpl->assign('default_amount', $co['montant']);
110 $tpl->display('admin/membres/cotisations/ajout.tpl');