|
|
|
@ -6,11 +6,21 @@ dieifnotloggedin();
|
|
|
|
|
|
|
|
|
|
header("Content-Type: application/json");
|
|
|
|
|
|
|
|
|
|
require_once __DIR__ . "/login.php";
|
|
|
|
|
require_once __DIR__ . "/userinfo.php";
|
|
|
|
|
|
|
|
|
|
$showmanaged = ($VARS['show_all'] == 1 && account_has_permission($_SESSION['username'], "QWIKCLOCK_MANAGE"));
|
|
|
|
|
$managed_uids = [];
|
|
|
|
|
if ($showmanaged) {
|
|
|
|
|
$managed_uids = getManagedUIDs($_SESSION['uid']);
|
|
|
|
|
}
|
|
|
|
|
$managed_uids[] = $_SESSION['uid'];
|
|
|
|
|
|
|
|
|
|
$out = [];
|
|
|
|
|
|
|
|
|
|
$out['draw'] = intval($VARS['draw']);
|
|
|
|
|
|
|
|
|
|
$out['recordsTotal'] = $database->count('punches', ['uid' => $_SESSION['uid']]);
|
|
|
|
|
$out['recordsTotal'] = $database->count('punches', ['uid' => $managed_uids]);
|
|
|
|
|
$filter = false;
|
|
|
|
|
|
|
|
|
|
// sort
|
|
|
|
@ -21,9 +31,12 @@ if ($VARS['order'][0]['dir'] == 'asc') {
|
|
|
|
|
}
|
|
|
|
|
switch ($VARS['order'][0]['column']) {
|
|
|
|
|
case 1:
|
|
|
|
|
$order = ["in" => $sortby];
|
|
|
|
|
$order = ["uid" => $sortby];
|
|
|
|
|
break;
|
|
|
|
|
case 2:
|
|
|
|
|
$order = ["in" => $sortby];
|
|
|
|
|
break;
|
|
|
|
|
case 3:
|
|
|
|
|
$order = ["out" => $sortby];
|
|
|
|
|
break;
|
|
|
|
|
}
|
|
|
|
@ -37,13 +50,13 @@ if (!is_empty($VARS['search']['value'])) {
|
|
|
|
|
"in[~]" => $VARS['search']['value'],
|
|
|
|
|
"out[~]" => $VARS['search']['value']
|
|
|
|
|
],
|
|
|
|
|
"uid" => $_SESSION['uid']
|
|
|
|
|
"uid" => $managed_uids
|
|
|
|
|
]
|
|
|
|
|
];
|
|
|
|
|
$where = $wherenolimit;
|
|
|
|
|
$where["LIMIT"] = [$VARS['start'], $VARS['length']];
|
|
|
|
|
} else {
|
|
|
|
|
$where = ["uid" => $_SESSION['uid'], "LIMIT" => [$VARS['start'], $VARS['length']]];
|
|
|
|
|
$where = ["uid" => $managed_uids, "LIMIT" => [$VARS['start'], $VARS['length']]];
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
if (!is_null($order)) {
|
|
|
|
@ -52,20 +65,29 @@ if (!is_null($order)) {
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
$punches = $database->select('punches', [
|
|
|
|
|
'uid',
|
|
|
|
|
'in',
|
|
|
|
|
'out',
|
|
|
|
|
'notes'
|
|
|
|
|
], $where);
|
|
|
|
|
|
|
|
|
|
$usercache = [];
|
|
|
|
|
|
|
|
|
|
for ($i = 0; $i < count($punches); $i++) {
|
|
|
|
|
// Get user info
|
|
|
|
|
if (!isset($usercache[$punches[$i]['uid']])) {
|
|
|
|
|
$usercache[$punches[$i]['uid']] = getUserByID($punches[$i]['uid']);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
$punches[$i][0] = "";
|
|
|
|
|
$punches[$i][1] = date(DATETIME_FORMAT, strtotime($punches[$i]['in']));
|
|
|
|
|
$punches[$i][1] = $usercache[$punches[$i]['uid']]['name'];
|
|
|
|
|
$punches[$i][2] = date(DATETIME_FORMAT, strtotime($punches[$i]['in']));
|
|
|
|
|
if (is_null($punches[$i]['out'])) {
|
|
|
|
|
$punches[$i][2] = lang("na", false);
|
|
|
|
|
$punches[$i][3] = lang("na", false);
|
|
|
|
|
} else {
|
|
|
|
|
$punches[$i][2] = date(DATETIME_FORMAT, strtotime($punches[$i]['out']));
|
|
|
|
|
$punches[$i][3] = date(DATETIME_FORMAT, strtotime($punches[$i]['out']));
|
|
|
|
|
}
|
|
|
|
|
$punches[$i][3] = $punches[$i]['notes'];
|
|
|
|
|
$punches[$i][4] = $punches[$i]['notes'];
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
$out['status'] = "OK";
|
|
|
|
|