Subversion Repositories Applications.gtt

Rev

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

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