<%@ page contentType="text/html;charset=UTF-8" pageEncoding="UTF-8" %>
<%@ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core" %>
<%@ taglib prefix="fn" uri="http://java.sun.com/jsp/jstl/functions" %>
<!doctype html>
<html lang="zh-CN">
<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1">
    <title>新增借阅 - MZH 图书馆</title>
    <link rel="stylesheet" href="${pageContext.request.contextPath}/static/css/app.css?v=20260428-visual-shell">
</head>
<body>
<%@ include file="/WEB-INF/jsp/common/header.jspf" %>
<main class="page-shell">
    <section class="form-panel" aria-labelledby="borrow-form-title">
        <p class="eyebrow">借阅管理</p>
        <h1 id="borrow-form-title">新增借阅</h1>

        <c:if test="${not empty errorMessage}">
            <div class="message message-error" role="alert">
                <c:out value="${errorMessage}" />
            </div>
        </c:if>

        <c:set var="readerIdentifierValue" value="${formValues.readerIdentifier}" />
        <c:set var="bookIdentifierValue" value="${formValues.bookIdentifier}" />

        <form class="borrow-form" action="${pageContext.request.contextPath}/borrowing/create" method="post" novalidate>
            <div class="form-grid">
                <div class="form-field">
                    <label for="readerIdentifier">读者编号</label>
                    <input id="readerIdentifier" name="readerIdentifier" type="text"
                           value="${fn:escapeXml(readerIdentifierValue)}" required>
                    <c:if test="${not empty errors.readerIdentifier}">
                        <span class="field-error"><c:out value="${errors.readerIdentifier}" /></span>
                    </c:if>
                </div>

                <div class="form-field">
                    <label for="bookIdentifier">图书编号</label>
                    <input id="bookIdentifier" name="bookIdentifier" type="text"
                           value="${fn:escapeXml(bookIdentifierValue)}" required>
                    <c:if test="${not empty errors.bookIdentifier}">
                        <span class="field-error"><c:out value="${errors.bookIdentifier}" /></span>
                    </c:if>
                </div>
            </div>

            <div class="form-actions">
                <button class="button button-primary" type="submit">借出</button>
                <a class="button button-secondary" href="${pageContext.request.contextPath}/borrowing">取消</a>
            </div>
        </form>
    </section>
</main>
</body>
</html>
