Subversion Repositories Applications.gtt

Rev

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

Rev 71 Rev 75
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_NOM = 'PROJET_NOM';
51
	const GP_NOM = 'PROJET_NOM';
52
	const GP_ID_MAX = 'PROJET_ID_MAX';
52
	const GP_ID_MAX = 'PROJET_ID_MAX';
53
	const GP_ID_LIST = 'PROJET_ID_LIST';
53
	const GP_ID_LIST = 'PROJET_ID_LIST';
54
	const GP_CE_CATEGORIE = 'PROJET_CE_CATEGORIE';
54
	const GP_CE_CATEGORIE = 'PROJET_CE_CATEGORIE';
55
 
55
 
56
	/*** Attributs : */
56
	/*** Attributs : */
57
	private $id_projet;
57
	private $id_projet;
58
	private $ce_categorie;
58
	private $ce_categorie;
59
	private $nom_projet;
59
	private $nom_projet;
60
	private $description;
60
	private $description;
61
	private $date_debut;
61
	private $date_debut;
62
	private $duree_prevue;
62
	private $duree_prevue;
63
	private $avancement;
63
	private $avancement;
64
 
64
 
65
	/*** Aggregations : */
65
	/*** Aggregations : */
66
 
66
 
67
	/*** Constructeur : */
67
	/*** Constructeur : */
68
	public function __construct($cmd = null, $parametres = null)
68
	public function __construct($cmd = null, $parametres = null)
69
	{
69
	{
70
		$this->dao_table_nom = 'gestion_projet';
70
		$this->dao_table_nom = 'gestion_projet';
71
		$this->dao_correspondance = array(
71
		$this->dao_correspondance = array(
72
			'gp_id_projet'	=> 'id_projet',
72
			'gp_id_projet'	=> 'id_projet',
73
			'gp_ce_categorie'	=> 'ce_categorie',
73
			'gp_ce_categorie'	=> 'ce_categorie',
74
			'gp_nom_projet'	=> 'nom_projet',
74
			'gp_nom_projet'	=> 'nom_projet',
75
			'gp_description'	=> 'description',
75
			'gp_description'	=> 'description',
76
			'gp_date_debut'	=> 'date_debut',
76
			'gp_date_debut'	=> 'date_debut',
77
			'gp_duree_prevue'	=> 'duree_prevue',
77
			'gp_duree_prevue'	=> 'duree_prevue',
78
			'gp_avancement'	=> 'avancement');
78
			'gp_avancement'	=> 'avancement');
79
 
79
 
80
		// Si l'on veut remplir l'objet à la création on lance la requete correspondante
80
		// Si l'on veut remplir l'objet à la création on lance la requete correspondante
81
		if (!is_null($cmd)) {
81
		if (!is_null($cmd)) {
82
			$this->consulter($cmd, $parametres, true);
82
			$this->consulter($cmd, $parametres, true);
83
		}
83
		}
84
	}
84
	}
85
 
85
 
86
	/*** Accesseurs : */
86
	/*** Accesseurs : */
87
	// Id Projet
87
	// Id Projet
88
	public function getIdProjet()
88
	public function getIdProjet()
89
	{
89
	{
90
		return $this->id_projet;
90
		return $this->id_projet;
91
	}
91
	}
92
	public function setIdProjet( $ip )
92
	public function setIdProjet( $ip )
93
	{
93
	{
94
		$this->id_projet = $ip;
94
		$this->id_projet = $ip;
95
	}
95
	}
96
 
96
 
97
	// Ce Categorie
97
	// Ce Categorie
98
	public function getCeCategorie()
98
	public function getCeCategorie()
99
	{
99
	{
100
		return $this->ce_categorie;
100
		return $this->ce_categorie;
101
	}
101
	}
102
	public function setCeCategorie( $cc )
102
	public function setCeCategorie( $cc )
