 <?php

include('../include/header.php');
$leave_id = $_REQUEST['leave_id'];
 $sql2 = "select *from tbl_leave_request where md5(id)= '$leave_id' ";
						$result2 = $objhr->viewdata($sql2);
							
							$rows2 = $result2->fetch_assoc();
	
?>

<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">Leave Detail</li>
                    </ol>
                </div>
            </div>
            <!-- End Bread crumb -->
            <!-- Container fluid  -->
            <div class="container-fluid">
                <!-- Start Page Content -->
                <div class="row">
                    <div class="col-12">
                        <div class="card">
                            <div class="card-body">
                                <div class="card-content">
                                    <!-- Left sidebar -->
                                    <div class="inbox-leftbar">

                                        <a href="view_leave_request.php" class="btn btn-danger btn-block waves-effect waves-light">Back</a>

                                        <div class="mail-list mt-4">
                                            <a href="view_leave_request.php" class="list-group-item border-0 text-danger"><i class="mdi mdi-inbox font-18 align-middle mr-2"></i><b>Inbox</b></a>
                                            <a href="#" class="list-group-item border-0"><i class="mdi mdi-star font-18 align-middle mr-2"></i>Starred</a>
                                            <a href="#" class="list-group-item border-0"><i class="mdi mdi-file-document-box font-18 align-middle mr-2"></i>Draft</a>
                                            <a href="#" class="list-group-item border-0"><i class="mdi mdi-send font-18 align-middle mr-2"></i>Sent Mail</a>
                                            <a href="#" class="list-group-item border-0"><i class="mdi mdi-delete font-18 align-middle mr-2"></i>Trash</a>
                                        </div>

                                        <h6 class="mt-5 m-b-15">Labels</h6>

                                        <div class="list-group b-0 mail-list">
                                            <a href="#" class="list-group-item border-0"><span class="fa fa-circle text-info mr-2"></span>Web App</a>
                                            <a href="#" class="list-group-item border-0"><span class="fa fa-circle text-warning mr-2"></span>Project 1</a>
                                            <a href="#" class="list-group-item border-0"><span class="fa fa-circle text-purple mr-2"></span>Project 2</a>
                                            <a href="#" class="list-group-item border-0"><span class="fa fa-circle text-pink mr-2"></span>Friends</a>
                                            <a href="#" class="list-group-item border-0"><span class="fa fa-circle text-success mr-2"></span>Family</a>
                                        </div>

                                    </div>
                                    <!-- End Left sidebar -->
                                    <div class="inbox-rightbar">

                                        <div class="m-t-10 m-b-20" role="toolbar">
                                            <div class="btn-group">
                                                <button type="button" class="btn btn-light waves-effect"><i class="mdi mdi-archive font-18 vertical-middle"></i></button>
                                                <button type="button" class="btn btn-light waves-effect"><i class="mdi mdi-alert-octagon font-18 vertical-middle"></i></button>
                                                <button type="button" class="btn btn-light waves-effect"><i class="mdi mdi-delete-variant font-18 vertical-middle"></i></button>
                                            </div>
                                            <div class="btn-group">
                                                <button type="button" class="btn btn-light dropdown-toggle waves-effect" data-toggle="dropdown" aria-expanded="false">
                                                                                    <i class="mdi mdi-folder font-18 vertical-middle"></i>
                                                                                    <b class="caret m-l-5"></b>
                                                                                </button>
                                                <div class="dropdown-menu">
                                                    <span class="dropdown-header">Move to</span>
                                                    <a class="dropdown-item" href="javascript: void(0);">Social</a>
                                                    <a class="dropdown-item" href="javascript: void(0);">Promotions</a>
                                                    <a class="dropdown-item" href="javascript: void(0);">Updates</a>
                                                    <a class="dropdown-item" href="javascript: void(0);">Forums</a>
                                                </div>
                                            </div>
                                            <div class="btn-group">
                                                <button type="button" class="btn btn-light dropdown-toggle waves-effect" data-toggle="dropdown" aria-expanded="false">
                                                                                    <i class="mdi mdi-label font-18 vertical-middle"></i>
                                                                                    <b class="caret m-l-5"></b>
                                                                                </button>
                                                <div class="dropdown-menu">
                                                    <span class="dropdown-header">Label as:</span>
                                                    <a class="dropdown-item" href="javascript: void(0);">Updates</a>
                                                    <a class="dropdown-item" href="javascript: void(0);">Social</a>
                                                    <a class="dropdown-item" href="javascript: void(0);">Promotions</a>
                                                    <a class="dropdown-item" href="javascript: void(0);">Forums</a>
                                                </div>
                                            </div>

                                            <div class="btn-group">
                                                <button type="button" class="btn btn-light dropdown-toggle waves-effect" data-toggle="dropdown" aria-expanded="false">
                                                                                    More
                                                                                    <span class="caret m-l-5"></span>
                                                                                </button>
                                                <div class="dropdown-menu">
                                                    <span class="dropdown-header">More Option :</span>
                                                    <a class="dropdown-item" href="javascript: void(0);">Mark as Unread</a>
                                                    <a class="dropdown-item" href="javascript: void(0);">Add to Tasks</a>
                                                    <a class="dropdown-item" href="javascript: void(0);">Add Star</a>
                                                    <a class="dropdown-item" href="javascript: void(0);">Mute</a>
                                                </div>
                                            </div>
                                        </div>

                                        <div class="mt-4">
                                            <h5>Leave Detail </h5>

                                            <hr/>

                                            <div class="media mb-4 mt-1">
                                                
                                                <div class="media-body">
                                                    <span class="pull-right" style="font-size:16px;"><?php $date_time = $rows2['requested_time'];
																	echo date('d-m-Y', strtotime($date_time));
																	?></span>
                                                    <h6 class="m-0">Name: <?php
												 $sql1 = "select *from tbl_emp_master where id = '".$rows2['emp_id']."' ";
						$result1 = $objhr->viewdata($sql1);
							
						$rows1 = $result1->fetch_assoc(); echo strtoupper($rows1['emp_name']);?></h6>
                                                    <small class="text-muted">Employee code: <?php echo strtoupper($rows1['emp_code']);?></small>
                                                </div>
                                            </div>

                                            <p><b>Detail: </b></p>
                                            <p><?php echo $rows2['leave_detail'];?></p>
                                            <p><span><b>Date From:</b></span> <?php echo date('d-m-Y', strtotime($rows2['from_date']));?> </p>
											<p><span><b>Date To:</b></span> <?php echo date('d-m-Y', strtotime($rows2['to_date']));?> </p>
                                           <?php
										   if($rows2['emp_id']==$row_emp['emp_id']){
										   ?>
										   
										   <p><span style="font-size:16px; color:#FF0000"><b>Remark:</b></span> <?php echo strtoupper($rows2['remark']);?> </p>
										   <?php }elseif($rows2['leave_status']==0){?>
										    <form role="form" method="post">
                                                
                                                 <div class="form-group">
                                                    <input type="text" class="form-control" name="remark" placeholder="Remark" style=" height:50px;" required>
                                                </div>

                                                <div class="form-group m-b-0">
                                                    <div class="text-right">
                                                        <button type="submit" class="btn btn-danger waves-effect waves-light m-r-5" name="rej">Reject</button>
                                                       <a href="grant_leave.php?empl_code=<?php echo $rows1['emp_code'];?>&leave_id=<?php echo md5($rows2['id']);?>"> <button type="button" class="btn btn-success waves-effect waves-light m-r-5">Approve</button></a>
                                                       
                                                    </div>
                                                </div>

                                            </form>
											<?php }?>
                                            <hr/>

                                            
<?php
if(isset($_POST['rej'])){
$sqlupt = "UPDATE `tbl_leave_request` SET `leave_status` = '2', remark = '".$_REQUEST['remark']."' WHERE md5(id) = '".$leave_id."';";
$resultupt = $objhr->updation($sqlupt);

?>
<script>
alert('Success');
location='view_leave_request.php';
</script>
<?php

}
?>
                                   

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

include('../include/footer.php');
	
?>