var TAXE_AEROPORT = "5900"; var TAXE_AEROPORT_LIVRAISON = "10000"; var TAXE_AEROPORT_RETOUR = "20000"; var TAXE_CHAUFFEUR = "6000"; function jqueryUI(){ var dateFormat = "dd/mm/yy", from = jQuery( "#date_depart" ) .datepicker({ defaultDate: "+1w", changeMonth: true, minDate: 0, numberOfMonths: 1, showOn: "button", buttonImage: "squelettes/images/rsv_cld.gif", buttonImageOnly: true, buttonText: "Selectionnez une date" }) .on( "change", function() { to.datepicker( "option", "minDate", getDatePicker( this ) ); }), to = jQuery( "#date_retour" ).datepicker({ defaultDate: "+1w", changeMonth: true, numberOfMonths: 1, showOn: "button", buttonImage: "squelettes/images/rsv_cld.gif", buttonImageOnly: true, buttonText: "Selectionnez une date" }) .on( "change", function() { from.datepicker( "option", "maxDate", getDatePicker( this ) ); }); } jQuery(document).ready(function($) { /* DEBUT FONCTIONS */ function gererSliders(){ var slider1 = $('#slider1'); if(slider1.length>0){ slider1.slick({ dots: false, arrows: false, infinite: true, speed: 500, fade: true, cssEase: 'linear', autoplay: true, autoplaySpeed: 6000 }); $(document).on("click",".slideshow-container .prev", function(){ slider1.slick("slickPrev"); }); $(document).on("click",".slideshow-container .next", function(){ slider1.slick("slickNext"); }); } } $('.nav_ss .menu_ss').on('click', function(){ showMenu(); }); function gererBandeauInterieur(){ } //pas de dimanche function noSundays(date) { return [date.getDay() != 0, '']; } function horairesReservation($heure,val){ var horaire_8_16 = ''; var horaire_0_23 = ''; switch(val) { case "37": $heure.html(horaire_8_16); break; case "34": $heure.html(horaire_8_16); break; case "35": $heure.html(horaire_8_16); break; case "36": $heure.html(horaire_0_23); break; default: $heure.html(horaire_0_23); } heure_dep_selectionnee = $("#heure_dep").attr("data-heure_depart"); if(heure_dep_selectionnee!="") $("#heure_dep").val(heure_dep_selectionnee).attr("selected"); heure_ret_selectionnee = $("#heure_retour").attr("data-heure_retour"); if(heure_ret_selectionnee!="") $("#heure_retour").val(heure_ret_selectionnee).attr("selected"); } function siDepartAeroport(){ if($("#lieu_depart").val()=="36") return true; else return false; } function siRetourAeroport(){ if($("#lieu_retour").val()=="36") return true; else return false; } function siDepartDuShowroom(){ if($("#lieu_depart").val()=="37") return true; else return false; } function siRetourAuShowroom(){ if($("#lieu_retour").val()=="37") return true; else return false; } function gererSiDepartDuShowroom(){ if(siDepartDuShowroom()){ $("body").addClass("depart_du_showroom"); $("#ui-datepicker-div").removeClass("ui-datepicker-retour"); $("#ui-datepicker-div").addClass("ui-datepicker-depart"); } else{ $("body").removeClass("depart_du_showroom"); $("#ui-datepicker-div").removeClass("ui-datepicker-retour"); } } function gererSiRetourAuShowroom(){ if(siRetourAuShowroom()){ $("body").addClass("retour_au_showroom"); $("#ui-datepicker-div").removeClass("ui-datepicker-depart"); $("#ui-datepicker-div").addClass("ui-datepicker-retour"); } else{ $("body").removeClass("retour_au_showroom"); $("#ui-datepicker-div").removeClass("ui-datepicker-depart"); } } function gererSiDepartEtRetourAuShowroom(){ $("body").addClass("depart_du_showroom"); $("body").addClass("retour_au_showroom"); $("#ui-datepicker-div").addClass("ui-datepicker-depart"); $("#ui-datepicker-div").addClass("ui-datepicker-retour"); } function gererSiNonDepartEtRetourAuShowroom(){ $("body").removeClass("depart_du_showroom"); $("body").removeClass("retour_au_showroom"); $("#ui-datepicker-div").removeClass("ui-datepicker-depart"); $("#ui-datepicker-div").removeClass("ui-datepicker-retour"); } function gererHeureReservationParLieu(){ var heure='#heure_dep'; var val_lieu_dep =$("#lieu_depart").val(); var heure2='#heure_retour'; var val_lieu_ret =$("#lieu_retour").val(); //if($("#heure_dep").attr("data-heure_depart")=="") horairesReservation($(heure),val_lieu_dep); //if($("#heure_retour").attr("data-heure_retour")=="") horairesReservation($(heure2),val_lieu_ret); if(siDepartDuShowroom() && siRetourAuShowroom()){ gererSiDepartEtRetourAuShowroom(); } else if(siDepartDuShowroom()){ gererSiDepartDuShowroom(); } else if(siRetourAuShowroom()){ gererSiRetourAuShowroom(); } else{ gererSiNonDepartEtRetourAuShowroom(); } $("#date_depart").bind("click",function(){ gererSiDepartDuShowroom(); }); $("#date_retour").bind("click",function(){ gererSiRetourAuShowroom(); }); $('#lieu_depart, #lieu_retour').change(function(){ var id=$(this).attr('id'); var val=$(this).val(); var html=$('#cl_'+val).html(); if(id=="lieu_depart"){ $heure = $(heure); gererSiDepartDuShowroom(); } if(id=="lieu_retour"){ $heure = $(heure2); gererSiRetourAuShowroom(); } horairesReservation($heure,val); }); } function showMenu2() { if($(".sous_menuv2").is(":visible")){ $(".sous_menuv2").hide(1000); } else{ $(".sous_menuv2").show(1000); } return false; } function closeMenu2() { $(".sous_menuv2").hide(); return false; } function showMenu() { if($(".menu_ss_list").is(":visible")){ $(".menu_ss_list").hide(1000); $(".header").css("position","fixed"); } else{ $(".menu_ss_list").show(1000); $(".menu_ss_list").css("background","#ffffff") ; $(".header").css("position","relative"); $("html,body").animate({ "scrollTop": 0 },700); } return false; } function showFakeBurger() { if($(".menu_ss_list").is(":visible")){ $(".menu_ss").css("display","none"); $(".fake_burger").css("display","block"); } else{ $(".fake_burger").css("display","none"); } return false; } //showFakeBurger(); function closeMenu() { $(".menu_ss_list").hide(); return false; } // function showBookingForm() { // $(".slideshow-container").css("max-height","100%"); // $(".slideshow-container").css("height","385px"); // $(".home_booking").show(1000); // return false; // } function getDatePicker(element){ var date; try { date = $.datepicker.parseDate( "dd/mm/yy", element.value ); } catch( error ) { date = null; } return date; } function monAlerte(message,element_focused){ $( "#dialog-message" ).html(message); $( "#dialog-message" ).dialog({ modal: true, buttons: { Ok: function() { $( this ).dialog( "close" ); } } }); $(element_focused).focus(); } function verifierChampInput(nom_champ){ var champ = $('input[name="'+nom_champ+'"]'); var le_parent = $('input[name="'+nom_champ+'"]').parent(); if($("#formulaire_contact").length>0 || $("#form_profil_utilisateur").length>0){ le_parent = $('input[name="'+nom_champ+'"]'); } if(champ.val()==""){ le_parent.addClass("erreur_saisie"); return false; } else{ le_parent.removeClass("erreur_saisie"); } return true; } function verifierChampTextarea(nom_champ){ var champ = $('textarea[name="'+nom_champ+'"]'); var le_parent = champ.parent(); if($("#formulaire_contact").length>0){ le_parent = champ; } if(champ.val()==""){ le_parent.addClass("erreur_saisie"); return false; } else{ le_parent.removeClass("erreur_saisie"); } return true; } function verifierChampRadio(nom_champ){ var le_parent = $('input[name="'+nom_champ+'"]').parent(); if(nom_champ == "type_vehicule"){ le_parent = $('input[name="'+nom_champ+'"]').parents().find(".choix_v_ctn"); if($(window).width()<470){ le_parent = $(".conteneur_select_type_vehicule"); } } var champ = $('input[name="'+nom_champ+'"]:checked'); if(!champ.length>0){ le_parent.addClass("erreur_saisie"); } else{ le_parent.removeClass("erreur_saisie"); } } function verifierChampSelect(nom_champ){ var champ = $('select[name="'+nom_champ+'"]'); if(champ.val()==""){ champ.parent().addClass("erreur_saisie"); } else{ champ.parent().removeClass("erreur_saisie"); } } function verifierChampCheckbox(nom_champ){ var le_parent = $('input[name="'+nom_champ+'"]').parent(); var champ = $('input[name="'+nom_champ+'"]:checked'); if(!champ.length>0){ le_parent.addClass("erreur_saisie"); } else{ le_parent.removeClass("erreur_saisie"); } } function verifierChampEmail(nom_champ){ var champ = $('input[name="'+nom_champ+'"]'); if(verifierChampInput(nom_champ)){ var pattern = new RegExp(/^((([a-z]|\d|[!#\$%&'\*\+\-\/=\?\^_`{\|}~]|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF])+(\.([a-z]|\d|[!#\$%&'\*\+\-\/=\?\^_`{\|}~]|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF])+)*)|((\x22)((((\x20|\x09)*(\x0d\x0a))?(\x20|\x09)+)?(([\x01-\x08\x0b\x0c\x0e-\x1f\x7f]|\x21|[\x23-\x5b]|[\x5d-\x7e]|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF])|(\\([\x01-\x09\x0b\x0c\x0d-\x7f]|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF]))))*(((\x20|\x09)*(\x0d\x0a))?(\x20|\x09)+)?(\x22)))@((([a-z]|\d|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF])|(([a-z]|\d|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF])([a-z]|\d|-|\.|_|~|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF])*([a-z]|\d|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF])))\.)+(([a-z]|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF])|(([a-z]|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF])([a-z]|\d|-|\.|_|~|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF])*([a-z]|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF])))\.?$/i); var emailAddress = champ.val(); if(!pattern.test(emailAddress)){ champ.parent().addClass("erreur_saisie"); }else{ champ.parent().removeClass("erreur_saisie"); } } } function commaSeparateNumber(val){ while (/(\d+)(\d{3})/.test(val.toString())){ val = val.toString().replace(/(\d+)(\d{3})/, '$1'+' '+'$2'); } return val; } function verifierFormulaireReservationAccueil(){ if($("#form_reservation_accueil").length>0){ $(document).on("submit","#form_reservation_accueil",function(event){ event.preventDefault(); verifierChampSelect("lieu_depart"); verifierChampInput("date_depart"); verifierChampSelect("heure_dep"); verifierChampSelect("minute_dep"); verifierChampSelect("lieu_retour"); verifierChampInput("date_retour"); verifierChampSelect("heure_retour"); verifierChampSelect("minute_retour"); if($(window).width()<470){ verifierChampSelect("type_vehicule"); } else{ verifierChampRadio("type_vehicule"); } verifierHeuresDepartRetour(); if($(".erreur_saisie").length>0) return false; // SI PAS D'ERREURS traiterReservation(); setTimeout(function(){ nbjours = $("#nb_jours_reserves").val(); //alert(nbjours); $.ajax({ url: "spip.php?page=ajaxReserver&act=etape2&nb_jours_reserves="+nbjours, type: "post", data: $("#form_reservation_accueil").serialize(), cache: true, success: function(d) { lien_redirection = d.split("_|_")[0]; document.location.href = lien_redirection; }, error : function(resultat, statut, erreur){ console.log(erreur); } }); return false; },300); }); } } function setNombreJoursReserves(date_heure_depart,date_heure_retour){ $.ajax({ url: "spip.php?page=ajaxNombreJours&date_heure_depart="+date_heure_depart+"&date_heure_retour="+date_heure_retour, type: "get", cache: true, success: function(d) { nombre_jours = d.split('_|_')[0]; $("#nb_jours_reserves").val(commaSeparateNumber(nombre_jours)); return nombre_jours; }, error : function(resultat, statut, erreur){ console.log(erreur); } }); } function traiterReservation(){ var date_depart = $("#date_depart").val(); var heure_dep = $("#heure_dep").val(); var minute_dep = $("#minute_dep").val(); var heure_minute_depart = heure_dep+":"+minute_dep; var tab_date_depart = date_depart.split("/"); date_depart = tab_date_depart[0]+"-"+tab_date_depart[1]+"-"+tab_date_depart[2]; var date_heure_depart = date_depart+" "+heure_minute_depart; var date_retour = $("#date_retour").val(); var tab_date_retour = date_retour.split("/"); date_retour = tab_date_retour[0]+"-"+tab_date_retour[1]+"-"+tab_date_retour[2]; var heure_retour = $("#heure_retour").val(); var minute_retour = $("#minute_retour").val(); var heure_minute_retour = heure_retour+":"+minute_retour; var date_heure_retour = date_retour+" "+heure_minute_retour; $("#date_heure_depart").val(date_heure_depart); $("#date_heure_retour").val(date_heure_retour); $.ajax({ url: "spip.php?page=ajaxNombreJours&date_heure_depart="+date_heure_depart+"&date_heure_retour="+date_heure_retour, type: "get", cache: false, success: function(d) { nombre_jours = d.split('_|_')[0]; $("#nb_jours_reserves").val(commaSeparateNumber(nombre_jours)); }, error : function(resultat, statut, erreur){ console.log(erreur); } }); } function verifierFormulaireReservationInt(){ if($("#form_reservation_int").length>0){ console.log("ok1"); $(document).on("submit","#form_reservation_int",function(event){ event.preventDefault(); verifierChampSelect("lieu_depart"); verifierChampInput("date_depart"); verifierChampSelect("heure_dep"); verifierChampSelect("minute_dep"); verifierChampSelect("lieu_retour"); verifierChampInput("date_retour"); verifierChampSelect("heure_retour"); verifierChampSelect("minute_retour"); if($(window).width()<470){ verifierChampSelect("type_vehicule"); } else{ verifierChampRadio("type_vehicule"); } verifierHeuresDepartRetour(); if($(".erreur_saisie").length>0) return false; // SI PAS D'ERREURS traiterReservation(); setTimeout(function(){ nbjours = $("#nb_jours_reserves").val(); //alert(nbjours); $.ajax({ url: "spip.php?page=ajaxReserver&act=etape2&nb_jours_reserves="+nbjours, type: "post", data: $("#form_reservation_int").serialize(), cache: false, success: function(d) { lien_redirection = d.split("_|_")[0]; document.location.href = lien_redirection; }, error : function(resultat, statut, erreur){ console.log(erreur); } }); return false; },300); }); } } function cacherListeVehicules(){ $(".choix_v_ctn ul").hide(); $(".choix_v_ctn").removeClass("active"); } function minuteDepartAZero(){ $("#minute_dep").val("0").trigger("change"); } function minuteRetourAZero(){ $("#minute_retour").val("0").trigger("change"); } function siRetraitADomicile(){ if($("#lieu_depart").val()==34) return true; return false; } function siRetraitChezMoi(){ if($("#lieu_depart").val()==34 || $("#lieu_depart").val()==35) return true; return false; } function siRetourADomicile(){ if($("#lieu_retour").val()==34) return true; return false; } function siRetourChezMoi(){ if($("#lieu_retour").val()==34 || $("#lieu_retour").val()==35) return true; return false; } function reinitHeureDepartEnFonctionDuLieu(){ var lieu_depart = $("#lieu_depart").val(); if($.trim(lieu_depart)!="") $("#lieu_depart").val(lieu_depart).trigger("change"); } function reinitHeureRetourEnFonctionDuLieu(){ var lieu_retour = $("#lieu_retour").val(); if($.trim(lieu_retour)!="") $("#lieu_retour").val(lieu_retour).trigger("change"); } function verifierHeuresDepartRetour(){ if($("#date_depart").val()==$("#date_retour").val()){ if(parseInt($("#heure_dep").val())>=parseInt($("#heure_retour").val())){ monAlerte("
Veuillez revoir l'heure de restitution!
","#heure_retour"); $("div.heure_retour").addClass("erreur_saisie"); } else{ $("div.heure_retour").removeClass("erreur_saisie"); } } } function gererFormulaireReservation(){ var largeur_ecran = $(window).width(); if($(".form-reservation").length>0){ $("#lieu_depart").change(function(){ minuteDepartAZero(); if(siRetraitChezMoi()) $("#ret_a_domicile").show(); else $("#ret_a_domicile").hide(); }); $("#heure_dep").change(function(){ minuteDepartAZero(); }); $("#lieu_retour").change(function(){ minuteRetourAZero(); if(siRetourChezMoi()) $("#ret_a_domicile").show(); else $("#ret_a_domicile").hide(); }); $("#heure_retour").change(function(){ minuteRetourAZero(); verifierHeuresDepartRetour(); }); $("#lieu_depart").bind("change",function(){ var lieu_depart = $(this).val(); //alert(ind_lieu_depart); var lieu_retour = $("#lieu_retour").val(); if($.trim(lieu_retour)=="") $("#lieu_retour").val(lieu_depart).trigger("change"); }); // SELECT TYPE VOITURE $(document).on("click",function(event) { cacherListeVehicules(); event.stopPropagation(); }); if(largeur_ecran<=470){ $(".choix_v_ctn").html(""); } else{ $(".conteneur_select_type_vehicule").html(""); } $(document).on("click",".choix_v_ctn",function(){ if($(this).hasClass("active")){ $(this).find("ul").hide(); $(this).removeClass("active"); } else{ $(this).find("ul").show(); $(this).addClass("active"); } return false; }); $(document).on("click",".choix_v_ctn li",function(){ $("#lb_select_type_vehicule").html($(this).find(".texte_label").html()); $(this).find("input").prop('checked', true).triggerHandler('click'); cacherListeVehicules(); return false; }); //initialiser champ déjà coché $(".choix_v_ctn .choix_vehicule_actif").click(); // reinitialiser heure en fonction du lieu var hidden_heure_depart = $("#hidden_heure_depart").val(); var hidden_minute_dep = $("#hidden_minute_dep").val(); var hidden_heure_retour = $("#hidden_heure_retour").val(); var hidden_minute_retour = $("#hidden_minute_retour").val(); if(hidden_heure_depart=="0") $("#heure_dep").val(hidden_heure_depart).trigger("change"); if(hidden_heure_retour=="0") $("#heure_retour").val(hidden_heure_retour).trigger("change"); $("#minute_dep").val(hidden_minute_dep).trigger("change"); $("#minute_retour").val(hidden_minute_retour).trigger("change"); $(".form-reservation .submit").hover(function(){ if($("#nb_jours_reserves").val()=="0" || $("#nb_jours_reserves").val()=="" ){ traiterReservation(); } }); } } function gererFormulaireReservationEtape2(){ verifierFormulaireReservationInt(); } function gererNombreDeJoursReserves(){ if($("#nb_jours_reserves").length>0){ var date_depart = $("#date_depart").val(); var heure_dep = $("#heure_dep").val(); var minute_dep = $("#minute_dep").val(); var heure_minute_depart = heure_dep+":"+minute_dep; var tab_date_depart = date_depart.split("/"); date_depart = tab_date_depart[0]+"-"+tab_date_depart[1]+"-"+tab_date_depart[2]; var date_heure_depart = date_depart+" "+heure_minute_depart; var date_retour = $("#date_retour").val(); var tab_date_retour = date_retour.split("/"); date_retour = tab_date_retour[0]+"-"+tab_date_retour[1]+"-"+tab_date_retour[2]; var heure_retour = $("#heure_retour").val(); var minute_retour = $("#minute_retour").val(); var heure_minute_retour = heure_retour+":"+minute_retour; var date_heure_retour = date_retour+" "+heure_minute_retour; $("#date_heure_depart").val(date_heure_depart); $("#date_heure_retour").val(date_heure_retour); setNombreJoursReserves(date_heure_depart,date_heure_retour); if($("#nb_jours_reserves").val()>0){ var nb_jours_reserves = $("#nb_jours_reserves").val(); $(".le_prix").each(function(){ var prix = $(this).attr("data-prix"); var prix_ht = prix*nb_jours_reserves*1.18; // si difference de prix dû à la lenteur de la requete par ajax var prix_actuel = $.trim($(this).find(".valeur").html()); console.log("prix_actuel="+prix_actuel); //if(prix_actuel!=prix_ht || prix_actuel=="0") $(this).find(".valeur").html(commaSeparateNumber(prix_ht)); }); if($("#prix_ttc .montant").length>0){ var prix = $("#prix_ttc .montant").attr("data-prix-ht"); var prix_ht = prix*nb_jours_reserves*1.18; // si difference de prix dû à la lenteur de la requete par ajax var prix_actuel = $("#prix_ttc .montant").html(); if(prix_actuel!=prix_ht) $("#prix_ttc .montant").html(commaSeparateNumber(prix_ht)); $("#prix_ttc .montant").attr("data-prix-ttc",prix_ht); if($.trim($("#prix_ttc .montant").html())==""){ location.reload(); } } } } } function reserverVehiculeAction(){ $(document).on("click",".reserver",function(){ var id_vehicule = $(this).attr("data-href"); setTimeout(function(){ var nb_jours_reserves = $("#nb_jours_reserves").val(); var categorie = $("#hidden_categorie").val(); var nb_places = $("#hidden_nb_places").val(); var chauffeur = $("#hidden_chauffeur").val(); console.log("categorie="+categorie); $.ajax({ url: "spip.php?page=ajaxReserver&act=etape3&id_article="+id_vehicule+"&nb_jours_reserves="+nb_jours_reserves+"&categorie="+categorie+"&nb_places="+nb_places+"&chauffeur="+chauffeur, type: "get", cache: false, success: function (d) { lien_redirection = d.split("_|_")[0]; document.location.href = lien_redirection; }, error: function (resultat, statut, erreur) { console.log(erreur); } }); },300); }); } function verifierFormulaireContact(){ if($("#formulaire_contact").length>0){ $(document).on("submit","#formulaire_contact",function(event){ event.preventDefault(); verifierChampInput("nom"); verifierChampEmail("email"); verifierChampInput("telephone"); verifierChampInput("objet"); verifierChampTextarea("message"); if($(".erreur_saisie").length>0) return false; // SI PAS D'ERREURS if($("#abonnement_newsletter:checked").length>0){ var email = $("#champ_email").val(); $("#iframe_newsletter").attr("src","spip.php?page=inscrireNewsletter&email="+email); } $.ajax({ url: "spip.php?page=ajaxEnvoyerMessage", type: "post", data: $("#formulaire_contact").serialize(), cache: false, success: function(d) { $("#entete_avertissement_contact").html("Succès"); $("#conteneur_avertissement_contact").html(d); $(".col_gauche_contact").hide(); $(".col_droite_contact").hide(); $(".ct_submit").hide(); }, error : function(resultat, statut, erreur){ $("#entete_avertissement_contact").html("Echec"); $("#conteneur_avertissement_contact").html(erreur); } }); $("#iframe_newsletter").attr("src",""); return false; }); } } function siAvecChauffeur(){ if($("input#chauffeur:checked").length>0) return true; return false; } function siAvecTaxeAeroport(){ if( siAvecTaxeAeroportLivraison() || siAvecTaxeAeroportRetour() ) return true; else return false; } function siAvecTaxeAeroportLivraison(){ if($("input#taxe_aero_livraison:checked").length>0){ return true; } else return false; } function siAvecTaxeAeroportRetour(){ if($("input#taxe_aero_retour:checked").length>0){ return true; } else return false; } function calculMontantKmSupp(){ if($("#km_supp").val()!="0"){ $("#km_supp").trigger("click"); } } function getTaxeAeroport(){ var TOTAL_TAXE_AEROPORT = 0; if(siAvecTaxeAeroportLivraison()){ TOTAL_TAXE_AEROPORT += parseInt(TAXE_AEROPORT_LIVRAISON); $("#hidden_montant_taxe_aeroport_livraison").val(TAXE_AEROPORT_LIVRAISON); } if(siAvecTaxeAeroportRetour()){ TOTAL_TAXE_AEROPORT += parseInt(TAXE_AEROPORT_RETOUR); $("#hidden_montant_taxe_aeroport_retour").val(TAXE_AEROPORT_RETOUR); } $("#montant_taxe_aeroport").attr("data-valeur",TOTAL_TAXE_AEROPORT); $("#montant_taxe_aeroport").html(commaSeparateNumber(TOTAL_TAXE_AEROPORT)); return TOTAL_TAXE_AEROPORT; } function gererFormulaireReservationEtape3(){ setTimeout(calculTotal,300); $(document).on("click","#km_supp",function(){ if(!$(this).hasClass("on")){ $(this).addClass("on"); var facteur = $(this).attr("data-facteur"); var produit = $(this).val(); var montant_km_supp = produit*facteur; $("#montant_km_supp").html(commaSeparateNumber(montant_km_supp)); $("#montant_km_supp").attr("data-valeur",$.trim(montant_km_supp)); } else{ $(this).removeClass("on"); } calculTotal(); }); $(document).on("click",".km_supp",function(){ $("#km_supp").trigger("click"); }); $(document).on("change","#km_supp",function(){ $("#km_supp").trigger("click"); }); $(document).on("blur","#km_supp",function(){ $("#km_supp").trigger("click"); }); calculMontantKmSupp(); $(document).on("change","input#chauffeur",function(){ var nb_jours_reserves = $("#nb_jours_reserves").val(); if(siAvecChauffeur()){ console.log("AvecChauffeur"); $("#montant_avec_chauffeur").attr("data-valeur",TAXE_CHAUFFEUR*nb_jours_reserves); $("#montant_avec_chauffeur").html(commaSeparateNumber(TAXE_CHAUFFEUR*nb_jours_reserves)); $("#hidden_chauffeur").val("oui"); } else{ console.log("SansChauffeur"); $("#montant_avec_chauffeur").attr("data-valeur","0"); $("#montant_avec_chauffeur").html("0"); $("#hidden_chauffeur").val("non"); } calculTotal(); }); TOTAL_TAXE_AEROPORT = getTaxeAeroport(); $(document).on("change","input#taxe_aero",function(){ if(siAvecTaxeAeroport()){ TOTAL_TAXE_AEROPORT = getTaxeAeroport(); } else{ $("#montant_taxe_aeroport").attr("data-valeur","0"); $("#montant_taxe_aeroport").html("0"); } calculTotal(); }); validerCommande(); } function calculTotal(){ if($("#prix_ttc").length>0){ var montant_total = 0; // OPTIONS var montant_options = 0; var montant_livraison_dom = $("#montant_livraison_domicile").attr("data-valeur"); montant_options += parseInt(montant_livraison_dom); var montant_retour_dom = $("#montant_retour_domicile").attr("data-valeur"); montant_options += parseInt(montant_retour_dom); if(siAvecChauffeur()){ montant_avec_chauffeur = $("#montant_avec_chauffeur").attr("data-valeur"); $("#montant_avec_chauffeur").html(commaSeparateNumber(montant_avec_chauffeur)); montant_options += parseInt(montant_avec_chauffeur); } var montant_taxe_aeroport = $("#montant_taxe_aeroport").attr("data-valeur"); if(!siAvecTaxeAeroport()){ $("#montant_taxe_aeroport").attr("data-valeur","0"); $("#montant_taxe_aeroport").html("0"); montant_taxe_aeroport = 0; } montant_options += parseInt(montant_taxe_aeroport); var montant_km_supp = $("#montant_km_supp").attr("data-valeur"); montant_options += parseInt(montant_km_supp); //console.log("montant_km_supp="+montant_km_supp); $("#montant_options").html(commaSeparateNumber(montant_options)); console.log("montant_options="+montant_options); var montant_location = $("#prix_ttc .montant").attr("data-prix-ttc"); if(montant_location==0) montant_location = $("#prix_ttc .montant").html(); montant_total = parseInt(montant_location) + parseInt(montant_options); //$("#prix_ttc .montant").html(commaSeparateNumber(montant_total)); $("#montant_options").html(commaSeparateNumber(montant_total)); var montant_tva = parseInt(montant_total - (montant_total/1.18)); $("#montant_tva").html(commaSeparateNumber(montant_tva)); $("#montant_tva").attr("data-valeur",montant_tva); } } function validerCommande(){ corrigerPrix(); $(document).on("click","#valider_commande",function(){ $("#form_valider_commande").submit(); }); $(document).on("submit","#form_valider_commande",function(event){ event.preventDefault(); var requete_url = ""; var id_article = $.trim($("#hidden_id_article").val()); var montant_ttc = myTrim($("#montant_options").html()); var montant_livraison_domicile = myTrim($("#montant_livraison_domicile").html()); var montant_retour_domicile = myTrim($("#montant_retour_domicile").html()); var montant_avec_chauffeur = myTrim($("#montant_avec_chauffeur").html()); var km_supp = $("#km_supp").val(); var montant_km_supp = myTrim($("#montant_km_supp").html()); var montant_taxe_aeroport = myTrim($("#montant_taxe_aeroport").html()); var montant_options = myTrim($("#montant_options").html()); var montant_tva = myTrim($("#montant_tva").html()); var nb_jours_reserves = $("#nb_jours_reserves").val(); requete_url+="&id_article"+id_article+"&nb_jours_reserves="+nb_jours_reserves; var categorie = myTrim($(".categorie_voiture").html()); $("#hidden_montant_ttc").val(montant_ttc); $("#hidden_montant_livraison_domicile").val(montant_livraison_domicile); $("#hidden_montant_retour_domicile").val(montant_retour_domicile); $("#hidden_montant_avec_chauffeur").val(montant_avec_chauffeur); $("#hidden_km_supp").val(km_supp); $("#hidden_montant_km_supp").val(montant_km_supp); $("#hidden_montant_taxe_aeroport").val(montant_taxe_aeroport); $("#hidden_montant_options").val(montant_options); $("#hidden_montant_tva").val(montant_tva); $("#hidden_categorie").val(categorie); //if(montant_ttc!=="0") requete_url+="&montant_ttc"+montant_ttc; //if(montant_livraison_domicile!=="") requete_url+="&montant_livraison_domicile"+montant_livraison_domicile; //if(montant_retour_domicile!=="") requete_url+="&montant_retour_domicile"+montant_retour_domicile; //if(montant_avec_chauffeur!=="") requete_url+="&montant_avec_chauffeur"+montant_avec_chauffeur; //if(km_supp!=="") requete_url+="&km_supp"+km_supp; //if(montant_km_supp!=="") requete_url+="&montant_km_supp"+montant_km_supp; //if(montant_taxe_aeroport!=="") requete_url+="&montant_taxe_aeroport"+montant_taxe_aeroport; //if(montant_options!=="") requete_url+="&montant_options"+montant_options; //if(montant_tva!=="") requete_url+="&montant_tva"+montant_tva; $.ajax({ url: "spip.php?page=ajaxReserver&act=etape4"+requete_url, type: "post", data: $("#form_valider_commande").serialize(), cache: true, success: function(d) { lien_redirection = d.split("_|_")[0]; document.location.href = lien_redirection; }, error : function(resultat, statut, erreur){ console.log(erreur); } }); return false; }); } function removeNBSP(chaine){ chaine = chaine.replace(" ", ''); return chaine; } function myTrim(chaine){ $return = ""; if(chaine!=="" && chaine!==undefined){ chaine = chaine.replace(/\s/g, ''); $return = removeNBSP(chaine); } return $return; } function corrigerPrix(){ if($('.modele_reserve #prix_ttc .montant').length>0){ var montant = $('.modele_reserve #prix_ttc .montant').html(); if(montant.indexOf('.')>-1){ var tab_montant = montant.split('.'); if(tab_montant[1].length>2){ var suffixe = tab_montant[1].substring(0, 2); montant = tab_montant[0]+'.'+suffixe; $('.modele_reserve #prix_ttc .montant').html(montant); } } } } function validerFormProfilUtilisateur(){ if($("#form_profil_utilisateur").length>0){ var url_actuel = new URL(window.location.href); var val_test = url_actuel.searchParams.get("test"); console.log("val_test = "+val_test); if(val_test==="1"){ // SET COUNTRY VALUE $(document).on('change','#select_pays',function(){ var country_label = $(this).find("option:selected").text(); $('#hidden_hbspt_country').val(country_label); }); if($("#select_pays").val()!==""){ $("#select_pays").val($("#select_pays").val()).trigger('change'); } // SET JOB FUNCTION $(document).on('change','#select_profession',function(){ var job_function_label = $(this).find("option:selected").text(); $('#hidden_hbspt_job_function').val(job_function_label); }); if($("#select_profession").val()!==""){ $("#select_profession").val($("#select_profession").val()).trigger('change'); } } var montant = $("#hidden_montant_options").val(); $("#vads_amount").val(montant.replace(/\s/g, '')); $(document).on("submit","#form_profil_utilisateur",function(event){ event.preventDefault(); verifierChampRadio("civilite"); verifierChampInput("nom"); verifierChampInput("prenom"); verifierChampEmail("email"); verifierChampInput("tel_gsm"); //verifierChampInput("fixe"); //verifierChampInput("profession"); verifierChampInput("ville"); verifierChampTextarea("adresse"); verifierChampSelect("pays"); verifierChampCheckbox("jaccepte"); verifierChampRadio("mode_paiement"); if($(".erreur_saisie").length>0) return false; $("#form_profil_utilisateur").addClass("loading_form"); $("#btn-valider-profil").addClass("nopointerevent nopointerevent"); // if($(".hidden_antispamp").val()!="") document.location.href = "merci.html"; document.location.href = "merci.html"; var vads_site_id = $("#vads_site_id").val(); var vads_ctx_mode = $("#vads_ctx_mode").val(); var vads_trans_id = $("#vads_trans_id").val(); var vads_trans_date = $("#vads_trans_date").val(); var vads_action_mode = $("#vads_action_mode").val(); var vads_page_action = $("#vads_page_action").val(); var vads_version = $("#vads_version").val(); var vads_capture_delay = $("#vads_capture_delay").val(); var vads_validation_mode = $("#vads_validation_mode").val(); var vads_return_mode = $("#vads_return_mode").val(); var vads_payment_config = $("#vads_payment_config").val(); var vads_amount = $.trim($("#vads_amount").val()); var signature = $("#signature").val(); var cust_civilite = $("#cust_civilite").val(); var cust_last_name= $("#cust_last_name").val(); var cust_first_name= $("#cust_first_name").val(); var cust_email= $("#cust_email").val(); var cust_cell_phone= $("#cust_cell_phone").val(); var cust_phone= $("#cust_phone").val(); var cust_legal_name= $("#cust_legal_name").val(); var cust_address= $("#cust_address").val(); var cust_city= $("#cust_city").val(); var select_pays= $("#select_pays").val(); var categorie = $("#hidden_categorie0").val(); var offre = $("#hidden_offre0").val(); $("#hidden_categorie").val(categorie); $("#hidden_offre").val(offre); // SI PAS D'ERREURS $.ajax({ url: "spip.php?page=ia-hubspot-spip&act=etape5", type: "post", data: $("#form_profil_utilisateur").serialize(), cache: false, success: function(d) { //alert(d); console.log(d); }, error : function(resultat, statut, erreur){ console.log(erreur); } }); var action_url = $(this).attr('action'); if(action_url!==""){ $.ajax({ url: action_url, type: "post", data: $("#form_profil_utilisateur").serialize(), cache: false, success: function(d) { //alert(d); console.log(d); lien_merci = d.split('_|_')[1]; document.location.href = lien_merci; }, error : function(resultat, statut, erreur){ console.log(erreur); } }); } var url_iframe = "vads-payment-php/form/index_valide.php"; url_iframe += "?vads_site_id="+vads_site_id; url_iframe += "&vads_ctx_mode="+vads_ctx_mode; url_iframe += "&vads_trans_id="+vads_trans_id; url_iframe += "&vads_trans_date="+vads_trans_date; url_iframe += "&vads_action_mode="+vads_action_mode; url_iframe += "&vads_page_action="+vads_page_action; url_iframe += "&vads_version="+vads_version; url_iframe += "&vads_capture_delay="+vads_capture_delay; url_iframe += "&vads_validation_mode="+vads_validation_mode; url_iframe += "&vads_return_mode="+vads_return_mode; url_iframe += "&vads_payment_config="+vads_payment_config; url_iframe += "&vads_amount="+$.trim(vads_amount); //url_iframe += "&vads_currency="+vads_currency; url_iframe += "&signature="+signature; //acheteur url_iframe += "&vads_cust_email="+$.trim(vads_amount); if($("#civ_monsieur:checked").length>0) cust_civilite = "M."; else cust_civilite = "Mme"; url_iframe += "&vads_cust_title="+cust_civilite; url_iframe += "&vads_cust_last_name="+cust_last_name; url_iframe += "&vads_cust_first_name="+cust_first_name; url_iframe += "&vads_cust_email="+cust_email; url_iframe += "&vads_cust_cell_phone="+cust_cell_phone; url_iframe += "&vads_cust_phone="+cust_phone; url_iframe += "&vads_cust_legal_name="+cust_legal_name; url_iframe += "&vads_cust_address="+cust_address; url_iframe += "&vads_cust_city="+cust_city; url_iframe += "&vads_cust_country="+select_pays; //$("#modal_form_paiement iframe").attr("src",url_iframe); //ouverture du formulaire de paimement //window.open(url_iframe); //$("#reservation_form").hide(); //$("#modal_form_paiement").show(); //$("body").addClass("modal_form_paiement_visible"); //document.location.href = "/?fin=oui"; //window.open(lien_merci, '_blank'); return false; }); } $(document).on("click","#modal_form_paiement .btn-fermer",function(){ $("#modal_form_paiement").hide(); $("body").removeClass("modal_form_paiement_visible"); }); } function gererFormulaireReservationEtape4(){ validerFormProfilUtilisateur(); } function scrollerA(destination,top_moins){ var tm = 0; if(top_moins) tm = top_moins; $("html,body").animate({"scrollTop":$(destination).offset().top-tm},700); } function gererHashUrl(){ var url = document.location.href; var hash = url.substring(url.indexOf('#')+1); if(hash==="contact"){ scrollerA("#formulaire_contact",300); } if(hash==="merci"){ //alert(hash); $("#modal_form_paiement .btn-fermer").click(); document.location.href = "merci.html"; } } function finPrechargement(){ setTimeout(function(){ $("body").removeClass("en_prechargement"); },400); } function isiPhone(){ var isiPhone = navigator.userAgent.toLowerCase().indexOf("iphone"); var isiPad = navigator.userAgent.toLowerCase().indexOf("ipad"); var isiPod = navigator.userAgent.toLowerCase().indexOf("ipod"); var deviceAgent = navigator.userAgent.toLowerCase(); var agentID = deviceAgent.match(/(iphone|ipod|ipad)/); return ( (isiPhone > -1) || (isiPad > -1) || (isiPod > -1) || (agentID) ); } /* FIN FONCTIONS */ var largeur_ecran = $(window).width(); var html_mob_select_type_vehicule = $(".conteneur_select_type_vehicule").html(); var html_desk_select_type_vehicule = $(".choix_v_ctn").html(); $(window).load(function(){ finPrechargement(); gererSliders(); gererNombreDeJoursReserves(); gererFormulaireReservationEtape3(); gererFormulaireReservationEtape4(); gererHashUrl(); }); if(isiPhone()) { $("body").addClass("iphone"); } // Variables var $codeSnippets = $('.code-example-body'), $nav = $('#nav'), $body = $('body'), $window = $(window), $popoverLink = $('[data-popover]'), navOffsetTop = $nav.offset().top, $document = $(document), entityMap = { "&": "&", "<": "<", ">": ">", '"': '"', "'": ''', "/": '/' } function init() { $window.on('scroll', onScroll) $window.on('resize', resize) $popoverLink.on('click', openPopover) $document.on('click', closePopover) $('a[href^="#"]').on('click', smoothScroll) buildSnippets(); } function smoothScroll(e) { e.preventDefault(); $(document).off("scroll"); var target = this.hash, menu = target; $target = $(target); if($(target).length>0){ $('html, body').stop().animate({ 'scrollTop': $target.offset().top-40 }, 0, 'swing', function () { window.location.hash = target; $(document).on("scroll", onScroll); }); } } function openPopover(e) { e.preventDefault() closePopover(); var popover = $($(this).data('popover')); popover.toggleClass('open') e.stopImmediatePropagation(); } function closePopover(e) { if($('.popover.open').length > 0) { $('.popover').removeClass('open') } } $("#button").click(function() { $('html, body').animate({ scrollTop: $("#elementtoScrollToID").offset().top }, 2000); }); function resize() { $body.removeClass('has-docked-nav') navOffsetTop = $nav.offset().top onScroll() } function onScroll() { if(navOffsetTop < $window.scrollTop() && !$body.hasClass('has-docked-nav')) { $body.addClass('has-docked-nav') } if(navOffsetTop > $window.scrollTop() && $body.hasClass('has-docked-nav')) { $body.removeClass('has-docked-nav') } } function escapeHtml(string) { return String(string).replace(/[&<>"'\/]/g, function (s) { return entityMap[s]; }); } function buildSnippets() { $codeSnippets.each(function() { var newContent = escapeHtml($(this).html()) $(this).html(newContent) }) } function facebookShare(url,image,texte,miniature){ FB.init({ appId : '506925609659628', cookie : true, xfbml : true, version : 'v2.8' }); FB.ui({ method: 'feed', name: 'RDE', link: url, picture: image, caption: 'Rencontre des Entrepreneurs', description: texte, thumbnail: miniature }, function(response) {}); } function faq(){ $("dl.faq.js dt").bind("click", function() { $("dl.faq.js dt").not(this).addClass("close"); $("dl.faq.js dt").not(this).next("dd").hide(); $(this).toggleClass("close"); $(this).next("dd").toggle(); }); } init(); $(document).on("click",".fshare a",function(){ url = $(this).attr("data-url"); image = $(this).attr("data-image"); texte = $(this).attr("data-texte"); miniature = $(this).attr("data-miniature"); facebookShare(url,image,texte,miniature); }); $(document).on("click","#close_form",function(){ closeForm(); }); $(document).on("blur","#search_input",function(){ closeForm(); }); var currentSlide = $('.slick-slider'); if(currentSlide.length>0){ currentSlide.slick({ dots: false, infinite: true, speed: 500, fade: true, cssEase: 'linear' }); $(document).on("click",".arr_prev a img", function(){ currentSlide.slick("slickPrev"); }); $(document).on("click",".arr_next a img", function(){ currentSlide.slick("slickNext"); }); } $(".nav li a").hover(function(){ if($(this).next(".menu-liste").length>0){ $("#nav").addClass("dessus"); } return false; }); $(".nav-items .menu-entree li").on("mouseleave",function(){ $("#nav").removeClass("dessus"); }); $(".non_cliquable").click(function(){return false;}); $(document).on("click",".print a",function(){ window.print(); }); $(".call_to").bind("click",function(){ setTimeout(function(){ $("body").addClass("layer_contact"); },1100); }); $(".call_to").hover(function(){ $("body").removeClass("layer_contact"); }); if($(".ev_content").length<=6 && $(".ev_content").length>0) $("#row_tout #voir_tout").hide(); if($(".social-feed").length<=6 && $(".social-feed").length>0) $("#row_tout #voir_tout").hide(); $(".non_cliquable").each(function(){ $(this).attr("href","#"); }); $(".champ_date").bind("click",function(){ $(this).next(".ui-datepicker-trigger").click(); }); /* Every time the window is scrolled ... */ $(window).scroll( function(){ var wscrolltop = $(window).scrollTop(); if(largeur_ecran>470){ if(wscrolltop>=83){ $("div.header").addClass("fixed"); $("body").addClass("entete_fixe"); } else{ $("div.header").removeClass("fixed"); $("body").removeClass("entete_fixe"); } } /* Check the location of each desired element */ $('.hideme').each( function(i){ var bottom_of_object = $(this).position().top + $(this).outerHeight(); var bottom_of_window = $(window).scrollTop() + $(window).height(); /* If the object is completely visible in the window, fade it it */ if( bottom_of_window > bottom_of_object ){ $(this).animate({'opacity':'1'},1500); $('.btn_animate').animate({'margin-left':'100px'},1500); } }); }); /********************************/ $('a[rel="external"]').each(function(){ $(this).attr("target","_blank"); }); $(document).on("click","#go_to_bottom",function(){ if($(".arbo").length>0) $destination = $(".arbo"); else $destination = $(".slider_container + div"); $("html,body").animate({"scrollTop":$destination.offset().top},700); }); $(document).on("click",".res_booking_btn",function(){ $(".slideshow-container").css("max-height","385px"); $(".slideshow-container").css("height","385px"); $(".home_booking").show(1000); }); function gererLOA(){ $(document).on("change","#champ_selection_1",function(){ $("#champ_selection_2").val(""); if($(this).val()=="2roues"){ $('#champ_selection_2 option[value="choix3"]').attr("disabled",""); } else{ $('#champ_selection_2 option[value="choix3"]').removeAttr("disabled"); } }); if($("#champ_selection_1").val()=="2roues") $("#champ_selection_1").trigger("change"); /* *** */ // $(document).on("change","#champ_selection_3",function(){ // $("#champ_selection_1").val(""); // if($(this).val()=="particulier"){ // $('#champ_selection_1 option[value="2roues"]').attr("disabled",""); // } // else{ // $('#champ_selection_1 option[value="2roues"]').removeAttr("disabled"); // } // }); if($("#champ_selection_3").val()=="particulier") $("#champ_selection_3").trigger("change"); } function getParameterByName(name, url) { if (!url) url = window.location.href; name = name.replace(/[\[\]]/g, "\\$&"); var regex = new RegExp("[?&]" + name + "(=([^]*)|&|#|$)"), results = regex.exec(url); if (!results) return null; if (!results[2]) return ''; return decodeURIComponent(results[2].replace(/\+/g, " ")); } function gererRedirectionVehicule(){ var url_actuel = window.location.href; var idv = getParameterByName("idv",url_actuel); if(idv && idv!=="" && idv!==null){ if($('.row[data-id="'+idv+'"]').length>0){ $("html,body").animate({ "scrollTop": $('.row[data-id="'+idv+'"]').offset().top - $('.header').height() },700); } } } jqueryUI(); verifierFormulaireReservationAccueil(); gererFormulaireReservationEtape2(); gererFormulaireReservation(); gererHeureReservationParLieu(); gererBandeauInterieur(); reserverVehiculeAction(); verifierFormulaireContact(); faq(); gererLOA(); gererRedirectionVehicule(); $(window).resize(function(){ var largeur_ecran = $(window).width(); if(largeur_ecran<=470){ $(".choix_v_ctn").html(""); $(".conteneur_select_type_vehicule").html(html_mob_select_type_vehicule); } else{ $(".choix_v_ctn").html(html_desk_select_type_vehicule); $(".conteneur_select_type_vehicule").html(""); } }); });