Subversion Repositories Applications.gtt

Rev

Rev 2 | Go to most recent revision | Only display areas with differences | Ignore whitespace | Details | Blame | Last modification | View Log | RSS feed

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