25'ten fazla konu seçemezsiniz Konular bir harf veya rakamla başlamalı, kısa çizgiler ('-') içerebilir ve en fazla 35 karakter uzunluğunda olabilir.

173 satır
9.8KB

  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. <% If Len(f("outcome")) > 0 Then %>
  68. <input type="hidden" name="outcome" value="<%= H(f("outcome")) %>" />
  69. <div class="mt-2 small">
  70. <span class="badge text-bg-primary">Outcome: <% If f("outcome") = "none" Then Response.Write "(no outcome)" Else Response.Write H(Businesses_Label(Businesses_Outcomes(), f("outcome"))) %> &middot; last 30 days</span>
  71. <a href="/businesses" class="ms-1">clear</a>
  72. </div>
  73. <% End If %>
  74. <div class="mt-2">
  75. <button type="submit" class="btn btn-primary btn-sm"><i class="bi bi-search"></i> Search</button>
  76. <a href="/businesses" class="btn btn-link btn-sm">Reset</a>
  77. </div>
  78. </div>
  79. </form>
  80. <%
  81. ' Sort header helper values (functions cannot be declared in a view, so build the links inline)
  82. Dim cols, ci, colKey, colLabel, nextDir, arrow
  83. cols = Array(Array("name", "Business"), Array("industry", "Industry"), Array("area", "Areas"), Array("city", "Location"), _
  84. Array("status", "Status"), Array("last_contacted", "Last contacted"), Array("next_action", "Next action"))
  85. %>
  86. <p class="text-muted small mb-2">
  87. <% If total = 0 Then %>
  88. No businesses match.
  89. <% Else %>
  90. Showing <%= FormatNumber(firstRow, 0) %>&ndash;<%= FormatNumber(lastRow, 0) %> of <%= FormatNumber(total, 0) %>
  91. <% End If %>
  92. </p>
  93. <div class="card shadow-sm mb-3">
  94. <div class="table-responsive">
  95. <table class="table table-sm table-hover align-middle mb-0">
  96. <thead class="table-light">
  97. <tr>
  98. <% For ci = 0 To UBound(cols)
  99. colKey = cols(ci)(0) : colLabel = cols(ci)(1)
  100. nextDir = "asc" : arrow = ""
  101. If (sort = colKey) Or (sort = "" And colKey = "name") Then
  102. 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>"
  103. End If
  104. %>
  105. <th><a class="text-decoration-none text-dark" href="/businesses<%= H(Businesses_QS(f, 1, colKey, nextDir)) %>"><%= colLabel %><%= arrow %></a></th>
  106. <% Next %>
  107. <th>Contact</th>
  108. </tr>
  109. </thead>
  110. <tbody>
  111. <% Dim ri, r, due
  112. For ri = 0 To rows.Count - 1
  113. Set r = rows(ri)
  114. %>
  115. <tr>
  116. <td>
  117. <a class="fw-semibold text-decoration-none" href="/businesses/<%= r("id") %>"><%= H(r("name")) %></a>
  118. <% If r("is_customer") = 1 Then %><span class="badge text-bg-success ms-1">Customer</span><% End If %>
  119. <% If Len(r("contact_name") & "") > 0 Then %><div class="small text-muted"><%= H(r("contact_name")) %></div><% End If %>
  120. </td>
  121. <td><%= H(r("industry_name")) %></td>
  122. <td class="small"><%= H(r("areas")) %></td>
  123. <td><%= H(r("city")) %><% If Len(r("city") & "") > 0 And Len(r("state") & "") > 0 Then Response.Write ", " %><%= H(r("state")) %></td>
  124. <td><span class="badge <%= Businesses_StatusClass(r("status")) %>"><%= Businesses_StatusLabel(r("status")) %></span></td>
  125. <td class="small"><%= Date_Fmt(r("last_contacted_at")) %></td>
  126. <td class="small<% due = False
  127. If Not IsNull(r("next_action_date")) Then
  128. If IsDate(r("next_action_date")) Then due = (CDate(r("next_action_date")) < Date)
  129. End If
  130. If due Then Response.Write " text-danger fw-semibold" %>"><%= Date_Fmt(r("next_action_date")) %></td>
  131. <td class="small">
  132. <% If Len(r("phone") & "") > 0 Then %><div><a href="tel:<%= H(r("phone")) %>" class="text-decoration-none"><%= H(r("phone")) %></a></div><% End If %>
  133. <% If Len(r("email") & "") > 0 Then %><div><a href="mailto:<%= H(r("email")) %>" class="text-decoration-none"><%= H(r("email")) %></a></div><% End If %>
  134. </td>
  135. </tr>
  136. <% Next %>
  137. <% If rows.Count = 0 Then %>
  138. <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>
  139. <% End If %>
  140. </tbody>
  141. </table>
  142. </div>
  143. </div>
  144. <% If pageCount > 1 Then
  145. Dim pFrom, pTo, pi
  146. pFrom = page - 3 : If pFrom < 1 Then pFrom = 1
  147. pTo = page + 3 : If pTo > pageCount Then pTo = pageCount
  148. %>
  149. <nav aria-label="Pages">
  150. <ul class="pagination pagination-sm justify-content-center">
  151. <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>
  152. <% If pFrom > 1 Then %>
  153. <li class="page-item"><a class="page-link" href="/businesses<%= H(Businesses_QS(f, 1, sort, dir)) %>">1</a></li>
  154. <% If pFrom > 2 Then %><li class="page-item disabled"><span class="page-link">&hellip;</span></li><% End If %>
  155. <% End If %>
  156. <% For pi = pFrom To pTo %>
  157. <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>
  158. <% Next %>
  159. <% If pTo < pageCount Then %>
  160. <% If pTo < pageCount - 1 Then %><li class="page-item disabled"><span class="page-link">&hellip;</span></li><% End If %>
  161. <li class="page-item"><a class="page-link" href="/businesses<%= H(Businesses_QS(f, pageCount, sort, dir)) %>"><%= pageCount %></a></li>
  162. <% End If %>
  163. <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>
  164. </ul>
  165. </nav>
  166. <% End If %>

Powered by TurnKey Linux.