1 2function _typeof(obj) { if (typeof Symbol === "function" && typeof Symbol.iterator === "symbol") { _typeof = function _typeof(obj) { return typeof obj; }; } else { _typeof = function _typeof(obj) { return obj && typeof Symbol === "function" && obj.constructor === Symbol && obj !== Symbol.prototype ? "symbol" : typeof obj; }; } return _typeof(obj); } 3 4jQuery(document).ready(function ($) { 5 $is_booking_end_date_clicked = false; 6 $is_booking_end_date_calendar_open = false; 7 $ph_date_from_previous_value = ''; 8 9 function generate_booking_info_text(from, to, cost, custom_messages, result) { 10 $('.display_time_from').val(from); 11 $('.display_time_to').val(to); 12 if ($('#calender_type').val() == 'date' && $('#charge_per_night').length && $('#charge_per_night').val() == 'yes') { 13 from_text = phive_booking_ajax.checkin; 14 to_text = phive_booking_ajax.checkout; 15 } else { 16 from_text = phive_booking_ajax.booking; 17 to_text = phive_booking_ajax.to; 18 } 19 if (from !== to && phive_booking_ajax.display_end_time) 20 { 21 // ticket 104504 safari and IE not support all date format. 22 var isSafari = /constructor/i.test(window.HTMLElement) || (function (p) { return p.toString() === "[object SafariRemoteNotification]"; })(!window['safari'] || (typeof safari !== 'undefined' && safari.pushNotification)); 23 var isIE = /*@cc_on!@*/false || !!document.documentMode; 24 if(isSafari || isIE) 25 { 26 date_and_time_from = result.org_from_date.split(" "); 27 date_form = date_and_time_from[0].split("-"); 28 new_date_from = date_form[1] + "/" + date_form[2] + "/" +date_form[0] + " " + date_and_time_from[1]; 29 30 date_and_time_to = result.org_to_date.split(" "); 31 date_to = date_and_time_to[0].split("-"); 32 new_date_to = date_to[1] + "/" + date_to[2] + "/" +date_to[0]+ " "+ date_and_time_to[1]; 33 34 from_date = new Date(new_date_from); 35 to_date = new Date(new_date_to); 36 } 37 else 38 { 39 from_date = new Date(result.org_from_date); 40 to_date = new Date(result.org_to_date); 41 } 42 if ($('#calender_type').val() != 'date' && $('#calender_type').val() != 'month' && from_date.getMonth() == to_date.getMonth() && from_date.getFullYear() == to_date.getFullYear() && from_date.getDate() == to_date.getDate()) { 43 var wp_date_format = jQuery("#ph_booking_wp_time_format").val(); 44 var hours = to_date.getHours(); 45 var ampm = hours >= 12 ? phive_booking_ajax.am_pm_to_text['pm']: phive_booking_ajax.am_pm_to_text['am']; 46 to_time = ph_convert_time_to_wp_time_format(wp_date_format, to_date, ampm); 47 date_html = "<b>" + from_text + ":</b> " + from + " <b>" + to_text + "</b> " + to_time; 48 } 49 else { 50 date_html = "<b>" + from_text + ":</b> " + from + " <b>" + to_text + "</b> " + to; 51 } 52 53 } else { 54 date_html = "<b>" + phive_booking_ajax.booking + ":</b> " + from; 55 } //for Addon 56 57 jQuery('.from_text').val(from_text); 58 jQuery('.to_text').val(to_text).trigger('change'); 59 if (custom_messages == '') 60 return '<p id="booking_info_text">' + date_html + '</p> <p id="booking_price_text"> <b>' + phive_booking_ajax.booking_cost + ': </b>' + cost + '</p>'; 61 else 62 return '<p id="booking_info_text">' + date_html + '</p> <p id="booking_price_text"> <b>' + phive_booking_ajax.booking_cost + ': </b>' + cost + '</p> <p id="booking_custom_text"> ' + custom_messages + '</p>'; 63 64 } 65 function timezoneOffset(date_string) { 66 // passing default parameter value doesn't work in safari 67 if (date_string === undefined || !date_string) { 68 date_string = ''; 69 } 70 let date = new Date(date_string), 71 timezoneOffset = date.getTimezoneOffset(), 72 hours = ('00' + Math.floor(Math.abs(timezoneOffset / 60))).slice(-2), 73 minutes = ('00' + Math.abs(timezoneOffset % 60)).slice(-2), 74 string = (timezoneOffset >= 0 ? '-' : '+') + hours + ':' + minutes; 75 return string; 76 } 77 78 function ph_convert_date_to_wp_date_format(wp_format, date) { 79 80 months = ["January", "February", "March", "April", "May", "June", "July", "August", "September", "October", "
80November", "December"]; 81 new_date = new Date(date + 'T' + '00:00' + timezoneOffset(date)); 82 83 month = ("0" + (new_date.getMonth() + 1)).slice(-2); 84 date = ("0" + new_date.getDate()).slice(-2); 85 86 switch (wp_format) { 87 case 'j F Y': display_date = date + ' ' + phive_booking_ajax.months[new_date.getMonth()] + ' ' + new_date.getFullYear(); 88 break; 89 case 'F j, Y': display_date = phive_booking_ajax.months[new_date.getMonth()] + ' ' + date + ', ' + new_date.getFullYear(); 90 break; 91 case 'Y-m-d': display_date = new_date.getFullYear() + '-' + month + '-' + date; 92 break; 93 case 'm/d/Y': display_date = month + '/' + date + '/' + new_date.getFullYear(); 94 break; 95 case 'd/m/Y': display_date = date + '/' + month + '/' + new_date.getFullYear(); 96 break; 97 case 'd.m.Y': display_date = date + '.' + month + '.' + new_date.getFullYear(); 98 break; 99 case 'm.d.Y': display_date = month + '.' + date + '.' + new_date.getFullYear(); 100 break; 101 default: display_date = new_date.getFullYear() + '-' + month + '-' + date; 102 break; 103 104 } 105 return display_date; 106 } 107 108 function ph_convert_time_to_wp_time_format(wp_format, date, am_pm) { 109 var hours = date.getHours(); 110 var minutes = date.getMinutes(); 111 wp_format = wp_format + ""; 112 switch (wp_format) { 113 case "g:i a": 114 case "g:ia": 115 case "g:i A": 116 case "g:iA": 117 hours = hours % 12; 118 hours = hours ? hours : 12; // the hour '0' should be '12' 119 minutes = minutes < 10 ? '0' + minutes : minutes; 120 121 // Determine if format is lowercase or uppercase 122 let isUpperCase = wp_format === "g:i A" || wp_format === "g:iA"; 123 let space = (wp_format === "g:i a" || wp_format === "g:i A") ? ' ' : ''; 124 125 display_time = hours + ':' + minutes + space + (isUpperCase ? am_pm.toUpperCase() : am_pm.toLowerCase()); 126 break; 127 case "H:i": 128 hours = hours.toString().padStart(2, 0); 129 minutes = minutes.toString().padStart(2, 0); 130 display_time = hours + ':' + minutes; 131 break; 132 case "G \\h i \\m\\i\\n": 133 display_time = hours + ' h ' + minutes + ' min'; 134 break; 135 case "G\\hi": // 151305 136 minutes = minutes.toString().padStart(2, 0); 137 display_time = hours + 'h' + minutes; 138 break; 139 case "G:i": 140 minutes = minutes < 10 ? '0' + minutes : minutes; 141 display_time = hours + ':' + minutes; 142 break; 143 case "G.i": 144 minutes = minutes < 10 ? '0' + minutes : minutes; 145 display_time = hours + '.' + minutes; 146 break; 147 default: 148 hours = hours % 12; 149 hours = hours ? hours : 12; // the hour '0' should be '12' 150 minutes = minutes < 10 ? '0' + minutes : minutes; 151 display_time = hours + ':' + minutes + ' ' + am_pm.toUpperCase(); 152 break; 153 154 } 155 return display_time; 156 } 157 function resetSelection(fullReset) { 158 fullReset = fullReset || 'yes'; 159 date_from = ''; 160 date_to = ''; 161 click = 0; 162 $(".single_add_to_cart_button").addClass("disabled"); 163 $(".selected-date").each(function () { 164 $(this).removeClass("selected-date"); 165 }); 166 167 168 $(".ph-date-from").val(""); 169 $(".ph-date-to").val(""); 170 $('.element_from').val(""); 171 $('.element_to').val(""); 172 $('.element_from_date').val(""); 173 $('.element_from_time').val(""); 174 $('.element_to_date').val(""); 175 $('.element_to_time').val(""); 176 $('#ph_selected_blocks').val(''); 177 178 if (fullReset == 'yes') { 179 $(".booking-info-wraper").html(""); 180 } 181 182 if ($(".not-startable").length) { 183 $(".not-startable").removeClass("hide-not-startable"); 184 } 185 } 186 /*function formate_date( input_date ){ 187 var date = new Date( input_date.replace(/-/g, "/") ); //Safari bowser will accept only with seprator '/' 188 189 var month = ["Jan", "Feb", "Mar", "Apr", "May", "Jun", 190 "Jul", "Aug", "Sep", "Oct", "Nov", "Dec"][date.getMonth()]; 191 var strDate = date.getDate() + '-' + month + '-' + date.getFullYear(); 192 if( $("#calender_type").val() =='time' ){ 193 strDate += " ";
194 strDate += date.getHours()<10 ? "0"+date.getHours() : date.getHours(); 195 strDate += ":" 196 strDate += date.getMinutes()<10 ? "0"+date.getMinutes() : date.getMinutes(); 197 } 198 return strDate; 199 }*/ 200 // Calculate the booking price. 201 202 203 jQuery(document).on('change', ".ph-date-to", function () { 204 calculate_booking_price(); 205 }); 206 207 // #104395 - For input type number, price should re-calculate on change 208 jQuery(document).on('change', ".addon,.wc-pao-addon-field,.ph-addons:not(.phive-addon-textbox):not(.phive-addon-textarea), input.ph-addons.phive-addon-textbox[type=number]", function () 209 { 210 from = jQuery(".ph-date-from").val(); 211 212 if (from != '') { 213 calculate_booking_price(); 214 } 215 }); 216 217 //update price on image select - wc product addons 218 jQuery(document).on('click', ".wc-pao-addon-image-swatch", function () { 219 from = jQuery(".ph-date-from").val(); 220 if (from != '') { 221 calculate_booking_price(); 222 } 223 }); 224 225 // update price on keyup - product addons 226 jQuery(document).on('keyup', ".ph-addons.phive-addon-textbox, .ph-addons.phive-addon-textarea", function () { 227 from = jQuery(".ph-date-from").val(); 228 if(jQuery(this).attr('data-price')) 229 { 230 data_price = parseInt(jQuery(this).attr('data-price')); 231 if(data_price == 0) 232 { 233 return true; 234 } 235 } 236 237 if (from != '') { 238 calculate_booking_price(); 239 } 240 }); 241 242 function calculate_booking_price() { 243 if ($('.input-disabled').length || !jQuery(".ph-date-from").length) { 244 return; 245 } 246 247 $(".shipping-price-related").addClass('input-disabled'); 248 $(".shipping-price-related").attr("disabled", true); 249 250 //171254 Issue: Customer is using WooCommerce Product Add-ons plugin along with our Bookings plugin. When selecting the add-ons quickly the cost is not getting added. 251 $(".ph-addon-container").css({'pointer-events':'none','cursor':'not-allowed','opacity':'0.4'}); 252 $(".wc-pao-addon-container").css({'pointer-events':'none','cursor':'not-allowed','opacity':'0.4'}); 253 254 var loding_ico_url = $("#plugin_dir_url").val() + "/resources/icons/loading2.gif"; 255 256 $(".booking-info-wraper").html('<img class="loading-ico" align="middle" src="' + loding_ico_url + '">'); 257 $(".single_add_to_cart_button").addClass("disabled"); 258 var from = jQuery(".ph-date-from").val(); 259 var to = jQuery(".ph-date-to").val(); 260 var person_details = []; 261 $('.input-person').each(function () { 262 if ($(this).val() != '') person_details.push(parseInt($(this).val())); else person_details.push(0); 263 }); // for range values select min available slot 264 265 var available_slots = $('.selected-date').map(function () { 266 var attr = $(this).attr('data-title'); 267 268 if (_typeof(attr) !== (typeof undefined === "undefined" ? "undefined" : _typeof(undefined)) && attr !== false) { 269 return parseInt($(this).attr('data-title')); 270 } else { 271 if ($(this).text() == '' || ($(".selected-date").last().find('.callender-full-date').val() == $(this).find('.callender-full-date').val() && $('#charge_per_night').val() == 'yes')) return; // If try to book between months or per night booking and Consider each participant as booking is marked 272 return 0; 273 } 274 }).get(); 275 var available_slot = Math.min.apply(Math, available_slots); // for range values select min available slot 276 277 // 150854 - unable to choose the same day (check-in day for other bookings) as check-out day for other bookings when assigning participants. 278 if($('#charge_per_night').val() == 'yes' && $('.book_interval_period').val() == 'day') 279 { 280 available_slots = $('.selected-date:not(:last)').map(function () { 281 attr = $(this).attr('data-title'); 282 283 if (_typeof(attr) !== (typeof undefined === "undefined" ? "undefined" : _typeof(undefined)) && attr !== false) { 284 return parseInt($(this).attr('data-title')); 285 } else { 286 if ($(this).text() == '' || ($(".selected-date").last().find('.callender-full-date').val() == $(this).find('.callender-full-date').val() && $('#charge_per_night').val() == 'yes')) return; // If try to book between months or per night booking and Consider each participant as booking is marked 287 return 0; 288 } 289 }).get(); 290 available_slot = Math.min.apply(Math, available_slots); 291 } 292 293 var available_slots_to_displays = $('.selected-date').map(function () { 294 var attr = $(this).attr('data-max'); 295 296 if (_typeof(attr) !== (typeof undefined === "undefined" ? "undefined" : _typeof(undefined)) && attr !== false) { 297 return parseInt($(this).attr('data-max')); 298 } else { 299 if ($(this).text() == '') return; // If try to book between months and Consider each participant as booking is marked 300 301 return 0; 302 } 303 }).get(); 304 var available_slots_to_display = Math.min.apply(Math, available_slots_to_displays); 305 var persons_as_booking = $('#persons_as_booking').val(); 306 307 if (persons_as_booking == 'yes') { 308 person_details_count = person_details.reduce(function (a, b) { 309 return a + b; 310 }, 0); 311 312 if (person_details_count > available_slot) { 313 var message = phive_booking_ajax.available_slot_message; 314 message = message.replace('%available_slot', available_slots_to_display); 315 $('.booking-info-wraper').html('<p id="booking_info_text"><span class="not-available-msg">' + message + '</span></p>'); 316 $(".shipping-price-related").removeClass('input-disabled'); 317 $(".shipping-price-related").removeAttr("disabled"); 318 // /171254 319 $(".ph-addon-container").css({'pointer-events':'initial','cursor':'initial','opacity':'initial'}); 320 $(".wc-pao-addon-container").css({'pointer-events':'initial','cursor':'initial','opacity':'initial'}); 321 return false;
322 } 323 324 // 144645 - Issue with Max Bookings per Block & Participant as booking when choosing multiple dates. 325 selected_dates_mna = $('.select-random-dates-html-div .select_random_dates_from'); 326 if (selected_dates_mna.length) 327 { 328 var available_slots_mna = $(selected_dates_mna).map(function () { 329 var attr = $(this).attr('data-title'); 330 if (_typeof(attr) !== (typeof undefined === "undefined" ? "undefined" : _typeof(undefined)) && attr !== false) { 331 return parseInt($(this).attr('data-title')); 332 } else { 333 return 0; 334 } 335 }).get(); 336 var available_slot_mna = Math.min.apply(Math, available_slots_mna); // for range values select min available slot 337 338 var available_slots_to_displays_mna = $(selected_dates_mna).map(function () { 339 var attr = $(this).attr('data-max'); 340 341 if (_typeof(attr) !== (typeof undefined === "undefined" ? "undefined" : _typeof(undefined)) && attr !== false) { 342 return parseInt($(this).attr('data-max')); 343 } else { 344 if ($(this).text() == '') return; // If try to book between months and Consider each participant as booking is marked 345 346 return 0; 347 } 348 }).get(); 349 var available_slots_to_display_mna = Math.min.apply(Math, available_slots_to_displays_mna); 350 351 if (person_details_count > available_slot_mna) 352 { 353 var message = phive_booking_ajax.available_slot_message; 354 message = message.replace('%available_slot', available_slots_to_display_mna); 355 $('.booking-info-wraper').html('<p id="booking_info_text"><span class="not-available-msg">' + message + '</span></p>'); 356 $(".shipping-price-related").removeClass('input-disabled'); 357 $(".shipping-price-related").removeAttr("disabled"); 358 // /171254 359 $(".ph-addon-container").css({'pointer-events':'initial','cursor':'initial','opacity':'initial'}); 360 $(".wc-pao-addon-container").css({'pointer-events':'initial','cursor':'initial','opacity':'initial'}); 361 return false; 362 } 363 } 364 // 144645 END 365 } 366 367 var total_numer_persons = 0; 368 $('.input-person').each(function () { 369 // total_numer_persons += parseInt($(this).val()); 370 Number.isInteger = Number.isInteger || function (value) { 371 return typeof value === 'number' && 372 isFinite(value) && 373 Math.floor(value) === value; 374 }; 375 if (Number.isInteger(parseInt($(this).val()))) { 376 total_numer_persons += parseInt($(this).val()); 377 } 378 }); 379 380 // #105168 - maximum participant should work even if consider each participant as separate booking is active. 381 if (total_numer_persons > parseInt($('#phive_booking_maximum_number_of_allowed_participant').val()) && parseInt($('#phive_booking_maximum_number_of_allowed_participant').val()) != 'NaN') { 382 var message = phive_booking_ajax.maximum_participant_warning; 383 message = message.replace('%total', total_numer_persons); 384 message = message.replace('%max', parseInt($('#phive_booking_maximum_number_of_allowed_participant').val())); 385 $('.booking-info-wraper').html('<p id="booking_info_text"><span class="not-available-msg">' + message + '</span></p>'); 386 $(".shipping-price-related").removeClass('input-disabled'); 387 $(".shipping-price-related").removeAttr("disabled"); 388 // /171254 389 $(".ph-addon-container").css({'pointer-events':'initial','cursor':'initial','opacity':'initial'}); 390 $(".wc-pao-addon-container").css({'pointer-events':'initial','cursor':'initial','opacity':'initial'}); 391 if ($('.ph_booking_info_wrapper_error').length) { 392 $('.ph_booking_info_wrapper_error').trigger('click'); 393 } return false; 394 } 395 396 // if (persons_as_booking != 'yes' && total_numer_persons < parseInt($ 397 if (total_numer_persons < parseInt($('#phive_booking_minimum_number_of_required_participant').val()) && parseInt($('#phive_booking_minimum_number_of_required_participant').val()) != 'NaN') { 398 var message = phive_booking_ajax.minimum_participant_warning; 399 // message = message.replace('%total', total_numer_persons); 400 message = message.replace('%min', parseInt($('#phive_booking_minimum_number_of_required_participant').val())); 401 $('.booking-info-wraper').html('<p id="booking_info_text"><span class="not-available-msg">' + message + '</span></p>'); 402 $(".shipping-price-related").removeClass('input-disabled'); 403 $(".shipping-price-related").removeAttr("disabled"); 404 // /171254 405 $(".ph-addon-container").css({'pointer-events':'initial','cursor':'initial','opacity':'initial'}); 406 $(".wc-pao-addon-container").css({'pointer-events':'initial','cursor':'initial','opacity':'initial'}); 407 408 if ($('.ph_booking_info_wrapper_error').length) { 409 $('.ph_booking_info_wrapper_error').trigger('click'); 410 } 411 return false;
412 } 413 414 resources_type = $('.resources_type').val(); 415 if (resources_type == 'single') { 416 resources_details = []; 417 selected_resources = $('.phive_book_resources').val(); 418 $(".phive_book_resources option").each(function (i) { 419 if ($(this).val() == '') 420 return true; 421 val = 'no'; 422 if (selected_resources == $(this).val()) { 423 val = 'yes'; 424 } 425 426 // Checking id to support hide Resource 427 let id = $(this).attr('id'); 428 429 let resourceId = id.replace('phive_book_resources_', ''); 430 431 resources_details[resourceId] = val; 432 }); 433 } 434 else { 435 resources_details = []; 436 $('.input-resources').each(function () { 437 val = $(this).is(":checked") ? 'yes' : 'no'; 438 439 // Checking id to support hide Resource 440 let id = $(this).attr('id'); 441 442 let resourceId = id.replace('phive_book_resources_', ''); 443 444 resources_details[resourceId] = val; 445 }); 446 } 447 448 product_id = jQuery("#phive_product_id").val(); 449 450 current_product_id = product_id; 451 452 // WPML Compatibility 453 if(jQuery("#product-addons-total")) 454 { 455 current_product_id = jQuery("#product-addons-total").attr('data-product-id'); 456 } 457 458 if (from.length === 0 || to.length === 0) { 459 return; 460 } 461 462 addon_data = jQuery('.addon').serialize(); 463 if (parseInt($(".wc-pao-addon-field").length) > 0) { 464 addon_data = jQuery('.wc-pao-addon-field').serialize(); 465 } 466 467 product_addon_data = ''; 468 if (parseInt($(".phive-addon-field").length) > 0) { 469 product_addon_data = jQuery('.phive-addon-field').serialize(); 470 } 471 custom_time_period = ''; 472 if ($(".cutome_time_period").length > 0) { 473 custom_time_period = $(".cutome_time_period").find(':selected').val(); 474 } 475 476 //PH Product Addons - File upload cost not getting added 477 if(jQuery('input[name^=addon-fileupload-phive_addons_]').length) 478 { 479 product_addon_files = jQuery('input[name^=addon-fileupload-phive_addons_]') 480 if(product_addon_files.length) 481 { 482 for (let index = 0; index < product_addon_files.length; index++) 483 { 484 input_name = $(product_addon_files[index]).attr('name'); 485 files = product_addon_files[index].files; 486 if(files.length) 487 { 488 if(product_addon_data) 489 { 490 product_addon_data += '&'+input_name+'='+files[0].name; 491 } 492 else 493 { 494 product_addon_data += input_name+'='+files[0].name; 495 } 496 } 497 } 498 } 499 } 500 501 //WC Product Addons - File upload cost not getting added 502 if(jQuery('input.wc-pao-addon-file-upload').length) 503 { 504 wc_product_addon_files = jQuery('input.wc-pao-addon-file-upload'); 505 if(wc_product_addon_files.length) 506 { 507 for (let index = 0; index < wc_product_addon_files.length; index++) 508 { 509 input_name = $(wc_product_addon_files[index]).attr('name'); 510 files = wc_product_addon_files[index].files; 511 if(files.length) 512 { 513 if(addon_data) 514 { 515 addon_data += '&'+input_name+'='+files[0].name; 516 } 517 else 518 { 519 addon_data += input_name+'='+files[0].name; 520 } 521 } 522 } 523 } 524 } 525 526 let json_data = $(".ph_custom_fields").val(); 527 528 // Convert the JSON string back to an object 529 let ph_custom_fields_data = json_data ? JSON.parse(json_data) : {}; 530 531 var data = { 532 action: 'phive_get_booked_price', 533 // security : phive_booking_ajax.security, 534 product_id: product_id, 535 book_from: from, 536 book_to: to, 537 person_details: person_details, 538 resources_details: resources_details, 539 addon_data: addon_data, 540 product_addon_data: product_addon_data, 541 asset: $(".input-assets").val(), 542 custom_fields: $(".custom_fields").val(), 543 ph_custom_fields: ph_custom_fields_data, 544 custom_time_period: custom_time_period, 545 current_product_id: current_product_id 546 }; 547 jQuery(".ph-calendar-date").prop('disabled', true); 548 $.post(phive_booking_ajax.ajaxurl, data, function (res) { 549 result = jQuery.parseJSON(res); 550 jQuery(".ph-calendar-date").prop('disabled', false); // Confirm the response of last request. 551 // The price should updated only for last request incase another request send immediately 552 553 $(".shipping-price-related").removeClass('input-disabled'); 554 $(".shipping-price-related").removeAttr("disabled"); 555 // /171254 556 $(".ph-addon-container").css({'pointer-events':'initial','cursor':'initial','opacity':'initial'}); 557 $(".wc-pao-addon-container").css({'pointer-events':'initial','cursor':'initial','opacity':'initial'}); 558 $(".single_add_to_cart_button").removeClass("disabled"); 559 $(".callender-msg").html(''); 560 561 if(result.selected_blocks) { 562 563 $('#ph_selected_blocks').val(result.selected_blocks); 564 } else { 565 566 $('#ph_selected_blocks').val(''); 567 } 568 569 if (result.error_msg) { 570 if ($('#calendar_design').val() != '3') { 571 resetSelection(); 572 } 573 $('.booking-info-wraper').html(result.error_msg); 574 // $("#phive_booked_price").val(''); 575 $(".phive_booked_price").val(''); 576 // $(".phive_book_assets").val(asset); 577 $(".single_add_to_cart_button").addClass("disabled"); 578 } else { 579 if (to != '') { 580 var to_date_obj = new Date(to); 581 var from_date_obj = new Date(from); 582 583 //support for customise booking interval addon 584 if(custom_time_period && result.org_to_date_customise_booking_interval) 585 { 586 if(result.org_to_date_customise_booking_interval != '') 587 { 588 $('.ph-date-to').val(result.org_to_date_customise_booking_interval); 589 } 590 } 591 592 if (from_date_obj.getTime() > to_date_obj.getTime()) { 593 resetSelection(); 594 $('.booking-info-wraper').html('<p id="booking_info_text"><span class="not-available-msg">Booking start date cannot be higher than end date.</span></p>'); 595 // $("#phive_booked_price").val(''); 596 $(".phive_booked_price").val(''); 597 $(".phive_book_assets").val(''); 598 } else { 599 // $(".price").html( result.price_html ); //to change the main product price 600 // $("#phive_booked_price").val(result.price); 601 $(".phive_booked_price").val(result.price); 602 $(".phive_book_assets").val(result.asset_id); //in the case of monthpicker, take last date of 'TO' month 603 var custom_messages = ''; 604 if (result.custom_messages) { 605 custom_messages = result.custom_messages; 606 } 607 608 if (result.product_addon_data) { 609 $(".ph_booking_product_addon_data").val(result.product_addon_data); 610 }else{ 611 $(".ph_booking_product_addon_data").val(''); 612 } 613 614 if (result.addon_data) { 615 $(".ph_booking_addon_data").val(result.addon_data); 616 617 let json_data = JSON.stringify(result.ph_addon_data); 618 619 $(".ph_addon_data").val(json_data); 620 } 621 /*if( (to.match(new RegExp("-", "g")) || []).length < 2 ){ 622 var date = new Date( to.replace(/-/g, "/") ); //Safari bowser will accept only with separator '/' 623 var LastDay = new Date(date.getFullYear(), date.getMonth() + 1, 0); 624 to = to+"-"+LastDay.getDate(); 625 }*/ 626 627 booking_info_text = generate_booking_info_text(result.from_date, result.to_date, result.price_html, custom_messages, result); 628 $('.booking-info-wraper').html(booking_info_text).trigger('change'); 629 630 // 213065 When the resource is mandatory and not selected any option book now button should be disabled 631 if (resources_type == 'single' && $('.phive_book_resources_required').length && $('.phive_book_resources').val() == '') { 632 633 $(".single_add_to_cart_button").addClass("disabled"); 634 } 635 } 636 } 637 } 638 }); 639 } 640 641 // $('.time-picker-wraper #ph-calendar-days').on("click", ".ph-calendar-date", function () { 642 $(document).on("click", ".time-picker-wraper .ph-ul-date .ph-calendar-date", function () { 643 644 if ($(this).hasClass("booking-disabled") || 645 $(this).hasClass("de-active") || 646 $(this).hasClass("not-available")) {
647 // Do nothing and stop the event if the slot is not available 648 return false; 649 } 650 651 var from = jQuery(".ph-date-from").val(); 652 var element_from_date = $('.element_from_date').val() 653 var to = jQuery(".ph-date-to").val(); 654 655 var loding_ico_url = $("#plugin_dir_url").val() + "/resources/icons/loading2.gif"; 656 $(".ph-ul-time").show(); 657 // $("#ph-calendar-time").html('<img class="loading-ico" align="middle" src="' + loding_ico_url + '">'); 658 $(".ph-ul-time").html('<img class="loading-ico" align="middle" src="' + loding_ico_url + '">'); 659 var product_id = jQuery("#phive_product_id").val(); 660 661 if ($is_booking_end_date_calendar_open && from != '') { 662 // When user clicks a To Date in Design 3 with all fields filled 663 $(".ph-calendar-overlay").show(); 664 from_date = convert_date_to_wp_format($('.timepicker-selected-date .callender-full-date').val()); 665 $('.element_to_date').val(from_date); 666 $is_booking_end_date_clicked = true; 667 $('.element_to_time').val(''); 668 } 669 else if ($is_booking_end_date_calendar_open && from == '') { 670 // When user clicks a To Date in Design 3 and the previous selection was invalid 671 $(".ph-date-from").val($ph_date_from_previous_value); 672 $(".ph-calendar-overlay").show(); 673 $is_booking_end_date_clicked = true; 674 $('.element_to_date').val(''); 675 $('.element_to_time').val(''); 676 var current_date = convert_date_to_wp_format($('.timepicker-selected-date .callender-full-date').val()); 677 $(".element_to_date").val(current_date); 678 $('.element_to_time').trigger('click'); 679 $('.element_to_time').focus(); 680 } 681 else if (from == '' || (from != '' && to != '')) { 682 $(".ph-calendar-overlay").show(); 683 from_date = convert_date_to_wp_format($('.timepicker-selected-date .callender-full-date').val()); 684 $('.element_from_date').val(from_date).change(); 685 $('.element_from_time').val(''); 686 $('.element_from_time').scrollTop(); 687 $('.element_from_time').trigger('click'); 688 $('.element_from_time').focus(); 689 $('.element_to_date').val(''); 690 $('.element_to_time').val(''); 691 } else { 692 $(".ph-calendar-overlay").show(); 693 to_date = convert_date_to_wp_format($('.timepicker-selected-date .callender-full-date').val()); 694 $('.element_to_date').val(to_date); 695 $('.element_to_time').val(''); 696 $('.element_to_time').scrollTop(); 697 $('.element_to_time').trigger('click'); 698 $('.element_to_time').focus(); 699 } 700 701 // custom booking interval addon supprt 702 custom_time_period = ''; 703 if ($(".cutome_time_period").length > 0) { 704 custom_time_period = $(".cutome_time_period").find(':selected').val(); 705 } 706 707 var data = { 708 action: 'phive_get_booked_datas_of_date', 709 product_id: product_id, 710 date: $('.timepicker-selected-date .callender-full-date').val(), 711 type: 'time-picker', 712 asset: $(".input-assets").val(), 713 custom_time_period:custom_time_period, 714 lang: phive_booking_locale.current_lang, // Current language in case of WPML or Polylang compatibility. 715 }; 716 // $is_booking_end_date_calendar_open = false; 717 718 jQuery(".ph-calendar-date").prop('disabled', true); 719 $.post(phive_booking_ajax.ajaxurl, data, function (res) { 720 721 $(".ph-calendar-overlay").hide(); 722 jQuery(".ph-calendar-date").prop('disabled', false); 723 // $("#ph-calendar-time").html(res).trigger('change'); 724 725 if ($('#calendar_design').val() == '3') { 726 $('.time-calendar-date-section').hide(); 727 $('.ph-calendar-container .time-picker').show(); 728 } 729 $(".ph-ul-time").html(res); 730 // change slot time as end time while showing time calendar for end time 731 if ($('#calendar_design').val() == '3') { 732 // if (from != '' && to == '') { 733 // This was inside IF earlier 734 if ($is_booking_end_date_calendar_open) { 735 $('.ph_calendar_time_start').hide(); 736 $('.ph_calendar_time_end').show(); 737 } 738 } 739 $('#ph-calendar-time').trigger('change'); 740 $(this).addClass("timepicker-selected-date"); 741 742 // 137142 - Point 2 - When using "Auto Select Available Time of the Date" add-on, its not showing "Minimum number of participants required for a booking is (1)" pop-up. 743 if(($(document).find('.ph_auto_select_available_time_of_date_status').length > 0) && 744 ($(document).find('.ph_auto_select_available_time_of_date_status').val() == 'yes') && 745 ($(document).find('.ph-ul-time .ph-calendar-date.selected-date').length > 0)) 746 { 747 return; 748 } 749 750 // 137142 - Point 1 - For Time calendar, as of now there is no pop-up like "Please pick a time" after selecting the Date. 751 $(".booking-info-wraper").html('<p id="booking_info_text" style="text-align:center;">
751'+phive_booking_ajax.pick_a_time+'</p><p id="booking_price_text"> </p>'); 752 $is_booking_end_date_calendar_open = false; 753 }); 754 755 }); 756 757 function convert_date_to_wp_format(date) { 758 var wp_date_format = jQuery("#ph_booking_wp_date_format").val(); 759 date = ph_convert_date_to_wp_date_format(wp_date_format, date); 760 return date; 761 } 762 763 $('.outlook-wrapper').on('click', '#signin_to_outlook', function (e) { 764 e.preventDefault(); 765 766 const clientId = $('#ph-outlook-client-id').val(); 767 const clientSecret = $('#ph-outlook-client-secret').val(); 768 769 const data = { 770 action: 'ph_signin_with_outlook', 771 clientId, 772 clientSecret 773 }; 774 775 $.post(phive_booking_ajax.ajaxurl, data, function (response) { 776 777 if (response?.status === 'success') { 778 const { redirectUrl } = response; 779 window.location.replace(redirectUrl); 780 } 781 }) 782 }); 783 784 // On click of deactivation, make the fields editable to configure new outlook credentials. 785 $('#deactivate_outlook_authorization').on('click', function(e) { 786 e.preventDefault(); 787 788 const data = { 789 action: 'ph_deactivate_outlook_authorization' 790 }; 791 792 $.post(phive_booking_ajax.ajaxurl, data, function (response) { 793 794 if (response?.status === 'success') { 795 location.reload(); 796 } 797 }) 798 }); 799 800 if (jQuery('#outlook_event_filter').length > 0) { 801 802 jQuery('#outlook_event_filter').select2({ 803 width: '50%' 804 }); 805 } 806 807 if (jQuery('#google_cal_event_filter').length > 0) { 808 809 jQuery('#google_cal_event_filter').select2({ 810 width: '50%' 811 }); 812 } 813 814 // Fetch Outlook Calendars 815 $('#ph-fetch-outlook-calendars').on('click', function (e) { 816 817 e.preventDefault(); 818 819 let data = { 820 action: 'ph_get_outlook_calendars', 821 }; 822 823 $.post(phive_booking_ajax.ajaxurl, data, function (response) { 824 825 if (response?.status === 'success') { 826 827 location.reload(); 828 } else { 829 830 alert(response?.message || 'An error occurred. Please try again.'); 831 } 832 }) 833 }); 834 835 // Fetch Google Calendars 836 $('#ph-fetch-google-calendars').on('click', function (e) { 837 838 e.preventDefault(); 839 840 let data = { 841 action: 'ph_get_google_calendars', 842 }; 843 844 $.post(phive_booking_ajax.ajaxurl, data, function (response) { 845 846 if (response?.status === 'success') { 847 848 location.reload(); 849 } else { 850 851 alert(response?.message || 'An error occurred. Please try again.'); 852 } 853 }) 854 }); 855});
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.