$(document).ready(function() { // -------------------------------------------------------------------------------- // Depart // -------------------------------------------------------------------------------- $('#depart').datetimepicker({ locale: 'fr', stepping: 30, daysOfWeekDisabled: [0], //format: 'D d/m/Y H:i', format: 'llll', } ); $("#depart").on("dp.change", function (e) { $('#retour').data("DateTimePicker").maxDate(moment(e.date).add(30, 'days').format('llll')); // On borde la période sur 30 jours $('#retour').data("DateTimePicker").minDate(e.date); // date de retour ne peut pas être inférieur à date de départ $('#F450DTDEP').val(moment(e.date).format('L')); }); // -------------------------------------------------------------------------------- // Retour // -------------------------------------------------------------------------------- $('#retour').datetimepicker({ locale: 'fr', stepping: 30, daysOfWeekDisabled: [0], format: 'llll', useCurrent: false } ); $("#retour").on("dp.change", function (e) { $('#depart').data("DateTimePicker").maxDate(e.date); $('#F450DTARR').val(moment(e.date).format('L')); }); // Other // // Jours de fermetures $("#depart").data("DateTimePicker").disabledDates( holidays // voir holidays sur footerJs.php ); $("#retour").data("DateTimePicker").disabledDates( holidays ); // Heures de fermetures $("#depart").data("DateTimePicker").disabledHours( horaires ); $("#retour").data("DateTimePicker").disabledHours( horaires ); // Changement d'agence // $('#agence').change(function() { // razCalendrier $('#depart').data("DateTimePicker").clear(); $('#retour').data("DateTimePicker").clear(); //raz Hidden input $('#F450DTDEP').val(''); $('#F450DTARR').val(''); }); if ( $( "#agence" ).length ) { $.widget("custom.autocompleteHighlight", $.ui.autocomplete, { _renderItem: function (ul, item) { var regexp = new RegExp('(' + this.term + ')', 'gi'), classString = this.options.highlightClass ? ' class="' + this.options.highlightClass + '"' : '', label = item.label.replace(regexp, '$1'); return $('
  • ' + label + '
  • ').appendTo(ul); } }); } }); // End document ready //////////////////// // Autocomplétion // // // //////////////////// /// function jsUcfirst(string) { string=string.toLowerCase() return string.charAt(0).toUpperCase() + string.slice(1); } if ( $( "#agence" ).length ) { $( function() { $.ajax({ url: "xml/agences.xml", dataType: "xml", success: function( xmlResponse ) { var data = $( "agence", xmlResponse ).map(function() { return { value: $( "cp", this ).text() + " - " + ( $.trim( jsUcfirst($( "title", this ).text()) )), id: $( "id", this ).text(), lat:$( "latitude", this ).text(), lon:$( "longitude", this ).text() }; }).get(); $( "#agence" ).autocompleteHighlight({ source: data, sort: { enabled: true }, list: { maxNumberOfElements: 10, match: { enabled: true } }, minLength: 2, highlightClass: 'ui-autocomplete-hightlight', select: function( event, ui ) { log( ui.item ? ui.item.id : "ErrID #" + this.value ); } }); } }); function log( message ) { // $('#depart').val(''); // $('#retour').val(''); // $('#jDepart').val(''); //$('#jRetour').val(''); $( "#K450030DEP" ).val(message); console.log("msg :"+message); //setCal(); } function valide(id,cp,ville) { // alert("ville" + ville) $('#depart').val(''); $('#retour').val(''); $( "#K450030DEP" ).val(id); console.log("Valide : "+$( "#K450030DEP" ).val()); //findCoord(id); //setCal(); $( "#agence").val(cp+" - "+ville); $('#ui-id-1').hide(); }; }); // fin fonction }