Changes to holidays and the overlap between this year and the previous year
This commit is contained in:
@@ -3,7 +3,10 @@
|
||||
use Morilog\Jalali\Jalalian;
|
||||
use Carbon\Carbon;
|
||||
|
||||
$previousMonthName = Jalalian::now()->subMonths(1)->format('%B');
|
||||
$previous = Jalalian::now()->subMonths(1);
|
||||
$previousMonthKey = sprintf('%04d-%02d', $previous->getYear(), $previous->getMonth());
|
||||
$previousMonthName = $previous->format('%B');
|
||||
$currentJalaliYear = Jalalian::now()->getYear();
|
||||
|
||||
$employeeTotals = [];
|
||||
|
||||
@@ -267,7 +270,7 @@ foreach ($data as $employee) {
|
||||
<h2>{{ $employee->name }}</h2>
|
||||
<div class="employee-stat">
|
||||
<span>کارکرد ماه قبل ({{ $previousMonthName }}):</span>
|
||||
<strong>{{ $employeeTotals[$employee->id][$previousMonthName] ?? '00:00' }}</strong>
|
||||
<strong>{{ $employeeTotals[$employee->id][$previousMonthKey] ?? '00:00' }}</strong>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
@@ -282,10 +285,23 @@ foreach ($data as $employee) {
|
||||
@else
|
||||
<div class="month-tabs">
|
||||
@foreach(array_keys($recordsGrouped) as $month)
|
||||
@php
|
||||
$monthLabel = $month;
|
||||
if (preg_match('/^(\d{4})-(\d{2})$/', (string) $month, $mm)) {
|
||||
try {
|
||||
$jj = new Jalalian((int) $mm[1], (int) $mm[2], 1);
|
||||
$monthLabel = ((int) $mm[1] === (int) $currentJalaliYear)
|
||||
? $jj->format('%B')
|
||||
: $jj->format('%B') . ' ' . $mm[1];
|
||||
} catch (\Throwable $e) {
|
||||
$monthLabel = $month;
|
||||
}
|
||||
}
|
||||
@endphp
|
||||
<button type="button"
|
||||
class="month-tab tablinks-{{ $employee->id }}"
|
||||
onclick="openMonth(event, 'month_{{ $employee->id }}_{{ $month }}', '{{ $employee->id }}')">
|
||||
{{ $month }}
|
||||
{{ $monthLabel }}
|
||||
</button>
|
||||
@endforeach
|
||||
</div>
|
||||
@@ -307,7 +323,7 @@ foreach ($data as $employee) {
|
||||
<tbody>
|
||||
@foreach($records as $row)
|
||||
<tr>
|
||||
<td>{{ \App\Support\JalaliHelper::format($row->entered_at, 'm/d') }}</td>
|
||||
<td>{{ \App\Support\JalaliHelper::format($row->entered_at, 'Y/m/d') }}</td>
|
||||
<td>{{ \App\Support\JalaliHelper::format($row->entered_at, '%A') }}</td>
|
||||
<td>{{ Carbon::parse($row->entered_at)->format('H:i') ?? '-' }}</td>
|
||||
<td>{{ $row->exited_at ? Carbon::parse($row->exited_at)->format('H:i') : '-' }}</td>
|
||||
|
||||
Reference in New Issue
Block a user