1 |
<?php
|
1 |
<?php
|
2 |
require_once GTT_CHEMIN_CLASSE.'Calendrier.class.php';
|
2 |
require_once GTT_CHEMIN_CLASSE.'Calendrier.class.php';
|
3 |
|
3 |
|
4 |
require_once GTT_CHEMIN_ACTION.'GttCtrlActionIdentification.class.php';
|
4 |
require_once GTT_CHEMIN_ACTION.'GttCtrlActionIdentification.class.php';
|
5 |
|
5 |
|
6 |
require_once GTT_CHEMIN_PEAR.'Calendar/Month/Weeks.php';
|
6 |
require_once GTT_CHEMIN_PEAR.'Calendar/Month/Weeks.php';
|
7 |
require_once GTT_CHEMIN_PEAR.'Calendar/Week.php';
|
7 |
require_once GTT_CHEMIN_PEAR.'Calendar/Week.php';
|
8 |
require_once GTT_CHEMIN_PEAR.'Calendar/Day.php';
|
8 |
require_once GTT_CHEMIN_PEAR.'Calendar/Day.php';
|
9 |
|
9 |
|
10 |
require_once GTT_CHEMIN_METIER.'Projet.class.php';
|
10 |
require_once GTT_CHEMIN_METIER.'Projet.class.php';
|
11 |
require_once GTT_CHEMIN_METIER.'TravailProjet.class.php';
|
11 |
require_once GTT_CHEMIN_METIER.'TravailProjet.class.php';
|
12 |
require_once GTT_CHEMIN_METIER.'Absence.class.php';
|
12 |
require_once GTT_CHEMIN_METIER.'Absence.class.php';
|
13 |
require_once GTT_CHEMIN_METIER.'AbsenceMotif.class.php';
|
13 |
require_once GTT_CHEMIN_METIER.'AbsenceMotif.class.php';
|
14 |
require_once GTT_CHEMIN_METIER.'ProjetCategorie.class.php';
|
14 |
require_once GTT_CHEMIN_METIER.'ProjetCategorie.class.php';
|
15 |
require_once GTT_CHEMIN_METIER.'Utilisateur.class.php';
|
15 |
require_once GTT_CHEMIN_METIER.'Utilisateur.class.php';
|
16 |
require_once GTT_CHEMIN_METIER.'UtilisateurAProjet.class.php';
|
16 |
require_once GTT_CHEMIN_METIER.'UtilisateurAProjet.class.php';
|
17 |
|
17 |
|
18 |
class GttCtrlActionGestion extends aControlleurAction {
|
18 |
class GttCtrlActionGestion extends aControlleurAction {
|
19 |
|
19 |
|
20 |
public function __construct(Registre $Registre)
|
20 |
public function __construct(Registre $Registre)
|
21 |
{
|
21 |
{
|
22 |
$Registre->ajouterEspace('Gestion', 'gestion');
|
22 |
$Registre->ajouterEspace('Gestion', 'gestion');
|
23 |
$Registre->ajouterSquelette('gestion', 'gestion.tpl.html');
|
23 |
$Registre->ajouterSquelette('gestion', 'gestion.tpl.html');
|
24 |
// TODO : gérer les actions chainées provenant d'un autre ControlleurAction
|
- |
|
25 |
$GttCtrlActionIdentification = new GttCtrlActionIdentification($this->getRegistre());
|
- |
|
26 |
$GttCtrlActionIdentification->setSuivant('__defaut__');
|
- |
|
27 |
$this->setSuivant($GttCtrlActionIdentification);
|
- |
|
28 |
}
|
24 |
}
|
29 |
|
25 |
|
30 |
public function executer()
|
26 |
public function executer()
|
31 |
{
|
27 |
{
|
32 |
$aso_gestion = array();
|
28 |
$aso_gestion = array();
|
33 |
$this->getRegistre()->setTitre('Gérer son temps');
|
29 |
$this->getRegistre()->setTitre('Gérer son temps');
|
34 |
|
30 |
|
35 |
//+-------------------------------------------------------------------------------------------------+
|
31 |
//+-------------------------------------------------------------------------------------------------+
|
36 |
// GESTION DES CALENDRIERS
|
32 |
// GESTION DES CALENDRIERS
|
37 |
//+-------------------------------------------------------------------------------------------------+
|
33 |
//+-------------------------------------------------------------------------------------------------+
|
38 |
// Initialisation des variables pour le calendrier
|
34 |
// Initialisation des variables pour le calendrier
|
39 |
if (!isset($_GET['annee'])) {
|
35 |
if (!isset($_GET['annee'])) {
|
40 |
$_GET['annee'] = date('Y');
|
36 |
$_GET['annee'] = date('Y');
|
41 |
}
|
37 |
}
|
42 |
if (!isset($_GET['mois'])) {
|
38 |
if (!isset($_GET['mois'])) {
|
43 |
$_GET['mois'] = date('m');
|
39 |
$_GET['mois'] = date('m');
|
44 |
}
|
40 |
}
|
45 |
if (!isset($_GET['semaine'])) {
|
41 |
if (!isset($_GET['semaine'])) {
|
46 |
$_GET['semaine'] = date('W');
|
42 |
$_GET['semaine'] = date('W');
|
47 |
}
|
43 |
}
|
48 |
if (!isset($_GET['jour'])) {
|
44 |
if (!isset($_GET['jour'])) {
|
49 |
$_GET['jour'] = date('d');
|
45 |
$_GET['jour'] = date('d');
|
50 |
}
|
46 |
}
|
51 |
// Instanciation de la classe Calendrier France
|
47 |
// Instanciation de la classe Calendrier France
|
52 |
$Calendrier = new Calendrier($_GET['jour'], $_GET['semaine'], $_GET['mois'], $_GET['annee']);
|
48 |
$Calendrier = new Calendrier($_GET['jour'], $_GET['semaine'], $_GET['mois'], $_GET['annee']);
|
53 |
$tab_jours_feries = $Calendrier->getListeFeries();
|
49 |
$tab_jours_feries = $Calendrier->getListeFeries();
|
54 |
|
50 |
|
55 |
// Create an array of days which are "selected"
|
51 |
// Create an array of days which are "selected"
|
56 |
// Used for Week::build() below
|
52 |
// Used for Week::build() below
|
57 |
$CalendrierJourCourrant = new Calendar_Week(date('Y'), date('m'), date('d'));
|
53 |
$CalendrierJourCourrant = new Calendar_Week(date('Y'), date('m'), date('d'));
|
58 |
$aso_gestion['jc']['jour'] = $CalendrierJourCourrant->thisDay();
|
54 |
$aso_gestion['jc']['jour'] = $CalendrierJourCourrant->thisDay();
|
59 |
$aso_gestion['jc']['semaine'] = $CalendrierJourCourrant->thisWeek('n_in_year');
|
55 |
$aso_gestion['jc']['semaine'] = $CalendrierJourCourrant->thisWeek('n_in_year');
|
60 |
$aso_gestion['jc']['mois'] = $CalendrierJourCourrant->thisMonth();
|
56 |
$aso_gestion['jc']['mois'] = $CalendrierJourCourrant->thisMonth();
|
61 |
$aso_gestion['jc']['mois_nom'] = $Calendrier->getNomMois($CalendrierJourCourrant->thisMonth());
|
57 |
$aso_gestion['jc']['mois_nom'] = $Calendrier->getNomMois($CalendrierJourCourrant->thisMonth());
|
62 |
$aso_gestion['jc']['annee'] = $CalendrierJourCourrant->thisYear();
|
58 |
$aso_gestion['jc']['annee'] = $CalendrierJourCourrant->thisYear();
|
63 |
$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'];
|
59 |
$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'];
|
64 |
|
60 |
|
65 |
$CalendrierJourCourrant->build();
|
61 |
$CalendrierJourCourrant->build();
|
66 |
$CalendrierSemaineCourrante = $CalendrierJourCourrant->thisWeek('object');
|
62 |
$CalendrierSemaineCourrante = $CalendrierJourCourrant->thisWeek('object');
|
67 |
$CalendrierSemaineCourrante->build();
|
63 |
$CalendrierSemaineCourrante->build();
|
68 |
$tab_jours = $CalendrierSemaineCourrante->fetchAll();
|
64 |
$tab_jours = $CalendrierSemaineCourrante->fetchAll();
|
69 |
$aso_gestion['sjc_1']['jour'] = $tab_jours[1]->thisDay();
|
65 |
$aso_gestion['sjc_1']['jour'] = $tab_jours[1]->thisDay();
|
70 |
$aso_gestion['sjc_1']['mois'] = $Calendrier->getNomMois($tab_jours[1]->thisMonth());
|
66 |
$aso_gestion['sjc_1']['mois'] = $Calendrier->getNomMois($tab_jours[1]->thisMonth());
|
71 |
$aso_gestion['sjc_1']['annee'] = $tab_jours[1]->thisYear();
|
67 |
$aso_gestion['sjc_1']['annee'] = $tab_jours[1]->thisYear();
|
72 |
$aso_gestion['sjc_7']['jour'] = $tab_jours[7]->thisDay();
|
68 |
$aso_gestion['sjc_7']['jour'] = $tab_jours[7]->thisDay();
|
73 |
$aso_gestion['sjc_7']['mois'] = $Calendrier->getNomMois($tab_jours[7]->thisMonth());
|
69 |
$aso_gestion['sjc_7']['mois'] = $Calendrier->getNomMois($tab_jours[7]->thisMonth());
|
74 |
$aso_gestion['sjc_7']['annee'] = $tab_jours[7]->thisYear();
|
70 |
$aso_gestion['sjc_7']['annee'] = $tab_jours[7]->thisYear();
|
75 |
|
71 |
|
76 |
$aso_gestion['selectedDays'] = array ($CalendrierJourCourrant);
|
72 |
$aso_gestion['selectedDays'] = array ($CalendrierJourCourrant);
|
77 |
|
73 |
|
78 |
// Instruct month to build Week objects
|
74 |
// Instruct month to build Week objects
|
79 |
// Construction de l'objet mois
|
75 |
// Construction de l'objet mois
|
80 |
$Month = new Calendar_Month_Weeks($_GET['annee'], $_GET['mois']);
|
76 |
$Month = new Calendar_Month_Weeks($_GET['annee'], $_GET['mois']);
|
81 |
$Month->build();
|
77 |
$Month->build();
|
82 |
|
78 |
|
83 |
while ($Week = $Month->fetch()) {
|
79 |
while ($Week = $Month->fetch()) {
|
84 |
$Week->build($aso_gestion['selectedDays']);
|
80 |
$Week->build($aso_gestion['selectedDays']);
|
85 |
//echo '<pre>'.print_r($Month, true).'</pre>';
|
81 |
//echo '<pre>'.print_r($Month, true).'</pre>';
|
86 |
$tab_semaine_jours = $Week->fetchAll();
|
82 |
$tab_semaine_jours = $Week->fetchAll();
|
87 |
foreach ($tab_semaine_jours as $num => $Day) {
|
83 |
foreach ($tab_semaine_jours as $num => $Day) {
|
88 |
$element = array();
|
84 |
$element = array();
|
89 |
$element['annee'] = $Day->thisYear();
|
85 |
$element['annee'] = $Day->thisYear();
|
90 |
$element['mois'] = $Day->thisMonth();
|
86 |
$element['mois'] = $Day->thisMonth();
|
91 |
$element['jour'] = $Day->thisDay();
|
87 |
$element['jour'] = $Day->thisDay();
|
92 |
$element['jour_nom'] = $Calendrier->getNomJours($num);
|
88 |
$element['jour_nom'] = $Calendrier->getNomJours($num);
|
93 |
$element['url'] = 'index.php?action='.GTT_ACTION_GESTION.'&annee='.$Day->thisYear().'&mois='.$Day->thisMonth().'&jour='.$Day->thisDay();
|
89 |
$element['url'] = 'index.php?action='.GTT_ACTION_GESTION.'&annee='.$Day->thisYear().'&mois='.$Day->thisMonth().'&jour='.$Day->thisDay();
|
94 |
// Check to see if day is selected
|
90 |
// Check to see if day is selected
|
95 |
if ($Day->isSelected()) {
|
91 |
if ($Day->isSelected()) {
|
96 |
$element['class'] = 'jour_courrant';
|
92 |
$element['class'] = 'jour_courrant';
|
97 |
} else if ($Day->isEmpty()) {
|
93 |
} else if ($Day->isEmpty()) {
|
98 |
$element['class'] = 'jour_vide';
|
94 |
$element['class'] = 'jour_vide';
|
99 |
} else {
|
95 |
} else {
|
100 |
$element['class'] = 'jour';
|
96 |
$element['class'] = 'jour';
|
101 |
}
|
97 |
}
|
102 |
foreach ($tab_jours_feries as $jour_ferie) {
|
98 |
foreach ($tab_jours_feries as $jour_ferie) {
|
103 |
if ($Day->thisDay(true) == $jour_ferie) {
|
99 |
if ($Day->thisDay(true) == $jour_ferie) {
|
104 |
$element['class'] = 'jour_ferie';
|
100 |
$element['class'] = 'jour_ferie';
|
105 |
}
|
101 |
}
|
106 |
}
|
102 |
}
|
107 |
$aso_gestion['elements'][$Week->thisWeek('n_in_year')][$num] = $element;
|
103 |
$aso_gestion['elements'][$Week->thisWeek('n_in_year')][$num] = $element;
|
108 |
}
|
104 |
}
|
109 |
}
|
105 |
}
|
110 |
|
106 |
|
111 |
// Construction de l'url pour les mois précédent/suivant
|
107 |
// Construction de l'url pour les mois précédent/suivant
|
112 |
$PMonth = $Month->prevMonth('object');
|
108 |
$PMonth = $Month->prevMonth('object');
|
113 |
$aso_gestion['url_mois_precedent'] = 'index.php?action='.GTT_ACTION_GESTION.'&annee='.$PMonth->thisYear().'&mois='.$PMonth->thisMonth().'&jour='.$PMonth->thisDay();
|
109 |
$aso_gestion['url_mois_precedent'] = 'index.php?action='.GTT_ACTION_GESTION.'&annee='.$PMonth->thisYear().'&mois='.$PMonth->thisMonth().'&jour='.$PMonth->thisDay();
|
114 |
$NMonth = $Month->nextMonth('object');
|
110 |
$NMonth = $Month->nextMonth('object');
|
115 |
$aso_gestion['url_mois_suivant'] = 'index.php?action='.GTT_ACTION_GESTION.'&annee='.$NMonth->thisYear().'&mois='.$NMonth->thisMonth().'&jour='.$NMonth->thisDay();
|
111 |
$aso_gestion['url_mois_suivant'] = 'index.php?action='.GTT_ACTION_GESTION.'&annee='.$NMonth->thisYear().'&mois='.$NMonth->thisMonth().'&jour='.$NMonth->thisDay();
|
116 |
$aso_gestion['mois']['mois'] = $Calendrier->getNomMois($Month->thisMonth());
|
112 |
$aso_gestion['mois']['mois'] = $Calendrier->getNomMois($Month->thisMonth());
|
117 |
$aso_gestion['mois']['annee'] = $Month->thisYear();
|
113 |
$aso_gestion['mois']['annee'] = $Month->thisYear();
|
118 |
|
114 |
|
119 |
// Construction de l'url pour les semaines précédente/suivante
|
115 |
// Construction de l'url pour les semaines précédente/suivante
|
120 |
$Week = new Calendar_Week($_GET['annee'], $_GET['mois'], $_GET['jour']);
|
116 |
$Week = new Calendar_Week($_GET['annee'], $_GET['mois'], $_GET['jour']);
|
121 |
$aso_gestion['s'] = $Week->thisWeek('n_in_year');
|
117 |
$aso_gestion['s'] = $Week->thisWeek('n_in_year');
|
122 |
|
118 |
|
123 |
$PWeek = $Week->prevWeek('object');
|
119 |
$PWeek = $Week->prevWeek('object');
|
124 |
$aso_gestion['url_semaine_precedente'] = 'index.php?action='.GTT_ACTION_GESTION.'&annee='.$PWeek->thisYear().'&mois='.$PWeek->thisMonth().'&jour='.$PWeek->thisDay();
|
120 |
$aso_gestion['url_semaine_precedente'] = 'index.php?action='.GTT_ACTION_GESTION.'&annee='.$PWeek->thisYear().'&mois='.$PWeek->thisMonth().'&jour='.$PWeek->thisDay();
|
125 |
|
121 |
|
126 |
$url_sc_param_date = '&annee='.$Week->thisYear().'&mois='.$Week->thisMonth().'&jour='.$Week->thisDay();
|
122 |
$url_sc_param_date = '&annee='.$Week->thisYear().'&mois='.$Week->thisMonth().'&jour='.$Week->thisDay();
|
127 |
$aso_gestion['url_semaine_courante'] = 'index.php?action='.GTT_ACTION_GESTION.$url_sc_param_date;
|
123 |
$aso_gestion['url_semaine_courante'] = 'index.php?action='.GTT_ACTION_GESTION.$url_sc_param_date;
|
128 |
|
124 |
|
129 |
$NWeek = $Week->nextWeek('object');
|
125 |
$NWeek = $Week->nextWeek('object');
|
130 |
$aso_gestion['url_semaine_suivante'] = 'index.php?action='.GTT_ACTION_GESTION.'&annee='.$NWeek->thisYear().'&mois='.$NWeek->thisMonth().'&jour='.$NWeek->thisDay();
|
126 |
$aso_gestion['url_semaine_suivante'] = 'index.php?action='.GTT_ACTION_GESTION.'&annee='.$NWeek->thisYear().'&mois='.$NWeek->thisMonth().'&jour='.$NWeek->thisDay();
|
131 |
|
127 |
|
132 |
$Week->build();
|
128 |
$Week->build();
|
133 |
$aso_jours = array();
|
129 |
$aso_jours = array();
|
134 |
foreach($Week->fetchAll() as $num => $j) {
|
130 |
foreach($Week->fetchAll() as $num => $j) {
|
135 |
$aso_gestion['sj_'.$num]['jour'] = $j->thisDay();
|
131 |
$aso_gestion['sj_'.$num]['jour'] = $j->thisDay();
|
136 |
$aso_gestion['sj_'.$num]['mois'] = $Calendrier->getNomMois($j->thisMonth());
|
132 |
$aso_gestion['sj_'.$num]['mois'] = $Calendrier->getNomMois($j->thisMonth());
|
137 |
$aso_gestion['sj_'.$num]['annee'] = $j->thisYear();
|
133 |
$aso_gestion['sj_'.$num]['annee'] = $j->thisYear();
|
138 |
$aso_gestion['sj_'.$num]['mysql'] = $aso_gestion['sj_'.$num]['annee'].'-'.sprintf("%02s", $j->thisMonth()).'-'.$aso_gestion['sj_'.$num]['jour'];
|
134 |
$aso_gestion['sj_'.$num]['mysql'] = $aso_gestion['sj_'.$num]['annee'].'-'.sprintf("%02s", $j->thisMonth()).'-'.$aso_gestion['sj_'.$num]['jour'];
|
139 |
$aso_jours[$aso_gestion['sj_'.$num]['mysql']] = $num;
|
135 |
$aso_jours[$aso_gestion['sj_'.$num]['mysql']] = $num;
|
140 |
$aso_tps_w_vide[$num] = '';
|
136 |
$aso_tps_w_vide[$num] = '';
|
141 |
}
|
137 |
}
|
142 |
|
138 |
|
143 |
//+-------------------------------------------------------------------------------------------------+
|
139 |
//+-------------------------------------------------------------------------------------------------+
|
144 |
// GESTION DES PROJETS
|
140 |
// GESTION DES PROJETS
|
145 |
//+-------------------------------------------------------------------------------------------------+
|
141 |
//+-------------------------------------------------------------------------------------------------+
|
146 |
// Récupération des infos sur l'utilisateur
|
142 |
// Récupération des infos sur l'utilisateur
|
147 |
$aso_gestion['conges_payes'] = $GLOBALS['_GTT_']['Utilisateur']->getCongesPayes();
|
143 |
$aso_gestion['conges_payes'] = $GLOBALS['_GTT_']['Utilisateur']->getCongesPayes();
|
148 |
$aso_gestion['rtt'] = $GLOBALS['_GTT_']['Utilisateur']->getQuotaHeuresSupp();
|
144 |
$aso_gestion['rtt'] = $GLOBALS['_GTT_']['Utilisateur']->getQuotaHeuresSupp();
|
149 |
$aso_gestion['tps_w'] = $GLOBALS['_GTT_']['Utilisateur']->getTempsDeTravail();
|
145 |
$aso_gestion['tps_w'] = $GLOBALS['_GTT_']['Utilisateur']->getTempsDeTravail();
|
150 |
|
146 |
|
151 |
// Récupération des projets sur lesquels l'utilisateur travaille
|
147 |
// Récupération des projets sur lesquels l'utilisateur travaille
|
152 |
$UtilsateurAProjet = new UtilisateurAProjet();
|
148 |
$UtilsateurAProjet = new UtilisateurAProjet();
|
153 |
$tab_uap = $UtilsateurAProjet->consulter(UtilisateurAProjet::GUAP_UTILISATEUR, $GLOBALS['_GTT_']['Utilisateur']->getIdUtilisateur());
|
149 |
$tab_uap = $UtilsateurAProjet->consulter(UtilisateurAProjet::GUAP_UTILISATEUR, $GLOBALS['_GTT_']['Utilisateur']->getIdUtilisateur());
|
154 |
$tab_projet_id = array();
|
150 |
$tab_projet_id = array();
|
155 |
foreach ($tab_uap as $uap) {
|
151 |
foreach ($tab_uap as $uap) {
|
156 |
$tab_projet_id[] = $uap->getIdProjet();
|
152 |
$tab_projet_id[] = $uap->getIdProjet();
|
157 |
}
|
153 |
}
|
158 |
|
154 |
|
159 |
// Récupération du temps de travail pour un utilisateur à une date donnée
|
155 |
// Récupération du temps de travail pour un utilisateur à une date donnée
|
160 |
$TravailProjet = new TravailProjet();
|
156 |
$TravailProjet = new TravailProjet();
|
161 |
$cmd = TravailProjet::GTP_ID_UTILISATEUR_DATE_DEB_FIN;
|
157 |
$cmd = TravailProjet::GTP_ID_UTILISATEUR_DATE_DEB_FIN;
|
162 |
$param = array($GLOBALS['_GTT_']['Utilisateur']->getIdUtilisateur(), $aso_gestion['sj_1']['mysql'], $aso_gestion['sj_7']['mysql']);
|
158 |
$param = array($GLOBALS['_GTT_']['Utilisateur']->getIdUtilisateur(), $aso_gestion['sj_1']['mysql'], $aso_gestion['sj_7']['mysql']);
|
163 |
$tab_tp = $TravailProjet->consulter($cmd, $param);
|
159 |
$tab_tp = $TravailProjet->consulter($cmd, $param);
|
164 |
if ($tab_tp && count($tab_tp) == 1) {
|
160 |
if ($tab_tp && count($tab_tp) == 1) {
|
165 |
$tab_tp = array($tab_tp);
|
161 |
$tab_tp = array($tab_tp);
|
166 |
}
|
162 |
}
|
167 |
|
163 |
|
168 |
// Récupération des infos sur les projets de l'utilisateur
|
164 |
// Récupération des infos sur les projets de l'utilisateur
|
169 |
$aso_gestion['totaux'] = $aso_tps_w_vide;
|
165 |
$aso_gestion['totaux'] = $aso_tps_w_vide;
|
170 |
$Projet = new Projet();
|
166 |
$Projet = new Projet();
|
171 |
$tab_p = $Projet->consulter(Projet::GP_ID_LIST, array(implode(',', $tab_projet_id)));
|
167 |
$tab_p = $Projet->consulter(Projet::GP_ID_LIST, array(implode(',', $tab_projet_id)));
|
172 |
foreach ($tab_p as $Projet) {
|
168 |
foreach ($tab_p as $Projet) {
|
173 |
|
169 |
|
174 |
// Récupération de la catégorie du projet
|
170 |
// Récupération de la catégorie du projet
|
175 |
$ProjetCategorie = new ProjetCategorie();
|
171 |
$ProjetCategorie = new ProjetCategorie();
|
176 |
$cmd = ProjetCategorie::GPC_ID;
|
172 |
$cmd = ProjetCategorie::GPC_ID;
|
177 |
$param = $Projet->getCeCategorie();
|
173 |
$param = $Projet->getCeCategorie();
|
178 |
$Categorie = $ProjetCategorie->consulter($cmd, $param);
|
174 |
$Categorie = $ProjetCategorie->consulter($cmd, $param);
|
179 |
|
175 |
|
180 |
// Nous vérifions le temps de travail pour ce projet pour la semaine courrante
|
176 |
// Nous vérifions le temps de travail pour ce projet pour la semaine courrante
|
181 |
$aso_tps_w = $aso_tps_w_vide;
|
177 |
$aso_tps_w = $aso_tps_w_vide;
|
182 |
if (!isset($aso_gestion['categorie_totaux'][$Categorie->getLibelle()])) {
|
178 |
if (!isset($aso_gestion['categorie_totaux'][$Categorie->getLibelle()])) {
|
183 |
$aso_gestion['categorie_totaux'][$Categorie->getLibelle()] = $aso_tps_w_vide;
|
179 |
$aso_gestion['categorie_totaux'][$Categorie->getLibelle()] = $aso_tps_w_vide;
|
184 |
}
|
180 |
}
|
185 |
if ($tab_tp) {
|
181 |
if ($tab_tp) {
|
186 |
foreach ($tab_tp as $TP) {
|
182 |
foreach ($tab_tp as $TP) {
|
187 |
if ($TP->getIdProjet() == $Projet->getIdProjet()) {
|
183 |
if ($TP->getIdProjet() == $Projet->getIdProjet()) {
|
188 |
$num = $aso_jours[$TP->getIdDateTravail()];
|
184 |
$num = $aso_jours[$TP->getIdDateTravail()];
|
189 |
$aso_tps_w[$num] = $TP->getDuree();
|
185 |
$aso_tps_w[$num] = $TP->getDuree();
|
190 |
$aso_gestion['categorie_totaux'][$Categorie->getLibelle()][$num] += $TP->getDuree();
|
186 |
$aso_gestion['categorie_totaux'][$Categorie->getLibelle()][$num] += $TP->getDuree();
|
191 |
$aso_gestion['totaux'][$num] += $TP->getDuree();
|
187 |
$aso_gestion['totaux'][$num] += $TP->getDuree();
|
192 |
}
|
188 |
}
|
193 |
}
|
189 |
}
|
194 |
}
|
190 |
}
|
195 |
|
191 |
|
196 |
// Stockage des infos nécessaire pour l'affichage
|
192 |
// Stockage des infos nécessaire pour l'affichage
|
197 |
$aso_gestion['preferences'][$Categorie->getLibelle()][] = array(
|
193 |
$aso_gestion['preferences'][$Categorie->getLibelle()][] = array(
|
198 |
'id' => $Projet->getIdProjet(),
|
194 |
'id' => $Projet->getIdProjet(),
|
199 |
'valeur' => $Projet->getIdProjet(),
|
195 |
'valeur' => $Projet->getIdProjet(),
|
200 |
'nom' => $Projet->getNomProjet(),
|
196 |
'nom' => $Projet->getNomProjet(),
|
201 |
'date' => $aso_tps_w);
|
197 |
'date' => $aso_tps_w);
|
202 |
|
198 |
|
203 |
|
199 |
|
204 |
}
|
200 |
}
|
205 |
//+-------------------------------------------------------------------------------------------------+
|
201 |
//+-------------------------------------------------------------------------------------------------+
|
206 |
// GESTION DES ABSENCES
|
202 |
// GESTION DES ABSENCES
|
207 |
//+-------------------------------------------------------------------------------------------------+
|
203 |
//+-------------------------------------------------------------------------------------------------+
|
208 |
// Récupération des motifs d'absence
|
204 |
// Récupération des motifs d'absence
|
209 |
$AbsenceMotif = new AbsenceMotif();
|
205 |
$AbsenceMotif = new AbsenceMotif();
|
210 |
$cmd = AbsenceMotif::GAM_TOUS;
|
206 |
$cmd = AbsenceMotif::GAM_TOUS;
|
211 |
$tab_am = $AbsenceMotif->consulter($cmd);
|
207 |
$tab_am = $AbsenceMotif->consulter($cmd);
|
212 |
if ($tab_am && count($tab_am) == 1) {
|
208 |
if ($tab_am && count($tab_am) == 1) {
|
213 |
$tab_am = array($tab_am);
|
209 |
$tab_am = array($tab_am);
|
214 |
}
|
210 |
}
|
215 |
|
211 |
|
216 |
// Récupération des absences pour un utilisateur à une date donnée
|
212 |
// Récupération des absences pour un utilisateur à une date donnée
|
217 |
$Absence = new Absence();
|
213 |
$Absence = new Absence();
|
218 |
$cmd = Absence::GA_ID_UTILISATEUR_DATE_DEB_FIN;
|
214 |
$cmd = Absence::GA_ID_UTILISATEUR_DATE_DEB_FIN;
|
219 |
$param = array($GLOBALS['_GTT_']['Utilisateur']->getIdUtilisateur(), $aso_gestion['sj_1']['mysql'], $aso_gestion['sj_7']['mysql']);
|
215 |
$param = array($GLOBALS['_GTT_']['Utilisateur']->getIdUtilisateur(), $aso_gestion['sj_1']['mysql'], $aso_gestion['sj_7']['mysql']);
|
220 |
$tab_a = $Absence->consulter($cmd, $param);
|
216 |
$tab_a = $Absence->consulter($cmd, $param);
|
221 |
if ($tab_a && count($tab_a) == 1) {
|
217 |
if ($tab_a && count($tab_a) == 1) {
|
222 |
$tab_a = array($tab_a);
|
218 |
$tab_a = array($tab_a);
|
223 |
}
|
219 |
}
|
224 |
|
220 |
|
225 |
$aso_gestion['ab_total'] = $aso_tps_w_vide;
|
221 |
$aso_gestion['ab_total'] = $aso_tps_w_vide;
|
226 |
if ($tab_am) {
|
222 |
if ($tab_am) {
|
227 |
foreach ($tab_am as $AM) {
|
223 |
foreach ($tab_am as $AM) {
|
228 |
$aso_gestion['ab_libelle'][$AM->getIdAbsenceMotif()] = $AM->getLibelle();
|
224 |
$aso_gestion['ab_libelle'][$AM->getIdAbsenceMotif()] = $AM->getLibelle();
|
229 |
$aso_gestion['ab'][$AM->getIdAbsenceMotif()] = $aso_tps_w_vide;
|
225 |
$aso_gestion['ab'][$AM->getIdAbsenceMotif()] = $aso_tps_w_vide;
|
230 |
if ($tab_a) {
|
226 |
if ($tab_a) {
|
231 |
foreach ($tab_a as $A) {
|
227 |
foreach ($tab_a as $A) {
|
232 |
if ($A->getIdAbsenceMotif() == $AM->getIdAbsenceMotif()) {
|
228 |
if ($A->getIdAbsenceMotif() == $AM->getIdAbsenceMotif()) {
|
233 |
$num = $aso_jours[$A->getIdDateAbsence()];
|
229 |
$num = $aso_jours[$A->getIdDateAbsence()];
|
234 |
$aso_gestion['ab'][$AM->getIdAbsenceMotif()][$num] = $A->getDuree();
|
230 |
$aso_gestion['ab'][$AM->getIdAbsenceMotif()][$num] = $A->getDuree();
|
235 |
$aso_gestion['ab_total'][$num] += $A->getDuree();
|
231 |
$aso_gestion['ab_total'][$num] += $A->getDuree();
|
236 |
$aso_gestion['totaux'][$num] += $A->getDuree();
|
232 |
$aso_gestion['totaux'][$num] += $A->getDuree();
|
237 |
}
|
233 |
}
|
238 |
}
|
234 |
}
|
239 |
}
|
235 |
}
|
240 |
}
|
236 |
}
|
241 |
}
|
237 |
}
|
242 |
|
238 |
|
243 |
// Création de l'url de réponse du formulaire
|
239 |
// Création de l'url de réponse du formulaire
|
244 |
$aso_gestion['url_gestion_valider'] = 'index.php?action='.GTT_ACTION_GESTION_VALIDER.$url_sc_param_date;
|
240 |
$aso_gestion['url_gestion_valider'] = 'index.php?action='.GTT_ACTION_GESTION_VALIDER.$url_sc_param_date;
|
245 |
|
241 |
|
246 |
//echo '<pre>ici '.print_r($aso_gestion['ab'], true).'la</pre>';
|
242 |
//echo '<pre>ici '.print_r($aso_gestion['ab'], true).'la</pre>';
|
247 |
$this->getRegistre()->ajouterDonnee('gestion', $aso_gestion);
|
243 |
$this->getRegistre()->ajouterDonnee('gestion', $aso_gestion);
|
248 |
}
|
244 |
}
|
249 |
|
245 |
|
250 |
public function verifierValider()
|
246 |
public function verifierValider()
|
251 |
{
|
247 |
{
|
252 |
|
248 |
|
253 |
}
|
249 |
}
|
254 |
|
250 |
|
255 |
public function executerValider()
|
251 |
public function executerValider()
|
256 |
{
|
252 |
{
|
257 |
//echo '<pre>'.print_r($_POST, true).'</pre>';
|
253 |
//echo '<pre>'.print_r($_POST, true).'</pre>';
|
258 |
|
254 |
|
259 |
// Récupération des info sur la semaine courrante
|
255 |
// Récupération des info sur la semaine courrante
|
260 |
$Week = new Calendar_Week($_GET['annee'], $_GET['mois'], $_GET['jour']);
|
256 |
$Week = new Calendar_Week($_GET['annee'], $_GET['mois'], $_GET['jour']);
|
261 |
$Week->build();
|
257 |
$Week->build();
|
262 |
$aso_jours = array();
|
258 |
$aso_jours = array();
|
263 |
$aso_semaine = array();
|
259 |
$aso_semaine = array();
|
264 |
foreach($Week->fetchAll() as $num => $j) {
|
260 |
foreach($Week->fetchAll() as $num => $j) {
|
265 |
$aso_semaine[$num]['mysql'] = $j->thisYear().'-'.sprintf("%02s", $j->thisMonth()).'-'.$j->thisDay();
|
261 |
$aso_semaine[$num]['mysql'] = $j->thisYear().'-'.sprintf("%02s", $j->thisMonth()).'-'.$j->thisDay();
|
266 |
$aso_jours[$aso_semaine[$num]['mysql']] = $num;
|
262 |
$aso_jours[$aso_semaine[$num]['mysql']] = $num;
|
267 |
}
|
263 |
}
|
268 |
|
264 |
|
269 |
// Récupération du temps de travail pour un utilisateur à une date donnée
|
265 |
// Récupération du temps de travail pour un utilisateur à une date donnée
|
270 |
$TravailProjet = new TravailProjet();
|
266 |
$TravailProjet = new TravailProjet();
|
271 |
$cmd = TravailProjet::GTP_ID_UTILISATEUR_DATE_DEB_FIN;
|
267 |
$cmd = TravailProjet::GTP_ID_UTILISATEUR_DATE_DEB_FIN;
|
272 |
$param = array($GLOBALS['_GTT_']['Utilisateur']->getIdUtilisateur(), $aso_semaine[1]['mysql'], $aso_semaine[7]['mysql']);
|
268 |
$param = array($GLOBALS['_GTT_']['Utilisateur']->getIdUtilisateur(), $aso_semaine[1]['mysql'], $aso_semaine[7]['mysql']);
|
273 |
$tab_tp = $TravailProjet->consulter($cmd, $param);
|
269 |
$tab_tp = $TravailProjet->consulter($cmd, $param);
|
274 |
if ($tab_tp && count($tab_tp) == 1) {
|
270 |
if ($tab_tp && count($tab_tp) == 1) {
|
275 |
$tab_tp = array($tab_tp);
|
271 |
$tab_tp = array($tab_tp);
|
276 |
}
|
272 |
}
|
277 |
|
273 |
|
278 |
// Ajout ou Mise à jour des durées de travail
|
274 |
// Ajout ou Mise à jour des durées de travail
|
279 |
if (isset($_POST['pr'])) {
|
275 |
if (isset($_POST['pr'])) {
|
280 |
foreach($_POST['pr'] as $projet_id => $jours) {
|
276 |
foreach($_POST['pr'] as $projet_id => $jours) {
|
281 |
//echo '<pre>'.print_r($jours, true).'</pre>';
|
277 |
//echo '<pre>'.print_r($jours, true).'</pre>';
|
282 |
foreach($jours as $jour_num => $nbr_heure) {
|
278 |
foreach($jours as $jour_num => $nbr_heure) {
|
283 |
$bool_ajouter = true;
|
279 |
$bool_ajouter = true;
|
284 |
if (!empty($tab_tp)) {
|
280 |
if (!empty($tab_tp)) {
|
285 |
foreach ($tab_tp as $TP) {
|
281 |
foreach ($tab_tp as $TP) {
|
286 |
if ($TP->getIdDateTravail() == $aso_semaine[$jour_num]['mysql']) {
|
282 |
if ($TP->getIdDateTravail() == $aso_semaine[$jour_num]['mysql']) {
|
287 |
if ($TP->getIdProjet() == $projet_id) {
|
283 |
if ($TP->getIdProjet() == $projet_id) {
|
288 |
$bool_ajouter = false;
|
284 |
$bool_ajouter = false;
|
289 |
if ($TP->getDuree() != $nbr_heure) {
|
285 |
if ($TP->getDuree() != $nbr_heure) {
|
290 |
if (empty($nbr_heure)) {
|
286 |
if (empty($nbr_heure)) {
|
291 |
$TP->supprimer();
|
287 |
$TP->supprimer();
|
292 |
} else {
|
288 |
} else {
|
293 |
$TP->setDuree($nbr_heure);
|
289 |
$TP->setDuree($nbr_heure);
|
294 |
$TP->modifier();
|
290 |
$TP->modifier();
|
295 |
}
|
291 |
}
|
296 |
}
|
292 |
}
|
297 |
}
|
293 |
}
|
298 |
}
|
294 |
}
|
299 |
}
|
295 |
}
|
300 |
}
|
296 |
}
|
301 |
if ($bool_ajouter && !empty($nbr_heure)) {
|
297 |
if ($bool_ajouter && !empty($nbr_heure)) {
|
302 |
$TP = new TravailProjet();
|
298 |
$TP = new TravailProjet();
|
303 |
$TP->setDuree((float)$nbr_heure);
|
299 |
$TP->setDuree((float)$nbr_heure);
|
304 |
$TP->setIdUtilisateur($GLOBALS['_GTT_']['Utilisateur']->getIdUtilisateur());
|
300 |
$TP->setIdUtilisateur($GLOBALS['_GTT_']['Utilisateur']->getIdUtilisateur());
|
305 |
$TP->setIdProjet($projet_id);
|
301 |
$TP->setIdProjet($projet_id);
|
306 |
$TP->setIdDateTravail((string)$aso_semaine[$jour_num]['mysql']);
|
302 |
$TP->setIdDateTravail((string)$aso_semaine[$jour_num]['mysql']);
|
307 |
$TP->ajouter();
|
303 |
$TP->ajouter();
|
308 |
}
|
304 |
}
|
309 |
}
|
305 |
}
|
310 |
}
|
306 |
}
|
311 |
}
|
307 |
}
|
312 |
|
308 |
|
313 |
// Récupération des absences pour un utilisateur à une date donnée
|
309 |
// Récupération des absences pour un utilisateur à une date donnée
|
314 |
$Absence = new Absence();
|
310 |
$Absence = new Absence();
|
315 |
$cmd = Absence::GA_ID_UTILISATEUR_DATE_DEB_FIN;
|
311 |
$cmd = Absence::GA_ID_UTILISATEUR_DATE_DEB_FIN;
|
316 |
$param = array($GLOBALS['_GTT_']['Utilisateur']->getIdUtilisateur(), $aso_semaine[1]['mysql'], $aso_semaine[7]['mysql']);
|
312 |
$param = array($GLOBALS['_GTT_']['Utilisateur']->getIdUtilisateur(), $aso_semaine[1]['mysql'], $aso_semaine[7]['mysql']);
|
317 |
$tab_a = $Absence->consulter($cmd, $param);
|
313 |
$tab_a = $Absence->consulter($cmd, $param);
|
318 |
if ($tab_a && count($tab_a) == 1) {
|
314 |
if ($tab_a && count($tab_a) == 1) {
|
319 |
$tab_a = array($tab_a);
|
315 |
$tab_a = array($tab_a);
|
320 |
}
|
316 |
}
|
321 |
|
317 |
|
322 |
// Ajout ou Mise à jour des durées d'absences pour congés payés
|
318 |
// Ajout ou Mise à jour des durées d'absences pour congés payés
|
323 |
if (isset($_POST['ab'])) {
|
319 |
if (isset($_POST['ab'])) {
|
324 |
//echo '<pre>'.print_r($_POST['ab'], true).'</pre>';
|
320 |
//echo '<pre>'.print_r($_POST['ab'], true).'</pre>';
|
325 |
foreach($_POST['ab'] as $ab_id => $tab_num_j) {
|
321 |
foreach($_POST['ab'] as $ab_id => $tab_num_j) {
|
326 |
foreach($tab_num_j as $num_j => $ab_duree) {
|
322 |
foreach($tab_num_j as $num_j => $ab_duree) {
|
327 |
$bool_ajouter = true;
|
323 |
$bool_ajouter = true;
|
328 |
if (!empty($tab_a)) {
|
324 |
if (!empty($tab_a)) {
|
329 |
foreach ($tab_a as $A) {
|
325 |
foreach ($tab_a as $A) {
|
330 |
if ($A->getIdDateAbsence() == $aso_semaine[$num_j]['mysql']) {
|
326 |
if ($A->getIdDateAbsence() == $aso_semaine[$num_j]['mysql']) {
|
331 |
|
327 |
|
332 |
if ($A->getIdAbsenceMotif() == $ab_id) {
|
328 |
if ($A->getIdAbsenceMotif() == $ab_id) {
|
333 |
$bool_ajouter = false;
|
329 |
$bool_ajouter = false;
|
334 |
|
330 |
|
335 |
if ($A->getDuree() != $ab_duree) {
|
331 |
if ($A->getDuree() != $ab_duree) {
|
336 |
echo 'ici'.$ab_duree;
|
332 |
echo 'ici'.$ab_duree;
|
337 |
if (empty($ab_duree)) {
|
333 |
if (empty($ab_duree)) {
|
338 |
$A->supprimer();
|
334 |
$A->supprimer();
|
339 |
} else {
|
335 |
} else {
|
340 |
$A->setDuree($ab_duree);
|
336 |
$A->setDuree($ab_duree);
|
341 |
$A->modifier();
|
337 |
$A->modifier();
|
342 |
}
|
338 |
}
|
343 |
}
|
339 |
}
|
344 |
}
|
340 |
}
|
345 |
}
|
341 |
}
|
346 |
}
|
342 |
}
|
347 |
}
|
343 |
}
|
348 |
if ($bool_ajouter && !empty($ab_duree)) {
|
344 |
if ($bool_ajouter && !empty($ab_duree)) {
|
349 |
$A = new Absence();
|
345 |
$A = new Absence();
|
350 |
$A->setDuree((float)$ab_duree);
|
346 |
$A->setDuree((float)$ab_duree);
|
351 |
$A->setIdUtilisateur($GLOBALS['_GTT_']['Utilisateur']->getIdUtilisateur());
|
347 |
$A->setIdUtilisateur($GLOBALS['_GTT_']['Utilisateur']->getIdUtilisateur());
|
352 |
$A->setIdAbsenceMotif($ab_id);
|
348 |
$A->setIdAbsenceMotif($ab_id);
|
353 |
$A->setIdDateAbsence((string)$aso_semaine[$num_j]['mysql']);
|
349 |
$A->setIdDateAbsence((string)$aso_semaine[$num_j]['mysql']);
|
354 |
$A->ajouter();
|
350 |
$A->ajouter();
|
355 |
}
|
351 |
}
|
356 |
}
|
352 |
}
|
357 |
}
|
353 |
}
|
358 |
}
|
354 |
}
|
359 |
|
355 |
|
360 |
// Action suivante
|
356 |
// Action suivante
|
361 |
$this->setSuivant('__defaut__');
|
357 |
$this->setSuivant('__defaut__');
|
362 |
}
|
358 |
}
|
363 |
}
|
359 |
}
|
364 |
?>
|
360 |
?>
|