@php $proposalTemplates = $proposalTemplates ?? \App\Models\ProposalTemplate::where('is_active', true)->orderBy('sort_order')->orderBy('name')->get(); $contentHasItems = !empty($proposal->content) && strpos($proposal->content, '{proposal_items}') !== false; // Get active brand logos from Brand module (same as estimation view) $brandLogos = collect([]); $hasBrands = false; try { if (class_exists('Modules\Brand\Models\Brand')) { $brandLogos = \Modules\Brand\Models\Brand::where('is_active', 1)->orderBy('sort_order')->get(); $hasBrands = $brandLogos->count() > 0; } } catch (\Exception $e) { $brandLogos = collect([]); $hasBrands = false; } @endphp

📋 Proposal Details

🔗 Merge Fields
Customer @if($proposal->customer) {{ $proposal->customer->company ?? $proposal->customer->name }} @else No customer @endif
Date {{ $proposal->date ? $proposal->date->format('d M Y') : '-' }}
Valid Until {{ $proposal->open_till ? $proposal->open_till->format('d M Y') : '-' }}
Total Amount ₹{{ number_format($proposal->total ?? 0, 2) }}
📊 Status
@foreach(['draft', 'sent', 'open', 'revised', 'declined', 'accepted'] as $status) @endforeach
📅 Activity
Created {{ $proposal->created_at->format('d M Y, h:i A') }}
@if($proposal->sent_at)
Sent {{ $proposal->sent_at->format('d M Y, h:i A') }}
@endif @if($proposal->accepted_at)
Accepted {{ $proposal->accepted_at->format('d M Y, h:i A') }}
@endif

Content

@if(!empty($proposal->content)) @php $displayContent = $proposal->content; if (strpos($displayContent, '{proposal_items}') !== false) { $currency = $proposal->currency ?? 'INR'; $currencySymbol = $currency === 'INR' ? '₹' : ($currency === 'USD' ? '$' : $currency); $itemsHtml = ''; $itemsHtml .= ''; $itemsHtml .= ''; $itemsHtml .= ''; $itemsHtml .= ''; $itemsHtml .= ''; $itemsHtml .= ''; $itemsHtml .= ''; $itemsHtml .= ''; $idx = 0; foreach ($proposal->items as $item) { $idx++; $qty = $item->quantity ?? $item->qty ?? 1; $rate = $item->rate ?? $item->unit_price ?? 0; $amount = $item->amount ?? ($qty * $rate); $bgColor = $idx % 2 === 0 ? '#f7fafc' : '#ffffff'; $itemsHtml .= ''; $itemsHtml .= ''; $itemsHtml .= ''; $itemsHtml .= ''; $itemsHtml .= ''; $itemsHtml .= ''; $itemsHtml .= ''; $itemsHtml .= ''; } $itemsHtml .= ''; $itemsHtml .= ''; if (($proposal->discount_amount ?? 0) > 0) { $itemsHtml .= ''; } if (($proposal->tax_amount ?? 0) > 0) { $itemsHtml .= ''; } $itemsHtml .= ''; $itemsHtml .= '
#ItemQtyRateTaxAmount
'.$idx.''.e($item->description ?? $item->item_name ?? 'Item').''.number_format($qty, 0).''.number_format($rate, 2).'-'.number_format($amount, 2).'
Sub Total'.$currencySymbol.number_format($proposal->subtotal ?? 0, 2).'
Discount-'.$currencySymbol.number_format($proposal->discount_amount, 2).'
Tax'.$currencySymbol.number_format($proposal->tax_amount, 2).'
Total'.$currencySymbol.number_format($proposal->total ?? 0, 2).'
'; $displayContent = str_replace('{proposal_items}', $itemsHtml, $displayContent); } $currencySymbol = ($proposal->currency ?? 'INR') === 'INR' ? '₹' : (($proposal->currency ?? 'INR') === 'USD' ? '$' : ($proposal->currency ?? 'INR')); $replacements = [ '{proposal_number}' => $proposal->proposal_number, '{proposal_date}' => $proposal->date ? $proposal->date->format('d M Y') : '', '{proposal_total}' => $currencySymbol . number_format($proposal->total ?? 0, 2), '{total}' => $currencySymbol . number_format($proposal->total ?? 0, 2), '{subtotal}' => $currencySymbol . number_format($proposal->subtotal ?? 0, 2), '{client_company}' => $proposal->customer->company ?? '', '{client_name}' => $proposal->customer->name ?? '', '{client_email}' => $proposal->customer->email ?? '', '{client_phone}' => $proposal->customer->phone ?? '', ]; foreach ($replacements as $placeholder => $value) { $displayContent = str_replace($placeholder, $value, $displayContent); } @endphp {!! $displayContent !!} @elseif($proposal->items->count() > 0) @foreach($proposal->items as $index => $item) @endforeach
# Item Qty Rate Amount
{{ $index + 1 }} {{ $item->description ?? $item->item_name ?? 'Item' }} {{ number_format($item->quantity ?? $item->qty ?? 1) }} ₹{{ number_format($item->rate ?? $item->unit_price ?? 0, 2) }} ₹{{ number_format($item->amount ?? (($item->quantity ?? 1) * ($item->rate ?? 0)), 2) }}
Subtotal₹{{ number_format($proposal->subtotal ?? 0, 2) }}
@if(($proposal->discount_amount ?? 0) > 0)
Discount-₹{{ number_format($proposal->discount_amount, 2) }}
@endif @if(($proposal->tax_amount ?? 0) > 0)
Tax₹{{ number_format($proposal->tax_amount, 2) }}
@endif
Total₹{{ number_format($proposal->total ?? 0, 2) }}
@else No content. Click "Templates" tab to insert a template. @endif

📝 Proposal Templates

⚙️ Manage
@if($proposalTemplates->count() > 0)
@foreach($proposalTemplates as $template)
📄
{{ $template->name }}
Updated {{ $template->updated_at->diffForHumans() }}
Edit
@endforeach
@else

No templates found

Create Template
@endif
@if($hasBrands) @endif