@extends('website.layouts.master') @section('content') {{-- --}} {{-- --}}
@php $hasOrders = false; @endphp @php $deliveryStatuses = [ 'pending' => [ 'label' => 'فى انتظار الموافقه', 'icon' => 'fa-mobile-alt', ], 'in_progress' => [ 'label' => 'يتم تحضير طلبك', 'icon' => 'fa-utensils', ], 'on_way' => [ 'label' => 'طلبك فى الطريق اليك', 'icon' => 'fa-map-marker-alt', ], 'delivered' => [ 'label' => 'تم التوصيل', 'icon' => 'fa-check-circle', ], ]; // Define statuses for takeaway orders $takeawayStatuses = [ 'pending' => [ 'label' => __('trackOrder.pending'), 'icon' => 'fa-mobile-alt', ], 'in_progress' => [ 'label' => __('trackOrder.in_progress'), 'icon' => 'fa-utensils', ], 'completed' => [ 'label' => __('trackOrder.ready'), 'icon' => 'fa-check-circle', ], ]; @endphp @if ($orders) @foreach ($orders as $order) @php // Fetch the statuses from the tracking table $trackingStatuses = $order->tracking->pluck('order_status')->toArray(); $currentStatus = last($trackingStatuses); @endphp @if ($order->type === 'Delivery') @php $hasOrders = true; @endphp
@lang('header.orderstatus')
@php $lastTrackingStatus = $order->tracking->last()?->order_status; @endphp @if ($order->status === 'pending') @if (now()->diffInMinutes($order->created_at) <= $order->branch->time_cancellation) @endif @endif
@php $lastTracking = $order->tracking->last(); $orderCreationTime = $order->created_at; $fromTime = $orderCreationTime ? \Carbon\Carbon::parse($orderCreationTime) : null; $deliveryTime = getBranchSettings($order->branch_id, 'delivery_time'); // $bufferTime = 15; $toTime = $fromTime ? $fromTime->copy()->addMinutes($deliveryTime) //+ $bufferTime) : null; $estimatedMinutes = $lastTracking?->time; @endphp
@lang('header.deliverytimeexpect')
{{ $fromTime ? $fromTime->format('h:i') : 'N/A' }} @lang($fromTime && $fromTime->format('A') === 'AM' ? 'header.am' : 'header.pm') - {{ $toTime ? $toTime->format('h:i') : 'N/A' }} @lang($toTime && $toTime->format('A') === 'AM' ? 'header.am' : 'header.pm')
@lang('header.ordernum') {{ $order->order_number }}
{{-- code for websockit update dynamic --}} @php // Fetch the statuses from the tracking table $trackingStatuses = $order->tracking->pluck('order_status')->toArray(); $currentStatus = last($trackingStatuses); @endphp
@lang('header.orderSummary')
@lang('header.deliveryinfo')
@if ($order->address)

@lang('header.address') : {{ $order->address->address }}

@lang('header.state') : {{ $order->address->state }}

@lang('header.extranote') : @if ($order->address->building || $order->address->floor_number || $order->address->apartment_number)

@if ($order->address->building) {{ __('header.bulding') }}: {{ $order->address->building }}
@endif @if ($order->address->floor_number) {{ __('header.floor') }}: {{ $order->address->floor_number }}
@endif @if ($order->address->apartment_number) {{ __('header.apartment') }}: {{ $order->address->apartment_number }}
@endif
@else
@lang('header.noextrainfo')
@endif

@lang('header.note') : {{ $order->address->notes ?? __('header.nonote') }}

@lang('header.phone') : {{ $order->address->address_phone ?? __('header.nophone') }}

@else

@lang('header.noaddress')

@endif

@lang('header.name') : {{ $order->client?->name }}

@lang('header.paymentinfo')
@if ($order->orderTransactions->isNotEmpty()) @foreach ($order->orderTransactions as $transaction)

@lang('header.paymentmethod') @switch($transaction->payment_method) @case('cash') @lang('header.cash') @break @case('credit_card') @lang('header.credit_card') @break @case('online') @lang('header.online') @break @default @lang('header.cash') @endswitch

@endforeach @else

@lang('header.nopaymentmethod')

