@extends('layouts.app') @section('title', $complaint->complaint_no . ' - PMMS') @section('content')

{{ $complaint->complaint_no }}

{{-- Permintaan tambahan pengguna - Penyelaras Aduan boleh sunting semula maklumat asas aduan yang telah dihantar. --}} @can('editSubmitted', $complaint) {{ __('app.complaint.show.edit_button') }} @endcan {{ $complaint->status }}
{{-- Fasa 2 Langkah 33 (PMMS_Flowchart.html, Carta 1) - Pengesahan Akhir Ketua Juruteknik: semua WO sudah terminal, menunggu sahkan/tolak. --}} @can('finalVerify', $complaint) @if ($complaint->status === 'PENDING_FINAL_VERIFICATION')
{{ __('app.complaint.show.final_verify.header') }}

{{ __('app.complaint.show.final_verify.hint') }}

@csrf
@csrf
@endif @endcan {{-- Fasa 2 Langkah 29 (PMMS_Flowchart.html, Carta 1/4) - Semakan Penyelaras Aduan: lulus/tolak/hantar semula. Hanya kelihatan semasa status UNDER_REVIEW DAN pengguna ada kebenaran complaint.review. --}} @can('review', $complaint) @if ($complaint->status === 'UNDER_REVIEW')
{{ __('app.complaint.show.review.header') }}

{{ __('app.complaint.show.review.hint') }}

@csrf
@csrf
@csrf
@endif @endcan {{-- Fasa 2 Langkah 30 (PMMS_Flowchart.html, Carta 6a/6b) - Percubaan Hubungi Penyewa (maks 2) sebelum inspection boleh dijadualkan. Hanya kelihatan semasa status OPEN (selepas lulus) DAN pengguna ada kebenaran complaint.review. --}} @can('recordContactAttempt', $complaint) @if ($complaint->status === 'OPEN')
{{ __('app.complaint.show.contact.header', ['count' => $complaint->contactAttempts->count()]) }}
@if ($complaint->contactAttempts->isEmpty())

{{ __('app.complaint.show.contact.none_recorded') }}

@else @endif @if ($complaint->hasSuccessfulContactAttempt())

{{ __('app.complaint.show.contact.success_hint') }}

@elseif ($complaint->contactAttempts->count() >= 2)

{{ __('app.complaint.show.contact.max_reached_hint') }}

