@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 .= 'Item | ';
$itemsHtml .= 'Qty | ';
$itemsHtml .= 'Rate | ';
$itemsHtml .= 'Tax | ';
$itemsHtml .= 'Amount | ';
$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 .= '| '.$idx.' | ';
$itemsHtml .= ''.e($item->description ?? $item->item_name ?? 'Item').' | ';
$itemsHtml .= ''.number_format($qty, 0).' | ';
$itemsHtml .= ''.number_format($rate, 2).' | ';
$itemsHtml .= '- | ';
$itemsHtml .= ''.number_format($amount, 2).' | ';
$itemsHtml .= '
';
}
$itemsHtml .= '';
$itemsHtml .= '| Sub Total | '.$currencySymbol.number_format($proposal->subtotal ?? 0, 2).' |
';
if (($proposal->discount_amount ?? 0) > 0) {
$itemsHtml .= '| Discount | -'.$currencySymbol.number_format($proposal->discount_amount, 2).' |
';
}
if (($proposal->tax_amount ?? 0) > 0) {
$itemsHtml .= '| Tax | '.$currencySymbol.number_format($proposal->tax_amount, 2).' |
';
}
$itemsHtml .= '| Total | '.$currencySymbol.number_format($proposal->total ?? 0, 2).' |
';
$itemsHtml .= '
';
$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)
| # |
Item |
Qty |
Rate |
Amount |
@foreach($proposal->items as $index => $item)
| {{ $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) }} |
@endforeach
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