Subversion Repositories Applications.gtt

Rev

Rev 15 | 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 Absence
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 Absence : est à la fois le DAO et le conteneur de la table gestion_utilisateur.
45
* classe métier
46
*/
47
class Absence extends aGttSql {
48
	/*** Constantes : */
15 jpm 49
	const GA_ID = 'ABSENCE_ID';
48 jpm 50
	const GA_ID_ABSENCE_MOTIF = 'ABSENCE_ID_ABSENCE_MOTIF';
15 jpm 51
	const GA_ID_UTILISATEUR_DATE_DEB_FIN = 'ABSENCE_ID_UTILISATEUR_DATE_DEB_FIN';
52
	const GA_ID_MAX_UTILISATEUR = 'ABSENCE_ID_MAX_UTILISATEUR';
53
	const GA_ID_MAX_ABSENCE_MOTIF = 'ABSENCE_ID_MAX_ABSENCE_MOTIF';
54
	const GA_ID_MAX_DATE_ABSENCE = 'ABSENCE_ID_MAX_DATE_ABSENCE';
55
 
10 jpm 56
	/*** Attributs : */
15 jpm 57
	private $id_utilisateur;
58
	private $id_absence_motif;
59
	private $id_date_absence;
60
	private $duree;
61
 
10 jpm 62
	/*** Aggregations : */
63
 
64
	/*** Constructeur : */
65
	public function __construct($cmd = null, $parametres = null)
66
	{
67
		$this->dao_table_nom = 'gestion_absence';
68
		$this->dao_correspondance = array(
15 jpm 69
			'ga_id_utilisateur'	=> 'id_utilisateur',
70
			'ga_id_absence_motif'	=> 'id_absence_motif',
71
			'ga_id_date_absence'	=> 'id_date_absence',
72
			'ga_duree'	=> 'duree');
73
 
10 jpm 74
		// Si l'on veut remplir l'objet à la création on lance la requete correspondante
75
		if (!is_null($cmd)) {
76
			$this->consulter($cmd, $parametres, true);
77
		}
78
	}
15 jpm 79
 
10 jpm 80
	/*** Accesseurs : */
15 jpm 81
	// Id Utilisateur
82
	public function getIdUtilisateur()
10 jpm 83
	{
15 jpm 84
		return $this->id_utilisateur;
10 jpm 85
	}
15 jpm 86
	public function setIdUtilisateur( $iu )
10 jpm 87
	{
15 jpm 88
		$this->id_utilisateur = $iu;
10 jpm 89
	}
15 jpm 90
 
91
	// Id Absence Motif
92
	public function getIdAbsenceMotif()
10 jpm 93
	{
15 jpm 94
		return $this->id_absence_motif;
10 jpm 95
	}
15 jpm 96
	public function setIdAbsenceMotif( $iam )
10 jpm 97
	{
15 jpm 98
		$this->id_absence_motif = $iam;
10 jpm 99
	}
15 jpm 100
 
101
	// Id Date Absence
102
	public function getIdDateAbsence()
10 jpm 103
	{
15 jpm 104
		return $this->id_date_absence;
10 jpm 105
	}
15 jpm 106
	public function setIdDateAbsence( $ida )
10 jpm 107
	{
15 jpm 108
		$this->id_date_absence = $ida;
10 jpm 109
	}
15 jpm 110
 
111
	// Duree
112
	public function getDuree()
10 jpm 113
	{
15 jpm 114
		return $this->duree;
10 jpm 115
	}
15 jpm 116
	public function setDuree( $d )
10 jpm 117
	{
15 jpm 118
		$this->duree = $d;
10 jpm 119
	}
15 jpm 120
 
10 jpm 121
	/*** Méthodes : */
122
 
123
	/**
124
	* Consulter la table gestion_absence.
125
	* @return mixed un tableau d'objets Absence s'il y en a plusieurs, l'objet Absence s'il y en a 1 seul sinon false.
126
	*/
127
	public function consulter($cmd = '', $parametres = array(), $instancier = false)
128
	{
48 jpm 129
		if (!is_array($parametres)) {
130
			$parametres[0] = $parametres;
131
		}
10 jpm 132
		switch ($cmd) {
133
			case Absence::GA_ID:
134
				$requete = 	'SELECT * '.
135
							'FROM gestion_absence '.
15 jpm 136
							'WHERE ga_id_utilisateur = '.$parametres[0].' AND ga_id_absence_motif = '.$parametres[1].' AND ga_id_date_absence = '.$parametres[2].' ';
137
				break;
48 jpm 138
			case Absence::GA_ID_ABSENCE_MOTIF:
139
				$requete = 	'SELECT * '.
140
							'FROM gestion_absence '.
141
							'WHERE ga_id_absence_motif = '.$parametres[0].' ';
142
				break;
15 jpm 143
			case Absence::GA_ID_UTILISATEUR_DATE_DEB_FIN:
144
				$requete = 	'SELECT * '.
145
							'FROM gestion_absence '.
146
							'WHERE ga_id_utilisateur = '.$parametres[0].' AND ga_id_date_absence >= "'.$parametres[1].'" '.' AND ga_id_date_absence <= "'.$parametres[2].'" ';
10 jpm 147
				break;
15 jpm 148
			case Absence::GA_ID_MAX_UTILISATEUR:
149
				$requete =	'SELECT MAX(ga_id_utilisateur) '.
10 jpm 150
							'FROM gestion_absence ';
151
				break;
15 jpm 152
			case Absence::GA_ID_MAX_ABSENCE_MOTIF:
153
				$requete =	'SELECT MAX(ga_id_absence_motif) '.
154
							'FROM gestion_absence ';
155
				break;
156
			case Absence::GA_ID_MAX_DATE_ABSENCE:
157
				$requete =	'SELECT MAX(ga_id_date_absence) '.
158
							'FROM gestion_absence ';
159
				break;
10 jpm 160
			default :
161
				$message = 'Commande '.$cmd.'inconnue!';
162
				$e = GestionnaireErreur::formaterMessageErreur(__FILE__, __LINE__, $message);
163
    			trigger_error($e, E_USER_ERROR);
164
		}
15 jpm 165
 
10 jpm 166
		$resultat = $GLOBALS['db']->query($requete);
167
		(DB::isError($resultat)) ? die (GestionnaireErreur::retournerErreurSql(__FILE__, __LINE__, $resultat->getMessage(), $requete)) : '' ;
168
		$tab_resultat = array();
169
		while ($donnees =& $resultat->fetchRow(DB_FETCHMODE_ASSOC)) {
170
			$tab_resultat[] = $this->basculerEnregistrementObjet($donnees, $instancier);
171
		}
15 jpm 172
 
173
		$resultat_nbre = count($tab_resultat);
10 jpm 174
		if ($resultat_nbre > 1) {
175
			return $tab_resultat;
176
		} else if ($resultat_nbre == 1) {
177
			return $tab_resultat[0];
178
		} else if ($resultat_nbre == 0) {
179
			return false;
180
		}
181
	}
15 jpm 182
 
10 jpm 183
	/** Afficher l'objet Absence */
184
	function afficherAbsence()
185
	{
186
		echo '<pre>'.print_r($this, true).'</pre>';
187
	}
188
}
189
 
190
/* +--Fin du code ----------------------------------------------------------------------------------------+
191
*
192
* $Log$
193
*
194
* +-- Fin du code ----------------------------------------------------------------------------------------+
195
*/
196
?>