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