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.

154 rindas
8.6KB

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

Powered by TurnKey Linux.