Improve info cards on Punches/History page

This commit is contained in:
Skylar Ittner 2017-06-28 17:14:55 -06:00
parent accc804040
commit 3a9efd0670
5 changed files with 46 additions and 24 deletions

View File

@ -41,6 +41,8 @@ define("STRINGS", [
"notes" => "Notes", "notes" => "Notes",
"view punch card" => "View punch card", "view punch card" => "View punch card",
"na" => "N/A", "na" => "N/A",
"this week" => "This week", "this week" => "This Week",
"x on the clock" => "{time} on the clock" "x on the clock" => "{time} on the clock",
"x punches" => "{count} punches",
"history" => "History"
]); ]);

View File

@ -14,7 +14,7 @@ define("PAGES", [
"title" => "404 error" "title" => "404 error"
], ],
"punches" => [ "punches" => [
"title" => "punch card", "title" => "history",
"navbar" => true, "navbar" => true,
"icon" => "clock-o", "icon" => "clock-o",
"styles" => [ "styles" => [

View File

@ -36,7 +36,7 @@ redirectifnotloggedin();
?> ?>
<i class="fa fa-info-circle"></i> <span id="inmsg"<?php echo ($in ? '' : ' style="display: none;"') ?>><?php lang("you are punched in"); ?></span><span id="outmsg"<?php echo ($in ? ' style="display: none;"' : '') ?>><?php lang("you are not punched in"); ?></span> <i class="fa fa-info-circle"></i> <span id="inmsg"<?php echo ($in ? '' : ' style="display: none;"') ?>><?php lang("you are punched in"); ?></span><span id="outmsg"<?php echo ($in ? ' style="display: none;"' : '') ?>><?php lang("you are not punched in"); ?></span>
<br /> <br />
<a href="app.php?page=punches" style="color: #01579b;"><i class="fa fa-arrow-right"></i> <?php lang("view punch card"); ?></a> <a href="app.php?page=punches#punches" style="color: #01579b;"><i class="fa fa-arrow-right"></i> <?php lang("view punch card"); ?></a>
</div> </div>
</div> </div>
</div> </div>

View File

@ -2,33 +2,49 @@
require_once __DIR__ . '/../required.php'; require_once __DIR__ . '/../required.php';
redirectifnotloggedin(); redirectifnotloggedin();
require_once __DIR__ . "/../lib/dates.php";
$weekstart = sqldatetime(getstartofweek(WEEK_START));
$punches = $database->select('punches', ['in', 'out'], ['AND' => ['uid' => $_SESSION['uid'], 'in[>]' => $weekstart]]);
$punchtimes = [];
foreach ($punches as $p) {
$punchtimes[] = [$p['in'], $p['out']];
}
$totalseconds = sumelapsedtimearray($punchtimes);
$totalpunches = count($punches);
?> ?>
<p class="page-header h5"><i class="fa fa-calendar fa-fw"></i> <?php lang("this week") ?></p>
<div class="row"> <div class="row">
<div class="col-xs-12 col-sm-6 col-md-4">
<div class="col-xs-12 col-sm-6 col-md-4 col-md-offset-2">
<div class="panel panel-blue"> <div class="panel panel-blue">
<div class="panel-heading">
<h3 class="panel-title">
<i class="fa fa-clock-o"></i> <?php lang("this week"); ?>
</h3>
</div>
<div class="panel-body"> <div class="panel-body">
<h4> <h4>
<?php <?php
require_once __DIR__ . "/../lib/dates.php";
$weekstart = sqldatetime(getstartofweek(WEEK_START));
$punches = $database->select('punches', ['in', 'out'], ['AND' => ['uid' => $_SESSION['uid'], 'in[>]' => $weekstart]]);
$punchtimes = [];
foreach ($punches as $p) {
$punchtimes[] = [$p['in'], $p['out']];
}
$totalseconds = sumelapsedtimearray($punchtimes);
lang2("x on the clock", ["time" => seconds2string($totalseconds, false)]); lang2("x on the clock", ["time" => seconds2string($totalseconds, false)]);
?> ?>
</h4> </h4>
</div> </div>
</div> </div>
</div> </div>
<div class="col-xs-12 col-sm-6 col-md-4">
<div class="panel panel-blue">
<div class="panel-body">
<h4>
<?php
lang2("x punches", ["count" => $totalpunches]);
?>
</h4>
</div>
</div>
</div>
</div> </div>
<a id="punches" style="height: 0px; width: 0px;">&nbsp;</a>
<p class="page-header h5"><i class="fa fa-clock-o fa-fw"></i> <?php lang("punch card") ?></p>
<table id="punchtable" class="table table-bordered table-striped"> <table id="punchtable" class="table table-bordered table-striped">
<thead> <thead>
<tr> <tr>

View File

@ -4,6 +4,15 @@ $(document).ready(function () {
$(".alert .close").click(function (e) { $(".alert .close").click(function (e) {
$(this).parent().fadeOut("slow"); $(this).parent().fadeOut("slow");
}); });
try {
window.history.replaceState("", "", getniceurl());
if (window.location.hash) {
document.getElementById(window.location.hash.replace("#", "")).scrollIntoView();
}
} catch (ex) {
}
}); });
@ -11,13 +20,8 @@ $(document).ready(function () {
* Remove feedback params from the URL so they don't stick around too long * Remove feedback params from the URL so they don't stick around too long
*/ */
function getniceurl() { function getniceurl() {
var url = window.location.search; var url = window.location.search + window.location.hash;
url = url.substring(url.lastIndexOf("/") + 1); url = url.substring(url.lastIndexOf("/") + 1);
url = url.replace(/&?msg=([^&]$|[^&]*)/i, ""); url = url.replace(/&?msg=([^&]$|[^&]*)/i, "");
return url; return url;
}
try {
window.history.replaceState("", "", getniceurl());
} catch (ex) {
} }