Subversion Repositories Applications.gtt

Rev

Rev 48 | Rev 73 | Go to most recent revision | Only display areas with differences | Regard whitespace | Details | Blame | Last modification | View Log | RSS feed

Rev 48 Rev 68
1
<?php
1
<?php
2
class GttCtrlActionAdminCategorie extends aControlleurAction {
2
class GttCtrlActionAdminCategorie extends aControlleurAction {
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');
8
		$Registre->setTitre('Administrer les catégories des projets');
9
	}
9
	}
10
 
10
 
11
	public function executer()
11
	public function executer()
12
    {
12
    {
13
    	$aso_admin_categ = array();
13
    	$aso_admin_categ = array();
14
 
14
 
15
		// Récupération des catégories
15
		// Récupération des catégories
16
		$ProjetCategorie = new ProjetCategorie();
16
		$ProjetCategorie = new ProjetCategorie();
-
 
17
 
-
 
18
		// Ajout de l'utilisateur vide par défaut
-
 
19
		$aso_admin_categ['ProjetCategorie'] = $ProjetCategorie;
-
 
20
		
-
 
21
		// Récupération des infos sur les categories existantes 
17
    	$tab_pc = $ProjetCategorie->consulter(ProjetCategorie::GPC_TOUS);
22
    	$tab_pc = $ProjetCategorie->consulter(ProjetCategorie::GPC_TOUS);
18
    	foreach ($tab_pc as $pc) {
23
    	foreach ($tab_pc as $pc) {
19
    		if ($pc->getIdCategorie() != 0) {
24
    		if ($pc->getIdCategorie() != 0) {
20
    			$aso_categ['id'] = $pc->getIdCategorie();
25
    			$aso_categ['id'] = $pc->getIdCategorie();
21
    			$aso_categ['libelle'] = $pc->getLibelle();
26
    			$aso_categ['libelle'] = $pc->getLibelle();
22
    			$aso_admin_categ['categories'][] = $aso_categ;
27
    			$aso_admin_categ['categories'][] = $aso_categ;
23
    		}
28
    		}
24
    	}
29
    	}
-
 
30
		// Modification des titres, légendes et bouton
-
 
31
		$aso_admin_categ['form_legend'] = 'Ajouter une categorie';
-
 
32
		$aso_admin_categ['form_bouton_value'] = 'Ajouter';
-
 
33
		$aso_admin_categ['form_bouton_id'] = 'btn_categorie_ajouter';
-
 
34
		$aso_admin_categ['form_url'] = 'index.php?action=admin-categorie_valider-ajouter';
25
 
35
		
26
    	//echo '<pre>'.print_r($aso_admin_categ, true).'</pre>';
36
    	//echo '<pre>'.print_r($aso_admin_categ, true).'</pre>';
27
		$this->getRegistre()->ajouterDonnee('admin_categorie', $aso_admin_categ);
37
		$this->getRegistre()->ajouterDonnee('admin_categorie', $aso_admin_categ);
28
    }
38
    }
-
 
39
 
-
 
40
	public function executerEditer()
-
 
41
    {
-
 
42
		// Ajout du statut d'utilisateur
-
 
43
		if (isset($_POST['btn_categorie_modifier'])) {
-
 
44
			// Récupération des données de la categorie à modifier
-
 
45
			$ProjetCategorie = new ProjetCategorie();
-
 
46
			$ProjetCategorie->consulter(ProjetCategorie::GPC_ID, $_POST['casu_id'], true);
-
 
47
			$aso_admin_categ['ProjetCategorie'] = $ProjetCategorie;
-
 
48
 
-
 
49
			// Modification des titres, légendes et bouton
-
 
50
			$aso_admin_categ['form_legend'] = 'Modifier une categorie';
-
 
51
			$aso_admin_categ['form_bouton_value'] = 'Modifier';
-
 
52
			$aso_admin_categ['form_bouton_id'] = 'btn_categorie_modifier';
-
 
53
			$aso_admin_categ['form_url'] = 'index.php?action=admin-categorie_valider-modifier';
-
 
54
 
-
 
55
			$this->getRegistre()->ajouterDonnee('admin_categorie', $aso_admin_categ);
-
 
56
		} else if (isset($_POST['btn_utilisateur_supprimer'])) {
-
 
57
			// Action suivante
-
 
58
    		$this->setSuivant('supprimer');
-
 
59
		}
-
 
60
    }
-
 
61
 
-
 
62
	public function executerValiderModifier()
-
 
