|
- <%
- ' Tile helper values: label, number, link, optional emphasis class
- Dim tiles, ti, t, pct, pctText, barW, di, dd, barPct, oi, ob, mi, mb, ii, ir, bi_
- tiles = Array( _
- Array("Prospects", counts("prospects"), "/businesses?show=prospects", ""), _
- Array("Previous customers", counts("customers"), "/businesses?show=customers", "text-success"), _
- Array("Never contacted", counts("never_contacted"), "/businesses?show=prospects&contacted=never", ""), _
- Array("Follow-ups overdue", counts("overdue"), "/", Iif_(counts("overdue") > 0, "text-danger", "")), _
- Array("Due today", counts("due_today"), "/", Iif_(counts("due_today") > 0, "text-warning-emphasis", "")), _
- Array("Due in the next 7 days", counts("this_week"), "/", ""), _
- Array("No phone number", counts("no_phone"), "/businesses?show=prospects", "text-muted"), _
- Array("Removed", counts("removed"), "/businesses?status=removed", "text-muted") _
- )
- %>
- <% Flash().ShowErrorsIfPresent : Flash().ShowSuccessIfPresent %>
-
- <div class="d-flex justify-content-between align-items-center mb-3">
- <div>
- <h1 class="h3 mb-0">Dashboard</h1>
- <div class="text-muted small"><%= FormatNumber(counts("active"), 0) %> active businesses · <%= FormatNumber(counts("total"), 0) %> including removed</div>
- </div>
- </div>
-
- <!-- The list -->
- <div class="row g-3 mb-4">
- <% For ti = 0 To UBound(tiles)
- t = tiles(ti) %>
- <div class="col-6 col-md-3">
- <a href="<%= t(2) %>" class="card shadow-sm text-decoration-none h-100">
- <div class="card-body py-3">
- <div class="display-6 fw-semibold <%= t(3) %>"><%= FormatNumber(t(1), 0) %></div>
- <div class="small text-muted"><%= t(0) %></div>
- </div>
- </a>
- </div>
- <% Next %>
- </div>
-
- <div class="row g-3 mb-4">
- <!-- Pipeline -->
- <div class="col-lg-5">
- <div class="card shadow-sm h-100">
- <div class="card-body">
- <h2 class="h5 mb-3">Where everyone stands</h2>
- <%
- Dim stages, si, s, tot
- stages = Array(Array("New", counts("st_new"), "text-bg-secondary", "new"), Array("Contacted", counts("st_contacted"), "text-bg-info", "contacted"), Array("Follow-up", counts("st_follow_up"), "text-bg-warning", "follow_up"))
- tot = counts("st_new") + counts("st_contacted") + counts("st_follow_up")
- If tot = 0 Then tot = 1
- %>
- <div class="progress mb-3" style="height: 1.5rem;" role="img" aria-label="Pipeline breakdown">
- <% For si = 0 To UBound(stages)
- s = stages(si)
- If s(1) > 0 Then %>
- <div class="progress-bar <%= s(2) %>" style="width: <%= Round(s(1) * 100 / tot, 1) %>%"><%= s(0) %></div>
- <% End If
- Next %>
- </div>
- <table class="table table-sm mb-0">
- <% For si = 0 To UBound(stages)
- s = stages(si) %>
- <tr>
- <td><span class="badge <%= s(2) %>"><%= s(0) %></span></td>
- <td class="text-end"><a href="/businesses?status=<%= s(3) %>" class="text-decoration-none"><%= FormatNumber(s(1), 0) %></a></td>
- <td class="text-end text-muted small"><%= Round(s(1) * 100 / tot, 0) %>%</td>
- </tr>
- <% Next %>
- </table>
- <div class="form-text">Counts include previous customers. Removed businesses are not counted here.</div>
- </div>
- </div>
- </div>
-
- <!-- Activity -->
- <div class="col-lg-7">
- <div class="card shadow-sm h-100">
- <div class="card-body">
- <h2 class="h5 mb-3">Contact activity</h2>
- <div class="row text-center mb-3">
- <div class="col-4"><div class="h3 mb-0"><%= FormatNumber(activity("today"), 0) %></div><div class="small text-muted">Today</div></div>
- <div class="col-4"><div class="h3 mb-0"><%= FormatNumber(activity("week"), 0) %></div><div class="small text-muted">Last 7 days</div></div>
- <div class="col-4"><div class="h3 mb-0"><%= FormatNumber(activity("month"), 0) %></div><div class="small text-muted">Last 30 days</div></div>
- </div>
-
- <div class="small text-muted mb-1">Last 14 days</div>
- <div class="d-flex align-items-end gap-1" style="height: 90px;" role="img" aria-label="Contacts per day for the last 14 days">
- <% For di = 0 To daily.Count - 1
- dd = daily(di)
- barPct = Round(dd(1) * 100 / maxDaily, 0)
- If dd(1) > 0 And barPct < 6 Then barPct = 6 %>
- <div class="flex-fill d-flex flex-column justify-content-end align-items-center h-100" title="<%= Date_Fmt(dd(0)) %>: <%= dd(1) %>">
- <div class="small text-muted" style="font-size: .7rem;"><% If dd(1) > 0 Then Response.Write dd(1) %></div>
- <div class="w-100 rounded-top <% If dd(0) = Date Then Response.Write "bg-primary" Else Response.Write "bg-primary-subtle" %>" style="height: <%= barPct %>%; min-height: <% If dd(1) > 0 Then Response.Write "2px" Else Response.Write "1px" %>;<% If dd(1) = 0 Then Response.Write " background:#dee2e6;" %>"></div>
- </div>
- <% Next %>
- </div>
- <div class="d-flex gap-1 small text-muted" style="font-size: .7rem;">
- <% For di = 0 To daily.Count - 1 %>
- <div class="flex-fill text-center"><%= Day(daily(di)(0)) %></div>
- <% Next %>
- </div>
- </div>
- </div>
- </div>
- </div>
-
- <div class="row g-3 mb-4">
- <div class="col-md-6">
- <div class="card shadow-sm h-100">
- <div class="card-body">
- <h2 class="h5 mb-3">How you reached out <span class="text-muted fs-6">(30 days)</span></h2>
- <% If byMethod.Count = 0 Then %><p class="text-muted mb-0">Nothing logged yet.</p><% Else %>
- <table class="table table-sm mb-0">
- <% For mi = 0 To byMethod.Count - 1
- mb = byMethod(mi) %>
- <tr><td><%= H(Businesses_Label(Businesses_Methods(), mb(0))) %></td><td class="text-end"><%= FormatNumber(mb(1), 0) %></td></tr>
- <% Next %>
- </table>
- <% End If %>
- </div>
- </div>
- </div>
- <div class="col-md-6">
- <div class="card shadow-sm h-100">
- <div class="card-body">
- <h2 class="h5 mb-3">Outcomes <span class="text-muted fs-6">(30 days)</span></h2>
- <% If byOutcome.Count = 0 Then %><p class="text-muted mb-0">Nothing logged yet.</p><% Else %>
- <table class="table table-sm mb-0">
- <% For oi = 0 To byOutcome.Count - 1
- ob = byOutcome(oi) %>
- <tr>
- <td><% If Len(ob(0)) = 0 Then Response.Write "<span class=""text-muted"">(no outcome)</span>" Else Response.Write H(Businesses_Label(Businesses_Outcomes(), ob(0))) %></td>
- <td class="text-end"><%= FormatNumber(ob(1), 0) %></td>
- </tr>
- <% Next %>
- </table>
- <% End If %>
- </div>
- </div>
- </div>
- </div>
-
- <div class="row g-3 mb-4">
- <div class="col-lg-7">
- <div class="card shadow-sm h-100">
- <div class="card-body">
- <h2 class="h5 mb-3">Biggest industries <span class="text-muted fs-6">(<a href="/industries" class="text-decoration-none">manage</a>)</span></h2>
- <% If industries.Count = 0 Then %><p class="text-muted mb-0">No industries yet.</p><% Else %>
- <table class="table table-sm align-middle mb-0">
- <thead><tr><th>Industry</th><th class="text-end">Businesses</th><th style="width:40%">Contacted</th></tr></thead>
- <tbody>
- <% For ii = 0 To industries.Count - 1
- ir = industries(ii)
- If ir(2) > 0 Then pct = Round(ir(3) * 100 / ir(2), 0) Else pct = 0
- If ir(3) > 0 And pct = 0 Then pctText = "<1" Else pctText = CStr(pct)
- If ir(3) > 0 And pct = 0 Then barW = 1 Else barW = pct %>
- <tr>
- <td><a href="/businesses?industry=<%= ir(0) %>" class="text-decoration-none"><%= H(ir(1)) %></a></td>
- <td class="text-end"><%= FormatNumber(ir(2), 0) %></td>
- <td>
- <div class="d-flex align-items-center gap-2">
- <div class="progress flex-fill" style="height: .6rem;" role="img" aria-label="<%= pctText %> percent contacted"><div class="progress-bar" style="width: <%= barW %>%"></div></div>
- <span class="small text-muted text-nowrap"><%= FormatNumber(ir(3), 0) %> · <%= pctText %>%</span>
- </div>
- </td>
- </tr>
- <% Next %>
- </tbody>
- </table>
- <% End If %>
- </div>
- </div>
- </div>
- <div class="col-lg-5">
- <div class="card shadow-sm h-100">
- <div class="card-body">
- <h2 class="h5 mb-3">Recent imports <span class="text-muted fs-6">(<a href="/import" class="text-decoration-none">import</a>)</span></h2>
- <% If imports.Count = 0 Then %><p class="text-muted mb-0">No imports yet.</p><% Else %>
- <ul class="list-unstyled mb-0 small">
- <% For bi_ = 0 To imports.Count - 1
- ir = imports(bi_) %>
- <li class="mb-2">
- <div class="fw-semibold text-break"><%= H(ir(1)) %></div>
- <div class="text-muted"><%= Date_Fmt(ir(2)) %> · <%= FormatNumber(ir(4), 0) %> added of <%= FormatNumber(ir(3), 0) %> rows</div>
- </li>
- <% Next %>
- </ul>
- <% End If %>
- </div>
- </div>
- </div>
- </div>
|