1var time_buffer_value = 0; // Customization of bufer time for DAN 2var is_check_start_time_gone = true; // Check start time or end time for the time, which is gone already TODAY. //FixIn: 10.5.2.3 3var start_time_checking_index; 4//////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// 5 6/** 7 * Get dots for partially booked dates. 8 * For parent booking resources with specific capacity, 9 * System do not show partially booked dates, if at least one child booking resource fully available 10 * Otherwise it show maximum number of time-slot in one specific child booking resource 11 * 12 * @param param_calendar_id ID of booking resource 13 * @param my_thisDateTime timestamp of date 14 * @returns {string} 15 */ 16function wpbc_show_date_info_top( param_calendar_id, my_thisDateTime ){ 17 18 var resource_id = parseInt( param_calendar_id.replace( "calendar_booking", '' ) ); 19 20 // console.log( _wpbc.bookings_in_calendar__get( resource_id ) ); // for debug 21 22 // 1. Get child booking resources or single booking resource that exist in dates : [1] | [1,14,15,17] 23 var child_resources_arr = wpbc_clone_obj( _wpbc.booking__get_param_value( resource_id, 'resources_id_arr__in_dates' ) ); 24 25 // '2023-08-21' 26 var sql_date = wpbc__get__sql_class_date( new Date( my_thisDateTime ) ); 27 28 var child_resource_id; 29 var merged_seconds; 30 var dots_count = 0; 31 32 var dots_in__resources = []; 33 34 // Loop all resources ID 35 for ( var res_key in child_resources_arr ){ 36 37 child_resource_id = child_resources_arr[ res_key ]; 38 39 // _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 // _wpbc.bookings_in_calendar__get_for_date(2,'2023-08-21')[2].booked_time_slots.merged_seconds = [ [ 25211, 27002 ], [ 36011, 86400 ] ] 41 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 ] ] 44 } else { 45 merged_seconds = []; 46 } 47 48 if ( 0 === merged_seconds.length ){ 49 return ''; // Day available 50 } 51 52 for ( var i = 0; i < merged_seconds.length; i++ ){ 53 if ( ! wpbc_is_this_timeslot__full_day_booked( merged_seconds[i] ) ){ // Check if this fully booked date. If yes, then do not count it 54 dots_count++; 55 } 56 } 57 58 dots_in__resources.push( dots_count ); 59 dots_count = 0; 60 } 61 62 var dots_count_max = Math.max.apply( Math, dots_in__resources ); // Get maximum value in array [ 1, 5, 3] -> 5 63 64 var dot_content = ''; 65 for ( var d = 0; d < dots_count_max; d++ ){ 66 dot_content += '·'; 67 } 68 69 dot_content = ( '' !== dot_content ) ? '<div class="wpbc_time_dots">' + dot_content + '</div>' : ''; 70 71 return dot_content; 72} 73 74/** 75 * Show Date Info at bottom of the Day Cell 76 * 77 * @param param_calendar_id 'calendar_booking1' 78 * @param my_thisDateTime 56567557757 79 * @returns {string} 80 */ 81function wpbc_show_date_info_bottom( param_calendar_id, my_thisDateTime ) { 82 83 var bottom_hint_arr = []; 84 85 // Cost Hint 86 if ( typeof (wpbc_show_day_cost_in_date_bottom) == 'function' ) { 87 var cost_hint = wpbc_show_day_cost_in_date_bottom( param_calendar_id, my_thisDateTime ); 88 if ( '' !== cost_hint ) { 89 bottom_hint_arr.push( wpbc_show_day_cost_in_date_bottom( param_calendar_id, my_thisDateTime ) ); 90 } 91 } 92 93 // Availability Hint //FixIn: 10.6.4.1 94 var availability = wpbc_get_in_date_availability_hint( param_calendar_id, my_thisDateTime ) 95 if ( '' !== availability ) { 96 bottom_hint_arr.push( availability ); 97 } 98 99 var bottom_hint = bottom_hint_arr.join( '' ); 100 return bottom_hint; 101} 102 103/** 104 * Get Availability Hint for in Day Cell 105 * 106 * @param param_calendar_id 107 * @param my_thisDateTime 108 * @returns {string} 109 */ 110function wpbc_get_in_date_availability_hint( param_calendar_id, my_thisDateTime ) { //FixIn: 10.6.4.1 111 112 /* 113 var sql_date = wpbc__get__sql_class_date( new Date( my_thisDateTime ) ); // '2023-08-21' 114 var resource_id = parseInt( param_calendar_id.replace( "calendar_booking", '' ) ); // 1 115 var day_availability_obj = _wpbc.bookings_in_calendar__get_for_date( resource_id, sql_date ); // obj 116 117 if ( 'undefined' !== typeof (day_availability_obj.day_availability) ) { 118 return '<strong>' + day_availability_obj.day_availability + '</strong> ' + 'available'; 119 } else { 120 return ''; 121 } 122 */ 123 124 var resource_id = parseInt( param_calendar_id.replace( "calendar_booking", '' ) ); 125 126 // console.log( _wpbc.bookings_in_calendar__get( resource_id ) ); // for debug 127 128 // 1. Get child booking resources or single booking resource that exist in dates : [1] | [1,14,15,17] 129 // var child_resources_arr = wpbc_clone_obj( _wpbc.booking__get_param_value( resource_id, 'resources_id_arr__in_dates' ) ); 130 131 // '2023-08-21' 132 var sql_date = wpbc__get__sql_class_date( new Date( my_thisDateTime ) ); 133 134 var hint__in_day__availability = ''; 135 136 var get_for_date_obj = _wpbc.bookings_in_calendar__get_for_date( resource_id, sql_date ); 137 138 if ( false !== get_for_date_obj ){ 139 140 if ( 141 (undefined != get_for_date_obj[ 'summary' ]) 142 && (undefined != get_for_date_obj[ 'summary' ].hint__in_day__availability) 143 ){ 144 hint__in_day__availability = get_for_date_obj[ 'summary' ].hint__in_day__availability; // "5 available" 145 } 146 147 } 148 149 return hint__in_day__availability; 150} 151 152 153/** 154 * Hide Tippy tooltip on scroll, to prevent issue on mobile touch devices of showing tooltip at top left corner! 155 * @param evt 156 */ 157jQuery( window ).on( 'scroll', function ( event ){ //FixIn: 9.2.1.5 //FixIn: 9.4.3.3 158 if ( 'function' === typeof( wpbc_tippy ) ){ 159 wpbc_tippy.hideAll(); 160 } 161} ); 162 163 164/** 165 * Check if in booking form exist times fields for booking for specific time-slot 166 * @param resource_id 167 * @param form_elements 168 * @returns {boolean} 169 */
170function wpbc_is_time_field_in_booking_form( resource_id, form_elements ){ //FixIn: 8.2.1.28 171 172 var count = form_elements.length; 173 var start_time = false; 174 var end_time = false; 175 var duration = false; 176 var element; 177 178 /** 179 * Get from booking form 'rangetime', 'durationtime', 'starttime', 'endtime', if exists. 180 */ 181 for ( var i = 0; i < count; i++ ){ 182 183 element = form_elements[ i ]; 184 185 // Skip elements from garbage 186 if ( jQuery( element ).closest( '.booking_form_garbage' ).length ){ //FixIn: 7.1.2.14 187 continue; 188 } 189 190 if ( 191 ( element.name != undefined ) 192 && ( element.name.indexOf( 'hint' ) !== -1 ) //FixIn: 9.5.5.2 193 ){ 194 var my_element = element.name; //.toString(); 195 if ( my_element.indexOf( 'rangetime' ) !== -1 ){ // Range Time 196 197 return true; 198 } 199 if ( (my_element.indexOf( 'durationtime' ) !== -1) ){ // Duration 200 duration = element.value; 201 } 202 if ( my_element.indexOf( 'starttime' ) !== -1 ){ // Start Time 203 start_time = element.value; 204 } 205 if ( my_element.indexOf( 'endtime' ) !== -1 ){ // End Time 206 end_time = element.value; 207 } 208 } 209 } 210 211 // Duration get Values 212 if ( ( duration !== false ) && ( start_time !== false ) ){ // we have Duration and Start time 213 return true; 214 } 215 216 if ( ( start_time !== false ) && ( end_time !== false ) ){ // we have End time and Start time 217 return true; 218 } 219 220 return false; 221} 222 223 224//////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// 225//TODO: Continue Refactoring here 2018-04-21 226//////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// 227 228 229 //PS: This function from ../booking/inc/js/personal.js 230 function wpbc_is_this_time_selection_not_available( resource_id, form_elements ){ 231 232 // Skip this checking if we are in the Admin panel at Add booking page 233 if ( location.href.indexOf( 'page=wpbc-new' ) > 0 ) { 234 return false; 235 } 236 237 var count = form_elements.length; 238 var start_time = false; 239 var end_time = false; 240 var duration = false; 241 var element; 242 var element_start = false; 243 var element_end = false; 244 var element_duration = false; 245 var element_rangetime = false; 246 247 /** 248 * Get from booking form 'rangetime', 'durationtime', 'starttime', 'endtime', if exists. 249 */ 250 for ( var i = 0; i < count; i++ ){ 251 252 element = form_elements[ i ]; 253 254 // Skip elements from garbage 255 if ( jQuery( element ).closest( '.booking_form_garbage' ).length ){ //FixIn: 7.1.2.14 256 continue; 257 } 258 259 if ( 260 ( element.name != undefined ) 261 && ( element.name.indexOf( 'hint' ) === -1 ) //FixIn: 9.5.5.2 //FixIn: 9.6.3.9 262 ){ 263 var my_element = element.name; //.toString(); 264 if ( my_element.indexOf( 'rangetime' ) !== -1 ){ // Range Time 265 if ( element.value == '' ){ //FixIn: 7.0.Beta.19 266 var notice_message_id = wpbc_front_end__show_message__warning( element, _wpbc.get_message( 'message_check_required' ) ); 267 return true; 268 } 269 var my_rangetime = element.value.split( '-' ); 270 if ( my_rangetime.length > 1 ){ 271 start_time = my_rangetime[ 0 ].replace( /(^\s+)|(\s+$)/g, "" ); // Trim 272 end_time = my_rangetime[ 1 ].replace( /(^\s+)|(\s+$)/g, "" ); 273 element_rangetime = element; 274 } 275 } 276 if ( (my_element.indexOf( 'durationtime' ) !== -1) ){ // Duration 277 duration = element.value; 278 element_duration = element; 279 } 280 if ( my_element.indexOf( 'starttime' ) !== -1 ){ // Start Time 281 start_time = element.value; 282 element_start = element; 283 } 284 if ( my_element.indexOf( 'endtime' ) !== -1 ){ // End Time 285 end_time = element.value; 286 element_end = element; 287 } 288 } 289 } 290 291 292 // Duration get Values 293 if ( (duration !== false) && (start_time !== false) ){ // we have Duration and Start time so try to get End time 294 295 var mylocalstarttime = start_time.split( ':' );
296 var d = new Date( 1980, 1, 1, mylocalstarttime[ 0 ], mylocalstarttime[ 1 ], 0 ); 297 298 var my_duration = duration.split( ':' ); 299 my_duration = my_duration[ 0 ] * 60 * 60 * 1000 + my_duration[ 1 ] * 60 * 1000; 300 d.setTime( d.getTime() + my_duration ); 301 302 var my_hours = d.getHours(); 303 if ( my_hours < 10 ) my_hours = '0' + (my_hours + ''); 304 var my_minutes = d.getMinutes(); 305 if ( my_minutes < 10 ) my_minutes = '0' + (my_minutes + ''); 306 307 // We are get end time 308 end_time = (my_hours + '') + ':' + (my_minutes + ''); 309 if ( end_time == '00:00' ) end_time = '23:59'; 310 } 311 312 313 if ( (start_time === false) || (end_time === false) ){ // We do not have Start or End time or Both of them, so do not check it 314 315 return false; 316 317 } else { 318 319 var valid_time = true; 320 if ( (start_time == '') || (end_time == '') ) valid_time = false; 321 322 if ( !isValidTimeTextField( start_time ) ) valid_time = false; 323 if ( !isValidTimeTextField( end_time ) ) valid_time = false; 324 325 if ( valid_time === true ) 326 if ( 327 (typeof(checkRecurentTimeInside) == 'function') && 328 329 ( _wpbc.get_other_param( 'is_enabled_booking_recurrent_time' ) == true ) 330 ){ // Recheck Time here !!! 331 valid_time = checkRecurentTimeInside( [ start_time, end_time ], resource_id ); 332 } else { 333 334 if ( typeof(checkTimeInside) == 'function' ){ 335 valid_time = checkTimeInside( start_time, true, resource_id ); 336 } 337 338 if ( valid_time === true ){ 339 if ( typeof(checkTimeInside) == 'function' ){ 340 valid_time = checkTimeInside( end_time, false, resource_id ); 341 } 342 } 343 } 344 345 if ( valid_time !== true ){ 346 //return false; // do not show warning for setting pending days selectable, if making booking for time-slot //FixIn: 7.0.1.23 347 if ( (_wpbc.get_other_param( 'is_enabled_change_over' )) && (element_start !== false) && (element_end !== false) ){ //FixIn:6.1.1.1 348 wpbc_front_end__show_message__warning_under_element( '#date_booking' + resource_id, _wpbc.get_message( 'message_check_no_selected_dates' ) ); 349 } 350 if ( element_rangetime !== false ){ wpbc_front_end__show_message__warning_under_element( element_rangetime, _wpbc.get_message( 'message_error_range_time' ) ); } 351 if ( element_duration !== false ){ wpbc_front_end__show_message__warning_under_element( element_duration, _wpbc.get_message( 'message_error_duration_time' ) ); } 352 if ( element_start !== false ){ wpbc_front_end__show_message__warning_under_element( element_start, _wpbc.get_message( 'message_error_start_time' ) ); } 353 if ( element_end !== false ){ wpbc_front_end__show_message__warning_under_element( element_end, _wpbc.get_message( 'message_error_end_time' ) ); } 354 355 return true; 356 357 } else { 358 return false; 359 } 360 361 } 362 363 364 } 365 366 367 function isTimeTodayGone( myTime, sort_date_array ){ 368 var date_to_check = sort_date_array[ 0 ]; 369 if ( is_check_start_time_gone == false ){ 370 date_to_check = sort_date_array[ (sort_date_array.length - 1) ]; 371 } 372 373 if ( parseInt( date_to_check[ 0 ] ) < parseInt( _wpbc.get_other_param( 'today_arr' )[ 0 ] ) ) return true; 374 if ( (parseInt( date_to_check[ 0 ] ) == parseInt( _wpbc.get_other_param( 'today_arr' )[ 0 ] )) && (parseInt( date_to_check[ 1 ] ) < parseInt( _wpbc.get_other_param( 'today_arr' )[ 1 ] )) ) 375 return true; 376 if ( (parseInt( date_to_check[ 0 ] ) == parseInt( _wpbc.get_other_param( 'today_arr' )[ 0 ] )) && (parseInt( date_to_check[ 1 ] ) == parseInt( _wpbc.get_other_param( 'today_arr' )[ 1 ] )) && (parseInt( date_to_check[ 2 ] ) < parseInt( _wpbc.get_other_param( 'today_arr' )[ 2 ] )) ) 377 return true; 378 if ( (parseInt( date_to_check[ 0 ] ) == parseInt( _wpbc.get_other_param( 'today_arr' )[ 0 ] )) && 379 (parseInt( date_to_check[ 1 ] ) == parseInt( _wpbc.get_other_param( 'today_arr' )[ 1 ] )) && 380 (parseInt( date_to_check[ 2 ] ) == parseInt( _wpbc.get_other_param( 'today_arr' )[ 2 ] )) ){ 381 var mytime_value = myTime.split( ":" ); 382 mytime_value = mytime_value[ 0 ] * 60 + parseInt( mytime_value[ 1 ] ); 383 384 var current_time_value = _wpbc.get_other_param( 'today_arr' )[ 3 ] * 60 + parseInt( _wpbc.get_other_param( 'today_arr' )[ 4 ] ); 385 386 if ( current_time_value > mytime_value ) return true; 387 388 } 389 return false; 390 } 391 392 393 function checkTimeInside( mytime, is_start_time, bk_type ){ 394 395 var my_dates_str = document.getElementById( 'date_booking' + bk_type ).value; // GET DATES From TEXTAREA 396 397 if ( my_dates_str.indexOf( ' - ' ) != 0 ){ 398 399 my_dates_str = my_dates_str.replace( ' - ', ', ' ); //FixIn: 10.2.3.2 400 } 401 402 return checkTimeInsideProcess( mytime, is_start_time, bk_type, my_dates_str ); 403 } 404 405 406 function checkRecurentTimeInside( my_rangetime, bk_type ){ 407
408 var valid_time = true; 409 var my_dates_str = document.getElementById( 'date_booking' + bk_type ).value; // GET DATES From TEXTAREA 410 // recurrent time check for all days in loop 411 412 var date_array = my_dates_str.split( ", " ); 413 if ( date_array.length == 2 ){ // This recheck is need for editing booking, with single day 414 if ( date_array[ 0 ] == date_array[ 1 ] ){ 415 date_array = [ date_array[ 0 ] ]; 416 } 417 } 418 var temp_date_str = ''; 419 for ( var i = 0; i < date_array.length; i++ ){ // Get SORTED selected days array 420 temp_date_str = date_array[ i ]; 421 if ( checkTimeInsideProcess( my_rangetime[ 0 ], true, bk_type, temp_date_str ) == false ) valid_time = false; 422 if ( checkTimeInsideProcess( my_rangetime[ 1 ], false, bk_type, temp_date_str ) == false ) valid_time = false; 423 424 } 425 426 return valid_time; 427 } 428 429 430// Function check start and end time at selected days 431 function checkTimeInsideProcess( mytime, is_start_time, bk_type, my_dates_str ){ 432 var i, h, s, m; //FixIn: 9.1.5.1 433 434 var date_array = my_dates_str.split( ", " ); 435 if ( date_array.length == 2 ){ // This recheck is need for editing booking, with single day 436 if ( date_array[ 0 ] == date_array[ 1 ] ){ 437 date_array = [ date_array[ 0 ] ]; 438 } 439 } 440 441 var temp_elemnt; 442 var td_class; 443 var sort_date_array = []; 444 var work_date_array = []; 445 var times_array = []; 446 var is_check_for_time; 447 448 for ( var i = 0; i < date_array.length; i++ ){ // Get SORTED selected days array 449 temp_elemnt = date_array[ i ].split( "." ); 450 sort_date_array[ i ] = [ temp_elemnt[ 2 ], temp_elemnt[ 1 ] + '', temp_elemnt[ 0 ] + '' ]; // [2009,7,1],... 451 } 452 sort_date_array.sort(); // SORT D a t e s 453 for ( i = 0; i < sort_date_array.length; i++ ){ // trnasform to integers 454 sort_date_array[ i ] = [ parseInt( sort_date_array[ i ][ 0 ] * 1 ), parseInt( sort_date_array[ i ][ 1 ] * 1 ), parseInt( sort_date_array[ i ][ 2 ] * 1 ) ]; // [2009,7,1],... 455 } 456 457 if ( ((is_check_start_time_gone) && (is_start_time)) || 458 ((!is_check_start_time_gone) && (!is_start_time)) ){ 459 460 if ( isTimeTodayGone( mytime, sort_date_array ) ) return false; 461 } 462 // CHECK FOR BOOKING INSIDE OF S E L E C T E D DAY RANGE AND FOR TOTALLY BOOKED DAYS AT THE START AND END OF RANGE 463 work_date_array = sort_date_array; 464 for ( var j = 0; j < work_date_array.length; j++ ){ 465 td_class = work_date_array[ j ][ 1 ] + '-' + work_date_array[ j ][ 2 ] + '-' + work_date_array[ j ][ 0 ]; 466 467 if ( (j == 0) || (j == (work_date_array.length - 1)) ) is_check_for_time = true; // Check for time only start and end time 468 else is_check_for_time = false; 469 470 471 } /////////////////////////////////////////////////////////////////////////////////////////////////////// 472 473 474 // Check START OR END time for time no in correct fee range 475 if ( is_start_time ) work_date_array = sort_date_array[ 0 ]; 476 else work_date_array = sort_date_array[ sort_date_array.length - 1 ]; 477 478 td_class = work_date_array[ 1 ] + '-' + work_date_array[ 2 ] + '-' + work_date_array[ 0 ]; 479 480 // Get dates and time from pending dates 481 //deleted 482 // Get dates and time from pending dates 483 //deleted 484 485 486 times_array.sort(); // SORT TIMES 487 488 var times_in_day = []; // array with all times 489 var times_in_day_interval_marks = []; // array with time interval marks 1- stsrt time 2 - end time 490 491 492 for ( i = 0; i < times_array.length; i++ ){ 493 s = times_array[ i ][ 2 ]; // s = 2 - end time, s = 1 - start time 494 // Start close interval 495 if ( (s == 2) && (i == 0) ){ 496 times_in_day[ times_in_day.length ] = 0; 497 times_in_day_interval_marks[ times_in_day_interval_marks.length ] = 1; 498 } 499 // Normal 500 times_in_day[ times_in_day.length ] = times_array[ i ][ 0 ] * 60 + parseInt( times_array[ i ][ 1 ] ); 501 times_in_day_interval_marks[ times_in_day_interval_marks.length ] = s; 502 // End close interval 503 if ( (s == 1) && (i == (times_array.length - 1)) ){ 504 times_in_day[ times_in_day.length ] = (24 * 60); 505 times_in_day_interval_marks[ times_in_day_interval_marks.length ] = 2; 506 } 507 } 508 509 // Get time from entered time 510 var mytime_value = mytime.split( ":" ); 511 mytime_value = mytime_value[ 0 ] * 60 + parseInt( mytime_value[ 1 ] ); 512 513//alert('My time:'+ mytime_value + ' List of times: '+ times_in_day + ' Saved indexes: ' + start_time_checking_index + ' Days: ' + sort_date_array ) ; 514 515 var start_i = 0; 516 if ( start_time_checking_index != undefined ) 517 if ( start_time_checking_index[ 0 ] != undefined ) 518 if ( (!is_start_time) && (sort_date_array.length == 1) ){ 519 start_i = start_time_checking_index[ 0 ]; 520 /*start_i++;*/ 521 } 522 i = start_i; 523 524 // Main checking inside a day 525 for ( i = start_i; i < times_in_day.length; i++ ){ 526 times_in_day[ i ] = parseInt( times_in_day[ i ] ); 527 mytime_value = parseInt( mytime_value ); 528 if ( is_start_time ){ 529 if ( mytime_value > times_in_day[ i ] ){ 530 // Its Ok, lets Loop to next item 531 } else if ( mytime_value == times_in_day[ i ] ){ 532 if ( times_in_day_interval_marks[ i ] == 1 ){ 533 return false; //start time is begin with some other interval 534 } else { 535 if ( (i + 1) <= (times_in_day.length - 1) ){ 536 if ( times_in_day[ i + 1 ] <= mytime_value ) return false; //start time is begin with next elemnt interval 537 else { // start time from end of some other 538 if ( sort_date_array.length > 1 ) 539 if ( (i + 1) <= (times_in_day.length - 1) ) return false; // Its mean that we make end booking at some other day then this and we have some booking time at this day after start booking - its wrong 540 start_time_checking_index = [ i, td_class, mytime_value ]; 541 return true; 542 } 543 } 544 if ( sort_date_array.length > 1 ) 545 if ( (i + 1) <= (times_in_day.length - 1) ) return false; // Its mean that we make end booking at some other day then this and we have some booking time at this day after start booking - its wrong 546 start_time_checking_index = [ i, td_class, mytime_value ]; 547 return true; // start time from end of some other 548 } 549 } else if ( mytime_value < times_in_day[ i ] ){ 550 if ( times_in_day_interval_marks[ i ] == 2 ){ 551 return false; // start time inside of some interval 552 } else { 553 if ( sort_date_array.length > 1 ) 554 if ( (i + 1) <= (times_in_day.length - 1) ) return false; // Its mean that we make end booking at some other day then this and we have some booking time at this day after start booking - its wrong 555 start_time_checking_index = [ i, td_class, mytime_value ]; 556 return true; 557 } 558 } 559 } else { 560 if ( sort_date_array.length == 1 ){ 561 562 if ( start_time_checking_index != undefined ) 563 if ( start_time_checking_index[ 2 ] != undefined ) 564 565 if ( (start_time_checking_index[ 2 ] == times_in_day[ i ]) && (times_in_day_interval_marks[ i ] == 2) ){ // Good, because start time = end of some other interval and we need to get next interval for current end time. 566 } else if ( times_in_day[ i ] < mytime_value ) return false; // some interval begins before end of curent "end time" 567 else { 568 if ( start_time_checking_index[ 2 ] >= mytime_value ) return false; // we are select only one day and end time is earlythe starttime its wrong 569 return true; // if we selected only one day so evrything is fine and end time no inside some other intervals 570 } 571 } else { 572 if ( times_in_day[ i ] < mytime_value ) return false; // Some other interval start before we make end time in the booking at the end day selection 573 else return true; 574 } 575 576 } 577 } 578 579 if ( is_start_time ) start_time_checking_index = [ i, td_class, mytime_value ]; 580 else { 581 if ( start_time_checking_index != undefined ) 582 if ( start_time_checking_index[ 2 ] != undefined ) 583 if ( (sort_date_array.length == 1) && (start_time_checking_index[ 2 ] >= mytime_value) ) return false; // we are select only one day and end time is earlythe starttime its wrong 584 } 585 return true; 586 } 587 588 589 //PS: This function from ../booking/inc/js/personal.js 590 function isValidTimeTextField( timeStr ){
591 // Checks if time is in HH:MM AM/PM format. 592 // The seconds and AM/PM are optional. 593 594 var timePat = /^(\d{1,2}):(\d{2})(\s?(AM|am|PM|pm))?$/; 595 596 var matchArray = timeStr.match( timePat ); 597 if ( matchArray == null ){ 598 return false; //("<?php _e('Time is not in a valid format. Use this format HH:MM or HH:MM AM/PM'); ?>"); 599 } 600 var hour = matchArray[ 1 ]; 601 var minute = matchArray[ 2 ]; 602 var ampm = matchArray[ 4 ]; 603 604 if ( ampm == "" ){ 605 ampm = null 606 } 607 608 if ( hour < 0 || hour > 24 ){ //FixIn: 8.3.1.1 609 return false; //("<?php _e('Hour must be between 1 and 12. (or 0 and 23 for military time)'); ?>"); 610 } 611 if ( hour > 12 && ampm != null ){ 612 return false; //("<?php _e('You can not specify AM or PM for military time.'); ?>"); 613 } 614 if ( minute < 0 || minute > 59 ){ 615 return false; //("<?php _e('Minute must be between 0 and 59.'); ?>"); 616 } 617 return true; 618 }
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.