Subversion Repositories Applications.gtt

Rev

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

Rev Author Line No. Line
10 jpm 1
<?php
170 mathias 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
// +------------------------------------------------------------------------------------------------------+
10 jpm 23
// CVS : $Id$
170 mathias 24
/**
10 jpm 25
* Classe Projet
170 mathias 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
10 jpm 39
*@version       $Revision$ $Date$
170 mathias 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 : */
10 jpm 49
	const GP_TOUS = 'PROJET_TOUS';
71 jpm 50
	const GP_ID = 'PROJET_ID';
170 mathias 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';
170 mathias 54
	const GP_CE_CATEGORIE = 'PROJET_CE_CATEGORIE';
55
 
56
	/*** Attributs : */
57
	private $id_projet;
82 jpm 58
	private $ce_projet_parent;
170 mathias 59
	private $ce_categorie;
60
	private $nom;
61
	private $description;
82 jpm 62
	private $date_debut;
170 mathias 63
	private $date_fin;
108 jpm 64
	private $duree_prevue;
170 mathias 65
	private $duree_finance;
66
	private $avancement;
67
 
68
	/*** Aggregations : */
69
 
70
	/*** Constructeur : */
71
	public function __construct($cmd = null, $parametres = null)
72
	{
73
		$this->dao_table_nom = GTT_BDD_PREFIXE . 'gestion_projet';
74
		$this->dao_correspondance = array(
10 jpm 75
			'gp_id_projet'	=> 'id_projet',
82 jpm 76
			'gp_ce_projet_parent'	=> 'ce_projet_parent',
10 jpm 77
			'gp_ce_categorie'	=> 'ce_categorie',
82 jpm 78
			'gp_nom'	=> 'nom',
10 jpm 79
			'gp_description'	=> 'description',
80
			'gp_date_debut'	=> 'date_debut',
82 jpm 81
			'gp_date_fin'	=> 'date_fin',
10 jpm 82
			'gp_duree_prevue'	=> 'duree_prevue',
108 jpm 83
			'gp_duree_finance'	=> 'duree_finance',
10 jpm 84
			'gp_avancement'	=> 'avancement');
170 mathias 85
 
86
		// Si l'on veut remplir l'objet à la création on lance la requete correspondante
87
		if (!is_null($cmd)) {
88
			$this->consulter($cmd, $parametres, true);
89
		}
90
	}
91
 
92
	/*** Accesseurs : */
10 jpm 93
	// Id Projet
170 mathias 94
	public function getIdProjet()
95
	{
96
		return $this->id_projet;
97
	}
98
	public function setIdProjet( $ip )
99
	{
100
		$this->id_projet = $ip;
101
	}
82 jpm 102
 
103
	// Ce Projet Parent
104
	public function getCeProjetParent()
105
	{
106
		return $this->ce_projet_parent;
107
	}
108
	public function setCeProjetParent( $cpp )
109
	{
110
		$this->ce_projet_parent = $cpp;
111
	}
112
 
170 mathias 113
 
10 jpm 114
	// Ce Categorie
170 mathias 115
	public function getCeCategorie()
116
	{
117
		return $this->ce_categorie;
118
	}
119
	public function setCeCategorie( $cc )
120
	{
121
		$this->ce_categorie = $cc;
122
	}
123
 
82 jpm 124
	// Nom
170 mathias 125
	public function getNom()
126
	{
127
		return $this->nom;
128
	}
129
	public function setNom( $n )
130
	{
131
		$this->nom = $n;
132
	}
133
 
10 jpm 134
	// Description
170 mathias 135
	public function getDescription()
136
	{
137
		return $this->description;
138
	}
139
	public function setDescription( $d )
140
	{
141
		$this->description = $d;
142
	}
143
 
10 jpm 144
	// Date Debut
170 mathias 145
	public function getDateDebut()
146
	{
147
		return $this->date_debut;
85 jpm 148
	}
170 mathias 149
	public function setDateDebut( $dd )
150
	{
151
		$this->date_debut = $dd;
152
	}
85 jpm 153
 
154
	// Date Fin
155
	public function getDateFin()
156
	{
157
		return $this->date_fin;
158
	}
159
	public function setDateFin( $df )
160
	{
161
		$this->date_fin = $df;
170 mathias 162
	}
163
 
10 jpm 164
	// Duree Prevue
170 mathias 165
	public function getDureePrevue()
166
	{
167
		return $this->duree_prevue;
168
	}
169
	public function setDureePrevue( $dp )
170
	{
171
		$this->duree_prevue = $dp;
172
	}
108 jpm 173
 
174
	// Duree Finance
175
	public function getDureeFinance()
176
	{
177
		return $this->duree_finance;
178
	}
179
	public function setDureeFinance( $df )
