<?php

namespace Bookingor\Routes;

use Bookingor\Helper\HelperControl;


class AdminRoute
{

	private static $bookedingorDb;
	/**
	 * The ID of this plugin.
	 *
	 * @since    1.0.0
	 * @access   private
	 * @var      string    $plugin_name    The ID of this plugin.
	 */
	private $plugin_name;
	/**
	 * The version of this plugin.
	 *
	 * @since    1.0.0
	 * @access   private
	 * @var      string    $version    The current version of this plugin.
	 */
	/**
	 * The version number of the class.
	 *
	 * @since 1.0.0
	 * @access private
	 * @var string $version The version number of the class.
	 */
	private $version;

	/**
	 * The prefix used for data processing.
	 *
	 * @since 1.0.0
	 * @access public
	 * @var string $dp_prefix The prefix used for data processing.
	 */
	public static $dp_prefix = "bookingor_";

	/**
	 * The result of an operation or process.
	 *
	 * @since 1.0.0
	 * @access public
	 * @var mixed $result The result of an operation or process.
	 */
	public $result;

	/**
	 * The service button configuration.
	 *
	 * @since 1.0.0
	 * @access public
	 * @var mixed $service_button The service button configuration.
	 */
	public $service_button;

	/**
	 * The payment view configuration.
	 *
	 * @since 1.0.0
	 * @access public
	 * @var mixed $payment_view The payment view configuration.
	 */
	public $payment_view;



	/**
	 * The view icon configuration.
	 *
	 * @since 1.0.0
	 * @access public
	 * @var mixed $view_icon The view icon configuration.
	 */
	public $view_icon;

	/**
	 * The default image URL.
	 *
	 * @since 1.0.0
	 * @access public
	 * @var string $default_img The default image URL.
	 */
	public static $default_img;

	/**
	 * The admin customer view configuration.
	 *
	 * @since 1.0.0
	 * @access public
	 * @var mixed $admin_customer_view The admin customer view configuration.
	 */
	public $admin_customer_view;

	/**
	 * The default staff image URL.
	 *
	 * @since 1.0.0
	 * @access public
	 * @var string $b_default_staff_img The default staff image URL.
	 */
	public $b_default_staff_img;

	/**
	 * The default image URL.
	 *
	 * @since 1.0.0
	 * @access public
	 * @var string $b_default_img The default image URL.
	 */
	public $b_default_img;


	/**
	 * The eidit image URL.
	 *
	 * @since 1.0.0
	 * @access public
	 * @var string $edit_img Edit image .
	 */
	public static $edit_img;


	/**
	 * The edit icon URL.
	 *
	 * @since 1.0.0
	 * @access public
	 * @var string $edit_img Edit icon .
	 */
	public static $edit_icon;

	/**
	 * The configuration for getting all emails.
	 *
	 * @since 1.0.0
	 * @access public
	 * @var mixed $get_all_emails The configuration for getting all emails.
	 */
	public $get_all_emails;

