<?php
include("../../classes/manager.class.php");
$m = new Manager();

$id = $_REQUEST['id'];  // Category ID
$cus_id = $_REQUEST['cus_id'];  // Customer ID
$cat_type = $_REQUEST['cat_type']; // Cat Type (0 for Wholesaler, 1 for Local Mart)

if ($id) {
    $customersfilter = " WHERE status = 'active' ";

    if ($id != 'All') {
        $customersfilter .= " AND category_id = '$id' ";
    }

    if ($cat_type != 'All') {
        $customersfilter .= " AND is_mart = '$cat_type' ";
    }

    $qry = CustomerSetup::GetCustomerSetupList($customersfilter);

    if ($qry) {
        echo '<option value="All">All</option>';
        foreach ($qry AS $row) {
            if ($row->status != 'Draft') {
                echo '<option ';
                if ($cus_id == $row->id) {
                    echo 'selected ';
                }
                echo 'value="' . $row->id . '">' . $row->name . '</option>';
            }
        }
    } else {
        echo '<option>No Customers Found</option>';
    }
}
?>
