Subversion Repositories Applications.gtt

Rev

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

Rev Author Line No. Line
10 jpm 1
<?php
2
// +------------------------------------------------------------------------------------------------------+
3
// | PHP version 5.1.1                                                                                    |
4
// +------------------------------------------------------------------------------------------------------+
5
// | Copyright (C) 2006 Tela Botanica (accueil@tela-botanica.org)                                         |
6
// +------------------------------------------------------------------------------------------------------+
7
// | This file is part of eFlore.                                                                         |
8
// |                                                                                                      |
9
// | Foobar is free software; you can redistribute it and/or modify                                       |
10
// | it under the terms of the GNU General Public License as published by                                 |
11
// | the Free Software Foundation; either version 2 of the License, or                                    |
12
// | (at your option) any later version.                                                                  |
13
// |                                                                                                      |
14
// | Foobar is distributed in the hope that it will be useful,                                            |
15
// | but WITHOUT ANY WARRANTY; without even the implied warranty of                                       |
16
// | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the                                        |
17
// | GNU General Public License for more details.                                                         |
18
// |                                                                                                      |
19
// | You should have received a copy of the GNU General Public License                                    |
20
// | along with Foobar; if not, write to the Free Software                                                |
21
// | Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA                            |
22
// +------------------------------------------------------------------------------------------------------+
23
// CVS : $Id$
24
/**
25
* Classe Utilisateur
26
*
27
* Description
28
*
29
*@package eFlore
30
*@subpackage modele
31
//Auteur original :
32
*@version 3
33
*@author        Shaheen ABDOOL RAHEEM <shaheenar50@hotmail.com>
34
//Autres auteurs :
35
*@version 4
36
*@author        Jean-Pascal MILCENT <jpm@clapas.org>
37
*@author        aucun
38
*@copyright     Tela-Botanica 2000-2006
39
*@version       $Revision$ $Date$
40
// +------------------------------------------------------------------------------------------------------+
41
*/
42
 
43
/**
44
* class Utilisateur : est à la fois le DAO et le conteneur de la table gestion_utilisateur.
45
* classe métier
46
*/
47
class Utilisateur extends aGttSql {
48
	/*** Constantes : */
48 jpm 49
	const GU_TOUS = 'UTILISATEUR_TOUS';
10 jpm 50
	const GU_ID = 'UTILISATEUR_ID';
51
	const GU_ID_MAX = 'UTILISATEUR_ID_MAX';
48 jpm 52
	const GU_CE_STATUT = 'UTILISATEUR_CE_STATUT';
67 jpm 53
	const GU_MAIL = 'UTILISATEUR_MAIL';
95 jpm 54
	const GU_TOUS_AFFICHABLE = 'UTILISATEUR_TOUS_AFFICHABLE';
55
	const GU_ADMIN = 'UTILISATEUR_ADMIN';
36 jpm 56
 
10 jpm 57
	/*** Attributs : */
58
	private $id_utilisateur;
48 jpm 59
	private $ce_statut = 0;
10 jpm 60
	private $nom;
61
	private $prenom;
62
	private $password;
63
	private $email;
64
	private $telephone;
65
	private $adresse;
66
	private $code_postal;
67
	private $ville;
48 jpm 68
	private $quota_heures_supp = 0;
69
	private $conges_payes = 0;
67 jpm 70
	private $temps_de_travail_jour = 7;
71
	private $temps_de_travail_mois = 0;
48 jpm 72
	private $mark_admin = 0;
73
	private $mark_recapitulatif = 1;
10 jpm 74
	private $notes;
36 jpm 75
 
10 jpm 76
	/*** Aggregations : */
77
 
78
	/*** Constructeur : */
79
	public function __construct($cmd = null, $parametres = null)
80
	{
81
		$this->dao_table_nom = 'gestion_utilisateur';
82
		$this->dao_correspondance = array(
83
			'gu_id_utilisateur'	=> 'id_utilisateur',
36 jpm 84
			'gu_ce_statut'	=> 'ce_statut',
10 jpm 85
			'gu_nom'	=> 'nom',
86
			'gu_prenom'	=> 'prenom',
87
			'gu_password'	=> 'password',
88
			'gu_email'	=> 'email',
89
			'gu_telephone'	=> 'telephone',
90
			'gu_adresse'	=> 'adresse',
91
			'gu_code_postal'	=> 'code_postal',
92
			'gu_ville'	=> 'ville',
93
			'gu_quota_heures_supp'	=> 'quota_heures_supp',
94
			'gu_conges_payes'	=> 'conges_payes',
67 jpm 95
			'gu_temps_de_travail_jour'	=> 'temps_de_travail_jour',
96
			'gu_temps_de_travail_mois'	=> 'temps_de_travail_mois',
10 jpm 97
			'gu_mark_admin'	=> 'mark_admin',
98
			'gu_mark_recapitulatif'	=> 'mark_recapitulatif',
99
			'gu_notes'	=> 'notes');
36 jpm 100
 
10 jpm 101
		// Si l'on veut remplir l'objet à la création on lance la requete correspondante
102
		if (!is_null($cmd)) {
103
			$this->consulter($cmd, $parametres, true);
104
		}
105
	}
36 jpm 106
 
10 jpm 107
	/*** Accesseurs : */
108
	// Id Utilisateur
109
	public function getIdUtilisateur()
110
	{
111
		return $this->id_utilisateur;
112
	}
113
	public function setIdUtilisateur( $iu )
114
	{
115
		$this->id_utilisateur = $iu;
116
	}
36 jpm 117
 
10 jpm 118
	// Gus Id Utilisateur Statut
36 jpm 119
	public function getCeStatut()
10 jpm 120
	{
36 jpm 121
		return $this->ce_statut;
10 jpm 122
	}
36 jpm 123
	public function setCeStatut( $cs )
10 jpm 124
	{
36 jpm 125
		$this->ce_statut = $cs;
10 jpm 126
	}
36 jpm 127
 
10 jpm 128
	// Nom
129
	public function getNom()
130
	{
131
		return $this->nom;
132
	}
133
	public function setNom( $n )
134
	{
54 jpm 135
		$this->nom = strtoupper($n);
10 jpm 136
	}
36 jpm 137
 
10 jpm 138
	// Prenom
139
	public function getPrenom()
140
	{
141
		return $this->prenom;
142
	}
143
	public function setPrenom( $p )
144
	{
145
		$this->prenom = $p;
146
	}
36 jpm 147
 
10 jpm 148
	// Password
149
	public function getPassword()
150
	{
151
		return $this->password;
152
	}
153
	public function setPassword( $p )
154
	{
54 jpm 155
		$this->password = md5($p);
10 jpm 156
	}
36 jpm 157
 
10 jpm 158
	// Email
159
	public function getEmail()
160
	{
161
		return $this->email;
162
	}
163
	public function setEmail( $e )
164
	{
165
		$this->email = $e;
166
	}
36 jpm 167
 
10 jpm 168
	// Telephone
169
	public function getTelephone()
170
	{
171
		return $this->telephone;
172
	}
173
	public function setTelephone( $t )
174
	{
54 jpm 175
		$this->telephone = (string) $t;
10 jpm 176
	}
36 jpm 177
 
10 jpm 178
	// Adresse
179
	public function getAdresse()
180
	{
181
		return $this->adresse;
182
	}
183
	public function setAdresse( $a )
184
	{
185
		$this->adresse = $a;
186
	}
36 jpm 187
 
10 jpm 188
	// Code Postal
189
	public function getCodePostal()
190
	{
191
		return $this->code_postal;
192
	}
193
	public function setCodePostal( $cp )
194
	{
195
		$this->code_postal = $cp;
196
	}
36 jpm 197
 
10 jpm 198
	// Ville
199
	public function getVille()
200
	{
201
		return $this->ville;
202
	}
203
	public function setVille( $v )
204
	{
205
		$this->ville = $v;
206
	}
36 jpm 207
 
10 jpm 208
	// Quota Heures Supp
209
	public function getQuotaHeuresSupp()
210
	{
211
		return $this->quota_heures_supp;
212
	}
213
	public function setQuotaHeuresSupp( $qhs )
214
	{
215
		$this->quota_heures_supp = $qhs;
216
	}
36 jpm 217
 
10 jpm 218
	// Conges Payes
219
	public function getCongesPayes()
220
	{
221
		return $this->conges_payes;
222
	}
223
	public function setCongesPayes( $cp )
224
	{
225
		$this->conges_payes = $cp;
226
	}
36 jpm 227
 
67 jpm 228
	// Temps De Travail Jour
229
	public function getTempsDeTravailJour()
10 jpm 230
	{
67 jpm 231
		return $this->temps_de_travail_jour;
10 jpm 232
	}
67 jpm 233
	public function setTempsDeTravailJour( $tdt )
10 jpm 234
	{
67 jpm 235
		$this->temps_de_travail_jour = $tdt;
10 jpm 236
	}
36 jpm 237
 
67 jpm 238
	// Temps De Travail Mois
239
	public function getTempsDeTravailMois()
240
	{
241
		return $this->temps_de_travail_mois;
242
	}
243
	public function setTempsDeTravailMois( $tdt )
244
	{
245
		$this->temps_de_travail_mois = $tdt;
246
	}
247
 
10 jpm 248
	// Mark Admin
249
	public function getMarkAdmin()
250
	{
251
		return $this->mark_admin;
252
	}
253
	public function setMarkAdmin( $ma )
254
	{
255
		$this->mark_admin = $ma;
256
	}
36 jpm 257
 
10 jpm 258
	// Mark Recapitulatif
259
	public function getMarkRecapitulatif()
260
	{
261
		return $this->mark_recapitulatif;
262
	}
263
	public function setMarkRecapitulatif( $mr )
264
	{
265
		$this->mark_recapitulatif = $mr;
266
	}
36 jpm 267
 
10 jpm 268
	// Notes
269
	public function getNotes()
270
	{
271
		return $this->notes;
272
	}
273
	public function setNotes( $n )
274
	{
275
		$this->notes = $n;
276
	}
36 jpm 277
 
10 jpm 278
	/*** Méthodes : */
279
 
280
	/**
281
	* Consulter la table gestion_utilisateur.
282
	* @return mixed un tableau d'objets Utilisateur s'il y en a plusieurs, l'objet Utilisateur s'il y en a 1 seul sinon false.
283
	*/
284
	public function consulter($cmd = '', $parametres = array(), $instancier = false)
285
	{
286
		switch ($cmd) {
48 jpm 287
			case Utilisateur::GU_TOUS:
288
				$requete = 	'SELECT * '.
289
							'FROM gestion_utilisateur '.
290
							'ORDER BY gu_prenom, gu_nom ASC';
291
				break;
10 jpm 292
			case Utilisateur::GU_ID:
293
				$requete = 	'SELECT * '.
294
							'FROM gestion_utilisateur '.
92 jpm 295
							'WHERE gu_id_utilisateur = #0 ';
10 jpm 296
				break;
297
			case Utilisateur::GU_ID_MAX:
48 jpm 298
				$requete =	'SELECT MAX(gu_id_utilisateur) AS gu_id_utilisateur '.
10 jpm 299
							'FROM gestion_utilisateur ';
300
				break;
48 jpm 301
			case Utilisateur::GU_CE_STATUT:
302
				$requete =	'SELECT * '.
303
							'FROM gestion_utilisateur '.
92 jpm 304
							'WHERE gu_ce_statut = "#0" ';
48 jpm 305
				break;
10 jpm 306
			case Utilisateur::GU_MAIL:
307
				$requete =	'SELECT * '.
308
							'FROM gestion_utilisateur '.
92 jpm 309
							'WHERE gu_email = "#0" ';
67 jpm 310
				break;
311
			case Utilisateur::GU_TOUS_AFFICHABLE:
312
				$requete = 	'SELECT * '.
313
							'FROM gestion_utilisateur '.
314
							'WHERE gu_mark_recapitulatif = 0 '.
315
							'ORDER BY gu_prenom, gu_nom ASC';
95 jpm 316
				break;
317
			case Utilisateur::GU_ADMIN:
318
				$requete = 	'SELECT * '.
319
							'FROM gestion_utilisateur '.
320
							'WHERE gu_mark_admin = 1 ';
321
				break;
322
 
10 jpm 323
			default :
324
				$message = 'Commande '.$cmd.'inconnue!';
325
				$e = GestionnaireErreur::formaterMessageErreur(__FILE__, __LINE__, $message);
326
    			trigger_error($e, E_USER_ERROR);
327
		}
92 jpm 328
		return parent::consulter($requete, $parametres, $instancier);
10 jpm 329
	}
52 jpm 330
 
331
	public function supprimer()
332
	{
333
		$requete = 	'DELETE FROM gestion_utilisateur '.
334
					'WHERE gu_id_utilisateur = '.$this->getIdUtilisateur();
335
		$resultat = $GLOBALS['db']->query($requete);
336
		(DB::isError($resultat)) ? die (GestionnaireErreur::retournerErreurSql(__FILE__, __LINE__, $resultat->getMessage(), $requete)) : '' ;
337
 
338
		if ($GLOBALS['db']->affectedRows() == 1) {
339
			return true;
340
		} elseif ($GLOBALS['db']->affectedRows() == 0) {
341
			return false;
342
		}
343
	}
36 jpm 344
 
10 jpm 345
	/**augmenter le nombre d'heure sup
36 jpm 346
	*un acces est fait a la bse de donnees pour enregistrer les changements en temps reel
10 jpm 347
 	*/
348
	function augmenterQuotaHeuresSup($nb)
349
	{
79 jpm 350
		$this->quota_heures_supp =  $this->quota_heures_supp + $nb;
10 jpm 351
	}
352
 
353
	/**diminuer le nb d'heures sup*/
354
	public function diminuerQuotaHeuresSup($nb)
355
	{
79 jpm 356
		$this->quota_heures_supp =  $this->quota_heures_supp - $nb;
10 jpm 357
		/*un quota heure supp negatif implique qu'il y a des heures a rattraper*/
358
	}
36 jpm 359
 
10 jpm 360
	/**augmenter le nombre de jours de conges */
361
	function augmenterCongesPayes($nb)
362
	{
363
		$this->conges_payes = $this->conges_payes + $nb;
364
	}
36 jpm 365
 
10 jpm 366
	/**diminuer le nombre de jour de conges */
367
	function diminuerCongesPayes($nb)
368
	{
369
		$this->conges_payes = $this->conges_payes - $nb;
370
	}
371
}
372
 
373
/* +--Fin du code ----------------------------------------------------------------------------------------+
374
*
375
* $Log$
376
*
377
* +-- Fin du code ----------------------------------------------------------------------------------------+
378
*/
379
?>