Rev 82 | Rev 101 | Go to most recent revision | Blame | Compare with Previous | Last modification | View Log | RSS feed
<?phpclass GttCtrlActionStatTableauGlobal extends aControlleurAction {public function __construct(Registre $Registre){$Registre->ajouterEspace('StatTableauGlobal', 'stat_tableau_global');$Registre->ajouterSquelette('stat_tableau_global', 'stat_tableau_global.tpl.html');}public function executer(){$aso_stat = array();$this->getRegistre()->setTitre('Tableau récapitulatif');//+-------------------------------------------------------------------------------------------------+// GESTION DES CALENDRIERS//+-------------------------------------------------------------------------------------------------+// Initialisation des variables pour le calendrierif (!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$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()));$DaoUtilsateur = new Utilisateur();$utilisateurs = $DaoUtilsateur->consulter(Utilisateur::GU_TOUS_AFFICHABLE);if (is_object($utilisateurs)) {$utilisateurs[0] = $utilisateurs;}foreach ($utilisateurs as $Utilisateur) {$aso_gestion = array();//+-------------------------------------------------------------------------------------------------+// GESTION DES PROJETS//+-------------------------------------------------------------------------------------------------+// Récupération des infos sur l'utilisateur$aso_gestion['prenom_nom'] = $Utilisateur->getPrenom().' '.$Utilisateur->getNom();$aso_gestion['conges_payes'] = $Utilisateur->getCongesPayes();$aso_gestion['rtt'] = $Utilisateur->getQuotaHeuresSupp();$aso_gestion['tps_w'] = $Utilisateur->getTempsDeTravailJour();// Récupération des projets sur lesquels l'utilisateur travaille$UtilsateurAProjet = new UtilisateurAProjet();$tab_uap = $UtilsateurAProjet->consulter(UtilisateurAProjet::GUAP_UTILISATEUR, $Utilisateur->getIdUtilisateur());if (is_array($tab_uap) && count($tab_uap) > 0) {//echo '<pre>la'.print_r($tab_uap, true).'</pre>';$tab_projet_id = array();foreach ($tab_uap as $uap) {$tab_projet_id[] = $uap->getIdProjet();}// 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 ($tab_tp && count($tab_tp) == 1) {$tab_tp = array($tab_tp);}// Récupération des infos sur les projets de l'utilisateur$aso_gestion['totaux'] = 0;$Projet = new Projet();$tab_p = $Projet->consulter(Projet::GP_ID_LIST, array(implode(',', $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 = $ProjetCategorie->consulter($cmd, $param);// Nous vérifions le temps de travail pour ce projet pour la semaine courrante$aso_tps_w = 0;if (!isset($aso_gestion['categorie_totaux'][$Categorie->getLibelle()])) {$aso_gestion['categorie_totaux'][$Categorie->getLibelle()] = 0;}if ($tab_tp) {foreach ($tab_tp as $TP) {if ($TP->getIdProjet() == $Projet->getIdProjet()) {$aso_gestion['categorie_totaux'][$Categorie->getLibelle()] += $TP->getDuree();$aso_gestion['totaux'] += $TP->getDuree();// Stockage des infos nécessaire pour l'affichageif (!isset($aso_gestion['projets'][$Categorie->getLibelle()][$Projet->getIdProjet()])) {$aso_gestion['projets'][$Categorie->getLibelle()][$Projet->getIdProjet()] = array('id' => $Projet->getIdProjet(),'nom' => $Projet->getNom(),'duree' => 0);}$aso_gestion['projets'][$Categorie->getLibelle()][$Projet->getIdProjet()]['duree'] += $TP->getDuree();}}}$aso_stat['projets'][$Categorie->getLibelle()][$Projet->getIdProjet()] = $Projet->getNom();}}//+-------------------------------------------------------------------------------------------------+// GESTION DES ABSENCES//+-------------------------------------------------------------------------------------------------+// Récupération des motifs d'absence$AbsenceMotif = new AbsenceMotif();$cmd = AbsenceMotif::GAM_TOUS;$tab_am = $AbsenceMotif->consulter($cmd);if ($tab_am && count($tab_am) == 1) {$tab_am = array($tab_am);}// 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 ($tab_a && count($tab_a) == 1) {$tab_a = array($tab_a);}$aso_gestion['ab_total'] = '';if ($tab_am) {foreach ($tab_am as $AM) {$aso_stat['absences'][$AM->getIdAbsenceMotif()] = $AM->getLibelle();//$aso_gestion['ab'][$AM->getIdAbsenceMotif()] = 0;if ($tab_a) {foreach ($tab_a as $A) {if ($A->getIdAbsenceMotif() == $AM->getIdAbsenceMotif() && $A->getDuree() != 0) {$aso_gestion['ab'][$AM->getIdAbsenceMotif()] = $A->getDuree();$aso_gestion['ab_total'] += $A->getDuree();$aso_gestion['totaux'] += $A->getDuree();}}}}}$aso_stat['utilisateurs'][] = $aso_gestion;}//trigger_error('<pre>'.print_r($aso_stat, true).'</pre>', E_USER_NOTICE);$this->getRegistre()->ajouterDonnee('stat_tableau_global', $aso_stat);}}?>