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

if (!auth::isadmin()) {
    endrequest("You don't have permissions to access this api");
}

$query  = "select u.id,u.name,u.designation, DATE_FORMAT(lastseen, '%Y/%m/%d - %H:%i') as lastseen from users as u";

$response = datatable::query($query);

foreach ($response["data"] as $key => $value) {
    $response["data"][$key]["roles"] = userroles::assigned($response["data"][$key]["id"]);
}

echo json_encode($response);
