@extends('layouts.app')
@section('title', 'Documents — ' . $job->job_number)
@section('breadcrumb')
Jobs
{{ $job->job_number }}
Documents
@endsection
@section('content')
@php
$tabs = [
'original_designer_plans' => ['label' => 'Original Designer Plans', 'icon' => 'fa-drafting-compass'],
'variations' => ['label' => 'Variations', 'icon' => 'fa-random'],
'production_plans' => ['label' => 'Production Plans', 'icon' => 'fa-industry'],
'sample_door_requests' => ['label' => 'Sample Door Requests', 'icon' => 'fa-door-open'],
'appliances' => ['label' => 'Appliances', 'icon' => 'fa-blender'],
'delivery' => ['label' => 'Delivery', 'icon' => 'fa-truck'],
'photographs' => ['label' => 'Photographs', 'icon' => 'fa-camera'],
'pm' => ['label' => 'PM', 'icon' => 'fa-user-tie'],
'home_warranty' => ['label' => 'Home Warranty', 'icon' => 'fa-home'],
];
$imageTypes = ['image/jpeg','image/png','image/gif','image/webp'];
@endphp
{{-- Header --}}
Job Documents
{{ $job->job_number }}
{{ $job->contact?->full_name ?? '—' }}
@if($job->site_address) · {{ $job->site_address }}{{ $job->site_suburb ? ', '.$job->site_suburb : '' }} @endif
Total documents
{{ $allDocuments->count() }}
@if(session('success'))
{{ session('success') }}
@endif
@if(session('error'))
{{ session('error') }}
@endif
@if($errors->any())
Upload failed
@foreach($errors->all() as $err)- {{ $err }}
@endforeach
@endif
{{-- Tab bar --}}
@foreach($tabs as $key => $tab)
@php $count = $allDocuments->where('category', $key)->count(); @endphp
@endforeach
{{-- Tab panels --}}
@foreach($tabs as $key => $tab)
@php $docs = $allDocuments->where('category', $key)->values(); @endphp
{{ $tab['label'] }}
{{ $docs->count() }} file{{ $docs->count() !== 1 ? 's' : '' }} uploaded
{{-- Upload form --}}
{{-- File list --}}
@if($docs->isEmpty())
No {{ strtolower($tab['label']) }} documents yet.
Upload files using the form above.
@else
@foreach($docs as $doc)
@php
$isImage = in_array($doc->file_type, $imageTypes);
$ext = strtolower(pathinfo($doc->name, PATHINFO_EXTENSION));
$iconClass = match(true) {
in_array($ext, ['pdf']) => 'fa-file-pdf text-red-400',
in_array($ext, ['doc','docx']) => 'fa-file-word text-blue-400',
in_array($ext, ['xls','xlsx','csv']) => 'fa-file-excel text-green-400',
in_array($ext, ['jpg','jpeg','png','gif','webp']) => 'fa-file-image text-purple-400',
in_array($ext, ['zip']) => 'fa-file-archive text-yellow-400',
default => 'fa-file text-slate-400',
};
@endphp
{{ $doc->name }}
{{ $doc->note ?? "" }}
{{ $doc->formatted_size }}
· {{ $doc->created_at->format('d M Y, H:i') }}
@if($doc->uploader) · {{ $doc->uploader->name }} @endif
@php $role = auth()->user()->role?->name ?? ''; @endphp
@if(in_array($role, ['office_admin','project_manager','sales_consultant']))
@endif
@endforeach
@endif
@endforeach
{{-- /x-data --}}
@endsection