| 1 |
<?php /** |
| 2 |
* @version 1.0 |
| 3 |
* @package Booking Calendar |
| 4 |
* @category Content of Add New Booking |
| 5 |
* @author wpdevelop |
| 6 |
* |
| 7 |
* @web-site https://wpbookingcalendar.com/ |
| 8 |
* @email info@wpbookingcalendar.com |
| 9 |
* |
| 10 |
* @modified 2015-10-31 |
| 11 |
*/ |
| 12 |
|
| 13 |
if ( ! defined( 'ABSPATH' ) ) exit; // Exit if accessed directly |
| 14 |
|
| 15 |
|
| 16 |
/** |
| 17 |
* Show Content |
| 18 |
* Update Content |
| 19 |
* Define Slug |
| 20 |
* Define where to show |
| 21 |
*/ |
| 22 |
class WPBC_Page_AddNewBooking extends WPBC_Page_Structure { |
| 23 |
|
| 24 |
|
| 25 |
public function in_page() { |
| 26 |
return 'wpbc-new'; |
| 27 |
} |
| 28 |
|
| 29 |
public function tabs() { |
| 30 |
|
| 31 |
$tabs = array(); |
| 32 |
$tabs['add-booking'] = array( |
| 33 |
'is_show_top_path' => false, // true | false. By default value is: false. |
| 34 |
'left_navigation__default_view_mode' => 'compact', // '' | 'min' | 'compact' | 'max' | 'none'. By default value is: ''. |
| 35 |
'page_title' => __( 'Add New Booking', 'booking' ), // Header - Title. If false, than hidden. |
| 36 |
'page_description' => __( 'Manually add new bookings from the Admin Panel.', 'booking' ), // Header - Title Description. If false, than hidden. |
| 37 |
'title' => __( 'Add booking', 'booking' ), // Title of TAB. |
| 38 |
'hint' => __( 'Add booking', 'booking' ), // Hint. |
| 39 |
'link' => '', // Can be skiped, then generated link based on Page and Tab tags. Or can be extenral link. |
| 40 |
'position' => '', // Can be: 'left' | 'right' | ''. |
| 41 |
'css_classes' => '', // this is CSS class(es). |
| 42 |
'icon' => '', // Icon - link to the real PNG img. |
| 43 |
'font_icon' => 'wpbc-bi-calendar-plus', // CSS definition of forn Icon. |
| 44 |
'default' => true, // Is this tab activated by default or not: true || false. |
| 45 |
'disabled' => false, // Is this tab disbaled: true || false. |
| 46 |
'hided' => true, // Is this tab hided: true || false. |
| 47 |
'subtabs' => array(), |
| 48 |
); |
| 49 |
|
| 50 |
return $tabs; |
| 51 |
} |
| 52 |
|
| 53 |
|
| 54 |
public function content() { |
| 55 |
|
| 56 |
do_action( 'wpbc_hook_add_booking_page_header', 'add_booking' ); // Define Notices Section and show some static messages, if needed. |
| 57 |
|
| 58 |
if ( ! wpbc_is_mu_user_can_be_here( 'activated_user' ) ) { |
| 59 |
return false; // Check if MU user activated, otherwise show Warning message. |
| 60 |
} |
| 61 |
|
| 62 |
if ( ! wpbc_set_default_resource_to__get() ) { |
| 63 |
return false; // Define default booking resources for $_ GET and check if booking resource belong to user. |
| 64 |
} |
| 65 |
|
| 66 |
?><span class="wpdevelop"><?php // BS UI CSS Class. |
| 67 |
|
| 68 |
wpbc_js_for_bookings_page(); // JavaScript functions. |
| 69 |
|
| 70 |
// T o o l b a r s. |
| 71 |
wpbc_add_new_booking_toolbar(); |
| 72 |
|
| 73 |
?></span><!-- wpdevelop class --><?php |
| 74 |
|
| 75 |
?><div class="clear" style="height:40px;"></div><?php |
| 76 |
|
| 77 |
?><div class="add_booking_page_content" style="width:100%;margin-bottom:100px;"><?php |
| 78 |
|
| 79 |
// Previously we defined booking resources to $_GET |
| 80 |
$bk_type = isset( $_GET['booking_type'] ) ? intval( $_GET['booking_type'] ) : 1; // phpcs:ignore WordPress.Security.NonceVerification.Recommended |
| 81 |
|
| 82 |
// do_action( 'wpdev_bk_add_form', $bk_type, get_bk_option( 'booking_client_cal_count' ) ); |
| 83 |
|
| 84 |
$saved_user_calendar_params = $this->get_saved_user_calendar_options(); |
| 85 |
|
| 86 |
make_bk_action( 'wpdevbk_add_form' |
| 87 |
, $bk_type // $bk_type =1 |
| 88 |
, $saved_user_calendar_params['months_number'] // get_bk_option( 'booking_client_cal_count' ) // $cal_count = 1 |
| 89 |
, 1 // $is_echo = 1 |
| 90 |
, 'standard' // $my_booking_form = 'standard' |
| 91 |
, '' // $my_selected_dates_without_calendar = '' |
| 92 |
, false // $start_month_calendar = false |
| 93 |
, '{calendar' . $saved_user_calendar_params['options_param'] . '}' // $bk_otions=array() |
| 94 |
); // FixIn: 6.0.1.6. |
| 95 |
|
| 96 |
?></div><?php |
| 97 |
|
| 98 |
|
| 99 |
?><hr /><?php |
| 100 |
wpbc_toolbar_is_send_emails_btn_duplicated(); |
| 101 |
|
| 102 |
|
| 103 |
wpbc_bs_javascript_popover(); // JS Popover |
| 104 |
|
| 105 |
do_action( 'wpbc_hook_add_booking_page_footer', 'add_booking' ); |
| 106 |
} |
| 107 |
|
| 108 |
|
| 109 |
/** |
| 110 |
* Get Calendar Options of specific User |
| 111 |
* |
| 112 |
* @return array (number of months, options parameter |
| 113 |
*/ |
| 114 |
function get_saved_user_calendar_options() { |
| 115 |
|
| 116 |
// Get possible saved previous "Custom User Calendar data" |
| 117 |
$user_calendar_options = get_user_option( 'booking_custom_' . 'add_booking_calendar_options', wpbc_get_current_user_id() ); |
| 118 |
|
| 119 |
if ( $user_calendar_options === false ) { // Default, if no saved previously. |
| 120 |
$user_calendar_options = array(); |
| 121 |
$user_calendar_options['calendar_months_count'] = 1; |
| 122 |
$user_calendar_options['calendar_months_num_in_1_row'] = 0 ; |
| 123 |
$user_calendar_options['calendar_width'] = ''; |
| 124 |
$user_calendar_options['calendar_widthunits'] = 'px'; |
| 125 |
$user_calendar_options['calendar_cell_height'] = ''; |
| 126 |
$user_calendar_options['calendar_cell_heightunits'] = 'px'; |
| 127 |
} else { |
| 128 |
$user_calendar_options = maybe_unserialize( $user_calendar_options ); |
| 129 |
} |
| 130 |
|
| 131 |
if ( ! empty( $user_calendar_options['calendar_months_count'] ) ) |
| 132 |
$selected_calendar_months_count = intval ( $user_calendar_options['calendar_months_count'] ); |
| 133 |
else $selected_calendar_months_count = 1; |
| 134 |
|
| 135 |
if ( ! empty( $user_calendar_options['calendar_months_num_in_1_row'] ) ) |
| 136 |
$option_months_num_in_row = ' months_num_in_row=' . intval ( $user_calendar_options['calendar_months_num_in_1_row'] ); |
| 137 |
else $option_months_num_in_row = ''; |
| 138 |
|
| 139 |
if ( ! empty( $user_calendar_options['calendar_width'] ) ) { |
| 140 |
$unit_value = ( esc_attr( $user_calendar_options['calendar_widthunits'] ) == 'percent' ) ? '%' : esc_attr( $user_calendar_options['calendar_widthunits'] ); |
| 141 |
$option_width = ' width=' . intval( $user_calendar_options['calendar_width'] ) . $unit_value; |
| 142 |
$option_width .= ' strong_width=' . intval( $user_calendar_options['calendar_width'] ) . $unit_value; // FixIn: 9.3.1.6. |
| 143 |
} else $option_width = ''; |
| 144 |
|
| 145 |
if ( ! empty( $user_calendar_options['calendar_cell_height'] ) ) { |
| 146 |
$unit_value = ( esc_attr( $user_calendar_options['calendar_cell_heightunits'] ) == 'percent' ) ? '%' : esc_attr( $user_calendar_options['calendar_cell_heightunits'] ); |
| 147 |
$option_cell_height = ' cell_height=' . intval( $user_calendar_options['calendar_cell_height'] ) . $unit_value; |
| 148 |
} else $option_cell_height = ''; |
| 149 |
|
| 150 |
|
| 151 |
return array( 'months_number'=> $selected_calendar_months_count, 'options_param' => $option_months_num_in_row . $option_width . $option_cell_height ); |
| 152 |
} |
| 153 |
|
| 154 |
} |
| 155 |
add_action('wpbc_menu_created', array( new WPBC_Page_AddNewBooking() , '__construct') ); // Executed after creation of Menu |
| 156 |
|