<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_contact_list_id">
                                        <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'>{{ __('daily_logs.contact_list_id') }}</label>
                                            <div class="header-actions" data-field="contact_list">
                                                <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_date">
                                        <div class="header-content" >
                                            <label class="form-check-label" for='selectall'>{{ __('daily_logs.date') }}</label>
                                            <div class="header-actions" data-field="date">
                                                <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_employee_id">
                                        <div class="header-content" >
                                            <label class="form-check-label" for='selectall'>{{ __('daily_logs.employee_id') }}</label>
                                            <div class="header-actions" data-field="employee">
                                                <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_objective">
                                        <div class="header-content" >
                                            <label class="form-check-label" for='selectall'>{{ __('daily_logs.objective') }}</label>
                                            <div class="header-actions" data-field="objective">
                                                <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_type">
                                        <div class="header-content" >
                                            <label class="form-check-label" for='selectall'>{{ __('daily_logs.type') }}</label>
                                            <div class="header-actions" data-field="type">
                                                <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_estimated_sale">
                                        <div class="header-content" >
                                            <label class="form-check-label" for='selectall'>{{ __('daily_logs.estimated_sale') }}</label>
                                            <div class="header-actions" data-field="estimated_sale">
                                                <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_next_action">
                                        <div class="header-content" >
                                            <label class="form-check-label" for='selectall'>{{ __('daily_logs.next_action') }}</label>
                                            <div class="header-actions" data-field="next_action">
                                                <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_next_contact">
                                        <div class="header-content" >
                                            <label class="form-check-label" for='selectall'>{{ __('daily_logs.next_contact') }}</label>
                                            <div class="header-actions" data-field="next_contact">
                                                <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('contact_list_id','daily_logs') ? 'checked' : '' }} onclick="ToggleItem(this)" data-module="daily_logs" data-column="contact_list_id" >{{__('daily_logs.contact_list_id')}}</li>
                                                    <li ><input type="checkbox" class="hidden_column" {{ auth()->user()->disabledColumn('date','daily_logs') ? 'checked' : '' }} onclick="ToggleItem(this)" data-module="daily_logs" data-column="date" >{{__('daily_logs.date')}}</li>
                                                    <li ><input type="checkbox" class="hidden_column" {{ auth()->user()->disabledColumn('employee_id','daily_logs') ? 'checked' : '' }} onclick="ToggleItem(this)" data-module="daily_logs" data-column="employee_id" >{{__('daily_logs.employee_id')}}</li>
                                                    <li ><input type="checkbox" class="hidden_column" {{ auth()->user()->disabledColumn('objective','daily_logs') ? 'checked' : '' }} onclick="ToggleItem(this)" data-module="daily_logs" data-column="objective" >{{__('daily_logs.objective')}}</li>
                                                    <li ><input type="checkbox" class="hidden_column" {{ auth()->user()->disabledColumn('type','daily_logs') ? 'checked' : '' }} onclick="ToggleItem(this)" data-module="daily_logs" data-column="type" >{{__('daily_logs.type')}}</li>
                                                    <li ><input type="checkbox" class="hidden_column" {{ auth()->user()->disabledColumn('estimated_sale','daily_logs') ? 'checked' : '' }} onclick="ToggleItem(this)" data-module="daily_logs" data-column="estimated_sale" >{{__('daily_logs.estimated_sale')}}</li>
                                                    <li ><input type="checkbox" class="hidden_column" {{ auth()->user()->disabledColumn('next_action','daily_logs') ? 'checked' : '' }} onclick="ToggleItem(this)" data-module="daily_logs" data-column="next_action" >{{__('daily_logs.next_action')}}</li>
                                                    <li ><input type="checkbox" class="hidden_column" {{ auth()->user()->disabledColumn('next_contact','daily_logs') ? 'checked' : '' }} onclick="ToggleItem(this)" data-module="daily_logs" data-column="next_contact" >{{__('daily_logs.next_contact')}}</li>
                                                    <li ><input type="checkbox" class="hidden_column" {{ auth()->user()->disabledColumn('created_at','daily_logs') ? 'checked' : '' }} onclick="ToggleItem(this)" data-module="daily_logs" data-column="created_at" >{{ __('dashboard.created_at') }}</li>
                                                </ul>
                                            </div>
                                        </div>
                                    </th>
                                </tr>

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

                                        <input type="text" name="contact_list" value="{{ $request->contact_list ?? '' }}" class="form-control" placeholder="Name">
                                    </td>
                                    <td class="column_date">
                                        <input type="date" name="date" value="{{ $request->date ?? '' }}" class="form-control" placeholder="Name">
                                    </td>
                                    <td class="column_employee_id">
                                        <input type="text" name="employee" value="{{ $request->employee ?? '' }}" class="form-control" placeholder="Name">
                                    </td>
                                    <td class="column_objective">
                                        <select name="objective" class="form-control">
                                            <option value="">{{ __('dashboard.all') }}</option>
                                            @foreach($objectives as $row)
                                                <option {{ ($request->objective ?? '') == $row ? 'selected' : '' }} value="{{ $row }}"> {{ __('daily_logs.objectives.'.$row) }} </option>
                                            @endforeach
                                        </select>
                                    </td>
                                    <td class="column_type">
                                        <select name="type" class="form-control">
                                            <option value="">{{ __('dashboard.all') }}</option>
                                            @foreach($types as $row)
                                                <option {{ ($request->type ?? '') == $row ? 'selected' : '' }} value="{{ $row }}"> {{ __('daily_logs.types.'.$row) }} </option>
                                            @endforeach
                                        </select>
                                    </td>
                                    <td class="column_estimated_sale">
                                        <input type="text" name="estimated_sale" value="{{ $request->estimated_sale ?? '' }}" class="form-control" placeholder="Estimated Sale">
                                    </td>
                                    <td class="column_next_action">
                                        <select name="next_action" class="form-control">
                                            <option value="">{{ __('dashboard.all') }}</option>
                                            @foreach($actions as $row)
                                                <option {{ ($request->next_action ?? '') == $row ? 'selected' : '' }} value="{{ $row }}"> {{ __('daily_logs.next_actions.'.$row) }} </option>
                                            @endforeach
                                        </select>
                                    </td>
                                    <td class="column_next_contact">
                                        <input type="date" name="next_contact" value="{{ $request->next_contact ?? '' }}" class="form-control" placeholder="Next Contact">
                                    </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($daily_logs as $row)
                                    <tr>
                                        <td  class="column_contact_list_id">
                                            <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('daily_logs','show')) style="cursor: pointer" onclick="openModel(this)" action="{{ route ('employee.daily_logs.show', $row->id) }}" @endif>
                                                    <div class="main-inf">
                                                        <h6 class="com-name"> {{$row->contactList->currentDescription->title ?? ''}} </h6>
                                                    </div>
                                                </label>
                                            </div>
                                        </td>
                                        <td class="column_date"> <div class="text"> {{ $row->date }} </td>
                                        <td class="column_employee_id"> <div class="text"> {{ $row->employee->name ?? '' }} </td>
                                        <td class="column_objective"> <div class="text"> {{ __('daily_logs.objectives.'.$row->objective) }} </td>
                                        <td class="column_type"> <div class="text"> {{ __('daily_logs.types.'.$row->type) }} </td>
                                        <td class="column_estimated_sale">{{ $row->estimated_sale }}</td>
                                        <td class="column_next_action"> <div class="text"> {{ __('daily_logs.next_actions.'.$row->next_action) }} </td>
                                        <td class="column_next_contact"> <div class="text"> {{ $row->next_contact }} </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', [
                                                                    'budget_start' => $row->start_price,
                                                                    'budget_end'   => $row->end_price
                                                                    ])
                                                                }}"
                                                           class="dropdown-item" title="{{ __('contact_lists.head') }}"> <i class="bi bi-pen ml-1"></i> {{ __('contact_lists.head') }} </a>
                                                    @endif

                                                    @if(auth()->user()->canAccess('daily_logs','update') && $row->lock == 0)
                                                        <a href="#0" onclick="openModel(this)" action="{{ route ('employee.daily_logs.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('daily_logs','delete'))
                                                        @if($row->deleted_at ?? null)
                                                            <a href="{{ route ('employee.daily_logs.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.daily_logs.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( $daily_logs ) && $daily_logs->hasPages() )
                                    <tr> <td> {{ $daily_logs->links() }} </td> </tr>
                                @endif
                                </tbody>
                            </table>
                        </div>
                    </div>
                </div>
            </div>
        </div>
    </div>
</div>

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