ssm burial permit
parent
ff0dd39868
commit
6990fd0a10
|
|
@ -2,9 +2,11 @@ import path from "path";
|
||||||
import * as ejs from "ejs";
|
import * as ejs from "ejs";
|
||||||
import * as configFunctions from "../../helpers/functions.config.js";
|
import * as configFunctions from "../../helpers/functions.config.js";
|
||||||
import * as dateTimeFunctions from "@cityssm/expressjs-server-js/dateTimeFns.js";
|
import * as dateTimeFunctions from "@cityssm/expressjs-server-js/dateTimeFns.js";
|
||||||
|
import * as lotOccupancyFunctions from "../../helpers/functions.lotOccupancy.js";
|
||||||
import { getReportData, getPdfPrintConfig } from "../../helpers/functions.print.js";
|
import { getReportData, getPdfPrintConfig } from "../../helpers/functions.print.js";
|
||||||
import { convertHTMLToPDF } from "@cityssm/pdf-puppeteer";
|
import { convertHTMLToPDF } from "@cityssm/pdf-puppeteer";
|
||||||
import camelcase from "camelcase";
|
import camelcase from "camelcase";
|
||||||
|
const attachmentOrInline = "attachment";
|
||||||
export const handler = async (request, response, next) => {
|
export const handler = async (request, response, next) => {
|
||||||
const printName = request.params.printName;
|
const printName = request.params.printName;
|
||||||
const printConfig = getPdfPrintConfig(printName);
|
const printConfig = getPdfPrintConfig(printName);
|
||||||
|
|
@ -15,7 +17,7 @@ export const handler = async (request, response, next) => {
|
||||||
const reportData = getReportData(printConfig, request.query);
|
const reportData = getReportData(printConfig, request.query);
|
||||||
const reportPath = path.join("views", "print", "pdf", printName + ".ejs");
|
const reportPath = path.join("views", "print", "pdf", printName + ".ejs");
|
||||||
const pdfCallbackFunction = (pdf) => {
|
const pdfCallbackFunction = (pdf) => {
|
||||||
response.setHeader("Content-Disposition", "attachment;" + " filename=" + camelcase(printConfig.title) + ".pdf");
|
response.setHeader("Content-Disposition", attachmentOrInline + ";" + " filename=" + camelcase(printConfig.title) + ".pdf");
|
||||||
response.setHeader("Content-Type", "application/pdf");
|
response.setHeader("Content-Type", "application/pdf");
|
||||||
response.send(pdf);
|
response.send(pdf);
|
||||||
};
|
};
|
||||||
|
|
@ -35,6 +37,7 @@ export const handler = async (request, response, next) => {
|
||||||
};
|
};
|
||||||
reportData.configFunctions = configFunctions;
|
reportData.configFunctions = configFunctions;
|
||||||
reportData.dateTimeFunctions = dateTimeFunctions;
|
reportData.dateTimeFunctions = dateTimeFunctions;
|
||||||
|
reportData.lotOccupancyFunctions = lotOccupancyFunctions;
|
||||||
await ejs.renderFile(reportPath, reportData, {}, ejsCallbackFunction);
|
await ejs.renderFile(reportPath, reportData, {}, ejsCallbackFunction);
|
||||||
};
|
};
|
||||||
export default handler;
|
export default handler;
|
||||||
|
|
|
||||||
|
|
@ -5,12 +5,15 @@ import * as ejs from "ejs";
|
||||||
|
|
||||||
import * as configFunctions from "../../helpers/functions.config.js";
|
import * as configFunctions from "../../helpers/functions.config.js";
|
||||||
import * as dateTimeFunctions from "@cityssm/expressjs-server-js/dateTimeFns.js";
|
import * as dateTimeFunctions from "@cityssm/expressjs-server-js/dateTimeFns.js";
|
||||||
|
import * as lotOccupancyFunctions from "../../helpers/functions.lotOccupancy.js";
|
||||||
|
|
||||||
import { getReportData, getPdfPrintConfig } from "../../helpers/functions.print.js";
|
import { getReportData, getPdfPrintConfig } from "../../helpers/functions.print.js";
|
||||||
|
|
||||||
import { convertHTMLToPDF } from "@cityssm/pdf-puppeteer";
|
import { convertHTMLToPDF } from "@cityssm/pdf-puppeteer";
|
||||||
import camelcase from "camelcase";
|
import camelcase from "camelcase";
|
||||||
|
|
||||||
|
const attachmentOrInline: "attachment" | "inline" = "attachment";
|
||||||
|
|
||||||
export const handler: RequestHandler = async (request, response, next) => {
|
export const handler: RequestHandler = async (request, response, next) => {
|
||||||
const printName = request.params.printName;
|
const printName = request.params.printName;
|
||||||
|
|
||||||
|
|
@ -30,7 +33,7 @@ export const handler: RequestHandler = async (request, response, next) => {
|
||||||
const pdfCallbackFunction = (pdf: Buffer) => {
|
const pdfCallbackFunction = (pdf: Buffer) => {
|
||||||
response.setHeader(
|
response.setHeader(
|
||||||
"Content-Disposition",
|
"Content-Disposition",
|
||||||
"attachment;" + " filename=" + camelcase(printConfig.title) + ".pdf"
|
attachmentOrInline + ";" + " filename=" + camelcase(printConfig.title) + ".pdf"
|
||||||
);
|
);
|
||||||
|
|
||||||
response.setHeader("Content-Type", "application/pdf");
|
response.setHeader("Content-Type", "application/pdf");
|
||||||
|
|
@ -63,6 +66,7 @@ export const handler: RequestHandler = async (request, response, next) => {
|
||||||
|
|
||||||
reportData.configFunctions = configFunctions;
|
reportData.configFunctions = configFunctions;
|
||||||
reportData.dateTimeFunctions = dateTimeFunctions;
|
reportData.dateTimeFunctions = dateTimeFunctions;
|
||||||
|
reportData.lotOccupancyFunctions = lotOccupancyFunctions;
|
||||||
|
|
||||||
await ejs.renderFile(reportPath, reportData, {}, ejsCallbackFunction);
|
await ejs.renderFile(reportPath, reportData, {}, ejsCallbackFunction);
|
||||||
};
|
};
|
||||||
|
|
|
||||||
|
|
@ -0,0 +1,3 @@
|
||||||
|
import type * as recordTypes from "../types/recordTypes";
|
||||||
|
export declare const filterOccupantsByLotOccupantType: (lotOccupancy: recordTypes.LotOccupancy, lotOccupantType: string) => recordTypes.LotOccupancyOccupant[];
|
||||||
|
export declare const getFieldValueByOccupancyTypeField: (lotOccupancy: recordTypes.LotOccupancy, occupancyTypeField: string) => string;
|
||||||
|
|
@ -0,0 +1,17 @@
|
||||||
|
export const filterOccupantsByLotOccupantType = (lotOccupancy, lotOccupantType) => {
|
||||||
|
const lotOccupantTypeLowerCase = lotOccupantType.toLowerCase();
|
||||||
|
const occupants = lotOccupancy.lotOccupancyOccupants.filter((possibleOccupant) => {
|
||||||
|
return possibleOccupant.lotOccupantType.toLowerCase() === lotOccupantTypeLowerCase;
|
||||||
|
});
|
||||||
|
return occupants;
|
||||||
|
};
|
||||||
|
export const getFieldValueByOccupancyTypeField = (lotOccupancy, occupancyTypeField) => {
|
||||||
|
const occupancyTypeFieldLowerCase = occupancyTypeField.toLowerCase();
|
||||||
|
const field = lotOccupancy.lotOccupancyFields.find((possibleField) => {
|
||||||
|
return possibleField.occupancyTypeField.toLowerCase() === occupancyTypeFieldLowerCase;
|
||||||
|
});
|
||||||
|
if (field) {
|
||||||
|
return field.lotOccupancyFieldValue;
|
||||||
|
}
|
||||||
|
return undefined;
|
||||||
|
};
|
||||||
|
|
@ -0,0 +1,31 @@
|
||||||
|
import type * as recordTypes from "../types/recordTypes";
|
||||||
|
|
||||||
|
export const filterOccupantsByLotOccupantType = (
|
||||||
|
lotOccupancy: recordTypes.LotOccupancy,
|
||||||
|
lotOccupantType: string
|
||||||
|
): recordTypes.LotOccupancyOccupant[] => {
|
||||||
|
const lotOccupantTypeLowerCase = lotOccupantType.toLowerCase();
|
||||||
|
|
||||||
|
const occupants = lotOccupancy.lotOccupancyOccupants.filter((possibleOccupant) => {
|
||||||
|
return possibleOccupant.lotOccupantType.toLowerCase() === lotOccupantTypeLowerCase;
|
||||||
|
});
|
||||||
|
|
||||||
|
return occupants;
|
||||||
|
};
|
||||||
|
|
||||||
|
export const getFieldValueByOccupancyTypeField = (
|
||||||
|
lotOccupancy: recordTypes.LotOccupancy,
|
||||||
|
occupancyTypeField: string
|
||||||
|
): string => {
|
||||||
|
const occupancyTypeFieldLowerCase = occupancyTypeField.toLowerCase();
|
||||||
|
|
||||||
|
const field = lotOccupancy.lotOccupancyFields.find((possibleField) => {
|
||||||
|
return possibleField.occupancyTypeField.toLowerCase() === occupancyTypeFieldLowerCase;
|
||||||
|
});
|
||||||
|
|
||||||
|
if (field) {
|
||||||
|
return field.lotOccupancyFieldValue;
|
||||||
|
}
|
||||||
|
|
||||||
|
return undefined;
|
||||||
|
};
|
||||||
|
|
@ -68,13 +68,17 @@ const initializeCemeteryDatabase = () => {
|
||||||
orderNumber: 1
|
orderNumber: 1
|
||||||
}, session);
|
}, session);
|
||||||
addLotOccupantType({
|
addLotOccupantType({
|
||||||
lotOccupantType: "Preneed Owner",
|
lotOccupantType: "Funeral Director",
|
||||||
orderNumber: 2
|
orderNumber: 2
|
||||||
}, session);
|
}, session);
|
||||||
addLotOccupantType({
|
addLotOccupantType({
|
||||||
lotOccupantType: "Purchaser",
|
lotOccupantType: "Preneed Owner",
|
||||||
orderNumber: 3
|
orderNumber: 3
|
||||||
}, session);
|
}, session);
|
||||||
|
addLotOccupantType({
|
||||||
|
lotOccupantType: "Purchaser",
|
||||||
|
orderNumber: 4
|
||||||
|
}, session);
|
||||||
addOccupancyType({
|
addOccupancyType({
|
||||||
occupancyType: "Preneed",
|
occupancyType: "Preneed",
|
||||||
orderNumber: 1
|
orderNumber: 1
|
||||||
|
|
|
||||||
|
|
@ -143,7 +143,7 @@ const initializeCemeteryDatabase = () => {
|
||||||
|
|
||||||
addLotOccupantType(
|
addLotOccupantType(
|
||||||
{
|
{
|
||||||
lotOccupantType: "Preneed Owner",
|
lotOccupantType: "Funeral Director",
|
||||||
orderNumber: 2
|
orderNumber: 2
|
||||||
},
|
},
|
||||||
session
|
session
|
||||||
|
|
@ -151,12 +151,20 @@ const initializeCemeteryDatabase = () => {
|
||||||
|
|
||||||
addLotOccupantType(
|
addLotOccupantType(
|
||||||
{
|
{
|
||||||
lotOccupantType: "Purchaser",
|
lotOccupantType: "Preneed Owner",
|
||||||
orderNumber: 3
|
orderNumber: 3
|
||||||
},
|
},
|
||||||
session
|
session
|
||||||
);
|
);
|
||||||
|
|
||||||
|
addLotOccupantType(
|
||||||
|
{
|
||||||
|
lotOccupantType: "Purchaser",
|
||||||
|
orderNumber: 4
|
||||||
|
},
|
||||||
|
session
|
||||||
|
);
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* Occupancy Types
|
* Occupancy Types
|
||||||
*/
|
*/
|
||||||
|
|
|
||||||
|
|
@ -17,7 +17,8 @@ export const getLotOccupancy = (lotOccupancyId) => {
|
||||||
" o.lotId, l.lotName, l.lotTypeId," +
|
" o.lotId, l.lotName, l.lotTypeId," +
|
||||||
" l.mapId, m.mapName," +
|
" l.mapId, m.mapName," +
|
||||||
" o.occupancyStartDate, userFn_dateIntegerToString(o.occupancyStartDate) as occupancyStartDateString," +
|
" o.occupancyStartDate, userFn_dateIntegerToString(o.occupancyStartDate) as occupancyStartDateString," +
|
||||||
" o.occupancyEndDate, userFn_dateIntegerToString(o.occupancyEndDate) as occupancyEndDateString" +
|
" o.occupancyEndDate, userFn_dateIntegerToString(o.occupancyEndDate) as occupancyEndDateString," +
|
||||||
|
" o.recordUpdate_timeMillis" +
|
||||||
" from LotOccupancies o" +
|
" from LotOccupancies o" +
|
||||||
" left join OccupancyTypes t on o.occupancyTypeId = t.occupancyTypeId" +
|
" left join OccupancyTypes t on o.occupancyTypeId = t.occupancyTypeId" +
|
||||||
" left join Lots l on o.lotId = l.lotId" +
|
" left join Lots l on o.lotId = l.lotId" +
|
||||||
|
|
|
||||||
|
|
@ -32,7 +32,8 @@ export const getLotOccupancy = (
|
||||||
" o.lotId, l.lotName, l.lotTypeId," +
|
" o.lotId, l.lotName, l.lotTypeId," +
|
||||||
" l.mapId, m.mapName," +
|
" l.mapId, m.mapName," +
|
||||||
" o.occupancyStartDate, userFn_dateIntegerToString(o.occupancyStartDate) as occupancyStartDateString," +
|
" o.occupancyStartDate, userFn_dateIntegerToString(o.occupancyStartDate) as occupancyStartDateString," +
|
||||||
" o.occupancyEndDate, userFn_dateIntegerToString(o.occupancyEndDate) as occupancyEndDateString" +
|
" o.occupancyEndDate, userFn_dateIntegerToString(o.occupancyEndDate) as occupancyEndDateString," +
|
||||||
|
" o.recordUpdate_timeMillis" +
|
||||||
" from LotOccupancies o" +
|
" from LotOccupancies o" +
|
||||||
" left join OccupancyTypes t on o.occupancyTypeId = t.occupancyTypeId" +
|
" left join OccupancyTypes t on o.occupancyTypeId = t.occupancyTypeId" +
|
||||||
" left join Lots l on o.lotId = l.lotId" +
|
" left join Lots l on o.lotId = l.lotId" +
|
||||||
|
|
|
||||||
|
|
@ -1,10 +1,79 @@
|
||||||
|
<%
|
||||||
|
const funeralDirectorLotOccupantType = "Funeral Director";
|
||||||
|
const funeralDirectorOccupants = lotOccupancyFunctions.filterOccupantsByLotOccupantType(lotOccupancy, funeralDirectorLotOccupantType);
|
||||||
|
|
||||||
|
const deceasedLotOccupantType = "Deceased";
|
||||||
|
const deceasedOccupants = lotOccupancyFunctions.filterOccupantsByLotOccupantType(lotOccupancy, deceasedLotOccupantType);
|
||||||
|
|
||||||
|
const deathDateOccupantTypeField = "Death Date";
|
||||||
|
%>
|
||||||
<html>
|
<html>
|
||||||
<head>
|
<head>
|
||||||
<style>
|
<style>
|
||||||
<%- include('style.css'); %>
|
<%- include('style.css'); %>
|
||||||
</style>
|
</style>
|
||||||
</head>
|
</head>
|
||||||
<body>
|
<body style="margin:100px 80px">
|
||||||
<h1>Burial Permit</h1>
|
<p class="mb-2 has-text-centered is-capitalized">Province of Ontario</p>
|
||||||
|
<p class="has-text-centered is-italic">Vital Statistics Act</p>
|
||||||
|
<h1 class="has-text-centered is-capitalized mt-4 mb-4">Burial Permit</h1>
|
||||||
|
|
||||||
|
<p>
|
||||||
|
Under the <span class="is-italic">Vital Statistics Act</span>
|
||||||
|
and the regulations,
|
||||||
|
subject to the limitations thereof,
|
||||||
|
this permit is granted to:<br />
|
||||||
|
</p>
|
||||||
|
|
||||||
|
<p class="has-text-centered">
|
||||||
|
<% if (funeralDirectorOccupants.length > 0) { %>
|
||||||
|
<% const funeralDirector = funeralDirectorOccupants[0]; %>
|
||||||
|
<strong><%= funeralDirector.occupantName %></strong><br />
|
||||||
|
<%= funeralDirector.occupantAddress1 %><br />
|
||||||
|
<% if (funeralDirector.occupantAddress2) { %><%= funeralDirector.occupantAddress2 %><br /><% } %>
|
||||||
|
<%= funeralDirector.occupantCity %>, <%= funeralDirector.occupantProvince %><br />
|
||||||
|
<%= funeralDirector.occupantPostalCode %>
|
||||||
|
<% } %>
|
||||||
|
</p>
|
||||||
|
|
||||||
|
<p class="mt-4">
|
||||||
|
for the purpose of the burial or other disposition of the body of:
|
||||||
|
</p>
|
||||||
|
|
||||||
|
<p class="has-text-centered">
|
||||||
|
<% if (deceasedOccupants.length > 0) { %>
|
||||||
|
<% const deceased = deceasedOccupants[0]; %>
|
||||||
|
<strong><%= deceased.occupantName %></strong>
|
||||||
|
<% } %>
|
||||||
|
</p>
|
||||||
|
|
||||||
|
<p>
|
||||||
|
who died at
|
||||||
|
<span class="field has-text-centered" style="width:300px"> </span>
|
||||||
|
in Ontario on
|
||||||
|
<span class="field has-text-centered" style="width:150px">
|
||||||
|
<%= lotOccupancyFunctions.getFieldValueByOccupancyTypeField(lotOccupancy, deathDateOccupantTypeField); %>
|
||||||
|
</span>
|
||||||
|
.
|
||||||
|
</p>
|
||||||
|
|
||||||
|
<p class="has-text-right mt-6">
|
||||||
|
<span class="field mb-1" style="width:300px"> </span><br />
|
||||||
|
<span class="is-8pt">(Signature of Division Registrar)</span>
|
||||||
|
</p>
|
||||||
|
|
||||||
|
<p class="has-text-right">
|
||||||
|
Sault Ste. Marie
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
5724
|
||||||
|
</p>
|
||||||
|
|
||||||
|
<p class="has-text-right">
|
||||||
|
<span class="field" style="width:150px">
|
||||||
|
<%= dateTimeFunctions.dateToString(new Date(lotOccupancy.recordUpdate_timeMillis)) %>
|
||||||
|
</span>
|
||||||
|
</p>
|
||||||
</body>
|
</body>
|
||||||
</html>
|
</html>
|
||||||
|
|
@ -29,6 +29,13 @@ body {
|
||||||
content: '\2714';
|
content: '\2714';
|
||||||
}
|
}
|
||||||
|
|
||||||
|
.field {
|
||||||
|
border-bottom: 1px solid black;
|
||||||
|
display: inline-block;
|
||||||
|
width: 100%;
|
||||||
|
padding: 10px 0;
|
||||||
|
}
|
||||||
|
|
||||||
/* Data Table */
|
/* Data Table */
|
||||||
|
|
||||||
.data-table {
|
.data-table {
|
||||||
|
|
@ -78,10 +85,30 @@ td.is-width-1 {
|
||||||
margin-top: 10px;
|
margin-top: 10px;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
.mt-4 {
|
||||||
|
margin-top: 40px;
|
||||||
|
}
|
||||||
|
|
||||||
|
.mt-6 {
|
||||||
|
margin-top: 60px;
|
||||||
|
}
|
||||||
|
|
||||||
.mb-0 {
|
.mb-0 {
|
||||||
margin-bottom: 0;
|
margin-bottom: 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
.mb-1 {
|
||||||
|
margin-bottom: 10px;
|
||||||
|
}
|
||||||
|
|
||||||
|
.mb-2 {
|
||||||
|
margin-bottom: 20px;
|
||||||
|
}
|
||||||
|
|
||||||
|
.mb-4 {
|
||||||
|
margin-bottom: 40px;
|
||||||
|
}
|
||||||
|
|
||||||
.pl-1 {
|
.pl-1 {
|
||||||
padding-left: 10px;
|
padding-left: 10px;
|
||||||
}
|
}
|
||||||
|
|
@ -96,7 +123,15 @@ td.is-width-1 {
|
||||||
text-align: right;
|
text-align: right;
|
||||||
}
|
}
|
||||||
|
|
||||||
.has-text-italicized {
|
.has-text-centered {
|
||||||
|
text-align: center;
|
||||||
|
}
|
||||||
|
|
||||||
|
.is-capitalized {
|
||||||
|
text-transform: uppercase;
|
||||||
|
}
|
||||||
|
|
||||||
|
.is-italic {
|
||||||
font-style: italic;
|
font-style: italic;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -72,7 +72,7 @@
|
||||||
<% } %>
|
<% } %>
|
||||||
|
|
||||||
|
|
||||||
<p class="has-text-right has-text-italicized is-8pt" style="position:absolute;bottom:10px;right:10px">
|
<p class="has-text-right is-italic is-8pt" style="position:absolute;bottom:10px;right:10px">
|
||||||
<%
|
<%
|
||||||
const recordCreateDate = new Date(workOrder.recordCreate_timeMillis);
|
const recordCreateDate = new Date(workOrder.recordCreate_timeMillis);
|
||||||
const currentDate = new Date();
|
const currentDate = new Date();
|
||||||
|
|
|
||||||
|
|
@ -143,7 +143,7 @@
|
||||||
|
|
||||||
<h2 class="mb-0">Notes</h2>
|
<h2 class="mb-0">Notes</h2>
|
||||||
|
|
||||||
<p class="has-text-right has-text-italicized is-8pt" style="position:absolute;bottom:10px;right:10px">
|
<p class="has-text-right is-italic is-8pt" style="position:absolute;bottom:10px;right:10px">
|
||||||
<%
|
<%
|
||||||
const recordCreateDate = new Date(workOrder.recordCreate_timeMillis);
|
const recordCreateDate = new Date(workOrder.recordCreate_timeMillis);
|
||||||
const currentDate = new Date();
|
const currentDate = new Date();
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue