<?php
	
	// Obtaining connection
	include './conn.php';
	
	
	// Sql query
	$sql = "SELECT * FROM staff";

	$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>Staff</title>
<style type="text/css">
body {
	margin-left: 0px;
	margin-top: 0px;
	margin-right: 0px;
	margin-bottom: 0px;
	background-image: url(../images/bg.gif);
}
</style>
<link href="../style.css" rel="stylesheet" type="text/css" />
</head>
<body>
<style>


.single_card {
    width: 100px;
    height: 100px;
    padding: 0.5rem;
    background: rgb(23, 88, 61);
    margin: 1rem 1.5rem;
    border-radius: 5px;
    box-shadow: 5px 5px 30px rgba(0, 0, 0, .2);

}

.single_card h3 {
    font-size: 1.0rem;
    color: white;
    font-weight: 300;
    padding: 0.2rem ;
}

.single_card .row {
    display: flex;
    justify-content: space-between;
    padding: 0.2;
    align-items: center;
}

.single_card .row h1 {
    font-size: 1.2rem;
    color: whitesmoke;
    font-weight: 600;
    padding: 0.5rem 0;
}
</style>
<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">
  <?php  
         $selectstaff = "SELECT COUNT(staff_id) FROM staff;";
         $result1= mysqli_query($conn,$selectstaff)or die("Querry Unsuccessfull".mysqli_error($conn));

         $selectadmin = "SELECT COUNT(user_id) FROM login WHERE user_type = 'admin'";
         $result2 = mysqli_query($conn, $selectadmin) or die("Query Unsuccessful: " . mysqli_error($conn));
         
         $selectPC = "SELECT COUNT(user_id) FROM login WHERE user_type = 'PC'";
         $result3 = mysqli_query($conn, $selectPC) or die("Query Unsuccessful: " . mysqli_error($conn));
         
       $r1= mysqli_fetch_array($result1);
       $r2= mysqli_fetch_array($result2);
       $r3= mysqli_fetch_array($result3);
     
        ?>
     <div class="single_card">
                        <h3>Staff</h3>
                        <div class="row">
                            <h1><?php   echo $r1[0] ;  ?></h1>
                        </div>
                    </div>

                    <div class="single_card">
                        <h3>Adminstrators</h3>
                        <div class="row">
                            <h1><?php   echo $r2[0] ;  ?></h1>
                        </div>
                    </div>

                    <div class="single_card">
                        <h3>PC</h3>
                        <div class="row">
                            <h1><?php   echo $r3[0] ;  ?></h1>
                        </div>
                    </div>
    </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");
	}
?>
