development
parent
5b56d14321
commit
c77a6f56ef
|
|
@ -1,4 +1,4 @@
|
|||
import { getOccupancyTypes } from "../../helpers/functions.cache.js";
|
||||
import { getLotOccupantTypes, getOccupancyTypes } from "../../helpers/functions.cache.js";
|
||||
import * as configFunctions from "../../helpers/functions.config.js";
|
||||
import { getLotOccupancy } from "../../helpers/lotOccupancyDB/getLotOccupancy.js";
|
||||
export const handler = (request, response) => {
|
||||
|
|
@ -7,10 +7,12 @@ export const handler = (request, response) => {
|
|||
return response.redirect(configFunctions.getProperty("reverseProxy.urlPrefix") + "/lotOccupancies/?error=lotOccupancyIdNotFound");
|
||||
}
|
||||
const occupancyTypes = getOccupancyTypes();
|
||||
const lotOccupantTypes = getLotOccupantTypes();
|
||||
return response.render("lotOccupancy-edit", {
|
||||
headTitle: configFunctions.getProperty("aliases.lot") + " " + configFunctions.getProperty("aliases.occupancy") + " Update",
|
||||
lotOccupancy,
|
||||
occupancyTypes,
|
||||
lotOccupantTypes,
|
||||
isCreate: false
|
||||
});
|
||||
};
|
||||
|
|
|
|||
|
|
@ -3,6 +3,7 @@ import type {
|
|||
} from "express";
|
||||
|
||||
import {
|
||||
getLotOccupantTypes,
|
||||
getOccupancyTypes
|
||||
} from "../../helpers/functions.cache.js";
|
||||
|
||||
|
|
@ -22,12 +23,14 @@ export const handler: RequestHandler = (request, response) => {
|
|||
}
|
||||
|
||||
const occupancyTypes = getOccupancyTypes();
|
||||
const lotOccupantTypes = getLotOccupantTypes();
|
||||
|
||||
return response.render("lotOccupancy-edit", {
|
||||
headTitle: configFunctions.getProperty("aliases.lot") + " " + configFunctions.getProperty("aliases.occupancy") + " Update",
|
||||
lotOccupancy,
|
||||
|
||||
occupancyTypes,
|
||||
lotOccupantTypes,
|
||||
isCreate: false
|
||||
});
|
||||
};
|
||||
|
|
|
|||
|
|
@ -24,4 +24,6 @@ export declare function getProperty(propertyName: "aliases.occupancies"): string
|
|||
export declare function getProperty(propertyName: "aliases.occupant"): string;
|
||||
export declare function getProperty(propertyName: "aliases.occupants"): string;
|
||||
export declare function getProperty(propertyName: "settings.lotOccupancy.occupancyEndDateIsRequired"): boolean;
|
||||
export declare function getProperty(propertyName: "settings.lotOccupancy.occupantCityDefault"): string;
|
||||
export declare function getProperty(propertyName: "settings.lotOccupancy.occupantProvinceDefault"): string;
|
||||
export declare const keepAliveMillis: number;
|
||||
|
|
|
|||
|
|
@ -24,6 +24,8 @@ configFallbackValues.set("aliases.occupancies", "Occupancies");
|
|||
configFallbackValues.set("aliases.occupant", "Occupant");
|
||||
configFallbackValues.set("aliases.occupants", "Occupants");
|
||||
configFallbackValues.set("settings.lotOccupancy.occupancyEndDateIsRequired", true);
|
||||
configFallbackValues.set("settings.lotOccupancy.occupantCityDefault", "");
|
||||
configFallbackValues.set("settings.lotOccupancy.occupantProvinceDefault", "");
|
||||
export function getProperty(propertyName) {
|
||||
const propertyNameSplit = propertyName.split(".");
|
||||
let currentObject = config;
|
||||
|
|
|
|||
|
|
@ -1,4 +1,5 @@
|
|||
// eslint-disable-next-line node/no-unpublished-import
|
||||
/* eslint-disable node/no-unpublished-import */
|
||||
|
||||
import {
|
||||
config
|
||||
} from "../data/config.js";
|
||||
|
|
@ -42,6 +43,8 @@ configFallbackValues.set("aliases.occupant", "Occupant");
|
|||
configFallbackValues.set("aliases.occupants", "Occupants");
|
||||
|
||||
configFallbackValues.set("settings.lotOccupancy.occupancyEndDateIsRequired", true);
|
||||
configFallbackValues.set("settings.lotOccupancy.occupantCityDefault", "");
|
||||
configFallbackValues.set("settings.lotOccupancy.occupantProvinceDefault", "");
|
||||
|
||||
|
||||
/*
|
||||
|
|
@ -79,6 +82,8 @@ export function getProperty(propertyName: "aliases.occupant"): string;
|
|||
export function getProperty(propertyName: "aliases.occupants"): string;
|
||||
|
||||
export function getProperty(propertyName: "settings.lotOccupancy.occupancyEndDateIsRequired"): boolean;
|
||||
export function getProperty(propertyName: "settings.lotOccupancy.occupantCityDefault"): string;
|
||||
export function getProperty(propertyName: "settings.lotOccupancy.occupantProvinceDefault"): string;
|
||||
|
||||
export function getProperty(propertyName: string): unknown {
|
||||
|
||||
|
|
|
|||
|
|
@ -1,11 +1,11 @@
|
|||
import { lotOccupancyDB as databasePath } from "../data/databasePaths.js";
|
||||
import { initializeDatabase } from "./initializer.database.js";
|
||||
import addLotType from "./lotOccupancyDB/addLotType.js";
|
||||
import { addLotType } from "./lotOccupancyDB/addLotType.js";
|
||||
import { addOccupancyType } from "./lotOccupancyDB/addOccupancyType.js";
|
||||
import { addOccupancyTypeField } from "./lotOccupancyDB/addOccupancyTypeField.js";
|
||||
import { addLotStatus } from "./lotOccupancyDB/addLotStatus.js";
|
||||
import { addLotOccupantType } from "./lotOccupancyDB/addLotOccupantType.js";
|
||||
import Debug from "debug";
|
||||
import addOccupancyType from "./lotOccupancyDB/addOccupancyType.js";
|
||||
import addOccupancyTypeField from "./lotOccupancyDB/addOccupancyTypeField.js";
|
||||
import addLotStatus from "./lotOccupancyDB/addLotStatus.js";
|
||||
import addLotOccupantType from "./lotOccupancyDB/addLotOccupantType.js";
|
||||
const debug = Debug("lot-occupancy-system:initialize");
|
||||
const session = {
|
||||
user: {
|
||||
|
|
|
|||
|
|
@ -6,17 +6,31 @@ import {
|
|||
initializeDatabase
|
||||
} from "./initializer.database.js";
|
||||
|
||||
import addLotType from "./lotOccupancyDB/addLotType.js";
|
||||
import {
|
||||
addLotType
|
||||
} from "./lotOccupancyDB/addLotType.js";
|
||||
|
||||
import {
|
||||
addOccupancyType
|
||||
} from "./lotOccupancyDB/addOccupancyType.js";
|
||||
|
||||
import {
|
||||
addOccupancyTypeField
|
||||
} from "./lotOccupancyDB/addOccupancyTypeField.js";
|
||||
|
||||
import {
|
||||
addLotStatus
|
||||
} from "./lotOccupancyDB/addLotStatus.js";
|
||||
|
||||
import {
|
||||
addLotOccupantType
|
||||
} from "./lotOccupancyDB/addLotOccupantType.js";
|
||||
|
||||
import type {
|
||||
PartialSession
|
||||
} from "../types/recordTypes.js";
|
||||
|
||||
import Debug from "debug";
|
||||
import addOccupancyType from "./lotOccupancyDB/addOccupancyType.js";
|
||||
import addOccupancyTypeField from "./lotOccupancyDB/addOccupancyTypeField.js";
|
||||
import addLotStatus from "./lotOccupancyDB/addLotStatus.js";
|
||||
import addLotOccupantType from "./lotOccupancyDB/addLotOccupantType.js";
|
||||
const debug = Debug("lot-occupancy-system:initialize");
|
||||
|
||||
|
||||
|
|
|
|||
|
|
@ -95,17 +95,6 @@ export const initializeDatabase = () => {
|
|||
")").run();
|
||||
lotOccupancyDB.prepare("create index if not exists idx_lotcomments_datetime" +
|
||||
" on LotComments (lotId, lotCommentDate, lotCommentTime)").run();
|
||||
lotOccupancyDB.prepare("create table if not exists Occupants (" +
|
||||
"occupantId integer not null primary key autoincrement," +
|
||||
" occupantName varchar(200) not null," +
|
||||
" occupantAddress1 varchar(50)," +
|
||||
" occupantAddress2 varchar(50)," +
|
||||
" occupantCity varchar(20)," +
|
||||
" occupantProvince varchar(2)," +
|
||||
" occupantPostalCode varchar(7)," +
|
||||
" occupantPhoneNumber varchar(30)," +
|
||||
recordColumns +
|
||||
")").run();
|
||||
lotOccupancyDB.prepare("create table if not exists OccupancyTypes (" +
|
||||
"occupancyTypeId integer not null primary key autoincrement," +
|
||||
" occupancyType varchar(100) not null," +
|
||||
|
|
@ -150,12 +139,17 @@ export const initializeDatabase = () => {
|
|||
lotOccupancyDB.prepare("create table if not exists LotOccupancyOccupants (" +
|
||||
"lotOccupancyId integer not null," +
|
||||
" lotOccupantIndex integer not null," +
|
||||
" occupantId integer not null," +
|
||||
" occupantName varchar(200) not null," +
|
||||
" occupantAddress1 varchar(50)," +
|
||||
" occupantAddress2 varchar(50)," +
|
||||
" occupantCity varchar(20)," +
|
||||
" occupantProvince varchar(2)," +
|
||||
" occupantPostalCode varchar(7)," +
|
||||
" occupantPhoneNumber varchar(30)," +
|
||||
" lotOccupantTypeId integer not null," +
|
||||
recordColumns + "," +
|
||||
" primary key (lotOccupancyId, lotOccupantIndex)," +
|
||||
" foreign key (lotOccupancyId) references LotOccupancies (lotOccupancyId)," +
|
||||
" foreign key (occupantId) references Occupants (occupantId)," +
|
||||
" foreign key (lotOccupantTypeId) references LotOccupantTypes (lotOccupantTypeId)" +
|
||||
") without rowid").run();
|
||||
lotOccupancyDB.prepare("create table if not exists LotOccupancyFields (" +
|
||||
|
|
|
|||
|
|
@ -132,18 +132,6 @@ export const initializeDatabase = (): boolean => {
|
|||
|
||||
// Occupancies
|
||||
|
||||
lotOccupancyDB.prepare("create table if not exists Occupants (" +
|
||||
"occupantId integer not null primary key autoincrement," +
|
||||
" occupantName varchar(200) not null," +
|
||||
" occupantAddress1 varchar(50)," +
|
||||
" occupantAddress2 varchar(50)," +
|
||||
" occupantCity varchar(20)," +
|
||||
" occupantProvince varchar(2)," +
|
||||
" occupantPostalCode varchar(7)," +
|
||||
" occupantPhoneNumber varchar(30)," +
|
||||
recordColumns +
|
||||
")").run();
|
||||
|
||||
lotOccupancyDB.prepare("create table if not exists OccupancyTypes (" +
|
||||
"occupancyTypeId integer not null primary key autoincrement," +
|
||||
" occupancyType varchar(100) not null," +
|
||||
|
|
@ -195,12 +183,17 @@ export const initializeDatabase = (): boolean => {
|
|||
lotOccupancyDB.prepare("create table if not exists LotOccupancyOccupants (" +
|
||||
"lotOccupancyId integer not null," +
|
||||
" lotOccupantIndex integer not null," +
|
||||
" occupantId integer not null," +
|
||||
" occupantName varchar(200) not null," +
|
||||
" occupantAddress1 varchar(50)," +
|
||||
" occupantAddress2 varchar(50)," +
|
||||
" occupantCity varchar(20)," +
|
||||
" occupantProvince varchar(2)," +
|
||||
" occupantPostalCode varchar(7)," +
|
||||
" occupantPhoneNumber varchar(30)," +
|
||||
" lotOccupantTypeId integer not null," +
|
||||
recordColumns + "," +
|
||||
" primary key (lotOccupancyId, lotOccupantIndex)," +
|
||||
" foreign key (lotOccupancyId) references LotOccupancies (lotOccupancyId)," +
|
||||
" foreign key (occupantId) references Occupants (occupantId)," +
|
||||
" foreign key (lotOccupantTypeId) references LotOccupantTypes (lotOccupantTypeId)" +
|
||||
") without rowid").run();
|
||||
|
||||
|
|
|
|||
|
|
@ -1,8 +0,0 @@
|
|||
import type * as recordTypes from "../../types/recordTypes";
|
||||
interface AddLotOccupancyFieldForm {
|
||||
lotOccupancyId: string | number;
|
||||
occupancyTypeFieldId: string | number;
|
||||
lotOccupancyFieldValue: string;
|
||||
}
|
||||
export declare const addLotOccupancyField: (lotOccupancyFieldForm: AddLotOccupancyFieldForm, requestSession: recordTypes.PartialSession) => boolean;
|
||||
export default addLotOccupancyField;
|
||||
|
|
@ -1,25 +0,0 @@
|
|||
import sqlite from "better-sqlite3";
|
||||
import { lotOccupancyDB as databasePath } from "../../data/databasePaths.js";
|
||||
export const addLotOccupancyField = (lotOccupancyFieldForm, requestSession) => {
|
||||
const database = sqlite(databasePath);
|
||||
const rightNowMillis = Date.now();
|
||||
let success = true;
|
||||
try {
|
||||
database
|
||||
.prepare("insert into LotOccupancyFields (" +
|
||||
"lotOccupancyId, occupancyTypeFieldId," +
|
||||
" lotOccupancyFieldValue," +
|
||||
" recordCreate_userName, recordCreate_timeMillis," +
|
||||
" recordUpdate_userName, recordUpdate_timeMillis)" +
|
||||
" values (?, ?, ?, ?, ?, ?, ?)")
|
||||
.run(lotOccupancyFieldForm.lotOccupancyId, lotOccupancyFieldForm.occupancyTypeFieldId, lotOccupancyFieldForm.lotOccupancyFieldValue, requestSession.user.userName, rightNowMillis, requestSession.user.userName, rightNowMillis);
|
||||
}
|
||||
catch (_a) {
|
||||
success = false;
|
||||
}
|
||||
finally {
|
||||
database.close();
|
||||
}
|
||||
return success;
|
||||
};
|
||||
export default addLotOccupancyField;
|
||||
|
|
@ -1,51 +0,0 @@
|
|||
import sqlite from "better-sqlite3";
|
||||
|
||||
import {
|
||||
lotOccupancyDB as databasePath
|
||||
} from "../../data/databasePaths.js";
|
||||
|
||||
import type * as recordTypes from "../../types/recordTypes";
|
||||
|
||||
|
||||
interface AddLotOccupancyFieldForm {
|
||||
lotOccupancyId: string | number;
|
||||
occupancyTypeFieldId: string | number;
|
||||
lotOccupancyFieldValue: string;
|
||||
}
|
||||
|
||||
|
||||
export const addLotOccupancyField =
|
||||
(lotOccupancyFieldForm: AddLotOccupancyFieldForm, requestSession: recordTypes.PartialSession): boolean => {
|
||||
|
||||
const database = sqlite(databasePath);
|
||||
|
||||
const rightNowMillis = Date.now();
|
||||
|
||||
let success = true;
|
||||
|
||||
try {
|
||||
database
|
||||
.prepare("insert into LotOccupancyFields (" +
|
||||
"lotOccupancyId, occupancyTypeFieldId," +
|
||||
" lotOccupancyFieldValue," +
|
||||
" recordCreate_userName, recordCreate_timeMillis," +
|
||||
" recordUpdate_userName, recordUpdate_timeMillis)" +
|
||||
" values (?, ?, ?, ?, ?, ?, ?)")
|
||||
.run(lotOccupancyFieldForm.lotOccupancyId,
|
||||
lotOccupancyFieldForm.occupancyTypeFieldId,
|
||||
lotOccupancyFieldForm.lotOccupancyFieldValue,
|
||||
requestSession.user.userName,
|
||||
rightNowMillis,
|
||||
requestSession.user.userName,
|
||||
rightNowMillis);
|
||||
} catch {
|
||||
success = false;
|
||||
} finally {
|
||||
database.close();
|
||||
}
|
||||
|
||||
return success;
|
||||
};
|
||||
|
||||
|
||||
export default addLotOccupancyField;
|
||||
|
|
@ -1,8 +1,14 @@
|
|||
import type * as recordTypes from "../../types/recordTypes";
|
||||
interface AddLotOccupancyOccupantForm {
|
||||
lotOccupancyId: string | number;
|
||||
occupantId: string | number;
|
||||
lotOccupantTypeId: string | number;
|
||||
occupantName: string;
|
||||
occupantAddress1: string;
|
||||
occupantAddress2: string;
|
||||
occupantCity: string;
|
||||
occupantProvince: string;
|
||||
occupantPostalCode: string;
|
||||
occupantPhoneNumber: string;
|
||||
}
|
||||
export declare const addLotOccupancyOccupant: (lotOccupancyOccupantForm: AddLotOccupancyOccupantForm, requestSession: recordTypes.PartialSession) => number;
|
||||
export default addLotOccupancyOccupant;
|
||||
|
|
|
|||
|
|
@ -16,12 +16,15 @@ export const addLotOccupancyOccupant = (lotOccupancyOccupantForm, requestSession
|
|||
database
|
||||
.prepare("insert into LotOccupancyOccupants (" +
|
||||
"lotOccupancyId, lotOccupantIndex," +
|
||||
" occupantId," +
|
||||
"occupantName," +
|
||||
" occupantAddress1, occupantAddress2," +
|
||||
" occupantCity, occupantProvince, occupantPostalCode," +
|
||||
" occupantPhoneNumber," +
|
||||
" lotOccupantTypeId," +
|
||||
" recordCreate_userName, recordCreate_timeMillis," +
|
||||
" recordUpdate_userName, recordUpdate_timeMillis)" +
|
||||
" values (?, ?, ?, ?, ?, ?, ?, ?)")
|
||||
.run(lotOccupancyOccupantForm.lotOccupancyId, lotOccupantIndex, lotOccupancyOccupantForm.occupantId, lotOccupancyOccupantForm.lotOccupantTypeId, requestSession.user.userName, rightNowMillis, requestSession.user.userName, rightNowMillis);
|
||||
" values (?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?)")
|
||||
.run(lotOccupancyOccupantForm.lotOccupancyId, lotOccupantIndex, lotOccupancyOccupantForm.occupantName, lotOccupancyOccupantForm.occupantAddress1, lotOccupancyOccupantForm.occupantAddress2, lotOccupancyOccupantForm.occupantCity, lotOccupancyOccupantForm.occupantProvince, lotOccupancyOccupantForm.occupantPostalCode, lotOccupancyOccupantForm.occupantPhoneNumber, lotOccupancyOccupantForm.lotOccupantTypeId, requestSession.user.userName, rightNowMillis, requestSession.user.userName, rightNowMillis);
|
||||
database.close();
|
||||
return lotOccupantIndex;
|
||||
};
|
||||
|
|
|
|||
|
|
@ -9,8 +9,14 @@ import type * as recordTypes from "../../types/recordTypes";
|
|||
|
||||
interface AddLotOccupancyOccupantForm {
|
||||
lotOccupancyId: string | number;
|
||||
occupantId: string | number;
|
||||
lotOccupantTypeId: string | number;
|
||||
occupantName: string;
|
||||
occupantAddress1: string;
|
||||
occupantAddress2: string;
|
||||
occupantCity: string;
|
||||
occupantProvince: string;
|
||||
occupantPostalCode: string;
|
||||
occupantPhoneNumber: string;
|
||||
}
|
||||
|
||||
|
||||
|
|
@ -37,14 +43,23 @@ export const addLotOccupancyOccupant =
|
|||
database
|
||||
.prepare("insert into LotOccupancyOccupants (" +
|
||||
"lotOccupancyId, lotOccupantIndex," +
|
||||
" occupantId," +
|
||||
"occupantName," +
|
||||
" occupantAddress1, occupantAddress2," +
|
||||
" occupantCity, occupantProvince, occupantPostalCode," +
|
||||
" occupantPhoneNumber," +
|
||||
" lotOccupantTypeId," +
|
||||
" recordCreate_userName, recordCreate_timeMillis," +
|
||||
" recordUpdate_userName, recordUpdate_timeMillis)" +
|
||||
" values (?, ?, ?, ?, ?, ?, ?, ?)")
|
||||
" values (?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?)")
|
||||
.run(lotOccupancyOccupantForm.lotOccupancyId,
|
||||
lotOccupantIndex,
|
||||
lotOccupancyOccupantForm.occupantId,
|
||||
lotOccupancyOccupantForm.occupantName,
|
||||
lotOccupancyOccupantForm.occupantAddress1,
|
||||
lotOccupancyOccupantForm.occupantAddress2,
|
||||
lotOccupancyOccupantForm.occupantCity,
|
||||
lotOccupancyOccupantForm.occupantProvince,
|
||||
lotOccupancyOccupantForm.occupantPostalCode,
|
||||
lotOccupancyOccupantForm.occupantPhoneNumber,
|
||||
lotOccupancyOccupantForm.lotOccupantTypeId,
|
||||
requestSession.user.userName,
|
||||
rightNowMillis,
|
||||
|
|
|
|||
|
|
@ -1,13 +0,0 @@
|
|||
import sqlite from "better-sqlite3";
|
||||
import type * as recordTypes from "../../types/recordTypes";
|
||||
interface AddOccupantForm {
|
||||
occupantName: string;
|
||||
occupantAddress1: string;
|
||||
occupantAddress2: string;
|
||||
occupantCity: string;
|
||||
occupantProvince: string;
|
||||
occupantPostalCode: string;
|
||||
occupantPhoneNumber: string;
|
||||
}
|
||||
export declare const addOccupant: (occupantForm: AddOccupantForm, requestSession: recordTypes.PartialSession, connectedDatabase?: sqlite.Database) => number;
|
||||
export default addOccupant;
|
||||
|
|
@ -1,19 +0,0 @@
|
|||
import sqlite from "better-sqlite3";
|
||||
import { lotOccupancyDB as databasePath } from "../../data/databasePaths.js";
|
||||
export const addOccupant = (occupantForm, requestSession, connectedDatabase) => {
|
||||
const database = connectedDatabase || sqlite(databasePath);
|
||||
const rightNowMillis = Date.now();
|
||||
const result = database
|
||||
.prepare("insert into Occupants (" +
|
||||
"occupantName," +
|
||||
" occupantAddress1, occupantAddress2, occupantCity, occupantProvince, occupantPostalCode, occupantPhoneNumber," +
|
||||
" recordCreate_userName, recordCreate_timeMillis," +
|
||||
" recordUpdate_userName, recordUpdate_timeMillis)" +
|
||||
" values (?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?)")
|
||||
.run(occupantForm.occupantName, occupantForm.occupantAddress1, occupantForm.occupantAddress2, occupantForm.occupantCity, occupantForm.occupantProvince, occupantForm.occupantPostalCode, occupantForm.occupantPhoneNumber, requestSession.user.userName, rightNowMillis, requestSession.user.userName, rightNowMillis);
|
||||
if (!connectedDatabase) {
|
||||
database.close();
|
||||
}
|
||||
return result.lastInsertRowid;
|
||||
};
|
||||
export default addOccupant;
|
||||
|
|
@ -1,54 +0,0 @@
|
|||
import sqlite from "better-sqlite3";
|
||||
import {
|
||||
lotOccupancyDB as databasePath
|
||||
} from "../../data/databasePaths.js";
|
||||
|
||||
import type * as recordTypes from "../../types/recordTypes";
|
||||
|
||||
|
||||
interface AddOccupantForm {
|
||||
occupantName: string;
|
||||
occupantAddress1: string;
|
||||
occupantAddress2: string;
|
||||
occupantCity: string;
|
||||
occupantProvince: string;
|
||||
occupantPostalCode: string;
|
||||
occupantPhoneNumber: string;
|
||||
}
|
||||
|
||||
|
||||
export const addOccupant =
|
||||
(occupantForm: AddOccupantForm, requestSession: recordTypes.PartialSession, connectedDatabase ? : sqlite.Database): number => {
|
||||
|
||||
const database = connectedDatabase || sqlite(databasePath);
|
||||
|
||||
const rightNowMillis = Date.now();
|
||||
|
||||
const result = database
|
||||
.prepare("insert into Occupants (" +
|
||||
"occupantName," +
|
||||
" occupantAddress1, occupantAddress2, occupantCity, occupantProvince, occupantPostalCode, occupantPhoneNumber," +
|
||||
" recordCreate_userName, recordCreate_timeMillis," +
|
||||
" recordUpdate_userName, recordUpdate_timeMillis)" +
|
||||
" values (?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?)")
|
||||
.run(occupantForm.occupantName,
|
||||
occupantForm.occupantAddress1,
|
||||
occupantForm.occupantAddress2,
|
||||
occupantForm.occupantCity,
|
||||
occupantForm.occupantProvince,
|
||||
occupantForm.occupantPostalCode,
|
||||
occupantForm.occupantPhoneNumber,
|
||||
requestSession.user.userName,
|
||||
rightNowMillis,
|
||||
requestSession.user.userName,
|
||||
rightNowMillis);
|
||||
|
||||
if (!connectedDatabase) {
|
||||
database.close();
|
||||
}
|
||||
|
||||
return result.lastInsertRowid as number;
|
||||
};
|
||||
|
||||
|
||||
export default addOccupant;
|
||||
|
|
@ -0,0 +1,9 @@
|
|||
import sqlite from "better-sqlite3";
|
||||
import type * as recordTypes from "../../types/recordTypes";
|
||||
interface LotOccupancyFieldForm {
|
||||
lotOccupancyId: string | number;
|
||||
occupancyTypeFieldId: string | number;
|
||||
lotOccupancyFieldValue: string;
|
||||
}
|
||||
export declare const addOrUpdateLotOccupancyField: (lotOccupancyFieldForm: LotOccupancyFieldForm, requestSession: recordTypes.PartialSession, connectedDatabase?: sqlite.Database) => boolean;
|
||||
export default addOrUpdateLotOccupancyField;
|
||||
|
|
@ -0,0 +1,31 @@
|
|||
import sqlite from "better-sqlite3";
|
||||
import { lotOccupancyDB as databasePath } from "../../data/databasePaths.js";
|
||||
export const addOrUpdateLotOccupancyField = (lotOccupancyFieldForm, requestSession, connectedDatabase) => {
|
||||
const database = connectedDatabase || sqlite(databasePath);
|
||||
const rightNowMillis = Date.now();
|
||||
let result = database
|
||||
.prepare("update LotOccupancyFields" +
|
||||
" set lotOccupancyFieldValue = ?," +
|
||||
" recordUpdate_userName = ?," +
|
||||
" recordUpdate_timeMillis = ?," +
|
||||
" recordDelete_userName = null," +
|
||||
" recordDelete_timeMillis = null" +
|
||||
" where lotOccupancyId = ?" +
|
||||
" and occupancyTypeFieldId = ?")
|
||||
.run(lotOccupancyFieldForm.lotOccupancyFieldValue, requestSession.user.userName, rightNowMillis, lotOccupancyFieldForm.lotOccupancyId, lotOccupancyFieldForm.occupancyTypeFieldId);
|
||||
if (result.changes === 0) {
|
||||
result = database
|
||||
.prepare("insert into LotOccupancyFields (" +
|
||||
"lotOccupancyId, occupancyTypeFieldId," +
|
||||
" lotOccupancyFieldValue," +
|
||||
" recordCreate_userName, recordCreate_timeMillis," +
|
||||
" recordUpdate_userName, recordUpdate_timeMillis)" +
|
||||
" values (?, ?, ?, ?, ?, ?, ?)")
|
||||
.run(lotOccupancyFieldForm.lotOccupancyId, lotOccupancyFieldForm.occupancyTypeFieldId, lotOccupancyFieldForm.lotOccupancyFieldValue, requestSession.user.userName, rightNowMillis, requestSession.user.userName, rightNowMillis);
|
||||
}
|
||||
if (!connectedDatabase) {
|
||||
database.close();
|
||||
}
|
||||
return (result.changes > 0);
|
||||
};
|
||||
export default addOrUpdateLotOccupancyField;
|
||||
|
|
@ -0,0 +1,67 @@
|
|||
import sqlite from "better-sqlite3";
|
||||
|
||||
import {
|
||||
lotOccupancyDB as databasePath
|
||||
} from "../../data/databasePaths.js";
|
||||
|
||||
import type * as recordTypes from "../../types/recordTypes";
|
||||
|
||||
|
||||
interface LotOccupancyFieldForm {
|
||||
lotOccupancyId: string | number;
|
||||
occupancyTypeFieldId: string | number;
|
||||
lotOccupancyFieldValue: string;
|
||||
}
|
||||
|
||||
|
||||
export const addOrUpdateLotOccupancyField =
|
||||
(lotOccupancyFieldForm: LotOccupancyFieldForm,
|
||||
requestSession: recordTypes.PartialSession,
|
||||
connectedDatabase?: sqlite.Database): boolean => {
|
||||
|
||||
const database = connectedDatabase || sqlite(databasePath);
|
||||
|
||||
const rightNowMillis = Date.now();
|
||||
|
||||
let result = database
|
||||
.prepare("update LotOccupancyFields" +
|
||||
" set lotOccupancyFieldValue = ?," +
|
||||
" recordUpdate_userName = ?," +
|
||||
" recordUpdate_timeMillis = ?," +
|
||||
" recordDelete_userName = null," +
|
||||
" recordDelete_timeMillis = null" +
|
||||
" where lotOccupancyId = ?" +
|
||||
" and occupancyTypeFieldId = ?")
|
||||
.run(lotOccupancyFieldForm.lotOccupancyFieldValue,
|
||||
requestSession.user.userName,
|
||||
rightNowMillis,
|
||||
lotOccupancyFieldForm.lotOccupancyId,
|
||||
lotOccupancyFieldForm.occupancyTypeFieldId);
|
||||
|
||||
if (result.changes === 0) {
|
||||
|
||||
result = database
|
||||
.prepare("insert into LotOccupancyFields (" +
|
||||
"lotOccupancyId, occupancyTypeFieldId," +
|
||||
" lotOccupancyFieldValue," +
|
||||
" recordCreate_userName, recordCreate_timeMillis," +
|
||||
" recordUpdate_userName, recordUpdate_timeMillis)" +
|
||||
" values (?, ?, ?, ?, ?, ?, ?)")
|
||||
.run(lotOccupancyFieldForm.lotOccupancyId,
|
||||
lotOccupancyFieldForm.occupancyTypeFieldId,
|
||||
lotOccupancyFieldForm.lotOccupancyFieldValue,
|
||||
requestSession.user.userName,
|
||||
rightNowMillis,
|
||||
requestSession.user.userName,
|
||||
rightNowMillis);
|
||||
}
|
||||
|
||||
if (!connectedDatabase) {
|
||||
database.close();
|
||||
}
|
||||
|
||||
return (result.changes > 0);
|
||||
};
|
||||
|
||||
|
||||
export default addOrUpdateLotOccupancyField;
|
||||
|
|
@ -0,0 +1,4 @@
|
|||
import sqlite from "better-sqlite3";
|
||||
import type * as recordTypes from "../../types/recordTypes";
|
||||
export declare const deleteLotOccupancyField: (lotOccupancyId: number | string, occupancyTypeFieldId: number | string, requestSession: recordTypes.PartialSession, connectedDatabase?: sqlite.Database) => boolean;
|
||||
export default deleteLotOccupancyField;
|
||||
|
|
@ -0,0 +1,18 @@
|
|||
import sqlite from "better-sqlite3";
|
||||
import { lotOccupancyDB as databasePath } from "../../data/databasePaths.js";
|
||||
export const deleteLotOccupancyField = (lotOccupancyId, occupancyTypeFieldId, requestSession, connectedDatabase) => {
|
||||
const database = connectedDatabase || sqlite(databasePath);
|
||||
const rightNowMillis = Date.now();
|
||||
const result = database
|
||||
.prepare("update LotOccupancyFields" +
|
||||
" set recordDelete_userName = ?," +
|
||||
" recordDelete_timeMillis = ?" +
|
||||
" where lotOccupancyId = ?" +
|
||||
" and occupancyTypeFieldId = ?")
|
||||
.run(requestSession.user.userName, rightNowMillis, lotOccupancyId, occupancyTypeFieldId);
|
||||
if (!connectedDatabase) {
|
||||
database.close();
|
||||
}
|
||||
return (result.changes > 0);
|
||||
};
|
||||
export default deleteLotOccupancyField;
|
||||
|
|
@ -0,0 +1,39 @@
|
|||
import sqlite from "better-sqlite3";
|
||||
|
||||
import {
|
||||
lotOccupancyDB as databasePath
|
||||
} from "../../data/databasePaths.js";
|
||||
|
||||
import type * as recordTypes from "../../types/recordTypes";
|
||||
|
||||
|
||||
export const deleteLotOccupancyField =
|
||||
(lotOccupancyId: number | string,
|
||||
occupancyTypeFieldId: number | string,
|
||||
requestSession: recordTypes.PartialSession,
|
||||
connectedDatabase ? : sqlite.Database): boolean => {
|
||||
|
||||
const database = connectedDatabase || sqlite(databasePath);
|
||||
|
||||
const rightNowMillis = Date.now();
|
||||
|
||||
const result = database
|
||||
.prepare("update LotOccupancyFields" +
|
||||
" set recordDelete_userName = ?," +
|
||||
" recordDelete_timeMillis = ?" +
|
||||
" where lotOccupancyId = ?" +
|
||||
" and occupancyTypeFieldId = ?")
|
||||
.run(requestSession.user.userName,
|
||||
rightNowMillis,
|
||||
lotOccupancyId,
|
||||
occupancyTypeFieldId);
|
||||
|
||||
if (!connectedDatabase) {
|
||||
database.close();
|
||||
}
|
||||
|
||||
return (result.changes > 0);
|
||||
};
|
||||
|
||||
|
||||
export default deleteLotOccupancyField;
|
||||
|
|
@ -23,7 +23,7 @@ export const getLotOccupancies = (filters, options, connectedDatabase) => {
|
|||
if (filters.occupantName) {
|
||||
const occupantNamePieces = filters.occupantName.toLowerCase().split(" ");
|
||||
for (const occupantNamePiece of occupantNamePieces) {
|
||||
sqlWhereClause += " and o.lotOccupancyId in (select oo.lotOccupancyId from LotOccupancyOccupants oo left join Occupants o on oo.occupantId = o.occupantId where oo.recordDelete_timeMillis is null and instr(lower(o.occupantName), ?))";
|
||||
sqlWhereClause += " and o.lotOccupancyId in (select oo.lotOccupancyId from LotOccupancyOccupants oo where oo.recordDelete_timeMillis is null and instr(lower(oo.occupantName), ?))";
|
||||
sqlParameters.push(occupantNamePiece);
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -66,7 +66,7 @@ export const getLotOccupancies = (filters: GetLotOccupanciesFilters,
|
|||
if (filters.occupantName) {
|
||||
const occupantNamePieces = filters.occupantName.toLowerCase().split(" ");
|
||||
for (const occupantNamePiece of occupantNamePieces) {
|
||||
sqlWhereClause += " and o.lotOccupancyId in (select oo.lotOccupancyId from LotOccupancyOccupants oo left join Occupants o on oo.occupantId = o.occupantId where oo.recordDelete_timeMillis is null and instr(lower(o.occupantName), ?))";
|
||||
sqlWhereClause += " and o.lotOccupancyId in (select oo.lotOccupancyId from LotOccupancyOccupants oo where oo.recordDelete_timeMillis is null and instr(lower(oo.occupantName), ?))";
|
||||
sqlParameters.push(occupantNamePiece);
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -23,7 +23,7 @@ export const getLotOccupancyFields = (lotOccupancyId, connectedDatabase) => {
|
|||
" from OccupancyTypeFields f" +
|
||||
" where f.recordDelete_timeMillis is null" +
|
||||
" and f.occupancyTypeId in (select occupancyTypeId from LotOccupancies where lotOccupancyId = ?)" +
|
||||
" and f.occupancyTypeFieldId not in (select occupancyTypeFieldId from LotOccupancyFields where lotOccupancyId = ?)" +
|
||||
" and f.occupancyTypeFieldId not in (select occupancyTypeFieldId from LotOccupancyFields where lotOccupancyId = ? and recordDelete_timeMillis is null)" +
|
||||
" order by orderNumber, occupancyTypeField")
|
||||
.all(lotOccupancyId, lotOccupancyId, lotOccupancyId, lotOccupancyId);
|
||||
if (!connectedDatabase) {
|
||||
|
|
|
|||
|
|
@ -33,7 +33,7 @@ export const getLotOccupancyFields = (lotOccupancyId: number | string,
|
|||
" from OccupancyTypeFields f" +
|
||||
" where f.recordDelete_timeMillis is null" +
|
||||
" and f.occupancyTypeId in (select occupancyTypeId from LotOccupancies where lotOccupancyId = ?)" +
|
||||
" and f.occupancyTypeFieldId not in (select occupancyTypeFieldId from LotOccupancyFields where lotOccupancyId = ?)" +
|
||||
" and f.occupancyTypeFieldId not in (select occupancyTypeFieldId from LotOccupancyFields where lotOccupancyId = ? and recordDelete_timeMillis is null)" +
|
||||
" order by orderNumber, occupancyTypeField")
|
||||
.all(lotOccupancyId, lotOccupancyId, lotOccupancyId, lotOccupancyId);
|
||||
|
||||
|
|
|
|||
|
|
@ -6,16 +6,14 @@ export const getLotOccupancyOccupants = (lotOccupancyId, connectedDatabase) => {
|
|||
});
|
||||
const lotOccupancyOccupants = database
|
||||
.prepare("select o.lotOccupancyId, o.lotOccupantIndex," +
|
||||
" o.occupantId," +
|
||||
" n.occupantName, n.occupantAddress1, n.occupantAddress2," +
|
||||
" n.occupantCity, n.occupantProvince, n.occupantPostalCode, n.occupantPhoneNumber," +
|
||||
" o.occupantName, o.occupantAddress1, o.occupantAddress2," +
|
||||
" o.occupantCity, o.occupantProvince, o.occupantPostalCode, o.occupantPhoneNumber," +
|
||||
" o.lotOccupantTypeId, t.lotOccupantType" +
|
||||
" from LotOccupancyOccupants o" +
|
||||
" left join Occupants n on o.occupantId = n.occupantId" +
|
||||
" left join LotOccupantTypes t on o.lotOccupantTypeId = t.lotOccupantTypeId" +
|
||||
" where o.recordDelete_timeMillis is null" +
|
||||
" and o.lotOccupancyId = ?" +
|
||||
" order by t.orderNumber, t.lotOccupantType, n.occupantName, o.lotOccupantIndex")
|
||||
" order by t.orderNumber, t.lotOccupantType, o.occupantName, o.lotOccupantIndex")
|
||||
.all(lotOccupancyId);
|
||||
if (!connectedDatabase) {
|
||||
database.close();
|
||||
|
|
|
|||
|
|
@ -16,16 +16,14 @@ export const getLotOccupancyOccupants = (lotOccupancyId: number | string,
|
|||
|
||||
const lotOccupancyOccupants: recordTypes.LotOccupancyOccupant[] = database
|
||||
.prepare("select o.lotOccupancyId, o.lotOccupantIndex," +
|
||||
" o.occupantId," +
|
||||
" n.occupantName, n.occupantAddress1, n.occupantAddress2," +
|
||||
" n.occupantCity, n.occupantProvince, n.occupantPostalCode, n.occupantPhoneNumber," +
|
||||
" o.occupantName, o.occupantAddress1, o.occupantAddress2," +
|
||||
" o.occupantCity, o.occupantProvince, o.occupantPostalCode, o.occupantPhoneNumber," +
|
||||
" o.lotOccupantTypeId, t.lotOccupantType" +
|
||||
" from LotOccupancyOccupants o" +
|
||||
" left join Occupants n on o.occupantId = n.occupantId" +
|
||||
" left join LotOccupantTypes t on o.lotOccupantTypeId = t.lotOccupantTypeId" +
|
||||
" where o.recordDelete_timeMillis is null" +
|
||||
" and o.lotOccupancyId = ?" +
|
||||
" order by t.orderNumber, t.lotOccupantType, n.occupantName, o.lotOccupantIndex")
|
||||
" order by t.orderNumber, t.lotOccupantType, o.occupantName, o.lotOccupantIndex")
|
||||
.all(lotOccupancyId);
|
||||
|
||||
if (!connectedDatabase) {
|
||||
|
|
|
|||
|
|
@ -5,7 +5,8 @@ export const getLotOccupantTypes = () => {
|
|||
readonly: true
|
||||
});
|
||||
const lotOccupantTypes = database
|
||||
.prepare("select * from LotOccupantTypes" +
|
||||
.prepare("select lotOccupantTypeId, lotOccupantType" +
|
||||
" from LotOccupantTypes" +
|
||||
" where recordDelete_timeMillis is null" +
|
||||
" order by orderNumber, lotOccupantType")
|
||||
.all();
|
||||
|
|
|
|||
|
|
@ -1,5 +1,8 @@
|
|||
import sqlite from "better-sqlite3";
|
||||
import { lotOccupancyDB as databasePath } from "../../data/databasePaths.js";
|
||||
|
||||
import {
|
||||
lotOccupancyDB as databasePath
|
||||
} from "../../data/databasePaths.js";
|
||||
|
||||
import type * as recordTypes from "../../types/recordTypes";
|
||||
|
||||
|
|
@ -11,7 +14,8 @@ export const getLotOccupantTypes = (): recordTypes.LotOccupantType[] => {
|
|||
});
|
||||
|
||||
const lotOccupantTypes: recordTypes.LotOccupantType[] = database
|
||||
.prepare("select * from LotOccupantTypes" +
|
||||
.prepare("select lotOccupantTypeId, lotOccupantType" +
|
||||
" from LotOccupantTypes" +
|
||||
" where recordDelete_timeMillis is null" +
|
||||
" order by orderNumber, lotOccupantType")
|
||||
.all();
|
||||
|
|
|
|||
|
|
@ -5,7 +5,8 @@ export const getLotStatuses = () => {
|
|||
readonly: true
|
||||
});
|
||||
const lotStatuses = database
|
||||
.prepare("select * from LotStatuses" +
|
||||
.prepare("select lotStatusId, lotStatus" +
|
||||
" from LotStatuses" +
|
||||
" where recordDelete_timeMillis is null" +
|
||||
" order by orderNumber, lotStatus")
|
||||
.all();
|
||||
|
|
|
|||
|
|
@ -11,7 +11,8 @@ export const getLotStatuses = (): recordTypes.LotStatus[] => {
|
|||
});
|
||||
|
||||
const lotStatuses: recordTypes.LotStatus[] = database
|
||||
.prepare("select * from LotStatuses" +
|
||||
.prepare("select lotStatusId, lotStatus" +
|
||||
" from LotStatuses" +
|
||||
" where recordDelete_timeMillis is null" +
|
||||
" order by orderNumber, lotStatus")
|
||||
.all();
|
||||
|
|
|
|||
|
|
@ -5,7 +5,8 @@ export const getLotTypes = () => {
|
|||
readonly: true
|
||||
});
|
||||
const lotTypes = database
|
||||
.prepare("select * from LotTypes" +
|
||||
.prepare("select lotTypeId, lotType" +
|
||||
" from LotTypes" +
|
||||
" where recordDelete_timeMillis is null" +
|
||||
" order by orderNumber, lotType")
|
||||
.all();
|
||||
|
|
|
|||
|
|
@ -1,5 +1,8 @@
|
|||
import sqlite from "better-sqlite3";
|
||||
import { lotOccupancyDB as databasePath } from "../../data/databasePaths.js";
|
||||
|
||||
import {
|
||||
lotOccupancyDB as databasePath
|
||||
} from "../../data/databasePaths.js";
|
||||
|
||||
import type * as recordTypes from "../../types/recordTypes";
|
||||
|
||||
|
|
@ -11,7 +14,8 @@ export const getLotTypes = (): recordTypes.LotType[] => {
|
|||
});
|
||||
|
||||
const lotTypes: recordTypes.LotType[] = database
|
||||
.prepare("select * from LotTypes" +
|
||||
.prepare("select lotTypeId, lotType" +
|
||||
" from LotTypes" +
|
||||
" where recordDelete_timeMillis is null" +
|
||||
" order by orderNumber, lotType")
|
||||
.all();
|
||||
|
|
|
|||
|
|
@ -5,7 +5,8 @@ export const getOccupancyType = (occupancyTypeId) => {
|
|||
readonly: true
|
||||
});
|
||||
const occupancyType = database
|
||||
.prepare("select * from OccupancyTypes" +
|
||||
.prepare("select occupancyTypeId, occupancyType" +
|
||||
" from OccupancyTypes" +
|
||||
" where occupancyTypeId = ?")
|
||||
.get(occupancyTypeId);
|
||||
if (occupancyType) {
|
||||
|
|
|
|||
|
|
@ -1,5 +1,8 @@
|
|||
import sqlite from "better-sqlite3";
|
||||
import { lotOccupancyDB as databasePath } from "../../data/databasePaths.js";
|
||||
|
||||
import {
|
||||
lotOccupancyDB as databasePath
|
||||
} from "../../data/databasePaths.js";
|
||||
|
||||
import type * as recordTypes from "../../types/recordTypes";
|
||||
|
||||
|
|
@ -11,7 +14,8 @@ export const getOccupancyType = (occupancyTypeId: number | string): recordTypes.
|
|||
});
|
||||
|
||||
const occupancyType: recordTypes.OccupancyType = database
|
||||
.prepare("select * from OccupancyTypes" +
|
||||
.prepare("select occupancyTypeId, occupancyType" +
|
||||
" from OccupancyTypes" +
|
||||
" where occupancyTypeId = ?")
|
||||
.get(occupancyTypeId);
|
||||
|
||||
|
|
|
|||
|
|
@ -5,7 +5,8 @@ export const getOccupancyTypes = () => {
|
|||
readonly: true
|
||||
});
|
||||
const occupancyTypes = database
|
||||
.prepare("select * from OccupancyTypes" +
|
||||
.prepare("select occupancyTypeId, occupancyType" +
|
||||
" from OccupancyTypes" +
|
||||
" where recordDelete_timeMillis is null" +
|
||||
" order by orderNumber, occupancyType")
|
||||
.all();
|
||||
|
|
|
|||
|
|
@ -1,5 +1,8 @@
|
|||
import sqlite from "better-sqlite3";
|
||||
import { lotOccupancyDB as databasePath } from "../../data/databasePaths.js";
|
||||
|
||||
import {
|
||||
lotOccupancyDB as databasePath
|
||||
} from "../../data/databasePaths.js";
|
||||
|
||||
import type * as recordTypes from "../../types/recordTypes";
|
||||
|
||||
|
|
@ -11,7 +14,8 @@ export const getOccupancyTypes = (): recordTypes.OccupancyType[] => {
|
|||
});
|
||||
|
||||
const occupancyTypes: recordTypes.OccupancyType[] = database
|
||||
.prepare("select * from OccupancyTypes" +
|
||||
.prepare("select occupancyTypeId, occupancyType" +
|
||||
" from OccupancyTypes" +
|
||||
" where recordDelete_timeMillis is null" +
|
||||
" order by orderNumber, occupancyType")
|
||||
.all();
|
||||
|
|
|
|||
|
|
@ -1,10 +0,0 @@
|
|||
import type * as recordTypes from "../../types/recordTypes";
|
||||
interface GetOccupantsFilters {
|
||||
occupantName?: string;
|
||||
occupantAddress?: string;
|
||||
occupantCity?: string;
|
||||
occupantPostalCode?: string;
|
||||
occupantPhoneNumber?: string;
|
||||
}
|
||||
export declare const getOccupants: (filters?: GetOccupantsFilters) => recordTypes.Occupant[];
|
||||
export default getOccupants;
|
||||
|
|
@ -1,56 +0,0 @@
|
|||
import sqlite from "better-sqlite3";
|
||||
import { lotOccupancyDB as databasePath } from "../../data/databasePaths.js";
|
||||
export const getOccupants = (filters) => {
|
||||
const database = sqlite(databasePath, {
|
||||
readonly: true
|
||||
});
|
||||
let sqlWhereClause = "";
|
||||
const sqlParameters = [];
|
||||
if (filters.occupantName) {
|
||||
const occupantNamePieces = filters.occupantName.toLowerCase().split(" ");
|
||||
for (const occupantNamePiece of occupantNamePieces) {
|
||||
sqlWhereClause += " and instr(lower(occupantName), ?)";
|
||||
sqlParameters.push(occupantNamePiece);
|
||||
}
|
||||
}
|
||||
if (filters.occupantAddress) {
|
||||
const occupantAddressPieces = filters.occupantAddress.toLowerCase().split(" ");
|
||||
for (const occupantAddressPiece of occupantAddressPieces) {
|
||||
sqlWhereClause += " and (instr(lower(occupantAddress1), ?) or instr(lower(occupantAddress2), ?))";
|
||||
sqlParameters.push(occupantAddressPiece, occupantAddressPiece);
|
||||
}
|
||||
}
|
||||
if (filters.occupantCity) {
|
||||
const occupantCityPieces = filters.occupantCity.toLowerCase().split(" ");
|
||||
for (const occupantCityPiece of occupantCityPieces) {
|
||||
sqlWhereClause += " and instr(lower(occupantCity), ?)";
|
||||
sqlParameters.push(occupantCityPiece);
|
||||
}
|
||||
}
|
||||
if (filters.occupantPostalCode) {
|
||||
const occupantPostalCodePieces = filters.occupantPostalCode.toLowerCase().split(" ");
|
||||
for (const occupantPostalCodePiece of occupantPostalCodePieces) {
|
||||
sqlWhereClause += " and instr(lower(occupantPostalCode), ?)";
|
||||
sqlParameters.push(occupantPostalCodePiece);
|
||||
}
|
||||
}
|
||||
if (filters.occupantPhoneNumber) {
|
||||
const occupantPhoneNumberPieces = filters.occupantPhoneNumber.toLowerCase().split(" ");
|
||||
for (const occupantPhoneNumberPiece of occupantPhoneNumberPieces) {
|
||||
sqlWhereClause += " and instr(lower(occupantPhoneNumber), ?)";
|
||||
sqlParameters.push(occupantPhoneNumberPiece);
|
||||
}
|
||||
}
|
||||
const occupants = database
|
||||
.prepare("select occupantId, occupantName," +
|
||||
" occupantAddress1, occupantAddress2, occupantCity, occupantProvince, occupantPostalCode," +
|
||||
" occupantPhoneNumber" +
|
||||
" from Occupants" +
|
||||
" where recordDelete_timeMillis is null" +
|
||||
sqlWhereClause +
|
||||
" order by occupantName, occupantAddress1")
|
||||
.all(sqlParameters);
|
||||
database.close();
|
||||
return occupants;
|
||||
};
|
||||
export default getOccupants;
|
||||
|
|
@ -1,93 +0,0 @@
|
|||
import sqlite from "better-sqlite3";
|
||||
import {
|
||||
lotOccupancyDB as databasePath
|
||||
} from "../../data/databasePaths.js";
|
||||
|
||||
import type * as recordTypes from "../../types/recordTypes";
|
||||
|
||||
|
||||
interface GetOccupantsFilters {
|
||||
occupantName?: string;
|
||||
occupantAddress?: string;
|
||||
occupantCity?: string;
|
||||
occupantPostalCode?: string;
|
||||
occupantPhoneNumber?: string;
|
||||
}
|
||||
|
||||
|
||||
export const getOccupants = (filters ? : GetOccupantsFilters): recordTypes.Occupant[] => {
|
||||
|
||||
const database = sqlite(databasePath, {
|
||||
readonly: true
|
||||
});
|
||||
|
||||
let sqlWhereClause = "";
|
||||
const sqlParameters = [];
|
||||
|
||||
if (filters.occupantName) {
|
||||
|
||||
const occupantNamePieces = filters.occupantName.toLowerCase().split(" ");
|
||||
|
||||
for (const occupantNamePiece of occupantNamePieces) {
|
||||
sqlWhereClause += " and instr(lower(occupantName), ?)";
|
||||
sqlParameters.push(occupantNamePiece);
|
||||
}
|
||||
}
|
||||
|
||||
if (filters.occupantAddress) {
|
||||
|
||||
const occupantAddressPieces = filters.occupantAddress.toLowerCase().split(" ");
|
||||
|
||||
for (const occupantAddressPiece of occupantAddressPieces) {
|
||||
sqlWhereClause += " and (instr(lower(occupantAddress1), ?) or instr(lower(occupantAddress2), ?))";
|
||||
sqlParameters.push(occupantAddressPiece, occupantAddressPiece);
|
||||
}
|
||||
}
|
||||
|
||||
if (filters.occupantCity) {
|
||||
|
||||
const occupantCityPieces = filters.occupantCity.toLowerCase().split(" ");
|
||||
|
||||
for (const occupantCityPiece of occupantCityPieces) {
|
||||
sqlWhereClause += " and instr(lower(occupantCity), ?)";
|
||||
sqlParameters.push(occupantCityPiece);
|
||||
}
|
||||
}
|
||||
|
||||
if (filters.occupantPostalCode) {
|
||||
|
||||
const occupantPostalCodePieces = filters.occupantPostalCode.toLowerCase().split(" ");
|
||||
|
||||
for (const occupantPostalCodePiece of occupantPostalCodePieces) {
|
||||
sqlWhereClause += " and instr(lower(occupantPostalCode), ?)";
|
||||
sqlParameters.push(occupantPostalCodePiece);
|
||||
}
|
||||
}
|
||||
|
||||
if (filters.occupantPhoneNumber) {
|
||||
|
||||
const occupantPhoneNumberPieces = filters.occupantPhoneNumber.toLowerCase().split(" ");
|
||||
|
||||
for (const occupantPhoneNumberPiece of occupantPhoneNumberPieces) {
|
||||
sqlWhereClause += " and instr(lower(occupantPhoneNumber), ?)";
|
||||
sqlParameters.push(occupantPhoneNumberPiece);
|
||||
}
|
||||
}
|
||||
|
||||
const occupants: recordTypes.Occupant[] = database
|
||||
.prepare("select occupantId, occupantName," +
|
||||
" occupantAddress1, occupantAddress2, occupantCity, occupantProvince, occupantPostalCode," +
|
||||
" occupantPhoneNumber" +
|
||||
" from Occupants" +
|
||||
" where recordDelete_timeMillis is null" +
|
||||
sqlWhereClause +
|
||||
" order by occupantName, occupantAddress1")
|
||||
.all(sqlParameters);
|
||||
|
||||
database.close();
|
||||
|
||||
return occupants;
|
||||
};
|
||||
|
||||
|
||||
export default getOccupants;
|
||||
|
|
@ -5,6 +5,8 @@ interface UpdateLotOccupancyForm {
|
|||
lotId: string | number;
|
||||
occupancyStartDateString: string;
|
||||
occupancyEndDateString: string;
|
||||
occupancyTypeFieldIds: string;
|
||||
[lotOccupancyFieldValue_occupancyTypeFieldId: string]: unknown;
|
||||
}
|
||||
export declare function updateLotOccupancy(lotOccupancyForm: UpdateLotOccupancyForm, requestSession: recordTypes.PartialSession): boolean;
|
||||
export default updateLotOccupancy;
|
||||
|
|
|
|||
|
|
@ -1,6 +1,8 @@
|
|||
import { dateStringToInteger } from "@cityssm/expressjs-server-js/dateTimeFns.js";
|
||||
import sqlite from "better-sqlite3";
|
||||
import { lotOccupancyDB as databasePath } from "../../data/databasePaths.js";
|
||||
import { addOrUpdateLotOccupancyField } from "./addOrUpdateLotOccupancyField.js";
|
||||
import { deleteLotOccupancyField } from "./deleteLotOccupancyField.js";
|
||||
export function updateLotOccupancy(lotOccupancyForm, requestSession) {
|
||||
const database = sqlite(databasePath);
|
||||
const rightNowMillis = Date.now();
|
||||
|
|
@ -15,6 +17,22 @@ export function updateLotOccupancy(lotOccupancyForm, requestSession) {
|
|||
" where lotOccupancyId = ?" +
|
||||
" and recordDelete_timeMillis is null")
|
||||
.run(lotOccupancyForm.occupancyTypeId, (lotOccupancyForm.lotId === "" ? undefined : lotOccupancyForm.lotId), dateStringToInteger(lotOccupancyForm.occupancyStartDateString), (lotOccupancyForm.occupancyEndDateString === "" ? undefined : dateStringToInteger(lotOccupancyForm.occupancyEndDateString)), requestSession.user.userName, rightNowMillis, lotOccupancyForm.lotOccupancyId);
|
||||
if (result.changes > 0) {
|
||||
const occupancyTypeFieldIds = lotOccupancyForm.occupancyTypeFieldIds.split(",");
|
||||
for (const occupancyTypeFieldId of occupancyTypeFieldIds) {
|
||||
const lotOccupancyFieldValue = lotOccupancyForm["lotOccupancyFieldValue_" + occupancyTypeFieldId];
|
||||
if (lotOccupancyFieldValue && lotOccupancyFieldValue !== "") {
|
||||
addOrUpdateLotOccupancyField({
|
||||
lotOccupancyId: lotOccupancyForm.lotOccupancyId,
|
||||
occupancyTypeFieldId,
|
||||
lotOccupancyFieldValue
|
||||
}, requestSession, database);
|
||||
}
|
||||
else {
|
||||
deleteLotOccupancyField(lotOccupancyForm.lotOccupancyId, occupancyTypeFieldId, requestSession, database);
|
||||
}
|
||||
}
|
||||
}
|
||||
database.close();
|
||||
return result.changes > 0;
|
||||
}
|
||||
|
|
|
|||
|
|
@ -1,10 +1,22 @@
|
|||
import { dateStringToInteger } from "@cityssm/expressjs-server-js/dateTimeFns.js";
|
||||
import {
|
||||
dateStringToInteger
|
||||
} from "@cityssm/expressjs-server-js/dateTimeFns.js";
|
||||
|
||||
import sqlite from "better-sqlite3";
|
||||
import { lotOccupancyDB as databasePath } from "../../data/databasePaths.js";
|
||||
|
||||
import {
|
||||
lotOccupancyDB as databasePath
|
||||
} from "../../data/databasePaths.js";
|
||||
|
||||
import {
|
||||
addOrUpdateLotOccupancyField
|
||||
} from "./addOrUpdateLotOccupancyField.js";
|
||||
import {
|
||||
deleteLotOccupancyField
|
||||
} from "./deleteLotOccupancyField.js";
|
||||
|
||||
import type * as recordTypes from "../../types/recordTypes";
|
||||
|
||||
|
||||
interface UpdateLotOccupancyForm {
|
||||
lotOccupancyId: string | number;
|
||||
occupancyTypeId: string | number;
|
||||
|
|
@ -12,6 +24,9 @@ interface UpdateLotOccupancyForm {
|
|||
|
||||
occupancyStartDateString: string;
|
||||
occupancyEndDateString: string;
|
||||
|
||||
occupancyTypeFieldIds: string;
|
||||
[lotOccupancyFieldValue_occupancyTypeFieldId: string]: unknown;
|
||||
}
|
||||
|
||||
|
||||
|
|
@ -39,6 +54,29 @@ export function updateLotOccupancy(lotOccupancyForm: UpdateLotOccupancyForm, req
|
|||
rightNowMillis,
|
||||
lotOccupancyForm.lotOccupancyId);
|
||||
|
||||
if (result.changes > 0) {
|
||||
|
||||
const occupancyTypeFieldIds = lotOccupancyForm.occupancyTypeFieldIds.split(",");
|
||||
|
||||
for (const occupancyTypeFieldId of occupancyTypeFieldIds) {
|
||||
|
||||
const lotOccupancyFieldValue = lotOccupancyForm["lotOccupancyFieldValue_" + occupancyTypeFieldId] as string;
|
||||
|
||||
if (lotOccupancyFieldValue && lotOccupancyFieldValue !== "") {
|
||||
addOrUpdateLotOccupancyField({
|
||||
lotOccupancyId: lotOccupancyForm.lotOccupancyId,
|
||||
occupancyTypeFieldId,
|
||||
lotOccupancyFieldValue
|
||||
}, requestSession, database);
|
||||
} else {
|
||||
deleteLotOccupancyField(lotOccupancyForm.lotOccupancyId,
|
||||
occupancyTypeFieldId,
|
||||
requestSession,
|
||||
database);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
database.close();
|
||||
|
||||
return result.changes > 0;
|
||||
|
|
|
|||
|
|
@ -1,5 +1,8 @@
|
|||
import sqlite from "better-sqlite3";
|
||||
import { lotOccupancyDB as databasePath } from "../../data/databasePaths.js";
|
||||
|
||||
import {
|
||||
lotOccupancyDB as databasePath
|
||||
} from "../../data/databasePaths.js";
|
||||
|
||||
import type * as recordTypes from "../../types/recordTypes";
|
||||
|
||||
|
|
|
|||
|
|
@ -67,7 +67,7 @@
|
|||
"gulp-sass": "^5.1.0",
|
||||
"nodemon": "^2.0.19",
|
||||
"papaparse": "^5.3.2",
|
||||
"sass": "^1.54.3"
|
||||
"sass": "^1.54.4"
|
||||
},
|
||||
"engines": {
|
||||
"node": "^12.20.0 || ^14.13.1 || >=16.0.0"
|
||||
|
|
@ -8601,9 +8601,9 @@
|
|||
"integrity": "sha512-YZo3K82SD7Riyi0E1EQPojLz7kpepnSQI9IyPbHHg1XXXevb5dJI7tpyN2ADxGcQbHG7vcyRHk0cbwqcQriUtg=="
|
||||
},
|
||||
"node_modules/sass": {
|
||||
"version": "1.54.3",
|
||||
"resolved": "https://registry.npmjs.org/sass/-/sass-1.54.3.tgz",
|
||||
"integrity": "sha512-fLodey5Qd41Pxp/Tk7Al97sViYwF/TazRc5t6E65O7JOk4XF8pzwIW7CvCxYVOfJFFI/1x5+elDyBIixrp+zrw==",
|
||||
"version": "1.54.4",
|
||||
"resolved": "https://registry.npmjs.org/sass/-/sass-1.54.4.tgz",
|
||||
"integrity": "sha512-3tmF16yvnBwtlPrNBHw/H907j8MlOX8aTBnlNX1yrKx24RKcJGPyLhFUwkoKBKesR3unP93/2z14Ll8NicwQUA==",
|
||||
"dev": true,
|
||||
"dependencies": {
|
||||
"chokidar": ">=3.0.0 <4.0.0",
|
||||
|
|
@ -17340,9 +17340,9 @@
|
|||
"integrity": "sha512-YZo3K82SD7Riyi0E1EQPojLz7kpepnSQI9IyPbHHg1XXXevb5dJI7tpyN2ADxGcQbHG7vcyRHk0cbwqcQriUtg=="
|
||||
},
|
||||
"sass": {
|
||||
"version": "1.54.3",
|
||||
"resolved": "https://registry.npmjs.org/sass/-/sass-1.54.3.tgz",
|
||||
"integrity": "sha512-fLodey5Qd41Pxp/Tk7Al97sViYwF/TazRc5t6E65O7JOk4XF8pzwIW7CvCxYVOfJFFI/1x5+elDyBIixrp+zrw==",
|
||||
"version": "1.54.4",
|
||||
"resolved": "https://registry.npmjs.org/sass/-/sass-1.54.4.tgz",
|
||||
"integrity": "sha512-3tmF16yvnBwtlPrNBHw/H907j8MlOX8aTBnlNX1yrKx24RKcJGPyLhFUwkoKBKesR3unP93/2z14Ll8NicwQUA==",
|
||||
"dev": true,
|
||||
"requires": {
|
||||
"chokidar": ">=3.0.0 <4.0.0",
|
||||
|
|
|
|||
|
|
@ -88,6 +88,6 @@
|
|||
"gulp-sass": "^5.1.0",
|
||||
"nodemon": "^2.0.19",
|
||||
"papaparse": "^5.3.2",
|
||||
"sass": "^1.54.3"
|
||||
"sass": "^1.54.4"
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -156,4 +156,63 @@ Object.defineProperty(exports, "__esModule", { value: true });
|
|||
document.querySelector("#lotOccupancy--occupancyStartDateString").value;
|
||||
});
|
||||
los.initializeUnlockFieldButtons(formElement);
|
||||
if (!isCreate) {
|
||||
let lotOccupancyOccupants = exports.lotOccupancyOccupants;
|
||||
const renderLotOccupancyOccupants = () => {
|
||||
const occupantsContainer = document.querySelector("#container--lotOccupancyOccupants");
|
||||
cityssm.clearElement(occupantsContainer);
|
||||
if (lotOccupancyOccupants.length === 0) {
|
||||
occupantsContainer.innerHTML = "<div class=\"message is-warning\">" +
|
||||
"<p class=\"message-body\">There are no " + exports.aliases.occupants.toLowerCase() + " associated with this record.</p>" +
|
||||
"</div>";
|
||||
return;
|
||||
}
|
||||
const tableElement = document.createElement("table");
|
||||
tableElement.className = "table is-fullwidth is-striped is-hoverable";
|
||||
tableElement.innerHTML = "<thead><tr>" +
|
||||
"<th>" + exports.aliases.occupant + " Type</th>" +
|
||||
"<th>" + exports.aliases.occupant + "</th>" +
|
||||
"<th>Address</th>" +
|
||||
"<th>Phone Number</th>" +
|
||||
"<th></th>" +
|
||||
"</tr></thead>" +
|
||||
"<tbody></tbody>";
|
||||
for (const lotOccupancyOccupant of lotOccupancyOccupants) {
|
||||
const tableRowElement = document.createElement("tr");
|
||||
tableRowElement.dataset.lotOccupantIndex = lotOccupancyOccupant.lotOccupantIndex.toString();
|
||||
tableRowElement.innerHTML = ("<td>" + cityssm.escapeHTML(lotOccupancyOccupant.lotOccupantType) + "</td>") +
|
||||
("<td>" + cityssm.escapeHTML(lotOccupancyOccupant.occupantName) + "</td>") +
|
||||
("<td>" +
|
||||
cityssm.escapeHTML(lotOccupancyOccupant.occupantAddress1) + "<br />" +
|
||||
(lotOccupancyOccupant.occupantAddress2 ? cityssm.escapeHTML(lotOccupancyOccupant.occupantAddress2) + "<br />" : "") +
|
||||
cityssm.escapeHTML(lotOccupancyOccupant.occupantCity) + ", " + cityssm.escapeHTML(lotOccupancyOccupant.occupantProvince) + "<br />" +
|
||||
cityssm.escapeHTML(lotOccupancyOccupant.occupantPostalCode) +
|
||||
"</td>") +
|
||||
("<td>" + cityssm.escapeHTML(lotOccupancyOccupant.occupantPhoneNumber) + "</td>") +
|
||||
("<td>" +
|
||||
"<div class=\"buttons are-small is-justify-content-end\">" +
|
||||
("<button class=\"button is-primary button--edit\" type=\"button\">" +
|
||||
"<span class=\"icon is-small\"><i class=\"fas fa-pencil-alt\" aria-hidden=\"true\"></i></span>" +
|
||||
" <span>Edit</span>" +
|
||||
"</button>") +
|
||||
("<button class=\"button is-light is-danger button--delete\" type=\"button\" aria-label=\"Delete\">" +
|
||||
"<i class=\"fas fa-trash\" aria-hidden=\"true\"></i>" +
|
||||
"</button>") +
|
||||
"</div>" +
|
||||
"</td>");
|
||||
tableElement.querySelector("tbody").append(tableRowElement);
|
||||
}
|
||||
occupantsContainer.append(tableElement);
|
||||
};
|
||||
document.querySelector("#button--addOccupant").addEventListener("click", () => {
|
||||
cityssm.openHtmlModal("lotOccupancy-addOccupant", {
|
||||
onshow: (modalElement) => {
|
||||
los.populateAliases(modalElement);
|
||||
modalElement.querySelector("#lotOccupancyOccupantAdd--occupantCity").value = exports.occupantCityDefault;
|
||||
modalElement.querySelector("#lotOccupancyOccupantAdd--occupantProvince").value = exports.occupantProvinceDefault;
|
||||
}
|
||||
});
|
||||
});
|
||||
renderLotOccupancyOccupants();
|
||||
}
|
||||
})();
|
||||
|
|
|
|||
|
|
@ -24,7 +24,9 @@ declare const bulmaJS: BulmaJS;
|
|||
const lotOccupancyId = (document.querySelector("#lotOccupancy--lotOccupancyId") as HTMLInputElement).value;
|
||||
const isCreate = (lotOccupancyId === "");
|
||||
|
||||
// Main form
|
||||
/*
|
||||
* Main form
|
||||
*/
|
||||
|
||||
let hasUnsavedChanges = false;
|
||||
let refreshAfterSave = isCreate;
|
||||
|
|
@ -239,4 +241,96 @@ declare const bulmaJS: BulmaJS;
|
|||
});
|
||||
|
||||
los.initializeUnlockFieldButtons(formElement);
|
||||
|
||||
/*
|
||||
* Occupants
|
||||
*/
|
||||
|
||||
if (!isCreate) {
|
||||
let lotOccupancyOccupants: recordTypes.LotOccupancyOccupant[] = exports.lotOccupancyOccupants;
|
||||
|
||||
const renderLotOccupancyOccupants = () => {
|
||||
|
||||
const occupantsContainer = document.querySelector("#container--lotOccupancyOccupants") as HTMLElement;
|
||||
|
||||
cityssm.clearElement(occupantsContainer);
|
||||
|
||||
if (lotOccupancyOccupants.length === 0) {
|
||||
occupantsContainer.innerHTML = "<div class=\"message is-warning\">" +
|
||||
"<p class=\"message-body\">There are no " + exports.aliases.occupants.toLowerCase() + " associated with this record.</p>" +
|
||||
"</div>";
|
||||
|
||||
return;
|
||||
}
|
||||
|
||||
const tableElement = document.createElement("table");
|
||||
tableElement.className = "table is-fullwidth is-striped is-hoverable";
|
||||
|
||||
tableElement.innerHTML = "<thead><tr>" +
|
||||
"<th>" + exports.aliases.occupant + " Type</th>" +
|
||||
"<th>" + exports.aliases.occupant + "</th>" +
|
||||
"<th>Address</th>" +
|
||||
"<th>Phone Number</th>" +
|
||||
"<th></th>" +
|
||||
"</tr></thead>" +
|
||||
"<tbody></tbody>";
|
||||
|
||||
for (const lotOccupancyOccupant of lotOccupancyOccupants) {
|
||||
|
||||
const tableRowElement = document.createElement("tr");
|
||||
tableRowElement.dataset.lotOccupantIndex = lotOccupancyOccupant.lotOccupantIndex.toString();
|
||||
|
||||
tableRowElement.innerHTML = ("<td>" + cityssm.escapeHTML(lotOccupancyOccupant.lotOccupantType as string) + "</td>") +
|
||||
("<td>" + cityssm.escapeHTML(lotOccupancyOccupant.occupantName) + "</td>") +
|
||||
("<td>" +
|
||||
cityssm.escapeHTML(lotOccupancyOccupant.occupantAddress1) + "<br />" +
|
||||
(lotOccupancyOccupant.occupantAddress2 ? cityssm.escapeHTML(lotOccupancyOccupant.occupantAddress2) + "<br />" : "") +
|
||||
cityssm.escapeHTML(lotOccupancyOccupant.occupantCity) + ", " + cityssm.escapeHTML(lotOccupancyOccupant.occupantProvince) + "<br />" +
|
||||
cityssm.escapeHTML(lotOccupancyOccupant.occupantPostalCode) +
|
||||
"</td>") +
|
||||
("<td>" + cityssm.escapeHTML(lotOccupancyOccupant.occupantPhoneNumber) + "</td>") +
|
||||
("<td>" +
|
||||
"<div class=\"buttons are-small is-justify-content-end\">" +
|
||||
("<button class=\"button is-primary button--edit\" type=\"button\">" +
|
||||
"<span class=\"icon is-small\"><i class=\"fas fa-pencil-alt\" aria-hidden=\"true\"></i></span>" +
|
||||
" <span>Edit</span>" +
|
||||
"</button>") +
|
||||
("<button class=\"button is-light is-danger button--delete\" type=\"button\" aria-label=\"Delete\">" +
|
||||
"<i class=\"fas fa-trash\" aria-hidden=\"true\"></i>" +
|
||||
"</button>") +
|
||||
"</div>" +
|
||||
"</td>");
|
||||
|
||||
tableElement.querySelector("tbody").append(tableRowElement);
|
||||
}
|
||||
|
||||
occupantsContainer.append(tableElement);
|
||||
};
|
||||
|
||||
document.querySelector("#button--addOccupant").addEventListener("click", () => {
|
||||
|
||||
cityssm.openHtmlModal("lotOccupancy-addOccupant", {
|
||||
onshow: (modalElement) => {
|
||||
los.populateAliases(modalElement);
|
||||
|
||||
(modalElement.querySelector("#lotOccupancyOccupantAdd--occupantCity") as HTMLInputElement).value = exports.occupantCityDefault;
|
||||
(modalElement.querySelector("#lotOccupancyOccupantAdd--occupantProvince") as HTMLInputElement).value = exports.occupantProvinceDefault;
|
||||
}
|
||||
});
|
||||
});
|
||||
|
||||
renderLotOccupancyOccupants();
|
||||
}
|
||||
|
||||
/*
|
||||
* Comments
|
||||
*/
|
||||
|
||||
/*
|
||||
* Fees
|
||||
*/
|
||||
|
||||
/*
|
||||
* Transactions
|
||||
*/
|
||||
})();
|
||||
|
|
@ -51,6 +51,12 @@ Object.defineProperty(exports, "__esModule", { value: true });
|
|||
case "lot":
|
||||
aliasElement.textContent = exports.aliases.lot.toLowerCase();
|
||||
break;
|
||||
case "Occupant":
|
||||
aliasElement.textContent = exports.aliases.occupant;
|
||||
break;
|
||||
case "occupant":
|
||||
aliasElement.textContent = exports.aliases.lot.toLowerCase();
|
||||
break;
|
||||
}
|
||||
}
|
||||
};
|
||||
|
|
|
|||
|
|
@ -83,6 +83,14 @@ import type * as globalTypes from "../types/globalTypes";
|
|||
case "lot":
|
||||
aliasElement.textContent = exports.aliases.lot.toLowerCase();
|
||||
break;
|
||||
|
||||
case "Occupant":
|
||||
aliasElement.textContent = exports.aliases.occupant;
|
||||
break;
|
||||
|
||||
case "occupant":
|
||||
aliasElement.textContent = exports.aliases.lot.toLowerCase();
|
||||
break;
|
||||
}
|
||||
}
|
||||
};
|
||||
|
|
|
|||
|
|
@ -19,7 +19,7 @@
|
|||
</form>
|
||||
</section>
|
||||
<footer class="modal-card-foot justify-right">
|
||||
<button class="button is-success" type="submit" form="form--ticketTypeAdd">
|
||||
<button class="button is-success" type="submit" form="form--lotCommentAdd">
|
||||
<span class="icon"><i class="fas fa-plus" aria-hidden="true"></i></span>
|
||||
<span>Add Comment</span>
|
||||
</button>
|
||||
|
|
|
|||
|
|
@ -0,0 +1,82 @@
|
|||
<div class="modal">
|
||||
<div class="modal-background"></div>
|
||||
<div class="modal-card">
|
||||
<header class="modal-card-head">
|
||||
<h3 class="modal-card-title">
|
||||
Add <span class="alias" data-alias="Occupant"></span>
|
||||
</h3>
|
||||
<button class="delete is-close-modal-button" aria-label="close" type="button"></button>
|
||||
</header>
|
||||
<section class="modal-card-body">
|
||||
<form id="form--lotOccupancyOccupantAdd">
|
||||
<input id="lotOccupancyOccupantAdd--lotOccupancyId" name="lotOccupancyId" type="hidden" value="" />
|
||||
<div class="field">
|
||||
<label class="label" for="lotOccupancyOccupantAdd--lotOccupantTypeId"><span class="alias" data-alias="Occupant"></span> Type</label>
|
||||
<div class="control">
|
||||
<div class="select">
|
||||
<select id="lotOccupancyOccupantAdd--lotOccupantTypeId" name="lotOccupantTypeId" required>
|
||||
<option value="">(Select a Type)</option>
|
||||
</select>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
<div class="field">
|
||||
<label class="label" for="lotOccupancyOccupantAdd--occupantName"><span class="alias" data-alias="Occupant"></span> Name</label>
|
||||
<div class="control">
|
||||
<input class="input" id="lotOccupancyOccupantAdd--occupantName" name="occupantName" maxlength="200" required />
|
||||
</div>
|
||||
</div>
|
||||
<div class="field">
|
||||
<label class="label" for="lotOccupancyOccupantAdd--occupantAddress1">Address</label>
|
||||
<div class="control">
|
||||
<input class="input" id="lotOccupancyOccupantAdd--occupantAddress1" name="occupantAddress1" maxlength="50" placeholder="Line 1" />
|
||||
</div>
|
||||
</div>
|
||||
<div class="field">
|
||||
<div class="control">
|
||||
<input class="input" id="lotOccupancyOccupantAdd--occupantAddress2" name="occupantAddress2" maxlength="50" placeholder="Line 2" aria-label="Address Line 2" />
|
||||
</div>
|
||||
</div>
|
||||
<div class="columns">
|
||||
<div class="column">
|
||||
<div class="field">
|
||||
<label class="label" for="lotOccupancyOccupant--occupantCity">City</label>
|
||||
<div class="control">
|
||||
<input class="input" id="lotOccupancyOccupantAdd--occupantCity" name="occupantCity" maxlength="20" />
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
<div class="column">
|
||||
<div class="field">
|
||||
<label class="label" for="lotOccupancyOccupant--occupantProvince">Province</label>
|
||||
<div class="control">
|
||||
<input class="input" id="lotOccupancyOccupantAdd--occupantProvince" name="occupantProvince" maxlength="2" />
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
<div class="column">
|
||||
<div class="field">
|
||||
<label class="label" for="lotOccupancyOccupant--occupantPostalCode">Postal Code</label>
|
||||
<div class="control">
|
||||
<input class="input" id="lotOccupancyOccupantAdd--occupantPostalCode" name="occupantPostalCode" maxlength="7" />
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
<div class="field">
|
||||
<label class="label" for="lotOccupancyOccupant--occupantPhoneNumber">Phone Number</label>
|
||||
<div class="control">
|
||||
<input class="input" id="lotOccupancyOccupantAdd--occupantPhoneNumber" name="occupantPhoneNumber" maxlength="30" />
|
||||
</div>
|
||||
</div>
|
||||
</form>
|
||||
</section>
|
||||
<footer class="modal-card-foot justify-right">
|
||||
<button class="button is-success" type="submit" form="form--lotOccupancyOccupantAdd">
|
||||
<span class="icon"><i class="fas fa-plus" aria-hidden="true"></i></span>
|
||||
<span>Add <span class="alias" data-alias="Occupant"></span></span>
|
||||
</button>
|
||||
<button class="button is-close-modal-button" type="button">Cancel</button>
|
||||
</footer>
|
||||
</div>
|
||||
</div>
|
||||
File diff suppressed because one or more lines are too long
|
|
@ -1 +1 @@
|
|||
"use strict";Object.defineProperty(exports,"__esModule",{value:!0}),(()=>{const e=e=>{const t=e.currentTarget.closest(".field").querySelector("input, select");if("INPUT"===t.tagName)t.disabled=!1;else{const e=t.querySelectorAll("option");for(const t of e)t.disabled=!1}t.focus()},t={highlightMap:(e,t,l)=>{let o,s=t;for(;!(o=e.querySelector("#"+s))&&s.includes("-");)s=s.slice(0,Math.max(0,s.lastIndexOf("-"))),console.log(s);if(o){o.style.fill=null,o.classList.add("highlight","is-"+l);const e=o.querySelectorAll("path");for(const t of e)t.style.fill=null}},initializeUnlockFieldButtons:t=>{const l=t.querySelectorAll(".is-unlock-field-button");for(const t of l)t.addEventListener("click",e)},populateAliases:e=>{const t=e.querySelectorAll(".alias");for(const e of t)switch(e.dataset.alias){case"Lot":e.textContent=exports.aliases.lot;break;case"lot":e.textContent=exports.aliases.lot.toLowerCase()}}};exports.los=t})();
|
||||
"use strict";Object.defineProperty(exports,"__esModule",{value:!0}),(()=>{const e=e=>{const t=e.currentTarget.closest(".field").querySelector("input, select");if("INPUT"===t.tagName)t.disabled=!1;else{const e=t.querySelectorAll("option");for(const t of e)t.disabled=!1}t.focus()},t={highlightMap:(e,t,o)=>{let l,s=t;for(;!(l=e.querySelector("#"+s))&&s.includes("-");)s=s.slice(0,Math.max(0,s.lastIndexOf("-"))),console.log(s);if(l){l.style.fill=null,l.classList.add("highlight","is-"+o);const e=l.querySelectorAll("path");for(const t of e)t.style.fill=null}},initializeUnlockFieldButtons:t=>{const o=t.querySelectorAll(".is-unlock-field-button");for(const t of o)t.addEventListener("click",e)},populateAliases:e=>{const t=e.querySelectorAll(".alias");for(const e of t)switch(e.dataset.alias){case"Lot":e.textContent=exports.aliases.lot;break;case"lot":e.textContent=exports.aliases.lot.toLowerCase();break;case"Occupant":e.textContent=exports.aliases.occupant;break;case"occupant":e.textContent=exports.aliases.lot.toLowerCase()}}};exports.los=t})();
|
||||
|
|
@ -7,12 +7,10 @@ import { addMap } from "../helpers/lotOccupancyDB/addMap.js";
|
|||
import { getMap as getMapFromDatabase } from "../helpers/lotOccupancyDB/getMap.js";
|
||||
import { addLot } from "../helpers/lotOccupancyDB/addLot.js";
|
||||
import { updateLotStatus } from "../helpers/lotOccupancyDB/updateLot.js";
|
||||
import { getOccupants } from "../helpers/lotOccupancyDB/getOccupants.js";
|
||||
import { addOccupant } from "../helpers/lotOccupancyDB/addOccupant.js";
|
||||
import { addLotOccupancy } from "../helpers/lotOccupancyDB/addLotOccupancy.js";
|
||||
import { addLotOccupancyOccupant } from "../helpers/lotOccupancyDB/addLotOccupancyOccupant.js";
|
||||
import { addLotOccupancyComment } from "../helpers/lotOccupancyDB/addLotOccupancyComment.js";
|
||||
import { addLotOccupancyField } from "../helpers/lotOccupancyDB/addLotOccupancyField.js";
|
||||
import { addOrUpdateLotOccupancyField } from "../helpers/lotOccupancyDB/addOrUpdateLotOccupancyField.js";
|
||||
const user = {
|
||||
user: {
|
||||
userName: "import.unix",
|
||||
|
|
@ -24,12 +22,12 @@ const user = {
|
|||
};
|
||||
function purgeTables() {
|
||||
const database = sqlite(databasePath);
|
||||
database.prepare("delete from LotOccupancyFields").run();
|
||||
database.prepare("delete from LotOccupancyComments").run();
|
||||
database.prepare("delete from LotOccupancyOccupants").run();
|
||||
database.prepare("delete from LotOccupancies").run();
|
||||
database.prepare("delete from Occupants").run();
|
||||
database.prepare("delete from Lots").run();
|
||||
database.prepare("delete from sqlite_sequence where name in ('Lots', 'LotOccupancies', 'LotOccupancyComments', 'Occupants')").run();
|
||||
database.prepare("delete from sqlite_sequence where name in ('Lots', 'LotOccupancies', 'LotOccupancyComments')").run();
|
||||
database.close();
|
||||
}
|
||||
function purgeConfigTables() {
|
||||
|
|
@ -69,11 +67,7 @@ const cemeteryToMapName = {
|
|||
};
|
||||
const mapCache = new Map();
|
||||
function getMap(masterRow) {
|
||||
let mapCacheKey = masterRow.CM_CEMETERY;
|
||||
if (masterRow.CM_CEMETERY === "HS" &&
|
||||
(masterRow.CM_BLOCK === "F" || masterRow.CM_BLOCK === "G" || masterRow.CM_BLOCK === "H" || masterRow.CM_BLOCK === "J")) {
|
||||
mapCacheKey += "-" + masterRow.CM_BLOCK;
|
||||
}
|
||||
const mapCacheKey = masterRow.CM_CEMETERY;
|
||||
if (mapCache.has(mapCacheKey)) {
|
||||
return mapCache.get(mapCacheKey);
|
||||
}
|
||||
|
|
@ -169,24 +163,6 @@ function importFromCSV() {
|
|||
lotLongitude: ""
|
||||
}, user);
|
||||
if (masterRow.CM_PRENEED_ORDER) {
|
||||
const occupantPostalCode = ((masterRow.CM_POST1 || "") + " " + (masterRow.CM_POST2 || "")).trim();
|
||||
const possibleOccupants = getOccupants({
|
||||
occupantName: masterRow.CM_PRENEED_OWNER,
|
||||
occupantAddress: masterRow.CM_ADDRESS,
|
||||
occupantCity: masterRow.CM_CITY,
|
||||
occupantPostalCode
|
||||
});
|
||||
const occupantId = possibleOccupants.length > 0 ?
|
||||
possibleOccupants[0].occupantId :
|
||||
addOccupant({
|
||||
occupantName: masterRow.CM_PRENEED_OWNER,
|
||||
occupantAddress1: masterRow.CM_ADDRESS,
|
||||
occupantAddress2: "",
|
||||
occupantCity: masterRow.CM_CITY,
|
||||
occupantProvince: masterRow.CM_PROV,
|
||||
occupantPostalCode,
|
||||
occupantPhoneNumber: ""
|
||||
}, user);
|
||||
let occupancyStartDateString = formatDateString(masterRow.CM_PURCHASE_YR, masterRow.CM_PURCHASE_MON, masterRow.CM_PURCHASE_DAY);
|
||||
let occupancyEndDateString = "";
|
||||
if (masterRow.CM_INTERMENT_YR !== "" && masterRow.CM_INTERMENT_YR !== "0") {
|
||||
|
|
@ -207,10 +183,17 @@ function importFromCSV() {
|
|||
occupancyStartDateString,
|
||||
occupancyEndDateString
|
||||
}, user);
|
||||
const occupantPostalCode = ((masterRow.CM_POST1 || "") + " " + (masterRow.CM_POST2 || "")).trim();
|
||||
addLotOccupancyOccupant({
|
||||
lotOccupancyId,
|
||||
lotOccupantTypeId: preneedOwnerLotOccupantType.lotOccupantTypeId,
|
||||
occupantId
|
||||
occupantName: masterRow.CM_PRENEED_OWNER,
|
||||
occupantAddress1: masterRow.CM_ADDRESS,
|
||||
occupantAddress2: "",
|
||||
occupantCity: masterRow.CM_CITY,
|
||||
occupantProvince: masterRow.CM_PROV,
|
||||
occupantPostalCode,
|
||||
occupantPhoneNumber: ""
|
||||
}, user);
|
||||
if (masterRow.CM_REMARK1 !== "") {
|
||||
addLotOccupancyComment({
|
||||
|
|
@ -233,16 +216,6 @@ function importFromCSV() {
|
|||
}
|
||||
}
|
||||
if (masterRow.CM_DECEASED_NAME) {
|
||||
const deceasedPostalCode = ((masterRow.CM_POST1 || "") + " " + (masterRow.CM_POST2 || "")).trim();
|
||||
const occupantId = addOccupant({
|
||||
occupantName: masterRow.CM_DECEASED_NAME,
|
||||
occupantAddress1: masterRow.CM_ADDRESS,
|
||||
occupantAddress2: "",
|
||||
occupantCity: masterRow.CM_CITY,
|
||||
occupantProvince: masterRow.CM_PROV,
|
||||
occupantPostalCode: deceasedPostalCode,
|
||||
occupantPhoneNumber: ""
|
||||
}, user);
|
||||
let occupancyStartDateString = formatDateString(masterRow.CM_INTERMENT_YR, masterRow.CM_INTERMENT_MON, masterRow.CM_INTERMENT_DAY);
|
||||
const occupancyEndDateString = "";
|
||||
if (occupancyStartDateString === "0000-00-00" && masterRow.CM_DEATH_YR !== "" && masterRow.CM_DEATH_YR !== "0") {
|
||||
|
|
@ -257,14 +230,21 @@ function importFromCSV() {
|
|||
occupancyStartDateString,
|
||||
occupancyEndDateString
|
||||
}, user);
|
||||
const deceasedPostalCode = ((masterRow.CM_POST1 || "") + " " + (masterRow.CM_POST2 || "")).trim();
|
||||
addLotOccupancyOccupant({
|
||||
lotOccupancyId,
|
||||
lotOccupantTypeId: deceasedLotOccupantType.lotOccupantTypeId,
|
||||
occupantId
|
||||
occupantName: masterRow.CM_DECEASED_NAME,
|
||||
occupantAddress1: masterRow.CM_ADDRESS,
|
||||
occupantAddress2: "",
|
||||
occupantCity: masterRow.CM_CITY,
|
||||
occupantProvince: masterRow.CM_PROV,
|
||||
occupantPostalCode: deceasedPostalCode,
|
||||
occupantPhoneNumber: ""
|
||||
}, user);
|
||||
if (masterRow.CM_DEATH_YR !== "") {
|
||||
const lotOccupancyFieldValue = formatDateString(masterRow.CM_DEATH_YR, masterRow.CM_DEATH_MON, masterRow.CM_DEATH_DAY);
|
||||
addLotOccupancyField({
|
||||
addOrUpdateLotOccupancyField({
|
||||
lotOccupancyId,
|
||||
occupancyTypeFieldId: deceasedOccupancyType.occupancyTypeFields.find((occupancyTypeField) => {
|
||||
return occupancyTypeField.occupancyTypeField === "Death Date";
|
||||
|
|
@ -273,7 +253,7 @@ function importFromCSV() {
|
|||
}, user);
|
||||
}
|
||||
if (masterRow.CM_AGE !== "") {
|
||||
addLotOccupancyField({
|
||||
addOrUpdateLotOccupancyField({
|
||||
lotOccupancyId,
|
||||
occupancyTypeFieldId: deceasedOccupancyType.occupancyTypeFields.find((occupancyTypeField) => {
|
||||
return occupancyTypeField.occupancyTypeField === "Death Age";
|
||||
|
|
@ -282,7 +262,7 @@ function importFromCSV() {
|
|||
}, user);
|
||||
}
|
||||
if (masterRow.CM_PERIOD !== "") {
|
||||
addLotOccupancyField({
|
||||
addOrUpdateLotOccupancyField({
|
||||
lotOccupancyId,
|
||||
occupancyTypeFieldId: deceasedOccupancyType.occupancyTypeFields.find((occupancyTypeField) => {
|
||||
return occupancyTypeField.occupancyTypeField === "Death Age Period";
|
||||
|
|
@ -291,7 +271,7 @@ function importFromCSV() {
|
|||
}, user);
|
||||
}
|
||||
if (masterRow.CM_FUNERAL_HOME !== "") {
|
||||
addLotOccupancyField({
|
||||
addOrUpdateLotOccupancyField({
|
||||
lotOccupancyId,
|
||||
occupancyTypeFieldId: deceasedOccupancyType.occupancyTypeFields.find((occupancyTypeField) => {
|
||||
return occupancyTypeField.occupancyTypeField === "Funeral Home";
|
||||
|
|
@ -301,7 +281,7 @@ function importFromCSV() {
|
|||
}
|
||||
if (masterRow.CM_FUNERAL_YR !== "") {
|
||||
const lotOccupancyFieldValue = formatDateString(masterRow.CM_FUNERAL_YR, masterRow.CM_FUNERAL_MON, masterRow.CM_FUNERAL_DAY);
|
||||
addLotOccupancyField({
|
||||
addOrUpdateLotOccupancyField({
|
||||
lotOccupancyId,
|
||||
occupancyTypeFieldId: deceasedOccupancyType.occupancyTypeFields.find((occupancyTypeField) => {
|
||||
return occupancyTypeField.occupancyTypeField === "Funeral Date";
|
||||
|
|
@ -310,7 +290,7 @@ function importFromCSV() {
|
|||
}, user);
|
||||
}
|
||||
if (masterRow.CM_CONTAINER_TYPE !== "") {
|
||||
addLotOccupancyField({
|
||||
addOrUpdateLotOccupancyField({
|
||||
lotOccupancyId,
|
||||
occupancyTypeFieldId: deceasedOccupancyType.occupancyTypeFields.find((occupancyTypeField) => {
|
||||
return occupancyTypeField.occupancyTypeField === "Container Type";
|
||||
|
|
@ -319,7 +299,7 @@ function importFromCSV() {
|
|||
}, user);
|
||||
}
|
||||
if (masterRow.CM_COMMITTAL_TYPE !== "") {
|
||||
addLotOccupancyField({
|
||||
addOrUpdateLotOccupancyField({
|
||||
lotOccupancyId,
|
||||
occupancyTypeFieldId: deceasedOccupancyType.occupancyTypeFields.find((occupancyTypeField) => {
|
||||
return occupancyTypeField.occupancyTypeField === "Committal Type";
|
||||
|
|
@ -353,4 +333,5 @@ function importFromCSV() {
|
|||
}
|
||||
}
|
||||
purgeTables();
|
||||
purgeConfigTables();
|
||||
importFromCSV();
|
||||
|
|
|
|||
|
|
@ -24,15 +24,10 @@ import {
|
|||
updateLotStatus
|
||||
} from "../helpers/lotOccupancyDB/updateLot.js";
|
||||
|
||||
import {
|
||||
getOccupants
|
||||
} from "../helpers/lotOccupancyDB/getOccupants.js";
|
||||
import {
|
||||
addOccupant
|
||||
} from "../helpers/lotOccupancyDB/addOccupant.js";
|
||||
import {
|
||||
addLotOccupancy
|
||||
} from "../helpers/lotOccupancyDB/addLotOccupancy.js";
|
||||
|
||||
import {
|
||||
addLotOccupancyOccupant
|
||||
} from "../helpers/lotOccupancyDB/addLotOccupancyOccupant.js";
|
||||
|
|
@ -42,8 +37,8 @@ import {
|
|||
} from "../helpers/lotOccupancyDB/addLotOccupancyComment.js";
|
||||
|
||||
import {
|
||||
addLotOccupancyField
|
||||
} from "../helpers/lotOccupancyDB/addLotOccupancyField.js";
|
||||
addOrUpdateLotOccupancyField
|
||||
} from "../helpers/lotOccupancyDB/addOrUpdateLotOccupancyField.js";
|
||||
|
||||
import type * as recordTypes from "../types/recordTypes";
|
||||
|
||||
|
|
@ -111,12 +106,12 @@ const user: recordTypes.PartialSession = {
|
|||
|
||||
function purgeTables() {
|
||||
const database = sqlite(databasePath);
|
||||
database.prepare("delete from LotOccupancyFields").run();
|
||||
database.prepare("delete from LotOccupancyComments").run();
|
||||
database.prepare("delete from LotOccupancyOccupants").run();
|
||||
database.prepare("delete from LotOccupancies").run();
|
||||
database.prepare("delete from Occupants").run();
|
||||
database.prepare("delete from Lots").run();
|
||||
database.prepare("delete from sqlite_sequence where name in ('Lots', 'LotOccupancies', 'LotOccupancyComments', 'Occupants')").run();
|
||||
database.prepare("delete from sqlite_sequence where name in ('Lots', 'LotOccupancies', 'LotOccupancyComments')").run();
|
||||
database.close();
|
||||
}
|
||||
|
||||
|
|
@ -172,13 +167,14 @@ const mapCache: Map < string, recordTypes.Map > = new Map();
|
|||
|
||||
function getMap(masterRow: MasterRecord): recordTypes.Map {
|
||||
|
||||
let mapCacheKey = masterRow.CM_CEMETERY;
|
||||
const mapCacheKey = masterRow.CM_CEMETERY;
|
||||
|
||||
/*
|
||||
if (masterRow.CM_CEMETERY === "HS" &&
|
||||
(masterRow.CM_BLOCK === "F" || masterRow.CM_BLOCK === "G" || masterRow.CM_BLOCK === "H" || masterRow.CM_BLOCK === "J")) {
|
||||
mapCacheKey += "-" + masterRow.CM_BLOCK;
|
||||
}
|
||||
|
||||
*/
|
||||
|
||||
if (mapCache.has(mapCacheKey)) {
|
||||
return mapCache.get(mapCacheKey);
|
||||
|
|
@ -301,27 +297,6 @@ function importFromCSV() {
|
|||
|
||||
if (masterRow.CM_PRENEED_ORDER) {
|
||||
|
||||
const occupantPostalCode = ((masterRow.CM_POST1 || "") + " " + (masterRow.CM_POST2 || "")).trim();
|
||||
|
||||
const possibleOccupants = getOccupants({
|
||||
occupantName: masterRow.CM_PRENEED_OWNER,
|
||||
occupantAddress: masterRow.CM_ADDRESS,
|
||||
occupantCity: masterRow.CM_CITY,
|
||||
occupantPostalCode
|
||||
});
|
||||
|
||||
const occupantId = possibleOccupants.length > 0 ?
|
||||
possibleOccupants[0].occupantId :
|
||||
addOccupant({
|
||||
occupantName: masterRow.CM_PRENEED_OWNER,
|
||||
occupantAddress1: masterRow.CM_ADDRESS,
|
||||
occupantAddress2: "",
|
||||
occupantCity: masterRow.CM_CITY,
|
||||
occupantProvince: masterRow.CM_PROV,
|
||||
occupantPostalCode,
|
||||
occupantPhoneNumber: ""
|
||||
}, user);
|
||||
|
||||
let occupancyStartDateString = formatDateString(masterRow.CM_PURCHASE_YR,
|
||||
masterRow.CM_PURCHASE_MON,
|
||||
masterRow.CM_PURCHASE_DAY);
|
||||
|
|
@ -357,10 +332,18 @@ function importFromCSV() {
|
|||
occupancyEndDateString
|
||||
}, user);
|
||||
|
||||
const occupantPostalCode = ((masterRow.CM_POST1 || "") + " " + (masterRow.CM_POST2 || "")).trim();
|
||||
|
||||
addLotOccupancyOccupant({
|
||||
lotOccupancyId,
|
||||
lotOccupantTypeId: preneedOwnerLotOccupantType.lotOccupantTypeId,
|
||||
occupantId
|
||||
occupantName: masterRow.CM_PRENEED_OWNER,
|
||||
occupantAddress1: masterRow.CM_ADDRESS,
|
||||
occupantAddress2: "",
|
||||
occupantCity: masterRow.CM_CITY,
|
||||
occupantProvince: masterRow.CM_PROV,
|
||||
occupantPostalCode,
|
||||
occupantPhoneNumber: ""
|
||||
}, user);
|
||||
|
||||
if (masterRow.CM_REMARK1 !== "") {
|
||||
|
|
@ -388,18 +371,6 @@ function importFromCSV() {
|
|||
|
||||
if (masterRow.CM_DECEASED_NAME) {
|
||||
|
||||
const deceasedPostalCode = ((masterRow.CM_POST1 || "") + " " + (masterRow.CM_POST2 || "")).trim();
|
||||
|
||||
const occupantId = addOccupant({
|
||||
occupantName: masterRow.CM_DECEASED_NAME,
|
||||
occupantAddress1: masterRow.CM_ADDRESS,
|
||||
occupantAddress2: "",
|
||||
occupantCity: masterRow.CM_CITY,
|
||||
occupantProvince: masterRow.CM_PROV,
|
||||
occupantPostalCode: deceasedPostalCode,
|
||||
occupantPhoneNumber: ""
|
||||
}, user);
|
||||
|
||||
let occupancyStartDateString = formatDateString(masterRow.CM_INTERMENT_YR,
|
||||
masterRow.CM_INTERMENT_MON,
|
||||
masterRow.CM_INTERMENT_DAY);
|
||||
|
|
@ -424,12 +395,18 @@ function importFromCSV() {
|
|||
occupancyEndDateString
|
||||
}, user);
|
||||
|
||||
|
||||
const deceasedPostalCode = ((masterRow.CM_POST1 || "") + " " + (masterRow.CM_POST2 || "")).trim();
|
||||
|
||||
addLotOccupancyOccupant({
|
||||
lotOccupancyId,
|
||||
lotOccupantTypeId: deceasedLotOccupantType.lotOccupantTypeId,
|
||||
occupantId
|
||||
occupantName: masterRow.CM_DECEASED_NAME,
|
||||
occupantAddress1: masterRow.CM_ADDRESS,
|
||||
occupantAddress2: "",
|
||||
occupantCity: masterRow.CM_CITY,
|
||||
occupantProvince: masterRow.CM_PROV,
|
||||
occupantPostalCode: deceasedPostalCode,
|
||||
occupantPhoneNumber: ""
|
||||
}, user);
|
||||
|
||||
if (masterRow.CM_DEATH_YR !== "") {
|
||||
|
|
@ -438,7 +415,7 @@ function importFromCSV() {
|
|||
masterRow.CM_DEATH_MON,
|
||||
masterRow.CM_DEATH_DAY);
|
||||
|
||||
addLotOccupancyField({
|
||||
addOrUpdateLotOccupancyField({
|
||||
lotOccupancyId,
|
||||
occupancyTypeFieldId: deceasedOccupancyType.occupancyTypeFields.find((occupancyTypeField) => {
|
||||
return occupancyTypeField.occupancyTypeField === "Death Date"
|
||||
|
|
@ -449,7 +426,7 @@ function importFromCSV() {
|
|||
|
||||
if (masterRow.CM_AGE !== "") {
|
||||
|
||||
addLotOccupancyField({
|
||||
addOrUpdateLotOccupancyField({
|
||||
lotOccupancyId,
|
||||
occupancyTypeFieldId: deceasedOccupancyType.occupancyTypeFields.find((occupancyTypeField) => {
|
||||
return occupancyTypeField.occupancyTypeField === "Death Age"
|
||||
|
|
@ -460,7 +437,7 @@ function importFromCSV() {
|
|||
|
||||
if (masterRow.CM_PERIOD !== "") {
|
||||
|
||||
addLotOccupancyField({
|
||||
addOrUpdateLotOccupancyField({
|
||||
lotOccupancyId,
|
||||
occupancyTypeFieldId: deceasedOccupancyType.occupancyTypeFields.find((occupancyTypeField) => {
|
||||
return occupancyTypeField.occupancyTypeField === "Death Age Period"
|
||||
|
|
@ -471,7 +448,7 @@ function importFromCSV() {
|
|||
|
||||
if (masterRow.CM_FUNERAL_HOME !== "") {
|
||||
|
||||
addLotOccupancyField({
|
||||
addOrUpdateLotOccupancyField({
|
||||
lotOccupancyId,
|
||||
occupancyTypeFieldId: deceasedOccupancyType.occupancyTypeFields.find((occupancyTypeField) => {
|
||||
return occupancyTypeField.occupancyTypeField === "Funeral Home"
|
||||
|
|
@ -486,7 +463,7 @@ function importFromCSV() {
|
|||
masterRow.CM_FUNERAL_MON,
|
||||
masterRow.CM_FUNERAL_DAY);
|
||||
|
||||
addLotOccupancyField({
|
||||
addOrUpdateLotOccupancyField({
|
||||
lotOccupancyId,
|
||||
occupancyTypeFieldId: deceasedOccupancyType.occupancyTypeFields.find((occupancyTypeField) => {
|
||||
return occupancyTypeField.occupancyTypeField === "Funeral Date"
|
||||
|
|
@ -497,7 +474,7 @@ function importFromCSV() {
|
|||
|
||||
if (masterRow.CM_CONTAINER_TYPE !== "") {
|
||||
|
||||
addLotOccupancyField({
|
||||
addOrUpdateLotOccupancyField({
|
||||
lotOccupancyId,
|
||||
occupancyTypeFieldId: deceasedOccupancyType.occupancyTypeFields.find((occupancyTypeField) => {
|
||||
return occupancyTypeField.occupancyTypeField === "Container Type"
|
||||
|
|
@ -508,7 +485,7 @@ function importFromCSV() {
|
|||
|
||||
if (masterRow.CM_COMMITTAL_TYPE !== "") {
|
||||
|
||||
addLotOccupancyField({
|
||||
addOrUpdateLotOccupancyField({
|
||||
lotOccupancyId,
|
||||
occupancyTypeFieldId: deceasedOccupancyType.occupancyTypeFields.find((occupancyTypeField) => {
|
||||
return occupancyTypeField.occupancyTypeField === "Committal Type"
|
||||
|
|
@ -545,5 +522,5 @@ function importFromCSV() {
|
|||
}
|
||||
|
||||
purgeTables();
|
||||
// purgeConfigTables();
|
||||
purgeConfigTables();
|
||||
importFromCSV();
|
||||
|
|
@ -27,6 +27,8 @@ export interface Config {
|
|||
lotOccupancy?: {
|
||||
lotIdIsRequired?: boolean;
|
||||
occupancyEndDateIsRequired?: boolean;
|
||||
occupantCityDefault?: string;
|
||||
occupantProvinceDefault?: string;
|
||||
};
|
||||
};
|
||||
}
|
||||
|
|
|
|||
|
|
@ -27,6 +27,8 @@ export interface Config {
|
|||
lotOccupancy ? : {
|
||||
lotIdIsRequired ? : boolean;
|
||||
occupancyEndDateIsRequired ? : boolean;
|
||||
occupantCityDefault ? : string;
|
||||
occupantProvinceDefault ? : string;
|
||||
}
|
||||
};
|
||||
}
|
||||
|
|
|
|||
|
|
@ -97,16 +97,6 @@ export interface LotOccupantType extends Record {
|
|||
lotOccupantType?: string;
|
||||
orderNumber?: number;
|
||||
}
|
||||
export interface Occupant extends Record {
|
||||
occupantId?: number;
|
||||
occupantName?: string;
|
||||
occupantAddress1?: string;
|
||||
occupantAddress2?: string;
|
||||
occupantCity?: string;
|
||||
occupantProvince?: string;
|
||||
occupantPostalCode?: string;
|
||||
occupantPhoneNumber?: string;
|
||||
}
|
||||
export interface Fee extends Record {
|
||||
feeId?: number;
|
||||
feeName?: string;
|
||||
|
|
@ -131,11 +121,18 @@ export interface LotOccupancyTransaction extends Record {
|
|||
externalReceiptNumber?: string;
|
||||
transactionNote?: string;
|
||||
}
|
||||
export interface LotOccupancyOccupant extends Occupant, Record {
|
||||
export interface LotOccupancyOccupant extends Record {
|
||||
lotOccupancyId?: number;
|
||||
lotOccupantIndex?: number;
|
||||
lotOccupantTypeId?: number;
|
||||
lotOccupantType?: string | LotOccupantType;
|
||||
occupantName?: string;
|
||||
occupantAddress1?: string;
|
||||
occupantAddress2?: string;
|
||||
occupantCity?: string;
|
||||
occupantProvince?: string;
|
||||
occupantPostalCode?: string;
|
||||
occupantPhoneNumber?: string;
|
||||
}
|
||||
export interface LotOccupancyComment extends Record {
|
||||
lotOccupancyCommentId?: number;
|
||||
|
|
|
|||
|
|
@ -139,18 +139,6 @@ export interface LotOccupantType extends Record {
|
|||
}
|
||||
|
||||
|
||||
export interface Occupant extends Record {
|
||||
occupantId ? : number;
|
||||
occupantName ? : string;
|
||||
occupantAddress1 ? : string;
|
||||
occupantAddress2 ? : string;
|
||||
occupantCity ? : string;
|
||||
occupantProvince ? : string;
|
||||
occupantPostalCode ? : string;
|
||||
occupantPhoneNumber ? : string;
|
||||
}
|
||||
|
||||
|
||||
export interface Fee extends Record {
|
||||
feeId?: number;
|
||||
feeName?: string;
|
||||
|
|
@ -184,12 +172,20 @@ export interface LotOccupancyTransaction extends Record {
|
|||
}
|
||||
|
||||
|
||||
export interface LotOccupancyOccupant extends Occupant, Record {
|
||||
export interface LotOccupancyOccupant extends Record {
|
||||
lotOccupancyId ? : number;
|
||||
lotOccupantIndex ? : number;
|
||||
|
||||
lotOccupantTypeId ? : number;
|
||||
lotOccupantType ? : string | LotOccupantType;
|
||||
|
||||
occupantName ? : string;
|
||||
occupantAddress1 ? : string;
|
||||
occupantAddress2 ? : string;
|
||||
occupantCity ? : string;
|
||||
occupantProvince ? : string;
|
||||
occupantPostalCode ? : string;
|
||||
occupantPhoneNumber ? : string;
|
||||
}
|
||||
|
||||
|
||||
|
|
|
|||
|
|
@ -44,7 +44,7 @@
|
|||
<select id="searchFilter--lotTypeId" name="lotTypeId">
|
||||
<option value="">(All <%= configFunctions.getProperty("aliases.lot") %> Types)</option>
|
||||
<% for (const lotType of lotTypes) { %>
|
||||
<option value="<%= lotType.lotTypeId %>"><%= lotType.lotType %></option>
|
||||
<option value="<%= lotType.lotTypeId %>"><%= lotType.lotType || "(No Name)" %></option>
|
||||
<% } %>
|
||||
</select>
|
||||
</div>
|
||||
|
|
@ -62,7 +62,7 @@
|
|||
<option value="">(All <%= configFunctions.getProperty("aliases.maps") %>)</option>
|
||||
<% for (const map of maps) { %>
|
||||
<option value="<%= map.mapId %>" <%= (map.mapId.toString() === mapId) ? " selected" : "" %>>
|
||||
<%= map.mapName %>
|
||||
<%= map.mapName || "(No Name)" %>
|
||||
</option>
|
||||
<% } %>
|
||||
</select>
|
||||
|
|
|
|||
|
|
@ -165,10 +165,33 @@
|
|||
<% if (isCreate) { %>
|
||||
|
||||
<% } else { %>
|
||||
<hr />
|
||||
|
||||
<h2 class="title is-4 mt-2"><%= configFunctions.getProperty("aliases.occupants") %></h2>
|
||||
<div class="level is-mobile">
|
||||
<div class="level-left">
|
||||
<div class="level-item">
|
||||
<h2 class="title is-4">
|
||||
<%= configFunctions.getProperty("aliases.occupants") %>
|
||||
</h2>
|
||||
</div>
|
||||
</div>
|
||||
<div class="level-right">
|
||||
<div class="level-item">
|
||||
<button class="button is-small is-success" id="button--addOccupant" type="button">
|
||||
<span class="icon is-small"><i class="fas fa-plus" aria-hidden="true"></i></span>
|
||||
<span>Add <%= configFunctions.getProperty("aliases.occupant") %></span>
|
||||
</button>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<h2 class="title is-4">Comments</h2>
|
||||
<div id="container--lotOccupancyOccupants"></div>
|
||||
|
||||
<hr />
|
||||
|
||||
<h2 class="title is-4 mt-2">Comments</h2>
|
||||
|
||||
<div id="container--lotOccupancyComments"></div>
|
||||
|
||||
<div class="columns">
|
||||
<div class="column">
|
||||
|
|
@ -183,6 +206,10 @@
|
|||
<%- include('_footerA'); -%>
|
||||
|
||||
<script>
|
||||
exports.occupantCityDefault = "<%= configFunctions.getProperty("settings.lotOccupancy.occupantCityDefault") %>";
|
||||
exports.occupantProvinceDefault = "<%= configFunctions.getProperty("settings.lotOccupancy.occupantProvinceDefault") %>";
|
||||
exports.lotOccupantTypes = <%- JSON.stringify(lotOccupantTypes) %>;
|
||||
|
||||
exports.lotOccupancyOccupants = <%- JSON.stringify(lotOccupancy.lotOccupancyOccupants) %>;
|
||||
exports.lotOccupancyComments = <%- JSON.stringify(lotOccupancy.lotOccupancyComments) %>;
|
||||
exports.lotOccupancyFees = <%- JSON.stringify(lotOccupancy.lotOccupancyFees) %>;
|
||||
|
|
|
|||
|
|
@ -93,7 +93,7 @@
|
|||
<option value="">(All <%= configFunctions.getProperty("aliases.maps") %>)</option>
|
||||
<% for (const map of maps) { %>
|
||||
<option value="<%= map.mapId %>" <%= (map.mapId.toString() === mapId) ? " selected" : "" %>>
|
||||
<%= map.mapName %>
|
||||
<%= map.mapName || "(No Name)" %>
|
||||
</option>
|
||||
<% } %>
|
||||
</select>
|
||||
|
|
|
|||
Loading…
Reference in New Issue