<?php
include("../classes/manager.class.php");
//ini_set('display_errors', 1);
//error_reporting(E_ALL);
$m = new Manager();
$output = '';
if (!isset($_SESSION['sess_userid'])) {
    header("Location: " . PROJECT_ADMIN_URL);
    exit();
}
//$parent_id = isset($_POST['parent_id']) ? (int)$_POST['parent_id'] : 0;
$parent_id = $_GET['parent_id'] ?? null;


if ($parent_id > 0) {
    $filter = " WHERE parent_id = '$parent_id' AND status = 'active' ORDER BY name";
    $subCats = ExpenseTaxCategorySetup::GetExpenseTaxCategorySetupList($filter);
    if ($subCats) {
        echo '<option value="">-- Select Subcategory --</option>';
        foreach ($subCats as $cat) {
            echo '<option value="' . $cat->id . '">' . ucwords($cat->name) . '</option>';
        }
    } else {
        echo '<option value="">No subcategories</option>';
    }
} else {
    echo '<option value="">Select parent category first</option>';
}
?>