fix: timecard
This commit is contained in:
parent
e8c70d4ef7
commit
3ea8d828ed
3
.gitignore
vendored
3
.gitignore
vendored
@ -1,3 +1,2 @@
|
||||
config.php
|
||||
install.php
|
||||
|
||||
.htaccess
|
||||
|
@ -32,8 +32,15 @@ class BootLoader
|
||||
$isAdmin = false;
|
||||
$loginUser = [];
|
||||
$works = [];
|
||||
$month = 0;
|
||||
|
||||
$page = filter_input(INPUT_GET, "p") ?? "home";
|
||||
$tmonth = filter_input(INPUT_GET, "m");
|
||||
|
||||
if ($result = filter_var($tmonth, FILTER_VALIDATE_INT))
|
||||
{
|
||||
$month = $result;
|
||||
}
|
||||
|
||||
if ($user->hasLogout())
|
||||
{
|
||||
@ -109,7 +116,7 @@ class BootLoader
|
||||
}
|
||||
|
||||
$result = $this->cards->hasCard($loginUser["id"], $isAdmin);
|
||||
$works = $this->cards->SelectTimes($loginUser["id"]);
|
||||
$works = $this->cards->SelectTimes($loginUser["id"], $month);
|
||||
$lastCard = $this->cards->getLastInsert($loginUser["id"]);
|
||||
|
||||
$users = $this->cards->getUsers();
|
||||
@ -118,6 +125,7 @@ class BootLoader
|
||||
"users" => $users,
|
||||
"user" => $loginUser,
|
||||
"works" => $works,
|
||||
"queryTime" => $this->cards->queryTime,
|
||||
"canonical" => $this->config["canonical"],
|
||||
"config" => $this->config,
|
||||
"addCard" => $result,
|
||||
|
@ -12,6 +12,7 @@ class Timecard
|
||||
}
|
||||
|
||||
protected $pdo;
|
||||
public $queryTime = [];
|
||||
|
||||
public function InitTables()
|
||||
{
|
||||
@ -94,14 +95,34 @@ class Timecard
|
||||
return true;
|
||||
}
|
||||
|
||||
public function SelectTimes($uid)
|
||||
public function SelectTimes($uid, $month = 0)
|
||||
{
|
||||
try {
|
||||
$mm = strtotime(sprintf("%dmonth", $month));
|
||||
$today = ((int) date("d")) - 1;
|
||||
$dayCount = (int) date("t");
|
||||
|
||||
if ( $month == 0 )
|
||||
{
|
||||
$startTime = date("Y-m-d 00:00:00", strtotime(sprintf("-%ddays", $today)));
|
||||
$endTime = date("Y-m-d 00:00:00", strtotime(sprintf("+%ddays", $dayCount - $today)));
|
||||
} else {
|
||||
$y = date("Y", $mm);
|
||||
$m = date("m", $mm);
|
||||
$ly = $y;
|
||||
$lm = $m + 1;
|
||||
if ($lm > 12)
|
||||
{
|
||||
$ly += 1;
|
||||
$lm = 1;
|
||||
}
|
||||
|
||||
$startTime = date("Y-m-d 00:00:00", strtotime(sprintf("%d-%d-01", $y, $m)));
|
||||
$endTime = date("Y-m-d 00:00:00", strtotime(sprintf("%d-%d-01", $ly, $lm)));
|
||||
}
|
||||
|
||||
|
||||
$this->queryTime = [$startTime, $endTime];
|
||||
|
||||
$smt = $this->pdo->prepare("SELECT * FROM cards WHERE startTime > ? AND endTime < ? AND uid=?;");
|
||||
$smt->execute([
|
||||
|
@ -118,12 +118,37 @@
|
||||
<hr />
|
||||
|
||||
<?php if($args["logged"]): ?>
|
||||
|
||||
<div class="container-fluid row">
|
||||
<div class="col-md-4 offset-md-5">
|
||||
<nav aria-label="Page navigation">
|
||||
<ul class="pagination">
|
||||
<li class="page-item"><a class="page-link" href="?m=-2">先々月</a></li>
|
||||
<li class="page-item"><a class="page-link" href="?m=-1">先月</a></li>
|
||||
<li class="page-item"><a class="page-link" href="?m=0">今月</a></li>
|
||||
</ul>
|
||||
</nav>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div class="container mt-3">
|
||||
<?php if(empty($args["works"]) && !$args["lastCard"]): ?>
|
||||
<p class="text-danger">タイムカードは登録されていません。</p>
|
||||
<?php else: ?>
|
||||
<?php $hours = 0; $minutes = 0; ?>
|
||||
<div class="table-responsive">
|
||||
<table class="table table-hover table-bordered">
|
||||
<tr>
|
||||
<th>開始日</th>
|
||||
<th>終了日</th>
|
||||
</tr>
|
||||
<tr>
|
||||
<th><?php echo $args["queryTime"][0]; ?></th>
|
||||
<th><?php echo $args["queryTime"][1]; ?></th>
|
||||
</tr>
|
||||
</table>
|
||||
</div>
|
||||
<div class="table-responsive mt-1">
|
||||
<table class="table table-hover table-bordered">
|
||||
<tr>
|
||||
<th>始業</th>
|
||||
|
Loading…
Reference in New Issue
Block a user