Вы не можете выбрать более 25 тем Темы должны начинаться с буквы или цифры, могут содержать дефисы(-) и должны содержать не более 35 символов.

165 строки
9.2KB

  1. <% Flash().ShowErrorsIfPresent : Flash().ShowSuccessIfPresent %>
  2. <div class="d-flex justify-content-between align-items-center mb-3">
  3. <h1 class="h3 mb-0">Businesses</h1>
  4. <div class="d-flex gap-2">
  5. <a href="/export/businesses<%= H(Businesses_QS(f, 1, sort, dir)) %>" class="btn btn-outline-success btn-sm" title="Download everything matching the current search and filters as a spreadsheet (CSV)"><i class="bi bi-download"></i> Export<% If total > 0 Then Response.Write " " & FormatNumber(total, 0) %></a>
  6. <a href="/import" class="btn btn-outline-primary btn-sm"><i class="bi bi-upload"></i> Import</a>
  7. </div>
  8. </div>
  9. <form method="get" action="/businesses" class="card shadow-sm mb-3">
  10. <div class="card-body">
  11. <div class="row g-2 align-items-end">
  12. <div class="col-lg-3">
  13. <label for="q" class="form-label small mb-1">Search</label>
  14. <input type="text" class="form-control form-control-sm" id="q" name="q" value="<%= H(f("q")) %>" placeholder="Name, contact, email, city or phone" maxlength="100" />
  15. </div>
  16. <div class="col-6 col-lg-2">
  17. <label for="industry" class="form-label small mb-1">Industry</label>
  18. <select class="form-select form-select-sm" id="industry" name="industry">
  19. <option value="">Any</option>
  20. <option value="0"<% If f("industry") = "0" Then Response.Write " selected" %>>(No industry)</option>
  21. <% Dim indKey : For Each indKey In industries.Keys %>
  22. <option value="<%= indKey %>"<% If f("industry") = indKey Then Response.Write " selected" %>><%= H(industries(indKey)) %></option>
  23. <% Next %>
  24. </select>
  25. </div>
  26. <div class="col-6 col-lg-2">
  27. <label for="area" class="form-label small mb-1">Area</label>
  28. <select class="form-select form-select-sm" id="area" name="area">
  29. <option value="">Any</option>
  30. <option value="0"<% If f("area") = "0" Then Response.Write " selected" %>>(No area)</option>
  31. <% Dim ai : For ai = 0 To areas.Count - 1 %>
  32. <option value="<%= areas(ai)("id") %>"<% If f("area") = CStr(areas(ai)("id")) Then Response.Write " selected" %>><%= H(areas(ai)("name")) %></option>
  33. <% Next %>
  34. </select>
  35. </div>
  36. <div class="col-6 col-lg-2">
  37. <label for="status" class="form-label small mb-1">Status</label>
  38. <select class="form-select form-select-sm" id="status" name="status">
  39. <option value=""<% If f("status") = "" Or f("status") = "active" Then Response.Write " selected" %>>Active (not removed)</option>
  40. <option value="all"<% If f("status") = "all" Then Response.Write " selected" %>>All</option>
  41. <option value="new"<% If f("status") = "new" Then Response.Write " selected" %>>New</option>
  42. <option value="contacted"<% If f("status") = "contacted" Then Response.Write " selected" %>>Contacted</option>
  43. <option value="follow_up"<% If f("status") = "follow_up" Then Response.Write " selected" %>>Follow-up</option>
  44. <option value="removed"<% If f("status") = "removed" Then Response.Write " selected" %>>Removed</option>
  45. </select>
  46. </div>
  47. <div class="col-6 col-lg-2">
  48. <label for="show" class="form-label small mb-1">Show</label>
  49. <select class="form-select form-select-sm" id="show" name="show">
  50. <option value="">Everyone</option>
  51. <option value="prospects"<% If f("show") = "prospects" Then Response.Write " selected" %>>Prospects only</option>
  52. <option value="customers"<% If f("show") = "customers" Then Response.Write " selected" %>>Previous customers</option>
  53. </select>
  54. </div>
  55. <div class="col-6 col-lg-2">
  56. <div class="form-check mb-1">
  57. <input class="form-check-input" type="checkbox" id="contacted" name="contacted" value="never"<% If f("contacted") = "never" Then Response.Write " checked" %> />
  58. <label class="form-check-label small" for="contacted">Never contacted</label>
  59. </div>
  60. <div class="form-check mb-1">
  61. <input class="form-check-input" type="checkbox" id="phone" name="phone" value="1"<% If f("phone") = "1" Then Response.Write " checked" %> />
  62. <label class="form-check-label small" for="phone">Has a phone number</label>
  63. </div>
  64. </div>
  65. </div>
  66. <div class="mt-2">
  67. <button type="submit" class="btn btn-primary btn-sm"><i class="bi bi-search"></i> Search</button>
  68. <a href="/businesses" class="btn btn-link btn-sm">Reset</a>
  69. </div>
  70. </div>
  71. </form>
  72. <%
  73. ' Sort header helper values (functions cannot be declared in a view, so build the links inline)
  74. Dim cols, ci, colKey, colLabel, nextDir, arrow
  75. cols = Array(Array("name", "Business"), Array("industry", "Industry"), Array("area", "Areas"), Array("city", "Location"), _
  76. Array("status", "Status"), Array("last_contacted", "Last contacted"), Array("next_action", "Next action"))
  77. %>
  78. <p class="text-muted small mb-2">
  79. <% If total = 0 Then %>
  80. No businesses match.
  81. <% Else %>
  82. Showing <%= FormatNumber(firstRow, 0) %>&ndash;<%= FormatNumber(lastRow, 0) %> of <%= FormatNumber(total, 0) %>
  83. <% End If %>
  84. </p>
  85. <div class="card shadow-sm mb-3">
  86. <div class="table-responsive">
  87. <table class="table table-sm table-hover align-middle mb-0">
  88. <thead class="table-light">
  89. <tr>
  90. <% For ci = 0 To UBound(cols)
  91. colKey = cols(ci)(0) : colLabel = cols(ci)(1)
  92. nextDir = "asc" : arrow = ""
  93. If (sort = colKey) Or (sort = "" And colKey = "name") Then
  94. If dir = "asc" Then nextDir = "desc" : arrow = " <i class=""bi bi-caret-up-fill""></i>" Else nextDir = "asc" : arrow = " <i class=""bi bi-caret-down-fill""></i>"
  95. End If
  96. %>
  97. <th><a class="text-decoration-none text-dark" href="/businesses<%= H(Businesses_QS(f, 1, colKey, nextDir)) %>"><%= colLabel %><%= arrow %></a></th>
  98. <% Next %>
  99. <th>Contact</th>
  100. </tr>
  101. </thead>
  102. <tbody>
  103. <% Dim ri, r, due
  104. For ri = 0 To rows.Count - 1
  105. Set r = rows(ri)
  106. %>
  107. <tr>
  108. <td>
  109. <a class="fw-semibold text-decoration-none" href="/businesses/<%= r("id") %>"><%= H(r("name")) %></a>
  110. <% If r("is_customer") = 1 Then %><span class="badge text-bg-success ms-1">Customer</span><% End If %>
  111. <% If Len(r("contact_name") & "") > 0 Then %><div class="small text-muted"><%= H(r("contact_name")) %></div><% End If %>
  112. </td>
  113. <td><%= H(r("industry_name")) %></td>
  114. <td class="small"><%= H(r("areas")) %></td>
  115. <td><%= H(r("city")) %><% If Len(r("city") & "") > 0 And Len(r("state") & "") > 0 Then Response.Write ", " %><%= H(r("state")) %></td>
  116. <td><span class="badge <%= Businesses_StatusClass(r("status")) %>"><%= Businesses_StatusLabel(r("status")) %></span></td>
  117. <td class="small"><%= Date_Fmt(r("last_contacted_at")) %></td>
  118. <td class="small<% due = False
  119. If Not IsNull(r("next_action_date")) Then
  120. If IsDate(r("next_action_date")) Then due = (CDate(r("next_action_date")) < Date)
  121. End If
  122. If due Then Response.Write " text-danger fw-semibold" %>"><%= Date_Fmt(r("next_action_date")) %></td>
  123. <td class="small">
  124. <% If Len(r("phone") & "") > 0 Then %><div><a href="tel:<%= H(r("phone")) %>" class="text-decoration-none"><%= H(r("phone")) %></a></div><% End If %>
  125. <% If Len(r("email") & "") > 0 Then %><div><a href="mailto:<%= H(r("email")) %>" class="text-decoration-none"><%= H(r("email")) %></a></div><% End If %>
  126. </td>
  127. </tr>
  128. <% Next %>
  129. <% If rows.Count = 0 Then %>
  130. <tr><td colspan="8"class="text-center text-muted py-4">Nothing to show. Try different filters, or <a href="/import">import a list</a>.</td></tr>
  131. <% End If %>
  132. </tbody>
  133. </table>
  134. </div>
  135. </div>
  136. <% If pageCount > 1 Then
  137. Dim pFrom, pTo, pi
  138. pFrom = page - 3 : If pFrom < 1 Then pFrom = 1
  139. pTo = page + 3 : If pTo > pageCount Then pTo = pageCount
  140. %>
  141. <nav aria-label="Pages">
  142. <ul class="pagination pagination-sm justify-content-center">
  143. <li class="page-item<% If page = 1 Then Response.Write " disabled" %>"><a class="page-link" href="/businesses<%= H(Businesses_QS(f, page - 1, sort, dir)) %>">Previous</a></li>
  144. <% If pFrom > 1 Then %>
  145. <li class="page-item"><a class="page-link" href="/businesses<%= H(Businesses_QS(f, 1, sort, dir)) %>">1</a></li>
  146. <% If pFrom > 2 Then %><li class="page-item disabled"><span class="page-link">&hellip;</span></li><% End If %>
  147. <% End If %>
  148. <% For pi = pFrom To pTo %>
  149. <li class="page-item<% If pi = page Then Response.Write " active" %>"><a class="page-link" href="/businesses<%= H(Businesses_QS(f, pi, sort, dir)) %>"><%= pi %></a></li>
  150. <% Next %>
  151. <% If pTo < pageCount Then %>
  152. <% If pTo < pageCount - 1 Then %><li class="page-item disabled"><span class="page-link">&hellip;</span></li><% End If %>
  153. <li class="page-item"><a class="page-link" href="/businesses<%= H(Businesses_QS(f, pageCount, sort, dir)) %>"><%= pageCount %></a></li>
  154. <% End If %>
  155. <li class="page-item<% If page = pageCount Then Response.Write " disabled" %>"><a class="page-link" href="/businesses<%= H(Businesses_QS(f, page + 1, sort, dir)) %>">Next</a></li>
  156. </ul>
  157. </nav>
  158. <% End If %>

Powered by TurnKey Linux.