var list_booking_id_for_show = [];
var prices_per_day = [];
var cost_curency = '';
var wpdev_bk_weekday_conditions_for_range_selection = [];
var wpdev_bk_seasons_conditions_for_range_selection = [];
var wpdev_bk_seasons_conditions_for_start_day = [];
var bk_2clicks_mode_days_selection__saved_variables = []; // Saved initial values of varibales: bk_2clicks_mode_days_specific , bk_2clicks_mode_days_min, bk_2clicks_mode_days_max
function addBKForm(param){
document.getElementById('bk_form_plus').style.display='none';
document.getElementById('bk_form_addbutton').style.display='block';
setTimeout(function ( ) {
jQuery('#booking_form_new_name').focus();
}
,100);
}
function delete_bk_form(form_name){
var wpdev_ajax_path = wpdev_bk_plugin_url+'/' + wpdev_bk_plugin_filename;
//Ajax adding new type to the DB
document.getElementById('ajax_working').innerHTML =
'
\n\
Deleting...
\n\
\n\
\n\
\n\
';
jQuery.ajax({ // Start Ajax Sending
// url: wpdev_ajax_path,
url: wpbc_ajaxurl,
type:'POST',
success: function (data, textStatus){if( textStatus == 'success') jQuery('#ajax_respond').html( data );},
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:' + ' http://wpbookingcalendar.com/faq/#ajax-sending-error');}},
// beforeSend: someFunction,
data:{
// ajax_action : 'DELETE_BK_FORM',
action : 'DELETE_BK_FORM',
formname : form_name,
wpbc_nonce: document.getElementById('wpbc_admin_panel_nonce').value
}
});
return false;
}
function changeBookingFormForAdvancedCost(selectObj){
var idx = selectObj.selectedIndex;
var my_form = selectObj.options[idx].value;
jQuery('.wpdev_forms_div').hide();
jQuery( '#' + my_form ).show();
}
function changeBookingForm(selectObj){
var idx = selectObj.selectedIndex;
var my_form = selectObj.options[idx].value;
var loc = location.href;
if (loc.substr((loc.length-1),1)=='#') {
loc = loc.substr(0,(loc.length-1) );
}
if ( loc.indexOf('booking_form=') == -1 ) {
loc = loc + '&booking_form=' +my_form;}
else { // Alredy have this paremeter at URL
var start = loc.indexOf('&booking_form=');
var fin = loc.indexOf('&', (start+15));
if (fin == -1) {loc = loc.substr(0,start) + '&booking_form=' +my_form;} // at the end of row
else { // at the middle of the row
var loc1 = loc.substr(0,start) + '&booking_form=' +my_form;//alert(loc)
loc = loc1 + loc.substr(fin);
}
}
location.href = loc;
}
function changeFilter(selectObj){
var idx = selectObj.selectedIndex;
// get the value of the selected option
var which = selectObj.options[idx].value;
var loc = location.href;
if ( loc.indexOf('sybtypefilter=') == -1 ) {
loc = location.href + '&sybtypefilter=' +which;}
else { // Alredy have this paremeter at URL
var start = loc.indexOf('&sybtypefilter=');
var fin = loc.indexOf('&', (start+15));
if (fin == -1) {loc = loc.substr(0,start) + '&sybtypefilter=' +which;} // at the end of row
else { // at the middle of the row
var loc1 = loc.substr(0,start) + '&sybtypefilter=' +which;//alert(loc)
loc = loc1 + loc.substr(fin);
}
}
location.href = loc;
}
function filterBookingRowsApply(){
// alert(list_booking_id_for_show);
hide_bk_rows = [];
for(var i=0; i 0 ) jQuery(document).ready(filterBookingRowsApply);
function setavailabilitycontent(contnt){
document.getElementById('selectword').innerHTML = contnt;
}
function is_this_day_available( date, bk_type){ //TODO continue here according time
function in_array(what, where) {
var a=false;
for(var i=0; i';
return tooltip_time + cost_curency + prices_per_day[bk_type][td_class] ;
}
}
return tooltip_time ;
}
// Admin panel - Add additional row with cost, which is depends from number of selected days
function addRowForCustomizationCostDependsFromNumSellDays(row__id) {
jQuery('#cost_days_row_help'+row__id ).html( getRowForCustomizationCostDependsFromNumSellDays(row__id)) ;
}
function getRowForCustomizationCostDependsFromNumSellDays(row__id) {
return '';
}
function addRowForCustomizationCostDependsFromNumSellDays4Summ(row__id) {
jQuery('#cost_days_row_help'+row__id ).html( getRowForCustomizationCostDependsFromNumSellDays4Summ(row__id)) ;
}
function getRowForCustomizationCostDependsFromNumSellDays4Summ(row__id) {
return '';
}
function getBookingFormElements(bk_type){
var submit_form = document.getElementById('booking_form' + bk_type );
var formdata = '';
if (submit_form != null) {
var count = submit_form.elements.length;
var inp_value;
var element;
var el_type;
// Serialize form here
for (i=0; i/span>';
if (document.getElementById('additional_booking_hint' + bk_type) !== null)
document.getElementById('additional_booking_hint' + bk_type).innerHTML =
'/span>';
if (document.getElementById('original_booking_hint' + bk_type) !== null)
document.getElementById('original_booking_hint' + bk_type).innerHTML =
'/span>';
if (document.getElementById('original_booking_hint' + bk_type) !== null)
document.getElementById('original_booking_hint' + bk_type).innerHTML =
'/span>';
if (document.getElementById('deposit_booking_hint' + bk_type) !== null)
document.getElementById('deposit_booking_hint' + bk_type).innerHTML =
'/span>';
if (document.getElementById('balance_booking_hint' + bk_type) !== null)
document.getElementById('balance_booking_hint' + bk_type).innerHTML =
'/span>';
// Dates and Times shortcodes
if (document.getElementById('check_in_date_hint_tip' + bk_type) !== null)
document.getElementById('check_in_date_hint_tip' + bk_type).innerHTML =
'/span>';
if (document.getElementById('check_out_date_hint_tip' + bk_type) !== null)
document.getElementById('check_out_date_hint_tip' + bk_type).innerHTML =
'/span>';
if (document.getElementById('start_time_hint_tip' + bk_type) !== null)
document.getElementById('start_time_hint_tip' + bk_type).innerHTML =
'/span>';
if (document.getElementById('end_time_hint_tip' + bk_type) !== null)
document.getElementById('end_time_hint_tip' + bk_type).innerHTML =
'/span>';
if (document.getElementById('selected_dates_hint_tip' + bk_type) !== null)
document.getElementById('selected_dates_hint_tip' + bk_type).innerHTML =
'/span>';
if (document.getElementById('selected_timedates_hint_tip' + bk_type) !== null)
document.getElementById('selected_timedates_hint_tip' + bk_type).innerHTML =
'/span>';
if (document.getElementById('selected_short_dates_hint_tip' + bk_type) !== null)
document.getElementById('selected_short_dates_hint_tip' + bk_type).innerHTML =
'/span>';
if (document.getElementById('selected_short_timedates_hint_tip' + bk_type) !== null)
document.getElementById('selected_short_timedates_hint_tip' + bk_type).innerHTML =
'/span>';
if (document.getElementById('days_number_hint_tip' + bk_type) !== null)
document.getElementById('days_number_hint_tip' + bk_type).innerHTML =
'/span>';
if (document.getElementById('nights_number_hint_tip' + bk_type) !== null)
document.getElementById('nights_number_hint_tip' + bk_type).innerHTML =
'/span>';
var wpdev_ajax_path = wpdev_bk_plugin_url+'/' + wpdev_bk_plugin_filename;
var ajax_type_action='CALCULATE_THE_COST';
var my_booking_form='';
if (document.getElementById('booking_form_type' + bk_type) != undefined)
my_booking_form =document.getElementById('booking_form_type' + bk_type).value;
jQuery.ajax({ // Start Ajax Sending
// url: wpdev_ajax_path,
url: wpbc_ajaxurl,
type:'POST',
success: function (data, textStatus){if( textStatus == 'success') jQuery('#ajax_respond_insert' + bk_type).html( data ) ;},
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:' + ' http://wpbookingcalendar.com/faq/#ajax-sending-error');}},
// beforeSend: someFunction,
data:{
action: ajax_type_action,
// ajax_action : ajax_type_action,
form: formdata,
all_dates : all_dates,
bk_type : bk_type,
booking_form_type:my_booking_form,
wpdev_active_locale:wpbc_active_locale,
wpbc_nonce: document.getElementById('wpbc_nonce'+ ajax_type_action + bk_type).value
}
});
return false;
}
var temp_click_mode_days_start = [];
function check_conditions_for_start_day_selection(bk_type, selceted_first_day, is_start){
if (is_start == 'start') {
temp_click_mode_days_start = [];
// S E A S O N C O N D I T I O N S
if ( wpdev_bk_seasons_conditions_for_start_day.length > 0 )
if ( typeof( wpdev_bk_seasons_conditions_for_start_day[bk_type] ) != 'undefined' )
if ( wpdev_bk_seasons_conditions_for_start_day[bk_type].length > 0 ) {
var class_day = (selceted_first_day.getMonth()+1) + '-' + selceted_first_day.getDate() + '-' + selceted_first_day.getFullYear();
if (jQuery('#calendar_booking'+bk_type+' .datepick-days-cell.cal4date-'+class_day).length <= 0) return; // This date is not exist
var calendarDateClassList =jQuery('#calendar_booking'+bk_type+' .datepick-days-cell.cal4date-'+class_day).attr('class').split(/\s+/);
// Check for the Season filters conditions for the range days selection
jQuery.each( calendarDateClassList, function(index, singleClassCSS){
// S E A S O N F I L T E R C O N D I T I O N S - checking
if ( singleClassCSS.indexOf("wpdevbk_season_") >= 0 ) {
singleClassCSS = singleClassCSS.replace('wpdevbk_season_', '');
jQuery.each( wpdev_bk_seasons_conditions_for_start_day[bk_type], function(ind, seasons_condition){
if ( (singleClassCSS == seasons_condition[0] ) && ( temp_click_mode_days_start.length == 0 ) ){
temp_click_mode_days_start = [bk_2clicks_mode_days_start, bk_1click_mode_days_start];
bk_2clicks_mode_days_start = seasons_condition[1] ;
bk_1click_mode_days_start = seasons_condition[1];
}
});
}
});
}
}
if (is_start == 'end') {
if ( temp_click_mode_days_start.length > 0 ) {
bk_2clicks_mode_days_start = temp_click_mode_days_start[0];
if ( temp_click_mode_days_start.length > 1 ) {
bk_1click_mode_days_start = temp_click_mode_days_start[1];
temp_click_mode_days_start = [];
}
}
}
}
// TODO:3 Interface in the popup dialog for possibility to enter these conditions
// TODO:5 Refactoring structure
function check_conditions_for_range_days_selection(all_dates, bk_type){
if ( ( bk_days_selection_mode != 'dynamic') &&
( bk_days_selection_mode != 'fixed') ) return false; // This conditional logic is possible only if the rnage days selection using 2 mouse clicks is activated
if (all_dates == '') return false; // If no days selections so then skip all.
if ( typeof(all_dates) == 'object' ) { // H I G H L I G H T // If this paramater is object (Date), so its mean that we are highlight the dates
var selceted_first_day = all_dates;
all_dates = document.getElementById('date_booking'+bk_type).value; // Get dates from the textarea date booking to ''
if (all_dates != '') { // If some date is selected
var first_date = get_first_day_of_selection(all_dates); // So we are DO NOT MAKE chnaging of highlighting if its was first click.
var last_date = get_last_day_of_selection(all_dates);
if ( first_date == last_date ) return false;
}
} else { // S E L E C T
var first_date = get_first_day_of_selection(all_dates);
var last_date = get_last_day_of_selection(all_dates);
if ( first_date != last_date ) return false; // We are clicked second time
var date_sections = first_date.split(".");
var selceted_first_day = new Date;
selceted_first_day.setFullYear( parseInt(date_sections[2]-0) ,parseInt(date_sections[1]-1), parseInt(date_sections[0]-0) );
}
check_conditions_for_range_days_selection_for_check_in(selceted_first_day, bk_type);
}
function check_conditions_for_range_days_selection_for_check_in(selceted_first_day, bk_type){
if ( bk_2clicks_mode_days_selection__saved_variables.length == 0) { // Saved ONLY ONCE initial values of varibales: bk_2clicks_mode_days_specific , bk_2clicks_mode_days_min, bk_2clicks_mode_days_max
bk_2clicks_mode_days_selection__saved_variables = [ bk_2clicks_mode_days_specific,
bk_2clicks_mode_days_min,
bk_2clicks_mode_days_max,
bk_1click_mode_days_num
];
}
var is_condition_applied = false;
// S E A S O N C O N D I T I O N S
if ( wpdev_bk_seasons_conditions_for_range_selection.length > 0 )
if ( typeof( wpdev_bk_seasons_conditions_for_range_selection[bk_type] ) != 'undefined' )
if ( wpdev_bk_seasons_conditions_for_range_selection[bk_type].length > 0 ) {
var class_day = (selceted_first_day.getMonth()+1) + '-' + selceted_first_day.getDate() + '-' + selceted_first_day.getFullYear();
if (jQuery('#calendar_booking'+bk_type+' .datepick-days-cell.cal4date-'+class_day).length <= 0) return; // This date is not exist
var calendarDateClassList =jQuery('#calendar_booking'+bk_type+' .datepick-days-cell.cal4date-'+class_day).attr('class').split(/\s+/);
// Check for the Season filters conditions for the range days selection
jQuery.each( calendarDateClassList, function(index, singleClassCSS){
// S E A S O N F I L T E R C O N D I T I O N S - checking
if ( singleClassCSS.indexOf("wpdevbk_season_") >= 0 ) {
singleClassCSS = singleClassCSS.replace('wpdevbk_season_', '');
jQuery.each( wpdev_bk_seasons_conditions_for_range_selection[bk_type], function(ind, seasons_condition){
if (singleClassCSS == seasons_condition[0] ) {
bk_2clicks_mode_days_specific = seasons_condition[1] ;
bk_2clicks_mode_days_min = seasons_condition[1][0];
bk_2clicks_mode_days_max = seasons_condition[1][ (seasons_condition[1].length-1) ];
bk_1click_mode_days_num = seasons_condition[1][0];
is_condition_applied = true;
}
});
}
});
}
// W E E K D A Y S C O N D I T I O N S
if ( wpdev_bk_weekday_conditions_for_range_selection.length > 0 )
if ( typeof( wpdev_bk_weekday_conditions_for_range_selection[bk_type] ) != 'undefined' )
if ( wpdev_bk_weekday_conditions_for_range_selection[bk_type].length > 0 ) {
// Check for the WEEK DAY filters conditions for the range days selection
jQuery.each( wpdev_bk_weekday_conditions_for_range_selection[bk_type], function(ind, weekday_condition){
if ( selceted_first_day.getDay() == weekday_condition[0] ) {
bk_2clicks_mode_days_specific = weekday_condition[1] ;
bk_2clicks_mode_days_min = weekday_condition[1][0];
bk_2clicks_mode_days_max = weekday_condition[1][ (weekday_condition[1].length-1) ];
bk_1click_mode_days_num = weekday_condition[1][0];
is_condition_applied = true;
}
});
}
if ( is_condition_applied == false ) {
// Reset to the global initial conditions
bk_2clicks_mode_days_specific = bk_2clicks_mode_days_selection__saved_variables[0];
bk_2clicks_mode_days_min = bk_2clicks_mode_days_selection__saved_variables[1];
bk_2clicks_mode_days_max = bk_2clicks_mode_days_selection__saved_variables[2];
bk_1click_mode_days_num = bk_2clicks_mode_days_selection__saved_variables[3];
}
}
function wpdevbk_get_selected_checkboxes_id(my_link, my_parameter, my_current_id, my_checkboxes){
var all_selected_id = my_current_id + ',';
// Get all selecyed IDs
jQuery(my_checkboxes).each(function () {
if (this.checked) {
if (jQuery(this).val() != my_current_id )
all_selected_id += jQuery(this).val() + ',';
}
});
// Remove last ","
all_selected_id = all_selected_id.substring(0,(all_selected_id.length-1) );
window.location.href= my_link + '&' + my_parameter + '=' + all_selected_id ;
}