PluginProbe
Booking Calendar / 11.8.4
Booking Calendar v11.8.4
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 10.11 All 204 releases
booking / includes / page-bookings / bookings__page.php

bookings__page.php in Booking Calendar 11.8.4, at includes/page-bookings/bookings__page.php

318 lines 13.7 KB
No matching file
Up and down to move Enter to open Esc to close
Raw Download Zip
1 <?php
2 /*
3 * @package: AJX_Bookings Page
4 * @category: o Email Reminders
5 * @description: Define AJX_Bookings in admin settings page. - Sending friendly email reminders based on custom ajx_booking.
6 * Plugin URI: https://oplugins.com/plugins/email-reminders/#premium
7 * Author URI: https://oplugins.com
8 * Author: wpdevelop, oplugins
9 * Version: 0.0.1
10 * @modified 2020-05-11
11 */
12 //FixIn: 9.2.1
13 if ( ! defined( 'ABSPATH' ) ) exit; // Exit if accessed directly
14
15
16 /** Show Content
17 * Update Content
18 * Define Slug
19 * Define where to show
20 */
21 class WPBC_Page_AJX_Bookings extends WPBC_Page_Structure {
22
23 // public function __construct() {
24 //
25 // parent::__construct();
26 //
27 // }
28
29 public function in_page() {
30 return 'wpbc';
31 }
32
33 public function tabs() {
34
35 $is_full_screen = WPBC_User_Custom_Data_Saver::get_user_data_value( wpbc_get_current_user_id(), 'is_full_screen' );
36 $is_full_screen = function_exists( 'wpbc_ui__get_full_screen_mode_from_cookie' )
37 ? wpbc_ui__get_full_screen_mode_from_cookie( $is_full_screen )
38 : $is_full_screen;
39 $is_full_screen = ( 'On' === $is_full_screen );
40
41 $tabs = array();
42 $tabs['vm_booking_listing'] = array(
43 'is_show_top_path' => true, // true | false. By default value is: true.
44 'is_show_top_navigation' => true, // true | false. By default value is: false.
45 'left_navigation__default_view_mode' => '', // FixIn: 11.7.1.1.: ( $is_full_screen ) ? 'compact' : 'min', // '' | 'min' | 'compact' | 'max' | 'none'. By default value is: ''.
46 'page_title' => false, // Header - Title. If false, than hidden.
47 'page_description' => false, // Header - Title Description. If false, than hidden.
48 'title' => __( 'Bookings', 'booking' ), // Menu - Title.
49 'hint' => __( 'Booking Listing', 'booking' ), // Menu - Mouse Over Hint.
50 'font_icon' => 'wpbc-bi-collection', // Menu - Icon.
51 'link' => '', // Can be skiped, then generated link based on Page and Tab tags. Or can be extenral link.
52 'position' => '', // 'left' | 'right' | '' -- Default is ''.
53 'css_classes' => '', // CSS classes.
54 'icon' => '', // Icon - link to the real PNG img.
55 'default' => false, // Is this tab activated by default or not: true || false.
56 'disabled' => false, // Is this tab disabled: true || false.
57 'hided' => true, // Is this tab hided: true || false.
58 'subtabs' => array(),
59 );
60
61 // $subtabs = array();
62 // $tabs[ 'items' ][ 'subtabs' ] = $subtabs;
63 return $tabs;
64 }
65
66 public function content() {
67
68 do_action( 'wpbc_hook_settings_page_header', 'page_booking_listing' ); // Define Notices Section and show some static messages, if needed.
69
70 if ( ! wpbc_is_mu_user_can_be_here( 'activated_user' ) ) {
71 return false; // Check if MU user activated, otherwise show Warning message.
72 }
73
74 // -------------------------------------------------------------------------------------------------------------
75 // Get and escape request parameters
76 // -------------------------------------------------------------------------------------------------------------
77 $user_request = new WPBC_AJX__REQUEST(
78 array(
79 'db_option_name' => 'booking_listing_request_params',
80 'user_id' => wpbc_get_current_user_id(),
81 'request_rules_structure' => wpbc_ajx_get__request_params__names_default(),
82 )
83 );
84
85 $escaped_search_request_params = false;
86 // phpcs:ignore WordPress.Security.NonceVerification.Recommended, WordPress.Security.NonceVerification.Missing
87 if ( empty( $_REQUEST['overwrite'] ) ) {
88 $escaped_search_request_params = $user_request->get_sanitized__saved__user_request_params(); // Get Saved.
89 }
90
91 // phpcs:ignore WordPress.Security.NonceVerification.Recommended, WordPress.Security.NonceVerification.Missing
92 if ( ( false === $escaped_search_request_params ) || ( ! empty( $_REQUEST['overwrite'] ) ) ) {
93 // This request was not saved before, then get sanitized direct parameters, like: $_REQUEST['resource_id'].
94 $request_prefix = false;
95 $escaped_search_request_params = $user_request->get_sanitized__in_request__value_or_default( $request_prefix ); // Direct request: $_REQUEST['resource_id'] //.
96 }
97
98 // -------------------------------------------------------------------------------------------------------------
99
100
101 // Submit.
102 $submit_form_name = 'wpbc_ajx_booking_form'; // Define form name.
103
104 ?><span class="wpdevelop"><?php // BS UI CSS Class.
105
106 wpbc_js_for_bookings_page(); // JavaScript functions.
107
108 wpbc_ajx_bookings_toolbar( $escaped_search_request_params );
109
110 ?></span><?php // BS UI CSS Class.
111
112 // TODO: continue here with this new toolbar
113 // wpbc_ui__toolbar__bo_listing( $escaped_search_request_params );
114
115 ?><div id="wpbc_log_screen" class="wpbc_log_screen"></div><?php
116
117 // Content ----------------------------------------------------------------------------------------------------.
118 ?>
119 <div class="clear" style="margin-bottom:10px;"></div>
120 <span class="metabox-holder">
121 <form style="min-height:459px;" name="<?php echo esc_attr( $submit_form_name ); ?>" id="<?php echo esc_attr( $submit_form_name ); ?>" action="" method="post">
122 <div class="wpbc_ajx_trigger_hooks"></div>
123 <?php
124
125 // N o n c e field, and key for checking S u b m i t.
126 wp_nonce_field( 'wpbc_settings_page_' . $submit_form_name );
127 ?><input type="hidden" name="is_form_sbmitted_<?php echo esc_attr( $submit_form_name ); ?>" id="is_form_sbmitted_<?php echo esc_attr( $submit_form_name ); ?>" value="1"/><?php
128
129 // wpbc_ajx_booking_modify_container_show(); // Container for showing Edit ajx_booking and define Edit and Delete ajx_booking JavaScript vars.
130
131 $is_test_sql_directly = false;
132 if ( ! $is_test_sql_directly ) {
133
134 $this->show_ajx_booking_listing_container_ajax( $escaped_search_request_params );
135
136 $this->show_pagination_container();
137
138 } else {
139 $this->show_ajx_booking_listing_container_directly(); // Useful for direct showing of listing without the ajax request, its requirement JavaScript to show data in template!.
140 }
141
142 ?><div class="clear"></div><?php
143
144 ?>
145 </form>
146 </span>
147 <?php
148
149 do_action( 'wpbc_hook_settings_page_footer', 'wpbc-ajx_booking' );
150
151 wpbc_welcome_panel(); // Welcome Panel (links).
152
153 // == Hidden Templates for - Booking Actions ==
154 do_action( 'wpbc_hook_booking_template__hidden_templates' );
155
156 wpbc_show_booking_footer(); // Show rating line.
157 }
158
159 private function show_pagination_container(){
160 ?>
161 <div class="wpbc_ajx_booking_pagination"></div>
162 <?php
163 wpbc_clear_div();
164
165 $wpbc_pagination = new WPBC_Pagination();
166 $wpbc_pagination->init( array(
167 'load_on_page' => 'wpbc-ajx_booking',
168 'container_header' => '.wpbc_ajx_booking_pagination_header',
169 'container_footer' => '.wpbc_ajx_booking_pagination_footer',
170 'container' => '.wpbc_ajx_booking_pagination',
171 'on_click' => 'wpbc_ajx_booking_pagination_click' // onclick = "javascript: wpbc_ajx_booking_pagination_click( page_num );" - need to define this function in JS file
172 ));
173
174 /**
175 $wpbc_pagination->show( array( // Its showing with JavaScript on document ready
176 'page_active' => 3,
177 'pages_count' => 20
178 ));
179 /**/
180 }
181
182
183 private function show_ajx_booking_listing_container_ajax( $escaped_search_request_params ) {
184
185 if ( class_exists( 'WPBC_AJX_Bookings' ) ) {
186 WPBC_AJX_Bookings::enqueue_js_files_now();
187 }
188
189 ?>
190 <div class="wpbc__wrap__booking_listing">
191 <div class="wpbc__list__table wpbc_selectable_table">
192 <?php $this->spins_loading_container(); ?>
193 </div>
194 </div>
195 <script type="text/javascript">
196 jQuery(document).ready(function () {
197
198 var wpbc_booking_listing_wait_counter = 0;
199 var wpbc_booking_listing_wait_timer = setInterval( function() {
200
201 wpbc_booking_listing_wait_counter++;
202
203 if (
204 'undefined' === typeof wpbc_ajx_booking_listing
205 || 'function' !== typeof wpbc_ajx_booking_listing.set_secure_param
206 || 'function' !== typeof wpbc_ajx_booking_send_search_request_with_params
207 ) {
208 if ( wpbc_booking_listing_wait_counter > 20 ) {
209 clearInterval( wpbc_booking_listing_wait_timer );
210 }
211 return;
212 }
213
214 clearInterval( wpbc_booking_listing_wait_timer );
215
216 // Set Security - Nonce for Ajax - Listing
217 wpbc_ajx_booking_listing.set_secure_param( 'nonce', '<?php echo esc_attr( wp_create_nonce( 'wpbc_ajx_booking_listing_ajx' . '_wpbcnonce' ) ); ?>' );
218 wpbc_ajx_booking_listing.set_secure_param( 'user_id', '<?php echo esc_attr( wpbc_get_current_user_id() ); ?>' );
219 wpbc_ajx_booking_listing.set_secure_param( 'locale', '<?php echo esc_attr( get_user_locale() ); ?>' );
220
221 // Set other parameters
222 wpbc_ajx_booking_listing.set_other_param( 'listing_container', '.wpbc__list__table' );
223
224 wpbc_ajx_booking_listing.set_other_param( 'pagination_container', '.wpbc_ajx_booking_pagination' );
225 wpbc_ajx_booking_listing.set_other_param( 'pagination_container_header', '.wpbc_ajx_booking_pagination_header' );
226 wpbc_ajx_booking_listing.set_other_param( 'pagination_container_footer', '.wpbc_ajx_booking_pagination_footer' );
227
228 // Send Ajax request and show listing after this.
229 wpbc_ajx_booking_send_search_request_with_params( <?php echo wp_json_encode( $escaped_search_request_params ); ?> );
230 }, 100 );
231 });
232 </script>
233 <?php
234 }
235
236
237 /**
238 * Show Spin Loading container.
239 *
240 * @return void
241 */
242 private function spins_loading_container() {
243 ?>
244 <div class="wpbc_spins_loading_container">
245 <div class="wpbc_booking_form_spin_loader">
246 <div class="wpbc_spins_loader_wrapper">
247 <div class="wpbc_spin_loader_one_new"></div>
248 </div>
249 </div>
250 <span>
251 <?php
252 esc_html_e( 'Loading', 'booking' );
253 echo ' ...';
254 ?>
255 </span>
256 </div>
257 <?php
258 }
259
260
261 private function show_ajx_booking_listing_container_directly(){
262
263
264 //TODO: We need to send Ajax request and then show the listing (its will make one same way of showing listing and pagination)!
265
266
267 $my_ajx_booking = new WPBC_AJX_Bookings;
268
269 ////////////////////////////////////
270 // 0. Check Nonce if Ajax ( ! used now )
271 ////////////////////////////////////
272 if ( 0 ){
273 $action_name = 'wpbc_search_field' . '_wpbcnonce'; // $_POST['element_id'] . '_wpbcnonce';
274 $nonce_post_key = 'nonce';
275 $result_check = check_ajax_referer( $action_name, $nonce_post_key );
276 }
277
278 ////////////////////////////////////
279 // 1. Direct Clean Params
280 ////////////////////////////////////
281 $request_params_ajx_booking = array(
282 'page_num' => array( 'validate' => 'd', 'default' => 1 )
283 , 'page_items_count' => array( 'validate' => 'd', 'default' => 10 )
284 , 'sort' => array( 'validate' => array( 'booking_id' ), 'default' => 'booking_id' )
285 , 'sort_type' => array( 'validate' => array( 'ASC', 'DESC'),'default' => 'DESC' )
286 , 'status' => array( 'validate' => 's', 'default' => '' )
287 , 'keyword' => array( 'validate' => 's', 'default' => '' )
288 , 'ru_create_date' => array( 'validate' => 'date', 'default' => '' )
289 );
290 $request_params_values = array( // Usually $request_params_values is $_REQUEST
291 'page_num' => 1,
292 'page_items_count' => 3,
293 'sort' => 'booking_id',
294 'sort_type' => 'DESC',
295 'status' => '',
296 'keyword' => '',
297 'ru_create_date' => ''
298 );
299 $request_params = wpbc_sanitize_params_in_arr( $request_params_values, $request_params_ajx_booking );
300
301 ////////////////////////////////////
302 // 2. Get items array from DB
303 ////////////////////////////////////
304 $items_arr = wpbc_ajx_get_booking_data_arr( $request_params );
305 debuge($items_arr);
306
307 // Show Pagination - $total_num_of_items_in_all_pages = $sql_res[ [ 'count' ] ];
308 // $wpbc_pagination->show_pagination(
309 // $request_params_values['page_num'],
310 // ceil( $sql_res[ [ 'count' ] ] / $request_params_values['page_items_count'] )
311 // );
312
313 }
314
315 }
316
317 add_action( 'wpbc_menu_created', array( new WPBC_Page_AJX_Bookings(), '__construct' ) ); // Executed after creation of Menu.
318