103
	{
103
	{
104
		$this->ce_categorie = $cc;
104
		$this->ce_categorie = $cc;
105
	}
105
	}
106
 
106
 
107
	// Nom Projet
107
	// Nom Projet
108
	public function getNomProjet()
108
	public function getNomProjet()
109
	{
109
	{
110
		return $this->nom_projet;
110
		return $this->nom_projet;
111
	}
111
	}
112
	public function setNomProjet( $np )
112
	public function setNomProjet( $np )
113
	{
113
	{
114
		$this->nom_projet = $np;
114
		$this->nom_projet = $np;
115
	}
115
	}
116
 
116
 
117
	// Description
117
	// Description
118
	public function getDescription()
118
	public function getDescription()
119
	{
119
	{
120
		return $this->description;
120
		return $this->description;
121
	}
121
	}
122
	public function setDescription( $d )
122
	public function setDescription( $d )
123
	{
123
	{
124
		$this->description = $d;
124
		$this->description = $d;
125
	}
125
	}
126
 
126
 
127
	// Date Debut
127
	// Date Debut
128
	public function getDateDebut()
128
	public function getDateDebut()
129
	{
129
	{
130
		return $this->date_debut;
130
		return $this->date_debut;
131
	}
131
	}
132
	public function setDateDebut( $dd )
132
	public function setDateDebut( $dd )
133
	{
133
	{
134
		$this->date_debut = $dd;
134
		$this->date_debut = $dd;
135
	}
135
	}
136
 
136
 
137
	// Duree Prevue
137
	// Duree Prevue
138
	public function getDureePrevue()
138
	public function getDureePrevue()
139
	{
139
	{
140
		return $this->duree_prevue;
140
		return $this->duree_prevue;
141
	}
141
	}
142
	public function setDureePrevue( $dp )
142
	public function setDureePrevue( $dp )
143
	{
143
	{
144
		$this->duree_prevue = $dp;
144
		$this->duree_prevue = $dp;
145
	}
145
	}
146
 
146
 
147
	// Avancement
147
	// Avancement
148
	public function getAvancement()
148
	public function getAvancement()
149
	{
149
	{
150
		return $this->avancement;
150
		return $this->avancement;
151
	}
151
	}
152
	public function setAvancement( $a )
152
	public function setAvancement( $a )
153
	{
153
	{
154
		$this->avancement = $a;
154
		$this->avancement = $a;
155
	}
155
	}
156
 
156
 
157
	/*** Méthodes : */
157
	/*** Méthodes : */
158
 
158
 
159
	/**
159
	/**
160
	* Consulter la table gestion_projet.
160
	* Consulter la table gestion_projet.
161
	* @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.
161
	* @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.
162
	*/
162
	*/
163
	public function consulter($cmd = '', $parametres = array(), $instancier = false)
163
	public function consulter($cmd = '', $parametres = array(), $instancier = false)
