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