@inject('request', 'Illuminate\Http\Request')
@extends('layouts.app')

@section('content')
    <h3 class="page-title">@lang('quickadmin.customer-appeal.title')</h3>

    <div class="panel panel-default customer-appeal">
        <div class="panel-heading header-block">
            @include('partials.header-filter', [
                'model_key' => $model_key,
                'gate_key' => $gate_key,
                'search_id' => $search_id,
                'listForSelect' => $filterList
            ])
        </div>

        <div class="panel-body table-responsive">
            <table class="table table-bordered table-striped {{ count($customer_appeals) > 0 ? 'datatable' : '' }} @can('customer_appeal_delete') @if ( request('show_deleted') != 1 ) dt-select @endif @endcan">
                <thead>
                <tr>
                    @can('customer_appeal_delete')
                        @if ( request('show_deleted') != 1 )
                            <th style="text-align:center;"><input type="checkbox" id="select-all"/></th>@endif
                    @endcan

                        <th>@lang('quickadmin.customer-appeal.fields.created-at')</th>
                    <th>@lang('quickadmin.customer-appeal.fields.phone')</th>
                    <th>@lang('quickadmin.customer-appeal.fields.customer-appeal-option')</th>

                    <th>@lang('quickadmin.customer-appeal.fields.call-now')</th>
                    <th>@lang('quickadmin.customer-appeal.fields.call-time')</th>
                    {{--<th>@lang('quickadmin.customer-appeal.fields.request-processed')</th>--}}
                    <th>@lang('quickadmin.customer-appeal.fields.developer')</th>
                    <th>@lang('quickadmin.customer-appeal.fields.residential-complexes')</th>
                        <th>@lang('quickadmin.customer-appeal.fields.planning')</th>

                    @if( request('show_deleted') == 1 )
                        <th>@lang('quickadmin.qa_action')</th>
                    @else
                        <th>@lang('quickadmin.qa_action')</th>
                    @endif
                </tr>
                </thead>

                <tbody>
                @if (count($customer_appeals) > 0)
                    @foreach ($customer_appeals as $customer_appeal)
                        <tr data-entry-id="{{ $customer_appeal->id }}">
                            @can('customer_appeal_delete')
                                @if ( request('show_deleted') != 1 )
                                    <td></td>@endif
                            @endcan
                            <td field-key='created_at'>{{ $customer_appeal->created_at_modify }}</td>
                            <td field-key='phone'>{{ $customer_appeal->phone }}</td>
                            <td field-key='customer_appeal_option'>{{ $customer_appeal->customer_appeal_option->name ?? '' }}</td>
                            <td field-key='call_now'>{{ Form::checkbox("call_now", 1, $customer_appeal->call_now == 1 ? true : false, ["disabled"]) }}</td>
                            <td field-key='call_time'>{{ $customer_appeal->call_time }}</td>
                                {{--<td field-key='request_processed'>{{ Form::checkbox("request_processed", 1, $customer_appeal->request_processed == 1 ? true : false, ["disabled"]) }}</td>--}}
                                <td field-key='developer'>{{ $customer_appeal->developer->name ?? '' }}</td>
                                <td field-key='residential_complexes'>{{ $customer_appeal->residential_complexes->name ?? '' }}</td>
                                <td field-key='planning'>
                                    @if ($customer_appeal->planning && $customer_appeal->planning->section)
                                        {{ $customer_appeal->planning->section->name ?? '' }}
                                    @endif
                                </td>

                            @if( request('show_deleted') == 1 )
                                <td class="action">
                                    @can('customer_appeal_delete')
                                        {!! Form::open(array(
        'style' => 'display: inline-block;',
        'method' => 'POST',
        'onsubmit' => "return confirm('".trans("quickadmin.qa_are_you_sure")."');",
        'route' => ['admin.customer_appeals.restore', $customer_appeal->id])) !!}
                                        {!! Form::submit(trans('quickadmin.qa_restore'), array('class' => 'btn btn-xs btn-success')) !!}
                                        {!! Form::close() !!}
                                    @endcan
                                    @can('customer_appeal_delete')
                                        {!! Form::open(array(
        'style' => 'display: inline-block;',
        'method' => 'DELETE',
        'onsubmit' => "return confirm('".trans("quickadmin.qa_are_you_sure")."');",
        'route' => ['admin.customer_appeals.perma_del', $customer_appeal->id])) !!}
                                        {!! Form::submit(trans('quickadmin.qa_permadel'), array('class' => 'btn btn-xs btn-danger')) !!}
                                        {!! Form::close() !!}
                                    @endcan
                                </td>
                            @else
                                <td class="action">
                                    @can('customer_appeal_view')
                                        <a href="{{ route('admin.customer_appeals.show',[$customer_appeal->id]) }}"
                                           class="btn btn-xs btn-primary">@lang('quickadmin.qa_view')</a>
                                    @endcan
                                    @can('customer_appeal_edit')
                                        <a href="{{ route('admin.customer_appeals.edit',[$customer_appeal->id]) }}"
                                           class="btn btn-xs btn-info">@lang('quickadmin.qa_edit')</a>
                                    @endcan
                                    @can('customer_appeal_delete')
                                        {!! Form::open(array(
                                                                                'style' => 'display: inline-block;',
                                                                                'method' => 'DELETE',
                                                                                'onsubmit' => "return confirm('".trans("quickadmin.qa_are_you_sure")."');",
                                                                                'route' => ['admin.customer_appeals.destroy', $customer_appeal->id])) !!}
                                        {!! Form::submit(trans('quickadmin.qa_delete'), array('class' => 'btn btn-xs btn-danger')) !!}
                                        {!! Form::close() !!}
                                    @endcan
                                </td>
                            @endif
                        </tr>
                    @endforeach
                @else
                    <tr>
                        <td colspan="13">@lang('quickadmin.qa_no_entries_in_table')</td>
                    </tr>
                @endif
                </tbody>
            </table>
            @if ( !isset($search_id) && request('show_deleted') != 1)
                {{ $customer_appeals->links() }}
            @endif
        </div>
    </div>
@stop

@section('javascript')
    <script>
        @can('customer_appeal_delete')
                @if ( request('show_deleted') != 1 ) window.route_mass_crud_entries_destroy = '{{ route('admin.customer_appeals.mass_destroy') }}'; @endif
        @endcan

    </script>
@endsection