Consolidated ASP Classic MVC framework from best components
Vous ne pouvez pas sélectionner plus de 25 sujets Les noms de sujets doivent commencer par une lettre ou un nombre, peuvent contenir des tirets ('-') et peuvent comporter jusqu'à 35 caractères.

151 lignes
6.7KB

  1. <div class="container mt-4">
  2. <div class="d-flex justify-content-between align-items-center mb-4">
  3. <h1>Territories</h1>
  4. <a href="/territories/new" class="btn btn-primary">New Territory</a>
  5. </div>
  6. <% Flash().ShowSuccessIfPresent %>
  7. <% Flash().ShowErrorsIfPresent %>
  8. <!-- Search Form -->
  9. <div class="card mb-4">
  10. <div class="card-body">
  11. <form method="get" action="/territories" class="row g-3">
  12. <div class="col-md-8">
  13. <div class="input-group">
  14. <input type="text" class="form-control" name="q" placeholder="Search by name or description..." value="<%= Server.HTMLEncode(TerritoryController.searchTerm) %>">
  15. <button class="btn btn-outline-primary" type="submit">Search</button>
  16. <% If TerritoryController.searchTerm <> "" Then %>
  17. <a href="/territories" class="btn btn-outline-secondary">Clear</a>
  18. <% End If %>
  19. </div>
  20. </div>
  21. <div class="col-md-4 text-end">
  22. <span class="text-muted">
  23. <% If TerritoryController.searchTerm <> "" Then %>
  24. Found <%= TerritoryController.recordCount %> result(s)
  25. <% Else %>
  26. <%= TerritoryController.recordCount %> total territories
  27. <% End If %>
  28. </span>
  29. </div>
  30. </form>
  31. </div>
  32. </div>
  33. <div class="table-responsive">
  34. <table class="table table-striped table-hover">
  35. <thead class="table-dark">
  36. <tr>
  37. <th>ID</th>
  38. <th>Name</th>
  39. <th>Description</th>
  40. <th>Households</th>
  41. <th>Actions</th>
  42. </tr>
  43. </thead>
  44. <tbody>
  45. <%
  46. Dim iter, t
  47. Set iter = TerritoryController.territories.Iterator()
  48. If Not iter.HasNext() Then
  49. %>
  50. <tr>
  51. <td colspan="5" class="text-center text-muted py-4">
  52. <% If TerritoryController.searchTerm <> "" Then %>
  53. No territories found matching "<%= Server.HTMLEncode(TerritoryController.searchTerm) %>"
  54. <% Else %>
  55. No territories found. <a href="/territories/new">Create one</a>
  56. <% End If %>
  57. </td>
  58. </tr>
  59. <%
  60. Else
  61. Do While iter.HasNext()
  62. Set t = iter.GetNext()
  63. %>
  64. <tr>
  65. <td><%= t.Id %></td>
  66. <td><%= Server.HTMLEncode(t.Name) %></td>
  67. <td><%= Server.HTMLEncode(Left(t.Description & "", 50)) %><% If Len(t.Description & "") > 50 Then Response.Write "..." End If %></td>
  68. <%
  69. Dim householdCount
  70. householdCount = 0
  71. If IsObject(TerritoryController.territoryHouseholdCounts) Then
  72. If TerritoryController.territoryHouseholdCounts.Exists(CLng(t.Id)) Then
  73. householdCount = TerritoryController.territoryHouseholdCounts(CLng(t.Id))
  74. End If
  75. End If
  76. %>
  77. <td><%= householdCount %></td>
  78. <td>
  79. <a href="/territories/<%= t.Id %>" class="btn btn-sm btn-info">View</a>
  80. <a href="/territories/<%= t.Id %>/edit" class="btn btn-sm btn-warning">Edit</a>
  81. <form method="post" action="/territories/<%= t.Id %>/delete" style="display:inline;" onsubmit="return confirm('Are you sure you want to delete this territory?');">
  82. <button type="submit" class="btn btn-sm btn-danger">Delete</button>
  83. </form>
  84. </td>
  85. </tr>
  86. <%
  87. Loop
  88. End If
  89. %>
  90. </tbody>
  91. </table>
  92. </div>
  93. <!-- Pagination -->
  94. <% If TerritoryController.pageCount > 1 Then %>
  95. <%
  96. Dim baseUrl, pg, startPage, endPage
  97. baseUrl = "/territories?"
  98. If TerritoryController.searchTerm <> "" Then
  99. baseUrl = baseUrl & "q=" & Server.URLEncode(TerritoryController.searchTerm) & "&"
  100. End If
  101. ' Calculate pagination range (show 5 pages at a time)
  102. startPage = TerritoryController.currentPage - 2
  103. If startPage < 1 Then startPage = 1
  104. endPage = startPage + 4
  105. If endPage > TerritoryController.pageCount Then
  106. endPage = TerritoryController.pageCount
  107. startPage = endPage - 4
  108. If startPage < 1 Then startPage = 1
  109. End If
  110. %>
  111. <nav aria-label="Territory pagination">
  112. <ul class="pagination justify-content-center">
  113. <!-- First page -->
  114. <li class="page-item <% If TerritoryController.currentPage = 1 Then Response.Write "disabled" End If %>">
  115. <a class="page-link" href="<%= baseUrl %>page=1">&laquo; First</a>
  116. </li>
  117. <!-- Previous page -->
  118. <li class="page-item <% If TerritoryController.currentPage = 1 Then Response.Write "disabled" End If %>">
  119. <a class="page-link" href="<%= baseUrl %>page=<%= TerritoryController.currentPage - 1 %>">&lsaquo; Prev</a>
  120. </li>
  121. <!-- Page numbers -->
  122. <% For pg = startPage To endPage %>
  123. <li class="page-item <% If pg = TerritoryController.currentPage Then Response.Write "active" End If %>">
  124. <a class="page-link" href="<%= baseUrl %>page=<%= pg %>"><%= pg %></a>
  125. </li>
  126. <% Next %>
  127. <!-- Next page -->
  128. <li class="page-item <% If TerritoryController.currentPage >= TerritoryController.pageCount Then Response.Write "disabled" End If %>">
  129. <a class="page-link" href="<%= baseUrl %>page=<%= TerritoryController.currentPage + 1 %>">Next &rsaquo;</a>
  130. </li>
  131. <!-- Last page -->
  132. <li class="page-item <% If TerritoryController.currentPage >= TerritoryController.pageCount Then Response.Write "disabled" End If %>">
  133. <a class="page-link" href="<%= baseUrl %>page=<%= TerritoryController.pageCount %>">Last &raquo;</a>
  134. </li>
  135. </ul>
  136. </nav>
  137. <p class="text-center text-muted">
  138. Page <%= TerritoryController.currentPage %> of <%= TerritoryController.pageCount %>
  139. </p>
  140. <% End If %>
  141. </div>

Powered by TurnKey Linux.