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 TravailTache
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 TravailTache : est à la fois le DAO et le conteneur de la table gestion_utilisateur.
45
* classe métier
46
*/
47
class TravailTache extends aGttSql {
48
	/*** Constantes : */
49
	const GTT_ID = 'TRAVAILTACHE_ID';
50
	const GTT_ID_MAX_UTILISATEUR = 'TRAVAILTACHE_ID_MAX_UTILISATEUR';
51
	const GTT_ID_MAX_TACHE = 'TRAVAILTACHE_ID_MAX_TACHE';
52
	const GTT_ID_MAX_DATE_TRAVAIL = 'TRAVAILTACHE_ID_MAX_DATE_TRAVAIL';
48 jpm 53
 
10 jpm 54
	/*** Attributs : */
55
	private $id_utilisateur;
56
	private $id_tache;
57
	private $id_date_travail;
58
	private $duree;
48 jpm 59
 
10 jpm 60
	/*** Aggregations : */
61
 
62
	/*** Constructeur : */
63
	public function __construct($cmd = null, $parametres = null)
64
	{
65
		$this->dao_table_nom = 'gestion_travail_tache';
66
		$this->dao_correspondance = array(
67
			'gtt_id_utilisateur'	=> 'id_utilisateur',
68
			'gtt_id_tache'	=> 'id_tache',
69
			'gtt_id_date_travail'	=> 'id_date_travail',
70
			'gtt_duree'	=> 'duree');
48 jpm 71
 
10 jpm 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
	}
48 jpm 77
 
10 jpm 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
	}
48 jpm 88
 
10 jpm 89
	// Id Tache
90
	public function getIdTache()
91
	{
92
		return $this->id_tache;
93
	}
94
	public function setIdTache( $it )
95
	{
96
		$this->id_tache = $it;
97
	}
48 jpm 98
 
10 jpm 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
	}
48 jpm 108
 
10 jpm 109
	// Duree
110
	public function getDuree()
111
	{
112
		return $this->duree;
113
	}
114
	public function setDuree( $d )
115
	{
116
		$this->duree = $d;
117
	}
48 jpm 118
 
10 jpm 119
	/*** Méthodes : */
120
 
121
	/**
122
	* Consulter la table gestion_travail_tache.
123
	* @return mixed un tableau d'objets TravailTache s'il y en a plusieurs, l'objet TravailTache s'il y en a 1 seul sinon false.
124
	*/
125
	public function consulter($cmd = '', $parametres = array(), $instancier = false)
126
	{
48 jpm 127
		if (!is_array($parametres)) {
128
			$parametres[0] = $parametres;
129
		}
10 jpm 130
		switch ($cmd) {
131
			case TravailTache::GTT_ID:
132
				$requete = 	'SELECT * '.
133
							'FROM gestion_travail_tache '.
134
							'WHERE gtt_id_utilisateur = '.$parametres[0].' AND gtt_id_tache = '.$parametres[1].' AND gtt_id_date_travail = '.$parametres[2].' ';
135
				break;
136
			case TravailTache::GTT_ID_MAX_UTILISATEUR:
137
				$requete =	'SELECT MAX(gtt_id_utilisateur) '.
138
							'FROM gestion_travail_tache ';
139
				break;
140
			case TravailTache::GTT_ID_MAX_TACHE:
141
				$requete =	'SELECT MAX(gtt_id_tache) '.
142
							'FROM gestion_travail_tache ';
143
				break;
144
			case TravailTache::GTT_ID_MAX_DATE_TRAVAIL:
145
				$requete =	'SELECT MAX(gtt_id_date_travail) '.
146
							'FROM gestion_travail_tache ';
147
				break;
148
			default :
149
				$message = 'Commande '.$cmd.'inconnue!';
150
				$e = GestionnaireErreur::formaterMessageErreur(__FILE__, __LINE__, $message);
151
    			trigger_error($e, E_USER_ERROR);
152
		}
48 jpm 153
 
10 jpm 154
		$resultat = $GLOBALS['db']->query($requete);
155
		(DB::isError($resultat)) ? die (GestionnaireErreur::retournerErreurSql(__FILE__, __LINE__, $resultat->getMessage(), $requete)) : '' ;
156
		$tab_resultat = array();
157
		while ($donnees =& $resultat->fetchRow(DB_FETCHMODE_ASSOC)) {
158
			$tab_resultat[] = $this->basculerEnregistrementObjet($donnees, $instancier);
159
		}
48 jpm 160
 
161
		$resultat_nbre = count($tab_resultat);
10 jpm 162
		if ($resultat_nbre > 1) {
163
			return $tab_resultat;
164
		} else if ($resultat_nbre == 1) {
165
			return $tab_resultat[0];
166
		} else if ($resultat_nbre == 0) {
167
			return false;
168
		}
169
	}
48 jpm 170
 
10 jpm 171
	/** Afficher l'objet TravailTache */
172
	function afficherTravailTache()
173
	{
174
		echo '<pre>'.print_r($this, true).'</pre>';
175
	}
176
}
177
 
178
/* +--Fin du code ----------------------------------------------------------------------------------------+
179
*
180
* $Log$
181
*
182
* +-- Fin du code ----------------------------------------------------------------------------------------+
183
*/
184
?>