<?php
include "../../src/config.php";

if (!auth::user()) {
    endrequest("You dont have access to this api");
}


// TODO 
// access control using user permissions

$response['input'] = $_GET;

if (!isset($_GET['state'])) {
    endrequest("not enough inputs");
}

if ($_GET['state'] == 0) {
    $response = datatable::query("SELECT * from cases");
} else {
    $response = datatable::query("SELECT * from cases where state = :state", ["state" => $_GET["state"]]);
}

echo json_encode($response);
