<div class="body-content">
    <div class="tasks Kanban-view">

        <div class="row gx-3 horizontal-scroll">
            @foreach($months as $month)
                <div class="col-lg-3">
                    <div class="tasks-box">
                        <div class="task-head">
                            <div class="l-side">
                                <div class="form-check mb-0">
                                    <label class="form-check-label d-block" for="task{{$month}}">
                                        {{__('deals.months.'.$month)}} <span class="num"> {{ count(( $monthDeals[$month] ?? [])) }} </span>
                                    </label>
                                </div>
                            </div>
                            <div class="btns d-flex justify-content-lg-end mt-4 mt-lg-0 align-items-center">
                                @if(auth()->user()->canAccess('deals','store'))
                                    <a href="#0" onclick="openModel(this)" action="{{ route ('deals.create').'?month='.$month }}" class="add-btn"> <i class="fal fa-plus"></i> </a>
                                @endif

                            </div>
                        </div>
                        <div class="task-body drag-column">
                            @foreach(($monthDeals[$month] ?? []) as $deal)
                                <div class="item drag-item">
                                    <div class="form-check mb-0">
                                        <input class="form-check-input rounded-pill" type="checkbox" value="" id="task-{{$deal->id}}">
                                        <label class="form-check-label" for="task-{{$deal->id}}">
                                            {{ $deal->title }}
                                        </label>
                                    </div>
                                    <div class="item-side">
                                        <div class="avatars-imgs">
                                            <a href="#" class="user-img w-auto rounded-0"> <img src="{{ asset($deal->company->image) }}" alt="" style="object-fit: contain !important;" class="rounded-0"> </a>
                                        </div>
                                    </div>
                                    <ul class="card-list small py-3 lh-lg">
                                        <li> <i class="fal fa-building me-2"></i> {{ $deal->company->currentDescription->title}} </li>
                                        <li> <i class="fal fa-user-tie me-2"></i> {{ $deal->employee->name }} </li>
                                        <li> <i class="fal fa-badge-dollar me-2"></i> {{$deal->amount}} AED </li>
                                    </ul>
                                    <div class="btm-inf d-block">
                                        <div class="icons">
                                            <span class="date small mt-2"> <i class="fal fa-calendar me-1"></i> {{$deal->start_date}} </span>
                                        </div>
                                        <span class="date small mt-2"> <i class="fal fa-calendar me-1"></i> {{$deal->end_date}} </span>
                                    </div>
                                    <div class="dropdown ms-3 card-dots">
                                        <button class="btn bg-transparent border-0 p-0 dropdown-toggle after-none" type="button" data-bs-toggle="dropdown" aria-expanded="true">
                                            <i class="fas fa-ellipsis-vertical"></i>
                                        </button>
                                        <ul class="dropdown-menu" data-popper-placement="bottom-end" style="position: absolute; inset: 0px 0px auto auto; margin: 0px; transform: translate3d(0px, 26.4px, 0px);">
                                            @if(auth()->user()->canAccess('deals','update') && $deal->lock == 0)
                                                <li><a class="dropdown-item" href="#0" onclick="openModel(this)" action="{{ route ('deals.edit', $deal->id) }}"> <i class="fal fa-pen me-1"></i> {{ __('dashboard.update') }}</a></li>
                                            @endif
                                            @if($deal->lock)
                                                <a href="{{ route('deals.lock', $deal->id) }}"
                                                   class="dropdown-item"
                                                   title="{{ __('dashboard.unlock') }}">
                                                    <i class="bi bi-unlock-fill"></i>
                                                    {{ __('dashboard.unlock') }}
                                                </a>
                                            @else
                                                <a href="{{ route('deals.lock', $deal->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($deal->deleted_at ?? null)
                                                    <a href="{{ route ('deals.restore', $deal->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', $deal->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>
                                </div>
                            @endforeach
                        </div>
                    </div>
                </div>
            @endforeach
        </div>

    </div>
</div>

