Subversion Repositories eFlore/Archives.herbiers

Rev

Blame | Last modification | View Log | RSS feed

<?php
/*vim: set expandtab tabstop=4 shiftwidth=4: */ 
// +------------------------------------------------------------------------------------------------------+
// | PHP version 4.1                                                                                      |
// +------------------------------------------------------------------------------------------------------+
// | Copyright (C) 2005 Tela Botanica (accueil@tela-botanica.org)                                         |
// +------------------------------------------------------------------------------------------------------+
// | This file is part of Herbier.                                                                        |
// |                                                                                                      |
// | 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: hb_collection.class.php,v 1.1 2005-11-23 10:32:32 jp_milcent Exp $
/**
* Classe H_collection
*
* Classe permettant de récupérer les données concernant les collections de la base de données.
*
*@package Herbier
*@subpackage Classes
//Auteur original :
*@author        Alexandre GRANIER <alexandre@tela-botanica.org>
//Autres auteurs :
*@author        Jean-Pascal MILCENT <jpm@clapas.org>
*@copyright     Tela-Botanica 2000-2005
*@version       $Revision: 1.1 $ $Date: 2005-11-23 10:32:32 $
// +------------------------------------------------------------------------------------------------------+
*/

// +------------------------------------------------------------------------------------------------------+
// |                                            ENTETE du PROGRAMME                                       |
// +------------------------------------------------------------------------------------------------------+

