Subversion Repositories Applications.annuaire

Rev

Rev 336 | Only display areas with differences | Ignore whitespace | Details | Blame | Last modification | View Log | RSS feed

Rev 336 Rev 514
1
<?php
1
<?php
2
class Cotisation extends AppControleur {
2
class Cotisation extends AppControleur {
3
	
3
	
4
	public function Cotisation() {
4
	public function Cotisation() {
5
		
5
		
6
		parent::__construct();
6
		parent::__construct();
7
	}
7
	}
8
	
8
	
9
    /**
9
    /**
10
     * Initialisation du controleur principal en fonction des paramètres de l'url.
10
     * Initialisation du controleur principal en fonction des paramètres de l'url.
11
     */
11
     */
12
    public function executerPlugin() {
12
    public function executerPlugin() {
13
    	
13
    	
14
    	$plugin_action = Config::get('plugin_variable_action');
14
    	$plugin_action = Config::get('plugin_variable_action');
15
    	    	               
15
    	    	               
16
        if (isset($_GET[$plugin_action])) {
16
        if (isset($_GET[$plugin_action])) {
17
            $action = $_GET[$plugin_action];
17
            $action = $_GET[$plugin_action];
18
        } else {
18
        } else {
19
        	$action = Config::get('plugin_action_defaut');
19
        	$action = Config::get('plugin_action_defaut');
20
        }
20
        }
21
        
21
        
22
        if(!$this->controleAccesAdmin($action)) {
22
        if(!$this->controleAccesAdmin($action)) {
23
        	return;
23
        	return;
24
        }
24
        }
25
        
25
        
26
        unset($_GET[$plugin_action]);
26
        unset($_GET[$plugin_action]);
27
       
27
       
28
        $resultat_action_plugin = $this->$action($_GET);
28
        $resultat_action_plugin = $this->$action($_GET);
29
        
29
        
30
        return $resultat_action_plugin ;
30
        return $resultat_action_plugin ;
31
    }
31
    }
32
	   
32
	   
33
    /**
33
    /**
34
     * Méthode appelée pour ajouter un élément.
34
     * Méthode appelée pour ajouter un élément.
35
     */
35
     */
36
    public function ajouterCotisation() {
36
    public function ajouterCotisation() {
37
    	
37
    	
38
    	$params = $_POST;
38
    	$params = $_POST;
39
    	
39
    	
40
    	$elements_requis = array('id_cotisant','date_cotisation', 'montant_cotisation', 'mode_cotisation');
40
    	$elements_requis = array('id_cotisant','date_cotisation', 'montant_cotisation', 'mode_cotisation');
41
    	$erreurs = array();
41
    	$erreurs = array();
42
        
42
        
43
    	foreach($elements_requis as $requis) {
43
    	foreach($elements_requis as $requis) {
44
    		if(!isset($params[$requis])) {
44
    		if(!isset($params[$requis])) {
45
    			//$erreurs[$requis] = 'erreur ';
45
    			//$erreurs[$requis] = 'erreur ';
46
    		}
46
    		}
47
    	}
47
    	}
48
    	
48
    	
49
    	if(!empty($erreurs)) {
49
    	if(!empty($erreurs)) {
50
    		$this->envoyer($erreurs);
50
    		$this->envoyer($erreurs);
51
    	}
51
    	}
-
 
52
    	
-
 
53
    	$annuaire_modele = $this->getModele('AnnuaireModele');
-
 
54
    	$params['infos_utilisateur'] = $annuaire_modele->obtenirInfosUtilisateurParId($elements_requis['id_cotisant']);
52
    	
55
    	
53
    	$params['date_cotisation'] = $this->formaterVersDateMysql($params['date_cotisation']);
56
    	$params['date_cotisation'] = $this->formaterVersDateMysql($params['date_cotisation']);
54
 
57
 
55
    	$cotisation_modele = new CotisationModele(); 
58
    	$cotisation_modele = new CotisationModele(); 
56
    	$ajout_cotisation = $cotisation_modele->ajouterCotisation($params);
59
    	$ajout_cotisation = $cotisation_modele->ajouterCotisation($params);
57
		
60
		
58
		if(!$ajout_cotisation) {
61
		if(!$ajout_cotisation) {
59
    		$retour['erreurs'] = 'erreur d\'insertion';
62
    		$retour['erreurs'] = 'erreur d\'insertion';
60
    	}
63
    	}
61
    	
64
    	
62
    	$retour['id_utilisateur'] = $params['id_cotisant'];
65
    	$retour['id_utilisateur'] = $params['id_cotisant'];
63
    	
66
    	
64
    	return $this->afficherInformationsCotisationPourInscrit($retour);
67
    	return $this->afficherInformationsCotisationPourInscrit($retour);
65
    	
68
    	
66
    }
69
    }
67
   
70
   
68
    /**
71
    /**
69
     * Méthode appelée pour mettre à jour une cotisation
72
     * Méthode appelée pour mettre à jour une cotisation
70
     */
73
     */
71
    public function mettreAJourCotisation()    {
74
    public function mettreAJourCotisation()    {
72
    	
75
    	
73
    	$params = $_POST;
76
    	$params = $_POST;
74
    	
77
    	
75
    	$id_cotisation = $params['id_cotisation'];
78
    	$id_cotisation = $params['id_cotisation'];
76
    	
79
    	
77
    	$elements_requis = array('id_cotisation','id_cotisant','date_cotisation', 'montant_cotisation', 'mode_cotisation');
80
    	$elements_requis = array('id_cotisation','id_cotisant','date_cotisation', 'montant_cotisation', 'mode_cotisation');
78
    	$erreurs = array();
81
    	$erreurs = array();
79
        
82
        
80
    	foreach($elements_requis as $requis) {
83
    	foreach($elements_requis as $requis) {
81
    		if(!isset($params[$requis])) {
84
    		if(!isset($params[$requis])) {
82
    			//$erreurs[$requis] = 'erreur ';
85
    			//$erreurs[$requis] = 'erreur ';
83
    		}
86
    		}
84
    	}
87
    	}
85
    	
88
    	
86
    	if(!empty($erreurs)) {
89
    	if(!empty($erreurs)) {
87
    		$this->envoyer($erreurs);
90
    		$this->envoyer($erreurs);
88
    	}
91
    	}
89
    	    	
92
    	    	
90
    	$params['date_cotisation'] = $this->formaterVersDateMysql($params['date_cotisation']);
93
    	$params['date_cotisation'] = $this->formaterVersDateMysql($params['date_cotisation']);
91
    	
94
    	
92
    	$cotisation_modele = new CotisationModele(); 
95
    	$cotisation_modele = new CotisationModele(); 
93
    	$modification_cotisation = $cotisation_modele->mettreAJourCotisation($id_cotisation, $params);
96
    	$modification_cotisation = $cotisation_modele->mettreAJourCotisation($id_cotisation, $params);
94
    	
97
    	
95
		if(!$modification_cotisation) {
98
		if(!$modification_cotisation) {
96
    		$retour['erreurs'] = 'erreur d\'insertion';
99
    		$retour['erreurs'] = 'erreur d\'insertion';
97
    	}
100
    	}
98
    	
101
    	
99
    	$retour['id_utilisateur'] = $params['id_cotisant'];
102
    	$retour['id_utilisateur'] = $params['id_cotisant'];
100
    	
103
    	
101
    	return $this->afficherInformationsCotisationPourInscrit($retour);
104
    	return $this->afficherInformationsCotisationPourInscrit($retour);
102
    }
105
    }
103
   
106
   
104
    /**
107
    /**
105
     * Méthode appelée pour supprimer un élément
108
     * Méthode appelée pour supprimer un élément
106
     */
109
     */
107
    public function supprimerCotisation() {
110
    public function supprimerCotisation() {
108
		
111
		
109
    	$id_cotisation = $_GET['id_cotisation'];
112
    	$id_cotisation = $_GET['id_cotisation'];
110
    	
113
    	
111
    	$cotisation_modele = new CotisationModele(); 
114
    	$cotisation_modele = new CotisationModele(); 
112
    	$suppression_cotisation = $cotisation_modele->supprimerCotisation($id_cotisation);
115
    	$suppression_cotisation = $cotisation_modele->supprimerCotisation($id_cotisation);
113
    	
116
    	
114
    	if(!$suppression_cotisation) {
117
    	if(!$suppression_cotisation) {
115
    		// TODO: comment gère t'on les erreurs ?
118
    		// TODO: comment gère t'on les erreurs ?
116
    	}
119
    	}
117
    	
120
    	
118
    	$param['id_utilisateur'] = $_GET['id_utilisateur'];
121
    	$param['id_utilisateur'] = $_GET['id_utilisateur'];
119
    	
122
    	
120
    	return $this->afficherInformationsCotisationPourInscrit($param);
123
    	return $this->afficherInformationsCotisationPourInscrit($param);
121
    	
124
    	
122
    }
125
    }
123
    
126
    
124
     /**
127
     /**
125
     * 
128
     * 
126
	 * Affiche un tableau récapitulant les informations de l'historique des cotisations pour un membre donné 
129
	 * Affiche un tableau récapitulant les informations de l'historique des cotisations pour un membre donné 
127
     */
130
     */
128
    private function afficherInformationsCotisationPourInscrit($param) {
131
    private function afficherInformationsCotisationPourInscrit($param) {
129
    	
132
    	
130
    	$id_inscrit = $param['id_utilisateur'];
133
    	$id_inscrit = $param['id_utilisateur'];
131
    	
134
    	
132
    	if(!Registre::getInstance()->get('est_admin')) {
135
    	if(!Registre::getInstance()->get('est_admin')) {
133
    		$id_inscrit = Registre::getInstance()->get('identification_id');
136
    		$id_inscrit = Registre::getInstance()->get('identification_id');
134
    	}
137
    	}
135
    	
138
    	
136
    	$donnees['cotisations'] = $this->obtenirInformationsCotisationPourInscrit($param);
139
    	$donnees['cotisations'] = $this->obtenirInformationsCotisationPourInscrit($param);
-
 
140
    	
-
 
141
    	$donnees['infos_utilisateur'] = $this->getInformationsUtilisateur($id_inscrit);
137
    	
142
    	
138
    	$donnees['url_formulaire_ajout_cotisation'] = $this->getUrlFormulaireAjoutCotisation($id_inscrit);
143
    	$donnees['url_formulaire_ajout_cotisation'] = $this->getUrlFormulaireAjoutCotisation($id_inscrit);
139
    	
144
    	
140
    	if(isset($param['message'])) {
145
    	if(isset($param['message'])) {
141
    		$donnees['message'] = $param['message'];
146
    		$donnees['message'] = $param['message'];
142
    	}
147
    	}
143
    	
148
    	
144
    	if(Registre::getInstance()->get('est_admin')) {
149
    	if(Registre::getInstance()->get('est_admin')) {
145
    		$squelette = 'liste_cotisations_admin';
150
    		$squelette = 'liste_cotisations_admin';
146
    	} else {
151
    	} else {
147
    		$squelette = 'liste_cotisations_inscrit';
152
    		$squelette = 'liste_cotisations_inscrit';
148
    	}
153
    	}
149
    	
154
    	
150
    	$liste_cotisations_html = $this->renvoyerSquelette($squelette, $donnees);
155
    	$liste_cotisations_html = $this->renvoyerSquelette($squelette, $donnees);
151
    	
156
    	
152
    	return $liste_cotisations_html;
157
    	return $liste_cotisations_html;
153
    }
158
    }
154
        
159
        
155
    /**
160
    /**
156
     * 
161
     * 
157
	 *  Renvoie les informations de cotisation pour un membre donné 
162
	 *  Renvoie les informations de cotisation pour un membre donné 
158
     */
163
     */
159
	private function obtenirInformationsCotisationPourInscrit($param) {
164
	private function obtenirInformationsCotisationPourInscrit($param) {
160
			
165
			
161
		$id_inscrit = $param['id_utilisateur'];
166
		$id_inscrit = $param['id_utilisateur'];
162
		
167
		
163
		if(!Registre::getInstance()->get('est_admin')) {
168
		if(!Registre::getInstance()->get('est_admin')) {
164
    		$id_inscrit = Registre::getInstance()->get('identification_id');
169
    		$id_inscrit = Registre::getInstance()->get('identification_id');
165
    	}
170
    	}
166
		
171
		
167
		$cotisation_modele = new CotisationModele(); 
172
		$cotisation_modele = new CotisationModele(); 
168
		$infos_cotisation_inscrit = $cotisation_modele->obtenirInformationsCotisationsPourInscrit($id_inscrit);
173
		$infos_cotisation_inscrit = $cotisation_modele->obtenirInformationsCotisationsPourInscrit($id_inscrit);
169
		
174
		
170
    	$infos_cotisation_inscrit_formatees = array();
175
    	$infos_cotisation_inscrit_formatees = array();
171
    	
176
    	
172
    	foreach($infos_cotisation_inscrit as $cotisation_inscrit) {
177
    	foreach($infos_cotisation_inscrit as $cotisation_inscrit) {
173
    		$infos_cotisation_inscrit_formatees[] = $this->formaterInformationsCotisationPourEnvoi($cotisation_inscrit);
178
    		$infos_cotisation_inscrit_formatees[] = $this->formaterInformationsCotisationPourEnvoi($cotisation_inscrit);
174
    	}
179
    	}
175
    	
180
    	
176
    	return $infos_cotisation_inscrit_formatees;
181
    	return $infos_cotisation_inscrit_formatees;
177
	}
182
	}
178
    
183
    
179
	
184
	
180
	private function afficherFormulaireAjoutCotisation($param) {
185
	private function afficherFormulaireAjoutCotisation($param) {
181
    	
186
    	
182
		$donnees['id_cotisant'] = $param['id_cotisant'];
187
		$donnees['id_cotisant'] = $param['id_cotisant'];
183
		
188
		
184
    	$donnees['cotisations'] = $this->obtenirInformationsCotisationPourInscrit($param);
189
    	$donnees['cotisations'] = $this->obtenirInformationsCotisationPourInscrit($param);
185
    	
190
    	
186
    	$cotisation_modele = new CotisationModele(); 
191
    	$cotisation_modele = new CotisationModele(); 
187
    	$donnees['modes_cotisation'] = $cotisation_modele->obtenirListeModesCotisation();
192
    	$donnees['modes_cotisation'] = $cotisation_modele->obtenirListeModesCotisation();
188
    	
193
    	
189
    	$donnees['url_liste_cotisations'] = $this->getUrlVoirListeCotisations();
194
    	$donnees['url_liste_cotisations'] = $this->getUrlVoirListeCotisations();
190
    	
195
    	
191
    	$donnees['url_ajout_cotisation'] = $this->getUrlAjoutCotisation();
196
    	$donnees['url_ajout_cotisation'] = $this->getUrlAjoutCotisation();
192
    	
197
    	
193
    	$donnees['url_retour'] = $this->urlService();
198
    	$donnees['url_retour'] = $this->urlService();
-
 
199
    	
-
 
200
    	$donnees['infos_utilisateur'] = $this->getInformationsUtilisateur($donnees['id_cotisant']);
194
    	
201
    	
195
    	$liste_cotisations_html = $this->renvoyerSquelette('formulaire_ajout_cotisation', $donnees);
202
    	$liste_cotisations_html = $this->renvoyerSquelette('formulaire_ajout_cotisation', $donnees);
196
    	
203
    	
197
    	return $liste_cotisations_html;
204
    	return $liste_cotisations_html;
198
    }
205
    }
199
    
206
    
200
    private function afficherFormulaireModificationCotisation() {
207
    private function afficherFormulaireModificationCotisation() {
201
 
208
 
202
    	$param = $_GET;
209
    	$param = $_GET;
203
    	
210
    	
204
    	$donnees['id_utilisateur'] = $param['id_utilisateur'];
211
    	$donnees['id_utilisateur'] = $param['id_utilisateur'];
205
    	$donnees['id_cotisation_a_modifer'] = $param['id_cotisation'];
212
    	$donnees['id_cotisation_a_modifer'] = $param['id_cotisation'];
206
    	
213
    	
207
    	$donnees['cotisations'] = $this->obtenirInformationsCotisationPourInscrit($param);
214
    	$donnees['cotisations'] = $this->obtenirInformationsCotisationPourInscrit($param);
208
    	
215
    	
209
    	$cotisation_modele = new CotisationModele(); 
216
    	$cotisation_modele = new CotisationModele(); 
210
    	$donnees['modes_cotisation'] = $cotisation_modele->obtenirListeModesCotisation();
217
    	$donnees['modes_cotisation'] = $cotisation_modele->obtenirListeModesCotisation();
211
    	
218
    	
212
    	$donnees['url_liste_cotisations'] = $this->getUrlVoirListeCotisations();
219
    	$donnees['url_liste_cotisations'] = $this->getUrlVoirListeCotisations();
213
    	
220
    	
214
    	$donnees['url_modification_cotisation'] = $this->getUrlModificationCotisation($donnees['id_cotisation_a_modifer']);
221
    	$donnees['url_modification_cotisation'] = $this->getUrlModificationCotisation($donnees['id_cotisation_a_modifer']);
215
    	
222
    	
216
    	$donnees['url_retour'] = $this->urlService();
223
    	$donnees['url_retour'] = $this->urlService();
-
 
224
    	
-
 
225
    	$donnees['infos_utilisateur'] = $this->getInformationsUtilisateur($donnees['id_utilisateur']);
217
    	
226
    	
218
    	$liste_cotisations_html = $this->renvoyerSquelette('formulaire_modification_cotisation', $donnees);
227
    	$liste_cotisations_html = $this->renvoyerSquelette('formulaire_modification_cotisation', $donnees);
219
    	
228
    	
220
    	return $liste_cotisations_html;
229
    	return $liste_cotisations_html;
221
    }
230
    }
-
 
231
    
-
 
232
    private function getInformationsUtilisateur($id_utilisateur) {
-
 
233
    	$id_annuaire = !empty($_GET['id_annuaire']) ? $_GET['id_annuaire'] : Config::get('annuaire_defaut');
-
 
234
    	$annuaire_modele = $this->getModele('AnnuaireModele');
-
 
235
    	return $annuaire_modele->obtenirInfosUtilisateurParId($id_annuaire, $id_utilisateur);
-
 
236
    }
222
    
237
    
223
    // +---------------------------------------------------------------------------------------------------------------+
238
    // +---------------------------------------------------------------------------------------------------------------+
224
    // METHODES D'ACCES A LA BASE DE DONNEES
239
    // METHODES D'ACCES A LA BASE DE DONNEES
225
    
240
    
226
    private function getInformationsHistoriqueCotisation() {
241
    private function getInformationsHistoriqueCotisation() {
227
    	
242
    	
228
    	$requete_infos_historique_cotisation = 'SELECT * FROM annuaire_COTISATION';
243
    	$requete_infos_historique_cotisation = 'SELECT * FROM annuaire_COTISATION';
229
 
244
 
230
    	$infos_historique_cotisation = $this->executerRequete($requete_infos_historique_cotisation);
245
    	$infos_historique_cotisation = $this->executerRequete($requete_infos_historique_cotisation);
231
    	
246
    	
232
    	$infos_historique_cotisation_formatees = array();
247
    	$infos_historique_cotisation_formatees = array();
233
    	
248
    	
234
    	foreach($infos_historique_cotisation as $cotisation) {
249
    	foreach($infos_historique_cotisation as $cotisation) {
235
    		$infos_historique_cotisation_formatees[] = $this->formaterInformationsCotisationPourEnvoi($cotisation);
250
    		$infos_historique_cotisation_formatees[] = $this->formaterInformationsCotisationPourEnvoi($cotisation);
236
    	}
251
    	}
237
    	
252
    	
238
    	return $infos_historique_cotisation_formatees;
253
    	return $infos_historique_cotisation_formatees;
239
    }
254
    }
240
    
255
    
241
    private function obtenirNumeroRecuCotisation($param) {
256
    private function obtenirNumeroRecuCotisation($param) {
242
    	
257
    	
243
    	$id_cotisation = $param['id_cotisation'];
258
    	$id_cotisation = $param['id_cotisation'];
244
    	$id_utilisateur = $param['id_utilisateur'];
259
    	$id_utilisateur = $param['id_utilisateur'];
245
    	
260
    	
246
		if(!Registre::getInstance()->get('est_admin')) {
261
		if(!Registre::getInstance()->get('est_admin')) {
247
    		$id_utilisateur = Registre::getInstance()->get('identification_id');
262
    		$id_utilisateur = Registre::getInstance()->get('identification_id');
248
    	}
263
    	}
249
    	
264
    	
250
    	$id_annuaire = Config::get('annuaire_defaut');
265
    	$id_annuaire = Config::get('annuaire_defaut');
251
    	
266
    	
252
    	if(isset($_GET['id_annuaire'])) {
267
    	if(isset($_GET['id_annuaire'])) {
253
    		$id_annuaire = $_GET['id_annuaire'];
268
    		$id_annuaire = $_GET['id_annuaire'];
254
    	}
269
    	}
255
    	
270
    	
256
    	$utilisateur = $this->obtenirValeursUtilisateur($id_annuaire, $id_utilisateur);
271
    	$utilisateur = $this->obtenirValeursUtilisateur($id_annuaire, $id_utilisateur);
257
    	
272
    	
258
	    if(!isset($id_cotisation)) {
273
	    if(!isset($id_cotisation)) {
259
    		return;
274
    		return;
260
    	}
275
    	}
261
    	
276
    	
262
    	$cotisation_modele = new CotisationModele(); 
277
    	$cotisation_modele = new CotisationModele(); 
263
    	$infos_cotisation = $cotisation_modele->obtenirInformationsPourIdCotisation($id_cotisation, $id_utilisateur);
278
    	$infos_cotisation = $cotisation_modele->obtenirInformationsPourIdCotisation($id_cotisation, $id_utilisateur);
264
    	    	
279
    	    	
265
    	if(empty($infos_cotisation)) {
280
    	if(empty($infos_cotisation)) {
266
    		return;
281
    		return;
267
    	}
282
    	}
268
    	
283
    	
269
    	$infos_cotisation_formatees = $this->formaterInformationsCotisationPourEnvoi($infos_cotisation);
284
    	$infos_cotisation_formatees = $this->formaterInformationsCotisationPourEnvoi($infos_cotisation);
270
    	
285
    	
271
	    if(!$this->recuEstGenere($infos_cotisation_formatees)) {
286
	    if(!$this->recuEstGenere($infos_cotisation_formatees)) {
272
	    	
287
	    	
273
    		$numero_nouveau_recu = $this->calculerNouvelOrdreRecuPourCotisation($infos_cotisation_formatees);
288
    		$numero_nouveau_recu = $this->calculerNouvelOrdreRecuPourCotisation($infos_cotisation_formatees);
274
    		$infos_cotisation_formatees['recu_envoye'] = $numero_nouveau_recu;
289
    		$infos_cotisation_formatees['recu_envoye'] = $numero_nouveau_recu;
275
    		$this->mettreAJourNumeroRecu($infos_cotisation_formatees['id_cotisation'],$numero_nouveau_recu);
290
    		$this->mettreAJourNumeroRecu($infos_cotisation_formatees['id_cotisation'],$numero_nouveau_recu);
276
    	
291
    	
277
	    }    
292
	    }    
278
 
293
 
279
	    return $infos_cotisation_formatees;
294
	    return $infos_cotisation_formatees;
280
    }
295
    }
281
    
296
    
282
    private function initialiserInformationsAnnuaireUtilisateur($param) {
297
    private function initialiserInformationsAnnuaireUtilisateur($param) {
283
    	
298
    	
284
    	$id_cotisation = $param['id_cotisation'];
299
    	$id_cotisation = $param['id_cotisation'];
285
    	$id_utilisateur = $param['id_utilisateur'];
300
    	$id_utilisateur = $param['id_utilisateur'];
286
    	
301
    	
287
		if(!Registre::getInstance()->get('est_admin')) {
302
		if(!Registre::getInstance()->get('est_admin')) {
288
    		$param['id_utilisateur'] = Registre::getInstance()->get('identification_id');
303
    		$param['id_utilisateur'] = Registre::getInstance()->get('identification_id');
289
    	}
304
    	}
290
    	
305
    	
291
    	$id_annuaire = Config::get('annuaire_defaut');
306
    	$id_annuaire = Config::get('annuaire_defaut');
292
    	
307
    	
293
    	if(isset($_GET['id_annuaire'])) {
308
    	if(isset($_GET['id_annuaire'])) {
294
    		$param['id_annuaire'] = $_GET['id_annuaire'];
309
    		$param['id_annuaire'] = $_GET['id_annuaire'];
295
    	}
310
    	}
296
    	
311
    	
297
    	$param['utilisateur'] = $this->obtenirValeursUtilisateur($id_annuaire, $id_utilisateur);
312
    	$param['utilisateur'] = $this->obtenirValeursUtilisateur($id_annuaire, $id_utilisateur);
298
    	
313
    	
299
    	return $param;
314
    	return $param;
300
    }
315
    }
301
        
316
        
302
	private function envoyerRecuCotisation($param) {
317
	private function envoyerRecuCotisation($param) {
303
		
318
		
304
		$param = $this->initialiserInformationsAnnuaireUtilisateur($param);
319
		$param = $this->initialiserInformationsAnnuaireUtilisateur($param);
305
		
320
		
306
		$infos_cotisation_formatees = $this->obtenirNumeroRecuCotisation($param);
321
		$infos_cotisation_formatees = $this->obtenirNumeroRecuCotisation($param);
307
		
322
		
308
		if(!$this->recuEstEnvoye($infos_cotisation_formatees)) {
323
		if(!$this->recuEstEnvoye($infos_cotisation_formatees)) {
309
	    	$infos_cotisation_formatees['date_envoi_recu'] = $this->mettreAJourDateEnvoiRecuPourCotisation($infos_cotisation_formatees);
324
	    	$infos_cotisation_formatees['date_envoi_recu'] = $this->mettreAJourDateEnvoiRecuPourCotisation($infos_cotisation_formatees);
310
	    }
325
	    }
311
		
326
		
312
    	$recu = new Recu();
327
    	$recu = new Recu();
313
    	$recu_pdf = $recu->renvoyerRecuPdf($param['utilisateur'], $infos_cotisation_formatees);
328
    	$recu_pdf = $recu->renvoyerRecuPdf($param['utilisateur'], $infos_cotisation_formatees);
314
    	
329
    	
315
    	$messagerie = new MessageControleur();
330
    	$messagerie = new MessageControleur();
316
    	$donnees['url_voir_recu'] = $this->getUrlTelechargementRecuPourMail($param['id_cotisation']);
331
    	$donnees['url_voir_recu'] = $this->getUrlTelechargementRecuPourMail($param['id_cotisation']);
317
    	$contenu_message = $this->renvoyerSquelette('message_recu_cotisation', $donnees);
332
    	$contenu_message = $this->renvoyerSquelette('message_recu_cotisation', $donnees);
318
    	$envoi = $messagerie->envoyerMailAvecPieceJointe(Config::get('adresse_mail_cotisation'), $param['utilisateur']['mail']['amv_valeur'], 'Recu pour votre don à tela botanica', $contenu_message, $recu_pdf, 'Recu.pdf', 'application/pdf');
333
    	$envoi = $messagerie->envoyerMailAvecPieceJointe(Config::get('adresse_mail_cotisation'), $param['utilisateur']['mail']['amv_valeur'], 'Recu pour votre don à tela botanica', $contenu_message, $recu_pdf, 'Recu.pdf', 'application/pdf');
319
   
334
   
320
    	$param['message'] = 'Votre reçu a bien été envoyé à l\'adresse '.$param['utilisateur']['mail']['amv_valeur'];
335
    	$param['message'] = 'Votre reçu a bien été envoyé à l\'adresse '.$param['utilisateur']['mail']['amv_valeur'];
321
    	
336
    	
322
    	return $this->afficherInformationsCotisationPourInscrit($param);
337
    	return $this->afficherInformationsCotisationPourInscrit($param);
323
    }
338
    }
324
    
339
    
325
    private function voirRecuCotisation($param) {
340
    private function voirRecuCotisation($param) {
326
    	
341
    	
327
		$param = $this->initialiserInformationsAnnuaireUtilisateur($param);
342
		$param = $this->initialiserInformationsAnnuaireUtilisateur($param);
328
		    	
343
		    	
329
	    if(!isset($param['id_cotisation'])) {
344
	    if(!isset($param['id_cotisation'])) {
330
    		return;
345
    		return;
331
    	}
346
    	}
332
    	
347
    	
333
    	$cotisation_modele = new CotisationModele(); 
348
    	$cotisation_modele = new CotisationModele(); 
334
    	$infos_cotisation = $cotisation_modele->obtenirInformationsPourIdCotisation($param['id_cotisation'], $param['id_utilisateur']);
349
    	$infos_cotisation = $cotisation_modele->obtenirInformationsPourIdCotisation($param['id_cotisation'], $param['id_utilisateur']);
335
 
350
 
336
    	if(empty($infos_cotisation)) {
351
    	if(empty($infos_cotisation)) {
337
    		return;
352
    		return;
338
    	}
353
    	}
339
    	
354
    	
340
    	$infos_cotisation_formatees = $this->formaterInformationsCotisationPourEnvoi($infos_cotisation);    	    	
355
    	$infos_cotisation_formatees = $this->formaterInformationsCotisationPourEnvoi($infos_cotisation);    	    	
341
    	$infos_cotisation_formatees = $this->obtenirNumeroRecuCotisation($param);
356
    	$infos_cotisation_formatees = $this->obtenirNumeroRecuCotisation($param);
342
    	
357
    	
343
    	// tant que le recu n'est pas envoyé sa date est celle du jour courant
358
    	// tant que le recu n'est pas envoyé sa date est celle du jour courant
344
    	if(!$this->recuEstEnvoye($infos_cotisation_formatees)) {
359
    	if(!$this->recuEstEnvoye($infos_cotisation_formatees)) {
345
    		$infos_cotisation_formatees['date_envoi_recu'] = date('d/m/Y');
360
    		$infos_cotisation_formatees['date_envoi_recu'] = date('d/m/Y');
346
    	}
361
    	}
347
    	    	
362
    	    	
348
    	$recu = new Recu();
363
    	$recu = new Recu();
349
    	
364
    	
350
    	$recu->afficherRecuPdf($param['utilisateur'], $infos_cotisation_formatees);
365
    	$recu->afficherRecuPdf($param['utilisateur'], $infos_cotisation_formatees);
351
    	
366
    	
352
    	return true;
367
    	return true;
353
    }
368
    }
354
    
369
    
355
    private function recuEstGenere($cotisation) {
370
    private function recuEstGenere($cotisation) {
356
    	
371
    	
357
    	if($cotisation['recu_envoye'] != null && $cotisation['recu_envoye'] != 0) {
372
    	if($cotisation['recu_envoye'] != null && $cotisation['recu_envoye'] != 0) {
358
    		return true;
373
    		return true;
359
    	}
374
    	}
360
    	
375
    	
361
    	return false;
376
    	return false;
362
    }
377
    }
363
    
378
    
364
	private function recuEstEnvoye($cotisation) {
379
	private function recuEstEnvoye($cotisation) {
365
    	
380
    	
366
    	if($cotisation['date_envoi_recu'] != null && $cotisation['date_envoi_recu'] != 0) {
381
    	if($cotisation['date_envoi_recu'] != null && $cotisation['date_envoi_recu'] != 0) {
367
    		return true;
382
    		return true;
368
    	}
383
    	}
369
    	
384
    	
370
    	return false;
385
    	return false;
371
    }
386
    }
372
    
387
    
373
    private function calculerNouvelOrdreRecuPourCotisation($cotisation) {
388
    private function calculerNouvelOrdreRecuPourCotisation($cotisation) {
374
    	
389
    	
375
    	$cotisation_modele = new CotisationModele();
390
    	$cotisation_modele = new CotisationModele();
376
    	
391
    	
377
    	$annee_recu = $cotisation['annee_cotisation'];
392
    	$annee_recu = $cotisation['annee_cotisation'];
378
    	$numero_ordre = $cotisation_modele->calculerNouvelOrdreRecuEtIncrementer($annee_recu);
393
    	$numero_ordre = $cotisation_modele->calculerNouvelOrdreRecuEtIncrementer($annee_recu);
379
    	
394
    	
380
    	return $numero_ordre;
395
    	return $numero_ordre;
381
    }
396
    }
382
    
397
    
383
    private function mettreAJourDateEnvoiRecuPourCotisation($cotisation) {
398
    private function mettreAJourDateEnvoiRecuPourCotisation($cotisation) {
384
    	
399
    	
385
    	$cotisation_modele = new CotisationModele();
400
    	$cotisation_modele = new CotisationModele();
386
    	$cotisation_modele->mettreAJourDateEnvoiRecu($cotisation['id_cotisation']);
401
    	$cotisation_modele->mettreAJourDateEnvoiRecu($cotisation['id_cotisation']);
387
    	
402
    	
388
    	$date_envoi_recu = $this->genererDateCouranteFormatAnnuaire();
403
    	$date_envoi_recu = $this->genererDateCouranteFormatAnnuaire();
389
    	
404
    	
390
    	return $date_envoi_recu;
405
    	return $date_envoi_recu;
391
    }
406
    }
392
    
407
    
393
	private function mettreAJourNumeroRecu($id_cotisation, $numero_recu) {
408
	private function mettreAJourNumeroRecu($id_cotisation, $numero_recu) {
394
       	
409
       	
395
    	$cotisation_modele = new CotisationModele();
410
    	$cotisation_modele = new CotisationModele();
396
    	$maj_cotisation_num_recu = $cotisation_modele->mettreAJourNumeroRecu($id_cotisation, $numero_recu);
411
    	$maj_cotisation_num_recu = $cotisation_modele->mettreAJourNumeroRecu($id_cotisation, $numero_recu);
397
    	
412
    	
398
    	return $maj_cotisation_num_recu;
413
    	return $maj_cotisation_num_recu;
399
    }
414
    }
400
    
415
    
401
    private function formaterInformationsCotisationPourEnvoi($cotisation) {
416
    private function formaterInformationsCotisationPourEnvoi($cotisation) {
402
    	
417
    	
403
    	$cotisation_modele = new CotisationModele(); 
418
    	$cotisation_modele = new CotisationModele(); 
404
    	
419
    	
405
    	$cotisation_champs_formates = array(
420
    	$cotisation_champs_formates = array(
406
		    	'id_cotisation' => $cotisation['IC_ID'],
421
		    	'id_cotisation' => $cotisation['IC_ID'],
407
		    	'id_inscrit' => $cotisation['IC_ANNU_ID'],
422
		    	'id_inscrit' => $cotisation['IC_ANNU_ID'],
408
    			'annee_cotisation' => $this->formaterAnneeDateCotisationMySql($cotisation['IC_DATE']),
423
    			'annee_cotisation' => $this->formaterAnneeDateCotisationMySql($cotisation['IC_DATE']),
409
				'date_cotisation' => $this->formaterDateMysqlVersDateAnnuaire($cotisation['IC_DATE']),
424
				'date_cotisation' => $this->formaterDateMysqlVersDateAnnuaire($cotisation['IC_DATE']),
410
    			'montant_cotisation' => $cotisation['IC_MONTANT'],
425
    			'montant_cotisation' => $cotisation['IC_MONTANT'],
411
				'mode_cotisation' => $cotisation_modele->obtenirModeCotisationParId($cotisation['IC_MC_ID']),
426
				'mode_cotisation' => $cotisation_modele->obtenirModeCotisationParId($cotisation['IC_MC_ID']),
412
				'id_mode_cotisation' => $cotisation['IC_MC_ID'],
427
				'id_mode_cotisation' => $cotisation['IC_MC_ID'],
413
				'recu_envoye' => $cotisation['IC_RECU'],
428
				'recu_envoye' => $cotisation['IC_RECU'],
414
    			'date_envoi_recu' => $this->formaterDateMysqlVersDateCotisation($cotisation['IC_DATE_ENVOIE_RECU']),
429
    			'date_envoi_recu' => $this->formaterDateMysqlVersDateCotisation($cotisation['IC_DATE_ENVOIE_RECU']),
415
    			'url_voir_recu' => $this->getUrlVoirRecuCotisation($cotisation['IC_ID']),
430
    			'url_voir_recu' => $this->getUrlVoirRecuCotisation($cotisation['IC_ID']),
416
    	    	'url_envoyer_recu' => $this->getUrlEnvoiRecuCotisation($cotisation['IC_ID']),
431
    	    	'url_envoyer_recu' => $this->getUrlEnvoiRecuCotisation($cotisation['IC_ID']),
417
    			'url_formulaire_modification' => $this->getUrlFormulaireModificationCotisation($cotisation['IC_ID']),
432
    			'url_formulaire_modification' => $this->getUrlFormulaireModificationCotisation($cotisation['IC_ID']),
418
    			'url_suppression' => $this->getUrlSuppressionCotisation($cotisation['IC_ID'])
433
    			'url_suppression' => $this->getUrlSuppressionCotisation($cotisation['IC_ID'])
419
		    );
434
		    );
420
		    
435
		    
421
		return $cotisation_champs_formates;
436
		return $cotisation_champs_formates;
422
    }
437
    }
423
    
438
    
424
    private function renvoyerSquelette($squelette, $donnees) {
439
    private function renvoyerSquelette($squelette, $donnees) {
425
    	
440
    	
426
    	$chemin_squelette = Config::get('chemin_appli').'composants'.DS.ANNUAIRE_PLUGIN.DS.'squelettes'.DS.$squelette.'.tpl.html';
441
    	$chemin_squelette = Config::get('chemin_appli').'composants'.DS.ANNUAIRE_PLUGIN.DS.'squelettes'.DS.$squelette.'.tpl.html';
427
    	
442
    	
428
    	$sortie = SquelettePhp::analyser($chemin_squelette, $donnees);
443
    	$sortie = SquelettePhp::analyser($chemin_squelette, $donnees);
429
    	//$squelette_dossier = .'squelettes'.DS;
444
    	//$squelette_dossier = .'squelettes'.DS;
430
    	return $sortie;
445
    	return $sortie;
431
    }
446
    }
432
    
447
    
433
	private function urlService($params = array()) {
448
	private function urlService($params = array()) {
434
		
449
		
435
    	$url_service = new Url(Url::getDemande()->getUrl());
450
    	$url_service = new Url(Url::getDemande()->getUrl());
436
    	    	    	
451
    	    	    	
437
    	$variables_requetes = $url_service->getVariablesRequete();
452
    	$variables_requetes = $url_service->getVariablesRequete();
438
    	
453
    	
439
    	$variables_plugins = array(Config::get('plugin_variable_action'), 'id_cotisation', 'id_cotisant');
454
    	$variables_plugins = array(Config::get('plugin_variable_action'), 'id_cotisation', 'id_cotisant');
440
    	
455
    	
441
    	foreach($params as $cle => $valeur) {
456
    	foreach($params as $cle => $valeur) {
442
    		$variables_requetes[$cle] = $valeur;
457
    		$variables_requetes[$cle] = $valeur;
443
    	}
458
    	}
444
    	
459
    	
445
    	$url_service->setVariablesRequete($variables_requetes);
460
    	$url_service->setVariablesRequete($variables_requetes);
446
    	
461
    	
447
    	return $url_service->getUrl();
462
    	return $url_service->getUrl();
448
    }
463
    }
449
    
464
    
450
	private function getUrlVoirListeCotisations() {
465
	private function getUrlVoirListeCotisations() {
451
		
466
		
452
		$params = array('action_cotisation' => 'afficherInformationsCotisationPourInscrit');
467
		$params = array('action_cotisation' => 'afficherInformationsCotisationPourInscrit');
453
		
468
		
454
    	return $this->urlService($params);
469
    	return $this->urlService($params);
455
    }
470
    }
456
    
471
    
457
	private function getUrlVoirRecuCotisation($id_cotisation) {
472
	private function getUrlVoirRecuCotisation($id_cotisation) {
458
		
473
		
459
		$params = array('action_cotisation' => 'voirRecuCotisation',
474
		$params = array('action_cotisation' => 'voirRecuCotisation',
460
						'id_cotisation' => $id_cotisation);
475
						'id_cotisation' => $id_cotisation);
461
		
476
		
462
    	return $this->urlService($params);
477
    	return $this->urlService($params);
463
    }
478
    }
464
    
479
    
465
    private function getUrlTelechargementRecuPourMail($id_cotisation) {
480
    private function getUrlTelechargementRecuPourMail($id_cotisation) {
466
    	return Config::get('base_url_telechargement').'?m=annuaire_afficher_page&page=cotisations&id_annuaire=1&action_cotisation=voirRecuCotisation&id_cotisation='.$id_cotisation;
481
    	return Config::get('base_url_telechargement').'?m=annuaire_afficher_page&page=cotisations&id_annuaire=1&action_cotisation=voirRecuCotisation&id_cotisation='.$id_cotisation;
467
    }
482
    }
468
    
483
    
469
	private function getUrlEnvoiRecuCotisation($id_cotisation) {
484
	private function getUrlEnvoiRecuCotisation($id_cotisation) {
470
		
485
		
471
		$params = array('action_cotisation' => 'envoyerRecuCotisation',
486
		$params = array('action_cotisation' => 'envoyerRecuCotisation',
472
						'id_cotisation' => $id_cotisation);
487
						'id_cotisation' => $id_cotisation);
473
		
488
		
474
    	return $this->urlService($params);
489
    	return $this->urlService($params);
475
    }
490
    }
476
    
491
    
477
    private function getUrlFormulaireAjoutCotisation($id_cotisant) {
492
    private function getUrlFormulaireAjoutCotisation($id_cotisant) {
478
    	
493
    	
479
    	$params = array('action_cotisation' => 'afficherFormulaireAjoutCotisation',
494
    	$params = array('action_cotisation' => 'afficherFormulaireAjoutCotisation',
480
						'id_cotisant' => $id_cotisant);
495
						'id_cotisant' => $id_cotisant);
481
    	
496
    	
482
    	return $this->urlService($params);
497
    	return $this->urlService($params);
483
    }
498
    }
484
    
499
    
485
	private function getUrlAjoutCotisation() {
500
	private function getUrlAjoutCotisation() {
486
		
501
		
487
    	$params = array('action_cotisation' => 'ajouterCotisation');
502
    	$params = array('action_cotisation' => 'ajouterCotisation');
488
    	
503
    	
489
    	return $this->urlService($params);
504
    	return $this->urlService($params);
490
    }
505
    }
491
    
506
    
492
    private function getUrlFormulaireModificationCotisation($id_cotisation) {
507
    private function getUrlFormulaireModificationCotisation($id_cotisation) {
493
    	
508
    	
494
    	$params = array('action_cotisation' => 'afficherFormulaireModificationCotisation',
509
    	$params = array('action_cotisation' => 'afficherFormulaireModificationCotisation',
495
						'id_cotisation' => $id_cotisation);
510
						'id_cotisation' => $id_cotisation);
496
    	
511
    	
497
    	return $this->urlService($params);
512
    	return $this->urlService($params);
498
    }
513
    }
499
    
514
    
500
   	private function getUrlModificationCotisation($id_cotisation) {
515
   	private function getUrlModificationCotisation($id_cotisation) {
501
   		
516
   		
502
   		$params = array('action_cotisation' => 'mettreAjourCotisation',
517
   		$params = array('action_cotisation' => 'mettreAjourCotisation',
503
					'id_cotisation' => $id_cotisation);
518
					'id_cotisation' => $id_cotisation);
504
   		
519
   		
505
   		return $this->urlService($params);
520
   		return $this->urlService($params);
506
   	}
521
   	}
507
    
522
    
508
	private function getUrlSuppressionCotisation($id_cotisation) {
523
	private function getUrlSuppressionCotisation($id_cotisation) {
509
		
524
		
510
		$params = array('action_cotisation' => 'supprimerCotisation',
525
		$params = array('action_cotisation' => 'supprimerCotisation',
511
					'id_cotisation' => $id_cotisation);
526
					'id_cotisation' => $id_cotisation);
512
		
527
		
513
    	return $this->urlService($params);
528
    	return $this->urlService($params);
514
    }
529
    }
515
    
530
    
516
    private function controleAccesAdmin($fonction) {
531
    private function controleAccesAdmin($fonction) {
517
    	
532
    	
518
    	$fonction_admins = array(
533
    	$fonction_admins = array(
519
    		'ajouterCotisation',
534
    		'ajouterCotisation',
520
    		'mettreAJourCotisation',
535
    		'mettreAJourCotisation',
521
    		'supprimerCotisation',
536
    		'supprimerCotisation',
522
    		'afficherFormulaireAjoutCotisation',
537
    		'afficherFormulaireAjoutCotisation',
523
    		'envoyerRecuCotisation'
538
    		'envoyerRecuCotisation'
524
    	);
539
    	);
525
    	
540
    	
526
    	if(in_array($fonction, $fonction_admins) && !Registre::getInstance()->get('est_admin')) {
541
    	if(in_array($fonction, $fonction_admins) && !Registre::getInstance()->get('est_admin')) {
527
    		return false;
542
    		return false;
528
    	}
543
    	}
529
    	
544
    	
530
    	return true;
545
    	return true;
531
    }
546
    }
532
    
547
    
533
    private function formaterAnneeDateCotisationMySql($date_cotisation) {
548
    private function formaterAnneeDateCotisationMySql($date_cotisation) {
534
    	
549
    	
535
    	$annee_cotisation = '0';
550
    	$annee_cotisation = '0';
536
    	
551
    	
537
    	if($date_cotisation != '0') {
552
    	if($date_cotisation != '0') {
538
    		$annee_cotisation = date('Y',strtotime($date_cotisation));
553
    		$annee_cotisation = date('Y',strtotime($date_cotisation));
539
    	}
554
    	}
540
    	
555
    	
541
    	return $annee_cotisation;
556
    	return $annee_cotisation;
542
    }
557
    }
543
    
558
    
544
    private function formaterDateMysqlVersDateCotisation($date) {
559
    private function formaterDateMysqlVersDateCotisation($date) {
545
    	if($date == '0000-00-00') {
560
    	if($date == '0000-00-00') {
546
    		return 0;
561
    		return 0;
547
    	}
562
    	}
548
    	return $this->formaterDateMysqlVersDateAnnuaire($date);
563
    	return $this->formaterDateMysqlVersDateAnnuaire($date);
549
    }
564
    }
550
}
565
}
551
?>
566
?>