Subversion Repositories Applications.gtt

Rev

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