	/**
	 * The business icon configuration.
	 *
	 * @since 1.0.0
	 * @access public
	 * @var mixed $business_icon The business icon configuration.
	 */
	public $business_icon;
	/**
	 * Initialize the class and set its properties.
	 *
	 * @since    1.0.0
	 * @param      string    $plugin_name       The name of this plugin.
	 * @param      string    $version    The version of this plugin.
	 */
	public function __construct($plugin_name, $version)
	{
		$this->plugin_name = $plugin_name;
		$this->version = $version;
	}
	/**
	 * Register the stylesheets for the admin area.
	 *
	 * @since    1.0.0
	 */
	public function enqueue_styles()
	{
		/**
		 * This function is provided for demonstration purposes only.
		 *
		 * An instance of this class should be passed to the run() function
		 * defined in Bookingor_Loader as all of the hooks are defined
		 * in that particular class.
		 *
		 * The Bookingor_Loader will then create the relationship
		 * between the defined hooks and the functions defined in this
		 * class.
		 */
		//toaster
		wp_enqueue_style($this->plugin_name . '-toastr', plugin_dir_url(dirname(__FILE__)) . 'includes/toastr/css/jquery.toast.css', '1.0', 'all');
		// bootstrap
		wp_enqueue_style($this->plugin_name . '-bootstrap', plugin_dir_url(dirname(__FILE__)) . 'includes/bootstrap/bootstrap.min.css', '5.3.3', true);
		wp_enqueue_style($this->plugin_name, plugin_dir_url(dirname(__FILE__)) . 'Backend/assets/css/style.css', array(), $this->version, 'all');
		// year calendar
		wp_enqueue_style($this->plugin_name . '-year-calender', plugin_dir_url(dirname(__FILE__)) . 'includes/year-calendar/css/js-year-calendar.min.css', '2.0', true);
		// data tables
		wp_enqueue_style($this->plugin_name . '-datatables', plugin_dir_url(dirname(__FILE__)) . 'includes/datatables/css/datatables.css', array(), '1.0', 'all');
		//select2
		wp_enqueue_style($this->plugin_name . '-select2', plugin_dir_url(dirname(__FILE__)) . 'includes/select2/css/select2.css', array(), '1.0', 'all');
		// multiselect
		wp_enqueue_style($this->plugin_name . '-multi-select', plugin_dir_url(dirname(__FILE__)) . 'includes/multiselect/css/bootstrap-multiselect.css', array(), '2.0', 'all');
		// time picker
		wp_enqueue_style($this->plugin_name . '-jquery-timepicker', plugin_dir_url(dirname(__FILE__)) . 'includes/jonthornton-jquery-timepicker/css/jquery.timepicker.css', '1.0', 'all');
		// datepicker
		wp_enqueue_style($this->plugin_name . '-datepicker', plugin_dir_url(dirname(__FILE__)) . 'includes/datepicker/css/bootstrap-datepicker.css', '1.0', 'all');
	}
	/**
	 * Register the JavaScript for the admin area.
	 *
	 * @since    1.0.0
	 */
	public function enqueue_scripts()
	{
		/**
		 * This function is provided for demonstration purposes only.
		 *
		 * An instance of this class should be passed to the run() function
		 * defined in Bookingor_Loader as all of the hooks are defined
		 * in that particular class.
		 *
		 * The Bookingor_Loader will then create the relationship
		 * between the defined hooks and the functions defined in this
		 * class.
		 */
		wp_enqueue_media();
		if (!did_action('wp_enqueue_media')) {
			wp_enqueue_media();
		}
		wp_enqueue_script($this->plugin_name . '-letter-avatr', plugin_dir_url(dirname(__FILE__)) . 'includes/letter-avatar/letter.js', array(), '1.0.0', true);
		wp_enqueue_script($this->plugin_name . '-bootstrap-js', plugin_dir_url(dirname(__FILE__)) . 'includes/bootstrap/bootstrap.bundle.min.js', array('jquery'), '5.3.3', true);
		// select2
		wp_enqueue_script($this->plugin_name . '-select2', plugin_dir_url(dirname(__FILE__)) . 'includes/select2/js/select2.full.js', array('jquery'), '5.0.2', true);

		// multiselect
		wp_enqueue_script($this->plugin_name . '-multi-select', plugin_dir_url(dirname(__FILE__)) . 'includes/multiselect/js/bootstrap-multiselect.js', array('jquery'), "2.0.0", true);


		wp_enqueue_script($this->plugin_name . '-datatables', plugin_dir_url(dirname(__FILE__)) . 'includes/datatables/js/datatables.js', array(), '2.1.8', "all");

		wp_enqueue_script($this->plugin_name . '-datatable-row-group', plugin_dir_url(dirname(__FILE__)) . 'includes/datatables/js/dataTables.rowGroup.js', array(), '2.1.8', "all");
		wp_enqueue_script($this->plugin_name . '-datatable-group-row', plugin_dir_url(dirname(__FILE__)) . 'includes/datatables/js/rowGroup.dataTables.js', array(), '2.1.8', "all");


		// data tables
		wp_enqueue_script($this->plugin_name . '-adding-datatables', plugin_dir_url(dirname(__FILE__)) . 'Backend/assets/js/datatables.js', array('jquery'), '1.0.0', true);
		wp_enqueue_script($this->plugin_name . '-admin-clock-time', plugin_dir_url(dirname(__FILE__)) . 'includes/jonthornton-jquery-timepicker/js/jquery.timepicker.js', array(), '1.0.0', true);
		wp_enqueue_script($this->plugin_name . '-clock-timepicker', plugin_dir_url(dirname(__FILE__)) . 'Backend/assets/js/jquery-clock-timepicker.js', array(), '1.0.0', true);
		wp_enqueue_script('media-upload');
		wp_enqueue_script($this->plugin_name . '-wp-images', plugin_dir_url(dirname(__FILE__)) . 'Backend/assets/js/images/images.js', array('jquery'), $this->version, true);
		// letter avatar
		wp_enqueue_script($this->plugin_name . '-validation', plugin_dir_url(dirname(__FILE__)) . 'Backend/assets/js/validation.js', array('jquery'), $this->version, true);


		$ajax_nonce = wp_create_nonce('bookingor_ajax_nonce');
		wp_localize_script('jquery', 'TCN_BIND', array('GET_URL' => admin_url('admin-ajax.php'), 'nonce' => $ajax_nonce));


		// tostr
		wp_enqueue_script($this->plugin_name . '-toastr', plugin_dir_url(dirname(__FILE__)) . 'includes/toastr/js/jquery.toast.js', array(), '2.1.4', true);
		// datepicker
		wp_enqueue_script($this->plugin_name . '-datepicker', plugin_dir_url(dirname(__FILE__)) . 'includes/datepicker/js/bootstrap-datepicker.js', array(), '1.0.0', true);
	}
	/**
	 * Add admin menu pages
	 *
	 * @since 1.0.0
	 */

