Subversion Repositories Applications.gtt

Rev

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

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