@php // Get selected brand IDs from query string $selectedBrandIds = []; $brandsParam = request()->get('brands', ''); if (!empty($brandsParam)) { $selectedBrandIds = array_filter(array_map('intval', explode(',', $brandsParam))); } // Fetch selected brands - ensure it's always a collection $selectedBrands = collect([]); if (!empty($selectedBrandIds)) { try { if (class_exists('\Modules\Brand\Models\Brand')) { $selectedBrands = \Modules\Brand\Models\Brand::whereIn('id', $selectedBrandIds) ->where('is_active', 1) ->orderBy('sort_order') ->get(); } } catch (\Exception $e) { $selectedBrands = collect([]); } } // Use count() function for safety $brandCount = is_object($selectedBrands) && method_exists($selectedBrands, 'count') ? $selectedBrands->count() : count($selectedBrands); @endphp
@if(!empty($company['logo'])) @if(str_starts_with($company['logo'], 'data:image')) @else @endif @endif {{-- Brand Logos Row --}} @if($brandCount > 0)
@foreach($selectedBrands as $brand) @if($brand->logo) @php $brandLogoPath = storage_path('app/public/' . $brand->logo); $brandLogoExists = file_exists($brandLogoPath); @endphp @if($brandLogoExists) @php $brandLogoData = base64_encode(file_get_contents($brandLogoPath)); $brandLogoMime = mime_content_type($brandLogoPath); @endphp @endif @endif @endforeach
@endif
{{ $company['name'] }}
@if($company['address']){{ $company['address'] }}
@endif @if($company['phone'])Phone: {{ $company['phone'] }}
@endif @if($company['email'])Email: {{ $company['email'] }}
@endif @if($company['gst'])GST: {{ $company['gst'] }}@endif
ESTIMATE
#{{ $estimation->estimation_number }}
Estimate Date:{{ $estimation->date ? $estimation->date->format('d M Y') : '-' }}
Valid Until:{{ $estimation->valid_until ? $estimation->valid_until->format('d M Y') : '-' }}
{{ ucfirst($estimation->status) }}
Prepared For
@if($estimation->customer)
{{ $estimation->customer->customer_type === 'company' ? $estimation->customer->company : $estimation->customer->name }}
@if($estimation->customer->customer_type === 'company' && $estimation->customer->name)Attn: {{ $estimation->customer->name }}
@endif @if($estimation->address){{ $estimation->address }}
@endif @if($estimation->city || $estimation->state){{ $estimation->city }}{{ $estimation->city && $estimation->state ? ', ' : '' }}{{ $estimation->state }}
@endif @if($estimation->country){{ $estimation->country }} {{ $estimation->zip_code }}
@endif @if($estimation->email)Email: {{ $estimation->email }}
@endif @if($estimation->phone)Phone: {{ $estimation->phone }}@endif
@else
No customer assigned
@endif
Estimate Details
Currency: {{ $estimation->currency ?? 'INR' }}
Status: {{ ucfirst($estimation->status ?? 'draft') }}
Total Value: {{ $estimation->currency ?? 'INR' }} {{ number_format($estimation->total, 2) }}
@if($estimation->subject)
Subject: {{ $estimation->subject }}
@endif @if($estimation->content)
📝 Customer Notes
{!! nl2br(e($estimation->content)) !!}
@endif @php $itemIndex = 0; @endphp @forelse($estimation->items as $item) @if(($item->item_type ?? 'product') === 'section') @elseif(($item->item_type ?? 'product') === 'note') @else @php $itemIndex++; $itemTaxIds = []; if (!empty($item->tax_ids)) { if (is_array($item->tax_ids)) { $itemTaxIds = array_map('intval', $item->tax_ids); } else { $decoded = json_decode($item->tax_ids, true); if (is_array($decoded)) { $itemTaxIds = array_map('intval', $decoded); } elseif (strpos($item->tax_ids, ',') !== false) { $itemTaxIds = array_map('intval', array_filter(explode(',', $item->tax_ids))); } elseif ($item->tax_ids) { $itemTaxIds = [intval($item->tax_ids)]; } } } @endphp @endif @empty @endforelse
#DescriptionQtyRateTaxAmount
{{ $item->description }}
{{ $item->long_description ?: $item->description }}
{{ $itemIndex }}
{{ $item->description }}
@if($item->long_description)
{{ $item->long_description }}
@endif
{{ number_format($item->quantity, 2) }} {{ number_format($item->rate, 2) }} @foreach($itemTaxIds as $taxId){{ $taxRatesMap[$taxId] ?? 0 }}%@endforeach @if(empty($itemTaxIds))-@endif {{ number_format($item->amount, 2) }}
No items
Total Estimate
{{ $estimation->currency ?? 'INR' }} {{ number_format($estimation->total, 2) }}
Subtotal{{ $estimation->currency ?? 'INR' }} {{ number_format($estimation->subtotal, 2) }}
@if(($estimation->discount_amount ?? 0) > 0)
Discount @if($estimation->discount_percent > 0)({{ $estimation->discount_percent }}%)@endif- {{ $estimation->currency ?? 'INR' }} {{ number_format($estimation->discount_amount, 2) }}
@endif @if(count($taxBreakdown) > 0)
Tax Breakdown
@foreach($taxBreakdown as $tax)
{{ $tax['name'] }} ({{ $tax['rate'] }}%){{ $estimation->currency ?? 'INR' }} {{ number_format($tax['amount'], 2) }}
@endforeach
@endif
Total Tax{{ $estimation->currency ?? 'INR' }} {{ number_format($estimation->tax_amount ?? 0, 2) }}
@if(($estimation->adjustment ?? 0) != 0)
Adjustment{{ $estimation->currency ?? 'INR' }} {{ number_format($estimation->adjustment, 2) }}
@endif
Grand Total{{ $estimation->currency ?? 'INR' }} {{ number_format($estimation->total, 2) }}
@if($estimation->terms_conditions)
📋 Terms & Conditions
{!! $estimation->terms_conditions !!}
@endif @if($estimation->privacy_policy)
🔒 Privacy Policy
{!! $estimation->privacy_policy !!}
@endif @if($estimation->payment_details)
💳 Payment Details
{!! $estimation->payment_details !!}
@endif @if($estimation->conclusion)
📝 Conclusion
{!! $estimation->conclusion !!}
@endif @if(!empty($company['signature']))
Customer Signature
@if(str_starts_with($company['signature'], 'data:image')) Signature @else @php $signaturePath = storage_path('app/public/' . $company['signature']); $signatureExists = file_exists($signaturePath); @endphp @if($signatureExists) @php $signatureData = base64_encode(file_get_contents($signaturePath)); $signatureMime = mime_content_type($signaturePath); @endphp Signature @else Signature @endif @endif
{{ $company['name'] }}
Authorized Signatory
@endif