@extends('admin.layouts.container')

@section('content')


<div class="search_filter_form">
    <input type="hidden" name="company_id" value="{{$request->company_id ?? null}}">
    <div class="body-title mt-4 ">
        <div class="row">
            <div class="col-lg-6">
                <div class="nav-butns d-flex">
                    <div class="dropdown">
                        <button class="butn-st2 line-butn py-2 px-3 dropdown-toggle" type="button" data-bs-toggle="dropdown" aria-expanded="false">
                            <i class="fal fa-diagram-cells me-2"></i> {{__('dashboard.viewTypes.'. $typeView ) }}
                        </button>
                        <input type="hidden" name="typeView" value="{{$typeView}}">
                        <ul class="dropdown-menu">
                            @if($typeView != $kanbanView)
                                <li><a class="dropdown-item" href="{{route('contact_lists.index').'?typeView='.$kanbanView}}"><i class="fal fa-grid-2 me-2"></i> {{__('dashboard.viewTypes.kanban')}}</a></li>
                            @else
                                <li><a class="dropdown-item" href="{{route('contact_lists.index')}}"><i class="fal fa-grid-2 me-2"></i>  {{__('dashboard.viewTypes.list')}}</a></li>
                            @endif
                        </ul>
                    </div>
                    {{--
                    <div class="dropdown">
                        <button class="butn-st2 line-butn py-2 px-3 ms-2 dropdown-toggle" type="button" data-bs-toggle="dropdown" aria-expanded="false">
                            <i class="fal fa-arrow-up-arrow-down me-2"></i> Sort by
                        </button>
                        <ul class="dropdown-menu">
                            <li><a class="dropdown-item" href="#">Sort by</a></li>
                            <li><a class="dropdown-item" href="#">Sort by</a></li>
                        </ul>
                    </div>
                    --}}
                </div>
            </div>
            <div class="col-lg-6">
                <div class="nav-butns d-flex justify-content-lg-end mt-4 mt-lg-0">
                    @if(auth()->user()->canAccess('contact_lists','export'))
                        <button type="button" class="export_excel ref-btn butn-st2 blue-butn py-2 px-3 ms-2">
                            {{__('dashboard.export')}}
                        </button>
                    @endif
                    @if(auth()->user()->canAccess('contact_lists','delete'))
                        <a href="{{ route ('contact_lists.destroyAll') }}" data-method="delete" class="butn statusButns status_1 tableAction btn disabled ref-btn butn-st2 line-butn py-2 px-3"><div class="cont"><span>{{ __('dashboard.sendToTrash') }}</span></div></a>
                        <a href="#" class="butn statusButns status_1 showArchive ref-btn butn-st2 line-butn py-2 px-3"><div class="cont"><span> {{ __('dashboard.displayTrash') }} </span></div></a>

        {{--                <a href="{{ route ('contact_lists.destroyAll') }}" data-method="delete" class="butn statusButns status_0 tableAction btn disabled force hidden butn_blue ms-auto"><div class="cont"><span> {{ __('dashboard.delete') }} </span></div></a>--}}
                        <a href="{{ route ('contact_lists.restoreAll') }}" data-method="put" class="butn statusButns status_0 tableAction btn disabled force hidden ref-btn butn-st2 line-butn py-2 px-3"><div class="cont"><span> {{ __('dashboard.restore') }} </span></div></a>
                        <a href="#" class="butn statusButns status_0 showActive hidden ref-btn butn-st2 line-butn py-2 px-3"><div class="cont"><span> {{ __('dashboard.displayActive') }} </span></div></a>
                    @endif
                    @if(auth()->user()->canAccess('contact_lists','store'))
                        <a href="#0" class="ref-btn butn-st2 blue-butn py-2 px-3 ms-2" onclick="openModel(this)" action="{{route('contact_lists.create')}}"> <i class="fal fa-plus"></i> <span class="txt ms-2"> {{ __('contact_lists.new') }} </span> </a>
                    @endif
                </div>
            </div>
        </div>
    </div>
    <div class="body-content response">
    </div>
</div>

<div class="modal fade modal-add-contact" id="modal-check" tabindex="-1" aria-labelledby="modalCheckLabel" aria-hidden="true">
    <div class="modal-dialog modal-dialog-centered modal-md">
        <div class="modal-content rounded-3 shadow-lg border-0">

            <!-- Modal Header -->
            <div class="modal-header border-0 pb-0 justify-content-center">
                <h3 class="modal-title fw-bold text-dark" id="modalCheckLabel">
                    {{ __('contact_lists.target_question') }}
                </h3>
            </div>


            <!-- Modal Footer -->
            <div class="modal-footer justify-content-center border-0 pt-0">
                <a href="{{ route('deals.index') }}" class="btn btn-primary px-4 py-2 rounded-pill shadow-sm">
                    {{ __('contact_lists.yes') }}
                </a>
                <button type="button" class="btn btn-outline-secondary px-4 py-2 rounded-pill"
                        id="no-btn" data-bs-dismiss="modal">
                    {{ __('contact_lists.no') }}
                </button>
            </div>

        </div>
    </div>
</div>





@endsection


<script>
    document.addEventListener('DOMContentLoaded', function () {
        let modal = document.getElementById('modal-check');
        let noBtn = document.getElementById('no-btn');

        noBtn.addEventListener('click', function () {
            location.reload();
        });

        modal.addEventListener('hidden.bs.modal', function () {
            location.reload();
        });
    });
</script>
<script>
/**
 * Importat to handle ajax requests for filters, deletes, trash and any proccess done on the table's data
 */
var dataTable={
    route: '{{ route("contact_lists.grid") }}'
}
</script>
@section('inner_js')

    <script>

        $('.export_excel').click(function(){
            const data= dataInDiv('.search_filter_form', 'string')
            const redirect= '{{ route("contact_lists.grid", ["export"=> true]) }}&'+data
            window.open(redirect)
        })
    </script>
@endsection
