<%@ page language="java" %>
<%@ 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 rooms = (java.util.List)request.getSession().getAttribute("rooms");
    java.util.Iterator itor = rooms.iterator();
%>
  <head>
    <title>Travel-Agency Listing Page</title>
  <script type="text/javascript">
   function enterValue(RoomId)
   {
      document.forms[0].elements[0].value = RoomId;
      document.forms[1].elements[0].value = RoomId;
   } 

   function detail()
   {
      if (document.forms[0].elements[0].value == "") alert ("You must select a room!");
        else document.forms[0].submit();
   }
  </script>
  </head>
<body>
 <h1>Travel Agency Software V0.1</h1><br><br>
 <h2>List of Rooms</h2>
 <html:errors/><p>
 <table border="0">
   <tr><th>Select</th><th>No.</th><th>Type</th><th>Status</th></tr>
   <%
      while (itor.hasNext())
      {
        com.ferienclub.vacancymgm.beans.Room r = (com.ferienclub.vacancymgm.beans.Room)itor.next();
        int roomNo = r.getRoomNo();
        java.lang.String type = r.getType().getRoomCategory();
        java.lang.String status = r.getStatus();
        java.lang.String id = r.getRoomId();
        %><tr><td><input type="radio" name="DetailBookingChoice" value="<%= id %>" onClick="enterValue('<%= id %>')"></td><td><%= roomNo %></td><td><%= type %></td><td><%= status %></td></tr><%
      }
    %>
 </table>

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

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

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

</body>
</html>
