Subversion Repositories Applications.gtt

Rev

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

Rev 10 Rev 11
1
<?php
1
<?php
2
// +------------------------------------------------------------------------------------------------------+
2
// +------------------------------------------------------------------------------------------------------+
3
// | PHP version 5.1.1                                                                                    |
3
// | PHP version 5.1.1                                                                                    |
4
// +------------------------------------------------------------------------------------------------------+
4
// +------------------------------------------------------------------------------------------------------+
5
// | Copyright (C) 2006 Tela Botanica (accueil@tela-botanica.org)                                         |
5
// | Copyright (C) 2006 Tela Botanica (accueil@tela-botanica.org)                                         |
6
// +------------------------------------------------------------------------------------------------------+
6
// +------------------------------------------------------------------------------------------------------+
7
// | This file is part of eFlore.                                                                         |
7
// | This file is part of eFlore.                                                                         |
8
// |                                                                                                      |
8
// |                                                                                                      |
9
// | Foobar is free software; you can redistribute it and/or modify                                       |
9
// | Foobar is free software; you can redistribute it and/or modify                                       |
10
// | it under the terms of the GNU General Public License as published by                                 |
10
// | it under the terms of the GNU General Public License as published by                                 |
11
// | the Free Software Foundation; either version 2 of the License, or                                    |
11
// | the Free Software Foundation; either version 2 of the License, or                                    |
12
// | (at your option) any later version.                                                                  |
12
// | (at your option) any later version.                                                                  |
13
// |                                                                                                      |
13
// |                                                                                                      |
14
// | Foobar is distributed in the hope that it will be useful,                                            |
14
// | Foobar is distributed in the hope that it will be useful,                                            |
15
// | but WITHOUT ANY WARRANTY; without even the implied warranty of                                       |
15
// | but WITHOUT ANY WARRANTY; without even the implied warranty of                                       |
16
// | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the                                        |
16
// | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the                                        |
17
// | GNU General Public License for more details.                                                         |
17
// | GNU General Public License for more details.                                                         |
18
// |                                                                                                      |
18
// |                                                                                                      |
19
// | You should have received a copy of the GNU General Public License                                    |
19
// | You should have received a copy of the GNU General Public License                                    |
20
// | along with Foobar; if not, write to the Free Software                                                |
20
// | along with Foobar; if not, write to the Free Software                                                |
21
// | Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA                            |
21
// | Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA                            |
22
// +------------------------------------------------------------------------------------------------------+
22
// +------------------------------------------------------------------------------------------------------+
23
// CVS : $Id$
23
// CVS : $Id$
24
/**
24
/**
25
* Classe Projet
25
* Classe Projet
26
*
26
*
27
* Description
27
* Description
28
*
28
*
29
*@package eFlore
29
*@package eFlore
30
*@subpackage modele
30
*@subpackage modele
31
//Auteur original :
31
//Auteur original :
32
*@version 3
32
*@version 3
33
*@author        Shaheen ABDOOL RAHEEM <shaheenar50@hotmail.com>
33
*@author        Shaheen ABDOOL RAHEEM <shaheenar50@hotmail.com>
34
//Autres auteurs :
34
//Autres auteurs :
35
*@version 4
35
*@version 4
36
*@author        Jean-Pascal MILCENT <jpm@clapas.org>
36
*@author        Jean-Pascal MILCENT <jpm@clapas.org>
37
*@author        aucun
37
*@author        aucun
38
*@copyright     Tela-Botanica 2000-2006
38
*@copyright     Tela-Botanica 2000-2006
39
*@version       $Revision$ $Date$
39
*@version       $Revision$ $Date$
40
// +------------------------------------------------------------------------------------------------------+
40
// +------------------------------------------------------------------------------------------------------+
41
*/
41
*/
42
 
42
 
