<?php
include('../include/header.php');
?>

 <!-- Page wrapper  -->
        <div class="page-wrapper">
            <!-- Bread crumb -->
            <div class="row page-titles">
                <div class="col-md-5 align-self-center">
                    <h3 class="text-primary"></h3> </div>
                <div class="col-md-7 align-self-center">
                    <ol class="breadcrumb">
                        <li class="breadcrumb-item"><a href="javascript:void(0)">Home</a></li>
                        <li class="breadcrumb-item active">Add Leave Request</li>
                    </ol>
                </div>
            </div>
            <!-- End Bread crumb -->
            <!-- Container fluid  -->
           <div class="container-fluid">
                <!-- Start Page Content -->
                <div class="row justify-content-center">
                    <div class="col-lg-6">
                        <div class="card">
                            <div class="card-body">
                                <div class="form-validation">
                                    <form class="form-valide" method="post">
									<?php 
									
									?>
                                        <div class="form-group row">
                                            <label class="col-lg-4 col-form-label" for="val-username">Leave Detail<span class="text-danger">*</span></label>
                                            <div class="col-lg-6">
                                                <textarea class="form-control" name="leave_detail" id="leave_detail" required style="height:150px;" ></textarea>
                                            </div>
                                        </div>
										
										<div class="form-group row">
                                            <label class="col-lg-4 col-form-label" for="val-username">Leave Type<span class="text-danger">*</span></label>
                                            <div class="col-lg-6">
                                                <select  class="form-control" name="leave_type" id="leave_type" required >
												<option value="">Select</option>
												<?php
												 $sql2 = "select *from tbl_leave_type ";
						$result2 = $objhr->viewdata($sql2);
							
							while($rows2 = $result2->fetch_assoc()){
												?>
												<option value="<?php echo $rows2['id']; ?>"><?php echo strtoupper($rows2['leave_type']); ?></option>
												<?php } ?>
												</select>
                                            </div>
                                        </div>
										
										<div class="form-group row">
                                            <label class="col-lg-4 col-form-label" for="val-username">From<span class="text-danger">*</span></label>
                                            <div class="col-lg-6">
                                                <input type="date" class="form-control" name="from_date" id="from_date" required >
                                            </div>
                                        </div>
										
										<div class="form-group row">
                                            <label class="col-lg-4 col-form-label" for="val-username">To<span class="text-danger">*</span></label>
                                            <div class="col-lg-6">
                                                <input type="date" class="form-control" name="to_date" id="to_date" required >
                                            </div>
                                        </div>
                                        
                                        <div class="form-group row">
                                            <div class="col-lg-8 ml-auto">
                                                <button type="submit" class="btn btn-primary" name="save">Send</button>
                                            </div>
                                        </div>
                                    </form>
                                </div>

                            </div>
                        </div>
                    </div>
                </div>
                <!-- End PAge Content -->
            </div>
			
<?php 

if(isset($_POST["save"]))
	{
		$leave_detail = $_POST["leave_detail"];
		$leave_type = $_POST["leave_type"];
		$date1 = $_POST["from_date"];
		$date2 = $_POST["to_date"];

		$sql_insert = "INSERT INTO tbl_leave_request (emp_id, leave_detail, leave_type, from_date, to_date, request_to) VALUES ('".$row_emp['emp_id']."', '$leave_detail', '$leave_type', '$date1', '$date2', '".$row_li['leader_id']."');";
		$result_insert = $objhr->insertion($sql_insert);
		?>
		<script>
		alert('Sended Request');
		location='';
		</script>
		<?php
		
	}
?>
<?php
include('../include/footer.php');
?>