<%@ include file="SQL.jsp" %>
<%@ page import="java.sql.*" %>
<%@ include file="header.jsp"%>

<!-- script for highlighting the table rows-->
<script type="text/javascript">
    function ChangeColor(tableRow, highLight)
    {
    if (highLight)
    {
      tableRow.style.backgroundColor = '#dcfac9';
    }
    else
    {
      tableRow.style.backgroundColor = 'white';
    }
  }

  function DoNav(theUrl)
  {
  	document.location.href = theUrl;
  }
</script>

<%
String self = request.getParameter("self");
%>

<body>
<!-- main menu -->
<div id="b3k_contentarea_header">
	 <div id="b3k_contentarea_header_nav">
                  <ul   <% if(self!=null && self.equals("true")) {
					out.println("class=\"b3k_menumode\">");
				}else{
					out.println(">");
				}
			%>

                    <li class="b3k_firstchild b3k_active">
			<a href="myReservations.jsp?self=
				<% if(self!=null && self.equals("true")) {
						out.print("false");
					}else{
						out.print("true");
					}
				%>
                         " title="Meine Reservierungen">Meine Reservierungen</a>
                     </li>
                    
                    
                    <li class="b3k_lastchild">
                      <a href="reservationDateTimeChooser.jsp" title="Neue Reservierung">Neue Reservierung</a>
                     </li>

		    <li class="b3k_lastchild">
                      <a href="logout.jsp" title="Logout">Logout</a>
                   </li>
                    
                  </ul>
       </div>
</div>
<!-- menu end-->

<%
String user = (String) session.getAttribute("user");

if(user!=null){
	ResultSet res = queryDB("select bachelor_reservation.id as resID, date, startTime, endTime, station, level, area from"
				+" bachelor_reservation, bachelor_station"
				+" where user_id='" + user +"' and station = bachelor_station.id and"
				+" date>=CURRENT_DATE order by date");

	out.println("<h3>Zeile ausw\u00E4hlen um Details zu sehen:</h3>");
	out.println("<p><table class='resList'>");
	out.println("<tr class='first'><td>Datum<td>Beginn<td>Ende<td>Stock<td>Bereich<td>Station");

	while (res.next()) { 
		//add script for highlight to table
		String script = "onmouseover='ChangeColor(this, true);' onmouseout='ChangeColor(this, false);' onclick='DoNav("
			+"\"reservationInfo.jsp?station="+res.getString("station")+"&reservation="+res.getString("resID")
			+"\");' ";		

        	out.println("<tr "+script+"><td>"+res.getString("date")+
				"<td>"+res.getString("startTime")+
				"<td>"+res.getString("endTime")+
				"<td>"+res.getString("level")+
				"<td>"+res.getString("area")+
				"<td>"+res.getString("station")  );
		
	}//while end
}else{

out.println("<meta HTTP-EQUIV='REFRESH' content='0; url=index.jsp'>");

}
%>
</table>

</body>
<%@ include file="footer.jsp"%>
</html>