	function add_admin_pages()
	{
		if (!current_user_can('manage_options')) {
			wp_die(esc_html__('You do not have sufficient permissions to access this page.', 'bookingor'));
		}




		add_menu_page($this->plugin_name, 'Bookingor', 'manage_options', $this->plugin_name, array($this, 'admin_booking_dashboard'), plugin_dir_url(dirname(__FILE__)) . 'Backend/assets/images/svg/bookingor-admin-icon-free.svg', 26);
		add_submenu_page($this->plugin_name, 'Dashboard', 'Dashboard', 'manage_options', $this->plugin_name, array($this, 'admin_booking_dashboard'));

		global $wpdb;
		$services_table = $wpdb->prefix . self::$dp_prefix . 'services';
		$services_count = $wpdb->get_var("SELECT COUNT(*) FROM {$services_table}");

		if ((int) $services_count === 0) {
			add_submenu_page($this->plugin_name, 'Starter Installer', 'Starter Installer', 'manage_options', 'bookingor-starter-installer', array($this, 'admin_starter_installer'));
		} else {
			if (isset($_GET['page']) && $_GET['page'] === 'bookingor-starter-installer') {
				wp_safe_redirect(admin_url('admin.php?page=' . $this->plugin_name));
				exit;
			}
		}

		add_submenu_page($this->plugin_name, 'Business Profile', 'Business Profile', 'manage_options', 'bookingor-profile', array($this, 'admin_booking_business_details'));
		add_submenu_page($this->plugin_name, 'Bookings', 'Bookings', 'manage_options', 'bookingor-appointment', array($this, 'admin_booking_detail'));
		add_submenu_page($this->plugin_name, 'Category', 'Category', 'manage_options', 'bookingor-category', array($this, 'admin_booking_category'));
		add_submenu_page($this->plugin_name, 'Services', 'Services', 'manage_options', 'bookingor-services', array($this, 'admin_booking_services'));
		add_submenu_page($this->plugin_name, 'Locations', 'Locations', 'manage_options', 'bookingor-location', array($this, 'admin_booking_location'));
		add_submenu_page($this->plugin_name, 'Staff', get_option('bookingor_settings_staff_name', 'Staff'), 'manage_options', 'bookingor-staff', array($this, 'admin_booking_team'));
		add_submenu_page($this->plugin_name, 'Customer', 'Customer', 'manage_options', 'bookingor-customer', array($this, 'admin_booking_customer'));
		add_submenu_page($this->plugin_name, 'Payment', 'Payment', 'manage_options', 'bookingor-payment', array($this, 'admin_booking_payment'));
		add_submenu_page($this->plugin_name, 'Notifications', 'Notifications', 'manage_options', 'bookingor-notification', array($this, 'admin_booking_notification'));
		add_submenu_page($this->plugin_name, 'Settings', 'Settings', 'manage_options', 'bookingor-settings', array($this, 'admin_booking_settings'));
		add_submenu_page($this->plugin_name, 'Custom Fields', 'Custom Fields', 'manage_options', 'bookingor-custom-fields', array($this, 'admin_booking_custom_fields'));
		add_submenu_page($this->plugin_name, 'Design', 'Style Templates', 'manage_options', 'bookingor-design', array($this, 'admin_booking_design'));
	}
	/**
	 * Set the default image for categories and services
	 *
	 * @since 1.0.0
	 */
	public static function default_image()
	{
		self::$default_img = plugin_dir_url(dirname(dirname(__FILE__))) . 'app/Backend/assets/images/cate-serv.jpg';
		self::$edit_icon = plugin_dir_url(dirname(dirname(__FILE__))) . 'app/Backend/assets/images/view-icon.jpg';
		self::$edit_img = plugin_dir_url(dirname(dirname(__FILE__))) . 'app/Backend/assets/images/image-icon.jpg';
	}
	/**
	 * Show the design templates for bookingor
	 *
	 * @since 1.0.0
	 */
	public function admin_booking_design()
	{
		wp_enqueue_script($this->plugin_name . '-edit-templates', plugin_dir_url(dirname(__FILE__)) . 'Backend/assets/js/templates/edit-templates.js', array('jquery'), $this->version, true);
		if (isset($_GET['type']) && $_GET['type'] === 'edit-template') {
			if (!empty($_GET['id'] === '1')) {
				if (isset($_POST['nonce'])) {
					if (!wp_verify_nonce(sanitize_text_field(wp_unslash($_POST['nonce'])), 'bookingor_ajax_nonce')) {
						$response = [
							'status' => htmlspecialchars('error'),
							'message' => htmlspecialchars('Nonce verification failed.')
						];
					}
				}
				wp_enqueue_style($this->plugin_name . '-design-2', plugin_dir_url(dirname(__FILE__)) . 'Frontend/assets/css/design-1/design-1.css', [], $this->version, "all");
				wp_enqueue_style($this->plugin_name . '-design-fonts', plugin_dir_url(dirname(__FILE__)) . 'Frontend/assets/css/font.css', [], $this->version, "all");

				// datepicker
				wp_enqueue_style($this->plugin_name . '-datepicker', plugin_dir_url(dirname(__FILE__)) . 'includes/datepicker/css/bootstrap-datepicker.css', '1.0', 'all');
				ob_start();
				wp_enqueue_script('jquery');

				// datepicker
				wp_enqueue_script($this->plugin_name . '-datepicker', plugin_dir_url(dirname(__FILE__)) . 'includes/datepicker/js/bootstrap-datepicker.js', ['jquery'], '1.0.0', true);
				// letter avatar
				wp_enqueue_script($this->plugin_name . '-letter-avatr', plugin_dir_url(dirname(__FILE__)) . 'includes/letter-avatar/letter.js', [], '1.0.0', false);
				// calendar
				wp_enqueue_script($this->plugin_name . '-calendar-full', plugin_dir_url(dirname(__FILE__)) . 'includes/calendars/calendar-full.js', ['jquery'], $this->version, true);

				include plugin_dir_path(dirname(__FILE__)) . 'Backend/View/Templates/settings-design-1.php';
			} else if ($_GET['id'] === '2') {
				if (isset($_POST['nonce'])) {
					if (!wp_verify_nonce(sanitize_text_field(wp_unslash($_POST['nonce'])), 'bookingor_ajax_nonce')) {
						$response = [
							'status' => htmlspecialchars('error'),
							'message' => htmlspecialchars('Nonce verification failed.')
						];
					}
				}
				wp_enqueue_script($this->plugin_name . '-calendar-full', plugin_dir_url(dirname(__FILE__)) . 'includes/calendars/calendar-full.js', ['jquery'], $this->version, true);

				wp_enqueue_style($this->plugin_name . '-design-2', plugin_dir_url(dirname(__FILE__)) . 'Frontend/assets/css/design-2/design-2.css', [], $this->version, "all");
				wp_enqueue_style($this->plugin_name . '-design-fonts', plugin_dir_url(dirname(__FILE__)) . 'Frontend/assets/css/font.css', [], $this->version, "all");

				// datepicker
				wp_enqueue_style($this->plugin_name . '-datepicker', plugin_dir_url(dirname(__FILE__)) . 'includes/datepicker/css/bootstrap-datepicker.css', '1.0', 'all');
				ob_start();
				wp_enqueue_script('jquery');

				// datepicker
				wp_enqueue_script($this->plugin_name . '-datepicker', plugin_dir_url(dirname(__FILE__)) . 'includes/datepicker/js/bootstrap-datepicker.js', ['jquery'], '1.0.0', true);
				// inter tel

				// letter avatar
				wp_enqueue_script($this->plugin_name . '-letter-avatr', plugin_dir_url(dirname(__FILE__)) . 'includes/letter-avatar/letter.js', [], '1.0.0', false);
				// calendar
				wp_enqueue_script($this->plugin_name . '-calendar-full', plugin_dir_url(dirname(__FILE__)) . 'includes/calendars/calendar-full.js', ['jquery'], $this->version, true);

				include plugin_dir_path(dirname(__FILE__)) . 'Backend/View/Templates/settings-design-2.php';
			} else if ($_GET['id'] === '3') {
				if (isset($_POST['nonce'])) {
					if (!wp_verify_nonce(sanitize_text_field(wp_unslash($_POST['nonce'])), 'bookingor_ajax_nonce')) {
						$response = [
							'status' => htmlspecialchars('error'),
							'message' => htmlspecialchars('Nonce verification failed.')
						];
					}
				}
				wp_enqueue_style($this->plugin_name . '-design-3', plugin_dir_url(dirname(__FILE__)) . 'Frontend/assets/css/design-3/design-3.css', [], $this->version, "all");
				wp_enqueue_style($this->plugin_name . '-design-fonts', plugin_dir_url(dirname(__FILE__)) . 'Frontend/assets/css/font.css', [], $this->version, "all");

				// datepicker
				wp_enqueue_style($this->plugin_name . '-datepicker', plugin_dir_url(dirname(__FILE__)) . 'includes/datepicker/css/bootstrap-datepicker.css', '1.0', 'all');
				wp_enqueue_script('jquery');

				// datepicker
				wp_enqueue_script($this->plugin_name . '-datepicker', plugin_dir_url(dirname(__FILE__)) . 'includes/datepicker/js/bootstrap-datepicker.js', ['jquery'], '1.0.0', true);
				// inter tel

				// letter avatar
				wp_enqueue_script($this->plugin_name . '-letter-avatr', plugin_dir_url(dirname(__FILE__)) . 'includes/letter-avatar/letter.js', [], '1.0.0', false);
				// calendar
				wp_enqueue_script($this->plugin_name . '-calendar-full', plugin_dir_url(dirname(__FILE__)) . 'includes/calendars/calendar-full.js', ['jquery'], $this->version, true);
				include plugin_dir_path(dirname(__FILE__)) . 'Backend/View/Templates/settings-design-3.php';
			} else if ($_GET['id'] === '4') {
				if (isset($_POST['nonce'])) {
					if (!wp_verify_nonce(sanitize_text_field(wp_unslash($_POST['nonce'])), 'bookingor_ajax_nonce')) {
						$response = [
							'status' => htmlspecialchars('error'),
							'message' => htmlspecialchars('Nonce verification failed.')
						];
					}
				}
				wp_enqueue_style($this->plugin_name . '-design-4', plugin_dir_url(dirname(__FILE__)) . 'Frontend/assets/css/design-4/design-4.css', [], $this->version, "all");
				wp_enqueue_style($this->plugin_name . '-design-fonts', plugin_dir_url(dirname(__FILE__)) . 'Frontend/assets/css/font.css', [], $this->version, "all");

				wp_enqueue_script('jquery');

				// datepicker
				wp_enqueue_script($this->plugin_name . '-datepicker', plugin_dir_url(dirname(__FILE__)) . 'includes/datepicker/js/bootstrap-datepicker.js', ['jquery'], '1.0.0', true);
				// inter tel

				// letter avatar
				wp_enqueue_script($this->plugin_name . '-letter-avatr', plugin_dir_url(dirname(__FILE__)) . 'includes/letter-avatar/letter.js', [], '1.0.0', false);
				// calendar
				wp_enqueue_script($this->plugin_name . '-calendar-full', plugin_dir_url(dirname(__FILE__)) . 'includes/calendars/calendar-full.js', ['jquery'], $this->version, true);

				include plugin_dir_path(dirname(__FILE__)) . 'Backend/View/Templates/settings-design-4.php';
			} else if ($_GET['id'] === '5') {
				if (isset($_POST['nonce'])) {
					if (!wp_verify_nonce(sanitize_text_field(wp_unslash($_POST['nonce'])), 'bookingor_ajax_nonce')) {
						$response = [
							'status' => htmlspecialchars('error'),
							'message' => htmlspecialchars('Nonce verification failed.')
						];
					}
				}
				wp_enqueue_style($this->plugin_name . '-design-5', plugin_dir_url(dirname(__FILE__)) . 'Frontend/assets/css/design-5/design-5.css', [], $this->version, "all");
				wp_enqueue_style($this->plugin_name . '-design-fonts', plugin_dir_url(dirname(__FILE__)) . 'Frontend/assets/css/font.css', [], $this->version, "all");

				wp_enqueue_script('jquery');
				wp_enqueue_script($this->plugin_name . '-slick', plugin_dir_url(dirname(__FILE__)) . 'includes/slick/slick.js', ['jquery'], $this->version, true);
				wp_enqueue_script($this->plugin_name . '-calendar-full', plugin_dir_url(dirname(__FILE__)) . 'includes/calendars/calendar-full.js', ['jquery'], $this->version, true);

				wp_enqueue_script('moment');

				// datepicker
				wp_enqueue_script($this->plugin_name . '-datepicker', plugin_dir_url(dirname(__FILE__)) . 'includes/datepicker/js/bootstrap-datepicker.js', ['jquery'], '1.0.0', true);
				// inter tel

				// letter avatar
				wp_enqueue_script($this->plugin_name . '-letter-avatr', plugin_dir_url(dirname(__FILE__)) . 'includes/letter-avatar/letter.js', [], '1.0.0', false);
				// calendar

				wp_enqueue_script($this->plugin_name . '-widget-calendar', plugin_dir_url(dirname(__FILE__)) . 'includes/calendars/widget-calendar-final.js', ['jquery'], $this->version, true);


				include plugin_dir_path(dirname(__FILE__)) . 'Backend/View/Templates/settings-design-5.php';
			} else if ($_GET['id'] === '6') {
				if (isset($_POST['nonce'])) {
					if (!wp_verify_nonce(sanitize_text_field(wp_unslash($_POST['nonce'])), 'bookingor_ajax_nonce')) {
						$response = [
							'status' => htmlspecialchars('error'),
							'message' => htmlspecialchars('Nonce verification failed.')
						];
					}
				}
				wp_enqueue_style($this->plugin_name . '-design-5', plugin_dir_url(dirname(__FILE__)) . 'Frontend/assets/css/design-6/design-6.css', [], $this->version, "all");
				wp_enqueue_style($this->plugin_name . '-design-fonts', plugin_dir_url(dirname(__FILE__)) . 'Frontend/assets/css/font.css', [], $this->version, "all");

				wp_enqueue_script('jquery');

				// datepicker
				wp_enqueue_script($this->plugin_name . '-datepicker', plugin_dir_url(dirname(__FILE__)) . 'includes/datepicker/js/bootstrap-datepicker.js', ['jquery'], '1.0.0', true);
				// inter tel

				// letter avatar
				wp_enqueue_script($this->plugin_name . '-letter-avatr', plugin_dir_url(dirname(__FILE__)) . 'includes/letter-avatar/letter.js', [], '1.0.0', false);
				// calendar
				wp_enqueue_script($this->plugin_name . '-calendar-full', plugin_dir_url(dirname(__FILE__)) . 'includes/calendars/calendar-full.js', ['jquery'], $this->version, true);
				include plugin_dir_path(dirname(__FILE__)) . 'Backend/View/Templates/settings-design-6.php';
			} else if ($_GET['id'] === '8') {
				if (isset($_POST['nonce'])) {
					if (!wp_verify_nonce(sanitize_text_field(wp_unslash($_POST['nonce'])), 'bookingor_ajax_nonce')) {
						$response = [
							'status' => htmlspecialchars('error'),
							'message' => htmlspecialchars('Nonce verification failed.')
						];
					}
				}
				wp_enqueue_style($this->plugin_name . '-design-category', plugin_dir_url(dirname(__FILE__)) . 'Frontend/assets/css/design-start/design-category.css', [], $this->version, "all");
				wp_enqueue_style($this->plugin_name . '-design-fonts', plugin_dir_url(dirname(__FILE__)) . 'Frontend/assets/css/font.css', [], $this->version, "all");

				wp_enqueue_script('jquery');

				// datepicker
				wp_enqueue_script($this->plugin_name . '-datepicker', plugin_dir_url(dirname(__FILE__)) . 'includes/datepicker/js/bootstrap-datepicker.js', ['jquery'], '1.0.0', true);

				// letter avatar
				wp_enqueue_script($this->plugin_name . '-letter-avatr', plugin_dir_url(dirname(__FILE__)) . 'includes/letter-avatar/letter.js', [], '1.0.0', false);
				// calendar
				wp_enqueue_script($this->plugin_name . '-calendar-full', plugin_dir_url(dirname(__FILE__)) . 'includes/calendars/calendar-full.js', ['jquery'], $this->version, true);
				include plugin_dir_path(dirname(__FILE__)) . 'Backend/View/Templates/settings-design-category.php';
			} else if ($_GET['id'] === '9') {
				if (isset($_POST['nonce'])) {
					if (!wp_verify_nonce(sanitize_text_field(wp_unslash($_POST['nonce'])), 'bookingor_ajax_nonce')) {
						$response = [
							'status' => htmlspecialchars('error'),
							'message' => htmlspecialchars('Nonce verification failed.')
						];
					}
				}
				wp_enqueue_style($this->plugin_name . '-design-service', plugin_dir_url(dirname(__FILE__)) . 'Frontend/assets/css/design-start/design-service.css', [], $this->version, "all");
				wp_enqueue_style($this->plugin_name . '-design-fonts', plugin_dir_url(dirname(__FILE__)) . 'Frontend/assets/css/font.css', [], $this->version, "all");

				wp_enqueue_script('jquery');

				// datepicker
				wp_enqueue_script($this->plugin_name . '-datepicker', plugin_dir_url(dirname(__FILE__)) . 'includes/datepicker/js/bootstrap-datepicker.js', ['jquery'], '1.0.0', true);

				// letter avatar
				wp_enqueue_script($this->plugin_name . '-letter-avatr', plugin_dir_url(dirname(__FILE__)) . 'includes/letter-avatar/letter.js', [], '1.0.0', false);
				// calendar
				wp_enqueue_script($this->plugin_name . '-calendar-full', plugin_dir_url(dirname(__FILE__)) . 'includes/calendars/calendar-full.js', ['jquery'], $this->version, true);
				include plugin_dir_path(dirname(__FILE__)) . 'Backend/View/Templates/settings-design-services.php';
			} else if ($_GET['id'] === '10') {
				if (isset($_POST['nonce'])) {
					if (!wp_verify_nonce(sanitize_text_field(wp_unslash($_POST['nonce'])), 'bookingor_ajax_nonce')) {
						$response = [
							'status' => htmlspecialchars('error'),
							'message' => htmlspecialchars('Nonce verification failed.')
						];
					}
				}
				wp_enqueue_style($this->plugin_name . '-design-staff', plugin_dir_url(dirname(__FILE__)) . 'Frontend/assets/css/design-start/design-staff.css', [], $this->version, "all");
				wp_enqueue_style($this->plugin_name . '-design-fonts', plugin_dir_url(dirname(__FILE__)) . 'Frontend/assets/css/font.css', [], $this->version, "all");

				wp_enqueue_script('jquery');

				// datepicker
				wp_enqueue_script($this->plugin_name . '-datepicker', plugin_dir_url(dirname(__FILE__)) . 'includes/datepicker/js/bootstrap-datepicker.js', ['jquery'], '1.0.0', true);

				// letter avatar
				wp_enqueue_script($this->plugin_name . '-letter-avatr', plugin_dir_url(dirname(__FILE__)) . 'includes/letter-avatar/letter.js', [], '1.0.0', false);
				// calendar
				wp_enqueue_script($this->plugin_name . '-calendar-full', plugin_dir_url(dirname(__FILE__)) . 'includes/calendars/calendar-full.js', ['jquery'], $this->version, true);
				include plugin_dir_path(dirname(__FILE__)) . 'Backend/View/Templates/settings-design-staff.php';
			}
		} else {
			include plugin_dir_path(dirname(__FILE__)) . 'Backend/View/Templates/Templates.php';
		}
	}
	/**
	 * Set the add booking button URL
	 *
	 * @since 1.0.0
	 */
	function bp_add_boooking_buttons()
	{
		$this->service_button = admin_url('admin.php?page=booking-services' . '&type=add');
	}

