PluginProbe
Booking Calendar / 11.1
Booking Calendar v11.1
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 11.1, at core/admin/wpbc-toolbars.php

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