@extends('admin.layouts.container')

@section('content')

    <div class="dashbord_home">
        <div class="row">

            <div class="row col-12  mb-5">
                <div class="col-12">
                    <div class="row">
                        <div class="col-lg-8">
                            <h5 class="text-uppercase font-weight-bold">{{__('dashboard.all_visits')}}</h5>
                        </div>
                        <div class="col-lg-4">
                            <select name="state_year" id="state_year" class="state_year form-control">
                                @for ($i = date('Y'); $i >= 2024; $i--)
                                    <option value="{{ $i }}"> {{ $i }} </option>
                                @endfor
                            </select>
                        </div>
                    </div>
                    <br />
                    <canvas class="border-item lineChart" width="400" height="150"></canvas>
                </div>
            </div>

            <div class="row col-12  mb-5">
                <div class="col-lg-6">
                    <div class="new-users border-item">
                        <div class="datatitle">
                            <h6 class="text-uppercase font-weight-bold">{{__('dashboard.website_visits')}}</h6>
                        </div>

                        <div class="items">
                            <span class="number text-primary">
                                {{$allUsersCounts}}
                            </span>
                        </div>
                    </div>
                </div>
                <div class="col-lg-6">
                    <div class="new-users border-item">
                        <div class="datatitle">
                            <h6 class="text-uppercase font-weight-bold">{{__('dashboard.visits_this_year')}} ({{date('Y')}})</h6>
                        </div>

                        <div class="items">
                            <span class="number text-primary">
                                {{$yearUsers}}
                            </span>
                        </div>
                    </div>
                </div>
                <div class="col-lg-6">
                    <div class="new-users border-item">
                        <div class="datatitle">
                            <h6 class="text-uppercase font-weight-bold"> {{__('dashboard.month_visits')}} ({{ __('web.'.date('F')) }}) </h6>
                        </div>

                        <div class="items">
                            <span class="number text-primary">
                                {{$monthUsers}}
                            </span>
                        </div>
                    </div>
                </div>
                <div class="col-lg-6">
                    <div class="new-users border-item">
                        <div class="datatitle">
                            <h6 class="text-uppercase font-weight-bold">{{__('dashboard.day_visits')}} ({{ __('web.'.date('l')) }}) </h6>
                        </div>

                        <div class="items">
                            <span class="number text-primary">
                                {{!empty($dayUsers) ? $dayUsers : 0}}
                            </span>
                        </div>
                    </div>
                </div>
                <div class="col-lg-6">
                    <div class="new-users border-item">
                        <div class="datatitle">
                            <h6 class="text-uppercase font-weight-bold">{{__('dashboard.now_visits')}} </h6>
                        </div>

                        <div class="items">
                            <span class="number text-primary">
                                {{!empty($nowUsersCounts) ? $nowUsersCounts : 0}}
                            </span>
                        </div>
                    </div>
                </div>
                <div class="col-lg-6">
                    <div class="new-users border-item">
                        <div class="datatitle">
                            <h6 class="text-uppercase font-weight-bold">{{__('dashboard.parents')}} </h6>
                        </div>

                        <div class="items">
                            <span class="number text-primary">
                                {{!empty($parents) ? $parents : 0}}
                            </span>
                        </div>
                    </div>
                </div>
                <div class="col-lg-6">
                    <div class="new-users border-item">
                        <div class="datatitle">
                            <h6 class="text-uppercase font-weight-bold">{{__('dashboard.user_canteens')}} </h6>
                        </div>

                        <div class="items">
                            <span class="number text-primary">
                                {{!empty($user_canteens) ? $user_canteens : 0}}
                            </span>
                        </div>
                    </div>
                </div>
                <div class="col-lg-6">
                    <div class="new-users border-item">
                        <div class="datatitle">
                            <h6 class="text-uppercase font-weight-bold">{{__('dashboard.schools')}} </h6>
                        </div>

                        <div class="items">
                            <span class="number text-primary">
                                {{!empty($schools) ? $schools : 0}}
                            </span>
                        </div>
                    </div>
                </div>
                <div class="col-lg-6">
                    <div class="new-users border-item">
                        <div class="datatitle">
                            <h6 class="text-uppercase font-weight-bold">{{__('dashboard.orders')}} </h6>
                        </div>

                        <div class="items">
                            <span class="number text-primary">
                                {{!empty($orders) ? $orders : 0}}
                            </span>
                        </div>
                    </div>
                </div>
                <div class="col-lg-12">
                    <div class="new-users border-item">
                        <div class="datatitle">
                            <h6 class="text-uppercase font-weight-bold">{{__('dashboard.canteens_most_sell')}} </h6>
                        </div>

                        <div class="items">
                            <div class="new-users border-item  table-responsive no-padding">
                                <table class="table table-bordered table-hover" style="text-align:center">
                                    <thead>
                                    <th>#</th>
                                    <th>{{__('dashboard.canteen')}}</th>
                                    <th>{{__('dashboard.canteen_count_paid')}}</th>
                                    </thead>
                                    <tbody>
                                        @foreach($canteens as $key=>$row)
                                            <tr>
                                                <td>{{$key+1}}</td>
                                                <td>{{$row->title}}</td>
                                                <td>{{$row->orders_count}}</td>
                                            </tr>
                                        @endforeach
                                    </tbody>
                                </table>

                            </div>
                        </div>
                    </div>
                </div>

            </div>

        </div>
    </div>
@endsection

@section('inner_js')

<script>
    const state_route= '{{ route("dashboard.stats") }}'
</script>
<script src="{{asset('assets/admin/js/lib/Chart.min.js')}}"></script>
<script src="{{ asset('assets/admin/js/charts.js') }}"></script>

@endsection
