@php // Get active languages for the restaurant $showArabic = $receiptSettings->show_arabic_on_receipt ?? false; $allActiveLanguages = collect(languages())->pluck('language_code')->toArray(); // Prioritize en and ar if both are available (common case like Lubab) // Otherwise use the first 2 active languages $primaryLang = 'en'; $secondaryLang = 'ar'; // If en is not in active languages, use first active language if (!in_array('en', $allActiveLanguages) && !empty($allActiveLanguages)) { $primaryLang = $allActiveLanguages[0]; } // If ar is not in active languages, use second active language or primary if only one if (!in_array('ar', $allActiveLanguages)) { if (count($allActiveLanguages) >= 2 && $allActiveLanguages[0] !== $primaryLang) { $secondaryLang = $allActiveLanguages[1]; } elseif (count($allActiveLanguages) >= 2) { // If primary is first, get second $secondaryLang = $allActiveLanguages[1]; } elseif (!empty($allActiveLanguages) && $allActiveLanguages[0] !== $primaryLang) { $secondaryLang = $allActiveLanguages[0]; } else { // If no other language, use same as primary (will only show one language) $secondaryLang = $primaryLang; } } // Ensure we have 2 different languages if ($primaryLang === $secondaryLang && count($allActiveLanguages) >= 2) { $secondaryLang = $allActiveLanguages[1] ?? 'en'; } // Helper function to get bilingual text $getBilingualText = function($key, $params = []) use ($showArabic, $primaryLang, $secondaryLang) { $currentLocale = app()->getLocale(); // Get primary language translation app()->setLocale($primaryLang); $primary = trans($key, $params); if ($showArabic) { // Get secondary language translation app()->setLocale($secondaryLang); $secondary = trans($key, $params); // Restore original locale app()->setLocale($currentLocale); // If secondary translation is same as key, it means translation doesn't exist, so just show primary if ($secondary === $key || empty($secondary)) { return $primary; } return $primary . ' / ' . $secondary; } // Restore original locale app()->setLocale($currentLocale); return $primary; }; // Helper function to get bilingual item name $getBilingualItemName = function($menuItem) use ($showArabic, $primaryLang, $secondaryLang) { if (!$menuItem) { return 'Item Not Found'; } $primaryName = $menuItem->getTranslatedValue('item_name', $primaryLang); if (!$primaryName) { $primaryName = $menuItem->item_name ?? 'Item Not Found'; } if ($showArabic) { $secondaryName = $menuItem->getTranslatedValue('item_name', $secondaryLang); // If secondary translation exists and is different, show both if ($secondaryName && $secondaryName !== $primaryName && $secondaryName !== $menuItem->item_name) { return $primaryName . ' / ' . $secondaryName; } } return $primaryName; }; @endphp
@if ($receiptSettings->show_restaurant_logo) @php $logoUrl = restaurant()->logo_url; $logoBase64 = null; if ($logoUrl) { try { // If the URL is relative, prepend the app URL if (!preg_match('/^https?:\/\//', $logoUrl)) { $logoUrl = url($logoUrl); } $logoImageContents = @file_get_contents($logoUrl); if ($logoImageContents !== false) { $logoBase64 = 'data:image/png;base64,' . base64_encode($logoImageContents); } } catch (\Exception $e) { $logoBase64 = null; } } @endphp @if ($logoBase64) @else @endif @endif {{ restaurant()->name }}
{!! nl2br(branch()->address) !!}
{{ $getBilingualText('modules.customer.phone') }}:{{ restaurant()->phone_number }}
@if ($receiptSettings->show_tax) @foreach ($taxDetails as $taxDetail)
{{ $taxDetail->tax_name }}: {{ $taxDetail->tax_id }}
@endforeach @endif
{{ $order->show_formatted_order_number }} {{ $order->date_time->timezone(timezone())->translatedFormat('d M Y h:i A') }}
@if ($receiptSettings->show_table_number && $order->table && $order->table->table_code) {{ $getBilingualText('modules.settings.tableNumber') }}: {{ $order->table->table_code }} @else @endif @if ($receiptSettings->show_total_guest && $order->number_of_pax) {{ $getBilingualText('modules.order.noOfPax') }}: {{ $order->number_of_pax }} @else @endif
@if ($receiptSettings->show_waiter && $order->waiter && $order->waiter->name) {{ $getBilingualText('modules.order.waiter') }}: {{ $order->waiter->name }} @endif
@if ($receiptSettings->show_order_type ) {{ Str::title(ucwords(str_replace('_', ' ', $order->order_type))) }} @if ($order->order_type === 'pickup') @if ($order->pickup_date) : {{ \Carbon\Carbon::parse($order->pickup_date)->translatedFormat('d M Y h:i A') }} @endif @endif @endif
@if ($receiptSettings->show_customer_name && $order->customer && $order->customer->name) {{ $getBilingualText('modules.customer.customer') }}: {{ $order->customer->name }} @endif
@if ($receiptSettings->show_customer_address && $order->customer && $order->customer->delivery_address)
{{ $getBilingualText('modules.customer.customerAddress') }}: {{ $order->customer->delivery_address }}
@endif
@foreach ($order->items as $item) @php // Calculate original price and discount // The price stored in order_item is the promotional price, so we need to get original from menu item $originalPrice = isset($item->menuItemVariation) && $item->menuItemVariation ? $item->menuItemVariation->price : ($item->menuItem->price ?? $item->price); $discountedPrice = $item->price; // This is the promotional price that was saved $hasDiscount = abs($discountedPrice - $originalPrice) > 0.01; // Use small tolerance for float comparison $discountAmount = $hasDiscount ? ($originalPrice - $discountedPrice) * $item->quantity : 0; $discountPercent = $hasDiscount && $originalPrice > 0 ? (($originalPrice - $discountedPrice) / $originalPrice * 100) : 0; @endphp @endforeach
{{ $getBilingualText('modules.order.qty') }} {{ $getBilingualText('modules.menu.itemName') }} {{ $getBilingualText('modules.order.price') }} {{ $getBilingualText('modules.order.amount') }}
{{ $item->quantity }} {{ $getBilingualItemName($item->menuItem) }} @if (isset($item->menuItemVariation) && $item->menuItemVariation)
({{ $item->menuItemVariation->variation }}) @endif @foreach ($item->modifierOptions as $modifier)
• {{ $modifier->name }} (+{{ currency_format($modifier->price, restaurant()->currency_id) }})
@endforeach @if($item->note)
{{ $getBilingualText('modules.order.note') }}: {{ $item->note }}
@endif @if($hasDiscount)
@if($discountPercent > 0) {{ number_format($discountPercent, 0) }}% OFF @else -{{ currency_format($discountAmount, restaurant()->currency_id) }} @endif @endif
@if($hasDiscount)
{{ currency_format($originalPrice, restaurant()->currency_id) }}
{{ currency_format($discountedPrice, restaurant()->currency_id) }}
@else {{ currency_format($item->price, restaurant()->currency_id) }} @endif
{{ currency_format($item->amount, restaurant()->currency_id) }}
{{ $getBilingualText('modules.order.subTotal') }}: {{ currency_format($order->sub_total, restaurant()->currency_id) }}
@if (!is_null($order->discount_amount))
{{ $getBilingualText('modules.order.discount') }} @if ($order->discount_type == 'percent') ({{ rtrim(rtrim($order->discount_value, '0'), '.') }}%) @endif -{{ currency_format($order->discount_amount, restaurant()->currency_id) }}
@endif @foreach ($order->charges as $item)
{{ $item->charge->charge_name }} @if ($item->charge->charge_type == 'percent') ({{ $item->charge->charge_value }}%) @endif: {{ currency_format(($item->charge->getAmount($order->sub_total - ($order->discount_amount ?? 0))), restaurant()->currency_id) }}
@endforeach @if ($order->tip_amount > 0)
{{ $getBilingualText('modules.order.tip') }}: {{ currency_format($order->tip_amount, restaurant()->currency_id) }}
@endif @if ($order->order_type === 'delivery' && !is_null($order->delivery_fee))
{{ $getBilingualText('modules.delivery.deliveryFee') }} @if($order->delivery_fee > 0) {{ currency_format($order->delivery_fee, restaurant()->currency_id) }} @else {{ $getBilingualText('modules.delivery.freeDelivery') }} @endif
@endif @if ($taxMode == 'order') @foreach ($order->taxes as $item)
{{ $item->tax->tax_name }} ({{ $item->tax->tax_percent }}%): {{ currency_format(($item->tax->tax_percent / 100) * ($order->sub_total - ($order->discount_amount ?? 0)), restaurant()->currency_id) }}
@endforeach @else @if($order->total_tax_amount > 0) @php $taxTotals = []; $totalTax = 0; foreach ($order->items as $item) { $qty = $item->quantity ?? 1; $taxBreakdown = is_array($item->tax_breakup) ? $item->tax_breakup : (json_decode($item->tax_breakup, true) ?? []); foreach ($taxBreakdown as $taxName => $taxInfo) { if (!isset($taxTotals[$taxName])) { $taxTotals[$taxName] = [ 'percent' => $taxInfo['percent'] ?? 0, 'amount' => ($taxInfo['amount'] ?? 0) * $qty ]; } else { $taxTotals[$taxName]['amount'] += ($taxInfo['amount'] ?? 0) * $qty; } } $totalTax += $item->tax_amount ?? 0; } @endphp
@foreach ($taxTotals as $taxName => $taxInfo)
{{ $taxName }} ({{ $taxInfo['percent'] }}%) {{ currency_format($taxInfo['amount'], restaurant()->currency_id) }}
@endforeach
{{ $getBilingualText('modules.order.totalTax') }}: {{ currency_format($totalTax, restaurant()->currency_id) }}
@endif @endif @if ($payment)
{{ $getBilingualText('modules.order.balanceReturn') }}: {{ currency_format($payment->balance, restaurant()->currency_id) }}
@endif
{{ $getBilingualText('modules.order.total') }}: {{ currency_format($order->total, restaurant()->currency_id) }}
@php // Get order-level notes from KOTs $orderNotes = $order->kot->pluck('note')->filter()->unique()->values(); @endphp @if($orderNotes->isNotEmpty())
{{ $getBilingualText('modules.order.specialInstructions') }}:
@foreach($orderNotes as $note)
{{ $note }}
@endforeach
@endif