@extends('app')
@section('content')
<div class="col-md-12 content-header" >
    <h1><i class="fa fa-user"></i> {{trans('application.system_users')}}</h1>
</div>
<section class="content">
<div class="row">
    <div class="col-md-12">
        <div class="box  box-primary">
            @if(hasPermission('add_user'))
                <div class="box-header with-border">
                    <h3 class="box-title pull-right">
                        <div class="box-tools ">
                            <a href="{{ route('users.create') }}" class="btn btn-primary btn-xs pull-right" data-toggle="ajax-modal"> <i class="fa fa-user-plus"></i> {{trans('application.new_user')}}</a>
                        </div>
                    </h3>
                </div>
            @endif
            <div class="box-body">
                <div class="table-responsive">
                    <table class="table table-bordered table-striped table-hover ajax_datatable">
                        <thead>
                        <tr>
                            <th>{{trans('application.photo')}} </th>
                            <th>{{trans('application.name')}} </th>
                            <th>{{trans('application.username')}} </th>
                            <th>{{trans('application.email')}} </th>
                            <th>{{trans('application.phone')}} </th>
                            <th>{{trans('application.role')}} </th>
                            <th>{{trans('application.action')}} </th>
                        </tr>
                        </thead>
                        <tbody></tbody>
                    </table>
                </div>
            </div>
        </div>
    </div>
</div>
</section>
@endsection
@section('scripts')
    <script type="text/javascript">
        $(document).ready(function() {
            $('.ajax_datatable').DataTable({
                processing: true,
                serverSide: true,
                stateSave: true,
                ajax: '{{route('users.index')}}',
                order: [],
                columnDefs: [{
                    "orderable": false,
                    "targets": 0
                }],
                oLanguage: {
                    "sProcessing":"{{trans('application.processing')}}"
                },
                columns:[
                    {data: 'photo',orderable:false},
                    {data: 'name',orderable:false},
                    {data: 'username', orderable:false},
                    {data: 'email',orderable:false},
                    {data: 'phone',orderable:false},
                    {data: 'role',name:"roles.name",orderable:false},
                    {data: 'action', 'searchable':false,orderable:false,className: "text-right"}
                ]
            });
            $('div.dataTables_filter input').addClass('form-control input-sm');
            $('div.dataTables_length select').addClass('form-control input-sm');
        });
    </script>
@endsection


