@extends('layouts.admin')

@section('title'){{__('adminforms.carousels.plural')}} @endsection
@section('header'){{__('adminforms.carousels.plural')}} @endsection
@section('header_desc') @endsection
@section('breadcumbs') @endsection

@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.carousels.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', $carousel)
                        <div class="text-right">
                            <a class="btn btn-outline-success" href="{{ route('admin.carousel.create') }}"><i class="ionicons ion-ios-plus-outline"> {{__('adminforms.carousels.btn_add')}}</i></a>
                            <hr>
                        </div>
                    @endcan
                    <div class="box-body">
                        <table id="data-table" class="table table-hover">
                            <thead>
                            <tr>
                                <th>{{__('adminforms.carousels.car_id')}}</th>
                                <th>{{__('adminforms.carousels.car_title')}}</th>
                                <th>{{__('adminforms.carousels.car_type')}}</th>
                                <th>{{__('adminforms.carousels.car_order')}}</th>
                                <th>{{__('adminforms.carousels.car_active')}}</th>
                                <th style="text-align: right;">&nbsp;</th>
                                <th style="text-align: right;">&nbsp;</th>
                            </tr>
                            </thead>
                            <tbody>
                            @foreach($carousels as $carousel)
                                <tr>
                                    <td>{{$carousel->car_id}}</td>
                                    <td> {{($carousel->ctranslation) ? $carousel->ctranslation->car_title : ''}}</td>
                                    <td> {{strtr($carousel->car_type, $types)}}</td>
                                    <td> {{strtr($carousel->car_order, $sorts)}}</td>
                                    <td> {{strtr($carousel->car_active, [0 => __('adminforms.common.false'), 1 => __('adminforms.common.true')])}}</td>
                                    
                                    <td style="text-align: right;">
                                        @can('update', $carousel)
                                            <a class="btn btn-outline-success btn-xsm" href="{{ route('admin.carousel.edit', ['carousel' => $carousel->car_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', $carousel)
                                            @if($carousel->car_id > 2)
                                            {{ Form::open(array('route' => array('admin.carousel.destroy', $carousel->car_id), 'method' => 'DELETE', 'class'=>'form-inline', 'onsubmit' => 'return submitDeleteForm(this);')) }}
                                            {{ Form::hidden('carousel', $carousel->car_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;
                                            @endif
                                        @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