Subversion Repositories Applications.annuaire

Rev

Rev 296 | Go to most recent revision | Only display areas with differences | Ignore whitespace | Details | Blame | Last modification | View Log | RSS feed

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