diff --git a/README.md b/README.md index 1ff2bc9..86780d6 100644 --- a/README.md +++ b/README.md @@ -1,4 +1,6 @@ QwikClock ========= -QwikClock is an employee time tracking app. \ No newline at end of file +QwikClock is an employee time tracking app. + +**Warning: Under heavy development. Don't use yet.** \ No newline at end of file diff --git a/api.php b/api.php index c4af15c..77d63e6 100644 --- a/api.php +++ b/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\""); diff --git a/lang/en_us.php b/lang/en_us.php index 476625e..fd77880 100644 --- a/lang/en_us.php +++ b/lang/en_us.php @@ -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.",