<%@ taglib uri="/WEB-INF/struts-bean.tld" prefix="bean" %>
<%@ taglib uri="/WEB-INF/struts-html.tld" prefix="html" %>
<%@ taglib uri="/WEB-INF/struts-logic.tld" prefix="logic" %>
<html>
<%
    java.util.List bookings = (java.util.List)request.getAttribute("bookings");
    com.ferienclub.vacancymgm.beans.Room room = (com.ferienclub.vacancymgm.beans.Room)request.getAttribute("room");
    int roomNo = room.getRoomNo();
    java.lang.String type = room.getType().getRoomCategory();
    java.lang.String status = room.getStatus();
    java.util.Iterator itor = bookings.iterator();
    java.text.SimpleDateFormat sdf = new java.text.SimpleDateFormat("dd-MM-yyyy");
%>
  <head>
    <title>Travel-Agency Detail Page</title>
  <script type="text/javascript">
    function makeBooking()
    {
      document.forms[0].elements[0].value = "<%= room.getRoomId() %>";
      document.forms[0].submit();
    }
  </script>
  </head>
<body>
 <h1>Travel Agency Software V0.1</h1><br><br>
 <h2>Room Details</h2><p>
 <html:errors/><p>
 
 <b>Number:</b><%= roomNo %><br>
 <b>Type:</b><%= type %><br>
 <b>Status:</b><%= status %><br>
 
 <h3>Current Bookings:</h3>
 <table border="0">
   <tr><th>From:</th><th>To:</th></tr>
   <%
      while (itor.hasNext())
      {
         com.ferienclub.vacancymgm.beans.Booking booking = (com.ferienclub.vacancymgm.beans.Booking)itor.next();
	 java.util.Date from = booking.getFromDate();
	 java.util.Date to = booking.getToDate();
	 java.lang.String sFrom = sdf.format(from);
         java.lang.String sTo = sdf.format(to);
         %><tr><td><%= sFrom %></td><td><%= sTo %></td></tr><%
      }
   %>
 </table>
 <p>

 <html:form action="booking.do?action=init">
   <html:hidden property="roomId" name="DetailBookingForm"/>
 </html:form>

 <form action="back.do"/>


 <input type="button" value="Make Booking" onClick="makeBooking()"/>  <input type="button" value="Back" onClick="document.forms[1].submit()"/> 

</body>
</html>