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 |
|
|
|
26 |
/**
|
|
|
27 |
*classe servant d'interface
|
|
|
28 |
*avec la base de données pour éditer les statut
|
|
|
29 |
entant qu'administrateur*/
|
|
|
30 |
|
|
|
31 |
|
|
|
32 |
|
|
|
33 |
class Statut
|
|
|
34 |
{
|
|
|
35 |
|
|
|
36 |
/**Attributes: */
|
|
|
37 |
|
|
|
38 |
var $_id_statut= null;
|
|
|
39 |
var $_libelle_statut = null;
|
|
|
40 |
|
|
|
41 |
/*
|
|
|
42 |
*constructeur : @param no identifiant du statut
|
|
|
43 |
*/
|
|
|
44 |
function Statut($id)
|
|
|
45 |
{
|
|
|
46 |
$this->_id_statut =$id;
|
|
|
47 |
}
|
|
|
48 |
|
|
|
49 |
/*met à jour le libelle */
|
|
|
50 |
function setLibelleStatut($lib)
|
|
|
51 |
{
|
|
|
52 |
$this->_libelle_statut= $lib;
|
|
|
53 |
}
|
|
|
54 |
|
|
|
55 |
/*enregistre un nouveau statut dans la base de donnees*/
|
|
|
56 |
|
|
|
57 |
function enregistrerStatut( )
|
|
|
58 |
{
|
|
|
59 |
$table=GEST_STATUT;
|
|
|
60 |
$d=$this->nextId();
|
|
|
61 |
$this->_id_statut=$d;
|
|
|
62 |
$champs =array (
|
|
|
63 |
GEST_CHAMPS_ID_STATUT => $this->_id_statut,
|
|
|
64 |
GEST_CHAMPS_LIBELLE_STATUT=> "$this->_libelle_statut");
|
|
|
65 |
|
|
|
66 |
$resultat = $GLOBALS['db']->autoExecute($table, $champs,DB_AUTOQUERY_INSERT);
|
|
|
67 |
|
|
|
68 |
if (DB::isError($resultat)) {
|
|
|
69 |
die($resultat->getMessage());
|
|
|
70 |
}
|
|
|
71 |
}
|
|
|
72 |
|
|
|
73 |
/**
|
|
|
74 |
*recupere l'identifiant de la base de donnees
|
|
|
75 |
*/
|
|
|
76 |
|
|
|
77 |
function nextId()
|
|
|
78 |
{
|
|
|
79 |
$requete = 'SELECT MAX('.GEST_CHAMPS_ID_STATUT.') AS maxi FROM '.GEST_STATUT;
|
|
|
80 |
$resultat = $GLOBALS['db']->query($requete);
|
|
|
81 |
if (DB::isError($resultat) || $resultat->numRows() > 1) {
|
|
|
82 |
return false;
|
|
|
83 |
}
|
|
|
84 |
|
|
|
85 |
$ligne = $resultat->fetchRow(DB_FETCHMODE_OBJECT);
|
|
|
86 |
return $ligne->maxi + 1;
|
|
|
87 |
}
|
|
|
88 |
|
|
|
89 |
|
|
|
90 |
|
|
|
91 |
|
|
|
92 |
/*
|
|
|
93 |
*retourne un tableau contenant tous les statuts et leurs identifiants
|
|
|
94 |
*/
|
|
|
95 |
|
|
|
96 |
function recupererTableauStatut( )
|
|
|
97 |
{
|
|
|
98 |
$tableau= array();
|
|
|
99 |
$i=0;
|
|
|
100 |
$requete="SELECT ".GEST_CHAMPS_ID_STATUT." , ".GEST_CHAMPS_LIBELLE_STATUT.
|
|
|
101 |
" FROM ".GEST_STATUT."";
|
|
|
102 |
$resultat = $GLOBALS['db']->query($requete);
|
|
|
103 |
|
|
|
104 |
(DB::isError($resultat)) ?
|
|
|
105 |
die (BOG_afficherErreurSql(__FILE__, __LINE__, $resultat->getMessage(), $requete)) : '' ;
|
|
|
106 |
|
|
|
107 |
while ($ligne= $resultat->fetchRow(DB_FETCHMODE_ASSOC))
|
|
|
108 |
{
|
|
|
109 |
$case = array(GEST_CHAMPS_ID_STATUT => $ligne[GEST_CHAMPS_ID_STATUT],
|
|
|
110 |
GEST_CHAMPS_LIBELLE_STATUT =>$ligne[GEST_CHAMPS_LIBELLE_STATUT]);
|
|
|
111 |
$tableau[$i]=$case;
|
|
|
112 |
$i=$i+1;
|
|
|
113 |
}
|
|
|
114 |
|
|
|
115 |
return $tableau;
|
|
|
116 |
|
|
|
117 |
}
|
|
|
118 |
|
|
|
119 |
/**
|
|
|
120 |
*recuperer tableau libelle
|
|
|
121 |
*/
|
|
|
122 |
function recupererTableauLibelleStatut()
|
|
|
123 |
{
|
|
|
124 |
$tableau= array();
|
|
|
125 |
$requete="SELECT ".GEST_CHAMPS_LIBELLE_STATUT.
|
|
|
126 |
" FROM ".GEST_STATUT."";
|
|
|
127 |
|
|
|
128 |
$resultat = $GLOBALS['db']->query($requete);
|
|
|
129 |
|
|
|
130 |
(DB::isError($resultat)) ?
|
|
|
131 |
die (BOG_afficherErreurSql(__FILE__, __LINE__, $resultat->getMessage(), $requete)) : '' ;
|
|
|
132 |
|
|
|
133 |
while ($ligne= $resultat->fetchRow(DB_FETCHMODE_ASSOC))
|
|
|
134 |
{
|
|
|
135 |
array_push($tableau,$ligne[GEST_CHAMPS_LIBELLE_STATUT]);
|
|
|
136 |
}
|
|
|
137 |
return $tableau;
|
|
|
138 |
}
|
|
|
139 |
|
|
|
140 |
/*supprime une categorie
|
|
|
141 |
*renvoie 1 si suppression effectuee
|
|
|
142 |
*0 si rien
|
|
|
143 |
*-1 si erreur
|
|
|
144 |
*/
|
|
|
145 |
function supprimerStatut($id)
|
|
|
146 |
{
|
|
|
147 |
$requete= "DELETE FROM ".GEST_STATUT.
|
|
|
148 |
" WHERE ".GEST_CHAMPS_ID_STATUT." =$id ";
|
|
|
149 |
|
|
|
150 |
$resultat = $GLOBALS['db'] ->query($requete);
|
|
|
151 |
|
|
|
152 |
(DB::isError($resultat)) ?
|
|
|
153 |
die (BOG_afficherErreurSql(__FILE__, __LINE__, $resultat->getMessage(), $requete)) : '' ;
|
|
|
154 |
|
|
|
155 |
$int=$GLOBALS['db']->affectedRows();
|
|
|
156 |
|
|
|
157 |
if($int==1)
|
|
|
158 |
{
|
|
|
159 |
return 1;
|
|
|
160 |
}elseif($int==0){
|
|
|
161 |
return 0;
|
|
|
162 |
}else return -1;
|
|
|
163 |
|
|
|
164 |
}
|
|
|
165 |
/**
|
|
|
166 |
*fonction verifiant si le statut est utilise
|
|
|
167 |
*renvoie 1 si statut utilise
|
|
|
168 |
*-1 sinon
|
|
|
169 |
*/
|
|
|
170 |
function statutUtilise($id)
|
|
|
171 |
{
|
|
|
172 |
$requete="SELECT ".GEST_CHAMPS_ID_UTILISATEUR.
|
|
|
173 |
" FROM ".GEST_UTILISATEUR.
|
|
|
174 |
" WHERE ". GEST_CHAMPS_ID_STATUT."=$id";
|
|
|
175 |
$ligne= $GLOBALS['db']->query($requete);
|
|
|
176 |
|
|
|
177 |
(DB::isError($ligne)) ?
|
|
|
178 |
die (BOG_afficherErreurSql(__FILE__, __LINE__, $ligne->getMessage(), $requete)) : '' ;
|
|
|
179 |
|
|
|
180 |
$j= $ligne->numRows();
|
|
|
181 |
if ($j==0){
|
|
|
182 |
return -1;
|
|
|
183 |
}else {
|
|
|
184 |
return 1;
|
|
|
185 |
}
|
|
|
186 |
}
|
|
|
187 |
|
|
|
188 |
function afficherStatut()
|
|
|
189 |
{
|
|
|
190 |
echo "Statut : \n";
|
|
|
191 |
echo "id : ";
|
|
|
192 |
echo "$this->_id_statut <BR>";
|
|
|
193 |
echo "libelle_statut : ";
|
|
|
194 |
echo "$this->_libelle_statut <BR>";
|
|
|
195 |
}
|
|
|
196 |
|
|
|
197 |
|
|
|
198 |
}
|
|
|
199 |
?>
|