Improve tasks UI, dark theme, performance fixes, and admin pages polish

This commit is contained in:
2026-06-02 18:45:01 +03:30
parent 54aa8f40dd
commit 300575930f
18 changed files with 2598 additions and 780 deletions
+50 -66
View File
@@ -3,14 +3,12 @@
use Morilog\Jalali\Jalalian;
use Carbon\Carbon;
//dd($data);
$monthlyTotals = [];
foreach ($data as $month => $attendances) {
$tsec = 0;
foreach ($attendances as $attendance) {
// اگر duration موجود باشه استفاده می‌کنیم
if (!empty($attendance->duration)) {
[$h, $m, $s] = explode(':', $attendance->duration);
$tsec += (int)$h * 3600 + (int)$m * 60 + (int)$s;
@@ -19,88 +17,74 @@ foreach ($data as $month => $attendances) {
$hours = floor($tsec / 3600);
$minutes = floor(($tsec % 3600) / 60);
$seconds = $tsec % 60;
// ذخیره در آرایه جدید با کل زمان ماه
$monthlyTotals[$month] = sprintf('%02d:%02d', $hours, $minutes);
}
//dd($monthlyTotals);
?>
@extends('app')
@section('content')
<div class="container inline-flex flex-col items-center justify-center ">
@section('content')
<div class="ui-page">
@if(empty($data))
<div class="mt-80 text-gray-500 text-xl font-bold italic">
<div class="ui-empty">
<h1>اطلاعاتی موجود نمیباشد</h1>
</div>
@else
<div class="tab rounded-t-2xl max-w-[350px] mx-auto flex"
style="margin-top: 80px; max-width: 350px">
@foreach(array_keys($data) as $month)
<button class="tablinks active rounded-t-2xl cursor-pointer" onclick="openCity(event, '{{$month}}')">{{$month}}</button>
@endforeach
</div>
@foreach($data as $month => $records)
<div id="{{$month}}" class="tabcontent w-[350px] bg-white rounded-b-xl rounded-tl-2xl cursor-default leading-7" style="">
<table class="" style="width:100%; border-collapse: collapse;text-align: center">
<thead>
<tr class="" style="border-bottom: 1px solid #ddd;">
<th style="border-right: 1px solid #ddd;">تاریخ</th>
<th style="border-right: 1px solid #ddd;">روز</th>
<th style="border-right: 1px solid #ddd;">ورود</th>
<th style="border-right: 1px solid #ddd;">خروج</th>
<th style="border-right: 1px solid #ddd;">مدت</th>
</tr>
</thead>
<tbody >
@foreach($records as $row)
<tr class="hover:bg-cyan-500" style="border-bottom: 1px solid #ddd;">
<td style="border-right: 1px solid #ddd;">{{ Jalalian::fromCarbon(\Carbon\Carbon::parse($row->entered_at))->format('m/d') ?? '-' }}</td>
<td style="border-right: 1px solid #ddd;">{{ Jalalian::fromCarbon(\Carbon\Carbon::parse($row->entered_at))->format('%A') ?? '-' }}</td>
<td style="border-right: 1px solid #ddd;">{{ \Carbon\Carbon::parse($row->entered_at)->format('H:i') ?? '-' }}</td>
<td style="border-right: 1px solid #ddd;">{{ $row->exited_at ? \Carbon\Carbon::parse($row->exited_at)->format('H:i') : '-' }}</td>
<td style="border-right: 1px solid #ddd;">{{ $row->exited_at ? \Carbon\Carbon::parse($row->duration)->format('H:i') : '-' }}</td>
</tr>
@endforeach
<tr>
<td colspan="5" class="hover:bg-cyan-500 rounded-b-xl" style="border-top: 1px solid #ddd; text-align: center; ">
مجموع کارکرد این ماه: {{$monthlyTotals[$month]}}
</td>
</tr>
</tbody>
</table>
<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>
@endforeach
@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) {
var i, tabcontent, tablinks;
tabcontent = document.getElementsByClassName("tabcontent");
for (i = 0; i < tabcontent.length; i++) {
tabcontent[i].style.display = "none";
}
tablinks = document.getElementsByClassName("tablinks");
for (i = 0; i < tablinks.length; i++) {
tablinks[i].className = tablinks[i].className.replace(" active", "");
}
document.getElementById(Month).style.display = "block";
evt.currentTarget.className += " active";
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 () {
let firstTab = document.querySelector(".tablinks"); // اولین دکمه
if (firstTab) {
firstTab.click(); // همون اول کلیک مجازی بخوره
}
document.addEventListener('DOMContentLoaded', function () {
const firstTab = document.querySelector('.tablinks');
if (firstTab) firstTab.click();
});
</script>
@endsection