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 +132 -439 10.1.3 → 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,480 +9,168 @@
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-global-vars' ), 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/codemirror.js' ) */
55 - , array( 'wpbc-global-vars' ), 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/codemirror.js' ) */
59 - , array( 'wpbc-global-vars' ), 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/codemirror.js' ) */
63 - , array( 'wpbc-global-vars' ), 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-global-vars' ), WP_BK_VERSION_NUM, $in_footer );
68 82
69 - /**
70 - wp_localize_script( 'wpbc-global-vars', '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 _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 $text_color; ?>;background-color:<?php echo $color; ?>;">{{{data.parsed_fields<?php echo $label; ?>}}}</span><?php
272 - }
273 - }
274 -
275 - // Predefined internal Labels
276 - ?><#
277 - if ( ( undefined != data._paid )
278 - && ( -1 != data._paid.toLowerCase().indexOf( 'refund' ) )
279 - ) {
280 - #><span class="wpbc_label booking_label__refund"><?php echo esc_js(__('Refund','booking')); ?></span><#
281 - }
282 -console.log( 'row listing', data ); // LISTING_ROWS
283 - #>
284 - </div>
285 - </div>
286 - <div class="wpbc_listing_col wpbc_col_data">
287 - <div class="content_text">
288 - <# <?php if (0) { ?><script type="text/javascript"><?php /* Hack for showing JavaScript syntax */ } ?>
289 - var booking_details = data.templates.form_show;
290 - var booking_keyword = data[ '__search_request_keyword__' ];
291 - booking_details = wpbc_get_highlighted_search_keyword( booking_details, booking_keyword );
292 - <?php if (0) { ?></script><?php } ?> #>
293 - {{{booking_details}}}
294 - <?php if ( 0 ) { ?>
295 - <div class="wpbc_next_booking_time">
296 - <?php do_action( 'wpbca_show_cron_data_in_ajx_booking_listing' ); ?>
297 - <span><strong><?php echo esc_js(__( 'Source', 'booking' )); ?></strong>: <span class="fieldvalue"><strong>{{data['source']}}</strong></span></span>
298 - <span><strong><?php echo esc_js(__( 'Booking ID', 'booking' )); ?></strong>: <span class="fieldvalue"><strong>{{data['booking_id']}}</strong></span></span>
299 - <span class="wpbc_item_actions wpdevelop">
300 - <a href="javascript:void();" style="margin:0;"
301 - onclick="javascript:wpbc_ajx_booking__modify__ajx_reset( wpbc_get_row_id_from_element( this ) );return false;"
302 - class="tooltip_top button-secondary button"
303 - title="<?php echo esc_js(__('Set last checked booking id to 0', 'booking' )); ?>"
304 - data-original-title="Reset"
305 - ><i class="glyphicon glyphicon-flash -repeat"></i></a>
306 - </span>
307 - </div>
308 - <hr/>
309 - <?php } ?>
310 - <# if ( ( !true ) || ( '' == booking_details.trim() ) ) { #>
311 - <hr/>
312 - <# <?php if (0) { ?><script type="text/javascript"><?php /* Hack for showing JavaScript syntax */ } ?>
313 -
314 - // Content Data Template
315 - var my_content_data = wp.template( 'wpbc_content_data' );
316 -
317 - _.each( data['parsed_fields'], function ( p_val, p_key, p_data ) {
318 -
319 - // Skip these fields
320 - if (
321 - ! _.contains( [
322 - '__search_request_keyword__'
323 - , 'booking_id', 'source'
324 - , 'create_date','edit_date', 'google_calendar_link'
325 - ]
326 - , p_key
327 - )
328 - ){
329 - #>{{{
330 - my_content_data( {"key": p_key, "value": wpbc_decode_HTML_entities( p_val ), "keyword": data['__search_request_keyword__'] } )
331 - }}}<#
332 - }
333 -
334 - });
335 - <?php if (0) { ?></script><?php } ?> #>
336 - <# } #>
337 - </div>
338 - </div>
339 - <div class="wpbc_listing_col wpbc_col_dates wpbc_col_labels">
340 - <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;<# } #>"
341 - ><div class="content_text">{{{data.templates.short_dates_content}}}</div></div>
342 - <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;<# } #>"
343 - ><div class="content_text">{{{data.templates.wide_dates_content}}}</div></div>
344 - </div><?php
345 - $this->for_template__actions_buttons();
346 - ?>
347 - </div>
348 -
349 - </script><?php
350 - }
351 -
352 -
353 - private function template__content_data(){
354 -
355 - // Content Data
356 - ?><script type="text/html" id="tmpl-wpbc_content_data">
357 - <strong>{{data.key}}</strong>:<span class="fieldvalue {{data.key}}<#
358 - if ( ( data.keyword != '' )
359 - && ( undefined != data.value )
360 - && ( -1 != data.value.toLowerCase().indexOf( data.keyword.trim().toLowerCase() ) )
361 - ) {
362 - #> fieldsearchvalue<#
363 - }
364 - if ( ( undefined != data.value )
365 - && ( -1 != data.value.toLowerCase().indexOf( 'refund' ) )
366 - ) {
367 - #> _refund<#
368 - }
369 - #>">{{{data.value}}}</span>&nbsp;&nbsp;
370 - </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<#
371 127 }
372 -
373 -
374 - private function for_template__actions_buttons(){
375 - ?>
376 - <div class="wpbc_item_actions wpdevelop">
377 - <div class="wpbc_actions_buttons">
378 -
379 - <div class="wpbc_ajx_toolbar wpbc_buttons_row wpbc_buttons_row_for_booking">
380 - <div class="ui_container ui_container_small">
381 - <div class="ui_group"><?php
382 -
383 - wpbc_for_booking_template__action_cost();
384 -
385 - wpbc_for_booking_template__action_payment_request();
386 -
387 - wpbc_for_booking_template__action_set_payment_status();
388 -
389 - if ( class_exists( 'wpdev_bk_personal' ) ) {
390 - wpbc_flex_divider();
391 - }
392 -
393 - wpbc_for_booking_template__action_edit_booking();
394 -
395 - if ( ! class_exists( 'wpdev_bk_personal' ) ) {
396 - wpbc_flex_divider();
397 - }
398 -
399 - wpbc_for_booking_template__action_change_resource();
400 -
401 - wpbc_for_booking_template__action_duplicate_booking_to_other_resource();
402 -
403 - wpbc_for_booking_template__action_print();
404 -
405 - wpbc_for_booking_template__action_remark();
406 -
407 - wpbc_for_booking_template__action_locale();
408 -
409 - wpbc_for_booking_template__action_add_google_calendar();
410 -
411 - wpbc_flex_divider();
412 -
413 - wpbc_for_booking_template__action_trash();
414 -
415 - wpbc_for_booking_template__action_trash_restore();
416 -
417 - wpbc_for_booking_template__action_delete();
418 -
419 - wpbc_for_booking_template__action_approved();
420 -
421 - wpbc_for_booking_template__action_pending();
422 -
423 - ?><div class="ui_element" style="flex:100%;"></div><?php // New line
424 -
425 - wpbc_for_booking_template_section__action_remark_textarea();
426 -
427 - wpbc_for_booking_template_section__change_booking_resource();
428 -
429 - wpbc_for_booking_template_section__duplicate_booking_to_other_resource();
430 -
431 - wpbc_for_booking_template_section__set_payment_status();
432 -
433 - ?></div>
434 - </div>
435 - </div>
436 -
437 - </div>
438 - <div class="wpbc_actions_sysinfo">
439 - <span><?php echo esc_js(__( 'Booking ID', 'booking' )); ?>: <strong>{{data['parsed_fields']['booking_id']}}</strong></span>&nbsp;&nbsp;
440 - <span><?php echo esc_js(__( 'Edited', 'booking' )); ?>: <strong>{{data['parsed_fields']['modification_date']}}</strong></span>&nbsp;&nbsp;
441 - <span><?php echo esc_js(__( 'Created', 'booking' )); ?>: <strong>{{data['parsed_fields']['creation_date']}}</strong></span>
442 - </div>
443 - </div>
444 - <?php
128 + if ( ( undefined != data.value )
129 + && ( -1 != data.value.toLowerCase().indexOf( 'refund' ) )
130 + ) {
131 + #> _refund<#
445 132 }
133 + #>">{{{data.value}}}</span>&nbsp;&nbsp;
134 + </script><?php
135 + }
446 136
447 -
448 -
449 137 // </editor-fold>
450 138
451 139
452 140 // <editor-fold defaultstate="collapsed" desc=" /// A J A X /// " >
453 141
454 - // A J A X =====================================================================================================
142 + // A J A X =========================================================================================================.
455 143
456 - /**
457 - * Define HOOKs for start loading Ajax
458 - */
459 - public function define_ajax_hook(){
144 + /**
145 + * Define HOOKs for start loading Ajax
146 + */
147 + public function define_ajax_hook() {
460 148
461 - // Ajax Handlers. Note. "locale_for_ajax" rechecked in wpbc-ajax.php
462 - 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).
463 151
464 - // Ajax Handlers for actions
465 - 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 + }
466 156
467 - // add_action( 'wp_ajax_nopriv_' . 'WPBC_AJX_BOOKING_LISTING', array( $this, 'ajax_' . 'WPBC_AJX_BOOKING_LISTING' ) ); // Client (not logged in)
468 - }
469 157
470 158
471 -
472 159 /**
473 160 * Ajax - Get Listing Data and Response to JS script
474 161 */
475 162 public function ajax_WPBC_AJX_BOOKING_LISTING() {
476 163
164 + // phpcs:ignore WordPress.Security.NonceVerification.Recommended, WordPress.Security.NonceVerification.Missing
477 165 if ( ! isset( $_POST['search_params'] ) || empty( $_POST['search_params'] ) ) { exit; }
478 166
479 - // 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' ),.
480 168 $action_name = 'wpbc_ajx_booking_listing_ajx' . '_wpbcnonce';
481 169 $nonce_post_key = 'nonce';
482 170 $result_check = check_ajax_referer( $action_name, $nonce_post_key );
483 171
484 - $user_id = ( isset( $_REQUEST['wpbc_ajx_user_id'] ) ) ? intval( $_REQUEST['wpbc_ajx_user_id'] ) : wpbc_get_current_user_id();
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
485 173
486 174 /**
487 175 * SQL ---------------------------------------------------------------------------
488 176 *
@@ -491,19 +179,21 @@
491 179 * Use prefix "search_params", if Ajax sent -
492 180 * $_REQUEST['search_params']['page_num'], $_REQUEST['search_params']['page_items_count'],..
493 181 */
494 182
495 - $user_request = new WPBC_AJX__REQUEST( array(
496 - 'db_option_name' => 'booking_listing_request_params',
497 - 'user_id' => $user_id, //FixIn: 9.4.3.2
498 - 'request_rules_structure' => wpbc_ajx_get__request_params__names_default()
499 - )
500 - );
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 +
501 191 $request_prefix = 'search_params';
502 - $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'].
503 193
504 194
505 - $data_arr = wpbc_ajx_get_booking_data_arr( $request_params );
195 + $data_arr = wpbc_ajx_get_booking_data_arr( $request_params );
506 196
507 197 $new_bookings_count = wpbc_db_get_number_new_bookings();
508 198
509 199 if ( 'make_reset' === $request_params['ui_reset'] ) {
@@ -509,24 +199,28 @@
509 199 if ( 'make_reset' === $request_params['ui_reset'] ) {
510 200
511 201 $is_reseted = wpbc_ajx__user_request_params__delete( $user_id );
512 202
513 - $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';
514 205
515 206 } else {
516 - $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.
517 208 }
518 209
519 - //----------------------------------------------------------------------------------------------------------
520 - // 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.
521 - wp_send_json( array(
522 - 'ajx_count' => $data_arr['count'],
523 - 'ajx_items' => $data_arr['data_arr'],
524 - 'ajx_booking_resources' => $data_arr['booking_resources'],
525 - 'ajx_search_params' => $_REQUEST['search_params'],
526 - 'ajx_cleaned_params' => $request_params,
527 - 'ajx_new_bookings_count'=> $new_bookings_count
528 - ) );
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 + );
529 223 }
530 224
531 225 // </editor-fold>
532 226
@@ -537,11 +231,11 @@
537 231 /**
538 232 * Just for loading CSS and JavaScript files
539 233 */
540 234 if ( true ) {
541 - $ajx_booking_loading = new WPBC_AJX_Bookings;
542 - $ajx_booking_loading->init_load_css_js_tpl();
543 - $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();
544 238 }
545 239
546 240
547 241
@@ -704,5 +398,4 @@
704 398
705 399 /**
706 400 * DevApi: apply_filters( 'wpbc_search_booking_by_keyword', ' d1ca3d0b476c ', array( 'source' => 'csv' ) );
707 401 */
708 -