<!-- Author : Jagbir Singh -->
<!-- Debug : Jagbir Singh -->
<!-- Tested : Amanbir Singh -->

<%@ page import="java.sql.*, javax.sql.DataSource, javax.naming.*" %>
<html>
<head>

<style>
table.table3{
    font-family:Arial;
    font-size: 18px;
    font-style: normal;
    font-weight: normal;
    text-transform: uppercase;
    letter-spacing: -1px;
    line-height: 1.7em;
    text-align:center;
    border-collapse:collapse;
    width:80%;
    margin-left:auto;
    margin-right:auto;
    
}
.table3 thead th{
    padding:6px 10px;
    text-transform:uppercase;
    color:#444;
    font-weight:bold;
    text-shadow:1px 1px 1px #fff;
    border-bottom:5px solid #444;
}
.table3 thead th:empty{
    background:transparent;
    border:none;
}
.table3 thead :nth-child(2),
.table3 tfoot :nth-child(2){
    background-color: #7FD2FF;
}
.table3 tfoot :nth-child(2){
    -moz-border-radius:0px 0px 0px 5px;
    -webkit-border-bottom-left-radius:5px;
    border-bottom-left-radius:5px;
}
.table3 thead :nth-child(2){
    -moz-border-radius:5px 0px 0px 0px;
    -webkit-border-top-left-radius:5px;
    border-top-left-radius:5px;
}
.table3 thead :nth-child(3),
.table3 tfoot :nth-child(3){
    background-color: #45A8DF;
}
.table3 thead :nth-child(4),
.table3 tfoot :nth-child(4){
    background-color: #2388BF;
}
.table3 thead :nth-child(5),
.table3 tfoot :nth-child(5){
    background-color: #096A9F;
}
.table3 thead :nth-child(5){
    -moz-border-radius:0px 5px 0px 0px;
    -webkit-border-top-right-radius:5px;
    border-top-right-radius:5px;
}
.table3 tfoot :nth-child(5){
    -moz-border-radius:0px 0px 5px 0px;
    -webkit-border-bottom-right-radius:5px;
    border-bottom-right-radius:5px;
}
.table3 tfoot td{
    font-size:38px;
    font-weight:bold;
    padding:15px 0px;
    text-shadow:1px 1px 1px #fff;
}
.table3 tbody td{
    padding:10px;
}
.table3 tbody tr:nth-child(4) td{
    font-size:18px;
    font-weight:normal;
}
.table3 tbody td:nth-child(even){
    background-color:#444;
    color:#444;
    border-bottom:1px solid #444;
    background:-webkit-gradient(
        linear,
        left bottom,
        left top,
        color-stop(0.39, rgb(189,189,189)),
        color-stop(0.7, rgb(224,224,224))
        );
    background:-moz-linear-gradient(
        center bottom,
        rgb(189,189,189) 39%,
        rgb(224,224,224) 70%
        );
    text-shadow:1px 1px 1px #fff;
}
.table3 tbody td:nth-child(odd){
    background-color:#555;
    color:#f0f0f0;
    border-bottom:1px solid #444;
    background:-webkit-gradient(
        linear,
        left bottom,
        left top,
        color-stop(0.39, rgb(85,85,85)),
        color-stop(0.7, rgb(105,105,105))
        );
    background:-moz-linear-gradient(
        center bottom,
        rgb(85,85,85) 39%,
        rgb(105,105,105) 70%
        );
    text-shadow:1px 1px 1px #000;
}
.table3 tbody td:nth-last-child(1){
    border-right:1px solid #222;
}
.table3 tbody th{
    color:#696969;
    text-align:right;
    padding:0px 10px;
    border-right:1px solid #aaa;
}
.table3 tbody span.check::before{
    content : url(../images/check2.png)
}
</style>
</head>
<body >
<br><br>
<form name="home" " action="welcome.jsp">
<input type="image" src="home.jpg" alt="Submit" align="left" width="70" height="60">
</form>
<form name="graph" " action="logout.jsp">
<input type="image" src="logout.jpg" alt="Submit" align="right" width="60" height="60">
</form>
<br><br><br>
<form method="post" name="form" action = "editProfile.jsp">
<table  class="table3">

