@extends('layouts.app') @section('title', __('app.complaint.edit.title') . ' - PMMS') @section('content')

{{ __('app.complaint.edit.heading') }} {{ $complaint->complaint_no ? "{$complaint->complaint_no}" : __('app.complaint.table.draft') }}

@if ($sendBackReason) {{-- Fasa 2 Langkah 29 (PMMS_Flowchart.html, Carta 4) - "UnderReview -> Draft": Penyelaras Aduan hantar semula aduan ini kerana maklumat tidak lengkap. --}}
{{ __('app.complaint.edit.sent_back_notice') }}
{{ __('app.complaint.edit.sent_back_reason', ['reason' => $sendBackReason]) }}
{{ __('app.complaint.edit.sent_back_hint') }}
@endif
{!! __('app.complaint.readonly_card_header') !!}
{{ __('app.complaint.tenant_name') }}
{{ $tenant->name }}
{{ __('app.complaint.unit_no') }}
{{ $primaryUnit->unit->unit_no }}
{{ __('app.complaint.location') }}
{{ $primaryUnit->unit->location?->name ?? '-' }}
{{ __('app.complaint.project') }}
{{ $primaryUnit->unit->project->project_name }}
@csrf @method('PUT')
{{ __('app.complaint.edit.back') }}
{{ __('app.complaint.edit.work_orders_header', ['count' => $complaint->workOrders->count()]) }} {{ __('app.complaint.edit.add_work_order') }}

{!! __('app.complaint.edit.category_hint') !!}

@if ($complaint->workOrders->isEmpty())

{!! __('app.complaint.edit.no_work_orders') !!}

@else
@foreach ($complaint->workOrders as $i => $workOrder) @endforeach
{{ __('app.complaint.edit.table.no') }} {{ __('app.complaint.edit.table.title') }} {{ __('app.complaint.edit.table.location') }} {{ __('app.complaint.edit.table.attachments') }} {{ __('app.complaint.edit.table.actions') }}
{{ $i + 1 }} {{ $workOrder->title }} {{ $workOrder->location ?? '-' }} @if ($workOrder->attachments->isEmpty()) {{ __('app.complaint.edit.no_attachment_badge') }} @else {{ __('app.complaint.edit.attachment_count_badge', ['count' => $workOrder->attachments->count()]) }} @endif {{ __('app.complaint.edit.row_edit') }}
@csrf @method('DELETE')
@endif
{{-- requirements.md ยง22 (Langkah 12) - Submit Complaint. Nombor Aduan/Work Order dijana hanya di sini (OD-11), bukan semasa draf dicipta (OD-3). --}}
{{ __('app.complaint.edit.submit_header') }}
@php $workOrdersWithoutAttachment = $complaint->workOrders->filter(fn ($wo) => $wo->attachments->isEmpty()); @endphp @if ($complaint->workOrders->isEmpty())

{{ __('app.complaint.edit.submit_need_wo') }}

@elseif ($workOrdersWithoutAttachment->isNotEmpty())

{{ __('app.complaint.edit.submit_missing_attachment') }} {{ $workOrdersWithoutAttachment->pluck('title')->implode(', ') }}.

@else

{{ __('app.complaint.edit.submit_ready', ['count' => $complaint->workOrders->count()]) }}

@csrf
@endif
@csrf @method('DELETE')
@endsection