<?php
session_start();
if(!isset ($_SESSION['user_id'])){
    header("Location:../login.php?msg=Log in first");
    exit();
}else{
	include('../Server/connection.php');
	include('includes/session.php');
?>


<!DOCTYPE html>
<html lang="en">
  <head>
    <meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
    <!-- Meta, title, CSS, favicons, etc. -->
    <meta charset="utf-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1">

    <?php
	include 'title.php';
	?>
	
		<link type = "image/png" rel="icon" href="images/brvision.png"/>
	
    <!-- Bootstrap must-->
    <link href="../vendors/bootstrap/dist/css/bootstrap.min.css" rel="stylesheet">
	
    <!-- Font Awesome must-->
    <link href="../vendors/font-awesome/css/font-awesome.min.css" rel="stylesheet">
	
	<!-- custom css -->
    <link rel="stylesheet" href="custom/css/custom.css">
	
    <!-- NProgress must-->
    <link href="../vendors/nprogress/nprogress.css" rel="stylesheet">
	
    <!-- Custom Theme Style must-->
    <link href="../build/css/custom.min.css" rel="stylesheet">
	
	<!-- must-->
	<script src="assests/jquery/jquery.min.js"></script>
	
	<script type="text/javascript" src="https://ajax.aspnetcdn.com/ajax/jquery.validate/1.13.1/jquery.validate.min.js"></script>
    <script type="text/javascript" src="https://ajax.aspnetcdn.com/ajax/jquery.validate/1.13.1/additional-methods.min.js"></script>
	
  <!-- jquery ui must-->  
  <link rel="stylesheet" href="assests/jquery-ui/jquery-ui.min.css">
  <script src="assests/jquery-ui/jquery-ui.min.js"></script>
	
 
	
	<style>
  .error {
    color: #F00;
}  

</style>
	
  </head>

  <body class="nav-md">
  
    <div class="container body">
	
    <?php
	//include 'header.php';
	?>
	
      <div class="main_container">
        <div class="col-md-3 left_col">
          <div class="left_col scroll-view">
		  
            <?php  
		include 'includes/role.php';
               ?>

            <div class="clearfix"></div>
            
			<?php
            include 'includes/profile.php';
			print '</br></br>';
			include 'includes/menu.php';
			?>

           

        <!-- page content -->
        <div class="right_col" role="main">
          <div class="">
		  
			
			
            <div class="clearfix"></div>

            <div class="row">
              <div class="col-md-12 col-sm-12 col-xs-12">
                <div class="x_panel">
                  <div class="x_title">
				  
                    <a href="dashboard.php">  <h2><span class="glyphicon glyphicon-step-backward"></span> Back</h2></a>
					
					
                    <ul class="nav navbar-right panel_toolbox">
                      <li><a class="collapse-link"><i class="fa fa-chevron-up"></i></a>
                      </li>
                      
                     
                    </ul>
                    <div class="clearfix"></div>
                  </div>
                  <div class="x_content" style="overflow: auto;">
				  
				  <?php if (isset($_SESSION['success_message']) && !empty($_SESSION['success_message'])) { ?>
                        <div class="success-message" style="margin-bottom: 20px;font-size: 20px;color: green;"><?php echo $_SESSION['success_message']; ?></div>
                        <?php
                        unset($_SESSION['success_message']);
                    }
                    ?>	

                    <form action="php_action/request_Leave.php"  id="id_frm" method="post" enctype="multipart/form-data" class="form-horizontal form-label-left">

                      <span class="section">Grant Staff Leave </span>
					  
					    <div class="item form-group">
                        <label for="password" class="control-label col-md-3">Leave Type</label>
                        <div class="col-md-6 col-sm-6 col-xs-12">
						
						  <?php
							$sql421 = "SELECT * FROM leave_type";	
        $result421 = $conn->query($sql421); 
		while ($row421 = mysqli_fetch_array($result421))
		{
			$leaveTypeId = $row421['leaveType_id'];
			$leaveType = $row421['type'];
	
		?>
						<label class="radio-inline">
						<input  type="radio"  id="leavetype_id" name="leavetype_id" value="<?php echo $row421['leaveType_id'] ?>" <?php if($leaveTypeId==1){ echo "checked";}?> />&nbsp<?php echo $leaveType; ?>
						</label>
						
						
						
						<?php
		                }
						?>
                         
                        </div>
                      </div>
					  
					<div id="textboxes1">
					 
					 <div class="item form-group">
                        <label for="password" class="control-label col-md-3">List Of Current Staff</label>
                        <div class="col-md-6 col-sm-6 col-xs-12">
						
						  <select class="form-control" name="staff_id" id="staff_id" autocomplete="off">
			  						<option value="">~~SELECT~~</option>
			  						<?php
			  							$productSql = "SELECT * FROM staff,designation where status_id=1 and staff.des_id=designation.des_id ORDER BY firstname";
			  							$productData = $conn->query($productSql);
			  							while($row = $productData->fetch_array()){									 		
			  								echo "<option value='".$row['staff_id']."'>".$row['firstname']."&nbsp&nbsp&nbsp".$row['lastname']."&nbsp&nbsp&nbsp(".$row['des_name'].")&nbsp&nbsp&nbsp"."</option>";
										 	} // /while 

			  						?>
		  						</select>
								<br/>
                         <label for="staff_id" class="error" generated="true"></label>
                         
                        </div>
                      </div>
					  
					  </div>
					  
					  <div id="textboxes2" style="display: none">
					 
					 <div class="item form-group">
                        <label for="password" class="control-label col-md-3">List Of Current Female Staff</label>
                        <div class="col-md-6 col-sm-6 col-xs-12">
						
						  <select class="form-control" name="staff_id1" id="staff_id1" autocomplete="off">
			  						<option value="">~~SELECT~~</option>
			  						<?php
			  							$productSql4 = "SELECT * FROM staff,designation where status_id=1 and gender_id=2 and staff.des_id=designation.des_id ORDER BY firstname";
			  							$productData4 = $conn->query($productSql4);
			  							while($row4 = $productData4->fetch_array()){									 		
			  								echo "<option value='".$row4['staff_id']."'>".$row4['firstname']."&nbsp&nbsp&nbsp".$row4['lastname']."&nbsp&nbsp&nbsp(".$row4['des_name'].")&nbsp&nbsp&nbsp"."</option>";
										 	} // /while 

			  						?>
		  						</select>
								<br/>
                         <label for="staff_id1" class="error" generated="true"></label>
                         
                        </div>
                      </div>
					  
					  </div>
					  
					  <div id="textboxes3" style="display: none">
					 
					 <div class="item form-group">
                        <label for="password" class="control-label col-md-3">List Of Current Male Staff</label>
                        <div class="col-md-6 col-sm-6 col-xs-12">
						
						  <select class="form-control" name="staff_id2" id="staff_id2" autocomplete="off">
			  						<option value="">~~SELECT~~</option>
			  						<?php
			  							$productSql46 = "SELECT * FROM staff,designation where status_id=1 and gender_id=1 and staff.des_id=designation.des_id ORDER BY firstname";
			  							$productData46 = $conn->query($productSql46);
			  							while($row46 = $productData46->fetch_array()){									 		
			  								echo "<option value='".$row46['staff_id']."'>".$row46['firstname']."&nbsp&nbsp&nbsp".$row46['lastname']."&nbsp&nbsp&nbsp(".$row46['des_name'].")&nbsp&nbsp&nbsp"."</option>";
										 	} // /while 

			  						?>
		  						</select>
								<br/>
                         <label for="staff_id2" class="error" generated="true"></label>
                         
                        </div>
                      </div>
					  
					  </div>
					  
					  
					  <div class="item form-group">
                        <label for="password" class="control-label col-md-3">Leave Start Date</label>
                        <div class="col-md-6 col-sm-6 col-xs-12">
                          
                       <input type="text" class="form-control" id="leaveDate" placeholder="Leave Start Date" name="leaveDate" autocomplete="off">
						  <br/>
                         <label for="leaveDate" class="error" generated="true"></label>
						</div>
                      </div>
					  
					 
					  
					  <div class="item form-group">
                        <label for="password" class="control-label col-md-3">Remarks </label>
                        <div class="col-md-6 col-sm-6 col-xs-12">
						
						<textarea id="remarks" rows="10" cols="50" name="remarks" class="form-control" style="margin-left:0%;" autocomplete="off"> </textarea>
			            
                          
                       
						  
						</div>
                      </div>
					  
					  <div class="item form-group">
                        <label for="password" class="control-label col-md-3"> Upload Document (s) </label>
                        <div class="col-md-6 col-sm-6 col-xs-12">
						
						
                 		 <label class="radio-inline">
          <input type="radio" name="upl_status" value="Yes" id="upl_status"> Yes
         </label>&nbsp&nbsp&nbsp&nbsp
         <label class="radio-inline">
          <input type="radio" name="upl_status" value="No" id="upl_status" checked> No
         </label>&nbsp&nbsp&nbsp&nbsp
		 
		
		
		<div id="textboxes" style="display: none">		
		     
			  <input  type="file" name="file[]"  id="file" class="form-control" style="width:100%;margin-left:0%;" multiple>
			  
			   <br/>
        <label for="file" class="error" generated="true"></label>
			 
			</div>	
                          
                       
						  
						</div>
                      </div>
					 
					
					  
					 
					  
					  <div class="ln_solid"></div>
                      <div class="form-group">
                        <div class="col-md-6 col-md-offset-3">
						  <button class="btn btn-success"><span class="glyphicon glyphicon-registration-save"> </span> Submit </button>
                        </div>
                      </div>
                    </form>
					
			
					
                  </div>
                </div>
              </div>
            </div>
          </div>
        </div>
        <!-- /page content -->

		<?php
		include 'includes/footer.php';
		?>
		
        
      </div>
    </div>
	
	
	
	<script>
	
	$(document).ready(function(){
    $('input[name="leavetype_id"]').on('click', function(){
        if ($(this).val() == 1){
			 $('#textboxes1').show();
			 $('#textboxes2').hide();
			 $('#textboxes3').hide();
        }else if($(this).val() == 2){
			 $('#textboxes2').show();
			 $('#textboxes1').hide();
			 $('#textboxes3').hide();
		}else {
			$('#textboxes3').show();
			$('#textboxes1').hide();
			$('#textboxes2').hide();
		}
	
		
    });
});
	
	$(document).ready(function(){
    $('input[name="upl_status"]').on('click', function(){
        if ($(this).val() == 'Yes'){
			 $('#textboxes').show();
        }else {
			$('#textboxes').hide();
		}
	
		
    });
});



 $("#id_frm").validate({
        rules: {
			
			"staff_id": {
                required: true
            },
			
			"staff_id1": {
                required: true
            },
			
			"staff_id2": {
                required: true
            },
			
			"leaveDate": {
                required: true
            }
		
		 
        },
        messages: {
			
			"staff_id": {
                required: "Please Select Staff."
            },
			
			"staff_id1": {
                required: "Please Select Staff."
            },
			
			"staff_id2": {
                required: "Please Select Staff."
            },
			
			"leaveDate": {
                required: "Please Enter Suspension Date."
            }
        },
        // for demo
        //submitHandler: function(form) {
            //alert('valid form');
            //return false;
        //}
 });
 
 
 
 
</script>

   <script>
	// order date picker
		$("#leaveDate").datepicker();
		
		// delivery date picker
		//$("#suspensionEndDate").datepicker();
		
		//$("#editBirthDate").datepicker();
		
		//$("#editEmployDate").datepicker();
		
		
	
	</script>
	
	
	<script>
	
	</script>
	
    
    <!-- Bootstrap -->
    <script src="../vendors/bootstrap/dist/js/bootstrap.min.js"></script>
	
	
    <!-- FastClick -->
    <script src="../vendors/fastclick/lib/fastclick.js"></script>
    <!-- NProgress -->
    <script src="../vendors/nprogress/nprogress.js"></script>
	
    <!-- validator -->
    <!--<script src="../vendors/validator/validator.js"></script>-->
	
	<!-- bootstrap-daterangepicker -->
    <script src="../vendors/moment/min/moment.min.js"></script>
	
	<!-- bootstrap-datetimepicker -->    
    <script src="../vendors/bootstrap-datetimepicker/build/js/bootstrap-datetimepicker.min.js"></script>

    <!-- Custom Theme Scripts -->
    <script src="../build/js/custom.min.js"></script>
	
	
	
  </body>
</html>



<?php
}
?>