@extends('admin.layouts.container')

@section('content')
    <form>
        <div class="side-title">
            <div class="row">
                <div class="col-lg-6">
                    <h3>{{ $title }}</h3>
                </div>
                <div class="col-lg-6 valign">

                    <div class="edit-buttons text-right w-100">
                        <a href="{{ route ('units.destroyAll') }}" data-method="delete" class="butn statusButns status_1 tableAction btn disabled butn_blue ms-auto"><div class="cont"><span>{{ __('dashboard.sendToTrash') }}</span></div><img src="{{ asset('assets/admin/images/butn_shap.png') }} " alt="" class="shape"></a>
                        <a href="#" class="butn statusButns status_1 showArchive butn_blue ms-auto"><div class="cont"><span> {{ __('dashboard.displayTrash') }} </span></div><img src="{{ asset('assets/admin/images/butn_shap.png') }} " alt="" class="shape"></a>

                        {{-- <a href="{{ route ('units.destroyAll') }}" data-method="delete" class="butn statusButns status_0 tableAction btn disabled force butn_blue ms-auto"><div class="cont"><span> {{ __('dashboard.delete') }} </span></div><img src="{{ asset('assets/admin/images/butn_shap.png') }} " alt="" class="shape"></a> --}}
                        <a href="{{ route ('units.restoreAll') }}" data-method="put" class="butn statusButns status_0 tableAction btn disabled butn_blue ms-auto"><div class="cont"><span> {{ __('dashboard.restore') }} </span></div><img src="{{ asset('assets/admin/images/butn_shap.png') }} " alt="" class="shape"></a>
                        <a href="#" class="butn statusButns status_0 showActive butn_blue ms-auto"><div class="cont"><span> {{ __('dashboard.displayActive') }} </span></div><img src="{{ asset('assets/admin/images/butn_shap.png') }} " alt="" class="shape"></a>
                    </div>
                </div>
            </div>
        </div>

        <!-- ------------ data table ------------- -->
        <table class="table table-hover table-bordered">
            <thead>
            <tr>
                <th scope="col">
                    <div class="custom-control custom-checkbox">
                        <input type="checkbox" class="custom-control-input" id="selectall" name="example1">
                        <label class="custom-control-label" for="selectall"> </label>
                    </div>
                </th>
                <th scope="col">{{ __('units.user_id') }}</th>
                <th scope="col">{{ __('units.city_id') }}</th>
                <th scope="col">{{ __('units.area_id') }}</th>
                <th scope="col">{{ __('units.price') }}</th>
                <th scope="col">{{ __('units.type_id') }}</th>
                <th scope="col">{{ __('units.baths') }}</th>
                <th scope="col">{{ __('units.title') }}</th>
                <th scope="col">{{ __('units.status') }}</th>
                <th scope="col">{{ __('units.sold_status') }}</th>
                <th scope="col">{{ __('dashboard.created_at') }}</th>
                <th scope="col">{{ __('dashboard.processes') }}</th>
            </tr>
            </thead>

            <tbody class="response">
                <tr class="search_filter_form">
                    <th scope="row">
                        <!-- <input type="checkbox" class="checkAll" /> -->
                    </th>
                    <th scope="row">
                        <select name="user_code" id="user_code" class="form-control" >
                            <option value="">{{__('dashboard.all')}}</option>
                            @foreach($users as $row)
                                <option value="{{$row->code}}" {{ $request->provider_id == $row->code ? 'selected' : ''}}>{{$row->name}}</option>
                            @endforeach
                        </select>
                    </th>
                    <th scope="row">
                        <select name="city_id" id="city_id" class="form-control" >
                            <option value="">{{__('dashboard.all')}}</option>
                            @foreach($cities as $row)
                                <option value="{{$row->id}}">{{$row->title}}</option>
                            @endforeach
                        </select>
                    </th>
                    <th scope="row">
                        <select name="area_id" id="area_id" class="form-control" >
                            <option value="">{{__('dashboard.all')}}</option>
                        </select>
                    </th>
                    <th scope="row">
                        <input type="text" name="price" value="{{ $request->price ?? '' }}" class="form-control" placeholder="">
                    </th>
                    <th scope="row">
                        <select name="type_id" id="type_id" class="form-control" >
                            <option value="">{{__('dashboard.all')}}</option>
                            @foreach($types as $row)
                                <option value="{{$row->id}}">{{$row->title}}</option>
                            @endforeach
                        </select>
                    </th>
                    <th scope="row">
                        <input type="text" name="baths" value="{{ $request->baths ?? '' }}" class="form-control" placeholder="">
                    </th>
                    <th scope="row">
                        <input type="text" name="title" value="{{ $request->title ?? '' }}" class="form-control" placeholder="">
                    </th>
                    <th scope="row">
                        <select name="unit_status" id="unit_status" class="form-control">
                            <option value="">{{ __('dashboard.all') }}</option>
                            @foreach (config('globals.unit_statuses') as $status)
                                <option value="{{ $status }}" {{ ($request->unit_status ?? '') == $status ? 'selected' : '' }}>{{ __('units.statuses.'.$status) }}</option>
                            @endforeach
                        </select>
                    </th>
                    <th scope="row">
                        <select name="sold_status" id="sold_status" class="form-control">
                            <option value="">{{ __('dashboard.all') }}</option>
                            @foreach (config('globals.sold_statuses') as $status)
                                <option value="{{ $status }}" {{ ($request->sold_status ?? '') == $status ? 'selected' : '' }}>{{ __('units.sold_statuses.'.$status) }}</option>
                            @endforeach
                        </select>
                    </th>
                    <td>
                        <input type="text" placeholder="{{ __('dashboard.date_from') }}" name="date_from" value="{{ $request->date_from ?? '' }}" class="date_from form-control">
                        <input type="text" placeholder="{{ __('dashboard.date_to') }}" name="date_to" value="{{ $request->date_to ?? '' }}" class="date_to form-control">
                    </td>
                    <th scope="col">
                        <button type="button" class="butn butn_blue search">
                            <div class="cont">
                                <span> {{__('dashboard.select')}}  </span>
                            </div>
                            <img src="{{ asset('assets/admin/images/butn_shap.png') }} " alt="" class="shape">
                        </button>
                        <!--<button type="button" class="butn color small search"><span><i class="fas fa-search"></i></span></button>-->
                    </th>
                </tr>
            </tbody>


        </table>
        <!-- ------------ sidemenu links ------------- -->
    </form>
@endsection



<script>
    /**
     * Importat to handle ajax requests for filters, deletes, trash and any proccess done on the table's data
     */
    var dataTable={
        route: '{{ route("units.grid") }}'
    }
</script>
@section('inner_js')
    <script>
        const area_route = '{{ route("dashboard.areas") }}';
        const area_id = '{{ old("area_id", $unit->area_id ?? '') }}';
    </script>
    <script src="{{ asset('assets/admin/js/custom/admin/units.js') }}"></script>
@endsection
