<?php
session_start();
require_once "../../config.php";
require_once "../../../validation.php";
require_once "../../../Helper.php";
require_once '../../database1.php';
require_once "../../check_admin.php";

require_once '../check_edit_page_ajax.php';

class getValues extends database{
	public function index($id)
	{
		$where['cl_product_subcategory_filter_id'] = $id;
		return $this->fetchAll('tb_product_subcategory_values_filter', $where);
	}

	public function getFilter($id)
        {
            return $this->fetchRow('tb_product_subcategory_filter', ['cl_id' => $id]);
        }
}

if(!isset($_GET['id']))
{
	http_response_code(400);
	echo json_encode(array('error_text' => 'No input found'));
	exit;
}

$id = $_GET['id'];

$obj = new getValues();
$filter = $obj->getFilter($id);
if(!$filter)
{
    http_response_code(400);
	echo json_encode(array('error_text' => 'No input found'));
	exit;
}

$filterValues = $obj->index($id);


http_response_code(200);
echo json_encode(['name' => $filter['cl_name'], 'data' => $filterValues]);