update timekeeping

This commit is contained in:
JOSEPH LE 2024-06-05 14:59:32 +07:00
parent 54e5d8e780
commit 16bc8b9a7a
2 changed files with 9 additions and 9 deletions

View File

@ -40,10 +40,10 @@ class TimekeepingController extends Controller
$user_data = [];
for ($i = 1; $i <= $daysInMonth; $i++) {
// Tạo ngày cụ thể trong tháng
$date = Carbon::create($now->year, $now->month, $i)->format('Y-m-d');
$date = Carbon::create($now->year, $now->month, $i)->setTimezone(env('TIME_ZONE'))->format('Y-m-d');
// Kiểm tra xem có mục nào trong $history có created_at trùng với $date
$hasEntry = $history->filter(function ($entry) use ($date, $admin) {
return Carbon::parse($entry->created_at)->format('Y-m-d') === $date && $entry->user_id == $admin->id;
return Carbon::parse($entry->created_at)->setTimezone(env('TIME_ZONE'))->format('Y-m-d') === $date && $entry->user_id == $admin->id;
});
if (count($hasEntry) > 0) {
@ -51,9 +51,9 @@ class TimekeepingController extends Controller
$last_checkin = null;
$total = 0;
foreach ($values as $value) {
$createdAt = Carbon::parse($value->created_at);
$createdAt = Carbon::parse($value->created_at)->setTimezone(env('TIME_ZONE'));
if ($value->status == 'check out' && $last_checkin != null) {
$lastCheckInTime = Carbon::parse($last_checkin);
$lastCheckInTime = Carbon::parse($last_checkin)->setTimezone(env('TIME_ZONE'));
// Tính thời gian làm việc bằng hiệu của thời gian check out và check in
$workingTime = $createdAt->diffInSeconds($lastCheckInTime);
$total += $workingTime;

View File

@ -208,11 +208,11 @@ const Tracking = () => {
if (listTracking.data.length === 0) {
getAllTracking()
}
// setInterval(() => {
// if (window.location.pathname.includes('tracking')) {
// getAllTracking()
// }
// }, 7000)
setInterval(() => {
if (window.location.pathname.includes('tracking')) {
getAllTracking()
}
}, 7000)
}, [])
return (
<div>