	/**
	 * Renders the dashboard page
	 *
	 * @since 1.0.0
	 */
	public function admin_booking_dashboard()
	{

		if (!current_user_can('manage_options')) {
			wp_die(esc_html__('You do not have sufficient permissions to access this page.', 'bookingor'));
		}
		require_once plugin_dir_path(dirname(__FILE__)) . 'Backend/View/Dashboard/DashboardView.php';

		wp_enqueue_script($this->plugin_name . '-steps', plugin_dir_url(dirname(__FILE__)) . 'includes/jquery-steps/jquery.steps.min.js', array('jquery'), $this->version, true);

		wp_enqueue_style($this->plugin_name . '-steps', plugin_dir_url(dirname(__FILE__)) . 'includes/jquery-steps/jquery.steps.css', [], $this->version, "all");
		wp_enqueue_script($this->plugin_name . '-charts-data', plugin_dir_url(dirname(__FILE__)) . 'Backend/assets/js/dashboard/chart.js', array('jquery'), $this->version, true);
		wp_enqueue_script($this->plugin_name . '-charts-show-data', plugin_dir_url(dirname(__FILE__)) . 'Backend/assets/js/dashboard/dashboard.js', array('jquery'), $this->version, true);
	}

	public function admin_starter_installer()
	{
		if (!current_user_can('manage_options')) {
			wp_die(esc_html__('You do not have sufficient permissions to access this page.', 'bookingor'));
		}
		require_once plugin_dir_path(dirname(__FILE__)) . 'Backend/View/starter/starter-installer.php';

		// Enqueue Bootstrap (already loaded by enqueue_styles/scripts in many cases, but ensuring dependency)
		// Note: AdminRoute::enqueue_styles/scripts are registered globally for admin pages effectively via loader usually, 
		// but here we just need to make sure our specific assets are loaded.

		// Custom Wizard Assets
		wp_enqueue_style($this->plugin_name . '-starter-css', plugin_dir_url(dirname(__FILE__)) . 'Backend/assets/css/starter.css', array(), $this->version, "all");

		// Timepicker Assets
		wp_enqueue_style($this->plugin_name . '-jquery-timepicker', plugin_dir_url(dirname(__FILE__)) . 'includes/jonthornton-jquery-timepicker/css/jquery.timepicker.css', '1.0', 'all');
		wp_enqueue_script($this->plugin_name . '-admin-clock-time', plugin_dir_url(dirname(__FILE__)) . 'includes/jonthornton-jquery-timepicker/js/jquery.timepicker.js', array('jquery'), '1.0.0', true);

		wp_enqueue_script($this->plugin_name . '-starter-js', plugin_dir_url(dirname(__FILE__)) . 'Backend/assets/js/starter/starter.js', array('jquery'), $this->version, true);

		$ajax_nonce = wp_create_nonce('bookingor_ajax_nonce');

		global $wpdb;
		$services_table = $wpdb->prefix . self::$dp_prefix . 'services';
		$services_count = $wpdb->get_var("SELECT COUNT(*) FROM {$services_table}");

		wp_localize_script($this->plugin_name . '-starter-js', 'bookingor_starter_local', array('ajax_url' => admin_url('admin-ajax.php'), 'nonce' => $ajax_nonce, 'services_count' => (int)$services_count));
	}

