PluginProbe
Booking Calendar / 10.1.3
Booking Calendar v10.1.3
11.8.3 11.8.2 11.8.1 11.8 11.7 11.6.1 11.6 11.5 11.4.3 11.4.2 11.4.1 11.4 11.3 11.2.1 11.2 11.1 11.0 10.15.7 10.15.6 10.1.3 10.10 10.10.1 10.10.2 10.11 10.11.2 All 203 releases
booking / includes / page-availability / availability__page.php

availability__page.php in Booking Calendar 10.1.3, at includes/page-availability/availability__page.php

436 lines 20.6 KB
No matching file
Up and down to move Enter to open Esc to close
Raw Download Zip
1 <?php
2 /*
3 * @package: AJX_Bookings Page
4 * @category: o Email Reminders
5 * @description: Define AJX_Bookings in admin settings page. - Sending friendly email reminders based on custom ajx_booking.
6 * Plugin URI: https://oplugins.com/plugins/email-reminders/#premium
7 * Author URI: https://oplugins.com
8 * Author: wpdevelop, oplugins
9 * Version: 0.0.1
10 * @modified 2020-05-11
11 */
12 //FixIn: 9.2.1
13 if ( ! defined( 'ABSPATH' ) ) exit; // Exit if accessed directly
14
15
16 /** Show Content
17 * Update Content
18 * Define Slug
19 * Define where to show
20 */
21 class WPBC_Page_AJX_Availability extends WPBC_Page_Structure {
22
23
24 public function __construct() {
25
26 parent::__construct();
27
28 add_action( 'wpbc_toolbar_top_tabs_after', array( $this, 'wpbc_toolbar_toolbar_tabs' ) );
29 add_action( 'wpbc_toolbar_top_tabs_insert', array( $this, 'wpbc_toolbar_toolbar_tabs' ) );
30 }
31
32
33 public function in_page() {
34 return 'wpbc-availability';
35 }
36
37
38 public function tabs() {
39
40 $tabs = array();
41 $tabs[ 'availability' ] = array(
42 'title' => __( 'Days Availability', 'booking' ) // Title of TAB //FixIn: 9.8.15.2.2
43 , 'hint' => __( 'Define available and unavailable days for calendar(s)', 'booking' ) // Hint
44 , 'page_title' => __( 'Calendar Availability', 'booking' ) // Title of Page
45 , 'link' => '' // Can be skiped, then generated link based on Page and Tab tags. Or can be extenral link
46 , 'position' => '' // 'left' || 'right' || ''
47 , 'css_classes' => '' // CSS class(es)
48 , 'icon' => '' // Icon - link to the real PNG img
49 , 'font_icon' => 'wpbc-bi-calendar2-check'//'wpbc_icn_free_cancellation' // CSS definition of forn Icon
50 , 'default' => true // Is this tab activated by default or not: true || false.
51 , 'disabled' => false // Is this tab disbaled: true || false.
52 , 'hided' => false // Is this tab hided: true || false.
53 , 'subtabs' => array()
54 );
55 // $subtabs = array();
56 // $tabs[ 'items' ][ 'subtabs' ] = $subtabs;
57 return $tabs;
58 }
59
60
61 /**
62 * Show custom tabs for Toolbar at . - . R i g h t . s i d e.
63 *
64 * @param string $menu_in_page_tag - active page
65 */
66 public function wpbc_toolbar_toolbar_tabs( $menu_in_page_tag ) {
67
68 if (
69 ( $this->in_page() == $menu_in_page_tag )
70 && ( ( empty( $_GET['tab'] ) ) || ( 'availability' == $_GET['tab'] ) ) //FixIn: 9.8.15.2.2
71 ) {
72
73 wpbc_bs_toolbar_tabs_html_container_start();
74
75 $escaped_search_request_params = $this->get_cleaned_params__saved_requestvalue_default();
76
77 // Check if by some reason, user was saved request without this parameter, then get default value
78 if ( ! empty( $escaped_search_request_params['ui_usr__availability_selected_toolbar'] ) ) {
79 $selected_tab = $escaped_search_request_params['ui_usr__availability_selected_toolbar'];
80 } else {
81 $default_search_request_params = WPBC_AJX__Availability::request_rules_structure();
82 $selected_tab = $default_search_request_params ['ui_usr__availability_selected_toolbar']['default'];
83 }
84
85 wpbc_bs_display_tab( array(
86 'title' => __( 'Set Availability', 'booking' )
87 , 'hint' => array( 'title' => __('Availability' ,'booking') , 'position' => 'top' )
88 , 'onclick' => "jQuery('.ui_container_toolbar').hide();"
89 . "jQuery('.ui_container_info').show();"
90 . "jQuery('.wpbc_availability_support_tabs').removeClass('nav-tab-active');"
91 . "jQuery(this).addClass('nav-tab-active');"
92 . "jQuery('.nav-tab i.icon-white').removeClass('icon-white');"
93 . "jQuery('.nav-tab-active i').addClass('icon-white');"
94 /**
95 * It will save such changes, and if we have selected bookings, then deselect them
96 */
97 // . "wpbc_ajx_booking_send_search_request_with_params( { 'ui_usr__availability_selected_toolbar': 'filters' });"
98 /**
99 * It will save changes with NEXT search request, but not immediately
100 * it is handy, in case if we have selected bookings,
101 * we will not lose selection.
102 */
103 . "wpbc_ajx_availability.search_set_param( 'ui_usr__availability_selected_toolbar', 'info' );"
104 , 'font_icon' => 'wpbc-bi-calendar2-check' //'wpbc_icn_info_outline'
105 , 'default' => ( 'info' == $selected_tab ) ? true : false
106 //, 'position' => 'right'
107 , 'css_classes' => 'wpbc_availability_support_tabs'
108 ) );
109
110 wpbc_bs_display_tab( array(
111 'title' => __('Options', 'booking')
112 , 'hint' => array( 'title' => __('User Options' ,'booking') , 'position' => 'top' )
113 , 'onclick' => "jQuery('.ui_container_toolbar').hide();"
114 . "jQuery('.ui_container_options').show();"
115 . "jQuery('.wpbc_availability_support_tabs').removeClass('nav-tab-active');"
116 . "jQuery(this).addClass('nav-tab-active');"
117 . "jQuery('.nav-tab i.icon-white').removeClass('icon-white');"
118 . "jQuery('.nav-tab-active i').addClass('icon-white');"
119 /**
120 * It will save such changes, and if we have selected bookings, then deselect them
121 */
122 // . "wpbc_ajx_booking_send_search_request_with_params( { 'ui_usr__availability_selected_toolbar': 'options' });"
123 /**
124 * It will save changes with NEXT search request, but not immediately
125 * it is handy, in case if we have selected bookings,
126 * we will not lose selection.
127 */
128 . "wpbc_ajx_availability.search_set_param( 'ui_usr__availability_selected_toolbar', 'calendar_settings' );"
129 , 'font_icon' => 'wpbc_icn_tune'
130 , 'default' => ( 'calendar_settings' == $selected_tab ) ? true : false
131 //, 'position' => 'right'
132 , 'css_classes' => 'wpbc_availability_support_tabs'
133
134 ) );
135
136 wpbc_bs_toolbar_tabs_html_container_end();
137
138 }
139 }
140
141
142 /**
143 * Get sanitised request parameters. :: Firstly check if user saved it. :: Otherwise, check $_REQUEST. :: Otherwise get default.
144 *
145 * @return array|false
146 */
147 public function get_cleaned_params__saved_requestvalue_default(){
148
149 $user_request = new WPBC_AJX__REQUEST( array(
150 'db_option_name' => 'booking_availability_request_params',
151 'user_id' => wpbc_get_current_user_id(),
152 'request_rules_structure' => WPBC_AJX__Availability::request_rules_structure()
153 )
154 );
155 $escaped_request_params_arr = $user_request->get_sanitized__saved__user_request_params(); // Get Saved
156
157 //Fix Calendar cell heights in versions older than //FixIn: 9.7.3.2
158 if ( ( false !== $escaped_request_params_arr )
159 && ( '' === $escaped_request_params_arr['calendar__view__cell_height'] )
160 ) {
161 $user_request->user_request_params__db_delete(); // Delete from DB
162 }
163
164 if ( false === $escaped_request_params_arr ) { // This request was not saved before, then get sanitized direct parameters, like: $_REQUEST['resource_id']
165
166 $request_prefix = false;
167 $escaped_request_params_arr = $user_request->get_sanitized__in_request__value_or_default( $request_prefix ); // Direct: $_REQUEST['resource_id']
168 }
169
170
171 //MU
172 if ( class_exists( 'wpdev_bk_multiuser' ) ) {
173
174 // Check if this MU user activated or superadmin, otherwise show warning
175 if ( ! wpbc_is_mu_user_can_be_here('activated_user') )
176 return false;
177
178 // Check if this MU user owner of this resource or superadmin, otherwise show warning
179 if ( ! wpbc_is_mu_user_can_be_here( 'resource_owner', $escaped_request_params_arr['resource_id'] ) ) {
180 $default_values = $user_request->get_request_rules__default();
181 $escaped_request_params_arr['resource_id'] = $default_values['resource_id'];
182 }
183
184 }
185
186
187
188 return $escaped_request_params_arr;
189 }
190
191
192 public function content() {
193
194 $this->css_fix();
195
196 do_action( 'wpbc_hook_settings_page_header', 'page_booking_availability'); // Define Notices Section and show some static messages, if needed.
197
198 if ( ! wpbc_is_mu_user_can_be_here( 'activated_user' ) ) { return false; } // Check if MU user activated, otherwise show Warning message.
199
200 // if ( ! wpbc_set_default_resource_to__get() ) return false; // Define default booking resources for $_GET and check if booking resource belong to user.
201
202
203 // Get and escape request parameters ////////////////////////////////////////////////////////////////////////
204 $escaped_request_params_arr = $this->get_cleaned_params__saved_requestvalue_default();
205
206 // During initial load of the page, we need to reset 'dates_selection' value in our saved parameter
207 $escaped_request_params_arr['dates_selection'] = '';
208 $escaped_request_params_arr['calendar__start_week_day'] = get_bk_option( 'booking_start_day_weeek' );
209
210
211 // Submit /////////////////////////////////////////////////////////////
212 $submit_form_name = 'wpbc_ajx_availability_form'; // Define form name
213
214 ?><span class="wpdevelop"><?php // BS UI CSS Class
215
216 wpbc_js_for_bookings_page(); // JavaScript functions
217
218 wpbc_ajx_availability__toolbar( $escaped_request_params_arr );
219
220 ?></span><?php
221
222 ?><div id="wpbc_log_screen" class="wpbc_log_screen"></div><?php
223
224 // Content ////////////////////////////////////////////////////////////
225 ?>
226 <div class="clear" style="margin-bottom:10px;"></div>
227 <span class="metabox-holder">
228 <form name="<?php echo $submit_form_name; ?>" id="<?php echo $submit_form_name; ?>" action="" method="post" >
229 <?php
230 // N o n c e field, and key for checking S u b m i t
231 wp_nonce_field( 'wpbc_settings_page_' . $submit_form_name );
232 ?><input type="hidden" name="is_form_sbmitted_<?php echo $submit_form_name; ?>" id="is_form_sbmitted_<?php echo $submit_form_name; ?>" value="1" /><?php
233
234 //wpbc_ajx_booking_modify_container_show(); // Container for showing Edit ajx_booking and define Edit and Delete ajx_booking JavaScript vars.
235
236 wpbc_clear_div();
237
238 $this->ajx_availability_container__show( $escaped_request_params_arr );
239
240 wpbc_clear_div();
241
242 ?></form>
243 </span>
244 <?php
245
246 //wpbc_show_wpbc_footer(); // Rating
247
248 do_action( 'wpbc_hook_settings_page_footer', 'wpbc-ajx_booking_availability' );
249 }
250
251 private function ajx_availability_container__show( $escaped_request_params_arr ) {
252
253 ?>
254 <div id="ajx_nonce_calendar_section"></div>
255 <div class="wpbc_listing_container wpbc_selectable_table wpbc_ajx_availability_container wpdevelop" wpbc_loaded="first_time">
256 <style type="text/css">
257 .wpbc_calendar_loading .wpbc_icn_autorenew::before{
258 font-size: 1.2em;
259 }
260 .wpbc_calendar_loading {
261 width:95%;
262 text-align: center;
263 margin:2em 0;
264 font-size: 1.2em;
265 font-weight: 600;
266 }
267 </style>
268 <div class="wpbc_calendar_loading"><span class="wpbc_icn_autorenew wpbc_spin"></span>&nbsp;&nbsp;<span><?php _e( 'Loading', 'booking' ); ?>...</span>
269 </div>
270 </div>
271 <script type="text/javascript">
272 jQuery( document ).ready( function (){
273
274 // Set Security - Nonce for Ajax - Listing
275 wpbc_ajx_availability.set_secure_param( 'nonce', '<?php echo wp_create_nonce( 'wpbc_ajx_availability_ajx' . '_wpbcnonce' ) ?>' );
276 wpbc_ajx_availability.set_secure_param( 'user_id', '<?php echo wpbc_get_current_user_id(); ?>' );
277 wpbc_ajx_availability.set_secure_param( 'locale', '<?php echo get_user_locale(); ?>' );
278
279 // Set other parameters
280 wpbc_ajx_availability.set_other_param( 'listing_container', '.wpbc_ajx_availability_container' );
281
282 // Send Ajax request and show listing after this.
283 wpbc_ajx_availability__send_request_with_params( <?php echo wp_json_encode( $escaped_request_params_arr ); ?> );
284 } );
285 </script>
286 <?php
287 //FixIn: 10.0.0.5
288 if ( 0 ) {
289 $resource_id = 220;
290 // $bk_cal = apply_bk_filter( 'pre_get_calendar_html', $resource_id, $my_boook_count, $bk_otions );
291 ?>
292 <style type="text/css" rel="stylesheet"> .hasDatepick .datepick-inline .datepick-title-row th, .hasDatepick .datepick-inline .datepick-days-cell { height: 50px; } </style>
293 <div class="wpbc_calendar_wraper wpbc_change_over_triangle">
294 <div class="bk_calendar_frame months_num_in_row_4 cal_month_num_4" style="width:100%;max-width:100%;">
295 <div id="calendar_booking<?php echo $resource_id ?>"><?php _e('Calendar is loading...', 'booking'); ?></div>
296 </div>
297 </div><?php
298
299 $selected_dates_if_no_calendar = '';
300 echo '<textarea rows="3" cols="50" id="date_booking' . $resource_id . '" name="date_booking' . $resource_id . '" autocomplete="off" style="display:none;">'
301 . $selected_dates_if_no_calendar . '</textarea>';
302 if(1){
303 $start_script_code = wpbc__calendar__load( array(
304
305 'resource_id' => $resource_id,
306 'aggregate_resource_id_arr' => array(), // It is array of booking resources from aggregate parameter()
307 'selected_dates_without_calendar' => $selected_dates_if_no_calendar, // $selected_dates_if_no_calendar
308 'calendar_number_of_months' => 12, // $my_boook_count
309 'start_month_calendar' => false, // $start_month_calendar
310 'shortcode_options' => '', // options from the Booking Calendar shortcode. Usually it's conditional dates selection parameters
311 'custom_form' => 'standard'
312
313 ));
314
315 echo $start_script_code;
316 } else {
317 ?>
318 <script type='text/javascript'> jQuery( document ).ready( function (){
319 _wpbc.balancer__set_max_threads( 1 );
320 _wpbc.calendar__set_param_value( 220, 'calendar_scroll_to', false );
321 _wpbc.calendar__set_param_value( 220, 'booking_max_monthes_in_calendar', '2y' );
322 _wpbc.calendar__set_param_value( 220, 'booking_start_day_weeek', '1' );
323 _wpbc.calendar__set_param_value( 220, 'calendar_number_of_months', '12' );
324 _wpbc.calendar__set_param_value( 220, 'days_select_mode', 'dynamic' );
325 _wpbc.calendar__set_param_value( 220, 'fixed__days_num', 7 );
326 _wpbc.calendar__set_param_value( 220, 'fixed__week_days__start', [-1] );
327 _wpbc.calendar__set_param_value( 220, 'dynamic__days_min', 1 );
328 _wpbc.calendar__set_param_value( 220, 'dynamic__days_max', 30 );
329 _wpbc.calendar__set_param_value( 220, 'dynamic__days_specific', [] );
330 _wpbc.calendar__set_param_value( 220, 'dynamic__week_days__start', [-1] );
331 _wpbc.calendar__set_param_value( 220, 'booking_date_format', 'j M Y' );
332 _wpbc.calendar__set_param_value( 220, 'booking_time_format', 'g:i A' );
333 _wpbc.set_message( 'message_dates_times_unavailable', 'These dates and times in this calendar are already booked or unavailable.' );
334 _wpbc.set_message( 'message_choose_alternative_dates', 'Please choose alternative date(s), times, or adjust the number of slots booked.' );
335 _wpbc.set_message( 'message_cannot_save_in_one_resource', 'It is not possible to store this sequence of the dates into the one same resource.' );
336 _wpbc.calendar__set_param_value( 220, 'is_parent_resource', 0 );
337 _wpbc.calendar__set_param_value( 220, 'booking_capacity_field', 'visitors' );
338 _wpbc.calendar__set_param_value( 220, 'booking_is_dissbale_booking_for_different_sub_resources', 'Off' );
339 _wpbc.calendar__set_param_value( 220, 'booking_recurrent_time', 'Off' );
340 if ( 'function' === typeof (wpbc__conditions__SAVE_INITIAL__days_selection_params__bm) ){ wpbc__conditions__SAVE_INITIAL__days_selection_params__bm( 220 ); }
341 _wpbc.calendar__set_param_value( 220, 'conditions', {
342 "select-day": {
343 "weekday": [{
344 "for" : "0",
345 "value": "7,14"
346 }]
347 }
348 } );
349 _wpbc.seasons__set( 220, [] );
350 wpbc_calendar_show( '220' );
351 _wpbc.set_secure_param( 'nonce', '<?php echo wp_create_nonce( 'wpbc_calendar_load_ajx' . '_wpbcnonce' ); ?>' );
352 _wpbc.set_secure_param( 'user_id','<?php echo wpbc_get_current_user_id(); ?>' );
353 _wpbc.set_secure_param( 'locale', '<?php echo get_user_locale(); ?>' );
354 wpbc_calendar__load_data__ajx( {
355 "resource_id" : 220,
356 "booking_hash" : "",
357 "request_uri" : "\/2024-03-221132\/",
358 "custom_form" : "standard",
359 "aggregate_resource_id_str": "",
360 "aggregate_type" : "all"
361 } );
362 } );
363 </script>
364 <?php
365 }
366 }
367
368
369 }
370
371 /**
372 * Hide first "Availability tab", because we have only one tab hhere, and need to show only tabs for toolbar
373 * @return void
374 */
375 private function css_fix(){
376 //FixIn: 9.8.15.2
377 /*
378
379 ?><style type="text/css">
380 .nav-tabs .nav-tab:first-child{
381 display:none;
382 }
383 </style><?php
384 */
385 }
386
387 }
388 add_action('wpbc_menu_created', array( new WPBC_Page_AJX_Availability() , '__construct') ); // Executed after creation of Menu
389
390
391 /**
392 * Duplicated Genal Availability Tab - Redirect to Booking > Settings General page in "Availability" section
393 *
394 */
395 class WPBC_Page_Availability_General extends WPBC_Page_Structure {
396
397
398 public function in_page() {
399
400 if ( ! wpbc_is_mu_user_can_be_here( 'only_super_admin' ) ) { // If this User not "super admin", then do not load this page at all
401 return (string) rand( 100000, 1000000 ); // If this User not "super admin", then do not load this page at all
402 }
403
404 return 'wpbc-availability';
405 }
406
407
408
409 public function tabs() {
410
411 $tabs = array();
412 $tabs[ 'general_availability' ] = array(
413 'title' => __( 'General Availability', 'booking' ) // Title of TAB //FixIn: 9.8.15.2.2
414 , 'hint' => __( 'Define unavailable weekdays for all calendar(s) and unavailable dates depend from today date', 'booking' ) // Hint
415 , 'page_title' => __( 'General Availability', 'booking' ) // Title of Page
416 , 'link' => wpbc_get_settings_url( true, false ) . '&scroll_to_section=wpbc_general_settings_availability_tab' // Can be skiped, then generated link based on Page and Tab tags. Or can be extenral link
417 , 'position' => '' // 'left' || 'right' || ''
418 , 'css_classes' => 'wpbc_top_tab__general_availability' // CSS class(es)
419 , 'icon' => '' // Icon - link to the real PNG img
420 , 'font_icon' => 'wpbc-bi-calendar2-day 0wpbc-bi-calendar2-check'//'wpbc_icn_free_cancellation' // CSS definition of forn Icon
421 , 'default' => false // Is this tab activated by default or not: true || false.
422 , 'disabled' => false // Is this tab disbaled: true || false.
423 , 'hided' => false // Is this tab hided: true || false.
424 , 'subtabs' => array()
425 );
426 // $subtabs = array();
427 // $tabs[ 'items' ][ 'subtabs' ] = $subtabs;
428 return $tabs;
429 }
430
431 public function content() {
432
433 }
434 }
435 add_action('wpbc_menu_created', array( new WPBC_Page_Availability_General() , '__construct') ); // Executed after creation of Menu
436