From a5a78ff1e46b50fcc42b8eaacaf51b2cfb0c96cd Mon Sep 17 00:00:00 2001 From: gildeluermoz Date: Tue, 22 Mar 2016 09:15:23 +0100 Subject: [PATCH] ajout du contact flore --- apps/backend/config/routing.yml | 45 +- apps/backend/modules/ap/config/security.yml | 16 +- .../modules/bibs/actions/actions.class.php | 39 + apps/backend/modules/bibs/config/security.yml | 2 +- apps/backend/modules/bryo/config/security.yml | 12 +- .../modules/cf/actions/actions.class.php | 54 +- apps/backend/modules/cf/config/security.yml | 2 +- .../modules/cflore/actions/actions.class.php | 237 ++ .../modules/cflore/config/security.yml | 3 + apps/backend/modules/cflore/config/view.yml | 0 .../modules/home/actions/actions.class.php | 10 + apps/backend/modules/home/config/security.yml | 11 +- apps/backend/modules/home/config/view.yml | 31 +- .../home/templates/indexCfloreSuccess.php | 43 + .../modules/invertebre/config/security.yml | 2 +- .../modules/station/config/security.yml | 12 +- apps/backend/modules/zp/config/security.yml | 8 +- config/doctrine/schema.yml | 208 +- data/2154/contactflore.sql | 1266 +++++++++++ data/2154/data_synthese_2154.sql | 64 +- data/update_1.6to1.7.sql | 137 ++ docs/changelog.rst | 26 + install_db.sh | 3 + .../doctrine/BibAbondancesCflore.class.php | 15 + .../BibAbondancesCfloreTable.class.php | 19 + .../doctrine/BibMessagesCflore.class.php | 15 + .../doctrine/BibMessagesCfloreTable.class.php | 11 + .../doctrine/BibPhenologiesCflore.class.php | 15 + .../BibPhenologiesCfloreTable.class.php | 19 + lib/model/doctrine/BibTaxonsTable.class.php | 41 + .../doctrine/CorMessageTaxonCflore.class.php | 15 + .../CorMessageTaxonCfloreTable.class.php | 11 + .../doctrine/CorRoleFicheCflore.class.php | 15 + .../CorRoleFicheCfloreTable.class.php | 11 + .../doctrine/CorUniteTaxonCflore.class.php | 15 + .../CorUniteTaxonCfloreTable.class.php | 11 + lib/model/doctrine/SyntheseffTable.class.php | 57 +- lib/model/doctrine/TFichesCfTable.class.php | 11 - lib/model/doctrine/TFichesCflore.class.php | 15 + .../doctrine/TFichesCfloreTable.class.php | 97 + lib/model/doctrine/TRelevesCflore.class.php | 16 + .../doctrine/TRelevesCfloreTable.class.php | 49 + lib/model/doctrine/TRolesTable.class.php | 13 + .../doctrine/VNomadeTaxonsFlore.class.php | 15 + .../VNomadeTaxonsFloreTable.class.php | 11 + .../base/BaseBibAbondancesCflore.class.php | 47 + lib/model/doctrine/base/BaseBibLots.class.php | 7 + .../base/BaseBibMessagesCflore.class.php | 47 + .../base/BaseBibPhenologiesCflore.class.php | 47 + .../doctrine/base/BaseBibTaxons.class.php | 136 +- .../base/BaseCorMessageTaxonCflore.class.php | 55 + .../base/BaseCorMessageTaxonInv.class.php | 8 +- .../base/BaseCorRoleFicheCf.class.php | 4 +- .../base/BaseCorRoleFicheCflore.class.php | 55 + .../base/BaseCorUniteTaxonCflore.class.php | 83 + .../base/BaseCorUniteTaxonInv.class.php | 2 +- .../doctrine/base/BaseLCommunes.class.php | 7 + .../doctrine/base/BaseLUnitesGeo.class.php | 27 +- .../doctrine/base/BaseTFichesCflore.class.php | 181 ++ .../doctrine/base/BaseTProtocoles.class.php | 7 + .../base/BaseTRelevesCflore.class.php | 147 ++ lib/model/doctrine/base/BaseTRoles.class.php | 7 + .../base/BaseVNomadeTaxonsFlore.class.php | 103 + lib/model/fauneUsers.class.php | 1 + lib/sfGeonatureConfig.php.sample | 4 + web/js/cflore/application.cflore.editFiche.js | 1989 +++++++++++++++++ web/js/cflore/application.cflore.js | 402 ++++ .../application.cflore.layerWindowFactory.js | 170 ++ web/js/config.js.sample | 25 +- .../application.invertebre.editFiche.js | 16 +- .../application.synthese.editCflore.js | 1896 ++++++++++++++++ .../application.synthese.editInvertebre.js | 17 +- web/js/synthese/application.synthese.js | 12 + .../synthese/application.synthese.search.js | 23 +- 74 files changed, 8050 insertions(+), 203 deletions(-) create mode 100755 apps/backend/modules/cflore/actions/actions.class.php create mode 100755 apps/backend/modules/cflore/config/security.yml create mode 100755 apps/backend/modules/cflore/config/view.yml create mode 100755 apps/backend/modules/home/templates/indexCfloreSuccess.php create mode 100644 data/2154/contactflore.sql create mode 100644 data/update_1.6to1.7.sql create mode 100644 lib/model/doctrine/BibAbondancesCflore.class.php create mode 100644 lib/model/doctrine/BibAbondancesCfloreTable.class.php create mode 100644 lib/model/doctrine/BibMessagesCflore.class.php create mode 100644 lib/model/doctrine/BibMessagesCfloreTable.class.php create mode 100644 lib/model/doctrine/BibPhenologiesCflore.class.php create mode 100644 lib/model/doctrine/BibPhenologiesCfloreTable.class.php create mode 100644 lib/model/doctrine/CorMessageTaxonCflore.class.php create mode 100644 lib/model/doctrine/CorMessageTaxonCfloreTable.class.php create mode 100644 lib/model/doctrine/CorRoleFicheCflore.class.php create mode 100644 lib/model/doctrine/CorRoleFicheCfloreTable.class.php create mode 100644 lib/model/doctrine/CorUniteTaxonCflore.class.php create mode 100644 lib/model/doctrine/CorUniteTaxonCfloreTable.class.php create mode 100644 lib/model/doctrine/TFichesCflore.class.php create mode 100644 lib/model/doctrine/TFichesCfloreTable.class.php create mode 100644 lib/model/doctrine/TRelevesCflore.class.php create mode 100644 lib/model/doctrine/TRelevesCfloreTable.class.php create mode 100644 lib/model/doctrine/VNomadeTaxonsFlore.class.php create mode 100644 lib/model/doctrine/VNomadeTaxonsFloreTable.class.php create mode 100644 lib/model/doctrine/base/BaseBibAbondancesCflore.class.php create mode 100644 lib/model/doctrine/base/BaseBibMessagesCflore.class.php create mode 100644 lib/model/doctrine/base/BaseBibPhenologiesCflore.class.php create mode 100644 lib/model/doctrine/base/BaseCorMessageTaxonCflore.class.php create mode 100644 lib/model/doctrine/base/BaseCorRoleFicheCflore.class.php create mode 100644 lib/model/doctrine/base/BaseCorUniteTaxonCflore.class.php create mode 100644 lib/model/doctrine/base/BaseTFichesCflore.class.php create mode 100644 lib/model/doctrine/base/BaseTRelevesCflore.class.php create mode 100644 lib/model/doctrine/base/BaseVNomadeTaxonsFlore.class.php create mode 100755 web/js/cflore/application.cflore.editFiche.js create mode 100755 web/js/cflore/application.cflore.js create mode 100755 web/js/cflore/application.cflore.layerWindowFactory.js create mode 100755 web/js/synthese/application.synthese.editCflore.js diff --git a/apps/backend/config/routing.yml b/apps/backend/config/routing.yml index 2cab0657b0..7d69060331 100755 --- a/apps/backend/config/routing.yml +++ b/apps/backend/config/routing.yml @@ -148,7 +148,27 @@ saveStationBryo: saveTaxonBryo: url: /bryo/savetaxon param: { module: bryo, action: saveTaxon } - + +# Partie contact flore +saveFicheCflore: + url: /cflore/save + param: { module: cflore, action: saveCflore } +deleteFicheCflore: + url: /cflore/deletefiche + param: { module: cflore, action: deleteFicheCflore } +deleteReleveCflore: + url: /cflore/deletereleve + param: { module: cflore, action: deleteReleveCflore } +getZCflore: + url: /cflore/getz + param: { module: cflore, action: getZ } +getOneFicheCflore: + url: /cflore/getone/:id_cflore + param: { module: cflore, action: getOneFiche } +getListRelevesCflore: + url: /cflore/listreleves/:id_cflore + param: { module: cflore, action: getListRelevesCflore } + # Partie contact faune saveFicheCf: url: /cf/save @@ -227,7 +247,7 @@ getTaxonsCfUnite: url: /bibs/taxonscfu param: { module: bibs, action: listTaxonsCfu } -# Menus déroulants flore +# Menus déroulants flore listObservateursFlore: url: /bibs/observateurs param: { module: bibs, action: listObservateursFlore } @@ -240,6 +260,9 @@ filtreObservateursFs: filtreObservateursBryo: url: /bibs/filtreobservateursbryo param: { module: bibs, action: filtreObservateursBryo } +filtreObservateursCflore: + url: /bibs/filtreobservateurscflore + param: { module: bibs, action: filtreObservateursCflore } anneesFp: url: /bibs/listanneefp param: { module: bibs, action: listAnneeFp } @@ -306,6 +329,15 @@ abondances: abondancesBryo: url: /bibs/abondancesbryo param: { module: bibs, action: listAbondancesBryo } +abondancesCflore: + url: /bibs/abondancescflore + param: { module: bibs, action: listAbondancesCflore } +phenologiesCflore: + url: /bibs/phenologiescflore + param: { module: bibs, action: listPhenologiesCflore } +validitesCflore: + url: /bibs/validitescflore + param: { module: bibs, action: listValiditesCflore } expositions: url: /bibs/expositions param: { module: bibs, action: listExpositions } @@ -330,6 +362,12 @@ supports: idSophie: url: /bibs/sophie param: { module: bibs, action: listSophie } +getTaxonsCflore: + url: /bibs/taxonscflore + param: { module: bibs, action: listTaxonsCflore } +getTaxonsCfloreUnite: + url: /bibs/taxonscfloreu + param: { module: bibs, action: listTaxonsCfloreu } #Menus déroulants synthèse getAnneesSynthese: @@ -401,6 +439,9 @@ fs: bryo: url: /bryo param: { module: home, action: indexBryo } +cflore: + url: /cflore + param: { module: home, action: indexCflore } synthese: url: /synthese param: { module: home, action: indexSynthese } diff --git a/apps/backend/modules/ap/config/security.yml b/apps/backend/modules/ap/config/security.yml index cce69f0497..fe2b22774d 100644 --- a/apps/backend/modules/ap/config/security.yml +++ b/apps/backend/modules/ap/config/security.yml @@ -1,24 +1,24 @@ all: is_secure: true - credentials: [[ administrateur, redacteur, utilisateur, referent ]] + credentials: [[ administrateur, redacteur, utilisateur, referent, validateur ]] xls: - credentials: [[ administrateur, redacteur, utilisateur, referent ]] + credentials: [[ administrateur, redacteur, utilisateur, referent, validateur ]] is_secure: true delete: - credentials: [[ administrateur, redacteur, referent ]] + credentials: [[ administrateur, redacteur, referent, validateur ]] is_secure: true save: - credentials: [[ administrateur, redacteur, referent ]] + credentials: [[ administrateur, redacteur, referent, validateur ]] is_secure: true validate: - credentials: [[ administrateur, redacteur, referent ]] + credentials: [[ administrateur, redacteur, referent, validateur ]] is_secure: true deleteZp: - credentials: [[ administrateur, redacteur, referent ]] + credentials: [[ administrateur, redacteur, referent, validateur ]] is_secure: true saveZp: - credentials: [[ administrateur, redacteur, referent ]] + credentials: [[ administrateur, redacteur, referent, validateur ]] is_secure: true uploadFileGpx: - credentials: [[ administrateur, redacteur, referent ]] + credentials: [[ administrateur, redacteur, referent, validateur ]] is_secure: true \ No newline at end of file diff --git a/apps/backend/modules/bibs/actions/actions.class.php b/apps/backend/modules/bibs/actions/actions.class.php index 8c493df856..0f4d05857d 100755 --- a/apps/backend/modules/bibs/actions/actions.class.php +++ b/apps/backend/modules/bibs/actions/actions.class.php @@ -224,6 +224,45 @@ public function executeListAnneeBryo(sfRequest $request) $annees = TStationsBryoTable::listAnneeBryo(); return $this->renderJSON($annees); } + + //---------------- CONTACT FLORE --------------------------------- + public function executeListTaxonsCflore(sfRequest $request) + { + $val = BibTaxonsTable::listCflore(); + return $this->renderText(json_encode($val)); + } + + public function executeListTaxonsCfloreu(sfRequest $request) + { + $srid_loc = sfGeonatureConfig::$srid_local; + $point = $request->getParameter('point'); + $dbh = Doctrine_Manager::getInstance()->getCurrentConnection()->getDbh(); + $sql = "SELECT DISTINCT id_unite_geo + FROM layers.l_unites_geo + WHERE ST_intersects(the_geom,ST_transform(st_setsrid(ST_GeomFromText('$point',3857),3857),".$srid_loc."))"; + $array_unite = $dbh->query($sql); + foreach($array_unite as $val){ + $id_unite_geo = $val['id_unite_geo']; + } + if($id_unite_geo!=null){ + $val = BibTaxonsTable::listCfloreUnite($id_unite_geo);} + else{$val = BibTaxonsTable::listCflore();} + + return $this->renderText(json_encode($val)); + } + + public function executeListAbondancesCflore(sfRequest $request) + { + $val = BibAbondancesCfloreTable::listAll(); + return $this->renderText(json_encode($val)); + } + + public function executeListPhenologiesCflore(sfRequest $request) + { + $val = BibPhenologiesCfloreTable::listAll(); + return $this->renderText(json_encode($val)); + } + //---------------- CONTACT FAUNE --------------------------------- public function executeListObservateursCfAdd(sfRequest $request) { diff --git a/apps/backend/modules/bibs/config/security.yml b/apps/backend/modules/bibs/config/security.yml index a537dc66ce..bb9aa2d62d 100644 --- a/apps/backend/modules/bibs/config/security.yml +++ b/apps/backend/modules/bibs/config/security.yml @@ -1,3 +1,3 @@ all: - credentials: [[ administrateur, redacteur, utilisateur, referent ]] + credentials: [[ administrateur, redacteur, utilisateur, referent, validateur ]] is_secure: true \ No newline at end of file diff --git a/apps/backend/modules/bryo/config/security.yml b/apps/backend/modules/bryo/config/security.yml index d244d01291..0e2aa0d9dc 100644 --- a/apps/backend/modules/bryo/config/security.yml +++ b/apps/backend/modules/bryo/config/security.yml @@ -1,18 +1,18 @@ all: is_secure: true - credentials: [[ administrateur, redacteur, utilisateur, referent ]] + credentials: [[ administrateur, redacteur, utilisateur, referent, validateur ]] xls: - credentials: [[ administrateur, redacteur, referent ]] + credentials: [[ administrateur, redacteur, referent, validateur ]] is_secure: true delete: - credentials: [[ administrateur, redacteur, referent ]] + credentials: [[ administrateur, redacteur, referent, validateur ]] is_secure: true deleteTaxon: - credentials: [[ administrateur, redacteur, referent ]] + credentials: [[ administrateur, redacteur, referent, validateur ]] is_secure: true saveTaxon: - credentials: [[ administrateur, redacteur, referent ]] + credentials: [[ administrateur, redacteur, referent, validateur ]] is_secure: true save: - credentials: [[ administrateur, redacteur, referent ]] + credentials: [[ administrateur, redacteur, referent, validateur ]] is_secure: true \ No newline at end of file diff --git a/apps/backend/modules/cf/actions/actions.class.php b/apps/backend/modules/cf/actions/actions.class.php index aeb6064c19..e3e54d264b 100755 --- a/apps/backend/modules/cf/actions/actions.class.php +++ b/apps/backend/modules/cf/actions/actions.class.php @@ -83,7 +83,7 @@ public function saveTaxons($id_cf,$string_taxons,$monaction) // $new_cd_nom = $request->getParameter('new_cd_nom'); // $old_cd_nom = $request->getParameter('old_cd_nom'); - //on vérifie que le taxon (old ou new) n'existe pas déjà éventuellement avec supprime = true pour cette station + //on vérifie que le taxon (old ou new) n'existe pas déjà éventuellement avec supprime = true pour cette station // $verif_new = Doctrine::getTable('CorFsTaxon')->find(array($id_station,$new_cd_nom)); // if($verif_new){$verif_new->delete();}// si oui on le supprime // if($old_cd_nom>0){ @@ -93,24 +93,24 @@ public function saveTaxons($id_cf,$string_taxons,$monaction) // print_r($string_taxons); $array_taxons = explode('|',$string_taxons); - // Suppression des taxons qui existe et qui ont été supprimé dans le formulaire javascript + // Suppression des taxons qui existe et qui ont été supprimé dans le formulaire javascript $mon_array = array(); // dans ce tableau on va pousser tous les enregistrements qui ont un id_releve_cf donc ceux qui ne sont pas nouveau foreach ($array_taxons as $string_taxon){ $array_taxon = explode(",",$string_taxon); if($array_taxon[0]!='' OR $array_taxon[0]!=null){array_push($mon_array,$array_taxon[0]);} } //s'il y a des id_releve_cf on boucle pour supprimer ceux de la fiche qui ne serait plus dans le tableau $array_taxon - // si comme dans le cas d'un ajout de taxon pour une nouvelle fiche, il n'y a pas encore de id_releve_cf il n'y a rien à supprimer + // si comme dans le cas d'un ajout de taxon pour une nouvelle fiche, il n'y a pas encore de id_releve_cf il n'y a rien à supprimer if(count($mon_array)>0){ - $string_del_tx = implode(', ',$mon_array);//on créé une chaine avec les taxon à supprimer + $string_del_tx = implode(', ',$mon_array);//on créé une chaine avec les taxon à supprimer $dbh = Doctrine_Manager::getInstance()->getCurrentConnection()->getDbh(); $sql = "UPDATE contactfaune.t_releves_cf SET supprime = true WHERE id_cf = $id_cf AND id_releve_cf NOT IN ($string_del_tx);"; $a = $dbh->query($sql); } - //on boucle sur la chaine des taxons envoyée par le formulaire pour récupérer les champs et on insert ou on update + //on boucle sur la chaine des taxons envoyée par le formulaire pour récupérer les champs et on insert ou on update foreach ($array_taxons as $string_taxon){ $array_taxon = explode(",",$string_taxon); - // Récupération des valeurs dans des variables + // Récupération des valeurs dans des variables $id_releve_cf = $array_taxon[0]; $id_taxon = $array_taxon[1]; $nom_taxon_saisi = $array_taxon[4]; @@ -125,7 +125,7 @@ public function saveTaxons($id_cf,$string_taxons,$monaction) $commentaire = $array_taxon[13]; $determinateur = $array_taxon[14]; $cd_ref_origine = $array_taxon[15]; - //on récupère l'enregistrement ou on le crée + //on récupère l'enregistrement ou on le crée // $taxon = new TRelevesCf(); if($id_releve_cf==null OR $id_releve_cf==''){ $taxon = new TRelevesCf(); @@ -160,8 +160,8 @@ public function saveTaxons($id_cf,$string_taxons,$monaction) public function executeSaveCf(sfRequest $request) { if($this->getUser()->isAuthenticated()){ - $monaction = $request->getParameter('monaction');//on récupère l'action pour savoir si on update ou si on créé un nouvel enregistrement - //création de l'objet selon update ou ajout + $monaction = $request->getParameter('monaction');//on récupère l'action pour savoir si on update ou si on créé un nouvel enregistrement + //création de l'objet selon update ou ajout switch ($monaction) { case 'add': $new_id_cf = TFichesCfTable::getMaxIdFiche()+1; @@ -184,7 +184,7 @@ public function executeSaveCf(sfRequest $request) $d = array(); $pattern = '/^(\d{2})\/(\d{2})\/(\d{4})/'; preg_match($pattern, $request->getParameter('dateobs'), $d); $datepg = sprintf('%s-%s-%s', $d[3],$d[2],$d[1]); - //affectation des valeurs reçues du formulaire extjs + //affectation des valeurs reçues du formulaire extjs $fiche->dateobs = $datepg; $fiche->pdop = sfGeonatureConfig::$default_pdop; if($request->getParameter('altitude_saisie')=='' OR !$request->hasParameter('altitude_saisie')){$altitude_saisie=-1;} else{$altitude_saisie=$request->getParameter('altitude_saisie');} @@ -218,10 +218,10 @@ public function executeSaveCf(sfRequest $request) $crfc->save(); } } - //sauvegarde de la géometrie de la fiche - // on le fait après l'enregistrement des observateurs car l'insertion de la géométrie va provoquer le trigger update - // et ce trigger met à jour la synthese, dont les observateurs. Si on insert les observateurs après, cela ne mettrait - //pas à jour la synthese. + //sauvegarde de la géometrie de la fiche + // on le fait après l'enregistrement des observateurs car l'insertion de la géométrie va provoquer le trigger update + // et ce trigger met à jour la synthese, dont les observateurs. Si on insert les observateurs après, cela ne mettrait + //pas à jour la synthese. $geometry = $request->getParameter('geometry'); Doctrine_Query::create() ->update('TFichesCf') @@ -242,21 +242,21 @@ public function saveTaxonsMortalite($id_cf,$string_taxons,$monaction) { if($this->getUser()->isAuthenticated()){ $array_taxons = explode('|',$string_taxons); - // Suppression des taxons qui existe et qui ont été supprimé dans le formulaire javascript + // Suppression des taxons qui existe et qui ont été supprimé dans le formulaire javascript $mon_array = array(); // dans ce tableau on va pousser tous les enregistrements qui ont un id_releve_cf donc ceux qui ne sont pas nouveau foreach ($array_taxons as $string_taxon){ $array_taxon = explode(",",$string_taxon); if($array_taxon[0]!='' OR $array_taxon[0]!=null){array_push($mon_array,$array_taxon[0]);} } //s'il y a des id_releve_cf on boucle pour supprimer ceux de la fiche qui ne serait plus dans le tableau $array_taxon - // si comme dans le cas d'un ajout de taxon pour une nouvelle fiche, il n'y a pas encore de id_releve_cf il n'y a rien à supprimer + // si comme dans le cas d'un ajout de taxon pour une nouvelle fiche, il n'y a pas encore de id_releve_cf il n'y a rien à supprimer if(count($mon_array)>0){ - $string_del_tx = implode(', ',$mon_array);//on créé une chaine avec les taxon à supprimer + $string_del_tx = implode(', ',$mon_array);//on créé une chaine avec les taxon à supprimer $dbh = Doctrine_Manager::getInstance()->getCurrentConnection()->getDbh(); $sql = "UPDATE contactfaune.t_releves_cf SET supprime = true WHERE id_cf = $id_cf AND id_releve_cf NOT IN ($string_del_tx);"; $a = $dbh->query($sql); } - //on boucle sur la chaine des taxons envoyée par le formulaire pour récupérer les champs et on insert ou on update + //on boucle sur la chaine des taxons envoyée par le formulaire pour récupérer les champs et on insert ou on update foreach ($array_taxons as $string_taxon){ $array_taxon = explode(",",$string_taxon); //construction de variable dynamique avec le nom des champs @@ -264,7 +264,7 @@ public function saveTaxonsMortalite($id_cf,$string_taxons,$monaction) // ${$var$array_keys[$i]} = $array_taxon[$i]; // $taxons->{$var$array_keys[$i]} = $array_taxon[$i]; // } - // Récupération des valeurs dans des variables + // Récupération des valeurs dans des variables $id_releve_cf = $array_taxon[0]; $id_taxon = $array_taxon[1]; $nom_taxon_saisi = $array_taxon[4]; @@ -280,7 +280,7 @@ public function saveTaxonsMortalite($id_cf,$string_taxons,$monaction) $cd_ref_origine = $array_taxon[15]; $prelevement = $array_taxon[18]; $determinateur = $array_taxon[19]; - //on récupère l'enregistrement ou on le crée + //on récupère l'enregistrement ou on le crée // $taxon = new TRelevesCf(); if($id_releve_cf==null OR $id_releve_cf==''){ $taxon = new TRelevesCf(); @@ -315,8 +315,8 @@ public function saveTaxonsMortalite($id_cf,$string_taxons,$monaction) public function executeSaveMortalite(sfRequest $request) { if($this->getUser()->isAuthenticated()){ - $monaction = $request->getParameter('monaction');//on récupère l'action pour savoir si on update ou si on créé un nouvel enregistrement - //création de l'objet selon update ou ajout + $monaction = $request->getParameter('monaction');//on récupère l'action pour savoir si on update ou si on créé un nouvel enregistrement + //création de l'objet selon update ou ajout switch ($monaction) { case 'add': $new_id_cf = TFichesCfTable::getMaxIdFiche()+1; @@ -336,7 +336,7 @@ public function executeSaveMortalite(sfRequest $request) $d = array(); $pattern = '/^(\d{2})\/(\d{2})\/(\d{4})/'; preg_match($pattern, $request->getParameter('dateobs'), $d); $datepg = sprintf('%s-%s-%s', $d[3],$d[2],$d[1]); - //affectation des valeurs reçues du formulaire extjs + //affectation des valeurs reçues du formulaire extjs $fiche->dateobs = $datepg; $fiche->pdop = sfGeonatureConfig::$default_pdop; if($request->getParameter('altitude_saisie')=='' OR !$request->hasParameter('altitude_saisie')){$altitude_saisie=-1;} else{$altitude_saisie=$request->getParameter('altitude_saisie');} @@ -372,10 +372,10 @@ public function executeSaveMortalite(sfRequest $request) $crfc->save(); } } - //sauvegarde de la géometrie de la fiche - // on le fait après l'enregistrement des observateurs car l'insertion de la géométrie va provoquer le trigger update - // et ce trigger met à jour la synthese, dont les observateurs. Si on insert les observateurs après, cela ne mettrait - //pas à jour la synthese. + //sauvegarde de la géometrie de la fiche + // on le fait après l'enregistrement des observateurs car l'insertion de la géométrie va provoquer le trigger update + // et ce trigger met à jour la synthese, dont les observateurs. Si on insert les observateurs après, cela ne mettrait + //pas à jour la synthese. $geometry = $request->getParameter('geometry'); Doctrine_Query::create() ->update('TFichesCf') diff --git a/apps/backend/modules/cf/config/security.yml b/apps/backend/modules/cf/config/security.yml index 89ccc6d266..2db81fcbf3 100755 --- a/apps/backend/modules/cf/config/security.yml +++ b/apps/backend/modules/cf/config/security.yml @@ -1,3 +1,3 @@ all: is_secure: true - credentials: [[ administrateur, redacteur ]] \ No newline at end of file + credentials: [[ administrateur, redacteur , validateur ]] \ No newline at end of file diff --git a/apps/backend/modules/cflore/actions/actions.class.php b/apps/backend/modules/cflore/actions/actions.class.php new file mode 100755 index 0000000000..2f0c470ad1 --- /dev/null +++ b/apps/backend/modules/cflore/actions/actions.class.php @@ -0,0 +1,237 @@ +geojson = new Services_GeoJson(); + } + + /** + * Get GeoJSON fiche from id_cflore passed + * @param sfRequest $request + * @return sfView::NONE + */ + public function executeGetOneFiche(sfRequest $request) + { + if ($request->hasParameter('id_cflore') && $request->getParameter('format','')=='geoJSON') + { + $fiche = TFichesCfloreTable::findOne($request->getParameter('id_cflore'), 'geoJSON'); + if (empty($fiche)) + return $this->renderText(sfGeonatureActions::$EmptyGeoJSON); + else + return $this->renderText($this->geojson->encode(array($fiche), 'the_geom_3857', 'id_cflore')); + } + } + + public function executeGetListRelevesCflore(sfRequest $request) + { + $taxons = TRelevesCfloreTable::getListRelevesCflore($request->getParameter('id_cflore')); + return $this->renderJSON($taxons); + } + + /** + * Delete a fiche (in fact mark it as supprime=true) + * @param sfRequest $request + * @return sfView::NONE + */ + public function executeDeleteFicheCflore(sfRequest $request) + { + if($this->getUser()->isAuthenticated()){ + $this->forward404Unless($t=TfichesCfloreTable::get($request->getParameter('id_cflore'))); + $t->set('supprime', true); + if ($t->trySave()){ + Doctrine_Query::create() + ->update('TfichesCflore') + ->set('supprime', '?', true) + ->where('id_cflore=?', $t->getId_cflore()) + ->execute(); + return $this->renderSuccess(); + } + else{return $this->throwError();} + } + else{return sfView::ERROR;} + } + + public function executeDeleteReleveCflore(sfRequest $request) + { + if($this->getUser()->isAuthenticated()){ + $id_releve_cflore = $request->getParameter('id_releve_cflore'); + Doctrine_Query::create() + ->update('TRelevesCflore') + ->set('supprime', '?', true) + ->where('id_releve_cflore=?', $id_releve_cflore) + ->execute(); + return $this->renderSuccess(); + } + else{return sfView::ERROR;} + } + + public function saveTaxons($id_cflore,$string_taxons,$monaction) + { + if($this->getUser()->isAuthenticated()){ + $array_taxons = explode('|',$string_taxons); + // Suppression des taxons qui existe et qui ont été supprimé dans le formulaire javascript + $mon_array = array(); // dans ce tableau on va pousser tous les enregistrements qui ont un id_releve_cflore donc ceux qui ne sont pas nouveau + foreach ($array_taxons as $string_taxon){ + $array_taxon = explode(",",$string_taxon); + if($array_taxon[0]!='' OR $array_taxon[0]!=null){array_push($mon_array,$array_taxon[0]);} + } + //s'il y a des id_releve_cflore on boucle pour supprimer ceux de la fiche qui ne serait plus dans le tableau $array_taxon + // si comme dans le cas d'un ajout de taxon pour une nouvelle fiche, il n'y a pas encore de id_releve_cflore il n'y a rien à supprimer + if(count($mon_array)>0){ + $string_del_tx = implode(', ',$mon_array);//on créé une chaine avec les taxon à supprimer + $dbh = Doctrine_Manager::getInstance()->getCurrentConnection()->getDbh(); + $sql = "UPDATE contactflore.t_releves_cflore SET supprime = true WHERE id_cflore = $id_cflore AND id_releve_cflore NOT IN ($string_del_tx);"; + $a = $dbh->query($sql); + } + //on boucle sur la chaine des taxons envoyée par le formulaire pour récupérer les champs et on insert ou on update + foreach ($array_taxons as $string_taxon){ + $array_taxon = explode(",",$string_taxon); + // Récupération des valeurs dans des variables + $id_releve_cflore = $array_taxon[0]; + $id_taxon = $array_taxon[1]; + $nom_taxon_saisi = $array_taxon[4]; + $id_abondance_cflore = $array_taxon[5]; + $id_phenologie_cflore = $array_taxon[6]; + $validite_cflore = $array_taxon[7]; + $commentaire = $array_taxon[8]; + $determinateur = $array_taxon[9]; + $cd_ref_origine = $array_taxon[10]; + $herbier = $array_taxon[12]; + //on récupère l'enregistrement ou on le crée + // $taxon = new TRelevesCflore(); + if($id_releve_cflore==null OR $id_releve_cflore==''){ + $taxon = new TRelevesCflore(); + $id_releve_cflore = TRelevesCfloreTable::getMaxIdReleve()+1; + } + else{$taxon = Doctrine::getTable('TRelevesCflore')->find($id_releve_cflore);} + //on passe les valeur et on enregistre + $taxon->id_releve_cflore = $id_releve_cflore; + $taxon->id_cflore = $id_cflore; + $taxon->id_taxon = $id_taxon; + $taxon->nom_taxon_saisi = str_replace('',',',$nom_taxon_saisi); + $taxon->id_abondance_cflore = $id_abondance_cflore; + $taxon->id_phenologie_cflore = $id_phenologie_cflore; + $taxon->validite_cflore = $validite_cflore; + $taxon->commentaire = str_replace('',',',$commentaire); + $taxon->determinateur = str_replace('',',',$determinateur); + $taxon->cd_ref_origine = $cd_ref_origine; + $taxon->herbier = $herbier; + $taxon->save(); + } + // return $this->renderText("{success: true,data:".print_r($taxon)."}"); + return true; + } + else{return sfView::ERROR;} + } + + public function executeSaveCflore(sfRequest $request) + { + if($this->getUser()->isAuthenticated()){ + $monaction = $request->getParameter('monaction');//on récupère l'action pour savoir si on update ou si on créé un nouvel enregistrement + //création de l'objet selon update ou ajout + switch ($monaction) { + case 'add': + $new_id_cflore = TFichesCfloreTable::getMaxIdFiche()+1; + $fiche = new TfichesCflore(); + break; + case 'update': + $fiche = Doctrine::getTable('TfichesCflore')->find($request->getParameter('id_cflore')); + break; + default: + break; + } + if($monaction=='add') { + $id_cflore = $new_id_cflore; + $fiche->id_cflore = $id_cflore; + $fiche->saisie_initiale = 'web'; + $fiche->id_organisme = sfGeonatureConfig::$id_organisme; + $fiche->id_protocole = sfGeonatureConfig::$id_protocole_cflore; + } + //remise au format de la date + $d = array(); $pattern = '/^(\d{2})\/(\d{2})\/(\d{4})/'; + preg_match($pattern, $request->getParameter('dateobs'), $d); + $datepg = sprintf('%s-%s-%s', $d[3],$d[2],$d[1]); + //affectation des valeurs reçues du formulaire extjs + $fiche->dateobs = $datepg; + $fiche->pdop = sfGeonatureConfig::$default_pdop; + if($request->getParameter('altitude_saisie')=='' OR !$request->hasParameter('altitude_saisie')){$altitude_saisie=-1;} else{$altitude_saisie=$request->getParameter('altitude_saisie');} + $fiche->altitude_saisie = $altitude_saisie; + $fiche->supprime = false; + $fiche->srid_dessin = sfGeonatureConfig::$srid_dessin; + $fiche->id_lot = sfGeonatureConfig::$id_lot_cflore; + $fiche->save();//enregistrement avec la methode save de symfony + // ensuite on commence par supprimer tout ce qui concerne cette fiche si on est en update + + if($monaction=='update'){ + $id_cflore = $request->getParameter('id_cflore'); + //suppression des observateurs de la fiche + $deleted = Doctrine_Query::create() + ->delete() + ->from('CorRoleFicheCflore crfc') + ->where('crfc.id_cflore = ?', $id_cflore) + ->execute(); + } + //enregistrement dans la table cor_role_fiche_cflore + $ids_observateurs = $request->getParameter('ids_observateurs'); + $array_observateurs = array(); + if($ids_observateurs!=''){$array_observateurs = explode(",",$ids_observateurs);} + if(count($array_observateurs)>0){ + foreach ($array_observateurs as $id_role) + { + $crfc = new CorRoleFicheCflore(); + $crfc->id_cflore = $id_cflore; + $crfc->id_role = $id_role; + $crfc->save(); + } + } + //sauvegarde de la géometrie de la fiche + // on le fait après l'enregistrement des observateurs car l'insertion de la géométrie va provoquer le trigger update + // et ce trigger met à jour la synthese, dont les observateurs. Si on insert les observateurs après, cela ne mettrait + //pas à jour la synthese. + $geometry = $request->getParameter('geometry'); + Doctrine_Query::create() + ->update('TFichesCflore') + ->set('the_geom_3857','st_geometryFromText(?, 3857)', $geometry) + ->where('id_cflore= ?', $fiche->getId_cflore()) + ->execute(); + + if($request->hasParameter('sting_taxons')){self::saveTaxons($id_cflore,$request->getParameter('sting_taxons'),$monaction);} + return $this->renderText("{success: true,id_cflore:".$fiche->getId_cflore()."}"); + // return $this->renderSuccess();//retour ajax pour Extjs ; retourne {success: true} + } + else{ + $this->redirect('@login'); + } + } + + + public function executeGetZ(sfRequest $request) + { + $point = $request->getParameter('point'); + $srid_layer_commune = sfGeonatureConfig::$srid_local; + $srid_layer_isoline = sfGeonatureConfig::$srid_local; + $dbh = Doctrine_Manager::getInstance()->getCurrentConnection()->getDbh(); + $sql = "SELECT layers.f_isolines20(ST_transform(st_setsrid(ST_GeomFromText('$point',3857),3857),".$srid_layer_isoline.")) AS z, + layers.f_nomcommune(ST_transform(st_setsrid(ST_GeomFromText('$point',3857),3857),".$srid_layer_commune.")) AS nomcommune"; + $array_z = $dbh->query($sql); + foreach($array_z as $val){ + $z = $val['z']; + $nomcommune = str_replace("'","\'",$val['nomcommune']); + } + if($z==null){$z=0;} + if($nomcommune==null){$nomcommune='hors zone';} + return $this->renderText("{success: true,data:{altitude:".$z.",nomcommune:'".$nomcommune."'}}"); + } +} diff --git a/apps/backend/modules/cflore/config/security.yml b/apps/backend/modules/cflore/config/security.yml new file mode 100755 index 0000000000..be22a25af9 --- /dev/null +++ b/apps/backend/modules/cflore/config/security.yml @@ -0,0 +1,3 @@ +all: + is_secure: true + credentials: [[ administrateur, validateur, redacteur ]] \ No newline at end of file diff --git a/apps/backend/modules/cflore/config/view.yml b/apps/backend/modules/cflore/config/view.yml new file mode 100755 index 0000000000..e69de29bb2 diff --git a/apps/backend/modules/home/actions/actions.class.php b/apps/backend/modules/home/actions/actions.class.php index 7d1532310b..baa70a9089 100755 --- a/apps/backend/modules/home/actions/actions.class.php +++ b/apps/backend/modules/home/actions/actions.class.php @@ -114,6 +114,16 @@ public function executeIndexCf(sfRequest $request) } } + public function executeIndexCflore(sfRequest $request) + { + if($this->getUser()->isAuthenticated()){ + slot('title', sfGeonatureConfig::$appname_cflore); + } + else{ + $this->redirect('@login'); + } + } + public function executeIndexMortalite(sfRequest $request) { if($this->getUser()->isAuthenticated()){ diff --git a/apps/backend/modules/home/config/security.yml b/apps/backend/modules/home/config/security.yml index b89dadef26..1847da52d6 100755 --- a/apps/backend/modules/home/config/security.yml +++ b/apps/backend/modules/home/config/security.yml @@ -1,12 +1,15 @@ all: is_secure: true - credentials: [[ administrateur, redacteur, utilisateur, referent ]] + credentials: [[ administrateur, redacteur, utilisateur, referent, validateur ]] cf: - credentials: [[ administrateur, redacteur ]] + credentials: [[ administrateur, redacteur, validateur ]] is_secure: true invertebre: - credentials: [[ administrateur, redacteur ]] + credentials: [[ administrateur, redacteur, validateur ]] is_secure: true mortalite: - credentials: [[ administrateur, redacteur ]] + credentials: [[ administrateur, redacteur, validateur ]] + is_secure: true +cflore: + credentials: [[ administrateur, validateur , redacteur]] is_secure: true \ No newline at end of file diff --git a/apps/backend/modules/home/config/view.yml b/apps/backend/modules/home/config/view.yml index 1b6960991d..3575d8a6d0 100755 --- a/apps/backend/modules/home/config/view.yml +++ b/apps/backend/modules/home/config/view.yml @@ -52,6 +52,7 @@ indexSyntheseSuccess: - synthese/application.synthese.layerWindowFactory.js - synthese/application.synthese.search.js - synthese/application.synthese.editCf.js + - synthese/application.synthese.editCflore.js - synthese/application.synthese.editInvertebre.js - synthese/application.synthese.editMortalite.js @@ -81,7 +82,35 @@ indexCfSuccess: - SuperBoxSelect.js - cf/application.cf.js - cf/application.cf.layerWindowFactory.js - - cf/application.cf.editFiche.js + - cf/application.cf.editFiche.js + +indexCfloreSuccess: + stylesheets: + - ../js/client/mfbase/ext-3.4.0/resources/css/ext-all.css + - ../js/client/mfbase/ext-3.4.0/resources/css/xtheme-gray.css + - "http://api.ign.fr/geoportail/api/js/2.0.0/theme/geoportal/style.css" + - main.css + - superboxselect.css + - geoportail.css + javascripts: + - client/mfbase/ext-3.4.0/adapter/ext/ext-base.js + - client/mfbase/ext-3.4.0/ext-all.js + - client/mfbase/ext-3.4.0/src/locale/ext-lang-fr.js + - client/mfbase/openlayers/OpenLayers.js + - client/mfbase/openlayers/lib/OpenLayers/Lang/fr.js + - "http://api.ign.fr/geoportail/api/js/2.0.0/GeoportalMin.js" + - client/mfbase/mapfish/MapFish-all-min.js + - client/mfbase/mapfish/lang/fr.js + - config.js + - configmap.js + - accents.js + - Ext.ux.form.TwinTriggerComboBox.js + - Ext.ux.Toast.js + - Ext.ux.GpsLocation.js + - SuperBoxSelect.js + - cflore/application.cflore.js + - cflore/application.cflore.layerWindowFactory.js + - cflore/application.cflore.editFiche.js indexMortaliteSuccess: stylesheets: diff --git a/apps/backend/modules/home/templates/indexCfloreSuccess.php b/apps/backend/modules/home/templates/indexCfloreSuccess.php new file mode 100755 index 0000000000..c7ba415c43 --- /dev/null +++ b/apps/backend/modules/home/templates/indexCfloreSuccess.php @@ -0,0 +1,43 @@ + + +
+
+
+

Chargement…

+

Contact flore

+
+
+
+ + \ No newline at end of file diff --git a/apps/backend/modules/invertebre/config/security.yml b/apps/backend/modules/invertebre/config/security.yml index 7e50fb4b01..7fcc1a68fd 100755 --- a/apps/backend/modules/invertebre/config/security.yml +++ b/apps/backend/modules/invertebre/config/security.yml @@ -1,3 +1,3 @@ all: - credentials: [[ administrateur, redacteur ]] + credentials: [[ administrateur, redacteur, validateur ]] is_secure: true \ No newline at end of file diff --git a/apps/backend/modules/station/config/security.yml b/apps/backend/modules/station/config/security.yml index 66fd5a754e..2a589d2ee8 100644 --- a/apps/backend/modules/station/config/security.yml +++ b/apps/backend/modules/station/config/security.yml @@ -1,18 +1,18 @@ all: is_secure: true - credentials: [[ administrateur, redacteur, utilisateur, referent ]] + credentials: [[ administrateur, redacteur, utilisateur, referent, validateur ]] delete: - credentials: [[ administrateur, redacteur, referent ]] + credentials: [[ administrateur, redacteur, referent, validateur ]] is_secure: true deleteTaxon: - credentials: [[ administrateur, redacteur, referent ]] + credentials: [[ administrateur, redacteur, referent, validateur ]] is_secure: true validate: - credentials: [[ administrateur, redacteur, referent ]] + credentials: [[ administrateur, redacteur, referent, validateur ]] is_secure: true saveTaxon: - credentials: [[ administrateur, redacteur, referent ]] + credentials: [[ administrateur, redacteur, referent, validateur ]] is_secure: true save: - credentials: [[ administrateur, redacteur, referent ]] + credentials: [[ administrateur, redacteur, referent, validateur ]] is_secure: true diff --git a/apps/backend/modules/zp/config/security.yml b/apps/backend/modules/zp/config/security.yml index 204e208fbf..b2b4079a75 100644 --- a/apps/backend/modules/zp/config/security.yml +++ b/apps/backend/modules/zp/config/security.yml @@ -1,12 +1,12 @@ all: - credentials: [[ administrateur, redacteur, utilisateur, referent ]] + credentials: [[ administrateur, redacteur, utilisateur, referent, validateur ]] is_secure: true save: - credentials: [[ administrateur, redacteur, referent ]] + credentials: [[ administrateur, redacteur, referent, validateur ]] is_secure: true delete: - credentials: [[ administrateur, redacteur, referent ]] + credentials: [[ administrateur, redacteur, referent, validateur ]] is_secure: true validate: - credentials: [[ administrateur, redacteur, referent ]] + credentials: [[ administrateur, redacteur, referent, validateur ]] is_secure: true \ No newline at end of file diff --git a/config/doctrine/schema.yml b/config/doctrine/schema.yml index 9a28a220d3..be9cacc40d 100755 --- a/config/doctrine/schema.yml +++ b/config/doctrine/schema.yml @@ -5,6 +5,13 @@ BibAbondances: type: string(1) primary: true nom_abondance: string(128) +BibAbondancesCflore: + tableName: contactflore.bib_abondances_cflore + columns: + id_abondance_cflore: + type: integer(4) + primary: true + nom_abondance_cflore: string(25) BibAbondancesBryo: tableName: bryophytes.bib_abondances columns: @@ -168,6 +175,13 @@ BibMessagesCf: type: integer(4) primary: true texte_message_cf: string(255) +BibMessagesCflore: + tableName: contactflore.bib_messages_cflore + columns: + id_message_cflore: + type: integer(4) + primary: true + texte_message_cflore: string(255) BibMessagesInv: tableName: contactinv.bib_messages_inv columns: @@ -214,6 +228,13 @@ BibPerturbations: description: type: string(65) notnull: true +BibPhenologiesCflore: + tableName: contactflore.bib_phenologies_cflore + columns: + id_phenologie_cflore: + type: integer(4) + primary: true + nom_phenologie_cflore: string(100) BibPhenologies: tableName: florepatri.bib_phenologies columns: @@ -569,6 +590,26 @@ CorMessageTaxonCf: local: id_message_cf foreign: id_message_cf foreignAlias: CorMessageTaxonCf +CorMessageTaxonCflore: + tableName: contactflore.cor_message_taxon_cflore + columns: + id_message_cflore: + type: integer(4) + primary: true + id_taxon: + type: integer(4) + primary: true + relations: + BibTaxons: + class: BibTaxons + local: id_taxon + foreign: id_taxon + foreignAlias: CorMessageTaxonCflore + BibMessagesCflore: + class: BibMessagesCflore + local: id_message_cflore + foreign: id_message_cflore + foreignAlias: CorMessageTaxonCflore CorMessageTaxonInv: tableName: contactinv.cor_message_taxon columns: @@ -584,7 +625,7 @@ CorMessageTaxonInv: local: id_taxon foreign: id_taxon foreignAlias: CorMessageTaxonInv - BibMessagesCf: + BibMessagesInv: class: BibMessagesInv local: id_message_inv foreign: id_message_inv @@ -682,7 +723,7 @@ CorRoleFicheCf: type: integer(4) primary: true id_cf: - type: integer(5) + type: integer(4) notnull: true relations: TRoles: @@ -694,6 +735,27 @@ CorRoleFicheCf: class: TFichesCf local: id_cf foreign: id_cf + foreignAlias: CorRoleFicheCf +CorRoleFicheCflore: + tableName: contactflore.cor_role_fiche_cflore + columns: + id_role: + type: integer(4) + primary: true + id_cflore: + type: integer(4) + notnull: true + relations: + TRoles: + class: TRoles + local: id_role + foreign: id_role + foreignAlias: CorRoleFicheCflore + TFichesCflore: + class: TFichesCflore + local: id_cflore + foreign: id_cflore + foreignAlias: CorRoleFicheCflore CorRoleFicheInv: tableName: contactinv.cor_role_fiche_inv columns: @@ -713,6 +775,7 @@ CorRoleFicheInv: class: TFichesInv local: id_inv foreign: id_inv + foreignAlias: CorRoleFicheInv CorRoleMenu: tableName: utilisateurs.cor_role_menu columns: @@ -777,6 +840,29 @@ CorUniteTaxon: local: id_unite_geo foreign: id_unite_geo foreignAlias: CorUniteTaxon +CorUniteTaxonCflore: + tableName: contactflore.cor_unite_taxon_cflore + columns: + id_taxon: + type: integer(4) + primary: true + id_unite_geo: + type: integer(4) + primary: true + derniere_date: date(25) + couleur: string(10) + nb_obs: integer(4) + relations: + BibTaxons: + class: BibTaxons + local: id_taxon + foreign: id_taxon + foreignAlias: CorUniteTaxonCflore + LUnitesGeo: + class: LUnitesGeo + local: id_unite_geo + foreign: id_unite_geo + foreignAlias: CorUniteTaxonCflore CorUniteTaxonInv: tableName: contactinv.cor_unite_taxon_inv columns: @@ -785,7 +871,7 @@ CorUniteTaxonInv: primary: true id_unite_geo: type: integer(4) - notnull: true + primary: true derniere_date: date(25) couleur: string(10) nb_obs: integer(4) @@ -1236,6 +1322,51 @@ TFichesCf: local: id_organisme foreign: id_organisme foreignAlias: TFichesCf +TFichesCflore: + tableName: contactflore.t_fiches_cflore + columns: + id_cflore: + type: integer(8) + primary: true + insee: string(5) + id_organisme: integer(4) + id_protocole: integer(4) + id_lot: integer(4) + dateobs: date(25) + altitude_saisie: integer(4) + altitude_sig: integer(4) + altitude_retenue: integer(4) + date_insert: timestamp(25) + date_update: timestamp(25) + supprime: + type: boolean(1) + notnull: true + pdop: integer(4) + srid_dessin: integer(4) + saisie_initiale: string(20) + the_geom_2154: blob() + the_geom_3857: blob() + relations: + LCommunes: + class: LCommunes + local: insee + foreign: insee + foreignAlias: TFichesCflore + TProtocoles: + class: TProtocoles + local: id_protocole + foreign: id_protocole + foreignAlias: TFichesCflore + BibLots: + class: BibLots + local: id_lot + foreign: id_lot + foreignAlias: TFichesCflore + BibProprietaires: + class: BibProprietaires + local: id_organisme + foreign: id_organisme + foreignAlias: TFichesCflore TFichesInv: tableName: contactinv.t_fiches_inv columns: @@ -1347,6 +1478,48 @@ TRelevesCf: local: id_cf foreign: id_cf foreignAlias: TRelevesCf +TRelevesCflore: + tableName: contactflore.t_releves_cflore + columns: + id_releve_cflore: + type: integer(5) + primary: true + id_cflore: integer(5) + id_taxon: integer(4) + id_abondance_cflore: integer(4) + id_phenologie_cflore: integer(4) + validite_cflore: boolean(1) + cd_ref_origine: integer(4) + nom_taxon_saisi: string(100) + commentaire: string() + determinateur: string(255) + supprime: + type: boolean(1) + notnull: true + herbier: + type: boolean(1) + notnull: true + relations: + BibAbondancesCflore: + class: BibAbondancesCflore + local: id_abondance_cflore + foreign: id_abondance_cflore + foreignAlias: TRelevesCflore + BibPhenologiesCflore: + class: BibPhenologiesCflore + local: id_phenologie_cflore + foreign: id_phenologie_cflore + foreignAlias: TRelevesCflore + BibTaxons: + class: BibTaxons + local: id_taxon + foreign: id_taxon + foreignAlias: TRelevesCflore + TFichesCflore: + class: TFichesCflore + local: id_cf + foreign: id_cf + foreignAlias: TRelevesCflore TRelevesInv: tableName: contactinv.t_releves_inv columns: @@ -1723,6 +1896,35 @@ VNomadeTaxonsFaune: local: id_taxon foreign: id_taxon foreignAlias: VNomadeTaxonsFaune +VNomadeTaxonsFlore: + tableName: contactflore.v_nomade_taxons_flore + columns: + id_taxon: + type: integer(8) + primary: true + cd_ref: integer(8) + cd_nom: integer(8) + nom_latin: string(100) + nom_francais: string(50) + id_classe: integer(8) + patrimonial: boolean(1) + message: string(255) + relations: + BibTaxons: + class: BibTaxons + local: id_taxon + foreign: id_taxon + foreignAlias: VNomadeTaxonsFlore + CorUniteTaxonCflore: + class: CorUniteTaxonCflore + local: id_taxon + foreign: id_taxon + foreignAlias: VNomadeTaxonsFlore + TRelevesCflore: + class: TRelevesCflore + local: id_taxon + foreign: id_taxon + foreignAlias: VNomadeTaxonsFlore VNomadeTaxonsInv: tableName: contactinv.v_nomade_taxons_inv columns: diff --git a/data/2154/contactflore.sql b/data/2154/contactflore.sql new file mode 100644 index 0000000000..f4684224d1 --- /dev/null +++ b/data/2154/contactflore.sql @@ -0,0 +1,1266 @@ +-- +-- PostgreSQL database dump +-- + +-- Dumped from database version 9.3.5 +-- Dumped by pg_dump version 9.3.1 +-- Started on 2016-03-21 17:06:14 + +SET statement_timeout = 0; +SET lock_timeout = 0; +SET client_encoding = 'UTF8'; +SET standard_conforming_strings = on; +SET check_function_bodies = false; +SET client_min_messages = warning; + +-- +-- TOC entry 18 (class 2615 OID 1387972) +-- Name: contactflore; Type: SCHEMA; Schema: -; Owner: geonatuser +-- + +CREATE SCHEMA contactflore; + + +ALTER SCHEMA contactflore OWNER TO geonatuser; + +SET search_path = contactflore, pg_catalog; + +-- +-- TOC entry 1504 (class 1255 OID 1388146) +-- Name: couleur_taxon(integer, date); Type: FUNCTION; Schema: contactflore; Owner: geonatuser +-- + +CREATE FUNCTION couleur_taxon(id integer, maxdateobs date) RETURNS text + LANGUAGE plpgsql + AS $$ +--fonction permettant de renvoyer la couleur d'un taxon à partir de la dernière date d'observation +-- +--Gil DELUERMOZ mars 2016 + + DECLARE + couleur text; + patri character(3); + BEGIN + SELECT filtre2 INTO patri + FROM taxonomie.bib_taxons + WHERE id_taxon = id; + IF patri = 'oui' THEN + IF date_part('year',maxdateobs)=date_part('year',now()) THEN couleur = 'gray'; + ELSE couleur = 'red'; + END IF; + ELSIF patri = 'non' THEN + IF date_part('year',maxdateobs)>=date_part('year',now())-3 THEN couleur = 'gray'; + ELSE couleur = 'red'; + END IF; + ELSE + return false; + END IF; + return couleur; + END; +$$; + + +ALTER FUNCTION contactflore.couleur_taxon(id integer, maxdateobs date) OWNER TO geonatuser; + +-- +-- TOC entry 1496 (class 1255 OID 1387973) +-- Name: insert_fiche_cflore(); Type: FUNCTION; Schema: contactflore; Owner: geonatuser +-- + +CREATE FUNCTION insert_fiche_cflore() RETURNS trigger + LANGUAGE plpgsql + AS $$ +DECLARE +macommune character(5); +BEGIN +------- si le pointage est deja dans la BDD alors le trigger retourne null (l'insertion de la ligne est annulée). +IF new.id_cflore in (SELECT id_cflore FROM contactflore.t_fiches_cflore) THEN + return null; +ELSE + new.date_insert= 'now'; + new.date_update= 'now'; +-------gestion des infos relatives a la numerisation (srid utilisé et support utilisé : nomade ou web ou autre) + IF new.saisie_initiale = 'pda' OR new.saisie_initiale = 'nomade' THEN + new.srid_dessin = 2154; + new.the_geom_3857 = st_transform(new.the_geom_2154,3857); + ELSIF new.saisie_initiale = 'web' THEN + new.srid_dessin = 3857; + -- attention : pas de creation des geom 2154 car c'est fait par l'application web + ELSIF new.saisie_initiale ISNULL THEN + new.srid_dessin = 0; + -- pas d'info sur le srid utilisé, cas des importations à gérer manuellement. Ne devrait pas exister. + END IF; +-------gestion des divers control avec attributions des secteurs + communes : dans le cas d'un insert depuis le nomade uniquement via the_geom !!!! + IF st_isvalid(new.the_geom_2154) = true THEN -- si la topologie est bonne alors... + -- on calcul la commune + SELECT INTO macommune c.insee FROM layers.l_communes c WHERE st_intersects(c.the_geom, new.the_geom_2154); + new.insee = macommune; + -- on calcul l'altitude + new.altitude_sig = layers.f_isolines20(new.the_geom_2154); -- mise à jour de l'altitude sig + IF new.altitude_saisie IS null OR new.altitude_saisie = -1 THEN-- mis à jour de l'altitude retenue + new.altitude_retenue = new.altitude_sig; + ELSE + new.altitude_retenue = new.altitude_saisie; + END IF; + ELSE + SELECT INTO macommune c.insee FROM layers.l_communes c WHERE st_intersects(c.the_geom, ST_PointFromWKB(st_centroid(Box2D(new.the_geom_2154)),2154)); + new.insee = macommune; + -- on calcul l'altitude + new.altitude_sig = layers.f_isolines20(ST_PointFromWKB(st_centroid(Box2D(new.the_geom_2154)),2154)); -- mise à jour de l'altitude sig + IF new.altitude_saisie IS null OR new.altitude_saisie = -1 THEN-- mis à jour de l'altitude retenue + new.altitude_retenue = new.altitude_sig; + ELSE + new.altitude_retenue = new.altitude_saisie; + END IF; + END IF; + RETURN NEW; +END IF; +END; +$$; + + +ALTER FUNCTION contactflore.insert_fiche_cflore() OWNER TO geonatuser; + +-- +-- TOC entry 1497 (class 1255 OID 1387974) +-- Name: insert_releve_cflore(); Type: FUNCTION; Schema: contactflore; Owner: geonatuser +-- + +CREATE FUNCTION insert_releve_cflore() RETURNS trigger + LANGUAGE plpgsql + AS $$ +DECLARE +cdnom integer; +re integer; +unite integer; +nbobs integer; +line record; +fiche record; +BEGIN + --récup du cd_nom du taxon + SELECT INTO cdnom cd_nom FROM taxonomie.bib_taxons WHERE id_taxon = new.id_taxon; + --récup du cd_ref du taxon pour le stocker en base au moment de l'enregistrement (= conseil inpn) + SELECT INTO re taxonomie.find_cdref(cd_nom) FROM taxonomie.bib_taxons WHERE id_taxon = new.id_taxon; + new.cd_ref_origine = re; + -- MAJ de la table cor_unite_taxon, on commence par récupérer l'unité à partir du pointage (table t_fiches_cf) + SELECT INTO fiche * FROM contactflore.t_fiches_cflore WHERE id_cflore = new.id_cflore; + SELECT INTO unite u.id_unite_geo FROM layers.l_unites_geo u WHERE ST_INTERSECTS(fiche.the_geom_2154,u.the_geom); + --si on est dans une des unités on peut mettre à jour la table cor_unite_taxon, sinon on fait rien + IF unite>0 THEN + SELECT INTO line * FROM contactflore.cor_unite_taxon WHERE id_unite_geo = unite AND id_taxon = new.id_taxon; + --si la ligne existe dans cor_unite_taxon on la supprime + IF line IS NOT NULL THEN + DELETE FROM contactflore.cor_unite_taxon WHERE id_unite_geo = unite AND id_taxon = new.id_taxon; + END IF; + --on compte le nombre d'enregistrement pour ce taxon dans l'unité + SELECT INTO nbobs count(*) from synthese.syntheseff s + JOIN layers.l_unites_geo u ON ST_Intersects(u.the_geom, s.the_geom_2154) AND u.id_unite_geo = unite + WHERE s.cd_nom = cdnom; + --on créé ou recréé la ligne + INSERT INTO contactflore.cor_unite_taxon VALUES(unite,new.id_taxon,fiche.dateobs,contactflore.couleur_taxon(new.id_taxon,fiche.dateobs), nbobs+1); + END IF; + RETURN NEW; +END; +$$; + + +ALTER FUNCTION contactflore.insert_releve_cflore() OWNER TO geonatuser; + +-- +-- TOC entry 1498 (class 1255 OID 1387975) +-- Name: synthese_delete_releve_cflore(); Type: FUNCTION; Schema: contactflore; Owner: geonatuser +-- + +CREATE FUNCTION synthese_delete_releve_cflore() RETURNS trigger + LANGUAGE plpgsql + AS $$ +DECLARE + idsource integer; +BEGIN + --SUPRESSION EN SYNTHESE + + SELECT INTO idsource id_source FROM synthese.bib_sources WHERE db_schema='contactflore' AND db_field = 'id_releve_cflore' ; + + DELETE FROM synthese.syntheseff WHERE id_source = idsource AND id_fiche_source = old.id_releve_cflore::text; + RETURN OLD; +END; +$$; + + +ALTER FUNCTION contactflore.synthese_delete_releve_cflore() OWNER TO geonatuser; + +-- +-- TOC entry 1505 (class 1255 OID 1387976) +-- Name: synthese_insert_releve_cflore(); Type: FUNCTION; Schema: contactflore; Owner: geonatuser +-- + +CREATE FUNCTION synthese_insert_releve_cflore() RETURNS trigger + LANGUAGE plpgsql + AS $$ +DECLARE + fiche RECORD; + mesobservateurs character varying(255); + idsourcecflore integer; +BEGIN + --Récupération des données id_source dans la table synthese.bib_sources + SELECT INTO idsourcecflore id_source FROM synthese.bib_sources WHERE db_schema='contactflore' AND db_field = 'id_releve_cflore' AND nom_source = 'Contact flore'; + --Récupération des données dans la table t_fiches_cf et de la liste des observateurs + SELECT INTO fiche * FROM contactflore.t_fiches_cflore WHERE id_cflore = new.id_cflore; + + SELECT INTO mesobservateurs o.observateurs FROM contactflore.t_releves_cflore r + JOIN contactflore.t_fiches_cflore f ON f.id_cflore = r.id_cflore + LEFT JOIN ( + SELECT id_cflore, array_to_string(array_agg(r.nom_role || ' ' || r.prenom_role), ', ') AS observateurs + FROM contactflore.cor_role_fiche_cflore c + JOIN utilisateurs.t_roles r ON r.id_role = c.id_role + GROUP BY id_cflore + ) o ON o.id_cflore = f.id_cflore + WHERE r.id_releve_cflore = new.id_releve_cflore; + + INSERT INTO synthese.syntheseff ( + id_source, + id_fiche_source, + code_fiche_source, + id_organisme, + id_protocole, + id_precision, + cd_nom, + insee, + dateobs, + observateurs, + determinateur, + altitude_retenue, + remarques, + derniere_action, + supprime, + the_geom_3857, + the_geom_2154, + the_geom_point, + id_lot + ) + VALUES( + idsourcecflore, + new.id_releve_cflore, + 'f'||new.id_cflore||'-r'||new.id_releve_cflore, + fiche.id_organisme, + fiche.id_protocole, + 1, + new.cd_ref_origine, + fiche.insee, + fiche.dateobs, + mesobservateurs, + new.determinateur, + fiche.altitude_retenue, + new.commentaire, + 'c', + false, + fiche.the_geom_3857, + fiche.the_geom_2154, + fiche.the_geom_3857, + fiche.id_lot + ); + RETURN NEW; +END; +$$; + + +ALTER FUNCTION contactflore.synthese_insert_releve_cflore() OWNER TO geonatuser; + +-- +-- TOC entry 1499 (class 1255 OID 1387977) +-- Name: synthese_update_cor_role_fiche_cflore(); Type: FUNCTION; Schema: contactflore; Owner: geonatuser +-- + +CREATE FUNCTION synthese_update_cor_role_fiche_cflore() RETURNS trigger + LANGUAGE plpgsql + AS $$ +DECLARE + releves RECORD; + test integer; + mesobservateurs character varying(255); + sources RECORD; + idsource integer; + idsourcecflore integer; +BEGIN + -- + --CE TRIGGER NE DEVRAIT SERVIR QU'EN CAS DE MISE A JOUR MANUELLE SUR CETTE TABLE cor_role_fiche_cf + --L'APPLI WEB ET LES TABLETTES NE FONT QUE DES INSERTS QUI SONT GERER PAR LE TRIGGER INSERT DE t_releves_cf + -- + --on doit boucler pour récupérer le id_source car il y en a 2 possibles (cf et mortalité) pour le même schéma + FOR sources IN SELECT id_source, url FROM synthese.bib_sources WHERE db_schema='contactflore' AND db_field = 'id_releve_cflore' LOOP + IF sources.url = 'cflore' THEN + idsourcecflore = sources.id_source; + END IF; + END LOOP; + + --Récupération des enregistrements de la table t_releves_cf avec l'id_cf de la table cor_role_fiche_cf + FOR releves IN SELECT * FROM contactflore.t_releves_cflore WHERE id_cflore = new.id_cflore LOOP + --test si on a bien l'enregistrement dans la table syntheseff avant de le mettre à jour + SELECT INTO test id_fiche_source FROM synthese.syntheseff + WHERE (id_source = idsourcecflore) AND id_fiche_source = releves.id_releve_cflore::text; + IF test ISNULL THEN + RETURN null; + ELSE + SELECT INTO mesobservateurs o.observateurs FROM contactflore.t_releves_cflore r + JOIN contactflore.t_fiches_cflore f ON f.id_cflore = r.id_cflore + LEFT JOIN ( + SELECT id_cflore, array_to_string(array_agg(r.nom_role || ' ' || r.prenom_role), ', ') AS observateurs + FROM contactflore.cor_role_fiche_cflore c + JOIN utilisateurs.t_roles r ON r.id_role = c.id_role + GROUP BY id_cflore + ) o ON o.id_cflore = f.id_cflore + WHERE r.id_releve_cflore = releves.id_releve_cflore; + --mise à jour de l'enregistrement correspondant dans syntheseff ; uniquement le champ observateurs ici + UPDATE synthese.syntheseff SET + observateurs = mesobservateurs + WHERE (id_source = idsourcecflore) AND id_fiche_source = releves.id_releve_cflore::text; + END IF; + END LOOP; + RETURN NEW; +END; +$$; + + +ALTER FUNCTION contactflore.synthese_update_cor_role_fiche_cflore() OWNER TO geonatuser; + +-- +-- TOC entry 1500 (class 1255 OID 1387978) +-- Name: synthese_update_fiche_cflore(); Type: FUNCTION; Schema: contactflore; Owner: geonatuser +-- + +CREATE FUNCTION synthese_update_fiche_cflore() RETURNS trigger + LANGUAGE plpgsql + AS $$ +DECLARE + releves RECORD; + test integer; + mesobservateurs character varying(255); + sources RECORD; + idsourcecflore integer; +BEGIN + + --on doit boucler pour récupérer le id_source car il y en a 2 possibles (cf et mortalité) pour le même schéma + FOR sources IN SELECT id_source, url FROM synthese.bib_sources WHERE db_schema='contactflore' AND db_field = 'id_releve_cflore' LOOP + IF sources.url = 'cflore' THEN + idsourcecflore = sources.id_source; + END IF; + END LOOP; + --Récupération des données de la table t_releves_cf avec l'id_cf de la fiche modifié + -- Ici on utilise le OLD id_cf pour être sur qu'il existe dans la table synthese (cas improbable où on changerait la pk de la table t_fiches_cf + --le trigger met à jour avec le NEW --> SET code_fiche_source = .... + FOR releves IN SELECT * FROM contactflore.t_releves_cflore WHERE id_cflore = old.id_cflore LOOP + --test si on a bien l'enregistrement dans la table syntheseff avant de le mettre à jour + SELECT INTO test id_fiche_source FROM synthese.syntheseff WHERE id_fiche_source = releves.id_releve_cflore::text AND (id_source = idsourcecflore); + IF test IS NOT NULL THEN + SELECT INTO mesobservateurs o.observateurs FROM contactflore.t_releves_cflore r + JOIN contactflore.t_fiches_cflore f ON f.id_cflore = r.id_cflore + LEFT JOIN ( + SELECT id_cflore, array_to_string(array_agg(r.nom_role || ' ' || r.prenom_role), ', ') AS observateurs + FROM contactflore.cor_role_fiche_cflore c + JOIN utilisateurs.t_roles r ON r.id_role = c.id_role + GROUP BY id_cflore + ) o ON o.id_cflore = f.id_cflore + WHERE r.id_releve_cflore = releves.id_releve_cflore; + IF NOT St_Equals(new.the_geom_3857,old.the_geom_3857) OR NOT St_Equals(new.the_geom_2154,old.the_geom_2154) THEN + + --mise à jour de l'enregistrement correspondant dans syntheseff + UPDATE synthese.syntheseff SET + code_fiche_source = 'f'||new.id_cflore||'-r'||releves.id_releve_cf, + id_organisme = new.id_organisme, + id_protocole = new.id_protocole, + insee = new.insee, + dateobs = new.dateobs, + observateurs = mesobservateurs, + altitude_retenue = new.altitude_retenue, + derniere_action = 'u', + supprime = new.supprime, + the_geom_3857 = new.the_geom_3857, + the_geom_2154 = new.the_geom_2154, + the_geom_point = new.the_geom_3857, + id_lot = new.id_lot + WHERE id_fiche_source = releves.id_releve_cflore::text AND (id_source = idsourcecflore) ; + ELSE + --mise à jour de l'enregistrement correspondant dans syntheseff + UPDATE synthese.syntheseff SET + code_fiche_source = 'f'||new.id_cflore||'-r'||releves.id_releve_cflore, + id_organisme = new.id_organisme, + id_protocole = new.id_protocole, + insee = new.insee, + dateobs = new.dateobs, + observateurs = mesobservateurs, + altitude_retenue = new.altitude_retenue, + derniere_action = 'u', + supprime = new.supprime, + the_geom_3857 = new.the_geom_3857, + the_geom_2154 = new.the_geom_2154, + the_geom_point = new.the_geom_3857, + id_lot = new.id_lot + WHERE id_fiche_source = releves.id_releve_cflore::text AND (id_source = idsourcecflore); + END IF; + END IF; + END LOOP; + RETURN NEW; +END; +$$; + + +ALTER FUNCTION contactflore.synthese_update_fiche_cflore() OWNER TO geonatuser; + +-- +-- TOC entry 1501 (class 1255 OID 1387979) +-- Name: synthese_update_releve_cflore(); Type: FUNCTION; Schema: contactflore; Owner: geonatuser +-- + +CREATE FUNCTION synthese_update_releve_cflore() RETURNS trigger + LANGUAGE plpgsql + AS $$ +DECLARE + test integer; + sources RECORD; + idsourcecflore integer; +BEGIN + + --on doit boucler pour récupérer le id_source car il y en a 2 possibles (cflore et mortalité) pour le même schéma + FOR sources IN SELECT id_source, url FROM synthese.bib_sources WHERE db_schema='contactflore' AND db_field = 'id_releve_cflore' LOOP + IF sources.url = 'cflore' THEN + idsourcecflore = sources.id_source; + END IF; + END LOOP; + --test si on a bien l'enregistrement dans la table syntheseff avant de le mettre à jour + SELECT INTO test id_fiche_source FROM synthese.syntheseff WHERE id_fiche_source = old.id_releve_cflore::text AND (id_source = idsourcecflore); + IF test IS NOT NULL THEN + + + --mise à jour de l'enregistrement correspondant dans syntheseff + UPDATE synthese.syntheseff SET + id_fiche_source = new.id_releve_cflore, + code_fiche_source = 'f'||new.id_cflore||'-r'||new.id_releve_cflore, + cd_nom = new.cd_ref_origine, + remarques = new.commentaire, + determinateur = new.determinateur, + derniere_action = 'u', + supprime = new.supprime + WHERE id_fiche_source = old.id_releve_cflore::text AND (id_source = idsourcecflore); -- Ici on utilise le OLD id_releve_cflore pour être sur + --qu'il existe dans la table synthese (cas improbable où on changerait la pk de la table t_releves_cflore + --le trigger met à jour avec le NEW --> SET id_fiche_source = new.id_releve_cflore + END IF; + RETURN NEW; +END; +$$; + + +ALTER FUNCTION contactflore.synthese_update_releve_cflore() OWNER TO geonatuser; + +-- +-- TOC entry 1502 (class 1255 OID 1387980) +-- Name: update_fiche_cflore(); Type: FUNCTION; Schema: contactflore; Owner: geonatuser +-- + +CREATE FUNCTION update_fiche_cflore() RETURNS trigger + LANGUAGE plpgsql + AS $$ +DECLARE +macommune character(5); +BEGIN +-------------------------- gestion des infos relatives a la numerisation (srid utilisé et support utilisé : pda ou web ou sig) +-------------------------- attention la saisie sur le web réalise un insert sur qq données mais the_geom_3857 est "faussement inséré" par un update !!! +IF (NOT ST_Equals(new.the_geom_2154,old.the_geom_2154) OR (old.the_geom_2154 is null AND new.the_geom_2154 is NOT NULL)) + OR (NOT ST_Equals(new.the_geom_3857,old.the_geom_3857) OR (old.the_geom_3857 is null AND new.the_geom_3857 is NOT NULL)) + THEN + IF NOT ST_Equals(new.the_geom_3857,old.the_geom_3857) OR (old.the_geom_3857 is null AND new.the_geom_3857 is NOT NULL) THEN + new.the_geom_2154 = st_transform(new.the_geom_3857,2154); + new.srid_dessin = 3857; + ELSIF NOT ST_Equals(new.the_geom_2154,old.the_geom_2154) OR (old.the_geom_2154 is null AND new.the_geom_2154 is NOT NULL) THEN + new.the_geom_3857 = st_transform(new.the_geom_2154,3857); + new.srid_dessin = 2154; + END IF; +-------gestion des divers control avec attributions de la commune : dans le cas d'un insert depuis le nomade uniquement via the_geom_2154 !!!! + IF st_isvalid(new.the_geom_2154) = true THEN -- si la topologie est bonne alors... + -- on calcul la commune (celle qui contient le plus de zp en surface)... + SELECT INTO macommune c.insee FROM layers.l_communes c WHERE st_intersects(c.the_geom, new.the_geom_2154); + new.insee = macommune; + -- on calcul l'altitude + new.altitude_sig = layers.f_isolines20(new.the_geom_2154); -- mise à jour de l'altitude sig + IF new.altitude_saisie IS null OR new.altitude_saisie = -1 THEN-- mis à jour de l'altitude retenue + new.altitude_retenue = new.altitude_sig; + ELSE + new.altitude_retenue = new.altitude_saisie; + END IF; + ELSE + SELECT INTO macommune c.insee FROM layers.l_communes c WHERE st_intersects(c.the_geom, ST_PointFromWKB(st_centroid(Box2D(new.the_geom_2154)),2154)); + new.insee = macommune; + -- on calcul l'altitude + new.altitude_sig = layers.f_isolines20(ST_PointFromWKB(st_centroid(Box2D(new.the_geom_2154)),2154)); -- mise à jour de l'altitude sig + IF new.altitude_saisie IS null OR new.altitude_saisie = -1 THEN-- mis à jour de l'altitude retenue + new.altitude_retenue = new.altitude_sig; + ELSE + new.altitude_retenue = new.altitude_saisie; + END IF; + END IF; +END IF; +--- divers update +IF new.altitude_saisie <> old.altitude_saisie THEN + new.altitude_retenue = new.altitude_saisie; +END IF; +new.date_update = 'now'; +IF new.supprime <> old.supprime THEN + IF new.supprime = 't' THEN + update contactflore.t_releves_cflore set supprime = 't' WHERE id_cflore = old.id_cflore; + END IF; + IF new.supprime = 'f' THEN + update contactflore.t_releves_cflore set supprime = 'f' WHERE id_cflore = old.id_cflore; + END IF; +END IF; +RETURN NEW; +END; +$$; + + +ALTER FUNCTION contactflore.update_fiche_cflore() OWNER TO geonatuser; + +-- +-- TOC entry 1503 (class 1255 OID 1387981) +-- Name: update_releve_cflore(); Type: FUNCTION; Schema: contactflore; Owner: geonatuser +-- + +CREATE FUNCTION update_releve_cflore() RETURNS trigger + LANGUAGE plpgsql + AS $$ +DECLARE + re integer; +BEGIN + -- Si changement de taxon, + IF new.id_taxon<>old.id_taxon THEN + -- Correction du cd_ref_origine + SELECT INTO re taxonomie.find_cdref(cd_nom) FROM taxonomie.bib_taxons WHERE id_taxon = new.id_taxon; + new.cd_ref_origine = re; + END IF; +RETURN NEW; +END; +$$; + + +ALTER FUNCTION contactflore.update_releve_cflore() OWNER TO geonatuser; + +SET default_tablespace = ''; + +SET default_with_oids = false; + +-- +-- TOC entry 347 (class 1259 OID 1387982) +-- Name: bib_abondances_cflore; Type: TABLE; Schema: contactflore; Owner: geonatuser; Tablespace: +-- + +CREATE TABLE bib_abondances_cflore ( + id_abondance_cflore integer NOT NULL, + nom_abondance_cflore character varying(25) +); + + +ALTER TABLE contactflore.bib_abondances_cflore OWNER TO geonatuser; + +-- +-- TOC entry 358 (class 1259 OID 1388106) +-- Name: bib_messages_cflore; Type: TABLE; Schema: contactflore; Owner: geonatuser; Tablespace: +-- + +CREATE TABLE bib_messages_cflore ( + id_message_cflore integer NOT NULL, + texte_message_cflore character varying(255) +); + + +ALTER TABLE contactflore.bib_messages_cflore OWNER TO geonatuser; + +-- +-- TOC entry 348 (class 1259 OID 1387985) +-- Name: bib_phenologies_cflore; Type: TABLE; Schema: contactflore; Owner: geonatuser; Tablespace: +-- + +CREATE TABLE bib_phenologies_cflore ( + id_phenologie_cflore integer NOT NULL, + nom_phenologie_cflore character varying(100) +); + + +ALTER TABLE contactflore.bib_phenologies_cflore OWNER TO geonatuser; + +-- +-- TOC entry 359 (class 1259 OID 1388111) +-- Name: cor_message_taxon_cflore; Type: TABLE; Schema: contactflore; Owner: geonatuser; Tablespace: +-- + +CREATE TABLE cor_message_taxon_cflore ( + id_message_cflore integer NOT NULL, + id_taxon integer NOT NULL +); + + +ALTER TABLE contactflore.cor_message_taxon_cflore OWNER TO geonatuser; + +-- +-- TOC entry 360 (class 1259 OID 1388128) +-- Name: cor_role_fiche_cflore; Type: TABLE; Schema: contactflore; Owner: geonatuser; Tablespace: +-- + +CREATE TABLE cor_role_fiche_cflore ( + id_cflore bigint NOT NULL, + id_role integer NOT NULL +); + + +ALTER TABLE contactflore.cor_role_fiche_cflore OWNER TO geonatuser; + +-- +-- TOC entry 349 (class 1259 OID 1387991) +-- Name: cor_unite_taxon_cflore; Type: TABLE; Schema: contactflore; Owner: geonatuser; Tablespace: +-- + +CREATE TABLE cor_unite_taxon_cflore ( + id_unite_geo integer NOT NULL, + id_taxon integer NOT NULL, + derniere_date date, + couleur character varying(10) NOT NULL, + nb_obs integer +); + + +ALTER TABLE contactflore.cor_unite_taxon_cflore OWNER TO geonatuser; + +-- +-- TOC entry 352 (class 1259 OID 1388006) +-- Name: t_fiches_cflore; Type: TABLE; Schema: contactflore; Owner: geonatuser; Tablespace: +-- + +CREATE TABLE t_fiches_cflore ( + id_cflore bigint NOT NULL, + insee character(5), + dateobs date NOT NULL, + altitude_saisie integer, + altitude_sig integer, + altitude_retenue integer, + date_insert timestamp without time zone, + date_update timestamp without time zone, + supprime boolean DEFAULT false NOT NULL, + pdop double precision, + saisie_initiale character varying(20), + id_organisme integer, + srid_dessin integer, + id_protocole integer, + id_lot integer, + the_geom_3857 public.geometry, + the_geom_2154 public.geometry, + CONSTRAINT enforce_dims_the_geom_2154 CHECK ((public.st_ndims(the_geom_2154) = 2)), + CONSTRAINT enforce_dims_the_geom_3857 CHECK ((public.st_ndims(the_geom_3857) = 2)), + CONSTRAINT enforce_geotype_the_geom_2154 CHECK (((public.geometrytype(the_geom_2154) = 'POINT'::text) OR (the_geom_2154 IS NULL))), + CONSTRAINT enforce_geotype_the_geom_3857 CHECK (((public.geometrytype(the_geom_3857) = 'POINT'::text) OR (the_geom_3857 IS NULL))), + CONSTRAINT enforce_srid_the_geom_2154 CHECK ((public.st_srid(the_geom_2154) = 2154)), + CONSTRAINT enforce_srid_the_geom_3857 CHECK ((public.st_srid(the_geom_3857) = 3857)) +); + + +ALTER TABLE contactflore.t_fiches_cflore OWNER TO geonatuser; + +-- +-- TOC entry 353 (class 1259 OID 1388019) +-- Name: t_releves_cflore; Type: TABLE; Schema: contactflore; Owner: geonatuser; Tablespace: +-- + +CREATE TABLE t_releves_cflore ( + id_releve_cflore bigint NOT NULL, + id_cflore bigint NOT NULL, + id_taxon integer NOT NULL, + id_abondance_cflore integer NOT NULL, + id_phenologie_cflore integer NOT NULL, + cd_ref_origine integer, + nom_taxon_saisi character varying(255), + commentaire text, + determinateur character varying(255), + supprime boolean DEFAULT false NOT NULL, + herbier boolean DEFAULT false NOT NULL, + gid integer NOT NULL, + validite_cflore boolean +); + + +ALTER TABLE contactflore.t_releves_cflore OWNER TO geonatuser; + +-- +-- TOC entry 354 (class 1259 OID 1388027) +-- Name: t_releves_cflore_gid_seq; Type: SEQUENCE; Schema: contactflore; Owner: geonatuser +-- + +CREATE SEQUENCE t_releves_cflore_gid_seq + START WITH 1 + INCREMENT BY 1 + NO MINVALUE + NO MAXVALUE + CACHE 1; + + +ALTER TABLE contactflore.t_releves_cflore_gid_seq OWNER TO geonatuser; + +-- +-- TOC entry 3897 (class 0 OID 0) +-- Dependencies: 354 +-- Name: t_releves_cflore_gid_seq; Type: SEQUENCE OWNED BY; Schema: contactflore; Owner: geonatuser +-- + +ALTER SEQUENCE t_releves_cflore_gid_seq OWNED BY t_releves_cflore.gid; + + +-- +-- TOC entry 362 (class 1259 OID 1388156) +-- Name: v_nomade_abondances_cflore; Type: VIEW; Schema: contactflore; Owner: geonatuser +-- + +CREATE VIEW v_nomade_abondances_cflore AS + SELECT a.id_abondance_cflore, + a.nom_abondance_cflore + FROM bib_abondances_cflore a + ORDER BY a.id_abondance_cflore; + + +ALTER TABLE contactflore.v_nomade_abondances_cflore OWNER TO geonatuser; + +-- +-- TOC entry 355 (class 1259 OID 1388029) +-- Name: v_nomade_classes; Type: VIEW; Schema: contactflore; Owner: geonatuser +-- + +CREATE VIEW v_nomade_classes AS + SELECT g.id_liste AS id_classe, + g.nom_liste AS nom_classe_fr, + g.desc_liste AS desc_classe + FROM (( SELECT l.id_liste, + l.nom_liste, + l.desc_liste, + min(taxonomie.find_cdref(tx.cd_nom)) AS cd_ref + FROM ((taxonomie.bib_listes l + JOIN taxonomie.cor_taxon_liste ctl ON ((ctl.id_liste = l.id_liste))) + JOIN taxonomie.bib_taxons tx ON ((tx.id_taxon = ctl.id_taxon))) + WHERE ((l.id_liste > 300) AND (l.id_liste < 400)) + GROUP BY l.id_liste, l.nom_liste, l.desc_liste) g + JOIN taxonomie.taxref t ON ((t.cd_nom = g.cd_ref))) + WHERE ((t.regne)::text = 'Plantae'::text); + + +ALTER TABLE contactflore.v_nomade_classes OWNER TO geonatuser; + +-- +-- TOC entry 356 (class 1259 OID 1388034) +-- Name: v_nomade_observateurs_flore; Type: VIEW; Schema: contactflore; Owner: geonatuser +-- + +CREATE VIEW v_nomade_observateurs_flore AS + SELECT DISTINCT r.id_role, + r.nom_role, + r.prenom_role + FROM utilisateurs.t_roles r + WHERE ((r.id_role IN ( SELECT DISTINCT cr.id_role_utilisateur + FROM utilisateurs.cor_roles cr + WHERE (cr.id_role_groupe IN ( SELECT crm.id_role + FROM utilisateurs.cor_role_menu crm + WHERE (crm.id_menu = 10))) + ORDER BY cr.id_role_utilisateur)) OR (r.id_role IN ( SELECT crm.id_role + FROM (utilisateurs.cor_role_menu crm + JOIN utilisateurs.t_roles r_1 ON ((((r_1.id_role = crm.id_role) AND (crm.id_menu = 9)) AND (r_1.groupe = false))))))) + ORDER BY r.nom_role, r.prenom_role, r.id_role; + + +ALTER TABLE contactflore.v_nomade_observateurs_flore OWNER TO geonatuser; + +-- +-- TOC entry 363 (class 1259 OID 1388160) +-- Name: v_nomade_phenologies_cflore; Type: VIEW; Schema: contactflore; Owner: geonatuser +-- + +CREATE VIEW v_nomade_phenologies_cflore AS + SELECT p.id_phenologie_cflore, + p.nom_phenologie_cflore + FROM bib_phenologies_cflore p + ORDER BY p.id_phenologie_cflore; + + +ALTER TABLE contactflore.v_nomade_phenologies_cflore OWNER TO geonatuser; + +-- +-- TOC entry 361 (class 1259 OID 1388147) +-- Name: v_nomade_taxons_flore; Type: VIEW; Schema: contactflore; Owner: geonatuser +-- + +CREATE VIEW v_nomade_taxons_flore AS + SELECT DISTINCT t.id_taxon, + taxonomie.find_cdref(tx.cd_nom) AS cd_ref, + tx.cd_nom, + t.nom_latin, + t.nom_francais, + g.id_classe, + f2.bool AS patrimonial, + m.texte_message_cflore AS message + FROM ((((((taxonomie.bib_taxons t + LEFT JOIN cor_message_taxon_cflore cmt ON ((cmt.id_taxon = t.id_taxon))) + LEFT JOIN bib_messages_cflore m ON ((m.id_message_cflore = cmt.id_message_cflore))) + JOIN taxonomie.cor_taxon_liste ctl ON ((ctl.id_taxon = t.id_taxon))) + JOIN v_nomade_classes g ON ((g.id_classe = ctl.id_liste))) + JOIN taxonomie.taxref tx ON ((tx.cd_nom = t.cd_nom))) + JOIN public.cor_boolean f2 ON (((f2.expression)::text = (t.filtre2)::text))) + WHERE ((t.filtre1)::text = 'oui'::text) + ORDER BY t.id_taxon, taxonomie.find_cdref(tx.cd_nom), t.nom_latin, t.nom_francais, g.id_classe, f2.bool; + + +ALTER TABLE contactflore.v_nomade_taxons_flore OWNER TO geonatuser; + +-- +-- TOC entry 357 (class 1259 OID 1388044) +-- Name: v_nomade_unites_geo_cflore; Type: VIEW; Schema: contactflore; Owner: geonatuser +-- + +CREATE VIEW v_nomade_unites_geo_cflore AS + SELECT public.st_simplifypreservetopology(l_unites_geo.the_geom, (15)::double precision) AS the_geom, + l_unites_geo.id_unite_geo + FROM layers.l_unites_geo + GROUP BY l_unites_geo.the_geom, l_unites_geo.id_unite_geo; + + +ALTER TABLE contactflore.v_nomade_unites_geo_cflore OWNER TO geonatuser; + +-- +-- TOC entry 3680 (class 2604 OID 1388048) +-- Name: gid; Type: DEFAULT; Schema: contactflore; Owner: geonatuser +-- + +ALTER TABLE ONLY t_releves_cflore ALTER COLUMN gid SET DEFAULT nextval('t_releves_cflore_gid_seq'::regclass); + + +-- +-- TOC entry 3900 (class 0 OID 0) +-- Dependencies: 354 +-- Name: t_releves_cflore_gid_seq; Type: SEQUENCE SET; Schema: contactflore; Owner: geonatuser +-- + +SELECT pg_catalog.setval('t_releves_cflore_gid_seq', 1, true); + + +-- +-- TOC entry 3682 (class 2606 OID 1388050) +-- Name: bib_abondance_cflore_pkey; Type: CONSTRAINT; Schema: contactflore; Owner: geonatuser; Tablespace: +-- + +ALTER TABLE ONLY bib_abondances_cflore + ADD CONSTRAINT bib_abondance_cflore_pkey PRIMARY KEY (id_abondance_cflore); + + +-- +-- TOC entry 3684 (class 2606 OID 1388052) +-- Name: bib_phenologie_cflore_pkey; Type: CONSTRAINT; Schema: contactflore; Owner: geonatuser; Tablespace: +-- + +ALTER TABLE ONLY bib_phenologies_cflore + ADD CONSTRAINT bib_phenologie_cflore_pkey PRIMARY KEY (id_phenologie_cflore); + + +-- +-- TOC entry 3686 (class 2606 OID 1388056) +-- Name: cor_unite_taxon_cflore_pkey; Type: CONSTRAINT; Schema: contactflore; Owner: geonatuser; Tablespace: +-- + +ALTER TABLE ONLY cor_unite_taxon_cflore + ADD CONSTRAINT cor_unite_taxon_cflore_pkey PRIMARY KEY (id_unite_geo, id_taxon); + + +-- +-- TOC entry 3693 (class 2606 OID 1388110) +-- Name: pk_bib_messages_cflore; Type: CONSTRAINT; Schema: contactflore; Owner: geonatuser; Tablespace: +-- + +ALTER TABLE ONLY bib_messages_cflore + ADD CONSTRAINT pk_bib_messages_cflore PRIMARY KEY (id_message_cflore); + + +-- +-- TOC entry 3697 (class 2606 OID 1388115) +-- Name: pk_cor_message_taxon_cflore; Type: CONSTRAINT; Schema: contactflore; Owner: geonatuser; Tablespace: +-- + +ALTER TABLE ONLY cor_message_taxon_cflore + ADD CONSTRAINT pk_cor_message_taxon_cflore PRIMARY KEY (id_message_cflore, id_taxon); + + +-- +-- TOC entry 3701 (class 2606 OID 1388132) +-- Name: pk_cor_role_fiche_cflore; Type: CONSTRAINT; Schema: contactflore; Owner: geonatuser; Tablespace: +-- + +ALTER TABLE ONLY cor_role_fiche_cflore + ADD CONSTRAINT pk_cor_role_fiche_cflore PRIMARY KEY (id_cflore, id_role); + + +-- +-- TOC entry 3689 (class 2606 OID 1388058) +-- Name: pk_t_fiches_cflore; Type: CONSTRAINT; Schema: contactflore; Owner: geonatuser; Tablespace: +-- + +ALTER TABLE ONLY t_fiches_cflore + ADD CONSTRAINT pk_t_fiches_cflore PRIMARY KEY (id_cflore); + + +-- +-- TOC entry 3691 (class 2606 OID 1388190) +-- Name: t_releves_cflore_pkey; Type: CONSTRAINT; Schema: contactflore; Owner: geonatuser; Tablespace: +-- + +ALTER TABLE ONLY t_releves_cflore + ADD CONSTRAINT t_releves_cflore_pkey PRIMARY KEY (id_releve_cflore); + + +-- +-- TOC entry 3694 (class 1259 OID 1388126) +-- Name: i_fk_cor_message_cflore_bib_me; Type: INDEX; Schema: contactflore; Owner: geonatuser; Tablespace: +-- + +CREATE INDEX i_fk_cor_message_cflore_bib_me ON cor_message_taxon_cflore USING btree (id_message_cflore); + + +-- +-- TOC entry 3695 (class 1259 OID 1388127) +-- Name: i_fk_cor_message_cflore_bib_ta; Type: INDEX; Schema: contactflore; Owner: geonatuser; Tablespace: +-- + +CREATE INDEX i_fk_cor_message_cflore_bib_ta ON cor_message_taxon_cflore USING btree (id_taxon); + + +-- +-- TOC entry 3698 (class 1259 OID 1388143) +-- Name: i_fk_cor_role_fiche_cflore_t_fiche; Type: INDEX; Schema: contactflore; Owner: geonatuser; Tablespace: +-- + +CREATE INDEX i_fk_cor_role_fiche_cflore_t_fiche ON cor_role_fiche_cflore USING btree (id_cflore); + + +-- +-- TOC entry 3699 (class 1259 OID 1388144) +-- Name: i_fk_cor_role_fiche_cflore_t_roles; Type: INDEX; Schema: contactflore; Owner: geonatuser; Tablespace: +-- + +CREATE INDEX i_fk_cor_role_fiche_cflore_t_roles ON cor_role_fiche_cflore USING btree (id_role); + + +-- +-- TOC entry 3687 (class 1259 OID 1388078) +-- Name: i_fk_t_fiches_cflore_l_communes; Type: INDEX; Schema: contactflore; Owner: geonatuser; Tablespace: +-- + +CREATE INDEX i_fk_t_fiches_cflore_l_communes ON t_fiches_cflore USING btree (insee); + + +-- +-- TOC entry 3713 (class 2620 OID 1388074) +-- Name: tri_insert_fiche_cflore; Type: TRIGGER; Schema: contactflore; Owner: geonatuser +-- + +CREATE TRIGGER tri_insert_fiche_cflore BEFORE INSERT ON t_fiches_cflore FOR EACH ROW EXECUTE PROCEDURE insert_fiche_cflore(); + + +-- +-- TOC entry 3716 (class 2620 OID 1388184) +-- Name: tri_insert_releve_cflore; Type: TRIGGER; Schema: contactflore; Owner: geonatuser +-- + +CREATE TRIGGER tri_insert_releve_cflore BEFORE INSERT ON t_releves_cflore FOR EACH ROW EXECUTE PROCEDURE insert_releve_cflore(); + + +-- +-- TOC entry 3717 (class 2620 OID 1388185) +-- Name: tri_synthese_delete_releve_cflore; Type: TRIGGER; Schema: contactflore; Owner: geonatuser +-- + +CREATE TRIGGER tri_synthese_delete_releve_cflore AFTER DELETE ON t_releves_cflore FOR EACH ROW EXECUTE PROCEDURE synthese_delete_releve_cflore(); + + +-- +-- TOC entry 3718 (class 2620 OID 1388186) +-- Name: tri_synthese_insert_releve_cflore; Type: TRIGGER; Schema: contactflore; Owner: geonatuser +-- + +CREATE TRIGGER tri_synthese_insert_releve_cflore AFTER INSERT ON t_releves_cflore FOR EACH ROW EXECUTE PROCEDURE synthese_insert_releve_cflore(); + + +-- +-- TOC entry 3714 (class 2620 OID 1388075) +-- Name: tri_synthese_update_fiche_cflore; Type: TRIGGER; Schema: contactflore; Owner: geonatuser +-- + +CREATE TRIGGER tri_synthese_update_fiche_cflore AFTER UPDATE ON t_fiches_cflore FOR EACH ROW EXECUTE PROCEDURE synthese_update_fiche_cflore(); + + +-- +-- TOC entry 3719 (class 2620 OID 1388187) +-- Name: tri_synthese_update_releve_cflore; Type: TRIGGER; Schema: contactflore; Owner: geonatuser +-- + +CREATE TRIGGER tri_synthese_update_releve_cflore AFTER UPDATE ON t_releves_cflore FOR EACH ROW EXECUTE PROCEDURE synthese_update_releve_cflore(); + + +-- +-- TOC entry 3715 (class 2620 OID 1388077) +-- Name: tri_update_fiche_cflore; Type: TRIGGER; Schema: contactflore; Owner: geonatuser +-- + +CREATE TRIGGER tri_update_fiche_cflore BEFORE UPDATE ON t_fiches_cflore FOR EACH ROW EXECUTE PROCEDURE update_fiche_cflore(); + + +-- +-- TOC entry 3720 (class 2620 OID 1388188) +-- Name: tri_update_releve_cflore; Type: TRIGGER; Schema: contactflore; Owner: geonatuser +-- + +CREATE TRIGGER tri_update_releve_cflore BEFORE UPDATE ON t_releves_cflore FOR EACH ROW EXECUTE PROCEDURE update_releve_cflore(); + + +-- +-- TOC entry 3721 (class 2620 OID 1388145) +-- Name: tri_update_synthese_cor_role_fiche_cflore; Type: TRIGGER; Schema: contactflore; Owner: geonatuser +-- + +CREATE TRIGGER tri_update_synthese_cor_role_fiche_cflore AFTER INSERT OR UPDATE ON cor_role_fiche_cflore FOR EACH ROW EXECUTE PROCEDURE synthese_update_cor_role_fiche_cflore(); + + +-- +-- TOC entry 3710 (class 2606 OID 1388116) +-- Name: fk_cor_message_taxon_cflore_bib_taxons; Type: FK CONSTRAINT; Schema: contactflore; Owner: geonatuser +-- + +ALTER TABLE ONLY cor_message_taxon_cflore + ADD CONSTRAINT fk_cor_message_taxon_cflore_bib_taxons FOREIGN KEY (id_taxon) REFERENCES taxonomie.bib_taxons(id_taxon) ON UPDATE CASCADE; + + +-- +-- TOC entry 3709 (class 2606 OID 1388121) +-- Name: fk_cor_message_taxon_cflore_l_unites_geo; Type: FK CONSTRAINT; Schema: contactflore; Owner: geonatuser +-- + +ALTER TABLE ONLY cor_message_taxon_cflore + ADD CONSTRAINT fk_cor_message_taxon_cflore_l_unites_geo FOREIGN KEY (id_message_cflore) REFERENCES bib_messages_cflore(id_message_cflore) ON UPDATE CASCADE; + + +-- +-- TOC entry 3712 (class 2606 OID 1388133) +-- Name: fk_cor_role_fiche_cflore_t_fiches_cflore; Type: FK CONSTRAINT; Schema: contactflore; Owner: geonatuser +-- + +ALTER TABLE ONLY cor_role_fiche_cflore + ADD CONSTRAINT fk_cor_role_fiche_cflore_t_fiches_cflore FOREIGN KEY (id_cflore) REFERENCES t_fiches_cflore(id_cflore) ON UPDATE CASCADE ON DELETE CASCADE; + + +-- +-- TOC entry 3711 (class 2606 OID 1388138) +-- Name: fk_cor_role_fiche_cflore_t_roles; Type: FK CONSTRAINT; Schema: contactflore; Owner: geonatuser +-- + +ALTER TABLE ONLY cor_role_fiche_cflore + ADD CONSTRAINT fk_cor_role_fiche_cflore_t_roles FOREIGN KEY (id_role) REFERENCES utilisateurs.t_roles(id_role) ON UPDATE CASCADE; + + +-- +-- TOC entry 3708 (class 2606 OID 1388079) +-- Name: fk_t_releves_cflore_bib_abondances_cflore; Type: FK CONSTRAINT; Schema: contactflore; Owner: geonatuser +-- + +ALTER TABLE ONLY t_releves_cflore + ADD CONSTRAINT fk_t_releves_cflore_bib_abondances_cflore FOREIGN KEY (id_abondance_cflore) REFERENCES bib_abondances_cflore(id_abondance_cflore) ON UPDATE CASCADE; + + +-- +-- TOC entry 3707 (class 2606 OID 1388084) +-- Name: fk_t_releves_cflore_bib_phenologies_cflore; Type: FK CONSTRAINT; Schema: contactflore; Owner: geonatuser +-- + +ALTER TABLE ONLY t_releves_cflore + ADD CONSTRAINT fk_t_releves_cflore_bib_phenologies_cflore FOREIGN KEY (id_phenologie_cflore) REFERENCES bib_phenologies_cflore(id_phenologie_cflore) ON UPDATE CASCADE; + + +-- +-- TOC entry 3706 (class 2606 OID 1388094) +-- Name: fk_t_releves_cflore_bib_taxons; Type: FK CONSTRAINT; Schema: contactflore; Owner: geonatuser +-- + +ALTER TABLE ONLY t_releves_cflore + ADD CONSTRAINT fk_t_releves_cflore_bib_taxons FOREIGN KEY (id_taxon) REFERENCES taxonomie.bib_taxons(id_taxon) ON UPDATE CASCADE; + + +-- +-- TOC entry 3705 (class 2606 OID 1388101) +-- Name: fk_t_releves_cflore_t_fiches_cflore; Type: FK CONSTRAINT; Schema: contactflore; Owner: geonatuser +-- + +ALTER TABLE ONLY t_releves_cflore + ADD CONSTRAINT fk_t_releves_cflore_t_fiches_cflore FOREIGN KEY (id_cflore) REFERENCES t_fiches_cflore(id_cflore) ON UPDATE CASCADE; + + +-- +-- TOC entry 3704 (class 2606 OID 1388059) +-- Name: t_fiches_cflore_id_lot_fkey; Type: FK CONSTRAINT; Schema: contactflore; Owner: geonatuser +-- + +ALTER TABLE ONLY t_fiches_cflore + ADD CONSTRAINT t_fiches_cflore_id_lot_fkey FOREIGN KEY (id_lot) REFERENCES meta.bib_lots(id_lot) ON UPDATE CASCADE; + + +-- +-- TOC entry 3703 (class 2606 OID 1388064) +-- Name: t_fiches_cflore_id_organisme_fkey; Type: FK CONSTRAINT; Schema: contactflore; Owner: geonatuser +-- + +ALTER TABLE ONLY t_fiches_cflore + ADD CONSTRAINT t_fiches_cflore_id_organisme_fkey FOREIGN KEY (id_organisme) REFERENCES utilisateurs.bib_organismes(id_organisme) ON UPDATE CASCADE; + + +-- +-- TOC entry 3702 (class 2606 OID 1388069) +-- Name: t_fiches_cflore_id_protocole_fkey; Type: FK CONSTRAINT; Schema: contactflore; Owner: geonatuser +-- + +ALTER TABLE ONLY t_fiches_cflore + ADD CONSTRAINT t_fiches_cflore_id_protocole_fkey FOREIGN KEY (id_protocole) REFERENCES meta.t_protocoles(id_protocole) ON UPDATE CASCADE; + + +-- +-- TOC entry 3894 (class 0 OID 0) +-- Dependencies: 358 +-- Name: bib_messages_cflore; Type: ACL; Schema: contactflore; Owner: geonatuser +-- + +REVOKE ALL ON TABLE bib_messages_cflore FROM PUBLIC; +REVOKE ALL ON TABLE bib_messages_cflore FROM geonatuser; +GRANT ALL ON TABLE bib_messages_cflore TO geonatuser; + + +-- +-- TOC entry 3895 (class 0 OID 0) +-- Dependencies: 359 +-- Name: cor_message_taxon_cflore; Type: ACL; Schema: contactflore; Owner: geonatuser +-- + +REVOKE ALL ON TABLE cor_message_taxon_cflore FROM PUBLIC; +REVOKE ALL ON TABLE cor_message_taxon_cflore FROM geonatuser; +GRANT ALL ON TABLE cor_message_taxon_cflore TO geonatuser; + + +-- +-- TOC entry 3896 (class 0 OID 0) +-- Dependencies: 360 +-- Name: cor_role_fiche_cflore; Type: ACL; Schema: contactflore; Owner: geonatuser +-- + +REVOKE ALL ON TABLE cor_role_fiche_cflore FROM PUBLIC; +REVOKE ALL ON TABLE cor_role_fiche_cflore FROM geonatuser; +GRANT ALL ON TABLE cor_role_fiche_cflore TO geonatuser; + + +-- +-- TOC entry 3898 (class 0 OID 0) +-- Dependencies: 362 +-- Name: v_nomade_abondances_cflore; Type: ACL; Schema: contactflore; Owner: geonatuser +-- + +REVOKE ALL ON TABLE v_nomade_abondances_cflore FROM PUBLIC; +REVOKE ALL ON TABLE v_nomade_abondances_cflore FROM geonatuser; +GRANT ALL ON TABLE v_nomade_abondances_cflore TO geonatuser; + + +-- +-- TOC entry 3899 (class 0 OID 0) +-- Dependencies: 363 +-- Name: v_nomade_phenologies_cflore; Type: ACL; Schema: contactflore; Owner: geonatuser +-- + +REVOKE ALL ON TABLE v_nomade_phenologies_cflore FROM PUBLIC; +REVOKE ALL ON TABLE v_nomade_phenologies_cflore FROM geonatuser; +GRANT ALL ON TABLE v_nomade_phenologies_cflore TO geonatuser; + + +-- Completed on 2016-03-21 17:06:48 + +-- +-- PostgreSQL database dump complete +-- + +---------------- Contenu des listes déroulantes abondances et phénologies + +-- +-- TOC entry 3879 (class 0 OID 1387982) +-- Dependencies: 347 +-- Data for Name: bib_abondances_cflore; Type: TABLE DATA; Schema: contactflore; Owner: geonatuser +-- + +INSERT INTO bib_abondances_cflore (id_abondance_cflore, nom_abondance_cflore) VALUES (1, '1 individu'); +INSERT INTO bib_abondances_cflore (id_abondance_cflore, nom_abondance_cflore) VALUES (2, 'De 1 à 10 individus'); +INSERT INTO bib_abondances_cflore (id_abondance_cflore, nom_abondance_cflore) VALUES (3, 'De 10 à 100 individus'); +INSERT INTO bib_abondances_cflore (id_abondance_cflore, nom_abondance_cflore) VALUES (4, 'Plus de 100 individus'); + + +-- +-- TOC entry 3880 (class 0 OID 1387985) +-- Dependencies: 348 +-- Data for Name: bib_phenologies_cflore; Type: TABLE DATA; Schema: contactflore; Owner: geonatuser +-- + +INSERT INTO bib_phenologies_cflore (id_phenologie_cflore, nom_phenologie_cflore) VALUES (1, 'Stade végétatif'); +INSERT INTO bib_phenologies_cflore (id_phenologie_cflore, nom_phenologie_cflore) VALUES (2, 'Stade boutons floraux'); +INSERT INTO bib_phenologies_cflore (id_phenologie_cflore, nom_phenologie_cflore) VALUES (3, 'Début de floraison'); +INSERT INTO bib_phenologies_cflore (id_phenologie_cflore, nom_phenologie_cflore) VALUES (4, 'Pleine floraison'); +INSERT INTO bib_phenologies_cflore (id_phenologie_cflore, nom_phenologie_cflore) VALUES (5, 'Fin de floraison et maturation des fruits'); +INSERT INTO bib_phenologies_cflore (id_phenologie_cflore, nom_phenologie_cflore) VALUES (6, 'Dissémination'); +INSERT INTO bib_phenologies_cflore (id_phenologie_cflore, nom_phenologie_cflore) VALUES (7, 'Stade de décrépitude'); +INSERT INTO bib_phenologies_cflore (id_phenologie_cflore, nom_phenologie_cflore) VALUES (8, 'Stage végétatif permanent '); + + +---------------- geometry_columns + +INSERT INTO geometry_columns (f_table_catalog, f_table_schema, f_table_name, f_geometry_column, coord_dimension, srid, type) VALUES ('', 'contactflore', 't_fiches_cflore', 'the_geom_3857', 2, 3857, 'POINT'); +INSERT INTO geometry_columns (f_table_catalog, f_table_schema, f_table_name, f_geometry_column, coord_dimension, srid, type) VALUES ('', 'contactflore', 't_fiches_cflore', 'the_geom_2154', 2, 2154, 'POINT'); +INSERT INTO geometry_columns (f_table_catalog, f_table_schema, f_table_name, f_geometry_column, coord_dimension, srid, type) VALUES ('', 'contactflore', 'v_nomade_unites_geo_cflore', 'the_geom', 2, 2154, 'MULTIPOLYGON'); + +-- ajout des enregistrements nécéssaires dans les tables liées +INSERT INTO meta.bib_programmes (id_programme, nom_programme, desc_programme, actif, programme_public, desc_programme_public) VALUES (7, 'Contact flore', 'Contact aléatoire de la flore.', true, true, 'Contact aléatoire de la faune invertébrée.'); +INSERT INTO meta.bib_lots (id_lot, nom_lot, desc_lot, menu_cf, pn, menu_inv, id_programme) VALUES (7, 'Contact flore', 'Contact flore', false, true, false, 7); +INSERT INTO meta.t_protocoles VALUES (7, 'contact flore', 'à compléter', 'à compléter', 'à compléter', 'non', NULL, NULL); +INSERT INTO synthese.bib_sources (id_source, nom_source, desc_source, host, port, username, pass, db_name, db_schema, db_table, db_field, url, target, picto, groupe, actif) VALUES (7,'Contact flore','Contenu des tables t_fiches_cflore et t_releves_cflore de la base GeoNature postgres','localhost',22,NULL,NULL,'geonaturedb','contactflore','t_releves_cflore','id_releve_cflore','cflore',NULL,'images/pictos/plante.gif','FLORE',true); + + +---------------- Mise à jour de la vue v_nomade_classes globale +CREATE OR REPLACE VIEW taxonomie.v_nomade_classes AS + SELECT v_nomade_classes.id_classe, + v_nomade_classes.nom_classe_fr, + v_nomade_classes.desc_classe + FROM contactfaune.v_nomade_classes +UNION + SELECT v_nomade_classes.id_classe, + v_nomade_classes.nom_classe_fr, + v_nomade_classes.desc_classe + FROM contactinv.v_nomade_classes +UNION + SELECT v_nomade_classes.id_classe, + v_nomade_classes.nom_classe_fr, + v_nomade_classes.desc_classe + FROM florepatri.v_nomade_classes +UNION + SELECT v_nomade_classes.id_classe, + v_nomade_classes.nom_classe_fr, + v_nomade_classes.desc_classe + FROM contactflore.v_nomade_classes; + + +---------------- 3 Données exemple; Si besoin, décommenter les lignes INSERT INTO ci-dessous + + +--INSERT INTO t_fiches_cflore (id_cflore, insee, dateobs, altitude_saisie, altitude_sig, altitude_retenue, date_insert, date_update, supprime, pdop, saisie_initiale, id_organisme, srid_dessin, id_protocole, id_lot, the_geom_3857, the_geom_2154) VALUES (1, '05181', '2016-03-10', 3627, 0, 3627, '2016-03-10 17:34:09.160291', '2016-03-10 17:34:09.319749', false, -1, 'web', 99, 3857, 7, 7, '0101000020110F00003DFA78D1CE79254161CCCC4D13725541', '01010000206A0800007B4143E5ED582D41481F86793A905841'); +--INSERT INTO t_fiches_cflore (id_cflore, insee, dateobs, altitude_saisie, altitude_sig, altitude_retenue, date_insert, date_update, supprime, pdop, saisie_initiale, id_organisme, srid_dessin, id_protocole, id_lot, the_geom_3857, the_geom_2154) VALUES (2, '05063', '2016-03-10', 2295, 0, 2295, '2016-03-10 17:47:42.100277', '2016-03-10 17:47:42.257232', false, -1, 'web', 99, 3857, 7, 7, '0101000020110F000026A524147A502541FD0BA9995B805541', '01010000206A0800009C3CFA465C382D41F7844B6F229A5841'); + +--INSERT INTO t_releves_cflore (id_releve_cflore, id_cflore, id_taxon, id_abondance_cflore, id_phenologie_cflore, cd_ref_origine, nom_taxon_saisi, commentaire, determinateur, supprime, herbier, gid, validite_cflore) VALUES (1, 1, 100001, 1, 2, 81065, 'Alchémille rampante', 'test comment', 'Gil det', false, true, 4, NULL); +--INSERT INTO t_releves_cflore (id_releve_cflore, id_cflore, id_taxon, id_abondance_cflore, id_phenologie_cflore, cd_ref_origine, nom_taxon_saisi, commentaire, determinateur, supprime, herbier, gid, validite_cflore) VALUES (2, 1, 100002, 4, 8, 95186, 'Inule fétide', 'test sans prélevemnt', 'Gil test det2', false, true, 5, NULL); +--INSERT INTO t_releves_cflore (id_releve_cflore, id_cflore, id_taxon, id_abondance_cflore, id_phenologie_cflore, cd_ref_origine, nom_taxon_saisi, commentaire, determinateur, supprime, herbier, gid, validite_cflore) VALUES (3, 2, 100001, 2, 4, 81065, 'Alchémille rampante', '', '', false, false, 6, NULL); + +--INSERT INTO cor_role_fiche_cflore (id_cflore, id_role) VALUES (1, 1); +--INSERT INTO cor_role_fiche_cflore (id_cflore, id_role) VALUES (2, 1); \ No newline at end of file diff --git a/data/2154/data_synthese_2154.sql b/data/2154/data_synthese_2154.sql index 764d4d90ba..b9e0e4c865 100644 --- a/data/2154/data_synthese_2154.sql +++ b/data/2154/data_synthese_2154.sql @@ -319,6 +319,9 @@ INSERT INTO geometry_columns (f_table_catalog, f_table_schema, f_table_name, f_g INSERT INTO geometry_columns (f_table_catalog, f_table_schema, f_table_name, f_geometry_column, coord_dimension, srid, type) VALUES ('', 'florepatri', 'v_touteslesap_2154_line', 'the_geom_2154', 2, 2154, 'LINESTRING'); INSERT INTO geometry_columns (f_table_catalog, f_table_schema, f_table_name, f_geometry_column, coord_dimension, srid, type) VALUES ('', 'florepatri', 'v_touteslesap_2154_polygon', 'the_geom_2154', 2, 2154, 'POLYGON'); INSERT INTO geometry_columns (f_table_catalog, f_table_schema, f_table_name, f_geometry_column, coord_dimension, srid, type) VALUES ('', 'florepatri', 'v_toutesleszp_2154', 'the_geom_2154', 2, 2154, 'POLYGON'); +INSERT INTO geometry_columns (f_table_catalog, f_table_schema, f_table_name, f_geometry_column, coord_dimension, srid, type) VALUES ('', 'contactflore', 't_fiches_cflore', 'the_geom_3857', 2, 3857, 'POINT'); +INSERT INTO geometry_columns (f_table_catalog, f_table_schema, f_table_name, f_geometry_column, coord_dimension, srid, type) VALUES ('', 'contactflore', 't_fiches_cflore', 'the_geom_2154', 2, 2154, 'POINT'); +INSERT INTO geometry_columns (f_table_catalog, f_table_schema, f_table_name, f_geometry_column, coord_dimension, srid, type) VALUES ('', 'contactflore', 'v_nomade_unites_geo_cflore', 'the_geom', 2, 2154, 'MULTIPOLYGON'); SET search_path = synthese, pg_catalog; @@ -335,6 +338,7 @@ INSERT INTO bib_sources (id_source, nom_source, desc_source, host, port, usernam INSERT INTO bib_sources (id_source, nom_source, desc_source, host, port, username, pass, db_name, db_schema, db_table, db_field, url, target, picto, groupe, actif) VALUES (4, 'Flore prioritaire', 'Relevés en présence-absence de la flore prioritaire', 'localhost', 22, NULL, NULL, 'geonaturedb', 'florepatri', 't_apresence', 'indexap', 'pda', NULL, 'images/pictos/plante.gif', 'FLORE', false); INSERT INTO bib_sources (id_source, nom_source, desc_source, host, port, username, pass, db_name, db_schema, db_table, db_field, url, target, picto, groupe, actif) VALUES (5, 'Flore station', 'Données de relevés floristique stationnels complets ou partiel', 'localhost', 22, NULL, NULL, 'geonaturedb', 'florestation', 'cor_fs_taxon', 'gid', 'fs', NULL, 'images/pictos/plante.gif', 'FLORE', true); INSERT INTO bib_sources (id_source, nom_source, desc_source, host, port, username, pass, db_name, db_schema, db_table, db_field, url, target, picto, groupe, actif) VALUES (6, 'Bryophytes', 'Données de contact bryologique', 'localhost', 22, NULL, NULL, 'geonaturedb', 'bryophytes', 'cor_bryo_taxon', 'gid', 'bryo', NULL, 'images/pictos/mousse.gif', 'FLORE', true); +INSERT INTO bib_sources (id_source, nom_source, desc_source, host, port, username, pass, db_name, db_schema, db_table, db_field, url, target, picto, groupe, actif) VALUES (7,'Contact flore','Contenu des tables t_fiches_cflore et t_releves_cflore de la base GeoNature postgres','localhost',22,NULL,NULL,'geonaturedb','contactflore','t_releves_cflore','id_releve_cflore','cflore',NULL,'images/pictos/plante.gif','FLORE',true); SET search_path = taxonomie, pg_catalog; @@ -424,11 +428,12 @@ INSERT INTO bib_listes (id_liste ,nom_liste,desc_liste,picto) VALUES (16, 'Arach INSERT INTO bib_listes (id_liste ,nom_liste,desc_liste,picto) VALUES (20, 'Rotifères',null, 'images/pictos/nopicto.gif'); INSERT INTO bib_listes (id_liste ,nom_liste,desc_liste,picto) VALUES (21, 'Tardigrades',null, 'images/pictos/nopicto.gif'); INSERT INTO bib_listes (id_liste ,nom_liste,desc_liste,picto) VALUES (101, 'Mollusques',null, 'images/pictos/mollusque.gif'); -INSERT INTO bib_listes (id_liste ,nom_liste,desc_liste,picto) VALUES (300, 'Plantes vasculaires',null, 'images/pictos/plante.gif'); INSERT INTO bib_listes (id_liste ,nom_liste,desc_liste,picto) VALUES (301, 'Bryophytes',null, 'images/pictos/mousse.gif'); INSERT INTO bib_listes (id_liste ,nom_liste,desc_liste,picto) VALUES (302, 'Lichens',null, 'images/pictos/nopicto.gif'); INSERT INTO bib_listes (id_liste ,nom_liste,desc_liste,picto) VALUES (303, 'Algues',null, 'images/pictos/nopicto.gif'); -INSERT INTO bib_listes (id_liste ,nom_liste,desc_liste,picto) VALUES (304, 'Champignons',null, 'images/pictos/champignon.gif'); +INSERT INTO bib_listes (id_liste ,nom_liste,desc_liste,picto) VALUES (305, 'Ptéridophytes',null, 'images/pictos/nopicto.gif'); +INSERT INTO bib_listes (id_liste ,nom_liste,desc_liste,picto) VALUES (306, 'Monocotylédones',null, 'images/pictos/nopicto.gif'); +INSERT INTO bib_listes (id_liste ,nom_liste,desc_liste,picto) VALUES (307, 'Dycotylédones',null, 'images/pictos/nopicto.gif'); INSERT INTO bib_listes (id_liste ,nom_liste,desc_liste,picto) VALUES (666, 'Nuisibles',null, 'images/pictos/nopicto.gif'); INSERT INTO bib_listes (id_liste ,nom_liste,desc_liste,picto) VALUES (1001, 'liste faune vertébré', 'Liste servant à l''affichage des taxons de la faune vertébré pouvant être saisis', 'images/pictos/nopicto.gif'); INSERT INTO bib_listes (id_liste ,nom_liste,desc_liste,picto) VALUES (1002, 'liste faune invertébré', 'Liste servant à l''affichage des taxons de la faune invertébré pouvant être saisis', 'images/pictos/nopicto.gif'); @@ -455,8 +460,8 @@ INSERT INTO cor_taxon_liste (id_taxon ,id_liste) VALUES (1950, 9); INSERT INTO cor_taxon_liste (id_taxon ,id_liste) VALUES (2804,9); INSERT INTO cor_taxon_liste (id_taxon ,id_liste) VALUES (100001,1003); INSERT INTO cor_taxon_liste (id_taxon ,id_liste) VALUES (100002,1003); -INSERT INTO cor_taxon_liste (id_taxon ,id_liste) VALUES (100001,300); -INSERT INTO cor_taxon_liste (id_taxon ,id_liste) VALUES (100002,300); +INSERT INTO cor_taxon_liste (id_taxon ,id_liste) VALUES (100001,306); +INSERT INTO cor_taxon_liste (id_taxon ,id_liste) VALUES (100002,307); SET search_path = contactfaune, pg_catalog; @@ -625,6 +630,7 @@ INSERT INTO bib_programmes (id_programme, nom_programme, desc_programme, actif, INSERT INTO bib_programmes (id_programme, nom_programme, desc_programme, actif, programme_public, desc_programme_public) VALUES (4, 'Flore prioritaire', 'Inventaire et suivi en présence absence de la Flore prioritaire.', true, true, 'Inventaire et suivi en présence absence de la Flore prioritaire.'); INSERT INTO bib_programmes (id_programme, nom_programme, desc_programme, actif, programme_public, desc_programme_public) VALUES (5, 'Flore station', 'Relevés stationnels et stratifiés de la flore.', true, true, 'Relevés stationnels et stratifiés de la flore.'); INSERT INTO bib_programmes (id_programme, nom_programme, desc_programme, actif, programme_public, desc_programme_public) VALUES (6, 'Bryophytes', 'Relevés stationnels et non stratifiés de la flore bryophyte.', true, true, 'Relevés stationnels et non stratifiés de la flore bryophyte.'); +INSERT INTO bib_programmes (id_programme, nom_programme, desc_programme, actif, programme_public, desc_programme_public) VALUES (7, 'Contact flore', 'Contact aléatoire de la flore.', true, true, 'Contact aléatoire de la faune invertébrée.'); -- -- TOC entry 3370 (class 0 OID 55751) @@ -654,11 +660,12 @@ INSERT INTO bib_supports (id_support, nom_support) VALUES (12, 'Grade sans info' INSERT INTO bib_lots (id_lot, nom_lot, desc_lot, menu_cf, pn, menu_inv, id_programme) VALUES (1, 'Contact vertébrés', 'Contact vertébrés', true, true, false, 1); INSERT INTO bib_lots (id_lot, nom_lot, desc_lot, menu_cf, pn, menu_inv, id_programme) VALUES (2, 'Mortalité', 'Mortalité', true, true, false, 2); -INSERT INTO bib_lots (id_lot, nom_lot, desc_lot, menu_cf, pn, menu_inv, id_programme) VALUES (3, 'Contact invertébrés', 'Contact invertébrés', true, true, false, 3); +INSERT INTO bib_lots (id_lot, nom_lot, desc_lot, menu_cf, pn, menu_inv, id_programme) VALUES (3, 'Contact invertébrés', 'Contact invertébrés', false, true, false, 3); --flore -INSERT INTO bib_lots (id_lot, nom_lot, desc_lot, menu_cf, pn, menu_inv, id_programme) VALUES (4, 'flore prioritaire', 'Inventaire et suivi en présence absence de la Flore prioritaire', true, true, false, 4); -INSERT INTO bib_lots (id_lot, nom_lot, desc_lot, menu_cf, pn, menu_inv, id_programme) VALUES (5, 'flore station', 'Relevés stationnels et stratifiés de la flore', true, true, false, 5); -INSERT INTO bib_lots (id_lot, nom_lot, desc_lot, menu_cf, pn, menu_inv, id_programme) VALUES (6, 'bryophytes', 'Relevés stationnels et non stratifiés de la flore bryophyte', true, true, false, 6); +INSERT INTO bib_lots (id_lot, nom_lot, desc_lot, menu_cf, pn, menu_inv, id_programme) VALUES (4, 'flore prioritaire', 'Inventaire et suivi en présence absence de la Flore prioritaire', false, true, false, 4); +INSERT INTO bib_lots (id_lot, nom_lot, desc_lot, menu_cf, pn, menu_inv, id_programme) VALUES (5, 'flore station', 'Relevés stationnels et stratifiés de la flore', false, true, false, 5); +INSERT INTO bib_lots (id_lot, nom_lot, desc_lot, menu_cf, pn, menu_inv, id_programme) VALUES (6, 'bryophytes', 'Relevés stationnels et non stratifiés de la flore bryophyte', false, true, false, 6); +INSERT INTO bib_lots (id_lot, nom_lot, desc_lot, menu_cf, pn, menu_inv, id_programme) VALUES (7, 'Contact flore', 'Contact flore', false, true, false, 7); -- -- TOC entry 3140 (class 0 OID 126911) @@ -672,9 +679,48 @@ INSERT INTO t_protocoles VALUES (3, 'mortalité', 'à compléter', 'à compléte INSERT INTO t_protocoles VALUES (4, 'Flore prioritaire', 'à compléter', 'à compléter', 'à compléter', 'non', NULL, NULL); INSERT INTO t_protocoles VALUES (5, 'Flore station', 'à compléter', 'à compléter', 'à compléter', 'non', NULL, NULL); INSERT INTO t_protocoles VALUES (6, 'Bryophytes', 'à compléter', 'à compléter', 'à compléter', 'non', NULL, NULL); +INSERT INTO t_protocoles VALUES (7, 'contact flore', 'à compléter', 'à compléter', 'à compléter', 'non', NULL, NULL); -SET search_path = bryophytes, pg_catalog; +SET search_path = contactflore, pg_catalog; +-- +-- TOC entry 3404 (class 0 OID 55310) +-- Dependencies: 179 +-- Data for Name: bib_abondances_cflore; Type: TABLE DATA; Schema: contactflore; Owner: cartopne +-- + +INSERT INTO bib_abondances_cflore (id_abondance_cflore, nom_abondance_cflore) VALUES ('1', '1 individu'); +INSERT INTO bib_abondances_cflore (id_abondance_cflore, nom_abondance_cflore) VALUES ('2', 'De 1 à 10 individus'); +INSERT INTO bib_abondances_cflore (id_abondance_cflore, nom_abondance_cflore) VALUES ('3', 'De 10 à 100 individus'); +INSERT INTO bib_abondances_cflore (id_abondance_cflore, nom_abondance_cflore) VALUES ('4', 'Plus de 100 individus'); + + +-- +-- TOC entry 3410 (class 0 OID 55409) +-- Dependencies: 191 +-- Data for Name: bib_phenologies_cflore; Type: TABLE DATA; Schema: contactflore; Owner: cartopne +-- + +INSERT INTO bib_phenologies_cflore (id_phenologie_cflore, nom_phenologie_cflore) VALUES (1, 'Stade végétatif'); +INSERT INTO bib_phenologies_cflore (id_phenologie_cflore, nom_phenologie_cflore) VALUES (2, 'Stade boutons floraux'); +INSERT INTO bib_phenologies_cflore (id_phenologie_cflore, nom_phenologie_cflore) VALUES (3, 'Début de floraison'); +INSERT INTO bib_phenologies_cflore (id_phenologie_cflore, nom_phenologie_cflore) VALUES (4, 'Pleine floraison'); +INSERT INTO bib_phenologies_cflore (id_phenologie_cflore, nom_phenologie_cflore) VALUES (5, 'Fin de floraison et maturation des fruits'); +INSERT INTO bib_phenologies_cflore (id_phenologie_cflore, nom_phenologie_cflore) VALUES (6, 'Dissémination'); +INSERT INTO bib_phenologies_cflore (id_phenologie_cflore, nom_phenologie_cflore) VALUES (7, 'Stade de décrépitude'); +INSERT INTO bib_phenologies_cflore (id_phenologie_cflore, nom_phenologie_cflore) VALUES (8, 'Stage végétatif permanent '); + + +-- +-- TOC entry 3410 (class 0 OID 55409) +-- Dependencies: 191 +-- Data for Name: bib_validites_cflore; Type: TABLE DATA; Schema: contactflore; Owner: cartopne +-- + +INSERT INTO bib_validites_cflore (id_validite_cflore, nom_validite_cflore) VALUES (1, 'relue'); +INSERT INTO bib_validites_cflore (id_validite_cflore, nom_validite_cflore) VALUES (2, 'non relue'); + +SET search_path = bryophytes, pg_catalog; -- -- TOC entry 3404 (class 0 OID 55310) -- Dependencies: 179 diff --git a/data/update_1.6to1.7.sql b/data/update_1.6to1.7.sql new file mode 100644 index 0000000000..d2e4fa03e7 --- /dev/null +++ b/data/update_1.6to1.7.sql @@ -0,0 +1,137 @@ +-- IMPORTANT ! LIRE AVANT D'EXECUTER CE CODE -- +--Modification des identifiants des listes pour compatibilité avec les applications GeoNature Mobile +--Dans GeoNature Mobile, les taxons sont filtrables par classe sur la base d'un id_classe. Ces id sont inscrits en dur dans le code des applications mobiles. +--Dans la base GeoNature les classes taxonomiques sont configurables grace au vues v_nomade_classes qui utilisent les listes (taxonomie.bib_listes) +--Les id_liste ont donc été mis à jour pour être compatibles avec les id_classe des applications mobiles +--ATTENTION, le script ci-dessous permet de rentre compatible votre base avec geonature mobile sur la base des id_liste livrées avec la base. +--Si vous avez modifié les id_liste dans votre base GeoNature après son installation, vous ne devez pas exécuter ce script. +--Vous pouvez vous en inspirer mais soyez vigilant. +--Si vous n'utilisez pas les applications GeoNature Mobile, vous pouvez laisser id_liste d'origine. +--ATENTION à ne lancer ce script d'update qu'une seule fois. +--Il est conseillé de lancer les instructions sql d'update ligne par ligne et de vérifier que les id_liste à mettre à jour correspondent bien à ceux de votre base. +--Les liens d'intégrité doivent mettre à jour les tables contactfaune.cor_critere_liste, taxonomie.cor_taxon_liste + +UPDATE taxonomie.bib_liste set id_liste = id_liste + 10000; --gestion des conflits sur la clé primaire +DELETE FROM taxonomie.bib_liste WHERE id_liste = 11000; --Plantes vasculaires +DELETE FROM taxonomie.bib_liste WHERE id_liste = 10400; --Champignons +UPDATE taxonomie.bib_liste set id_liste = 1001 WHERE id_liste = 10001; --faune vertébré +UPDATE taxonomie.bib_liste set id_liste = 1002 WHERE id_liste = 10002; --faune invertébré +UPDATE taxonomie.bib_liste set id_liste = 1003 WHERE id_liste = 10003; --flore +UPDATE taxonomie.bib_liste set id_liste = 1004 WHERE id_liste = 11004; --fonge +UPDATE taxonomie.bib_liste set id_liste = 301 WHERE id_liste = 11001; --Bryophytes +UPDATE taxonomie.bib_liste set id_liste = 302 WHERE id_liste = 11002; --Lichens +UPDATE taxonomie.bib_liste set id_liste = 303 WHERE id_liste = 11003; --Algues +UPDATE taxonomie.bib_liste set id_liste = 1 WHERE id_liste = 10101; --Amphibiens +UPDATE taxonomie.bib_liste set id_liste = 7 WHERE id_liste = 10102; --Pycnogonides +UPDATE taxonomie.bib_liste set id_liste = 3 WHERE id_liste = 10103; --Entognathes +UPDATE taxonomie.bib_liste set id_liste = 4 WHERE id_liste = 10104; --Echinodermes +UPDATE taxonomie.bib_liste set id_liste = 5 WHERE id_liste = 10105; --Ecrevisses +UPDATE taxonomie.bib_liste set id_liste = 9 WHERE id_liste = 10106; --Insectes +UPDATE taxonomie.bib_liste set id_liste = 11 WHERE id_liste = 10107; --Mammifères +UPDATE taxonomie.bib_liste set id_liste = 12 WHERE id_liste = 10108; --Oiseaux +UPDATE taxonomie.bib_liste set id_liste = 13 WHERE id_liste = 10109; --Poissons +UPDATE taxonomie.bib_liste set id_liste = 14 WHERE id_liste = 10110; --Reptiles +UPDATE taxonomie.bib_liste set id_liste = 15 WHERE id_liste = 10111; --Myriapodes +UPDATE taxonomie.bib_liste set id_liste = 16 WHERE id_liste = 10112; --Arachnides +UPDATE taxonomie.bib_liste set id_liste = 101 WHERE id_liste = 10113; --Mollusques +UPDATE taxonomie.bib_liste set id_liste = 2 WHERE id_liste = 10114; --Vers +UPDATE taxonomie.bib_liste set id_liste = 20 WHERE id_liste = 10115; --Rotifères +UPDATE taxonomie.bib_liste set id_liste = 21 WHERE id_liste = 10116; --Tardigrades +UPDATE taxonomie.bib_liste set id_liste = 10 WHERE id_liste = 10201; --Bivalves +UPDATE taxonomie.bib_liste set id_liste = 8 WHERE id_liste = 10202; --Gastéropodes +UPDATE taxonomie.bib_liste set nom_liste = 'Crustacés' WHERE id_liste = 10105; --Ecrevisses + +CREATE OR REPLACE VIEW contactfaune.v_nomade_classes AS + SELECT g.id_liste AS id_classe, + g.nom_liste AS nom_classe_fr, + g.desc_liste AS desc_classe + FROM ( SELECT l.id_liste, + l.nom_liste, + l.desc_liste, + min(taxonomie.find_cdref(tx.cd_nom)) AS cd_ref + FROM taxonomie.bib_listes l + JOIN taxonomie.cor_taxon_liste ctl ON ctl.id_liste = l.id_liste + JOIN taxonomie.bib_taxons tx ON tx.id_taxon = ctl.id_taxon + WHERE l.id_liste = ANY (ARRAY[1, 11, 12, 13, 14]) + GROUP BY l.id_liste, l.nom_liste, l.desc_liste) g + JOIN taxonomie.taxref t ON t.cd_nom = g.cd_ref + WHERE t.phylum::text = 'Chordata'::text; + +CREATE OR REPLACE VIEW contactinv.v_nomade_classes AS + SELECT g.id_liste AS id_classe, + g.nom_liste AS nom_classe_fr, + g.desc_liste AS desc_classe + FROM ( SELECT l.id_liste, + l.nom_liste, + l.desc_liste, + min(taxonomie.find_cdref(tx.cd_nom)) AS cd_ref + FROM taxonomie.bib_listes l + JOIN taxonomie.cor_taxon_liste ctl ON ctl.id_liste = l.id_liste + JOIN taxonomie.bib_taxons tx ON tx.id_taxon = ctl.id_taxon + WHERE l.id_liste = ANY (ARRAY[2, 5, 8, 9, 10, 15, 16]) + GROUP BY l.id_liste, l.nom_liste, l.desc_liste) g + JOIN taxonomie.taxref t ON t.cd_nom = g.cd_ref + WHERE t.phylum::text <> 'Chordata'::text AND t.regne::text = 'Animalia'::text; + +CREATE OR REPLACE VIEW florepatri.v_nomade_classes AS + SELECT g.id_liste AS id_classe, + g.nom_liste AS nom_classe_fr, + g.desc_liste AS desc_classe + FROM ( SELECT l.id_liste, + l.nom_liste, + l.desc_liste, + min(taxonomie.find_cdref(tx.cd_nom)) AS cd_ref + FROM taxonomie.bib_listes l + JOIN taxonomie.cor_taxon_liste ctl ON ctl.id_liste = l.id_liste + JOIN taxonomie.bib_taxons tx ON tx.id_taxon = ctl.id_taxon + WHERE l.id_liste > 300 AND l.id_liste < 400 + GROUP BY l.id_liste, l.nom_liste, l.desc_liste) g + JOIN taxonomie.taxref t ON t.cd_nom = g.cd_ref + WHERE t.regne::text = 'Plantae'::text; + +CREATE OR REPLACE VIEW taxonomie.v_nomade_classes AS + SELECT v_nomade_classes.id_classe, + v_nomade_classes.nom_classe_fr, + v_nomade_classes.desc_classe + FROM contactfaune.v_nomade_classes +UNION + SELECT v_nomade_classes.id_classe, + v_nomade_classes.nom_classe_fr, + v_nomade_classes.desc_classe + FROM contactinv.v_nomade_classes +UNION + SELECT v_nomade_classes.id_classe, + v_nomade_classes.nom_classe_fr, + v_nomade_classes.desc_classe + FROM florepatri.v_nomade_classes; + +CREATE OR REPLACE VIEW synthese.v_taxons_synthese AS + SELECT DISTINCT t.nom_francais, + txr.lb_nom AS nom_latin, + f2.bool AS patrimonial, + f3.bool AS protection_stricte, + txr.cd_ref, + txr.cd_nom, + txr.nom_valide, + txr.famille, + txr.ordre, + txr.classe, + txr.regne, + prot.protections, + l.id_liste, + l.picto + FROM taxonomie.taxref txr + JOIN taxonomie.bib_taxons t ON txr.cd_nom = t.cd_nom + JOIN taxonomie.cor_taxon_liste ctl ON ctl.id_taxon = t.id_taxon + JOIN taxonomie.bib_listes l ON l.id_liste = ctl.id_liste AND (l.id_liste = ANY (ARRAY[1001, 1002, 1003, 1004])) + LEFT JOIN ( SELECT tpe.cd_nom, + string_agg((((tpa.arrete || ' '::text) || tpa.article::text) || '__'::text) || tpa.url::text, '#'::text) AS protections + FROM taxonomie.taxref_protection_especes tpe + JOIN taxonomie.taxref_protection_articles tpa ON tpa.cd_protection::text = tpe.cd_protection::text AND tpa.concerne_mon_territoire = true + GROUP BY tpe.cd_nom) prot ON prot.cd_nom = t.cd_nom + JOIN cor_boolean f2 ON f2.expression::text = t.filtre2::text + JOIN cor_boolean f3 ON f3.expression::text = t.filtre3::text + JOIN ( SELECT DISTINCT syntheseff.cd_nom + FROM synthese.syntheseff + WHERE syntheseff.supprime = false) s ON s.cd_nom = t.cd_nom + ORDER BY t.nom_francais; \ No newline at end of file diff --git a/docs/changelog.rst b/docs/changelog.rst index d3a3a6ff43..787784fb76 100644 --- a/docs/changelog.rst +++ b/docs/changelog.rst @@ -4,6 +4,32 @@ CHANGELOG 1.7.0 dev (unreleased) ---------------------- +**Note de version** + +* Modification des identifiants des listes pour compatibilité avec les applications GeoNature Mobile. +Dans GeoNature Mobile, les taxons sont filtrables par classe sur la base d'un id_classe. Ces id sont inscrits en dur dans le code des applications mobiles. +Dans la base GeoNature les classes taxonomiques sont configurables grace au vues v_nomade_classes qui utilisent les listes (taxonomie.bib_listes) +Les id_liste ont donc été mis à jour pour être compatibles avec les id_classe des applications mobiles +Voir le script SQL d'update ``data/update_1.6to1.7.sql`` ; LIRE ATTENTIVEMENT LES COMMENTAIRES +* En lien avec les modifications ci-dessus, mettre à jour les variables des classes taxonomiques correspondant aux modification des id_liste dans ``web/js/config.js`` +* Pour ajouter le contact flore : + * Exécuter le script sql ``data/2154/contactflore.sql`` + * Ajouter les variables $id_lot_cflore = 7, $id_protocole_cflore = 7, $id_source_cflore = 7 et $appname_cflore = 'Contact flore - GeoNature'; dans ``lib/sfGeonatureConfig.php`` (voir le fichier ``lib/sfGeonatureConfig.php.sample``) + * Ajouter les variables id_lot_contact_flore = 7, id_protocole_contact_flore = 7, id_source_contactflore = 7 dans ``web/js/config.js`` (voir le fichier ``web/js/config.js.sample``) + * l'enregistrement correspondant au contact flore dans la table ``synthese.bib_sources`` doit être actif (dernière colonne) pour que le contact flore soit visible sur la page d'accueil. + * Vider le cache + + :: + php symfony cc + +**Changements** + +* Modification des identifiants des listes pour compatibilité avec les applications GeoNature Mobile. +* Correction d'une erreur sur l'importation de shape pour la recherche géographique +* WMS : correction de la liste des sites N2000 et retrait des sites inscrits et classés +* Ajout du contact flore + + 1.6.0 (2016-01-14) ------------------ diff --git a/install_db.sh b/install_db.sh index f514a2423a..4d904b705b 100755 --- a/install_db.sh +++ b/install_db.sh @@ -70,6 +70,9 @@ then echo "Insertion des données des tables dictionnaires de la base..." export PGPASSWORD=$user_pg_pass;psql -h geonatdbhost -U $user_pg -d $db_name -f data/2154/data_synthese_2154.sql &>> log/install_db.log + echo "Création du contact flore..." + export PGPASSWORD=$user_pg_pass;psql -h geonatdbhost -U $user_pg -d $db_name -f data/2154/contactflore.sql &>> log/install_db.log + echo "Décompression des fichiers du référentiel géographique..." cd data/layers unzip apb.zip diff --git a/lib/model/doctrine/BibAbondancesCflore.class.php b/lib/model/doctrine/BibAbondancesCflore.class.php new file mode 100644 index 0000000000..3fd5e5d038 --- /dev/null +++ b/lib/model/doctrine/BibAbondancesCflore.class.php @@ -0,0 +1,15 @@ +select('id_abondance_cflore, nom_abondance_cflore') + ->from('BibAbondancesCflore') + ->fetchArray(); + return $query; + } +} \ No newline at end of file diff --git a/lib/model/doctrine/BibMessagesCflore.class.php b/lib/model/doctrine/BibMessagesCflore.class.php new file mode 100644 index 0000000000..b4395afce8 --- /dev/null +++ b/lib/model/doctrine/BibMessagesCflore.class.php @@ -0,0 +1,15 @@ +select('id_phenologie_cflore, nom_phenologie_cflore') + ->from('BibPhenologiesCflore') + ->fetchArray(); + return $phenos; + } +} \ No newline at end of file diff --git a/lib/model/doctrine/BibTaxonsTable.class.php b/lib/model/doctrine/BibTaxonsTable.class.php index 6037e81dcb..78a89479da 100755 --- a/lib/model/doctrine/BibTaxonsTable.class.php +++ b/lib/model/doctrine/BibTaxonsTable.class.php @@ -108,6 +108,21 @@ public static function listTreeSynthese($fff, $patri, $protege) return $query; } + public static function listCflore() + { + $query= Doctrine_Query::create() + ->select('t.id_taxon, t.cd_ref, t.cd_nom, t.nom_latin, t.nom_francais, \'inconnue\' derniere_date, 0 nb_obs, t.id_classe, t.patrimonial, t.message,\'orange\' couleur' ) + ->distinct() + ->from('VNomadeTaxonsFlore t') + ->orderBy('t.nom_latin') + ->fetchArray(); + foreach ($query as $key => &$val) + { + if($val['nom_francais']==null || $val['nom_francais']=='null' || $val['nom_francais']==''){$val['nom_francais']=$val['nom_latin'];} + } + return $query; + } + public static function listCf() { $query= Doctrine_Query::create() @@ -139,6 +154,32 @@ public static function listInv() return $query; } + public static function listCfloreUnite($id_unite_geo = null) + { + $dbh = Doctrine_Manager::getInstance()->getCurrentConnection()->getDbh(); + $sql = "( + SELECT DISTINCT t.id_taxon, t.cd_ref, t.nom_latin, t.nom_francais, to_char(cut.derniere_date,'dd/mm/yyyy') AS derniere_date,CAST(cut.nb_obs AS varchar), + t.id_classe, t.patrimonial, t.message,cut.couleur + FROM contactflore.v_nomade_taxons_flore t + LEFT JOIN contactflore.cor_unite_taxon_cflore cut ON cut.id_taxon = t.id_taxon + WHERE cut.id_unite_geo = $id_unite_geo + ORDER BY t.nom_latin + ) + UNION + ( + SELECT DISTINCT t.id_taxon, t.cd_ref, t.nom_latin, t.nom_francais, '' AS derniere_date,null as nb_obs, + t.id_classe, t.patrimonial, t.message,'orange' AS couleur + FROM contactflore.v_nomade_taxons_flore t + WHERE t.id_taxon NOT IN (SELECT id_taxon FROM contactfflore.cor_unite_taxon_cflore WHERE id_unite_geo = $id_unite_geo) + ORDER BY t.nom_latin + )"; + $taxons = $dbh->query($sql)->fetchAll(PDO::FETCH_ASSOC); + foreach ($taxons as $key => &$val) + { + if($val['nom_francais']==null || $val['nom_francais']=='null' || $val['nom_francais']==''){$val['nom_francais']=$val['nom_latin'];} + } + return $taxons; + } public static function listCfUnite($id_unite_geo = null) { $dbh = Doctrine_Manager::getInstance()->getCurrentConnection()->getDbh(); diff --git a/lib/model/doctrine/CorMessageTaxonCflore.class.php b/lib/model/doctrine/CorMessageTaxonCflore.class.php new file mode 100644 index 0000000000..0599696546 --- /dev/null +++ b/lib/model/doctrine/CorMessageTaxonCflore.class.php @@ -0,0 +1,15 @@ +getCurrentConnection()->getDbh(); @@ -171,12 +171,12 @@ public static function preSearch($params) $nb_res = $nb[0]['nb']; return $nb_res; } - //sinon on est sur la première page, on retourne 50 qui le nombre de résultats que l'on va rechercher + //sinon on est sur la première page, on retourne 50 qui le nombre de résultats que l'on va rechercher else{return 50;} } public static function search($params,$nb_res,$userNom,$userPrenom,$statuscode) { - // On met une limite pour éviter qu'il n'y ait trop de réponses à charger + // On met une limite pour éviter qu'il n'y ait trop de réponses à charger if($nb_res<10000){ $zoom = $params['zoom']; if($zoom<12){$geom = 'synt.the_geom_point';} @@ -237,16 +237,19 @@ public static function search($params,$nb_res,$userNom,$userPrenom,$statuscode) $obs['id_source']==sfGeonatureConfig::$id_source_cf || $obs['id_source']==sfGeonatureConfig::$id_source_mortalite || $obs['id_source']==sfGeonatureConfig::$id_source_inv + || $obs['id_source']==sfGeonatureConfig::$id_source_cflore ) ) || - ($statuscode==6 + ($statuscode ==6 && ( $obs['id_source']==sfGeonatureConfig::$id_source_cf || $obs['id_source']==sfGeonatureConfig::$id_source_mortalite || $obs['id_source']==sfGeonatureConfig::$id_source_inv ) ) + || + ($statuscode >=5 && $obs['id_source']==sfGeonatureConfig::$id_source_cflore) ) {$obs['edit_ok']='true';} else{$obs['edit_ok']='false';} if($compt>0){$geojson .= ',';} @@ -266,12 +269,12 @@ public static function search($params,$nb_res,$userNom,$userPrenom,$statuscode) } private static function addwhere($params) { - //on doit gérer la valeur du emptyText d'extjs qui est transmise pour les champs autre que combobox + //on doit gérer la valeur du emptyText d'extjs qui est transmise pour les champs autre que combobox if($params['observateur']=='Observateur'){$params['observateur']=null;} - if($params['datedebut']=='Date début'){$params['datedebut']=null;} - if($params['periodedebut']=='Période début'){$params['periodedebut']=null;} + if($params['datedebut']=='Date début'){$params['datedebut']=null;} + if($params['periodedebut']=='Période début'){$params['periodedebut']=null;} if($params['datefin']=='Date fin'){$params['datefin']=null;} - if($params['periodefin']=='Période fin'){$params['periodefin']=null;} + if($params['periodefin']=='Période fin'){$params['periodefin']=null;} $sql = ''; if (isset($params['searchgeom']) && $params['searchgeom']!='') $sql .= " AND ST_intersects(synt.the_geom_3857,ST_GeomFromText('".$params['searchgeom']."', 3857))"; @@ -311,7 +314,7 @@ private static function addwhere($params) $sql .= " AND synt.id_organisme = ".$params['id_organisme']; if (isset($params['datedebut']) && $params['datedebut']!=null && isset($params['datefin']) && $params['datefin']!=null) $sql .= " AND synt.dateobs BETWEEN to_date('".$params['datedebut']."','Dy Mon DD YYYY') AND to_date('".$params['datefin']."','Dy Mon DD YYYY')"; - if (isset($params['periodedebut']) && $params['periodedebut']!=null && $params['periodedebut']!='Période début' && isset($params['periodefin']) && $params['periodefin']!=null && $params['periodefin']!='Période fin') + if (isset($params['periodedebut']) && $params['periodedebut']!=null && $params['periodedebut']!='Période début' && isset($params['periodefin']) && $params['periodefin']!=null && $params['periodefin']!='Période fin') $sql .= " AND periode(synt.dateobs,to_date('".$params['periodedebut']."','Dy Mon DD YYYY'),to_date('".$params['periodefin']."','Dy Mon DD YYYY'))=true "; return $sql; } @@ -436,20 +439,20 @@ public static function listShp($params,$typ) public static function getDatasNbObsKd() { $dbh = Doctrine_Manager::getInstance()->getCurrentConnection()->getDbh(); - //nb d'observations par règne + //nb d'observations par règne $sql = "SELECT l.nom_liste, count(*) as nb FROM synthese.syntheseff s JOIN taxonomie.taxref tx ON tx.cd_nom = s.cd_nom JOIN taxonomie.bib_taxons t ON t.cd_nom = tx.cd_nom LEFT JOIN taxonomie.cor_taxon_liste ctl ON ctl.id_taxon = t.id_taxon LEFT JOIN taxonomie.bib_listes l ON l.id_liste = ctl.id_liste - WHERE s.supprime = false AND l.id_liste < 100 + WHERE s.supprime = false AND l.id_liste >= 1000 GROUP BY nom_liste,l.id_liste ORDER BY l.id_liste;"; $result = $dbh->query($sql)->fetchAll(PDO::FETCH_ASSOC); - $nb = count($result); + $nbs = count($result); $datas = array(); $somme = 0; - for ($i = 0; $i < $nb; $i++) { + for ($i = 0; $i < $nbs; $i++) { $data = array(); $nb = $result[$i]['nb']; $nom_liste = $result[$i]['nom_liste']; @@ -462,20 +465,20 @@ public static function getDatasNbObsKd() public static function getDatasNbObsCl() { $dbh = Doctrine_Manager::getInstance()->getCurrentConnection()->getDbh(); - //nb d'observations par règne + //nb d'observations par règne $sql = "SELECT l.nom_liste, count(*) as nb FROM synthese.syntheseff s JOIN taxonomie.taxref tx ON tx.cd_nom = s.cd_nom JOIN taxonomie.bib_taxons t ON t.cd_nom = tx.cd_nom LEFT JOIN taxonomie.cor_taxon_liste ctl ON ctl.id_taxon = t.id_taxon LEFT JOIN taxonomie.bib_listes l ON l.id_liste = ctl.id_liste - WHERE s.supprime = false AND l.id_liste > 100 + WHERE s.supprime = false AND l.id_liste < 1000 GROUP BY nom_liste,l.id_liste ORDER BY l.id_liste;"; $result = $dbh->query($sql)->fetchAll(PDO::FETCH_ASSOC); - $nb = count($result); + $nbs = count($result); $datas = array(); $somme = 0; - for ($i = 0; $i < $nb; $i++) { + for ($i = 0; $i < $nbs; $i++) { $data = array(); $nb = $result[$i]['nb']; $nom_liste = $result[$i]['nom_liste']; diff --git a/lib/model/doctrine/TFichesCfTable.class.php b/lib/model/doctrine/TFichesCfTable.class.php index 5befe43866..7cff957094 100755 --- a/lib/model/doctrine/TFichesCfTable.class.php +++ b/lib/model/doctrine/TFichesCfTable.class.php @@ -3,7 +3,6 @@ class TFichesCfTable extends Doctrine_Table { - public static function getInstance() { return Doctrine_Core::getTable('TFichesCf'); @@ -104,14 +103,4 @@ private static function listIdsObservateurs($id_cf) } return implode(',',$obs); } - - // private static function getCounterObservateurs() - // { - // $o = Doctrine_Query::create() - // ->select('count(id_role) nb') - // ->from('CorRoleFicheCf c') - // ->where('c.id_cf=?'); - // return $o; - // } - } \ No newline at end of file diff --git a/lib/model/doctrine/TFichesCflore.class.php b/lib/model/doctrine/TFichesCflore.class.php new file mode 100644 index 0000000000..961326511f --- /dev/null +++ b/lib/model/doctrine/TFichesCflore.class.php @@ -0,0 +1,15 @@ +select('id_cflore, dateobs') + ->from('TFichesCflore') + ->where('supprime=?', false) + ->fetchArray(); + return $list; + } + //methode pour l'alimentation du formulaire de saisie + //on passe l'altitude retenue avec le nom altitude _saisie pour l'enregistrement de retour du formulaire + public static function findOne($id_cflore, $format = null) + { + $fields = 'f.id_cflore, f.dateobs,f.altitude_retenue altitude_saisie,com.commune_min commune'; + if ( !is_null($format) && $format==='geoJSON' ) + $query = mfQuery::create('the_geom_3857'); + else + $query = Doctrine_Query::create(); + $fiche = $query + ->select($fields) + ->from('TFichesCflore f') + ->leftJoin('f.LCommunes com') + ->where('id_cflore=?', $id_cflore) + ->fetchOne(array(), Doctrine::HYDRATE_ARRAY); + + if (!isset($fiche['id_cflore']) && $fiche['id_cflore']=='') + return false; + + // Format array + $fiche['ids_observateurs'] = self::listIdsObservateurs($id_cflore); + $fiche['lesobservateurs'] = $fiche['ids_observateurs'];//pour le chargement auto du combobox multiselect dans extjs + + //remise au format des dates + $d = array(); $pattern = '/^(\d{4})-(\d{2})-(\d{2})/'; + preg_match($pattern, $fiche['dateobs'], $d); + $fiche['dateobs'] = sprintf('%s/%s/%s', $d[3],$d[2],$d[1]); + + return $fiche; + } + public static function getMaxIdFiche() + { + $ids= Doctrine_Query::create() + ->select('max(id_cflore) as maxid' ) + ->from('TFichesCflore') + ->where('id_cflore<10000000') + ->fetchArray(); + foreach ($ids as $key => &$id) + { + $maxid = $id['maxid']; + } + return $maxid; + } + + private static function listObservateurs($id_cflore) + { + $observateurs = Doctrine_Query::create() + ->select("o.id_role, concat(o.prenom_role, ' ', o.nom_role) observateur") + ->distinct() + ->from('TRoles o') + ->innerJoin('o.CorRoleFicheCflore crfc') + ->where('crfc.id_cflore=?', $id_cflore) + ->fetchArray(); + $obs = array(); + foreach ($observateurs as $observateur) + { + $o = $observateur['observateur']; + array_push($obs,$o); + } + return implode(', ',$obs); + } + + private static function listIdsObservateurs($id_cflore) + { + $observateurs = Doctrine_Query::create() + ->select("id_role") + ->distinct() + ->from('CorRoleFicheCflore') + ->where('id_cflore=?', $id_cflore) + ->fetchArray(); + $obs = array(); + foreach ($observateurs as $observateur) + { + $o = $observateur['id_role']; + array_push($obs,$o); + } + return implode(',',$obs); + } +} \ No newline at end of file diff --git a/lib/model/doctrine/TRelevesCflore.class.php b/lib/model/doctrine/TRelevesCflore.class.php new file mode 100644 index 0000000000..c6443d725d --- /dev/null +++ b/lib/model/doctrine/TRelevesCflore.class.php @@ -0,0 +1,16 @@ +select($select) + ->from('TRelevesCflore r') + ->leftJoin('r.VNomadeTaxonsFlore v') + ->where('r.supprime=?', false) + ->addWhere('r.id_cflore=?', $id_cflore) + ->fetchArray(); + // print_r($releves); + foreach ($releves as $key => &$releve) + { + $releve['cd_ref'] = $releve['VNomadeTaxonsFlore'][0]['cd_ref']; + $releve['nom_francais'] = $releve['VNomadeTaxonsFlore'][0]['nom_francais']; + $releve['nom_latin'] = $releve['VNomadeTaxonsFlore'][0]['nom_latin']; + $releve['patrimonial'] = (!$releve['VNomadeTaxonsFlore'][0]['patrimonial'])?true:false; + $releve['id_classe'] = $releve['VNomadeTaxonsFlore'][0]['id_classe']; + $releve['message'] = $releve['VNomadeTaxonsFlore'][0]['message']; + unset($releve['VNomadeTaxonsFlore']); + } + return $releves; + } + public static function getMaxIdReleve() + { + $ids= Doctrine_Query::create() + ->select('max(id_releve_cflore) as maxid' ) + ->from('TRelevesCflore') + ->where('id_releve_cflore<10000000') + ->fetchArray(); + foreach ($ids as $key => &$id) + { + $maxid = $id['maxid']; + } + return $maxid; + } +} \ No newline at end of file diff --git a/lib/model/doctrine/TRolesTable.class.php b/lib/model/doctrine/TRolesTable.class.php index fa479b137c..d7ba3c258c 100755 --- a/lib/model/doctrine/TRolesTable.class.php +++ b/lib/model/doctrine/TRolesTable.class.php @@ -106,4 +106,17 @@ public static function filtreObservateursBryo() ->fetchArray(); return $query; } + + public static function filtreObservateursCflore() + { + $query = Doctrine_Query::create() + ->select('r.id_role, concat(r.nom_role, \' \',r.prenom_role) auteur' ) + ->from('TRoles r') + ->innerJoin('r.CorRoleFicheCflore crfc') + ->where('r.groupe = false') + // ->addWhere('') + ->orderBy('auteur') + ->fetchArray(); + return $query; + } } \ No newline at end of file diff --git a/lib/model/doctrine/VNomadeTaxonsFlore.class.php b/lib/model/doctrine/VNomadeTaxonsFlore.class.php new file mode 100644 index 0000000000..88d21ae7fd --- /dev/null +++ b/lib/model/doctrine/VNomadeTaxonsFlore.class.php @@ -0,0 +1,15 @@ +setTableName('contactflore.bib_abondances_cflore'); + $this->hasColumn('id_abondance_cflore', 'integer', 4, array( + 'type' => 'integer', + 'primary' => true, + 'length' => 4, + )); + $this->hasColumn('nom_abondance_cflore', 'string', 25, array( + 'type' => 'string', + 'length' => 25, + )); + } + + public function setUp() + { + parent::setUp(); + $this->hasMany('TRelevesCflore', array( + 'local' => 'id_abondance_cflore', + 'foreign' => 'id_abondance_cflore')); + } +} \ No newline at end of file diff --git a/lib/model/doctrine/base/BaseBibLots.class.php b/lib/model/doctrine/base/BaseBibLots.class.php index cdcad36fe8..45d31aeaf0 100755 --- a/lib/model/doctrine/base/BaseBibLots.class.php +++ b/lib/model/doctrine/base/BaseBibLots.class.php @@ -15,6 +15,7 @@ * @property BibProgrammes $BibProgrammes * @property Doctrine_Collection $Syntheseff * @property Doctrine_Collection $TFichesCf + * @property Doctrine_Collection $TFichesCflore * @property Doctrine_Collection $TFichesInv * @property Doctrine_Collection $TStationsBryo * @property Doctrine_Collection $TStationsFs @@ -30,6 +31,7 @@ * @method BibProgrammes getBibProgrammes() Returns the current record's "BibProgrammes" value * @method Doctrine_Collection getSyntheseff() Returns the current record's "Syntheseff" collection * @method Doctrine_Collection getTFichesCf() Returns the current record's "TFichesCf" collection + * @method Doctrine_Collection getTFichesCflore() Returns the current record's "TFichesCflore" collection * @method Doctrine_Collection getTFichesInv() Returns the current record's "TFichesInv" collection * @method Doctrine_Collection getTStationsBryo() Returns the current record's "TStationsBryo" collection * @method Doctrine_Collection getTStationsFs() Returns the current record's "TStationsFs" collection @@ -44,6 +46,7 @@ * @method BibLots setBibProgrammes() Sets the current record's "BibProgrammes" value * @method BibLots setSyntheseff() Sets the current record's "Syntheseff" collection * @method BibLots setTFichesCf() Sets the current record's "TFichesCf" collection + * @method BibLots setTFichesCflore() Sets the current record's "TFichesCflore" collection * @method BibLots setTFichesInv() Sets the current record's "TFichesInv" collection * @method BibLots setTStationsBryo() Sets the current record's "TStationsBryo" collection * @method BibLots setTStationsFs() Sets the current record's "TStationsFs" collection @@ -105,6 +108,10 @@ public function setUp() 'local' => 'id_lot', 'foreign' => 'id_lot')); + $this->hasMany('TFichesCflore', array( + 'local' => 'id_lot', + 'foreign' => 'id_lot')); + $this->hasMany('TFichesInv', array( 'local' => 'id_lot', 'foreign' => 'id_lot')); diff --git a/lib/model/doctrine/base/BaseBibMessagesCflore.class.php b/lib/model/doctrine/base/BaseBibMessagesCflore.class.php new file mode 100644 index 0000000000..fb0571f8f2 --- /dev/null +++ b/lib/model/doctrine/base/BaseBibMessagesCflore.class.php @@ -0,0 +1,47 @@ +setTableName('contactflore.bib_messages_cflore'); + $this->hasColumn('id_message_cflore', 'integer', 4, array( + 'type' => 'integer', + 'primary' => true, + 'length' => 4, + )); + $this->hasColumn('texte_message_cflore', 'string', 255, array( + 'type' => 'string', + 'length' => 255, + )); + } + + public function setUp() + { + parent::setUp(); + $this->hasMany('CorMessageTaxonCflore', array( + 'local' => 'id_message_cflore', + 'foreign' => 'id_message_cflore')); + } +} \ No newline at end of file diff --git a/lib/model/doctrine/base/BaseBibPhenologiesCflore.class.php b/lib/model/doctrine/base/BaseBibPhenologiesCflore.class.php new file mode 100644 index 0000000000..1e1f2cfddf --- /dev/null +++ b/lib/model/doctrine/base/BaseBibPhenologiesCflore.class.php @@ -0,0 +1,47 @@ +setTableName('contactflore.bib_phenologies_cflore'); + $this->hasColumn('id_phenologie_cflore', 'integer', 4, array( + 'type' => 'integer', + 'primary' => true, + 'length' => 4, + )); + $this->hasColumn('nom_phenologie_cflore', 'string', 100, array( + 'type' => 'string', + 'length' => 100, + )); + } + + public function setUp() + { + parent::setUp(); + $this->hasMany('TRelevesCflore', array( + 'local' => 'id_phenologie_cflore', + 'foreign' => 'id_phenologie_cflore')); + } +} \ No newline at end of file diff --git a/lib/model/doctrine/base/BaseBibTaxons.class.php b/lib/model/doctrine/base/BaseBibTaxons.class.php index 3207afd9dd..352020847d 100644 --- a/lib/model/doctrine/base/BaseBibTaxons.class.php +++ b/lib/model/doctrine/base/BaseBibTaxons.class.php @@ -22,71 +22,83 @@ * @property string $filtre10 * @property Taxref $Taxref * @property Doctrine_Collection $CorMessageTaxonCf + * @property Doctrine_Collection $CorMessageTaxonCflore * @property Doctrine_Collection $CorMessageTaxonInv * @property Doctrine_Collection $CorTaxonAttribut * @property Doctrine_Collection $CorTaxonListe * @property Doctrine_Collection $CorUniteTaxon + * @property Doctrine_Collection $CorUniteTaxonCflore * @property Doctrine_Collection $CorUniteTaxonInv * @property Doctrine_Collection $TRelevesCf + * @property Doctrine_Collection $TRelevesCflore * @property Doctrine_Collection $TRelevesInv * @property Doctrine_Collection $VNomadeTaxonsFaune + * @property Doctrine_Collection $VNomadeTaxonsFlore * @property Doctrine_Collection $VNomadeTaxonsInv * @property Doctrine_Collection $VTreeTaxonsSynthese * - * @method integer getIdTaxon() Returns the current record's "id_taxon" value - * @method integer getCdNom() Returns the current record's "cd_nom" value - * @method string getNomLatin() Returns the current record's "nom_latin" value - * @method string getNomFrancais() Returns the current record's "nom_francais" value - * @method string getAuteur() Returns the current record's "auteur" value - * @method string getFiltre1() Returns the current record's "filtre1" value - * @method string getFiltre2() Returns the current record's "filtre2" value - * @method string getFiltre3() Returns the current record's "filtre3" value - * @method string getFiltre4() Returns the current record's "filtre4" value - * @method string getFiltre5() Returns the current record's "filtre5" value - * @method string getFiltre6() Returns the current record's "filtre6" value - * @method string getFiltre7() Returns the current record's "filtre7" value - * @method string getFiltre8() Returns the current record's "filtre8" value - * @method string getFiltre9() Returns the current record's "filtre9" value - * @method string getFiltre10() Returns the current record's "filtre10" value - * @method Taxref getTaxref() Returns the current record's "Taxref" value - * @method Doctrine_Collection getCorMessageTaxonCf() Returns the current record's "CorMessageTaxonCf" collection - * @method Doctrine_Collection getCorMessageTaxonInv() Returns the current record's "CorMessageTaxonInv" collection - * @method Doctrine_Collection getCorTaxonAttribut() Returns the current record's "CorTaxonAttribut" collection - * @method Doctrine_Collection getCorTaxonListe() Returns the current record's "CorTaxonListe" collection - * @method Doctrine_Collection getCorUniteTaxon() Returns the current record's "CorUniteTaxon" collection - * @method Doctrine_Collection getCorUniteTaxonInv() Returns the current record's "CorUniteTaxonInv" collection - * @method Doctrine_Collection getTRelevesCf() Returns the current record's "TRelevesCf" collection - * @method Doctrine_Collection getTRelevesInv() Returns the current record's "TRelevesInv" collection - * @method Doctrine_Collection getVNomadeTaxonsFaune() Returns the current record's "VNomadeTaxonsFaune" collection - * @method Doctrine_Collection getVNomadeTaxonsInv() Returns the current record's "VNomadeTaxonsInv" collection - * @method Doctrine_Collection getVTreeTaxonsSynthese() Returns the current record's "VTreeTaxonsSynthese" collection - * @method BibTaxons setIdTaxon() Sets the current record's "id_taxon" value - * @method BibTaxons setCdNom() Sets the current record's "cd_nom" value - * @method BibTaxons setNomLatin() Sets the current record's "nom_latin" value - * @method BibTaxons setNomFrancais() Sets the current record's "nom_francais" value - * @method BibTaxons setAuteur() Sets the current record's "auteur" value - * @method BibTaxons setFiltre1() Sets the current record's "filtre1" value - * @method BibTaxons setFiltre2() Sets the current record's "filtre2" value - * @method BibTaxons setFiltre3() Sets the current record's "filtre3" value - * @method BibTaxons setFiltre4() Sets the current record's "filtre4" value - * @method BibTaxons setFiltre5() Sets the current record's "filtre5" value - * @method BibTaxons setFiltre6() Sets the current record's "filtre6" value - * @method BibTaxons setFiltre7() Sets the current record's "filtre7" value - * @method BibTaxons setFiltre8() Sets the current record's "filtre8" value - * @method BibTaxons setFiltre9() Sets the current record's "filtre9" value - * @method BibTaxons setFiltre10() Sets the current record's "filtre10" value - * @method BibTaxons setTaxref() Sets the current record's "Taxref" value - * @method BibTaxons setCorMessageTaxonCf() Sets the current record's "CorMessageTaxonCf" collection - * @method BibTaxons setCorMessageTaxonInv() Sets the current record's "CorMessageTaxonInv" collection - * @method BibTaxons setCorTaxonAttribut() Sets the current record's "CorTaxonAttribut" collection - * @method BibTaxons setCorTaxonListe() Sets the current record's "CorTaxonListe" collection - * @method BibTaxons setCorUniteTaxon() Sets the current record's "CorUniteTaxon" collection - * @method BibTaxons setCorUniteTaxonInv() Sets the current record's "CorUniteTaxonInv" collection - * @method BibTaxons setTRelevesCf() Sets the current record's "TRelevesCf" collection - * @method BibTaxons setTRelevesInv() Sets the current record's "TRelevesInv" collection - * @method BibTaxons setVNomadeTaxonsFaune() Sets the current record's "VNomadeTaxonsFaune" collection - * @method BibTaxons setVNomadeTaxonsInv() Sets the current record's "VNomadeTaxonsInv" collection - * @method BibTaxons setVTreeTaxonsSynthese() Sets the current record's "VTreeTaxonsSynthese" collection + * @method integer getIdTaxon() Returns the current record's "id_taxon" value + * @method integer getCdNom() Returns the current record's "cd_nom" value + * @method string getNomLatin() Returns the current record's "nom_latin" value + * @method string getNomFrancais() Returns the current record's "nom_francais" value + * @method string getAuteur() Returns the current record's "auteur" value + * @method string getFiltre1() Returns the current record's "filtre1" value + * @method string getFiltre2() Returns the current record's "filtre2" value + * @method string getFiltre3() Returns the current record's "filtre3" value + * @method string getFiltre4() Returns the current record's "filtre4" value + * @method string getFiltre5() Returns the current record's "filtre5" value + * @method string getFiltre6() Returns the current record's "filtre6" value + * @method string getFiltre7() Returns the current record's "filtre7" value + * @method string getFiltre8() Returns the current record's "filtre8" value + * @method string getFiltre9() Returns the current record's "filtre9" value + * @method string getFiltre10() Returns the current record's "filtre10" value + * @method Taxref getTaxref() Returns the current record's "Taxref" value + * @method Doctrine_Collection getCorMessageTaxonCf() Returns the current record's "CorMessageTaxonCf" collection + * @method Doctrine_Collection getCorMessageTaxonCflore() Returns the current record's "CorMessageTaxonCflore" collection + * @method Doctrine_Collection getCorMessageTaxonInv() Returns the current record's "CorMessageTaxonInv" collection + * @method Doctrine_Collection getCorTaxonAttribut() Returns the current record's "CorTaxonAttribut" collection + * @method Doctrine_Collection getCorTaxonListe() Returns the current record's "CorTaxonListe" collection + * @method Doctrine_Collection getCorUniteTaxon() Returns the current record's "CorUniteTaxon" collection + * @method Doctrine_Collection getCorUniteTaxonCflore() Returns the current record's "CorUniteTaxonCflore" collection + * @method Doctrine_Collection getCorUniteTaxonInv() Returns the current record's "CorUniteTaxonInv" collection + * @method Doctrine_Collection getTRelevesCf() Returns the current record's "TRelevesCf" collection + * @method Doctrine_Collection getTRelevesCflore() Returns the current record's "TRelevesCflore" collection + * @method Doctrine_Collection getTRelevesInv() Returns the current record's "TRelevesInv" collection + * @method Doctrine_Collection getVNomadeTaxonsFaune() Returns the current record's "VNomadeTaxonsFaune" collection + * @method Doctrine_Collection getVNomadeTaxonsFlore() Returns the current record's "VNomadeTaxonsFlore" collection + * @method Doctrine_Collection getVNomadeTaxonsInv() Returns the current record's "VNomadeTaxonsInv" collection + * @method Doctrine_Collection getVTreeTaxonsSynthese() Returns the current record's "VTreeTaxonsSynthese" collection + * @method BibTaxons setIdTaxon() Sets the current record's "id_taxon" value + * @method BibTaxons setCdNom() Sets the current record's "cd_nom" value + * @method BibTaxons setNomLatin() Sets the current record's "nom_latin" value + * @method BibTaxons setNomFrancais() Sets the current record's "nom_francais" value + * @method BibTaxons setAuteur() Sets the current record's "auteur" value + * @method BibTaxons setFiltre1() Sets the current record's "filtre1" value + * @method BibTaxons setFiltre2() Sets the current record's "filtre2" value + * @method BibTaxons setFiltre3() Sets the current record's "filtre3" value + * @method BibTaxons setFiltre4() Sets the current record's "filtre4" value + * @method BibTaxons setFiltre5() Sets the current record's "filtre5" value + * @method BibTaxons setFiltre6() Sets the current record's "filtre6" value + * @method BibTaxons setFiltre7() Sets the current record's "filtre7" value + * @method BibTaxons setFiltre8() Sets the current record's "filtre8" value + * @method BibTaxons setFiltre9() Sets the current record's "filtre9" value + * @method BibTaxons setFiltre10() Sets the current record's "filtre10" value + * @method BibTaxons setTaxref() Sets the current record's "Taxref" value + * @method BibTaxons setCorMessageTaxonCf() Sets the current record's "CorMessageTaxonCf" collection + * @method BibTaxons setCorMessageTaxonCflore() Sets the current record's "CorMessageTaxonCflore" collection + * @method BibTaxons setCorMessageTaxonInv() Sets the current record's "CorMessageTaxonInv" collection + * @method BibTaxons setCorTaxonAttribut() Sets the current record's "CorTaxonAttribut" collection + * @method BibTaxons setCorTaxonListe() Sets the current record's "CorTaxonListe" collection + * @method BibTaxons setCorUniteTaxon() Sets the current record's "CorUniteTaxon" collection + * @method BibTaxons setCorUniteTaxonCflore() Sets the current record's "CorUniteTaxonCflore" collection + * @method BibTaxons setCorUniteTaxonInv() Sets the current record's "CorUniteTaxonInv" collection + * @method BibTaxons setTRelevesCf() Sets the current record's "TRelevesCf" collection + * @method BibTaxons setTRelevesCflore() Sets the current record's "TRelevesCflore" collection + * @method BibTaxons setTRelevesInv() Sets the current record's "TRelevesInv" collection + * @method BibTaxons setVNomadeTaxonsFaune() Sets the current record's "VNomadeTaxonsFaune" collection + * @method BibTaxons setVNomadeTaxonsFlore() Sets the current record's "VNomadeTaxonsFlore" collection + * @method BibTaxons setVNomadeTaxonsInv() Sets the current record's "VNomadeTaxonsInv" collection + * @method BibTaxons setVTreeTaxonsSynthese() Sets the current record's "VTreeTaxonsSynthese" collection * * @package geonature * @subpackage model @@ -172,6 +184,10 @@ public function setUp() 'local' => 'id_taxon', 'foreign' => 'id_taxon')); + $this->hasMany('CorMessageTaxonCflore', array( + 'local' => 'id_taxon', + 'foreign' => 'id_taxon')); + $this->hasMany('CorMessageTaxonInv', array( 'local' => 'id_taxon', 'foreign' => 'id_taxon')); @@ -188,6 +204,10 @@ public function setUp() 'local' => 'id_taxon', 'foreign' => 'id_taxon')); + $this->hasMany('CorUniteTaxonCflore', array( + 'local' => 'id_taxon', + 'foreign' => 'id_taxon')); + $this->hasMany('CorUniteTaxonInv', array( 'local' => 'id_taxon', 'foreign' => 'id_taxon')); @@ -196,6 +216,10 @@ public function setUp() 'local' => 'id_taxon', 'foreign' => 'id_taxon')); + $this->hasMany('TRelevesCflore', array( + 'local' => 'id_taxon', + 'foreign' => 'id_taxon')); + $this->hasMany('TRelevesInv', array( 'local' => 'id_taxon', 'foreign' => 'id_taxon')); @@ -204,6 +228,10 @@ public function setUp() 'local' => 'id_taxon', 'foreign' => 'id_taxon')); + $this->hasMany('VNomadeTaxonsFlore', array( + 'local' => 'id_taxon', + 'foreign' => 'id_taxon')); + $this->hasMany('VNomadeTaxonsInv', array( 'local' => 'id_taxon', 'foreign' => 'id_taxon')); diff --git a/lib/model/doctrine/base/BaseCorMessageTaxonCflore.class.php b/lib/model/doctrine/base/BaseCorMessageTaxonCflore.class.php new file mode 100644 index 0000000000..9fe3c2b6e4 --- /dev/null +++ b/lib/model/doctrine/base/BaseCorMessageTaxonCflore.class.php @@ -0,0 +1,55 @@ +setTableName('contactflore.cor_message_taxon_cflore'); + $this->hasColumn('id_message_cflore', 'integer', 4, array( + 'type' => 'integer', + 'primary' => true, + 'length' => 4, + )); + $this->hasColumn('id_taxon', 'integer', 4, array( + 'type' => 'integer', + 'primary' => true, + 'length' => 4, + )); + } + + public function setUp() + { + parent::setUp(); + $this->hasOne('BibTaxons', array( + 'local' => 'id_taxon', + 'foreign' => 'id_taxon')); + + $this->hasOne('BibMessagesCflore', array( + 'local' => 'id_message_cflore', + 'foreign' => 'id_message_cflore')); + } +} \ No newline at end of file diff --git a/lib/model/doctrine/base/BaseCorMessageTaxonInv.class.php b/lib/model/doctrine/base/BaseCorMessageTaxonInv.class.php index 50c0f2f8ed..14af00ce8c 100755 --- a/lib/model/doctrine/base/BaseCorMessageTaxonInv.class.php +++ b/lib/model/doctrine/base/BaseCorMessageTaxonInv.class.php @@ -8,16 +8,16 @@ * @property integer $id_message_inv * @property integer $id_taxon * @property BibTaxons $BibTaxons - * @property BibMessagesInv $BibMessagesCf + * @property BibMessagesInv $BibMessagesInv * * @method integer getIdMessageInv() Returns the current record's "id_message_inv" value * @method integer getIdTaxon() Returns the current record's "id_taxon" value * @method BibTaxons getBibTaxons() Returns the current record's "BibTaxons" value - * @method BibMessagesInv getBibMessagesCf() Returns the current record's "BibMessagesCf" value + * @method BibMessagesInv getBibMessagesInv() Returns the current record's "BibMessagesInv" value * @method CorMessageTaxonInv setIdMessageInv() Sets the current record's "id_message_inv" value * @method CorMessageTaxonInv setIdTaxon() Sets the current record's "id_taxon" value * @method CorMessageTaxonInv setBibTaxons() Sets the current record's "BibTaxons" value - * @method CorMessageTaxonInv setBibMessagesCf() Sets the current record's "BibMessagesCf" value + * @method CorMessageTaxonInv setBibMessagesInv() Sets the current record's "BibMessagesInv" value * * @package geonature * @subpackage model @@ -48,7 +48,7 @@ public function setUp() 'local' => 'id_taxon', 'foreign' => 'id_taxon')); - $this->hasOne('BibMessagesInv as BibMessagesCf', array( + $this->hasOne('BibMessagesInv', array( 'local' => 'id_message_inv', 'foreign' => 'id_message_inv')); } diff --git a/lib/model/doctrine/base/BaseCorRoleFicheCf.class.php b/lib/model/doctrine/base/BaseCorRoleFicheCf.class.php index 1a1ed20996..f97b94714a 100755 --- a/lib/model/doctrine/base/BaseCorRoleFicheCf.class.php +++ b/lib/model/doctrine/base/BaseCorRoleFicheCf.class.php @@ -34,10 +34,10 @@ public function setTableDefinition() 'primary' => true, 'length' => 4, )); - $this->hasColumn('id_cf', 'integer', 5, array( + $this->hasColumn('id_cf', 'integer', 4, array( 'type' => 'integer', 'notnull' => true, - 'length' => 5, + 'length' => 4, )); } diff --git a/lib/model/doctrine/base/BaseCorRoleFicheCflore.class.php b/lib/model/doctrine/base/BaseCorRoleFicheCflore.class.php new file mode 100644 index 0000000000..63e2e84e5a --- /dev/null +++ b/lib/model/doctrine/base/BaseCorRoleFicheCflore.class.php @@ -0,0 +1,55 @@ +setTableName('contactflore.cor_role_fiche_cflore'); + $this->hasColumn('id_role', 'integer', 4, array( + 'type' => 'integer', + 'primary' => true, + 'length' => 4, + )); + $this->hasColumn('id_cflore', 'integer', 4, array( + 'type' => 'integer', + 'notnull' => true, + 'length' => 4, + )); + } + + public function setUp() + { + parent::setUp(); + $this->hasOne('TRoles', array( + 'local' => 'id_role', + 'foreign' => 'id_role')); + + $this->hasOne('TFichesCflore', array( + 'local' => 'id_cflore', + 'foreign' => 'id_cflore')); + } +} \ No newline at end of file diff --git a/lib/model/doctrine/base/BaseCorUniteTaxonCflore.class.php b/lib/model/doctrine/base/BaseCorUniteTaxonCflore.class.php new file mode 100644 index 0000000000..3feb5b9cb5 --- /dev/null +++ b/lib/model/doctrine/base/BaseCorUniteTaxonCflore.class.php @@ -0,0 +1,83 @@ +setTableName('contactflore.cor_unite_taxon_cflore'); + $this->hasColumn('id_taxon', 'integer', 4, array( + 'type' => 'integer', + 'primary' => true, + 'length' => 4, + )); + $this->hasColumn('id_unite_geo', 'integer', 4, array( + 'type' => 'integer', + 'primary' => true, + 'length' => 4, + )); + $this->hasColumn('derniere_date', 'date', 25, array( + 'type' => 'date', + 'length' => 25, + )); + $this->hasColumn('couleur', 'string', 10, array( + 'type' => 'string', + 'length' => 10, + )); + $this->hasColumn('nb_obs', 'integer', 4, array( + 'type' => 'integer', + 'length' => 4, + )); + } + + public function setUp() + { + parent::setUp(); + $this->hasOne('BibTaxons', array( + 'local' => 'id_taxon', + 'foreign' => 'id_taxon')); + + $this->hasOne('LUnitesGeo', array( + 'local' => 'id_unite_geo', + 'foreign' => 'id_unite_geo')); + + $this->hasMany('VNomadeTaxonsFlore', array( + 'local' => 'id_taxon', + 'foreign' => 'id_taxon')); + } +} \ No newline at end of file diff --git a/lib/model/doctrine/base/BaseCorUniteTaxonInv.class.php b/lib/model/doctrine/base/BaseCorUniteTaxonInv.class.php index beecbd8525..902de8a6df 100755 --- a/lib/model/doctrine/base/BaseCorUniteTaxonInv.class.php +++ b/lib/model/doctrine/base/BaseCorUniteTaxonInv.class.php @@ -48,7 +48,7 @@ public function setTableDefinition() )); $this->hasColumn('id_unite_geo', 'integer', 4, array( 'type' => 'integer', - 'notnull' => true, + 'primary' => true, 'length' => 4, )); $this->hasColumn('derniere_date', 'date', 25, array( diff --git a/lib/model/doctrine/base/BaseLCommunes.class.php b/lib/model/doctrine/base/BaseLCommunes.class.php index bb5f658018..f573288fc7 100755 --- a/lib/model/doctrine/base/BaseLCommunes.class.php +++ b/lib/model/doctrine/base/BaseLCommunes.class.php @@ -25,6 +25,7 @@ * @property LSecteurs $LSecteurs * @property Doctrine_Collection $Syntheseff * @property Doctrine_Collection $TFichesCf + * @property Doctrine_Collection $TFichesCflore * @property Doctrine_Collection $TFichesInv * @property Doctrine_Collection $TStationsBryo * @property Doctrine_Collection $TStationsFs @@ -49,6 +50,7 @@ * @method LSecteurs getLSecteurs() Returns the current record's "LSecteurs" value * @method Doctrine_Collection getSyntheseff() Returns the current record's "Syntheseff" collection * @method Doctrine_Collection getTFichesCf() Returns the current record's "TFichesCf" collection + * @method Doctrine_Collection getTFichesCflore() Returns the current record's "TFichesCflore" collection * @method Doctrine_Collection getTFichesInv() Returns the current record's "TFichesInv" collection * @method Doctrine_Collection getTStationsBryo() Returns the current record's "TStationsBryo" collection * @method Doctrine_Collection getTStationsFs() Returns the current record's "TStationsFs" collection @@ -72,6 +74,7 @@ * @method LCommunes setLSecteurs() Sets the current record's "LSecteurs" value * @method LCommunes setSyntheseff() Sets the current record's "Syntheseff" collection * @method LCommunes setTFichesCf() Sets the current record's "TFichesCf" collection + * @method LCommunes setTFichesCflore() Sets the current record's "TFichesCflore" collection * @method LCommunes setTFichesInv() Sets the current record's "TFichesInv" collection * @method LCommunes setTStationsBryo() Sets the current record's "TStationsBryo" collection * @method LCommunes setTStationsFs() Sets the current record's "TStationsFs" collection @@ -172,6 +175,10 @@ public function setUp() 'local' => 'insee', 'foreign' => 'insee')); + $this->hasMany('TFichesCflore', array( + 'local' => 'insee', + 'foreign' => 'insee')); + $this->hasMany('TFichesInv', array( 'local' => 'insee', 'foreign' => 'insee')); diff --git a/lib/model/doctrine/base/BaseLUnitesGeo.class.php b/lib/model/doctrine/base/BaseLUnitesGeo.class.php index 5ac99af6ff..9172363df3 100755 --- a/lib/model/doctrine/base/BaseLUnitesGeo.class.php +++ b/lib/model/doctrine/base/BaseLUnitesGeo.class.php @@ -8,19 +8,22 @@ * @property integer $id_unite_geo * @property blob $the_geom * @property Doctrine_Collection $CorUniteTaxon + * @property Doctrine_Collection $CorUniteTaxonCflore * @property Doctrine_Collection $CorUniteTaxonInv * @property Doctrine_Collection $CorUniteSynthese * - * @method integer getIdUniteGeo() Returns the current record's "id_unite_geo" value - * @method blob getTheGeom() Returns the current record's "the_geom" value - * @method Doctrine_Collection getCorUniteTaxon() Returns the current record's "CorUniteTaxon" collection - * @method Doctrine_Collection getCorUniteTaxonInv() Returns the current record's "CorUniteTaxonInv" collection - * @method Doctrine_Collection getCorUniteSynthese() Returns the current record's "CorUniteSynthese" collection - * @method LUnitesGeo setIdUniteGeo() Sets the current record's "id_unite_geo" value - * @method LUnitesGeo setTheGeom() Sets the current record's "the_geom" value - * @method LUnitesGeo setCorUniteTaxon() Sets the current record's "CorUniteTaxon" collection - * @method LUnitesGeo setCorUniteTaxonInv() Sets the current record's "CorUniteTaxonInv" collection - * @method LUnitesGeo setCorUniteSynthese() Sets the current record's "CorUniteSynthese" collection + * @method integer getIdUniteGeo() Returns the current record's "id_unite_geo" value + * @method blob getTheGeom() Returns the current record's "the_geom" value + * @method Doctrine_Collection getCorUniteTaxon() Returns the current record's "CorUniteTaxon" collection + * @method Doctrine_Collection getCorUniteTaxonCflore() Returns the current record's "CorUniteTaxonCflore" collection + * @method Doctrine_Collection getCorUniteTaxonInv() Returns the current record's "CorUniteTaxonInv" collection + * @method Doctrine_Collection getCorUniteSynthese() Returns the current record's "CorUniteSynthese" collection + * @method LUnitesGeo setIdUniteGeo() Sets the current record's "id_unite_geo" value + * @method LUnitesGeo setTheGeom() Sets the current record's "the_geom" value + * @method LUnitesGeo setCorUniteTaxon() Sets the current record's "CorUniteTaxon" collection + * @method LUnitesGeo setCorUniteTaxonCflore() Sets the current record's "CorUniteTaxonCflore" collection + * @method LUnitesGeo setCorUniteTaxonInv() Sets the current record's "CorUniteTaxonInv" collection + * @method LUnitesGeo setCorUniteSynthese() Sets the current record's "CorUniteSynthese" collection * * @package geonature * @subpackage model @@ -50,6 +53,10 @@ public function setUp() 'local' => 'id_unite_geo', 'foreign' => 'id_unite_geo')); + $this->hasMany('CorUniteTaxonCflore', array( + 'local' => 'id_unite_geo', + 'foreign' => 'id_unite_geo')); + $this->hasMany('CorUniteTaxonInv', array( 'local' => 'id_unite_geo', 'foreign' => 'id_unite_geo')); diff --git a/lib/model/doctrine/base/BaseTFichesCflore.class.php b/lib/model/doctrine/base/BaseTFichesCflore.class.php new file mode 100644 index 0000000000..2d25c1a3e1 --- /dev/null +++ b/lib/model/doctrine/base/BaseTFichesCflore.class.php @@ -0,0 +1,181 @@ +setTableName('contactflore.t_fiches_cflore'); + $this->hasColumn('id_cflore', 'integer', 8, array( + 'type' => 'integer', + 'primary' => true, + 'length' => 8, + )); + $this->hasColumn('insee', 'string', 5, array( + 'type' => 'string', + 'length' => 5, + )); + $this->hasColumn('id_organisme', 'integer', 4, array( + 'type' => 'integer', + 'length' => 4, + )); + $this->hasColumn('id_protocole', 'integer', 4, array( + 'type' => 'integer', + 'length' => 4, + )); + $this->hasColumn('id_lot', 'integer', 4, array( + 'type' => 'integer', + 'length' => 4, + )); + $this->hasColumn('dateobs', 'date', 25, array( + 'type' => 'date', + 'length' => 25, + )); + $this->hasColumn('altitude_saisie', 'integer', 4, array( + 'type' => 'integer', + 'length' => 4, + )); + $this->hasColumn('altitude_sig', 'integer', 4, array( + 'type' => 'integer', + 'length' => 4, + )); + $this->hasColumn('altitude_retenue', 'integer', 4, array( + 'type' => 'integer', + 'length' => 4, + )); + $this->hasColumn('date_insert', 'timestamp', 25, array( + 'type' => 'timestamp', + 'length' => 25, + )); + $this->hasColumn('date_update', 'timestamp', 25, array( + 'type' => 'timestamp', + 'length' => 25, + )); + $this->hasColumn('supprime', 'boolean', 1, array( + 'type' => 'boolean', + 'notnull' => true, + 'length' => 1, + )); + $this->hasColumn('pdop', 'integer', 4, array( + 'type' => 'integer', + 'length' => 4, + )); + $this->hasColumn('srid_dessin', 'integer', 4, array( + 'type' => 'integer', + 'length' => 4, + )); + $this->hasColumn('saisie_initiale', 'string', 20, array( + 'type' => 'string', + 'length' => 20, + )); + $this->hasColumn('the_geom_2154', 'blob', null, array( + 'type' => 'blob', + 'length' => '', + )); + $this->hasColumn('the_geom_3857', 'blob', null, array( + 'type' => 'blob', + 'length' => '', + )); + } + + public function setUp() + { + parent::setUp(); + $this->hasOne('LCommunes', array( + 'local' => 'insee', + 'foreign' => 'insee')); + + $this->hasOne('TProtocoles', array( + 'local' => 'id_protocole', + 'foreign' => 'id_protocole')); + + $this->hasOne('BibLots', array( + 'local' => 'id_lot', + 'foreign' => 'id_lot')); + + $this->hasMany('CorRoleFicheCflore', array( + 'local' => 'id_cflore', + 'foreign' => 'id_cflore')); + + $this->hasMany('TRelevesCflore', array( + 'local' => 'id_cf', + 'foreign' => 'id_cf')); + } +} \ No newline at end of file diff --git a/lib/model/doctrine/base/BaseTProtocoles.class.php b/lib/model/doctrine/base/BaseTProtocoles.class.php index 2f47b3aad6..85d4ca2f8b 100755 --- a/lib/model/doctrine/base/BaseTProtocoles.class.php +++ b/lib/model/doctrine/base/BaseTProtocoles.class.php @@ -15,6 +15,7 @@ * @property date $date_fin * @property Doctrine_Collection $Syntheseff * @property Doctrine_Collection $TFichesCf + * @property Doctrine_Collection $TFichesCflore * @property Doctrine_Collection $TFichesInv * @property Doctrine_Collection $TStationsBryo * @property Doctrine_Collection $TStationsFs @@ -30,6 +31,7 @@ * @method date getDateFin() Returns the current record's "date_fin" value * @method Doctrine_Collection getSyntheseff() Returns the current record's "Syntheseff" collection * @method Doctrine_Collection getTFichesCf() Returns the current record's "TFichesCf" collection + * @method Doctrine_Collection getTFichesCflore() Returns the current record's "TFichesCflore" collection * @method Doctrine_Collection getTFichesInv() Returns the current record's "TFichesInv" collection * @method Doctrine_Collection getTStationsBryo() Returns the current record's "TStationsBryo" collection * @method Doctrine_Collection getTStationsFs() Returns the current record's "TStationsFs" collection @@ -44,6 +46,7 @@ * @method TProtocoles setDateFin() Sets the current record's "date_fin" value * @method TProtocoles setSyntheseff() Sets the current record's "Syntheseff" collection * @method TProtocoles setTFichesCf() Sets the current record's "TFichesCf" collection + * @method TProtocoles setTFichesCflore() Sets the current record's "TFichesCflore" collection * @method TProtocoles setTFichesInv() Sets the current record's "TFichesInv" collection * @method TProtocoles setTStationsBryo() Sets the current record's "TStationsBryo" collection * @method TProtocoles setTStationsFs() Sets the current record's "TStationsFs" collection @@ -105,6 +108,10 @@ public function setUp() 'local' => 'id_protocole', 'foreign' => 'id_protocole')); + $this->hasMany('TFichesCflore', array( + 'local' => 'id_protocole', + 'foreign' => 'id_protocole')); + $this->hasMany('TFichesInv', array( 'local' => 'id_protocole', 'foreign' => 'id_protocole')); diff --git a/lib/model/doctrine/base/BaseTRelevesCflore.class.php b/lib/model/doctrine/base/BaseTRelevesCflore.class.php new file mode 100644 index 0000000000..1ba457b2bb --- /dev/null +++ b/lib/model/doctrine/base/BaseTRelevesCflore.class.php @@ -0,0 +1,147 @@ +setTableName('contactflore.t_releves_cflore'); + $this->hasColumn('id_releve_cflore', 'integer', 5, array( + 'type' => 'integer', + 'primary' => true, + 'length' => 5, + )); + $this->hasColumn('id_cflore', 'integer', 5, array( + 'type' => 'integer', + 'length' => 5, + )); + $this->hasColumn('id_taxon', 'integer', 4, array( + 'type' => 'integer', + 'length' => 4, + )); + $this->hasColumn('id_abondance_cflore', 'integer', 4, array( + 'type' => 'integer', + 'length' => 4, + )); + $this->hasColumn('id_phenologie_cflore', 'integer', 4, array( + 'type' => 'integer', + 'length' => 4, + )); + $this->hasColumn('validite_cflore', 'boolean', 1, array( + 'type' => 'boolean', + 'length' => 1, + )); + $this->hasColumn('cd_ref_origine', 'integer', 4, array( + 'type' => 'integer', + 'length' => 4, + )); + $this->hasColumn('nom_taxon_saisi', 'string', 100, array( + 'type' => 'string', + 'length' => 100, + )); + $this->hasColumn('commentaire', 'string', null, array( + 'type' => 'string', + 'length' => '', + )); + $this->hasColumn('determinateur', 'string', 255, array( + 'type' => 'string', + 'length' => 255, + )); + $this->hasColumn('supprime', 'boolean', 1, array( + 'type' => 'boolean', + 'notnull' => true, + 'length' => 1, + )); + $this->hasColumn('herbier', 'boolean', 1, array( + 'type' => 'boolean', + 'notnull' => true, + 'length' => 1, + )); + } + + public function setUp() + { + parent::setUp(); + $this->hasOne('BibAbondancesCflore', array( + 'local' => 'id_abondance_cflore', + 'foreign' => 'id_abondance_cflore')); + + $this->hasOne('BibPhenologiesCflore', array( + 'local' => 'id_phenologie_cflore', + 'foreign' => 'id_phenologie_cflore')); + + $this->hasOne('BibTaxons', array( + 'local' => 'id_taxon', + 'foreign' => 'id_taxon')); + + $this->hasOne('TFichesCflore', array( + 'local' => 'id_cf', + 'foreign' => 'id_cf')); + + $this->hasMany('VNomadeTaxonsFlore', array( + 'local' => 'id_taxon', + 'foreign' => 'id_taxon')); + } +} \ No newline at end of file diff --git a/lib/model/doctrine/base/BaseTRoles.class.php b/lib/model/doctrine/base/BaseTRoles.class.php index 8eb72916cc..4c604b4da7 100755 --- a/lib/model/doctrine/base/BaseTRoles.class.php +++ b/lib/model/doctrine/base/BaseTRoles.class.php @@ -29,6 +29,7 @@ * @property Doctrine_Collection $CorFsObservateur * @property Doctrine_Collection $CorRoleDroitApplication * @property Doctrine_Collection $CorRoleFicheCf + * @property Doctrine_Collection $CorRoleFicheCflore * @property Doctrine_Collection $CorRoleFicheInv * @property Doctrine_Collection $CorRoleMenu * @property Doctrine_Collection $CorRoles @@ -58,6 +59,7 @@ * @method Doctrine_Collection getCorFsObservateur() Returns the current record's "CorFsObservateur" collection * @method Doctrine_Collection getCorRoleDroitApplication() Returns the current record's "CorRoleDroitApplication" collection * @method Doctrine_Collection getCorRoleFicheCf() Returns the current record's "CorRoleFicheCf" collection + * @method Doctrine_Collection getCorRoleFicheCflore() Returns the current record's "CorRoleFicheCflore" collection * @method Doctrine_Collection getCorRoleFicheInv() Returns the current record's "CorRoleFicheInv" collection * @method Doctrine_Collection getCorRoleMenu() Returns the current record's "CorRoleMenu" collection * @method Doctrine_Collection getCorRoles() Returns the current record's "CorRoles" collection @@ -86,6 +88,7 @@ * @method TRoles setCorFsObservateur() Sets the current record's "CorFsObservateur" collection * @method TRoles setCorRoleDroitApplication() Sets the current record's "CorRoleDroitApplication" collection * @method TRoles setCorRoleFicheCf() Sets the current record's "CorRoleFicheCf" collection + * @method TRoles setCorRoleFicheCflore() Sets the current record's "CorRoleFicheCflore" collection * @method TRoles setCorRoleFicheInv() Sets the current record's "CorRoleFicheInv" collection * @method TRoles setCorRoleMenu() Sets the current record's "CorRoleMenu" collection * @method TRoles setCorRoles() Sets the current record's "CorRoles" collection @@ -207,6 +210,10 @@ public function setUp() 'local' => 'id_role', 'foreign' => 'id_role')); + $this->hasMany('CorRoleFicheCflore', array( + 'local' => 'id_role', + 'foreign' => 'id_role')); + $this->hasMany('CorRoleFicheInv', array( 'local' => 'id_role', 'foreign' => 'id_role')); diff --git a/lib/model/doctrine/base/BaseVNomadeTaxonsFlore.class.php b/lib/model/doctrine/base/BaseVNomadeTaxonsFlore.class.php new file mode 100644 index 0000000000..1995e2e40c --- /dev/null +++ b/lib/model/doctrine/base/BaseVNomadeTaxonsFlore.class.php @@ -0,0 +1,103 @@ +setTableName('contactflore.v_nomade_taxons_flore'); + $this->hasColumn('id_taxon', 'integer', 8, array( + 'type' => 'integer', + 'primary' => true, + 'length' => 8, + )); + $this->hasColumn('cd_ref', 'integer', 8, array( + 'type' => 'integer', + 'length' => 8, + )); + $this->hasColumn('cd_nom', 'integer', 8, array( + 'type' => 'integer', + 'length' => 8, + )); + $this->hasColumn('nom_latin', 'string', 100, array( + 'type' => 'string', + 'length' => 100, + )); + $this->hasColumn('nom_francais', 'string', 50, array( + 'type' => 'string', + 'length' => 50, + )); + $this->hasColumn('id_classe', 'integer', 8, array( + 'type' => 'integer', + 'length' => 8, + )); + $this->hasColumn('patrimonial', 'boolean', 1, array( + 'type' => 'boolean', + 'length' => 1, + )); + $this->hasColumn('message', 'string', 255, array( + 'type' => 'string', + 'length' => 255, + )); + } + + public function setUp() + { + parent::setUp(); + $this->hasOne('BibTaxons', array( + 'local' => 'id_taxon', + 'foreign' => 'id_taxon')); + + $this->hasOne('CorUniteTaxonCflore', array( + 'local' => 'id_taxon', + 'foreign' => 'id_taxon')); + + $this->hasOne('TRelevesCflore', array( + 'local' => 'id_taxon', + 'foreign' => 'id_taxon')); + } +} \ No newline at end of file diff --git a/lib/model/fauneUsers.class.php b/lib/model/fauneUsers.class.php index 8dd8a397e5..7defb597b4 100755 --- a/lib/model/fauneUsers.class.php +++ b/lib/model/fauneUsers.class.php @@ -6,6 +6,7 @@ class fauneUsers extends sfGeonatureActions 1 => 'utilisateur', 2 => 'redacteur', 3 => 'referent', + 5 => 'validateur', 6 => 'administrateur' ); diff --git a/lib/sfGeonatureConfig.php.sample b/lib/sfGeonatureConfig.php.sample index 1e62e5daa5..ef4c89849b 100644 --- a/lib/sfGeonatureConfig.php.sample +++ b/lib/sfGeonatureConfig.php.sample @@ -8,6 +8,7 @@ class sfGeonatureConfig extends sfActions public static $id_lot_florepatri = 4; public static $id_lot_florestation = 5; public static $id_lot_bryo = 6; + public static $id_lot_cflore = 7; //Identifiants des protocoles dans la table meta.bib_protocoles public static $id_protocole_cf = 1; @@ -16,6 +17,7 @@ class sfGeonatureConfig extends sfActions public static $id_protocole_florepatri = 4; public static $id_protocole_florestation = 5; public static $id_protocole_bryo = 6; + public static $id_protocole_cflore = 7; //Identifiants des sources de données dans la table synthese.bib_sources public static $id_source_cf = 1; @@ -24,6 +26,7 @@ class sfGeonatureConfig extends sfActions public static $id_source_florepatri = 4; public static $id_source_florestation = 5; public static $id_source_bryo = 6; + public static $id_source_cflore = 7; //Personnalisation du contenu des menus déroulants (en lien avec la table utilisateurs.t_menus et utilisateurs.cor_role_menu) public static $id_menu_observateurs_cf = 9; @@ -62,6 +65,7 @@ class sfGeonatureConfig extends sfActions public static $appname_cf = 'Contact faune - GeoNature'; public static $appname_inv = 'Contact invertébrés - GeoNature'; public static $appname_mortalite = 'Mortalite faune - GeoNature'; + public static $appname_cflore = 'Contact flore - GeoNature'; public static $appname_florepatri = 'Flore prioritaire - GeoNature'; public static $appname_florestation = 'Flore station - GeoNature'; public static $appname_bryo = 'Bryophytes - GeoNature'; diff --git a/web/js/cflore/application.cflore.editFiche.js b/web/js/cflore/application.cflore.editFiche.js new file mode 100755 index 0000000000..68a1ad66f8 --- /dev/null +++ b/web/js/cflore/application.cflore.editFiche.js @@ -0,0 +1,1989 @@ +/** + * @class application.cflore.editFiche + * Singleton to build the editFiche viewport + * + * @singleton + */ + + Ext.namespace("application.cflore"); + +application.cflore.editFiche = function() { + // private variables + + /** + * Property: map + * {OpenLayers.Map} + */ + map = null; + + /** + * Property: toolbar + * {mapfish.widgets.ToolBar} + */ + var toolbar = null; + + /** + * Property: toolbarInitializedOnce + * {Boolean} toolbar has already been initialized + */ + var toolbarInitializedOnce = false; + + /** + * Property: vectorLayer + * {OpenLayers.Layer.Vector} + */ + vectorLayer = null; + + /** + * Property: dragPanControl + */ + var dragPanControl = null; + + /** + * Property: dragPointControl + */ + var dragPointControl = null; + + /** + * Property: store + * {Ext.data.Store} The ap store (should contain only one record) + */ + var store = null; + + /** + * Property: protocol + * {mapfish.Protocol.MapFish} + */ + var protocol = null + + /** + * Property: eventProtocol + * {mapfish.Protocol.TriggerEventDecorator} + */ + var eventProtocol = null; + + /** + * Property: filterProtocol + * {mapfish.Protocol.MergeFilterDecorator} + */ + var filterProtocol = null; + + /** + * Property: format + * {} + */ + var format = new OpenLayers.Format.WKT(); + + /** + * APIProperty: id_cflore + * The id of fiche to update (if applies), null in case of a creating a new fiche + */ + var id_cflore = null; + + /** + * APIProperty: old_cd_nom + * The old cd_nom of the taxon to update + */ + var old_taxon = null; + + /** + * Property: layerTreeTip + * {Ext.Tip} The layerTreeTip created with the factory + */ + var layerTreeTip = null; + + /** + * Property: firstGeometryLoad + * {Boolean} is the geometry has been load once only + */ + var firstGeometryLoad = true; + + /** + * Property: myProxyTaxons + * {Ext.data.HttpProxy} Url pour charger une liste de taxon fonction de l'unité ??? + */ + + var myProxyReleves = null; + + /** + * Property: myProxyReleves + * {Ext.data.HttpProxy} Url pour charger une liste des releves de la fiche ??? + */ + + var myProxyTaxons = null; + /** + * Property: maProjection + * {Openlayers.Projection} définie ici sinon temps de retard lors de la création du point gps ??? + */ + var maProjection = null; + + /** + * Property: blankRecord + * {Ext.data.Record} record vide pour la grid-taxons + */ + var blankRecord = null; + + /** + * Property: errorMsg + * {string} message to display if taxon form is invalid or not complete + */ + var errorMsg = ''; + + // private functions + + /** + * Method: initViewport + */ + var initViewport = function() { + return new Ext.Viewport({ + layout: 'border' + ,defaults: { + border: false + } + ,items: [ + getViewportCenterItem() + ,getViewportEastItem() + ,getViewportSouthItem() + ] + ,listeners: { + show: initToolbarItems + ,beforedestroy:function(){window.location.href = host_uri+'/'+app_uri;} + ,afterlayout: function(){ + map.baseLayer.redraw(); + } + } + }); + }; + /** + * Method: getViewportSouthItem + */ + var getViewportSouthItem = function() { + return { + region:"south" + ,layout:'fit' + ,height:45 + ,bbar: new Ext.Toolbar({ + items: ['© GeoNature, développé par le Parc national des Ecrins', '->', + application.cflore.user.nom+' ('+application.cflore.user.status+')', + { + text: 'Déconnexion' + ,iconCls: 'logout' + ,handler: function() { + window.location.href = 'deconnexion' + } + },{ + text: 'Accueil' + ,iconCls: 'home_mini' + ,handler: function() { + window.location.href = '/'+app_uri + } + }] + }) + } + }; + /** + * Method: getViewportEastItem + */ + var getViewportEastItem = function() { + return { + region: 'east' + ,width: 600 + ,split: true + ,autoScroll: true + ,defaults: { + border: false + } + ,items: [{ + id: 'edit-fiche-form' + ,xtype: 'form' + ,bodyStyle: 'padding: 5px' + ,disabled: true + ,defaults: { + xtype: 'numberfield' + ,labelWidth: 90 + ,width: 180 + ,anchor:'-15' + } + ,monitorValid:true + ,items: [getFormItems(),getFormTaxons()] + //pour version Extjs 3.4 + ,buttons:[{ + text: 'Annuler' + ,xtype: 'button' + ,handler: function() { + Ext.Msg.confirm('Attention' + ,'Cette action va réinitialiser totalement le formulaire.
Si vous avez des données non enregistrées elles seront perdues.
Souhaitez poursuivre ?' + ,function(btn) { + if (btn == 'yes') { + resetViewport(); + Ext.ux.Toast.msg('Information !', 'Aucune données n\'a été enregistrée, le formulaire a été réinitialisé.'); + } + else{Ext.ux.Toast.msg('Action annulée', '');} + } + ,this // scope + ); + } + ,scope: this + },{ + text: 'Enregistrer' + ,xtype: 'button' + ,id: 'ficheSaveButton' + ,iconCls: 'action-save' + ,handler:function(){submitForm();} + }] + }] + } + }; + + /** + * Method: getViewportCenterItem + */ + var getViewportCenterItem = function() { + createMap(); + toolbar = new mapfish.widgets.toolbar.Toolbar({ + map: map, + configurable: false + }); + + return { + region: 'center' + ,id: 'edit-fiche-mapcomponent' + ,xtype: 'mapcomponent' + ,map: map + ,tbar: toolbar + }; + }; + + /** + * Method: getFormItems + * Creates the form items + */ + var getFormItems = function() { + var comboObservateurs = new Ext.ux.form.SuperBoxSelect({ + id:'combo-fiche-observateurs' + ,xtype:'superboxselect' + ,fieldLabel: 'Observateur(s) ' + ,name: 'lesobservateurs' + ,store: application.cflore.storeObservateursCfloreAdd + ,displayField: 'auteur' + ,valueField: 'id_role' + ,allowBlank: false + ,resizable: true + ,forceSelection : true + ,selectOnFocus:true + ,resizable: true + ,mode: 'local' + ,value: application.cflore.user.id_utilisateur + ,listeners:{ + afterrender :function(combo){ + combo.setValue(application.cflore.user.id_utilisateur); + Ext.getCmp('edit-fiche-form').getForm().findField('ids_observateurs').setValue(combo.getValue()); + } + ,change:function(combo,newValue){ + Ext.getCmp('edit-fiche-form').getForm().findField('ids_observateurs').setValue(newValue); + Ext.getCmp('edit-fiche-form').getForm().findField('ids_observateurs').setValue(newValue); + } + ,render: function(c) { + Ext.QuickTips.register({ + target: c.getEl(), + text: 'Le ou les auteurs de l\'observation.' + }); + } + } + }); + var todayButton = new Ext.Button({ + id:'bt-today' + ,text: 'aujourd\'hui' + ,handler: function() { + var d = new Date(); + Ext.getCmp('datefield-fiche-date').setValue(d); + } + ,scope: this + }); + var yesterdayButton = new Ext.Button({ + id:'bt-yesterday' + ,text: 'hier' + ,handler: function() { + var d = new Date(); + d.setDate(d.getDate() - 1); + Ext.getCmp('datefield-fiche-date').setValue(d); + } + ,scope: this + }); + + return [{ + id:'hidden-idfiche' + ,xtype:'hidden' + ,name: 'id_cflore' + },{ + xtype:'hidden' + ,name: 'monaction' + },{ + xtype: 'hidden' + ,name: 'geometry' + },{ + xtype:'hidden' + ,name: 'ids_observateurs' + },{ + // Fieldset + xtype:'fieldset' + ,id:'fieldset-1-fiche' + ,columnWidth: 1 + ,title: 'Renseignements concernant le pointage' + ,collapsible: true + ,autoHeight:true + ,anchor:'98%' + ,items :[comboObservateurs + ,{ + xtype: 'compositefield' + ,labelWidth: 80 + ,items: [ + { + id:'datefield-fiche-date' + ,fieldLabel: 'Date ' + ,name: 'dateobs' + ,xtype:'datefield' + ,maxValue: new Date() + ,format: 'd/m/Y' + ,altFormats:'Y-m-d' + ,allowBlank: false + ,blankText:'La date de l\'observation est obligatoire' + ,listeners: { + render: function(c) { + Ext.QuickTips.register({ + target: c.getEl(), + text: 'Date de l\'observation. Elle ne peut donc être postérieure à la date de saisie.' + }); + } + } + } + ,todayButton + ,yesterdayButton + ,{ + xtype: 'displayfield', + value: ' Altitude :' + },{ + id: 'fieldfiche-altitude' + ,xtype:'numberfield' + ,allowDecimals :false + ,allowNegative: false + ,name: 'altitude_saisie' + ,anchor: '40%' + ,listeners: { + render: function(c) { + Ext.QuickTips.register({ + target: c.getEl(), + text: 'L\'altitude est calculée à partir d\'un service de l\'API Geoportail de l\'IGN. Vous pouvez la corriger si vous le souhaitez.' + }); + } + } + }] + },{ + id:'fieldlabel-commune' + ,xtype: 'displayfield' + ,value: 'Commune : inconnue' + } + ] + } //fin du groupe 1 + ] //fin du return + }; + /** + * Method: getFormTaxons + * + * Dans ce formulaire, les données saisies à droite sont enregistrées dans le store + * de la grille de gauche en temps réel (sur keyup ou sur select pour les combo). + * Une fonction invoquée sur chaque modification des champs obligatoires vérifie + * si l'ensemble du formulaire est valid ou non. + * si oui on active le bouton enregister, sinon l'enregistrement est impossible. + */ + var getFormTaxons = function(){ + var relevesStoreFields = [ + {name: 'id_releve_cflore', type: 'integer'} + ,{name: 'id_taxon', type: 'integer'} + ,{name: 'nom_francais', type: 'string',sortType: Ext.data.SortTypes.asAccentuatedString} + ,{name: 'nom_latin', type: 'string'} + ,{name: 'nom_taxon_saisi', type: 'string'} + ,{name: 'id_abondance_cflore', type: 'integer'} + ,{name: 'id_phenologie_cflore', type: 'integer'} + ,{name: 'validite_cflore', type: 'boolean'} + ,{name: 'commentaire', type: 'string'} + ,{name: 'determinateur', type: 'string'} + ,{name: 'cd_ref_origine', type: 'integer'} + ,{name: 'id_classe', type: 'integer'} + ,{name: 'herbier', type: 'boolean'} + ,{name: 'patrimonial'} + ]; + + myProxyReleves = new Ext.data.HttpProxy({ + id:'store-releve-proxy' + ,url: 'cflore/listreleves' + ,method: 'GET' + }); + var relevesStore = new Ext.data.JsonStore({ + url: myProxyReleves + ,sortInfo: { + field: 'nom_francais' + ,direction: 'ASC' + } + ,fields: relevesStoreFields + ,listeners: { + load: function(store, records) { + Ext.getCmp('grid-taxons').getSelectionModel().selectRow(0); + } + } + }); + + //record vide pour le bouton ajouter un taxon + blankRecord = Ext.data.Record.create(relevesStoreFields); + + function isPatri(val){ + if(val){ + return '' + val + ''; + } + return val; + } + + var colModel = new Ext.grid.ColumnModel([ + {header: "Id", width: 55, sortable: true, dataIndex: 'id_taxon',hidden:true} + ,{id:'taxonfr',header: "Taxons déjà saisis", width: 160, sortable: true, locked:false, dataIndex: 'nom_francais',hidden:true} + ,{id:'taxonssc',header: "Taxons déjà saisis", width: 160, sortable: true, locked:false, dataIndex: 'nom_latin',hidden:true} + ,{header: "Abondance", width: 55, sortable: true, dataIndex: 'id_abondance_cflore',hidden:true} + ,{header: "Phénologie", width: 55, sortable: true, dataIndex: 'id_phenologie_cflore',hidden:true} + ,{header: "Validité", width: 25, sortable: true, dataIndex: 'validite_cflore',hidden:true} + ,{header: "Herbier", width: 35, sortable: true, dataIndex: 'herbier',hidden:true} + ,{header: "Commentaire", width: 135, sortable: true, dataIndex: 'commentaire',hidden:true} + ,{header: "Déterminateur", width: 50, sortable: true, dataIndex: 'determinateur',hidden:true} + ,{header: "id_classe", width: 135, sortable: true, dataIndex: 'id_classe',hidden:true} + ,{id:'taxonsaisi',header: "Taxons saisis", width: 160, sortable: true, dataIndex: 'nom_taxon_saisi'} + ,{header: "cd_ref", width: 135, sortable: true, dataIndex: 'cd_ref_origine',hidden:true} + ,{header: "Patrimoniale", width: 50, sortable: true, renderer:isPatri,dataIndex: 'patrimonial',hidden:true} + ,{ + xtype : 'actioncolumn' + ,sortable : false + ,hideable : false + ,menuDisabled : true + ,width:20 + ,items : [{ + tooltip : 'Supprimer ce taxon du pointage' + ,getClass : function(v, meta, record, rowIndex, colIdx, store) { + return 'action-remove'; + } + ,scope : this + ,handler : function(grid, rowIndex, colIndex) { + var record = grid.getStore().getAt(rowIndex); + if(!record.data.id_taxon){ + grid.getStore().remove(record); + if(Ext.getCmp('grid-taxons').getStore().getCount()==0){ + this.addNewTaxon(); + Ext.ux.Toast.msg('Information !', 'Vous avez supprimé tous les taxons de ce pointage.'); + } + else{ + Ext.getCmp('grid-taxons').getSelectionModel().selectRow(0); + Ext.ux.Toast.msg('Annulation !', 'La saisie d\'un nouveau taxon a été annulée.'); + } + } + else{ + Ext.Msg.confirm('Attention' + ,'Etes-vous certain de vouloir supprimer le taxon "'+record.data.nom_francais+'" ?' + ,function(btn) { + if (btn == 'yes') { + grid.getStore().remove(record); + if(Ext.getCmp('grid-taxons').getStore().getCount()==0){ + this.addNewTaxon(); + Ext.ux.Toast.msg('Suppression !', 'Le taxon "'+record.data.nom_francais+'" a été supprimé de ce pointage. Vous avez supprimé tous les taxons de ce pointage.'); + } + else{ + Ext.getCmp('grid-taxons').getSelectionModel().selectRow(0); + Ext.ux.Toast.msg('Suppression !', 'Le taxon "'+record.data.nom_francais+'" a été supprimé de ce pointage.'); + } + } + } + ,this // scope + ); + } + Ext.getCmp('combo-fiche-abondance').setWidth(200);//debug sinon le combo apparait avec une largeur ridicule + Ext.getCmp('combo-fiche-abondance').syncSize();//debug sinon le combo apparait avec une largeur ridicule + } + }] + } + ]); + + var abondancesStore = new Ext.data.JsonStore({ + url: 'bibs/abondancescflore' + ,sortInfo: { + field: 'id_abondance_cflore' + ,direction: 'ASC' + } + ,fields: [ + 'id_abondance_cflore' + ,'nom_abondance_cflore' + ] + ,autoLoad: true + ,synchronous: true + ,listeners: { + load: function(store, records) { + if(Ext.getCmp('grid-taxons').getSelectionModel().getSelected()){ + Ext.getCmp('combo-fiche-abondance').setValue(Ext.getCmp('grid-taxons').getSelectionModel().getSelected().data.id_abondance_cflore); + } + } + } + }); + var phenologiesStore = new Ext.data.JsonStore({ + url: 'bibs/phenologiescflore' + ,sortInfo: { + field: 'id_phenologie_cflore' + ,direction: 'ASC' + } + ,fields: [ + 'id_phenologie_cflore' + ,'nom_phenologie_cflore' + ] + ,autoLoad: true + ,synchronous: true + ,listeners: { + load: function(store, records) { + if(Ext.getCmp('grid-taxons').getSelectionModel().getSelected()){ + Ext.getCmp('combo-fiche-phenologie').setValue(Ext.getCmp('grid-taxons').getSelectionModel().getSelected().data.id_phenologie_cflore); + } + } + } + }); + + myProxyTaxons = new Ext.data.HttpProxy({ + id:'store-taxon-proxy' + ,url: 'bibs/taxonscflore' + ,method: 'GET' + }); + var comboTaxonsFiltre = function(){ + var orange = Ext.getCmp('cb-orange-cf').getValue(); + var red = Ext.getCmp('cb-red-cf').getValue(); + var gray = Ext.getCmp('cb-gray-cf').getValue(); + var patri = Ext.getCmp('cb-patri-cf').getValue(); + + Ext.getCmp('combo-fiche-taxon').getStore().filterBy(function(record,id){ + var recColor = record.data.couleur; + var statutPatri = record.data.patrimonial; + var id_classe = record.data.id_classe; + if(!patri){ + if(recColor == 'orange' && orange && comboTaxonsFiltreClasse(id_classe)){return true;} + if(recColor == 'red' && red && comboTaxonsFiltreClasse(id_classe)){return true;} + if(recColor == 'gray' && gray && comboTaxonsFiltreClasse(id_classe)){return true;} + } + if(patri){ + if(recColor == 'orange' && orange && statutPatri && comboTaxonsFiltreClasse(id_classe)){return true;} + if(recColor == 'red' && red && statutPatri && comboTaxonsFiltreClasse(id_classe)){return true;} + if(recColor == 'gray' && gray && statutPatri && comboTaxonsFiltreClasse(id_classe)){return true;} + } + return false; + }); + }; + var comboTaxonsFiltreClasse = function(classe){ + var pteridophytes = Ext.getCmp('cb-pteridophytes-cf').getValue(); + var monocotyledones = Ext.getCmp('cb-monocotyledones-cf').getValue(); + var dicotyledones = Ext.getCmp('cb-dicotyledones-cf').getValue(); + var bryophytes = Ext.getCmp('cb-bryophytes-cf').getValue(); + if((!pteridophytes&&!monocotyledones&&!dicotyledones&&!bryophytes)==true){return true;} + if(dicotyledones && classe==id_classe_dicotyledones){return true;} + if(monocotyledones && classe==id_classe_monocotyledones){return true;} + if(pteridophytes && classe==id_classe_pteridophytes){return true;} + if(bryophytes && classe==id_classe_bryophytes){return true;} + return false; + }; + + /*** SOLUTION ATOL ***/ + var comboTaxonsTemplate = function(langue) { + var dataIndex = (langue == 'latin'?'nom_latin':'nom_francais'); + var comboFicheTaxon = Ext.getCmp('combo-fiche-taxon'); + comboFicheTaxon.getStore().sort(dataIndex); + var monTpl = new Ext.XTemplate( + ''+ + '
'+ + ' '+ + ' '+ + ' '+ + ' {'+dataIndex+'}({nb_obs}) - {derniere_date}'+ + '
'+ + '
'); + if(Ext.isDefined(comboFicheTaxon.view)){ + comboFicheTaxon.view.tpl = monTpl; + comboFicheTaxon.view.refresh(); + } + }; + + var isValidForm = function(){ + var isValid = true; + Ext.getCmp('grid-taxons').getStore().each(function(r){ + if(r.data.id_taxon==0 || r.data.id_taxon==null){isValid = false;return false;} + if(r.data.nom_taxon_saisi=='Saisie en cours'){isValid = false;return false;} + if(r.data.id_abondance_cflore==0 || r.data.id_abondance_cflore==null){isValid = false;return false;} + if(r.data.id_phenologie_cflore==0 || r.data.id_phenologie_cflore==null){isValid = false;return false;} + return true; + }); + return isValid; + }; + var isValidTaxon = function(r){ + var isValid = true; + errorMsg = ''; + if(r.data.id_taxon==0 || r.data.id_taxon==null){isValid = false;errorMsg='Veuillez choisir un taxon';return false;} + if(r.data.id_abondance_cflore==0 || r.data.id_abondance_cflore==null){isValid = false;errorMsg='Veuillez définir l\'abondance pour ce taxon';return false;} + if(r.data.id_phenologie_cflore==0 || r.data.id_phenologie_cflore==null){isValid = false;errorMsg='Veuillez définir la phénologie de ce taxon';return false;} + var commentValue = Ext.getCmp('ta-fiche-commentaire').getValue(); + if(Ext.getCmp('cb-herbier').getValue() && (commentValue == null || commentValue == '')){isValid = false;errorMsg='Un commentaire est obligatoire en cas de mise en herbier';return false;} + return isValid; + }; + var manageValidationTaxon = function(isValid){ + if(isValid){ + Ext.getCmp('grid-taxons').enable(); + Ext.getCmp('bt-validtaxon').enable(); + Ext.getCmp('bt-validtaxon').setIconClass('validate'); + Ext.getCmp('bt-validtaxon').setText('Valider "' + returnTaxonSaisi() +'"'); + } + else{ + if(!Ext.getCmp('grid-taxons').getSelectionModel().hasNext() && Ext.getCmp('grid-taxons').getSelectionModel().getSelected().data.id_taxon==null){ + Ext.getCmp('grid-taxons').enable(); + } + else{Ext.getCmp('grid-taxons').disable();} + Ext.getCmp('bt-validtaxon').disable(); + Ext.getCmp('bt-validtaxon').setIconClass('unvalidate'); + Ext.getCmp('bt-validtaxon').setText('Terminer la saisie pour valider'); + Ext.getCmp('grid-taxons').getSelectionModel().getSelected().set('nom_taxon_saisi','Saisie en cours'); + } + Ext.getCmp('error-message').setText(errorMsg); + manageValidationForm(isValidForm()) + }; + var manageValidationForm = function(isValid){ + if(isValid){ + Ext.getCmp('ficheSaveButton').enable(); + Ext.getCmp('bt-addtaxon').enable(); + } + else{ + Ext.getCmp('ficheSaveButton').disable(); + Ext.getCmp('bt-addtaxon').disable(); + } + + }; + + this.addNewTaxon = function(){ + Ext.getCmp('edit-fiche-form').getForm().findField('monactiontaxon').setValue('add'); + relevesStore.add(new blankRecord({ + //attention l'ordre des champs est important + id_releve_cflore:null + ,id_taxon:null + ,nom_francais:'' + ,nom_latin:'' + ,nom_taxon_saisi:'Saisie en cours' + ,id_abondance_cflore:null + ,id_phenologie_cflore:null + ,validite_cflore:default_validite_cflore + ,commentaire:'' + ,determinateur:'' + ,cd_ref_origine:null + ,id_classe:null + ,herbier:false + ,patrimonial:false + })); + Ext.getCmp('fieldset-abondance').collapse(); + Ext.getCmp('fieldset-phenologie').collapse(); + Ext.getCmp('fieldset-validite').collapse(); + Ext.getCmp('fieldset-herbier').collapse(); + Ext.getCmp('fieldset-commentaire').collapse(); + Ext.getCmp('fieldset-determinateur').collapse(); + Ext.getCmp('grid-taxons').getSelectionModel().selectLastRow(false); + manageValidationTaxon(false); + }; + var returnTaxonSaisi = function(){ + var r = null; + if(Ext.getCmp('combo-fiche-taxon').findRecord('id_taxon',Ext.getCmp('combo-fiche-taxon').getValue())){r = Ext.getCmp('combo-fiche-taxon').findRecord('id_taxon',Ext.getCmp('combo-fiche-taxon').getValue())}; + if(Ext.getCmp('radiogroup-langue-cf').getValue().inputValue=='fr'){ + if(r){return r.data.nom_francais;} + else{return 'en cours';} + } + if(Ext.getCmp('radiogroup-langue-cf').getValue().inputValue=='latin'){ + if(r){return r.data.nom_latin;} + else{return 'en cours';} + } + }; + + if(application.cflore.user.statuscode >= 2){ + var validTaxonButton = new Ext.Button({ + id:'bt-validtaxon' + ,iconCls: 'unvalidate' + ,text: 'Terminer la saisie pour valider' + ,disabled: true + ,handler: function() { + Ext.getCmp('grid-taxons').getSelectionModel().getSelected().set('nom_taxon_saisi',returnTaxonSaisi()); + manageValidationForm(isValidForm()); + } + ,scope: this + }); + } + if(application.cflore.user.statuscode >= 2){ + var addTaxonButton = new Ext.Button({ + id:'bt-addtaxon' + ,iconCls: 'add' + ,text: 'Ajouter un taxon sur ce pointage' + ,disabled: true + ,handler: function() { + this.addNewTaxon(); + Ext.getCmp('combo-fiche-taxon').focus(); + } + ,scope: this + }); + } + + storeTaxonsCf = new Ext.data.JsonStore({ + url: myProxyTaxons + ,fields: [ + 'id_taxon' + ,'cd_ref' + ,'nom_latin' + ,{name:'nom_francais',sortType: Ext.data.SortTypes.asAccentuatedString} + ,'id_classe' + ,'patrimonial' + ,'message' + ,'couleur' + ,'nb_obs' + ,'derniere_date' + ] + ,sortInfo: { + field: 'nom_francais' + ,direction: 'ASC' + } + ,autoLoad:true + ,listeners: { + load: function(store, records) { + if(Ext.getCmp('grid-taxons').getSelectionModel().getSelected()){ + Ext.getCmp('combo-fiche-taxon').setValue(Ext.getCmp('grid-taxons').getSelectionModel().getSelected().data.id_taxon); + } + comboTaxonsFiltre(); + } + } + }); + + + /* + * création du formulaire taxon + */ + var gridForm = new Ext.Panel({ + id: 'taxons-form' + ,frame: true + ,labelAlign: 'left' + ,title: 'Listes des taxons observés' + ,bodyStyle:'padding:5px' + ,width: 600 + ,layout: 'column' // Specifies that the items will now be arranged in columns + ,items: [{ + columnWidth: 0.6 + ,xtype: 'panel' + ,labelWidth: 80 + ,defaults: { + width: 305 + ,border:false + ,allowDecimals :false + ,allowNegative: false + } + ,defaultType: 'numberfield' + ,autoHeight: true + ,bodyStyle: Ext.isIE ? 'padding:0 0 5px 5px;' : 'padding:5px 5px;' + ,border: false + ,style: { + "margin-left": "5px", // when you add custom margin in IE 6... + "margin-right": Ext.isIE6 ? (Ext.isStrict ? "-10px" : "-13px") : "0" // you have to adjust for it somewhere else + } + ,items: [ + { + xtype:'fieldset' + ,id:'fieldset-taxons' + ,columnWidth: 1 + ,title: 'Choix du taxon observé' + ,collapsible: true + ,autoHeight:true + ,anchor:'100%' + ,items :[ + { + id:'radiogroup-langue-cf' + ,xtype: 'radiogroup' + ,fieldLabel: 'Langue' + ,defaultType: 'radio' + ,cls:'graytext' + ,itemCls:'graytext' + ,items: [{ + boxLabel: 'français' + ,name: 'langue' + ,itemCls:'graytext' + ,inputValue: 'fr' + ,checked: true + ,listeners: { + check: function(checkbox,checked) { + if(checked){ + comboTaxonsTemplate('fr'); + Ext.getCmp('combo-fiche-taxon').displayField = 'nom_francais'; + Ext.getCmp('combo-fiche-taxon').setValue(Ext.getCmp('combo-fiche-taxon').getValue());//pas trouvé mieux pour rafraichier en live le taxon déjà affiché dans le combo + } + } + } + },{ + boxLabel: 'latin' + ,name: 'langue' + ,itemCls:'graytext' + ,inputValue: 'latin' + ,listeners: { + check: function(checkbox,checked) { + if(checked){comboTaxonsTemplate('latin'); + Ext.getCmp('combo-fiche-taxon').displayField = 'nom_latin' + Ext.getCmp('combo-fiche-taxon').setValue(Ext.getCmp('combo-fiche-taxon').getValue());//pas trouvé mieux pour rafraichier en live le taxon déjà affiché dans le combo + } + } + } + } + ] + },{ + id:'checkboxgroup-classe-cf' + ,xtype: 'checkboxgroup' + ,fieldLabel: 'Groupe taxonomique' + ,cls:'graytext' + ,itemCls:'graytext' + ,columns: 2 + ,items: [{ + id:'cb-monocotyledones-cf' + ,boxLabel: 'Monocotylédones' + ,name: 'cb-monocotyledones' + ,itemCls:'graytext' + ,checked: false + ,listeners: { + check: function(checkbox,checked){ + if(checked){ + Ext.getCmp('cb-dicotyledones-cf').setValue(false); + Ext.getCmp('cb-pteridophytes-cf').setValue(false); + Ext.getCmp('cb-bryophytes-cf').setValue(false); + } + if(Ext.getCmp('combo-fiche-taxon')){Ext.getCmp('combo-fiche-taxon').clearValue();} + comboTaxonsFiltre(); + } + ,render: function(c) { + Ext.QuickTips.register({ + target: c.getEl(), + text: 'Affiche les monocotylédones dans la liste si la case est cochée.' + }); + } + } + },{ + id:'cb-dicotyledones-cf' + ,boxLabel: 'Dicotylédones' + ,name: 'cb-dicotyledones' + ,itemCls:'graytext' + ,checked: false + ,listeners: { + check: function(checkbox,checked) { + if(checked){ + Ext.getCmp('cb-monocotyledones-cf').setValue(false); + Ext.getCmp('cb-pteridophytes-cf').setValue(false); + Ext.getCmp('cb-bryophytes-cf').setValue(false); + } + if(Ext.getCmp('combo-fiche-taxon')){Ext.getCmp('combo-fiche-taxon').clearValue();} + comboTaxonsFiltre(); + } + ,render: function(c) { + Ext.QuickTips.register({ + target: c.getEl(), + text: 'Affiche les dicotylédones dans la liste si la case est cochée.' + }); + } + } + },{ + id:'cb-pteridophytes-cf' + ,boxLabel: 'Ptéridophytes' + ,name: 'cb-pteridophytes' + ,itemCls:'graytext' + ,checked: false + ,listeners: { + check: function(checkbox,checked) { + if(checked){ + Ext.getCmp('cb-monocotyledones-cf').setValue(false); + Ext.getCmp('cb-dicotyledones-cf').setValue(false); + Ext.getCmp('cb-bryophytes-cf').setValue(false); + } + if(Ext.getCmp('combo-fiche-taxon')){Ext.getCmp('combo-fiche-taxon').clearValue();} + comboTaxonsFiltre(); + } + ,render: function(c) { + Ext.QuickTips.register({ + target: c.getEl(), + text: 'Affiche les ptéridophytes dans la liste si la case est cochée.' + }); + } + } + },{ + id:'cb-bryophytes-cf' + ,boxLabel: 'Bryophytes' + ,name: 'cb-bryophytes' + ,itemCls:'graytext' + ,checked: false + ,listeners: { + check: function(checkbox,checked) { + if(checked){ + Ext.getCmp('cb-monocotyledones-cf').setValue(false); + Ext.getCmp('cb-dicotyledones-cf').setValue(false); + Ext.getCmp('cb-pteridophytes-cf').setValue(false); + } + if(Ext.getCmp('combo-fiche-taxon')){Ext.getCmp('combo-fiche-taxon').clearValue();} + comboTaxonsFiltre(); + } + ,render: function(c) { + Ext.QuickTips.register({ + target: c.getEl(), + text: 'Affiche les bryophytes dans la liste si la case est cochée.' + }); + } + } + } + ] + },{ + id:'checkboxgroup-patri-cf' + ,xtype: 'checkboxgroup' + ,fieldLabel: 'Patrimonialité' + ,itemCls:'graytext' + ,items: [{ + id:'cb-patri-cf' + ,boxLabel: ' Patrimoniaux seulement' + ,name: 'cb-patri' + ,checked: false + ,cls:'graytext' + ,itemCls:'graytext' + ,listeners: { + check: function(checkbox,checked) { + comboTaxonsFiltre(); + if(Ext.getCmp('combo-fiche-taxon')){Ext.getCmp('combo-fiche-taxon').clearValue();} + } + ,render: function(c) { + Ext.QuickTips.register({ + target: c.getEl(), + text: 'Filtrer la liste avec uniquement les taxons patrimoniaux.' + }); + } + } + } + ] + },{ + id:'checkboxgroup-couleur-cf' + ,xtype: 'checkboxgroup' + ,fieldLabel: 'A rechercher' + ,cls:'graytext' + ,itemCls:'graytext' + ,items: [{ + id:'cb-red-cf' + ,boxLabel: 'Priorité' + ,name: 'cb-red' + ,itemCls:'redtext' + ,checked: true + ,listeners: { + check: function(checkbox,checked) { + comboTaxonsFiltre(); + if(Ext.getCmp('combo-fiche-taxon')){Ext.getCmp('combo-fiche-taxon').clearValue();} + } + ,render: function(c) { + Ext.QuickTips.register({ + target: c.getEl(), + text: 'Taxons à saisir ou rechercher dans cette unité géographique.' + }); + } + } + },{ + id:'cb-orange-cf' + ,boxLabel: 'Nouveau' + ,name: 'cb-orange' + ,itemCls:'orangetext' + ,checked: true + ,listeners: { + check: function(checkbox,checked) { + comboTaxonsFiltre(); + if(Ext.getCmp('combo-fiche-taxon')){Ext.getCmp('combo-fiche-taxon').clearValue();} + } + ,render: function(c) { + Ext.QuickTips.register({ + target: c.getEl(), + text: 'Taxons jamais observés dans dans cette unité géographique.' + }); + } + } + },{ + id:'cb-gray-cf' + ,boxLabel: 'Facultatif' + ,name: 'cb-gray' + ,itemCls:'graytext' + ,checked: true + ,listeners: { + check: function(checkbox,checked) { + comboTaxonsFiltre(); + if(Ext.getCmp('combo-fiche-taxon')){Ext.getCmp('combo-fiche-taxon').clearValue();} + } + ,render: function(c) { + Ext.QuickTips.register({ + target: c.getEl(), + text: 'La saisie est facultative pour ces taxons dans cette unité géographique.' + }); + } + } + } + ] + ,listeners: { + afterrender: function(checkboxg) { + comboTaxonsFiltre(); + } + } + },{ + xtype: 'line' + },{ + id:'combo-fiche-taxon' + ,xtype:'twintriggercombo' + ,tpl: '
{nom_francais} ({nb_obs}) - {derniere_date}
' + ,fieldLabel: 'Taxon ' + ,name: 'id_taxon' + ,hiddenName:"id_taxon" + ,store: storeTaxonsCf + ,valueField: "id_taxon" + ,displayField: "nom_francais" + ,allowBlank:false + ,typeAhead: true + ,typeAheadDelay:750 + ,forceSelection: true + ,selectOnFocus: true + ,editable: true + ,resizable:true + ,listWidth: 300 + ,triggerAction: 'all' + ,trigger3Class: 'x-form-zoomto-trigger x-hidden' + ,mode: 'local' + ,listeners: { + select: function(combo, record) { + Ext.getCmp('grid-taxons').getSelectionModel().getSelected().set('nom_francais',record.data.nom_francais); + Ext.getCmp('grid-taxons').getSelectionModel().getSelected().set('nom_latin',record.data.nom_latin); + Ext.getCmp('grid-taxons').getSelectionModel().getSelected().set('id_taxon',combo.getValue()); + Ext.getCmp('grid-taxons').getSelectionModel().getSelected().set('id_classe',record.data.id_classe); + Ext.getCmp('grid-taxons').getSelectionModel().getSelected().set('denombrement',record.data.denombrement); + Ext.getCmp('grid-taxons').getSelectionModel().getSelected().set('patrimonial',record.data.patrimonial); + Ext.getCmp('grid-taxons').getSelectionModel().getSelected().set('cd_ref_origine',record.data.cd_ref); + Ext.getCmp('grid-taxons').getSelectionModel().getSelected().set('nom_taxon_saisi','Saisie en cours'); + Ext.getCmp('grid-taxons').getSelectionModel().getSelected().set('id_abondance_cflore',null); + Ext.getCmp('combo-fiche-abondance').clearValue(); + Ext.getCmp('grid-taxons').getSelectionModel().getSelected().set('id_phenologie_cflore',null); + Ext.getCmp('combo-fiche-phenologie').clearValue(); + Ext.getCmp('grid-taxons').getSelectionModel().getSelected().set('validite_cflore',default_validite_cflore); + Ext.getCmp('cb-validite').setValue(default_validite_cflore); + Ext.getCmp('grid-taxons').getSelectionModel().getSelected().set('herbier',false); + Ext.getCmp('cb-herbier').setValue(false); + Ext.getCmp('ta-fiche-commentaire').setValue(''); + Ext.getCmp('grid-taxons').getSelectionModel().getSelected().set('commentaire',null); + Ext.getCmp('ta-fiche-determinateur').setValue(''); + Ext.getCmp('grid-taxons').getSelectionModel().getSelected().set('determinateur',null); + manageValidationTaxon(isValidTaxon(record));//puisque le critère est obligatoire et qu'on vient de le vider + Ext.getCmp('fieldset-abondance').expand(); + Ext.getCmp('combo-fiche-abondance').setWidth(200);//debug sinon le combo apparait avec une largeur ridicule + Ext.getCmp('combo-fiche-abondance').syncSize();//debug sinon le combo apparait avec une largeur ridicule + } + ,change: function(combo, record) { + Ext.getCmp('combo-fiche-abondance').clearValue(); + if(record.data){ + manageValidationTaxon(isValidTaxon(record)); + } + } + ,afterrender: function(combo, record) { + comboTaxonsFiltre(); + combo.keyNav.tab = function() { // Override TAB handling function + this.onViewClick(false); // Select the currently highlighted row + }; + } + ,clear: function(combo, record) { + Ext.getCmp('grid-taxons').getSelectionModel().getSelected().set('nom_francais',null); + Ext.getCmp('grid-taxons').getSelectionModel().getSelected().set('nom_latin',null); + Ext.getCmp('grid-taxons').getSelectionModel().getSelected().set('id_taxon',null); + Ext.getCmp('grid-taxons').getSelectionModel().getSelected().set('id_classe',null); + Ext.getCmp('grid-taxons').getSelectionModel().getSelected().set('patrimonial',false); + Ext.getCmp('grid-taxons').getSelectionModel().getSelected().set('cd_ref_origine',null); + Ext.getCmp('grid-taxons').getSelectionModel().getSelected().set('nom_taxon_saisi','Saisie en cours'); + Ext.getCmp('combo-fiche-abondance').clearValue(); + Ext.getCmp('grid-taxons').getSelectionModel().getSelected().set('id_abondance_cflore',null); + Ext.getCmp('combo-fiche-phenologie').clearValue(); + Ext.getCmp('grid-taxons').getSelectionModel().getSelected().set('id_phenologie_cflore',null); + Ext.getCmp('cb-validite').setValue(default_validite_cflore); + Ext.getCmp('grid-taxons').getSelectionModel().getSelected().set('validite_cflore',default_validite_cflore); + Ext.getCmp('grid-taxons').getSelectionModel().getSelected().set('herbier',false); + Ext.getCmp('cb-herbier').setValue(false); + Ext.getCmp('ta-fiche-commentaire').setValue(''); + Ext.getCmp('grid-taxons').getSelectionModel().getSelected().set('commentaire',null); + Ext.getCmp('ta-fiche-determinateur').setValue(''); + Ext.getCmp('grid-taxons').getSelectionModel().getSelected().set('determinateur',null); + Ext.getCmp('fieldset-abondance').collapse(); + Ext.getCmp('fieldset-phenologie').collapse(); + Ext.getCmp('fieldset-validite').collapse(); + Ext.getCmp('fieldset-herbier').collapse(); + Ext.getCmp('fieldset-commentaire').collapse(); + Ext.getCmp('fieldset-determinateur').collapse(); + manageValidationTaxon(isValidTaxon(Ext.getCmp('grid-taxons').getSelectionModel().getSelected())); + } + } + } + ] + },{ + xtype:'fieldset' + ,id:'fieldset-abondance' + ,columnWidth: 1 + ,title: 'Définir l\'abondance' + ,collapsible: true + ,collapsed: true + ,autoHeight:true + ,anchor:'100%' + ,items :[ + { + id:'combo-fiche-abondance' + ,xtype:'twintriggercombo' + ,fieldLabel: 'Abondance ' + ,name: 'id_abondance_cflore' + ,hiddenName:"id_abondance_cflore" + ,store: abondancesStore + ,valueField: "id_abondance_cflore" + ,displayField: "nom_abondance_cflore" + ,allowBlank:false + ,typeAhead: true + ,forceSelection: true + ,selectOnFocus: true + ,editable: true + ,resizable:true + ,listWidth: 300 + ,typeAheadDelay:750 + ,triggerAction: 'all' + ,trigger3Class: 'x-form-zoomto-trigger x-hidden' + ,mode: 'local' + ,listeners: { + select: function(combo, record) { + Ext.getCmp('grid-taxons').getSelectionModel().getSelected().set('id_abondance_cflore',combo.getValue()); + Ext.getCmp('fieldset-phenologie').expand(); + Ext.getCmp('combo-fiche-phenologie').setWidth(200);//debug sinon le combo apparait avec une largeur ridicule + Ext.getCmp('combo-fiche-phenologie').syncSize();//debug sinon le combo apparait avec une largeur ridicule + manageValidationTaxon(isValidTaxon(Ext.getCmp('grid-taxons').getSelectionModel().getSelected())); + } + ,change: function(combo, record) { + manageValidationTaxon(isValidTaxon(Ext.getCmp('grid-taxons').getSelectionModel().getSelected())); + } + ,clear: function(combo, record) { + manageValidationTaxon(isValidTaxon(Ext.getCmp('grid-taxons').getSelectionModel().getSelected())); + } + ,afterrender: function(combo, record) { + combo.keyNav.tab = function() { // Override TAB handling function + this.onViewClick(false); // Select the currently highlighted row + }; + } + } + } + ] + },{ + xtype:'fieldset' + ,id:'fieldset-phenologie' + ,columnWidth: 1 + ,title: 'Définir la phénologie' + ,collapsible: true + ,collapsed: true + ,autoHeight:true + ,anchor:'100%' + ,items :[ + { + id:'combo-fiche-phenologie' + ,xtype:'twintriggercombo' + ,fieldLabel: 'Phénologie ' + ,name: 'id_phenologie_cflore' + ,hiddenName:"id_phenologie_cflore" + ,store: phenologiesStore + ,valueField: "id_phenologie_cflore" + ,displayField: "nom_phenologie_cflore" + ,allowBlank:false + ,typeAhead: true + ,forceSelection: true + ,selectOnFocus: true + ,editable: true + ,resizable:true + ,listWidth: 300 + ,typeAheadDelay:750 + ,triggerAction: 'all' + ,trigger3Class: 'x-form-zoomto-trigger x-hidden' + ,mode: 'local' + ,listeners: { + select: function(combo, record) { + Ext.getCmp('grid-taxons').getSelectionModel().getSelected().set('id_phenologie_cflore',combo.getValue()); + Ext.getCmp('fieldset-validite').expand(); + manageValidationTaxon(isValidTaxon(Ext.getCmp('grid-taxons').getSelectionModel().getSelected())); + } + ,change: function(combo, record) { + manageValidationTaxon(isValidTaxon(Ext.getCmp('grid-taxons').getSelectionModel().getSelected())); + } + ,clear: function(combo, record) { + manageValidationTaxon(isValidTaxon(Ext.getCmp('grid-taxons').getSelectionModel().getSelected())); + } + ,afterrender: function(combo, record) { + combo.keyNav.tab = function() { // Override TAB handling function + this.onViewClick(false); // Select the currently highlighted row + }; + } + } + } + ] + },{ + xtype:'fieldset' + ,id:'fieldset-validite' + ,columnWidth: 1 + ,title: 'Définir la validité' + ,collapsible: true + ,collapsed: true + ,hidden:!(application.cflore.user.statuscode >= 5 && use_validite_cflore) + ,autoHeight:true + ,anchor:'100%' + ,items :[ + { + id:'cb-validite' + ,xtype:'checkbox' + ,fieldLabel: label_validite + ,name: 'validite_cflore' + ,inputValue: true + ,checked: false + ,listeners: { + check: function(checkbox,checked) { + if(checked){ + Ext.getCmp('grid-taxons').getSelectionModel().getSelected().set('validite_cflore',true); + } + else{ + Ext.getCmp('grid-taxons').getSelectionModel().getSelected().set('validite_cflore',false); + } + Ext.getCmp('fieldset-herbier').expand(); + manageValidationTaxon(isValidTaxon(Ext.getCmp('grid-taxons').getSelectionModel().getSelected())); + } + ,render: function(c) { + Ext.QuickTips.register({ + target: c.getEl(), + text: tooltip_validite + }); + } + } + } + ] + },{ + xtype:'fieldset' + ,id:'fieldset-herbier' + ,columnWidth: 1 + ,title: 'Mise en herbier' + ,collapsible: true + ,collapsed: true + ,autoHeight:true + ,anchor:'100%' + ,items :[{ + id:'cb-herbier' + ,xtype:'checkbox' + ,fieldLabel: 'Mise en herbier' + ,name: 'herbier' + ,inputValue: true + ,checked: false + ,listeners: { + check: function(checkbox,checked) { + if(checked){ + Ext.getCmp('grid-taxons').getSelectionModel().getSelected().set('herbier',true); + var commentValue = Ext.getCmp('ta-fiche-commentaire').getValue(); + if(commentValue == null || commentValue == ''){ + Ext.getCmp('ta-fiche-commentaire').markInvalid('En cas de mise en herbier, un commentaire est obligatoire.'); + } + } + else{ + Ext.getCmp('grid-taxons').getSelectionModel().getSelected().set('herbier',false); + Ext.getCmp('ta-fiche-commentaire').validate(); + } + Ext.getCmp('fieldset-commentaire').expand(); + manageValidationTaxon(isValidTaxon(Ext.getCmp('grid-taxons').getSelectionModel().getSelected())); + } + ,render: function(c) { + Ext.QuickTips.register({ + target: c.getEl(), + text: 'Cochez si vous avez prélevé la plante ou une partie de la plante pour mise en herbier.' + }); + } + } + }] + },{ + xtype:'fieldset' + ,id:'fieldset-commentaire' + ,columnWidth: 1 + ,title: 'Commentaire concernant le taxon (facultatif)' + ,collapsible: true + ,collapsed: true + ,autoHeight:true + ,anchor:'100%' + ,items :[{ + id:'ta-fiche-commentaire' + ,xtype: 'textarea' + ,fieldLabel: 'Commentaire ' + ,name: 'commentaire' + ,grow:true + ,autoHeight: true + ,height:'auto' + ,anchor:'100%' + ,enableKeyEvents:true + ,listeners: { + render: function(c) { + Ext.QuickTips.register({ + target: c.getEl(), + text: 'Indiquer ici un éventuel commentaire concernant ce taxon.' + }); + } + ,keyup: function(field) { + Ext.getCmp('grid-taxons').getSelectionModel().getSelected().set('commentaire',field.getValue()); + manageValidationTaxon(isValidTaxon(Ext.getCmp('grid-taxons').getSelectionModel().getSelected())); + } + } + } + ] + },{ + xtype:'fieldset' + ,id:'fieldset-determinateur' + ,columnWidth: 1 + ,title: 'Déterminateur du taxon (facultatif)' + ,collapsible: true + ,collapsed: true + ,autoHeight:true + ,anchor:'100%' + ,items :[{ + id:'ta-fiche-determinateur' + ,xtype: 'textarea' + ,fieldLabel: 'Déterminateur ' + ,name: 'determinateur' + ,grow:true + ,autoHeight: true + ,height:'auto' + ,anchor:'100%' + ,enableKeyEvents:true + ,listeners: { + render: function(c) { + Ext.QuickTips.register({ + target: c.getEl(), + text: 'Indiquer ici le determinateur de ce taxon.' + }); + } + ,keyup: function(field) {Ext.getCmp('grid-taxons').getSelectionModel().getSelected().set('determinateur',field.getValue());} + } + } + ] + } + ,validTaxonButton + ,{xtype: 'label',id: 'error-message',cls: 'errormsg',text:''} + ,addTaxonButton + ,{ + xtype:'hidden' + ,name: 'monactiontaxon' + ,value:'update' + },{ + xtype:'hidden' + ,name: 'cd_ref_origine' + },{ + xtype:'hidden' + ,name: 'nom_taxon_saisi' + } + ] + },{ + columnWidth: 0.4 + ,layout: 'fit' + ,items:[{ + xtype: 'grid' + ,id:'grid-taxons' + ,store: relevesStore + ,cm: colModel + ,stripeRows: true + ,sm: new Ext.grid.RowSelectionModel({ + singleSelect: true + ,listeners: { + rowselect: function(sm, row, rec) { + Ext.getCmp('edit-fiche-form').getForm().loadRecord(rec); + if(rec.data.nom_taxon_saisi=='Saisie en cours'){ + if(Ext.getCmp('combo-fiche-taxon').getValue()==null){ + Ext.getCmp('fieldset-abondance').collapse(); + Ext.getCmp('fieldset-phenologie').collapse(); + Ext.getCmp('fieldset-validite').collapse(); + Ext.getCmp('fieldset-herbier').collapse(); + Ext.getCmp('fieldset-commentaire').collapse(); + Ext.getCmp('fieldset-determinateur').collapse(); + } + else{Ext.getCmp('fieldset-abondance').expand();} + if(Ext.getCmp('combo-fiche-abondance').getValue()==null){ + Ext.getCmp('fieldset-phenologie').collapse(); + Ext.getCmp('fieldset-validite').collapse(); + Ext.getCmp('fieldset-herbier').collapse(); + Ext.getCmp('fieldset-commentaire').collapse(); + Ext.getCmp('fieldset-determinateur').collapse(); + } + else{ + Ext.getCmp('fieldset-phenologie').expand(); + Ext.getCmp('fieldset-validite').expand(); + if(Ext.getCmp('cb-herbier').getValue()==false){Ext.getCmp('fieldset-herbier').collapse();} + else{Ext.getCmp('fieldset-herbier').expand();} + if(Ext.getCmp('ta-fiche-commentaire').getValue()==''){Ext.getCmp('fieldset-commentaire').collapse();} + else{Ext.getCmp('fieldset-commentaire').expand();} + if(Ext.getCmp('ta-fiche-determinateur').getValue()==''){Ext.getCmp('fieldset-determinateur').collapse();} + else{Ext.getCmp('fieldset-determinateur').expand();} + } + } + else{ + Ext.getCmp('fieldset-abondance').expand(); + Ext.getCmp('fieldset-phenologie').expand(); + Ext.getCmp('fieldset-validite').expand(); + if(Ext.getCmp('cb-herbier').getValue()==false){Ext.getCmp('fieldset-herbier').collapse();} + else{Ext.getCmp('fieldset-herbier').expand();} + if(Ext.getCmp('ta-fiche-commentaire').getValue()==''){Ext.getCmp('fieldset-commentaire').collapse();} + else{Ext.getCmp('fieldset-commentaire').expand();} + if(Ext.getCmp('ta-fiche-determinateur').getValue()==''){Ext.getCmp('fieldset-determinateur').collapse();} + else{Ext.getCmp('fieldset-determinateur').expand();} + } + } + ,selectionchange: function(sm) { + if(Ext.getCmp('edit-fiche-form').getForm().findField('monactiontaxon').getValue()=='add'){ + Ext.getCmp('edit-fiche-form').getForm().findField('monactiontaxon').setValue('update'); + } + if(sm.getSelected()){manageValidationTaxon(isValidTaxon(sm.getSelected()));} + + } + } + }) + ,viewConfig: { + // Return CSS class to apply to rows depending upon data values + getRowClass: function(r, index) { + var patri = r.get('patrimonial'); + if(patri){return 'gras';} + } + } + ,autoExpandColumn: 'taxonsaisi' + ,height: 350 + ,border: true + ,listeners: { + viewready: function(g) { + g.getSelectionModel().selectRow(0); + } // Allow rows to be rendered. + } + } + ] + }//fin du collum2 + ]//fin du item + ,listeners: { + afterlayout: function(g) { + Ext.getCmp('grid-taxons').getSelectionModel().selectRow(0); + } + } + });//fin du gridForm + return [gridForm]; + };//Fin du getFormTaxons + + /** + * Method: createLayer + * Creates the vector layer + * + * Return + * + */ + var createLayer = function() { + var styleMap = new OpenLayers.StyleMap({ + 'default': { + fillColor: "red" + ,strokeColor: "#ff6666" + ,cursor: "pointer" + ,fillOpacity: 0.7 + ,strokeOpacity: 1 + ,strokeWidth: 2 + ,pointRadius: 7 + } + ,select : { + fillColor: "blue" + ,strokeColor: "blue" + ,cursor: "pointer" + ,fillOpacity: 0.5 + ,strokeOpacity: 1 + ,strokeWidth: 3 + ,pointRadius: 8 + } + }); + vectorLayer = new OpenLayers.Layer.Vector("editFiche vector layer" + ,{ + protocol: eventProtocol + ,strategies: [ + new mapfish.Strategy.ProtocolListener() + ] + ,styleMap: styleMap + ,format: OpenLayers.Format.GeoJSON + } + ); + vectorLayer.events.on({ + featureadded: function(obj) { + var feature = obj.feature; + if(map.getZoom()<15){ + vectorLayer.removeFeatures(feature); + zoomin.activate();// on active le bouton pour zoomer + Ext.ux.Toast.msg('Echelle de saisie inadaptée', 'Vous ne pouvez pas pointer à cette échelle.
Merci de zoomer jusqu\'à la carte au 1/25 000ème.'); + return false; //la fonction s'arrête là + } + if(vectorLayer.features[1]){vectorLayer.removeFeatures(vectorLayer.features[0])};//s'il y a déjà une géométrie, on la supprime pour ne garder que celle qui vient d'être ajoutée + updateGeometryField(feature); + Ext.getCmp('edit-fiche-form').enable(); + Ext.getCmp('edit-fiche-form').ownerCt.ownerCt.doLayout(); + Ext.getCmp('edit-fiche-form').getForm().findField('ids_observateurs').setValue(Ext.getCmp('combo-fiche-observateurs').getValue()); + myProxyTaxons.url = 'bibs/taxonscfloreu?point='+Ext.getCmp('edit-fiche-form').getForm().findField('geometry').getValue(); + Ext.getCmp('combo-fiche-taxon').getStore().reload(); + application.cflore.editFiche.findZ(feature); + } + ,featuremodified: function(obj) { + updateGeometryField(obj.feature); + myProxyTaxons.url = 'bibs/taxonscfloreu?point='+Ext.getCmp('edit-fiche-form').getForm().findField('geometry').getValue(); + Ext.getCmp('combo-fiche-taxon').getStore().reload(); + } + ,featureremoved: function(obj) { + updateGeometryField(null); + Ext.getCmp('edit-fiche-form').disable(); + } + }); + }; + + /** + * Method: createMap + * Creates the map + * + * Return + * + */ + var createMap = function() { + map = application.cflore.createMap(); + map.getLayersByName('overlay')[0].mergeNewParams({ + id_cflore:id_cflore + }); + createLayer(); + map.addLayers([vectorLayer]); + map.zoomToMaxExtent(); + maProjection = map.getProjectionObject(); + }; + + /** + * Method: initToolbarItems + * Creates the map toolbar + */ + var initToolbarItems = function() { + if (!toolbarInitializedOnce) { + toolbar.addControl( + new OpenLayers.Control.ZoomToMaxExtent({ + map: map, + title: 'Revenir à l\'échelle maximale' + }), { + iconCls: 'zoomfull', + toggleGroup: this.id + } + ); + + application.cflore.utils.addSeparator(toolbar); + + var history = new OpenLayers.Control.NavigationHistory(); + map.addControl(history); + toolbar.addControl(history.previous, { + iconCls: 'previous' + ,toggleGroup: 'navigation' + ,tooltip: 'Etendue précédente' + ,handler: function() { + syntheseListGrid.getView().refresh(); + } + }); + + toolbar.addControl( + zoomin = new OpenLayers.Control.ZoomBox({ + title: 'Zoomer' + }), { + iconCls: 'zoomin', + toggleGroup: this.id + } + ); + + toolbar.addControl( + new OpenLayers.Control.ZoomBox({ + out: true, + title: 'Dézoomer' + }), { + iconCls: 'zoomout', + toggleGroup: this.id + } + ); + + toolbar.addControl( + dragPanControl = new OpenLayers.Control.DragPan({ + isDefault: true, + title: 'Déplacer la carte' + }), { + iconCls: 'pan', + toggleGroup: this.id + } + ); + + application.cflore.utils.addSeparator(toolbar); + + toolbar.addControl( + drawPointControl = new OpenLayers.Control.DrawFeature(vectorLayer, OpenLayers.Handler.Point, { + title: 'Localiser l\'observation (supprime la localisation existante s\'il y en a une)' + }), { + iconCls: 'drawpoint' + ,toggleGroup: this.id + ,disabled: true + } + ); + + toolbar.add({ + text: 'GPS' + ,id: 'edit-fiche-gps' + ,tooltip: 'Positionner l\'observation sur la carte à partir de coordonnées GPS en UTM' + ,handler: function() { + vectorLayer.removeFeatures(vectorLayer.features[0]); + application.cflore.editFiche.initGpsWindow(); + } + }); + + layerTreeTip = application.cflore.createLayerWindow(map); + layerTreeTip.render(Ext.getCmp('edit-fiche-mapcomponent').body); + layerTreeTip.show(); + layerTreeTip.getEl().alignTo( + Ext.getCmp('edit-fiche-mapcomponent').body, + "tl-tl", + [5, 5] + ); + layerTreeTip.hide(); + + application.cflore.utils.addSeparator(toolbar); + + toolbar.add({ + iconCls: 'legend' + ,enableToggle: true + ,tooltip: 'Gérer les couches affichées' + ,handler: function(button) { + showLayerTreeTip(button.pressed); + } + }); + + toolbar.activate(); + toolbarInitializedOnce = true; + } + }; + + /** + * Method: activateControls + * Allows to activate / enable / deactivate / disable the draw and modify feature controls + * + * Parameters: + * activateDrawControls - {Boolean} true to activate / enable the draw controls + */ + var activateControls = function(activateDrawControls) { + Ext.each([drawPointControl] + ,function(control) { + toolbar.getButtonForControl(control).setDisabled(!activateDrawControls); + if (!activateDrawControls) { + control.deactivate(); + } + } + ); + }; + + /** + * Method: deactivateAllEditingControls + */ + var deactivateAllEditingControls = function() { + toolbar.getButtonForControl(drawPointControl).setDisabled(true); + drawPointControl.deactivate(); + }; + + /** + * Method: updateGeometryField + * Updates the geometry field (hidden) in the form + * + * Parameters: + * geometry - {null|} Geometry + */ + var updateGeometryField = function(geometry) { + if (geometry == null) {wkt = '';} + else {var wkt = format.write(geometry);} + Ext.getCmp('edit-fiche-form').getForm().findField('geometry').setValue(wkt); + firstGeometryLoad = false; + }; + + /** + * Method: createProtocol + * Create the search protocol. + */ + var createProtocol = function() { + protocol = new mapfish.Protocol.MapFish({}); + eventProtocol = new mapfish.Protocol.TriggerEventDecorator({ + protocol: protocol + ,eventListeners: { + crudtriggered: function() { + } + ,crudfinished: function(response) { + var feature = response.features[0]; + //chargement des valeurs du formulaire + Ext.getCmp('edit-fiche-form').getForm().loadRecord(feature); + //on centre en limitant le zoom à 15 + var centerGeom = feature.geometry.getBounds().getCenterLonLat(); + map.setCenter(centerGeom,15); + Ext.getCmp('edit-fiche-form').enable(); + } + } + }); + }; + + /** + * Method: createStore + * Create the search result store. + */ + var createStore = function() { + store = new Ext.data.Store({ + reader: new mapfish.widgets.data.FeatureReader({}, [ + 'id_cflore' + ,'ids_observateurs' + ,{name:'dateobs', type: 'date', dateFormat:'d/m/Y'} + ,'commune' + ,'altitude' + ]) + ,listeners: { + load: function(store, records) { + Ext.getCmp('edit-fiche-form').getForm().loadRecord(records[0]); + } + } + }); + }; + + /** + * Method: resetViewport + * Reset the different items status (on close) for next usage + */ + var resetViewport = function() { + id_cflore = null; + vectorLayer.removeFeatures(vectorLayer.features); + Ext.getCmp('edit-fiche-form').getForm().reset(); + Ext.getCmp('edit-fiche-form').getForm().findField('monaction').setValue('add'); + Ext.getCmp('grid-taxons').getStore().removeAll(); + this.addNewTaxon(); + dragPanControl.activate(); + activateControls(true); + updateGeometryField(null); + Ext.getCmp('edit-fiche-form').disable(); + }; + + /** + * Method: constructStringTaxons + * Construct a multidimentional Array with all taxon informations + */ + var constructStringTaxons = function(){ + var arrayGlobal = [] + Ext.getCmp('grid-taxons').getStore().each(function(rec){ + var attrib = []; + var reg = new RegExp("(,)", "g"); + var val = null; + for (key in rec.data) { + if(typeof rec.data[key]==="string"){val = rec.data[key].replace(reg,'');} //gestion des virgules dans les commentaires + else{val = rec.data[key];} + attrib.push(val); + } + arrayGlobal.push(attrib); + }); + var taxons = arrayGlobal.join("|") + return taxons; + }; + + /** + * Method: submitForm + * Submits the form + */ + var submitForm = function() { + Ext.getCmp('ficheSaveButton').setText('Enregistrement en cours...'); + var params = {}; + if (id_cflore) { + params.id_cflore = id_cflore; + } + params.sting_taxons = constructStringTaxons(); + Ext.getCmp('edit-fiche-form').getForm().submit({ + url: 'cflore/save' + ,params: params + ,success: function(form,action) { + Ext.getCmp('ficheSaveButton').setText('Enregistrer'); + Ext.getCmp('edit-fiche-form').getForm().findField('id_cflore').setValue(action.result.id_cflore); + id_cflore = action.result.id_cflore; + Ext.getCmp('edit-fiche-form').getForm().findField('monaction').setValue('update'); + myProxyReleves.url = 'cflore/listreleves/'+id_cflore; + Ext.getCmp('grid-taxons').getStore().reload(); + application.cflore.editFiche.initSaveWindow(id_cflore); + } + ,failure: function(form, action) { + Ext.getCmp('ficheSaveButton').setText('Enregistrer'); + var msg; + switch (action.failureType) { + case Ext.form.Action.CLIENT_INVALID: + msg = "Les informations saisies sont invalides ou incomplètes. Vérifiez le formulaire (voir champs en rouge)."; + break; + case Ext.form.Action.CONNECT_FAILURE: + msg = "Erreur lors de l'enregistrement"; + break; + case Ext.form.Action.SERVER_INVALID: + msg = "Erreur lors de l'enregistrement : vérifiez les données saisies !"; + break; + } + Ext.Msg.show({ + title: 'Erreur' + ,msg: msg + ,buttons: Ext.Msg.OK + ,icon: Ext.MessageBox.ERROR + }); + } + }); + }; + + /** + * Method: showLayerTreeTip + * Shows or hide the layer tree tip + */ + var showLayerTreeTip = function(show) { + layerTreeTip.setVisible(show); + }; + + + var initSaveWindow = function(id_fiche) { + return new Ext.Window({ + id:'window-save' + ,title:'POINTAGE N° '+id_fiche+'. Et maintenant chef, on fait quoi chef ?' + ,layout:'border' + ,height:175 + ,width: 600 + ,closable:false + ,autoScroll:true + ,modal: true + ,plain: true + ,split: true + ,buttons: [{ + text: 'Créer un nouveau pointage' + ,iconCls:'add' + ,handler: function(){ + resetViewport(); + Ext.getCmp('window-save').destroy(); + Ext.ux.Toast.msg('Et voilà !', 'C\'est reparti ! Pensez à commencer par le pointage sur la carte'); + } + },{ + text: 'Modifier/compléter ce pointage' + ,iconCls:'annuler' + ,handler: function(){ + Ext.ux.Toast.msg('Ok !', 'Vous pouvez compléter ou modifier ce pointage'); + Ext.getCmp('window-save').destroy(); + } + },{ + text:'Accéder à la synthèse' + ,iconCls:'search' + ,handler: function(){ + window.location.href = 'synthese'; + } + },{ + text:'Quitter' + ,iconCls:'action-recenter' + ,handler: function(){ + Ext.getCmp('window-save').destroy(); + window.location.href = 'http://'+host_uri+'/'+app_uri; + } + }] + ,items: [{ + id:'panel-window-save' + ,xtype: 'panel' + ,region: 'center' + ,frame:true + ,border:false + ,split: false + ,autoScroll:false + ,bodyStyle:'padding:5px 5px 0' + ,width: 350 + ,html: 'Votre pointage a bien été enregistré sous le N° '+id_fiche+'.
A l\'avenir, pour le consulter ou éventuellement le modifier, vous devrez utiliser l\'application synthèse.

Vous pouvez maintenant utiliser l\'un des boutons ci-dessous pour modifier ou compléter ce pointage n°'+id_fiche+', réaliser un autre pointage, accéder à l\'application de synthèse ou quitter.' + }] + ,listeners: { + hide:function(){this.destroy();} + } + }); + }; +//---------------------------------- fin de fenêtre choix après sauvegarde ---------------------------------- + // public space + return { + viewport: null + ,init: function() { + createProtocol(); + createStore(); + this.viewport = initViewport(); + } + + /** + * Method: loadAp + * Loads a record from the aps list store + */ + ,loadFiche: function(fiche,action,cd) { + this.init(); + this.viewport.show(); + activateControls(true); + updateGeometryField(null); + Ext.getCmp('edit-fiche-form').getForm().findField('monaction').setValue('add'); + Ext.getCmp('edit-fiche-form').getForm().findField('monactiontaxon').setValue('add'); + Ext.getCmp('grid-taxons').getStore().removeAll(); + Ext.getCmp('grid-taxons').getStore().add(new blankRecord({ + //attention l'ordre des champs est important + id_releve_cflore:null + ,id_taxon:null + ,nom_francais:'' + ,nom_latin:'' + ,nom_taxon_saisi:'Saisie en cours' + ,id_abondance_cflore:null + ,id_phenologie_cflore:null + ,validite_cflore:default_validite_cflore + ,commentaire:'' + ,determinateur:'' + ,cd_ref_origine:null + ,id_classe:null + ,herbier:false + ,patrimonial:false + })); + Ext.getCmp('grid-taxons').getSelectionModel().selectRow(0); + Ext.ux.Toast.msg('Information !', 'Commencez par pointer l\'observation sur la carte, puis saisissez les informations à droite'); + } + + ,initGpsWindow: function() { + this.GpsWindow = Ext.ux.GpsLocation.initGpsWindow(vectorLayer); + this.GpsWindow.show(); + } + ,initSaveWindow: function(id_fiche) { + this.saveWindow = initSaveWindow(id_fiche); + this.saveWindow.show(); + } + + //remplir l'altitude du champ altitude dans le formulaire selon le pointage + ,findZ : function(feature) { + //on recherche l'altitude avec l'API IGN + var geometryCentroid = feature.geometry.getCentroid(); + var latLonGeom = geometryCentroid.transform(new OpenLayers.Projection("EPSG:3857"), new OpenLayers.Projection("EPSG:4326")); + var script = document.createElement('script'); + script.src = String.format('//wxs.ign.fr/{0}/alti/rest/elevation.xml?lon={1}&lat={2}&output=json&zonly=true&callback=application.cflore.editFiche.handleIGNResponse', ign_api_key, latLonGeom.x, latLonGeom.y); + document.head.appendChild(script); + } + ,handleIGNResponse : function(data) { + var parser = new DOMParser(); + var xmlDoc = parser.parseFromString(data.xml, "text/xml"); + var s = xmlDoc.getElementsByTagName('z'); + if (s.length === 0 || Ext.isEmpty(s[0]) || Ext.isEmpty(s[0].innerHTML)) { + Ext.Msg.alert('Attention', "Un problème à été rencontré lors de l'appel au service de l'IGN."); + return; + } + Ext.ux.Toast.msg('Information !', 'Cette altitude est fournie par un service de l\'IGN.'); + application.cflore.editFiche.setAltitude(Math.round(s[0].innerHTML)); + } + ,setAltitude : function(alti) { + Ext.getCmp('fieldfiche-altitude').setValue(alti); + } + + ,changeLabel: function(fieldId, newLabel){ + var label = Ext.DomQuery.select(String.format('label[for="{0}"]', fieldId)); + if (label){ + label[0].childNodes[0].nodeValue = newLabel; + } + } + } +}(); diff --git a/web/js/cflore/application.cflore.js b/web/js/cflore/application.cflore.js new file mode 100755 index 0000000000..23aee7cd3b --- /dev/null +++ b/web/js/cflore/application.cflore.js @@ -0,0 +1,402 @@ +// Ext.Compat.showErrors = true; +// reference local blank image +Ext.BLANK_IMAGE_URL = 'js/client/mfbase/ext-3.4.0/resources/images/default/s.gif'; +Ext.namespace("application.cflorelore"); +if (window.__Geoportal$timer===undefined) { + var __Geoportal$timer= null; +} +/** + * Function: checkApiLoading + * Assess that needed classes have been loaded. + * + * Parameters: + * retryClbk - {Function} function to call if any of the expected classes + * is missing. + * clss - {Array({String})} list of classes to check. + * + * Returns: + * {Boolean} true when all needed classes have been loaded, false otherwise. + */ +function checkApiLoading(retryClbk,clss) { + if (__Geoportal$timer!=null) { + //clearTimeout: annule le minuteur "__Geoportal$timer" avant sa fin + window.clearTimeout(__Geoportal$timer); + __Geoportal$timer= null; + } + /** + * Il se peut que l'init soit exécuté avant que l'API ne soit chargée + * Ajout d'un code temporisateur qui attend 300 ms avant de relancer l'init + */ + var f; + for (var i=0, l= clss.length; i +Ext.ns("Gil.ux"); + Gil.ux.line = Ext.extend(Ext.Component, { + autoEl: 'hr' + ,cls : 'hrdashed' + }); +Ext.reg('line', Gil.ux.line); + + +/** + * Method: addSeparator + * toolbar seperator creator helper + */ +application.cflore.utils.addSeparator = function(toolbar) { + toolbar.add(new Ext.Toolbar.Spacer()); + toolbar.add(new Ext.Toolbar.Separator()); + toolbar.add(new Ext.Toolbar.Spacer()); +}; diff --git a/web/js/cflore/application.cflore.layerWindowFactory.js b/web/js/cflore/application.cflore.layerWindowFactory.js new file mode 100755 index 0000000000..e4e0e10673 --- /dev/null +++ b/web/js/cflore/application.cflore.layerWindowFactory.js @@ -0,0 +1,170 @@ + +Ext.namespace("application.cflore"); + +/** + * function createLayerWindow + * Factory to create the layer tree window + * + * Parameters: + * {OpenLayers.Map} + * + * Returns: + * {Ext.Window} + */ + +application.cflore.createLayerWindow = function(map) { + var overlayLayerUrl = map.getLayersByName('overlay')[0].url; + var model = [ + { + text: "Photographies aériennes" + ,id:'layer_ortho' + ,leaf: true + ,checked: false + ,layerName: "Ortho-imagerie" + } + ,{ + text: "Parcelles cadastrales" + ,id:'layer_cadastre' + ,leaf: true + ,checked: false + ,layerName: "Parcelles cadastrales" + } + ,{ + text: "Communes" + ,leaf: true + ,checked: false + ,icon: mapfish.Util.getIconUrl(overlayLayerUrl, {layer: 'communes'}) + ,layerName: "overlay:communes" + } + ,{ + text: "Secteurs" + ,leaf: true + ,checked: false + ,icon: mapfish.Util.getIconUrl(overlayLayerUrl, {layer: 'secteurs'}) + ,layerName: "overlay:secteurs" + } + ,{ + text: "Unités géographiques" + ,leaf: true + ,checked: true + ,icon: mapfish.Util.getIconUrl(overlayLayerUrl, {layer: 'unitesgeo'}) + ,layerName: "overlay:unitesgeo" + } + ,{ + text: "Zones à statut" + ,leaf: false + ,expanded: false + ,checked: true + ,children: [ + { + text: 'Aire optimale d\'adhésion' + ,leaf: true + ,checked: false + ,icon: mapfish.Util.getIconUrl(overlayLayerUrl, {layer: 'aoa'}) + ,layerName: "overlay:aoa" + },{ + text: 'Coeur de parc national' + ,leaf: true + ,checked: false + ,icon: mapfish.Util.getIconUrl(overlayLayerUrl, {layer: 'coeur'}) + ,layerName: "overlay:coeur" + } + ,{ + text: 'Réserves naturelles nationales' + ,leaf: true + ,checked: false + ,icon: mapfish.Util.getIconUrl(overlayLayerUrl, {layer: 'reservesnationales'}) + ,layerName: "overlay:reservesnationales" + } + ,{ + text: 'Réserves naturelles regionales' + ,leaf: true + ,checked: false + ,icon: mapfish.Util.getIconUrl(overlayLayerUrl, {layer: 'reservesregionales'}) + ,layerName: "overlay:reservesregionales" + } + ,{ + text: 'Arretés de biotope' + ,leaf: true + ,checked: false + ,icon: mapfish.Util.getIconUrl(overlayLayerUrl, {layer: 'ab'}) + ,layerName: "overlay:ab" + } + ,{ + text: 'Natura 2000' + ,leaf: true + ,checked: false + ,icon: mapfish.Util.getIconUrl(overlayLayerUrl, {layer: 'n2000'}) + ,layerName: "overlay:n2000" + } + ,{ + text: 'Znieff2' + ,leaf: true + ,checked: false + ,icon: mapfish.Util.getIconUrl(overlayLayerUrl, {layer: 'znieff2'}) + ,layerName: "overlay:znieff2" + },{ + text: 'Znieff1' + ,leaf: true + ,checked: false + ,icon: mapfish.Util.getIconUrl(overlayLayerUrl, {layer: 'znieff1'}) + ,layerName: "overlay:znieff1" + } + ,{ + text: 'Réserve intégrale' + ,leaf: true + ,checked: false + ,icon: mapfish.Util.getIconUrl(overlayLayerUrl, {layer: 'reservesintegrales'}) + ,layerName: "overlay:reservesintegrales" + } + ,{ + text: 'Réserves de chasse' + ,leaf: true + ,checked: false + ,icon: mapfish.Util.getIconUrl(overlayLayerUrl, {layer: 'reserveschasse'}) + ,layerName: "overlay:reserveschasse" + } + // ,{ + // text: 'Sites classés' + // ,leaf: true + // ,checked: false + // ,icon: mapfish.Util.getIconUrl(overlayLayerUrl, {layer: 'sitesclasses'}) + // ,layerName: "overlay:sitesclasses" + // },{ + // text: 'Sites inscrits' + // ,leaf: true + // ,checked: false + // ,icon: mapfish.Util.getIconUrl(overlayLayerUrl, {layer: 'sitesinscrits'}) + // ,layerName: "overlay:sitesinscrits" + // } + ] + } + + ]; + + var tree = new mapfish.widgets.LayerTree({ + id:'layer-tree-tip' + ,map: map + ,model: model + ,height: 260 + }); + + + return new Ext.Tip({ + width:230, + title: 'Couches', + items: tree, + shadow: false, + closable:true, + listeners:{ + beforehide:function(){ + if(Ext.getCmp('zp-layertreetip')){ + Ext.getCmp('zp-layertreetip').toggle(false); + } + if(Ext.getCmp('search-layertreetip')){ + Ext.getCmp('search-layertreetip').toggle(false); + } + } + } + }); +}; diff --git a/web/js/config.js.sample b/web/js/config.js.sample index 569176abd9..9c3ad67105 100755 --- a/web/js/config.js.sample +++ b/web/js/config.js.sample @@ -8,26 +8,29 @@ usage = 'prod';//valeur possible : demo (limit 100 sur les exports), prod pn_name_long = 'Parc nationaux de France'; struc_abregee = 'PnF'; -//-----Configuration relatives aux données saisies------------- +//-----Configuration relatives aux sources des données saisies------------- id_lot_contact_vertebre = 1; id_lot_mortalite = 2; id_lot_contact_invertebre = 3; id_lot_flore_station = 5; id_lot_bryophytes = 6; +id_lot_contact_flore = 7; id_protocole_contact_vertebre = 1; id_protocole_mortalite = 2; id_protocole_contact_invertebre = 3; id_protocole_flore_station = 5; id_protocole_bryophyte = 6; +id_protocole_contact_flore = 7; id_source_contactfaune = 1; id_source_mortalite = 2; id_source_contactinv = 3; id_source_flore_station = 5; id_source_bryophytes = 6; +id_source_contactflore = 7; -//configuration du filtre par classes contact faune et mortalité +//-----configuration du filtre par classes contact faune et mortalité //Utiliser les identifiants id_liste de la table taxonomie.bib_listes id_classe_oiseaux = 12; id_classe_mammiferes = 11; @@ -35,10 +38,24 @@ id_classe_amphibiens = 1; id_classe_reptiles = 14; id_classe_poissons = 13; -//configuration du filtre par classes contact invertébré +//-----configuration du filtre par classes contact invertébré //Utiliser les identifiants id_liste de la table taxonomie.bib_listes id_classe_ecrevisses = 5; id_classe_insectes = 9; id_classe_arachnides = 16; id_classe_myriapodes = 15; -id_classe_mollusques = 101; \ No newline at end of file +id_classe_mollusques = 101; + +//-----configuration du contact flore +//activation/désactivation de la validation des données de contact flore +//valeurs possibles true ou false +use_validite_cflore = false; +//défini la valeur par défaut du champ booléen validite_cflore de la table contactflore.t_releves_cflore +//valeurs possibles true ou false +default_validite_cflore = false; +//label utilisé pour définir la notion de validité d'une observation +//string +label_validite = "Observation relue"; +//Texte d'aide à la saisie affiché au survol de la case à cocher validite_cflore +//string +tooltip_validite = "Cochez si cette observation a été relue. Si la case n'est pas cochée, l'observation est non relue"; \ No newline at end of file diff --git a/web/js/invertebre/application.invertebre.editFiche.js b/web/js/invertebre/application.invertebre.editFiche.js index fb385d0c36..395144860c 100755 --- a/web/js/invertebre/application.invertebre.editFiche.js +++ b/web/js/invertebre/application.invertebre.editFiche.js @@ -54,7 +54,7 @@ application.invertebre.editFiche = function() { * Property: protocol * {mapfish.Protocol.MapFish} */ - var protocol = null + var protocol = null; /** * Property: eventProtocol @@ -709,7 +709,7 @@ application.invertebre.editFiche = function() { } }; - this.addNewTaxon = function(){ + this.addNewTaxon = function(){ Ext.getCmp('edit-fiche-form').getForm().findField('monactiontaxon').setValue('add'); relevesStore.add(new blankRecord({ //attention l'ordre des champs est important @@ -817,7 +817,7 @@ application.invertebre.editFiche = function() { ,title: 'Listes des taxons observés' ,bodyStyle:'padding:5px' ,width: 600 - ,layout: 'column' // Specifies that the items will now be arranged in columns + ,layout: 'column' // Specifies that the items will now be arranged in columns ,items: [{ columnWidth: 0.6 ,xtype: 'panel' @@ -876,7 +876,7 @@ application.invertebre.editFiche = function() { ,listeners: { check: function(checkbox,checked) { if(checked){comboTaxonsTemplate('latin'); - Ext.getCmp('combo-fiche-taxon').displayField = 'nom_latin' + Ext.getCmp('combo-fiche-taxon').displayField = 'nom_latin'; Ext.getCmp('combo-fiche-taxon').setValue(Ext.getCmp('combo-fiche-taxon').getValue());//pas trouvé mieux pour rafraichier en live le taxon déjà affiché dans le combo } } @@ -1137,7 +1137,7 @@ application.invertebre.editFiche = function() { Ext.getCmp('grid-taxons').getSelectionModel().getSelected().set('patrimonial',record.data.patrimonial); Ext.getCmp('grid-taxons').getSelectionModel().getSelected().set('cd_ref_origine',record.data.cd_ref); Ext.getCmp('combo-fiche-critere').clearValue(); - Ext.getCmp('grid-taxons').getSelectionModel().getSelected().set('id_critere_inv',null); + Ext.getCmp('grid-taxons').getSelectionModel().getSelected().set('id_critere_inv',null); Ext.getCmp('fieldfiche-male').setValue(0); Ext.getCmp('grid-taxons').getSelectionModel().getSelected().set('am',0); Ext.getCmp('fieldfiche-femelle').setValue(0); @@ -1785,8 +1785,8 @@ application.invertebre.editFiche = function() { * Method: constructStringTaxons * Construct a multidimentional Array with all taxon informations */ - var constructStringTaxons = function(){ - var arrayGlobal = [] + var constructStringTaxons = function(){ + var arrayGlobal = []; Ext.getCmp('grid-taxons').getStore().each(function(rec){ var attrib = []; var reg = new RegExp("(,)", "g"); @@ -1798,7 +1798,7 @@ application.invertebre.editFiche = function() { } arrayGlobal.push(attrib); }); - var taxons = arrayGlobal.join("|") + var taxons = arrayGlobal.join("|"); return taxons; }; diff --git a/web/js/synthese/application.synthese.editCflore.js b/web/js/synthese/application.synthese.editCflore.js new file mode 100755 index 0000000000..fa999bf0f8 --- /dev/null +++ b/web/js/synthese/application.synthese.editCflore.js @@ -0,0 +1,1896 @@ +/** + * @class application.synthese.editCflore + * Singleton to build the editFiche viewport + * + * @singleton + */ + + Ext.namespace("application.synthese"); + +application.synthese.editCflore = function() { + // private variables + // "use strict"; + /** + * Property: map + * {OpenLayers.Map} + */ + map = null; + + /** + * Property: toolbar + * {mapfish.widgets.ToolBar} + */ + var toolbar = null; + + /** + * Property: toolbarInitializedOnce + * {Boolean} toolbar has already been initialized + */ + var toolbarInitializedOnce = false; + + /** + * Property: vectorLayer + * {OpenLayers.Layer.Vector} + */ + vectorLayer = null; + + /** + * Property: dragPanControl + */ + var dragPanControl = null; + + /** + * Property: dragPointControl + */ + var dragPointControl = null; + + /** + * Property: store + * {Ext.data.Store} The ap store (should contain only one record) + */ + var store = null; + + /** + * Property: protocol + * {mapfish.Protocol.MapFish} + */ + var protocol = null + + /** + * Property: eventProtocol + * {mapfish.Protocol.TriggerEventDecorator} + */ + var eventProtocol = null; + + /** + * Property: filterProtocol + * {mapfish.Protocol.MergeFilterDecorator} + */ + var filterProtocol = null; + + /** + * Property: format + * {} + */ + var format = new OpenLayers.Format.WKT(); + + /** + * APIProperty: id_cflore + * The id of fiche to update (if applies), null in case of a creating a new fiche + */ + var id_cflore = null; + + /** + * APIProperty: old_cd_nom + * The old cd_nom of the taxon to update + */ + var old_taxon = null; + + /** + * Property: layerTreeTip + * {Ext.Tip} The layerTreeTip created with the factory + */ + var layerTreeTip = null; + + /** + * Property: firstGeometryLoad + * {Boolean} is the geometry has been load once only + */ + var firstGeometryLoad = true; + + /** + * Property: firstAltitudeLoad + * {Boolean} is the altitude has been load once only + */ + var firstAltitudeLoad = true; + + /** + * Property: myProxyTaxons + * {Ext.data.HttpProxy} Url pour charger une liste de taxon fonction de l'unité ??? + */ + + var myProxyReleves = null; + + /** + * Property: myProxyReleves + * {Ext.data.HttpProxy} Url pour charger une liste des releves de la fiche ??? + */ + + var myProxyTaxons = null; + /** + * Property: maProjection + * {Openlayers.Projection} définie ici sinon temps de retard lors de la création du point gps ??? + */ + var maProjection = null; + + /** + * Property: blankRecord + * {Ext.data.Record} record vide pour la grid-taxons + */ + var blankRecord = null; + + /** + * Property: errorMsg + * {string} message to display if taxon form is invalid or not complete + */ + var errorMsg = ''; + + // private functions + + /** + * Method: initWindow + */ + var initWindow = function() { + return new Ext.Window({ + id:'window-form' + ,title: "Modifier une fiche contact Flore" + ,layout: 'border' + ,modal: true + ,plain: true + ,plugins: [new Ext.ux.plugins.ProportionalWindows()] + ,width: 800 + ,height: 600 + ,percentage: 0.92 + ,split: true + ,closeAction: 'hide' + ,defaults: { + border: false + } + ,items: [ + getWindowCenterItem() + ,getViewportEastItem() + ] + ,listeners: { + show: initToolbarItems + ,hide: function(){ + if(Ext.isDefined(this.destroy)){ + toolbarInitializedOnce = false; + this.destroy(); + } + } + ,afterlayout: function(){ + Ext.getCmp('layer-tree-tip').getNodeById('layer_unites_geo').getUI().toggleCheck(true); + map.baseLayer.redraw(); + } + } + }); + }; + + /** + * Method: getViewportEastItem + */ + var getViewportEastItem = function() { + return { + region: 'east' + ,width: 600 + ,split: true + ,autoScroll: true + ,defaults: { + border: false + } + ,items: [{ + id: 'edit-fiche-form' + ,xtype: 'form' + ,bodyStyle: 'padding: 5px' + ,disabled: true + ,defaults: { + xtype: 'numberfield' + ,labelWidth: 90 + ,width: 180 + ,anchor:'-15' + } + ,monitorValid:true + ,items: [getFormItems(),getFormTaxons()] + //pour version Extjs 3.4 + ,buttons:[{ + text: 'Enregistrer' + ,xtype: 'button' + ,id: 'ficheSaveButton' + ,iconCls: 'action-save' + ,handler:function(){submitForm();} + }] + }] + } + }; + + /** + * Method: getViewportCenterItem + */ + var getWindowCenterItem = function() { + createMap(); + toolbar = new mapfish.widgets.toolbar.Toolbar({ + map: map, + configurable: false + }); + + return { + region: 'center' + ,id: 'edit-fiche-mapcomponent' + ,xtype: 'mapcomponent' + ,map: map + ,tbar: toolbar + }; + }; + + /** + * Method: getFormItems + * Creates the form items + */ + var getFormItems = function() { + var comboObservateurs = new Ext.ux.form.SuperBoxSelect({ + id:'combo-fiche-observateurs' + ,xtype:'superboxselect' + ,fieldLabel: 'Observateur(s) ' + ,name: 'lesobservateurs' + ,store: application.synthese.storeObservateursCfloreAdd + ,displayField: 'auteur' + ,valueField: 'id_role' + ,allowBlank: false + ,resizable: true + ,forceSelection : true + ,selectOnFocus:true + ,resizable: true + ,mode: 'local' + ,value: application.synthese.user.id_utilisateur + ,listeners:{ + afterrender :function(combo){ + combo.setValue(application.synthese.user.id_utilisateur); + Ext.getCmp('edit-fiche-form').getForm().findField('ids_observateurs').setValue(combo.getValue()); + } + ,change:function(combo,newValue){ + Ext.getCmp('edit-fiche-form').getForm().findField('ids_observateurs').setValue(newValue); + Ext.getCmp('edit-fiche-form').getForm().findField('ids_observateurs').setValue(newValue); + } + ,render: function(c) { + Ext.QuickTips.register({ + target: c.getEl(), + text: 'Le ou les auteurs de l\'observation.' + }); + } + } + }); + + return [{ + id:'hidden-idfiche' + ,xtype:'hidden' + ,name: 'id_cflore' + },{ + xtype:'hidden' + ,name: 'monaction' + },{ + xtype: 'hidden' + ,name: 'geometry' + },{ + xtype:'hidden' + ,name: 'ids_observateurs' + },{ + // Fieldset + xtype:'fieldset' + ,id:'fieldset-1-fiche' + ,columnWidth: 1 + ,title: 'Renseignements concernant le pointage' + ,collapsible: true + ,autoHeight:true + ,anchor:'98%' + ,items :[comboObservateurs + ,{ + xtype: 'compositefield' + ,labelWidth: 80 + ,items: [ + { + id:'datefield-fiche-date' + ,fieldLabel: 'Date ' + ,name: 'dateobs' + ,xtype:'datefield' + ,maxValue: new Date() + ,format: 'd/m/Y' + ,altFormats:'Y-m-d' + ,allowBlank: false + ,blankText:'La date de l\'observation est obligatoire' + ,listeners: { + render: function(c) { + Ext.QuickTips.register({ + target: c.getEl(), + text: 'Date de l\'observation. Elle ne peut donc être postérieure à la date de saisie.' + }); + } + } + } + ,{ + xtype: 'displayfield', + value: ' Altitude :' + },{ + id: 'fieldfiche-altitude' + ,xtype:'numberfield' + ,allowDecimals :false + ,allowNegative: false + ,name: 'altitude_saisie' + ,anchor: '40%' + ,listeners: { + render: function(c) { + Ext.QuickTips.register({ + target: c.getEl(), + text: 'L\'altitude est calculée à partir d\'un service de l\'API Geoportail de l\'IGN. Vous pouvez la corriger si vous le souhaitez.' + }); + } + } + }] + },{ + id:'fieldlabel-commune' + ,xtype: 'displayfield' + ,value: 'Commune : inconnue' + } + ] + } //fin du groupe 1 + ] //fin du return + }; + /** + * Method: getFormTaxons + * + * Dans ce formulaire, les données saisies à droite sont enregistrées dans le store + * de la grille de gauche en temps réel (sur keyup ou sur select pour les combo). + * Une fonction invoquée sur chaque modification des champs obligatoires vérifie + * si l'ensemble du formulaire est valid ou non. + * si oui on active le bouton enregister, sinon l'enregistrement est impossible. + */ + var getFormTaxons = function(){ + var relevesStoreFields = [ + {name: 'id_releve_cflore', type: 'integer'} + ,{name: 'id_taxon', type: 'integer'} + ,{name: 'nom_francais', type: 'string',sortType: Ext.data.SortTypes.asAccentuatedString} + ,{name: 'nom_latin', type: 'string'} + ,{name: 'nom_taxon_saisi', type: 'string'} + ,{name: 'id_abondance_cflore', type: 'integer'} + ,{name: 'id_phenologie_cflore', type: 'integer'} + ,{name: 'validite_cflore', type: 'boolean'} + ,{name: 'commentaire', type: 'string'} + ,{name: 'determinateur', type: 'string'} + ,{name: 'cd_ref_origine', type: 'integer'} + ,{name: 'id_classe', type: 'integer'} + ,{name: 'herbier', type: 'boolean'} + ,{name: 'patrimonial'} + ]; + + myProxyReleves = new Ext.data.HttpProxy({ + id:'store-releve-proxy' + ,url: 'cflore/listreleves' + ,method: 'GET' + }); + var relevesStore = new Ext.data.JsonStore({ + url: myProxyReleves + ,sortInfo: { + field: 'nom_francais' + ,direction: 'ASC' + } + ,fields: relevesStoreFields + ,listeners: { + load: function(store, records) { + Ext.getCmp('grid-taxons').getSelectionModel().selectRow(0); + } + } + }); + + //record vide pour le bouton ajouter un taxon + blankRecord = Ext.data.Record.create(relevesStoreFields); + + function isPatri(val){ + if(val){ + return '' + val + ''; + } + return val; + } + + var colModel = new Ext.grid.ColumnModel([ + {header: "Id", width: 55, sortable: true, dataIndex: 'id_taxon',hidden:true} + ,{id:'taxonfr',header: "Taxons déjà saisis", width: 160, sortable: true, locked:false, dataIndex: 'nom_francais',hidden:true} + ,{id:'taxonssc',header: "Taxons déjà saisis", width: 160, sortable: true, locked:false, dataIndex: 'nom_latin',hidden:true} + ,{header: "Abondance", width: 55, sortable: true, dataIndex: 'id_abondance_cflore',hidden:true} + ,{header: "Phénologie", width: 55, sortable: true, dataIndex: 'id_phenologie_cflore',hidden:true} + ,{header: "Validité", width: 25, sortable: true, dataIndex: 'validite_cflore',hidden:true} + ,{header: "Herbier", width: 35, sortable: true, dataIndex: 'herbier',hidden:true} + ,{header: "Commentaire", width: 135, sortable: true, dataIndex: 'commentaire',hidden:true} + ,{header: "Déterminateur", width: 50, sortable: true, dataIndex: 'determinateur',hidden:true} + ,{header: "id_classe", width: 135, sortable: true, dataIndex: 'id_classe',hidden:true} + ,{id:'taxonsaisi',header: "Taxons saisis", width: 160, sortable: true, dataIndex: 'nom_taxon_saisi'} + ,{header: "cd_ref", width: 135, sortable: true, dataIndex: 'cd_ref_origine',hidden:true} + ,{header: "Patrimoniale", width: 50, sortable: true, renderer:isPatri,dataIndex: 'patrimonial',hidden:true} + ,{ + xtype : 'actioncolumn' + ,sortable : false + ,hideable : false + ,menuDisabled : true + ,width:20 + ,items : [{ + tooltip : 'Supprimer ce taxon du pointage' + ,getClass : function(v, meta, record, rowIndex, colIdx, store) { + return 'action-remove'; + } + ,scope : this + ,handler : function(grid, rowIndex, colIndex) { + var record = grid.getStore().getAt(rowIndex); + if(!record.data.id_taxon){ + grid.getStore().remove(record); + if(Ext.getCmp('grid-taxons').getStore().getCount()===0){ + this.addNewTaxon(); + Ext.ux.Toast.msg('Information !', 'Vous avez supprimé tous les taxons de ce pointage.'); + } + else{ + Ext.getCmp('grid-taxons').getSelectionModel().selectRow(0); + Ext.ux.Toast.msg('Annulation !', 'La saisie d\'un nouveau taxon a été annulée.'); + } + } + else{ + Ext.Msg.confirm('Attention' + ,'Etes-vous certain de vouloir supprimer le taxon "'+record.data.nom_francais+'" ?' + ,function(btn) { + if (btn == 'yes') { + grid.getStore().remove(record); + if(Ext.getCmp('grid-taxons').getStore().getCount()===0){ + this.addNewTaxon(); + Ext.ux.Toast.msg('Suppression !', 'Le taxon "'+record.data.nom_francais+'" a été supprimé de ce pointage. Vous avez supprimé tous les taxons de ce pointage.'); + } + else{ + Ext.getCmp('grid-taxons').getSelectionModel().selectRow(0); + Ext.ux.Toast.msg('Suppression !', 'Le taxon "'+record.data.nom_francais+'" a été supprimé de ce pointage.'); + } + } + } + ,this // scope + ); + } + Ext.getCmp('combo-fiche-abondance').setWidth(200);//debug sinon le combo apparait avec une largeur ridicule + Ext.getCmp('combo-fiche-abondance').syncSize();//debug sinon le combo apparait avec une largeur ridicule + } + }] + } + ]); + + var abondancesStore = new Ext.data.JsonStore({ + url: 'bibs/abondancescflore' + ,sortInfo: { + field: 'id_abondance_cflore' + ,direction: 'ASC' + } + ,fields: [ + 'id_abondance_cflore' + ,'nom_abondance_cflore' + ] + ,autoLoad: true + ,synchronous: true + ,listeners: { + load: function(store, records) { + if(Ext.getCmp('grid-taxons').getSelectionModel().getSelected()){ + Ext.getCmp('combo-fiche-abondance').setValue(Ext.getCmp('grid-taxons').getSelectionModel().getSelected().data.id_abondance_cflore); + } + } + } + }); + var phenologiesStore = new Ext.data.JsonStore({ + url: 'bibs/phenologiescflore' + ,sortInfo: { + field: 'id_phenologie_cflore' + ,direction: 'ASC' + } + ,fields: [ + 'id_phenologie_cflore' + ,'nom_phenologie_cflore' + ] + ,autoLoad: true + ,synchronous: true + ,listeners: { + load: function(store, records) { + if(Ext.getCmp('grid-taxons').getSelectionModel().getSelected()){ + Ext.getCmp('combo-fiche-phenologie').setValue(Ext.getCmp('grid-taxons').getSelectionModel().getSelected().data.id_phenologie_cflore); + } + } + } + }); + + myProxyTaxons = new Ext.data.HttpProxy({ + id:'store-taxon-proxy' + ,url: 'bibs/taxonscflore' + ,method: 'GET' + }); + var comboTaxonsFiltre = function(){ + var orange = Ext.getCmp('cb-orange-cf').getValue(); + var red = Ext.getCmp('cb-red-cf').getValue(); + var gray = Ext.getCmp('cb-gray-cf').getValue(); + var patri = Ext.getCmp('cb-patri-cf').getValue(); + + Ext.getCmp('combo-fiche-taxon').getStore().filterBy(function(record,id){ + var recColor = record.data.couleur; + var statutPatri = record.data.patrimonial; + var id_classe = record.data.id_classe; + if(!patri){ + if(recColor == 'orange' && orange && comboTaxonsFiltreClasse(id_classe)){return true;} + if(recColor == 'red' && red && comboTaxonsFiltreClasse(id_classe)){return true;} + if(recColor == 'gray' && gray && comboTaxonsFiltreClasse(id_classe)){return true;} + } + if(patri){ + if(recColor == 'orange' && orange && statutPatri && comboTaxonsFiltreClasse(id_classe)){return true;} + if(recColor == 'red' && red && statutPatri && comboTaxonsFiltreClasse(id_classe)){return true;} + if(recColor == 'gray' && gray && statutPatri && comboTaxonsFiltreClasse(id_classe)){return true;} + } + return false; + }); + }; + var comboTaxonsFiltreClasse = function(classe){ + var pteridophytes = Ext.getCmp('cb-pteridophytes-cf').getValue(); + var monocotyledones = Ext.getCmp('cb-monocotyledones-cf').getValue(); + var dicotyledones = Ext.getCmp('cb-dicotyledones-cf').getValue(); + var bryophytes = Ext.getCmp('cb-bryophytes-cf').getValue(); + if((!pteridophytes&&!monocotyledones&&!dicotyledones&&!bryophytes)==true){return true;} + if(dicotyledones && classe==id_classe_dicotyledones){return true;} + if(monocotyledones && classe==id_classe_monocotyledones){return true;} + if(pteridophytes && classe==id_classe_pteridophytes){return true;} + if(bryophytes && classe==id_classe_bryophytes){return true;} + return false; + }; + + /*** SOLUTION ATOL ***/ + var comboTaxonsTemplate = function(langue) { + var dataIndex = (langue == 'latin'?'nom_latin':'nom_francais'); + var comboFicheTaxon = Ext.getCmp('combo-fiche-taxon'); + comboFicheTaxon.getStore().sort(dataIndex); + var monTpl = new Ext.XTemplate( + ''+ + '
'+ + ' '+ + ' '+ + ' '+ + ' {'+dataIndex+'}({nb_obs}) - {derniere_date}'+ + '
'+ + '
'); + if(Ext.isDefined(comboFicheTaxon.view)){ + comboFicheTaxon.view.tpl = monTpl; + comboFicheTaxon.view.refresh(); + } + }; + + var isValidForm = function(){ + var isValid = true; + Ext.getCmp('grid-taxons').getStore().each(function(r){ + if(r.data.id_taxon==0 || r.data.id_taxon==null){isValid = false;return false;} + if(r.data.nom_taxon_saisi=='Saisie en cours'){isValid = false;return false;} + if(r.data.id_abondance_cflore==0 || r.data.id_abondance_cflore==null){isValid = false;return false;} + if(r.data.id_phenologie_cflore==0 || r.data.id_phenologie_cflore==null){isValid = false;return false;} + return true; + }); + return isValid; + }; + var isValidTaxon = function(r){ + var isValid = true; + errorMsg = ''; + if(r.data.id_taxon==0 || r.data.id_taxon==null){isValid = false;errorMsg='Veuillez choisir un taxon';return false;} + if(r.data.id_abondance_cflore==0 || r.data.id_abondance_cflore==null){isValid = false;errorMsg='Veuillez définir l\'abondance pour ce taxon';return false;} + if(r.data.id_phenologie_cflore==0 || r.data.id_phenologie_cflore==null){isValid = false;errorMsg='Veuillez définir la phénologie de ce taxon';return false;} + var commentValue = Ext.getCmp('ta-fiche-commentaire').getValue(); + if(Ext.getCmp('cb-herbier').getValue() && (commentValue == null || commentValue == '')){isValid = false;errorMsg='Un commentaire est obligatoire en cas de mise en herbier';return false;} + return isValid; + }; + var manageValidationTaxon = function(isValid){ + if(isValid){ + Ext.getCmp('grid-taxons').enable(); + Ext.getCmp('bt-validtaxon').enable(); + Ext.getCmp('bt-validtaxon').setIconClass('validate'); + if(Ext.getCmp('combo-fiche-taxon').findRecord('id_taxon',Ext.getCmp('combo-fiche-taxon').getValue())){Ext.getCmp('bt-validtaxon').setText('Valider "' + returnTaxonSaisi() +'"');} + else{Ext.getCmp('bt-validtaxon').setText('Valider');} + } + else{ + if(!Ext.getCmp('grid-taxons').getSelectionModel().hasNext() && Ext.getCmp('grid-taxons').getSelectionModel().getSelected().data.id_taxon==null){ + Ext.getCmp('grid-taxons').enable(); + } + else{Ext.getCmp('grid-taxons').disable();} + Ext.getCmp('bt-validtaxon').disable(); + Ext.getCmp('bt-validtaxon').setIconClass('unvalidate'); + Ext.getCmp('bt-validtaxon').setText('Terminer la saisie pour valider'); + if(Ext.getCmp('grid-taxons').getSelectionModel().getSelected()){Ext.getCmp('grid-taxons').getSelectionModel().getSelected().set('nom_taxon_saisi','Saisie en cours');} + } + Ext.getCmp('error-message').setText(errorMsg); + manageValidationForm(isValidForm()) + }; + var manageValidationForm = function(isValid){ + if(isValid){ + Ext.getCmp('ficheSaveButton').enable(); + Ext.getCmp('bt-addtaxon').enable(); + } + else{ + Ext.getCmp('ficheSaveButton').disable(); + Ext.getCmp('bt-addtaxon').disable(); + } + + }; + + this.addNewTaxon = function(){ + Ext.getCmp('edit-fiche-form').getForm().findField('monactiontaxon').setValue('add'); + relevesStore.add(new blankRecord({ + //attention l'ordre des champs est important + id_releve_cflore:null + ,id_taxon:null + ,nom_francais:'' + ,nom_latin:'' + ,nom_taxon_saisi:'Saisie en cours' + ,id_abondance_cflore:null + ,id_phenologie_cflore:null + ,validite_cflore:default_validite_cflore + ,commentaire:'' + ,determinateur:'' + ,cd_ref_origine:null + ,id_classe:null + ,herbier:false + ,patrimonial:false + })); + Ext.getCmp('fieldset-abondance').collapse(); + Ext.getCmp('fieldset-phenologie').collapse(); + Ext.getCmp('fieldset-validite').collapse(); + Ext.getCmp('fieldset-herbier').collapse(); + Ext.getCmp('fieldset-commentaire').collapse(); + Ext.getCmp('fieldset-determinateur').collapse(); + Ext.getCmp('grid-taxons').getSelectionModel().selectLastRow(false); + manageValidationTaxon(false); + }; + var returnTaxonSaisi = function(){ + var r = null; + if(Ext.getCmp('combo-fiche-taxon').findRecord('id_taxon',Ext.getCmp('combo-fiche-taxon').getValue())){r = Ext.getCmp('combo-fiche-taxon').findRecord('id_taxon',Ext.getCmp('combo-fiche-taxon').getValue())}; + if(Ext.getCmp('radiogroup-langue-cf').getValue().inputValue=='fr'){ + if(r){return r.data.nom_francais;} + else{return 'en cours';} + } + if(Ext.getCmp('radiogroup-langue-cf').getValue().inputValue=='latin'){ + if(r){return r.data.nom_latin;} + else{return 'en cours';} + } + }; + + if(application.synthese.user.statuscode >= 2){ + var validTaxonButton = new Ext.Button({ + id:'bt-validtaxon' + ,iconCls: 'unvalidate' + ,text: 'Terminer la saisie pour valider' + ,disabled: true + ,handler: function() { + Ext.getCmp('grid-taxons').getSelectionModel().getSelected().set('nom_taxon_saisi',returnTaxonSaisi()); + manageValidationForm(isValidForm()); + } + ,scope: this + }); + } + if(application.synthese.user.statuscode >= 2){ + var addTaxonButton = new Ext.Button({ + id:'bt-addtaxon' + ,iconCls: 'add' + ,text: 'Ajouter un taxon sur ce pointage' + ,disabled: true + ,handler: function() { + this.addNewTaxon(); + Ext.getCmp('combo-fiche-taxon').focus(); + } + ,scope: this + }); + } + + storeTaxonsCf = new Ext.data.JsonStore({ + url: myProxyTaxons + ,fields: [ + 'id_taxon' + ,'cd_ref' + ,'nom_latin' + ,{name:'nom_francais',sortType: Ext.data.SortTypes.asAccentuatedString} + ,'id_classe' + ,'patrimonial' + ,'message' + ,'couleur' + ,'nb_obs' + ,'derniere_date' + ] + ,sortInfo: { + field: 'nom_francais' + ,direction: 'ASC' + } + ,autoLoad:true + ,listeners: { + load: function(store, records) { + if(Ext.getCmp('grid-taxons').getSelectionModel().getSelected()){ + Ext.getCmp('combo-fiche-taxon').setValue(Ext.getCmp('grid-taxons').getSelectionModel().getSelected().data.id_taxon); + } + comboTaxonsFiltre(); + } + } + }); + + + /* + * création du formulaire taxon + */ + var gridForm = new Ext.Panel({ + id: 'taxons-form' + ,frame: true + ,labelAlign: 'left' + ,title: 'Listes des taxons observés' + ,bodyStyle:'padding:5px' + ,width: 600 + ,layout: 'column' // Specifies that the items will now be arranged in columns + ,items: [{ + columnWidth: 0.6 + ,xtype: 'panel' + ,labelWidth: 80 + ,defaults: { + width: 305 + ,border:false + ,allowDecimals :false + ,allowNegative: false + } + ,defaultType: 'numberfield' + ,autoHeight: true + ,bodyStyle: Ext.isIE ? 'padding:0 0 5px 5px;' : 'padding:5px 5px;' + ,border: false + ,style: { + "margin-left": "5px", // when you add custom margin in IE 6... + "margin-right": Ext.isIE6 ? (Ext.isStrict ? "-10px" : "-13px") : "0" // you have to adjust for it somewhere else + } + ,items: [ + { + xtype:'fieldset' + ,id:'fieldset-taxons' + ,columnWidth: 1 + ,title: 'Choix du taxon observé' + ,collapsible: true + ,autoHeight:true + ,anchor:'100%' + ,items :[ + { + id:'radiogroup-langue-cf' + ,xtype: 'radiogroup' + ,fieldLabel: 'Langue' + ,defaultType: 'radio' + ,cls:'graytext' + ,itemCls:'graytext' + ,items: [{ + boxLabel: 'français' + ,name: 'langue' + ,itemCls:'graytext' + ,inputValue: 'fr' + ,checked: true + ,listeners: { + check: function(checkbox,checked) { + if(checked){ + comboTaxonsTemplate('fr'); + Ext.getCmp('combo-fiche-taxon').displayField = 'nom_francais'; + Ext.getCmp('combo-fiche-taxon').setValue(Ext.getCmp('combo-fiche-taxon').getValue());//pas trouvé mieux pour rafraichier en live le taxon déjà affiché dans le combo + } + } + } + },{ + boxLabel: 'latin' + ,name: 'langue' + ,itemCls:'graytext' + ,inputValue: 'latin' + ,listeners: { + check: function(checkbox,checked) { + if(checked){comboTaxonsTemplate('latin'); + Ext.getCmp('combo-fiche-taxon').displayField = 'nom_latin' + Ext.getCmp('combo-fiche-taxon').setValue(Ext.getCmp('combo-fiche-taxon').getValue());//pas trouvé mieux pour rafraichier en live le taxon déjà affiché dans le combo + } + } + } + } + ] + },{ + id:'checkboxgroup-classe-cf' + ,xtype: 'checkboxgroup' + ,fieldLabel: 'Groupe taxonomique' + ,cls:'graytext' + ,itemCls:'graytext' + ,columns: 2 + ,items: [{ + id:'cb-monocotyledones-cf' + ,boxLabel: 'Monocotylédones' + ,name: 'cb-monocotyledones' + ,itemCls:'graytext' + ,checked: false + ,listeners: { + check: function(checkbox,checked){ + if(checked){ + Ext.getCmp('cb-dicotyledones-cf').setValue(false); + Ext.getCmp('cb-pteridophytes-cf').setValue(false); + Ext.getCmp('cb-bryophytes-cf').setValue(false); + } + if(Ext.getCmp('combo-fiche-taxon')){Ext.getCmp('combo-fiche-taxon').clearValue();} + comboTaxonsFiltre(); + } + ,render: function(c) { + Ext.QuickTips.register({ + target: c.getEl(), + text: 'Affiche les monocotylédones dans la liste si la case est cochée.' + }); + } + } + },{ + id:'cb-dicotyledones-cf' + ,boxLabel: 'Dicotylédones' + ,name: 'cb-dicotyledones' + ,itemCls:'graytext' + ,checked: false + ,listeners: { + check: function(checkbox,checked) { + if(checked){ + Ext.getCmp('cb-monocotyledones-cf').setValue(false); + Ext.getCmp('cb-pteridophytes-cf').setValue(false); + Ext.getCmp('cb-bryophytes-cf').setValue(false); + } + if(Ext.getCmp('combo-fiche-taxon')){Ext.getCmp('combo-fiche-taxon').clearValue();} + comboTaxonsFiltre(); + } + ,render: function(c) { + Ext.QuickTips.register({ + target: c.getEl(), + text: 'Affiche les dicotylédones dans la liste si la case est cochée.' + }); + } + } + },{ + id:'cb-pteridophytes-cf' + ,boxLabel: 'Ptéridophytes' + ,name: 'cb-pteridophytes' + ,itemCls:'graytext' + ,checked: false + ,listeners: { + check: function(checkbox,checked) { + if(checked){ + Ext.getCmp('cb-monocotyledones-cf').setValue(false); + Ext.getCmp('cb-dicotyledones-cf').setValue(false); + Ext.getCmp('cb-bryophytes-cf').setValue(false); + } + if(Ext.getCmp('combo-fiche-taxon')){Ext.getCmp('combo-fiche-taxon').clearValue();} + comboTaxonsFiltre(); + } + ,render: function(c) { + Ext.QuickTips.register({ + target: c.getEl(), + text: 'Affiche les ptéridophytes dans la liste si la case est cochée.' + }); + } + } + },{ + id:'cb-bryophytes-cf' + ,boxLabel: 'Bryophytes' + ,name: 'cb-bryophytes' + ,itemCls:'graytext' + ,checked: false + ,listeners: { + check: function(checkbox,checked) { + if(checked){ + Ext.getCmp('cb-monocotyledones-cf').setValue(false); + Ext.getCmp('cb-dicotyledones-cf').setValue(false); + Ext.getCmp('cb-pteridophytes-cf').setValue(false); + } + if(Ext.getCmp('combo-fiche-taxon')){Ext.getCmp('combo-fiche-taxon').clearValue();} + comboTaxonsFiltre(); + } + ,render: function(c) { + Ext.QuickTips.register({ + target: c.getEl(), + text: 'Affiche les bryophytes dans la liste si la case est cochée.' + }); + } + } + } + ] + },{ + id:'checkboxgroup-patri-cf' + ,xtype: 'checkboxgroup' + ,fieldLabel: 'Patrimonialité' + ,itemCls:'graytext' + ,items: [{ + id:'cb-patri-cf' + ,boxLabel: ' Patrimoniaux seulement' + ,name: 'cb-patri' + ,checked: false + ,cls:'graytext' + ,itemCls:'graytext' + ,listeners: { + check: function(checkbox,checked) { + comboTaxonsFiltre(); + if(Ext.getCmp('combo-fiche-taxon')){Ext.getCmp('combo-fiche-taxon').clearValue();} + } + ,render: function(c) { + Ext.QuickTips.register({ + target: c.getEl(), + text: 'Filtrer la liste avec uniquement les taxons patrimoniaux.' + }); + } + } + } + ] + },{ + id:'checkboxgroup-couleur-cf' + ,xtype: 'checkboxgroup' + ,fieldLabel: 'A rechercher' + ,cls:'graytext' + ,itemCls:'graytext' + ,items: [{ + id:'cb-red-cf' + ,boxLabel: 'Priorité' + ,name: 'cb-red' + ,itemCls:'redtext' + ,checked: true + ,listeners: { + check: function(checkbox,checked) { + comboTaxonsFiltre(); + if(Ext.getCmp('combo-fiche-taxon')){Ext.getCmp('combo-fiche-taxon').clearValue();} + } + ,render: function(c) { + Ext.QuickTips.register({ + target: c.getEl(), + text: 'Taxons à saisir ou rechercher dans cette unité géographique.' + }); + } + } + },{ + id:'cb-orange-cf' + ,boxLabel: 'Nouveau' + ,name: 'cb-orange' + ,itemCls:'orangetext' + ,checked: true + ,listeners: { + check: function(checkbox,checked) { + comboTaxonsFiltre(); + if(Ext.getCmp('combo-fiche-taxon')){Ext.getCmp('combo-fiche-taxon').clearValue();} + } + ,render: function(c) { + Ext.QuickTips.register({ + target: c.getEl(), + text: 'Taxons jamais observés dans dans cette unité géographique.' + }); + } + } + },{ + id:'cb-gray-cf' + ,boxLabel: 'Facultatif' + ,name: 'cb-gray' + ,itemCls:'graytext' + ,checked: true + ,listeners: { + check: function(checkbox,checked) { + comboTaxonsFiltre(); + if(Ext.getCmp('combo-fiche-taxon')){Ext.getCmp('combo-fiche-taxon').clearValue();} + } + ,render: function(c) { + Ext.QuickTips.register({ + target: c.getEl(), + text: 'La saisie est facultative pour ces taxons dans cette unité géographique.' + }); + } + } + } + ] + ,listeners: { + afterrender: function(checkboxg) { + comboTaxonsFiltre(); + } + } + },{ + xtype: 'line' + },{ + id:'combo-fiche-taxon' + ,xtype:'twintriggercombo' + ,tpl: '
{nom_francais} ({nb_obs}) - {derniere_date}
' + ,fieldLabel: 'Taxon ' + ,name: 'id_taxon' + ,hiddenName:"id_taxon" + ,store: storeTaxonsCf + ,valueField: "id_taxon" + ,displayField: "nom_francais" + ,allowBlank:false + ,typeAhead: true + ,typeAheadDelay:750 + ,forceSelection: true + ,selectOnFocus: true + ,editable: true + ,resizable:true + ,listWidth: 300 + ,triggerAction: 'all' + ,trigger3Class: 'x-form-zoomto-trigger x-hidden' + ,mode: 'local' + ,listeners: { + select: function(combo, record) { + Ext.getCmp('grid-taxons').getSelectionModel().getSelected().set('nom_francais',record.data.nom_francais); + Ext.getCmp('grid-taxons').getSelectionModel().getSelected().set('nom_latin',record.data.nom_latin); + Ext.getCmp('grid-taxons').getSelectionModel().getSelected().set('id_taxon',combo.getValue()); + Ext.getCmp('grid-taxons').getSelectionModel().getSelected().set('id_classe',record.data.id_classe); + Ext.getCmp('grid-taxons').getSelectionModel().getSelected().set('denombrement',record.data.denombrement); + Ext.getCmp('grid-taxons').getSelectionModel().getSelected().set('patrimonial',record.data.patrimonial); + Ext.getCmp('grid-taxons').getSelectionModel().getSelected().set('cd_ref_origine',record.data.cd_ref); + Ext.getCmp('grid-taxons').getSelectionModel().getSelected().set('nom_taxon_saisi','Saisie en cours'); + Ext.getCmp('grid-taxons').getSelectionModel().getSelected().set('id_abondance_cflore',null); + Ext.getCmp('combo-fiche-abondance').clearValue(); + Ext.getCmp('grid-taxons').getSelectionModel().getSelected().set('id_phenologie_cflore',null); + Ext.getCmp('combo-fiche-phenologie').clearValue(); + Ext.getCmp('grid-taxons').getSelectionModel().getSelected().set('validite_cflore',default_validite_cflore); + Ext.getCmp('cb-validite').setValue(default_validite_cflore); + Ext.getCmp('grid-taxons').getSelectionModel().getSelected().set('herbier',false); + Ext.getCmp('cb-herbier').setValue(false); + Ext.getCmp('ta-fiche-commentaire').setValue(''); + Ext.getCmp('grid-taxons').getSelectionModel().getSelected().set('commentaire',null); + Ext.getCmp('ta-fiche-determinateur').setValue(''); + Ext.getCmp('grid-taxons').getSelectionModel().getSelected().set('determinateur',null); + manageValidationTaxon(isValidTaxon(record));//puisque le critère est obligatoire et qu'on vient de le vider + Ext.getCmp('fieldset-abondance').expand(); + Ext.getCmp('combo-fiche-abondance').setWidth(200);//debug sinon le combo apparait avec une largeur ridicule + Ext.getCmp('combo-fiche-abondance').syncSize();//debug sinon le combo apparait avec une largeur ridicule + } + ,change: function(combo, record) { + Ext.getCmp('combo-fiche-abondance').clearValue(); + if(record.data){ + manageValidationTaxon(isValidTaxon(record)); + } + } + ,afterrender: function(combo, record) { + comboTaxonsFiltre(); + combo.keyNav.tab = function() { // Override TAB handling function + this.onViewClick(false); // Select the currently highlighted row + }; + } + ,clear: function(combo, record) { + if(Ext.getCmp('grid-taxons').getSelectionModel().getSelected()){ + Ext.getCmp('grid-taxons').getSelectionModel().getSelected().set('nom_francais',null); + Ext.getCmp('grid-taxons').getSelectionModel().getSelected().set('nom_latin',null); + Ext.getCmp('grid-taxons').getSelectionModel().getSelected().set('id_taxon',null); + Ext.getCmp('grid-taxons').getSelectionModel().getSelected().set('id_classe',null); + Ext.getCmp('grid-taxons').getSelectionModel().getSelected().set('patrimonial',false); + Ext.getCmp('grid-taxons').getSelectionModel().getSelected().set('cd_ref_origine',null); + Ext.getCmp('grid-taxons').getSelectionModel().getSelected().set('nom_taxon_saisi','Saisie en cours'); + Ext.getCmp('combo-fiche-abondance').clearValue(); + Ext.getCmp('grid-taxons').getSelectionModel().getSelected().set('id_abondance_cflore',null); + Ext.getCmp('combo-fiche-phenologie').clearValue(); + Ext.getCmp('grid-taxons').getSelectionModel().getSelected().set('id_phenologie_cflore',null); + Ext.getCmp('cb-validite').setValue(default_validite_cflore); + Ext.getCmp('grid-taxons').getSelectionModel().getSelected().set('validite_cflore',default_validite_cflore); + Ext.getCmp('grid-taxons').getSelectionModel().getSelected().set('herbier',false); + Ext.getCmp('cb-herbier').setValue(false); + Ext.getCmp('ta-fiche-commentaire').setValue(''); + Ext.getCmp('grid-taxons').getSelectionModel().getSelected().set('commentaire',null); + Ext.getCmp('ta-fiche-determinateur').setValue(''); + Ext.getCmp('grid-taxons').getSelectionModel().getSelected().set('determinateur',null); + Ext.getCmp('fieldset-abondance').collapse(); + Ext.getCmp('fieldset-phenologie').collapse(); + Ext.getCmp('fieldset-validite').collapse(); + Ext.getCmp('fieldset-herbier').collapse(); + Ext.getCmp('fieldset-commentaire').collapse(); + Ext.getCmp('fieldset-determinateur').collapse(); + manageValidationTaxon(isValidTaxon(Ext.getCmp('grid-taxons').getSelectionModel().getSelected())); + } + } + } + } + ] + },{ + xtype:'fieldset' + ,id:'fieldset-abondance' + ,columnWidth: 1 + ,title: 'Définir l\'abondance' + ,collapsible: true + ,collapsed: true + ,autoHeight:true + ,anchor:'100%' + ,items :[ + { + id:'combo-fiche-abondance' + ,xtype:'twintriggercombo' + ,fieldLabel: 'Abondance ' + ,name: 'id_abondance_cflore' + ,hiddenName:"id_abondance_cflore" + ,store: abondancesStore + ,valueField: "id_abondance_cflore" + ,displayField: "nom_abondance_cflore" + ,allowBlank:false + ,typeAhead: true + ,forceSelection: true + ,selectOnFocus: true + ,editable: true + ,resizable:true + ,listWidth: 300 + ,typeAheadDelay:750 + ,triggerAction: 'all' + ,trigger3Class: 'x-form-zoomto-trigger x-hidden' + ,mode: 'local' + ,listeners: { + select: function(combo, record) { + Ext.getCmp('grid-taxons').getSelectionModel().getSelected().set('id_abondance_cflore',combo.getValue()); + Ext.getCmp('fieldset-phenologie').expand(); + Ext.getCmp('combo-fiche-phenologie').setWidth(200);//debug sinon le combo apparait avec une largeur ridicule + Ext.getCmp('combo-fiche-phenologie').syncSize();//debug sinon le combo apparait avec une largeur ridicule + manageValidationTaxon(isValidTaxon(Ext.getCmp('grid-taxons').getSelectionModel().getSelected())); + } + ,change: function(combo, record) { + manageValidationTaxon(isValidTaxon(Ext.getCmp('grid-taxons').getSelectionModel().getSelected())); + } + ,clear: function(combo, record) { + manageValidationTaxon(isValidTaxon(Ext.getCmp('grid-taxons').getSelectionModel().getSelected())); + } + ,afterrender: function(combo, record) { + combo.keyNav.tab = function() { // Override TAB handling function + this.onViewClick(false); // Select the currently highlighted row + }; + } + } + } + ] + },{ + xtype:'fieldset' + ,id:'fieldset-phenologie' + ,columnWidth: 1 + ,title: 'Définir la phénologie' + ,collapsible: true + ,collapsed: true + ,autoHeight:true + ,anchor:'100%' + ,items :[ + { + id:'combo-fiche-phenologie' + ,xtype:'twintriggercombo' + ,fieldLabel: 'Phénologie ' + ,name: 'id_phenologie_cflore' + ,hiddenName:"id_phenologie_cflore" + ,store: phenologiesStore + ,valueField: "id_phenologie_cflore" + ,displayField: "nom_phenologie_cflore" + ,allowBlank:false + ,typeAhead: true + ,forceSelection: true + ,selectOnFocus: true + ,editable: true + ,resizable:true + ,listWidth: 300 + ,typeAheadDelay:750 + ,triggerAction: 'all' + ,trigger3Class: 'x-form-zoomto-trigger x-hidden' + ,mode: 'local' + ,listeners: { + select: function(combo, record) { + Ext.getCmp('grid-taxons').getSelectionModel().getSelected().set('id_phenologie_cflore',combo.getValue()); + Ext.getCmp('fieldset-validite').expand(); + manageValidationTaxon(isValidTaxon(Ext.getCmp('grid-taxons').getSelectionModel().getSelected())); + } + ,change: function(combo, record) { + manageValidationTaxon(isValidTaxon(Ext.getCmp('grid-taxons').getSelectionModel().getSelected())); + } + ,clear: function(combo, record) { + manageValidationTaxon(isValidTaxon(Ext.getCmp('grid-taxons').getSelectionModel().getSelected())); + } + ,afterrender: function(combo, record) { + combo.keyNav.tab = function() { // Override TAB handling function + this.onViewClick(false); // Select the currently highlighted row + }; + } + } + } + ] + },{ + xtype:'fieldset' + ,id:'fieldset-validite' + ,columnWidth: 1 + ,title: label_validite + ,collapsible: true + ,collapsed: true + ,hidden:!(application.synthese.user.statuscode >= 5 && use_validite_cflore) + ,autoHeight:true + ,anchor:'100%' + ,items :[ + { + id:'cb-validite' + ,xtype:'checkbox' + ,fieldLabel: label_validite + ,name: 'validite_cflore' + ,inputValue: true + ,checked: false + ,listeners: { + check: function(checkbox,checked) { + if(checked){ + Ext.getCmp('grid-taxons').getSelectionModel().getSelected().set('validite_cflore',true); + } + else{ + Ext.getCmp('grid-taxons').getSelectionModel().getSelected().set('validite_cflore',false); + } + Ext.getCmp('fieldset-herbier').expand(); + manageValidationTaxon(isValidTaxon(Ext.getCmp('grid-taxons').getSelectionModel().getSelected())); + } + ,render: function(c) { + Ext.QuickTips.register({ + target: c.getEl(), + text: tooltip_validite + }); + } + } + } + ] + },{ + xtype:'fieldset' + ,id:'fieldset-herbier' + ,columnWidth: 1 + ,title: 'Mise en herbier' + ,collapsible: true + ,collapsed: true + ,autoHeight:true + ,anchor:'100%' + ,items :[{ + id:'cb-herbier' + ,xtype:'checkbox' + ,fieldLabel: 'Mise en herbier' + ,name: 'herbier' + ,inputValue: true + ,checked: false + ,listeners: { + check: function(checkbox,checked) { + if(checked){ + Ext.getCmp('grid-taxons').getSelectionModel().getSelected().set('herbier',true); + var commentValue = Ext.getCmp('ta-fiche-commentaire').getValue(); + if(commentValue == null || commentValue == ''){ + Ext.getCmp('ta-fiche-commentaire').markInvalid('En cas de mise en herbier, un commentaire est obligatoire.'); + } + } + else{ + Ext.getCmp('grid-taxons').getSelectionModel().getSelected().set('herbier',false); + Ext.getCmp('ta-fiche-commentaire').validate(); + } + Ext.getCmp('fieldset-commentaire').expand(); + manageValidationTaxon(isValidTaxon(Ext.getCmp('grid-taxons').getSelectionModel().getSelected())); + } + ,render: function(c) { + Ext.QuickTips.register({ + target: c.getEl(), + text: 'Cochez si vous avez prélevé la plante ou une partie de la plante pour mise en herbier.' + }); + } + } + }] + },{ + xtype:'fieldset' + ,id:'fieldset-commentaire' + ,columnWidth: 1 + ,title: 'Commentaire concernant le taxon (facultatif)' + ,collapsible: true + ,collapsed: true + ,autoHeight:true + ,anchor:'100%' + ,items :[{ + id:'ta-fiche-commentaire' + ,xtype: 'textarea' + ,fieldLabel: 'Commentaire ' + ,name: 'commentaire' + ,grow:true + ,autoHeight: true + ,height:'auto' + ,anchor:'100%' + ,enableKeyEvents:true + ,listeners: { + render: function(c) { + Ext.QuickTips.register({ + target: c.getEl(), + text: 'Indiquer ici un éventuel commentaire concernant ce taxon.' + }); + } + ,keyup: function(field) { + Ext.getCmp('grid-taxons').getSelectionModel().getSelected().set('commentaire',field.getValue()); + manageValidationTaxon(isValidTaxon(Ext.getCmp('grid-taxons').getSelectionModel().getSelected())); + } + } + } + ] + },{ + xtype:'fieldset' + ,id:'fieldset-determinateur' + ,columnWidth: 1 + ,title: 'Déterminateur du taxon (facultatif)' + ,collapsible: true + ,collapsed: true + ,autoHeight:true + ,anchor:'100%' + ,items :[{ + id:'ta-fiche-determinateur' + ,xtype: 'textarea' + ,fieldLabel: 'Déterminateur ' + ,name: 'determinateur' + ,grow:true + ,autoHeight: true + ,height:'auto' + ,anchor:'100%' + ,enableKeyEvents:true + ,listeners: { + render: function(c) { + Ext.QuickTips.register({ + target: c.getEl(), + text: 'Indiquer ici le determinateur de ce taxon.' + }); + } + ,keyup: function(field) {Ext.getCmp('grid-taxons').getSelectionModel().getSelected().set('determinateur',field.getValue());} + } + } + ] + } + ,validTaxonButton + ,{xtype: 'label',id: 'error-message',cls: 'errormsg',text:''} + ,addTaxonButton + ,{ + xtype:'hidden' + ,name: 'monactiontaxon' + ,value:'update' + },{ + xtype:'hidden' + ,name: 'cd_ref_origine' + },{ + xtype:'hidden' + ,name: 'nom_taxon_saisi' + } + ] + },{ + columnWidth: 0.4 + ,layout: 'fit' + ,items:[{ + xtype: 'grid' + ,id:'grid-taxons' + ,store: relevesStore + ,cm: colModel + ,stripeRows: true + ,sm: new Ext.grid.RowSelectionModel({ + singleSelect: true + ,listeners: { + rowselect: function(sm, row, rec) { + Ext.getCmp('edit-fiche-form').getForm().loadRecord(rec); + if(rec.data.nom_taxon_saisi=='Saisie en cours'){ + if(Ext.getCmp('combo-fiche-taxon').getValue()==null){ + Ext.getCmp('fieldset-abondance').collapse(); + Ext.getCmp('fieldset-phenologie').collapse(); + Ext.getCmp('fieldset-validite').collapse(); + Ext.getCmp('fieldset-herbier').collapse(); + Ext.getCmp('fieldset-commentaire').collapse(); + Ext.getCmp('fieldset-determinateur').collapse(); + } + else{ + Ext.getCmp('fieldset-abondance').expand(); + Ext.getCmp('combo-fiche-abondance').setWidth(200);//debug sinon le combo apparait avec une largeur ridicule + Ext.getCmp('combo-fiche-abondance').syncSize(); + } + if(Ext.getCmp('combo-fiche-abondance').getValue()==null){ + Ext.getCmp('fieldset-phenologie').collapse(); + Ext.getCmp('fieldset-validite').collapse(); + Ext.getCmp('fieldset-herbier').collapse(); + Ext.getCmp('fieldset-commentaire').collapse(); + Ext.getCmp('fieldset-determinateur').collapse(); + } + else{ + Ext.getCmp('fieldset-phenologie').expand(); + Ext.getCmp('combo-fiche-phenologie').setWidth(200);//debug sinon le combo apparait avec une largeur ridicule + Ext.getCmp('combo-fiche-phenologie').syncSize(); + Ext.getCmp('fieldset-validite').expand(); + if(Ext.getCmp('cb-herbier').getValue()==false){Ext.getCmp('fieldset-herbier').collapse();} + else{Ext.getCmp('fieldset-herbier').expand();} + if(Ext.getCmp('ta-fiche-commentaire').getValue()==''){Ext.getCmp('fieldset-commentaire').collapse();} + else{Ext.getCmp('fieldset-commentaire').expand();} + if(Ext.getCmp('ta-fiche-determinateur').getValue()==''){Ext.getCmp('fieldset-determinateur').collapse();} + else{Ext.getCmp('fieldset-determinateur').expand();} + } + } + else{ + Ext.getCmp('fieldset-abondance').expand(); + Ext.getCmp('fieldset-phenologie').expand(); + Ext.getCmp('fieldset-validite').expand(); + Ext.getCmp('combo-fiche-abondance').setWidth(200);//debug sinon le combo apparait avec une largeur ridicule + Ext.getCmp('combo-fiche-abondance').syncSize(); + Ext.getCmp('combo-fiche-phenologie').setWidth(200);//debug sinon le combo apparait avec une largeur ridicule + Ext.getCmp('combo-fiche-phenologie').syncSize(); + if(Ext.getCmp('cb-herbier').getValue()==false){Ext.getCmp('fieldset-herbier').collapse();} + else{Ext.getCmp('fieldset-herbier').expand();} + if(Ext.getCmp('ta-fiche-commentaire').getValue()==''){Ext.getCmp('fieldset-commentaire').collapse();} + else{Ext.getCmp('fieldset-commentaire').expand();} + if(Ext.getCmp('ta-fiche-determinateur').getValue()==''){Ext.getCmp('fieldset-determinateur').collapse();} + else{Ext.getCmp('fieldset-determinateur').expand();} + } + } + ,selectionchange: function(sm) { + if(Ext.getCmp('edit-fiche-form').getForm().findField('monactiontaxon').getValue()=='add'){ + Ext.getCmp('edit-fiche-form').getForm().findField('monactiontaxon').setValue('update'); + } + if(sm.getSelected()){manageValidationTaxon(isValidTaxon(sm.getSelected()));} + + } + } + }) + ,viewConfig: { + // Return CSS class to apply to rows depending upon data values + getRowClass: function(r, index) { + var patri = r.get('patrimonial'); + if(patri){return 'gras';} + } + } + ,autoExpandColumn: 'taxonsaisi' + ,height: 350 + ,border: true + ,listeners: { + viewready: function(g) { + g.getSelectionModel().selectRow(0); + } // Allow rows to be rendered. + } + } + ] + }//fin du collum2 + ]//fin du item + ,listeners: { + afterlayout: function(g) { + Ext.getCmp('grid-taxons').getSelectionModel().selectRow(0); + } + } + });//fin du gridForm + return [gridForm]; + };//Fin du getFormTaxons + + /** + * Method: createLayer + * Creates the vector layer + * + * Return + * + */ + var createLayer = function() { + var styleMap = new OpenLayers.StyleMap({ + 'default': { + fillColor: "red" + ,strokeColor: "#ff6666" + ,cursor: "pointer" + ,fillOpacity: 0.7 + ,strokeOpacity: 1 + ,strokeWidth: 2 + ,pointRadius: 7 + } + ,select : { + fillColor: "blue" + ,strokeColor: "blue" + ,cursor: "pointer" + ,fillOpacity: 0.5 + ,strokeOpacity: 1 + ,strokeWidth: 3 + ,pointRadius: 8 + } + }); + vectorLayer = new OpenLayers.Layer.Vector("editCflore vector layer" + ,{ + protocol: eventProtocol + ,strategies: [ + new mapfish.Strategy.ProtocolListener() + ] + ,styleMap: styleMap + ,format: OpenLayers.Format.GeoJSON + } + ); + vectorLayer.events.on({ + featureadded: function(obj) { + var feature = obj.feature; + if(map.getZoom()<15){ + vectorLayer.removeFeatures(feature); + zoomin.activate();// on active le bouton pour zoomer + Ext.ux.Toast.msg('Echelle de saisie inadaptée', 'Vous ne pouvez pas pointer à cette échelle.
Merci de zoomer jusqu\'à la carte au 1/25 000ème.'); + return false; //la fonction s'arrête là + } + if(vectorLayer.features[1]){vectorLayer.removeFeatures(vectorLayer.features[0])};//s'il y a déjà une géométrie, on la supprime pour ne garder que celle qui vient d'être ajoutée + activateControls(true); + updateGeometryField(feature); + Ext.getCmp('edit-fiche-form').enable(); + Ext.getCmp('edit-fiche-form').ownerCt.ownerCt.doLayout(); + Ext.getCmp('edit-fiche-form').getForm().findField('ids_observateurs').setValue(Ext.getCmp('combo-fiche-observateurs').getValue()); + myProxyTaxons.url = 'bibs/taxonscfloreu?point='+Ext.getCmp('edit-fiche-form').getForm().findField('geometry').getValue(); + Ext.getCmp('combo-fiche-taxon').getStore().reload(); + if(!firstAltitudeLoad){application.synthese.editCflore.findZ(feature);} + firstAltitudeLoad = false; + } + ,featuremodified: function(obj) { + updateGeometryField(obj.feature); + myProxyTaxons.url = 'bibs/taxonscfloreu?point='+Ext.getCmp('edit-fiche-form').getForm().findField('geometry').getValue(); + Ext.getCmp('combo-fiche-taxon').getStore().reload(); + } + ,featureremoved: function(obj) { + updateGeometryField(null); + Ext.getCmp('edit-fiche-form').disable(); + } + }); + }; + + /** + * Method: createMap + * Creates the map + * + * Return + * + */ + var createMap = function() { + map = application.synthese.createMap(); + map.getLayersByName('overlay')[0].mergeNewParams({ + id_cflore:id_cflore + }); + createLayer(); + map.addLayers([vectorLayer]); + map.zoomToMaxExtent(); + maProjection = map.getProjectionObject(); + }; + + /** + * Method: initToolbarItems + * Creates the map toolbar + */ + var initToolbarItems = function() { + if (!toolbarInitializedOnce) { + toolbar.addControl( + new OpenLayers.Control.ZoomToMaxExtent({ + map: map, + title: 'Revenir à l\'échelle maximale' + }), { + iconCls: 'zoomfull', + toggleGroup: this.id + } + ); + + application.synthese.utils.addSeparator(toolbar); + + var history = new OpenLayers.Control.NavigationHistory(); + map.addControl(history); + toolbar.addControl(history.previous, { + iconCls: 'previous' + ,toggleGroup: 'navigation' + ,tooltip: 'Etendue précédente' + ,handler: function() { + syntheseListGrid.getView().refresh(); + } + }); + + toolbar.addControl( + zoomin = new OpenLayers.Control.ZoomBox({ + title: 'Zoomer' + }), { + iconCls: 'zoomin', + toggleGroup: this.id + } + ); + + toolbar.addControl( + new OpenLayers.Control.ZoomBox({ + out: true, + title: 'Dézoomer' + }), { + iconCls: 'zoomout', + toggleGroup: this.id + } + ); + + toolbar.addControl( + dragPanControl = new OpenLayers.Control.DragPan({ + isDefault: true, + title: 'Déplacer la carte' + }), { + iconCls: 'pan', + toggleGroup: this.id + } + ); + + application.synthese.utils.addSeparator(toolbar); + + toolbar.addControl( + drawPointControl = new OpenLayers.Control.DrawFeature(vectorLayer, OpenLayers.Handler.Point, { + title: 'Localiser l\'observation (supprime la localisation existante s\'il y en a une)' + }), { + iconCls: 'drawpoint' + ,toggleGroup: this.id + ,disabled: true + } + ); + + toolbar.add({ + text: 'GPS' + ,id: 'edit-fiche-gps' + ,tooltip: 'Positionner l\'observation sur la carte à partir de coordonnées GPS en UTM' + ,handler: function() { + vectorLayer.removeFeatures(vectorLayer.features[0]); + application.synthese.editCflore.initGpsWindow(); + } + }); + + layerTreeTip = application.synthese.createLayerWindow(map); + layerTreeTip.render(Ext.getCmp('edit-fiche-mapcomponent').body); + layerTreeTip.show(); + layerTreeTip.getEl().alignTo( + Ext.getCmp('edit-fiche-mapcomponent').body, + "tl-tl", + [5, 5] + ); + layerTreeTip.hide(); + + application.synthese.utils.addSeparator(toolbar); + + toolbar.add({ + iconCls: 'legend' + ,enableToggle: true + ,tooltip: 'Gérer les couches affichées' + ,handler: function(button) { + showLayerTreeTip(button.pressed); + } + }); + + toolbar.activate(); + toolbarInitializedOnce = true; + } + }; + + /** + * Method: activateControls + * Allows to activate / enable / deactivate / disable the draw and modify feature controls + * + * Parameters: + * activateDrawControls - {Boolean} true to activate / enable the draw controls + */ + var activateControls = function(activateDrawControls) { + Ext.each([drawPointControl] + ,function(control) { + toolbar.getButtonForControl(control).setDisabled(!activateDrawControls); + if (!activateDrawControls) { + control.deactivate(); + } + } + ); + }; + + /** + * Method: deactivateAllEditingControls + */ + var deactivateAllEditingControls = function() { + toolbar.getButtonForControl(drawPointControl).setDisabled(true); + drawPointControl.deactivate(); + }; + + /** + * Method: updateGeometryField + * Updates the geometry field (hidden) in the form + * + * Parameters: + * geometry - {null|} Geometry + */ + var updateGeometryField = function(geometry) { + if (geometry == null) {wkt = '';} + else {var wkt = format.write(geometry);} + Ext.getCmp('edit-fiche-form').getForm().findField('geometry').setValue(wkt); + firstGeometryLoad = false; + }; + + /** + * Method: createProtocol + * Create the search protocol. + */ + var createProtocol = function() { + protocol = new mapfish.Protocol.MapFish({}); + eventProtocol = new mapfish.Protocol.TriggerEventDecorator({ + protocol: protocol + ,eventListeners: { + crudtriggered: function() { + } + ,crudfinished: function(response) { + var feature = response.features[0]; + //chargement des valeurs du formulaire + Ext.getCmp('edit-fiche-form').getForm().loadRecord(feature); + Ext.getCmp('fieldlabel-commune').setValue('Commune: '+feature.data.commune); + //on centre en limitant le zoom à 15 + var centerGeom = feature.geometry.getBounds().getCenterLonLat(); + map.setCenter(centerGeom,15); + Ext.getCmp('edit-fiche-form').enable(); + } + } + }); + }; + + /** + * Method: createStore + * Create the search result store. + */ + var createStore = function() { + store = new Ext.data.Store({ + reader: new mapfish.widgets.data.FeatureReader({}, [ + 'id_cflore' + ,'ids_observateurs' + ,{name:'dateobs', type: 'date', dateFormat:'d/m/Y'} + ,'commune' + ,'altitude' + ]) + ,listeners: { + load: function(store, records) { + Ext.getCmp('edit-fiche-form').getForm().loadRecord(records[0]); + } + } + }); + }; + + /** + * Method: resetWindow + * Reset the different items status (on close) for next usage + */ + var resetWindow = function() { + id_cflore = null; + vectorLayer.removeFeatures(vectorLayer.features); + Ext.getCmp('edit-fiche-form').getForm().reset(); + Ext.getCmp('edit-fiche-form').getForm().findField('monaction').setValue('add'); + Ext.getCmp('grid-taxons').getStore().removeAll(); + this.addNewTaxon(); + dragPanControl.activate(); + activateControls(true); + updateGeometryField(null); + Ext.getCmp('edit-fiche-form').disable(); + }; + + /** + * Method: constructStringTaxons + * Construct a multidimentional Array with all taxon informations + */ + var constructStringTaxons = function(){ + var arrayGlobal = []; + Ext.getCmp('grid-taxons').getStore().each(function(rec){ + var attrib = []; + var reg = new RegExp("(,)", "g"); + var val = null; + var key; + for (key in rec.data) { + if(typeof rec.data[key]==="string"){val = rec.data[key].replace(reg,'');} //gestion des virgules dans les commentaires + else{val = rec.data[key];} + attrib.push(val); + } + arrayGlobal.push(attrib); + }); + var taxons = arrayGlobal.join("|"); + return taxons; + }; + + /** + * Method: submitForm + * Submits the form + */ + var submitForm = function() { + Ext.getCmp('ficheSaveButton').setText('Enregistrement en cours...'); + var params = {}; + if (id_cflore) { + params.id_cflore = id_cflore; + } + params.sting_taxons = constructStringTaxons(); + Ext.getCmp('edit-fiche-form').getForm().submit({ + url: 'cflore/save' + ,params: params + ,success: function(form,action) { + Ext.getCmp('ficheSaveButton').setText('Enregistrer'); + if(Ext.getCmp('result_count').text=="les 50 dernières observations"){ + Ext.getCmp('hidden-start').setValue('yes'); + } + application.synthese.search.triggerSearch(); + toolbarInitializedOnce = false; + application.synthese.editCflore.window.destroy(); + } + ,failure: function(form, action) { + Ext.getCmp('ficheSaveButton').setText('Enregistrer'); + var msg; + switch (action.failureType) { + case Ext.form.Action.CLIENT_INVALID: + msg = "Les informations saisies sont invalides ou incomplètes. Vérifiez le formulaire (voir champs en rouge)."; + break; + case Ext.form.Action.CONNECT_FAILURE: + msg = "Erreur lors de l'enregistrement"; + break; + case Ext.form.Action.SERVER_INVALID: + msg = "Erreur lors de l'enregistrement : vérifiez les données saisies !"; + break; + } + Ext.Msg.show({ + title: 'Erreur' + ,msg: msg + ,buttons: Ext.Msg.OK + ,icon: Ext.MessageBox.ERROR + }); + } + }); + }; + + /** + * Method: showLayerTreeTip + * Shows or hide the layer tree tip + */ + var showLayerTreeTip = function(show) { + layerTreeTip.setVisible(show); + }; + + // public space + return { + window: null + ,init: function() { + createProtocol(); + createStore(); + this.window = initWindow(); + } + + /** + * Method: loadAp + * Loads a record from the aps list store + */ + ,loadFiche: function(fiche,action,cd) { + firstAltitudeLoad = true; + this.init(); + this.window.show(); + if (action=='update') { + Ext.getCmp('edit-fiche-form').getForm().findField('monaction').setValue('update'); + this.window.setTitle('Modification d\'une observation contact flore'); + if (fiche) { + id_cflore = fiche; + wmslayer = map.getLayersByName('overlay')[0]; + wmslayer.mergeNewParams({ + id_cflore: id_cflore + }); + var options = { + url: 'cflore/getone/'+id_cflore + ,params: {format: 'geoJSON'} + }; + eventProtocol.read(options); + myProxyReleves.url = 'cflore/listreleves/'+id_cflore; + Ext.getCmp('grid-taxons').getStore().reload(); + Ext.getCmp('grid-taxons').getSelectionModel().selectRow(0); + + } + } + } + + ,initGpsWindow: function() { + this.GpsWindow = Ext.ux.GpsLocation.initGpsWindow(vectorLayer); + this.GpsWindow.show(); + } + + //remplir l'altitude du champ altitude dans le formulaire selon le pointage + ,findZ : function(feature) { + //on recherche l'altitude avec l'API IGN + var geometryCentroid = feature.geometry.getCentroid(); + var latLonGeom = geometryCentroid.transform(new OpenLayers.Projection("EPSG:3857"), new OpenLayers.Projection("EPSG:4326")); + var script = document.createElement('script'); + script.src = String.format('//wxs.ign.fr/{0}/alti/rest/elevation.xml?lon={1}&lat={2}&output=json&zonly=true&callback=application.synthese.editCflore.handleIGNResponse', ign_api_key, latLonGeom.x, latLonGeom.y); + document.head.appendChild(script); + } + ,handleIGNResponse : function(data) { + var parser = new DOMParser(); + var xmlDoc = parser.parseFromString(data.xml, "text/xml"); + var s = xmlDoc.getElementsByTagName('z'); + if (s.length === 0 || Ext.isEmpty(s[0]) || Ext.isEmpty(s[0].innerHTML)) { + Ext.Msg.alert('Attention', "Un problème à été rencontré lors de l'appel au service de l'IGN."); + return; + } + Ext.ux.Toast.msg('Information !', 'Cette altitude est fournie par un service de l\'IGN.'); + application.synthese.editCflore.setAltitude(Math.round(s[0].innerHTML)); + } + ,setAltitude : function(alti) { + Ext.getCmp('fieldfiche-altitude').setValue(alti); + } + + ,changeLabel: function(fieldId, newLabel){ + var label = Ext.DomQuery.select(String.format('label[for="{0}"]', fieldId)); + if (label){ + label[0].childNodes[0].nodeValue = newLabel; + } + } + } +}(); diff --git a/web/js/synthese/application.synthese.editInvertebre.js b/web/js/synthese/application.synthese.editInvertebre.js index 2e1c5240cd..c3eeffaa01 100755 --- a/web/js/synthese/application.synthese.editInvertebre.js +++ b/web/js/synthese/application.synthese.editInvertebre.js @@ -137,7 +137,7 @@ application.synthese.editInvertebre = function() { // private functions /** - * Method: initViewport + * Method: initWindow */ var initWindow = function() { return new Ext.Window({ @@ -618,7 +618,8 @@ application.synthese.editInvertebre = function() { return true; }); return isValid; - }; + }; + var isValidTaxon = function(r){ var isValid = true; errorMsg = ''; @@ -768,7 +769,7 @@ application.synthese.editInvertebre = function() { ,title: 'Listes des taxons observés' ,bodyStyle:'padding:5px' ,width: 600 - ,layout: 'column' // Specifies that the items will now be arranged in columns + ,layout: 'column' // Specifies that the items will now be arranged in columns ,items: [{ columnWidth: 0.6 ,xtype: 'panel' @@ -974,7 +975,7 @@ application.synthese.editInvertebre = function() { ,name: 'cb-patri' ,checked: false ,cls:'graytext' - ,itemCls:'graytext' + ,itemCls:'graytext' ,listeners: { check: function(checkbox,checked) { comboTaxonsFiltre(); @@ -999,7 +1000,7 @@ application.synthese.editInvertebre = function() { id:'cb-red-inv' ,boxLabel: 'Priorité' ,name: 'cb-red' - ,itemCls:'redtext' + ,itemCls:'redtext' ,checked: true ,listeners: { check: function(checkbox,checked) { @@ -1030,13 +1031,13 @@ application.synthese.editInvertebre = function() { text: 'Taxons jamais observés dans cette unité géographique.' }); } - } + } },{ id:'cb-gray-inv' ,boxLabel: 'Facultatif' ,name: 'cb-gray' ,itemCls:'graytext' - ,checked: true + ,checked: true ,listeners: { check: function(checkbox,checked) { comboTaxonsFiltre(); @@ -1048,7 +1049,7 @@ application.synthese.editInvertebre = function() { text: 'La saisie est facultative pour ces taxons dans cette unité géographique.' }); } - } + } } ] ,listeners: { diff --git a/web/js/synthese/application.synthese.js b/web/js/synthese/application.synthese.js index c8249a6607..80a96ea727 100755 --- a/web/js/synthese/application.synthese.js +++ b/web/js/synthese/application.synthese.js @@ -171,6 +171,18 @@ application.synthese = function() { } ,autoLoad:true }) + ,storeObservateursCfloreAdd: new Ext.data.JsonStore({ + url: 'bibs/observateurs' + ,fields: [ + 'id_role' + ,{name:'auteur',sortType: Ext.data.SortTypes.asAccentuatedString} + ] + ,sortInfo: { + field: 'auteur' + ,direction: 'ASC' + } + ,autoLoad:true + }) ,storeMilieuxInv: new Ext.data.JsonStore({ url: 'bibs/milieuxinv' ,fields: [ diff --git a/web/js/synthese/application.synthese.search.js b/web/js/synthese/application.synthese.search.js index 75cf9af0b2..0be4fa0018 100755 --- a/web/js/synthese/application.synthese.search.js +++ b/web/js/synthese/application.synthese.search.js @@ -640,6 +640,7 @@ application.synthese.search = function() { if(record.data.id_source==id_source_contactfaune&&record.data.id_protocole==id_protocole_contact_vertebre){application.synthese.editCf.loadFiche(id_fiche,'update',null);} if(record.data.id_source==id_source_mortalite&&record.data.id_protocole==id_protocole_mortalite){application.synthese.editMortalite.loadFiche(id_fiche,'update',null);} if(record.data.id_source==id_source_contactinv){application.synthese.editInvertebre.loadFiche(id_fiche,'update',null);} + if(record.data.id_source==id_source_contactflore){application.synthese.editCflore.loadFiche(id_fiche,'update',null);} } } }] @@ -674,6 +675,7 @@ application.synthese.search = function() { if(record.data.id_source==id_source_contactfaune&&record.data.id_protocole==id_protocole_contact_vertebre){application.synthese.search.deleteReleveCf(id_releve, record.data.taxon_francais);} if(record.data.id_source==id_source_mortalite&&record.data.id_protocole==id_protocole_mortalite){application.synthese.search.deleteReleveCf(id_releve, record.data.taxon_francais);} if(record.data.id_source==id_source_contactinv){application.synthese.search.deleteReleveInv(id_releve, record.data.taxon_latin);} + if(record.data.id_source==id_source_contactflore){application.synthese.search.deleteReleveCflore(id_releve, record.data.taxon_latin);} } } } @@ -767,7 +769,7 @@ application.synthese.search = function() { if(record){ var code = record.data.code_fiche_source; var id_source = record.data.id_source; - if(code!='' && code!=null && (id_source==id_source_contactfaune || id_source==id_source_contactinv || id_source==id_source_mortalite)){ + if(code!='' && code!=null && (id_source==id_source_contactfaune || id_source==id_source_contactflore || id_source==id_source_contactinv || id_source==id_source_mortalite)){ var reg=new RegExp("[-]+", "g"); var tableau=code.split(reg); var id_fiche = tableau[0].substr(1,20); @@ -782,6 +784,9 @@ application.synthese.search = function() { if(id_source==id_source_contactinv&&id_protocole==id_protocole_contact_invertebre&&record.data.edit_ok){ application.synthese.editInvertebre.loadFiche(id_fiche,'update',null); } + if(id_source==id_source_contactflore&&id_protocole==id_protocole_contact_flore&&record.data.edit_ok){ + application.synthese.editCflore.loadFiche(id_fiche,'update',null); + } if(!record.data.edit_ok){Ext.ux.Toast.msg('Non, non, non !', 'Vous devez être l\'auteur de cette observation ou administrateur pour la modifier.');} } else{Ext.ux.Toast.msg('Donnée ancienne', 'Cette observation n\'est pas modifiable.');} @@ -2402,6 +2407,22 @@ application.synthese.search = function() { } }); } + ,deleteReleveCflore: function(id, taxon) { + var params = {}; + if (id) {params.id_releve_cflore = id;} + Ext.Ajax.request({ + url : 'cflore/deletereleve' + ,method: 'POST' + ,params: params + ,success: function (result, request) { + Ext.ux.Toast.msg('Suppression !', 'L\'observation de "'+taxon+'" a été supprimée.'); + formSearcher.triggerSearch(); + } + ,failure: function (result, request) { + Ext.MessageBox.alert('Erreur lors de la suppression'); + } + }); + } ,addGml: function() { this.initWindowUploadShp(); }