|
- <% Flash().ShowErrorsIfPresent : Flash().ShowSuccessIfPresent %>
-
- <div class="d-flex justify-content-between align-items-center mb-3">
- <h1 class="h3 mb-0">Businesses</h1>
- <div class="d-flex gap-2">
- <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>
- <a href="/import" class="btn btn-outline-primary btn-sm"><i class="bi bi-upload"></i> Import</a>
- </div>
- </div>
-
- <form method="get" action="/businesses" class="card shadow-sm mb-3">
- <div class="card-body">
- <div class="row g-2 align-items-end">
- <div class="col-lg-4">
- <label for="q" class="form-label small mb-1">Search</label>
- <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" />
- </div>
- <div class="col-6 col-lg-2">
- <label for="industry" class="form-label small mb-1">Industry</label>
- <select class="form-select form-select-sm" id="industry" name="industry">
- <option value="">Any</option>
- <option value="0"<% If f("industry") = "0" Then Response.Write " selected" %>>(No industry)</option>
- <% Dim indKey : For Each indKey In industries.Keys %>
- <option value="<%= indKey %>"<% If f("industry") = indKey Then Response.Write " selected" %>><%= H(industries(indKey)) %></option>
- <% Next %>
- </select>
- </div>
- <div class="col-6 col-lg-2">
- <label for="status" class="form-label small mb-1">Status</label>
- <select class="form-select form-select-sm" id="status" name="status">
- <option value=""<% If f("status") = "" Or f("status") = "active" Then Response.Write " selected" %>>Active (not removed)</option>
- <option value="all"<% If f("status") = "all" Then Response.Write " selected" %>>All</option>
- <option value="new"<% If f("status") = "new" Then Response.Write " selected" %>>New</option>
- <option value="contacted"<% If f("status") = "contacted" Then Response.Write " selected" %>>Contacted</option>
- <option value="follow_up"<% If f("status") = "follow_up" Then Response.Write " selected" %>>Follow-up</option>
- <option value="removed"<% If f("status") = "removed" Then Response.Write " selected" %>>Removed</option>
- </select>
- </div>
- <div class="col-6 col-lg-2">
- <label for="show" class="form-label small mb-1">Show</label>
- <select class="form-select form-select-sm" id="show" name="show">
- <option value="">Everyone</option>
- <option value="prospects"<% If f("show") = "prospects" Then Response.Write " selected" %>>Prospects only</option>
- <option value="customers"<% If f("show") = "customers" Then Response.Write " selected" %>>Previous customers</option>
- </select>
- </div>
- <div class="col-6 col-lg-2">
- <div class="form-check mb-1">
- <input class="form-check-input" type="checkbox" id="contacted" name="contacted" value="never"<% If f("contacted") = "never" Then Response.Write " checked" %> />
- <label class="form-check-label small" for="contacted">Never contacted</label>
- </div>
- <div class="form-check mb-1">
- <input class="form-check-input" type="checkbox" id="phone" name="phone" value="1"<% If f("phone") = "1" Then Response.Write " checked" %> />
- <label class="form-check-label small" for="phone">Has a phone number</label>
- </div>
- </div>
- </div>
- <div class="mt-2">
- <button type="submit" class="btn btn-primary btn-sm"><i class="bi bi-search"></i> Search</button>
- <a href="/businesses" class="btn btn-link btn-sm">Reset</a>
- </div>
- </div>
- </form>
-
- <%
- ' Sort header helper values (functions cannot be declared in a view, so build the links inline)
- Dim cols, ci, colKey, colLabel, nextDir, arrow
- cols = Array(Array("name", "Business"), Array("industry", "Industry"), Array("city", "Location"), _
- Array("status", "Status"), Array("last_contacted", "Last contacted"), Array("next_action", "Next action"))
- %>
-
- <p class="text-muted small mb-2">
- <% If total = 0 Then %>
- No businesses match.
- <% Else %>
- Showing <%= FormatNumber(firstRow, 0) %>–<%= FormatNumber(lastRow, 0) %> of <%= FormatNumber(total, 0) %>
- <% End If %>
- </p>
-
- <div class="card shadow-sm mb-3">
- <div class="table-responsive">
- <table class="table table-sm table-hover align-middle mb-0">
- <thead class="table-light">
- <tr>
- <% For ci = 0 To UBound(cols)
- colKey = cols(ci)(0) : colLabel = cols(ci)(1)
- nextDir = "asc" : arrow = ""
- If (sort = colKey) Or (sort = "" And colKey = "name") Then
- 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>"
- End If
- %>
- <th><a class="text-decoration-none text-dark" href="/businesses<%= H(Businesses_QS(f, 1, colKey, nextDir)) %>"><%= colLabel %><%= arrow %></a></th>
- <% Next %>
- <th>Contact</th>
- </tr>
- </thead>
- <tbody>
- <% Dim ri, r, due
- For ri = 0 To rows.Count - 1
- Set r = rows(ri)
- %>
- <tr>
- <td>
- <a class="fw-semibold text-decoration-none" href="/businesses/<%= r("id") %>"><%= H(r("name")) %></a>
- <% If r("is_customer") = 1 Then %><span class="badge text-bg-success ms-1">Customer</span><% End If %>
- <% If Len(r("contact_name") & "") > 0 Then %><div class="small text-muted"><%= H(r("contact_name")) %></div><% End If %>
- </td>
- <td><%= H(r("industry_name")) %></td>
- <td><%= H(r("city")) %><% If Len(r("city") & "") > 0 And Len(r("state") & "") > 0 Then Response.Write ", " %><%= H(r("state")) %></td>
- <td><span class="badge <%= Businesses_StatusClass(r("status")) %>"><%= Businesses_StatusLabel(r("status")) %></span></td>
- <td class="small"><%= Date_Fmt(r("last_contacted_at")) %></td>
- <td class="small<% due = False
- If Not IsNull(r("next_action_date")) Then
- If IsDate(r("next_action_date")) Then due = (CDate(r("next_action_date")) < Date)
- End If
- If due Then Response.Write " text-danger fw-semibold" %>"><%= Date_Fmt(r("next_action_date")) %></td>
- <td class="small">
- <% If Len(r("phone") & "") > 0 Then %><div><a href="tel:<%= H(r("phone")) %>" class="text-decoration-none"><%= H(r("phone")) %></a></div><% End If %>
- <% If Len(r("email") & "") > 0 Then %><div><a href="mailto:<%= H(r("email")) %>" class="text-decoration-none"><%= H(r("email")) %></a></div><% End If %>
- </td>
- </tr>
- <% Next %>
- <% If rows.Count = 0 Then %>
- <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>
- <% End If %>
- </tbody>
- </table>
- </div>
- </div>
-
- <% If pageCount > 1 Then
- Dim pFrom, pTo, pi
- pFrom = page - 3 : If pFrom < 1 Then pFrom = 1
- pTo = page + 3 : If pTo > pageCount Then pTo = pageCount
- %>
- <nav aria-label="Pages">
- <ul class="pagination pagination-sm justify-content-center">
- <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>
- <% If pFrom > 1 Then %>
- <li class="page-item"><a class="page-link" href="/businesses<%= H(Businesses_QS(f, 1, sort, dir)) %>">1</a></li>
- <% If pFrom > 2 Then %><li class="page-item disabled"><span class="page-link">…</span></li><% End If %>
- <% End If %>
- <% For pi = pFrom To pTo %>
- <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>
- <% Next %>
- <% If pTo < pageCount Then %>
- <% If pTo < pageCount - 1 Then %><li class="page-item disabled"><span class="page-link">…</span></li><% End If %>
- <li class="page-item"><a class="page-link" href="/businesses<%= H(Businesses_QS(f, pageCount, sort, dir)) %>"><%= pageCount %></a></li>
- <% End If %>
- <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>
- </ul>
- </nav>
- <% End If %>
|