Subversion Repositories Applications.gtt

Rev

Rev 140 | 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
/**
104 jpm 44
* class Utilisateur : est à la fois le DAO et le conteneur de la table gestion_utilisateur.
45
* classe métier
10 jpm 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;
110 jpm 71
	private $temps_de_travail_mois = 0;
72
	private $tdt_lundi = 0;
73
	private $tdt_mardi = 0;
74
	private $tdt_mercredi = 0;
75
	private $tdt_jeudi = 0;
76
	private $tdt_vendredi = 0;
77
	private $tdt_samedi = 0;
78
	private $tdt_dimanche = 0;
48 jpm 79
	private $mark_admin = 0;
80
	private $mark_recapitulatif = 1;
10 jpm 81
	private $notes;
36 jpm 82
 
10 jpm 83
	/*** Aggregations : */
84
 
85
	/*** Constructeur : */
86
	public function __construct($cmd = null, $parametres = null)
87
	{
88
		$this->dao_table_nom = 'gestion_utilisateur';
89
		$this->dao_correspondance = array(
90
			'gu_id_utilisateur'	=> 'id_utilisateur',
36 jpm 91
			'gu_ce_statut'	=> 'ce_statut',
10 jpm 92
			'gu_nom'	=> 'nom',
93
			'gu_prenom'	=> 'prenom',
94
			'gu_password'	=> 'password',
95
			'gu_email'	=> 'email',
96
			'gu_telephone'	=> 'telephone',
97
			'gu_adresse'	=> 'adresse',
98
			'gu_code_postal'	=> 'code_postal',
99
			'gu_ville'	=> 'ville',
100
			'gu_quota_heures_supp'	=> 'quota_heures_supp',
101
			'gu_conges_payes'	=> 'conges_payes',
67 jpm 102
			'gu_temps_de_travail_jour'	=> 'temps_de_travail_jour',
103
			'gu_temps_de_travail_mois'	=> 'temps_de_travail_mois',
110 jpm 104
			'gu_tdt_lundi'	=> 'tdt_lundi',
105
			'gu_tdt_mardi'	=> 'tdt_mardi',
106
			'gu_tdt_mercredi'	=> 'tdt_mercredi',
107
			'gu_tdt_jeudi'	=> 'tdt_jeudi',
108
			'gu_tdt_vendredi'	=> 'tdt_vendredi',
109
			'gu_tdt_samedi'	=> 'tdt_samedi',
110
			'gu_tdt_dimanche'	=> 'tdt_dimanche',
10 jpm 111
			'gu_mark_admin'	=> 'mark_admin',
112
			'gu_mark_recapitulatif'	=> 'mark_recapitulatif',
113
			'gu_notes'	=> 'notes');
36 jpm 114
 
104 jpm 115
		// Si l'on veut remplir l'objet à la création on lance la requete correspondante
10 jpm 116
		if (!is_null($cmd)) {
117
			$this->consulter($cmd, $parametres, true);
118
		}
119
	}
36 jpm 120
 
10 jpm 121
	/*** Accesseurs : */
122
	// Id Utilisateur
123
	public function getIdUtilisateur()
124
	{
125
		return $this->id_utilisateur;
126
	}
127
	public function setIdUtilisateur( $iu )
128
	{
129
		$this->id_utilisateur = $iu;
130
	}
36 jpm 131
 
10 jpm 132
	// Gus Id Utilisateur Statut
36 jpm 133
	public function getCeStatut()
10 jpm 134
	{
36 jpm 135
		return $this->ce_statut;
10 jpm 136
	}
36 jpm 137
	public function setCeStatut( $cs )
10 jpm 138
	{
36 jpm 139
		$this->ce_statut = $cs;
10 jpm 140
	}
36 jpm 141
 
10 jpm 142
	// Nom
143
	public function getNom()
144
	{
145
		return $this->nom;
146
	}
147
	public function setNom( $n )
148
	{
128 jpm 149
		if (!is_null($n)) {
150
			$this->nom = strtoupper($n);
151
		} else {
152
			$this->nom = $n;
153
		}
10 jpm 154
	}
