<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">
                                                {{ __('contact_lists.title') }}
                                            </label>
                                        </div>
                                    </th>
                                    <th scope="col"><i class="fal fa-bolt me-1"></i> {{ __('contact_lists.is_top_customer') }} </th>
                                    <th scope="col"><i class="fal fa-bolt me-1"></i> {{ __('contact_lists.status') }} </th>
                                    <th scope="col"><i class="fal fa-bolt me-1"></i> {{ __('contact_lists.company_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>
                                        <select name="is_top_customer" id="" class="form-control form-select">
                                            <option value="">{{__('dashboard.all')}}</option>
                                            <option {{($request->is_top_customer ?? '') == 0 ? 'selected' : ''}} value="0">{{ __('contact_lists.no') }}</option>
                                            <option {{($request->is_top_customer ?? '') == 1 ? 'selected' : ''}} value="1">{{ __('contact_lists.yes') }}</option>
                                        </select>
                                    </td>

                                    <td>
                                        <select name="type" id="" class="form-control form-select">
                                            <option value="">{{__('dashboard.all')}}</option>
                                            @foreach($statuses as $row)
                                                <option {{($request->type ?? '') == $row ? 'selected' : ''}} value="{{$row}}">{{ __('contact_lists.statuses.'.$row) }}</option>
                                            @endforeach
                                        </select>
                                    </td>
                                    <td>
                                        <select name="company_id" id="" class="form-control form-select">
                                            <option value="">{{__('dashboard.all')}}</option>
                                            @foreach($companies as $row)
                                                <option {{($request->company_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($contact_lists 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"> <i class="{{ $row->is_top_customer ? 'fas fa-star' : 'fal fa-star' }}"></i> </td>
                                        <td> <div class="text"> {{ __('contact_lists.statuses.'.$row->status) }} </td>
                                        <td> <div class="text"> {{ $row->company->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('daily_logs','index'))
                                                        <a href="{{ route('daily_logs.index', [
                                                                    'contact_list' => $row->title,
                                                                    ])
                                                                }}"
                                                           class="dropdown-item" title="{{ __('daily_logs.head') }}"> <i class="bi bi-pen ml-1"></i> {{ __('daily_logs.head') }} </a>
                                                    @endif
                                                    @if(auth()->user()->canAccess('contact_lists','update'))
                                                        <a href="#0" onclick="openModel(this)" action="{{ route ('contact_lists.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('contact_lists','delete'))
                                                        @if($row->deleted_at ?? null)
                                                            <a href="{{ route ('contact_lists.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 ('contact_lists.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( $contact_lists ) && $contact_lists->hasPages() )
                                    <tr> <td> {{ $contact_lists->links() }} </td> </tr>
                                @endif
                                </tbody>
                            </table>
                        </div>
                    </div>
                </div>
            </div>
        </div>
    </div>
</div>

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