Subversion Repositories Applications.gtt

Rev

Rev 15 | Go to most recent revision | Only display areas with differences | Ignore whitespace | Details | Blame | Last modification | View Log | RSS feed

Rev 15 Rev 48
1
<?php
1
<?php
2
// +------------------------------------------------------------------------------------------------------+
2
// +------------------------------------------------------------------------------------------------------+
3
// | PHP version 5.1.1                                                                                    |
3
// | PHP version 5.1.1                                                                                    |
4
// +------------------------------------------------------------------------------------------------------+
4
// +------------------------------------------------------------------------------------------------------+
5
// | Copyright (C) 2006 Tela Botanica (accueil@tela-botanica.org)                                         |
5
// | Copyright (C) 2006 Tela Botanica (accueil@tela-botanica.org)                                         |
6
// +------------------------------------------------------------------------------------------------------+
6
// +------------------------------------------------------------------------------------------------------+
7
// | This file is part of eFlore.                                                                         |
7
// | This file is part of eFlore.                                                                         |
8
// |                                                                                                      |
8
// |                                                                                                      |
9
// | Foobar is free software; you can redistribute it and/or modify                                       |
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                                 |
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                                    |
11
// | the Free Software Foundation; either version 2 of the License, or                                    |
12
// | (at your option) any later version.                                                                  |
12
// | (at your option) any later version.                                                                  |
13
// |                                                                                                      |
13
// |                                                                                                      |
14
// | Foobar is distributed in the hope that it will be useful,                                            |
14
// | Foobar is distributed in the hope that it will be useful,                                            |
15
// | but WITHOUT ANY WARRANTY; without even the implied warranty of                                       |
15
// | but WITHOUT ANY WARRANTY; without even the implied warranty of                                       |
16
// | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the                                        |
16
// | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the                                        |
17
// | GNU General Public License for more details.                                                         |
17
// | GNU General Public License for more details.                                                         |
18
// |                                                                                                      |
18
// |                                                                                                      |
19
// | You should have received a copy of the GNU General Public License                                    |
19
// | You should have received a copy of the GNU General Public License                                    |
20
// | along with Foobar; if not, write to the Free Software                                                |
20
// | along with Foobar; if not, write to the Free Software                                                |
21
// | Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA                            |
21
// | Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA                            |
22
// +------------------------------------------------------------------------------------------------------+
22
// +------------------------------------------------------------------------------------------------------+
23
// CVS : $Id$
23
// CVS : $Id$
24
/**
24
/**
25
* Classe Absence
25
* Classe Absence
26
*
26
*
27
* Description
27
* Description
28
*
28
*
29
*@package eFlore
29
*@package eFlore
30
*@subpackage modele
30
*@subpackage modele
31
//Auteur original :
31
//Auteur original :
32
*@version 3
32
*@version 3
33
*@author        Shaheen ABDOOL RAHEEM <shaheenar50@hotmail.com>
33
*@author        Shaheen ABDOOL RAHEEM <shaheenar50@hotmail.com>
34
//Autres auteurs :
34
//Autres auteurs :
35
*@version 4
35
*@version 4
36
*@author        Jean-Pascal MILCENT <jpm@clapas.org>
36
*@author        Jean-Pascal MILCENT <jpm@clapas.org>
37
*@author        aucun
37
*@author        aucun
38
*@copyright     Tela-Botanica 2000-2006
38
*@copyright     Tela-Botanica 2000-2006
39
*@version       $Revision$ $Date$
39
*@version       $Revision$ $Date$
40
// +------------------------------------------------------------------------------------------------------+
40
// +------------------------------------------------------------------------------------------------------+
41
*/
41
*/
42
 
42
 
