<?php
// csr_manager/ajax/get_statuses.php — returns all job statuses for filter dropdown
session_start();
require_once '../../config/database.php';
header('Content-Type: application/json');

if (!isset($_SESSION['csr_id'])) {
    echo json_encode(['success' => false]);
    exit();
}

try {
    $db = (new Database())->getConnection();
    $stmt = $db->query("SELECT id, status_name, color_code FROM job_statuses ORDER BY id ASC");
    echo json_encode(['success' => true, 'statuses' => $stmt->fetchAll(PDO::FETCH_ASSOC)]);
} catch (Exception $e) {
    echo json_encode(['success' => false, 'statuses' => []]);
}
?>
