Subversion Repositories Applications.gtt

Rev

Rev 103 | Rev 110 | Go to most recent revision | Show entire file | Ignore whitespace | Details | Blame | Last modification | View Log | RSS feed

Rev 103 Rev 107
Line 41... Line 41...
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()));
Line 42... Line 42...
42
 
42
 
43
    	//+-------------------------------------------------------------------------------------------------+
43
    	//+-------------------------------------------------------------------------------------------------+
44
		// GESTION D'INFO GLOBALES
44
		// GESTION D'INFO GLOBALES
-
 
45
		//+-------------------------------------------------------------------------------------------------+
-
 
46
		// Initialisation de variables communes à la gestion des projets et des absences
-
 
47
		$aso_stat['total_absences_projets'] = 0;
45
		//+-------------------------------------------------------------------------------------------------+
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);
Line 57... Line 60...
57
    		
60
    		
Line 58... Line 61...
58
    	}
61
    	}
59
    	
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(),
60
    	// Pour chaque utilisateur nous récupérons les infos
67
		 							'total_w' => 0,
-
 
68
		 							'total_a' => 0,
61
		foreach ($utilisateurs as $Utilisateur) {
69
	 								'total' => 0);
62
			$aso_gestion = array();
70
 
63
			//+-------------------------------------------------------------------------------------------------+
71
			//+-------------------------------------------------------------------------------------------------+
64
			// GESTION DES PROJETS
72
			// GESTION DES PROJETS
65
			//+-------------------------------------------------------------------------------------------------+
-
 
66
	    	// Récupération des infos sur l'utilisateur
-
 
67
	 		$aso_gestion['prenom_nom'] = $Utilisateur->getPrenom().' '.$Utilisateur->getNom();
73
			//+-------------------------------------------------------------------------------------------------+
68
	 		$aso_gestion['conges_payes'] = $Utilisateur->getCongesPayes();
-
 
69
	 		$aso_gestion['rtt'] = $Utilisateur->getQuotaHeuresSupp();
74
			// Initialisation de variables propre aux absences
70
	 		$aso_gestion['tps_w'] = $Utilisateur->getTempsDeTravailJour();
75
			$aso_stat['total_projets'] = 0;
71
	
76
   	
-
 
77
	    	// Récupération du temps de travail pour un utilisateur à une date donnée
72
	    	// Récupération des projets sur lesquels l'utilisateur travaille
78
	    	$TravailProjet = new TravailProjet();
73
			$UtilsateurAProjet = new UtilisateurAProjet();
-
 
-
 
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();
-
 
84
		    	}
-
 
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
		    		$tab_projet_id[0] .= $tp->getIdProjet().',';
Line 89... Line 90...
89
				$param = array($Utilisateur->getIdUtilisateur(), $mois_courant_j1, $mois_courant_j36);
90
		    	}
90
				$tab_tp = $TravailProjet->consulter($cmd, $param);
-
 
91
		
91
				$tab_projet_id[0] = rtrim($tab_projet_id[0], ',');
92
				// Récupération des infos sur les projets de l'utilisateur
92
		
Line 93... Line 93...
93
		    	$aso_gestion['totaux'] = 0;
93
				// Récupération des infos sur les projets de l'utilisateur
94
		    	$Projet = new Projet();
-
 
95
		    	$tab_p = $Projet->consulter(Projet::GP_ID_LIST, array(implode(',', $tab_projet_id)));
94
		    	$Projet = new Projet();
96
		    	
95
		    	$tab_p = $Projet->consulter(Projet::GP_ID_LIST, $tab_projet_id);
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
Line 100... Line 99...
100
					$ProjetCategorie = new ProjetCategorie();
99
					$ProjetCategorie = new ProjetCategorie();
101
					$cmd = ProjetCategorie::GPC_ID;
-
 
102
					$param = $Projet->getCeCategorie();
100
					$cmd = ProjetCategorie::GPC_ID;
-
 
101
					$param = $Projet->getCeCategorie();
103
					$Categorie = current($ProjetCategorie->consulter($cmd, $param));
102
					$Categorie = current($ProjetCategorie->consulter($cmd, $param));
-
 
103
		
104
		
104
					// Info trans utilisateur sur les catégories
105
					// Nous vérifions le temps de travail pour ce projet pour la semaine courrante
