
<?php
//this page brings out a static form editing a user 



if($_POST['act'] == 'edit_staff')
{
	  $id_array = $_POST['staff']; // return array
	  $id_count = count($_POST['staff']); // count array
	  
	
	  
?>


<div class="well">

      <ul class="tabs"> 
        <li><a href="#view1" >Staff Details</a></li> 
      </ul> 
      <div class="tabcontents"> 
        <div id="view1"  class="row">
        

        <?php 
		
		for($i=0; $i < $id_count; $i++) 
		{
		  $id = $id_array[$i];
		  $q = "SELECT * FROM staff WHERE id = '$id'";
		  $r = mysqli_query(dbc(),$q);
				
		  if(!$r) { die(mysql_error()); }
		
			  
			  if(mysqli_num_rows($r) > 0)
			  {//begin if result exist
				  while($row = mysqli_fetch_array($r, MYSQLI_ASSOC))
				  {//begin while
		?>
        
        
        			<div class="col-lg-12">
            
            			<div class="col-lg-6">
        
        				<fieldset> 
                            <legend>EditUser <span class="ast">*</span> indicate required fields </legend>
      

        
        					<!-- form cut to the toolbar add user-->
               	    	<input type="hidden" name="MAX_FILE_SIZE" value="MAX_FILE_SIZE" />	
                        
                       
                                                  
                        <div class="form-group">
                              <label for="first_name" class="col-sm-2 control-label">First Name </label>
                              <div class="col-sm-10">
                              	<div class="input-group">
                                <input  id="first_name" class="form-control input-sm" type="text" placeholder="First Name"  name="first_name" 
                                value="<?php  echo $row['first_name']; ?>" required></input>
                                <div class="input-group-addon"> <span class="ast">*</span></div>
                                </div>
                                 
                              </div>
                           </div>
                           
                           
                            <div class="form-group">
                              <label for="other_names" class="col-sm-2 control-label">Other Names </label>
                              <div class="col-sm-10">
                              	<div class="input-group">
                                <input id="other_names" class="form-control input-sm" type="text" placeholder="Other Names" name="other_names" 
                                value="<?php  echo $row['other_names']; ?>" required></input>
                                  <div class="input-group-addon"> <span class="ast">*</span></div>
                                 </div>
                              </div>
                           </div>
                          
                   
                  <div class="form-group">
                          <label class="col-sm-2 control-label" for="gender">Gender</label>
                          <div class="col-sm-10">
                          <div class="input-group">
                             
                          <label class="radio-inline">
                              <input type= "radio" name="gender" value="M"  checked ></input>Male  
                          </label>
                          <label class="radio-inline">
                    
                              <input type= "radio" name="gender" value="F" <?php if($row['gender'] == 'F') echo "checked"; ?>></input>Female
                    
                          </label>
                      <div class="input-group-addon"> <span class="ast">*</span></div>
                    </div>
                   </div>
                 </div>
                 
                 <div class="form-group">
                    <label for="email" class="col-sm-2 control-label"> Email </label>
                    <div class="col-sm-10"> 
                    <div class="input-group">
                      <input id="email" class="form-control input-sm" type="text" placeholder="Email" name="email" required
                      
                       value="<?php echo $row['email']; ?>"></input>
                        
                       <div class="input-group-addon"> <span class="ast">*</span></div>
                       <span id="email_msg_box" style="display:none"></span>
                     </div>
                     
                    </div>
                 </div>	
                       
                  <div class="form-group">
                        
                      <label for="username" class="col-sm-2 control-label"> C Number/  Username </label>
                      <div class="col-sm-10">
                      
                      <div class="input-group">
                       <span class="input-group-addon"> @</span>
                         <input id="username" class="form-control input-sm" type="text" placeholder="Username" name="username" required
                        
                         value="<?php echo $row['username']; ?>"></input>
                         
                         <div class="input-group-addon"> <span class="ast">*</span></div> <span id="user_msg_box" style="display:none"></span>
                      
                        </div>
                      </div>
                   </div>	
                       	
              
              
              		   
                   <div class="form-group">
                      <label class="col-sm-2 control-label" for="group">Group</label>
                      <div class="col-sm-10">
                       <div class="input-group">
                        <select  class="form-control input-sm"  name="group"  id="group" required>
                         <!--  <option value="0">none</option> --><?php select_group($row['group_id']); ?>
                        </select>     
                       <div class="input-group-addon"> <span class="ast">*</span></div>
                      
                        </div>
                      </div>
                      
                    </div>
                    
                    <!-- <div class="form-group">
                          <label for="birthdate" class="col-sm-2 control-label">Birth-Date[YYYY-MM-DD] </label>
                          <div class="col-sm-10">
                           <div class="input-group">
                            <input id="datepicker4" class="form-control input-sm" type="text" placeholder="Birth date" name="birthdate" required
                            
                           // value="<?php //echo $row['birthdate'];?>"></input>
                            <div class="input-group-addon"> <span class="ast">*</span></div>
                          
                            </div>
                            
                          </div>
                       </div> -->
                 
                    
                    
                </div><!-- /col-lg-6 --> 

				<div class="col-lg-6">
                	<br/>
                	
              		 	<!-- <div class="form-group">
                        <label class="col-sm-2 control-label" for="image"> Image</label>
                        <div class="col-sm-10">
                         <div class="input-group">
                        <input    name="image" class="form-control input-sm"  type="file" ></input>
                         <div class="input-group-addon"> <span class="ast">*</span></div>
                        </div>
                        <span class="help-block"> Upload  Image less than 50kb. 	
                        <span class="ast"><?php //echo $errors['image_result_message']; ?></span></span>
					
                        
                        </div>
                      	</div>
                     -->  


                      <div class="form-group">
                            <label class="col-sm-2 control-label" for="department">Department</label>
                            <div class="col-sm-10">
                            
                              <select id="department" class="form-control input-sm" name="department" required>
                               <option value="0"> ---- Choose Department --- </option> 
                              <?php  echo select_department($row['department_id']); ?>
                                
                               </select>
                            
                                   
                                </div>
                            
                            </div>
                              
                            
                      
                       <div class="form-group">
                        <label class="col-sm-2 control-label" for="textarea">Address </label>
                          <div class="col-sm-10">
                          <textarea cols = "70" rows = "5" name="address" class="rte1" action="#" class="form-control" >
                  		 <?php echo $row['address'];?>
                   		</textarea>
                       </div>
                        </div>
                  
                  		<div class="form-group">
                          <label for="phone_number" class="col-sm-2 control-label">Phone Number</label>
                         <div class="col-sm-10">
                          <div class="input-group">
                            <input id="phone_number" class="form-control input-sm" type="telephone" placeholder="Phone Number" name="phone_number"
                           value="<?php echo $row['phone_number'];?>" required
                            ></input>
                             <div class="input-group-addon"> <span class="ast">*</span></div>
                        	</div>
                          </div>
                       </div>
                       
                       
                       <div class="form-group">
                              <label class="col-sm-2 control-label" for="user_status">User Status</label>
                              <div class="col-sm-10">
                              	<div class="input-group">
                                	<select  class="form-control input-sm" name="user_status"  id="user_status" required>
                                  	 <option value="1"  selected> Unblock </option>
                                  	 <option value="0" <?php if($row['user_status']=='0') echo "selected";?>> Block </option>
                               	    </select>
                                    <div class="input-group-addon"> <span class="ast">*</span></div>
                          		</div>
                         	  </div>
                         </div>
                         
                          <div class="form-group">
                          <label class="col-sm-2 control-label" for="gender">Status</label>
                          <div class="col-sm-10">
                          
                            <select id="status" class="form-control input-sm" name="status" required>
                              
                            <?php  echo select_status($_SESSION['status']); ?>
                              
                             </select>
                          
                             
                          </div>
                          
                        </div>	
                         
                       
             
                  
                  
                  
                        <input type="hidden" value="update_staff" name="act" />
                        <input type="hidden" value="TRUE" name="update_staff" /><!-- pass value for editing -->
                        <input type="hidden" value="<?php echo $row['id']; ?>" name="staff" id='staff' /><!-- pass id value incase he didnt fill well den bring bk for editing -->
                        <input type="hidden" value="TRUE" name="upload" /> <!-- for image upload -->
  
            
                  </div><!-- /col-lg- 6 -->
                  </fieldset>
              
                  </form>
                
                
               
			</div><!-- / col-lg -12 -->
        

	<?php
				  }//end of if
				  }//end of while
	
			  }//end of for loop
	?>

        
        </div>  <!-- #view1 -->
         
      </div> <!-- /tab-content -->
</div> <!-- /well-->
<?php 

}//end of if post edit user
?>