36 jpm 155
 
10 jpm 156
	// Prenom
157
	public function getPrenom()
158
	{
159
		return $this->prenom;
160
	}
161
	public function setPrenom( $p )
162
	{
163
		$this->prenom = $p;
164
	}
36 jpm 165
 
10 jpm 166
	// Password
167
	public function getPassword()
168
	{
169
		return $this->password;
170
	}
171
	public function setPassword( $p )
172
	{
134 jpm 173
		if (!is_null($p)) {
174
			$this->password = md5($p);
175
		} else {
176
			$this->password = $p;
177
		}
10 jpm 178
	}
36 jpm 179
 
10 jpm 180
	// Email
181
	public function getEmail()
182
	{
183
		return $this->email;
184
	}
185
	public function setEmail( $e )
186
	{
187
		$this->email = $e;
188
	}
36 jpm 189
 
10 jpm 190
	// Telephone
191
	public function getTelephone()
192
	{
193
		return $this->telephone;
194
	}
195
	public function setTelephone( $t )
196
	{
54 jpm 197
		$this->telephone = (string) $t;
10 jpm 198
	}
36 jpm 199
 
10 jpm 200
	// Adresse
201
	public function getAdresse()
202
	{
203
		return $this->adresse;
204
	}
205
	public function setAdresse( $a )
206
	{
207
		$this->adresse = $a;
208
	}
36 jpm 209
 
10 jpm 210
	// Code Postal
211
	public function getCodePostal()
212
	{
213
		return $this->code_postal;
214
	}
215
	public function setCodePostal( $cp )
216
	{
217
		$this->code_postal = $cp;
218
	}
36 jpm 219
 
10 jpm 220
	// Ville
221
	public function getVille()
222
	{
223
		return $this->ville;
224
	}
225
	public function setVille( $v )
226
	{
227
		$this->ville = $v;
228
	}
36 jpm 229
 
10 jpm 230
	// Quota Heures Supp
231
	public function getQuotaHeuresSupp()
232
	{
233
		return $this->quota_heures_supp;
234
	}
235
	public function setQuotaHeuresSupp( $qhs )
236
	{
237
		$this->quota_heures_supp = $qhs;
238
	}
36 jpm 239
 
10 jpm 240
	// Conges Payes
241
	public function getCongesPayes()
242
	{
243
		return $this->conges_payes;
244
	}
245
	public function setCongesPayes( $cp )
246
	{
247
		$this->conges_payes = $cp;
248
	}
36 jpm 249
 
67 jpm 250
	// Temps De Travail Jour
251
	public function getTempsDeTravailJour()
10 jpm 252
	{
67 jpm 253
		return $this->temps_de_travail_jour;
10 jpm 254
	}
67 jpm 255
	public function setTempsDeTravailJour( $tdt )
10 jpm 256
	{
67 jpm 257
		$this->temps_de_travail_jour = $tdt;
10 jpm 258
	}
36 jpm 259
 
67 jpm 260
	// Temps De Travail Mois
261
	public function getTempsDeTravailMois()
262
	{
263
		return $this->temps_de_travail_mois;
264
	}
265
	public function setTempsDeTravailMois( $tdt )
266
	{
267
		$this->temps_de_travail_mois = $tdt;
268
	}
269
 
110 jpm 270
	// Tdt Lundi
271
	public function getTdtLundi()
272
	{
273
		return $this->tdt_lundi;
274
	}
275
	public function setTdtLundi( $tdt )
276
	{
277
		$this->tdt_lundi = $tdt;
278
	}
279
 
280
	// Tdt Mardi
281
	public function getTdtMardi()
282
	{
283
		return $this->tdt_mardi;
284
	}
285
	public function setTdtMardi( $tdt )
286
	{
287
		$this->tdt_mardi = $tdt;
288
	}
155 jpm 289
 
110 jpm 290
	// Tdt Mercredi
291
	public function getTdtMercredi()
