Subversion Repositories Applications.gtt

Rev

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

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