105
					if (!isset($aso_stat['categories'][$Categorie->getIdCategorie()])) {
-
 
106
						$aso_stat['categories'][$Categorie->getIdCategorie()] = array(	'projets' => array(), 
106
					$aso_tps_w = 0;
107
																						'nom' => $Categorie->getLibelle(), 
107
					if (!isset($aso_gestion['categorie_totaux'][$Categorie->getLibelle()])) {
108
																						'total' => 0);
-
 
109
					}
-
 
110
					$aso_stat['categories'][$Categorie->getIdCategorie()]['projets'][$Projet->getIdProjet()]['nom'] = $Projet->getNom();
-
 
111
					
-
 
112
					foreach ($tab_tp as $TP) {
108
						$aso_gestion['categorie_totaux'][$Categorie->getLibelle()] = 0;
113
						if ($TP->getIdProjet() == $Projet->getIdProjet()) {
-
 
114
							// Info trans utilisateur sur les catégories
109
					}
115
							if (!isset($aso_stat['categories'][$Categorie->getIdCategorie()]['projets'][$Projet->getIdProjet()]['total'])) {
110
					if ($tab_tp) {
116
								$aso_stat['categories'][$Categorie->getIdCategorie()]['projets'][$Projet->getIdProjet()]['total'] = 0;
111
						foreach ($tab_tp as $TP) {
117
							} else {
112
							if ($TP->getIdProjet() == $Projet->getIdProjet()) {
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()])) {
-
 
117
									$aso_gestion['projets'][$Categorie->getLibelle()][$Projet->getIdProjet()] = array(
-
 
118
										'id' => $Projet->getIdProjet(),
122
							if (!isset($aso_gestion['projets'][$Categorie->getIdCategorie()][$Projet->getIdProjet()])) {
-
 
123
								$aso_gestion['projets'][$Categorie->getIdCategorie()][$Projet->getIdProjet()] = array(
-
 
124
									'id' => $Projet->getIdProjet(),
119
										'nom' => $Projet->getNom(),
125
									'nom' => $Projet->getNom(),
120
										'duree' => 0);
126
									'duree' => 0);
121
								}
-
 
122
								$aso_gestion['projets'][$Categorie->getLibelle()][$Projet->getIdProjet()]['duree'] += $TP->getDuree();
127
							}
123
							}
128
							$aso_gestion['projets'][$Categorie->getIdCategorie()][$Projet->getIdProjet()]['duree'] += $TP->getDuree();
-
 
129
							$aso_gestion['total_w'] += $TP->getDuree();
-
 
130
						}
124
						}
131
					}
125
					}
132
				}
126
					$aso_stat['projets'][$Categorie->getLibelle()][$Projet->getIdProjet()] = $Projet->getNom();
133
	    	}
127
				}
134
			$aso_gestion['total'] = $aso_gestion['total_w'];
-
 
135
			$aso_stat['total_projets'] += $aso_gestion['total_w'];
-
 
136
			
-
 
137
			//+-------------------------------------------------------------------------------------------------+
128
	    	}
138
			// GESTION DES ABSENCES
129
 
139
			//+-------------------------------------------------------------------------------------------------+
130
			//+-------------------------------------------------------------------------------------------------+
140
			// Initialisation de variables propre aux absences
131
			// GESTION DES ABSENCES
141
			$aso_stat['total_absences'] = 0;
132
			//+-------------------------------------------------------------------------------------------------+
142
			
133
			// Récupération des absences pour un utilisateur à une date donnée
-
 
134
	    	$Absence = new Absence();
143
			// Récupération des absences pour un utilisateur à une date donnée
135
			$cmd = Absence::GA_ID_UTILISATEUR_DATE_DEB_FIN;
144
	    	$Absence = new Absence();
136
			$param = array($Utilisateur->getIdUtilisateur(), $mois_courant_j1, $mois_courant_j36);
145
			$cmd = Absence::GA_ID_UTILISATEUR_DATE_DEB_FIN;
137
			$tab_a = $Absence->consulter($cmd, $param);
146
			$param = array($Utilisateur->getIdUtilisateur(), $mois_courant_j1, $mois_courant_j36);
138
			$aso_gestion['ab_total'] = '';
147
			$tab_a = $Absence->consulter($cmd, $param);
139
			if (false == $tab_a) {
148
			if (false == $tab_a) {
140
				$aso_stat['absences'] = false;
149
				$aso_stat['absences'] = false;
-
 
150
				$aso_stat['messages'][] = "Aucune information sur les absences de ${aso_gestion['prenom_nom']}";
141
				$aso_stat['messages'][] = "Aucune information sur les absences de ${aso_gestion['prenom_nom']}";
151
			} else {
142
			} else {
152
				if (false != $tab_am) {
143
				if (false != $tab_am) {
153
					foreach ($tab_am as $AM) {
-
 
154
						$aso_stat['absences'][$AM->getIdAbsenceMotif()]['nom'] = $AM->getLibelle();
-
 
155
						
-
 
156
						//$aso_gestion['ab'][$AM->getIdAbsenceMotif()] = 0;
-
 
157
						foreach ($tab_a as $A) {
-
 
158
							if ($A->getIdAbsenceMotif() == $AM->getIdAbsenceMotif() && $A->getDuree() != 0) {
-
 
159
								if (!isset($aso_stat['absences'][$AM->getIdAbsenceMotif()]['total'])) {
144
					foreach ($tab_am as $AM) {
160
									$aso_stat['absences'][$AM->getIdAbsenceMotif()]['total'] = 0;
145
						$aso_stat['absences'][$AM->getIdAbsenceMotif()] = $AM->getLibelle();
161
								} else {
146
						//$aso_gestion['ab'][$AM->getIdAbsenceMotif()] = 0;
162
									$aso_stat['absences'][$AM->getIdAbsenceMotif()]['total'] += $A->getDuree();
147
						foreach ($tab_a as $A) {
163
								}
148
							if ($A->getIdAbsenceMotif() == $AM->getIdAbsenceMotif() && $A->getDuree() != 0) {
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();
-
 
168
							}
152
							}
169
						}
153
						}
170
					}
Line 154... Line 171...
154
					}
171
				}
155
				}
172
			}