Subversion Repositories Applications.gtt

Compare Revisions

Ignore whitespace Rev 89 → Rev 90

/trunk/actions/GttCtrlActionAdminUtilisateur.class.php
189,7 → 189,13
$Utilisateur->setTempsDeTravailJour($_POST['ut_temps_de_travail_jour']);
$Utilisateur->setTempsDeTravailMois($_POST['ut_temps_de_travail_mois']);
$Utilisateur->setQuotaHeuresSupp($_POST['ut_quota_heures_supp']);
if (!isset($_POST['ut_mark_admin'])) {
$_POST['ut_mark_admin'] = 0;
}
$Utilisateur->setMarkAdmin($_POST['ut_mark_admin']);
if (!isset($_POST['ut_mark_recapitulatif'])) {
$_POST['ut_mark_recapitulatif'] = 0;
}
$Utilisateur->setMarkRecapitulatif($_POST['ut_mark_recapitulatif']);
$Utilisateur->ajouter();
// Action suivante
/trunk/actions/GttCtrlActionStatTableauCharge.class.php
New file
0,0 → 1,220
<?php
class GttCtrlActionStatTableauCharge extends aControlleurAction {
 
public function __construct(Registre $Registre)
{
$Registre->ajouterEspace('StatTableauCharge', 'stat_tableau_charge');
$Registre->ajouterSquelette('stat_tableau_charge', 'stat_tableau_charge.tpl.html');
}
 
public function executer()
{
$aso_stat = array();
$this->getRegistre()->setTitre('Plan de charge');
 
//+-------------------------------------------------------------------------------------------------+
// GESTION DES PARAMÊTRE de l'URL
//+-------------------------------------------------------------------------------------------------+
// Initialisation des variables
if (!isset($_GET['annee'])) {
$_GET['annee'] = date('Y');
}
if (!isset($_GET['mois'])) {
$_GET['mois'] = date('m');
}
if (!isset($_GET['uid'])) {// ID de l'utilisateur à afficher
$_GET['uid'] = null;
}
//+-------------------------------------------------------------------------------------------------+
// GESTION DES UTILISATEURS
//+-------------------------------------------------------------------------------------------------+
$DaoUtilsateur = new Utilisateur();
$utilisateurs = $DaoUtilsateur->consulter(Utilisateur::GU_TOUS_AFFICHABLE);
if (is_object($utilisateurs)) {
$utilisateurs[0] = $utilisateurs;
}
$UtilisateurCourant = null;
foreach ($utilisateurs as $Utilisateur) {
// Récupération des infos sur l'utilisateur
$aso_stat['utilisateurs'][$Utilisateur->getIdUtilisateur()]['courant'] = false;
$aso_stat['utilisateurs'][$Utilisateur->getIdUtilisateur()]['nom'] = $Utilisateur->getPrenom().' '.$Utilisateur->getNom();
if ( (!is_null($_GET['uid']) && $Utilisateur->getIdUtilisateur() == $_GET['uid'])
|| (is_null($_GET['uid']) && $Utilisateur->getIdUtilisateur() == $GLOBALS['_GTT_']['Utilisateur']->getIdUtilisateur()) ) {
$UtilisateurCourant = clone $Utilisateur;
$aso_stat['utilisateurs'][$Utilisateur->getIdUtilisateur()]['courant'] = true;
$aso_stat['utilisateur_courant'] = $Utilisateur->getPrenom().' '.$Utilisateur->getNom();
$_GET['uid'] = $Utilisateur->getIdUtilisateur();
}
}
$aso_stat['etre_admin'] = $GLOBALS['_GTT_']['Utilisateur']->getMarkAdmin();
$Utilisateur = $UtilisateurCourant;
//+-------------------------------------------------------------------------------------------------+
// GESTION DES CALENDRIERS
//+-------------------------------------------------------------------------------------------------+
// Construction du Calendrier
$Calendrier = new Calendrier();
$tab_jours_feries = $Calendrier->getListeFeries();
// Construction de l'objet mois
$Month = new Calendar_Month_Weeks($_GET['annee'], $_GET['mois']);
$Month->build();
// Récupération des jours du mois
while ($Week = $Month->fetch()) {
$Week->build();
//echo '<pre>'.print_r($Month, true).'</pre>';
$tab_semaine_jours = $Week->fetchAll();
foreach ($tab_semaine_jours as $num => $Day) {
// Nous prenons en compte uniquement les jours du mois courant
if ($Day->thisMonth() == $_GET['mois']) {
$element = array();
$element['jour'] = $Day->thisDay();
$element['jour_nom'] = $Calendrier->getNomJours($num);
$element['class'] = 'jour';
// Nous vérifions le type de jour
// Jour courrant
if ($Day->isSelected()) {
$element['class'] .= ' jour_courrant';
}
// Jour n'appartenant pas au moins courrant
if ($Day->isEmpty()) {
$element['class'] .= ' jour_vide';
}
// Jour férié
foreach ($tab_jours_feries as $jour_ferie) {
if ($Day->thisDay(true) == $jour_ferie) {
$element['class'] .= ' jour_ferie';
}
}
// Jour de week-end
if ($element['jour_nom'] == GESTION_DIM_L || $element['jour_nom'] == GESTION_SAM_L) {
$element['class'] .= ' jour_we';
}
$id = date('Y-m-d', mktime(0, 0, 0, $Day->thisMonth(), $Day->thisDay(), $Day->thisYear()));
$aso_stat['elements'][$id] = $element;
}
}
}
// Construction de l'url pour les mois précédent/suivant/courant et paramêtres pour le formulaire utilisateur
$aso_stat['form_url'] = 'index.php';
$aso_stat['form_param']['action'] = GTT_ACTION_STAT_TAB_CHARGE;
$aso_stat['form_param']['annee'] = $Month->thisYear();
$aso_stat['form_param']['mois'] = $Month->thisMonth();
$PMonth = $Month->prevMonth('object');
$aso_stat['url_mois_precedent'] = 'index.php?action='.GTT_ACTION_STAT_TAB_CHARGE.'&amp;annee='.$PMonth->thisYear().'&amp;mois='.$PMonth->thisMonth().'&amp;uid='.$_GET['uid'];
$NMonth = $Month->nextMonth('object');
$aso_stat['url_mois_suivant'] = 'index.php?action='.GTT_ACTION_STAT_TAB_CHARGE.'&amp;annee='.$NMonth->thisYear().'&amp;mois='.$NMonth->thisMonth().'&amp;uid='.$_GET['uid'];
$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 DES PROJETS
//+-------------------------------------------------------------------------------------------------+
// Récupération du temps de travail pour un utilisateur pour le mois donné
$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);
}
if ($tab_tp != false) {
$tab_projet_id = array();
foreach ($tab_tp as $utp) {
$tab_projet_id[] = $utp->getIdProjet();
}
// Nous vérifions qu'il y a des données pour l'utilisateur courant pour le mois donné
// Récupération des infos sur les projets de l'utilisateur
$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
$aso_tps_w = 0;
if ($tab_tp) {
foreach ($tab_tp as $TP) {
$j = date('Y-m-d', strtotime($TP->getIdDateTravail()));
if ($TP->getIdProjet() == $Projet->getIdProjet()) {
// Récupération des infos sur les catégories
if (!isset($aso_stat['categorie_totaux'][$Categorie->getLibelle()][$j])) {
$aso_stat['categorie_totaux'][$Categorie->getLibelle()][$j] = 0;
}
$aso_stat['categorie_totaux'][$Categorie->getLibelle()][$j] += $TP->getDuree();
// Récupération des infos sur les projets
if (!isset($aso_stat['projets'][$Categorie->getLibelle()][$Projet->getIdProjet()])) {
$aso_stat['projets'][$Categorie->getLibelle()][$Projet->getIdProjet()] = array(
'id' => $Projet->getIdProjet(),
'nom' => $Projet->getNom(),
'duree' => array());
}
$aso_stat['projets'][$Categorie->getLibelle()][$Projet->getIdProjet()]['duree'][$j] = $TP->getDuree();
}
}
}
}
} else {
$aso_stat['messages'][] = 'Aucune information sur le travail en '.$aso_stat['mois']['mois'].' '.$aso_stat['mois']['annee'];
}
//+-------------------------------------------------------------------------------------------------+
// 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);
}
if ($tab_a != false) {
$aso_stat['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) {
$j = date('Y-m-d', strtotime($A->getIdDateAbsence()));
// Récupération des infos sur les absences
$aso_stat['ab'][$AM->getIdAbsenceMotif()][$j] = $A->getDuree();
// Récupération du total des absences
if (!isset($aso_stat['ab_total'][$j])) {
$aso_stat['ab_total'][$j] = 0;
}
$aso_stat['ab_total'][$j] += $A->getDuree();
}
}
}
}
}
} else {
$aso_stat['messages'][] = 'Aucune absence de mentionnée en '.$aso_stat['mois']['mois'].' '.$aso_stat['mois']['annee'];
}
trigger_error('<pre>'.print_r($aso_stat, true).'</pre>', E_USER_NOTICE);
$this->getRegistre()->ajouterDonnee('stat_tableau_charge', $aso_stat);
}
}
?>