@extends('layout')
@section('title','Rôles & Permissions ')
@section('content')
 
	

       <div class="main-container container-fluid">

				<div class="page-header">
					<div>

						<ol class="breadcrumb">
							<li class="breadcrumb-item"><a href="{{route('accueil')}}">Accueil</a></li>
							<li class="breadcrumb-item active" aria-current="page">Attribution des permissions</li>
						</ol>
					</div>
				
				</div>
			

			</div>
			
			
			<div class="main-container container-fluid">
			
			
					<div class="row">
					<div class="col-lg-12">
						<div class="card custom-card overflow-hidden">
							<div class="card-body" style="margin:30px">
							
							<form class="needs-validation" action="{{route('permissionPost', ['id'=> $idrole])}}" method="post" >
					 
								   {{csrf_field()}}
						 
						          	<div class="form-group ">
											
											<div class="custom-control custom-radio">
												<input type="radio" class="custom-control-input" id="feedback111" name="role" value="{{ $idrole }}" checked>
												<label class="custom-control-label" for="feedback111">  {{ DB::table('role')->where('id',$idrole)->first()->lib }} </label>
											</div>
											
											 <hr>
											  
												<div class="custom-control custom-checkbox">
														<input type="checkbox" class="custom-control-input" id="Tout" name="Tout"  onclick="selectAll(this)" >
														<label class="custom-control-label" for="Tout" > Tout sélectionner </label>
												</div>
										
										</div>
							
							
								
												<div class="table-responsive">
												<table class="table table-bordered mg-b-0">
													 <thead>
														 <tr >
									
															 <th  >Pages</th>
															 <th  >Permissions</th>
															
															</tr>
													</thead>
													<tbody>
													
															
								   @foreach($vue as $key => $vues)
								   
								   @php

							   
								   @endphp
								  
									<tr>
									  
									  <td class="center">
									  
											<div class="col">
											  
												<div class="custom-control custom-checkbox">
												  <input type="checkbox" class="custom-control-input" name="vu[{{$key}}]" value="{{ $vues->id }}"  id="{{ $vues->id }}"  > 
												   <label class="custom-control-label" for="{{ $vues->id }}" > {{ $vues->lib }} </label>
												</div>
												
											  </div>
									  
									  </td>
									  <td>
										 
										  @foreach($typepermission as $typepermissions)
									
											<div class="col">
											
												<div class="custom-control custom-checkbox">
												  <input type="checkbox" class="custom-control-input" name="typerm[{{$key}}][]" value="{{ $typepermissions->id }}"  id="checktyp[{{$vues->id}}][{{$typepermissions->id}}]"  > 
												   <label class="custom-control-label" for="checktyp[{{$vues->id}}][{{$typepermissions->id}}]" > {{ $typepermissions->lib }} </label>
												</div>
												
											  </div>
											  
										@endforeach
									  
									  </td>
									
									</tr>
								
									@endforeach
													
													</tbody>
												</table>
											
											
											</div>
											
										   </br>
					
						     <a href="{{route('nouveau-role')}}" class="btn btn-danger float-right" type="button"> Annuler </a>
						  
						      <button class="btn btn-primary" type="submit"> Enregistrer </button>
					
                          </form> 	
											
											
							</div>
						</div>
					</div>
				</div>
				
				
			</div>
		
			
			
    
@push('scripts') 

	 <script>
	
	    function selectAll (ch) {
			
			var tab = document.getElementsByTagName("input");
			
			for (var i = 0; i < tab.length; i++) {
				
				if (tab[i].type == "checkbox")
					
				   tab[i].checked = ch.checked;
				
			}
				
		}
	
	</script>
	 
@endpush

@endsection