	/**
	 * Renders the business details page.
	 *
	 * @since 1.0.0
	 */
	public function admin_booking_business_details()
	{
		if (!current_user_can('manage_options')) {
			wp_die(esc_html__('You do not have sufficient permissions to access this page.', 'bookingor'));
		} else {
			$this->business_icon = plugin_dir_url(dirname(__FILE__)) . 'Backend/assets/images/icons-business.jpg';
			include plugin_dir_path(dirname(__FILE__)) . 'Backend/View/BusinessProfile/BusinessProfile.php';
			wp_enqueue_script($this->plugin_name . '-business-profile', plugin_dir_url(dirname(__FILE__)) . 'Backend/assets/js/business-profile/business-profile.js', array('jquery'), $this->version, true);
		}
	}

	/**
	 * Admin booking category
	 *
	 * This function is used to create, edit and view categories
	 *
	 * @since 1.0.0
	 */
	public function admin_booking_category()
	{
		if (!current_user_can('manage_options')) {
			wp_die(esc_html__('You do not have sufficient permissions to access this page.', 'bookingor'));
		}
		require_once plugin_dir_path(dirname(__FILE__)) . 'Backend/View/Category/CategoryView.php';
		require_once plugin_dir_path(dirname(__FILE__)) . 'Backend/View/Category/CategoryCreate.php';
		require_once plugin_dir_path(dirname(__FILE__)) . 'Backend/View/Category/CategoryEdit.php';
		wp_enqueue_script($this->plugin_name . '-category-back', plugin_dir_url(dirname(__FILE__)) . 'Backend/assets/js/category/category.js', array('jquery'), $this->version, true);
	}
	/**
	 * Admin booking coupon
	 *
	 * This function is used to create, edit and view coupon
	 *
	 * It loads the add-on helper class and includes the coupon_create.php, coupon_edit.php or coupon_view.php partials
	 * based on the $_GET['type'] parameter.
	 *
	 * It also enqueues the coupon.js script
	 *
	 * @since 1.0.0
	 */
	public function admin_booking_coupon()
	{
		if (!current_user_can('manage_options')) {
			wp_die(esc_html__('You do not have sufficient permissions to access this page.', 'bookingor'));
		}
		require_once plugin_dir_path(__FILE__) . './partials/coupon/coupon_view.php';
		require_once plugin_dir_path(__FILE__) . './partials/coupon/coupon_create.php';
		require_once plugin_dir_path(__FILE__) . './partials/coupon/coupon_edit.php';
		wp_enqueue_script($this->plugin_name . '-coupon', plugin_dir_url(dirname(__FILE__)) . 'Backend/assets/js/coupon/coupon.js', array('jquery'), $this->version, true);
	}
	/**
	 * Admin booking services
	 *
	 * This function is used to create, edit and view services
	 *
	 * It loads the add-on helper class and includes the service_create.php, service_edit.php or service_view.php partials
	 * based on the $_GET['type'] parameter.
	 *
	 * It also enqueues the service.js script
	 *
	 * @since 1.0.0
	 */
	public function admin_booking_services()
	{
		if (!current_user_can('manage_options')) {
			wp_die(esc_html__('You do not have sufficient permissions to access this page.', 'bookingor'));
		}
		if (isset($_GET['type']) && $_GET['type'] === 'add-service') {
			if (isset($_POST['nonce'])) {
				if (!wp_verify_nonce(sanitize_text_field(wp_unslash($_POST['nonce'])), 'bookingor_ajax_nonce')) {
					$response = [
						'status' => htmlspecialchars('error'),
						'message' => htmlspecialchars('Nonce verification failed.')
					];
				}
			}
			include plugin_dir_path(dirname(__FILE__)) . 'Backend/View/Services/ServiceCreate.php';
		} else if (isset($_GET['type']) && $_GET['type'] === 'edit-service') {
			if (isset($_POST['nonce'])) {
				if (!wp_verify_nonce(sanitize_text_field(wp_unslash($_POST['nonce'])), 'bookingor_ajax_nonce')) {
					$response = [
						'status' => htmlspecialchars('error'),
						'message' => htmlspecialchars('Nonce verification failed.')
					];
				}
			}
			include plugin_dir_path(dirname(__FILE__)) . 'Backend/View/Services/ServiceEdit.php';
		} else {
			include plugin_dir_path(dirname(__FILE__)) . 'Backend/View/Services/ServiceView.php';
		}

		if (is_plugin_active("bookingor-service-schedule/bookingor-service-schedule.php")) {
			$file_path = plugins_url('bookingor-service-schedule/app/assets/js/service-schedule-admin.js');
			wp_enqueue_script($this->plugin_name . '-services-schedule', $file_path, array(), '1.0.0', true);
		}

		wp_enqueue_script($this->plugin_name . '-services-back', plugin_dir_url(dirname(__FILE__)) . 'Backend/assets/js/service/service.js', array('jquery'), $this->version, true);
	}

