<%@page import="project.ConnectionProvider"%>
<%@page import="java.sql.*"%>
<%@include file="adminHeader.jsp" %>
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=ISO-8859-1">
<link rel="stylesheet" href="css/sidenevbarcss.css">
<title>Home</title>
</head>
<body style="background-color: #f2f2f2">
<div id="mySidenav" class="sidenav">
    
  <a href="" class="closebtn" onclick="closeNav()">&times;</a>
  <a href="changeDetails.jsp"><%out.println(email);%>  <i class="fa fa-edit"></i></a>
  <a href="messageUs.jsp">Message Us <i class='fas fa-comment-alt'></i></a>
  <a href="about.jsp">About <i class="fa fa-address-book"></i></a>
  <a href="logout.jsp">Logout <i class='fas fa-share-square'></i></a>
</div>
  
  <div id="main">
  <span style="font-size:30px;cursor:pointer" onclick="openNav()"><i class='fas fa-user-alt'></i></span>


  <div class="row">
<% 
    int z=0;
    try{
    String search=request.getParameter("search");   
    Class.forName("com.mysql.jdbc.Driver");
    Connection con = DriverManager.getConnection("jdbc:mysql://localhost:3306/CLINIHR", "root", "Clinica123");
    Statement st = con.createStatement();
    ResultSet rs = st.executeQuery("select * from users where first_name like '%"+search+"%' or last_name like '%"+search+"%' or emp_code like '%"+search+"%'");
    while(rs.next()){
        z=1;
    
%>
<form action="editEmployeeDetails.jsp?id=<%=rs.getString(1)%>" method="post">      
    
<div class="col-md-4">
  <div class="column">
      <div class="card">
        <img src="images/<%=rs.getString(33)%>" alt="User Image" style="width: 100%; height: 300px; background-color: #f2f2f2;">
        <div style="background-color: white;">
        <h1 style="background-color: #f2f2f2; padding-top:1rem; padding-left: 1rem; padding-right: 1rem; margin: 0px"><%=rs.getString(2)%> <%=rs.getString(4)%> </h1>                                    
        <p class="price" style="background-color: #f2f2f2; padding: 10px; margin: 0px;"> <%=rs.getString(22)%> </p>
        <p style="background-color: #f2f2f2; margin: 0px"><%=rs.getString(23)%></p>
        <p style="background-color: #f2f2f2; margin: 0px"><button class="card button" type="submit"> Edit </button> </p>             
        </div>
      </div>
  </div>
</div>
   
</form> 
<%
        }
%>

</div>       
        <%
    } catch (Exception e) {
          out.println(e);
    }           
%>
      	<%if(z==0){%>              
	<h1 style="color: black; text-align: center;">Nothing to show</h1>
	<%    }%>
      <br>
      <br>
      <br>
      
</div>
      <script>
function openNav() {
  document.getElementById("mySidenav").style.width = "310px";
  document.getElementById("main").style.marginLeft = "310px";
}

function closeNav() {
  document.getElementById("mySidenav").style.width = "0";
  document.getElementById("main").style.marginLeft= "0";
}
</script>
   
</body>
</html>