Subversion Repositories Applications.gtt

Compare Revisions

Ignore whitespace Rev 15 → Rev 16

/trunk/actions/GttCtrlActionGestion.class.php
9,6 → 9,8
 
require_once GTT_CHEMIN_METIER.'Projet.class.php';
require_once GTT_CHEMIN_METIER.'TravailProjet.class.php';
require_once GTT_CHEMIN_METIER.'Absence.class.php';
require_once GTT_CHEMIN_METIER.'AbsenceMotif.class.php';
require_once GTT_CHEMIN_METIER.'ProjetCategorie.class.php';
require_once GTT_CHEMIN_METIER.'Utilisateur.class.php';
require_once GTT_CHEMIN_METIER.'UtilisateurAProjet.class.php';
24,7 → 26,7
$GttCtrlActionIdentification->setSuivant('__defaut__');
$this->setSuivant($GttCtrlActionIdentification);
}
 
public function executer()
{
$aso_gestion = array();
54,12 → 56,12
// Used for Week::build() below
$CalendrierJourCourrant = new Calendar_Week(date('Y'), date('m'), date('d'));
$aso_gestion['jc']['jour'] = $CalendrierJourCourrant->thisDay();
$aso_gestion['jc']['semaine'] = $CalendrierJourCourrant->thisWeek('n_in_year');
$aso_gestion['jc']['semaine'] = $CalendrierJourCourrant->thisWeek('n_in_year');
$aso_gestion['jc']['mois'] = $CalendrierJourCourrant->thisMonth();
$aso_gestion['jc']['mois_nom'] = $Calendrier->getNomMois($CalendrierJourCourrant->thisMonth());
$aso_gestion['jc']['annee'] = $CalendrierJourCourrant->thisYear();
$aso_gestion['jc_url'] = 'index.php?action='.GTT_ACTION_GESTION.'&annee='.$aso_gestion['jc']['annee'].'&mois='.$aso_gestion['jc']['mois'].'&semaine='.$aso_gestion['jc']['semaine'].'&jour='.$aso_gestion['jc']['jour'];
 
$CalendrierJourCourrant->build();
$CalendrierSemaineCourrante = $CalendrierJourCourrant->thisWeek('object');
$CalendrierSemaineCourrante->build();
70,14 → 72,14
$aso_gestion['sjc_7']['jour'] = $tab_jours[7]->thisDay();
$aso_gestion['sjc_7']['mois'] = $Calendrier->getNomMois($tab_jours[7]->thisMonth());
$aso_gestion['sjc_7']['annee'] = $tab_jours[7]->thisYear();
 
$aso_gestion['selectedDays'] = array ($CalendrierJourCourrant);
 
// Instruct month to build Week objects
// Construction de l'objet mois
$Month = new Calendar_Month_Weeks($_GET['annee'], $_GET['mois']);
$Month->build();
 
while ($Week = $Month->fetch()) {
$Week->build($aso_gestion['selectedDays']);
//echo '<pre>'.print_r($Month, true).'</pre>';
105,7 → 107,7
$aso_gestion['elements'][$Week->thisWeek('n_in_year')][$num] = $element;
}
}
 
// Construction de l'url pour les mois précédent/suivant
$PMonth = $Month->prevMonth('object');
$aso_gestion['url_mois_precedent'] = 'index.php?action='.GTT_ACTION_GESTION.'&amp;annee='.$PMonth->thisYear().'&amp;mois='.$PMonth->thisMonth().'&amp;jour='.$PMonth->thisDay();
113,20 → 115,20
$aso_gestion['url_mois_suivant'] = 'index.php?action='.GTT_ACTION_GESTION.'&amp;annee='.$NMonth->thisYear().'&amp;mois='.$NMonth->thisMonth().'&amp;jour='.$NMonth->thisDay();
$aso_gestion['mois']['mois'] = $Calendrier->getNomMois($Month->thisMonth());
$aso_gestion['mois']['annee'] = $Month->thisYear();
 
// Construction de l'url pour les semaines précédente/suivante
$Week = new Calendar_Week($_GET['annee'], $_GET['mois'], $_GET['jour']);
$aso_gestion['s'] = $Week->thisWeek('n_in_year');
 
$PWeek = $Week->prevWeek('object');
$aso_gestion['url_semaine_precedente'] = 'index.php?action='.GTT_ACTION_GESTION.'&amp;annee='.$PWeek->thisYear().'&amp;mois='.$PWeek->thisMonth().'&amp;jour='.$PWeek->thisDay();
 
$url_sc_param_date = '&amp;annee='.$Week->thisYear().'&amp;mois='.$Week->thisMonth().'&amp;jour='.$Week->thisDay();
$aso_gestion['url_semaine_courante'] = 'index.php?action='.GTT_ACTION_GESTION.$url_sc_param_date;
 
$NWeek = $Week->nextWeek('object');
$aso_gestion['url_semaine_suivante'] = 'index.php?action='.GTT_ACTION_GESTION.'&amp;annee='.$NWeek->thisYear().'&amp;mois='.$NWeek->thisMonth().'&amp;jour='.$NWeek->thisDay();
 
$Week->build();
$aso_jours = array();
foreach($Week->fetchAll() as $num => $j) {
137,7 → 139,7
$aso_jours[$aso_gestion['sj_'.$num]['mysql']] = $num;
$aso_tps_w_vide[$num] = '';
}
 
//+-------------------------------------------------------------------------------------------------+
// GESTION DES PROJETS
//+-------------------------------------------------------------------------------------------------+
145,7 → 147,7
$aso_gestion['conges_payes'] = $GLOBALS['_GTT_']['Utilisateur']->getCongesPayes();
$aso_gestion['rtt'] = $GLOBALS['_GTT_']['Utilisateur']->getQuotaHeuresSupp();
$aso_gestion['tps_w'] = $GLOBALS['_GTT_']['Utilisateur']->getTempsDeTravail();
 
// Récupération des projets sur lesquels l'utilisateur travaille
$UtilsateurAProjet = new UtilisateurAProjet();
$tab_uap = $UtilsateurAProjet->consulter(UtilisateurAProjet::GUAP_UTILISATEUR, $GLOBALS['_GTT_']['Utilisateur']->getIdUtilisateur());
163,7 → 165,8
$tab_tp = array($tab_tp);
}
 
// Récupération des infos sur les projets de l'utilisateur
// Récupération des infos sur les projets de l'utilisateur
$aso_gestion['totaux'] = $aso_tps_w_vide;
$Projet = new Projet();
$tab_p = $Projet->consulter(Projet::GP_ID_LIST, array(implode(',', $tab_projet_id)));
foreach ($tab_p as $Projet) {
173,36 → 176,124
$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 = $aso_tps_w_vide;
if (!isset($aso_gestion['categorie_totaux'][$Categorie->getLibelle()])) {
$aso_gestion['categorie_totaux'][$Categorie->getLibelle()] = $aso_tps_w_vide;
}
if ($tab_tp) {
foreach ($tab_tp as $TP) {
if ($TP->getIdProjet() == $Projet->getIdProjet()) {
$aso_tps_w[$aso_jours[$TP->getIdDateTravail()]] = $TP->getDuree();
$num = $aso_jours[$TP->getIdDateTravail()];
$aso_tps_w[$num] = $TP->getDuree();
$aso_gestion['categorie_totaux'][$Categorie->getLibelle()][$num] += $TP->getDuree();
$aso_gestion['totaux'][$num] += $TP->getDuree();
}
}
}
 
// Stockage des infos nécessaire pour l'affichage
$aso_gestion['preferences'][$Categorie->getLibelle()][] = array(
'id' => $Projet->getIdProjet(),
'valeur' => $Projet->getIdProjet(),
'id' => $Projet->getIdProjet(),
'valeur' => $Projet->getIdProjet(),
'nom' => $Projet->getNomProjet(),
'date' => $aso_tps_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($GLOBALS['_GTT_']['Utilisateur']->getIdUtilisateur(), $aso_gestion['sj_1']['mysql'], $aso_gestion['sj_7']['mysql']);
$tab_a = $Absence->consulter($cmd, $param);
if ($tab_a && count($tab_a) == 1) {
$tab_a = array($tab_a);
}
$aso_gestion['cp'] = $aso_tps_w_vide;
$aso_gestion['rtt'] = $aso_tps_w_vide;
if ($tab_a) {
foreach ($tab_a as $A) {
$num = $aso_jours[$A->getIdDateAbsence()];
switch ($A->getIdAbsenceMotif()) {
case GTT_ABSCENCE_ID_CP :
$aso_gestion['cp'][$num] = $A->getDuree();
break;
case GTT_ABSCENCE_ID_RTT :
$aso_gestion['rtt'][$num] = $A->getDuree();
break;
}
}
}
 
// Création de l'url de réponse du formulaire
$aso_gestion['url_gestion_valider'] = 'index.php?action='.GTT_ACTION_GESTION_VALIDER.$url_sc_param_date;
 
//echo '<pre>'.print_r($aso_gestion, true).'</pre>';
$this->getRegistre()->ajouterDonnee('gestion', $aso_gestion);
}
 
public function verifierValider()
{
 
}
 
public function executerValider()
{
//echo '<pre>'.print_r($_POST, true).'</pre>';
 
// Récupération des info sur la semaine courrante
$Week = new Calendar_Week($_GET['annee'], $_GET['mois'], $_GET['jour']);
$Week->build();
$aso_jours = array();
$aso_semaine = array();
foreach($Week->fetchAll() as $num => $j) {
$aso_semaine[$num]['mysql'] = $j->thisYear().'-'.sprintf("%02s", $j->thisMonth()).'-'.$j->thisDay();
$aso_jours[$aso_semaine[$num]['mysql']] = $num;
}
 
// 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($GLOBALS['_GTT_']['Utilisateur']->getIdUtilisateur(), $aso_semaine[1]['mysql'], $aso_semaine[7]['mysql']);
$tab_tp = $TravailProjet->consulter($cmd, $param);
if ($tab_tp && count($tab_tp) == 1) {
$tab_tp = array($tab_tp);
}
 
foreach($_POST['pr'] as $projet_id => $jours) {
//echo '<pre>'.print_r($jours, true).'</pre>';
foreach($jours as $jour_num => $nbr_heure) {
$bool_ajouter = true;
foreach ($tab_tp as $TP) {
if ($TP->getIdDateTravail() == $aso_semaine[$jour_num]['mysql']) {
if ($TP->getIdProjet() == $projet_id) {
$bool_ajouter = false;
if ($TP->getDuree() != $nbr_heure && $TP->getIdProjet() == $projet_id) {
if (empty($nbr_heure)) {
$TP->supprimer();
} else {
$TP->setDuree($nbr_heure);
$TP->modifier();
}
}
}
}
}
if ($bool_ajouter && !empty($nbr_heure)) {
$TP = new TravailProjet();
$TP->setDuree((float)$nbr_heure);
$TP->setIdUtilisateur($GLOBALS['_GTT_']['Utilisateur']->getIdUtilisateur());
$TP->setIdProjet($projet_id);
$TP->setIdDateTravail((string)$aso_semaine[$jour_num]['mysql']);
$TP->ajouter();
}
}
}
 
// Action suivante
$this->setSuivant('__defaut__');
}