	/**
	 * Booking settings
	 *	
	 * This function is used to create, edit and view settings
	 *
	 * @since 1.0.0
	 */
	public function admin_booking_settings()
	{
		if (!current_user_can('manage_options')) {
			wp_die(esc_html__('You do not have sufficient permissions to access this page.', 'bookingor'));
		}
		require_once plugin_dir_path(dirname(__FILE__)) . 'Backend/View/Settings/Settings.php';
		wp_enqueue_script($this->plugin_name . '-settings-back', plugin_dir_url(dirname(__FILE__)) . 'Backend/assets/js/settings/settings.js', array('jquery'), $this->version, true);
		wp_enqueue_script($this->plugin_name . '-integration', plugin_dir_url(dirname(__FILE__)) . 'Backend/assets/js/settings/integration.js', array('jquery'), $this->version, true);
	}
	/**
	 * Staff
	 *
	 * This function is used to create, edit and view staff
	 *
	 * @since 1.0.0
	 */
	public function admin_booking_team()
	{
		if (!current_user_can('manage_options')) {
			wp_die(esc_html__('You do not have sufficient permissions to access this page.', 'bookingor'));
		}
		if (isset($_GET['type']) && $_GET['type'] === 'add-team') {
			if (isset($_POST['nonce'])) {
				if (!wp_verify_nonce(sanitize_text_field(wp_unslash($_POST['nonce'])), 'bookingor_ajax_nonce')) {
					$response = [
						'status' => htmlspecialchars('error'),
						'message' => htmlspecialchars('Nonce verification failed.')
					];
				}
			}
			include plugin_dir_path(dirname(__FILE__)) . 'Backend/View/Staff/StaffCreate.php';
		} else if (isset($_GET['type']) && $_GET['type'] === 'edit-team') {
			if (isset($_POST['nonce'])) {
				if (!wp_verify_nonce(sanitize_text_field(wp_unslash($_POST['nonce'])), 'bookingor_ajax_nonce')) {
					$response = [
						'status' => htmlspecialchars('error'),
						'message' => htmlspecialchars('Nonce verification failed.')
					];
				}
			}
			include plugin_dir_path(dirname(__FILE__)) . 'Backend/View/Staff/StaffEdit.php';
		} else {
			include plugin_dir_path(dirname(__FILE__)) . 'Backend/View/Staff/StaffView.php';
		}
		wp_enqueue_script($this->plugin_name . '-admin-staff', plugin_dir_url(dirname(__FILE__)) . 'Backend/assets/js/staff/staff.js', array('jquery'), $this->version, true);
		wp_enqueue_script($this->plugin_name . '-year-calender', plugin_dir_url(dirname(__FILE__)) . 'includes/year-calendar/js/js-year-calendar.js', array('jquery'), $this->version, true);
	}
	/**
	 * Admin booking payment
	 *
	 * This function is used to view all payment.
	 *
	 * @since   1.0.0
	 *
	 * @return void
	 */
	public function admin_booking_payment()
	{
		if (!current_user_can('manage_options')) {
			wp_die(esc_html__('You do not have sufficient permissions to access this page.', 'bookingor'));
		}
		include plugin_dir_path(dirname(__FILE__)) . 'Backend/View/Payment/PaymentView.php';
		wp_enqueue_script('payment', plugin_dir_url(dirname(__FILE__)) . 'Backend/assets/js/payment/payment.js', array('jquery'), $this->version, true);
	}
	/**
	 * Admin booking notification
	 *
	 * This function is used to create, edit and view notifications
	 *
	 * It enqueues the quill editor and notification js files and includes the notification.php partial
	 *
	 * @since 1.0.0
	 */
	public function admin_booking_notification()
	{
		if (!current_user_can('manage_options')) {
			wp_die(esc_html__('You do not have sufficient permissions to access this page.', 'bookingor'));
		}
		wp_enqueue_style($this->plugin_name . '-quill-css', plugin_dir_url(dirname(__FILE__)) . 'Backend/View/Notification/assets/css/quill.snow.css', array(), "1.3.7", 'all');
		wp_enqueue_script($this->plugin_name . '-email-notifi', plugin_dir_url(dirname(__FILE__)) . 'Backend/View/Notification/assets/js/notification.js', array('jquery'), $this->version, true);
		wp_enqueue_script($this->plugin_name . '-quill-editor', plugin_dir_url(dirname(__FILE__)) . 'Backend/View/Notification/assets/js/quill.js', array('jquery'), $this->version, true);
		wp_enqueue_script($this->plugin_name . '-quill-code', plugin_dir_url(dirname(__FILE__)) . 'Backend/assets/js/notification/quill-add.js', array('jquery'), $this->version, true);
		include plugin_dir_path(dirname(__FILE__)) . 'Backend/View/Notification/Notification.php';
	}
	/**
	 * Admin booking location
	 *
	 * This function is used to create, edit and view locations
	 *
	 * @since 1.0.0
	 */
	public function admin_booking_location()
	{
		if (!current_user_can('manage_options')) {
			wp_die(esc_html__('You do not have sufficient permissions to access this page.', 'bookingor'));
		}

		include plugin_dir_path(dirname(__FILE__)) . 'Backend/View/Location/LocationView.php';
		include plugin_dir_path(dirname(__FILE__)) . 'Backend/View/Location/LocationCreate.php';
		include plugin_dir_path(dirname(__FILE__)) . 'Backend/View/Location/LocationEdit.php';
		wp_enqueue_script($this->plugin_name . '-bk-location', plugin_dir_url(dirname(__FILE__)) . 'Backend/assets/js/location/backend-location.js', array('jquery'), $this->version, true);
		if (is_plugin_active("bookingor-google-maps/bookingor-google-maps.php")) {
			$file_path = plugins_url('bookingor-google-maps/admin/js/bookingor-google-maps-admin.js');
			wp_enqueue_script($this->plugin_name . '-location-google-maps', $file_path, array(), '1.0.0', true);
		}
	}
	/**
	 * Customers page
	 *
	 * @since   1.0.0
	 *
	 * @return void
	 */
	public function admin_booking_customer()
	{
		if (!current_user_can('manage_options')) {
			wp_die(esc_html__('You do not have sufficient permissions to access this page.', 'bookingor'));
		}
		include plugin_dir_path(dirname(__FILE__)) . 'Backend/View/Customer/Customer.php';
		wp_enqueue_script($this->plugin_name . '-customer', plugin_dir_url(dirname(__FILE__)) . 'Backend/assets/js/customer/customer.js', array('jquery'), $this->version, true);
	}
	public function admin_booking_detail()
	{
		wp_enqueue_script($this->plugin_name . '-booking', plugin_dir_url(dirname(__FILE__)) . 'Backend/assets/js/booking/booking.js', array('jquery'), $this->version, true);
		include plugin_dir_path(dirname(__FILE__)) . 'Backend/View/Bookings/BookingsView.php';
	}

