Subversion Repositories Applications.gtt

Rev

Rev 39 | Rev 68 | Go to most recent revision | Show entire file | Ignore whitespace | Details | Blame | Last modification | View Log | RSS feed

Rev 39 Rev 48
Line 3... Line 3...
3
 
3
 
4
	public function __construct(Registre $Registre)
4
	public function __construct(Registre $Registre)
5
	{
5
	{
6
		$Registre->ajouterEspace('AdminCategorie', 'admin_categorie');
6
		$Registre->ajouterEspace('AdminCategorie', 'admin_categorie');
-
 
7
		$Registre->ajouterSquelette('admin_categorie', 'admin_categorie.tpl.html');
7
		$Registre->ajouterSquelette('admin_categorie', 'admin_categorie.tpl.html');
8
		$Registre->setTitre('Administrer les catégories des projets');
Line 8... Line 9...
8
	}
9
	}
9
 
10
 
10
	public function executer()
11
	public function executer()
11
    {
-
 
Line -... Line 12...
-
 
12
    {
-
 
13
    	$aso_admin_categ = array();
-
 
14
 
-
 
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();
Line 12... Line 22...
12
    	$aso_admin_categ = array();
22
    			$aso_admin_categ['categories'][] = $aso_categ;
13
    	$this->getRegistre()->setTitre('Administrer les catégories des projets');
23
    		}
14
 
24
    	}
-
 
25
 
-
 
26
    	//echo '<pre>'.print_r($aso_admin_categ, true).'</pre>';
-
 
27
		$this->getRegistre()->ajouterDonnee('admin_categorie', $aso_admin_categ);
-
 
28
    }
-
 
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
		}
15
 
70
 
16
    	//echo '<pre>'.print_r($aso_admin_categ, true).'</pre>';
71
		// Action suivante
17
		$this->getRegistre()->ajouterDonnee('admin_categorie', $aso_admin_categ);
72
    	$this->setSuivant('__defaut__');