292
	{
293
		return $this->tdt_mercredi;
294
	}
295
	public function setTdtMercredi( $tdt )
296
	{
297
		$this->tdt_mercredi = $tdt;
298
	}
155 jpm 299
 
110 jpm 300
	// Tdt Jeudi
301
	public function getTdtJeudi()
302
	{
303
		return $this->tdt_jeudi;
304
	}
305
	public function setTdtJeudi( $tdt )
306
	{
307
		$this->tdt_jeudi = $tdt;
308
	}
309
 
310
	// Tdt Vendredi
311
	public function getTdtVendredi()
312
	{
313
		return $this->tdt_vendredi;
314
	}
315
	public function setTdtVendredi( $tdt )
316
	{
317
		$this->tdt_vendredi = $tdt;
318
	}
155 jpm 319
 
110 jpm 320
	// Tdt Samedi
321
	public function getTdtSamedi()
322
	{
323
		return $this->tdt_samedi;
324
	}
325
	public function setTdtSamedi( $tdt )
326
	{
327
		$this->tdt_samedi = $tdt;
328
	}
329
 
330
	// Tdt Dimanche
331
	public function getTdtDimanche()
332
	{
333
		return $this->tdt_dimanche;
334
	}
335
	public function setTdtDimanche( $tdt )
336
	{
337
		$this->tdt_dimanche = $tdt;
338
	}
339
 
155 jpm 340
	// Tdt Par Numéro du jour
341
	public function getTdtParNumJour($num)
342
	{
343
		$tdt = 0;
344
		if ($num == 1) {
345
			$tdt = $this->getTdtLundi();
346
		} else if ($num == 2) {
347
			$tdt = $this->getTdtMardi();
348
		} else if ($num == 3) {
349
			$tdt = $this->getTdtMercredi();
350
		} else if ($num == 4) {
351
			$tdt = $this->getTdtJeudi();
352
		} else if ($num == 5) {
353
			$tdt = $this->getTdtVendredi();
354
		} else if ($num == 6) {
355
			$tdt = $this->getTdtSamedi();
356
		} else if ($num == 7) {
357
			$tdt = $this->getTdtDimanche();
358
		}
359
 
360
		return $tdt;
361
	}
362
 
10 jpm 363
	// Mark Admin
364
	public function getMarkAdmin()
365
	{
366
		return $this->mark_admin;
367
	}
368
	public function setMarkAdmin( $ma )
369
	{
370
		$this->mark_admin = $ma;
371
	}
36 jpm 372
 
10 jpm 373
	// Mark Recapitulatif
374
	public function getMarkRecapitulatif()
375
	{
376
		return $this->mark_recapitulatif;
377
	}
378
	public function setMarkRecapitulatif( $mr )
379
	{
380
		$this->mark_recapitulatif = $mr;
381
	}
36 jpm 382
 
10 jpm 383
	// Notes
384
	public function getNotes()
385
	{
386
		return $this->notes;
387
	}
388
	public function setNotes( $n )
389
	{
390
		$this->notes = $n;
391
	}
36 jpm 392
 
104 jpm 393
	/*** Méthodes : */
10 jpm 394
 
395
	/**
396
	* Consulter la table gestion_utilisateur.
397
	* @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.
398
	*/
399
	public function consulter($cmd = '', $parametres = array(), $instancier = false)
