<!--  Author : Jagbir Singh -->
<!--  Debug : Jagbir Singh -->
<!--  Tested by : Ajinkya Bilolikar -->
 
 <%
    response.setHeader("Cache-Control","no-store");
    response.setHeader("Pragma","no-cache");
    response.setDateHeader ("Expires", 0); 
    %>

<%@ page language="java" contentType="text/html; charset=UTF-8"
    pageEncoding="UTF-8"%>
    <%@page import="java.sql.*, javax.sql.DataSource, javax.naming.*"%>
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">


<html>
<head>

<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
<style>
#customers
{
font-family:"Trebuchet MS", Arial, Helvetica, sans-serif;
width:70%;
padding-right:50px;
margin-left:auto;
margin-right:auto;

border-collapse:collapse;
}
#customers td, #customers th 
{
font-size:1em;
border:1px solid #98bf21;
padding:3px 7px 2px 7px;
}
#customers th 
{
font-size:1.1em;
text-align:left;
padding-top:5px;
padding-bottom:4px;
background-color:#25587E;
color:#ffffff;
}
#customers tr.alt td 
{
color:#000000;
background-color:#1589FF;
}
</style>

<title>Patient List</title>
</head>
<body><center>
<p style="color: #25587E; font-size: 18pt;">Patients Details </p>

</center>

<form name="home" " action="welcome.jsp">
<input type="image" src="home.jpg" alt="Submit" align="left" width="70" height="60">
</form>

<form name="logout" " action="logout.jsp">
<input type="image" src="logout.jpg" alt="Submit" align="right" width="60" height="60">
</form>
<table id="customers">
<tr>
  <th>Name</th>
  <th>Height</th>
  <th>Weight</th>
  <th>Age</th>
  <th>Sex</th>
  <th>Occupation</th>
  <th>Contact</th>
  <th>Reports</th>
  <th>FeedBack</th>
</tr>
<%

DataSource pool;
int flag =0;

  Connection conn = null;
 
  PreparedStatement pstmt = null;
 	
  String id = (String)session.getAttribute("sUserName");
  String active = (String)session.getAttribute("active");
  String loginQuery = null;
 

  try {
	
	InitialContext ctx = new InitialContext();
	pool = (DataSource)ctx.lookup("java:comp/env/jdbc/TestDB");
	if (pool == null)
	   throw new SQLException("Unknown DataSource 'jdbc/TestDB'");
	conn = pool.getConnection();
	
	  String drname;
	  String spclization;
	
		loginQuery = "SELECT * from userInfo where docId = ?";

	pstmt = conn.prepareStatement(loginQuery);
	pstmt.setString(1, id);
	ResultSet rs = pstmt.executeQuery();
	int odd =0;
	while(rs.next()){			//creating table for patients List 
		
		
		if((odd % 2) == 0){%>
		<tr>
		<%
		
			
		} else { %>
			<tr class="alt">
			<%
		}
		odd++;
		%>
		<td><%=rs.getString("firstName")%></td>
		<td><%=rs.getString("height")%></td>
		<td><%=rs.getString("weight")%></td>
		<td><%=rs.getString("age")%></td>
		<td><%=rs.getString("seX")%></td>
		<td><%=rs.getString("occuPation")%></td>
		<td><%=rs.getString("conNumber")%></td>
		
		<td><form action = "calender.jsp" >
		<br><input type="hidden" name="userId" value="<%=rs.getString("user_Id")%>" size=15 maxlength=20>
		<input type="submit" name="View Details" value="View Details" style="background-color:#1589FF;font-weight:bold;color:#000000;">
		</form></td>
		
		<td><form action = "feedback.jsp" >
		<br><input type="hidden" name="userId" value="<%=rs.getString("user_Id")%>" size=15 maxlength=20>
		<input type="submit" name="FeedBack" value="FeedBack" style="background-color:#1589FF;font-weight:bold;color:#000000;">
		</form></td>
		
		</tr>
		<%		
	}

	}
	catch(Exception e){
		e.printStackTrace();
	} finally {
		if(pstmt!= null){
			pstmt.close();
		}
		if(conn != null){
			conn.close();
		}
	}
  
%>

</table>

</body>
</html>