|
- <div class="container mt-4">
- <div class="d-flex justify-content-between align-items-center mb-4">
- <h1>
- Householder Names
- <% If IsObject(HouseholderNameController.household) Then %>
- <small class="text-muted">for <%= Server.HTMLEncode(HouseholderNameController.household.Address) %></small>
- <% End If %>
- </h1>
- <a href="/householder-names/new<% If HouseholderNameController.filterHouseholdId > 0 Then Response.Write "?household=" & HouseholderNameController.filterHouseholdId End If %>" class="btn btn-primary">New Householder Name</a>
- </div>
-
- <% Flash().ShowSuccessIfPresent %>
- <% Flash().ShowErrorsIfPresent %>
-
- <!-- Search Form -->
- <div class="card mb-4">
- <div class="card-body">
- <form method="get" action="/householder-names" class="row g-3">
- <div class="col-md-6">
- <div class="input-group">
- <input type="text" class="form-control" name="q" placeholder="Search by name..." value="<%= Server.HTMLEncode(HouseholderNameController.searchTerm) %>">
- <button class="btn btn-outline-primary" type="submit">Search</button>
- <% If HouseholderNameController.searchTerm <> "" Or HouseholderNameController.filterHouseholdId > 0 Then %>
- <a href="/householder-names" class="btn btn-outline-secondary">Clear</a>
- <% End If %>
- </div>
- </div>
- <div class="col-md-3 text-end">
- <span class="text-muted">
- <% If HouseholderNameController.searchTerm <> "" Then %>
- Found <%= HouseholderNameController.recordCount %> result(s)
- <% Else %>
- <%= HouseholderNameController.recordCount %> total
- <% End If %>
- </span>
- </div>
- </form>
- </div>
- </div>
-
- <% If IsObject(HouseholderNameController.household) Then %>
- <div class="alert alert-info">
- Showing householder names for: <strong><a href="/households/<%= HouseholderNameController.household.Id %>"><%= Server.HTMLEncode(HouseholderNameController.household.Address) %></a></strong>
- <a href="/householder-names" class="btn btn-sm btn-outline-info ms-2">Show All</a>
- </div>
- <% End If %>
-
- <div class="table-responsive">
- <table class="table table-striped table-hover">
- <thead class="table-dark">
- <tr>
- <th>ID</th>
- <th>Name</th>
- <th>Type</th>
- <th>Letter Returned</th>
- <th>Created</th>
- <th>Actions</th>
- </tr>
- </thead>
- <tbody>
- <%
- Dim iter, hn
- Set iter = HouseholderNameController.householderNames.Iterator()
- If Not iter.HasNext() Then
- %>
- <tr>
- <td colspan="6" class="text-center text-muted py-4">
- <% If HouseholderNameController.searchTerm <> "" Then %>
- No householder names found matching "<%= Server.HTMLEncode(HouseholderNameController.searchTerm) %>"
- <% ElseIf HouseholderNameController.filterHouseholdId > 0 Then %>
- No householder names for this household. <a href="/householder-names/new?household=<%= HouseholderNameController.filterHouseholdId %>">Add one</a>
- <% Else %>
- No householder names found. <a href="/householder-names/new">Create one</a>
- <% End If %>
- </td>
- </tr>
- <%
- Else
- Do While iter.HasNext()
- Set hn = iter.GetNext()
- %>
- <tr>
- <td><%= hn.Id %></td>
- <td><%= Server.HTMLEncode(hn.Name & "") %></td>
- <td>
- <span class="badge bg-secondary">Household</span>
- </td>
- <td>
- <% If hn.LetterReturned = 1 Then %>
- <span class="badge bg-warning text-dark">Returned</span>
- <% If Year(hn.ReturnDate) > 1970 Then %>
- <small class="text-muted"><%= FormatDateTime(hn.ReturnDate, 2) %></small>
- <% End If %>
- <% Else %>
- <span class="badge bg-success">No</span>
- <% End If %>
- </td>
- <td><%= FormatDateTime(hn.Created, 2) %></td>
- <td>
- <a href="/householder-names/<%= hn.Id %>" class="btn btn-sm btn-info">View</a>
- <a href="/householder-names/<%= hn.Id %>/edit" class="btn btn-sm btn-warning">Edit</a>
- <form method="post" action="/householder-names/<%= hn.Id %>/delete" style="display:inline;" onsubmit="return confirm('Are you sure you want to delete this householder name?');">
- <button type="submit" class="btn btn-sm btn-danger">Delete</button>
- </form>
- </td>
- </tr>
- <%
- Loop
- End If
- %>
- </tbody>
- </table>
- </div>
-
- <!-- Pagination -->
- <% If HouseholderNameController.pageCount > 1 Then %>
- <%
- Dim baseUrl, pg, startPage, endPage
- baseUrl = "/householder-names?"
- If HouseholderNameController.searchTerm <> "" Then
- baseUrl = baseUrl & "q=" & Server.URLEncode(HouseholderNameController.searchTerm) & "&"
- End If
- If HouseholderNameController.filterHouseholdId > 0 Then
- baseUrl = baseUrl & "household=" & HouseholderNameController.filterHouseholdId & "&"
- End If
-
- ' Calculate pagination range (show 5 pages at a time)
- startPage = HouseholderNameController.currentPage - 2
- If startPage < 1 Then startPage = 1
- endPage = startPage + 4
- If endPage > HouseholderNameController.pageCount Then
- endPage = HouseholderNameController.pageCount
- startPage = endPage - 4
- If startPage < 1 Then startPage = 1
- End If
- %>
- <nav aria-label="Householder names pagination">
- <ul class="pagination justify-content-center">
- <!-- First page -->
- <li class="page-item <% If HouseholderNameController.currentPage = 1 Then Response.Write "disabled" End If %>">
- <a class="page-link" href="<%= baseUrl %>page=1">« First</a>
- </li>
-
- <!-- Previous page -->
- <li class="page-item <% If HouseholderNameController.currentPage = 1 Then Response.Write "disabled" End If %>">
- <a class="page-link" href="<%= baseUrl %>page=<%= HouseholderNameController.currentPage - 1 %>">‹ Prev</a>
- </li>
-
- <!-- Page numbers -->
- <% For pg = startPage To endPage %>
- <li class="page-item <% If pg = HouseholderNameController.currentPage Then Response.Write "active" End If %>">
- <a class="page-link" href="<%= baseUrl %>page=<%= pg %>"><%= pg %></a>
- </li>
- <% Next %>
-
- <!-- Next page -->
- <li class="page-item <% If HouseholderNameController.currentPage >= HouseholderNameController.pageCount Then Response.Write "disabled" End If %>">
- <a class="page-link" href="<%= baseUrl %>page=<%= HouseholderNameController.currentPage + 1 %>">Next ›</a>
- </li>
-
- <!-- Last page -->
- <li class="page-item <% If HouseholderNameController.currentPage >= HouseholderNameController.pageCount Then Response.Write "disabled" End If %>">
- <a class="page-link" href="<%= baseUrl %>page=<%= HouseholderNameController.pageCount %>">Last »</a>
- </li>
- </ul>
- </nav>
- <p class="text-center text-muted">
- Page <%= HouseholderNameController.currentPage %> of <%= HouseholderNameController.pageCount %>
- </p>
- <% End If %>
- </div>
|