@endif
@lang('header.orderdetails')
@foreach ($order->orderDetails as $detail) @php $addons = $order->orderAddons->filter( fn($addon) => $addon->order_details_id == $detail->id && $addon->Addon?->addons?->name_ar, ); @endphp
{{ $detail->quantity }} x {{ app()->getLocale() === 'ar' ? $detail->dish?->name_ar : $detail->dish?->name_en }} @if ($detail->dishSize) ({{ app()->getLocale() === 'ar' ? $detail->dishSize->size_name_ar : $detail->dishSize->size_name_en }}) @endif

@if ($order->tax_application == 0) {{ $detail->price_befor_tax + $addons->sum('price_before_tax') }} @else {{ $detail->price_after_tax + $addons->sum('price_after_tax') }} @endif {{ $order->Branch->country->currency_symbol }}

@if ($addons->isNotEmpty())
{{ $addons->map(fn($addon) => app()->getLocale() === 'ar' ? $addon->Addon->addons->name_ar : $addon->Addon->addons->name_en)->implode(', ') }}
@endif @if ($detail->note)
@lang('order.notes'):{{ $detail->note }}
@endif @endforeach @if ($order->note)
@lang('order.orderNote'): {{ $order->note }}
@endif
@lang('header.reset')

@lang('header.totalorder')

@php $subTotalPrice = $order->total_price_befor_tax; if ($order->tax_application == 1) { $subTotalPrice += $order->tax_value; } @endphp {{ $subTotalPrice }} {{ $order->Branch->country->currency_symbol }}

@if ($order->coupon_value != 0)

@lang('header.coupon')

-{{ $order->coupon_value }} {{ $order->Branch->country->currency_symbol }}

@endif

@lang('header.feesdelivery')

{{ $order->delivery_fees ?? 0 }} {{ $order->Branch->country->currency_symbol }}

@lang('header.serviceFees')

{{ $order->service_fees ?? 0 }} {{ $order->Branch->country->currency_symbol }}

@if ($order->tax_application == 0)

@lang('header.includefees') {{ number_format(($order->tax_value / $order->total_price_befor_tax) * 100, 2) . '%' }} @lang('header.anotherway') {{ $order->tax_value }} {{ $order->Branch->country->currency_symbol }}

@else

@lang('header.notincludefees')

@endif
@lang('header.total')
{{ $order->total_price_after_tax }} {{ $order->Branch->country->currency_symbol }}
@if ($currentStatus == 'pending' || $currentStatus == 'in-progress')
@lang('order.contactRestaurant')
@endif @if ($currentStatus == 'on_way')
@lang('order.contactDriver')
{{ $order->delivery->first_name . ' ' . $order->delivery->last_name }}
Driver
{{ $order->delivery->first_name . ' ' . $order->delivery->last_name }}
@lang('order.driver')
@lang('order.welcomeMsg') Driver
@endif
@endif @if ($order->type === 'Takeaway') @php $hasOrders = true; @endphp
@lang('header.orderstatus')
@php $lastTrackingStatus = $order->tracking->last()?->order_status; @endphp @if ($order->status === 'pending') @if (now()->diffInMinutes($order->created_at) <= $order->branch->time_cancellation) @endif @endif
@lang('header.ordernum'){{ $order->order_number }}
@lang('header.orderSummary')
@lang('header.pickupFrom')

{{ app()->getLocale() === 'ar' ? $order->branch->address_ar : $order->branch->address_en }}

{{ app()->getLocale() === 'ar' ? $order->branch->name_ar : $order->branch->name_en }}

@lang('header.paymentinfo')
@if ($order->orderTransactions->isNotEmpty()) @foreach ($order->orderTransactions as $transaction)

@lang('header.paymentmethod') @switch($transaction->payment_method) @case('cash') @lang('header.cash') @break @case('credit_card') @lang('header.credit_card') @break @case('online') @lang('header.online') @break @default @lang('header.cash') @endswitch

@endforeach @else

@lang('header.nopaymentmethod')

@endif
@lang('header.orderdetails')
@foreach ($order->orderDetails as $detail) @php $addons = $order->orderAddons->filter( fn($addon) => $addon->order_details_id == $detail->id && $addon->Addon?->addons?->name_ar, ); @endphp
{{ $detail->quantity }} x {{ app()->getLocale() === 'ar' ? $detail->dish?->name_ar : $detail->dish?->name_en }} @if ($detail->dishSize) ({{ app()->getLocale() === 'ar' ? $detail->dishSize->size_name_ar : $detail->dishSize->size_name_en }}) @endif