180
	{
181
		$this->duree_finance = $df;
182
	}
170 mathias 183
 
10 jpm 184
	// Avancement
170 mathias 185
	public function getAvancement()
75 jpm 186
	{
170 mathias 187
		return $this->avancement;
188
	}
189
	public function setAvancement( $a )
190
	{
191
		$this->avancement = $a;
192
	}
193
 
177 mathias 194
	/**
195
	 * Calcule l'avancement d'un projet en pourcentage, en fonction du nombre
196
	 * d'heures déclaré et du nombre d'heures effectuées (tous utilisateurs
197
	 * confondus) - @TODO devrait devenir une vue / être requêté au moment de
198
	 * charger le projet
199
	 */
200
	public function getAvancementCalcule()
201
	{
202
		$avancementCalcule = null;
203
 
204
		$requete = "SELECT IFNULL(FLOOR(sum(gtp_duree) / 7), 0) as jours"
178 mathias 205
			. " FROM " . GTT_BDD_PREFIXE . "gtt_test_gestion_travail_projet"
177 mathias 206
			. " WHERE gtp_id_projet = " . $this->id_projet;
207
 
208
		$resultat = $GLOBALS['db']->query($requete);
209
		(DB::isError($resultat)) ? trigger_error(GestionnaireErreur::retournerErreurSql(__FILE__, __LINE__, $resultat->getMessage(), $requete), E_USER_ERROR) : '' ;
210
		while ($donnees =& $resultat->fetchRow(DB_FETCHMODE_ASSOC)) {
211
			$avancementCalcule = $donnees['jours'];
212
		}
213
 
214
		return $avancementCalcule;
215
	}
216
 
170 mathias 217
	/*** Méthodes : */
218
 
219
	/**
220
	* Consulter la table gestion_projet.
221
	* @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.
222
	*/
223
	public function consulter($cmd = '', $parametres = array(), $instancier = false)
224
	{
10 jpm 225
		switch ($cmd) {
226
			case Projet::GP_TOUS:
227
				$requete =	'SELECT * '.
170 mathias 228
							'FROM ' . GTT_BDD_PREFIXE . 'gestion_projet LEFT JOIN ' . GTT_BDD_PREFIXE . 'gestion_projet_categorie ON (gp_ce_categorie = gpc_id_categorie) '.
141 jpm 229
							'ORDER BY gpc_libelle, gp_nom ASC';
71 jpm 230
				break;
170 mathias 231
			case Projet::GP_ID:
232
				$requete = 	'SELECT * '.
233
							'FROM ' . GTT_BDD_PREFIXE . 'gestion_projet '.
234
							'WHERE gp_id_projet =  #0 ';
235
				break;
71 jpm 236
			case Projet::GP_NOM:
237
				$requete =	'SELECT * '.
170 mathias 238
							'FROM ' . GTT_BDD_PREFIXE . 'gestion_projet '.
85 jpm 239
							'WHERE gp_nom = "#0" ';
11 jpm 240
				break;
170 mathias 241
			case Projet::GP_ID_MAX:
242
				$requete =	'SELECT MAX(gp_id_projet) AS gp_id_projet '.
243
							'FROM ' . GTT_BDD_PREFIXE . 'gestion_projet ';
244
				break;
11 jpm 245
			case Projet::GP_ID_LIST:
246
				$requete =	'SELECT * '.
170 mathias 247
							'FROM ' . GTT_BDD_PREFIXE . 'gestion_projet LEFT JOIN ' . GTT_BDD_PREFIXE . 'gestion_projet_categorie ON (gp_ce_categorie = gpc_id_categorie) '.
130 jpm 248
							'WHERE gp_id_projet IN (#0) '.
141 jpm 249
							'ORDER BY gpc_libelle, gp_nom ASC';
48 jpm 250
				break;
251
			case Projet::GP_CE_CATEGORIE:
252
				$requete =	'SELECT * '.
170 mathias 253
							'FROM ' . GTT_BDD_PREFIXE . 'gestion_projet '.
75 jpm 254
							'WHERE gp_ce_categorie = #0 ';
170 mathias 255
				break;
256
			default :
257
				$message = 'Commande '.$cmd.'inconnue!';
258
				$e = GestionnaireErreur::formaterMessageErreur(__FILE__, __LINE__, $message);
259
    			trigger_error($e, E_USER_ERROR);
260
		}
75 jpm 261
		return parent::consulter($requete, $parametres, $instancier);
170 mathias 262
	}
263
}
264
 
265
/* +--Fin du code ----------------------------------------------------------------------------------------+
266
*
10 jpm 267
* $Log$
170 mathias 268
*
269
* +-- Fin du code ----------------------------------------------------------------------------------------+
270
*/
10 jpm 271
?>