| @@ -1,7 +1,79 @@ | ||
| 1 | 1 | var start_time_checking_index; |
| 2 | 2 | |
| 3 | 3 | /** |
| 4 | + * Check if the date has only Working Time limits, without real bookings or manually blocked time slots. | |
| 5 | + * | |
| 6 | + * Working Time intervals still have to stay in the booking data for validation and tooltips, | |
| 7 | + * but they should not produce the small dots inside calendar day cells. | |
| 8 | + * | |
| 9 | + * @param {Object} date_bookings_obj | |
| 10 | + * @param {Array} child_resources_arr | |
| 11 | + * @returns {boolean} | |
| 12 | + */ | |
| 13 | +function wpbc_is_date_has_only_working_time_limits_for_dots( date_bookings_obj, child_resources_arr ) { | |
| 14 | + | |
| 15 | + var has_working_time_limits = false; | |
| 16 | + var has_real_time_limits = false; | |
| 17 | + var resource_day_obj; | |
| 18 | + var time_details_obj; | |
| 19 | + var time_details; | |
| 20 | + var source_type; | |
| 21 | + | |
| 22 | + if ( ( ! date_bookings_obj ) || ( null === child_resources_arr ) ) { | |
| 23 | + return false; | |
| 24 | + } | |
| 25 | + | |
| 26 | + if ( | |
| 27 | + ( date_bookings_obj[ 'summary' ] ) | |
| 28 | + && ( date_bookings_obj[ 'summary' ][ 'status_for_bookings' ] ) | |
| 29 | + && ( '' !== date_bookings_obj[ 'summary' ][ 'status_for_bookings' ] ) | |
| 30 | + ) { | |
| 31 | + return false; | |
| 32 | + } | |
| 33 | + | |
| 34 | + for ( var i = 0; i < child_resources_arr.length; i++ ) { | |
| 35 | + | |
| 36 | + resource_day_obj = date_bookings_obj[ child_resources_arr[ i ] ]; | |
| 37 | + | |
| 38 | + if ( ! resource_day_obj ) { | |
| 39 | + continue; | |
| 40 | + } | |
| 41 | + | |
| 42 | + time_details_obj = resource_day_obj[ '__booked__times__details' ]; | |
| 43 | + | |
| 44 | + if ( ! time_details_obj ) { | |
| 45 | + if ( | |
| 46 | + ( resource_day_obj.booked_time_slots ) | |
| 47 | + && ( resource_day_obj.booked_time_slots.merged_seconds ) | |
| 48 | + && ( resource_day_obj.booked_time_slots.merged_seconds.length > 0 ) | |
| 49 | + ) { | |
| 50 | + has_real_time_limits = true; | |
| 51 | + } | |
| 52 | + continue; | |
| 53 | + } | |
| 54 | + | |
| 55 | + for ( var time_key in time_details_obj ) { | |
| 56 | + | |
| 57 | + if ( ! time_details_obj.hasOwnProperty( time_key ) ) { | |
| 58 | + continue; | |
| 59 | + } | |
| 60 | + | |
| 61 | + time_details = time_details_obj[ time_key ]; | |
| 62 | + source_type = ( time_details && ( 'undefined' !== typeof( time_details[ 'source_type' ] ) ) ) ? time_details[ 'source_type' ] : 'booking'; | |
| 63 | + | |
| 64 | + if ( 'working_time' === source_type ) { | |
| 65 | + has_working_time_limits = true; | |
| 66 | + } else { | |
| 67 | + has_real_time_limits = true; | |
| 68 | + } | |
| 69 | + } | |
| 70 | + } | |
| 71 | + | |
| 72 | + return ( has_working_time_limits && ! has_real_time_limits ); | |
| 73 | +} | |
| 74 | + | |
| 75 | +/** | |
| 4 | 76 | * Get dots for partially booked dates. |
| 5 | 77 | * For parent booking resources with specific capacity, |
| 6 | 78 | * System do not show partially booked dates, if at least one child booking resource fully available |
| 7 | 79 | * Otherwise it show maximum number of time-slot in one specific child booking resource |
| @@ -24,9 +96,14 @@ | ||
| 24 | 96 | var child_resources_arr = wpbc_clone_obj(_wpbc.booking__get_param_value(resource_id, 'resources_id_arr__in_dates')); |
| 25 | 97 | |
| 26 | 98 | // '2023-08-21' |
| 27 | 99 | var sql_date = wpbc__get__sql_class_date(new Date(my_thisDateTime)); |
| 100 | + var date_bookings_obj = _wpbc.bookings_in_calendar__get_for_date(resource_id, sql_date); | |
| 28 | 101 | |
| 102 | + if ( wpbc_is_date_has_only_working_time_limits_for_dots( date_bookings_obj, child_resources_arr ) ) { | |
| 103 | + return ''; | |
| 104 | + } | |
| 105 | + | |
| 29 | 106 | var child_resource_id; |
| 30 | 107 | var merged_seconds; |
| 31 | 108 | var dots_count = 0; |
| 32 | 109 | |
| @@ -38,10 +115,10 @@ | ||
| 38 | 115 | |
| 39 | 116 | // _wpbc.bookings_in_calendar__get_for_date(2,'2023-08-21')[12].booked_time_slots.merged_seconds = [ "07:00:11 - 07:30:02", "10:00:11 - 00:00:00" ] |
| 40 | 117 | // _wpbc.bookings_in_calendar__get_for_date(2,'2023-08-21')[2].booked_time_slots.merged_seconds = [ [ 25211, 27002 ], [ 36011, 86400 ] ] |
| 41 | 118 | |
| 42 | - if (false !== _wpbc.bookings_in_calendar__get_for_date(resource_id, sql_date)) { | |
| 43 | - merged_seconds = _wpbc.bookings_in_calendar__get_for_date(resource_id, sql_date)[child_resource_id].booked_time_slots.merged_seconds; // [ [ 25211, 27002 ], [ 36011, 86400 ] ] | |
| 119 | + if (false !== date_bookings_obj) { | |
| 120 | + merged_seconds = date_bookings_obj[child_resource_id].booked_time_slots.merged_seconds; // [ [ 25211, 27002 ], [ 36011, 86400 ] ] | |
| 44 | 121 | } else { |
| 45 | 122 | merged_seconds = []; |
| 46 | 123 | } |
| 47 | 124 | |
| @@ -247,8 +324,21 @@ | ||
| 247 | 324 | * @returns {boolean} True if selected date/time is in the past, otherwise false. |
| 248 | 325 | */ |
| 249 | 326 | function wpbc_is_time_in_the_past_for_today(myTime, sort_date_array, resource_id) { |
| 250 | 327 | |
| 328 | + var allow_past_context = _wpbc.get_other_param( 'this_page_allow_past' ); | |
| 329 | + var edit_booking_hash_context = _wpbc.get_other_param( 'this_page_booking_hash' ); | |
| 330 | + if ( | |
| 331 | + ( '1' === String( allow_past_context ) ) | |
| 332 | + || ( 1 === allow_past_context ) | |
| 333 | + || ( true === allow_past_context ) | |
| 334 | + || ( '' !== String( edit_booking_hash_context || '' ) ) | |
| 335 | + || ( location.href.indexOf( 'booking_hash' ) > -1 ) | |
| 336 | + || ( location.href.indexOf( 'allow_past' ) > -1 ) | |
| 337 | + ) { | |
| 338 | + return false; | |
| 339 | + } | |
| 340 | + | |
| 251 | 341 | // FixIn: 10.14.10.2. |
| 252 | 342 | if ( true === wpbc_is_change_over_enabled_for_resource( resource_id ) ) { |
| 253 | 343 | return false; |
| 254 | 344 | } |
| @@ -377,8 +467,12 @@ | ||
| 377 | 467 | if ( jQuery( element ).closest( '.booking_form_garbage' ).length ){ // FixIn: 7.1.2.14. |
| 378 | 468 | continue; |
| 379 | 469 | } |
| 380 | 470 | |
| 471 | + if ( '1' === String( jQuery( element ).attr( 'data-wpbc-booking-submit-ignore' ) || '' ) ) { | |
| 472 | + continue; | |
| 473 | + } | |
| 474 | + | |
| 381 | 475 | if ( |
| 382 | 476 | ( element.name != undefined ) |
| 383 | 477 | && ( element.name.indexOf( 'hint' ) === -1 ) //FixIn: 9.5.5.2 // FixIn: 9.6.3.9. |
| 384 | 478 | ){ |
| @@ -384,9 +478,9 @@ | ||
| 384 | 478 | ){ |
| 385 | 479 | var my_element = element.name; //.toString(); |
| 386 | 480 | if ( my_element.indexOf( 'rangetime' ) !== -1 ){ // Range Time |
| 387 | 481 | if ( element.value == '' ){ //FixIn: 7.0.Beta.19 |
| 388 | - var notice_message_id = wpbc_front_end__show_message__warning( element, _wpbc.get_message( 'message_check_required' ) ); | |
| 482 | + var notice_message_id = wpbc_front_end__show_message__warning( element, _wpbc.get_message( 'message_check_required' ), 'text' ); | |
| 389 | 483 | return true; |
| 390 | 484 | } |
| 391 | 485 | var my_rangetime = element.value.split( '-' ); |
| 392 | 486 | if ( my_rangetime.length > 1 ){ |
| @@ -466,14 +560,14 @@ | ||
| 466 | 560 | |
| 467 | 561 | if ( valid_time !== true ){ |
| 468 | 562 | //return false; // do not show warning for setting pending days selectable, if making booking for time-slot // FixIn: 7.0.1.23. |
| 469 | 563 | if ( ( wpbc_is_change_over_enabled_for_resource( resource_id ) ) && (element_start !== false) && (element_end !== false) ){ // FixIn: 6.1.1.1. |
| 470 | - wpbc_front_end__show_message__warning_under_element( '#date_booking' + resource_id, _wpbc.get_message( 'message_check_no_selected_dates' ) ); | |
| 564 | + wpbc_front_end__show_message__warning( '#booking_form_div' + resource_id + ' .bk_calendar_frame', _wpbc.get_message( 'message_check_no_selected_dates' ), 'text' ); | |
| 471 | 565 | } |
| 472 | - if ( element_rangetime !== false ){ wpbc_front_end__show_message__warning_under_element( element_rangetime, _wpbc.get_message( 'message_error_range_time' ) ); } | |
| 473 | - if ( element_duration !== false ){ wpbc_front_end__show_message__warning_under_element( element_duration, _wpbc.get_message( 'message_error_duration_time' ) ); } | |
| 474 | - if ( element_start !== false ){ wpbc_front_end__show_message__warning_under_element( element_start, _wpbc.get_message( 'message_error_start_time' ) ); } | |
| 475 | - if ( element_end !== false ){ wpbc_front_end__show_message__warning_under_element( element_end, _wpbc.get_message( 'message_error_end_time' ) ); } | |
| 566 | + if ( element_rangetime !== false ){ wpbc_front_end__show_message__warning_under_element( element_rangetime, _wpbc.get_message( 'message_error_range_time' ), 'text' ); } | |
| 567 | + if ( element_duration !== false ){ wpbc_front_end__show_message__warning_under_element( element_duration, _wpbc.get_message( 'message_error_duration_time' ), 'text' ); } | |
| 568 | + if ( element_start !== false ){ wpbc_front_end__show_message__warning_under_element( element_start, _wpbc.get_message( 'message_error_start_time' ), 'text' ); } | |
| 569 | + if ( element_end !== false ){ wpbc_front_end__show_message__warning_under_element( element_end, _wpbc.get_message( 'message_error_end_time' ), 'text' ); } | |
| 476 | 570 | |
| 477 | 571 | return true; |
| 478 | 572 | |
| 479 | 573 | } else { |