63
	{
-
 
64
		if (isset($_POST['btn_categorie_annuler'])) {
-
 
65
			// Action suivante
-
 
66
    		$this->setSuivant('__defaut__');
-
 
67
    	} else if (isset($_POST['btn_categorie_modifier'])) {
-
 
68
			$ProjetCategorie = new ProjetCategorie();
-
 
69
			$ProjetCategorie->setIdCategorie($_POST['caaj_id_categorie']);
-
 
70
			$ProjetCategorie->setLibelle($_POST['caaj_libelle']);
-
 
71
			$ProjetCategorie->setAbreviation($_POST['caaj_abreviation']);
-
 
72
	    	$ProjetCategorie->modifier();
-
 
73
		}
-
 
74
	}
29
 
75
	
30
    public function executerValiderAjouter()
76
    public function executerValiderAjouter()
31
    {
77
    {
32
		// Ajout de la catégorie
78
		// Ajout de la catégorie
33
		$ProjetCategorie = new ProjetCategorie();
79
		$ProjetCategorie = new ProjetCategorie();
34
		$bool_existe = $ProjetCategorie->consulter(ProjetCategorie::GPC_LIBELLE, array($_POST['caaj_libelle']));
80
		$bool_existe = $ProjetCategorie->consulter(ProjetCategorie::GPC_LIBELLE, array($_POST['caaj_libelle']));
35
		if ($bool_existe == false) {
81
		if ($bool_existe == false) {
36
			$ProjetCategorieMax = $ProjetCategorie->consulter(ProjetCategorie::GPC_ID_MAX);
82
			$ProjetCategorieMax = $ProjetCategorie->consulter(ProjetCategorie::GPC_ID_MAX);
37
			$id_max = $ProjetCategorieMax->getIdCategorie();
83
			$id_max = $ProjetCategorieMax->getIdCategorie();
38
			$ProjetCategorie->setIdCategorie(++$id_max);
84
			$ProjetCategorie->setIdCategorie(++$id_max);
39
			$ProjetCategorie->setLibelle($_POST['caaj_libelle']);
85
			$ProjetCategorie->setLibelle($_POST['caaj_libelle']);
-
 
86
			$ProjetCategorie->setAbreviation($_POST['caaj_abreviation']);
40
    		$ProjetCategorie->ajouter();
87
    		$ProjetCategorie->ajouter();
41
		} else {
88
		} else {
42
			$aso_admin_categ['message'] = 'Cette catégorie existe déjà !';
89
			$aso_admin_categ['message'] = 'Cette catégorie existe déjà !';
43
			$this->getRegistre()->ajouterDonnee('admin_categorie', $aso_admin_categ);
90
			$this->getRegistre()->ajouterDonnee('admin_categorie', $aso_admin_categ);
44
		}
91
		}
45
 
92
 
46
		// Action suivante
93
		// Action suivante
47
    	$this->setSuivant('__defaut__');
94
    	$this->setSuivant('__defaut__');
48
    }
95
    }
49
 
96
 
50
    public function executerValiderSupprimer()
97
    public function executerValiderSupprimer()
51
    {
98
    {
52
		// Suppression de la catégorie
99
		// Suppression de la catégorie
53
		$ProjetCategorie = new ProjetCategorie();
100
		$ProjetCategorie = new ProjetCategorie();
54
		$ProjetCategorie->setIdCategorie($_POST['casu_id']);
101
		$ProjetCategorie->setIdCategorie($_POST['casu_id']);
55
    	$ProjetCategorie->supprimer();
102
    	$ProjetCategorie->supprimer();
56
 
103
 
57
		// Mise à jour des projets appartenant à la catégorie
104
		// Mise à jour des projets appartenant à la catégorie
58
		$Projet = new Projet();
105
		$Projet = new Projet();
59
		$tab_p = $Projet->consulter(Projet::GP_CE_CATEGORIE, $_POST['casu_id']);
106
		$tab_p = $Projet->consulter(Projet::GP_CE_CATEGORIE, $_POST['casu_id']);
60
		if ($tab_p != false) {
107
		if ($tab_p != false) {
61
			if ($tab_p && count($tab_p) == 1) {
108
			if ($tab_p && count($tab_p) == 1) {
62
				$tab_p = array($tab_p);
109
				$tab_p = array($tab_p);
63
			}
110
			}
64
			foreach ($tab_p as $p) {
111
			foreach ($tab_p as $p) {
65
	    		$Ancien = clone $p;
112
	    		$Ancien = clone $p;
66
	    		$p->setCeCategorie(0);
113
	    		$p->setCeCategorie(0);
67
	    		$p->modifier($Ancien);
114
	    		$p->modifier($Ancien);
68
	    	}
115
	    	}
69
		}
116
		}
70
 
117
 
71
		// Action suivante
118
		// Action suivante
72
    	$this->setSuivant('__defaut__');
119
    	$this->setSuivant('__defaut__');
73
    }
120
    }
74
}
121
}
75
?>
122
?>