Subversion Repositories Applications.gtt

Rev

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

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