From afa0286a2a11e08ab009d0a1f575c3e5fd2b49d0 Mon Sep 17 00:00:00 2001 From: Dan Gowans Date: Mon, 28 Apr 2025 13:08:31 -0400 Subject: [PATCH] show funeral details on work order view --- database/getContracts.js | 8 ++- database/getContracts.ts | 8 ++- views/workOrder-view.ejs | 143 +++++++++++++++++++++++---------------- 3 files changed, 96 insertions(+), 63 deletions(-) diff --git a/database/getContracts.js b/database/getContracts.js index 3416725e..6f4002ec 100644 --- a/database/getContracts.js +++ b/database/getContracts.js @@ -1,4 +1,4 @@ -import { dateIntegerToString, dateStringToInteger, timeIntegerToString } from '@cityssm/utils-datetime'; +import { dateIntegerToString, dateStringToInteger, timeIntegerToPeriodString, timeIntegerToString } from '@cityssm/utils-datetime'; import sqlite from 'better-sqlite3'; import { getConfigProperty } from '../helpers/config.helpers.js'; import { sunriseDB } from '../helpers/database.helpers.js'; @@ -11,6 +11,7 @@ export default async function getContracts(filters, options, connectedDatabase) const database = connectedDatabase ?? sqlite(sunriseDB); database.function('userFn_dateIntegerToString', dateIntegerToString); database.function('userFn_timeIntegerToString', timeIntegerToString); + database.function('userFn_timeIntegerToPeriodString', timeIntegerToPeriodString); const { sqlParameters, sqlWhereClause } = buildWhereClause(filters); let count = typeof options.limit === 'string' ? Number.parseInt(options.limit, 10) @@ -40,7 +41,10 @@ export default async function getContracts(filters, options, connectedDatabase) o.funeralHomeId, o.funeralDirectorName, f.funeralHomeName, o.funeralDate, userFn_dateIntegerToString(o.funeralDate) as funeralDateString, - o.funeralTime, userFn_timeIntegerToString(o.funeralTime) as funeralTimeString, + o.funeralTime, + userFn_timeIntegerToString(o.funeralTime) as funeralTimeString, + userFn_timeIntegerToPeriodString(o.funeralTime) as funeralTimePeriodString, + o.directionOfArrival, o.committalTypeId, c.committalType from Contracts o left join ContractTypes t on o.contractTypeId = t.contractTypeId diff --git a/database/getContracts.ts b/database/getContracts.ts index 29e3b41f..8464e048 100644 --- a/database/getContracts.ts +++ b/database/getContracts.ts @@ -2,6 +2,7 @@ import { type DateString, dateIntegerToString, dateStringToInteger, + timeIntegerToPeriodString, timeIntegerToString } from '@cityssm/utils-datetime' import sqlite from 'better-sqlite3' @@ -60,6 +61,8 @@ export default async function getContracts( database.function('userFn_dateIntegerToString', dateIntegerToString) database.function('userFn_timeIntegerToString', timeIntegerToString) + database.function( + 'userFn_timeIntegerToPeriodString', timeIntegerToPeriodString) const { sqlParameters, sqlWhereClause } = buildWhereClause(filters) @@ -101,7 +104,10 @@ export default async function getContracts( o.funeralHomeId, o.funeralDirectorName, f.funeralHomeName, o.funeralDate, userFn_dateIntegerToString(o.funeralDate) as funeralDateString, - o.funeralTime, userFn_timeIntegerToString(o.funeralTime) as funeralTimeString, + o.funeralTime, + userFn_timeIntegerToString(o.funeralTime) as funeralTimeString, + userFn_timeIntegerToPeriodString(o.funeralTime) as funeralTimePeriodString, + o.directionOfArrival, o.committalTypeId, c.committalType from Contracts o left join ContractTypes t on o.contractTypeId = t.contractTypeId diff --git a/views/workOrder-view.ejs b/views/workOrder-view.ejs index da4e92b0..755f7a0a 100644 --- a/views/workOrder-view.ejs +++ b/views/workOrder-view.ejs @@ -140,7 +140,7 @@
-

Related Burial Sites

+

Related Contracts

<% const tabToSelect = (workOrder.workOrderContracts.length > 0 || workOrder.workOrderBurialSites.length === 0 ? "contracts" : "burialSites"); @@ -312,76 +312,99 @@
<% } %>
- <% if (workOrder.workOrderMilestones.length > 0) { %> -
+ +
+ <% if (workOrder.workOrderContracts.length > 0) { %>
-
-
-
-
-

Milestones

-
+

Contract Milestones

+ <% let hasContractMilestones = false; %> + <% for (const contract of workOrder.workOrderContracts) { %> + <% if (contract.funeralDate !== null && contract.funeralDate >= workOrder.workOrderOpenDate && (workOrder.workOrderCloseDate === null || workOrderCloseDate >= contract.funeralDate)) { %> + <% hasContractMilestones = true; %> +
+ Funeral
+ <%= contract.funeralDateString %> + <% if (contract.funeralTime !== null && contract.funeralTime !== 0) { %> + <%= contract.funeralTimePeriodString %> + <% } %>
+ <%= contract.funeralHomeName %>
-
-
- <%- include('_footerA'); -%>