Subversion Repositories Applications.gtt

Rev

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