@livewire('frontend::list-data.request-list', ['page' => 'approval-list']) @if (!empty($lists))
{{-- หมายเหตุ: ถ้าหน้านี้มองไม่เห็นปุ่ม ให้ตรวจสอบ class "hidden" ที่อยู่ใน
ถ้าต้องการให้ปุ่มแสดงผล ให้เอา class "hidden" ออก หรือเปลี่ยนการจัดการแสดง/ซ่อนด้วย Alpine.js, Livewire หรือ JS อื่น ๆ ให้เหมาะสม --}}
@foreach ($lists as $code => $list) @endforeach
@php $hasSelectable = false; if (!empty($lists)) { foreach ($lists as $l) { $text_status = trim(strip_tags($l['status'])); // ถ้าใน status summary/render แล้วมีคำว่า "รออนุมัติ" ให้ถือว่ามี checkbox if ( (is_string($l['status']) && $text_status == 'รออนุมัติ') || (is_array($l['status_all'] ?? []) && collect($l['status_all'])->contains(function ($val) { return is_string($val) && $text_status == 'รออนุมัติ'; })) ) { $hasSelectable = true; break; } } } @endphp @if ($hasSelectable) @else - @endif พนักงาน / แผนก วันที่ สรุปรายการ สถานะ การจัดการ
@if (!in_array($status[0], $list['status_all'] ?? [])) - @else @if ($text == 'รออนุมัติ') - @else @endif @endif
{{ $list['name'] ?? '' }}
{{ $list['department'] ?? '' }}
{{ $list['submission_date'] ?? '' }}
{{ count($list['request_list']) ?? '' }} รายการ
รวม {{ array_sum(array_column($list['request_list'], 'distance_km')) ?? '' }} กม.
{!! $list['status'] ?? '' !!} @php $isFirstApprover = isset($member) && !empty($list['member_dt']->approve_by_first_id) && $list['member_dt']->approve_by_first_id == $member->id; $isSecondApprover = isset($member) && !empty($list['member_dt']->approve_by_second_id) && $list['member_dt']->approve_by_second_id == $member->id; $hasSecondApprover = !empty($list['member_dt']->approve_by_second_id); $minStatus = !empty($list['status_all']) ? min($list['status_all']) : 0; // ผู้อนุมัติที่ 1 อนุมัติแล้ว (status = 3) และมีผู้อนุมัติที่ 2 -> ซ่อนปุ่ม $hideButtonsForFirstApprover = $isFirstApprover && $hasSecondApprover && $minStatus == 3; // ผู้อนุมัติที่ 2 ต้องรอผู้อนุมัติที่ 1 ก่อน (status = 2) -> ซ่อนปุ่ม $hideButtonsForSecondApprover = $isSecondApprover && $minStatus == 2; $hideButtons = $hideButtonsForFirstApprover || $hideButtonsForSecondApprover; @endphp @if (!$hideButtons && (in_array($check_status, $list['status_all'] ?? []) || in_array(3, $list['status_all'] ?? []) || in_array(2, $list['status_all'] ?? []))) @else @if ($text == 'รออนุมัติ' )
รอผู้อนุมัติลำดับที่ 1
@endif @endif
@if (!empty($list['request_list'])) @foreach ($list['request_list'] as $request) @endforeach @endif
เลือก สถานะคำขอ สถานที่ปัจจุบัน สถานที่ไป เวลา
Check-in/out
ระยะทาง ค่าน้ำมัน สถานะ
@if (!$hideButtons && strpos($request['status'] ?? '', 'รออนุมัติ') !== false) @if (in_array($check_status, $list['status_all'] ?? []) || trim(strip_tags($list['status'])) !== 'อนุมัติแล้ว') @else - @endif @else - @endif {{ $request['status_request'] ?? '' }} @php $currentPlace = $request['current_place'] ?? ''; @endphp @if(mb_strlen($currentPlace) > 20) {{ mb_substr($currentPlace, 0, 20) }}
{{ mb_substr($currentPlace, 20) }} @else {{ $currentPlace }} @endif
@php $targetPlace = $request['target_place'] ?? ''; @endphp @if(mb_strlen($targetPlace) > 20) {{ mb_substr($targetPlace, 0, 20) }}
{{ mb_substr($targetPlace, 20) }} @else {{ $targetPlace }} @endif
{{ $request['time'] ?? '' }} - {{ $request['checkout_time'] ?? '' }} น. {{ $request['distance_km'] ?? '' }} {{ $request['oil_price'] ?? '' }} {!! $request['status'] ?? '' !!}
@if ($confirm_open)
@if (in_array($confirm_action_type, ['reject', 'reject_selected'])) ยืนยันการปฏิเสธ @else แจ้งเตือน @endif

{{-- เงื่อนไข: ถ้าไม่มีการเลือก checkbox เลย (เลือกได้อย่างน้อย 1 รายการเท่านั้น) --}} {{-- @if (isset($no_checkbox_selected) && $no_checkbox_selected) กรุณาเลือกอย่างน้อย 1 รายการ66 @else --}} @if (in_array($confirm_action_type, ['reject', 'reject_selected']))

@if (strlen($remarks) > 0) ✓ {{ strlen($remarks) }} ตัวอักษร @else ⚠ กรุณากรอกเหตุผล @endif
@else ต้องการอนุมัติรายการนี้หรือไม่? @endif {{-- @endif --}}

{{-- ถ้าไม่มี checkbox ให้เลือก และ $confirm_action_type เป็น approve/reject selected --}} {{-- @if (isset($no_checkbox_selected) && $no_checkbox_selected)
@else --}}
{{-- @endif --}}
@endif @if ($show_reject_modal)
ยืนยันการปฏิเสธ
@if (!empty($remarks)) ✓ {{ strlen($remarks) }} ตัวอักษร @else ⚠ กรุณากรอกเหตุผล @endif
@endif
@endif