164
	{
164
	{
165
		if (!is_array($parametres)) {
-
 
166
			$parametres[0] = $parametres;
-
 
167
		}
-
 
168
		switch ($cmd) {
165
		switch ($cmd) {
169
			case Projet::GP_TOUS:
166
			case Projet::GP_TOUS:
170
				$requete =	'SELECT * '.
167
				$requete =	'SELECT * '.
171
							'FROM gestion_projet ';
168
							'FROM gestion_projet ';
172
				break;
169
				break;
173
			case Projet::GP_ID:
170
			case Projet::GP_ID:
174
				$requete = 	'SELECT * '.
171
				$requete = 	'SELECT * '.
175
							'FROM gestion_projet '.
172
							'FROM gestion_projet '.
176
							'WHERE gp_id_projet = '.$parametres[0].' ';
173
							'WHERE gp_id_projet =  #0 ';
177
				break;
174
				break;
178
			case Projet::GP_NOM:
175
			case Projet::GP_NOM:
179
				$requete =	'SELECT * '.
176
				$requete =	'SELECT * '.
180
							'FROM gestion_projet '.
177
							'FROM gestion_projet '.
181
							'WHERE gp_nom_projet = "'.$parametres[0].'" ';
178
							'WHERE gp_nom_projet = "#0" ';
182
				break;
179
				break;
183
			case Projet::GP_ID_MAX:
180
			case Projet::GP_ID_MAX:
184
				$requete =	'SELECT MAX(gp_id_projet) AS gp_id_projet '.
181
				$requete =	'SELECT MAX(gp_id_projet) AS gp_id_projet '.
185
							'FROM gestion_projet ';
182
							'FROM gestion_projet ';
186
				break;
183
				break;
187
			case Projet::GP_ID_LIST:
184
			case Projet::GP_ID_LIST:
188
				$requete =	'SELECT * '.
185
				$requete =	'SELECT * '.
189
							'FROM gestion_projet '.
186
							'FROM gestion_projet '.
190
							'WHERE gp_id_projet IN ('.$parametres[0].') ';
187
							'WHERE gp_id_projet IN (#0) ';
191
				break;
188
				break;
192
			case Projet::GP_CE_CATEGORIE:
189
			case Projet::GP_CE_CATEGORIE:
193
				$requete =	'SELECT * '.
190
				$requete =	'SELECT * '.
194
							'FROM gestion_projet '.
191
							'FROM gestion_projet '.
195
							'WHERE gp_ce_categorie = '.$parametres[0].' ';
192
							'WHERE gp_ce_categorie = #0 ';
196
				break;
193
				break;
197
			default :
194
			default :
198
				$message = 'Commande '.$cmd.'inconnue!';
195
				$message = 'Commande '.$cmd.'inconnue!';
199
				$e = GestionnaireErreur::formaterMessageErreur(__FILE__, __LINE__, $message);
196
				$e = GestionnaireErreur::formaterMessageErreur(__FILE__, __LINE__, $message);
200
    			trigger_error($e, E_USER_ERROR);
197
    			trigger_error($e, E_USER_ERROR);
201
		}
198
		}
202
		$resultat = $GLOBALS['db']->query($requete);
-
 
203
		(DB::isError($resultat)) ? die (GestionnaireErreur::retournerErreurSql(__FILE__, __LINE__, $resultat->getMessage(), $requete)) : '' ;
-
 
204
		$tab_resultat = array();
-
 
205
		while ($donnees =& $resultat->fetchRow(DB_FETCHMODE_ASSOC)) {
-
 
206
			$tab_resultat[] = $this->basculerEnregistrementObjet($donnees, $instancier);
199
		return parent::consulter($requete, $parametres, $instancier);
207
		}
-
 
208
 
-
 
209
		$resultat_nbre = count($tab_resultat);
-
 
210
		if ($resultat_nbre > 1) {
-
 
211
			return $tab_resultat;
-
 
212
		} else if ($resultat_nbre == 1) {
-
 
213
			return $tab_resultat[0];
-
 
214
		} else if ($resultat_nbre == 0) {
-
 
215
			return false;
-
 
216
		}
-
 
217
	}
200
	}
218
 
201
 
219
	/** Afficher l'objet Projet */
202
	/** Afficher l'objet Projet */
220
	function afficherProjet()
203
	function afficherProjet()
221
	{
204
	{
222
		echo '<pre>'.print_r($this, true).'</pre>';
205
		echo '<pre>'.print_r($this, true).'</pre>';
223
	}
206
	}
224
}
207
}
225
 
208
 
226
/* +--Fin du code ----------------------------------------------------------------------------------------+
209
/* +--Fin du code ----------------------------------------------------------------------------------------+
227
*
210
*
228
* $Log$
211
* $Log$
229
*
212
*
230
* +-- Fin du code ----------------------------------------------------------------------------------------+
213
* +-- Fin du code ----------------------------------------------------------------------------------------+
231
*/
214
*/
232
?>
215
?>