Subversion Repositories Applications.annuaire

Rev

Rev 296 | Go to most recent revision | Details | Compare with Previous | Last modification | View Log | RSS feed

Rev Author Line No. Line
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
 
103
    public function calculerNouvelOrdreRecuEtIncrementer() {
104
 
105
    	$requete_nouvel_ordre = 'select COMPTEUR from '.Config::get('cotisation_bdd').'.COMPTEUR_COTISATION';
106
 
107
		$resultat_requete_nouvel_ordre = $this->requeteUn($requete_nouvel_ordre) ;
108
 
109
		$num_recu = $resultat_requete_nouvel_ordre['COMPTEUR'];
110
 
111
		if(!$num_recu) {
112
			return 0;
113
		}
114
 
115
		$requete_incrementation_ordre = 'UPDATE '.Config::get('cotisation_bdd').'.COMPTEUR_COTISATION '.
116
										'SET COMPTEUR = COMPTEUR + 1';
117
		$resultat_requete_incrementation_ordre = $this->requete($requete_incrementation_ordre) ;
118
 
119
		return $num_recu;
120
    }
121
 
122
	public function mettreAJourNumeroRecu($id_cotisation, $id_recu) {
123
 
124
    	$requete_maj_num_recu_cotisation = 'UPDATE '.Config::get('cotisation_bdd').'.annuaire_COTISATION '.
125
			'SET '.
126
			'IC_RECU = '.$this->proteger($id_recu).' '.
127
			'WHERE IC_ID = '.$this->proteger($id_cotisation);
128
 
129
    	$resultat_maj_envoi_num_cotisation = $this->requete($requete_maj_num_recu_cotisation) ;
130
 
328 aurelien 131
    	return $id_recu;
296 aurelien 132
    }
133
 
134
    public function mettreAJourDateEnvoiRecu($id_cotisation) {
135
 
136
    	$requete_maj_envoi_recu_cotisation = 'UPDATE '.Config::get('cotisation_bdd').'.annuaire_COTISATION '.
137
			'SET '.
138
			'IC_DATE_ENVOIE_RECU = NOW() '.
139
			'WHERE IC_ID = '.$this->proteger($id_cotisation);
140
 
141
    	$resultat_maj_envoi_recu_cotisation = $this->requete($requete_maj_envoi_recu_cotisation) ;
142
 
143
    	return $resultat_maj_envoi_recu_cotisation;
144
    }
145
 
146
	protected function renvoyerDernierIdInsere() {
147
		//TODO: cela marche t'il partout ?
148
		// à faire: tester le type de driver pdo et faire une fonction portable
149
		return $this->connexion->lastInsertId();
150
	}
151
}
152
?>