refactor: sjednoceni zdroje casu na MySQL NOW() + audit log cleanup a UI

- attendance handlery pouzivaji getDbNow() misto PHP date()
- nova helper funkce getDbNow() v AttendanceHelpers.php
- audit log: cleanup endpoint (POST) s volbou stari zaznamu
- audit log: filtry na jednom radku
- dashboard: aktivita prejmenovana na Audit log s odkazem

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
This commit is contained in:
2026-03-12 20:48:05 +01:00
parent 36a864c852
commit 5529219234
5 changed files with 157 additions and 17 deletions

View File

@@ -4,7 +4,8 @@ declare(strict_types=1);
function handleGetCurrent(PDO $pdo, int $userId): void
{
$today = date('Y-m-d');
$dbTime = getDbNow($pdo);
$today = $dbTime['today'];
$stmt = $pdo->prepare("
SELECT id, user_id, shift_date, arrival_time, arrival_lat, arrival_lng,
@@ -68,13 +69,13 @@ function handleGetCurrent(PDO $pdo, int $userId): void
$leaveBalance = getLeaveBalance($pdo, $userId);
$currentYear = (int)date('Y');
$currentMonth = (int)date('m');
$currentYear = $dbTime['year'];
$currentMonth = $dbTime['month'];
$fund = CzechHolidays::getMonthlyWorkFund($currentYear, $currentMonth);
$businessDays = CzechHolidays::getBusinessDaysInMonth($currentYear, $currentMonth);
$startDate = date('Y-m-01');
$endDate = date('Y-m-t');
$startDate = substr($dbTime['today'], 0, 7) . '-01';
$endDate = date('Y-m-t', strtotime($startDate));
$stmt = $pdo->prepare('
SELECT id, user_id, shift_date, arrival_time, break_start, break_end,
@@ -253,8 +254,9 @@ function handlePunch(PDO $pdo, int $userId): void
{
$input = getJsonInput();
$action = $input['punch_action'] ?? '';
$today = date('Y-m-d');
$rawNow = date('Y-m-d H:i:s');
$dbTime = getDbNow($pdo);
$today = $dbTime['today'];
$rawNow = $dbTime['now'];
$lat = isset($input['latitude']) && $input['latitude'] !== '' ? (float)$input['latitude'] : null;
$lng = isset($input['longitude']) && $input['longitude'] !== '' ? (float)$input['longitude'] : null;
@@ -508,7 +510,7 @@ function handleSwitchProject(PDO $pdo, int $userId): void
}
$attendanceId = $currentShift['id'];
$now = date('Y-m-d H:i:s');
$now = getDbNow($pdo)['now'];
$stmt = $pdo->prepare(
'UPDATE attendance_project_logs SET ended_at = ?