<script src="assets/js/king-table.js"></script>
<div class="widget widget-table">
	<div class="widget-header">
		<h3><i class="fa fa-group"></i> PERMISSION</h3> <em>- List of Support Tickets</em>
		<div class="btn-group widget-header-toolbar">
			<!--<a class="btn createMod" href="CreateModule" title="Focus" class="btn-borderless btn-focus"><i class="fa fa-plus"></i></a>-->
			<!--<a href="#" title="Expand/Collapse" class="btn-borderless btn-toggle-expand"><i class="fa fa-chevron-up"></i></a>
			<a href="#" title="Remove" class="btn-borderless btn-remove"><i class="fa fa-times"></i></a>-->
		</div>
		<!--<div class="widget-header-toolbar">
			<div class="label label-danger"><i class="fa fa-warning"></i> 2 Critical Messages</div>
		</div>-->
	</div>
	<div class="widget-content"> 
		<table id="visit-stat-table" class="table table-sorting table-striped table-hover datatable">
			<thead>
				<tr>
					<th>Serial No</th>
					<th>Module Name</th>
					<th>User type</th>
					<th>View</th>
					<th>Create</th>
					<th>Edit</th>
					<th>Delete</th>
				</tr>
			</thead>
			<?php $i=1;?>
			<tbody>
				@foreach($data['permission'] as $perms)
				<tr>
					<td><?php echo $i++;?></td>
					<td>{{$perms->Modulename}}</td>
					<td>{{$perms->ut_type}}</td>
					
					<td><input data-src="{{$perms->Mid}}" type="checkbox" value="1" <?php  if($perms->View)  echo 'checked'; ?> class="Pview control-inline fancy-checkbox"> </td>
					<td><input data-src="{{$perms->Mid}}" type="checkbox" value="1" <?php  if($perms->create)  echo 'checked'; ?> class="Pcreate control-inline fancy-checkbox"> </td>
					<td><input data-src="{{$perms->Mid}}" type="checkbox" value="1" <?php  if($perms->Edit)  echo 'checked'; ?> class="PEdit control-inline fancy-checkbox"> </td>
					<td><input data-src="{{$perms->Mid}}" type="checkbox" value="1" <?php  if($perms->Delete)  echo 'checked'; ?> class="Pdelete control-inline fancy-checkbox"> </td>
			</tr>
				
				@endforeach
			</tbody>
		</table>
	</div>
</div>
<script>
	$('.createMod').click(function(e)
	{   
		e.preventDefault();
		$('#sideMenu').load($(this).attr('href'));
	});
	
	
	$('.Pview').change(function(e){
		Pid=$(this).attr('data-src');
		
		if($(this).is(":checked"))
		{
			val='1';
		}
		else
		{
			val='0';
		}
		
		$.ajax({
			type: 'get',
			url: "Viewpermision",
			data : { val : val, Pid : Pid },
			success: function(result)
			{}
		});
	});
	$('.Pcreate').change(function(e){
		Pid=$(this).attr('data-src');
		
		if($(this).is(":checked"))
		{
			val='1';
		}
		else
		{
			val='0';
		}
		
		$.ajax({
			type: 'get',
			url: "Crreatepermision",
			data : { val : val, Pid : Pid },
			success: function(result)
			{}
		});
	});
	
	
	$('.PEdit').change(function(e){
		Pid=$(this).attr('data-src');
		
		if($(this).is(":checked"))
		{
			val='1';
		}
		else
		{
			val='0';
		}
		
		$.ajax({
			type: 'get',
			url: "Editpermision",
			data : { val : val, Pid : Pid },
			success: function(result)
			{}
		});
	});
	
	$('.Pdelete').change(function(e){
		Pid=$(this).attr('data-src');
		
		if($(this).is(":checked"))
		{
			val='1';
		}
		else
		{
			val='0';
		}
		
		$.ajax({
			type: 'get',
			url: "Deletepermision",
			data : { val : val, Pid : Pid },
			success: function(result)
			{}
		});
	});
</script>