New file |
0,0 → 1,199 |
<?php |
class GttCtrlActionStatTableauGlobal extends aControlleurAction { |
|
public function __construct(Registre $Registre) |
{ |
$Registre->ajouterEspace('StatTableauGlobal', 'stat_tableau_global'); |
} |
|
public function executer() |
{ |
$aso_stat = array(); |
$this->getRegistre()->setTitre('Tableau récapitulatif'); |
|
//+-------------------------------------------------------------------------------------------------+ |
// GESTION DES CALENDRIERS |
//+-------------------------------------------------------------------------------------------------+ |
// Initialisation des variables pour le calendrier |
if (!isset($_GET['annee'])) { |
$_GET['annee'] = date('Y'); |
} |
if (!isset($_GET['mois'])) { |
$_GET['mois'] = date('m'); |
} |
|
// Construction de l'objet mois |
$Month = new Calendar_Month_Weeks($_GET['annee'], $_GET['mois']); |
$Month->build(); |
|
// Construction du Calendrier |
$Calendrier = new Calendrier(); |
|
// Construction de l'url pour les mois précédent/suivant |
$aso_stat['url_mois_courant'] = 'index.php?action='.GTT_ACTION_STAT_TAB_GLOB.'&annee='.$Month->thisYear().'&mois='.$Month->thisMonth(); |
$PMonth = $Month->prevMonth('object'); |
$aso_stat['url_mois_precedent'] = 'index.php?action='.GTT_ACTION_STAT_TAB_GLOB.'&annee='.$PMonth->thisYear().'&mois='.$PMonth->thisMonth(); |
$NMonth = $Month->nextMonth('object'); |
$aso_stat['url_mois_suivant'] = 'index.php?action='.GTT_ACTION_STAT_TAB_GLOB.'&annee='.$NMonth->thisYear().'&mois='.$NMonth->thisMonth(); |
$aso_stat['mois']['mois'] = $Calendrier->getNomMois($Month->thisMonth()); |
$aso_stat['mois']['annee'] = $Month->thisYear(); |
$mois_courant_j1 = $Month->thisYear().'-'.sprintf("%02s", $Month->thisMonth()).'-'.sprintf("%02s", $Month->thisDay()).' 00:00:00'; |
$mois_courant_j36 = date('Y-m-d H:i:s', mktime(0, 0, 0, $NMonth->thisMonth(), 0, $NMonth->thisYear())); |
|
//+-------------------------------------------------------------------------------------------------+ |
// GESTION D'INFO GLOBALES |
//+-------------------------------------------------------------------------------------------------+ |
// Initialisation de variables |
$aso_stat['absences'] = false; |
$aso_stat['categories'] = false; |
|
// Récupération des infos sur les utilisateurs |
$DaoUtilsateur = new Utilisateur(); |
$utilisateurs = $DaoUtilsateur->consulter(Utilisateur::GU_TOUS_AFFICHABLE); |
|
if (false == $utilisateurs) { |
$aso_stat['messages'][] = "Aucun utilisateur affichable de disponible..."; |
} else { |
// Initialisation de variables communes à la gestion des projets et des absences |
$aso_stat['total_absences_projets'] = 0; |
// Initialisation de variables propre aux absences |
$aso_stat['total_absences'] = 0; |
// Initialisation de variables propre aux absences |
$aso_stat['total_projets'] = 0; |
|
// Récupération des motifs d'absence |
$AbsenceMotif = new AbsenceMotif(); |
$cmd = AbsenceMotif::GAM_TOUS; |
$tab_am = $AbsenceMotif->consulter($cmd); |
if (false == $tab_am) { |
$aso_stat['messages'][] = "Aucun motif d'absence de renseigné"; |
} |
|
// Pour chaque utilisateur nous récupérons les infos |
foreach ($utilisateurs as $Utilisateur) { |
// Initialisation du talbeau des infos sur l'utilisateur |
$aso_gestion = array( 'prenom_nom' => $Utilisateur->getPrenom().' '.$Utilisateur->getNom(), |
'total_w' => 0, |
'total_a' => 0, |
'total' => 0); |
|
//+-------------------------------------------------------------------------------------------------+ |
// GESTION DES PROJETS |
//+-------------------------------------------------------------------------------------------------+ |
// Récupération du temps de travail pour un utilisateur à une date donnée |
$TravailProjet = new TravailProjet(); |
$cmd = TravailProjet::GTP_ID_UTILISATEUR_DATE_DEB_FIN; |
$param = array($Utilisateur->getIdUtilisateur(), $mois_courant_j1, $mois_courant_j36); |
$tab_tp = $TravailProjet->consulter($cmd, $param); |
if (false == $tab_tp) { |
$aso_stat['messages'][] = "Aucune information sur le travail de ${aso_gestion['prenom_nom']}"; |
} else { |
// Récupération des identifiants des projets |
$tab_projet_id = array(''); |
foreach ($tab_tp as $tp) { |
$tab_projet_id[0] .= $tp->getIdProjet().','; |
} |
$tab_projet_id[0] = rtrim($tab_projet_id[0], ','); |
|
// Récupération des infos sur les projets de l'utilisateur |
$Projet = new Projet(); |
$tab_p = $Projet->consulter(Projet::GP_ID_LIST, $tab_projet_id); |
|
foreach ($tab_p as $Projet) { |
// Récupération de la catégorie du projet |
$ProjetCategorie = new ProjetCategorie(); |
$cmd = ProjetCategorie::GPC_ID; |
$param = $Projet->getCeCategorie(); |
$Categorie = current($ProjetCategorie->consulter($cmd, $param)); |
|
// Info trans utilisateur sur les catégories |
if (!isset($aso_stat['categories'][$Categorie->getIdCategorie()])) { |
$aso_stat['categories'][$Categorie->getIdCategorie()] = array( 'projets' => array(), |
'nom' => $Categorie->getLibelle(), |
'abreviation' => $Categorie->getAbreviation(), |
'total' => 0); |
} |
|
foreach ($tab_tp as $TP) { |
if ($TP->getIdProjet() == $Projet->getIdProjet()) { |
// Info trans utilisateur sur les catégories |
if (!isset($aso_stat['categories'][$Categorie->getIdCategorie()]['projets'][$Projet->getIdProjet()])) { |
$aso_stat['categories'][$Categorie->getIdCategorie()]['projets'][$Projet->getIdProjet()] = |
array( 'nom' => $Projet->getNom(), |
'desc' => $Projet->getDescription(), |
'total' => 0); |
} |
$aso_stat['categories'][$Categorie->getIdCategorie()]['projets'][$Projet->getIdProjet()]['total'] += $TP->getDuree(); |
$aso_stat['categories'][$Categorie->getIdCategorie()]['total'] += $TP->getDuree(); |
// Stockage des infos nécessaire pour l'affichage d'un utilisateur |
if (!isset($aso_gestion['projets'][$Categorie->getIdCategorie()][$Projet->getIdProjet()])) { |
$aso_gestion['projets'][$Categorie->getIdCategorie()][$Projet->getIdProjet()] = array( |
'id' => $Projet->getIdProjet(), |
'nom' => $Projet->getNom(), |
'duree' => 0); |
} |
$aso_gestion['projets'][$Categorie->getIdCategorie()][$Projet->getIdProjet()]['duree'] += $TP->getDuree(); |
if (!isset($aso_gestion['projets'][$Categorie->getIdCategorie()]['total'])) { |
$aso_gestion['projets'][$Categorie->getIdCategorie()]['total'] = 0; |
} |
$aso_gestion['projets'][$Categorie->getIdCategorie()]['total'] += $TP->getDuree(); |
$aso_gestion['total_w'] += $TP->getDuree(); |
} |
} |
} |
} |
$aso_gestion['total'] = $aso_gestion['total_w']; |
$aso_stat['total_projets'] += $aso_gestion['total_w']; |
|
//+-------------------------------------------------------------------------------------------------+ |
// GESTION DES ABSENCES |
//+-------------------------------------------------------------------------------------------------+ |
// Récupération des absences pour un utilisateur à une date donnée |
$Absence = new Absence(); |
$cmd = Absence::GA_ID_UTILISATEUR_DATE_DEB_FIN; |
$param = array($Utilisateur->getIdUtilisateur(), $mois_courant_j1, $mois_courant_j36); |
$tab_a = $Absence->consulter($cmd, $param); |
|
if (false == $tab_a) { |
$aso_stat['messages'][] = "Aucune information sur les absences de ${aso_gestion['prenom_nom']}"; |
} else { |
if (false != $tab_am) { |
foreach ($tab_am as $AM) { |
if (!isset($aso_stat['absences'][$AM->getIdAbsenceMotif()])) { |
$aso_stat['absences'][$AM->getIdAbsenceMotif()] = |
array( 'nom' => $AM->getLibelle(), |
'total' => 0); |
} |
|
foreach ($tab_a as $A) { |
if ($A->getIdAbsenceMotif() == $AM->getIdAbsenceMotif() && $A->getDuree() != 0) { |
$aso_stat['absences'][$AM->getIdAbsenceMotif()]['total'] += $A->getDuree(); |
$aso_stat['total_absences'] += $A->getDuree(); |
if (!isset($aso_gestion['ab'][$AM->getIdAbsenceMotif()])) { |
$aso_gestion['ab'][$AM->getIdAbsenceMotif()] = 0; |
} |
$aso_gestion['ab'][$AM->getIdAbsenceMotif()] += $A->getDuree(); |
$aso_gestion['total_a'] += $A->getDuree(); |
$aso_gestion['total'] += $A->getDuree(); |
} |
} |
} |
} |
} |
$aso_stat['total_absences_projets'] += $aso_gestion['total']; |
$aso_stat['utilisateurs'][] = $aso_gestion; |
} |
} |
|
// Post-traitement des nombre pour l'affichage |
$formatage = array('total_projets', 'total_absences','total_absences_projets', 'utilisateurs', 'categories', 'projets', 'absences'); |
foreach ($formatage as $cle) { |
$aso_stat[$cle] = Nombre::formaterNbre($aso_stat[$cle], GTT_LANGUE); |
} |
|
// Sortie |
//trigger_error(print_r($aso_stat, true), E_USER_NOTICE); |
$this->getRegistre()->ajouterDonnee('stat_tableau_global', $aso_stat); |
} |
} |
?> |