@extends('admin.layouts.master')

@section('css')
<link href="{{URL::asset('assets/plugins/datatable/css/dataTables.bootstrap4.min.css')}}" rel="stylesheet" />
<link href="{{URL::asset('assets/plugins/datatable/css/buttons.bootstrap4.min.css')}}" rel="stylesheet">
<link href="{{URL::asset('assets/plugins/datatable/css/responsive.bootstrap4.min.css')}}" rel="stylesheet" />
<link href="{{URL::asset('assets/plugins/datatable/css/jquery.dataTables.min.css')}}" rel="stylesheet">
<link href="{{URL::asset('assets/plugins/datatable/css/responsive.dataTables.min.css')}}" rel="stylesheet">
@endsection

@section('title')
    ID Card Requests
@endsection

@section('content')
<!-- row opened -->
<div class="row row-sm">
    <!--div-->
    <div class="col-xl-12">
        <div class="card mg-b-20">
            <div class="card-header pb-0">
                <div class="d-flex justify-content-between">
                    <h4 class="card-title mg-b-0">{{ trans('dashboard.id_card_requests') }}</h4>
                </div>
            </div>
            <div class="card-body">
                <div class="table-responsive">
                    <table id="example" class="table key-buttons text-md-nowrap">
                        <thead>
                            <tr>
                                <th class="border-bottom-0">{{ trans('dashboard.name') }}</th>
                                <th class="border-bottom-0">{{ trans('dashboard.status') }}</th>
                                <th class="border-bottom-0">{{ trans('dashboard.notes') }}</th>
                                @canany(['accept_id_card_request', 'reject_id_card_request', 'view_id_card_request'])
                                    <th class="border-bottom-0">{{ trans('dashboard.actions') }}</th>
                                @endcanany
                                <th class="border-bottom-0">{{ trans('dashboard.created') }}</th>
                            </tr>
                        </thead>
                        <tbody>
                            @foreach ($id_card_requests as $id_card_request)
                                <tr>
                                    <td>{{ $id_card_request->user->{'name_' . $locale} }}</td>
                                    <td>{{ trans('dashboard.'.$id_card_request->status) }}</td>
                                    <td>{{ $id_card_request->notes }}</td>
                                    @if ($id_card_request->status == 'pending')
                                        @canany(['accept_id_card_request', 'reject_id_card_request'])
                                            <td class="row pl-3 mr-1">
                                                @can('accept_id_card_request')
                                                    <form class="pl-3" action="{{ route('id_card_requests.accept') }}" method="post">
                                                        @csrf
                                                        <input type="hidden" name="user_id" value="{{ $id_card_request->user->id }}">
                                                        <input type="hidden" name="id_card_request_id" value="{{ $id_card_request->id }}">
                                                        <button class="btn btn-success" type="submit">{{ trans('dashboard.accept') }}</button>
                                                    </form>
                                                @endcan
                                                &nbsp;&nbsp;

                                                @can('reject_id_card_request')
                                                    <form class="pl-3" action="{{ route('id_card_requests.reject') }}" method="post">
                                                        @csrf
                                                        <input type="hidden" name="user_id" value="{{ $id_card_request->user->id }}">
                                                        <input type="hidden" name="id_card_request_id" value="{{ $id_card_request->id }}">
                                                        <button class="btn btn-danger" type="submit">{{ trans('dashboard.reject') }}</button>
                                                    </form>
                                                @endcan
                                                <div class="pl-3">
                                                    <a target="_blank" href="{{ route('id_card', $id_card_request->user->id) }}" class="btn btn-warning">{{ trans('dashboard.view') }}</a>
                                                </div>
                                            </td>
                                        @endcanany
                                    @else
                                        <td class="row pl-3 mr-1">
                                            <a target="_blank" href="{{ route('id_card', $id_card_request->user->id) }}" class="btn btn-warning">{{ trans('dashboard.view') }}</a>
                                        </td>
                                    @endif
                                    <td>{{ $id_card_request->created_at->diffForHumans() }}</td>
                                </tr>
                            @endforeach

                        </tbody>
                    </table>
                </div>
            </div>
        </div>
    </div>
    <!--/div-->
</div>
@endsection

@section('js')
<!-- Internal Data tables -->
<script src="{{URL::asset('assets/plugins/datatable/js/jquery.dataTables.min.js')}}"></script>
<script src="{{URL::asset('assets/plugins/datatable/js/dataTables.dataTables.min.js')}}"></script>
<script src="{{URL::asset('assets/plugins/datatable/js/dataTables.responsive.min.js')}}"></script>
<script src="{{URL::asset('assets/plugins/datatable/js/responsive.dataTables.min.js')}}"></script>
<script src="{{URL::asset('assets/plugins/datatable/js/jquery.dataTables.js')}}"></script>
<script src="{{URL::asset('assets/plugins/datatable/js/dataTables.bootstrap4.js')}}"></script>
<script src="{{URL::asset('assets/plugins/datatable/js/dataTables.buttons.min.js')}}"></script>
<script src="{{URL::asset('assets/plugins/datatable/js/buttons.bootstrap4.min.js')}}"></script>
<script src="{{URL::asset('assets/plugins/datatable/js/jszip.min.js')}}"></script>
<script src="{{URL::asset('assets/plugins/datatable/js/pdfmake.min.js')}}"></script>
<script src="{{URL::asset('assets/plugins/datatable/js/vfs_fonts.js')}}"></script>
<script src="{{URL::asset('assets/plugins/datatable/js/buttons.html5.min.js')}}"></script>
<script src="{{URL::asset('assets/plugins/datatable/js/buttons.print.min.js')}}"></script>
<script src="{{URL::asset('assets/plugins/datatable/js/buttons.colVis.min.js')}}"></script>
<script src="{{URL::asset('assets/plugins/datatable/js/dataTables.responsive.min.js')}}"></script>
<script src="{{URL::asset('assets/plugins/datatable/js/responsive.bootstrap4.min.js')}}"></script>
<!--Internal  Datatable js -->
<script src="{{URL::asset('assets/js/table-data.js')}}"></script>
@endsection
