91 lines
3.3 KiB
PHP
Executable File
91 lines
3.3 KiB
PHP
Executable File
<?php
|
|
|
|
use Morilog\Jalali\Jalalian;
|
|
use Carbon\Carbon;
|
|
|
|
$monthlyTotals = [];
|
|
|
|
foreach ($data as $month => $attendances) {
|
|
$tsec = 0;
|
|
|
|
foreach ($attendances as $attendance) {
|
|
if (!empty($attendance->duration)) {
|
|
[$h, $m, $s] = explode(':', $attendance->duration);
|
|
$tsec += (int)$h * 3600 + (int)$m * 60 + (int)$s;
|
|
}
|
|
}
|
|
|
|
$hours = floor($tsec / 3600);
|
|
$minutes = floor(($tsec % 3600) / 60);
|
|
|
|
$monthlyTotals[$month] = sprintf('%02d:%02d', $hours, $minutes);
|
|
}
|
|
|
|
?>
|
|
@extends('app')
|
|
|
|
@section('content')
|
|
<div class="ui-page">
|
|
@if(empty($data))
|
|
<div class="ui-empty">
|
|
<h1>اطلاعاتی موجود نمیباشد</h1>
|
|
</div>
|
|
@else
|
|
<div class="ui-month-tabs" style="margin-top: 5rem;">
|
|
@foreach(array_keys($data) as $month)
|
|
<button type="button" class="tablinks" onclick="openCity(event, '{{ $month }}')">{{ $month }}</button>
|
|
@endforeach
|
|
</div>
|
|
|
|
@foreach($data as $month => $records)
|
|
<div id="{{ $month }}" class="tabcontent ui-attendance-card">
|
|
<table class="ui-attendance-table">
|
|
<thead>
|
|
<tr>
|
|
<th>تاریخ</th>
|
|
<th>روز</th>
|
|
<th>ورود</th>
|
|
<th>خروج</th>
|
|
<th>مدت</th>
|
|
</tr>
|
|
</thead>
|
|
<tbody>
|
|
@foreach($records as $row)
|
|
<tr>
|
|
<td>{{ Jalalian::fromCarbon(Carbon::parse($row->entered_at))->format('m/d') ?? '-' }}</td>
|
|
<td>{{ Jalalian::fromCarbon(Carbon::parse($row->entered_at))->format('%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>
|
|
<td>{{ $row->exited_at ? Carbon::parse($row->duration)->format('H:i') : '-' }}</td>
|
|
</tr>
|
|
@endforeach
|
|
<tr>
|
|
<td colspan="5" class="table-summary">
|
|
مجموع کارکرد این ماه: {{ $monthlyTotals[$month] }}
|
|
</td>
|
|
</tr>
|
|
</tbody>
|
|
</table>
|
|
</div>
|
|
@endforeach
|
|
@endif
|
|
</div>
|
|
|
|
<script>
|
|
function openCity(evt, Month) {
|
|
document.querySelectorAll('.tabcontent').forEach(el => el.style.display = 'none');
|
|
document.querySelectorAll('.tablinks').forEach(el => el.classList.remove('active'));
|
|
|
|
const panel = document.getElementById(Month);
|
|
if (panel) panel.style.display = 'block';
|
|
|
|
if (evt.currentTarget) evt.currentTarget.classList.add('active');
|
|
}
|
|
|
|
document.addEventListener('DOMContentLoaded', function () {
|
|
const firstTab = document.querySelector('.tablinks');
|
|
if (firstTab) firstTab.click();
|
|
});
|
|
</script>
|
|
@endsection
|