Subversion Repositories Applications.gtt

Rev

Rev 170 | Details | Compare with Previous | Last modification | View Log | RSS feed

Rev Author Line No. Line
10 jpm 1
<?php
170 mathias 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
// +------------------------------------------------------------------------------------------------------+
10 jpm 23
// CVS : $Id$
170 mathias 24
/**
10 jpm 25
* Classe TravailProjet
170 mathias 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
10 jpm 39
*@version       $Revision$ $Date$
170 mathias 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 : */
11 jpm 49
	const GTP_ID = 'TRAVAILPROJET_ID';
170 mathias 50
	const GTP_ID_UTILISATEUR_DATE_DEB_FIN = 'TRAVAILPROJET_ID_UTILISATEUR_DATE';
51
	const GTP_ID_MAX_UTILISATEUR = 'TRAVAILPROJET_ID_MAX_UTILISATEUR';
52
	const GTP_ID_MAX_PROJET = 'TRAVAILPROJET_ID_MAX_PROJET';
53
	const GTP_ID_MAX_DATE_TRAVAIL = 'TRAVAILPROJET_ID_MAX_DATE_TRAVAIL';
71 jpm 54
	const GTP_PROJET = 'TRAVAILPROJET_ID_PROJET';
95 jpm 55
	const GTP_UTILISATEUR = 'TRAVAILPROJET_ID_UTILISATEUR';
189 mathias 56
	const GTP_UTILISATEUR_SOMME_TEMPS_PAR_PROJET = 'TRAVAILPROJET_ID_UTILISATEUR_SOMME_TEMPS_PAR_PROJET';
170 mathias 57
 
58
	/*** Attributs : */
59
	private $id_utilisateur;
60
	private $id_projet;
61
	private $id_date_travail;
62
	private $duree;
63
 
64
	/*** Aggregations : */
65
 
66
	/*** Constructeur : */
67
	public function __construct($cmd = null, $parametres = null)
68
	{
69
		$this->dao_table_nom = GTT_BDD_PREFIXE . 'gestion_travail_projet';
70
		$this->dao_correspondance = array(
10 jpm 71
			'gtp_id_utilisateur'	=> 'id_utilisateur',
72
			'gtp_id_projet'	=> 'id_projet',
73
			'gtp_id_date_travail'	=> 'id_date_travail',
74
			'gtp_duree'	=> 'duree');
170 mathias 75
 
76
		// Si l'on veut remplir l'objet à la création on lance la requete correspondante
77
		if (!is_null($cmd)) {
78
			$this->consulter($cmd, $parametres, true);
79
		}
80
	}
81
 
82
	/*** Accesseurs : */
10 jpm 83
	// Id Utilisateur
170 mathias 84
	public function getIdUtilisateur()
85
	{
86
		return $this->id_utilisateur;
87
	}
88
	public function setIdUtilisateur( $iu )
89
	{
90
		$this->id_utilisateur = $iu;
91
	}
92
 
10 jpm 93
	// Id Projet
170 mathias 94
	public function getIdProjet()
95
	{
96
		return $this->id_projet;
97
	}
98
	public function setIdProjet( $ip )
99
	{
100
		$this->id_projet = $ip;
101
	}
102
 
10 jpm 103
	// Id Date Travail
170 mathias 104
	public function getIdDateTravail()
105
	{
106
		return $this->id_date_travail;
107
	}
108
	public function setIdDateTravail( $idt )
109
	{
110
		$this->id_date_travail = $idt;
111
	}
112
 
10 jpm 113
	// Duree
170 mathias 114
	public function getDuree()
115
	{
116
		return $this->duree;
117
	}
118
	public function setDuree( $d )
119
	{
120
		$this->duree = $d;
121
	}
122
 
123
	/*** Méthodes : */
124
 
125
	/**
126
	* Consulter la table gestion_travail_projet.
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.
128
	*/
129
	public function consulter($cmd = '', $parametres = array(), $instancier = false)
130
	{
131
		switch ($cmd) {
132
			case TravailProjet::GTP_ID:
133
				$requete = 	'SELECT * '.
134
							'FROM ' . GTT_BDD_PREFIXE . 'gestion_travail_projet '.
90 jpm 135
							'WHERE gtp_id_utilisateur = #0 '.
136
							'	AND gtp_id_projet = #1 '.
170 mathias 137
							'	AND gtp_id_date_travail = "#2" ';
138
				break;
11 jpm 139
			case TravailProjet::GTP_ID_UTILISATEUR_DATE_DEB_FIN:
140
				$requete = 	'SELECT * '.
170 mathias 141
							'FROM ' . GTT_BDD_PREFIXE . 'gestion_travail_projet '.
90 jpm 142
							'WHERE gtp_id_utilisateur = #0 '.
143
							'	AND gtp_id_date_travail >= "#1" '.
144
							'	AND gtp_id_date_travail <= "#2" ';
11 jpm 145
				break;
170 mathias 146
			case TravailProjet::GTP_ID_MAX_UTILISATEUR:
147
				$requete =	'SELECT MAX(gtp_id_utilisateur) '.
148
							'FROM ' . GTT_BDD_PREFIXE . 'gestion_travail_projet ';
11 jpm 149
				break;
170 mathias 150
			case TravailProjet::GTP_ID_MAX_PROJET:
151
				$requete =	'SELECT MAX(gtp_id_projet) '.
152
							'FROM ' . GTT_BDD_PREFIXE . 'gestion_travail_projet ';
153
				break;
154
			case TravailProjet::GTP_ID_MAX_DATE_TRAVAIL:
155
				$requete =	'SELECT MAX(gtp_id_date_travail) '.
156
							'FROM ' . GTT_BDD_PREFIXE . 'gestion_travail_projet ';
157
				break;
71 jpm 158
			case TravailProjet::GTP_PROJET:
159
				$requete =	'SELECT gtp_id_projet '.
170 mathias 160
							'FROM ' . GTT_BDD_PREFIXE . 'gestion_travail_projet '.
90 jpm 161
							'WHERE gtp_id_projet = #0 ';
71 jpm 162
				break;
95 jpm 163
			case TravailProjet::GTP_UTILISATEUR:
164
				$requete =	'SELECT gtp_id_utilisateur '.
170 mathias 165
							'FROM ' . GTT_BDD_PREFIXE . 'gestion_travail_projet '.
95 jpm 166
							'WHERE gtp_id_utilisateur = #0 ';
167
				break;
170 mathias 168
			default :
169
				$message = 'Commande '.$cmd.' inconnue!';
170
				$e = GestionnaireErreur::formaterMessageErreur(__FILE__, __LINE__, $message);
171
    			trigger_error($e, E_USER_ERROR);
172
		}
173
		return parent::consulter($requete, $parametres, $instancier);
174
	}
189 mathias 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
	}
170 mathias 197
}
198
 
199
/* +--Fin du code ----------------------------------------------------------------------------------------+
200
*
10 jpm 201
* $Log$
170 mathias 202
*
203
* +-- Fin du code ----------------------------------------------------------------------------------------+
204
*/
10 jpm 205
?>