PluginProbe
Booking Calendar / 11.8.3
Booking Calendar v11.8.3
11.8.3 11.8.2 11.8.1 11.8 11.7 11.6.1 11.6 11.5 11.4.3 11.4.2 11.4.1 11.4 11.3 11.2.1 11.2 11.1 11.0 10.15.7 10.15.6 10.1.3 10.10 10.10.1 10.10.2 10.11 10.11.2 All 203 releases
← All changes | core/admin/wpbc-toolbars.php +114 -198 10.1011.8.3 View file →
@@ -1,4 +1,4 @@
1 1 <?php /**
2 2 * @version 1.0
3 3 * @package Booking Calendar
4 4 * @category Toolbar. Data for UI Elements at Booking Calendar admin pages
@@ -13,104 +13,23 @@
13 13 if ( ! defined( 'ABSPATH' ) ) exit; // Exit, if accessed directly
14 14
15 15
16 16 // ---------------------------------------------------------------------------------------------------------------------
17 -// T o o l b a r s
17 +// == T o o l b a r s ==
18 18 // ---------------------------------------------------------------------------------------------------------------------
19 19
20 -// FixIn: 9.6.3.5.
21 20
22 -/** T o o l b a r C o n t a i n e r f o r Timeline */
23 -function wpbc_timeline_toolbar() {
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() ) {
24 23
25 - wpbc_clear_div();
24 + $defaults = array(
25 + 'resource_id' => null,
26 + 'booking_form' => null,
27 + );
28 + $args = wp_parse_args( $args, $defaults );
26 29
27 - //wpbc_toolbar_search_by_id_bookings(); // Search bookings by ID - form at the top right side of the page
28 -
29 - //wpbc_toolbar_btn__view_mode(); // Vertical Buttons // FixIn: 9.8.15.2.
30 -
31 - // Toolbar ////////////////////////////////////////////////////////////////
32 -
33 - ?><div id="toolbar_booking_listing" class="wpbc_timeline_toolbar_container"><?php
34 -/*
35 - wpbc_bs_toolbar_tabs_html_container_start();
36 -
37 - // <editor-fold defaultstate="collapsed" desc=" T O P T A B s " >
38 -
39 - // phpcs:ignore WordPress.Security.NonceVerification.Recommended, WordPress.Security.NonceVerification.Missing
40 - if ( ! isset( $_REQUEST['tab_cvm'] ) ) $_REQUEST['tab_cvm'] = 'actions_cvm';
41 - $selected_tab = sanitize_text_field( wp_unslash( $_REQUEST['tab_cvm'] ) );
42 -
43 - wpbc_bs_display_tab( array(
44 - 'title' => __('View', 'booking')
45 - // , 'hint' => array( 'title' => __('Manage bookings' ,'booking') , 'position' => 'top' )
46 - , 'onclick' => "jQuery('.visibility_container').hide();"
47 - . "jQuery('#actions_toolbar_container').show();"
48 - . "jQuery('#toolbar_booking_listing .nav-tab').removeClass('nav-tab-active');" // FixIn: 9.8.15.2.
49 - . "jQuery(this).addClass('nav-tab-active');"
50 - . "jQuery('.nav-tab i.icon-white').removeClass('icon-white');"
51 - . "jQuery('.nav-tab-active i').addClass('icon-white');"
52 - , 'font_icon' => 'wpbc-bi-calendar2-range-fill'
53 - , 'default' => ( $selected_tab == 'actions_cvm' ) ? true : false
54 -
55 - ) );
56 -
57 -
58 - wpbc_bs_dropdown_menu_help();
59 -
60 - // </editor-fold>
61 -
62 - wpbc_bs_toolbar_tabs_html_container_end();
63 -*/
64 - ////////////////////////////////////////////////////////////////////////
65 -
66 - wpbc_bs_toolbar_sub_html_container_start();
67 -
68 - // A c t i o n s T o o l b a r f o r T i m e l i n e
69 -
70 -
71 - ?><div class="wpbc_timeline_toolbar_structure"><?php
72 -
73 - make_bk_action( 'wpbc_br_selection_for_timeline' );
74 -
75 - wpbc_toolbar_is_send_emails_btn( '');
76 -
77 - ?></div><?php
78 -
79 - wpbc_bs_toolbar_sub_html_container_end();
80 -
81 - ?></div><?php
82 -
83 30 wpbc_clear_div();
84 31
85 -}
86 -
87 -/**
88 - * Show Search by Booking ID form at top right side of Calendar Overview page
89 - *
90 - * @param $page_tag
91 - * @param $active_page_tab
92 - * @param $active_page_subtab
93 - *
94 - * @return false|void
95 - */
96 -function wpbc_calendar_overview__search_by_id_bookings( $page_tag, $active_page_tab, $active_page_subtab ) {
97 -
98 - if ( ( 'wpbc' !== $page_tag ) || ( 'vm_calendar' !== $active_page_tab ) ) {
99 - return false;
100 - }
101 - ?><span class="wpdevelop wpbc_page wpbc_toolbar_search_by_id_bookings"><?php
102 - wpbc_toolbar_search_by_id_bookings(); // Search bookings by ID - form at the top right side of the page
103 - ?></span><?php
104 -}
105 -add_bk_action('wpbc_h1_header_content_end', 'wpbc_calendar_overview__search_by_id_bookings');
106 -
107 -
108 -/** T o o l b a r C o n t a i n e r f o r Add New Booking */
109 -function wpbc_add_new_booking_toolbar() {
110 -
111 - wpbc_clear_div();
112 -
113 32 // Toolbar ////////////////////////////////////////////////////////////////
114 33
115 34 ?><div id="toolbar_booking_listing" style="position:relative;"><?php
116 35
@@ -170,21 +89,23 @@
170 89
171 90 wpbc_toolbar_btn__resource_selection();
172 91 }
173 92
174 - if ( function_exists( 'wpbc_toolbar_btn__form_selection' ) )
175 - wpbc_toolbar_btn__form_selection();
176 -
177 - ////////////////////////////////////////////////////////////////////
93 + WPBC_FE_Custom_Form_Helper::wpbc_bfb__custom_booking_forms_list__selectbox_html();
94 +
95 + ////////////////////////////////////////////////////////////////////
178 96 ?><div class="clear-for-mobile"></div><?php
179 97
180 98 ?><div class="control-group wpbc-no-padding" style="float:right;margin-right: 0;margin-left: 15px;"><?php
181 99
182 - if ( function_exists( 'wpbc_toolbar_btn__auto_fill' ) )
183 - wpbc_toolbar_btn__auto_fill();
100 + wpbc_toolbar_btn__add_past_booking( $args );
184 101
185 - wpbc_toolbar_btn__add_new_booking();
102 + if ( function_exists( 'wpbc_toolbar_btn__auto_fill' ) ) {
103 + wpbc_toolbar_btn__auto_fill();
104 + }
186 105
106 + wpbc_toolbar_btn__add_new_booking( $args );
107 +
187 108 ?></div><?php
188 109 ////////////////////////////////////////////////////////////////////
189 110
190 111 ?></div><?php
@@ -305,47 +226,9 @@
305 226 ?></div><?php
306 227 }
307 228
308 229
309 -/** Search form by booking ID (at top right side of page) */
310 -function wpbc_toolbar_search_by_id_bookings() {
311 230
312 - $bk_admin_url = wpbc_get_params_in_url( wpbc_get_bookings_url( true, false ), array('view_mode', 'wh_booking_id', 'page_num' ) );
313 -
314 - ?>
315 - <div style=" position: absolute; right: 23px; top: 11px;z-index: 9;">
316 - <form name="booking_filters_formID" action="<?php echo esc_url( $bk_admin_url . '&view_mode=vm_listing' ); ?>" method="post" id="booking_filters_formID" >
317 - <?php
318 -
319 - // phpcs:ignore WordPress.Security.NonceVerification.Missing, WordPress.Security.NonceVerification.Recommended, WordPress.Security.ValidatedSanitizedInput.MissingUnslash, WordPress.Security.ValidatedSanitizedInput.InputNotSanitized
320 - if (isset($_REQUEST['wh_booking_id'])) $wh_booking_id = wpbc_clean_digit_or_csd( $_REQUEST['wh_booking_id'] ); // {'1', '2', .... }.
321 - else $wh_booking_id = '';
322 -
323 -
324 - $params = array( 'label_for' => 'wh_booking_id'
325 - , 'label' => ''//__('Keyword:', 'booking')
326 - , 'items' => array(
327 - array( 'type' => 'text', 'id' => 'wh_booking_id', 'value' => $wh_booking_id, 'placeholder' => __('Booking ID', 'booking'), 'style' => 'border-right: none;' )
328 - , array(
329 - 'type' => 'button'
330 - , 'title' => __('Go', 'booking')
331 - , 'class' => 'button-secondary'
332 - , 'font_icon' => 'wpbc_icn_search'
333 - , 'icon_position' => 'right'
334 - , 'action' => "jQuery('#booking_filters_formID').trigger( 'submit' );" )
335 - )
336 - );
337 - ?><div class="control-group wpbc-no-padding" ><?php
338 - wpbc_bs_input_group( $params );
339 - ?></div><?php
340 - ?>
341 - </form>
342 - <?php wpbc_clear_div(); ?>
343 - </div>
344 - <?php
345 -}
346 -
347 -
348 231 // ---------------------------------------------------------------------------------------------------------------------
349 232 // U I E l e m e n t s
350 233 // ---------------------------------------------------------------------------------------------------------------------
351 234
@@ -376,55 +259,8 @@
376 259 ) );
377 260 }
378 261
379 262
380 -/** View Mode - B u t t o n */
381 -function wpbc_toolbar_btn__view_mode() {
382 -
383 - // phpcs:ignore WordPress.Security.NonceVerification.Recommended
384 - $selected_view_mode = ( isset( $_REQUEST['view_mode'] ) ) ? sanitize_text_field( wp_unslash( $_REQUEST['view_mode'] ) ) : '';
385 -
386 - $bk_admin_url = wpbc_get_params_in_url( wpbc_get_bookings_url( false ), array('view_mode', 'wh_booking_id', 'page_num' ) );
387 -
388 - $params = array();
389 -
390 -
391 - // FixIn: 9.6.3.5.
392 - $is_selected = ( ( $selected_view_mode == 'vm_booking_listing' ) || ( $selected_view_mode == 'vm_listing' ) ) ? true : false;
393 -
394 - $params['btn_vm_listing_new'] = array(
395 - 'title' => ''
396 - , 'hint' => array( 'title' => __('Booking Listing' ,'booking') , 'position' => 'top' )
397 - , 'selected' => $is_selected
398 - , 'link' => wpbc_get_bookings_url('booking-listing', true ) . '&view_mode=vm_booking_listing'
399 - , 'icon' => ''
400 - , 'font_icon' => 'wpbc-bi-collection'//'glyphicon glyphicon-align-justify'
401 - );
402 -
403 -
404 - $bk_admin_url = wpbc_get_params_in_url( wpbc_get_bookings_url( false ) , array() // Exclude Value of this parameter
405 - , array( 'page', 'tab', 'tab_cvm', 'wh_booking_type', 'scroll_start_date', 'scroll_month', 'view_days_num'
406 - , 'wh_trash' // FixIn: 6.1.1.10.
407 - ) // Only this parameters
408 - );
409 - $params['btn_vm_calendar'] = array(
410 - 'title' => ''
411 - , 'hint' => array( 'title' => __('Timeline View' ,'booking') , 'position' => 'bottom' )
412 - , 'selected' => ( $selected_view_mode == 'vm_calendar' ) ? true : false
413 - , 'link' => $bk_admin_url . '&view_mode=vm_calendar'
414 - , 'icon' => ''
415 - , 'font_icon' => 'wpbc-bi-calendar2-range'// 'glyphicon glyphicon-calendar'
416 - );
417 -
418 - ?><div style="position:absolute;" class="wpbc_mode_switcher"><?php
419 -
420 - wpbc_bs_vertical_buttons_group( $params );
421 -
422 - ?></div><?php
423 -}
424 -
425 -// FixIn: 9.6.3.5.
426 -
427 263 // ---------------------------------------------------------------------------------------------------------------------
428 264 // Toolbar Actions B u t t o n s - T i m e l i n e //////////////////
429 265 // ---------------------------------------------------------------------------------------------------------------------
430 266
@@ -644,9 +480,9 @@
644 480 , 'value' => ''
645 481 )
646 482 )
647 483 , 'divider2' => 'divider'
648 - , 'buttons' => array( array( 'type' => 'group', 'class' => 'btn-group' ),
484 + , 'buttons' => array( array( 'type' => 'group', 'class' => 'btn-group0', 'style'=>'display: flex;flex-flow: row nowrap;align-items: center;justify-content: flex-end;' ),
649 485 array(
650 486 'type' => 'button'
651 487 , 'title' => __('Apply' ,'booking') // Title of the button
652 488 , 'hint' => '' // , 'hint' => array( 'title' => __('Select status' ,'booking') , 'position' => 'bottom' )
@@ -675,9 +511,9 @@
675 511 , 'class' => 'button-secondary' // button-secondary | button-primary
676 512 , 'icon' => ''
677 513 , 'font_icon' => ''
678 514 , 'icon_position' => 'left' // Position of icon relative to Text: left | right
679 - , 'style' => '' // Any CSS class here
515 + , 'style' => 'margin:0 10px;' // Any CSS class here
680 516 , 'mobile_show_text' => false // Show or hide text, when viewing on Mobile devices (small window size).
681 517 , 'attr' => array()
682 518 )
683 519 )
@@ -987,14 +823,81 @@
987 823 ><?php esc_html_e('Reset' , 'booking' ); ?></a><?php
988 824 ?></div><?php
989 825 }
990 826
827 +/**
828 + * Button for ability to add bookings in the past.
829 + *
830 + * @return void
831 + */
832 +function wpbc_toolbar_btn__add_past_booking( $args = array() ) {
991 833
834 + if ( isset( $_GET['allow_past'] ) ) { // phpcs:ignore WordPress.Security.NonceVerification.Recommended, WordPress.Security.NonceVerification.Missing
835 + return;
836 + }
837 +
838 + $defaults = array(
839 + 'resource_id' => null,
840 + 'booking_form' => null,
841 + );
842 + $args = wp_parse_args( $args, $defaults );
843 +
844 + $link = wpbc_get_new_booking_url();
845 +
846 + if ( null !== $args['resource_id'] ) {
847 + $link .= '&booking_type=' . absint( $args['resource_id'] );
848 + } else {
849 + $link .= ( ! empty( $_REQUEST['booking_type'] ) ) ? '&booking_type=' . intval( $_REQUEST['booking_type'] ) : ''; // phpcs:ignore WordPress.Security.NonceVerification.Recommended, WordPress.Security.NonceVerification.Missing
850 + }
851 +
852 + if ( null !== $args['booking_form'] ) {
853 + $link .= '&booking_form=' . sanitize_text_field( wp_unslash( (string) $args['booking_form'] ) );
854 + } else {
855 + $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
856 + }
857 +
858 + $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
859 + $link .= ( ! empty( $_REQUEST['is_show_payment_form'] ) ) ? '&is_show_payment_form=Off' : ''; // phpcs:ignore WordPress.Security.NonceVerification.Recommended, WordPress.Security.NonceVerification.Missing
860 + $link .= ( ! empty( $_REQUEST['parent_res'] ) ) ? '&parent_res=' . intval( $_REQUEST['parent_res'] ) : ''; // phpcs:ignore WordPress.Security.NonceVerification.Recommended, WordPress.Security.NonceVerification.Missing
861 +
862 + $el_id = 'is_allow_bookings_in_past';
863 + $el_value = 'Off';
864 +
865 + $params_checkbox = array(
866 + 'id' => $el_id // HTML ID of element
867 + , 'name' => $el_id
868 + , 'label' => array( 'title' => __( 'Allow booking in the past', 'booking' ) , 'position' => 'right' ) // FixIn: 9.6.1.5.
869 + , 'style' => '' // CSS of select element
870 + , 'class' => '' // CSS Class of select element
871 + , 'disabled' => false
872 + , 'attr' => array() // Any additional attributes, if this radio | checkbox element
873 + , 'legend' => '' // aria-label parameter
874 + , 'value' => $el_value // Some Value from optins array that selected by default
875 + , 'selected' => ( ( 'On' == $el_value ) ? true : false ) // Selected or not
876 + //, 'onfocus' => "console.log( 'ON FOCUS:', jQuery( this ).is(':checked') , 'in element:' , jQuery( this ) );" // JavaScript code
877 + , 'onchange' => "window.location.href='". $link . "&allow_past=1';" // JavaScript code
878 + , 'hint' => array( 'title' => __('Allow booking in the past' ,'booking') , 'position' => 'top' )
879 + );
880 +
881 + ?><div class="btn-group" style="display: inline-flex;min-height: 31px;flex-flow: row nowrap;align-items: center;"><?php
882 +
883 + wpbc_flex_toggle( $params_checkbox );
884 +
885 + ?></div><?php
886 +}
887 +
888 +
992 889 /** Add New Booking Button*/
993 -function wpbc_toolbar_btn__add_new_booking() {
890 +function wpbc_toolbar_btn__add_new_booking( $args = array() ) {
994 891
995 - // phpcs:ignore WordPress.Security.NonceVerification.Recommended, WordPress.Security.NonceVerification.Missing
996 - if ( isset( $_GET['booking_type'] ) ) {
892 + $defaults = array(
893 + 'resource_id' => null,
894 + );
895 + $args = wp_parse_args( $args, $defaults );
896 +
897 + if ( null !== $args['resource_id'] ) {
898 + $bk_type = absint( $args['resource_id'] );
899 + } elseif ( isset( $_GET['booking_type'] ) ) { // phpcs:ignore WordPress.Security.NonceVerification.Recommended, WordPress.Security.NonceVerification.Missing
997 900 $bk_type = intval( $_GET['booking_type'] ); // phpcs:ignore WordPress.Security.NonceVerification.Recommended, WordPress.Security.NonceVerification.Missing
998 901 } else {
999 902 $bk_type = 1;
1000 903 }
@@ -1001,9 +904,9 @@
1001 904
1002 905 ?><a
1003 906 class="button-primary button wpbc_submit_button"
1004 907 href="javascript:void(0)"
1005 - onclick="mybooking_submit(
908 + onclick="wpbc_booking_form_submit(
1006 909 document.getElementById('booking_form<?php echo intval( $bk_type ); ?>' )
1007 910 , <?php echo intval( $bk_type ); ?>
1008 911 , '<?php echo esc_js( wpbc_get_maybe_reloaded_booking_locale() ); ?>'
1009 912 );"
@@ -1593,14 +1496,12 @@
1593 1496
1594 1497
1595 1498 /** Datepicker activation JavaScript */
1596 1499 function wpbc_datepicker_js() {
1597 -
1598 - ?><script type="text/javascript">
1599 - //jQuery(document).ready( function(){
1500 + ?>
1501 + <script type="text/javascript">
1600 1502 <?php
1601 - // phpcs:ignore WordPress.Security.EscapeOutput.OutputNotEscaped
1602 - echo wpbc_jq_ready_start();
1503 + echo wpbc_jq_ready_start(); // phpcs:ignore WordPress.Security.EscapeOutput.OutputNotEscaped
1603 1504 ?>
1604 1505 if ( 'function' === typeof( jQuery('input.wpdevbk-filters-section-calendar').datepick ) ) {
1605 1506 jQuery( 'input.wpdevbk-filters-section-calendar' ).datepick(
1606 1507 {
@@ -1606,8 +1507,14 @@
1606 1507 {
1607 1508 beforeShowDay : function ( date ) {
1608 1509 return [true, 'date_available'];
1609 1510 },
1511 + onSelect : function ( string_dates, js_dates_arr ){ /**
1512 + * string_dates = '23.08.2023 - 26.08.2023' | '23.08.2023 - 23.08.2023' | '19.09.2023, 24.08.2023, 30.09.2023'
1513 + * 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) ]
1514 + */
1515 + return wpbc_filters_section_calendar_selected_day( string_dates, {}, this );
1516 + },
1610 1517 showOn : 'focus',
1611 1518 multiSelect : 0,
1612 1519 numberOfMonths : 1,
1613 1520 stepMonths : 1,
@@ -1620,9 +1527,9 @@
1620 1527 maxDate : null, //'1Y',
1621 1528 showStatus : false,
1622 1529 multiSeparator : ', ',
1623 1530 closeAtTop : null, //!false,
1624 - firstDay :<?php echo intval(get_bk_option( 'booking_start_day_weeek' )); ?>,
1531 + firstDay : <?php echo intval( get_bk_option( 'booking_start_day_weeek' ) ); ?>,
1625 1532 gotoCurrent : false,
1626 1533 hideIfNoPrevNext: true,
1627 1534 useThemeRoller : false,
1628 1535 mandatory : true
@@ -1627,16 +1534,25 @@
1627 1534 useThemeRoller : false,
1628 1535 mandatory : true
1629 1536 }
1630 1537 );
1538 + function wpbc_filters_section_calendar_selected_day( string_dates, params_arr, _this ) {
1539 + // FixIn: 10.11.4.2.
1540 + if ( 'ui_wh_booking_date_checkin' === jQuery( _this ).attr( 'id' ) ) {
1541 + setTimeout( function () {
1542 + jQuery( '#ui_wh_booking_date_checkout' ).val( string_dates );
1543 + jQuery( '#ui_wh_booking_date_checkout' ).trigger( 'focus' );
1544 + }, 100 );
1545 + }
1546 + }
1631 1547 } else {
1632 1548 console.log( 'WPBC Error. JavaScript library "datepick" was not defined.' );
1633 1549 }
1634 1550 <?php
1635 - // phpcs:ignore WordPress.Security.EscapeOutput.OutputNotEscaped
1636 - echo wpbc_jq_ready_end(); ?>
1637 - //});
1638 - </script><?php
1551 + echo wpbc_jq_ready_end(); // phpcs:ignore WordPress.Security.EscapeOutput.OutputNotEscaped
1552 + ?>
1553 + </script>
1554 + <?php
1639 1555 }
1640 1556
1641 1557
1642 1558 /** Support CSS - datepick, etc... */
@@ -1705,5 +1621,5 @@
1705 1621 });
1706 1622 </script>
1707 1623 <?php
1708 1624
1709 -}
1625 +}