<%@ include file="/includes/setup.inc" %>
<html>
  <head>
    <title>
      Library Books
    </title>
    <link rel="stylesheet" type="text/css" href='<c:url value="/css/app.css"/>'>
  </head>
  <body>
    <h1>
      Library Collection
    </h1>
    <hr>
    <html:form action="/bookDisplay">
      <table>
        <tr>
          <td valign="top">
					  <c:set var="bookList" value="${library.bookList}"/>
            <html:select property="trackingID" size="10" onchange="submit()">
              <html:options collection="bookList" property="trackingID" labelProperty="title"/>
            </html:select>
            <p />
            <html:link forward="home">
              Return Home
            </html:link>
            <td valign="top">
              <c:if test="${ ! empty usersession.currentBook }">
                <table>
                  <tbody>
                    <tr>
                      <td class="rowLabel">
                        Title:
                      </td>
                      <td class="rowContent">
                        <c:out value="${usersession.currentBook.title}"/>
                      </td>
                    </tr>
                    <tr>
                      <td class="rowLabel">
                        Author:
                      </td>
                      <td class="rowContent">
                        <c:out value="${usersession.currentBook.author}"/>
                      </td>
                    </tr>
                    <tr>
                      <td class="rowLabel">
                        ISBN:
                      </td>
                      <td class="rowContent">
                        <c:out value="${usersession.currentBook.ISBN}"/>
                      </td>
                    </tr>
                    <tr>
                      <td class="rowLabel">
                        Status:
                      </td>
                      <td class="rowContent">
                        <c:choose>
                          <c:when test="${usersession.currentBook.checkedOut == true}">
                            Checked Out
                          </c:when>
                          <c:otherwise>
                            Checked In
                          </c:otherwise>
                        </c:choose>
                      </td>
                    </tr>
                  </tbody>
                </table>
<%--
	For the Java code version of BookDisplayForm, reference safeModeChange with
		BookDisplayForm.safeModeChange
	For the DynaValidatorForm (SmartDynaValidatorForm) version, use
		BookDisplayForm.map.safeModeChange
	(because JSTL can only use . notation on a real Map; since DynaValidatorForm
	isn't itself a map, we have to use its getMap() method to get to the underlying
	map.)
--%>
                <c:if test="${BookDisplayForm.safeModeChange != true}">
                  <c:if test="${usersession.currentUser.borrower == true}">
                    <c:if test="${usersession.currentBook.checkedOut == false}">
                      <html:submit property="checkInOut" value="Check Out"/>
                    </c:if>
                  </c:if>
                  <c:if test="${usersession.currentUser.librarian == true}">
                    <c:if test="${usersession.currentBook.checkedOut == true}">
                      <html:submit property="checkInOut" value="Check In"/>
                    </c:if>
                  </c:if>
                </c:if>
              </c:if>
            </td>
          </tr>
        </table>
        <html:checkbox property="safeModeChange" onchange="submit()"/>
        Safe Mode
      </html:form>
    </body>
  </html>
