Subversion Repositories Applications.gtt

Rev

Details | Last modification | View Log | RSS feed

Rev Author Line No. Line
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
// |@author ABDOOL RAHEEM shaheen   shaheenar50@hotmail.com                                                 |
23
// |@version 3                                                                                            |
24
/*@package gtt_general
25
//Auteur original :
26
*@author        Dorian Bannier <dbannier@aol.com>
27
//Autres auteurs :
28
*@author        Jean-Pascal MILCENT <jpm@tela-botanica.org>
29
*@copyright     Copyright (C) 2003 Tela-Botanica
30
@version        $Date: 2004/07/06
31
*/
32
// +------------------------------------------------------------------------------------------------------+
33
// +------------------------------------------------------------------------------------------------------+
34
// |                                            INCLUSION DE FICHIERS                                       |
35
// +------------------------------------------------------------------------------------------------------+
36
 
37
include_once CHEMIN_CLASSES_METIER.'gtt_statut.class.php';
38
include_once CHEMIN_CONTROLEUR.'gtt_controleur_admin_utilisateur.php';
39
 
40
//inclusion des paquets de la librairie pear
41
include_once 'HTML/QuickForm.php';
42
 
43
 
44
/**
45
*focntion affichant le menu aministration utilisateur
46
*@$tabDef =tableau contenant les parametres par defaut
47
*@$test =test si on est en insertion ou modification
48
*@ $mode = 1 =>modification
49
*@ $mode =0 =>insertion
50
*/
51
 
52
 
