<?php $__env->startSection('content'); ?>
<?php Fun::lang()?>
<div class="title-add">
	<div class="page-bar"> 
		<ul class="page-breadcrumb"> 
			<li> <a class="ng-binding" href="#"><i class="fa fa-dashboard"></i> Dashboard</a> </li>
            <li><a href="#">Role</a></li>
		</ul> 
	</div>
</div>

<div class="page">
	<div class="top-content">
		<div class="row">
			<div class="col-sm-12 col-xs-12">
				<div class="title-add">
	                <div class="pull-left">
	                    <h3>Role</h3>
	                </div>
                </div>
				<div class="pull-right">
					<?php if (app(\Illuminate\Contracts\Auth\Access\Gate::class)->check('Role-Create')): ?>
					<a class="button_sm button_primary" href="<?php echo e(route('roles.create')); ?>"><span class="fa fa-plus"></span>  Create New</a>
					<?php endif; ?>
				</div>
			</div>
		</div>
	</div>

	<div class="box-body table-responsive">
		<table id="datatable_roles" class="table  table-bordered table-hover nowrap">
			<thead>
				<tr>
					<th>No</th>
					<th>Roles Name</th>
					<th><?php echo e(__('administrator.action')); ?></th>
				</tr>
			</thead>
		</table>
	</div>
</div>
<?php $__env->stopSection(); ?>

<?php $__env->startSection('js'); ?>
<script type="text/javascript">
	$(document).ready(function() {
		$('#datatable_roles').DataTable({
			ordering:  false,
			"serverSide": true,
			"lengthMenu": [[20, 30, 50, 100, -1], [20, 30, 50, 100, "All"]],
			ajax: "<?php echo e(route('datatable.get_roles')); ?>",
			columns: [
			{data: 'id', name: 'id'},
			{data: 'name', name: 'name'},
			{data: 'action', name: 'action'},
			]				  
		});
		$.fn.dataTable.ext.errMode = 'throw';
	});
	$(document).on('click', '.btn-delete-role', function() {
		var id = $(this).closest('a').data('id');
		var route = "<?php echo e(route('roles.destroy',':id')); ?>";
		route = route.replace(':id',id);
		$.confirm({
			title: 'Confirm!',
			content: 'This role will be permanently deleted!',
			buttons: {
				cancel: function() {
				},
				confirm: function() {
					$.ajax({
						type:"DELETE",
						dataType:"JSON",
						url:route,
						data:{
							_token:"<?php echo e(csrf_token()); ?>"
						},
						success:function(data){
							$.alert(data.msg);
							$('#datatable_roles').DataTable().ajax.reload();
						}
					});
				}
			}
		});
	});
</script>

<?php $__env->stopSection(); ?>




<?php echo $__env->make('adminlte::page', array_except(get_defined_vars(), array('__data', '__path')))->render(); ?>