@if ($order->tax_application == 0) {{ $detail->price_befor_tax + $addons->sum('price_before_tax') }} @else {{ $detail->price_after_tax + $addons->sum('price_after_tax') }} @endif {{ $order->Branch->country->currency_symbol }}

@if ($addons->isNotEmpty())
{{ $addons->map(fn($addon) => app()->getLocale() === 'ar' ? $addon->Addon->addons->name_ar : $addon->Addon->addons->name_en)->implode(', ') }}
@endif @if ($detail->note)
@lang('order.notes'):{{ $detail->note }}
@endif @endforeach @if ($order->note)
@lang('order.orderNote'): {{ $order->note }}
@endif
@lang('header.reset')

@lang('header.totalorder')

@php $basePrice = $order->total_price_befor_tax; $couponDiscount = 0; if ($order->coupon_id) { if ($order->coupon->type === 'percentage') { $couponDiscount = ($basePrice * $order->coupon->value) / 100; } elseif ($order->coupon->type === 'fixed') { $couponDiscount = $order->coupon->value; } } $subTotalPrice = $basePrice + $couponDiscount; if ($order->tax_application == 1) { $subTotalPrice += $order->tax_value; } @endphp {{ $subTotalPrice }} {{ $order->Branch->country->currency_symbol }}

@if ($order->coupon_id)

@lang('header.coupon')

@if ($order->coupon->type === 'percentage')

-{{ ($order->total_price_befor_tax * $order->coupon->value) / 100 }} {{ $order->Branch->country->currency_symbol }}

@elseif ($order->coupon->type === 'fixed')

-{{ $order->coupon->value }} {{ $order->Branch->country->currency_symbol }}

@endif
@endif @if ($order->tax_application == 0)

@lang('header.includefees') {{ number_format(($order->tax_value / $order->total_price_befor_tax) * 100, 2) . '%' }} @lang('header.anotherway') {{ $order->tax_value }} {{ $order->Branch->country->currency_symbol }}

@else

@lang('header.notincludefees')

@endif
@lang('header.total')
{{ $order->total_price_after_tax }} {{ $order->Branch->country->currency_symbol }}
@endif @endforeach @endif @if ($reservations) @foreach ($reservations as $reservation)
@lang('header.orderstatus')
@lang('order.arrivingTime')
{{ $reservation->time_from ? $reservation->time_from->format('h:i') : 'N/A' }} @lang($reservation->time_from->format('A') === 'AM' ? 'header.am' : 'header.pm')
{{ $reservation->reservation_number }}
Done
@lang('order.reservationConfirmed')
@lang('header.orderSummary')
@lang('header.paymentinfo')
@if ($reservation->reservation_type == 'without') @if ($reservation->transaction->payment_status == 'unpaid')

@lang('order.withoutDeposit')

@elseif($reservation->transaction->payment_status == 'part')

@lang('order.withDeposit') ({{ $reservation->transaction->paid }} {{ $reservation->branch->country->currency_symbol }})

@if ($reservation->transaction->payment_method == 'online')

@lang('order.paidOnline')

@elseif($reservation->transaction->payment_method == 'cash')

@lang('order.paidCash')

@elseif($reservation->transaction->payment_method == 'credit_card')

@lang('order.paidCredit')

@endif
@endif @elseif ($reservation->reservation_type == 'with') @if ($reservation->order->transaction->payment_status == 'unpaid')

@lang('order.withoutDeposit')

@elseif($reservation->order->transaction->payment_status == 'part')

@lang('order.withDeposit') ({{ $reservation->order->transaction->paid }} {{ $reservation->branch->country->currency_symbol }})

@if ($reservation->order->transaction->payment_method == 'online')

@lang('order.paidOnline')

@elseif($reservation->order->transaction->payment_method == 'cash')

@lang('order.paidCash')

@elseif($reservation->order->transaction->payment_method == 'credit_card')

@lang('order.paidCredit')

@endif
@elseif($reservation->order->transaction->payment_status == 'paid')

@lang('order.wholeDeposit') ({{ $reservation->order->transaction->paid }} {{ $reservation->branch->country->currency_symbol }})

@if ($reservation->order->transaction->payment_method == 'online')

@lang('order.paidOnline')

@elseif($reservation->order->transaction->payment_method == 'cash')

@lang('order.paidCash')

