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 +112 -88 10.1111.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,81 +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 - // Toolbar ////////////////////////////////////////////////////////////////
28 -
29 - ?><div id="toolbar_booking_listing" class="wpbc_timeline_toolbar_container"><?php
30 -/*
31 - wpbc_bs_toolbar_tabs_html_container_start();
32 -
33 - // <editor-fold defaultstate="collapsed" desc=" T O P T A B s " >
34 -
35 - // phpcs:ignore WordPress.Security.NonceVerification.Recommended, WordPress.Security.NonceVerification.Missing
36 - if ( ! isset( $_REQUEST['tab_cvm'] ) ) $_REQUEST['tab_cvm'] = 'actions_cvm';
37 - $selected_tab = sanitize_text_field( wp_unslash( $_REQUEST['tab_cvm'] ) );
38 -
39 - wpbc_bs_display_tab( array(
40 - 'title' => __('View', 'booking')
41 - // , 'hint' => array( 'title' => __('Manage bookings' ,'booking') , 'position' => 'top' )
42 - , 'onclick' => "jQuery('.visibility_container').hide();"
43 - . "jQuery('#actions_toolbar_container').show();"
44 - . "jQuery('#toolbar_booking_listing .nav-tab').removeClass('nav-tab-active');" // FixIn: 9.8.15.2.
45 - . "jQuery(this).addClass('nav-tab-active');"
46 - . "jQuery('.nav-tab i.icon-white').removeClass('icon-white');"
47 - . "jQuery('.nav-tab-active i').addClass('icon-white');"
48 - , 'font_icon' => 'wpbc-bi-calendar2-range-fill'
49 - , 'default' => ( $selected_tab == 'actions_cvm' ) ? true : false
50 -
51 - ) );
52 -
53 -
54 - wpbc_bs_dropdown_menu_help();
55 -
56 - // </editor-fold>
57 -
58 - wpbc_bs_toolbar_tabs_html_container_end();
59 -*/
60 - ////////////////////////////////////////////////////////////////////////
61 -
62 - wpbc_bs_toolbar_sub_html_container_start();
63 -
64 - // A c t i o n s T o o l b a r f o r T i m e l i n e
65 -
66 -
67 - ?><div class="wpbc_timeline_toolbar_structure"><?php
68 -
69 - make_bk_action( 'wpbc_br_selection_for_timeline' );
70 -
71 - wpbc_toolbar_is_send_emails_btn( '');
72 -
73 - ?></div><?php
74 -
75 - wpbc_bs_toolbar_sub_html_container_end();
76 -
77 - ?></div><?php
78 -
79 30 wpbc_clear_div();
80 31
81 -}
82 -
83 -
84 -
85 -/** T o o l b a r C o n t a i n e r f o r Add New Booking */
86 -function wpbc_add_new_booking_toolbar() {
87 -
88 - wpbc_clear_div();
89 -
90 32 // Toolbar ////////////////////////////////////////////////////////////////
91 33
92 34 ?><div id="toolbar_booking_listing" style="position:relative;"><?php
93 35
@@ -147,21 +89,23 @@
147 89
148 90 wpbc_toolbar_btn__resource_selection();
149 91 }
150 92
151 - if ( function_exists( 'wpbc_toolbar_btn__form_selection' ) )
152 - wpbc_toolbar_btn__form_selection();
153 -
154 - ////////////////////////////////////////////////////////////////////
93 + WPBC_FE_Custom_Form_Helper::wpbc_bfb__custom_booking_forms_list__selectbox_html();
94 +
95 + ////////////////////////////////////////////////////////////////////
155 96 ?><div class="clear-for-mobile"></div><?php
156 97
157 98 ?><div class="control-group wpbc-no-padding" style="float:right;margin-right: 0;margin-left: 15px;"><?php
158 99
159 - if ( function_exists( 'wpbc_toolbar_btn__auto_fill' ) )
160 - wpbc_toolbar_btn__auto_fill();
100 + wpbc_toolbar_btn__add_past_booking( $args );
161 101
162 - wpbc_toolbar_btn__add_new_booking();
102 + if ( function_exists( 'wpbc_toolbar_btn__auto_fill' ) ) {
103 + wpbc_toolbar_btn__auto_fill();
104 + }
163 105
106 + wpbc_toolbar_btn__add_new_booking( $args );
107 +
164 108 ?></div><?php
165 109 ////////////////////////////////////////////////////////////////////
166 110
167 111 ?></div><?php
@@ -879,14 +823,81 @@
879 823 ><?php esc_html_e('Reset' , 'booking' ); ?></a><?php
880 824 ?></div><?php
881 825 }
882 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() ) {
883 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 +
884 889 /** Add New Booking Button*/
885 -function wpbc_toolbar_btn__add_new_booking() {
890 +function wpbc_toolbar_btn__add_new_booking( $args = array() ) {
886 891
887 - // phpcs:ignore WordPress.Security.NonceVerification.Recommended, WordPress.Security.NonceVerification.Missing
888 - 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
889 900 $bk_type = intval( $_GET['booking_type'] ); // phpcs:ignore WordPress.Security.NonceVerification.Recommended, WordPress.Security.NonceVerification.Missing
890 901 } else {
891 902 $bk_type = 1;
892 903 }
@@ -893,9 +904,9 @@
893 904
894 905 ?><a
895 906 class="button-primary button wpbc_submit_button"
896 907 href="javascript:void(0)"
897 - onclick="mybooking_submit(
908 + onclick="wpbc_booking_form_submit(
898 909 document.getElementById('booking_form<?php echo intval( $bk_type ); ?>' )
899 910 , <?php echo intval( $bk_type ); ?>
900 911 , '<?php echo esc_js( wpbc_get_maybe_reloaded_booking_locale() ); ?>'
901 912 );"
@@ -1485,14 +1496,12 @@
1485 1496
1486 1497
1487 1498 /** Datepicker activation JavaScript */
1488 1499 function wpbc_datepicker_js() {
1489 -
1490 - ?><script type="text/javascript">
1491 - //jQuery(document).ready( function(){
1500 + ?>
1501 + <script type="text/javascript">
1492 1502 <?php
1493 - // phpcs:ignore WordPress.Security.EscapeOutput.OutputNotEscaped
1494 - echo wpbc_jq_ready_start();
1503 + echo wpbc_jq_ready_start(); // phpcs:ignore WordPress.Security.EscapeOutput.OutputNotEscaped
1495 1504 ?>
1496 1505 if ( 'function' === typeof( jQuery('input.wpdevbk-filters-section-calendar').datepick ) ) {
1497 1506 jQuery( 'input.wpdevbk-filters-section-calendar' ).datepick(
1498 1507 {
@@ -1498,8 +1507,14 @@
1498 1507 {
1499 1508 beforeShowDay : function ( date ) {
1500 1509 return [true, 'date_available'];
1501 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 + },
1502 1517 showOn : 'focus',
1503 1518 multiSelect : 0,
1504 1519 numberOfMonths : 1,
1505 1520 stepMonths : 1,
@@ -1512,9 +1527,9 @@
1512 1527 maxDate : null, //'1Y',
1513 1528 showStatus : false,
1514 1529 multiSeparator : ', ',
1515 1530 closeAtTop : null, //!false,
1516 - firstDay :<?php echo intval(get_bk_option( 'booking_start_day_weeek' )); ?>,
1531 + firstDay : <?php echo intval( get_bk_option( 'booking_start_day_weeek' ) ); ?>,
1517 1532 gotoCurrent : false,
1518 1533 hideIfNoPrevNext: true,
1519 1534 useThemeRoller : false,
1520 1535 mandatory : true
@@ -1519,16 +1534,25 @@
1519 1534 useThemeRoller : false,
1520 1535 mandatory : true
1521 1536 }
1522 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 + }
1523 1547 } else {
1524 1548 console.log( 'WPBC Error. JavaScript library "datepick" was not defined.' );
1525 1549 }
1526 1550 <?php
1527 - // phpcs:ignore WordPress.Security.EscapeOutput.OutputNotEscaped
1528 - echo wpbc_jq_ready_end(); ?>
1529 - //});
1530 - </script><?php
1551 + echo wpbc_jq_ready_end(); // phpcs:ignore WordPress.Security.EscapeOutput.OutputNotEscaped
1552 + ?>
1553 + </script>
1554 + <?php
1531 1555 }
1532 1556
1533 1557
1534 1558 /** Support CSS - datepick, etc... */
@@ -1597,5 +1621,5 @@
1597 1621 });
1598 1622 </script>
1599 1623 <?php
1600 1624
1601 -}
1625 +}