<!--  Author : Jagbir Singh -->
<!--  Debug : Siddhesh Surve -->
<!--  Tested by : Amanbir Singh -->
 
 <%
    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"%>
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">

<%@page language="java"%>
<%@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><br>

<form method="post" action="update.jsp">

<table class="table3">
<%
System.out.println("inside editprofile");
String active = (String)session.getAttribute("active");
String id = (String)session.getAttribute("sUserName");

PreparedStatement pstmt = null;
DataSource pool;
System.out.println("inside editprofile.jsp");
String loginQuery;

int sumcount=0;
try {

Connection conn ;

InitialContext ctx = new InitialContext();
// Lookup the DataSource, which will be backed by a pool
//   that the application server provides.
pool = (DataSource)ctx.lookup("java:comp/env/jdbc/TestDB");
//get a connection from pool
if (pool == null)
   throw new SQLException("Unknown DataSource 'jdbc/TestDB'");
conn = pool.getConnection();
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()){			//creating table for editing profile
%>

<%if(active.equals("actpatient")){ %>
 <tr>
    <td>UserId</td>
    <td> <input type = "hidden" name = "userId" value=<%=rs.getString("user_Id")%>>
    <%=rs.getString("user_Id")%>
    </td>
  </tr>
  <%}else{ %>
  
  <tr>
    <td>UserId</td>
    <td> <input type = "hidden" name = "userId" value=<%=rs.getString("doc_Id")%>>
    <%=rs.getString("doc_Id")%>
    </td>
  </tr>
  <%} %>
  <tr>
    <td>First Name</td>
    <td><input type = "text" name = "firstname" value=<%=rs.getString("firstName")%>></td>
  </tr>
  
  <tr>
    <td>Last Name</td>
    <td><input type = "text" name = "surname" value=<%=rs.getString("lastName")%>></td>
  </tr>
  
  <tr>
    <td>Email Id</td>
    <td><input type = "text" name = "email" value=<%=rs.getString("email")%>></td>
  </tr>
  
  <tr>
    <td>Password</td>
    <td><input type = "password" name = "pswd2" value=<%=rs.getString("passWord")%>></td>
  </tr>
  
  <%if(active.equals("actpatient")){ %>
  <tr>
    <td>AGE</td>
    <td><input type = "text" name = "age" value=<%=rs.getString("age")%>></td>
  </tr>
  
  <tr>
    <td>SEX</td>
    <td><input type = "hidden" name = "SEX(M/F)" value=<%=rs.getString("seX") %>>
    <%=rs.getString("seX") %>
    </td>
  </tr>
  <%} %>
 
  
  <tr>
  <td>Permanent Address</td>
    <td><textarea rows="5" cols="30" name = "address2">
    <%=rs.getString("addressPerm")%>
    </textarea></td>
  </tr>
  
<tr>
    <td>Contact Number</td>
    <td><input type = "text" name = "phNumber" value=<%=rs.getString("conNumber") %>></td>
  </tr>
  <%if(active.equals("actpatient")){ %>
  <tr>
    <td>Height</td>
    <td><input type = "text" name = "height" value=<%=rs.getString("height")%>></td>
  </tr>
  
  <tr>
    <td>Weight</td>
    <td><input type = "text" name = "weight" value=<%=rs.getString("weight") %>></td>
  </tr>  
  
  <tr>
    <td>BMI</td>
    <td><input type = "hidden" name = "bmi" value=<%=rs.getString("BMI") %>>
    <%=rs.getString("BMI")%>
    </td>
  </tr>  
  
  <tr>
    <td>Occupation</td>
    <td><input type = "text" name = "Occupation" value=<%=rs.getString("occupation") %>></td>
  </tr>
<%}else{ %>
 <tr>
    <td>Specialization</td>
    <td><input type = "text" name = "spclization" value=<%=rs.getString("spclZtion") %>></td>
  </tr>
  <%} %>
  

<tr>
<td><input type="submit" name="Submit" value="Update" style="background-color:#49743D;font-weight:bold;color:#ffffff;"></td>
</tr>
<%
}
}
catch(Exception e){}
%>
</table>
</form>
</body>
</html>