@extends('layouts.app') @section('title', $contract->contract_number) @section('breadcrumb')Contracts {{ $contract->contract_number }}@endsection @section('content')
{{-- Success / Error Alerts --}} @if(session('success'))
{{ session('success') }}
@endif @if(session('error'))
{{ session('error') }}
@endif

{{ $contract->contract_number }}

@php $sc = match($contract->status) { 'draft' => 'gray', 'sent' => 'blue', 'signed' => 'green', 'deposit_paid' => 'teal', 'in_progress' => 'purple', 'completed' => 'emerald', default => 'gray' }; @endphp {{ $contract->statusLabel() }}

{{ $contract->contact?->full_name }} — {{ $contract->job?->job_number }}

${{ number_format($contract->contract_price ?? 0) }}

Contract Progress

@foreach([['Draft','draft'],['Sent','sent'],['Signed','signed'],['In Progress','in_progress'],['Completed','completed']] as $i => [$label, $key]) @php $step = $contract->stepNumber(); @endphp
@if($i + 1 < $step)@else{{ $i + 1 }}@endif
{{ $label }}
@if($i < 4)
@endif @endforeach

Payment Schedule

@foreach([ ['Deposit', 'deposit_pct', 'deposit_paid', fn() => $contract->depositAmount()], ['Check Measure', 'cm_pct', 'cm_paid', fn() => $contract->cmAmount()], ['Delivery', 'delivery_pct', 'delivery_paid', fn() => $contract->deliveryAmount()], ['Completion', 'completion_pct', 'completion_paid', fn() => $contract->completionAmount()], ] as [$label, $pctField, $paidField, $amountFn])
@if($contract->$paidField) @else @endif
{{ $label }} ({{ $contract->$pctField ?? 0 }}%)
{{ $contract->$paidField ? 'Paid' : 'Pending' }}
${{ number_format($amountFn(), 2) }}
@endforeach
@if($contract->inclusions || $contract->exclusions || $contract->terms || $contract->notes)
@if($contract->inclusions)

Inclusions

{{ $contract->inclusions }}

@endif @if($contract->exclusions)

Exclusions

{{ $contract->exclusions }}

@endif @if($contract->terms)

Terms & Conditions

{{ $contract->terms }}

@endif @if($contract->notes)

Notes

{{ $contract->notes }}

@endif
@endif
Contract Value
${{ number_format($contract->contract_price ?? 0) }}
@if($contract->signed_date)
Signed {{ $contract->signed_date->format('d M Y') }}
@endif
@if($contract->contact)
Client
{{ $contract->contact->initials }}
{{ $contract->contact->full_name }}
{{ $contract->contact->email }}
@endif
Actions
@can('office_admin') @if(!in_array($contract->status, ['completed', 'cancelled'])) Edit Contract @endif @endcan @if($contract->status === 'draft')
@csrf
@endif @if(in_array($contract->status, ['sent', 'draft']))
@csrf
@endif {{-- Payment buttons — each with confirmation modal --}} @if(! $contract->deposit_paid && in_array($contract->status, ['signed', 'deposit_paid', 'in_progress'])) @endif @if(! $contract->cm_paid && $contract->deposit_paid) @endif @if(! $contract->delivery_paid && $contract->cm_paid) @endif @if(! $contract->completion_paid && $contract->delivery_paid) @endif @if(!in_array($contract->status, ['completed', 'cancelled'])) @if($contract->status === 'draft')
@csrf @method('DELETE')
@endif @endif
@include('partials.document-panel', [ 'documents' => $contract->documents, 'documentableType' => 'Contract', 'documentableId' => $contract->id, ])
{{-- Payment Confirmation Modal --}}
{{-- /x-data --}} @endsection