Subversion Repositories Applications.gtt

Rev

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

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