<?php
// +------------------------------------------------------------------------------------------------------+
// | PHP version 5.1.1                                                                                    |
// +------------------------------------------------------------------------------------------------------+
// | Copyright (C) 2006 Tela Botanica (accueil@tela-botanica.org)                                         |
// +------------------------------------------------------------------------------------------------------+
// | This file is part of eFlore.                                                                         |
// |                                                                                                      |
// | Foobar is free software; you can redistribute it and/or modify                                       |
// | it under the terms of the GNU General Public License as published by                                 |
// | the Free Software Foundation; either version 2 of the License, or                                    |
// | (at your option) any later version.                                                                  |
// |                                                                                                      |
// | Foobar is distributed in the hope that it will be useful,                                            |
// | but WITHOUT ANY WARRANTY; without even the implied warranty of                                       |
// | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the                                        |
// | GNU General Public License for more details.                                                         |
// |                                                                                                      |
// | You should have received a copy of the GNU General Public License                                    |
// | along with Foobar; if not, write to the Free Software                                                |
// | Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA                            |
// +------------------------------------------------------------------------------------------------------+
// CVS : $Id$
/**
* Classe Projet
*
* Description
*
*@package eFlore
*@subpackage modele
//Auteur original :
*@version 3
*@author        Shaheen ABDOOL RAHEEM <shaheenar50@hotmail.com>
//Autres auteurs :
*@version 4
*@author        Jean-Pascal MILCENT <jpm@clapas.org>
*@author        aucun
*@copyright     Tela-Botanica 2000-2006
*@version       $Revision$ $Date$
// +------------------------------------------------------------------------------------------------------+
*/

/**
* class Projet : est à la fois le DAO et le conteneur de la table gestion_utilisateur.
* classe métier
*/
class Projet extends aGttSql {
	/*** Constantes : */
	const GP_TOUS = 'PROJET_TOUS';
	const GP_ID = 'PROJET_ID';
	const GP_NOM = 'PROJET_NOM';
	const GP_ID_MAX = 'PROJET_ID_MAX';
	const GP_ID_LIST = 'PROJET_ID_LIST';
	const GP_CE_CATEGORIE = 'PROJET_CE_CATEGORIE';

	/*** Attributs : */
	private $id_projet;
	private $ce_projet_parent;
	private $ce_categorie;
	private $nom;
	private $description;
	private $date_debut;
	private $date_fin;
	private $duree_prevue;
	private $duree_finance;
	private $avancement;

	/*** Aggregations : */

	/*** Constructeur : */
	public function __construct($cmd = null, $parametres = null)
	{
		$this->dao_table_nom = 'gestion_projet';
		$this->dao_correspondance = array(
			'gp_id_projet'	=> 'id_projet',
			'gp_ce_projet_parent'	=> 'ce_projet_parent',
			'gp_ce_categorie'	=> 'ce_categorie',
			'gp_nom'	=> 'nom',
			'gp_description'	=> 'description',
			'gp_date_debut'	=> 'date_debut',
			'gp_date_fin'	=> 'date_fin',
			'gp_duree_prevue'	=> 'duree_prevue',
			'gp_duree_finance'	=> 'duree_finance',
			'gp_avancement'	=> 'avancement');

		// Si l'on veut remplir l'objet à la création on lance la requete correspondante
		if (!is_null($cmd)) {
			$this->consulter($cmd, $parametres, true);
		}
	}

	/*** Accesseurs : */
	// Id Projet
	public function getIdProjet()
	{
		return $this->id_projet;
	}
	public function setIdProjet( $ip )
	{
		$this->id_projet = $ip;
	}

	// Ce Projet Parent
	public function getCeProjetParent()
	{
		return $this->ce_projet_parent;
	}
	public function setCeProjetParent( $cpp )
	{
		$this->ce_projet_parent = $cpp;
	}


	// Ce Categorie
	public function getCeCategorie()
	{
		return $this->ce_categorie;
	}
	public function setCeCategorie( $cc )
	{
		$this->ce_categorie = $cc;
	}

	// Nom
	public function getNom()
	{
		return $this->nom;
	}
	public function setNom( $n )
	{
		$this->nom = $n;
	}

	// Description
	public function getDescription()
	{
		return $this->description;
	}
	public function setDescription( $d )
	{
		$this->description = $d;
	}

	// Date Debut
	public function getDateDebut()
	{
		return $this->date_debut;
	}
	public function setDateDebut( $dd )
	{
		$this->date_debut = $dd;
	}
	
	// Date Fin
	public function getDateFin()
	{
		return $this->date_fin;
	}
	public function setDateFin( $df )
	{
		$this->date_fin = $df;
	}

	// Duree Prevue
	public function getDureePrevue()
	{
		return $this->duree_prevue;
	}
	public function setDureePrevue( $dp )
	{
		$this->duree_prevue = $dp;
	}

	// Duree Finance
	public function getDureeFinance()
	{
		return $this->duree_finance;
	}
	public function setDureeFinance( $df )
	{
		$this->duree_finance = $df;
	}

	// Avancement
	public function getAvancement()
	{
		return $this->avancement;
	}
	public function setAvancement( $a )
	{
		$this->avancement = $a;
	}

	/*** Méthodes : */

	/**
	* Consulter la table gestion_projet.
	* @return mixed un tableau d'objets Projet s'il y en a plusieurs, l'objet Projet s'il y en a 1 seul sinon false.
	*/
	public function consulter($cmd = '', $parametres = array(), $instancier = false)
	{
		switch ($cmd) {
			case Projet::GP_TOUS:
				$requete =	'SELECT * '.
							'FROM gestion_projet LEFT JOIN gestion_projet_categorie ON (gp_ce_categorie = gpc_id_categorie) '.
							'ORDER BY gpc_libelle, gp_nom ASC';
				break;
			case Projet::GP_ID:
				$requete = 	'SELECT * '.
							'FROM gestion_projet '.
							'WHERE gp_id_projet =  #0 ';
				break;
			case Projet::GP_NOM:
				$requete =	'SELECT * '.
							'FROM gestion_projet '.
							'WHERE gp_nom = "#0" ';
				break;
			case Projet::GP_ID_MAX:
				$requete =	'SELECT MAX(gp_id_projet) AS gp_id_projet '.
							'FROM gestion_projet ';
				break;
			case Projet::GP_ID_LIST:
				$requete =	'SELECT * '.
							'FROM gestion_projet LEFT JOIN gestion_projet_categorie ON (gp_ce_categorie = gpc_id_categorie) '.
							'WHERE gp_id_projet IN (#0) '.
							'ORDER BY gpc_libelle, gp_nom ASC';
				break;
			case Projet::GP_CE_CATEGORIE:
				$requete =	'SELECT * '.
							'FROM gestion_projet '.
							'WHERE gp_ce_categorie = #0 ';
				break;
			default :
				$message = 'Commande '.$cmd.'inconnue!';
				$e = GestionnaireErreur::formaterMessageErreur(__FILE__, __LINE__, $message);
    			trigger_error($e, E_USER_ERROR);
		}
		return parent::consulter($requete, $parametres, $instancier);
	}
}

/* +--Fin du code ----------------------------------------------------------------------------------------+
*
* $Log$
*
* +-- Fin du code ----------------------------------------------------------------------------------------+
*/
?>