<?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 -->
    <link href="../vendors/bootstrap/dist/css/bootstrap.min.css" rel="stylesheet">
    <!-- Font Awesome -->
    <link href="../vendors/font-awesome/css/font-awesome.min.css" rel="stylesheet">
    <!-- NProgress -->
    <link href="../vendors/nprogress/nprogress.css" rel="stylesheet">
	
	 <!-- bootstrap-daterangepicker -->
    <link href="../vendors/bootstrap-daterangepicker/daterangepicker.css" rel="stylesheet">
    <!-- bootstrap-datetimepicker -->
    <link href="../vendors/bootstrap-datetimepicker/build/css/bootstrap-datetimepicker.css" rel="stylesheet">
	
	<!-- bootstrap-datetimepicker -->
    <link href="../vendors/bootstrap-datetimepicker/build/css/bootstrap-datetimepicker.css" rel="stylesheet">
    
    <!-- Custom Theme Style -->
    <link href="../build/css/custom.min.css" rel="stylesheet">
	
	<!-- jQuery -->
    <script src="../vendors/jquery/dist/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>
	
  
	
	<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
				   $query154 = "select * from staff where staff_id='$staff_id'";
                   $result154 = $conn->query($query154);
                   $row154 = $result154->fetch_array();
                   $genderId = $row154['gender_id'];
                    ?>
				  
				  <?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" name="id_frm" method="post" enctype="multipart/form-data" class="form-horizontal form-label-left"  >

                    <span class="section"> Request Leave </span>
					
					<?php
					if($genderId==1){
					?>
			   
			   
					 <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">
						
						  <select class="form-control" name="leaveType_id" id="leaveType_id" autocomplete="off">
			  						<option value="">~~SELECT~~</option>
			  						<?php
			  							$productSql = "SELECT * FROM leave_type where leaveType_id!='2' ORDER BY type";
			  							$productData = $conn->query($productSql);
			  							while($row = $productData->fetch_array()){									 		
			  								echo "<option value='".$row['leaveType_id']."'>".$row['type']."</option>";
										 	} // /while 

			  						?>
		  						</select>
								<br/>
                         <label for="leaveType_id" class="error" generated="true"></label>
                         
                        </div>
                      </div>
					  
					  <?php
					}else{
					  ?>
					  
					  <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">
						
						  <select class="form-control" name="leaveType_id" id="leaveType_id" autocomplete="off">
			  						<option value="">~~SELECT~~</option>
			  						<?php
			  							$productSql = "SELECT * FROM leave_type where leaveType_id!='3' ORDER BY type";
			  							$productData = $conn->query($productSql);
			  							while($row = $productData->fetch_array()){									 		
			  								echo "<option value='".$row['leaveType_id']."'>".$row['type']."</option>";
										 	} // /while 

			  						?>
		  						</select>
								<br/>
                         <label for="itemType_id" class="error" generated="true"></label>
                         
                        </div>
                      </div>
					  
					  <?php
                       }
					  ?>
					  
					  <div id="comments" style="display:none">
					  
					   <div class="item form-group">
                        <label for="password" class="control-label col-md-3"> Total Working Days Requested</label>
					  	
                        <div class="col-md-6 col-sm-6 col-xs-12">
						
						<input  type="number" style="width:100%;margin-left:0%;" placeholder="Total Working Days Requested" name="days_requested_annual" id = "days_requested_annual" min="1" max="28" class="form-control col-md-7 col-xs-12">
						  <br/>
                         <label for="days_requested_annual" class="error" generated="true"></label>
						
						</div>
						</div>
					  
					
					
					 
					  </div>
					  
					  <div id="comments1" style="display:none">
					  
					   <div class="item form-group">
                        <label for="password" class="control-label col-md-3"> Total Working Days Requested</label>
					  	
                        <div class="col-md-6 col-sm-6 col-xs-12">
						
						<input  type="number" style="width:100%;margin-left:0%;" placeholder="Total Working Days Requested" name="days_requested_maternity" id = "days_requested_maternity" min="1" max="100" class="form-control col-md-7 col-xs-12">
						   <br/>
                         <label for="days_requested_maternity" class="error" generated="true"></label>
						
						</div>
						</div>
					  
					  
					 
					  </div>
					  
					  <div id="comments2" style="display:none">
					  
					   <div class="item form-group">
                        <label for="password" class="control-label col-md-3"> Total Working Days Requested</label>
					  	
                        <div class="col-md-6 col-sm-6 col-xs-12">
						
						<input  type="number" style="width:100%;margin-left:0%;" placeholder="Total Working Days Requested" name="days_requested_paternity" id = "days_requested_paternity" min="1" max="7" class="form-control col-md-7 col-xs-12">
						  <br/>
                         <label for="days_requested_paternity" class="error" generated="true"></label>
						
						</div>
						</div>

					  </div>
					  
					  <div id="comments3" style="display:none">
					  
					   <div class="item form-group">
                        <label for="password" class="control-label col-md-3"> Total Working Days Requested</label>
					  	
                        <div class="col-md-6 col-sm-6 col-xs-12">
						
						<input  type="number" style="width:100%;margin-left:0%;" placeholder="Total Working Days Requested" name="days_requested" id = "days_requested" min="1"  class="form-control col-md-7 col-xs-12">
						  <br/>
                         <label for="days_requested" class="error" generated="true"></label>
						
						</div>
						</div>
					  
					  
					  
					 
					
					 
					  </div>
					  
					  
					   <div class="item form-group">
                        <label for="password" class="control-label col-md-3"> Reasons For Leave </label>
                        <div class="col-md-6 col-sm-6 col-xs-12">
						
						<textarea id="leave_remarks" rows="10" cols="50" name="leave_remarks" class="form-control" style="margin-left:0%;" autocomplete="off"> </textarea>
			            <br/>
                         <label for="leave_remarks" class="error" generated="true"></label>
                          
						</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>	
	//jquery
