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:
@@ -6,6 +6,21 @@
|
||||
|
||||
declare(strict_types=1);
|
||||
|
||||
/**
|
||||
* Vraci aktualni cas a datum z MySQL (jednotny zdroj casu)
|
||||
* @return array{now: string, today: string, year: int, month: int}
|
||||
*/
|
||||
function getDbNow(PDO $pdo): array
|
||||
{
|
||||
$row = $pdo->query("SELECT NOW() AS now, CURDATE() AS today, YEAR(NOW()) AS y, MONTH(NOW()) AS m")->fetch();
|
||||
return [
|
||||
'now' => $row['now'],
|
||||
'today' => $row['today'],
|
||||
'year' => (int)$row['y'],
|
||||
'month' => (int)$row['m'],
|
||||
];
|
||||
}
|
||||
|
||||
function roundUpTo15Minutes(string $datetime): string
|
||||
{
|
||||
$timestamp = strtotime($datetime);
|
||||
@@ -327,15 +342,14 @@ function addFundDataToUserTotals(PDO $pdo, array &$userTotals, int $year, int $m
|
||||
}
|
||||
unset($ut);
|
||||
|
||||
$today = date('Y-m-d');
|
||||
$stmt = $pdo->prepare("
|
||||
SELECT DISTINCT user_id FROM attendance
|
||||
WHERE shift_date = ?
|
||||
WHERE shift_date = CURDATE()
|
||||
AND arrival_time IS NOT NULL
|
||||
AND departure_time IS NULL
|
||||
AND (leave_type IS NULL OR leave_type = 'work')
|
||||
");
|
||||
$stmt->execute([$today]);
|
||||
$stmt->execute();
|
||||
$workingNow = $stmt->fetchAll(PDO::FETCH_COLUMN);
|
||||
foreach ($workingNow as $uid) {
|
||||
if (isset($userTotals[$uid])) {
|
||||
|
||||
Reference in New Issue
Block a user