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>
|
||||
|
||||
|
||||
@@ -36,6 +36,21 @@
|
||||
pattern="^09\d{9}$"
|
||||
class="border border-gray-300 rounded-md text-center" required>
|
||||
|
||||
<label class="pb-3">تاریخ تولد:</label>
|
||||
<div class="flex flex-col gap-1">
|
||||
<input type="text" id="birthday_display"
|
||||
value="{{ $user->birthday ? \Morilog\Jalali\Jalalian::fromCarbon($user->birthday)->format('Y/m/d') : '' }}"
|
||||
placeholder="اختیاری — انتخاب تاریخ"
|
||||
class="border border-gray-300 rounded-md text-center"
|
||||
autocomplete="off" readonly>
|
||||
<input type="hidden" name="birthday" id="birthday"
|
||||
value="{{ $user->birthday ? $user->birthday->format('Y-m-d') : '' }}">
|
||||
<button type="button" id="clear_birthday"
|
||||
class="text-xs text-gray-500 hover:text-red-500 cursor-pointer self-end">
|
||||
پاک کردن
|
||||
</button>
|
||||
</div>
|
||||
|
||||
<label class="pb-3">چت آیدی تلگرام:</label>
|
||||
<input type="text" pattern="\d+" name="chatid" value="{{ $user->chatid ?? '' }}"
|
||||
placeholder="چت آیدی تلگرام"
|
||||
@@ -71,6 +86,27 @@
|
||||
<button type="button" id="registerFingerprint" class="...">ثبت اثر انگشت</button>
|
||||
|
||||
<script>
|
||||
$(document).ready(function () {
|
||||
$('#birthday_display').persianDatepicker({
|
||||
format: 'YYYY/MM/DD',
|
||||
autoClose: true,
|
||||
initialValue: false,
|
||||
toolbox: {
|
||||
calendarSwitch: {enabled: false},
|
||||
todayButton: {enabled: true, text: {fa: 'امروز'}}
|
||||
},
|
||||
onSelect: function (unix) {
|
||||
const gregorian = new persianDate(unix).toCalendar('gregorian').toLocale('en');
|
||||
$('#birthday').val(gregorian.format('YYYY-MM-DD'));
|
||||
}
|
||||
});
|
||||
|
||||
$('#clear_birthday').on('click', function () {
|
||||
$('#birthday_display').val('');
|
||||
$('#birthday').val('');
|
||||
});
|
||||
});
|
||||
|
||||
function base64urlToBuffer(base64url) {
|
||||
const padding = '='.repeat((4 - base64url.length % 4) % 4);
|
||||
const base64 = (base64url + padding).replace(/-/g, '+').replace(/_/g, '/');
|
||||
|
||||
Reference in New Issue
Block a user