1/* */ 2/* Principe : on a 3 modes de fonctionnenemts différents */ 3/* */ 4/* - Activité sur modèle : ni date à choisir ni slot */ 5/* - Activité sur durée : une date à choisir mais pas de slot */ 6/* - Activité sur slot : une date + un slot à choisir */ 7/* */ 8 9"use strict"; 10var trierProduits = false; 11var slotEvent = []; 12var ajaxEnCours = false; 13var viewportWidth = window.innerWidth; 14var viewportHeight = window.innerHeight; 15var moisOK = []; //moisOK[iAct] = "01/2023" si on ne veut pas reclaculer un mois. 16var cacheQteSouhaitee = []; //cacheQteSouhaitee[iAct] = N 17 18/*********** Nombre et Calendrier ***********/ 19//changement du nombre à côté du calendrier 20//si un package n'a pas de nombre, la fonction est appelée quand même avec nombre = 1 dans index par $(document).on("click", "#blocCal_ 21 22function refreshCalNombre(iAct,nombre,mode) 23{ 24 var Tocken = $("#tokenAct_" + iAct).val(); 25 var nombreAct = 1; 26 //var nombre = getQteCombo("qteAct_" + iAct); 27 if(nombre > 1) 28 nombreAct = nombre; 29 30 if($("#icoSpinAct_" + iAct).is(":visible")) 31 { 32 alert(msgRechercheEnCours); 33 return; 34 } 35 36 if(mode == 1) 37 { 38 //daté 39 $("#icoDownAct_" + iAct).hide(); 40 $("#icoSpinAct_" + iAct).show(); 41 } 42 else if(mode ==2) 43 { 44 //catalogue 45 if($("#choixDateAct_" + iAct).hasClass("noDates")) 46 { 47 //pas de pré-calcul du calendrier, on le remplit avec le mois en cours. 48 $("#choixDateAct_" + iAct).toggleClass("noDates"); 49 $("#choixDateAct_" + iAct).prop("readonly",false); 50 $(document).off("click", "#blocCal_" + iAct); 51 } 52 //$("#choixDateAct_" + iAct).val(""); 53 $("#icoCalAct_" + iAct).hide(); 54 $("#icoSpinAct_" + iAct).show(); 55 $("#divSpinnerRecherche_"+ iAct).html(msgRechercheDates + nombre); 56 $("#divSpinnerRecherche_"+ iAct).show(); 57 } 58 59 if($("#cntAjaxSrvAct_" + iAct).is(":visible")) 60 { 61 //plier les div 62 if(mode == 1) 63 $("#icoDownAct_" + iAct).css({'transform' : 'rotate(0deg)'}); 64 65 $("#cntAjaxSrvAct_" + iAct).removeClass("d-flex"); 66 $("#cntAjaxSrvAct_" + iAct).addClass("collapse"); 67 if($("#divAjaxSlotsAct_" + iAct).length && $("#divAjaxSlotsAct_" + iAct).is(":visible")) 68 { 69 if($("#divAjaxSlotsAct_" + iAct).hasClass("colSlotNavig")) 70 { 71 $("#divAjaxSlotsAct_" + iAct).toggleClass("colSlotNavig d-flex flex-column flex-sm-row flex-sm-wrap justify-content-center " + largeurSlots); 72 $("#cntAjaxSrvAct_" + iAct).toggleClass("collapse " + largeurSrv); 73 } 74 else 75 { 76 //damier de slots 77 $("#divAjaxSlotsAct_" + iAct).removeClass("colSlotDamier d-flex flex-row flex-wrap"); 78 } 79 } 80 } 81 if($("#choixDateAct_" + iAct).length) 82 { 83 /*recalcul du calendrier type date-picker*/ 84 var dateActuelle = $("#choixDateAct_" + iAct).val(); 85 86 ajaxEnCours = true; 87 $.ajax({
88 type: "POST", 89 async: true, 90 url: "actliste_ajax_refresh_cal.php", 91 data: {tokenPage: Tocken,i: iAct,nbr: nombreAct,date: dateActuelle}, 92 dataType: 'json', 93 success: function (retour) { 94 ajaxEnCours = false; 95 console.log("retour REFRESH_CAL par refreshCalNombre()."); 96 if (retour['code_erreur'] == 0) { 97 /*****************************************************************/ 98 /******************** REFRESH_CAL REUSSI *********************/ 99 /*****************************************************************/ 100 /*var newEndDate = retour['endDate'];*/ 101 //console.log("datesOK=" + retour['datesOK']); 102 var retourDates = JSON.parse(retour['datesOK']); 103 if(retour['merge_dates']) 104 { 105 datesOK[retour['iAct']] = {...datesOK[retour['iAct']], ...retourDates}; 106 moisOK[retour['iAct']].push(retour['mois']); 107 console.log("Dates conservées pour le mois : " + retour['mois']); 108 } 109 else 110 datesOK[retour['iAct']] = retourDates; 111 $("#choixDateAct_" + iAct).datepicker('hide',''); 112 if($("#choixDateAct_" + iAct).length) 113 { 114 $("#choixDateAct_" + iAct).datepicker('setStartDate',retour['startDate']); 115 //$("#choixDateAct_" + iAct).datepicker('setEndDate',retour['EndDate']); //fait tout planter ! 116 if(retour['startDate'] == retour['endDate']) 117 { 118 $("#choixDateAct_" + iAct).val(retour['startDate']); 119 //$("#choixDateAct_" + iAct).datepicker('update',new Date(2022,12,1)); 120 //$('#dpStartDate').datepicker().children('input').val('2012-08-08'); 121 } 122 //$("#choixDateAct_" + iAct).datepicker('update'); 123 } 124 //else 125 $("#choixDateAct_" + iAct).datepicker('update'); 126 $("#choixDateAct_" + iAct).datepicker('show',''); 127 128 if($("#icoDownAct_" + iAct).length) 129 { 130 //mode daté 131 $("#icoDownAct_" + iAct).show(); 132 $("#icoSpinAct_" + iAct).hide(); 133 } 134 else 135 { 136 //mode catalogue 137 $("#icoCalAct_" + iAct).show(); 138 $("#icoSpinAct_" + iAct).hide(); 139 $("#divSpinnerRecherche_"+ iAct).hide(); 140 } 141 142 if(retour['msg'].length >0) 143 alert(retour['msg']); 144 145 if(retour['startDate'] == retour['endDate']) 146 toggleAct(iAct,mode,true); 147 148 } 149 else if (retour['code_erreur'] == 2) 150 { 151 var complement = "&nc=" + Math.floor(Math.random() * 1000); 152 alert(retour['msg']); 153 document.location.href= mainURL + "bin/index.php?page=vente" + complement; 154 } 155 else { 156 /**********************************************************/ 157 /*************** ERREUR REFRESH_CAL ******************/ 158 /**********************************************************/ 159 console.log("code_erreur REFRESH_CAL = " + retour['code_erreur']); 160 if($("#icoDownAct_" + iAct).length) 161 { 162 //mode daté 163 $("#icoDownAct_" + iAct).show(); 164 $("#icoSpinAct_" + iAct).hide(); 165 } 166 else 167 { 168 //mode catalogue 169 $("#icoCalAct_" + iAct).show(); 170 $("#icoSpinAct_" + iAct).hide(); 171 $("#divSpinnerRecherche_"+ iAct).hide(); 172 } 173 if(retour['msg'].length >0) 174 alert(retour['msg']); 175 } 176 }, 177 error: function (retour) { 178 ajaxEnCours = false; 179 console.log("plantage REFRESH_CAL !"); 180 if($("#icoDownAct_" + iAct).length) 181 { 182 //mode daté 183 $("#icoDownAct_" + iAct).show(); 184 $("#icoSpinAct_" + iAct).hide(); 185 } 186 else 187 { 188 //mode catalogue 189 $("#icoCalAct_" + iAct).show(); 190 $("#icoSpinAct_" + iAct).hide(); 191 $("#divSpinnerRecherche_"+ iAct).hide(); 192 } 193 alert("Mise à jour des dates impossible.\nVeuillez actualiser votre page SVP."); 194 } 195 }); 196 } 197} 198 199//supprime les dates de calendrier et masque le contenu du package 200function abandonPkg(iAct,mode) 201{ 202 if($("#icoSpinAct_" + iAct).is(":visible")) 203 { 204 alert(msgRechercheEnCours); 205 return; 206 } 207 208 if(mode == 1) 209 { 210 //daté 211 $("#icoDownAct_" + iAct).hide(); 212 $("#icoSpinAct_" + iAct).hide(); 213 } 214 else if(mode ==2) 215 { 216 //catalogue
217 if(! $("#choixDateAct_" + iAct).hasClass("noDates")) 218 { 219 $("#choixDateAct_" + iAct).toggleClass("noDates"); 220 $("#choixDateAct_" + iAct).prop("readonly",true); 221 } 222 else 223 $("#choixDateAct_" + iAct).prop("readonly",true); 224 225 $("#choixDateAct_" + iAct).val(""); 226 $("#icoCalAct_" + iAct).show(); 227 $("#icoSpinAct_" + iAct).hide(); 228 $("#divSpinnerRecherche_"+ iAct).hide(); 229 } 230 231 if($("#cntAjaxSrvAct_" + iAct).is(":visible")) 232 { 233 //plier les div 234 if(mode == 1) 235 $("#icoDownAct_" + iAct).css({'transform' : 'rotate(0deg)'}); 236 237 $("#cntAjaxSrvAct_" + iAct).removeClass("d-flex"); 238 $("#cntAjaxSrvAct_" + iAct).addClass("collapse"); 239 if($("#divAjaxSlotsAct_" + iAct).length && $("#divAjaxSlotsAct_" + iAct).is(":visible")) 240 { 241 if($("#divAjaxSlotsAct_" + iAct).hasClass("colSlotNavig")) 242 { 243 $("#divAjaxSlotsAct_" + iAct).toggleClass("colSlotNavig d-flex flex-column flex-sm-row flex-sm-wrap justify-content-center " + largeurSlots); 244 $("#cntAjaxSrvAct_" + iAct).toggleClass("collapse " + largeurSrv); 245 } 246 else 247 { 248 //damier de slots 249 $("#divAjaxSlotsAct_" + iAct).removeClass("colSlotDamier d-flex flex-row flex-wrap"); 250 } 251 } 252 } 253 if($("#choixDateAct_" + iAct).length) 254 { 255 /*vidage du calendrier type date-picker*/ 256 if($("#icoDownAct_" + iAct).length) 257 { 258 //mode daté 259 $("#icoDownAct_" + iAct).show(); 260 $("#icoSpinAct_" + iAct).hide(); 261 } 262 else 263 { 264 //mode catalogue 265 $("#icoCalAct_" + iAct).show(); 266 $("#icoSpinAct_" + iAct).hide(); 267 $("#divSpinnerRecherche_"+ iAct).hide(); 268 } 269 } 270} 271 272function affSpinnerCal(iAct) 273{ 274 console.log("affSpinnerCal" + iAct); 275 $("#icoCalAct_" + iAct).hide(); 276 $("#icoSpinAct_" + iAct).show(); 277} 278 279function hideSpinnerCal(iAct) 280{ 281 console.log("hideSpinnerCal" + iAct); 282 $("#icoSpinAct_" + iAct).hide(); 283 $("#icoCalAct_" + iAct).show(); 284} 285 286/* 11/2023 passage en ASYNC */ 287async function refreshCalMonth(iAct,newMonth) 288{ 289 var Tocken = $("#tokenAct_" + iAct).val(); 290 var dateActuelle = ""; 291 var dateDemandee = "01/" + newMonth ; 292 var nombreAct = 1; 293 var nombre = 1; 294 var startDate = ''; 295 var ancienneDate = ''; 296 297 /* 298 if($("#icoDownAct_" + iAct).length) 299 { 300 //mode daté 301 $("#icoDownAct_" + iAct).hide(); 302 $("#icoSpinAct_" + iAct).show(); 303 } 304 else 305 { 306 //mode catalogue 307 $("#icoCalAct_" + iAct).hide(); 308 $("#icoSpinAct_" + iAct).show(); 309 $("#divSpinnerRecherche_"+ iAct).hide(); 310 }*/ 311 312 if($("#qteAct_" + iAct).length) 313 { 314 if($("#qteAct_" + iAct + ":hidden").length) 315 nombre = 1; 316 else 317 nombre = getQteCombo("qteAct_" + iAct); 318 } 319 if(nombre > 1) 320 nombreAct = nombre; 321 if($("#choixDateAct_" + iAct).length) 322 { 323 dateActuelle = $("#choixDateAct_" + iAct).val(); 324 /* 325 //startDate = $("#choixDateAct_" + iAct).datepicker("getStartDate"); //format inutilisable 326 //console.log("StartDate = " + startDate); 327 ancienneDate = $("#choixDateAct_" + iAct).data("olddate"); 328 console.log("AncienneDate = " + ancienneDate); 329 330 if(dateActuelle.length == 0) 331 dateActuelle = ancienneDate;*/ 332 } 333 /* 334 if(dateActuelle == newMonth) 335 { 336 console.log("refreshCalMonth STOP avec date identique : " + dateActuelle); 337 return; 338 }*/ 339 console.log("Appel ASYNChrone de refresh_cal : " + newMonth); 340 ajaxEnCours = true; 341 $.ajax({
342 type: "POST", 343 async: true, //laisser à false ! 344 url: "actliste_ajax_refresh_cal.php", 345 data: {tokenPage: Tocken,i: iAct,nbr: nombreAct,date: dateActuelle,navDate: dateDemandee}, 346 dataType: 'json', 347 beforeSend: function () { 348 console.log("Starting AJAX RefreshCal..."); 349 }, 350 complete: function () { 351 console.log("Complete AJAX RefreshCal !"); 352 }, 353 success: function (retour) { 354 console.log("retour REFRESH_CAL par refreshCalMonth."); 355 ajaxEnCours = false; 356 var retourAct = retour['iAct']; 357 358 setTimeout(()=> { 359 hideSpinnerCal(retourAct); 360 }, 0); 361 362 if (retour['code_erreur'] == 0) 363 { 364 /*****************************************************************/ 365 /******************** REFRESH_CAL REUSSI *********************/ 366 /*****************************************************************/ 367 var retourDates = JSON.parse(retour['datesOK']); 368 if(retour['merge_dates']) 369 { 370 datesOK[retourAct] = datesOK[retour['iAct']] = {...datesOK[retour['iAct']], ...retourDates}; 371 moisOK[retourAct].push(retour['mois']); 372 console.log("Dates conservées pour le mois : " + retour['mois']); 373 } 374 else 375 datesOK[retourAct] = retourDates; 376 //$("#choixDateAct_" + iAct).datepicker('update'); //surtout pas ! bloque le calendrier au mois courant avant la navigation ! 377 //$("#choixDateAct_" + iAct).datepicker('update', '01' + retour['mois']); //surtout pas ! 378 //$("#choixDateAct_" + iAct).datepicker('update', ''); //surtout pas ! 379 //voir navArrowsClick: function(b) et fill: function() dans bootstrap-datepicker.min.js 380 $("#choixDateAct_" + iAct).datepicker('fill'); //fonction non documentée !!! 381 382 if(! retour['keep_date_actuelle'] && $("#cntAjaxSrvAct_" + iAct).is(":visible")) 383 { 384 //plier les div 385 $("#icoDownAct_" + iAct).css({'transform' : 'rotate(0deg)'}); 386 387 if($("#icoDownAct_" + iAct).length) 388 $("#icoDownAct_" + iAct).show(); 389 $("#icoSpinAct_" + iAct).hide(); 390 391 $("#cntAjaxSrvAct_" + iAct).toggleClass("d-flex"); 392 if($("#divAjaxSlotsAct_" + iAct).length && $("#divAjaxSlotsAct_" + iAct).is(":visible")) 393 { 394 if($("#divAjaxSlotsAct_" + iAct).hasClass("colSlotNavig")) 395 { 396 $("#divAjaxSlotsAct_" + iAct).toggleClass("colSlotNavig d-flex flex-column flex-sm-row flex-sm-wrap justify-content-center " + largeurSlots); 397 $("#cntAjaxSrvAct_" + iAct).toggleClass("collapse " + largeurSrv); 398 } 399 else 400 $("#divAjaxSlotsAct_" + iAct).toggleClass("colSlotDamier d-flex flex-row flex-wrap"); //damier 401 } 402 else { 403 $("#cntAjaxSrvAct_" + iAct).toggleClass("collapse"); 404 } 405 } 406 if(retour['msg'].length >0) 407 alert(retour['msg']); 408 } 409 else { 410 /**********************************************************/ 411 /*************** ERREUR REFRESH_CAL ******************/ 412 /**********************************************************/ 413 console.log("code_erreur REFRESH_CAL = " + retour['code_erreur']); 414 if(retour['msg'].length >0) 415 alert(retour['msg']); 416 if(retour['code_erreur'] == 2) 417 { 418 var complement = "&nc=" + Math.floor(Math.random() * 1000); 419 document.location.href= mainURL + "bin/index.php?page=vente" + complement; 420 } 421 } 422 }, 423 error: function () { 424 setTimeout(()=> { 425 hideSpinnerCal(iAct); 426 }, 0); 427 ajaxEnCours = false; 428 console.log("plantage REFRESH_CAL !"); 429 alert("Mise à jour des dates impossible.\nVotre page va être actualisée."); 430 var complement = "&nc=" + Math.floor(Math.random() * 1000); 431 document.location.href = mainURL + "bin/index.php?page=vente" + complement; 432 } 433 });
434} 435 436async function refreshCalMonthAsync(iAct,newMonth) 437{ 438 var Tocken = $("#tokenAct_" + iAct).val(); 439 var dateActuelle = ""; 440 var dateDemandee = "01/" + newMonth ; 441 var nombreAct = 1; 442 var nombre = 1; 443 var startDate = ''; 444 var ancienneDate = ''; 445 446 await new Promise(resolve => setTimeout(resolve, 1000)); 447 448 if($("#qteAct_" + iAct).length) 449 { 450 if($("#qteAct_" + iAct + ":hidden").length) 451 nombre = 1; 452 else 453 nombre = getQteCombo("qteAct_" + iAct); 454 } 455 if(nombre > 1) 456 nombreAct = nombre; 457 if($("#choixDateAct_" + iAct).length) 458 { 459 dateActuelle = $("#choixDateAct_" + iAct).val(); 460 /* 461 //startDate = $("#choixDateAct_" + iAct).datepicker("getStartDate"); //format inutilisable 462 //console.log("StartDate = " + startDate); 463 ancienneDate = $("#choixDateAct_" + iAct).data("olddate"); 464 console.log("AncienneDate = " + ancienneDate); 465 466 if(dateActuelle.length == 0) 467 dateActuelle = ancienneDate;*/ 468 } 469 /* 470 if(dateActuelle == newMonth) 471 { 472 console.log("refreshCalMonth STOP avec date identique : " + dateActuelle); 473 return; 474 }*/ 475 console.log("Appel refresh_cal en asynchrone : " + newMonth); 476 477 ajaxEnCours = true; 478 $.ajax({
479 type: "POST", 480 async: true, //laisser à true ! 481 url: "actliste_ajax_refresh_cal.php", 482 data: {tokenPage: Tocken,i: iAct,nbr: nombreAct,date: dateActuelle,navDate: dateDemandee}, 483 dataType: 'json', 484 success: function (retour) { 485 ajaxEnCours = false; 486 console.log("retour async REFRESH_CAL par refreshCalMonth."); 487 if (retour['code_erreur'] == 0) { 488 /*****************************************************************/ 489 /******************** REFRESH_CAL REUSSI *********************/ 490 /*****************************************************************/ 491 var retourDates = JSON.parse(retour['datesOK']); 492 if(retour['merge_dates']) 493 { 494 datesOK[retour['iAct']] = {...datesOK[retour['iAct']], ...retourDates}; 495 moisOK[retour['iAct']].push(retour['mois']); 496 console.log("Dates conservées pour le mois : " + retour['mois']); 497 } 498 else 499 datesOK[retour['iAct']] = retourDates; 500 console.log("ASYNC retour['datesOK'] = " + retour['datesOK']) 501 $("#choixDateAct_" + iAct).datepicker('update'); 502 } 503 else { 504 /**********************************************************/ 505 /*************** ERREUR REFRESH_CAL ******************/ 506 /**********************************************************/ 507 console.log("code_erreur async REFRESH_CAL = " + retour['code_erreur']); 508 } 509 }, 510 error: function (retour) { 511 ajaxEnCours = false; 512 console.log("plantage async REFRESH_CAL !"); 513 } 514 }); 515} 516 517function toggleAct(iAct,mode,actDatee) 518{ 519 var Tocken = $("#tokenAct_" + iAct).val(); 520 var nombreAct = 1; 521 var nombre = 1; 522 var cntServices = $("#cntAjaxSrvAct_" + iAct); 523 524 console.log("toggleAct" + iAct); 525 if(datesOK[iAct]) 526 console.log("datesOK[iAct]=" + JSON.stringify(datesOK[iAct])); 527 528 if(cntServices.is(":visible")) 529 { 530 //replier les div déjà affichées 531 $("#icoDownAct_" + iAct).css({'transform' : 'rotate(0deg)'}); 532 if(mode == 1) 533 { 534 //date 535 $("#icoDownAct_" + iAct).show(); 536 $("#icoSpinAct_" + iAct).hide(); 537 } 538 else if(mode ==2) 539 { 540 //catalogue 541 $("#icoCalAct_" + iAct).show(); 542 $("#icoSpinAct_" + iAct).hide(); 543 } 544 545 if(cntServices.is(":visible")) 546 { 547 if(! cntServices.hasClass("isChargement")) 548 cntServices.removeClass("d-flex"); 549 cntServices.addClass("collapse"); 550 } 551 else { 552 //afficher tout 553 cntServices.removeClass("collapse"); 554 if(! cntServices.hasClass("isChargement")) 555 cntServices.removeClass("d-flex"); 556 } 557 if($("#divAjaxSlotsAct_" + iAct).length && $("#divAjaxSlotsAct_" + iAct).is(":visible")) 558 { 559 if($("#divAjaxSlotsAct_" + iAct).hasClass("colSlotNavig")) 560 { 561 $("#divAjaxSlotsAct_" + iAct).removeClass("colSlotNavig d-flex flex-column flex-sm-row flex-sm-wrap justify-content-center " + largeurSlots); 562 //$("#cntAjaxSrvAct_" + iAct).toggleClass("collapse " + largeurSrv); 563 } 564 else 565 $("#divAjaxSlotsAct_" + iAct).removeClass("colSlotDamier d-flex flex-row flex-wrap"); //damier 566 } 567 } 568 else 569 { 570 //spinner attente pour déplier les div selon les cas dans refreshSlots 571 if(mode == 1) { 572 //date 573 $("#icoDownAct_" + iAct).hide(); 574 $("#icoSpinAct_" + iAct).show(); 575 } 576 else if(mode ==2) 577 { 578 //catalogue 579 //les forfaits et act non datées n'ont pas de nombre. 580 if($("#qteAct_" + iAct).length) 581 { 582 if($("#qteAct_" + iAct + ":hidden").length) 583 nombre = 1; 584 else 585 nombre = getQteCombo("qteAct_" + iAct); 586 if(nombre > 1) 587 nombreAct = nombre; 588 $("#divSpinnerRecherche_"+ iAct).html(msgRechercheDates + nombreAct + '<i class="collapse fas fa-spinner fa-spin"></i>'); 589 $("#divSpinnerRecherche_"+ iAct).show(); 590 } 591 else if($("#divSpinnerRecherche_"+ iAct).length) 592 $("#divSpinnerRecherche_"+ iAct).show(); 593 } 594 refreshColSlots(iAct,Tocken,"0",actDatee); 595 } 596 return false; 597} 598 599//ancien calcul des couleurs du clendrier ! plus utilisé 600function switchDateColor(iAct,uneDate,classOK,messageOK,classKO,messageKO) 601{ 602 603 if(datesOK[iAct].indexOf(uneDate) < 0) 604 { 605 //console.log("TT Act " + iAct + " date " + uneDate + " = FALSE"); 606 return { 607 enabled: false, 608 classes: classKO, 609 tooltip: messageKO, 610 content: null 611 }; 612 } 613 else 614 { 615 //console.log("TT Act " + iAct + " date " + uneDate + " = TRUE"); 616 return { 617 enabled: true, 618 classes: classOK, 619 tooltip: messageOK, 620 content: null 621 }; 622 } 623} 624 625// utilisé en 2025 626// calcul multicolor des couleurs du clendrier ! 627function switchDateColor2025(iAct,uneDate,classOK,messageOK,classKO,messageKO,classFull,messageFull,classLess,messageLess) 628{ 629 //la date est-elle présente 630 if(Object.hasOwn(datesOK[iAct],uneDate)) 631 { 632 //date valide ou presque complète 633 //console.log("TT Act " + iAct + " date " + uneDate + " = FALSE"); 634 if(datesOK[iAct][uneDate] == 0) 635 return { 636 enabled: true, 637 classes: classFull, 638 tooltip: messageFull, 639 content: null 640 }; 641 else if(datesOK[iAct][uneDate] < cacheQteSouhaitee[iAct]) 642 { 643 var messageInfo = messageLess.replace("XXX", cacheQteSouhaitee[iAct]); 644 return { 645 enabled: true, 646 classes: classLess, 647 tooltip: messageInfo, 648 content: null 649 }; 650 } 651 else 652 return { 653 enabled: true, 654 classes: classOK, 655 tooltip: messageOK, 656 content: null 657 }; 658 } 659 else 660 { 661 //date invalide 662 //console.log("TT Act " + iAct + " date " + uneDate + " = TRUE"); 663 return { 664 enabled: false, 665 classes: classKO, 666 tooltip: messageKO, 667 content: null 668 }; 669 } 670} 671 672function avertRechercheEnCours(event) { 673 event.preventDefault(); 674 alert("Il y a déjà une recherche en cours."); 675} 676 677async function refreshColSlots(iAct,paramToken,offsetSlot,isActDatee) 678{ 679 if(paramToken) 680 { 681 //var zonePhotos; 682 var dateChoisie = null; //au format JJ/MM/AAAA 683 var nombreAct = 1; //de l'activité 684 var zoneSlots = null; 685 var zoneServices = null; 686 var cntServices = null; 687 var nombre = 1; 688 var isAct = true; 689 690 if( $("#divAjaxSlotsAct_" + iAct).length) 691 zoneSlots = $("#divAjaxSlotsAct_" + iAct); 692 else { 693 alert("La page comporte une erreur. Veuillez nous contacter."); 694 return; 695 } 696 if( $("#qteAct_" + iAct).length) 697 { 698 if($("#qteAct_" + iAct + ":hidden").length) 699 nombre = 1; 700 else 701 nombre = getQteCombo("qteAct_" + iAct); 702 703 if(nombre > 1) 704 nombreAct = nombre; 705 } 706 if( $("#cntAjaxSrvAct_" + iAct).length) 707 cntServices = $("#cntAjaxSrvAct_" + iAct); 708 else { 709 alert("La page comporte une erreur. Veuillez nous contacter."); 710 return; 711 } 712 //pour les activités 713 if( $("#divAjaxSrvAct_" + iAct).length) 714 zoneServices = $("#divAjaxSrvAct_" + iAct); 715 else { 716 isAct = false; 717 //alert("La page comporte une erreur. Veuillez nous contacter."); 718 //return; 719 } 720 if( $("#choixDateAct_" + iAct).length) 721 { 722 dateChoisie = $("#choixDateAct_" + iAct).val(); 723 console.log("Date refreshColSlots = " + dateChoisie); 724 if($("#divSpinnerRecherche_" + iAct).length) 725 $("#divSpinnerRecherche_" + iAct).show(); 726 $("#choixDateAct_" + iAct).on("click",avertRechercheEnCours); 727 $("#groupIcoCal_" + iAct).on("click",avertRechercheEnCours); 728 } 729 else if (isActDatee) 730 { 731 alert("Aucune date choisie."); 732 return; 733 } 734 else 735 dateChoisie = ''; 736 737 //en cas de navigation dans les slots 738 if(zoneSlots.is(":visible")) 739 { 740 zoneServices.html('<p class="ajaxRechTarifs"><i class="spinnerLoadServices fa fa-spinner fa-3x"></i><br>
740' + msgRechercheTarifs + '</p>'); 741 zoneSlots.html('<p class="ajaxRechSlots"><i class="spinnerLoadServices fa fa-spinner fa-3x"></i><br>' + msgRechercheSlots + '</p>'); 742 } 743 //else //dans toggleAct 744 //{ 745 // if($("#divSpinnerRecherche_" + iAct).length) 746 // $("#divSpinnerRecherche_" + iAct).show(); 747 //forfaits & pkg libre : spinner dans la zone services ! 748 //if($("#icoSpinAct_" + iAct).length) 749 // $("#icoSpinAct_" + iAct).show(); 750 //} 751 /*afficher le calendrier et les services si possible*/ 752 if(isAct) 753 { 754 $.ajax({ 755 type: "POST", 756 async: true, 757 url: "actliste_ajax_get_slots.php", 758 data: {tokenPage: paramToken,i: iAct,nbr: nombreAct,date: dateChoisie,next: offsetSlot}, 759 dataType: 'json', 760 success: function (retour) { 761 var isPackage = false; 762 var iAct = retour['iAct']; 763 764 console.log("retour GET SLOTS/MODELE...") 765 $("#choixDateAct_" + iAct).off("click"); 766 $("#groupIcoCal_" + iAct).off("click"); 767 768 if(! $("#formAct_" + iAct).length) 769 isPackage = true; 770 //forfaits & pkg libre : spinner dans la zone services ! 771 //if($("#icoSpinAct_" + iAct).length) //forfaits & pkg libre 772 // $("#icoSpinAct_" + iAct).hide(); 773 //$("#icoDownAct_" + iAct).show(); 774 if($("#divSpinnerRecherche_" + iAct).length) 775 $("#divSpinnerRecherche_" + iAct).hide(); 776 777 if (retour['code_erreur'] == 0) 778 { 779 /***************************************************************/ 780 /******************** GET_SLOTS REUSSI *********************/ 781 /***************************************************************/ 782 if(retour['zoneSlots'].length >0) 783 { 784 zoneSlots.html(retour['zoneSlots']); 785 if(retour['aff_slots'] && ! zoneSlots.is(":visible")) 786 { 787 if(retour['modeDamier']) 788 zoneSlots.addClass("colSlotDamier d-flex flex-row flex-wrap justify-content-center"); //damier 789 else 790 zoneSlots.addClass("colSlotNavig d-flex flex-column flex-sm-row flex-sm-wrap justify-content-center " + largeurSlots); 791 792 } 793 else if(! retour['aff_slots'] && zoneSlots.is(":visible")) 794 { 795 zoneSlots.toggleClass("collapse"); 796 } 797 } 798 799 if(retour['zoneServices'].length >0) 800 { 801 zoneServices.html(retour['zoneServices']); 802 803 if(! cntServices.is(":visible")) 804 { 805 $("#icoDownAct_" + iAct).css({'transform' : 'rotate(180deg)'}); 806 cntServices.toggleClass("collapse"); 807 if(retour['aff_slots'] && ! retour['modeDamier'] ) 808 { 809 if(! cntServices.hasClass(largeurSrv)) 810 cntServices.addClass(largeurSrv); //$gVars['srv_style'] ou 'col-md-9' 811 cntServices.toggleClass("d-flex"); 812 } 813 else 814 { 815 if(cntServices.hasClass(largeurSrv)) 816 { 817 //passage en mode damier, il faut toute la largeur 818 cntServices.removeClass(largeurSrv); //$gVars['srv_style'] ou 'col-md-9' 819 } 820 if(cntServices.hasClass("isChargement")) 821 cntServices.show(); 822 else 823 cntServices.toggleClass("d-flex"); 824 } 825 } 826 } 827 $("#icoSpinAct_" + iAct).hide(); 828 if($("#icoDownAct_" + iAct).length) 829 $("#icoDownAct_" + iAct).show(); 830 831 modeDamier[iAct] = retour['modeDamier']; 832 833 if(retour['msg'].length >0) 834 alert(retour['msg']); 835 //malaysia 836 if(retour['yesterday']) 837 dateChoisie = retour['dateChoisie']; 838 839 if(retour['refreshServices']) 840 refreshServices(iAct,dateChoisie,retour['slotSel'],isPackage); 841 } 842 else if (retour['code_erreur'] == 2) 843 { 844 var complement = "&nc=" + Math.floor(Math.random() * 1000); 845 alert(retour['msg']); 846 document.location.href= mainURL + "bin/index.php?page=vente" + complement; 847 } 848 else { 849 /*******************************************************/ 850 /******* ERREUR ou PLUS DISPO *** GET_SLOTS *********/ 851 /*******************************************************/ 852 var mode = 0; 853 console.log("code_erreur GET_SLOTS = " + retour['code_erreur']); 854 855 $("#icoSpinAct_" + iAct).hide(); 856 if($("#icoDownAct_" + iAct).length) 857 { 858 $("#icoDownAct_" + iAct).show(); 859 mode = 1; 860 } 861 else 862 mode = 2; 863 864 if($("#cntAjaxSrvAct_" + iAct).is(":visible")) 865 { 866 //plier les div 867 if(mode == 1) 868 { 869 //date 870 $("#icoDownAct_" + iAct).css({'transform' : 'rotate(0deg)'}); 871 $("#icoDownAct_" + iAct).show(); 872 $("#icoSpinAct_" + iAct).hide(); 873 } 874 else if(mode ==2) 875 { 876 //catalogue 877 $("#icoCalAct_" + iAct).show(); 878 $("#icoSpinAct_" + iAct).hide(); 879 } 880 881 $("#cntAjaxSrvAct_" + iAct).toggleClass("d-flex"); 882 if($("#divAjaxSlotsAct_" + iAct).length && $("#divAjaxSlotsAct_" + iAct).is(":visible")) 883 { 884 if($("#divAjaxSlotsAct_" + iAct).hasClass("colSlotNavig")) 885 { 886 $("#divAjaxSlotsAct_" + iAct).toggleClass("colSlotNavig d-flex flex-column flex-sm-row flex-sm-wrap justify-content-center " + largeurSlots); 887 $("#cntAjaxSrvAct_" + iAct).toggleClass("collapse " + largeurSrv); 888 } 889 else 890 $("#divAjaxSlotsAct_" + iAct).toggleClass("colSlotDamier d-flex flex-row flex-wrap"); //damier
891 } 892 else { 893 $("#cntAjaxSrvAct_" + iAct).toggleClass("collapse"); 894 } 895 } 896 897 if(retour['msg'].length >0) 898 alert(retour['msg']); 899 } 900 }, 901 error: function (retour) { 902 console.log("plantage GET_SERVICE !"); 903 $("#choixDateAct_" + iAct).off("click"); 904 $("#groupIcoCal_" + iAct).off("click"); 905 906 if($("#divSpinnerRecherche_" + iAct).length) 907 $("#divSpinnerRecherche_" + iAct).hide(); 908 $("#icoDownAct_" + iAct).show(); 909 $("#icoDownAct_" + iAct).css({'transform' : 'rotate(0deg)'}); 910 $("#icoSpinAct_" + iAct).hide(); 911 alert("Affichage des tarifs impossible.\nVeuillez actualiser votre page SVP."); 912 } 913 }); 914 } //isACT 915 else { 916 //forfaits et packages 917 console.log("TT spécifique Forfaits & PAckages..."); 918 cntServices.html('<p class="ajaxRechTarifs"><i class="spinnerLoadServices fa fa-spinner fa-3x"></i><br>' + msgRechercheTarifs +'</p>'); 919 920 $("#choixDateAct_" + iAct).off("click"); 921 $("#groupIcoCal_" + iAct).off("click"); 922 923 if($("#divSpinnerRecherche_" + iAct).length) 924 $("#divSpinnerRecherche_" + iAct).hide(); 925 926 if(! cntServices.is(":visible")) 927 { 928 $("#icoDownAct_" + iAct).css({'transform' : 'rotate(180deg)'}); 929 cntServices.toggleClass("collapse"); 930 931 if(cntServices.hasClass(largeurSrv)) 932 { 933 //passage en mode damier, il faut toute la largeur 934 cntServices.removeClass(largeurSrv); //$gVars['srv_style'] ou 'col-md-9' 935 } 936 cntServices.toggleClass("d-flex"); 937 } 938 939 refreshServices(iAct,dateChoisie,'',true); 940 } 941 } 942 else 943 alert("PAGE HTML INCOMPLETE\nImpossible d'afficher le calendrier."); 944} 945 946/* évènement changement de SLOT ! récupère le slot sélectionné et lance refreshService */ 947function actualiseServices(e) 948{ 949 var origine = this.name.split("_"); //slot_iAct 950 var iAct = origine[1]; 951 var dateCourante = $("#choixDateAct_" + iAct).val(); 952 var newHeure = $(this).val(); 953 var long = newHeure.length; 954 console.log("choix slot :" + newHeure); 955 var zoneServices = $("#divAjaxSrvAct_" + iAct); 956 var isYesterday = $(this).data("yesterday"); 957 958 if(this.checked && long == 5 && dateCourante) 959 { 960 zoneServices.html('<p class="ajaxRechTarifs"><i class="spinnerLoadServices fa fa-spinner fa-3x"></i><br>' + msgRechercheTarifs + '</p>'); 961 if(isYesterday == "1") 962 { 963 var dateToleree = $(this).data("datetoleree"); 964 refreshServices(iAct,dateToleree,newHeure,false); 965 } 966 else 967 refreshServices(iAct,dateCourante,newHeure,false); 968 } 969 else 970 { 971 alert("Impossible de déterminer la date et l'heure choisie.\nVeuillez actualiser la page et nous contacter si le problème persiste.") 972 } 973} 974 975async function refreshServices(iAct, dateSel, slotSel,isPkg) 976{ 977 //alert("refreshServices pour le " + dateSel + " à " + slotSel); 978 979 var Tocken = $("#tokenAct_" + iAct).val(); 980 var zoneServices = $("#divAjaxSrvAct_" + iAct); 981 var reste = 0; 982 var nombre = 1; 983 var urlAjax = "actliste_ajax_get_services.php"; 984 985 if(isPkg) 986 zoneServices = $("#cntAjaxSrvAct_" + iAct); 987 988 if($("#qteAct_" + iAct).length) 989 { 990 if($("#qteAct_" + iAct + ":hidden").length) 991 nombre = 1; 992 else 993 nombre = getQteCombo("qteAct_" + iAct); 994 } 995 996 if(slotSel) { 997 var masque = "input:radio[name ='slot_" + iAct + "']:checked"; 998 var slot = $(masque).val(); 999 reste = parseInt($("#slot_" + iAct + "_" + slot.replace(':','-')).data("reste"),10); 1000 } 1001 1002 if(isPkg) 1003 urlAjax = "actliste_ajax_choixpackage.php"; 1004 1005 /*afficher les services associés*/ 1006 $.ajax({
1007 type: "POST", 1008 async: true, 1009 url: urlAjax, 1010 data: {tokenPage: Tocken,i: iAct, date: dateSel, slot: slotSel, cap: reste, nbr : nombre}, 1011 dataType: 'json', 1012 success: function (retour) { 1013 console.log("retour SERVICES/PACKAGES..."); 1014 1015 if (retour['code_erreur'] == 0) { 1016 /*************************************************************/ 1017 /******************** SERVICES REUSSI ********************/ 1018 /*************************************************************/ 1019 zoneServices.html(retour['zoneServices']); 1020 1021 //mode daté 1022 if($("#icoSpinAct_" + iAct).length) 1023 $("#icoSpinAct_" + iAct).hide(); 1024 if($("#icoDownAct_" + iAct).length) 1025 { 1026 $("#icoDownAct_" + iAct).css({'transform' : 'rotate(180deg)'}); 1027 $("#icoDownAct_" + iAct).show(); 1028 } 1029 1030 if(retour['msg'].length >0) 1031 alert(retour['msg']); 1032 } 1033 else if (retour['code_erreur'] == 2) 1034 { 1035 var complement = "&nc=" + Math.floor(Math.random() * 1000); 1036 alert(retour['msg']); 1037 document.location.href= mainURL + "bin/index.php?page=vente" + complement; 1038 } 1039 else { 1040 /******************************************************/ 1041 /*************** ERREUR SERVICES ******************/ 1042 /******************************************************/ 1043 console.log("code_erreur SERVICES = " + retour['code_erreur']); 1044 if(retour['msg'].length >=0) 1045 alert(retour['msg']); 1046 1047 if(retour['redirect_url'].length >0) 1048 { 1049 ajaxEnCours = true; 1050 document.location.href = retour['redirect_url']; 1051 } 1052 } 1053 }, 1054 error: function () { 1055 console.log("plantage SERVICES !"); 1056 zoneServices.html('<p><i class="fas fa-exclamation-circle"></i><br>Un problème est survenu lors de la recherche des tarifs.</p>'); 1057 alert("Affichage des tarifs impossibles.\nVeuillez actualiser votre page SVP et nous contacter si le problème persiste."); 1058 } 1059 }); 1060} 1061 1062async function fillModalCalendrier(iAct,type) 1063{ 1064 var Tocken = $("#tokenAct_" + iAct).val(); 1065 var dateCourante = $("#choixDateAct_" + iAct).val(); 1066 var nombre = 0; 1067 1068 if($("#qteAct_" + iAct).length) 1069 { 1070 if($("#qteAct_" + iAct + ":hidden").length) 1071 nombre = 1; 1072 else 1073 nombre = getQteCombo("qteAct_" + iAct); 1074 } 1075 1076 $('#bodyCalendrier').html('<p id="spinCalendar"><i class="faModalSpin fa fa-spinner fa-4x"></i></p>'); 1077 $.ajax({
1078 type: "POST", 1079 async: true, 1080 url: "actliste_ajax_get_calendar.php", 1081 data: {tokenPage: Tocken,i: iAct, date: dateCourante, nbr : nombre}, 1082 dataType: 'html', 1083 success: function(retour) { 1084 //$("#spinCalendar").hide(); 1085 $('#bodyCalendrier').html(retour); 1086 }, 1087 error: function () { 1088 console.log("plantage CALENDRIER !"); 1089 //$("#spinCalendar").hide(); 1090 $('#bodyCalendrier').html('<p class="errorInModal">Affichage du calendrier impossibles.<br>Veuillez actualiser votre page SVP et nous contacter si le problème persiste.</p>'); 1091 } 1092 }); 1093} 1094 1095async function fillModalPanier() 1096{ 1097 $('#bodyPanier').html('<p id="spinPanier"><i class="faModalSpin fa fa-spinner fa-4x"></i></p>'); 1098 $('#footerPanier').html('<button type="button" class="btn btn-primary" data-dismiss="modal">OK</button>'); 1099 $('#divListingPanierMobile').html('<p id="spinPanier"><i class="faModalSpin fa fa-spinner fa-4x"></i></p>'); 1100 $.ajax({
1101 type: "POST", 1102 async: true, 1103 url: "actliste_ajax_get_panier.php", 1104 dataType: 'json', 1105 success: function (retour) { 1106 console.log("retour PANIER..."); 1107 $("#txtPanier").html(retour['txtBouton']); 1108 $("#bodyPanier").html(retour['panier']); 1109 $("#footerPanier").html(retour['checkBoxModal']); 1110 //mobiles 1111 $("#divListingPanierMobile").html(retour['panier']+ retour['checkBoxMobile']); 1112 $("#spanTotPanierMobile").html(retour['total']); 1113 1114 //alert uniquement pour les smartphones 1115 if(retour['msg'].length > 0) 1116 alert(retour['msg']); 1117 if(retour['isPerime'] && retour['longTime']) 1118 { 1119 /******************************************************************/ 1120 /*************** DOSSIER PERIME Page a rafraichir *****************/ 1121 /******************************************************************/ 1122 $('#modalPanier').on('hidden.bs.modal', function (event) { 1123 var complement = "&nc=" + Math.floor(Math.random() * 1000); 1124 var inputCal = $("#inputCalGlobal"); 1125 if(inputCal.val().length == 10) 1126 complement += "&date=" + inputCal.val(); 1127 document.location.href= mainURL + "bin/index.php?page=vente" + complement; 1128 }) 1129 } 1130 }, 1131 error: function (retour) { 1132 var erreurPanier = '<p class="errorInModal"><i class="fas fa-exclamation-circle"></i><br>Un problème est survenu lors de l\'affichage du panier</p>'; 1133 console.log("plantage PANIER !"); 1134 $("#bodyPanier").html(erreurPanier); 1135 $("#footerPanier").html('<button type="button" class="btn btn-primary" data-dismiss="modal">OK</button>'); 1136 $("#divListingPanierMobile").html(erreurPanier); 1137 if($("#menuPanierMobile").is(":visible")) 1138 alert("Affichage du panier impossible.\nVeuillez actualiser votre page SVP et nous contacter si le problème persiste."); 1139 } 1140 }); 1141} 1142/* après un ajout réussi */ 1143function autoAfficherModalPanier() 1144{ 1145 viewportWidth = window.innerWidth; 1146 viewportHeight = window.innerHeight; 1147 if($("#menuPanierMobile").is(":visible")) 1148 { 1149 $(document.body).toggleClass("noscroll"); 1150 $("#ctnMenuPanierMobile").toggleClass("deplierPanier"); 1151 if($("#ctnMenuPanierMobile").hasClass("deplierPanier")) 1152 fillModalPanier(); 1153 } 1154 else 1155 $("#modalPanier").modal('show'); 1156 1157} 1158 1159/**** pas de # devant ****/ 1160function getQteCombo(idCombo) 1161{ 1162 var selectElmt = document.getElementById(idCombo); 1163 var qte = selectElmt.options[selectElmt.selectedIndex].value; 1164 return parseInt(qte,10); 1165} 1166/**calcul des totaux par activité**/ 1167function actualiseTotLigneSrv(e) 1168{ 1169 console.log("actualiseTotLigneSrv"); 1170 var origine = this.name.split("_"); //qteSrv_iAct_iSrv 1171 var iAct = origine[1]; 1172 var iSrv = origine[2]; 1173 var totAct = 0; 1174 var totQteSrv = 0; 1175 var masque = ".qteSrvAct_" + iAct; 1176 var pu = getQteCombo("qteSrv_" + iAct + "_" + iSrv); 1177 var totLigne = parseFloat($("#prixSrv_"+ iAct + "_" + iSrv).text()) * pu; 1178 1179 $(masque).each(function() 1180 { 1181 var idQte = $(this).prop('id'); 1182 totQteSrv += getQteCombo(idQte); 1183 }); 1184 if(totQteSrv > 0) 1185 $("#btnAjouterAct_" + iAct).prop("disabled",false); 1186 /*else 1187 $("#btnAjouterAct_" + iAct).prop("disabled",true);*/ 1188 1189 $("#totSrv_"+ iAct + "_" + iSrv).text(totLigne.toFixed(2)); 1190 1191 masque = ".totSrv_" + iAct; 1192 var totAct = 0; 1193 $(masque).each(function() 1194 { 1195 var unText = $(this).text(); 1196 var unTot = 0; 1197 if(isNaN(unText)) 1198 unTot = 0; 1199 else 1200 unTot = parseFloat(unText); 1201 1202 totAct += unTot; 1203 }); 1204 $("#totAct_"+ iAct).text(totAct.toFixed(2)); 1205} 1206 1207/**calcul des totaux par activité**/ 1208function ctrlActualiseTotLigneSrv(e) 1209{ 1210 console.log("ctrlActualiseTotLigneSrv"); 1211 var origine = this.name.split("_"); //qteSrv_iAct_iSrv 1212 var iAct = origine[1]; 1213 var iSrv = origine[2]; 1214 var masque = "input:radio[name ='slot_" + iAct +"']:checked"; 1215 var slot = $(masque).val(); 1216 if(slot) 1217 { 1218 var reste = parseInt($("#slot_" + iAct + "_" + slot.replace(':','-')).data("reste"),10); 1219 var totQteSrv = 0; 1220 var pu = getQteCombo("qteSrv_" + iAct + "_" + iSrv); 1221 var totLigne = parseFloat($("#prixSrv_"+ iAct + "_" + iSrv).text()) * pu; 1222 var totAct = 0; 1223 1224 masque = ".qteSrvAct_" + iAct; 1225 $(masque).each(function() 1226 { 1227 var idQte = $(this).prop('id');
1228 totQteSrv += getQteCombo(idQte); 1229 }); 1230 1231 if(reste < totQteSrv) 1232 { 1233 var msgAlerte = msgCapDepacee.replace('XXX',totQteSrv); 1234 alert(msgAlerte.replace('YYY',reste)); //capacité dépassée : totQteSrv alors qu'il reste reste 1235 $("#btnAjouterAct_" + iAct).prop("disabled",true); 1236 } 1237 else if(totQteSrv > 0) 1238 $("#btnAjouterAct_" + iAct).prop("disabled",false); 1239 1240 $("#totSrv_"+ iAct + "_" + iSrv).text(totLigne.toFixed(2)); 1241 1242 masque = ".totSrv_" + iAct; 1243 $(masque).each(function() 1244 { 1245 var unText = $(this).text(); 1246 var unTot = 0; 1247 if(isNaN(unText)) 1248 unTot = 0; 1249 else 1250 unTot = parseFloat(unText); 1251 1252 totAct += unTot; 1253 }); 1254 $("#totAct_"+ iAct).text(totAct.toFixed(2)); 1255 } 1256 else 1257 alert("Veuillez sélectionner un slot SVP."); 1258} 1259 1260function verifAjout(iAct) 1261{ 1262 var masque = ".qteSrvAct_" + iAct; 1263 var totQteSrv = 0; 1264 var nombre = 0; 1265 var hasSrvOptionnel = false; 1266 1267 /*activité*/ 1268 if($("#qteAct_" + iAct).length) 1269 { 1270 if($("#qteAct_" + iAct + ":hidden").length) 1271 nombre = 1; 1272 else 1273 nombre = getQteCombo("qteAct_" + iAct); 1274 } 1275 1276 /*service chargement*/ 1277 if($("#qteSrv_" + iAct + "_1").length && $("#qteSrv_" + iAct + "_1").hasClass("inputChargement")) 1278 { 1279 var chargement = $("#qteSrv_" + iAct + "_1").val(); 1280 if(chargement.length == 0) 1281 { 1282 alert("Veuillez choisir un montant à charger SVP."); 1283 return false; 1284 } 1285 return true; 1286 } 1287 1288 /*services*/ 1289 $(masque).each(function() 1290 { 1291 var idQte = $(this).prop('id'); 1292 1293 if(! $(this).parent().closest('div').hasClass("srvOptionnel")) 1294 totQteSrv += getQteCombo(idQte); 1295 else if(getQteCombo(idQte) > 0) 1296 hasSrvOptionnel = true; 1297 1298 }); 1299 1300 if(totQteSrv == 0 && ! hasSrvOptionnel) 1301 { 1302 alert("Veuillez choisir un tarif et une quantité."); 1303 return false; 1304 } 1305 /*if($("#btnAjouterAct_" + iAct).hasClass('disabled') && totQteSrv > 0) 1306 { 1307 alert("Veuillez vérifier les quantités SVP."); 1308 return false; 1309 }*/ 1310 if(nombre > 0 && ! hasSrvOptionnel) { 1311 if (totQteSrv > nombre) { 1312 var difference = totQteSrv - nombre; 1313 alert(msgTropBillets.replace('XXX',difference)); 1314 return false; 1315 } 1316 if (totQteSrv < nombre) { 1317 /*var difference = nombre - totQteSrv;*/ 1318 var alertMessage = msgMoinsBillets.replace('XXX',totQteSrv); 1319 alert(alertMessage.replace('YYY',nombre)); 1320 return false; 1321 } 1322 } 1323 1324 return true; 1325} 1326 1327function actualiseTotReventeSrv(e) 1328{ 1329 //console.log("actualiseTotReventeSrv"); 1330 var origine = this.name.split("_"); //qteSrv_iAct_iSrv 1331 var iAct = origine[1]; 1332 var iSrv = origine[2]; 1333 var totAct = 0; 1334 var masque = ".chkSrvAct_" + iAct; 1335 1336 $(masque).each(function() 1337 { 1338 var idQte = $(this).prop('id'); 1339 var prixSrv = 0; 1340 if($('#' + idQte).is(':checked')) 1341 { 1342 prixSrv = parseFloat($(this).data('prix')); 1343 } 1344 totAct += prixSrv; 1345 }); 1346 if(totAct > 0) 1347 $("#btnAjouterAct_" + iAct).prop("disabled",false); 1348 else 1349 $("#btnAjouterAct_" + iAct).prop("disabled",true); 1350 1351 $("#totAct_"+ iAct).text(totAct.toFixed(2)); 1352} 1353 1354/**************** modal panier *****************/ 1355function do_submit_panier(idFormulaire) { 1356 if ($("#chk_" + idFormulaire).length && ! $("#chk_" + idFormulaire).is(":checked")) 1357 { 1358 alert(msgVerifDatesValidite); 1359 return false; 1360 } 1361 return true; 1362} 1363 1364function do_submit_panier_placement_speed(idFormulaire) { 1365 $("#spinner_" + idFormulaire).show(); 1366 document.getElementById(idFormulaire).value = msgPlacementEnCours; 1367 return true; 1368} 1369 1370function do_submit_panier_placement(idFormulaire) { 1371 if (! $("#chk_" + idFormulaire).is(":checked")) 1372 { 1373 alert(msgVerifDatesValidite); 1374 return false; 1375 } 1376 $("#spinner_" + idFormulaire).show(); 1377 $(idFormulaire).html = msgPlacementEnCours; 1378 return true; 1379} 1380 1381function debSTOP() 1382{ 1383 var debug = true; 1384} 1385 1386function traiteAssurance(addAss) { 1387 1388 if(addAss == 1) 1389 $('#noAss').attr('disabled', true); 1390 else 1391 $('#okAss').attr('disabled', true); 1392 1393 $('#bodyPanier').html('<p id="spinPanier"><i class="faModalSpin fa fa-spinner fa-4x"></i></p>'); 1394 $('#footerPanier').html('<button type="button" class="btn btn-primary" data-dismiss="modal">OK</button>'); 1395 $('#divListingPanierMobile').html('<p id="spinPanier"><i class="faModalSpin fa fa-spinner fa-4x"></i></p>'); 1396 $.ajax({
1397 type: "POST", 1398 async: true, 1399 url: "actliste_ajax_get_panier.php", 1400 dataType: 'json', 1401 success: function (retour) { 1402 console.log("retour PANIER..."); 1403 $("#txtPanier").html(retour['txtBouton']); 1404 $("#bodyPanier").html(retour['panier']); 1405 $("#footerPanier").html(retour['checkBoxModal']); 1406 //mobiles 1407 $("#divListingPanierMobile").html(retour['panier']+ retour['checkBoxMobile']); 1408 $("#spanTotPanierMobile").html(retour['total']); 1409 1410 //alert uniquement pour les smartphones 1411 if(retour['msg'].length > 0) 1412 alert(retour['msg']); 1413 if(retour['isPerime'] && retour['longTime']) 1414 { 1415 /******************************************************************/ 1416 /*************** DOSSIER PERIME Page a rafraichir *****************/ 1417 /******************************************************************/ 1418 $('#modalPanier').on('hidden.bs.modal', function (event) { 1419 var complement = "&nc=" + Math.floor(Math.random() * 1000); 1420 var inputCal = $("#inputCalGlobal"); 1421 if(inputCal.val().length == 10) 1422 complement += "&date=" + inputCal.val(); 1423 document.location.href= mainURL + "bin/index.php?page=vente" + complement; 1424 }) 1425 } 1426 }, 1427 error: function (retour) { 1428 var erreurPanier = '<p class="errorInModal"><i class="fas fa-exclamation-circle"></i><br>Un problème est survenu lors de l\'affichage du panier</p>'; 1429 console.log("plantage PANIER !"); 1430 $("#bodyPanier").html(erreurPanier); 1431 $("#footerPanier").html('<button type="button" class="btn btn-primary" data-dismiss="modal">OK</button>'); 1432 $("#divListingPanierMobile").html(erreurPanier); 1433 if($("#menuPanierMobile").is(":visible")) 1434 alert("Affichage du panier impossible.\nVeuillez actualiser votre page SVP et nous contacter si le problème persiste."); 1435 } 1436 }); 1437} 1438/**menu Langue par Conbo**/ 1439function changeLangue(e) 1440{ 1441 console.log("changeLangue"); 1442 var selectElmt = document.getElementById("lang"); 1443 var newLangue = selectElmt.options[selectElmt.selectedIndex].value; 1444 document.location.href= mainURL + "bin/index.php?code_langue=" + newLangue; 1445} 1446
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.