Subversion Repositories Applications.gtt

Rev

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