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