Adding delay and penalty calculations
This commit is contained in:
@@ -180,11 +180,33 @@ if (!empty($user->tasks)) {
|
||||
<th>ورود</th>
|
||||
<th>خروج</th>
|
||||
<th>مدت</th>
|
||||
<th>تأخیر</th>
|
||||
</tr>
|
||||
</thead>
|
||||
|
||||
<tbody>
|
||||
@php
|
||||
$monthLateMinutes = 0;
|
||||
$monthDailyFine = 0;
|
||||
$monthKey = $records->first()?->entered_at
|
||||
? \Carbon\Carbon::parse($records->first()->entered_at)
|
||||
: null;
|
||||
if ($monthKey) {
|
||||
[$mStart, $mEnd] = app(\App\Services\LatePenaltyService::class)->jalaliMonthBounds($monthKey);
|
||||
$monthWeeklyFine = (int) \App\Models\LatePeriodFine::query()
|
||||
->where('user_identity', $user->user_name)
|
||||
->where('period_type', 'weekly')
|
||||
->whereBetween('period_start', [$mStart->toDateString(), $mEnd->toDateString()])
|
||||
->sum('fine_amount');
|
||||
} else {
|
||||
$monthWeeklyFine = 0;
|
||||
}
|
||||
@endphp
|
||||
@foreach($records as $item)
|
||||
@php
|
||||
$monthLateMinutes += (int) ($item->late_minutes ?? 0);
|
||||
$monthDailyFine += (int) ($item->daily_fine_amount ?? 0);
|
||||
@endphp
|
||||
<tr class="hover:bg-cyan-500 cursor-pointer transition duration-150"
|
||||
style="border-bottom: 1px solid #ddd; background-color: {{$item->requested ? '#bfdbfe' : '#ffffff' }}"
|
||||
onclick="openModal('{{ $item->id }}', '{{ $item->id }}' , '{{ $item->entered_at }}', '{{ $item->exited_at }} ')">
|
||||
@@ -218,14 +240,35 @@ if (!empty($user->tasks)) {
|
||||
<td style="border-right: 1px solid #ddd; padding: 4px;">
|
||||
{{ $item->entered_at && $item->exited_at ? \Carbon\Carbon::parse($item->duration)->format('H:i') : '-' }}
|
||||
</td>
|
||||
|
||||
{{-- تأخیر --}}
|
||||
<td style="border-right: 1px solid #ddd; padding: 4px; {{ ($item->daily_fine_minutes ?? 0) > 0 ? 'color:#dc2626;font-weight:600;' : (($item->late_minutes ?? 0) > 0 ? 'color:#d97706;' : '') }}">
|
||||
@if(($item->late_minutes ?? 0) > 0)
|
||||
{{ $item->late_minutes }}د
|
||||
@if(($item->daily_fine_amount ?? 0) > 0)
|
||||
<span class="text-[10px] block">{{ number_format($item->daily_fine_amount) }}ت</span>
|
||||
@endif
|
||||
@else
|
||||
-
|
||||
@endif
|
||||
</td>
|
||||
</tr>
|
||||
@endforeach
|
||||
|
||||
{{-- ردیف جمع کل (اختیاری - چون متغیر آن موجود نبود کامنت کردم که خطا ندهد) --}}
|
||||
|
||||
@php
|
||||
$monthTotalFine = $monthDailyFine + $monthWeeklyFine;
|
||||
@endphp
|
||||
<tr>
|
||||
<td colspan="5" class="table-summary">
|
||||
<td colspan="6" class="table-summary text-right leading-6">
|
||||
تعداد رکورد: {{ count($records) }}
|
||||
<br>
|
||||
تأخیر ماه: {{ $monthLateMinutes }} دقیقه
|
||||
<br>
|
||||
جریمه روزانه: {{ number_format($monthDailyFine) }} تومان
|
||||
<br>
|
||||
جریمه هفتگی: {{ number_format($monthWeeklyFine) }} تومان
|
||||
<br>
|
||||
<strong>جمع جریمه ماه: {{ number_format($monthTotalFine) }} تومان</strong>
|
||||
</td>
|
||||
</tr>
|
||||
|
||||
|
||||
Reference in New Issue
Block a user