	/**
	 * Renders the Custom Fields promotional page.
	 *
	 * @since 1.0.0
	 */
	public function admin_booking_custom_fields()
	{
		if (!current_user_can('manage_options')) {
			wp_die(esc_html__('You do not have sufficient permissions to access this page.', 'bookingor'));
		}
		include plugin_dir_path(dirname(__FILE__)) . 'Backend/View/CustomFields/CustomFields.php';
	}
	public function email_data_insert()
	{
		global $wpdb;
		self::$bookedingorDb = $wpdb;
		$table_name = $wpdb->prefix . self::$dp_prefix . 'notifications';
		$dataArray = HelperControl::email_seeder_customer();
		// Data does not exist, insert it
		foreach ($dataArray as $data) {
			self::$bookedingorDb->insert($table_name, self::$bookedingorDb->prepare($data));
			$my_id = $wpdb->insert_id;
		}
	}

	/**
	 * Check for activation redirect transient and redirect if exists.
	 *
	 * @since 1.0.0
	 */
	public function check_activation_redirect()
	{
		if (get_transient('bookingor_activation_redirect')) {
			delete_transient('bookingor_activation_redirect');
			wp_safe_redirect(admin_url('admin.php?page=bookingor-starter-installer'));
			exit;
		}
	}
}
