<?php
		// Obtaining connection
	include './conn.php';
	
	// Sql query
	$sql = "SELECT * FROM leave_requests ORDER BY leave_status";
    //$sql = "SELECT * FROM leave_requests WHERE leave_status != 'Pending' ORDER BY leave_status";
	$result = mysqli_query($conn,$sql);
	if(mysqli_num_rows($result)==0)
	{
		echo 	"<script>
				alert(\"Search results not found !\");
				window.location=\"#\";</script>";
	}
?>
<?php
	session_start();
	if($_SESSION['sid'] == session_id() && $_SESSION['user'] == "admin")
	{
		?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>Aproved and Rejected leaves</title>
<style type="text/css">
body {
	margin-left: 0px;
	margin-top: 0px;
	margin-right: 0px;
	margin-bottom: 0px;
	background-image: url(../images/bg.gif);
}
    /* Apply styles to the select field */
    #branch {
        width: 200px;
        padding: 10px;
        font-size: 16px;
        border: 1px solid #ccc;
        border-radius: 5px;
        background-color: #f5f5f5;
        cursor: pointer; /* Change cursor to pointer on hover */
    }

   
</style>
<link href="../style.css" rel="stylesheet" type="text/css" />
</head>
<body>
<div id="container">
  <div id="header">
  <div id="title">Lorenzo Group Leave Management</div>
    <div id="quick_links">
      <ul>
        <li><a class="home" href="index.php">Home</a></li>
        <li>|</li>
        <li><a class="logout" href="../logout.php">Logout</a></li>
        <li>|</li>
        <li><a class="greeting" href="#">Hi <?php echo $_SESSION['user']; ?></a></li>
      </ul>
    </div>
  </div>
  <div id="side_bar">
  	<ul>
    	<li class="menu_head">Menu</li>
        <li><a href="staff.php">Staff</a></li>
        <li><a href="add_staff.php">Add Staff</a></li>
        <li><a href="search_staff_for_updation.php">Update Staff</a></li>
        <li><a href="search_staff_for_deletion.php">Delete Staff</a></li>
    	<li><a href="add_leave.php">Add Leave</a></li>
        <li><a href="delete_leave_type.php">Delete Leave</a></li>
        <li><a href="approved_pending_leaves.php">Processed Leaves</a></li>
        <li><a href="search_staff_for_recall.php">Recall a Leave</a></li>
        <li><a href="search_staff_to_assign_pc.php">Program Coordinator</a></li>
    </ul>
  </div>
  
  <div id="content_panel">

<div id="heading">Staff
    <hr size="2" color="#FFFFFF" ice:repeating=""/>
</div>

<div id="table">
    <br/>
    <?php
    echo "<span><table border=\"1\" bgcolor=\"#006699\" >
        <tr>
            <th width=\"200px\">Staff ID</th>
            <th width=\"250px\">Leave Type</th>
            <th width=\"180px\">Date Applied</th>
            <th width=\"180px\">Days Requested</th>
            <th width=\"180px\">Leave Status</th>
        </tr>
    </table></span>";

    while($row = mysqli_fetch_array($result))
    {
        $staff_id = $row['staff_id'];
        $leave_type = $row['leave_type'];
        $date_applied = $row['date_applied'];
        $days_requested = $row['days_requested'];
        $leave_status = $row['leave_status'];

        echo "<table border=\"1\">
            <tr>
                <td width=\"200px\">".$staff_id."</td>
                <td width=\"250px\">".$leave_type."</td>
                <td width=\"180px\">".$date_applied."</td>
                <td width=\"180px\">".$days_requested."</td>
                <td width=\"180px\">".$leave_status."</td>
            </tr>
        </table>";
    }

    mysqli_close($conn);
    ?>
</div>
<STYLE>
    #downloadButton {
    background-color: #4CAF50; /* Green background */
    border: none; /* Remove border */
    color: white; /* White text */
    padding: 10px 20px; /* Padding */
    text-align: center; /* Center text */
    text-decoration: none; /* Remove underline */
    display: inline-block; /* Make it inline */
    font-size: 15px; /* Font size */
    margin: 10px; /* Add margin */
    cursor: pointer; /* Cursor style */
    border-radius: 5px; /* Rounded corners */
}

#downloadButton:hover {
    background-color: #45a049; /* Darker green on hover */
}

#downloadButton:active {
    background-color: #3e8e41; /* Darker green when clicked */
}

</STYLE>
<!-- Add download button -->
<a href="print1.php" id="downloadButton">Download</a>

</div>



  <div id="footer">
  <p><br />&copy; Lorenzo Group <br><br>All Rights Reserved.</p>
  </div>
</div>
</body>
</html>
<?php
	}
	else
	{
		header("Location: ../index.html");
	}
?>
