Subversion Repositories Applications.gtt

Rev

Rev 101 | Rev 116 | Go to most recent revision | Show entire file | Ignore whitespace | Details | Blame | Last modification | View Log | RSS feed

Rev 101 Rev 103
Line 11... Line 11...
11
    {
11
    {
12
   		$aso_stat = array();
12
   		$aso_stat = array();
13
    	$this->getRegistre()->setTitre('Plan de charge');
13
    	$this->getRegistre()->setTitre('Plan de charge');
Line 14... Line 14...
14
 
14
 
15
    	//+-------------------------------------------------------------------------------------------------+
15
    	//+-------------------------------------------------------------------------------------------------+
16
		// GESTION DES PARAMÊTRE de l'URL
16
		// GESTION DES PARAMÊTRE de l'URL
17
		//+-------------------------------------------------------------------------------------------------+
17
		//+-------------------------------------------------------------------------------------------------+
18
		// Initialisation des variables
18
		// Initialisation des variables
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['uid'])) {// ID de l'utilisateur à afficher
25
		if (!isset($_GET['uid'])) {// ID de l'utilisateur à afficher
26
			$_GET['uid'] = null;
26
			$_GET['uid'] = null;
27
		}
27
		}
28
		//+-------------------------------------------------------------------------------------------------+
28
		//+-------------------------------------------------------------------------------------------------+
29
		// GESTION DES UTILISATEURS
29
		// GESTION DES UTILISATEURS
Line 33... Line 33...
33
    	if (is_object($utilisateurs)) {
33
    	if (is_object($utilisateurs)) {
34
    		$utilisateurs[0] = $utilisateurs;
34
    		$utilisateurs[0] = $utilisateurs;
35
    	}
35
    	}
36
    	$UtilisateurCourant = null;
36
    	$UtilisateurCourant = null;