53
function afficherMenuAjouterUser($tabDef,$mode)
54
{
55
   $id="MANIPULER_USER";
56
   $size=30;
57
 
58
 
59
   $assoc1 =array('class'=>$id);
60
 
61
   $form=new HTML_QuickForm('gestion_utilisateur', 'post',$GLOBALS['urlBase'].GESTION_ADMIN_UTILISATEUR,'', $assoc1);
62
 
63
    //creation des templates pour la mise en forme
64
   $squelette =& $form->defaultRenderer();
65
   $squelette->setFormTemplate("\n<form{attributes}>\n<ul>{content}\n</ul></form>");
66
   $squelette->setElementTemplate('<li>'."\n".'{label}'."\n".'{element}'."\n".
67
                                    '<!-- BEGIN required --><span class="symbole_obligatoire">*</span><!-- END required -->'."\n".
68
                                    '<!-- BEGIN error --><span class="erreur">{error}</span><!-- END error -->'."\n".
69
                                    '</li>'."\n");
70
  $squelette->setGroupElementTemplate('{label}{element}','groupe');
71
  $squelette->setRequiredNoteTemplate("\n".'<li>'.'<p>'."\n".'<span class="symbole_obligatoire">*</span> {requiredNote}'."\n".'</p>'.'</li>'."\n");
72
  $squelette->setHeaderTemplate("\n".'<li><h2>'."\n".'{header}'."\n".'</h2></li>'."\n");
73
 
74
    //entete du formulaire
75
 
76
    $form->addElement('header', 'entete', GESTION_AJOUTER_UTILISATEUR_L);
77
 
78
    //creation des Messages d'erreur
79
 
80
    $form->setRequiredNote('='.GTT_CHAMPS_OBLIGATOIRE);
81
    $form->setJsWarnings(GTT_DONNEES_INCORRECTES, GTT_DONNEES_A_CORRIGER);
82
 
83
 
84
    //creation et ajouts des elements
85
 
86
 
87
    //element cache pour verifier si formulaire est en mode insertion ou modification
88
 
89
    $form->addElement('hidden', 'champ_verif', $mode);
90
 
91
    //definition du champ d'activation
92
 
93
 
94
    //premier ligne: nom
95
    $size=20;
96
    $assoc=array('class' =>$id, 'size'=>$size);
97
 
98
    //desactivation des champs si mode modification
99
    if ($mode==1)
100
    {
101
	$temp_assoc=array('disabled');
102
	$assoc=array_merge($assoc,$temp_assoc);
103
 
104
    }
105
    $ligneNom = &HTML_QuickForm::createElement('text', 'champ_nom',GESTION_NOM_L.': ',$assoc);
106
    $form->addElement($ligneNom);
107
 
108
    //ligne : prenom
109
    $assoc=array('class' =>$id, 'size'=>$size);
110
    //desactivation des champs si mode modification
111
    if ($mode==1)
112
    {
113
	$temp_assoc=array('disabled');
114
	$assoc=array_merge($assoc,$temp_assoc);
115
 
116
    }
117
   $lignePrenom = &HTML_QuickForm::createElement('text', 'champ_prenom',GESTION_PRENOM_L.': ',$assoc);
118
   $form->addElement($lignePrenom);
119
 
120
    // ligne : adresse
121
    $assoc=array('class' =>$id, 'size'=>$size);
122
    $ligneAdresse= &HTML_QuickForm::createElement('text', 'champ_adresse',GTT_L_FU_ADRESSE.': ',$assoc);
123
    $form->addElement($ligneAdresse);
124
 
125
     //ligne :ville
126
    $assoc=array('class' =>$id, 'size'=>$size);
127
    $ligneVille = &HTML_QuickForm::createElement('text', 'champ_ville',GTT_L_FU_VILLE.': ',$assoc);
128
    $form->addElement($ligneVille);
129
 
130
    // ligne : code postal
131
    $size=5;
132
    $assoc=array('class' =>$id, 'size'=>$size);
133
    $ligneCode = &HTML_QuickForm::createElement('text', 'champ_code_postal',GTT_L_FU_CODE_POSTAL.': ',$assoc);
134
    $form->addElement($ligneCode);
135
 
136
    // ligne :telephone
137
 
138
    $size=10;
139
    $assoc=array('class' =>$id, 'size'=>$size);
140
    $ligneTel=&HTML_QuickForm::createElement('text', 'champ_telephone',GTT_L_FU_TEL.': ',$assoc);
141
    $form->addElement($ligneTel);
142
 
143
     // ligne :email
144
    $size=25;
145
    $assoc=array('class' =>$id, 'size'=>$size);
146
    $ligneMail=&HTML_QuickForm::createElement('text', 'champ_email',GTT_L_FU_EMAIL.': ',$assoc);
147
    $form->addElement($ligneMail);
148
 
149
   // ligne : explication
150
   $cl="EXPLICATION";
151
   $assoc=array('class' =>$cl, 'size'=>$size);
152
 
153
   if ($mode==1)
154
   {
155
   $ligneExplication=&HTML_QuickForm::createElement('HTML',GTT_L_FU_MAJ_MDP);
156
   $form->addElement($ligneExplication);
157
 
158
   }
159
   // ligne : mot de passe
160
    $size=20;
161
   $assoc=array('class' =>$id, 'size'=>$size);
162
   $ligneMDP=&HTML_QuickForm::createElement('password', 'champ_password',GTT_L_FU_MDP.': ', $assoc);
163
   $form->addElement($ligneMDP);
164
 
165
    //ligne : confirmer mot de passe
166
 
167
   $assoc=array('class' =>$id, 'size'=>$size);
168
   $ligneConfirmMDP=&HTML_QuickForm::createElement('password', 'champ_confirm_password',GTT_L_FU_CONFIRMATION_MDP.': ',$assoc);
169
   $form->addElement( $ligneConfirmMDP);
170
 
171
 
172
     //recuperation de la liste de statut
173
 
174
    $assoc=array('class' =>$id);
175
    $ligneStatut = &HTML_QuickForm::createElement('select', 'champ_statut',GESTION_STATUT_L.': ','',$assoc);
176
 
177
    $ligneStatut->load($result) ;
178
    $c="SELECT * FROM ".GEST_STATUT."";
179
    $ligneStatut->loadQuery($GLOBALS['dsn'],$c,GEST_CHAMPS_LIBELLE_STATUT,GEST_CHAMPS_ID_STATUT);
180
    $form->addElement($ligneStatut);
181
 
182
 
183
    //conges payes initiaux
184
    $size=3;
185
    $assoc=array('class' =>$id, 'size'=>$size);
186
     //desactivation des champs si mode modification
187
    if ($mode==1)
188
    {
189
	$temp_assoc=array('disabled');
190
	$assoc=array_merge($assoc,$temp_assoc);
191
 
192
    }
193
    $ligneConges = &HTML_QuickForm::createElement('text', 'champ_nb_conge',GESTION_CONGES_INIT_L.': ',$assoc);
194
    $form->addElement($ligneConges);
195
 
196
    //temps journalier de travail
197
    $size=3;
198
    $assoc=array('class' =>$id, 'size'=>$size);
199
    $ligneTT = &HTML_QuickForm::createElement('text', 'champ_temps_travail',GTT_L_FU_TEMPS_TRAVAIL.': ',$assoc);
200
    $form->addElement($ligneTT);
201
 
202
    //heures supp
203
     //desactivation des champs si mode modification
204
     $size=3;
205
    $assoc=array('class' =>$id, 'size'=>$size);
206
    if ($mode==1)
207
    {
208
	$temp_assoc=array('disabled');
209
	$assoc=array_merge($assoc,$temp_assoc);
210
 
211
    }
212
    $ligneHeuresSup = &HTML_QuickForm::createElement('text', 'champ_heure_supp_init',GESTION_HEURESINIT_L.': ',$assoc);
213
    $form->addElement($ligneHeuresSup);
214
 
215
    //administrateur
216
    $size=1;
217
    $assoc=array('class' =>$id,'size'=>$size);
218
    $ligneAdmin = &HTML_QuickForm::createElement('checkbox', 'champ_administrateur',GTT_L_FU_ADMIN.': ','',$assoc);
219
    if ($mode==1 and $tabDef['champ_administrateur']==true)
220
    {
221
	$ligneAdmin->setChecked(true);
222
    }else{
223
    $ligneAdmin->setChecked(false);
224
    }
225
    $form->addElement($ligneAdmin);
226
 
227
 
228
 
229
    //ligne : admin2
230
    $ligneAdmin2= &HTML_QuickForm::createElement('checkbox', 'champ_admin2',GTT_L_FU_ADMIN_2.': ','',$assoc);
231
 
232
    if ($mode==1 and $tabDef['champ_admin2']==true)
233
    {
234
	$ligneAdmin2->setChecked(true);
235
    }else{
236
    $ligneAdmin2->setChecked(false);
237
    }
238
    $form->addElement($ligneAdmin2);
239
 
240
 
241
    //element ok : valider le formulaire
242
    $bouton=&HTML_QuickForm::createElement('submit', 'champ_valider',GTT_L_G_VALIDER,$assoc);
243
    $form->addElement($bouton);
244
 
245
 
246
    //ajout des regles de saisie
247
    $form->applyFilter('champ_nom', 'trim');
248
    $form->applyFilter('champ_prenom','trim');
249
    $form->applyFilter('champ_email', 'trim');
250
 
251
 
252
    //regles individuelles
253
    //regles applicables si on est en mode insertion
254
 
255
    if($mode==0)
256
    {
257
    $form->addRule('champ_nom',GTT_ERREUR_NOM, 'required','','client');
258
    $form->addRule('champ_nom',GTT_ERREUR_NOM, 'lettersonly','','client');
259
 
260
    $form->addRule('champ_prenom',GTT_ERREUR_PRENOM, 'required','','client');
261
    $form->addRule('champ_prenom',GTT_ERREUR_PRENOM, 'lettersonly','','client');
262
    $form->addRule('champ_password',GTT_ERREUR_PASSWD, 'required','','client');
263
    $form->addRule('champ_confirm_password','', 'required','','client');
264
    $form->addRule('champ_nb_conge',GTT_ERREUR_NOMBRE, 'numeric','','client');
265
    $form->addRule('champ_heure_supp_init',GTT_ERREUR_NOMBRE, 'numeric','','client');
266
   }
267
 
268
    $form->addRule(array('champ_password','champ_confirm_password'),GESTION_ERREUR_PASSWORD_L, 'compare','','client');
269
 
270
 
271
    $form->addRule('champ_temps_travail',GTT_ERREUR_NOMBRE, 'numeric','','client');
272
 
273
    //nouvelles regles
274
    $form->registerRule('verifValeurTemps','function','verifValeurTemps');
275
    $form->addRule('champ_temps_travail',GTT_ERREUR_NOMBRE, 'verifValeurTemps','','client');
276
 
277
    $form->addRule('champ_code_postal',GTT_ERREUR_NOMBRE, 'numeric','','client');
278
    $form->addRule('champ_telephone',GTT_ERREUR_TEL, 'numeric','','client');
279
    $form->addRule('champ_email',GTT_ERREUR_MAIL, 'required','','client');
280
    $form->addRule('champ_email',GTT_ERREUR_MAIL, 'email','','client');
281
 
282
    //creation de valeurs par defaut
283
    $default=array("champ_nom"=> null,
284
                    "champ_prenom"=>null,
285
		    "champ_adresse" =>null,
286
		    "champ_ville" =>null,
287
		    "champ_code_postal" =>0,
288
		    "champ_telephone" => 0,
289
		    "champ_email" =>null,
290
		    "champ_administrateur" =>false,
291
		    "champ_statut"=>0,
292
		    "champ_admin2"=> false,
293
		    "champ_nb_conge"=>0,
294
		    "champ_temps_travail"=>7,
295
		    "champ_heure_supp_init"=>0);
296
 
297
    if ($mode==1)
298
    {
299
	$form->setDefaults($tabDef);
300
	$form->addElement('hidden', 'nom_utilisateur',$tabDef["champ_nom"]);
301
	$form->addElement('hidden', 'prenom_utilisateur',$tabDef["champ_prenom"]);
302
        $form->addElement('hidden', 'conges_utilisateur',$tabDef["champ_nb_conge"]);
303
	$form->addElement('hidden', 'heure_supp_utilisateur',$tabDef["champ_heure_supp_init"]);
304
 
305
    }else {
306
	$form->setDefaults($default);
307
    }
308
 
309
 
310
    //ajout des regles de saisie
311
    $form->applyFilter('champ_nom', 'trim');
312
    $form->applyFilter('champ_prenom','trim');
313
    $form->applyFilter('champ_email', 'trim');
314
    $form->applyFilter('champ_adresse','trim');
315
    return $form;
316
}
317
 
