Subversion Repositories Applications.gtt

Rev

Rev 10 | Go to most recent revision | Only display areas with differences | Ignore whitespace | Details | Blame | Last modification | View Log | RSS feed

Rev 10 Rev 48
1
<?php
1
<?php
2
// +------------------------------------------------------------------------------------------------------+
2
// +------------------------------------------------------------------------------------------------------+
3
// | PHP version 5.1.1                                                                                    |
3
// | PHP version 5.1.1                                                                                    |
4
// +------------------------------------------------------------------------------------------------------+
4
// +------------------------------------------------------------------------------------------------------+
5
// | Copyright (C) 2006 Tela Botanica (accueil@tela-botanica.org)                                         |
5
// | Copyright (C) 2006 Tela Botanica (accueil@tela-botanica.org)                                         |
6
// +------------------------------------------------------------------------------------------------------+
6
// +------------------------------------------------------------------------------------------------------+
7
// | This file is part of eFlore.                                                                         |
7
// | This file is part of eFlore.                                                                         |
8
// |                                                                                                      |
8
// |                                                                                                      |
9
// | Foobar is free software; you can redistribute it and/or modify                                       |
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                                 |
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                                    |
11
// | the Free Software Foundation; either version 2 of the License, or                                    |
12
// | (at your option) any later version.                                                                  |
12
// | (at your option) any later version.                                                                  |
13
// |                                                                                                      |
13
// |                                                                                                      |
14
// | Foobar is distributed in the hope that it will be useful,                                            |
14
// | Foobar is distributed in the hope that it will be useful,                                            |
15
// | but WITHOUT ANY WARRANTY; without even the implied warranty of                                       |
15
// | but WITHOUT ANY WARRANTY; without even the implied warranty of                                       |
16
// | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the                                        |
16
// | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the                                        |
17
// | GNU General Public License for more details.                                                         |
17
// | GNU General Public License for more details.                                                         |
18
// |                                                                                                      |
18
// |                                                                                                      |
19
// | You should have received a copy of the GNU General Public License                                    |
19
// | You should have received a copy of the GNU General Public License                                    |
20
// | along with Foobar; if not, write to the Free Software                                                |
20
// | along with Foobar; if not, write to the Free Software                                                |
21
// | Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA                            |
21
// | Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA                            |
22
// +------------------------------------------------------------------------------------------------------+
22
// +------------------------------------------------------------------------------------------------------+
23
// CVS : $Id$
23
// CVS : $Id$
24
/**
24
/**
25
* Classe TravailTache
25
* Classe TravailTache
26
*
26
*
27
* Description
27
* Description
28
*
28
*
29
*@package eFlore
29
*@package eFlore
30
*@subpackage modele
30
*@subpackage modele
31
//Auteur original :
31
//Auteur original :
32
*@version 3
32
*@version 3
33
*@author        Shaheen ABDOOL RAHEEM <shaheenar50@hotmail.com>
33
*@author        Shaheen ABDOOL RAHEEM <shaheenar50@hotmail.com>
34
//Autres auteurs :
34
//Autres auteurs :
35
*@version 4
35
*@version 4
36
*@author        Jean-Pascal MILCENT <jpm@clapas.org>
36
*@author        Jean-Pascal MILCENT <jpm@clapas.org>
37
*@author        aucun
37
*@author        aucun
38
*@copyright     Tela-Botanica 2000-2006
38
*@copyright     Tela-Botanica 2000-2006
39
*@version       $Revision$ $Date$
39
*@version       $Revision$ $Date$
40
// +------------------------------------------------------------------------------------------------------+
40
// +------------------------------------------------------------------------------------------------------+
41
*/
41
*/
42
 
42
 
