Subversion Repositories Applications.gtt

Rev

Rev 170 | Only display areas with differences | Regard whitespace | Details | Blame | Last modification | View Log | RSS feed

Rev 170 Rev 189
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
	const GTP_PROJET = 'TRAVAILPROJET_ID_PROJET';
54
	const GTP_PROJET = 'TRAVAILPROJET_ID_PROJET';
55
	const GTP_UTILISATEUR = 'TRAVAILPROJET_ID_UTILISATEUR';
55
	const GTP_UTILISATEUR = 'TRAVAILPROJET_ID_UTILISATEUR';
-
 
56
	const GTP_UTILISATEUR_SOMME_TEMPS_PAR_PROJET = 'TRAVAILPROJET_ID_UTILISATEUR_SOMME_TEMPS_PAR_PROJET';
56
	
57
	
57
	/*** Attributs : */
58
	/*** Attributs : */
58
	private $id_utilisateur;
59
	private $id_utilisateur;
59
	private $id_projet;
60
	private $id_projet;
60
	private $id_date_travail;
61
	private $id_date_travail;
61
	private $duree;
62
	private $duree;
62
 
63
 
63
	/*** Aggregations : */
64
	/*** Aggregations : */
64
 
65
 
65
	/*** Constructeur : */
66
	/*** Constructeur : */
66
	public function __construct($cmd = null, $parametres = null)
67
	public function __construct($cmd = null, $parametres = null)
67
	{
68
	{
68
		$this->dao_table_nom = GTT_BDD_PREFIXE . 'gestion_travail_projet';
69
		$this->dao_table_nom = GTT_BDD_PREFIXE . 'gestion_travail_projet';
69
		$this->dao_correspondance = array(
70
		$this->dao_correspondance = array(
70
			'gtp_id_utilisateur'	=> 'id_utilisateur',
71
			'gtp_id_utilisateur'	=> 'id_utilisateur',
71
			'gtp_id_projet'	=> 'id_projet',
72
			'gtp_id_projet'	=> 'id_projet',
72
			'gtp_id_date_travail'	=> 'id_date_travail',
73
			'gtp_id_date_travail'	=> 'id_date_travail',
73
			'gtp_duree'	=> 'duree');
74
			'gtp_duree'	=> 'duree');
74
 
75
 
75
		// Si l'on veut remplir l'objet à la création on lance la requete correspondante
76
		// Si l'on veut remplir l'objet à la création on lance la requete correspondante
76
		if (!is_null($cmd)) {
77
		if (!is_null($cmd)) {
77
			$this->consulter($cmd, $parametres, true);
78
			$this->consulter($cmd, $parametres, true);
78
		}
79
		}
79
	}
80
	}
80
 
81
 
81
	/*** Accesseurs : */
82
	/*** Accesseurs : */
82
	// Id Utilisateur
83
	// Id Utilisateur
83
	public function getIdUtilisateur()
84
	public function getIdUtilisateur()
84
	{
85
	{
85
		return $this->id_utilisateur;
86
		return $this->id_utilisateur;
86
	}
87
	}
87
	public function setIdUtilisateur( $iu )
88
	public function setIdUtilisateur( $iu )
88
	{
89
	{
89
		$this->id_utilisateur = $iu;
90
		$this->id_utilisateur = $iu;
90
	}
91
	}
91
 
92
 
92
	// Id Projet
93
	// Id Projet
93
	public function getIdProjet()
94
	public function getIdProjet()
94
	{
95
	{
95
		return $this->id_projet;
96
		return $this->id_projet;
96
	}
97
	}
97
	public function setIdProjet( $ip )
98
	public function setIdProjet( $ip )
98
	{
99
	{
99
		$this->id_projet = $ip;
100
		$this->id_projet = $ip;
100
	}
101
	}
101
 
102
 
102
	// Id Date Travail
103
	// Id Date Travail
103
	public function getIdDateTravail()
104
	public function getIdDateTravail()
104
	{
105
	{
105
		return $this->id_date_travail;
106
		return $this->id_date_travail;
106
	}
107
	}
