

<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/updatemyuser' , 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/viewemployee">

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


  <div class="form-group">

    <label for="inputsurname" class="col-sm-2 control-label">Last Name</label>
    <div class="col-sm-10">
		  		<input type="text" name="surname" value="<?php echo set_value('surname',$member[0]['surname']); ?>"id="surname" class="form-control" required placeholder="Enter your surname">
     <span class="text-danger"><?php echo form_error('surname'); ?></span>
   </div>
  </div>
    <div class="form-group">
    <label for="inputfirstname" class="col-sm-2 control-label">First Name</label>
    <div class="col-sm-10">
		<input type="text" name="firstname" value="<?php echo set_value('firstname',$member[0]['firstname']) ;?>" id="firstname" class="form-control" required placeholder="Enter your Other Names">
       <span class="text-danger"><?php echo form_error('firstname'); ?></span>
   </div>
  </div>
  
  
     <div class="form-group">
    <label for="inputphone" class="col-sm-2 control-label">Phone Number</label>
    <div class="col-sm-10">
		<input type="text" name="phone" value="<?php echo set_value('phone',$member[0]['phone']) ;?>" id="firstname" class="form-control" required placeholder="Enter your phone Number e.g 25716567890">
       <span class="text-danger"><?php echo form_error('phone'); ?></span>
   </div>
  </div>
  
  
  
     
   	<div class="form-group">
    <label for="inputgender" class="col-sm-2 control-label">	Gender	 </label>
    <div class="col-sm-10">
	
	<select class="form-control" name="gender" >
		<option selected="selectted" value="<?php echo $member[0]['gender']?>"  ><?php echo$member[0]['gender']?></option>
	<option value=""  >---Select Gender---</option>
	<option value="female"  >female</option>
		<option value="male"  >male</option>
	</select>		 
				
		<span class="text-danger"> <?php echo form_error('gender'); ?>
		
		</span>
	</div>
	
	</div>

  

 
 <div class="form-group" >
    <label for="inputidno" class="col-sm-2 control-label">		ID Number	 </label>
    <div class="col-sm-10">
	
		  		<input type="text" name="idno" value="<?php echo set_value('idno',$member[0]['idno']); ?>" class="form-control"  placeholder="Enter  ID Number">
		 
				
		<span class="text-danger"> <?php echo form_error('idno'); ?>
		
		</span>
	</div>
  </div>
 
   	<div class="form-group" >
    <label for="inputidno" class="col-sm-2 control-label">	Pin Number		 </label>
    <div class="col-sm-10">
	
		  		<input type="text" name="idnumber" value="<?php echo set_value('idnumber',$member[0]['idnumber']); ?>" class="form-control"  placeholder="Enter Pin ">
		 
				
		<span class="text-danger"> <?php echo form_error('idno'); ?>
		
		</span>
	</div>
  </div>
 
  <div class="form-group">
    <label for="inputstatus" class="col-sm-2 control-label">	Status	 </label>
    <div class="col-sm-10">
	
	<select class="form-control" name="status" required>
		<option selected="selectted" value="<?php echo $member[0]['status']?>"  ><?php $mymember=$member[0]['status']; if($mymember=="1"){echo "active";}else if($mymember=="0"){ echo "inactive";} ?></option>
	<option value=""  >---Select status---</option>
	<option value="1"  >active</option>
		<option value="0"  >inactive</option>
	</select>		 
				
		<span class="text-danger"> <?php echo form_error('gender'); ?>
		
		</span>
	</div>
  </div>
  
  
    <div class="form-group">
    <label for="inputemail" class="col-sm-2 control-label">Email</label>
    <div class="col-sm-10">
				<input type="text"  name="email" value="<?php echo set_value('email',$member[0]['email']) ;?>" id="email" class="form-control" required placeholder="Enter Your email">
    <span class="text-danger"><?php echo form_error('email'); ?></span>
	</div>
  </div>

 
    <div class="form-group">
    <label for="inputpassword" class="col-sm-2 control-label">Password</label>
    <div class="col-sm-10">
				<input type="password"  name="password" value="<?php echo set_value('password',$member[0]['password']) ;?>" id="email" class="form-control" required placeholder="Enter Your Password">
    <span class="text-danger"><?php echo form_error('password'); ?></span>
	</div>
  </div>
  
 
	  <div class="form-group">
    <label for="inputusertype" class="col-sm-2 control-label">	User type	 </label>
    <div class="col-sm-10">
	
	<select class="form-control" name="usertype" required>
		<option value="" selected="selected" >---Select User type---</option>

			<option selected="selectted" value="<?php echo $member[0]['usertype']?>"  ><?php echo $member[0]['usertype']?></option>

		<option  value="user">user</option>
		<option value="admin"  >admin</option>
			<option value="superadmin"  >superadmin</option>
	</select>		 
				
		<span class="text-danger"> <?php echo form_error('usertype'); ?>
		
		</span>
	</div>
  </div>
  
	  <div class="form-group">
    <label for="inputusertype" class="col-sm-2 control-label">	User category	 </label>
    <div class="col-sm-10">
  <select class="form-control" name="category" id="category" >
		<option selected="selected" value="<?php echo set_value('category',$member[0]['category']); ?>"  ><?php echo set_value('category',$member[0]['category']); ?></option>

	<option value=""  >---Select category---</option>
	<option value="member"  >Customer</option>
		<option value="supplier"  >Supplier</option>
												<option value="accomodation" >Accomodation</option>
				<option value="user"  >Employee</option>

	</select>		 
				
		<span class="text-danger"> <?php echo form_error('category'); ?>
		
		</span>
	</div>
  </div>
  	
	<div class="form-group">
    <label for="inputcode" class="col-sm-2 control-label">	Account Limit	 </label>
    <div class="col-sm-10">
	
		  		<input type="text" name="code" value="<?php echo set_value('code',$member[0]['code']); ?>" class="form-control"  placeholder="Enter amount limit per day if any ">
		 
				
		<span class="text-danger"> <?php echo form_error('code'); ?>
		
		</span>
	</div>
  </div>
 
 
 	<div class="form-group">
    <label for="inputrate" class="col-sm-2 control-label">	Commission	 </label>
    <div class="col-sm-10">
	
		  		<input type="text" name="rate" value="<?php echo set_value('rate',$member[0]['rate']); ?>" class="form-control"  placeholder="Enter rate ">
		 
				
		<span class="text-danger"> <?php echo form_error('rate'); ?>
		
		</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->populatuserpermissions($moduleid,$member[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->populatuserpermissionsactions($moduleid,$member[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="user" name="btn_updatemyuser" class="btn btn-primary"> Update user   </button>

    </div>
  </div>
   

 

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

    

				</div>

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

			
			</div>



