318
/**
319
*fonction creant le formulaire de suppression d'utilisateur
320
*affiche la liste des utilisateurs
321
*la supression se fera en fonction du choix de l'utilisateur
322
*/
323
 
324
function afficherMenuEditerUser()
325
{
326
   $id="EDITER_USER";
327
   $size=30;
328
  $assoc1 =array('class'=>$id);
329
  $form= new HTML_QuickForm('editer_utilisateur', 'post',$GLOBALS['urlBase'].GESTION_EDITER_UTILISATEUR,'',$assoc1);
330
 
331
   $form->addElement('header', 'entete', GESTION_EDITER_UTILISATEUR_L);
332
 
333
   //creation des elements
334
   $id="EDITER_USER";
335
   $assoc=array('class' =>$id);
336
   $ligne[0]=&HTML_QuickForm::createElement('select', 'champ_utilisateur_supprimer',GESTION_UTILISATEUR_L." : ",'',$assoc);
337
   $ligne[0]->load($result) ;
338
   $c="SELECT * FROM ".GEST_UTILISATEUR."";
339
   $ligne[0]->loadQuery($GLOBALS['dsn'],$c,GEST_CHAMPS_NOM,GEST_CHAMPS_ID_UTILISATEUR);
340
  // $ligne[1]=&HTML_QuickForm::createElement('html','<a href ="'.$GLOBALS['urlBase'].GESTION_EDITER_UTILISATEUR.'">');
341
   $ligne[2]=&HTML_QuickForm::createElement('submit', 'btn_modifier',GTT_L_G_MODIFIER, $assoc);
342
  // $ligne[3]=&HTML_QuickForm::createElement('html','</a>');
343
 
344
   //$ligne[4]=&HTML_QuickForm::createElement('html','<a href ="'.$GLOBALS['urlBase'].GESTION_ADMIN_UTILISATEUR.'">');
345
   $ligne[5]=&HTML_QuickForm::createElement('submit', 'btn_supprimer',GTT_L_G_SUPPRIMER,$assoc);
346
  // $ligne[6]=&HTML_QuickForm::createElement('html','</a>');
347
    $form->addElement('hidden','action',GESTION_EDITER_UTILISATEUR);
348
   //ajout
349
   $form->addGroup($ligne,'groupe',"",'&nbsp',false);
350
   //validation des donnees
351
   return $form;
352
}
353
 
354
?>