2 |
jpm |
1 |
<?php
|
|
|
2 |
|
|
|
3 |
// +------------------------------------------------------------------------------------------------------+
|
|
|
4 |
// | PHP version 4.1 |
|
|
|
5 |
// +------------------------------------------------------------------------------------------------------+
|
|
|
6 |
// | Copyright (C) 2004 Tela Botanica (accueil@tela-botanica.org) |
|
|
|
7 |
// +------------------------------------------------------------------------------------------------------+
|
|
|
8 |
// | This library is free software; you can redistribute it and/or |
|
|
|
9 |
// | modify it under the terms of the GNU Lesser General Public |
|
|
|
10 |
// | License as published by the Free Software Foundation; either |
|
|
|
11 |
// | version 2.1 of the License, or (at your option) any later version. |
|
|
|
12 |
// | |
|
|
|
13 |
// | This library is distributed in the hope that it will be useful, |
|
|
|
14 |
// | but WITHOUT ANY WARRANTY; without even the implied warranty of |
|
|
|
15 |
// | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU |
|
|
|
16 |
// | Lesser General Public License for more details. |
|
|
|
17 |
// | |
|
|
|
18 |
// | You should have received a copy of the GNU Lesser General Public |
|
|
|
19 |
// | License along with this library; if not, write to the Free Software |
|
|
|
20 |
// | Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA |
|
|
|
21 |
// +------------------------------------------------------------------------------------------------------+
|
|
|
22 |
|
|
|
23 |
// |@author ABDOOL RAHEEM shaheen shaheenar50@hotmail.com |
|
|
|
24 |
// |@version 3 |
|
|
|
25 |
|
|
|
26 |
|
|
|
27 |
/*
|
|
|
28 |
*gere la table contenant les motifs d'absence
|
|
|
29 |
*/
|
|
|
30 |
|
|
|
31 |
class Motif
|
|
|
32 |
{
|
|
|
33 |
|
|
|
34 |
|
|
|
35 |
/**Attributes: */
|
|
|
36 |
|
|
|
37 |
|
|
|
38 |
var $_id_motif =null;
|
|
|
39 |
|
|
|
40 |
var $_libelle_motif=null;
|
|
|
41 |
|
|
|
42 |
var $_type_rtt=null;
|
|
|
43 |
|
|
|
44 |
/**le type de rtt est ègale à si la condition d'absence occasionne
|
|
|
45 |
*une réduction du temps de travail
|
|
|
46 |
*et est égale à 0 sinon
|
|
|
47 |
*/
|
|
|
48 |
|
|
|
49 |
function Motif($id)
|
|
|
50 |
{
|
|
|
51 |
$this->_id_motif= $id;
|
|
|
52 |
}
|
|
|
53 |
|
|
|
54 |
|
|
|
55 |
/* Construit un motif à partir des paramètres passés dans le tableau*/
|
|
|
56 |
function ConstruireMotif($tableau)
|
|
|
57 |
{
|
|
|
58 |
$this->_id_motif =$tableau[GEST_CHAMPS_ID_MOTIF];
|
|
|
59 |
$this->_libelle_motif = $tableau[GEST_CHAMPS_LIBELLE_MOTIF];
|
|
|
60 |
$this->_type_rtt = $tableau[GEST_CHAMPS_TYPE_RTT];
|
|
|
61 |
}
|
|
|
62 |
|
|
|
63 |
/**
|
|
|
64 |
* enregistre les motifs d'absence
|
|
|
65 |
*renvoi 1 si enregistrement effectué
|
|
|
66 |
*renvoi message d'erreur sinon
|
|
|
67 |
*/
|
|
|
68 |
function enregistrerMotif()
|
|
|
69 |
{
|
|
|
70 |
$table = GEST_MOTIF_ABSENCE;
|
|
|
71 |
$i=$this->nextId();
|
|
|
72 |
$this->_id_motif=$i;
|
|
|
73 |
$champs = array (
|
|
|
74 |
GEST_CHAMPS_ID_MOTIF => $this->_id_motif,
|
|
|
75 |
GEST_CHAMPS_LIBELLE_MOTIF => "$this->_libelle_motif",
|
|
|
76 |
GEST_CHAMPS_TYPE_RTT=> $this->_type_rtt
|
|
|
77 |
);
|
|
|
78 |
|
|
|
79 |
$resultat = $GLOBALS['db']->autoExecute($table, $champs, DB_AUTOQUERY_INSERT);
|
|
|
80 |
|
|
|
81 |
if (DB::isError($resultat)) {
|
|
|
82 |
die($resultat->getMessage());
|
|
|
83 |
}
|
|
|
84 |
|
|
|
85 |
$j=$GLOBALS['db']->affectedRows();
|
|
|
86 |
if($j==1)
|
|
|
87 |
{
|
|
|
88 |
return 1;
|
|
|
89 |
}else return 0;
|
|
|
90 |
|
|
|
91 |
}
|
|
|
92 |
|
|
|
93 |
|
|
|
94 |
/**
|
|
|
95 |
* recupere tous les motifs de la bse de donnees
|
|
|
96 |
*et les renvoie sous forme d'un tableau avec 2 champs
|
|
|
97 |
*: champs identifiant et champs libelle
|
|
|
98 |
*/
|
|
|
99 |
function recupererTableauMotif()
|
|
|
100 |
{
|
|
|
101 |
$tableau = array();
|
|
|
102 |
$i =0;
|
|
|
103 |
$requete="SELECT ".GEST_CHAMPS_ID_MOTIF." , ".GEST_CHAMPS_LIBELLE_MOTIF.",".GEST_CHAMPS_TYPE_RTT
|
|
|
104 |
." FROM ".GEST_MOTIF_ABSENCE."";
|
|
|
105 |
|
|
|
106 |
$resultat = $GLOBALS['db']->query($requete);
|
|
|
107 |
|
|
|
108 |
while ($ligne= $resultat->fetchRow(DB_FETCHMODE_ASSOC))
|
|
|
109 |
{
|
|
|
110 |
$case = array(GEST_CHAMPS_ID_MOTIF => $ligne[GEST_CHAMPS_ID_MOTIF],
|
|
|
111 |
GEST_CHAMPS_LIBELLE_MOTIF =>$ligne[GEST_CHAMPS_LIBELLE_MOTIF],
|
|
|
112 |
GEST_CHAMPS_TYPE_RTT =>$ligne[GEST_CHAMPS_TYPE_RTT]);
|
|
|
113 |
$tableau[$i]=$case;
|
|
|
114 |
$i=$i+1;
|
|
|
115 |
}
|
|
|
116 |
|
|
|
117 |
return $tableau;
|
|
|
118 |
}
|
|
|
119 |
/**
|
|
|
120 |
* supprime un motif de la bse de donnees et detruit l'instance
|
|
|
121 |
*renvoie 1 si motif supprimé
|
|
|
122 |
*renvoie 0 si motif inexistant
|
|
|
123 |
*-1 si erreur
|
|
|
124 |
*/
|
|
|
125 |
function supprimerMotif($id)
|
|
|
126 |
{
|
|
|
127 |
$requete = "DELETE FROM ".GEST_MOTIF_ABSENCE.
|
|
|
128 |
" WHERE ".GEST_CHAMPS_ID_MOTIF."= $id";
|
|
|
129 |
|
|
|
130 |
$resultat = $GLOBALS['db'] ->query($requete);
|
|
|
131 |
|
|
|
132 |
(DB::isError($resultat)) ?
|
|
|
133 |
die (BOG_afficherErreurSql(__FILE__, __LINE__, $resultat->getMessage(), $requete)) : '' ;
|
|
|
134 |
|
|
|
135 |
$int=$GLOBALS['db']->affectedRows();
|
|
|
136 |
|
|
|
137 |
if($int==1)
|
|
|
138 |
{
|
|
|
139 |
return 1;
|
|
|
140 |
}elseif($int==0){
|
|
|
141 |
return 0;
|
|
|
142 |
}else return-1;
|
|
|
143 |
|
|
|
144 |
}
|
|
|
145 |
|
|
|
146 |
/**
|
|
|
147 |
fonction retournant l'idntifiant suivant de la base de donnees
|
|
|
148 |
*/
|
|
|
149 |
|
|
|
150 |
function nextId()
|
|
|
151 |
{
|
|
|
152 |
|
|
|
153 |
$requete = 'SELECT MAX('.GEST_CHAMPS_ID_MOTIF.') AS maxi FROM '.GEST_MOTIF_ABSENCE;
|
|
|
154 |
$resultat = $GLOBALS['db']->query($requete);
|
|
|
155 |
if (DB::isError($resultat) || $resultat->numRows() > 1) {
|
|
|
156 |
return false;
|
|
|
157 |
}
|
|
|
158 |
|
|
|
159 |
$ligne = $resultat->fetchRow(DB_FETCHMODE_OBJECT);
|
|
|
160 |
return $ligne->maxi + 1;
|
|
|
161 |
}
|
|
|
162 |
|
|
|
163 |
|
|
|
164 |
|
|
|
165 |
/**
|
|
|
166 |
*modifie le type de rtt
|
|
|
167 |
*/
|
|
|
168 |
function setRtt($typeRtt)
|
|
|
169 |
{
|
|
|
170 |
$requete = " UPDATE ".GEST_MOTIF_ABSENCE." SET "
|
|
|
171 |
.GEST_CHAMPS_TYPE_RTT." =$typeRtt WHERE ".GEST_CHAMPS_ID_MOTIF." = $this->_id_motif";
|
|
|
172 |
|
|
|
173 |
|
|
|
174 |
$resultat = $GLOBALS['db']->query($requete);
|
|
|
175 |
(DB::isError($resultat)) ?
|
|
|
176 |
die (BOG_afficherErreurSql(__FILE__, __LINE__, $resultat->getMessage(), $requete)) : '' ;
|
|
|
177 |
|
|
|
178 |
$this->_type_rtt = $typeRtt;
|
|
|
179 |
}
|
|
|
180 |
/**
|
|
|
181 |
*fonction verifiant si le motif d'absence est en cours d'utilisation
|
|
|
182 |
*la suppression sera interdite dans ce cas afin de maintenir la cohérence de
|
|
|
183 |
*de la base de donnees
|
|
|
184 |
*renvoie 1 si le motif est utilisé
|
|
|
185 |
*-1 sinon
|
|
|
186 |
*/
|
|
|
187 |
|
|
|
188 |
function motifUtilise($id)
|
|
|
189 |
{
|
|
|
190 |
$requete="SELECT ".GEST_CHAMPS_ID_UTILISATEUR.
|
|
|
191 |
" FROM ".GEST_ABSENCE.
|
|
|
192 |
" WHERE ". GEST_CHAMPS_ID_MOTIF." = $id";
|
|
|
193 |
$ligne= $GLOBALS['db']->query($requete);
|
|
|
194 |
|
|
|
195 |
(DB::isError($ligne)) ?
|
|
|
196 |
die (BOG_afficherErreurSql(__FILE__, __LINE__, $ligne->getMessage(), $requete)) : '' ;
|
|
|
197 |
$j= $ligne->numRows();
|
|
|
198 |
if ($j==0){
|
|
|
199 |
return -1;
|
|
|
200 |
}else {
|
|
|
201 |
return 1;
|
|
|
202 |
}
|
|
|
203 |
}
|
|
|
204 |
|
|
|
205 |
|
|
|
206 |
/*afficher un motif */
|
|
|
207 |
|
|
|
208 |
function afficherMotif()
|
|
|
209 |
{
|
|
|
210 |
echo "Motif : \n";
|
|
|
211 |
echo "id :";
|
|
|
212 |
echo "$this->_id_motif <BR>";
|
|
|
213 |
echo "libelle :";
|
|
|
214 |
echo "$this->_libelle_motif <BR>";
|
|
|
215 |
echo "type rtt :";
|
|
|
216 |
echo "$this->_type_rtt <BR>";
|
|
|
217 |
}
|
|
|
218 |
}
|
|
|
219 |
?>
|