PluginProbe
Booking Calendar / 10.11.2
Booking Calendar v10.11.2
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 10.11.3 All 202 releases
booking / core / admin / wpbc-toolbars.php

wpbc-toolbars.php in Booking Calendar 10.11.2, at core/admin/wpbc-toolbars.php

1,601 lines 91.5 KB
No matching file
Up and down to move Enter to open Esc to close
Raw Download Zip
1 <?php /**
2 * @version 1.0
3 * @package Booking Calendar
4 * @category Toolbar. Data for UI Elements at Booking Calendar admin pages
5 * @author wpdevelop
6 *
7 * @web-site https://wpbookingcalendar.com/
8 * @email info@wpbookingcalendar.com
9 *
10 * @modified 2015-11-16
11 */
12
13 if ( ! defined( 'ABSPATH' ) ) exit; // Exit, if accessed directly
14
15
16 // ---------------------------------------------------------------------------------------------------------------------
17 // T o o l b a r s
18 // ---------------------------------------------------------------------------------------------------------------------
19
20 // FixIn: 9.6.3.5.
21
22 /** T o o l b a r C o n t a i n e r f o r Timeline */
23 function wpbc_timeline_toolbar() {
24
25 wpbc_clear_div();
26
27 // Toolbar ////////////////////////////////////////////////////////////////
28
29 ?><div id="toolbar_booking_listing" class="wpbc_timeline_toolbar_container"><?php
30 /*
31 wpbc_bs_toolbar_tabs_html_container_start();
32
33 // <editor-fold defaultstate="collapsed" desc=" T O P T A B s " >
34
35 // phpcs:ignore WordPress.Security.NonceVerification.Recommended, WordPress.Security.NonceVerification.Missing
36 if ( ! isset( $_REQUEST['tab_cvm'] ) ) $_REQUEST['tab_cvm'] = 'actions_cvm';
37 $selected_tab = sanitize_text_field( wp_unslash( $_REQUEST['tab_cvm'] ) );
38
39 wpbc_bs_display_tab( array(
40 'title' => __('View', 'booking')
41 // , 'hint' => array( 'title' => __('Manage bookings' ,'booking') , 'position' => 'top' )
42 , 'onclick' => "jQuery('.visibility_container').hide();"
43 . "jQuery('#actions_toolbar_container').show();"
44 . "jQuery('#toolbar_booking_listing .nav-tab').removeClass('nav-tab-active');" // FixIn: 9.8.15.2.
45 . "jQuery(this).addClass('nav-tab-active');"
46 . "jQuery('.nav-tab i.icon-white').removeClass('icon-white');"
47 . "jQuery('.nav-tab-active i').addClass('icon-white');"
48 , 'font_icon' => 'wpbc-bi-calendar2-range-fill'
49 , 'default' => ( $selected_tab == 'actions_cvm' ) ? true : false
50
51 ) );
52
53
54 wpbc_bs_dropdown_menu_help();
55
56 // </editor-fold>
57
58 wpbc_bs_toolbar_tabs_html_container_end();
59 */
60 ////////////////////////////////////////////////////////////////////////
61
62 wpbc_bs_toolbar_sub_html_container_start();
63
64 // A c t i o n s T o o l b a r f o r T i m e l i n e
65
66
67 ?><div class="wpbc_timeline_toolbar_structure"><?php
68
69 make_bk_action( 'wpbc_br_selection_for_timeline' );
70
71 wpbc_toolbar_is_send_emails_btn( '');
72
73 ?></div><?php
74
75 wpbc_bs_toolbar_sub_html_container_end();
76
77 ?></div><?php
78
79 wpbc_clear_div();
80
81 }
82
83
84
85 /** T o o l b a r C o n t a i n e r f o r Add New Booking */
86 function wpbc_add_new_booking_toolbar() {
87
88 wpbc_clear_div();
89
90 // Toolbar ////////////////////////////////////////////////////////////////
91
92 ?><div id="toolbar_booking_listing" style="position:relative;"><?php
93
94 wpbc_bs_toolbar_tabs_html_container_start();
95
96 // <editor-fold defaultstate="collapsed" desc=" T O P T A B s " >
97
98 // phpcs:ignore WordPress.Security.NonceVerification.Recommended, WordPress.Security.NonceVerification.Missing
99 if ( ! isset( $_REQUEST['toolbar'] ) ) $_REQUEST['toolbar'] = 'filter';
100 $selected_tab = sanitize_text_field( wp_unslash( $_REQUEST['toolbar'] ) ); /* phpcs:ignore WordPress.Security.NonceVerification.Recommended, WordPress.Security.NonceVerification.Missing */ /* FixIn: sanitize_unslash */
101
102 wpbc_bs_display_tab( array(
103 'title' => __('Options', 'booking')
104 // , 'hint' => array( 'title' => __('Manage bookings' ,'booking') , 'position' => 'top' )
105 , 'onclick' => "jQuery('.visibility_container').hide();"
106 . "jQuery('#filter_toolbar_container').show();"
107 . "jQuery('#toolbar_booking_listing .nav-tab').removeClass('nav-tab-active');" // FixIn: 9.8.15.2.
108 . "jQuery(this).addClass('nav-tab-active');"
109 . "jQuery('.nav-tab i.icon-white').removeClass('icon-white');"
110 . "jQuery('.nav-tab-active i').addClass('icon-white');"
111 , 'font_icon' => 'wpbc_icn_adjust'
112 , 'default' => ( $selected_tab == 'filter' ) ? true : false
113
114 ) );
115
116 wpbc_bs_display_tab( array(
117 'title' => __('Calendar View', 'booking')
118 // , 'hint' => array( 'title' => __('Manage bookings' ,'booking') , 'position' => 'top' )
119 , 'onclick' => "jQuery('.visibility_container').hide();"
120 . "jQuery('#calendar_size_toolbar_container').show();"
121 . "jQuery('#toolbar_booking_listing .nav-tab').removeClass('nav-tab-active');" // FixIn: 9.8.15.2.
122 . "jQuery(this).addClass('nav-tab-active');"
123 . "jQuery('.nav-tab i.icon-white').removeClass('icon-white');"
124 . "jQuery('.nav-tab-active i').addClass('icon-white');"
125 , 'font_icon' => 'wpbc-bi-calendar2'
126 , 'default' => ( $selected_tab == 'calendar' ) ? true : false
127
128 ) );
129
130
131 wpbc_bs_dropdown_menu_help();
132
133 // </editor-fold>
134
135 wpbc_bs_toolbar_tabs_html_container_end();
136
137 ////////////////////////////////////////////////////////////////////////
138
139 wpbc_bs_toolbar_sub_html_container_start();
140
141 // T o o l b a r
142 ?><div id="filter_toolbar_container" class="visibility_container clearfix-height" style="display:<?php echo ( $selected_tab == 'filter' ) ? 'block' : 'none' ?>;margin-top:-5px;"><?php
143
144 // phpcs:ignore WordPress.Security.NonceVerification.Recommended
145 if ( ( function_exists( 'wpbc_toolbar_btn__resource_selection' ) ) && ( empty( $_GET['booking_hash'] ) ) ) {
146 // Do not show resource seleciton if editing booking. // FixIn: 7.1.2.10.
147
148 wpbc_toolbar_btn__resource_selection();
149 }
150
151 if ( function_exists( 'wpbc_toolbar_btn__form_selection' ) )
152 wpbc_toolbar_btn__form_selection();
153
154 ////////////////////////////////////////////////////////////////////
155 ?><div class="clear-for-mobile"></div><?php
156
157 ?><div class="control-group wpbc-no-padding" style="float:right;margin-right: 0;margin-left: 15px;"><?php
158
159 if ( function_exists( 'wpbc_toolbar_btn__auto_fill' ) )
160 wpbc_toolbar_btn__auto_fill();
161
162 wpbc_toolbar_btn__add_new_booking();
163
164 ?></div><?php
165 ////////////////////////////////////////////////////////////////////
166
167 ?></div><?php
168 ?><div id="calendar_size_toolbar_container" class="visibility_container clearfix-height" style="display:<?php echo ( $selected_tab == 'calendar_size' ) ? 'block' : 'none' ?>;margin-top:-5px;"><?php
169 /*
170 ?><span class="advanced_booking_filter" style="display:none;"><div class="clear" style="width:100%;border-bottom:1px solid #ccc;height:10px;"></div><?php
171 */
172 // Get possible saved previous "Custom User Calendar data"
173 $user_calendar_options = get_user_option( 'booking_custom_' . 'add_booking_calendar_options', wpbc_get_current_user_id() );
174
175 if ( $user_calendar_options === false ) { // Default, if no saved previously.
176 $user_calendar_options = array();
177 $user_calendar_options['calendar_months_count'] = 1;
178 $user_calendar_options['calendar_months_num_in_1_row'] = 0 ;
179 $user_calendar_options['calendar_width'] = '';
180 $user_calendar_options['calendar_widthunits'] = 'px';
181 $user_calendar_options['calendar_cell_height'] = '';
182 $user_calendar_options['calendar_cell_heightunits'] = 'px';
183 } else {
184 $user_calendar_options = maybe_unserialize( $user_calendar_options );
185 }
186
187 wpbc_toolbar_btn__calendar_months_number_selection( $user_calendar_options );
188
189 wpbc_toolbar_btn__calendar_months_num_in_1_row_selection( $user_calendar_options );
190
191 wpbc_toolbar_btn__calendar_width( $user_calendar_options );
192
193 wpbc_toolbar_btn__calendar_cell_height( $user_calendar_options );
194
195 wpbc_toolbar_btn__calendar_options_save();
196
197 wpbc_toolbar_btn__calendar_options_reset();
198 /*
199 ?><div class="clear"></div></span><?php
200
201
202 wpbc_clear_div();
203
204 wpbc_toolbar_expand_collapse_btn( 'advanced_booking_filter' );
205 */
206 ?></div><?php
207
208
209 wpbc_bs_toolbar_sub_html_container_end();
210
211 wpbc_toolbar_is_send_emails_btn();
212
213 ?></div><?php
214
215 wpbc_clear_div();
216
217 }
218
219
220 // ---------------------------------------------------------------------------------------------------------------------
221 // HTML elements for Toolbar
222 // ---------------------------------------------------------------------------------------------------------------------
223
224 /**
225 * Expand or Collapse Advanced Filter set
226 *
227 * @param string $css_class_of_expand_element - CSS Class of element section to show or hide
228 */
229 function wpbc_toolbar_expand_collapse_btn( $css_class_of_expand_element ) {
230
231 ?><span id="show_link_advanced_booking_filter" class="tab-bottom tooltip_right advanced_booking_filter"
232 title="<?php esc_attr_e('Expand Advanced Toolbar' ,'booking'); ?>"
233 ><a href="javascript:void(0)"
234 onclick="javascript:jQuery('.<?php echo esc_js( $css_class_of_expand_element ); ?>').show();
235 jQuery('#show_link_advanced_booking_filter').hide();
236 jQuery('#hide_link_advanced_booking_filter').show();"><i
237 class="wpbc_icn_expand_more"></i></a></span>
238 <span id="hide_link_advanced_booking_filter" class="tab-bottom tooltip_right advanced_booking_filter" style="display:none;"
239 title="<?php esc_attr_e('Collapse Advanced Toolbar' ,'booking'); ?>"
240 ><a href="javascript:void(0)"
241 onclick="javascript:jQuery('.<?php echo esc_js( $css_class_of_expand_element ); ?>').hide();
242 jQuery('#hide_link_advanced_booking_filter').hide();
243 jQuery('#show_link_advanced_booking_filter').show();"><i
244 class="wpbc_icn_expand_less"></i></a></span><?php
245
246 }
247
248
249 /**
250 * Checkbox - sending emails or not
251 *
252 * @param $style Styles of this element group
253 *
254 * @return void
255 */
256 function wpbc_toolbar_is_send_emails_btn( $style = 'position:absolute;right:0px;margin-top:10px;' ) {
257
258 ?><div class="btn-group" style="<?php echo esc_attr( $style ); ?>"><?php
259
260 $el_id = 'is_send_email_for_pending';
261
262 $el_value = ( get_bk_option( 'booking_send_emails_off_addbooking' ) !== 'On' ) ? 'On' : 'Off';
263
264 $params_checkbox = array(
265 'id' => $el_id // HTML ID of element
266 , 'name' => $el_id
267 , 'label' => array( 'title' => __( 'Emails sending', 'booking' ) , 'position' => 'right' ) // FixIn: 9.6.1.5.
268 , 'style' => '' // CSS of select element
269 , 'class' => '' // CSS Class of select element
270 , 'disabled' => false
271 , 'attr' => array() // Any additional attributes, if this radio | checkbox element
272 , 'legend' => '' // aria-label parameter
273 , 'value' => $el_value // Some Value from optins array that selected by default
274 , 'selected' => ( ( 'On' == $el_value ) ? true : false ) // Selected or not
275 //, 'onfocus' => "console.log( 'ON FOCUS:', jQuery( this ).is(':checked') , 'in element:' , jQuery( this ) );" // JavaScript code
276 //, 'onchange' => "wpbc_ajx_booking_send_search_request_with_params( {'ui_usr__send_emails': (jQuery( this ).is(':checked') ? 'send' : 'not_send') } );" // JavaScript code
277 , 'hint' => array( 'title' => __('Send email notification to customer about this operation' ,'booking') , 'position' => 'top' )
278 );
279
280 wpbc_flex_toggle( $params_checkbox );
281
282 ?></div><?php
283 }
284
285
286
287 // ---------------------------------------------------------------------------------------------------------------------
288 // U I E l e m e n t s
289 // ---------------------------------------------------------------------------------------------------------------------
290
291 /** Help - Drop Down Menu - T a b */
292 function wpbc_bs_dropdown_menu_help() {
293
294 wpbc_bs_dropdown_menu( array(
295 'title' => __( 'Help', 'booking' )
296 , 'font_icon' => 'wpbc_icn_support' //FixIn: 9.0.1.4 'glyphicon glyphicon-question-sign'
297 , 'position' => 'right'
298 , 'items' => array(
299 array( 'type' => 'link', 'title' => __('FAQ', 'booking'), 'url' => 'https://wpbookingcalendar.com/faq/' )
300 , array( 'type' => 'link', 'title' => __('Support Forum', 'booking'), 'url' => 'https://wpbookingcalendar.com/support/' )
301 , array( 'type' => 'divider' )
302 , array( 'type' => 'link', 'title' => __('Contact Support', 'booking'), 'url' => 'mailto:support@wpbookingcalendar.com'
303 , 'attr' => array( 'style' => 'font-weight: 600;' ) )
304 , array( 'type' => 'divider' )
305 , array( 'type' => 'link', 'title' => "What's New"/*__('Get Started')*/, 'url' => esc_url( admin_url( add_query_arg( array( 'page' => 'wpbc-about' ), 'index.php' ) ) ) )
306 , array( 'type' => 'link', 'title' => __('About', 'booking')
307 // , 'url' => wpbc_up_link()
308 , 'url' => 'https://wpbookingcalendar.com/' //esc_url( admin_url( add_query_arg( array( 'page' => 'wpbc-about-premium' ), 'index.php' ) ) )
309 , 'attr' => array(
310 // 'target' => '_blank'
311 // 'style' => 'font-weight: 600;'
312 )
313 )
314 )
315 ) );
316 }
317
318
319 // ---------------------------------------------------------------------------------------------------------------------
320 // Toolbar Actions B u t t o n s - T i m e l i n e //////////////////
321 // ---------------------------------------------------------------------------------------------------------------------
322
323
324
325
326 /** Navigation Timeline - B u t t o n s */
327 function wpbc_toolbar_btn__timeline_navigation() {
328
329 // phpcs:ignore WordPress.Security.NonceVerification.Recommended, WordPress.Security.NonceVerification.Missing, WordPress.Security.ValidatedSanitizedInput.MissingUnslash, WordPress.Security.ValidatedSanitizedInput.InputNotSanitized
330 if ((isset($_REQUEST['wh_booking_type'])) && ( strpos($_REQUEST['wh_booking_type'], ',') !== false ) )
331 $is_show_resources_matrix = true;
332 else $is_show_resources_matrix = false;
333
334
335 // phpcs:ignore WordPress.Security.NonceVerification.Recommended, WordPress.Security.NonceVerification.Missing
336 if ( isset( $_REQUEST['view_days_num'] ) )
337 $view_days_num = intval( $_REQUEST['view_days_num'] ); // phpcs:ignore WordPress.Security.NonceVerification.Recommended, WordPress.Security.NonceVerification.Missing
338 else $view_days_num = get_bk_option( 'booking_view_days_num');
339
340
341 $bk_admin_url = wpbc_get_params_in_url( wpbc_get_bookings_url( false ), array('scroll_month', 'scroll_day') );
342 //debuge($_REQUEST, $bk_admin_url);
343
344 // Get Data For buttons
345 if (! $is_show_resources_matrix) {
346
347 switch ($view_days_num) {
348 case '90':
349 // phpcs:ignore WordPress.Security.NonceVerification.Recommended, WordPress.Security.NonceVerification.Missing
350 if (isset($_REQUEST['scroll_day'])) $scroll_day = intval( $_REQUEST['scroll_day'] ); // phpcs:ignore WordPress.Security.NonceVerification.Recommended, WordPress.Security.NonceVerification.Missing
351 else $scroll_day = 0;
352 $scroll_params = array( '&scroll_day='.intval($scroll_day-4*7),
353 '&scroll_day='.intval($scroll_day-7),
354 '&scroll_day=0',
355 '&scroll_day='.intval($scroll_day+7 ),
356 '&scroll_day='.intval($scroll_day+4*7) );
357 $scroll_titles = array( __('Previous 4 weeks' ,'booking'),
358 __('Previous week' ,'booking'),
359 __('Current week' ,'booking'),
360 __('Next week' ,'booking'),
361 __('Next 4 weeks' ,'booking') );
362 break;
363 case '30':
364 // phpcs:ignore WordPress.Security.NonceVerification.Recommended, WordPress.Security.NonceVerification.Missing
365 if (isset($_REQUEST['scroll_day'])) $scroll_day = intval( $_REQUEST['scroll_day'] ); // phpcs:ignore WordPress.Security.NonceVerification.Recommended, WordPress.Security.NonceVerification.Missing
366 else $scroll_day = 0;
367
368 // FixIn: 8.9.4.3.
369 // Here we need to define number of days to scroll depends from selected number of days to show.
370 $days_num_to_scroll = intval( get_bk_option( 'booking_calendar_overview__day_mode__days_number_show' ) );;
371 if ( empty( $days_num_to_scroll ) ) {
372 $days_num_to_scroll = 7;
373 }
374
375 $scroll_params = array( '&scroll_day='.intval( $scroll_day - $days_num_to_scroll * 2 ),
376 '&scroll_day='.intval( $scroll_day - $days_num_to_scroll ),
377 '&scroll_day=0',
378 '&scroll_day='.intval( $scroll_day + $days_num_to_scroll ),
379 '&scroll_day='.intval( $scroll_day + $days_num_to_scroll *2 ) );
380 $scroll_titles = array( __( 'Previous', 'booking' ) . ' ' . ( 2 * $days_num_to_scroll ) . ' ' . __( 'days', 'booking' ),
381 __( 'Previous', 'booking' ) . ' ' . $days_num_to_scroll . ' ' . __( 'days', 'booking' ),
382 __('Current week' ,'booking'),
383 __( 'Next', 'booking' ) . ' ' . $days_num_to_scroll . ' ' . __( 'days', 'booking' ),
384 __( 'Next', 'booking' ) . ' ' . ( 2 * $days_num_to_scroll ) . ' ' . __( 'days', 'booking' ) );
385 break;
386 default: // 365
387 // phpcs:ignore WordPress.Security.NonceVerification.Recommended, WordPress.Security.NonceVerification.Missing
388 if (! isset($_REQUEST['scroll_month'])) $_REQUEST['scroll_month'] = 0;
389 $scroll_month = intval( $_REQUEST['scroll_month'] ); // phpcs:ignore WordPress.Security.NonceVerification.Recommended, WordPress.Security.NonceVerification.Missing
390 $scroll_params = array( '&scroll_month='.intval($scroll_month-3),
391 '&scroll_month='.intval($scroll_month-1),
392 '&scroll_month=0',
393 '&scroll_month='.intval($scroll_month+1 ),
394 '&scroll_month='.intval($scroll_month+3) );
395 $scroll_titles = array( __('Previous 3 months' ,'booking'),
396 __('Previous month' ,'booking'),
397 __('Current month' ,'booking'),
398 __('Next month' ,'booking'),
399 __('Next 3 months' ,'booking') );
400 break;
401 }
402 } else { // Matrix
403
404 switch ($view_days_num) {
405 case '1': //Day
406 // phpcs:ignore WordPress.Security.NonceVerification.Recommended, WordPress.Security.NonceVerification.Missing
407 if (isset($_REQUEST['scroll_day'])) $scroll_day = intval( $_REQUEST['scroll_day'] ); // phpcs:ignore WordPress.Security.NonceVerification.Recommended, WordPress.Security.NonceVerification.Missing
408 else $scroll_day = 0;
409 $scroll_params = array( '&scroll_day='.intval($scroll_day-7),
410 '&scroll_day='.intval($scroll_day-1),
411 '&scroll_day=0',
412 '&scroll_day='.intval($scroll_day+1 ),
413 '&scroll_day='.intval($scroll_day+7) );
414 $scroll_titles = array( __('Previous 7 days' ,'booking'),
415 __('Previous day' ,'booking'),
416 __('Current day' ,'booking'),
417 __('Next day' ,'booking'),
418 __('Next 7 days' ,'booking') );
419 break;
420
421 case '7': //Week
422 // phpcs:ignore WordPress.Security.NonceVerification.Recommended, WordPress.Security.NonceVerification.Missing
423 if (isset($_REQUEST['scroll_day'])) $scroll_day = intval( $_REQUEST['scroll_day'] ); // phpcs:ignore WordPress.Security.NonceVerification.Recommended, WordPress.Security.NonceVerification.Missing
424 else $scroll_day = 0;
425 $scroll_params = array( '&scroll_day='.intval($scroll_day-4*7),
426 '&scroll_day='.intval($scroll_day-7),
427 '&scroll_day=0',
428 '&scroll_day='.intval($scroll_day+7 ),
429 '&scroll_day='.intval($scroll_day+4*7) );
430 $scroll_titles = array( __('Previous 4 weeks' ,'booking'),
431 __('Previous week' ,'booking'),
432 __('Current week' ,'booking'),
433 __('Next week' ,'booking'),
434 __('Next 4 weeks' ,'booking') );
435 break;
436
437 case '30':
438 case '60':
439 case '90': //3 months
440 // phpcs:ignore WordPress.Security.NonceVerification.Recommended, WordPress.Security.NonceVerification.Missing
441 if (! isset($_REQUEST['scroll_month'])) $_REQUEST['scroll_month'] = 0;
442 $scroll_month = intval( $_REQUEST['scroll_month'] ); // phpcs:ignore WordPress.Security.NonceVerification.Recommended, WordPress.Security.NonceVerification.Missing
443 $scroll_params = array( '&scroll_month='.intval($scroll_month-3),
444 '&scroll_month='.intval($scroll_month-1),
445 '&scroll_month=0',
446 '&scroll_month='.intval($scroll_month+1 ),
447 '&scroll_month='.intval($scroll_month+3) );
448 $scroll_titles = array( __('Previous 3 months' ,'booking'),
449 __('Previous month' ,'booking'),
450 __('Current month' ,'booking'),
451 __('Next month' ,'booking'),
452 __('Next 3 months' ,'booking') );
453 break;
454
455 default: // 30, 60, 90...
456 // phpcs:ignore WordPress.Security.NonceVerification.Recommended, WordPress.Security.NonceVerification.Missing
457 if (! isset($_REQUEST['scroll_month'])) $_REQUEST['scroll_month'] = 0;
458 $scroll_month = intval( $_REQUEST['scroll_month'] ); // phpcs:ignore WordPress.Security.NonceVerification.Recommended, WordPress.Security.NonceVerification.Missing
459 $scroll_params = array( '&scroll_month='.intval($scroll_month-3),
460 '&scroll_month='.intval($scroll_month-1),
461 '&scroll_month=0',
462 '&scroll_month='.intval($scroll_month+1 ),
463 '&scroll_month='.intval($scroll_month+3) );
464 $scroll_titles = array( __('Previous 3 months' ,'booking'),
465 __('Previous month' ,'booking'),
466 __('Current month' ,'booking'),
467 __('Next month' ,'booking'),
468 __('Next 3 months' ,'booking') );
469 break;
470 }
471 }
472
473
474 $params = array(
475 'label_for' => 'calendar_overview_navigation' // "For" parameter of button group element
476 , 'label' => '' //__('Calendar Navigation', 'booking') // Label above the button group
477 , 'style' => '' // CSS Style of entire div element
478 , 'items' => array(
479 array(
480 'type' => 'button'
481 , 'title' => '' // Title of the button
482 , 'hint' => array( 'title' => $scroll_titles[0] , 'position' => 'top' ) // Hint
483 , 'link' => $bk_admin_url .$scroll_params[0] // Direct link or skip it
484 , 'action' => "" // Some JavaScript to execure, for example run the function
485 , 'class' => 'button-secondary wpbc_button_no_background' // button-secondary | button-primary
486 , 'icon' => ''
487 , 'font_icon' => 'wpbc_icn_keyboard_double_arrow_left'
488 , 'icon_position' => 'left' // Position of icon relative to Text: left | right
489 , 'style' => '' // Any CSS class here
490 , 'mobile_show_text' => false // Show or hide text, when viewing on Mobile devices (small window size).
491 , 'attr' => array()
492 )
493 , array(
494 'type' => 'button'
495 , 'title' => '' // Title of the button
496 , 'hint' => array( 'title' => $scroll_titles[1] , 'position' => 'top' ) // Hint
497 , 'link' => $bk_admin_url .$scroll_params[1] // Direct link or skip it
498 , 'action' => "" // Some JavaScript to execure, for example run the function
499 , 'class' => 'button-secondary wpbc_button_no_background' // button-secondary | button-primary
500 , 'icon' => ''
501 , 'font_icon' => 'wpbc_icn_keyboard_arrow_left'
502 , 'icon_position' => 'left' // Position of icon relative to Text: left | right
503 , 'style' => '' // Any CSS class here
504 , 'mobile_show_text' => false // Show or hide text, when viewing on Mobile devices (small window size).
505 , 'attr' => array()
506 )
507 , array(
508 'type' => 'dropdown'
509 , 'id' => 'timeline_navigation_date'
510 , 'title' => '' // Title of the button
511 , 'hint' => array( 'title' => __('Custom' ,'booking') , 'position' => 'top' ) // Hint
512 , 'class' => 'button-secondary wpbc_button_no_background' // button-secondary | button-primary
513 , 'icon' => ''
514 , 'font_icon' => 'wpbc_icn_gps_fixed'
515 , 'icon_position' => 'left' // Position of icon relative to Text: left | right
516 , 'style' => '' // Any CSS class here
517 , 'mobile_show_text' => false // Show or hide text, when viewing on Mobile devices (small window size).
518 , 'attr' => array()
519 , 'options' => array(
520 $scroll_titles[2] => "window.location.href='"
521 . wpbc_get_params_in_url( wpbc_get_bookings_url( false )
522 , array('scroll_month', 'scroll_day', 'scroll_start_date') )
523 . $scroll_params[2] . "'"
524 , 'divider1' => 'divider'
525 , 'custom' => array( array( 'type' => 'group', 'class' => 'input-group text-group')
526 , array(
527 'type' => 'text'
528 , 'id' => 'calendar_overview_navigation_currentdate'
529 , 'name' => 'calendar_overview_navigation_currentdate'
530 , 'label' => __('Start Date' ,'booking') . ':'
531 , 'disabled' => false
532 , 'class' => 'wpdevbk-filters-section-calendar'
533 , 'style' => ''
534 , 'placeholder' => gmdate('Y-m-d')
535 , 'attr' => array()
536 , 'value' => ''
537 )
538 )
539 , 'divider2' => 'divider'
540 , 'buttons' => array( array( 'type' => 'group', 'class' => 'btn-group0', 'style'=>'display: flex;flex-flow: row nowrap;align-items: center;justify-content: flex-end;' ),
541 array(
542 'type' => 'button'
543 , 'title' => __('Apply' ,'booking') // Title of the button
544 , 'hint' => '' // , 'hint' => array( 'title' => __('Select status' ,'booking') , 'position' => 'bottom' )
545 , 'link' => 'javascript:void(0)' // Direct link or skip it
546 , 'action' => "jQuery('#calendar_overview_navigation_container').hide();
547 window.location.href='"
548 . wpbc_get_params_in_url( wpbc_get_bookings_url( false )
549 , array('scroll_month', 'scroll_day', 'scroll_start_date') )
550 . "&scroll_start_date=' + jQuery('#calendar_overview_navigation_currentdate').val();"
551
552 , 'class' => 'button-primary' // button-secondary | button-primary
553 , 'icon' => ''
554 , 'font_icon' => ''
555 , 'icon_position' => 'left' // Position of icon relative to Text: left | right
556 , 'style' => '' // Any CSS class here
557 , 'mobile_show_text' => false // Show or hide text, when viewing on Mobile devices (small window size).
558 , 'attr' => array()
559
560 )
561 , array(
562 'type' => 'button'
563 , 'title' => __('Close' ,'booking') // Title of the button
564 , 'hint' => '' // , 'hint' => array( 'title' => __('Select status' ,'booking') , 'position' => 'bottom' )
565 , 'link' => 'javascript:void(0)' // Direct link or skip it
566 //, 'action' => '' // Some JavaScript to execure, for example run the function
567 , 'class' => 'button-secondary' // button-secondary | button-primary
568 , 'icon' => ''
569 , 'font_icon' => ''
570 , 'icon_position' => 'left' // Position of icon relative to Text: left | right
571 , 'style' => 'margin:0 10px;' // Any CSS class here
572 , 'mobile_show_text' => false // Show or hide text, when viewing on Mobile devices (small window size).
573 , 'attr' => array()
574 )
575 )
576 )
577 )
578 , array(
579 'type' => 'button'
580 , 'title' => '' // Title of the button
581 , 'hint' => array( 'title' => $scroll_titles[3] , 'position' => 'top' ) // Hint
582 , 'link' => $bk_admin_url .$scroll_params[3] // Direct link or skip it
583 , 'action' => "" // Some JavaScript to execure, for example run the function
584 , 'class' => 'button-secondary wpbc_button_no_background' // button-secondary | button-primary
585 , 'icon' => ''
586 , 'font_icon' => 'wpbc_icn_keyboard_arrow_right'
587 , 'icon_position' => 'left' // Position of icon relative to Text: left | right
588 , 'style' => '' // Any CSS class here
589 , 'mobile_show_text' => false // Show or hide text, when viewing on Mobile devices (small window size).
590 , 'attr' => array()
591 )
592 , array(
593 'type' => 'button'
594 , 'title' => '' // Title of the button
595 , 'hint' => array( 'title' => $scroll_titles[4] , 'position' => 'top' ) // Hint
596 , 'link' => $bk_admin_url .$scroll_params[4] // Direct link or skip it
597 , 'action' => "" // Some JavaScript to execure, for example run the function
598 , 'class' => 'button-secondary wpbc_button_no_background' // button-secondary | button-primary
599 , 'icon' => ''
600 , 'font_icon' => 'wpbc_icn_keyboard_double_arrow_right'
601 , 'icon_position' => 'left' // Position of icon relative to Text: left | right
602 , 'style' => '' // Any CSS class here
603 , 'mobile_show_text' => false // Show or hide text, when viewing on Mobile devices (small window size).
604 , 'attr' => array()
605 )
606 )
607 );
608
609 wpbc_bs_button_group( $params );
610 }
611
612
613
614 // ---------------------------------------------------------------------------------------------------------------------
615 // Toolbar Options B u t t o n s - Add New Booking //////////////////
616 // ---------------------------------------------------------------------------------------------------------------------
617
618 /** Genereate URL based on GET parameters */
619 function wpbc_get_new_booking_url__base( $skip_parameters = array() ) {
620
621 $link_base = wpbc_get_new_booking_url( true, false );
622
623 $link_params = array();
624 // phpcs:ignore WordPress.Security.NonceVerification.Recommended, WordPress.Security.NonceVerification.Missing
625 if ( ( isset( $_GET['booking_type'] ) ) && ( $_GET['booking_type'] > 0 ) ) $link_params['booking_type'] = sanitize_text_field( wp_unslash( $_GET['booking_type'] ) ); /* phpcs:ignore WordPress.Security.NonceVerification.Recommended, WordPress.Security.NonceVerification.Missing */ /* FixIn: sanitize_unslash */
626 // phpcs:ignore WordPress.Security.NonceVerification.Recommended, WordPress.Security.NonceVerification.Missing
627 if ( isset( $_GET['booking_hash'] ) ) $link_params['booking_hash'] = sanitize_text_field( wp_unslash( $_GET['booking_hash'] ) ); /* phpcs:ignore WordPress.Security.NonceVerification.Recommended, WordPress.Security.NonceVerification.Missing */ /* FixIn: sanitize_unslash */
628 // phpcs:ignore WordPress.Security.NonceVerification.Recommended, WordPress.Security.NonceVerification.Missing
629 if ( isset( $_GET['parent_res'] ) ) $link_params['parent_res'] = sanitize_text_field( wp_unslash( $_GET['parent_res'] ) ); /* phpcs:ignore WordPress.Security.NonceVerification.Recommended, WordPress.Security.NonceVerification.Missing */ /* FixIn: sanitize_unslash */
630 // phpcs:ignore WordPress.Security.NonceVerification.Recommended, WordPress.Security.NonceVerification.Missing
631 if ( isset( $_GET['booking_form'] ) ) $link_params['booking_form'] = sanitize_text_field( wp_unslash( $_GET['booking_form'] ) ); /* phpcs:ignore WordPress.Security.NonceVerification.Recommended, WordPress.Security.NonceVerification.Missing */ /* FixIn: sanitize_unslash */
632 // phpcs:ignore WordPress.Security.NonceVerification.Recommended, WordPress.Security.NonceVerification.Missing
633 if ( isset( $_GET['calendar_months_count'] ) ) $link_params['calendar_months_count'] = intval( $_GET['calendar_months_count'] ); // phpcs:ignore WordPress.Security.NonceVerification.Recommended, WordPress.Security.NonceVerification.Missing
634 // phpcs:ignore WordPress.Security.NonceVerification.Recommended, WordPress.Security.NonceVerification.Missing
635 if ( isset( $_GET['calendar_months_num_in_1_row'] ) ) $link_params['calendar_months_num_in_1_row'] = intval( $_GET['calendar_months_num_in_1_row'] ); // phpcs:ignore WordPress.Security.NonceVerification.Recommended, WordPress.Security.NonceVerification.Missing
636
637
638 foreach ( $link_params as $key => $value ) {
639
640 if ( ! in_array( $key, $skip_parameters) ) {
641 $link_base .= '&' . $key . '=' . $value;
642 }
643 }
644
645 return $link_base;
646 }
647
648 /** Selection Number of visible months */
649 function wpbc_toolbar_btn__calendar_months_number_selection( $user_calendar_options = array() ) {
650
651 $text_label = __('Visible months' ,'booking') .':' ;
652
653 $form_options = array( 1 => 1, 2 => 2, 3 => 3, 4 => 4, 5 => 5, 6 => 6, 7 => 7, 8 => 8, 9 => 9, 10 => 10, 11 => 11, 12 => 12 );
654
655 $parameter_name = 'calendar_months_count';
656
657 if ( isset( $user_calendar_options[$parameter_name] ) ) $selected_value = intval ( $user_calendar_options[ $parameter_name ] );
658 else $selected_value = 1;
659
660 $link_base = wpbc_get_new_booking_url__base( array( $parameter_name ) ) . '&' . $parameter_name . '=' ;
661
662 $on_change = ''; //'location.href=\'' . $link_base . '\' + this.value;';
663
664
665 $params = array(
666 'label_for' => $parameter_name // "For" parameter of label element
667 , 'label' => '' // Label above the input group
668 , 'style' => '' // CSS Style of entire div element
669 , 'items' => array(
670 array(
671 'type' => 'addon'
672 , 'element' => 'text' // text | radio | checkbox
673 , 'text' => $text_label
674 , 'class' => '' // Any CSS class here
675 , 'style' => 'font-weight:600;' // CSS Style of entire div element
676 )
677 , array(
678 'type' => 'select'
679 , 'id' => $parameter_name // HTML ID of element
680 , 'options' => $form_options // Associated array of titles and values
681 , 'value' => $selected_value // Some Value from optins array that selected by default
682 , 'style' => '' // CSS of select element
683 , 'class' => '' // CSS Class of select element
684 , 'attr' => array() // Any additional attributes, if this radio | checkbox element
685 , 'onchange' => $on_change
686 )
687 )
688 );
689 ?><div class="control-group wpbc-no-padding" style="width:auto;"><?php
690 wpbc_bs_input_group( $params );
691 ?></div><?php
692 }
693
694
695 /** Selection Number of calendar months in one row */
696 function wpbc_toolbar_btn__calendar_months_num_in_1_row_selection( $user_calendar_options = array() ) {
697
698 $text_label = __('Number of months in one row' ,'booking') . ':';
699 $form_options = array( 0 => __('All', 'booking'), 1 => 1, 2 => 2, 3 => 3, 4 => 4, 5 => 5, 6 => 6, 7 => 7, 8 => 8, 9 => 9, 10 => 10, 11 => 11, 12 => 12 );
700
701 $parameter_name = 'calendar_months_num_in_1_row';
702
703 if ( isset( $user_calendar_options[$parameter_name] ) ) $selected_value = intval ( $user_calendar_options[ $parameter_name ] );
704 else $selected_value = 0;
705
706 $link_base = wpbc_get_new_booking_url__base( array( $parameter_name ) ) . '&' . $parameter_name . '=' ;
707
708 $on_change = ''; // 'location.href=\'' . $link_base . '\' + this.value;';
709
710
711 $params = array(
712 'label_for' => $parameter_name // "For" parameter of label element
713 , 'label' => '' // Label above the input group
714 , 'style' => '' // CSS Style of entire div element
715 , 'items' => array(
716 array(
717 'type' => 'addon'
718 , 'element' => 'text' // text | radio | checkbox
719 , 'text' => $text_label
720 , 'class' => '' // Any CSS class here
721 , 'style' => 'font-weight:600;' // CSS Style of entire div element
722 )
723 , array(
724 'type' => 'select'
725 , 'id' => $parameter_name // HTML ID of element
726 , 'options' => $form_options // Associated array of titles and values
727 , 'value' => $selected_value // Some Value from optins array that selected by default
728 , 'style' => '' // CSS of select element
729 , 'class' => '' // CSS Class of select element
730 , 'attr' => array() // Any additional attributes, if this radio | checkbox element
731 , 'onchange' => $on_change
732 )
733 )
734 );
735 ?><div class="control-group wpbc-no-padding"><?php
736 wpbc_bs_input_group( $params );
737 ?></div><?php
738 }
739
740
741 function wpbc_toolbar_btn__calendar_width( $user_calendar_options = array() ){
742
743 $text_label = __('Maximum width of calendar' ,'booking') . ':';
744 $parameter_name = 'calendar_width';
745
746 if ( isset( $user_calendar_options[$parameter_name] ) ) $selected_value = intval( $user_calendar_options[ $parameter_name ] );
747 else $selected_value = '';
748
749 if ( isset( $user_calendar_options[$parameter_name . 'units'] ) ) $selected_value_units = esc_attr( $user_calendar_options[ $parameter_name . 'units' ] );
750 else $selected_value_units = '';
751
752 $params = array(
753 'label_for' => $parameter_name // "For" parameter of label element
754 , 'label' => '' // Label above the input group
755 , 'style' => '' // CSS Style of entire div element
756 , 'items' => array(
757 array(
758 'type' => 'addon'
759 , 'element' => 'text' // text | radio | checkbox
760 , 'text' => $text_label
761 , 'class' => '' // Any CSS class here
762 , 'style' => 'font-weight:600;' // CSS Style of entire div element
763 )
764 , array(
765 'type' => 'text'
766 , 'id' => $parameter_name // HTML ID of element
767 , 'value' => $selected_value // Some Value from optins array that selected by default
768 , 'style' => 'width: 5em;' // CSS of select element
769 , 'placeholder' => '100%'
770 , 'class' => '' // CSS Class of select element
771 , 'attr' => array() // Any additional attributes, if this radio | checkbox element
772 )
773 , array(
774 'type' => 'select'
775 , 'id' => $parameter_name . 'units' // HTML ID of element
776 , 'options' => array( 'px' => 'px', 'percent' => '%' ) // Associated array of titles and values
777 , 'value' => $selected_value_units // Some Value from optins array that selected by default
778 , 'style' => 'width: 5em;' // CSS of select element
779 , 'class' => '' // CSS Class of select element
780 , 'attr' => array() // Any additional attributes, if this radio | checkbox element
781 )
782 )
783 );
784 ?><div class="control-group wpbc-no-padding"><?php
785 wpbc_bs_input_group( $params );
786 ?></div><?php
787 }
788
789 function wpbc_toolbar_btn__calendar_cell_height( $user_calendar_options = array() ){
790
791 $text_label = __('Calendar cell height' ,'booking') . ':';
792 $parameter_name = 'calendar_cell_height';
793
794 if ( isset( $user_calendar_options[$parameter_name] ) ) $selected_value = intval( $user_calendar_options[ $parameter_name ] );
795 else $selected_value = '';
796
797 if ( isset( $user_calendar_options[$parameter_name . 'units'] ) ) $selected_value_units = esc_attr( $user_calendar_options[ $parameter_name . 'units' ] );
798 else $selected_value_units = '';
799
800 $params = array(
801 'label_for' => $parameter_name // "For" parameter of label element
802 , 'label' => '' // Label above the input group
803 , 'style' => '' // CSS Style of entire div element
804 , 'items' => array(
805 array(
806 'type' => 'addon'
807 , 'element' => 'text' // text | radio | checkbox
808 , 'text' => $text_label
809 , 'class' => '' // Any CSS class here
810 , 'style' => 'font-weight:600;' // CSS Style of entire div element
811 )
812 , array(
813 'type' => 'text'
814 , 'id' => $parameter_name // HTML ID of element
815 , 'value' => $selected_value // Some Value from optins array that selected by default
816 , 'style' => 'width: 5em;' // CSS of select element
817 , 'placeholder' => '48px'
818 , 'class' => '' // CSS Class of select element
819 , 'attr' => array() // Any additional attributes, if this radio | checkbox element
820 )
821 , array(
822 'type' => 'select'
823 , 'id' => $parameter_name . 'units' // HTML ID of element
824 , 'options' => array( 'px' => 'px', 'percent' => '%' ) // Associated array of titles and values
825 , 'value' => $selected_value_units // Some Value from optins array that selected by default
826 , 'style' => 'width: 5em;' // CSS of select element
827 , 'class' => '' // CSS Class of select element
828 , 'attr' => array() // Any additional attributes, if this radio | checkbox element
829 )
830
831 )
832 );
833 ?><div class="control-group wpbc-no-padding"><?php
834 wpbc_bs_input_group( $params );
835 ?></div><?php
836 }
837
838
839 /** Add New Booking Button*/
840 function wpbc_toolbar_btn__calendar_options_save() {
841
842 ?><div class="control-group wpbc-no-padding"><?php
843 ?><a id="toolbar_btn__calendar_options_save"
844 class="button button-primary "
845 href="javascript:void(0)"
846 onclick="javascript:var data_params = {};
847 data_params.calendar_months_count = jQuery('#calendar_months_count').val();
848 data_params.calendar_months_num_in_1_row = jQuery('#calendar_months_num_in_1_row').val();
849 data_params.calendar_width = jQuery('#calendar_width').val();
850 data_params.calendar_widthunits = jQuery('#calendar_widthunits').val();
851 data_params.calendar_cell_height = jQuery('#calendar_cell_height').val();
852 data_params.calendar_cell_heightunits = jQuery('#calendar_cell_heightunits').val();
853 var ajax_data_params = jQuery.param( data_params );
854 wpbc_save_custom_user_data(<?php echo esc_js( wpbc_get_current_user_id() ); ?>
855 , '<?php echo 'add_booking_calendar_options'; ?>'
856 , ajax_data_params
857 , 1
858 );"
859 ><?php esc_html_e('Save' , 'booking' ); ?></a><?php
860 ?></div><?php
861 }
862
863
864 /** Add New Booking Button*/
865 function wpbc_toolbar_btn__calendar_options_reset() {
866
867 ?><div class="control-group wpbc-no-padding"><?php
868 ?><a
869 class="button button-secondary "
870 href="javascript:void(0)"
871 onclick="javascript:jQuery('#calendar_months_count').val('1');
872 jQuery('#calendar_months_num_in_1_row').val('0');
873 jQuery('#calendar_width').val('0');
874 jQuery('#calendar_widthunits').val('px');
875 jQuery('#calendar_cell_height').val('0');
876 jQuery('#calendar_cell_heightunits').val('px');
877 jQuery( '#toolbar_btn__calendar_options_save').trigger('click');
878 "
879 ><?php esc_html_e('Reset' , 'booking' ); ?></a><?php
880 ?></div><?php
881 }
882
883
884 /** Add New Booking Button*/
885 function wpbc_toolbar_btn__add_new_booking() {
886
887 // phpcs:ignore WordPress.Security.NonceVerification.Recommended, WordPress.Security.NonceVerification.Missing
888 if ( isset( $_GET['booking_type'] ) ) {
889 $bk_type = intval( $_GET['booking_type'] ); // phpcs:ignore WordPress.Security.NonceVerification.Recommended, WordPress.Security.NonceVerification.Missing
890 } else {
891 $bk_type = 1;
892 }
893
894 ?><a
895 class="button-primary button wpbc_submit_button"
896 href="javascript:void(0)"
897 onclick="mybooking_submit(
898 document.getElementById('booking_form<?php echo intval( $bk_type ); ?>' )
899 , <?php echo intval( $bk_type ); ?>
900 , '<?php echo esc_js( wpbc_get_maybe_reloaded_booking_locale() ); ?>'
901 );"
902 ><?php esc_html_e( 'Add booking', 'booking' ); ?></a><?php
903 }
904
905
906 /** Checkbox - sending emails or not - duplicated button, usually at the bottom of page*/
907 function wpbc_toolbar_is_send_emails_btn_duplicated() {
908
909 ?><div class="btn-group" style="margin-top:10px;"><?php
910
911 $el_id = 'is_send_email_for_new_booking';
912
913 $el_value = ( get_bk_option( 'booking_send_emails_off_addbooking' ) !== 'On' ) ? 'On' : 'Off';
914
915 $params_checkbox = array(
916 'id' => $el_id // HTML ID of element
917 , 'name' => $el_id
918 , 'label' => array( 'title' => __( 'Emails sending', 'booking' ) , 'position' => 'right' ) // FixIn: 9.6.1.5.
919 , 'style' => '' // CSS of select element
920 , 'class' => '' // CSS Class of select element
921 , 'disabled' => false
922 , 'attr' => array() // Any additional attributes, if this radio | checkbox element
923 , 'legend' => '' // aria-label parameter
924 , 'value' => $el_value // Some Value from optins array that selected by default
925 , 'selected' => ( ( 'On' == $el_value ) ? true : false ) // Selected or not
926 //, 'onfocus' => "console.log( 'ON FOCUS:', jQuery( this ).is(':checked') , 'in element:' , jQuery( this ) );" // JavaScript code
927 , 'onchange' => "document.getElementById('is_send_email_for_pending').checked = this.checked;" // JavaScript code
928 , 'hint' => array( 'title' => __('Send email notification to customer about this operation' ,'booking') , 'position' => 'top' )
929 );
930
931 wpbc_flex_toggle( $params_checkbox );
932
933 ?></div><?php
934
935 ?>
936 <script type="text/javascript">
937 jQuery( '#is_send_email_for_pending' ).on('change', function() {
938 document.getElementById( 'is_send_email_for_new_booking' ).checked = jQuery( '#is_send_email_for_pending' ).is( ':checked' );
939 });
940 </script>
941 <?php
942 }
943
944
945 /**
946 * Show Link (button) for adding booking to Google Calendar
947 *
948 * @param int $booking_id
949 * @param array $button_attr
950 * @param bool $echo
951 * @return string
952 */
953 function wpbc_btn_add_booking_to_google_calendar( $booking_data, $button_attr = array(), $echo = true ) { // FixIn: 7.1.2.5.
954
955 //debuge($booking_data);
956 if ( ! $echo ) {
957 ob_start();
958 }
959
960 $defaults = array(
961 'title' => __( 'Add to Google Calendar', 'booking' )
962 , 'hint' => __( 'Add to Google Calendar', 'booking' )
963 , 'class' => 'button-secondary button'
964 , 'is_show_icon' => true
965 , 'is_only_url' => false
966 );
967 $button_attr = wp_parse_args( $button_attr, $defaults );
968
969 $params = array();
970 $params['timezone'] = get_bk_option('booking_gcal_timezone');
971
972 $booking_gcal_events_form_fields = get_bk_option( 'booking_gcal_events_form_fields');
973 if ( is_serialized( $booking_gcal_events_form_fields ) )
974 $booking_gcal_events_form_fields = unserialize( $booking_gcal_events_form_fields );
975
976 /**
977 * Array
978 (
979 [title] => text^name
980 [description] => textarea^details
981 [where] => text^
982 )
983 */
984
985
986 // Fields
987 $fields = array( 'title' => '', 'description' => '', 'where' => '' );
988
989 foreach ( $fields as $key_name => $field_value ) {
990
991 if ( ! empty( $booking_gcal_events_form_fields[ $key_name ] ) ) {
992
993 $field_name = explode( '^', $booking_gcal_events_form_fields[ $key_name ] );
994
995 $field_name = $field_name[ ( count( $field_name ) - 1 ) ]; // FixIn: 8.7.7.6.
996
997 if ( (! empty($field_name))
998 && (! empty($booking_data['form_data']))
999 && (! empty($booking_data['form_data']['_all_fields_']))
1000 && (! empty($booking_data['form_data']['_all_fields_'][ $field_name ]))
1001 ) {
1002
1003 if ( 'description' === $key_name ) { // FixIn: 8.1.3.2.
1004 if ( isset( $booking_data['form_show'] ) ) { // FixIn: 8.7.3.14.
1005 // FixIn: 8.7.11.4.
1006 $fields[ $key_name ] = $booking_data['form_show'];
1007 $fields[ $key_name ] = htmlspecialchars_decode($fields[ $key_name ], ENT_QUOTES );
1008 $fields[ $key_name ] = urlencode($fields[ $key_name ]);
1009 $fields[ $key_name ] = htmlentities($fields[ $key_name ] );
1010 $fields[ $key_name ] = htmlspecialchars_decode ( $fields[ $key_name ], ENT_NOQUOTES );
1011 }
1012 } else {
1013 // FixIn: 8.7.11.4.
1014 $fields[ $key_name ] = $booking_data['form_data']['_all_fields_'][ $field_name ];
1015 $fields[ $key_name ] = htmlspecialchars_decode($fields[ $key_name ], ENT_QUOTES );
1016 // Convert here from usual symbols to URL symbols https://www.url-encode-decode.com/
1017 // $fields[ $key_name ] = str_replace( array( '%','#', '+', '&' )
1018 // , array( '%25','%23', '%2B', '%26')
1019 // , $fields[ $key_name ]
1020 // );
1021 $fields[ $key_name ] = urlencode($fields[ $key_name ]);
1022 $fields[ $key_name ] = htmlentities($fields[ $key_name ] );
1023 $fields[ $key_name ] = htmlspecialchars_decode ( $fields[ $key_name ], ENT_NOQUOTES );
1024 }
1025 }
1026 }
1027 }
1028 //debuge($booking_gcal_events_form_fields, $fields,$booking_data['form_data']);
1029
1030 // Dates.
1031
1032 $check_in_timestamp = $check_out_timestamp = '';
1033 if ( ! empty( $booking_data[ 'dates_short' ] ) ) {
1034
1035
1036 /* all day events, you can use 20161208/20161209 - note that the old google documentation gets it wrong.
1037 * You must use the following date as the end date for a one day all day event,
1038 * or +1 day to whatever you want the end date to be.
1039 */
1040
1041 $check_in_timestamp = strtotime( $booking_data[ 'dates_short' ][ 0 ], current_time( 'timestamp' ) );
1042 if ( trim( substr( $booking_data[ 'dates_short' ][ 0 ], 11 ) ) == '00:00:00' ) {
1043 $check_in_timestamp = gmdate( "Ymd", $check_in_timestamp ); // All day
1044 } else {
1045 $check_in_timestamp = gmdate( "Ymd\THis", $check_in_timestamp );
1046 //$check_in_timestamp = gmdate( "Ymd\THis\Z", $check_in_timestamp );
1047 }
1048
1049 $check_out_timestamp = strtotime( $booking_data[ 'dates_short' ][ ( count( $booking_data[ 'dates_short' ] ) - 1 ) ], current_time( 'timestamp' ) );
1050 if ( trim( substr( $booking_data[ 'dates_short' ][ ( count( $booking_data[ 'dates_short' ] ) - 1 ) ], 11 ) ) == '00:00:00' ) {
1051 $check_out_timestamp = strtotime( '+1 day', $check_out_timestamp );
1052 $check_out_timestamp = gmdate( "Ymd", $check_out_timestamp ); // All day
1053 } else {
1054 $check_out_timestamp = gmdate( "Ymd\THis", $check_out_timestamp );
1055 //$check_out_timestamp = gmdate( "Ymd\THis\Z", $check_out_timestamp );
1056 }
1057
1058 }
1059
1060 //debuge($check_in_timestamp,$check_out_timestamp, $fields );die;
1061 //Convert an ISO date/time to a UNIX timestamp
1062 //function iso_to_ts( $iso ) {
1063 // sscanf( $iso, "%u-%u-%uT%u:%u:%uZ", $year, $month, $day, $hour, $minute, $second );
1064 // return mktime( intval($hour), intval($minute), intval($second), intval($month), intval($day), intval($year) );
1065 // 20140127T224000Z
1066 // gmdate("Ymd\THis\Z", time());
1067
1068 /**
1069 action:
1070 action=TEMPLATE
1071 A default required parameter.
1072
1073 src:
1074 Example: src=default%40gmail.com
1075 Format: src=text
1076 This is not covered by Google help but is an optional parameter in order to add an event to a shared calendar rather than a user's default.
1077
1078 text:
1079 Example: text=Garden%20Waste%20Collection
1080 Format: text=text
1081 This is a required parameter giving the event title.
1082
1083 dates:
1084 Example: dates=20090621T063000Z/20090621T080000Z (i.e. an event on 21 June 2009 from 7.30am to 9.0am British Summer Time (=GMT+1)).
1085 Format: dates=YYYYMMDDToHHMMSSZ/YYYYMMDDToHHMMSSZ
1086 This required parameter gives the start and end dates and times (in Greenwich Mean Time) for the event.
1087
1088 location:
1089 Example: location=Home
1090 Format: location=text
1091 The obvious location field.
1092
1093 trp:
1094 Example: trp=false
1095 Format: trp=true/false
1096 Show event as busy (true) or available (false)
1097
1098 sprop:
1099 Example: sprop=http%3A%2F%2Fwww.me.org
1100 Example: sprop=name:Home%20Page
1101 Format: sprop=website and/or sprop=name:website_name
1102 */
1103
1104 // $link_add2gcal = 'http://www.google.com/calendar/event?action=TEMPLATE';
1105 // $link_add2gcal .= '&text=' . $fields['title'];
1106 // FixIn: 8.7.3.10.
1107 $link_add2gcal = 'https://calendar.google.com/calendar/r/eventedit?';
1108 $link_add2gcal .= 'text=' . $fields['title']; // FixIn: 8.7.11.4.
1109 //$link_add2gcal .= '&dates=[start-custom format='Ymd\\THi00\\Z']/[end-custom format='Ymd\\THi00\\Z']';
1110 $link_add2gcal .= '&dates=' . $check_in_timestamp . '/' . $check_out_timestamp;
1111 $link_add2gcal .= '&details=' . ( ( 'On' !== get_bk_option( 'booking_g_cal_export_no_data' ) ) ? $fields['description'] : '' ); // FixIn: 10.3.0.1.
1112 $link_add2gcal .= '&location=' . ( ( 'On' !== get_bk_option( 'booking_g_cal_export_no_data' ) ) ? $fields['where'] : '' );
1113 $link_add2gcal .= '&trp=false';
1114 if ( ! empty( $params['timezone'] ) ) {
1115 $link_add2gcal .= '&ctz=' . str_replace( '%', '%25', $params['timezone'] ); //FixIn: 8.7.3.10 //TimeZone
1116 }
1117
1118
1119 //$link_add2gcal .= '&sprop=';
1120 //$link_add2gcal .= '&sprop=name:';
1121
1122 if ( $button_attr['is_only_url'] ) {
1123 // phpcs:ignore WordPress.Security.EscapeOutput.OutputNotEscaped
1124 echo $link_add2gcal;
1125 } else {
1126
1127 ?><a href="<?php echo esc_url( $link_add2gcal ); ?>" target="_blank" rel="nofollow"
1128 class="tooltip_top <?php echo esc_attr( $button_attr['class'] ) ?>"
1129 title="<?php echo esc_attr( $button_attr['hint'] ); ?>"
1130 ><?php
1131 if ( $button_attr['is_show_icon'] ) {
1132 ?><i class="wpbc_icn_event"></i><?php //FixIn: 9.0.1.4 glyphicon icon-1x glyphicon-export
1133 } else {
1134 echo esc_js( $button_attr['title'] );
1135 }
1136 ?></a><?php
1137 }
1138
1139 if ( ! $echo ) {
1140 return ob_get_clean();
1141 }
1142
1143 }
1144 // ---------------------------------------------------------------------------------------------------------------------
1145 // Toolbar Other UI elements - General
1146 // ---------------------------------------------------------------------------------------------------------------------
1147
1148 /**
1149 * Selection elements in toolbar UI selectbox
1150 *
1151 * @param array $params
1152 *
1153 * Exmaple:
1154 wpbc_toolbar_btn__selection_element( array(
1155 'name' => 'resources_count'
1156 , 'title' => __('Resources count' ,'booking') . ':'
1157 , 'selected' => 1
1158 , 'options' => array_combine( range(1, 201) ,range(1, 201) )
1159 ) ) ;
1160
1161 */
1162 function wpbc_toolbar_btn__selection_element( $params ) {
1163
1164 $defaults = array(
1165 'name' => 'random_' . wp_rand( 1000, 10000 )
1166 , 'title' => __('Total', 'booking') . ':'
1167 , 'on_change' => '' //'location.href=\'' . $link_base . '\' + this.value;'; //$link_base = wpbc_get_new_booking_url__base( array( $params['name'] ) ) . '&' . $params['name'] . '=' ;
1168 , 'options' => array()
1169 , 'selected' => 0
1170 );
1171 $params = wp_parse_args( $params, $defaults );
1172
1173
1174
1175
1176 for ( $i = 1; $i < 201; $i++ ) {
1177 $form_options[ $i ] = $i;
1178 }
1179
1180 $params = array(
1181 'label_for' => $params['name'] // "For" parameter of label element
1182 , 'label' => '' // Label above the input group
1183 , 'style' => '' // CSS Style of entire div element
1184 , 'items' => array(
1185 array(
1186 'type' => 'addon'
1187 , 'element' => 'text' // text | radio | checkbox
1188 , 'text' => $params['title']
1189 , 'class' => '' // Any CSS class here
1190 , 'style' => 'font-weight:600;' // CSS Style of entire div element
1191 )
1192 , array(
1193 'type' => 'select'
1194 , 'id' => $params['name'] // HTML ID of element
1195 , 'name' => $params['name'] // HTML ID of element
1196 , 'options' => $params['options'] // Associated array of titles and values
1197 , 'value' => $params['selected'] // Some Value from optins array that selected by default
1198 , 'style' => '' // CSS of select element
1199 , 'class' => '' // CSS Class of select element
1200 , 'attr' => array() // Any additional attributes, if this radio | checkbox element
1201 , 'onchange' => $params['on_change']
1202 )
1203 )
1204 );
1205 ?><div class="control-group wpbc-no-padding"><?php
1206 wpbc_bs_input_group( $params );
1207 ?></div><?php
1208 }
1209
1210
1211 // ---------------------------------------------------------------------------------------------------------------------
1212 // Toolbar S e a r c h F o r m at Top Right side of Settings page
1213 // ---------------------------------------------------------------------------------------------------------------------
1214
1215 // FixIn: 8.0.1.12.
1216 /**
1217 * Add hidden input SEARCH KEY field into main form, if previosly was searching by ID or Title
1218 * @param array $params => array( 'search_get_key' => 'wh_resource_id' )
1219 */
1220 function wpbc_hidden_search_by_id_field_in_main_form( $params = array() ){
1221
1222 $defaults = array(
1223 'search_get_key' => 'wh_search_id'
1224 );
1225 $params = wp_parse_args( $params, $defaults );
1226
1227
1228 $search_form_value = '';
1229 // phpcs:ignore WordPress.Security.NonceVerification.Recommended, WordPress.Security.NonceVerification.Missing
1230 if ( isset( $_REQUEST[ $params[ 'search_get_key' ] ] ) ) {
1231 // phpcs:ignore WordPress.Security.ValidatedSanitizedInput.InputNotValidated, WordPress.Security.NonceVerification.Missing, WordPress.Security.NonceVerification.Recommended, WordPress.Security.ValidatedSanitizedInput.MissingUnslash, WordPress.Security.ValidatedSanitizedInput.InputNotSanitized
1232 $wh_resource_id = wpbc_clean_digit_or_csd( $_REQUEST[ $params['search_get_key'] ] ); // '12,0,45,9' or '10'.
1233 // phpcs:ignore WordPress.Security.ValidatedSanitizedInput.InputNotValidated, WordPress.Security.NonceVerification.Missing, WordPress.Security.NonceVerification.Recommended, WordPress.Security.ValidatedSanitizedInput.MissingUnslash, WordPress.Security.ValidatedSanitizedInput.InputNotSanitized
1234 $wh_resource_title = wpbc_clean_string_for_form( $_REQUEST[ $params['search_get_key'] ] ); // Clean string.
1235
1236 if ( ! empty( $wh_resource_id ) ) {
1237 $search_form_value = $wh_resource_id;
1238 } else {
1239 $search_form_value = $wh_resource_title;
1240 }
1241 }
1242
1243 if ( '' !== $search_form_value ) {
1244 ?><input name="<?php echo esc_attr( $params['search_get_key'] ); ?>" value="<?php echo esc_attr( $search_form_value ); ?>" type="hidden"><?php
1245 }
1246 }
1247
1248 /**
1249 * Real Search booking data by ID | Title (at top right side of page)
1250 *
1251 * @param array $params - array of parameters
1252 * Exmaple:
1253 wpbc_toolbar_search_by_id__top_form( array(
1254 'search_form_id' => 'wpbc_seasonfilters_search_form'
1255 , 'search_get_key' => 'wh_search_id'
1256 , 'is_pseudo' => false
1257 ) );
1258
1259 */
1260 function wpbc_toolbar_search_by_id__top_form( $params ) {
1261
1262 $defaults = array(
1263 'search_form_id' => 'wpbc_seasonfilters_search_form'
1264 , 'search_get_key' => 'wh_search_id'
1265 , 'is_pseudo' => false //'location.href=\'' . $link_base . '\' + this.value;'; //$link_base = wpbc_get_new_booking_url__base( array( $params['name'] ) ) . '&' . $params['name'] . '=' ;
1266 , 'container_style' => 'position: absolute; right: 20px; top: 0px;z-index: 0;' // FixIn: 10.0.0.29.
1267 );
1268 $params = wp_parse_args( $params, $defaults );
1269
1270
1271 $exclude_params = array(); //array('page_num', 'orderby', 'order'); - if using "only_these_parameters", then this parameter does NOT require
1272 $only_these_parameters = array( 'page', 'tab', 'subtab', $params[ 'search_get_key' ] ); //FixIn: 8.1.1.11 - added , 'subtab' - ability to search booking resources in sub tab pages in settings
1273 $wpbc_admin_url = wpbc_get_params_in_url( wpbc_get_bookings_url( false, false ), $exclude_params, $only_these_parameters );
1274
1275
1276 $search_form_value = '';
1277 // phpcs:ignore WordPress.Security.NonceVerification.Recommended, WordPress.Security.NonceVerification.Missing
1278 if ( isset( $_REQUEST[ $params[ 'search_get_key' ] ] ) ) {
1279 $wh_resource_id = wpbc_clean_digit_or_csd( $_REQUEST[ $params[ 'search_get_key' ] ] ); // phpcs:ignore WordPress.Security.NonceVerification.Missing, WordPress.Security.NonceVerification.Recommended, WordPress.Security.ValidatedSanitizedInput.MissingUnslash, WordPress.Security.ValidatedSanitizedInput.InputNotSanitized, WordPress.Security.ValidatedSanitizedInput.InputNotSanitized // '12,0,45,9' or '10'
1280 $wh_resource_title = wpbc_clean_string_for_form( $_REQUEST[ $params[ 'search_get_key' ] ] ); // phpcs:ignore WordPress.Security.NonceVerification.Missing, WordPress.Security.NonceVerification.Recommended, WordPress.Security.ValidatedSanitizedInput.MissingUnslash, WordPress.Security.ValidatedSanitizedInput.InputNotSanitized, WordPress.Security.ValidatedSanitizedInput.InputNotSanitized // Clean string
1281 if ( ! empty( $wh_resource_id ) ) {
1282 $search_form_value = $wh_resource_id;
1283 } else {
1284 $search_form_value = $wh_resource_title;
1285 }
1286 }
1287
1288
1289 wpbc_clear_div();
1290
1291 ?>
1292 <span class="wpdevelop">
1293
1294 <?php if ( ! $params['is_pseudo'] ) { ?>
1295 <div style="<?php echo esc_attr( $params['container_style'] ); ?>">
1296 <form action="<?php echo esc_url( $wpbc_admin_url ); ?>" method="post" id="<?php echo esc_attr( $params[ 'search_form_id' ] ); ?>" name="<?php echo esc_attr( $params[ 'search_form_id' ] ); ?>" >
1297 <?php
1298 } else {
1299 ?><div style="float:right;" id="<?php echo esc_attr( $params['search_form_id'] . '_pseudo' ); ?>"><?php
1300 }
1301
1302
1303 if(0){
1304 $params_for_element = array( 'label_for' => $params[ 'search_get_key' ] . ( ( $params['is_pseudo'] ) ? '_pseudo' : '' )
1305 , 'label' => ''//__('Keyword:', 'booking')
1306 , 'items' => array(
1307 array( 'type' => 'text'
1308 , 'id' => $params[ 'search_get_key' ] . ( ( $params['is_pseudo'] ) ? '_pseudo' : '' )
1309 , 'value' => $search_form_value
1310 , 'placeholder' => __('ID or Title', 'booking')
1311 )
1312 , array(
1313 'type' => 'button'
1314 , 'title' => __('Go', 'booking')
1315 , 'class' => 'button-secondary'
1316 , 'font_icon' => 'wpbc_icn_search'
1317 , 'icon_position' => 'right'
1318 , 'action' => ( ( ! $params['is_pseudo'] ) ? "jQuery('#". $params[ 'search_form_id' ] ."').trigger( 'submit' );"
1319 : "jQuery('#" . $params[ 'search_get_key' ] . "').val( jQuery('#" . $params[ 'search_get_key' ] . "_pseudo').val() ); jQuery('#". $params[ 'search_form_id' ] ."').trigger( 'submit' );" ) //Submit real form at the top of page.
1320 )
1321 )
1322 );
1323
1324 ?><div class="control-group wpbc-no-padding" ><?php
1325 wpbc_bs_input_group( $params_for_element );
1326 ?></div><?php
1327 } else {
1328 ?><div id="booking_resources_toolbar_container" class="wpbc_ajx_toolbar wpbc_background_transparent"><?php
1329
1330 ?><div class="ui_container ui_container_toolbar ui_container_small ui_container_options ui_container_options_row_1"
1331 style=" display: flex"><?php
1332
1333 ?><div class="ui_group"><?php
1334
1335 // Search Keyword text field
1336 ?><div class="ui_element"><?php
1337
1338 $el_id = 'booking_resource_search_keyword';
1339
1340 $default_value = $search_form_value;
1341
1342 $params_for_element = array(
1343 'type' => 'text'
1344 , 'id' => $params[ 'search_get_key' ] . ( ( $params['is_pseudo'] ) ? '_pseudo' : '' )
1345 , 'name' => $params[ 'search_get_key' ] . ( ( $params['is_pseudo'] ) ? '_pseudo' : '' )
1346 , 'label' => ''
1347 , 'disabled' => false
1348 , 'class' => ''
1349 , 'style' => 'min-width:100px;'
1350 , 'placeholder' => __('ID or Title' ,'booking')
1351 , 'attr' => array( 'maxlength' => '200' )
1352 , 'value' => $default_value
1353 , 'onfocus' => ''
1354 );
1355
1356 wpbc_flex_text( $params_for_element );
1357
1358 ?></div><?php
1359
1360
1361 // Reset keyword
1362 $params_for_element = array(
1363 'type' => 'button' ,
1364 'title' => '',//__( 'Reset', 'booking' ) . '&nbsp;&nbsp;', // Title of the button
1365 'hint' => array( 'title' => __( 'Reset keyword text field', 'booking' ), 'position' => 'top' ), // Hint
1366 'link' => 'javascript:void(0)', // Direct link or skip it
1367 // 'action' => "jQuery( '#booking_resource_search_keyword').val('');
1368 // window.location.href='" . $option_params['url'] . "';", // JavaScript
1369 'action' => ( ( ! $params['is_pseudo'] ) ? "jQuery('#" . $params[ 'search_get_key' ] . "').val( '' ); jQuery('#". $params[ 'search_form_id' ] ."').trigger( 'submit' );"
1370 : "jQuery('#" . $params[ 'search_get_key' ] . "').val( '' ); jQuery('#". $params[ 'search_form_id' ] ."').trigger( 'submit' );" ) ,
1371 'icon' => array(
1372 'icon_font' => 'wpbc_icn_close', //'wpbc_icn_rotate_left',
1373 'position' => 'left',
1374 'icon_img' => ''
1375 ),
1376 'class' => 'wpbc_button_as_icon', // '' | 'wpbc_ui_button_primary'
1377 'style' => '', // Any CSS class here
1378 'mobile_show_text' => true, // Show or hide text, when viewing on Mobile devices (small window size).
1379 'attr' => array()
1380 );
1381
1382 ?><div class="ui_element" style="flex: 0 1 auto;margin-left: -50px;z-index: 1;"><?php
1383 wpbc_flex_button( $params_for_element );
1384 ?></div><?php
1385
1386
1387 // Go button
1388 ?><div class="ui_element"><?php
1389
1390 $booking_action = 'booking_resource_search_keyword_btn';
1391
1392 $el_id = 'ui_btn_' . $booking_action;
1393
1394 // Escaped construction of search keyword. // FixIn: 9.9.0.11.
1395 $params_for_element = array(
1396 'type' => 'button' ,
1397 'title' => '',//__( 'Search', 'booking' ) . '&nbsp;&nbsp;', // Title of the button
1398 'hint' => array( 'title' => __('Search' ,'booking'), 'position' => 'top' ), // Hint
1399 'link' => 'javascript:void(0)', // Direct link or skip it
1400 //'link' => $option_params['url'] . '&wh_resource_id=sdfs+f',
1401 // 'action' => "if (jQuery('#booking_resource_search_keyword' ).val() == '' ) {
1402 // wpbc_field_highlight( '#booking_resource_search_keyword' );
1403 // } else {
1404 // window.location.href='" . $option_params['url'] . "&wh_resource_id='+window.encodeURIComponent(jQuery('#booking_resource_search_keyword' ).val());
1405 // }" ,
1406 'action' => ( ( ! $params['is_pseudo'] ) ? "jQuery('#". $params[ 'search_form_id' ] ."').trigger( 'submit' );"
1407 : "jQuery('#" . $params[ 'search_get_key' ] . "').val( jQuery('#" . $params[ 'search_get_key' ] . "_pseudo').val() ); jQuery('#". $params[ 'search_form_id' ] ."').trigger( 'submit' );" ) ,
1408
1409 'icon' => array(
1410 'icon_font' => 'wpbc_icn_search',
1411 'position' => 'left',
1412 'icon_img' => ''
1413 ),
1414 'class' => 'wpbc_ui_button _primary', // '' | 'wpbc_ui_button_primary'
1415 'style' => '', // Any CSS class here
1416 'mobile_show_text' => true, // Show or hide text, when viewing on Mobile devices (small window size).
1417 'attr' => array( 'id' => $el_id )
1418 );
1419
1420 wpbc_flex_button( $params_for_element );
1421
1422 ?></div><?php
1423
1424 ?></div><?php
1425
1426 ?></div><?php
1427
1428 ?></div><?php
1429
1430 }
1431
1432
1433
1434
1435 if ( ! $params['is_pseudo'] ) { ?>
1436 </form>
1437 <?php } ?>
1438 <?php wpbc_clear_div(); ?>
1439
1440 <?php
1441 if ( $params['is_pseudo'] ) {
1442 // Required for opening specific page NUM during saving ////////
1443 ?><input type="hidden" value="<?php
1444 // phpcs:ignore WordPress.Security.EscapeOutput.OutputNotEscaped
1445 echo $search_form_value; ?>" name="<?php echo esc_attr( $params[ 'search_get_key' ] ); ?>" /><?php
1446 ?><div class="clear" style="height:20px;"></div><?php
1447 }
1448 ?>
1449 </div>
1450 </span>
1451 <?php
1452
1453 if ( $params['is_pseudo'] ) {
1454
1455 // Hide pseudo form, if real search form does not exist
1456 ?>
1457 <script type="text/javascript">
1458 jQuery(document).ready(function(){
1459 if ( jQuery('#<?php echo esc_js( $params[ 'search_form_id' ] ); ?>').length == 0 ) {
1460 jQuery('#<?php echo esc_js( $params['search_form_id'] . '_pseudo' ); ?>').hide();
1461 }
1462 });
1463 </script>
1464 <?php
1465 }
1466 }
1467
1468
1469 // FixIn: 9.6.3.5.
1470
1471 // ---------------------------------------------------------------------------------------------------------------------
1472 // JS & CSS
1473 // ---------------------------------------------------------------------------------------------------------------------
1474
1475 /**
1476 * Load support JavaScript for "Bookings" page :: JS Tooltips, Popover, Datepicker
1477 */
1478 function wpbc_js_for_bookings_page() {
1479
1480 wpbc_bs_javascript_tooltips(); // JS Tooltips
1481 wpbc_bs_javascript_popover(); // JS Popover
1482 wpbc_datepicker_js(); // JS Datepicker
1483 wpbc_datepicker_css(); // CSS DatePicker
1484 }
1485
1486
1487 /** Datepicker activation JavaScript */
1488 function wpbc_datepicker_js() {
1489
1490 ?><script type="text/javascript">
1491 //jQuery(document).ready( function(){
1492 <?php
1493 // phpcs:ignore WordPress.Security.EscapeOutput.OutputNotEscaped
1494 echo wpbc_jq_ready_start();
1495 ?>
1496 if ( 'function' === typeof( jQuery('input.wpdevbk-filters-section-calendar').datepick ) ) {
1497 jQuery( 'input.wpdevbk-filters-section-calendar' ).datepick(
1498 {
1499 beforeShowDay : function ( date ) {
1500 return [true, 'date_available'];
1501 },
1502 showOn : 'focus',
1503 multiSelect : 0,
1504 numberOfMonths : 1,
1505 stepMonths : 1,
1506 prevText : '&lsaquo;',
1507 nextText : '&rsaquo;',
1508 dateFormat : 'yy-mm-dd',
1509 changeMonth : false,
1510 changeYear : false,
1511 minDate : null,
1512 maxDate : null, //'1Y',
1513 showStatus : false,
1514 multiSeparator : ', ',
1515 closeAtTop : null, //!false,
1516 firstDay :<?php echo intval(get_bk_option( 'booking_start_day_weeek' )); ?>,
1517 gotoCurrent : false,
1518 hideIfNoPrevNext: true,
1519 useThemeRoller : false,
1520 mandatory : true
1521 }
1522 );
1523 } else {
1524 console.log( 'WPBC Error. JavaScript library "datepick" was not defined.' );
1525 }
1526 <?php
1527 // phpcs:ignore WordPress.Security.EscapeOutput.OutputNotEscaped
1528 echo wpbc_jq_ready_end(); ?>
1529 //});
1530 </script><?php
1531 }
1532
1533
1534 /** Support CSS - datepick, etc... */
1535 function wpbc_datepicker_css(){
1536
1537 // FixIn: 9.7.3.4
1538 $width = 300;
1539 $height = 40;
1540 ?>
1541 <style type="text/css">
1542 #datepick-div {
1543 max-width: <?php echo intval( $width ); ?>px !important;
1544 width:100%;
1545 margin-top: 2px;
1546 background: #fff;
1547 }
1548 #datepick-div .datepick-days-cell {
1549 height: <?php echo intval( $height ); ?>px !important;
1550 }
1551 #datepick-div .datepick-control {
1552 display: none;
1553 font-size: 10px;
1554 text-align: center;
1555 }
1556 #datepick-div .datepick .datepick-days-cell a{
1557 font-size: 12px;
1558 }
1559 #datepick-div table.datepick tr td {
1560 padding: 0 !important;
1561 }
1562 #datepick-div .datepick-one-month {
1563 height: auto;
1564 }
1565 </style>
1566 <?php
1567 }
1568
1569
1570 /** Sortable Table JavaScript */
1571 function wpbc_sortable_js() {
1572 ?>
1573 <script type="text/javascript">
1574 // Activate Sortable Functionality
1575 jQuery( document ).ready(function(){
1576
1577 jQuery('.wpbc_input_table tbody th').css('cursor','move');
1578
1579 jQuery('.wpbc_input_table tbody td.sort').css('cursor','move');
1580
1581 jQuery('.wpbc_input_table.sortable tbody').sortable({
1582 items:'tr',
1583 cursor:'move',
1584 axis:'y',
1585 scrollSensitivity:40,
1586 forcePlaceholderSize: true,
1587 helper: 'clone',
1588 opacity: 0.65,
1589 placeholder: '.wpbc_sortable_table .sort',
1590 start:function(event,ui){
1591 ui.item.css('background-color','#f6f6f6');
1592 },
1593 stop:function(event,ui){
1594 ui.item.removeAttr('style');
1595 }
1596 });
1597 });
1598 </script>
1599 <?php
1600
1601 }