@extends('layouts.layout-horizontal') @section('title', 'Enquiry Details') @section('css') @endsection @section('content')
{{-- Top Bar --}}
Back
PDF @if($enquiry->status == 'open') Edit
@csrf
@else Closed @endif
@php $totalQty = $enquiry->items->sum('qty'); $totalOutward = $enquiry->items->sum('outward_qty'); $overallPercent = $totalQty > 0 ? round(($totalOutward / $totalQty) * 100) : 0; $enquiryStatus = $overallPercent >= 100 ? 'closed' : ($overallPercent > 0 ? 'partial' : 'open'); @endphp {{-- Summary Card --}}
{{ $enquiry->party->name }}
{{ $enquiry->enquiry_no }} · {{ $enquiry->enquiry_date->format('d-M-Y') }} · {{ ucfirst($enquiry->status) }}
{{ $overallPercent }}%
{{ indian_number($totalOutward, 2) }} of {{ indian_number($totalQty, 2) }} converted
Total: {{ indian_number($enquiry->grand_total, 2) }}
@php $convertedAmt = $enquiry->items->sum(function($i) { return $i->qty > 0 ? ($i->outward_qty / $i->qty) * $i->line_total : 0; }); $pendingAmt = $enquiry->grand_total - $convertedAmt; @endphp Done: {{ indian_number($convertedAmt, 2) }} Pending: {{ indian_number(max(0, $pendingAmt), 2) }}
{{-- Items Table with Progress --}}
@foreach($enquiry->items as $idx => $item) @php $remaining = max(0, $item->qty - $item->outward_qty); $pct = $item->qty > 0 ? round(($item->outward_qty / $item->qty) * 100) : 0; $itemStatus = $pct >= 100 ? 'full' : ($pct > 0 ? 'partial' : 'none'); @endphp @endforeach
# Product Qty Converted Pending Progress Rate Total Status
{{ $idx + 1 }} {{ $item->product->name }} {{-- HSN hidden --}} {{ indian_number($item->qty, 2) }} {{ $item->unit }} {{ indian_number($item->outward_qty, 2) }} {{ indian_number($remaining, 2) }}
{{ $pct }}%
{{ indian_number($item->rate, 2) }} {{ indian_number($item->line_total, 2) }} @if($pct >= 100) Done @elseif($pct > 0) Partial @else Pending @endif
{{-- Convert to Invoice Section --}} @if($enquiry->status == 'open') @php $hasRemaining = $enquiry->items->contains(fn($i) => $i->remainingQty() > 0); @endphp @if($hasRemaining)
Convert to Invoice
@csrf {{-- Company Selection --}}
@foreach($companies as $c)
first ? 'checked' : '' }}>
@endforeach
{{-- Items to Convert --}} @foreach($enquiry->items as $item) @php $rem = $item->remainingQty(); @endphp @if($rem > 0) @endif @endforeach
Product Enquiry Qty Already Converted Remaining Convert Qty Rate
{{ $item->product->name }} {{-- HSN hidden --}} {{ indian_number($item->qty, 2) }} {{ $item->unit }} {{ indian_number($item->outward_qty, 2) }} {{ indian_number($rem, 2) }} {{ indian_number($item->rate, 2) }}
{{-- Hidden inputs populated by JS --}}
@else
All items have been fully converted to invoices.
@endif @endif
@endsection @push('scripts') @endpush