| Line 3... |
Line 3... |
| 3 |
|
3 |
|
| 4 |
public function __construct(Registre $Registre)
|
4 |
public function __construct(Registre $Registre)
|
| 5 |
{
|
5 |
{
|
| 6 |
$Registre->ajouterEspace('AdminAbsenceMotif', 'admin_absence_motif');
|
6 |
$Registre->ajouterEspace('AdminAbsenceMotif', 'admin_absence_motif');
|
| 7 |
$Registre->ajouterSquelette('admin_absence_motif', 'admin_absence_motif.tpl.html');
|
7 |
$Registre->ajouterSquelette('admin_absence_motif', 'admin_absence_motif.tpl.html');
|
| 8 |
$Registre->setTitre('Administrer les motifs d\'absence');
|
8 |
$Registre->setTitre("Administrer les motifs d'absence");
|
| Line 9... |
Line 9... |
| 9 |
}
|
9 |
}
|
| 10 |
|
10 |
|
| 11 |
public function executer()
|
11 |
public function executer()
|
| Line 12... |
Line 12... |
| 12 |
{
|
12 |
{
|
| 13 |
$aso_admin_absence_motif = array();
|
13 |
$aso_admin_absence_motif = array();
|
| - |
|
14 |
|
| - |
|
15 |
// Récupération des catégories
|
| - |
|
16 |
$AbsenceMotif = new AbsenceMotif();
|
| - |
|
17 |
|
| 14 |
|
18 |
// Utilisateur vide par défaut
|
| - |
|
19 |
$aso_admin_absence_motif['AbsenceMotif'] = clone $AbsenceMotif;
|
| - |
|
20 |
|
| - |
|
21 |
$tab_am = $AbsenceMotif->consulter(AbsenceMotif::GAM_TOUS);
|
| - |
|
22 |
if ($tab_am) {
|
| 15 |
// Récupération des catégories
|
23 |
if ($tab_am instanceof AbsenceMotif) {
|
| 16 |
$AbsenceMotif = new AbsenceMotif();
|
24 |
$tab_am = array($tab_am);
|
| 17 |
$tab_am = $AbsenceMotif->consulter(AbsenceMotif::GAM_TOUS);
|
25 |
}
|
| 18 |
foreach ($tab_am as $am) {
|
26 |
foreach ($tab_am as $am) {
|
| 19 |
if ($am->getIdAbsenceMotif() != 0) {
|
27 |
if ($am->getIdAbsenceMotif() != 0) {
|
| 20 |
$aso_motif['id'] = $am->getIdAbsenceMotif();
|
28 |
$aso_motif['id'] = $am->getIdAbsenceMotif();
|
| - |
|
29 |
$aso_motif['libelle'] = $am->getLibelle();
|
| 21 |
$aso_motif['libelle'] = $am->getLibelle();
|
30 |
$aso_admin_absence_motif['motifs'][] = $aso_motif;
|
| 22 |
$aso_admin_absence_motif['motifs'][] = $aso_motif;
|
31 |
}
|
| - |
|
32 |
}
|
| - |
|
33 |
}
|
| - |
|
34 |
|
| - |
|
35 |
// Modification des titres, légendes et bouton
|
| - |
|
36 |
$aso_admin_absence_motif['form_legend'] = "Ajouter un motif d'abscence";
|
| - |
|
37 |
$aso_admin_absence_motif['form_bouton_value'] = 'Ajouter';
|
| 23 |
}
|
38 |
$aso_admin_absence_motif['form_bouton_id'] = 'btn_absence_motif_ajouter';
|
| 24 |
}
|
39 |
$aso_admin_absence_motif['form_url'] = 'index.php?action=admin-absence-motif_valider-ajouter';
|
| 25 |
|
40 |
|
| - |
|
41 |
//echo '<pre>'.print_r($aso_admin_absence_motif, true).'</pre>';
|
| - |
|
42 |
$this->getRegistre()->ajouterDonnee('admin_absence_motif', $aso_admin_absence_motif);
|
| - |
|
43 |
}
|
| - |
|
44 |
|
| - |
|
45 |
public function executerEditer()
|
| Line -... |
Line 46... |
| - |
|
46 |
{
|
| - |
|
47 |
// Initialisation de variable
|
| - |
|
48 |
$aso_admin_absence_motif = array();
|
| - |
|
49 |
|
| - |
|
50 |
// Récupération d'info en fonction du bouton selectionné
|
| - |
|
51 |
if (isset($_POST['btn_absence_motif_modifier'])) {
|
| - |
|
52 |
// Récupération des données du motif à modifier
|
| - |
|
53 |
$AbsenceMotif = new AbsenceMotif();
|
| - |
|
54 |
$AbsenceMotif ->consulter(AbsenceMotif::GAM_ID, $_POST['amsu_id'], true);
|
| - |
|
55 |
$aso_admin_absence_motif['AbsenceMotif'] = $AbsenceMotif;
|
| - |
|
56 |
|
| - |
|
57 |
// Modification des titres, légendes et bouton
|
| - |
|
58 |
$aso_admin_absence_motif['form_legend'] = "Modifier un motif d'absence";
|
| - |
|
59 |
$aso_admin_absence_motif['form_bouton_value'] = 'Modifier';
|
| - |
|
60 |
$aso_admin_absence_motif['form_bouton_id'] = 'btn_absence_motif_modifier';
|
| - |
|
61 |
$aso_admin_absence_motif['form_url'] = 'index.php?action=admin-absence-motif_valider-modifier';
|
| - |
|
62 |
|
| - |
|
63 |
$this->getRegistre()->ajouterDonnee('admin_absence_motif', $aso_admin_absence_motif);
|
| - |
|
64 |
} else if (isset($_POST['btn_absence_motif_supprimer'])) {
|
| - |
|
65 |
// Action suivante
|
| 26 |
//echo '<pre>'.print_r($aso_admin_absence_motif, true).'</pre>';
|
66 |
$this->setSuivant('ValiderSupprimer');
|
| 27 |
$this->getRegistre()->ajouterDonnee('admin_absence_motif', $aso_admin_absence_motif);
|
67 |
}
|
| - |
|
68 |
}
|
| 28 |
}
|
69 |
|
| - |
|
70 |
public function executerValiderAjouter()
|
| - |
|
71 |
{
|
| - |
|
72 |
if (isset($_POST['btn_absence_motif_annuler'])) {
|
| - |
|
73 |
// Action suivante
|
| - |
|
74 |
$this->setSuivant('__defaut__');
|
| - |
|
75 |
} else if (isset($_POST['btn_absence_motif_ajouter'])) {
|
| - |
|
76 |
// Vérification du motif à ajouter
|
| - |
|
77 |
$bool_modifier = true;
|
| - |
|
78 |
$AbsenceMotif = new AbsenceMotif();
|
| - |
|
79 |
$AmLibelle = $AbsenceMotif->consulter(AbsenceMotif::GAM_LIBELLE, array($_POST['amaj_libelle']));
|
| - |
|
80 |
if ((is_array($AmLibelle) && count($AmLibelle) > 1) || ($AmLibelle instanceof AbsenceMotif && $AmLibelle->getIdAbsenceMotif() != $_POST['amaj_id_absence_motif'])) {
|
| - |
|
81 |
$aso_admin_absence_motif['messages'][] = "Un motif d'absence avec le même libellé existe déjà !";
|
| - |
|
82 |
$bool_modifier = false;
|
| - |
|
83 |
}
|
| - |
|
84 |
|
| - |
|
85 |
//$this->verifierChampsCommuns(&$aso_admin_absence_motif, &$bool_modifier);
|
| - |
|
86 |
if ($bool_modifier) {
|
| - |
|
87 |
// Action suivante
|
| - |
|
88 |
$this->setSuivant('ajouter');
|
| - |
|
89 |
} else {
|
| - |
|
90 |
// Action suivante
|
| - |
|
91 |
$this->setSuivant('__defaut__');
|
| - |
|
92 |
$this->getRegistre()->ajouterDonnee('admin_absence_motif', $aso_admin_absence_motif);
|
| - |
|
93 |
}
|
| - |
|
94 |
}
|
| - |
|
95 |
}
|
| - |
|
96 |
|
| - |
|
97 |
public function executerAjouter()
|
| - |
|
98 |
{
|
| 29 |
|
99 |
// Initialisation de variable
|
| 30 |
public function executerValiderAjouter()
|
- |
|
| 31 |
{
|
- |
|
| 32 |
// Ajout de la catégorie
|
- |
|
| 33 |
$AbsenceMotif = new AbsenceMotif();
|
- |
|
| 34 |
$bool_existe = $AbsenceMotif->consulter(AbsenceMotif::GAM_LIBELLE, array($_POST['amaj_libelle']));
|
- |
|
| 35 |
if ($bool_existe == false) {
|
100 |
$aso_admin_motif = array();
|
| 36 |
$AbsenceMotifMax = $AbsenceMotif->consulter(AbsenceMotif::GAM_ID_MAX);
|
101 |
|
| 37 |
$id_max = $AbsenceMotifMax->getIdAbsenceMotif();
|
- |
|
| 38 |
$AbsenceMotif->setIdAbsenceMotif(++$id_max);
|
102 |
// Création de l'objet AbsenceMotif à ajouter
|
| 39 |
$AbsenceMotif->setLibelle($_POST['amaj_libelle']);
|
- |
|
| 40 |
$AbsenceMotif->ajouter();
|
103 |
$AbsenceMotif = new AbsenceMotif();
|
| - |
|
104 |
$AbsenceMotif->setLibelle($_POST['amaj_libelle']);
|
| - |
|
105 |
if (!isset($_POST['amaj_mark_cp_diminuer'])) {
|
| - |
|
106 |
$_POST['amaj_mark_cp_diminuer'] = 0;
|
| - |
|
107 |
}
|
| - |
|
108 |
$AbsenceMotif->setMarkCpDiminuer($_POST['amaj_mark_cp_diminuer']);
|
| - |
|
109 |
if (!isset($_POST['amaj_mark_hs_diminuer'])) {
|
| - |
|
110 |
$_POST['amaj_mark_hs_diminuer'] = 0;
|
| - |
|
111 |
}
|
| - |
|
112 |
$AbsenceMotif->setMarkHsDiminuer($_POST['amaj_mark_hs_diminuer']);
|
| - |
|
113 |
if ($AbsenceMotif->ajouter()) {
|
| - |
|
114 |
$aso_admin_motif['messages'][] = "Le motif d'absence ${_POST['amaj_libelle']} a été ajouté.";
|
| - |
|
115 |
}
|
| 41 |
} else {
|
116 |
|
| 42 |
$aso_admin_absence_motif['message'] = 'Ce motif d\'absence existe déjà !';
|
117 |
// Ajout du message d'information
|
| - |
|
118 |
$this->getRegistre()->ajouterDonnee('admin_absence_motif', $aso_admin_motif);
|
| - |
|
119 |
|
| - |
|
120 |
// Action suivante
|
| - |
|
121 |
$this->setSuivant('__defaut__');
|
| - |
|
122 |
}
|
| - |
|
123 |
|
| - |
|
124 |
public function executerValiderModifier()
|
| - |
|
125 |
{
|
| - |
|
126 |
if (isset($_POST['btn_absence_motif_annuler'])) {
|
| - |
|
127 |
// Action suivante
|
| - |
|
128 |
$this->setSuivant('__defaut__');
|
| - |
|
129 |
} else if (isset($_POST['btn_absence_motif_modifier'])) {
|
| - |
|
130 |
// Initialisation de variable
|
| - |
|
131 |
$aso_admin_motif = array();
|
| - |
|
132 |
|
| - |
|
133 |
// Vérification du motif à modifier
|
| - |
|
134 |
$bool_modifier = true;
|
| - |
|
135 |
$AbsenceMotif = new AbsenceMotif();
|
| - |
|
136 |
$AmLibelle = $AbsenceMotif->consulter(AbsenceMotif::GAM_LIBELLE, array($_POST['amaj_libelle']));
|
| - |
|
137 |
if ((is_array($AmLibelle) && count($AmLibelle) > 1) || ($AmLibelle instanceof AbsenceMotif && $AmLibelle->getIdAbsenceMotif() != $_POST['amaj_id_absence_motif'])) {
|
| - |
|
138 |
$aso_admin_motif['messages'][] = "Un motif d'absence avec le même libellé existe déjà !";
|
| - |
|
139 |
$bool_modifier = false;
|
| - |
|
140 |
}
|
| - |
|
141 |
//$this->verifierChampsCommuns(&$aso_admin_absence_motif, &$bool_modifier);
|
| - |
|
142 |
if ($bool_modifier) {
|
| - |
|
143 |
// Action suivante
|
| - |
|
144 |
$this->setSuivant('modifier');
|
| - |
|
145 |
} else {
|
| - |
|
146 |
// Action suivante
|
| - |
|
147 |
$_POST['btn_motif_absence_modifier'] = 'btn_absence_motif_modifier';
|
| - |
|
148 |
$_POST['amsu_id'] = $_POST['amaj_id_absence_motif'];
|
| 43 |
$this->getRegistre()->ajouterDonnee('admin_absence_motif', $aso_admin_absence_motif);
|
149 |
$this->setSuivant('editer');
|
| Line -... |
Line 150... |
| - |
|
150 |
$this->getRegistre()->ajouterDonnee('admin_absence_motif', $aso_admin_motif);
|
| - |
|
151 |
}
|
| - |
|
152 |
}
|
| - |
|
153 |
}
|
| - |
|
154 |
|
| - |
|
155 |
public function executerModifier()
|
| - |
|
156 |
{
|
| - |
|
157 |
// Initialisation de variable
|
| - |
|
158 |
$aso_admin_motif = array();
|
| - |
|
159 |
|
| - |
|
160 |
// Création de l'objet AbsenceMotif à modifier
|
| - |
|
161 |
$AbsenceMotif = new AbsenceMotif();
|
| - |
|
162 |
$AbsenceMotif->setIdAbsenceMotif($_POST['amaj_id_absence_motif']);
|
| - |
|
163 |
$AbsenceMotif->setLibelle($_POST['amaj_libelle']);
|
| - |
|
164 |
if (!isset($_POST['amaj_mark_cp_diminuer'])) {
|
| - |
|
165 |
$_POST['amaj_mark_cp_diminuer'] = 0;
|
| - |
|
166 |
}
|
| - |
|
167 |
$AbsenceMotif->setMarkCpDiminuer($_POST['amaj_mark_cp_diminuer']);
|
| - |
|
168 |
if (!isset($_POST['amaj_mark_hs_diminuer'])) {
|
| - |
|
169 |
$_POST['amaj_mark_hs_diminuer'] = 0;
|
| - |
|
170 |
}
|
| - |
|
171 |
$AbsenceMotif->setMarkHsDiminuer($_POST['amaj_mark_hs_diminuer']);
|
| - |
|
172 |
|
| - |
|
173 |
if ($AbsenceMotif->modifier()) {
|
| - |
|
174 |
$aso_admin_motif['messages'][] = "Le motif d'absence ${_POST['amaj_libelle']} a été modifié.";
|
| - |
|
175 |
}
|
| - |
|
176 |
|
| - |
|
177 |
// Ajout du message d'information
|
| - |
|
178 |
$this->getRegistre()->ajouterDonnee('admin_absence_motif', $aso_admin_motif);
|
| 44 |
}
|
179 |
|
| 45 |
// Action suivante
|
180 |
// Action suivante
|
| 46 |
$this->setSuivant('__defaut__');
|
181 |
$this->setSuivant('__defaut__');
|
| 47 |
}
|
- |
|
| 48 |
|
- |
|
| 49 |
public function executerValiderSupprimer()
|
182 |
}
|
| Line 50... |
Line 183... |
| 50 |
{
|
183 |
|
| 51 |
// Suppression du motif d'absence
|
184 |
public function executerValiderSupprimer()
|
| 52 |
$AbsenceMotif = new AbsenceMotif();
|
185 |
{
|
| 53 |
$AbsenceMotif->setIdAbsenceMotif($_POST['amsu_id']);
|
186 |
// Initialisation des variables
|
| 54 |
$AbsenceMotif->supprimer();
|
187 |
$aso_admin_motif = array();
|
| 55 |
|
188 |
|
| 56 |
// Mise à jour des absences possédant le motif supprimé
|
- |
|
| 57 |
$Absence = new Absence();
|
189 |
// Vérif des absences
|
| 58 |
$tab_a = $Absence->consulter(Absence::GA_ID_ABSENCE_MOTIF, $_POST['amsu_id']);
|
190 |
$Absence = new Absence();
|
| 59 |
if ($tab_a != false) {
|
191 |
$bool_existe = $Absence->consulter(Absence::GA_ID_ABSENCE_MOTIF, array($_POST['amsu_id']));
|
| 60 |
if ($tab_a && count($tab_a) == 1) {
|
192 |
if ($bool_existe == false) {
|
| 61 |
$tab_a = array($tab_a);
|
193 |
trigger_error('Absence -> OK', E_USER_NOTICE);
|
| 62 |
}
|
194 |
// Suppression du motif d'absence
|
| - |
|
195 |
$AbsenceMotif = new AbsenceMotif();
|
| - |
|
196 |
$AbsenceMotif->setIdAbsenceMotif($_POST['amsu_id']);
|
| - |
|
197 |
if ($AbsenceMotif->supprimer()) {
|
| - |
|
198 |
$aso_admin_motif['messages'][] = "Le motif d'absence a été supprimé.";
|
| Line -... |
Line 199... |
| - |
|
199 |
}
|
| - |
|
200 |
}
|
| - |
|
201 |
// Message d'erreur si le motif d'absence est utilisé
|
| 63 |
foreach ($tab_a as $a) {
|
202 |
if ($bool_existe != false) {
|
| 64 |
$Ancien = clone $a;
|
203 |
$aso_admin_motif['messages'][ ] = "Il n'est pas possible de supprimer un motif d'absence contenant des données!";
|
| 65 |
$a->setIdAbsenceMotif(0);
|
204 |
}
|
| - |
|
205 |
|
| - |
|
206 |
// Enregistrement du message
|
| 66 |
$a->modifier($Ancien);
|
207 |
$this->getRegistre()->ajouterDonnee('admin_absence_motif', $aso_admin_motif);
|
| 67 |
}
|
208 |
|
| 68 |
}
|
209 |
// Action suivante
|