PluginProbe
Booking Calendar / 11.1
Booking Calendar v11.1
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 / includes / ui_settings / parts / ui__timeline_toolbar.php

ui__timeline_toolbar.php in Booking Calendar 11.1, at includes/ui_settings/parts/ui__timeline_toolbar.php

270 lines 10.9 KB
No matching file
Up and down to move Enter to open Esc to close
Raw Download Zip
1 <?php
2 /**
3 * Admin Panel UI - Timeline Toolbar
4 *
5 * @version 1.0
6 * @package Any
7 * @category Page Structure in Admin Panel
8 * @author wpdevelop
9 *
10 * @web-site https://wpbookingcalendar.com/
11 * @email info@wpbookingcalendar.com
12 *
13 * @modified 2025-03-22
14 */
15
16 if ( ! defined( 'ABSPATH' ) ) {
17 exit; // Exit, if accessed directly.
18 }
19
20
21 /**
22 * Show "Send Emails" toggle at the right side of Top Horizontal Navigation Bar
23 *
24 * @param string $active_page_tag - such as 'wpbc'.
25 * @param string $active_tab_tab - such as 'vm_calendar'.
26 *
27 * @return void
28 */
29 function wpbc_timeline_toolbar_show_send_emails_btn( $active_page_tag, $active_tab_tab ) {
30
31 if ( ( 'wpbc' === $active_page_tag ) && ( 'vm_calendar' === $active_tab_tab ) ) {
32
33 ?>
34 <div class="wpbc_ajx_toolbar wpbc_no_borders wpbc_not_toolbar_is_send_emails" style="margin-left: auto;">
35 <div class="ui_container ui_container_micro">
36 <div class="ui_group">
37 <div class="ui_element">
38 <?php
39 wpbc_timeline__is_send_emails_toggle();
40 // wpbc_toolbar_is_send_emails_btn('');
41 ?>
42 </div>
43 </div>
44 </div>
45 </div>
46 <?php
47 }
48 }
49 add_action( 'hook__wpbc_ui__top_horisontal_nav__end', 'wpbc_timeline_toolbar_show_send_emails_btn', 10, 2 );
50
51
52 /**
53 * Toggle "Emails Sending".
54 *
55 * @return void
56 */
57 function wpbc_timeline__is_send_emails_toggle(){
58
59 $el_id = 'is_send_email_for_pending';
60
61 $el_value = ( get_bk_option( 'booking_send_emails_off_addbooking' ) !== 'On' ) ? 'On' : 'Off';
62
63 $params_checkbox = array(
64 'id' => $el_id // HTML ID of element
65 , 'name' => $el_id
66 , 'label' => array( 'title' => __( 'Emails sending', 'booking' ) , 'position' => 'right' ) // FixIn: 9.6.1.5.
67 , 'style' => '' // CSS of select element
68 , 'class' => '' // CSS Class of select element
69 , 'disabled' => false
70 , 'attr' => array() // Any additional attributes, if this radio | checkbox element
71 , 'legend' => '' // aria-label parameter
72 , 'value' => $el_value // Some Value from optins array that selected by default
73 , 'selected' => ( ( 'On' == $el_value ) ? true : false ) // Selected or not
74 //, 'onfocus' => "console.log( 'ON FOCUS:', jQuery( this ).is(':checked') , 'in element:' , jQuery( this ) );" // JavaScript code
75 //, 'onchange' => "wpbc_ajx_booking_send_search_request_with_params( {'ui_usr__send_emails': (jQuery( this ).is(':checked') ? 'send' : 'not_send') } );" // JavaScript code
76 , 'hint' => array( 'title' => __('Send email notification to customer about this operation' ,'booking') , 'position' => 'top' )
77 );
78
79 wpbc_flex_toggle( $params_checkbox );
80 }
81
82 /**
83 * Show Resource selection choosen in Timeline View.
84 *
85 * @return void
86 */
87 function wpbc_ui__timeline__resource_selection() {
88
89 if ( ! class_exists( 'wpdev_bk_personal' ) ) {
90 return;
91 }
92
93 wpbc_ui__choosen__resource_selection();
94
95 $bk_admin_url = wpbc_get_params_in_url( wpbc_get_bookings_url( false ), array( 'wh_booking_type' ) );
96 $bk_admin_url .= '&wh_booking_type=';
97
98 ?>
99 <script type="text/javascript">
100 function wpbc_timeline_view__choozen__remove_all_options(selectbox_id) {
101 jQuery( selectbox_id + ' option' ).removeAttr( 'selected' ); // Disable selection in the real selectbox.
102 jQuery( selectbox_id ).trigger( 'chosen:updated' ); // Remove all fields from the Choozen field // FixIn: 8.7.9.9.
103 }
104 function wpbc_timeline_view__reload_page__for_selected_resources() {
105 var resource_value = jQuery( '#wh_booking_type' ).val();
106 if ( resource_value == null ) {
107 resource_value = jQuery( "#wh_booking_type option:first" ).val();
108 }
109 if ( resource_value == null ) {
110 resource_value = '';
111 }
112 // FixIn: 7.2.1.18 - Fix "Request-URI Too Long" fatal error.
113 if ( resource_value instanceof Array ) {
114 jQuery.each( resource_value, function (r_index, r_value) {
115 r_value = String( r_value );
116 if ( r_value.length > 200 ) {
117 resource_value[r_index] = '';
118 }
119 } );
120 }
121 window.location.assign( "<?php echo $bk_admin_url; /* phpcs:ignore WordPress.Security.EscapeOutput.OutputNotEscaped */ ?>" + resource_value );
122 }
123 </script>
124 <?php
125 }
126
127
128 /**
129 * Get data for Resource Selection elemnt - [C H O O S E N]
130 *
131 * @return void
132 */
133 function wpbc_ui__choosen__resource_selection() {
134
135 $resources_arr = wpbc_get_br_as_objects();
136
137 $all_ids = array();
138 foreach ( $resources_arr as $resource_obj ) {
139 $all_ids[] = $resource_obj->id;
140 }
141
142 $selector_arr = array();
143 if ( count( $all_ids ) > 1 ) {
144 $selector_arr[ __( 'All resources', 'booking' ) ] = implode( ',', $all_ids );
145 }
146
147 foreach ( $resources_arr as $resource_obj ) {
148
149 $resource_title = $resource_obj->title;
150
151 if ( ( isset( $resource_obj->parent ) ) && ( intval( $resource_obj->parent ) !== 0 ) ) {
152 $resource_title = '&nbsp;&nbsp;&nbsp;' . $resource_title;
153 }
154
155 $selector_arr[ $resource_title ] = $resource_obj->id;
156 }
157
158
159 $selector_id = 'wh_booking_type';
160 $text_empty_selection = __( 'Booking resources', 'booking' );
161 wpbc_ui__choosen( $selector_id, $selector_arr, $text_empty_selection );
162 }
163
164
165 /**
166 * R e s o u r c e s S e l e c t o r [C H O O S E N].
167 *
168 * @param string $selector_id - 'wh_booking_type' - HTML ID of element.
169 * @param array $selector_arr - array( 'Title' => Value ).
170 * @param string $text_empty_selection - 'Booking resources'.
171 */
172 function wpbc_ui__choosen( $selector_id, $selector_arr, $text_empty_selection ) {
173
174 $wpdevbk_value = '';
175 $wpdevbk_value_array = array();
176
177 if ( isset( $_REQUEST[ $selector_id ] ) ) { // phpcs:ignore WordPress.Security.NonceVerification.Recommended, WordPress.Security.NonceVerification.Missing
178 $wpdevbk_value = sanitize_text_field( wp_unslash( $_REQUEST[ $selector_id ] ) ); // phpcs:ignore WordPress.Security.NonceVerification.Recommended, WordPress.Security.NonceVerification.Missing
179
180 if ( strpos( $wpdevbk_value, ',' ) !== false ) {
181 $wpdevbk_value_array = explode( ',', $wpdevbk_value );
182 }
183 }
184
185 $wpdevbk_selector_default = array_search( $wpdevbk_value, $selector_arr, true );
186 if ( false === $wpdevbk_selector_default ) {
187 $wpdevbk_selector_default = current( $selector_arr );
188 }
189
190 ?>
191 <div class="wpbc_ui_el wpbc_ui_el__choosen wpbc_ui_el__choosen_<?php echo esc_attr( $selector_id ); ?>">
192 <select multiple="multiple" class="chzn-select wpbc_ui_el__choosen_select" style="display:none;"
193 id="<?php echo esc_attr( $selector_id ); ?>"
194 name="<?php echo esc_attr( $selector_id ); ?>[]"
195 data-placeholder="<?php echo esc_attr( $text_empty_selection ); ?>">
196 <?php
197 $is_all_resources_selected = false;
198 foreach ( $selector_arr as $key => $value ) {
199 if ( 'divider' !== $value ) {
200 $is_in_array = in_array( $value, $wpdevbk_value_array, true );
201 ?>
202 <option <?php
203 if ( ( ( $wpdevbk_value === $value ) || ( $is_in_array ) ) && ( ! $is_all_resources_selected ) ) {
204 echo ' selected="SELECTED" ';
205 if ( strpos( $value, ',' ) !== false ) {
206 $is_all_resources_selected = true;
207 }
208 }
209 if ( ( strpos( $key, '&nbsp;' ) === false ) || ( __( 'All resources', 'booking' ) === $key ) ) {
210 echo ' style="font-weight:600;" ';
211 }
212 ?>
213 value="<?php echo esc_attr( $value ); ?>"
214 title="<?php echo esc_attr( $key ); ?>"><?php
215 echo esc_html( substr( $key, 0, 80 ) . ( ( strlen( $key ) > 80 ) ? '...' : '' ) ); // FixIn: 9.1.2.3.
216 ?></option><?php
217 }
218 }
219 ?>
220 </select>
221 <div class="wpbc_ui_el__choosen_reset_buttons">
222 <input type="hidden" name="blank_field__this_field_only_for_formatting_buttons" value="">
223 <a data-original-title="<?php esc_attr_e( 'Clear booking resources selection', 'booking' ); ?>"
224 rel="tooltip"
225 class="tooltip_top my_class4"
226 onclick="javascript:wpbc_timeline_view__choozen__remove_all_options('#<?php echo esc_attr( $selector_id ); ?>');"
227 ><i class="wpbc_icn_close"></i></a>
228 <a data-original-title="<?php esc_attr_e( 'Apply booking resources selection', 'booking' ); ?>"
229 rel="tooltip"
230 class="tooltip_top my_class5"
231 onclick="javascript:wpbc_timeline_view__reload_page__for_selected_resources();"
232 ><i class="wpbc_icn_refresh"></i></a>
233 </div>
234 </div>
235 <script type="text/javascript">
236 <?php
237 echo wpbc_jq_ready_start(); // phpcs:ignore WordPress.Security.EscapeOutput.OutputNotEscaped
238 ?>
239 if ( 'function' === typeof( jQuery("#<?php echo esc_attr( $selector_id ); ?>").chosen ) ) {
240
241 jQuery( "#<?php echo esc_attr( $selector_id ); ?>" ).chosen( { no_results_text: "No results matched" } );
242 if ( jQuery( '#<?php echo esc_attr( $selector_id ); ?>_chosen' ).length ) {
243 jQuery( '.wpbc_ui_el__choosen_<?php echo esc_attr( $selector_id ); ?> .wpbc_ui_el__choosen_reset_buttons').css('display','flex');
244 jQuery( "#<?php echo esc_attr( $selector_id ); ?>_chosen" ).attr( "tabindex", "0" );
245 }
246 // Catch any selections in the Choozen.
247 jQuery( "#<?php echo esc_attr( $selector_id ); ?>" ).chosen().on( 'change', function (va) {
248 if ( jQuery( "#<?php echo esc_attr( $selector_id ); ?>" ).val() != null ) {
249 // So we are having aready values.
250 jQuery.each( jQuery( "#<?php echo esc_attr( $selector_id ); ?>" ).val(), function (index, value) {
251 if ( value.indexOf( ',' ) > 0 ) { // Ok we are have array with all booking resources ID.
252 jQuery( '#<?php echo esc_attr( $selector_id ); ?>' + ' option' ).removeAttr( 'selected' ); // Disable selection in the real selectbox.
253 jQuery( '#<?php echo esc_attr( $selector_id ); ?>' + ' option:first-child' ).prop( "selected", true ); // Disable selection in the real selectbox.
254 jQuery( '#<?php echo esc_attr( $selector_id ); ?>' ).trigger( 'liszt:updated' ); // Update all fields from the Choozen field.
255 var my_message = '<?php echo esc_js( __( 'Please note, its not possible to add new resources, if "All resources" option is selected. Please clear the selection, then add new resources.', 'booking' ) ); ?>';
256 wpbc_admin_show_message( my_message, 'warning', 10000 );
257 }
258 } );
259 }
260 } );
261 } else {
262 alert( 'WPBC Error. JavaScript library "chosen" was not defined.' );
263 }
264 <?php
265 echo wpbc_jq_ready_end(); // phpcs:ignore WordPress.Security.EscapeOutput.OutputNotEscaped
266 ?>
267 </script>
268 <?php
269 }
270