Add punch in/out API
This commit is contained in:
parent
f5b01d7fa4
commit
5a6c3d1aff
@ -1,4 +1,6 @@
|
||||
QwikClock
|
||||
=========
|
||||
|
||||
QwikClock is an employee time tracking app.
|
||||
QwikClock is an employee time tracking app.
|
||||
|
||||
**Warning: Under heavy development. Don't use yet.**
|
12
api.php
12
api.php
@ -30,6 +30,18 @@ switch ($VARS['action']) {
|
||||
case "ping":
|
||||
$out = ["status" => "OK", "maxresults" => $max, "pong" => true];
|
||||
exit(json_encode($out));
|
||||
case "punchin":
|
||||
if ($database->has('punches', ['AND' => ['uid' => $userinfo['uid'], 'out' => null]])) {
|
||||
die(json_encode(["status" => "ERROR", "msg" => lang("already punched in", false)]));
|
||||
}
|
||||
$database->insert('punches', ['uid' => $userinfo['uid'], 'in' => date("Y-m-d H:i:s"), 'out' => null, 'notes' => '']);
|
||||
exit(json_encode(["status" => "OK", "msg" => lang("punched in", false)]));
|
||||
case "punchout":
|
||||
if (!$database->has('punches', ['AND' => ['uid' => $userinfo['uid'], 'out' => null]])) {
|
||||
die(json_encode(["status" => "ERROR", "msg" => lang("already punched out", false)]));
|
||||
}
|
||||
$database->update('punches', ['uid' => $userinfo['uid'], 'out' => date("Y-m-d H:i:s")], ['out' => null]);
|
||||
exit(json_encode(["status" => "OK", "msg" => lang("punched out", false)]));
|
||||
default:
|
||||
http_response_code(404);
|
||||
die("\"404 Action not found\"");
|
||||
|
@ -26,6 +26,8 @@ define("STRINGS", [
|
||||
"captcha error" => "There was a problem with the CAPTCHA (robot test). Try again.",
|
||||
"home" => "Home",
|
||||
"punch in out" => "Punch In/Out",
|
||||
"punch in" => "Punch in",
|
||||
"punch out" => "Punch out",
|
||||
"you are punched in" => "You are punched in.",
|
||||
"you are not punched in" => "You are not on the clock.",
|
||||
"already punched in" => "You are already on the clock.",
|
||||
|
Loading…
x
Reference in New Issue
Block a user