
<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">
                                                {{ __('deals.title') }}
                                            </label>
                                        </div>
                                    </th>
                                    <th scope="col"><i class="fal fa-bolt me-1"></i> {{ __('deals.employee_id') }} </th>
                                    <th scope="col"><i class="fal fa-bolt me-1"></i> {{ __('deals.company_id') }} </th>
                                    <th scope="col"><i class="fal fa-bolt me-1"></i> {{ __('deals.status') }} </th>
                                    <th scope="col"><i class="fal fa-bolt me-1"></i> {{ __('deals.amount') }} </th>
                                    <th scope="col"><i class="fal fa-bolt me-1"></i> {{ __('deals.month') }} </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>
                                        <input type="text" name="employee" value="{{ $request->employee ?? '' }}" class="form-control" placeholder="Name">
                                    </td>
                                    <td>
                                        <input type="text" name="company" value="{{ $request->company ?? '' }}" class="form-control" placeholder="Name">
                                    </td>
                                    <td>
                                        <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>
                                        <input type="text" name="amount" value="{{ $request->amount ?? '' }}" class="form-control" placeholder="Name">
                                    </td>
                                    <td>
                                        <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>
                                        <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($deals 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"> {{ $row->employee->name }} </td>
                                        <td> <div class="text"> {{ $row->company->currentDescription->title ?? '' }} </td>
                                        <td> <div class="text"> {{ __('deals.statuses.'.$row->status) }} </td>
                                        <td> <div class="text"> {{ $row->amount }} </td>
                                        <td> <div class="text"> {{ __('deals.months.'.$row->month) }} </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('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'))
                                                        <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(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>
