<?php

namespace Bookingor\Frontend\Controller\Category;

class CategoryControlFront
{

	private static $bookingorDb;
	public static $f_category;
	public static $f_subcategory;
	public static $f_service_subcategory;
	public static $f_widget_category;
	public static $f_currency_symbol;
	public static $dp_prefix = "bookingor_";
	/**
	 * Retrieves all categories from the database that are active.
	 *
	 * This function retrieves category data from the database and returns it as an array.
	 * The function is used to populate the category dropdown in the frontend search form.
	 *
	 * @global wpdb $wpdb WordPress database object.
	 * @return array An array of category data containing the category ID, icon, and category name.
	 */
	public static function bp_font_category_view($category_get_id = null)
	{
		global $wpdb;
		self::$bookingorDb = $wpdb;
		$category = $wpdb->prefix . self::$dp_prefix . '';
		$category_id = $category_get_id;
		if (!empty($category_id)) {
			// If a specific category ID is provided, retrieve that category
			return self::$f_category = self::$bookingorDb->get_results($wpdb->prepare("SELECT category_id, icon, category_name FROM {$wpdb->prefix}bookingor_categories WHERE status = %d AND category_id = %d", 1, $category_id));
		} else {
			return self::$f_category = self::$bookingorDb->get_results($wpdb->prepare("SELECT category_id, icon, category_name FROM  {$wpdb->prefix}bookingor_categories WHERE status = %d", 1));
		}
	}
	/**
	 * Retrieves all categories from the database that are active.
	 *
	 * This function is used to populate the category dropdown in the frontend widget search form.
	 *
	 * @global wpdb $wpdb WordPress database object.
	 * @return array An array of category data containing the category ID, icon, and category name.
	 */
	public static function bp_font_widget_category_view($category_get_id = null)
	{
		self::$f_currency_symbol = get_option("bookingor_settings_currency_symbol");
		global $wpdb;
		self::$bookingorDb = $wpdb;
		$category_id = $category_get_id;
		if (!empty($category_id)) {
			// print_r($category_id);

			// If a specific category ID is provided, retrieve that category
			return self::$f_widget_category = self::$bookingorDb->get_results($wpdb->prepare("SELECT category_id, icon, category_name FROM {$wpdb->prefix}bookingor_categories WHERE status = %d AND category_id = %d", 1, $category_id));
		} else {
			return self::$f_widget_category = self::$bookingorDb->get_results($wpdb->prepare("SELECT category_id, icon, category_name FROM  {$wpdb->prefix}bookingor_categories WHERE status = %d", 1));
		}
	}
}
