Improve tasks UI, dark theme, performance fixes, and admin pages polish
This commit is contained in:
@@ -1,63 +1,9 @@
|
||||
<?php
|
||||
|
||||
use App\Models\Attendance;
|
||||
use App\Models\AttendanceBreak;
|
||||
use Morilog\Jalali\Jalalian;
|
||||
use Carbon\Carbon;
|
||||
|
||||
//dd($reqs);
|
||||
$now = Jalalian::fromCarbon(Carbon::now());
|
||||
foreach ($users as $user) {
|
||||
$totaltime = 0;
|
||||
$tsec = 0;
|
||||
foreach ($user->attendances as $att) {
|
||||
$date = $att->entered_at != null ? Jalalian::fromCarbon(Carbon::parse($att->entered_at)) : null;
|
||||
$att->date = $date != null ? $date->format('Y/m/d') : null;
|
||||
if ($att->duration != null && $date != null && $now->getMonth() == $date->getMonth()) {
|
||||
[$h, $m, $s] = explode(':', $att->duration);
|
||||
$tsec += $h * 3600 + $m * 60 + $s;
|
||||
}
|
||||
}
|
||||
$hours = floor($tsec / 3600);
|
||||
$minutes = floor(($tsec % 3600) / 60);
|
||||
$seconds = $tsec % 60;
|
||||
|
||||
$totalTime = sprintf('%02d:%02d', $hours, $minutes);
|
||||
$user->totaltime = $totalTime;
|
||||
|
||||
}
|
||||
//dd($users);
|
||||
$now = now()->format('Y-m-d');
|
||||
foreach ($users as $u) {
|
||||
|
||||
$us = $u->attendances()
|
||||
->whereNull('exited_at')
|
||||
->latest('entered_at')
|
||||
->first();
|
||||
// dump($us);
|
||||
if ($us) {
|
||||
$us->entered_at = Carbon::parse($us->entered_at)->format('Y-m-d');
|
||||
if ($us->entered_at == $now)
|
||||
$us = true;
|
||||
else
|
||||
$us = false;
|
||||
$u->working = $us ? 1 : 0;
|
||||
} else
|
||||
$u->working = 0;
|
||||
|
||||
foreach ($u->attendances as $u_att) {
|
||||
$break = AttendanceBreak::wherenull('break_end')->where('attendance_id', $u_att->id)->exists();
|
||||
if ($break)
|
||||
$u->working = 2;
|
||||
}
|
||||
|
||||
}
|
||||
//dd($users);
|
||||
$users = $users->sortByDesc('working');
|
||||
//$users = json_decode(json: $users);
|
||||
// $users = collect($users);
|
||||
$usersChunked = $users->chunk(3);
|
||||
//dd($users);
|
||||
?>
|
||||
|
||||
|
||||
@@ -66,43 +12,35 @@ $usersChunked = $users->chunk(3);
|
||||
<div class="container w-full flex flex-col items-center">
|
||||
|
||||
@if(!collect($reqs)->pluck('attendances')->flatten()->isEmpty())
|
||||
<div class="mt-10 bg-white rounded-lg shadow-md max-w-[350px] flex flex-col items-center">
|
||||
<p style="min-font-size: 30; text-align: center; margin-bottom: 10px">درخواست ها</p>
|
||||
{{-- {{dd($reqs)}}--}}
|
||||
<div class="ui-requests-card flex flex-col items-center">
|
||||
<p>درخواست ها</p>
|
||||
|
||||
@foreach ($reqs as $u)
|
||||
@if(!empty($u['attendances']))
|
||||
|
||||
<button type="button"
|
||||
class="w-[150px] p-3 font-bold text-white bg-blue-500 hover:bg-blue-700 rounded transition duration-150 text-center "
|
||||
onclick="togglerequests('attendance-{{ $loop->index }}')"
|
||||
style="margin: 10px 0; text-align: center; background-color: #00bcd4">
|
||||
class="ui-chip-btn"
|
||||
onclick="togglerequests('attendance-{{ $loop->index }}')">
|
||||
{{ $u['name'] }}
|
||||
</button>
|
||||
{{-- @else--}}
|
||||
{{-- <p class="text-stone-400" style="text-align: center">درخواستی ثبت نشده</p>--}}
|
||||
{{-- @break--}}
|
||||
@endif
|
||||
<div id="attendance-{{ $loop->index }}" class="hidden-content pt-4">
|
||||
<table style="max-width: 350px; margin: auto; text-align: center" class="w-[350px] table-auto">
|
||||
<div id="attendance-{{ $loop->index }}" class="hidden-content pt-4 w-full">
|
||||
<div class="ui-table-wrap">
|
||||
<table class="w-full table-auto">
|
||||
|
||||
<thead>
|
||||
<tr class="text-sm" style="background-color: #00a3ba; color: white; text-align: center;">
|
||||
|
||||
<th class="px-2 py-2 border w-1/6">درخواست</th>
|
||||
<th class="px-2 py-2 border w-1/6">تاریخ</th>
|
||||
<th class="px-2 py-2 border w-1/6">ورود</th>
|
||||
<th class="px-2 py-2 border w-1/6">خروج</th>
|
||||
{{-- @if($userType == 'admin')--}}
|
||||
<th class="px-2 py-2 border w-1/6">تعیین وضعیت</th>
|
||||
{{-- @endif--}}
|
||||
<tr>
|
||||
<th class="px-2 py-2 w-1/6">درخواست</th>
|
||||
<th class="px-2 py-2 w-1/6">تاریخ</th>
|
||||
<th class="px-2 py-2 w-1/6">ورود</th>
|
||||
<th class="px-2 py-2 w-1/6">خروج</th>
|
||||
<th class="px-2 py-2 w-1/6">تعیین وضعیت</th>
|
||||
</tr>
|
||||
</thead>
|
||||
|
||||
<tbody>
|
||||
{{-- {{dd($u['attendances'])}}--}}
|
||||
@forelse($u['attendances'] as $rec)
|
||||
<tr style="background-color: {{$rec->id=='new' ? 'lightblue' : 'white'}}">
|
||||
<tr class="{{ $rec->id=='new' ? 'is-new' : '' }}">
|
||||
{{--{{dd($rec)}}--}}
|
||||
<td class="px-4 py-2 border">{{ match ($rec->function) {
|
||||
'edit' => "تغییر ساعت",
|
||||
@@ -138,8 +76,7 @@ $usersChunked = $users->chunk(3);
|
||||
<input type="hidden" name="update" id="update" value="approve">
|
||||
<input type="hidden" name="data" id="data"
|
||||
value="{{json_encode($rec)}}">
|
||||
<button class="bg-white rounded w-full"
|
||||
style="background-color: #81ff65; margin-bottom: 5px">
|
||||
<button type="submit" class="ui-btn-approve">
|
||||
تایید
|
||||
</button>
|
||||
</form>
|
||||
@@ -148,8 +85,7 @@ $usersChunked = $users->chunk(3);
|
||||
<input type="hidden" name="update" id="update" value="reject">
|
||||
<input type="hidden" name="data" id="data"
|
||||
value="{{json_encode($rec)}}">
|
||||
<button class="bg-white rounded w-full"
|
||||
style="background-color: #ff6565">
|
||||
<button type="submit" class="ui-btn-reject">
|
||||
رد
|
||||
</button>
|
||||
</form>
|
||||
@@ -163,7 +99,8 @@ $usersChunked = $users->chunk(3);
|
||||
@endforelse
|
||||
</tbody>
|
||||
</table>
|
||||
</div> {{-- پایان hidden-content --}}
|
||||
</div>
|
||||
</div>
|
||||
@endforeach
|
||||
{{-- @if(collect($reqs)->pluck('attendances')->flatten()->isEmpty())--}}
|
||||
{{-- <p class="text-stone-400" style="text-align: center">درخواستی ثبت نشده</p>--}}
|
||||
@@ -175,38 +112,29 @@ $usersChunked = $users->chunk(3);
|
||||
<div class="grid grid-cols-2 grid-rows-none ">
|
||||
@foreach ($usersChunked as $chunk)
|
||||
@foreach ($chunk as $u)
|
||||
<div class="form m-3 justify-evenly rounded-lg shadow-md "
|
||||
style="align-items: center; text-align: center; border: 2px solid
|
||||
{{ $u->active_task ? '#00ff15' : ($u->working == 1 ? '#16c8ce' : ($u->working == 2 ? 'orange' : 'white' ))}}; padding: 10px; ">
|
||||
@php
|
||||
@endphp
|
||||
<a href="/admin/{{ $u->user_name }}"
|
||||
class=" rounded-xl"
|
||||
style="text-decoration: none; color: inherit;">
|
||||
<p style="font-weight: bold ; color:#333;">
|
||||
{{ $u->name ?? $u->user_name }}
|
||||
</p>
|
||||
@php
|
||||
$cardClass = 'ui-user-card m-3';
|
||||
if ($u->active_task) {
|
||||
$cardClass .= ' is-active';
|
||||
} elseif ($u->working == 1) {
|
||||
$cardClass .= ' is-working';
|
||||
} elseif ($u->working == 2) {
|
||||
$cardClass .= ' is-break';
|
||||
}
|
||||
@endphp
|
||||
<div class="{{ $cardClass }}">
|
||||
<a href="/admin/{{ $u->user_name }}">
|
||||
<p class="ui-user-name">{{ $u->name ?? $u->user_name }}</p>
|
||||
@if($u->active_task)
|
||||
<p>وظیفه: {{ $u->active_task }}</p>
|
||||
@endif
|
||||
<p>
|
||||
کارکرد ماه جاری:
|
||||
{{ $u->totaltime }}
|
||||
</p>
|
||||
|
||||
<p>
|
||||
تعداد درخواست ها:
|
||||
{{ $u->req_counts }}
|
||||
</p>
|
||||
|
||||
<p>کارکرد ماه جاری: {{ $u->totaltime }}</p>
|
||||
<p>تعداد درخواست ها: {{ $u->req_counts }}</p>
|
||||
</a>
|
||||
@if($userType == 'admin')
|
||||
|
||||
<button type="button"
|
||||
class="rounded-lg bg-cyan-500 hover:bg-cyan-600"
|
||||
onclick="window.location.href='{{ url('attendance/profile').'?username='.$u->user_name }}'"
|
||||
style=" border: none; color: white; padding: 5px 10px; text-align: center; text-decoration: none;
|
||||
display: inline-block; font-size: 16px; margin: 4px 2px; cursor: pointer; ">
|
||||
class="ui-chip-btn mt-2 !min-w-0 !w-auto !text-sm"
|
||||
onclick="window.location.href='{{ url('attendance/profile').'?username='.$u->user_name }}'">
|
||||
ویرایش
|
||||
</button>
|
||||
@endif
|
||||
@@ -214,10 +142,8 @@ $usersChunked = $users->chunk(3);
|
||||
|
||||
@endforeach
|
||||
@endforeach
|
||||
<a class="form m-3 justify-evenly rounded-lg shadow-md " href="{{route('admin.new')}}"
|
||||
style="align-items: center; text-align: center; ">
|
||||
<i class="fa-regular fa-plus "
|
||||
style="font-size: 80px; width: 90%; height: 90%;"></i>
|
||||
<a class="ui-user-card m-3 flex items-center justify-center min-h-[140px]" href="{{route('admin.new')}}">
|
||||
<i class="fa-regular fa-plus text-5xl text-gray-400"></i>
|
||||
</a>
|
||||
</div>
|
||||
|
||||
|
||||
Reference in New Issue
Block a user