| @@ -19,143 +19,144 @@ | ||
| 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 | - if ( empty( $_REQUEST['overwrite'] ) ) { | |
| 80 | - $escaped_search_request_params = $user_request->get_sanitized__saved__user_request_params(); // Get Saved | |
| 81 | - } | |
| 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 | + } | |
| 82 | 90 | |
| 83 | - if ( | |
| 84 | - ( false === $escaped_search_request_params ) | |
| 85 | - || ( ! empty( $_REQUEST['overwrite'] ) ) | |
| 86 | - ){ // This request was not saved before, then get sanitized direct parameters, like: $_REQUEST['resource_id'] | |
| 87 | - | |
| 88 | - $request_prefix = false; | |
| 89 | - $escaped_search_request_params = $user_request->get_sanitized__in_request__value_or_default( $request_prefix ); // Direct: $_REQUEST['resource_id'] | |
| 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'] //. | |
| 90 | 96 | } |
| 91 | 97 | |
| 92 | - //////////////////////////////////////////////////////////////////////////////////////////////////////////////// | |
| 98 | + // ------------------------------------------------------------------------------------------------------------- | |
| 93 | 99 | |
| 94 | 100 | |
| 95 | - // Submit ///////////////////////////////////////////////////////////// | |
| 96 | - $submit_form_name = 'wpbc_ajx_booking_form'; // Define form name | |
| 101 | + // Submit. | |
| 102 | + $submit_form_name = 'wpbc_ajx_booking_form'; // Define form name. | |
| 97 | 103 | |
| 98 | - ?><span class="wpdevelop"><?php // BS UI CSS Class | |
| 104 | + ?><span class="wpdevelop"><?php // BS UI CSS Class. | |
| 99 | 105 | |
| 100 | - wpbc_js_for_bookings_page(); // JavaScript functions | |
| 106 | + wpbc_js_for_bookings_page(); // JavaScript functions. | |
| 101 | 107 | |
| 102 | - wpbc_welcome_panel(); // Welcome Panel (links) | |
| 108 | + wpbc_ajx_bookings_toolbar( $escaped_search_request_params ); | |
| 103 | 109 | |
| 104 | - wpbc_ajx_bookings_toolbar( $escaped_search_request_params ); | |
| 110 | + ?></span><?php // BS UI CSS Class. | |
| 105 | 111 | |
| 106 | - ?></span><?php // BS UI CSS Class | |
| 112 | + // TODO: continue here with this new toolbar | |
| 113 | + // wpbc_ui__toolbar__bo_listing( $escaped_search_request_params ); | |
| 107 | 114 | |
| 108 | 115 | ?><div id="wpbc_log_screen" class="wpbc_log_screen"></div><?php |
| 109 | 116 | |
| 110 | - // Content //////////////////////////////////////////////////////////// | |
| 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 $submit_form_name; ?>" id="<?php echo $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 $submit_form_name; ?>" id="is_form_sbmitted_<?php echo $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 | |
| @@ -176,36 +179,84 @@ | ||
| 176 | 179 | /**/ |
| 177 | 180 | } |
| 178 | 181 | |
| 179 | 182 | |
| 180 | - private function show_ajx_booking_listing_container_ajax( $escaped_search_request_params ) { | |
| 183 | + private function show_ajx_booking_listing_container_ajax( $escaped_search_request_params ) { | |
| 181 | 184 | |
| 182 | - ?> | |
| 183 | - <div class="wpbc_listing_container wpbc_selectable_table wpbc_ajx_booking_listing_container"> | |
| 184 | - <?php // New Spinner Loader //FixIn: 10.0.0.25 ?> | |
| 185 | - <div class="wpbc_spins_loading_container" > | |
| 186 | - <div class="wpbc_booking_form_spin_loader" ><div class="wpbc_spins_loader_wrapper"><div class="wpbc_spins_loader_mini"></div></div></div> | |
| 187 | - <span><?php _e('Loading','booking'); ?> ...</span> | |
| 188 | - </div> | |
| 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(); ?> | |
| 189 | 193 | </div> |
| 190 | - <script type="text/javascript"> | |
| 191 | - jQuery( document ).ready( function (){ | |
| 194 | + </div> | |
| 195 | + <script type="text/javascript"> | |
| 196 | + jQuery(document).ready(function () { | |
| 192 | 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 | + | |
| 193 | 216 | // Set Security - Nonce for Ajax - Listing |
| 194 | - wpbc_ajx_booking_listing.set_secure_param( 'nonce', '<?php echo wp_create_nonce( 'wpbc_ajx_booking_listing_ajx' . '_wpbcnonce' ) ?>' ); | |
| 195 | - wpbc_ajx_booking_listing.set_secure_param( 'user_id', '<?php echo wpbc_get_current_user_id(); ?>' ); | |
| 196 | - wpbc_ajx_booking_listing.set_secure_param( 'locale', '<?php echo get_user_locale(); ?>' ); | |
| 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() ); ?>' ); | |
| 197 | 220 | |
| 198 | 221 | // Set other parameters |
| 199 | - wpbc_ajx_booking_listing.set_other_param( 'listing_container', '.wpbc_ajx_booking_listing_container' ); | |
| 222 | + wpbc_ajx_booking_listing.set_other_param( 'listing_container', '.wpbc__list__table' ); | |
| 223 | + | |
| 200 | 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' ); | |
| 201 | 227 | |
| 202 | 228 | // Send Ajax request and show listing after this. |
| 203 | 229 | wpbc_ajx_booking_send_search_request_with_params( <?php echo wp_json_encode( $escaped_search_request_params ); ?> ); |
| 204 | - } ); | |
| 205 | - </script> | |
| 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> | |
| 206 | 251 | <?php |
| 207 | - } | |
| 252 | + esc_html_e( 'Loading', 'booking' ); | |
| 253 | + echo ' ...'; | |
| 254 | + ?> | |
| 255 | + </span> | |
| 256 | + </div> | |
| 257 | + <?php | |
| 258 | + } | |
| 208 | 259 | |
| 209 | 260 | |
| 210 | 261 | private function show_ajx_booking_listing_container_directly(){ |
| 211 | 262 | |
| @@ -261,5 +312,6 @@ | ||
| 261 | 312 | |
| 262 | 313 | } |
| 263 | 314 | |
| 264 | 315 | } |
| 265 | -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. | |