<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_employee_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'>{{ __('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 class="column_year">
                                        <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 class="column_product_id">
                                        <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 class="column_target">
                                        <div class="header-content" >
                                            <span>{{ __('targets.target') }}</span>
                                            <div class="header-actions" data-field="total_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>
                                        <div class="header">
                                            <button class="dots-btn">⋮</button>
                                            <div class="dropdown-columns">
                                                <ul>
                                                    <li ><input type="checkbox" class="hidden_column" {{ auth()->user()->disabledColumn('employee_id','targets') ? 'checked' : '' }} onclick="ToggleItem(this)" data-module="targets" data-column="employee_id" >{{__('targets.employee_id')}}</li>
                                                    <li ><input type="checkbox" class="hidden_column" {{ auth()->user()->disabledColumn('year','targets') ? 'checked' : '' }} onclick="ToggleItem(this)" data-module="targets" data-column="year" >{{__('targets.year')}}</li>
                                                    <li ><input type="checkbox" class="hidden_column" {{ auth()->user()->disabledColumn('product_id','targets') ? 'checked' : '' }} onclick="ToggleItem(this)" data-module="targets" data-column="product_id" >{{__('targets.product_id')}}</li>
                                                    <li ><input type="checkbox" class="hidden_column" {{ auth()->user()->disabledColumn('target','targets') ? 'checked' : '' }} onclick="ToggleItem(this)" data-module="targets" data-column="target" >{{ __('targets.target') }}</li>
                                                </ul>
                                            </div>
                                        </div>
                                    </th>
                                </tr>
                                <tr class="search-tr">
                                    <td class="column_employee_id">
                                        <input type="hidden" name="orderBy" id="orderBy" value='{{ $request->orderBy ? json_encode($request->orderBy) : '{"key":"year","value":"DESC"}' }}'>

                                        <input type="text" name="employee" value="{{ $request->employee ?? '' }}" class="form-control" placeholder="{{ __('targets.employee') }}">
                                    </td>
                                    <td class="column_year">
                                        <input type="text" name="year" value="{{ $request->year ?? '' }}" class="form-control" placeholder="{{ __('targets.year') }}">
                                    </td>
                                    <td class="column_product_id">
                                        <input type="text" name="product" value="{{ $request->product ?? '' }}" class="form-control" placeholder="{{ __('targets.product') }}">
                                    </td>
                                    <td class="column_target">
                                        <input type="text" name="total_target" value="{{ $request->total_target ?? '' }}" class="form-control" placeholder="{{ __('targets.target') }}">
                                    </td>

                                    <td>
                                        <button class="search-btn search"> <i class="fal fa-search"></i> </button>
                                    </td>
                                </tr>
                                </thead>
                                <tbody>
                                @foreach($targets as $row)
                                    <tr>
                                        <td class="column_employee_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" >
                                                    <div class="main-inf">
                                                        <a @if(auth()->user()->canAccess('targets','showTarget') ) href="#0" onclick="openModel(this)" action="{{ route ('employee.targets.showTarget',[
                                                            'year'=>$row->year,
                                                            'product_id'=>$row->product_id,
                                                            'employee_id'=>$row->employee_id
                                                        ]) }}" @endif>
                                                            <h6 class="com-name"> {{$row->employee->name}} </h6>
                                                        </a>
                                                    </div>
                                                </label>
                                            </div>
                                        </td>
                                        <td class="column_year">
                                            {{ $row->year }}
                                        </td>
                                        <td class="column_product_id">
                                            {{ $row->product->currentDescription->title ?? '' }}
                                        </td>
                                        <td class="column_target">
                                            {{ $row->total_target }}
                                        </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','showTarget') )
                                                        <a href="#0" onclick="openModel(this)" action="{{ route ('employee.targets.showTarget',[
                                                            'year'=>$row->year,
                                                            'product_id'=>$row->product_id,
                                                            'employee_id'=>$row->employee_id
                                                        ]) }}" class="dropdown-item" title="{{ __('dashboard.show') }}"> <i class="bi bi-eye ml-1"></i> {{ __('dashboard.show') }} </a>
                                                    @endif

                                                    @if(auth()->user()->canAccess('targets','editTarget') && $row->lock == 0)
                                                        <a href="#0" onclick="openModel(this)" action="{{ route ('employee.targets.editTarget',[
                                                            'year'=>$row->year,
                                                            'product_id'=>$row->product_id,
                                                            'employee_id'=>$row->employee_id
                                                        ]) }}" class="dropdown-item" title="{{ __('dashboard.edit') }}"> <i class="bi bi-pen ml-1"></i> {{ __('dashboard.edit') }} </a>
                                                    @endif

                                                </ul>
                                            </div>
                                        </td>
                                    </tr>
                                @endforeach

                                </tbody>
                            </table>
                        </div>
                    </div>
                </div>
            </div>
        </div>
    </div>
</div>

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