

<script type='text/javascript'>


//validation and submit handling
$(document).ready(function()
{
    setTimeout(function(){$(":input:visible:first","#employee_form").focus();},100);
	$(".module_checkboxes").change(function()
	{
		if ($(this).prop('checked'))
		{
			$(this).parent().find('input[type=checkbox]').not(':disabled').prop('checked', true);
		}
		else
		{
			$(this).parent().find('input[type=checkbox]').not(':disabled').prop('checked', false);			
		}
	});

	
	});
	</script>
 
 <div class="row">
  
   	

   	<div class="col-md-12">

  
		

			
	<div class="widget-content nopadding table_holder table-responsive" >				
			
		

    <!-- Modal content-->
    <div class="modal-content">
      <div class="modal-header">
        <button type="button" class="close" data-dismiss="modal">&times;</button>
        <h4 class="modal-title">Update  User details </h4>
      </div>
      <div class="modal-body">
      
	  	

		
		
	<?PHP
	



 echo $this->session->flashdata('msg'); 
                  echo form_open('user/updateuserroles' , array('class' => 'form-horizontal form-groups-bordered validate',  'id' => 'signup','enctype' => 'multipart/form-data'));

		 if(validation_errors()):?>

<?php endif;?>
	 <input type="hidden" id="view"name="view" class="view" placeholder="view" value="user/viewroles">

<input type="hidden" name="myid" value="<?php echo $itemid; ?>"  id="myid" class="form-control" required placeholder="Enter status">


  <div class="form-group">

    <label for="inputname" class="col-sm-2 control-label">Role Name</label>
    <div class="col-sm-10">
		  		<input type="text" name="name" readonly value="<?php echo set_value('name',$role[0]['name']); ?>"id="name" class="form-control" required placeholder="Enter role name">
     <span class="text-danger"><?php echo form_error('name'); ?></span>
   </div>
  </div>
 
 
   
	
    <div class="form-group">
    <label for="inputusertype" class="col-sm-2 control-label">	ACCESS ROLES </label>
    <div class="col-sm-10">
	<div style="width:100%; margin: auto;">  
	 
  	<ul id="permission_list" class="list-unstyled">
  <?php
  
  
          		//$allmodules= $this->usermodel->populatealldata('modules','sort','ASC');

  	     $allmodules= $this->usermodel->populatealldatawhere('modules','sort','DESC','status','1');

  	
	


if(is_array($allmodules)) {

   foreach($allmodules as $mycategoryrow){
	  $moduleid= $mycategoryrow->id;
	  
	             		$allmymodules= $this->usermodel->populatealldatawhere('modulesactions','sort','ASC','moduleid',$moduleid);
if(is_array($allmymodules)) {
						$permissions= $this->usermodel->populatuserpermissionsroles($moduleid,$role[0]['id']);

	   ?>
	   	      <div class="pull-right radius-5px" style="width:23%; margin:2px; padding: 5px; border: 1px solid #ddd;">

	   <li>

	   <?php
	  if($permissions==true){
		     ?>
	   <input type="checkbox" name="permissions[]"  class="module_checkboxes"  value="<?php echo$mycategoryrow->id?>" checked="checked" class="module_checkboxes "  />	<span class="text-success"><?php echo$mycategoryrow->name ?>:</span>
	<?php
		
	  }else{
		      ?>
	   <input type="checkbox" name="permissions[]"  class="module_checkboxes" value="<?php echo$mycategoryrow->id?>" class="module_checkboxes "  />	<span class="text-success"><?php echo$mycategoryrow->name ?>:</span>
	<?php
		  
	  }
	   
	   ?>
	<?php
	 foreach($allmymodules as $row){
		 $actionid=$row->actionid;
		 						$permissionsaction= $this->usermodel->populatuserpermissionsactionsroles($moduleid,$role[0]['id'],$actionid);

	?>
	
	
	<ul>
													
											
													<li>
													
												
												
										   <?php
									
	  if($permissionsaction==true){
		     ?>

	 <input type="checkbox" name="permissionctions[]" value="<?php echo$row->actionid."|".$mycategoryrow->id?>" checked="checked" class="module_checkboxes "  />	<span class="text-success"><?php echo$row->name ?>:</span>
	<?php
		
	  }else{
		  
		      ?>

	 <input type="checkbox" name="permissionctions[]"  value="<?php echo$row->actionid."|".$mycategoryrow->id?>"   class="module_checkboxes "  />	<span class="text-success"><?php echo$row->name ?>:</span>
	<?php
		  
	  }
	   
	   ?>				
													
													
													
													
													
													
													
													
													
													
													

							</li>
								
							
												</ul>
												
	<?php
	}
	} else {
   
}
	
	?>
	  </li>
	  	</div>
<?php

}} else {
  
}
  
  
  
  
  ?>
  	</ul>
	</div>

  	</div>
  </div>

	 <div class="form-group">

    <div class="col-sm-offset-2 col-sm-10">
     
	         <button type="submit"  value="roles" name="btn_updateuserroles" class="btn btn-primary"> Update roles   </button>

    </div>
  </div>
   

 

			<?PHP
		echo form_close();
		
		?>
		
		
			
		
		
		
		
		
		
		
		
		
		
		
			</div>							   
				
									
							
								
			<div class="modal-footer">

    

				</div>

		</div>
	  						
									
									
									
									
							</div>
						</div>
				

			
			</div>



















