Punch in/out now works
This commit is contained in:
parent
359509732c
commit
d286053ef4
14
action.php
14
action.php
@ -24,7 +24,19 @@ function returnToSender($msg, $arg = "") {
|
||||
}
|
||||
|
||||
switch ($VARS['action']) {
|
||||
case "time":
|
||||
case "punchin":
|
||||
if ($database->has('punches', ['AND' => ['uid' => $_SESSION['uid'], 'out' => null]])) {
|
||||
returnToSender("already_in");
|
||||
}
|
||||
$database->insert('punches', ['uid' => $_SESSION['uid'], 'in' => date("Y-m-d H:i:s"), 'out' => null, 'notes' => '']);
|
||||
returnToSender("punched_in");
|
||||
case "punchout":
|
||||
if (!$database->has('punches', ['AND' => ['uid' => $_SESSION['uid'], 'out' => null]])) {
|
||||
returnToSender("already_out");
|
||||
}
|
||||
$database->update('punches', ['uid' => $_SESSION['uid'], 'out' => date("Y-m-d H:i:s")], ['out' => null]);
|
||||
returnToSender("punched_out");
|
||||
case "gettime":
|
||||
$out = ["status" => "OK", "time" => date(TIME_FORMAT), "date" => date(LONG_DATE_FORMAT), "seconds" => date("s")];
|
||||
header('Content-Type: application/json');
|
||||
exit(json_encode($out));
|
||||
|
@ -27,5 +27,9 @@ define("STRINGS", [
|
||||
"home" => "Home",
|
||||
"punch in out" => "Punch In/Out",
|
||||
"you are punched in" => "You are punched in.",
|
||||
"you are not punched in" => "You are not on the clock."
|
||||
"you are not punched in" => "You are not on the clock.",
|
||||
"already punched in" => "You are already on the clock.",
|
||||
"already punched out" => "You are already punched out.",
|
||||
"punched in" => "You are now on the clock.",
|
||||
"punched out" => "You are now off the clock."
|
||||
]);
|
@ -12,5 +12,21 @@ define("MESSAGES", [
|
||||
"404_error" => [
|
||||
"string" => "page not found",
|
||||
"type" => "info"
|
||||
],
|
||||
"already_in" => [
|
||||
"string" => "already punched in",
|
||||
"type" => "danger"
|
||||
],
|
||||
"already_out" => [
|
||||
"string" => "already punched out",
|
||||
"type" => "danger"
|
||||
],
|
||||
"punched_in" => [
|
||||
"string" => "punched in",
|
||||
"type" => "success"
|
||||
],
|
||||
"punched_out" => [
|
||||
"string" => "punched out",
|
||||
"type" => "success"
|
||||
]
|
||||
]);
|
||||
|
@ -21,9 +21,9 @@
|
||||
</h3>
|
||||
</div>
|
||||
<div class="panel-body">
|
||||
<a href="action.php?action=punchin" class="btn btn-block btn-success btn-lg"><i class="fa fa-play"></i> <?php lang("punch in"); ?></a>
|
||||
<a href="action.php?source=home&action=punchin" class="btn btn-block btn-success btn-lg"><i class="fa fa-play"></i> <?php lang("punch in"); ?></a>
|
||||
<br />
|
||||
<a href="action.php?action=punchout" class="btn btn-block btn-danger btn-lg"><i class="fa fa-stop"></i> <?php lang("punch out"); ?></a>
|
||||
<a href="action.php?source=home&action=punchout" class="btn btn-block btn-danger btn-lg"><i class="fa fa-stop"></i> <?php lang("punch out"); ?></a>
|
||||
</div>
|
||||
<div class="panel-footer">
|
||||
<i class="fa fa-info-circle"></i> <?php
|
||||
|
@ -1,6 +1,6 @@
|
||||
function setClock() {
|
||||
$.getJSON("action.php", {
|
||||
action: "time"
|
||||
action: "gettime"
|
||||
}, function (resp) {
|
||||
if (resp.status == "OK") {
|
||||
$('#server_time').text(resp.time);
|
||||
@ -30,15 +30,6 @@ function setClock() {
|
||||
});
|
||||
}
|
||||
|
||||
function setSeconds() {
|
||||
//$('#seconds_bar div').css("width", ((seconds / 60) * 100) + "%");
|
||||
$('#seconds_bar div').animate({
|
||||
width: ((seconds / 60) * 100) + "%"
|
||||
}, 1000, "linear", function () {
|
||||
seconds++;
|
||||
});
|
||||
}
|
||||
|
||||
$(document).ready(function () {
|
||||
setClock();
|
||||
setInterval(setClock, 5000);
|
||||
|
Loading…
x
Reference in New Issue
Block a user