<%
Connection conn = null;

PreparedStatement pstmt = null;
DataSource pool;		//for DB connection Pool
int sumcount=0;

try{

String loginQuery = null;
InitialContext ctx = new InitialContext();
pool = (DataSource)ctx.lookup("java:comp/env/jdbc/TestDB");	//fething DB connect from pool
if (pool == null)
   throw new SQLException("Unknown DataSource 'jdbc/TestDB'");
conn = pool.getConnection();
String active = (String)session.getAttribute("active");		//Currently Active connection--patient or doctor
String Id = (String)session.getAttribute("sUserName");		//user Id of user
int odd=0;
if(active.equals("actpatient")){
 loginQuery = "SELECT * from userInfo where user_Id = ?";
}
else{
	loginQuery = "SELECT * from drInfo where doc_Id = ?";
}
pstmt = conn.prepareStatement(loginQuery);
pstmt.setString(1, Id);
ResultSet rs = pstmt.executeQuery();
%>
<%
while(rs.next()){
						//making table for profile view
%>


<%if(active.equals("actpatient")){ %>
<tbody>
 <tr>
    <td>UserId</td>
    <td> <%=rs.getString("user_Id")%></td>
  </tr>
  <%}else{ %>
  
  <tr>
    <td>UserId</td>
    <td> <%=rs.getString("doc_Id")%></td>
  </tr>
  <%} %>
  <tr>
    <td>First Name</td>
    <td><%=rs.getString("firstName")%></td>
  </tr>
  
  <tr>
    <td>Last Name</td>
    <td><%=rs.getString("lastName")%></td>
  </tr>
  
  <%if(active.equals("actpatient")){			//for displaying doctor name only when patient has logged in
	  String docid = rs.getString("docId");
	  loginQuery = "SELECT firstName from drInfo where doc_Id = ?";
	  pstmt = conn.prepareStatement(loginQuery);
	  pstmt.setString(1,docid);
	  ResultSet rs2 = pstmt.executeQuery();
	  rs2.next();
	  %>
  }
  <tr>
    <td>Consultant</td>
    <td>Dr <%=rs2.getString("firstName")%></td>
  </tr>
  <%} %>
  <tr>
    <td>Email Id</td>
    <td><%=rs.getString("email")%></td>
  </tr>
  
  <%if(active.equals("actpatient")){ %>
  <tr>
    <td>Age</td>
    <td><%=rs.getString("age")%></td>
  </tr>
  
  <tr>
    <td>Sex</td>
    <td><%=rs.getString("seX") %></td>
  </tr>
  <%} %>
 
  
  <tr>
  <td>Permanent Address</td>
    <td><%=rs.getString("addressPerm")%></td>
  </tr>
  
<tr>
    <td>Contact Number</td>
    <td><%=rs.getString("conNumber") %></td>
  </tr>
  <%if(active.equals("actpatient")){ %>
  <tr>
    <td>Height</td>
    <td><%=rs.getString("height")%></td>
  </tr>
  
  <tr>
    <td>Weight</td>
    <td><%=rs.getString("weight") %></td>
  </tr>  
  
  <tr>
    <td>BMI</td>
    <td><%=rs.getString("BMI") %></td>
  </tr> 
  
  <tr>
    <td>Occupation</td>
    <td><%=rs.getString("occupation") %></td>
  </tr>
<%}else{ %>
 <tr>
    <td>Specialization</td>
    <td><%=rs.getString("spclZtion") %></td>
  </tr>
  <%} %>
  
  </tbody>
</table>
<input type="Submit" name="edit" value="Edit" style="background-color:green;font-weight:bold;color:white;" >

<%
}
%>
<%
}
catch(Exception e){
e.printStackTrace();
}
%>

</form>
</body>
</html>