Rev 39 | Rev 68 | Go to most recent revision | Blame | Compare with Previous | Last modification | View Log | RSS feed
<?phpclass GttCtrlActionAdminCategorie extends aControlleurAction {public function __construct(Registre $Registre){$Registre->ajouterEspace('AdminCategorie', 'admin_categorie');$Registre->ajouterSquelette('admin_categorie', 'admin_categorie.tpl.html');$Registre->setTitre('Administrer les catégories des projets');}public function executer(){$aso_admin_categ = array();// Récupération des catégories$ProjetCategorie = new ProjetCategorie();$tab_pc = $ProjetCategorie->consulter(ProjetCategorie::GPC_TOUS);foreach ($tab_pc as $pc) {if ($pc->getIdCategorie() != 0) {$aso_categ['id'] = $pc->getIdCategorie();$aso_categ['libelle'] = $pc->getLibelle();$aso_admin_categ['categories'][] = $aso_categ;}}//echo '<pre>'.print_r($aso_admin_categ, true).'</pre>';$this->getRegistre()->ajouterDonnee('admin_categorie', $aso_admin_categ);}public function executerValiderAjouter(){// Ajout de la catégorie$ProjetCategorie = new ProjetCategorie();$bool_existe = $ProjetCategorie->consulter(ProjetCategorie::GPC_LIBELLE, array($_POST['caaj_libelle']));if ($bool_existe == false) {$ProjetCategorieMax = $ProjetCategorie->consulter(ProjetCategorie::GPC_ID_MAX);$id_max = $ProjetCategorieMax->getIdCategorie();$ProjetCategorie->setIdCategorie(++$id_max);$ProjetCategorie->setLibelle($_POST['caaj_libelle']);$ProjetCategorie->ajouter();} else {$aso_admin_categ['message'] = 'Cette catégorie existe déjà !';$this->getRegistre()->ajouterDonnee('admin_categorie', $aso_admin_categ);}// Action suivante$this->setSuivant('__defaut__');}public function executerValiderSupprimer(){// Suppression de la catégorie$ProjetCategorie = new ProjetCategorie();$ProjetCategorie->setIdCategorie($_POST['casu_id']);$ProjetCategorie->supprimer();// Mise à jour des projets appartenant à la catégorie$Projet = new Projet();$tab_p = $Projet->consulter(Projet::GP_CE_CATEGORIE, $_POST['casu_id']);if ($tab_p != false) {if ($tab_p && count($tab_p) == 1) {$tab_p = array($tab_p);}foreach ($tab_p as $p) {$Ancien = clone $p;$p->setCeCategorie(0);$p->modifier($Ancien);}}// Action suivante$this->setSuivant('__defaut__');}}?>