Subversion Repositories Applications.gtt

Rev

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

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