Subversion Repositories Applications.gtt

Rev

Rev 5 | Go to most recent revision | Details | Compare with Previous | 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
include_once CHEMIN_CLASSES_METIER.'gtt_travail.class.php';
7 jpm 37
include_once CHEMIN_CLASSES_METIER.'gtt_motif.class.php';
2 jpm 38
include_once CHEMIN_CLASSES_METIER.'gtt_projet.class.php';
39
include_once CHEMIN_CLASSES_METIER.'gtt_absence.class.php';
40
include_once CHEMIN_CALENDRIER.'gtt_calendrier.class.php';
41
 
7 jpm 42
 
2 jpm 43
/**
44
*fonction affichant le tableau des jours
45
*et le menu travail
46
*@param : $utilisateur : identifiant de l'utilisateur
47
*@param : semaine : numero de semaine
48
*/
49
function afficherTableauJour($url,$utilisateur,$semaine,$annee)
50
{
51
     $id10="TABLEAU_JOUR_TRAVAIL";
52
     $assoc10=array('class'=>$id10);
53
     $form=new HTML_QuickForm('tableau_travail','post',$GLOBALS['urlBase'].GESTION_TRAVAIL,'',$assoc10);
54
 
55
      //templates
56
     $squelette =& $form->defaultRenderer();
57
     $squelette->setGroupElementTemplate('<td>{label}{element}</td>','groupe');
58
    //construction d'une preference
59
     $pref=new Preference($utilisateur,0);
60
    //recuperation du tableau de preferences regroupes par categorie
61
     $tabPref=$pref->recupererTableauPreferences();
62
 
63
   //creation des Messages d'erreur
64
    $form->setRequiredNote('='.GTT_CHAMPS_OBLIGATOIRE);
65
    $form->setJsWarnings(GTT_DONNEES_INCORRECTES, GTT_DONNEES_A_CORRIGER);
66
    //affichage du nom, conges et heure supp de la personn
67
    $user=&Utilisateur::recupererUtilisateur($utilisateur);
5 jpm 68
    if(is_object($user)) {
2 jpm 69
	$z=$form->addElement('html','<tr><td>'.GTT_L_TR_BIENVENUE."\t".$user->getPrenom()."\t".
70
	                                      $user->getNom().'</td></tr>');
71
	$z=$form->addElement('html','<tr><td>'.'</td></tr>');
72
	if($user->getConges()==1 or $user->getConges()==0 or $user->getConges()==-1)
73
	{
74
	    $jour=GESTION_RTTJOUR_L;
75
	}else $jour =GESTION_RTTJOURS_L;
76
	$z=$form->addElement('html','<tr><td>'.GTT_L_TR_JOURS_CONGES." : ".$user->getConges().$jour.'</td></tr>');
77
	$z=$form->addElement('html','<tr><td>'.'</td></tr>');
78
 
79
	$quota=$user->getQuota();
80
 
81
	$jour1=intval($quota / 24);
82
	$heure= ($quota %24);
83
 
84
	if($heure==0 or $heure==1 or $heure==-1)
85
	    {
86
		$h=GTT_L_TR_HEURE_L;
87
	    }else $h=GTT_L_TR_HEURES_L;
88
 
89
	    if($jour1==0 or $jour1==1 or $jour1==-1)
90
	    {
91
		$jour2=GESTION_RTTJOUR_L;
92
	    }else $jour2=GESTION_RTTJOURS_L;
93
 
94
	    $temps =$jour1.'&nbsp'.$jour2.'&nbsp'.$heure.'&nbsp'.$h;
95
 
96
	$z=$form->addElement('html','<tr><td>'.GTT_L_TR_JOURS_RECUPERATION." : ".'</td></tr>');
97
	$z=$form->addElement('html','<tr><td>'."  ".$jour1.$jour2."\t".$heure.$h.'</td></tr>');
98
	$z=$form->addElement('html','<tr><td>'.'</td></tr>');
99
 
100
    }
101
 
102
    //insertion du calendrier
103
    $calendrier=new Calendrier($url,$semaine,$annee);
104
    //affichage de la ligne mois
105
    $z=$form->addElement('html','<tr><td>'.GTT_L_TR_MOIS." : ".
106
                                $calendrier->nom_mois[$calendrier->mois]."\t".$calendrier->annee.'</td></tr>');
107
 
108
    $aff=$calendrier->afficherCalendrier($annee);
109
    $form->addElement('html','<tr><td>'.$aff.'</td></tr>');
110
    $z=$form->addElement('html','<tr><td>'.'</td></tr>');
111
    //memoriser le nombre de projets inclus dans les preferences
112
    $form->addElement('hidden','champ_nb_projet',count($tabPref));
113
    //creation du tableau
114
   $cat='';
115
   $ok=0;
116
   $form->addElement('html','<tr><td>'.GESTION_PROJETS_L.'</td><td></td><td>'.GESTION_LUN_L.'</td><td>'.
117
   GESTION_MAR_L.'</td><td>'.GESTION_MER_L.'</td><td>'.GESTION_JEU_L.
118
   '</td><td>'.GESTION_VEN_L.'</td><td>'.GESTION_SAM_L.'</td><td>'.GESTION_DIM_L.
119
   '</td><td>'.GESTION_TACHES_L.'</td></tr>');
120
 
121
   for ($i=0; $i<count($tabPref) ;$i++)
122
   {
123
     //ligne categorie si categorie pas deja inseree
124
    $tabLigne=$tabPref[$i];
125
    if ($cat!=$tabLigne['libelle_cat'])
126
    {
127
    $size1=25;
128
    $id1="nom_categorie";
129
    $assoc1=array('class' =>$id1, 'size'=>$size1);
130
    $ligneNomCat=&HTML_QuickForm::createElement('html', '<tr><td>'.$tabLigne['libelle_cat'].' : '.'</td></tr>');
131
    $form->addElement($ligneNomCat);
132
    $cat =$tabLigne['libelle_cat'];
133
    }
134
    //creation de l'element hidden pour memoriser l'identifiant du projet
135
    $ligneIdProjet=&HTML_QuickForm::createElement('hidden', 'champ_id_projet'.$i,$tabLigne['id_proj']);
136
    $form->addElement($ligneIdProjet);
137
 
138
    //nom des jours
139
    $id2="nom_jours";
140
    $size2=5;
141
    $assoc2=array('class' =>$id2, 'size'=>$size2);
142
    $ligne2[0]=&HTML_QuickForm::createElement('text','champ_lundi'.$i,'',$assoc2);
143
    $ligne2[1]=&HTML_QuickForm::createElement('text','champ_mardi'.$i,'',$assoc2);
144
    $ligne2[2]=&HTML_QuickForm::createElement('text','champ_mercredi'.$i,'',$assoc2);
145
    $ligne2[3]=&HTML_QuickForm::createElement('text','champ_jeudi'.$i,'',$assoc2);
146
    $ligne2[4]=&HTML_QuickForm::createElement('text','champ_vendredi'.$i,'',$assoc2);
147
    $ligne2[5]=&HTML_QuickForm::createElement('text','champ_samedi'.$i,'',$assoc2);
148
    $ligne2[6]=&HTML_QuickForm::createElement('text','champ_dimanche'.$i,'',$assoc2);
149
 
150
    //creation des taches
151
    $id3="nom_taches";
152
    $assoc3=array('class' =>$id3);
153
    $ligne2[7]=&HTML_QuickForm::createElement('select','champ_tache'.$i,'','',$assoc3);
154
    //verification si le projet contient une tache
155
    $verification=&Projet::contientTache($tabLigne['id_proj']);
156
    //enregistrement de la tache par defaut
157
    if ($verification!=1)
158
    {
159
	$tache=new Tache(0);
160
	$tache->construireDefaultTache($tabLigne['id_proj'],GESTION_NOM_TACHE_DEFAUT_L);
161
	$tache->enregistrerNewDefaultTache();
162
    }
163
    $ligne2[7]->load($result) ;
164
    $c="SELECT * FROM ".GEST_TACHES." WHERE ".GEST_CHAMPS_ID_PROJET." = $tabLigne[id_proj]";
165
    $ligne2[7]->loadQuery($GLOBALS['dsn'],$c,GEST_CHAMPS_NOM_TACHE,GEST_CHAMPS_ID_TACHE);
166
    //recuperation de l'identifiant de la tache par defaut
167
    $idDefTache=&Tache::recupererIdentifiantDefaultTache();
168
    $ligne2[7]->setSelected(GESTION_NOM_TACHE_DEFAUT_L,$idDefTache);
169
 
170
    $form->addGroup($ligne2,'groupe',$tabLigne['nom_proj'].'  : ','&nbsp',false);
171
 
172
    //filtres
173
    $form->applyFilter('champ_lundi'.$i,'trim');
174
    $form->applyFilter('champ_mardi'.$i,'trim');
175
    $form->applyFilter('champ_mercredi'.$i,'trim');
176
    $form->applyFilter('champ_jeudi'.$i,'trim');
177
    $form->applyFilter('champ_vendredi'.$i,'trim');
178
    $form->applyFilter('champ_samedi'.$i,'trim');
179
    $form->applyFilter('champ_dimanche'.$i,'trim');
180
 
181
    //creation de regles
182
    $regle['champ_lundi'.$i][]=array(GTT_ERREUR_NOMBRE,'numeric','','client');
183
    $regle['champ_mardi'.$i][]=array(GTT_ERREUR_NOMBRE,'numeric','','client');
184
    $regle['champ_mercredi'.$i][]=array(GTT_ERREUR_NOMBRE,'numeric','','client');
185
    $regle['champ_jeudi'.$i][]=array(GTT_ERREUR_NOMBRE,'numeric','','client');
186
    $regle['champ_vendredi'.$i][]=array(GTT_ERREUR_NOMBRE,'numeric','','client');
187
    $regle['champ_samedi'.$i][]=array(GTT_ERREUR_NOMBRE,'numeric','','client');
188
    $regle['champ_dimanche'.$i][]=array(GTT_ERREUR_NOMBRE,'numeric','','client');
189
    $form->addGroupRule('groupe', $regle);
190
   }
191
   //enregistrement de regles
192
    $form->registerRule('verifTempsTravail','function','verifTempsTravail');
193
    $regle2['champ_tache0'][]=array(GESTION_ERREUR_L,'verifTempsTravail','','client');
194
    $form->addGroupRule('groupe', $regle2);
195
 
196
   //ligne type de jour
197
   $id4="type_jour";
198
   $size4=3;
199
   $assoc4=array('classe'=>$id4,'cols'=>10);
200
   $tabMotif=&Motif::recupererTableauMotif();
201
   $tabTypeJour1=array();
202
   for ($h=0;$h<count($tabMotif);$h++)
203
   {
204
       array_push($tabTypeJour1,trim($tabMotif[$h][GEST_CHAMPS_LIBELLE_MOTIF]));
205
       //champ cache pour recuperer le type de jour si des modifications
206
       //sont faites eventuellement dans la base de donnees
207
       //et le rang des motifs d'absence se b=voit altéré
208
      $y=& $form->addElement('hidden',"champ_libelle_type_jour".$h,trim($tabMotif[$h][GEST_CHAMPS_LIBELLE_MOTIF]) );
209
      $z=& $form->addElement('hidden',"champ_rtt_type_jour".$h,($tabMotif[$h][GEST_CHAMPS_TYPE_RTT]) );
210
   }
211
 
212
    $y=& $form->addElement('hidden',"champ_libelle_type_jour".count($tabMotif),GTT_NOM_TRAVAIL);
213
    $z=& $form->addElement('hidden',"champ_rtt_type_jour".count($tabMotif),1);
214
    array_push($tabTypeJour1,GTT_NOM_TRAVAIL);
215
    $z=& $form->addElement('hidden',"champ_rtt_type_jour".(count($tabMotif)+1),1);
216
    $y=& $form->addElement('hidden',"champ_libelle_type_jour".(count($tabMotif)+1),GTT_NOM_WEEK_END);
217
 
218
    //CHAMP POUR AVOIR LE NOMBRE DE TYPE DE JOUR
219
    $y=& $form->addElement('hidden',"champ_nb_type_jour",(count($tabMotif)+1+1));
220
 
221
 
222
   //determination des indices des valeurs dans la table
223
   $ferie=array_search('Ferié',$tabTypeJour1);
224
   $trav=array_search('travail',$tabTypeJour1);
225
 
226
   //calcul de la date du premier jour de la semaine choisie
227
   $tabJour=$calendrier->lundiEtDimancheSemaine($calendrier->semaine,$calendrier->annee);
228
   $d=date('d',mktime(0,0,0,1,$tabJour[0],$calendrier->annee));
229
   $m=date('m',mktime(0,0,0,1,$tabJour[0],$calendrier->annee));
230
   $Y=date('Y',mktime(0,0,0,1,$tabJour[0],$calendrier->annee));
231
 
232
    //recuperation de la liste des absences de l'utilisateur
233
    $listeAbsence=&Absence::recupAbsence( $GLOBALS['idCurrentUser'],date('Y-m-d',mktime(0,0,0,1,$tabJour[0],$calendrier->annee)),
234
                                          date('Y-m-d',mktime(0,0,0,1,$tabJour[1],$calendrier->annee)));
235
 
236
    //creation du tableau pour les week ends
237
    $tabTypeJour2=array(array_search(GTT_NOM_TRAVAIL,$tabTypeJour1) => GTT_NOM_TRAVAIL,
238
                  (array_search(GTT_NOM_TRAVAIL,$tabTypeJour1)+1) =>GTT_NOM_WEEK_END);
239
 
240
   //parcours de la liste de jours
241
   for ($g=0;$g<7;$g++)
242
   {
243
     //creation des dates de la semaine
244
    $date=mktime(0,0,0,$m,$d+(1*$g),$Y);
245
    //ajout d'un element cache pour recuperer les dates
246
    $form->addElement('hidden','champ_date_j'.$g,$date);
247
 
248
    //proposition de l'option week end que si on est en we
249
    if($g==5 or $g==6)
250
    {
251
	 $tabTypeJour=$tabTypeJour2;
252
 
253
    }else
254
    {
255
	$tabTypeJour=$tabTypeJour1;
256
    }
257
    $ligneType[$g]=&HTML_QuickForm::createElement('select','champ_type_jour'.$g,'',$tabTypeJour,$assoc4);
258
 
259
    //determination du type de jour
260
     //weekend
261
    if (($g==5)or ($g==6))
262
    {
263
	$ligneType[$g]->setSelected(array_search(GTT_NOM_WEEK_END,$tabTypeJour));
264
    }
265
    //jours feries
266
    elseif (in_array($date,$calendrier->liste_feries)==1 and ($g!=5 and $g!=6))
267
    {
268
	$ligneType[$g]->setSelected(array_search(GTT_NOM_FERIE,$tabTypeJour));
269
    }else
270
    {
271
	$ligneType[$g]->setSelected(array_search(GTT_NOM_TRAVAIL,$tabTypeJour));
272
    }
273
 
274
    //parcours de liste des absences
275
    if(count($listeAbsence)!=0)
276
    {
277
      for($t=0;$t<count($listeAbsence);$t++)
278
    {
279
	$h=$listeAbsence[$t];
280
	$debAbs=explode('-',$h[GEST_CHAMPS_DATE_DEBUT_ABSENCE]);
281
 
282
	$dateDebAbs=mktime(0,0,0,$debAbs[1],$debAbs[2],$debAbs[0]);
283
	//date fin absence
284
	if($h[GEST_CHAMPS_DATE_FIN_ABSENCE]!='0000-00-00')
285
	{
286
	$finAbs=explode('-',$h[GEST_CHAMPS_DATE_FIN_ABSENCE]);
287
	$dateFinAbs=mktime(0,0,0,$finAbs[1],$finAbs[2],$finAbs[0]);
288
 
289
	if (($dateDebAbs<=$date)and ($date<=$dateFinAbs))
290
	{
291
	    $ligneType[$g]->setSelected($h[GEST_CHAMPS_ID_MOTIF]);
292
	}
293
	}else{
294
	    //cas ou la date de fin n'est pas rentre
295
	    if($dateDebAbs==$date)
296
	    {
297
		 $ligneType[$g]->setSelected($h[GEST_CHAMPS_ID_MOTIF]);
298
	    }
299
	}
300
    }
301
    }
302
   }
303
   $form->addGroup($ligneType,'groupe','Type de Jour  : ','&nbsp',false);
304
 
305
 
306
 
307
   //ligne bouton validation
308
   $size4=5;
309
   $id4='bouton_valider_travail';
310
   $assoc4=array('class' =>$id4, 'size'=>$size4);
311
   $boutonSubmit= &HTML_QuickForm::createElement('submit', 'champ_valider_travail',GTT_L_G_VALIDER,$assoc4);
312
   $form->addElement($boutonSubmit);
313
   $form->addElement('html',afficherOptionAplication($utilisateur));
314
   return $form;
315
}
316
 
317
?>