
<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'>{{ __('sectors.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_description">
                                        <div class="header-content" >
                                          <label class="form-check-label" for='selectall'>{{ __('sectors.description') }}</label>
                                          <div class="header-actions" data-field="description">
                                            <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','sectors') ? 'checked' : '' }} onclick="ToggleItem(this)" data-module="sectors" data-column="title" >{{__('sectors.title')}}</li>
                                                    <li ><input type="checkbox" class="hidden_column" {{ auth()->user()->disabledColumn('description','sectors') ? 'checked' : '' }} onclick="ToggleItem(this)" data-module="sectors" data-column="description" >{{__('sectors.description')}}</li>
                                                    <li ><input type="checkbox" class="hidden_column" {{ auth()->user()->disabledColumn('created_at','sectors') ? 'checked' : '' }} onclick="ToggleItem(this)" data-module="sectors" 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_description">
                                        <input type="text" name="description" value="{{ $request->description ?? '' }}" class="form-control" placeholder="Description">
                                    </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($sectors as $row)
                                    <tr>
                                        <td class="column_title">
                                            <div class="form-check d-flex align-items-center">
                                                @if($row->id != 1)
                                                    <input class="form-check-input custom-control-input selectOne deleteCheck" name="id[]" type="checkbox" value="{{$row->id}}" id="customCheck{{$row->id}}">
                                                @endif
                                                <label class="form-check-label" @if(auth()->user()->canAccess('sectors','show')) style="cursor: pointer" onclick="openModel(this)" action="{{ route ('employee.sectors.show', $row->id) }}" @endif>
                                                    <div class="main-inf">
                                                        <h6 class="com-name"> {{$row->title}} </h6>
                                                    </div>
                                                </label>
                                            </div>
                                        </td>
                                        <td class="column_description"> <div class="text"> {{ $row->description }} </div> </td>

                                        <td colspan="2" class="column_created_at"> <div class="text"> {{ \Carbon\Carbon::parse($row->created_at)->format('Y/m/d') }} </div></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('employees','index'))
                                                        <a href="{{ route ('employee.employees.index', 'sector_id='.$row->id) }}" class="dropdown-item" title="{{ __('employees.head') }}"> <i class="bi bi-pen ml-1"></i> {{ __('employees.head') }} </a>
                                                    @endif
                                                    @if(auth()->user()->canAccess('sectors','update') && $row->lock == 0)
                                                        <a href="#0" onclick="openModel(this)" action="{{ route ('employee.sectors.edit', $row->id) }}" class="dropdown-item" title="{{ __('dashboard.edit') }}"> <i class="bi bi-pen ml-1"></i> {{ __('dashboard.edit') }} </a>
                                                    @endif
                                                    @if(auth()->user()->canAccess('sectors','delete'))
                                                        @if($row->id != 1)
                                                            @if($row->deleted_at ?? null)
                                                                <a href="{{ route ('employee.sectors.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 ('employee.sectors.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
                                                    @endif
                                                </ul>
                                            </div>
                                        </td>
                                    </tr>
                                @endforeach

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


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