Subversion Repositories Applications.gtt

Rev

Rev 103 | Rev 177 | Go to most recent revision | Only display areas with differences | Ignore whitespace | Details | Blame | Last modification | View Log | RSS feed

Rev 103 Rev 109
1
<?php
1
<?php
2
class GttCtrlActionPreferences extends aControlleurAction {
2
class GttCtrlActionPreferences extends aControlleurAction {
3
 
3
 
4
    public function __construct(Registre $Registre)
4
    public function __construct(Registre $Registre)
5
    {
5
    {
6
    	$Registre->ajouterEspace('Preferences', 'preferences');
6
    	$Registre->ajouterEspace('Preferences', 'preferences');
7
    	$Registre->ajouterSquelette('preferences', 'preferences.tpl.html');
7
    	$Registre->ajouterSquelette('preferences', 'preferences.tpl.html');
8
    }
8
    }
9
 
9
 
10
    public function executer()
10
    public function executer()
11
    {
11
    {
12
    	$aso_preferences = array();
12
    	$aso_preferences = array();
13
    	$this->getRegistre()->setTitre('Modifier mes préférences');
13
    	$this->getRegistre()->setTitre('Modifier mes préférences');
14
    	$Projet = new Projet();
14
    	$Projet = new Projet();
15
    	$tab_projets = $Projet->consulter(Projet::GP_TOUS);
15
    	$tab_projets = $Projet->consulter(Projet::GP_TOUS);
16
 
16
 
17
		if (false == $tab_projets) {
17
		if (false == $tab_projets) {
18
			$aso_preferences['messages'][] = "Veuillez commencer par ajouter des catégories de projet et des projets !";
18
			$aso_preferences['messages'][] = "Veuillez commencer par ajouter des catégories de projet et des projets !";
19
			$aso_preferences['preferences'] = false;
19
			$aso_preferences['preferences'] = false;
20
		} else {
20
		} else {
21
    		$aso_preferences['nbre_projets'] = count($tab_projets);
21
    		$aso_preferences['nbre_projets'] = count($tab_projets);
22
			// Parcourt du tableau de projets
22
			// Parcourt du tableau de projets
23
	    	foreach ($tab_projets as $Projet) {
23
	    	foreach ($tab_projets as $Projet) {
24
				// Vérification de la présence du projet dans les préférences de l'utilisateur
24
				// Vérification de la présence du projet dans les préférences de l'utilisateur
25
				$UtilisateurAProjet = new UtilisateurAProjet();
25
				$UtilisateurAProjet = new UtilisateurAProjet();
26
				$cmd = UtilisateurAProjet::GUAP_ID;
26
				$cmd = UtilisateurAProjet::GUAP_ID;
27
				$param = array($GLOBALS['_GTT_']['Utilisateur']->getIdUtilisateur(), $Projet->getIdProjet());
27
				$param = array($GLOBALS['_GTT_']['Utilisateur']->getIdUtilisateur(), $Projet->getIdProjet());
28
				$coche = false;
28
				$coche = false;
29
				if ($present = $UtilisateurAProjet->consulter($cmd, $param)) {
29
				if ($present = $UtilisateurAProjet->consulter($cmd, $param)) {
30
					$coche = true;
30
					$coche = true;
31
				}
31
				}
32
	
32
	
33
				// Récupération de la catégorie du projet
33
				// Récupération de la catégorie du projet
34
				$ProjetCategorie = new ProjetCategorie();
34
				$ProjetCategorie = new ProjetCategorie();
35
				$Categorie = current($ProjetCategorie->consulter(ProjetCategorie::GPC_ID, $Projet->getCeCategorie()));
35
				$Categorie = current($ProjetCategorie->consulter(ProjetCategorie::GPC_ID, $Projet->getCeCategorie()));
36
	
36
	
37
				// Récupération de toutes les infos
37
				// Récupération de toutes les infos
38
				$aso_preferences['preferences'][$Categorie->getLibelle()][] = array(
38
				$aso_preferences['preferences'][$Categorie->getLibelle()][] = array(
39
					'id' => $Projet->getIdProjet(),
39
					'id' => $Projet->getIdProjet(),
40
					'valeur' => $Projet->getIdProjet(),
40
					'valeur' => $Projet->getIdProjet(),
41
					'nom' => $Projet->getNom(),
41
					'no' => $Projet->getNom(),
-
 
42
					'de' => $Projet->getDescription(),
-
 
43
					'dade' => $Projet->getDateDebut(),
-
 
44
					'dafi' => $Projet->getDateFin(),
-
 
45
					'dupr' => $Projet->getDureePrevue(),
-
 
46
					'dufi' => $Projet->getDureeFinance(),
-
 
47
					'av' => $Projet->getAvancement(),
42
					'coche' => $coche);
48
					'coche' => $coche);
43
	    	}
49
	    	}
44
	    	ksort($aso_preferences['preferences']);
50
	    	ksort($aso_preferences['preferences']);
45
		}
51
		}
46
		
52
		
47
    	//echo '<pre>'.print_r($aso_preferences, true).'</pre>';
53
    	//echo '<pre>'.print_r($aso_preferences, true).'</pre>';
48
		$this->getRegistre()->ajouterDonnee('preferences', $aso_preferences);
54
		$this->getRegistre()->ajouterDonnee('preferences', $aso_preferences);
49
    }
55
    }
50
 
56
 
51
    public function executerValider()
57
    public function executerValider()
52
    {
58
    {
53
    	// Mise à jour des Préférences
59
    	// Mise à jour des Préférences
54
    	$UtilisateurAProjet = new UtilisateurAProjet();
60
    	$UtilisateurAProjet = new UtilisateurAProjet();
55
    	$UtilisateurAProjet->setIdUtilisateur($GLOBALS['_GTT_']['Utilisateur']->getIdUtilisateur());
61
    	$UtilisateurAProjet->setIdUtilisateur($GLOBALS['_GTT_']['Utilisateur']->getIdUtilisateur());
56
    	$UtilisateurAProjet->supprimer();
62
    	$UtilisateurAProjet->supprimer();
57
    	//echo '<pre>'.print_r($_POST, true).'</pre>';
63
    	//echo '<pre>'.print_r($_POST, true).'</pre>';
58
    	if (isset($_POST['pr'])) {
64
    	if (isset($_POST['pr'])) {
59
	    	foreach ($_POST['pr'] as $pr_id) {
65
	    	foreach ($_POST['pr'] as $pr_id) {
60
	    		$UtilisateurAProjet = new UtilisateurAProjet();
66
	    		$UtilisateurAProjet = new UtilisateurAProjet();
61
				$UtilisateurAProjet->setIdUtilisateur($GLOBALS['_GTT_']['Utilisateur']->getIdUtilisateur());
67
				$UtilisateurAProjet->setIdUtilisateur($GLOBALS['_GTT_']['Utilisateur']->getIdUtilisateur());
62
				$UtilisateurAProjet->setIdProjet($pr_id);
68
				$UtilisateurAProjet->setIdProjet($pr_id);
63
				$UtilisateurAProjet->ajouter();
69
				$UtilisateurAProjet->ajouter();
64
	    	}
70
	    	}
65
    	}
71
    	}
66
    	
72
    	
67
    	// Action suivante
73
    	// Action suivante
68
    	$this->setSuivant('__defaut__');
74
    	$this->setSuivant('__defaut__');
69
    }
75
    }
70
}
76
}
71
?>
77
?>