<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 scope="col">
                                        <div class="form-check">
                                            <input class="form-check-input custom-control-input" type="checkbox" name="example1" id="selectall">
                                            <label class="form-check-label" for="selectall">
                                                {{ __('companies.title') }}
                                            </label>
                                        </div>
                                    </th>
                                    <th scope="col"><i class="fal fa-bolt me-1"></i> {{ __('companies.domain') }} </th>
                                    <th scope="col"><i class="fal fa-bolt me-1"></i> {{ __('companies.sector_id') }} </th>
                                    <th scope="col" colspan="2"><i class="fal fa-user me-1"></i> {{ __('dashboard.created_at') }} </th>
                                    <th></th>
                                </tr>
                                </thead>
                                <tbody>
                                <tr class="search-tr">
                                    <td>
                                        <input type="text" name="title" value="{{ $request->title ?? '' }}" class="form-control" placeholder="Name">
                                    </td>
                                    <td>
                                        <input type="text" name="domain" value="{{ $request->domain ?? '' }}" class="form-control" placeholder="Name">
                                    </td>

                                    <td>
                                        <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>
                                        <input type="text" placeholder="{{ __('dashboard.date_from') }}" name="date_from" value="{{ $request->date_from ?? '' }}" class="date_from form-control">
                                    </td>
                                    <td>
                                        <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>
                                @foreach($companies as $row)
                                    <tr>
                                        <td>
                                            <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" for="customCheck{{$row->id}}">
                                                    <div class="main-inf">
                                                        <h6 class="com-name"> {{$row->title}} </h6>
                                                    </div>
                                                </label>
                                            </div>
                                        </td>
                                        <td> <div class="text"> {{ $row->domain }} </td>
                                        <td> <div class="text"> {{ $row->sector->currentDescription->title }} </td>
                                        <td colspan="2"> <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', '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 ('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'))
                                                        <a href="#0" onclick="openModel(this)" action="{{ route ('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 ('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 ('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>
