Subversion Repositories Applications.gtt

Rev

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

Rev 110 Rev 116
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
    	$Registre->ajouterSquelette('stat_tableau_global', 'stat_tableau_global.tpl.html');
7
    	$Registre->ajouterSquelette('stat_tableau_global', 'stat_tableau_global.tpl.html');
8
    }
8
    }
9
 
9
 
10
    public function executer()
10
    public function executer()
11
    {
11
    {
12
   		$aso_stat = array();
12
   		$aso_stat = array();
13
    	$this->getRegistre()->setTitre('Tableau récapitulatif');
13
    	$this->getRegistre()->setTitre('Tableau récapitulatif');
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
 
25
 
26
		// Construction de l'objet mois
26
		// Construction de l'objet mois
27
		$Month = new Calendar_Month_Weeks($_GET['annee'], $_GET['mois']);
27
		$Month = new Calendar_Month_Weeks($_GET['annee'], $_GET['mois']);
28
		$Month->build();
28
		$Month->build();
29
 
29
 
30
		// Construction du Calendrier
30
		// Construction du Calendrier
31
		$Calendrier = new Calendrier();
31
		$Calendrier = new Calendrier();
32
		
32
		
33
		// Construction de l'url pour les mois précédent/suivant
33
		// Construction de l'url pour les mois précédent/suivant
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 communes à la gestion des projets et des absences
46
		// Initialisation de variables
47
		$aso_stat['total_absences_projets'] = 0;
47
		$aso_stat['absences'] = false;
-
 
48
	    $aso_stat['categories'] = false;
48
 
49
	    		
49
		// Récupération des infos sur les utilisateurs
50
		// Récupération des infos sur les utilisateurs
50
		$DaoUtilsateur = new Utilisateur();
51
		$DaoUtilsateur = new Utilisateur();
51
    	$utilisateurs = $DaoUtilsateur->consulter(Utilisateur::GU_TOUS_AFFICHABLE);
52
    	$utilisateurs = $DaoUtilsateur->consulter(Utilisateur::GU_TOUS_AFFICHABLE);
52
 
-
 
53
		// Récupération des motifs d'absence
-
 
54
		$AbsenceMotif = new AbsenceMotif();
-
 
55
		$cmd = AbsenceMotif::GAM_TOUS;
-
 
56
		$tab_am = $AbsenceMotif->consulter($cmd);
-
 
57
    	if (false == $tab_am) {
-
 
58
    		$aso_stat['absences'] = false;
-
 
59
			$aso_stat['messages'][] = "Aucun motif d'absence de renseigné";
-
 
60
    		
-
 
61
    	}
-
 
62
    	
-
 
63
    	// Pour chaque utilisateur nous récupérons les infos
-
 
64
		foreach ($utilisateurs as $Utilisateur) {
-
 
65
			// Initialisation du talbeau des infos sur l'utilisateur
-
 
66
		 	$aso_gestion = array(	'prenom_nom' => $Utilisateur->getPrenom().' '.$Utilisateur->getNom(),
-
 
67
		 							'total_w' => 0,
-
 
68
		 							'total_a' => 0,
-
 
69
	 								'total' => 0);
-
 
70
 
-
 
71
			//+-------------------------------------------------------------------------------------------------+
-
 
72
			// GESTION DES PROJETS
-
 
73
			//+-------------------------------------------------------------------------------------------------+
-
 
74
			// Initialisation de variables propre aux absences
-
 
75
			$aso_stat['total_projets'] = 0;
-
 
76
   	
-
 
77
	    	// Récupération du temps de travail pour un utilisateur à une date donnée
-
 
78
	    	$TravailProjet = new TravailProjet();
-
 
79
			$cmd = TravailProjet::GTP_ID_UTILISATEUR_DATE_DEB_FIN;
-
 
80
			$param = array($Utilisateur->getIdUtilisateur(), $mois_courant_j1, $mois_courant_j36);
-
 
81
			$tab_tp = $TravailProjet->consulter($cmd, $param);
-
 
82
			if (false == $tab_tp) {
-
 
83
    			$aso_stat['categories'] = false;
-
 
84
    			$aso_stat['messages'][] = "Aucune information sur le travail de ${aso_gestion['prenom_nom']}";
-
 
85
    		} else {
-
 
86
				// Récupération des identifiants des projets 
-
 
87
		    	$tab_projet_id = array('');
-
 
88
		    	foreach ($tab_tp as $tp) {
-
 
89
		    		$tab_projet_id[0] .= $tp->getIdProjet().',';
-
 
90
		    	}
-
 
91
				$tab_projet_id[0] = rtrim($tab_projet_id[0], ',');
-
 
92
		
-
 
93
				// Récupération des infos sur les projets de l'utilisateur
53
		
94
		    	$Projet = new Projet();
54
    	if (false == $utilisateurs) {
95
		    	$tab_p = $Projet->consulter(Projet::GP_ID_LIST, $tab_projet_id);
-
 
96
		    	
55
    		$aso_stat['messages'][] = "Aucun utilisateur affichable de disponible...";
97
				foreach ($tab_p as $Projet) {
56
    	} else {
98
					// Récupération de la catégorie du projet
57
			// Initialisation de variables communes à la gestion des projets et des absences
99
					$ProjetCategorie = new ProjetCategorie();
-
 
100
					$cmd = ProjetCategorie::GPC_ID;
-
 
101
					$param = $Projet->getCeCategorie();
-
 
102
					$Categorie = current($ProjetCategorie->consulter($cmd, $param));
58
			$aso_stat['total_absences_projets'] = 0;
103
		
59
 
104
					// Info trans utilisateur sur les catégories
-
 
105
					if (!isset($aso_stat['categories'][$Categorie->getIdCategorie()])) {
-
 
106
						$aso_stat['categories'][$Categorie->getIdCategorie()] = array(	'projets' => array(), 
-
 
107
																						'nom' => $Categorie->getLibelle(), 
60
		    // Récupération des motifs d'absence
108
																						'total' => 0);
-
 
109
					}
-
 
110
					$aso_stat['categories'][$Categorie->getIdCategorie()]['projets'][$Projet->getIdProjet()] = 
61
			$AbsenceMotif = new AbsenceMotif();
111
						array(	'nom' => $Projet->getNom(),
62
			$cmd = AbsenceMotif::GAM_TOUS;
112
								'desc' => $Projet->getDescription());
-
 
113
					
63
			$tab_am = $AbsenceMotif->consulter($cmd);
114
					foreach ($tab_tp as $TP) {
-
 
115
						if ($TP->getIdProjet() == $Projet->getIdProjet()) {
-
 
116
							// Info trans utilisateur sur les catégories
-
 
117
							if (!isset($aso_stat['categories'][$Categorie->getIdCategorie()]['projets'][$Projet->getIdProjet()]['total'])) {
-
 
118
								$aso_stat['categories'][$Categorie->getIdCategorie()]['projets'][$Projet->getIdProjet()]['total'] = 0;
-
 
119
							} else {
-
 
120
								$aso_stat['categories'][$Categorie->getIdCategorie()]['projets'][$Projet->getIdProjet()]['total'] += $TP->getDuree();
-
 
121
							}
64
	    	if (false == $tab_am) {
122
							$aso_stat['categories'][$Categorie->getIdCategorie()]['total'] += $TP->getDuree();
-
 
123
							// Stockage des infos nécessaire pour l'affichage d'un utilisateur
-
 
124
							if (!isset($aso_gestion['projets'][$Categorie->getIdCategorie()][$Projet->getIdProjet()])) {
-
 
125
								$aso_gestion['projets'][$Categorie->getIdCategorie()][$Projet->getIdProjet()] = array(
-
 
126
									'id' => $Projet->getIdProjet(),
-
 
127
									'nom' => $Projet->getNom(),
-
 
128
									'duree' => 0);
-
 
129
							}
-
 
130
							$aso_gestion['projets'][$Categorie->getIdCategorie()][$Projet->getIdProjet()]['duree'] += $TP->getDuree();
-
 
131
							$aso_gestion['total_w'] += $TP->getDuree();
-
 
132
						}
-
 
133
					}
-
 
134
				}
65
				$aso_stat['messages'][] = "Aucun motif d'absence de renseigné";
-
 
66
	    	}
-
 
67
	    	
-
 
68
	    	// Pour chaque utilisateur nous récupérons les infos
135
	    	}
69
			foreach ($utilisateurs as $Utilisateur) {
-
 
70
				// Initialisation du talbeau des infos sur l'utilisateur
-
 
71
			 	$aso_gestion = array(	'prenom_nom' => $Utilisateur->getPrenom().' '.$Utilisateur->getNom(),
-
 
72
			 							'total_w' => 0,
-
 
73
			 							'total_a' => 0,
-
 
74
		 								'total' => 0);
-
 
75
	
-
 
76
				//+-------------------------------------------------------------------------------------------------+
-
 
77
				// GESTION DES PROJETS
-
 
78
				//+-------------------------------------------------------------------------------------------------+
136
			$aso_gestion['total'] = $aso_gestion['total_w'];
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
		    	$TravailProjet = new TravailProjet();
-
 
84
				$cmd = TravailProjet::GTP_ID_UTILISATEUR_DATE_DEB_FIN;
-
 
85
				$param = array($Utilisateur->getIdUtilisateur(), $mois_courant_j1, $mois_courant_j36);
-
 
86
				$tab_tp = $TravailProjet->consulter($cmd, $param);
-
 
87
				if (false == $tab_tp) {
-
 
88
	    			$aso_stat['messages'][] = "Aucune information sur le travail de ${aso_gestion['prenom_nom']}";
-
 
89
	    		} else {
-
 
90
					// Récupération des identifiants des projets 
-
 
91
			    	$tab_projet_id = array('');
-
 
92
			    	foreach ($tab_tp as $tp) {
-
 
93
			    		$tab_projet_id[0] .= $tp->getIdProjet().',';
-
 
94
			    	}
137
			$aso_stat['total_projets'] += $aso_gestion['total_w'];
95
					$tab_projet_id[0] = rtrim($tab_projet_id[0], ',');
138
			
96
			
139
			//+-------------------------------------------------------------------------------------------------+
97
					// Récupération des infos sur les projets de l'utilisateur
-
 
98
			    	$Projet = new Projet();
-
 
99
			    	$tab_p = $Projet->consulter(Projet::GP_ID_LIST, $tab_projet_id);
140
			// GESTION DES ABSENCES
100
			    	
-
 
101
					foreach ($tab_p as $Projet) {
141
			//+-------------------------------------------------------------------------------------------------+
102
						// Récupération de la catégorie du projet
-
 
103
						$ProjetCategorie = new ProjetCategorie();
-
 
104
						$cmd = ProjetCategorie::GPC_ID;
142
			// Initialisation de variables propre aux absences
105
						$param = $Projet->getCeCategorie();
143
			$aso_stat['total_absences'] = 0;
-
 
144
			
106
						$Categorie = current($ProjetCategorie->consulter($cmd, $param));
145
			// Récupération des absences pour un utilisateur à une date donnée
107
			
146
	    	$Absence = new Absence();
108
						// Info trans utilisateur sur les catégories
147
			$cmd = Absence::GA_ID_UTILISATEUR_DATE_DEB_FIN;
-
 
148
			$param = array($Utilisateur->getIdUtilisateur(), $mois_courant_j1, $mois_courant_j36);
109
						if (!isset($aso_stat['categories'][$Categorie->getIdCategorie()])) {
149
			$tab_a = $Absence->consulter($cmd, $param);
-
 
150
			if (false == $tab_a) {
110
							$aso_stat['categories'][$Categorie->getIdCategorie()] = array(	'projets' => array(), 
151
				$aso_stat['absences'] = false;
111
																							'nom' => $Categorie->getLibelle(), 
152
				$aso_stat['messages'][] = "Aucune information sur les absences de ${aso_gestion['prenom_nom']}";
112
																							'total' => 0);
153
			} else {
113
						}
154
				if (false != $tab_am) {
-
 
155
					foreach ($tab_am as $AM) {
114
						$aso_stat['categories'][$Categorie->getIdCategorie()]['projets'][$Projet->getIdProjet()] = 
156
						$aso_stat['absences'][$AM->getIdAbsenceMotif()]['nom'] = $AM->getLibelle();
115
							array(	'nom' => $Projet->getNom(),
-
 
116
									'desc' => $Projet->getDescription());
157
						
117
						
158
						//$aso_gestion['ab'][$AM->getIdAbsenceMotif()] = 0;
118
						foreach ($tab_tp as $TP) {
159
						foreach ($tab_a as $A) {
119
							if ($TP->getIdProjet() == $Projet->getIdProjet()) {
-
 
120
								// Info trans utilisateur sur les catégories
-
 
121
								if (!isset($aso_stat['categories'][$Categorie->getIdCategorie()]['projets'][$Projet->getIdProjet()]['total'])) {
-
 
122
									$aso_stat['categories'][$Categorie->getIdCategorie()]['projets'][$Projet->getIdProjet()]['total'] = 0;
-
 
123
								} else {
-
 
124
									$aso_stat['categories'][$Categorie->getIdCategorie()]['projets'][$Projet->getIdProjet()]['total'] += $TP->getDuree();
-
 
125
								}
-
 
126
								$aso_stat['categories'][$Categorie->getIdCategorie()]['total'] += $TP->getDuree();
-
 
127
								// Stockage des infos nécessaire pour l'affichage d'un utilisateur
-
 
128
								if (!isset($aso_gestion['projets'][$Categorie->getIdCategorie()][$Projet->getIdProjet()])) {
-
 
129
									$aso_gestion['projets'][$Categorie->getIdCategorie()][$Projet->getIdProjet()] = array(
-
 
130
										'id' => $Projet->getIdProjet(),
-
 
131
										'nom' => $Projet->getNom(),
-
 
132
										'duree' => 0);
-
 
133
								}
-
 
134
								$aso_gestion['projets'][$Categorie->getIdCategorie()][$Projet->getIdProjet()]['duree'] += $TP->getDuree();
-
 
135
								$aso_gestion['total_w'] += $TP->getDuree();
-
 
136
							}
-
 
137
						}
-
 
138
					}
-
 
139
		    	}
-
 
140
				$aso_gestion['total'] = $aso_gestion['total_w'];
-
 
141
				$aso_stat['total_projets'] += $aso_gestion['total_w'];
-
 
142
				
-
 
143
				//+-------------------------------------------------------------------------------------------------+
-
 
144
				// GESTION DES ABSENCES
-
 
145
				//+-------------------------------------------------------------------------------------------------+
-
 
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
		    	$Absence = new Absence();
-
 
151
				$cmd = Absence::GA_ID_UTILISATEUR_DATE_DEB_FIN;
-
 
152
				$param = array($Utilisateur->getIdUtilisateur(), $mois_courant_j1, $mois_courant_j36);
-
 
153
				$tab_a = $Absence->consulter($cmd, $param);
-
 
154
				if (false == $tab_a) {
-
 
155
					$aso_stat['messages'][] = "Aucune information sur les absences de ${aso_gestion['prenom_nom']}";
-
 
156
				} else {
-
 
157
					if (false != $tab_am) {
-
 
158
						foreach ($tab_am as $AM) {
-
 
159
							$aso_stat['absences'][$AM->getIdAbsenceMotif()]['nom'] = $AM->getLibelle();
-
 
160
							
-
 
161
							//$aso_gestion['ab'][$AM->getIdAbsenceMotif()] = 0;
-
 
162
							foreach ($tab_a as $A) {
160
							if ($A->getIdAbsenceMotif() == $AM->getIdAbsenceMotif() && $A->getDuree() != 0) {
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 {
-
 
167
										$aso_stat['absences'][$AM->getIdAbsenceMotif()]['total'] += $A->getDuree();
-
 
168
									}
161
								if (!isset($aso_stat['absences'][$AM->getIdAbsenceMotif()]['total'])) {
169
									$aso_stat['total_absences'] += $A->getDuree();
162
									$aso_stat['absences'][$AM->getIdAbsenceMotif()]['total'] = 0;
-
 
163
								} else {
-
 
164
									$aso_stat['absences'][$AM->getIdAbsenceMotif()]['total'] += $A->getDuree();
-
 
165
								}
-
 
166
								$aso_stat['total_absences'] += $A->getDuree();
170
									$aso_gestion['ab'][$AM->getIdAbsenceMotif()] = $A->getDuree();
167
								$aso_gestion['ab'][$AM->getIdAbsenceMotif()] = $A->getDuree();
171
									$aso_gestion['total_a'] += $A->getDuree();
168
								$aso_gestion['total_a'] += $A->getDuree();
172
									$aso_gestion['total'] += $A->getDuree();
169
								$aso_gestion['total'] += $A->getDuree();
173
								}
170
							}
174
							}
171
						}
175
						}
172
					}
176
					}
173
				}
177
				}
174
			}
-
 
175
			$aso_stat['total_absences_projets'] += $aso_gestion['total'];
178
				$aso_stat['total_absences_projets'] += $aso_gestion['total'];
176
			$aso_stat['utilisateurs'][] = $aso_gestion;
179
				$aso_stat['utilisateurs'][] = $aso_gestion;
-
 
180
	    	}
177
    	}
181
    	}
178
		
182
    	
179
		//trigger_error('<pre>'.print_r($aso_stat, true).'</pre>', E_USER_NOTICE);
183
		//trigger_error('<pre>'.print_r($aso_stat, true).'</pre>', E_USER_NOTICE);
180
		$this->getRegistre()->ajouterDonnee('stat_tableau_global', $aso_stat);
184
		$this->getRegistre()->ajouterDonnee('stat_tableau_global', $aso_stat);
181
    }
185
    }
182
}
186
}
183
?>
187
?>