Subversion Repositories Applications.gtt

Rev

Rev 110 | Rev 134 | 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
	{
54 jpm 173
		$this->password = md5($p);
10 jpm 174
	}
36 jpm 175
 
10 jpm 176
	// Email
177
	public function getEmail()
178
	{
179
		return $this->email;
180
	}
181
	public function setEmail( $e )
182
	{
183
		$this->email = $e;
184
	}
36 jpm 185
 
10 jpm 186
	// Telephone
187
	public function getTelephone()
188
	{
189
		return $this->telephone;
190
	}
191
	public function setTelephone( $t )
192
	{
54 jpm 193
		$this->telephone = (string) $t;
10 jpm 194
	}
36 jpm 195
 
10 jpm 196
	// Adresse
197
	public function getAdresse()
198
	{
199
		return $this->adresse;
200
	}
201
	public function setAdresse( $a )
202
	{
203
		$this->adresse = $a;
204
	}
36 jpm 205
 
10 jpm 206
	// Code Postal
207
	public function getCodePostal()
208
	{
209
		return $this->code_postal;
210
	}
211
	public function setCodePostal( $cp )
212
	{
213
		$this->code_postal = $cp;
214
	}
36 jpm 215
 
10 jpm 216
	// Ville
217
	public function getVille()
218
	{
219
		return $this->ville;
220
	}
221
	public function setVille( $v )
222
	{
223
		$this->ville = $v;
224
	}
36 jpm 225
 
10 jpm 226
	// Quota Heures Supp
227
	public function getQuotaHeuresSupp()
228
	{
229
		return $this->quota_heures_supp;
230
	}
231
	public function setQuotaHeuresSupp( $qhs )
232
	{
233
		$this->quota_heures_supp = $qhs;
234
	}
36 jpm 235
 
10 jpm 236
	// Conges Payes
237
	public function getCongesPayes()
238
	{
239
		return $this->conges_payes;
240
	}
241
	public function setCongesPayes( $cp )
242
	{
243
		$this->conges_payes = $cp;
244
	}
36 jpm 245
 
67 jpm 246
	// Temps De Travail Jour
247
	public function getTempsDeTravailJour()
10 jpm 248
	{
67 jpm 249
		return $this->temps_de_travail_jour;
10 jpm 250
	}
67 jpm 251
	public function setTempsDeTravailJour( $tdt )
10 jpm 252
	{
67 jpm 253
		$this->temps_de_travail_jour = $tdt;
10 jpm 254
	}
36 jpm 255
 
67 jpm 256
	// Temps De Travail Mois
257
	public function getTempsDeTravailMois()
258
	{
259
		return $this->temps_de_travail_mois;
260
	}
261
	public function setTempsDeTravailMois( $tdt )
262
	{
263
		$this->temps_de_travail_mois = $tdt;
264
	}
265
 
110 jpm 266
	// Tdt Lundi
267
	public function getTdtLundi()
268
	{
269
		return $this->tdt_lundi;
270
	}
271
	public function setTdtLundi( $tdt )
272
	{
273
		$this->tdt_lundi = $tdt;
274
	}
275
 
276
	// Tdt Mardi
277
	public function getTdtMardi()
278
	{
279
		return $this->tdt_mardi;
280
	}
281
	public function setTdtMardi( $tdt )
282
	{
283
		$this->tdt_mardi = $tdt;
284
	}
285
 
286
	// Tdt Mercredi
287
	public function getTdtMercredi()
288
	{
289
		return $this->tdt_mercredi;
290
	}
291
	public function setTdtMercredi( $tdt )
292
	{
293
		$this->tdt_mercredi = $tdt;
294
	}
295
 
296
	// Tdt Jeudi
297
	public function getTdtJeudi()
298
	{
299
		return $this->tdt_jeudi;
300
	}
301
	public function setTdtJeudi( $tdt )
302
	{
303
		$this->tdt_jeudi = $tdt;
304
	}
305
 
306
	// Tdt Vendredi
307
	public function getTdtVendredi()
308
	{
309
		return $this->tdt_vendredi;
310
	}
311
	public function setTdtVendredi( $tdt )
312
	{
313
		$this->tdt_vendredi = $tdt;
314
	}
315
 
316
	// Tdt Samedi
317
	public function getTdtSamedi()
318
	{
319
		return $this->tdt_samedi;
320
	}
321
	public function setTdtSamedi( $tdt )
322
	{
323
		$this->tdt_samedi = $tdt;
324
	}
325
 
326
	// Tdt Dimanche
327
	public function getTdtDimanche()
328
	{
329
		return $this->tdt_dimanche;
330
	}
331
	public function setTdtDimanche( $tdt )
332
	{
333
		$this->tdt_dimanche = $tdt;
334
	}
335
 
10 jpm 336
	// Mark Admin
337
	public function getMarkAdmin()
338
	{
339
		return $this->mark_admin;
340
	}
341
	public function setMarkAdmin( $ma )
342
	{
343
		$this->mark_admin = $ma;
344
	}
36 jpm 345
 
10 jpm 346
	// Mark Recapitulatif
347
	public function getMarkRecapitulatif()
348
	{
349
		return $this->mark_recapitulatif;
350
	}
