@php $statusClasses = [ 'on_track' => 'bg-emerald-100 text-emerald-800', 'at_risk' => 'bg-amber-100 text-amber-800', 'delayed' => 'bg-rose-100 text-rose-800', 'completed' => 'bg-sky-100 text-sky-800', ]; $statusColors = [ 'on_track' => '#16a34a', 'at_risk' => '#d97706', 'delayed' => '#e11d48', 'completed' => '#0284c7', ]; $tabLabels = [ 'overview' => 'Overview', 'drawing' => 'Drawing', 'material' => 'Material', 'production' => 'Production', 'ready_to_dispatch' => 'Ready to Dispatch', 'delivery' => 'Delivery', 'installation' => 'Installation', 'completed' => 'Completed', 'activity' => 'Activity', 'comments' => 'Comments', ]; $daysRemaining = $project->end_date ? now()->startOfDay()->diffInDays($project->end_date, false) : null; @endphp

{{ __('Project Details') }}: {{ $project->name }}

{{ $statusOptions[$project->status] ?? str($project->status)->headline() }} Stage {{ $project->stage_label }} Accepted

Project Overview

Project Name: {{ $project->name }}

Client: {{ $project->client_name }}

Reference Number: {{ $project->reference_no }}

Linked Lead: {{ $project->lead?->client_name ?? 'Not linked' }}

Current Stage: {{ $project->stage_label }}

Project Value: {{ $projectValue !== null ? '$'.number_format($projectValue, 2) : 'Not available' }}

Team & Timeline

Project Manager: {{ $project->manager?->name ?? 'Unassigned' }}

Team Members: {{ $teamMembers->pluck('name')->join(', ') ?: 'No team members assigned' }}

Start Date: {{ $project->start_date?->format('d M Y') ?? 'N/A' }}

Deadline: {{ $project->end_date?->format('d M Y') ?? 'N/A' }}

Days Remaining / Overdue: @if($daysRemaining === null) N/A @elseif($daysRemaining < 0) {{ abs($daysRemaining) }} days overdue @else {{ $daysRemaining }} days remaining @endif

Completion Percentage: {{ $project->completion_percentage }}%

@csrf
Drawing Files
Version
Actions
Upload

No files selected.

Allowed: JPG, JPEG, PNG, PDF, DWG, DXF. Max 50 MB total per file.

@php $drawingUploadError = $errors->first('drawing_files') ?: $errors->first('drawing_files.*'); @endphp

{{ $drawingUploadError }}

@php $drawingsToShow = $project->drawings->sortByDesc('created_at'); @endphp @if($drawingsToShow->isEmpty())

No drawings uploaded yet.

@else
@foreach($drawingsToShow as $drawing) @endforeach
File Name Version Added Action
{{ $drawing->file_name }} {{ $drawing->version }}
@endif
{{--
@csrf
@if($acceptedDrawing) Accepted @elseif($pendingDrawingForAccept) Select a drawing below to accept @else Ready to upload @endif @if(!$acceptedDrawing) Upload @endif
@php $drawingUploadError = $errors->first('drawing_files') ?: $errors->first('drawing_files.*') ?: $errors->first('drawing_status'); @endphp

{{ $drawingUploadError }}

@php $drawingsToShow = $project->drawings ->sortByDesc('created_at') ->reject(fn ($drawing) => $drawing->accepted_at !== null); $acceptedVersion = $acceptedDrawing?->version; $canAcceptMoreDrawings = !$acceptedDrawing || ($drawingsToShow->isNotEmpty() && $drawingsToShow->every(fn ($d) => (string) $d->version === (string) $acceptedVersion)); @endphp @if($drawingsToShow->isEmpty())

{{ $acceptedDrawing ? 'No pending drawings. Accepted drawing is available above.' : 'No drawings uploaded yet.' }}

@else
@csrf @method('PATCH') @foreach($drawingsToShow as $drawing) {{-- --}} {{-- @endforeach
File Name Version Status Added Action
@if($canAcceptMoreDrawings) @endif
{{ $drawing->file_name }}
{{ $drawing->version }} {{ str($drawing->drawing_status)->headline() }} {{ $drawing->created_at->format('d M Y, h:i A') }}
0 selected @if(!$canAcceptMoreDrawings && $acceptedDrawing) Only version {{ $acceptedVersion }} can be accepted. @endif
@if($canAcceptMoreDrawings) @endif
@endif
--}}
@csrf
@php $materialsToShow = $project->materials ->sortByDesc('created_at') ->reject(fn ($material) => $material->source_drawing_id !== null); @endphp @if($materialsToShow->isEmpty())

No material items added yet.

@else
@foreach($materialsToShow as $material) @endforeach
Material Qty Size Note Added Action
{{ $material->material_name }} {{ $material->qty }} {{ $material->size ?: 'N/A' }}
{{ $material->note ?: 'No note' }}
{{ $material->created_at->format('d M Y, h:i A') }}
@csrf @method('DELETE')
@if($material->attachment_path) @endif
@endif
@csrf
Title
Note
Attachment

No file selected.

Allowed: JPG, JPEG, PNG, PDF, DOC, DOCX, XLS, XLSX, PPT, PPTX, ZIP, RAR, MP4, MOV, AVI, MKV, MP3, WAV. Max 50 MB.

Add
@php $productionsToShow = $project->productions->sortByDesc('created_at'); @endphp @if($productionsToShow->isEmpty())

No production updates yet.

@else
@foreach($productionsToShow as $production) @endforeach
Title Note Added Action
{{ $production->title }}
{{ $production->note ?: 'No note' }}
QA: {{ $production->qa_done ? 'Done' : 'Pending' }}
@csrf @method('DELETE')
@if(!$production->qa_done)
@csrf @method('PATCH')
@endif @if($production->attachment_path) @endif
@endif
@php $readyToDispatchPendingItems = $project->productions ->filter(fn ($production) => (bool) $production->qa_done && empty($production->dispatched_at)) ->sortByDesc('created_at') ->values(); $readyToDispatchDispatchedItems = $project->productions ->filter(fn ($production) => (bool) $production->qa_done && !empty($production->dispatched_at)) ->sortByDesc('dispatched_at') ->values(); @endphp

{{ $tabLabels['ready_to_dispatch'] }}

Tick any QA done items you want to dispatch to Delivery.

Pending: {{ $readyToDispatchPendingItems->count() }} | Dispatched: {{ $readyToDispatchDispatchedItems->count() }}
@if($readyToDispatchPendingItems->isEmpty()) {{-- No pending items to dispatch --}} @else
@csrf
@foreach($readyToDispatchPendingItems as $production) @endforeach
Done Title Note Added
{{ $production->title }}
{{ $production->note ?: 'No note' }}
{{ $production->created_at->format('d M Y, h:i A') }}
@endif

Dispatched Items

Shows all QA done items already dispatched.
@if($readyToDispatchDispatchedItems->isEmpty())

No dispatched items yet.

@else
@foreach($readyToDispatchDispatchedItems as $production) @endforeach
Status Title Note Dispatched At
Dispatched {{ $production->title }}
{{ $production->note ?: 'No note' }}
{{ $production->dispatched_at?->format('d M Y, h:i A') ?? '-' }}
@endif
@if(false)
@php $latestChallan = $project->challans->sortByDesc('created_at')->first(); $challanProductionIds = collect($latestChallan?->production_ids ?? [])->map(fn ($id) => (int) $id)->values(); $deliveryItems = $project->productions->whereIn('id', $challanProductionIds)->values(); @endphp

{{ $tabLabels['delivery'] }}

Fill transport details and print challan.

@if($latestChallan)
Challan
{{ $latestChallan->challan_no }}
@endif
@if(!$latestChallan)

No challan yet. Complete Ready to Dispatch first.

@else
Delivery Status
Changing to Delivered will ask for a signature challan photo and move to Installation.
@foreach($deliveryItems as $production) @endforeach
Title Note
{{ $production->title }}
{{ $production->note ?: 'No note' }}
@endif

Challan Details

@if(!$latestChallan)

Challan details will appear here after you move items to Delivery.

@else
@csrf @method('PATCH')

Selecting Delivered will ask for a signature challan photo and move the project to Installation.

Print Challan Save Details
@endif
@endif
@php $challans = $project->challans->sortByDesc('created_at')->values(); $alreadyChallanedIds = $challans ->flatMap(fn ($challan) => $challan->production_ids ?? []) ->map(fn ($id) => (int) $id) ->unique() ->values(); $deliveryPendingItems = $project->productions ->filter(fn ($production) => (bool) $production->qa_done && !empty($production->dispatched_at)) ->reject(fn ($production) => $alreadyChallanedIds->contains((int) $production->id)) ->sortByDesc('dispatched_at') ->values(); @endphp

Create Challan

Select dispatched items and fill challan details.

Pending Challan: {{ $deliveryPendingItems->count() }} | Challans: {{ $challans->count() }}
@if($deliveryPendingItems->isEmpty())

No dispatched items pending challan.

@else
@csrf
@foreach($deliveryPendingItems as $production) @endforeach
Title Note Dispatched
{{ $production->title }}
{{ $production->note ?: 'No note' }}
{{ $production->dispatched_at?->format('d M Y, h:i A') ?? '-' }}
@php $challanCreateError = $errors->first('production_ids') ?: $errors->first('production_ids.*'); @endphp
0 selected @if($challanCreateError) {{ $challanCreateError }} @endif
@endif
@if($challans->isNotEmpty())

Challan History

Different challans can be created. Use View to update status/details.

@foreach($challans as $challan) @endforeach
Challan No Status Items Created Action
{{ $challan->challan_no }} {{ str($challan->status)->headline() }} {{ count($challan->production_ids ?? []) }} {{ $challan->created_at->format('d M Y, h:i A') }} Print
@endif @if($challans->isNotEmpty()) @foreach($challans as $challan) @php $challanProductionIdsForModal = collect($challan->production_ids ?? [])->map(fn ($id) => (int) $id)->values(); $challanItemsForModal = $project->productions->whereIn('id', $challanProductionIdsForModal)->values(); @endphp @endforeach @endif
@php $installationValues = [ 'site_preparation_status' => old('site_preparation_status', $project->site_preparation_status ?? 'not_started'), 'fixing_welding_status' => old('fixing_welding_status', $project->fixing_welding_status ?? 'not_started'), 'testing_commissioning_status' => old('testing_commissioning_status', $project->testing_commissioning_status ?? 'not_started'), 'final_inspection_status' => old('final_inspection_status', $project->final_inspection_status ?? 'ready'), 'client_handover_status' => old('client_handover_status', $project->client_handover_status ?? 'pending'), ]; $installationComplete = $installationValues['site_preparation_status'] === 'done' && $installationValues['fixing_welding_status'] === 'done' && $installationValues['testing_commissioning_status'] === 'pass' && $installationValues['final_inspection_status'] === 'passed' && $installationValues['client_handover_status'] === 'completed'; @endphp

{{ $tabLabels['installation'] }}

Update installation checklist. When all steps are positive, you can complete the order.

Complete the current stage before selecting the next.

@if($project->installation_completed_at)
Completed At
{{ $project->installation_completed_at->format('d M Y, h:i A') }}
@endif
@csrf @method('PATCH')

Changes are saved automatically.

Complete Order is enabled only when all steps are positive.
@csrf
@php $completedChallan = $project->challans->sortByDesc('created_at')->first(); $completedChallanProductionIds = collect($completedChallan?->production_ids ?? [])->map(fn ($id) => (int) $id)->values(); $completedProductions = $project->productions->whereIn('id', $completedChallanProductionIds)->values(); $completedMaterials = $project->materials ->sortByDesc('created_at') ->reject(fn ($material) => $material->source_drawing_id !== null); @endphp

{{ $tabLabels['completed'] }}

Order is completed. View details or print important summary.

Project

Name: {{ $project->name }}

Client: {{ $project->client_name ?: 'N/A' }}

Reference: {{ $project->reference_no }}

Manager: {{ $project->manager?->name ?? 'Unassigned' }}

Status: {{ str($project->status)->headline() }}

Stage: {{ $project->stage_label }}

Completed At: {{ $project->installation_completed_at?->format('d M Y, h:i A') ?? '-' }}

Delivery / Challan
@if(!$completedChallan)

No challan found.

@else

Challan No: {{ $completedChallan->challan_no }}

Status: {{ str($completedChallan->status ?? 'created')->headline() }}

Dispatch Date: {{ $completedChallan->dispatch_date?->format('d M Y') ?? '-' }}

Transport: {{ $completedChallan->transport_name ?: '-' }}

Vehicle: {{ $completedChallan->vehicle_no ?: '-' }}

LR No: {{ $completedChallan->lr_no ?: '-' }}

@endif
Installation Checklist

Site Preparation: {{ str($project->site_preparation_status ?: 'not_started')->replace('_', ' ')->headline() }}

Fixing & Welding: {{ str($project->fixing_welding_status ?: 'not_started')->replace('_', ' ')->headline() }}

Testing & Commissioning: {{ str($project->testing_commissioning_status ?: 'not_started')->replace('_', ' ')->headline() }}

Final Inspection: {{ str($project->final_inspection_status ?: 'ready')->replace('_', ' ')->headline() }}

Client Handover: {{ str($project->client_handover_status ?: 'pending')->replace('_', ' ')->headline() }}

Materials
@if($completedMaterials->isEmpty())

No materials.

@else
@foreach($completedMaterials as $material) @endforeach
Material Qty Size Note
{{ $material->material_name }} {{ $material->qty }} {{ $material->size ?: '-' }} {{ $material->note ?: '-' }}
@endif
Delivered Items
@if(!$completedChallan || $completedProductions->isEmpty())

No delivered items.

@else
@foreach($completedProductions as $production) @endforeach
Title Note
{{ $production->title }} {{ $production->note ?: '-' }}
@endif
    @forelse($project->activities->sortByDesc('occurred_at') as $activity)
  • @if(!$loop->last) @endif
    @if($activity->type === 'status_change') @elseif(in_array($activity->type, ['drawing', 'material', 'production'], true)) @elseif($activity->type === 'note') @else @endif

    {{ $activity->description }} by {{ $activity->user->name ?? 'System' }}

  • @empty

    No project activity yet.

    @endforelse
@foreach($project->comments->sortByDesc('created_at') as $comment)
{{ $comment->user->name }} {{ $comment->created_at->diffForHumans() }}

{{ $comment->comment }}

@endforeach
@csrf
Post Comment
@push('scripts') @endpush