Subversion Repositories eFlore/Applications.cel

Compare Revisions

Ignore whitespace Rev 1214 → Rev 1215

/branches/v1.5-cisaille/widget/modules/saisie/Saisie.php
25,6 → 25,7
const WS_SAISIE = "CelWidgetSaisie";
const WS_NOM = "noms";
const NS_PROJET = "bdtfx";
const NS_PROJET_VERSION = "1.01";
const EFLORE_API_VERSION = "0.1";
 
private $projet = null;
82,10 → 83,13
$widget['donnees']['url_base'] = sprintf($this->config['chemins']['baseURLAbsoluDyn'], '');
$widget['donnees']['url_ws_saisie'] = sprintf($this->config['chemins']['baseURLServicesCelTpl'], self::WS_SAISIE);
 
 
if ($this->projet == 'defaut') {
$urlWsNsTpl = $this->config['chemins']['baseURLServicesEfloreTpl'];
$urlWsNs = sprintf($urlWsNsTpl, self::EFLORE_API_VERSION, self::NS_PROJET, self::WS_NOM);
$widget['donnees']['url_ws_autocompletion_ns'] = $urlWsNs;
$widget['donnees']['ns_referentiel'] = self::NS_PROJET.':'.self::NS_PROJET_VERSION;
$widget['donnees']['ns_version'] = self::NS_PROJET_VERSION;
} else {
$widget['donnees']['taxons'] = $this->recupererListeTaxon();
$widget['donnees']['milieux'] = $this->parserMilieux();
/branches/v1.5-cisaille/widget/modules/saisie/squelettes/defaut/css/defaut.css
4,6 → 4,9
footer p{
text-align:center;
}
button img {
display:block;
}
/*+--------------------------------------------------------------------------------------------------------+*/
/* Générique */
.discretion {
22,9 → 25,24
#info-commune {
text-align:right;
}
.ns-retenu {
font-weight:bold;
}
/*+--------------------------------------------------------------------------------------------------------+*/
/* Correction style CSS Bootstrap */
.well {
margin-bottom: 5px;
padding: 4px;
}
.table thead th {
vertical-align:top;
border: 1px solid #DDDDDD !important;
}
.table tbody td.obs-action, .table tbody td.obs-miniature {
vertical-align:middle;
text-align:center;
}
.table tbody td.obs-miniature img {
max-width:100px;
max-height:100px;
}
/branches/v1.5-cisaille/widget/modules/saisie/squelettes/defaut/defaut.tpl.html
45,15 → 45,24
var DEBUG = <?=isset($_GET['debug']) ? 'true' : 'false'?>;
// La présence du parametre 'html5' dans l'URL enclenche les fonctions avancées HTML5
var HTML5 = <?=isset($_GET['html5']) ? 'true' : 'false'?>;
// La présence du parametre 'html5' dans l'URL enclenche les fonctions avancées HTML5
var PROJET_TAG = "<?=isset($_GET['tag-obs']) ? $_GET['tag-obs'] : 'WidgetSaisie'?>";
// URL du web service réalisant l'insertion des données dans la base du CEL.
var SERVICE_SAISIE_URL = "<?=$url_ws_saisie?>";
// Code du référentiel utilisé pour les nom scientifiques.
var NOM_SCI_REFERENTIEL = "<?=$ns_referentiel?>";
// Code de la version du référentiel utilisé pour les nom scientifiques.
var NOM_SCI_VERSION = "<?=$ns_version?>";
// Nombre d'élément dans les listes d'auto-complétion
var AUTOCOMPLETION_ELEMENTS_NBRE = 20;
// URL du web service permettant l'auto-complétion des noms scientifiques.
var SERVICE_AUTOCOMPLETION_NOM_SCI_URL = "<?=$url_ws_autocompletion_ns?>?"+
"masque={masque}&"+
"recherche=etendue&"+
"retour.format=min&"+
"retour.champs=nom_retenu,num_taxonomique,nom_retenu.id&"+
"navigation.limite=50";
"version.projet="+NOM_SCI_VERSION+"&"+
"navigation.limite="+AUTOCOMPLETION_ELEMENTS_NBRE;
console.log(SERVICE_AUTOCOMPLETION_NOM_SCI_URL);
// Squelette d'URL du web service d'eFlore fournissant les noms de communes.
var SERVICE_NOM_COMMUNE_URL = "http://www.tela-botanica.org/service:eflore:osm/0.1/nom-commune?lon={lon}&lat={lat}";
// URL du marqueur à utiliser dans la carte Google Map
271,22 → 280,32
<div id="zone-liste-obs" class="row-fluid">
<form action="#" class="well form-horizontal">
<div class="row-fluid">
<h2>Liste des observations à transmettre</h2>
<table id="liste-obs" class="table table-striped table-bordered table-condensed">
<h2>Liste des <span class="obs-nbre"></span> observations à transmettre</h2>
<table id="liste-obs" class="table table-bordered table-condensed">
<thead>
<tr>
<th><i class="icon-list illustration">&nbsp;</i>N&deg;</th>
<th><i class="icon-calendar illustration">&nbsp;</i>Date</th>
<th rowspan="3">Photo</th>
<th><i class="icon-leaf illustration">&nbsp;</i>Nom</th>
<th title="Latitude / Longitude"><i class="icon-map-marker">&nbsp;</i>Lat./Long.</th>
<th>Commune</th>
<th colspan="2">Commune (code INSEE) [<span title="Latitude / Longitude"><i class="icon-map-marker">&nbsp;</i>Lat./Long.</span>]</th>
<th rowspan="3">Notes</th>
<th rowspan="3"><i class="icon-trash icone">&nbsp;</i>Action</th>
</tr>
<tr>
<!-- Photo -->
<th rowspan="2"><i class="icon-calendar illustration">&nbsp;</i>Date</th>
<th>Lieu-dit</th>
<th>Station</th>
<th>Milieu</th>
<th>Photo</th>
<th>Notes</th>
<th><i class="icon-trash icone">&nbsp;</i>Action</th>
<!-- Notes -->
<!-- Action -->
</tr>
<tr>
<!-- N° -->
<!-- Photo -->
<!-- Nom scientifique & Date -->
<th colspan="2">Milieu</th>
<!-- Notes -->
<!-- Action -->
</tr>
</thead>
<tbody></tbody>
</table>
308,19 → 327,19
</div>
<!-- Messages d'erreur du formulaire-->
<div id="dialogue-bloquer-copier-coller" class="alert alert-error" style="display: none;" title="Information copier/coller">
<div id="dialogue-bloquer-copier-coller" style="display: none;" title="Information copier/coller">
<p>
Merci de ne pas copier/coller votre courriel.<br/>
La double saisie permet de vérifier l'absence d'erreurs.
</p>
</div>
<div id="dialogue-zero-obs" class="alert alert-info" style="display: none;" title="Information aucune observation">
<div id="dialogue-zero-obs" style="display: none;" title="Information aucune observation">
<p>Veuillez saisir des observations pour les transmettres.</p>
</div>
<div id="dialogue-obs-transaction" class="alert" style="display: none;" title="Transmission des observations"></div>
<div id="dialogue-obs-transaction" style="display: none;" title="Transmission des observations"></div>
<div id="dialogue-erreur" class="alert alert-error" style="display: none;" title="Erreur"></div>
<div id="dialogue-erreur" style="display: none;" title="Erreur"></div>
<div id="chargement" style="position:fixed;z-index:1000;top:0;left:0;height:100%;width:100%;background:#777;background:rgba(90,86,93,0.7);text-align:center;display:none;">
<div id="chargement-centrage" style="position:relative;width:30%;margin:0 auto;top:30%;">
/branches/v1.5-cisaille/widget/modules/saisie/squelettes/defaut/js/defaut.js
336,6 → 336,8
 
//+---------------------------------------------------------------------------------------------------------+
// FORMULAIRE
var obsNbre = 0;
 
$(document).ready(function() {
$("#prenom").bind("change", function(event) {
var prenom = new Array();
387,14 → 389,14
} else {
if ($(element).attr('id') == 'taxon') {
var warningClass = "control-group warning";
if ($("#taxon").data("selection") != $("#taxon").val()) {
$("#taxon").data("selection", "");
$("#taxon").data("nn", "");
if ($("#taxon").data("value") != $("#taxon").val()) {
$("#taxon").removeData();
$("#taxon").removeClass('ns-retenu');
if ($("#taxon").val() != '') {
$("#taxon-input-groupe").removeClass(validClass)
.removeClass(errorClass)
.addClass(warningClass);
this.showLabel(element, "Nom abscent du référentiel.");
this.showLabel(element, "Nom absent du référentiel.");
}
} else {
if ($("#taxon").val() != '') {
456,40 → 458,48
if (validerFormulaire() == true) {
//rassemble les obs dans un tableau html
obsNumero = obsNumero + 1;
obsNbre = obsNbre + 1;
$(".obs-nbre").text(obsNbre);
$("#liste-obs tbody").append(
'<tr id="obs'+obsNumero+'" class="obs">'+
'<td>'+obsNumero+'</td>'+
'<td>'+$("#date").val()+'</td>'+
'<tr id="obs'+obsNumero+'" class="obs obs'+obsNumero+'">'+
'<td rowspan="3" class="obs-miniature">'+ajouterImgMiniatureAuTransfert()+'</td>'+
'<td>'+$("#taxon").val()+'</td>'+
'<td>'+$("#latitude").val()+' / '+$("#longitude").val()+'</td>'+
'<td>'+$('#commune-nom').text()+' ('+$('#commune-code-insee').text()+')</td>'+
'<td colspan="2">'+$('#commune-nom').text()+' ('+$('#commune-code-insee').text()+') ['+$("#latitude").val()+' / '+$("#longitude").val()+']</td>'+
'<td rowspan="3">'+$("#notes").val()+'</td>'+
'<td rowspan="3" class="obs-action">'+
'<button class="supprimer-obs" value="'+obsNumero+'" title="Supprimer l\'observation '+obsNumero+'">'+
'<img src="'+SUPPRIMER_ICONE_URL+'"/></button>'+
'</td>'+
'</tr>'+
'<tr class="obs obs'+obsNumero+'">'+
'<td rowspan="2">'+$("#date").val()+'</td>'+
'<td>'+$('#lieudit').val()+'</td>'+
'<td>'+$('#station').val()+'</td>'+
'<td>'+$('#milieu').val()+'</td>'+
'<td class="obs-miniature">'+ajouterImgMiniatureAuTransfert()+'</td>'+
'<td>'+$("#notes").val()+'</td>'+
'<td><button class="supprimer-obs" value="'+obsNumero+'" title="Supprimer l\'observation '+obsNumero+'">'+
'<img src="'+SUPPRIMER_ICONE_URL+'"/></button></td>'+
'</tr>'+
'<tr class="obs obs'+obsNumero+'">'+
'<td colspan="2">'+$('#milieu').val()+'</td>'+
'</tr>');
//rassemble les obs dans #liste-obs
var numNomSel = $("#taxon").val();
$("#liste-obs").data('obsId'+obsNumero, {
'date' : $("#date").val(),
'num_nom_sel' : numNomSel,
'nom_sel' : taxons[numNomSel]['nom_sel'],
'nom_ret' : taxons[numNomSel]['nom_ret'],
'num_nom_ret' : taxons[numNomSel]['num_nom_ret'],
'num_taxon' : taxons[numNomSel]['num_taxon'],
'famille' : taxons[numNomSel]['famille'],
'nom_fr' : taxons[numNomSel]['nom_fr'],
'milieu' : $('input[name=milieu]:checked').val(),
'notes' : $("#notes").val(),
'nom_sel' : $("#taxon").val(),
'num_nom_sel' : $("#taxon").data("numNomSel"),
'nom_ret' : $("#taxon").data("nomRet"),
'num_nom_ret' : $("#taxon").data("numNomRet"),
'num_taxon' : $("#taxon").data("nt"),
'famille' : $("#taxon").data("famille"),
'referentiel' : NOM_SCI_REFERENTIEL,
'latitude' : $("#latitude").val(),
'longitude' : $("#longitude").val(),
'commune_nom' : $("#commune-nom").text(),
'commune_code_insee' : $("#commune-code-insee").text(),
'lieu_dit' : $("#rue").val(),
'station' : $("#rue_num_debut").val()+'-'+$("#rue_num_fin").val()+'-'+$("#rue_cote").val(),
'notes' : $("#notes").val(),
'lieu_dit' : $("#lieu_dit").val(),
'station' : $("#station").val(),
'milieu' : $("#milieu").val(),
//Ajout des champs images
'image_nom' : $("#miniature-img").attr('alt'),
'image_b64' : getB64ImgOriginal()
507,7 → 517,7
} else if ($("#saisie-obs").valid() == false) {
$("#dialogue-form-invalide").dialog();
} else {
observations['projet'] = 'Sauvages';
observations['projet'] = PROJET_TAG;
var utilisateur = new Object();
utilisateur.prenom = $("#prenom").val();
616,8 → 626,10
if (obsId == "Supprimer") {
obsId = $(this).attr("title");
}
obsNbre = obsNbre - 1;
$(".obs-nbre").text(obsNbre);
$('#obs'+obsId).remove();
$('.obs'+obsId).remove();
$("#liste-obs").removeData('obsId'+obsId);
}
 
634,7 → 646,6
 
//+---------------------------------------------------------------------------------------------------------+
// AUTO-COMPLÉTION Noms Scientifiques
var listeNomsScientifiques = new Object();
 
function ajouterAutocompletionNoms() {
$('#taxon').autocomplete({
641,7 → 652,8
source: function(requete, add){
// la variable de requête doit être vidée car sinon le parametre "term" est ajouté
requete = "";
$.getJSON(getUrlAutocompletionNomsSci($('#taxon').val()), requete, function(data) {
var url = getUrlAutocompletionNomsSci();
$.getJSON(url, requete, function(data) {
var suggestions = traiterRetourNomsSci(data);
add(suggestions);
});
648,13 → 660,19
},
html: true
});
$( "#taxon" ).bind("autocompleteselect", function(event, ui) {
$("#taxon").data("selection", ui.item.value);
$("#taxon").data("nn", ui.item.nn);
$("#taxon").data(ui.item);
if (ui.item.retenu == true) {
$("#taxon").addClass('ns-retenu');
} else {
$("#taxon").removeClass('ns-retenu');
}
});
}
 
function getUrlAutocompletionNomsSci(mots) {
function getUrlAutocompletionNomsSci() {
var mots = $('#taxon').val();
var url = SERVICE_AUTOCOMPLETION_NOM_SCI_URL.replace('{masque}', mots);
return url;
}
664,18 → 682,27
if (data.resultat != undefined) {
$.each(data.resultat, function(i, val) {
val.nn = i;
var nom = {};
if (suggestions.length >= 20) {
var nom = {label : '', value : '', nt : '', nomSel : '', nomSelComplet : '', numNomSel : '',
nomRet : '', numNomRet : '', famille : '', retenu : false
};
if (suggestions.length >= AUTOCOMPLETION_ELEMENTS_NBRE) {
nom.label = "...";
nom.value = $('#taxon').val();
nom.nn = "";
suggestions.push(nom);
return false;
} else {
nom.label = val.nom_sci;
nom.value = val.nom_sci;
nom.nn = val.nn;
listeNomsScientifiques[val.nom_sci] = val;
nom.nt = val.num_taxonomique;
nom.nomSel = val.nom_sci;
nom.nomSelComplet = val.nom_sci_complet;
nom.numNomSel = val.nn;
nom.nomRet = val.nom_retenu;
// TODO : remplacer val.nom_retenu par val.nom_retenu.libelle et réactiver nom_retenu.id
//nom.numNomRet = val.nom_retenu.id;
nom.famille = val.famille;
nom.retenu = (val.retenu == 'false') ? false : true;
suggestions.push(nom);
}
});
695,41 → 722,35
* Adaptation par Aurélien Peronnet pour la mise en gras des noms de taxons valides
*/
(function( $ ) {
 
var proto = $.ui.autocomplete.prototype,
initSource = proto._initSource;
 
function filter( array, term ) {
var matcher = new RegExp( $.ui.autocomplete.escapeRegex(term), "i" );
return $.grep( array, function(value) {
return matcher.test( $( "<div>" ).html( value.label || value.value || value ).text() );
var proto = $.ui.autocomplete.prototype,
initSource = proto._initSource;
function filter( array, term ) {
var matcher = new RegExp( $.ui.autocomplete.escapeRegex(term), "i" );
return $.grep( array, function(value) {
return matcher.test( $( "<div>" ).html( value.label || value.value || value ).text() );
});
}
$.extend( proto, {
_initSource: function() {
if ( this.options.html && $.isArray(this.options.source) ) {
this.source = function( request, response ) {
response( filter( this.options.source, request.term ) );
};
} else {
initSource.call( this );
}
},
_renderItem: function( ul, item) {
if (item.retenu == true) {
item.label = "<strong>"+item.label+"</strong>";
}
return $( "<li></li>" )
.data( "item.autocomplete", item )
.append( $( "<a></a>" )[ this.options.html ? "html" : "text" ]( item.label ) )
.appendTo( ul );
}
});
}
 
$.extend( proto, {
_initSource: function() {
if ( this.options.html && $.isArray(this.options.source) ) {
this.source = function( request, response ) {
response( filter( this.options.source, request.term ) );
};
} else {
initSource.call( this );
}
},
_renderItem: function( ul, item) {
if (listeNomsScientifiques[item.label] != undefined && listeNomsScientifiques[item.label].retenu == "true") {
item.label = "<b>"+item.label+"</b>";
}
if (item.label == '...') {
item.label = "<b>"+item.label+"</b>";
}
return $( "<li></li>" )
.data( "item.autocomplete", item )
.append( $( "<a></a>" )[ this.options.html ? "html" : "text" ]( item.label ) )
.appendTo( ul );
}
});
 
})( jQuery );