Subversion Repositories Applications.gtt

Rev

Rev 64 | Rev 75 | Go to most recent revision | Details | Compare with Previous | Last modification | View Log | RSS feed

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