add "direction of arrival"
database update: create table if not exists CemeteryDirectionsOfArrival ( cemeteryId integer not null, directionOfArrival varchar(2) not null, directionOfArrivalDescription varchar(100) not null, primary key (cemeteryId, directionOfArrival), foreign key (cemeteryId) references Cemeteries (cemeteryId)) without rowid alter table Contracts add directionOfArrival varchar(2)pull/11/head
parent
96a41862bf
commit
556a6a71b6
|
|
@ -1,7 +1,9 @@
|
||||||
export declare const deathAgePeriods: readonly ["Years", "Months", "Days", "Stillborn"];
|
export declare const deathAgePeriods: readonly ["Years", "Months", "Days", "Stillborn"];
|
||||||
export declare const purchaserRelationships: readonly ["Spouse", "Husband", "Wife", "Child", "Parent", "Sibling", "Friend", "Self"];
|
export declare const purchaserRelationships: readonly ["Spouse", "Husband", "Wife", "Child", "Parent", "Sibling", "Friend", "Self"];
|
||||||
|
export declare const directionsOfArrival: readonly ["N", "NE", "E", "SE", "S", "SW", "W", "NW"];
|
||||||
declare const _default: {
|
declare const _default: {
|
||||||
deathAgePeriods: readonly ["Years", "Months", "Days", "Stillborn"];
|
deathAgePeriods: readonly ["Years", "Months", "Days", "Stillborn"];
|
||||||
|
directionsOfArrival: readonly ["N", "NE", "E", "SE", "S", "SW", "W", "NW"];
|
||||||
purchaserRelationships: readonly ["Spouse", "Husband", "Wife", "Child", "Parent", "Sibling", "Friend", "Self"];
|
purchaserRelationships: readonly ["Spouse", "Husband", "Wife", "Child", "Parent", "Sibling", "Friend", "Self"];
|
||||||
};
|
};
|
||||||
export default _default;
|
export default _default;
|
||||||
|
|
|
||||||
|
|
@ -1,9 +1,4 @@
|
||||||
export const deathAgePeriods = [
|
export const deathAgePeriods = ['Years', 'Months', 'Days', 'Stillborn'];
|
||||||
'Years',
|
|
||||||
'Months',
|
|
||||||
'Days',
|
|
||||||
'Stillborn'
|
|
||||||
];
|
|
||||||
export const purchaserRelationships = [
|
export const purchaserRelationships = [
|
||||||
'Spouse',
|
'Spouse',
|
||||||
'Husband',
|
'Husband',
|
||||||
|
|
@ -14,7 +9,18 @@ export const purchaserRelationships = [
|
||||||
'Friend',
|
'Friend',
|
||||||
'Self'
|
'Self'
|
||||||
];
|
];
|
||||||
|
export const directionsOfArrival = [
|
||||||
|
'N',
|
||||||
|
'NE',
|
||||||
|
'E',
|
||||||
|
'SE',
|
||||||
|
'S',
|
||||||
|
'SW',
|
||||||
|
'W',
|
||||||
|
'NW'
|
||||||
|
];
|
||||||
export default {
|
export default {
|
||||||
deathAgePeriods,
|
deathAgePeriods,
|
||||||
|
directionsOfArrival,
|
||||||
purchaserRelationships
|
purchaserRelationships
|
||||||
};
|
};
|
||||||
|
|
|
||||||
|
|
@ -1,9 +1,4 @@
|
||||||
export const deathAgePeriods = [
|
export const deathAgePeriods = ['Years', 'Months', 'Days', 'Stillborn'] as const
|
||||||
'Years',
|
|
||||||
'Months',
|
|
||||||
'Days',
|
|
||||||
'Stillborn'
|
|
||||||
] as const
|
|
||||||
|
|
||||||
export const purchaserRelationships = [
|
export const purchaserRelationships = [
|
||||||
'Spouse',
|
'Spouse',
|
||||||
|
|
@ -16,7 +11,19 @@ export const purchaserRelationships = [
|
||||||
'Self'
|
'Self'
|
||||||
] as const
|
] as const
|
||||||
|
|
||||||
|
export const directionsOfArrival = [
|
||||||
|
'N',
|
||||||
|
'NE',
|
||||||
|
'E',
|
||||||
|
'SE',
|
||||||
|
'S',
|
||||||
|
'SW',
|
||||||
|
'W',
|
||||||
|
'NW'
|
||||||
|
] as const
|
||||||
|
|
||||||
export default {
|
export default {
|
||||||
deathAgePeriods,
|
deathAgePeriods,
|
||||||
|
directionsOfArrival,
|
||||||
purchaserRelationships
|
purchaserRelationships
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -8,6 +8,7 @@ export interface AddContractForm {
|
||||||
[fieldValue_contractTypeFieldId: `fieldValue_${string}`]: unknown;
|
[fieldValue_contractTypeFieldId: `fieldValue_${string}`]: unknown;
|
||||||
contractTypeFieldIds?: string;
|
contractTypeFieldIds?: string;
|
||||||
committalTypeId?: number | string;
|
committalTypeId?: number | string;
|
||||||
|
directionOfArrival?: string;
|
||||||
funeralDateString?: '' | DateString;
|
funeralDateString?: '' | DateString;
|
||||||
funeralDirectorName?: string;
|
funeralDirectorName?: string;
|
||||||
funeralHomeId?: number | string;
|
funeralHomeId?: number | string;
|
||||||
|
|
|
||||||
|
|
@ -16,17 +16,17 @@ export default function addContract(addForm, user, connectedDatabase) {
|
||||||
purchaserPhoneNumber, purchaserEmail, purchaserRelationship,
|
purchaserPhoneNumber, purchaserEmail, purchaserRelationship,
|
||||||
funeralHomeId, funeralDirectorName,
|
funeralHomeId, funeralDirectorName,
|
||||||
funeralDate, funeralTime,
|
funeralDate, funeralTime,
|
||||||
committalTypeId,
|
directionOfArrival, committalTypeId,
|
||||||
recordCreate_userName, recordCreate_timeMillis,
|
recordCreate_userName, recordCreate_timeMillis,
|
||||||
recordUpdate_userName, recordUpdate_timeMillis)
|
recordUpdate_userName, recordUpdate_timeMillis)
|
||||||
values (?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?)`)
|
values (?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?)`)
|
||||||
.run(addForm.contractTypeId, addForm.burialSiteId === '' ? undefined : addForm.burialSiteId, contractStartDate, addForm.contractEndDateString === ''
|
.run(addForm.contractTypeId, addForm.burialSiteId === '' ? undefined : addForm.burialSiteId, contractStartDate, addForm.contractEndDateString === ''
|
||||||
? undefined
|
? undefined
|
||||||
: dateStringToInteger(addForm.contractEndDateString), addForm.purchaserName ?? '', addForm.purchaserAddress1 ?? '', addForm.purchaserAddress2 ?? '', addForm.purchaserCity ?? '', addForm.purchaserProvince ?? '', addForm.purchaserPostalCode ?? '', addForm.purchaserPhoneNumber ?? '', addForm.purchaserEmail ?? '', addForm.purchaserRelationship ?? '', addForm.funeralHomeId === '' ? undefined : addForm.funeralHomeId, addForm.funeralDirectorName ?? '', addForm.funeralDateString === ''
|
: dateStringToInteger(addForm.contractEndDateString), addForm.purchaserName ?? '', addForm.purchaserAddress1 ?? '', addForm.purchaserAddress2 ?? '', addForm.purchaserCity ?? '', addForm.purchaserProvince ?? '', addForm.purchaserPostalCode ?? '', addForm.purchaserPhoneNumber ?? '', addForm.purchaserEmail ?? '', addForm.purchaserRelationship ?? '', addForm.funeralHomeId === '' ? undefined : addForm.funeralHomeId, addForm.funeralDirectorName ?? '', addForm.funeralDateString === ''
|
||||||
? undefined
|
? undefined
|
||||||
: dateStringToInteger(addForm.funeralDateString), addForm.funeralTimeString === ''
|
: dateStringToInteger(addForm.funeralDateString), addForm.funeralTimeString === ''
|
||||||
? undefined
|
? undefined
|
||||||
: timeStringToInteger(addForm.funeralTimeString), addForm.committalTypeId === '' ? undefined : addForm.committalTypeId, user.userName, rightNowMillis, user.userName, rightNowMillis);
|
: timeStringToInteger(addForm.funeralTimeString), addForm.directionOfArrival ?? '', addForm.committalTypeId === '' ? undefined : addForm.committalTypeId, user.userName, rightNowMillis, user.userName, rightNowMillis);
|
||||||
const contractId = result.lastInsertRowid;
|
const contractId = result.lastInsertRowid;
|
||||||
/*
|
/*
|
||||||
* Add contract fields
|
* Add contract fields
|
||||||
|
|
|
||||||
|
|
@ -20,6 +20,7 @@ export interface AddContractForm {
|
||||||
contractTypeFieldIds?: string
|
contractTypeFieldIds?: string
|
||||||
|
|
||||||
committalTypeId?: number | string
|
committalTypeId?: number | string
|
||||||
|
directionOfArrival?: string
|
||||||
funeralDateString?: '' | DateString
|
funeralDateString?: '' | DateString
|
||||||
funeralDirectorName?: string
|
funeralDirectorName?: string
|
||||||
funeralHomeId?: number | string
|
funeralHomeId?: number | string
|
||||||
|
|
@ -74,10 +75,10 @@ export default function addContract(
|
||||||
purchaserPhoneNumber, purchaserEmail, purchaserRelationship,
|
purchaserPhoneNumber, purchaserEmail, purchaserRelationship,
|
||||||
funeralHomeId, funeralDirectorName,
|
funeralHomeId, funeralDirectorName,
|
||||||
funeralDate, funeralTime,
|
funeralDate, funeralTime,
|
||||||
committalTypeId,
|
directionOfArrival, committalTypeId,
|
||||||
recordCreate_userName, recordCreate_timeMillis,
|
recordCreate_userName, recordCreate_timeMillis,
|
||||||
recordUpdate_userName, recordUpdate_timeMillis)
|
recordUpdate_userName, recordUpdate_timeMillis)
|
||||||
values (?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?)`
|
values (?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?)`
|
||||||
)
|
)
|
||||||
.run(
|
.run(
|
||||||
addForm.contractTypeId,
|
addForm.contractTypeId,
|
||||||
|
|
@ -103,6 +104,7 @@ export default function addContract(
|
||||||
addForm.funeralTimeString === ''
|
addForm.funeralTimeString === ''
|
||||||
? undefined
|
? undefined
|
||||||
: timeStringToInteger(addForm.funeralTimeString as TimeString),
|
: timeStringToInteger(addForm.funeralTimeString as TimeString),
|
||||||
|
addForm.directionOfArrival ?? '',
|
||||||
addForm.committalTypeId === '' ? undefined : addForm.committalTypeId,
|
addForm.committalTypeId === '' ? undefined : addForm.committalTypeId,
|
||||||
user.userName,
|
user.userName,
|
||||||
rightNowMillis,
|
rightNowMillis,
|
||||||
|
|
|
||||||
|
|
@ -0,0 +1,9 @@
|
||||||
|
import sqlite from 'better-sqlite3';
|
||||||
|
import type { directionsOfArrival } from '../data/dataLists.js';
|
||||||
|
export declare const defaultDirectionsOfArrival: {
|
||||||
|
E: string;
|
||||||
|
N: string;
|
||||||
|
S: string;
|
||||||
|
W: string;
|
||||||
|
};
|
||||||
|
export default function getBurialSiteDirectionsOfArrival(burialSiteId: number | string, connectedDatabase?: sqlite.Database): Partial<Record<(typeof directionsOfArrival)[number], string>>;
|
||||||
|
|
@ -0,0 +1,39 @@
|
||||||
|
import sqlite from 'better-sqlite3';
|
||||||
|
import { sunriseDB } from '../helpers/database.helpers.js';
|
||||||
|
import getCemeteryDirectionsOfArrival from './getCemeteryDirectionsOfArrival.js';
|
||||||
|
export const defaultDirectionsOfArrival = {
|
||||||
|
E: 'East',
|
||||||
|
N: 'North',
|
||||||
|
S: 'South',
|
||||||
|
W: 'West'
|
||||||
|
};
|
||||||
|
export default function getBurialSiteDirectionsOfArrival(burialSiteId, connectedDatabase) {
|
||||||
|
const database = connectedDatabase ?? sqlite(sunriseDB, { readonly: true });
|
||||||
|
const directionsList = database
|
||||||
|
.prepare(`select c.parentCemeteryId,
|
||||||
|
d.directionOfArrival, d.directionOfArrivalDescription
|
||||||
|
from BurialSites b
|
||||||
|
left join Cemeteries c on b.cemeteryId = c.cemeteryId
|
||||||
|
left join CemeteryDirectionsOfArrival d on c.cemeteryId = d.cemeteryId
|
||||||
|
where b.burialSiteId = ?`)
|
||||||
|
.all(burialSiteId);
|
||||||
|
let directions = {};
|
||||||
|
if (directionsList.length === 1 &&
|
||||||
|
directionsList[0].directionOfArrival === null &&
|
||||||
|
directionsList[0].parentCemeteryId !== null) {
|
||||||
|
directions = getCemeteryDirectionsOfArrival(directionsList[0].parentCemeteryId, connectedDatabase);
|
||||||
|
}
|
||||||
|
else if (directionsList.length > 0 && directionsList[0].directionOfArrival !== null) {
|
||||||
|
for (const direction of directionsList) {
|
||||||
|
directions[direction.directionOfArrival] =
|
||||||
|
direction.directionOfArrivalDescription ?? '';
|
||||||
|
}
|
||||||
|
}
|
||||||
|
if (Object.keys(directions).length === 0) {
|
||||||
|
directions = defaultDirectionsOfArrival;
|
||||||
|
}
|
||||||
|
if (connectedDatabase === undefined) {
|
||||||
|
database.close();
|
||||||
|
}
|
||||||
|
return directions;
|
||||||
|
}
|
||||||
|
|
@ -0,0 +1,65 @@
|
||||||
|
import sqlite from 'better-sqlite3'
|
||||||
|
|
||||||
|
import type { directionsOfArrival } from '../data/dataLists.js'
|
||||||
|
import { sunriseDB } from '../helpers/database.helpers.js'
|
||||||
|
|
||||||
|
import getCemeteryDirectionsOfArrival from './getCemeteryDirectionsOfArrival.js'
|
||||||
|
|
||||||
|
export const defaultDirectionsOfArrival = {
|
||||||
|
E: 'East',
|
||||||
|
N: 'North',
|
||||||
|
S: 'South',
|
||||||
|
W: 'West'
|
||||||
|
}
|
||||||
|
|
||||||
|
export default function getBurialSiteDirectionsOfArrival(
|
||||||
|
burialSiteId: number | string,
|
||||||
|
connectedDatabase?: sqlite.Database
|
||||||
|
): Partial<Record<(typeof directionsOfArrival)[number], string>> {
|
||||||
|
const database = connectedDatabase ?? sqlite(sunriseDB, { readonly: true })
|
||||||
|
|
||||||
|
const directionsList = database
|
||||||
|
.prepare(
|
||||||
|
`select c.parentCemeteryId,
|
||||||
|
d.directionOfArrival, d.directionOfArrivalDescription
|
||||||
|
from BurialSites b
|
||||||
|
left join Cemeteries c on b.cemeteryId = c.cemeteryId
|
||||||
|
left join CemeteryDirectionsOfArrival d on c.cemeteryId = d.cemeteryId
|
||||||
|
where b.burialSiteId = ?`
|
||||||
|
)
|
||||||
|
.all(burialSiteId) as Array<{
|
||||||
|
directionOfArrival: (typeof directionsOfArrival)[number] | null
|
||||||
|
directionOfArrivalDescription: string | null
|
||||||
|
parentCemeteryId: number | null
|
||||||
|
}>
|
||||||
|
|
||||||
|
let directions: Partial<
|
||||||
|
Record<(typeof directionsOfArrival)[number], string>
|
||||||
|
> = {}
|
||||||
|
|
||||||
|
if (
|
||||||
|
directionsList.length === 1 &&
|
||||||
|
directionsList[0].directionOfArrival === null &&
|
||||||
|
directionsList[0].parentCemeteryId !== null
|
||||||
|
) {
|
||||||
|
directions = getCemeteryDirectionsOfArrival(
|
||||||
|
directionsList[0].parentCemeteryId,
|
||||||
|
connectedDatabase
|
||||||
|
)
|
||||||
|
} else if (directionsList.length > 0 && directionsList[0].directionOfArrival !== null) {
|
||||||
|
for (const direction of directionsList) {
|
||||||
|
directions[direction.directionOfArrival as string] =
|
||||||
|
direction.directionOfArrivalDescription ?? ''
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
if (Object.keys(directions).length === 0) {
|
||||||
|
directions = defaultDirectionsOfArrival
|
||||||
|
}
|
||||||
|
|
||||||
|
if (connectedDatabase === undefined) {
|
||||||
|
database.close()
|
||||||
|
}
|
||||||
|
|
||||||
|
return directions
|
||||||
|
}
|
||||||
|
|
@ -1,6 +1,7 @@
|
||||||
import sqlite from 'better-sqlite3';
|
import sqlite from 'better-sqlite3';
|
||||||
import { sunriseDB } from '../helpers/database.helpers.js';
|
import { sunriseDB } from '../helpers/database.helpers.js';
|
||||||
import getCemeteries from './getCemeteries.js';
|
import getCemeteries from './getCemeteries.js';
|
||||||
|
import getCemeteryDirectionsOfArrival from './getCemeteryDirectionsOfArrival.js';
|
||||||
export default function getCemetery(cemeteryId, connectedDatabase) {
|
export default function getCemetery(cemeteryId, connectedDatabase) {
|
||||||
return _getCemetery('cemeteryId', cemeteryId, connectedDatabase);
|
return _getCemetery('cemeteryId', cemeteryId, connectedDatabase);
|
||||||
}
|
}
|
||||||
|
|
@ -42,6 +43,7 @@ function _getCemetery(keyColumn, cemeteryIdOrKey, connectedDatabase) {
|
||||||
cemetery.parentCemeteryId === null
|
cemetery.parentCemeteryId === null
|
||||||
? getCemeteries({ parentCemeteryId: cemetery.cemeteryId }, connectedDatabase)
|
? getCemeteries({ parentCemeteryId: cemetery.cemeteryId }, connectedDatabase)
|
||||||
: [];
|
: [];
|
||||||
|
cemetery.directionsOfArrival = getCemeteryDirectionsOfArrival(cemetery.cemeteryId, connectedDatabase);
|
||||||
}
|
}
|
||||||
if (connectedDatabase === undefined) {
|
if (connectedDatabase === undefined) {
|
||||||
database.close();
|
database.close();
|
||||||
|
|
|
||||||
|
|
@ -4,6 +4,7 @@ import { sunriseDB } from '../helpers/database.helpers.js'
|
||||||
import type { Cemetery } from '../types/record.types.js'
|
import type { Cemetery } from '../types/record.types.js'
|
||||||
|
|
||||||
import getCemeteries from './getCemeteries.js'
|
import getCemeteries from './getCemeteries.js'
|
||||||
|
import getCemeteryDirectionsOfArrival from './getCemeteryDirectionsOfArrival.js'
|
||||||
|
|
||||||
export default function getCemetery(
|
export default function getCemetery(
|
||||||
cemeteryId: number | string,
|
cemeteryId: number | string,
|
||||||
|
|
@ -65,6 +66,11 @@ function _getCemetery(
|
||||||
connectedDatabase
|
connectedDatabase
|
||||||
)
|
)
|
||||||
: []
|
: []
|
||||||
|
|
||||||
|
cemetery.directionsOfArrival = getCemeteryDirectionsOfArrival(
|
||||||
|
cemetery.cemeteryId as number,
|
||||||
|
connectedDatabase
|
||||||
|
)
|
||||||
}
|
}
|
||||||
|
|
||||||
if (connectedDatabase === undefined) {
|
if (connectedDatabase === undefined) {
|
||||||
|
|
|
||||||
|
|
@ -0,0 +1,3 @@
|
||||||
|
import sqlite from 'better-sqlite3';
|
||||||
|
import type { directionsOfArrival } from '../data/dataLists.js';
|
||||||
|
export default function getCemeteryDirectionsOfArrival(cemeteryId: number | string, connectedDatabase?: sqlite.Database): Partial<Record<(typeof directionsOfArrival)[number], string>>;
|
||||||
|
|
@ -0,0 +1,19 @@
|
||||||
|
import sqlite from 'better-sqlite3';
|
||||||
|
import { sunriseDB } from '../helpers/database.helpers.js';
|
||||||
|
export default function getCemeteryDirectionsOfArrival(cemeteryId, connectedDatabase) {
|
||||||
|
const database = connectedDatabase ?? sqlite(sunriseDB, { readonly: true });
|
||||||
|
const directionsList = database
|
||||||
|
.prepare(`select directionOfArrival, directionOfArrivalDescription
|
||||||
|
from CemeteryDirectionsOfArrival
|
||||||
|
where cemeteryId = ?`)
|
||||||
|
.all(cemeteryId);
|
||||||
|
const directions = {};
|
||||||
|
for (const direction of directionsList) {
|
||||||
|
directions[direction.directionOfArrival] =
|
||||||
|
direction.directionOfArrivalDescription;
|
||||||
|
}
|
||||||
|
if (connectedDatabase === undefined) {
|
||||||
|
database.close();
|
||||||
|
}
|
||||||
|
return directions;
|
||||||
|
}
|
||||||
|
|
@ -0,0 +1,37 @@
|
||||||
|
import sqlite from 'better-sqlite3'
|
||||||
|
|
||||||
|
import type { directionsOfArrival } from '../data/dataLists.js'
|
||||||
|
import { sunriseDB } from '../helpers/database.helpers.js'
|
||||||
|
|
||||||
|
export default function getCemeteryDirectionsOfArrival(
|
||||||
|
cemeteryId: number | string,
|
||||||
|
connectedDatabase?: sqlite.Database
|
||||||
|
): Partial<Record<(typeof directionsOfArrival)[number], string>> {
|
||||||
|
const database = connectedDatabase ?? sqlite(sunriseDB, { readonly: true })
|
||||||
|
|
||||||
|
const directionsList = database
|
||||||
|
.prepare(
|
||||||
|
`select directionOfArrival, directionOfArrivalDescription
|
||||||
|
from CemeteryDirectionsOfArrival
|
||||||
|
where cemeteryId = ?`
|
||||||
|
)
|
||||||
|
.all(cemeteryId) as Array<{
|
||||||
|
directionOfArrival: (typeof directionsOfArrival)[number]
|
||||||
|
directionOfArrivalDescription: string
|
||||||
|
}>
|
||||||
|
|
||||||
|
const directions: Partial<
|
||||||
|
Record<(typeof directionsOfArrival)[number], string>
|
||||||
|
> = {}
|
||||||
|
|
||||||
|
for (const direction of directionsList) {
|
||||||
|
directions[direction.directionOfArrival] =
|
||||||
|
direction.directionOfArrivalDescription
|
||||||
|
}
|
||||||
|
|
||||||
|
if (connectedDatabase === undefined) {
|
||||||
|
database.close()
|
||||||
|
}
|
||||||
|
|
||||||
|
return directions
|
||||||
|
}
|
||||||
|
|
@ -14,23 +14,24 @@ export default async function getContract(contractId, connectedDatabase) {
|
||||||
database.function('userFn_timeIntegerToPeriodString', timeIntegerToPeriodString);
|
database.function('userFn_timeIntegerToPeriodString', timeIntegerToPeriodString);
|
||||||
const contract = database
|
const contract = database
|
||||||
.prepare(`select o.contractId,
|
.prepare(`select o.contractId,
|
||||||
o.contractTypeId, t.contractType, t.isPreneed,
|
o.contractTypeId, t.contractType, t.isPreneed,
|
||||||
o.burialSiteId, l.burialSiteName, l.burialSiteTypeId,
|
o.burialSiteId, l.burialSiteName, l.burialSiteTypeId,
|
||||||
l.cemeteryId, m.cemeteryName,
|
l.cemeteryId, m.cemeteryName,
|
||||||
o.contractStartDate, userFn_dateIntegerToString(o.contractStartDate) as contractStartDateString,
|
o.contractStartDate, userFn_dateIntegerToString(o.contractStartDate) as contractStartDateString,
|
||||||
o.contractEndDate, userFn_dateIntegerToString(o.contractEndDate) as contractEndDateString,
|
o.contractEndDate, userFn_dateIntegerToString(o.contractEndDate) as contractEndDateString,
|
||||||
o.purchaserName, o.purchaserAddress1, o.purchaserAddress2,
|
o.purchaserName, o.purchaserAddress1, o.purchaserAddress2,
|
||||||
o.purchaserCity, o.purchaserProvince, o.purchaserPostalCode,
|
o.purchaserCity, o.purchaserProvince, o.purchaserPostalCode,
|
||||||
o.purchaserPhoneNumber, o.purchaserEmail, o.purchaserRelationship,
|
o.purchaserPhoneNumber, o.purchaserEmail, o.purchaserRelationship,
|
||||||
o.funeralHomeId, o.funeralDirectorName, f.funeralHomeKey,
|
o.funeralHomeId, o.funeralDirectorName, f.funeralHomeKey,
|
||||||
f.funeralHomeName, f.funeralHomeAddress1, f.funeralHomeAddress2,
|
f.funeralHomeName, f.funeralHomeAddress1, f.funeralHomeAddress2,
|
||||||
f.funeralHomeCity, f.funeralHomeProvince, f.funeralHomePostalCode,
|
f.funeralHomeCity, f.funeralHomeProvince, f.funeralHomePostalCode,
|
||||||
o.funeralDate, userFn_dateIntegerToString(o.funeralDate) as funeralDateString,
|
o.funeralDate, userFn_dateIntegerToString(o.funeralDate) as funeralDateString,
|
||||||
o.funeralTime,
|
o.funeralTime,
|
||||||
userFn_timeIntegerToString(o.funeralTime) as funeralTimeString,
|
userFn_timeIntegerToString(o.funeralTime) as funeralTimeString,
|
||||||
userFn_timeIntegerToPeriodString(o.funeralTime) as funeralTimePeriodString,
|
userFn_timeIntegerToPeriodString(o.funeralTime) as funeralTimePeriodString,
|
||||||
o.committalTypeId, c.committalType,
|
o.directionOfArrival,
|
||||||
o.recordUpdate_timeMillis
|
o.committalTypeId, c.committalType,
|
||||||
|
o.recordUpdate_timeMillis
|
||||||
from Contracts o
|
from Contracts o
|
||||||
left join ContractTypes t on o.contractTypeId = t.contractTypeId
|
left join ContractTypes t on o.contractTypeId = t.contractTypeId
|
||||||
left join FuneralHomes f on o.funeralHomeId = f.funeralHomeId
|
left join FuneralHomes f on o.funeralHomeId = f.funeralHomeId
|
||||||
|
|
@ -38,7 +39,7 @@ export default async function getContract(contractId, connectedDatabase) {
|
||||||
left join BurialSites l on o.burialSiteId = l.burialSiteId
|
left join BurialSites l on o.burialSiteId = l.burialSiteId
|
||||||
left join Cemeteries m on l.cemeteryId = m.cemeteryId
|
left join Cemeteries m on l.cemeteryId = m.cemeteryId
|
||||||
where o.recordDelete_timeMillis is null
|
where o.recordDelete_timeMillis is null
|
||||||
and o.contractId = ?`)
|
and o.contractId = ?`)
|
||||||
.get(contractId);
|
.get(contractId);
|
||||||
if (contract !== undefined) {
|
if (contract !== undefined) {
|
||||||
contract.contractFields = getContractFields(contractId, database);
|
contract.contractFields = getContractFields(contractId, database);
|
||||||
|
|
|
||||||
|
|
@ -31,23 +31,24 @@ export default async function getContract(
|
||||||
const contract = database
|
const contract = database
|
||||||
.prepare(
|
.prepare(
|
||||||
`select o.contractId,
|
`select o.contractId,
|
||||||
o.contractTypeId, t.contractType, t.isPreneed,
|
o.contractTypeId, t.contractType, t.isPreneed,
|
||||||
o.burialSiteId, l.burialSiteName, l.burialSiteTypeId,
|
o.burialSiteId, l.burialSiteName, l.burialSiteTypeId,
|
||||||
l.cemeteryId, m.cemeteryName,
|
l.cemeteryId, m.cemeteryName,
|
||||||
o.contractStartDate, userFn_dateIntegerToString(o.contractStartDate) as contractStartDateString,
|
o.contractStartDate, userFn_dateIntegerToString(o.contractStartDate) as contractStartDateString,
|
||||||
o.contractEndDate, userFn_dateIntegerToString(o.contractEndDate) as contractEndDateString,
|
o.contractEndDate, userFn_dateIntegerToString(o.contractEndDate) as contractEndDateString,
|
||||||
o.purchaserName, o.purchaserAddress1, o.purchaserAddress2,
|
o.purchaserName, o.purchaserAddress1, o.purchaserAddress2,
|
||||||
o.purchaserCity, o.purchaserProvince, o.purchaserPostalCode,
|
o.purchaserCity, o.purchaserProvince, o.purchaserPostalCode,
|
||||||
o.purchaserPhoneNumber, o.purchaserEmail, o.purchaserRelationship,
|
o.purchaserPhoneNumber, o.purchaserEmail, o.purchaserRelationship,
|
||||||
o.funeralHomeId, o.funeralDirectorName, f.funeralHomeKey,
|
o.funeralHomeId, o.funeralDirectorName, f.funeralHomeKey,
|
||||||
f.funeralHomeName, f.funeralHomeAddress1, f.funeralHomeAddress2,
|
f.funeralHomeName, f.funeralHomeAddress1, f.funeralHomeAddress2,
|
||||||
f.funeralHomeCity, f.funeralHomeProvince, f.funeralHomePostalCode,
|
f.funeralHomeCity, f.funeralHomeProvince, f.funeralHomePostalCode,
|
||||||
o.funeralDate, userFn_dateIntegerToString(o.funeralDate) as funeralDateString,
|
o.funeralDate, userFn_dateIntegerToString(o.funeralDate) as funeralDateString,
|
||||||
o.funeralTime,
|
o.funeralTime,
|
||||||
userFn_timeIntegerToString(o.funeralTime) as funeralTimeString,
|
userFn_timeIntegerToString(o.funeralTime) as funeralTimeString,
|
||||||
userFn_timeIntegerToPeriodString(o.funeralTime) as funeralTimePeriodString,
|
userFn_timeIntegerToPeriodString(o.funeralTime) as funeralTimePeriodString,
|
||||||
o.committalTypeId, c.committalType,
|
o.directionOfArrival,
|
||||||
o.recordUpdate_timeMillis
|
o.committalTypeId, c.committalType,
|
||||||
|
o.recordUpdate_timeMillis
|
||||||
from Contracts o
|
from Contracts o
|
||||||
left join ContractTypes t on o.contractTypeId = t.contractTypeId
|
left join ContractTypes t on o.contractTypeId = t.contractTypeId
|
||||||
left join FuneralHomes f on o.funeralHomeId = f.funeralHomeId
|
left join FuneralHomes f on o.funeralHomeId = f.funeralHomeId
|
||||||
|
|
@ -55,7 +56,7 @@ export default async function getContract(
|
||||||
left join BurialSites l on o.burialSiteId = l.burialSiteId
|
left join BurialSites l on o.burialSiteId = l.burialSiteId
|
||||||
left join Cemeteries m on l.cemeteryId = m.cemeteryId
|
left join Cemeteries m on l.cemeteryId = m.cemeteryId
|
||||||
where o.recordDelete_timeMillis is null
|
where o.recordDelete_timeMillis is null
|
||||||
and o.contractId = ?`
|
and o.contractId = ?`
|
||||||
)
|
)
|
||||||
.get(contractId) as Contract | undefined
|
.get(contractId) as Contract | undefined
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -74,6 +74,12 @@ const createStatements = [
|
||||||
parentCemeteryId integer,
|
parentCemeteryId integer,
|
||||||
${recordColumns},
|
${recordColumns},
|
||||||
foreign key (parentCemeteryId) references Cemeteries (cemeteryId))`,
|
foreign key (parentCemeteryId) references Cemeteries (cemeteryId))`,
|
||||||
|
`create table if not exists CemeteryDirectionsOfArrival (
|
||||||
|
cemeteryId integer not null,
|
||||||
|
directionOfArrival varchar(2) not null,
|
||||||
|
directionOfArrivalDescription varchar(100) not null,
|
||||||
|
primary key (cemeteryId, directionOfArrival),
|
||||||
|
foreign key (cemeteryId) references Cemeteries (cemeteryId)) without rowid`,
|
||||||
/*
|
/*
|
||||||
* Burial Sites
|
* Burial Sites
|
||||||
*/
|
*/
|
||||||
|
|
@ -199,6 +205,7 @@ const createStatements = [
|
||||||
funeralDate integer check (funeralDate > 0),
|
funeralDate integer check (funeralDate > 0),
|
||||||
funeralTime integer check (funeralTime >= 0),
|
funeralTime integer check (funeralTime >= 0),
|
||||||
committalTypeId integer,
|
committalTypeId integer,
|
||||||
|
directionOfArrival varchar(2),
|
||||||
|
|
||||||
${recordColumns},
|
${recordColumns},
|
||||||
foreign key (burialSiteId) references BurialSites (burialSiteId),
|
foreign key (burialSiteId) references BurialSites (burialSiteId),
|
||||||
|
|
|
||||||
|
|
@ -90,6 +90,13 @@ const createStatements = [
|
||||||
${recordColumns},
|
${recordColumns},
|
||||||
foreign key (parentCemeteryId) references Cemeteries (cemeteryId))`,
|
foreign key (parentCemeteryId) references Cemeteries (cemeteryId))`,
|
||||||
|
|
||||||
|
`create table if not exists CemeteryDirectionsOfArrival (
|
||||||
|
cemeteryId integer not null,
|
||||||
|
directionOfArrival varchar(2) not null,
|
||||||
|
directionOfArrivalDescription varchar(100) not null,
|
||||||
|
primary key (cemeteryId, directionOfArrival),
|
||||||
|
foreign key (cemeteryId) references Cemeteries (cemeteryId)) without rowid`,
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* Burial Sites
|
* Burial Sites
|
||||||
*/
|
*/
|
||||||
|
|
@ -231,6 +238,7 @@ const createStatements = [
|
||||||
funeralDate integer check (funeralDate > 0),
|
funeralDate integer check (funeralDate > 0),
|
||||||
funeralTime integer check (funeralTime >= 0),
|
funeralTime integer check (funeralTime >= 0),
|
||||||
committalTypeId integer,
|
committalTypeId integer,
|
||||||
|
directionOfArrival varchar(2),
|
||||||
|
|
||||||
${recordColumns},
|
${recordColumns},
|
||||||
foreign key (burialSiteId) references BurialSites (burialSiteId),
|
foreign key (burialSiteId) references BurialSites (burialSiteId),
|
||||||
|
|
|
||||||
|
|
@ -1,4 +1,5 @@
|
||||||
export interface UpdateCemeteryForm {
|
import { directionsOfArrival } from '../data/dataLists.js';
|
||||||
|
export type UpdateCemeteryForm = Partial<Record<`directionOfArrival_${(typeof directionsOfArrival)[number]}`, (typeof directionsOfArrival)[number]>> & Partial<Record<`directionOfArrivalDescription_${(typeof directionsOfArrival)[number]}`, string>> & {
|
||||||
cemeteryId: string;
|
cemeteryId: string;
|
||||||
cemeteryDescription: string;
|
cemeteryDescription: string;
|
||||||
cemeteryKey: string;
|
cemeteryKey: string;
|
||||||
|
|
@ -13,7 +14,7 @@ export interface UpdateCemeteryForm {
|
||||||
cemeteryLatitude: string;
|
cemeteryLatitude: string;
|
||||||
cemeteryLongitude: string;
|
cemeteryLongitude: string;
|
||||||
cemeterySvg: string;
|
cemeterySvg: string;
|
||||||
}
|
};
|
||||||
/**
|
/**
|
||||||
* Updates a cemetery in the database.
|
* Updates a cemetery in the database.
|
||||||
* Be sure to rebuild burial site names after updating a cemetery.
|
* Be sure to rebuild burial site names after updating a cemetery.
|
||||||
|
|
|
||||||
|
|
@ -1,4 +1,5 @@
|
||||||
import sqlite from 'better-sqlite3';
|
import sqlite from 'better-sqlite3';
|
||||||
|
import { directionsOfArrival } from '../data/dataLists.js';
|
||||||
import { sunriseDB } from '../helpers/database.helpers.js';
|
import { sunriseDB } from '../helpers/database.helpers.js';
|
||||||
/**
|
/**
|
||||||
* Updates a cemetery in the database.
|
* Updates a cemetery in the database.
|
||||||
|
|
@ -35,6 +36,20 @@ export default function updateCemetery(updateForm, user) {
|
||||||
: updateForm.cemeteryLongitude, updateForm.cemeteryAddress1, updateForm.cemeteryAddress2, updateForm.cemeteryCity, updateForm.cemeteryProvince, updateForm.cemeteryPostalCode, updateForm.cemeteryPhoneNumber, updateForm.parentCemeteryId === ''
|
: updateForm.cemeteryLongitude, updateForm.cemeteryAddress1, updateForm.cemeteryAddress2, updateForm.cemeteryCity, updateForm.cemeteryProvince, updateForm.cemeteryPostalCode, updateForm.cemeteryPhoneNumber, updateForm.parentCemeteryId === ''
|
||||||
? undefined
|
? undefined
|
||||||
: updateForm.parentCemeteryId, user.userName, Date.now(), updateForm.cemeteryId);
|
: updateForm.parentCemeteryId, user.userName, Date.now(), updateForm.cemeteryId);
|
||||||
|
database
|
||||||
|
.prepare(`delete from CemeteryDirectionsOfArrival
|
||||||
|
where cemeteryId = ?`)
|
||||||
|
.run(updateForm.cemeteryId);
|
||||||
|
for (const direction of directionsOfArrival) {
|
||||||
|
const directionDescriptionName = `directionOfArrivalDescription_${direction}`;
|
||||||
|
if (directionDescriptionName in updateForm) {
|
||||||
|
database
|
||||||
|
.prepare(`insert into CemeteryDirectionsOfArrival (
|
||||||
|
cemeteryId, directionOfArrival, directionOfArrivalDescription)
|
||||||
|
values (?, ?, ?)`)
|
||||||
|
.run(updateForm.cemeteryId, direction, updateForm[directionDescriptionName] ?? '');
|
||||||
|
}
|
||||||
|
}
|
||||||
database.close();
|
database.close();
|
||||||
return result.changes > 0;
|
return result.changes > 0;
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -1,27 +1,39 @@
|
||||||
import sqlite from 'better-sqlite3'
|
import sqlite from 'better-sqlite3'
|
||||||
|
|
||||||
|
import { directionsOfArrival } from '../data/dataLists.js'
|
||||||
import { sunriseDB } from '../helpers/database.helpers.js'
|
import { sunriseDB } from '../helpers/database.helpers.js'
|
||||||
|
|
||||||
export interface UpdateCemeteryForm {
|
export type UpdateCemeteryForm = Partial<
|
||||||
cemeteryId: string
|
Record<
|
||||||
|
`directionOfArrival_${(typeof directionsOfArrival)[number]}`,
|
||||||
|
(typeof directionsOfArrival)[number]
|
||||||
|
>
|
||||||
|
> &
|
||||||
|
Partial<
|
||||||
|
Record<
|
||||||
|
`directionOfArrivalDescription_${(typeof directionsOfArrival)[number]}`,
|
||||||
|
string
|
||||||
|
>
|
||||||
|
> & {
|
||||||
|
cemeteryId: string
|
||||||
|
|
||||||
cemeteryDescription: string
|
cemeteryDescription: string
|
||||||
cemeteryKey: string
|
cemeteryKey: string
|
||||||
cemeteryName: string
|
cemeteryName: string
|
||||||
parentCemeteryId: string
|
parentCemeteryId: string
|
||||||
|
|
||||||
cemeteryAddress1: string
|
cemeteryAddress1: string
|
||||||
cemeteryAddress2: string
|
cemeteryAddress2: string
|
||||||
cemeteryCity: string
|
cemeteryCity: string
|
||||||
cemeteryPostalCode: string
|
cemeteryPostalCode: string
|
||||||
cemeteryProvince: string
|
cemeteryProvince: string
|
||||||
|
|
||||||
cemeteryPhoneNumber: string
|
cemeteryPhoneNumber: string
|
||||||
|
|
||||||
cemeteryLatitude: string
|
cemeteryLatitude: string
|
||||||
cemeteryLongitude: string
|
cemeteryLongitude: string
|
||||||
cemeterySvg: string
|
cemeterySvg: string
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Updates a cemetery in the database.
|
* Updates a cemetery in the database.
|
||||||
|
|
@ -82,6 +94,31 @@ export default function updateCemetery(
|
||||||
updateForm.cemeteryId
|
updateForm.cemeteryId
|
||||||
)
|
)
|
||||||
|
|
||||||
|
database
|
||||||
|
.prepare(
|
||||||
|
`delete from CemeteryDirectionsOfArrival
|
||||||
|
where cemeteryId = ?`
|
||||||
|
)
|
||||||
|
.run(updateForm.cemeteryId)
|
||||||
|
|
||||||
|
for (const direction of directionsOfArrival) {
|
||||||
|
const directionDescriptionName = `directionOfArrivalDescription_${direction}`
|
||||||
|
|
||||||
|
if (directionDescriptionName in updateForm) {
|
||||||
|
database
|
||||||
|
.prepare(
|
||||||
|
`insert into CemeteryDirectionsOfArrival (
|
||||||
|
cemeteryId, directionOfArrival, directionOfArrivalDescription)
|
||||||
|
values (?, ?, ?)`
|
||||||
|
)
|
||||||
|
.run(
|
||||||
|
updateForm.cemeteryId,
|
||||||
|
direction,
|
||||||
|
updateForm[directionDescriptionName] ?? ''
|
||||||
|
)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
database.close()
|
database.close()
|
||||||
|
|
||||||
return result.changes > 0
|
return result.changes > 0
|
||||||
|
|
|
||||||
|
|
@ -7,6 +7,7 @@ export interface UpdateContractForm {
|
||||||
contractStartDateString: DateString;
|
contractStartDateString: DateString;
|
||||||
funeralHomeId?: number | string;
|
funeralHomeId?: number | string;
|
||||||
committalTypeId?: number | string;
|
committalTypeId?: number | string;
|
||||||
|
directionOfArrival?: string;
|
||||||
funeralDateString: '' | DateString;
|
funeralDateString: '' | DateString;
|
||||||
funeralDirectorName: string;
|
funeralDirectorName: string;
|
||||||
funeralTimeString: '' | TimeString;
|
funeralTimeString: '' | TimeString;
|
||||||
|
|
|
||||||
|
|
@ -16,6 +16,7 @@ export default function updateContract(updateForm, user) {
|
||||||
funeralDirectorName = ?,
|
funeralDirectorName = ?,
|
||||||
funeralDate = ?,
|
funeralDate = ?,
|
||||||
funeralTime = ?,
|
funeralTime = ?,
|
||||||
|
directionOfArrival = ?,
|
||||||
committalTypeId = ?,
|
committalTypeId = ?,
|
||||||
purchaserName = ?,
|
purchaserName = ?,
|
||||||
purchaserAddress1 = ?,
|
purchaserAddress1 = ?,
|
||||||
|
|
@ -36,7 +37,7 @@ export default function updateContract(updateForm, user) {
|
||||||
? undefined
|
? undefined
|
||||||
: dateStringToInteger(updateForm.funeralDateString), updateForm.funeralTimeString === ''
|
: dateStringToInteger(updateForm.funeralDateString), updateForm.funeralTimeString === ''
|
||||||
? undefined
|
? undefined
|
||||||
: timeStringToInteger(updateForm.funeralTimeString), updateForm.committalTypeId === ''
|
: timeStringToInteger(updateForm.funeralTimeString), updateForm.directionOfArrival ?? '', updateForm.committalTypeId === ''
|
||||||
? undefined
|
? undefined
|
||||||
: updateForm.committalTypeId, updateForm.purchaserName ?? '', updateForm.purchaserAddress1 ?? '', updateForm.purchaserAddress2 ?? '', updateForm.purchaserCity ?? '', updateForm.purchaserProvince ?? '', updateForm.purchaserPostalCode ?? '', updateForm.purchaserPhoneNumber ?? '', updateForm.purchaserEmail ?? '', updateForm.purchaserRelationship ?? '', user.userName, Date.now(), updateForm.contractId);
|
: updateForm.committalTypeId, updateForm.purchaserName ?? '', updateForm.purchaserAddress1 ?? '', updateForm.purchaserAddress2 ?? '', updateForm.purchaserCity ?? '', updateForm.purchaserProvince ?? '', updateForm.purchaserPostalCode ?? '', updateForm.purchaserPhoneNumber ?? '', updateForm.purchaserEmail ?? '', updateForm.purchaserRelationship ?? '', user.userName, Date.now(), updateForm.contractId);
|
||||||
if (result.changes > 0) {
|
if (result.changes > 0) {
|
||||||
|
|
|
||||||
|
|
@ -23,6 +23,7 @@ export interface UpdateContractForm {
|
||||||
funeralHomeId?: number | string
|
funeralHomeId?: number | string
|
||||||
|
|
||||||
committalTypeId?: number | string
|
committalTypeId?: number | string
|
||||||
|
directionOfArrival?: string
|
||||||
funeralDateString: '' | DateString
|
funeralDateString: '' | DateString
|
||||||
funeralDirectorName: string
|
funeralDirectorName: string
|
||||||
funeralTimeString: '' | TimeString
|
funeralTimeString: '' | TimeString
|
||||||
|
|
@ -61,6 +62,7 @@ export default function updateContract(
|
||||||
funeralDirectorName = ?,
|
funeralDirectorName = ?,
|
||||||
funeralDate = ?,
|
funeralDate = ?,
|
||||||
funeralTime = ?,
|
funeralTime = ?,
|
||||||
|
directionOfArrival = ?,
|
||||||
committalTypeId = ?,
|
committalTypeId = ?,
|
||||||
purchaserName = ?,
|
purchaserName = ?,
|
||||||
purchaserAddress1 = ?,
|
purchaserAddress1 = ?,
|
||||||
|
|
@ -91,6 +93,7 @@ export default function updateContract(
|
||||||
updateForm.funeralTimeString === ''
|
updateForm.funeralTimeString === ''
|
||||||
? undefined
|
? undefined
|
||||||
: timeStringToInteger(updateForm.funeralTimeString),
|
: timeStringToInteger(updateForm.funeralTimeString),
|
||||||
|
updateForm.directionOfArrival ?? '',
|
||||||
updateForm.committalTypeId === ''
|
updateForm.committalTypeId === ''
|
||||||
? undefined
|
? undefined
|
||||||
: updateForm.committalTypeId,
|
: updateForm.committalTypeId,
|
||||||
|
|
|
||||||
|
|
@ -3,6 +3,7 @@ import getContract from '../../database/getContract.js';
|
||||||
import getFuneralHomes from '../../database/getFuneralHomes.js';
|
import getFuneralHomes from '../../database/getFuneralHomes.js';
|
||||||
import { getConfigProperty } from '../../helpers/config.helpers.js';
|
import { getConfigProperty } from '../../helpers/config.helpers.js';
|
||||||
import { getBurialSiteStatuses, getBurialSiteTypes, getCommittalTypes, getContractTypePrintsById, getContractTypes, getIntermentContainerTypes, getWorkOrderTypes } from '../../helpers/functions.cache.js';
|
import { getBurialSiteStatuses, getBurialSiteTypes, getCommittalTypes, getContractTypePrintsById, getContractTypes, getIntermentContainerTypes, getWorkOrderTypes } from '../../helpers/functions.cache.js';
|
||||||
|
import getBurialSiteDirectionsOfArrival, { defaultDirectionsOfArrival } from '../../database/getBurialSiteDirectionsOfArrival.js';
|
||||||
export default async function handler(request, response) {
|
export default async function handler(request, response) {
|
||||||
const contract = await getContract(request.params.contractId);
|
const contract = await getContract(request.params.contractId);
|
||||||
if (contract === undefined) {
|
if (contract === undefined) {
|
||||||
|
|
@ -23,6 +24,9 @@ export default async function handler(request, response) {
|
||||||
const burialSiteStatuses = getBurialSiteStatuses();
|
const burialSiteStatuses = getBurialSiteStatuses();
|
||||||
const burialSiteTypes = getBurialSiteTypes();
|
const burialSiteTypes = getBurialSiteTypes();
|
||||||
const cemeteries = getCemeteries();
|
const cemeteries = getCemeteries();
|
||||||
|
const burialSiteDirectionsOfArrival = contract.burialSiteId === undefined
|
||||||
|
? defaultDirectionsOfArrival
|
||||||
|
: getBurialSiteDirectionsOfArrival(contract.burialSiteId);
|
||||||
/*
|
/*
|
||||||
* Work Order Drop Lists
|
* Work Order Drop Lists
|
||||||
*/
|
*/
|
||||||
|
|
@ -38,6 +42,7 @@ export default async function handler(request, response) {
|
||||||
burialSiteStatuses,
|
burialSiteStatuses,
|
||||||
burialSiteTypes,
|
burialSiteTypes,
|
||||||
cemeteries,
|
cemeteries,
|
||||||
|
burialSiteDirectionsOfArrival,
|
||||||
workOrderTypes,
|
workOrderTypes,
|
||||||
isCreate: false
|
isCreate: false
|
||||||
});
|
});
|
||||||
|
|
|
||||||
|
|
@ -13,6 +13,9 @@ import {
|
||||||
getIntermentContainerTypes,
|
getIntermentContainerTypes,
|
||||||
getWorkOrderTypes
|
getWorkOrderTypes
|
||||||
} from '../../helpers/functions.cache.js'
|
} from '../../helpers/functions.cache.js'
|
||||||
|
import getBurialSiteDirectionsOfArrival, {
|
||||||
|
defaultDirectionsOfArrival
|
||||||
|
} from '../../database/getBurialSiteDirectionsOfArrival.js'
|
||||||
|
|
||||||
export default async function handler(
|
export default async function handler(
|
||||||
request: Request,
|
request: Request,
|
||||||
|
|
@ -48,6 +51,11 @@ export default async function handler(
|
||||||
const burialSiteTypes = getBurialSiteTypes()
|
const burialSiteTypes = getBurialSiteTypes()
|
||||||
const cemeteries = getCemeteries()
|
const cemeteries = getCemeteries()
|
||||||
|
|
||||||
|
const burialSiteDirectionsOfArrival =
|
||||||
|
contract.burialSiteId === undefined
|
||||||
|
? defaultDirectionsOfArrival
|
||||||
|
: getBurialSiteDirectionsOfArrival(contract.burialSiteId)
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* Work Order Drop Lists
|
* Work Order Drop Lists
|
||||||
*/
|
*/
|
||||||
|
|
@ -69,6 +77,8 @@ export default async function handler(
|
||||||
burialSiteTypes,
|
burialSiteTypes,
|
||||||
cemeteries,
|
cemeteries,
|
||||||
|
|
||||||
|
burialSiteDirectionsOfArrival,
|
||||||
|
|
||||||
workOrderTypes,
|
workOrderTypes,
|
||||||
|
|
||||||
isCreate: false
|
isCreate: false
|
||||||
|
|
|
||||||
|
|
@ -1,5 +1,6 @@
|
||||||
import { dateToInteger, dateToString } from '@cityssm/utils-datetime';
|
import { dateToInteger, dateToString } from '@cityssm/utils-datetime';
|
||||||
import getBurialSite from '../../database/getBurialSite.js';
|
import getBurialSite from '../../database/getBurialSite.js';
|
||||||
|
import getBurialSiteDirectionsOfArrival, { defaultDirectionsOfArrival } from '../../database/getBurialSiteDirectionsOfArrival.js';
|
||||||
import getCemeteries from '../../database/getCemeteries.js';
|
import getCemeteries from '../../database/getCemeteries.js';
|
||||||
import getFuneralHomes from '../../database/getFuneralHomes.js';
|
import getFuneralHomes from '../../database/getFuneralHomes.js';
|
||||||
import { getConfigProperty } from '../../helpers/config.helpers.js';
|
import { getConfigProperty } from '../../helpers/config.helpers.js';
|
||||||
|
|
@ -35,6 +36,9 @@ export default async function handler(request, response) {
|
||||||
const burialSiteStatuses = getBurialSiteStatuses();
|
const burialSiteStatuses = getBurialSiteStatuses();
|
||||||
const burialSiteTypes = getBurialSiteTypes();
|
const burialSiteTypes = getBurialSiteTypes();
|
||||||
const cemeteries = getCemeteries();
|
const cemeteries = getCemeteries();
|
||||||
|
const burialSiteDirectionsOfArrival = contract.burialSiteId === undefined
|
||||||
|
? defaultDirectionsOfArrival
|
||||||
|
: getBurialSiteDirectionsOfArrival(contract.burialSiteId);
|
||||||
response.render('contract-edit', {
|
response.render('contract-edit', {
|
||||||
headTitle: 'Create a New Contract',
|
headTitle: 'Create a New Contract',
|
||||||
contract,
|
contract,
|
||||||
|
|
@ -45,6 +49,7 @@ export default async function handler(request, response) {
|
||||||
burialSiteStatuses,
|
burialSiteStatuses,
|
||||||
burialSiteTypes,
|
burialSiteTypes,
|
||||||
cemeteries,
|
cemeteries,
|
||||||
|
burialSiteDirectionsOfArrival,
|
||||||
isCreate: true
|
isCreate: true
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -3,6 +3,7 @@ import type { Request, Response } from 'express'
|
||||||
import { dateToInteger, dateToString } from '@cityssm/utils-datetime'
|
import { dateToInteger, dateToString } from '@cityssm/utils-datetime'
|
||||||
|
|
||||||
import getBurialSite from '../../database/getBurialSite.js'
|
import getBurialSite from '../../database/getBurialSite.js'
|
||||||
|
import getBurialSiteDirectionsOfArrival, { defaultDirectionsOfArrival } from '../../database/getBurialSiteDirectionsOfArrival.js'
|
||||||
import getCemeteries from '../../database/getCemeteries.js'
|
import getCemeteries from '../../database/getCemeteries.js'
|
||||||
import getFuneralHomes from '../../database/getFuneralHomes.js'
|
import getFuneralHomes from '../../database/getFuneralHomes.js'
|
||||||
import { getConfigProperty } from '../../helpers/config.helpers.js'
|
import { getConfigProperty } from '../../helpers/config.helpers.js'
|
||||||
|
|
@ -58,6 +59,11 @@ export default async function handler(
|
||||||
const burialSiteTypes = getBurialSiteTypes()
|
const burialSiteTypes = getBurialSiteTypes()
|
||||||
const cemeteries = getCemeteries()
|
const cemeteries = getCemeteries()
|
||||||
|
|
||||||
|
const burialSiteDirectionsOfArrival =
|
||||||
|
contract.burialSiteId === undefined
|
||||||
|
? defaultDirectionsOfArrival
|
||||||
|
: getBurialSiteDirectionsOfArrival(contract.burialSiteId)
|
||||||
|
|
||||||
response.render('contract-edit', {
|
response.render('contract-edit', {
|
||||||
headTitle: 'Create a New Contract',
|
headTitle: 'Create a New Contract',
|
||||||
|
|
||||||
|
|
@ -72,6 +78,8 @@ export default async function handler(
|
||||||
burialSiteTypes,
|
burialSiteTypes,
|
||||||
cemeteries,
|
cemeteries,
|
||||||
|
|
||||||
|
burialSiteDirectionsOfArrival,
|
||||||
|
|
||||||
isCreate: true
|
isCreate: true
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -0,0 +1,4 @@
|
||||||
|
import type { Request, Response } from 'express';
|
||||||
|
export default function handler(request: Request<unknown, unknown, {
|
||||||
|
burialSiteId: string;
|
||||||
|
}>, response: Response): void;
|
||||||
|
|
@ -0,0 +1,9 @@
|
||||||
|
import getBurialSiteDirectionsOfArrival, { defaultDirectionsOfArrival } from '../../database/getBurialSiteDirectionsOfArrival.js';
|
||||||
|
export default function handler(request, response) {
|
||||||
|
const directionsOfArrival = request.body.burialSiteId === ''
|
||||||
|
? defaultDirectionsOfArrival
|
||||||
|
: getBurialSiteDirectionsOfArrival(request.body.burialSiteId);
|
||||||
|
response.json({
|
||||||
|
directionsOfArrival
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
@ -0,0 +1,19 @@
|
||||||
|
import type { Request, Response } from 'express'
|
||||||
|
|
||||||
|
import getBurialSiteDirectionsOfArrival, {
|
||||||
|
defaultDirectionsOfArrival
|
||||||
|
} from '../../database/getBurialSiteDirectionsOfArrival.js'
|
||||||
|
|
||||||
|
export default function handler(
|
||||||
|
request: Request<unknown, unknown, { burialSiteId: string }>,
|
||||||
|
response: Response
|
||||||
|
): void {
|
||||||
|
const directionsOfArrival =
|
||||||
|
request.body.burialSiteId === ''
|
||||||
|
? defaultDirectionsOfArrival
|
||||||
|
: getBurialSiteDirectionsOfArrival(request.body.burialSiteId)
|
||||||
|
|
||||||
|
response.json({
|
||||||
|
directionsOfArrival
|
||||||
|
})
|
||||||
|
}
|
||||||
|
|
@ -96,4 +96,26 @@ Object.defineProperty(exports, "__esModule", { value: true });
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
/*
|
||||||
|
* Directions of Arrival
|
||||||
|
*/
|
||||||
|
function toggleDirectionOfArrivalDescription(clickEvent) {
|
||||||
|
const checkboxElement = clickEvent.currentTarget;
|
||||||
|
const descriptionElement = document.querySelector(`#cemetery--directionOfArrivalDescription_${checkboxElement.value}`);
|
||||||
|
if (checkboxElement.checked) {
|
||||||
|
descriptionElement.removeAttribute('disabled');
|
||||||
|
descriptionElement.focus();
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
descriptionElement.setAttribute('disabled', 'disabled');
|
||||||
|
// descriptionElement.value = ''
|
||||||
|
}
|
||||||
|
setUnsavedChanges();
|
||||||
|
}
|
||||||
|
const directionOfArrivalCheckboxElements =
|
||||||
|
// eslint-disable-next-line no-secrets/no-secrets
|
||||||
|
document.querySelectorAll('input[name^="directionOfArrival_"]');
|
||||||
|
for (const checkboxElement of directionOfArrivalCheckboxElements) {
|
||||||
|
checkboxElement.addEventListener('change', toggleDirectionOfArrivalDescription);
|
||||||
|
}
|
||||||
})();
|
})();
|
||||||
|
|
|
||||||
|
|
@ -149,4 +149,37 @@ declare const exports: Record<string, unknown>
|
||||||
}
|
}
|
||||||
})
|
})
|
||||||
})
|
})
|
||||||
|
|
||||||
|
/*
|
||||||
|
* Directions of Arrival
|
||||||
|
*/
|
||||||
|
|
||||||
|
function toggleDirectionOfArrivalDescription(clickEvent: Event): void {
|
||||||
|
const checkboxElement = clickEvent.currentTarget as HTMLInputElement
|
||||||
|
|
||||||
|
const descriptionElement = document.querySelector(
|
||||||
|
`#cemetery--directionOfArrivalDescription_${checkboxElement.value}`
|
||||||
|
) as HTMLInputElement
|
||||||
|
|
||||||
|
if (checkboxElement.checked) {
|
||||||
|
descriptionElement.removeAttribute('disabled')
|
||||||
|
descriptionElement.focus()
|
||||||
|
} else {
|
||||||
|
descriptionElement.setAttribute('disabled', 'disabled')
|
||||||
|
// descriptionElement.value = ''
|
||||||
|
}
|
||||||
|
|
||||||
|
setUnsavedChanges()
|
||||||
|
}
|
||||||
|
|
||||||
|
const directionOfArrivalCheckboxElements: NodeListOf<HTMLInputElement> =
|
||||||
|
// eslint-disable-next-line no-secrets/no-secrets
|
||||||
|
document.querySelectorAll('input[name^="directionOfArrival_"]')
|
||||||
|
|
||||||
|
for (const checkboxElement of directionOfArrivalCheckboxElements) {
|
||||||
|
checkboxElement.addEventListener(
|
||||||
|
'change',
|
||||||
|
toggleDirectionOfArrivalDescription
|
||||||
|
)
|
||||||
|
}
|
||||||
})()
|
})()
|
||||||
|
|
|
||||||
|
|
@ -231,7 +231,37 @@ Object.defineProperty(exports, "__esModule", { value: true });
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
// Burial Site Selector
|
// Burial Site Selector
|
||||||
|
const burialSiteIdElement = document.querySelector('#contract--burialSiteId');
|
||||||
const burialSiteNameElement = document.querySelector('#contract--burialSiteName');
|
const burialSiteNameElement = document.querySelector('#contract--burialSiteName');
|
||||||
|
const directionOfArrivalElement = document.querySelector('#contract--directionOfArrival');
|
||||||
|
function refreshDirectionsOfArrival() {
|
||||||
|
const burialSiteId = burialSiteIdElement.value;
|
||||||
|
cityssm.postJSON(`${sunrise.urlPrefix}/contracts/doGetBurialSiteDirectionsOfArrival`, {
|
||||||
|
burialSiteId
|
||||||
|
}, (rawResponseJSON) => {
|
||||||
|
const responseJSON = rawResponseJSON;
|
||||||
|
const currentDirectionOfArrival = directionOfArrivalElement.value;
|
||||||
|
directionOfArrivalElement.value = '';
|
||||||
|
directionOfArrivalElement.innerHTML =
|
||||||
|
'<option value="">(No Direction)</option>';
|
||||||
|
for (const direction of exports.directionsOfArrival) {
|
||||||
|
// eslint-disable-next-line security/detect-object-injection
|
||||||
|
if (responseJSON.directionsOfArrival[direction] !== undefined) {
|
||||||
|
const optionElement = document.createElement('option');
|
||||||
|
optionElement.value = direction;
|
||||||
|
optionElement.textContent =
|
||||||
|
direction +
|
||||||
|
(responseJSON.directionsOfArrival[direction] === ''
|
||||||
|
? ''
|
||||||
|
: ` - ${responseJSON.directionsOfArrival[direction]}`);
|
||||||
|
if (currentDirectionOfArrival === direction) {
|
||||||
|
optionElement.selected = true;
|
||||||
|
}
|
||||||
|
directionOfArrivalElement.append(optionElement);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
});
|
||||||
|
}
|
||||||
burialSiteNameElement.addEventListener('click', (clickEvent) => {
|
burialSiteNameElement.addEventListener('click', (clickEvent) => {
|
||||||
const currentBurialSiteName = clickEvent.currentTarget
|
const currentBurialSiteName = clickEvent.currentTarget
|
||||||
.value;
|
.value;
|
||||||
|
|
@ -240,11 +270,11 @@ Object.defineProperty(exports, "__esModule", { value: true });
|
||||||
let burialSiteSelectResultsElement;
|
let burialSiteSelectResultsElement;
|
||||||
let burialSiteCreateFormElement;
|
let burialSiteCreateFormElement;
|
||||||
function renderSelectedBurialSiteAndClose(burialSiteId, burialSiteName) {
|
function renderSelectedBurialSiteAndClose(burialSiteId, burialSiteName) {
|
||||||
;
|
burialSiteIdElement.value = burialSiteId.toString();
|
||||||
document.querySelector('#contract--burialSiteId').value = burialSiteId.toString();
|
burialSiteNameElement.value = burialSiteName;
|
||||||
document.querySelector('#contract--burialSiteName').value = burialSiteName;
|
|
||||||
setUnsavedChanges();
|
setUnsavedChanges();
|
||||||
burialSiteSelectCloseModalFunction();
|
burialSiteSelectCloseModalFunction();
|
||||||
|
refreshDirectionsOfArrival();
|
||||||
}
|
}
|
||||||
function selectExistingBurialSite(selectClickEvent) {
|
function selectExistingBurialSite(selectClickEvent) {
|
||||||
selectClickEvent.preventDefault();
|
selectClickEvent.preventDefault();
|
||||||
|
|
@ -401,6 +431,7 @@ Object.defineProperty(exports, "__esModule", { value: true });
|
||||||
else {
|
else {
|
||||||
burialSiteNameElement.value = '(No Burial Site)';
|
burialSiteNameElement.value = '(No Burial Site)';
|
||||||
document.querySelector('#contract--burialSiteId').value = '';
|
document.querySelector('#contract--burialSiteId').value = '';
|
||||||
|
refreshDirectionsOfArrival();
|
||||||
setUnsavedChanges();
|
setUnsavedChanges();
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
|
||||||
|
|
@ -4,6 +4,7 @@
|
||||||
import type { BulmaJS } from '@cityssm/bulma-js/types.js'
|
import type { BulmaJS } from '@cityssm/bulma-js/types.js'
|
||||||
import type { cityssmGlobal } from '@cityssm/bulma-webapp-js/src/types.js'
|
import type { cityssmGlobal } from '@cityssm/bulma-webapp-js/src/types.js'
|
||||||
|
|
||||||
|
import type { directionsOfArrival } from '../../data/dataLists.js'
|
||||||
import type {
|
import type {
|
||||||
BurialSite,
|
BurialSite,
|
||||||
BurialSiteStatus,
|
BurialSiteStatus,
|
||||||
|
|
@ -13,6 +14,7 @@ import type {
|
||||||
} from '../../types/record.types.js'
|
} from '../../types/record.types.js'
|
||||||
|
|
||||||
import type { Sunrise } from './types.js'
|
import type { Sunrise } from './types.js'
|
||||||
|
import { ref } from 'process'
|
||||||
|
|
||||||
declare const cityssm: cityssmGlobal
|
declare const cityssm: cityssmGlobal
|
||||||
declare const bulmaJS: BulmaJS
|
declare const bulmaJS: BulmaJS
|
||||||
|
|
@ -22,6 +24,8 @@ declare const exports: {
|
||||||
burialSiteStatuses: BurialSiteStatus[]
|
burialSiteStatuses: BurialSiteStatus[]
|
||||||
burialSiteTypes: BurialSiteType[]
|
burialSiteTypes: BurialSiteType[]
|
||||||
cemeteries: Cemetery[]
|
cemeteries: Cemetery[]
|
||||||
|
|
||||||
|
directionsOfArrival: typeof directionsOfArrival
|
||||||
}
|
}
|
||||||
;(() => {
|
;(() => {
|
||||||
const sunrise = exports.sunrise
|
const sunrise = exports.sunrise
|
||||||
|
|
@ -362,10 +366,60 @@ declare const exports: {
|
||||||
|
|
||||||
// Burial Site Selector
|
// Burial Site Selector
|
||||||
|
|
||||||
|
const burialSiteIdElement = document.querySelector(
|
||||||
|
'#contract--burialSiteId'
|
||||||
|
) as HTMLInputElement
|
||||||
|
|
||||||
const burialSiteNameElement = document.querySelector(
|
const burialSiteNameElement = document.querySelector(
|
||||||
'#contract--burialSiteName'
|
'#contract--burialSiteName'
|
||||||
) as HTMLInputElement
|
) as HTMLInputElement
|
||||||
|
|
||||||
|
const directionOfArrivalElement = document.querySelector(
|
||||||
|
'#contract--directionOfArrival'
|
||||||
|
) as HTMLSelectElement
|
||||||
|
|
||||||
|
function refreshDirectionsOfArrival(): void {
|
||||||
|
const burialSiteId = burialSiteIdElement.value
|
||||||
|
|
||||||
|
cityssm.postJSON(
|
||||||
|
`${sunrise.urlPrefix}/contracts/doGetBurialSiteDirectionsOfArrival`,
|
||||||
|
{
|
||||||
|
burialSiteId
|
||||||
|
},
|
||||||
|
(rawResponseJSON) => {
|
||||||
|
const responseJSON = rawResponseJSON as {
|
||||||
|
directionsOfArrival: Partial<Record<string, string>>
|
||||||
|
}
|
||||||
|
|
||||||
|
const currentDirectionOfArrival = directionOfArrivalElement.value
|
||||||
|
|
||||||
|
directionOfArrivalElement.value = ''
|
||||||
|
directionOfArrivalElement.innerHTML =
|
||||||
|
'<option value="">(No Direction)</option>'
|
||||||
|
|
||||||
|
for (const direction of exports.directionsOfArrival) {
|
||||||
|
// eslint-disable-next-line security/detect-object-injection
|
||||||
|
if (responseJSON.directionsOfArrival[direction] !== undefined) {
|
||||||
|
const optionElement = document.createElement('option')
|
||||||
|
|
||||||
|
optionElement.value = direction
|
||||||
|
optionElement.textContent =
|
||||||
|
direction +
|
||||||
|
(responseJSON.directionsOfArrival[direction] === ''
|
||||||
|
? ''
|
||||||
|
: ` - ${responseJSON.directionsOfArrival[direction]}`)
|
||||||
|
|
||||||
|
if (currentDirectionOfArrival === direction) {
|
||||||
|
optionElement.selected = true
|
||||||
|
}
|
||||||
|
|
||||||
|
directionOfArrivalElement.append(optionElement)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
)
|
||||||
|
}
|
||||||
|
|
||||||
burialSiteNameElement.addEventListener('click', (clickEvent) => {
|
burialSiteNameElement.addEventListener('click', (clickEvent) => {
|
||||||
const currentBurialSiteName = (clickEvent.currentTarget as HTMLInputElement)
|
const currentBurialSiteName = (clickEvent.currentTarget as HTMLInputElement)
|
||||||
.value
|
.value
|
||||||
|
|
@ -381,15 +435,13 @@ declare const exports: {
|
||||||
burialSiteId: number | string,
|
burialSiteId: number | string,
|
||||||
burialSiteName: string
|
burialSiteName: string
|
||||||
): void {
|
): void {
|
||||||
;(
|
burialSiteIdElement.value = burialSiteId.toString()
|
||||||
document.querySelector('#contract--burialSiteId') as HTMLInputElement
|
burialSiteNameElement.value = burialSiteName
|
||||||
).value = burialSiteId.toString()
|
|
||||||
;(
|
|
||||||
document.querySelector('#contract--burialSiteName') as HTMLInputElement
|
|
||||||
).value = burialSiteName
|
|
||||||
|
|
||||||
setUnsavedChanges()
|
setUnsavedChanges()
|
||||||
burialSiteSelectCloseModalFunction()
|
burialSiteSelectCloseModalFunction()
|
||||||
|
|
||||||
|
refreshDirectionsOfArrival()
|
||||||
}
|
}
|
||||||
|
|
||||||
function selectExistingBurialSite(selectClickEvent: Event): void {
|
function selectExistingBurialSite(selectClickEvent: Event): void {
|
||||||
|
|
@ -661,6 +713,7 @@ declare const exports: {
|
||||||
document.querySelector('#contract--burialSiteId') as HTMLInputElement
|
document.querySelector('#contract--burialSiteId') as HTMLInputElement
|
||||||
).value = ''
|
).value = ''
|
||||||
|
|
||||||
|
refreshDirectionsOfArrival()
|
||||||
setUnsavedChanges()
|
setUnsavedChanges()
|
||||||
}
|
}
|
||||||
})
|
})
|
||||||
|
|
|
||||||
|
|
@ -17,6 +17,7 @@ import handler_doDeleteContractComment from '../handlers/contracts-post/doDelete
|
||||||
import handler_doDeleteContractFee from '../handlers/contracts-post/doDeleteContractFee.js';
|
import handler_doDeleteContractFee from '../handlers/contracts-post/doDeleteContractFee.js';
|
||||||
import handler_doDeleteContractInterment from '../handlers/contracts-post/doDeleteContractInterment.js';
|
import handler_doDeleteContractInterment from '../handlers/contracts-post/doDeleteContractInterment.js';
|
||||||
import handler_doDeleteContractTransaction from '../handlers/contracts-post/doDeleteContractTransaction.js';
|
import handler_doDeleteContractTransaction from '../handlers/contracts-post/doDeleteContractTransaction.js';
|
||||||
|
import handler_doGetBurialSiteDirectionsOfArrival from '../handlers/contracts-post/doGetBurialSiteDirectionsOfArrival.js';
|
||||||
import handler_doGetContractTypeFields from '../handlers/contracts-post/doGetContractTypeFields.js';
|
import handler_doGetContractTypeFields from '../handlers/contracts-post/doGetContractTypeFields.js';
|
||||||
import handler_doGetDynamicsGPDocument from '../handlers/contracts-post/doGetDynamicsGPDocument.js';
|
import handler_doGetDynamicsGPDocument from '../handlers/contracts-post/doGetDynamicsGPDocument.js';
|
||||||
import handler_doGetFees from '../handlers/contracts-post/doGetFees.js';
|
import handler_doGetFees from '../handlers/contracts-post/doGetFees.js';
|
||||||
|
|
@ -45,6 +46,7 @@ router.get('/:contractId/edit', updateGetHandler, handler_edit);
|
||||||
router.post('/doUpdateContract', updatePostHandler, handler_doUpdateContract);
|
router.post('/doUpdateContract', updatePostHandler, handler_doUpdateContract);
|
||||||
router.post('/doCopyContract', updatePostHandler, handler_doCopyContract);
|
router.post('/doCopyContract', updatePostHandler, handler_doCopyContract);
|
||||||
router.post('/doDeleteContract', updatePostHandler, handler_doDeleteContract);
|
router.post('/doDeleteContract', updatePostHandler, handler_doDeleteContract);
|
||||||
|
router.post('/doGetBurialSiteDirectionsOfArrival', updatePostHandler, handler_doGetBurialSiteDirectionsOfArrival);
|
||||||
// Interments
|
// Interments
|
||||||
router.post('/doAddContractInterment', updatePostHandler, handler_doAddContractInterment);
|
router.post('/doAddContractInterment', updatePostHandler, handler_doAddContractInterment);
|
||||||
router.post('/doUpdateContractInterment', updatePostHandler, handler_doUpdateContractInterment);
|
router.post('/doUpdateContractInterment', updatePostHandler, handler_doUpdateContractInterment);
|
||||||
|
|
|
||||||
|
|
@ -18,6 +18,7 @@ import handler_doDeleteContractComment from '../handlers/contracts-post/doDelete
|
||||||
import handler_doDeleteContractFee from '../handlers/contracts-post/doDeleteContractFee.js'
|
import handler_doDeleteContractFee from '../handlers/contracts-post/doDeleteContractFee.js'
|
||||||
import handler_doDeleteContractInterment from '../handlers/contracts-post/doDeleteContractInterment.js'
|
import handler_doDeleteContractInterment from '../handlers/contracts-post/doDeleteContractInterment.js'
|
||||||
import handler_doDeleteContractTransaction from '../handlers/contracts-post/doDeleteContractTransaction.js'
|
import handler_doDeleteContractTransaction from '../handlers/contracts-post/doDeleteContractTransaction.js'
|
||||||
|
import handler_doGetBurialSiteDirectionsOfArrival from '../handlers/contracts-post/doGetBurialSiteDirectionsOfArrival.js'
|
||||||
import handler_doGetContractTypeFields from '../handlers/contracts-post/doGetContractTypeFields.js'
|
import handler_doGetContractTypeFields from '../handlers/contracts-post/doGetContractTypeFields.js'
|
||||||
import handler_doGetDynamicsGPDocument from '../handlers/contracts-post/doGetDynamicsGPDocument.js'
|
import handler_doGetDynamicsGPDocument from '../handlers/contracts-post/doGetDynamicsGPDocument.js'
|
||||||
import handler_doGetFees from '../handlers/contracts-post/doGetFees.js'
|
import handler_doGetFees from '../handlers/contracts-post/doGetFees.js'
|
||||||
|
|
@ -68,6 +69,12 @@ router.post('/doCopyContract', updatePostHandler, handler_doCopyContract)
|
||||||
|
|
||||||
router.post('/doDeleteContract', updatePostHandler, handler_doDeleteContract)
|
router.post('/doDeleteContract', updatePostHandler, handler_doDeleteContract)
|
||||||
|
|
||||||
|
router.post(
|
||||||
|
'/doGetBurialSiteDirectionsOfArrival',
|
||||||
|
updatePostHandler,
|
||||||
|
handler_doGetBurialSiteDirectionsOfArrival
|
||||||
|
)
|
||||||
|
|
||||||
// Interments
|
// Interments
|
||||||
|
|
||||||
router.post(
|
router.post(
|
||||||
|
|
|
||||||
|
|
@ -1,4 +1,5 @@
|
||||||
import type { DateString, TimeString } from '@cityssm/utils-datetime';
|
import type { DateString, TimeString } from '@cityssm/utils-datetime';
|
||||||
|
import type { directionsOfArrival } from '../data/dataLists.js';
|
||||||
export interface BurialSite extends Record {
|
export interface BurialSite extends Record {
|
||||||
burialSiteId: number;
|
burialSiteId: number;
|
||||||
burialSiteName?: string;
|
burialSiteName?: string;
|
||||||
|
|
@ -85,6 +86,7 @@ export interface Cemetery extends Record {
|
||||||
cemeteryPhoneNumber: string;
|
cemeteryPhoneNumber: string;
|
||||||
burialSiteCount?: number;
|
burialSiteCount?: number;
|
||||||
childCemeteries?: Cemetery[];
|
childCemeteries?: Cemetery[];
|
||||||
|
directionsOfArrival?: Partial<globalThis.Record<(typeof directionsOfArrival)[number], string>>;
|
||||||
}
|
}
|
||||||
export interface CommittalType extends Record {
|
export interface CommittalType extends Record {
|
||||||
committalTypeId: number;
|
committalTypeId: number;
|
||||||
|
|
@ -133,6 +135,7 @@ export interface Contract extends Record {
|
||||||
funeralTimeString?: TimeString;
|
funeralTimeString?: TimeString;
|
||||||
committalType?: string;
|
committalType?: string;
|
||||||
committalTypeId?: number;
|
committalTypeId?: number;
|
||||||
|
directionOfArrival?: string;
|
||||||
contractComments?: ContractComment[];
|
contractComments?: ContractComment[];
|
||||||
contractFees?: ContractFee[];
|
contractFees?: ContractFee[];
|
||||||
contractFields?: ContractField[];
|
contractFields?: ContractField[];
|
||||||
|
|
|
||||||
|
|
@ -1,5 +1,7 @@
|
||||||
import type { DateString, TimeString } from '@cityssm/utils-datetime'
|
import type { DateString, TimeString } from '@cityssm/utils-datetime'
|
||||||
|
|
||||||
|
import type { directionsOfArrival } from '../data/dataLists.js'
|
||||||
|
|
||||||
export interface BurialSite extends Record {
|
export interface BurialSite extends Record {
|
||||||
burialSiteId: number
|
burialSiteId: number
|
||||||
|
|
||||||
|
|
@ -118,6 +120,9 @@ export interface Cemetery extends Record {
|
||||||
|
|
||||||
burialSiteCount?: number
|
burialSiteCount?: number
|
||||||
childCemeteries?: Cemetery[]
|
childCemeteries?: Cemetery[]
|
||||||
|
directionsOfArrival?: Partial<
|
||||||
|
globalThis.Record<(typeof directionsOfArrival)[number], string>
|
||||||
|
>
|
||||||
}
|
}
|
||||||
|
|
||||||
export interface CommittalType extends Record {
|
export interface CommittalType extends Record {
|
||||||
|
|
@ -186,6 +191,8 @@ export interface Contract extends Record {
|
||||||
committalType?: string
|
committalType?: string
|
||||||
committalTypeId?: number
|
committalTypeId?: number
|
||||||
|
|
||||||
|
directionOfArrival?: string
|
||||||
|
|
||||||
contractComments?: ContractComment[]
|
contractComments?: ContractComment[]
|
||||||
contractFees?: ContractFee[]
|
contractFees?: ContractFee[]
|
||||||
contractFields?: ContractField[]
|
contractFields?: ContractField[]
|
||||||
|
|
|
||||||
|
|
@ -260,8 +260,6 @@
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
|
||||||
<div class="column">
|
|
||||||
<div class="panel">
|
<div class="panel">
|
||||||
<div class="panel-heading">
|
<div class="panel-heading">
|
||||||
<div class="level is-mobile">
|
<div class="level is-mobile">
|
||||||
|
|
@ -296,6 +294,64 @@
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
|
<div class="column">
|
||||||
|
<div class="panel">
|
||||||
|
<div class="panel-heading">
|
||||||
|
<div class="level is-mobile">
|
||||||
|
<div class="level-left">
|
||||||
|
<div class="level-item">
|
||||||
|
<h2 class="title is-5 has-text-weight-bold has-text-white">Directions of Arrival</h2>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
<div class="panel-block is-block">
|
||||||
|
<table class="table is-fullwidth is-striped is-hoverable">
|
||||||
|
<thead>
|
||||||
|
<tr>
|
||||||
|
<th class="has-width-1">
|
||||||
|
<span class="is-sr-only">Selected</span>
|
||||||
|
</th>
|
||||||
|
<th>Direction</th>
|
||||||
|
<th>Description</th>
|
||||||
|
</tr>
|
||||||
|
</thead>
|
||||||
|
<tbody>
|
||||||
|
<% for (const direction of dataLists.directionsOfArrival) { %>
|
||||||
|
<%
|
||||||
|
const directionIsSelected = cemetery.directionsOfArrival[direction] || false;
|
||||||
|
%>
|
||||||
|
<tr>
|
||||||
|
<td class="is-vcentered">
|
||||||
|
<div class="control">
|
||||||
|
<input id="cemetery--directionOfArrival_<%= direction %>" name="directionOfArrival_<%= direction %>"
|
||||||
|
type="checkbox" value="<%= direction %>"
|
||||||
|
<%= directionIsSelected ? " checked" : "" %> />
|
||||||
|
</div>
|
||||||
|
</td>
|
||||||
|
<td class="is-vcentered">
|
||||||
|
<label for="cemetery--directionOfArrival_<%= direction %>">
|
||||||
|
<span><%= direction %></span>
|
||||||
|
</label>
|
||||||
|
</td>
|
||||||
|
<td>
|
||||||
|
<div class="control">
|
||||||
|
<input class="input" id="cemetery--directionOfArrivalDescription_<%= direction %>"
|
||||||
|
name="directionOfArrivalDescription_<%= direction %>"
|
||||||
|
type="text"
|
||||||
|
value="<%= cemetery.directionsOfArrival[direction] || "" %>"
|
||||||
|
maxlength="100"
|
||||||
|
placeholder="Description"
|
||||||
|
<%= directionIsSelected ? "" : "disabled" %>
|
||||||
|
/>
|
||||||
|
</div>
|
||||||
|
</tr>
|
||||||
|
<% } %>
|
||||||
|
</tbody>
|
||||||
|
</table>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
</div>
|
</div>
|
||||||
</form>
|
</form>
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -66,29 +66,31 @@
|
||||||
<div class="panel">
|
<div class="panel">
|
||||||
<div class="panel-block is-block">
|
<div class="panel-block is-block">
|
||||||
<div class="columns">
|
<div class="columns">
|
||||||
<% if (cemetery.cemeteryDescription && cemetery.cemeteryDescription !== "") { %>
|
|
||||||
<div class="column">
|
|
||||||
<strong>Description</strong><br />
|
|
||||||
<%= cemetery.cemeteryDescription %>
|
|
||||||
</div>
|
|
||||||
<% } %>
|
|
||||||
<div class="column">
|
<div class="column">
|
||||||
<strong>Address</strong><br />
|
<% if (cemetery.cemeteryDescription && cemetery.cemeteryDescription !== "") { %>
|
||||||
<% if (cemetery.cemeteryAddress1 !== "") { %>
|
<p class="mb-2">
|
||||||
<%= cemetery.cemeteryAddress1 %><br />
|
<strong>Description</strong><br />
|
||||||
|
<%= cemetery.cemeteryDescription %>
|
||||||
|
</p>
|
||||||
<% } %>
|
<% } %>
|
||||||
<% if (cemetery.cemeteryAddress2 !== "") { %>
|
<p class="mb-2">
|
||||||
<%= cemetery.cemeteryAddress2 %><br />
|
<strong>Address</strong><br />
|
||||||
|
<% if (cemetery.cemeteryAddress1 !== "") { %>
|
||||||
|
<%= cemetery.cemeteryAddress1 %><br />
|
||||||
|
<% } %>
|
||||||
|
<% if (cemetery.cemeteryAddress2 !== "") { %>
|
||||||
|
<%= cemetery.cemeteryAddress2 %><br />
|
||||||
|
<% } %>
|
||||||
|
<%= cemetery.cemeteryCity %>, <%= cemetery.cemeteryProvince %><br />
|
||||||
|
<%= cemetery.cemeteryPostalCode %>
|
||||||
|
</p>
|
||||||
|
<% if (cemetery.cemeteryPhoneNumber !== "") { %>
|
||||||
|
<p>
|
||||||
|
<strong>Phone Number</strong><br />
|
||||||
|
<%= cemetery.cemeteryPhoneNumber %>
|
||||||
|
</p>
|
||||||
<% } %>
|
<% } %>
|
||||||
<%= cemetery.cemeteryCity %>, <%= cemetery.cemeteryProvince %><br />
|
|
||||||
<%= cemetery.cemeteryPostalCode %>
|
|
||||||
</div>
|
</div>
|
||||||
<% if (cemetery.cemeteryPhoneNumber !== "") { %>
|
|
||||||
<div class="column">
|
|
||||||
<strong>Phone Number</strong><br />
|
|
||||||
<%= cemetery.cemeteryPhoneNumber %>
|
|
||||||
</div>
|
|
||||||
<% } %>
|
|
||||||
<% if (cemetery.parentCemeteryId !== null) { %>
|
<% if (cemetery.parentCemeteryId !== null) { %>
|
||||||
<div class="column">
|
<div class="column">
|
||||||
<strong>Parent Cemetery</strong><br />
|
<strong>Parent Cemetery</strong><br />
|
||||||
|
|
|
||||||
|
|
@ -391,6 +391,30 @@
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
|
<div class="field">
|
||||||
|
<label class="label" for="contract--directionOfArrival">Direction of Arrival</label>
|
||||||
|
<div class="control">
|
||||||
|
<div class="select is-fullwidth">
|
||||||
|
<select id="contract--directionOfArrival" name="directionOfArrival">
|
||||||
|
<option value="">(No Direction)</option>
|
||||||
|
<% for (const direction of dataLists.directionsOfArrival) { %>
|
||||||
|
<%
|
||||||
|
if (burialSiteDirectionsOfArrival[direction] === undefined) {
|
||||||
|
continue
|
||||||
|
}
|
||||||
|
%>
|
||||||
|
<option value="<%= direction %>"
|
||||||
|
<%= (contract.directionOfArrival === direction ? " selected" : "") %>>
|
||||||
|
<%= direction %>
|
||||||
|
<% if (burialSiteDirectionsOfArrival[direction] !== '') { %>
|
||||||
|
- <%= burialSiteDirectionsOfArrival[direction] %>
|
||||||
|
<% } %>
|
||||||
|
</option>
|
||||||
|
<% } %>
|
||||||
|
</select>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
<div class="field">
|
<div class="field">
|
||||||
<label class="label" for="contract--committalTypeId">Committal Type</label>
|
<label class="label" for="contract--committalTypeId">Committal Type</label>
|
||||||
<div class="control">
|
<div class="control">
|
||||||
|
|
@ -997,6 +1021,7 @@
|
||||||
exports.burialSiteStatuses = <%- JSON.stringify(burialSiteStatuses) %>;
|
exports.burialSiteStatuses = <%- JSON.stringify(burialSiteStatuses) %>;
|
||||||
exports.burialSiteTypes = <%- JSON.stringify(burialSiteTypes) %>;
|
exports.burialSiteTypes = <%- JSON.stringify(burialSiteTypes) %>;
|
||||||
exports.cemeteries = <%- JSON.stringify(cemeteries) %>;
|
exports.cemeteries = <%- JSON.stringify(cemeteries) %>;
|
||||||
|
exports.directionsOfArrival = <%- JSON.stringify(dataLists.directionsOfArrival) %>;
|
||||||
</script>
|
</script>
|
||||||
|
|
||||||
<script src="<%= urlPrefix %>/javascripts/contract.edit.js"></script>
|
<script src="<%= urlPrefix %>/javascripts/contract.edit.js"></script>
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue