@extends('layouts.app')
@section('title', $job->job_number)
@section('breadcrumb'){{ isset($isTrades) && $isTrades ? 'My Jobs' : 'Jobs' }} {{ $job->job_number }}@endsection
@section('content')
@php
$isTrades = isset($isTrades) && $isTrades;
$isProcessor = isset($isProcessor) && $isProcessor;
$isFactoryEmployee = isset($isFactoryEmployee) && $isFactoryEmployee;
$isRestrictedRole = $isProcessor || $isFactoryEmployee;
@endphp
{{ $job->contact?->initials ?? '??' }}
{{ $job->contact?->full_name ?? 'Unknown' }}
{{ $job->stageLabel() }}
@if($job->status === 'completed')
Completed
@endif
{{ $job->job_number }} · {{ $job->site_address }}, {{ $job->site_suburb }}
@if(!$isTrades && !$isRestrictedRole)
Edit
@if(auth()->user()->role?->name === 'office_admin')
@endif
@endif
@if(!$isRestrictedRole)
Job Pipeline
@php
$stages = [['lead','Lead'],['consult','Consult'],['sold','Sold'],['contracts','Contracts'],['cm','Check Measure'],['processing','Processing'],['delivery','Delivery'],['installation','Install'],['completion','Complete']];
$currentIdx = array_search($job->stage, array_column($stages, 0));
@endphp
@foreach($stages as $i => [$key, $label])
@if($i < $currentIdx)@else{{ $i + 1 }}@endif
{{ $label }}
@if($i < 8)
@endif
@endforeach
@if(!$isTrades && in_array(auth()->user()->role?->name, ['office_admin','project_manager']))
@endif
@endif
@if(session('success'))
{{ session('success') }}
@endif
@if(session('error'))
{{ session('error') }}
@endif
@if($isRestrictedRole)
{{-- ════════════════════════════════════════════════════════════════════
PROCESSOR / FACTORY EMPLOYEE: Only the Processor Drawing Documents tab
════════════════════════════════════════════════════════════════════ --}}
@include('jobs.partials._processor_drawings_tab')
@elseif($isTrades)
{{-- ── TRADES: simplified job view ──────────────────────────────────────── --}}
Job Details
Job Number{{ $job->job_number }}
Status{{ ucwords(str_replace('_',' ',$job->status)) }}
Project Type{{ $job->project_type ? ucfirst($job->project_type) : '—' }}
Expected Completion{{ $job->expected_completion?->format('d M Y') ?? '—' }}
Site Address{{ $job->site_address ?? '—' }}
Suburb{{ $job->site_suburb ?? '—' }}, {{ $job->site_state ?? '' }} {{ $job->site_postcode ?? '' }}
@if($job->notes)
@endif
@if($job->status !== 'completed')
Log Time on this Job
Go to My Timesheet
Start your timer from the Timesheet page and select this job.
@else
This job is completed
No further time can be logged on completed jobs.
@endif
@if($job->contact)
Client
{{ $job->contact->initials }}
{{ $job->contact->full_name }}
{{ $job->contact->company ?? 'Individual' }}
@if($job->contact->phone)
{{ $job->contact->phone }}
@endif
@endif
@else
{{-- ── FULL VIEW for non-trades ──────────────────────────────────────────── --}}
@if(in_array(auth()->user()->role?->name, ['office_admin','project_manager']))
Assigned Trades
Assign trades workers to this job. They will see it in their job list and can log time against it.
@if($job->tradeUsers->count())
@foreach($job->tradeUsers as $tu)
{{ $tu->initials }}
{{ $tu->name }}
@endforeach
@else
No trades workers assigned yet.
@endif
@endif
@foreach([
['overview','Overview','fa-info-circle'],
['works-order','Works Order','fa-clipboard-list'],
['payments','Payments','fa-dollar-sign'],
['variants','Variants','fa-code-branch'],
['invoice','Invoices','fa-file-invoice-dollar'],
['documents','Documents','fa-folder'],
['processor-drawings','Processor Drawings','fa-drafting-compass'],
] as [$t,$l,$icon])
@endforeach
Job Details
Project Type{{ $job->project_type ? ucfirst($job->project_type) : '—' }}
Design Style{{ $job->design_style ?? '—' }}
Rooms{{ $job->num_rooms ?? '—' }}
Source{{ $job->source ?? '—' }}
Sale Date{{ $job->sale_date?->format('d M Y') ?? '—' }}
Expected Completion{{ $job->expected_completion?->format('d M Y') ?? '—' }}
Team
Consultant{{ $job->consultant?->name ?? '—' }}
Project Manager{{ $job->manager?->name ?? '—' }}
Site Address{{ $job->site_address ?? '—' }}
Suburb{{ $job->site_suburb ?? '—' }}, {{ $job->site_state ?? '' }} {{ $job->site_postcode ?? '' }}
@if($job->description)
Description
{{ $job->description }}
@endif
@if($job->notes)
@endif
@if($job->next_action)
Next Action
{{ $job->next_action }}
@endif
@if(isset($allTimeEntries) && $allTimeEntries->count() > 0)
Time Logged
Total hours logged
{{ number_format($allTimeEntries->sum('duration_minutes') / 60, 1) }}h
@endif
@if(auth()->user()->role->id == 2 || auth()->user()->role->id== 10 || auth()->user()->role->id == 3)
Job Value
${{ number_format($job->job_value ?? 0) }}
Total job value
@foreach([['Deposit (30%)', ($job->job_value??0)*0.3],['CM (20%)',($job->job_value??0)*0.2],['Delivery (20%)',($job->job_value??0)*0.2],['Completion (30%)',($job->job_value??0)*0.3]] as [$lbl,$amt])
{{ $lbl }}
${{ number_format($amt) }}
@endforeach
@if($job->contact)
@endif
@if($job->warranty_expiry)
Warranty
Expires {{ $job->warranty_expiry->format('d M Y') }}
{{ $job->warranty_expiry->diffForHumans() }}
@endif
@endif
Works Orders
Scope-of-works documents with trade task lines for this job
@if(in_array(auth()->user()->role?->name, ['office_admin','project_manager']))
New Works Order
@endif
@forelse($job->worksOrders as $wo)
@if($wo->scope_of_works)
{{ Str::limit($wo->scope_of_works, 120) }}
@else
No scope documented yet
@endif
@if($wo->issued_date)Issued {{ $wo->issued_date->format('d M Y') }}@endif
@if($wo->target_completion)Target {{ $wo->target_completion->format('d M Y') }}@endif
@if($wo->items->count() > 0)
{{ $wo->items->where('status','done')->count() }}/{{ $wo->items->count() }} tasks
@endif
@if($wo->items->count() > 0)
@php $pct = $wo->completionPct(); @endphp
@endif
View →
@empty
No works orders yet
@if(in_array(auth()->user()->role?->name, ['office_admin','project_manager']))
Create first works order
@endif
@endforelse
@if($job->productionOrders->count() > 0)
Production / Manufacturing Orders
{{ $job->productionOrders->count() }}
@foreach($job->productionOrders as $po)
{{ $po->order_number ?? ('PO-'.str_pad($po->id,4,'0',STR_PAD_LEFT)) }}
{{ ucfirst(str_replace('_',' ',$po->status ?? 'pending')) }}
{{ $po->description ?? 'Production order' }}
Supplier: {{ $po->supplier ?? '—' }}@if($po->due_date) · Due: {{ \Carbon\Carbon::parse($po->due_date)->format('d M Y') }}@endif
@if($po->cost)
${{ number_format($po->cost) }}
@endif
@endforeach
@endif
Payment Schedule
@php
$payments = [
['Deposit (30%)', 'deposit_paid', ($job->job_value??0)*0.30, '#2563eb'],
['Check Measure (20%)', 'cm_paid', ($job->job_value??0)*0.20, '#7c3aed'],
['Delivery (20%)', 'delivery_paid', ($job->job_value??0)*0.20, '#d97706'],
['Final Payment (30%)', 'final_paid', ($job->job_value??0)*0.30, '#16a34a'],
];
@endphp
@foreach($payments as [$lbl, $field, $amt, $color])
{{ $lbl }}
${{ number_format($amt) }}
@if(auth()->user()->role?->name === 'office_admin')
@endif
@endforeach
Payment Summary
@php
$paid = collect(['deposit_paid','cm_paid','delivery_paid','final_paid'])
->filter(fn($f) => $job->$f)
->map(fn($f) => match($f) {
'deposit_paid' => ($job->job_value??0)*0.30,
'cm_paid' => ($job->job_value??0)*0.20,
'delivery_paid' => ($job->job_value??0)*0.20,
'final_paid' => ($job->job_value??0)*0.30,
default => 0
})->sum();
$outstanding = ($job->job_value ?? 0) - $paid;
$paidPct = ($job->job_value ?? 0) > 0 ? ($paid / $job->job_value) * 100 : 0;
@endphp
Total Job Value${{ number_format($job->job_value ?? 0) }}
Received${{ number_format($paid) }}
Outstanding${{ number_format($outstanding) }}
Collection Progress{{ round($paidPct) }}%
Job Variants
Track quote options presented to the client.
@if(in_array(auth()->user()->role?->name, ['office_admin','project_manager','sales_consultant']))
@endif
@if(isset($variantRevenue) && $job->variants->where('status','accepted')->count())
{{ $job->variants->where('status','accepted')->count() }} accepted variant(s) adding ${{ number_format($variantRevenue, 2) }} to job revenue
@endif
@forelse($job->variants->sortByDesc('created_at') as $variant)
{{ ucfirst($variant->status) }}
{{ $variant->name }}
@if($variant->price_adjustment != 0)
{{ $variant->price_adjustment > 0 ? '+' : '' }}${{ number_format(abs($variant->price_adjustment), 2) }}
@endif
@if($variant->description)
{{ $variant->description }}
@endif
@if($variant->status === 'pending' && in_array(auth()->user()->role?->name, ['office_admin','project_manager','sales_consultant']))
@endif
@empty
No variants yet for this job.
@endforelse
@forelse($job->jobInvoices as $inv)
{{ $inv->invoice_number ?? 'No Invoice #' }}
{{ $inv->invoice_date?->format('d M Y') ?? '—' }}
${{ number_format($inv->invoice_amount, 2) }}
@if($inv->note)
{{ $inv->note }}
@endif
@if(in_array(auth()->user()->role?->name, ['office_admin','project_manager']))
@endif
@empty
No invoices recorded yet.
@endforelse
@if(in_array(auth()->user()->role?->name, ['office_admin','project_manager','accounts']))
Add Invoice
@endif
@include('jobs.partials._processor_drawings_tab')
@endif {{-- end non-trades / processor view --}}
@endsection