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__page.php +154 -109 10.10 → 11.9 View file →
@@ -19,93 +19,100 @@
19 19 * Define where to show
20 20 */
21 21 class WPBC_Page_AJX_Bookings extends WPBC_Page_Structure {
22 22
23 - public function __construct() {
23 +// public function __construct() {
24 +//
25 +// parent::__construct();
26 +//
27 +// }
24 28
25 - parent::__construct();
29 + public function in_page() {
30 + return 'wpbc';
31 + }
26 32
27 - // Redefine TAGs Names, becasue 'tab' slug already used in the system for definition of active toolbar.
28 - $this->tags['tab'] = 'view_mode';
29 - $this->tags['subtab'] = 'bottom_nav';
30 - }
33 + public function tabs() {
31 34
32 - public function in_page() {
33 - return 'wpbc';
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 );
35 40
36 - public function tabs() {
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 + );
37 60
38 - $tabs = array();
39 - $tabs[ 'vm_booking_listing' ] = array(
40 - 'title' => __( 'Booking Listing', 'booking' ) // Title of TAB
41 - , 'hint' => __( 'Booking Listing', 'booking' ) // Hint
42 - , 'page_title' => __( 'Booking Listing', 'booking' ) // Title of Page
43 - , 'link' => '' // Can be skiped, then generated link based on Page and Tab tags. Or can be extenral link
44 - , 'position' => '' // 'left' || 'right' || ''
45 - , 'css_classes' => '' // CSS class(es)
46 - , 'icon' => '' // Icon - link to the real PNG img
47 - , 'font_icon' => 'wpbc-bi-collection' // CSS definition of forn Icon // FixIn: 9.5.5.3.
48 - , 'header_font_icon' => 'wpbc-bi-collection' // CSS definition of forn Icon // FixIn: 9.5.5.3.
49 - , 'default' => false // Is this tab activated by default or not: true || false.
50 - , 'disabled' => false // Is this tab disabled: true || false.
51 - , 'hided' => true // Is this tab hided: true || false.
52 - , 'subtabs' => array()
53 - );
54 - // $subtabs = array();
55 - // $tabs[ 'items' ][ 'subtabs' ] = $subtabs;
56 - return $tabs;
57 - }
61 + // $subtabs = array();
62 + // $tabs[ 'items' ][ 'subtabs' ] = $subtabs;
63 + return $tabs;
64 + }
58 65
59 - public function content() {
66 + public function content() {
60 67
61 - do_action( 'wpbc_hook_settings_page_header', 'page_booking_listing'); // Define Notices Section and show some static messages, if needed.
68 + do_action( 'wpbc_hook_settings_page_header', 'page_booking_listing' ); // Define Notices Section and show some static messages, if needed.
62 69
63 - if ( ! wpbc_is_mu_user_can_be_here( 'activated_user' ) ) { return false; } // Check if MU user activated, otherwise show Warning message.
70 + if ( ! wpbc_is_mu_user_can_be_here( 'activated_user' ) ) {
71 + return false; // Check if MU user activated, otherwise show Warning message.
72 + }
64 73
65 -//?? if ( ! wpbc_set_default_resource_to__get() ) return false; // Define default booking resources for $_GET and check if booking resource belong to user.
66 -
67 -
68 - ////////////////////////////////////////////////////////////////////////////////////////////////////////////////
74 + // -------------------------------------------------------------------------------------------------------------
69 75 // Get and escape request parameters
70 - ////////////////////////////////////////////////////////////////////////////////////////////////////////////////
71 - $user_request = new WPBC_AJX__REQUEST( array(
72 - 'db_option_name' => 'booking_listing_request_params',
73 - 'user_id' => wpbc_get_current_user_id(),
74 - 'request_rules_structure' => wpbc_ajx_get__request_params__names_default()
75 - )
76 - );
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 + );
77 84
78 85 $escaped_search_request_params = false;
79 - // phpcs:ignore WordPress.Security.NonceVerification.Recommended, WordPress.Security.NonceVerification.Missing
80 - if ( empty( $_REQUEST['overwrite'] ) ) {
81 - $escaped_search_request_params = $user_request->get_sanitized__saved__user_request_params(); // Get Saved
82 - }
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 + }
83 90
84 91 // phpcs:ignore WordPress.Security.NonceVerification.Recommended, WordPress.Security.NonceVerification.Missing
85 92 if ( ( false === $escaped_search_request_params ) || ( ! empty( $_REQUEST['overwrite'] ) ) ) {
86 - // This request was not saved before, then get sanitized direct parameters, like: $_REQUEST['resource_id'].
87 -
93 + // This request was not saved before, then get sanitized direct parameters, like: $_REQUEST['resource_id'].
88 94 $request_prefix = false;
89 - $escaped_search_request_params = $user_request->get_sanitized__in_request__value_or_default( $request_prefix ); // Direct: $_REQUEST['resource_id'].
95 + $escaped_search_request_params = $user_request->get_sanitized__in_request__value_or_default( $request_prefix ); // Direct request: $_REQUEST['resource_id'] //.
90 96 }
91 97
92 - ////////////////////////////////////////////////////////////////////////////////////////////////////////////////
98 + // -------------------------------------------------------------------------------------------------------------
93 99
94 100
95 101 // Submit.
96 - $submit_form_name = 'wpbc_ajx_booking_form'; // Define form name.
102 + $submit_form_name = 'wpbc_ajx_booking_form'; // Define form name.
97 103
98 104 ?><span class="wpdevelop"><?php // BS UI CSS Class.
99 105
100 106 wpbc_js_for_bookings_page(); // JavaScript functions.
101 107
102 - wpbc_welcome_panel(); // Welcome Panel (links).
103 -
104 108 wpbc_ajx_bookings_toolbar( $escaped_search_request_params );
105 109
106 110 ?></span><?php // BS UI CSS Class.
107 111
112 + // TODO: continue here with this new toolbar
113 + // wpbc_ui__toolbar__bo_listing( $escaped_search_request_params );
114 +
108 115 ?><div id="wpbc_log_screen" class="wpbc_log_screen"></div><?php
109 116
110 117 // Content ----------------------------------------------------------------------------------------------------.
111 118 ?>
@@ -110,52 +117,46 @@
110 117 // Content ----------------------------------------------------------------------------------------------------.
111 118 ?>
112 119 <div class="clear" style="margin-bottom:10px;"></div>
113 120 <span class="metabox-holder">
114 - <form name="<?php echo esc_attr( $submit_form_name ); ?>" id="<?php echo esc_attr( $submit_form_name ); ?>" action="" method="post" >
115 - <?php
116 - // N o n c e field, and key for checking S u b m i t
117 - wp_nonce_field( 'wpbc_settings_page_' . $submit_form_name );
118 - ?><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
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
119 124
120 - ///wpbc_ajx_booking_modify_container_show(); // Container for showing Edit ajx_booking and define Edit and Delete ajx_booking JavaScript vars.
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
121 128
122 - ?><div class="wpbc_ajx_under_toolbar_row"><?php
129 + // wpbc_ajx_booking_modify_container_show(); // Container for showing Edit ajx_booking and define Edit and Delete ajx_booking JavaScript vars.
123 130
124 - wpbc_ajx__ui__booking_sorting( $escaped_search_request_params , wpbc_ajx_get__request_params__names_default( 'default' ) );
131 + $is_test_sql_directly = false;
132 + if ( ! $is_test_sql_directly ) {
125 133
126 - ?><div class="wpbc_ajx_booking_pagination"></div><?php // Pagination container at head
134 + $this->show_ajx_booking_listing_container_ajax( $escaped_search_request_params );
127 135
128 - // Is send Emails
129 - wpbc_ajx__ui__booking__no_toolbar__is_email_sending( $escaped_search_request_params, wpbc_ajx_get__request_params__names_default( 'default' ) ); // FixIn: 9.6.1.5.
136 + $this->show_pagination_container();
130 137
131 - ?></div><?php
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 + }
132 141
133 - wpbc_clear_div();
142 + ?><div class="clear"></div><?php
134 143
135 - $is_test_sql_directly = false;
136 - if ( ! $is_test_sql_directly ) {
144 + ?>
145 + </form>
146 + </span>
147 + <?php
137 148
138 - $this->show_ajx_booking_listing_container_ajax( $escaped_search_request_params );
149 + do_action( 'wpbc_hook_settings_page_footer', 'wpbc-ajx_booking' );
139 150
140 - $this->show_pagination_container();
151 + wpbc_welcome_panel(); // Welcome Panel (links).
141 152
142 - } else {
153 + // == Hidden Templates for - Booking Actions ==
154 + do_action( 'wpbc_hook_booking_template__hidden_templates' );
143 155
144 - $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!!
145 - }
156 + wpbc_show_booking_footer(); // Show rating line.
157 + }
146 158
147 - ?><div class="clear"></div><?php
148 -
149 - ?></form>
150 - </span>
151 - <?php
152 -
153 - do_action( 'wpbc_hook_settings_page_footer', 'wpbc-ajx_booking' );
154 -
155 - wpbc_show_booking_footer(); // Show rating line
156 - }
157 -
158 159 private function show_pagination_container(){
159 160 ?>
160 161 <div class="wpbc_ajx_booking_pagination"></div>
161 162 <?php
@@ -163,8 +164,10 @@
163 164
164 165 $wpbc_pagination = new WPBC_Pagination();
165 166 $wpbc_pagination->init( array(
166 167 'load_on_page' => 'wpbc-ajx_booking',
168 + 'container_header' => '.wpbc_ajx_booking_pagination_header',
169 + 'container_footer' => '.wpbc_ajx_booking_pagination_footer',
167 170 'container' => '.wpbc_ajx_booking_pagination',
168 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
169 172 ));
170 173
@@ -177,38 +180,55 @@
177 180 }
178 181
179 182
180 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 +
181 189 ?>
182 - <div class="wpbc_listing_container wpbc_selectable_table wpbc_ajx_booking_listing_container">
183 - <div class="wpbc_spins_loading_container">
184 - <div class="wpbc_booking_form_spin_loader">
185 - <div class="wpbc_spins_loader_wrapper">
186 - <div class="wpbc_spins_loader_mini"></div>
187 - </div>
188 - </div>
189 - <span>
190 - <?php
191 - esc_html_e( 'Loading', 'booking' );
192 - echo ' ...';
193 - ?>
194 - </span>
190 + <div class="wpbc__wrap__booking_listing">
191 + <div class="wpbc__list__table wpbc_selectable_table">
192 + <?php $this->spins_loading_container(); ?>
195 193 </div>
196 194 </div>
197 195 <script type="text/javascript">
198 196 jQuery(document).ready(function () {
199 197
200 - // Set Security - Nonce for Ajax - Listing
201 - wpbc_ajx_booking_listing.set_secure_param('nonce', '<?php echo esc_attr( wp_create_nonce( 'wpbc_ajx_booking_listing_ajx' . '_wpbcnonce' ) ); ?>');
202 - wpbc_ajx_booking_listing.set_secure_param('user_id', '<?php echo esc_attr( wpbc_get_current_user_id() ); ?>');
203 - wpbc_ajx_booking_listing.set_secure_param('locale', '<?php echo esc_attr( get_user_locale() ); ?>');
198 + var wpbc_booking_listing_wait_counter = 0;
199 + var wpbc_booking_listing_wait_timer = setInterval( function() {
204 200
205 - // Set other parameters
206 - wpbc_ajx_booking_listing.set_other_param('listing_container', '.wpbc_ajx_booking_listing_container');
207 - wpbc_ajx_booking_listing.set_other_param('pagination_container', '.wpbc_ajx_booking_pagination');
201 + wpbc_booking_listing_wait_counter++;
208 202
209 - // Send Ajax request and show listing after this.
210 - wpbc_ajx_booking_send_search_request_with_params( <?php echo wp_json_encode( $escaped_search_request_params ); ?> );
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 );
211 231 });
212 232 </script>
213 233 <?php
214 234 }
@@ -213,8 +233,32 @@
213 233 <?php
214 234 }
215 235
216 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 +
217 261 private function show_ajx_booking_listing_container_directly(){
218 262
219 263
220 264 //TODO: We need to send Ajax request and then show the listing (its will make one same way of showing listing and pagination)!
@@ -268,5 +312,6 @@
268 312
269 313 }
270 314
271 315 }
272 -add_action('wpbc_menu_created', array( new WPBC_Page_AJX_Bookings() , '__construct') ); // Executed after creation of Menu
316 +
317 +add_action( 'wpbc_menu_created', array( new WPBC_Page_AJX_Bookings(), '__construct' ) ); // Executed after creation of Menu.