PluginProbe
Booking Calendar / 11.9
Booking Calendar v11.9
11.9 11.8.4 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 All 205 releases
← All changes | includes/page-bookings/bookings__listing.php +131 -442 10.10 → 11.9 View file →
@@ -1,4 +1,4 @@
1 1 <?php /**
2 2 * @version 1.0
3 3 * @description AJX_Bookings
4 4 * @category AJX_Bookings Class
@@ -9,469 +9,154 @@
9 9 *
10 10 * @modified 2020-01-23
11 11 */
12 12
13 -if ( ! defined( 'ABSPATH' ) ) exit; // Exit if accessed directly
13 +if ( ! defined( 'ABSPATH' ) ) {
14 + exit; // Exit if accessed directly.
15 +}
14 16
15 17 class WPBC_AJX_Bookings {
16 18
17 - /* Static Variables */
18 - static $data_separator = array(
19 - 'r_separator' => '~'
20 - , 'f_separator' => '^'
21 - );
19 + /**
20 + * Static Variables
21 + *
22 + * @var string[]
23 + */
24 + public static $data_separator = array(
25 + 'r_separator' => '~',
26 + 'f_separator' => '^',
27 + );
22 28
23 29
24 30 // <editor-fold defaultstate="collapsed" desc=" /// JS | CSS files | Tpl loading /// " >
25 31
26 - // JS | CSS ===================================================================================================
32 + // JS | CSS =======================================================================================================.
27 33
28 - /**
29 - * Define HOOKs for loading CSS and JavaScript files
30 - */
31 - public function init_load_css_js_tpl() {
32 - // JS & CSS
34 + /**
35 + * Define HOOKs for loading CSS and JavaScript files
36 + */
37 + public function init_load_css_js_tpl() {
33 38
34 - // Load only at AJX_Bookings Settings Page
35 - if ( 'vm_booking_listing' == wpbc_ajx_booking_listing__get_default_view_mode() ) {
36 - //if ( strpos( $_SERVER['REQUEST_URI'], 'view_mode=vm_booking_listing' ) !== false ) {
39 + add_action( 'wpbc_enqueue_js_files', array( $this, 'js_load_files' ), 50 );
40 + add_action( 'wpbc_enqueue_css_files', array( $this, 'enqueue_css_files' ), 50 );
37 41
38 - add_action( 'wpbc_enqueue_js_files', array( $this, 'js_load_files' ), 50 );
39 - add_action( 'wpbc_enqueue_css_files', array( $this, 'enqueue_css_files' ), 50 );
42 + add_action( 'wpbc_hook_settings_page_footer', array( $this, 'hook__page_footer_tmpl' ) );
43 + }
40 44
41 - add_action( 'wpbc_hook_settings_page_footer', array( $this, 'hook__page_footer_tmpl' ) );
42 - }
43 - }
44 45
45 - /** JSS */
46 - public function js_load_files( $where_to_load ) {
46 + /**
47 + * JSS.
48 + *
49 + * @param string $where_to_load - slug.
50 + *
51 + * @return void
52 + */
53 + public function js_load_files( $where_to_load ) {
47 54
48 - $in_footer = true;
55 + if ( ! is_admin() || ! wpbc_is_bookings_page() ) {
56 + return;
57 + }
49 58
50 - if ( ( is_admin() ) && ( in_array( $where_to_load, array( 'admin', 'both' ) ) ) ) {
59 + if ( ( is_admin() ) && ( in_array( $where_to_load, array( 'admin', 'both' ), true ) ) ) {
60 + self::enqueue_js_files_now();
61 + }
62 + }
51 63
52 - //wp_enqueue_script( 'wpbc-live_search', wpbc_plugin_url( '/_out/js/live_search.js' ), array( 'wpbc_all' ), WP_BK_VERSION_NUM, $in_footer );
53 - wp_enqueue_script( 'wpbc-booking_ajx_toolbar_hooks'
54 - , trailingslashit( plugins_url( '', __FILE__ ) ) . '_out/bookings__hooks.js' /* wpbc_plugin_url( '/_out/js/code_mirror.js' ) */
55 - , array( 'wpbc_all' ), WP_BK_VERSION_NUM, $in_footer );
64 + /**
65 + * Enqueue AJAX booking listing scripts.
66 + *
67 + * The Booking Listing page prints inline initialization in its content. In Free, the saved default view can differ
68 + * from the current tab, so this method is also called directly from the page content as a last-mile guarantee.
69 + *
70 + * @return void
71 + */
72 + public static function enqueue_js_files_now() {
56 73
57 - wp_enqueue_script( 'wpbc-booking_ajx_listing'
58 - , trailingslashit( plugins_url( '', __FILE__ ) ) . '_out/bookings__listing.js' /* wpbc_plugin_url( '/_out/js/code_mirror.js' ) */
59 - , array( 'wpbc_all' ), WP_BK_VERSION_NUM, $in_footer );
74 + $in_footer = true;
60 75
61 - wp_enqueue_script( 'wpbc-booking_ajx_actions'
62 - , trailingslashit( plugins_url( '', __FILE__ ) ) . '_out/bookings__actions.js' /* wpbc_plugin_url( '/_out/js/code_mirror.js' ) */
63 - , array( 'wpbc_all' ), WP_BK_VERSION_NUM, $in_footer );
76 + wp_enqueue_script( 'wpbc-booking_ajx_listing', trailingslashit( plugins_url( '', __FILE__ ) ) . '_out/bookings__listing.js', array( 'wpbc_all', 'wp-util' ), WP_BK_VERSION_NUM, $in_footer );
77 + wp_enqueue_script( 'wpbc-booking_ajx_toolbar_hooks', trailingslashit( plugins_url( '', __FILE__ ) ) . '_out/bookings__hooks.js', array( 'wpbc-booking_ajx_listing', 'wpbc-ui-chosen-filter' ), WP_BK_VERSION_NUM, $in_footer );
78 + wp_enqueue_script( 'wpbc-booking_ajx_actions', trailingslashit( plugins_url( '', __FILE__ ) ) . '_out/bookings__actions.js', array( 'wpbc-booking_ajx_listing' ), WP_BK_VERSION_NUM, $in_footer );
79 + wp_enqueue_script( 'wpbc-boo_listing_ajx_actions', trailingslashit( plugins_url( '', __FILE__ ) ) . '_out/boo_listing__actions.js', array( 'wpbc-booking_ajx_listing' ), WP_BK_VERSION_NUM, $in_footer );
80 + }
64 81
65 - wp_enqueue_script( 'wpbc-general_ui_js_css'
66 - , wpbc_plugin_url( '/includes/_general_ui_js_css/_out/wpbc_main_ui_funcs.js' )
67 - , array( 'wpbc_all' ), WP_BK_VERSION_NUM, $in_footer );
68 82
69 - /**
70 - wp_localize_script( 'wpbc_all', 'wpbc_live_request_obj'
71 - , array(
72 - 'ajx_booking' => '',
73 - 'reminders' => ''
74 - )
75 - );
76 - */
77 - }
78 - }
83 + /**
84 + * CSS
85 + *
86 + * @param string $where_to_load - slug.
87 + *
88 + * @return void
89 + */
90 + public function enqueue_css_files( $where_to_load ) {
91 + }
79 92
80 - /** CSS */
81 - public function enqueue_css_files( $where_to_load ) {
82 -
83 - if ( ( is_admin() ) && ( in_array( $where_to_load, array( 'admin', 'both' ) ) ) ) {
84 -
85 - //wp_enqueue_style( 'wpbc-ajx_booking-listing', wpbc_plugin_url( '/includes/listing_ajx_booking/o-ajx_booking-listing.css' ), array(), WP_BK_VERSION_NUM );
86 - //wp_enqueue_style( 'wpbc-listing_ajx_booking', trailingslashit( plugins_url( '', __FILE__ ) ) . '_out/bookings__listing.css' , array(), WP_BK_VERSION_NUM );
87 -
88 - }
89 - }
90 -
91 93 // </editor-fold>
92 94
93 95
94 96 // <editor-fold defaultstate="collapsed" desc=" /// Templates /// " >
95 97
96 - // Templates ===================================================================================================
98 + // Templates ===================================================================================================
97 99
98 - /**
99 - * Templates at footer of page
100 - *
101 - * @param $page string
102 - */
103 - public function hook__page_footer_tmpl( $page ){
100 + /**
101 + * Templates at footer of page
102 + *
103 + * @param string $page - 'wpbc-ajx_booking'.
104 + */
105 + public function hook__page_footer_tmpl( $page ) {
104 106
105 - // page=wpbc&view_mode=vm_booking_listing
106 - if ( 'wpbc-ajx_booking' === $page ) { // it's from >> do_action( 'wpbc_hook_settings_page_footer', 'wpbc-ajx_booking' );
107 - $this->template__listing_header();
108 - $this->template__listing_row();
109 - $this->template__content_data();
110 - }
111 - }
107 + if ( 'wpbc-ajx_booking' === $page ) { // it's from >> do_action( 'wpbc_hook_settings_page_footer', 'wpbc-ajx_booking' );.
112 108
109 + wpbc_template__booking_listing_header();
110 + wpbc_template__booking_listing_footer();
111 + wpbc_template__booking_listing_row();
113 112
114 - private function template__listing_header() {
115 -
116 - // Header
117 - ?><script type="text/html" id="tmpl-wpbc_ajx_booking_list_header">
118 - <div class="wpbc_listing_usual_row wpbc_list_header wpbc_selectable_head">
119 - <div class="wpbc_listing_col wpbc_col_id check-column"><div class="content_text"><input type="checkbox" /></div></div>
120 - <div class="wpbc_listing_col wpbc_col_booking_labels wpbc_col_labels"><div class="content_text"><?php echo esc_js( __( 'Labels', 'booking' ) . ' / ' . __('Actions' ,'booking' ) ); ?></div></div>
121 - <div class="wpbc_listing_col wpbc_col_data"><div class="content_text"><?php echo esc_js( __( 'Booking Data', 'booking' ) ); ?></div></div>
122 - <div class="wpbc_listing_col wpbc_col_dates"><div class="content_text"><?php echo esc_js( __( 'Booking Dates', 'booking' ) ); ?>
123 - <span class="wpbc_listing_header_action_icon">
124 - <a id="booking_dates_full"
125 - onclick="javascript:wpbc_ajx_click_on_dates_wide();" href="javascript:void(0)"
126 - title="<?php echo esc_attr( __('Show ALL dates of booking' ,'booking') ); ?>"
127 - style="<# if ( 'wide' === wpbc_ajx_booking_listing.search_get_param('ui_usr__dates_short_wide') ) { #>display: none;<# } #>"
128 - class="tooltip_top"
129 - ><i class="wpbc_icn_swap_horiz" style=" margin-top: 2px;"></i></a>
130 - <a id="booking_dates_small"
131 - onclick="javascript:wpbc_ajx_click_on_dates_short();" href="javascript:void(0)"
132 - title="<?php echo esc_attr( __('Show only check in/out dates' ,'booking') ); ?>"
133 - style="<# if ( 'short' === wpbc_ajx_booking_listing.search_get_param('ui_usr__dates_short_wide') ) { #>display: none;<# } #>"
134 - class="tooltip_top"
135 - ><i class="wpbc_icn_compare_arrows" style=" margin-top: 2px;"></i></a>
136 - </span>
137 - </div></div>
138 - </div>
139 - </script><?php
113 + $this->template__content_data();
140 114 }
115 + }
141 116
117 + private function template__content_data(){
142 118
143 - private function template__listing_row() {
144 -
145 - /**
146 - * data objet = { "booking_db": {
147 - "booking_id": "3",
148 - "trash": "0",
149 - "sync_gid": "",
150 - "is_new": "0",
151 - "status": "",
152 - "sort_date": "2022-02-03 12:00:01",
153 - "modification_date": "2022-03-14 17:48:23",
154 - "form": "selectbox-one^rangetime2^12:00 - 14:00~text^name2^Anthony~text^secondname2^Gomez~text^email2^[email protected]~text^address2^144 Hitchcock Rd~text^city2^Jacksonville~text^postcode2^38374~text^country2^US~text^phone2^988-48-45~selectbox-one^visitors2^3~checkbox^children2[]^2~textarea^details2^",
155 - "hash": "993086af7a382f3956e6a0010932c856",
156 - "booking_type": "2",
157 - "remark": null,
158 - "cost": "58.00",
159 - "pay_status": "",
160 - "pay_request": "0"
161 - },
162 - "id": "3",
163 - "approved": "0",
164 - "dates": [ "2022-02-03 12:00:01", "2022-02-03 14:00:02" ],
165 - "child_id": [ "", "" ],
166 - "short_dates": [ "2022-02-03 12:00:01", "-", "2022-02-03 14:00:02" ],
167 - "short_dates_child_id": [ "", "", "" ],
168 - "parsed_fields": {
169 - "rangetime": "12:00 PM - 2:00 PM",
170 - "name": "Anthony",
171 - "secondname": "Gomez",
172 - "email": "[email protected]",
173 - "address": "144 Hitchcock Rd",
174 - "city": "Jacksonville",
175 - "postcode": "38374",
176 - "country": "US",
177 - "phone": "988-48-45",
178 - "visitors": "3",
179 - "children": "2",
180 - "details": "",
181 - "booking_id": "3",
182 - "trash": "0",
183 - "sync_gid": "",
184 - "is_new": "0",
185 - "status": "",
186 - "sort_date": "2022-02-03 12:00:01",
187 - "modification_date": "March 14, 2022 5:48 PM",
188 - "hash": "993086af7a382f3956e6a0010932c856",
189 - "booking_type": "2",
190 - "cost": "58.00",
191 - "pay_status": "",
192 - "pay_request": "0",
193 - "id": "3",
194 - "approved": "0"
195 - },
196 - "templates": {
197 - "form_show": "<div class=\"standard-content-form\"> \r\n\t<strong>First Name</strong>:<span class=\"fieldvalue\">Anthony</span>&nbsp;&nbsp; \r\n\t<strong>Last Name</strong>:<span class=\"fieldvalue\">Gomez</span>&nbsp;&nbsp; \r\n\t<strong>Email</strong>:<span class=\"fieldvalue\">[email protected]</span>&nbsp;&nbsp; \r\n\t<strong>Adults</strong>:<span class=\"fieldvalue\"> 3</span>&nbsp;&nbsp; \r\n\t<strong>Children</strong>:<span class=\"fieldvalue\"> 2</span>&nbsp;&nbsp; \r\n\t<strong>Details</strong>:&nbsp;&nbsp;<span class=\"fieldvalue\"> </span> \r\n</div>"
198 - },
199 - "__search_request_keyword__": ""
200 - }
201 - */
202 -
203 - // Rows
204 - ?><script type="text/html" id="tmpl-wpbc_ajx_booking_list_row">
205 - <div id="row_id_{{{data.parsed_fields.booking_id}}}" class="wpbc_listing_usual_row wpbc_list_row wpbc_row">
206 - <div class="wpbc_listing_col wpbc_col_id check-column"><div class="content_text"><input type="checkbox" /></div></div>
207 - <div class="wpbc_listing_col wpbc_col_booking_labels wpbc_col_labels">
208 - <div class="content_text">
209 - <?php
210 - wpbc_for_booking_template__action_read();
211 - ?>
212 - <span class="wpbc_label wpbc_label_booking_id">{{data['parsed_fields']['booking_id']}}</span><?php
213 -
214 - /**
215 - * Check for errors in translation.
216 - *
217 - * Example
218 - * French translation of this code:
219 - *
220 - * if ( '<?php esc_html_e( 'Resource not exist', 'booking' ); ?>' == data.parsed_fields.resource_title ) {
221 - * is:
222 - * if ( 'La ressource n'existe pas' == data.parsed_fields.resource_title ) {
223 - *
224 - * it's generate JS error
225 - *
226 - * That's why we need to use
227 - * if ( '<?php echo esc_js(__( 'Resource not exist', 'booking' )); ?>' == data.parsed_fields.resource_title ) {
228 - * which is:
229 - * if ( 'La ressource n\'existe pas' == data.parsed_fields.resource_title ) {
230 - */
231 -
232 - ?>
233 - <#
234 - if ( '<?php echo esc_js(__( 'Resource not exist', 'booking' )); ?>' == data.parsed_fields.resource_title ) {
235 - #><span class="wpbc_label wpbc_label_resource wpbc_label_deleted_resource">{{{data.parsed_fields.resource_title}}}</span><#
236 - } else if ( '' != data.parsed_fields.resource_title ) {
237 - #><span class="wpbc_label wpbc_label_resource">{{{data.parsed_fields.resource_title}}}</span><#
238 - }
239 -
240 - #><span class="wpbc_label wpbc_label_approved<# if ( '0' == data.approved ) { #> hidden_items <# } #>"><i style="color: #def5d4;" class="menu_icon icon-1x wpbc_icn_done_all"></i><?php echo esc_js(__( 'Approved', 'booking' )); ?></span><#
241 - #><span class="wpbc_label wpbc_label_pending<# if ( '1' == data.approved ) { #> hidden_items <# } #>"><i style="color: #f6efe8;" class="menu_icon icon-1x wpbc_icn_hourglass_empty"></i><?php echo esc_js(__( 'Pending', 'booking' )); ?></span><#
242 -
243 - if ( '' != data.templates.payment_label_template ) {
244 - #>{{{data.templates.payment_label_template}}}<#
245 - }
246 -
247 - if ( '' != data.parsed_fields.sync_gid ) {
248 - #><span class="wpbc_label wpbc_label_imported"><i class="menu_icon icon-1x wpbc_icn_cloud_download system_update_alt"></i><?php echo esc_js(__( 'Imported', 'booking' )); ?></span><#
249 - }
250 -
251 - #><span class="wpbc_label wpbc_label_trash<# if ( '1' != data.parsed_fields.trash ) { #> hidden_items <# } #>"><i style="color: #f6efe8;" class="menu_icon icon-1x wpbc_icn_delete_forever"></i><?php echo esc_js(__( 'In Trash', 'booking' )); ?></span><#
252 -
253 - #><?php
254 -
255 -
256 - $labels = get_bk_option( 'wpbc_ajx_booking_labels' );
257 - $labels = explode( "\n",$labels );
258 - $labels = array_map( 'trim',$labels );
259 -
260 - // Check for Labels and colors
261 - foreach ($labels as $label) {
262 -
263 - if ( ( ! empty( $label ) ) && ( false !== strpos( ':', $label ) ) ) {
264 - list( $label, $color, $text_color ) = explode( ':', $label );
265 - } else{
266 - $color = $text_color = '';
267 - }
268 -
269 -
270 - if ( ! empty( $label ) ) {
271 - ?><span class="wpbc_label" style="color:<?php echo esc_attr( $text_color ); ?>;background-color:<?php echo esc_attr( $color ); ?>;">{{{data.parsed_fields<?php
272 - // phpcs:ignore WordPress.Security.EscapeOutput.OutputNotEscaped
273 - echo $label; ?>}}}</span><?php
274 - }
275 - }
276 -
277 - // Predefined internal Labels
278 - ?><#
279 - if ( ( undefined != data._paid )
280 - && ( -1 != data._paid.toLowerCase().indexOf( 'refund' ) )
281 - ) {
282 - #><span class="wpbc_label booking_label__refund"><?php echo esc_js(__('Refund','booking')); ?></span><#
283 - }
284 -console.log( 'row listing', data ); // LISTING_ROWS
285 - #>
286 - </div>
287 - </div>
288 - <div class="wpbc_listing_col wpbc_col_data">
289 - <div class="content_text">
290 - <# <?php if (0) { ?><script type="text/javascript"><?php /* Hack for showing JavaScript syntax */ } ?>
291 - var booking_details = data.templates.form_show;
292 - var booking_keyword = data[ '__search_request_keyword__' ];
293 - booking_details = wpbc_get_highlighted_search_keyword( booking_details, booking_keyword );
294 - <?php if (0) { ?></script><?php } ?> #>
295 - {{{booking_details}}}
296 - <?php if ( 0 ) { ?>
297 - <div class="wpbc_next_booking_time">
298 - <?php do_action( 'wpbca_show_cron_data_in_ajx_booking_listing' ); ?>
299 - <span><strong><?php echo esc_js(__( 'Source', 'booking' )); ?></strong>: <span class="fieldvalue"><strong>{{data['source']}}</strong></span></span>
300 - <span><strong><?php echo esc_js(__( 'Booking ID', 'booking' )); ?></strong>: <span class="fieldvalue"><strong>{{data['booking_id']}}</strong></span></span>
301 - <span class="wpbc_item_actions wpdevelop">
302 - <a href="javascript:void();" style="margin:0;"
303 - onclick="javascript:wpbc_ajx_booking__modify__ajx_reset( wpbc_get_row_id_from_element( this ) );return false;"
304 - class="tooltip_top button-secondary button"
305 - title="<?php echo esc_js(__('Set last checked booking id to 0', 'booking' )); ?>"
306 - data-original-title="Reset"
307 - ><i class="-repeat"></i> Reset</a>
308 - </span>
309 - </div>
310 - <hr/>
311 - <?php } ?>
312 - <# if ( ( !true ) || ( '' == booking_details.trim() ) ) { #>
313 - <hr/>
314 - <# <?php if (0) { ?><script type="text/javascript"><?php /* Hack for showing JavaScript syntax */ } ?>
315 -
316 - // Content Data Template
317 - var my_content_data = wp.template( 'wpbc_content_data' );
318 -
319 - _.each( data['parsed_fields'], function ( p_val, p_key, p_data ) {
320 -
321 - // Skip these fields
322 - if (
323 - ! _.contains( [
324 - '__search_request_keyword__'
325 - , 'booking_id', 'source'
326 - , 'create_date','edit_date', 'google_calendar_link'
327 - ]
328 - , p_key
329 - )
330 - ){
331 - #>{{{
332 - my_content_data( {"key": p_key, "value": wpbc_decode_HTML_entities( p_val ), "keyword": data['__search_request_keyword__'] } )
333 - }}}<#
334 - }
335 -
336 - });
337 - <?php if (0) { ?></script><?php } ?> #>
338 - <# } #>
339 - </div>
340 - </div>
341 - <div class="wpbc_listing_col wpbc_col_dates wpbc_col_labels">
342 - <div class="booking_dates_small booking_dates_expand_section" style="<# if ( 'short' !== wpbc_ajx_booking_listing.search_get_param('ui_usr__dates_short_wide') ) { #>display: none;<# } #>"
343 - ><div class="content_text">{{{data.templates.short_dates_content}}}</div></div>
344 - <div class="booking_dates_full booking_dates_expand_section" style="<# if ( 'wide' !== wpbc_ajx_booking_listing.search_get_param('ui_usr__dates_short_wide') ) { #>display: none;<# } #>"
345 - ><div class="content_text">{{{data.templates.wide_dates_content}}}</div></div>
346 - </div><?php
347 - $this->for_template__actions_buttons();
348 - ?>
349 - </div>
350 -
351 - </script><?php
352 - }
353 -
354 -
355 - private function template__content_data(){
356 -
357 - // Content Data
358 - ?><script type="text/html" id="tmpl-wpbc_content_data">
359 - <strong>{{data.key}}</strong>:<span class="fieldvalue {{data.key}}<#
360 - if ( ( data.keyword != '' )
361 - && ( undefined != data.value )
362 - && ( -1 != data.value.toLowerCase().indexOf( data.keyword.trim().toLowerCase() ) )
363 - ) {
364 - #> fieldsearchvalue<#
365 - }
366 - if ( ( undefined != data.value )
367 - && ( -1 != data.value.toLowerCase().indexOf( 'refund' ) )
368 - ) {
369 - #> _refund<#
370 - }
371 - #>">{{{data.value}}}</span>&nbsp;&nbsp;
372 - </script><?php
119 + // Content Data.
120 + ?><script type="text/html" id="tmpl-wpbc_content_data">
121 + <strong>{{data.key}}</strong>:<span class="fieldvalue {{data.key}}<#
122 + if ( ( data.keyword != '' )
123 + && ( undefined != data.value )
124 + && ( -1 != data.value.toLowerCase().indexOf( data.keyword.trim().toLowerCase() ) )
125 + ) {
126 + #> fieldsearchvalue<#
373 127 }
374 -
375 -
376 - private function for_template__actions_buttons(){
377 - ?>
378 - <div class="wpbc_item_actions wpdevelop">
379 - <div class="wpbc_actions_buttons">
380 -
381 - <div class="wpbc_ajx_toolbar wpbc_buttons_row wpbc_buttons_row_for_booking">
382 - <div class="ui_container ui_container_small">
383 - <div class="ui_group"><?php
384 -
385 - wpbc_for_booking_template__action_cost();
386 -
387 - wpbc_for_booking_template__action_payment_request();
388 -
389 - wpbc_for_booking_template__action_set_payment_status();
390 -
391 - if ( class_exists( 'wpdev_bk_personal' ) ) {
392 - wpbc_flex_divider();
393 - }
394 -
395 - wpbc_for_booking_template__action_edit_booking();
396 -
397 - if ( ! class_exists( 'wpdev_bk_personal' ) ) {
398 - wpbc_flex_divider();
399 - }
400 -
401 - wpbc_for_booking_template__action_change_resource();
402 -
403 - wpbc_for_booking_template__action_duplicate_booking_to_other_resource();
404 -
405 - wpbc_for_booking_template__action_print();
406 -
407 - wpbc_for_booking_template__action_remark();
408 -
409 - wpbc_for_booking_template__action_locale();
410 -
411 - wpbc_for_booking_template__action_add_google_calendar();
412 -
413 - wpbc_flex_divider();
414 -
415 - wpbc_for_booking_template__action_trash();
416 -
417 - wpbc_for_booking_template__action_trash_restore();
418 -
419 - wpbc_for_booking_template__action_delete();
420 -
421 - wpbc_for_booking_template__action_approved();
422 -
423 - wpbc_for_booking_template__action_pending();
424 -
425 - ?><div class="ui_element" style="flex:100%;"></div><?php // New line
426 -
427 - wpbc_for_booking_template_section__action_remark_textarea();
428 -
429 - wpbc_for_booking_template_section__change_booking_resource();
430 -
431 - wpbc_for_booking_template_section__duplicate_booking_to_other_resource();
432 -
433 - wpbc_for_booking_template_section__set_payment_status();
434 -
435 - ?></div>
436 - </div>
437 - </div>
438 -
439 - </div>
440 - <div class="wpbc_actions_sysinfo">
441 - <span><?php echo esc_js(__( 'Booking ID', 'booking' )); ?>: <strong>{{data['parsed_fields']['booking_id']}}</strong></span>&nbsp;&nbsp;
442 - <span><?php echo esc_js(__( 'Edited', 'booking' )); ?>: <strong>{{data['parsed_fields']['modification_date']}}</strong></span>&nbsp;&nbsp;
443 - <span><?php echo esc_js(__( 'Created', 'booking' )); ?>: <strong>{{data['parsed_fields']['creation_date']}}</strong></span>
444 - </div>
445 - </div>
446 - <?php
128 + if ( ( undefined != data.value )
129 + && ( -1 != data.value.toLowerCase().indexOf( 'refund' ) )
130 + ) {
131 + #> _refund<#
447 132 }
133 + #>">{{{data.value}}}</span>&nbsp;&nbsp;
134 + </script><?php
135 + }
448 136
449 -
450 -
451 137 // </editor-fold>
452 138
453 139
454 140 // <editor-fold defaultstate="collapsed" desc=" /// A J A X /// " >
455 141
456 - // A J A X =====================================================================================================
142 + // A J A X =========================================================================================================.
457 143
458 - /**
459 - * Define HOOKs for start loading Ajax
460 - */
461 - public function define_ajax_hook(){
144 + /**
145 + * Define HOOKs for start loading Ajax
146 + */
147 + public function define_ajax_hook() {
462 148
463 - // Ajax Handlers. Note. "locale_for_ajax" rechecked in wpbc-ajax.php
464 - add_action( 'wp_ajax_' . 'WPBC_AJX_BOOKING_LISTING', array( $this, 'ajax_' . 'WPBC_AJX_BOOKING_LISTING' ) ); // Admin & Client (logged in usres)
149 + // Ajax Handlers. Note. "locale_for_ajax" rechecked in wpbc-ajax.php.
150 + add_action( 'wp_ajax_' . 'WPBC_AJX_BOOKING_LISTING', array( $this, 'ajax_' . 'WPBC_AJX_BOOKING_LISTING' ) ); // Admin & Client (logged in usres).
465 151
466 - // Ajax Handlers for actions
467 - add_action( 'wp_ajax_' . 'WPBC_AJX_BOOKING_ACTIONS', 'wpbc_ajax_' . 'WPBC_AJX_BOOKING_ACTIONS' );
152 + // Ajax Handlers for actions.
153 + add_action( 'wp_ajax_' . 'WPBC_AJX_BOOKING_ACTIONS', 'wpbc_ajax_' . 'WPBC_AJX_BOOKING_ACTIONS' );
154 + // add_action( 'wp_ajax_nopriv_' . 'WPBC_AJX_BOOKING_LISTING', array( $this, 'ajax_' . 'WPBC_AJX_BOOKING_LISTING' ) ); // Client (not logged in).
155 + }
468 156
469 - // add_action( 'wp_ajax_nopriv_' . 'WPBC_AJX_BOOKING_LISTING', array( $this, 'ajax_' . 'WPBC_AJX_BOOKING_LISTING' ) ); // Client (not logged in)
470 - }
471 157
472 158
473 -
474 159 /**
475 160 * Ajax - Get Listing Data and Response to JS script
476 161 */
477 162 public function ajax_WPBC_AJX_BOOKING_LISTING() {
@@ -478,14 +163,14 @@
478 163
479 164 // phpcs:ignore WordPress.Security.NonceVerification.Recommended, WordPress.Security.NonceVerification.Missing
480 165 if ( ! isset( $_POST['search_params'] ) || empty( $_POST['search_params'] ) ) { exit; }
481 166
482 - // Security ----------------------------------------------------------------------------------------------- // in Ajax Post: 'nonce': wpbc_ajx_booking_listing.get_secure_param( 'nonce' ),
167 + // Security ----------------------------------------------------------------------------------------------- // in Ajax Post: 'nonce': wpbc_ajx_booking_listing.get_secure_param( 'nonce' ),.
483 168 $action_name = 'wpbc_ajx_booking_listing_ajx' . '_wpbcnonce';
484 169 $nonce_post_key = 'nonce';
485 170 $result_check = check_ajax_referer( $action_name, $nonce_post_key );
486 171
487 - $user_id = ( isset( $_REQUEST['wpbc_ajx_user_id'] ) ) ? intval( $_REQUEST['wpbc_ajx_user_id'] ) : wpbc_get_current_user_id(); // phpcs:ignore WordPress.Security.NonceVerification.Recommended, WordPress.Security.NonceVerification.Missing
172 + $user_id = ( isset( $_REQUEST['wpbc_ajx_user_id'] ) ) ? intval( $_REQUEST['wpbc_ajx_user_id'] ) : wpbc_get_current_user_id(); // phpcs:ignore WordPress.Security.NonceVerification.Recommended, WordPress.Security.NonceVerification.Missing
488 173
489 174 /**
490 175 * SQL ---------------------------------------------------------------------------
491 176 *
@@ -494,19 +179,21 @@
494 179 * Use prefix "search_params", if Ajax sent -
495 180 * $_REQUEST['search_params']['page_num'], $_REQUEST['search_params']['page_items_count'],..
496 181 */
497 182
498 - $user_request = new WPBC_AJX__REQUEST( array(
499 - 'db_option_name' => 'booking_listing_request_params',
500 - 'user_id' => $user_id, // FixIn: 9.4.3.2.
501 - 'request_rules_structure' => wpbc_ajx_get__request_params__names_default()
502 - )
503 - );
183 + $user_request = new WPBC_AJX__REQUEST(
184 + array(
185 + 'db_option_name' => 'booking_listing_request_params',
186 + 'user_id' => $user_id, // FixIn: 9.4.3.2.
187 + 'request_rules_structure' => wpbc_ajx_get__request_params__names_default(),
188 + )
189 + );
190 +
504 191 $request_prefix = 'search_params';
505 - $request_params = $user_request->get_sanitized__in_request__value_or_default( $request_prefix ); // NOT Direct: $_REQUEST['search_params']['resource_id']
192 + $request_params = $user_request->get_sanitized__in_request__value_or_default( $request_prefix ); // NOT Direct: $_REQUEST['search_params']['resource_id'].
506 193
507 194
508 - $data_arr = wpbc_ajx_get_booking_data_arr( $request_params );
195 + $data_arr = wpbc_ajx_get_booking_data_arr( $request_params );
509 196
510 197 $new_bookings_count = wpbc_db_get_number_new_bookings();
511 198
512 199 if ( 'make_reset' === $request_params['ui_reset'] ) {
@@ -512,25 +199,28 @@
512 199 if ( 'make_reset' === $request_params['ui_reset'] ) {
513 200
514 201 $is_reseted = wpbc_ajx__user_request_params__delete( $user_id );
515 202
516 - $request_params['ui_reset'] = $is_reseted ? 'reset_done' : 'reset_error';
203 + $request_params['ui_reset'] = $is_reseted ? 'reset_done' : 'reset_error';
204 + $request_params['ui_reset_url'] = wpbc_get_bookings_url() . '&tab=vm_booking_listing';
517 205
518 206 } else {
519 - $is_success_update = wpbc_ajx__user_request_params__save( $request_params, $user_id ); // - $request_params - serialized here automatically
207 + $is_success_update = wpbc_ajx__user_request_params__save( $request_params, $user_id ); // - $request_params - serialized here automatically.
520 208 }
521 209
522 - //----------------------------------------------------------------------------------------------------------
523 - // Send JSON. Its will make "wp_json_encode" - so pass only array, and This function call wp_die( '', '', array( 'response' => null, ) ) Pass JS OBJ: response_data in "jQuery.post( " function on success.
524 - wp_send_json( array(
525 - 'ajx_count' => $data_arr['count'],
526 - 'ajx_items' => $data_arr['data_arr'],
527 - 'ajx_booking_resources' => $data_arr['booking_resources'],
528 - // phpcs:ignore WordPress.Security.ValidatedSanitizedInput.InputNotValidated, WordPress.Security.ValidatedSanitizedInput.MissingUnslash, WordPress.Security.ValidatedSanitizedInput.InputNotSanitized
529 - 'ajx_search_params' => $_REQUEST['search_params'],
530 - 'ajx_cleaned_params' => $request_params,
531 - 'ajx_new_bookings_count'=> $new_bookings_count
532 - ) );
210 + // ---------------------------------------------------------------------------------------------------------.
211 + // Send JSON. Its will make "wp_json_encode" - so pass only array, and This function call wp_die( '', '', array( 'response' => null, ) ) Pass JS OBJ: response_data in "jQuery.post( " function on success.
212 + wp_send_json(
213 + array(
214 + 'ajx_count' => $data_arr['count'],
215 + 'ajx_items' => $data_arr['data_arr'],
216 + 'ajx_booking_resources' => $data_arr['booking_resources'],
217 + // phpcs:ignore WordPress.Security.ValidatedSanitizedInput.InputNotValidated, WordPress.Security.ValidatedSanitizedInput.MissingUnslash, WordPress.Security.ValidatedSanitizedInput.InputNotSanitized
218 + 'ajx_search_params' => $_REQUEST['search_params'],
219 + 'ajx_cleaned_params' => $request_params,
220 + 'ajx_new_bookings_count' => $new_bookings_count,
221 + )
222 + );
533 223 }
534 224
535 225 // </editor-fold>
536 226
@@ -541,11 +231,11 @@
541 231 /**
542 232 * Just for loading CSS and JavaScript files
543 233 */
544 234 if ( true ) {
545 - $ajx_booking_loading = new WPBC_AJX_Bookings;
546 - $ajx_booking_loading->init_load_css_js_tpl();
547 - $ajx_booking_loading->define_ajax_hook();
235 + $wpbc_ajx_booking_loading = new WPBC_AJX_Bookings();
236 + $wpbc_ajx_booking_loading->init_load_css_js_tpl();
237 + $wpbc_ajx_booking_loading->define_ajax_hook();
548 238 }
549 239
550 240
551 241
@@ -708,5 +398,4 @@
708 398
709 399 /**
710 400 * DevApi: apply_filters( 'wpbc_search_booking_by_keyword', ' d1ca3d0b476c ', array( 'source' => 'csv' ) );
711 401 */
712 -