var is_booking_without_payment = false; var date_approved = []; var date2approve = []; var date_admin_blank = []; var dates_additional_info = []; var is_all_days_available = []; var avalaibility_filters = []; var is_show_cost_in_tooltips = false; var is_show_availability_in_tooltips = false; var global_avalaibility_times = []; var numbb = 0; //var is_use_visitors_number_for_availability; var timeoutID_of_thank_you_page = null; // Calendar Initialisation ///////////////////////////////////////////////// function init_datepick_cal(bk_type, date_approved_par, my_num_month, start_day_of_week, start_bk_month ){ if ( jQuery('#calendar_booking'+ bk_type).hasClass('hasDatepick') == true ) { // If the calendar with the same Booking resource is activated already, then exist. return false; } var cl = document.getElementById('calendar_booking'+ bk_type);if (cl === null) return; // Get calendar instance and exit if its not exist date_approved[ bk_type ] = date_approved_par; var isRangeSelect = false; var bkMultiDaysSelect = 365; if ( bk_days_selection_mode==='dynamic' ) { isRangeSelect = true; bkMultiDaysSelect = 0; } if ( bk_days_selection_mode==='single' ) bkMultiDaysSelect = 0; var bkMinDate = 0; var bkMaxDate = booking_max_monthes_in_calendar; var is_this_admin = false; if ( (location.href.indexOf('wpdev-booking.phpwpdev-booking-reservation') != -1 ) && (location.href.indexOf('booking_hash') != -1 ) ) { is_this_admin = true; bkMinDate = null; bkMaxDate = null; } function click_on_cal_td(){ if(typeof( selectDayPro ) == 'function') {selectDayPro( bk_type);} } function selectDay(date) { if(typeof( bkRangeDaysSelection ) == 'function') { // Check if this minimum BS version, and then proced jQuery('.datepick-days-cell' ).popover('hide'); } jQuery('#date_booking' + bk_type).val(date); if(typeof( selectDayPro ) == 'function') {selectDayPro( date, bk_type);} } function hoverDay(value, date){ if(typeof( hoverDayTime ) == 'function') {hoverDayTime(value, date, bk_type);} if ( (location.href.indexOf('wpdev-booking.phpwpdev-booking')==-1) || (location.href.indexOf('wpdev-booking.phpwpdev-booking-reservation')>0) ) { // Do not show it (range) at the main admin page if(typeof( hoverDayPro ) == 'function') {hoverDayPro(value, date, bk_type);} } //if(typeof( hoverAdminDay ) == 'function') { hoverAdminDay(value, date, bk_type); } } function applyCSStoDays(date ){ var class_day = (date.getMonth()+1) + '-' + date.getDate() + '-' + date.getFullYear(); var additional_class = ' '; if(typeof( prices_per_day ) !== 'undefined') if(typeof( prices_per_day[bk_type] ) !== 'undefined') if(typeof( prices_per_day[bk_type][class_day] ) !== 'undefined') { additional_class += ' rate_'+prices_per_day[bk_type][class_day]; } // define season filter names as classes if(typeof( wpdev_bk_season_filter ) !== 'undefined') if(typeof( wpdev_bk_season_filter[class_day] ) !== 'undefined') { additional_class += ' '+wpdev_bk_season_filter[class_day].join(' '); } if (is_this_admin == false) { var my_test_date = new Date( wpdev_bk_today[0],(wpdev_bk_today[1]-1), wpdev_bk_today[2] ,0,0,0 ); //Get today if ( (days_between( date, my_test_date)) < block_some_dates_from_today ) return [false, 'cal4date-' + class_day +' date_user_unavailable']; } if (typeof( is_this_day_available ) == 'function') { var is_day_available = is_this_day_available( date, bk_type); if (! is_day_available) {return [false, 'cal4date-' + class_day +' date_user_unavailable'];} } // Time availability if (typeof( check_global_time_availability ) == 'function') {check_global_time_availability( date, bk_type );} var blank_admin_class_day = ''; if(typeof(date_admin_blank[ bk_type ]) !== 'undefined') if(typeof(date_admin_blank[ bk_type ][ class_day ]) !== 'undefined') { blank_admin_class_day = ' date_admin_blank '; } // Check availability per day for BL var reserved_days_count = 1; if(typeof(availability_per_day) !== 'undefined') if(typeof(availability_per_day[ bk_type ]) !== 'undefined') if(typeof(availability_per_day[ bk_type ][ class_day ]) !== 'undefined') { reserved_days_count = parseInt( availability_per_day[ bk_type ][ class_day ] );} // Number of Check In Dates for BL var checkin_days_count = [0 ,0]; if(typeof(wpbc_check_in_dates) !== 'undefined') if(typeof(wpbc_check_in_dates[ bk_type ]) !== 'undefined') if(typeof(wpbc_check_in_dates[ bk_type ][ class_day ]) !== 'undefined') { // [ Number of check in bookings, Pending or Approved status ] checkin_days_count = [ wpbc_check_in_dates[ bk_type ][ class_day ][ 0 ] , wpbc_check_in_dates[ bk_type ][ class_day ][ 1 ] ]; } // Number of Check Out Dates for BL var checkout_days_count = [0 ,0]; if(typeof(wpbc_check_out_dates) !== 'undefined') if(typeof(wpbc_check_out_dates[ bk_type ]) !== 'undefined') if(typeof(wpbc_check_out_dates[ bk_type ][ class_day ]) !== 'undefined') { // [ Number of check Out bookings, Pending or Approved status ] checkout_days_count = [ wpbc_check_out_dates[ bk_type ][ class_day ][ 0 ] , wpbc_check_out_dates[ bk_type ][ class_day ][ 1 ] ]; } // Booked both check in/out dates in the same child resources var both_check_in_out_num = 0; if ( typeof( getNumberClosedCheckInOutDays ) == 'function' ) { both_check_in_out_num = getNumberClosedCheckInOutDays( bk_type, class_day ); } // we have 0 available at this day - Only for resources, which have childs if ( wpdev_in_array( parent_booking_resources, bk_type ) ) if (reserved_days_count <= 0) { if(typeof(date2approve[ bk_type ]) !== 'undefined') if(typeof(date2approve[ bk_type ][ class_day ]) !== 'undefined') return [false, 'cal4date-' + class_day +' date2approve date_unavailable_for_all_childs ' + blank_admin_class_day]; return [false, 'cal4date-' + class_day +' date_approved date_unavailable_for_all_childs ' + blank_admin_class_day]; } var th=0; var tm=0; var ts=0; var time_return_value = false; // Select dates which need to approve, its exist only in Admin if(typeof(date2approve[ bk_type ]) !== 'undefined') if(typeof(date2approve[ bk_type ][ class_day ]) !== 'undefined') { for (var ia=0;ia 0 ) ) { // Check Check In / Out dates for the parent resources. // Unavailable if ( (reserved_days_count - both_check_in_out_num ) <= 0 ) { // Check Pending or Approved by the Check In date if ( checkin_days_count[1] == 1 ) additional_class = ' date_approved'; else additional_class = ' date2approve'; return [false, 'cal4date-' + class_day + additional_class + blank_admin_class_day]; } // Recheck if this date check in/out if ( (reserved_days_count - both_check_in_out_num - checkin_days_count[0]) <= 0 ) { if ( checkin_days_count[1] == 1 ) additional_class += ' date_approved'; else additional_class += ' date2approve'; additional_class += ' timespartly check_in_time'; } if ( (reserved_days_count - both_check_in_out_num - checkout_days_count[0]) <= 0 ) { if ( checkout_days_count[1] == 1 ) additional_class += ' date_approved'; else additional_class += ' date2approve'; additional_class += ' timespartly check_out_time'; } } return [true, 'date_available cal4date-' + class_day +' reserved_days_count' + reserved_days_count + ' ' + is_datepick_unselectable + additional_class+ ' ']; } } function changeMonthYear(year, month){ if(typeof( bkRangeDaysSelection ) == 'function') { // Check if this minimum BS version, and then proced if(typeof( prepare_tooltip ) == 'function') { setTimeout("prepare_tooltip("+bk_type+");",1000); } } if(typeof( prepare_highlight ) == 'function') { setTimeout("prepare_highlight();",1000); } } // Configure and show calendar jQuery('#calendar_booking'+ bk_type).text(''); jQuery('#calendar_booking'+ bk_type).datepick( {beforeShowDay: applyCSStoDays, onSelect: selectDay, onHover:hoverDay, onChangeMonthYear:changeMonthYear, showOn: 'both', multiSelect: bkMultiDaysSelect, numberOfMonths: my_num_month, stepMonths: 1, prevText: '«', nextText: '»', dateFormat: 'dd.mm.yy', changeMonth: false, changeYear: false, minDate: bkMinDate, maxDate: bkMaxDate, //'1Y', showStatus: false, multiSeparator: ', ', closeAtTop: false, firstDay:start_day_of_week, gotoCurrent: false, hideIfNoPrevNext:true, rangeSelect:isRangeSelect, useThemeRoller :false // ui-cupertino.datepick.css } ); if ( start_bk_month != false ) { var inst = jQuery.datepick._getInst(document.getElementById('calendar_booking'+bk_type)); inst.cursorDate = new Date(); inst.cursorDate.setFullYear( start_bk_month[0], (start_bk_month[1]-1) , 1 ); inst.drawMonth = inst.cursorDate.getMonth(); inst.drawYear = inst.cursorDate.getFullYear(); jQuery.datepick._notifyChange(inst); jQuery.datepick._adjustInstDate(inst); jQuery.datepick._showDate(inst); jQuery.datepick._updateDatepick(inst); } if(typeof( bkRangeDaysSelection ) == 'function') { // Check if this minimum BS version, and then proced if(typeof( prepare_tooltip ) == 'function') {setTimeout("prepare_tooltip("+bk_type+");",1000);} } } //////////////////////////////////////////////////////////////////////////// // Days Selections - support functions //////////////////////////////////////////////////////////////////////////// // Get fisrst day of selection function get_first_day_of_selection(dates) { // Multiple days selections if ( dates.indexOf(',') != -1 ){ var dates_array =dates.split(/,\s*/); var length = dates_array.length; var element = null; var new_dates_array = []; for (var i = 0; i < length; i++) { element = dates_array[i].split(/\./); new_dates_array[new_dates_array.length] = element[2]+'.' + element[1]+'.' + element[0]; //2013.12.20 } new_dates_array.sort(); element = new_dates_array[0].split(/\./); return element[2]+'.' + element[1]+'.' + element[0]; //20.12.2013 } // Range days selection if ( dates.indexOf(' - ') != -1 ){ var start_end_date = dates.split(" - "); return start_end_date[0]; } // Single day selection return dates; //20.12.2013 } // Get fisrst day of selection function get_last_day_of_selection(dates) { // Multiple days selections if ( dates.indexOf(',') != -1 ){ var dates_array =dates.split(/,\s*/); var length = dates_array.length; var element = null; var new_dates_array = []; for (var i = 0; i < length; i++) { element = dates_array[i].split(/\./); new_dates_array[new_dates_array.length] = element[2]+'.' + element[1]+'.' + element[0]; //2013.12.20 } new_dates_array.sort(); element = new_dates_array[(new_dates_array.length-1)].split(/\./); return element[2]+'.' + element[1]+'.' + element[0]; //20.12.2013 } // Range days selection if ( dates.indexOf(' - ') != -1 ){ var start_end_date = dates.split(" - "); return start_end_date[(start_end_date.length-1)]; } // Single day selection return dates; //20.12.2013 } // Set selected days at calendar as UnAvailable function setUnavailableSelectedDays( bk_type ){ var sel_dates = jQuery('#calendar_booking'+bk_type).datepick('getDate'); var class_day2; for( var i =0; i '; jQuery('.submiting_content').fadeOut( new_booking_title_time ); } } else { setUnavailableSelectedDays(bk_type); // Set days as unavailable document.getElementById('date_booking'+bk_type).value = ''; // Set textarea date booking to '' jQuery('#calendar_booking'+bk_type+', .block_hints').hide(); var is_admin = 0; if (location.href.indexOf('booking.php') != -1 ) {is_admin = 1;} if (is_admin == 0) { // Get calendar from the html and insert it before form div, which will hide after btn click jQuery('#calendar_booking'+bk_type).insertBefore("#booking_form_div"+bk_type); document.getElementById("booking_form_div"+bk_type).style.display="none"; makeScroll('#ajax_respond_insert'+bk_type); if ( ( document.getElementById('paypalbooking_form'+bk_type) != null ) && ( document.getElementById('paypalbooking_form'+bk_type).innerHTML != '' ) ) is_pay_now = true; if ( (! is_pay_now) || ( is_booking_without_payment == true ) ) { if (type_of_thank_you_message == 'page') { // Page timeoutID_of_thank_you_page = setTimeout(function ( ) {location.href= thank_you_page_URL;} ,1000); } else { // Message document.getElementById('submiting'+bk_type).innerHTML = '
'+new_booking_title+'
'; makeScroll('#submiting'+bk_type); jQuery('.submiting_content').fadeOut( new_booking_title_time ); } } } else { setTimeout(function ( ) {location.reload(true);} ,1000); } } } //////////////////////////////////////////////////////////////////////////// // Submit Booking Data //////////////////////////////////////////////////////////////////////////// // Check fields at form and then send request function mybooking_submit( submit_form , bk_type, wpdev_active_locale){ var count = submit_form.elements.length; var formdata = ''; var inp_value; var element; var el_type; // Serialize form here for (i=0; i