<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>
                                        <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'>{{ __('targets.employee') }}</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>
                                        <div class="header-content" >
                                            <span>{{ __('targets.year') }}</span>
                                            <div class="header-actions" data-field="year">
                                                <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-content" >
                                            <span>{{ __('targets.month') }}</span>
                                            <div class="header-actions" data-field="month">
                                                <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-content" >
                                            <span>{{ __('targets.product') }}</span>
                                            <div class="header-actions" data-field="product">
                                                <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-content" >
                                            <span>{{ __('targets.target') }}</span>
                                            <div class="header-actions" data-field="target">
                                                <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">
                                        <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></th>
                                </tr>
                                <tr class="search-tr">
                                    <td>
                                        <input type="hidden" name="orderBy" id="orderBy" value='{{ $request->orderBy ? json_encode($request->orderBy) : '{"key":"id","value":"DESC"}' }}'>

                                        <input type="text" name="employee" value="{{ $request->employee ?? '' }}" class="form-control" placeholder="{{ __('targets.employee') }}">
                                    </td>
                                    <td>
                                        <input type="text" name="year" value="{{ $request->year ?? '' }}" class="form-control" placeholder="{{ __('targets.year') }}">
                                    </td>
                                    <td>
                                        <input type="text" name="month" value="{{ $request->month ?? '' }}" class="form-control" placeholder="{{ __('targets.month') }}">
                                    </td>
                                    <td>
                                        <input type="text" name="product" value="{{ $request->product ?? '' }}" class="form-control" placeholder="{{ __('targets.product') }}">
                                    </td>
                                    <td>
                                        <input type="text" name="target" value="{{ $request->target ?? '' }}" class="form-control" placeholder="{{ __('targets.product') }}">
                                    </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>
                                </thead>
                                <tbody>
                                @foreach($targets 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"  @if(auth()->user()->canAccess('targets','show')) style="cursor: pointer" onclick="openModel(this)" action="{{ route ('targets.show', $row->id) }}" @endif>
                                                    <div class="main-inf">
                                                        <h6 class="com-name"> {{$row->employee->name}} </h6>
                                                    </div>
                                                </label>
                                            </div>
                                        </td>
                                        <td>
                                            {{ $row->year }}
                                        </td>
                                        <td>
                                            {{ __('web.monthes.'.$row->month) }}
                                        </td>
                                        <td>
                                            {{ $row->product->currentDescription->title ?? '' }}
                                        </td>
                                        <td>
                                            {{ $row->target }}
                                        </td>
                                        <td colspan="2"> <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('targets','update') && $row->lock == 0)
                                                        <a href="#0" onclick="openModel(this)" action="{{ route ('targets.edit', $row->id) }}" class="dropdown-item" title="{{ __('dashboard.edit') }}"> <i class="bi bi-pen ml-1"></i> {{ __('dashboard.edit') }} </a>
                                                    @endif
                                                    @if($row->lock)
                                                        <a href="{{ route('targets.lock', $row->id) }}"
                                                           class="dropdown-item"
                                                           title="{{ __('dashboard.unlock') }}">
                                                            <i class="bi bi-unlock-fill"></i>
                                                            {{ __('dashboard.unlock') }}
                                                        </a>
                                                    @else
                                                        <a href="{{ route('targets.lock', $row->id) }}"
                                                           class="dropdown-item"
                                                           title="{{ __('dashboard.lock') }}">
                                                            <i class="bi bi-lock-fill"></i>
                                                            {{ __('dashboard.lock') }}
                                                        </a>
                                                    @endif
                                                    @if(auth()->user()->canAccess('targets','delete'))
                                                            @if($row->deleted_at ?? null)
                                                                <a href="{{ route ('targets.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 ('targets.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( $targets ) && $targets->hasPages() )
                                    <tr> <td> {{ $targets->links() }} </td> </tr>
                                @endif
                                </tbody>
                            </table>
                        </div>
                    </div>
                </div>
            </div>
        </div>
    </div>
</div>

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