Subversion Repositories Applications.gtt

Rev

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

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