Nevar pievienot vairāk kā 25 tēmas Tēmai ir jāsākas ar burtu vai ciparu, tā var saturēt domu zīmes ('-') un var būt līdz 35 simboliem gara.

166 rindas
9.3KB

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

Powered by TurnKey Linux.