@else
@csrf
{{ __('app.complaint.show.contact.attempt_progress', ['current' => $complaint->contactAttempts->count() + 1]) }}
@endif
@endif @endcan {{-- requirements.md §48 - Maklumat Tenant. Fasa 2 Langkah 35: aduan unit kosong (is_vacant_unit) TIADA Tenant - papar "Dicipta Oleh (PIC)" sebagai ganti. --}}
{{ $complaint->is_vacant_unit ? __('app.complaint.show.tenant_info.vacant_unit_header') : __('app.complaint.show.tenant_info.tenant_header') }}
@if ($complaint->is_vacant_unit)
{{ __('app.complaint.show.tenant_info.created_by_pic') }}
{{ $complaint->creator?->name ?? '-' }}
@else
{{ __('app.complaint.show.tenant_info.tenant_name') }}
{{ $complaint->tenant->name }}
{{ __('app.complaint.show.tenant_info.tenant_code') }}
{{ $complaint->tenant->tenant_code }}
{{ __('app.complaint.show.tenant_info.phone') }}
{{ $complaint->tenant->phone ?? '-' }}
{{ __('app.complaint.show.tenant_info.email') }}
{{ $complaint->tenant->email ?? '-' }}
@endif
{{ __('app.complaint.unit_no') }}
{{ $complaint->unit->unit_no }}
{{ __('app.complaint.location') }}
{{ $complaint->unit->location?->name ?? '-' }}
{{ __('app.complaint.project') }}
{{ $complaint->project->project_name }}
@can('addWorkOrderForVacantUnit', $complaint)
{{ __('app.complaint.show.vacant_unit_add_wo.hint') }} {{ __('app.complaint.show.vacant_unit_add_wo.button') }}
@endcan {{-- Maklumat Complaint --}}
{{ __('app.complaint.show.info.header') }}
{{ __('app.complaint.show.info.no') }}
{{ $complaint->complaint_no }}
{{ __('app.complaint.show.info.title') }}
{{ $complaint->title }}
{{ __('app.complaint.show.info.contact_phone') }}
{{ $complaint->contact_phone ?? '-' }}
{{ __('app.complaint.show.info.damage_date') }}
{{ optional($complaint->damage_date)->format('d/m/Y') ?? '-' }}
{{ __('app.complaint.show.info.description') }}
{{ $complaint->description ?? '-' }}
{{ __('app.complaint.show.info.status') }}
{{ $complaint->status }}
{{ __('app.complaint.show.info.submitted_date') }}
{{ $complaint->submitted_at->format('d/m/Y H:i') }}
{{-- Work Orders - setiap satu dipaparkan berasingan (Bahagian 9.3 - kebebasan WO). Permintaan tambahan pengguna - dipaparkan sebagai table (bukan kad bertindih) supaya maklumat utama setiap WO mudah dibanding/nampak sekali imbas. --}}
{{ __('app.complaint.show.work_orders.header', ['count' => $complaint->workOrders->count()]) }}
@foreach ($complaint->workOrders as $workOrder) @endforeach
{{ __('app.complaint.show.work_orders.table.no') }} {{ __('app.complaint.show.work_orders.table.title') }} {{ __('app.complaint.show.work_orders.table.category') }} {{ __('app.complaint.show.work_orders.table.location') }} {{ __('app.complaint.show.work_orders.table.priority') }} {{ __('app.complaint.show.work_orders.table.status') }} {{ __('app.complaint.show.work_orders.table.inspection') }}
{{ $workOrder->work_order_no }} {{ $workOrder->title }} {{ $workOrder->category?->name ?? __('app.complaint.show.work_orders.category_pending') }} @if ($workOrder->category_other_note) ({{ $workOrder->category_other_note }}) @endif {{ $workOrder->location ?? '-' }} {{ $workOrder->priority ?? __('app.complaint.show.work_orders.priority_pending') }} {{ $workOrder->status ?? __('app.complaint.show.work_orders.pending_approval') }} {{-- Permintaan tambahan pengguna: Tenant WAJIB nampak tarikh inspection bersama nama staff yang akan datang, terus di sini (bukan perlu klik masuk Work Order Detail dahulu). --}} @if ($workOrder->inspections->isNotEmpty()) @foreach ($workOrder->inspections as $inspection)
{{ $inspection->inspection_date->format('d/m/Y') }}{{ $inspection->inspection_time ? ' '.$inspection->inspection_time : '' }} — {{ __('app.complaint.show.work_orders.staff_label', ['name' => $inspection->assignedStaff?->name ?? '-']) }}
@endforeach @elseif ($workOrder->status === 'OPEN') {{ __('app.complaint.show.work_orders.not_scheduled') }} @else - @endif
{{-- Attachments peringkat-Complaint (jika ada; kebanyakan attachment diskop Work Order - R-19). requirements.md §72/§73 (Langkah 26) - galeri imej + video HTML5. --}}
{{ __('app.complaint.show.attachment.header') }}
@if ($complaint->attachments->isEmpty())

{{ __('app.complaint.show.attachment.empty') }}

@else @include('partials.attachment-gallery', ['attachments' => $complaint->attachments, 'downloadRoute' => 'attachments.download']) @endif
{{-- Timeline - requirements.md §48/§50, architecture.md Bahagian 15 (Langkah 21). Unjuran kronologi status_history bagi Complaint ini (entity_type=COMPLAINT). --}}
{{ __('app.complaint.show.timeline.header') }}
@if ($statusHistory->isEmpty())

{{ __('app.complaint.show.timeline.empty') }}

@else @endif
{{-- Audit trail --}}
{{ __('app.complaint.show.audit.header') }}
@if ($auditLogs->isEmpty())

{{ __('app.complaint.show.audit.empty') }}

@else @endif
@endsection