@extends('layouts.admin')

@section('title', __('adminforms.categorygroups.plural'))
@section('header', __('adminforms.categorygroups.plural'))
@section('header_desc', '')
@section('breadcumbs', '')

@section('content')
    <!-- Main content -->
    <section class="content">
        <div class="row">
            <div class="col-xs-12">
                <div class="box">
                    <div class="box-header">
                        <h3 class="box-title">{{__('adminforms.categorygroups.plural')}}</h3>
                    </div>
                    @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
                <!-- /.box-header -->
                    @can('create', $group)
                        <div class="text-right">
                            <a class="btn btn-outline-success" href="{{ route('admin.categorygroup.create') }}"><i class="ionicons ion-ios-plus-outline"> {{__('adminforms.categorygroups.btn_add')}}</i></a>
                            <hr>
                        </div>
                    @endcan
                    <div class="box-body">
                        <table id="data-table" class="table table-hover">
                            <thead>
                            <tr>
                                <th>{{__('adminforms.categorygroups.cg_id')}}</th>
                                <th>{{__('adminforms.categorygroups.cg_name')}}</th>
                                <th>{{__('adminforms.categorygroups.cg_feat')}}</th>
                                <th style="text-align: right;">&nbsp;</th>
                                <th style="text-align: right;">&nbsp;</th>
                            </tr>
                            </thead>
                            <tbody>
                            @foreach($groups as $group)
                                <tr>
                                    <td>{{$group->cg_id}}</td>
                                    <td> {{$group->ctranslation->cg_name}}</td>
                                    <td> {{$group->cg_feat ? 'Da' : 'Ne'}} </td>
                                    <td style="text-align: right;">
                                        @can('update', $group)
                                            <a class="btn btn-outline-success btn-xsm" href="{{ route('admin.categorygroup.edit', ['categorygroup' => $group->cg_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', $group)
                                            {{ Form::open(array('route' => array('admin.categorygroup.destroy', $group->cg_id), 'method' => 'DELETE', 'class'=>'form-inline', 'onsubmit' => 'return submitDeleteForm(this);')) }}
                                            {{ Form::hidden('categorygroup', $group->cg_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