From 8da22d137ad56673c0ada5debb48d107ad17ad66 Mon Sep 17 00:00:00 2001 From: Dan Gowans Date: Mon, 22 Aug 2022 13:15:00 -0400 Subject: [PATCH] development preparing to make public --- handlers/lotOccupancies-get/new.js | 15 +- handlers/lotOccupancies-get/new.ts | 21 +- handlers/reports-get/reportName.js | 21 ++ handlers/reports-get/reportName.ts | 45 ++- .../lotOccupancyDB/addLotOccupancyOccupant.js | 2 +- .../lotOccupancyDB/addLotOccupancyOccupant.ts | 2 +- .../addLotOccupancyTransaction.js | 3 +- .../addLotOccupancyTransaction.ts | 4 +- helpers/lotOccupancyDB/getReportData.d.ts | 5 + helpers/lotOccupancyDB/getReportData.js | 51 +++ helpers/lotOccupancyDB/getReportData.ts | 84 +++++ package-lock.json | 60 ++- package.json | 3 +- public-typescript/lotOccupancyEdit.js | 8 + public-typescript/lotOccupancyEdit.ts | 11 +- public/javascripts/lotOccupancyEdit.min.js | 2 +- temp/legacy.importFromCSV.js | 6 +- temp/legacy.importFromCSV.ts | 8 +- views/lot-edit.ejs | 347 ++++++++++-------- views/lot-view.ejs | 226 ++++++------ views/lotOccupancy-view.ejs | 24 +- views/map-edit.ejs | 154 ++++---- views/map-view.ejs | 109 +++--- views/report-search.ejs | 132 +++---- 24 files changed, 863 insertions(+), 480 deletions(-) create mode 100644 helpers/lotOccupancyDB/getReportData.d.ts create mode 100644 helpers/lotOccupancyDB/getReportData.js create mode 100644 helpers/lotOccupancyDB/getReportData.ts diff --git a/handlers/lotOccupancies-get/new.js b/handlers/lotOccupancies-get/new.js index 8249fcff..21abfb0b 100644 --- a/handlers/lotOccupancies-get/new.js +++ b/handlers/lotOccupancies-get/new.js @@ -1,7 +1,20 @@ +import { dateToInteger, dateToString } from "@cityssm/expressjs-server-js/dateTimeFns.js"; import { getOccupancyTypes } from "../../helpers/functions.cache.js"; +import { getLot } from "../../helpers/lotOccupancyDB/getLot.js"; import * as configFunctions from "../../helpers/functions.config.js"; export const handler = (request, response) => { - const lotOccupancy = {}; + const startDate = new Date(); + const lotOccupancy = { + occupancyStartDate: dateToInteger(startDate), + occupancyStartDateString: dateToString(startDate) + }; + if (request.query.lotId) { + const lot = getLot(request.query.lotId); + lotOccupancy.lotId = lot.lotId; + lotOccupancy.lotName = lot.lotName; + lotOccupancy.mapId = lot.mapId; + lotOccupancy.mapName = lot.mapName; + } const occupancyTypes = getOccupancyTypes(); return response.render("lotOccupancy-edit", { headTitle: "Create a New " + configFunctions.getProperty("aliases.lot") + " " + configFunctions.getProperty("aliases.occupancy") + " Record", diff --git a/handlers/lotOccupancies-get/new.ts b/handlers/lotOccupancies-get/new.ts index add3756e..01f39790 100644 --- a/handlers/lotOccupancies-get/new.ts +++ b/handlers/lotOccupancies-get/new.ts @@ -1,3 +1,7 @@ +import { + dateToInteger, + dateToString +} from "@cityssm/expressjs-server-js/dateTimeFns.js"; import type { RequestHandler } from "express"; @@ -6,6 +10,10 @@ import { getOccupancyTypes } from "../../helpers/functions.cache.js"; +import { + getLot +} from "../../helpers/lotOccupancyDB/getLot.js"; + import * as configFunctions from "../../helpers/functions.config.js"; import type * as recordTypes from "../../types/recordTypes"; @@ -13,10 +21,21 @@ import type * as recordTypes from "../../types/recordTypes"; export const handler: RequestHandler = (request, response) => { + const startDate = new Date(); + const lotOccupancy: recordTypes.LotOccupancy = { - + occupancyStartDate: dateToInteger(startDate), + occupancyStartDateString: dateToString(startDate) }; + if (request.query.lotId) { + const lot = getLot(request.query.lotId as string); + lotOccupancy.lotId = lot.lotId; + lotOccupancy.lotName = lot.lotName; + lotOccupancy.mapId = lot.mapId; + lotOccupancy.mapName = lot.mapName; + } + const occupancyTypes = getOccupancyTypes(); return response.render("lotOccupancy-edit", { diff --git a/handlers/reports-get/reportName.js b/handlers/reports-get/reportName.js index 469bed64..26026229 100644 --- a/handlers/reports-get/reportName.js +++ b/handlers/reports-get/reportName.js @@ -1,3 +1,24 @@ +import { getReportData } from "../../helpers/lotOccupancyDB/getReportData.js"; +import papaparse from "papaparse"; export const handler = (request, response) => { + const reportName = request.params.reportName; + let rows; + switch (reportName) { + default: + rows = getReportData(reportName, request.query); + break; + } + if (!rows) { + return response + .status(404) + .json({ + success: false, + message: "Report Not Found" + }); + } + const csv = papaparse.unparse(rows); + response.setHeader("Content-Disposition", "attachment; filename=" + reportName + "-" + Date.now().toString() + ".csv"); + response.setHeader("Content-Type", "text/csv"); + response.send(csv); }; export default handler; diff --git a/handlers/reports-get/reportName.ts b/handlers/reports-get/reportName.ts index 6f6c43a2..4f3cf09d 100644 --- a/handlers/reports-get/reportName.ts +++ b/handlers/reports-get/reportName.ts @@ -1,23 +1,46 @@ -import type { RequestHandler } from "express"; +import type { + RequestHandler +} from "express"; -// import * as configFunctions from "../../helpers/functions.config.js"; +import { + getReportData, + ReportParameters +} from "../../helpers/lotOccupancyDB/getReportData.js"; + +import papaparse from "papaparse"; export const handler: RequestHandler = (request, response) => { - // const reportName = request.params.reportName; + const reportName = request.params.reportName; - /* - const csv = rawToCSV(rowsColumnsObject); + let rows: unknown[]; - response.setHeader("Content-Disposition", - "attachment; filename=" + reportName + "-" + Date.now().toString() + ".csv"); + switch (reportName) { - response.setHeader("Content-Type", "text/csv"); + default: + rows = getReportData(reportName, request.query as ReportParameters); + break; + } - response.send(csv); - */ + if (!rows) { + return response + .status(404) + .json({ + success: false, + message: "Report Not Found" + }); + } + + const csv = papaparse.unparse(rows); + + response.setHeader("Content-Disposition", + "attachment; filename=" + reportName + "-" + Date.now().toString() + ".csv"); + + response.setHeader("Content-Type", "text/csv"); + + response.send(csv); }; -export default handler; +export default handler; \ No newline at end of file diff --git a/helpers/lotOccupancyDB/addLotOccupancyOccupant.js b/helpers/lotOccupancyDB/addLotOccupancyOccupant.js index fe609d74..0a5a4358 100644 --- a/helpers/lotOccupancyDB/addLotOccupancyOccupant.js +++ b/helpers/lotOccupancyDB/addLotOccupancyOccupant.js @@ -6,7 +6,7 @@ export const addLotOccupancyOccupant = (lotOccupancyOccupantForm, requestSession const maxIndexResult = database.prepare("select lotOccupantIndex" + " from LotOccupancyOccupants" + " where lotOccupancyId = ?" + - " order by lotOccupantIndex" + + " order by lotOccupantIndex desc" + " limit 1") .get(lotOccupancyOccupantForm.lotOccupancyId); if (maxIndexResult) { diff --git a/helpers/lotOccupancyDB/addLotOccupancyOccupant.ts b/helpers/lotOccupancyDB/addLotOccupancyOccupant.ts index 27e53450..878c8140 100644 --- a/helpers/lotOccupancyDB/addLotOccupancyOccupant.ts +++ b/helpers/lotOccupancyDB/addLotOccupancyOccupant.ts @@ -30,7 +30,7 @@ export const addLotOccupancyOccupant = const maxIndexResult = database.prepare("select lotOccupantIndex" + " from LotOccupancyOccupants" + " where lotOccupancyId = ?" + - " order by lotOccupantIndex" + + " order by lotOccupantIndex desc" + " limit 1") .get(lotOccupancyOccupantForm.lotOccupancyId); diff --git a/helpers/lotOccupancyDB/addLotOccupancyTransaction.js b/helpers/lotOccupancyDB/addLotOccupancyTransaction.js index cf2eb4b0..2dd258c4 100644 --- a/helpers/lotOccupancyDB/addLotOccupancyTransaction.js +++ b/helpers/lotOccupancyDB/addLotOccupancyTransaction.js @@ -7,12 +7,13 @@ export const addLotOccupancyTransaction = (lotOccupancyTransactionForm, requestS const maxIndexResult = database.prepare("select transactionIndex" + " from LotOccupancyTransactions" + " where lotOccupancyId = ?" + - " order by transactionIndex" + + " order by transactionIndex desc" + " limit 1") .get(lotOccupancyTransactionForm.lotOccupancyId); if (maxIndexResult) { transactionIndex = maxIndexResult.transactionIndex + 1; } + console.log("transactionIndex = " + transactionIndex); const rightNow = new Date(); const transactionDate = lotOccupancyTransactionForm.transactionDateString ? dateStringToInteger(lotOccupancyTransactionForm.transactionDateString) : diff --git a/helpers/lotOccupancyDB/addLotOccupancyTransaction.ts b/helpers/lotOccupancyDB/addLotOccupancyTransaction.ts index ca2b6a52..4a1aa500 100644 --- a/helpers/lotOccupancyDB/addLotOccupancyTransaction.ts +++ b/helpers/lotOccupancyDB/addLotOccupancyTransaction.ts @@ -33,7 +33,7 @@ export const addLotOccupancyTransaction = const maxIndexResult = database.prepare("select transactionIndex" + " from LotOccupancyTransactions" + " where lotOccupancyId = ?" + - " order by transactionIndex" + + " order by transactionIndex desc" + " limit 1") .get(lotOccupancyTransactionForm.lotOccupancyId); @@ -41,6 +41,8 @@ export const addLotOccupancyTransaction = transactionIndex = maxIndexResult.transactionIndex + 1; } + console.log("transactionIndex = " + transactionIndex); + const rightNow = new Date(); const transactionDate = lotOccupancyTransactionForm.transactionDateString ? diff --git a/helpers/lotOccupancyDB/getReportData.d.ts b/helpers/lotOccupancyDB/getReportData.d.ts new file mode 100644 index 00000000..bd606ff9 --- /dev/null +++ b/helpers/lotOccupancyDB/getReportData.d.ts @@ -0,0 +1,5 @@ +export interface ReportParameters { + [parameterName: string]: string | number; +} +export declare const getReportData: (reportName: string, reportParameters?: ReportParameters) => unknown[]; +export default getReportData; diff --git a/helpers/lotOccupancyDB/getReportData.js b/helpers/lotOccupancyDB/getReportData.js new file mode 100644 index 00000000..fc4675d3 --- /dev/null +++ b/helpers/lotOccupancyDB/getReportData.js @@ -0,0 +1,51 @@ +import sqlite from "better-sqlite3"; +import { lotOccupancyDB as databasePath } from "../../data/databasePaths.js"; +import * as configFunctions from "../functions.config.js"; +import * as dateTimeFunctions from "@cityssm/expressjs-server-js/dateTimeFns.js"; +import camelCase from "camelcase"; +const mapCamelCase = camelCase(configFunctions.getProperty("aliases.map")); +const mapNameAlias = mapCamelCase + "Name"; +const mapDescriptionAlias = mapCamelCase + "Description"; +const mapAddress1Alias = mapCamelCase + "Address1"; +const mapAddress2Alias = mapCamelCase + "Address2"; +const mapCityAlias = mapCamelCase + "City"; +const mapProvinceAlias = mapCamelCase + "Province"; +const mapPostalCodeAlias = mapCamelCase + "PostalCode"; +const mapPhoneNumberAlias = mapCamelCase + "PhoneNumber"; +export const getReportData = (reportName, reportParameters) => { + let sql; + const sqlParameters = []; + switch (reportName) { + case "maps-all": + sql = "select * from Maps"; + break; + case "maps-formatted": + sql = "select mapName as " + mapNameAlias + "," + + " mapDescription as " + mapDescriptionAlias + "," + + " mapAddress1 as " + mapAddress1Alias + "," + + " mapAddress2 as " + mapAddress2Alias + "," + + " mapCity as " + mapCityAlias + "," + + " mapProvince as " + mapProvinceAlias + "," + + " mapPostalCode as " + mapPostalCodeAlias + "," + + " mapPhoneNumber as " + mapPhoneNumberAlias + + " from Maps" + + " where recordDelete_timeMillis is null" + + " order by mapName"; + break; + case "lots-all": + sql = "select * from Lots"; + break; + default: + return undefined; + } + const database = sqlite(databasePath, { + readonly: true + }); + database.function("userFn_dateIntegerToString", dateTimeFunctions.dateIntegerToString); + database.function("userFn_timeIntegerToString", dateTimeFunctions.timeIntegerToString); + const rows = database.prepare(sql) + .all(sqlParameters); + database.close(); + return rows; +}; +export default getReportData; diff --git a/helpers/lotOccupancyDB/getReportData.ts b/helpers/lotOccupancyDB/getReportData.ts new file mode 100644 index 00000000..5566de7e --- /dev/null +++ b/helpers/lotOccupancyDB/getReportData.ts @@ -0,0 +1,84 @@ +/* eslint-disable no-case-declarations */ + +import sqlite from "better-sqlite3"; + +import { + lotOccupancyDB as databasePath +} from "../../data/databasePaths.js"; + +import * as configFunctions from "../functions.config.js"; +import * as dateTimeFunctions from "@cityssm/expressjs-server-js/dateTimeFns.js"; + +import camelCase from "camelcase"; + +export interface ReportParameters { + [parameterName: string]: string | number; +} + + +const mapCamelCase = camelCase(configFunctions.getProperty("aliases.map")); + +const mapNameAlias = mapCamelCase + "Name"; +const mapDescriptionAlias = mapCamelCase + "Description"; +const mapAddress1Alias = mapCamelCase + "Address1"; +const mapAddress2Alias = mapCamelCase + "Address2"; +const mapCityAlias = mapCamelCase + "City"; +const mapProvinceAlias = mapCamelCase + "Province"; +const mapPostalCodeAlias = mapCamelCase + "PostalCode"; +const mapPhoneNumberAlias = mapCamelCase + "PhoneNumber"; + +export const getReportData = (reportName: string, reportParameters ? : ReportParameters): unknown[] => { + + let sql: string; + const sqlParameters = []; + + switch (reportName) { + + case "maps-all": + + sql = "select * from Maps"; + break; + + case "maps-formatted": + + sql = "select mapName as " + mapNameAlias + "," + + " mapDescription as " + mapDescriptionAlias + "," + + " mapAddress1 as " + mapAddress1Alias + "," + + " mapAddress2 as " + mapAddress2Alias + "," + + " mapCity as " + mapCityAlias + "," + + " mapProvince as " + mapProvinceAlias + "," + + " mapPostalCode as " + mapPostalCodeAlias + "," + + " mapPhoneNumber as " + mapPhoneNumberAlias + + " from Maps" + + " where recordDelete_timeMillis is null" + + " order by mapName"; + + break; + + case "lots-all": + + sql = "select * from Lots"; + break; + + default: + return undefined; + } + + const database = sqlite(databasePath, { + readonly: true + }); + + database.function("userFn_dateIntegerToString", dateTimeFunctions.dateIntegerToString); + database.function("userFn_timeIntegerToString", dateTimeFunctions.timeIntegerToString); + + const rows = + database.prepare(sql) + .all(sqlParameters); + + database.close(); + + return rows; +}; + + +export default getReportData; \ No newline at end of file diff --git a/package-lock.json b/package-lock.json index 0c36d279..62e9cdfc 100644 --- a/package-lock.json +++ b/package-lock.json @@ -16,6 +16,7 @@ "@fortawesome/fontawesome-free": "^5.15.4", "activedirectory2": "^2.1.0", "better-sqlite3": "^7.6.2", + "camelcase": "^7.0.0", "compression": "^1.7.4", "cookie-parser": "^1.4.6", "cross-env": "^7.0.3", @@ -28,6 +29,7 @@ "express-session": "^1.17.3", "http-errors": "^2.0.0", "leaflet": "^1.8.0", + "papaparse": "^5.3.2", "session-file-store": "^1.5.0" }, "devDependencies": { @@ -65,7 +67,6 @@ "gulp-minify": "^3.1.0", "gulp-sass": "^5.1.0", "nodemon": "^2.0.19", - "papaparse": "^5.3.2", "sass": "^1.54.5" }, "engines": { @@ -2105,12 +2106,14 @@ } }, "node_modules/camelcase": { - "version": "3.0.0", - "resolved": "https://registry.npmjs.org/camelcase/-/camelcase-3.0.0.tgz", - "integrity": "sha512-4nhGqUkc4BqbBBB4Q6zLuD7lzzrHYrjKGeYaEji/3tFR5VdJu9v+LilhGIVe8wxEJPPOeWo7eg8dwY13TZ1BNg==", - "dev": true, + "version": "7.0.0", + "resolved": "https://registry.npmjs.org/camelcase/-/camelcase-7.0.0.tgz", + "integrity": "sha512-JToIvOmz6nhGsUhAYScbo2d6Py5wojjNfoxoc2mEVLUdJ70gJK2gnd+ABY1Tc3sVMyK7QDPtN0T/XdlCQWITyQ==", "engines": { - "node": ">=0.10.0" + "node": ">=14.16" + }, + "funding": { + "url": "https://github.com/sponsors/sindresorhus" } }, "node_modules/chalk": { @@ -7621,8 +7624,7 @@ "node_modules/papaparse": { "version": "5.3.2", "resolved": "https://registry.npmjs.org/papaparse/-/papaparse-5.3.2.tgz", - "integrity": "sha512-6dNZu0Ki+gyV0eBsFKJhYr+MdQYAzFUGlBMNj3GNrmHxmz1lfRa24CjFObPXtjcetlOv5Ad299MhIK0znp3afw==", - "dev": true + "integrity": "sha512-6dNZu0Ki+gyV0eBsFKJhYr+MdQYAzFUGlBMNj3GNrmHxmz1lfRa24CjFObPXtjcetlOv5Ad299MhIK0znp3afw==" }, "node_modules/parent-module": { "version": "1.0.1", @@ -10502,6 +10504,15 @@ "object.assign": "^4.1.0" } }, + "node_modules/yargs-parser/node_modules/camelcase": { + "version": "3.0.0", + "resolved": "https://registry.npmjs.org/camelcase/-/camelcase-3.0.0.tgz", + "integrity": "sha512-4nhGqUkc4BqbBBB4Q6zLuD7lzzrHYrjKGeYaEji/3tFR5VdJu9v+LilhGIVe8wxEJPPOeWo7eg8dwY13TZ1BNg==", + "dev": true, + "engines": { + "node": ">=0.10.0" + } + }, "node_modules/yargs/node_modules/ansi-regex": { "version": "2.1.1", "resolved": "https://registry.npmjs.org/ansi-regex/-/ansi-regex-2.1.1.tgz", @@ -10511,6 +10522,15 @@ "node": ">=0.10.0" } }, + "node_modules/yargs/node_modules/camelcase": { + "version": "3.0.0", + "resolved": "https://registry.npmjs.org/camelcase/-/camelcase-3.0.0.tgz", + "integrity": "sha512-4nhGqUkc4BqbBBB4Q6zLuD7lzzrHYrjKGeYaEji/3tFR5VdJu9v+LilhGIVe8wxEJPPOeWo7eg8dwY13TZ1BNg==", + "dev": true, + "engines": { + "node": ">=0.10.0" + } + }, "node_modules/yargs/node_modules/find-up": { "version": "1.1.2", "resolved": "https://registry.npmjs.org/find-up/-/find-up-1.1.2.tgz", @@ -12293,10 +12313,9 @@ "dev": true }, "camelcase": { - "version": "3.0.0", - "resolved": "https://registry.npmjs.org/camelcase/-/camelcase-3.0.0.tgz", - "integrity": "sha512-4nhGqUkc4BqbBBB4Q6zLuD7lzzrHYrjKGeYaEji/3tFR5VdJu9v+LilhGIVe8wxEJPPOeWo7eg8dwY13TZ1BNg==", - "dev": true + "version": "7.0.0", + "resolved": "https://registry.npmjs.org/camelcase/-/camelcase-7.0.0.tgz", + "integrity": "sha512-JToIvOmz6nhGsUhAYScbo2d6Py5wojjNfoxoc2mEVLUdJ70gJK2gnd+ABY1Tc3sVMyK7QDPtN0T/XdlCQWITyQ==" }, "chalk": { "version": "4.1.2", @@ -16588,8 +16607,7 @@ "papaparse": { "version": "5.3.2", "resolved": "https://registry.npmjs.org/papaparse/-/papaparse-5.3.2.tgz", - "integrity": "sha512-6dNZu0Ki+gyV0eBsFKJhYr+MdQYAzFUGlBMNj3GNrmHxmz1lfRa24CjFObPXtjcetlOv5Ad299MhIK0znp3afw==", - "dev": true + "integrity": "sha512-6dNZu0Ki+gyV0eBsFKJhYr+MdQYAzFUGlBMNj3GNrmHxmz1lfRa24CjFObPXtjcetlOv5Ad299MhIK0znp3afw==" }, "parent-module": { "version": "1.0.1", @@ -18850,6 +18868,12 @@ "integrity": "sha512-TIGnTpdo+E3+pCyAluZvtED5p5wCqLdezCyhPZzKPcxvFplEt4i+W7OONCKgeZFT3+y5NZZfOOS/Bdcanm1MYA==", "dev": true }, + "camelcase": { + "version": "3.0.0", + "resolved": "https://registry.npmjs.org/camelcase/-/camelcase-3.0.0.tgz", + "integrity": "sha512-4nhGqUkc4BqbBBB4Q6zLuD7lzzrHYrjKGeYaEji/3tFR5VdJu9v+LilhGIVe8wxEJPPOeWo7eg8dwY13TZ1BNg==", + "dev": true + }, "find-up": { "version": "1.1.2", "resolved": "https://registry.npmjs.org/find-up/-/find-up-1.1.2.tgz", @@ -18940,6 +18964,14 @@ "requires": { "camelcase": "^3.0.0", "object.assign": "^4.1.0" + }, + "dependencies": { + "camelcase": { + "version": "3.0.0", + "resolved": "https://registry.npmjs.org/camelcase/-/camelcase-3.0.0.tgz", + "integrity": "sha512-4nhGqUkc4BqbBBB4Q6zLuD7lzzrHYrjKGeYaEji/3tFR5VdJu9v+LilhGIVe8wxEJPPOeWo7eg8dwY13TZ1BNg==", + "dev": true + } } }, "yocto-queue": { diff --git a/package.json b/package.json index 385bc096..c8f13b1a 100644 --- a/package.json +++ b/package.json @@ -37,6 +37,7 @@ "@fortawesome/fontawesome-free": "^5.15.4", "activedirectory2": "^2.1.0", "better-sqlite3": "^7.6.2", + "camelcase": "^7.0.0", "compression": "^1.7.4", "cookie-parser": "^1.4.6", "cross-env": "^7.0.3", @@ -49,6 +50,7 @@ "express-session": "^1.17.3", "http-errors": "^2.0.0", "leaflet": "^1.8.0", + "papaparse": "^5.3.2", "session-file-store": "^1.5.0" }, "devDependencies": { @@ -86,7 +88,6 @@ "gulp-minify": "^3.1.0", "gulp-sass": "^5.1.0", "nodemon": "^2.0.19", - "papaparse": "^5.3.2", "sass": "^1.54.5" } } diff --git a/public-typescript/lotOccupancyEdit.js b/public-typescript/lotOccupancyEdit.js index 34f00c6e..ac80ad01 100644 --- a/public-typescript/lotOccupancyEdit.js +++ b/public-typescript/lotOccupancyEdit.js @@ -896,6 +896,14 @@ Object.defineProperty(exports, "__esModule", { value: true }); lotOccupancyTransactionsContainerElement.querySelector("#lotOccupancyTransactions--grandTotal").textContent = "$" + transactionGrandTotal.toFixed(2); const feeGrandTotal = getFeeGrandTotal(); if (feeGrandTotal > transactionGrandTotal) { + lotOccupancyTransactionsContainerElement.insertAdjacentHTML("afterbegin", "
" + + "
" + + "
" + + "
Outstanding Balance
" + + "
$" + (feeGrandTotal - transactionGrandTotal).toFixed(2) + "
" + + "
" + + "
" + + "
"); } }; document.querySelector("#button--addTransaction").addEventListener("click", () => { diff --git a/public-typescript/lotOccupancyEdit.ts b/public-typescript/lotOccupancyEdit.ts index d77ec86c..0368a418 100644 --- a/public-typescript/lotOccupancyEdit.ts +++ b/public-typescript/lotOccupancyEdit.ts @@ -1247,10 +1247,15 @@ declare const bulmaJS: BulmaJS; if (feeGrandTotal > transactionGrandTotal) { - /* lotOccupancyTransactionsContainerElement.insertAdjacentHTML("afterbegin", - "
" + + "
" + + "
" + + "
Outstanding Balance
" + + "
$" + (feeGrandTotal - transactionGrandTotal).toFixed(2) + "
" + + "
" + + "
" + + "
"); } }; diff --git a/public/javascripts/lotOccupancyEdit.min.js b/public/javascripts/lotOccupancyEdit.min.js index a287ace1..9d0c387c 100644 --- a/public/javascripts/lotOccupancyEdit.min.js +++ b/public/javascripts/lotOccupancyEdit.min.js @@ -1 +1 @@ -"use strict";Object.defineProperty(exports,"__esModule",{value:!0}),(()=>{const t=exports.los,e=document.querySelector("main").dataset.urlPrefix,c=document.querySelector("#lotOccupancy--lotOccupancyId").value,a=""===c;let o=!1,n=a;const s=()=>{o||(o=!0,cityssm.enableNavBlocker())},l=document.querySelector("#form--lotOccupancy");l.addEventListener("submit",t=>{t.preventDefault(),cityssm.postJSON(e+"/lotOccupancies/"+(a?"doCreateLotOccupancy":"doUpdateLotOccupancy"),l,t=>{t.success?(o=!1,cityssm.disableNavBlocker(),a||n?window.location.href=e+"/lotOccupancies/"+t.lotOccupancyId+"/edit?t="+Date.now():bulmaJS.alert({message:exports.aliases.occupancy+" Updated Successfully",contextualColorName:"success"})):bulmaJS.alert({title:"Error Saving "+exports.aliases.occupancy,message:t.errorMessage,contextualColorName:"danger"})})});const r=l.querySelectorAll("input, select");for(const t of r)t.addEventListener("change",s);a||document.querySelector("#button--deleteLotOccupancy").addEventListener("click",t=>{t.preventDefault();bulmaJS.confirm({title:"Delete "+exports.aliases.occupancy+" Record",message:"Are you sure you want to delete this record?",contextualColorName:"warning",okButton:{text:"Yes, Delete",callbackFunction:()=>{cityssm.postJSON(e+"/lotOccupancies/doDeleteLotOccupancy",{lotOccupancyId:c},t=>{t.success?window.location.href=e+"/lotOccupancies?t="+Date.now():bulmaJS.alert({title:"Error Deleting Record",message:t.errorMessage,contextualColorName:"danger"})})}}})});const u=document.querySelector("#lotOccupancy--occupancyTypeId");if(a){const t=document.querySelector("#container--lotOccupancyFields");u.addEventListener("change",()=>{""!==u.value?cityssm.postJSON(e+"/lotOccupancies/doGetOccupancyTypeFields",{occupancyTypeId:u.value},e=>{if(0===e.occupancyTypeFields.length)return void(t.innerHTML='

There are no additional fields for this '+exports.aliases.occupancy.toLowerCase()+" type.

");t.innerHTML="";let c="";for(const a of e.occupancyTypeFields){c+=","+a.occupancyTypeFieldId;const e=document.createElement("div");e.className="field",e.innerHTML='
',e.querySelector("label").textContent=a.occupancyTypeField;const o=document.createElement("input");o.className="input",o.id="lotOccupancy--lotOccupancyFieldValue_"+a.occupancyTypeFieldId,o.name="lotOccupancyFieldValue_"+a.occupancyTypeFieldId,o.type="text",o.required=a.isRequired,o.minLength=a.minimumLength,o.maxLength=a.maximumLength,a.pattern&&""!==a.pattern&&(o.pattern=a.pattern),e.querySelector(".control").append(o),t.append(e)}t.insertAdjacentHTML("beforeend",'')}):t.innerHTML='

Select the '+exports.aliases.occupancy.toLowerCase()+" type to load the available fields.

"})}else{const t=u.value;u.addEventListener("change",()=>{u.value!==t&&bulmaJS.confirm({title:"Confirm Change",message:"Are you sure you want to change the "+exports.aliases.occupancy.toLowerCase()+" type?\nThis change affects the additional fields associated with this record, and may also affect the available fees.",contextualColorName:"warning",okButton:{text:"Yes, Keep the Change",callbackFunction:()=>{n=!0}},cancelButton:{text:"Revert the Change",callbackFunction:()=>{u.value=t}}})})}if(document.querySelector("#lotOccupancy--lotName").addEventListener("click",c=>{const a=c.currentTarget.value;let o,n,l;const r=t=>{t.preventDefault();const e=t.currentTarget;document.querySelector("#lotOccupancy--lotId").value=e.dataset.lotId,document.querySelector("#lotOccupancy--lotName").value=e.dataset.lotName,s(),o()},u=()=>{l.innerHTML='


Searching...

',cityssm.postJSON(e+"/lots/doSearchLots",n,t=>{if(0===t.count)return void(l.innerHTML='

No results.

');const e=document.createElement("div");e.className="panel";for(const c of t.lots){const t=document.createElement("a");t.className="panel-block is-block",t.href="#",t.dataset.lotId=c.lotId.toString(),t.dataset.lotName=c.lotName,t.innerHTML='
'+cityssm.escapeHTML(c.lotName)+'
'+cityssm.escapeHTML(c.mapName)+'
'+cityssm.escapeHTML(c.lotStatus)+'
'+(c.lotOccupancyCount>0?"Currently Occupied":"")+"
",t.addEventListener("click",r),e.append(t)}l.innerHTML="",l.append(e)})};cityssm.openHtmlModal("lotOccupancy-selectLot",{onshow:e=>{t.populateAliases(e)},onshown:(t,e)=>{bulmaJS.toggleHtmlClipped(),o=e;const c=t.querySelector("#lotSelect--lotName");c.value=a,c.focus(),c.addEventListener("change",u),t.querySelector("#lotSelect--occupancyStatus").addEventListener("change",u),n=t.querySelector("#form--lotSelect"),l=t.querySelector("#resultsContainer--lotSelect"),n.addEventListener("submit",t=>{t.preventDefault()}),u()},onremoved:()=>{bulmaJS.toggleHtmlClipped()}})}),document.querySelector("#lotOccupancy--occupancyStartDateString").addEventListener("change",()=>{document.querySelector("#lotOccupancy--occupancyEndDateString").min=document.querySelector("#lotOccupancy--occupancyStartDateString").value}),t.initializeUnlockFieldButtons(l),!a){let a=exports.lotOccupancyOccupants;const o=o=>{const n=Number.parseInt(o.currentTarget.closest("tr").dataset.lotOccupantIndex,10),l=a.find(t=>t.lotOccupantIndex===n);let r,u;const i=t=>{t.preventDefault(),cityssm.postJSON(e+"/lotOccupancies/doUpdateLotOccupancyOccupant",r,t=>{t.success?(a=t.lotOccupancyOccupants,u(),s()):bulmaJS.alert({title:"Error Updating "+exports.aliases.occupant,message:t.errorMessage,contextualColorName:"danger"})})};cityssm.openHtmlModal("lotOccupancy-editOccupant",{onshow:e=>{t.populateAliases(e),e.querySelector("#lotOccupancyOccupantEdit--lotOccupancyId").value=c,e.querySelector("#lotOccupancyOccupantEdit--lotOccupantIndex").value=n.toString();const a=e.querySelector("#lotOccupancyOccupantEdit--lotOccupantTypeId");let o=!1;for(const t of exports.lotOccupantTypes){const e=document.createElement("option");e.value=t.lotOccupantTypeId.toString(),e.textContent=t.lotOccupantType,t.lotOccupantTypeId===l.lotOccupantTypeId&&(e.selected=!0,o=!0),a.append(e)}if(!o){const t=document.createElement("option");t.value=l.lotOccupantTypeId.toString(),t.textContent=l.lotOccupantType,t.selected=!0,a.append(t)}e.querySelector("#lotOccupancyOccupantEdit--occupantName").value=l.occupantName,e.querySelector("#lotOccupancyOccupantEdit--occupantAddress1").value=l.occupantAddress1,e.querySelector("#lotOccupancyOccupantEdit--occupantAddress2").value=l.occupantAddress2,e.querySelector("#lotOccupancyOccupantEdit--occupantCity").value=l.occupantCity,e.querySelector("#lotOccupancyOccupantEdit--occupantProvince").value=l.occupantProvince,e.querySelector("#lotOccupancyOccupantEdit--occupantPostalCode").value=l.occupantPostalCode,e.querySelector("#lotOccupancyOccupantEdit--occupantPhoneNumber").value=l.occupantPhoneNumber},onshown:(t,e)=>{bulmaJS.toggleHtmlClipped(),t.querySelector("#lotOccupancyOccupantEdit--lotOccupantTypeId").focus(),(r=t.querySelector("form")).addEventListener("submit",i),u=e},onremoved:()=>{bulmaJS.toggleHtmlClipped()}})},n=t=>{const o=t.currentTarget.closest("tr").dataset.lotOccupantIndex;bulmaJS.confirm({title:"Remove "+exports.aliases.occupant+"?",message:"Are you sure you want to remove this "+exports.aliases.occupant.toLowerCase()+"?",okButton:{text:"Yes, Remove "+exports.aliases.occupant,callbackFunction:()=>{cityssm.postJSON(e+"/lotOccupancies/doDeleteLotOccupancyOccupant",{lotOccupancyId:c,lotOccupantIndex:o},t=>{t.success?(a=t.lotOccupancyOccupants,s()):bulmaJS.alert({title:"Error Removing "+exports.aliases.occupant,message:t.errorMessage,contextualColorName:"danger"})})}},contextualColorName:"warning"})},s=()=>{const t=document.querySelector("#container--lotOccupancyOccupants");if(cityssm.clearElement(t),0===a.length)return void(t.innerHTML='

There are no '+exports.aliases.occupants.toLowerCase()+" associated with this record.

");const e=document.createElement("table");e.className="table is-fullwidth is-striped is-hoverable",e.innerHTML=""+exports.aliases.occupant+" Type"+exports.aliases.occupant+"AddressPhone Number";for(const t of a){const c=document.createElement("tr");c.dataset.lotOccupantIndex=t.lotOccupantIndex.toString(),c.innerHTML=""+cityssm.escapeHTML(t.lotOccupantType)+""+cityssm.escapeHTML(t.occupantName)+""+cityssm.escapeHTML(t.occupantAddress1)+"
"+(t.occupantAddress2?cityssm.escapeHTML(t.occupantAddress2)+"
":"")+cityssm.escapeHTML(t.occupantCity)+", "+cityssm.escapeHTML(t.occupantProvince)+"
"+cityssm.escapeHTML(t.occupantPostalCode)+""+cityssm.escapeHTML(t.occupantPhoneNumber)+'
',c.querySelector(".button--edit").addEventListener("click",o),c.querySelector(".button--delete").addEventListener("click",n),e.querySelector("tbody").append(c)}t.append(e)};document.querySelector("#button--addOccupant").addEventListener("click",()=>{let o,n;const l=t=>{t.preventDefault(),cityssm.postJSON(e+"/lotOccupancies/doAddLotOccupancyOccupant",o,t=>{t.success?(a=t.lotOccupancyOccupants,n(),s()):bulmaJS.alert({title:"Error Adding "+exports.aliases.occupant,message:t.errorMessage,contextualColorName:"danger"})})};cityssm.openHtmlModal("lotOccupancy-addOccupant",{onshow:e=>{t.populateAliases(e),e.querySelector("#lotOccupancyOccupantAdd--lotOccupancyId").value=c;const a=e.querySelector("#lotOccupancyOccupantAdd--lotOccupantTypeId");for(const t of exports.lotOccupantTypes){const e=document.createElement("option");e.value=t.lotOccupantTypeId.toString(),e.textContent=t.lotOccupantType,a.append(e)}e.querySelector("#lotOccupancyOccupantAdd--occupantCity").value=exports.occupantCityDefault,e.querySelector("#lotOccupancyOccupantAdd--occupantProvince").value=exports.occupantProvinceDefault},onshown:(t,e)=>{bulmaJS.toggleHtmlClipped(),t.querySelector("#lotOccupancyOccupantAdd--lotOccupantTypeId").focus(),(o=t.querySelector("form")).addEventListener("submit",l),n=e},onremoved:()=>{bulmaJS.toggleHtmlClipped()}})}),s()}if(!a){let a=exports.lotOccupancyComments;const o=o=>{const n=Number.parseInt(o.currentTarget.closest("tr").dataset.lotOccupancyCommentId,10),l=a.find(t=>t.lotOccupancyCommentId===n);let r,u;const i=t=>{t.preventDefault(),cityssm.postJSON(e+"/lotOccupancies/doUpdateLotOccupancyComment",r,t=>{t.success?(a=t.lotOccupancyComments,u(),s()):bulmaJS.alert({title:"Error Updating Comment",message:t.errorMessage,contextualColorName:"danger"})})};cityssm.openHtmlModal("lotOccupancy-editComment",{onshow:e=>{t.populateAliases(e),e.querySelector("#lotOccupancyCommentEdit--lotOccupancyId").value=c,e.querySelector("#lotOccupancyCommentEdit--lotOccupancyCommentId").value=n.toString(),e.querySelector("#lotOccupancyCommentEdit--lotOccupancyComment").value=l.lotOccupancyComment,e.querySelector("#lotOccupancyCommentEdit--lotOccupancyCommentDateString").value=l.lotOccupancyCommentDateString,e.querySelector("#lotOccupancyCommentEdit--lotOccupancyCommentTimeString").value=l.lotOccupancyCommentTimeString},onshown:(t,e)=>{bulmaJS.toggleHtmlClipped(),t.querySelector("#lotOccupancyCommentEdit--lotOccupancyComment").focus(),(r=t.querySelector("form")).addEventListener("submit",i),u=e},onremoved:()=>{bulmaJS.toggleHtmlClipped()}})},n=t=>{const o=Number.parseInt(t.currentTarget.closest("tr").dataset.lotOccupancyCommentId,10);bulmaJS.confirm({title:"Remove Comment?",message:"Are you sure you want to remove this comment?",okButton:{text:"Yes, Remove Comment",callbackFunction:()=>{cityssm.postJSON(e+"/lotOccupancies/doDeleteLotOccupancyComment",{lotOccupancyId:c,lotOccupancyCommentId:o},t=>{t.success?(a=t.lotOccupancyComments,s()):bulmaJS.alert({title:"Error Removing Comment",message:t.errorMessage,contextualColorName:"danger"})})}},contextualColorName:"warning"})},s=()=>{const t=document.querySelector("#container--lotOccupancyComments");if(0===a.length)return void(t.innerHTML='

There are no comments associated with this record.

');const e=document.createElement("table");e.className="table is-fullwidth is-striped is-hoverable",e.innerHTML='CommentorComment DateCommentOptions';for(const t of a){const c=document.createElement("tr");c.dataset.lotOccupancyCommentId=t.lotOccupancyCommentId.toString(),c.innerHTML=""+cityssm.escapeHTML(t.recordCreate_userName)+""+t.lotOccupancyCommentDateString+(0===t.lotOccupancyCommentTime?"":" "+t.lotOccupancyCommentTimeString)+""+cityssm.escapeHTML(t.lotOccupancyComment)+'
',c.querySelector(".button--edit").addEventListener("click",o),c.querySelector(".button--delete").addEventListener("click",n),e.querySelector("tbody").append(c)}t.innerHTML="",t.append(e)};document.querySelector("#button--addComment").addEventListener("click",()=>{let o,n;const l=t=>{t.preventDefault(),cityssm.postJSON(e+"/lotOccupancies/doAddLotOccupancyComment",o,t=>{t.success?(a=t.lotOccupancyComments,n(),s()):bulmaJS.alert({title:"Error Adding Comment",message:t.errorMessage,contextualColorName:"danger"})})};cityssm.openHtmlModal("lotOccupancy-addComment",{onshow:e=>{t.populateAliases(e),e.querySelector("#lotOccupancyCommentAdd--lotOccupancyId").value=c},onshown:(t,e)=>{bulmaJS.toggleHtmlClipped(),t.querySelector("#lotOccupancyCommentAdd--lotOccupancyComment").focus(),(o=t.querySelector("form")).addEventListener("submit",l),n=e},onremoved:()=>{bulmaJS.toggleHtmlClipped()}})}),s()}if(!a){let a=exports.lotOccupancyFees;const n=document.querySelector("#container--lotOccupancyFees"),s=()=>{let t=0;for(const e of a)t+=(e.feeAmount+e.taxAmount)*e.quantity;return t},l=t=>{const o=t.currentTarget.closest(".container--lotOccupancyFee").dataset.feeId;bulmaJS.confirm({title:"Delete Fee",message:"Are you sure you want to delete this fee?",contextualColorName:"warning",okButton:{text:"Yes, Delete Fee",callbackFunction:()=>{cityssm.postJSON(e+"/lotOccupancies/doDeleteLotOccupancyFee",{lotOccupancyId:c,feeId:o},t=>{t.success?(a=t.lotOccupancyFees,r()):bulmaJS.alert({title:"Error Deleting Fee",message:t.errorMessage,contextualColorName:"danger"})})}}})},r=()=>{if(0===a.length)return void(n.innerHTML='

There are no fees associated with this record.

');n.innerHTML='
FeeUnit Cost×QuantityequalsTotalOptions
Subtotal
Tax
Grand Total
';let t=0,e=0;for(const c of a){const a=document.createElement("tr");a.className="container--lotOccupancyFee",a.dataset.feeId=c.feeId.toString(),a.innerHTML=''+cityssm.escapeHTML(c.feeName)+""+(1===c.quantity?"":'$'+c.feeAmount.toFixed(2)+'×'+c.quantity+"=")+'$'+(c.feeAmount*c.quantity).toFixed(2)+'',a.querySelector("button").addEventListener("click",l),n.querySelector("tbody").append(a),t+=c.feeAmount*c.quantity,e+=c.taxAmount*c.quantity}n.querySelector("#lotOccupancyFees--feeAmountTotal").textContent="$"+t.toFixed(2),n.querySelector("#lotOccupancyFees--taxAmountTotal").textContent="$"+e.toFixed(2),n.querySelector("#lotOccupancyFees--grandTotal").textContent="$"+(t+e).toFixed(2),m()};document.querySelector("#button--addFee").addEventListener("click",()=>{if(o)return void bulmaJS.alert({message:"Please save all unsaved changes before adding fees.",contextualColorName:"warning"});let t,s,l;const u=(t,o=1)=>{cityssm.postJSON(e+"/lotOccupancies/doAddLotOccupancyFee",{lotOccupancyId:c,feeId:t,quantity:o},t=>{t.success?(a=t.lotOccupancyFees,r(),d()):bulmaJS.alert({title:"Error Adding Fee",message:t.errorMessage,contextualColorName:"danger"})})},i=e=>{e.preventDefault();const c=Number.parseInt(e.currentTarget.dataset.feeId,10),a=Number.parseInt(e.currentTarget.closest(".container--feeCategory").dataset.feeCategoryId,10),o=t.find(t=>t.feeCategoryId===a).fees.find(t=>t.feeId===c);o.includeQuantity?(t=>{let e,c;const a=a=>{a.preventDefault(),u(t.feeId,e.value),c()};cityssm.openHtmlModal("lotOccupancy-setFeeQuantity",{onshow:e=>{e.querySelector("#lotOccupancyFeeQuantity--quantityUnit").textContent=t.quantityUnit},onshown:(t,o)=>{c=o,e=t.querySelector("#lotOccupancyFeeQuantity--quantity"),t.querySelector("form").addEventListener("submit",a)}})})(o):u(c)},d=()=>{const e=s.value.trim().toLowerCase().split(" ");l.innerHTML="";for(const c of t){const t=document.createElement("div");t.className="container--feeCategory",t.dataset.feeCategoryId=c.feeCategoryId.toString(),t.innerHTML='

'+cityssm.escapeHTML(c.feeCategory)+'

';let a=!1;for(const o of c.fees){if(n.querySelector(".container--lotOccupancyFee[data-fee-id='"+o.feeId+"']"))continue;let c=!0;for(const t of e)if(!o.feeName.toLowerCase().includes(t)){c=!1;break}if(!c)continue;a=!0;const s=document.createElement("a");s.className="panel-block is-block container--fee",s.dataset.feeId=o.feeId.toString(),s.href="#",s.innerHTML=""+cityssm.escapeHTML(o.feeName)+"
"+cityssm.escapeHTML(o.feeDescription).replace(/\n/g,"
")+"
",s.addEventListener("click",i),t.querySelector(".panel").append(s)}a&&l.append(t)}};cityssm.openHtmlModal("lotOccupancy-addFee",{onshow:a=>{s=a.querySelector("#feeSelect--feeName"),l=a.querySelector("#resultsContainer--feeSelect"),cityssm.postJSON(e+"/lotOccupancies/doGetFees",{lotOccupancyId:c},e=>{t=e.feeCategories,s.disabled=!1,s.addEventListener("keyup",d),s.focus(),d()})},onshown:()=>{bulmaJS.toggleHtmlClipped()},onhidden:()=>{r()},onremoved:()=>{bulmaJS.toggleHtmlClipped()}})});let u=exports.lotOccupancyTransactions;const i=document.querySelector("#container--lotOccupancyTransactions"),d=()=>{let t=0;for(const e of u)t+=e.transactionAmount;return t},p=t=>{const a=t.currentTarget.closest(".container--lotOccupancyTransaction").dataset.transactionIndex;bulmaJS.confirm({title:"Delete Trasnaction",message:"Are you sure you want to delete this transaction?",contextualColorName:"warning",okButton:{text:"Yes, Delete Transaction",callbackFunction:()=>{cityssm.postJSON(e+"/lotOccupancies/doDeleteLotOccupancyTransaction",{lotOccupancyId:c,transactionIndex:a},t=>{t.success?(u=t.lotOccupancyTransactions,m()):bulmaJS.alert({title:"Error Deleting Transaction",message:t.errorMessage,contextualColorName:"danger"})})}}})},m=()=>{if(0===u.length)return void(i.innerHTML='

There are no transactions associated with this record.

');i.innerHTML='
Date'+cityssm.escapeHTML(exports.aliases.externalReceiptNumber)+'AmountOptions
Transaction Total
';let t=0;for(const e of u){t+=e.transactionAmount;const c=document.createElement("tr");c.className="container--lotOccupancyTransaction",c.dataset.transactionIndex=e.transactionIndex.toString(),c.innerHTML=""+e.transactionDateString+""+cityssm.escapeHTML(e.externalReceiptNumber)+"
"+cityssm.escapeHTML(e.transactionNote)+'$'+e.transactionAmount.toFixed(2)+'',c.querySelector("button").addEventListener("click",p),i.querySelector("tbody").append(c)}i.querySelector("#lotOccupancyTransactions--grandTotal").textContent="$"+t.toFixed(2);s()};document.querySelector("#button--addTransaction").addEventListener("click",()=>{let a;const o=t=>{t.preventDefault(),cityssm.postJSON(e+"/lotOccupancies/doAddLotOccupancyTransaction",t.currentTarget,t=>{t.success?(u=t.lotOccupancyTransactions,a(),m()):bulmaJS.confirm({title:"Error Adding Transaction",message:t.errorMessage,contextualColorName:"danger"})})};cityssm.openHtmlModal("lotOccupancy-addTransaction",{onshow:e=>{t.populateAliases(e),e.querySelector("#lotOccupancyTransactionAdd--lotOccupancyId").value=c.toString();const a=s(),o=d(),n=e.querySelector("#lotOccupancyTransactionAdd--transactionAmount");n.min=(-1*o).toFixed(2),n.max=Math.max(a-o,0).toFixed(2),n.value=Math.max(a-o,0).toFixed(2)},onshown:(t,e)=>{bulmaJS.toggleHtmlClipped(),a=e,t.querySelector("form").addEventListener("submit",o)},onremoved:()=>{bulmaJS.toggleHtmlClipped()}})}),r()}})(); \ No newline at end of file +"use strict";Object.defineProperty(exports,"__esModule",{value:!0}),(()=>{const e=exports.los,t=document.querySelector("main").dataset.urlPrefix,c=document.querySelector("#lotOccupancy--lotOccupancyId").value,a=""===c;let o=!1,n=a;const s=()=>{o||(o=!0,cityssm.enableNavBlocker())},l=document.querySelector("#form--lotOccupancy");l.addEventListener("submit",e=>{e.preventDefault(),cityssm.postJSON(t+"/lotOccupancies/"+(a?"doCreateLotOccupancy":"doUpdateLotOccupancy"),l,e=>{e.success?(o=!1,cityssm.disableNavBlocker(),a||n?window.location.href=t+"/lotOccupancies/"+e.lotOccupancyId+"/edit?t="+Date.now():bulmaJS.alert({message:exports.aliases.occupancy+" Updated Successfully",contextualColorName:"success"})):bulmaJS.alert({title:"Error Saving "+exports.aliases.occupancy,message:e.errorMessage,contextualColorName:"danger"})})});const r=l.querySelectorAll("input, select");for(const e of r)e.addEventListener("change",s);a||document.querySelector("#button--deleteLotOccupancy").addEventListener("click",e=>{e.preventDefault();bulmaJS.confirm({title:"Delete "+exports.aliases.occupancy+" Record",message:"Are you sure you want to delete this record?",contextualColorName:"warning",okButton:{text:"Yes, Delete",callbackFunction:()=>{cityssm.postJSON(t+"/lotOccupancies/doDeleteLotOccupancy",{lotOccupancyId:c},e=>{e.success?window.location.href=t+"/lotOccupancies?t="+Date.now():bulmaJS.alert({title:"Error Deleting Record",message:e.errorMessage,contextualColorName:"danger"})})}}})});const u=document.querySelector("#lotOccupancy--occupancyTypeId");if(a){const e=document.querySelector("#container--lotOccupancyFields");u.addEventListener("change",()=>{""!==u.value?cityssm.postJSON(t+"/lotOccupancies/doGetOccupancyTypeFields",{occupancyTypeId:u.value},t=>{if(0===t.occupancyTypeFields.length)return void(e.innerHTML='

There are no additional fields for this '+exports.aliases.occupancy.toLowerCase()+" type.

");e.innerHTML="";let c="";for(const a of t.occupancyTypeFields){c+=","+a.occupancyTypeFieldId;const t=document.createElement("div");t.className="field",t.innerHTML='
',t.querySelector("label").textContent=a.occupancyTypeField;const o=document.createElement("input");o.className="input",o.id="lotOccupancy--lotOccupancyFieldValue_"+a.occupancyTypeFieldId,o.name="lotOccupancyFieldValue_"+a.occupancyTypeFieldId,o.type="text",o.required=a.isRequired,o.minLength=a.minimumLength,o.maxLength=a.maximumLength,a.pattern&&""!==a.pattern&&(o.pattern=a.pattern),t.querySelector(".control").append(o),e.append(t)}e.insertAdjacentHTML("beforeend",'')}):e.innerHTML='

Select the '+exports.aliases.occupancy.toLowerCase()+" type to load the available fields.

"})}else{const e=u.value;u.addEventListener("change",()=>{u.value!==e&&bulmaJS.confirm({title:"Confirm Change",message:"Are you sure you want to change the "+exports.aliases.occupancy.toLowerCase()+" type?\nThis change affects the additional fields associated with this record, and may also affect the available fees.",contextualColorName:"warning",okButton:{text:"Yes, Keep the Change",callbackFunction:()=>{n=!0}},cancelButton:{text:"Revert the Change",callbackFunction:()=>{u.value=e}}})})}if(document.querySelector("#lotOccupancy--lotName").addEventListener("click",c=>{const a=c.currentTarget.value;let o,n,l;const r=e=>{e.preventDefault();const t=e.currentTarget;document.querySelector("#lotOccupancy--lotId").value=t.dataset.lotId,document.querySelector("#lotOccupancy--lotName").value=t.dataset.lotName,s(),o()},u=()=>{l.innerHTML='


Searching...

',cityssm.postJSON(t+"/lots/doSearchLots",n,e=>{if(0===e.count)return void(l.innerHTML='

No results.

');const t=document.createElement("div");t.className="panel";for(const c of e.lots){const e=document.createElement("a");e.className="panel-block is-block",e.href="#",e.dataset.lotId=c.lotId.toString(),e.dataset.lotName=c.lotName,e.innerHTML='
'+cityssm.escapeHTML(c.lotName)+'
'+cityssm.escapeHTML(c.mapName)+'
'+cityssm.escapeHTML(c.lotStatus)+'
'+(c.lotOccupancyCount>0?"Currently Occupied":"")+"
",e.addEventListener("click",r),t.append(e)}l.innerHTML="",l.append(t)})};cityssm.openHtmlModal("lotOccupancy-selectLot",{onshow:t=>{e.populateAliases(t)},onshown:(e,t)=>{bulmaJS.toggleHtmlClipped(),o=t;const c=e.querySelector("#lotSelect--lotName");c.value=a,c.focus(),c.addEventListener("change",u),e.querySelector("#lotSelect--occupancyStatus").addEventListener("change",u),n=e.querySelector("#form--lotSelect"),l=e.querySelector("#resultsContainer--lotSelect"),n.addEventListener("submit",e=>{e.preventDefault()}),u()},onremoved:()=>{bulmaJS.toggleHtmlClipped()}})}),document.querySelector("#lotOccupancy--occupancyStartDateString").addEventListener("change",()=>{document.querySelector("#lotOccupancy--occupancyEndDateString").min=document.querySelector("#lotOccupancy--occupancyStartDateString").value}),e.initializeUnlockFieldButtons(l),!a){let a=exports.lotOccupancyOccupants;const o=o=>{const n=Number.parseInt(o.currentTarget.closest("tr").dataset.lotOccupantIndex,10),l=a.find(e=>e.lotOccupantIndex===n);let r,u;const i=e=>{e.preventDefault(),cityssm.postJSON(t+"/lotOccupancies/doUpdateLotOccupancyOccupant",r,e=>{e.success?(a=e.lotOccupancyOccupants,u(),s()):bulmaJS.alert({title:"Error Updating "+exports.aliases.occupant,message:e.errorMessage,contextualColorName:"danger"})})};cityssm.openHtmlModal("lotOccupancy-editOccupant",{onshow:t=>{e.populateAliases(t),t.querySelector("#lotOccupancyOccupantEdit--lotOccupancyId").value=c,t.querySelector("#lotOccupancyOccupantEdit--lotOccupantIndex").value=n.toString();const a=t.querySelector("#lotOccupancyOccupantEdit--lotOccupantTypeId");let o=!1;for(const e of exports.lotOccupantTypes){const t=document.createElement("option");t.value=e.lotOccupantTypeId.toString(),t.textContent=e.lotOccupantType,e.lotOccupantTypeId===l.lotOccupantTypeId&&(t.selected=!0,o=!0),a.append(t)}if(!o){const e=document.createElement("option");e.value=l.lotOccupantTypeId.toString(),e.textContent=l.lotOccupantType,e.selected=!0,a.append(e)}t.querySelector("#lotOccupancyOccupantEdit--occupantName").value=l.occupantName,t.querySelector("#lotOccupancyOccupantEdit--occupantAddress1").value=l.occupantAddress1,t.querySelector("#lotOccupancyOccupantEdit--occupantAddress2").value=l.occupantAddress2,t.querySelector("#lotOccupancyOccupantEdit--occupantCity").value=l.occupantCity,t.querySelector("#lotOccupancyOccupantEdit--occupantProvince").value=l.occupantProvince,t.querySelector("#lotOccupancyOccupantEdit--occupantPostalCode").value=l.occupantPostalCode,t.querySelector("#lotOccupancyOccupantEdit--occupantPhoneNumber").value=l.occupantPhoneNumber},onshown:(e,t)=>{bulmaJS.toggleHtmlClipped(),e.querySelector("#lotOccupancyOccupantEdit--lotOccupantTypeId").focus(),(r=e.querySelector("form")).addEventListener("submit",i),u=t},onremoved:()=>{bulmaJS.toggleHtmlClipped()}})},n=e=>{const o=e.currentTarget.closest("tr").dataset.lotOccupantIndex;bulmaJS.confirm({title:"Remove "+exports.aliases.occupant+"?",message:"Are you sure you want to remove this "+exports.aliases.occupant.toLowerCase()+"?",okButton:{text:"Yes, Remove "+exports.aliases.occupant,callbackFunction:()=>{cityssm.postJSON(t+"/lotOccupancies/doDeleteLotOccupancyOccupant",{lotOccupancyId:c,lotOccupantIndex:o},e=>{e.success?(a=e.lotOccupancyOccupants,s()):bulmaJS.alert({title:"Error Removing "+exports.aliases.occupant,message:e.errorMessage,contextualColorName:"danger"})})}},contextualColorName:"warning"})},s=()=>{const e=document.querySelector("#container--lotOccupancyOccupants");if(cityssm.clearElement(e),0===a.length)return void(e.innerHTML='

There are no '+exports.aliases.occupants.toLowerCase()+" associated with this record.

");const t=document.createElement("table");t.className="table is-fullwidth is-striped is-hoverable",t.innerHTML=""+exports.aliases.occupant+" Type"+exports.aliases.occupant+"AddressPhone Number";for(const e of a){const c=document.createElement("tr");c.dataset.lotOccupantIndex=e.lotOccupantIndex.toString(),c.innerHTML=""+cityssm.escapeHTML(e.lotOccupantType)+""+cityssm.escapeHTML(e.occupantName)+""+cityssm.escapeHTML(e.occupantAddress1)+"
"+(e.occupantAddress2?cityssm.escapeHTML(e.occupantAddress2)+"
":"")+cityssm.escapeHTML(e.occupantCity)+", "+cityssm.escapeHTML(e.occupantProvince)+"
"+cityssm.escapeHTML(e.occupantPostalCode)+""+cityssm.escapeHTML(e.occupantPhoneNumber)+'
',c.querySelector(".button--edit").addEventListener("click",o),c.querySelector(".button--delete").addEventListener("click",n),t.querySelector("tbody").append(c)}e.append(t)};document.querySelector("#button--addOccupant").addEventListener("click",()=>{let o,n;const l=e=>{e.preventDefault(),cityssm.postJSON(t+"/lotOccupancies/doAddLotOccupancyOccupant",o,e=>{e.success?(a=e.lotOccupancyOccupants,n(),s()):bulmaJS.alert({title:"Error Adding "+exports.aliases.occupant,message:e.errorMessage,contextualColorName:"danger"})})};cityssm.openHtmlModal("lotOccupancy-addOccupant",{onshow:t=>{e.populateAliases(t),t.querySelector("#lotOccupancyOccupantAdd--lotOccupancyId").value=c;const a=t.querySelector("#lotOccupancyOccupantAdd--lotOccupantTypeId");for(const e of exports.lotOccupantTypes){const t=document.createElement("option");t.value=e.lotOccupantTypeId.toString(),t.textContent=e.lotOccupantType,a.append(t)}t.querySelector("#lotOccupancyOccupantAdd--occupantCity").value=exports.occupantCityDefault,t.querySelector("#lotOccupancyOccupantAdd--occupantProvince").value=exports.occupantProvinceDefault},onshown:(e,t)=>{bulmaJS.toggleHtmlClipped(),e.querySelector("#lotOccupancyOccupantAdd--lotOccupantTypeId").focus(),(o=e.querySelector("form")).addEventListener("submit",l),n=t},onremoved:()=>{bulmaJS.toggleHtmlClipped()}})}),s()}if(!a){let a=exports.lotOccupancyComments;const o=o=>{const n=Number.parseInt(o.currentTarget.closest("tr").dataset.lotOccupancyCommentId,10),l=a.find(e=>e.lotOccupancyCommentId===n);let r,u;const i=e=>{e.preventDefault(),cityssm.postJSON(t+"/lotOccupancies/doUpdateLotOccupancyComment",r,e=>{e.success?(a=e.lotOccupancyComments,u(),s()):bulmaJS.alert({title:"Error Updating Comment",message:e.errorMessage,contextualColorName:"danger"})})};cityssm.openHtmlModal("lotOccupancy-editComment",{onshow:t=>{e.populateAliases(t),t.querySelector("#lotOccupancyCommentEdit--lotOccupancyId").value=c,t.querySelector("#lotOccupancyCommentEdit--lotOccupancyCommentId").value=n.toString(),t.querySelector("#lotOccupancyCommentEdit--lotOccupancyComment").value=l.lotOccupancyComment,t.querySelector("#lotOccupancyCommentEdit--lotOccupancyCommentDateString").value=l.lotOccupancyCommentDateString,t.querySelector("#lotOccupancyCommentEdit--lotOccupancyCommentTimeString").value=l.lotOccupancyCommentTimeString},onshown:(e,t)=>{bulmaJS.toggleHtmlClipped(),e.querySelector("#lotOccupancyCommentEdit--lotOccupancyComment").focus(),(r=e.querySelector("form")).addEventListener("submit",i),u=t},onremoved:()=>{bulmaJS.toggleHtmlClipped()}})},n=e=>{const o=Number.parseInt(e.currentTarget.closest("tr").dataset.lotOccupancyCommentId,10);bulmaJS.confirm({title:"Remove Comment?",message:"Are you sure you want to remove this comment?",okButton:{text:"Yes, Remove Comment",callbackFunction:()=>{cityssm.postJSON(t+"/lotOccupancies/doDeleteLotOccupancyComment",{lotOccupancyId:c,lotOccupancyCommentId:o},e=>{e.success?(a=e.lotOccupancyComments,s()):bulmaJS.alert({title:"Error Removing Comment",message:e.errorMessage,contextualColorName:"danger"})})}},contextualColorName:"warning"})},s=()=>{const e=document.querySelector("#container--lotOccupancyComments");if(0===a.length)return void(e.innerHTML='

There are no comments associated with this record.

');const t=document.createElement("table");t.className="table is-fullwidth is-striped is-hoverable",t.innerHTML='CommentorComment DateCommentOptions';for(const e of a){const c=document.createElement("tr");c.dataset.lotOccupancyCommentId=e.lotOccupancyCommentId.toString(),c.innerHTML=""+cityssm.escapeHTML(e.recordCreate_userName)+""+e.lotOccupancyCommentDateString+(0===e.lotOccupancyCommentTime?"":" "+e.lotOccupancyCommentTimeString)+""+cityssm.escapeHTML(e.lotOccupancyComment)+'
',c.querySelector(".button--edit").addEventListener("click",o),c.querySelector(".button--delete").addEventListener("click",n),t.querySelector("tbody").append(c)}e.innerHTML="",e.append(t)};document.querySelector("#button--addComment").addEventListener("click",()=>{let o,n;const l=e=>{e.preventDefault(),cityssm.postJSON(t+"/lotOccupancies/doAddLotOccupancyComment",o,e=>{e.success?(a=e.lotOccupancyComments,n(),s()):bulmaJS.alert({title:"Error Adding Comment",message:e.errorMessage,contextualColorName:"danger"})})};cityssm.openHtmlModal("lotOccupancy-addComment",{onshow:t=>{e.populateAliases(t),t.querySelector("#lotOccupancyCommentAdd--lotOccupancyId").value=c},onshown:(e,t)=>{bulmaJS.toggleHtmlClipped(),e.querySelector("#lotOccupancyCommentAdd--lotOccupancyComment").focus(),(o=e.querySelector("form")).addEventListener("submit",l),n=t},onremoved:()=>{bulmaJS.toggleHtmlClipped()}})}),s()}if(!a){let a=exports.lotOccupancyFees;const n=document.querySelector("#container--lotOccupancyFees"),s=()=>{let e=0;for(const t of a)e+=(t.feeAmount+t.taxAmount)*t.quantity;return e},l=e=>{const o=e.currentTarget.closest(".container--lotOccupancyFee").dataset.feeId;bulmaJS.confirm({title:"Delete Fee",message:"Are you sure you want to delete this fee?",contextualColorName:"warning",okButton:{text:"Yes, Delete Fee",callbackFunction:()=>{cityssm.postJSON(t+"/lotOccupancies/doDeleteLotOccupancyFee",{lotOccupancyId:c,feeId:o},e=>{e.success?(a=e.lotOccupancyFees,r()):bulmaJS.alert({title:"Error Deleting Fee",message:e.errorMessage,contextualColorName:"danger"})})}}})},r=()=>{if(0===a.length)return void(n.innerHTML='

There are no fees associated with this record.

');n.innerHTML='
FeeUnit Cost×QuantityequalsTotalOptions
Subtotal
Tax
Grand Total
';let e=0,t=0;for(const c of a){const a=document.createElement("tr");a.className="container--lotOccupancyFee",a.dataset.feeId=c.feeId.toString(),a.innerHTML=''+cityssm.escapeHTML(c.feeName)+""+(1===c.quantity?"":'$'+c.feeAmount.toFixed(2)+'×'+c.quantity+"=")+'$'+(c.feeAmount*c.quantity).toFixed(2)+'',a.querySelector("button").addEventListener("click",l),n.querySelector("tbody").append(a),e+=c.feeAmount*c.quantity,t+=c.taxAmount*c.quantity}n.querySelector("#lotOccupancyFees--feeAmountTotal").textContent="$"+e.toFixed(2),n.querySelector("#lotOccupancyFees--taxAmountTotal").textContent="$"+t.toFixed(2),n.querySelector("#lotOccupancyFees--grandTotal").textContent="$"+(e+t).toFixed(2),m()};document.querySelector("#button--addFee").addEventListener("click",()=>{if(o)return void bulmaJS.alert({message:"Please save all unsaved changes before adding fees.",contextualColorName:"warning"});let e,s,l;const u=(e,o=1)=>{cityssm.postJSON(t+"/lotOccupancies/doAddLotOccupancyFee",{lotOccupancyId:c,feeId:e,quantity:o},e=>{e.success?(a=e.lotOccupancyFees,r(),d()):bulmaJS.alert({title:"Error Adding Fee",message:e.errorMessage,contextualColorName:"danger"})})},i=t=>{t.preventDefault();const c=Number.parseInt(t.currentTarget.dataset.feeId,10),a=Number.parseInt(t.currentTarget.closest(".container--feeCategory").dataset.feeCategoryId,10),o=e.find(e=>e.feeCategoryId===a).fees.find(e=>e.feeId===c);o.includeQuantity?(e=>{let t,c;const a=a=>{a.preventDefault(),u(e.feeId,t.value),c()};cityssm.openHtmlModal("lotOccupancy-setFeeQuantity",{onshow:t=>{t.querySelector("#lotOccupancyFeeQuantity--quantityUnit").textContent=e.quantityUnit},onshown:(e,o)=>{c=o,t=e.querySelector("#lotOccupancyFeeQuantity--quantity"),e.querySelector("form").addEventListener("submit",a)}})})(o):u(c)},d=()=>{const t=s.value.trim().toLowerCase().split(" ");l.innerHTML="";for(const c of e){const e=document.createElement("div");e.className="container--feeCategory",e.dataset.feeCategoryId=c.feeCategoryId.toString(),e.innerHTML='

'+cityssm.escapeHTML(c.feeCategory)+'

';let a=!1;for(const o of c.fees){if(n.querySelector(".container--lotOccupancyFee[data-fee-id='"+o.feeId+"']"))continue;let c=!0;for(const e of t)if(!o.feeName.toLowerCase().includes(e)){c=!1;break}if(!c)continue;a=!0;const s=document.createElement("a");s.className="panel-block is-block container--fee",s.dataset.feeId=o.feeId.toString(),s.href="#",s.innerHTML=""+cityssm.escapeHTML(o.feeName)+"
"+cityssm.escapeHTML(o.feeDescription).replace(/\n/g,"
")+"
",s.addEventListener("click",i),e.querySelector(".panel").append(s)}a&&l.append(e)}};cityssm.openHtmlModal("lotOccupancy-addFee",{onshow:a=>{s=a.querySelector("#feeSelect--feeName"),l=a.querySelector("#resultsContainer--feeSelect"),cityssm.postJSON(t+"/lotOccupancies/doGetFees",{lotOccupancyId:c},t=>{e=t.feeCategories,s.disabled=!1,s.addEventListener("keyup",d),s.focus(),d()})},onshown:()=>{bulmaJS.toggleHtmlClipped()},onhidden:()=>{r()},onremoved:()=>{bulmaJS.toggleHtmlClipped()}})});let u=exports.lotOccupancyTransactions;const i=document.querySelector("#container--lotOccupancyTransactions"),d=()=>{let e=0;for(const t of u)e+=t.transactionAmount;return e},p=e=>{const a=e.currentTarget.closest(".container--lotOccupancyTransaction").dataset.transactionIndex;bulmaJS.confirm({title:"Delete Trasnaction",message:"Are you sure you want to delete this transaction?",contextualColorName:"warning",okButton:{text:"Yes, Delete Transaction",callbackFunction:()=>{cityssm.postJSON(t+"/lotOccupancies/doDeleteLotOccupancyTransaction",{lotOccupancyId:c,transactionIndex:a},e=>{e.success?(u=e.lotOccupancyTransactions,m()):bulmaJS.alert({title:"Error Deleting Transaction",message:e.errorMessage,contextualColorName:"danger"})})}}})},m=()=>{if(0===u.length)return void(i.innerHTML='

There are no transactions associated with this record.

');i.innerHTML='
Date'+cityssm.escapeHTML(exports.aliases.externalReceiptNumber)+'AmountOptions
Transaction Total
';let e=0;for(const t of u){e+=t.transactionAmount;const c=document.createElement("tr");c.className="container--lotOccupancyTransaction",c.dataset.transactionIndex=t.transactionIndex.toString(),c.innerHTML=""+t.transactionDateString+""+cityssm.escapeHTML(t.externalReceiptNumber)+"
"+cityssm.escapeHTML(t.transactionNote)+'$'+t.transactionAmount.toFixed(2)+'',c.querySelector("button").addEventListener("click",p),i.querySelector("tbody").append(c)}i.querySelector("#lotOccupancyTransactions--grandTotal").textContent="$"+e.toFixed(2);const t=s();t>e&&i.insertAdjacentHTML("afterbegin",'
Outstanding Balance
$'+(t-e).toFixed(2)+"
")};document.querySelector("#button--addTransaction").addEventListener("click",()=>{let a;const o=e=>{e.preventDefault(),cityssm.postJSON(t+"/lotOccupancies/doAddLotOccupancyTransaction",e.currentTarget,e=>{e.success?(u=e.lotOccupancyTransactions,a(),m()):bulmaJS.confirm({title:"Error Adding Transaction",message:e.errorMessage,contextualColorName:"danger"})})};cityssm.openHtmlModal("lotOccupancy-addTransaction",{onshow:t=>{e.populateAliases(t),t.querySelector("#lotOccupancyTransactionAdd--lotOccupancyId").value=c.toString();const a=s(),o=d(),n=t.querySelector("#lotOccupancyTransactionAdd--transactionAmount");n.min=(-1*o).toFixed(2),n.max=Math.max(a-o,0).toFixed(2),n.value=Math.max(a-o,0).toFixed(2)},onshown:(e,t)=>{bulmaJS.toggleHtmlClipped(),a=t,e.querySelector("form").addEventListener("submit",o)},onremoved:()=>{bulmaJS.toggleHtmlClipped()}})}),r()}})(); \ No newline at end of file diff --git a/temp/legacy.importFromCSV.js b/temp/legacy.importFromCSV.js index 5c7f4e19..2754f47e 100644 --- a/temp/legacy.importFromCSV.js +++ b/temp/legacy.importFromCSV.js @@ -301,12 +301,16 @@ function importFromCSV() { }, user); } if (masterRow.CM_COMMITTAL_TYPE !== "") { + let commitalType = masterRow.CM_COMMITTAL_TYPE; + if (commitalType === "GS") { + commitalType = "Graveside"; + } addOrUpdateLotOccupancyField({ lotOccupancyId, occupancyTypeFieldId: deceasedOccupancyType.occupancyTypeFields.find((occupancyTypeField) => { return occupancyTypeField.occupancyTypeField === "Committal Type"; }).occupancyTypeFieldId, - lotOccupancyFieldValue: masterRow.CM_COMMITTAL_TYPE + lotOccupancyFieldValue: commitalType }, user); } if (masterRow.CM_REMARK1 !== "") { diff --git a/temp/legacy.importFromCSV.ts b/temp/legacy.importFromCSV.ts index 456c69d6..32063189 100644 --- a/temp/legacy.importFromCSV.ts +++ b/temp/legacy.importFromCSV.ts @@ -487,12 +487,18 @@ function importFromCSV() { if (masterRow.CM_COMMITTAL_TYPE !== "") { + let commitalType = masterRow.CM_COMMITTAL_TYPE; + + if (commitalType === "GS") { + commitalType = "Graveside"; + } + addOrUpdateLotOccupancyField({ lotOccupancyId, occupancyTypeFieldId: deceasedOccupancyType.occupancyTypeFields.find((occupancyTypeField) => { return occupancyTypeField.occupancyTypeField === "Committal Type" }).occupancyTypeFieldId, - lotOccupancyFieldValue: masterRow.CM_COMMITTAL_TYPE + lotOccupancyFieldValue: commitalType }, user); } diff --git a/views/lot-edit.ejs b/views/lot-edit.ejs index 726c1712..64721d40 100644 --- a/views/lot-edit.ejs +++ b/views/lot-edit.ejs @@ -42,83 +42,87 @@ -
-
-
- -
- -
-
-
-
- -
-
-
- +
+
+
+
+
+ +
+ +
-
- +
+ +
+
+
+ +
+
+
+ +
+
-
-
-
- -
-
-
- +
+ +
+
+
+ +
+
@@ -127,81 +131,88 @@
-

Geographic Location

-
- -
- -
-
-
- -
- +
+

Geographic Location

+
+
+ +
+ +
+
+
+ +
+ +
+
-

Image

- -
-
-
- +
+

Image

+
+ +
+
+
+ +
+
+
+ +
+
+ +
+ +
+ +
+

+ + + What is the SVG key? + +

-
- -
-
- -
- -
- -
-

- - - What is the SVG key? - -

- -
+
+

+ Additional Details +

+
- -

- Additional Details -

<% if (isCreate) { %> @@ -211,25 +222,51 @@

<% } else { %> -
-
-

- Comments -

+
+
+
+
+
+

+ Comments +

+
+
+
+
+ +
+
+
-
- +
+
+ +
+
+
+
+
+

+ <%= configFunctions.getProperty("aliases.occupancies") %> + <%= lot.lotOccupancies.length %> +

+
+
+ +
-
- -

- <%= configFunctions.getProperty("aliases.occupancies") %> - <%= lot.lotOccupancies.length %> -

<% if (lot.lotOccupancies.length === 0) { %>
diff --git a/views/lot-view.ejs b/views/lot-view.ejs index ac3b4001..4fc4431c 100644 --- a/views/lot-view.ejs +++ b/views/lot-view.ejs @@ -1,127 +1,143 @@ <%- include('_header'); -%>

- <%= lot.lotName %> + <%= lot.lotName %>

<% if (user.userProperties.canUpdate) { %> - <% } %>
-
-
- <%= configFunctions.getProperty("aliases.map") %>
- - <%= lot.mapName %> - -
-
- <%= configFunctions.getProperty("aliases.lot") %> Type
- <%= lot.lotType %> -
-
- Status
- <%= lot.lotStatus %> -
-
-
-

Image

- <% if (lot.mapSVG) { %> - <% const imageURL = urlPrefix + "/images/maps/" + lot.mapSVG %> -
- <%- include('../public/images/maps/' + lot.mapSVG); -%> +
+
+
+
+ <%= configFunctions.getProperty("aliases.map") %>
+ + <%= lot.mapName %> + +
+
+ <%= configFunctions.getProperty("aliases.lot") %> Type
+ <%= lot.lotType %> +
+
+ Status
+ <%= lot.lotStatus %> +
+
- <% } else { %> -
-

There are no image associated with this <%= configFunctions.getProperty("aliases.lot").toLowerCase() %>.

+
+
+
+

Image

+
+ <% if (lot.mapSVG) { %> + <% const imageURL = urlPrefix + "/images/maps/" + lot.mapSVG %> +
+ <%- include('../public/images/maps/' + lot.mapSVG); -%> +
+ <% } else { %> +
+

There are no image associated with this + <%= configFunctions.getProperty("aliases.lot").toLowerCase() %>.

+
+ <% } %> +
- <% } %> -
+
-

- <%= configFunctions.getProperty("aliases.occupancies") %> - <%= lot.lotOccupancies.length %> -

- -<% if (lot.lotOccupancies.length === 0) { %> -
-

There are no occupancy records asscociated with this <%= configFunctions.getProperty("aliases.lot") %>.

-
-<% } else { %> - - - - - - - - - - - - <% const currentDate = dateTimeFunctions.dateToInteger(new Date()); %> - <% for (const lotOccupancy of lot.lotOccupancies) { %> - <% const isActive = !(lotOccupancy.occupancyEndDate && lotOccupancy.occupancyEndDate < currentDate); %> - - - - - - - - <% } %> - -
 <%= configFunctions.getProperty("aliases.occupancy") %> TypeStart DateEnd Date<%= configFunctions.getProperty("aliases.occupants") %>
- <% if (isActive) { %> - "> - <% } else { %> - "> - <% } %> - - - <%= lotOccupancy.occupancyType %> - - <%= lotOccupancy.occupancyStartDateString %> - <% if (lotOccupancy.occupancyEndDate) { %> - <%= lotOccupancy.occupancyEndDateString %> - <% } else { %> - (No End Date) - <% } %> - - <% if (lotOccupancy.lotOccupancyOccupants.length === 0) { %> - (No <%= configFunctions.getProperty("aliases.occupants") %>) - <% } else { %> - <% const occupant = lotOccupancy.lotOccupancyOccupants[0]; %> - <%= occupant.occupantName %> - <%= (lotOccupancy.lotOccupancyOccupants.length > 1 ? " plus " + (lotOccupancy.lotOccupancyOccupants.length - 1) : "") %> - <% } %> -
-<% } %> +
+

+ <%= configFunctions.getProperty("aliases.occupancies") %> + <%= lot.lotOccupancies.length %> +

+
+ <% if (lot.lotOccupancies.length === 0) { %> +
+

There are no occupancy records asscociated with this + <%= configFunctions.getProperty("aliases.lot") %>.

+
+ <% } else { %> + + + + + + + + + + + + <% const currentDate = dateTimeFunctions.dateToInteger(new Date()); %> + <% for (const lotOccupancy of lot.lotOccupancies) { %> + <% const isActive = !(lotOccupancy.occupancyEndDate && lotOccupancy.occupancyEndDate < currentDate); %> + + + + + + + + <% } %> + +
 <%= configFunctions.getProperty("aliases.occupancy") %> TypeStart DateEnd Date<%= configFunctions.getProperty("aliases.occupants") %>
+ <% if (isActive) { %> + "> + <% } else { %> + "> + <% } %> + + + <%= lotOccupancy.occupancyType %> + + <%= lotOccupancy.occupancyStartDateString %> + <% if (lotOccupancy.occupancyEndDate) { %> + <%= lotOccupancy.occupancyEndDateString %> + <% } else { %> + (No End Date) + <% } %> + + <% if (lotOccupancy.lotOccupancyOccupants.length === 0) { %> + (No <%= configFunctions.getProperty("aliases.occupants") %>) + <% } else { %> + <% const occupant = lotOccupancy.lotOccupancyOccupants[0]; %> + <%= occupant.occupantName %> + <%= (lotOccupancy.lotOccupancyOccupants.length > 1 ? " plus " + (lotOccupancy.lotOccupancyOccupants.length - 1) : "") %> + <% } %> +
+ <% } %> +
+
<%- include('_footerA'); -%> -<%- include('_footerB'); -%> +<%- include('_footerB'); -%> \ No newline at end of file diff --git a/views/lotOccupancy-view.ejs b/views/lotOccupancy-view.ejs index a9463cbb..1e5b09f3 100644 --- a/views/lotOccupancy-view.ejs +++ b/views/lotOccupancy-view.ejs @@ -234,7 +234,29 @@

<% } else { %> - + + + + + + + + + + <% for (const lotOccupancyTransaction of lotOccupancy.lotOccupancyTransactions) { %> + + + + + + <% } %> + +
Date<%= configFunctions.getProperty("aliases.externalReceiptNumber") %>Amount
<%= lotOccupancyTransaction.transactionDateString %> + <%= lotOccupancyTransaction.externalReceiptNumber %>
+ <%= lotOccupancyTransaction.transactionNote %> +
+ $<%= lotOccupancyTransaction.transactionAmount.toFixed(2) %> +
<% } %>
diff --git a/views/map-edit.ejs b/views/map-edit.ejs index 494345fd..654c05ad 100644 --- a/views/map-edit.ejs +++ b/views/map-edit.ejs @@ -40,65 +40,72 @@
-
- -
- -
-
-
- -
- +
+
+
+ +
+ +
+
+
+ +
+ +
+
-

Address

- -
- -
- -
-
-
-
- -
-
-
-
+
+

Address

+
- +
- +
-
-
-
- +
-
-
-
-
-
- -
- +
+
+
+ +
+ +
+
+
+
+
+ +
+ +
+
-
-
-
- -
- +
+
+
+ +
+ +
+
+
+
+
+ +
+ +
+
@@ -107,37 +114,46 @@
-

Geographic Location

-
- -
- -
-
-
- -
- +
+

Geographic Location

+
+
+ +
+ +
+
+
+ +
+ +
+
-

Image

-
- -
-
- +
+

Image

+
+
+ +
+
+ +
+
+
diff --git a/views/map-view.ejs b/views/map-view.ejs index ec0e7ee8..877a4bb1 100644 --- a/views/map-view.ejs +++ b/views/map-view.ejs @@ -33,68 +33,83 @@
<% } %> -
- <% if (map.mapDescription && map.mapDescription !== "") { %> -
- Description
- <%= map.mapDescription %> +
+
+
+ <% if (map.mapDescription && map.mapDescription !== "") { %> +
+ Description
+ <%= map.mapDescription %> +
+ <% } %> +
+ Address
+ <% if (map.mapAddress1 !== "") { %> + <%= map.mapAddress1 %>
+ <% } %> + <% if (map.mapAddress2 !== "") { %> + <%= map.mapAddress2 %>
+ <% } %> + <%= map.mapCity %>, <%= map.mapProvince %>
+ <%= map.mapPostalCode %> +
- <% } %> -
- Address
- <% if (map.mapAddress1 !== "") { %> - <%= map.mapAddress1 %>
+ <% if (map.mapPhoneNumber !== "") { %> +
+ Phone Number
+ <%= map.mapPhoneNumber %> +
<% } %> - <% if (map.mapAddress2 !== "") { %> - <%= map.mapAddress2 %>
- <% } %> - <%= map.mapCity %>, <%= map.mapProvince %>
- <%= map.mapPostalCode %>
- <% if (map.mapPhoneNumber !== "") { %> -
- Phone Number
- <%= map.mapPhoneNumber %> -
- <% } %>
-

Geographic Location

- - <% if (map.mapLatitude && map.mapLongitude) { %> -
- <% } else { %> -
-

There are no geographic coordinates associated with this <%= configFunctions.getProperty("aliases.map").toLowerCase() %>.

+
+

Geographic Location

+
+ <% if (map.mapLatitude && map.mapLongitude) { %> +
+ <% } else { %> +
+

There are no geographic coordinates associated with this <%= configFunctions.getProperty("aliases.map").toLowerCase() %>.

+
+ <% } %>
- <% } %> +
-

Image

- <% if (map.mapSVG) { %> - <% const imageURL = urlPrefix + "/images/maps/" + map.mapSVG %> - - <%- include('../public/images/maps/' + map.mapSVG); -%> - - <% } else { %> -
-

There are no image associated with this <%= configFunctions.getProperty("aliases.map").toLowerCase() %>.

+
+

Image

+
+ <% if (map.mapSVG) { %> + <% const imageURL = urlPrefix + "/images/maps/" + map.mapSVG %> + + <%- include('../public/images/maps/' + map.mapSVG); -%> + + <% } else { %> +
+

There are no image associated with this <%= configFunctions.getProperty("aliases.map").toLowerCase() %>.

+
+ <% } %>
- <% } %> +
-

- Related Searches -

+ - - - <%= configFunctions.getProperty("aliases.lots") %> - <%= map.lotCount %> -
diff --git a/views/report-search.ejs b/views/report-search.ejs index fdba3f10..e2dee29e 100644 --- a/views/report-search.ejs +++ b/views/report-search.ejs @@ -1,81 +1,83 @@ <%- include('_header'); -%>

- Licence Reports + Reports

-
-
-

Licences

- - -
-
-

Table Exports

-
-
-

- Note that table exports are full, unfiltered, and unformatted exports. - They may contain deleted records that have not been fully purged. -

+ - -
- - -
- CSV -
-
-

Full Licences Table

-

- All the data from the Licences table unfiltered. -

-
-
-
<%- include('_footerA'); -%> -<%- include('_footerB'); -%> +<%- include('_footerB'); -%> \ No newline at end of file