Subversion Repositories Applications.gtt

Rev

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

Rev 126 Rev 138
1
<?php
1
<?php
2
class GttCtrlActionStatTableauGlobal extends aControlleurAction {
2
class GttCtrlActionStatTableauGlobal extends aControlleurAction {
3
 
3
 
4
	public function __construct(Registre $Registre)
4
	public function __construct(Registre $Registre)
5
    {
5
    {
6
    	$Registre->ajouterEspace('StatTableauGlobal', 'stat_tableau_global');
6
    	$Registre->ajouterEspace('StatTableauGlobal', 'stat_tableau_global');
7
    }
7
    }
8
 
8
 
9
    public function executer()
9
    public function executer()
10
    {
10
    {
11
   		$aso_stat = array();
11
   		$aso_stat = array();
12
    	$this->getRegistre()->setTitre('Tableau récapitulatif');
12
    	$this->getRegistre()->setTitre('Tableau récapitulatif');
13
 
13
 
14
    	//+-------------------------------------------------------------------------------------------------+
14
    	//+-------------------------------------------------------------------------------------------------+
15
		// GESTION DES CALENDRIERS
15
		// GESTION DES CALENDRIERS
16
		//+-------------------------------------------------------------------------------------------------+
16
		//+-------------------------------------------------------------------------------------------------+
17
		// Initialisation des variables pour le calendrier
17
		// Initialisation des variables pour le calendrier
18
		if (!isset($_GET['annee'])) {
18
		if (!isset($_GET['annee'])) {
19
			$_GET['annee'] = date('Y');
19
			$_GET['annee'] = date('Y');
20
		}
20
		}
21
		if (!isset($_GET['mois'])) {
21
		if (!isset($_GET['mois'])) {
22
			$_GET['mois'] = date('m');
22
			$_GET['mois'] = date('m');
23
		}
23
		}
24
 
24
 
25
		// Construction de l'objet mois
25
		// Construction de l'objet mois
26
		$Month = new Calendar_Month_Weeks($_GET['annee'], $_GET['mois']);
26
		$Month = new Calendar_Month_Weeks($_GET['annee'], $_GET['mois']);
27
		$Month->build();
27
		$Month->build();
28
 
28
 
29
		// Construction du Calendrier
29
		// Construction du Calendrier
30
		$Calendrier = new Calendrier();
30
		$Calendrier = new Calendrier();
31
		
31
		
32
		// Construction de l'url pour les mois précédent/suivant
32
		// Construction de l'url pour les mois précédent/suivant
33
		$aso_stat['url_mois_courant'] = 'index.php?action='.GTT_ACTION_STAT_TAB_GLOB.'&amp;annee='.$Month->thisYear().'&amp;mois='.$Month->thisMonth();
33
		$aso_stat['url_mois_courant'] = 'index.php?action='.GTT_ACTION_STAT_TAB_GLOB.'&amp;annee='.$Month->thisYear().'&amp;mois='.$Month->thisMonth();
34
		$PMonth = $Month->prevMonth('object');
34
		$PMonth = $Month->prevMonth('object');
35
		$aso_stat['url_mois_precedent'] = 'index.php?action='.GTT_ACTION_STAT_TAB_GLOB.'&amp;annee='.$PMonth->thisYear().'&amp;mois='.$PMonth->thisMonth();
35
		$aso_stat['url_mois_precedent'] = 'index.php?action='.GTT_ACTION_STAT_TAB_GLOB.'&amp;annee='.$PMonth->thisYear().'&amp;mois='.$PMonth->thisMonth();
36
		$NMonth = $Month->nextMonth('object');
36
		$NMonth = $Month->nextMonth('object');
37
		$aso_stat['url_mois_suivant'] = 'index.php?action='.GTT_ACTION_STAT_TAB_GLOB.'&amp;annee='.$NMonth->thisYear().'&amp;mois='.$NMonth->thisMonth();
37
		$aso_stat['url_mois_suivant'] = 'index.php?action='.GTT_ACTION_STAT_TAB_GLOB.'&amp;annee='.$NMonth->thisYear().'&amp;mois='.$NMonth->thisMonth();
38
		$aso_stat['mois']['mois'] = $Calendrier->getNomMois($Month->thisMonth());
38
		$aso_stat['mois']['mois'] = $Calendrier->getNomMois($Month->thisMonth());
39
		$aso_stat['mois']['annee'] = $Month->thisYear();
39
		$aso_stat['mois']['annee'] = $Month->thisYear();
40
		$mois_courant_j1 = $Month->thisYear().'-'.sprintf("%02s", $Month->thisMonth()).'-'.sprintf("%02s", $Month->thisDay()).' 00:00:00';
40
		$mois_courant_j1 = $Month->thisYear().'-'.sprintf("%02s", $Month->thisMonth()).'-'.sprintf("%02s", $Month->thisDay()).' 00:00:00';
41
		$mois_courant_j36 = date('Y-m-d H:i:s', mktime(0, 0, 0, $NMonth->thisMonth(), 0, $NMonth->thisYear()));
41
		$mois_courant_j36 = date('Y-m-d H:i:s', mktime(0, 0, 0, $NMonth->thisMonth(), 0, $NMonth->thisYear()));
42
 
42
 
43
    	//+-------------------------------------------------------------------------------------------------+
43
    	//+-------------------------------------------------------------------------------------------------+
44
		// GESTION D'INFO GLOBALES
44
		// GESTION D'INFO GLOBALES
45
		//+-------------------------------------------------------------------------------------------------+
45
		//+-------------------------------------------------------------------------------------------------+
46
		// Initialisation de variables
46
		// Initialisation de variables
47
		$aso_stat['absences'] = false;
47
		$aso_stat['absences'] = false;
48
	    $aso_stat['categories'] = false;
48
	    $aso_stat['categories'] = false;
49
	    		
49
	    		
50
		// Récupération des infos sur les utilisateurs
50
		// Récupération des infos sur les utilisateurs
51
		$DaoUtilsateur = new Utilisateur();
51
		$DaoUtilsateur = new Utilisateur();
52
    	$utilisateurs = $DaoUtilsateur->consulter(Utilisateur::GU_TOUS_AFFICHABLE);
52
    	$utilisateurs = $DaoUtilsateur->consulter(Utilisateur::GU_TOUS_AFFICHABLE);
53
		
53
		
54
    	if (false == $utilisateurs) {
54
    	if (false == $utilisateurs) {
55
    		$aso_stat['messages'][] = "Aucun utilisateur affichable de disponible...";
55
    		$aso_stat['messages'][] = "Aucun utilisateur affichable de disponible...";
56
    	} else {
56
    	} else {
57
			// Initialisation de variables communes à la gestion des projets et des absences
57
			// Initialisation de variables communes à la gestion des projets et des absences
58
			$aso_stat['total_absences_projets'] = 0;
58
			$aso_stat['total_absences_projets'] = 0;
-
 
59
			// Initialisation de variables propre aux absences
-
 
60
			$aso_stat['total_absences'] = 0;
-
 
61
			// Initialisation de variables propre aux absences
-
 
62
			$aso_stat['total_projets'] = 0;
59
 
63
 
60
		    // Récupération des motifs d'absence
64
		    // Récupération des motifs d'absence
61
			$AbsenceMotif = new AbsenceMotif();
65
			$AbsenceMotif = new AbsenceMotif();
62
			$cmd = AbsenceMotif::GAM_TOUS;
66
			$cmd = AbsenceMotif::GAM_TOUS;
63
			$tab_am = $AbsenceMotif->consulter($cmd);
67
			$tab_am = $AbsenceMotif->consulter($cmd);
64
	    	if (false == $tab_am) {
68
	    	if (false == $tab_am) {
65
				$aso_stat['messages'][] = "Aucun motif d'absence de renseigné";
69
				$aso_stat['messages'][] = "Aucun motif d'absence de renseigné";
66
	    	}
70
	    	}
67
	    	
71
	    	
68
	    	// Pour chaque utilisateur nous récupérons les infos
72
	    	// Pour chaque utilisateur nous récupérons les infos
69
			foreach ($utilisateurs as $Utilisateur) {
73
			foreach ($utilisateurs as $Utilisateur) {
70
				// Initialisation du talbeau des infos sur l'utilisateur
74
				// Initialisation du talbeau des infos sur l'utilisateur
71
			 	$aso_gestion = array(	'prenom_nom' => $Utilisateur->getPrenom().' '.$Utilisateur->getNom(),
75
			 	$aso_gestion = array(	'prenom_nom' => $Utilisateur->getPrenom().' '.$Utilisateur->getNom(),
72
			 							'total_w' => 0,
76
			 							'total_w' => 0,
73
			 							'total_a' => 0,
77
			 							'total_a' => 0,
74
		 								'total' => 0);
78
		 								'total' => 0);
75
	
79
	
76
				//+-------------------------------------------------------------------------------------------------+
80
				//+-------------------------------------------------------------------------------------------------+
77
				// GESTION DES PROJETS
81
				// GESTION DES PROJETS
78
				//+-------------------------------------------------------------------------------------------------+
82
				//+-------------------------------------------------------------------------------------------------+
79
				// Initialisation de variables propre aux absences
-
 
80
				$aso_stat['total_projets'] = 0;
-
 
81
	   	
-
 
82
		    	// Récupération du temps de travail pour un utilisateur à une date donnée
83
		    	// Récupération du temps de travail pour un utilisateur à une date donnée
83
		    	$TravailProjet = new TravailProjet();
84
		    	$TravailProjet = new TravailProjet();
84
				$cmd = TravailProjet::GTP_ID_UTILISATEUR_DATE_DEB_FIN;
85
				$cmd = TravailProjet::GTP_ID_UTILISATEUR_DATE_DEB_FIN;
85
				$param = array($Utilisateur->getIdUtilisateur(), $mois_courant_j1, $mois_courant_j36);
86
				$param = array($Utilisateur->getIdUtilisateur(), $mois_courant_j1, $mois_courant_j36);
86
				$tab_tp = $TravailProjet->consulter($cmd, $param);
87
				$tab_tp = $TravailProjet->consulter($cmd, $param);
87
				if (false == $tab_tp) {
88
				if (false == $tab_tp) {
88
	    			$aso_stat['messages'][] = "Aucune information sur le travail de ${aso_gestion['prenom_nom']}";
89
	    			$aso_stat['messages'][] = "Aucune information sur le travail de ${aso_gestion['prenom_nom']}";
89
	    		} else {
90
	    		} else {
90
					// Récupération des identifiants des projets 
91
					// Récupération des identifiants des projets 
91
			    	$tab_projet_id = array('');
92
			    	$tab_projet_id = array('');
92
			    	foreach ($tab_tp as $tp) {
93
			    	foreach ($tab_tp as $tp) {
93
			    		$tab_projet_id[0] .= $tp->getIdProjet().',';
94
			    		$tab_projet_id[0] .= $tp->getIdProjet().',';
94
			    	}
95
			    	}
95
					$tab_projet_id[0] = rtrim($tab_projet_id[0], ',');
96
					$tab_projet_id[0] = rtrim($tab_projet_id[0], ',');
96
			
97
			
97
					// Récupération des infos sur les projets de l'utilisateur
98
					// Récupération des infos sur les projets de l'utilisateur
98
			    	$Projet = new Projet();
99
			    	$Projet = new Projet();
99
			    	$tab_p = $Projet->consulter(Projet::GP_ID_LIST, $tab_projet_id);
100
			    	$tab_p = $Projet->consulter(Projet::GP_ID_LIST, $tab_projet_id);
100
			    	
101
			    	
101
					foreach ($tab_p as $Projet) {
102
					foreach ($tab_p as $Projet) {
102
						// Récupération de la catégorie du projet
103
						// Récupération de la catégorie du projet
103
						$ProjetCategorie = new ProjetCategorie();
104
						$ProjetCategorie = new ProjetCategorie();
104
						$cmd = ProjetCategorie::GPC_ID;
105
						$cmd = ProjetCategorie::GPC_ID;
105
						$param = $Projet->getCeCategorie();
106
						$param = $Projet->getCeCategorie();
106
						$Categorie = current($ProjetCategorie->consulter($cmd, $param));
107
						$Categorie = current($ProjetCategorie->consulter($cmd, $param));
107
			
108
			
108
						// Info trans utilisateur sur les catégories
109
						// Info trans utilisateur sur les catégories
109
						if (!isset($aso_stat['categories'][$Categorie->getIdCategorie()])) {
110
						if (!isset($aso_stat['categories'][$Categorie->getIdCategorie()])) {
110
							$aso_stat['categories'][$Categorie->getIdCategorie()] = array(	'projets' => array(), 
111
							$aso_stat['categories'][$Categorie->getIdCategorie()] = array(	'projets' => array(), 
111
																							'nom' => $Categorie->getLibelle(), 
112
																							'nom' => $Categorie->getLibelle(), 
112
																							'total' => 0);
113
																							'total' => 0);
113
						}
114
						}
114
						$aso_stat['categories'][$Categorie->getIdCategorie()]['projets'][$Projet->getIdProjet()] = 
-
 
115
							array(	'nom' => $Projet->getNom(),
-
 
116
									'desc' => $Projet->getDescription());
-
 
117
						
115
						
118
						foreach ($tab_tp as $TP) {
116
						foreach ($tab_tp as $TP) {
119
							if ($TP->getIdProjet() == $Projet->getIdProjet()) {
117
							if ($TP->getIdProjet() == $Projet->getIdProjet()) {
120
								// Info trans utilisateur sur les catégories
118
								// Info trans utilisateur sur les catégories
121
								if (!isset($aso_stat['categories'][$Categorie->getIdCategorie()]['projets'][$Projet->getIdProjet()]['total'])) {
119
								if (!isset($aso_stat['categories'][$Categorie->getIdCategorie()]['projets'][$Projet->getIdProjet()])) {
122
									$aso_stat['categories'][$Categorie->getIdCategorie()]['projets'][$Projet->getIdProjet()]['total'] = 0;
120
									$aso_stat['categories'][$Categorie->getIdCategorie()]['projets'][$Projet->getIdProjet()] = 
123
								} else {
121
										array(	'nom' => $Projet->getNom(),
124
									$aso_stat['categories'][$Categorie->getIdCategorie()]['projets'][$Projet->getIdProjet()]['total'] += $TP->getDuree();
122
												'desc' => $Projet->getDescription(),
-
 
123
												'total' => 0);
125
								}
124
								}
-
 
125
								$aso_stat['categories'][$Categorie->getIdCategorie()]['projets'][$Projet->getIdProjet()]['total'] += $TP->getDuree();
126
								$aso_stat['categories'][$Categorie->getIdCategorie()]['total'] += $TP->getDuree();
126
								$aso_stat['categories'][$Categorie->getIdCategorie()]['total'] += $TP->getDuree();
127
								// Stockage des infos nécessaire pour l'affichage d'un utilisateur
127
								// Stockage des infos nécessaire pour l'affichage d'un utilisateur
128
								if (!isset($aso_gestion['projets'][$Categorie->getIdCategorie()][$Projet->getIdProjet()])) {
128
								if (!isset($aso_gestion['projets'][$Categorie->getIdCategorie()][$Projet->getIdProjet()])) {
129
									$aso_gestion['projets'][$Categorie->getIdCategorie()][$Projet->getIdProjet()] = array(
129
									$aso_gestion['projets'][$Categorie->getIdCategorie()][$Projet->getIdProjet()] = array(
130
										'id' => $Projet->getIdProjet(),
130
										'id' => $Projet->getIdProjet(),
131
										'nom' => $Projet->getNom(),
131
										'nom' => $Projet->getNom(),
132
										'duree' => 0);
132
										'duree' => 0);
133
								}
133
								}
134
								$aso_gestion['projets'][$Categorie->getIdCategorie()][$Projet->getIdProjet()]['duree'] += $TP->getDuree();
134
								$aso_gestion['projets'][$Categorie->getIdCategorie()][$Projet->getIdProjet()]['duree'] += $TP->getDuree();
-
 
135
								if (!isset($aso_gestion['projets'][$Categorie->getIdCategorie()]['total'])) {
-
 
136
									$aso_gestion['projets'][$Categorie->getIdCategorie()]['total'] = 0;
-
 
137
								}
-
 
138
								$aso_gestion['projets'][$Categorie->getIdCategorie()]['total'] += $TP->getDuree();
135
								$aso_gestion['total_w'] += $TP->getDuree();
139
								$aso_gestion['total_w'] += $TP->getDuree();
136
							}
140
							}
137
						}
141
						}
138
					}
142
					}
139
		    	}
143
		    	}
140
				$aso_gestion['total'] = $aso_gestion['total_w'];
144
				$aso_gestion['total'] = $aso_gestion['total_w'];
141
				$aso_stat['total_projets'] += $aso_gestion['total_w'];
145
				$aso_stat['total_projets'] += $aso_gestion['total_w'];
142
				
146
				
143
				//+-------------------------------------------------------------------------------------------------+
147
				//+-------------------------------------------------------------------------------------------------+
144
				// GESTION DES ABSENCES
148
				// GESTION DES ABSENCES
145
				//+-------------------------------------------------------------------------------------------------+
149
				//+-------------------------------------------------------------------------------------------------+
146
				// Initialisation de variables propre aux absences
-
 
147
				$aso_stat['total_absences'] = 0;
-
 
148
				
-
 
149
				// Récupération des absences pour un utilisateur à une date donnée
150
				// Récupération des absences pour un utilisateur à une date donnée
150
		    	$Absence = new Absence();
151
		    	$Absence = new Absence();
151
				$cmd = Absence::GA_ID_UTILISATEUR_DATE_DEB_FIN;
152
				$cmd = Absence::GA_ID_UTILISATEUR_DATE_DEB_FIN;
152
				$param = array($Utilisateur->getIdUtilisateur(), $mois_courant_j1, $mois_courant_j36);
153
				$param = array($Utilisateur->getIdUtilisateur(), $mois_courant_j1, $mois_courant_j36);
153
				$tab_a = $Absence->consulter($cmd, $param);
154
				$tab_a = $Absence->consulter($cmd, $param);
-
 
155
 
154
				if (false == $tab_a) {
156
				if (false == $tab_a) {
155
					$aso_stat['messages'][] = "Aucune information sur les absences de ${aso_gestion['prenom_nom']}";
157
					$aso_stat['messages'][] = "Aucune information sur les absences de ${aso_gestion['prenom_nom']}";
156
				} else {
158
				} else {
157
					if (false != $tab_am) {
159
					if (false != $tab_am) {
158
						foreach ($tab_am as $AM) {
160
						foreach ($tab_am as $AM) {
-
 
161
							if (!isset($aso_stat['absences'][$AM->getIdAbsenceMotif()])) {
159
							$aso_stat['absences'][$AM->getIdAbsenceMotif()]['nom'] = $AM->getLibelle();
162
								$aso_stat['absences'][$AM->getIdAbsenceMotif()] = 
-
 
163
									array( 	'nom' => $AM->getLibelle(),
-
 
164
											'total' => 0);
-
 
165
							}
160
							
-
 
161
							//$aso_gestion['ab'][$AM->getIdAbsenceMotif()] = 0;
166
							
162
							foreach ($tab_a as $A) {
167
							foreach ($tab_a as $A) {
163
								if ($A->getIdAbsenceMotif() == $AM->getIdAbsenceMotif() && $A->getDuree() != 0) {
-
 
164
									if (!isset($aso_stat['absences'][$AM->getIdAbsenceMotif()]['total'])) {
-
 
165
										$aso_stat['absences'][$AM->getIdAbsenceMotif()]['total'] = 0;
-
 
166
									} else {
168
								if ($A->getIdAbsenceMotif() == $AM->getIdAbsenceMotif() && $A->getDuree() != 0) {
167
										$aso_stat['absences'][$AM->getIdAbsenceMotif()]['total'] += $A->getDuree();
-
 
168
									}
169
									$aso_stat['absences'][$AM->getIdAbsenceMotif()]['total'] += $A->getDuree();
-
 
170
									$aso_stat['total_absences'] += $A->getDuree();
-
 
171
									if (!isset($aso_gestion['ab'][$AM->getIdAbsenceMotif()])) {
-
 
172
										$aso_gestion['ab'][$AM->getIdAbsenceMotif()] = 0;
169
									$aso_stat['total_absences'] += $A->getDuree();
173
									}
170
									$aso_gestion['ab'][$AM->getIdAbsenceMotif()] = $A->getDuree();
174
									$aso_gestion['ab'][$AM->getIdAbsenceMotif()] += $A->getDuree();
171
									$aso_gestion['total_a'] += $A->getDuree();
175
									$aso_gestion['total_a'] += $A->getDuree();
172
									$aso_gestion['total'] += $A->getDuree();
176
									$aso_gestion['total'] += $A->getDuree();
173
								}
177
								}
174
							}
178
							}
175
						}
179
						}
176
					}
180
					}
177
				}
181
				}
178
				$aso_stat['total_absences_projets'] += $aso_gestion['total'];
182
				$aso_stat['total_absences_projets'] += $aso_gestion['total'];
179
				$aso_stat['utilisateurs'][] = $aso_gestion;
183
				$aso_stat['utilisateurs'][] = $aso_gestion;
180
	    	}
184
	    	}
181
    	}
185
    	}
-
 
186
    	
-
 
187
    	// Post-traitement des nombre pour l'affichage
-
 
188
    	$aso_stat = Nombre::formaterNbre($aso_stat, GTT_LANGUE);
-
 
189
		
182
    	
190
		// Sortie
183
		//trigger_error('<pre>'.print_r($aso_stat, true).'</pre>', E_USER_NOTICE);
191
		//trigger_error(print_r($aso_stat, true), E_USER_NOTICE);
184
		$this->getRegistre()->ajouterDonnee('stat_tableau_global', $aso_stat);
192
		$this->getRegistre()->ajouterDonnee('stat_tableau_global', $aso_stat);
185
    }
193
    }
186
}
194
}
187
?>
195
?>