// Get HTML for the initilizing inline calendars
function pre_get_calendar_html( $resource_id=1, $cal_count=1, $bk_otions=array() ){
//SHORTCODE:
/*
* [booking type=56 form_type='standard' nummonths=4
* options='{calendar months_num_in_row=2 width=682px cell_height=48px}']
*/
$bk_otions = wpbc_parse_calendar_options($bk_otions);
/* options:
[months_num_in_row] => 2
[width] => 341px define: width: 100%; max-width:341px;
[strong_width] => 341px define: width:341px;
[cell_height] => 48px
*/
$width = $months_num_in_row = $cell_height = '';
if (!empty($bk_otions)){
if ( isset( $bk_otions['months_num_in_row'] ) ) {
$months_num_in_row = $bk_otions['months_num_in_row'];
}
if ( isset( $bk_otions['width'] ) ) {
$width = 'width:100%;max-width:' . $bk_otions['width'] . ';'; //FixIn: 9.3.1.5
}
if ( isset( $bk_otions['strong_width'] ) ) {
$width .= 'width:' . $bk_otions['strong_width'] . ';'; //FixIn: 9.3.1.6
}
if ( isset( $bk_otions['cell_height'] ) ) {
$cell_height = $bk_otions['cell_height'];
}
if ( isset( $bk_otions['strong_cell_height'] ) ) { //FixIn: 9.7.3.3
$cell_height = $bk_otions['strong_cell_height'] . '!important;';
}
}
/* FixIn: 9.7.3.4 */
if (!empty($cell_height))
$style= '';
else $style= '';
//FixIn: 8.2.1.27
$booking_timeslot_day_bg_as_available = get_bk_option( 'booking_timeslot_day_bg_as_available' );
$booking_timeslot_day_bg_as_available = ( $booking_timeslot_day_bg_as_available === 'On' ) ? ' wpbc_timeslot_day_bg_as_available' : '';
//FixIn: 9.8.1
$is_custom_width_css = ( empty( $width ) ) ? ' wpbc_no_custom_width ' : '';
$calendar = $style.
'' .
'
' .
__('Calendar is loading...' ,'booking').
'
'.
'
'.
'';
$booking_is_show_powered_by_notice = get_bk_option( 'booking_is_show_powered_by_notice' );
if ( ( ! class_exists( 'wpdev_bk_personal' ) ) && ( $booking_is_show_powered_by_notice == 'On' ) ) {
$calendar .= '';
}
$calendar .= ''; // Calendar code
$calendar .= wpbc_get_calendar_legend(); //FixIn: 9.4.3.6
$calendar_css_class_outer = 'wpbc_calendar_wraper';
//FixIn: 7.0.1.24
$is_booking_change_over_days_triangles = get_bk_option( 'booking_change_over_days_triangles' );
if ( $is_booking_change_over_days_triangles !== 'Off' ) {
$calendar_css_class_outer .= ' wpbc_change_over_triangle';
}
$calendar = '' . $calendar . '
';
return $calendar;
}
// Get form
function get_booking_form( $my_boook_type ) {
$my_form = apply_bk_filter( 'wpbc_get_free_booking_form' , $my_boook_type );
return $my_form;
}
// Get booking form
function get_booking_form_action( $resource_id = 1, $my_boook_count = 1, $my_booking_form = 'standard', $my_selected_dates_without_calendar = '', $start_month_calendar = false, $bk_otions = array() ) {
$res = $this->add_booking_form_action($resource_id,$my_boook_count, 0, $my_booking_form , $my_selected_dates_without_calendar, $start_month_calendar, $bk_otions );
return $res;
}
//Show booking form from action call - wpdev_bk_add_form
function add_booking_form_action( $resource_id = 1, $cal_count = 1, $is_echo = 1, $my_booking_form = 'standard', $my_selected_dates_without_calendar = '', $start_month_calendar = false, $bk_otions = array() ) {
$additional_bk_types = array();
if ( strpos($resource_id,';') !== false ) {
$additional_bk_types = explode(';',$resource_id);
$resource_id = $additional_bk_types[0];
}
//--------------------------------------------------------------------------------------------------------------
// Check if booking resource exist
if ( $resource_id == '') {
$my_result = __('Booking resource type is not defined. This can be, when at the URL is wrong booking hash.' ,'booking');
if ( $is_echo ) echo $my_result;
else return $my_result;
return;
}
$is_booking_resource_exist = apply_bk_filter('wpdev_is_booking_resource_exist',true, $resource_id, $is_echo );
if (! $is_booking_resource_exist) {
if ( $is_echo ) echo 'Booking resource does not exist.' . ' [ID=' . $resource_id . ']';
return 'Booking resource does not exist.' . ' [ID=' . $resource_id . ']';
}
//--------------------------------------------------------------------------------------------------------------
// Define $this->client_side_active_params_of_user to specific User,
// depends from belonging booking resource to specific User
make_bk_action('check_multiuser_params_for_client_side', $resource_id );
//--------------------------------------------------------------------------------------------------------------
// Get Booking ID and booking resource ID, if we EDIT booking
if ( isset( $_GET['booking_hash'] ) ) {
$my_booking_id_type = wpbc_hash__get_booking_id__resource_id( $_GET['booking_hash'] );
$is_error = false; //FixIn: 9.1.3.2
if ( $my_booking_id_type !== false ) {
list( $my_edited_bk_id, $my_boook_type ) = $my_booking_id_type;
if ( $my_boook_type == '' ) {
$is_error ='' . __('Oops!' ,'booking') . ' ' . __('We could not find your booking. The link you used may be incorrect or has expired. If you need assistance, please contact our support team.' ,'booking');
}
} else {
$is_error = '' . __('Oops!' ,'booking') . ' ' . __('We could not find your booking. The link you used may be incorrect or has expired. If you need assistance, please contact our support team.' ,'booking');
}
if ( false !== $is_error ) {
if ( $is_echo ) {
echo $is_error;
}
return $is_error;
}
// Check situation when we have editing "child booking resource", so need to reupdate calendar and form to have it for parent resource.
if ( //FixIn: 6.1.1.9 //Fix:2016-10-12
( ! isset( $_GET['booking_pay'] ) )
&& ( ! isset( $_GET['resource_no_update'] ) ) //FixIn: 9.4.2.3
&& ( function_exists( 'wpbc_is_this_child_resource' ) )
&& ( wpbc_is_this_child_resource( $my_boook_type ) )
){
$bk_parent_br_id = wpbc_get_parent_resource( $my_boook_type );
$resource_id = $bk_parent_br_id;
}
}
//--------------------------------------------------------------------------------------------------------------
// Get JS vars for Booked dates | Rates | Availability & define function for showing calendar
$start_script_code = wpbc__calendar__load( array(
'resource_id' => $resource_id,
'aggregate_resource_id_arr' => $additional_bk_types,
'selected_dates_without_calendar' => $my_selected_dates_without_calendar,
'calendar_number_of_months' => $cal_count,
'start_month_calendar' => $start_month_calendar,
'shortcode_options' => $bk_otions,
'custom_form' => ( isset( $_GET['booking_form'] ) ) ? wpbc_clean_text_value( $_GET['booking_form'] ) : $my_booking_form //FixIn: 10.0.0.10
));
if ( $my_selected_dates_without_calendar !== '' ) { //FixIn: 9.3.1.1
// Disable booked time slots, for predefined selected date in the booking form (it's shortcode for booking form, without the calendar)
$start_script_code .= ''; //FixIn: 10.1.3.7
}
//--------------------------------------------------------------------------------------------------------------
// Get booking form content
$my_result = ' ' . $this->get__client_side_booking_content($resource_id, $my_booking_form, $my_selected_dates_without_calendar, $cal_count, $bk_otions ) . ' ' . $start_script_code ;
$my_result = apply_filters('wpdev_booking_form', $my_result , $resource_id); // Add DIV structure, where to show payment form
make_bk_action('finish_check_multiuser_params_for_client_side', $resource_id );
if ( $is_echo ) echo $my_result;
else return $my_result;
}
/**
* For [bookingcalendar ... ] shortcode Only!
*
* @param $resource_id
* @param $cal_count
* @param $is_echo
* @param $start_month_calendar
* @param $bk_otions
*
* @return string|void
*/
function add_calendar_action( $resource_id = 1, $cal_count = 1, $is_echo = 1, $start_month_calendar = false, $bk_otions = array() ) {
$additional_bk_types = array();
if ( strpos($resource_id,';') !== false ) {
$additional_bk_types = explode(';',$resource_id);
$resource_id = $additional_bk_types[0];
}
make_bk_action('check_multiuser_params_for_client_side', $resource_id );
if (isset($_GET['booking_hash'])) {
$my_booking_id_type = wpbc_hash__get_booking_id__resource_id( $_GET['booking_hash'] );
if ($my_booking_id_type != false)
if ($my_booking_id_type[1]=='') {
$my_result = '' . __('Oops!' ,'booking') . ' ' . __('We could not find your booking. The link you used may be incorrect or has expired. If you need assistance, please contact our support team.' ,'booking');
if ( $is_echo ) echo $my_result;
else return $my_result;
return;
}
}
$start_script_code = wpbc__calendar__load( array(
'resource_id' => $resource_id,
'aggregate_resource_id_arr' => $additional_bk_types,
'selected_dates_without_calendar' => '',
'calendar_number_of_months' => $cal_count,
'start_month_calendar' => $start_month_calendar,
'custom_form' => 'standard' // Because we show only 'AVAILABILITY CALENDAR' without the form, at all.
));
$my_result = '' . $this->pre_get_calendar_html( $resource_id, $cal_count, $bk_otions );
$my_result .= ' ' . $start_script_code ;
$my_result = apply_filters('wpdev_booking_calendar', $my_result , $resource_id);
$booking_form_is_using_bs_css = get_bk_option( 'booking_form_is_using_bs_css' );
$my_result = '' . $my_result . '';
make_bk_action('finish_check_multiuser_params_for_client_side', $resource_id );
if ( $is_echo ) echo $my_result;
else return $my_result;
}
// Get content at client side of C A L E N D A R
function get__client_side_booking_content( $resource_id = 1, $my_booking_form = 'standard', $my_selected_dates_without_calendar = '', $cal_count = 1, $bk_otions = array() ) {
$nl = ''; // New line
if ($my_selected_dates_without_calendar=='') {
// Get HTML with [calendar] shortcode and Styles for calendar. Get legend html.
$calendar = $this->pre_get_calendar_html( $resource_id, $cal_count, $bk_otions );
} else {
$calendar = ''; // Calendar code
}
//FixIn: 8.2.1.1
$form = '';
$submitting = '';
//Params: $action = -1, $name = "_wpnonce", $referer = true , $echo = true
$wpbc_nonce = wp_nonce_field('CALCULATE_THE_COST', ( "wpbc_nonceCALCULATE_THE_COST" . $resource_id) , true , false );
$res = $form . $submitting . $wpbc_nonce;
$my_random_id = time() * rand(0,1000);
$my_random_id = 'form_id'. $my_random_id;
$booking_form_is_using_bs_css = get_bk_option( 'booking_form_is_using_bs_css');
$booking_form_format_type = get_bk_option( 'booking_form_format_type');
$booking_form_theme = get_bk_option( 'booking_form_theme');
$return_form = '';
$return_form .= '';
if ($my_selected_dates_without_calendar == '' ) {
// Check according already shown Booking Calendar and set do not visible of it
$return_form .= ''; //FixIn: 10.1.3.7
} else {
//FixIn:6.1.1.16 //FixIn: 8.2.1.13
$return_form .= ''; //FixIn: 10.1.3.7
}
$is_use_auto_fill_for_logged = get_bk_option( 'booking_is_use_autofill_4_logged_user' ) ;
if (! isset($_GET['booking_hash']))
if ($is_use_auto_fill_for_logged == 'On') {
$curr_user = wpbc_get_current_user();
if ( $curr_user->ID > 0 ) {
$user_nick_name = get_user_meta( $curr_user->ID, 'nickname' );
$user_nick_name = ( empty( $user_nick_name ) ) ? '' : $user_nick_name[0]; //FixIn: 8.7.1.5
$return_form .= ''; //FixIn: 10.1.3.7
}
}
return $return_form ;
}
//
//