@extends('layouts.admin')
@section('title'){{__('adminforms.pages.plural')}} @endsection
@section('header'){{__('adminforms.pages.plural')}} @endsection
@section('header_desc') @endsection
@section('breadcumbs') @endsection

@section('content')
    <!-- Main content -->
    <section class="content">

        <div class="row">
            <div class="col-xs-12">
                @if (session('result'))
                    <div class="alert alert-success alert-dismissible">
                        <button type="button" class="close" data-dismiss="alert" aria-hidden="true">×</button>
                        <i class="icon fa fa-check"></i> <strong>Info: </strong> &nbsp;  &nbsp;
                        {{ session('result') }}
                    </div>
                @endif
                @if (session('error'))
                    <div class="alert alert-danger alert-dismissible">
                        <button type="button" class="close" data-dismiss="alert" aria-hidden="true">×</button>
                        <i class="icon fa fa-exclamation-triangle"></i> <strong>Info: </strong> &nbsp;  &nbsp;
                        {{ session('error') }}
                    </div>
                @endif
            </div>
        </div>
        <div class="row">
            <div class="col-xs-12">
                <div class="box">

                <!-- /.box-header -->
                    @can('create', $page)
                        <div class="col-xs-12"><br></div>
                        <div class="col-xs-12 col-md-6">&nbsp;</div>
                        <div class="col-xs-12 col-md-6">
                            <div class="text-right">
                                <a class="btn btn-outline-success" href="{{ route('admin.page.create') }}">
                                    <i class="ionicons ion-ios-plus-outline"> {{__('adminforms.pages.btn_add')}}</i>
                                </a>
                            </div>
                        </div>
                        <div class="col-xs-12"><hr></div>

                    @endcan
                    <div class="box-body">
                        <table id="data-table" class="table table-hover">
                            <thead>
                            <tr>
                                <th>{{ucfirst(__('adminforms.pages.page_id'))}}</th>
                                <th>{{ucfirst(__('adminforms.pages.page_gr_name'))}}</th>
                                <th>{{ucfirst(__('adminforms.pages.page_name'))}}</th>
                                <th style="text-align: right;">&nbsp;</th>
                                <th style="text-align: right;">&nbsp;</th>
                            </tr>
                            </thead>
                            <tbody>
                            {{--@php
                                $cadmin = auth('admin')->user();
                            @endphp--}}
                            @foreach($pages as $page)
                                <tr>
                                    <td>{{$page->page_id}}</td>
                                    <td> {{$page->group->ctranslation->page_gr_name}}</td>
                                    <td> {{$page->ctranslation->page_name}}</td>
                                    <td style="text-align: right;">
                                        @can('update', /*$cadmin, */$page)
                                            <a class="btn btn-outline-success btn-xsm" href="{{ route('admin.page.edit', ['page' => $page->page_id]) }}">
                                                <i class="fa fa-pencil-square-o"></i> {{__('adminforms.common.edit_btn')}}
                                            </a>
                                        @else
                                            &nbsp;
                                        @endcan
                                    </td>
                                    <td style="text-align: right;">
                                        @can('delete', /*$cadmin, */$page)
                                            {{ Form::open(array('route' => array('admin.page.destroy', $page->page_id), 'method' => 'DELETE', 'class'=>'form-inline', 'onsubmit' => 'return submitDeleteForm(this);')) }}
                                            {{ Form::hidden('page', $page->page_id) }}
                                            <button type="submit" class="btn btn-outline-danger btn-xsm delete"><i class="fa fa-times-circle-o"></i> {{__('adminforms.common.del_btn')}}</button>
                                            {{ Form::close() }}
                                        @else
                                            &nbsp;
                                        @endcan
                                    </td>
                                </tr>
                            @endforeach
                            </tbody>
                        </table>
                    </div>
                    <!-- /.box-body -->
                </div>
                <!-- /.box -->
            </div>
            <!-- /.col -->
        </div>
        <!-- /.row -->

    </section>
@endsection


@push('css')
<link rel="stylesheet" href="{{asset('assets/components/datatables.net-bs/css/dataTables.bootstrap.min.css')}}">
@endpush

@push('primscripts')
<script src="{{asset('assets/components/datatables.net/js/jquery.dataTables.min.js')}}"></script>
<script src="{{asset('assets/components/datatables.net-bs/js/dataTables.bootstrap.js')}}"></script>
@endpush
@push('scripts')
<script>
    $(function () {
        $('#data-table').DataTable({
            'paging'      : true,
            'lengthChange': false,
            'searching'   : true,
            'ordering'    : true,
            'info'        : true,
            'autoWidth'   : false,
            "bStateSave"  : true,
            "language": {
                "sProcessing":   "{{__('adminforms.data_tables.sProcessing')}}",
                "sLengthMenu":   "{{__('adminforms.data_tables.sLengthMenu')}}",
                "sZeroRecords":  "{{__('adminforms.data_tables.sZeroRecords')}}",
                "sInfo":         "{{__('adminforms.data_tables.sInfo')}}",
                "sInfoEmpty":    "{{__('adminforms.data_tables.sInfoEmpty')}}",
                "sInfoFiltered": "{{__('adminforms.data_tables.sInfoFiltered')}}",
                "sInfoPostFix":  "{{__('adminforms.data_tables.sInfoPostFix')}}",
                "sSearch":       "{{__('adminforms.data_tables.sSearch')}}",
                "sUrl":          "{{__('adminforms.data_tables.sUrl')}}",
                "oPaginate": {
                    "sFirst":    "{{__('adminforms.data_tables.sFirst')}}",
                    "sPrevious": "{{__('adminforms.data_tables.sPrevious')}}",
                    "sNext":     "{{__('adminforms.data_tables.sNext')}}",
                    "sLast":     "{{__('adminforms.data_tables.sLast')}}",
                }
            }
        })
    })
</script>
@endpush