2 |
jpm |
1 |
<?php
|
|
|
2 |
// +------------------------------------------------------------------------------------------------------+
|
|
|
3 |
// | PHP version 4.1 |
|
|
|
4 |
// +------------------------------------------------------------------------------------------------------+
|
|
|
5 |
// | Copyright (C) 2004 Tela Botanica (accueil@tela-botanica.org) |
|
|
|
6 |
// +------------------------------------------------------------------------------------------------------+
|
|
|
7 |
// | This library is free software; you can redistribute it and/or |
|
|
|
8 |
// | modify it under the terms of the GNU Lesser General Public |
|
|
|
9 |
// | License as published by the Free Software Foundation; either |
|
|
|
10 |
// | version 2.1 of the License, or (at your option) any later version. |
|
|
|
11 |
// | |
|
|
|
12 |
// | This library is distributed in the hope that it will be useful, |
|
|
|
13 |
// | but WITHOUT ANY WARRANTY; without even the implied warranty of |
|
|
|
14 |
// | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU |
|
|
|
15 |
// | Lesser General Public License for more details. |
|
|
|
16 |
// | |
|
|
|
17 |
// | You should have received a copy of the GNU Lesser General Public |
|
|
|
18 |
// | License along with $this library; if not, write to the Free Software |
|
|
|
19 |
// | Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA |
|
|
|
20 |
// +------------------------------------------------------------------------------------------------------+
|
|
|
21 |
|
|
|
22 |
// |@author ABDOOL RAHEEM shaheen shaheenar50@hotmail.com |
|
|
|
23 |
// |@version 3 |
|
|
|
24 |
|
|
|
25 |
include_once 'gtt_taches.class.php';
|
|
|
26 |
/**
|
|
|
27 |
* class Projet
|
|
|
28 |
*
|
|
|
29 |
*/
|
|
|
30 |
|
|
|
31 |
class Projet
|
|
|
32 |
{
|
|
|
33 |
|
|
|
34 |
/**Aggregations: */
|
|
|
35 |
|
|
|
36 |
var $liste_taches = array();
|
|
|
37 |
/**Attributes: */
|
|
|
38 |
var $_id_projet=null;
|
|
|
39 |
|
|
|
40 |
var $_nom_projet=null;
|
|
|
41 |
|
|
|
42 |
var $_description_projet=null;
|
|
|
43 |
|
|
|
44 |
var $_date_debut_projet = null;
|
|
|
45 |
|
|
|
46 |
var $_duree_prevue_projet=null;
|
|
|
47 |
|
|
|
48 |
var $_avancement_projet=null;
|
|
|
49 |
|
|
|
50 |
var $_categorie=null;
|
|
|
51 |
|
|
|
52 |
|
|
|
53 |
/**
|
|
|
54 |
*constructeur
|
|
|
55 |
*/
|
|
|
56 |
function Projet($id)
|
|
|
57 |
{
|
|
|
58 |
$this->_id_projet= $id;
|
|
|
59 |
}
|
|
|
60 |
|
|
|
61 |
/**
|
|
|
62 |
*construit un projet a partir d'un tableau associatif
|
|
|
63 |
*le tableau ne contient toutefois pas la liste de taches
|
|
|
64 |
*/
|
|
|
65 |
function construireProjet($tableau)
|
|
|
66 |
{
|
|
|
67 |
|
|
|
68 |
$this->_nom_projet=$tableau[GEST_CHAMPS_NOM_PROJET];
|
|
|
69 |
$this->_description_projet=$tableau[GEST_CHAMPS_DESCRIPTION_PROJET];
|
|
|
70 |
$this->_date_debut_projet=$tableau[GEST_CHAMPS_DATE_DEBUT_PROJET];
|
|
|
71 |
$this->_duree_prevue_projet= $tableau[GEST_CHAMPS_DUREE_PREVUE_PROJET];
|
|
|
72 |
$this->_avancement_projet=$tableau[GEST_CHAMPS_AVANCEMENT_PROJET];
|
|
|
73 |
$this->_categorie=$tableau[GEST_CHAMPS_ID_CATEGORIE];
|
|
|
74 |
}
|
|
|
75 |
|
|
|
76 |
/**
|
|
|
77 |
*recupere l'identifiant de la base de donnees
|
|
|
78 |
*/
|
|
|
79 |
|
|
|
80 |
function nextId()
|
|
|
81 |
{
|
|
|
82 |
$requete = 'SELECT MAX('.GEST_CHAMPS_ID_PROJET.') AS maxi FROM '.GEST_PROJET;
|
|
|
83 |
$resultat = $GLOBALS['db']->query($requete);
|
|
|
84 |
if (DB::isError($resultat) || $resultat->numRows() > 1) {
|
|
|
85 |
return false;
|
|
|
86 |
}
|
|
|
87 |
|
|
|
88 |
$ligne = $resultat->fetchRow(DB_FETCHMODE_OBJECT);
|
|
|
89 |
return $ligne->maxi + 1;
|
|
|
90 |
}
|
|
|
91 |
|
|
|
92 |
|
|
|
93 |
/**
|
|
|
94 |
* enregistre un nouveau projet
|
|
|
95 |
*renvoie 0 si aucun enregistrement effectue,
|
|
|
96 |
*1 si enregistrement ok
|
|
|
97 |
*-1 si erreur
|
|
|
98 |
*on suppose qu'on aura pas d'erreur car
|
|
|
99 |
*on controle les projets a enregistrer : pas de duplicata
|
|
|
100 |
*/
|
|
|
101 |
function enregistrerNewProjet()
|
|
|
102 |
{
|
|
|
103 |
$table=GEST_PROJET;
|
|
|
104 |
$p=&Projet::nextId();
|
|
|
105 |
$this->_id_projet=$p;
|
|
|
106 |
|
|
|
107 |
$champs=array(
|
|
|
108 |
GEST_CHAMPS_ID_PROJET =>$this->_id_projet,
|
|
|
109 |
GEST_CHAMPS_NOM_PROJET => "$this->_nom_projet",
|
|
|
110 |
GEST_CHAMPS_DESCRIPTION_PROJET =>"$this->_description_projet",
|
|
|
111 |
GEST_CHAMPS_DATE_DEBUT_PROJET =>$this->_date_debut_projet,
|
|
|
112 |
GEST_CHAMPS_DUREE_PREVUE_PROJET =>$this->_duree_prevue_projet,
|
|
|
113 |
GEST_CHAMPS_AVANCEMENT_PROJET =>$this->_avancement_projet,
|
|
|
114 |
GEST_CHAMPS_ID_CATEGORIE => $this->_categorie);
|
|
|
115 |
|
|
|
116 |
$resultat = $GLOBALS['db']->autoExecute($table, $champs,DB_AUTOQUERY_INSERT);
|
|
|
117 |
|
|
|
118 |
if (DB::isError($resultat)) {
|
|
|
119 |
die($resultat->getMessage());
|
|
|
120 |
}
|
|
|
121 |
|
|
|
122 |
$j =$GLOBALS['db']->affectedRows($resultat);
|
|
|
123 |
return $j;
|
|
|
124 |
}
|
|
|
125 |
/*
|
|
|
126 |
*recupere une liste de taches
|
|
|
127 |
*/
|
|
|
128 |
function recupererListeTaches()
|
|
|
129 |
{
|
|
|
130 |
|
|
|
131 |
}
|
|
|
132 |
|
|
|
133 |
/*
|
|
|
134 |
* modifie la liste de taches
|
|
|
135 |
*@param $t : tableau de taches
|
|
|
136 |
*/
|
|
|
137 |
function setListeTaches($t)
|
|
|
138 |
{
|
|
|
139 |
$this->_liste_taches= $t;
|
|
|
140 |
}
|
|
|
141 |
|
|
|
142 |
/**
|
|
|
143 |
*recupere un projet pour instancier l'objet
|
|
|
144 |
*renvoie -1 si erreur
|
|
|
145 |
*renvoie utilisateur sinon
|
|
|
146 |
*/
|
|
|
147 |
function recupererProjet($id)
|
|
|
148 |
{
|
|
|
149 |
$requete="SELECT ".GEST_CHAMPS_NOM_PROJET.", ".GEST_CHAMPS_DESCRIPTION_PROJET.", ".GEST_CHAMPS_DATE_DEBUT_PROJET.", "
|
|
|
150 |
.GEST_CHAMPS_DUREE_PREVUE_PROJET.", ".GEST_CHAMPS_AVANCEMENT_PROJET." , ".GEST_CHAMPS_ID_CATEGORIE.
|
|
|
151 |
" FROM ".GEST_PROJET.
|
|
|
152 |
" WHERE ".GEST_CHAMPS_ID_PROJET." = $id";
|
|
|
153 |
|
|
|
154 |
$resultat = $GLOBALS['db']->query($requete);
|
|
|
155 |
|
|
|
156 |
(DB::isError($resultat)) ?
|
|
|
157 |
die (BOG_afficherErreurSql(__FILE__, __LINE__, $resultat->getMessage(), $requete)) : '' ;
|
|
|
158 |
|
|
|
159 |
$tab = $resultat->fetchRow(DB_FETCHMODE_ASSOC);
|
|
|
160 |
$j=$resultat->numRows();
|
|
|
161 |
if ($j==1)
|
|
|
162 |
{
|
|
|
163 |
$project = new Projet($id);
|
|
|
164 |
$project->construireProjet($tab);
|
|
|
165 |
return $project;
|
|
|
166 |
//recuperation de la liste de taches
|
|
|
167 |
|
|
|
168 |
|
|
|
169 |
}else {
|
|
|
170 |
return -1;
|
|
|
171 |
}
|
|
|
172 |
|
|
|
173 |
}
|
|
|
174 |
/**
|
|
|
175 |
*fonction verifiant si le projet contient des taches
|
|
|
176 |
*renvoie 1 si le projet contient des taches
|
|
|
177 |
*et 0 sinon
|
|
|
178 |
*/
|
|
|
179 |
|
|
|
180 |
function contientTache($id)
|
|
|
181 |
{
|
|
|
182 |
$requete="SELECT ".GEST_CHAMPS_ID_TACHE.
|
|
|
183 |
" FROM ".GEST_TACHES.
|
|
|
184 |
" WHERE ".GEST_CHAMPS_ID_PROJET." = $id ";
|
|
|
185 |
|
|
|
186 |
$ligne= $GLOBALS['db']->query($requete);
|
|
|
187 |
|
|
|
188 |
(DB::isError($ligne)) ?
|
|
|
189 |
die (BOG_afficherErreurSql(__FILE__, __LINE__, $ligne->getMessage(), $requete)) : '' ;
|
|
|
190 |
|
|
|
191 |
$j= $ligne->numRows();
|
|
|
192 |
if ($j==0){
|
|
|
193 |
return -1;
|
|
|
194 |
}else {
|
|
|
195 |
return 1;
|
|
|
196 |
}
|
|
|
197 |
}
|
|
|
198 |
|
|
|
199 |
/**
|
|
|
200 |
*supprime un projet de la base de donnees
|
|
|
201 |
*ne prend pas en compte les taches
|
|
|
202 |
*/
|
|
|
203 |
function supprimerProjet($id)
|
|
|
204 |
{
|
|
|
205 |
$requete="DELETE FROM ".GEST_PROJET.
|
|
|
206 |
" WHERE ".GEST_CHAMPS_ID_PROJET." =$id";
|
|
|
207 |
|
|
|
208 |
$ligne=$GLOBALS['db']->query($requete);
|
|
|
209 |
(DB::isError($ligne)) ?
|
|
|
210 |
die (BOG_afficherErreurSql(__FILE__, __LINE__, $ligne->getMessage(), $requete)) : '' ;
|
|
|
211 |
|
|
|
212 |
$j=$GLOBALS['db']->affectedRows();
|
|
|
213 |
return $j;
|
|
|
214 |
}
|
|
|
215 |
|
|
|
216 |
/**
|
|
|
217 |
*fonction recuperant la date de debut d'un projet
|
|
|
218 |
*/
|
|
|
219 |
function getDateDeb()
|
|
|
220 |
{
|
|
|
221 |
return $this->_date_debut_projet;
|
|
|
222 |
}
|
|
|
223 |
/**
|
|
|
224 |
*fonction recuperant la duree prevue
|
|
|
225 |
*/
|
|
|
226 |
function getDureePrevue()
|
|
|
227 |
{
|
|
|
228 |
return $this->_duree_prevue_projet;
|
|
|
229 |
}
|
|
|
230 |
/**
|
|
|
231 |
*etablit le pourcentage d'avancement du projet
|
|
|
232 |
*/
|
|
|
233 |
function setAvancement($pourcentage)
|
|
|
234 |
{
|
|
|
235 |
$this->_avancement_projet=$pourcentage;
|
|
|
236 |
}
|
|
|
237 |
|
|
|
238 |
/*
|
|
|
239 |
*modofie la duree prevue
|
|
|
240 |
*/
|
|
|
241 |
|
|
|
242 |
function setDureePrevue($d)
|
|
|
243 |
{
|
|
|
244 |
$this->_duree_prevue_projet = $d;
|
|
|
245 |
}
|
|
|
246 |
/*
|
|
|
247 |
*modifie la description
|
|
|
248 |
*/
|
|
|
249 |
|
|
|
250 |
function setDescription($desc)
|
|
|
251 |
{
|
|
|
252 |
$this->_description_projet = $desc;
|
|
|
253 |
}
|
|
|
254 |
|
|
|
255 |
function mettreAJourProjet()
|
|
|
256 |
{
|
|
|
257 |
$table=GEST_PROJET;
|
|
|
258 |
|
|
|
259 |
$requete="UPDATE $table SET "
|
|
|
260 |
.GEST_CHAMPS_NOM_PROJET." = \"$this->_nom_projet\","
|
|
|
261 |
.GEST_CHAMPS_DESCRIPTION_PROJET." =\"$this->_description_projet\","
|
|
|
262 |
.GEST_CHAMPS_DATE_DEBUT_PROJET." =\"$this->_date_debut_projet\","
|
|
|
263 |
.GEST_CHAMPS_DUREE_PREVUE_PROJET." =$this->_duree_prevue_projet,"
|
|
|
264 |
.GEST_CHAMPS_AVANCEMENT_PROJET." =$this->_avancement_projet,"
|
|
|
265 |
.GEST_CHAMPS_ID_CATEGORIE." = $this->_categorie"
|
|
|
266 |
." WHERE ".GEST_CHAMPS_ID_PROJET." =$this->_id_projet";
|
|
|
267 |
|
|
|
268 |
$resultat= $GLOBALS['db']->query($requete);
|
|
|
269 |
(DB::isError($resultat)) ?
|
|
|
270 |
die (BOG_afficherErreurSql(__FILE__, __LINE__, $resultat->getMessage(), $requete)) : '' ;
|
|
|
271 |
|
|
|
272 |
|
|
|
273 |
$j= $GLOBALS['db']->affectedRows();
|
|
|
274 |
echo "$j";
|
|
|
275 |
|
|
|
276 |
switch ($j)
|
|
|
277 |
{
|
|
|
278 |
case 0: return 0;
|
|
|
279 |
case 1: return 1;
|
|
|
280 |
default: return -1;
|
|
|
281 |
}
|
|
|
282 |
|
|
|
283 |
}
|
9 |
jpm |
284 |
/** Méthode recuperant la liste de projets */
|
|
|
285 |
function recupererTableauProjet()
|
|
|
286 |
{
|
|
|
287 |
$requete = 'SELECT '.GEST_CHAMPS_ID_PROJET." , ".GEST_CHAMPS_NOM_PROJET.",C.".GEST_CHAMPS_ID_CATEGORIE.",C.".GEST_CHAMPS_LIBELLE_CATEGORIE.
|
|
|
288 |
" FROM ".GEST_PROJET." P ,".GEST_CATEGORIE." C ".
|
|
|
289 |
" WHERE P.".GEST_CHAMPS_ID_CATEGORIE." = C.".GEST_CHAMPS_ID_CATEGORIE.
|
|
|
290 |
" ORDER BY C.".GEST_CHAMPS_ID_CATEGORIE;
|
|
|
291 |
$tab = array();
|
|
|
292 |
$resultat = $GLOBALS['db']->query($requete);
|
|
|
293 |
(DB::isError($resultat)) ? die (BOG_afficherErreurSql(__FILE__, __LINE__, $resultat->getMessage(), $requete)) : '' ;
|
|
|
294 |
|
|
|
295 |
$j = $resultat->numRows();
|
|
|
296 |
if ($j != 0) {
|
|
|
297 |
while($ligne = $resultat->fetchRow(DB_FETCHMODE_ASSOC)) {
|
|
|
298 |
$case = array( GEST_CHAMPS_ID_PROJET => $ligne[GEST_CHAMPS_ID_PROJET],
|
|
|
299 |
GEST_CHAMPS_NOM_PROJET => $ligne[GEST_CHAMPS_NOM_PROJET],
|
|
|
300 |
GEST_CHAMPS_LIBELLE_CATEGORIE => $ligne[GEST_CHAMPS_LIBELLE_CATEGORIE]);
|
|
|
301 |
array_push($tab, $case);
|
|
|
302 |
}
|
|
|
303 |
}
|
|
|
304 |
return $tab;
|
|
|
305 |
}
|
|
|
306 |
|
2 |
jpm |
307 |
/**
|
|
|
308 |
*fonction recuperant la tache par defaut d'un projet
|
|
|
309 |
*tache par defaut : tache s'appelant general
|
|
|
310 |
*@id : identifiant du projet
|
|
|
311 |
*@param : $nom : nom de la atche par default
|
|
|
312 |
*@return identifiant de la tache
|
|
|
313 |
*/
|
|
|
314 |
|
|
|
315 |
function getDefaultTache($id, $nom)
|
|
|
316 |
{
|
|
|
317 |
$requete="SELECT ".GEST_CHAMPS_ID_TACHE.
|
|
|
318 |
" FROM ".GEST_TACHES.
|
|
|
319 |
" WHERE ".GEST_CHAMPS_ID_PROJET." = $id ".
|
|
|
320 |
" AND ".GEST_CHAMPS_NOM_TACHE."=\" $nom\"";
|
|
|
321 |
$ligne= $GLOBALS['db']->query($requete);
|
|
|
322 |
|
|
|
323 |
(DB::isError($ligne)) ?
|
|
|
324 |
die (BOG_afficherErreurSql(__FILE__, __LINE__, $ligne->getMessage(), $requete)) : '' ;
|
|
|
325 |
|
|
|
326 |
$j= $ligne->numRows();
|
|
|
327 |
if ($j==1)
|
|
|
328 |
{
|
|
|
329 |
$resultat=$ligne->fetchRow(DB_FETCHMODE_ORDERED);
|
|
|
330 |
return $resultat[0];
|
|
|
331 |
}else return -1;
|
|
|
332 |
|
|
|
333 |
}
|
|
|
334 |
|
|
|
335 |
function afficherProjet()
|
|
|
336 |
{
|
|
|
337 |
echo "<br /> projet: ";
|
|
|
338 |
echo "id projet: \n";
|
|
|
339 |
echo"$this->_id_projet <br /> ";
|
|
|
340 |
echo "nom projet: \n";
|
|
|
341 |
echo"$this->_nom_projet <br /> ";
|
|
|
342 |
echo "description projet: \n";
|
|
|
343 |
echo"$this->_description_projet <br /> ";
|
|
|
344 |
echo "avancement : \n";
|
|
|
345 |
echo"$this->_avancement_projet <br /> ";
|
|
|
346 |
echo "date debut projet: \n";
|
|
|
347 |
echo"$this->_date_debut_projet <br /> ";
|
|
|
348 |
echo "duree prevue du projet: \n";
|
|
|
349 |
echo"$this->_duree_prevue_projet <br /> ";
|
|
|
350 |
echo "categorie : ";
|
|
|
351 |
echo "$this->_categorie <br />";
|
|
|
352 |
echo "liste de taches : ";
|
|
|
353 |
$liste=$this->_liste_taches;
|
|
|
354 |
if (isset($liste))
|
|
|
355 |
{
|
|
|
356 |
foreach ($liste as $t)
|
|
|
357 |
{
|
|
|
358 |
echo "$t \t , ";
|
|
|
359 |
}
|
|
|
360 |
}
|
|
|
361 |
echo "<br />";
|
|
|
362 |
}
|
|
|
363 |
|
|
|
364 |
}
|
|
|
365 |
?>
|