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.

188 lignes
9.2KB

  1. <div class="container mt-4">
  2. <div class="d-flex justify-content-between align-items-center mb-4">
  3. <h1>Households</h1>
  4. <a href="/households/new" class="btn btn-primary">New Household</a>
  5. </div>
  6. <% Flash().ShowSuccessIfPresent %>
  7. <% Flash().ShowErrorsIfPresent %>
  8. <!-- Search and Filter Form -->
  9. <div class="card mb-4">
  10. <div class="card-body">
  11. <form method="get" action="/households" class="row g-3">
  12. <div class="col-md-5">
  13. <div class="input-group">
  14. <input type="text" class="form-control" name="q" placeholder="Search by address or street name..." value="<%= Server.HTMLEncode(HouseholdController.searchTerm) %>">
  15. <button class="btn btn-outline-primary" type="submit">Search</button>
  16. </div>
  17. </div>
  18. <div class="col-md-4">
  19. <select name="territory" class="form-select" onchange="this.form.submit()">
  20. <option value="">All Territories</option>
  21. <%
  22. Dim tIter, tItem
  23. Set tIter = HouseholdController.territoriesList.Iterator()
  24. Do While tIter.HasNext()
  25. Set tItem = tIter.GetNext()
  26. %>
  27. <option value="<%= tItem.Id %>" <% If tItem.Id = HouseholdController.filterTerritoryId Then Response.Write "selected" End If %>><%= Server.HTMLEncode(tItem.Name) %></option>
  28. <%
  29. Loop
  30. %>
  31. </select>
  32. </div>
  33. <div class="col-md-2">
  34. <select name="dnc" class="form-select" onchange="this.form.submit()">
  35. <option value="" <% If HouseholdController.filterDoNotCall = -1 Then Response.Write "selected" End If %>>All DNC Status</option>
  36. <option value="1" <% If HouseholdController.filterDoNotCall = 1 Then Response.Write "selected" End If %>>Do Not Call</option>
  37. <option value="0" <% If HouseholdController.filterDoNotCall = 0 Then Response.Write "selected" End If %>>Callable</option>
  38. </select>
  39. </div>
  40. <div class="col-md-1 text-end">
  41. <span class="text-muted">
  42. <%= HouseholdController.recordCount %> household(s)
  43. </span>
  44. <% If HouseholdController.searchTerm <> "" Or HouseholdController.filterTerritoryId > 0 Or HouseholdController.filterDoNotCall > -1 Then %>
  45. <a href="/households" class="btn btn-sm btn-outline-secondary ms-2">Clear</a>
  46. <% End If %>
  47. </div>
  48. </form>
  49. </div>
  50. </div>
  51. <div class="table-responsive">
  52. <table class="table table-striped table-hover">
  53. <thead class="table-dark">
  54. <tr>
  55. <th>ID</th>
  56. <th>Address</th>
  57. <th>Type</th>
  58. <th>DNC</th>
  59. <th>Street</th>
  60. <th>Territory</th>
  61. <th>Actions</th>
  62. </tr>
  63. </thead>
  64. <tbody>
  65. <%
  66. Dim iter, h
  67. Set iter = HouseholdController.households.Iterator()
  68. If Not iter.HasNext() Then
  69. %>
  70. <tr>
  71. <td colspan="7" class="text-center text-muted py-4">
  72. <% If HouseholdController.searchTerm <> "" Then %>
  73. No households found matching "<%= Server.HTMLEncode(HouseholdController.searchTerm) %>"
  74. <% ElseIf HouseholdController.filterTerritoryId > 0 Then %>
  75. No households found in this territory.
  76. <% Else %>
  77. No households found. <a href="/households/new">Create one</a>
  78. <% End If %>
  79. </td>
  80. </tr>
  81. <%
  82. Else
  83. Do While iter.HasNext()
  84. Set h = iter.GetNext()
  85. %>
  86. <tr>
  87. <td><%= h.Id %></td>
  88. <td><%= Server.HTMLEncode(h.Address) %></td>
  89. <td>
  90. <% If h.IsBusiness = 1 Then %>
  91. <span class="badge bg-info">Business</span>
  92. <% Else %>
  93. <span class="badge bg-secondary">Residential</span>
  94. <% End If %>
  95. </td>
  96. <td>
  97. <% If h.DoNotCall = 1 Then %>
  98. <span class="badge bg-danger">Do Not Call</span>
  99. <% If IsDate(h.DoNotCallDate) Then %>
  100. <div><small class="text-muted"><%= FormatDateTime(h.DoNotCallDate, 2) %></small></div>
  101. <% End If %>
  102. <% Else %>
  103. <span class="text-muted">No</span>
  104. <% End If %>
  105. </td>
  106. <td><%= h.StreetNumber %> <%= Server.HTMLEncode(h.StreetName) %></td>
  107. <td>
  108. <a href="/territories/<%= h.TerritoryId %>">
  109. <%
  110. If HouseholdController.territoryNamesById.Exists(CStr(h.TerritoryId)) Then
  111. Response.Write Server.HTMLEncode(HouseholdController.territoryNamesById(CStr(h.TerritoryId)))
  112. Else
  113. Response.Write "Territory " & h.TerritoryId
  114. End If
  115. %>
  116. </a>
  117. </td>
  118. <td>
  119. <a href="/households/<%= h.Id %>" class="btn btn-sm btn-info">View</a>
  120. <a href="/households/<%= h.Id %>/edit" class="btn btn-sm btn-warning">Edit</a>
  121. <form method="post" action="/households/<%= h.Id %>/delete" style="display:inline;" onsubmit="return confirm('Are you sure you want to delete this household?');">
  122. <button type="submit" class="btn btn-sm btn-danger">Delete</button>
  123. </form>
  124. </td>
  125. </tr>
  126. <%
  127. Loop
  128. End If
  129. %>
  130. </tbody>
  131. </table>
  132. </div>
  133. <!-- Pagination -->
  134. <% If HouseholdController.pageCount > 1 Then %>
  135. <%
  136. Dim baseUrl, pg, startPage, endPage
  137. baseUrl = "/households?"
  138. If HouseholdController.searchTerm <> "" Then
  139. baseUrl = baseUrl & "q=" & Server.URLEncode(HouseholdController.searchTerm) & "&"
  140. End If
  141. If HouseholdController.filterTerritoryId > 0 Then
  142. baseUrl = baseUrl & "territory=" & HouseholdController.filterTerritoryId & "&"
  143. End If
  144. If HouseholdController.filterDoNotCall > -1 Then
  145. baseUrl = baseUrl & "dnc=" & HouseholdController.filterDoNotCall & "&"
  146. End If
  147. ' Calculate pagination range (show 5 pages at a time)
  148. startPage = HouseholdController.currentPage - 2
  149. If startPage < 1 Then startPage = 1
  150. endPage = startPage + 4
  151. If endPage > HouseholdController.pageCount Then
  152. endPage = HouseholdController.pageCount
  153. startPage = endPage - 4
  154. If startPage < 1 Then startPage = 1
  155. End If
  156. %>
  157. <nav aria-label="Household pagination">
  158. <ul class="pagination justify-content-center">
  159. <li class="page-item <% If HouseholdController.currentPage = 1 Then Response.Write "disabled" End If %>">
  160. <a class="page-link" href="<%= baseUrl %>page=1">&laquo; First</a>
  161. </li>
  162. <li class="page-item <% If HouseholdController.currentPage = 1 Then Response.Write "disabled" End If %>">
  163. <a class="page-link" href="<%= baseUrl %>page=<%= HouseholdController.currentPage - 1 %>">&lsaquo; Prev</a>
  164. </li>
  165. <% For pg = startPage To endPage %>
  166. <li class="page-item <% If pg = HouseholdController.currentPage Then Response.Write "active" End If %>">
  167. <a class="page-link" href="<%= baseUrl %>page=<%= pg %>"><%= pg %></a>
  168. </li>
  169. <% Next %>
  170. <li class="page-item <% If HouseholdController.currentPage >= HouseholdController.pageCount Then Response.Write "disabled" End If %>">
  171. <a class="page-link" href="<%= baseUrl %>page=<%= HouseholdController.currentPage + 1 %>">Next &rsaquo;</a>
  172. </li>
  173. <li class="page-item <% If HouseholdController.currentPage >= HouseholdController.pageCount Then Response.Write "disabled" End If %>">
  174. <a class="page-link" href="<%= baseUrl %>page=<%= HouseholdController.pageCount %>">Last &raquo;</a>
  175. </li>
  176. </ul>
  177. </nav>
  178. <p class="text-center text-muted">
  179. Page <%= HouseholdController.currentPage %> of <%= HouseholdController.pageCount %>
  180. </p>
  181. <% End If %>
  182. </div>

Powered by TurnKey Linux.