Subversion Repositories Applications.gtt

Rev

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

Rev 46 Rev 48
1
<?php
1
<?php
2
class GttCtrlActionGestion extends aControlleurAction {
2
class GttCtrlActionGestion extends aControlleurAction {
3
 
3
 
4
	public function __construct(Registre $Registre)
4
	public function __construct(Registre $Registre)
5
    {
5
    {
6
    	$Registre->ajouterEspace('Gestion', 'gestion');
6
    	$Registre->ajouterEspace('Gestion', 'gestion');
7
    	$Registre->ajouterSquelette('gestion', 'gestion.tpl.html');
7
    	$Registre->ajouterSquelette('gestion', 'gestion.tpl.html');
8
    }
8
    }
9
 
9
 
10
    public function executer()
10
    public function executer()
11
    {
11
    {
12
    	$aso_gestion = array();
12
    	$aso_gestion = array();
13
    	$this->getRegistre()->setTitre('Gérer son temps');
13
    	$this->getRegistre()->setTitre('Gérer son temps');
14
 
14
 
15
    	//+-------------------------------------------------------------------------------------------------+
15
    	//+-------------------------------------------------------------------------------------------------+
16
		// GESTION DES CALENDRIERS
16
		// GESTION DES CALENDRIERS
17
		//+-------------------------------------------------------------------------------------------------+
17
		//+-------------------------------------------------------------------------------------------------+
18
		// Initialisation des variables pour le calendrier
18
		// Initialisation des variables pour le calendrier
19
		if (!isset($_GET['annee'])) {
19
		if (!isset($_GET['annee'])) {
20
			$_GET['annee'] = date('Y');
20
			$_GET['annee'] = date('Y');
21
		}
21
		}
22
		if (!isset($_GET['mois'])) {
22
		if (!isset($_GET['mois'])) {
23
			$_GET['mois'] = date('m');
23
			$_GET['mois'] = date('m');
24
		}
24
		}
25
		if (!isset($_GET['semaine'])) {
25
		if (!isset($_GET['semaine'])) {
26
			$_GET['semaine'] = date('W');
26
			$_GET['semaine'] = date('W');
27
		}
27
		}
28
		if (!isset($_GET['jour'])) {
28
		if (!isset($_GET['jour'])) {
29
			$_GET['jour'] = date('d');
29
			$_GET['jour'] = date('d');
30
		}
30
		}
31
		// Instanciation de la classe Calendrier France
31
		// Instanciation de la classe Calendrier France
32
		$Calendrier = new Calendrier($_GET['jour'], $_GET['semaine'], $_GET['mois'], $_GET['annee']);
32
		$Calendrier = new Calendrier($_GET['jour'], $_GET['semaine'], $_GET['mois'], $_GET['annee']);
33
		$tab_jours_feries = $Calendrier->getListeFeries();
33
		$tab_jours_feries = $Calendrier->getListeFeries();
34
 
34
 
35
		// Create an array of days which are "selected"
35
		// Create an array of days which are "selected"
36
		// Used for Week::build() below
36
		// Used for Week::build() below
37
		$CalendrierJourCourrant = new Calendar_Week(date('Y'), date('m'), date('d'));
37
		$CalendrierJourCourrant = new Calendar_Week(date('Y'), date('m'), date('d'));
38
		$aso_gestion['jc']['jour'] = $CalendrierJourCourrant->thisDay();
38
		$aso_gestion['jc']['jour'] = $CalendrierJourCourrant->thisDay();
39
		$aso_gestion['jc']['semaine'] = $CalendrierJourCourrant->thisWeek('n_in_year');
39
		$aso_gestion['jc']['semaine'] = $CalendrierJourCourrant->thisWeek('n_in_year');
40
		$aso_gestion['jc']['mois'] = $CalendrierJourCourrant->thisMonth();
40
		$aso_gestion['jc']['mois'] = $CalendrierJourCourrant->thisMonth();
41
		$aso_gestion['jc']['mois_nom'] = $Calendrier->getNomMois($CalendrierJourCourrant->thisMonth());
41
		$aso_gestion['jc']['mois_nom'] = $Calendrier->getNomMois($CalendrierJourCourrant->thisMonth());
42
		$aso_gestion['jc']['annee'] = $CalendrierJourCourrant->thisYear();
42
		$aso_gestion['jc']['annee'] = $CalendrierJourCourrant->thisYear();
43
		$aso_gestion['jc_url'] = 'index.php?action='.GTT_ACTION_GESTION.'&amp;annee='.$aso_gestion['jc']['annee'].'&amp;mois='.$aso_gestion['jc']['mois'].'&amp;semaine='.$aso_gestion['jc']['semaine'].'&amp;jour='.$aso_gestion['jc']['jour'];
43
		$aso_gestion['jc_url'] = 'index.php?action='.GTT_ACTION_GESTION.'&amp;annee='.$aso_gestion['jc']['annee'].'&amp;mois='.$aso_gestion['jc']['mois'].'&amp;semaine='.$aso_gestion['jc']['semaine'].'&amp;jour='.$aso_gestion['jc']['jour'];
44
 
44
 
45
		$CalendrierJourCourrant->build();
45
		$CalendrierJourCourrant->build();
46
		$CalendrierSemaineCourrante = $CalendrierJourCourrant->thisWeek('object');
46
		$CalendrierSemaineCourrante = $CalendrierJourCourrant->thisWeek('object');
47
		$CalendrierSemaineCourrante->build();
47
		$CalendrierSemaineCourrante->build();
48
		$tab_jours = $CalendrierSemaineCourrante->fetchAll();
48
		$tab_jours = $CalendrierSemaineCourrante->fetchAll();
49
		$aso_gestion['sjc_1']['jour'] = $tab_jours[1]->thisDay();
49
		$aso_gestion['sjc_1']['jour'] = $tab_jours[1]->thisDay();
50
		$aso_gestion['sjc_1']['mois'] = $Calendrier->getNomMois($tab_jours[1]->thisMonth());
50
		$aso_gestion['sjc_1']['mois'] = $Calendrier->getNomMois($tab_jours[1]->thisMonth());
51
		$aso_gestion['sjc_1']['annee'] = $tab_jours[1]->thisYear();
51
		$aso_gestion['sjc_1']['annee'] = $tab_jours[1]->thisYear();
52
		$aso_gestion['sjc_7']['jour'] = $tab_jours[7]->thisDay();
52
		$aso_gestion['sjc_7']['jour'] = $tab_jours[7]->thisDay();
53
		$aso_gestion['sjc_7']['mois'] = $Calendrier->getNomMois($tab_jours[7]->thisMonth());
53
		$aso_gestion['sjc_7']['mois'] = $Calendrier->getNomMois($tab_jours[7]->thisMonth());
54
		$aso_gestion['sjc_7']['annee'] = $tab_jours[7]->thisYear();
54
		$aso_gestion['sjc_7']['annee'] = $tab_jours[7]->thisYear();
55
 
55
 
56
		$aso_gestion['selectedDays'] = array ($CalendrierJourCourrant);
56
		$aso_gestion['selectedDays'] = array ($CalendrierJourCourrant);
57
 
57
 
58
		// Instruct month to build Week objects
58
		// Instruct month to build Week objects
59
		// Construction de l'objet mois
59
		// Construction de l'objet mois
60
		$Month = new Calendar_Month_Weeks($_GET['annee'], $_GET['mois']);
60
		$Month = new Calendar_Month_Weeks($_GET['annee'], $_GET['mois']);
61
		$Month->build();
61
		$Month->build();
62
 
62
 
63
		while ($Week = $Month->fetch()) {
63
		while ($Week = $Month->fetch()) {
64
			$Week->build($aso_gestion['selectedDays']);
64
			$Week->build($aso_gestion['selectedDays']);
65
			//echo '<pre>'.print_r($Month, true).'</pre>';
65
			//echo '<pre>'.print_r($Month, true).'</pre>';
66
			$tab_semaine_jours = $Week->fetchAll();
66
			$tab_semaine_jours = $Week->fetchAll();
67
			foreach ($tab_semaine_jours as $num => $Day) {
67
			foreach ($tab_semaine_jours as $num => $Day) {
68
				$element = array();
68
				$element = array();
69
				$element['annee'] = $Day->thisYear();
69
				$element['annee'] = $Day->thisYear();
70
				$element['mois'] = $Day->thisMonth();
70
				$element['mois'] = $Day->thisMonth();
71
				$element['jour'] = $Day->thisDay();
71
				$element['jour'] = $Day->thisDay();
72
				$element['jour_nom'] = $Calendrier->getNomJours($num);
72
				$element['jour_nom'] = $Calendrier->getNomJours($num);
73
				$element['url'] = 'index.php?action='.GTT_ACTION_GESTION.'&amp;annee='.$Day->thisYear().'&amp;mois='.$Day->thisMonth().'&amp;jour='.$Day->thisDay();
73
				$element['url'] = 'index.php?action='.GTT_ACTION_GESTION.'&amp;annee='.$Day->thisYear().'&amp;mois='.$Day->thisMonth().'&amp;jour='.$Day->thisDay();
74
				// Check to see if day is selected
74
				// Check to see if day is selected
75
				if ($Day->isSelected()) {
75
				if ($Day->isSelected()) {
76
					$element['class'] = 'jour_courrant';
76
					$element['class'] = 'jour_courrant';
77
				} else if ($Day->isEmpty()) {
77
				} else if ($Day->isEmpty()) {
78
					$element['class'] = 'jour_vide';
78
					$element['class'] = 'jour_vide';
79
				} else {
79
				} else {
80
					$element['class'] = 'jour';
80
					$element['class'] = 'jour';
81
				}
81
				}
82
				foreach ($tab_jours_feries as $jour_ferie) {
82
				foreach ($tab_jours_feries as $jour_ferie) {
83
					if ($Day->thisDay(true) ==  $jour_ferie) {
83
					if ($Day->thisDay(true) ==  $jour_ferie) {
84
						$element['class'] = 'jour_ferie';
84
						$element['class'] = 'jour_ferie';
85
					}
85
					}
86
				}
86
				}
87
				$aso_gestion['elements'][$Week->thisWeek('n_in_year')][$num] = $element;
87
				$aso_gestion['elements'][$Week->thisWeek('n_in_year')][$num] = $element;
88
			}
88
			}
89
		}
89
		}
90
 
90
 
91
		// Construction de l'url pour les mois précédent/suivant
91
		// Construction de l'url pour les mois précédent/suivant
92
		$PMonth = $Month->prevMonth('object');
92
		$PMonth = $Month->prevMonth('object');
93
		$aso_gestion['url_mois_precedent'] = 'index.php?action='.GTT_ACTION_GESTION.'&amp;annee='.$PMonth->thisYear().'&amp;mois='.$PMonth->thisMonth().'&amp;jour='.$PMonth->thisDay();
93
		$aso_gestion['url_mois_precedent'] = 'index.php?action='.GTT_ACTION_GESTION.'&amp;annee='.$PMonth->thisYear().'&amp;mois='.$PMonth->thisMonth().'&amp;jour='.$PMonth->thisDay();
94
		$NMonth = $Month->nextMonth('object');
94
		$NMonth = $Month->nextMonth('object');
95
		$aso_gestion['url_mois_suivant'] = 'index.php?action='.GTT_ACTION_GESTION.'&amp;annee='.$NMonth->thisYear().'&amp;mois='.$NMonth->thisMonth().'&amp;jour='.$NMonth->thisDay();
95
		$aso_gestion['url_mois_suivant'] = 'index.php?action='.GTT_ACTION_GESTION.'&amp;annee='.$NMonth->thisYear().'&amp;mois='.$NMonth->thisMonth().'&amp;jour='.$NMonth->thisDay();
96
		$aso_gestion['mois']['mois'] = $Calendrier->getNomMois($Month->thisMonth());
96
		$aso_gestion['mois']['mois'] = $Calendrier->getNomMois($Month->thisMonth());
97
		$aso_gestion['mois']['annee'] = $Month->thisYear();
97
		$aso_gestion['mois']['annee'] = $Month->thisYear();
98
 
98
 
99
		// Construction de l'url pour les semaines précédente/suivante
99
		// Construction de l'url pour les semaines précédente/suivante
100
		$Week = new Calendar_Week($_GET['annee'], $_GET['mois'], $_GET['jour']);
100
		$Week = new Calendar_Week($_GET['annee'], $_GET['mois'], $_GET['jour']);
101
		$aso_gestion['s'] = $Week->thisWeek('n_in_year');
101
		$aso_gestion['s'] = $Week->thisWeek('n_in_year');
102
 
102
 
103
		$PWeek = $Week->prevWeek('object');
103
		$PWeek = $Week->prevWeek('object');
104
		$aso_gestion['url_semaine_precedente'] = 'index.php?action='.GTT_ACTION_GESTION.'&amp;annee='.$PWeek->thisYear().'&amp;mois='.$PWeek->thisMonth().'&amp;jour='.$PWeek->thisDay();
104
		$aso_gestion['url_semaine_precedente'] = 'index.php?action='.GTT_ACTION_GESTION.'&amp;annee='.$PWeek->thisYear().'&amp;mois='.$PWeek->thisMonth().'&amp;jour='.$PWeek->thisDay();
105
 
105
 
106
		$url_sc_param_date = '&amp;annee='.$Week->thisYear().'&amp;mois='.$Week->thisMonth().'&amp;jour='.$Week->thisDay();
106
		$url_sc_param_date = '&amp;annee='.$Week->thisYear().'&amp;mois='.$Week->thisMonth().'&amp;jour='.$Week->thisDay();
107
		$aso_gestion['url_semaine_courante'] = 'index.php?action='.GTT_ACTION_GESTION.$url_sc_param_date;
107
		$aso_gestion['url_semaine_courante'] = 'index.php?action='.GTT_ACTION_GESTION.$url_sc_param_date;
108
 
108
 
109
		$NWeek = $Week->nextWeek('object');
109
		$NWeek = $Week->nextWeek('object');
110
		$aso_gestion['url_semaine_suivante'] = 'index.php?action='.GTT_ACTION_GESTION.'&amp;annee='.$NWeek->thisYear().'&amp;mois='.$NWeek->thisMonth().'&amp;jour='.$NWeek->thisDay();
110
		$aso_gestion['url_semaine_suivante'] = 'index.php?action='.GTT_ACTION_GESTION.'&amp;annee='.$NWeek->thisYear().'&amp;mois='.$NWeek->thisMonth().'&amp;jour='.$NWeek->thisDay();
111
 
111
 
112
		$Week->build();
112
		$Week->build();
113
		$aso_jours = array();
113
		$aso_jours = array();
114
		foreach($Week->fetchAll() as $num => $j) {
114
		foreach($Week->fetchAll() as $num => $j) {
115
			$aso_gestion['sj_'.$num]['jour'] = $j->thisDay();
115
			$aso_gestion['sj_'.$num]['jour'] = $j->thisDay();
116
			$aso_gestion['sj_'.$num]['mois'] = $Calendrier->getNomMois($j->thisMonth());
116
			$aso_gestion['sj_'.$num]['mois'] = $Calendrier->getNomMois($j->thisMonth());
117
			$aso_gestion['sj_'.$num]['annee'] = $j->thisYear();
117
			$aso_gestion['sj_'.$num]['annee'] = $j->thisYear();
118
			$aso_gestion['sj_'.$num]['mysql'] = $aso_gestion['sj_'.$num]['annee'].'-'.sprintf("%02s", $j->thisMonth()).'-'.$aso_gestion['sj_'.$num]['jour'];
118
			$aso_gestion['sj_'.$num]['mysql'] = $aso_gestion['sj_'.$num]['annee'].'-'.sprintf("%02s", $j->thisMonth()).'-'.$aso_gestion['sj_'.$num]['jour'];
119
			$aso_jours[$aso_gestion['sj_'.$num]['mysql']] = $num;
119
			$aso_jours[$aso_gestion['sj_'.$num]['mysql']] = $num;
120
			$aso_tps_w_vide[$num] = '';
120
			$aso_tps_w_vide[$num] = '';
121
		}
121
		}
122
 
122
 
123
		//+-------------------------------------------------------------------------------------------------+
123
		//+-------------------------------------------------------------------------------------------------+
124
		// GESTION DES PROJETS
124
		// GESTION DES PROJETS
125
		//+-------------------------------------------------------------------------------------------------+
125
		//+-------------------------------------------------------------------------------------------------+
126
    	// Récupération des infos sur l'utilisateur
126
    	// Récupération des infos sur l'utilisateur
127
 		$aso_gestion['conges_payes'] = $GLOBALS['_GTT_']['Utilisateur']->getCongesPayes();
127
 		$aso_gestion['conges_payes'] = $GLOBALS['_GTT_']['Utilisateur']->getCongesPayes();
128
 		$aso_gestion['rtt'] = $GLOBALS['_GTT_']['Utilisateur']->getQuotaHeuresSupp();
128
 		$aso_gestion['rtt'] = $GLOBALS['_GTT_']['Utilisateur']->getQuotaHeuresSupp();
129
 		$aso_gestion['tps_w'] = $GLOBALS['_GTT_']['Utilisateur']->getTempsDeTravail();
129
 		$aso_gestion['tps_w'] = $GLOBALS['_GTT_']['Utilisateur']->getTempsDeTravail();
130
 
130
 
131
    	// Récupération des projets sur lesquels l'utilisateur travaille
131
    	// Récupération des projets sur lesquels l'utilisateur travaille
132
		$UtilsateurAProjet = new UtilisateurAProjet();
132
		$UtilsateurAProjet = new UtilisateurAProjet();
133
    	$tab_uap = $UtilsateurAProjet->consulter(UtilisateurAProjet::GUAP_UTILISATEUR, $GLOBALS['_GTT_']['Utilisateur']->getIdUtilisateur());
133
    	$tab_uap = $UtilsateurAProjet->consulter(UtilisateurAProjet::GUAP_UTILISATEUR, $GLOBALS['_GTT_']['Utilisateur']->getIdUtilisateur());
134
    	$tab_projet_id = array();
134
    	$tab_projet_id = array();
135
    	foreach ($tab_uap as $uap) {
135
    	foreach ($tab_uap as $uap) {
136
    		$tab_projet_id[] = $uap->getIdProjet();
136
    		$tab_projet_id[] = $uap->getIdProjet();
137
    	}
137
    	}
138
 
138
 
139
    	// Récupération du temps de travail pour un utilisateur à une date donnée
139
    	// Récupération du temps de travail pour un utilisateur à une date donnée
140
    	$TravailProjet = new TravailProjet();
140
    	$TravailProjet = new TravailProjet();
141
		$cmd = TravailProjet::GTP_ID_UTILISATEUR_DATE_DEB_FIN;
141
		$cmd = TravailProjet::GTP_ID_UTILISATEUR_DATE_DEB_FIN;
142
		$param = array($GLOBALS['_GTT_']['Utilisateur']->getIdUtilisateur(), $aso_gestion['sj_1']['mysql'], $aso_gestion['sj_7']['mysql']);
142
		$param = array($GLOBALS['_GTT_']['Utilisateur']->getIdUtilisateur(), $aso_gestion['sj_1']['mysql'], $aso_gestion['sj_7']['mysql']);
143
		$tab_tp = $TravailProjet->consulter($cmd, $param);
143
		$tab_tp = $TravailProjet->consulter($cmd, $param);
144
		if ($tab_tp && count($tab_tp) == 1) {
144
		if ($tab_tp && count($tab_tp) == 1) {
145
			$tab_tp = array($tab_tp);
145
			$tab_tp = array($tab_tp);
146
		}
146
		}
147
 
147
 
148
		// Récupération des infos sur les projets de l'utilisateur
148
		// Récupération des infos sur les projets de l'utilisateur
149
    	$aso_gestion['totaux'] = $aso_tps_w_vide;
149
    	$aso_gestion['totaux'] = $aso_tps_w_vide;
150
    	$Projet = new Projet();
150
    	$Projet = new Projet();
151
    	$tab_p = $Projet->consulter(Projet::GP_ID_LIST, array(implode(',', $tab_projet_id)));
151
    	$tab_p = $Projet->consulter(Projet::GP_ID_LIST, array(implode(',', $tab_projet_id)));
152
		foreach ($tab_p as $Projet) {
152
		foreach ($tab_p as $Projet) {
153
 
153
 
154
			// Récupération de la catégorie du projet
154
			// Récupération de la catégorie du projet
155
			$ProjetCategorie = new ProjetCategorie();
155
			$ProjetCategorie = new ProjetCategorie();
156
			$cmd = ProjetCategorie::GPC_ID;
156
			$cmd = ProjetCategorie::GPC_ID;
157
			$param = $Projet->getCeCategorie();
157
			$param = $Projet->getCeCategorie();
158
			$Categorie = $ProjetCategorie->consulter($cmd, $param);
158
			$Categorie = $ProjetCategorie->consulter($cmd, $param);
159
 
159
 
160
			// Nous vérifions le temps de travail pour ce projet pour la semaine courrante
160
			// Nous vérifions le temps de travail pour ce projet pour la semaine courrante
161
			$aso_tps_w = $aso_tps_w_vide;
161
			$aso_tps_w = $aso_tps_w_vide;
162
			if (!isset($aso_gestion['categorie_totaux'][$Categorie->getLibelle()])) {
162
			if (!isset($aso_gestion['categorie_totaux'][$Categorie->getLibelle()])) {
163
				$aso_gestion['categorie_totaux'][$Categorie->getLibelle()] = $aso_tps_w_vide;
163
				$aso_gestion['categorie_totaux'][$Categorie->getLibelle()] = $aso_tps_w_vide;
164
			}
164
			}
165
			if ($tab_tp) {
165
			if ($tab_tp) {
166
				foreach ($tab_tp as $TP) {
166
				foreach ($tab_tp as $TP) {
167
					if ($TP->getIdProjet() == $Projet->getIdProjet()) {
167
					if ($TP->getIdProjet() == $Projet->getIdProjet()) {
168
						$num = $aso_jours[$TP->getIdDateTravail()];
168
						$num = $aso_jours[$TP->getIdDateTravail()];
169
						$aso_tps_w[$num] = $TP->getDuree();
169
						$aso_tps_w[$num] = $TP->getDuree();
170
						$aso_gestion['categorie_totaux'][$Categorie->getLibelle()][$num] += $TP->getDuree();
170
						$aso_gestion['categorie_totaux'][$Categorie->getLibelle()][$num] += $TP->getDuree();
171
						$aso_gestion['totaux'][$num] += $TP->getDuree();
171
						$aso_gestion['totaux'][$num] += $TP->getDuree();
172
					}
172
					}
173
				}
173
				}
174
			}
174
			}
175
 
175
 
176
			// Stockage des infos nécessaire pour l'affichage
176
			// Stockage des infos nécessaire pour l'affichage
177
			$aso_gestion['preferences'][$Categorie->getLibelle()][] = array(
177
			$aso_gestion['preferences'][$Categorie->getLibelle()][] = array(
178
				'id' => $Projet->getIdProjet(),
178
				'id' => $Projet->getIdProjet(),
179
				'valeur' => $Projet->getIdProjet(),
179
				'valeur' => $Projet->getIdProjet(),
180
				'nom' => $Projet->getNomProjet(),
180
				'nom' => $Projet->getNomProjet(),
181
				'date' => $aso_tps_w);
181
				'date' => $aso_tps_w);
182
 
182
 
183
 
183
 
184
		}
184
		}
185
		//+-------------------------------------------------------------------------------------------------+
185
		//+-------------------------------------------------------------------------------------------------+
186
		// GESTION DES ABSENCES
186
		// GESTION DES ABSENCES
187
		//+-------------------------------------------------------------------------------------------------+
187
		//+-------------------------------------------------------------------------------------------------+
188
		// Récupération des motifs d'absence
188
		// Récupération des motifs d'absence
189
		$AbsenceMotif = new AbsenceMotif();
189
		$AbsenceMotif = new AbsenceMotif();
190
		$cmd = AbsenceMotif::GAM_TOUS;
190
		$cmd = AbsenceMotif::GAM_TOUS;
191
		$tab_am = $AbsenceMotif->consulter($cmd);
191
		$tab_am = $AbsenceMotif->consulter($cmd);
192
		if ($tab_am && count($tab_am) == 1) {
192
		if ($tab_am && count($tab_am) == 1) {
193
			$tab_am = array($tab_am);
193
			$tab_am = array($tab_am);
194
		}
194
		}
195
 
195
 
196
		// Récupération des absences pour un utilisateur à une date donnée
196
		// Récupération des absences pour un utilisateur à une date donnée
197
    	$Absence = new Absence();
197
    	$Absence = new Absence();
198
		$cmd = Absence::GA_ID_UTILISATEUR_DATE_DEB_FIN;
198
		$cmd = Absence::GA_ID_UTILISATEUR_DATE_DEB_FIN;
199
		$param = array($GLOBALS['_GTT_']['Utilisateur']->getIdUtilisateur(), $aso_gestion['sj_1']['mysql'], $aso_gestion['sj_7']['mysql']);
199
		$param = array($GLOBALS['_GTT_']['Utilisateur']->getIdUtilisateur(), $aso_gestion['sj_1']['mysql'], $aso_gestion['sj_7']['mysql']);
200
		$tab_a = $Absence->consulter($cmd, $param);
200
		$tab_a = $Absence->consulter($cmd, $param);
201
		if ($tab_a && count($tab_a) == 1) {
201
		if ($tab_a && count($tab_a) == 1) {
202
			$tab_a = array($tab_a);
202
			$tab_a = array($tab_a);
203
		}
203
		}
204
 
204
 
205
		$aso_gestion['ab_total'] = $aso_tps_w_vide;
205
		$aso_gestion['ab_total'] = $aso_tps_w_vide;
206
		if ($tab_am) {
206
		if ($tab_am) {
207
			foreach ($tab_am as $AM) {
207
			foreach ($tab_am as $AM) {
208
				$aso_gestion['ab_libelle'][$AM->getIdAbsenceMotif()] = $AM->getLibelle();
208
				$aso_gestion['ab_libelle'][$AM->getIdAbsenceMotif()] = $AM->getLibelle();
209
				$aso_gestion['ab'][$AM->getIdAbsenceMotif()] = $aso_tps_w_vide;
209
				$aso_gestion['ab'][$AM->getIdAbsenceMotif()] = $aso_tps_w_vide;
210
				if ($tab_a) {
210
				if ($tab_a) {
211
					foreach ($tab_a as $A) {
211
					foreach ($tab_a as $A) {
212
						if ($A->getIdAbsenceMotif() == $AM->getIdAbsenceMotif()) {
212
						if ($A->getIdAbsenceMotif() == $AM->getIdAbsenceMotif()) {
213
							$num = $aso_jours[$A->getIdDateAbsence()];
213
							$num = $aso_jours[$A->getIdDateAbsence()];
214
							$aso_gestion['ab'][$AM->getIdAbsenceMotif()][$num] = $A->getDuree();
214
							$aso_gestion['ab'][$AM->getIdAbsenceMotif()][$num] = $A->getDuree();
215
							$aso_gestion['ab_total'][$num] += $A->getDuree();
215
							$aso_gestion['ab_total'][$num] += $A->getDuree();
216
							$aso_gestion['totaux'][$num] += $A->getDuree();
216
							$aso_gestion['totaux'][$num] += $A->getDuree();
217
						}
217
						}
218
					}
218
					}
219
				}
219
				}
220
			}
220
			}
221
		}
221
		}
222
 
222
 
223
		// Création de l'url de réponse du formulaire
223
		// Création de l'url de réponse du formulaire
224
		$aso_gestion['url_gestion_valider'] = 'index.php?action='.GTT_ACTION_GESTION_VALIDER.$url_sc_param_date;
224
		$aso_gestion['url_gestion_valider'] = 'index.php?action='.GTT_ACTION_GESTION_VALIDER.$url_sc_param_date;
225
 
225
 
226
    	//echo '<pre>ici '.print_r($aso_gestion['ab'], true).'la</pre>';
226
    	//echo '<pre>ici '.print_r($aso_gestion['ab'], true).'la</pre>';
227
		$this->getRegistre()->ajouterDonnee('gestion', $aso_gestion);
227
		$this->getRegistre()->ajouterDonnee('gestion', $aso_gestion);
228
    }
228
    }
229
 
229
 
230
    public function verifierValider()
230
    public function verifierValider()
231
    {
231
    {
232
 
232
 
233
    }
233
    }
234
 
234
 
235
	public function executerValider()
235
	public function executerValider()
236
    {
236
    {
237
    	//echo '<pre>'.print_r($_POST, true).'</pre>';
237
    	//echo '<pre>'.print_r($_POST, true).'</pre>';
238
 
238
 
239
    	// Récupération des info sur la semaine courrante
239
    	// Récupération des info sur la semaine courrante
240
		$Week = new Calendar_Week($_GET['annee'], $_GET['mois'], $_GET['jour']);
240
		$Week = new Calendar_Week($_GET['annee'], $_GET['mois'], $_GET['jour']);
241
		$Week->build();
241
		$Week->build();
242
		$aso_jours = array();
242
		$aso_jours = array();
243
		$aso_semaine = array();
243
		$aso_semaine = array();
244
		foreach($Week->fetchAll() as $num => $j) {
244
		foreach($Week->fetchAll() as $num => $j) {
245
			$aso_semaine[$num]['mysql'] = $j->thisYear().'-'.sprintf("%02s", $j->thisMonth()).'-'.$j->thisDay();
245
			$aso_semaine[$num]['mysql'] = $j->thisYear().'-'.sprintf("%02s", $j->thisMonth()).'-'.$j->thisDay();
246
			$aso_jours[$aso_semaine[$num]['mysql']] = $num;
246
			$aso_jours[$aso_semaine[$num]['mysql']] = $num;
247
		}
247
		}
248
 
248
 
249
		// Récupération du temps de travail pour un utilisateur à une date donnée
249
		// Récupération du temps de travail pour un utilisateur à une date donnée
250
    	$TravailProjet = new TravailProjet();
250
    	$TravailProjet = new TravailProjet();
251
		$cmd = TravailProjet::GTP_ID_UTILISATEUR_DATE_DEB_FIN;
251
		$cmd = TravailProjet::GTP_ID_UTILISATEUR_DATE_DEB_FIN;
252
		$param = array($GLOBALS['_GTT_']['Utilisateur']->getIdUtilisateur(), $aso_semaine[1]['mysql'], $aso_semaine[7]['mysql']);
252
		$param = array($GLOBALS['_GTT_']['Utilisateur']->getIdUtilisateur(), $aso_semaine[1]['mysql'], $aso_semaine[7]['mysql']);
253
		$tab_tp = $TravailProjet->consulter($cmd, $param);
253
		$tab_tp = $TravailProjet->consulter($cmd, $param);
254
		if ($tab_tp && count($tab_tp) == 1) {
254
		if ($tab_tp && count($tab_tp) == 1) {
255
			$tab_tp = array($tab_tp);
255
			$tab_tp = array($tab_tp);
256
		}
256
		}
257
 
257
 
258
		// Ajout ou Mise à jour des durées de travail
258
		// Ajout ou Mise à jour des durées de travail
259
		if (isset($_POST['pr'])) {
259
		if (isset($_POST['pr'])) {
260
			foreach($_POST['pr'] as $projet_id => $jours) {
260
			foreach($_POST['pr'] as $projet_id => $jours) {
261
				//echo '<pre>'.print_r($jours, true).'</pre>';
261
				//echo '<pre>'.print_r($jours, true).'</pre>';
262
				foreach($jours as $jour_num => $nbr_heure) {
262
				foreach($jours as $jour_num => $nbr_heure) {
263
					$bool_ajouter = true;
263
					$bool_ajouter = true;
264
					if (!empty($tab_tp)) {
264
					if (!empty($tab_tp)) {
265
						foreach ($tab_tp as $TP) {
265
						foreach ($tab_tp as $TP) {
266
							if ($TP->getIdDateTravail() == $aso_semaine[$jour_num]['mysql']) {
266
							if ($TP->getIdDateTravail() == $aso_semaine[$jour_num]['mysql']) {
267
								if ($TP->getIdProjet() == $projet_id) {
267
								if ($TP->getIdProjet() == $projet_id) {
268
									$bool_ajouter = false;
268
									$bool_ajouter = false;
269
									if ($TP->getDuree() != $nbr_heure) {
269
									if ($TP->getDuree() != $nbr_heure) {
270
										if (empty($nbr_heure)) {
270
										if (empty($nbr_heure)) {
271
											$TP->supprimer();
271
											$TP->supprimer();
272
										} else {
272
										} else {
273
											$TP->setDuree($nbr_heure);
273
											$TP->setDuree($nbr_heure);
274
											$TP->modifier();
274
											$TP->modifier();
275
										}
275
										}
276
									}
276
									}
277
								}
277
								}
278
							}
278
							}
279
						}
279
						}
280
					}
280
					}
281
					if ($bool_ajouter && !empty($nbr_heure)) {
281
					if ($bool_ajouter && !empty($nbr_heure)) {
282
						$TP = new TravailProjet();
282
						$TP = new TravailProjet();
283
						$TP->setDuree((float)$nbr_heure);
283
						$TP->setDuree((float)$nbr_heure);
284
						$TP->setIdUtilisateur($GLOBALS['_GTT_']['Utilisateur']->getIdUtilisateur());
284
						$TP->setIdUtilisateur($GLOBALS['_GTT_']['Utilisateur']->getIdUtilisateur());
285
						$TP->setIdProjet($projet_id);
285
						$TP->setIdProjet($projet_id);
286
						$TP->setIdDateTravail((string)$aso_semaine[$jour_num]['mysql']);
286
						$TP->setIdDateTravail((string)$aso_semaine[$jour_num]['mysql']);
287
						$TP->ajouter();
287
						$TP->ajouter();
288
					}
288
					}
289
				}
289
				}
290
			}
290
			}
291
		}
291
		}
292
 
292
 
293
		// Récupération des absences pour un utilisateur à une date donnée
293
		// Récupération des absences pour un utilisateur à une date donnée
294
    	$Absence = new Absence();
294
    	$Absence = new Absence();
295
		$cmd = Absence::GA_ID_UTILISATEUR_DATE_DEB_FIN;
295
		$cmd = Absence::GA_ID_UTILISATEUR_DATE_DEB_FIN;
296
		$param = array($GLOBALS['_GTT_']['Utilisateur']->getIdUtilisateur(), $aso_semaine[1]['mysql'], $aso_semaine[7]['mysql']);
296
		$param = array($GLOBALS['_GTT_']['Utilisateur']->getIdUtilisateur(), $aso_semaine[1]['mysql'], $aso_semaine[7]['mysql']);
297
		$tab_a = $Absence->consulter($cmd, $param);
297
		$tab_a = $Absence->consulter($cmd, $param);
298
		if ($tab_a && count($tab_a) == 1) {
298
		if ($tab_a && count($tab_a) == 1) {
299
			$tab_a = array($tab_a);
299
			$tab_a = array($tab_a);
300
		}
300
		}
301
 
301
 
302
		// Ajout ou Mise à jour des durées d'absences pour congés payés
302
		// Ajout ou Mise à jour des durées d'absences pour congés payés
303
		if (isset($_POST['ab'])) {
303
		if (isset($_POST['ab'])) {
304
			//echo '<pre>'.print_r($_POST['ab'], true).'</pre>';
304
			//echo '<pre>'.print_r($_POST['ab'], true).'</pre>';
305
			foreach($_POST['ab'] as $ab_id => $tab_num_j) {
305
			foreach($_POST['ab'] as $ab_id => $tab_num_j) {
306
				foreach($tab_num_j as $num_j => $ab_duree) {
306
				foreach($tab_num_j as $num_j => $ab_duree) {
307
					$bool_ajouter = true;
307
					$bool_ajouter = true;
308
					if (!empty($tab_a)) {
308
					if (!empty($tab_a)) {
309
						foreach ($tab_a as $A) {
309
						foreach ($tab_a as $A) {
310
							if ($A->getIdDateAbsence() == $aso_semaine[$num_j]['mysql']) {
310
							if ($A->getIdDateAbsence() == $aso_semaine[$num_j]['mysql']) {
311
 
311
 
312
								if ($A->getIdAbsenceMotif() == $ab_id) {
312
								if ($A->getIdAbsenceMotif() == $ab_id) {
313
									$bool_ajouter = false;
313
									$bool_ajouter = false;
314
 
314
 
315
									if ($A->getDuree() != $ab_duree) {
315
									if ($A->getDuree() != $ab_duree) {
316
										echo 'ici'.$ab_duree;
-
 
317
										if (empty($ab_duree)) {
316
										if (empty($ab_duree)) {
318
											$A->supprimer();
317
											$A->supprimer();
319
										} else {
318
										} else {
320
											$A->setDuree($ab_duree);
319
											$A->setDuree($ab_duree);
321
											$A->modifier();
320
											$A->modifier();
322
										}
321
										}
323
									}
322
									}
324
								}
323
								}
325
							}
324
							}
326
						}
325
						}
327
					}
326
					}
328
					if ($bool_ajouter && !empty($ab_duree)) {
327
					if ($bool_ajouter && !empty($ab_duree)) {
329
						$A = new Absence();
328
						$A = new Absence();
330
						$A->setDuree((float)$ab_duree);
329
						$A->setDuree((float)$ab_duree);
331
						$A->setIdUtilisateur($GLOBALS['_GTT_']['Utilisateur']->getIdUtilisateur());
330
						$A->setIdUtilisateur($GLOBALS['_GTT_']['Utilisateur']->getIdUtilisateur());
332
						$A->setIdAbsenceMotif($ab_id);
331
						$A->setIdAbsenceMotif($ab_id);
333
						$A->setIdDateAbsence((string)$aso_semaine[$num_j]['mysql']);
332
						$A->setIdDateAbsence((string)$aso_semaine[$num_j]['mysql']);
334
						$A->ajouter();
333
						$A->ajouter();
335
					}
334
					}
336
				}
335
				}
337
			}
336
			}
338
		}
337
		}
339
 
338
 
340
    	// Action suivante
339
    	// Action suivante
341
    	$this->setSuivant('__defaut__');
340
    	$this->setSuivant('__defaut__');
342
    }
341
    }
343
}
342
}
344
?>
343
?>