| [1eb7a55] | 1 | <%@ page language="java" contentType="text/html; charset=UTF-8" pageEncoding="UTF-8" %>
|
|---|
| 2 | <%@ taglib uri="http://java.sun.com/jsp/jstl/core" prefix="c" %>
|
|---|
| 3 |
|
|---|
| 4 | <!DOCTYPE html>
|
|---|
| 5 | <html lang="en">
|
|---|
| 6 | <head>
|
|---|
| 7 | <meta charset="UTF-8">
|
|---|
| 8 | <title>${professor != null ? 'Edit Professor' : 'Add New Professor'}</title>
|
|---|
| 9 | <link rel="stylesheet" href="https://stackpath.bootstrapcdn.com/bootstrap/4.3.1/css/bootstrap.min.css">
|
|---|
| 10 | </head>
|
|---|
| 11 | <body>
|
|---|
| 12 |
|
|---|
| 13 | <header>
|
|---|
| 14 | <nav class="navbar navbar-expand-md navbar-dark" style="background-color: tomato;">
|
|---|
| 15 | <a class="navbar-brand" href="#">Professor App</a>
|
|---|
| 16 | <ul class="navbar-nav">
|
|---|
| 17 | <li class="nav-item">
|
|---|
| 18 | <a href="${pageContext.request.contextPath}/professor/list" class="nav-link">Professor List</a>
|
|---|
| 19 | </li>
|
|---|
| 20 | </ul>
|
|---|
| 21 | </nav>
|
|---|
| 22 | </header>
|
|---|
| 23 |
|
|---|
| 24 | <div class="container col-md-6 mt-5 mb-5">
|
|---|
| 25 | <div class="card shadow">
|
|---|
| 26 | <div class="card-body">
|
|---|
| 27 |
|
|---|
| 28 | <%-- MAIN PROFESSOR FORM --%>
|
|---|
| 29 | <form action="${pageContext.request.contextPath}/professor/${professor != null ? 'update' : 'insert'}" method="post">
|
|---|
| 30 | <h2 class="text-center">${professor != null ? 'Edit Professor' : 'Add New Professor'}</h2>
|
|---|
| 31 | <hr>
|
|---|
| 32 |
|
|---|
| 33 | <c:if test="${professor != null}">
|
|---|
| 34 | <input type="hidden" name="id" value="${professor.id}" />
|
|---|
| 35 | </c:if>
|
|---|
| 36 |
|
|---|
| 37 | <div class="form-group">
|
|---|
| 38 | <label for="name">First Name</label>
|
|---|
| 39 | <input type="text" name="name" id="name" class="form-control"
|
|---|
| 40 | value="${professor != null ? professor.name : ''}" required>
|
|---|
| 41 | </div>
|
|---|
| 42 |
|
|---|
| 43 | <div class="form-group">
|
|---|
| 44 | <label for="surname">Last Name</label>
|
|---|
| 45 | <input type="text" name="surname" id="surname" class="form-control"
|
|---|
| 46 | value="${professor != null ? professor.surname : ''}" required>
|
|---|
| 47 | </div>
|
|---|
| 48 |
|
|---|
| 49 | <div class="form-group">
|
|---|
| 50 | <label for="age">Age</label>
|
|---|
| 51 | <input type="number" name="age" id="age" class="form-control"
|
|---|
| 52 | value="${professor != null ? professor.age : ''}" required>
|
|---|
| 53 | </div>
|
|---|
| 54 |
|
|---|
| 55 | <div class="form-group">
|
|---|
| 56 | <label for="facultyid">Primary Faculty</label>
|
|---|
| 57 | <select name="facultyid" id="facultyid" class="form-control" required>
|
|---|
| 58 | <option value="">-- Select Faculty --</option>
|
|---|
| 59 | <c:forEach var="faculty" items="${faculties}">
|
|---|
| 60 | <option value="${faculty.id}"
|
|---|
| 61 | <c:if test="${professor != null && professor.facultyid == faculty.id}">selected</c:if>>
|
|---|
| 62 | ${faculty.name} (ID: ${faculty.id})
|
|---|
| 63 | </option>
|
|---|
| 64 | </c:forEach>
|
|---|
| 65 | </select>
|
|---|
| 66 | </div>
|
|---|
| 67 |
|
|---|
| 68 | <div class="form-group">
|
|---|
| 69 | <label for="universityId">Affiliated University</label>
|
|---|
| 70 | <select name="universityId" id="universityId" class="form-control" required>
|
|---|
| 71 | <option value="">-- Select University --</option>
|
|---|
| 72 | <c:forEach var="univ" items="${universities}">
|
|---|
| 73 | <option value="${univ.id}"
|
|---|
| 74 | <c:if test="${professor != null && professor.university != null && professor.university.id == univ.id}">selected</c:if>>
|
|---|
| 75 | ${univ.name} (ID: ${univ.id})
|
|---|
| 76 | </option>
|
|---|
| 77 | </c:forEach>
|
|---|
| 78 | </select>
|
|---|
| 79 | </div>
|
|---|
| 80 |
|
|---|
| 81 | <div class="mt-4">
|
|---|
| 82 | <button type="submit" class="btn btn-success btn-block">Save Professor Details</button>
|
|---|
| 83 | <a href="${pageContext.request.contextPath}/professor/list" class="btn btn-secondary btn-block">Back to List</a>
|
|---|
| 84 | </div>
|
|---|
| 85 | </form>
|
|---|
| 86 | <%-- END OF MAIN PROFESSOR FORM --%>
|
|---|
| 87 |
|
|---|
| 88 | <%-- SUBJECT ASSIGNMENT SECTION (Only visible when editing) --%>
|
|---|
| 89 | <c:if test="${professor != null}">
|
|---|
| 90 | <hr class="mt-5">
|
|---|
| 91 | <h4 class="mb-3">Subjects Taught by ${professor.name}</h4>
|
|---|
| 92 |
|
|---|
| 93 | <%-- Table of currently assigned subjects --%>
|
|---|
| 94 | <table class="table table-bordered table-sm">
|
|---|
| 95 | <thead class="thead-light">
|
|---|
| 96 | <tr>
|
|---|
| 97 | <th>Subject Name</th>
|
|---|
| 98 | <th class="text-center" style="width: 100px;">Action</th>
|
|---|
| 99 | </tr>
|
|---|
| 100 | </thead>
|
|---|
| 101 | <tbody>
|
|---|
| 102 | <c:forEach var="sub" items="${taughtSubjects}">
|
|---|
| 103 | <tr>
|
|---|
| 104 | <td class="align-middle">${sub.name}</td>
|
|---|
| 105 | <td class="text-center">
|
|---|
| 106 | <form action="${pageContext.request.contextPath}/professor-subject/remove" method="post" class="m-0">
|
|---|
| 107 | <input type="hidden" name="professor_id" value="${professor.id}">
|
|---|
| 108 | <input type="hidden" name="subject_id" value="${sub.id}">
|
|---|
| 109 | <button type="submit" class="btn btn-outline-danger btn-sm"
|
|---|
| 110 | onclick="return confirm('Unassign this subject?')">Remove</button>
|
|---|
| 111 | </form>
|
|---|
| 112 | </td>
|
|---|
| 113 | </tr>
|
|---|
| 114 | </c:forEach>
|
|---|
| 115 | <c:if test="${empty taughtSubjects}">
|
|---|
| 116 | <tr>
|
|---|
| 117 | <td colspan="2" class="text-center text-muted">No subjects assigned yet.</td>
|
|---|
| 118 | </tr>
|
|---|
| 119 | </c:if>
|
|---|
| 120 | </tbody>
|
|---|
| 121 | </table>
|
|---|
| 122 |
|
|---|
| 123 | <%-- Form to assign a new subject --%>
|
|---|
| 124 | <div class="card bg-light mt-3">
|
|---|
| 125 | <div class="card-body">
|
|---|
| 126 | <h5 class="card-title">Assign New Subject</h5>
|
|---|
| 127 | <form action="${pageContext.request.contextPath}/professor-subject/assign" method="post" class="form-inline">
|
|---|
| 128 | <input type="hidden" name="professor_id" value="${professor.id}">
|
|---|
| 129 | <select name="subject_id" class="form-control mr-2" style="flex: 1;" required>
|
|---|
| 130 | <option value="">-- Choose a Subject --</option>
|
|---|
| 131 | <c:forEach var="allSub" items="${allSubjectsList}">
|
|---|
| 132 | <option value="${allSub.id}">${allSub.name}</option>
|
|---|
| 133 | </c:forEach>
|
|---|
| 134 | </select>
|
|---|
| 135 | <button type="submit" class="btn btn-primary">Add Assignment</button>
|
|---|
| 136 | </form>
|
|---|
| 137 | </div>
|
|---|
| 138 | </div>
|
|---|
| 139 | </c:if>
|
|---|
| 140 |
|
|---|
| 141 | </div>
|
|---|
| 142 | </div>
|
|---|
| 143 | </div>
|
|---|
| 144 |
|
|---|
| 145 | </body>
|
|---|
| 146 | </html> |
|---|