@extends('admin.master') @section('content')

Factory Quotation Detail

@if(session('success'))
{{ session('success') }}
@endif @if(session('error'))
{{ session('error') }}
@endif

Quotation #{{ $enquiry->id }}

@if(auth('admin')->user()->isWarehouse() || auth('admin')->user()->role === 'factory') @elseif($enquiry->status == 'Pending') @elseif($enquiry->status == 'In Progress') @else @endif
Submitted {{ $enquiry->created_at ? \Carbon\Carbon::parse($enquiry->created_at)->format('d-m-Y / h:i A') : '--' }}
Company Name {{ $enquiry->company_name }}
Contact Person {{ $enquiry->contact_person }}
Phone / WhatsApp {{ $enquiry->phone_whatsapp }}
Email {{ $enquiry->email_address }}
Website {{ $enquiry->website }}
Address {{ $enquiry->address }}
Country {{ $enquiry->country }}
City {{ $enquiry->city }}
Product Required {{ $enquiry->product_required }}
Fabric Composition {{ $enquiry->fabric_composition }}
GSM {{ $enquiry->gsm }}
Colors {{ $enquiry->colors }}
Sizes {{ $enquiry->sizes }}
Quantity Required {{ $enquiry->quantity_required }}
Delivery Date {{ $enquiry->delivery_date }}
Additional Notes {{ $enquiry->additional_notes }}
Assigned CSR {{ $enquiry->csrDetails->name ?? 'Not Assigned' }}
Status @if($enquiry->status == 'Pending') Pending @elseif($enquiry->status == 'In Progress') In Progress @else Completed @endif
Attachment
@forelse($enquiry->upload_files ?? [] as $file) @php $extension = strtolower(pathinfo($file, PATHINFO_EXTENSION)); $fileUrl = asset('storage/' . $file); @endphp View {{ strtoupper($extension) }} @empty No attachment @endforelse
{{-- QUOTATION --}}
@php $isFactoryAdmin = strtolower(trim((string) auth('admin')->user()->role)) === 'factory'; $canEditQuotation = auth('admin')->user()->role == 'admin' || (auth('admin')->user()->role == 'sales executive' && $enquiry->csr_id == auth('admin')->id()); $hasFactoryOrder = (bool) $enquiry->factoryOrder; $canPlaceFactoryOrder = auth('admin')->user()->role == 'admin' && $enquiry->isOrderable(); $quoteErrors = $errors->getBag('quotation'); $hasQuote = $enquiry->hasQuotation(); $hasFactoryQuote = $enquiry->hasFactoryQuotation(); $showQuoteForm = $isFactoryAdmin ? (!$hasFactoryQuote || $quoteErrors->any()) : ($canEditQuotation && !$hasFactoryOrder && (!$hasQuote || $quoteErrors->any())); $sar = fn ($v) => 'SAR ' . number_format((float) $v, 2); @endphp
{{ $isFactoryAdmin ? 'Quotation from Factory' : 'Quotation' }}
@if($hasFactoryOrder) View Order {{ $enquiry->factoryOrder->number() }} @elseif($canPlaceFactoryOrder) @endif @if($hasFactoryQuote && $isFactoryAdmin) @endif
@if($hasFactoryQuote && !$isFactoryAdmin)
Quotation from Factory
@if(filled($enquiry->factory_quote_notes)) @endif
Manufacturing Time{{ $enquiry->factory_quote_manufacturing_time }}
Shipment / Delivery Time{{ $enquiry->factory_quote_delivery_time ?: '-' }}
Quantity{{ $enquiry->quotationQuantity() !== null ? $enquiry->quotationQuantity() : '—' }}
Factory Unit Cost (SAR){{ $sar($enquiry->factory_quote_cost) }}
Delivery Cost{{ $enquiry->factory_quote_delivery_cost !== null ? $sar($enquiry->factory_quote_delivery_cost) : '-' }}
Total Cost{{ $sar($enquiry->factory_quote_total_cost) }}
Advance Payment{{ $enquiry->factory_quote_advance_percent !== null ? $enquiry->factory_quote_advance_percent.'%' : '-' }}
Notes{!! nl2br(e($enquiry->factory_quote_notes)) !!}
@elseif(!$hasFactoryQuote && !$isFactoryAdmin)
Factory quotation is not submitted yet.
@endif @if($hasQuote && !$isFactoryAdmin)
Quotation for Customer
@if(filled($enquiry->quote_notes)) @endif
Manufacturing Time {{ $enquiry->quote_manufacturing_time }}
Shipment / Delivery Time {{ $enquiry->quote_delivery_time ?: '-' }}
Quantity {{ $enquiry->quotationQuantity() !== null ? $enquiry->quotationQuantity() : '—' }}
Unit Cost (SAR) {{ $sar($enquiry->quote_cost) }}
Delivery Cost {{ $sar($enquiry->quote_delivery_cost ?? 0) }}
Total Cost {{ $sar($enquiry->quote_total_cost) }}
Advance Payment {{ $enquiry->quote_advance_percent !== null ? $enquiry->quote_advance_percent.'%' : '-' }}
Shipment Out Date {{ $enquiry->quote_shipment_out_date?->format('d-m-Y') ?: '-' }}
Delivery Date (Warehouse) {{ $enquiry->quote_warehouse_delivery_date?->format('d-m-Y') ?: '-' }}
Notes {!! nl2br(e($enquiry->quote_notes)) !!}
@elseif($isFactoryAdmin && $hasFactoryQuote)
@if(filled($enquiry->factory_quote_notes)) @endif
Manufacturing Time{{ $enquiry->factory_quote_manufacturing_time }}
Shipment / Delivery Time{{ $enquiry->factory_quote_delivery_time ?: '-' }}
Quantity{{ $enquiry->quotationQuantity() !== null ? $enquiry->quotationQuantity() : '—' }}
Factory Unit Cost (SAR){{ $sar($enquiry->factory_quote_cost) }}
Delivery Cost{{ $enquiry->factory_quote_delivery_cost !== null ? $sar($enquiry->factory_quote_delivery_cost) : '-' }}
Total Cost{{ $sar($enquiry->factory_quote_total_cost) }}
Advance Payment{{ $enquiry->factory_quote_advance_percent !== null ? $enquiry->factory_quote_advance_percent.'%' : '-' }}
Notes{!! nl2br(e($enquiry->factory_quote_notes)) !!}
@elseif(!$canEditQuotation && !$isFactoryAdmin)
No quotation saved yet.
@endif @if($hasQuote && auth('admin')->user()->role == 'admin') @php $dateErrors = $errors->getBag('quote_dates'); @endphp
@csrf @if($dateErrors->any())
    @foreach($dateErrors->all() as $message)
  • {{ $message }}
  • @endforeach
