@extends('layouts.app')
@section('title',$quotation->quotation_number) @section('page_title','Quotation '.$quotation->quotation_number)
@section('content')@php($s=$quotation->status)<div class="page-header"><div><h1>{{ $quotation->quotation_number }}</h1><p class="muted">{{ $quotation->party?->legal_name }} · Version {{ $quotation->version }}</p></div><div class="actions"><a class="btn btn-secondary" target="_blank" href="{{ route('quotations.print',$quotation) }}">Print</a><a class="btn btn-secondary" href="{{ route('quotations.pdf',$quotation) }}">PDF</a>@if(in_array($s,['draft','rejected'])&&auth()->user()->hasPermission('quotations.edit_draft'))<a class="btn btn-primary" href="{{ route('quotations.edit',$quotation) }}">Edit</a>@endif</div></div><div class="grid grid-3"><div class="card metric"><div class="metric-label">Status</div><div class="metric-value" style="font-size:20px">{{ ucwords(str_replace('_',' ',$s)) }}</div></div><div class="card metric"><div class="metric-label">Expiry</div><div class="metric-value" style="font-size:20px">{{ $quotation->expiry_date?->format('d M Y')??'—' }}</div></div><div class="card metric"><div class="metric-label">Grand Total</div><div class="metric-value" style="font-size:20px">{{ $quotation->currency_code }} {{ number_format((float)$quotation->grand_total,2) }}</div></div></div><div class="card" style="margin-top:18px"><div class="table-wrap"><table><thead><tr><th>#</th><th>Description</th><th>Route</th><th>Vehicle</th><th class="text-right">Qty</th><th class="text-right">Rate</th><th class="text-right">VAT</th><th class="text-right">Total</th></tr></thead><tbody>@foreach($quotation->items as $i)<tr><td>{{ $i->line_number }}</td><td>{{ $i->description }}<div class="muted">{{ $i->serviceType?->name }}</div></td><td>{{ $i->route?->name??'—' }}</td><td>{{ $i->vehicle_type??'—' }}</td><td class="text-right">{{ $i->quantity }}</td><td class="text-right">{{ number_format((float)$i->unit_rate,2) }}</td><td class="text-right">{{ number_format((float)$i->vat_amount,2) }}</td><td class="text-right">{{ number_format((float)$i->line_total,2) }}</td></tr>@endforeach</tbody></table></div></div><div class="card" style="margin-top:18px"><div class="card-header"><h3>Workflow</h3></div><div class="card-body"><div class="actions">@if(in_array($s,['draft','rejected'])&&auth()->user()->hasPermission('quotations.submit'))<form method="post" action="{{ route('quotations.submit',$quotation) }}">@csrf<button class="btn btn-warning">Submit for Approval</button></form>@endif @if($s==='pending_approval'&&auth()->user()->hasPermission('quotations.approve'))<form method="post" action="{{ route('quotations.approve',$quotation) }}">@csrf<button class="btn btn-success">Approve</button></form>@endif @if($s==='pending_approval'&&auth()->user()->hasPermission('quotations.reject'))<form method="post" action="{{ route('quotations.reject',$quotation) }}" class="inline-form">@csrf<input class="control" name="reason" placeholder="Rejection reason" required><button class="btn btn-danger">Reject</button></form>@endif @if(in_array($s,['approved','sent'])&&auth()->user()->hasPermission('quotations.manage'))<form method="post" action="{{ route('quotations.send',$quotation) }}">@csrf<button class="btn btn-secondary">Mark Sent</button></form><form method="post" action="{{ route('quotations.accept',$quotation) }}">@csrf<button class="btn btn-success">Mark Accepted</button></form>@endif @if($s==='accepted'&&auth()->user()->hasPermission('quotations.manage')&&auth()->user()->hasPermission('transport_jobs.create'))<form method="post" action="{{ route('quotations.convert',$quotation) }}">@csrf<button class="btn btn-primary">Convert to Job</button></form>@endif @if($quotation->convertedJob)<a class="btn btn-primary" href="{{ route('jobs.show',$quotation->convertedJob) }}">Open {{ $quotation->convertedJob->job_number }}</a>@endif</div></div></div>@endsection
