@extends('employee.layouts.container')

@section('content')


<div class="search_filter_form">
    <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 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('targets','chart_export'))
                        <button type="button" class="export_chart_excel ref-btn butn-st2 blue-butn py-2 px-3 ms-2">
                            {{__('dashboard.chart_export')}}
                        </button>
                    @endif
                    @if(auth()->user()->canAccess('targets','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('targets','delete'))
                        <a href="{{ route ('employee.targets.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 ('employee.targets.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 ('employee.targets.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('targets','store'))
                        <a href="#0" class="ref-btn butn-st2 blue-butn py-2 px-3 ms-2" onclick="openModel(this)" action="{{route('employee.targets.create')}}"> <i class="fal fa-plus"></i> <span class="txt ms-2"> {{ __('targets.new') }} </span> </a>
                    @endif
                </div>
            </div>
        </div>
    </div>
    <div class="body-content response">
    </div>
</div>
@endsection



<script>
/**
 * Importat to handle ajax requests for filters, deletes, trash and any proccess done on the table's data
 */
var dataTable={
    route: '{{ route("employee.targets.grid") }}?' + @json(http_build_query($request->all()))
}
</script>
@section('inner_js')

    <script>

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

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