@extends('layouts.app_booking') @section('title', __('restaurant.bookings')) @section('content')
@component('components.widget', ['class' => 'card'])
@foreach($availableTimes as $times) @endforeach @foreach($waiters as $waiter) @php $count = DB::table('transaction_sell_lines as tsl') ->join('bookings as b', 'tsl.booking_id', '=', 'b.id') ->join('transactions as t', 'b.id', '=', 't.booking_id') ->join('contacts as c', 't.contact_id', '=', 'c.id') // 👤 العميل ->join('products as p', 'tsl.product_id', '=', 'p.id') // 📦 المنتج ->join('users as u', 'tsl.res_service_staff_id', '=', 'u.id') // 👨‍💼 الموظف ->whereDate('tsl.booking_start_time', $selected_date) ->where('tsl.res_service_staff_id', $waiter->id)->count(); @endphp @foreach($availableTimes as $time) @php $staff_id =$waiter->id; $fullDateTime = Carbon::createFromFormat('Y-m-d H:i', $selected_date . ' ' . $time)->format('Y-m-d H:i:s'); // 📌 تنفيذ الاستعلام لجلب جميع تفاصيل الحجز $booking = DB::table('transaction_sell_lines as tsl') ->join('bookings as b', 'tsl.booking_id', '=', 'b.id') ->join('transactions as t', 'b.id', '=', 't.booking_id') ->join('contacts as c', 't.contact_id', '=', 'c.id') // 👤 العميل ->join('products as p', 'tsl.product_id', '=', 'p.id') // 📦 المنتج ->join('users as u', 'tsl.res_service_staff_id', '=', 'u.id') // 👨‍💼 الموظف ->whereTime('tsl.booking_start_time', $time) ->where('tsl.booking_start_time', '=', $fullDateTime) // ✅ البحث بتاريخ + وقت معًا ->where('b.location_id', $location_id) ->where('tsl.res_service_staff_id', $staff_id) ->select( 't.id as transaction_id', 'b.id as booking_id', 'b.created_by as booking_by', 'b.booking_status as booking_status', 'b.created_by as booking_created_by', 'tsl.res_service_staff_id as staff_id', 'u.first_name as staff_first_name', 'u.last_name as staff_last_name', 't.location_id as branch_id', 't.invoice_no as invoice_no', 'c.id as customer_id', 'c.name as customer_name', 'c.mobile as customer_phone', 'p.id as product_id', 'p.name as product_name', 'tsl.booking_start_time as start_time', 'tsl.booking_end_time as end_time' ) ->first(); // ✅ جلب أول سجل فقط @endphp @endforeach @endforeach
{{$times}} 🕒
{{$waiter->surname ?? $waiter->first_name .' '.$waiter->last_name}}
{{__('new.total_bookings') .' : ' . $count }}
booking_status == 'waiting') class="bg-warning" @elseif($booking && $booking->booking_status == 'completed') class="bg-success" @elseif($booking && $booking->booking_status == 'cancelled') class="bg-danger" @endif> @if($booking)
@if($booking->customer_name) {{mb_substr($booking->customer_name, 0, 1, 'utf-8')}} @endif
{{$booking->customer_name ?? ""}}
{{$booking->product_name ?? ""}}
{{ __('new.booking_no') .' : '. $booking->invoice_no ?? ""}}
{{ __('new.booking_by') .' : '. \App\User::find($booking->booking_by)->first_name .' ' .\App\User::find($booking->booking_by)->last_name }}
@endif
@endcomponent
@endsection @section('css') @endsection