1var is_booking_without_payment = false; 2var date_approved = []; 3var date2approve = []; 4var date_admin_blank = []; 5var dates_additional_info = []; 6var is_all_days_available = []; 7var avalaibility_filters = []; 8var is_show_cost_in_tooltips = false; 9var is_show_cost_in_date_cell = false; 10var is_show_availability_in_tooltips = false; 11var global_avalaibility_times = []; 12var numbb = 0; 13//var is_use_visitors_number_for_availability; 14var timeoutID_of_thank_you_page = null; 15 16 17/** 18 * Booking Calendar - JavaScript Settings 19 * 20 * Example or redefine some settings: 21 * <script type="text/javascript"> wpbc_settings.set_option( 'pending_days_selectable', true ); </script> 22 * [booking type=1] 23 * 24 //FixIn: 8.6.1.18 25 */ 26var wpbc_settings = (function ( obj, $) { 27 28 // Define private property 29 var p_options = obj.options = obj.options || []; 30 31 p_options['pending_days_selectable'] = false; 32 33 // Get Option 34 obj.get_option = function ( item_id ) { 35 36 return p_options[ item_id ]; 37 }; 38 39 // Set Option 40 obj.set_option = function ( item_id, item_value ) { 41 42 p_options[ item_id ] = item_value; 43 }; 44 45 return obj; 46 47}(wpbc_settings || {}, jQuery )); 48 49 50/** 51 * Calendar Init 52 * 53 * @param bk_type - resource ID 54 * @param date_approved_par 55 * @param my_num_month 56 * @param start_day_of_week 57 * @param start_bk_month 58 * @returns {boolean} 59 */ 60function init_datepick_cal(bk_type, date_approved_par, my_num_month, start_day_of_week, start_bk_month ){ 61 62 if ( jQuery('#calendar_booking'+ bk_type).hasClass('hasDatepick') == true ) { // If the calendar with the same Booking resource is activated already, then exist. 63 return false; 64 } 65 66 var cl = document.getElementById('calendar_booking'+ bk_type);if (cl === null) return; // Get calendar instance and exit if its not exist 67 68 date_approved[ bk_type ] = date_approved_par; 69 70 var isRangeSelect = false; 71 var bkMultiDaysSelect = 365; 72 if ( bk_days_selection_mode==='dynamic' ) { isRangeSelect = true; bkMultiDaysSelect = 0; } 73 if ( bk_days_selection_mode==='single' ) bkMultiDaysSelect = 0; 74 75 var bkMinDate = 0; 76 var bkMaxDate = booking_max_monthes_in_calendar; 77 78 var is_this_admin = false; 79 if ( ( location.href.indexOf('page=wpbc-new') != -1 ) 80 && ( location.href.indexOf('booking_hash') != -1 ) // Comment this line for ability to add booking in past days at Booking > Add booking page. 81 ){ 82 is_this_admin = true; 83 bkMinDate = null; 84 bkMaxDate = null; 85 } 86 87 function click_on_cal_td(){ 88 if(typeof( selectDayPro ) == 'function') {selectDayPro( bk_type);} 89 } 90 91 function selectDay(date) { 92 93 // Set unselectable, if only Availability Calendar here (and we do not insert Booking form by mistake). 94 var is_calendar_booking_unselectable = jQuery( '#calendar_booking_unselectable' + bk_type ); //FixIn: 8.0.1.2 95 var is_booking_form_also = jQuery( '#booking_form_div' + bk_type ); 96 if ( ( is_calendar_booking_unselectable.length > 0 ) && ( is_booking_form_also.length <= 0 ) ){ 97 98 wpbc_unselect_all_days( bk_type ); 99 jQuery('.wpbc_only_calendar .popover_calendar_hover').remove(); //Hide all opened popovers 100 return false; 101 } //FixIn: 8.0.1.2 end 102 103 //console.log( jQuery.fn.popover.Constructor.VERSION ); // Check if this minimum BS version, and then proced 104 if ( 'function' === typeof( jQuery( ".datepick-days-cell" ).popover ) ){ //FixIn: 7.0.1.2 - 2016-12-10 105 jQuery( '.datepick-days-cell' ).popover( 'hide' ); 106 } 107 108 jQuery( '#date_booking' + bk_type ).val( date ); 109 110 if ( typeof( bkDisableBookedTimeSlots ) == 'function' ){ 111 if(typeof( prepare_tooltip ) == 'function') {setTimeout("prepare_tooltip("+bk_type+");",1000);} 112 // HERE WE WILL DISABLE ALL OPTIONS IN RANGE TIME INTERVALS FOR SINGLE DAYS SELECTIONS FOR THAT DAYS WHERE HOURS ALREADY BOOKED 113 bkDisableBookedTimeSlots( jQuery( '#date_booking' + bk_type ).val(), bk_type ); 114 }
115 if ( typeof( selectDayPro ) == 'function' ){ 116 selectDayPro( date, bk_type ); 117 } 118 jQuery( ".booking_form_div" ).trigger( "date_selected", [ bk_type, date ] ); 119 } 120 121 function hoverDay(value, date){ 122 123 if ( typeof( hoverDayTime ) == 'function' ){ 124 hoverDayTime( value, date, bk_type ); 125 } 126 127 if ( (location.href.indexOf( 'page=wpbc' ) == -1) || 128 (location.href.indexOf( 'page=wpbc-new' ) > 0) ){ // Do not show it (range) at the main admin page 129 if ( typeof( hoverDayPro ) == 'function' ){ 130 hoverDayPro( value, date, bk_type ); 131 } 132 } 133 134 var is_calendar_booking_unselectable = jQuery( '#calendar_booking_unselectable' + bk_type ); //FixIn: 8.0.1.2 135 var is_booking_form_also = jQuery( '#booking_form_div' + bk_type ); 136 // Set unselectable, if only Availability Calendar here (and we do not insert Booking form by mistake). 137 if ( ( is_calendar_booking_unselectable.length == 1 ) && ( is_booking_form_also.length != 1 ) ){ 138 jQuery( '#calendar_booking' + bk_type + ' .datepick-days-cell-over' ).removeClass( 'datepick-days-cell-over' ); // clear all highlight days selections 139 jQuery( '.wpbc_only_calendar #calendar_booking' + bk_type + ' .datepick-days-cell, ' + 140 '.wpbc_only_calendar #calendar_booking' + bk_type + ' .datepick-days-cell a' ).css( 'cursor', 'default' ); 141 return false; 142 } //FixIn: 8.0.1.2 end 143 } 144 145 function applyCSStoDays(date ){ 146 var class_day = (date.getMonth()+1) + '-' + date.getDate() + '-' + date.getFullYear(); 147 var additional_class = ' wpbc_weekday_' + date.getDay() + ' '; 148 149 //Block today date if current today time older than 18:00 150 if ( ( false ) && ( date.getDate() == (wpdev_bk_today[2] ) ) && ( date.getMonth() == (wpdev_bk_today[1]-1) ) &&( date.getFullYear() == (wpdev_bk_today[0]) ) ){ 151 var my_test_date1 = new Date( wpdev_bk_today[ 0 ], (wpdev_bk_today[ 1 ] - 1), wpdev_bk_today[ 2 ], wpdev_bk_today[ 3 ], wpdev_bk_today[ 4 ], 0 ); //Get today 152 var my_test_date2 = new Date( wpdev_bk_today[ 0 ], (wpdev_bk_today[ 1 ] - 1), wpdev_bk_today[ 2 ], 18, 0, 0 ); //Today 18:00 153 if ( my_test_date2.getTime() < my_test_date1.getTime() ) 154 return [ false, 'cal4date-' + class_day + ' date_user_unavailable' ]; 155 } 156 157 if(typeof( prices_per_day ) !== 'undefined') 158 if(typeof( prices_per_day[bk_type] ) !== 'undefined') 159 if(typeof( prices_per_day[bk_type][class_day] ) !== 'undefined') { 160 additional_class += ' rate_'+prices_per_day[bk_type][class_day]; 161 } 162 163 // define season filter names as classes 164 if(typeof( wpdev_bk_season_filter ) !== 'undefined') 165 if(typeof( wpdev_bk_season_filter[class_day] ) !== 'undefined') { 166 additional_class += ' '+wpdev_bk_season_filter[class_day].join(' '); 167 } 168 169 if (is_this_admin == false) { 170 var my_test_date = new Date( wpdev_bk_today[0],(wpdev_bk_today[1]-1), wpdev_bk_today[2] ,0,0,0 ); //Get today 171 if ( (days_between( date, my_test_date)) < block_some_dates_from_today ) 172 return [false, 'cal4date-' + class_day +' date_user_unavailable']; 173 174 if( typeof( wpbc_available_days_num_from_today ) !== 'undefined') 175 if ( parseInt( '0' + wpbc_available_days_num_from_today ) > 0 ) 176 if ( (days_between( date, my_test_date)) > parseInt( '0' + wpbc_available_days_num_from_today ) ) 177 return [false, 'cal4date-' + class_day +' date_user_unavailable']; 178 } 179 180 if (typeof( is_this_day_available ) == 'function') { 181 var is_day_available = is_this_day_available( date, bk_type); 182 var season_filter = ''; //FixIn: 6.0.1.8 183 if ( is_day_available instanceof Array ) { 184 season_filter = ' season_filter_id_' + is_day_available[1]; 185 is_day_available = is_day_available[0]; 186 } 187 if (! is_day_available) {return [false, 'cal4date-' + class_day +' date_user_unavailable ' + season_filter ];} 188 } 189 190 // Time availability 191 if (typeof( check_global_time_availability ) == 'function') {check_global_time_availability( date, bk_type );} 192 193 var blank_admin_class_day = ''; 194 if(typeof(date_admin_blank[ bk_type ]) !== 'undefined') 195 if(typeof(date_admin_blank[ bk_type ][ class_day ]) !== 'undefined') { 196 blank_admin_class_day = ' date_admin_blank '; 197 } 198 199 // Check availability per day for BL 200 var reserved_days_count = 1; 201 if(typeof(availability_per_day) !== 'undefined') 202 if(typeof(availability_per_day[ bk_type ]) !== 'undefined') 203 if(typeof(availability_per_day[ bk_type ][ class_day ]) !== 'undefined') { 204 reserved_days_count = parseInt( availability_per_day[ bk_type ][ class_day ] );} 205 206 // Number of Check In Dates for BL 207 var checkin_days_count = [0 ,0]; 208 if(typeof(wpbc_check_in_dates) !== 'undefined') 209 if(typeof(wpbc_check_in_dates[ bk_type ]) !== 'undefined') 210 if(typeof(wpbc_check_in_dates[ bk_type ][ class_day ]) !== 'undefined') { 211 // [ Number of check in bookings, Pending or Approved status ] 212 checkin_days_count = [ wpbc_check_in_dates[ bk_type ][ class_day ][ 0 ] , wpbc_check_in_dates[ bk_type ][ class_day ][ 1 ] ]; 213 } 214 215 // Number of Check Out Dates for BL 216 var checkout_days_count = [0 ,0]; 217 if(typeof(wpbc_check_out_dates) !== 'undefined') 218 if(typeof(wpbc_check_out_dates[ bk_type ]) !== 'undefined') 219 if(typeof(wpbc_check_out_dates[ bk_type ][ class_day ]) !== 'undefined') { 220 // [ Number of check Out bookings, Pending or Approved status ] 221 checkout_days_count = [ wpbc_check_out_dates[ bk_type ][ class_day ][ 0 ] , wpbc_check_out_dates[ bk_type ][ class_day ][ 1 ] ]; 222 } 223 224 // Booked both check in/out dates in the same child resources 225 var both_check_in_out_num = 0; 226 if ( typeof( getNumberClosedCheckInOutDays ) == 'function' ) { 227 both_check_in_out_num = getNumberClosedCheckInOutDays( bk_type, class_day ); 228 } 229 230 231 // we have 0 available at this day - Only for resources, which have childs 232 if ( wpdev_in_array( parent_booking_resources, bk_type ) ) 233 if (reserved_days_count <= 0) { 234 if(typeof(date2approve[ bk_type ]) !== 'undefined') 235 if(typeof(date2approve[ bk_type ][ class_day ]) !== 'undefined') 236 return [false, 'cal4date-' + class_day +' date2approve date_unavailable_for_all_childs ' + blank_admin_class_day]; 237 return [false, 'cal4date-' + class_day +' date_approved date_unavailable_for_all_childs ' + blank_admin_class_day]; 238 } 239 240 var th=0; 241 var tm=0; 242 var ts=0; 243 var time_return_value = false;
244 245 var is_set_pending_days_selectable = wpbc_settings.get_option( 'pending_days_selectable' ); // set pending days selectable //FixIn: 8.6.1.18 246 247 // Select dates which need to approve, its exist only in Admin 248 if(typeof(date2approve[ bk_type ]) !== 'undefined') 249 if(typeof(date2approve[ bk_type ][ class_day ]) !== 'undefined') { 250 251 for (var ia=0;ia<date2approve[ bk_type ][ class_day ].length;ia++) { 252 253 th = date2approve[ bk_type ][ class_day ][ia][3]; 254 tm = date2approve[ bk_type ][ class_day ][ia][4]; 255 ts = date2approve[ bk_type ][ class_day ][ia][5]; 256 if ( ( th == 0 ) && ( tm == 0 ) && ( ts == 0 ) ) { 257 return [ is_set_pending_days_selectable, 'cal4date-' + class_day +' date2approve' + blank_admin_class_day]; // Orange //FixIn: 8.6.1.18 258 } else { 259 if ( is_booking_used_check_in_out_time === true ) { 260 if (ts == '1') additional_class += ' check_in_time' + ' check_in_time_date2approve'; //FixIn: 6.0.1.2 261 if (ts == '2') additional_class += ' check_out_time'+ ' check_out_time_date2approve'; //FixIn: 6.0.1.2 262 } else { 263 additional_class += ' times_clock'; //FixIn: 8.2.1.27 264 } 265 time_return_value = [true, 'date_available cal4date-' + class_day +' date2approve timespartly' + additional_class]; // Times 266 if(typeof( isDayFullByTime ) == 'function') { 267 if ( isDayFullByTime(bk_type, class_day ) ) { 268 return [ is_set_pending_days_selectable, 'cal4date-' + class_day +' date2approve' + blank_admin_class_day]; // Orange //FixIn: 8.6.1.18 269 } 270 } 271 } 272 273 } 274 275 } 276 277 //select Approved dates 278 if(typeof(date_approved[ bk_type ]) !== 'undefined') 279 if(typeof(date_approved[ bk_type ][ class_day ]) !== 'undefined') { 280 281 for (var ia=0;ia<date_approved[ bk_type ][ class_day ].length;ia++) { 282 283 th = date_approved[ bk_type ][ class_day ][ia][3]; 284 tm = date_approved[ bk_type ][ class_day ][ia][4]; 285 ts = date_approved[ bk_type ][ class_day ][ia][5]; 286 if ( ( th == 0 ) && ( tm == 0 ) && ( ts == 0 ) ) 287 return [false, 'cal4date-' + class_day +' date_approved' + blank_admin_class_day]; //Blue or Grey in client 288 else { 289 if ( is_booking_used_check_in_out_time === true ) { 290 if (ts == '1') additional_class += ' check_in_time' + ' check_in_time_date_approved'; //FixIn: 6.0.1.2 291 if (ts == '2') additional_class += ' check_out_time'+ ' check_out_time_date_approved'; //FixIn: 6.0.1.2 292 } else { 293 additional_class += ' times_clock'; //FixIn: 8.2.1.27 294 } 295 time_return_value = [true, 'date_available cal4date-' + class_day +' date_approved timespartly' + additional_class]; // Times 296 if(typeof( isDayFullByTime ) == 'function') { 297 if ( isDayFullByTime(bk_type, class_day ) ) return [false, 'cal4date-' + class_day +' date_approved' + blank_admin_class_day]; // Blue or Grey in client 298 } 299 } 300 301 } 302 } 303 304 305 for (var i=0; i<user_unavilable_days.length;i++) { 306 if (date.getDay()==user_unavilable_days[i]) return [false, 'cal4date-' + class_day +' date_user_unavailable' ]; 307 } 308 309 var is_datepick_unselectable = ''; 310 //FixIn: 8.0.1.2 311 /* 312 var is_calendar_booking_unselectable = jQuery('#calendar_booking_unselectable' + bk_type); 313 var is_booking_form_also = jQuery('#booking_form_div' + bk_type); 314 // Set unselectable, if only Availability Calendar here (and we do not insert Booking form by mistake). 315 if ( ( is_calendar_booking_unselectable.length == 1 ) && ( is_booking_form_also.length != 1 ) ){ 316 is_datepick_unselectable = 'datepick-unselectable'; // 'ui-datepicker-unselectable ui-state-disabled'; 317 }*/ 318 319 320 //FixIn: 8.1.2.3 321 if ( false ){ 322 if ( (time_return_value !== false) && (time_return_value[ 1 ].indexOf( 'timespartly' ) != -1) && (is_booking_used_check_in_out_time !== true) ){ 323 time_return_value[ 1 ] = time_return_value[ 1 ].replace( "date_approved", "" ); 324 time_return_value[ 1 ] = time_return_value[ 1 ].replace( "date2approve", "" ); 325 } 326 } 327 var is_exist_check_in_out_for_parent_resource = Math.max( checkin_days_count[0], checkout_days_count[0] ); 328 //FixIn: 8.4.7.29 329 if ( ! wpdev_in_array( parent_booking_resources, bk_type ) ) { 330 is_exist_check_in_out_for_parent_resource = 0; 331 } 332 333 if ( ( time_return_value !== false ) && ( is_exist_check_in_out_for_parent_resource == 0 ) ) { // Check this only for single booking resources - is_exist_check_in_out_for_parent_resource == 0 334 if ( is_booking_used_check_in_out_time === true ) { 335 // If the date is cehck in/out and the check in/out time is activated so then this date is unavailbale 336 if ( ( additional_class.indexOf('check_in_time') != -1 ) && ( additional_class.indexOf('check_out_time') != -1 ) ){ 337 // Make this date unavailbale 338 time_return_value[0] = false; 339 //FixIn: 6.0.1.2 340 if ( ! ( 341 ( ( additional_class.indexOf('check_in_time_date_approved') != -1 ) && ( additional_class.indexOf('check_out_time_date2approve') != -1 ) ) 342 || ( ( additional_class.indexOf('check_out_time_date_approved') != -1 ) && ( additional_class.indexOf('check_in_time_date2approve') != -1 ) ) 343 ) ) { 344 // Remove CSS classes from this date 345 time_return_value[1]=time_return_value[1].replace("check_in_time",""); 346 time_return_value[1]=time_return_value[1].replace("check_out_time",""); 347 time_return_value[1]=time_return_value[1].replace("timespartly",""); 348 } 349 time_return_value[1]=time_return_value[1].replace("date_available",""); 350 } 351 } 352 if ( ( wpdev_in_array( parent_booking_resources, bk_type ) ) && ( (reserved_days_count - both_check_in_out_num ) <= 0 ) ) { //FixIn: 6.0.1.2 353 time_return_value[0] = false; 354 time_return_value[1]=time_return_value[1].replace("check_in_time",""); 355 time_return_value[1]=time_return_value[1].replace("check_out_time",""); 356 time_return_value[1]=time_return_value[1].replace("timespartly",""); 357 time_return_value[1]=time_return_value[1].replace("date_available",""); 358 } 359 return time_return_value; 360 361 } else { 362 363 if ( 364 ( is_booking_used_check_in_out_time === true ) 365 && ( ( is_exist_check_in_out_for_parent_resource > 0 ) || ( (reserved_days_count - both_check_in_out_num ) <= 0 ) ) 366 ) { // Check Check In / Out dates for the parent resources. // reserved_days_count - number of available items, including check in/out dates || both_check_in_out_num number of items with both check in/out //FixIn: 6.0.1.12 367 368 // Unavailable 369 if ( (reserved_days_count - both_check_in_out_num ) <= 0 ) { 370 // Check Pending or Approved by the Check In date 371 if ( checkin_days_count[1] == 1 ) additional_class = ' date_approved'; 372 else additional_class = ' date2approve'; 373 return [false, 'cal4date-' + class_day + additional_class + blank_admin_class_day]; 374 } 375 376 // Recheck if this date check in/out 377 if ( (reserved_days_count - both_check_in_out_num - checkin_days_count[0]) <= 0 ) { 378 if ( checkin_days_count[1] == 1 ) additional_class += ' date_approved'; 379 else additional_class += ' date2approve'; 380 additional_class += ' timespartly check_in_time'; 381 } 382 if ( (reserved_days_count - both_check_in_out_num - checkout_days_count[0]) <= 0 ) { 383 if ( checkout_days_count[1] == 1 ) additional_class += ' date_approved'; 384 else additional_class += ' date2approve'; 385 additional_class += ' timespartly check_out_time'; 386 } 387 } 388 389 return [true, 'date_available cal4date-' + class_day +' reserved_days_count' + reserved_days_count + ' ' + is_datepick_unselectable + additional_class+ ' ']; 390 } 391 } 392 393 function changeMonthYear(year, month){ 394 395 if(typeof( prepare_tooltip ) == 'function') { 396 setTimeout("prepare_tooltip("+bk_type+");",1000); 397 } 398 if(typeof( prepare_highlight ) == 'function') { 399 setTimeout("prepare_highlight();",1000); 400 } 401 } 402 // Configure and show calendar 403 jQuery('#calendar_booking'+ bk_type).text(''); 404 jQuery('#calendar_booking'+ bk_type).datepick( 405 {beforeShowDay: applyCSStoDays, 406 onSelect: selectDay, 407 onHover:hoverDay, 408 onChangeMonthYear:changeMonthYear, 409 showOn: 'both', 410 multiSelect: bkMultiDaysSelect, 411 numberOfMonths: my_num_month, 412 stepMonths: 1, 413 prevText: '«', 414 nextText: '»', 415 dateFormat: 'dd.mm.yy',
416 changeMonth: false, 417 changeYear: false, 418 minDate: bkMinDate, maxDate: bkMaxDate, //'1Y', 419 // minDate: new Date(2020, 2, 1), maxDate: new Date(2020, 9, 31), // Ability to set any start and end date in calendar 420 showStatus: false, 421 multiSeparator: ', ', 422 closeAtTop: false, 423 firstDay:start_day_of_week, 424 gotoCurrent: false, 425 hideIfNoPrevNext:true, 426 rangeSelect:isRangeSelect, 427 // showWeeks: true, 428 useThemeRoller :false // ui-cupertino.datepick.css 429 } 430 ); 431 432 //FixIn: 7.1.2.8 433 setTimeout( function ( ) { 434 jQuery( '.datepick-days-cell.datepick-today.datepick-days-cell-over' ).removeClass( 'datepick-days-cell-over' ); 435 }, 500 ); 436 437 if ( start_bk_month != false ) { 438 var inst = jQuery.datepick._getInst(document.getElementById('calendar_booking'+bk_type)); 439 inst.cursorDate = new Date(); 440 inst.cursorDate.setFullYear( start_bk_month[0], (start_bk_month[1]-1) , 1 ); 441 // In some cases, the setFullYear can set only Year, and not the Month and day //FixIn:6.2.3.5 442 inst.cursorDate.setMonth( parseInt( start_bk_month[1] - 1 ) ); 443 inst.cursorDate.setDate( 1 ); 444 445 inst.drawMonth = inst.cursorDate.getMonth(); 446 inst.drawYear = inst.cursorDate.getFullYear(); 447 448 jQuery.datepick._notifyChange(inst); 449 jQuery.datepick._adjustInstDate(inst); 450 jQuery.datepick._showDate(inst); 451 jQuery.datepick._updateDatepick(inst); 452 } 453 454 if ( typeof( prepare_tooltip ) == 'function' ){ 455 setTimeout( "prepare_tooltip(" + bk_type + ");", 1000 ); 456 } 457} 458 459 460//////////////////////////////////////////////////////////////////////////// 461// Days Selections - support functions 462//////////////////////////////////////////////////////////////////////////// 463 464// Get fisrst day of selection 465function get_first_day_of_selection(dates) { 466 467 // Multiple days selections 468 if ( dates.indexOf(',') != -1 ){ 469 var dates_array =dates.split(/,\s*/); 470 var length = dates_array.length; 471 var element = null; 472 var new_dates_array = []; 473 474 for (var i = 0; i < length; i++) { 475 476 element = dates_array[i].split(/\./); 477 478 new_dates_array[new_dates_array.length] = element[2]+'.' + element[1]+'.' + element[0]; //2013.12.20 479 } 480 new_dates_array.sort(); 481 482 element = new_dates_array[0].split(/\./); 483 484 return element[2]+'.' + element[1]+'.' + element[0]; //20.12.2013 485 } 486 487 // Range days selection 488 if ( dates.indexOf(' - ') != -1 ){ 489 var start_end_date = dates.split(" - "); 490 return start_end_date[0]; 491 } 492 493 // Single day selection 494 return dates; //20.12.2013 495} 496 497 498// Get fisrst day of selection 499function get_last_day_of_selection(dates) { 500 501 // Multiple days selections 502 if ( dates.indexOf(',') != -1 ){ 503 var dates_array =dates.split(/,\s*/); 504 var length = dates_array.length; 505 var element = null; 506 var new_dates_array = []; 507 508 for (var i = 0; i < length; i++) { 509 510 element = dates_array[i].split(/\./); 511 512 new_dates_array[new_dates_array.length] = element[2]+'.' + element[1]+'.' + element[0]; //2013.12.20 513 } 514 new_dates_array.sort(); 515 516 element = new_dates_array[(new_dates_array.length-1)].split(/\./); 517 518 return element[2]+'.' + element[1]+'.' + element[0]; //20.12.2013 519 } 520 521 // Range days selection 522 if ( dates.indexOf(' - ') != -1 ){ 523 var start_end_date = dates.split(" - "); 524 return start_end_date[(start_end_date.length-1)]; 525 } 526 527 // Single day selection 528 return dates; //20.12.2013 529} 530 531 532// Set selected days at calendar as UnAvailable 533function setUnavailableSelectedDays( bk_type ){ 534 var sel_dates = jQuery('#calendar_booking'+bk_type).datepick('getDate'); 535 var class_day2; 536 for( var i =0; i <sel_dates.length; i++) { 537 class_day2 = (sel_dates[i].getMonth()+1) + '-' + sel_dates[i].getDate() + '-' + sel_dates[i].getFullYear(); 538 date_approved[ bk_type ][ class_day2 ] = [ (sel_dates[i].getMonth()+1) , sel_dates[i].getDate(), sel_dates[i].getFullYear(),0,0,0]; 539 jQuery('#calendar_booking'+bk_type+' td.cal4date-'+class_day2).html(sel_dates[i].getDate()); 540 // jQuery('#calendar_booking'+bk_type).datepick('refresh'); 541 } 542} 543 544 545// Aftre reservation action is done 546function setReservedSelectedDates( bk_type ){ 547 548 var is_pay_now = false;
549 550 if (document.getElementById('calendar_booking'+bk_type) === null ) { 551 552 jQuery( '#submiting' + bk_type ).html( '' ); 553 jQuery( '#booking_form_div' + bk_type ).hide(); 554 makeScroll( '#ajax_respond_insert'+bk_type ); 555 556 if ( ( document.getElementById('gateway_payment_forms'+bk_type) != null ) && 557 ( document.getElementById('gateway_payment_forms'+bk_type).innerHTML != '' ) ) 558 is_pay_now = true; 559 560 if ( (! is_pay_now) || ( is_booking_without_payment == true ) ) 561 if (type_of_thank_you_message == 'page') { // Page 562 timeoutID_of_thank_you_page = setTimeout(function ( ) {location.href= thank_you_page_URL;} ,1000); 563 } else { // Message 564 document.getElementById('submiting'+bk_type).innerHTML = '<div class=\"submiting_content wpdev-help-message alert alert-warning alert-success\" >'+new_booking_title+'</div>'; 565 jQuery('.submiting_content').fadeOut( new_booking_title_time ); 566 setTimeout( function () { location.reload( true ); }, parseInt( 1000 + new_booking_title_time ) ); //FixIn: 8.1.2.14 567 } 568 569 } else { 570 571 setUnavailableSelectedDays( bk_type ); 572 document.getElementById('date_booking' + bk_type).value = ''; 573 jQuery('#calendar_booking' + bk_type + ', .block_hints').hide(); 574 575 if ( location.href.indexOf('admin.php') == -1 ) { // Front End 576 577 // Get calendar from the html and insert it before form div, which will hide after btn click 578 jQuery('#calendar_booking' + bk_type).insertBefore("#booking_form_div" + bk_type); 579 document.getElementById("booking_form_div" + bk_type).style.display = "none"; 580 581 jQuery( '#hided_booking_form' + bk_type ).prevAll( 'select[name="active_booking_form"]' ).hide(); //FixIn: 7.1.2.13 582 jQuery( '#hided_booking_form' + bk_type ).prevAll( 'label[for="calendar_type"]' ).hide(); 583 584 makeScroll('#ajax_respond_insert' + bk_type); 585 586 if ((document.getElementById('gateway_payment_forms' + bk_type) != null) && 587 (document.getElementById('gateway_payment_forms' + bk_type).innerHTML != '')) 588 is_pay_now = true; 589 590 if ((!is_pay_now) || (is_booking_without_payment == true)) { 591 if (type_of_thank_you_message == 'page') { // Page 592 timeoutID_of_thank_you_page = setTimeout(function ( ) { 593 location.href = thank_you_page_URL; 594 }, 1000); 595 } else { // Message 596 document.getElementById('submiting' + bk_type).innerHTML = '<div class=\"submiting_content wpdev-help-message alert alert-warning alert-success\" >' + new_booking_title + '</div>'; 597 598 //FixIn: 8.5.2.26 599 if ( ! jQuery('#submiting' + bk_type ).is('visible') ) { 600 jQuery('#submiting' + bk_type ).closest( 'form.booking_form').before( jQuery('#submiting' + bk_type ) ); 601 jQuery('#submiting' + bk_type ).show(); 602 jQuery(".wpbc_submit_spinner").hide(); 603 } 604 605 makeScroll( '#submiting' + bk_type ); 606 jQuery('.submiting_content').fadeOut( new_booking_title_time ); 607 setTimeout( function () { location.reload( true ); }, parseInt( 1000 + new_booking_title_time ) ); //FixIn: 8.1.2.14 608 } 609 } 610 611 } else { // Back End 612 setTimeout( function () { 613 location.reload( true ); 614 }, 1000); 615 } 616 } 617} 618 619 620/** 621 * Check ID of selected additional calendars 622 * 623 * @param int bk_type 624 * @returns array 625 */ 626function wpbc_get_arr_of_selected_additional_calendars( bk_type ){ //FixIn: 8.5.2.26 627 628 var selected_additionl_calendars = []; 629 630 // Checking according additional calendars 631 if ( document.getElementById( 'additional_calendars' + bk_type ) != null ){ 632 633 var id_additional_str = document.getElementById( 'additional_calendars' + bk_type ).value; 634 var id_additional_arr = id_additional_str.split( ',' ); 635 636 var is_all_additional_days_unselected = true; 637 638 for ( var ia = 0; ia < id_additional_arr.length; ia++ ){ 639 if ( document.getElementById( 'date_booking' + id_additional_arr[ ia ] ).value != '' ){ 640 selected_additionl_calendars.push( id_additional_arr[ ia ] ); 641 } 642 } 643 } 644 return selected_additionl_calendars; 645} 646
647//////////////////////////////////////////////////////////////////////////// 648// Submit Booking Data 649//////////////////////////////////////////////////////////////////////////// 650 651// Check fields at form and then send request 652function mybooking_submit( submit_form , bk_type, wpdev_active_locale){ 653 654//console.log( wpbc_get_arr_of_selected_additional_calendars( bk_type ) ); 655 656 //FixIn: 8.4.0.2 657 var is_error = wpbc_check_errors_in_booking_form( bk_type ); 658 if ( is_error ) { return false; } 659 660 // Show message if no selected days in Calendar(s) 661 if (document.getElementById('date_booking' + bk_type).value == '') { 662 663 var arr_of_selected_additional_calendars = wpbc_get_arr_of_selected_additional_calendars( bk_type ); //FixIn: 8.5.2.26 664 665 if ( arr_of_selected_additional_calendars.length == 0 ) { 666 showMessageUnderElement( '#date_booking' + bk_type, message_verif_selectdts, ''); 667 makeScroll('#calendar_booking' + bk_type); // Scroll to the calendar 668 return; 669 } 670 } 671 672 var count = submit_form.elements.length; 673 var formdata = ''; 674 var inp_value; 675 var element; 676 var el_type; 677 678 679 // Serialize form here 680 for (i=0; i<count; i++) { 681 element = submit_form.elements[i]; 682 683 if ( jQuery( element ).closest( '.booking_form_garbage' ).length ) { 684 continue; // Skip elements from garbage //FixIn: 7.1.2.14 685 } 686 687 if ( 688 ( element.type !== 'button' ) 689 && ( element.type !== 'hidden' ) 690 && ( element.name !== ( 'date_booking' + bk_type ) ) 691 // && ( jQuery( element ).is( ':visible' ) ) //FixIn: 7.2.1.12.2 // Its prevent of saving hints, and some other hidden element 692 ) { // Skip buttons and hidden element - type //FixIn: 7.2.1.12 693 694 695 // Get Element Value 696 if ( element.type == 'checkbox' ){ 697 698 if (element.value == '') { 699 inp_value = element.checked; 700 } else { 701 if (element.checked) inp_value = element.value; 702 else inp_value = ''; 703 } 704 705 } else if ( element.type == 'radio' ) { 706 707 if (element.checked) { 708 inp_value = element.value; 709 } else { 710 // Cehck if this radio required, and if its do not checked, then show warning, otherwise if it not required or some other option checked skip this loop 711 // We need to check it here, because radio have the several otions with same name and type and otherwsie we will save several options with selcted and empty values. 712 if ( //FixIn: 7.0.1.62 713 ( element.className.indexOf('wpdev-validates-as-required') !== -1 ) 714 && ( jQuery( element ).is( ':visible' ) ) //FixIn: 7.2.1.12.2 // Its prevent of saving hints, and some other hidden element 715 && ( ! jQuery(':radio[name="'+element.name+'"]', submit_form).is(":checked") ) ) { 716 showErrorMessage( element , message_verif_requred_for_radio_box, false ); //FixIn: 8.5.1.3 717 return; 718 } 719 continue; 720 } 721 } else { 722 inp_value = element.value; 723 } 724 725 // Get value in selectbox of multiple selection 726 if (element.type =='select-multiple') { 727 inp_value = jQuery('[name="'+element.name+'"]').val() ; 728 if (( inp_value == null ) || (inp_value.toString() == '' )) 729 inp_value=''; 730 } 731 732 // Make validation only for visible elements 733 if ( jQuery( element ).is( ':visible' ) ) { //FixIn: 7.2.1.12.2 734 // Recheck for max num. available visitors selection 735 if ( element.name == ('visitors'+bk_type) ){ 736 if ( typeof(is_max_visitors_selection_more_than_available) == 'function' ){ 737 738 //FixIn: 8.2.1.28 739 if ( ( wpbc_is_time_field_in_booking_form( bk_type, submit_form.elements ) ) 740 && ( ! wpdev_in_array( parent_booking_resources, bk_type ) ) 741 ) { 742 743 // We are having timeslots and this is single booking resource, so skip checking for max number of visitors 744 745 } else { 746 747 if ( is_max_visitors_selection_more_than_available( bk_type, inp_value, element ) ){ 748 return; 749 } 750 } 751 } 752 } 753 // Phone validation 754 /*if ( element.name == ('phone'+bk_type) ) { 755 // we validate a phone number of 10 digits with no comma, no spaces, no punctuation and there will be no + sign in front the number - See more at: http://www.w3resource.com/javascript/form/phone-no-vali
755dation.php#sthash.U9FHwcdW.dpuf 756 var reg = /^\d{10}$/; 757 var message_verif_phone = "Please enter correctly phone number"; 758 if ( inp_value != '' ) 759 if(reg.test(inp_value) == false) {showErrorMessage( element , message_verif_phone, false );return;} 760 }*/ 761 762 // Validation Check --- Requred fields 763 if ( element.className.indexOf('wpdev-validates-as-required') !== -1 ){ 764 if ((element.type =='checkbox') && ( element.checked === false)) { 765 if ( ! jQuery(':checkbox[name="'+element.name+'"]', submit_form).is(":checked") ) { 766 showErrorMessage( element , message_verif_requred_for_check_box, false ); //FixIn: 8.5.1.3 767 return; 768 } 769 } 770 if (element.type =='radio') { 771 if ( ! jQuery(':radio[name="'+element.name+'"]', submit_form).is(":checked") ) { 772 showErrorMessage( element , message_verif_requred_for_radio_box, false ); //FixIn: 8.5.1.3 773 return; 774 } 775 } 776 777 if ( (element.type != 'checkbox') && (element.type != 'radio') && ( '' === wpbc_trim( inp_value ) ) ){ //FixIn: 8.8.1.3 //FixIn:7.0.1.39 //FixIn: 8.7.11.12 778 showErrorMessage( element , message_verif_requred, false ); //FixIn: 8.5.1.3 779 return; 780 } 781 } 782 783 // Validation Check --- Email correct filling field 784 if ( element.className.indexOf('wpdev-validates-as-email') !== -1 ){ 785 inp_value = inp_value.replace(/^\s+|\s+$/gm,''); // Trim white space //FixIn: 5.4.5 786 var reg = /^([A-Za-z0-9_\-\.\+])+\@([A-Za-z0-9_\-\.])+\.([A-Za-z]{2,})$/; 787 if ( inp_value != '' ) 788 if(reg.test(inp_value) == false) { 789 showErrorMessage( element , message_verif_emeil, false ); //FixIn: 8.5.1.3 790 return; 791 } 792 } 793 794 // Validation Check --- Same Email Field 795 if ( ( element.className.indexOf('wpdev-validates-as-email') !== -1 ) && ( element.className.indexOf('same_as_') !== -1 ) ) { 796 797 // Get the name of Primary Email field from the "same_as_NAME" class 798 var primary_email_name = element.className.match(/same_as_([^\s])+/gi); 799 if (primary_email_name != null) { // We found 800 primary_email_name = primary_email_name[0].substr(8); 801 802 // Recehck if such primary email field exist in the booking form 803 if (jQuery('[name="' + primary_email_name + bk_type + '"]').length > 0) { 804 805 // Recheck the values of the both emails, if they do not equla show warning 806 if ( jQuery('[name="' + primary_email_name + bk_type + '"]').val() !== inp_value ) { 807 showErrorMessage( element , message_verif_same_emeil , false ); //FixIn: 8.5.1.3 808 return; 809 } 810 } 811 } 812 // Skip one loop for the email veryfication field 813 continue; //FixIn: 8.1.2.15 814 } 815 816 } 817 818 // Get Form Data 819 if ( element.name !== ('captcha_input' + bk_type) ) { 820 if (formdata !=='') formdata += '~'; // next field element 821 822 el_type = element.type; 823 if ( element.className.indexOf('wpdev-validates-as-email') !== -1 ) el_type='email'; 824 if ( element.className.indexOf('wpdev-validates-as-coupon') !== -1 ) el_type='coupon'; 825 826 inp_value = inp_value + ''; 827 inp_value = inp_value.replace(new RegExp("\\^",'g'), '^'); // replace registered characters 828 inp_value = inp_value.replace(new RegExp("~",'g'), '~'); // replace registered characters 829 830 inp_value = inp_value.replace(/"/g, '"'); // replace double quot 831 inp_value = inp_value.replace(/'/g, '''); // replace single quot 832 833 formdata += el_type + '^' + element.name + '^' + inp_value ; // element attr 834 } 835 } 836 837 } // End Fields Loop 838 839 //FixIn:6.1.1.3 840 if( typeof( is_this_time_selections_not_available ) == 'function' ) { 841 842 if ( document.getElementById('date_booking' + bk_type).value == '' ) { // Primary calendar not selected. 843 844 if ( document.getElementById('additional_calendars' + bk_type ) != null ) { // Checking additional calendars. 845 846 var id_additional_str = document.getElementById('additional_calendars' + bk_type).value; //Loop have to be here based on , sign 847 var id_additional_arr = id_additional_str.split(','); 848 var is_times_dates_ok = false;
849 for ( var ia=0;ia<id_additional_arr.length;ia++ ) { 850 if ( 851 ( document.getElementById('date_booking' + id_additional_arr[ia] ).value != '' ) 852 && ( ! is_this_time_selections_not_available( id_additional_arr[ia], submit_form.elements ) ) 853 ){ 854 is_times_dates_ok = true; 855 } 856 } 857 if ( ! is_times_dates_ok ) return; 858 } 859 } else { //Primary calendar selected. 860 if ( is_this_time_selections_not_available( bk_type, submit_form.elements ) ) 861 return; 862 } 863 } 864 865 if ( bk_days_selection_mode == 'dynamic' ) { // Check if visitor finish dates selection. 866 //FixIn:6.1.1.5 867 var selected_dates_cal_id = []; // Get ID of calendars, where selected dates. 868 if ( document.getElementById('date_booking' + bk_type).value != '' ) { 869 selected_dates_cal_id[selected_dates_cal_id.length] = bk_type; 870 } 871 if ( document.getElementById('additional_calendars' + bk_type) != null ) { // Checking according additional calendars. 872 var id_additional_str = document.getElementById('additional_calendars' + bk_type).value; //Loop have to be here based on , sign 873 var id_additional_arr = id_additional_str.split(','); 874 var is_all_additional_days_unselected = true; 875 for (var ia=0;ia<id_additional_arr.length;ia++) { 876 if (document.getElementById('date_booking' + id_additional_arr[ia] ).value != '' ) { 877 selected_dates_cal_id[selected_dates_cal_id.length] = id_additional_arr[ia]; 878 } 879 } 880 } 881 for( var ci = 0; ci < selected_dates_cal_id.length; ci++) { 882 var abk_type = selected_dates_cal_id[selected_dates_cal_id.length] 883 if (document.getElementById('calendar_booking'+abk_type) != null ) { 884 var inst = jQuery.datepick._getInst(document.getElementById('calendar_booking'+abk_type)); 885 if (bk_2clicks_mode_days_min != undefined) { 886 if(typeof( check_conditions_for_range_days_selection_for_check_in ) == 'function') { 887 var first_date = get_first_day_of_selection(document.getElementById('date_booking' + abk_type).value); 888 var date_sections = first_date.split("."); 889 var selceted_first_day = new Date; 890 selceted_first_day.setFullYear( parseInt(date_sections[2]-0) ,parseInt(date_sections[1]-1), parseInt(date_sections[0]-0) ); 891 check_conditions_for_range_days_selection_for_check_in(selceted_first_day, abk_type); 892 } 893 if (inst.dates.length < bk_2clicks_mode_days_min ) { 894 showMessageUnderElement( '#date_booking' + abk_type, message_verif_selectdts, ''); 895 makeScroll('#calendar_booking' + abk_type); // Scroll to the calendar 896 return; 897 } 898 } 899 } 900 } 901 } 902 903 // Cpatch verify 904 var captcha = document.getElementById('wpdev_captcha_challenge_' + bk_type); 905 906 //Disable Submit button 907 jQuery('#booking_form_div' + bk_type + ' input[type="button"]').prop("disabled", true); 908 jQuery('#booking_form_div' + bk_type + ' button').prop("disabled", true); //FixIn: 8.5.2.7 909 if (captcha != null) form_submit_send( bk_type, formdata, captcha.value, document.getElementById('captcha_input' + bk_type).value ,wpdev_active_locale); 910 else form_submit_send( bk_type, formdata, '', '' , wpdev_active_locale); 911 return; 912} 913 914 915// Gathering params for sending Ajax request and then send it 916function form_submit_send( bk_type, formdata, captcha_chalange, user_captcha ,wpdev_active_locale){ 917 918 document.getElementById('submiting' + bk_type).innerHTML = '<div style="height:20px;width:100%;text-align:center;margin:15px auto;"><img style="vertical-align:middle;box-shadow:none;width:14px;" src="'+wpdev_bk_plugin_url+'/assets/img/ajax-loader.gif"><//div>'; 919 920 var my_booking_form = ''; 921 var my_booking_hash = ''; 922 if (document.getElementById('booking_form_type' + bk_type) != undefined) 923 my_booking_form =document.getElementById('booking_form_type' + bk_type).value; 924 925 if ( wpdev_bk_edit_id_hash != '' ) my_booking_hash = wpdev_bk_edit_id_hash; 926 927 var is_send_emeils = 1; 928 if ( jQuery('#is_send_email_for_pending').length ) { 929 is_send_emeils = jQuery( '#is_send_email_for_pending' ).is( ':checked' ); //FixIn: 8.7.9.5 930 if ( false === is_send_emeils ) { is_send_emeils = 0; } 931 else { is_send_emeils = 1; } 932 } 933 934 if ( document.getElementById('date_booking' + bk_type).value != '' ) //FixIn:6.1.1.3 935 send_ajax_submit(bk_type,formdata,captcha_chalange,user_captcha,is_send_emeils,my_booking_hash,my_booking_form,wpdev_active_locale ); // Ajax sending request 936 else { 937 jQuery('#booking_form_div' + bk_type ).hide(); 938 jQuery('#submiting' + bk_type ).hide(); 939 } 940 941 var formdata_additional_arr; 942 var formdata_additional; 943 var my_form_field; 944 var id_additional; 945 var id_additional_str; 946 var id_additional_arr; 947 if (document.getElementById('additional_calendars' + bk_type) != null ) { 948 949 id_additional_str = document.getElementById('additional_calendars' + bk_type).value; //Loop have to be here based on , sign 950 id_additional_arr = id_additional_str.split(','); 951 952 //FixIn: 8.5.2.26 953 if ( ! jQuery( '#booking_form_div' + bk_type ).is( ':visible' ) ) { 954 jQuery( '#booking_form_div' + bk_type ).after( 955 '<div class="wpbc_submit_spinner" style="height:20px;width:100%;text-align:center;margin:15px auto;"><img style="vertical-align:middle;box-shadow:none;width:14px;" src="'+wpdev_bk_plugin_url+'/assets/img/ajax-loader.gif"></div>' 956 ); 957 } 958 959 960 961 for (var ia=0;ia<id_additional_arr.length;ia++) { 962 formdata_additional_arr = formdata; 963 formdata_additional = ''; 964 id_additional = id_additional_arr[ia]; 965 966 967 formdata_additional_arr = formdata_additional_arr.split('~'); 968 for (var j=0;j<formdata_additional_arr.length;j++) { 969 my_form_field = formdata_additional_arr[j].split('^'); 970 if (formdata_additional !=='') formdata_additional += '~'; 971 972 if (my_form_field[1].substr( (my_form_field[1].length -2),2)=='[]') 973 my_form_field[1] = my_form_field[1].substr(0, (my_form_field[1].length - (''+bk_type).length ) - 2 ) + id_additional + '[]'; 974 else 975 my_form_field[1] = my_form_field[1].substr(0, (my_form_field[1].length - (''+bk_type).length ) ) + id_additional ; 976 977 978 formdata_additional += my_form_field[0] + '^' + my_form_field[1] + '^' + my_form_field[2]; 979 } 980 981 if ( jQuery('#gateway_payment_forms' + bk_type).length > 0 ) { // If Payment form for main booking resources is showing then append payment form for additional calendars. 982 jQuery('#gateway_payment_forms' + bk_type).after('<div id="gateway_payment_forms'+id_additional+'"></div>'); 983 jQuery('#gateway_payment_forms' + bk_type).after('<div id="ajax_respond_insert'+id_additional+'" style="display:none;"></div>'); 984 } 985 //FixIn: 8.5.2.17 986 send_ajax_submit( id_additional ,formdata_additional,captcha_chalange,user_captcha,is_send_emeils,my_booking_hash,my_booking_form ,wpdev_active_locale ); // Submit 987 988// if (document.getElementById('date_booking' + id_additional).value != '' ) { 989// setUnavailableSelectedDays(id_additional); // Set selected days unavailable in this calendar 990// jQuery('#calendar_booking'+id_additional).insertBefore("#booking_form_div"+bk_type); // Insert calendar before form to do not hide it 991// if (document.getElementById('gateway_payment_forms'+id_additional) != null) 992// jQuery('#gateway_payment_forms'+id_additional).insertBefore("#booking_form_div"+bk_type); // Insert payment form to do not hide it 993// else { 994// jQuery("#booking_form_div"+bk_type).append('<div id="gateway_payment_forms'+id_additional+'" ></div>'); 995// jQuery("#booking_form_div"+bk_type).append('<div id="ajax_respond_insert'+id_additional+'" ></div>'); 996// } 997// send_ajax_submit( id_additional ,formdata_additional,captcha_chalange,user_captcha,is_send_emeils,my_booking_hash,my_booking_form ,wpdev_active_locale ); 998// } 999 } 1000 } 1001} 1002 1003 1004//<![CDATA[ 1005function send_ajax_submit(bk_type,formdata,captcha_chalange,user_captcha,is_send_emeils,my_booking_hash,my_booking_form ,wpdev_active_locale ) { 1006 // Ajax POST here
1007 1008 var my_bk_res = bk_type; 1009 if ( document.getElementById('bk_type' + bk_type) != null ) my_bk_res = document.getElementById('bk_type' + bk_type).value; 1010 1011 jQuery.ajax({ // Start Ajax Sending 1012 // url: wpdev_bk_plugin_url+ '/' + wpdev_bk_plugin_filename, 1013 url: wpbc_ajaxurl, 1014 type:'POST', 1015 success: function (data, textStatus){if( textStatus == 'success') jQuery('#ajax_respond_insert' + bk_type).html( data ) ;}, 1016 error:function (XMLHttpRequest, textStatus, errorThrown){window.status = 'Ajax sending Error status:'+ textStatus;alert(XMLHttpRequest.status + ' ' + XMLHttpRequest.statusText);if (XMLHttpRequest.status == 500) {alert('Please check at this page according this error:' + ' https://wpbookingcalendar.com/faq/#ajax-sending-error');}}, 1017 // beforeSend: someFunction, 1018 data:{ 1019 // ajax_action : 'INSERT_INTO_TABLE', 1020 action : 'INSERT_INTO_TABLE', 1021 bktype: my_bk_res , 1022 dates: document.getElementById('date_booking' + bk_type).value , 1023 form: formdata, 1024 captcha_chalange:captcha_chalange, 1025 captcha_user_input: user_captcha, 1026 is_send_emeils : is_send_emeils, 1027 my_booking_hash:my_booking_hash, 1028 booking_form_type:my_booking_form, 1029 wpdev_active_locale:wpdev_active_locale, 1030 wpbc_nonce: document.getElementById('wpbc_nonce' + bk_type).value 1031 } 1032 }); 1033} 1034//]]> 1035 1036//////////////////////////////////////////////////////////////////////////// 1037//////////////////////////////////////////////////////////////////////////// 1038 1039// Show Error Message in Booking Form at Front End 1040function showErrorMessage( element , errorMessage , isScrollStop ) { //FixIn: 8.5.1.3 1041 //FixIn: 8.4.0.2 1042 // if(typeof( bk_form_step_click ) == 'function') { 1043 // bk_form_step_click(); // rollback to 1st step, if system will show warning and booking form is using this customization: in the Exmaple #2 here: https://wpbookingcalendar.com/faq/customize-booking-form-for-having-several-steps-of-reservation/ 1044 // } 1045 1046 //FixIn: 8.5.1.3 1047 if ( ! isScrollStop ){ 1048 makeScroll( element ); 1049 } 1050 //FixIn: 8.7.11.10 1051 if ( jQuery( "[name='" + element.name + "']" ).is( ':visible' ) ){ 1052 jQuery("[name='"+ element.name +"']") 1053 .fadeOut( 350 ).fadeIn( 300 ) 1054 .fadeOut( 350 ).fadeIn( 400 ) 1055 .fadeOut( 350 ).fadeIn( 300 ) 1056 .fadeOut( 350 ).fadeIn( 400 ) 1057 .animate( {opacity: 1}, 4000 ) 1058 ; // mark red border 1059 } 1060 if (jQuery("[name='"+ element.name +"']").attr('type') == "radio") { 1061 1062 if ( ( ! jQuery( "[name='" + element.name + "']" ).parent().parent().parent().next().hasClass( 'alert-warning' )) 1063 || ( 1064 ( jQuery( "[name='" + element.name + "']" ).parent().parent().parent().next().hasClass( 'alert-warning' )) 1065 && ( ! jQuery( "[name='" + element.name + "']" ).parent().parent().parent().next().is( ':visible' ) ) 1066 ) 1067 ){ //FixIn: 8.4.5.7 1068 jQuery( "[name='" + element.name + "']" ).parent().parent().parent() 1069 .after( '<span class="wpdev-help-message alert alert-warning">' + errorMessage + '</span>' ); // Show message 1070 } 1071 1072 } else if (jQuery("[name='"+ element.name +"']").attr('type') == "checkbox") { 1073 1074 if ( ( ! jQuery( "[name='" + element.name + "']" ).parent().next().hasClass( 'alert-warning' )) 1075 || ( 1076 ( jQuery( "[name='" + element.name + "']" ).parent().next().hasClass( 'alert-warning' )) 1077 && ( ! jQuery( "[name='" + element.name + "']" ).parent().next().is( ':visible' ) ) 1078 ) 1079 ){ //FixIn: 8.4.5.7 1080 jQuery( "[name='" + element.name + "']" ).parent() 1081 .after( '<span class="wpdev-help-message alert alert-warning">' + errorMessage + '</span>' ); // Show message 1082 } 1083 1084 } else { 1085 1086 if ( ( ! jQuery( "[name='" + element.name + "']" ).next().hasClass( 'alert-warning' )) 1087 || ( 1088 ( jQuery( "[name='" + element.name + "']" ).next().hasClass( 'alert-warning' )) 1089 && ( ! jQuery( "[name='" + element.name + "']" ).next().is( ':visible' ) ) 1090 ) 1091 ){ //FixIn: 8.4.5.7 1092 jQuery( "[name='" + element.name + "']" ) 1093 .after( '<span class="wpdev-help-message alert alert-warning">' + errorMessage + '</span>' ); // Show message 1094 } 1095 } 1096 jQuery(".wpdev-help-message") 1097 .css( {'padding' : '5px 5px 4px', 'margin' : '2px 2px 2px 10px', 'vertical-align': 'top', 'line-height': '32px' } ); 1098 1099 if ( element.type == 'checkbox' ) 1100 jQuery(".wpdev-help-message").css( { 'vertical-align': 'middle'} ); 1101 1102 jQuery(".widget_wpdev_booking .booking_form .wpdev-help-message") 1103 .css( {'vertical-align': 'sub' } ) ; 1104 jQuery(".wpdev-help-message") 1105 .animate( {opacity: 1}, 10000 ) 1106 .fadeOut( 2000 ); 1107 1108 if ( ! jQuery( "[name='" + element.name + "']" ).is( ':visible' ) ){ 1109 makeScroll( jQuery(".wpdev-help-message") ); 1110 } 1111 jQuery( element ).trigger( 'focus' ); //FixIn: 8.7.11.12 1112 return; 1113 1114} 1115 1116/** 1117 * Show message under specific element 1118 * 1119 * @param {type} element - jQuery definition of the element 1120 * @param {type} errorMessage - String message 1121 * @param {type} message_type "" | "alert-danger" | "alert-success" | "alert-info" 1122 */ 1123function showMessageUnderElement( element , errorMessage , message_type) { 1124 //FixIn: 8.4.0.2 1125 // if(typeof( bk_form_step_click ) == 'function') { 1126 // bk_form_step_click(); // rollback to 1st step, if system will show warning and booking form is using this customization: in the Exmaple #2 here: https://wpbookingcalendar.com/faq/customize-booking-form-for-having-several-steps-of-reservation/ 1127 // } 1128 1129 makeScroll( element ); 1130 1131 if ( jQuery( element ).attr('type') == "radio" ) { 1132 1133 if ( ( ! jQuery( element ).parent().parent().parent().next().hasClass( 'alert-warning' )) 1134 || ( 1135 ( jQuery( element ).parent().parent().parent().next().hasClass( 'alert-warning' )) 1136 && ( ! jQuery( element ).parent().parent().parent().next().is( ':visible' ) ) 1137 ) 1138 ){ //FixIn: 8.4.5.7 1139 jQuery( element ).parent().parent().parent() 1140 .after( '<span class="wpdev-help-message wpdev-element-message alert alert-warning ' + message_type + '">' + errorMessage + '</span>' ); // Show message 1141 } 1142 } else if (jQuery( element ).attr('type') == "checkbox") { 1143 1144 if ( ( ! jQuery( element ).parent().next().hasClass( 'alert-warning' )) 1145 || ( 1146 ( jQuery( element ).parent().next().hasClass( 'alert-warning' )) 1147 && ( ! jQuery( element ).parent().next().is( ':visible' ) ) 1148 ) 1149 ){ //FixIn: 8.4.5.7 1150 jQuery( element ).parent() 1151 .after( '<span class="wpdev-help-message wpdev-element-message alert alert-warning ' + message_type + '">' + errorMessage + '</span>' ); // Show message 1152 } 1153 } else { 1154 if ( ( ! jQuery( element ).next().hasClass( 'alert-warning' )) 1155 || ( 1156 ( jQuery( element ).next().hasClass( 'alert-warning' )) 1157 && ( ! jQuery( element ).next().is( ':visible' ) ) 1158 ) 1159 ){ //FixIn: 8.4.5.7 1160 jQuery( element ) 1161 .after( '<span class="wpdev-help-message wpdev-element-message alert alert-warning ' + message_type + '">' + errorMessage + '</span>' ); // Show message 1162 } 1163 } 1164 // jQuery(".wpdev-help-message") 1165 // .css( {'padding' : '5px 5px 4px', 'margin' : '10px 2px', 'vertical-align': 'middle' } ); 1166 jQuery(".widget_wpdev_booking .booking_form .wpdev-help-message") 1167 .css( {'vertical-align': 'sub' } ) ; 1168 jQuery(".wpdev-help-message") 1169 .animate( {opacity: 1}, 10000 ) 1170 .fadeOut( 2000 ); 1171} 1172 1173// Hint labels inside of input boxes 1174jQuery(document).ready( function(){ 1175 1176 jQuery('div.inside_hint').on( 'click', function(){ //FixIn: 8.7.11.12 1177 jQuery(this).css('visibility', 'hidden').siblings('.has-inside-hint').trigger( 'focus' ); //FixIn: 8.7.11.12 1178 }); 1179 1180 jQuery('input.has-inside-hint').on( 'blur', function(){ //FixIn: 8.7.11.12 1181 if ( this.value == '' ) 1182 jQuery(this).siblings('.inside_hint').css('visibility', ''); 1183 }).on( 'focus', function(){ //FixIn: 8.7.11.12 1184 jQuery(this).siblings('.inside_hint').css('visibility', 'hidden'); 1185 }); 1186 1187 jQuery('.booking_form_div input[type=button]').prop("disabled", false); 1188}); 1189 1190
1191//////////////////////////////////////////////////////////////////////////// 1192// Support Functions 1193//////////////////////////////////////////////////////////////////////////// 1194 1195// Scroll to script 1196function makeScroll(object_name) { 1197 var targetOffset = jQuery( object_name ).offset().top; 1198 //targetOffset = targetOffset - 50; 1199 if (targetOffset<0) targetOffset = 0; 1200 if ( jQuery('#wpadminbar').length > 0 ) targetOffset = targetOffset - 50; 1201 else targetOffset = targetOffset - 20; 1202 jQuery('html,body').animate({scrollTop: targetOffset}, 500); 1203} 1204 1205 1206//FixIn: 8.8.1.3 1207/** 1208 * Trim strings and array joined with (,) 1209 * 1210 * @param string_to_trim string / array 1211 * @returns string 1212 */ 1213function wpbc_trim( string_to_trim ){ 1214 1215 if ( Array.isArray( string_to_trim ) ){ 1216 string_to_trim = string_to_trim.join( ',' ); 1217 } 1218 1219 if ( 'string' == typeof (string_to_trim) ){ 1220 string_to_trim = string_to_trim.trim(); 1221 } 1222 1223 return string_to_trim; 1224} 1225 1226 1227function wpdev_in_array (array_here, p_val) { 1228 for(var i = 0, l = array_here.length; i < l; i++) { 1229 if(array_here[i] == p_val) { 1230 return true; 1231 } 1232 } 1233 return false; 1234} 1235 1236 1237function days_between(date1, date2) { 1238 1239 // The number of milliseconds in one day 1240 var ONE_DAY = 1000 * 60 * 60 * 24; 1241 1242 // Convert both dates to milliseconds 1243 var date1_ms = date1.getTime(); 1244 var date2_ms = date2.getTime(); 1245 1246 // Calculate the difference in milliseconds 1247 var difference_ms = date1_ms - date2_ms; 1248 1249 // Convert back to days and return 1250 return Math.round(difference_ms/ONE_DAY); 1251 1252} 1253 1254 1255function daysInMonth(month,year) { 1256 var m = [31,28,31,30,31,30,31,31,30,31,30,31]; 1257 if (month != 2) return m[month - 1]; 1258 if (year%4 != 0) return m[1]; 1259 if (year%100 == 0 && year%400 != 0) return m[1]; 1260 return m[1] + 1; 1261} 1262 1263 1264function wpbc_timeline_nav( timeline_obj, nav_step ){ 1265 1266 jQuery( ".wpbc_timeline_front_end" ).trigger( "timeline_nav" , [ timeline_obj, nav_step ] ); //FixIn:7.0.1.48 1267 1268 jQuery( '#'+timeline_obj.html_client_id + ' .wpbc_tl_prev,#'+timeline_obj.html_client_id + ' .wpbc_tl_next').remove(); 1269 1270 jQuery('#'+timeline_obj.html_client_id + ' .wpbc_tl_title').html( '<span class="glyphicon glyphicon-refresh wpbc_spin"></span>   Loading...' ); // '<div style="height:20px;width:100%;text-align:center;margin:15px auto;">Loading ... <img style="vertical-align:middle;box-shadow:none;width:14px;" src="'+wpdev_bk_plugin_url+'/assets/img/ajax-loader.gif"><//div>' 1271 1272 if ( 'function' === typeof( jQuery(".popover_click.popover_bottom" ).popover ) ) //FixIn: 7.0.1.2 - 2016-12-10 1273 jQuery('.popover_click.popover_bottom').popover( 'hide' ); //Hide all opned popovers 1274 1275 jQuery.ajax({ 1276 url: wpbc_ajaxurl, 1277 type:'POST', 1278 success: function ( data, textStatus ){ // Note, here we direct show HTML to TimeLine frame 1279 if( textStatus == 'success') { 1280 jQuery('#' + timeline_obj.html_client_id + ' .wpbc_timeline_ajax_replace' ).html( data ); 1281 return true; 1282 } 1283 }, 1284 error: function ( XMLHttpRequest, textStatus, errorThrown){ 1285 window.status = 'Ajax Error! Status: ' + textStatus; 1286 alert( 'Ajax Error! Status: ' + XMLHttpRequest.status + ' ' + XMLHttpRequest.statusText ); 1287 }, 1288 // beforeSend: someFunction, 1289 data:{ 1290 action: 'WPBC_TIMELINE_NAV', 1291 timeline_obj: timeline_obj, 1292 nav_step: nav_step, 1293 wpdev_active_locale:wpbc_active_locale, 1294 wpbc_nonce: document.getElementById('wpbc_nonce_'+ timeline_obj.html_client_id).value 1295 } 1296 }); 1297} 1298 1299 1300 1301/** 1302 * Unselect all days in calendar 1303 * 1304 * @param bk_type - ID of booking resource 1305 */ 1306function wpbc_unselect_all_days( bk_type ){ //FixIn: 8.0.1.2 1307 1308 var is_calendar_exist = jQuery( '#calendar_booking' + bk_type ); 1309 1310 if ( is_calendar_exist.length > 0 ){ 1311 1312 var inst = jQuery.datepick._getInst( document.getElementById( 'calendar_booking' + bk_type ) ); // Unselect all dates and set properties of Datepick 1313 1314 jQuery( '#date_booking' + bk_type ).val( '' ); 1315 inst.stayOpen = false;
1316 inst.dates = []; 1317 jQuery.datepick._updateDatepick( inst ); 1318 } 1319} 1320 1321 1322 1323//FixIn: 8.4.0.2 1324/** 1325 * Check errors in booking form fields, and show warnings if some errors exist. 1326 * Check errors, like not selected dates or not filled requred form fields, or not correct entering email or phone fields, etc... 1327 * 1328 * @param bk_type int (ID of booking resource) 1329 */ 1330function wpbc_check_errors_in_booking_form( bk_type ) { 1331 1332 var is_error_in_field = false; // By default all is good - no error 1333 1334 var my_form = jQuery( '#booking_form' + bk_type ); 1335 1336 if ( my_form.length ) { 1337 1338 // Pseudo-selector that get form elements <input , <textarea , <select, <button... 1339 my_form.find( ':input' ).each( function( index, el ) { 1340 1341 // Skip some elements 1342 var skip_elements = [ 'hidden', 'button' ]; 1343 1344 if ( -1 == skip_elements.indexOf( jQuery( el ).attr( 'type' ) ) ){ 1345 1346 // Check Calendar Dates Selection 1347 if ( ( 'date_booking' + bk_type ) == jQuery( el ).attr( 'name' ) ) { 1348 1349 // Show Warning only if the calendar visible ( we are at step with calendar) 1350 if ( 1351 ( ( jQuery( '#calendar_booking' + bk_type ).is( ':visible' ) ) && ( '' == jQuery( el ).val() ) ) 1352 && ( wpbc_get_arr_of_selected_additional_calendars( bk_type ).length == 0 ) //FixIn: 8.5.2.26 1353 ){ //FixIn: 8.4.4.5 1354 showMessageUnderElement( '#date_booking' + bk_type, message_verif_selectdts, '' ); 1355 makeScroll('#calendar_booking' + bk_type); // Scroll to the calendar //FixIn: 8.5.1.3 1356 is_error_in_field = true; // Error 1357 } 1358 } 1359 1360 // Check only visible elements at this step 1361 if ( jQuery( el ).is( ':visible' ) ){ 1362// console.log( '|id, type, val, visible|::', jQuery( el ).attr( 'name' ), '|' + jQuery( el ).attr( 'type' ) + '|', jQuery( el ).val(), jQuery( el ).is( ':visible' ) ); 1363 1364 // Is Required 1365 if ( jQuery( el ).hasClass( 'wpdev-validates-as-required' ) ){ 1366 1367 // Checkboxes 1368 if ( 'checkbox' == jQuery( el ).attr( 'type' ) ){ 1369 1370 if ( 1371 ( ! jQuery( el ).is( ':checked' )) 1372 && ( ! jQuery( ':checkbox[name="' + el.name + '"]', my_form ).is( ":checked" ) ) //FixIn: 8.5.2.12 1373 ){ 1374 showErrorMessage( el, message_verif_requred_for_check_box, is_error_in_field ); 1375 is_error_in_field = true; // Error 1376 } 1377 1378 // Radio boxes 1379 } else if ( 'radio' == jQuery( el ).attr( 'type' ) ){ 1380 1381 if ( !jQuery( ':radio[name="' + jQuery( el ).attr( 'name' ) + '"]', my_form ).is( ':checked' ) ){ 1382 showErrorMessage( el, message_verif_requred_for_radio_box, is_error_in_field ); 1383 is_error_in_field = true; // Error 1384 } 1385 1386 // Other elements 1387 } else { 1388 1389 var inp_value = jQuery( el ).val(); 1390 1391 if ( '' === wpbc_trim( inp_value ) ){ //FixIn: 8.8.1.3 //FixIn: 8.7.11.12 1392 showErrorMessage( el, message_verif_requred, is_error_in_field ); 1393 is_error_in_field = true; // Error 1394 } 1395 } 1396 } 1397 1398 // Validate Email 1399 if ( jQuery( el ).hasClass( 'wpdev-validates-as-email' ) ){ 1400 var inp_value = jQuery( el ).val(); 1401 inp_value = inp_value.replace( /^\s+|\s+$/gm, '' ); // Trim white space //FixIn: 5.4.5 1402 var reg = /^([A-Za-z0-9_\-\.\+])+\@([A-Za-z0-9_\-\.])+\.([A-Za-z]{2,})$/; 1403 if ( (inp_value != '') && (reg.test( inp_value ) == false) ){ 1404 showErrorMessage( el, message_verif_emeil, is_error_in_field ); 1405 is_error_in_field = true; // Error 1406 } 1407 } 1408 1409 // Validate For digit entering - for example for - Phone 1410 // <p>Digit Field:<br />[text* dig_field class:validate_as_digit] </p> 1411 // <p>Phone:<br />[text* phone class:validate_digit_8] </p> 1412 1413 var classList = jQuery( el ).attr( 'class' ); 1414 1415 if ( classList ){ 1416 1417 classList = classList.split( /\s+/ ); 1418 1419 jQuery.each( classList, function ( cl_index, cl_item ){ 1420
1421 //////////////////////////////////////////////////////////////////////////////////////////// 1422 1423 // Validate field value as "Date" [CSS class - 'validate_as_digit'] 1424 if ( 'validate_as_date' === cl_item ) { 1425 1426 // Valid values: 09-25-2018, 09/25/2018, 09-25-2018, 31-9-1918 --- m/d/Y, m.d.Y, m-d-Y, d/m/Y, d.m.Y, d-m-Y 1427 var regex = new RegExp( '^[0-3]?\\d{1}[\\/\\.\\-]+[0-3]?\\d{1}[\\/\\.\\-]+[0-2]+\\d{3}$' ); // Check for Date 09/25/2018 1428 var message_verif_phone = 'This field must be valid date like this ' + '09/25/2018'; 1429 var inp_value = jQuery( el ).val(); 1430 1431 if ( ( inp_value != '' ) && ( regex.test( inp_value ) == false ) ){ 1432 showErrorMessage( el, message_verif_phone, is_error_in_field ); 1433 is_error_in_field = true; // Error 1434 } 1435 } 1436
1437 //////////////////////////////////////////////////////////////////////////////////////////// 1438 1439 // Validate field value as "DIGIT" [CSS class - 'validate_as_digit'] 1440 if ( 'validate_as_digit' === cl_item ) { 1441 1442 var regex = new RegExp( '^[0-9]+\\.?[0-9]*$' ); // Check for digits 1443 var message_verif_phone = 'This field must contain only digits'; 1444 var inp_value = jQuery( el ).val(); 1445 1446 if ( ( inp_value != '' ) && ( regex.test( inp_value ) == false ) ){ 1447 showErrorMessage( el, message_verif_phone, is_error_in_field ); 1448 is_error_in_field = true; // Error 1449 } 1450 } 1451 1452 //////////////////////////////////////////////////////////////////////////////////////////// 1453 1454 // Validate field value as "Phone" number or any other valid number wth specific number of digits [CSS class - 'validate_digit_8' || 'validate_digit_10' ] 1455 var is_validate_digit = cl_item.substring( 0, 15 ); 1456 1457 // Check if class start with 'validate_digit_' 1458 if ( 'validate_digit_' === is_validate_digit ){ 1459 1460 // Get number of digit in class: validate_digit_8 => 8 or validate_digit_10 => 10 1461 var digits_to_check = parseInt( cl_item.substring( 15 ) ); 1462 1463 // Check about any errors in 1464 if ( !isNaN( digits_to_check ) ){ 1465 1466 var regex = new RegExp( '^\\d{' + digits_to_check + '}$' ); // We was valid it as parseInt - only integer variable - digits_to_check 1467 var message_verif_phone = 'This field must contain ' + digits_to_check + ' digits'; 1468 var inp_value = jQuery( el ).val(); 1469 1470 if ( ( inp_value != '' ) && ( regex.test( inp_value ) == false ) ){ 1471 showErrorMessage( el, message_verif_phone, is_error_in_field ); 1472 is_error_in_field = true; // Error 1473 } 1474 } 1475 } 1476
1477 //////////////////////////////////////////////////////////////////////////////////////////// 1478 1479 }); 1480 } 1481 } 1482 } 1483 } ); 1484 1485 } 1486 return is_error_in_field; 1487} 1488 1489 1490//FixIn: 8.4.4.4 1491function bk_calendar_step_click( el ){ 1492 var br_id = jQuery( el ).closest( 'form' ).find( 'input[name^="bk_type"]' ).val(); 1493 var is_error = wpbc_check_errors_in_booking_form( br_id ); 1494 if ( is_error ){ 1495 return false; 1496 } 1497 if ( br_id != undefined ){ 1498 jQuery( "#booking_form" + br_id + " .bk_calendar_step" ).css( {"display": "none"} ); 1499 jQuery( "#booking_form" + br_id + " .bk_form_step" ).css( {"display": "block"} ); 1500 } else { 1501 jQuery( ".bk_calendar_step" ).css( {"display": "none"} ); 1502 jQuery( ".bk_form_step" ).css( {"display": "block"} ); 1503 } 1504} 1505 1506function bk_form_step_click( el ){ 1507 var br_id = jQuery( el ).closest( 'form' ).find( 'input[name^="bk_type"]' ).val(); 1508 var is_error = false; // wpbc_check_errors_in_booking_form( br_id ); //FixIn: 8.4.5.6 1509 if ( is_error ){ 1510 return false; 1511 } 1512 if ( br_id != undefined ){ 1513 jQuery( "#booking_form" + br_id + " .bk_calendar_step" ).css( {"display": "block"} ); 1514 jQuery( "#booking_form" + br_id + " .bk_form_step" ).css( {"display": "none"} ); 1515 makeScroll( "#bklnk" + br_id ); 1516 } else { 1517 jQuery( ".bk_calendar_step" ).css( {"display": "block"} ); 1518 jQuery( ".bk_form_step" ).css( {"display": "none"} ); 1519 } 1520} 1521 1522//FixIn: 8.6.1.15 1523/** 1524 * Go to next specific step in Wizard style booking form, with 1525 * check all required elements specific step, otherwise show warning message! 1526 * 1527 * @param el 1528 * @param step_num 1529 * @returns {boolean} 1530 */ 1531function wpbc_wizard_step( el, step_num, step_from ){ 1532 var br_id = jQuery( el ).closest( 'form' ).find( 'input[name^="bk_type"]' ).val(); 1533 1534 //FixIn: 8.8.1.5 1535 if ( ( undefined == step_from ) || ( step_num > step_from ) ){ 1536 if ( 1 != step_num ){ //FixIn: 8.7.7.8 1537 var is_error = wpbc_check_errors_in_booking_form( br_id ); 1538 if ( is_error ){ 1539 return false; 1540 } 1541 } 1542 } 1543 1544 if ( wpbc_is_some_elements_visible( br_id, ['rangetime', 'durationtime', 'starttime', 'endtime'] ) ){ 1545 if ( is_this_time_selections_not_available( br_id, document.getElementById( 'booking_form' + br_id ) ) ){ 1546 return false; 1547 } 1548 } 1549 1550 if ( br_id != undefined ){ 1551 jQuery( "#booking_form" + br_id + " .wpbc_wizard_step" ).css( {"display": "none"} ); 1552 jQuery( "#booking_form" + br_id + " .wpbc_wizard_step" + step_num ).css( {"display": "block"} ); 1553 } 1554} 1555 1556 1557//FixIn: 8.6.1.15 1558/** 1559 * Check if at least one element from array of elements names in booking form visible or not. 1560 * Usage Example: if ( wpbc_is_some_elements_visible( br_id, ['rangetime', 'durationtime', 'starttime', 'endtime'] ) ){ ... } 1561 * 1562 * @param bk_type 1563 * @param elements_names 1564 * @returns {boolean} 1565 */ 1566function wpbc_is_some_elements_visible( bk_type, elements_names ){ 1567 1568 var is_some_elements_visible = false; 1569 1570 var my_form = jQuery( '#booking_form' + bk_type ); 1571 1572 if ( my_form.length ){ 1573 1574 // Pseudo-selector that get form elements <input , <textarea , <select, <button... 1575 my_form.find( ':input' ).each( function ( index, el ){ 1576 1577 // Skip some elements 1578 var skip_elements = ['hidden', 'button']; 1579 1580 if ( -1 == skip_elements.indexOf( jQuery( el ).attr( 'type' ) ) ){ 1581 1582 for ( var ei = 0; ei < ( elements_names.length - 1) ; ei++ ){ 1583 1584 // Check Calendar Dates Selection 1585 if ( (elements_names[ ei ] + bk_type) == jQuery( el ).attr( 'name' ) ){ 1586 1587 if ( jQuery( el ).is( ':visible' ) ){ 1588 is_some_elements_visible = true; 1589 } 1590 } 1591 } 1592 } 1593 } ); 1594 } 1595 return is_some_elements_visible; 1596}
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.