@extends('layouts.app') @section('title', 'Daftar Laporan') @section('content') @php $user = auth()->user(); $qcDept = \App\Models\Department::whereRaw("LOWER(name) LIKE '%quality%'") ->orWhereRaw("LOWER(name) LIKE '%qc%'")->first(); $isQcUser = $user->role === 'staff_departemen' && $qcDept && $user->department_id == $qcDept->id; $isMachineAuditor = $user->role === 'auditor' && $user->auditType && strtolower($user->auditType->name) === 'mesin'; @endphp
@if($user->role === 'auditor') Laporan Saya @elseif($isQcUser) Laporan untuk Diverifikasi QC @elseif($user->role === 'staff_departemen') Laporan yang Ditugaskan @else Semua Laporan @endif
@if($user->role === 'auditor') Buat Laporan @endif @if(in_array($user->role, ['super_admin', 'auditor', 'staff_departemen'])) Ekspor & Arsip @endif
Filter Laporan
@if($user->role === 'staff_departemen')
@else
@endif {{-- Filter Auditor: hanya untuk super_admin --}} @if($user->role === 'super_admin')
@endif
@if(request()->hasAny(['status', 'department', 'audit_type', 'auditor', 'period', 'date_from', 'date_to', 'search'])) @endif @if($reports->count() > 0) {{-- ══ Desktop Table ══ --}}
@if($user->role === 'staff_departemen') @else @endif @if($user->role === 'super_admin') @endif @if($isMachineAuditor) @endif @foreach($reports as $report) @php $isThisMachine = $report->auditType && strtolower($report->auditType->name) === 'mesin'; $now = now(); $overdueMsg = null; if ($report->status === 'submitted') { $days = (int) $report->created_at->diffInDays($now); if ($days >= 7) $overdueMsg = "Terlambat {$days} hari"; } elseif ($report->status === 'in_progress' && $report->deadline) { $dl = \Carbon\Carbon::parse($report->deadline); if ($now->greaterThan($dl)) { $late = (int) $dl->diffInDays($now); $overdueMsg = $late === 0 ? 'Lewat deadline hari ini' : "Lewat deadline {$late} hari"; } } @endphp @if($user->role === 'staff_departemen') @else @endif @if($user->role === 'super_admin') @endif @if($isMachineAuditor) @endif @endforeach
No. LaporanTipe AuditDepartemenAuditorJenis Masalah Lokasi Nama MesinStatus Tanggal Aksi
{{ $report->report_number }} {{ $report->auditType->name }} {{ $report->department->name }} {{ $report->auditor->name ?? '-' }} {{ Str::limit($report->issue_type, 28) }} {{ Str::limit($report->location, 28) }} @if($report->machine_name) {{ Str::limit($report->machine_name, 22) }} @else @endif {!! $report->status_badge !!} {{ $report->created_at->format('d M Y') }} {{ $report->created_at->format('H:i') }} @if($overdueMsg) {{ $overdueMsg }} @endif Lihat
{{-- ══ Tablet ══ --}}
@foreach($reports as $report) @php $isThisMachine = $report->auditType && strtolower($report->auditType->name) === 'mesin'; $now = now(); $overdueMsg = null; if ($report->status === 'submitted') { $days = (int) $report->created_at->diffInDays($now); if ($days >= 7) $overdueMsg = "Terlambat {$days} hari"; } elseif ($report->status === 'in_progress' && $report->deadline) { $dl = \Carbon\Carbon::parse($report->deadline); if ($now->greaterThan($dl)) { $late = (int) $dl->diffInDays($now); $overdueMsg = $late === 0 ? 'Lewat deadline hari ini' : "Lewat deadline {$late} hari"; } } @endphp
{{ $report->report_number }}
@if($user->role === 'staff_departemen') {{ $report->auditType->name }} @else {{ $report->department->name }} @endif @if($user->role === 'super_admin') {{ $report->auditor->name ?? '-' }} @endif @if($isMachineAuditor && $report->machine_name) {{ Str::limit($report->machine_name, 18) }} @endif
{!! $report->status_badge !!}

{{ $report->location }}

{{ $report->issue_type }}

{{ $report->created_at->format('d M Y H:i') }}

@if($overdueMsg) {{ $overdueMsg }} @endif Lihat Detail
@endforeach
{{-- ══ Mobile ══ --}}
@foreach($reports as $report) @php $isThisMachine = $report->auditType && strtolower($report->auditType->name) === 'mesin'; $now = now(); $overdueMsg = null; if ($report->status === 'submitted') { $days = (int) $report->created_at->diffInDays($now); if ($days >= 7) $overdueMsg = "Terlambat {$days} hari"; } elseif ($report->status === 'in_progress' && $report->deadline) { $dl = \Carbon\Carbon::parse($report->deadline); if ($now->greaterThan($dl)) { $late = (int) $dl->diffInDays($now); $overdueMsg = $late === 0 ? 'Lewat deadline hari ini' : "Lewat deadline {$late} hari"; } } @endphp
{{ $report->report_number }}
{!! $report->status_badge !!}
@if($user->role === 'staff_departemen') {{ Str::limit($report->auditType->name, 15) }} @else {{ Str::limit($report->department->name, 15) }} @endif @if($user->role === 'super_admin') {{ Str::limit($report->auditor->name ?? '-', 15) }} @endif @if($isMachineAuditor && $report->machine_name) {{ Str::limit($report->machine_name, 15) }} @endif

{{ Str::limit($report->location, 35) }}

{{ Str::limit($report->issue_type, 30) }}

{{ $report->created_at->format('d M Y H:i') }}

@if($overdueMsg) {{ $overdueMsg }} @endif Lihat Detail
@endforeach
{{-- Pagination Custom --}} @if($reports->lastPage() > 1)

Menampilkan {{ $reports->firstItem() }}{{ $reports->lastItem() }} dari {{ $reports->total() }} laporan

@endif @else
Tidak ada laporan ditemukan
@if(request()->hasAny(['status', 'department', 'audit_type', 'auditor', 'period', 'date_from', 'date_to', 'search']))

Coba ubah kriteria filter atau pencarian Anda

Reset Filter @elseif($user->role === 'auditor')

Anda belum membuat laporan apapun

Buat Laporan Pertama @endif
@endif
@endsection @push('styles') @endpush