43
/**
43
/**
44
* class TravailTache : est à la fois le DAO et le conteneur de la table gestion_utilisateur.
44
* class TravailTache : est à la fois le DAO et le conteneur de la table gestion_utilisateur.
45
* classe métier
45
* classe métier
46
*/
46
*/
47
class TravailTache extends aGttSql {
47
class TravailTache extends aGttSql {
48
	/*** Constantes : */
48
	/*** Constantes : */
49
	const GTT_ID = 'TRAVAILTACHE_ID';
49
	const GTT_ID = 'TRAVAILTACHE_ID';
50
	const GTT_ID_MAX_UTILISATEUR = 'TRAVAILTACHE_ID_MAX_UTILISATEUR';
50
	const GTT_ID_MAX_UTILISATEUR = 'TRAVAILTACHE_ID_MAX_UTILISATEUR';
51
	const GTT_ID_MAX_TACHE = 'TRAVAILTACHE_ID_MAX_TACHE';
51
	const GTT_ID_MAX_TACHE = 'TRAVAILTACHE_ID_MAX_TACHE';
52
	const GTT_ID_MAX_DATE_TRAVAIL = 'TRAVAILTACHE_ID_MAX_DATE_TRAVAIL';
52
	const GTT_ID_MAX_DATE_TRAVAIL = 'TRAVAILTACHE_ID_MAX_DATE_TRAVAIL';
53
	
53
 
54
	/*** Attributs : */
54
	/*** Attributs : */
55
	private $id_utilisateur;
55
	private $id_utilisateur;
56
	private $id_tache;
56
	private $id_tache;
57
	private $id_date_travail;
57
	private $id_date_travail;
58
	private $duree;
58
	private $duree;
59
	
59
 
60
	/*** Aggregations : */
60
	/*** Aggregations : */
61
 
61
 
62
	/*** Constructeur : */
62
	/*** Constructeur : */
63
	public function __construct($cmd = null, $parametres = null)
63
	public function __construct($cmd = null, $parametres = null)
64
	{
64
	{
65
		$this->dao_table_nom = 'gestion_travail_tache';
65
		$this->dao_table_nom = 'gestion_travail_tache';
66
		$this->dao_correspondance = array(
66
		$this->dao_correspondance = array(
67
			'gtt_id_utilisateur'	=> 'id_utilisateur',
67
			'gtt_id_utilisateur'	=> 'id_utilisateur',
68
			'gtt_id_tache'	=> 'id_tache',
68
			'gtt_id_tache'	=> 'id_tache',
69
			'gtt_id_date_travail'	=> 'id_date_travail',
69
			'gtt_id_date_travail'	=> 'id_date_travail',
70
			'gtt_duree'	=> 'duree');
70
			'gtt_duree'	=> 'duree');
71
		
71
 
72
		// Si l'on veut remplir l'objet à la création on lance la requete correspondante
72
		// Si l'on veut remplir l'objet à la création on lance la requete correspondante
73
		if (!is_null($cmd)) {
73
		if (!is_null($cmd)) {
74
			$this->consulter($cmd, $parametres, true);
74
			$this->consulter($cmd, $parametres, true);
75
		}
75
		}
76
	}
76
	}
77
	
77
 
78
	/*** Accesseurs : */
78
	/*** Accesseurs : */
79
	// Id Utilisateur
79
	// Id Utilisateur
80
	public function getIdUtilisateur()
80
	public function getIdUtilisateur()
81
	{
81
	{
82
		return $this->id_utilisateur;
82
		return $this->id_utilisateur;
83
	}
83
	}
84
	public function setIdUtilisateur( $iu )
84
	public function setIdUtilisateur( $iu )
85
	{
85
	{
86
		$this->id_utilisateur = $iu;
86
		$this->id_utilisateur = $iu;
87
	}
87
	}
88
	
88
 
89
	// Id Tache
89
	// Id Tache
90
	public function getIdTache()
90
	public function getIdTache()
91
	{
91
	{
92
		return $this->id_tache;
92
		return $this->id_tache;
93
	}
93
	}
94
	public function setIdTache( $it )
94
	public function setIdTache( $it )
95
	{
95
	{
96
		$this->id_tache = $it;
96
		$this->id_tache = $it;
97
	}
97
	}
98
	
98
 
99
	// Id Date Travail
99
	// Id Date Travail
100
	public function getIdDateTravail()
100
	public function getIdDateTravail()
101
	{
101
	{
102
		return $this->id_date_travail;
102
		return $this->id_date_travail;
103
	}
103
	}
104
	public function setIdDateTravail( $idt )
104
	public function setIdDateTravail( $idt )
105
	{
105
	{
106
		$this->id_date_travail = $idt;
106
		$this->id_date_travail = $idt;
107
	}
107
	}
108
	
108
 
109
	// Duree
109
	// Duree
110
	public function getDuree()
110
	public function getDuree()
111
	{
111
	{
112
		return $this->duree;
112
		return $this->duree;
113
	}
113
	}
114
	public function setDuree( $d )
114
	public function setDuree( $d )
115
	{
115
	{
116
		$this->duree = $d;
116
		$this->duree = $d;
117
	}
117
	}
118
	
118
 
119
	/*** Méthodes : */
119
	/*** Méthodes : */
120
 
120
 
121
	/**
121
	/**
122
	* Consulter la table gestion_travail_tache.
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.
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
	*/
124
	*/
125
	public function consulter($cmd = '', $parametres = array(), $instancier = false)
125
	public function consulter($cmd = '', $parametres = array(), $instancier = false)
126
	{
126
	{
-
 
127
		if (!is_array($parametres)) {
-
 
128
			$parametres[0] = $parametres;
-
 
129
		}
127
		switch ($cmd) {
130
		switch ($cmd) {
128
			case TravailTache::GTT_ID:
131
			case TravailTache::GTT_ID:
129
				$requete = 	'SELECT * '.
132
				$requete = 	'SELECT * '.
130
							'FROM gestion_travail_tache '.
133
							'FROM gestion_travail_tache '.
131
							'WHERE gtt_id_utilisateur = '.$parametres[0].' AND gtt_id_tache = '.$parametres[1].' AND gtt_id_date_travail = '.$parametres[2].' ';
134
							'WHERE gtt_id_utilisateur = '.$parametres[0].' AND gtt_id_tache = '.$parametres[1].' AND gtt_id_date_travail = '.$parametres[2].' ';
132
				break;
135
				break;
133
			case TravailTache::GTT_ID_MAX_UTILISATEUR:
136
			case TravailTache::GTT_ID_MAX_UTILISATEUR:
134
				$requete =	'SELECT MAX(gtt_id_utilisateur) '.
137
				$requete =	'SELECT MAX(gtt_id_utilisateur) '.
135
							'FROM gestion_travail_tache ';
138
							'FROM gestion_travail_tache ';
136
				break;
139
				break;
137
			case TravailTache::GTT_ID_MAX_TACHE:
140
			case TravailTache::GTT_ID_MAX_TACHE:
138
				$requete =	'SELECT MAX(gtt_id_tache) '.
141
				$requete =	'SELECT MAX(gtt_id_tache) '.
139
							'FROM gestion_travail_tache ';
142
							'FROM gestion_travail_tache ';
140
				break;
143
				break;
141
			case TravailTache::GTT_ID_MAX_DATE_TRAVAIL:
144
			case TravailTache::GTT_ID_MAX_DATE_TRAVAIL:
142
				$requete =	'SELECT MAX(gtt_id_date_travail) '.
145
				$requete =	'SELECT MAX(gtt_id_date_travail) '.
143
							'FROM gestion_travail_tache ';
146
							'FROM gestion_travail_tache ';
144
				break;
147
				break;
145
			default :
148
			default :
146
				$message = 'Commande '.$cmd.'inconnue!';
149
				$message = 'Commande '.$cmd.'inconnue!';
147
				$e = GestionnaireErreur::formaterMessageErreur(__FILE__, __LINE__, $message);
150
				$e = GestionnaireErreur::formaterMessageErreur(__FILE__, __LINE__, $message);
148
    			trigger_error($e, E_USER_ERROR);
151
    			trigger_error($e, E_USER_ERROR);
149
		}
152
		}
150
		
153
 
151
		$resultat = $GLOBALS['db']->query($requete);
154
		$resultat = $GLOBALS['db']->query($requete);
152
		(DB::isError($resultat)) ? die (GestionnaireErreur::retournerErreurSql(__FILE__, __LINE__, $resultat->getMessage(), $requete)) : '' ;
155
		(DB::isError($resultat)) ? die (GestionnaireErreur::retournerErreurSql(__FILE__, __LINE__, $resultat->getMessage(), $requete)) : '' ;
153
		$tab_resultat = array();
156
		$tab_resultat = array();
154
		while ($donnees =& $resultat->fetchRow(DB_FETCHMODE_ASSOC)) {
157
		while ($donnees =& $resultat->fetchRow(DB_FETCHMODE_ASSOC)) {
155
			$tab_resultat[] = $this->basculerEnregistrementObjet($donnees, $instancier);
158
			$tab_resultat[] = $this->basculerEnregistrementObjet($donnees, $instancier);
156
		}
159
		}
157
				
160
 
158
		$resultat_nbre = count($tab_resultat); 
161
		$resultat_nbre = count($tab_resultat);
159
		if ($resultat_nbre > 1) {
162
		if ($resultat_nbre > 1) {
160
			return $tab_resultat;
163
			return $tab_resultat;
161
		} else if ($resultat_nbre == 1) {
164
		} else if ($resultat_nbre == 1) {
162
			return $tab_resultat[0];
165
			return $tab_resultat[0];
163
		} else if ($resultat_nbre == 0) {
166
		} else if ($resultat_nbre == 0) {
164
			return false;
167
			return false;
165
		}
168
		}
166
	}
169
	}
167
      
170
 
168
	/** Afficher l'objet TravailTache */
171
	/** Afficher l'objet TravailTache */
169
	function afficherTravailTache()
172
	function afficherTravailTache()
170
	{
173
	{
171
		echo '<pre>'.print_r($this, true).'</pre>';
174
		echo '<pre>'.print_r($this, true).'</pre>';
172
	}
175
	}
173
}
176
}
174
 
177
 
175
/* +--Fin du code ----------------------------------------------------------------------------------------+
178
/* +--Fin du code ----------------------------------------------------------------------------------------+
176
*
179
*
177
* $Log$
180
* $Log$
178
*
181
*
179
* +-- Fin du code ----------------------------------------------------------------------------------------+
182
* +-- Fin du code ----------------------------------------------------------------------------------------+
180
*/
183
*/
181
?>
184
?>