PluginProbe
Booking Calendar / 10.11.3
Booking Calendar v10.11.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 / core / admin / wpbc-toolbars.php

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

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