107
	public function setIdDateTravail( $idt )
108
	public function setIdDateTravail( $idt )
108
	{
109
	{
109
		$this->id_date_travail = $idt;
110
		$this->id_date_travail = $idt;
110
	}
111
	}
111
 
112
 
112
	// Duree
113
	// Duree
113
	public function getDuree()
114
	public function getDuree()
114
	{
115
	{
115
		return $this->duree;
116
		return $this->duree;
116
	}
117
	}
117
	public function setDuree( $d )
118
	public function setDuree( $d )
118
	{
119
	{
119
		$this->duree = $d;
120
		$this->duree = $d;
120
	}
121
	}
121
 
122
 
122
	/*** Méthodes : */
123
	/*** Méthodes : */
123
 
124
 
124
	/**
125
	/**
125
	* Consulter la table gestion_travail_projet.
126
	* Consulter la table gestion_travail_projet.
126
	* @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.
127
	* @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.
127
	*/
128
	*/
128
	public function consulter($cmd = '', $parametres = array(), $instancier = false)
129
	public function consulter($cmd = '', $parametres = array(), $instancier = false)
129
	{
130
	{
130
		switch ($cmd) {
131
		switch ($cmd) {
131
			case TravailProjet::GTP_ID:
132
			case TravailProjet::GTP_ID:
132
				$requete = 	'SELECT * '.
133
				$requete = 	'SELECT * '.
133
							'FROM ' . GTT_BDD_PREFIXE . 'gestion_travail_projet '.
134
							'FROM ' . GTT_BDD_PREFIXE . 'gestion_travail_projet '.
134
							'WHERE gtp_id_utilisateur = #0 '.
135
							'WHERE gtp_id_utilisateur = #0 '.
135
							'	AND gtp_id_projet = #1 '.
136
							'	AND gtp_id_projet = #1 '.
136
							'	AND gtp_id_date_travail = "#2" ';
137
							'	AND gtp_id_date_travail = "#2" ';
137
				break;
138
				break;
138
			case TravailProjet::GTP_ID_UTILISATEUR_DATE_DEB_FIN:
139
			case TravailProjet::GTP_ID_UTILISATEUR_DATE_DEB_FIN:
139
				$requete = 	'SELECT * '.
140
				$requete = 	'SELECT * '.
140
							'FROM ' . GTT_BDD_PREFIXE . 'gestion_travail_projet '.
141
							'FROM ' . GTT_BDD_PREFIXE . 'gestion_travail_projet '.
141
							'WHERE gtp_id_utilisateur = #0 '.
142
							'WHERE gtp_id_utilisateur = #0 '.
142
							'	AND gtp_id_date_travail >= "#1" '.
143
							'	AND gtp_id_date_travail >= "#1" '.
143
							'	AND gtp_id_date_travail <= "#2" ';
144
							'	AND gtp_id_date_travail <= "#2" ';
144
				break;
145
				break;
145
			case TravailProjet::GTP_ID_MAX_UTILISATEUR:
146
			case TravailProjet::GTP_ID_MAX_UTILISATEUR:
146
				$requete =	'SELECT MAX(gtp_id_utilisateur) '.
147
				$requete =	'SELECT MAX(gtp_id_utilisateur) '.
147
							'FROM ' . GTT_BDD_PREFIXE . 'gestion_travail_projet ';
148
							'FROM ' . GTT_BDD_PREFIXE . 'gestion_travail_projet ';
148
				break;
149
				break;
149
			case TravailProjet::GTP_ID_MAX_PROJET:
150
			case TravailProjet::GTP_ID_MAX_PROJET:
150
				$requete =	'SELECT MAX(gtp_id_projet) '.
151
				$requete =	'SELECT MAX(gtp_id_projet) '.
151
							'FROM ' . GTT_BDD_PREFIXE . 'gestion_travail_projet ';
152
							'FROM ' . GTT_BDD_PREFIXE . 'gestion_travail_projet ';
152
				break;
153
				break;
153
			case TravailProjet::GTP_ID_MAX_DATE_TRAVAIL:
154
			case TravailProjet::GTP_ID_MAX_DATE_TRAVAIL:
154
				$requete =	'SELECT MAX(gtp_id_date_travail) '.
155
				$requete =	'SELECT MAX(gtp_id_date_travail) '.
155
							'FROM ' . GTT_BDD_PREFIXE . 'gestion_travail_projet ';
156
							'FROM ' . GTT_BDD_PREFIXE . 'gestion_travail_projet ';
156
				break;
157
				break;
157
			case TravailProjet::GTP_PROJET:
158
			case TravailProjet::GTP_PROJET:
158
				$requete =	'SELECT gtp_id_projet '.
159
				$requete =	'SELECT gtp_id_projet '.
159
							'FROM ' . GTT_BDD_PREFIXE . 'gestion_travail_projet '.
160
							'FROM ' . GTT_BDD_PREFIXE . 'gestion_travail_projet '.
160
							'WHERE gtp_id_projet = #0 ';
161
							'WHERE gtp_id_projet = #0 ';
161
				break;
162
				break;
162
			case TravailProjet::GTP_UTILISATEUR:
163
			case TravailProjet::GTP_UTILISATEUR:
163
				$requete =	'SELECT gtp_id_utilisateur '.
164
				$requete =	'SELECT gtp_id_utilisateur '.
164
							'FROM ' . GTT_BDD_PREFIXE . 'gestion_travail_projet '.
165
							'FROM ' . GTT_BDD_PREFIXE . 'gestion_travail_projet '.
165
							'WHERE gtp_id_utilisateur = #0 ';
166
							'WHERE gtp_id_utilisateur = #0 ';
166
				break;
167
				break;
167
			default :
168
			default :
168
				$message = 'Commande '.$cmd.' inconnue!';
169
				$message = 'Commande '.$cmd.' inconnue!';
169
				$e = GestionnaireErreur::formaterMessageErreur(__FILE__, __LINE__, $message);
170
				$e = GestionnaireErreur::formaterMessageErreur(__FILE__, __LINE__, $message);
170
    			trigger_error($e, E_USER_ERROR);
171
    			trigger_error($e, E_USER_ERROR);
171
		}
172
		}
172
		return parent::consulter($requete, $parametres, $instancier);
173
		return parent::consulter($requete, $parametres, $instancier);
173
	}
174
	}
