<div class="body-content">
    <div class="contacts">
        <div class="contacts-box">
            <div class="contacts-body">
                <div class="contacts-box">
                    <div class="contact-row p-0 border-0">
                        <div class="table-responsive">
                            <table class="table">
                                <thead>

                                <tr>
                                    <th class="column_title">
                                        <div class="header-content" >
                                            <input class="form-check-input custom-control-input" type="checkbox" name="example1" style="border-radius:15px" id="selectall">
                                            <label class="form-check-label" for='selectall'>{{ __('categories.title') }}</label>
                                            <div class="header-actions" data-field="title">
                                                <button class="arrow-btn" title="{{ __('dashboard.sort_desc') }}">▾</button>
                                                <button class="dots-btn">⋮</button>
                                                <div class="dropdown-filter">
                                                    <ul>
                                                        <li data-order="ASC">{{ __('dashboard.sort_asc') }}</li>
                                                        <li data-order="DESC">{{ __('dashboard.sort_desc') }}</li>
                                                        <li data-order="reset">{{ __('dashboard.reset') }}</li>
                                                    </ul>
                                                </div>
                                            </div>
                                        </div>
                                    </th>
                                    <th class="column_start_price">
                                        <div class="header-content" >
                                            <label class="form-check-label" for='selectall'>{{ __('categories.start_price') }}</label>
                                            <div class="header-actions" data-field="start_price">
                                                <button class="arrow-btn" title="{{ __('dashboard.sort_desc') }}">▾</button>
                                                <button class="dots-btn">⋮</button>
                                                <div class="dropdown-filter">
                                                    <ul>
                                                        <li data-order="ASC">{{ __('dashboard.sort_asc') }}</li>
                                                        <li data-order="DESC">{{ __('dashboard.sort_desc') }}</li>
                                                        <li data-order="reset">{{ __('dashboard.reset') }}</li>
                                                    </ul>
                                                </div>
                                            </div>
                                        </div>
                                    </th>
                                    <th class="column_end_price">
                                        <div class="header-content" >
                                            <label class="form-check-label" for='selectall'>{{ __('categories.end_price') }}</label>
                                            <div class="header-actions" data-field="end_price">
                                                <button class="arrow-btn" title="{{ __('dashboard.sort_desc') }}">▾</button>
                                                <button class="dots-btn">⋮</button>
                                                <div class="dropdown-filter">
                                                    <ul>
                                                        <li data-order="ASC">{{ __('dashboard.sort_asc') }}</li>
                                                        <li data-order="DESC">{{ __('dashboard.sort_desc') }}</li>
                                                        <li data-order="reset">{{ __('dashboard.reset') }}</li>
                                                    </ul>
                                                </div>
                                            </div>
                                        </div>
                                    </th>
                                    <th colspan="2" class="column_created_at">
                                        <div class="header-content" >
                                            <span>{{ __('dashboard.created_at') }}</span>
                                            <div class="header-actions" data-field="created_at">
                                                <button class="arrow-btn" title="{{ __('dashboard.sort_desc') }}">▾</button>
                                                <button class="dots-btn">⋮</button>
                                                <div class="dropdown-filter">
                                                    <ul>
                                                        <li data-order="ASC">{{ __('dashboard.sort_asc') }}</li>
                                                        <li data-order="DESC">{{ __('dashboard.sort_desc') }}</li>
                                                        <li data-order="reset">{{ __('dashboard.reset') }}</li>
                                                    </ul>
                                                </div>
                                            </div>
                                        </div>
                                    </th>
                                    <th>
                                        <div class="header">
                                            <button class="dots-btn">⋮</button>
                                            <div class="dropdown-columns">
                                                <ul>
                                                    <li ><input type="checkbox" class="hidden_column" {{ auth()->user()->disabledColumn('title','categories') ? 'checked' : '' }} onclick="ToggleItem(this)" data-module="categories" data-column="title" >{{__('categories.title')}}</li>
                                                    <li ><input type="checkbox" class="hidden_column" {{ auth()->user()->disabledColumn('start_price','categories') ? 'checked' : '' }} onclick="ToggleItem(this)" data-module="categories" data-column="start_price" >{{__('categories.start_price')}}</li>
                                                    <li ><input type="checkbox" class="hidden_column" {{ auth()->user()->disabledColumn('end_price','categories') ? 'checked' : '' }} onclick="ToggleItem(this)" data-module="categories" data-column="end_price" >{{__('categories.end_price')}}</li>
                                                    <li ><input type="checkbox" class="hidden_column" {{ auth()->user()->disabledColumn('created_at','categories') ? 'checked' : '' }} onclick="ToggleItem(this)" data-module="categories" data-column="created_at" >{{ __('dashboard.created_at') }}</li>
                                                </ul>
                                            </div>
                                        </div>
                                    </th>
                                </tr>

                                <tr class="search-tr">
                                    <td class="column_title">
                                        <input type="hidden" name="orderBy" id="orderBy" value='{{ $request->orderBy ? json_encode($request->orderBy) : '{"key":"id","value":"DESC"}' }}'>

                                        <input type="text" name="title" value="{{ $request->title ?? '' }}" class="form-control" placeholder="Name">
                                    </td>
                                    <td class="column_start_price">
                                        <input type="text" name="start_price" value="{{ $request->start_price ?? '' }}" class="form-control" placeholder="Start Price">
                                    </td>
                                    <td class="column_end_price">
                                        <input type="text" name="end_price" value="{{ $request->end_price ?? '' }}" class="form-control" placeholder="End Price">
                                    </td>
                                    <td class="column_created_at">
                                        <input type="text" placeholder="{{ __('dashboard.date_from') }}" name="date_from" value="{{ $request->date_from ?? '' }}" class="date_from form-control">
                                    </td>
                                    <td class="column_created_at">
                                        <input type="text" placeholder="{{ __('dashboard.date_to') }}" name="date_to" value="{{ $request->date_to ?? '' }}" class="date_to form-control">
                                    </td>
                                    <td>
                                        <button class="search-btn search"> <i class="fal fa-search"></i> </button>
                                    </td>
                                </tr>
                                </thead>
                                <tbody>
                                @foreach($categories as $row)
                                    <tr>
                                        <td class="column_title">
                                            <div class="form-check d-flex align-items-center">
                                                <input class="form-check-input custom-control-input selectOne deleteCheck" name="id[]" type="checkbox" value="{{$row->id}}" id="customCheck{{$row->id}}">
                                                <label class="form-check-label" @if(auth()->user()->canAccess('categories','show')) style="cursor: pointer" onclick="openModel(this)" action="{{ route ('categories.show', $row->id) }}" @endif>
                                                    <div class="main-inf">
                                                        <h6 class="com-name"> {{$row->title}} </h6>
                                                    </div>
                                                </label>
                                            </div>
                                        </td>
                                        <td class="column_start_price"> {{ $row->start_price }} </td>
                                        <td class="column_end_price"> {{ $row->end_price }} </td>
                                        <td colspan="2" class="column_created_at"> <div class="text"> {{ \Carbon\Carbon::parse($row->created_at)->format('Y/m/d') }} </td>
                                        <td>
                                            <div class="dropdown">
                                                <button class="btn bg-transparent border-0 p-0 dropdown-toggle" type="button" data-bs-toggle="dropdown" aria-expanded="false">
                                                    <i class="fas fa-ellipsis"></i>
                                                </button>
                                                <ul class="dropdown-menu">
                                                    @if(auth()->user()->canAccess('contact_lists','index'))
                                                        <a href="{{ route('contact_lists.index', [
                                                                    'budget_start' => $row->start_price,
                                                                    'budget_end'   => $row->end_price
                                                                    ])
                                                                }}"
                                                           class="dropdown-item" title="{{ __('contact_lists.head') }}">  {{ __('contact_lists.head') }} </a>
                                                    @endif

                                                    @if(auth()->user()->canAccess('categories','update') && $row->lock == 0)
                                                        <a href="#0" onclick="openModel(this)" action="{{ route ('categories.edit', $row->id) }}" class="dropdown-item" title="{{ __('dashboard.edit') }}"> <i class="bi bi-pen ml-1"></i> {{ __('dashboard.edit') }} </a>
                                                    @endif
                                                    @if($row->lock)
                                                        <a href="{{ route('categories.lock', $row->id) }}"
                                                           class="dropdown-item"
                                                           title="{{ __('dashboard.unlock') }}">
                                                            <i class="bi bi-unlock-fill"></i>
                                                            {{ __('dashboard.unlock') }}
                                                        </a>
                                                    @else
                                                        <a href="{{ route('categories.lock', $row->id) }}"
                                                           class="dropdown-item"
                                                           title="{{ __('dashboard.lock') }}">
                                                            <i class="bi bi-lock-fill"></i>
                                                            {{ __('dashboard.lock') }}
                                                        </a>
                                                    @endif
                                                    @if(auth()->user()->canAccess('categories','delete'))
                                                            @if($row->deleted_at ?? null)
                                                                <a href="{{ route ('categories.restore', $row->id) }}" data-method="put" class="dropdown-item rowAction" title="{{ __('dashboard.restore') }}"> <i class="bi bi-pen ml-1"></i> {{ __('dashboard.restore') }} </a>
                                                            @else
                                                                <a href="{{ route ('categories.destroy', $row->id) }}" data-method="delete" class="dropdown-item rowAction" title="{{ __('dashboard.trash') }}"> <i class="bi bi-slash-circle ml-1"></i> {{ __('dashboard.trash') }} </a>
                                                            @endif
                                                    @endif
                                                </ul>
                                            </div>
                                        </td>
                                </tr>
                                @endforeach

                                @if( count( $categories ) && $categories->hasPages() )
                                    <tr> <td> {{ $categories->links() }} </td> </tr>
                                @endif
                                </tbody>
                            </table>
                        </div>
                    </div>
                </div>
            </div>
        </div>
    </div>
</div>

<script src="{{url('')}}/assets/admin/js/related.js"></script>
