<?php

/**
 * JT Admin Settings Design Class
 */

if (!class_exists('WPBOOKIT_Settings_Bookings', false)):

	/**
	 * WPB_Settings_calender Class.
	 */
	class WPBOOKIT_Settings_Bookings extends WPBOOKIT_Setting_Page
	{
		public $per_page;
		public $id;

		function __construct()
		{
			$this->id 			= 'bookings';
			$this->label 		= esc_html__('Bookings', 'wpbookit');
			$this->icon 		= IQWPB_PLUGIN_PATH . '/core/admin/assets/images/menu-icons/calender-icon.svg';
			$this->per_page 	= 5;
			$this->type         = esc_html__( 'COMPANY', 'wpbookit' );
			$this->priority     = 30; 

			parent::__construct();
		}

		public static function get_table_column() {
			return apply_filters(
				'wpbookit_bookings_columns',
				array(
					'booking-name' 				=> esc_html__( 'Customer', 'wpbookit' ),
					'booking-date'    			=> esc_html__( 'Date and Time', 'wpbookit' ),
					'booking-type'  			=> esc_html__( 'Type', 'wpbookit' ),
					'booking-duration'  		=> esc_html__( 'Duration', 'wpbookit' ),
					'booking-price'  			=> esc_html__( 'Total Price', 'wpbookit' ),
					'booking-status' 			=> esc_html__( 'Status', 'wpbookit' ),
					'booking-actions' 			=> esc_html__( 'Actions', 'wpbookit' ),
				)
			);
		}

		public function get_bookings( $current_page = 1 ) {
			return (object)['results'=>[],'total'=>25,'maxnumpages'=>10];
			
		}
	

		public function get_settings_html() {
			// phpcs:ignore WordPress.Security.NonceVerification.Recommended -- This is for pagination display, not processing form data
			$current_page 			= isset($_GET['paged']) ? sanitize_text_field(wp_unslash($_GET['paged'])) : 1;
			$columns 				= self::get_table_column();

			$statuses 				= wpbookit_get_booking_statuses();
			$payment_statuses 		= wpbookit_get_booking_payment_statuses();
			$booking_types 			= wpbookit_get_all_booking_types(
				array(
					'staff'	=> current_user_can('administrator') ? 0 : get_current_user_id(),
					"per_page" => 99
				)
			);

			$payment_modes 			= wpbookit_get_booking_modes();
			$customers 				= wpbookit_get_customers();

			$bookings 				= $this->get_bookings( $current_page );
			
			$CustomersObj        	= new WPBOOKIT_Settings_Customer();
			$CustomerEntry			= $CustomersObj->get_all_customers();
			$all_customers         	= $CustomerEntry->get_results();

			include IQWPB_PLUGIN_PATH . '/core/admin/views/settings/html-admin-settings-bookings.php';
		}
	}

	new WPBOOKIT_Settings_Bookings();
endif;