-
 
175
 
-
 
176
	/**
-
 
177
	 * Retourne la somme des heures travaillées pour chaque projet, pour un
-
 
178
	 * utilisateur donné
-
 
179
	 * 
-
 
180
	 * @WARNING Fonction plus pratique que d'utiliser le DAO (mais c'est MAL !)
-
 
181
	 * 
-
 
182
	 * @param int $idUtilisateur l'identifiant de l'utilisateur
-
 
183
	 */
-
 
184
	public function getTempsTravailUtilisateurParProjet($idUtilisateur) {
-
 
185
 
-
 
186
		$requete =	'SELECT gtp_id_utilisateur '.
-
 
187
					', gtp_id_projet '.
-
 
188
					', sum(gtp_duree) AS temps_total_heures '.
-
 
189
					'FROM ' . GTT_BDD_PREFIXE . 'gestion_travail_projet '.
-
 
190
					'WHERE gtp_id_utilisateur = ' . $idUtilisateur . ' '.
-
 
191
					'GROUP BY gtp_id_projet ';
-
 
192
 
-
 
193
		$resultat = $GLOBALS['db']->getAll($requete);
-
 
194
 
-
 
195
		return $resultat;
-
 
196
	}
174
}
197
}
175
 
198
 
176
/* +--Fin du code ----------------------------------------------------------------------------------------+
199
/* +--Fin du code ----------------------------------------------------------------------------------------+
177
*
200
*
178
* $Log$
201
* $Log$
179
*
202
*
180
* +-- Fin du code ----------------------------------------------------------------------------------------+
203
* +-- Fin du code ----------------------------------------------------------------------------------------+
181
*/
204
*/
182
?>
205
?>