39 |
jpm |
1 |
<?php
|
|
|
2 |
class GttCtrlActionAdminCategorie extends aControlleurAction {
|
|
|
3 |
|
|
|
4 |
public function __construct(Registre $Registre)
|
|
|
5 |
{
|
|
|
6 |
$Registre->ajouterEspace('AdminCategorie', 'admin_categorie');
|
|
|
7 |
$Registre->ajouterSquelette('admin_categorie', 'admin_categorie.tpl.html');
|
48 |
jpm |
8 |
$Registre->setTitre('Administrer les catégories des projets');
|
39 |
jpm |
9 |
}
|
|
|
10 |
|
|
|
11 |
public function executer()
|
|
|
12 |
{
|
|
|
13 |
$aso_admin_categ = array();
|
|
|
14 |
|
48 |
jpm |
15 |
// Récupération des catégories
|
|
|
16 |
$ProjetCategorie = new ProjetCategorie();
|
|
|
17 |
$tab_pc = $ProjetCategorie->consulter(ProjetCategorie::GPC_TOUS);
|
|
|
18 |
foreach ($tab_pc as $pc) {
|
|
|
19 |
if ($pc->getIdCategorie() != 0) {
|
|
|
20 |
$aso_categ['id'] = $pc->getIdCategorie();
|
|
|
21 |
$aso_categ['libelle'] = $pc->getLibelle();
|
|
|
22 |
$aso_admin_categ['categories'][] = $aso_categ;
|
|
|
23 |
}
|
|
|
24 |
}
|
39 |
jpm |
25 |
|
|
|
26 |
//echo '<pre>'.print_r($aso_admin_categ, true).'</pre>';
|
|
|
27 |
$this->getRegistre()->ajouterDonnee('admin_categorie', $aso_admin_categ);
|
|
|
28 |
}
|
48 |
jpm |
29 |
|
|
|
30 |
public function executerValiderAjouter()
|
|
|
31 |
{
|
|
|
32 |
// Ajout de la catégorie
|
|
|
33 |
$ProjetCategorie = new ProjetCategorie();
|
|
|
34 |
$bool_existe = $ProjetCategorie->consulter(ProjetCategorie::GPC_LIBELLE, array($_POST['caaj_libelle']));
|
|
|
35 |
if ($bool_existe == false) {
|
|
|
36 |
$ProjetCategorieMax = $ProjetCategorie->consulter(ProjetCategorie::GPC_ID_MAX);
|
|
|
37 |
$id_max = $ProjetCategorieMax->getIdCategorie();
|
|
|
38 |
$ProjetCategorie->setIdCategorie(++$id_max);
|
|
|
39 |
$ProjetCategorie->setLibelle($_POST['caaj_libelle']);
|
|
|
40 |
$ProjetCategorie->ajouter();
|
|
|
41 |
} else {
|
|
|
42 |
$aso_admin_categ['message'] = 'Cette catégorie existe déjà !';
|
|
|
43 |
$this->getRegistre()->ajouterDonnee('admin_categorie', $aso_admin_categ);
|
|
|
44 |
}
|
|
|
45 |
|
|
|
46 |
// Action suivante
|
|
|
47 |
$this->setSuivant('__defaut__');
|
|
|
48 |
}
|
|
|
49 |
|
|
|
50 |
public function executerValiderSupprimer()
|
|
|
51 |
{
|
|
|
52 |
// Suppression de la catégorie
|
|
|
53 |
$ProjetCategorie = new ProjetCategorie();
|
|
|
54 |
$ProjetCategorie->setIdCategorie($_POST['casu_id']);
|
|
|
55 |
$ProjetCategorie->supprimer();
|
|
|
56 |
|
|
|
57 |
// Mise à jour des projets appartenant à la catégorie
|
|
|
58 |
$Projet = new Projet();
|
|
|
59 |
$tab_p = $Projet->consulter(Projet::GP_CE_CATEGORIE, $_POST['casu_id']);
|
|
|
60 |
if ($tab_p != false) {
|
|
|
61 |
if ($tab_p && count($tab_p) == 1) {
|
|
|
62 |
$tab_p = array($tab_p);
|
|
|
63 |
}
|
|
|
64 |
foreach ($tab_p as $p) {
|
|
|
65 |
$Ancien = clone $p;
|
|
|
66 |
$p->setCeCategorie(0);
|
|
|
67 |
$p->modifier($Ancien);
|
|
|
68 |
}
|
|
|
69 |
}
|
|
|
70 |
|
|
|
71 |
// Action suivante
|
|
|
72 |
$this->setSuivant('__defaut__');
|
|
|
73 |
}
|
39 |
jpm |
74 |
}
|
|
|
75 |
?>
|