
@extends(ucfirst(activeGuard()).'.'.layout())
@section('pagetitle', __('trans.clientReport'))
@section('content')

@php
   $currency = currancy_code();
@endphp
<form method="GET" class="row g-3 mb-4">
    <div class="col-md-3">
        <label for="from" class="form-label">@lang('trans.from')</label>
        <input type="date" id="from" name="from" class="form-control" value="{{ request('from') }}">
    </div>

    <div class="col-md-3">
        <label for="to" class="form-label">@lang('trans.to')</label>
        <input type="date" id="to" name="to" class="form-control" value="{{ request('to') }}">
    </div>

     <div class="col-md-3 text-end d-flex justify-content-between align-items-end">
        <button type="submit" class="btn btn-primary w-50">
            <i class="fa fa-search"></i> @lang('trans.search')
        </button>
        <a href="{{ route(Route::currentRouteName()) }}" class="btn btn-secondary w-50 ms-3">
            <i class="fa fa-times"></i> @lang('trans.Clear')
        </a>
    </div>
</form>

<!--<table class="table table-bordered table-hover table-striped data-table">-->
<!--    <thead>-->
<!--        <tr>-->
<!--            <th>#</th>-->
<!--            <th>@lang('trans.name')</th>-->
<!--            <th>@lang('trans.phone')</th>-->
<!--            <th>@lang('trans.order')</th>-->
<!--            <th>@lang('trans.payment')</th>-->
<!--            <th>@lang('trans.sub_total')</th>-->
<!--            {{-- there can be vat , coupon and charge cost --}}-->
<!--            <th>@lang('trans.net_total')</th>-->
<!--            <th>@lang('trans.status')</th>-->
<!--            <th>@lang('trans.date')</th>-->
           
<!--        </tr>-->
<!--    </thead>-->
<!--    <tbody>-->
<!--        @foreach ($Models as $Model)-->
<!--            @foreach ($Model->Orders()->get() as $Order)-->
<!--        <tr>-->
<!--                <td>-->
<!--                    {{ $loop->iteration }}-->
<!--                </td>-->
               
<!--                <td>-->
<!--                    {{ $Model->name }}-->
<!--                </td>-->
<!--                <td>-->
<!--                {{ $Model->phone }}-->
<!--                </td>-->
<!--                <td>-->
<!--                {{ $Order->id }}-->
<!--                </td>-->
<!--                <td>-->
<!--                {{ $Order->Payment->title() }}-->
<!--                </td>-->
<!--                <td>-->
<!--                    {{ $Order->sub_total }}-->
<!--                </td>-->
<!--                <td>-->
<!--                    {{ $Order->net_total }}-->
<!--                </td>-->
<!--                <td>-->
<!--                    {{ $Order->status }}-->
<!--                </td>-->
<!--                <td>-->
<!--                    {{ $Model->created_at }}-->
<!--                </td>-->
<!--        </tr>-->
<!--            @endforeach-->
<!--        @endforeach-->
<!--    </tbody>-->
<!--</table>-->
<table class="table table-bordered table-hover table-striped data-table">
    <thead>
        <tr>
            <th>#</th>
            <th>@lang('trans.name')</th>
            <th>@lang('trans.phone')</th>
            <th>@lang('trans.country')</th>
            <th>@lang('trans.region')</th>
            <th>@lang('trans.city')</th>
            <th>@lang('trans.district')</th>
            <th>@lang('trans.building')</th>
            <th>@lang('trans.apartment')</th>
            <th>@lang('trans.additional_directions')</th>
            <th>@lang('trans.date')</th>
        </tr>
    </thead>
    <tbody>
        @foreach ($Models as $Model)
        @php($Address=$Model->Addresses()->latest()->first())
                <tr>
                    <td>{{ $loop->iteration }}</td>
                    <td>{{ $Model->name }}</td>
                    <td>{{ $Model->phone }}</td>
                    <td>{{ $Address ? $Address->country?->title() : '-' }}</td>
                    <td>{{ $Address ? $Address->region?->title() : '-' }}</td>
                    <td>{{ $Address ? $Address->block : '-' }}</td>
                    <td>{{ $Address ? $Address->road : '-' }}</td>
                    <td>{{ $Address ? $Address->building : '-' }}</td>
                    <td>{{ $Address ? $Address->apartment : '-' }}</td>
                    <td>{{ $Address ? $Address->additional_directions : '-' }}</td>
                    <td>{{ $Model->created_at }}</td>
                </tr>
        @endforeach
    </tbody>
</table>


@endsection