1// pour régler les problèmes de numérotation dans les différentes étapes de la résa, on initialise ici les mises à jour. fiche 258393 2jQuery( document ).ajaxComplete(function(){ 3 majNumEtapes(); 4 } 5); 6majNumEtapes(); 7 8function recupParamSiteModeOuverturePaybox(){ 9 if(jQuery('#form_formPbx').length){ 10 return jQuery('#form_formPbx').attr('ouverture_paybox'); 11 } 12} 13 14function pbxInPopUp(){ 15 return (recupParamSiteModeOuverturePaybox()=="POPUP"); 16} 17 18function setFormPaiementCptCliPaybox(){ 19 (function($){ 20 if ( $('#a_boutonValiderCptClientPbx').attr('disabled') == "disabled" ) { 21 return false; 22 } 23 if ($("#div_validFormPbx").length) { 24 $("#div_validFormPbx").hide(); 25 } 26 27 // Les valeurs par défaut 28 var quelPaiement = 'solde'; 29 var montant_a_payer = $("#inpt_solde_cptCliPbx").val(); 30 31 // On regarde ensuite si une checkbox est cochée 32 if ($("#input_paiement_cbVersPbx").length && $("#input_paiement_cbVersPbx:checked").length){ 33 if (verifMontantVersement()) { 34 montant_a_payer=parseFloat($("#inpt_vers_cptClient").val())*100; 35 } else { 36 // TODO : On peut peut-être faire mieux que ça... 37 alertAMalibu('Le montant saisi est incorrect.'); 38 return false; 39 } 40 quelPaiement = 'versement'; 41 } 42 43 if ($("#input_paiement_cbAcomptePbx").length && $("#input_paiement_cbAcomptePbx:checked").length) { 44 quelPaiement = 'acompte'; 45 montant_a_payer = $("#inpt_acompte_cptCliPbx").val(); 46 } 47 48 if ($("#input_paiement_cbSoldeANCVPbx").length && $("#input_paiement_cbSoldeANCVPbx:checked").length) { 49 quelPaiement = 'soldeANCV'; 50 } 51 if ($("#input_paiement_cbAcompteANCVPbx").length && $("#input_paiement_cbAcompteANCVPbx:checked").length) { 52 quelPaiement = 'acompteANCV'; 53 } 54 var montant_a_payer_for_trw = montant_a_payer; 55 var adr="/lib_2/ajax/infosDist.php"; 56 57 var exe=$("#form_formPbx").attr("exercice"); 58 var type_resa=$("#form_formPbx").attr("type_resa"); 59 var nom_instance=$("#form_formPbx").attr("nom_instance"); 60 var base=$("#form_formPbx").attr("base"); 61 var numero_resa=$("#form_formPbx").attr("numero_resa"); 62 var idsession='PHPSESSID='+$("#form_formPbx").attr("idsession"); 63 var dpt = $("#form_formPbx").attr("dpt"); 64 var sending="info=REGLTCPTCLIPBX&numero_resa="+numero_resa+"&exercice="+exe+"&type_resa="+type_resa+"&nom_instance="+nom_instance+"&base="+base+"&montant_a_payer="+montant_a_payer_for_trw+"&dpt="+dpt+"&"+idsession+"&quelPaiement="+quelPaiement; 65 66 $.ajax({ 67 url : adr, 68 method: 'POST', 69 data : sending, 70 contentType : "application/x-www-form-urlencoded", 71 success : function(retour){ 72 eval("var tabRetour="+retour); 73 if (tabRetour.code == "OK") { 74 majFormPaybox(tabRetour); 75 validerFormulairePaybox(); 76 } else { 77 location.reload(); 78 // alertAMalibu(tabRetour.msg); 79 } 80 }, 81 beforeSend : function(){ 82 $('#a_boutonValiderCptClientPbx').addClass('disabled'); 83 }, 84 // Yoann 03/04/2017 : On réactive le bouton uniquement en cas d'erreur, en cas de succès on change de page ou on reload donc pas besoin de réactiver 85 error : function(){ 86 $('#a_boutonValiderCptClientPbx').removeClass('disabled'); 87 } 88 }); 89 })(jQuery); 90} 91 92function setFormPaiementCptCliPayboxPourCouplageAvecCPay() { 93 (function ($) { 94 $('.erreurCouplagePaybox').hide(); 95 96 // Les valeurs par défaut 97 var quelPaiement = 'solde'; 98 var montant_a_payer = $("#inpt_solde_cptCliPbx").val(); 99 100 // On regarde ensuite si une checkbox est cochée 101 if ($('input[name=choixPaiementCB]:visible:checked').val() === 'acompte') { 102 quelPaiement = 'acompte'; 103 montant_a_payer = $("#inpt_acompte_cptCliPbx").val(); 104 } else if ($('input[name=choixPaiementCB]:visible:checked').val() === 'montantlibre') { 105 $('#input_montantVersement').removeClass('errSaisie'); 106 var regMontant = new RegExp('^[0-9]+([.]{1}[0-9]{1,2})?$');
107 var montantLibre = $('#input_montantVersement').val(); 108 if (regMontant.test(montantLibre)) { 109 montant_a_payer = parseFloat(montantLibre) * 100; 110 } else { 111 $('#input_montantVersement').addClass('errSaisie'); 112 return false; 113 } 114 quelPaiement = 'versement'; 115 } 116 117 var exe = $("#form_formPbx").attr("exercice"); 118 var type_resa = $("#form_formPbx").attr("type_resa"); 119 var nom_instance = $("#form_formPbx").attr("nom_instance"); 120 var base = $("#form_formPbx").attr("base"); 121 var numero_resa = $("#form_formPbx").attr("numero_resa"); 122 var idSession = $("#form_formPbx").attr("idsession"); 123 var dpt = $("#form_formPbx").attr("dpt"); 124 125 $.ajax({ 126 url: '/lib_2/ajax/infosDist.php', 127 method: 'POST', 128 data: { 129 info: 'REGLTCPTCLIPBX', 130 PHPSESSID: idSession, 131 numero_resa: numero_resa, 132 exercice: exe, 133 type_resa: type_resa, 134 nom_instance: nom_instance, 135 base: base, 136 montant_a_payer: montant_a_payer, 137 dpt: dpt, 138 quelPaiement: quelPaiement 139 }, 140 contentType: "application/x-www-form-urlencoded", 141 success: function (retour) { 142 eval("var tabRetour=" + retour); 143 if (tabRetour.code == "OK") { 144 majFormPaybox(tabRetour); 145 validerFormulairePaybox(); 146 } else { 147 $('.erreurCouplagePaybox').html(tabRetour.msg); 148 $('.erreurCouplagePaybox').show(); 149 $('#a_btChoixPaiementReserver').removeClass('disabled'); 150 } 151 }, 152 beforeSend: function () { 153 $('#a_btChoixPaiementReserver').addClass('disabled'); 154 }, 155 error: function () { 156 $('#a_btChoixPaiementReserver').removeClass('disabled'); 157 } 158 }); 159 })(jQuery); 160} 161 162function setFormPaiementCptCliANCVCentralPay() { 163 (function ($) { 164 var quelPaiement = 'soldeANCV'; 165 var montant_a_payer = $("#inpt_solde_cptCliPbx").val(); 166 if ($("input[name='choixPaiementANCV']").length && $("input[name='choixPaiementANCV']:checked").length && $("input[name='choixPaiementANCV']:checked").val() === 'acompte') { 167 quelPaiement = 'acompteANCV'; 168 montant_a_payer = $("#inpt_acompte_cptCliPbx").val(); 169 } 170 171 var exe = $("#form_formPbx").attr("exercice"); 172 var type_resa = $("#form_formPbx").attr("type_resa"); 173 var nom_instance = $("#form_formPbx").attr("nom_instance"); 174 var base = $("#form_formPbx").attr("base"); 175 var numero_resa = $("#form_formPbx").attr("numero_resa"); 176 var idSession = $("#form_formPbx").attr("idsession"); 177 var dpt = $("#form_formPbx").attr("dpt"); 178 179 $.ajax({ 180 url: '/lib_2/ajax/infosDist.php', 181 method: 'POST', 182 data: { 183 info : 'REGLTCPTCLIPBX', 184 PHPSESSID : idSession, 185 numero_resa : numero_resa, 186 exercice : exe, 187 type_resa : type_resa, 188 nom_instance : nom_instance, 189 base : base, 190 montant_a_payer : montant_a_payer, 191 dpt : dpt, 192 quelPaiement : quelPaiement 193 }, 194 contentType: "application/x-www-form-urlencoded", 195 dataType: 'json', 196 success: function (tabRetour) { 197 if (tabRetour.code === "OK") { 198 majFormPaybox(tabRetour); 199 validerFormulairePaybox(); 200 } else { 201 location.reload(); 202 } 203 }, 204 beforeSend: function () { 205 $('#a_btChoixPaiementPopinEANCV').addClass('disabled'); 206 }, 207 error: function () { 208 $('#a_btChoixPaiementPopinEANCV').removeClass('disabled'); 209 } 210 }); 211 })(jQuery); 212} 213 214// Variables globales permettant de paramétrer les calendriers datepicker 215// Gestion de l'expiration de la session, 216// les requêtes AJAX renvoit cette valeur lorsqu'aucun objet dossier n'est récupéré en session 217var lang = ""; 218var onEstSurUnSiteAnglaisEtFautMettreLeSigneEuroDevantLeMontant; 219var urlAJAX = "/lib_2/ajax/gereResa.php?"; 220var idSession; 221var errDossierNull = "dossierNull"; 222var chainePlanning = ""; 223var dateDebPlanning = ""; 224var infoBulles = ""; 225var nbJours = ""; 226var objDateDeb; 227var objDateFin; 228var nbMois; 229var txtAttente = "<p id='p_msgAttente'><img id='img_roueAttente' style='margin:auto' src=/config_v3/imgs_defaut/loading/ajax-loader2.gif /></p>"; 230var txtVerifDispos = "<p id='p_msgAttente'><img id='img_roueAttente' style='margin:auto' src=/config_v3/imgs_defaut/loading/loader.gif /></p>"; 231var txtErreurPrix = '<p id="p_msgErreur">Une erreur est survenue lors du calcul du prix de votre réservation. Si le problème persiste, contactez la centrale de réservation.</p>'; 232var gestprod = false;
233var rafraichirSurUrlActuelleApresSelectDateFin = false; // si on utilise le calendrier sur la fiche, il faut rafraichir la page et pas aller en etape 1 234var modeCalculPrixSurFiche = false; 235var afficheRecapPrix; // Permet de savoir s'il faut afficher le recapPrix après la validation des dates 236var defaultDateDebut = null; 237 238function initLangue(){ 239 (function($){ 240 lang = $("body").attr("data-langue"); 241 if (lang == "ANGLAIS") 242 lang = "en-GB"; 243 else if (lang == "HOLLANDAIS") 244 lang = "nl"; 245 else if (lang == "ALLEMAND") 246 lang = "de"; 247 else 248 lang = "fr"; 249 250 if (lang == "en-GB") 251 onEstSurUnSiteAnglaisEtFautMettreLeSigneEuroDevantLeMontant = true; 252 else 253 onEstSurUnSiteAnglaisEtFautMettreLeSigneEuroDevantLeMontant = false; 254 })(jQuery); 255} 256 257/** 258 * Récupération du numéro de session dans l'attribut data-itea de la balise body<br /> 259 * On utilise ensuite cet id de session pour l'url des appels AJAX<br /> 260 * et pour les liens vers les étapes suivantes 261 */ 262function getIdSessionInHtml(){ 263 var idSess; 264 (function($){ 265 idSess = $("body").attr("data-iditea"); 266 if(!idSess){ 267 // on va prendre dans la div IE < 10 ... 268 idSess = $('.data-iditea').attr('id'); 269 } 270 if (urlAJAX.indexOf("PHPSESSID") == -1) { 271 urlAJAX += 'PHPSESSID='+idSess; 272 } 273 })(jQuery); 274 //alert ("IDSESSION "+idSess); 275 return 'PHPSESSID='+idSess; 276} 277 278function ajoutePHPSESSID_history(){ 279 var params = recupParamsUrl(); 280 if (params.PHPSESSID) { 281 return; 282 } 283 // Yoann 17/06/2016 (fiche 267553) : J'ajoute le PHPSESSID dans l'URL et je fais le remplacement dans l'historique de navigation 284 // Pas de reload donc pas de perte de temps et le bouton retour du navigateur fonctionnera bien en étape 2 285 286 history.replaceState(null, '', location.pathname.replace('//','/')+location.search+'&'+getIdSessionInHtml()); 287} 288 289/** 290 * Fonction de récupération des paramètres GET de la page<br /> 291 * @return Array Tableau associatif contenant les paramètres GET 292 */ 293function recupParamsUrl(){ 294 var params = location.search.substring(1).split('&'); 295 var retour = []; 296 for (var i=0; i<params.length; i++){ 297 var param = params[i].split('='); 298 retour[param[0]]=param[1]; 299 } 300 301 return retour; 302} 303 304/** 305 * Récupération de l'instance dans les paramètres de l'url 306 */ 307function getInstanceInUrl(){ 308 var params = recupParamsUrl(); 309 if (!params.ident) 310 return ""; 311 var tabIdent = params.ident.split("."); 312 var tabInstance = tabIdent[0].split("_"); 313 314 return tabInstance[0]; 315} 316 317/** 318 * Récupération du numéro d'hébergement dans l'url 319 */ 320function getNumHeberInUrl(){ 321 var params = recupParamsUrl(); 322 if (!params.ident) 323 return ""; 324 var tabIdent = params.ident.split("."); 325 326 return tabIdent[2]; 327} 328 329/** 330 * Fonction permettant de revenir à l'étape1 en affichant un message<br /> 331 * Principalement utilisé au retour d'un appel AJAX si la session a expirée 332 * @param msg Le message à afficher 333 */ 334function retourEtape1(msg){ 335 alertAMalibu(msg); 336 setTimeout(function(){ 337 var pos = location.search.length; 338 var tmp = "?"; 339 if (location.search.indexOf("PHPSESSID") > -1) { 340 // On enlève le PHPSESSID dans l'URL de retour 341 pos = location.search.indexOf("PHPSESSID"); 342 // On décrémente pour enlever le & à la fin 343 pos--; 344 tmp = location.search.substr(0, pos); 345 } else { 346 tmp = location.search; 347 } 348 console.log('foncResa.js retourEtape1 /resa/etape1.php', tmp); 349 location.href = "/resa/etape1.php"+tmp; 350 }, 3000); 351} 352 353function retourEtape1AvecDate(stringDate) { 354 var params = recupParamsUrl(); 355 location.href = location.pathname + '?ident=' + params['ident'] + '&' + stringDate; 356} 357 358function initBtnsFooter(){ 359 (function($){ 360 // Je mets les fancybox que sur chrome car en fonction d'un paramétrage 361 // Ca ne marche pas bien sur FF 362 // Marche plus correctement sur Chrome non plus donc je désactive... 363 if (false && navigator.appVersion.indexOf("Chrome") > -1) { 364 $(".a_btnFooter[href$='.pdf']").fancybox({ 365 type : 'iframe', 366 titleShow : false, 367 autoScale : false, 368 width : "90%", 369 height : "90%" 370 }); 371 372 if ($("#a_valideCGV").length > 0) { 373 $("#a_valideCGV[href$='.pdf']").fancybox({ 374 type : "iframe", 375 titleShow : false, 376 autoScale : false, 377 width : "90%", 378 height : "90%" 379 }); 380 } 381 } 382 383 $(".a_btnFooter[href^='#div']").fancybox({ 384 fitToView: false, 385 maxWidth : "800", 386 maxHeight : "600" 387 }); 388 389 })(jQuery); 390} 391 392function initGooglePlusResa() { 393 return;
393 // fin de google plus, on return pour éviter les erreurs js 394 (function($){ 395 396 _idBtnConnexionGoogle = 'div_btnConnexionGoogle'; 397 if ($('#div_btnConnexionGoogle').is('.compteGdf')) { 398 _fctGooglePlusOK = authentificationGoogleCompteGdf; 399 _fctGooglePlusKO = authentificationGoogleCompteGdfKO; 400 } else { 401 _fctGooglePlusOK = resaGooglePlusOK; 402 _fctGooglePlusKO = resaGooglePlusKO; 403 } 404 405 $('#div_pasdecomptegdf').click(function(){ 406 _idBtnConnexionGoogle = 'div_btnConnexionGoogle_creaCptGDF'; 407 _fctGooglePlusOK = checkIfCompteFNGFGoogleExiste; 408 _fctGooglePlusKO = resaGooglePlusKO; 409 initBtnGooglePlus(); 410 }); 411 412 $('#div_connexioncomptegdf>p').click(function(){ 413 _idBtnConnexionGoogle = 'div_btnConnexionGoogle'; 414 if ($('#div_btnConnexionGoogle').is('.compteGdf')) { 415 _fctGooglePlusOK = authentificationGoogleCompteGdf; 416 _fctGooglePlusKO = authentificationGoogleCompteGdfKO; 417 } else { 418 _fctGooglePlusOK = resaGooglePlusOK; 419 _fctGooglePlusKO = resaGooglePlusKO; 420 } 421 422 initBtnGooglePlus(); 423 }) 424 425 })(jQuery); 426} 427 428function resaGooglePlusOK(accessToken, tabInfosUser) { 429 return; // fin de google plus, on return pour éviter les erreurs js 430 (function($){ 431 // Autorisation OK, on masque les boutons de connexion 432 $('.div_connexionReseau').hide(); 433 majFormClientResa_reseauSocial(tabInfosUser); 434 })(jQuery); 435} 436 437function resaGooglePlusKO(erreur) { 438 return; // fin de google plus, on return pour éviter les erreurs js 439 //console.log('Connexion KO : ' + erreur); 440 // Une erreur s'est produite. 441 // Codes d'erreur possibles : 442 // "access_denied" - L'utilisateur a refusé l'accès à votre application 443 // "immediate_failed" - La connexion automatique de l'utilisateur a échoué 444 // console.log('Une erreur s'est produite : ' + retour['error']); 445} 446 447function checkIfCompteFNGFGoogleExiste(accessToken, tabInfosUser){ 448 (function($){ 449 var data = 'email='+tabInfosUser.email+'&type=connexionCompteGdf'; 450 if ($('#div_btnConnexionGoogle_creaCptGDF').data('sessid')) { 451 data += '&phpsessid='+$('#div_btnConnexionGoogle_creaCptGDF').data('sessid'); 452 } 453 if ($('#div_btnConnexionGoogle_creaCptGDF').data('idsrv')) { 454 data += '&idsrv='+$('#div_btnConnexionGoogle_creaCptGDF').data('idsrv'); 455 } 456 data += '&connectGoogle=1'; 457 $.ajax({ 458 type: 'POST', 459 url: urlAJAX, 460 data: data, 461 success:function(result){ 462 var tabResult = XMLToArray(result); 463 if(tabResult.code === 'KO') { 464 creaCptGDFGoogle(tabInfosUser); 465 } else { 466 if (window.opener && window.location.host!=window.opener.location.host) { 467 window.opener.postMessage('reload','*'); 468 } else { 469 var urlHref = location.search + "&" + getIdSessionInHtml(); 470 location.href = urlHref; 471 } 472 } 473 if (window.opener && window.location.host!=window.opener.location.host) { 474 window.close(); 475 } 476 } 477 }); 478 })(jQuery); 479} 480 481function creaCptGDFGoogle(tabInfosUser){ 482 (function($){ 483 $.ajax({ 484 type: "POST", 485 url: urlAJAX, 486 dataType: 'json', 487 data: {type: "getMsgCreaCptGDF"}, 488 success: function(result){ 489 $('#div_msgChoixReseauxSociauxOuSaisieFormulaire span').html(result.msg); 490 } 491 }); 492 493 $('#div_saisieClientPassword').hide(); 494 $('#inpt_connectGoogle').val('O'); 495 majFormClientResa_reseauSocial(tabInfosUser); 496 // 314519 : Je ne bloque pas les champs de saisie du mail si on ne reçoit rien du WebService Google+ 497 if (tabInfosUser.email) { 498 $('#inpt_mailClient').attr('disabled','disabled'); 499 $('#inpt_confirmMailClient').attr('disabled','disabled'); 500 } 501 $('#inpt_mdpClient').val(tabInfosUser.id); 502 503 })(jQuery); 504} 505 506function checkIfCompteFNGFFacebookExiste(tabInfosUser){ 507 (function($){ 508 var data = 'email='+tabInfosUser.email+'&type=connexionCompteGdf'; 509 if ($('#div_btnConnexionFacebook_creaCptGDF').data('sessid')) { 510 data += '&phpsessid='+$('#div_btnConnexionFacebook_creaCptGDF').data('sessid'); 511 } 512 if ($('#div_btnConnexionFacebook_creaCptGDF').data('idsrv')) { 513 data += '&idsrv='+$('#div_btnConnexionFacebook_creaCptGDF').data('idsrv'); 514 } 515 data += '&connectFacebook=1'; 516 $.ajax({ 517 type: 'POST', 518 url: urlAJAX, 519 data: data, 520 success:function(result){ 521 var tabResult = XMLToArray(result); 522 if(tabResult.code === 'KO') { 523 creaCptGDFFacebook(tabInfosUser); 524 } else { 525 if (window.opener && window.location.host!=window.opener.location.host) { 526 window.opener.postMessage('reload','*'); 527 } else { 528 var urlHref = location.search + "&" + getIdSessionInHtml(); 529 location.href = urlHref; 530 } 531 } 532 if (window.opener && window.location.host!=window.opener.location.host) { 533 window.close(); 534 } 535 } 536 }); 537 })(jQuery); 538} 539 540function creaCptGDFFacebook(tabInfosUser){ 541 (function($){ 542 $.ajax({ 543 type: "POST", 544 url: urlAJAX, 545 dataType: 'json', 546 data: {type: "getMsgCreaCptGDF"}, 547 success: function(result){ 548 $('#div_msgChoixReseauxSociauxOuSaisieFormulaire span').html(result.msg); 549 } 550 }); 551 552 $('#div_saisieClientPassword').hide(); 553 $('#inpt_connectFB').val('O'); 554 majFormClientResa_reseauSocial(tabInfosUser); 555 // 314519 : Je ne bloque pas les champs de saisie du mail si on ne reçoit rien du WebService Facebook 556 if (tabInfosUser.email) { 557 $('#inpt_mailClient').attr('disabled', 'disabled'); 558 $('#inpt_confirmMailClient').attr('disabled', 'disabled'); 559 } 560 $('#inpt_mdpClient').val(tabInfosUser.id); 561 562 })(jQuery); 563} 564 565/** 566 * Fonction appelée au chargement de etape1.php et permettant d'initialiser les champs de saisie des dates 567 * et également les évènements sur les différents objets du formulaire 568 */ 569function initEtape1(){ 570 (function($){ 571 $.ajaxSetup({ 572 timeout: 100000 573 }); 574 initLangue(); 575// $(document).ready(function(){ 576 idSession = getIdSessionInHtml(); 577// }); 578 ajoutePHPSESSID_history(); 579 nbMois = $("#inpt_nbMoisCalend").val(); 580 if(!nbMois){ 581 nbMois = 2; 582 } 583 initBtnsFooter(); 584 //seulement pour ITEA : permet de voir les détails de la requete de dispo 585 $('#divBoutonAfficheDetailsVerifDate').click(function(){$('#divInfosResaITEA').show();}).show(); 586 // On initialise les datepicker en français pour avoir les noms des mois et des jours en fonction de la langue du site 587 $.datepicker.setDefaults($.datepicker.regional[lang]); 588 init_btnModifierDates(); 589 590 // On positionne l'étape courante sur la première div qui n'a pas de récap visible 591 $(".div_uneEtapeRecap:hidden:first").parent().addClass('div_uneEtapeCurr'); 592 // fiche 253899 593 $('span.sp_choixModeResa').click(function(){ 594 var loc = $(this).attr('data-href'); 595 location.href = loc; 596 }); 597 if ($('#input_testDatepickerResa').length>0) { 598 initDatepickersResa(); 599 initChangeJourRef(); 600 initChangeHeureDebFin(); 601 } else { 602 afficherMasquerCalendrier(); 603 initDatepickersDateNaissance(); 604 } 605 // fiche 243319 : on met en commentaires... 606 //$(".div_uneEtapeGrisee *").attr("disabled", true); 607 608 if ($("#div_uneEtape_compoFamilleGite").length > 0) { 609 setEventsForGite(); 610 } else if ($("#div_uneEtape_compoFamilleChambre").length > 0) { 611 setEventsForChambre(); 612 } 613 614 // fiche 243319 : ... et on déplace ici 615 $(".div_uneEtapeGrisee *").attr("disabled", true); 616 617 if ($('#div_uneEtape_selectionOrigine').length > 0) { 618 $('input[name="radio_selectionOrigine"]').change(function () { 619 var origine = $('input[name="radio_selectionOrigine"]:checked').val(); 620 $.ajax({ 621 type: 'POST', 622 url: urlAJAX, 623 data: {type: 'setTypeDossier_resaBureau', origine: origine}, 624 success:function(reponse){ 625 var tabRetour = XMLToArray(reponse); 626 if (tabRetour.code == 'OK') { 627 afficheEffaceRecapPrix(tabRetour); 628 } 629 } 630 }); 631 $('.divInfoModificationOrigineTauxCommission').slideDown('fast'); 632 }); 633 } 634 635 636 // Affectation des animaux au Dossier, on gère ensuite l'affichage des options animales 637 // Seulement s'il y a des options facultatives sinon on affiche directement le récap 638 $('body').delegate('.select_compoAnimaux', 'change', function() { 639 var prefixId = $(this).attr('data-num'); 640 var nbMax = $("#inpt_nbAnimauxMax"+prefixId).val(); 641 // on récupère le vrai nombre d'animaux autorisés (qui sera le même que nbMax, sauf dans le cas d'une résa pv avec dépassement de capacité animaux) 642 var nbMaxReel; 643 try{ 644 nbMaxReel = parseInt($(this).attr('data-nbAnimaux')); 645 } 646 catch(e){ 647 nbMaxReel =nbMax; 648 } 649 650 affectAnimaux(prefixId); 651 if ($(".option.animal").length > 0) { 652 afficheEffaceOptions("Animaux"); 653 } 654 else { 655 $("#div_recapOptionsAnimaux").hide(); 656 etapeCourante($("#div_uneEtapeAnimaux"), true); 657 } 658 if ($("#select_compoAnimauxChien"+prefixId).val() == 0 && $("#select_compoAnimauxChat"+prefixId).val() == 0) 659 $("#div_recapOptionsAnimaux").hide();
660 $("#div_uneEtapeAnimaux").find(".inpt_validEtape").val("Oui"); 661 var nbSelect = $(this).val(); 662 nbSelect = nbMax - nbSelect; 663 var i = 1; 664 while (i<=nbSelect && i > 0) { 665 if ($(this).is($("#select_compoAnimauxChien"+prefixId))) { 666 if ($("#select_compoAnimauxChat"+prefixId).children("[value='"+i+"']").length == 0) { 667 $("#select_compoAnimauxChat"+prefixId).append("<option value='"+i+"'>"+i+"</option>"); 668 } 669 } 670 else { 671 if ($("#select_compoAnimauxChien"+prefixId).children("[value='"+i+"']").length == 0) { 672 $("#select_compoAnimauxChien"+prefixId).append("<option value='"+i+"'>"+i+"</option>"); 673 } 674 } 675 i++; 676 } 677 678 for (i=nbMax; i>nbSelect; i--) { 679 if ($(this).is($("#select_compoAnimauxChien"+prefixId))) { 680// $("#select_compoAnimauxChat").children("[value='"+i+"']").hide(); 681 $("#select_compoAnimauxChat"+prefixId).children("[value='"+i+"']").remove(); 682 } 683 else { 684// $("#select_compoAnimauxChien").children("[value='"+i+"']").hide(); 685 $("#select_compoAnimauxChien"+prefixId).children("[value='"+i+"']").remove(); 686 } 687 } 688 689 if(prefixId>0){ 690 //j'affecte mes animaux par chambre, il faut que je modifie la liste totale pour que ce soit visible sur le recap 691 var numOption = $(this).closest('tr.optionChambre').attr('numoption'); 692 var valFinale = parseInt($("#select_compoAnimauxChat"+prefixId).val()) + parseInt($("#select_compoAnimauxChien"+prefixId).val()); 693 afficheEffaceOptionsSupplementaireObligatoires(numOption,prefixId,valFinale); 694 } 695 var nbChiensMax = $('#inpt_nbChiensMax').val(); 696 var nbChatsMax = $('#inpt_nbChatsMax').val(); 697 // gzestion de la surcapacite 698 if((nbMaxReel != parseInt(nbMax)) && nbMaxReel>=0){ 699 var valSelected = parseInt($(this).val()); 700 if ($(this).is($("#select_compoAnimauxChien"+prefixId))){ 701 $('option', "#select_compoAnimauxChat"+prefixId).each(function(){ 702 let valeurOption = parseInt($(this).val()); 703 if(estSurCapaciteParTypeAnimal(valeurOption, valSelected, nbMaxReel, nbChatsMax, nbChiensMax)){ 704 $(this).addClass('surcapacite'); 705 } 706 else{ 707 $(this).removeClass('surcapacite'); 708 } 709 }); 710 } 711 if($(this).is($("#select_compoAnimauxChat"+prefixId))){ 712 $('option', "#select_compoAnimauxChien"+prefixId).each(function(){ 713 let valeurOption = parseInt($(this).val()); 714 if(estSurCapaciteParTypeAnimal(valeurOption, valSelected, nbMaxReel, nbChiensMax, nbChatsMax)){ 715 $(this).addClass('surcapacite'); 716 } 717 else{ 718 $(this).removeClass('surcapacite'); 719 } 720 }); 721 } 722 var nbChats = parseInt($("#select_compoAnimauxChat"+prefixId).val()); 723 var nbChiens = parseInt($("#select_compoAnimauxChien"+prefixId).val()); 724 var divMessage; 725 if(prefixId){ 726 divMessage = $(this).parents('.div_uneEtapeAnimaux').find('.messageSurcapaciteAnimaux'); 727 } 728 else{ 729 divMessage = $('.messageSurcapaciteAnimaux', '#div_uneEtapeAnimaux'); 730 } 731 if(nbMaxReel<(nbChiens+nbChats) && !estResaBureauProp()){ 732 $(divMessage).show('fast'); 733 } 734 else{ 735 $(divMessage).hide(); 736 } 737 afficheAlerteChiensChats(nbMaxReel, nbChiensMax, nbChiens, nbChatsMax, nbChats); 738 } 739 740 741 }); 742 if($('#div_uneEtape_assuranceAnnul').length>0){ 743 $('#div_uneEtape_assuranceAnnul').css('display','none'); 744 } 745 746 initAssurance(); 747 if ($('input[name="formuleAssurance"] :selected').length > 0 && $('input[name="formuleAssurance"] :selected').val().length > 0) { 748 verifiePaysCouvertParAssurance('#selectPaysAssurance_' + $('input[name="formuleAssurance"] :selected').val()); 749 } 750 751 $('body').delegate('input:radio', 'change', function() { 752 var btRadio = $(this);
753 var regexAnimaux = /^animaux[0-9]*$/; 754 if(regexAnimaux.test(btRadio.attr('name'))) { 755 if (btRadio.val() == "Oui") { 756 btRadio.closest('.div_uneEtapeContentText').find('.div_compoAnimaux').show(); 757 btRadio.closest('.div_uneEtapeContentText').find('.div_recapOptionsAnimaux').show(); 758 } 759 else { 760 btRadio.closest('.div_uneEtapeContentText').find('.div_compoAnimaux').hide(); 761 btRadio.closest('.div_uneEtapeContentText').find('.div_recapOptionsAnimaux').hide(); 762 btRadio.closest('.div_uneEtapeContentText').find(".select_compoAnimaux").val(0); 763 btRadio.closest('.div_uneEtapeContentText').find(".select_compoAnimaux").trigger('change'); 764 /*if($(this).attr('data-num') > 0){ 765 var numOption = $(this).closest('tr.optionChambre').attr('numoption'); 766 afficheEffaceOptionsSupplementaireObligatoires(numOption,$(this).attr('data-num'),'0'); 767 affectAnimaux($(this).attr('data-num')); 768 }else{ 769 afficheEffaceOptions("Animaux"); 770 affectAnimaux(); 771 }*/ 772 // On affecte les animaux pour permettre la désaffectation (affectation à 0) 773 etapeCourante($("#div_uneEtapeAnimaux"), true); 774 } 775 } 776 }); 777 778 779 initActionsMotMagique(false); 780 781 // Modification d'une étape validée (le bouton s'affiche seulement après les validations) 782 $(".a_modifEtape").click(function(){ 783 $(this).siblings("h3").find(".sp_lblEtape").validationEngine("hide"); 784// $(this).parents(".div_uneEtape").find(".inpt_validEtape").val("Non"); 785 $(this).parents(".div_uneEtape").find(".div_uneEtapeRecap").hide("slow"); 786 $(".div_uneEtapeCurr").removeClass('div_uneEtapeCurr'); 787 $(this).parents(".div_uneEtape").addClass('div_uneEtapeCurr'); 788 $(this).parents(".div_uneEtape").find(".div_uneEtapeContent").show("slow",function(){ 789 $(this).parents(".div_uneEtape").find(".div_uneEtapeContent").css("overflow",""); 790 }); 791 $(this).hide(); 792 }); 793 794 // gestion de la modif des frais de dossier 795 if ($('#fraisDossierPV').length > 0) { 796 // pour ne rentrer que des numéros : 797 $('#fraisDossierPV').keypress(function(event){ 798 var charCode = event.which; 799 if (charCode > 31 && ((charCode < 48 || charCode >
799 57) && charCode !== 44 && charCode !== 46)){ 800 event.preventDefault(); 801 } 802 if (charCode > 31){ 803 var val = $(this).val()+String.fromCharCode(charCode); 804 var regex = /^(\d)*([\.,]){0,1}(\d)*$/; 805 if(!regex.test(val)){ 806 event.preventDefault(); 807 } 808 } 809 }); 810 811 $('#buttonFraisDossierPV').click(function() { 812 $.ajax({ 813 type: "POST", 814 url: urlAJAX, 815 data: {type: "affecteFraisDossier", frais: $('#fraisDossierPV').val()}, 816 beforeSend: function() { 817 affMsgAttenteParDessusInDiv("div_resaRecap", "recapPrix", txtAttente); 818 }, 819 success: function(result) { 820 var tabRetour = XMLToArray(result); 821 if (tabRetour.code == 'OK') { 822 afficheEffaceRecapPrix(tabRetour); 823 } 824 else { 825 tabRetour.msg = tabRetour.msg || false; 826 if (tabRetour.msg) { 827 alertAJquery(tabRetour.msg); 828 } 829 } 830 $('#sp_recapFraisDossier').html(tabRetour.htmlRecapFraisDossier); 831 effaceMsgAttenteParDessus("recapPrix"); 832 etapeCourante($("#div_uneEtape_fraisDossier"), true); 833 } 834 }); 835 }); 836 $('#buttonAnnuleFraisDossierPV').click(function() { 837 $('#fraisDossierPV').val(''); 838 $.ajax({ 839 type: "POST", 840 url: urlAJAX, 841 data: {type: "affecteFraisDossier", frais: ''}, 842 beforeSend: function() { 843 affMsgAttenteParDessusInDiv("div_resaRecap", "recapPrix", txtAttente); 844 }, 845 success: function(result) { 846 var tabRetour = XMLToArray(result); 847 if (tabRetour.code == 'OK') { 848 849 afficheEffaceRecapPrix(tabRetour); 850 } 851 else { 852 tabRetour.msg = tabRetour.msg || false; 853 if (tabRetour.msg) { 854 alertAJquery(tabRetour.msg); 855 } 856 } 857 $('#sp_recapFraisDossier').html(tabRetour.htmlRecapFraisDossier); 858 effaceMsgAttenteParDessus("recapPrix"); 859 etapeCourante($("#div_uneEtape_fraisDossier"), true); 860 } 861 }); 862 }); 863 } 864 865 $('#a_btnRecalculPrix').click(function(){ 866 questionRecalculAuto(); 867 }); 868 869 // On vérifie si toutes les étapes obligatoires ont été validées 870 // Si c'est le cas on envoie à l'étape2 en vérifiant que l'URL contient déjà PHPSESSID 871 // Pour ne pas avoir PHPSESSID en double dans l'url à l'étape2 872 $("#div_btnConfirmer > a:not(.a_btnAttenteConfirm), #div_btnConfirmer_1 > a:not(.a_btnAttenteConfirm)").click(function(){ 873 $(this).hide(); 874 $(".a_btnAttenteConfirm").show(); 875 if ($("#div_motMagique > span.confirmSaisie.ko:visible").length == 0 && etapesValid()) { 876 enregistreElementsAvantValidationEtape1(); 877 var paramsURL = location.search; 878 paramsURL += '&div_btnConfirmer=1'; 879 // On redirige seulement s'il n'y a qu'un bouton de validation sur la page, dans le cas de le résa 3 étapes 880 // On ne fait pas de redirection elle sera faite dans la fonction initEtape1_2(); 881 if ($(this).is('#div_btnConfirmer > a:not(.a_btnAttenteConfirm)')) { 882 var numeroEtape = '2'; 883 if ($('#divNumeroProchaineEtape').attr('data-prochaineetape')) { 884 numeroEtape = $('#divNumeroProchaineEtape').attr('data-prochaineetape'); 885 } 886 if (paramsURL.indexOf("PHPSESSID") > -1) { 887 location.href = 'etape' + numeroEtape + '.php' + paramsURL; 888 } else { 889 location.href = 'etape' + numeroEtape + '.php' + paramsURL + "&" + idSession; 890 } 891 } else { 892 $('#div_btnConfirmer_2 > a:not(.a_btnAttenteConfirm)').click(); 893 } 894 } 895 $(".a_btnAttenteConfirm").hide(); 896 $(this).show(); 897 }); 898 899 $('#divBoutonTerminerModification').click(function () { 900 enregistreElementsAvantValidationEtape1(); 901 if (etapesValid()) { 902 terminerModifResa(); 903 } 904 }); 905 906 //gestion du récap des étapes validées ou non (je mets un timer pour maj régulier, car on peut pas mettre à jour sur un onchange ou on click): 907 //window.setInterval(function(){initResumeEtapes();},2000); 908 909 // Gestion de la modification des horaires d'arrivée/départ pour les réservations faites sur le module PROP 910 $('.inpt_modifHoraires').live('blur', function(){ 911 setHeuresArriveeDepart(); 912 }); 913 914 initModifPrixResaBureau(); 915 initModalTaxeSejour(); 916 917 })(jQuery); 918} 919 920function afficheAvertissementErp(){ 921 (function($){ 922 if (!$('#afficheAvertissementErp').length) { 923 return; 924 } 925 nbEnfants = parseInt($('#select_compoFamilleEnfant').val()); 926 if (nbEnfants > 6) { 927 $('#afficheAvertissementErp').show(); 928 } else { 929 $('#afficheAvertissementErp').hide(); 930 } 931 })(jQuery); 932} 933 934function afficherMasquerCalendrier(tabParam){ 935 (function($){ 936 if ($("#div_choixModeResaGEGS").length > 0) { 937 var modeResa = $("input:radio[name=modeResa]:checked").val(); 938 } 939 var tabData = { 940 type: "getPlanningDeb", 941 modeResa: modeResa 942 } 943 if(tabParam){ 944 //Si on appelle cette fonction depuis autre chose que initEtape1, il faut creer un mini dossier, il faut les infos de base qui sont dasn div_fiche_moteurdates 945 tabData = { 946 type: "getPlanningDeb", 947 modeResa: modeResa , 948 ident: tabParam.ident , 949 instance: tabParam.instance , 950 exercice :tabParam.exercice, 951 estpresentsurfiche : true 952 } 953 if(!nbMois){ 954 nbMois = 1 955 } 956 if(tabParam.modefiche){ 957 rafraichirSurUrlActuelleApresSelectDateFin = true; 958 } 959 if (tabParam.modeFicheV8){ 960 modeCalculPrixSurFiche = true; 961 } 962 } 963 $(".sp_fermerCal").click(function(){ 964 $(this).parents(".div_calendDateDebFin").hide(); 965 }); 966 // Fonction sur le focus du champ de la date d'arrivée 967 $("#inpt_resaDateDeb").click(function(){ 968 if ($("#div_choixModeResaGEGS").length > 0) { 969 modeResa = $("input:radio[name=modeResa]:checked").val(); 970 tabData.modeResa = modeResa; 971 } 972 $("#div_calendrierDeb").show().addClass("open"); 973 $("#div_msgErreursDateDeb").hide(); 974 $("#div_calendrierFin").hide().removeClass("open"); 975 // On créé la requête ajax permettant de récupérer les disponibilités de cette structure 976 $.ajax({ 977 type: "POST", 978 url: urlAJAX, 979 async: false, 980 data: tabData , 981 beforeSend: function(){ 982 $("#div_roueDatepickerDeb").show(); 983 }, 984 // Quand la requête Ajax s'est terminée correctement, 985 // On met à jour chainePlanning et dateDebPlanning pour paramétrer les datepicker 986 success: function(result){ 987 eval("var tabDispos="+result); 988 if (tabDispos.code == errDossierNull) { 989 retourEtape1(tabDispos.msg); 990 } 991 else if (tabDispos.errTechnq) { 992 afficheMsgErrTechnq(tabDispos.msg, tabDispos.titre, tabDispos.ident, true); 993 } 994 else if (tabDispos.code == "OK"){ 995 chainePlanning = tabDispos.chaineDispo; 996 dateDebPlanning = tabDispos.dateDeb; 997 dateFinPlanning = tabDispos.dateFin; 998 infoBulles = tabDispos.infoBulle; 999 initDatePickerDeb(); 1000 } 1001 else { 1002 alertAMalibu(tabDispos.msg); 1003 $("#div_calendrierDeb").hide().removeClass("open");
1004 $("#div_uneEtape_date").find(".inpt_validEtape").val("Non"); 1005 } 1006 $("#div_roueDatepickerDeb").hide(); 1007 } 1008 }); 1009 return false; // très important ça, pour éviter de propager l'évenement jusqu'au body car sinon on va faire un .hide() sur le calendrier (voir fonction initClicBody) 1010 }); 1011 1012 1013 // Au focus sur le champ de départ, on affiche le calendrier de fin 1014 // Si aucune date d'arrivée n'est sélectionnée, rien ne s'affichera (vérif Regex) 1015 // On masque le calendrier de début au cas ou il serait visible 1016 $("#inpt_resaDateFin").click(function(){ 1017 var regDate = new RegExp("[0-9]{2}\/[0-9]{2}\/[0-9]{4}"); 1018 $("#div_calendrierDeb").hide().removeClass("open"); 1019 if (regDate.test($("#inpt_resaDateDeb").val())) { 1020 if($('#div_datepickerFin').text() == ''){ 1021 // si je n'ai pas cliqué sur mon calendrier de départ mais que j'ai une date de debut/fin, il faut que ca fonctionne 1022 if($('#div_datepickerDeb').text() == ''){ 1023 $("#inpt_resaDateDeb").trigger('click') 1024 } 1025 setDateDeb($('#inpt_resaDateDeb').val()) 1026 initDatePickerFin(); 1027 }else{ 1028 $("#div_calendrierFin").show().addClass("open"); 1029 } 1030 } 1031 else { 1032 $("#div_msgErreursDateDeb").show(); 1033 $("#div_calendrierDeb").show().addClass("open"); 1034 if (tabParam && tabParam.modeFicheV8) { 1035 ouvreDatePickerDateDeb_packDivDatesTarifs(); 1036 } 1037 } 1038 1039 return false; 1040 }); 1041 1042 initChangeJourRef(); 1043 initChangeHeureDebFin(); 1044 })(jQuery); 1045} 1046 1047 1048function initResumeEtapes(){ 1049 (function($){ 1050 $(".inpt_validEtape").each(function(){ 1051 var classe,li,divParente,numero,titre,id; 1052 divParente = $(this).parents('.div_uneEtape'); 1053 numero = $(divParente).find('.sp_numEtape').text(); 1054 titre = $(divParente).find('.sp_lblEtape').text(); 1055 id = $(divParente).attr('id'); 1056 if($(this).val() !='Oui'){ 1057 classe = "notValid"; 1058 } 1059 else{ 1060 classe = "valid"; 1061 } 1062 1063 li = "<li class='"+classe+"' id='resume_"+id+"'>"; 1064 li += "<a href='#"+id+"'>"+ numero + ". "+titre+"</a>"; 1065 li+="</li>"; 1066 if($('#resume_'+id).length>0){ 1067 $('#resume_'+id).remove(); 1068 } 1069 $('#recapEtapesValidees > ol').append(li); 1070 }); 1071 })(jQuery); 1072 1073} 1074 1075/** 1076 * Affectation des évènements sur les éléments JS spécifiques aux gîtes 1077 */ 1078function setEventsForGite(){ 1079 (function($){ 1080 $("#div_optionsSuppl").find("tr:last").addClass("last"); 1081 $("#div_infosOptionsObligatoiresContent").find("tr:last").addClass("last"); 1082 $("#div_infosOptionsAnimauxContent").find("tr:last").addClass("last"); 1083 1084 $("#select_compoFamilleAdulte").change(function(){ 1085 metAJourListeFamille(); 1086 afficheEffaceOptions("Adultes"); 1087 if ($(this).val() == 0) { 1088 if(estResaGP()) { // fiche 241930 1089 $("#div_infoCompoFamilleQuestionEnfants").hide(); 1090 $(".div_infoCompoFamilleReponseEnfants input").attr("checked", false); 1091 $("#div_infoCompoFamilleEnfants, #div_compoFamilleDateNaissanceEnfants, #div_compoFamilleDateNaissanceBebes").hide(); 1092 $(".select_compoFamilleAgeEnfants").val(0); 1093 $(".select_compoFamilleAgeBebes").val(0); 1094 $("#div_uneEtape_compoFamilleGite").find(".inpt_validEtape").val("Non"); 1095 } 1096 else{// fiche 249927 1097 if($('#select_compoFamilleEnfant').val() == 0 ){ // pas d'adultes ni d'enfants 1098 $("#div_uneEtape_compoFamilleGite").find(".inpt_val
1098idEtape").val("Non"); 1099 } 1100 if(!estResaBureauProp() && !estResaBureauGestloc()){ // si on est sur prop ou bureau, on peut choisir seulement des enfants 1101 $("#div_uneEtape_compoFamilleGite").find(".inpt_validEtape").val("Non"); 1102 } 1103 } 1104 } 1105 else { 1106 $("#div_infoCompoFamilleQuestionEnfants").show(); 1107 $(this).children("[value='0']").remove(); 1108 if ($('#inpt_enfantsNon').is(':checked') || !estResaGP()) { 1109 $("#div_uneEtape_compoFamilleGite").find(".inpt_validEtape").val("Oui"); 1110 } 1111 } 1112 affectFamille(); 1113 }); 1114 1115 // Si on revient d'une étape postérieure, il faut sélectionner le nombre d'enfants dans la liste 1116 if ($("#inpt_nbEnfants")) { 1117 metAJourListeFamille(); 1118 $("#select_compoFamilleEnfant").val($("#inpt_nbEnfants").val()); 1119 } 1120 1121 // Pour la liste des enfants, on gère également le champ de saisie des années de naissance des enfants 1122 $("#select_compoFamilleEnfant").change(function(){ 1123 metAJourListeFamille(); 1124 // On masque toutes les listes d'année de naissance 1125 // Puis on affiche le nombre de liste correspondant au nombre d'enfants sélectionnés 1126 $(".td_ageEnfants").hide(); 1127 if ($(this).val() != 0) { 1128 for (var i=1; i<=$(this).val(); i++) { 1129 $("#td_ageEnfant_"+i).show(); 1130 } 1131 $("#div_compoFamilleDateNaissanceEnfants").show("slow"); 1132 if (estResaBureauProp() || estResaBureauGestloc()) { 1133 $("#div_uneEtape_compoFamilleGite").find(".inpt_validEtape").val("Oui"); 1134 } else { 1135 if ($(".select_compoFamilleAgeEnfants[value=0]:visible").length == 0) { 1136 $("#div_uneEtape_compoFamilleGite").find(".inpt_validEtape").val("Oui"); 1137 } 1138 else { 1139 $("#div_uneEtape_compoFamilleGite").find(".inpt_validEtape").val("Non"); 1140 } 1141 verifCompoFamilleGiteAdultes(); 1142 } 1143 } 1144 else { 1145 $("#div_uneEtape_compoFamilleGite").find(".inpt_validEtape").val("Oui"); 1146 $("#div_compoFamilleDateNaissanceEnfants").hide("slow"); 1147 1148 $(".select_compoFamilleAgeEnfants").val(0); 1149 1150 verifCompoFamilleGiteAdultes(); 1151 } 1152 afficheEffaceOptions("Adultes"); 1153 affectFamille(); 1154 videDatesNaissanceNonVisibles(); 1155 }); 1156 1157 // Pour les bébés, on affecte juste le nombre de bébés au Dossier 1158 $("#select_compoFamilleBebe").change(function(){ 1159 if (bebeDansCapacite()) { 1160 metAJourListeFamille(); 1161 } 1162 1163 $(".td_ageBebe").hide(); 1164 if ($(this).val() != 0) { 1165 for (var i=1; i<=$(this).val(); i++) { 1166 $("#td_ageBebe_"+i).show(); 1167 } 1168 $("#div_compoFamilleDateNaissanceBebes").show("slow"); 1169 // ajout Caro suite fiche 287765 en resa bureau Gestloc ou bureau prop l age des bebes n est pas obligatoire comme pour les enfants 1170 if (estResaBureauProp() || estResaBureauGestloc()) { 1171 $("#div_uneEtape_compoFamilleGite").find(".inpt_validEtape").val("Oui"); 1172 } 1173 }else { 1174 $("#div_uneEtape_compoFamilleGite").find(".inpt_validEtape").val("Oui"); 1175 $("#div_compoFamilleDateNaissanceBebes").hide("slow"); 1176 1177 $(".select_compoFamilleBebe").val(0); 1178 1179 verifCompoFamilleGiteAdultes(); 1180 } 1181 affectFamille("bebes"); 1182 videDatesNaissanceNonVisibles(); 1183 }); 1184 1185 //Contrôle sur la date de naissance bébé au changement 1186 $('input[name=dateNaissanceBebe]').change((input) => { 1187 $('#message_err_age_bebe').hide(); 1188 if ($('#img_validAgeBebe_' + input.target.dataset.id).hasClass('fa')) { 1189 $('#img_validAgeBebe_' + input.target.dataset.id).removeClass(); 1190 $('#img_validAgeBebe_' + input.target.dataset.id).hide(); 1191 } 1192 1193 let dateNaissance = new OBJDate(input.target.value); 1194 dateNaissance.ajouteAnnee(input.target.dataset.ageMax); 1195 let dateDebSej = new OBJDate($('input#inpt_resaDateDeb').val()); 1196 1197 if (dateNaissance.estAvantOBJDate(dateDebSej)) { 1198 $('#img_validAgeBebe_' + input.target.dataset.id) 1199 .addClass('fa fa-close') 1200 .show('slow'); 1201 $('#message_err_age_bebe').show('slow'); 1202 } else { 1203 $('#img_validAgeBebe_' + input.target.dataset.id).addClass('fa fa-check'); 1204 $('#img_validAgeBebe_' + input.target.dataset.id).show('slow'); 1205 } 1206 }); 1207 1208 // Quand on choisit de venir avec des enfants, on invali
1208de l'étape jusqu'à la sélection des enfants 1209 $("input:radio[name=enfants]").change(function(){ 1210 if ($(this).val() == "Oui") { 1211 $("#div_uneEtape_compoFamilleGite").find(".inpt_validEtape").val("Non"); 1212 $("#div_infoCompoFamilleEnfants").show("slow"); 1213 } 1214 else { 1215 // Si des enfants étaient sélectionnés, il faut les désaffecter du Dossier 1216 if ($("#select_compoFamilleEnfant").val() > 0 || $("#select_compoFamilleBebe").val() > 0 ) { 1217 $("#select_compoFamilleEnfant" ).val(0); 1218 $('#select_compoFamilleBebe').val(0); 1219 if ($("tr.option.indiv.obligatoire:not(.animal):visible").length > 0) { 1220 afficheEffaceOptions("Adultes"); 1221 } 1222 affectFamille(); 1223 $("#div_infoCompoFamilleEnfants").hide("slow"); 1224 $("#div_compoFamilleDateNaissanceEnfants, #div_compoFamilleDateNaissanceBebes, #div_compoFamille_msgReinitEnfant").hide(); 1225 } 1226 // S'il y a des options obligatoires, on les mets à jour avec le nouveau nombre d'enfants 1227 if ($(".option.obligatoire:not(.animal)").length > 0) { 1228 $("#div_recapOptionsObligatoires > ul").html(getXHTML_recapOptionsObligatoires()); 1229 $("#div_recapOptionsObligatoires").show(); 1230 } 1231 $("#div_infoCompoFamilleEnfants").hide(); 1232 etapeCourante($("#div_uneEtape_compoFamilleGite"), true); 1233 } 1234 verifCompoFamilleGiteAdultes(); 1235 }); 1236 1237 $(".select_compoFamilleAgeEnfants, .select_compoFamilleAgeBebe").change(function(){ 1238 // On affecte les âges et valide l'étape seulement quand toutes les listes ont été renseignées 1239 if ($(".select_compoFamilleAgeEnfants[value=0]:visible").length == 0 && $(".select_compoFamilleAgeBebe[value=0]:visible").length == 0) { 1240 $("#div_recapOptionsObligatoires").find("ul").html(getXHTML_recapOptionsObligatoires()); 1241// affectAgeEnfants(); 1242 etapeCourante($("#div_uneEtape_compoFamilleGite"), true); 1243 } 1244 else { 1245 $("#div_uneEtape_compoFamilleGite").find(".inpt_validEtape").val("Non"); 1246 } 1247 verifCompoFamilleGiteAdultes(); 1248 }); 1249 1250 1251 //si je suis un point de vente, possiblité de ne pas saisir de dates 1252 $(".pasdeDateEnfants").click(function(){ 1253 if($(this).attr('data-ok')=='1'){ 1254 $(this).attr('data-ok','0'); 1255 etapeCourante($("#div_uneEtape_compoFamilleGite"), false); 1256 }else{ 1257 $(this).attr('data-ok','1'); 1258 etapeCourante($("#div_uneEtape_compoFamilleGite"), true); 1259 } 1260 return false; 1261 }); 1262 1263 1264// // Ajout de l'évènement change sur les case à cocher des options supplémentaires 1265// // Pour les options individuelles (qui dépendent du nombre de personnes), 1266// // On met à jour la liste de sélection avec le nombre de personnes/animaux déjà sélectionnés 1267// // Quand on décoche, on remet cette liste à 0 1268// $(".inpt_optionIndiv").change(function(){ 1269// if ($(this).attr("checked") == undefined) { 1270// $(this).parents("tr.option").find("select").val(0); 1271// } 1272// else { 1273// if ($(this).parents("tr.option").hasClass('animal')) { 1274// var nbAnimaux = (parseInt($("#select_compoAnimauxChat").val()) + parseInt($("#select_compoAnimauxChien").val())); 1275// $(this).parents("tr.option").find(".select_optionAnimaux").val(nbAnimaux); 1276// } 1277// else { 1278// if ($(this).parents("tr.option").hasClass('enfant')) { 1279// var nbEnfants = $("#select_compoFamilleEnfant").val(); 1280// $(this).parents("tr.option").find(".select_optionEnfants").val(nbEnfants); 1281// } 1282// else { 1283// var nbAdultes = $("#select_compoFamilleAdulte").val(); 1284// $(this).parents("tr.option").find(".select_optionAdultes").val(nbAdultes); 1285// } 1286// } 1287// } 1288// affectOptions(); 1289// }); 1290// 1291// $(".inpt_optionGroupe").change(function(){ 1292// affectOptions(); 1293// }); 1294 1295 // Affectation des options lorsqu'on change le nombre de personnes affectés à une option individuelle 1296 $(".select_optionAdultes, .select_optionEnfants, .select_optionAnimaux, .select_optionGroupe").change(function(){ 1297// // Si on met une liste à 0, on déselectionne l'option 1298// if ($(this).val() == 0) { 1299// if ($(this).parents("tr.option").find(".inpt_optionIndiv:checked").length > 0) { 1300// $(this).parents("tr.option").find(".inpt_optionIndiv").attr("checked", false); 1301// } 1302// } 1303// // Si on met autre chose que 0, on sélectionne l'option si c'est pas fait 1304// else { 1305// if ($(this).parents("tr.option").find(".inpt_optionIndiv:checked").length == 0) { 1306// $(this).parents("tr.option").find(".inpt_optionIndiv").attr("checked", true); 1307// } 1308// } 1309 affectOptions(); 1310 }); 1311 1312 initListesDureeOption(); 1313 })(jQuery); 1314} 1315 1316/** 1317 * Affectation des évènements sur les éléments JS spécifiques aux chambres 1318 */ 1319function setEventsForChambre(){ 1320 (function($){ 1321 if ($(".inpt_chambre:checked").length > 0){ 1322 $("#div_uneEtape_compoFamilleChambre").find(".inpt_val
1322idEtape").val("Oui"); 1323 } 1324 1325 1326 // Ajout d'une classe last à la dernière ligne du tableau des tarifs options 1327 $(".div_uneChambreTarifsOption").each(function(){ 1328 $(this).find("tr:last").addClass("last"); 1329 }); 1330 1331 $(".inpt_chambre").change(function(){ 1332 var numChambre = getNumChambreByElem($(this)); 1333 // On vérifie l'attribut annulChoix, il détermine si on vient d'annuler la sélection de cette chambre par le biais d'une pop-in 1334 // Cela se produit dans le cas des dispohotes niveau 2, le typeResa peut être modifié en sélectionnant une chambre avec plan_vente différent 1335 var annulChoix = false; 1336 if ($(this).attr('data-annulChoix')) { 1337 annulChoix = true; 1338 $(this).removeAttr('data-annulChoix'); 1339 } 1340 // Affectation de la chambre au dossier 1341 affectChambre(numChambre, annulChoix); 1342 // Déblocage/blocage de la liste de sélection des adultes 1343 if ($(this).attr("checked") == "checked") { 1344 $(this).siblings("span").show(); 1345 } 1346 else { 1347 $(this).siblings("span").hide(); 1348 if ($("#select_compoFamilleAdulte_"+numChambre).val() > 0) { 1349 $("#select_compoFamilleAdulte_"+numChambre).val(0); 1350 $("#select_compoFamilleAdulte_"+numChambre).change(); 1351 } 1352 } 1353 1354 }); 1355 1356 $(".select_compoFamilleAdulte").change(function(){ 1357 var numChambre = getNumChambreByElem($(this)); 1358 metAJourListeFamille(numChambre); 1359 // Affichage du choix des enfants (Oui/Non) 1360 var divUneChambreTarifsOption = $(this).parents('.div_uneChambreContent').find('.div_uneChambreTarifsOption'); 1361 var elemsDivUneChambreTarifsOption = divUneChambreTarifsOption.find('*'); 1362 1363 if ($(this).val() == 0) { 1364 $("#div_infoCompoFamilleQuestionEnfants_"+numChambre).hide(); 1365 /*if(estResaGP()) { // fiche 241930 - 313331 : on autorise désormais les chambres avec que des enfants en GP 1366 $("#div_infoCompoFamilleEnfants_"+numChambre).hide(); 1367 $("#div_compoFamilleAgeEnfants_"+numChambre).hide(); 1368 }*/ 1369 if (estResaGP() && $('#div_selectionChambre').data('bloque-chambre-sans-adulte') === 'O') { 1370 $('#select_compoFamilleEnfant_' + numChambre).val(0); 1371 $('#select_compoFamilleBebe_' + numChambre).val(0); 1372 $('#div_compoFamilleDateNaissanceEnfants_' + numChambre).hide(); 1373 } 1374 $(".inpt_optionChambre_"+numChambre).attr("disabled", true); 1375 $(".select_optionChambre_"+numChambre).attr("disabled", true); 1376 $("#inpt_enfantsNon_"+numChambre).attr("checked", false); 1377 $("#inpt_enfantsOui_"+numChambre).attr("checked", false); 1378 if(/*estResaGP() ||*/ parseInt($('#select_compoFamilleEnfant_'+numChambre).val()) === 0) { // fiche 241930 - 313331 : on autorise désormais les chambres avec que des enfants en GP 1379 $('#div_infoCompoBebes_'+numChambre).hide(); 1380 elemsDivUneChambreTarifsOption.attr('disabled', true); 1381 divUneChambreTarifsOption.toggleClass('div_uneChambreTarifsOptionGrisee', true); 1382 if ($("#inpt_chambre_"+numChambre).attr("checked") == "checked") { 1383 $("#inpt_chambre_"+numChambre).attr("checked", false); 1384 $("#inpt_chambre_"+numChambre).change(); 1385 } 1386 } 1387 if ($(".inpt_chambre:checked").length == 0) 1388 $(this).parents(".div_uneEtape").find(".inpt_validEtape").val("Non"); 1389 } else { 1390 if ($("#inpt_chambre_"+numChambre).attr("checked") == undefined) { 1391 $("#inpt_chambre_"+numChambre).attr("checked", true); 1392 $("#inpt_chambre_"+numChambre).change(); 1393 } 1394 $('#div_infoCompoBebes_'+numChambre).show(); 1395 $(".inpt_optionChambre_"+numChambre).attr("disabled", false); 1396 $(".select_optionChambre_"+numChambre).attr("disabled", false); 1397 $("#div_infoCompoFamilleQuestionEnfants_"+numChambre).show(); 1398 elemsDivUneChambreTarifsOption.attr('disabled', false); 1399 divUneChambreTarifsOption.toggleClass('div_uneChambreTarifsOptionGrisee', false); 1400 mettreAjourListeRepas(numChambre); 1401 etapeCourante($("#div_uneEtape_compoFamilleChambre"), true); 1402 } 1403 // Affectation du nombre d'adultes à la chambre 1404 affectFamille("Adultes", numChambre); 1405 }); 1406
1407 // onChange sur les radio de sélection enfants 1408 $(".input_choixEnfants").change(function(){ 1409 var numChambre = getNumChambreByElem($(this)); 1410 if ($(this).val() == "Oui" ) { 1411 $(this).parents(".div_uneEtape").find(".inpt_validEtape").val("Non"); 1412 $("#div_infoCompoFamilleEnfants_"+numChambre).show("slow"); 1413 $("#div_compoFamilleDateNaissanceEnfants_"+numChambre).show("slow"); 1414 } 1415 else { 1416 if ($("#select_compoFamilleEnfant_"+numChambre).val() > 0 || $("#select_compoFamilleBebe_"+numChambre).val() > 0) { 1417 $("#select_compoFamilleEnfant_"+numChambre+", #select_compoFamilleBebe_"+numChambre).val(0); 1418 affectFamille("", numChambre); 1419 } 1420 $("#div_infoCompoFamilleEnfants_"+numChambre).hide("slow"); 1421 $("#div_compoFamilleDateNaissanceEnfants_"+numChambre).hide("slow"); 1422 etapeCourante($("#div_uneEtape_compoFamilleChambre"), true); 1423 $('.select_compoFamilleAgeEnfants_'+numChambre).val(0); 1424 // voir affecteAgeEnfantsAvecCoherence qui remplace (fiche 293190) 1425// affectAgeEnfants(); 1426 } 1427 }); 1428 1429 // Si on revient d'une étape postérieure, il faut sélectionner le nombre d'enfants dans la liste 1430 if ($(".inpt_nbEnfants").length > 0) { 1431 $(".inpt_nbEnfants").each(function(){ 1432 var numChambre = getNumChambreByElem($(this)); 1433 metAJourListeFamille(numChambre); 1434 $("#select_compoFamilleEnfant_"+numChambre).val($("#inpt_nbEnfants_"+numChambre).val()); 1435 }); 1436 } 1437 1438 // onChange sur les listes sélection enfants 1439 $(".select_compoFamilleEnfant").change(function(){ 1440 var numChambre = getNumChambreByElem($(this)); 1441 if (estResaGP() && $('#div_selectionChambre').data('bloque-chambre-sans-adulte') === 'O' && $('#select_compoFamilleAdulte_' + numChambre).val() == 0) { 1442 $('#select_compoFamilleEnfant_' + numChambre).val(0); 1443 $('#select_compoFamilleBebe_' + numChambre).val(0); 1444 $('#div_compoFamilleDateNaissanceEnfants_' + numChambre).hide(); 1445 } 1446 metAJourListeFamille(numChambre); 1447 $(".td_ageEnfants_"+numChambre).hide(); 1448 var divUneChambreTarifsOption = $(this).parents('.div_uneChambreContent').find('.div_uneChambreTarifsOption'); 1449 var elemsDivUneChambreTarifsOption = divUneChambreTarifsOption.find('*'); 1450 // Création/mise à jour des listes déroulantes pour les ages des enfants 1451 // On ne gère plus pour les chambres car ce n'est pas géré dans GestLoc 1452 if ($(this).val() != 0) { 1453 for (var i=1; i<=$(this).val(); i++) { 1454 $("#td_ageEnfant_"+i+"_"+numChambre).show(); 1455 } 1456 $("#div_compoFamilleDateNaissanceEnfants_"+numChambre).show("slow"); 1457 if(/*!estResaGP() &&*/ $("#inpt_chambre_"+numChambre).attr("checked") == undefined) { // fiche 241930 - 313331 : on autorise désormais les chambres avec que des enfants en GP 1458 $("#inpt_chambre_"+numChambre).attr("checked", true); 1459 $("#inpt_chambre_"+numChambre).change(); 1460 } 1461 elemsDivUneChambreTarifsOption.attr('disabled', false); 1462 divUneChambreTarifsOption.toggleClass('div_uneChambreTarifsOptionGrisee', false); 1463 $('#div_infoCompoBebes_'+numChambre).show(); 1464// // on appelle "etapeCourante" que si y a pas de pb 1465// // - sur site GP, il faut qu'il y ait au moins un adulte dans la même chambre que les enfants 1466// // - sur site non GP, il faut qu'il y ait au moins un adulte dans la structure mais pas forcément dans la même chambre que les enfants 1467// if(!estResaBureauProp()) { // fiche 241930 1468// if(parseInt($('#select_compoFamilleAdulte_'+numChambre).val()) > 0) { 1469// etapeCourante($("#div_uneEtape_compoFamilleChambre"), true); 1470// } 1471// } else { 1472// if ($('.div_uneChambre:visible').find('.inpt_chambre:checked').length > 0) { 1473// etapeCourante($("#div_uneEtape_compoFamilleChambre"), true); 1474// } 1475// } 1476 } 1477 else { 1478 $("#div_compoFamilleDateNaissanceEnfants_"+numChambre).hide("slow"); 1479 if(parseInt($('#select_compoFamilleAdulte_'+numChambre).val()) === 0) { // fiche 241930 - 313331 : on autorise désormais les chambres avec que des enfants en GP 1480 $("#inpt_chambre_"+numChambre).attr("checked", false); 1481 $("#inpt_chambre_"+numChambre).change(); 1482 elemsDivUneChambreTarifsOption.attr('disabled', true); 1483 divUneChambreTarifsOption.toggleClass('div_uneChambreTarifsOptionGrisee', true); 1484 $('#div_infoCompoBebes_'+numChambre).hide(); 1485 } 1486 } 1487 // voir affecteAgeEnfantsAvecCoherence qui remplace (fiche 293190) 1488// affectAgeEnfants(numChambre); // fiche 263669 : je déplace car quand on a pas d'enfants, on doit mettre les dates naissance à vide 1489 // Affectation du nombre d'enfants à la chambre 1490 mettreAjourListeRepas(numChambre); 1491 affectFamille("Enfants", numChambre); 1492 }); 1493
1494 // onChange sur les listes sélection bébés 1495 $(".select_compoFamilleBebe").change(function(){ 1496 if (bebeDansCapacite()) { 1497 metAJourListeFamille(getNumChambreByElem($(this))); 1498 } 1499 var numChambre = getNumChambreByElem($(this)); 1500 $(".td_ageBebe_"+numChambre).hide(); 1501 if ($(this).val() != 0) { 1502 for (var i=1; i<=$(this).val(); i++) { 1503 $("#td_ageBebe_"+i+"_"+numChambre).show(); 1504 } 1505 $("#div_compoFamilleDateNaissanceBebes_"+numChambre).show("slow"); 1506 etapeCourante($("#div_uneEtape_compoFamilleChambre"), true); 1507 } 1508 else { 1509 $("#div_compoFamilleDateNaissanceBebes_"+numChambre).hide("slow"); 1510 } 1511 // Affectation du nombre de bébés à la chambre 1512 // voir affecteAgeEnfantsAvecCoherence qui remplace (fiche 293190) 1513// affectAgeEnfants(numChambre); 1514 affectFamille("bebes", numChambre); 1515 }); 1516 1517 // onChange sur les listes de sélection des ages des enfants 1518 $(".select_compoFamilleAgeEnfants, .select_compoFamilleAgeBebe").change(function(){ 1519 var numChambre = getNumChambreByElem($(this)); 1520 // Affectation des ages des enfants à la chambre 1521 if (($(".select_compoFamilleAgeEnfants_"+numChambre+":visible").length == 1 || $(".select_compoFamilleAgeEnfants_"+numChambre+"[value=0]:visible").length == 0) && $(".select_compoFamilleAgeBebe_"+numChambre+"[value=0]:visible").length == 0 ) { 1522 // voir affecteAgeEnfantsAvecCoherence qui remplace (fiche 293190) 1523// affectAgeEnfants(numChambre); 1524 } 1525 }); 1526 1527 // onChange sur les case à cocher des tarifs options (groupe et indiv) 1528 $(".inpt_optionChambre").live('change', function(){ 1529 var numChambre = getNumChambreByElem($(this)); 1530 // Si on décoche, on met la liste qte associée à 0 1531 if ($(this).attr("checked") == undefined) { 1532 $(this).parent().next().next().children("select.select_optionChambre").val(0); 1533 } 1534 // TODO: gérer les options avec reducEnfant 1535 else { 1536 var nbAdultes = $("#select_compoFamilleAdulte_"+numChambre).val(); 1537 $(this).parent().next().next().children("select.select_optionChambre").val(nbAdultes); 1538 } 1539 affectOptionsChambre(); 1540 }); 1541 1542 // onChange sur les listes déroulantes des tarifs options individuels 1543 $(".select_optionChambre").live('change', function(){ 1544 affectOptionsChambre(); 1545 }); 1546 1547 //Contrôle sur la date de naissance bébé au changement 1548 $('input[name=dateNaissanceBebe]').change((input) => { 1549 var numChambre = input.target.parentElement.id.slice(-1); 1550 1551 $('#message_err_age_bebe_' + numChambre).hide(); 1552 if ($('#img_validAgeBebe_' + input.target.dataset.id + '_' + numChambre).hasClass('fa')) { 1553 $('#img_validAgeBebe_' + input.target.dataset.id + '_' + numChambre).removeClass(); 1554 $('#img_validAgeBebe_' + input.target.dataset.id + '_' + numChambre).hide(); 1555 } 1556 1557 let dateNaissance = new OBJDate(input.target.value); 1558 dateNaissance.ajouteAnnee(input.target.dataset.ageMax); 1559 let dateDebSej = new OBJDate($('input#inpt_resaDateDeb').val()); 1560 1561 if (dateNaissance.estAvantOBJDate(dateDebSej)) { 1562 $('#img_validAgeBebe_' + input.target.dataset.id + '_' + numChambre).addClass('fa fa-close').show('slow'); 1563 $('#message_err_age_bebe_' + numChambre).show('slow'); 1564 } else { 1565 $('#img_validAgeBebe_' + input.target.dataset.id + '_' + numChambre).addClass('fa fa-check').show('slow'); 1566 } 1567 }); 1568 1569 initListesDureeOption(true); 1570 })(jQuery); 1571} 1572 1573function mettreAjourListeRepas(numChambre){ 1574 if(numChambre){ 1575 //ici on gère les actions du nombre de repas sur les selects qu'on trouve. On les affichent dans le PHP DossierGL.php[getXHTML_tarifsOptions] 1576 jQuery.each(jQuery(".optionChambre[numchambre="+numChambre+"] .select_optionChambre").not('.select_optionChambre_enfants,.forfaitaire'), function(){ 1577 var nbRepasAdultesAvant = jQuery(this).val()
1578 var nbAdultes = parseInt(jQuery("#select_compoFamilleAdulte_"+numChambre).val()); 1579 var nbRepasEnfantsAvant = 0; 1580 var nbEnfants = 0; 1581 //prevoir le cas ou il y a des recu enfant 1582 if(jQuery("#select_compoFamilleEnfant_"+numChambre)){ 1583 nbEnfants = parseInt(jQuery("#select_compoFamilleEnfant_"+numChambre).val()); 1584 } 1585 var nbNuits = 1; 1586 if(!jQuery(this).is('.parJour') && jQuery("#sp_recapDatesDuree")){ 1587 nbNuits = jQuery("#sp_recapDatesDuree").html(); 1588 } 1589 var htmlAdultes = '<option selected="selected" value="0">-</option>'; 1590 var nbOptionsMax = (nbAdultes + nbEnfants); // fiche 251622 : on prend en compte le nombre d'adultes + le nombre d'enfants 1591 if(jQuery(this).data('nbpers') && jQuery(this).data('nbpers') > 0){ 1592 nbOptionsMax = Math.ceil(nbOptionsMax / jQuery(this).data('nbpers')); 1593 } 1594 nbOptionsMax = nbOptionsMax * nbNuits; 1595 for(i = 1 ; i < (nbOptionsMax +1) ; i++){ 1596 htmlAdultes += '<option value="'+i+'">'+i+'</option>'; 1597 } 1598 jQuery(this).html(htmlAdultes); 1599 if(jQuery(this).parent().children(".select_optionChambre_enfants"+numChambre).length > 0){ 1600 var maDivEnfant = jQuery(this).parent().children(".select_optionChambre_enfants"+numChambre); 1601 nbRepasEnfantsAvant = jQuery(maDivEnfant).val(); 1602 var htmlEnfants = '<option'; 1603 if(nbRepasEnfantsAvant == 0){ 1604 htmlEnfants += ' selected="selected"'; 1605 } 1606 htmlEnfants += ' value="0">-</option>'; 1607 for(i = 1 ; i < (nbEnfants*nbNuits +1) ; i++){ 1608 htmlEnfants += '<option'; 1609 if(nbRepasEnfantsAvant == i){ 1610 htmlEnfants += ' selected="selected"'; 1611 } 1612 htmlEnfants += ' value="'+i+'">'+i+'</option>'; 1613 }/* 1614 if(jQuery(maDivEnfant).closest('.optionChambre').attr('numoption') == '5' && jQuery(this).closest('.optionChambre').attr('numchambre') == '1'){ 1615 jQuery(maDivEnfant).css('background','green') 1616 jQuery(maDivEnfant).addClass('passEnfants') 1617 console.log('**5/1 htmlEnfants:nb de base :'+nbEnfants) 1618 console.log(htmlEnfants) 1619 }*/ 1620 jQuery(maDivEnfant).html(htmlEnfants); 1621 } 1622 if(nbRepasAdultesAvant <= nbOptionsMax ){ 1623 jQuery(this).val(nbRepasAdultesAvant); 1624 }else { 1625 jQuery(this).val(nbOptionsMax); 1626 affectOptionsChambre(); 1627 } 1628 1629// if(nbRepasAdultesAvant <= (nbAdultes*nbNuits) && nbRepasEnfantsAvant <= (nbEnfants*nbNuits) ){ 1630// jQuery(this).val(nbRepasAdultesAvant); 1631// }else if(nbRepasAdultesAvant != (nbAdultes*nbNuits) || nbRepasEnfantsAvant != (nbEnfants*nbNuits)){ 1632// affectOptionsChambre(); 1633// } 1634 }); 1635 }else{ 1636 jQuery.each(jQuery("#div_selectionChambre div.div_uneChambre"), function(){ 1637 if(jQuery(this).attr('num').length > 0){ 1638 mettreAjourListeRepas(jQuery(this).attr('num')) 1639 } 1640 } 1641 ); 1642 } 1643} 1644 1645function getNumChambreByElem(elem){ 1646 var numChambre; 1647 (function(){ 1648 numChambre = elem.parents(".div_uneChambre").attr("num"); 1649 })(jQuery); 1650 return numChambre; 1651} 1652 1653/** 1654 * Initialisation du datepicker permettant de sélectionner la date de début de séjour 1655 */ 1656function initDatePickerDeb() { 1657 (function ($) { 1658 var dateDeb = new Date(); 1659 // Sur la résa on affiche les jours minifiés : L M M ... 1660 var dayNamesMin = $.datepicker._defaults.dayNamesMin; 1661 if(rafraichirSurUrlActuelleApresSelectDateFin || modeCalculPrixSurFiche){ 1662 //si on est sur la fiche, on a pas initialisé la langue 1663 var langue = initLangueForDatePicker(); 1664 $.datepicker.setDefaults($.datepicker.regional[langue]); 1665 // Sur la fiche on met les jours raccourcis : Lun Mar Mer ... 1666 dayNamesMin = $.datepicker._defaults.dayNamesShort; 1667 } 1668 $("#div_datepickerDeb").datepicker({ 1669 numberOfMonths: [1, nbMois], 1670 dateFormat: 'dd/mm/yy', 1671 minDate: dateDebPlanning, 1672 maxDate: dateFinPlanning, 1673 defaultDate: defaultDateDebut, 1674 dayNamesMin: dayNamesMin, 1675 beforeShowDay: setJourDebut, 1676 onSelect: function (dateDeb) { 1677 setDateDeb(dateDeb); 1678 initDatepickersDateNaissance(); 1679 } 1680 }); 1681 1682 1683 if(typeof(objDateDeb)!= 'undefined'){ 1684 $("#div_datepickerDeb").datepicker('setDate', objDateDeb); 1685 } 1686 })(jQuery); 1687} 1688 1689/** 1690 * Initialisation du datepicker permettant de sélectionner la date de fin de séjour 1691 */ 1692function initDatePickerFin() { 1693 (function($){ 1694 $("#div_datepickerFin").datepicker({ 1695 numberOfMonths: [1, nbMois], 1696 dateFormat: 'dd/mm/yy', 1697 defaultDate: new Date(), 1698 beforeShowDay: setJour, 1699 onSelect: function (dateFin) { 1700 setDateFin(dateFin); 1701 } 1702 }); 1703 })(jQuery); 1704} 1705 1706/** 1707 * 1708 * Initialisation du/des datepicker permettant de sélectionner la date de naissance du participant 1709 */ 1710function initDatePickerNaissanceParticipant() { 1711 (function ($) { 1712 var langue = initLangueForDatePicker(); 1713 $.datepicker.setDefaults($.datepicker.regional[langue]); 1714 $('.dateNaissanceParticipant').each(function () { 1715 $(this).datepicker({ 1716 dateFormat: 'dd/mm/yy', 1717 changeMonth: true, 1718 showOtherMonths: true, 1719 selectOtherMonths : true, 1720 changeYear: true, 1721 maxDate : 0, 1722 yearRange : '-100:+0' 1723 }); 1724 }); 1725 })(jQuery); 1726} 1727 1728function initChangeJourRef() { 1729 (function ($) { 1730 if ($('#select_resaJourReference')) { 1731 $("#select_resaJourReference").change(function () { 1732 var dateDeb = $("#inpt_resaDateDeb").val(); 1733 var dateFin = $("#inpt_resaDateFin").val(); 1734 // Affichage du message de confirmation/erreur en fonction des dates choisies 1735 var tabData = {type: "verifDates", dateDeb: dateDeb, dateFin: dateFin}; 1736 if ($('#select_resaJourReference') && $('#select_resaJourReference').val() != null) { 1737 tabData.jour_ref = $('#select_resaJourReference').val(); 1738 } 1739 if (gestprod) { 1740 tabData = {type: "verifDates_GP", dateDeb: dateDeb, dateFin: dateFin} 1741 } 1742 ajaxVerifDates(tabData); 1743 }); 1744 } 1745 })(jQuery); 1746} 1747 1748function initChangeHeureDebFin() { 1749 (function ($) { 1750 if($('#select_heureArrivee').length==0){ 1751 return; 1752 } 1753 // d'abord virer les events déjà existants (pour éviter d'avoir plusieurs fois les mêmes 1754 $('#select_heureDepart').unbind('change'); 1755 $('#select_heureArrivee').unbind('change'); 1756 $('#select_heureDepart').bind( 'change', function () { 1757 var dateDeb = $("#inpt_resaDateDeb").val(); 1758 var dateFin = $("#inpt_resaDateFin").val(); 1759 // Affichage du message de confirmation/erreur en fonction des dates choisies 1760 var tabData = {type: "verifDates", dateDeb: dateDeb, dateFin: dateFin}; 1761 if ($('#select_resaJourReference') && $('#select_resaJourReference').val() != null) { 1762 tabData.jour_ref = $('#select_resaJourReference').val(); 1763 } 1764 tabData.heureDeb = $('#select_heureArrivee').val() || null; 1765 tabData.heureFin = $('#select_heureDepart').val() || null; 1766 1767 if (gestprod) { 1768 tabData = {type: "verifDates_GP", dateDeb: dateDeb, dateFin: dateFin} 1769 } 1770 ajaxVerifDates(tabData); 1771 }); 1772 1773 1774 $('#select_heureArrivee').bind('change', function () { 1775 // fiche 283193 : si on a chevauchement, il faut pouvoir modifier les horaires 1776// if(typeof objDateDeb === 'undefined' || typeof objDateFin === 'undefined') {
1777// // fiche 243176 : si la date de début ou de fin n'est pas renseignée, on ne fait rien 1778// return false; 1779// } 1780 var dateDeb = $("#inpt_resaDateDeb").val(); 1781 var dateFin = $("#inpt_resaDateFin").val(); 1782 // Affichage du message de confirmation/erreur en fonction des dates choisies 1783 var tabData = {type: "verifDates", dateDeb: dateDeb, dateFin: dateFin}; 1784 if ($('#select_resaJourReference') && $('#select_resaJourReference').val() != null) { 1785 tabData.jour_ref = $('#select_resaJourReference').val(); 1786 } 1787 tabData.heureDeb = $('#select_heureArrivee').val() || null; 1788 tabData.heureFin = $('#select_heureDepart').val() || null; 1789 if (gestprod) { 1790 tabData = {type: "verifDates_GP", dateDeb: dateDeb, dateFin: dateFin} 1791 } 1792 ajaxVerifDates(tabData); 1793 }); 1794 1795 })(jQuery); 1796} 1797 1798function setDateDeb(dateDeb) { 1799 (function ($) { 1800 // On met à jour l'objet de date de début avec la date récupérée dans le datepicker 1801 // On enlève un mois car les mois de l'objet Date commencent à 0 1802 objDateDeb = new Date(); 1803 objDateDeb.setFullYear(dateDeb.substr(6, 4), dateDeb.substr(3, 2)-1, dateDeb.substr(0, 2)); 1804 // fiche 235579 1805 objDateDeb.setHours(0); 1806 objDateDeb.setMinutes(0); 1807 objDateDeb.setSeconds(0); 1808 1809 if (infoBulles) { 1810 var objDateDebPlanning = new Date(dateDebPlanning.substr(6,4), dateDebPlanning.substr(3,2)-1, dateDebPlanning.substr(0,2)); 1811 var ecart = Math.round(ecartDate(objDateDeb, objDateDebPlanning)); 1812 // Yoann 06/07 ajout du -1, j'ai déjà modifié 3fois cette ligne 1813 // parfois il faut -1 et parfois pas, j'ai pas réussi à identifier le problème 1814 // Erwan 31/10 200826: c'est surement lié au changement d'exe 1815 var infoBulle = infoBulles[ecart]; 1816 } 1817 1818 $("#inpt_resaDateDeb").val(dateDeb); 1819 if(estResaBureauGestloc() || estResaBureauProp()) { // fiche 243176 1820 $('#select_heureArrivee').prop('disabled', false); 1821 } 1822 if ($("#div_choixDateFin").length > 0) { 1823 if ($("#div_choixDateFin").length > 0) { 1824 // Si une date est déjà sélectionné dans le champ de départ, on la récupère également 1825 if ($("#inpt_resaDateFin").val() != "Départ") { 1826 //fiche 235579 : ne pas mettre en commentaires le code ci-dessous, on en a besoin 1827 var dateFin = $("#inpt_resaDateFin").val(); 1828 objDateFin = new Date(); 1829 objDateFin.setFullYear(dateFin.substr(6, 4), dateFin.substr(3, 2)-1, dateFin.substr(0, 2)); 1830 // fiche 235579 : ça permet qu'après midi chaque jour, la date de fin de séjour dans le datepicker de fin soit bien la même que dans le datepicker de début (on ne lui a pas ajouté +1 donc). 1831 // le pb était dû au fait que dans setJour(), le param "date" en entrée a pour heure 00:00:00 alors que objDateFin a pour heure l'heure courante (car créé ici avec un new Date et un setFullYear. 1832 // du coup la fonction ecartDate, qui utilise un Math.round, ne nous retournait pas la même chose suivant que l'heure de objDateFin était avant midi ou pas. 1833 objDateFin.setHours(0); 1834 objDateFin.setMinutes(0); 1835 objDateFin.setSeconds(0); 1836 } 1837 } 1838 1839 // Si une date de départ était déjà sélectionné et que dateDeb > dateFin 1840 // Alors on réinitialise le champ de départ avec sa valeur par défaut 1841 if (objDateFin && objDateDeb>objDateFin){ 1842 $("#inpt_resaDateFin").val("Départ"); 1843 } 1844 1845 $("#div_calendrierDeb").hide().removeClass("open"); 1846 $("#div_roueDatepickerFin").show(); 1847 var tabData = {type: "getPlanningFin", dateDeb: dateDeb, infoBulle: infoBulle}; 1848 if (gestprod) { 1849 tabData = {type: "getPlanningFin_GP", dateDeb: dateDeb}; 1850 } 1851 if (modeCalculPrixSurFiche) { 1852 tabData.estpresentsurfiche = true; 1853 } 1854 $.ajax({ 1855 type: "POST", 1856 url: urlAJAX, 1857 async: false, 1858 data: tabData, 1859 beforeSend: function(){ 1860 $("#div_calendrierFin").show().addClass("open"); 1861 }, 1862 success: function(result){ 1863 eval("var tabResult="+result); 1864 if (tabResult.code == errDossierNull) { 1865 retourEtape1(tabResult.msg); 1866 } 1867 else if (tabResult.errTechnq) { 1868 afficheMsgErrTechnq(tabResult.msg, tabResult.titre, tabResult.ident, true); 1869 } 1870 else if (tabResult.pack) { 1871 // TODO : traitement spécifique pour les packages 1872 $('#inpt_resaDateFin').val(tabResult.dateFin); 1873 setDateFin(tabResult.dateFin); 1874 } else { 1875 dateDebPlanning = tabResult.dateDeb; 1876 chainePlanning = tabResult.chaineDispo; 1877 infoBulles = tabResult.infoBulle; 1878 // On initialise le datepicker de fin seulement quand on a sélectionné une date de début 1879 initDatePickerFin(); 1880 if(estResaVoitureNouveauScript() ){ 1881 // Mise à jour de la date minimum du datepicker de fin avec la date sélectionné dans le datepicker de début :pour les voitures on peut séelctionner la même date que la date de début 1882 $("#div_datepickerFin").datepicker("option", "minDate", new Date(objDateDeb.getFullYear(), objDateDeb.getMonth(), objDateDeb.getDate() )); 1883 } 1884 else{ 1885 // Mise à jour de la date minimum du datepicker de fin avec la date sélectionné dans le datepicker de début (+1 jour) 1886 $("#div_datepickerFin").datepicker("option", "minDate", new Date(objDateDeb.getFullYear(), objDateDeb.getMonth(), objDateDeb.getDate() + 1)); 1887 } 1888 1889 $("#div_datepickerFin").datepicker("option", "maxDate", tabResult.dateFin); 1890 // On repositionne le calendrier de fin sur la date sélectionnée dans le calendrier de début pour mieux voir les dates sélectionnables 1891 $("#div_datepickerFin").datepicker("setDate", new Date(objDateDeb.getFullYear(), objDateDeb.getMonth(), objDateDeb.getDate() + 1)); 1892 $("#div_datepickerDeb").datepicker("destroy"); 1893 } 1894 1895 $("#div_roueDatepickerFin").hide(); 1896 } 1897 }); 1898 } 1899 else if ($("#div_choixNbNuits").length>0) { 1900 initListeNbNuits(infoBulle); 1901 $("#div_choixNbNuits").show(); 1902 } 1903 else if ($('#div_uneEtape_billetChoixPresta').length>0) { 1904 // On définit la date de fin, elle est utilisée lors de l'appel AJAX de demande de prix 1905 // Pour les billets on prend la date de début et on ajoute un jour (cf V4 : gereResa.php l.421 : si pas de duree on met duree à 1) 1906 objDateFin = new Date(); 1907 var timestampDeb = Date.UTC(dateDeb.substr(6, 4), dateDeb.substr(3, 2)-1, dateDeb.substr(0, 2)); 1908 var timestampFin = timestampDeb + (24*60*60*1000); 1909 objDateFin.setTime(timestampFin); 1910 1911 $("#div_calendrierDeb").hide().removeClass("open"); 1912 tabData = {type: "verifDates_GP", dateDeb: dateDeb, dateFin: dateDeb}; 1913 ajaxVerifDates(tabData); 1914 } 1915 })(jQuery); 1916} 1917 1918function setDateFin(dateFin){ 1919 (function($){ 1920// if (typeof dateFin === 'undefined') { 1921// return; 1922// } 1923 var dateDeb = $("#inpt_resaDateDeb").val(); 1924 objDateDeb.setFullYear(dateDeb.substr(6, 4), dateDeb.substr(3, 2)-1, dateDeb.substr(0, 2)); 1925 if (objDateFin == undefined){ 1926 objDateFin = new Date(); 1927 objDateFin.setHours(0); 1928 objDateFin.setMinutes(0); 1929 objDateFin.setSeconds(0); 1930 } 1931 objDateFin.setFullYear(dateFin.substr(6, 4), dateFin.substr(3, 2)-1, dateFin.substr(0, 2)); 1932 if(rafraichirSurUrlActuelleApresSelectDateFin){
1933 // si demande a être redirigé sur l'url courante, on ne va pas faire denovuelle requete ajax 1934 //location.href = location.pathname+'?deb='+dateDeb+'&nbj='+ecartDate(objDateFin, objDateDeb); 1935// var tabArgs = getTabValInQueryString() || []; 1936// var search = ''; 1937// $(tabArgs).each(function(){ 1938// var val = this[0] || false; 1939// if(val && val !== 'deb' & val !== 'nbj'){ 1940// search+= '&'+val+'='+this[1]; 1941// } 1942// }); 1943// location.search = search+'&deb='+dateDeb+'&nbj='+ecartDate(objDateFin, objDateDeb); 1944 1945 var tabArgs = getVarsFromUrl() || []; 1946 var search = ''; 1947 for(var prop in tabArgs){ 1948 if(prop && prop != 'deb' && prop != 'nbj' && prop != 'exe'){ 1949 search+=prop+'='+tabArgs[prop]+'&'; 1950 } 1951 } 1952 location.search = search+'&deb='+dateDeb+'&nbj='+ecartDate(objDateFin, objDateDeb); 1953 1954 return; 1955 } 1956 $("#div_confirmDispos span:first-child").hide(); 1957 $("#div_confirmDispos span:last-child").hide(); 1958 $("#inpt_resaDateFin").val(dateFin); 1959 if(estResaBureauGestloc() || estResaBureauProp()) { // fiche 243176 1960 $('#select_heureDepart').prop('disabled', false); 1961 } 1962 $("#div_calendrierFin").hide().removeClass("open"); 1963 1964 // Affichage du message de confirmation/erreur en fonction des dates choisies 1965 var tabData = {type: "verifDates", dateDeb: dateDeb, dateFin: dateFin}; 1966 if ($('#select_resaJourReference') && $('#select_resaJourReference').val()!=null){ 1967 tabData.jour_ref = $('#select_resaJourReference').val(); 1968 } 1969 if (gestprod) { 1970 tabData = {type: "verifDates_GP", dateDeb: dateDeb, dateFin: dateFin} 1971 } 1972 ajaxVerifDates(tabData); 1973 })(jQuery); 1974} 1975 1976function ajaxVerifDates(tabData, callbackOK){ 1977 (function($){ 1978 if (modeCalculPrixSurFiche) { 1979 tabData.avecDeuxLibelles = $("#a_btnReserver_packDivDatesTarifs").attr("data-avecDeuxLibelles"); 1980 if ($('#div_fiche_bloc_tarif_chmb_packDivDatesTarifs').length>0) { 1981 var tabAttributs = $('#div_fiche_bloc_tarif_chmb_packDivDatesTarifs').attr('data-attributsDiv'); 1982 var listeAttr = eval('('+tabAttributs+')'); 1983 tabData.listeAttrDivChambres = listeAttr; 1984 } 1985 tabData.instance = $('#div_choixDates_packDivDatesTarifs').attr('data-instance'); 1986 tabData.ident = $('#div_choixDates_packDivDatesTarifs').attr('data-ident'); 1987 tabData.exercice = $('#div_choixDates_packDivDatesTarifs').attr('data-exercice'); 1988 tabData.estpresentsurfiche = true; 1989 tabData.nbAdultes = $('#widgetFNGF_selectCapacite option:selected').val(); 1990 tabData.phpsessid = $('#bodyPage').attr('data-iditea'); 1991 tabData.forcereload = $('#div_choixDates_packDivDatesTarifs').attr('data-forcereload'); 1992 1993 if ($('#widgetFNGF_selectChambre').length > 0) { 1994 tabData['numChambre'] = $('#widgetFNGF_selectChambre option:selected').val(); 1995 tabData['annulChoix'] = true; 1996 tabData['removeChambres'] = 'O'; 1997 } 1998 } 1999 2000 // 652974 Suppression du async: false 2001 $.ajax({ 2002 type: "POST", 2003 url: urlAJAX, 2004 data: tabData, 2005 beforeSend: function(){ 2006 // Avant de faire la REQ AJAX verifDates, on invalide l'étape de sélection des dates. 2007 // Cela permet d'éviter le passage à l'étape2 qd la REQ AJAX met trop de temps à repondre (ERR200 par exemple) 2008 $("#div_uneEtape_date").find(".inpt_validEtape").val("Non"); 2009 affMsgAttenteParDessusInDiv("div_resaRecap", "recapPrix", txtAttente); 2010 if ($('.div_uneEtape_prodGP').length>0) { 2011 var idDivProd = $('.div_uneEtape_prodGP').attr('id'); 2012 affMsgAttenteParDessusInDiv(idDivProd, "recapPrix", txtVerifDispos); 2013 } 2014 if (modeCalculPrixSurFiche) { 2015 $('.tarifFicheApartirDe').html('<img src="../../config_v3/imgs_defaut/loading/ajax-loader.gif" />').show(); 2016 } 2017 afficheLoaderGlobal_site(); 2018 }, 2019 success: function (result) { 2020 2021 var tabRetour = XMLToArray(result); 2022 2023 afficheInfosVerifDateITEA(tabRetour); 2024 //console.log('requete ' + tabData.type + ' rep : ', tabRetour); 2025 //eval("var tabRetour="+result); 2026 if (tabRetour.code == errDossierNull) { 2027 retourEtape1(tabRetour.msg); 2028 } 2029 else if (tabRetour.errTechnq) { 2030 gereDivAlertResaJoursIdentiques(tabRetour.htmlAlertResasJoursIdentiques); 2031 gereDivModifHoraires(tabRetour.htmlModifHoraires); 2032 var avecFormContact = false;
2033 if (tabRetour.avecFormContact) { 2034 avecFormContact = true; 2035 } 2036 var msg = tabRetour.msg ; 2037// if(tabRetour.msgErreurCalculPrix){//242466 2038// msg = tabRetour.msgErreurCalculPrix; 2039// } 2040 afficheMsgErrTechnq(msg, tabRetour.titre, tabRetour.ident, avecFormContact,tabRetour.destinataire); 2041 if (modeCalculPrixSurFiche) { 2042 $('.tarifFicheApartirDe').hide(); 2043 reinitDatepickers_packDivTarifs(); 2044 } 2045 } 2046 else { 2047 if (tabRetour.code == "OK") { 2048 console.log('tabRetourOK '); 2049 if (tabRetour.chambresDispo) { 2050 $('#widgetFNGF_selectChambre option').attr('disabled', true); 2051 for (var i = 0; i < tabRetour.chambresDispo.length; i++) { 2052 $('#widgetFNGF_selectChambre option[value="' + tabRetour.chambresDispo[i] + '"]').removeAttr('disabled'); 2053 } 2054 if ($('#widgetFNGF_selectChambre option:selected').is(':disabled')) { 2055 $('#widgetFNGF_selectChambre option[value="default"]').prop('selected', true); 2056 $('.widgetFNGF_divSelectCapacite').hide(); 2057 } 2058 } 2059 2060 if ($('#widgetFNGF_selectChambre').length > 0 || $('#widgetFNGF_selectCapacite').length > 0) { 2061 var dateDeb = $('#inpt_resaDateDebCal').val(); 2062 var dateFin = $('#inpt_resaDateFinCal').val(); 2063 var objDateDebWidget = new OBJDate(dateDeb); 2064 var objDateFinWidget = new OBJDate(dateFin); 2065 if (typeof objDateDebWidget === 'object' && objDateDebWidget !== null && typeof objDateFinWidget === 'object' && objDateFinWidget !== null && $('#a_btnReserver_packDivDatesTarifs').attr('data-lienresa')) { 2066 var datesSejour = 'jour=' + objDateDebWidget.getJour() + '&mois=' + objDateDebWidget.getMois() + '&annee=' + objDateDebWidget.getAnnee() + '&duree=' + objDateDebWidget.getNbJourEcartWithOBJDate(objDateFinWidget, 'O'); 2067 var newLienResa = $('#a_btnReserver_packDivDatesTarifs').attr('data-lienresa'); 2068// console.log('newLienResa ',newLienResa); 2069 2070 if (newLienResa.match(/deb=[0-9]{2}\/[0-9]{2}\/[0-9]{4}&fin=[0-9]{2}\/[0-9]{2}\/[0-9]{4}/g)) { 2071 newLienResa = newLienResa.replace(/deb=[0-9]{2}\/[0-9]{2}\/[0-9]{4}&fin=[0-9]{2}\/[0-9]{2}\/[0-9]{4}/g, datesSejour); 2072 } else if (newLienResa.match(/jour=[0-9]{1,2}&mois=[0-9]{1,2}&annee=[0-9]{4}&duree=[0-9]{1,3}/g)) { 2073 newLienResa = newLienResa.replace(/jour=[0-9]{1,2}&mois=[0-9]{1,2}&annee=[0-9]{4}&duree=[0-9]{1,3}/g, datesSejour); 2074 } else { 2075 newLienResa += '&' + datesSejour; 2076 } 2077 if ($('#widgetFNGF_selectChambre').length == 0 && $('#widgetFNGF_selectCapacite').length > 0) { 2078 newLienResa += '&adultes=' + $('#widgetFNGF_selectCapacite option:selected').val(); 2079 } 2080 $('#a_btnReserver_packDivDatesTarifs').attr('data-lienresa', newLienResa); 2081 } 2082 } 2083 console.log('modeCalculPrixSurFiche', modeCalculPrixSurFiche); 2084 if (modeCalculPrixSurFiche) { 2085 if (tabRetour.exeMajFiche) { 2086 var tabInfosActualisation = {deb: tabRetour.dateDebMajFiche, nbj: tabRetour.nbjMajFiche, exe: tabRetour.exeMajFiche}; 2087 if (actualisePageFiche(tabInfosActualisation)!==false) { 2088 return; 2089 } 2090 } 2091 if (typeof callbackOK !== 'function' || callbackOK.name !== 'affectSelectionChambres_f
2091iche') { 2092 majDivTarifAPartirDe(tabRetour); 2093 if (tabRetour.htmlDivChambres || tabRetour.htmlDatesSejoursAlternatifs) { 2094 majDivChambres_packDivDatesTarifs(tabRetour); 2095 } else { 2096 majTarifsSelectionne(tabData.dateDeb, tabData.dateFin); 2097 } 2098 } 2099 if (typeof callbackOK === 'function') { 2100 callbackOK(); 2101 } 2102 2103 if(typeof foncQdFini_datesSelectionnes!=='undefined'){ 2104 foncQdFini_datesSelectionnes(); 2105 } 2106 2107 return; 2108 } 2109 // on teste si la résa est une résa centrale, si c'est autre chose on recharge 2110 if(tabRetour.modeResa != undefined){ 2111 manageChangementTypeResa(tabRetour);return; 2112 } 2113 //Ajout pour la FNGF du Google Analytics 2114 if (typeof(dataLayer)!='undefined') { 2115 if (tabRetour.date_non_disponible == 1){ 2116 ajouteOuRemplaceDansDataLayer({'event' : 'availability', 'availability' : false}); 2117 }else{ 2118 ajouteOuRemplaceDansDataLayer({'event' : 'availability', 'availability' : true}); 2119 } 2120 } 2121 // Si on récupère tabResult.maj, on recharge la page avec l'id de session 2122 // Car cela signifie qu'on a changé d'exercice, 2123 // donc il faut récupérer les données de ce nouvel exercice 2124 if (tabRetour.maj) { 2125 rechargementPageMAJ(tabRetour); 2126 return; 2127 } 2128 // 328741 2129 if ($('#div_uneEtape_compoFamilleGite').length === 0 && $('#div_uneEtape_compoFamilleChambre').length === 0 && tabRetour.html_choixCompoFamille) { 2130 $('#div_uneEtape_date').after(tabRetour.html_choixCompoFamille); 2131 if ($("#div_uneEtape_compoFamilleGite").length > 0) { 2132 setEventsForGite(); 2133 } else { 2134 setEventsForChambre(); 2135 } 2136 } 2137 2138 gereDivAlertResaJoursIdentiques(tabRetour.htmlAlertResasJoursIdentiques); 2139 2140 //choix du jour d'arrivée 2141 if ($('#div_choixJourReference').length>0){ 2142 $('#div_choixJourReference').show(); 2143 } 2144 $(".div_uneChambre").each(function(){ 2145 if ($(this).find(".inpt_chambre").attr("checked") == undefined) 2146 $(this).find(".select_optionChambre").attr("disabled", true); 2147 }); 2148 $("tfoot").find("input").attr("disabled", true); 2149 // on passe à l'étape de compo famille => on dégrise et on rend actif 2150 $("#div_uneEtape_date").next(".div_uneEtape").removeClass('div_uneEtapeGrisee'); 2151 $("#div_uneEtape_date").next(".div_uneEtape").find('*').attr("disabled", false); 2152 2153 if ($('#div_uneEtape_selectionOrigine').length>0) { 2154 $("#div_uneEtape_selectionOrigine").next(".div_uneEtape").removeClass('div_uneEtapeGrisee'); 2155 $("#div_uneEtape_selectionOrigine").next(".div_uneEtape").find('*').attr("disabled", false); 2156 } 2157 // On met les deux dates à la même heure pour que le calcul d'écart soit correct 2158 if ($('#input_testDatepickerResa').length>0) { 2159 var dateDeb = $("#inpt_resaDateDeb").val(); 2160 objDateDeb = new Date(); 2161 objDateDeb.setFullYear(dateDeb.substr(6, 4), dateDeb.substr(3, 2)-1, dateDeb.substr(0, 2)); 2162 var dateFin = $("#inpt_resaDateFin").val(); 2163 objDateFin = new Date(); 2164 objDateFin.setFullYear(dateFin.substr(6, 4), dateFin.substr(3, 2)-1, dateFin.substr(0, 2)); 2165 } 2166 objDateDeb.setHours(0, 0, 0); 2167 objDateFin.setHours(0, 0, 0); 2168 nbJours = ecartDate(objDateFin, objDateDeb); 2169 $("#sp_confirmDispos_nbNuits").html(nbJours); 2170 //$("#div_confirmDispos").find(".ok").show(); 2171 $('#div_confirmDispos span.confirmSaisie.ko').html('').hide();
2171 //fiche 243176 2172 $("#div_recapInfos").html(tabRetour.recapInfos); 2173 if($("#p_recapDatesSelectionnees").length>0 && tabRetour.recapDatesTxt){ 2174 $("#p_recapDatesSelectionnees").html(tabRetour.recapDatesTxt); 2175 $("#div_choixDates").hide(); 2176 $("#div_recapDateSelectionnees").show(); 2177 } 2178 $(".sp_nbNuits").html(tabRetour.nbNuits); 2179 // On a récupéré des prix que pour un gite 2180 gereDivModifHoraires(tabRetour.htmlModifHoraires); 2181 gereDivAlertHorairesBloquants(tabRetour.htmlAlertHorairesBloquants); 2182// if (tabRetour.htmlModifHoraires) { 2183// if ($('.div_modifHoraires').length>0) { 2184// $('.div_modifHoraires').remove(); 2185// } 2186// $('.div_modifHoraire_arrivee').replaceWith(tabRetour.htmlModifHoraires.arrivee); 2187// $('.div_modifHoraire_depart').replaceWith(tabRetour.htmlModifHoraires.depart); 2188// initChangeHeureDebFin(); 2189// } 2190 if (tabRetour.htmlModifJourReference) { 2191 $('.div_choixJourReference').replaceWith(tabRetour.htmlModifJourReference); 2192 initChangeJourRef(); 2193 initChangeHeureDebFin(); 2194 } 2195 if (tabRetour.msgInfoModeResa){ 2196 $('.infosModeResa').html(tabRetour.msgInfoModeResa); 2197 $('.infosModeResa').show(); 2198 } 2199 else{ 2200 $('.infosModeResa').html(''); 2201 $('.infosModeResa').hide(); 2202 } 2203 if ($("#div_uneEtape_compoFamilleGite").length > 0) { 2204 afficheEffaceRecapPrix(tabRetour); 2205 majListesDureeOption(); 2206 } 2207 else if ($("#div_uneEtape_compoFamilleChambre").length>0) { 2208 // Par contre, pour les chambres on a recu les chambres disponibles 2209 if(!tabRetour.dateNonModifiee){ 2210 $(".div_uneChambre").each(function(){ 2211 $(this).hide(); 2212 for (var i=0; i<tabRetour.chambresDispo.length; i++) { 2213 if ($(this).attr("num") == tabRetour.chambresDispo[i]) { 2214 $(this).show(); 2215 if (tabRetour.planVenteChambres) { 2216 $('#select_compoFamilleAdulte_'+tabRetour.chambresDispo[i]).attr('data-planVente', tabRetour.planVenteChambres[tabRetour.chambresDispo[i]]); 2217 } 2218 } 2219 } 2220 }); 2221 } 2222 if ($(".div_uneChambre:visible").find(".inpt_chambre:checked").length == 0) { 2223 $("#div_recapPrix").hide(); 2224 if ($(".div_uneChambre:not(visible)").find(".inpt_chambre:checked").length > 0) { 2225 $(".div_uneChambre:not(visible)").find(".inpt_chambre:checked").each(function(){ 2226 $(this).attr("checked", false); 2227 // Yoann 12/03/2015 (fiche ) : On a déjà déselectionné la chambre dans le PHP 2228// $(this).change(); 2229 var num = $(this).parents(".div_uneChambre").attr("num"); 2230 $("#tr_prixChambre_"+num).hide(); 2231 }); 2232 } 2233 } 2234 else { 2235 metAJourRecapPrixForChambre(); 2236 } 2237 if (tabRetour.htmlOptionsChambres) { 2238 tabRetour.htmlOptionsChambres.each(function(elem){ 2239 var idElement = elem.idElement; 2240 var html = elem.html; 2241 var nbAdultes = elem.nbAdultes; 2242 var div_uneChambreTarifsOption = $('#'+idElement).find('.div_uneChambreTarifsOption'); 2243 div_uneChambreTarifsOption.html(html); 2244 if(nbAdultes === '' || nbAdultes === '0') { 2245 div_uneChambreTarifsOption.toggleClass('div_uneChambreTarifsOptionGrisee', true); 2246 div_uneChambreTarifsOption.find('*').attr('disabled', true); 2247 } 2248 }); 2249 } 2250 majListesDureeOption(true); 2251 } else if ($('.div_uneEtape_prodGP').length > 0) { 2252 $('.div_uneEtapeMsgErreur').remove(); 2253 if ($('.div_conteneurApresChoixPresta').length>0) { 2254 $('.div_conteneurApresChoixPresta').show(); 2255 } 2256 var idDivProd = $('.div_uneEtape_prodGP').attr('id'); 2257 $(".div_uneEtape_prodGP").replaceWith(tabRetour.HTML_choixChambre); 2258 $(".div_uneEtape_prodGP").removeClass('div_uneEtapeGrisee'); 2259 if (tabRetour.HTML_choixChambre.length==0) { 2260 $('.div_uneEtapeMsgErreur.div_aucuneDispo').show(); 2261 } 2262 // Yoann 18/07/2014 (fiche 217906) : il peut arriver que le recapInfos soit vide, il ne faut donc pas l'afficher 2263 if (tabRetour.recapInfos.length>0) { 2264 $("#div_recapInfosEtPrix").show(); 2265 } 2266 if (!afficheRecapPrix) { 2267 $("#div_recapPrix").hide(); 2268 } 2269 majNumEtapes(); 2270 if (idDivProd=='div_uneEtape_packageChoixTarif') { 2271 chargeAlternatives(); 2272 } 2273 initDescTarifQTip(); 2274 reinitSelectionLignesFactures(); 2275 if($('.inputHeureVoiture').length>0){ 2276 $('#div_selectionVoiture .inputHeureVoiture').each(function () { 2277 var heuresAutorisees = $(this).data('heures_autorisees'); 2278 $(this).datetimepicker({ 2279 datepicker: false, 2280 format: 'H:i', 2281 step: 30, 2282 validateOnBlur: false, 2283 allowTimes: heuresAutorisees 2284 }); 2285 }); 2286 } 2287 if ($('.div_uneEtapeMsgErreur').length==0) { 2288 $('#div_boutonsResa').show(); 2289 } 2290 } 2291 $("#sp_recapDateDeb").html(tabData.dateDeb); 2292 $("#sp_recapDateFin").html(tabData.dateFin); 2293 $("#sp_recapDatesDuree").html(nbJours); 2294 if(nbJours>1){ 2295 $("#sp_recapDateLblNuits").css("display","inline"); 2296 $("#sp_recapDateLblNuit").css("display","none"); 2297 } 2298 else{ 2299 $("#sp_recapDateLblNuits").css("display","none"); 2300 $("#sp_recapDateLblNuit").css("display","inline"); 2301 } 2302 var elemToREmove = $("#div_uneEtape_date .div_uneEtapeRecap").find('.classForcageParametresPV'); 2303 $(elemToREmove).remove(); 2304 if(typeof(tabRetour.explicationsForcagePV) != 'undefined'){ 2305 $("#div_uneEtape_date .div_uneEtapeRecap").append(tabRetour.explicationsForcagePV); 2306 } 2307 2308 etapeCourante($("#div_uneEtape_date"), true); 2309 // fiche 250593 2310 var modeDevis = tabRetour.modeDevis || false; 2311 if(modeDevis ){ 2312 $('.div_uneEtapeRecap', '#div_uneEtape_date').hide(); 2313 } 2314 2315 2316 $("#div_msgDatesNull").hide(); 2317 $("#div_recapInfos").show();
2318 $("#div_uneEtape_date").find(".inpt_validEtape").val("Oui"); 2319// if($("#div_uneEtape_canevas").length>0){ 2320 initCanevasResaCouplee(tabRetour.reinitCanevas); 2321// } 2322 mettreAjourListeRepas(); 2323 2324 if (estMultiResa()) { 2325 affectAssuranceMultiResaDepuisSessionStorage(); 2326 } 2327 2328 2329 if(typeof foncQdFini_valideDateEtape1!=='undefined'){ 2330 foncQdFini_valideDateEtape1(); 2331 } 2332 if(tabRetour.questionRecalculAuto){ 2333 questionRecalculAuto(); 2334 } 2335 if (typeof callbackOK === 'function') { 2336 callbackOK(); 2337 } 2338 2339 2340 } 2341 else { 2342 if (modeCalculPrixSurFiche) { 2343 majDivTarifAPartirDe(tabRetour); 2344 if (tabRetour.htmlDivChambres) { 2345 majDivChambres_packDivDatesTarifs(tabRetour); 2346 } else { 2347 majTarifsSelectionne(tabData.dateDeb, tabData.dateFin); 2348 } 2349 return; 2350 } 2351 gereDivModifHoraires(tabRetour.htmlModifHoraires); 2352// if (tabRetour.htmlModifHoraires) { 2353// if ($('.div_modifHoraires').length>0) { 2354// $('.div_modifHoraires').remove(); 2355// } 2356// $('.div_modifHoraire_arrivee').replaceWith(tabRetour.htmlModifHoraires.arrivee); 2357// $('.div_modifHoraire_depart').replaceWith(tabRetour.htmlModifHoraires.depart); 2358// initChangeHeureDebFin(); 2359// } 2360 gereDivAlertResaJoursIdentiques(tabRetour.htmlAlertResasJoursIdentiques); 2361 gereDivAlertHorairesBloquants(tabRetour.htmlAlertHorairesBloquants); 2362 if(tabRetour.errLD != undefined || (tabRetour.dispo && tabRetour.dispo === 'OCC')){ 2363 effaceMsgAttenteParDessus("recapPrix"); 2364 $('#div_recapPrix').hide(); 2365 $("#inpt_resaDateFin").val("Départ"); 2366 $("#inpt_resaDateDeb").val("Arrivée"); 2367 alertAJquery(tabRetour.msg); 2368 return; 2369 } 2370 if (tabRetour.avecFormContact) { 2371 sendThisToProp(tabRetour.ident, 800, 600, tabRetour.titre, "O"); 2372 } 2373 // Pour le Google Tag Manager 2374 if (tabRetour.datesProches && typeof(dataLayer)!='undefined') { 2375 dataLayer.push({'event' : 'resa_datesProches'}); 2376 } 2377 if (typeof(dataLayer)!='undefined') { 2378 ajouteOuRemplaceDansDataLayer({'event' : 'availability', 'availability' : false}); 2379 } 2380 invalideSaisieDates(tabRetour.msg); 2381 } 2382 } 2383 initFancyBoxDeBase(); 2384 effaceMsgAttenteParDessus("recapPrix"); 2385 }, 2386 complete: function(){ 2387 effaceLoaderGlobal_site(); 2388 } 2389 }); 2390 })(jQuery) 2391} 2392 2393/** 2394 * Initialisation des prix si des dates sont passées en URL<br /> 2395 * On gère deux cas pour récupérer les dates: deux datepickers ou un datepicker et une liste<br /> 2396 * Puis avec ces dates on appelle verifDates qui va nous renvoyer les prix<br /> 2397 * Les dates ayant déjà été vérifiées dans etape1.php, il y a peu de chance d'avoir une erreur 2398 */ 2399function initPrix(){ 2400 (function($){ 2401 // Si j'ai un PHPSESSID dans l'URL cela signifie que l'on revient d'une étape postérieure, je vais donc afficher le recapPrix 2402 if (location.search.indexOf("PHPSESSID") > -1) { 2403 afficheRecapPrix = true; 2404 } 2405 2406 // Récupération de la date de début 2407 var dateDeb = $("#inpt_resaDateDeb").val(); 2408 var dateFin; 2409 objDateDeb = new Date(); 2410 objDateDeb.setFullYear(dateDeb.substr(6, 4), dateDeb.substr(3, 2)-1, dateDeb.substr(0, 2)); 2411 2412 // Récupération de la date de fin 2413 // Si deux datepicker 2414 if ($("#div_choixDateFin").length > 0) { 2415 dateFin = $("#inpt_resaDateFin").val(); 2416 objDateFin = new Date(); 2417 objDateFin.setFullYear(dateFin.substr(6, 4), dateFin.substr(3, 2)-1, dateFin.substr(0, 2)); 2418 } 2419 // Si datepicker et liste durée 2420 else if ($("#div_choixNbNuits").length>0) { 2421 initListeNbNuits(); 2422 var duree = $("#inpt_nbNuits").val(); 2423 duree = parseInt(duree); 2424 objDateFin = new Date(); 2425 objDateFin.setFullYear(objDateDeb.getFullYear(), objDateDeb.getMonth(), objDateDeb.getDate() + duree); 2426 var jour, mois, annee; 2427 if (objDateFin.getDate().toString().length == 1) 2428 jour = "0"+objDateFin.getDate(); 2429 else 2430 jour = objDateFin.getDate(); 2431 if (objDateFin.getMonth().toString().length == 1) 2432 mois = "0"+(objDateFin.getMonth()+1); 2433 else 2434 mois = objDateFin.getMonth()+1; 2435 annee = objDateFin.getFullYear(); 2436 dateFin = jour+"/"+mois+"/"+annee; 2437 } 2438 2439 // Une fois qu'on a récupéré les dates sélectionnées, on simule la sélection de ces dates 2440 // Clic sur le calDeb, sélection de la dateDeb et sélection de la dateFin. 2441 // Cela permet d'avoir le datePickerDateFin initialisé dans le cas ou l'utilisateur veut changer la date de fin 2442 $("#inpt_resaDateDeb").click(); 2443 // Avant d'aller plus loins, on vérifie que le click sur la date de début s'est bien passé
2444 if ($("#div_uneEtape_date").find(".inpt_validEtape").val() == "Oui") { 2445 $("#sp_fermerCalDateDeb").click(); 2446 if ($('#input_testDatepickerResa').length>0) { 2447 setInputDateDebResa(dateDeb); 2448 initDatepickersDateNaissance(); 2449 if ($('#div_uneEtape_billetChoixPresta').length==0 && $('#div_uneEtape_packageChoixTarif').length==0) { 2450 setInputDateFinResa(dateFin); 2451 } else { 2452 $("#sp_fermerCalDateFin").click(); 2453 } 2454 } else { 2455 setDateDeb(dateDeb); 2456 if ($('#div_uneEtape_billetChoixPresta').length==0 && $('#div_uneEtape_packageChoixTarif').length==0) { 2457 setDateFin(dateFin); 2458 } 2459 } 2460 } 2461 })(jQuery); 2462} 2463 2464/** 2465 * Initialisation de la liste contenant le nombre de nuits pour le séjour<br /> 2466 * Cette liste est créé à partir des informations récupérées dans la table sejour_GP<br /> 2467 * et contient donc uniquement le nombre de nuits possibles pour le séjour<br /> 2468 * en fonction de la date de début 2469 */ 2470function initListeNbNuits(infoBulle){ 2471 (function($){ 2472 var dateDeb = $("#inpt_resaDateDeb").val(); 2473 var duree = $("#inpt_nbNuits").val(); 2474 2475 // Récupération de la liste en ajax 2476 $.ajax({ 2477 type: "POST", 2478 url: urlAJAX, 2479 data: {type: "getListeNbNuits", dateDeb: dateDeb, duree: duree, infoBulle: infoBulle}, 2480 beforeSend: function(){ 2481 $("#img_roueDatePicker").show(); 2482 }, 2483 success: function(result){ 2484 eval("var tabResult="+result); 2485 if (tabResult.code == errDossierNull) { 2486 retourEtape1(tabResult.msg); 2487 } 2488 else if (tabResult.errTechnq) { 2489 afficheMsgErrTechnq(tabResult.msg, tabResult.titre, tabResult.ident, true); 2490 } 2491 else { 2492 if (tabResult.code == "OK") { 2493 $("#select_nbNuits").html(tabResult.listeNbNuits); 2494 } 2495 } 2496 2497 $("#img_roueDatePicker").hide(); 2498 } 2499 }); 2500 // On met à jour la liste avec le résultat obtenu 2501 })(jQuery); 2502} 2503 2504/** 2505* Retourne le nombre de jour entre 2 dates passées en paramètres<br /> 2506* <b>Attention, il faut date1 > date2</b> 2507* @param date1 La première date 2508* @param date2 La seconde date 2509* @return Le nombre de jours de différence entre date1 et date2 (le résultat est arrondi) 2510*/ 2511function ecartDate(date1, date2){ 2512 // On récupère le nombre de millisecondes dans un jour 2513 var unJour = 24*60*60*1000; 2514 2515 // On calcule la différence entre les deux dates (en millisecondes) 2516 // et on divise par unJour pour obtenir un résultat en nombre de jours et pas en millisecondes 2517 return Math.round((date1.getTime()-date2.getTime())/(unJour)); 2518} 2519 2520/** 2521 * Met à jour un calendrier datepicker gràce à la chaine de dispos récupérés par infosDist.php<br /> 2522 * Cette fonction est appelée pour chaque jour du calendrier datepicker 2523 * @param date Le jour du calendrier 2524 * @return array Tableau contenant un booleen indiquant si le jour est cliquable ou non<br > 2525 * et une chaine de caractères correspondant à la classe CSS affectée à ce jour 2526 */ 2527 2528function setJourDebut(date){ 2529 return setJour(date,true); 2530} 2531 2532function setJour(date,datepickerDeb){ 2533 var ObjDateDeb = new Date(dateDebPlanning.substr(6,4), dateDebPlanning.substr(3,2)-1, dateDebPlanning.substr(0,2)); 2534 var ecart = Math.round(ecartDate(date, ObjDateDeb)); 2535 var caractere = chainePlanning.charAt(ecart); 2536 var infoBulle; 2537 if (infoBulles) 2538 infoBulle = infoBulles[ecart]; 2539 else 2540 infoBulle = ""; 2541 var sejour = ''; 2542 2543 if(typeof(objDateDeb) != 'undefined' && typeof(objDateFin) != 'undefined' && objDateFin){ 2544 var ecartDateDeb = Math.round(ecartDate(objDateDeb, ObjDateDeb)); 2545 var ecartDateFin = Math.round(ecartDate(objDateFin, ObjDateDeb)); 2546 2547 if (ecartDateDeb <= ecart && ecartDateFin >= ecart){
2548 sejour = 'sejour'; 2549 if(ecart == ecartDateDeb){ 2550 sejour+= ' dateArrivee'; 2551 } 2552 if(ecart == ecartDateFin){ 2553 sejour+= ' dateFin'; 2554 } 2555 } 2556 } 2557 2558// var dateTest = new Date("2012", "8", "15"); 2559// var ecartTest = Math.round(diffDate(dateTest, ObjDateDeb)); 2560 var classe = sejour+' '; 2561 2562 var caracterePrecedent = chainePlanning.charAt(ecart-1); 2563 var caractereSuivant = chainePlanning.charAt(ecart+1); 2564 var tabCaracteresNonCliquables = ['i', 'o', 'r', 'n']; 2565 if (caractere.length>0 && caracterePrecedent.length>0) { 2566 if (datepickerDeb===true) { 2567 if (jQuery.inArray(caractere, tabCaracteresNonCliquables)>-1 && jQuery.inArray(caracterePrecedent, tabCaracteresNonCliquables)===-1) { 2568 classe += 'debutResa '; 2569 } 2570 if (jQuery.inArray(caractere, tabCaracteresNonCliquables)===-1 && jQuery.inArray(caracterePrecedent, tabCaracteresNonCliquables)>-1) { 2571 classe += 'finResa '; 2572 } 2573 } else { 2574 if (jQuery.inArray(caractere, tabCaracteresNonCliquables)===-1 && jQuery.inArray(caractereSuivant, tabCaracteresNonCliquables)>-1) { 2575 classe += 'debutResa '; 2576 } 2577 } 2578 } 2579 2580 if (caractere === "." || caractere === "A"){ 2581 classe+='cliquable'; 2582 return [true, classe, infoBulle]; 2583 } 2584 else if (caractere == "o" || caractere == "O" ){ 2585 //210475, "a" = resa agence, je fait comme le PHP, je demande a contacter le proprio 2586 // guillaume : a = resa agence = résa réservée à l'agence, donc impossible de réserver pour le grand public 2587 classe+='option'; 2588 //caro suite fiche 246874 je mets les options en non cliquable 2589 return [false, classe]; 2590 } 2591 else if (caractere == "r" || caractere == "R"){ 2592 classe+='resa'; 2593 return [false,classe]; 2594 } 2595 else if (caractere === "l" || caractere === "L"){ 2596 classe+='libre'; 2597 if (gestprod) { 2598 return [false, classe]; 2599 } else { 2600 return [true, classe]; 2601 } 2602 } 2603 else if (caractere == "n"){ 2604 classe+='occupe'; 2605 return [false, classe]; 2606 } 2607 else if (caractere == "b") { 2608 //210475, "a" est déjà pris par agence, je met b comme before 2609 classe+='avantDatesPossibles'; 2610 return [false, classe]; 2611 } 2612 else if (caractere == "j") { 2613 //CORR 229745 2614 classe+='dateArrivee'; 2615 return [false, classe]; 2616 } 2617 else if (caractere == "i") { 2618 classe+='intention'; 2619 return [false, classe]; 2620 } 2621 else if (caractere == "d") { 2622 classe+='devis'; 2623 return [true, classe]; 2624 } 2625 else if(caractere == "f"){ 2626 classe+='forcage'; 2627 return [true, classe]; 2628 } 2629 // Antoine : je mets >= au lieu de > sinon le dernier jour de l'exe apparaît en "sur demande" 2630 else if(!caractere && ecart>=chainePlanning.length){ 2631 //classe+='inconnu'; // fiche 242595 2632 classe+='occupe'; 2633 return [false, classe]; 2634 } else if (caractere == "?" || caractere == "a") { 2635 // fiche 239988 2636 classe+='inconnu'; 2637 if (gestprod) { 2638 return [false, classe]; 2639 } else { 2640 return [true, classe]; 2641 } 2642 } 2643 else if (ecart>=0){ 2644 return [false, "inconnu"]; 2645 } else { 2646 return [false, "avantDatesPossibles"]; 2647 } 2648} 2649 2650/** 2651 * Actualisation de la liste des enfants en fonction du nombre d'adultes et de la capacité totale<br /> 2652 * Afin d'éviter de pouvoir sélectionner un nombre de personnes > à la capacité du gîte 2653 * 2654 * @param {string} numChambre Le numéro de la chambre dont on souhaite mettre à jour les listes de sélection 2655 * @returns {undefined} 2656 */ 2657function metAJourListeFamille(numChambre){ 2658 (function($){ 2659 // On commence par cacher le message d'information concernant la réinitialisation de la liste enfant 2660 $("#div_compoFamille_msgReinitEnfant").hide(); 2661 2662 var suffixe = ""; 2663 if (numChambre) { 2664 suffixe = "_"+numChambre; 2665 } 2666 2667 var idSelectEnfants = "#select_compoFamilleEnfant"+suffixe; 2668 var idSelectAdultes = "#select_compoFamilleAdulte"+suffixe; 2669 var idSelectBebes = "#select_compoFamilleBebe"+suffixe; 2670 2671 // On récupère la capacité totale du gite grâce au nombre de balises option dans la liste Adultes 2672 var capacite = parseInt($(idSelectAdultes).attr('data-capacite')); 2673 if ($(idSelectAdultes).attr('data-surcapacite') === 'true'){ 2674 capacite*=2; 2675 } 2676 2677 // Modif guillaume : pour gérer le dépassement de capacité en mode point de vente, on va récupérer la vraie capacité du gite grace à l'attribut data-capacite 2678 var capaciteReel; 2679 try { 2680 capaciteReel = parseInt($("#select_compoFamilleAdulte"+suffixe).attr('data-capacite')); 2681 } catch(e){ 2682 capaciteReel = capacite; 2683 } 2684 2685 var nbAdultes = parseInt($(idSelectAdultes).val()); 2686 var nbEnfants = parseInt($(idSelectEnfants).val()) || 0 ; 2687 var nbBebes = parseInt($(idSelectBebes).val()) || 0 ; 2688 2689 // On commence par vérifier si le nombre de bébés est correct 2690 if (bebeDansCapacite()) { 2691 console.log('metAJourListeFamille ya bebeDansCapacite suffixe : ',suffixe); 2692 var nbBebesMax = $('#inpt_nbBebesMax'+suffixe).val(); 2693 console.log('nbBebesMax input ',nbBebesMax); 2694 if (nbBebesMax > (capacite - nbAdultes - nbEnfants)) { 2695 nbBebesMax = capacite - nbAdultes - nbEnfants; 2696 } 2697 if (nbBebesMax <= -1) { 2698 nbBebesMax = 0; 2699 } 2700 2701 console.log('nbBebesMax ',nbBebesMax); 2702 2703 if ($(idSelectAdultes).attr('data-surcapacite') === 'true') { 2704 supprimeSurcapacite(idSelectBebes); 2705 metAJourListeEnfants(idSelectBebes, nbBebesMax); 2706 ajouteSurcapacite(idSelectBebes, (nbAdultes+nbEnfants), capaciteReel); 2707 supprimeSurcapacite(idSelectAdultes); 2708 var nbMaxAdulte = $(idSelectAdultes).attr('data-max-adulte'); 2709 if (isNullOrUndefinedOrEmpty(nbMaxAdulte) || nbMaxAdulte === null || nbMaxAdulte === 0 || nbMaxAdulte === '') { 2710 nbMaxAdulte = capacite; 2711 } 2712 ajouteSurcapacite(idSelectAdultes, (nbEnfants + nbBebes), nbMaxAdulte); 2713 } else { 2714 metAJourListeEnfants(idSelectBebes, nbBebesMax); 2715 } 2716 2717 if (nbBebesMax===0) { 2718 $(idSelectBebes).attr('disabled',true); 2719 } else { 2720 $("#div_infoCompoBebes"+suffixe).show(); 2721 $(idSelectBebes).attr('disabled',false); 2722 } 2723 if (nbBebes>nbBebesMax) { 2724 $("#div_compoFamille_msgReinitBebe").show("pulsate", {times: 3}, "slow"); 2725 $("#div_compoFamilleDateNaissanceBebes"+suffixe).hide(); 2726 } 2727 } 2728 2729 // Ensuite on calcule le nombre max d'enfants que l'on peut afficher 2730 // Je redéfinis nbBebes car il peut avoir été modifié 2731 nbBebes = parseInt($(idSelectBebes).val()) || 0 ; 2732 var nbEnfantsMax = $('#inpt_nbEnfantsMax'+suffixe).val(); 2733 if (nbEnfantsMax > (capacite - nbAdultes)) { 2734 nbEnfantsMax = capacite - nbAdultes; 2735 } 2736 if (bebeDansCapacite()) { 2737 nbEnfantsMax -= nbBebes; 2738 } 2739 if (nbEnfantsMax <= -1) { 2740 nbEnfantsMax = 0; 2741 } 2742 2743 if ($(idSelectAdultes).attr('data-surcapacite') === 'true') { 2744 supprimeSurcapacite(idSelectEnfants); 2745 metAJourListeEnfants(idSelectEnfants, nbEnfantsMax); 2746 if (bebeDansCapacite()) { 2747 ajouteSurcapacite(idSelectEnfants, (nbAdultes+nbBebes), capaciteReel); 2748 } else { 2749 ajouteSurcapacite(idSelectEnfants, nbAdultes, capaciteReel); 2750 } 2751 2752 supprimeSurcapacite(idSelectAdultes); 2753 var nbMaxAdulte = $(idSelectAdultes).attr('data-max-adulte'); 2754 if (isNullOrUndefinedOrEmpty(nbMaxAdulte) || nbMaxAdulte === null || nbMaxAdulte === 0 || nbMaxAdulte === '') { 2755 nbMaxAdulte = capaciteReel; 2756 } 2757 if (bebeDansCapacite()) { 2758 ajouteSurcapacite(idSelectAdultes, (nbEnfants+nbBebes), nbMaxAdulte); 2759 } else { 2760 ajouteSurcapacite(idSelectAdultes, nbEnfants, nbMaxAdulte); 2761 } 2762 } else { 2763 metAJourListeEnfants(idSelectEnfants, nbEnfantsMax); 2764 } 2765 2766 // Si le nombre d'enfants sélectionnées est supérieur au nombre d'enfants max 2767 // Alors la liste va être réinitialisé, on affiche un message d'information 2768 // Et on cache le champ concernant l'âge des enfants 2769 if (nbEnfantsMax==0) { 2770 //$("#div_infoCompoEnfants"+suffixe).hide(); 2771 //$("#div_compoFamilleAgeEnfants"+suffixe).hide(); 2772 $(idSelectEnfants).attr('disabled',true); 2773 } else { 2774 $("#div_infoCompoEnfants"+suffixe).show(); 2775 $(idSelectEnfants).attr('disabled',false); 2776 } 2777 if (nbEnfants>nbEnfantsMax) { 2778 $("#div_compoFamille_msgReinitEnfant").show("pulsate", {times: 3}, "slow"); 2779 $("#div_compoFamilleDateNaissanceEnfants"+suffixe).hide(); 2780 } 2781 })(jQuery); 2782} 2783 2784function bebeDansCapacite(){ 2785 return jQuery('#inpt_bebeDansCapacite').length>0; 2786} 2787 2788function supprimeSurcapacite(idSelect){ 2789 (function($){ 2790 if ($(idSelect+' optgroup.surcapacite').length===0) { 2791 return; 2792 } 2793 2794 $(idSelect+' option.surcapacite').removeClass('surcapacite'); 2795 2796 if ($(idSelect+' optgroup.surcapacite').length>0) { 2797 $(idSelect+' optgroup.surcapacite option').each(function(){ 2798 $(idSelect).append($(this)); 2799 }); 2800 $(idSelect+' optgroup.surcapacite').remove(); 2801 } 2802 })(jQuery); 2803} 2804 2805function metAJourListeEnfants(idSelectEnfants, nbMaxEnfants){ 2806 (function($){ 2807 if (parseInt($(idSelectEnfants+" option:last-child").val()) < nbMaxEnfants) { 2808 var valAjout = parseInt($(idSelectEnfants+" option:last-child").val()); 2809 while (parseInt($(idSelectEnfants+" option:last-child").val()) < parseInt(nbMaxEnfants)) { 2810 valAjout++; 2811 $(idSelectEnfants).append("<option value='"+valAjout+"'>"+valAjout+"</option>"); 2812 } 2813 } 2814 else { 2815 // Si la liste est supérieur au nombre max, on supprime par la fin 2816 while (parseInt($(idSelectEnfants+" option:last-child").val()) > parseInt(nbMaxEnfants)) { 2817 $(idSelectEnfants+" option:last-child").remove(); 2818 } 2819 } 2820 })(jQuery); 2821} 2822 2823function ajouteSurcapacite(idSelect, ajout, capaciteMax){ 2824 (function($){ 2825 var valOptionLastChild = parseInt($(idSelect+' option:last-child').val()); 2826 if ((valOptionLastChild + ajout)>capaciteMax) { 2827 $(idSelect).append('<optgroup class="surcapacite" label="Surcapacité"></optgroup>'); 2828 } 2829 $(idSelect+' option').each(function(){ 2830 if (parseInt($(this).val())>0 && (parseInt($(this).val()) + ajout)>capaciteMax){ 2831 $(this).addClass('surcapacite'); 2832 $(idSelect+' optgroup.surcapacite').append($(this)); 2833 } 2834 }); 2835 })(jQuery); 2836} 2837 2838function videDatesNaissanceNonVisibles(){ 2839 jQuery('.inpt_dateNaissance:not(:visible)').val(''); 2840} 2841 2842function affecteDatesNaissanceAvecCoherence(){ 2843 (function ($) { 2844 var tabDatesNaissance = {}; 2845 $('.div_uneChambreSelection, #div_uneEtape_compoFamilleGite').each(function(){ 2846 var tabDates = construireTableauDatesNaissance(this);
2847 var index = $(this).data('num_idch') || 'gite'; 2848 tabDatesNaissance[index] = tabDates; 2849 }); 2850 $.ajax({ 2851 type: 'POST', 2852 url: urlAJAX, 2853 async: false, // TRES IMPORTANT 2854 data: { 2855 type : 'enregistreDatesNaissance', 2856 tabDatesNaissance: tabDatesNaissance 2857 }, 2858 dataType: 'json', 2859 success: function(JSONResult){ 2860 console.log('enregistreDatesNaissance success result : ',JSONResult); 2861 } 2862 }); 2863 })(jQuery); 2864} 2865 2866function construireTableauDatesNaissance(element){ 2867 var tabDatesNaissance = {}; 2868 (function ($) { 2869 var nb = parseInt($('.select_compoFamilleEnfant', element).val()); 2870 var date; 2871 for (var i = 1; i <= nb; i++) { 2872 date = $('.inpt_dateNaissance.enfant[data-id="' + i + '"]', element).val(); 2873 if (parseInt(date)>0) { 2874 tabDatesNaissance['enfant_'+i] = date; 2875 } 2876 } 2877 nb = parseInt($('.select_compoFamilleBebe', element).val()); 2878 for (var i = 1; i <= nb; i++) { 2879 date = $('.inpt_dateNaissance.bebe[data-id="' + i + '"]', element).val(); 2880 if (parseInt(date)>0) { 2881 tabDatesNaissance['bebe_'+i] = date; 2882 } 2883 } 2884 })(jQuery); 2885 return tabDatesNaissance; 2886} 2887 2888/** 2889 * Permet de mettre en valeur une étape de la résa (ajout de la classe div_uneEtapeCurr)<br /> 2890 * En fonction de l'étape en cours 2891 * @param elem L'étape actuelle (avec la classe div_uneEtape), on veut passer la suivante en surbrillance<br /> 2892 * Si on modifie une étape qui n'est pas en surbrillance,<br /> 2893 * on affiche son récap mais on ne met pas l'étape suivante en surbrillance<br /> 2894 * Si l'étape suivante a son récap affiché, on passe à la suivante pour la mettre en surbrillance<br /> 2895 * (en vérifiant également si son récap est déjà affiché) 2896 * @param repli Booléen permettant de choisir si on repli elem ou pas 2897 */ 2898function etapeCourante(elem, repli){ 2899 (function($){ 2900 if ($("#inpt_avecRepli").length > 0) { 2901 // On ne repli pas l'étape des chambres car on peut faire plusieurs sélection 2902 // et donc on évite au client de cliquer sur modifier à chaque fois 2903 if (elem.attr("id") != "div_uneEtape_compoFamilleChambre") { 2904 elem.find(".a_modifEtape").show(); 2905 if (repli) { 2906 elem.children(".div_uneEtapeContent").hide("slow"); 2907 elem.children(".div_uneEtapeRecap").show("slow"); 2908 } 2909 if (elem.hasClass('div_uneEtapeCurr')) { 2910 elem.next().addClass('div_uneEtapeCurr'); 2911 elem.removeClass('div_uneEtapeCurr'); 2912 if (elem.next().children(".div_uneEtapeRecap").is(":visible")) { 2913 // Si l'étape suivante a été validée, on passe à celle d'après 2914 etapeCourante(elem.next(), repli); 2915 } 2916 } 2917 } 2918 } 2919 else if (elem.attr("id") == "div_uneEtape_date"){ 2920 $("#div_uneEtape_date > div.div_uneEtapeRecap").show(); 2921 } 2922 elem.find(".inpt_validEtape").val("Oui"); 2923 elem.removeClass('div_uneEtapeAValider'); 2924 $("#div_msgErreurs").hide(); 2925 })(jQuery); 2926} 2927 2928/** 2929 * Permet d'afficher ou de masquer les options/suppléments de l'hébergement<br /> 2930 * En fonction du nombre d'adultes/animaux sélectionnés dans les listes déroulantes 2931 * @param typeOptions Le type d'options qua l'on veut afficher/masquer: 2932 * <ul> 2933 * <li>Animaux: pour afficher les options liées aux animaux</li> 2934 * <li>Adultes: pour afficher les options liées aux personnes (adultes+enfants)</li> 2935 * </ul> 2936 */ 2937function afficheEffaceOptions(typeOptions){ 2938 (function($){ 2939 switch (typeOptions) { 2940 case "Animaux": 2941 $("tr.animal").each(function(){ 2942 var nbAnimaux = (parseInt($("#select_compoAnimauxChat").val()) + parseInt($("#select_compoAnimauxChien").val())); 2943 if (nbAnimaux > 0) { 2944 $(this).find(".sp_optionObligatoire").html(nbAnimaux); 2945 $(this).find(".inpt_optionObligatoire").val(nbAnimaux); 2946 $(this).parents("#div_infosOptionsAnimaux").show(); 2947 } 2948 else { 2949 if ($(this).is(":not(.obligatoire)")) { 2950 $(this).find(".select_optionAnimaux").val(0); 2951 $(this).find(".inpt_optionIndiv").checked = false;
2952 $(this).find(".inpt_optionIndiv").attr("checked", false); 2953 } 2954 $(this).parents("#div_infosOptionsAnimaux").hide(); 2955 } 2956 }); 2957 break; 2958 case "AnimauxChambre": 2959 // on gere les animaux auterment 2960 2961 break; 2962 case "Adultes": 2963 if (parseInt($("#select_compoFamilleAdulte").val()) > 0) { 2964 $("#div_infosOptionsObligatoires").show(); 2965 } else { 2966 $("#div_infosOptionsObligatoires").hide(); 2967 } 2968 $("tr.indiv.obligatoire:not(.animal)").each(function(){ 2969 if (parseInt($("#select_compoFamilleAdulte").val()) > 0) { 2970 if ($(this).children("td").children("span").has("input.inpt_optionEnfants").length) { 2971 var nbEnfants = (parseInt($("#select_compoFamilleEnfant").val())); 2972 var nbAdultes = (parseInt($("#select_compoFamilleAdulte").val())); 2973 $(this).find("span.sp_optionEnfants").html(nbEnfants); 2974 $(this).find("input.inpt_optionEnfants").val(nbEnfants); 2975 $(this).find("span.sp_optionAdultes").html(nbAdultes); 2976 $(this).find("input.inpt_optionAdultes").val(nbAdultes); 2977 } 2978 else { 2979 var nbPers = 0; 2980 if(!isNaN(parseInt($("#select_compoFamilleAdulte").val()))){ 2981 nbPers += parseInt($("#select_compoFamilleAdulte").val()); 2982 } 2983 if (!isNaN(parseInt($("#select_compoFamilleEnfant").val()))) { 2984 nbPers += parseInt($("#select_compoFamilleEnfant").val()); 2985 } 2986 $(this).find(".sp_optionObligatoire").html(nbPers); 2987 $(this).find(".inpt_optionObligatoire").val(nbPers); 2988 } 2989 $(this).show(); 2990 $(this).parents("#div_infosOptionsObligatoires").show(); 2991 } 2992 else { 2993 $(this).hide(); 2994 $(this).parents("#div_infosOptionsObligatoires").hide(); 2995 } 2996 }); 2997 break; 2998 } 2999 })(jQuery); 3000} 3001function afficheEffaceOptionsSupplementaireObligatoires(numOption,numchambre,valFinale){ 3002 (function($){ 3003 $('#select_optionChambre_'+numOption+'_'+numchambre).val(valFinale); 3004 $('#select_optionChambre_'+numOption+'_'+numchambre).trigger('change'); 3005 if($('#remplace_select_optionChambre_'+numOption+'_'+numchambre)){ 3006 if(valFinale == '0'){ 3007 valFinale = '-'; 3008 } 3009 $('#remplace_select_optionChambre_'+numOption+'_'+numchambre).html(valFinale); 3010 } 3011 })(jQuery); 3012} 3013 3014function initListesDureeOption(optionsChambre){ 3015 (function($){ 3016 if (optionsChambre) { 3017 if ($('.div_uneChambreTarifsOption .select_dureeForOption').length>0) { 3018 $('.div_uneChambreTarifsOption .select_dureeForOption').live('change', function(){ 3019 affectOptionsChambre(); 3020 }); 3021 } 3022 } else { 3023 // fiche 301827 : il faut faire un delegate plutôt qu'un change directement. 3024 $('#div_resaContent').delegate('.select_dureeForOption','change',function(){ 3025 affectOptions(); 3026 }); 3027 3028// if ($('#div_optionsSuppl .select_dureeForOption').length>0) { 3029// $('#div_optionsSuppl .select_dureeForOption').change(function(){ 3030// affectOptions(); 3031// }); 3032// } 3033 if ($('#div_infosOptionsAnimauxContent .select_dureeForOption').length>0) { 3034 $('#div_infosOptionsAnimauxContent .select_dureeForOption').change(function(){ 3035 affectOptions(); 3036 }); 3037 } 3038 } 3039 3040 })(jQuery); 3041} 3042 3043function majListesDureeOption(optionsChambre){ 3044 (function($){ 3045 if((estResaBureauGestloc() || estResaBureauProp()) && !modifieResaExistante()){ 3046 $('#div_optionsSuppl .select_dureeForOption,#div_infosOptionsObligatoiresContent .select_dureeForOption, #div_infosOptionsAnimauxContent .select_dureeForOption').each(function(){ 3047 $(this).val(nbJours); 3048 }); 3049 } 3050 $('#div_optionsSuppl .select_dureeForOption, .div_uneChambreTarifsOption .select_dureeForOption').each(function(){ 3051 var nbMax = nbJours * 2; 3052 $(this).find('option').each(function(){ 3053 var duree = $(this).val(); 3054 if (duree<=nbMax) { 3055 $(this).show(); 3056 } else { 3057 $(this).hide(); 3058 } 3059 3060 }); 3061 }); 3062 3063 if (optionsChambre) { 3064 affectOptionsChambre(); 3065 } else { 3066 affectOptions(); 3067 } 3068 })(jQuery); 3069} 3070 3071// Plus utilisé normalement, à vérifier 3072/** 3073 * Mise à jour de l'encart de récapitulatif des prix 3074 * Cette fonction est appelée lorsque des paramètres de la résa ont été modifiés 3075 * Dates de séjour, nombre de personnes/d'animaux, options, promotion, assurance annulation 3076 * Elle récupère les prix grâce à une requête AJAX qui appelle Tr
3076scWeb 3077 */ 3078function metAJourRecapPrix(){ 3079 (function($){ 3080 if ($(".option:visible:has(input:checked)").length > 0) { 3081 affectOptions(); 3082 } 3083 else { 3084 $.ajax({ 3085 type: "POST", 3086 url: urlAJAX, 3087 data: {type: "recupPrix"}, 3088 beforeSend: function(){ 3089 affMsgAttenteParDessusInDiv("div_resaRecap", "recapPrix", txtAttente); 3090 }, 3091 success: function(result){ 3092 eval("var tabResult="+result); 3093 if (tabResult.code == errDossierNull) { 3094 retourEtape1(tabResult.msg); 3095 } 3096 else if (tabResult.errTechnq) { 3097 afficheMsgErrTechnq(tabResult.msg, tabResult.titre, tabResult.ident, true); 3098 } 3099 else { 3100 afficheEffaceRecapPrix(tabResult); 3101 } 3102 effaceMsgAttenteParDessus("recapPrix"); 3103 } 3104 }); 3105 } 3106 })(jQuery); 3107} 3108 3109function metAJourRecapPrixForChambre(){ 3110 (function($){ 3111 $.ajax({ 3112 type: "POST", 3113 url: urlAJAX, 3114 data: {type: "recupPrixForChambre"}, 3115 beforeSend: function(){ 3116 affMsgAttenteParDessusInDiv("div_resaRecap", "recapPrix", txtAttente); 3117 $('#div_confirmDispos span.confirmSaisie.ko').html('').hide(); 3118 }, 3119 success: function(result){ 3120 var tabResult= XMLToArray(result); 3121 //eval("var tabResult="+result); 3122 if (tabResult.code == errDossierNull) { 3123 retourEtape1(tabResult.msg); 3124 } 3125 else if (tabResult.errTechnq) { 3126 afficheMsgErrTechnq(tabResult.msg, tabResult.titre, tabResult.ident, true); 3127 } 3128 else if (tabResult.code === 'KO') { 3129 $('#div_recapInfosEtPrix').hide(); 3130 $('#div_confirmDispos').find('.ko').text(tabResult.msg).show(); 3131 } 3132 else { 3133 afficheEffaceRecapPrix(tabResult); 3134 } 3135 effaceMsgAttenteParDessus("recapPrix"); 3136 } 3137 }); 3138 })(jQuery); 3139} 3140 3141/** 3142 * On vérifie la validité du mot magique sélectionné,<br /> 3143 * on fait une requête AJAX qui va vérifier si le mot magique sélectionné est autorisé pour cette réservation 3144 */ 3145function verifMotMagique(nepaseffacer,reload){ 3146 (function($){ 3147 var motMagique = $("#inpt_motMagique").val(); 3148 var dateDeb = $("#inpt_resaDateDeb").val(); 3149 var dateFin = $("#inpt_resaDateFin").val(); 3150 3151 $.ajax({ 3152 type: "POST", 3153 url: urlAJAX, 3154 data: {type: "verifMotMagique", motMagique: motMagique, dateDeb: dateDeb, dateFin: dateFin}, 3155 async: false, 3156 beforeSend: function(){ 3157 affMsgAttenteParDessusInDiv("div_resaRecap", "recapPrix", txtAttente); 3158 }, 3159 success: function(result){ 3160 var tabResult= XMLToArray(result); 3161 //eval("var tabResult="+result); 3162 if (tabResult.code == errDossierNull) { 3163 retourEtape1(tabResult.msg); 3164 } 3165 else if (tabResult.errTechnq) { 3166 afficheMsgErrTechnq(tabResult.msg, tabResult.titre, tabResult.ident, true); 3167 } 3168 else { 3169 if (tabResult.code == "OK") { 3170 $("#div_motMagique").find(".ok").show(); 3171 $("#div_motMagique").find(".ko").hide(); 3172 if (gestprod) { 3173 afficheEffaceRecapPrix_Prod(tabResult); 3174 } else { 3175 afficheEffaceRecapPrix(tabResult); 3176 } 3177 } 3178 else { 3179 $("#div_motMagique").find(".ko").show(); 3180 $("#div_motMagique").find(".ok").hide(); 3181 } 3182 } 3183 effaceMsgAttenteParDessus("recapPrix");
3184 if(reload){ 3185 document.location.reload(); 3186 } 3187 } 3188 }); 3189 if(!nepaseffacer){ 3190 $("#inpt_motMagique").val(""); 3191 } 3192 })(jQuery); 3193} 3194 3195/** 3196 * Met à jour l'encart de récapitulatif des prix de la réservation grâce à un tableau contenant les prix<br /> 3197 * Ce tableau est obtenu après une requête AJAX qui a lance une REQ4 sur TrscWeb 3198 * @param tabResult: Le tableau contenant les différents prix 3199 */ 3200function afficheEffaceRecapPrix(tabResult){ 3201 (function($){ 3202 var effacerPrix = tabResult.effacerPrix || false; 3203 if(effacerPrix == '1'){ 3204 $('#div_recapPrix').hide(); 3205 return; 3206 } 3207 3208// var prixADefinir = tabResult.prixADefinir || false; 3209// if (prixADefinir=='1') { 3210// // TODO : afficher modale permettant de saisir le prix de location 3211// var htmlModal = tabResult.htmlModalSaisiePrixLocationProp; 3212// $('#div_saisiPrixLocationProp').dialog('destroy'); 3213// $('#div_saisiPrixLocationProp').remove(); 3214// $(htmlModal).dialog({ 3215// title: 'Définir prix location', 3216// closeOnEscape: false, 3217// modal: true, 3218// buttons: 3219// [{ 3220// text: 'Valider', 3221// click: function(){ 3222// var prixLocationProp = $('#inpt_saisirPrixLocationProp').val(); 3223// var regexPrix = new RegExp('^[0-9]+\.?[0-9]{0,2}$'); 3224// if (!regexPrix.test(prixLocationProp)) { 3225// $('#div_saisiPrixLocationProp .div_msgErrSaisiePrix').fadeIn().delay(3000).fadeOut(); 3226// } else { 3227// enregistrePrixLocationProp(prixLocationProp); 3228// $(this).dialog('close'); 3229// } 3230// } 3231// } 3232// ] 3233// }); 3234// } 3235 3236 var numOpt; 3237 if (tabResult.acompteSansAssurance) { 3238 tabResult.acompte = tabResult.acompteSansAssurance; 3239 $(".tr_prixAssurAnnul").hide(); 3240 $(".sp_recapAvecAssurAnnul").hide(); 3241 $(".sp_recapSansAssurAnnul").show(); 3242 } 3243 else { 3244 $(".tr_prixAssurAnnul").show(); 3245 } 3246 if (tabResult.motsMagiques == "Oui") { 3247 $("#div_uneEtape_motMagique").show(); 3248 } 3249 if (tabResult.promo && tabResult.promo.length > 0) { 3250 $("#tr_prixPromotion").show(); 3251 } else { 3252 $("#tr_prixPromotion").hide(); 3253 } 3254 if (tabResult.htmlInfoBullePromo && tabResult.htmlInfoBullePromo.length>0) { 3255 $('#sp_infoBulleAidePromos').html(tabResult.htmlInfoBullePromo); 3256 setEventForQtip(); 3257 $('.i_helperInfoBulle[data-qhelp="sp_infoBulleAidePromos"]').show(); 3258 } else { 3259 $('#sp_infoBulleAidePromos').html(''); 3260 $('.i_helperInfoBulle[data-qhelp="sp_infoBulleAidePromos"]').hide(); 3261 } 3262 if (tabResult.tauxRemise && tabResult.tauxRemise.length > 0) 3263 $("#tr_prixRemise").show(); 3264 else 3265 $("#tr_prixRemise").hide(); 3266 if (tabResult.options && tabResult.options.length > 0) { 3267 $("#tr_prixOptions").show(); 3268 } 3269// else { 3270// $("#tr_prixOptions").hide(); 3271// } 3272 3273 // fiche 237708 : on a deux id identiques pour les résas prop, du coup on ne modifie qu'un prix et pas l'autre 3274// $("#td_prixTotal").html(tabResult.total); 3275 $("td.td_prixTotal").html(tabResult.total); 3276 if (tabResult.prixModifie && $('#input_prixModifieBureau')){ 3277 $('#input_prixModifieBureau').val(tabResult.prixModifie); 3278 } 3279 if($('td.td_solde').length > 0 && tabResult.solde){ 3280 $('td.td_solde').html(tabResult.solde); 3281 } 3282 3283 if (tabResult.location) { 3284 $("#td_prixLocation").html(tabResult.location); 3285 $("#td_prixLocationFraisDossierInclus").html(tabResult.locationFraisDossierInclus); 3286 } else { 3287 $(".td_prixChambre").parent().hide(); 3288 var prixChambres = tabResult.prixChambres; 3289 if (prixChambres) { 3290 for (var i = 0; i < prixChambres.length; i++) { 3291 var num = prixChambres[i].numChambre; 3292 var prixAdu = prixChambres[i].prixAdu; 3293 //console.log("prixChambres "+i+" = "+num+" -> "+prixAdu) 3294 $(".td_prixChambre[numchambre=" + num + "]").html(prixAdu); 3295 $(".td_prixChambre[numchambre=" + num + "]").parent().show(); 3296 } 3297 } 3298 } 3299 3300 $(".tr_prixOptionsChambre").hide(); 3301 $(".tr_prixOptionChambre").hide(); 3302 $(".tr_prixOptionsChambre").removeClass('show'); 3303 var prixOptions = tabResult.prixOptions; 3304 if(prixOptions){ 3305 for (var i = 0; i<prixOptions.length; i++) { 3306 numChambre = prixOptions[i].numChambre; 3307 numOption = prixOptions[i].numOption; 3308 prixAdu = prixOptions[i].prixAdu; 3309 prixEnf = prixOptions[i].prixEnf; 3310 dureeSelect = prixOptions[i].dureeSelect; 3311 if (prixEnf && prixEnf != '0 €'){ 3312 if(prixAdu != '0 €'){ 3313 prixAdu = prixAdu+"<br/>"+prixEnf; 3314 }else{ 3315 prixAdu = prixEnf; 3316 } 3317 } 3318 if(prixAdu == '0 €'){ 3319 $(".td_prixOptionChambre[numchambre="+numChambre+"][numoption="+numOption+"]").html(''); 3320 $(".td_prixOptionChambre[numchambre="+numChambre+"][numoption="+numOption+"]").parent().hide(); 3321 // évite de masquer toutes les options su au moins une est active 3322 if(!$(".td_prixOptionChambre[numchambre="+numChambre+"][numoption="+numOption+"]").parents(".tr_prixOptionsChambre").hasClass('show')){ 3323 $(".td_prixOptionChambre[numchambre="+numChambre+"][numoption="+numOption+"]").parents(".tr_prixOptionsChambre").hide(); 3324 $(".td_prixOptionChambre[numchambre="+numChambre+"][numoption="+numOption+"]").parents(".tr_prixOptionsChambre").addClass('hide'); 3325 } 3326 }else{ 3327 $(".td_prixOptionChambre[numchambre="+numChambre+"][numoption="+numOption+"]").html(prixAdu); 3328 $(".td_prixOptionChambre[numchambre="+numChambre+"][numoption="+numOption+"]").parent().show(); 3329 $(".td_prixOptionChambre[numchambre="+numChambre+"][numoption="+numOption+"]").parents(".tr_prixOptionsChambre").show(); 3330 $(".td_prixOptionChambre[numchambre="+numChambre+"][numoption="+numOption+"]").parents(".tr_prixOptionsChambre").addClass('show'); 3331 } 3332 if (parseInt(dureeSelect)>0) { 3333 $(".td_nomOptionChambre[numchambre="+numChambre+"][numoption="+numOption+"] .sp_lblDureeOptionChambre").show(); 3334 $(".td_nomOptionChambre[numchambre="+numChambre+"][numoption="+numOption+"] .sp_dureeOptionChambre").text(dureeSelect); 3335 } else { 3336 $(".td_nomOptionChambre[numchambre="+numChambre+"][numoption="+numOption+"] .sp_lblDureeOptionChambre").hide(); 3337 } 3338 } 3339 } 3340 $("#tr_prixOptions").hide(); 3341 $(".tr_recap_option").hide(); 3342 if (tabResult.tabTarifs) { 3343 $("#tr_prixOptions").show(); 3344 var tabTarifs = tabResult.tabTarifs; 3345 3346 3347 for (i = 0; i<tabTarifs.length; i++) { 3348 numOpt = tabTarifs[i].noTarif; 3349 prixAdu = tabTarifs[i].prix; 3350 3351 $("#td_recap_prixOption_"+numOpt).html(prixAdu); 3352 $("#tr_recap_option_"+numOpt).show(); 3353 } 3354 } 3355 3356 3357 $(".td_prixAcompte").html(tabResult.acompte); 3358 if(tabResult.taux_commission){ 3359 $('.td_detailPrix.td_tauxCommission').html(tabResult.taux_commission); 3360 $('#tr_tauxCommission').show(); 3361 } else { 3362 $('#tr_tauxCommission').hide(); 3363 } 3364 if(tabResult.loyer_prop && (tabResult.comm_prop != tabResult.loyer_prop)){ 3365 $('.td_detailPrix.td_loyerProp').html(tabResult.loyer_prop); 3366 $('#tr_loyerProp').show(); 3367 } else { 3368 $('#tr_loyerProp').hide(); 3369 } 3370 if(tabResult.comm_prop){ 3371 $('.td_detailPrix.td_commProp').html(tabResult.comm_prop); 3372 $('#tr_commProp').show(); 3373 } else { 3374 $('#tr_commProp').hide(); 3375 } 3376 if (tabResult.assurance) { 3377 $(".td_prixAssurAnnul").html(tabResult.assurance); 3378 if (!tabResult.acompteSansAssurance) { 3379 $(".tr_prixAssurAnnul").show(); 3380 } 3381 } else { 3382 $(".tr_prixAssurAnnul").hide(); 3383 } 3384 3385 if($('#tr_prixRetrocession').length>0 && tabResult.montantRetro){
3386 $('#td_prixRetrocession').html(tabResult.montantRetro); 3387 } 3388 3389 $("#sp_code_formule_assurance").html(tabResult.code_formule_assurance); 3390 if (tabResult.fraisDossier) { 3391 $("#td_prixFraisDossier").html(tabResult.fraisDossier); 3392 $("#tr_prixFraisDossier:not('.masqueFraisDossier')").show(); 3393 } else { 3394 $("#tr_prixFraisDossier").hide(); 3395 } 3396 if (tabResult.charges) { 3397 $("#td_montantCharges").html(tabResult.charges); 3398 $("#tr_montantCharges").show(); 3399 } else { 3400 $("#tr_montantCharges").hide(); 3401 } 3402 $("#td_prixPromotion").html(tabResult.promo); 3403 3404 $("#td_prixRemise").html(tabResult.tauxRemise); 3405 3406 $('#td_dateEcheance .sp_dateEcheance').html(tabResult.dateLimite); 3407 if (tabResult.dateLimite) { 3408 $('#tr_dateEcheance').show(); 3409 } else { 3410 $('#tr_dateEcheance').hide(); 3411 } 3412 3413 if ($('#div_uneEtape_compoFamilleChambre').length === 0 || $('.div_uneChambre:visible').find('.inpt_chambre:checked').length > 0) { 3414 $("#table_recapPrix").show(); 3415 $("#div_recapPrix").show(); 3416 } 3417 3418 // Si acompte = total c'est une résa tardive, on masque le tr acompte 3419 if (tabResult.total == tabResult.acompte) 3420 $(".tr_prixAcompte").hide(); 3421 else 3422 $(".tr_prixAcompte").show(); 3423 3424 // Mise à jour du prix de l'assurance dans les parenthèses 3425 var montantAssurance = tabResult.assurance; 3426 3427 $("#sp_montantAssur").html(montantAssurance); 3428 3429 majAssurance(tabResult); 3430 3431 // pour les résas en mode pv avec possibilité de modif des frais de dossier : 3432 if($('#div_uneEtape_fraisDossier').is(':hidden')){ 3433 $('#div_uneEtape_fraisDossier').show(); 3434 } 3435 3436 $("#div_recapInfosEtPrix").show(); 3437 3438 // Pour l'affichage du recapPrix, on ajoute des classes pair/impair aux tr visibles 3439 i = 0; 3440 $("#table_recapPrix tr:visible").each(function(){ 3441 if (i%2 == 0) { 3442 $(this).addClass('pair'); 3443 $(this).removeClass('impair'); 3444 } 3445 else { 3446 $(this).addClass('impair'); 3447 $(this).removeClass('pair'); 3448 } 3449 i++; 3450 }); 3451 3452 if ($('#div_uneEtape_optionsSuppl .option.weRelax').length>0) { 3453 $('#div_uneEtape_optionsSuppl .option.weRelax').remove(); 3454 } 3455 if ($('#tr_recap_option_weRelax').length>0) { 3456 $('#tr_recap_option_weRelax').remove(); 3457 } 3458 if (tabResult.htmlOptionWeRelax) { 3459 if($('#div_uneEtape_optionsSuppl').length>0){ 3460 $('#div_uneEtape_optionsSuppl table tbody').append(tabResult.htmlOptionWeRelax); 3461 } 3462 else { 3463 $('#div_uneEtape_compoFamilleGite').after(tabResult.htmlOptionWeRelaxAvecDivSuppl); 3464 } 3465 $('.select_optionWeRelax').change(function(){ 3466 affectOptions(); 3467 }); 3468 if (tabResult.htmlRecapOptionWeRelax) { 3469 $('#tr_prixLocation').after(tabResult.htmlRecapOptionWeRelax); 3470 } 3471 } 3472 if(tabResult.prixTotalDiffImportante) { 3473 $('#div_msgPrixTotalDiffImportante').show(); 3474 } else { 3475 $('#div_msgPrixTotalDiffImportante').hide(); 3476 } 3477 if(tabResult.montant_taxe_sejour) { 3478 $("#td_montantTaxeSejour").html(tabResult.montant_taxe_sejour); 3479 $('#tr_montantTaxeSejour').show(); 3480 } else { 3481 $('#tr_montantTaxeSejour').hide(); 3482 } 3483 if(tabResult.solde && $('#td_solde').length>0) { 3484 $("#td_solde").html(tabResult.solde); 3485 $('#td_solde').show(); 3486 } 3487 })(jQuery); 3488} 3489 3490function affectChambre(numChambre, annulChoix){ 3491 (function($){ 3492 // fiche 231382 : je rajoute la compo de la famille pour pouvoir stocker au cas où on change de mode de résa et qu'on recharge le page 3493 var params ={ 3494 type: "affectChambre", 3495 numChambre: numChambre, 3496 annulChoix: annulChoix 3497 } 3498 if (numChambre) { 3499 params.nbAdultes = $("#select_compoFamilleAdulte_"+numChambre).val(); 3500 params.nbEnfants = $("#select_compoFamilleEnfant_"+numChambre).val(); 3501 params.nbBebes = $("#select_compoFamilleBebe_"+numChambre).val(); 3502 } 3503 $.ajax({ 3504 type: "POST", 3505 url: urlAJAX, 3506 async:false, 3507 data: params, 3508 beforeSend: function(){ 3509 3510 }, 3511 success: function(result){ 3512 var tabResult= XMLToArray(result); 3513 //eval("var tabResult="+result); 3514 if (tabResult.modeResa) { 3515 manageChangementTypeResa(tabResult,true); 3516 } 3517 else if (tabResult.prixChambres) { 3518 afficheEffaceRecapPrix(tabResult); 3519 } 3520 else if ($(".inpt_chambre:checked").length == 0){ 3521 $("#div_recapPrix").hide(); 3522 } 3523 3524 } 3525 }); 3526 })(jQuery); 3527} 3528 3529/** 3530 * On affecte le nombre de personnes (adultes, enfants et bébés) au Dossier de résa<br /> 3531 * Si l'hébergement comporte des options indiv/obligatoires, on les ajoute au Dossier également 3532 * @param type Le type de personnes que l'on affecte, si ce sont des bébés on ne fait pas affectOptions<br /> 3533 * Car c'est inutile et on évite un appel AJAX supplémentaire 3534 * @param numChambre Le numéro de la chambre à laquelle on affecte les personnes dans le cas d'une résa chambre d'hotes 3535 */ 3536function affectFamille(type, numChambre){ 3537 (function($){ 3538 var nbAdultes, nbEnfants, nbBebes; 3539 if (numChambre) { 3540 nbAdultes = $("#select_compoFamilleAdulte_" + numChambre).val() || 0; 3541 nbEnfants = $("#select_compoFamilleEnfant_" + numChambre).val() || 0; 3542 nbBebes = $("#select_compoFamilleBebe_" + numChambre).val() || 0; 3543 } 3544 else { 3545 // Récupération du nombre d'adultes, enfants et bébés 3546 nbAdultes = $("#select_compoFamilleAdulte").val() || 0; 3547 nbEnfants = $("#select_compoFamilleEnfant").val() || 0; 3548 nbBebes = $("#select_compoFamilleBebe").val() || 0; 3549 var majOptions = false;
3550 // suite fiche 231436 sinon les options obligatoires n etaient pas mise a jour si forfaitaires 3551 //if ($(".option.indiv.obligatoire:not(.animal)").length > 0) 3552 if ($(".option.obligatoire:not(.animal)").length > 0) 3553 majOptions = true; 3554 if (type == "bebes") 3555 majOptions = false; 3556 } 3557 3558 $.ajax({ 3559 type: "POST", 3560 url: urlAJAX, 3561 data: {type: "affectFamille", nbAdultes: nbAdultes, nbEnfants: nbEnfants, nbBebes: nbBebes, numChambre: numChambre}, 3562 beforeSend: function(){ 3563 var divCompoFamille = $("#select_compoFamilleAdulte").parents('.div_uneEtape'); 3564 if (numChambre) { 3565 divCompoFamille = $("#select_compoFamilleAdulte_"+numChambre).parents('.div_uneEtape'); 3566 } 3567 divCompoFamille.addClass('div_uneEtapeGrisee'); 3568 $('select, input',divCompoFamille).attr("disabled", true); 3569 affMsgAttenteParDessusInDiv("div_resaRecap", "recapPrix", txtAttente); 3570 $('#div_confirmDispos span.confirmSaisie.ko').html('').hide(); 3571 afficheLoaderGlobal_site(); 3572 }, 3573 success: function(result){ 3574 var tabResult = XMLToArray(result); 3575 //eval("var tabResult="+result); 3576 if (tabResult.code == errDossierNull) { 3577 retourEtape1(tabResult.msg); 3578 } 3579 else if (tabResult.errTechnq) { 3580 afficheMsgErrTechnq(tabResult.msg, tabResult.titre, tabResult.ident, true); 3581 } 3582 else { 3583 if (tabResult.code === 'KO') { 3584 if ($("#div_btnModifPrix").length == 0) { 3585 $('#div_recapInfosEtPrix').hide(); 3586 } 3587// $('#div_confirmDispos').find('.ko').text(tabResult.msg).show(); 3588 invalideSaisieDates(tabResult.msg); 3589 } 3590 else { 3591 if(numChambre){ // 263669 : test pour cohérence des adultes et enfants dans le dossier par rapport à l'affichage 3592 3593 } 3594 else{ 3595 try{ 3596 var compoFamille = tabResult.compoFamillePourControle; 3597 var adultesPhp = compoFamille.adultes || 0; 3598 var adultesHTML = $("#select_compoFamilleAdulte").val() || 0; 3599 3600 var enfantsPhp = compoFamille.enfants || 0; 3601 var enfantsHTML =$("#select_compoFamilleEnfant").val() || 0; 3602 if(adultesPhp != adultesHTML || enfantsPhp != enfantsHTML){ 3603 debugLogJS('foncResa.php affectFamille on a pas la meme compo famille entre html ('+adultesHTML+','+enfantsHTML+') et php ('+adultesPhp+','+enfantsPhp+')'); 3604 } 3605 } 3606 catch(e){ 3607 // on a pas réussi à faire le test 3608 } 3609 } 3610 if (tabResult.total) 3611 afficheEffaceRecapPrix(tabResult); 3612 $("#div_recapInfosEtPrix").show(); 3613 if (majOptions){ 3614 affectOptions(); 3615 } 3616 $("#div_uneEtape_compoFamilleGite").find(".p_recapCompoFamilleGite").html(tabResult.msg); 3617 $("#div_recapOptionsObligatoires").html(tabResult.options); 3618 $("#div_recapOptionsObligatoires").find("tr:last").addClass("last"); 3619 } 3620 $(".div_uneEtapeGrisee *").attr("disabled", false); 3621 $('.div_uneEtapeGrisee').removeClass('div_uneEtapeGrisee'); 3622 3623 $("#div_recapInfos").html(tabResult.recapInfos); 3624 3625 if (tabResult.msgInfoModeResa){ 3626 $('.infosModeResa').html(tabResult.msgInfoModeResa); 3627 $('.infosModeResa').show(); 3628 } else { 3629 $('.infosModeResa').html(''); 3630 $('.infosModeResa').hide(); 3631 } 3632 } 3633 effaceMsgAttenteParDessus("recapPrix"); 3634 rendChoixCanevasPossible(); 3635 // si on est en surcapacité (seulement possible en résa PV avec un pv qui autorise le dépassement de capacité) 3636 // on affiche un message commme quoi il faut l'accord du propriétaire 3637 var capaciteReel; 3638 try{ 3639 var suffixe = ""; 3640 var divParent = '.div_uneEtape'; 3641 if (numChambre){ 3642 divParent = '.div_uneChambre'; 3643 suffixe = "_"+numChambre; 3644 } 3645 capaciteReel = parseInt($("#select_compoFamilleAdulte"+suffixe).attr('data-capacite')); 3646 if((parseInt(nbAdultes) + parseInt(nbEnfants))> capaciteReel){ 3647 $("#select_compoFamilleAdulte"+suffixe).parents(divParent).find('.messageSurcapacite').show('fast'); 3648 } 3649 else{ 3650 $("#select_compoFamilleAdulte"+suffixe).parents(divParent).find('.messageSurcapacite').hide(); 3651 } 3652 } 3653 catch(e){ 3654 // on a pas réussi à récupérer data-capacite du gite. 3655 } 3656 if (tabResult.questionRecalculAuto) { 3657 questionRecalculAuto(); 3658 } 3659 }, 3660 complete: function(){ 3661 effaceLoaderGlobal_site(); 3662 } 3663 }); 3664 })(jQuery); 3665} 3666 3667function affectSelectionChambres(tabSelectionChambres){ 3668 (function($){ 3669 var tabData = {}; 3670 tabData.type = 'affectSelectionChambres'; 3671 tabData.tabSelection = tabSelectionChambres; 3672 tabData.avecDeuxLibelles = $("#a_btnReserver_packDivDatesTarifs").attr("data-avecDeuxLibelles"); 3673 if ($('#div_fiche_bloc_tarif_chmb_packDivDatesTarifs').length>0) { 3674 var tabAttributs = $('#div_fiche_bloc_tarif_chmb_packDivDatesTarifs').attr('data-attributsDiv'); 3675 var listeAttr = eval('('+tabAttributs+')'); 3676 tabData.listeAttrDivChambres = listeAttr; 3677 } 3678 tabData.estpresentsurfiche = true; 3679 $.ajax({ 3680 type: "POST", 3681 url: urlAJAX, 3682 data: tabData, 3683 beforeSend: function(){ 3684 3685 }, 3686 success: function(result){ 3687 var tabRetour = XMLToArray(result); 3688 majDivTarifAPartirDe(tabRetour); 3689 majDivChambres_packDivDatesTarifs(tabRetour, false); 3690 } 3691 }); 3692 })(jQuery); 3693} 3694 3695/** 3696 * NE PLUS UTILISER!!!! VOIR affecteAnneesEnfantsAvecCoherence 3697 */ 3698function affectAgeEnfants(numChambre){ 3699 3700 3701 3702 3703 (function($){ 3704 var suffixe = ""; 3705 if (numChambre) 3706 suffixe = "_"+numChambre; 3707 var i = 0; 3708 var tabAgeEnfants = new Array(); 3709 $(".select_compoFamilleAgeEnfants"+suffixe+":visible").each(function(){ 3710 tabAgeEnfants[i] = $(this).val(); 3711 i++; 3712 }); 3713 3714 $(".select_compoFamilleAgeBebe"+suffixe+":visible").each(function(){ 3715 tabAgeEnfants[i] = $(this).val(); 3716 i++; 3717 }); 3718// console.table(tabAgeEnfants); 3719 $.ajax({ 3720 type: "POST", 3721 url: urlAJAX, 3722 data: {type: "affectAgeEnfants", ageEnfants: tabAgeEnfants, numChambre: numChambre}, 3723 beforeSend: function(){ 3724 3725 }, 3726 success: function(result){ 3727 eval("var tabResult="+result); 3728 if (tabResult.code == errDossierNull) { 3729 retourEtape1(tabResult.msg); 3730 } 3731 else if (tabResult.errTechnq) { 3732 afficheMsgErrTechnq(tabResult.msg, tabResult.titre, tabResult.ident, true); 3733 } 3734 } 3735 }); 3736 })(jQuery); 3737} 3738 3739/** 3740 * Affectation du nombre d'animaux au dossier ainsi que les options animales s'il y en a 3741 */ 3742function affectAnimaux(numeroChambre){ 3743 (function($){ 3744 if(!numeroChambre){
3745 numeroChambre = ""; 3746 } 3747 var nbChats = $("#select_compoAnimauxChat"+numeroChambre).val(); 3748 var nbChiens = $("#select_compoAnimauxChien"+numeroChambre).val(); 3749 var nbAnimaux = nbChats + nbChiens; 3750 var majOptions = false; 3751 if ($("tr.animal").length > 0){ 3752 majOptions = true; 3753 } 3754 3755 $.ajax({ 3756 type: "POST", 3757 url: urlAJAX, 3758 data: {type: "affectAnimaux", nbChats: nbChats, nbChiens: nbChiens , numeroChambre : numeroChambre}, 3759 beforeSend: function(){ 3760 affMsgAttenteParDessusInDiv("div_resaRecap", "recapPrix", txtAttente); 3761 }, 3762 success: function(result){ 3763 var tabResult = XMLToArray(result); 3764 //eval("var tabResult="+result); 3765 if (tabResult.code == errDossierNull) { 3766 retourEtape1(tabResult.msg); 3767 } 3768 else if (tabResult.errTechnq) { 3769 afficheMsgErrTechnq(tabResult.msg, tabResult.titre, tabResult.ident, true); 3770 } 3771 else { 3772 if (tabResult.code == "KO") { 3773 $("#div_recapInfosEtPrix").hide(); 3774 } 3775 else { 3776 $("#div_recapInfosEtPrix").show(); 3777 if (majOptions){ 3778 affectOptions(); 3779 } 3780 //if(numeroChambre != ""){ 3781 if($("#div_uneEtapeAnimaux")){ 3782 $("#div_uneEtapeAnimaux").find(".inpt_validEtape").val("Oui"); 3783 $("#div_uneEtapeAnimaux").find(".p_recapAnimaux").html(tabResult.msg); 3784 $("#div_recapOptionsAnimaux").html(tabResult.options); 3785 if (nbAnimaux>0) { 3786 $("#div_recapOptionsAnimaux").show(); 3787 } else { 3788 $("#div_recapOptionsAnimaux").hide(); 3789 } 3790 $("#div_recapOptionsAnimaux > table > tbody > tr:last").addClass("last"); 3791 } 3792 if($("#div_uneEtapeAnimaux"+numeroChambre)){ 3793 $("#div_uneEtapeAnimaux"+numeroChambre).find(".inpt_validEtape").val("Oui"); 3794 $("#div_uneEtapeAnimaux"+numeroChambre).find(".p_recapAnimaux").html(tabResult.msg); 3795 } 3796 //} 3797 } 3798 $("#div_recapInfos").html(tabResult.recapInfos); 3799 } 3800 3801 effaceMsgAttenteParDessus("recapPrix"); 3802 } 3803 }); 3804 })(jQuery); 3805} 3806 3807/** 3808 * Ajout de l'assurance au dossier en fonction du radio coché 3809 */ 3810function affectAssurance(objParams){ 3811 var params = objParams || {}; 3812 params.type = "affectAssurance"; 3813 (function($){ 3814 var choixAssurance = $("input:radio[name=assur]:checked").val(); 3815 // gestion de l'assurance classique : 3816 if(typeof(choixAssurance) != 'undefined'){ 3817 params.choixAssur = choixAssurance; 3818 } 3819 $.ajax({ 3820 type: "POST", 3821 url: urlAJAX, 3822 data: params, 3823 beforeSend: function(){ 3824 afficheLoaderGlobal_site(); 3825 }, 3826 success: function(result){ 3827 var tabResult = XMLToArray(result); 3828 //eval("var tabResult="+result); 3829 if (tabResult.code == errDossierNull) { 3830 retourEtape1(tabResult.msg); 3831 } 3832 else if (tabResult.errTechnq) { 3833 afficheMsgErrTechnq(tabResult.msg, tabResult.titre, tabResult.ident, true); 3834 } 3835 else { 3836 if (tabResult.code == "OK") { 3837 if (tabResult.recapPrix) { 3838 $("#div_recapPrix").html(tabResult.recapPrix); 3839 } 3840 else { 3841 afficheEffaceRecapPrix(tabResult); 3842 $("#div_recapInfosEtPrix").show(); 3843 3844 } 3845 if (estMultiResa()) { 3846 setAssuranceMultiResaDansSessionStorage(params); 3847 } 3848 } 3849 else if (tabResult.msg == "datesNull") { 3850 $("#div_recapInfosEtPrix").hide(); 3851 } 3852 $("#div_recapInfos").html(tabResult.recapInfos); 3853 } 3854 3855 }, 3856 complete: function(){ 3857 effaceLoaderGlobal_site(); 3858 } 3859 }); 3860 })(jQuery); 3861} 3862 3863/** 3864 * On passe en revue les différentes options affichées et cochées et on créé une liste,<br /> 3865 * on utilise cette liste pour mettre à jour la liste des options sélectionnées dans le Dossier 3866 */ 3867function affectOptions(){ 3868 (function($){ 3869 var tabOptions = new Array(); 3870 var i = 0; 3871 $("#div_uneEtape_optionsSuppl .option, #div_infosOptionsAnimaux .option, #div_infosOptionsObligatoires .option, #div_recapOptionsObligatoires .option").each(function(){ 3872 if ($(this).find("select:not(.select_dureeForOption)").val() > 0 || $(this).is(".obligatoire")) { 3873 3874 var numOption; 3875 var nbAdultes =0; 3876 var nbEnfants = 0; 3877 if ($(this).is(".animal")) { 3878 numOption = $(this).attr("data-num"); 3879 nbAdultes = $(this).find("select.select_optionAnimaux").val() || $(this).find("input.inpt_optionAnimaux").val(); 3880 // Dans le cas ou on sélectionne des animaux puis on coche 'Non' pour les animaux, il faut forcer 0 pr les options animales 3881 var nbAnimaux = (parseInt($("#select_compoAnimauxChat").val()) + parseInt($("#select_compoAnimauxChien").val())); 3882 if (nbAnimaux==0) { 3883 nbAdultes = 0; 3884 } 3885 var duree = ''; 3886 3887 // 328446 : en modification, on a deux champs qui correspondent à la durée mais un seul qui passe dans le sélecteur, on check donc si le premier est bien visible 3888 if ($(this).find('select.select_dureeForOption').length>0 && $(this).is(':visible')) { 3889 duree = $(this).find('select.select_dureeForOption').val(); 3890 } else if($('tr[data-num="' + numOption + '"]:visible').length > 0) { 3891 duree = $('tr[data-num="' + numOption + '"]:visible').find('select.select_dureeForOption').val(); 3892 } 3893 if (nbAdultes>0) { 3894 tabOptions[i] = new Array(numOption, nbAdultes, nbEnfants, duree); 3895 } 3896 } 3897 else if ($(this).is(":not(.animal):visible")) { 3898 numOption = $(this).attr("data-num"); 3899 if ($(this).is(".adulte")) { 3900 nbAdultes = $(this).find("select.select_optionAdultes").val() || $(this).find("input.inpt_optionAdultes").val(); 3901 if ($(this).next().find("input").attr("checked") == "checked") { 3902 nbEnfants = $(this).next().find("select.select_optionEnfants").val() || $(this).next().find("input.inpt_optionEnfants").val(); 3903 } 3904 } 3905 else if ($(this).is(".enfant")) { 3906 nbEnfants = $(this).find("select.select_optionEnfants").val() || $(this).find("input.inpt_optionEnfants").val(); 3907 if ($(this).prev().find("input").attr("checked") == "checked" || $(this).prev().find("select").val() > 0) { 3908 i--; 3909 nbAdultes = $(this).prev().find("select.select_optionAdultes").val() || $(this).prev().find("input.inpt_optionAdultes").val(); 3910 } else { 3911 nbAdultes = 0; 3912 } 3913 } 3914 else { 3915 nbAdultes = $(this).find("select.select_optionAdultes").val() || $(this).find("select.select_optionGroupe").val(); 3916 if (nbAdultes == undefined) { 3917 nbAdultes = $(this).find("input.inpt_optionAdultes").val(); 3918 } 3919 } 3920 // 2680014 3921 if (!nbAdultes && $(this).is(".obligatoire")) { 3922 nbAdultes = 1; 3923 } 3924 var duree = ''; 3925 if ($(this).find('select.select_dureeForOption').length>0) { 3926 duree = $(this).find('select.select_dureeForOption').val(); 3927 } 3928 tabOptions[i] = new Array(numOption, nbAdultes, nbEnfants, duree); 3929 } 3930 i++; 3931 } 3932 }); 3933 //console.trace('affectOptions ajax'); 3934 $.ajax({ 3935 type: "POST", 3936 url: urlAJAX, 3937 data: {type: "affectOptions", tabOptions: tabOptions}, 3938 beforeSend: function(){ 3939 affMsgAttenteParDessusInDiv("div_resaRecap", "recapPrix", txtAttente); 3940 }, 3941 success: function(result){ 3942 var tabResult = XMLToArray(result); 3943 //eval("var tabResult="+result); 3944 if (tabResult.code == errDossierNull) { 3945 retourEtape1(tabResult.msg); 3946 } 3947 else if (tabResult.errTechnq) { 3948 afficheMsgErrTechnq(tabResult.msg, tabResult.titre, tabResult.ident, true); 3949 } 3950 else { 3951 if (tabResult.code == "OK") { 3952 afficheEffaceRecapPrix(tabResult); 3953 if (tabResult.tabTarifs) 3954 afficheEffaceTarifsOptions(tabResult.tabTarifs); 3955 } 3956 } 3957 3958 effaceMsgAttenteParDessus("recapPrix"); 3959 } 3960 }); 3961 })(jQuery); 3962} 3963 3964function affectOptionsChambre(){ 3965 // Récupérer toutes les options cochées et faire un tableau 3966 (function($){ 3967 var tabOptions = new Array(); 3968 var i = 0; 3969 $(".optionChambre").each(function(){ 3970 // si on a un select avec une reduc enfant, il faut le prendre en compte; find() prend que le 1er select 3971 if ($(this).find("select").val() > 0 || $(this).is(".obligatoire") || $(this).find("select").length>1) { 3972 var numOption = $(this).attr("numOption"); 3973 var numChambre = $(this).attr("numChambre"); 3974 var nbAdultes = $(this).find(".select_optionChambre").val(); 3975 var nbEnfants = $(this).find(".select_optionChambre_enfants").val(); 3976 if(nbEnfants > 0){ 3977 nbAdultes = nbAdultes +'-'+nbEnfants; 3978 } 3979 var duree = ''; 3980 if ($(this).find(".select_dureeForOption").length>0) { 3981 duree = $(this).find(".select_dureeForOption").val(); 3982 } 3983 if(nbAdultes){ 3984 tabOptions[i] = new Array(numChambre, numOption, nbAdultes, duree); 3985 } 3986 i++; 3987 } 3988 }); 3989 3990 $.ajax({ 3991 type: "POST", 3992 url: urlAJAX, 3993 data: {type: "affectOptionsChambre", tabOptions: tabOptions}, 3994 beforeSend: function(){ 3995 3996 }, 3997 success: function(result){ 3998 var tabResult = XMLToArray(result); 3999 //eval("var tabResult="+result); 4000 if (tabResult.code == errDossierNull) { 4001 retourEtape1(tabResult.msg); 4002 } 4003 else if (tabResult.errTechnq) { 4004 afficheMsgErrTechnq(tabResult.msg, tabResult.titre, tabResult.ident, true); 4005 } 4006 else{ 4007 afficheEffaceRecapPrix(tabResult); 4008 } 4009 } 4010 }); 4011 })(jQuery); 4012} 4013 4014/** 4015 * Permet d'afficher le prix de chaque option avec les prix renvoyés par TrscWeb<br /> 4016 * On efface le prix des options qui ne sont pas dans le tableau 4017 * @param tabTarifs Le tableau des tarifs des options renvoyés par TrscWeb (REP4) 4018 */ 4019function afficheEffaceTarifsOptions(tabTarifs){ 4020 (function($){ 4021 $(".td_prixOption").html(""); 4022 $("tr.option").each(function(){ 4023 var numOption = $(this).attr("data-num"); 4024// numOption = numOption.substr(11); 4025 for (var i=0; i<tabTarifs.length; i++) { 4026 if (numOption == tabTarifs[i].noTarif) { 4027 $(this).find("td.td_prixOption").html(tabTarifs[i].prix+" \u20ac"); 4028 break; 4029 } 4030 } 4031 }); 4032 })(jQuery); 4033} 4034 4035/** 4036 * Vérification que toutes les étapes sont valides et qu'on peut passer à l'étape suivante 4037 * Pour l'instant utilisé uniquement pour étape1, à voir si on peut l'utiliser pour les autres étapes 4038 */ 4039function etapesValid(){ 4040 var retour = true; 4041 (function($){ 4042 var replaceOK = false;
4043 $("#p_msgErreurs").html(""); 4044 $("#div_msgErreurs").hide(); 4045 // Vérification de la sélection du nombre de personnes dans la résaGP 4046 $('#div_uneEtape_compoFamilleGite').find('.inpt_validEtape').val('Oui'); 4047 $('#div_uneEtape_compoFamilleChambre').find('.inpt_validEtape').val('Oui'); 4048 verifNbPax(); 4049 verifCompoFamilleGiteAdultes(); 4050 if ($('.divUneRubriqueCanevas.canevasObligatoire').length>0) { 4051 var verifCanevasObligatoires = verifQteCanevasOblig(); 4052 if(!verifCanevasObligatoires){ 4053 retour = false; 4054 } 4055 } 4056 // Verification de la sélection de l'heure de prise/depot de la voiture dans le cas d'un canevas avec produit VOIT OU dans le cas d'une résa voiture 4057 if (!verifChoixHeureVoiture()){ 4058 retour = false; 4059 // Yoann : On sort tout de suite de la fonction sinon on risque de mettre retour à true 4060 return; 4061 } 4062 if (!verifMontantNullResaBureau()){ 4063 retour = false; 4064 // Yoann 25/03/2016 (fiche254498) : On sort tout de suite de la fonction sinon on risque de mettre retour à true 4065 return; 4066 } 4067 if (!verifSelectionAnimaux()) { 4068 $("#div_msgErreursNbAnimaux").show(); 4069 document.location = "#div_msgErreursNbAnimaux"; 4070 retour = false; 4071 return; 4072 } 4073 if (!verifPaysAssuranceEtape1()) { 4074 retour = false; 4075 return; 4076 } 4077 retour = verifErreurAjaxEtape1(); 4078 $(".inpt_validEtape").each(function(){ 4079// var numEtape = $(this).parents(".div_uneEtape").find(".sp_numEtape").text(); 4080 if ($(this).val() == "Non" || $(this).val() == undefined) { 4081 var message = $(this).parents(".div_uneEtape").find(".sp_msgErreur").text(); 4082 message = "- "+message; 4083 if ($("#div_msgErreurs:visible").length == 0) { 4084 $("#p_msgErreurs").html(message); 4085 $("#div_msgErreurs").show(); 4086 } 4087 else { 4088 $("#p_msgErreurs").append("<br />"); 4089 $("#p_msgErreurs").append(message); 4090 } 4091 $(this).parents(".div_uneEtape").addClass('div_uneEtapeAValider'); 4092 if (!replaceOK) { 4093 document.location = "#div_msgErreurs"; 4094 replaceOK = true; 4095 } 4096 retour = false; 4097 } 4098 }); 4099 })(jQuery); 4100 4101 return retour; 4102} 4103 4104 4105function actionsForCompteGdf(){ 4106 (function ($) { 4107 //validation formulaire de connexion 4108 $('#itea_cnxCptGDFResa_valid').click(function(e) { 4109 e.preventDefault(); 4110 validFormConnexionCompteGDFResa(); 4111 }); 4112 4113 //je n ai pas de compte gdf 4114 $('#div_pasdecomptegdf').click(function(e) { 4115 $('#div_pasdecomptegdf').hide(); 4116 $('#div_connexioncomptegdf').addClass('hide'); 4117 $('#div_uneEtape_nouveauClient').show(); 4118 $('#div_mentionsLegalesCoords').show(); 4119 $('#div_boutonsResa').show(); 4120 $('#itea_cnxCptGDFResa_msgInfo').hide(); 4121// initEtape2(); // guillaume 17/10/2016 : j'enlève init etape2 car ça multiplie les évents sur le click de validation du formulaire 4122 }); 4123 $('#div_connexioncomptegdf .titre').click(function(e) { 4124 $('#div_pasdecomptegdf').show(); 4125 $('#div_connexioncomptegdf').removeClass('hide'); 4126 $('#div_uneEtape_nouveauClient').hide(); 4127 $('#div_mentionsLegalesCoords').hide(); 4128 $('#div_boutonsResa').hide(); 4129 }); 4130 $('#form_nouveauClient .remplaceCheckbox').next('input').change(function(e) { 4131 if($(this).is(':checked')){ 4132 $(this).prev('.remplaceCheckbox').addClass('active') 4133 }else{ 4134 $(this).prev('.remplaceCheckbox').removeClass('active') 4135 } 4136 }); 4137 4138 //connexion Facebook 4139 $('#div_btnConnexionFacebookFede').click(function(){ 4140 ouvrePopInAuthentificationCompteGdf($(this).attr('data-url-authentification-compte-gdf')); 4141 }); 4142 4143 //connexion Google 4144 $('#div_btnConnexionGoogleFede').click(function(){ 4145 ouvrePopInAuthentificationCompteGdf($(this).attr('data-url-authentification-compte-gdf')); 4146 }); 4147 4148 //mot de passe oublié 4149 initMdpOublieCptGDF(); 4150 4151 //popin avantage compte GDF 4152 initActionPopInAvantagesCompteGdf(); 4153 })(jQuery); 4154} 4155 4156function initActionPopInAvantagesCompteGdf(){ 4157 (function($) { 4158 $('#a_avantagesCompteGdf').click(function(e) { 4159 $.fancybox( 4160 $('#div_avantagesCompteGdf'), {
4161 maxWidth: 800, 4162 autoHeight:true, 4163 autoWidth:true, 4164 autoResize:true, 4165 autoSize: true, 4166 closeClick: false, 4167 openEffect: 'none', 4168 closeEffect: 'none', 4169 padding: 0, 4170 wrapCSS:'popin_avantagesCptGDF', 4171 fitToView :false 4172 }); 4173 }); 4174 })(jQuery); 4175} 4176 4177 4178function validFormConnexionCompteGDFResa(){ 4179 (function ($) { 4180 var nomDivMsgInfo = '#itea_cnxCptGDFResa_msgInfo'; 4181 var $msgInfo = $(nomDivMsgInfo); 4182 4183 $msgInfo.html('').hide(); 4184 4185 var data = $('#frmCnxCptGDFResa').serialize(); 4186 data += '&type=connexionCompteGdf'; 4187 $.ajax({ 4188 type: 'POST', 4189 url: urlAJAX, 4190 data: data, 4191 beforeSend: function(){ 4192 $msgInfo.html('').show(); 4193 attenteInDiv(nomDivMsgInfo); 4194 }, 4195 success: function (result) { 4196 var tabResult = XMLToArray(result); 4197 if(tabResult.code === 'KO') { 4198 $msgInfo.html(tabResult.msg).fadeIn(); 4199 return false; 4200 } 4201 var urlHref = location.search + "&" + getIdSessionInHtml(); 4202 location.href = urlHref; 4203 } 4204 }); 4205 })(jQuery); 4206} 4207 4208 4209/** 4210 * Fonction appelée au chargement de etape2.php 4211 */ 4212 4213function initEtape2(){ 4214 (function($){ 4215 $(document).ready(function(){ 4216 idSession = getIdSessionInHtml(); 4217 initGooglePlusResa(); 4218 if($('.clientNatABloquer').length > 0){ 4219 lockModifClientNat(); 4220 } 4221 if ($('.dateNaissanceParticipant').length > 0) { 4222 initDatePickerNaissanceParticipant(); 4223 } 4224 }); 4225 initBtnsFooter(); 4226 majNumEtapes(); 4227 if(estResaAvecCompteGdf()){ 4228 actionsForCompteGdf(); 4229 var mailClient = $('#inpt_mailClient').val(); 4230 $('#itea_cnxCptGDFResa_email').val(mailClient); 4231 $('#div_connexioncomptegdf .titre').click(); 4232 } 4233 var tabAValider = []; 4234 if (estResaBureauProp() || estResaAilleurs()){ 4235 // Les champs à valider pour la résa PROP et la résa bureau sont les même 4236 tabAValider = getTabChampAValider_bureau(); 4237 4238 setSuggestionMailCheck($('#inpt_mailClient')); 4239 }else{ 4240 tabAValider = getTabChampAValider(); 4241 } 4242 4243 $("#a_dejaClientValide").click(function(){ 4244 $("#div_dejaClientMsgErreur").hide(); 4245 var mail = $("#inpt_dejaClientMail").val(); 4246 var mdp = $("#inpt_dejaClientPassword").val(); 4247 $.ajax({ 4248 type: "POST", 4249 url: urlAJAX, 4250 data: {type: "verifDejaClient", mail: mail, mdp: mdp}, 4251 beforeSend: function(){ 4252 afficheLoaderGlobal_site(); 4253 }, 4254 success: function(result){ 4255 var tabResult = XMLToArray(result); 4256 //eval("var tabResult="+result); 4257 if (tabResult.code == errDossierNull) { 4258 retourEtape1(tabResult.msg); 4259 } 4260 else if (tabResult.errTechnq) { 4261 afficheMsgErrTechnq(tabResult.msg, tabResult.titre, tabResult.ident, true); 4262 } 4263 else { 4264 if (tabResult.code == "OK") { 4265 if (tabResult.effaceAcompte == "OK") { 4266 $(".tr_prixAcompte").hide(); 4267 } else { 4268 $(".tr_prixAcompte").show(); 4269 } 4270 $("#div_uneEtape_nouveauClient").hide("slow"); 4271 $("#div_uneEtape_dejaClient").html(tabResult.msg); 4272 $('#form_dejaClient').append("<input type='hidden' name='pasDeSaisie' value='1'/>"); 4273 $("#form_nouveauClient").validationEngine("hide"); 4274 $("input:hidden[name=inpt_dejaClient]").remove(); 4275 4276 if (tabResult.vdm || tabResult.saisieIncomplete) { 4277 $('#a_btnModifierInfosClient').click(); 4278 } 4279 } 4280 else { 4281 console.log('eho'); 4282 $("#div_dejaClientMsgErreurContent").html("<p>"+tabResult.msg+"</p>"); 4283 $("#div_dejaClientMsgErreur").show("slow"); 4284 } 4285 } 4286 }, 4287 complete: function(){ 4288 effaceLoaderGlobal_site(); 4289 } 4290 }); 4291 }); 4292 4293 $("#inpt_dejaClientPassword").keyup(function(event){ 4294 if (event.keyCode == 13) { 4295 $("#a_dejaClientValide").click(); 4296 } 4297 }); 4298 4299 $("#a_btnModifierInfosClient").live("click",function(){ 4300 // fiche 229223 : quand on rechargeait par ajax, ça plantait. Du coup on recharge la page, en masquant la div de connexion 4301 document.location.reload(); 4302 return; 4303 $.ajax({ 4304 type: "POST", 4305 url: urlAJAX, 4306 data: {type: "recupFormulaireSaisieClient"}, 4307 beforeSend: function(){ 4308 4309 }, 4310 success: function(result){ 4311 var tabResult = XMLToArray(result); 4312 //eval("var tabResult="+result); 4313 if (tabResult == errDossierNull) { 4314 retourEtape1(tabResult.msg); 4315 } 4316 else if (tabResult.errTechnq) { 4317 afficheMsgErrTechnq(tabResult.msg, tabResult.titre, tabResult.ident, true); 4318 } 4319 else { 4320 $("#form_dejaClient").html(tabResult.msg); 4321 } 4322 4323 } 4324 }); 4325 }); 4326 4327 $("#div_btnConfirmer > a:not(.a_btnAttenteConfirm), #div_btnConfirmer_2 > a:not(.a_btnAttenteConfirm)").unbind('click'); 4328 $("#div_btnConfirmer > a:not(.a_btnAttenteConfirm), #div_btnConfirmer_2 > a:not(.a_btnAttenteConfirm)").bind('click', function(){ 4329 $(this).hide(); 4330 $(".a_btnAttenteConfirm").show(); 4331 $("#div_msgErreursInfosClient").hide(); 4332 //var verifDateNaissance = true; 4333 if ($("#div_adresseClient:visible").length>0){ 4334 // on regarde si on a pas chargé le formulaire de déjà client 4335 // si c'est le cas il faut mettre en place le tableau de champs à valider 4336 // c'est à dire que le client s'est loggué avec son email/mot de passe, il était déjà client 4337 tabAValider = []; 4338 } 4339 4340 if ($('#div_saisieParticipantsCongres').length>0) { 4341 var tabParticipants = new Array(); 4342 var civilite; var nom; var prenom; var naissance; 4343 var i = 0; 4344 $('.div_unParticipant').each(function(){
4345 civilite = $(this).find('.civiliteParticipant').val(); 4346 nom = $(this).find('.nomParticipant').val(); 4347 prenom = $(this).find('.prenomParticipant').val(); 4348 naissance = $(this).find('.dateNaissanceParticipant').val(); 4349 tabParticipants[i] = new Array(civilite, nom, prenom, naissance); 4350 i++; 4351 }); 4352 $.ajax({ 4353 type: "POST", 4354 url: urlAJAX, 4355 data: {type: "setParticipantsCongres", tabParticipants: tabParticipants}, 4356 beforeSend: function(){ 4357 4358 } 4359 }); 4360 } 4361 /* if ($("#div_dateNaissanceClient").length>0) { 4362 verifSaisieDateNaissance(); 4363 if (!$("#div_dateNaissanceClient > span.LV_valid").length > 0) 4364 verifDateNaissance = false; 4365 }*/ 4366 if ($(this).parent().is('#div_btnConfirmer_2')) { 4367 var urlHref = "etape"+ $('#div_btnConfirmer_2').attr('data-idPageNext')+".php"; 4368 } else { 4369 var urlHref = "etape"+ $('#div_btnConfirmer').attr('data-idPageNext')+".php"; 4370 } 4371 4372 if (location.search.indexOf("PHPSESSID") > -1) { 4373 urlHref += location.search; 4374 } else { 4375 urlHref += location.search + "&" + idSession; 4376 } 4377 // On vérifie si un client est connecté (il y a un input hidden) 4378 // Pas besoin d'appel AJAX uniquement pour faire is_object($dossier->objClient) 4379 4380 if ($("input:hidden[name=inpt_dejaClient]").length > 0) { 4381 location.href = urlHref; 4382 } 4383 //else if (LiveValidation.massValidate(tabAValider) && verifDateNaissance) { 4384 else if (LiveValidation.massValidate(tabAValider)) { 4385 var tabInfos = new Array(); 4386 4387 if (!verifQuestionnairesClient()){ 4388 $(".a_btnAttenteConfirm").hide(); 4389 $(this).show(); 4390 document.location = "#div_uneEtape_questionnaires"; 4391 return; 4392 } 4393 enregistreReponsesQuestionnairesClient(); 4394 4395 // On a le formulaire de saisie des coordonnées clients pour un nouveau client 4396 // ->On fait REQ62 4397 if ($("#form_nouveauClient:visible").length > 0) { 4398 // Récupération des infos saisies 4399 $(".div_saisieClient:visible").each(function(){ 4400 var objs = $(this).children(":not(label)"); 4401 var id, valeur; 4402 objs.each(function(){ 4403 var estInput = $(this).attr('name') || false; 4404 if(estInput){ 4405 id = $(this).attr("name"); 4406 valeur = $(this).val() || ''; 4407 } 4408 }) 4409 4410 tabInfos.push(new Array(id, valeur)); 4411 }); 4412 if (!tabInfos.some(tab => tab.includes('mail')) ) { 4413 debugLogJS('initEtape2 HL@1973094 enregistreClient tabInfos sans mail. Navigator.userAgent:'+navigator.userAgent); 4414 } 4415 // Récupération de la date de naissance pour FNGF 4416 if ($("#div_dateNaissanceClient").length > 0) { 4417 var jour = $("#select_jourNaissanceClient").val(); 4418 var mois = $("#select_moisNaissanceClient").val(); 4419 var annee = $("#select_anneeNaissanceClient").val(); 4420 var dateNaissance = jour+"-"+mois+"-"+annee; 4421 tabInfos.push(new Array("dateNaissance", dateNaissance)); 4422 } 4423 // Yoann 28/07/2016 (fiche 278591) : On envoie toujours le mdp client, cela permet de ne pas recréer un client 4424 if ($("#div_saisieClientAncienPassword").length > 0) { 4425 id = $("#inpt_mdpClient").attr("name"); 4426 valeur = $("#inpt_mdpClient").val(); 4427 tabInfos.push(new Array(id, valeur)); 4428 } 4429 id = $("#div_saisieClientOffres").children(":not(label)").attr("name"); 4430 valeur = $("#div_saisieClientOffres").children(":not(label)").attr("checked"); 4431 tabInfos.push(new Array(id, valeur)); 4432 // on demande au client si il veut les documents par courrier plutot que par mail : 4433 // ça veut dire que si c'est coché, on enverra par courrier => donc backoffice par mail est par défaut à O (envoi par mail) 4434 id = 'backofficeParMail'; 4435 valeur = 'O'; 4436// if($("#div_saisieClientBackofficeParMail").children(":not(label)").is(':checked')){ 4437// valeur = 'N'; 4438// } 4439 // simplification du backoffice par courrier / mail 4440 if($('.input_saisieClientRadioBackoffice').length>0){ 4441// id= 'backofficeParMail'; 4442 valeur= $('input[name="backofficeClient"]:checked').val(); 4443// tabInfos.push(new Array(id, valeur)); 4444 } 4445// else{ 4446// valeur = $("#div_saisieClientBackofficeParMail").children(":not(label)").attr("checked"); 4447 tabInfos.push(new Array(id, valeur)); 4448// } 4449 if(estResaAvecCompteGdf()){ 4450 id = $("#div_saisieClientCreationCompteGdf").children(":not(label)").attr("name"); 4451 valeur = $("#div_saisieClientCreationCompteGdf").children(":not(label)").attr("checked"); 4452 tabInfos.push(new Array(id, valeur)); 4453 } 4454 4455 if ($("#inpt_numeroClient").length>0) { 4456 id = 'numeroClient'; 4457 valeur = $("#inpt_numeroClient").val(); 4458 tabInfos.push(new Array(id, valeur)); 4459 4460 id = 'identClientNat'; 4461 valeur = $("#inpt_identClientNat").val(); 4462 tabInfos.push(new Array(id, valeur)); 4463 4464 id = 'mdpNationalExistant'; 4465 valeur = $("#inpt_mdpNationalExistant").val(); 4466 tabInfos.push(new Array(id, valeur)); 4467 } 4468 if($('#inpt_connectFB').length>0 && $('#inpt_connectFB').val() == 'O'){ 4469 id = 'facebook'; 4470 valeur = $('#inpt_connectFB').val(); 4471 tabInfos.push(new Array(id, valeur)); 4472 } 4473 if($('#inpt_connectGoogle').length>0 && $('#inpt_connectGoogle').val() == 'O'){ 4474 id = 'google'; 4475 valeur = $('#inpt_connectGoogle').val(); 4476 tabInfos.push(new Array(id, valeur)); 4477 } 4478 // /!\ Si la pop-in est décochée c'est qu'on
4478souhaite créer un compte, c'est bien le fonctionnement normal ! 4479 if ($('#inpt_creationCompteVacancesConnect').length>0 && !$('#inpt_creationCompteVacancesConnect').is(':checked')){ 4480 tabInfos.push(new Array('creationCompteVacancesConnect', 'O')); 4481 } 4482 4483 // Appel AJAX pour traiter la validation 4484 $.ajax({ 4485 type: "POST", 4486 url: urlAJAX, 4487 data: {type: "enregistreClient", tabInfos: tabInfos}, 4488 beforeSend: function(){ 4489 4490 }, 4491 success: function(result){ 4492 eval("var tabResult="+result); 4493 if (tabResult.code == errDossierNull) { 4494 retourEtape1(tabResult.msg); 4495 } 4496 else if (tabResult.errTechnq) { 4497 afficheMsgErrTechnq(tabResult.msg, tabResult.titre, tabResult.ident, true); 4498 } 4499 else { 4500 if (tabResult.code == "OK") { 4501 location.href = urlHref; 4502 } 4503 else { 4504 $("#div_msgErreursInfosClient").show('fast'); 4505 document.location = "#div_msgErreursInfosClient"; 4506 afficheMsgErrTechnq(tabResult.msg) 4507 } 4508 } 4509 4510 } 4511 }); 4512 } 4513 // On a un client et il a voulu modifier ses informations 4514 // ->REQ61 ou REQ62 en fonction des informations modifiées 4515 else { 4516 // Récupération des infos saisies 4517 $(".div_saisieClient:visible").each(function(){ 4518 var id = $(this).children(":not(label)").attr("name"); 4519 var valeur = $(this).children(":not(label)").val(); 4520 tabInfos.push(new Array(id, valeur)); 4521 }); 4522 // si ya pas eu de changement par le client, on push pas les infos 4523 if($("#div_saisieClientOffres:visible").length>0){ 4524 id = $("#div_saisieClientOffres:visible").children(":not(label)").attr("name"); 4525 valeur = $("#div_saisieClientOffres:visible").children(":not(label)").attr("checked"); 4526 tabInfos.push(new Array(id, valeur)); 4527 } 4528 4529 // Appel AJAX pour traiter la validation 4530 $.ajax({ 4531 type: "POST", 4532 url: urlAJAX, 4533 data: {type: "enregistreClient", tabInfos: tabInfos}, 4534 beforeSend: function(){ 4535 4536 }, 4537 success: function(result){ 4538 eval("var tabResult="+result); 4539 if (tabResult.code == errDossierNull) { 4540 retourEtape1(tabResult.msg); 4541 } 4542 else if (tabResult.errTechnq) { 4543 afficheMsgErrTechnq(tabResult.msg, tabResult.titre, tabResult.ident, true); 4544 } 4545 else { 4546 if (tabResult.code == "OK") { 4547 location.href = urlHref; 4548 } 4549 else { 4550 $("#div_msgErreursInfosClient").show('fast'); 4551 document.location = "#div_msgErreursInfosClient"; 4552 afficheMsgErrTechnq(tabResult.msg); 4553 4554 } 4555 } 4556 4557 } 4558 }); 4559 } 4560 } 4561 else { 4562 // Pour Google Tag Manager, on informe que la validation du formulaire a générée une erreur 4563 if (typeof(dataLayer)!='undefined') { 4564 dataLayer.push({'form_error': true, 4565 'event': 'form_error'}); 4566 var champsInvalides = '';
4567 $('.LV_invalid_field').each(function(){ 4568 champsInvalides += $(this).attr('name')+', '; 4569 }); 4570 // On enlève la dernière virgule et le dernier espace 4571 champsInvalides = champsInvalides.substring(0, champsInvalides.length - 2); 4572 dataLayer.push({'form_error_field': champsInvalides, 4573 'event': 'form_error'}); 4574 } 4575 $(".a_btnAttenteConfirm").hide(); 4576 $(this).show(); 4577 $("#div_msgErreursInfosClient").show(); 4578 document.location = "#div_msgErreursInfosClient"; 4579 } 4580 }); 4581 4582 $('#div_btnConnexionFacebook').click(function(){ 4583 if ($(this).is('.compteGdf')) { 4584 connexionFacebook(authentificationFacebookCompteGdf, resaFacebookKO); 4585 } else { 4586 connexionFacebook(resaFacebookOK, resaFacebookKO); 4587 } 4588 }); 4589 4590 $('#div_btnConnexionFacebook_creaCptGDF').click(function(){ 4591 connexionFacebook(checkIfCompteFNGFFacebookExiste, resaFacebookKO); 4592 }); 4593 4594 //Caro suite fiche 235726 4595 /* 4596 if ($('#a_saisieCoordProp').length>0 && $('#div_informationsProprio').length>0) { 4597 $('#a_saisieCoordProp').click(function(){ 4598 $('#select_civiliteClient').val($('#inptProp_civilite').val()); 4599 $('#inpt_nomClient').val($('#inptProp_nom').val()); 4600 $('#inpt_prenomClient').val($('#inptProp_prenom').val()); 4601 $('#inpt_adresse1Client').val($('#inptProp_adresse1').val()); 4602 $('#inpt_adresse2Client').val($('#inptProp_adresse2').val()); 4603 $('#inpt_cpClient').val($('#inptProp_CP').val()); 4604 $('#inpt_villeClient').val($('#inptProp_ville').val()); 4605 $('#select_pays').val($('#inptProp_pays').val().toUpperCase()); 4606 $('#inpt_telDomClient').val($('#inptProp_tel').val()); 4607 $('#inpt_mailClient').val($('#inptProp_email').val()); 4608 $('#inpt_confirmMailClient').val($('#inptProp_email').val()); 4609 $('#inpt_mdpClient').val($('#inptProp_motpasse').val()); 4610 }); 4611 } 4612 */ 4613 autocompleteurCpVille($('#inpt_cpClient'),$('#inpt_villeClient')); 4614 4615 if ($('#inpt_modeResaPROP').length>0 || estResaAilleurs()) { 4616 initAutocompleteClientsExistants(true); 4617 } 4618 if ($('.inpt_timepicker[type="text"]').length>0) { 4619 $('.inpt_timepicker').datetimepicker({ 4620 datepicker: false, 4621 format: 'H:i', 4622 step:30 4623 }); 4624 } 4625 4626 if($(".div_unParticipant").length>0){ 4627 $("#inpt_nomClient").blur(function(){ 4628 $("#nomParticipant_1").val($(this).val()); 4629 }); 4630 $("#inpt_prenomClient").blur(function(){ 4631 $("#prenomParticipant_1").val($(this).val()); 4632 }); 4633 } 4634 4635 initQuestionnaireClient(); 4636 initModalTaxeSejour(); 4637 })(jQuery); 4638} 4639 4640function afficheContentEtapeDejaClient() { 4641 (function($){ 4642 $("#div_uneEtape_dejaClient .div_uneEtapeContent").show(); 4643 $('.div_btnsConnexionVacancesConnect').hide(); 4644 })(jQuery); 4645} 4646 4647function masqueContentEtapeDejaClient() { 4648 (function($){ 4649 $("#div_uneEtape_dejaClient .div_uneEtapeContent").hide(); 4650 $('.div_btnsConnexionVacancesConnect').show(); 4651 })(jQuery); 4652} 4653 4654function initQuestionnaireClient(){ 4655 (function($){ 4656 if($(".select_questionClient").length>0){ 4657 $(".select_questionClient").change(function(){ 4658 actualiseDependancesQuestionsSelect($(this).data("id")); 4659 }); 4660 } 4661 4662 if($(".inpt_uneQuestionClient_radio").length>0){ 4663 $(".inpt_uneQuestionClient_radio").change(function(){ 4664 actualiseDependancesQuestionsRadio($(this).data("id")); 4665 }); 4666 } 4667 })(jQuery); 4668} 4669 4670function actualiseDependancesQuestionsRadio(idInputParent){ 4671 (function ($) { 4672 $('.div_uneQuestion[data-idparent="' + idInputParent + '"]').each(function () { 4673 var idParent = $(this).data("idparent"); 4674 var valeursParent = $(this).data("valeurparent").toString(); 4675 var tabValeurParent = valeursParent.split(","); 4676 if ($.inArray($('input[name="inpt_choixQuestion_' + idParent + '"]:checked').val(), tabValeurParent) !== -1) { 4677 $(this).show(); 4678 } else { 4679 $(this).hide(); 4680 effaceValeurFormInDiv(this);
4681 actualiseDependancesQuestionnaireClient($(this).data("id")); 4682 } 4683 }) 4684 })(jQuery); 4685} 4686 4687function actualiseDependancesQuestionsSelect(idInputParent){ 4688 (function ($) { 4689 $('.div_uneQuestion[data-idparent="' + idInputParent + '"]').each(function () { 4690 var idParent = $(this).data("idparent"); 4691 var valeursParent = $(this).data("valeurparent").toString(); 4692 var tabValeurParent = valeursParent.split(","); 4693 if ($.inArray($("#select_questionClient_" + idParent).val(), tabValeurParent) !== -1) { 4694 $(this).show(); 4695 } else { 4696 $(this).hide(); 4697 effaceValeurFormInDiv(this); 4698 actualiseDependancesQuestionsSelect($(this).data("id")); 4699 } 4700 }); 4701 })(jQuery); 4702} 4703 4704function initEtape2_agence(){ 4705 (function($){ 4706 $(document).ready(function(){ 4707 idSession = getIdSessionInHtml(); 4708 }); 4709 initBtnsFooter(); 4710 4711 var tabAValider = []; 4712 var nom = new LiveValidation("inpt_nomClient", {validMessage: $("#inpt_msgOk").val()}); 4713 nom.add(Validate.Presence, {failureMessage: $("#inpt_msgVide").val()}); 4714 tabAValider.push(nom); 4715 4716 $("#div_btnConfirmer > a:not(.a_btnAttenteConfirm)").click(function(){ 4717 4718 //console.log('foncResa.js initEtape2 click'); 4719 $(this).hide(); 4720 $(".a_btnAttenteConfirm").show(); 4721 4722 var urlHref = "etape"+ $('#div_btnConfirmer').attr('data-idPageNext')+".php"; 4723 if (location.search.indexOf("PHPSESSID") > -1) { 4724 urlHref += location.search; 4725 } else { 4726 urlHref += location.search + "&" + idSession; 4727 } 4728 4729 if (LiveValidation.massValidate(tabAValider)) { 4730 var tabInfos = new Array(); 4731 4732 // Récupération des infos saisies 4733 $(".div_saisieClient:visible").each(function(){ 4734 var objs = $(this).children(":not(label)"); 4735 var id, valeur; 4736 objs.each(function(){ 4737 var estInput = $(this).attr('name') || false; 4738 if(estInput){ 4739 id = $(this).attr("name"); 4740 valeur = $(this).val(); 4741 } 4742 }) 4743 4744 tabInfos.push(new Array(id, valeur)); 4745 }); 4746 // Appel AJAX pour traiter la validation 4747 $.ajax({ 4748 type: "POST", 4749 url: urlAJAX, 4750 data: {type: "enregistreClient_agence", tabInfos: tabInfos}, 4751 success: function(result){ 4752 eval("var tabResult="+result); 4753 if (tabResult.code == errDossierNull) { 4754 retourEtape1(tabResult.msg); 4755 } 4756 else if (tabResult.errTechnq) { 4757 afficheMsgErrTechnq(tabResult.msg, tabResult.titre, tabResult.ident, true); 4758 } 4759 else { 4760 if (tabResult.code == "OK") { 4761 location.href = urlHref; 4762 } 4763 else { 4764 4765 } 4766 } 4767 4768 } 4769 }); 4770 } 4771 else { 4772 $(".a_btnAttenteConfirm").hide(); 4773 $(this).show(); 4774 $("#div_msgErreursInfosClient").show(); 4775 document.location = "#div_msgErreursInfosClient"; 4776 } 4777 }); 4778 autocompleteurCpVille($('#inpt_cpClient'),$('#inpt_villeClient')); 4779 })(jQuery); 4780} 4781 4782function initEtape2_bureau(){ 4783 (function($){ 4784 var validerResa = false; 4785 $(document).ready(function(){ 4786 idSession = getIdSessionInHtml(); 4787 if ($('.dateNaissanceParticipant').length > 0) { 4788 initDatePickerNaissanceParticipant(); 4789 } 4790 }); 4791 initHistoriqueClientsLocalStorage(); 4792 initBtnsFooter(); 4793 initModifPrixResaBureau(); 4794 var tabAValider = getTabChampAValider_bureau(); 4795 if (estMultiResa()) { 4796 autofillFormulaireClient(getClientMultiResaDansSessionStorage()); 4797 } 4798 $("#div_btnConfirmer > a:not(.a_btnAttenteConfirm), #divBoutonTerminerModification").click(function(){ 4799 4800 $(this).hide(); 4801 $(".a_btnAttenteConfirm").show(); 4802 var urlHref = "etape"+ $('#div_btnConfirmer').attr('data-idPageNext')+".php"; 4803 if (location.search.indexOf("PHPSESSID") > -1) { 4804 urlHref += location.search; 4805 } else { 4806 urlHref += location.search + "&" + idSession; 4807 } 4808 if($(this).attr('id') == 'divBoutonTerminerModification'){ 4809 validerResa = true; 4810 } 4811 4812 if (LiveValidation.massValidate(tabAValider)) { 4813 var tabInfos = new Array(); 4814 4815 if (!verifQuestionnairesClient()){ 4816 $(".a_btnAttenteConfirm").hide(); 4817 $(this).show(); 4818 document.location = "#div_uneEtape_questionnaires"; 4819 return; 4820 } 4821 enregistreReponsesQuestionnairesClient(); 4822 4823 if ($('#div_saisieParticipantsCongres').length > 0) { 4824 var tabParticipants = new Array(); 4825 var civilite; 4826 var nom; 4827 var prenom; 4828 var naissance; 4829 var i = 0; 4830 $('.div_unParticipant').each(function () {
4831 civilite = $(this).find('.civiliteParticipant').val(); 4832 nom = $(this).find('.nomParticipant').val(); 4833 prenom = $(this).find('.prenomParticipant').val(); 4834 naissance = $(this).find('.dateNaissanceParticipant').val(); 4835 tabParticipants[i] = new Array(civilite, nom, prenom, naissance); 4836 i++; 4837 }); 4838 $.ajax({ 4839 type: "POST", 4840 url: urlAJAX, 4841 data: {type: "setParticipantsCongres", tabParticipants: tabParticipants}, 4842 beforeSend: function () { 4843 4844 } 4845 }); 4846 } 4847 4848 var tabInfosLocalStorage = {}; 4849 // TODO : enregistrer infos et go étape 3 4850 $(".div_saisieClient:visible, #div_saisieClientPassword").each(function(){ 4851 var objs = $(this).children(":not(label)"); 4852 var id, valeur; 4853 objs.each(function(){ 4854 var estInput = $(this).attr('name') || false; 4855 if(estInput){ 4856 id = $(this).attr("name"); 4857 valeur = $(this).val(); 4858 } 4859 }); 4860 tabInfos.push(new Array(id, valeur)); 4861 tabInfosLocalStorage[id] = valeur; 4862 }); 4863 4864 $(".div_saisieClientChecks:visible").each(function(){ 4865 id = $(this).children(":not(label)").attr("name"); 4866 valeur = $(this).children(":not(label)").attr("checked"); 4867 tabInfos.push(new Array(id, valeur)); 4868 tabInfosLocalStorage[id] = valeur; 4869 }); 4870 4871 if($('.input_saisieClientRadioBackoffice').length>0){ 4872 id= 'backofficeParMail'; 4873 valeur= $('input[name="backofficeClient"]:checked').val(); 4874 tabInfos.push(new Array(id, valeur)); 4875 tabInfosLocalStorage[id] = valeur; 4876 } 4877 4878 id = 'numeroClient'; 4879 valeur = $("#inpt_numeroClient").val(); 4880 tabInfos.push(new Array(id, valeur)); 4881 tabInfosLocalStorage[id] = valeur; 4882 4883 id = 'identClientNat'; 4884 valeur = $("#inpt_identClientNat").val(); 4885 tabInfos.push(new Array(id, valeur)); 4886 tabInfosLocalStorage[id] = valeur; 4887 4888 id = 'mdpNationalExistant'; 4889 valeur = $("#inpt_mdpNationalExistant").val(); 4890 tabInfos.push(new Array(id, valeur)); 4891 tabInfosLocalStorage[id] = valeur; 4892 4893 // Appel AJAX pour traiter la validation 4894 $.ajax({ 4895 type: "POST", 4896 url: urlAJAX, 4897 data: {type: "enregistreClient", tabInfos: tabInfos}, 4898 beforeSend: function(){ 4899 4900 }, 4901 success: function(result){ 4902 eval("var tabResult="+result); 4903 if (tabResult.code == errDossierNull) { 4904 retourEtape1(tabResult.msg); 4905 } 4906 else if (tabResult.errTechnq) { 4907 afficheMsgErrTechnq(tabResult.msg, tabResult.titre, tabResult.ident, true); 4908 } 4909 else { 4910 if (tabResult.code == "OK") { 4911 // on renseigne le mot de passe du client dans le local storage pour bien retomber sur le bon client quand on l'utilisera ultérieurement 4912 if(tabResult.mdpClientPourLocalStorage){ 4913 tabInfosLocalStorage.mdp = tabResult.mdpClientPourLocalStorage; 4914 } 4915 if (estMultiResa()) { 4916 ajouteClientMultiResaDansSessionStorage(tabInfosLocalStorage); 4917 } 4918 else{ 4919 ajouteClientDansLocalStorage(tabInfosLocalStorage); 4920 } 4921 if(validerResa){ 4922 terminerModifResa(); 4923 } 4924 else{ 4925 location.href = urlHref; 4926 } 4927 } 4928 else { 4929 $("#div_msgErreursInfosClient").show('fast'); 4930 document.location = "#div_msgErreursInfosClient"; 4931 afficheMsgErrTechnq(tabResult.msg); 4932 $('#div_btnConfirmer a').show(); 4933 $(".a_btnAttenteConfirm").hide(); 4934 } 4935 } 4936 4937 } 4938 }); 4939 //console.log(tabInfos); 4940 } else { 4941 $(".a_btnAttenteConfirm").hide(); 4942 $(this).show(); 4943 $("#div_msgErreursInfosClient").show(); 4944 document.location = "#div_msgErreursInfosClient"; 4945 } 4946 }); 4947 4948 // Gestion des messages d'informations en fonction des champs saisis 4949 $('.div_saisieClient input').change(function(){ 4950 checkChampsImportants(); 4951 }); 4952// // on met le plugin Mailcheck.js sur l'adresse mail 4953 setSuggestionMailCheck($('#inpt_mailClient')); 4954 // On lance le check dès qu'on arrive à l'étape2 pour masquer l'alerte si les champs sont déjà remplis 4955 checkChampsImportants(); 4956 autocompleteurCpVille($('#inpt_cpClient'),$('#inpt_villeClient')); 4957 initAutocompleteClientsExistants(false); 4958 })(jQuery); 4959} 4960 4961function checkChampsImportants(){ 4962 (function($){ 4963 if ($('#inpt_adresse1Client').val()=='') { 4964 $('#div_msgInfosChampsSaisis p.adresse').show(); 4965 } else { 4966 $('#div_msgInfosChampsSaisis p.adresse').hide(); 4967 } 4968 if ($('#inpt_telDomClient').val()=='') { 4969 $('#div_msgInfosChampsSaisis p.tel').show(); 4970 } else { 4971 $('#div_msgInfosChampsSaisis p.tel').hide(); 4972 } 4973 if ($('#inpt_mailClient').val()=='') { 4974 $('#div_msgInfosChampsSaisis p.mail').show(); 4975 } else { 4976 $('#div_msgInfosChampsSaisis p.mail').hide(); 4977 } 4978 4979 if ($('#div_msgInfosChampsSaisis .p_msgInfosChampsSaisis:visible').length==0) { 4980 $('#div_msgInfosChampsSaisis').hide(); 4981 } else { 4982 $('#div_msgInfosChampsSaisis').show(); 4983 } 4984 })(jQuery); 4985} 4986 4987// Fonction appelée si on a un objClient en session, il faut pouvoir afficher les msgs 4988// du plugin de validation de formulaire (LiveValidation) 4989function validFormulaire(){ 4990 4991// console.log('foncResa.js validFormulaire'); 4992 (function($){ 4993 var tabAValider = []; 4994 if (estResaBureauGestloc() || estResaBureauProp() || estResaAilleurs()){ 4995 tabAValider = getTabChampAValider_bureau(); 4996 }else{ 4997 tabAValider = getTabChampAValider(); 4998 } 4999 5000 //console.log(tabAValider); 5001 LiveValidation.massValidate(tabAValider); 5002 5003 //verifSaisieDateNaissance(); 5004 })(jQuery); 5005} 5006 5007function getTabChampAValider(){ 5008 var patternTel = /^\+?([0-9.-\s]{9,20}|[0-9]{8,20})$/; 5009 5010 //console.log('foncResa.js getTabChampAValider'); 5011 var retour = []; 5012 5013 (function($){ 5014 //console.log('foncResa.js getTabChampAValider fonction'); 5015 var nom = new LiveValidation("inpt_nomClient", {validMessage: $("#inpt_msgOk").val(), onlyOn
5015Blur: true}); 5016 nom.add(Validate.Presence, {failureMessage: $("#inpt_msgVide").val()}); 5017 retour.push(nom); 5018 var prenom = new LiveValidation("inpt_prenomClient", {validMessage: $("#inpt_msgOk").val(), onlyOnBlur: true}); 5019 prenom.add(Validate.Presence, {failureMessage: $("#inpt_msgVide").val()}); 5020 retour.push(prenom); 5021 var adresse = new LiveValidation("inpt_adresse1Client", {validMessage: $("#inpt_msgOk").val(), onlyOnBlur: true}); 5022 adresse.add(Validate.Presence, {failureMessage: $("#inpt_msgVide").val()}); 5023 // fiche 252166 5024 adresse.add(Validate.Length, {maximum: 30, tooLongMessage: $("#inpt_msgSaisieTropLongue").val()}); 5025 retour.push(adresse); 5026 var cp = new LiveValidation("inpt_cpClient", {validMessage: $("#inpt_msgOk").val(), onlyOnBlur: true}); 5027 cp.add(Validate.Presence, {failureMessage: $("#inpt_msgVide").val()}); 5028 retour.push(cp); 5029 var ville = new LiveValidation("inpt_villeClient", {validMessage: $("#inpt_msgOk").val(), onlyOnBlur: true}); 5030 ville.add(Validate.Presence, {failureMessage: $("#inpt_msgVide").val()}); 5031 retour.push(ville); 5032 var tel = new LiveValidation("inpt_telDomClient", {validMessage: $("#inpt_msgOk").val(), onlyOnBlur: true}); 5033 tel.add(Validate.Presence, {failureMessage: $("#inpt_msgVide").val()}); 5034 /* 5035 if($('#inpt_telDomClient').attr('data-typeTel') == 'portable'){ // pour les ventes de dernière minute, on doit vérifier si on a un tel portable 5036 // correction guillaume 13/03/2017 : la regex n'était pas bonne. On autorise seulement les portables français. 5037 tel.add(Validate.Format, {pattern: /^0[6-7][\s]?([0-9]{2}[\s]?){3}[0-9]{2}$/, failureMessage: $("#inpt_msgTelPortable").val()}); 5038// tel.add(Validate.Format, {pattern: /(^0[6-7][\s]?([0-9]{2}[\s]?){3}[0-9]{2}$|^00[0-9,\s]+[0-9]$)/, failureMessage: $("#inpt_msgTelPortable").val()}); 5039 } 5040 else{ 5041 // Yoann 13/01/2015 : j'autorise les espaces dans les numéros de téléphone pour ne pas bloquer la saisie rapide des coordonnées dans la résa PROP 5042// tel.add(Validate.Format, {pattern: /(^0[1-9][\s]?([0-9]{2}[\s]?){3}[0-9]{2}$|^00[0-9,\s]+[0-9]$)/, failureMessage: $("#inpt_msgTelChiffres").val()}); 5043 // Yoann 08/02/2016 : Modification du pattern de vérification des téléphones 5044 tel.add(Validate.Format, {pattern: patternTel, failureMessage: $("#inpt_msgTelChiffres").val()}); 5045 } 5046 */ 5047 5048 // HL@1835987 On veut débloquer les clients étrangers qui veulent créer une VDM => regex internationale inconditionnellement 5049 tel.add(Validate.Format, {pattern: patternTel, failureMessage: $("#inpt_msgTelChiffres").val()}); 5050 5051 5052 tel.add(Validate.Length, {minimum: 6, tooShortMessage: $("#inpt_msgTelCourt").val()}); 5053 tel.add(Validate.Length, {maximum: 20, tooLongMessage: $('#inpt_msgTelLong').val()}); // fiche 241538 + 245221 20chars 5054 retour.push(tel); 5055 var tel2 = new LiveValidation("inpt_telBurClient", {validMessage: $("#inpt_msgOk").val(), onlyOnBlur: true}); 5056 // Yoann 13/01/2015 : j'autorise les espaces dans les numéros de téléphone pour ne pas bloquer la saisie rapide des coordonnées dans la résa PROP 5057 //tel2.add(Validate.Format, {pattern: /(^0[1-9][\s]?([0-9]{2}[\s]?){3}[0-9]{2}$|^00[0-9,\s]+[0-9]$)/, failureMessage: $("#inpt_msgTelChiffres").val()}); 5058 tel2.add(Validate.Format, {pattern: patternTel, failureMessage: $("#inpt_msgTelChiffres").val()}); 5059// tel2.add(Validate.Numericality, {notANumberMessage: $("#inpt_msgTelChiffres").val()}); 5060 tel2.add(Validate.Length, {minimum: 6, tooShortMessage: $("#inpt_msgTelCourt").val()}); 5061 tel2.add(Validate.Length, {maximum: 20, tooLongMessage: $('#inpt_msgTelLong').val()}); // fiche 241538 + 245221 20chars 5062 retour.push(tel2); 5063 5064 var email = new LiveValidation("inpt_mailClient", {validMessage: $("#inpt_msgOk").val(),onlyOn
5064Blur: true}); 5065 //email.add(Validate.Email, {failureMessage: $("#inpt_msgMailNonValide").val()}); 5066 // fiche 243999 : ne pas mettre obligatoire pour les points de vente (si on a pas l'étoile dans le libellé c'est que c'est pas obligatoire) 5067 var obligatoire = true; 5068 if($('#div_saisieClientEmail').find('span.etoile').length === 0){ 5069 obligatoire = false; 5070 } 5071 addValidateOnLiveValidationEmail(email,undefined,obligatoire,$("#inpt_msgMailNonValide").val()); 5072 retour.push(email); 5073 5074 if(estResaAvecCompteGdf()){ 5075 if(!jQuery('#inputIdentClientNat').val()){ 5076 addValidateOnLiveValidationEmail(email, undefined, true, $('#inpt_msgCompteGdfExistant').val(), 'checkEmailClientCompilNotExist'); 5077 retour.push(email); 5078 } 5079 } 5080 if ($('#inpt_confirmMailClient').length>0) { 5081 var emailConfirm = new LiveValidation("inpt_confirmMailClient", {validMessage: $("#inpt_msgOk").val(), onlyOnBlur: true}); 5082 // fiche 213794 : le champ de confirm ne doit pas bloquer si le mail n'est pas obligatoire 5083 emailConfirm.add(Validate.Confirmation, {match: "inpt_mailClient", failureMessage: $("#inpt_msgCorresMails").val()}); 5084 retour.push(emailConfirm); 5085 } 5086 5087 if ($("#inpt_mdpClient").is(":visible")) { 5088 var mdp = new LiveValidation("inpt_mdpClient", {validMessage: $("#inpt_msgOk").val(), onlyOnBlur: true}); 5089 if(estResaAvecCompteGdf()){ 5090 mdp.add(Validate.Presence, {failureMessage: $("#inpt_msgVide").val()}); 5091 } 5092 // 2240594 : changement du pattern pour autoriser tous les caractères mêmes les caractères spéciaux (même pattern que initFormModifPass de cptClient.js) 5093 // mdp.add(Validate.Format,{pattern: /^(?=.*[0-9]+.*)(?=.*[A-Z]+.*)(?=.*[a-z]+.*)[0-9a-zA-Z-_]{8,}$/, failureMessage: $("#inpt_msgSeulementChiffresLettres").val()}); 5094 mdp.add(Validate.Format,{pattern: /^[\w\W]{8,}$/, failureMessage: $("#inpt_msgSeulementChiffresLettres").val()}); 5095 retour.push(mdp); 5096// var mdpConfirm = new LiveValidation("inpt_confirmMdpClient", {validMessage: $("#inpt_msgOk").val()}); 5097// mdpConfirm.add(Validate.Confirmation, {match: "inpt_mdpClient", failureMessage: $("#inpt_msgCorresMdp").val()}); 5098// retour.push(mdpConfirm); 5099 } 5100 5101 if ($('#modeResaPVTrue').length > 0 && $('#inpt_commentaireDossier').length > 0) { 5102 var commentaire = new LiveValidation("inpt_commentaireDossier", {validMessage: $("#inpt_msgOk").val(), onlyOnBlur: true}); 5103 commentaire.add(Validate.Length, {maximum: 500, tooLongMessage: $("#inpt_msgCommentaireNonValide").val()}); 5104 retour.push(commentaire); 5105 if($('#inpt_commentaireDossierPourCentrale').length>0){ 5106 var commentaireCentrale = new LiveValidation("inpt_commentaireDossierPourCentrale", {validMessage: $("#inpt_msgOk").val()}); 5107 var longeurMax = $('#inpt_commentaireDossierPourCentrale').data('longueurmax'); 5108 commentaireCentrale.add(Validate.Length, {maximum: parseInt(longeurMax), tooLongMessage: $("#inpt_msgCommentaireNonValide").val()}); 5109 retour.push(commentaireCentrale); 5110 } 5111 } 5112 5113 if($('#modeResaPVTrue').length==0 && $('#inpt_modeResaPROP').length==0 ){ 5114 // contrairement au fonctionnement point de vente on est mode grand public donc on demande la saisie obligatoire de email, emailConfirm, mdp et mdpConfirm 5115 email.add(Validate.Presence, {failureMessage: $("#inpt_msgVide").val()}); 5116 if (emailConfirm) { 5117 emailConfirm.add(Validate.Presence, {failureMessage: $("#inpt_msgVide").val()}); 5118 } 5119// if($("#inpt_mdpClient").is(":visible")){ 5120// mdp.add(Validate.Presence, {failureMessage: $("#inpt_msgVide").val()}); 5121// mdpConfirm.add(Validate.Presence, {failureMessage: $("#inpt_msgVide").val()}); 5122// } 5123 } 5124 5125 /*if ($("#div_dateNaissanceClient").length>0) { 5126 $(".select_dateNaissanceClient").change(function(){ 5127 verifSaisieDateNaissance(); 5128 }); 5129 }*/ 5130 })(jQuery); 5131 return retour; 5132} 5133 5134function getTabChampAValider_bureau(){ 5135 var retour = []; 5136 //console.log('getTabChampAValider_bureau'); 5137 (function($){ 5138 var categ,ori; 5139 if($('#select_categorieClient').hasClass('inputObligatoire')){ 5140 var categ = new LiveValidation('select_categorieClient', {validMessage: $("#inpt_msgOk").val()}); 5141 categ.add(Validate.Presence, {failureMessage: $("#inpt_msgVide").val()}); 5142 retour.push(categ); 5143 } 5144 if($('#select_origineClient').hasClass('inputObligatoire')){ 5145 var ori = new LiveValidation('select_origineClient', {validMessage: $("#inpt_msgOk").val()}); 5146 ori.add(Validate.Presence, {failureMessage: $("#inpt_msgVide").val()}); 5147 retour.push(ori); 5148 } 5149 // Fiche 299698 : évite de saisir juste un espace dans le nom du client 5150 $("#inpt_nomClient").change(function(){ 5151 $("#inpt_nomClient").val($("#inpt_nomClient").val().trim()); 5152 }); 5153 var nom = new LiveValidation("inpt_nomClient", {validMessage: $("#inpt_msgOk").val()}); 5154 nom.add(Validate.Presence, {failureMessage: $("#inpt_msgVide").val()}); 5155 retour.push(nom); 5156 // Fiche 299698 : Idem pour le prénom 5157 $("#inpt_prenomClient").change(function(){ 5158 $("#inpt_prenomClient").val($("#inpt_prenomClient").val().trim()); 5159 }); 5160 var prenom = new LiveValidation("inpt_prenomClient", {validMessage: $("#inpt_msgOk").val()}); 5161 retour.push(prenom); 5162 5163 $("#inpt_telDomClient").change(function(){ 5164 $("#inpt_telDomClient").val($("#inpt_telDomClient").val().trim()); 5165 }); 5166 5167 $("#inpt_telBurClient").change(function(){ 5168 $("#inpt_telBurClient").val($("#inpt_telBurClient").val().trim()); 5169 }); 5170 // fiche 252166 + 2787018 5171 var adresse = new LiveValidation("inpt_adresse1Client", {validMessage: $("#inpt_msgOk").val(), onlyOn
5171Blur: true}); 5172 adresse.add(Validate.Length, {maximum: 50, tooLongMessage: $("#inpt_msgSaisieTropLongue").val()}); 5173 retour.push(adresse); 5174 var tel = new LiveValidation("inpt_telDomClient", {validMessage: $("#inpt_msgOk").val(),onlyOnSubmit:true}); 5175 tel.add(Validate.Format, { pattern: /^\+?[0-9 ]{6,18}$/i, failureMessage: "Numéro de téléphone non valide" }); 5176 tel.add(Validate.Length, {maximum: 20, tooLongMessage: $('#inpt_msgTelLong').val()}); // fiche 241538 + 245221 20chars 5177 retour.push(tel); 5178 5179 var tel2 = new LiveValidation("inpt_telBurClient", {validMessage: $("#inpt_msgOk").val(),onlyOnSubmit:true}); 5180 tel2.add(Validate.Format, { pattern: /^\+?[0-9 ]{6,18}$/i, failureMessage: "Numéro de téléphone non valide" }); 5181 tel2.add(Validate.Length, {maximum: 20, tooLongMessage: $('#inpt_msgTelLong').val()}); // fiche 241538 + 245221 20chars 5182 retour.push(tel2); 5183 5184 var email = new LiveValidation("inpt_mailClient", {validMessage: $("#inpt_msgOk").val(),onlyOn
5184Blur: true}); 5185 //email.add(Validate.Email, {failureMessage: $("#inpt_msgMailNonValide").val()}); 5186 addValidateOnLiveValidationEmail(email,undefined,false,$("#inpt_msgMailNonValide").val()); 5187 retour.push(email); 5188 5189 if ($('#inpt_mailClientPlus').length>0) { 5190 var emailPlus = new LiveValidation("inpt_mailClientPlus", {validMessage: $("#inpt_msgOk").val(),onlyOnBlur: true}); 5191 //emailPlus.add(Validate.Email, {failureMessage: $("#inpt_msgMailNonValide").val()}); 5192 addValidateOnLiveValidationEmail(emailPlus,undefined,false,$("#inpt_msgMailNonValide").val()); 5193 retour.push(emailPlus); 5194 } 5195 5196 if ($('#inpt_commentaireDossier').length > 0) { 5197 var commentaire = new LiveValidation("inpt_commentaireDossier", {validMessage: $("#inpt_msgOk").val()}); 5198 commentaire.add(Validate.Length, {maximum: 500, tooLongMessage: $("#inpt_msgCommentaireNonValide").val()}); 5199 retour.push(commentaire); 5200 } 5201 5202 if ($('#inpt_commentaireDossierPourCentrale').length > 0) { 5203 var commentaireCentrale = new LiveValidation("inpt_commentaireDossierPourCentrale", {validMessage: $("#inpt_msgOk").val()}); 5204 commentaireCentrale.add(Validate.Length, {maximum: parseInt($('#inpt_commentaireDossierPourCentrale').attr('data-longueurMax')), tooLongMessage: $("#inpt_msgCommentaireNonValide").val()}); 5205 retour.push(commentaireCentrale); 5206 } 5207 5208 if ($('#inpt_commentaireClientPourCentrale').length > 0) { 5209 var commentaireClientPourCentrale = new LiveValidation("inpt_commentaireClientPourCentrale", {validMessage: $("#inpt_msgOk").val()}); 5210 commentaireClientPourCentrale.add(Validate.Length, {maximum: parseInt($('#inpt_commentaireClientPourCentrale').attr('data-longueurMax')), tooLongMessage: $("#inpt_msgCommentaireNonValide").val()}); 5211 retour.push(commentaireClientPourCentrale); 5212 } 5213 })(jQuery); 5214 5215 return retour; 5216} 5217 5218function verifSaisieDateNaissance(){ 5219 (function($){ 5220 var ok = $("#inpt_msgOk").val(); 5221 var err = $("#inpt_msgVide").val(); 5222 var xhtml = ""; 5223 $("#div_dateNaissanceClient > span").remove(); 5224 if ($("#select_anneeNaissanceClient").val() != '0' && $("#select_moisNaissanceClient").val() != '0' && $("#select_jourNaissanceClient").val() != '0') { 5225 xhtml = "<span class='LV_validation_message LV_valid'>"+ok+"</span>"; 5226 } 5227 5228 else { 5229 xhtml = "<span class='LV_validation_message LV_invalid'>"+err+"</span>"; 5230 } 5231 $("#div_dateNaissanceClient").append(xhtml); 5232 })(jQuery); 5233} 5234 5235function initEtape3(){ 5236 (function($){ 5237 $(document).ready(function(){ 5238 idSession = getIdSessionInHtml(); 5239 }); 5240 initBtnsFooter(); 5241 initModifPrixResaBureau(); 5242 $.datepicker.setDefaults($.datepicker.regional[initLangueForDatePicker()]); 5243 var avecEnvoiMailPaiement = 'N'; 5244 $('#inpt_nouvelleDateLimite').datepicker(); // résa prop, date limite 5245// if ($('#div_btnModifPrix').length>0) { 5246// $('.a_ongletResaProp').click(function(){ 5247// if($(this).attr('data-div') === 'div_boutonsResaProp_LD') { 5248// $('#div_btnModifPrix').hide(); 5249// } else { 5250// $('#div_btnModifPrix').show(); 5251// } 5252// }); 5253// } 5254 5255 if ($('#div_valideDocsFiche').length>0) {
5256 $("#inpt_valideDocFiche").click(function(){ 5257 $("#div_msgErreursDocs").hide(); 5258 /*if ($(this).attr("checked") == "checked" && $(this).hasClass("estPasNavMobile")) // plus besoin mail ACP 04/09 cyril 5259 window.open($("#a_valideFiche").attr("url"), "", 5260 "toolbar=no,top=50,left=50,location=no,directories=no,status=no,menubar=yes,scrollbars=yes,resizable=yes,width=600,height=700"); 5261 */ 5262 if ($(this).attr("checked") == "checked" && $("#inpt_valideDocCgv").attr("checked") == "checked" && $("#inpt_valideDocCga").attr("checked") == "checked") 5263 etapeCourante($("#div_uneEtape_validationReservation"), false); 5264 }); 5265 } 5266 5267 $("#div_recapHeberVoirFiche").click(function(){ 5268 $("#inpt_valideDocFiche").checked = true; 5269 $("#inpt_valideDocFiche").attr("checked", true); 5270 }); 5271 5272 $("#a_valideFiche").click(function(){ 5273 window.open($("#a_valideFiche").attr("url"), "", 5274 "toolbar=no,top=50,left=50,location=no,directories=no,status=no,menubar=yes,scrollbars=yes,resizable=yes,width=600,height=700"); 5275 if($("#inpt_valideDocCgv").length == 0 && $("#a_valideCGV").length>0){ 5276 if($("#inpt_valideDocFiche").attr("data-uneDocVue") == "true"){
5277 $("#inpt_valideDocFiche").checked = true; 5278 $("#inpt_valideDocFiche").attr("checked", true); 5279 }else { 5280 $("#inpt_valideDocFiche").attr("data-uneDocVue", 'true'); 5281 } 5282 }else if ($("#inpt_valideDocFiche").attr("checked") != "checked") { 5283 $("#inpt_valideDocFiche").checked = true; 5284 $("#inpt_valideDocFiche").attr("checked", true); 5285 } 5286 }); 5287 5288 $("#a_valideCGV").click(function(){ 5289 if($("#inpt_valideDocCgv").length == 0){ 5290 if ($("#inpt_valideDocFiche").attr("data-uneDocVue") == "true") { 5291 $("#inpt_valideDocFiche").checked = true; 5292 $("#inpt_valideDocFiche").attr("checked", true); 5293 }else { 5294 $("#inpt_valideDocFiche").attr("data-uneDocVue", 'true'); 5295 } 5296 }else { 5297 $("#inpt_valideDocCgv").checked = true; 5298 $("#inpt_valideDocCgv").attr("checked", true); 5299 } 5300 }); 5301 5302 $("#a_valideCGA").click(function(){
5303 $("#inpt_valideDocCga").checked = true; 5304 $("#inpt_valideDocCga").attr("checked", true); 5305 }); 5306 5307 $(".inpt_valideDoc").click(function(){ 5308 $("#div_msgErreursDocs").hide(); 5309 if ($("#inpt_valideDocFiche").attr("checked") == "checked"){ 5310 if (($("#inpt_valideDocCga").length == 0 || ($("#inpt_valideDocCga").length > 0 && $("#inpt_valideDocCga").attr("checked") == "checked")) 5311 && ( $("#inpt_valideDocCgv").length == 0 || ($("#inpt_valideDocCgv").length > 0 && $("#inpt_valideDocCgv").attr("checked") == "checked"))) 5312 { 5313 etapeCourante($("#div_uneEtape_validationReservation"), false); 5314 } 5315 } 5316 }); 5317 5318 $('.inpt_modifPrixChambreResaProp:visible, .inpt_modifPrixChambreCentraleProp:visible, .inpt_modifPrixLocationResaProp:visible, #inpt_modifMontantPercu:visible').change(function(){ 5319 actualiseMontantRestant(); 5320 }); 5321 5322 5323 $('#inpt_resaBureauIntention').change(function(){ 5324 if ($(this).is(':checked')) { 5325 $('.avecEnvoiMailPaiement').addClass('disabledLink'); 5326 } else { 5327 $('.avecEnvoiMailPaiement').removeClass("disabledLink"); 5328 } 5329 }); 5330 5331 $("#a_btChoixPaiementOption, #a_btChoixResaLD_sansLienPaiement, #a_btChoixResaLD, #a_btnChoixCentrale, .div_validePaiementSansPaiement>button,.div_valideResaDureeLimitee, .div_valideResaConfirmation").click(function () { 5332 masqueBtnsValidationSansPaiement(); 5333 // TODO : faire des vérifs sur les champs saisis et bloquer si pas correct (?) 5334 var typeResaProp = ''; 5335 var etatDossierIntention = ''; 5336 var nouveauFraisDossier; 5337 var montantsSaisisCorrects = true; 5338 var regexMontants = /^[0-9]+[\.,]?[0-9]{0,2}$/; 5339 var regexDate = new RegExp('^[0-9]{2}/[0-9]{2}/[0-9]{4}$'); 5340 var estResaConfirmation = false; 5341 var estResaDureeLimitee = false; 5342 var forceDossierIntention = false; 5343 5344 if ($(this).is('.a_btChoixResaLD') || ($(this).closest('#div_boutonsResaProp_LD') && $(this).closest('#div_boutonsResaProp_LD').length > 0)) { 5345 typeResaProp = 'LD'; 5346 } else if ($(this).is('.a_btnChoixCentrale') || ($(this).closest('#div_boutonsResaProp_centrale') && $(this).closest('#div_boutonsResaProp_centrale').length > 0)) { 5347 typeResaProp = 'centrale'; 5348 } 5349 if ($(this).is('.avecEnvoiMailPaiement')) { 5350 avecEnvoiMailPaiement = 'O'; 5351 } 5352 5353 if ($(this).is('.div_valideResaConfirmation')) { 5354 if (!valideChampsReservationAvecConfirmation()) { 5355 return; 5356 } 5357 etatDossierIntention = 'O'; 5358 forceDossierIntention = true; 5359 estResaConfirmation = true; 5360 } 5361 5362 if ($(this).is('.div_valideResaDureeLimitee')) { 5363 if (!valideChampsReservationDureeLimitee()) { 5364 return; 5365 } 5366 etatDossierIntention = 'O'; 5367 forceDossierIntention = true; 5368 estResaDureeLimitee = true; 5369 } 5370 5371 if ($('#inpt_modifFDResaProp:visible').length > 0) { 5372 nouveauFraisDossier = $('#inpt_modifFDResaProp').val(); 5373 if (!regexMontants.test(nouveauFraisDossier)) { 5374 montantsSaisisCorrects = false; 5375 $('#inpt_modifFDResaProp').addClass('errSaisie'); 5376 $('.sp_msgSaisieMontantErronee').show(); 5377 } 5378 // Si A, on doit vérifier si le montant saisi est à la baisse 5379 if ($('#inpt_modifFDResaProp').attr('data-typeModif') != 'A') { 5380 if (parseFloat(nouveauFraisDossier) > parseFloat($('#inpt_modifFDResaProp').attr('data-value'))) { 5381 montantsSaisisCorrects = false; 5382 $('#inpt_modifFDResaProp').addClass('errSaisie'); 5383 $('.sp_msgSaisieMontantErronee').show(); 5384 } 5385 } 5386 } 5387 var nouvelAcompte; 5388 var montantPercu; 5389 var prixLocation; 5390 var nouveauxPrixOptions = Array(); 5391 var tabPrixChambre = new Array(); 5392 var prixTotal = $('#inpt_prixTotalResaProp').val(); 5393 var prixLoc = $('#inpt_prixLocResaProp').val(); 5394 5395 // Pour calculer le nouveau prix total, on récupère d'abord les montants des suppléments 5396 var nouveauPrixTotal = parseFloat(prixTotal) - parseFloat(prixLoc); 5397 5398 // Ensuite on va regarder si les champs de modif de prix sont saisis et on va ajouter les prix saisis 5399 if ($('.inpt_modifPrixLocationResaProp:visible').length > 0) { 5400 prixLocation = $('.inpt_modifPrixLocationResaProp:visible').val(); 5401 if (!regexMontants.test(prixLocation)) { 5402 $('.sp_msgSaisieMontantErronee').show(); 5403 montantsSaisisCorrects = false;
5404 $('.inpt_modifPrixLocationResaProp:visible').addClass('errSaisie'); 5405 } else if ($('.inpt_modifPrixLocationResaProp:visible').attr('id') == 'inpt_modifPrixCentraleProp') { 5406 var prixLocationReference = $('#inpt_modifPrixCentraleProp').attr('data-prixReference'); 5407 if (parseFloat(prixLocation) > parseFloat(prixLocationReference)) { 5408 montantsSaisisCorrects = false; 5409 $('.sp_msgSaisieMontantSuperieur').show(); 5410 $(this).addClass('errSaisie'); 5411 } 5412 } 5413 nouveauPrixTotal += parseFloat(prixLocation); 5414 } 5415 // TODO : prendre en compte les champs de modifPrix chambre 5416 // premier cas : pour les résas LD, on prend les inputs correspondants à l'onglet "Faire un contrat location direct" 5417 // second cas : pour les résas centrales on prend en compte les inputs correspondants à l'onglet "Faire un contratcentrale" 5418 if ($('.inpt_modifPrixChambreResaProp:visible').length > 0 || $('.inpt_modifPrixChambreCentraleProp:visible').length > 0) { 5419 prixLocation = 0; 5420 var nbChambresModif = 0; 5421 var inputs = $('.inpt_modifPrixChambreResaProp:visible, .inpt_modifPrixChambreCentraleProp:visible'); 5422 $(inputs).each(function () { 5423 var numeroChambre = $(this).attr('data-numeroChambre'); 5424 var prixChambre = $(this).val(); 5425 var prixReference = $('#prixChambreCentralePropReference_' + numeroChambre).val(); 5426 if (!regexMontants.test(prixChambre)) { 5427 montantsSaisisCorrects = false; 5428 $('.sp_msgSaisieMontantErronee').show(); 5429 $(this).addClass('errSaisie'); 5430 // résa centrale : il faut vérifier si le nouveau prix est inférieur ou égal au prix de référence 5431 } else if ($(this).hasClass('inpt_modifPrixChambreCentraleProp') && parseFloat(prixChambre) > parseFloat(prixReference)) { 5432 montantsSaisisCorrects = false; 5433 $('.sp_msgSaisieMontantSuperieur').show(); 5434 $(this).addClass('errSaisie'); 5435 } else { 5436 prixLocation += parseFloat(prixChambre); 5437 // tabPrixChambre[numeroChambre] = prixChambre; 5438 tabPrixChambre[nbChambresModif] = { numeroChambre: numeroChambre, prixChambre: prixChambre }; 5439 } 5440 nbChambresModif++; 5441 }); 5442 nouveauPrixTotal += parseFloat(prixLocation); 5443 } 5444 5445 if ($('#inpt_modifAcompteResaProp:visible').length > 0) { 5446 nouvelAcompte = $('#inpt_modifAcompteResaProp').val(); 5447 if (!regexMontants.test(nouvelAcompte)) { 5448 montantsSaisisCorrects = false; 5449 $('.sp_msgSaisieMontantErronee').show(); 5450 $('#inpt_modifAcompteResaProp').addClass('errSaisie'); 5451 } 5452 if (parseFloat(nouvelAcompte) > parseFloat(nouveauPrixTotal)) { 5453 montantsSaisisCorrects = false; 5454 $('#inpt_modifAcompteResaProp').addClass('errSaisie'); 5455 $('.sp_msgErrMontantAcomptePrixLoc').show(); 5456 } 5457 var montantRegltsCB = $('#inpt_modifAcompteResaProp:visible').data('regltcb'); 5458 if (parseFloat(nouvelAcompte) < parseFloat(montantRegltsCB)) { 5459 montantsSaisisCorrects = false; 5460 $('#inpt_modifAcompteResaProp').addClass('errSaisie'); 5461 $('.sp_msgErrMontantPercuRegltCB').show(); 5462 } 5463 } 5464 5465 if ($('.inpt_modifOptionResaProp:visible').length > 0) { 5466 $('.inpt_modifOptionResaProp:visible').each(function () { 5467 var nouveauPrixOption = $(this).val(); 5468 if (!regexMontants.test(nouveauPrixOption)) { 5469 montantsSaisisCorrects = false;
5470 $('.sp_msgSaisieMontantErronee').show(); 5471 $(this).addClass('errSaisie'); 5472 } else if (parseFloat(nouveauPrixOption) > parseFloat(nouveauPrixTotal)) { 5473 montantsSaisisCorrects = false; 5474 $('.sp_msgErrMontantAcomptePrixLoc').show(); 5475 $(this).addClass('errSaisie'); 5476 } else { 5477 var indice = $(this).data('indice'); 5478 nouveauxPrixOptions.push({ indice: indice, montant: nouveauPrixOption }); 5479 } 5480 }); 5481 } 5482 5483 if ($('#inpt_modifMontantPercu:visible').length > 0) { 5484 montantPercu = $('#inpt_modifMontantPercu').val(); 5485 if (!montantPercu.match(regexMontants)) { 5486 montantsSaisisCorrects = false; 5487 $('.sp_msgSaisieMontantErronee').show(); 5488 $('#inpt_modifMontantPercu').addClass('errSaisie'); 5489 } 5490 if (parseFloat(montantPercu) > parseFloat(nouveauPrixTotal)) { 5491 montantsSaisisCorrects = false; 5492 $('#inpt_modifMontantPercu').addClass('errSaisie'); 5493 $('.sp_msgErrMontantPercuPrixLoc').show(); 5494 } 5495 var montantRegltsCB = $('#inpt_modifMontantPercu:visible').data('regltcb'); 5496 if (parseFloat(montantPercu) < parseFloat(montantRegltsCB)) { 5497 montantsSaisisCorrects = false; 5498 $('#inpt_modifAcompteResaProp').addClass('errSaisie'); 5499 $('.sp_msgErrMontantPercuRegltCB').show(); 5500 } 5501 } 5502 5503 if ($('#inpt_resaBureauIntention:visible').length > 0) { 5504 if ($('#inpt_resaBureauIntention').attr('checked') == 'checked') { 5505 etatDossierIntention = 'O'; 5506 } 5507 // Avec le formulaire centralPay j'ai plusieurs checkbox 5508 } else if ($('.inpt_resaBureauIntention:visible').length > 0) { 5509 if ($('.inpt_resaBureauIntention:visible').attr('checked') === 'checked') { 5510 etatDossierIntention = 'O'; 5511 } 5512 } 5513 5514 var nouvelleDateLimite = ''; 5515 5516 if ($('#inpt_nouvelleDateLimite:visible').length > 0) { 5517 nouvelleDateLimite = $('#inpt_nouvelleDateLimite').val(); 5518 if (!regexDate.test(nouvelleDateLimite)) { 5519 montantsSaisisCorrects = false; 5520 $('#inpt_nouvelleDateLimite').addClass('errSaisie'); 5521 } 5522 } 5523 // TODO : vérifier si le prixLocation est supérieur au montant calculé par Gestloc 5524 5525 if (casesCochees() === true && montantsSaisisCorrects) { 5526 $.ajax({ 5527 type: "POST", 5528 url: urlAJAX, 5529 data: { type: "affectAutrePaiement", nouveauFraisDossier: nouveauFraisDossier, nouvelAcompte: nouvelAcompte, nouveauxPrixOptions: nouveauxPrixOptions, montantPercu: montantPercu, typeResaProp: typeResaProp, prixLocation: prixLocation, tabPrixChambre: tabPrixChambre, etatDossierIntention: etatDossierIntention, nouvelleDateLimite: nouvelleDateLimite, avecEnvoiMailPaiement: avecEnvoiMailPaiement, forceDossierIntention: forceDossierIntention }, 5530 beforeSend: function () {}, 5531 success: function (result) { 5532 eval("var tabResult=" + result); 5533 if (tabResult.code == errDossierNull) { 5534 retourEtape1(tabResult.msg); 5535 } else if (tabResult.modifDateHorsExe == 'O') { 5536 afficheMsgErrModifDateHorsExe(tabResult.msg); 5537 } else if (tabResult.errTechnq) { 5538 afficheMsgErrTechnq(tabResult.msg, tabResult.titre, tabResult.ident, true); 5539 } else { 5540 if (tabResult.code == "OK") { 5541 if (estResaConfirmation) { 5542 traiteReservationAvecConfirmation(); 5543 return; 5544 } 5545 if (estResaDureeLimitee) { 5546 traiteReservationDureeLimitee(); 5547 return; 5548 } 5549 if (location.search.indexOf("PHPSESSID") > -1) { 5550 location.href = "etape4.php" + location.search; 5551 } else { 5552 location.href = "etape4.php" + location.search + "&" + idSession; 5553 } 5554 // Je sors ici pour ne pas réafficher les boutons 5555 return; 5556 } else { 5557 alertAMalibu(tabResult.msg); 5558 } 5559 } 5560 // On réaffiche les boutons à la fin pour éviter qu'ils soient visibles pendant une redirection 5561 reafficheBtnsValidationSansPaiement(); 5562 }, 5563 }); 5564 } else { 5565 $(".a_btnAttenteConfirm").hide(); 5566 $(".a_btChoixPaiement").show(); 5567 $('.div_valideResaConfirmation').show(); 5568 $('.div_validePaiementSansPaiement>button').show(); 5569 $('#div_btnsResaProp_centrale .div_msgErreurs, #div_btnsResaProp_centrale .div_msgErreurs p').show('fast'); 5570 $('#div_boutonsResaProp_centrale .div_msgErreurs, #div_boutonsResaProp_centrale .div_msgErreurs p').show('fast'); 5571 $('#div_btnsResaProp_LD .div_msgErreurs, #div_btnsResaProp_LD .div_msgErreurs p').show('fast'); 5572 $('.div_valideResaConfirmation').show(); 5573 } 5574 }); 5575 5576 $('.div_validePaiementDemandeResa>button').unbind('click'); 5577 $('.div_validePaiementDemandeResa>button').bind('click', function(){ 5578 if (casesCochees()) { 5579 if (location.search.indexOf("PHPSESSID") > -1) { 5580 location.href = "etape4.php"+location.search+"&DEMANDERESA=1"; 5581 } else { 5582 location.href = "etape4.php"+location.search+"&"+idSession+"&DEMANDERESA=1"; 5583 } 5584 } 5585 }); 5586 5587 $('#spanModiferMontantVersement').click(function(){ 5588 $('#input_montantVersement').removeAttr('disabled'); 5589 }); 5590 $('input[name=choixPaiementCB]').click(function(){ 5591 if ($('#div_saisieCB_centralPay').length>0) { // si central pay
5592 gereActionsChoixMontantLibre(this); 5593 } 5594 else{ // si paybox 5595 if ($(this).is('#inpt_choixPaiementCB_montantLibre')) { 5596 $('#input_montantVersement').removeAttr('disabled'); 5597 } else { 5598 $('#input_montantVersement').attr('disabled', 'disabled'); 5599 } 5600 } 5601 }); 5602 5603 if (typeof gereModifChoixMontantLibre === 'function') { 5604 gereModifChoixMontantLibre(); 5605 } 5606 5607 $("#a_btChoixPaiementReserver, #a_btChoixPaiementANCV").click(function(){ 5608 var typePaiement = $(this).data('typepaiement') || ''; 5609 valideReservationAvecPaiement(typePaiement); 5610 }); 5611 5612 initPopinConfirmeEANCV(); 5613 5614 $("#a_btChoixPaiementAcompte, #a_btChoixPaiementAcompteANCV").click(function(){ 5615 var typePaiement = $(this).data('typepaiement') || ''; 5616 $(".a_btChoixPaiement").hide(); 5617 $(".a_btnAttenteConfirm").show(); 5618 if (casesCochees() === true) { 5619 $.ajax({ 5620 type: "POST", 5621 url: urlAJAX, 5622 data: {type: "affectPaiementCB", choixPaiement: "acompte", typePaiement: typePaiement}, 5623 beforeSend: function(){ 5624 5625 }, 5626 success: function(result){ 5627 eval("var tabResult="+result); 5628 if (tabResult.code == errDossierNull) { 5629 retourEtape1(tabResult.msg); 5630 } else if (result.modifDateHorsExe == 'O') { 5631 afficheMsgErrModifDateHorsExe(result.msg); 5632 } 5633 else if (tabResult.errTechnq) { 5634 afficheMsgErrTechnq(tabResult.msg, tabResult.titre, tabResult.ident, true); 5635 } 5636 else { 5637 if (tabResult.code == "OK") { 5638 majFormPaybox(tabResult); 5639 validerFormulairePaybox(); 5640 } 5641 else { 5642 alertAMalibu(tabResult.msg); 5643 } 5644 } 5645 } 5646 }); 5647 } 5648 else { 5649 $(".a_btnAttenteConfirm").hide(); 5650 $(".a_btChoixPaiement").show(); 5651 } 5652 }); 5653 5654 $("#div_btnConfirmer > a").click(function(){ 5655 $(this).hide(); 5656 $(".a_btnAttenteConfirm").show(); 5657 if (casesCochees() === true) { 5658 var urlHref = "etape"+ $('#div_btnConfirmer').attr('data-idPageNext')+".php"; 5659 if (location.search.indexOf("PHPSESSID") > -1) 5660 urlHref+=location.search; 5661 else 5662 urlHref+=location.search+"&"+idSession; 5663 document.location=urlHref; 5664 } 5665 else { 5666 $(".a_btnAttenteConfirm").hide(); 5667 $(this).show(); 5668 } 5669 }); 5670 5671 if ($('.div_choixResaProp').length>0) { 5672 $('.div_choixResaProp a').click(function(){ 5673 $('.div_choixResaProp a').removeClass('actif'); 5674 $(this).addClass('actif'); 5675 var divAAfficher = $('#'+$(this).attr('data-div')); 5676 var divACacher = $('.' + $('.div_choixResaProp').attr('data-divtohide')); 5677 divACacher.hide(); 5678 divAAfficher.show(); 5679 majRecapPrixChoixResaProp($(this).data('type')); 5680 }); 5681 } 5682 5683 init_btnsAfficheDetailsMoyensPaiements(); 5684 5685 if (typeof initSaisieCB_centralPay !== 'undefined') { 5686 initSaisieCB_centralPay(); 5687 } 5688 5689 if (typeof initSaisieANCV_CVCO !== 'undefined') { 5690 initSaisieANCV_CVCO(false); 5691 } 5692 5693 if (typeof initSaisieChequeKDO !== 'undefined') { 5694 console.log('initSaisieChequeKDO '); 5695 initSaisieChequeKDO(); 5696 } 5697 if ($('.div_unPaiementPossible').length>0) { 5698 $('body').delegate('.div_unPaiementPossible > div.titre', 'click', function(){ 5699 $('.div_unPaiementPossible').removeClass('open'); 5700 $(this).parent().addClass('open'); 5701 }); 5702 } 5703 initChoixPaiementAncv(); 5704 $('.inpt_modifPrixChambreCentraleProp, #inpt_modifPrixCentraleProp, #inpt_modifFDResaProp').change(function() { 5705 updateAffichagePrixBuroProp(); 5706 }); 5707 5708 initModalTaxeSejour(); 5709 initActionsMotMagique(true); 5710 5711 })(jQuery); 5712} 5713 5714function masqueBtnsValidationSansPaiement() { 5715 (function($) { 5716 $(".a_btChoixPaiement").hide(); 5717 $('.div_validePaiementSansPaiement>button').hide(); 5718 $('.div_valideResaConfirmation').hide(); 5719 $('.div_valideResaDureeLimitee').hide(); 5720 $(".a_btnAttenteConfirm").show(); 5721 $('.errSaisie').removeClass('errSaisie'); 5722 $('#div_btnsResaProp_LD .div_msgErreurs, #div_btnsResaProp_LD .div_msgErreurs p, #div_btnsResaProp_LD .sp_msgErreur').hide(); 5723 })(jQuery); 5724} 5725 5726function reafficheBtnsValidationSansPaiement() { 5727 (function($) { 5728 $('.a_btnAttenteConfirm').hide(); 5729 $('.a_btChoixPaiement').show(); 5730 $('.div_validePaiementSansPaiement>button').show(); 5731 })(jQuery); 5732} 5733 5734function traiteReservationAvecConfirmation() { 5735 var tabParams = {}; 5736 (function ($) { 5737 tabParams['processus'] = $("input:radio[name='resaConfirmation_processus']:checked").val(); 5738 tabParams['nbminutes_delai_client'] = $('#resaConfirmation_delaiReponseClient').val(); 5739 tabParams['nbminutes_delai_prop'] = $('#resaConfirmation_delaiReponseProp').val(); 5740 tabParams['type_notif_client'] = $("input:radio[name='resaConfirmation_typeNotificationClient']:checked").val(); 5741 tabParams['notif_client_refus_prop'] = $("input:radio[name='resaConfirmation_notifRefus']:checked").val(); 5742 tabParams['commentaire_proprio'] = $('#resaConfirmation_commentaireProprietaire').val(); 5743 tabParams['type'] = 'enregistreInfosResaConfirmation'; 5744 $.ajax({ 5745 type: "POST", 5746 url: urlAJAX, 5747 data: tabParams, 5748 success: function (result) { 5749 if (result === 'OK') { 5750 if (location.search.indexOf("PHPSESSID") > -1) { 5751 location.href = "etape4.php" + location.search; 5752 } else { 5753 location.href = "etape4.php" + location.search + "&" + idSession; 5754 } 5755 } else { 5756 alertAMalibu('La réservation a bien été créée en intention mais une erreur est survenue lors de l\'enregistrement du paramétrage. \n\ 5757 Vous pouvez paramétré les délais et le processus depuis le détail du dossier du bureau ITEA.', location.href = "etape4.php" + location.search); 5758 reafficheBtnsValidationSansPaiement(); 5759 } 5760 } 5761 }); 5762 })(jQuery); 5763} 5764function traiteReservationDureeLimitee() { 5765 var tabParams = {}; 5766 (function ($) { 5767 tabParams['processus'] = 'T'; // processus T = durée limitée 5768 tabParams['nbminutes_delai_client'] = $('#resaDureeLimitee_delaiReponseClient').val(); 5769 tabParams['type_notif_client'] = $("input:radio[name='resaDureeLimitee_typeNotificationClient']:checked").val(); 5770 tabParams['envoi_confirme_proprio'] = $("input:radio[name='resaDureeLimitee_envoiConfirmeProprio']:checked").val(); 5771 tabParams['type'] = 'enregistreInfosResaConfirmation'; 5772 $.ajax({ 5773 type: "POST", 5774 url: urlAJAX, 5775 data: tabParams, 5776 success: function (result) { 5777 if (result === 'OK') { 5778 if (location.search.indexOf("PHPSESSID") > -1) { 5779 location.href = "etape4.php" + location.search; 5780 } else { 5781 location.href = "etape4.php" + location.search + "&" + idSession; 5782 } 5783 } else { 5784 alertAMalibu('La réservation a bien été créée en intention mais une erreur est survenue lors de l\'enregistrement du paramétrage. \n\ 5785 Vous pouvez paramétré les délais et le processus depuis le détail du dossier du bureau ITEA.', location.href = "etape4.php" + location.search); 5786 reafficheBtnsValidationSansPaiement(); 5787 } 5788 } 5789 }); 5790 })(jQuery); 5791} 5792 5793function valideChampsReservationAvecConfirmation() { 5794 var estValide = true; 5795 (function ($) { 5796 if ($('#div_paiementPossible_resaConfirmation').length === 0) { 5797 retour = false;
5798 } 5799 if ($('#resaConfirmation_delaiReponseProp').val() == '' || $('#resaConfirmation_delaiReponseClient').val() == '') { 5800 estValide = false; 5801 } 5802 if (!$("input:radio[name='resaConfirmation_typeNotificationClient']").is(":checked")) { 5803 estValide = false; 5804 } 5805 if (!$("input:radio[name='resaConfirmation_processus']").is(":checked")) { 5806 estValide = false; 5807 } 5808 if (estValide) { 5809 $('#div_msgErreurChampsResaConfirmation').hide(); 5810 } else { 5811 $('#div_msgErreurChampsResaConfirmation').show(); 5812 $('.div_valideResaConfirmation').show(); 5813 } 5814 })(jQuery); 5815 return estValide; 5816} 5817 5818function valideChampsReservationDureeLimitee() { 5819 var estValide = true; 5820 (function ($) { 5821 if ($('#resaDureeLimitee_delaiReponseClient').val() == '') { 5822 estValide = false; 5823 } 5824 if (!$("input:radio[name='resaDureeLimitee_typeNotificationClient']").is(":checked")) { 5825 estValide = false; 5826 } 5827 if (estValide) { 5828 $('#div_msgErreurChampsResaDureeLimitee').hide(); 5829 } else { 5830 $('#div_msgErreurChampsResaDureeLimitee').show(); 5831 $('.div_valideResaDureeLimitee').show(); 5832 } 5833 })(jQuery); 5834 return estValide; 5835} 5836 5837function initChangeMontantsCentralPayByOngletResaProp() { 5838 (function($) { 5839 $('.a_ongletResaProp').on('click', function() { 5840 var type = $(this).data('type'); 5841 if (type === 'LD') { 5842 updateAffichagePaiementCentralPayBuroPropResaLD(); 5843 showAndHidePaiementOptionsForPaiementLDSurBuroProp(); 5844 } else { 5845 updateAffichagePrixBuroProp(); 5846 showAndHidePaiementOptionsForPaiementCentraleSurBuroProp(); 5847 } 5848 }); 5849 // on simule un clic sur l'onglet actif à l'initialisation de la page pour être sur d'avoir les bonnes valeurs 5850 $('.a_ongletResaProp.actif').click(); 5851 })(jQuery); 5852} 5853 5854function showAndHidePaiementOptionsForPaiementCentraleSurBuroProp() { 5855 (function($) { 5856 $('.pourPaiementLD').hide(); 5857 $('input[name="choixPaiementCB"][value="montantlibre"]').closest('div').hide(); 5858 $('#inpt_valideAutorisationPriseGarantie').closest('div').hide(); 5859 })(jQuery); 5860} 5861 5862function showAndHidePaiementOptionsForPaiementLDSurBuroProp() { 5863 (function($) { 5864 $('.pourPaiementLD').show(); 5865 $('input[name="choixPaiementCB"][value="montantlibre"]').closest('div').show(); 5866 $('#inpt_valideAutorisationPriseGarantie').closest('div').show(); 5867 })(jQuery); 5868} 5869 5870function initChoixPaiementAncv() { 5871 (function ($) { 5872 if ($('#div_paiementPossibleANCV').length === 0) { 5873 return; 5874 } 5875 5876 var width = $(window).width() - 100; 5877 $('#div_popinPaiementEAncv').dialog({ 5878 modal: true, 5879 autoOpen: false, 5880 width: 'auto', 5881 height: 'auto', 5882 maxWidth: width 5883 }); 5884 5885 $('input[name="choixTypeAncv"]').on('change', function () { 5886 if ($('#maintenanceAncvCvco').length === 0) { 5887 return; 5888 } 5889 if ($(this).val() === 'cvco') { 5890 $('#maintenanceAncvCvco').show(); 5891 $('#btn_choixANCV').hide(); 5892 } else if ($(this).val() === 'eancv') { 5893 $('#maintenanceAncvCvco').hide(); 5894 $('#btn_choixANCV').show(); 5895 } 5896 }); 5897 5898 $('#btn_choixANCV').on('click', function () { 5899 var typeAncv = $('input[name="choixTypeAncv"]:checked').val(); 5900 if (typeAncv === 'eancv') { 5901 $('#div_popinPaiementEAncv').dialog('open'); 5902 } else if (typeAncv === 'cvco') { 5903 $('#div_popinPaiementAncvCvco').dialog('open'); 5904 } 5905 }); 5906 })(jQuery); 5907} 5908 5909function valideReservationAvecPaiement_old(typePaiement) { 5910 (function($){ 5911 $(".a_btChoixPaiement").hide(); 5912 $(".a_btnAttenteConfirm").show(); 5913 $('#div_btnsResaProp_LD .div_msgErreurs, #div_btnsResaProp_LD .div_msgErreurs p, #div_btnsResaProp_LD .sp_msgErreur').hide(); 5914 var nouveauFraisDossier=null, nouveauPrixLocation = null, tabPrixChambre=[]; 5915 5916 var montantsSaisisCorrects = true; 5917 var regexMontants = new RegExp('^[0-9]+\.?[0-9]{0,2}$'); 5918 if ($('#inpt_modifFDResaProp').length>0) { 5919 nouveauFraisDossier = $('#inpt_modifFDResaProp').val(); 5920 if (!regexMontants.test(nouveauFraisDossier)) { 5921 montantsSaisisCorrects = false;
5922 $('#inpt_modifFDResaProp').addClass('errSaisie'); 5923 $('.sp_msgSaisieMontantErronee').show(); 5924 } 5925 // Si A, on doit vérifier si le montant saisi est à la baisse 5926 if($('#inpt_modifFDResaProp').attr('data-typemodif') !== 'A'){ 5927 if(parseFloat(nouveauFraisDossier)> parseFloat($('#inpt_modifFDResaProp').attr('data-value'))){ 5928 montantsSaisisCorrects = false; 5929 $('#inpt_modifFDResaProp').addClass('errSaisie'); 5930 $('.sp_msgSaisieMontantErronee').show(); 5931 } 5932 } 5933 } 5934 5935 // Ensuite on va regarder si les champs de modif de prix sont saisis et on va ajouter les prix saisis 5936 if ($('#inpt_modifPrixCentraleProp').length>0) { 5937 var prixLocationReference = $('#inpt_modifPrixCentraleProp').attr('data-prixReference'); 5938 nouveauPrixLocation = $('#inpt_modifPrixCentraleProp').val(); 5939 if (!regexMontants.test(nouveauPrixLocation)) { 5940 $('.sp_msgSaisieMontantErronee').show(); 5941 montantsSaisisCorrects = false; 5942 $('#inpt_modifPrixCentraleProp').addClass('errSaisie'); 5943 } 5944 if(parseFloat(nouveauPrixLocation)>parseFloat(prixLocationReference)){ 5945 montantsSaisisCorrects = false; 5946 $('.sp_msgSaisieMontantSuperieur').show(); 5947 $('#inpt_modifPrixCentraleProp').addClass('errSaisie'); 5948 } 5949 } 5950 if ( $('.inpt_modifPrixChambreCentraleProp').length>0) { 5951 var nbChambresModif = 0; 5952 $('.inpt_modifPrixChambreCentraleProp').each(function(){ 5953 var numeroChambre = $(this).attr('data-numeroChambre'); 5954 var prixChambre = $(this).val(); 5955 var prixReference = $('#prixChambreCentralePropReference_'+numeroChambre).val(); 5956 if (!regexMontants.test(prixChambre)) { 5957 montantsSaisisCorrects = false; 5958 $('.sp_msgSaisieMontantErronee').show(); 5959 $(this).addClass('errSaisie'); 5960 } else if(parseFloat(prixChambre)>parseFloat(prixReference)){ 5961 montantsSaisisCorrects = false; 5962 $('.sp_msgSaisieMontantSuperieur').show(); 5963 $(this).addClass('errSaisie'); 5964 } 5965 else{ 5966 tabPrixChambre[nbChambresModif] = {numeroChambre:numeroChambre, prixChambre:prixChambre}; 5967 } 5968 nbChambresModif++; 5969 }); 5970 } 5971 var montantPaiement = null; 5972 if ($('#input_montantVersement').length>0 ) { 5973 montantPaiement = $('#input_montantVersement').val(); 5974 if (!regexMontants.test(montantPaiement)) { 5975 montantsSaisisCorrects = false; 5976 $('#input_montantVersement').addClass('errSaisie'); 5977 $('.sp_msgSaisieMontantErronee').show(); 5978 } 5979 var solde = $('#input_montantVersement').attr('data-solde'); 5980 // Si A, on doit vérifier si le montant saisi est à la baisse 5981 if (parseFloat(montantPaiement) > parseFloat(solde)) { 5982 montantsSaisisCorrects = false; 5983 $('#input_montantVersement').addClass('errSaisie'); 5984 $('.sp_msgSaisieMontantSuperieur').show(); 5985 } 5986 if(!montantsSaisisCorrects){ 5987 $('#div_btnPaiementCb .div_msgErreurs').show('fast'); 5988 } 5989 } 5990 5991 var choixPaiement = ''; 5992 if ($('.div_choixMontantPayer:visible').length>0) { 5993 choixPaiement = $('input[name=choixPaiementCB]:visible:checked').val(); 5994 if (choixPaiement!=='montantlibre') { 5995 montantPaiement = null; 5996 } 5997 } 5998 5999 if (casesCochees() === true && montantsSaisisCorrects) { 6000 affectPaiementCB(nouveauPrixLocation, nouveauFraisDossier, tabPrixChambre, montantPaiement, typePaiement, choixPaiement); 6001 } 6002 else { 6003 $(".a_btnAttenteConfirm").hide(); 6004 $(".a_btChoixPaiement").show(); 6005 $('#div_btnsResaProp_centrale .div_msgErreurs, #div_btnsResaProp_centrale .div_msgErreurs p').show('fast'); 6006 $('#div_boutonsResaProp_centrale .div_msgErreurs, #div_boutonsResaProp_centrale .div_msgErreurs p').show('fast'); 6007 reactiveBoutonsPaiement(); 6008 } 6009 })(jQuery); 6010} 6011 6012function valideReservationAvecPaiement(typePaiement){ 6013 (function($){ 6014 $(".a_btChoixPaiement").hide(); 6015 $(".a_btnAttenteConfirm").show(); 6016 $('#div_btnsResaProp_LD .div_msgErreurs, #div_btnsResaProp_LD .div_msgErreurs p, #div_btnsResaProp_LD .sp_msgErreur').hide(); 6017 var objPrix = { 6018 montantsSaisisCorrects : true, 6019 nouveauFraisDossier : null, 6020 nouveauPrixLocation : null, 6021 montantPaiement: null, 6022 montantAcompte: null, 6023 montantPercu: null, 6024 dateLimite: null, 6025 choixPaiement: '', 6026 tabPrixChambre: [] 6027 }; 6028 6029 var objInputs = getInputsByTypeResa(); 6030 6031 var inputMontantFD = objInputs.inputsCentrale.montantFd; 6032 if (inputMontantFD.length > 0) { 6033 objPrix.nouveauFraisDossier = inputMontantFD.val(); 6034 getErrSaisieMontantErrone(objPrix.nouveauFraisDossier, objPrix, inputMontantFD); 6035 // Si A, on doit vérifier si le montant saisi est à la baisse 6036 if (inputMontantFD.attr('data-typemodif') !== 'A') { 6037 var montantReferenceFD = inputMontantFD.attr('data-value'); 6038 getErrSaisieMontantSuperieur(objPrix.nouveauFraisDossier, montantReferenceFD, objPrix, inputMontantFD); 6039 } 6040 } 6041 6042 // Ensuite on va regarder si les champs de modif de prix sont saisis et on va ajouter les prix saisis 6043 if (estEnPaiementLD()) {
6044 getNouveauMontantResaProp(objPrix, 'nouveauPrixLocation', objInputs.inputsLD.montantLoc); 6045 getNouveauPrixLocationChambreResaProp(objPrix, objInputs.inputsLD.montantLocChambre); 6046 6047 // on soustrait le montant loc par défaut puis on ajoute le nouveau pour garder les suppléments (comme la tds par ex) 6048 var prixTotal = (parseFloat($('#inpt_prixTotalResaProp').val()) - parseFloat($('#inpt_prixLocResaProp').val())) + parseFloat(objInputs.inputsLD.montantLoc.val()); 6049 getNouveauMontantResaProp(objPrix, 'montantAcompte', objInputs.inputsLD.montantAcompte, prixTotal); 6050 getNouveauMontantResaProp(objPrix, 'montantPercu', objInputs.inputsLD.montantPercu, prixTotal); 6051 if (objInputs.inputsLD.dateLimite.length > 0) { 6052 objPrix.dateLimite = objInputs.inputsLD.dateLimite.val(); 6053 getErrSaisieDateErrone(objInputs.inputsLD.dateLimite.val(), objPrix, objInputs.inputsLD.dateLimite); 6054 } 6055 } else { 6056 var valReferencePrixLoc = objInputs.inputsCentrale.montantLoc.attr('data-prixReference'); 6057 getNouveauMontantResaProp(objPrix, 'nouveauPrixLocation', objInputs.inputsCentrale.montantLoc, valReferencePrixLoc); 6058 getNouveauPrixLocationChambreResaProp(objPrix, objInputs.inputsCentrale.montantLocChambre); 6059 } 6060 6061 var inputVersement = $('#input_montantVersement'); 6062 if (inputVersement.is(':visible')) { 6063 var valRefVersement = inputVersement.attr('data-solde'); 6064 getNouveauMontantResaProp(objPrix, 'montantPaiement', inputVersement, valRefVersement); 6065 if (inputVersement.length > 0 && !objPrix.montantsSaisisCorrects) { 6066 $('#div_btnPaiementCb .div_msgErreurs').show('fast'); 6067 } 6068 } 6069 6070 if ($('.div_choixMontantPayer:visible').length>0) { 6071 objPrix.choixPaiement = $('input[name=choixPaiementCB]:visible:checked').val(); 6072 if (objPrix.choixPaiement !== 'montantlibre') { 6073 objPrix.montantPaiement = null; 6074 } 6075 } 6076 6077 if (casesCochees() === true && objPrix.montantsSaisisCorrects) { 6078 affectPaiementCB(objPrix.nouveauPrixLocation, objPrix.nouveauFraisDossier, objPrix.tabPrixChambre, objPrix.montantPaiement, typePaiement, 6079 objPrix.choixPaiement, objPrix.montantAcompte, objPrix.montantPercu, objPrix.dateLimite); 6080 } else { 6081 $(".a_btnAttenteConfirm").hide(); 6082 $(".a_btChoixPaiement").show(); 6083 $('#div_btnsResaProp_centrale .div_msgErreurs, #div_btnsResaProp_centrale .div_msgErreurs p').show('fast'); 6084 $('#div_boutonsResaProp_centrale .div_msgErreurs, #div_boutonsResaProp_centrale .div_msgErreurs p').show('fast'); 6085 reactiveBoutonsPaiement(typePaiement); 6086 } 6087 })(jQuery); 6088} 6089 6090function getNouveauMontantResaProp(objPrix, labelMontant, input, valReference) { 6091 if (input.length === 0) { 6092 return; 6093 } 6094 var val = input.val(); 6095 objPrix[labelMontant] = val; 6096 getErrSaisieMontantErrone(val, objPrix, input); 6097 if (!isNullOrUndefinedOrEmpty(valReference)) { 6098 getErrSaisieMontantSuperieur(val, valReference, objPrix, input); 6099 } 6100} 6101 6102function getNouveauPrixLocationChambreResaProp(objPrix, inputs) { 6103 (function ($) { 6104 if (inputs.length === 0) { 6105 return; 6106 } 6107 var nbChambresModif = 0; 6108 inputs.each(function () { 6109 var numeroChambre = $(this).attr('data-numeroChambre'); 6110 var prixChambre = $(this).val(); 6111 objPrix.tabPrixChambre[nbChambresModif] = {numeroChambre: numeroChambre, prixChambre: prixChambre}; 6112 6113 var prixReference = $('#prixChambreCentralePropReference_' + numeroChambre).val(); 6114 getErrSaisieMontantErrone(prixChambre, objPrix, $(this)); 6115 getErrSaisieMontantSuperieur(prixChambre, prixReference, objPrix, $(this)); 6116 nbChambresModif++; 6117 }); 6118 6119 })(jQuery); 6120} 6121 6122function getErrSaisieMontantErrone(montant, objPrix, input) { 6123 var regexMontant = new RegExp('^[0-9]+\.?[0-9]{0,2}$'); 6124 if (!regexMontant.test(montant.toString())) { 6125 objPrix.montantsSaisisCorrects = false;
6126 input.addClass('errSaisie'); 6127 jQuery('.sp_msgSaisieMontantErronee').show(); 6128 } 6129} 6130 6131function getErrSaisieMontantSuperieur(montantSaisi, montantReference, objPrix, input) { 6132 if (parseFloat(montantSaisi) > parseFloat(montantReference)) { 6133 objPrix.montantsSaisisCorrects = false; 6134 input.addClass('errSaisie'); 6135 jQuery('.sp_msgSaisieMontantSuperieur').show(); 6136 } 6137} 6138 6139function getErrSaisieDateErrone(date, objPrix, input) { 6140 var regexDate = new RegExp('^[0-9]{2}/[0-9]{2}/[0-9]{4}$'); 6141 if (!regexDate.test(date)) { 6142 objPrix.montantsSaisisCorrects = false; 6143 input.addClass('errSaisie'); 6144 } 6145} 6146 6147function getInputsByTypeResa() { 6148 var objInputs = {}; 6149 (function ($) { 6150 var objInputsCentrale = {}; 6151 var objInputsLD = {}; 6152 6153 objInputsCentrale.montantFd = $('#inpt_modifFDResaProp:visible'); 6154 6155 objInputsCentrale.montantLoc = $('#inpt_modifPrixCentraleProp'); 6156 objInputsLD.montantLoc = $('#inpt_modifPrixLocationResaProp'); 6157 6158 objInputsCentrale.montantLocChambre = $('.inpt_modifPrixChambreCentraleProp'); 6159 objInputsLD.montantLocChambre = $('.inpt_modifPrixChambreResaProp'); 6160 6161 objInputsLD.montantAcompte = $('#inpt_modifAcompteResaProp:visible'); 6162 objInputsLD.montantPercu = $('#inpt_modifMontantPercu:visible'); 6163 objInputsLD.dateLimite = $('#inpt_nouvelleDateLimite:visible'); 6164 6165 objInputs.inputsCentrale = objInputsCentrale; 6166 objInputs.inputsLD = objInputsLD; 6167 })(jQuery); 6168 return objInputs; 6169} 6170 6171function estEnPaiementLD() { 6172 var estEnPaiementLD = true; 6173 (function ($) { 6174 if (!estSurBureauProprietaire()) { 6175 estEnPaiementLD = false; 6176 return; 6177 } 6178 if ($('#peutFairePaiementLD').length === 0) { 6179 estEnPaiementLD = false; 6180 return; 6181 } 6182 if ($('.div_choixResaProp').length > 0 && $('.a_ongletResaProp[data-type="LD"]').hasClass('actif') === false) { 6183 estEnPaiementLD = false; 6184 return; 6185 } 6186 })(jQuery); 6187 return estEnPaiementLD; 6188} 6189 6190function affectPaiementCB(nouveauPrixLocation, nouveauFraisDossier, tabPrixChambre, montantPaiement, typePaiement, choixPaiement, nouveauMontantAcompte, nouveauMontantPercu, nouvelleDateLimite){ 6191 (function($){ 6192 var params = { 6193 type: "affectPaiementCB" 6194 }; 6195 if(nouveauPrixLocation !== null){ 6196 params.prixLocation = nouveauPrixLocation; 6197 } 6198 if(nouveauFraisDossier !== null){ 6199 params.nouveauFraisDossier = nouveauFraisDossier; 6200 } 6201 if(tabPrixChambre.length> 0){ 6202 params.tabPrixChambre= tabPrixChambre; 6203 } 6204 // pour la modif de résa bureau, on peut définir le montant voulu 6205 if(montantPaiement){ 6206 params.MONTANT_PAIEMENT = $('#input_montantVersement').val(); 6207 } 6208 if (estEnPaiementLD()) { 6209 params.typeResa = 'locationDirecte'; 6210 } 6211 if (nouveauMontantAcompte !== null) { 6212 params.nouvelAcompte = nouveauMontantAcompte; 6213 } 6214 if (nouveauMontantPercu !== null) { 6215 params.montantPercu = nouveauMontantPercu; 6216 } 6217 if (nouvelleDateLimite !== null) { 6218 params.nouvelleDateLimite = nouvelleDateLimite; 6219 } 6220 params.typePaiement = typePaiement; 6221 if (typePaiement === 'PLEDG') { 6222 params.typePaiement = 'CENTRALPAY'; // PLEDG/CentralPay c'est pareil pour la création de la résa, on change juste l'affichage côté client 6223 if ($('#div_paiementPossiblePledg .div_choixMontantPayer input[name=choixPaiementPledg]').length > 0) { 6224 params.MONTANT_PAIEMENT = $('#div_paiementPossiblePledg .div_choixMontantPayer input[name=choixPaiementPledg]').data('montant'); 6225 } 6226 } 6227 params.choixPaiement = choixPaiement; 6228 jQuery.ajax({ 6229 type: "POST", 6230 url: urlAJAX, 6231 data: params, 6232 beforeSend: function(){ 6233 afficheLoaderGlobal_site(); 6234 }, 6235 success: function(result){ 6236 eval("var tabResult="+result); 6237 effaceLoaderGlobal_site(); 6238 if (tabResult.code == errDossierNull) { 6239 retourEtape1(tabResult.msg); 6240 } 6241 else if (tabResult.errTechnq) { 6242 afficheMsgErrTechnq(tabResult.msg, tabResult.titre, tabResult.ident, true); 6243 } 6244 else { 6245 if (tabResult.code == "OK") { 6246 if (typePaiement === 'PLEDG') { 6247 lanceTimerVerificationDureeEtatV(tabResult.idObjet); 6248 validerPaiementPledg(tabResult); 6249 setIdObjetApresAffectPaiement(tabResult.idObjet); // permet de détecter la résa comme créée si on tente de payer ensuite par un autre moyen 6250 } else if (tabResult.centralPay==='O') { 6251 console.log('affectPaiementCB tabResult : ',tabResult); 6252 $('#div_saisieCB_centralPay #inpt_idObjet').val(tabResult.idObjet); 6253 $('#inpt_idObjetANCV').val(tabResult.idObjet); 6254 $('#inpt_idObjetCheque').val(tabResult.idObjet); 6255 $('#div_saisieCB_centralPay #inpt_montantCB').val(tabResult.montant); 6256 valideSaisieCB_centralPay(tabResult.idObjet, tabResult.montant); 6257 lanceTimerVerificationDureeEtatV(tabResult.idObjet); 6258 // Je masque le bloc de paiement eANCV pour éviter que le client essaye de l'utiliser alors que la réservation a été créée 6259 // En le laissant actif on donne la possibilité de refaire un appel AJAX affectPaiementCB qui va forcément retourner une erreur 6260 $('#div_paiementPossibleEANCV').hide(); 6261 $('input[name=choixPaiementCB]').attr('disabled', 'disabled'); 6262 } else if (tabResult.chqkdo === 'O') { 6263 validePaiementChequeKDO(tabResult); 6264 } else if (tabResult.ancvCvco === 'O') { 6265 valideSaisieANCV_CVCO(tabResult); 6266 $('.formCentralPay').formCentralPay('setMontantEtIdObjet', tabResult.montant, tabResult.idObjet); 6267 } 6268 else { 6269 majFormPaybox(tabResult); 6270 if(window.foncQdFini_redirigePagePaiement){ // permet d'ajouter un evt pour redirection vers page paiement spécifique au look 6271 foncQdFini_redirigePagePaiement(); 6272 } 6273 validerFormulairePaybox(); 6274 } 6275 } 6276 else { 6277 if (tabResult.ancvCvco === 'O') { 6278 afficherErreurInitialisationAncvCvco(tabResult); 6279 } else { 6280 alertAMalibu(tabResult.msg); 6281 } 6282 reactiveBoutonsPaiement(); 6283 } 6284 } 6285 } 6286 }); 6287 })(jQuery); 6288} 6289 6290function creerObjetPayablePourPaiementCentralPay(){ 6291 valideReservationAvecPaiement('CENTRALPAY'); 6292} 6293 6294function majObjetPayablePourPaiementCentralPay(){ 6295 valideReservationAvecPaiement('CENTRALPAY'); 6296} 6297 6298function creerObjetPayablePourPaiementAncvCVCO(){ 6299 valideReservationAvecPaiement('ANCV_CVCO'); 6300} 6301 6302function creerObjetPayablePourPaiementChequeKDO(){ 6303 valideReservationAvecPaiement('CHQ_KDO'); 6304} 6305 6306function creerObjetPayablePourPaiementPledg() { 6307 valideReservationAvecPaiement('PLEDG'); 6308} 6309 6310function lanceTimerVerificationDureeEtatV(idObjet){ 6311 if (modifieResaExistante()) { 6312 return; 6313 } 6314 setTimeout(function () { 6315 verificationDureeEtatV(idObjet); 6316 }, 60000); 6317} 6318 6319function verificationDureeEtatV(idObjet){ 6320 var tabIdObjet = idObjet.split('_'); 6321 var instance = tabIdObjet[0]; 6322 var exercice = tabIdObjet[2]; 6323 jQuery.ajax({ 6324 type: 'POST', 6325 url: '/lib_2/ajax/passerelleBureauLocal.php', 6326 data: {url: 'lib_bureau/ajax/centralPay.php', instance: instance, exercice: exercice, idObjet: idObjet, action: 'verificationDureeEtatV'}, 6327 success: function(result){ 6328 if (!result || result === 'KO') { 6329 // TODO : Pop-in d'info ? 6330 if (typeof etape4VerifEtatV == 'function'){ 6331 etape4VerifEtatV(); 6332 } 6333 var urlEtape4 = 'etape4.php'+location.search+'&CentralPay=KO&dureeEtatV=KO'; 6334 if (location.search.indexOf("PHPSESSID") <= -1) { 6335 urlEtape4 += '&'+idSession; 6336 } 6337 location.href = urlEtape4; 6338 } 6339 if (result === 'ETAT_OK' || result.code === 'OK') { 6340 if (typeof etape4VerifEtatV == 'function'){ 6341 etape4VerifEtatV(); 6342 } 6343 var urlEtape4 = 'etape4.php' + location.search; 6344 if (location.search.indexOf("PHPSESSID") <= -1) { 6345 urlEtape4 += '&' + idSession; 6346 } 6347 if (result.etat_dossier === 'r') { 6348 urlEtape4 += '¢ralPay=OK'; 6349 } 6350 location.href = urlEtape4; 6351 } 6352 }, 6353 error: function(repJSON){ 6354 console.log(repJSON); 6355 }, 6356 complete: function(){ 6357 lanceTimerVerificationDureeEtatV(idObjet); 6358 } 6359 }); 6360} 6361 6362function retourValidationPaiementCB_centralPay(params){ 6363 afficheLoaderGlobal_site(); 6364 var query = 'centralPay=OK'; 6365 if (params === true || params.pbCaution === true) { 6366 query += '&pbCaution=O'; 6367 }
6368 if ((jQuery('#inpt_valideAutorisationDebitSolde') && jQuery('#inpt_valideAutorisationDebitSolde').is(':checked')) || params.avecDebitSoldeAuto) { 6369 query += '&avecDebitSolde=O'; 6370 } 6371 if ((jQuery('#inpt_valideAutorisationPriseDeCaution') && jQuery('#inpt_valideAutorisationPriseDeCaution').is(':checked')) || params.avecCaution) { 6372 query += '&avecCaution=O'; 6373 } 6374 if (params.idObjet) { 6375 query += '&idObjet=' + params.idObjet; 6376 } 6377 if (params.amount) { 6378 query += '&amount=' + params.amount; 6379 } 6380 if(!estSurResa()){ 6381// envoiMailControlCentralPaySurCompteCli(); 6382// window.location.reload(); 6383 var urlReload = location.href; 6384 if (location.search.length===0) { 6385 urlReload += '?'+query; 6386 } else { 6387 urlReload += '&'+query; 6388 } 6389 location.href = urlReload; 6390 return; 6391 } 6392 var urlEtape4 = 'etape4.php'+location.search+'&'+query; 6393 if (location.search.indexOf("PHPSESSID") <= -1) { 6394 urlEtape4 += '&'+idSession; 6395 } 6396 location.href = urlEtape4; 6397} 6398 6399function retourValidationPaiementANCV_CVCO(montantPaye){ 6400 afficheLoaderGlobal_site(); 6401 if(!estSurResa()){ 6402 getPopinConfirmationPaiementCompteCli(montantPaye); 6403 var urlReload = location.href; 6404 if (location.search.length===0) { 6405 urlReload += '?ancvCvco=OK'; 6406 } else { 6407 urlReload += '&ancvCvco=OK'; 6408 } 6409 location.href = urlReload; 6410 return; 6411 } 6412 var urlEtape4 = 'etape4.php'+location.search+'&ancvCvco=OK'; 6413 if (location.search.indexOf("PHPSESSID") <= -1) { 6414 urlEtape4 += '&'+idSession; 6415 } 6416 location.href = urlEtape4; 6417} 6418 6419 6420function retourValidationPaiementChequeKDO(montantPaye){ 6421 afficheLoaderGlobal_site(); 6422 if(!estSurResa()){ 6423 getPopinConfirmationPaiementCompteCli(montantPaye); 6424 var urlReload = location.href; 6425 location.href = urlReload; 6426 return; 6427 } 6428 var urlEtape4 = 'etape4.php'+location.search; 6429 if (location.search.indexOf("PHPSESSID") <= -1) { 6430 urlEtape4 += '&'+idSession; 6431 } 6432 location.href = urlEtape4; 6433} 6434 6435/** 6436 * Affiche une popin de confirmation de paiement suite à un paiement ANCV CVCO 6437 * @param {float} montantPaye 6438 */ 6439function getPopinConfirmationPaiementCompteCli(montantPaye) { 6440 (function($) { 6441 $('#popinValidationPaiementAncvCvco span').html(montantPaye + ''); 6442 6443 var width = $(window).width() - 100; 6444 $('#popinValidationPaiementAncvCvco').dialog({ 6445 modal: true, 6446 dialogClass: 'no-close', 6447 closeOnEscape: false, 6448 width: 'auto', 6449 height: 'auto', 6450 maxWidth: width 6451 }); 6452 })(jQuery); 6453} 6454 6455function retourValidationPaiementPledg() { 6456 afficheLoaderGlobal_site(); 6457 if (!estSurResa()) { 6458 var urlReload = location.href; 6459 location.href = urlReload; 6460 return; 6461 } 6462 var urlEtape4 = 'etape4.php' + location.search; 6463 if (location.search.indexOf("PHPSESSID") <= -1) { 6464 urlEtape4 += '&' + idSession; 6465 } 6466 urlEtape4 += '¢ralPay=OK'; 6467 location.href = urlEtape4; 6468} 6469 6470function envoiMailControlCentralPaySurCompteCli(){ 6471 (function($) { 6472 $.ajax({ 6473 type: "POST", 6474 url: urlAJAX, 6475 data: { 6476 type : 'envoiMailControlCentralPaySurCompteCli', 6477 idObjCentralPayCompteCli : $('#inpt_idObjet').val() 6478 } 6479 }); 6480 })(jQuery); 6481} 6482 6483function retourErreurPaiementCB_centralPay(sourceErreur){ 6484 if (estSurFlux()) { 6485 var urlReload = location.href; 6486 if (location.search.length === 0) { 6487 urlReload += '?centralPay=KO'; 6488 } else { 6489 urlReload += '¢ralPay=KO'; 6490 } 6491 location.href = urlReload; 6492 return; 6493 } 6494 if (!estSurResa()) { 6495 return; 6496 } 6497 afficheLoaderGlobal_site(); 6498 var urlEtape4 = 'etape4.php'+location.search+'¢ralPay=KO&sourceErreur='+sourceErreur; 6499 if (location.search.indexOf("PHPSESSID") <= -1) { 6500 urlEtape4 += '&'+idSession; 6501 } 6502 location.href = urlEtape4; 6503} 6504 6505function initPopinConfirmeEANCV(){ 6506 (function ($) { 6507 $("#a_btChoixPaiementPopinEANCV").fancybox({ 6508 maxWidth : 800, 6509 maxHeight : 600, 6510 fitToView : false, 6511 width : '90%', 6512 autoSize : true, 6513 closeClick : false, 6514 openEffect : 'none', 6515 closeEffect : 'none' 6516 }); 6517 $("#a_btChoixPaiementPopinEANCVacompte").fancybox({ 6518 maxWidth : 800, 6519 maxHeight : 600, 6520 fitToView : false, 6521 width : '90%', 6522 autoSize : true, 6523 closeClick : false, 6524 openEffect : 'none', 6525 closeEffect : 'none' 6526 }); 6527 6528 $(".a_btnConfirmeChoixEANCV").click(function(){ 6529 $("#a_btChoixPaiementANCV").trigger('click'); 6530 $.fancybox.close(); 6531 }); 6532 $(".a_btnConfirmeChoixEANCVacompte").click(function(){ 6533 $("#a_btChoixPaiementAcompteANCV").trigger('click'); 6534 $.fancybox.close(); 6535 }); 6536 6537 $(".a_btnAnnuleChoixEANCV").click(function(){ 6538 if($('#div_popinPaiementAncvCvco')) { 6539 $('#div_popinPaiementAncvCvco').dialog('close'); 6540 } 6541 $.fancybox.close(); 6542 }); 6543 6544 $(".a_btnAnnuleChoixEANCV_etPayeCB").click(function(){ 6545 if($('#div_popinPaiementAncvCvco')) { 6546 $('#div_popinPaiementAncvCvco').dialog('close'); 6547 } 6548 $("#a_btChoixPaiementReserver").trigger('click'); 6549 $.fancybox.close(); 6550 }); 6551 $(".a_btnAnnuleChoixEANCV_etPayeCBacompte").click(function(){ 6552 if($('#div_popinPaiementAncvCvco')) { 6553 $('#div_popinPaiementAncvCvco').dialog('close'); 6554 } 6555 $("#a_btChoixPaiementAcompte").trigger('click'); 6556 $.fancybox.close(); 6557 }); 6558 })(jQuery); 6559} 6560 6561// gestion des règlements pour les points de vente 6562function initEtape3_vendeur() { 6563 (function ($) { 6564 if ($('.inputMontantReglementPV').length > 0) { 6565 $('.inputMontantReglementPV').each(function () { 6566 var id = $(this).attr('id'); 6567 validate = new LiveValidation(id, {validMessage: 'Ok'}); 6568 validate.add(Validate.Custom, {against: function (value, args
6568) { 6569 var val = value; 6570 var pattern = /^[0-9]+(?:\.[0-9]+)?$/; 6571 if (val.match(pattern)) { 6572 return true; 6573 } 6574 return false; 6575 }, failureMessage: 'Entrez un montant valide'}); 6576 }); 6577 $('.inputMontantReglementPV').keyup(function () { 6578 verifReglementPV(this); 6579 }); 6580 } 6581 $('.a_btValideResaVendeur[data-moderesa="resa"]').click(function () { 6582 $('.a_btValideResaVendeur').hide(); 6583 if(verifReglementPV() && $('.LV_invalid_field').length == 0){ 6584 if (casesCochees() === true) { 6585 $('.a_btnAttenteConfirm').show(); 6586 // si c'est une réservation faite par un point de vente et que le mode de paiement carte bleue client n'est pas choisi, on ne va pas dans paybox 6587 var query = $('#formPaiementPV').serialize(); 6588 valideResaVendeur(query); 6589 } 6590 } 6591 else{ 6592 $('.a_btValideResaVendeur').show(); 6593 } 6594 6595 }); 6596 $('.a_btValideResaVendeur[data-moderesa="option"]').click(function () { 6597 $('.a_btValideResaVendeur').hide(); 6598 $('.a_btnAttenteConfirm').show(); 6599 if (casesCochees() === true) { 6600 valideResaVendeur(); 6601 } 6602 6603 }); 6604 $('.a_btValideResaVendeur[data-moderesa="devis"]').click(function () { 6605 $('.a_btValideResaVendeur').hide(); 6606 $('.a_btnAttenteConfirm').show(); 6607 valideResaVendeur(); 6608 }); 6609 })(jQuery); 6610} 6611 6612function valideResaVendeur(query) { 6613 (function ($) { 6614 var params = query || ''; 6615 params += '&type=valideResaVendeur'; 6616 $.ajax({ 6617 type: "POST", 6618 url: urlAJAX, 6619 data: params, 6620 beforeSend: function () { 6621 6622 }, 6623 success: function (result) { 6624 eval("var tabResult=" + result); 6625 if (tabResult.code == errDossierNull) { 6626 retourEtape1(tabResult.msg); 6627 } 6628 else if (tabResult.errTechnq) { 6629 afficheMsgErrTechnq(tabResult.msg, tabResult.titre, tabResult.ident, true); 6630 } 6631 else { 6632 if (tabResult.code == "OK") { 6633 if (!tabResult.cle && !$('#inputPaiementCB').val()) { 6634 if (location.search.indexOf("PHPSESSID") > -1) { 6635 location.href = "etape4.php" + location.search; 6636 } else { 6637 location.href = "etape4.php" + location.search + "&" + idSession; 6638 } 6639 } 6640 else { 6641 majFormPaybox(tabResult); 6642 validerFormulairePaybox(); 6643 } 6644 } 6645 else { 6646 alertAMalibu(tabResult.msg); 6647 } 6648 } 6649 } 6650 }); 6651 })(jQuery) 6652} 6653 6654function verifReglementPV(input) { 6655 var out = true; 6656 (function ($) { 6657 $('#div_msgErreursNombreReglementsCB').hide(); 6658 $('#div_msgErreursNombreReglements').hide(); 6659 $('#div_msgErreursTotalReglement').hide(); 6660 $('#div_msgErreursTotalSupReglement').hide(); 6661 var elemCurr = input || null; 6662 // test de la saisie : 6663 6664 var prix = parseFloat($('#formPaiementPV').attr('data-montant')); 6665 var total = 0; 6666 var nbPaiementsCB = 0; 6667 var nbPaiements = 0; 6668 6669 $('.inputMontantReglementPV').each(function () { 6670 if ($(this).val().length > 0) { 6671 if ($(this).attr('name') == 'paiementCB' || $(this).attr('name') == 'paiementPV_PVB') { 6672 nbPaiementsCB++; 6673 } 6674 nbPaiements++; 6675 var value= parseFloat($(this).val()); 6676 total += Math.round(value * 100); 6677 } 6678 }); 6679 if (nbPaiementsCB > 1) { 6680 if (elemCurr) { 6681 $(elemCurr).val(''); 6682 } 6683 $('#div_msgErreursNombreReglementsCB').show(); 6684 } 6685 else { 6686 // 4 = CB + Espèces + Chèque bancaire + Chèque vacance 6687 if (nbPaiements > 4) { 6688 $('#div_msgErreursNombreReglements').show(); 6689 out = false;
6690 } 6691 else { 6692 if ((prix - total) < 0) { 6693 $('#div_msgErreursTotalSupReglement').show(); 6694 out = false; 6695 } 6696 else { 6697 $('#inputTotalReglementPV').val(total); 6698 $('#spanTotalReglementPV').html(total / 100); 6699 6700 $('#inputResteReglementPV').val(prix - total); 6701 $('#spanResteReglementPV').html((prix - total) / 100); 6702 // si le compte n'y est pas on affiche une erreur. 6703 if ((prix - total) !== 0 ) { 6704 out = false; 6705 if(!elemCurr){// seulement si on a appelé la fonction depuis le clic sur le bouton valider 6706 $('#div_msgErreursTotalReglement').show(); 6707 } 6708 } 6709 } 6710 } 6711 } 6712 6713 })(jQuery); 6714 return out; 6715} 6716 6717function initEtape3_agence(){ 6718 (function($){ 6719 $(document).ready(function(){ 6720 idSession = getIdSessionInHtml(); 6721 }); 6722 initBtnsFooter(); 6723 6724 $('#inpt_mailAgence').keyup(function(){ 6725 var regex = new RegExp("[^@\s]+@[-a-z0-9]*\\.[a-z]{2,}"); 6726 var mail = $(this).val(); 6727 if (regex.test(mail)) { 6728 $('.sp_msgMailAgence.ok').show(); 6729 $('.sp_msgMailAgence.ko').hide(); 6730 } else { 6731 $('.sp_msgMailAgence.ko').show(); 6732 $('.sp_msgMailAgence.ok').hide(); 6733 } 6734 }); 6735 6736 $(".a_btValideResaAgence").click(function(){ 6737 $(".a_btValideResaAgence").hide(); 6738 $(".a_btnAttenteConfirm").show(); 6739 if (!verifQuestionnairesClient()) { 6740 $(".a_btnAttenteConfirm").hide(); 6741 $(this).show(); 6742 document.location = "#div_uneEtape_questionnaires"; 6743 return; 6744 } 6745 enregistreReponsesQuestionnairesClient(); 6746 var modeResa = $(this).attr('data-moderesa'); 6747 var mailAgence = $('#inpt_mailAgence').val(); 6748 var regex = new RegExp("[^@\s]+@[-a-z0-9]*\\.[a-z]{2,}"); 6749 if (!regex.test(mailAgence)) { 6750 mailAgence = ''; 6751 } 6752 var nomClient = ''; 6753 if($('#inpt_nomClient').length>0){ // dans le cas d'une résa agence gestprod 6754 var tabValidation = []; 6755 var nom = new LiveValidation("inpt_nomClient", {validMessage: $("#inpt_msgOk").val()}); 6756 nom.add(Validate.Presence, {failureMessage: $("#inpt_msgVide").val()}); 6757 tabValidation.push(nom); 6758 if (!LiveValidation.massValidate(tabValidation)){ 6759 $(".a_btnAttenteConfirm").hide(); 6760 $(".a_btValideResaAgence").show('fast'); 6761 $("#div_msgErreursInfosClient").show('fast'); 6762 document.location = "#div_msgErreursInfosClient"; 6763 return false; 6764 } 6765 nomClient = $('#inpt_nomClient').val(); 6766 } 6767 var nouveauPrix; 6768 if($('#inpt_modifPrixLocationResaAgence').length>0 || $('.inputModifPrixChambre').length>0){ 6769 var tabValidation = []; 6770 var inputs = $('#inpt_modifPrixLocationResaAgence')[0] || $('.inputModifPrixChambre'); 6771 var nouveauPrix; 6772 var erreurDeSaisie = false; 6773 $(inputs).each(function () { 6774 if ($(this).val() !== '') { 6775 var prixBase = $(this).attr('data-prix'); 6776 if (!$(this).val().match(/^[0-9]{1,}(\.|,){0,1}[0-9]{0,2}$/g) || parseFloat(prixBase) < parseFloat($(this).val())) { 6777 $(".a_btnAttenteConfirm").hide(); 6778 $(".a_btValideResaAgence").show('fast'); 6779 if(!$(this).val().match(/^[0-9]{1,}(\.|,){0,1}[0-9]{0,2}$/g)){ 6780 $("#div_msgErreursFormatLocation").show('fast'); 6781 } 6782 if(parseFloat(prixBase) < parseFloat($(this).val())){ 6783 $("#div_msgErreursMontantLocation").show('fast'); 6784 } 6785 document.location = "#div_msgErreursMontantLocation"; 6786 erreurDeSaisie = true; 6787 } 6788 if ($(this).attr('id') == 'inpt_modifPrixLocationResaAgence') { 6789 nouveauPrix = $('#inpt_modifPrixLocationResaAgence').val(); 6790 } 6791 else { 6792 nouveauPrix = nouveauPrix || {}; 6793 nouveauPrix[$(this).attr('data-numChambre')] = $(this).val(); 6794 } 6795 } 6796 }); 6797 } 6798 if(erreurDeSaisie){ 6799 return false;
6800 } 6801 $.ajax({ 6802 type: "POST", 6803 url: urlAJAX, 6804 data: {type: "valideResaAgence", modeResa: modeResa, mailAgence: mailAgence,nomClient:nomClient,nouveauPrix:nouveauPrix}, 6805 success: function(result){ 6806 eval("var tabResult="+result); 6807 if (tabResult.code == errDossierNull) { 6808 retourEtape1(tabResult.msg); 6809 } 6810 else if (tabResult.errTechnq) { 6811 afficheMsgErrTechnq(tabResult.msg, tabResult.titre, tabResult.ident, true); 6812 } 6813 else { 6814 if (tabResult.code == "OK") { 6815 if (location.search.indexOf("PHPSESSID") > -1) 6816 location.href = "etape4.php"+location.search; 6817 else 6818 location.href = "etape4.php"+location.search+"&"+idSession; 6819 } 6820 else { 6821 alertAMalibu(tabResult.msg); 6822 } 6823 } 6824 } 6825 }); 6826 }); 6827 6828 initQuestionnaireClient(); 6829 })(jQuery); 6830} 6831 6832function casesCochees(){ 6833 var retour = false; 6834 (function($){ 6835 if ($("#inpt_valideDocFiche").length>
68350 && $("#inpt_valideDocFiche").attr("checked") != "checked") { 6836 $("#div_msgErreursDocs").show(); 6837 $("#sp_msgErreurFiche").show(); 6838 // Envoi de l'event au Google Tag Manager 6839 if (typeof(dataLayer)!='undefined') { 6840 dataLayer.push({'ErrorMessage': 'Descriptif_Hebergement', 'event': 'resa3_erreur'}); 6841 } 6842 } else { 6843 $("#sp_msgErreurFiche").hide(); 6844 } 6845 6846 6847 if ($("#inpt_valideDocCgv").length>0 && $("#inpt_valideDocCgv").attr("checked") != "checked") { 6848 $("#div_msgErreursDocs").show(); 6849 $("#sp_msgErreurCgv").show(); 6850 // Envoi de l'event au Google Tag Manager 6851 if (typeof(dataLayer)!='undefined') { 6852 dataLayer.push({'ErrorMessage': 'CGV', 'event': 'resa3_erreur'}); 6853 } 6854 } else { 6855 $("#sp_msgErreurCgv").hide(); 6856 } 6857 6858 if ($("#inpt_valideDocCga").length > 0 && $("#inpt_valideDocCga").attr("checked") != "checked") { 6859 $("#div_msgErreursDocs").show(); 6860 $("#sp_msgErreurCga").show(); 6861 // Envoi de l'event au Google Tag Manager 6862 if (typeof(dataLayer)!='undefined') { 6863 dataLayer.push({'ErrorMessage': 'CGA', 'event': 'resa3_erreur'}); 6864 } 6865 } else { 6866 $("#sp_msgErreurCga").hide(); 6867 } 6868 6869 if ($("#sp_msgErreurFiche").is(':hidden') && $("#sp_msgErreurCgv").is(':hidden') && $("#sp_msgErreurCga").is(':hidden')) { 6870 retour = true; 6871 } else { 6872 $('html, body').animate({scrollTop: 0},1000); 6873 } 6874 })(jQuery); 6875 6876 return retour; 6877} 6878 6879function initEtape4(){ 6880 (function($){ 6881 $(document).ready(function(){ 6882 idSession = getIdSessionInHtml(); 6883 }); 6884 initBtnsFooter(); 6885 if(estMultiResa()){ 6886 // on écoute le message que nous renvoie le bureau : si on a une url, on redirige vers l'url pour continuer les résas 6887 window.addEventListener('message', function(event) { 6888 var retour = JSON.parse(event.data) || false; 6889 if(retour.link ){ 6890 $('#a_btnSuiteMultiResa').attr('data-link',retour.link); 6891 $('#div_btnRetourSite').hide(); 6892 $('#div_btnSuiteMultiResa').show('fast'); 6893 6894 } 6895 }, false); 6896 var ident = $('#a_btnSuiteMultiResa').attr('data-prodBooked'); 6897 // on envoie un message au bureau pour indiquer que la résa est ok pour le produit courant 6898 window.opener.postMessage(JSON.stringify({prodBooked:ident}),'*'); 6899 $('#a_btnSuiteMultiResa').click(function(){ 6900 var link = $(this).attr('data-link') || false; 6901 if(link){ 6902 document.location = link; 6903 } 6904 }); 6905 } 6906 // Guillaume le 06/03/2017 : l'appel ajax sur le bouton retour au site ne sert à rien, je l'enlève (sinon ça fait une erreur dans gereResa car on a plus de dossier en session ). 6907// $("#a_btnRetourSite").click(function(){ 6908// window.onbeforeunload = ""; 6909// $.ajax({ 6910// type : "POST", 6911// url: urlAJAX, 6912// data: {type: "retourSite"}, 6913// beforeSend: function(){ 6914// 6915// }, 6916// success: function(result){ 6917// eval("var tabResult="+result); 6918// if (tabResult.code == errDossierNull) { 6919// retourEtape1(tabResult.msg); 6920// } 6921// else if (tabResult.errTechnq) { 6922// afficheMsgErrTechnq(tabResult.msg, tabResult.titre, tabResult.ident, true); 6923// } 6924// else { 6925// if (tabResult.lien.length > 0) 6926// document.location = tabResult.lien; 6927// else 6928// window.close(); 6929// } 6930// } 6931// }); 6932// }); 6933 6934 6935 if($("#a_btnRetourBureauItea").length>0){ 6936 $("#a_btnRetourBureauItea").click(function(){ 6937 window.close(); 6938 }); 6939 } 6940 if($("#div_btnModifPrix").length>0){ 6941 $("#div_btnModifPrix").hide(); 6942 } 6943 initModalTaxeSejour(); 6944 })(jQuery); 6945 6946// window.onbeforeunload = function(){ 6947// return ""; 6948// } 6949} 6950 6951/******************************************************************************/ 6952/******************************************************************************/ 6953/************************ Fonctions générant du XHTML *************************/ 6954/******************************************************************************/ 6955/******************************************************************************/ 6956 6957function getXHTML_recapOptionsAnimaux(){ 6958 var xhtml = ""; 6959 (function($){ 6960 $(".option.animal:has(input:checked)").each(function(){ 6961 xhtml += "<li>"; 6962 xhtml += "<span>"+$(this).find("label").html()+"</span>"; 6963 xhtml += "<span>"+$(this).find("td.td_prixOption").html()+"</span>"; 6964 xhtml += "</li>"; 6965 }); 6966 })(jQuery); 6967 return xhtml; 6968} 6969 6970function getXHTML_recapOptionsObligatoires(){ 6971 var xhtml = ""; 6972 (function($){ 6973 $(".option.obligatoire:not(.animal)").each(function(){ 6974 xhtml += "<li>"; 6975 xhtml += "<span>"+$(this).find("label").html()+"</span>"; 6976 xhtml += "<span>"+$(this).find("td.td_prixOption").html()+"</span>"; 6977 xhtml += "</li>"; 6978 }); 6979 })(jQuery); 6980 return xhtml; 6981} 6982 6983function refreshBandeauEtapes(bandeau){ 6984 (function($){ 6985 $('#ul_etapesResa').html(bandeau); 6986 })(jQuery); 6987} 6988 6989function manageChangementTypeResa(retour, modifChambre){ 6990 (function($){ 6991 // Yoann 05/03/2014 (fiche 207615) Envoi d'information pour Google Tag Manager 6992 if (retour.modeResa == 'demandeNres' && typeof(dataLayer)!='undefined') { 6993 dataLayer.push({'event' : 'resa_datesProches'}); 6994 } 6995 // guillaume 28/05/2015 : le test ci dessous fonctionne tout le temps, on ne passe jamais après du coup... 6996 // On affiche le message seulement si on passe en résa par mail 6997// if (retour.modeResa == 'demandeParMail') { 6998 6999 // fiche 264956 on recharge la page quoi qu'il arrive,c'est plus simple et ça évite que dans les scripts de résa inversée on arrive à l'étape de paiement alors qu'on est en demande par mail 7000 rechargementPageMAJ(); 7001// } 7002// if (retour.modeResa == 'MODE_LD_PASMAIL' || retour.modeResa=='impossible' || retour.modeResa=='classique' || retour.modeResa=='pre_resa'){ 7003// rechargementPageMAJ(); 7004// } 7005 /*else*/ if (modifChambre===true){ 7006 var textenok = 'Annuler'; 7007 var texteok = 'Valider'; 7008 if(retour.motscles.annuler){textenok = retour.motscles.annuler;} 7009 if(retour.motscles.valider){texteok = retour.motscles.valider;} 7010 $("<div id='dialogMessageInfoModeResa'><p>"+retour.msgInfoModeResa+"</p></div>").dialog({ 7011 dialogClass: 'modaleChangeTypeResa', 7012 modal:true, 7013 closeOnEscape: false, 7014 buttons:[{ 7015 text : textenok, 7016 click:function(){ 7017 // TODO : on remet la sélection de la chambre à 0, il faut par contre ajouter un paramètre 7018 var numChambre = retour.numChambre; 7019 $('#inpt_chambre_1').attr('data-annulChoix', 'OK'); 7020 $('#select_compoFamilleAdulte_'+numChambre).val(0).change(); 7021 $(this).dialog('close'); 7022 } 7023 },{ 7024 text : texteok, 7025 click : function(){ 7026 var paramsURL = location.search; 7027 if (paramsURL.indexOf("PHPSESSID") > -1){ 7028 location.href = location.pathname+paramsURL; 7029// location.href = "etape1.php"+paramsURL; 7030 } 7031 else{ 7032 location.href = location.pathname+paramsURL+"&"+idSession; 7033// location.href = "etape1.php"+paramsURL+"&"+idSession; 7034 } 7035 } 7036 } 7037 ] 7038 }); 7039 } 7040 else { 7041 var paramsURL = location.search; 7042 if (paramsURL.indexOf("PHPSESSID") > -1) { 7043 location.href = location.pathname + paramsURL; 7044 } else { 7045 location.href = location.pathname + paramsURL + "&" + idSession; 7046 } 7047 } 7048 })(jQuery); 7049} 7050 7051function afficheMsgErrTechnq(msg, titre, ident, avecFormulaire,destinataire){ 7052 (function($){ 7053 var dateDeb = $('#inpt_resaDateDeb').val(); 7054 var dateFin = $('#inpt_resaDateFin').val(); 7055 $("<div id='dialogMessageErrTechnq'><p>"+msg+"</p></div>").dialog({ 7056 modal:true, 7057 buttons:{ 7058 "Ok":function(){ 7059 $(this).dialog('close'); 7060 if (avecFormulaire) { 7061 var dest = destinataire || 'centrale'; 7062 var quePourCentrale = 'N'; 7063 var pourCentrale = 'O'; 7064 if(dest == 'centrale'){ 7065 quePourCentrale = 'O'; 7066 } 7067 else{ 7068 pourCentrale = 'N'; 7069 } 7070 sendThisToProp(ident, 800, 600, titre, pourCentrale, quePourCentrale, dateDeb, null, dateFin); 7071 } 7072 } 7073 } 7074 }); 7075 })(jQuery); 7076} 7077 7078function initAssurance(){ 7079 (function($){ 7080 // Affectation du montant de l'assurance au dossier (ou 0 si on ne prend pas l'assurance) 7081 // Guillaume : j'ai remplcé le live par un click, car le live est la cause de double appel ajax, dans le cas où on re
7081charge le html de la div et qu'on réinit les évenements 7082 // Yoann : Oui mais du coup le click n'est jamais appelé vu que le HTML est généré en AJAX donc pas présent à l'appel de ce JS 7083 // Il faut donc penser à rappeler initAssurance quand on màj le HTML de l'assurance 7084 $("input:radio[name=assur]").click(function(){ 7085 affectAssurance(); 7086 if ($(this).val() == "Avec") { 7087 $(".sp_recapSansAssurAnnul").hide(); 7088 $(".sp_recapAvecAssurAnnul").show(); 7089 } 7090 else { 7091 $(".sp_recapAvecAssurAnnul").hide(); 7092 $(".sp_recapSansAssurAnnul").show(); 7093 } 7094 etapeCourante($("#div_uneEtape_assuranceAnnul"), true); 7095 }); 7096 7097 $('input[name="inputTypeClientAssurance"]').each(function(){ 7098 if($(this).is(':checked')){ 7099 $('.divFormuleAssurance').hide(); 7100 $('.divFormuleAssuranceType'+$(this).val()).show(); 7101 } 7102 }); 7103 var tagChoixAssurance = 'choixAssuranceEffectue'+getIdSessionInHtml(); 7104 $('input[name="inputTypeClientAssurance"]').click(function(){ 7105 $('.divFormuleAssurance').hide(); 7106 $('.divFormuleAssuranceType'+$(this).val()).show(); 7107 var assurancePrecochee = $('input.inpt_choixFormuleAssurance[data-precochage="O"]',$('.divFormuleAssuranceType'+$(this).val())); 7108 if(assurancePrecochee.length>0){ 7109 var yaAssuranceDejaChoisie = sessionStorage.getItem(tagChoixAssurance) || false; 7110 if(!yaAssuranceDejaChoisie ){ 7111 setFormuleAssurance(assurancePrecochee); 7112 } 7113 } 7114 }); 7115 if($('input.inpt_choixFormuleAssurance').length>0){ 7116 $('input[name="formuleAssurance"]').click(function(){ 7117 sessionStorage.setItem(tagChoixAssurance,true); 7118 setFormuleAssurance(this); 7119 afficheChoixPaysAssurance(this); 7120 if ($('#select_pays').length > 0) { 7121 if ($(this).val() === '') { 7122 $('#select_pays').prop('disabled', false); 7123 $('#select_pays').attr('title', ''); 7124 } else { 7125 majSelectPaysAssuranceEtClient($('.select_paysAssurance:visible')); 7126 } 7127 } 7128 }); 7129 } 7130 7131 })(jQuery); 7132} 7133 7134 7135 7136// initialisation du paiement d'un montant choisi par le client 7137function initPaiementVersementCompteClient(){ 7138 if($('input_paiement_cbVersPbx')){ 7139 $('input_paiement_cbSoldePbx').onclick = function(){ 7140 $("inpt_vers_cptClient").value= 0; 7141 $("inpt_vers_cptClient").setAttribute('disabled','true'); 7142 $('a_boutonValiderCptClientPbx').show(); 7143 }; 7144 $('input_paiement_cbVersPbx').onclick = function(){ 7145 $("inpt_vers_cptClient").removeAttribute('disabled'); 7146 $('a_boutonValiderCptClientPbx').hide(); 7147 } 7148 var elem = $("inpt_vers_cptClient"); 7149 elem.onchange=function(evt){ 7150 var val = elem.value; 7151 var pattern = '^[0-9]+([.]{1}[0-9]{1,2})?$'; 7152 var reg=new RegExp(pattern); 7153 var test = reg.test(val); 7154 // test de la saisie : 7155 if( test){ 7156 var solde = parseFloat($("inpt_solde_cptCliPbx").value); 7157 var total = parseFloat(val)*100; 7158 if((solde - total)<0){ 7159 $('a_boutonValiderCptClientPbx').hide(); 7160 alertAMalibu('Le montant saisi est supérieur au solde de la réservation.'); 7161 } 7162 else{ 7163 if(total<100){ 7164 $('a_boutonValiderCptClientPbx').hide(); 7165 alertAMalibu('Le montant saisi doit être supérieur à 1 euro.'); 7166 } 7167 else{ 7168 $('a_boutonValiderCptClientPbx').show(); 7169 } 7170 } 7171 7172 } 7173 else{ 7174 if(val.length!=0 ){ 7175 alertAMalibu('Le montant saisi doit être numérique et les décimales séparées par un point.'); 7176 } 7177 } 7178 } 7179 } 7180} 7181 7182function verifMontantVersement(){ 7183 var pattern = '^[0-9]+([.]{1}[0-9]{1,2})?$'; 7184 var elem = $("inpt_vers_cptClient"); 7185 var reg=new RegExp(pattern); 7186 return reg.test(elem.value); 7187 7188} 7189
7190function initCanevasResaCouplee(reinitCanevas){ 7191 var forceReinit = reinitCanevas || false; 7192 if(!forceReinit){ 7193 // on a déjà chargé les canevas, on ne les recharge pas à moins qu'on force avec tabRetour.reinitCanevas 7194 initActionsCanevas(); 7195 rendChoixCanevasPossible(); //fiche 239803 7196 } 7197 else{ 7198 getCanevasPossibles(); 7199 } 7200} 7201 7202function getCanevasPossibles() { 7203 (function ($) { 7204 var numEtape = parseInt($('#div_uneEtape_canevas').prev('.div_uneEtape').find('.sp_numEtape').text()) + 1; 7205 var data = 'TYPE=verifCanevasResaGP_html&numetape=' + numEtape; 7206 if (!gestprod) { 7207 data = 'TYPE=verifCanevasResaCouplee_html&numetape=' + numEtape; 7208 } 7209 $.ajax({ 7210 dataType: 'html', 7211 url: urlAJAX, 7212 data: data, 7213 beforeSend: function () { 7214 affMsgAttenteParDessusInDiv('div_uneEtape_canevas', 'canevas', txtAttente); 7215 }, 7216 complete: function () { 7217 effaceMsgAttenteParDessus('canevas'); 7218 }, 7219 success: function (html) { 7220 if (html.length === 0) { 7221 hideDivEtapeCanevas(); 7222 return; 7223 } 7224 $('#div_uneEtape_canevas').html(html); 7225 showDivEtapeCanevas(); 7226 initActionsCanevas(); 7227 7228 // gestion du numéro d'étape pour la/les div qui se situe après la div canevas (normalement c'est l'assurance) 7229 numEtape++; 7230 $('#div_uneEtape_canevas').nextAll('.div_uneEtape').each(function () { 7231 $(this).find('.sp_numEtape').text(numEtape); 7232 numEtape++; 7233 }); 7234 rendChoixCanevasPossible(); 7235 if (typeof foncQdFini_chargeCanevas !== 'undefined') { 7236 foncQdFini_chargeCanevas(); 7237 } 7238 if (typeof foncQdFini_verifCanevas !== 'undefined') { 7239 foncQdFini_verifCanevas(); 7240 } 7241 }, 7242 error: function (data) { 7243 alertAJquery(data); 7244 } 7245 }); 7246 })(jQuery); 7247} 7248 7249function getCanevasPossibles_OLD(){ 7250 (function($){ 7251 var numEtape = $("#div_uneEtape_canevas").prev(".div_uneEtape").find(".sp_numEtape").text(); 7252 numEtape = parseInt(numEtape) + 1; 7253 var data = ''; 7254 if (!gestprod) { 7255 data = "TYPE=verifCanevasResaCouplee&numetape="+numEtape; 7256 } else { 7257 data = "TYPE=verifCanevasResaGP&numetape="+numEtape; 7258 } 7259 $.ajax({ 7260 type: "POST", 7261 dataType:"xml", 7262 url:urlAJAX, 7263 data: data, 7264 beforeSend: function(){ 7265 affMsgAttenteParDessusInDiv("div_uneEtape_canevas", "canevas", txtAttente); 7266 }, 7267 complete:function(){ 7268 effaceMsgAttenteParDessus("canevas"); 7269 }, 7270 success:function(xml){ 7271 var code = $(xml).find("code").text(); 7272 if(code == "OK"){ 7273 var html = $(xml).find('HTML').text(); 7274 $('#div_uneEtape_canevas').html(html); 7275 initActionsCanevas(); 7276 7277 if($("#div_uneEtape_canevas").css("display") == 'none'){ 7278 showDivEtapeCanevas(); 7279 } 7280 // gestion du numéro d'étape pour la/les div qui se situe après la div canevas (normalement c'est l'assurance) 7281 numEtape++; 7282 $("#div_uneEtape_canevas").nextAll(".div_uneEtape").each(function(){ 7283 $(this).find(".sp_numEtape").text(numEtape); 7284 numEtape++; 7285 }); 7286 rendChoixCanevasPossible(); 7287 if(typeof foncQdFini_chargeCanevas!=='undefined'){ 7288 foncQdFini_chargeCanevas(); 7289 } 7290// var position; 7291// if ($("#div_uneEtape_date").length>0) { 7292// position = $("#div_uneEtape_date").offset(); 7293// } else { 7294// position = $('#div_uneEtape_choixNDate').offset(); 7295// } 7296// var h = position.top-105; 7297// $('html, body').animate({ 7298// scrollTop:h 7299// },1000,"easeOutCirc"); 7300 }else{ 7301 hideDivEtapeCanevas(); 7302 } 7303 if(typeof foncQdFini_verifCanevas!=='undefined'){ 7304 foncQdFini_verifCanevas(); 7305 } 7306 }, 7307 error:function(data){ 7308 alertAJquery(data); 7309 } 7310 }); 7311 })(jQuery) 7312} 7313 7314function initActionsCanevas(){ 7315 (function($){ 7316 showDivEtapeCanevas(); 7317 // action au clic sur la ligne du supplément dans le récap prix 7318 $('#div_recapInfosEtPrix').click(function(e){ 7319 var element =$(e.target); 7320 if(($(e.target).hasClass('spanSupprimerTarifSupplement'))){ 7321 var ligneFacture = $(e.target).get(0); 7322 var identifiantSupplementPossible = ''; 7323 // on cherche l'identifiant du supplément dans la liste des canevas possibles pour le transmettre à l'appel ajax 7324 var regex = new RegExp('^[0-9]+_[0-9]+_[0-9]+_'+$(ligneFacture).attr('data-idtarif')+'$'); 7325 var selectAMettreAJour = null; 7326 $('.lstChoixSupplQte').each(function(){ 7327 if(regex.test($(this).attr('data-identifiant'))){ 7328 identifiantSupplementPossible = $(this).attr('data-identifiant'); 7329 selectAMettreAJour = $(this); 7330 } 7331 });
7332 // si on a bien en supplément correspondant à l'idtarif de la ligne facture, on supprime 7333 if(identifiantSupplementPossible){ 7334 $(ligneFacture).attr('data-identifiant',identifiantSupplementPossible); 7335 // on met à jour le dossier via ajax 7336 majChoixCanevas(ligneFacture); 7337 // on met à jour le select du bloc de choix suppléments 7338 selectAMettreAJour.val(0); 7339 } 7340 7341 } 7342 }); 7343 // action sur le choix de la quantite dans la div de choix des suppléments 7344 $(".lstChoixSupplQte").change(function(){ 7345 majChoixCanevas(this); 7346 if ($(this).parents('.tarifElementRubriqueCanevas').is('.nonCumulable')) { 7347 majRubriqueCanevasAvecElementNonCumulable($(this)); 7348 } 7349 }); 7350 7351 // TODO : prendre en compte les checkbox inpt_choixQteCanevas_forfait 7352 $(".inpt_choixQteCanevas_forfait").change(function(){ 7353 majChoixCanevas(this); 7354 if ($(this).parents('.tarifElementRubriqueCanevas').is('.nonCumulable')) { 7355 majRubriqueCanevasAvecElementNonCumulable($(this)); 7356 } 7357 }); 7358 7359 $(".select_heureVoiture").change(function(){ 7360 var element = $(this).attr("data-identifiant"); 7361 var qte = parseInt($(".lstChoixSupplQte[data-identifiant='"+element+"']").val()); 7362 if (qte>0) { 7363 majChoixCanevas($(".lstChoixSupplQte[data-identifiant='"+element+"']")); 7364 } 7365 }); 7366 // action sur le choix de la date dans la div de choix des suppléments 7367 $(".lstChoixSupplDate").change(function(){ 7368 var dates = $(this).val(); 7369 var element = $(this).attr("data-identifiant"); 7370 $(".inputChoixSupplDate[data-identifiant='"+element+"']").val(dates); 7371 var qte = parseInt($(".lstChoixSupplQte[data-identifiant='"+element+"']").val()); 7372 if(qte>0 || ( qte==0 && $('.tr_prixSupplements').length>0 )){ // si on a une quantité ou alors si on a pas de quantité mais des suppléments déjà choisis : 7373 majChoixCanevas($(".lstChoixSupplQte[data-identifiant='"+element+"']")); 7374 } 7375 }); 7376 7377 // action sur le choix d'une location de voiture 7378 if($('.divRubriqueCanevasVoiture').length>0){ 7379 initActionsCanevasVoiture(); 7380 } 7381 7382 // le descriptif des tarifs des canevas 7383 if(jQuery('.viewWithQtip').length>0){ 7384 jQuery('.viewWithQtipTohide').hide() 7385 jQuery('.viewWithQtip').each(function(){ 7386 if(jQuery(this).attr('data-qhelp') && jQuery("#"+jQuery(this).attr('data-qhelp'))){ 7387 jQuery(this).qtip({ 7388 content: 7389 { 7390 text: jQuery("#"+jQuery(this).attr('data-qhelp')).html(), 7391 title:{ 7392 text:jQuery(this).attr('data-qtitle') 7393 } 7394 }, 7395 7396 show: 'mouseover', 7397 hide: 'mouseout' 7398 })} 7399 }) 7400 } 7401 //plugin JQuery pour affichage pop in canevas 7402 $(".a_canevasAfficheDetail").fancybox({ 7403 maxWidth : 800, 7404 maxHeight : 600, 7405 fitToView : false, 7406 width : '70%', 7407 height : '70%', 7408 autoSize : false, 7409 closeClick : false, 7410 openEffect : 'none', 7411 closeEffect : 'none' 7412 }); 7413 $(".bouton_ajouter_canevas").toggle( 7414 function(){ 7415 $(this).parents(".divUneRubriqueCanevas").children(".liste_tarifs_de_la_rubrique").show('fast'); 7416 }, 7417 function(){ 7418 $(this).parents(".divUneRubriqueCanevas").children(".liste_tarifs_de_la_rubrique").hide('fast'); 7419 }); 7420 $("#aToggleChoixCanevas").toggle(function(){ 7421 $('.divListeRubriquesDuCanevas .divUneRubriqueCanevas:not(".canevasObligatoire")').hide('fast'); 7422 $(this).children('#spanCanevasCache').hide(); 7423 $(this).children('#spanCanevasAffiche').show(); 7424 },function(){ 7425 $('.divListeRubriquesDuCanevas .divUneRubriqueCanevas').show('fast'); 7426 $(this).children('#spanCanevasAffiche').hide(); 7427 $(this).children('#spanCanevasCache').show(); 7428 }); 7429 7430 // Gestion des actions pour les rubriques obligatoires 7431 if ($('.divUneRubriqueCanevas.canevasObligatoire').length>0) { 7432 7433 } 7434 7435 initFancyBoxDeBase(); 7436 })(jQuery) 7437 7438} 7439 7440function initActionsCanevasVoiture() { 7441 (function ($) { 7442 7443 /***************** 7444 * 1. affectation d'un canevas 7445 **************/ 7446 $('.divRubriqueCanevasVoiture').delegate('.inputCanevasTarifVoiture','change',function () { 7447 var element = $(this).data('identifiant'); 7448 var identifiantRubrique = $(this).data("identifiant_rub_canevas_stock"); 7449 var params = { 7450 element: element, 7451 quantite: 1, 7452 dateDeb: $('#inpt_resaDateDebCanevas_' +$(this).data('canevas')+'_'+ $(this).data('rubrique')).val(), 7453 dateFin: $('#inpt_resaDateFinCanevas_' +$(this).data('canevas')+'_'+ $(this).data('rubrique')).val(), 7454 heureDebVoiture: $('.inputHeureDebVoiture[data-identifiant="'+identifiantRubrique+'"]').val(), 7455 heureFinVoiture: $('.inputHeureFinVoiture[data-identifiant="'+identifiantRubrique+'"]').val(), 7456 libelleRub: $(this).parents('.divUneRubriqueCanevas').children('input.inputLibelleRubrique').val() 7457 }; 7458 var affichageBoutonSupprimerSupplement = function(){ 7459 $('.spanEnleverSupplementDuDossier[data-identifiant="'+element+'"]').show(); 7460 }; 7461 setCanevas(params,affichageBoutonSupprimerSupplement); 7462 }); 7463 $('.divRubriqueCanevasVoiture').delegate('.spanEnleverSupplementDuDossier', 'click', function () { 7464 var element = $(this).data('identifiant'); 7465 var params = { 7466 element: element, 7467 quantite: 0 7468 }; 7469 setCanevas(params); 7470 }); 7471 7472 /***************** 7473 * 2. gestion de la modification des dates 7474 **************/ 7475 $('.inpt_resaDateFinCanevas').each(function () { 7476 var identifiantRubrique = $(this).data('identifiant'); 7477 var element = this; 7478 var minDate = $('.inpt_resaDateDebCanevas[data-identifiant="'+identifiantRubrique+'"]').val(); 7479 $(this).datepicker({ 7480 dateFormat: 'dd/mm/yy', 7481 minDate: minDate, 7482 dayNamesMin: $.datepicker._defaults.dayNamesMin, 7483 beforeShowDay: function (jour) { 7484 return beforeShowDayCanevasVoiture(jour, element); 7485 }, 7486 onSelect: function (dateFin) { 7487 var dateDeb = $('.inpt_resaDateDebCanevas[data-identifiant="'+identifiantRubrique+'"]').val(); 7488 genereListeStocksRubriqueCanevasVoiture(identifiantRubrique,dateDeb,dateFin); 7489 } 7490 }); 7491 }); 7492 $('.inpt_resaDateDebCanevas').each(function () { 7493 var identifiant = $(this).data('identifiant'); 7494 var element = this; 7495 $(this).datepicker({ 7496 dateFormat: 'dd/mm/yy', 7497 minDate: 0, 7498 dayNamesMin: $.datepicker._defaults.dayNamesMin, 7499 beforeShowDay: function (jour) { 7500 return beforeShowDayCanevasVoiture(jour, element); 7501 }, 7502 onSelect: function (dateDeb) { 7503 $('.inpt_resaDateFinCanevas[data-identifiant="'+identifiant+'"]').val(''); 7504 }, 7505 onClose: function(dateText, inst) { 7506 $('.inpt_resaDateFinCanevas[data-identifiant="'+identifiant+'"]').focus(); 7507 } 7508 }); 7509 }); 7510 $('.divRubriqueCanevasVoiture').delegate('.spanBoutonModifierDatesCanevasVoiture','click',function(){ 7511 $(this).parents('.divRecapDatesCanevasVoiture').slideUp(); 7512 $(this).parents('.divRubriqueCanevasVoiture').children('.choixDatesVoiture').slideDown(); 7513 var identifiant = $(this).data('identifiant'); 7514 $('.divListeTarifsCanevas[data-identifiant="'+identifiant+'"]').hide(); 7515 }); 7516 7517 7518 /***************** 7519 * 2. gestion de la modification des heures d'un stock 7520 **************/ 7521 $('.divRubriqueCanevasVoiture').delegate('.spanBoutonModifierHeuresCanevasVoiture','click',function(){ 7522 var identifiant = $(this).data('identifiant'); 7523 $('.divSelectHeure','.divUnStockRubriqueCanevas[data-identifiant="'+identifiant+'"]').slideDown(); 7524 $(this).parents('.divRecapHeuresStockRubriqueCanevasVoiture').slideUp(); 7525 $('.divListeTarifsByStockRubriqueCanevas','.divUnStockRubriqueCanevas[data-identifiant="'+identifiant+'"]').slide
7525Up(); 7526 $('.inputHeureVoiture', '.divUnStockRubriqueCanevas[data-identifiant="' + identifiant + '"').each(function () { 7527 var heuresAutorisees = $(this).data('heures_autorisees'); 7528 $(this).datetimepicker({ 7529 datepicker: false, 7530 format: 'H:i', 7531 step: 30, 7532 validateOnBlur: false, 7533 allowTimes: heuresAutorisees 7534 }); 7535 }); 7536 }); 7537 $('.divRubriqueCanevasVoiture').delegate('.btnValiderHeuresStockRubriqueCanevas','click',function () { 7538 var heureDeb = $('.inputHeureDebVoiture[data-identifiant="'+$(this).data('identifiant')+'"]').val(); 7539 var heureFin = $('.inputHeureFinVoiture[data-identifiant="'+$(this).data('identifiant')+'"]').val(); 7540 genereListeTarifsByStockRubriqueCanevasVoiture($(this).data('identifiant'),$(this).data('datedeb'),$(this).data('datefin'),heureDeb,heureFin); 7541 }); 7542 })(jQuery); 7543} 7544 7545function beforeShowDayCanevasVoiture(jour,input){ 7546 var out = (function($){ 7547 7548 var classe = ''; 7549 var moisJs = (jour.getMonth()+1).toString(); 7550 if(moisJs.length === 1){ 7551 moisJs = '0'+moisJs; 7552 } 7553 var j = jour.getDate().toString(); 7554 if(j.length === 1){ 7555 j = '0'+j; 7556 } 7557 var dateDuJour = j+'/'+moisJs+'/'+jour.getFullYear(); 7558 var tabDatesOk = $(input).data('dates_autorisees') || []; 7559 if ( $(input).val() === dateDuJour ){ 7560 if($(input).hasClass('inpt_resaDateDebCanevas')){ 7561 classe+= ' dateArrivee'; 7562 } 7563 else{ 7564 classe+= ' dateFin'; 7565 } 7566 } 7567 if(tabDatesOk.indexOf(dateDuJour)<0){ 7568 classe+=' occupe'; 7569 return [false, classe]; 7570 } 7571 else{ 7572 classe+=' cliquable'; 7573 return [true, classe]; 7574 } 7575 })(jQuery); 7576 return out; 7577} 7578 7579function genereListeStocksRubriqueCanevasVoiture(identifiantRubriqueCanevas,dateDeb,dateFin){ 7580 (function($){ 7581 $('.divListeTarifsCanevas[data-identifiant="'+identifiantRubriqueCanevas+'"').hide('fast'); 7582 if(!dateDeb || !dateFin){ 7583 return; 7584 } 7585 var infosCanevas = identifiantRubriqueCanevas.split('_'); 7586 var params = { 7587 TYPE : 'getTarifsRubriqueCanevasVoiture', 7588 canevas:infosCanevas[0], 7589 rubrique:infosCanevas[1], 7590 dateDeb : dateDeb, 7591 dateFin : dateFin 7592 } 7593 $.ajax({ 7594 type: 'POST', 7595 dataType:'xml', 7596 url:urlAJAX, 7597 data : params, 7598 beforeSend: function(){ 7599 affMsgAttenteParDessusInDiv("div_resaContenu", "contenu", txtAttente); 7600 }, 7601 complete:function(){ 7602 effaceMsgAttenteParDessus("contenu"); 7603 }, 7604 success:function(xml){ 7605 var data = XMLToArray(xml); 7606 if(!data.html && data.msg ){ 7607 $('.divListeTarifsCanevas[data-identifiant="'+identifiantRubriqueCanevas+'"]').html('<p>'+data.msg +'</p>'); 7608 } 7609 else{ 7610 $('.divListeTarifsCanevas[data-identifiant="'+identifiantRubriqueCanevas+'"]').html(decodeURIComponent(data.html)); 7611 $('.divRecapDatesCanevasVoiture[data-identifiant="'+identifiantRubriqueCanevas+'"]').html(decodeURIComponent(data.recapDatesCanevas)); 7612 } 7613 $('.divListeTarifsCanevas[data-identifiant="'+identifiantRubriqueCanevas+'"]').show('fast'); 7614 $('.divRecapDatesCanevasVoiture[data-identifiant="'+identifiantRubriqueCanevas+'"]').show('fast'); 7615 $('.choixDatesVoiture[data-identifiant="'+identifiantRubriqueCanevas+'"]').hide('fast'); 7616 if(data.maj){ 7617 rechargementPageMAJ(); 7618 } 7619 } 7620 }); 7621 })(jQuery); 7622} 7623 7624function genereListeTarifsByStockRubriqueCanevasVoiture(identifiantStockRubriqueCanevas,dateDeb,dateFin,heureDeb,heureFin){ 7625 (function($){ 7626 var infos = identifiantStockRubriqueCanevas.split('_'); 7627 var params = { 7628 type:'getListeTarifsByStockRubriqueCanevasVoiture', 7629 canevas:infos[0], 7630 rubrique:infos[1], 7631 stock:infos[2],
7632 dateDeb: dateDeb, 7633 dateFin : dateFin, 7634 heureDeb:heureDeb, 7635 heureFin:heureFin 7636 }; 7637 7638 $.ajax({ 7639 type: 'POST', 7640 dataType:'xml', 7641 url:urlAJAX, 7642 data : params, 7643 beforeSend:function(){ 7644 attenteInDiv($('.divChoixHeuresStockRubriqueCanevasVoiture[data-identifiant="'+identifiantStockRubriqueCanevas+'"]')); 7645 }, 7646 complete:function(){ 7647 effaceAttenteInDiv(); 7648 }, 7649 success:function(xml){ 7650 var data = XMLToArray(xml); 7651 $('.divSelectHeure','.divUnStockRubriqueCanevas[data-identifiant="'+identifiantStockRubriqueCanevas+'"]').slideUp(); 7652 if(!data.html && data.msg ){ 7653 $('.divListeTarifsByStockRubriqueCanevas','.divUnStockRubriqueCanevas[data-identifiant="'+identifiantStockRubriqueCanevas+'"]').html('<p>'+data.msg +'</p>'); 7654 } 7655 else{ 7656 $('.divListeTarifsByStockRubriqueCanevas','.divUnStockRubriqueCanevas[data-identifiant="'+identifiantStockRubriqueCanevas+'"]').replaceWith($.parseHTML(data.html)); 7657 } 7658 $('.divListeTarifsByStockRubriqueCanevas','.divUnStockRubriqueCanevas[data-identifiant="'+identifiantStockRubriqueCanevas+'"]').slideDown(); 7659 } 7660 }); 7661 })(jQuery); 7662} 7663 7664function majChoixCanevas(obj){ 7665 (function($){ 7666 var element = $(obj).attr("data-identifiant"); 7667 var quantite; 7668 7669 if ($(obj).is(':checkbox')){ 7670 quantite = 0; 7671 if ($(obj).is(':checked')) { 7672 var codeProd = $(obj).parents('.divListeRubriquesDuCanevas').attr('data-codeProd'); 7673 $('.select_compoNbPers_'+codeProd).each(function(){ 7674 var elem = $(this); 7675 quantite += parseInt(elem.val()); 7676 }); 7677 } 7678 } else { 7679 quantite = $(obj).val(); 7680 } 7681 7682 var dates = $(".inputChoixSupplDate[data-identifiant='"+element+"']").val(); 7683 var tabDates = dates.split('_'); 7684 var dateDeb = tabDates[0]; 7685 var dateFin = tabDates[1]; 7686 var params= { 7687 element:element, 7688 quantite:quantite, 7689 dateDeb:dateDeb, 7690 dateFin:dateFin 7691 }; 7692 if ($(".select_heureVoiture[data-identifiant='"+element+"']").length>0) { 7693 if (quantite>0) { 7694 $(".sp_choixHeureVoiture[data-identifiant='"+element+"']").show(); 7695 } else { 7696 $(".sp_choixHeureVoiture[data-identifiant='"+element+"']").hide(); 7697 } 7698 params.heureVoiture = $(".select_heureVoiture[data-identifiant='"+element+"']").val(); 7699 params.libelleRub = $(obj).parents('.divUneRubriqueCanevas').children('input.inputLibelleRubrique').val(); 7700 } 7701 7702 setCanevas(params); 7703 })(jQuery) 7704} 7705 7706/** 7707 * 7708 * @param { 7709 element:element, 7710 quantite:quantite, 7711 dateDeb:dateDeb, 7712 dateFin:dateFin, 7713 heureVoiture:heureVoiture, 7714 libelleRub:libelleRub 7715 }; 7716 callback : fonction à appeler après traitement si besoin 7717 * @returns {undefined} 7718 */ 7719function setCanevas(params,callback) { 7720 if(typeof params !== 'object'){ 7721 return; 7722 } 7723 console.log('setCanevas params ',params); 7724 params.type = 'affectCanevasResaGP'; 7725 if (!gestprod) { 7726 params.type = 'affectCanevasResaCouplee'; 7727 } 7728 (function ($) { 7729 $.ajax({ 7730 type: "POST", 7731 dataType: 'xml', 7732 url: urlAJAX, 7733 data: params, 7734 beforeSend: function () { 7735 affMsgAttenteParDessusInDiv("div_resaContenu", "contenu", txtAttente); 7736 }, 7737 complete: function () { 7738 effaceMsgAttenteParDessus("contenu"); 7739 }, 7740 success: function (data) { 7741 var xml = $(data); 7742 var tabResult = XMLToArray(xml); 7743 if (tabResult['code'] == "OK") { 7744 // si on a changé de type de résa (gestloc ou gestprod), on doit recharger 7745 if (tabResult["maj"] != undefined) { 7746// var tabInfosUrl = {"ancre":"div_uneEtape_canevas"}; 7747 rechargementPageMAJ(); 7748 } 7749 else { 7750 $('.choixSupplements_prixTotal[data-identifiant="' + params.element + '"]').html(tabResult["prixDuSupplement"]); 7751 $('#div_recapPrix').html(tabResult['recapPrix']); 7752 var htmlAssurance = tabResult['htmlAssurance']; 7753 if (tabResult['choixAssurance']) { 7754 htmlAssurance = tabResult['choixAssurance']; 7755 } 7756 majAssurance(null, htmlAssurance, tabResult['prixAssurance']); 7757 if(typeof(callback) !== 'undefined'){ 7758 callback(tabResult); 7759 } 7760 } 7761 } 7762 else { 7763 if (tabResult['htmlErreur']) { 7764 alertAJquery(tabResult['htmlErreur']); 7765 } else if (tabResult['msg']) { 7766 alertAJquery(tabResult['msg']); 7767 } 7768 else { 7769 alertAJquery('Une erreur 5168 s\'est produite');//HL230926 7770 } 7771 } 7772 }, 7773 error: function (data) { 7774 alert(data); 7775 } 7776 }); 7777 })(jQuery) 7778} 7779 7780function rendChoixCanevasPossible() { 7781 (function($) { 7782 // vérif préliminaire : si pas de compo famille, on rend inactif les canevas (pour ne pas avoir d'incohérence de prix dans le récap, c
7782ar si nb pax = 0, prix de loc =0) 7783 if ($("#div_recapInfosFamille").length > 0 || $('.div_uneEtape_prodGP').length > 0) { // si la div de récap infos famille est présente, c'est qu'il y a nb adultes >0 7784 $("#div_uneEtape_canevas").find("*:not(.inpt_choixQteCanevas_forfait)").attr("disabled", false); 7785 $("#div_uneEtape_canevas").removeClass('div_uneEtapeGrisee'); 7786 7787 $('.divListeRubriquesDuCanevas .divUneRubriqueCanevas').show('fast'); 7788 $('#aToggleChoixCanevas').children('#spanCanevasAffiche').hide(); 7789 $('#aToggleChoixCanevas').children('#spanCanevasCache').show(); 7790 } 7791 else { 7792 $("#div_uneEtape_canevas").addClass('div_uneEtapeGrisee'); 7793 $("#div_uneEtape_canevas *").find("*:not(.inpt_choixQteCanevas_forfait)").attr("disabled", true); 7794 7795 $('.divListeRubriquesDuCanevas .divUneRubriqueCanevas:not(".canevasObligatoire")').hide('fast'); 7796 $('#aToggleChoixCanevas').children('#spanCanevasCache').hide(); 7797 $('#aToggleChoixCanevas').children('#spanCanevasAffiche').show(); 7798 } 7799 7800 if ($('.divUneRubriqueCanevas.canevasObligatoire').length > 0) { 7801 // Si on a que des canevas obligatoire on va masquer le titre de l'étape pour laisser afficher seulement le titre des canevas obligatoires 7802 if ($('.divUneRubriqueCanevas:not(.canevasObligatoire)').length == 0) { 7803 $('#div_uneEtape_canevas > .div_titreEtape').hide(); 7804 } 7805 majNumEtapes(); 7806 } 7807 7808 7809 $(".lstChoixSupplQte").each(function(){ 7810 if ($(this).parents('.tarifElementRubriqueCanevas').is('.nonCumulable')) { 7811 if ($(this).is(':checked') || ($(this).val()!=0 && $(this).val()!=null)) { 7812 $(this).parents('.tarifElementRubriqueCanevas').addClass('selected'); 7813 $(this).parents('.liste_tarifs_de_la_rubrique').find('.tarifElementRubriqueCanevas:not(.selected) *').attr("disabled", true); 7814 } 7815 } 7816 }); 7817 })(jQuery) 7818} 7819 7820function majLstCanevasOblig(nbPers){ 7821 (function($){ 7822 if ($('.divUneRubriqueCanevas.canevasObligatoire').length>0) { 7823 $('.divUneRubriqueCanevas.canevasObligatoire').each(function(){ 7824 $(this).attr('data-nbPers', nbPers); 7825 var lstQte = $(this).find('.lstChoixSupplQte'); 7826// var htmlLstQte = '<option value="0">-</option>'; 7827// for (var i=1; i<=nbPers; i++) { 7828// htmlLstQte += '<option value="'+i+'">'+i+'</option>'; 7829// } 7830// lstQte.html(htmlLstQte); 7831 lstQte.each(function(){ 7832 if ($(this).val()>nbPers) { 7833 majChoixCanevas($(this)); 7834 } 7835 $(this).find('option').each(function(){ 7836 var valOption = parseInt($(this).val()) 7837 if (valOption>nbPers) { 7838 $(this).hide(); 7839 } else { 7840 $(this).show(); 7841 } 7842 }); 7843 }); 7844 }); 7845 } 7846 // J'en profite également pour mettre à jour les tarifs forfaitaires, 7847 // si on a aucune personne de sélectionné il faut déselectionner les tarifs forfaitaires 7848 if (nbPers==0) { 7849 $('.inpt_choixQteCanevas_forfait:checked').each(function(){ 7850 $(this).attr('checked', false); 7851 $(this).change(); 7852 }); 7853 } else { 7854 $('.inpt_choixQteCanevas_forfait:checked').each(function(){ 7855 $(this).change(); 7856 }); 7857 } 7858 7859 if (typeof foncQdFini_majLstCanevasOblig == 'function'){ 7860 foncQdFini_majLstCanevasOblig(); 7861 } 7862 })(jQuery); 7863} 7864 7865// TODO : gérer les canevas avec des tarifs forfaitaires (checkbox à la place des listes) 7866function verifQteCanevasOblig(){ 7867 var retour = false; 7868 (function($){ 7869 var nbPers; var qte=0; 7870 var verifCanevasOblig = null; 7871 $('.divUneRubriqueCanevas.canevasObligatoire').each(function(){ 7872 nbPers = $(this).attr('data-nbpers'); 7873 $(this).find('.lstChoixSupplQte').each(function(){ 7874 if ($(this).val()!=null) { 7875 qte += parseInt($(this).val()); 7876 } 7877 }); 7878 if (qte==nbPers || $(this).find('.inpt_choixQteCanevas_forfait:checked').length>0) { 7879 if (verifCanevasOblig===null) { 7880 verifCanevasOblig = true; 7881 } 7882 $(this).removeClass('rubriqueAValider'); 7883 } else {
7884 $('#div_uneEtape_canevas').find('.inpt_validEtape').val('Non'); 7885 if (verifCanevasOblig===null || verifCanevasOblig===true) { 7886 verifCanevasOblig = false; 7887 } 7888 $(this).addClass('rubriqueAValider'); 7889 } 7890 7891 qte = 0; 7892 }); 7893 7894 if (verifCanevasOblig===true) { 7895 $('#div_uneEtape_canevas').find('.inpt_validEtape').val('Oui'); 7896 retour = true; 7897 } else { 7898 $('#div_uneEtape_canevas').find('.inpt_validEtape').val('Non'); 7899 } 7900 })(jQuery); 7901 return retour; 7902} 7903 7904/** 7905 * tabretour : un objet json contenant les infos que l'on souhaite incorporer à l'url de destination 7906 * -tabParam.url : l'url de destination si on veut changer complètement d'url 7907 * -tabParam.ident : l'ident du produit de la résa 7908 * -tabParam.ancre : une ancre pour la page de destination 7909 */ 7910function rechargementPageMAJ(tabRetour){ 7911 console.trace('rechargementPageMAJ'); 7912 affMsgAttenteParDessusInDiv("div_resaContenu", "contenu", txtAttente); 7913 var tabParam = tabRetour || []; 7914 if (tabParam.url) { 7915 location.href = tabParam.url; 7916 return; 7917 } 7918 var paramsURL = location.search; 7919 if (tabParam.ident){ 7920 paramsURL = "?ident="+tabRetour.ident; 7921 } 7922 if (paramsURL.indexOf("PHPSESSID") == -1) 7923 paramsURL += "&"+idSession; 7924 if(tabParam.ancre){ 7925 paramsURL += "#"+tabParam.ancre; 7926 } 7927 // problème de rechargement de la page avec la même adresse : il faut faire un location.reload sinon ça ne recharge pas 7928 var oldHref = location.href; 7929 var tabInfosHref = oldHref.split('/'); 7930 var nomFichier = tabInfosHref.pop(); 7931 var dossierResa = tabInfosHref.pop(); 7932 var pathname = dossierResa+'/'+nomFichier; 7933 if(pathname != location.pathname+paramsURL){ 7934 location.href = location.pathname+paramsURL; 7935// location.href = "etape1.php"+paramsURL; 7936 } 7937 else{ 7938 window.location.reload(); 7939 } 7940 7941 return; 7942 7943} 7944 7945// Yoann l'objResult est attendu en JSON mais parfois il est en XML donc je passe le html et le montant directement 7946function majAssurance(objResult, htmlResult, montantResult){ 7947 (function($){ 7948 var htmlAssurance = false; 7949 var montantAssurance = false; 7950 if (objResult) { 7951 htmlAssurance = objResult.htmlAssurance; 7952 } else if (htmlResult){ 7953 htmlAssurance = htmlResult; 7954 } 7955 if(htmlAssurance && $('#div_assuranceAnnul').length>0){ 7956 $('#div_assuranceAnnul').html(htmlAssurance); 7957 if (objResult) { 7958 montantAssurance = objResult.assurance; 7959 } else if (montantResult){ 7960 montantAssurance = montantResult; 7961 } 7962 if(montantAssurance){ 7963 var montantReelAssurance = montantAssurance.replace('€',''); 7964 montantReelAssurance = montantReelAssurance.replace(' ',''); 7965 try{ // on essaie de le parser en int 7966 montantReelAssurance = parseInt(montantReelAssurance); 7967 } 7968 catch(e){// si on a pas réussi, c'est de toutes façons qu'on a un chiffre autre que zéro, donc on met à true (ou 1) 7969 montantReelAssurance = 1; 7970 } 7971 if(montantReelAssurance >0){ 7972 if ($("#sp_montantAssur").length>0) { 7973 $("#sp_montantAssur").html(montantAssurance); 7974 } else { 7975 $(".sp_montantAssur:visible").html(montantAssurance); 7976 } 7977 } 7978 } 7979 initAssurance(); 7980 } else{ 7981 $('#div_assuranceAnnul').html(''); 7982 } 7983
7984 if($('#div_assuranceAnnul').find('.inpt_validEtape').length == 0){ 7985 $('#div_uneEtape_assuranceAnnul').hide('fast'); 7986 } 7987 else{ 7988 $('#div_uneEtape_assuranceAnnul').show('fast'); 7989 } 7990 7991 // Vérification du pré-cochage de l'assurance 7992 if ($("#inpt_assurOui").is(':visible:checked') && $('#div_uneEtape_assuranceAnnul').find('.inpt_validEtape').val()=='Non') { 7993 $("#inpt_assurOui").click(); 7994 } 7995 7996 })(jQuery) 7997} 7998 7999 8000/**********************/ 8001/******* RESA GP ******/ 8002/**********************/ 8003function initEtape1_GP(){ 8004 (function($){ 8005 $.ajaxSetup({ 8006 timeout: 100000 8007 }); 8008 gestprod = true; 8009 initLangue(); 8010 idSession = getIdSessionInHtml(); 8011 ajoutePHPSESSID_history(); 8012 nbMois = $("#inpt_nbMoisCalend").val(); 8013 if(!nbMois){ 8014 nbMois = 2; 8015 } 8016 initBtnsFooter(); 8017 8018 // On initialise les datepicker en français pour avoir les noms des mois et des jours en fonction de la langue du site 8019 $.datepicker.setDefaults($.datepicker.regional[lang]); 8020 8021 // On positionne l'étape courante sur la première div qui n'a pas de récap visible 8022 $(".div_uneEtapeRecap:hidden:first").parent().addClass('div_uneEtapeCurr'); 8023 8024 $(".sp_fermerCal").click(function(){ 8025 $(this).parents(".div_calendDateDebFin").hide(); 8026 }); 8027 // Fonction sur le focus du champ de la date d'arrivée 8028 $("#inpt_resaDateDeb").click(function(){ 8029 $("#div_calendrierDeb").show().addClass("open"); 8030 $("#div_msgErreursDateDeb").hide(); 8031 $("#div_calendrierFin").hide().removeClass("open"); 8032 // On créé la requête ajax permettant de récupérer les disponibilités de cette structure 8033 $.ajax({ 8034 type: "POST", 8035 url: urlAJAX, 8036 // Je mets async à false quand on veut simuler le click sur le calendrier et ensuite vérifier si ça s'est bien passé 8037 // En mode asynchrone on a pas le retour d'AJAX donc on ne sait pas si ça s'est bien passé (voir fonction initPrix) 8038 async: false, 8039 data: {type: "getPlanningDeb_GP"}, 8040 beforeSend: function(){ 8041 $("#div_roueDatepickerDeb").show(); 8042 afficheLoaderGlobal_site(); 8043 }, 8044 // Quand la requête Ajax s'est terminée correctement, 8045 // On met à jour chainePlanning et dateDebPlanning pour paramétrer les datepicker 8046 success: function (result) { 8047 eval("var tabDispos=" + result); 8048 if (tabDispos.code == errDossierNull) { 8049 retourEtape1(tabDispos.msg); 8050 } 8051 8052 else if (tabDispos.errTechnq) { 8053 afficheMsgErrTechnq(tabDispos.msg, tabDispos.titre, tabDispos.ident, true); 8054 } 8055 else if (tabDispos.code == "OK"){ 8056 8057 chainePlanning = tabDispos.chaineDispo; 8058 dateDebPlanning = tabDispos.dateDeb; 8059 dateFinPlanning = tabDispos.dateFin; 8060 infoBulles = tabDispos.infoBulle; 8061 initDatePickerDeb(); 8062 } 8063 else { 8064 $("#div_confirmDispos").find(".ko").text(tabDispos.msg).show(); 8065// alertAMalibu(tabDispos.msg); 8066 $("#div_calendrierDeb").hide().removeClass("open"); 8067 $("#div_uneEtape_date").find(".inpt_validEtape").val("Non"); 8068 rendChoixCanevasPossible(); 8069 } 8070 $("#div_roueDatepickerDeb").hide(); 8071 }, 8072 complete: function(){ 8073 effaceLoaderGlobal_site(); 8074 } 8075 }); 8076 return false; // très important ça, pour éviter de propager l'évenement jusqu'au body car sinon on va faire un .hide() sur le calendrier (voir fonction initClicBody) 8077 }); 8078 8079 8080 $(".div_uneEtapeGrisee *").attr("disabled", true); 8081 8082 // TODO: à adpater pour chaque type de produit 8083 if ($("#div_uneEtape_hotelChoixChambre").length > 0) { 8084 setEventsForHotel(); 8085 } 8086 if ($('#div_uneEtape_locatChoixChambre').length>0) { 8087 setEventsForLocat(); 8088 } 8089 if ($('#div_uneEtape_billetChoixPresta').length>0) { 8090 setEventsForBillet(); 8091 } 8092 if ($("#div_uneEtape_choixNDate").length > 0) { 8093 setEventsForNDate(); 8094 } 8095 if ($("#div_uneEtape_packageChoixTarif").length > 0) { 8096 setEventsForPack(); 8097 } 8098 if ($('#div_uneEtape_voitureChoixPresta').length>0) { 8099 setEventsForVoiture(); 8100 } 8101// else if ($("#div_uneEtape_compoFamilleChambre").length > 0) 8102// setEventsForChambre(); 8103 8104 // Au focus sur le champ de départ, on affiche le calendrier de fin 8105 // Si aucune date d'arrivée n'est sélectionnée, rien ne s'affichera (vérif Regex) 8106 // On masque le calendrier de début au cas ou il serait visible 8107 $("#inpt_resaDateFin").click(function(){ 8108 var regDate = new RegExp("[0-9]{2}\/[0-9]{2}\/[0-9]{4}"); 8109 $("#div_calendrierDeb").hide(); 8110 if (regDate.test($("#inpt_resaDateDeb").val())) { 8111 $("#div_calendrierFin").show().addClass("open"); 8112 } 8113 else { 8114 $("#div_msgErreursDateDeb").show(); 8115 } 8116 }); 8117 8118// if($('#div_uneEtape_assuranceAnnul').length>0){ 8119// $('#div_uneEtape_assuranceAnnul').css('display','none'); 8120// } 8121 8122 initAssurance(); 8123 initModifEtape(); 8124 8125 $("#inpt_motMagique").blur(function(){ 8126 if ($("#inpt_motMagique").val() != "") {
8127 verifMotMagique(true,false); 8128 } 8129 }); 8130 8131 initPrixLibre(); 8132 8133 // On vérifie si toutes les étapes obligatoires ont été validées 8134 // Si c'est le cas on envoit à l'étape2 en vérifiant que l'URL contient déjà PHPSESSID 8135 // Pour ne pas avoir PHPSESSID en double dans l'url à l'étape2 8136 $("#div_btnConfirmer > a:not(.a_btnAttenteConfirm), #div_btnConfirmer_1 > a:not(.a_btnAttenteConfirm)").click(function(){ 8137 if ($('.div_uneEtapeMsgErreur').length>0) { 8138 return false; 8139 } 8140 $(this).hide(); 8141 $(".a_btnAttenteConfirm").show(); 8142 traiteNdatePrixLibre(); 8143 if (etapesValid()) { 8144 if ($(this).is('#div_btnConfirmer > a:not(.a_btnAttenteConfirm)')) { 8145 //var paramsURL = location.search; 8146 var paramsURL = location.search.replace(/&panier=[^&]+/,'');//335479 8147 var numeroEtape = '2'; 8148 if($('#divNumeroProchaineEtape').length>0){ 8149 numeroEtape = $('#divNumeroProchaineEtape').attr('data-prochaineEtape'); 8150 } 8151 8152 if (paramsURL.indexOf("PHPSESSID") > -1){ 8153 location.href = 'etape'+numeroEtape+'.php'+paramsURL; 8154 } 8155 else{ 8156 location.href = 'etape'+numeroEtape+'.php'+paramsURL+"&"+idSession; 8157 } 8158 } else { 8159 $('#div_btnConfirmer_2 > a:not(.a_btnAttenteConfirm)').click(); 8160 } 8161 } 8162 8163 $(".a_btnAttenteConfirm").hide(); 8164 $(this).show(); 8165 }); 8166 //gestion du récap des étapes validées ou non (je mets un timer pour maj régulier, car on peut pas mettre à jour sur un onchange ou on click): 8167 //window.setInterval(function(){initResumeEtapes();},2000); 8168 })(jQuery); 8169} 8170 8171function setEventsForHotel(){ 8172 (function($){ 8173 verifAllNbPaxCodeStock_hotel(); 8174 8175 $(".select_nbAdultesHotel").live("change", function(){ 8176 // On met à jour la liste déroulante enfant/adulte en fonction du nbPersMaxi 8177 var nbPersMaxi = $(this).parents('.tr_tarifHotel').attr('data-nbmaxtotal'); 8178 var nbAdultes = $(this).val(); 8179 var nbEnfantsMax = parseInt(nbPersMaxi) - parseInt(nbAdultes); 8180 var listeEnfants = $(this).parents('.tr_tarifHotel').find('.select_nbEnfantsHotel'); 8181 8182 // Si le nombre d'adultes est remis à 0, on réinitialise les enfants également (comme en résa GestLoc) 8183 if (nbAdultes==0) { 8184 listeEnfants.val(0); 8185 listeEnfants.change(); 8186 } else { 8187 // Si on sélectionne des adultes, on efface l'erreur au cas ou elle soit affichée 8188 $(this).parents('.tr_tarifHotel').removeClass('invalide'); 8189 $(this).parents('.tr_tarifHotel').find('.sp_msgErreurAdultes').hide(); 8190 } 8191 8192 // On modifie la liste de sélection des enfants en fonction du nombre max de personnes et du nombre d'adultes sélectionné 8193 if (nbEnfantsMax==0) { 8194 listeEnfants.hide(); 8195 } else { 8196 listeEnfants.show(); 8197 listeEnfants.find('option').each(function(){ 8198 if ($(this).val()>nbEnfantsMax) { 8199 $(this).hide(); 8200 } else { 8201 $(this).show(); 8202 } 8203 }); 8204 } 8205 8206 // Ensuite on vérifie si on a réservé toutes les chambres disponibles, si c'est le cas on va masquer/griser les autres 8207 var codeStock = $(this).parents('.tr_tarifHotel').attr('data-codestock'); 8208 verifNbPaxCodeStock_hotel(codeStock); 8209 8210 // Si on a aucune personne de sélectionnée on masque le recapPrix, on invalide l'étape et on ne fait pas le setLignesFactures 8211 var nbAdultesTot = 0; 8212 $('.select_nbAdultesHotel:visible').each(function(){ 8213 if ($(this).val()>0) { 8214 nbAdultesTot += $(this).val(); 8215 } 8216 }); 8217 8218 if (nbAdultesTot==0) { 8219 $('#div_uneEtape_hotelChoixChambre').find('.inpt_val
8219idEtape').val('Non'); 8220 $('#div_recapPrix').hide(); 8221 $('#div_recapInfosFamille').remove(); 8222 } 8223 else { 8224 setLignesFactures_hotel(); 8225 } 8226 8227 majListesSupplementsHotel(); 8228 }); 8229 8230 $(".select_nbEnfantsHotel").live("change", function(){ 8231 var nbEnfants = $(this).val(); 8232 var nbAdultes = $(this).parents('.tr_tarifHotel').find('.select_nbAdultesHotel').val(); 8233 var nbPersMaxi = $(this).parents('.tr_tarifHotel').attr('data-nbmaxtotal'); 8234 var nbAdultesMax = parseInt(nbPersMaxi) - parseInt(nbEnfants); 8235 var listeAdultes = $(this).parents('.tr_tarifHotel').find('.select_nbAdultesHotel'); 8236 8237 listeAdultes.find('option').each(function(){ 8238 if ($(this).val()>nbAdultesMax) { 8239 $(this).hide(); 8240 } else { 8241 $(this).show(); 8242 } 8243 }); 8244 8245 if (nbAdultes>0) { 8246 setLignesFactures_hotel(); 8247 } 8248 8249 majListesSupplementsHotel(); 8250 }); 8251 8252 setEventsSupplements(setLignesFactures_hotel); 8253 8254 $('.a_btnChoixTarif').live('click', function(){ 8255 var div = $(this).attr('data-div'); 8256 var divTarif = $('.'+div+'.divDeBase').clone(); 8257 $(this).parents('.div_uneChambre_choixTarif').after(divTarif); 8258 divTarif.removeClass('divDeBase').show(); 8259 $(this).parents('.div_uneChambre_choixTarif').hide(); 8260 }); 8261 8262 $('.a_modifTarif').live('click', function(){ 8263 $(this).parents('.div_uneChambreTarifs').siblings('.div_uneChambre_choixTarif:not(".divDeBase")').show(); 8264 $(this).parents('.div_uneChambreTarifs').remove(); 8265 setLignesFactures_hotel(); 8266 }); 8267 })(jQuery); 8268} 8269 8270function verifAllNbPaxCodeStock_hotel(){ 8271 (function($){ 8272 $('.tr_tarifHotel').each(function(){ 8273 verifNbPaxCodeStock_hotel($(this).attr('data-codestock')); 8274 }); 8275 })(jQuery); 8276} 8277 8278function gestionMultiTarifs(elemListe){ 8279 (function($){ 8280 var nbTarifs = elemListe.val(); 8281 if (nbTarifs>0) { 8282 var nbDivChoix = elemListe.parents(".div_uneChambreContent").find(".div_uneChambre_choixTarif").not(".divDeBase").length; 8283 if (nbDivChoix>nbTarifs) { 8284 // Il faut supprimer des divChoix et les divTarifs associées 8285 var diff = nbDivChoix-nbTarifs; 8286 for (var i=1; i<=diff; i++) { 8287 if (elemListe.parents(".div_uneChambreContent").find(".div_uneChambre_choixTarif").not(".divDeBase").last().next().is('.div_uneChambreTarifs:not(.divDeBase)')) { 8288 elemListe.parents(".div_uneChambreContent").find(".div_uneChambre_choixTarif").not(".divDeBase").last().next().remove(); 8289 } 8290 elemListe.parents(".div_uneChambreContent").find(".div_uneChambre_choixTarif").not(".divDeBase").last().remove(); 8291 } 8292 } else { 8293 for (var i=1; i<=nbTarifs; i++) { 8294 if (i>nbDivChoix) { 8295 if (elemListe.parents(".div_uneChambreContent").find(".div_uneChambre_choixTarif").not(".divDeBase").last().next().is('.div_uneChambreTarifs:not(.divDeBase)')) { 8296 ajouteDivChoixTarif(elemListe.parents(".div_uneChambreContent").find(".div_uneChambre_choixTarif").not(".divDeBase").last().next(), i); 8297 } else { 8298 var lastDiv; 8299 if (nbDivChoix==0) { 8300 lastDiv = elemListe.parents(".div_uneChambreContent").find(".div_uneChambre_choixTarif.divDeBase"); 8301 } else { 8302 lastDiv = elemListe.parents(".div_uneChambreContent").find(".div_uneChambre_choixTarif").not(".divDeBase").last(); 8303 } 8304 ajouteDivChoixTarif(lastDiv, i); 8305 } 8306 } 8307 } 8308 } 8309 8310 if (nbTarifs==1) { 8311 $('.p_lblChoixTarif').hide(); 8312 } else { 8313 $('.p_lblChoixTarif').show(); 8314 } 8315 8316// elemListe.parents(".div_uneChambreContent").find(".div_uneChambre_choixTarif").not(".divDeBase").remove(); 8317// for (var i=1; i<=nbTarifs; i++) { 8318// var divChoixTarif = elemListe.parents('.div_uneChambreContent').find('.div_uneChambre_choixTarif.divDeBase'); 8319// divChoixTarif.find('.sp_numChoix').text(i); 8320// var htmlChoixTarif = divChoixTarif.html(); 8321// htmlChoixTarif = '<div class="div_uneChambre_choixTarif">'+htmlChoixTarif+'</div>'; 8322// var nbDivVisible = elemListe.parents(".div_uneChambreContent").find(".div_uneChambre_choixTarif").not(".divDeBase").length; 8323// if (nbDivVisible==0) { 8324// divChoixTarif.after(htmlChoixTarif); 8325// } else { 8326// elemListe.parents(".div_uneChambreContent").find(".div_uneChambre_choixTarif").not(".divDeBase").last().after(htmlChoixTarif); 8327// } 8328// } 8329 } else { 8330 elemListe.parents('.div_uneChambreContent').find('.div_uneChambre_choixTarif:not(.divDeBase)').remove(); 8331 elemListe.parents('.div_uneChambreContent').find('.div_uneChambreTarifs:not(.divDeBase)').remove(); 8332 } 8333 })(jQuery); 8334} 8335 8336function ajouteDivChoixTarif(lastDiv, numChoix){ 8337 (function($){ 8338 var divChoixTarif = lastDiv.parents('.div_uneChambreContent').find('.div_uneChambre_choixTarif.divDeBase'); 8339 divChoixTarif.find('.sp_numChoix').text(numChoix); 8340 var htmlChoixTarif = divChoixTarif.html(); 8341 htmlChoixTarif = '<div class="div_uneChambre_choixTarif">'+htmlChoixTarif+'</div>'; 8342 var nbDivVisible = lastDiv.parents(".div_uneChambreContent").find(".div_uneChambre_choixTarif").not(".divDeBase").length; 8343 if (nbDivVisible==0) { 8344 divChoixTarif.after(htmlChoixTarif); 8345 } else { 8346 lastDiv.after(htmlChoixTarif); 8347 } 8348 })(jQuery); 8349} 8350 8351function gestionMonoTarif(elemListe){ 8352 (function($){ 8353 if (elemListe.val()>0) { 8354 var contentDiv = elemListe.parents(".div_uneChambreContent").find(".div_uneChambreTarifs.divDeBase").html(); 8355 contentDiv = "<div class='div_uneChambreTarifs'>"+contentDiv+"</div>"; 8356 var nbDivVisible = elemListe.parents(".div_uneChambreContent").find(".div_uneChambreTarifs").not(".divDeBase").length; 8357 var i; 8358 if (elemListe.val()>nbDivVisible) { 8359 var nbAAjouter = elemListe.val() - nbDivVisible; 8360 8361 for (i=0; i<nbAAjouter; i++) { 8362 if (nbDivVisible==0) { 8363 elemListe.parents(".div_uneChambreContent").find(".div_uneChambreTarifs.divDeBase").after(contentDiv); 8364 } 8365 else { 8366 elemListe.parents(".div_uneChambreContent").find(".div_uneChambreTarifs").not(".divDeBase").last().after(contentDiv); 8367 } 8368 // TODO : faire une REQ AJAX pour ajouter cette sélection? 8369 } 8370 } 8371 else { 8372 var nbASupprimer = nbDivVisible - elemListe.val(); 8373 8374 for (i=0; i<nbASupprimer; i++) { 8375 elemListe.parents(".div_uneChambreContent").find(".div_uneChambreTarifs").not(".divDeBase").last().remove(); 8376 } 8377 8378 setLignesFactures_hotel(); 8379 } 8380 } 8381 else { 8382 elemListe.parents(".div_uneChambreContent").find(".div_uneChambreTarifs").not(".divDeBase").remove(); 8383 var nbPers = 0; 8384 $('.select_compoFamille:visible').each(function(){ 8385 if (elemListe.val()>0) { 8386 nbPers = 1; 8387 return false;
8388 } 8389 }); 8390 if (nbPers==0) { 8391 $('#div_uneEtape_hotelChoixChambre').find('.inpt_validEtape').val('Non'); 8392 $('#div_recapPrix').hide(); 8393 $('#div_recapInfosFamille').remove(); 8394 } 8395 else { 8396 setLignesFactures_hotel(); 8397 } 8398 } 8399 })(jQuery); 8400} 8401 8402function setLignesFactures_hotel(){ 8403 (function($){ 8404// setLignesFactures(); 8405 8406 var lignesFactures = new Array(); 8407 var i = 0; 8408 $(".tr_tarifHotel:visible").each(function(){ 8409 var tarifs = new Array(); 8410 var nbAdultes = 0; var nbEnfants = 0; 8411 var codeStock = $(this).attr("data-codestock"); 8412 var idTarif = $(this).attr("data-idtarif"); 8413 var j = 0; 8414 8415 nbAdultes = $(this).find(".select_nbAdultesHotel").val(); 8416 if ($(this).find(".select_nbEnfantsHotel").length>0) { 8417 nbEnfants = $(this).find(".select_nbEnfantsHotel").val(); 8418 } else { 8419 nbEnfants = 0; 8420 } 8421 8422 var nbPax = parseInt(nbAdultes) + parseInt(nbEnfants); 8423 if (nbPax > 0) { 8424 tarifs[j] = new Array(idTarif, nbPax); 8425 j++; 8426 } 8427 8428 if (nbAdultes>0) { 8429 lignesFactures[i] = new Array(codeStock, nbAdultes, nbEnfants, tarifs); 8430 i++; 8431 } 8432 }); 8433 8434 $(".tr_tarifSupplement:visible").each(function(){ 8435 var tarifs = new Array(); 8436 var nbAdultes = 0; var nbEnfants = 0; 8437 var codeStock = ''; 8438 var idTarif = $(this).attr("data-idtarif"); 8439 var j = 0; 8440 8441 if ($(this).find(".select_qteSupplement").length>0) { 8442 nbAdultes = $(this).find(".select_qteSupplement").val(); 8443 nbEnfants = 0; 8444 } else if ($(this).find(".select_supplementForfaitaire").length>0) { 8445 nbAdultes = $(this).find(".select_supplementForfaitaire").val(); 8446 nbEnfants = 0; 8447 } 8448 8449 var nbPax = parseInt(nbAdultes) + parseInt(nbEnfants); 8450 if (nbPax > 0) { 8451 tarifs[j] = new Array(idTarif, nbPax); 8452 j++; 8453 } 8454 8455 lignesFactures[i] = new Array(codeStock, nbAdultes, nbEnfants, tarifs, null, null, true); 8456 i++; 8457 }); 8458 8459 $.ajax({ 8460 type: "POST", 8461 url: urlAJAX, 8462 data: {type: "setLignesFactures", lignesFactures : lignesFactures}, 8463 beforeSend: function(){ 8464 affMsgAttenteParDessusInDiv("div_resaRecap", "recapPrix", txtAttente); 8465 afficheLoaderGlobal_site(); 8466 }, 8467 success: function(result){ 8468 // TODO : si pas erreur, afficher le HTML récupéré à sa place (div_recapPrix?) 8469 var tabResult = XMLToArray(result); 8470 if (tabResult.code=="OK") { 8471 if (tabResult.recapPrix) { 8472 afficheEffaceRecapPrix_Prod(tabResult); 8473 } else { 8474 $("#div_recapInfos").html(tabResult.recapInfos); 8475 $("#div_recapPrix").hide(); 8476 } 8477 if (tabResult.nbPers) { 8478 majLstCanevasOblig(tabResult.nbPers); 8479 } 8480 verifAllNbPaxCodeStock_hotel(); 8481 effaceMsgAttenteParDessus("recapPrix"); 8482 } 8483 }, 8484 complete: function(){ 8485 effaceLoaderGlobal_site(); 8486 } 8487 }); 8488 })(jQuery); 8489} 8490 8491function setLignesFactures(){ 8492 (function($){ 8493 var lignesFactures = new Array(); 8494 var i = 0; 8495 $(".div_uneChambreTarifs:visible").each(function(){ 8496 var tarifs = new Array(); 8497 var nbAdultes = 0; var nbEnfants = 0; 8498 var codeStock = $(this).find(".inpt_codeStock").val(); 8499// var libelleLF = $(this).find(".div_infosTarif .sp_libTarif").text(); 8500 var divTarifs = $(this).children(".div_tarif"); 8501 var j = 0; 8502 var nbAduDec; var nbEnfDec; 8503 var commLF = ''; 8504 divTarifs.each(function(){ 8505 $(this).removeClass('invalide'); 8506 var idTarif = $(this).find(".inpt_idTarif").val(); 8507 if ($(this).find(".select_compoQte").length>0) { 8508 nbAduDec = $(this).find(".select_compoQte").val(); 8509 nbEnfDec = 0; 8510 } else if ($(this).find(".inpt_supplementForfaitaire").length>0) { 8511 if ($(this).find(".inpt_supplementForfaitaire").is(':checked')) { 8512 nbAduDec = 1; 8513 nbEnfDec = 0; 8514 } else { 8515 nbAduDec = 0; 8516 nbEnfDec = 0; 8517 } 8518 } else { 8519 nbAduDec = $(this).find(".select_compoFamilleAdulte").val(); 8520 if ($(this).find(".select_compoFamilleEnfant").length>0) { 8521 nbEnfDec = $(this).find(".select_compoFamilleEnfant").val(); 8522 } else { 8523 nbEnfDec = 0; 8524 } 8525 } 8526 8527// var libelleLT = $(this).find('.div_infosTarif span').first().text(); 8528 var nbPax = parseInt(nbAduDec) + parseInt(nbEnfDec); 8529 if (!$(this).hasClass("supplement")) { 8530 nbAdultes = nbAduDec; 8531 nbEnfants = nbEnfDec; 8532 } 8533 if (nbPax > 0) { 8534// tarifs[j] = new Array(idTarif, libelleLT, nbPax); 8535 tarifs[j] = new Array(idTarif, nbPax); 8536 j++; 8537 } 8538 if ($(this).find('.sp_choixHeureVoiture').length>0) { 8539 commLF = $(this).find('.select_heureVoiture').val(); 8540 } 8541 }); 8542// lignesFactures[i] = new Array(codeStock, libelleLF, nbAdultes, nbEnfants, tarifs, commLF); 8543 lignesFactures[i] = new Array(codeStock, nbAdultes, nbEnfants, tarifs, commLF); 8544 i++; 8545 }); 8546 8547 $.ajax({ 8548 type: "POST", 8549 url: urlAJAX, 8550 data: {type: "setLignesFactures", lignesFactures : lignesFactures}, 8551 beforeSend: function(){ 8552 affMsgAttenteParDessusInDiv("div_resaRecap", "recapPrix", txtAttente); 8553 afficheLoaderGlobal_site(); 8554 }, 8555 success: function(result){ 8556 // TODO : si pas erreur, afficher le HTML récupéré à sa place (div_recapPrix?) 8557 var tabResult = XMLToArray(result); 8558 if (tabResult.code=="OK") { 8559 if (tabResult.recapPrix) { 8560 afficheEffaceRecapPrix_Prod(tabResult); 8561 } else { 8562 $("#div_recapInfos").html(tabResult.recapInfos); 8563 $("#div_recapPrix").hide(); 8564 } 8565 if (tabResult.nbPers) { 8566 majLstCanevasOblig(tabResult.nbPers); 8567 } 8568 } else { 8569 effaceMsgAttenteParDessus("recapPrix"); 8570 } 8571 }, 8572 complete: function(){ 8573 effaceLoaderGlobal_site(); 8574 } 8575 }); 8576 })(jQuery); 8577} 8578 8579function setLignesFactures_locat(){ 8580 (function($){ 8581// setLignesFactures(); 8582 8583 var lignesFactures = new Array(); 8584 var i = 0; 8585 $(".tr_tarifLocat:visible").each(function(){ 8586 var tarifs = new Array(); 8587 var nbAdultes = 0; var nbEnfants = 0; 8588 var codeStock = $(this).attr("data-codestock"); 8589 var idTarif = $(this).attr("data-idtarif"); 8590 var noLigne = $(this).attr("data-noLigne"); 8591 var j = 0; 8592 8593 nbAdultes = $(this).find(".select_nbAdultesLocat").val(); 8594 if ($(this).find(".select_nbEnfantsLocat").length>0) { 8595 nbEnfants = $(this).find(".select_nbEnfantsLocat").val(); 8596 } else { 8597 nbEnfants = 0; 8598 } 8599 8600 var nbPax = parseInt(nbAdultes) + parseInt(nbEnfants); 8601 if (nbPax > 0) { 8602 tarifs[j] = new Array(idTarif, nbPax); 8603 j++; 8604 } 8605 8606 // On récupère les suppléments rattachés à ce tarif 8607 $('.tr_tarifSupplement').each(function(){ 8608 if ($(this).attr('data-idtarifprod')==idTarif && $(this).attr('data-noligne')==noLigne) { 8609 var nbPaxSuppl = 0; 8610 var idTarifSuppl = $(this).attr('data-idtarif'); 8611 if ($(this).find(".select_qteSupplement").length>0) { 8612 nbPaxSuppl = $(this).find(".select_qteSupplement").val(); 8613 } else if ($(this).find(".select_supplementForfaitaire").length>0) { 8614 nbPaxSuppl = $(this).find(".select_supplementForfaitaire").val(); 8615 } 8616 8617 if (nbPaxSuppl > 0) { 8618 tarifs[j] = new Array(idTarifSuppl, nbPaxSuppl); 8619 j++; 8620 } 8621 } 8622 }); 8623 8624 if (nbAdultes>0) { 8625 lignesFactures[i] = new Array(codeStock, nbAdultes, nbEnfants, tarifs); 8626 i++; 8627 } 8628 }); 8629 8630 // TODO : gérer les suppléments 8631 8632 $.ajax({ 8633 type: "POST", 8634 url: urlAJAX, 8635 data: {type: "setLignesFactures", lignesFactures : lignesFactures}, 8636 beforeSend: function(){ 8637 affMsgAttenteParDessusInDiv("div_resaRecap", "recapPrix", txtAttente); 8638 afficheLoaderGlobal_site(); 8639 }, 8640 success: function(result){ 8641 // TODO : si pas erreur, afficher le HTML récupéré à sa place (div_recapPrix?) 8642 var tabResult = XMLToArray(result); 8643 if (tabResult.code=="OK") { 8644 $('.spanErreurAjax','.div_uneEtape_prodGP').remove(); 8645 if (tabResult.recapPrix) { 8646 afficheEffaceRecapPrix_Prod(tabResult); 8647 } else { 8648 $("#div_recapInfos").html(tabResult.recapInfos); 8649 $("#div_recapPrix").hide(); 8650 } 8651 if (tabResult.nbPers) { 8652 majLstCanevasOblig(tabResult.nbPers); 8653 } 8654 effaceMsgAttenteParDessus("recapPrix"); 8655 } else { 8656 effaceMsgAttenteParDessus("recapPrix"); 8657 afficheMsgErreurSetLignesFactures(tabResult); 8658 } 8659 }, 8660 complete: function(){ 8661 effaceLoaderGlobal_site(); 8662 } 8663 }); 8664 })(jQuery); 8665} 8666
8667function setLignesFactures_billet(){ 8668 (function($){ 8669// setLignesFactures(); 8670 8671 var lignesFactures = new Array(); 8672 var i = 0; 8673 $(".tr_tarifBillet:visible").each(function(){ 8674 var tarifs = new Array(); 8675 var codeStock = $(this).attr("data-codestock"); 8676 var idTarif = $(this).attr("data-idtarif"); 8677 var nbAdultes = 0; var nbEnfants = 0; 8678 var j = 0; 8679 if ($(this).find(".select_qteBillet").length>0) { 8680 nbAdultes = $(this).find(".select_qteBillet").val(); 8681 nbEnfants = 0; 8682 } 8683 8684 var nbPax = parseInt(nbAdultes) + parseInt(nbEnfants); 8685 if (nbPax > 0) { 8686 tarifs[j] = new Array(idTarif, nbPax); 8687 j++; 8688 } 8689 lignesFactures[i] = new Array(codeStock, nbAdultes, nbEnfants, tarifs); 8690 i++; 8691 }); 8692 8693 $.ajax({ 8694 type: "POST", 8695 url: urlAJAX, 8696 data: {type: "setLignesFactures", lignesFactures : lignesFactures}, 8697 beforeSend: function(){ 8698 affMsgAttenteParDessusInDiv("div_resaRecap", "recapPrix", txtAttente); 8699 afficheLoaderGlobal_site(); 8700 }, 8701 success: function(result){ 8702 // TODO : si pas erreur, afficher le HTML récupéré à sa place (div_recapPrix?) 8703 var tabResult = XMLToArray(result); 8704 if (tabResult.code=="OK") { 8705 $('.spanErreurAjax','.div_uneEtape_prodGP').remove(); 8706 if (tabResult.recapPrix) { 8707 afficheEffaceRecapPrix_Prod(tabResult); 8708 } else { 8709 $("#div_recapInfos").html(tabResult.recapInfos); 8710 $("#div_recapPrix").hide(); 8711 } 8712 if (tabResult.nbPers) { 8713 majLstCanevasOblig(tabResult.nbPers); 8714 } 8715 effaceMsgAttenteParDessus("recapPrix"); 8716 } else{ 8717 effaceMsgAttenteParDessus("recapPrix"); 8718 $('#div_selectionBillet select').val(0); 8719 $('#div_selectionBillet select').change(); 8720 afficheMsgErreurSetLignesFactures(tabResult) 8721 } 8722 }, 8723 complete: function(){ 8724 effaceLoaderGlobal_site(); 8725 } 8726 }); 8727 })(jQuery); 8728} 8729 8730function afficheMsgErreurSetLignesFactures(tabResult) { 8731 (function($) { 8732 $("#p_msgErreurs").html(tabResult.msg); 8733 $("#div_msgErreurs").show(); 8734 $('html, body').animate({scrollTop: 0},1000); 8735 $("#div_recapPrix").html(tabResult.msg).show(); 8736 $('.div_uneEtape_prodGP').append('<span style="display:none;" class="spanErreurAjax" >'+tabResult.msg +'</span>'); 8737 hideDivEtapeCanevas(); 8738 })(jQuery); 8739} 8740 8741function verifNbPax(){ 8742 (function($){ 8743 // TODO : récupérer la div conteneur (ajouter une classe commune) 8744 var etapeValide = true; 8745 var div = $('.div_uneEtape_prodGP').attr('id'); 8746 if(typeof div === 'undefined') { 8747 div = $('#div_uneEtape_compoFamilleChambre').attr('id'); 8748 } 8749 var divTarifs; var qte; 8750 switch (div) { 8751 case 'div_uneEtape_hotelChoixChambre': 8752 etapeValide = false; 8753 $('.tr_tarifHotel').each(function(){ 8754 $(this).find('.sp_msgErreurAdultes').hide(); 8755 $(this).removeClass('invalide'); 8756 var nbAdultes = $(this).find('.select_nbAdultesHotel').val(); 8757 var nbEnfants = 0; 8758 if ($(this).find('.select_nbEnfantsHotel').length>0) { 8759 nbEnfants = $(this).find('.select_nbEnfantsHotel').val(); 8760 } 8761// var nbPax = parseInt(nbAdultes) + parseInt(nbEnfants); 8762 if (nbAdultes==0 && nbEnfants>0) { 8763 // TODO : afficher msg erreur et mettre en avant ligne 8764 $(this).addClass('invalide'); 8765 $(this).find('.sp_msgErreurAdultes').show(); 8766 } 8767 if (nbAdultes>0) { 8768 etapeValide = true; 8769 } 8770 8771 // TODO : voir avec Steve si on peut envoyer un nombre inférieur au paramétrage nb_pers_mini du tarif 8772 }); 8773 break; 8774 case 'div_uneEtape_locatChoixChambre': 8775 etapeValide = false;
8776 $('.tr_tarifLocat').each(function(){ 8777 $(this).removeClass('invalide'); 8778 var nbAdultes = $(this).find('.select_nbAdultesLocat').val(); 8779 var nbEnfants = 0; 8780 if ($(this).find('.select_nbEnfantsLocat').length>0) { 8781 nbEnfants = $(this).find('.select_nbEnfantsLocat').val(); 8782 } 8783// var nbPax = parseInt(nbAdultes) + parseInt(nbEnfants); 8784 if (nbAdultes==0 && nbEnfants>0) { 8785 // TODO : afficher msg erreur et mettre en avant ligne 8786 $(this).addClass('invalide'); 8787 } 8788 if (nbAdultes>0) { 8789 etapeValide = true; 8790 } 8791 8792 // TODO : voir avec Steve si on peut envoyer un nombre inférieur au paramétrage nb_pers_mini du tarif 8793 }); 8794 8795 // Pour hotel et locat on va fonctionner dans l'autre sens : par défaut l'étape n'est pas valide 8796 // Dès qu'on trouve un nbPax valide pour l'un des tarifs alors c'est valide 8797// etapeValide = false; 8798// divTarifs = $('#'+div).find('.div_tarif:visible').not('.supplement'); 8799// if (divTarifs.length==0) { 8800// // TODO : changer le message d'erreur pour l'étape : Vous devez sélectionner une chambre et le nombre de personnes 8801// etapeValide = false; 8802// } else { 8803// etapeValide = true; 8804// } 8805// divTarifs.each(function(){ 8806// var nbAdultes = $(this).find('.select_compoFamilleAdulte').val(); 8807// var nbEnfants = $(this).find('.select_compoFamilleEnfant').val(); 8808// var nbPersMini = $(this).attr('data-nbmini'); 8809// var nbPax = parseInt(nbAdultes) + parseInt(nbEnfants); 8810// if (nbAdultes>0) { 8811// etapeValide = true; 8812// } 8813// if (nbPax>=nbPersMini) { 8814// etapeValide = true; 8815// } 8816// if (!etapeValide) { 8817// $(this).addClass('invalide'); 8818// } 8819// }); 8820 break; 8821 case 'div_uneEtape_choixNDate': 8822 if($('.tarifNDatePrixLibre').length>0){ 8823 if(verifMontantLibreCorrect($('.tarifNDatePrixLibre').val())){ 8824 etapeValide = true; 8825 } 8826 else{ 8827 etapeValide = false; 8828 } 8829 break; 8830 } 8831 qte = 0; 8832 $('.td_ndateQuantite select').each(function(){ 8833 qte += $(this).val(); 8834 }); 8835 if (qte==0) { 8836 etapeValide = false; 8837 } else { 8838 etapeValide = true; 8839 } 8840 break; 8841 case 'div_uneEtape_billetChoixPresta': 8842 divTarifs = $('#'+div); 8843 qte = 0; 8844 $('.tr_tarifBillet').each(function(){ 8845 qte += $(this).find('.select_qteBillet').val(); 8846 }); 8847 if (qte==0) { 8848 etapeValide = false; 8849 } else { 8850 etapeValide = true; 8851 } 8852 break; 8853 case 'div_uneEtape_voitureChoixPresta': 8854 etapeValide = false; 8855 $('.tr_tarifVoiture').each(function(){ 8856 $(this).removeClass('invalide'); 8857 var qte = $(this).find('.select_qteVoiture').val(); 8858 if (qte>0) { 8859 etapeValide = true; 8860 } 8861 }); 8862 if($('.inputTarifVoiture:checked').length>0){ 8863 etapeValide = true; 8864 } 8865 break; 8866 case 'div_uneEtape_packageChoixTarif': 8867 qte = 0; 8868 $('#'+div).find('.select_compoNbPers').each(function(){ 8869 qte += $(this).val(); 8870 }); 8871 8872 if (qte==0) { 8873 etapeValide = false;
8874 } else { 8875 etapeValide = true; 8876 } 8877 break; 8878 case 'div_uneEtape_compoFamilleChambre': 8879 etapeValide = true; 8880 var nbAdultes = 0; 8881 $('#div_uneEtape_compoFamilleChambre .select_compoFamilleAdulte').each(function() { 8882 nbAdultes += parseInt($(this).val()); 8883 }); 8884 if(nbAdultes === 0) { 8885 etapeValide = false; 8886 break; 8887 } 8888 // On ne vérifie plus ça, à partir du moment où il y a au moins un adulte c'est bon 8889// // sur site non GP, si on a au moins un adulte dans une chambre, c'est bon 8890// if(!estResaGP()) { 8891// break; 8892// } 8893// sur site GP, s'il y a un enfant dans une chambre, il faut qu'il y ait au moins un adulte dans la même chambre 8894// var nbEnfantsDansUneChambre; 8895// var compoChambreOk = true; 8896// $('#div_uneEtape_compoFamilleChambre .select_compoFamilleEnfant').each(function() { 8897// nbEnfantsDansUneChambre = parseInt($(this).val()); 8898// if(nbEnfantsDansUneChambre > 0) { 8899// var nbAdultesDansUneChambre = parseInt($(this).parents('.div_uneChambre').find('.select_compoFamilleAdulte').val()); 8900// if(nbAdultesDansUneChambre === 0) { 8901// compoChambreOk = false; 8902// return false; 8903// } 8904// } 8905// }); 8906// if(!compoChambreOk) { 8907// etapeValide = false; 8908// } 8909 8910 break; 8911 } 8912 8913 var recapPrixOk = true; 8914 if ($('#div_recapPrix #p_msgErreur').length>0 || $("#p_msgErreurs").is(':visible')) { 8915 recapPrixOk = false; 8916 } 8917 if (etapeValide && recapPrixOk) {
8918 $('#'+div).find('.inpt_validEtape').val('Oui'); 8919 } else { 8920 $('#'+div).find('.inpt_validEtape').val('Non'); 8921 } 8922 })(jQuery); 8923} 8924 8925function verifMontantNullResaBureau(){ 8926 var verif = true; 8927 (function($){ 8928 if ($('#input_prixModifieBureau') && $('#input_okPrixModifieBureau')){ 8929 var val = $('#input_prixModifieBureau').val(); 8930 var forcage = $('#input_okPrixModifieBureau').val(); 8931 if (val<=0 && forcage==0){ 8932 $("#div_confirmMontantNullResaBureau").dialog({ 8933 autoOpen: false, 8934 //height: 420, 8935 width: 500, 8936 modal: true 8937 }); 8938 $('#div_confirmMontantNullResaBureau').dialog( 8939 "option", 8940 "buttons", 8941 { 8942 "Continuer": function () { 8943 //console.log('confirmé'); 8944 $('#input_okPrixModifieBureau').val(1); 8945 $("#div_btnConfirmer > a:not(.a_btnAttenteConfirm)").click(); 8946 $(this).dialog("close"); 8947 }, 8948 "Annuler": function () { 8949 //console.log('annulé'); 8950 $(this).dialog("close"); 8951 } 8952 } 8953 ); 8954 $('#div_confirmMontantNullResaBureau').dialog('open'); 8955 verif=false; 8956 } 8957 8958 } 8959 })(jQuery); 8960 return verif; 8961} 8962 8963function verifChoixHeureVoiture() { 8964 if (!verifHeuresVoiture()) { 8965 return false; 8966 } 8967 var verif = true; 8968 (function ($) { 8969 // On regarde si on a des listes déroulantes select_heureVoiture visibles, si c'est le cas cela signifie qu'on a sélectionné une qte pr un prod VOIT 8970 // Il faut donc vérifier que l'heure a bien été séletionne 8971 if ($('.select_heureVoiture:visible').length > 0) { 8972 var auMoinsUneLigneSelectionee = true; 8973 $('.select_heureVoiture:visible').each(function () { 8974 if ($(this).closest('.tr_tarifVoiture').find('.select_qteVoiture').val() > 0) { 8975 auMoinsUneLigneSelectionee = true; 8976 if ($(this).val() == 0) { 8977 $(this).closest('.tr_tarifVoiture').addClass('invalide'); 8978 var identifiant = $(this).attr('data-identifiant'); 8979 var message = $('.sp_msgErrHeureVoiture[data-identifiant="' + identifiant + '"]').text(); 8980 message = "- " + message; 8981 if ($("#div_msgErreurs:visible").length == 0) { 8982 $("#p_msgErreurs").html(message); 8983 $("#div_msgErreurs").show(); 8984 } else { 8985 $("#p_msgErreurs").append("<br />"); 8986 $("#p_msgErreurs").append(message); 8987 } 8988 document.location = "#div_msgErreurs"; 8989 verif = false; 8990 } 8991 } 8992 }); 8993 if (!auMoinsUneLigneSelectionee) { 8994 verif = false; 8995 }; 8996 } 8997 })(jQuery); 8998 return verif; 8999} 9000 9001function initModifEtape(){ 9002 (function($){ 9003 // Modification d'une étape validée (le bouton s'affiche seulement après les validations) 9004 $(".a_modifEtape").click(function(){ 9005 $(this).siblings("h3").find(".sp_lblEtape").validationEngine("hide"); 9006// $(this).parents(".div_uneEtape").find(".inpt_validEtape").val("Non"); 9007 $(this).parents(".div_uneEtape").find(".div_uneEtapeRecap").hide("slow"); 9008 $(".div_uneEtapeCurr").removeClass('div_uneEtapeCurr'); 9009 $(this).parents(".div_uneEtape").addClass('div_uneEtapeCurr'); 9010 $(this).parents(".div_uneEtape").find(".div_uneEtapeContent").show("slow",function(){ 9011 $(this).parents(".div_uneEtape").find(".div_uneEtapeContent").css("overflow",""); 9012 }); 9013 $(this).hide(); 9014 }); 9015 })(jQuery); 9016} 9017 9018function setEventsForNDate() { 9019 (function($){ 9020 initDescTarifQTip(); 9021 $('.td_ndateQuantite select').change(function(){ 9022 var qte = 0; 9023 9024 $('.td_ndateQuantite select').each(function(){ 9025 qte += $(this).val(); 9026 }); 9027 9028 if (qte==0) { 9029 // TODO : masquer recapPrix, recapInfos et invalider étape 9030 majLstCanevasOblig(0); 9031 activeCanevasAvecTarifForfaitaire(); 9032 } else { 9033 setLignesFactures_ndate(); 9034 } 9035 }); 9036 if ($("#div_uneEtape_canevas").length>0){ 9037 initCanevasResaCouplee(1); 9038 } 9039 })(jQuery); 9040} 9041 9042function setEventsForPack(dateLigneFacture){ 9043 (function($){ 9044// $('.select_compoQte').live('change', function(){ 9045// var qte = $(this).val(); 9046// var listeNbPers = $(this).parent().find('.select_compoNbPers'); 9047// var nbPers = listeNbPers.find('option[data-qte='+qte+']').val(); 9048// listeNbPers.val(nbPers); 9049// 9050// if (qte>0) { 9051// $(this).parents('.div_unTarifContent').find('.div_unTarifComposants').show('slow'); 9052// } else { 9053// $(this).parents('.div_unTarifContent').find('.div_unTarifComposants').hide('slow'); 9054// } 9055// 9056// var qteTotal = 0; 9057// $('.select_compoQte').each(function(){ 9058// qteTotal += $(this).val(); 9059// }); 9060// 9061// if (qteTotal>0) { 9062// setLignesFactures_package(); 9063// } else { 9064// $('#div_recapPrix').hide(); 9065// } 9066// }); 9067 9068 //$('.select_compoNbPers').off('change'); /// Attention à la mise en ligne 9069 //$('.select_compoNbPers').on('change', function(){ 9070 $('.select_compoNbPers').live('change', function(){ 9071 var qte = $(this).find('option:selected').attr('data-qte'); 9072// var listeQte = $(this).parent().find('.select_compoQte'); 9073// listeQte.val(qte); 9074 9075 // On affiche les composants si on a sélectionné une quantité et qu'il y a des composants à afficher 9076 if (qte>0 && $(this).parents('.div_unTarifContent').find('.div_unTarifComposants').children('.div_unComposantConsultable').length>0) { 9077 $(this).parents('.div_unTarifContent').find('.div_unTarifComposants').show(); 9078 } else { 9079 $(this).parents('.div_unTarifContent').find('.div_unTarifComposants').hide(); 9080 } 9081 9082 var qteTotal = 0; 9083// $('.select_compoQte').each(function(){ 9084// qteTotal += $(this).val(); 9085// }); 9086 9087 $('.select_compoNbPers').each(function(){ 9088 qteTotal += parseInt($(this).find('option:selected').attr('data-qte')); 9089 }); 9090// if (qteTotal>0 || dateLigneFacture) { // attention à la mise en ligne 9091 if (qteTotal>0) { 9092 setLignesFactures_package(dateLigneFacture); 9093 } else { 9094 $('#div_recapPrix').hide(); 9095 } 9096 }); 9097 9098 $('.a_choixAlternatives').live('click', function(){ 9099 var divARemplir = $(this).parents('.div_unComposant').find('.div_unComposantAlternatives'); 9100 var divDetailComposant = $(this).parents('.div_unComposant').find('.div_detailComposant'); 9101 if (divARemplir.html().length>0) { 9102 if (divARemplir.is(':visible')) { 9103 divARemplir.hide(); 9104 divDetailComposant.show(); 9105 } else { 9106 divARemplir.show(); 9107 selectionneTarifSelectDansAlternatives(divARemplir); 9108 divDetailComposant.hide(); 9109 } 9110 } else { 9111 // On va charger toutes les alternatives du tarif afin de pouvoir faire les correspondances entre les alternatives 9112 // Par exemple dans le cas des petits déjeuners, ils sont liés à un Hotel donc si on change d'Hotel il faut également changer le petit déjeuner 9113 // Pour éviter de dormir dans un hotel et avoir le petit dej dans un autre 9114 var btnsAlternatives = $(this).parents('.div_unTarifComposants').find('.a_choixAlternatives'); 9115 btnsAlternatives.each(function(){ 9116 var idTarif = $(this).parents('.div_unTarif').find('.inpt_idTarif').val(); 9117// var idComposant = $(this).parents('.div_unComposant').find('.inpt_idComposant').val(); 9118 var idComposant = $(this).parents('.div_unComposant').attr('data-idcomposant'); 9119 var divAlternative = $(this).parents('.div_unComposant').find('.div_unComposantAlternatives'); 9120 9121 $.ajax({ 9122 type: 'POST', 9123 url: urlAJAX, 9124 data: {type: 'getHTML_choixAlternatives', idTarif: idTarif, idComposant: idComposant}, 9125 beforeSend: function(){
9126 // Par contre on affiche uniquement la div correspondant au bouton sur lequel on vient de cliquer 9127 divDetailComposant.hide(); 9128 divARemplir.show(); 9129 divARemplir.html(txtAttente); 9130 }, 9131 success: function(result){ 9132 var tabResult = XMLToArray(result); 9133 if (tabResult.code==='OK') { 9134 divAlternative.html(tabResult.html); 9135 selectionneTarifSelectDansAlternatives(divARemplir); 9136 } 9137 9138 } 9139 }); 9140 }); 9141 } 9142 9143 }); 9144 9145 $('.a_btnChoixAlternative').live('click', function(){ 9146 affecteAlternative($(this)); 9147 9148 // On va regarder si l'alternative qu'on vient de choisir est liée à une autre alternative du tarif 9149// var libelleComposant = $(this).parents('.div_alternativeBtns').find('.inpt_nomAlternative').val(); 9150 9151 // fiche 230411 : vu avec Yoann, on met en commentaires pour l'instant le code ci-dessous, ce qui permet de résoudre le bug de cette fiche 9152 9153// var libelleComposant = $(this).attr('data-libelle'); 9154//// var numProd = $(this).parents('.div_alternativeBtns').find('.inpt_numProd').val(); 9155// var numProd = $(this).attr('data-numprod'); 9156// var divBtnsAlternatives = $(this).parents('.div_unTarifComposants').find('.a_btnChoixAlternative'); 9157// divBtnsAlternatives.each(function(){ 9158// if ($(this).attr('data-numprod')==numProd && $(this).attr('data-libelle')!=libelleComposant) { 9159// affecteAlternative($(this)); 9160// } 9161// }); 9162 setLignesFactures_package(); 9163 }); 9164 9165 $(".affichePlusAlternative a").live('click',function(){ 9166 $(".div_detailAlternative.masque").show(); 9167 $(this).hide(); 9168 }); 9169 $(".a_linkDetailAlternativeFancyBox").fancybox({ 9170 fitToView : false, 9171 width : '80%', 9172 height : '80%', 9173 autoSize : false, 9174 closeClick : false, 9175 closeEffect : 'none' 9176 }); 9177 9178 })(jQuery); 9179} 9180 9181function selectionneTarifSelectDansAlternatives(divAlternatives){ 9182 (function($){ 9183 var idTarifComposant = divAlternatives.parents('.div_unComposant').attr('data-idtarif'); 9184 divAlternatives.find('.div_detailAlternative').each(function(){ 9185 var idTarif = $(this).find('.a_btnChoixAlternative').attr('data-idtarif') 9186 if (idTarif == idTarifComposant) { 9187 $(this).addClass('selected'); 9188 } else { 9189 $(this).removeClass('selected'); 9190 } 9191 }); 9192 })(jQuery); 9193} 9194 9195function affecteAlternative(elemBtn){ 9196 (function($){ 9197 var libelleComposant = elemBtn.attr('data-libelle'); 9198 var nomComposant = elemBtn.attr('data-nom'); 9199 var idComposant = elemBtn.attr('data-idtarif'); 9200 var srcImage = elemBtn.attr('data-image'); 9201 var linkToFiche = elemBtn.attr('data-linkfiche'); 9202 var prix = elemBtn.attr('data-prix'); 9203 elemBtn.parents('.div_unComposantAlternatives').hide(); 9204 if (elemBtn.parents('.div_unComposant').attr('data-idtarif')!=idComposant) { 9205 elemBtn.parents('.div_unComposant').attr('data-idtarif', idComposant); 9206 elemBtn.parents('.div_unComposant').find('.div_detailComposant').find('.titreComposantNomLibelle').text(libelleComposant); 9207 elemBtn.parents('.div_unComposant').find('.div_detailComposant').find('.titreComposantNom').text(nomComposant); 9208 elemBtn.parents('.div_unComposant').find('.div_detailComposant').find('.div_composantVignette img').attr('src', srcImage); 9209 elemBtn.parents('.div_unComposant').find('.div_detailComposant').find('.a_lnkToFiche').attr('href', linkToFiche); 9210 elemBtn.parents('.div_unComposant').find('.div_detailComposant').find('.a_linkDetailAlternativeFancyBox').attr('href', linkToFiche); 9211 elemBtn.parents('.div_unComposant').find('.div_detailComposant').find('.sp_prixComposant').text(prix); 9212 } 9213 elemBtn.parents('.div_unComposant').find('.div_detailComposant').show(); 9214 9215 })(jQuery); 9216} 9217 9218function setEventsForVoiture(){ 9219 (function($){ 9220 $('.select_qteVoiture').live('change', function(){ 9221 var qte = $(this).val(); 9222 9223 if (qte>0) { 9224 setLignesFactures_voiture(); 9225 } else { 9226 $('#div_recapPrix').hide(); 9227 } 9228 }); 9229 $('.select_heureVoiture').live('change', function(){ 9230 setLignesFactures_voiture(); 9231 }); 9232 $(document).delegate('.inputTarifVoiture','change', function(){ 9233 if(!setLignesFactures_voitureNew()){ 9234 return false;
9235 } 9236 }); 9237 // dès qu'on change d'horaire, on renvoie les dates avec les nouveaux horaires car ça peut changer les tarifs dispo 9238 $(document).delegate('.inputHeureVoiture','change', function(){ 9239 var dateFin = $("#inpt_resaDateFin").val(); 9240 var dateDeb = $("#inpt_resaDateDeb").val(); 9241 var heuresByStock = {}; 9242 $('.inputHeureVoiture').each(function(){ 9243 var codeStock = $(this).data('codestock'); 9244 heuresByStock[codeStock] = heuresByStock[codeStock] || {}; 9245 if($(this).hasClass('inputHeureDebVoiture')){ 9246 heuresByStock[codeStock].HEUREDEB = $(this).val(); 9247 } 9248 if($(this).hasClass('inputHeureFinVoiture')){ 9249 heuresByStock[codeStock].HEUREFIN = $(this).val(); 9250 } 9251 }); 9252 var tabData = {type: "verifDates_GP", dateDeb: dateDeb, dateFin: dateFin, HEURESVOITUREBYSTOCK : heuresByStock} 9253 ajaxVerifDates(tabData); 9254 }); 9255 })(jQuery); 9256} 9257 9258function verifHeuresVoiture() { 9259 return (function ($) { 9260 // si on a rien à vérifier on sort 9261 if($('.inputHeureDebVoiture').length === 0){ 9262 return true; 9263 } 9264 if($('.inputTarifVoiture:checked').length === 0){ 9265 return true; 9266 } 9267 var dateFin = $("#inpt_resaDateFin").val(); 9268 var dateDeb = $("#inpt_resaDateDeb").val(); 9269 if (!dateFin || !dateDeb) { 9270 return false; 9271 } 9272 // on fait un test sur la cohérence des horaires (si c'est le même jour on regarde si l'heure de deb est bien inférieure à l'heure de fin) 9273 var tabValidation = []; 9274 var regexHeure = /^[0-9]{2}:[0-9]{2}$/; 9275 var typePlan = $('.inputTarifVoiture:checked').data('codestock'); 9276 9277 var heureDeb = new LiveValidation('inputHeureDebVoiture_'+typePlan, {validMessage: $('#inpt_msgOk').val()}); 9278 heureDeb.add(Validate.Presence, {failureMessage: $('#inpt_msgVide').val()}); 9279 heureDeb.add(Validate.Format, {pattern: regexHeure, failureMessage: 'format 00:00'}); 9280 heureDeb.add(Validate.Custom, {against: function (value, args) { 9281 var heuresAutorisees = $('#inputHeureDebVoiture_'+typePlan).data('heures_autorisees'); 9282 if (heuresAutorisees.indexOf(value) < 0) { 9283 return false; 9284 } 9285 return true; 9286 }, failureMessage: $('.inpt_msgHeuresIncoherentes:first').val()}); 9287 tabValidation.push(heureDeb); 9288 var heureFin = new LiveValidation('inputHeureFinVoiture_'+typePlan, {validMessage: $('#inpt_msgOk').val()}); 9289 heureFin.add(Validate.Presence, {failureMessage: $('#inpt_msgVide').val()}); 9290 heureFin.add(Validate.Format, {pattern: regexHeure, failureMessage: 'format 00:00'}); 9291 heureFin.add(Validate.Custom, {against: function (value, args) { 9292 if (dateDeb === dateFin) { 9293 var valDeb = $('#inputHeureDebVoiture_'+typePlan).val(); 9294 var heureDeb = valDeb.replace(':', ''); 9295 var heureFin = value.replace(':', ''); 9296 if (parseInt(heureDeb) >= parseInt(heureFin)) { 9297 return false; 9298 } 9299 var heuresAutorisees = $('#inputHeureFinVoiture_'+typePlan).data('heures_autorisees'); 9300 if(heuresAutorisees.indexOf(value)<0){ 9301 return false; 9302 } 9303 } 9304 return true; 9305 }, failureMessage: $('#inpt_msgHeuresIncoherentes').val()}); 9306 tabValidation.push(heureFin); 9307 if (!LiveValidation.massValidate(tabValidation)) { 9308 $("#div_uneEtape_date .div_uneEtapeRecap").hide(); 9309 if ($("#inpt_avecRepli").length > 0) { 9310 $("#div_uneEtape_date .div_uneEtapeContent").show(); 9311 } 9312 return false; 9313 } 9314 return true; 9315 })(jQuery); 9316} 9317 9318function setLignesFactures_package(dateLigneFacture){ 9319 (function($){ 9320 var lignesFactures = new Array(); 9321 var i = 0; 9322 $(".div_unTarifComposants").each(function(){ 9323 var tarifs = new Array(); var decomptes = new Array(); 9324 var nbEnfants = 0; 9325 var listeNbPers = $(this).parents('.div_unTarifContent').find(".div_unTarifSelection .select_compoNbPers"); 9326 var nbAdultes = listeNbPers.val(); 9327 var nbPax = nbAdultes; 9328 var qte = listeNbPers.find('option:selected').attr('data-qte'); 9329 var codeStock = ''; 9330 var idTarif = $(this).find('.inpt_idTarif').val(); 9331 var divComposants = $(this).find(".div_unComposant"); 9332 var j = 0; 9333 divComposants.each(function(){ 9334 var idComposant = $(this).attr('data-idcomposant'); 9335 var idTarifCompo = $(this).attr('data-idtarif'); 9336 decomptes[j] = new Array(idComposant, idTarifCompo); 9337 j++; 9338 }); 9339 tarifs[0] = new Array(idTarif, nbPax, qte, decomptes); 9340 lignesFactures[i] = new Array(codeStock, nbAdultes, nbEnfants, tarifs); 9341 i++; 9342 }); 9343 9344 $.ajax({ 9345 type: "POST", 9346 url: urlAJAX, 9347 data: {type: "setLignesFactures", lignesFactures : lignesFactures, dateLigneFacture:dateLigneFacture}, 9348 beforeSend: function(){ 9349 affMsgAttenteParDessusInDiv("div_resaRecap", "recapPrix", txtAttente); 9350 afficheLoaderGlobal_site(); 9351 }, 9352 success: function(result){ 9353 var tabResult = XMLToArray(result); 9354 if (tabResult.code=="OK") { 9355 $("#div_msgErreurs").hide(); 9356 $('.spanErreurAjax','.div_uneEtape_prodGP').remove(); 9357 if (tabResult.recapPrix) { 9358 afficheEffaceRecapPrix_Prod(tabResult); 9359 } else { 9360 $("#div_recapInfos").html(tabResult.recapInfos); 9361 $("#div_recapPrix").hide(); 9362 } 9363 if (tabResult.nbPers) { 9364 majLstCanevasOblig(tabResult.nbPers); 9365 } 9366 9367 $('.div_unTarifComposants').each(function(){ 9368 if ($(this).children('.div_unComposant:visible').length==0) { 9369 $(this).hide(); 9370 } 9371 }); 9372 showDivEtapeCanevas(); 9373 9374 } else { 9375 afficheMsgErreurSetLignesFactures(tabResult); 9376 } 9377 effaceMsgAttenteParDessus("recapPrix"); 9378 }, 9379 complete: function(){ 9380 effaceLoaderGlobal_site(); 9381 } 9382 }); 9383 })(jQuery); 9384} 9385 9386function setLignesFactures_ndate(){ 9387 (function($){ 9388 var lignesFactures = new Array(); 9389 var i = 0; 9390 // dans le cas d'un ndate avec prix libre (genre carte cadeau), on appelle setLignesFactures_ndate au clic sur le bouton valider etape1 9391 // donc il faut d'abord envoyer les lignes factures avant de valider l'étape1 9392 var appelAsync = true; 9393 $('.tr_tarifNDate').each(function(){ 9394 var tarifs = new Array(); 9395 // TODO : qteMini??? 9396 var codeStock = $(this).find(".inpt_codeStock").val(); 9397 var idTarif = $(this).find(".inpt_idTarif").val(); 9398 var qte; 9399 // pour les tarifs avec prix libre (genre carte cadeau), on doit mettre en quantité 1 et ajouter le montant saisi 9400 if($('.tarifNDatePrixLibre',this).length >0){ 9401 appelAsync = false;
9402 qte = 1; 9403 var montantPrixLibre = $(this).find('.tarifNDatePrixLibre').val(); 9404 tarifs[0] = {0:idTarif,1: qte,prixLibre:montantPrixLibre}; 9405 } 9406 else{ 9407 qte = $(this).find(".td_ndateQuantite select").val(); 9408 tarifs[0] = new Array(idTarif, qte); 9409 } 9410 // Pour la résa panier 9411 var codeProd = $(this).find(".inpt_codeProd").val(); 9412 lignesFactures[i] = new Array(codeStock, qte, 0, tarifs, '', codeProd); 9413 i++; 9414 }); 9415 $('.spanErreurAjax','.div_uneEtape_prodGP').remove(); 9416 $.ajax({ 9417 async: appelAsync, 9418 type: "POST", 9419 url: urlAJAX, 9420 data: {type: "setLignesFactures", lignesFactures : lignesFactures}, 9421 beforeSend: function(){ 9422 affMsgAttenteParDessusInDiv("div_resaRecap", "recapPrix", txtAttente); 9423 afficheLoaderGlobal_site(); 9424 }, 9425 success: function(result){ 9426 // TODO : si pas erreur, afficher le HTML récupéré à sa place (div_recapPrix?) 9427 var tabResult = XMLToArray(result); 9428 if (tabResult.code=="OK") { 9429 if (tabResult.recapPrix) { 9430 afficheEffaceRecapPrix_Prod(tabResult); 9431 } else { 9432 $("#div_recapInfos").html(tabResult.recapInfos); 9433 $("#div_recapPrix").hide(); 9434 } 9435// var html_recapPrix = tabResult.recapPrix; 9436// var html_choixAssurance = tabResult.choixAssurance; 9437// $("#div_recapPrix").html(html_recapPrix).show(); 9438// $("#div_recapInfosEtPrix").show(); 9439// if (html_choixAssurance.length>0) { 9440// $('#div_assuranceAnnul').html(html_choixAssurance); 9441// $("#div_uneEtape_assuranceAnnul").removeClass("div_uneEtapeGrisee"); 9442// $('#div_uneEtape_assuranceAnnul').show(); 9443// } 9444// majNumEtapes(); 9445// // On rappelle les fonctions permettant d'initialiser les évènement sur les éléments HTML que l'on vient d'ajouter 9446// initAssurance(); initModifEtape(); 9447// $("#div_recapInfos").html(tabResult.recapInfos); 9448// // On masque le racap de l'assurance si on ne la propose pas 9449// if ($("#div_uneEtape_assuranceAnnul").not(':visible')) { 9450// $("#div_uneEtape_assuranceAnnul").hide(); 9451// $('.p_recapInfosAssur').hide(); 9452// } 9453// if (tabResult.nbPers) { 9454// majLstCanevasOblig(tabResult.nbPers); 9455// activeCanevasAvecTarifForfaitaire(); 9456// } 9457 effaceMsgAttenteParDessus("recapPrix"); 9458 } 9459 else{ 9460 $("#div_recapPrix").html('<p>'+tabResult.msg +'</p>').show(); 9461 $('.div_uneEtape_prodGP').append('<span style="display:none;" class="spanErreurAjax" >'+tabResult.msg +'</span>'); 9462 } 9463 }, 9464 complete: function(){ 9465 effaceLoaderGlobal_site(); 9466 } 9467 }); 9468 })(jQuery); 9469} 9470 9471function setLignesFactures_voiture(){ 9472 (function($){ 9473 9474 var lignesFactures = new Array(); 9475 var i = 0; 9476 $(".tr_tarifVoiture:visible").each(function(){ 9477 var tarifs = new Array(); 9478 var codeStock = $(this).attr("data-codestock"); 9479 var idTarif = $(this).attr("data-idtarif"); 9480 var nbAdultes = 0; var nbEnfants = 0; 9481 var j = 0; 9482 var commLF = ''; 9483 if ($(this).find(".select_qteVoiture").length>0) { 9484 nbAdultes = $(this).find(".select_qteVoiture").val(); 9485 nbEnfants = 0; 9486 } 9487 9488 var nbPax = parseInt(nbAdultes) + parseInt(nbEnfants); 9489 if (nbPax > 0) { 9490 tarifs[j] = new Array(idTarif, nbPax); 9491 j++; 9492 } 9493 9494 if ($(this).find('.td_heurePriseVoiture').length>0) { 9495 commLF += $(this).find('.td_heurePriseVoiture .select_heureVoiture').val(); 9496 } 9497 if ($(this).find('.td_heureDepotVoiture').length>0) { 9498 commLF += '-'; 9499 commLF += $(this).find('.td_heureDepotVoiture .select_heureVoiture').val(); 9500 } 9501 9502 lignesFactures[i] = new Array(codeStock, nbAdultes, nbEnfants, tarifs, commLF); 9503 i++; 9504 }); 9505 9506 $.ajax({ 9507 type: "POST", 9508 url: urlAJAX, 9509 data: {type: "setLignesFactures", lignesFactures : lignesFactures}, 9510 beforeSend: function(){ 9511 affMsgAttenteParDessusInDiv("div_resaRecap", "recapPrix", txtAttente); 9512 afficheLoaderGlobal_site(); 9513 }, 9514 success: function(result){ 9515 // TODO : si pas erreur, afficher le HTML récupéré à sa place (div_recapPrix?) 9516 var tabResult = XMLToArray(result); 9517 if (tabResult.code=="OK") { 9518 if (tabResult.recapPrix) { 9519 afficheEffaceRecapPrix_Prod(tabResult); 9520 } else { 9521 $("#div_recapInfos").html(tabResult.recapInfos); 9522 $("#div_recapPrix").hide(); 9523 } 9524 if (tabResult.nbPers) { 9525 majLstCanevasOblig(tabResult.nbPers); 9526 } 9527 effaceMsgAttenteParDessus("recapPrix"); 9528 } 9529 }, 9530 complete: function(){ 9531 effaceLoaderGlobal_site(); 9532 } 9533 }); 9534 })(jQuery); 9535} 9536 9537function setLignesFactures_voitureNew(){ 9538 if(!verifHeuresVoiture()){ 9539 return false;
9540 } 9541 (function($){ 9542 var lignesFactures = new Array(); 9543 var i = 0; 9544 var heures = {}; 9545 var params = { 9546 type: "setLignesFactures" 9547 }; 9548 //on a qu'un tarif sélectionné quand on est sur de la voiture 9549 $('.inputTarifVoiture:checked').each(function(){ 9550 var tarifs = new Array(); 9551 var codeStock = $(this).attr('data-codestock'); 9552 var idTarif = $(this).attr('data-idtarif'); 9553 tarifs[0] = new Array(idTarif, 1); 9554 lignesFactures[i] = new Array(codeStock, 1, 0, tarifs); 9555 heures[idTarif] = { 9556 deb : $('#inputHeureDebVoiture_'+codeStock).val(), 9557 fin : $('#inputHeureFinVoiture_'+codeStock).val() 9558 } 9559 i++; 9560 }); 9561 params.lignesFactures = lignesFactures; 9562 params.heures = heures; 9563 $.ajax({ 9564 type: "POST", 9565 url: urlAJAX, 9566 data: params, 9567 beforeSend: function(){ 9568 affMsgAttenteParDessusInDiv("div_resaRecap", "recapPrix", txtAttente); 9569 afficheLoaderGlobal_site(); 9570 }, 9571 success: function(result){ 9572 // TODO : si pas erreur, afficher le HTML récupéré à sa place (div_recapPrix?) 9573 var tabResult = XMLToArray(result); 9574 if (tabResult.code=="OK") { 9575 if (tabResult.recapPrix) { 9576 afficheEffaceRecapPrix_Prod(tabResult); 9577 } else { 9578 $("#div_recapInfos").html(tabResult.recapInfos); 9579 $("#div_recapPrix").hide(); 9580 } 9581 if (tabResult.nbPers) { 9582 majLstCanevasOblig(tabResult.nbPers); 9583 } 9584 effaceMsgAttenteParDessus("recapPrix"); 9585 } 9586 }, 9587 complete: function(){ 9588 effaceLoaderGlobal_site(); 9589 } 9590 }); 9591 })(jQuery); 9592} 9593 9594function setEventsForLocat(){ 9595 (function($){ 9596 $('.select_nbCodeStock').live('change', function(){ 9597 var codeStock = $(this).attr('data-codestock'); 9598 var nbCodeStock = $(this).val(); 9599 $('.tr_tarifLocat[data-codestock="'+codeStock+'"]').hide(); 9600 $('.enteteCodeStock[data-codestock="'+codeStock+'"][data-noligne!="1"]').hide(); 9601 for (var i=1; i<=nbCodeStock; i++) { 9602 $('.enteteCodeStock[data-codestock="'+codeStock+'"][data-noligne="'+i+'"]').show(); 9603 $('.tr_tarifLocat[data-codestock="'+codeStock+'"][data-noligne="'+i+'"]').show(); 9604 } 9605 setLignesFactures_locat(); 9606 afficheMasqueHeaderLocat(); 9607 }); 9608 9609 $(".select_nbAdultesLocat").live('change', function(){ 9610 // On met à jour la liste déroulante enfant/adulte en fonction du nbPersMaxi 9611 var nbPersMaxi = $(this).parents('.tr_tarifLocat').attr('data-nbmaxi'); 9612 var nbAdultes = $(this).val(); 9613 var nbEnfantsMax = parseInt(nbPersMaxi) - parseInt(nbAdultes); 9614 var listeEnfants = $(this).parents('.tr_tarifLocat').find('.select_nbEnfantsLocat'); 9615 var idTarif = $(this).parents('.tr_tarifLocat').attr('data-idtarif'); 9616 var noLigne = $(this).parents('.tr_tarifLocat').attr('data-noligne'); 9617 9618 // Si on prend des adultes on affiche les suppléments sinon on masque les suppléments 9619 $('.tr_supplementsTarif').each(function(){ 9620 if ($(this).attr('data-idtarifprod')==idTarif && $(this).attr('data-noligne')==noLigne) { 9621 if (nbAdultes>0) { 9622 $(this).show(); 9623 } else { 9624 $(this).hide(); 9625 } 9626 } 9627 }); 9628 9629 if (nbEnfantsMax==0) { 9630 listeEnfants.hide(); 9631 } else { 9632 listeEnfants.show(); 9633 listeEnfants.find('option').each(function(){ 9634 if ($(this).val()>nbEnfantsMax) { 9635 $(this).hide(); 9636 } else { 9637 $(this).show(); 9638 } 9639 }); 9640 } 9641 9642 // Si on a aucune personne de sélectionnée on masque le recapPrix, on invali
9642de l'étape et on ne fait pas le setLignesFactures 9643 var nbAdultesTot = 0; 9644 $('.select_nbAdultesLocat:visible').each(function(){ 9645 if ($(this).val()>0) { 9646 nbAdultesTot += $(this).val(); 9647 } 9648 }); 9649 if (nbAdultesTot==0) { 9650 $('#div_uneEtape_locatChoixChambre').find('.inpt_validEtape').val('Non'); 9651 $('#div_recapPrix').hide(); 9652 $('#div_recapInfosFamille').remove(); 9653 } 9654 else { 9655 setLignesFactures_locat(); 9656 } 9657 9658 var nbEnfants = listeEnfants.val(); 9659 var nbPax = parseInt(nbAdultes) + parseInt(nbEnfants); 9660 majListesSupplementsLocat(idTarif, nbPax); 9661 }); 9662 9663 $(".select_nbEnfantsLocat").live('change', function(){ 9664 // On met à jour la liste déroulante enfant/adulte en fonction du nbPersMaxi 9665 var nbEnfants = $(this).val(); 9666 var nbAdultes = $(this).parents('.tr_tarifLocat').find('.select_nbAdultesLocat').val(); 9667 var nbPersMaxi = $(this).parents('.tr_tarifLocat').attr('data-nbmaxi'); 9668 var nbAdultesMax = parseInt(nbPersMaxi) - parseInt(nbEnfants); 9669 var listeAdultes = $(this).parents('.tr_tarifLocat').find('.select_nbAdultesLocat'); 9670 9671 listeAdultes.find('option').each(function(){ 9672 if ($(this).val()>nbAdultesMax) { 9673 $(this).hide(); 9674 } else { 9675 $(this).show(); 9676 } 9677 }); 9678 9679 if (nbAdultes>0) { 9680 setLignesFactures_locat(); 9681 } 9682 9683 var idTarif = $(this).parents('.tr_tarifLocat').attr('data-idtarif'); 9684 var nbPax = parseInt(nbAdultes) + parseInt(nbEnfants); 9685 majListesSupplementsLocat(idTarif, nbPax); 9686 }); 9687 9688 setEventsSupplements(setLignesFactures_locat); 9689 9690// $('.inpt_supplementForfaitaire').live('change', function(){ 9691// setLignesFactures_locat(); 9692// }); 9693 9694 // Normalement on a plus besoin de ça 9695 $('.a_btnChoixTarif').live('click', function(){ 9696 var div = $(this).attr('data-div'); 9697 var divTarif = $('.'+div+'.divDeBase').clone(); 9698 $(this).parents('.div_uneChambre_choixTarif').after(divTarif); 9699 divTarif.removeClass('divDeBase').show(); 9700 $(this).parents('.div_uneChambre_choixTarif').hide(); 9701 }); 9702 9703 $('.a_modifTarif').live('click', function(){ 9704 $(this).parents('.div_uneChambreTarifs').prev().show(); 9705 $(this).parents('.div_uneChambreTarifs').remove(); 9706 }); 9707 })(jQuery); 9708} 9709 9710function afficheMasqueHeaderLocat(){ 9711 var totalSelect = 0; 9712 jQuery('.select_nbCodeStock').each(function(){ 9713 totalSelect += jQuery(this).val(); 9714 }); 9715 if (totalSelect>0) { 9716 jQuery('#div_selectionLocatif > table > thead').show(); 9717 } else { 9718 jQuery('#div_selectionLocatif > table > thead').hide(); 9719 } 9720} 9721 9722function setEventsForBillet() { 9723 (function($){ 9724 $(".select_qteBillet").live("change", function(){ 9725 // Si on a aucune personne de sélectionnée on masque le recapPrix, on invalide l'étape et on ne fait pas le setLignesFactures 9726 setOnChangeStock(this); 9727 var nbPers = 0; 9728 $('.select_qteBillet:visible').each(function(){ 9729 if ($(this).val()>0) { 9730 nbPers += $(this).val(); 9731 } 9732 }); 9733 if (nbPers==0) { 9734 $('#div_uneEtape_billetChoixPresta').find('.inpt_val
9734idEtape').val('Non'); 9735 $('#div_recapPrix').hide(); 9736 $('#div_recapInfosFamille').remove(); 9737 } 9738 else { 9739 setLignesFactures_billet(); 9740 } 9741 }); 9742 })(jQuery); 9743} 9744 9745/* 9746 * Lorsque ce select est modifié, on update tous les selects partageant son code stock avec le stock restant 9747 * @param Object select $(select à changer) 9748 */ 9749function setOnChangeStock(select) { 9750 (function ($) { 9751 var codestock = $(select).closest('.ligneTarif').attr('data-codestock'); 9752 var currentStock = $(select).closest('.ligneTarif').attr('data-nbstock'); 9753 $(".ligneTarif[data-codestock='" + codestock + "']").find('.td_qte select').each(function () { 9754 currentStock = currentStock - $(this).val(); 9755 }); 9756 $(".ligneTarif[data-codestock='" + codestock + "']").find('.td_qte select').each(function () { 9757 if (this === select) { 9758 // équivalent d'un continue pour le .each 9759 return true; 9760 } 9761 var currentVal = $(this).val(); 9762 $(this).find('option').remove(); 9763 var maxOptions = parseInt(currentStock) + parseInt(currentVal); 9764 for (var i = 0; i <= maxOptions; i++) { 9765 var selected = ''; 9766 if (i == currentVal) { 9767 selected = 'selected="selected"'; 9768 } 9769 $(this).append('<option value="' + i + '" ' + selected + '>' + i + '</option>'); 9770 } 9771 }); 9772 })(jQuery); 9773} 9774 9775/** 9776 * Fonction permettant de mettre à jour les numéros des étapes pour éviter d'avoir des décalages <br /> 9777 * Quand on récupère le contenu d'une étape en AJAX le numéro est toujours décalé car il est incrémenté dans l'obj Dossier lors du chargement de la page <br /> 9778 * Mais quand on récupère en AJAX on ne repasse pas toutes les étapes donc le numEtape ne correspond plus du tout 9779 * 9780 */ 9781function majNumEtapes(){ 9782 (function($){ 9783 var numEtape = 1; 9784 $('.sp_numEtape:visible').each(function(){ 9785 $(this).text(numEtape); 9786 numEtape++; 9787 }); 9788 })(jQuery); 9789} 9790 9791function initEtape1_panier(){ 9792 (function($){ 9793 idSession = getIdSessionInHtml(); 9794 // On fait une demande de prix uniquement si on a une qté pour au moins un pdt 9795 // On va éviter de faire des demandes de prix pour chq pdt, la demande sera toujours la même 9796 var demandePrix = false; 9797 $('.td_ndateQuantite > select').each(function(){ 9798 if ($(this).val()>0) { 9799 demandePrix = true; 9800 } 9801 }); 9802 9803 // On peut activer sur n'importe quelle liste de qté, par défaut je fais sur la première 9804 if (demandePrix) { 9805 $('.td_ndateQuantite').first().find('select').change(); 9806 } 9807 })(jQuery); 9808} 9809 9810function afficheEffaceRecapPrix_Prod(tabResult){ 9811 (function($){ 9812 var html_recapPrix = tabResult.recapPrix; 9813 var html_choixAssurance = tabResult.choixAssurance; 9814 $("#div_recapPrix").html(html_recapPrix).show(); 9815 $("#div_recapInfosEtPrix").show(); 9816 majAssurance(null, html_choixAssurance); 9817// if (html_choixAssurance.length>0) { 9818// $('#div_assuranceAnnul').html(html_choixAssurance); 9819// $("#div_uneEtape_assuranceAnnul").removeClass("div_uneEtapeGrisee"); 9820// $('#div_uneEtape_assuranceAnnul').show(); 9821// } 9822 majNumEtapes(); 9823 // On rappelle les fonctions permettant d'initialiser les évènement sur les éléments HTML que l'on vient d'ajouter 9824 initAssurance(); initModifEtape(); 9825 $("#div_recapInfos").html(tabResult.recapInfos); 9826 if ($("#div_uneEtape_assuranceAnnul").not(':visible')) { 9827 $('.p_recapInfosAssur').hide(); 9828 } 9829 $(".div_uneEtapeGrisee *:not(.obligatoire)").attr("disabled", false); 9830 $('.div_uneEtapeGrisee').removeClass('div_uneEtapeGrisee'); 9831 if (tabResult.nbPers) { 9832 majLstCanevasOblig(tabResult.nbPers); 9833 activeCanevasAvecTarifForfaitaire(); 9834 if ($('#div_uneEtape_canevas').length>0) { 9835 $('.divListeRubriquesDuCanevas .divUneRubriqueCanevas').show('fast'); 9836 $('#aToggleChoixCanevas').children('#spanCanevasAffiche').hide(); 9837 $('#aToggleChoixCanevas').children('#spanCanevasCache').show(); 9838 } 9839 } 9840 9841 if (tabResult.motsMagiques=='Oui') { 9842 $('#div_uneEtape_motMagique').show(); 9843 } 9844 var messageDevis = tabResult.msgInfoModeResa || ''; 9845 if (messageDevis) { 9846 $('.infosModeResa').html(messageDevis); 9847 $('.infosModeResa').show();
9848 $('#sp_lblRecapDates').parent().hide(); 9849 } 9850 })(jQuery); 9851} 9852 9853 9854function majRubriqueCanevasAvecElementNonCumulable(obj){ 9855 (function($){ 9856 if (obj.is(':checked') || (obj.val()!=0 && obj.val()!=null)) { 9857 obj.parents('.tarifElementRubriqueCanevas').addClass('selected'); 9858 obj.parents('.liste_tarifs_de_la_rubrique').find('.tarifElementRubriqueCanevas:not(.selected) *').attr("disabled", true); 9859 } else { 9860 obj.parents('.tarifElementRubriqueCanevas').removeClass('selected'); 9861 obj.parents('.liste_tarifs_de_la_rubrique').find('.tarifElementRubriqueCanevas *').attr("disabled", false); 9862 } 9863 })(jQuery); 9864} 9865 9866function activeCanevasAvecTarifForfaitaire() { 9867 (function($) { 9868 if ($("#div_uneEtape_canevas").length > 0) { 9869 var nbPers = $('.divUneRubriqueCanevas').first().attr('data-nbpers'); 9870 if (nbPers > 0) { 9871 $('.inpt_choixQteCanevas_forfait').not('.obligatoire').attr('disabled', false);//HL230926 9872 } else { 9873 $('.inpt_choixQteCanevas_forfait').attr('disabled', true); 9874 9875 } 9876 } 9877 })(jQuery); 9878} 9879 9880/** 9881 * Remplissage du formulaire avec les infos récupérées avec l'API Google 9882 * 9883 * @param {type} obj 9884 * @returns {undefined} 9885 */ 9886function majFormClientResa_reseauSocial(tabInfosUser) { 9887 (function($) { 9888 9889 if(tabInfosUser.email) { 9890 $('#inpt_mailClient').val(tabInfosUser.email); 9891 $('#inpt_confirmMailClient').val(tabInfosUser.email); 9892 } 9893 if(tabInfosUser.nom) { 9894 $('#inpt_nomClient').val(tabInfosUser.nom); 9895 } 9896 if(tabInfosUser.prenom) { 9897 $('#inpt_prenomClient').val(tabInfosUser.prenom); 9898 } 9899 if(tabInfosUser.civilite) { 9900 $('#select_civiliteClient').val(tabInfosUser.civilite); 9901 } 9902 if(tabInfosUser.pays) { 9903 // TODO : gérer les personnes étrangères, faire une fonction permettant de sélectionner le bon pays en fonction de la langue 9904 } 9905 if(tabInfosUser.ville) { 9906 $('#inpt_villeClient').val(tabInfosUser.ville); 9907 } 9908 })(jQuery); 9909} 9910 9911/** 9912 * Fonction appelée après la tentative de connexion à Facebook pour se connecter au compte GDF depuis un site externe 9913 */ 9914 9915function ouvrePopInAuthentificationCompteGdf(adr){ 9916 (function($) { 9917 window.open(adr, "Authentification Compte Gîtes de France", "top=50,left=50,width=260,height=50,scrollbars=yes,resizable=yes"); 9918 /*** IE ne supporte pas le message sur des noms de domaine different, on va donc faire autrement ***/ 9919 if(getVersionIE()<12 /*|| (navigator.appName == 'Netscape')*/){ 9920 var i = j = 0; 9921 while(i<=20){ 9922 j = 5000 + j; 9923 setTimeout(function(){ 9924 $.ajax({ 9925 type: 'POST', 9926 url: urlAJAX, 9927 data: 'type=clientConnecteCompteGdf', 9928 success: function (result) { 9929 var tabResult = XMLToArray(result); 9930 if(tabResult.code === 'OK') { 9931 var urlHref = location.search + "&" + getIdSessionInHtml(); 9932 location.href = urlHref; 9933 } 9934 } 9935 }); 9936 }, j); 9937 i++; 9938 } 9939 } 9940 else { 9941 window.addEventListener('message', function(message) { 9942 // en fonction du message si on a bien connecte le client on reload sinon mettre le message d erreur 9943 if(message.data=='reload'){ 9944 var urlHref = location.search + "&" + getIdSessionInHtml(); 9945 location.href = urlHref; 9946 } 9947 else { 9948 $('#itea_cnxCptGDFResa_msgInfo').html(message.data); 9949 $('#itea_cnxCptGDFResa_msgInfo').fadeOut().fadeIn(); 9950 } 9951 }, false); 9952 } 9953 })(jQuery); 9954} 9955 9956function resaFacebookOK(tabInfosUser){ 9957 (function($) { 9958 // Connexion OK 9959 $('.div_connexionReseau').hide(); 9960 $('#div_msgChoixReseauxSociauxOuSaisieFormulaire').hide(); 9961 majFormClientResa_reseauSocial(tabInfosUser); 9962 })(jQuery); 9963} 9964 9965function resaFacebookKO(){ 9966 (function($) { 9967 // Connexion KO 9968 $('.div_connexionReseau').show(); 9969 $('#div_msgChoixReseauxSociauxOuSaisieFormulaire').show(); 9970 })(jQuery); 9971} 9972 9973function chargeAlternatives(){ 9974 (function($){ 9975 // On va charger toutes les alternatives du tarif afin de pouvoir faire les correspondances entre les alternatives 9976 // Par exemple dans le cas des petits déjeuners, ils sont liés à un Hotel donc si on change d'Hotel il faut également changer le petit déjeuner 9977 // Pour éviter de dormir dans un hotel et avoir le petit dej dans un autre 9978 var btnsAlternatives = $('.a_choixAlternatives'); 9979 btnsAlternatives.each(function(){ 9980 var divARemplir = $(this).parents('.div_unComposant').find('.div_unComposantAlternatives'); 9981 var idTarif = $(this).parents('.div_unTarif').find('.inpt_idTarif').val(); 9982// var idComposant = $(this).parents('.div_unComposant').find('.inpt_idComposant').val(); 9983 var idComposant = $(this).parents('.div_unComposant').attr('data-idcomposant'); 9984 var divAlternative = $(this).parents('.div_unComposant').find('.div_unComposantAlternatives'); 9985 9986 $.ajax({ 9987 type: 'POST', 9988 url: urlAJAX, 9989 data: {type: 'getHTML_choixAlternatives', idTarif: idTarif, idComposant: idComposant}, 9990 beforeSend: function(){
9991 // Par contre on affiche uniquement la div correspondant au bouton sur lequel on vient de cliquer 9992 divARemplir.html(txtAttente); 9993 }, 9994 success: function(result){ 9995 var tabResult = XMLToArray(result); 9996 if (tabResult.code==='OK') { 9997 divAlternative.html(tabResult.html); 9998// $('.div_unTarifComposants').show(); // cette ligne a été ajoutée suite à la fiche 268247, je la commente car le fonctionnement n'est plus logique avec les lignes sans alternative 282655 9999 } 10000 10001 } 10002 }); 10003 }); 10004 })(jQuery); 10005} 10006 10007function setEventsSupplements(foncPrix){ 10008 (function($){ 10009 $(".select_qteSupplement").live('change', function(){ 10010 foncPrix(); 10011 }); 10012 10013 $('.select_supplementForfaitaire').live('change', function(){ 10014 foncPrix(); 10015 }); 10016 })(jQuery); 10017} 10018 10019function majListesSupplementsHotel(){ 10020 (function($){ 10021 var nbPax = 0; 10022 var nbAdultes; var nbEnfants; 10023 var nbPaxSelected; var htmlOption; 10024 var selected = ''; 10025 10026 $('.select_nbAdultesHotel').each(function(){ 10027 nbAdultes = parseInt($(this).val()); 10028 nbPax += nbAdultes; 10029 }); 10030 10031 $('.select_nbEnfantsHotel').each(function(){ 10032 nbEnfants = parseInt($(this).val()); 10033 nbPax += nbEnfants; 10034 }); 10035 10036 $('.select_qteSupplement').each(function(){ 10037 nbPaxSelected = $(this).val(); 10038 $(this).html(''); 10039 if (nbPaxSelected > nbPax) { 10040 nbPaxSelected = nbPax; 10041 } 10042 for (var i=0; i<=nbPax; i++) { 10043 if (i == nbPaxSelected) { 10044 selected = 'selected="selected"'; 10045 } else { 10046 selected = ''; 10047 } 10048 htmlOption = '<option value="'+i+'" '+selected+'>'+i+'</option>'; 10049 $(this).append(htmlOption); 10050 } 10051 }); 10052 10053 })(jQuery); 10054} 10055 10056function majListesSupplementsLocat(idTarif, nbPax){ 10057 (function($){ 10058 var nbPaxSelected; var selected; var htmlOption; 10059 $('.tr_tarifSupplement').each(function(){ 10060 if ($(this).attr('data-idtarifprod')==idTarif) { 10061 if ($(this).find('.select_qteSupplement').length>0) { 10062 $(this).find('.select_qteSupplement').each(function(){ 10063 nbPaxSelected = $(this).val(); 10064 $(this).html(''); 10065 for (var i=0; i<=nbPax; i++) { 10066 if (i == nbPaxSelected) { 10067 selected = 'selected="selected"'; 10068 } else { 10069 selected = ''; 10070 } 10071 htmlOption = '<option value="'+i+'" '+selected+'>'+i+'</option>'; 10072 $(this).append(htmlOption); 10073 } 10074 }); 10075 } 10076 } 10077 }); 10078 })(jQuery); 10079} 10080 10081function verifNbPaxCodeStock_hotel(codestock){ 10082 (function($){ 10083 // TODO : parcourir tous les tr_tarifHotel et récupérer nbAdultes et nbEnfants 10084 var stockDispoTotal = null; 10085 var nbAdultes; var nbEnfants; var nbPax; 10086 var stockDispo; var nbChambres; var nbMaxChambre; 10087 $('.tr_tarifHotel').each(function(){ 10088 if ($(this).attr('data-codestock')==codestock) { 10089 nbAdultes = $(this).find('.select_nbAdultesHotel').val(); 10090 if ($(this).find('.select_nbEnfantsHotel').length>0) { 10091 nbEnfants = $(this).find('.select_nbEnfantsHotel').val(); 10092 } else { 10093 nbEnfants = 0; 10094 } 10095 nbPax = parseInt(nbAdultes) - parseInt(nbEnfants); 10096 nbMaxChambre = parseInt($(this).attr('data-nbmaxchambre')); 10097 nbChambres = Math.ceil(nbPax/nbMaxChambre); 10098 stockDispo = $(this).attr('data-stockdispo'); 10099 10100 if (stockDispoTotal === null) { 10101 stockDispoTotal = stockDispo - nbChambres; 10102 } else { 10103 stockDispoTotal = stockDispoTotal - nbChambres; 10104 } 10105 10106 if (nbChambres>0) { 10107 $(this).addClass('selected'); 10108 } else { 10109 $(this).removeClass('selected'); 10110 } 10111 } 10112 }); 10113 10114 $('.tr_tarifHotel').each(function(){ 10115 if ($(this).attr('data-codestock')==codestock && !$(this).hasClass('selected')) { 10116 nbMaxChambre = parseInt($(this).attr('data-nbmaxchambre')); 10117 var nbPersMax = nbMaxChambre * stockDispoTotal; 10118 if (stockDispoTotal<=0) { 10119 $(this).find('input,select').attr('disabled', true); 10120 $(this).addClass('chambreGrisee'); 10121 } else { 10122 $(this).find('input,select').attr('disabled', false); 10123 $(this).removeClass('chambreGrisee'); 10124 $(this).find('select').children().each(function(){ 10125 if ($(this).val()>nbPersMax) { 10126 $(this).hide(); 10127 } else { 10128 $(this).show(); 10129 } 10130 }); 10131 } 10132 } 10133 }); 10134 })(jQuery); 10135} 10136 10137function initDescTarifQTip(){ 10138 (function($){ 10139 // le descriptif des tarifs des canevas 10140 if ($('.img_descTarifAvecQTip').length>0) { 10141 $('.viewWithQtipTohide').hide(); 10142 $('.img_descTarifAvecQTip').each(function(){ 10143 if ($(this).attr('data-text') && $("#"+$(this).attr('data-text'))){ 10144 $(this).qtip({ 10145 content: 10146 { 10147 text: $("#"+$(this).attr('data-text')).html(), 10148 title:{ 10149 text:$(this).attr('data-titre') 10150 } 10151 }, 10152 show: 'mouseover', 10153 hide: 'mouseout' 10154 }); 10155 } 10156 }); 10157 } 10158 })(jQuery); 10159} 10160 10161/** 10162 * Pour le script en 3 étapes (étapes 1 et 2 regroupées), il faut gérer les évènements des deux étapes en même temps <br /> 10163 * Il faut également gérer les boutons de validation pour faire les vérifications des deux étapes 10164 */ 10165function initEtape1_2(){ 10166 (function($){ 10167 $.ajaxSetup({ 10168 timeout: 100000 10169 }); 10170 initEtape2(); 10171 // TODO : mettre à jour les numéros des étapes 10172 majNumEtapes(); 10173 10174 // TODO : griser toutes les étapes tant que les adultes ne sont pas sélectionnés 10175 if ($('#div_uneEtape_compoFamilleGite').length>
101750 && $('#div_uneEtape_compoFamilleGite').find('.inpt_validEtape').val()!='Oui') { 10176 $('#div_uneEtape_dejaClient').addClass('div_uneEtapeGrisee'); 10177 $('#div_uneEtape_nouveauClient').addClass('div_uneEtapeGrisee'); 10178 } 10179 if ($('#div_uneEtape_compoFamilleChambre').length>0 && $('#div_uneEtape_compoFamilleChambre').find('.inpt_validEtape').val()!='Oui') { 10180 $('#div_uneEtape_dejaClient').addClass('div_uneEtapeGrisee'); 10181 $('#div_uneEtape_nouveauClient').addClass('div_uneEtapeGrisee'); 10182 } 10183 10184 // TODO : refaire l'évènement sur le bouton de validation pour gérer les 2 étapes 10185 $('#div_btnConfirmer_2etapes').click(function(){ 10186 $('#div_btnConfirmer_1 > a').click(); 10187 }); 10188 10189 })(jQuery); 10190} 10191 10192function setHeuresArriveeDepart(){ 10193 (function($){ 10194 var heureArrivee = $('#inpt_heureArrivee').val(); 10195 var heureDepart = $('#inpt_heureDepart').val(); 10196 10197 var pattern = /([0-9]{1,2}[h|H][0-9]{0,2})/; 10198 var regex = new RegExp(pattern); 10199 10200 if (regex.test(heureArrivee) && regex.test(heureDepart)) { 10201 $('#sp_msgErrHoraires').hide(); 10202 $.ajax({ 10203 type: 'POST', 10204 url: urlAJAX, 10205 data: {type: 'setHeuresArriveeDepart', heureArrivee: heureArrivee, heureDepart: heureDepart}, 10206 success: function(result){ 10207 eval('var tabRetour='+result); 10208 $('#div_recapInfos').html(tabRetour.recapInfos); 10209 } 10210 }); 10211 } else { 10212 $('#sp_msgErrHoraires').show(); 10213 } 10214 10215 })(jQuery); 10216} 10217 10218function initModifPrixResaBureau(){ 10219 (function($){ 10220 if ($('#div_btnModifPrix').length>0) { 10221 $("#div_modifPrixResaBureau" ).dialog({ 10222 autoOpen: false, 10223 //height: 420, 10224 width: 500, 10225 modal: true 10226 }); 10227 $("#div_modifPrixResaBureauDangereux" ).dialog({ 10228 autoOpen: false, 10229 //height: 420, 10230 width: 500, 10231 modal: true 10232 }); 10233 $('#div_btnModifPrix a').live('click', function(){ 10234 $.ajax({ 10235 type: 'POST', 10236 url: urlAJAX, 10237 data: {type: 'getHTML_popinModifPrixResaBureau'}, 10238 success: function(result){ 10239 var tabRetour = XMLToArray(result); 10240 $('#div_modifPrixResaBureau').html(tabRetour.html); 10241 $('#div_modifPrixResaBureau').dialog('open'); 10242 initDatepickerDateLimite(); 10243 initCalculsModifPrixResaBureau(); 10244 calculsModifPrixResaBureau(); 10245 } 10246 }); 10247 }); 10248 initDialogModifPrixResaBureau(); 10249 initDialogModifPrixResaBureauDangereux(); 10250 } 10251 })(jQuery); 10252} 10253 10254function initDialogModifPrixResaBureau(){ 10255 (function($){ 10256 $('#div_modifPrixResaBureau').dialog( 10257 "option", 10258 "buttons", 10259 { 10260 "Annuler": function() { 10261 $(this).dialog("close"); 10262 }, 10263 "Valider": function() { 10264 // Vérifier les prix saisis et afficher un pop-in si incohérences 10265 verifFraisDossier(); 10266 if (prixResaBureauDangereux()) { 10267 // TODO : afficher pop-in et bloquer la suite 10268 $('#div_modifPrixResaBureauDangereux').dialog('open'); 10269 return false; 10270 } 10271 enregistreNouveauxPrix(); 10272 } 10273 } 10274 ); 10275 })(jQuery); 10276} 10277 10278function prixResaBureauDangereux(){ 10279 var prixDangereux = false; 10280 (function($){ 10281 var html = '<div class="alert alert-danger">'; 10282 // TODO : personnaliser le message d'erreur en fonction du prix dangereux 10283 if (parseFloat($('.inpt_modifPrixResaBureau[name="prixLocation"]').val())===0) { 10284 html += 'Le prix de location est défini à 0.<br />'; 10285 prixDangereux = true; 10286 } 10287 if ($('.inpt_modifPrixResaBureau[name="tauxAcompte"]').length > 0 && parseFloat($('.inpt_modifPrixResaBureau[name="tauxAcompte"]').val())===0) { 10288 html += 'Le taux de l\'acompte est défini à 0.<br />'; 10289 prixDangereux = true; 10290 } 10291 if (parseFloat($('.inpt_modifPrixResaBureau[name="tauxCommission"]').val())===0) { 10292 html += 'Le taux de commission est défini à 0.<br />'; 10293 prixDangereux = true; 10294 } 10295 if($('.inpt_modifPrixResaBureau[name="fraisDossier"]').hasClass('erreur')){ 10296 html += 'Les frais de dossier sont supérieurs au prix de la location et ont été défini à 0'; 10297 prixDangereux = true; 10298 } 10299 html += '</div>'; 10300 $('#div_modifPrixResaBureauDangereux').html(html); 10301 })(jQuery); 10302 return prixDangereux; 10303} 10304 10305function enregistreNouveauxPrix(){ 10306 (function($){ 10307 10308 // fiche 315165 10309 if($('.inpt_modifPrixResaBureau[name="fraisDossier"]').val() == ''){ 10310 $('.inpt_modifPrixResaBureau[name="fraisDossier"]').val(0); 10311 } 10312 10313 var tabPrix = new Array(); 10314 var i = 0; 10315 $('.inpt_modifPrixResaBureau').each(function(){ 10316 var nom = $(this).attr('name'); 10317 var valeur = $(this).val(); 10318 tabPrix[i] = new Array(nom, valeur); 10319 i++; 10320 }); 10321 $.ajax({ 10322 type: 'POST', 10323 url: urlAJAX, 10324 data: {type: 'enregistreNouveauxPrix', tabPrix: tabPrix}, 10325 success: function(result){ 10326 var tabResult = XMLToArray(result); 10327 if(tabResult.code === 'KO') { 10328 if(tabResult.msg.length > 0) { 10329 $('#div_msgErreurModifPrix p.p_msgErrResaProp').html(tabResult.msg); 10330 $('#div_msgErreurModifPrix').show(); 10331 return false;
10332 } 10333 $('#div_modifPrixResaBureau').dialog("close"); 10334 } 10335 afficheEffaceRecapPrix(tabResult); 10336 $('#div_modifPrixResaBureau').dialog("close"); 10337 } 10338 }); 10339 })(jQuery); 10340} 10341 10342function initDialogModifPrixResaBureauDangereux(){ 10343 (function($){ 10344 $('#div_modifPrixResaBureauDangereux').dialog( 10345 "option", "buttons", { 10346 "Annuler": function() { 10347 $(this).dialog("close"); 10348 }, 10349 "Valider": function() { 10350 enregistreNouveauxPrix(); 10351 $(this).dialog('close'); 10352 } 10353 } 10354 ); 10355 })(jQuery); 10356} 10357 10358function initDatepickerDateLimite(){ 10359 (function($){ 10360 $.datepicker.setDefaults($.datepicker.regional[initLangueForDatePicker()]); 10361 $('.inpt_modifPrixResaBureau[name="dateLimite"]').datepicker({ 10362 minDate: 0 10363 }); 10364 })(jQuery); 10365} 10366 10367function calculsModifPrixFraisDossier(){ 10368 (function ($) { 10369 var fraisDossier = recalculPrixFraisDossier(); 10370 var textFraisDossier = 'recalculé: '+fraisDossier+' '; 10371 $('#sp_prixFraisDossier').text(textFraisDossier); 10372 $('#sp_prixFraisDossier').removeAttr('hidden'); 10373 $('.inpt_modifPrixFraisDossier[name="fraisDossier"]').val(fraisDossier); 10374 10375 })(jQuery); 10376} 10377 10378function recalculPrixFraisDossier(){ 10379 var total = 0; 10380 (function($){ 10381 var prixLocation = 0; 10382 if ($('.inpt_modifPrixResaBureau[name="prixLocation"]').length>0){ 10383 prixLocation = getValeurChampModifPrix('prixLocation'); 10384 } else if ($('.inpt_modifPrixResaBureau.prixChambre').length>0) { 10385 $('.inpt_modifPrixResaBureau.prixChambre').each(function(){ 10386 prixLocation += getValeurChampModifPrix($(this).attr('name')); 10387 }); 10388 } 10389 var min = $('.inpt_minFraisDossier[name="minFraisDossier"]').val(); 10390 var max = $('.inpt_maxFraisDossier[name="maxFraisDossier"]').val(); 10391 var taux = $('.inpt_tauxFraisDossier[name="tauxFraisDossier"]').val(); 10392 var montant = $('.inpt_montantFixeFraisDossier[name="montantFixeFraisDossier"]').val(); 10393 if (montant > 0) { 10394 total = montant; 10395 } else { 10396 total = prixLocation * taux / 100; 10397 if (total < min) { 10398 total = min; 10399 } 10400 else if (max > 0 && total > max) { 10401 total = max; 10402 } 10403 } 10404 10405 })(jQuery); 10406 return Number.parseFloat(total).toFixed(2); 10407} 10408 10409function initCalculsModifPrixResaBureau(){ 10410 (function($){ 10411 $('.inpt_modifPrixResaBureau').live('keyup', function(){ 10412 calculsModifPrixResaBureau(); 10413 calculsModifPrixFraisDossier(); 10414 }); 10415 })(jQuery); 10416} 10417 10418function calculsModifPrixResaBureau(){ 10419 (function ($) { 10420 var total = recalculPrixTotalResaBureau(); 10421 $('#sp_prixTotalModif').text(total); 10422 $('.inpt_modifPrixResaBureau[name="total"]').val(total); 10423 10424 //gestion du "ou exclusif" montant promo et taux remise si gite! 10425 // 295422 : Activation de ces deux champs pour la résa chambre également 10426 // Pas pris en compte pour le moment donc je laisse comme ça 10427 if ($('.inpt_modifPrixResaBureau[name="prixLocation"]').length>0){ 10428 if (getValeurChampModifPrix('promotion')>0){ 10429 $('.inpt_modifPrixResaBureau[name="tauxRemise"]').attr('disabled', 'disabled'); 10430 }else{ 10431 $('.inpt_modifPrixResaBureau[name="tauxRemise"]').removeAttr('disabled'); 10432 } 10433 if (getValeurChampModifPrix('tauxRemise')>0){ 10434 $('.inpt_modifPrixResaBureau[name="promotion"]').attr('disabled', 'disabled'); 10435 }else{ 10436 $('.inpt_modifPrixResaBureau[name="promotion"]').removeAttr('disabled'); 10437 } 10438 } 10439 10440 })(jQuery); 10441} 10442 10443function recalculPrixTotalResaBureau(){ 10444 var total = 0; 10445 (function($){ 10446 var prixLocation = 0; 10447 if ($('.inpt_modifPrixResaBureau[name="prixLocation"]').length>0){ 10448 prixLocation = getValeurChampModifPrix('prixLocation'); 10449 } else if ($('.inpt_modifPrixResaBureau.prixChambre').length>0) { 10450 $('.inpt_modifPrixResaBureau.prixChambre').each(function(){ 10451 prixLocation += getValeurChampModifPrix($(this).attr('name')); 10452 }); 10453 } 10454 10455 var assurAnnul = getValeurChampModifPrix('assurAnnul'); 10456 var fraisDossier = getValeurChampModifPrix('fraisDossier'); 10457 var charges = getValeurChampModifPrix('charges'); 10458 var promotion = getValeurChampModifPrix('promotion'); 10459 var remise = getValeurChampModifPrix('tauxRemise') * prixLocation / 100; 10460 var totalOption = 0; 10461 $('.inpt_modifPrixResaBureau[name^=prixOption]').each(function(){ 10462 totalOption += getValeurChampModifPrix($(this).attr('name')); 10463 }); 10464 var taxeSejour = getValeurChampModifPrix('taxeSejour'); 10465 // TODO : gérer le lien entre les champs promotion et tauxRemise, les deux ne peuvent être renseignés en même temps 10466 10467 total = prixLocation + assurAnnul + fraisDossier + charges + totalOption + taxeSejour - promotion - remise; 10468 total = Math.round(total * 100) / 100; 10469 })(jQuery); 10470 10471 return total; 10472} 10473 10474function recalculPrixAcompteResaBureau(){ 10475 var acompte; 10476 var total = getValeurChampModifPrix('total'); 10477 var tauxAcompte = getValeurChampModifPrix('tauxAcompte'); 10478 10479 // Dans Gestloc, l'acompte est arrondi à l'entier inférieur 10480 acompte = total * tauxAcompte / 100; 10481 acompte = Math.floor(acompte); 10482 10483 return acompte; 10484} 10485 10486function getValeurChampModifPrix(nomChamp){ 10487 var valeur = 0; 10488 (function($){ 10489 if ($('.inpt_modifPrixResaBureau[name="'+nomChamp+'"]').length > 0 && $('.inpt_modifPrixResaBureau[name="'+nomChamp+'"]').val()!='' && ($('.inpt_modifPrixResaBureau[name="'+nomChamp+'"]').is(':visible') || nomChamp=='total')) { 10490 var valeurAvantParse = $('.inpt_modifPrixResaBureau[name="'+nomChamp+'"]').val(); 10491 var regexFloat = new RegExp(/^[0-9]*[\.|,]?[0-9]{0,2}$/); 10492 10493 if (regexFloat.test(valeurAvantParse)) { 10494 $('.inpt_modifPrixResaBureau[name="'+nomChamp+'"]').removeClass('erreur'); 10495 // On remplace les virgules par des points car la fonction parseFloat ne traite pas les virgules 10496 valeur = parseFloat(valeurAvantParse.replace(',', '.')); 10497 var tabNomChamp = nomChamp.split('_'); 10498 if (tabNomChamp[0]=='prixOption'){ 10499 valeur = valeur* parseFloat($('#coeffOption_'+tabNomChamp[1]).val()); 10500 } 10501 // Pour les champs de pourcentage on vérifie quand même que la valeur entre 0 et 100 10502 if ($('.inpt_modifPrixResaBureau[name="'+nomChamp+'"]').hasClass('pourcentage')) { 10503 if (valeur<0 || valeur>100) { 10504 $('.inpt_modifPrixResaBureau[name="'+nomChamp+'"]').addClass('erreur'); 10505 valeur = 0; 10506 } 10507 } 10508 } else { 10509 $('.inpt_modifPrixResaBureau[name="'+nomChamp+'"]').addClass('erreur'); 10510 valeur = 0; 10511 } 10512 } 10513 })(jQuery); 10514 10515 return valeur; 10516} 10517 10518function initAutocompleteClientsExistants(avecDpt){ 10519 (function($){ 10520 var date; 10521 var timeKeyUp; 10522 var xhr; 10523 $('#inpt_rechercheNumeroClient, #inpt_nomClient, #inpt_prenomClient, #inpt_mailClient, #inpt_cpClient, #inpt_telDomClient').keyup(function(){ 10524 if ($('#inpt_prenomClient').val()!='') { 10525 if ($('#inpt_rechercheNumeroClient').val()=='' && $('#inpt_nomClient').val()=='' && $('#inpt_mailClient').val()=='' && $('#inpt_cpClient').val()=='' && $('#inpt_telDomClient').val()=='') { 10526 return false;
10527 } 10528 } 10529 date = new Date(); 10530 timeKeyUp = date.getTime(); 10531 setTimeout(function(){ 10532 date = new Date(); 10533 var time = date.getTime(); 10534 var delai = time - timeKeyUp; 10535 if (delai>=800) { 10536 xhr=lanceAutocompleteClients(avecDpt); 10537 } 10538 }, 800); 10539 }); 10540 $('#inpt_rechercheNumeroClient, #inpt_nomClient, #inpt_prenomClient, #inpt_mailClient, #inpt_cpClient, #inpt_telDomClient').keypress(function(){ 10541 if(xhr !== undefined){ 10542 //console.log('foncResa.js initAutocompleteClientsExistants'); 10543 //console.log(xhr); 10544 xhr.abort(); 10545 } 10546 }); 10547 // 1982169 10548 $('#inpt_mailClient').on('change', function() { 10549 $('#inpt_numeroClient').val(''); 10550 }); 10551 })(jQuery); 10552} 10553 10554function lanceAutocompleteClients(avecDpt, pourMiniCatalogue){ 10555 return (function($){ 10556 if(pourMiniCatalogue){ 10557 var numero = ''; 10558 var nom = $('.div_champMiniCatalogue .nom').val(); 10559 var prenom = $('.div_champMiniCatalogue .prenom').val(); 10560 var mail = $('#div_envoiAmiContent #email1').val(); 10561 var cp = $('.div_champMiniCatalogue .cp').val(); 10562 var tel = $('.div_champMiniCatalogue .teldom').val(); 10563 var url = './ajax/appelsAjax.php'; 10564 var instance = $('#div_envoiAmisEmailsAmis').data('instance'); 10565 }else{ 10566 var numero = $('#inpt_rechercheNumeroClient').val() ?? ''; 10567 var nom = $('#inpt_nomClient').val(); 10568 var prenom = $('#inpt_prenomClient').val(); 10569 var mail = $('#inpt_mailClient').val(); 10570 var cp = $('#inpt_cpClient').val(); 10571 var tel = $('#inpt_telDomClient').val(); 10572 var url = urlAJAX; 10573 var instance = $('#inpt_instanceFormClient').val(); 10574 } 10575 var data = { numero, nom, prenom, mail, cp, tel, avecDpt, instance }; 10576 if(pourMiniCatalogue){ 10577 data['action'] = 'getHTML_listeClientsForAutocomplete'; 10578 }else{ 10579 data['type'] = 'getHTML_listeClientsForAutocomplete'; 10580 } 10581 var xhr; 10582 if (numero.length>=1 || nom.length>=3 || prenom.length>=4 || mail.length>=4 || cp.length>=2 || tel.length>=6) { 10583 xhr = $.ajax({ 10584 type: 'POST', 10585 url: url, 10586 data: data, 10587 beforeSend: function(){ 10588 $('#div_autocompleteClients').show(); 10589 if(pourMiniCatalogue){ 10590 $('#div_sendMailToFriend #div_saisieInfosClientPourMiniCata .div_saisieInfosClient').css('width','40%'); 10591 } 10592 $('#div_autocompleteClientsResults').html('<img src="/config_v3/imgs_defaut/loading/loader.gif" />'); 10593 }, 10594 success: function(result){ 10595 $('#div_autocompleteClientsResults').html(result); 10596 $('#div_autocompleteClients').show(); 10597 initChargeClientExistant(); 10598 }, 10599 }); 10600 } else { 10601 if(pourMiniCatalogue){ 10602 $('#div_autocompleteClients').hide(); 10603 $('#div_sendMailToFriend #div_saisieInfosClientPourMiniCata .div_saisieInfosClient').css('width','50%'); 10604 } 10605 $('#div_autocompleteClientsResults').html(''); 10606 } 10607 return xhr; 10608 })(jQuery); 10609} 10610 10611function initChargeClientExistant(){ 10612 (function($){ 10613 $('.li_autocompleteurClient').click(function(){ 10614 // TODO : vérifier que tous les champs ont été chargés, si ce n'est pas le cas il faut faire une requête AJAX pour avoir le détail 10615 // Dans tous les cas on a ces 4 champs 10616 var nom = $(this).find('.inpt_autocompleteClient.nomClient').val(); 10617 var prenom = $(this).find('.inpt_autocompleteClient.prenomClient').val(); 10618 var mail = $(this).find('.inpt_autocompleteClient.mailClient').val(); 10619 var instance = $(this).find('.inpt_autocompleteClient.instance').val(); 10620 let categorie = $(this).find('.inpt_autocompleteClient.categorie').val(); 10621 let codeOrigine = $(this).find('.inpt_autocompleteClient.codeOrigine').val(); 10622 var civilite; var CP = ''; var ville = ''; var adresse1 = ''; var adresse2 = ''; 10623 var telDom = ''; var telBur = ''; var mdp = ''; var pays = ''; 10624 var numeroClient = ''; var identClientNat = '';var mdpNationalExistant; 10625 var commentaireClient = ''; 10626 if ($(this).find('.inpt_autocompleteClient.villeClient').length===0 && instance.length>0 && $('#div_saisieInfosClientPourMiniCata').length===0) { 10627 // TODO : appel AJAX pour récupérer détail 10628 $.ajax({ 10629 type: 'POST', 10630 url: urlAJAX, 10631 async: false, 10632 data: {type: 'getDetailClient', nom: nom, prenom: prenom, mail: mail, instance: instance}, 10633 success: function(result){ 10634 var tabResult = XMLToArray(result); 10635 civilite = tabResult.civilite; 10636 CP = tabResult.code_postal; 10637 ville = tabResult.ville; 10638 adresse1 = tabResult.adresse; 10639 adresse2 = tabResult.lieu_dit; 10640 telDom = tabResult.tel1; 10641 telBur = tabResult.tel2; 10642 mdp = tabResult.mdp; 10643 pays = tabResult.pays || ''; 10644 numeroClient = tabResult.numeroClient; 10645 identClientNat = tabResult.identClientnat; 10646 commentaireClient = tabResult.commentaire || ''; 10647 } 10648 }); 10649 } else { 10650 civilite = $(this).find('.inpt_autocompleteClient.civilite').val(); 10651 CP = $(this).find('.inpt_autocompleteClient.CPClient').val(); 10652 ville = $(this).find('.inpt_autocompleteClient.villeClient').val(); 10653 adresse1 = $(this).find('.inpt_autocompleteClient.adresse1Client').val(); 10654 adresse2 = $(this).find('.inpt_autocompleteClient.adresse2Client').val(); 10655 telDom = $(this).find('.inpt_autocompleteClient.tel1Client').val(); 10656 telBur = $(this).find('.inpt_autocompleteClient.tel2Client').val(); 10657 mdp = $(this).find('.inpt_autocompleteClient.mdp').val(); 10658 pays = $(this).find('.inpt_autocompleteClient.pays').val() || ''; 10659 numeroClient = $(this).find('.inpt_autocompleteClient.numeroClient').val(); 10660 if ($(this).find('.inpt_autocompleteClient.identClientNat').length>0) { 10661 identClientNat = $(this).find('.inpt_autocompleteClient.identClientNat').val(); 10662 mdpNationalExistant = $(this).find('.inpt_autocompleteClient.mdpNationalExistant').val(); 10663 } 10664 commentaireClient = $(this).find('.inpt_autocompleteClient.commentaireClient').val() || ''; 10665 offresPromos = $(this).find('.inpt_autocompleteClient.inpt_offresPromos').val(); 10666 offresPromosPapier = $(this).find('.inpt_autocompleteClient.inpt_offresPromosPapier').val(); 10667 } 10668 10669 // TODO : récupérer les infos des champs cachés et remplir le formulaire 10670 $('#select_civiliteClient, .div_champMiniCatalogue .civilite').val(civilite); 10671 $('#inpt_nomClient, .div_champMiniCatalogue .nom').val(nom); 10672 $('#inpt_prenomClient, .div_champMiniCatalogue .prenom').val(prenom); 10673 $('#inpt_cpClient, .div_champMiniCatalogue .cp').val(CP); 10674 $('#inpt_villeClient, .div_champMiniCatalogue .ville').val(ville); 10675 $('#inpt_mailClient').val(mail); 10676 if (mail){ //2009242 10677 $('#inpt_mailClient').prop('readonly', true); 10678 } 10679 $('#div_envoiAmiContent #email1').val(mail); //pour le mini-catalogue 10680 $('#inpt_adresse1Client, .div_champMiniCatalogue .adresse1').val(adresse1); 10681 $('#inpt_adresse2Client, .div_champMiniCatalogue .adresse2').val(adresse2); 10682 $('#inpt_telDomClient, .div_champMiniCatalogue .teldom').val(telDom); 10683 $('#inpt_telBurClient, .div_champMiniCatalogue .telbur').val(telBur); 10684 $('#inpt_mdpClient, .div_champMiniCatalogue .mdp').val(mdp); 10685 $('#inpt_numeroClient').val(numeroClient); 10686 if (categorie) { 10687 $('option', $('#select_categorieClient')).attr('selected', false); 10688 $('option[value="' + categorie + '"]', $('#select_categorieClient')).attr('selected', true); 10689 } 10690 if (codeOrigine) { 10691 $('option', $('#select_origineClient')).attr('selected', false); 10692 $('option[value="' + codeOrigine + '"]', $('#select_origineClient')).attr('selected', true); 10693 } 10694 if (offresPromos === 'O') { 10695 $('#inpt_offresPromos').prop("checked", true); 10696 } else { 10697 $('#inpt_offresPromos').prop("checked", false); 10698 } 10699 10700 if (offresPromosPapier === 'O') { 10701 $('#inpt_offresPromosPapier').prop("checked", true); 10702 } else { 10703 $('#inpt_offresPromosPapier').prop("checked", false); 10704 } 10705 10706 if(estResaBureauGestloc()){ 10707 $('#inpt_commentaireClientPourCentrale').text(commentaireClient); 10708 } 10709 10710 $('#inpt_identClientNat').val(identClientNat); 10711 if (identClientNat && identClientNat.length>0) { 10712 $('.ipt_clientExistant').attr('disabled', true); 10713 $('#div_saisieClientEmail .i_helperInfoBulle').show(); 10714 var htmlAlerte = "<div class='row'><strong><i class='fa fa-exclamation-triangle' aria-hidden='true'></i></strong>" + 10715 " Ce client possède un compte client National"; 10716 if(estSurBureauITEA()){ 10717 htmlAlerte += "<input class='btn btn-primary pull-right' type='button' value='Modifier les coordonnées' onclick='actionBtnDelierCptNat(this);'>"; 10718 } 10719 htmlAlerte += "</div>"; 10720 $('#alerte_inputsClientDisabled').html(htmlAlerte); 10721 $('#alerte_inputsClientDisabled').show(); 10722 } else { 10723 $('.ipt_clientExistant').attr('disabled', false); 10724 $('#div_saisieClientEmail .i_helperInfoBulle').hide(); 10725 $('#alerte_inputsClientDisabled').hide(); 10726 } 10727 10728 $('#inpt_mdpNationalExistant').val(mdpNationalExistant); 10729 if(pays){ 10730 $('option',$('#select_pays')).attr('selected',false); 10731 $('option[data-code="'+pays+'"]',$('#select_pays')).attr('selected',true); 10732 $('.div_champMiniCatalogue .pays').val(pays); // Vincent 312116 10733 } 10734// $('#inpt_confirmMailClient').val($('#inptProp_email').val()); 10735// $('#div_autocompleteClients').hide(); 10736 //On valide les champs 10737 validFormulaire(); 10738 checkChampsImportants(); 10739 }); 10740 })(jQuery); 10741} 10742 10743function resetFormNouveauClient() { 10744 (function($){ 10745 $('#inpt_mailClient').prop('readonly', false); 10746 $('#select_histoClients').val('defaut'); 10747 $('#form_nouveauClient').trigger('reset'); 10748 })(jQuery); 10749} 10750 10751function lockModifClientNat(){ 10752 (function($){ 10753 $('.ipt_clientExistant').attr('disabled', true); 10754 $('#div_saisieClientEmail .i_helperInfoBulle').show(); 10755 var htmlAlerte = "<div class='row'>" + 10756 "<strong><i class='fa fa-exclamation-triangle' aria-hidden='true'></i></strong>" + 10757 " Ce client est rattaché à un compte client National, il n'est pas possible de le modifier." + 10758 " </div>"; 10759 $('#alerte_inputsClientDisabled').html(htmlAlerte); 10760 $('#alerte_inputsClientDisabled').show(); 10761 })(jQuery); 10762} 10763 10764function actionBtnDelierCptNat(element){ 10765 (function($){ 10766 10767 var htmlPopIn = '<div id="popInModifCompteClientNat">'; 10768 htmlPopIn += "<i class='fa fa-exclamation-triangle' aria-hidden='true'></i>"; 10769 htmlPopIn += 'Attention les modifications impacteront les coordonnées sur le compte national du client !'; 10770 htmlPopIn += '</div>'; 10771 10772 $('#alerte_inputsClientDisabled').after(htmlPopIn); 10773 var popin = $('#popInModifCompteClientNat').dialog({ 10774 modal : true, 10775 autoOpen: true, 10776 width: 550, 10777 dialogClass : 'popinLienCgi', 10778 position: { my: "center top", at: "center top", of: 'body' }, 10779 open: function(event, ui) { 10780 $(".ui-dialog-titlebar-close", ui.dialog | ui).hide(); 10781 }, 10782 buttons: [{ 10783 text: "Annuler", 10784 "class": 'ui-state-information', 10785 click: function () { 10786 $(this).dialog("close"); 10787 $('#popInModifCompteClientNat').remove(); 10788 } 10789 }, 10790 { 10791 text: "Valider", 10792 "class": 'ui-state-information', 10793 click: function () { 10794 $('.ipt_clientExistant').attr('disabled', false); 10795 $(this).dialog("close"); 10796 $('#popInModifCompteClientNat').remove(); 10797 $('#inpt_mailClient').attr('disabled', true); 10798 $('#alerte_inputsClientDisabled').hide(); 10799 } 10800 } 10801 ] 10802 }); 10803 })(jQuery); 10804} 10805 10806function estResaAvecCompteGdf(){ 10807 if(jQuery('#inputCompteGdf').length>0){ 10808 return true; 10809 } 10810 return false;
10811} 10812 10813function estResaBureauProp(){ 10814 if(jQuery('#inputTypeClientResaProp').length>0){ 10815 return true; 10816 } 10817 return false; 10818} 10819 10820// Deplacée dans lib_2-dev/js/fonc/divers.js 10821// 10822//function estSurResa() { 10823// var url = window.location.pathname; 10824// if (url !== undefined && url.match(/etape\d\.php/)) { 10825// return true; 10826// } 10827// return false; 10828//} 10829 10830function estResaAilleurs(){ 10831 if(jQuery('#modeResaAilleurs').length>0){ 10832 return true; 10833 } 10834 return false; 10835} 10836 10837function estResaBureauGestloc(){ 10838 if(jQuery('#inputTypeClientVendeurBureau').length>0){ 10839 return true; 10840 } 10841 return false; 10842} 10843 10844function estResaGP(){ 10845 if(jQuery('#inputTypeClientGP').length>0){ 10846 return true; 10847 } 10848 return false; 10849} 10850 10851function ajouteOuRemplaceDansDataLayer(objGA){ 10852 if (typeof(dataLayer)=='undefined' || typeof(objGA)=='undefined' || typeof(objGA.event)=='undefined'){ 10853 return false; 10854 } 10855 //on vérifie que l'event de l'objet n'est pas déjà dans le dataLayer, sinon on le supprime 10856 var eventName = objGA.event; 10857 jQuery.each(dataLayer, function(id,elemDataLayer){ 10858 if (typeof(elemDataLayer)!='undefined' && typeof(elemDataLayer.event)!='undefined' && elemDataLayer.event == eventName){ 10859 dataLayer.splice(id,1); 10860 } 10861 }) 10862 dataLayer.push(objGA); 10863 return true; 10864} 10865 10866function enregistrePrixLocationProp(prixLocationProp){ 10867 (function($){ 10868 $.ajax({ 10869 type: 'POST', 10870 url: urlAJAX, 10871 async: true, 10872 data: {type: 'enregistrePrixLocationProp', prixLocation: prixLocationProp}, 10873 success: function(result){ 10874 var tabRetour = XMLToArray(result); 10875 10876 afficheEffaceRecapPrix(tabRetour); 10877 } 10878 }); 10879 })(jQuery); 10880} 10881 10882/** 10883 * Lors d'un changement de dates dans la résa gestprod, il faut s'assurer que l'on recalcule bien le prix avec les bonnes lignes factures à jour 10884 * @returns {undefined} 10885 */ 10886function reinitSelectionLignesFactures() { 10887 (function ($) { 10888 var nbAdultesTot = 0; 10889 if ($('.selectQuantitePourReinit:visible').length > 0) { 10890 $('.selectQuantitePourReinit:visible').each(function () { 10891 if ($(this).val() > 0) { 10892 nbAdultesTot += $(this).val(); 10893 } 10894 }); 10895 } 10896 if($('.inputTarifVoiture:checked').length>0){ 10897 nbAdultesTot = 1; 10898 } 10899 var id = $('.div_uneEtape_prodGP').attr('id'); 10900 if (nbAdultesTot === 0) {
10901 $('#' + id).find('.inpt_validEtape').val('Non'); 10902 $('#div_recapPrix').hide(); 10903 $('#div_recapInfosFamille').remove(); 10904 } 10905 else { 10906 switch (id) { 10907 case 'div_uneEtape_hotelChoixChambre': 10908 setLignesFactures_hotel(); 10909 break; 10910 case 'div_uneEtape_choixNDate': 10911 setLignesFactures_ndate(); 10912 break; 10913 case 'div_uneEtape_packageChoixTarif': 10914 setLignesFactures_package(); 10915 break; 10916 case 'div_uneEtape_voitureChoixPresta': 10917 if($('.inputTarifVoiture:checked').length>0){ 10918 setLignesFactures_voitureNew(); 10919 } 10920 else{ 10921 setLignesFactures_voiture(); 10922 } 10923 break; 10924 case 'div_uneEtape_locatChoixChambre': 10925 setLignesFactures_locat(); 10926 break; 10927 case 'div_uneEtape_billetChoixPresta': 10928 setLignesFactures_billet(); 10929 break; 10930 } 10931 10932 } 10933 })(jQuery); 10934} 10935 10936function verifErreurAjaxEtape1(){ 10937 var verif = true; 10938 (function ($) { 10939 if($('.spanErreurAjax','.div_uneEtape_prodGP').length>0){ 10940 if($("#p_msgErreurs").text().length >0){ 10941 $("#p_msgErreurs").append("<br />"); 10942 } 10943 var text = $('.spanErreurAjax','.div_uneEtape_prodGP').text(); 10944 $("#p_msgErreurs").append(text); 10945 $("#div_msgErreurs").show(); 10946 verif = false; 10947 } 10948 })(jQuery); 10949 return verif; 10950} 10951 10952function actualiseRecapPrix(dateDeb, dateFin){ 10953 (function($){ 10954 idSession = getIdSessionInHtml(); 10955 10956 // On fait la même vérif que lors de la saisie des dates, cela permet d'avoir directement les modifications dans le dossier 10957 var tabData = {type: "verifDates", dateDeb: dateDeb, dateFin: dateFin}; 10958 $.ajax({ 10959 type: 'POST', 10960 url: urlAJAX, 10961 data: tabData, 10962 success: function(result){ 10963 var tabRetour = XMLToArray(result); 10964 if(tabRetour.modeResa != undefined){ 10965 manageChangementTypeResa(tabRetour); 10966 return; 10967 } else { 10968 if (tabRetour.code=='OK') { 10969 afficheEffaceRecapPrix(tabRetour); 10970 } 10971 } 10972 } 10973 }); 10974 10975 })(jQuery); 10976} 10977 10978function ouvrePopinSaisieOccupants() { 10979 (function ($) { 10980 10981 if ($('#div_saisieOccupantsResaBureau').length==0) { 10982 setPopinSaisieOccupants(); 10983 } 10984 10985 if (!$('#div_saisieOccupantsResaBureau').is('.initialisee')) { 10986 initialisePopinSaisieOccupants(); 10987 $('#div_saisieOccupantsResaBureau').addClass('initialisee'); 10988 } 10989 10990 $('#div_saisieOccupantsResaBureau').dialog('open'); 10991 if (estResaBureauGestloc()) { 10992 $('#div_saisieOccupantsResaBureau').trigger('setClient'); 10993 } 10994 })(jQuery); 10995} 10996 10997function setPopinSaisieOccupants() { 10998 (function ($) { 10999 $.ajax({ 11000 type: 'POST', 11001 url: urlAJAX, 11002 data: {type: 'getHtmlPopinSaisieOccupants'}, 11003 dataType: 'html', 11004 async: false, 11005 success: function(result) { 11006 $('body').append(result); 11007 } 11008 }); 11009 })(jQuery); 11010} 11011 11012function initialisePopinSaisieOccupants() { 11013 (function ($) { 11014 $('.btn_ajoutOccupant').click(function(){ 11015 var ligneDefaut = $('#div_saisieOccupantsResaBureau_content').find('tr.ligneDefaut').clone(); 11016 ligneDefaut.removeClass('ligneDefaut'); 11017 $('#div_saisieOccupantsResaBureau_content tbody').append(ligneDefaut); 11018 }); 11019 11020 // permet d'initialiser la première ligne des occupants avec les infos du client 11021 // on ne le fait qu'une fois 11022 $('#div_saisieOccupantsResaBureau').one('setClient', function(){ 11023 11024 // info du client 11025 var nom = $('#inpt_nomClient').val(); 11026 var prenom = $('#inpt_prenomClient').val(); 11027 var civilite = $('#select_civiliteClient').val(); 11028 var pays = $('#select_pays').val(); 11029 11030 // la première ligne de saisie des occupants 11031 var $ligne = $(this).find('table tr').not('.ligneDefaut').not('.tr_ligneTitre').first(); 11032 // si on a déjà des occupants, on remplie pas automatiquement 11033 if($ligne.find('.inpt_nomOccupant').val() || $ligne.find('.inpt_prenomOccupant').val()){ 11034 return false;
11035 } 11036 // on valorise les champs 11037 $ligne.find('.inpt_nomOccupant').val(nom); 11038 $ligne.find('.inpt_prenomOccupant').val(prenom); 11039 $ligne.find('.select_civiliteOccupant').val(civilite); 11040 $ligne.find('.select_paysOccupant').val(pays); 11041 }); 11042 11043 var titrePopin = $('#inpt_titrePopinSaisieOccupants').val(); 11044 $('#div_saisieOccupantsResaBureau').dialog({ 11045 autoOpen: false, 11046 modal:true, 11047 title: titrePopin, 11048 buttons:{ 11049 "Ok":function(){ 11050 enregistreSaisieOccupants() 11051 }, 11052 "Annuler": function() { 11053 $(this).dialog("close"); 11054 } 11055 }, 11056 close: function() { 11057 if (typeof fermePopinSaisieOccupants === 'function') { 11058 fermePopinSaisieOccupants(); 11059 } 11060 }, 11061 minWidth: 1150 11062 }); 11063 })(jQuery); 11064} 11065 11066function enregistreSaisieOccupants() { 11067 (function ($) { 11068 var tabOccupants = new Array(); 11069 var i = 0; 11070 $('#div_saisieOccupantsResaBureau_content tr').not('.ligneDefaut , .tr_ligneTitre').each(function(){ 11071 var nom = $(this).find('.inpt_nomOccupant').val(); 11072 if (nom=='') { 11073 return; 11074 } 11075 var civilite = $(this).find('.select_civiliteOccupant').val(); 11076 var prenom = $(this).find('.inpt_prenomOccupant').val(); 11077 var naissance = $(this).find('.inpt_naissanceOccupant').val(); 11078 var pays = $(this).find('.select_paysOccupant').val(); 11079 var exoneration = $(this).find('.select_exonerationOccupant').val(); 11080 tabOccupants[i] = new Array(civilite, nom, prenom, naissance, pays, exoneration); 11081 i++; 11082 }); 11083 11084 $.ajax({ 11085 type: 'POST', 11086 url: urlAJAX, 11087 data: {type: 'enregistreOccupants', tabOccupants: tabOccupants}, 11088 success: function(result){ 11089 eval('var tabResult='+result); 11090 if (tabResult.code=='OK') { 11091 if (typeof confirmationSaisieOccupants === 'function') { 11092 confirmationSaisieOccupants(); 11093 } 11094 $('#div_saisieOccupantsResaBureau').dialog('close'); 11095 } else { 11096 $('#div_saisieOccupantsResaBureau_content .div_msgErreur').show(); 11097 } 11098 } 11099 }); 11100 })(jQuery); 11101} 11102 11103 11104function actualiseMontantRestant(){ 11105 (function($){ 11106 var prixLocation = 0; 11107 var montantPercu = 0; 11108 11109 if ($('.inpt_modifPrixLocationResaProp:visible').length>0) { 11110 prixLocation = parseFloat($('.inpt_modifPrixLocationResaProp:visible').val()); 11111 } else if ($('.inpt_modifPrixChambreResaProp:visible').length>0 || $('.inpt_modifPrixChambreCentraleProp:visible').length>0) { 11112 var inputs = $('.inpt_modifPrixChambreResaProp:visible, .inpt_modifPrixChambreCentraleProp:visible'); 11113 $(inputs).each(function(){ 11114 var prixChambre = $(this).val(); 11115 prixLocation += parseFloat(prixChambre); 11116 }); 11117 } 11118 11119 if ($('#inpt_modifMontantPercu:visible').length>0) { 11120 montantPercu = parseFloat($('#inpt_modifMontantPercu').val()); 11121 } 11122 11123 // 337730 Il faut prendre en compte le montant total et non le prixLocation 11124 var prixTotal = parseFloat($('#td_prixTotal').data('montant')); 11125 var prixLocationCalcule = parseFloat($('#td_prixLocation').data('montant')); 11126 11127 var nouveauMontantRestant; 11128 if (prixLocation>0) { 11129 nouveauMontantRestant = prixTotal - prixLocationCalcule + prixLocation - montantPercu; 11130 nouveauMontantRestant = Math.round(nouveauMontantRestant*100)/100; 11131 } 11132 11133 $('.sp_montantRestant.valeur').text(nouveauMontantRestant); 11134 11135 11136 // TODO : mettre à jour le montant à payer dans le formulaire CentralPay 11137 })(jQuery); 11138} 11139 11140// suite fiche 249927 : il faut vérifier dans tous les cas si on a sélectionnné un adulte. 11141function verifCompoFamilleGiteAdultes(){ 11142 (function($){ 11143 if($('#select_compoFamilleAdulte').length == 0){ 11144 return; 11145 } 11146 // on est pas censé pouvoir faire une 11147// if ($("#select_compoFamilleEnfant").val() != 0 && (estResaBureauProp() || estResaBureauGestloc())){ 11148// // pour le bureau prop et itea, on laisse la possibilité de faire une résa avec seulement des enfants. 11149// return; 11150// } 11151 if($('#select_compoFamilleAdulte').val() == 0){
11152 $("input.inpt_validEtape","#div_uneEtape_compoFamilleGite").val("Non"); 11153 } 11154 })(jQuery); 11155} 11156 11157function corrigeSaisieDateNaissance(inputDate, enfantOuBebe){ 11158 (function($){ 11159 if ($(inputDate).val()==='') { 11160 return; 11161 } 11162 var qTipText = 'Date reformatée'; 11163 var qTipTextDateMin = "Date modifiée pour respecter le paramétrage de l'âge maximum"; 11164 var qTipTextDateMax = "Date modifiée pour respecter le paramétrage de l'âge minimum"; 11165 var patterns = [/^[0-9]{6,8}$/, /^[0-9]{2}\/[0-9]{2}\/[0-9]{2,4}$/, /^[0-9]{2}-[0-9]{2}-[0-9]{2,4}$/, /^[0-9]{2}\.[0-9]{2}\.[0-9]{2,4}$/]; 11166 var objDate = null; 11167 patterns.forEach(function(pattern){ 11168 if ($(inputDate).val().match(pattern)) { 11169 objDate = new OBJDate($(inputDate).val()); 11170 } 11171 }); 11172 var dateMin = getObjDateNaissanceMin(enfantOuBebe); 11173 var dateMax = getObjDateNaissanceMax(enfantOuBebe); 11174 var nouvelleValeur = null; 11175 11176 console.log('objDate : ',objDate); 11177 11178 // Test saisie annee 11179 if (objDate === null && $(inputDate).val().match(/^[0-9]{4}$/)) { 11180 // Vérifier qu'on a saisie une année correspondant au paramétrage, sinon on remplace par la première date de naissance possible 11181 var annee = $(inputDate).val(); 11182 if (annee < dateMin.getAnnee()) { 11183 qTipText = qTipTextDateMin; 11184 nouvelleValeur = dateMin.toString('dd/mm/yyyy'); 11185 } else if (annee > dateMax.getAnnee()) { 11186 qTipText = qTipTextDateMax; 11187 nouvelleValeur = dateMax.toString('dd/mm/yyyy'); 11188 } else { 11189 nouvelleValeur = '31/12/'+annee; 11190 } 11191 } else if (objDate === null) { 11192 qTipText = qTipTextDateMin; 11193 nouvelleValeur = dateMin.toString('dd/mm/yyyy'); 11194 } else if (!$(inputDate).val().match(/^[0-9]{2}\/[0-9]{2}\/[0-9]{4}$/)) { 11195 nouvelleValeur = objDate.toString('dd/mm/yyyy'); 11196 } 11197 11198 if (nouvelleValeur) { 11199 if (dateMin.estApres(nouvelleValeur)) { 11200 qTipText = qTipTextDateMin; 11201 nouvelleValeur = dateMin.toString('dd/mm/yyyy'); 11202 } else if (dateMax.estAvant(nouvelleValeur)) { 11203 qTipText = qTipTextDateMax; 11204 nouvelleValeur = dateMax.toString('dd/mm/yyyy'); 11205 } 11206 } else { 11207 if (dateMin.estApres($(inputDate).val())) { 11208 qTipText = qTipTextDateMin; 11209 nouvelleValeur = dateMin.toString('dd/mm/yyyy'); 11210 } else if (dateMax.estAvant($(inputDate).val())) { 11211 qTipText = qTipTextDateMax; 11212 nouvelleValeur = dateMax.toString('dd/mm/yyyy'); 11213 } 11214 } 11215 11216 if (nouvelleValeur===null) { 11217 return; 11218 } 11219 $(inputDate).val(nouvelleValeur); 11220 $(inputDate).qtip({ 11221 content: {text: qTipText}, 11222 position: {my: 'bottom center', at: 'top center', target: $(inputDate)}, 11223 show: {event: false, ready: true}, 11224 hide: {inactive: 5000}, 11225 style: {width: $(inputDate).width()} 11226 }); 11227 })(jQuery); 11228} 11229 11230function getObjDateNaissanceMin(enfantOuBebe){ 11231 if (enfantOuBebe==='enfant') { 11232 return getObjDateNaissanceMinEnfant(); 11233 } else if (enfantOuBebe==='bebe') { 11234 return getObjDateNaissanceMinBebe(); 11235 } 11236 return null; 11237} 11238 11239function getObjDateNaissanceMinEnfant(){ 11240 var ageMaxEnfants = parseInt(jQuery('#inpt_ageMaxEnfants').val());
11241 var dateNaissanceMinEnfants = new OBJDate(jQuery('#inpt_resaDateDeb').val()); 11242 dateNaissanceMinEnfants.retireMois(12*(ageMaxEnfants+1)); 11243 dateNaissanceMinEnfants.ajoutJour(1); 11244 11245 return dateNaissanceMinEnfants; 11246} 11247 11248function getObjDateNaissanceMinBebe(){ 11249 var ageMaxBebes = parseInt(jQuery('#inpt_ageMaxBebes').val()); 11250 var dateNaissanceMinBebes = new OBJDate(jQuery('#inpt_resaDateDeb').val()); 11251 dateNaissanceMinBebes.retireMois(12*(ageMaxBebes+1)); 11252 dateNaissanceMinBebes.ajoutJour(1); 11253 11254 return dateNaissanceMinBebes; 11255} 11256 11257function getObjDateNaissanceMax(enfantOuBebe){ 11258 if (enfantOuBebe==='enfant') { 11259 return getObjDateNaissanceMaxEnfant(); 11260 } else if (enfantOuBebe==='bebe') { 11261 return getObjDateNaissanceMaxBebe(); 11262 } 11263 return null; 11264} 11265 11266function getObjDateNaissanceMaxEnfant(){ 11267 var ageMaxBebes = parseInt(jQuery('#inpt_ageMaxBebes').val()); 11268 var dateNaissanceMaxEnfants = new OBJDate(jQuery('#inpt_resaDateDeb').val()); 11269 dateNaissanceMaxEnfants.retireMois(12*(ageMaxBebes+1)); 11270 11271 return dateNaissanceMaxEnfants; 11272} 11273 11274function getObjDateNaissanceMaxBebe(){ 11275 var dateNaissanceMaxBebes = new OBJDate(); 11276 return dateNaissanceMaxBebes; 11277} 11278 11279function estDateNaissanceValide(date, type){ 11280 var dateNaissanceMinEnfants = getObjDateNaissanceMin('enfant'); 11281 var dateNaissanceMaxEnfants = getObjDateNaissanceMax('enfant'); 11282 var dateNaissanceMinBebes = getObjDateNaissanceMin('bebe'); 11283 var dateNaissanceMaxBebes = getObjDateNaissanceMax('bebe'); 11284 11285 if (type==='enfant') { 11286 if (dateNaissanceMinEnfants.estAvant(date) && dateNaissanceMaxEnfants.estApres(date)) { 11287 return true; 11288 } 11289 return false; 11290 } else if (type==='bebe') { 11291 if (dateNaissanceMinBebes.estAvant(date) && dateNaissanceMaxBebes.estApres(date)) { 11292 return true; 11293 } 11294 return false; 11295 } else { 11296 return false; 11297 } 11298} 11299 11300function verifMontantLibreCorrect(valeur){ 11301 if(valeur.match(/^[0-9]{1,5}$/)){ 11302 return true; 11303 } 11304 return false; 11305} 11306 11307function traiteNdatePrixLibre() { 11308 (function ($) { 11309 if ($('.tarifNDatePrixLibre').length > 0) { 11310 setLignesFactures_ndate(); 11311 } 11312 })(jQuery); 11313} 11314 11315function initPrixLibre(){ 11316 (function ($) { 11317 $('.tarifNDatePrixLibre').blur(function(){ 11318 traiteNdatePrixLibre(); 11319 }); 11320 })(jQuery); 11321} 11322 11323function testYoann(){ 11324 (function ($) { 11325 $.ajax({ 11326 type: 'POST', 11327 url: urlAJAX, 11328 data: {type: 'testYoann'} 11329 }); 11330 })(jQuery); 11331} 11332 11333function verifQuestionnairesClient(){ 11334 verif = true; 11335 (function($){ 11336 if ($('#div_uneEtape_questionnaires').length==0) { 11337 return; 11338 } 11339 11340 $('.div_uneQuestion.obligatoire').removeClass('erreur'); 11341 $('.div_uneQuestion.obligatoire:visible').each(function(){ 11342 var idQuestion = $(this).attr('data-id'); 11343 var reponse = getReponseClientByTypeQuestion($('.inpt_uneQuestionClient[data-id="'+idQuestion+'"]:first')); 11344 if (reponse==='' || !reponse) { 11345 $(this).addClass('erreur'); 11346 verif = false; 11347 } 11348 }); 11349 })(jQuery); 11350 return verif; 11351} 11352 11353function getReponseClientByTypeQuestion(inptQuestion){ 11354 var reponse = ''; 11355 (function($){ 11356 var idQuestion = inptQuestion.attr('data-id'); 11357// if (inptQuestion.is('select') || inptQuestion.is('input[type="text"]') || inptQuestion.is('input[type="time"]')) { 11358// reponse = inptQuestion.val(); 11359// } 11360 if (inptQuestion.is('input[type="radio"]')) { 11361 reponse = $('.inpt_uneQuestionClient[data-id="'+idQuestion+'"]:checked').val(); 11362 } else if (inptQuestion.is('input[type="checkbox"]')) { 11363 // Attention pour les checkbox il faut réunir toutes les réponses cochées 11364 $('.inpt_uneQuestionClient[data-id="'+idQuestion+'"]:checked').each(function(){ 11365 reponse += $(this).val()+' - '; 11366 }); 11367 reponse = reponse.substr(0, reponse.length-3); 11368 } else { 11369 reponse = inptQuestion.val(); 11370 } 11371 })(jQuery); 11372 return reponse; 11373} 11374 11375function enregistreReponsesQuestionnairesClient(){ 11376 (function($){ 11377 if ($('#div_uneEtape_questionnaires').length==0) { 11378 return; 11379 } 11380 11381 // On a pas besoin d'enregistrer les id_questionnaire, uniquement les id_question 11382 var tabReponses = new Array(); 11383 $('.div_uneQuestion').each(function(){ 11384 var idQuestion = $(this).attr('data-id'); 11385 var reponse = getReponseClientByTypeQuestion($('.inpt_uneQuestionClient[data-id="'+idQuestion+'"]:first')); 11386 var infosReponse = {'ID': idQuestion, 'reponse': reponse}; 11387 tabReponses.push(infosReponse); 11388 }); 11389 11390 $.ajax({ 11391 type: 'POST', 11392 url: urlAJAX, 11393 data: {type: "enregistreReponsesQuestionnairesClient", tabReponses: tabReponses}, 11394 beforeSend: function(){ 11395 11396 } 11397 }); 11398 })(jQuery); 11399} 11400 11401function initHistoriqueClientsLocalStorage(){ 11402 (function($){ 11403 var histoClients = JSON.parse(localStorage.getItem('histoClients'));
11404 if (histoClients === null){ 11405 $('#select_histoClients').hide(); 11406 return; 11407 } 11408 var htmlSelect = '<option value="defaut">Historique clients</option>'; 11409 $.each(histoClients,function(index, tabInfos) { 11410 var libelle = tabInfos.nom+' '+tabInfos.prenom+' '+tabInfos.mail; 11411 htmlSelect += '<option value="'+index+'">'+libelle+'</option>'; 11412 }); 11413 11414 $('#select_histoClients').html(htmlSelect); 11415 $('#select_histoClients').show(); 11416 $('#select_histoClients').unbind('change'); 11417 $('#select_histoClients').bind('change', function(){ 11418 saisieClientsAvecHistorique($(this).val()); 11419 }); 11420 })(jQuery); 11421} 11422 11423function saisieClientsAvecHistorique(indexSelect){ 11424 (function($){ 11425 var tabInfosSelect = {}; 11426 var histoClients = JSON.parse(localStorage.getItem('histoClients')); 11427 if (histoClients === null){ 11428 // pas un json 11429 histoClients = {}; 11430 } 11431 $.each(histoClients,function(index, tabInfos) { 11432 if (index==indexSelect) { 11433 tabInfosSelect = tabInfos; 11434 } 11435 }); 11436 autofillFormulaireClient(tabInfosSelect); 11437 })(jQuery); 11438} 11439 11440function ajouteClientDansLocalStorage(tabInfos){ 11441 (function($){ 11442 var histoClients; 11443 histoClients = JSON.parse(localStorage.getItem('histoClients')); 11444 if (histoClients === null){ 11445 // pas un json 11446 histoClients = {}; 11447 } 11448 var remove = 0; 11449 if(histoClients.length>10){ 11450 remove = 1; 11451 } 11452 Array.prototype.splice.call(histoClients,histoClients.length,remove,tabInfos); 11453 localStorage.setItem('histoClients', JSON.stringify(histoClients)); 11454 })(jQuery); 11455} 11456 11457function autofillFormulaireClient(tabInfos) { 11458 if(!tabInfos){ 11459 return; 11460 } 11461 (function ($) { 11462 $('#select_civiliteClient').val(tabInfos.civilite); 11463 $('#select_categorieClient').val(tabInfos.categorie); 11464 $('#select_origineClient').val(tabInfos.origine); 11465 $('#inpt_nomClient').val(tabInfos.nom); 11466 $('#inpt_prenomClient').val(tabInfos.prenom); 11467 $('#inpt_cpClient').val(tabInfos.cp); 11468 $('#inpt_villeClient').val(tabInfos.ville); 11469 $('#inpt_mailClient').val(tabInfos.mail); 11470 $('#inpt_mailClientPlus').val(tabInfos.mailPlus); 11471 $('#inpt_adresse1Client').val(tabInfos.adresse1); 11472 $('#inpt_adresse2Client').val(tabInfos.adresse2); 11473 $('#inpt_telDomClient').val(tabInfos.telDom); 11474 $('#inpt_telBurClient').val(tabInfos.telBur); 11475 $('#inpt_mdpClient').val(tabInfos.mdp); 11476 $('#inpt_numeroClient').val(tabInfos.numeroClient); 11477 $('#inpt_identClientNat').val(tabInfos.identClientNat); 11478 $('#inpt_mdpNationalExistant').val(tabInfos.mdpNationalExistant); 11479 $('#select_langueContratClient').val(tabInfos.langueContrat); 11480 if (tabInfos.pays) { 11481 $('option', $('#select_pays')).attr('selected', false); 11482 $('option[data-code="' + tabInfos.pays + '"]', $('#select_pays')).attr('selected', true); 11483 } 11484 })(jQuery); 11485} 11486 11487function estMultiResa(){ 11488 return (function ($) { 11489 var multiResa = $('#divHiddenMultiResa') ; 11490 if(multiResa.length>0){ 11491 return true; 11492 } 11493 return false; 11494 })(jQuery); 11495} 11496 11497function getClientMultiResaDansSessionStorage() {
11498 let clientMultiResa = JSON.parse(sessionStorage.getItem('clientMultiResa')) || false; 11499 if (clientMultiResa) { 11500 return clientMultiResa; 11501 } 11502} 11503 11504function ajouteClientMultiResaDansSessionStorage(tabInfosClient) { 11505 if (!getClientMultiResaDansSessionStorage()) { 11506 sessionStorage.setItem('clientMultiResa', JSON.stringify(tabInfosClient)); 11507 } 11508} 11509 11510function verifFraisDossier(){(function($){ 11511 var prixLoc = parseFloat($('.inpt_modifPrixResaBureau[name="prixLocation"]').val()); 11512 var frais = parseFloat($('.inpt_modifPrixResaBureau[name="fraisDossier"]').val()); 11513 if(frais>prixLoc){ 11514 $('.inpt_modifPrixResaBureau[name="fraisDossier"]').addClass('erreur'); 11515 $('.inpt_modifPrixResaBureau[name="fraisDossier"]').val(0); 11516 }else{ 11517 $('.inpt_modifPrixResaBureau[name="fraisDossier"]').removeClass('erreur'); 11518 } 11519 })(jQuery); 11520} 11521 11522function questionRecalculAuto(){ 11523 (function($){ 11524 if($('#divQuestionRecalculAuto').length==0){ 11525 return; 11526 } 11527 $('#divQuestionRecalculAuto').dialog({ 11528 modal:true, 11529 title: 'Recalcul automatique', 11530 buttons:{ 11531 "Oui":function(){ 11532 $.ajax({ 11533 type: 'POST', 11534 url: urlAJAX, 11535 data: {type: 'recalculAutomatique'}, 11536 beforeSend: function(){ 11537 affMsgAttenteParDessusInDiv("div_resaRecap", "recapPrix", 'Recalcul en cours'); 11538 $('#div_confirmDispos span.confirmSaisie.ko').html('').hide(); 11539 }, 11540 success: function(result){ 11541 var tabRetour = XMLToArray(result); 11542 if (tabRetour.code=='OK') { 11543 afficheEffaceRecapPrix(tabRetour); 11544 } else { 11545 // TODO : afficher message d'erreur 11546 } 11547 effaceMsgAttenteParDessus("recapPrix"); 11548 }, 11549 error: function(jqXHR, textStatus, errorThrown){ 11550 alert(textStatus); 11551 alert(errorThrown); 11552 } 11553 }); 11554 $(this).dialog("close"); 11555 }, 11556 "Non": function() { 11557 $(this).dialog("close"); 11558 effaceMsgAttenteParDessus("recapPrix"); 11559 } 11560 } 11561 }); 11562 })(jQuery); 11563} 11564 11565function terminerModifResa() { 11566 (function ($) { 11567 $.ajax({ 11568 type: "POST", 11569 url: urlAJAX, 11570 async: false, 11571 dataType: 'json', 11572 data: {type: 'validerModifResa'}, 11573 success: function (result) { 11574 if (result.code === 'OK') { 11575 location.href = 'etape4.php' + location.search; 11576 } else if (result.modifDateHorsExe == 'O') { 11577 afficheMsgErrModifDateHorsExe(result.msg); 11578 } else { 11579 afficheMsgErrTechnq(result.msg, result.titre); 11580 effaceMsgAttenteParDessus('contenu'); 11581 } 11582 }, 11583 beforeSend: function () { 11584 affMsgAttenteParDessusInDiv('div_resaContenu', 'contenu', 'Enregistrement en cours'); 11585 } 11586 }); 11587 })(jQuery); 11588} 11589 11590function afficheMsgErrModifDateHorsExe(msg) { 11591 (function ($) { 11592 $("<div id='dialogMessageErrTechnq'><p>" + msg + "</p></div>").dialog({ 11593 modal: true, 11594 buttons: { 11595 "Fermer": function () { 11596 $(this).dialog('close'); 11597 11598 }, 11599 "Créer une nouvelle réservation": function () { 11600 retourEtape1AvecDate('deb=' + $('#inpt_resaDateDeb').val() + '&fin' + $('#inpt_resaDateFin').val()); 11601 } 11602 } 11603 }); 11604 })(jQuery); 11605} 11606 11607function affectAssuranceMultiResaDepuisSessionStorage() { 11608 let objMultiResa = JSON.parse(sessionStorage.getItem('assuranceMultiResa')) || false; 11609 if (objMultiResa) { 11610 affectAssurance(objMultiResa); 11611 } 11612} 11613 11614function setAssuranceMultiResaDansSessionStorage(infos) { 11615 let objMultiResa = JSON.parse(sessionStorage.getItem('assuranceMultiResa')) || false; 11616 if (!objMultiResa) { 11617 sessionStorage.setItem('assuranceMultiResa', JSON.stringify(infos)); 11618 } 11619} 11620 11621function setFormuleAssurance(inputSelected) { 11622 (function ($) { 11623 if (!inputSelected) { 11624 return; 11625 } 11626 var value = $(inputSelected).val(); 11627 affectAssurance({action: 'majChoixFormuleAssurance', value: value}); 11628 etapeCourante($("#div_uneEtape_assuranceAnnul"), true); 11629 if ($(inputSelected).val()) { 11630 $(".sp_recapSansAssurAnnul").hide(); 11631 $(".sp_recapAvecAssurAnnul").show(); 11632 } 11633 else { 11634 $(".sp_recapAvecAssurAnnul").hide(); 11635 $(".sp_recapSansAssurAnnul").show(); 11636 } 11637 })(jQuery); 11638} 11639 11640function modifieResaExistante(){ 11641 if (jQuery('.inpt_modifResa').length>0) { 11642 return true; 11643 } 11644 return false;
11645} 11646 11647function gereDivAlertResaJoursIdentiques(htmlAlertResasJoursIdentiques) { 11648 //console.log('foncResa.js gereDivAlertResaJoursIdentiques htmlAlertResasJoursIdentiques:'+htmlAlertResasJoursIdentiques); 11649 (function ($) { 11650 // Infos sur les résas présentes le même jour que les dates du dossier 11651 if (htmlAlertResasJoursIdentiques) { 11652 if ($('#div_alertResaJoursIdentiques').length > 0) { 11653 $('#div_alertResaJoursIdentiques').replaceWith(htmlAlertResasJoursIdentiques); 11654 } else { 11655 $('#div_choixDates').append(htmlAlertResasJoursIdentiques); 11656 } 11657 } else { 11658 $('#div_alertResaJoursIdentiques').remove(); 11659 } 11660 })(jQuery); 11661} 11662 11663function gereDivAlertHorairesBloquants(htmlAlertHorairesBloquants) { 11664 //console.log('foncResa.js gereDivAlertResaJoursIdentiques htmlAlertHorairesBloquants:'+htmlAlertHorairesBloquants); 11665 (function ($) { 11666 // Infos sur les résas présentes le même jour que les dates du dossier 11667 if (htmlAlertHorairesBloquants) { 11668 if ($('#div_alertHorairesBloquants').length > 0) { 11669 $('#div_alertHorairesBloquants').replaceWith(htmlAlertHorairesBloquants); 11670 } else { 11671 $('#div_choixDates').append(htmlAlertHorairesBloquants); 11672 } 11673 } else { 11674 $('#div_alertHorairesBloquants').remove(); 11675 } 11676 })(jQuery); 11677} 11678 11679function gereDivModifHoraires(htmlModifHoraires) { 11680 if (htmlModifHoraires === undefined) { 11681 return; 11682 } 11683 (function ($) { 11684 if ($('.div_modifHoraires').length > 0) { 11685 $('.div_modifHoraires').remove(); 11686 } 11687 $('.div_modifHoraire_arrivee').replaceWith(htmlModifHoraires.arrivee); 11688 $('.div_modifHoraire_depart').replaceWith(htmlModifHoraires.depart); 11689 initChangeHeureDebFin(); 11690 })(jQuery); 11691} 11692 11693function init_btnModifierDates(){ 11694 (function ($) { 11695 if($("#a_afficheModifDate").length>0){ 11696 $("#a_afficheModifDate").click(function(){ 11697 $('#'+$(this).data("divaffiche")).show(); 11698 $('#'+$(this).data("divmasque")).hide(); 11699 }); 11700 } 11701 })(jQuery); 11702} 11703 11704function init_btnsAfficheDetailsMoyensPaiements(){ 11705 (function ($) { 11706 if($(".a_txtModePaiement").length>0){ 11707 $(".a_txtModePaiement").each(function(){ 11708 if($(this).prev(".sp_txtModePaiement").html().length===0){ 11709 $(this).hide(); 11710 } 11711 }); 11712 $(".a_txtModePaiement").click(function(){ 11713 if($(this).prev(".sp_txtModePaiement").is(":hidden")){ 11714 $(this).prev(".sp_txtModePaiement").show(); 11715 $(this).text($(this).data("lblmasque")); 11716 } else { 11717 $(this).prev(".sp_txtModePaiement").hide(); 11718 $(this).text($(this).data("lblaffiche")); 11719 } 11720 11721 }); 11722 } 11723 })(jQuery); 11724} 11725 11726/******** 11727 * ATTENTION : tous les appels ajax doivent etre faits en async sinon on validera l'étape 1 sans finir 11728 * @returns {undefined} 11729 */ 11730function enregistreElementsAvantValidationEtape1() { 11731 (function($){ 11732 $.ajaxSetup({async:false}); 11733 affecteDatesNaissanceAvecCoherence(); 11734// affecteAnneesEnfantsAvecCoherence(); 11735 // on enregistre la provenance du dossier avant d'aller en étape 2 (pour tout gérer avant de partir) 11736 if ($('#inpt_provenance').length > 0) { 11737 var enregistrementProvenance = false; 11738 $.ajax({ 11739 type: "POST", 11740 url: urlAJAX, 11741 async: false, // TRES IMPORTANT 11742 dataType: 'json', 11743 data: {type: "setProvenance", provenance: $('#inpt_provenance').val()}, 11744 success: function (result) { 11745 if (result.code === 'OK') { 11746 enregistrementProvenance = true; 11747 } 11748 } 11749 }); 11750 if (!enregistrementProvenance) { 11751 afficheMsgErrTechnq('Nous n\'avons pas pu enregistrer le champ Provenance, veuillez recommencer ou contacter ITEA', 'Problème lors de l\'enregistrement.'); 11752 } 11753 } 11754 $.ajaxSetup({async:true}); 11755 })(jQuery); 11756} 11757 11758function affecteAnneesEnfantsAvecCoherence(){ 11759 (function($){ 11760 var tabChambres = {}; 11761 $('.div_uneChambreSelection,#div_uneEtape_compoFamilleGite').each(function(){ 11762 var tabAnnees = construireTableauAnneesEnfants(this);
11763 var index = $(this).data('num_idch') || 'gite'; 11764 tabChambres[index] = tabAnnees; 11765 }); 11766 var params= { 11767 type: 'affectAnneesEnfantsAvecCoherence', 11768 tabChambres : tabChambres 11769 }; 11770 $.ajax({ 11771 type: "POST", 11772 url: urlAJAX, 11773 async: false, // TRES IMPORTANT 11774 data: params, 11775 beforeSend: function(){ 11776 11777 }, 11778 success: function(result){ 11779 eval("var tabResult="+result); 11780 if (tabResult.code === errDossierNull) { 11781 retourEtape1(tabResult.msg); 11782 } 11783 else if (tabResult.errTechnq) { 11784 afficheMsgErrTechnq(tabResult.msg, tabResult.titre, tabResult.ident, true); 11785 } 11786 } 11787 }); 11788 })(jQuery); 11789} 11790 11791function affectePaysAssurance() { 11792 (function($){ 11793 if ($('.choixPaysAssurance').length === 0) { 11794 return; // pas le module 11795 } 11796 var codePays = ''; 11797 var assuranceSelectionnee = $('input[name="formuleAssurance"]:checked').val(); 11798 if (!assuranceSelectionnee) { 11799 if ($('#selectPaysAssurance_nonCouvert').val()) { 11800 codePays = $('#selectPaysAssurance_nonCouvert').val(); 11801 } 11802 } else { 11803 codePays = $('#selectPaysAssurance_' + assuranceSelectionnee).val(); 11804 } 11805 retour = true; 11806 var params= { 11807 type: 'affectePaysAssurance', 11808 codePays : codePays 11809 }; 11810 $.ajax({ 11811 type: "POST", 11812 url: urlAJAX, 11813 data: params, 11814 }); 11815 })(jQuery); 11816} 11817 11818function construireTableauAnneesEnfants(element) { 11819 var tabOut = []; 11820 (function ($) { 11821 var nb = parseInt($('.select_compoFamilleEnfant', element).val()); 11822 var age; 11823 for (var i = 1; i <= nb; i++) { 11824 age = $('.select_compoFamilleAgeEnfants[data-id="' + i + '"]', element).val(); 11825 if (parseInt(age)>0) { 11826 tabOut.push(age); 11827 } 11828 } 11829 nb = parseInt($('.select_compoFamilleBebe', element).val()); 11830 for (var i = 1; i <= nb; i++) { 11831 age = $('.select_compoFamilleAgeBebe[data-id="' + i + '"]', element).val(); 11832 if (parseInt(age)>0) { 11833 tabOut.push(age); 11834 } 11835 } 11836 })(jQuery); 11837 return tabOut; 11838} 11839 11840function estResaVoiture() { 11841 if (jQuery('#div_uneEtape_voitureChoixPresta').length > 0) { 11842 return true; 11843 } 11844 return false; 11845} 11846function estResaVoitureNouveauScript() { 11847 if (jQuery('#inpt_nouveauScriptVoiture').length > 0) { 11848 return true; 11849 } 11850 return false; 11851} 11852 11853function afficheInfosVerifDateITEA(tabRetour) { 11854 (function ($) { 11855 if ($('#divInfosResaITEA').length > 0 && tabRetour.resultReqITEA) { 11856 var htmlInfosITEA = ''; 11857 $.map(tabRetour.resultReqITEA, function (obj) { 11858 var htmlResultatITEA = '<div><h3>' + obj.libelle; 11859 if (parseInt(obj.erreur) > 0) { 11860 htmlResultatITEA += ' erreur : ' + obj.erreur; 11861 } 11862 htmlResultatITEA += '</h3>'; 11863 htmlResultatITEA += '<p>' + obj.info + '</p>'; 11864 if (obj.resultat) { 11865 htmlResultatITEA += '<h4>Infos requete : </h4>'; 11866 var props = Object.keys(obj.resultat); 11867 $(props).each(function (prop) { 11868 htmlResultatITEA += '<p><span class="infoITEAResultatRequete">' + this + '</span><span>' + obj.resultat[this] + '</span></p>'; 11869 }); 11870 } 11871 htmlResultatITEA += '</div>'; 11872 htmlInfosITEA += htmlResultatITEA; 11873 }); 11874 $('#divInfoVerifDate').html(htmlInfosITEA); 11875 } 11876 })(jQuery); 11877} 11878 11879function desactiveBoutonsPaiement(){ 11880 desactiveBoutonValidationCentralPay(); 11881} 11882 11883function reactiveBoutonsPaiement(typePaiement){ 11884 if (typePaiement === 'PLEDG') { 11885 reactiveBoutonValidationPledg(); 11886 return; 11887 } 11888 reactiveBoutonValidationCentralPay(); 11889 if (typeof reactiveBoutonValidationANCV_CVCO !== 'undefined') { 11890 reactiveBoutonValidationANCV_CVCO(); 11891 if (jQuery('#div_popinPaiementAncvCvco').length > 0) { 11892 jQuery('#div_popinPaiementAncvCvco').dialog('close'); 11893 } 11894 } 11895} 11896 11897function updateAffichagePrixBuroProp() { 11898 (function ($) { 11899 var prixLocation = 0; 11900 var acompte = 0; 11901 var fraisDossier = 0; 11902 var prixTotal = 0; 11903 let prixOptions = 0; 11904 11905 if ($('.inpt_modifPrixLocationResaProp:visible').length>0) { 11906 prixLocation = parseFloat($('.inpt_modifPrixLocationResaProp:visible').val()); 11907 var tdPrixGite = $('.td_detailPrix[id="td_prixLocation"]'); 11908 if(tdPrixGite !== undefined && tdPrixGite.length > 0){ 11909 tdPrixGite.html(getNumberFormatLikePrix(prixLocation.toString().replace('.', ',')) + ' '); 11910 } 11911 } else if ($('.inpt_modifPrixChambreCentraleProp:visible').length>0) { 11912 var inputs = $('.inpt_modifPrixChambreCentraleProp:visible'); 11913 $(inputs).each(function(){ 11914 var prixChambre = $(this).val(); 11915 var numChambre = $(this).data('numerochambre'); 11916 prixLocation += parseFloat(prixChambre.replace(',', '.')); 11917 // on ne passe pas l'id direct car on a plusieurs tr avec la même id 11918 // et passer l'id directement (ex:$('#test') ) ne ressort qu'un seul objet 11919 var tdPrixChambre = $('.tr_prixChambre[id="tr_prixChambre_' + numChambre + '"]').find('.td_prixChambre'); 11920 if(tdPrixChambre !== undefined && tdPrixChambre.length > 0){ 11921 tdPrixChambre.html(getNumberFormatLikePrix(prixChambre.toString().replace('.', ',')) + ' '); 11922 } 11923 }); 11924 } 11925 11926 $('#div_msgInfoRecalculFdTs').show(); 11927 11928 if($('#inpt_modifFDResaProp').length > 0){ 11929 fraisDossier = parseFloat($('#inpt_modifFDResaProp').val()); 11930 $('.td_prixFraisDossier').html(getNumberFormatLikePrix(fraisDossier.toString().replace('.', ',')) + ' '); 11931 } else { 11932 fraisDossier = parseFloat($('#td_prixFraisDossier').text()); 11933 } 11934 11935 // si il n'y a pas de valeur, le calcul plante 11936 prixLocation = prixLocation || 0; 11937 fraisDossier = fraisDossier || 0; 11938
11939 acompte = getAcompteByPrixLocEtFraisDossierBuroProp(prixLocation, fraisDossier); 11940 $('.td_prixAcompte').html(getNumberFormatLikePrix(acompte.toString().replace('.', ',')) + ' '); 11941 11942 let prixOptionsIdsTraites = []; 11943 $('.td_recap_prixOption').filter(':visible').each((i, element) => { 11944 let currentId = $(element).attr('id'); 11945 if(prixOptionsIdsTraites.includes(currentId)) { 11946 return; 11947 } 11948 prixOptionsIdsTraites.push(currentId); 11949 prixOptions += parseFloat($(element).data('prixoption')); 11950 }); 11951 11952 prixTotal = prixLocation + fraisDossier + prixOptions; 11953 prixTotal += parseFloat($('#td_montantTaxeSejour').html().replace(',', '.')); 11954 var stringPrixTotal = prixTotal.toString().replace('.', ','); 11955 11956 $('.td_prixTotal').attr('data-montant', prixTotal); 11957 $('.td_prixTotal').html(getNumberFormatLikePrix(stringPrixTotal) + ' '); 11958 $('.td_loyerProp').html(Math.floor((prixLocation * 100) / (100 + $('.td_detailPrix.td_tauxCommission').data('tauxcommission'))) + ' '); 11959 $('.td_commProp').html((loyerProp + prixOptions) + ' '); 11960 11961 updateAffichagePaiementCentralPayBuroProp(acompte, prixTotal); 11962 })(jQuery); 11963} 11964 11965function updateAffichagePaiementCentralPayBuroPropResaLD() { 11966 (function ($) { 11967 console.log('PASSE updateAffichagePaiementCentralPayBuroPropResaLD'); 11968 var prixLocation = 0; 11969 var acompte = 0; 11970 var montantPercu = 0; 11971 var prixTotal = 0; 11972 11973 if ($('.inpt_modifPrixLocationResaProp:visible').length > 0) { 11974 prixLocation = parseFloat($('.inpt_modifPrixLocationResaProp:visible').val()); 11975 } else if ($('.inpt_modifPrixChambreResaProp:visible').length > 0) { 11976 var inputs = $('.inpt_modifPrixChambreResaProp:visible'); 11977 $(inputs).each(function () { 11978 var prixChambre = $(this).val(); 11979 prixLocation += parseFloat(prixChambre.replace(',', '.')); 11980 }); 11981 } 11982 11983 if ($('#inpt_modifMontantPercu').length > 0 && !isNullOrUndefinedOrEmpty($('#inpt_modifMontantPercu').val())) { 11984 montantPercu = parseFloat($('#inpt_modifMontantPercu').val()); 11985 } 11986 11987 prixTotal = prixLocation - montantPercu; 11988 11989 if ($('#inpt_modifAcompteResaProp').length > 0 && !isNullOrUndefinedOrEmpty($('#inpt_modifAcompteResaProp').val())) { 11990 acompte = parseFloat($('#inpt_modifAcompteResaProp').val()); 11991 } else { 11992 acompte = getAcompteByPrixLocEtFraisDossierBuroProp(prixTotal, 0); 11993 } 11994 11995 updateAffichagePaiementCentralPayBuroProp(acompte, prixTotal); 11996 })(jQuery); 11997} 11998 11999function updateAffichagePaiementCentralPayBuroProp(acompte, prixTotal){ 12000 (function($){ 12001 if(acompte === 0 && prixTotal === 0){ 12002 return; 12003 } 12004 var montantARegler = 0; 12005 12006 // on récupère l'input radio de l'acompte 12007 var inputAcompte = $('input[name="choixPaiementCB"][value="acompte"]'); 12008 if(inputAcompte !== undefined && inputAcompte.length > 0 && acompte > 0) { 12009 // on récupère l'acompte actuel sous forme de string pour pouvoir le remplacer dans le span 12010 // on met '0' par défaut si le montant n'est pas rempli 12011 var acompteActuel = getNumberFormatLikePrix(inputAcompte.attr('data-montant').replace('.', ',')) || '0'; 12012 var stringAcompte = getNumberFormatLikePrix(acompte.toString().replace('.', ',')); 12013 // on récupère le texte du span 12014 var texteAcompte = inputAcompte.siblings('span:not(.infoSupMontantPaiement)').text(); 12015 // on remplace l'ancien acompte par le nouveau 12016 inputAcompte.siblings('span:not(.infoSupMontantPaiement)').html(texteAcompte.replace(acompteActuel.trim(), stringAcompte.trim())); 12017 inputAcompte.attr('data-montant', acompte); 12018 12019 if(inputAcompte.prop('checked')) { 12020 montantARegler = acompte; 12021 } 12022 } 12023 12024 // on récupère l'input radio du solde 12025 var inputPrixTotal = $('input[name="choixPaiementCB"][value="solde"]');
12026 if(inputPrixTotal !== undefined && inputPrixTotal.length > 0 && prixTotal > 0) { 12027 // on récupère le solde actuel sous forme de string pour pouvoir le remplacer dans le span 12028 // on met '0' par défaut si le montant n'est pas rempli 12029 var prixTotalActuel = getNumberFormatLikePrix(inputPrixTotal.attr('data-montant').replace('.', ',')) || '0'; 12030 var stringPrixTotal = getNumberFormatLikePrix(prixTotal.toString().replace('.', ',')); 12031 // on récupère le texte du span 12032 var textePrixTotal = inputPrixTotal.siblings('span:not(.infoSupMontantPaiement)').text(); 12033 // on remplace l'ancien solde par le nouveau 12034 inputPrixTotal.siblings('span:not(.infoSupMontantPaiement)').html(textePrixTotal.replace(prixTotalActuel.trim(), stringPrixTotal.trim())); 12035 inputPrixTotal.attr('data-montant', prixTotal); 12036 12037 if(inputPrixTotal.prop('checked')) { 12038 montantARegler = prixTotal; 12039 } 12040 } 12041 12042 if(montantARegler > 0) { 12043 $('#inpt_montantCB').val(montantARegler); 12044 } 12045 })(jQuery); 12046} 12047 12048function getAcompteByPrixLocEtFraisDossierBuroProp(prixLocation, fraisDossier) { 12049 // on met 25% en taux par défaut 12050 var tauxAcompte = jQuery('.td_prixAcompte').data('tauxacompte') || 25; 12051 var acompte = (prixLocation / 100) * tauxAcompte + fraisDossier; 12052 acompte = Math.round(acompte * 100) / 100; 12053 12054 return acompte; 12055} 12056 12057function getNumberFormatLikePrix(number) { 12058 if(number.match(/^\d+(,|\.)\d$/)) { 12059 number += '0'; 12060 } 12061 return number; 12062} 12063 12064function verifSelectionAnimaux(){ 12065 var verif = true; 12066 (function($){ 12067 $("#div_msgErreursNbAnimaux").hide(); 12068 $('.div_uneEtapeAnimaux').each(function(){ 12069 if ($(this).find('.div_infoCompoAnimauxReponse > input:checked').val()==='Oui') { 12070 if ($(this).find('.select_compoAnimauxChien').val()==="0" && $(this).find('.select_compoAnimauxChat').val()==="0") { 12071 verif = false; 12072 } 12073 } 12074 }); 12075 })(jQuery); 12076 return verif; 12077} 12078 12079function majRecapPrixChoixResaProp(typeResa){ 12080 (function($){ 12081 if ($('.tr_prixFraisDossierCreationPHP').length > 0) { 12082 return; 12083 } 12084 if (typeResa==='LD') { 12085 $('.tr_prixFraisDossier').hide(); 12086 if ($('.td_prixTotalSansFraisService').length > 0) { 12087 $('.td_prixTotal').hide(); 12088 $('.td_prixTotalSansFraisService').show(); 12089 } 12090 } else 12091 if (typeResa==='centrale') { 12092 $('.tr_prixFraisDossier').show(); 12093 if ($('.td_prixTotalSansFraisService').length > 0) { 12094 $('.td_prixTotal').show(); 12095 $('.td_prixTotalSansFraisService').hide(); 12096 } 12097 } 12098 })(jQuery); 12099} 12100 12101function initActionsMotMagique(reload){ 12102 (function($){ 12103 $("#div_motMagique a, #div_motMagique button").click(function(){ 12104 if ($("#inpt_motMagique").val() != "") { 12105 verifMotMagique(true,reload); 12106 } 12107 }); 12108 12109 $("#inpt_motMagique").blur(function(){ 12110 if ($("#inpt_motMagique").val() != "") { 12111 verifMotMagique(true,reload); 12112 } 12113 }); 12114 })(jQuery); 12115} 12116
12117function invalideSaisieDates(msgErr) { 12118 (function ($) { 12119 $("#div_confirmDispos").find(".ko").text(msgErr).show(); 12120 $("#div_uneEtape_date .div_uneEtapeRecap").hide(); 12121 if ($("#inpt_avecRepli").length > 0) { 12122 $("#div_uneEtape_date .div_uneEtapeContent").show(); 12123 } 12124 $("#div_uneEtape_date").find(".inpt_validEtape").val("Non"); 12125 })(jQuery); 12126} 12127 12128function updateSelectCapacite(capacite) { 12129// console.trace('updateSelectCapacite'); 12130 (function ($) { 12131 var isSafari = false; 12132 var ua = navigator.userAgent.toLowerCase(); 12133 if (ua.indexOf('safari') != -1) { 12134 if (ua.indexOf('chrome') > -1) { 12135 var isSafari = false; 12136 } else { 12137 var isSafari = true; 12138 } 12139 } 12140 12141 if (isSafari == true) { 12142 console.log('on est sur safari'); 12143 $('#widgetFNGF_selectCapacite option').remove(); 12144 } else { 12145 $('#widgetFNGF_selectCapacite option').hide(); 12146 } 12147 console.log('on met a jour la capacité : ', capacite); 12148 for (var i = 1; i <= capacite; i++) { 12149 if (isSafari == true) { 12150 $('#widgetFNGF_selectCapacite').append($('#widgetFNGF_selectCapacite_copie option[value="' + i + '"]').get()); 12151 } else { 12152 $('#widgetFNGF_selectCapacite option[value="' + i + '"]').show(); 12153 } 12154 } 12155 if (capacite >= 2) { 12156 $('.widgetFNGF_divSelectCapacite select option[value="2"]').prop('selected', true); 12157 } else { 12158 $('.widgetFNGF_divSelectCapacite select option[value="1"]').prop('selected', true); 12159 } 12160 $('.widgetFNGF_divSelectCapacite').show(); 12161 })(jQuery); 12162} 12163 12164function updatePrixResa() { 12165 (function ($) { 12166 $('#widgetFNGF_selectCapacite').attr('updated', 'O'); 12167 var tabData = { 12168 type: 'verifDates', 12169 dateDeb: $('#inpt_resaDateDebCal').val(), 12170 dateFin: $('#inpt_resaDateFinCal').val(), 12171 estPresentSurFiche: true, 12172 instance: $('#div_choixDates_packDivDatesTarifs').attr('data-instance'), 12173 ident: $('#div_choixDates_packDivDatesTarifs').attr('data-ident'), 12174 exercice: $('#div_choixDates_packDivDatesTarifs').attr('data-exercice'), 12175 }; 12176 if ($('#widgetFNGF_selectChambre').length > 0) { 12177 tabData['numChambre'] = $('#widgetFNGF_selectChambre option:selected').val(); 12178 tabData['annulChoix'] = true; 12179 tabData['removeChambres'] = 'O'; 12180 } 12181 ajaxVerifDates(tabData); 12182 })(jQuery); 12183} 12184 12185function showDivEtapeCanevas(){ 12186 (function ($) { 12187 if($('#div_uneEtape_canevas').find('.div_uneEtapeContent').length>0){ 12188 $('#div_uneEtape_canevas').addClass('div_uneEtape').show(); 12189 } 12190 })(jQuery); 12191} 12192 12193function hideDivEtapeCanevas(){ 12194 (function ($) { 12195 $('#div_uneEtape_canevas').removeClass('div_uneEtape').hide(); 12196 })(jQuery); 12197} 12198 12199function afficheChoixPaysAssurance(assurance) { 12200 (function ($) { 12201 if ($('.choixPaysAssurance').length === 0) { 12202 return; // pas le module 12203 } 12204 if (!$(assurance).val()) { 12205 return; 12206 } 12207 $('#choixPaysAssurance_' + $(assurance).val()).show(); 12208 verifiePaysCouvertParAssurance('#selectPaysAssurance_' + $(assurance).val()); 12209 })(jQuery); 12210} 12211 12212function verifiePaysCouvertParAssurance(select) { 12213 (function ($) { 12214 $('.select_paysAssurance').val($(select).val()); 12215 affectePaysAssurance(); 12216 if ($('option:selected', select).attr('data-pays-autorise')) { 12217 // pays de résidence autorisé pour l'assurance 12218 $('#alertChoixPaysAssurance').hide(); 12219 $('#div_assuranceAnnul').show(); 12220 // on sélectionne l'assurance la plus chère 12221 selectionneAssuranceParDefaut(); 12222 return; 12223 } 12224 $('input[name="formuleAssurance"]').prop('checked', false); // on retire l'assurance annulation 12225 $('#divFormuleAssuranceSans input[name="formuleAssurance"]').prop('checked', true); // on sélectionne "pas d'assurance" 12226 setFormuleAssurance($('#divFormuleAssuranceSans input[name="formuleAssurance"]')); 12227 $('#choixPaysAssurance_nonCouvert').show(); // on permet au client de modifier le pays sélectionné 12228 $('#alertChoixPaysAssurance').show(); 12229 $('#div_assuranceAnnul').hide(); 12230 })(jQuery); 12231} 12232 12233function majSelectPaysAssuranceEtClient(objetSelect) { 12234 (function ($) { 12235 // Si les deux select ne sont pas sur la même page ça ne sert à rien 12236 if ($('.select_paysAssurance').length === 0 || $('#select_pays').length === 0) { 12237 return; 12238 } 12239 12240 if ($(objetSelect).is('.select_paysAssurance')) { 12241 $('#select_pays').val($(objetSelect).val()); 12242 $('#select_pays').prop('disabled', true); 12243 $('#select_pays').attr('title', $('#select_pays').data('msg-pays-assurance')); 12244 } else { 12245 $('.select_paysAssurance').val($(objetSelect).val()); 12246 } 12247 12248 })(jQuery); 12249} 12250 12251function verifPaysAssuranceEtape1() { 12252 var retour = false;
12253 (function ($) { 12254 if ($('.choixPaysAssurance').length === 0) { 12255 retour = true; 12256 return; // pas le module 12257 } 12258 var assuranceSelectionnee = $('input[name="formuleAssurance"]:checked').val(); 12259 if (!assuranceSelectionnee) { 12260 retour = true; 12261 return; // pas d'assurance sélectionnée 12262 } 12263 var paysSelectionne = $('#selectPaysAssurance_' + assuranceSelectionnee); 12264 if (!paysSelectionne.val()) { 12265 return; // pas de pays de résidence sélectionné 12266 } 12267 if (!$('option:selected', paysSelectionne).attr('data-pays-autorise')) { 12268 return; // pays non couvert par l'assurance 12269 } 12270 retour = true; 12271 })(jQuery); 12272 return retour; 12273} 12274 12275function selectionneAssuranceParDefaut() { 12276 (function ($) { 12277 if ($('input[name="formuleAssurance"]:checked').val()) { 12278 return; // assurance déjà sélectionnée 12279 } 12280 var montantMax = 0; 12281 var assuranceSelectionnee; 12282 $('.divFormuleAssuranceChoix').each(function(){ 12283 if ($(this).find('.inpt_choixFormuleAssurance[data-precochage="O"]').length > 0) { 12284 assuranceSelectionnee = $(this); 12285 return false; // on sélectionne l'assurance précochée par défaut et sort de la boucle 12286 } 12287 if (!$(this).find('.sp_montantFormuleAssur')) { 12288 return; 12289 } 12290 if (parseFloat($(this).find('.sp_montantFormuleAssur').attr('data-montant')) > montantMax) { 12291 montantMax = parseFloat($(this).find('.sp_montantFormuleAssur').attr('data-montant')); 12292 assuranceSelectionnee = $(this); 12293 } 12294 }); 12295 assuranceSelectionnee.find('.inpt_choixFormuleAssurance').prop('checked', true); 12296 assuranceSelectionnee.find('.choixPaysAssurance').show(); 12297 setFormuleAssurance($(assuranceSelectionnee).find('.inpt_choixFormuleAssurance')); 12298 })(jQuery); 12299} 12300 12301function connexionVacancesConnectOK(dataClient) { 12302 (function($) { 12303 if (dataClient.civilite) { 12304 $('#select_civiliteClient').val(dataClient.civilite); 12305 } 12306 if (dataClient.nom) { 12307 $('#inpt_nomClient').val(dataClient.nom); 12308 } 12309 if (dataClient.prenom) { 12310 $('#inpt_prenomClient').val(dataClient.prenom); 12311 } 12312 if (dataClient.adresse1) { 12313 $('#inpt_adresse1Client').val(dataClient.adresse1); 12314 } 12315 if (dataClient.adresse2) { 12316 $('#inpt_adresse2Client').val(dataClient.adresse2); 12317 } 12318 if (dataClient.code_postal) { 12319 $('#inpt_cpClient').val(dataClient.code_postal); 12320 } 12321 if (dataClient.ville) { 12322 $('#inpt_villeClient').val(dataClient.ville); 12323 } 12324 if (dataClient.pays) { 12325 $('#select_pays').val(dataClient.pays); 12326 } 12327 if (dataClient.tel_dom) { 12328 $('#inpt_telDomClient').val(dataClient.tel_dom); 12329 } 12330 if (dataClient.tel_bur) { 12331 $('#inpt_telBurClient').val(dataClient.tel_bur); 12332 } 12333 if (dataClient.email) { 12334 $('#inpt_mailClient').val(dataClient.email); 12335 $('#inpt_confirmMailClient').val(dataClient.email); 12336 } 12337 12338 $('#inpt_mailClient').attr('disabled', true); 12339 $('#div_saisieClientEmailConfirm').hide(); 12340 $('#div_saisieClientPassword').hide(); 12341 $('#div_saisieClientCreationCompteVacancesConnect').hide(); 12342 })(jQuery); 12343} 12344 12345function afficheRecapEcheancier() { 12346 (($) => { 12347 $('.div_modalAidePaiementPledgContent').dialog({ 12348 width: 600, 12349 modal: true, 12350 classes: { 12351 'ui-dialog': 'modalAidePaiementPledg' 12352 } 12353 }); 12354 })(jQuery); 12355} 12356 12357function afficheAlerteChiensChats(nbMaxReel, nbChiensMax, nbChiens, nbChatsMax, nbChats) { 12358 (($) => { 12359 if (nbChiensMax == 0 && nbChatsMax == 0){ 12360 return; 12361 } 12362 12363 let doitAfficherAlerteChiens = true; 12364 let doitAfficherAlerteChats = true; 12365 12366 if (nbChiensMax == 0 && nbMaxReel > nbChatsMax){ 12367 doitAfficherAlerteChiens = false;
12368 } 12369 if (nbChatsMax == 0 && nbMaxReel > nbChiensMax){ 12370 doitAfficherAlerteChats = false; 12371 } 12372 12373 if(nbChiensMax<(nbChiens) && !estResaBureauProp() && doitAfficherAlerteChiens){ 12374 $('.messageSurcapaciteChien').show('fast'); 12375 } 12376 else{ 12377 $('.messageSurcapaciteChien').hide(); 12378 } 12379 if(nbChatsMax<(nbChats) && !estResaBureauProp() && doitAfficherAlerteChats){ 12380 $('.messageSurcapaciteChat').show('fast'); 12381 } 12382 else{ 12383 $('.messageSurcapaciteChat').hide(); 12384 } 12385 })(jQuery); 12386} 12387 12388function estSurCapaciteParTypeAnimal(valeurOption, valSelected, nbMaxReel, nbTypeMax, nbMaxAutreType) { 12389 if (valeurOption < 0){ 12390 return false; 12391 } 12392 if (valeurOption + valSelected > nbMaxReel){ 12393 return true; 12394 } 12395 if (valeurOption > nbTypeMax && nbTypeMax + nbMaxAutreType < nbMaxReel && nbTypeMax > 0){ 12396 return true; 12397 } 12398 return nbTypeMax == 0 && nbMaxAutreType == nbMaxReel; 12399} 12400 12401jQuery(($) => { 12402 let timer, xhr; 12403 const $input = $('#inpt_adresse1Client'); 12404 const $inputCity = $('#inpt_villeClient'); 12405 const $inputPostcode = $('#inpt_cpClient'); 12406 const $list = $input.siblings('.suggestions'); 12407 if (!$input.length || !$inputCity.length || !$inputPostcode.length || !$list.length) { 12408 return; 12409 } 12410 12411 const afficherSuggestionsAdresses = (features) => { 12412 if ($('#select_pays').val() !== 'FR') { 12413 return; 12414 } 12415 $list.empty(); 12416 if (!features.length) { 12417 return $list.hide(); 12418 } 12419 features.forEach((f) => { 12420 $('<li>') 12421 .text(`${f.properties.name} - ${f.properties.city} ${f.properties.postcode}`) 12422 .css({ 12423 padding: '8px', 12424 cursor: 'pointer', 12425 }) 12426 .on('mousedown', (e) => e.preventDefault()) 12427 .on('click', () => { 12428 clearTimeout(timer); 12429 if (xhr) { 12430 xhr.abort(); 12431 } 12432 $input.val(f.properties.name); 12433 $inputCity.val(f.properties.city); 12434 $inputPostcode.val(f.properties.postcode); 12435 $list.hide().empty(); 12436 }) 12437 .appendTo($list); 12438 }); 12439 const pos = $input.position(); 12440 $list.css({ 12441 top: pos.top + $input.outerHeight(), 12442 left: pos.left, 12443 width: $input.outerWidth(), 12444 boxSizing: 'border-box', 12445 }); 12446 $list.show(); 12447 }; 12448 12449 const planifierRecuperationAdresses = () => { 12450 if ($('#select_pays').val() !== 'FR') { 12451 return; 12452 } 12453 clearTimeout(timer); 12454 const q = $.trim($input.val()); 12455 if (q.length > 5) { 12456 timer = setTimeout(() => { 12457 if (xhr) { 12458 xhr.abort(); 12459 } 12460 xhr = $.ajax({ 12461 url: 'https://data.geopf.fr/geocodage/search/', 12462 data: { 12463 q: q, 12464 limit: 10, 12465 }, 12466 dataType: 'json', 12467 success: (res) => afficherSuggestionsAdresses(res.features || []), 12468 error: (err) => { 12469 if (err.statusText !== 'abort') { 12470 console.error(err); 12471 } 12472 }, 12473 }); 12474 }, 500); 12475 } else { 12476 $list.hide().empty(); 12477 } 12478 }; 12479 12480 if ($input.length){ 12481 $input.on('focus input', planifierRecuperationAdresses); 12482 } 12483 12484 $(document).on('click', (e) => { 12485 if ($('#select_pays').val() !== 'FR') { 12486 return; 12487 } 12488 if (!$(e.target).closest('.autocomplete-container').length) { 12489 $list.hide(); 12490 } 12491 }); 12492});
Line numbers count LF bytes from the start of the resource, as the search results do. Vendor segments are library code the classifier recognised; they are stored but not indexed. Bytes are shown as Latin1 characters, one per byte.