@extends('store.layouts.container')

@section('content')


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


            <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.today_orders_total')}}  </h6>
                        </div>

                        <div class="items">
                            <span class="number text-primary">
                                {{!empty($today_orders_total) ? $today_orders_total : 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.month_orders_total')}}  </h6>
                        </div>

                        <div class="items">
                            <span class="number text-primary">
                                {{!empty($month_orders_total) ? $month_orders_total : 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.year_orders_total')}} </h6>
                        </div>

                        <div class="items">
                            <span class="number text-primary">
                                {{!empty($year_orders_total) ? $year_orders_total : 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.today_orders_count')}}  </h6>
                        </div>

                        <div class="items">
                            <span class="number text-primary">
                                {{!empty($today_orders_count) ? $today_orders_count : 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.month_orders_count')}}  </h6>
                        </div>

                        <div class="items">
                            <span class="number text-primary">
                                {{!empty($month_orders_count) ? $month_orders_count : 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.year_orders_count')}} </h6>
                        </div>

                        <div class="items">
                            <span class="number text-primary">
                                {{!empty($year_orders_count) ? $year_orders_count : 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.latest_orders')}} </h6>
                        </div>
                        <div class="items">
                            <table class="table justify-content-center table-striped">
                                <thead>
                                <tr>
                                    <th scope="col">#</th>
                                    <th scope="col">{{__('dashboard.order_id')}}</th>
                                    <th scope="col">{{__('dashboard.order_user')}}</th>
                                    <th scope="col">{{__('dashboard.count_products')}}</th>
                                </tr>
                                </thead>
                                <tbody>
                                @foreach($latest_orders as $key=>$row)
                                    <tr>
                                        <th scope="row">{{$key+1}}</th>
                                        <td>{{$row->id}}</td>
                                        <td>{{$row->user->name}}</td>
                                        <td>{{$row->productsStore(auth()->user()->store_id)->count()}}</td>
                                    </tr>
                                @endforeach
                                </tbody>
                            </table>
                        </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.products_total')}} </h6>
                        </div>
                        <div class="items">
                            <table class="table justify-content-center table-striped">
                                <thead>
                                <tr>
                                    <th scope="col">#</th>
                                    <th scope="col">{{__('dashboard.product')}}</th>
                                    <th scope="col">{{__('dashboard.user_order')}}</th>
                                </tr>
                                </thead>
                                <tbody>
                                @foreach($most_sold_products as $key=>$row)
                                    <tr>
                                        <th scope="row">{{$row->id}}</th>
                                        <td>{{$row->currentDescription->title}}</td>
                                        <td>{{$row->sold_count ?? '0'}} </td>
                                    </tr>
                                @endforeach
                                </tbody>
                            </table>
                        </div>
                    </div>
                </div>


            </div>

        </div>
    </div>

@endsection

@section('inner_js')



@endsection
