Subversion Repositories Applications.gtt

Rev

Rev 11 | Go to most recent revision | Details | 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 TravailProjet
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 TravailProjet : est à la fois le DAO et le conteneur de la table gestion_utilisateur.
45
* classe métier
46
*/
47
class TravailProjet extends aGttSql {
48
	/*** Constantes : */
49
	const GTP_ID = 'TRAVAILPROJET_ID';
50
	const GTP_ID_MAX_UTILISATEUR = 'TRAVAILPROJET_ID_MAX_UTILISATEUR';
51
	const GTP_ID_MAX_PROJET = 'TRAVAILPROJET_ID_MAX_PROJET';
52
	const GTP_ID_MAX_DATE_TRAVAIL = 'TRAVAILPROJET_ID_MAX_DATE_TRAVAIL';
53
 
54
	/*** Attributs : */
55
	private $id_utilisateur;
56
	private $id_projet;
57
	private $id_date_travail;
58
	private $duree;
59
 
60
	/*** Aggregations : */
61
 
62
	/*** Constructeur : */
63
	public function __construct($cmd = null, $parametres = null)
64
	{
65
		$this->dao_table_nom = 'gestion_travail_projet';
66
		$this->dao_correspondance = array(
67
			'gtp_id_utilisateur'	=> 'id_utilisateur',
68
			'gtp_id_projet'	=> 'id_projet',
69
			'gtp_id_date_travail'	=> 'id_date_travail',
70
			'gtp_duree'	=> 'duree');
71
 
72
		// Si l'on veut remplir l'objet à la création on lance la requete correspondante
73
		if (!is_null($cmd)) {
74
			$this->consulter($cmd, $parametres, true);
75
		}
76
	}
77
 
78
	/*** Accesseurs : */
79
	// Id Utilisateur
80
	public function getIdUtilisateur()
81
	{
82
		return $this->id_utilisateur;
83
	}
84
	public function setIdUtilisateur( $iu )
85
	{
86
		$this->id_utilisateur = $iu;
87
	}
88
 
89
	// Id Projet
90
	public function getIdProjet()
91
	{
92
		return $this->id_projet;
93
	}
94
	public function setIdProjet( $ip )
95
	{
96
		$this->id_projet = $ip;
97
	}
98
 
99
	// Id Date Travail
100
	public function getIdDateTravail()
101
	{
102
		return $this->id_date_travail;
103
	}
104
	public function setIdDateTravail( $idt )
105
	{
106
		$this->id_date_travail = $idt;
107
	}
108
 
109
	// Duree
110
	public function getDuree()
111
	{
112
		return $this->duree;
113
	}
114
	public function setDuree( $d )
115
	{
116
		$this->duree = $d;
117
	}
118
 
119
	/*** Méthodes : */
120
 
121
	/**
122
	* Consulter la table gestion_travail_projet.
123
	* @return mixed un tableau d'objets TravailProjet s'il y en a plusieurs, l'objet TravailProjet s'il y en a 1 seul sinon false.
124
	*/
125
	public function consulter($cmd = '', $parametres = array(), $instancier = false)
126
	{
127
		switch ($cmd) {
128
			case TravailProjet::GTP_ID:
129
				$requete = 	'SELECT * '.
130
							'FROM gestion_travail_projet '.
131
							'WHERE gtp_id_utilisateur = '.$parametres[0].' AND gtp_id_projet = '.$parametres[1].' AND gtp_id_date_travail = '.$parametres[2].' ';
132
				break;
133
			case TravailProjet::GTP_ID_MAX_UTILISATEUR:
134
				$requete =	'SELECT MAX(gtp_id_utilisateur) '.
135
							'FROM gestion_travail_projet ';
136
				break;
137
			case TravailProjet::GTP_ID_MAX_PROJET:
138
				$requete =	'SELECT MAX(gtp_id_projet) '.
139
							'FROM gestion_travail_projet ';
140
				break;
141
			case TravailProjet::GTP_ID_MAX_DATE_TRAVAIL:
142
				$requete =	'SELECT MAX(gtp_id_date_travail) '.
143
							'FROM gestion_travail_projet ';
144
				break;
145
			default :
146
				$message = 'Commande '.$cmd.'inconnue!';
147
				$e = GestionnaireErreur::formaterMessageErreur(__FILE__, __LINE__, $message);
148
    			trigger_error($e, E_USER_ERROR);
149
		}
150
 
151
		$resultat = $GLOBALS['db']->query($requete);
152
		(DB::isError($resultat)) ? die (GestionnaireErreur::retournerErreurSql(__FILE__, __LINE__, $resultat->getMessage(), $requete)) : '' ;
153
		$tab_resultat = array();
154
		while ($donnees =& $resultat->fetchRow(DB_FETCHMODE_ASSOC)) {
155
			$tab_resultat[] = $this->basculerEnregistrementObjet($donnees, $instancier);
156
		}
157
 
158
		$resultat_nbre = count($tab_resultat);
159
		if ($resultat_nbre > 1) {
160
			return $tab_resultat;
161
		} else if ($resultat_nbre == 1) {
162
			return $tab_resultat[0];
163
		} else if ($resultat_nbre == 0) {
164
			return false;
165
		}
166
	}
167
 
168
	/** Afficher l'objet TravailProjet */
169
	function afficherTravailProjet()
170
	{
171
		echo '<pre>'.print_r($this, true).'</pre>';
172
	}
173
}
174
 
175
/* +--Fin du code ----------------------------------------------------------------------------------------+
176
*
177
* $Log$
178
*
179
* +-- Fin du code ----------------------------------------------------------------------------------------+
180
*/
181
?>