PluginProbe
Booking Calendar / 10.15.7
Booking Calendar v10.15.7
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.15.7, at core/admin/wpbc-toolbars.php

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