<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'>{{ __('companies.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_address">
                                        <div class="header-content" >
                                            <span>{{ __('companies.address') }}</span>
                                            <div class="header-actions" data-field="address">
                                                <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" >
                                            <span>{{ __('companies.description') }}</span>
                                            <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 class="column_domain">
                                        <div class="header-content" >
                                            <span>{{ __('companies.domain') }}</span>
                                            <div class="header-actions" data-field="domain">
                                                <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_sector_id">
                                        <div class="header-content" >
                                            <span>{{ __('companies.sector_id') }}</span>
                                            <div class="header-actions" data-field="sector">
                                                <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_country_id">
                                        <div class="header-content" >
                                            <span>{{ __('companies.country_id') }}</span>
                                            <div class="header-actions" data-field="country">
                                                <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','companies') ? 'checked' : '' }} onclick="ToggleItem(this)" data-module="companies" data-column="title" >{{__('companies.title')}}</li>
                                                    <li ><input type="checkbox" class="hidden_column" {{ auth()->user()->disabledColumn('address','companies') ? 'checked' : '' }} onclick="ToggleItem(this)" data-module="companies" data-column="address" >{{__('companies.address')}}</li>
                                                    <li ><input type="checkbox" class="hidden_column" {{ auth()->user()->disabledColumn('description','companies') ? 'checked' : '' }} onclick="ToggleItem(this)" data-module="companies" data-column="description" >{{__('companies.description')}}</li>
                                                    <li ><input type="checkbox" class="hidden_column" {{ auth()->user()->disabledColumn('domain','companies') ? 'checked' : '' }} onclick="ToggleItem(this)" data-module="companies" data-column="domain" >{{__('companies.domain')}}</li>
                                                    <li ><input type="checkbox" class="hidden_column" {{ auth()->user()->disabledColumn('sector_id','companies') ? 'checked' : '' }} onclick="ToggleItem(this)" data-module="companies" data-column="sector_id" >{{__('companies.sector_id')}}</li>
                                                    <li ><input type="checkbox" class="hidden_column" {{ auth()->user()->disabledColumn('country_id','companies') ? 'checked' : '' }} onclick="ToggleItem(this)" data-module="companies" data-column="country_id" >{{__('companies.country_id')}}</li>
                                                    <li ><input type="checkbox" class="hidden_column" {{ auth()->user()->disabledColumn('created_at','companies') ? 'checked' : '' }} onclick="ToggleItem(this)" data-module="companies" 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_address">
                                        <input type="text" name="address" value="{{ $request->address ?? '' }}" class="form-control" placeholder="Name">
                                    </td>

                                    <td class="column_description">
                                        <input type="text" name="description" value="{{ $request->description ?? '' }}" class="form-control" placeholder="Name">
                                    </td>

                                    <td class="column_domain">
                                        <input type="text" name="domain" value="{{ $request->domain ?? '' }}" class="form-control" placeholder="Name">
                                    </td>

                                    <td class="column_sector_id">
                                        <select name="sector_id" id="" class="form-control form-select">
                                            <option value="">{{__('dashboard.all')}}</option>
                                            @foreach($sectors as $row)
                                                <option {{($request->sector_id ?? '') == $row->id ? 'selected' : ''}} value="{{$row->id}}">{{ $row->title }}</option>
                                            @endforeach
                                        </select>
                                    </td>
                                    <td class="column_country_id">
                                        <select name="country_id" id="" class="form-control form-select">
                                            <option value="">{{__('dashboard.all')}}</option>
                                            @foreach($countries as $row)
                                                <option {{($request->country_id ?? '') == $row->id ? 'selected' : ''}} value="{{$row->id}}">{{ $row->title }}</option>
                                            @endforeach
                                        </select>
                                    </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($companies 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('companies','show')) style="cursor: pointer" onclick="openModel(this)" action="{{ route ('employee.companies.show', $row->id) }}" @endif>
                                                    <div class="main-inf">
                                                        <h6 class="com-name"> {{$row->title}} </h6>
                                                    </div>
                                                </label>
                                            </div>
                                        </td>
                                        <td class="column_address"> <div class="text"> {{ limitString($row->address, 50) }} </td>
                                        <td class="column_description"> <div class="text"> {{ limitString($row->description, 50) }} </td>
                                        <td class="column_domain"> <div class="text"> {{ limitString($row->domain, 50) }} </td>
                                        <td class="column_sector_id"> <div class="text"> {{ $row->sector->currentDescription->title ?? '' }} </td>
                                        <td class="column_country_id"> <div class="text"> {{ $row->country->currentDescription->title ?? '' }} </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 ('employee.contact_lists.index', 'company_id='.$row->id) }}" class="dropdown-item" title="{{ __('contact_lists.head') }}"> <i class="bi bi-pen ml-1"></i> {{ __('contact_lists.head') }} </a>
                                                    @endif
                                                    @if(auth()->user()->canAccess('deals','index'))
                                                        <a href="{{ route ('employee.deals.index', 'company='.$row->title) }}" class="dropdown-item" title="{{ __('deals.head') }}"> <i class="bi bi-pen ml-1"></i> {{ __('deals.head') }} </a>
                                                    @endif
                                                    @if(auth()->user()->canAccess('companies','update') && $row->lock == 0)
                                                        <a href="#0" onclick="openModel(this)" action="{{ route ('employee.companies.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('companies','delete'))
                                                        @if($row->deleted_at ?? null)
                                                            <a href="{{ route ('employee.companies.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.companies.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( $companies ) && $companies->hasPages() )
                                    <tr> <td> {{ $companies->links() }} </td> </tr>
                                @endif
                                </tbody>
                            </table>
                        </div>
                    </div>
                </div>
            </div>
        </div>
    </div>
</div>

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