$(document).ready(function () {

    $('#id_frm select[name="leaveType_id"]').change(function () {

        if ($('#id_frm select[name="leaveType_id"] option:selected').val() == 1) {
            $('#comments').show();
             $('#comments1').hide();
			 $('#comments2').hide();
			 $('#comments3').hide();
        }else if($('#id_frm select[name="leaveType_id"] option:selected').val() == 2){
			 $('#comments1').show();
			  $('#comments').hide();
			  $('#comments2').hide();
			  $('#comments3').hide();
		}else if($('#id_frm select[name="leaveType_id"] option:selected').val() == 3){
			 $('#comments2').show();
			  $('#comments').hide();
			  $('#comments1').hide();
			  $('#comments3').hide();
		}else {
            $('#comments3').show();
            $('#comments').hide();
			$('#comments1').hide();
			$('#comments2').hide();
        }

    });

    });
</script>


<script>	
	//jquery
$(document).ready(function () {

    $('#id_frm select[name="veh_owner_id"]').change(function () {

        if ($('#id_frm select[name="veh_owner_id"] option:selected').val() == 1) {

            //$('#comment').show();
             $('#comment1').hide();
        }else if($('#id_frm select[name="veh_owner_id"] option:selected').val() == 2){
			 $('#comment1').show();
			  //$('#comment').hide();
		}
		

    });

    });
</script>
	
	
	<script>
	
 $("#id_frm").validate({
        rules: {
			
			"leaveType_id": {
                required: true
            },
			
			"days_requested_annual": {
                required: true
            },
			
			"days_requested_paternity": {
                required: true
            },
			
			"days_requested_maternity": {
                required: true
            },
			
			"days_requested": {
                required: true
            },
			
			"leave_remarks": {
                required: true
            },
			
			"vehicle_model_id": {
                required: true
            },
			
			"vehicle_color_id": {
                required: true
            },
			
			"veh_owner_id": {
                required: true
            },
			
			"fuel_id": {
                required: true
            },
			
			"asset_remarks": {
                required: true
            },
			
			"owner_first_name": {
                required: true
            },
			
			"owner_middle_name": {
                required: true
            },
			
			"owner_last_name": {
                required: true
            },
			
			"owner_phone_number": {
                required: true
            },
			
			"owner_email_address": {
                required: true
            },
			
			
			"vehicle_remarks": {
                required: true
            }
		 
        },
        messages: {
			
			"leaveType_id": {
                required: "Please Select Leave Type."
            },
			
			"days_requested_annual": {
                required: "Please Enter No Of Days."
            },
			
			"days_requested_paternity": {
                required: "Please Enter No Of Days."
            },
			
			"days_requested_maternity": {
                required: "Please Enter No Of Days."
            },
			
			"days_requested": {
                required: "Please Enter No Of Days."
            },
			
			"leave_remarks": {
                required: "Please Enter Reasons For Leave."
            },
			
			"vehicle_model_id": {
                required: "Please Select Vehicle Model."
            },
			
			"vehicle_color_id": {
                required: "Please Select Vehicle Color."
            },
			
			"veh_owner_id": {
                required: "Please Select Vehicle Owner."
            },
			
			"fuel_id": {
                required: "Please Select Vehicle Fuel."
            },
			
			"asset_remarks": {
                required: "Please Enter Remarks"
            },
			
			"owner_first_name": {
                required: "Please Enter Owner First Name"
            },
			
			"owner_middle_name": {
                required: "Please Enter Owner Middle Name"
            },
			
			"owner_last_name": {
                required: "Please Enter Owner Last Name"
            },
			
			"owner_phone_number": {
                required: "Please Enter Owner Phone Number"
            },
			
			"owner_email_address": {
                required: "Please Enter Owner Email Address"
            },
			
			
			"vehicle_remarks": {
                required: "Please Enter Remarks"
            }
			
			
        },
        // for demo
        //submitHandler: function(form) {
            //alert('valid form');
            //return false;
        //}
 });
</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
}
?>