show funeral details on work order view

pull/11/head
Dan Gowans 2025-04-28 13:08:31 -04:00
parent 556a6a71b6
commit afa0286a2a
3 changed files with 96 additions and 63 deletions

View File

@ -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 sqlite from 'better-sqlite3';
import { getConfigProperty } from '../helpers/config.helpers.js'; import { getConfigProperty } from '../helpers/config.helpers.js';
import { sunriseDB } from '../helpers/database.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); const database = connectedDatabase ?? sqlite(sunriseDB);
database.function('userFn_dateIntegerToString', dateIntegerToString); database.function('userFn_dateIntegerToString', dateIntegerToString);
database.function('userFn_timeIntegerToString', timeIntegerToString); database.function('userFn_timeIntegerToString', timeIntegerToString);
database.function('userFn_timeIntegerToPeriodString', timeIntegerToPeriodString);
const { sqlParameters, sqlWhereClause } = buildWhereClause(filters); const { sqlParameters, sqlWhereClause } = buildWhereClause(filters);
let count = typeof options.limit === 'string' let count = typeof options.limit === 'string'
? Number.parseInt(options.limit, 10) ? Number.parseInt(options.limit, 10)
@ -40,7 +41,10 @@ export default async function getContracts(filters, options, connectedDatabase)
o.funeralHomeId, o.funeralDirectorName, f.funeralHomeName, o.funeralHomeId, o.funeralDirectorName, f.funeralHomeName,
o.funeralDate, userFn_dateIntegerToString(o.funeralDate) as funeralDateString, 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 o.committalTypeId, c.committalType
from Contracts o from Contracts o
left join ContractTypes t on o.contractTypeId = t.contractTypeId left join ContractTypes t on o.contractTypeId = t.contractTypeId

View File

@ -2,6 +2,7 @@ import {
type DateString, type DateString,
dateIntegerToString, dateIntegerToString,
dateStringToInteger, dateStringToInteger,
timeIntegerToPeriodString,
timeIntegerToString timeIntegerToString
} from '@cityssm/utils-datetime' } from '@cityssm/utils-datetime'
import sqlite from 'better-sqlite3' import sqlite from 'better-sqlite3'
@ -60,6 +61,8 @@ export default async function getContracts(
database.function('userFn_dateIntegerToString', dateIntegerToString) database.function('userFn_dateIntegerToString', dateIntegerToString)
database.function('userFn_timeIntegerToString', timeIntegerToString) database.function('userFn_timeIntegerToString', timeIntegerToString)
database.function(
'userFn_timeIntegerToPeriodString', timeIntegerToPeriodString)
const { sqlParameters, sqlWhereClause } = buildWhereClause(filters) const { sqlParameters, sqlWhereClause } = buildWhereClause(filters)
@ -101,7 +104,10 @@ export default async function getContracts(
o.funeralHomeId, o.funeralDirectorName, f.funeralHomeName, o.funeralHomeId, o.funeralDirectorName, f.funeralHomeName,
o.funeralDate, userFn_dateIntegerToString(o.funeralDate) as funeralDateString, 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 o.committalTypeId, c.committalType
from Contracts o from Contracts o
left join ContractTypes t on o.contractTypeId = t.contractTypeId left join ContractTypes t on o.contractTypeId = t.contractTypeId

View File

@ -140,7 +140,7 @@
</div> </div>
<div class="panel"> <div class="panel">
<h2 class="panel-heading">Related Burial Sites</h2> <h2 class="panel-heading">Related Contracts</h2>
<div class="panel-block is-block"> <div class="panel-block is-block">
<% <%
const tabToSelect = (workOrder.workOrderContracts.length > 0 || workOrder.workOrderBurialSites.length === 0 ? "contracts" : "burialSites"); const tabToSelect = (workOrder.workOrderContracts.length > 0 || workOrder.workOrderBurialSites.length === 0 ? "contracts" : "burialSites");
@ -312,8 +312,32 @@
</div> </div>
<% } %> <% } %>
</div> </div>
<% if (workOrder.workOrderMilestones.length > 0) { %>
<div class="column is-4-desktop"> <div class="column is-4-desktop">
<% if (workOrder.workOrderContracts.length > 0) { %>
<div class="panel">
<h2 class="panel-heading">Contract Milestones</h2>
<% 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; %>
<div class="panel-block is-block">
<strong>Funeral</strong><br />
<%= contract.funeralDateString %>
<% if (contract.funeralTime !== null && contract.funeralTime !== 0) { %>
<%= contract.funeralTimePeriodString %>
<% } %><br />
<%= contract.funeralHomeName %><br />
</div>
<% } %>
<% } %>
<% if (!hasContractMilestones) { %>
<div class="panel-block is-block">
<p class="has-text-grey">No relevant contract milestones available.</p>
</div>
<% } %>
</div>
<% } %>
<div class="panel"> <div class="panel">
<div class="panel-heading"> <div class="panel-heading">
<div class="level is-mobile"> <div class="level is-mobile">
@ -381,7 +405,6 @@
<% } %> <% } %>
</div> </div>
</div> </div>
<% } %>
</div> </div>
<%- include('_footerA'); -%> <%- include('_footerA'); -%>