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


<%
/*This is the first page which is loaded at the beginning of a new reservation process.
The user can enter the desired date 
*/


String self = request.getParameter("self");
String user = (String) session.getAttribute("user");

if(user==null){
	out.println("<meta HTTP-EQUIV='REFRESH' content='0; url=index.jsp'>");
}
%>



<body>

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

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


<form class='search' action=freeStationsOnDate.jsp>
<p>
Datum: 
<select name="day">

<%
//creates the options of the select tag

	for(int i=0; i<14; i++){ 		

		ResultSet res = queryDB("SELECT DATE_FORMAT( CURRENT_DATE+"+i+", '%a') as DayOfWeek, "+
				"DATE_FORMAT( CURRENT_DATE+"+i+", '%d') as NumberOfDay, "+
				"DATE_FORMAT( CURRENT_DATE+"+i+", '%b') as Month");
		res.next();
		
		if(res.getString("DayOfWeek")!=null && !res.getString("DayOfWeek").equals("Sun") ){
        			out.println("<option value='"+i+"'>"
				+res.getString("DayOfWeek")+", "+res.getString("NumberOfDay")+". "+res.getString("Month")+"</option>");
		}
	}

%>
</select>
<br>

Uhrzeit:
<select name="time">
	<%
	ResultSet resTime = queryDB("SELECT CURRENT_TIME as time;");
	resTime.next();
	String time = resTime.getString("time");
	time = time.substring(0, time.indexOf(":"));
	Integer startTime = new Integer(time)+1;

	for(int t=startTime; t<22; t++){
		 out.println("<option value='" +t+ "00'>" +t+ ":00</option>");
		 out.println("<option value='" +t+ "30'>" +t+ ":30</option>");
	}
	%>
</select>
<br>

Dauer:
<select name="duration">
	<%
	for(int t=0; t<=6; t++){
		 if(t!=0) out.println("<option value='" +t+ "00'>" +t+ ":00</option>");
		 if(t!=6) out.println("<option value='" +t+ "30'>" +t+ ":30</option>");
	}
	%>
</select>

<br>
<p>

<input type="submit" value="Suchen" />
</form>

</h2>
<p>

<a href="video.jsp">Wie reserviere ich? - Videoanleitung</a>
</body>

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