
<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_title">
                                        <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'>{{ __('deals.title') }}</label>
                                            <div class="header-actions" data-field="title">
                                                <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_description">
                                        <div class="header-content" >
                                            <span>{{ __('deals.description') }}</span>
                                            <div class="header-actions" data-field="description">
                                                <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_start_date">
                                        <div class="header-content" >
                                            <span>{{ __('deals.start_date') }}</span>
                                            <div class="header-actions" data-field="start_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_end_date">
                                        <div class="header-content" >
                                            <span>{{ __('deals.end_date') }}</span>
                                            <div class="header-actions" data-field="end_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" >
                                            <span>{{ __('deals.employee_id') }}</span>
                                            <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_product_id">
                                        <div class="header-content" >
                                            <span>{{ __('deals.product_id') }}</span>
                                            <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_contact_list_id">
                                        <div class="header-content" >
                                            <span>{{ __('deals.contact_list_id') }}</span>
                                            <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_company_id">
                                        <div class="header-content" >
                                            <span>{{ __('deals.company_id') }}</span>
                                            <div class="header-actions" data-field="company">
                                                <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_status">
                                        <div class="header-content" >
                                            <span>{{ __('deals.status') }}</span>
                                            <div class="header-actions" data-field="status">
                                                <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_amount">
                                        <div class="header-content" >
                                            <span>{{ __('deals.amount') }}</span>
                                            <div class="header-actions" data-field="amount">
                                                <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_month">
                                        <div class="header-content" >
                                            <span>{{ __('deals.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 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('title','deals') ? 'checked' : '' }} onclick="ToggleItem(this)" data-module="deals" data-column="title" >{{__('deals.title')}}</li>
                                                    <li ><input type="checkbox" class="hidden_column" {{ auth()->user()->disabledColumn('description','deals') ? 'checked' : '' }} onclick="ToggleItem(this)" data-module="deals" data-column="description" >{{__('deals.description')}}</li>
                                                    <li ><input type="checkbox" class="hidden_column" {{ auth()->user()->disabledColumn('start_date','deals') ? 'checked' : '' }} onclick="ToggleItem(this)" data-module="deals" data-column="start_date" >{{__('deals.start_date')}}</li>
                                                    <li ><input type="checkbox" class="hidden_column" {{ auth()->user()->disabledColumn('end_date','deals') ? 'checked' : '' }} onclick="ToggleItem(this)" data-module="deals" data-column="end_date" >{{__('deals.end_date')}}</li>
                                                    <li ><input type="checkbox" class="hidden_column" {{ auth()->user()->disabledColumn('employee_id','deals') ? 'checked' : '' }} onclick="ToggleItem(this)" data-module="deals" data-column="employee_id" >{{__('deals.employee_id')}}</li>
                                                    <li ><input type="checkbox" class="hidden_column" {{ auth()->user()->disabledColumn('product_id','deals') ? 'checked' : '' }} onclick="ToggleItem(this)" data-module="deals" data-column="product_id" >{{__('deals.product_id')}}</li>
                                                    <li ><input type="checkbox" class="hidden_column" {{ auth()->user()->disabledColumn('contact_list_id','deals') ? 'checked' : '' }} onclick="ToggleItem(this)" data-module="deals" data-column="contact_list_id" >{{__('deals.contact_list_id')}}</li>
                                                    <li ><input type="checkbox" class="hidden_column" {{ auth()->user()->disabledColumn('company_id','deals') ? 'checked' : '' }} onclick="ToggleItem(this)" data-module="deals" data-column="company_id" >{{__('deals.company_id')}}</li>
                                                    <li ><input type="checkbox" class="hidden_column" {{ auth()->user()->disabledColumn('status','deals') ? 'checked' : '' }} onclick="ToggleItem(this)" data-module="deals" data-column="status" >{{__('deals.status')}}</li>
                                                    <li ><input type="checkbox" class="hidden_column" {{ auth()->user()->disabledColumn('amount','deals') ? 'checked' : '' }} onclick="ToggleItem(this)" data-module="deals" data-column="amount" >{{__('deals.amount')}}</li>
                                                    <li ><input type="checkbox" class="hidden_column" {{ auth()->user()->disabledColumn('month','deals') ? 'checked' : '' }} onclick="ToggleItem(this)" data-module="deals" data-column="month" >{{__('deals.month')}}</li>
                                                    <li ><input type="checkbox" class="hidden_column" {{ auth()->user()->disabledColumn('created_at','deals') ? 'checked' : '' }} onclick="ToggleItem(this)" data-module="deals" data-column="created_at" >{{ __('dashboard.created_at') }}</li>
                                                </ul>
                                            </div>
                                        </div>
                                    </th>
                                </tr>

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

                                        <input type="text" name="title" value="{{ $request->title ?? '' }}" class="form-control" placeholder="Name">
                                    </td>
                                    <td class="column_description">
                                        <input type="text" name="description" value="{{ $request->description ?? '' }}" class="form-control" placeholder="Name">
                                    </td>
                                    <td class="column_start_date">
                                        <input type="date" name="start_date" value="{{ $request->start_date ?? '' }}" class="form-control" placeholder="Start Date">
                                    </td>
                                    <td class="column_end_date">
                                        <input type="date" name="end_date" value="{{ $request->end_date ?? '' }}" class="form-control" placeholder="End Date">
                                    </td>
                                    <td class="column_employee_id">
                                        <input type="text" name="employee" value="{{ $request->employee ?? '' }}" class="form-control" placeholder="Employee">
                                    </td>
                                    <td class="column_product_id">
                                        <input type="text" name="product" value="{{ $request->product ?? '' }}" class="form-control" placeholder="Product">
                                    </td>
                                    <td class="column_contact_list_id">
                                        <input type="text" name="contact_list" value="{{ $request->contact_list ?? '' }}" class="form-control" placeholder="Contact List">
                                    </td>
                                    <td class="column_company_id">
                                        <input type="text" name="company" value="{{ $request->company ?? '' }}" class="form-control" placeholder="Company">
                                    </td>
                                    <td class="column_status">
                                        <select name="typeStatus" id="" class="form-control form-select">
                                            <option value="">{{__('dashboard.all')}}</option>
                                            @foreach($statuses as $row)
                                                <option {{($request->typeStatus ?? '') == $row ? 'selected' : ''}} value="{{$row}}">{{ __('deals.statuses.'.$row) }}</option>
                                            @endforeach
                                        </select>
                                    </td>
                                    <td class="column_amount">
                                        <input type="text" name="amount" value="{{ $request->amount ?? '' }}" class="form-control" placeholder="Amount">
                                    </td>
                                    <td class="column_month">
                                        <select name="month" id="" class="form-control form-select">
                                            <option value="">{{__('dashboard.all')}}</option>
                                            @foreach($months as $row)
                                                <option {{($request->month ?? '') == $row ? 'selected' : ''}} value="{{$row}}">{{ __('deals.months.'.$row) }}</option>
                                            @endforeach
                                        </select>
                                    </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($deals as $row)
                                    <tr>
                                        <td class="column_title">
                                            <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('deals','show')) style="cursor: pointer" onclick="openModel(this)" action="{{ route ('deals.show', $row->id) }}" @endif>
                                                    <div class="main-inf">
                                                        <h6 class="com-name"> {{$row->title}} </h6>
                                                    </div>
                                                </label>
                                            </div>
                                        </td>
                                        <td class="column_description"> <div class="text"> {{ $row->description }} </td>
                                        <td class="column_start_date"> <div class="text"> {{ $row->start_date }} </td>
                                        <td class="column_end_date"> <div class="text"> {{ $row->end_date }} </td>
                                        <td class="column_employee_id"> <div class="text"> {{ $row->employee->name ?? '' }} </td>
                                        <td class="column_product_id"> <div class="text"> {{ $row->product->currentDescription->title ?? '' }} </td>
                                        <td class="column_contact_list_id"> <div class="text"> {{ $row->contactList->currentDescription->title ?? '' }} </td>
                                        <td class="column_company_id"> <div class="text"> {{ $row->company->currentDescription->title ?? '' }} </td>
                                        <td class="column_status"> <div class="text"> {{ __('deals.statuses.'.$row->status) }} </td>
                                        <td class="column_amount"> <div class="text"> {{ $row->amount }} </td>
                                        <td class="column_month"> <div class="text"> {{ __('deals.months.'.$row->month) }} </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('deals','store'))
                                                        <a href="#0" onclick="openModel(this)" action="{{ route ('deals.create').'?deal_id='.$row->id }}" class="dropdown-item" title="{{ __('deals.createSub') }}"> <i class="bi bi-pen ml-1"></i> {{ __('deals.createSub') }} </a>
                                                    @endif
                                                    @if(auth()->user()->canAccess('deals','update') && $row->lock == 0)
                                                        <a href="#0" onclick="openModel(this)" action="{{ route ('deals.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('deals.lock', $row->id) }}"
                                                           class="dropdown-item"
                                                           title="{{ __('dashboard.unlock') }}">
                                                            <i class="bi bi-unlock-fill"></i>
                                                            {{ __('dashboard.unlock') }}
                                                        </a>
                                                    @else
                                                        <a href="{{ route('deals.lock', $row->id) }}"
                                                           class="dropdown-item"
                                                           title="{{ __('dashboard.lock') }}">
                                                            <i class="bi bi-lock-fill"></i>
                                                            {{ __('dashboard.lock') }}
                                                        </a>
                                                    @endif
                                                    @if(auth()->user()->canAccess('deals','delete'))
                                                        @if($row->deleted_at ?? null)
                                                            <a href="{{ route ('deals.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 ('deals.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( $deals ) && $deals->hasPages() )
                                    <tr> <td> {{ $deals->links() }} </td> </tr>
                                @endif
                                </tbody>
                            </table>
                        </div>
                    </div>
                </div>
            </div>
        </div>
    </div>
</div>

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