Subversion Repositories Applications.gtt

Rev

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