PluginProbe
Booking Calendar / 10.15.7
Booking Calendar v10.15.7
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
booking / includes / page-bookings / bookings__page.php

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

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