@elseif($reservation->order->transaction->payment_method == 'credit_card')

@lang('order.paidCredit')

@endif
@endif @endif
@lang('header.orderdetails')
@lang('order.table') ({{ $reservation->tables->table_number }})
@lang('order.arrival'): {{ $reservation->time_from ? $reservation->time_from->format('h:i') : 'N/A' }} @lang($reservation->time_from->format('A') === 'AM' ? 'header.am' : 'header.pm')
{{ $reservation->date->translatedFormat('j F , Y') }}
{{ $reservation->adult }}@lang('order.person') @if ($reservation->kids != 0) ,{{ $reservation->kids }}@lang('order.kid') @endif
@if ($reservation->tables->type == 1) @lang('order.inside') @else @lang('order.outside') @endif
@lang('order.leaving'): {{ $reservation->time_to ? $reservation->time_to->format('h:i') : 'N/A' }} @lang($reservation->time_to->format('A') === 'AM' ? 'header.am' : 'header.pm')
@if ($reservation->reservation_type == 'with')
@foreach ($reservation->order->orderDetails as $detail) @php $addons = $reservation->order->orderAddons->filter( fn($addon) => $addon->order_details_id == $detail->id && $addon->Addon?->addons?->name_ar, ); @endphp
{{ $detail->quantity }} x {{ app()->getLocale() === 'ar' ? $detail->dish?->name_ar : $detail->dish?->name_en }} @if ($detail->dishSize) ({{ app()->getLocale() === 'ar' ? $detail->dishSize->size_name_ar : $detail->dishSize->size_name_en }}) @endif

@if ($reservation->order->tax_application == 0) {{ $detail->price_befor_tax + $addons->sum(fn($addon) => $addon->price_before_tax) }} @else {{ $detail->price_after_tax + $addons->sum(fn($addon) => $addon->price_after_tax) }} @endif {{ $reservation->order->Branch->country->currency_symbol }}

@if ($addons->isNotEmpty())
{{ $addons->map(fn($addon) => app()->getLocale() === 'ar' ? $addon->Addon->addons->name_ar : $addon->Addon->addons->name_en)->implode(', ') }}
@endif @if ($detail->note)
@lang('order.notes'):{{ $detail->note }}
@endif @endforeach
@endif
@if ($reservation->reservation_type == 'with')
@lang('header.reset')

@lang('header.totalorder')

@php $basePrice = $reservation->order->total_price_befor_tax; $couponDiscount = 0; if ($reservation->order->coupon_id) { if ($reservation->order->coupon->type === 'percentage') { $couponDiscount = ($basePrice * $reservation->order->coupon->value) / 100; } elseif ($reservation->order->coupon->type === 'fixed') { $couponDiscount = $reservation->order->coupon->value; } } $subTotalPrice = $basePrice + $couponDiscount; if ($reservation->order->tax_application == 1) { $subTotalPrice += $reservation->order->tax_value; } @endphp {{ $subTotalPrice }} {{ $reservation->order->Branch->country->currency_symbol }}

@if ($reservation->order->coupon_id)

@lang('header.coupon')

@if ($reservation->order->coupon->type === 'percentage')

-{{ ($reservation->order->total_price_befor_tax * $order->coupon->value) / 100 }} {{ $reservation->order->Branch->country->currency_symbol }}

@elseif ($reservation->order->coupon->type === 'fixed')

-{{ $reservation->order->coupon->value }} {{ $reservation->order->Branch->country->currency_symbol }}

@endif
@endif

@lang('header.serviceFees')

{{ $reservation->order->service_fees ?? 0 }} {{ $reservation->order->Branch->country->currency_symbol }}

@if ($reservation->order->tax_application == 0)

@lang('header.includefees') {{ number_format(($order->tax_value / $order->total_price_befor_tax) * 100, 2) . '%' }} @lang('header.anotherway') {{ $reservation->order->tax_value }} {{ $reservation->order->Branch->country->currency_symbol }}

@else

@lang('header.notincludefees')

@endif
@lang('header.total')
{{ $reservation->order->total_price_after_tax }} {{ $reservation->order->Branch->country->currency_symbol }}
@endif
@lang('order.contactRestaurant')
@endforeach @endif @if (!$hasOrders && $reservations->isEmpty())

@lang('auth.noorders')

@endif
@endsection @include('website.cart.global') {{-- @if ($orders && isset($statuses)) --}}