43
/**
43
/**
44
* class Projet : est à la fois le DAO et le conteneur de la table gestion_utilisateur.
44
* class Projet : est à la fois le DAO et le conteneur de la table gestion_utilisateur.
45
* classe métier
45
* classe métier
46
*/
46
*/
47
class Projet extends aGttSql {
47
class Projet extends aGttSql {
48
	/*** Constantes : */
48
	/*** Constantes : */
49
	const GP_TOUS = 'PROJET_TOUS';
49
	const GP_TOUS = 'PROJET_TOUS';
50
	const GP_ID = 'PROJET_ID';
50
	const GP_ID = 'PROJET_ID';
51
	const GP_ID_MAX = 'PROJET_ID_MAX';
51
	const GP_ID_MAX = 'PROJET_ID_MAX';
-
 
52
	const GP_ID_LIST = 'PROJET_ID_LIST';
52
	
53
	
53
	/*** Attributs : */
54
	/*** Attributs : */
54
	private $id_projet;
55
	private $id_projet;
55
	private $ce_categorie;
56
	private $ce_categorie;
56
	private $nom_projet;
57
	private $nom_projet;
57
	private $description;
58
	private $description;
58
	private $date_debut;
59
	private $date_debut;
59
	private $duree_prevue;
60
	private $duree_prevue;
60
	private $avancement;
61
	private $avancement;
61
	
62
	
62
	/*** Aggregations : */
63
	/*** Aggregations : */
63
 
64
 
64
	/*** Constructeur : */
65
	/*** Constructeur : */
65
	public function __construct($cmd = null, $parametres = null)
66
	public function __construct($cmd = null, $parametres = null)
66
	{
67
	{
67
		$this->dao_table_nom = 'gestion_projet';
68
		$this->dao_table_nom = 'gestion_projet';
68
		$this->dao_correspondance = array(
69
		$this->dao_correspondance = array(
69
			'gp_id_projet'	=> 'id_projet',
70
			'gp_id_projet'	=> 'id_projet',
70
			'gp_ce_categorie'	=> 'ce_categorie',
71
			'gp_ce_categorie'	=> 'ce_categorie',
71
			'gp_nom_projet'	=> 'nom_projet',
72
			'gp_nom_projet'	=> 'nom_projet',
72
			'gp_description'	=> 'description',
73
			'gp_description'	=> 'description',
73
			'gp_date_debut'	=> 'date_debut',
74
			'gp_date_debut'	=> 'date_debut',
74
			'gp_duree_prevue'	=> 'duree_prevue',
75
			'gp_duree_prevue'	=> 'duree_prevue',
75
			'gp_avancement'	=> 'avancement');
76
			'gp_avancement'	=> 'avancement');
76
		
77
		
77
		// Si l'on veut remplir l'objet à la création on lance la requete correspondante
78
		// Si l'on veut remplir l'objet à la création on lance la requete correspondante
78
		if (!is_null($cmd)) {
79
		if (!is_null($cmd)) {
79
			$this->consulter($cmd, $parametres, true);
80
			$this->consulter($cmd, $parametres, true);
80
		}
81
		}
81
	}
82
	}
82
	
83
	
83
	/*** Accesseurs : */
84
	/*** Accesseurs : */
84
	// Id Projet
85
	// Id Projet
85
	public function getIdProjet()
86
	public function getIdProjet()
86
	{
87
	{
87
		return $this->id_projet;
88
		return $this->id_projet;
88
	}
89
	}
89
	public function setIdProjet( $ip )
90
	public function setIdProjet( $ip )
90
	{
91
	{
91
		$this->id_projet = $ip;
92
		$this->id_projet = $ip;
92
	}
93
	}
93
	
94
	
94
	// Ce Categorie
95
	// Ce Categorie
95
	public function getCeCategorie()
96
	public function getCeCategorie()
96
	{
97
	{
97
		return $this->ce_categorie;
98
		return $this->ce_categorie;
98
	}
99
	}
99
	public function setCeCategorie( $cc )
100
	public function setCeCategorie( $cc )
100
	{
101
	{
101
		$this->ce_categorie = $cc;
102
		$this->ce_categorie = $cc;
102
	}
103
	}
103
	
104
	
104
	// Nom Projet
105
	// Nom Projet
105
	public function getNomProjet()
106
	public function getNomProjet()
106
	{
107
	{
107
		return $this->nom_projet;
108
		return $this->nom_projet;
108
	}
109
	}
109
	public function setNomProjet( $np )
110
	public function setNomProjet( $np )
110
	{
111
	{
111
		$this->nom_projet = $np;
112
		$this->nom_projet = $np;
112
	}
113
	}
113
	
114
	
114
	// Description
115
	// Description
115
	public function getDescription()
116
	public function getDescription()
116
	{
117
	{
117
		return $this->description;
118
		return $this->description;
118
	}
119
	}
119
	public function setDescription( $d )
120
	public function setDescription( $d )
120
	{
121
	{
121
		$this->description = $d;
122
		$this->description = $d;
122
	}
123
	}
123
	
124
	
124
	// Date Debut
125
	// Date Debut
125
	public function getDateDebut()
126
	public function getDateDebut()
126
	{
127
	{
127
		return $this->date_debut;
128
		return $this->date_debut;
128
	}
129
	}
129
	public function setDateDebut( $dd )
130
	public function setDateDebut( $dd )
130
	{
131
	{
131
		$this->date_debut = $dd;
132
		$this->date_debut = $dd;
132
	}
133
	}
133
	
134
	
134
	// Duree Prevue
135
	// Duree Prevue
135
	public function getDureePrevue()
136
	public function getDureePrevue()
136
	{
137
	{
137
		return $this->duree_prevue;
138
		return $this->duree_prevue;
138
	}
139
	}
139
	public function setDureePrevue( $dp )
140
	public function setDureePrevue( $dp )
140
	{
141
	{
141
		$this->duree_prevue = $dp;
142
		$this->duree_prevue = $dp;
142
	}
143
	}
143
	
144
	
144
	// Avancement
145
	// Avancement
145
	public function getAvancement()
146
	public function getAvancement()
146
	{
147
	{
147
		return $this->avancement;
148
		return $this->avancement;
148
	}
149
	}
149
	public function setAvancement( $a )
150
	public function setAvancement( $a )
150
	{
151
	{
151
		$this->avancement = $a;
152
		$this->avancement = $a;
152
	}
153
	}
153
	
154
	
154
	/*** Méthodes : */
155
	/*** Méthodes : */
155
 
156
 
156
	/**
157
	/**
157
	* Consulter la table gestion_projet.
158
	* Consulter la table gestion_projet.
158
	* @return mixed un tableau d'objets Projet s'il y en a plusieurs, l'objet Projet s'il y en a 1 seul sinon false.
159
	* @return mixed un tableau d'objets Projet s'il y en a plusieurs, l'objet Projet s'il y en a 1 seul sinon false.
159
	*/
160
	*/
160
	public function consulter($cmd = '', $parametres = array(), $instancier = false)
161
	public function consulter($cmd = '', $parametres = array(), $instancier = false)
161
	{
162
	{
162
		if (!is_array($parametres)) {
163
		if (!is_array($parametres)) {
163
			$parametres[0] = $parametres;
164
			$parametres[0] = $parametres;
164
		}
165
		}
165
		switch ($cmd) {
166
		switch ($cmd) {
166
			case Projet::GP_TOUS:
167
			case Projet::GP_TOUS:
167
				$requete =	'SELECT * '.
168
				$requete =	'SELECT * '.
168
							'FROM gestion_projet ';
169
							'FROM gestion_projet ';
169
				break;
170
				break;
170
			case Projet::GP_ID:
171
			case Projet::GP_ID:
171
				$requete = 	'SELECT * '.
172
				$requete = 	'SELECT * '.
172
							'FROM gestion_projet '.
173
							'FROM gestion_projet '.
173
							'WHERE gp_id_projet = '.$parametres[0].' ';
174
							'WHERE gp_id_projet = '.$parametres[0].' ';
174
				break;
175
				break;
175
			case Projet::GP_ID_MAX:
176
			case Projet::GP_ID_MAX:
176
				$requete =	'SELECT MAX(gp_id_projet) '.
177
				$requete =	'SELECT MAX(gp_id_projet) '.
177
							'FROM gestion_projet ';
178
							'FROM gestion_projet ';
-
 
179
				break;
-
 
180
			case Projet::GP_ID_LIST:
-
 
181
				$requete =	'SELECT * '.
-
 
182
							'FROM gestion_projet '.
-
 
183
							'WHERE gp_id_projet IN ('.$parametres[0].') ';
178
				break;
184
				break;
179
			default :
185
			default :
180
				$message = 'Commande '.$cmd.'inconnue!';
186
				$message = 'Commande '.$cmd.'inconnue!';
181
				$e = GestionnaireErreur::formaterMessageErreur(__FILE__, __LINE__, $message);
187
				$e = GestionnaireErreur::formaterMessageErreur(__FILE__, __LINE__, $message);
182
    			trigger_error($e, E_USER_ERROR);
188
    			trigger_error($e, E_USER_ERROR);
183
		}
189
		}
184
		
-
 
185
		$resultat = $GLOBALS['db']->query($requete);
190
		$resultat = $GLOBALS['db']->query($requete);
186
		(DB::isError($resultat)) ? die (GestionnaireErreur::retournerErreurSql(__FILE__, __LINE__, $resultat->getMessage(), $requete)) : '' ;
191
		(DB::isError($resultat)) ? die (GestionnaireErreur::retournerErreurSql(__FILE__, __LINE__, $resultat->getMessage(), $requete)) : '' ;
187
		$tab_resultat = array();
192
		$tab_resultat = array();
188
		while ($donnees =& $resultat->fetchRow(DB_FETCHMODE_ASSOC)) {
193
		while ($donnees =& $resultat->fetchRow(DB_FETCHMODE_ASSOC)) {
189
			$tab_resultat[] = $this->basculerEnregistrementObjet($donnees, $instancier);
194
			$tab_resultat[] = $this->basculerEnregistrementObjet($donnees, $instancier);
190
		}
195
		}
191
				
196
				
192
		$resultat_nbre = count($tab_resultat); 
197
		$resultat_nbre = count($tab_resultat); 
193
		if ($resultat_nbre > 1) {
198
		if ($resultat_nbre > 1) {
194
			return $tab_resultat;
199
			return $tab_resultat;
195
		} else if ($resultat_nbre == 1) {
200
		} else if ($resultat_nbre == 1) {
196
			return $tab_resultat[0];
201
			return $tab_resultat[0];
197
		} else if ($resultat_nbre == 0) {
202
		} else if ($resultat_nbre == 0) {
198
			return false;
203
			return false;
199
		}
204
		}
200
	}
205
	}
201
      
206
      
202
	/** Afficher l'objet Projet */
207
	/** Afficher l'objet Projet */
203
	function afficherProjet()
208
	function afficherProjet()
204
	{
209
	{
205
		echo '<pre>'.print_r($this, true).'</pre>';
210
		echo '<pre>'.print_r($this, true).'</pre>';
206
	}
211
	}
207
}
212
}
208
 
213
 
209
/* +--Fin du code ----------------------------------------------------------------------------------------+
214
/* +--Fin du code ----------------------------------------------------------------------------------------+
210
*
215
*
211
* $Log$
216
* $Log$
212
*
217
*
213
* +-- Fin du code ----------------------------------------------------------------------------------------+
218
* +-- Fin du code ----------------------------------------------------------------------------------------+
214
*/
219
*/
215
?>
220
?>