// +------------------------------------------------------------------------------------------------------+
// |                                            CORPS du PROGRAMME                                        |
// +------------------------------------------------------------------------------------------------------+
/**
*  class H_organisation contient la structure nécessaire pour
*  représenter une table HERBIERS_COLLECTION dont voici
*  la structure
*  @package herbiers
*/
class H_collection {
    var $indic;
    var $included_type;
    var $preservation_method;
    /**
    *  Constructeur de H_collection
    *
    *  @param    aucun
    *  @return    void
    *  @access    public
    */
    function H_collection($id_collection = null) {
        if (!is_null($id_collection)) {
            $this->setId($id_collection);
        }
        $indic = array();
        $preservation_method = array();
    }
    /** Accesseur getId() - Retourner l'id de la collection.
    *
    * @return integer l'identifiant de la collection.
    * @access public
    */
    function getId()
    {
        return $this->id;
    }
    /** Accesseur setId() - Attribuer un id à la collection.
    *
    * @param integer l'identifiant de la collection.
    * @return void l'identifiant est ajouté à l'objet.
    * @access public
    */
    function setId($id)
    {
        $this->id = $id;
    }
    /** Renvoie un objet de type H_collection
    *
    *  Renvoie un objet de type H_collection dont
    *  l'identificateur est spécifié en paramètre.
    *  L'objet correspond à une collection décrite
    *  par la table HERBIERS_COLLECTION
    *
    *  @param    integer $id l'identifiant de la table HERBIERS_COLLECTION
    *  @return    H_collection un objet de la classe H_collection
    *  @access    public
    */
    function getFromSQL($id) {
        $requete =  'SELECT HERBIERS_COLLECTION.*, HERBIERS_COLL_STATUT.LABEL, '.
                        'HERBIERS_DATE_DEBUT_CARAC.LABEL_DATE_DEBUT_CARAC, HERBIERS_DATE_FIN_CARAC.LABEL_DATE_FIN_CARAC, '.
                        'HERBIERS_DENOMBREMENT_CARAC_SP.HDC_LABEL AS SPECIES_LABEL, '.
                        'HERBIERS_DENOMBREMENT_CARAC_SC.HDC_LABEL AS SPECIMENS_LABEL '.
                    'FROM HERBIERS_COLLECTION, HERBIERS_COLL_STATUT, HERBIERS_DATE_DEBUT_CARAC, HERBIERS_DATE_FIN_CARAC, '.
                        'HERBIERS_DENOMBREMENT_CARAC_SC, HERBIERS_DENOMBREMENT_CARAC_SP '.
                    'WHERE ID = '.$id.' '.
                    'AND HERBIERS_COLLECTION.STATUT = HERBIERS_COLL_STATUT.ID_COLL_STATUT '.
                    'AND HERBIERS_COLLECTION.DATE_DEBUT_CARAC = HERBIERS_DATE_DEBUT_CARAC.ID_DATE_CARAC '.
                    'AND HERBIERS_COLLECTION.DATE_FIN_CARAC = HERBIERS_DATE_FIN_CARAC.ID_DATE_CARAC '.
                    'AND HERBIERS_COLLECTION.PREC_SPECIES = HERBIERS_DENOMBREMENT_CARAC_SC.HDC_ID '.
                    'AND HERBIERS_COLLECTION.PREC_SPECIMENS = HERBIERS_DENOMBREMENT_CARAC_SP.HDC_ID';
        $resultat = mysql_query($requete) or die (BOG_afficherErreurSql(__FILE__, __LINE__, mysql_error(), $requete));
        $ligne = mysql_fetch_object($resultat);
        
        foreach (get_object_vars($ligne) as $cle => $valeur) {
            $this->$cle = $valeur;
        }
        mysql_free_result($resultat);
        
        $requete_02 =   'SELECT ID_INDIC '.
                        'FROM HERBIERS_INDIC '.
                        'WHERE ID = '.$id;
        
        $resultat_02 = mysql_query($requete_02) or die(BOG_afficherErreurSql(__FILE__, __LINE__, mysql_error(), $requete_02));
        while ($ligne_02 = mysql_fetch_object($resultat_02)){
            $temp_indic = new H_indic();
            $this->indic[] = $temp_indic->getFromSQL($ligne_02->ID_INDIC);
        }
        
        switch ($this->INCLUDED_TYPE) {
            case 1 :
                $this->included_type = 'non';
            break;
            case 2 :
                $this->included_type = 'oui';
            break;
            case 0 :
                $this->included_type = 'indéterminé';
            break;
        }
        unset($this->INCLUDED_TYPE);
        
        // Récupération de la méthode de préservation
        $this->preservation_method = getPreservationMethod($ligne->ID);
        
        // Transformation des chiffres des champs ETAT en label
        $label_etat = array('1' => 'Inconnu', '2' => 'mauvais', '3' => 'moyen', '4' => 'très bon');
        
        if (!isset($label_etat[$this->ETAT_SPECIMENS])) {
            $label_etat[$this->ETAT_SPECIMENS] = '';
        }
        if (!isset($label_etat[$this->ETAT_PRESENTATION])) {
            $label_etat[$this->ETAT_PRESENTATION] = '';
        }
        if (!isset($label_etat[$this->ETAT_CLASSEMENT])) {
            $label_etat[$this->ETAT_CLASSEMENT] = '';
        }
        
        $this->ETAT_SPECIMENS = $label_etat[$this->ETAT_SPECIMENS];
        $this->ETAT_PRESENTATION = $label_etat[$this->ETAT_PRESENTATION];
        $this->ETAT_CLASSEMENT = $label_etat[$this->ETAT_CLASSEMENT];
        
        return H_Herbier::remplacerEsperluette($this);
    }
}

// +------------------------------------------------------------------------------------------------------+
// |                                            PIED du PROGRAMME                                         |
// +------------------------------------------------------------------------------------------------------+


/* +--Fin du code ----------------------------------------------------------------------------------------+
*
* $Log: not supported by cvs2svn $
* Revision 1.3  2005/04/06 13:29:17  jpm
* Ajout et modifications des objets représentant la base de données Herbier.
*
* Revision 1.2  2005/03/09 15:57:33  jpm
* Modification de la forme.
*
*
* +-- Fin du code ----------------------------------------------------------------------------------------+
*/
?>