Subversion Repositories Applications.gtt

Rev

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

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