351
	public function setMarkRecapitulatif( $mr )
352
	{
353
		$this->mark_recapitulatif = $mr;
354
	}
36 jpm 355
 
10 jpm 356
	// Notes
357
	public function getNotes()
358
	{
359
		return $this->notes;
360
	}
361
	public function setNotes( $n )
362
	{
363
		$this->notes = $n;
364
	}
36 jpm 365
 
104 jpm 366
	/*** Méthodes : */
10 jpm 367
 
368
	/**
369
	* Consulter la table gestion_utilisateur.
370
	* @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.
371
	*/
372
	public function consulter($cmd = '', $parametres = array(), $instancier = false)
373
	{
374
		switch ($cmd) {
48 jpm 375
			case Utilisateur::GU_TOUS:
376
				$requete = 	'SELECT * '.
377
							'FROM gestion_utilisateur '.
378
							'ORDER BY gu_prenom, gu_nom ASC';
379
				break;
10 jpm 380
			case Utilisateur::GU_ID:
381
				$requete = 	'SELECT * '.
382
							'FROM gestion_utilisateur '.
92 jpm 383
							'WHERE gu_id_utilisateur = #0 ';
10 jpm 384
				break;
385
			case Utilisateur::GU_ID_MAX:
48 jpm 386
				$requete =	'SELECT MAX(gu_id_utilisateur) AS gu_id_utilisateur '.
10 jpm 387
							'FROM gestion_utilisateur ';
388
				break;
48 jpm 389
			case Utilisateur::GU_CE_STATUT:
390
				$requete =	'SELECT * '.
391
							'FROM gestion_utilisateur '.
92 jpm 392
							'WHERE gu_ce_statut = "#0" ';
48 jpm 393
				break;
10 jpm 394
			case Utilisateur::GU_MAIL:
395
				$requete =	'SELECT * '.
396
							'FROM gestion_utilisateur '.
92 jpm 397
							'WHERE gu_email = "#0" ';
67 jpm 398
				break;
399
			case Utilisateur::GU_TOUS_AFFICHABLE:
400
				$requete = 	'SELECT * '.
401
							'FROM gestion_utilisateur '.
402
							'WHERE gu_mark_recapitulatif = 0 '.
403
							'ORDER BY gu_prenom, gu_nom ASC';
95 jpm 404
				break;
405
			case Utilisateur::GU_ADMIN:
406
				$requete = 	'SELECT * '.
407
							'FROM gestion_utilisateur '.
408
							'WHERE gu_mark_admin = 1 ';
409
				break;
410
 
10 jpm 411
			default :
412
				$message = 'Commande '.$cmd.'inconnue!';
413
				$e = GestionnaireErreur::formaterMessageErreur(__FILE__, __LINE__, $message);
414
    			trigger_error($e, E_USER_ERROR);
415
		}
92 jpm 416
		return parent::consulter($requete, $parametres, $instancier);
10 jpm 417
	}
52 jpm 418
 
419
	public function supprimer()
420
	{
421
		$requete = 	'DELETE FROM gestion_utilisateur '.
422
					'WHERE gu_id_utilisateur = '.$this->getIdUtilisateur();
423
		$resultat = $GLOBALS['db']->query($requete);
424
		(DB::isError($resultat)) ? die (GestionnaireErreur::retournerErreurSql(__FILE__, __LINE__, $resultat->getMessage(), $requete)) : '' ;
425
 
426
		if ($GLOBALS['db']->affectedRows() == 1) {
427
			return true;
428
		} elseif ($GLOBALS['db']->affectedRows() == 0) {
429
			return false;
430
		}
431
	}
36 jpm 432
 
10 jpm 433
	/**augmenter le nombre d'heure sup
36 jpm 434
	*un acces est fait a la bse de donnees pour enregistrer les changements en temps reel
10 jpm 435
 	*/
110 jpm 436
	public function augmenterQuotaHeuresSup($nb)
10 jpm 437
	{
110 jpm 438
		$this->quota_heures_supp =  $this->quota_heures_supp + abs($nb);
10 jpm 439
	}
440
 
441
	/**diminuer le nb d'heures sup*/
442
	public function diminuerQuotaHeuresSup($nb)
443
	{
110 jpm 444
		$this->quota_heures_supp =  $this->quota_heures_supp -  abs($nb);
10 jpm 445
		/*un quota heure supp negatif implique qu'il y a des heures a rattraper*/
446
	}
36 jpm 447
 
10 jpm 448
	/**augmenter le nombre de jours de conges */
110 jpm 449
	public function augmenterCongesPayes($nb)
10 jpm 450
	{
110 jpm 451
		$this->conges_payes = $this->conges_payes +  abs($nb);
10 jpm 452
	}
36 jpm 453
 
10 jpm 454
	/**diminuer le nombre de jour de conges */
110 jpm 455
	public function diminuerCongesPayes($nb)
10 jpm 456
	{
110 jpm 457
		$this->conges_payes = $this->conges_payes -  abs($nb);
10 jpm 458
	}
459
}
460
 
461
/* +--Fin du code ----------------------------------------------------------------------------------------+
462
*
463
* $Log$
464
*
465
* +-- Fin du code ----------------------------------------------------------------------------------------+
466
*/
467
?>