@endif
@endif @if($hasFactoryOrder)
This quotation is locked because factory order {{ $enquiry->factoryOrder->number() }} has been placed.
@endif @if($isFactoryAdmin || ($canEditQuotation && !$hasFactoryOrder))
@csrf @if($quoteErrors->any())
    @foreach($quoteErrors->all() as $message)
  • {{ $message }}
  • @endforeach
@endif @unless($isFactoryAdmin)
Quotation for Customer
@endunless
@if($quoteErrors->has('quote_manufacturing_time'))
{{ $quoteErrors->first('quote_manufacturing_time') }}
@endif
@if($quoteErrors->has('quote_delivery_time'))
{{ $quoteErrors->first('quote_delivery_time') }}
@endif
@if($quoteErrors->has('quote_advance_percent'))
{{ $quoteErrors->first('quote_advance_percent') }}
@endif
@php $quoteQty = $enquiry->quotationQuantity(); @endphp
@if($quoteQty === null) Quantity is missing on this enquiry, so Total Cost is Delivery Cost only. @endif
@if($quoteErrors->has('quote_cost'))
{{ $quoteErrors->first('quote_cost') }}
@endif
@if($quoteErrors->has('quote_delivery_cost'))
{{ $quoteErrors->first('quote_delivery_cost') }}
@endif
Unit Cost × Quantity + Delivery Cost
@if($quoteErrors->has('quote_notes'))
{{ $quoteErrors->first('quote_notes') }}
@endif
@if($hasQuote) @endif
@endif
{{-- ADD NOTE --}}
@php $canAddNote = false; if(auth('admin')->user()->role == 'admin'){ $canAddNote = true; } if( auth('admin')->user()->role == 'sales executive' && $enquiry->csr_id == auth('admin')->id() ){ $canAddNote = true; } @endphp @if($canAddNote)
Add Note
@csrf
@endif
{{-- NOTES HISTORY --}}
Notes History
@forelse( $enquiry->notes->sortByDesc('note_datetime') as $note )
{{ $note->admin->name ?? 'Admin' }} {{ \Carbon\Carbon::parse($note->note_datetime)->format('d M Y h:i A') }}

{!! nl2br(e($note->description)) !!}

@empty
No notes available.
@endforelse
@include('partials.enquiry-queries', [ 'indexUrl' => route('admin.enquiry.messages', $enquiry->id), 'storeUrl' => route('admin.enquiry.messages.store', $enquiry->id), ])
@if(!empty($canPlaceFactoryOrder)) @include('partials.factory-order-place-modal', [ 'enquiry' => $enquiry, 'placeOrderUrl' => route('admin.factory.orders.place', $enquiry->id), ]) @endif @endsection @push('js-script') @endpush @push('scripts') @if(!empty($canPlaceFactoryOrder)) @include('partials.factory-order-place-scripts') @endif @endpush