296 |
aurelien |
1 |
<?php
|
|
|
2 |
|
|
|
3 |
class CotisationModele extends AnnuaireModele {
|
|
|
4 |
|
|
|
5 |
public function __construct() {
|
|
|
6 |
parent::__construct();
|
|
|
7 |
}
|
|
|
8 |
|
|
|
9 |
public function obtenirInformationsCotisationsPourInscrit($id_inscrit) {
|
|
|
10 |
|
|
|
11 |
$requete_informations_cotisation = 'SELECT * FROM '.Config::get('cotisation_bdd').'.'.Config::get('cotisation_table').' '.
|
|
|
12 |
'WHERE IC_ANNU_ID = '.$this->proteger($id_inscrit).' '.
|
|
|
13 |
'ORDER BY IC_DATE ';
|
|
|
14 |
|
|
|
15 |
$infos_cotisation_inscrit = $this->requeteTous($requete_informations_cotisation);
|
|
|
16 |
|
|
|
17 |
return $infos_cotisation_inscrit;
|
|
|
18 |
}
|
|
|
19 |
|
|
|
20 |
public function obtenirInformationsPourIdCotisation($id_cotisation, $id_inscrit) {
|
|
|
21 |
|
|
|
22 |
$requete_informations_cotisation = 'SELECT * FROM '.Config::get('cotisation_bdd').'.'.Config::get('cotisation_table').' '.
|
|
|
23 |
'WHERE '.
|
|
|
24 |
'IC_ID = '.$this->proteger($id_cotisation).' '.
|
|
|
25 |
'AND IC_ANNU_ID = '.$this->proteger($id_inscrit);
|
|
|
26 |
|
|
|
27 |
$infos_cotisation = $this->requeteUn($requete_informations_cotisation);
|
|
|
28 |
|
|
|
29 |
return $infos_cotisation;
|
|
|
30 |
}
|
|
|
31 |
|
|
|
32 |
public function ajouterCotisation($params) {
|
|
|
33 |
|
|
|
34 |
$requete_creation_cotisation = 'INSERT INTO '.Config::get('cotisation_bdd').'.annuaire_COTISATION '.
|
|
|
35 |
'(IC_MC_ID, IC_ANNU_ID, IC_DATE, IC_MONTANT) '.
|
|
|
36 |
'VALUES ('.
|
|
|
37 |
$this->proteger($params['mode_cotisation']).','.
|
|
|
38 |
$this->proteger($params['id_cotisant']).','.
|
|
|
39 |
$this->proteger($params['date_cotisation']).','.
|
|
|
40 |
$this->proteger($params['montant_cotisation']).' '.
|
|
|
41 |
')';
|
|
|
42 |
|
|
|
43 |
return $this->requete($requete_creation_cotisation);
|
|
|
44 |
}
|
|
|
45 |
|
|
|
46 |
public function MettreAJourCotisation($id_cotisation, $params) {
|
|
|
47 |
|
|
|
48 |
$requete_modification_cotisation = 'UPDATE '.Config::get('cotisation_bdd').'.annuaire_COTISATION '.
|
|
|
49 |
'SET '.
|
|
|
50 |
'IC_MC_ID ='.$this->proteger($params['mode_cotisation']).','.
|
|
|
51 |
'IC_DATE ='.$this->proteger($params['date_cotisation']).','.
|
|
|
52 |
'IC_MONTANT ='.$this->proteger($params['montant_cotisation']).' '.
|
|
|
53 |
'WHERE IC_ID = '.$this->proteger($id_cotisation);
|
|
|
54 |
|
|
|
55 |
return $this->requete($requete_modification_cotisation);
|
|
|
56 |
}
|
|
|
57 |
|
|
|
58 |
public function supprimerCotisation($id_cotisation) {
|
|
|
59 |
|
|
|
60 |
$requete_suppression_cotisation = 'DELETE FROM '.Config::get('cotisation_bdd').'.annuaire_COTISATION '.
|
|
|
61 |
'WHERE IC_ID = '.$this->proteger($id_cotisation);
|
|
|
62 |
|
|
|
63 |
return $this->requete($requete_suppression_cotisation);
|
|
|
64 |
}
|
|
|
65 |
|
|
|
66 |
public function obtenirListeModesCotisation() {
|
|
|
67 |
|
|
|
68 |
$modes_cotisation = array(0 => 'Chèque',
|
|
|
69 |
1 => 'Espèce',
|
|
|
70 |
2 => 'Virement',
|
|
|
71 |
3 => 'Paypal',
|
|
|
72 |
4 => 'Prélèvement'
|
|
|
73 |
);
|
|
|
74 |
|
|
|
75 |
//FIXME : en attendant de savoir si on déplace le contenu de la table mode_cotisation dans les triples
|
|
|
76 |
return $modes_cotisation;
|
|
|
77 |
}
|
|
|
78 |
|
|
|
79 |
public function obtenirModeCotisationParId($id_mode) {
|
|
|
80 |
|
|
|
81 |
$modes_cotisation = array(0 => 'Chèque',
|
|
|
82 |
1 => 'Espèce',
|
|
|
83 |
2 => 'Virement',
|
|
|
84 |
3 => 'Paypal',
|
|
|
85 |
4 => 'Prélèvement'
|
|
|
86 |
);
|
|
|
87 |
|
|
|
88 |
|
|
|
89 |
//FIXME : en attendant de savoir si on déplace le contenu de la table mode_cotisation dans les triples
|
|
|
90 |
return $modes_cotisation[$id_mode];
|
|
|
91 |
|
|
|
92 |
$requete_infos_mode = 'SELECT MC_LABEL as mode_label FROM MODE_COTISATION WHERE MC_ID = '.$this->proteger($id_mode);
|
|
|
93 |
|
|
|
94 |
$infos_mode = $this->requete($requete_infos_mode);
|
|
|
95 |
|
|
|
96 |
if(!empty($infos_mode)) {
|
|
|
97 |
$infos_mode = $infos_mode[0];
|
|
|
98 |
}
|
|
|
99 |
|
|
|
100 |
return $infos_mode['mode_label'];
|
|
|
101 |
}
|
|
|
102 |
|
336 |
aurelien |
103 |
public function calculerNouvelOrdreRecuEtIncrementer($annee) {
|
|
|
104 |
|
|
|
105 |
$numero_recu = $this->numeroRecuExistePourAnnee($annee);
|
296 |
aurelien |
106 |
|
336 |
aurelien |
107 |
if($numero_recu == null) {
|
|
|
108 |
$numero_recu = $this->initialiserNumeroRecuPourAnnee($annee);
|
|
|
109 |
}
|
296 |
aurelien |
110 |
|
|
|
111 |
$requete_incrementation_ordre = 'UPDATE '.Config::get('cotisation_bdd').'.COMPTEUR_COTISATION '.
|
336 |
aurelien |
112 |
'SET COMPTEUR = COMPTEUR + 1 '.
|
|
|
113 |
'WHERE ANNEE = "'.$annee.'"';
|
|
|
114 |
|
296 |
aurelien |
115 |
$resultat_requete_incrementation_ordre = $this->requete($requete_incrementation_ordre) ;
|
|
|
116 |
|
336 |
aurelien |
117 |
return $numero_recu;
|
296 |
aurelien |
118 |
}
|
|
|
119 |
|
336 |
aurelien |
120 |
private function numeroRecuExistePourAnnee($annee) {
|
|
|
121 |
|
|
|
122 |
$requete_selection_num_recu_annee = 'SELECT COMPTEUR ' .
|
|
|
123 |
'FROM '.Config::get('cotisation_bdd').'.COMPTEUR_COTISATION ' .
|
|
|
124 |
'WHERE ANNEE = "'.$annee.'"';
|
|
|
125 |
|
|
|
126 |
$resultat_selection_num_recu_annee = $this->requeteUn($requete_selection_num_recu_annee);
|
|
|
127 |
|
|
|
128 |
$num_recu = null;
|
|
|
129 |
|
|
|
130 |
if($resultat_selection_num_recu_annee) {
|
|
|
131 |
$num_recu = $resultat_selection_num_recu_annee['COMPTEUR'];
|
|
|
132 |
}
|
|
|
133 |
|
|
|
134 |
return $num_recu;
|
|
|
135 |
}
|
|
|
136 |
|
|
|
137 |
private function initialiserNumeroRecuPourAnnee($annee) {
|
|
|
138 |
|
|
|
139 |
$requete_insertion_num_recu_annee = 'INSERT INTO '.Config::get('cotisation_bdd').'.COMPTEUR_COTISATION ' .
|
|
|
140 |
'(COMPTEUR, ANNEE) '.
|
|
|
141 |
'VALUES ('.
|
|
|
142 |
'1,'.
|
|
|
143 |
$this->proteger($annee).
|
|
|
144 |
')';
|
|
|
145 |
|
|
|
146 |
$resultat_insertion_num_recu_annee = $this->requete($requete_insertion_num_recu_annee);
|
|
|
147 |
|
|
|
148 |
$num_nouveau_recu = 1;
|
|
|
149 |
if(!$resultat_insertion_num_recu_annee) {
|
|
|
150 |
$num_nouveau_recu = null;
|
|
|
151 |
}
|
|
|
152 |
|
|
|
153 |
return $num_nouveau_recu;
|
|
|
154 |
}
|
|
|
155 |
|
296 |
aurelien |
156 |
public function mettreAJourNumeroRecu($id_cotisation, $id_recu) {
|
|
|
157 |
|
|
|
158 |
$requete_maj_num_recu_cotisation = 'UPDATE '.Config::get('cotisation_bdd').'.annuaire_COTISATION '.
|
|
|
159 |
'SET '.
|
|
|
160 |
'IC_RECU = '.$this->proteger($id_recu).' '.
|
|
|
161 |
'WHERE IC_ID = '.$this->proteger($id_cotisation);
|
|
|
162 |
|
|
|
163 |
$resultat_maj_envoi_num_cotisation = $this->requete($requete_maj_num_recu_cotisation) ;
|
|
|
164 |
|
328 |
aurelien |
165 |
return $id_recu;
|
296 |
aurelien |
166 |
}
|
|
|
167 |
|
|
|
168 |
public function mettreAJourDateEnvoiRecu($id_cotisation) {
|
|
|
169 |
|
|
|
170 |
$requete_maj_envoi_recu_cotisation = 'UPDATE '.Config::get('cotisation_bdd').'.annuaire_COTISATION '.
|
|
|
171 |
'SET '.
|
|
|
172 |
'IC_DATE_ENVOIE_RECU = NOW() '.
|
|
|
173 |
'WHERE IC_ID = '.$this->proteger($id_cotisation);
|
|
|
174 |
|
|
|
175 |
$resultat_maj_envoi_recu_cotisation = $this->requete($requete_maj_envoi_recu_cotisation) ;
|
|
|
176 |
|
|
|
177 |
return $resultat_maj_envoi_recu_cotisation;
|
|
|
178 |
}
|
|
|
179 |
|
|
|
180 |
protected function renvoyerDernierIdInsere() {
|
|
|
181 |
//TODO: cela marche t'il partout ?
|
|
|
182 |
// à faire: tester le type de driver pdo et faire une fonction portable
|
|
|
183 |
return $this->connexion->lastInsertId();
|
|
|
184 |
}
|
|
|
185 |
}
|
|
|
186 |
?>
|