@extends('layouts.dashboard') @section('content') @php use App\Models\Order; /** @var array $active @var array $completed @var array|null $driver */ /** * Render one deliveries table; $editable adds the status-change controls. * $caption gives each (visually identical) table a distinct accessible name * so screen-reader users can tell Active and Completed apart at the table level. */ $renderTable = function (iterable $rows, bool $editable, string $caption) use ($__env): void { @endphp
@if ($editable)@endif @foreach ($rows as $o) @if ($editable) @endif @endforeach
{{ $caption }}
{{ t_raw('dashboard.col_order') }}{{ t_raw('dashboard.col_restaurant') }}{{ t_raw('dashboard.col_customer') }}{{ t_raw('dashboard.col_dropoff') }} {{ t_raw('dashboard.col_fee') }}{{ t_raw('dashboard.col_status') }}{{ t_raw('common.actions') }}
{{ $o['order_number'] }} @if (!empty($o['first_item_name'])){{ $o['first_item_name'] }}@if (($o['item_count'] ?? 0) > 1) {{ t_raw('admin.dashboard.items_more_suffix', [':n' => (int) $o['item_count'] - 1]) }}@endif@endif
{!! restaurant_brandmark(['logo' => $o['restaurant_logo'] ?? '', 'name' => $o['restaurant_name'] ?? '', 'cuisine_slug' => $o['cuisine_slug'] ?? ''], 'md') !!}
{{ $o['restaurant_name'] }} @php $rAddr = trim((string) ($o['restaurant_address'] ?? '') . (!empty($o['restaurant_city']) ? ', ' . $o['restaurant_city'] : '')); @endphp @if ($rAddr !== ''){{ $rAddr }}@endif
{!! brandmark_html($o['customer_avatar'] ?? null, (string) $o['customer_name'], 'md', 'qm-brandmark--round') !!}
{{ $o['customer_name'] }} @if (!empty($o['customer_phone'])){{ $o['customer_phone'] }}@endif
{!! e($o['delivery_address'] ?? '') ?: '' . t('common.pickup') . '' !!} {{ money($o['delivery_fee']) }} {{ Order::statusLabel($o['status']) }} @php /** * Turn-by-turn hand-off, first in the row because it is the first thing a rider * does with a job. The pin is the order's OWN destination coordinate, so there * is no geocoding, no lookup and no API key; both are plain https deep links, * which open the installed app on a phone and the web map on a desktop. * * No coordinate, no buttons. A control that looks live and navigates nowhere * costs a rider more than an absent one, and the written address is already in * the Drop-off column for exactly that case. is_numeric() covers all three ways * the pin can be missing at once: a NULL column, an empty string, and a pickup * order that never had a destination. */ $navLat = $o['delivery_lat'] ?? null; $navLng = $o['delivery_lng'] ?? null; @endphp @if (is_numeric($navLat) && is_numeric($navLng)) @php // Formatted, not string-cast: a fixed decimal string is the same pin in // every locale and every PHP precision setting. $navPin = number_format((float) $navLat, 7, '.', '') . ',' . number_format((float) $navLng, 7, '.', ''); @endphp @endif @php $next = Order::transitions()[$o['status']] ?? []; @endphp @if (in_array('out_for_delivery', $next, true))
@csrf
@elseif ($next)
@csrf
@else {!! dash() !!} @endif
@php }; @endphp

{{ t_raw('dashboard.active_deliveries_heading') }}

@if (count($active)) @php $renderTable($active, true, t_raw('dashboard.caption_active_deliveries')); @endphp @else

{{ t_raw('dashboard.no_active_deliveries') }}

{{ t_raw('dashboard.no_active_deliveries_text') }}

@endif

{{ t_raw('dashboard.completed_heading') }}

@if (count($completed)) @php $renderTable($completed, false, t_raw('dashboard.caption_completed_deliveries')); @endphp @partial('table-toolbar', ['pager' => $pager, 'base' => '/driver/deliveries']) @else

{{ t_raw('dashboard.nothing_completed') }}

{{ t_raw('dashboard.nothing_completed_text') }}

@endif
@php // Optional geolocation pinger: only wires up when maps are enabled in settings. // It posts lat/lng to /driver/ping for any order currently out for delivery. $mapsEnabled = setting('maps_enabled', '1') === '1'; $liveOrderId = 0; foreach ($active as $o) { if ($o['status'] === 'out_for_delivery') { $liveOrderId = (int) $o['id']; break; } } @endphp @if ($mapsEnabled && $liveOrderId > 0) @endif @endsection