37
    	foreach ($utilisateurs as $Utilisateur) {
37
    	foreach ($utilisateurs as $Utilisateur) {
38
	    	// Récupération des infos sur l'utilisateur
38
	    	// Récupération des infos sur l'utilisateur
39
	 		$aso_stat['utilisateurs'][$Utilisateur->getIdUtilisateur()]['courant'] = false;
39
	 		$aso_stat['utilisateurs'][$Utilisateur->getIdUtilisateur()]['courant'] = false;
40
	 		$aso_stat['utilisateurs'][$Utilisateur->getIdUtilisateur()]['nom'] = $Utilisateur->getPrenom().' '.$Utilisateur->getNom();
40
	 		$aso_stat['utilisateurs'][$Utilisateur->getIdUtilisateur()]['nom'] = $Utilisateur->getPrenom().' '.$Utilisateur->getNom();
41
	 		if (	(!is_null($_GET['uid']) && $Utilisateur->getIdUtilisateur() == $_GET['uid'])
41
	 		if (	(!is_null($_GET['uid']) && $Utilisateur->getIdUtilisateur() == $_GET['uid'])
42
	 			||	(is_null($_GET['uid']) && $Utilisateur->getIdUtilisateur() == $GLOBALS['_GTT_']['Utilisateur']->getIdUtilisateur()) ) {
42
	 			||	(is_null($_GET['uid']) && $Utilisateur->getIdUtilisateur() == $GLOBALS['_GTT_']['Utilisateur']->getIdUtilisateur()) ) {
43
	 			$UtilisateurCourant = clone $Utilisateur;
43
	 			$UtilisateurCourant = clone $Utilisateur;
Line 59... Line 59...
59
		
59
		
60
		// Construction de l'objet mois
60
		// Construction de l'objet mois
61
		$Month = new Calendar_Month_Weeks($_GET['annee'], $_GET['mois']);
61
		$Month = new Calendar_Month_Weeks($_GET['annee'], $_GET['mois']);
Line 62... Line 62...
62
		$Month->build();
62
		$Month->build();
63
		
63
		
64
		// Récupération des jours du mois
64
		// Récupération des jours du mois
65
		while ($Week = $Month->fetch()) {
65
		while ($Week = $Month->fetch()) {
66
			$Week->build();
66
			$Week->build();
67
			//echo '<pre>'.print_r($Month, true).'</pre>';
67
			//echo '<pre>'.print_r($Month, true).'</pre>';
Line 71... Line 71...
71
				if ($Day->thisMonth() == $_GET['mois']) {
71
				if ($Day->thisMonth() == $_GET['mois']) {
72
					$element = array();
72
					$element = array();
73
					$element['jour'] = $Day->thisDay();
73
					$element['jour'] = $Day->thisDay();
74
					$element['jour_nom'] = $Calendrier->getNomJours($num);
74
					$element['jour_nom'] = $Calendrier->getNomJours($num);
75
					$element['class'] = 'jour';
75
					$element['class'] = 'jour';
76
					// Nous vérifions le type de jour
76
					// Nous vérifions le type de jour
77
					// Jour courrant
77
					// Jour courrant
78
					if ($Day->isSelected()) {
78
					if ($Day->isSelected()) {
79
						$element['class'] .= ' jour_courrant';
79
						$element['class'] .= ' jour_courrant';
80
					} 
80
					} 
81
					// Jour n'appartenant pas au moins courrant
81
					// Jour n'appartenant pas au moins courrant
82
					if ($Day->isEmpty()) {
82
					if ($Day->isEmpty()) {
83
						$element['class'] .= ' jour_vide';
83
						$element['class'] .= ' jour_vide';
84
					}
84
					}
85
					// Jour férié
85
					// Jour férié
86
					foreach ($tab_jours_feries as $jour_ferie) {
86
					foreach ($tab_jours_feries as $jour_ferie) {
87
						if ($Day->thisDay(true) ==  $jour_ferie) {
87
						if ($Day->thisDay(true) ==  $jour_ferie) {
88
							$element['class'] .= ' jour_ferie';
88
							$element['class'] .= ' jour_ferie';
89
						}
89
						}
90
					}
90
					}
Line 96... Line 96...
96
					$aso_stat['elements'][$id] = $element;
96
					$aso_stat['elements'][$id] = $element;
97
				}
97
				}
98
			}
98
			}
99
		}
99
		}
Line 100... Line 100...
100
		
100
		
101
		// Construction de l'url pour les mois précédent/suivant/courant et paramêtres pour le formulaire utilisateur
101
		// Construction de l'url pour les mois précédent/suivant/courant et paramêtres pour le formulaire utilisateur
102
		$aso_stat['form_url'] = 'index.php';
102
		$aso_stat['form_url'] = 'index.php';
103
		$aso_stat['form_param']['action'] = GTT_ACTION_STAT_TAB_CHARGE;
103
		$aso_stat['form_param']['action'] = GTT_ACTION_STAT_TAB_CHARGE;
104
		$aso_stat['form_param']['annee'] = $Month->thisYear();
104
		$aso_stat['form_param']['annee'] = $Month->thisYear();
105
		$aso_stat['form_param']['mois'] = $Month->thisMonth();
105
		$aso_stat['form_param']['mois'] = $Month->thisMonth();
Line 113... Line 113...
113
		$mois_courant_j36 = date('Y-m-d H:i:s', mktime(0, 0, 0, $NMonth->thisMonth(), 0, $NMonth->thisYear()));
113
		$mois_courant_j36 = date('Y-m-d H:i:s', mktime(0, 0, 0, $NMonth->thisMonth(), 0, $NMonth->thisYear()));
Line 114... Line 114...
114
		
114
		
115
		//+-------------------------------------------------------------------------------------------------+
115
		//+-------------------------------------------------------------------------------------------------+
116
		// GESTION DES PROJETS
116
		// GESTION DES PROJETS
117
		//+-------------------------------------------------------------------------------------------------+
117
		//+-------------------------------------------------------------------------------------------------+
118
    	// Récupération du temps de travail pour un utilisateur pour le mois donné
118
    	// Récupération du temps de travail pour un utilisateur pour le mois donné
119
    	$TravailProjet = new TravailProjet();
119
    	$TravailProjet = new TravailProjet();
120
		$cmd = TravailProjet::GTP_ID_UTILISATEUR_DATE_DEB_FIN;
120
		$cmd = TravailProjet::GTP_ID_UTILISATEUR_DATE_DEB_FIN;
121
		$param = array($Utilisateur->getIdUtilisateur(), $mois_courant_j1, $mois_courant_j36);
121
		$param = array($Utilisateur->getIdUtilisateur(), $mois_courant_j1, $mois_courant_j36);
Line 122... Line 122...
122
		$tab_tp = $TravailProjet->consulter($cmd, $param);
122
		$tab_tp = $TravailProjet->consulter($cmd, $param);
123
		
123
		
124
		if ($tab_tp != false) {
124
		if ($tab_tp != false) {
125
			$tab_projet_id = array();
125
			$tab_projet_id = array();
126
			foreach ($tab_tp as $utp) {
126
			foreach ($tab_tp as $utp) {
127
    			$tab_projet_id[] = $utp->getIdProjet();
127
    			$tab_projet_id[] = $utp->getIdProjet();
128
    		}
128
    		}
129
			// Nous vérifions qu'il y a des données pour l'utilisateur courant pour le mois donné
129
			// Nous vérifions qu'il y a des données pour l'utilisateur courant pour le mois donné
130
			// Récupération des infos sur les projets de l'utilisateur
130
			// Récupération des infos sur les projets de l'utilisateur
131
	    	$Projet = new Projet();
131
	    	$Projet = new Projet();
132
	    	$tab_p = $Projet->consulter(Projet::GP_ID_LIST, array(implode(',', $tab_projet_id)));
132
	    	$tab_p = $Projet->consulter(Projet::GP_ID_LIST, array(implode(',', $tab_projet_id)));
133
			foreach ($tab_p as $Projet) {
133
			foreach ($tab_p as $Projet) {
134
				// Récupération de la catégorie du projet
134
				// Récupération de la catégorie du projet
135
				$ProjetCategorie = new ProjetCategorie();
135
				$ProjetCategorie = new ProjetCategorie();
136
				$cmd = ProjetCategorie::GPC_ID;
136
				$cmd = ProjetCategorie::GPC_ID;
Line 137... Line 137...
137
				$param = $Projet->getCeCategorie();
137
				$param = $Projet->getCeCategorie();
138
				$Categorie = current($ProjetCategorie->consulter($cmd, $param));
138
				$Categorie = current($ProjetCategorie->consulter($cmd, $param));
139
				
139
				
140
				// Nous vérifions le temps de travail pour ce projet
140
				// Nous vérifions le temps de travail pour ce projet
141
				$aso_tps_w = 0;
141
				$aso_tps_w = 0;
142
				if ($tab_tp) {
142
				if ($tab_tp) {
143
					foreach ($tab_tp as $TP) {
143
					foreach ($tab_tp as $TP) {
144
						$j = date('Y-m-d', strtotime($TP->getIdDateTravail()));
144
						$j = date('Y-m-d', strtotime($TP->getIdDateTravail()));
145
						if ($TP->getIdProjet() == $Projet->getIdProjet()) {
145
						if ($TP->getIdProjet() == $Projet->getIdProjet()) {
146
							// Récupération des infos sur les catégories
146
							// Récupération des infos sur les catégories
147
							if (!isset($aso_stat['categorie_totaux'][$Categorie->getLibelle()][$j])) {
147
							if (!isset($aso_stat['categorie_totaux'][$Categorie->getLibelle()][$j])) {
148
								$aso_stat['categorie_totaux'][$Categorie->getLibelle()][$j] = 0;
148
								$aso_stat['categorie_totaux'][$Categorie->getLibelle()][$j] = 0;
149
							}
149
							}
150
							$aso_stat['categorie_totaux'][$Categorie->getLibelle()][$j] += $TP->getDuree();
150
							$aso_stat['categorie_totaux'][$Categorie->getLibelle()][$j] += $TP->getDuree();
151
							// Récupération des infos sur les projets
151
							// Récupération des infos sur les projets
152
							if (!isset($aso_stat['projets'][$Categorie->getLibelle()][$Projet->getIdProjet()])) {
152
							if (!isset($aso_stat['projets'][$Categorie->getLibelle()][$Projet->getIdProjet()])) {
153
								$aso_stat['projets'][$Categorie->getLibelle()][$Projet->getIdProjet()] = array(
153
								$aso_stat['projets'][$Categorie->getLibelle()][$Projet->getIdProjet()] = array(
Line 165... Line 165...
165
		}
165
		}
Line 166... Line 166...
166
		
166
		
167
		//+-------------------------------------------------------------------------------------------------+
167
		//+-------------------------------------------------------------------------------------------------+
168
		// GESTION DES ABSENCES
168
		// GESTION DES ABSENCES
169
		//+-------------------------------------------------------------------------------------------------+
169
		//+-------------------------------------------------------------------------------------------------+
170
		// Récupération des motifs d'absence
170
		// Récupération des motifs d'absence
171
		$AbsenceMotif = new AbsenceMotif();
171
		$AbsenceMotif = new AbsenceMotif();
172
		$cmd = AbsenceMotif::GAM_TOUS;
172
		$cmd = AbsenceMotif::GAM_TOUS;
Line 173... Line 173...
173
		$tab_am = $AbsenceMotif->consulter($cmd);
173
		$tab_am = $AbsenceMotif->consulter($cmd);
174
 
174
 
175
		// Récupération des absences pour un utilisateur à une date donnée
175
		// Récupération des absences pour un utilisateur à une date donnée
176
    	$Absence = new Absence();
176
    	$Absence = new Absence();
177
		$cmd = Absence::GA_ID_UTILISATEUR_DATE_DEB_FIN;
177
		$cmd = Absence::GA_ID_UTILISATEUR_DATE_DEB_FIN;
178
		$param = array($Utilisateur->getIdUtilisateur(), $mois_courant_j1, $mois_courant_j36);
178
		$param = array($Utilisateur->getIdUtilisateur(), $mois_courant_j1, $mois_courant_j36);
Line 185... Line 185...
185
					//$aso_gestion['ab'][$AM->getIdAbsenceMotif()] = 0;
185
					//$aso_gestion['ab'][$AM->getIdAbsenceMotif()] = 0;
186
					if ($tab_a) {
186
					if ($tab_a) {
187
						foreach ($tab_a as $A) {
187
						foreach ($tab_a as $A) {
188
							if ($A->getIdAbsenceMotif() == $AM->getIdAbsenceMotif() && $A->getDuree() != 0) {
188
							if ($A->getIdAbsenceMotif() == $AM->getIdAbsenceMotif() && $A->getDuree() != 0) {
189
								$j = date('Y-m-d', strtotime($A->getIdDateAbsence()));
189
								$j = date('Y-m-d', strtotime($A->getIdDateAbsence()));
190
								// Récupération des infos sur les absences
190
								// Récupération des infos sur les absences
191
								$aso_stat['ab'][$AM->getIdAbsenceMotif()][$j] = $A->getDuree();
191
								$aso_stat['ab'][$AM->getIdAbsenceMotif()][$j] = $A->getDuree();
192
								// Récupération du total des absences
192
								// Récupération du total des absences
193
								if (!isset($aso_stat['ab_total'][$j])) {
193
								if (!isset($aso_stat['ab_total'][$j])) {
194
									$aso_stat['ab_total'][$j] = 0;
194
									$aso_stat['ab_total'][$j] = 0;
195
								}
195
								}
196
								$aso_stat['ab_total'][$j] += $A->getDuree();
196
								$aso_stat['ab_total'][$j] += $A->getDuree();
197
							}
197
							}
198
						}
198
						}
199
					}
199
					}
200
				}
200
				}
201
			}
201
			}
202
		} else {
202
		} else {
203
			$aso_stat['messages'][] = 'Aucune absence de mentionnée en '.$aso_stat['mois']['mois'].' '.$aso_stat['mois']['annee'];
203
			$aso_stat['messages'][] = 'Aucune absence de mentionnée en '.$aso_stat['mois']['mois'].' '.$aso_stat['mois']['annee'];
204
		}
204
		}
Line 205... Line 205...
205
		
205
		
206
		
206