43
/**
43
/**
44
* class Absence : est à la fois le DAO et le conteneur de la table gestion_utilisateur.
44
* class Absence : est à la fois le DAO et le conteneur de la table gestion_utilisateur.
45
* classe métier
45
* classe métier
46
*/
46
*/
47
class Absence extends aGttSql {
47
class Absence extends aGttSql {
48
	/*** Constantes : */
48
	/*** Constantes : */
49
	const GA_ID = 'ABSENCE_ID';
49
	const GA_ID = 'ABSENCE_ID';
-
 
50
	const GA_ID_ABSENCE_MOTIF = 'ABSENCE_ID_ABSENCE_MOTIF';
50
	const GA_ID_UTILISATEUR_DATE_DEB_FIN = 'ABSENCE_ID_UTILISATEUR_DATE_DEB_FIN';
51
	const GA_ID_UTILISATEUR_DATE_DEB_FIN = 'ABSENCE_ID_UTILISATEUR_DATE_DEB_FIN';
51
	const GA_ID_MAX_UTILISATEUR = 'ABSENCE_ID_MAX_UTILISATEUR';
52
	const GA_ID_MAX_UTILISATEUR = 'ABSENCE_ID_MAX_UTILISATEUR';
52
	const GA_ID_MAX_ABSENCE_MOTIF = 'ABSENCE_ID_MAX_ABSENCE_MOTIF';
53
	const GA_ID_MAX_ABSENCE_MOTIF = 'ABSENCE_ID_MAX_ABSENCE_MOTIF';
53
	const GA_ID_MAX_DATE_ABSENCE = 'ABSENCE_ID_MAX_DATE_ABSENCE';
54
	const GA_ID_MAX_DATE_ABSENCE = 'ABSENCE_ID_MAX_DATE_ABSENCE';
54
 
55
 
55
	/*** Attributs : */
56
	/*** Attributs : */
56
	private $id_utilisateur;
57
	private $id_utilisateur;
57
	private $id_absence_motif;
58
	private $id_absence_motif;
58
	private $id_date_absence;
59
	private $id_date_absence;
59
	private $duree;
60
	private $duree;
60
 
61
 
61
	/*** Aggregations : */
62
	/*** Aggregations : */
62
 
63
 
63
	/*** Constructeur : */
64
	/*** Constructeur : */
64
	public function __construct($cmd = null, $parametres = null)
65
	public function __construct($cmd = null, $parametres = null)
65
	{
66
	{
66
		$this->dao_table_nom = 'gestion_absence';
67
		$this->dao_table_nom = 'gestion_absence';
67
		$this->dao_correspondance = array(
68
		$this->dao_correspondance = array(
68
			'ga_id_utilisateur'	=> 'id_utilisateur',
69
			'ga_id_utilisateur'	=> 'id_utilisateur',
69
			'ga_id_absence_motif'	=> 'id_absence_motif',
70
			'ga_id_absence_motif'	=> 'id_absence_motif',
70
			'ga_id_date_absence'	=> 'id_date_absence',
71
			'ga_id_date_absence'	=> 'id_date_absence',
71
			'ga_duree'	=> 'duree');
72
			'ga_duree'	=> 'duree');
72
 
73
 
73
		// Si l'on veut remplir l'objet à la création on lance la requete correspondante
74
		// Si l'on veut remplir l'objet à la création on lance la requete correspondante
74
		if (!is_null($cmd)) {
75
		if (!is_null($cmd)) {
75
			$this->consulter($cmd, $parametres, true);
76
			$this->consulter($cmd, $parametres, true);
76
		}
77
		}
77
	}
78
	}
78
 
79
 
79
	/*** Accesseurs : */
80
	/*** Accesseurs : */
80
	// Id Utilisateur
81
	// Id Utilisateur
81
	public function getIdUtilisateur()
82
	public function getIdUtilisateur()
82
	{
83
	{
83
		return $this->id_utilisateur;
84
		return $this->id_utilisateur;
84
	}
85
	}
85
	public function setIdUtilisateur( $iu )
86
	public function setIdUtilisateur( $iu )
86
	{
87
	{
87
		$this->id_utilisateur = $iu;
88
		$this->id_utilisateur = $iu;
88
	}
89
	}
89
 
90
 
90
	// Id Absence Motif
91
	// Id Absence Motif
91
	public function getIdAbsenceMotif()
92
	public function getIdAbsenceMotif()
92
	{
93
	{
93
		return $this->id_absence_motif;
94
		return $this->id_absence_motif;
94
	}
95
	}
95
	public function setIdAbsenceMotif( $iam )
96
	public function setIdAbsenceMotif( $iam )
96
	{
97
	{
97
		$this->id_absence_motif = $iam;
98
		$this->id_absence_motif = $iam;
98
	}
99
	}
99
 
100
 
100
	// Id Date Absence
101
	// Id Date Absence
101
	public function getIdDateAbsence()
102
	public function getIdDateAbsence()
102
	{
103
	{
103
		return $this->id_date_absence;
104
		return $this->id_date_absence;
104
	}
105
	}
105
	public function setIdDateAbsence( $ida )
106
	public function setIdDateAbsence( $ida )
106
	{
107
	{
107
		$this->id_date_absence = $ida;
108
		$this->id_date_absence = $ida;
108
	}
109
	}
109
 
110
 
110
	// Duree
111
	// Duree
111
	public function getDuree()
112
	public function getDuree()
112
	{
113
	{
113
		return $this->duree;
114
		return $this->duree;
114
	}
115
	}
115
	public function setDuree( $d )
116
	public function setDuree( $d )
116
	{
117
	{
117
		$this->duree = $d;
118
		$this->duree = $d;
118
	}
119
	}
119
 
120
 
120
	/*** Méthodes : */
121
	/*** Méthodes : */
121
 
122
 
122
	/**
123
	/**
123
	* Consulter la table gestion_absence.
124
	* Consulter la table gestion_absence.
124
	* @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.
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.
125
	*/
126
	*/
126
	public function consulter($cmd = '', $parametres = array(), $instancier = false)
127
	public function consulter($cmd = '', $parametres = array(), $instancier = false)
127
	{
128
	{
-
 
129
		if (!is_array($parametres)) {
-
 
130
			$parametres[0] = $parametres;
-
 
131
		}
128
		switch ($cmd) {
132
		switch ($cmd) {
129
			case Absence::GA_ID:
133
			case Absence::GA_ID:
130
				$requete = 	'SELECT * '.
134
				$requete = 	'SELECT * '.
131
							'FROM gestion_absence '.
135
							'FROM gestion_absence '.
132
							'WHERE ga_id_utilisateur = '.$parametres[0].' AND ga_id_absence_motif = '.$parametres[1].' AND ga_id_date_absence = '.$parametres[2].' ';
136
							'WHERE ga_id_utilisateur = '.$parametres[0].' AND ga_id_absence_motif = '.$parametres[1].' AND ga_id_date_absence = '.$parametres[2].' ';
133
				break;
137
				break;
-
 
138
			case Absence::GA_ID_ABSENCE_MOTIF:
-
 
139
				$requete = 	'SELECT * '.
-
 
140
							'FROM gestion_absence '.
-
 
141
							'WHERE ga_id_absence_motif = '.$parametres[0].' ';
-
 
142
				break;
134
			case Absence::GA_ID_UTILISATEUR_DATE_DEB_FIN:
143
			case Absence::GA_ID_UTILISATEUR_DATE_DEB_FIN:
135
				$requete = 	'SELECT * '.
144
				$requete = 	'SELECT * '.
136
							'FROM gestion_absence '.
145
							'FROM gestion_absence '.
137
							'WHERE ga_id_utilisateur = '.$parametres[0].' AND ga_id_date_absence >= "'.$parametres[1].'" '.' AND ga_id_date_absence <= "'.$parametres[2].'" ';
146
							'WHERE ga_id_utilisateur = '.$parametres[0].' AND ga_id_date_absence >= "'.$parametres[1].'" '.' AND ga_id_date_absence <= "'.$parametres[2].'" ';
138
				break;
147
				break;
139
			case Absence::GA_ID_MAX_UTILISATEUR:
148
			case Absence::GA_ID_MAX_UTILISATEUR:
140
				$requete =	'SELECT MAX(ga_id_utilisateur) '.
149
				$requete =	'SELECT MAX(ga_id_utilisateur) '.
141
							'FROM gestion_absence ';
150
							'FROM gestion_absence ';
142
				break;
151
				break;
143
			case Absence::GA_ID_MAX_ABSENCE_MOTIF:
152
			case Absence::GA_ID_MAX_ABSENCE_MOTIF:
144
				$requete =	'SELECT MAX(ga_id_absence_motif) '.
153
				$requete =	'SELECT MAX(ga_id_absence_motif) '.
145
							'FROM gestion_absence ';
154
							'FROM gestion_absence ';
146
				break;
155
				break;
147
			case Absence::GA_ID_MAX_DATE_ABSENCE:
156
			case Absence::GA_ID_MAX_DATE_ABSENCE:
148
				$requete =	'SELECT MAX(ga_id_date_absence) '.
157
				$requete =	'SELECT MAX(ga_id_date_absence) '.
149
							'FROM gestion_absence ';
158
							'FROM gestion_absence ';
150
				break;
159
				break;
151
			default :
160
			default :
152
				$message = 'Commande '.$cmd.'inconnue!';
161
				$message = 'Commande '.$cmd.'inconnue!';
153
				$e = GestionnaireErreur::formaterMessageErreur(__FILE__, __LINE__, $message);
162
				$e = GestionnaireErreur::formaterMessageErreur(__FILE__, __LINE__, $message);
154
    			trigger_error($e, E_USER_ERROR);
163
    			trigger_error($e, E_USER_ERROR);
155
		}
164
		}
156
 
165
 
157
		$resultat = $GLOBALS['db']->query($requete);
166
		$resultat = $GLOBALS['db']->query($requete);
158
		(DB::isError($resultat)) ? die (GestionnaireErreur::retournerErreurSql(__FILE__, __LINE__, $resultat->getMessage(), $requete)) : '' ;
167
		(DB::isError($resultat)) ? die (GestionnaireErreur::retournerErreurSql(__FILE__, __LINE__, $resultat->getMessage(), $requete)) : '' ;
159
		$tab_resultat = array();
168
		$tab_resultat = array();
160
		while ($donnees =& $resultat->fetchRow(DB_FETCHMODE_ASSOC)) {
169
		while ($donnees =& $resultat->fetchRow(DB_FETCHMODE_ASSOC)) {
161
			$tab_resultat[] = $this->basculerEnregistrementObjet($donnees, $instancier);
170
			$tab_resultat[] = $this->basculerEnregistrementObjet($donnees, $instancier);
162
		}
171
		}
163
 
172
 
164
		$resultat_nbre = count($tab_resultat);
173
		$resultat_nbre = count($tab_resultat);
165
		if ($resultat_nbre > 1) {
174
		if ($resultat_nbre > 1) {
166
			return $tab_resultat;
175
			return $tab_resultat;
167
		} else if ($resultat_nbre == 1) {
176
		} else if ($resultat_nbre == 1) {
168
			return $tab_resultat[0];
177
			return $tab_resultat[0];
169
		} else if ($resultat_nbre == 0) {
178
		} else if ($resultat_nbre == 0) {
170
			return false;
179
			return false;
171
		}
180
		}
172
	}
181
	}
173
 
182
 
174
	/** Afficher l'objet Absence */
183
	/** Afficher l'objet Absence */
175
	function afficherAbsence()
184
	function afficherAbsence()
176
	{
185
	{
177
		echo '<pre>'.print_r($this, true).'</pre>';
186
		echo '<pre>'.print_r($this, true).'</pre>';
178
	}
187
	}
179
}
188
}
180
 
189
 
181
/* +--Fin du code ----------------------------------------------------------------------------------------+
190
/* +--Fin du code ----------------------------------------------------------------------------------------+
182
*
191
*
183
* $Log$
192
* $Log$
184
*
193
*
185
* +-- Fin du code ----------------------------------------------------------------------------------------+
194
* +-- Fin du code ----------------------------------------------------------------------------------------+
186
*/
195
*/
187
?>
196
?>