@extends('layouts.app') @section('title', 'Application 360 - '.$application->application_number) @section('content') @php $stageCode = $application->currentStage?->stage_code; $visitedStageIds = $application->stageHistory->pluck('to_stage_id')->unique(); $contact = $application->customer?->contact; $activeInvoice = $application->invoiceItems->pluck('invoice')->filter()->sortByDesc('id')->first(); @endphp
@if($errors->any())
This action needs attention
@endif
{{ $application->priority }}{{ str($application->status)->replace('_',' ') }}{{ $application->service?->authority?->code ?? 'UAE Service' }}

{{ $application->application_number }}

{{ $application->customer?->full_name_en }} · {{ $application->service?->name_en }} · {{ $application->branch?->name ?? 'All branches' }}

Current Stage{{ $application->currentStage?->stage_name_en ?? 'Not configured' }}
Assigned Staff{{ $application->assignedUser?->name ?? 'Role queue' }}
Payment{{ str($application->payment_status)->replace('_',' ')->title() }}
Stage SLA{{ $application->sla_paused_at ? 'Paused' : ($application->due_at?->diffForHumans() ?? 'No deadline') }}

UAE Application Lifecycle

@foreach($allStages as $stage) @php $isCurrent = $stage->id === $application->current_stage_id; $isVisited = $visitedStageIds->contains($stage->id); @endphp
{{ $loop->iteration }}@if($stage->sla_minutes){{ $stage->sla_minutes }}m@endif
{{ $stage->stage_name_en }}{{ $stage->queue_role ? str($stage->queue_role)->replace('_',' ') : $stage->stage_type }}
@endforeach
C

Customer

{{ $application->customer?->full_name_en }}{{ $contact?->primary_mobile ?? 'No mobile' }}
D

Documents

{{ $application->documents->where('status','verified')->count() }}/{{ $application->documents->where('is_mandatory',true)->count() }}{{ str($application->document_status)->replace('_',' ')->title() }}
AED

Total Fee

{{ number_format((float)$application->total_price,2) }}Government + service + VAT
T

Open Tasks

{{ $application->workflowTasks->whereNotIn('status',['completed','cancelled'])->count() }}{{ $application->workflowTasks->count() }} workflow tasks

Current Stage Instructions

{{ $application->currentStage?->instructions ?? 'Follow the configured service workflow.' }}

{{ str($application->sla_status)->replace('_',' ')->title() }}
@foreach([ ['Mandatory documents', !$application->currentStage?->requires_documents || $application->document_status === 'verified'], ['Payment arrangement', !$application->currentStage?->requires_payment || in_array($application->payment_status,['paid','credit_account','corporate_credit']) || (float)$application->total_price <= 0], ['Supervisor approval', !$application->currentStage?->requires_approval || $stageApproval?->status === 'approved'], ['Government submission', !$application->currentStage?->requires_submission || $application->submissions->isNotEmpty()], ['Approved output', !$application->currentStage?->requires_output || $application->outputs->where('status','ready')->isNotEmpty()], ['Customer notification', !$application->currentStage?->requires_notification || $application->customer_notified_at], ] as [$label,$ready])
{{ $ready ? '✓' : '!' }}{{ $label }}
@endforeach

Service Accountability

Permanent staff attribution remains visible after every workflow handoff.

Audit ready

Customer attended by

{{ $application->attendedBy?->name ?? $application->creator?->name ?? 'Not recorded' }}Intake / front desk

Service typed by

{{ $application->typedByUser?->name ?? 'Typing not started' }}Responsible typist

Typing started

{{ $application->typing_started_at?->format('d M Y, h:i A') ?? 'Not started' }}Latest typing cycle

Typing completed

{{ $application->typing_completed_at?->format('d M Y, h:i A') ?? 'In progress' }}Submitted for quality check

Application Document Checklist

Mandatory evidence must be uploaded and verified before the workflow can advance.

{{ str($application->document_status)->replace('_',' ')->title() }}
@forelse($application->documents as $document) @empty @endforelse
RequirementSourceFileStatusControlled Action
{{ $document->display_name }}{{ $document->is_mandatory ? 'Mandatory' : 'Optional' }} · {{ $document->documentType?->code }}{{ str($document->source_entity)->replace('_',' ')->title() }}{{ $document->customer_document_id ? 'Linked vault version' : 'Application upload' }}{{ $document->attachment_path || $document->customer_document_id ? 'Available' : 'Missing' }}@if($document->rejection_reason){{ $document->rejection_reason }}@endif{{ ucfirst($document->status) }} @if(auth()->user()->hasPermission('documents.upload'))
Upload / Review
@csrf
@csrf
@elseRead only@endif
No document rules configured

This service can pass document verification without attachments.

@if($stageCode === 'GOVERNMENT_SUBMISSION' && auth()->user()->hasPermission('applications.submit'))

Record Government Submission

Every portal attempt is immutable and receives its own attempt number.

Attempt {{ $application->submissions->count()+1 }}
@csrf
@endif @if($stageCode === 'GOVERNMENT_PROCESSING')
@if(auth()->user()->hasPermission('applications.approve'))
@csrfGovernment Approved
@endif @if(auth()->user()->hasPermission('applications.edit'))
@csrfReturned for Correction
@endif @if(auth()->user()->hasPermission('applications.reject'))
@csrfGovernment Rejected
@endif
@endif

Government Attempt History

Returns and resubmissions never overwrite earlier attempts.

{{ $application->submissions->count() }} attempt(s)
@forelse($application->submissions as $submission) @empty@endforelse
AttemptAuthority / PortalReferencesGovernment FeeStatusResponse
#{{ $submission->attempt_number }}{{ $submission->created_at->format('d M Y, h:i A') }}{{ $submission->authority_code }}{{ $submission->portal_name }}{{ $submission->government_reference }}{{ $submission->request_number ?: $submission->transaction_number }}AED {{ number_format((float)$submission->gov_fee_paid,2) }}{{ $submission->receipt_number }}{{ ucfirst($submission->status) }}{{ $submission->response_at?->format('d M Y, h:i A') ?? 'Awaiting response' }}@if($submission->return_reason){{ $submission->return_reason }}@endif
GNo submission attempts

Advance to Government Submission to record the first attempt.

@if(in_array($stageCode,['GOVERNMENT_APPROVED','OUTPUT_READY']) && auth()->user()->hasPermission('documents.upload'))

Upload Approved Government Output

Store the exact delivered permit, visa, form, license or official receipt.

@csrf
@endif

Output Register

Customer-visible final records attached to this application.

{{ ucfirst($application->output_status) }}
@forelse($application->outputs as $output)@empty@endforelse
DocumentTypeReferenceValidityStatus
{{ $output->document_name }}By {{ $output->uploader?->name }} · {{ $output->created_at->diffForHumans() }}{{ str($output->output_type)->replace('_',' ')->title() }}{{ $output->reference_number ?: 'Not recorded' }}{{ $output->issue_date?->format('d M Y') ?? '—' }}{{ $output->expiry_date ? 'Expires '.$output->expiry_date->format('d M Y') : 'No expiry' }}{{ ucfirst($output->status) }}
ONo approved outputs uploaded

Outputs become available after government approval.

@if(in_array($stageCode,['OUTPUT_READY','CUSTOMER_NOTIFICATION']) && auth()->user()->hasPermission('communications.manage'))

Notify Customer

Log the channel and exact collection message.

@csrf
@if($stageCode==='CUSTOMER_NOTIFICATION')

Secure Delivery Acknowledgement

Identify the recipient before closing the application.

@csrf
@endif
@endif

Immutable Fee Snapshot

Government money remains separated from typing-center revenue.

@if(auth()->user()->hasPermission('payments.view')){{ $activeInvoice ? 'Open Invoice' : 'Open POS' }}@endif
@foreach($application->feeItems as $fee)@endforeach
FeeClassificationTaxAmount
{{ $fee->name_en }}{{ $fee->fee_code }}{{ str($fee->revenue_classification)->replace('_',' ')->title() }}{{ str($fee->tax_behavior)->replace('_',' ')->title() }}AED {{ number_format((float)$fee->amount,2) }}
TotalAED {{ number_format((float)$application->total_price,2) }}

Workflow Tasks

Role handoffs create traceable operational assignments.

Task Center
@forelse($application->workflowTasks as $task)@empty@endforelse
TaskAssignedDueStatus
{{ $task->task_number }} · {{ $task->title }}{{ $task->description }}{{ $task->assignedUser?->name ?? 'Role queue' }}{{ $task->due_at?->format('d M Y, h:i A') ?? 'No deadline' }}{{ str($task->status)->replace('_',' ')->title() }}
TNo workflow tasks yet

The next role handoff creates an operational task.

Complete Application Timeline

Stage movements, assignments and government actions are immutable.

@foreach($application->stageHistory->sortByDesc('created_at') as $history)
{{ $history->action_name }}

{{ $history->fromStage?->stage_name_en ?? 'Application created' }} → {{ $history->toStage?->stage_name_en }}

{{ $history->created_at->format('d M Y, h:i A') }}

{{ $history->remarks }}

By {{ $history->performedByUser?->name }}
@endforeach
@endsection