|
- <div class="container mt-4">
- <%
- Dim dncNotesVal, dncPrivateNotesVal
- dncNotesVal = ""
- dncPrivateNotesVal = ""
- If Not IsNull(HouseholdController.household.DoNotCallNotes) Then dncNotesVal = HouseholdController.household.DoNotCallNotes
- If Not IsNull(HouseholdController.household.DoNotCallPrivateNotes) Then dncPrivateNotesVal = HouseholdController.household.DoNotCallPrivateNotes
- %>
- <nav aria-label="breadcrumb">
- <ol class="breadcrumb">
- <li class="breadcrumb-item"><a href="/households">Households</a></li>
- <li class="breadcrumb-item active" aria-current="page"><%= Server.HTMLEncode(HouseholdController.household.Address) %></li>
- </ol>
- </nav>
-
- <% Flash().ShowSuccessIfPresent %>
- <% Flash().ShowErrorsIfPresent %>
-
- <div class="card">
- <div class="card-header d-flex justify-content-between align-items-center">
- <h2 class="mb-0"><%= Server.HTMLEncode(HouseholdController.household.Address) %></h2>
- <div>
- <a href="/households/<%= HouseholdController.household.Id %>/edit" class="btn btn-warning">Edit</a>
- <form method="post" action="/households/<%= HouseholdController.household.Id %>/delete" style="display:inline;" onsubmit="return confirm('Are you sure you want to delete this household?');">
- <button type="submit" class="btn btn-danger">Delete</button>
- </form>
- </div>
- </div>
- <div class="card-body">
- <div class="row">
- <div class="col-md-6">
- <dl>
- <dt>ID</dt>
- <dd><%= HouseholdController.household.Id %></dd>
-
- <dt>Address</dt>
- <dd><%= Server.HTMLEncode(HouseholdController.household.Address) %></dd>
-
- <dt>Street Number</dt>
- <dd><%= HouseholdController.household.StreetNumber %></dd>
-
- <dt>Street Name</dt>
- <dd><%= Server.HTMLEncode(HouseholdController.household.StreetName & "") %></dd>
-
- <dt>Type</dt>
- <dd>
- <% If HouseholdController.household.IsBusiness = 1 Then %>
- <span class="badge bg-info">Business</span>
- <% Else %>
- <span class="badge bg-secondary">Residential</span>
- <% End If %>
- <% If HouseholdController.household.DoNotCall = 1 Then %>
- <span class="badge bg-danger ms-2">Do Not Call</span>
- <% End If %>
- </dd>
-
- <dt>Do Not Call Date</dt>
- <dd>
- <% If IsDate(HouseholdController.household.DoNotCallDate) Then %>
- <%= FormatDateTime(HouseholdController.household.DoNotCallDate, 2) %>
- <% Else %>
- <span class="text-muted">Not set</span>
- <% End If %>
- </dd>
-
- <dt>Do Not Call Notes</dt>
- <dd>
- <% If Trim(dncNotesVal) <> "" Then %>
- <%= Server.HTMLEncode(dncNotesVal) %>
- <% Else %>
- <span class="text-muted">None</span>
- <% End If %>
- </dd>
-
- <dt>Private DNC Notes</dt>
- <dd>
- <% If Trim(dncPrivateNotesVal) <> "" Then %>
- <%= Server.HTMLEncode(dncPrivateNotesVal) %>
- <% Else %>
- <span class="text-muted">None</span>
- <% End If %>
- </dd>
-
- <dt>Territory</dt>
- <dd><a href="/territories/<%= HouseholdController.household.TerritoryId %>">Territory <%= HouseholdController.household.TerritoryId %></a></dd>
- </dl>
- </div>
- <div class="col-md-6">
- <dl>
- <dt>Latitude</dt>
- <dd><%= Server.HTMLEncode(HouseholdController.household.Latitude & "") %></dd>
-
- <dt>Longitude</dt>
- <dd><%= Server.HTMLEncode(HouseholdController.household.Longitude & "") %></dd>
- </dl>
-
- <% If HouseholdController.household.Latitude <> "" And HouseholdController.household.Longitude <> "" Then %>
- <div id="map" style="height: 250px; width: 100%; border-radius: 8px;"></div>
- <% End If %>
- </div>
- </div>
- </div>
- </div>
-
- <!-- Householder Names Section -->
- <div class="card mt-4">
- <div class="card-header d-flex justify-content-between align-items-center">
- <h5 class="mb-0">Householder Names</h5>
- <a href="/householder-names/new?household=<%= HouseholdController.household.Id %>" class="btn btn-sm btn-success">Add Name</a>
- </div>
- <div class="card-body p-0">
- <%
- Dim hnIter, hn
- Set hnIter = HouseholdController.householderNames.Iterator()
- If Not hnIter.HasNext() Then
- %>
- <div class="p-3 text-center text-muted">
- No householder names recorded. <a href="/householder-names/new?household=<%= HouseholdController.household.Id %>">Add one</a>
- </div>
- <%
- Else
- %>
- <table class="table table-hover mb-0">
- <thead class="table-light">
- <tr>
- <th>Name</th>
- <th>Type</th>
- <th style="width: 180px;">Letter Status</th>
- <th style="width: 100px;">Actions</th>
- </tr>
- </thead>
- <tbody>
- <%
- Do While hnIter.HasNext()
- Set hn = hnIter.GetNext()
- %>
- <tr>
- <td>
- <a href="/householder-names/<%= hn.Id %>"><%= Server.HTMLEncode(hn.Name & "") %></a>
- </td>
- <td>
- <% If HouseholdController.household.IsBusiness = 1 Then %>
- <span class="badge bg-info">Business</span>
- <% Else %>
- <span class="badge bg-secondary">Residential</span>
- <% End If %>
- </td>
- <td>
- <form method="post" action="/households/<%= HouseholdController.household.Id %>/mark-returned" style="display:inline;">
- <input type="hidden" name="householder_id" value="<%= hn.Id %>">
- <% If hn.LetterReturned = 1 Then %>
- <button type="submit" class="btn btn-sm btn-warning" title="Click to mark as NOT returned">
- Returned
- <% If Year(hn.ReturnDate) > 1970 Then %>
- <small>(<%= FormatDateTime(hn.ReturnDate, 2) %>)</small>
- <% End If %>
- </button>
- <% Else %>
- <button type="submit" class="btn btn-sm btn-outline-success" title="Click to mark as returned">
- Not Returned
- </button>
- <% End If %>
- </form>
- </td>
- <td>
- <a href="/householder-names/<%= hn.Id %>/edit" class="btn btn-sm btn-outline-warning" title="Edit">Edit</a>
- </td>
- </tr>
- <%
- Loop
- %>
- </tbody>
- </table>
- <%
- End If
- %>
- </div>
- </div>
-
- <div class="mt-3">
- <a href="/households" class="btn btn-secondary">Back to List</a>
- <a href="/households?territory=<%= HouseholdController.household.TerritoryId %>" class="btn btn-outline-primary">View Territory Households</a>
- </div>
- </div>
-
- <% If HouseholdController.household.Latitude <> "" And HouseholdController.household.Longitude <> "" Then %>
- <%
- Dim mapProvider, googleMapsKey, mapTilerKey, mapTilerStyle, mapTilerSdkJsUrl, mapTilerSdkCssUrl
- mapProvider = LCase(Trim(GetAppSetting("MapProvider") & ""))
- If mapProvider <> "maptiler" Then mapProvider = "google"
-
- googleMapsKey = Trim(GetAppSetting("GoogleMapsApiKey") & "")
- mapTilerKey = Trim(GetAppSetting("MapTilerApiKey") & "")
- mapTilerStyle = Trim(GetAppSetting("MapTilerStyle") & "")
- If mapTilerStyle = "" Or LCase(mapTilerStyle) = "nothing" Then mapTilerStyle = "streets-v2"
-
- mapTilerSdkJsUrl = Trim(GetAppSetting("MapTilerSdkJsUrl") & "")
- mapTilerSdkCssUrl = Trim(GetAppSetting("MapTilerSdkCssUrl") & "")
- If mapTilerSdkJsUrl = "" Or LCase(mapTilerSdkJsUrl) = "nothing" Then mapTilerSdkJsUrl = "https://cdn.maptiler.com/maptiler-sdk-js/v3.0.0/maptiler-sdk.umd.min.js"
- If mapTilerSdkCssUrl = "" Or LCase(mapTilerSdkCssUrl) = "nothing" Then mapTilerSdkCssUrl = "https://cdn.maptiler.com/maptiler-sdk-js/v3.0.0/maptiler-sdk.css"
- %>
- <script>
- var householdLat = <%= HouseholdController.household.Latitude %>;
- var householdLng = <%= HouseholdController.household.Longitude %>;
- var mapProvider = "<%= Replace(mapProvider, """", "\""") %>";
- var googleMapsKey = "<%= Replace(googleMapsKey, """", "\""") %>";
- var mapTilerKey = "<%= Replace(mapTilerKey, """", "\""") %>";
- var mapTilerStyle = "<%= Replace(mapTilerStyle, """", "\""") %>";
- </script>
- <% If mapProvider = "maptiler" Then %>
- <link rel="stylesheet" href="<%= Server.HTMLEncode(mapTilerSdkCssUrl) %>" />
- <script src="<%= Server.HTMLEncode(mapTilerSdkJsUrl) %>"></script>
- <% Else %>
- <script src="https://maps.googleapis.com/maps/api/js?key=<%= Server.HTMLEncode(googleMapsKey) %>&callback=initMap" async defer></script>
- <% End If %>
- <script>
- function setMapMessage(message) {
- var mapEl = document.getElementById('map');
- if (mapEl) {
- mapEl.innerHTML = '<div class="alert alert-info">' + message + '</div>';
- }
- }
-
- function initMap() {
- try {
- if (mapProvider === 'maptiler') {
- if (!mapTilerKey || mapTilerKey === 'nothing') {
- setMapMessage('MapTiler API key is missing.');
- return;
- }
- if (typeof maptilersdk === 'undefined') {
- setMapMessage('MapTiler SDK failed to load.');
- return;
- }
-
- maptilersdk.config.apiKey = mapTilerKey;
- var styleUrl = 'https://api.maptiler.com/maps/' + encodeURIComponent(mapTilerStyle) + '/style.json?key=' + encodeURIComponent(mapTilerKey);
- var location = [parseFloat(householdLng), parseFloat(householdLat)];
-
- var map = new maptilersdk.Map({
- container: 'map',
- style: styleUrl,
- center: location,
- zoom: 17
- });
-
- new maptilersdk.Marker()
- .setLngLat(location)
- .addTo(map);
-
- return;
- }
-
- var location = { lat: householdLat, lng: householdLng };
-
- var map = new google.maps.Map(document.getElementById('map'), {
- zoom: 17,
- center: location,
- mapTypeId: 'roadmap'
- });
-
- var marker = new google.maps.Marker({
- position: location,
- map: map,
- title: '<%= Replace(HouseholdController.household.Address, "'", "\'") %>'
- });
- } catch (e) {
- setMapMessage('Map error: ' + e.message);
- }
- }
-
- if (mapProvider === 'maptiler') {
- if (document.readyState === 'loading') {
- document.addEventListener('DOMContentLoaded', initMap);
- } else {
- initMap();
- }
- setTimeout(function() {
- if (typeof maptilersdk === 'undefined') {
- setMapMessage('MapTiler SDK failed to load.');
- }
- }, 2000);
- } else {
- setTimeout(function() {
- if (typeof google === 'undefined') {
- setMapMessage('Google Maps failed to load.');
- }
- }, 2000);
- }
- </script>
- <% End If %>
|