Subversion Repositories eFlore/Archives.eflore-consultation-v2

Rev

Blame | Last modification | View Log | RSS feed

<?php
class TAXON_RECHERCHE_CLASSIFICATION extends macroElement {
    function getSQL()
    {
        $contexte = array();
        if (array_key_exists('etr_id_version_projet_taxon_1', $this->contexteRef) and 
            array_key_exists('etr_id_taxon_1', $this->contexteRef)) {
            
            $contexte['etr_id_version_projet_taxon_1'] = $this->contexteRef['etr_id_version_projet_taxon_1'];
            $contexte['etr_id_taxon_1'] = $this->contexteRef['etr_id_taxon_1'];
            if (!empty($contexte['etr_id_version_projet_taxon_1']) && !empty($contexte['etr_id_taxon_1'])) {
                $requete = 
                'SELECT DISTINCT 
                nom.en_id_nom,
                nom.en_ce_rang,
                intitule.eni_intitule_nom,
                taxon_relation.etr_id_version_projet_taxon_1, 
                taxon_relation.etr_id_taxon_1 
               
                FROM 
                eflore_nom AS nom, 
                eflore_nom_intitule AS intitule, 
                eflore_selection_nom AS selection, 
                eflore_taxon_relation AS taxon_relation
                
                WHERE 
                nom.en_id_nom = intitule.eni_id_nom 
                AND intitule.eni_id_categorie_format = 3 
                AND intitule.eni_id_valeur_format = 4 
                AND nom.en_id_nom = selection.esn_id_nom 
                AND selection.esn_ce_statut = 3 
                AND selection.esn_id_version_projet_taxon = taxon_relation.etr_id_version_projet_taxon_1 
                AND selection.esn_id_taxon = taxon_relation.etr_id_taxon_1
                AND taxon_relation.etr_id_version_projet_taxon_2 = '.$contexte['etr_id_version_projet_taxon_1'].' 
                AND taxon_relation.etr_id_taxon_2 = '.$contexte['etr_id_taxon_1'].' 
                AND taxon_relation.etr_id_categorie_taxon = 3 
                AND taxon_relation.etr_id_valeur_taxon = 3 
                ORDER BY intitule.eni_intitule_nom ASC';
                
                return $requete;
            }
        }
        if (array_key_exists('nvp', $this->contexteRef) and 
            array_key_exists('nt', $this->contexteRef)) {
            
            $contexte['nvp'] = $this->contexteRef['nvp'];
            $contexte['nt'] = $this->contexteRef['nt'];
            if (!empty($contexte['nvp']) && !empty($contexte['nt'])) {
                $requete = 
                'SELECT DISTINCT 
                nom.en_id_nom,
                nom.en_ce_rang,
                intitule.eni_intitule_nom,
                taxon_relation.etr_id_taxon_1, 
                taxon_relation.etr_id_version_projet_taxon_1 
               
                FROM 
                eflore_nom AS nom, 
                eflore_nom_intitule AS intitule, 
                eflore_selection_nom AS selection, 
                eflore_taxon_relation AS taxon_relation
                
                WHERE 
                nom.en_id_nom = intitule.eni_id_nom
                AND intitule.eni_id_categorie_format = 3
                AND intitule.eni_id_valeur_format = 4
                AND nom.en_id_nom = selection.esn_id_nom 
                AND selection.esn_ce_statut = 3 
                AND selection.esn_id_version_projet_taxon = taxon_relation.etr_id_version_projet_taxon_1
                AND selection.esn_id_taxon = taxon_relation.etr_id_taxon_1 
                AND taxon_relation.etr_id_version_projet_taxon_2 = '.$contexte['nvp'].' 
                AND taxon_relation.etr_id_taxon_2 = '.$contexte['nt'].' 
                AND taxon_relation.etr_id_categorie_taxon = 3 
                AND taxon_relation.etr_id_valeur_taxon = 3 
                ORDER BY intitule.eni_intitule_nom ASC';
                
                return $requete;
            }
        }
        if (array_key_exists('nvp', $this->contexteRef) and 
            array_key_exists('rg', $this->contexteRef)) {
            
            $contexte['nvp'] = $this->contexteRef['nvp'];
            $contexte['rg'] = $this->contexteRef['rg'];
            if (!empty($contexte['nvp']) && !empty($contexte['rg'])) {
                $requete = 
                'SELECT DISTINCT 
                nom.en_id_nom,
                intitule.eni_intitule_nom,
                selection.esn_id_taxon,
                selection.esn_id_version_projet_taxon,
                taxon_relation.etr_id_taxon_1 
               
                FROM 
                eflore_nom AS nom, 
                eflore_nom_intitule AS intitule, 
                eflore_selection_nom AS selection, 
                eflore_taxon AS taxon, 
                eflore_taxon_relation AS taxon_relation
                
                WHERE 
                nom.en_id_nom = intitule.eni_id_nom
                AND intitule.eni_id_categorie_format = 3
                AND intitule.eni_id_valeur_format = 4
                AND nom.en_ce_rang = '.$contexte['rg'].' 
                AND nom.en_id_nom = selection.esn_id_nom 
                AND selection.esn_ce_statut = 3 
                AND selection.esn_id_version_projet_taxon = '.$contexte['nvp'].' 
                AND selection.esn_id_version_projet_taxon = taxon.et_id_version_projet_taxon 
                AND selection.esn_id_taxon = taxon.et_id_taxon 
                AND taxon.et_id_version_projet_taxon = taxon_relation.etr_id_version_projet_taxon_2
                AND taxon.et_id_taxon = taxon_relation.etr_id_taxon_2 
                AND taxon_relation.etr_id_categorie_taxon = 3 
                AND taxon_relation.etr_id_valeur_taxon = 3 
                ORDER BY intitule.eni_intitule_nom ASC';
                
                return $requete;
            }
        }
        return null;
    }
}
?>