400
	{
401
		switch ($cmd) {
48 jpm 402
			case Utilisateur::GU_TOUS:
403
				$requete = 	'SELECT * '.
404
							'FROM gestion_utilisateur '.
140 jpm 405
							'ORDER BY gu_nom, gu_prenom ASC';
48 jpm 406
				break;
10 jpm 407
			case Utilisateur::GU_ID:
408
				$requete = 	'SELECT * '.
409
							'FROM gestion_utilisateur '.
92 jpm 410
							'WHERE gu_id_utilisateur = #0 ';
10 jpm 411
				break;
412
			case Utilisateur::GU_ID_MAX:
48 jpm 413
				$requete =	'SELECT MAX(gu_id_utilisateur) AS gu_id_utilisateur '.
10 jpm 414
							'FROM gestion_utilisateur ';
415
				break;
48 jpm 416
			case Utilisateur::GU_CE_STATUT:
417
				$requete =	'SELECT * '.
418
							'FROM gestion_utilisateur '.
92 jpm 419
							'WHERE gu_ce_statut = "#0" ';
48 jpm 420
				break;
10 jpm 421
			case Utilisateur::GU_MAIL:
422
				$requete =	'SELECT * '.
423
							'FROM gestion_utilisateur '.
92 jpm 424
							'WHERE gu_email = "#0" ';
67 jpm 425
				break;
426
			case Utilisateur::GU_TOUS_AFFICHABLE:
427
				$requete = 	'SELECT * '.
428
							'FROM gestion_utilisateur '.
429
							'WHERE gu_mark_recapitulatif = 0 '.
140 jpm 430
							'ORDER BY gu_nom, gu_prenom ASC';
95 jpm 431
				break;
432
			case Utilisateur::GU_ADMIN:
433
				$requete = 	'SELECT * '.
434
							'FROM gestion_utilisateur '.
435
							'WHERE gu_mark_admin = 1 ';
436
				break;
155 jpm 437
 
10 jpm 438
			default :
439
				$message = 'Commande '.$cmd.'inconnue!';
440
				$e = GestionnaireErreur::formaterMessageErreur(__FILE__, __LINE__, $message);
441
    			trigger_error($e, E_USER_ERROR);
442
		}
92 jpm 443
		return parent::consulter($requete, $parametres, $instancier);
10 jpm 444
	}
52 jpm 445
 
446
	public function supprimer()
447
	{
448
		$requete = 	'DELETE FROM gestion_utilisateur '.
449
					'WHERE gu_id_utilisateur = '.$this->getIdUtilisateur();
450
		$resultat = $GLOBALS['db']->query($requete);
451
		(DB::isError($resultat)) ? die (GestionnaireErreur::retournerErreurSql(__FILE__, __LINE__, $resultat->getMessage(), $requete)) : '' ;
452
 
453
		if ($GLOBALS['db']->affectedRows() == 1) {
454
			return true;
455
		} elseif ($GLOBALS['db']->affectedRows() == 0) {
456
			return false;
457
		}
458
	}
36 jpm 459
 
10 jpm 460
	/**augmenter le nombre d'heure sup
36 jpm 461
	*un acces est fait a la bse de donnees pour enregistrer les changements en temps reel
10 jpm 462
 	*/
110 jpm 463
	public function augmenterQuotaHeuresSup($nb)
10 jpm 464
	{
110 jpm 465
		$this->quota_heures_supp =  $this->quota_heures_supp + abs($nb);
10 jpm 466
	}
467
 
468
	/**diminuer le nb d'heures sup*/
469
	public function diminuerQuotaHeuresSup($nb)
470
	{
110 jpm 471
		$this->quota_heures_supp =  $this->quota_heures_supp -  abs($nb);
10 jpm 472
		/*un quota heure supp negatif implique qu'il y a des heures a rattraper*/
473
	}
36 jpm 474
 
10 jpm 475
	/**augmenter le nombre de jours de conges */
110 jpm 476
	public function augmenterCongesPayes($nb)
10 jpm 477
	{
110 jpm 478
		$this->conges_payes = $this->conges_payes +  abs($nb);
10 jpm 479
	}
36 jpm 480
 
10 jpm 481
	/**diminuer le nombre de jour de conges */
110 jpm 482
	public function diminuerCongesPayes($nb)
10 jpm 483
	{
110 jpm 484
		$this->conges_payes = $this->conges_payes -  abs($nb);
10 jpm 485
	}
486
}
487
 
488
/* +--Fin du code ----------------------------------------------------------------------------------------+
489
*
490
* $Log$
491
*
492
* +-- Fin du code ----------------------------------------------------------------------------------------+
493
*/
494
?>