1var time_buffer_value = 0; // Customization of bufer time for DAN 2var is_check_start_time_gone = false; // Check start time or end time for the time, which is gone already TODAY. 3var start_time_checking_index; 4//////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// 5 6//FixIn: Deprecated 7function prepare_tooltip( myParam ){ 8 wpbc_set_popover_in_cal( myParam ); 9} 10 11//FixIn: Deprecated 12function hoverDayTime( value, date_obj, resource_id ){ 13 wpbc_prepare_tooltip_content( value, date_obj, resource_id ); 14} 15 16//FixIn: Deprecated 17function is_this_time_selections_not_available( resource_id, form_elements ){ 18 var reslt = wpbc_is_this_time_selection_not_available( resource_id, form_elements ); 19 return reslt; 20} 21//////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// 22 23/** 24 * Prepare for showing popovers in calendar at front-end side 25 * 26 * @param resource_id 27 */ 28function wpbc_set_popover_in_cal( resource_id ){ 29 30 var tooltip_day_class_4_show = " .timespartly"; 31 32 if ( is_show_availability_in_tooltips ){ 33 if ( wpdev_in_array( parent_booking_resources, resource_id ) ) 34 tooltip_day_class_4_show = " .datepick-days-cell"; //" .datepick-days-cell a"; // each day 35 } 36 37 if ( is_show_cost_in_tooltips ){ 38 tooltip_day_class_4_show = " .datepick-days-cell"; //" .datepick-days-cell a"; // each day 39 } 40 41 // Show tooltip at each day if time availability filter is set 42 if ( typeof(global_avalaibility_times[ resource_id ]) != "undefined" ){ 43 if ( global_avalaibility_times[ resource_id ].length > 0 ) tooltip_day_class_4_show = " .datepick-days-cell"; // each day 44 } 45 46 if ( jQuery.isFunction( jQuery( "#calendar_booking" + resource_id + tooltip_day_class_4_show ).popover ) ){ //FixIn: 7.0.1.2 - 2016-12-10 47 jQuery( "#calendar_booking" + resource_id + tooltip_day_class_4_show ).popover( { 48 placement: 'top auto' 49 , trigger : 'hover' 50 , delay : {show: 500, hide: 1} 51 , content : '' 52 , template : '<div class="popover popover_calendar_hover" role="tooltip"><div class="arrow"></div><h3 class="popover-title"></h3><div class="popover-content"></div></div>' 53 , container: '#calendar_booking' + resource_id 54 , html : 'true' 55 } ); 56 } 57} 58 59/** 60 * Sort times array - prevent issue with same start/end times. 61 * @param times_array [ 62 0: Array [ 10, "00", "01" ] 63 1: Array [ 12, "00", "01" ] 64 2: Array [ 12, "00", "02" ] 65 ] 66 * @returns [ 67 0: Array [ 10, "00", "01" ] 68 1: Array [ 12, "00", "02" ] 69 2: Array [ 12, "00", "01" ] 70 ] 71 */ 72function wpbc_sort_times_array( times_array ){ 73 74 var sort_time_arr=[]; 75 var sort_time_obj = []; 76 var time_second = 0 77 var is_it_endtime = 0; 78 for ( var i = 0 ; i < times_array.length; i++ ){ 79 80 if ( times_array[ i ].length > 2 ) { 81 82 time_second = parseInt( times_array[ i ][ 0 ] ) * 3600 + parseInt( times_array[ i ][ 1 ] ) * 60 + parseInt( times_array[ i ][ 2 ] ); 83 84 is_it_endtime = time_second % 10; // 1 -start || 2 - end 85 86 if ( 2 === is_it_endtime ) { 87 time_second = time_second - 10; // End time 88 } else { 89 time_second = time_second + 10; // Start time 90 } 91 92 sort_time_obj[ sort_time_obj.length ] = { second: time_second, value: times_array[ i ] }; 93 } 94 } 95 96 // sort by seconds 97 sort_time_obj.sort(function (a, b) { 98 return a.second - b.second; 99 }); 100 101 for ( var i = 0 ; i < sort_time_obj.length; i++ ){ 102 sort_time_arr[ sort_time_arr.length ] = sort_time_obj[ i ].value; 103 } 104 return sort_time_arr; 105} 106 107 108 109/** 110 * Prepare content for popover, like Times, Costs, Availability, .... 111 * @param value 112 * @param date_obj 113 * @param resource_id 114 */ 115function wpbc_prepare_tooltip_content( value, date_obj, resource_id ){ 116 117 if ( date_obj == null ) return; 118 119 var i = 0; 120 var h = ''; 121 var m = ''; 122 var s = ''; 123 var td_class; 124 125 var tooltip_time = ''; 126 var times_array = []; 127 128 td_class = ( date_obj.getMonth() + 1 ) + '-' + date_obj.getDate() + '-' + date_obj.getFullYear(); 129 130 // Get Times from Approved dates 131 var times_array_approved = wpbc_get_times_from_dates_arr( date_approved, resource_id, td_class ); 132 for ( i = 0; i < times_array_approved.length; i++ ){ 133 times_array[ times_array.length ] = times_array_approved[ i ]; 134 } 135 136 // Get Times from Pending dates
137 var times_array_pending = wpbc_get_times_from_dates_arr( date2approve, resource_id, td_class ); 138 for ( i = 0; i < times_array_pending.length; i++ ){ 139 times_array[ times_array.length ] = times_array_pending[ i ]; 140 } 141 142 // Time availability 143 if ( typeof(hover_day_check_global_time_availability) == 'function' ){ 144 times_array = hover_day_check_global_time_availability( date_obj, resource_id, times_array ); 145 } 146 147 148 //FixIn: 8.2.1.9 149 if ( times_array.length > 0 ){ 150 times_array = wpbc_sort_times_array( times_array ); 151 } 152 // times_array.sort(); 153 154 155 for ( i = 0; i < times_array.length; i++ ){ // s = 2 - end time, s = 1 - start time 156 s = parseInt( times_array[ i ][ 2 ] ); 157 if ( s == 2 ){ 158 if ( tooltip_time == '' ) tooltip_time = ' ... - '; 159 } // End time and before was no dates so its start from start of date_obj 160 if ( (tooltip_time == '') && (times_array[ i ][ 0 ] == '00') && (times_array[ i ][ 1 ] == '00') ) 161 tooltip_time = ' ... '; //start date at the midnight 162 else if ( (i == (times_array.length - 1)) && (times_array[ i ][ 0 ] == '23') && (times_array[ i ][ 1 ] == '59') ) 163 tooltip_time += ' ... '; 164 else { 165 var hours_show = times_array[ i ][ 0 ]; 166 var hours_show_sufix = ''; 167 if ( is_am_pm_inside_time ){ 168 if ( hours_show >= 12 ){ 169 hours_show = hours_show - 12; 170 if ( hours_show == 0 ) hours_show = 12; 171 hours_show_sufix = ' pm'; 172 } else { 173 hours_show_sufix = ' am'; 174 } 175 } 176//Customization of bufer time for DAN 177 if ( times_array[ i ][ 2 ] == '02' ){ 178 times_array[ i ][ 1 ] = (times_array[ i ][ 1 ] * 1) + time_buffer_value; 179 if ( times_array[ i ][ 1 ] > 59 ){ 180 times_array[ i ][ 1 ] = times_array[ i ][ 1 ] - 60; 181 hours_show = (hours_show * 1) + 1; 182 } 183 if ( times_array[ i ][ 1 ] < 10 ) times_array[ i ][ 1 ] = '0' + times_array[ i ][ 1 ]; 184 } 185 186 tooltip_time += hours_show + ':' + times_array[ i ][ 1 ] + hours_show_sufix; 187 } 188 189 190 if ( s == 1 ){ 191 tooltip_time += ' - '; 192 if ( i == (times_array.length - 1) ) tooltip_time += ' ... '; 193 } 194 if ( s == 2 ){ 195 if ( typeof(wpbc_get_additional_info_for_tooltip) == 'function' ){ 196 tooltip_time += wpbc_get_additional_info_for_tooltip( resource_id, td_class, parseInt( times_array[ i ][ 0 ] * 60 ) + parseInt( times_array[ i ][ 1 ] ) ); 197 } 198 tooltip_time += '<br/>'; 199 } 200 } 201 202 // jQuery( '#calendar_booking'+resource_id+' td.cal4date-'+td_class ) // TODO: continue working here, check unshow times at full booked days 203 if ( tooltip_time.indexOf( "undefined" ) > -1 ){ 204 tooltip_time = ''; 205 } 206 else { 207 if ( (tooltip_time != '') && (bk_highlight_timeslot_word != '') ){ 208 if ( is_booking_used_check_in_out_time === true ) // Disable showing time tooltip, if we are using check in/out times 209 tooltip_time = ''; 210 else 211 tooltip_time = '<span class="wpbc_booked_times_word">' + bk_highlight_timeslot_word + '</span><br />' + tooltip_time; 212 } 213 } 214 if ( typeof(getDayPrice4Show) == 'function' ){ 215 tooltip_time = getDayPrice4Show( resource_id, tooltip_time, td_class ); 216 } 217 if ( typeof(getDayAvailability4Show) == 'function' ){ 218 tooltip_time = getDayAvailability4Show( resource_id, tooltip_time, td_class ); 219 } 220 221 //tooltip_time = 'Already booked time slots: </br>' + tooltip_time ; 222 jQuery( '#calendar_booking' + resource_id + ' td.cal4date-' + td_class ).attr( 'data-content', tooltip_time ); 223} 224 225 226/** 227 * Get Times array [ [ h, m, s ], ... ] from Dates array ( date_approved || date2approve ), or return empty array otherwise 228 * @arr dates_arr 229 * @int resource_id 230 * @string td_class 231 * @returns {Array} 232 */ 233function wpbc_get_times_from_dates_arr( dates_arr, resource_id, td_class ){ 234 235 var i; 236 var h = ''; 237 var m = ''; 238 var s = ''; 239 var times_array = []; 240 241 // Get Times from Dates Array 242 243 if ( ( typeof( dates_arr[ resource_id ] ) !== 'undefined' ) 244 && ( typeof( dates_arr[ resource_id ][ td_class ] ) !== 'undefined' ) 245 && ( 246 ( dates_arr[ resource_id ][ td_class ][ 0 ][ 3 ] != 0 ) 247 || ( dates_arr[ resource_id ][ td_class ][ 0 ][ 4 ] != 0 ) 248 ) 249 ){ 250 for ( i = 0; i < dates_arr[ resource_id ][ td_class ].length; i++ ){ 251
252 h = dates_arr[ resource_id ][ td_class ][ i ][ 3 ]; 253 if ( h < 10 ) h = '0' + h; 254 if ( h == 0 ) h = '00'; 255 256 m = dates_arr[ resource_id ][ td_class ][ i ][ 4 ]; 257 if ( m < 10 ) m = '0' + m; 258 if ( m == 0 ) m = '00'; 259 260 s = dates_arr[ resource_id ][ td_class ][ i ][ 5 ]; 261 if ( s == 2 ) s = '02'; 262 if ( s == 1 ) s = '01'; 263 if ( s == 0 ) s = '00'; 264 265 times_array[ times_array.length ] = [ h, m, s ]; 266 } 267 } 268 269 return times_array; 270} 271 272 273/** 274 * Check if in booking form exist times fields for booking for specific time-slot 275 * @param resource_id 276 * @param form_elements 277 * @returns {boolean} 278 */ 279function wpbc_is_time_field_in_booking_form( resource_id, form_elements ){ //FixIn: 8.2.1.28 280 281 var count = form_elements.length; 282 var start_time = false; 283 var end_time = false; 284 var duration = false; 285 var element; 286 287 /** 288 * Get from booking form 'rangetime', 'durationtime', 'starttime', 'endtime', if exists. 289 */ 290 for ( var i = 0; i < count; i++ ){ 291 292 element = form_elements[ i ]; 293 294 // Skip elements from garbage 295 if ( jQuery( element ).closest( '.booking_form_garbage' ).length ){ //FixIn: 7.1.2.14 296 continue; 297 } 298 299 if ( element.name != undefined ){ 300 var my_element = element.name; //.toString(); 301 if ( my_element.indexOf( 'rangetime' ) !== -1 ){ // Range Time 302 303 return true; 304 } 305 if ( (my_element.indexOf( 'durationtime' ) !== -1) ){ // Duration 306 duration = element.value; 307 } 308 if ( my_element.indexOf( 'starttime' ) !== -1 ){ // Start Time 309 start_time = element.value; 310 } 311 if ( my_element.indexOf( 'endtime' ) !== -1 ){ // End Time 312 end_time = element.value; 313 } 314 } 315 } 316 317 // Duration get Values 318 if ( ( duration !== false ) && ( start_time !== false ) ){ // we have Duration and Start time 319 return true; 320 } 321 322 if ( ( start_time !== false ) && ( end_time !== false ) ){ // we have End time and Start time 323 return true; 324 } 325 326 return false; 327} 328 329 330//////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// 331//TODO: Continue Refactoring here 2018-04-21 332//////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// 333 334 335 //PS: This function from ../booking/inc/js/personal.js 336 function wpbc_is_this_time_selection_not_available( resource_id, form_elements ){ 337 338 // Skip this checking if we are in the Admin panel at Add booking page 339 if ( location.href.indexOf( 'page=wpbc-new' ) > 0 ) { 340 return false; 341 } 342 343 var count = form_elements.length; 344 var start_time = false; 345 var end_time = false; 346 var duration = false; 347 var element; 348 var element_start = false;
349 var element_end = false; 350 var element_duration = false; 351 var element_rangetime = false; 352 353 /** 354 * Get from booking form 'rangetime', 'durationtime', 'starttime', 'endtime', if exists. 355 */ 356 for ( var i = 0; i < count; i++ ){ 357 358 element = form_elements[ i ]; 359 360 // Skip elements from garbage 361 if ( jQuery( element ).closest( '.booking_form_garbage' ).length ){ //FixIn: 7.1.2.14 362 continue; 363 } 364 365 if ( element.name != undefined ){ 366 var my_element = element.name; //.toString(); 367 if ( my_element.indexOf( 'rangetime' ) !== -1 ){ // Range Time 368 if ( element.value == '' ){ //FixIn: 7.0.Beta.19 369 showErrorMessage( element, message_verif_requred ); 370 return true; 371 } 372 var my_rangetime = element.value.split( '-' ); 373 if ( my_rangetime.length > 1 ){ 374 start_time = my_rangetime[ 0 ].replace( /(^\s+)|(\s+$)/g, "" ); // Trim 375 end_time = my_rangetime[ 1 ].replace( /(^\s+)|(\s+$)/g, "" ); 376 element_rangetime = element; 377 } 378 } 379 if ( (my_element.indexOf( 'durationtime' ) !== -1) ){ // Duration 380 duration = element.value; 381 element_duration = element; 382 } 383 if ( my_element.indexOf( 'starttime' ) !== -1 ){ // Start Time 384 start_time = element.value; 385 element_start = element; 386 } 387 if ( my_element.indexOf( 'endtime' ) !== -1 ){ // End Time 388 end_time = element.value; 389 element_end = element; 390 } 391 } 392 } 393 394 395 // Duration get Values 396 if ( (duration !== false) && (start_time !== false) ){ // we have Duration and Start time so try to get End time 397 398 var mylocalstarttime = start_time.split( ':' ); 399 var d = new Date( 1980, 1, 1, mylocalstarttime[ 0 ], mylocalstarttime[ 1 ], 0 ); 400 401 var my_duration = duration.split( ':' ); 402 my_duration = my_duration[ 0 ] * 60 * 60 * 1000 + my_duration[ 1 ] * 60 * 1000; 403 d.setTime( d.getTime() + my_duration ); 404 405 var my_hours = d.getHours(); 406 if ( my_hours < 10 ) my_hours = '0' + (my_hours + ''); 407 var my_minutes = d.getMinutes(); 408 if ( my_minutes < 10 ) my_minutes = '0' + (my_minutes + ''); 409 410 // We are get end time 411 end_time = (my_hours + '') + ':' + (my_minutes + ''); 412 if ( end_time == '00:00' ) end_time = '23:59'; 413 } 414 415 416 if ( (start_time === false) || (end_time === false) ){ // We do not have Start or End time or Both of them, so do not check it 417 418 return false; 419 420 } else { 421 422 var valid_time = true; 423 if ( (start_time == '') || (end_time == '') ) valid_time = false; 424 425 if ( !isValidTimeTextField( start_time ) ) valid_time = false; 426 if ( !isValidTimeTextField( end_time ) ) valid_time = false; 427 428 if ( valid_time === true ) 429 if ( 430 (typeof(checkRecurentTimeInside) == 'function') && 431 (typeof(is_booking_recurrent_time) !== 'undefined') && 432 (is_booking_recurrent_time == true) 433 ){ // Recheck Time here !!! 434 valid_time = checkRecurentTimeInside( [ start_time, end_time ], resource_id ); 435 } else { 436 437 if ( typeof(checkTimeInside) == 'function' ){ 438 valid_time = checkTimeInside( start_time, true, resource_id ); 439 } 440 441 if ( valid_time === true ){ 442 if ( typeof(checkTimeInside) == 'function' ){ 443 valid_time = checkTimeInside( end_time, false, resource_id ); 444 } 445 } 446 } 447 448 if ( valid_time !== true ){ 449 //return false; // do not show warning for setting pending days selectable, if making booking for time-slot //FixIn: 7.0.1.23 450 if ( (is_booking_used_check_in_out_time) && (element_start !== false) && (element_end !== false) ){ //FixIn:6.1.1.1 451 showMessageUnderElement( '#date_booking' + resource_id, message_checkinouttime_error, '' ); 452 makeScroll( '#calendar_booking' + resource_id ); // Scroll to the calendar 453 return true; 454 } 455 if ( element_rangetime !== false ) showErrorTimeMessage( message_rangetime_error, element_rangetime ); 456 if ( element_duration !== false ) showErrorTimeMessage( message_durationtime_error, element_duration ); 457 if ( element_start !== false ) showErrorTimeMessage( message_starttime_error, element_start ); 458 if ( element_end !== false ) showErrorTimeMessage( message_endtime_error, element_end ); 459 460 return true; 461 462 } else { 463 return false;
464 } 465 466 } 467 468 469 } 470 471 472 function isTimeTodayGone( myTime, sort_date_array ){ 473 var date_to_check = sort_date_array[ 0 ]; 474 if ( is_check_start_time_gone == false ){ 475 date_to_check = sort_date_array[ (sort_date_array.length - 1) ]; 476 } 477 478 if ( parseInt( date_to_check[ 0 ] ) < parseInt( wpdev_bk_today[ 0 ] ) ) return true; 479 if ( (parseInt( date_to_check[ 0 ] ) == parseInt( wpdev_bk_today[ 0 ] )) && (parseInt( date_to_check[ 1 ] ) < parseInt( wpdev_bk_today[ 1 ] )) ) 480 return true; 481 if ( (parseInt( date_to_check[ 0 ] ) == parseInt( wpdev_bk_today[ 0 ] )) && (parseInt( date_to_check[ 1 ] ) == parseInt( wpdev_bk_today[ 1 ] )) && (parseInt( date_to_check[ 2 ] ) < parseInt( wpdev_bk_today[ 2 ] )) ) 482 return true; 483 if ( (parseInt( date_to_check[ 0 ] ) == parseInt( wpdev_bk_today[ 0 ] )) && 484 (parseInt( date_to_check[ 1 ] ) == parseInt( wpdev_bk_today[ 1 ] )) && 485 (parseInt( date_to_check[ 2 ] ) == parseInt( wpdev_bk_today[ 2 ] )) ){ 486 var mytime_value = myTime.split( ":" ); 487 mytime_value = mytime_value[ 0 ] * 60 + parseInt( mytime_value[ 1 ] ); 488 489 var current_time_value = wpdev_bk_today[ 3 ] * 60 + parseInt( wpdev_bk_today[ 4 ] ); 490 491 if ( current_time_value > mytime_value ) return true; 492 493 } 494 return false; 495 } 496 497 498 499 500 function checkTimeInside( mytime, is_start_time, bk_type ){ 501 502 // Check time availability for global filters 503 if ( typeof(check_entered_time_to_global_availability_time) == 'function' ){ 504 if ( !check_entered_time_to_global_availability_time( mytime, is_start_time, bk_type ) ) return false; 505 } 506 507 var my_dates_str = document.getElementById( 'date_booking' + bk_type ).value; // GET DATES From TEXTAREA 508 509 return checkTimeInsideProcess( mytime, is_start_time, bk_type, my_dates_str ); 510 511 } 512 513 514 function checkRecurentTimeInside( my_rangetime, bk_type ){ 515
516 var valid_time = true; 517 var my_dates_str = document.getElementById( 'date_booking' + bk_type ).value; // GET DATES From TEXTAREA 518 // recurrent time check for all days in loop 519 520 var date_array = my_dates_str.split( ", " ); 521 if ( date_array.length == 2 ){ // This recheck is need for editing booking, with single day 522 if ( date_array[ 0 ] == date_array[ 1 ] ){ 523 date_array = [ date_array[ 0 ] ]; 524 } 525 } 526 var temp_date_str = ''; 527 for ( var i = 0; i < date_array.length; i++ ){ // Get SORTED selected days array 528 temp_date_str = date_array[ i ]; 529 if ( checkTimeInsideProcess( my_rangetime[ 0 ], true, bk_type, temp_date_str ) == false ) valid_time = false; 530 if ( checkTimeInsideProcess( my_rangetime[ 1 ], false, bk_type, temp_date_str ) == false ) valid_time = false; 531 532 } 533 534 return valid_time; 535 } 536 537 538// Function check start and end time at selected days 539 function checkTimeInsideProcess( mytime, is_start_time, bk_type, my_dates_str ){ 540 541 542 var date_array = my_dates_str.split( ", " ); 543 if ( date_array.length == 2 ){ // This recheck is need for editing booking, with single day 544 if ( date_array[ 0 ] == date_array[ 1 ] ){ 545 date_array = [ date_array[ 0 ] ]; 546 } 547 } 548 549 var temp_elemnt; 550 var td_class; 551 var sort_date_array = []; 552 var work_date_array = []; 553 var times_array = []; 554 var is_check_for_time; 555 556 for ( var i = 0; i < date_array.length; i++ ){ // Get SORTED selected days array 557 temp_elemnt = date_array[ i ].split( "." ); 558 sort_date_array[ i ] = [ temp_elemnt[ 2 ], temp_elemnt[ 1 ] + '', temp_elemnt[ 0 ] + '' ]; // [2009,7,1],... 559 } 560 sort_date_array.sort(); // SORT D a t e s 561 for ( i = 0; i < sort_date_array.length; i++ ){ // trnasform to integers 562 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],... 563 } 564 565 if ( ((is_check_start_time_gone) && (is_start_time)) || 566 ((!is_check_start_time_gone) && (!is_start_time)) ){ 567 568 if ( isTimeTodayGone( mytime, sort_date_array ) ) return false; 569 } 570 // 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 571 work_date_array = sort_date_array; 572 for ( var j = 0; j < work_date_array.length; j++ ){ 573 td_class = work_date_array[ j ][ 1 ] + '-' + work_date_array[ j ][ 2 ] + '-' + work_date_array[ j ][ 0 ]; 574 575 if ( (j == 0) || (j == (work_date_array.length - 1)) ) is_check_for_time = true; // Check for time only start and end time 576 else is_check_for_time = false; 577 578 // Get dates and time from pending dates 579 if ( typeof(date2approve[ bk_type ]) !== 'undefined' ){ 580 if ( (typeof(date2approve[ bk_type ][ td_class ]) !== 'undefined') ){ 581 if ( !is_check_for_time ){ 582 return false; 583 } // its mean that this date is booked inside of range selected dates 584 if ( (date2approve[ bk_type ][ td_class ][ 0 ][ 3 ] != 0) || (date2approve[ bk_type ][ td_class ][ 0 ][ 4 ] != 0) ){ 585 // Evrything good - some time is booked check later 586 } else { 587 return false; 588 } // its mean that this date tottally booked 589 } 590 } 591 592 // Get dates and time from pending dates 593 if ( typeof(date_approved[ bk_type ]) !== 'undefined' ){ 594 if ( (typeof(date_approved[ bk_type ][ td_class ]) !== 'undefined') ){ 595 if ( !is_check_for_time ){ 596 return false; 597 } // its mean that this date is booked inside of range selected dates 598 if ( (date_approved[ bk_type ][ td_class ][ 0 ][ 3 ] != 0) || (date_approved[ bk_type ][ td_class ][ 0 ][ 4 ] != 0) ){ 599 // Evrything good - some time is booked check later 600 } else { 601 return false; 602 } // its mean that this date tottally booked 603 } 604 } 605 } /////////////////////////////////////////////////////////////////////////////////////////////////////// 606 607 608 // Check START OR END time for time no in correct fee range 609 if ( is_start_time ) work_date_array = sort_date_array[ 0 ]; 610 else work_date_array = sort_date_array[ sort_date_array.length - 1 ]; 611 612 td_class = work_date_array[ 1 ] + '-' + work_date_array[ 2 ] + '-' + work_date_array[ 0 ]; 613 614 // Get dates and time from pending dates 615 if ( typeof(date2approve[ bk_type ]) !== 'undefined' ) 616 if ( typeof(date2approve[ bk_type ][ td_class ]) !== 'undefined' ) 617 for ( i = 0; i < date2approve[ bk_type ][ td_class ].length; i++ ){ 618 h = date2approve[ bk_type ][ td_class ][ i ][ 3 ]; 619 if ( h < 10 ) h = '0' + h; 620 if ( h == 0 ) h = '00'; 621 m = date2approve[ bk_type ][ td_class ][ i ][ 4 ]; 622 if ( m < 10 ) m = '0' + m; 623 if ( m == 0 ) m = '00'; 624 s = date2approve[ bk_type ][ td_class ][ i ][ 5 ]; 625 626//Customization of bufer time for DAN 627 if ( s == '02' ){ 628 m = (m * 1) + time_buffer_value; 629 if ( m > 59 ){ 630 m = m - 60; 631 h = (h * 1) + 1; 632 } 633 if ( m < 10 ) m = '0' + m; 634 } 635 636 times_array[ times_array.length ] = [ h, m, s ]; 637 } 638 639 // Get dates and time from pending dates 640 if ( typeof(date_approved[ bk_type ]) !== 'undefined' ) 641 if ( typeof(date_approved[ bk_type ][ td_class ]) !== 'undefined' ) 642 for ( i = 0; i < date_approved[ bk_type ][ td_class ].length; i++ ){ 643 h = date_approved[ bk_type ][ td_class ][ i ][ 3 ]; 644 if ( h < 10 ) h = '0' + h; 645 if ( h == 0 ) h = '00'; 646 m = date_approved[ bk_type ][ td_class ][ i ][ 4 ]; 647 if ( m < 10 ) m = '0' + m; 648 if ( m == 0 ) m = '00'; 649 s = date_approved[ bk_type ][ td_class ][ i ][ 5 ]; 650 651//Customization of bufer time for DAN 652 if ( s == '02' ){ 653 m = (m * 1) + time_buffer_value; 654 if ( m > 59 ){ 655 m = m - 60; 656 h = (h * 1) + 1; 657 } 658 if ( m < 10 ) m = '0' + m; 659 } 660 661 662 times_array[ times_array.length ] = [ h, m, s ]; 663 } 664 665 666 times_array.sort(); // SORT TIMES 667 668 var times_in_day = []; // array with all times 669 var times_in_day_interval_marks = []; // array with time interval marks 1- stsrt time 2 - end time 670 671 672 for ( i = 0; i < times_array.length; i++ ){ 673 s = times_array[ i ][ 2 ]; // s = 2 - end time, s = 1 - start time 674 // Start close interval 675 if ( (s == 2) && (i == 0) ){ 676 times_in_day[ times_in_day.length ] = 0; 677 times_in_day_interval_marks[ times_in_day_interval_marks.length ] = 1; 678 } 679 // Normal 680 times_in_day[ times_in_day.length ] = times_array[ i ][ 0 ] * 60 + parseInt( times_array[ i ][ 1 ] ); 681 times_in_day_interval_marks[ times_in_day_interval_marks.length ] = s; 682 // End close interval 683 if ( (s == 1) && (i == (times_array.length - 1)) ){ 684 times_in_day[ times_in_day.length ] = (24 * 60); 685 times_in_day_interval_marks[ times_in_day_interval_marks.length ] = 2; 686 } 687 } 688 689 // Get time from entered time 690 var mytime_value = mytime.split( ":" ); 691 mytime_value = mytime_value[ 0 ] * 60 + parseInt( mytime_value[ 1 ] ); 692 693//alert('My time:'+ mytime_value + ' List of times: '+ times_in_day + ' Saved indexes: ' + start_time_checking_index + ' Days: ' + sort_date_array ) ; 694 695 var start_i = 0; 696 if ( start_time_checking_index != undefined ) 697 if ( start_time_checking_index[ 0 ] != undefined ) 698 if ( (!is_start_time) && (sort_date_array.length == 1) ){ 699 start_i = start_time_checking_index[ 0 ]; 700 /*start_i++;*/ 701 } 702 i = start_i; 703 704 // Main checking inside a day 705 for ( i = start_i; i < times_in_day.length; i++ ){ 706 times_in_day[ i ] = parseInt( times_in_day[ i ] ); 707 mytime_value = parseInt( mytime_value ); 708 if ( is_start_time ){ 709 if ( mytime_value > times_in_day[ i ] ){ 710 // Its Ok, lets Loop to next item 711 } else if ( mytime_value == times_in_day[ i ] ){ 712 if ( times_in_day_interval_marks[ i ] == 1 ){ 713 return false; //start time is begin with some other interval 714 } else { 715 if ( (i + 1) <= (times_in_day.length - 1) ){ 716 if ( times_in_day[ i + 1 ] <= mytime_value ) return false; //start time is begin with next elemnt interval 717 else { // start time from end of some other 718 if ( sort_date_array.length > 1 ) 719 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 720 start_time_checking_index = [ i, td_class, mytime_value ]; 721 return true; 722 } 723 } 724 if ( sort_date_array.length > 1 ) 725 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 726 start_time_checking_index = [ i, td_class, mytime_value ]; 727 return true; // start time from end of some other 728 } 729 } else if ( mytime_value < times_in_day[ i ] ){ 730 if ( times_in_day_interval_marks[ i ] == 2 ){ 731 return false; // start time inside of some interval 732 } else { 733 if ( sort_date_array.length > 1 ) 734 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 735 start_time_checking_index = [ i, td_class, mytime_value ]; 736 return true; 737 } 738 } 739 } else { 740 if ( sort_date_array.length == 1 ){ 741 742 if ( start_time_checking_index != undefined ) 743 if ( start_time_checking_index[ 2 ] != undefined ) 744 745 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. 746 } else if ( times_in_day[ i ] < mytime_value ) return false; // some interval begins before end of curent "end time" 747 else { 748 if ( start_time_checking_index[ 2 ] >= mytime_value ) return false; // we are select only one day and end time is earlythe starttime its wrong 749 return true; // if we selected only one day so evrything is fine and end time no inside some other intervals 750 } 751 } else { 752 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 753 else return true; 754 } 755 756 } 757 } 758 759 if ( is_start_time ) start_time_checking_index = [ i, td_class, mytime_value ]; 760 else { 761 if ( start_time_checking_index != undefined ) 762 if ( start_time_checking_index[ 2 ] != undefined ) 763 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 764 } 765 return true; 766 } 767 768 //PS: This function from ../booking/inc/js/personal.js 769 function showErrorTimeMessage( my_message, element ){ 770 var element_name = element.name; 771 makeScroll( element ); 772 jQuery( "[name='" + element_name + "']" ) 773 .css( {'border': '1px solid red'} ) 774 .fadeOut( 350 ) 775 .fadeIn( 500 ) 776 .animate( {opacity: 1}, 4000 ) 777 .animate( {border: '1px solid #DFDFDF'}, 100 ) 778 ; // mark red border 779 jQuery( "[name='" + element_name + "']" ) 780 .after( '<div class="wpdev-help-message alert alert-warning">' + my_message + '</div>' ); // Show message 781 jQuery( ".wpdev-help-message" ) 782 // .css( {'color' : 'red'} ) 783 .animate( {opacity: 1}, 10000 ) 784 .fadeOut( 2000 ); // hide message 785 element.focus(); // make focus to elemnt 786 return true; 787 } 788 789 //PS: This function from ../booking/inc/js/personal.js 790 function isValidTimeTextField( timeStr ){
791 // Checks if time is in HH:MM AM/PM format. 792 // The seconds and AM/PM are optional. 793 794 var timePat = /^(\d{1,2}):(\d{2})(\s?(AM|am|PM|pm))?$/; 795 796 var matchArray = timeStr.match( timePat ); 797 if ( matchArray == null ){ 798 return false; //("<?php _e('Time is not in a valid format. Use this format HH:MM or HH:MM AM/PM'); ?>"); 799 } 800 var hour = matchArray[ 1 ]; 801 var minute = matchArray[ 2 ]; 802 var ampm = matchArray[ 4 ]; 803 804 if ( ampm == "" ){ 805 ampm = null 806 } 807 808 if ( hour < 0 || hour > 24 ){ //FixIn: 8.3.1.1 809 return false; //("<?php _e('Hour must be between 1 and 12. (or 0 and 23 for military time)'); ?>"); 810 } 811 if ( hour > 12 && ampm != null ){ 812 return false; //("<?php _e('You can not specify AM or PM for military time.'); ?>"); 813 } 814 if ( minute < 0 || minute > 59 ){ 815 return false; //("<?php _e('Minute must be between 0 and 59.'); ?>"); 816 } 817 return true; 818 } 819 820 821 // Disable Booked Time Slots in selectbox 822 function bkDisableBookedTimeSlots( all_dates, bk_type ){ 823 824 var inst = jQuery.datepick._getInst( document.getElementById( 'calendar_booking' + bk_type ) ); 825 var td_class; 826 827 var time_slot_field_name = 'select[name="rangetime' + bk_type + '"]'; 828 var time_slot_field_name2 = 'select[name="rangetime' + bk_type + '[]"]'; 829 830 var start_time_slot_field_name = 'select[name="starttime' + bk_type + '"]'; 831 var start_time_slot_field_name2 = 'select[name="starttime' + bk_type + '[]"]'; 832 833 // HERE WE WILL DISABLE ALL OPTIONS IN RANGE TIME INTERVALS FOR SINGLE DAYS SELECTIONS FOR THAT DAYS WHERE HOURS ALREADY BOOKED 834 //here is not range selections 835 all_dates = get_first_day_of_selection( all_dates ); 836 if ( (bk_days_selection_mode == 'single') || (true) ){ // Only single day selections here 837 838 var current_single_day_selections = all_dates.split( '.' ); 839 td_class = (current_single_day_selections[ 1 ] * 1) + '-' + (current_single_day_selections[ 0 ] * 1) + '-' + (current_single_day_selections[ 2 ] * 1); 840 var times_array = []; 841 842 jQuery( time_slot_field_name + ' option:disabled,' + time_slot_field_name2 + ' option:disabled,' + start_time_slot_field_name + ' option:disabled,' + start_time_slot_field_name2 + ' option:disabled' ).removeClass( 'booked' ); // Remove class "booked" 843 jQuery( time_slot_field_name + ' option:disabled,' + time_slot_field_name2 + ' option:disabled,' + start_time_slot_field_name + ' option:disabled,' + start_time_slot_field_name2 + ' option:disabled' ).removeAttr( 'disabled' ); // Make active all times 844 845 846 if ( jQuery( time_slot_field_name + ',' + time_slot_field_name2 + ',' + start_time_slot_field_name + ',' + start_time_slot_field_name2 ).length == 0 ) return; // WE DO NOT HAVE RANGE SELECTIONS AT THIS FORM SO JUST RETURN 847 848 var range_time_object = jQuery( time_slot_field_name + ' option:first,' + time_slot_field_name2 + ' option:first,' + start_time_slot_field_name + ' option:first,' + start_time_slot_field_name2 + ' option:first' ); 849 if ( range_time_object == undefined ) return; // WE DO NOT HAVE RANGE SELECTIONS AT THIS FORM SO JUST RETURN 850 851 // Get dates and time from aproved dates 852 if ( typeof(date_approved[ bk_type ]) !== 'undefined' ) 853 if ( typeof(date_approved[ bk_type ][ td_class ]) !== 'undefined' ){ 854 if ( (date_approved[ bk_type ][ td_class ][ 0 ][ 3 ] != 0) || (date_approved[ bk_type ][ td_class ][ 0 ][ 4 ] != 0) ){ 855 for ( i = 0; i < date_approved[ bk_type ][ td_class ].length; i++ ){ 856 h = date_approved[ bk_type ][ td_class ][ i ][ 3 ]; 857 if ( h < 10 ) h = '0' + h; 858 if ( h == 0 ) h = '00'; 859 m = date_approved[ bk_type ][ td_class ][ i ][ 4 ]; 860 if ( m < 10 ) m = '0' + m; 861 if ( m == 0 ) m = '00'; 862 s = date_approved[ bk_type ][ td_class ][ i ][ 5 ]; 863 if ( s == 2 ) s = '02'; 864 times_array[ times_array.length ] = [ h, m, s ]; 865 } 866 } 867 } 868 869 // Get dates and time from pending dates 870 if ( typeof(date2approve[ bk_type ]) !== 'undefined' ) 871 if ( typeof(date2approve[ bk_type ][ td_class ]) !== 'undefined' ) 872 if ( (date2approve[ bk_type ][ td_class ][ 0 ][ 3 ] != 0) || (date2approve[ bk_type ][ td_class ][ 0 ][ 4 ] != 0) ) //check for time here 873 { 874 for ( i = 0; i < date2approve[ bk_type ][ td_class ].length; i++ ){ 875 h = date2approve[ bk_type ][ td_class ][ i ][ 3 ]; 876 if ( h < 10 ) h = '0' + h; 877 if ( h == 0 ) h = '00'; 878 m = date2approve[ bk_type ][ td_class ][ i ][ 4 ]; 879 if ( m < 10 ) m = '0' + m; 880 if ( m == 0 ) m = '00'; 881 s = date2approve[ bk_type ][ td_class ][ i ][ 5 ]; 882 if ( s == 2 ) s = '02'; 883 times_array[ times_array.length ] = [ h, m, s ]; 884 } 885 } 886 887 // Check about situations, when we have end time without start time (... - 09:00) or start time without end time (21:00 - ...) 888 times_array.sort(); 889 if ( times_array.length > 0 ){ 890 s = parseInt( times_array[ 0 ][ 2 ] ); 891 if ( s == 2 ){ 892 times_array[ times_array.length ] = [ '00', '00', '01' ]; 893 times_array.sort(); 894 } 895 s = parseInt( times_array[ (times_array.length - 1) ][ 2 ] ); 896 if ( s == 1 ){ 897 times_array[ times_array.length ] = [ '23', '59', '02' ]; 898 times_array.sort(); 899 } 900 } 901 902 var removed_time_slots = is_time_slot_booked_for_this_time_array( bk_type, times_array, td_class ); 903 var my_time_value = jQuery( time_slot_field_name + ' option,' + time_slot_field_name2 + ' option,' + start_time_slot_field_name + ' option,' + start_time_slot_field_name2 + ' option' ); 904 905 for ( j = 0; j < my_time_value.length; j++ ){ 906 if ( wpdev_in_array( removed_time_slots, j ) ){ 907 jQuery( time_slot_field_name + ' option:eq(' + j + '),' + time_slot_field_name2 + ' option:eq(' + j + '),' + start_time_slot_field_name + ' option:eq(' + j + '),' + start_time_slot_field_name2 + ' option:eq(' + j + ')' ).attr( 'disabled', 'disabled' ); // Make disable some options 908 jQuery( time_slot_field_name + ' option:eq(' + j + '),' + time_slot_field_name2 + ' option:eq(' + j + '),' + start_time_slot_field_name + ' option:eq(' + j + '),' + start_time_slot_field_name2 + ' option:eq(' + j + ')' ).addClass( 'booked' ); // Add "booked" CSS class 909 if ( jQuery( time_slot_field_name + ' option:eq(' + j + '),' + time_slot_field_name2 + ' option:eq(' + j + '),' + start_time_slot_field_name + ' option:eq(' + j + '),' + start_time_slot_field_name2 + ' option:eq(' + j + ')' ).attr( 'selected' ) ){ // iF THIS ELEMENT IS SELECTED SO REMOVE IT FROM THIS TIME 910 jQuery( time_slot_field_name + ' option:eq(' + j + '),' + time_slot_field_name2 + ' option:eq(' + j + '),' + start_time_slot_field_name + ' option:eq(' + j + '),' + start_time_slot_field_name2 + ' option:eq(' + j + ')' ).removeAttr( 'selected' ); 911 912 if ( IEversion_4_bk == 7 ){ // Emulate disabling option in selectboxes for IE7 - its set selected option, which is not disabled 913 914 var rangetime_element = document.getElementsByName( "rangetime" + bk_type ); 915 if ( typeof(rangetime_element) != 'undefined' && rangetime_element != null ){ 916 set_selected_first_not_disabled_option_IE7( document.getElementsByName( "rangetime" + bk_type )[ 0 ] ); 917 } 918 919 var start_element = document.getElementsByName( "starttime" + bk_type ); 920 if ( typeof(start_element) != 'undefined' && start_element != null ){ 921 set_selected_first_not_disabled_option_IE7( document.getElementsByName( "starttime" + bk_type )[ 0 ] ); 922 } 923 924 } 925 } 926 } 927 } 928 929 if ( IEversion_4_bk == 7 ){ // Emulate disabling option in selectboxes for IE7 - its set grayed text options, which is disabled 930 emulate_disabled_options_to_gray_IE7( "rangetime" + bk_type ); 931 emulate_disabled_options_to_gray_IE7( "starttime" + bk_type ); 932 } 933 } 934 935 } 936 937 938// Check if this IE and get version of IE otherwise setversion of IE to 0 939 var isIE_4_bk = (navigator.appName == "Microsoft Internet Explorer"); 940 var IEversion_4_bk = navigator.appVersion; 941 if ( isIE_4_bk ){ 942 IEversion_4_bk = parseInt( IEversion_4_bk.substr( IEversion_4_bk.indexOf( "MSIE" ) + 4 ) ); 943 } else { 944 IEversion_4_bk = 0; 945 } 946 947 948// IE7 select box emulate functions for disabling select boxes: 949 if ( IEversion_4_bk == 7 ){ 950 951 window.onload = function (){ 952 if ( document.getElementsByTagName ){ 953 var s = document.getElementsByTagName( "select" ); 954 955 if ( s.length > 0 ){ 956 window.select_current = new Array(); 957 958 for ( var i = 0, select; select = s[ i ]; i++ ){ 959 select.onfocus = function (){ 960 window.select_current[ this.id ] = this.selectedIndex; 961 } 962 select.onchange = function (){ 963 set_selected_previos_selected_option_IE7( this ); 964 } 965 emulate_disabled_options_to_gray_IE7( select.name ); 966 } 967 } 968 } 969 } 970 971 function set_selected_previos_selected_option_IE7( e ){ 972 if ( e.options[ e.selectedIndex ].disabled ){ 973 e.selectedIndex = window.select_current[ e.id ]; 974 } 975 } 976 977 function set_selected_first_not_disabled_option_IE7( e ){ 978 979 if ( e.options[ e.selectedIndex ].disabled ){ 980 for ( var i = 0, option; option = e.options[ i ]; i++ ){ 981 if ( !option.disabled ){ 982 e.selectedIndex = i; 983 return 0; 984 } 985 } 986 } 987 return 0; 988 } 989 990 function emulate_disabled_options_to_gray_IE7( ename ){ 991 992 jQuery( 'select[name="' + ename + '"] option,select[name="' + ename + '[]"] option' ).each( function ( index ){ 993 if ( jQuery( this ).prop( 'disabled' ) ){ 994 jQuery( this ).css( 'color', 'graytext' ); 995 } else { 996 jQuery( this ).css( 'color', 'menutext' ); 997 } 998 } ); 999 /* 1000 for (var i=0, option; option = e.options[i]; i++) { 1001 1002 if (option.disabled) { option.style.color = "graytext";} 1003 else { option.style.color = "menutext";} 1004 }*/ 1005 } 1006 } 1007 1008 1009 function is_time_slot_booked_for_this_time_array( bk_type, times_array, td_class ) { 1010 1011 var time_slot_field_name = 'select[name="rangetime' + bk_type + '"]'; 1012 var time_slot_field_name2 = 'select[name="rangetime' + bk_type + '[]"]'; 1013 // Get rangetime element from possible conditional section //FixIn: 7.0.Beta.11 1014 if ( typeof(wpbc_get_conditional_section_id_for_weekday) == 'function' ){ 1015 var conditional_field_element_id = wpbc_get_conditional_section_id_for_weekday( td_class, bk_type ); 1016 if ( conditional_field_element_id !== false ){ 1017 time_slot_field_name = conditional_field_element_id + ' ' + 'select[name="rangetime' + bk_type + '"]'; 1018 time_slot_field_name2 = conditional_field_element_id + ' ' + 'select[name="rangetime' + bk_type + '[]"]'; 1019 } 1020 } 1021 1022 var start_time_slot_field_name = 'select[name="starttime' + bk_type + '"]'; 1023 var start_time_slot_field_name2 = 'select[name="starttime' + bk_type + '[]"]'; 1024 // Get rangetime element from possible conditional section //FixIn: 7.0.Beta.11 1025 if ( typeof(wpbc_get_conditional_section_id_for_weekday) == 'function' ){ 1026 var conditional_field_element_id = wpbc_get_conditional_section_id_for_weekday( td_class, bk_type ); 1027 if ( conditional_field_element_id !== false ){ 1028 start_time_slot_field_name = conditional_field_element_id + ' ' + 'select[name="starttime' + bk_type + '"]'; 1029 start_time_slot_field_name2 = conditional_field_element_id + ' ' + 'select[name="starttime' + bk_type + '[]"]'; 1030 } 1031 } 1032 1033 1034 times_array.sort(); 1035 var my_time_value = ''; 1036 var j; 1037 var bk_time_slot_selection = ''; 1038 var minutes_booked; 1039 var minutes_slot; 1040 var my_range_time; 1041 1042 var removed_time_slots = []; 1043 1044 if ( times_array.length > 0 ){ //FixIn: 6.1.1.6 1045 //Situation when we have first time option as End time. So we need to add start time to the midnight 1046 if ( parseInt( times_array[ 0 ][ 2 ] ) == 2 ){ 1047 var new_times_array = []; 1048 new_times_array[ new_times_array.length ] = [ '00', '00', '01' ]; 1049 for ( var i = 0; i < times_array.length; i++ ){ 1050 new_times_array[ new_times_array.length ] = times_array[ i ]; 1051 } 1052 times_array = new_times_array; 1053 } 1054 //Situation when we have last time option as Start time. So we need to add End time to end of this times 1055 if ( parseInt( times_array[ (times_array.length - 1) ][ 2 ] ) == 1 ){ 1056 times_array[ times_array.length ] = [ '23', '59', '02' ]; 1057 } 1058 } 1059 1060 1061 for ( var i = 0; i < times_array.length; i++ ){ // s = 2 - end time, s = 1 - start time 1062 var s = parseInt( times_array[ i ][ 2 ] ); 1063 1064 if ( i > 0 ){ 1065 1066 if ( s == 2 ){ 1067 my_range_time = times_array[ i - 1 ][ 0 ] + ':' + times_array[ i - 1 ][ 1 ] + ' - ' + times_array[ i ][ 0 ] + ':' + times_array[ i ][ 1 ]; 1068 my_time_value = jQuery( time_slot_field_name + ' option,' + time_slot_field_name2 + ' option,' + start_time_slot_field_name + ' option,' + start_time_slot_field_name2 + ' option' ); 1069 1070 for ( j = 0; j < my_time_value.length; j++ ){ 1071 1072 if ( my_time_value[ j ].value == my_range_time ){ // Mark as disable this option 1073 1074 removed_time_slots[ removed_time_slots.length ] = j; 1075 //return true; 1076 1077 } else { 1078 // We will recheck here if, may be some interval here inside of already booked intervals, so then we need to disable it. 1079 bk_time_slot_selection = my_time_value[ j ].value; 1080 var is_time_range = bk_time_slot_selection.indexOf( "-" ); 1081 1082 if ( is_time_range > -1 ){ // Timeslots 1083 bk_time_slot_selection = bk_time_slot_selection.split( '-' ); 1084 bk_time_slot_selection[ 0 ] = jQuery.trim( bk_time_slot_selection[ 0 ] ); 1085 bk_time_slot_selection[ 1 ] = jQuery.trim( bk_time_slot_selection[ 1 ] ); 1086 1087 bk_time_slot_selection[ 0 ] = bk_time_slot_selection[ 0 ].split( ':' ); 1088 bk_time_slot_selection[ 1 ] = bk_time_slot_selection[ 1 ].split( ':' ); 1089 1090 // Get only minutes 1091 minutes_booked = [ (parseInt( times_array[ i - 1 ][ 0 ] * 60 ) + parseInt( times_array[ i - 1 ][ 1 ] )), (parseInt( times_array[ i ][ 0 ] * 60 ) + parseInt( times_array[ i ][ 1 ] )) ]; 1092 minutes_slot = [ (parseInt( bk_time_slot_selection[ 0 ][ 0 ] * 60 ) + parseInt( bk_time_slot_selection[ 0 ][ 1 ] )), (parseInt( bk_time_slot_selection[ 1 ][ 0 ] * 60 ) + parseInt( bk_time_slot_selection[ 1 ][ 1 ] )) ]; 1093 1094 1095 if ( 1096 ((minutes_booked[ 0 ] >= minutes_slot[ 0 ]) && (minutes_booked[ 0 ] < minutes_slot[ 1 ])) || 1097 ((minutes_booked[ 1 ] > minutes_slot[ 0 ]) && (minutes_booked[ 1 ] <= minutes_slot[ 1 ])) 1098 || 1099 ((minutes_slot[ 0 ] >= minutes_booked[ 0 ]) && (minutes_slot[ 0 ] < minutes_booked[ 1 ])) || 1100 ((minutes_slot[ 1 ] > minutes_booked[ 0 ]) && (minutes_slot[ 1 ] <= minutes_booked[ 1 ])) 1101 ){ 1102 removed_time_slots[ removed_time_slots.length ] = j; 1103 //return true; 1104 } 1105 } else { // Just some time (like start time) 1106 bk_time_slot_selection = bk_time_slot_selection.split( ':' ); 1107 1108 // Get only minutes 1109 minutes_booked = [ (parseInt( times_array[ i - 1 ][ 0 ] * 60 ) + parseInt( times_array[ i - 1 ][ 1 ] )), (parseInt( times_array[ i ][ 0 ] * 60 ) + parseInt( times_array[ i ][ 1 ] )) ]; 1110 minutes_slot = [ (parseInt( bk_time_slot_selection[ 0 ] * 60 ) + parseInt( bk_time_slot_selection[ 1 ] )) ]; 1111 if ( 1112 ((minutes_slot[ 0 ] >= minutes_booked[ 0 ]) && (minutes_slot[ 0 ] < minutes_booked[ 1 ])) 1113 ){ 1114 removed_time_slots[ removed_time_slots.length ] = j; 1115 //return true; 1116 } 1117 1118 } 1119 1120 } 1121 1122 } 1123 } 1124 } 1125 1126 } 1127 1128 return removed_time_slots; 1129 } 1130 1131 1132 1133 // Times 1134 function isDayFullByTime( bk_type, td_class ) { 1135 1136 var times_array = []; 1137 var time_slot_field_name = 'select[name="rangetime' + bk_type + '"]'; 1138 var time_slot_field_name2 = 'select[name="rangetime' + bk_type + '[]"]'; 1139 1140 // Get rangetime element from possible conditional section //FixIn: 5.4.5.2 1141 if( typeof( wpbc_get_conditional_section_id_for_weekday ) == 'function' ) { 1142 var conditional_field_element_id = wpbc_get_conditional_section_id_for_weekday( td_class, bk_type ); 1143 if ( conditional_field_element_id !== false ) { 1144 time_slot_field_name = conditional_field_element_id + ' ' + 'select[name="rangetime' + bk_type + '"]'; 1145 time_slot_field_name2 = conditional_field_element_id + ' ' + 'select[name="rangetime' + bk_type + '[]"]'; 1146 } 1147 } 1148 1149 //console.log( time_slot_field_name, time_slot_field_name2 ); 1150 1151 // Get dates and time from aproved dates 1152 if(typeof(date_approved[ bk_type ]) !== 'undefined') 1153 if(typeof(date_approved[ bk_type ][ td_class ]) !== 'undefined') { 1154 for ( i=
11540; i< date_approved[ bk_type ][ td_class ].length; i++){ 1155 if( ( date_approved[ bk_type ][ td_class ][0][3] != 0) || ( date_approved[ bk_type ][ td_class ][0][4] != 0) ) { 1156 h = date_approved[ bk_type ][ td_class ][i][3];if (h < 10) h = '0' + h;if (h == 0) h = '00'; 1157 m = date_approved[ bk_type ][ td_class ][i][4];if (m < 10) m = '0' + m;if (m == 0) m = '00'; 1158 s = date_approved[ bk_type ][ td_class ][i][5];if (s == 2) s = '02'; 1159 times_array[ times_array.length ] = [h,m,s]; 1160 } 1161 } 1162 } 1163 1164 // Get dates and time from pending dates 1165 if(typeof( date2approve[ bk_type ]) !== 'undefined') 1166 if(typeof( date2approve[ bk_type ][ td_class ]) !== 'undefined') 1167 for ( i=0; i< date2approve[ bk_type ][ td_class ].length; i++){ 1168 if( ( date2approve[ bk_type ][ td_class ][0][3] != 0) || ( date2approve[ bk_type ][ td_class ][0][4] != 0) ) { 1169 h = date2approve[ bk_type ][ td_class ][i][3];if (h < 10) h = '0' + h;if (h == 0) h = '00'; 1170 m = date2approve[ bk_type ][ td_class ][i][4];if (m < 10) m = '0' + m;if (m == 0) m = '00'; 1171 s = date2approve[ bk_type ][ td_class ][i][5];if (s == 2) s = '02'; 1172 times_array[ times_array.length ] = [h,m,s]; 1173 } 1174 } 1175 1176 times_array.sort(); 1177 1178 //Customization Bence - make day with start and end time - unavailable 1179 //var is_start_here = false; 1180 //var is_end_here = false; 1181 //for (var jj=0; jj< times_array.length; jj++){ 1182 // if (times_array[jj][2]=='01' ) is_start_here = true; 1183 // if (times_array[jj][2]=='02' ) is_end_here = true; 1184 //} 1185 //if ( (is_start_here) && (is_end_here) ) return true; 1186 1187 // check here according time ranges selection 1188 // and check all slots for reserVATION. 1189 // IF ALL SLOTS ARE RESERVED, INSIDE OF times_array 1190 // SO THEN RETURN TRUE 1191 1192 //var is_element_exist = jQuery( time_slot_field_name+','+time_slot_field_name2 ).length; //FixIn:6.1.1.6 - Previously was this line 1193 var start_time_fields = 'select[name="starttime' + bk_type + '"]'; //FixIn:6.1.1.6 1194 var start_time_fields2 = 'select[name="starttime' + bk_type + '[]"]'; //FixIn:6.1.1.6 1195 var is_element_exist = jQuery( time_slot_field_name + ',' + time_slot_field_name2 + ',' + start_time_fields + ',' + start_time_fields2 ).length; //FixIn:6.1.1.6 1196 1197 if (is_element_exist) { 1198 var my_timerange_value = jQuery( time_slot_field_name + ' option,'+time_slot_field_name2 + ' option'); 1199 var my_st_en_times; 1200 var my_temp_time; 1201 var times_ranges_array=[]; 1202 1203 for (var j=0; j< my_timerange_value.length; j++){ 1204 1205 my_st_en_times = my_timerange_value[j].value.split(' - '); 1206 1207 my_temp_time = my_st_en_times[0].split(':'); 1208 times_ranges_array[ times_ranges_array.length ] = [ my_temp_time[0], my_temp_time[1], '01' ]; //Start time 1209 1210 my_temp_time = my_st_en_times[1].split(':'); 1211 times_ranges_array[ times_ranges_array.length ] = [ my_temp_time[0], my_temp_time[1], '02' ]; //End time 1212 } 1213 1214 // check if all time slots from the selectbox are the booked inside of this day. Simple checking for the same 1215 if (times_array.length == times_ranges_array.length) { 1216 var is_all_same = true; 1217 for ( var i=0; i< times_array.length; i++){ 1218 if ( 1219 ( times_array[i][0] != times_ranges_array[i][0] ) || 1220 ( times_array[i][1] != times_ranges_array[i][1] ) || 1221 ( times_array[i][2] != times_ranges_array[i][2] ) 1222 ) 1223 is_all_same = false; 1224 } 1225 if ( is_all_same) return true; 1226 } 1227 1228 // Star Time checking //FixIn:6.1.1.6 1229 var my_start_time_options = jQuery( start_time_fields + ' option,'+start_time_fields2 + ' option'); 1230 1231 if ( ( my_start_time_options.length > 0 ) 1232 && ( ( bk_days_selection_mode == 'single' ) || ( bk_days_selection_mode == 'multiple' ) ) 1233 ){ // Only if range selections exist and we are have single days selections 1234 var removed_time_slots = is_time_slot_booked_for_this_time_array( bk_type, times_array, td_class ); 1235 var some_exist_time_slots = []; 1236 var my_time_value = jQuery( start_time_fields + ' option,'+start_time_fields2 + ' option'); 1237 1238 for ( j=0; j< my_time_value.length; j++){ 1239 1240 if ( wpdev_in_array( removed_time_slots, j ) ) { 1241 } else { 1242 some_exist_time_slots[some_exist_time_slots.length] = j; 1243 } 1244 } 1245 if (some_exist_time_slots.length == 0 ) return true; 1246 } 1247 // End //FixIn:6.1.1.6 End fix 1248 1249 //Check may be its not possible to select any other time slots from the selectbox, because its already booked, sothen mark this day as booked. 1250 if ( ( my_timerange_value.length > 0 ) 1251 && ( ( bk_days_selection_mode == 'single' ) || ( bk_days_selection_mode == 'multiple' ) ) 1252 ){ // Only if range selections exist and we are have single days selections 1253 var removed_time_slots = is_time_slot_booked_for_this_time_array( bk_type, times_array, td_class ); 1254 var some_exist_time_slots = []; 1255 var my_time_value = jQuery( time_slot_field_name + ' option,'+time_slot_field_name2 + ' option'); 1256 1257 for ( j=0; j< my_time_value.length; j++){ 1258 1259 if ( wpdev_in_array( removed_time_slots, j ) ) { 1260 1261 } else { 1262 some_exist_time_slots[some_exist_time_slots.length] = j; 1263 } 1264 } 1265 if (some_exist_time_slots.length == 0 ) return true; 1266 } 1267 1268 } 1269 1270 for ( var i=0; i< times_array.length; i++){ // s = 2 - end time, s = 1 - start time 1271 s = parseInt( times_array[i][2] ); 1272 1273 if (i == 0) 1274 if (s !== 2) {return false;} // Its not start at the start of day 1275 1276 if ( i > 0 ) { 1277 1278 if ( s == 1 ) 1279 if ( !( ( times_array[i-1][0] == times_array[i][0] ) && ( times_array[i-1][1] == times_array[i][1] ) ) ) { 1280 return false; // previos time is not equal to current so we have some free interval 1281 } 1282 1283 } 1284 1285 if (i == ( times_array.length-1)) 1286 if (s !== 1) {return false;} // Its not end at the end of day 1287 1288 } 1289 return true; 1290 }
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.