diff --git a/handlers/lotOccupancies-post/doUpdateLotOccupancyFeeQuantity.d.ts b/handlers/lotOccupancies-post/doUpdateLotOccupancyFeeQuantity.d.ts new file mode 100644 index 00000000..7c872b55 --- /dev/null +++ b/handlers/lotOccupancies-post/doUpdateLotOccupancyFeeQuantity.d.ts @@ -0,0 +1,3 @@ +import type { Request, Response } from 'express'; +export declare function handler(request: Request, response: Response): Promise; +export default handler; diff --git a/handlers/lotOccupancies-post/doUpdateLotOccupancyFeeQuantity.js b/handlers/lotOccupancies-post/doUpdateLotOccupancyFeeQuantity.js new file mode 100644 index 00000000..507a7b20 --- /dev/null +++ b/handlers/lotOccupancies-post/doUpdateLotOccupancyFeeQuantity.js @@ -0,0 +1,11 @@ +import { updateLotOccupancyFeeQuantity } from '../../helpers/lotOccupancyDB/updateLotOccupancyFeeQuantity.js'; +import { getLotOccupancyFees } from '../../helpers/lotOccupancyDB/getLotOccupancyFees.js'; +export async function handler(request, response) { + const success = await updateLotOccupancyFeeQuantity(request.body, request.session); + const lotOccupancyFees = await getLotOccupancyFees(request.body.lotOccupancyId); + response.json({ + success, + lotOccupancyFees + }); +} +export default handler; diff --git a/handlers/lotOccupancies-post/doUpdateLotOccupancyFeeQuantity.ts b/handlers/lotOccupancies-post/doUpdateLotOccupancyFeeQuantity.ts new file mode 100644 index 00000000..e07e844c --- /dev/null +++ b/handlers/lotOccupancies-post/doUpdateLotOccupancyFeeQuantity.ts @@ -0,0 +1,24 @@ +import type { Request, Response } from 'express' + +import { updateLotOccupancyFeeQuantity } from '../../helpers/lotOccupancyDB/updateLotOccupancyFeeQuantity.js' + +import { getLotOccupancyFees } from '../../helpers/lotOccupancyDB/getLotOccupancyFees.js' + +export async function handler( + request: Request, + response: Response +): Promise { + const success = await updateLotOccupancyFeeQuantity( + request.body, + request.session + ) + + const lotOccupancyFees = await getLotOccupancyFees(request.body.lotOccupancyId) + + response.json({ + success, + lotOccupancyFees + }) +} + +export default handler diff --git a/helpers/lotOccupancyDB/getLotOccupancyFees.js b/helpers/lotOccupancyDB/getLotOccupancyFees.js index 9a750bd0..0319f3b4 100644 --- a/helpers/lotOccupancyDB/getLotOccupancyFees.js +++ b/helpers/lotOccupancyDB/getLotOccupancyFees.js @@ -4,7 +4,7 @@ export async function getLotOccupancyFees(lotOccupancyId, connectedDatabase) { const lotOccupancyFees = database .prepare(`select o.lotOccupancyId, o.feeId, c.feeCategory, f.feeName, - f.includeQuantity, o.feeAmount, o.taxAmount, o.quantity + f.includeQuantity, o.feeAmount, o.taxAmount, o.quantity, f.quantityUnit from LotOccupancyFees o left join Fees f on o.feeId = f.feeId left join FeeCategories c on f.feeCategoryId = c.feeCategoryId diff --git a/helpers/lotOccupancyDB/getLotOccupancyFees.ts b/helpers/lotOccupancyDB/getLotOccupancyFees.ts index 8af4e731..71661f69 100644 --- a/helpers/lotOccupancyDB/getLotOccupancyFees.ts +++ b/helpers/lotOccupancyDB/getLotOccupancyFees.ts @@ -13,7 +13,7 @@ export async function getLotOccupancyFees( .prepare( `select o.lotOccupancyId, o.feeId, c.feeCategory, f.feeName, - f.includeQuantity, o.feeAmount, o.taxAmount, o.quantity + f.includeQuantity, o.feeAmount, o.taxAmount, o.quantity, f.quantityUnit from LotOccupancyFees o left join Fees f on o.feeId = f.feeId left join FeeCategories c on f.feeCategoryId = c.feeCategoryId diff --git a/helpers/lotOccupancyDB/updateLotOccupancyFeeQuantity.d.ts b/helpers/lotOccupancyDB/updateLotOccupancyFeeQuantity.d.ts new file mode 100644 index 00000000..c845b661 --- /dev/null +++ b/helpers/lotOccupancyDB/updateLotOccupancyFeeQuantity.d.ts @@ -0,0 +1,8 @@ +import type * as recordTypes from '../../types/recordTypes'; +interface UpdateLotOccupancyFeeQuantityForm { + lotOccupancyId: string | number; + feeId: string | number; + quantity: string | number; +} +export declare function updateLotOccupancyFeeQuantity(feeQuantityForm: UpdateLotOccupancyFeeQuantityForm, requestSession: recordTypes.PartialSession): Promise; +export default updateLotOccupancyFeeQuantity; diff --git a/helpers/lotOccupancyDB/updateLotOccupancyFeeQuantity.js b/helpers/lotOccupancyDB/updateLotOccupancyFeeQuantity.js new file mode 100644 index 00000000..8714c06e --- /dev/null +++ b/helpers/lotOccupancyDB/updateLotOccupancyFeeQuantity.js @@ -0,0 +1,17 @@ +import { acquireConnection } from './pool.js'; +export async function updateLotOccupancyFeeQuantity(feeQuantityForm, requestSession) { + const rightNowMillis = Date.now(); + const database = await acquireConnection(); + const result = database + .prepare(`update LotOccupancyFees + set quantity = ?, + recordUpdate_userName = ?, + recordUpdate_timeMillis = ? + where recordDelete_timeMillis is null + and lotOccupancyId = ? + and feeId = ?`) + .run(feeQuantityForm.quantity, requestSession.user.userName, rightNowMillis, feeQuantityForm.lotOccupancyId, feeQuantityForm.feeId); + database.release(); + return result.changes > 0; +} +export default updateLotOccupancyFeeQuantity; diff --git a/helpers/lotOccupancyDB/updateLotOccupancyFeeQuantity.ts b/helpers/lotOccupancyDB/updateLotOccupancyFeeQuantity.ts new file mode 100644 index 00000000..cce2cf69 --- /dev/null +++ b/helpers/lotOccupancyDB/updateLotOccupancyFeeQuantity.ts @@ -0,0 +1,47 @@ +import { acquireConnection } from './pool.js' + +import { + dateStringToInteger, + timeStringToInteger +} from '@cityssm/expressjs-server-js/dateTimeFns.js' + +import type * as recordTypes from '../../types/recordTypes' + +interface UpdateLotOccupancyFeeQuantityForm { + lotOccupancyId: string | number + feeId: string | number + quantity: string | number +} + +export async function updateLotOccupancyFeeQuantity( + feeQuantityForm: UpdateLotOccupancyFeeQuantityForm, + requestSession: recordTypes.PartialSession +): Promise { + const rightNowMillis = Date.now() + + const database = await acquireConnection() + + const result = database + .prepare( + `update LotOccupancyFees + set quantity = ?, + recordUpdate_userName = ?, + recordUpdate_timeMillis = ? + where recordDelete_timeMillis is null + and lotOccupancyId = ? + and feeId = ?` + ) + .run( + feeQuantityForm.quantity, + requestSession.user!.userName, + rightNowMillis, + feeQuantityForm.lotOccupancyId, + feeQuantityForm.feeId + ) + + database.release() + + return result.changes > 0 +} + +export default updateLotOccupancyFeeQuantity diff --git a/public-typescript/lotOccupancyEdit.js b/public-typescript/lotOccupancyEdit.js index 1ba93f7b..e75a0609 100644 --- a/public-typescript/lotOccupancyEdit.js +++ b/public-typescript/lotOccupancyEdit.js @@ -1103,6 +1103,56 @@ Object.defineProperty(exports, "__esModule", { value: true }); } return feeGrandTotal; } + function editLotOccupancyFeeQuantity(clickEvent) { + const feeId = Number.parseInt(clickEvent.currentTarget.closest('tr').dataset + .feeId, 10); + const fee = lotOccupancyFees.find((possibleFee) => { + return possibleFee.feeId === feeId; + }); + if (fee === undefined) { + bulmaJS.alert({ + title: 'Fee Not Found', + message: 'Please refresh the page', + contextualColorName: 'danger' + }); + return; + } + let updateCloseModalFunction; + function doUpdateQuantity(formEvent) { + formEvent.preventDefault(); + cityssm.postJSON(los.urlPrefix + '/lotOccupancies/doUpdateLotOccupancyFeeQuantity', formEvent.currentTarget, (rawResponseJSON) => { + const responseJSON = rawResponseJSON; + if (responseJSON.success) { + lotOccupancyFees = responseJSON.lotOccupancyFees; + renderLotOccupancyFees(); + updateCloseModalFunction(); + } + else { + bulmaJS.alert({ + title: 'Error Updating Quantity', + message: 'Please try again.', + contextualColorName: 'danger' + }); + } + }); + } + cityssm.openHtmlModal('lotOccupancy-editFeeQuantity', { + onshow(modalElement) { + ; + modalElement.querySelector('#lotOccupancyFeeQuantity--lotOccupancyId').value = lotOccupancyId; + modalElement.querySelector('#lotOccupancyFeeQuantity--feeId').value = fee.feeId.toString(); + modalElement.querySelector('#lotOccupancyFeeQuantity--quantity').valueAsNumber = fee.quantity; + modalElement.querySelector('#lotOccupancyFeeQuantity--quantityUnit').textContent = fee.quantityUnit; + }, + onshown(modalElement, closeModalFunction) { + var _a; + updateCloseModalFunction = closeModalFunction; + modalElement.querySelector('#lotOccupancyFeeQuantity--quantity').focus(); + (_a = modalElement + .querySelector('form')) === null || _a === void 0 ? void 0 : _a.addEventListener('submit', doUpdateQuantity); + } + }); + } function deleteLotOccupancyFee(clickEvent) { const feeId = clickEvent.currentTarget.closest('.container--lotOccupancyFee').dataset.feeId; function doDelete() { @@ -1136,7 +1186,7 @@ Object.defineProperty(exports, "__esModule", { value: true }); }); } function renderLotOccupancyFees() { - var _a, _b, _c; + var _a, _b, _c, _d, _e, _f, _g; if (lotOccupancyFees.length === 0) { lotOccupancyFeesContainerElement.innerHTML = `

There are no fees associated with this record.

@@ -1200,16 +1250,21 @@ Object.defineProperty(exports, "__esModule", { value: true }); (lotOccupancyFee.feeAmount * lotOccupancyFee.quantity).toFixed(2) + '' + ('' + - '' + : '') + + '' + + '
' + ''); - tableRowElement - .querySelector('button') - .addEventListener('click', deleteLotOccupancyFee); - lotOccupancyFeesContainerElement - .querySelector('tbody') - .append(tableRowElement); + (_e = tableRowElement + .querySelector('.button--editQuantity')) === null || _e === void 0 ? void 0 : _e.addEventListener('click', editLotOccupancyFeeQuantity); + (_f = tableRowElement + .querySelector('.button--delete')) === null || _f === void 0 ? void 0 : _f.addEventListener('click', deleteLotOccupancyFee); + (_g = lotOccupancyFeesContainerElement + .querySelector('tbody')) === null || _g === void 0 ? void 0 : _g.append(tableRowElement); feeAmountTotal += lotOccupancyFee.feeAmount * lotOccupancyFee.quantity; taxAmountTotal += lotOccupancyFee.taxAmount * lotOccupancyFee.quantity; } diff --git a/public-typescript/lotOccupancyEdit/lotOccupancyEditFees.js b/public-typescript/lotOccupancyEdit/lotOccupancyEditFees.js index 754315b7..22a58ee6 100644 --- a/public-typescript/lotOccupancyEdit/lotOccupancyEditFees.js +++ b/public-typescript/lotOccupancyEdit/lotOccupancyEditFees.js @@ -13,6 +13,56 @@ function getFeeGrandTotal() { } return feeGrandTotal; } +function editLotOccupancyFeeQuantity(clickEvent) { + const feeId = Number.parseInt(clickEvent.currentTarget.closest('tr').dataset + .feeId, 10); + const fee = lotOccupancyFees.find((possibleFee) => { + return possibleFee.feeId === feeId; + }); + if (fee === undefined) { + bulmaJS.alert({ + title: 'Fee Not Found', + message: 'Please refresh the page', + contextualColorName: 'danger' + }); + return; + } + let updateCloseModalFunction; + function doUpdateQuantity(formEvent) { + formEvent.preventDefault(); + cityssm.postJSON(los.urlPrefix + '/lotOccupancies/doUpdateLotOccupancyFeeQuantity', formEvent.currentTarget, (rawResponseJSON) => { + const responseJSON = rawResponseJSON; + if (responseJSON.success) { + lotOccupancyFees = responseJSON.lotOccupancyFees; + renderLotOccupancyFees(); + updateCloseModalFunction(); + } + else { + bulmaJS.alert({ + title: 'Error Updating Quantity', + message: 'Please try again.', + contextualColorName: 'danger' + }); + } + }); + } + cityssm.openHtmlModal('lotOccupancy-editFeeQuantity', { + onshow(modalElement) { + ; + modalElement.querySelector('#lotOccupancyFeeQuantity--lotOccupancyId').value = lotOccupancyId; + modalElement.querySelector('#lotOccupancyFeeQuantity--feeId').value = fee.feeId.toString(); + modalElement.querySelector('#lotOccupancyFeeQuantity--quantity').valueAsNumber = fee.quantity; + modalElement.querySelector('#lotOccupancyFeeQuantity--quantityUnit').textContent = fee.quantityUnit; + }, + onshown(modalElement, closeModalFunction) { + var _a; + updateCloseModalFunction = closeModalFunction; + modalElement.querySelector('#lotOccupancyFeeQuantity--quantity').focus(); + (_a = modalElement + .querySelector('form')) === null || _a === void 0 ? void 0 : _a.addEventListener('submit', doUpdateQuantity); + } + }); +} function deleteLotOccupancyFee(clickEvent) { const feeId = clickEvent.currentTarget.closest('.container--lotOccupancyFee').dataset.feeId; function doDelete() { @@ -46,7 +96,7 @@ function deleteLotOccupancyFee(clickEvent) { }); } function renderLotOccupancyFees() { - var _a, _b, _c; + var _a, _b, _c, _d, _e, _f, _g; if (lotOccupancyFees.length === 0) { lotOccupancyFeesContainerElement.innerHTML = `

There are no fees associated with this record.

@@ -110,16 +160,21 @@ function renderLotOccupancyFees() { (lotOccupancyFee.feeAmount * lotOccupancyFee.quantity).toFixed(2) + '' + ('' + - '' + : '') + + '' + + '
' + ''); - tableRowElement - .querySelector('button') - .addEventListener('click', deleteLotOccupancyFee); - lotOccupancyFeesContainerElement - .querySelector('tbody') - .append(tableRowElement); + (_e = tableRowElement + .querySelector('.button--editQuantity')) === null || _e === void 0 ? void 0 : _e.addEventListener('click', editLotOccupancyFeeQuantity); + (_f = tableRowElement + .querySelector('.button--delete')) === null || _f === void 0 ? void 0 : _f.addEventListener('click', deleteLotOccupancyFee); + (_g = lotOccupancyFeesContainerElement + .querySelector('tbody')) === null || _g === void 0 ? void 0 : _g.append(tableRowElement); feeAmountTotal += lotOccupancyFee.feeAmount * lotOccupancyFee.quantity; taxAmountTotal += lotOccupancyFee.taxAmount * lotOccupancyFee.quantity; } diff --git a/public-typescript/lotOccupancyEdit/lotOccupancyEditFees.ts b/public-typescript/lotOccupancyEdit/lotOccupancyEditFees.ts index c7f5e50a..16520f92 100644 --- a/public-typescript/lotOccupancyEdit/lotOccupancyEditFees.ts +++ b/public-typescript/lotOccupancyEdit/lotOccupancyEditFees.ts @@ -33,6 +33,92 @@ function getFeeGrandTotal(): number { return feeGrandTotal } +function editLotOccupancyFeeQuantity(clickEvent: Event): void { + const feeId = Number.parseInt( + (clickEvent.currentTarget as HTMLButtonElement).closest('tr')!.dataset + .feeId!, + 10 + ) + const fee = lotOccupancyFees.find((possibleFee) => { + return possibleFee.feeId === feeId + }) + + if (fee === undefined) { + bulmaJS.alert({ + title: 'Fee Not Found', + message: 'Please refresh the page', + contextualColorName: 'danger' + }) + return + } + + let updateCloseModalFunction: () => void + + function doUpdateQuantity(formEvent: SubmitEvent): void { + formEvent.preventDefault() + + cityssm.postJSON( + los.urlPrefix + '/lotOccupancies/doUpdateLotOccupancyFeeQuantity', + formEvent.currentTarget, + (rawResponseJSON) => { + const responseJSON = rawResponseJSON as { + success: boolean + lotOccupancyFees?: recordTypes.LotOccupancyFee[] + } + + if (responseJSON.success) { + lotOccupancyFees = responseJSON.lotOccupancyFees! + renderLotOccupancyFees() + updateCloseModalFunction() + } else { + bulmaJS.alert({ + title: 'Error Updating Quantity', + message: 'Please try again.', + contextualColorName: 'danger' + }) + } + } + ) + } + + cityssm.openHtmlModal('lotOccupancy-editFeeQuantity', { + onshow(modalElement) { + ;( + modalElement.querySelector( + '#lotOccupancyFeeQuantity--lotOccupancyId' + ) as HTMLInputElement + ).value = lotOccupancyId + ;( + modalElement.querySelector( + '#lotOccupancyFeeQuantity--feeId' + ) as HTMLInputElement + ).value = fee.feeId.toString() + ;( + modalElement.querySelector( + '#lotOccupancyFeeQuantity--quantity' + ) as HTMLInputElement + ).valueAsNumber = fee.quantity! + ;( + modalElement.querySelector( + '#lotOccupancyFeeQuantity--quantityUnit' + ) as HTMLElement + ).textContent = fee.quantityUnit! + }, + onshown(modalElement, closeModalFunction) { + updateCloseModalFunction = closeModalFunction + ;( + modalElement.querySelector( + '#lotOccupancyFeeQuantity--quantity' + ) as HTMLInputElement + ).focus() + + modalElement + .querySelector('form') + ?.addEventListener('submit', doUpdateQuantity) + } + }) +} + function deleteLotOccupancyFee(clickEvent: Event): void { const feeId = ( (clickEvent.currentTarget as HTMLElement).closest( @@ -149,18 +235,27 @@ function renderLotOccupancyFees(): void { (lotOccupancyFee.feeAmount! * lotOccupancyFee.quantity!).toFixed(2) + '' + ('' + - '' + : '') + + '' + + '' + '') tableRowElement - .querySelector('button')! - .addEventListener('click', deleteLotOccupancyFee) + .querySelector('.button--editQuantity') + ?.addEventListener('click', editLotOccupancyFeeQuantity) + + tableRowElement + .querySelector('.button--delete') + ?.addEventListener('click', deleteLotOccupancyFee) lotOccupancyFeesContainerElement - .querySelector('tbody')! - .append(tableRowElement) + .querySelector('tbody') + ?.append(tableRowElement) feeAmountTotal += lotOccupancyFee.feeAmount! * lotOccupancyFee.quantity! taxAmountTotal += lotOccupancyFee.taxAmount! * lotOccupancyFee.quantity! @@ -185,7 +280,9 @@ function renderLotOccupancyFees(): void { renderLotOccupancyTransactions() } -const addFeeButtonElement = document.querySelector('#button--addFee') as HTMLButtonElement +const addFeeButtonElement = document.querySelector( + '#button--addFee' +) as HTMLButtonElement addFeeButtonElement.addEventListener('click', () => { if (los.hasUnsavedChanges()) { diff --git a/public/html/lotOccupancy-editFeeQuantity.html b/public/html/lotOccupancy-editFeeQuantity.html new file mode 100644 index 00000000..96b6e112 --- /dev/null +++ b/public/html/lotOccupancy-editFeeQuantity.html @@ -0,0 +1,55 @@ + diff --git a/public/javascripts/lotOccupancyEdit.min.js b/public/javascripts/lotOccupancyEdit.min.js index e85cf591..7144de4b 100644 --- a/public/javascripts/lotOccupancyEdit.min.js +++ b/public/javascripts/lotOccupancyEdit.min.js @@ -1 +1 @@ -"use strict";Object.defineProperty(exports,"__esModule",{value:!0}),(()=>{var e,t,c,n,o;const a=exports.los,s=document.querySelector("#lotOccupancy--lotOccupancyId").value,l=""===s;let r=l;function i(){var e;a.setUnsavedChanges(),null===(e=document.querySelector("button[type='submit'][form='form--lotOccupancy']"))||void 0===e||e.classList.remove("is-light")}function u(){var e;a.clearUnsavedChanges(),null===(e=document.querySelector("button[type='submit'][form='form--lotOccupancy']"))||void 0===e||e.classList.add("is-light")}const d=document.querySelector("#form--lotOccupancy");d.addEventListener("submit",e=>{e.preventDefault(),cityssm.postJSON(a.urlPrefix+"/lotOccupancies/"+(l?"doCreateLotOccupancy":"doUpdateLotOccupancy"),d,e=>{var t;const c=e;c.success?(u(),l||r?window.location.href=a.getLotOccupancyURL(c.lotOccupancyId,!0,!0):bulmaJS.alert({message:`${a.escapedAliases.Occupancy} Updated Successfully`,contextualColorName:"success"})):bulmaJS.alert({title:"Error Saving "+a.escapedAliases.Occupancy,message:null!==(t=c.errorMessage)&&void 0!==t?t:"",contextualColorName:"danger"})})});const p=d.querySelectorAll("input, select");for(const e of p)e.addEventListener("change",i);function m(){cityssm.postJSON(a.urlPrefix+"/lotOccupancies/doCopyLotOccupancy",{lotOccupancyId:s},e=>{var t;const c=e;c.success?(u(),window.location.href=a.getLotOccupancyURL(c.lotOccupancyId,!0)):bulmaJS.alert({title:"Error Copying Record",message:null!==(t=c.errorMessage)&&void 0!==t?t:"",contextualColorName:"danger"})})}null===(S=document.querySelector("#button--copyLotOccupancy"))||void 0===S||S.addEventListener("click",e=>{e.preventDefault(),a.hasUnsavedChanges()?bulmaJS.alert({title:"Unsaved Changes",message:"Please save all unsaved changes before continuing.",contextualColorName:"warning"}):bulmaJS.confirm({title:`Copy ${a.escapedAliases.Occupancy} Record as New`,message:"Are you sure you want to copy this record to a new record?",contextualColorName:"info",okButton:{text:"Yes, Copy",callbackFunction:m}})}),null===(e=document.querySelector("#button--deleteLotOccupancy"))||void 0===e||e.addEventListener("click",e=>{e.preventDefault(),bulmaJS.confirm({title:`Delete ${a.escapedAliases.Occupancy} Record`,message:"Are you sure you want to delete this record?",contextualColorName:"warning",okButton:{text:"Yes, Delete",callbackFunction:function(){cityssm.postJSON(a.urlPrefix+"/lotOccupancies/doDeleteLotOccupancy",{lotOccupancyId:s},e=>{var t;const c=e;c.success?(u(),window.location.href=a.getLotOccupancyURL()):bulmaJS.alert({title:"Error Deleting Record",message:null!==(t=c.errorMessage)&&void 0!==t?t:"",contextualColorName:"danger"})})}}})}),null===(t=document.querySelector("#button--createWorkOrder"))||void 0===t||t.addEventListener("click",e=>{let t;function c(e){e.preventDefault(),cityssm.postJSON(a.urlPrefix+"/workOrders/doCreateWorkOrder",e.currentTarget,e=>{const c=e;c.success?(t(),bulmaJS.confirm({title:"Work Order Created Successfully",message:"Would you like to open the work order now?",contextualColorName:"success",okButton:{text:"Yes, Open the Work Order",callbackFunction:()=>{window.location.href=a.getWorkOrderURL(c.workOrderId,!0)}}})):bulmaJS.alert({title:"Error Creating Work Order",message:c.errorMessage,contextualColorName:"danger"})})}e.preventDefault(),cityssm.openHtmlModal("lotOccupancy-createWorkOrder",{onshow(e){var t;e.querySelector("#workOrderCreate--lotOccupancyId").value=s,e.querySelector("#workOrderCreate--workOrderOpenDateString").value=cityssm.dateToString(new Date);const c=e.querySelector("#workOrderCreate--workOrderTypeId"),n=exports.workOrderTypes;1===n.length&&(c.innerHTML="");for(const e of n){const n=document.createElement("option");n.value=e.workOrderTypeId.toString(),n.textContent=null!==(t=e.workOrderType)&&void 0!==t?t:"",c.append(n)}},onshown(e,n){var o;t=n,bulmaJS.toggleHtmlClipped(),e.querySelector("#workOrderCreate--workOrderTypeId").focus(),null===(o=e.querySelector("form"))||void 0===o||o.addEventListener("submit",c)},onremoved(){bulmaJS.toggleHtmlClipped(),document.querySelector("#button--createWorkOrder").focus()}})});const y=document.querySelector("#lotOccupancy--occupancyTypeId");if(l){const e=document.querySelector("#container--lotOccupancyFields");y.addEventListener("change",()=>{""!==y.value?cityssm.postJSON(a.urlPrefix+"/lotOccupancies/doGetOccupancyTypeFields",{occupancyTypeId:y.value},t=>{var c,n;const o=t;if(0===o.occupancyTypeFields.length)return void(e.innerHTML=`
\n

There are no additional fields for this ${a.escapedAliases.occupancy} type.

\n
`);e.innerHTML="";let s="";for(const t of o.occupancyTypeFields){s+=","+t.occupancyTypeFieldId.toString();const o="lotOccupancyFieldValue_"+t.occupancyTypeFieldId.toString(),a="lotOccupancy--"+o,l=document.createElement("div");if(l.className="field",l.innerHTML=`
`,l.querySelector("label").textContent=t.occupancyTypeField,""===(null!==(c=t.occupancyTypeFieldValues)&&void 0!==c?c:"")){const e=document.createElement("input");e.className="input",e.id=a,e.name=o,e.type="text",e.required=t.isRequired,e.minLength=t.minimumLength,e.maxLength=t.maximumLength,""!==(null!==(n=t.pattern)&&void 0!==n?n:"")&&(e.pattern=t.pattern),l.querySelector(".control").append(e)}else{l.querySelector(".control").innerHTML=`
\n \n
`;const e=l.querySelector("select");e.required=t.isRequired;const c=t.occupancyTypeFieldValues.split("\n");for(const t of c){const c=document.createElement("option");c.value=t,c.textContent=t,e.append(c)}}console.log(l),e.append(l)}e.insertAdjacentHTML("beforeend",``)}):e.innerHTML=`
\n

Select the ${a.escapedAliases.occupancy} type to load the available fields.

\n
`})}else{const e=y.value;y.addEventListener("change",()=>{y.value!==e&&bulmaJS.confirm({title:"Confirm Change",message:`Are you sure you want to change the ${a.escapedAliases.occupancy} type?\n\n This 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:()=>{r=!0}},cancelButton:{text:"Revert the Change",callbackFunction:()=>{y.value=e}}})})}const v=document.querySelector("#lotOccupancy--lotName");v.addEventListener("click",e=>{const t=e.currentTarget.value;let c,n,o,s;function l(e,t){document.querySelector("#lotOccupancy--lotId").value=e.toString(),document.querySelector("#lotOccupancy--lotName").value=t,i(),c()}function r(e){e.preventDefault();const t=e.currentTarget;l(t.dataset.lotId,t.dataset.lotName)}function u(){s.innerHTML=a.getLoadingParagraphHTML("Searching..."),cityssm.postJSON(a.urlPrefix+"/lots/doSearchLots",o,e=>{var t,c;const n=e;if(0===n.count)return void(s.innerHTML='
\n

No results.

\n
');const o=document.createElement("div");o.className="panel";for(const e of n.lots){const n=document.createElement("a");n.className="panel-block is-block",n.href="#",n.dataset.lotId=e.lotId.toString(),n.dataset.lotName=e.lotName,n.innerHTML='
'+cityssm.escapeHTML(null!==(t=e.lotName)&&void 0!==t?t:"")+'
'+cityssm.escapeHTML(null!==(c=e.mapName)&&void 0!==c?c:"")+'
'+cityssm.escapeHTML(e.lotStatus)+'
'+(e.lotOccupancyCount>0?"Currently Occupied":"")+"
",n.addEventListener("click",r),o.append(n)}s.innerHTML="",s.append(o)})}function d(e){e.preventDefault();const t=n.querySelector("#lotCreate--lotName").value;cityssm.postJSON(a.urlPrefix+"/lots/doCreateLot",e.currentTarget,e=>{var c;const n=e;n.success?l(n.lotId,t):bulmaJS.alert({title:`Error Creating ${a.escapedAliases.Lot}`,message:null!==(c=n.errorMessage)&&void 0!==c?c:"",contextualColorName:"danger"})})}cityssm.openHtmlModal("lotOccupancy-selectLot",{onshow(e){a.populateAliases(e)},onshown(e,a){var l;bulmaJS.toggleHtmlClipped(),n=e,c=a,bulmaJS.init(e);const r=e.querySelector("#lotSelect--lotName");""!==document.querySelector("#lotOccupancy--lotId").value&&(r.value=t),r.focus(),r.addEventListener("change",u);const i=e.querySelector("#lotSelect--occupancyStatus");if(i.addEventListener("change",u),""!==t&&(i.value=""),o=e.querySelector("#form--lotSelect"),s=e.querySelector("#resultsContainer--lotSelect"),o.addEventListener("submit",e=>{e.preventDefault()}),u(),exports.lotNamePattern){const t=exports.lotNamePattern;e.querySelector("#lotCreate--lotName").pattern=t.source}const p=e.querySelector("#lotCreate--lotTypeId");for(const e of exports.lotTypes){const t=document.createElement("option");t.value=e.lotTypeId.toString(),t.textContent=e.lotType,p.append(t)}const m=e.querySelector("#lotCreate--lotStatusId");for(const e of exports.lotStatuses){const t=document.createElement("option");t.value=e.lotStatusId.toString(),t.textContent=e.lotStatus,m.append(t)}const y=e.querySelector("#lotCreate--mapId");for(const e of exports.maps){const t=document.createElement("option");t.value=e.mapId.toString(),t.textContent=""===(null!==(l=e.mapName)&&void 0!==l?l:"")?"(No Name)":e.mapName,y.append(t)}e.querySelector("#form--lotCreate").addEventListener("submit",d)},onremoved(){bulmaJS.toggleHtmlClipped()}})}),null===(c=document.querySelector(".is-lot-view-button"))||void 0===c||c.addEventListener("click",()=>{const e=document.querySelector("#lotOccupancy--lotId").value;""===e?bulmaJS.alert({message:`No ${a.escapedAliases.lot} selected.`,contextualColorName:"info"}):window.open(a.urlPrefix+"/lots/"+e)}),null===(n=document.querySelector(".is-clear-lot-button"))||void 0===n||n.addEventListener("click",()=>{v.disabled?bulmaJS.alert({message:"You need to unlock the field before clearing it.",contextualColorName:"info"}):(v.value=`(No ${a.escapedAliases.Lot})`,document.querySelector("#lotOccupancy--lotId").value="",i())}),a.initializeDatePickers(d),null===(o=document.querySelector("#lotOccupancy--occupancyStartDateString"))||void 0===o||o.addEventListener("change",()=>{const e=document.querySelector("#lotOccupancy--occupancyEndDateString").bulmaCalendar.datePicker;e.min=document.querySelector("#lotOccupancy--occupancyStartDateString").value,e.refresh()}),a.initializeUnlockFieldButtons(d),Object.defineProperty(exports,"__esModule",{value:!0});let f=exports.lotOccupancyOccupants;function O(e){const t=Number.parseInt(e.currentTarget.closest("tr").dataset.lotOccupantIndex,10),c=f.find(e=>e.lotOccupantIndex===t);let n,o;function l(e){e.preventDefault(),cityssm.postJSON(a.urlPrefix+"/lotOccupancies/doUpdateLotOccupancyOccupant",n,e=>{var t;const c=e;c.success?(f=c.lotOccupancyOccupants,o(),h()):bulmaJS.alert({title:"Error Updating "+a.escapedAliases.Occupant,message:null!==(t=c.errorMessage)&&void 0!==t?t:"",contextualColorName:"danger"})})}cityssm.openHtmlModal("lotOccupancy-editOccupant",{onshow(e){var n;a.populateAliases(e),e.querySelector("#lotOccupancyOccupantEdit--lotOccupancyId").value=s,e.querySelector("#lotOccupancyOccupantEdit--lotOccupantIndex").value=t.toString();const o=e.querySelector("#lotOccupancyOccupantEdit--lotOccupantTypeId");let l=!1;for(const e of exports.lotOccupantTypes){const t=document.createElement("option");t.value=e.lotOccupantTypeId.toString(),t.textContent=e.lotOccupantType,t.dataset.occupantCommentTitle=e.occupantCommentTitle,t.dataset.fontAwesomeIconClass=e.fontAwesomeIconClass,e.lotOccupantTypeId===c.lotOccupantTypeId&&(t.selected=!0,l=!0),o.append(t)}if(!l){const e=document.createElement("option");e.value=c.lotOccupantTypeId.toString(),e.textContent=c.lotOccupantType,e.dataset.occupantCommentTitle=c.occupantCommentTitle,e.dataset.fontAwesomeIconClass=c.fontAwesomeIconClass,e.selected=!0,o.append(e)}e.querySelector("#lotOccupancyOccupantEdit--fontAwesomeIconClass").innerHTML=``,e.querySelector("#lotOccupancyOccupantEdit--occupantName").value=c.occupantName,e.querySelector("#lotOccupancyOccupantEdit--occupantFamilyName").value=c.occupantFamilyName,e.querySelector("#lotOccupancyOccupantEdit--occupantAddress1").value=c.occupantAddress1,e.querySelector("#lotOccupancyOccupantEdit--occupantAddress2").value=c.occupantAddress2,e.querySelector("#lotOccupancyOccupantEdit--occupantCity").value=c.occupantCity,e.querySelector("#lotOccupancyOccupantEdit--occupantProvince").value=c.occupantProvince,e.querySelector("#lotOccupancyOccupantEdit--occupantPostalCode").value=c.occupantPostalCode,e.querySelector("#lotOccupancyOccupantEdit--occupantPhoneNumber").value=c.occupantPhoneNumber,e.querySelector("#lotOccupancyOccupantEdit--occupantEmailAddress").value=c.occupantEmailAddress,e.querySelector("#lotOccupancyOccupantEdit--occupantCommentTitle").textContent=""===(null!==(n=c.occupantCommentTitle)&&void 0!==n?n:"")?"Comment":c.occupantCommentTitle,e.querySelector("#lotOccupancyOccupantEdit--occupantComment").value=c.occupantComment},onshown(e,t){bulmaJS.toggleHtmlClipped();const c=e.querySelector("#lotOccupancyOccupantEdit--lotOccupantTypeId");c.focus(),c.addEventListener("change",()=>{var t,n;const o=null!==(t=c.selectedOptions[0].dataset.fontAwesomeIconClass)&&void 0!==t?t:"user";e.querySelector("#lotOccupancyOccupantEdit--fontAwesomeIconClass").innerHTML=``;let a=null!==(n=c.selectedOptions[0].dataset.occupantCommentTitle)&&void 0!==n?n:"";""===a&&(a="Comment"),e.querySelector("#lotOccupancyOccupantEdit--occupantCommentTitle").textContent=a}),(n=e.querySelector("form")).addEventListener("submit",l),o=t},onremoved(){bulmaJS.toggleHtmlClipped()}})}function g(e){const t=e.currentTarget.closest("tr").dataset.lotOccupantIndex;bulmaJS.confirm({title:`Remove ${a.escapedAliases.Occupant}?`,message:`Are you sure you want to remove this ${a.escapedAliases.occupant}?`,okButton:{text:"Yes, Remove "+a.escapedAliases.Occupant,callbackFunction:function(){cityssm.postJSON(a.urlPrefix+"/lotOccupancies/doDeleteLotOccupancyOccupant",{lotOccupancyId:s,lotOccupantIndex:t},e=>{var t;const c=e;c.success?(f=c.lotOccupancyOccupants,h()):bulmaJS.alert({title:"Error Removing "+a.escapedAliases.Occupant,message:null!==(t=c.errorMessage)&&void 0!==t?t:"",contextualColorName:"danger"})})}},contextualColorName:"warning"})}function h(){var e,t,c,n,o,s,l,r,i,u,d;const p=document.querySelector("#container--lotOccupancyOccupants");if(cityssm.clearElement(p),0===f.length)return void(p.innerHTML=`
\n

There are no ${a.escapedAliases.occupants} associated with this record.

\n
`);const m=document.createElement("table");m.className="table is-fullwidth is-striped is-hoverable",m.innerHTML=`\n ${a.escapedAliases.Occupant}\n Address\n Other Contact\n Comment\n Options\n \n `;for(const a of f){const p=document.createElement("tr");p.dataset.lotOccupantIndex=a.lotOccupantIndex.toString(),p.innerHTML=""+cityssm.escapeHTML(""===(null!==(e=a.occupantName)&&void 0!==e?e:"")&&""===(null!==(t=a.occupantFamilyName)&&void 0!==t?t:"")?"(No Name)":a.occupantName+" "+a.occupantFamilyName)+'
'+cityssm.escapeHTML(a.lotOccupantType)+""+(""===(null!==(c=a.occupantAddress1)&&void 0!==c?c:"")?"":cityssm.escapeHTML(a.occupantAddress1)+"
")+(""===(null!==(n=a.occupantAddress2)&&void 0!==n?n:"")?"":cityssm.escapeHTML(a.occupantAddress2)+"
")+(""===(null!==(o=a.occupantCity)&&void 0!==o?o:"")?"":cityssm.escapeHTML(a.occupantCity)+", ")+cityssm.escapeHTML(null!==(s=a.occupantProvince)&&void 0!==s?s:"")+"
"+cityssm.escapeHTML(null!==(l=a.occupantPostalCode)&&void 0!==l?l:"")+""+(""===(null!==(r=a.occupantPhoneNumber)&&void 0!==r?r:"")?"":cityssm.escapeHTML(a.occupantPhoneNumber)+"
")+(""===(null!==(i=a.occupantEmailAddress)&&void 0!==i?i:"")?"":cityssm.escapeHTML(a.occupantEmailAddress))+''+cityssm.escapeHTML(null!==(d=a.occupantComment)&&void 0!==d?d:"")+'
',p.querySelector(".button--edit").addEventListener("click",O),p.querySelector(".button--delete").addEventListener("click",g),m.querySelector("tbody").append(p)}p.append(m)}if(delete exports.lotOccupancyOccupants,l){const e=document.querySelector("#lotOccupancy--lotOccupantTypeId");e.addEventListener("change",()=>{var t;const c=d.querySelectorAll("[data-table='LotOccupancyOccupant']");for(const t of c)t.disabled=""===e.value;let n=null!==(t=e.selectedOptions[0].dataset.occupantCommentTitle)&&void 0!==t?t:"";""===n&&(n="Comment"),d.querySelector("#lotOccupancy--occupantCommentTitle").textContent=n})}else h();if(null===(S=document.querySelector("#button--addOccupant"))||void 0===S||S.addEventListener("click",()=>{let e,t,c,n;function o(t){cityssm.postJSON(a.urlPrefix+"/lotOccupancies/doAddLotOccupancyOccupant",t,t=>{var c;const n=t;n.success?(f=n.lotOccupancyOccupants,e(),h()):bulmaJS.alert({title:`Error Adding ${a.escapedAliases.Occupant}`,message:null!==(c=n.errorMessage)&&void 0!==c?c:"",contextualColorName:"danger"})})}function l(e){e.preventDefault(),o(t)}let r=[];function i(e){e.preventDefault();const t=e.currentTarget,c=r[Number.parseInt(t.dataset.index,10)],n=t.closest(".modal").querySelector("#lotOccupancyOccupantCopy--lotOccupantTypeId").value;""===n?bulmaJS.alert({title:`No ${a.escapedAliases.Occupant} Type Selected`,message:`Select a type to apply to the newly added ${a.escapedAliases.occupant}.`,contextualColorName:"warning"}):(c.lotOccupantTypeId=Number.parseInt(n,10),c.lotOccupancyId=Number.parseInt(s,10),o(c))}function u(e){e.preventDefault(),""!==c.querySelector("#lotOccupancyOccupantCopy--searchFilter").value?(n.innerHTML=a.getLoadingParagraphHTML("Searching..."),cityssm.postJSON(a.urlPrefix+"/lotOccupancies/doSearchPastOccupants",c,e=>{var t,c,o,a,s,l,u,d,p;r=e.occupants;const m=document.createElement("div");m.className="panel";for(const[e,n]of r.entries()){const r=document.createElement("a");r.className="panel-block is-block",r.dataset.index=e.toString(),r.innerHTML=""+cityssm.escapeHTML(null!==(t=n.occupantName)&&void 0!==t?t:"")+" "+cityssm.escapeHTML(null!==(c=n.occupantFamilyName)&&void 0!==c?c:"")+'
'+cityssm.escapeHTML(null!==(o=n.occupantAddress1)&&void 0!==o?o:"")+"
"+(""===(null!==(a=n.occupantAddress2)&&void 0!==a?a:"")?"":cityssm.escapeHTML(n.occupantAddress2)+"
")+cityssm.escapeHTML(null!==(s=n.occupantCity)&&void 0!==s?s:"")+", "+cityssm.escapeHTML(null!==(l=n.occupantProvince)&&void 0!==l?l:"")+"
"+cityssm.escapeHTML(null!==(u=n.occupantPostalCode)&&void 0!==u?u:"")+'
'+(""===(null!==(d=n.occupantPhoneNumber)&&void 0!==d?d:"")?"":cityssm.escapeHTML(n.occupantPhoneNumber)+"
")+cityssm.escapeHTML(null!==(p=n.occupantEmailAddress)&&void 0!==p?p:"")+"
",r.addEventListener("click",i),m.append(r)}n.innerHTML="",n.append(m)})):n.innerHTML='

Enter a partial name or address in the search field above.

'}cityssm.openHtmlModal("lotOccupancy-addOccupant",{onshow(e){a.populateAliases(e),e.querySelector("#lotOccupancyOccupantAdd--lotOccupancyId").value=s;const t=e.querySelector("#lotOccupancyOccupantAdd--lotOccupantTypeId"),c=e.querySelector("#lotOccupancyOccupantCopy--lotOccupantTypeId");for(const e of exports.lotOccupantTypes){const n=document.createElement("option");n.value=e.lotOccupantTypeId.toString(),n.textContent=e.lotOccupantType,n.dataset.occupantCommentTitle=e.occupantCommentTitle,n.dataset.fontAwesomeIconClass=e.fontAwesomeIconClass,t.append(n),c.append(n.cloneNode(!0))}e.querySelector("#lotOccupancyOccupantAdd--occupantCity").value=exports.occupantCityDefault,e.querySelector("#lotOccupancyOccupantAdd--occupantProvince").value=exports.occupantProvinceDefault},onshown(o,a){bulmaJS.toggleHtmlClipped(),bulmaJS.init(o);const s=o.querySelector("#lotOccupancyOccupantAdd--lotOccupantTypeId");s.focus(),s.addEventListener("change",()=>{var e,t;const c=null!==(e=s.selectedOptions[0].dataset.fontAwesomeIconClass)&&void 0!==e?e:"user";o.querySelector("#lotOccupancyOccupantAdd--fontAwesomeIconClass").innerHTML=``;let n=null!==(t=s.selectedOptions[0].dataset.occupantCommentTitle)&&void 0!==t?t:"";""===n&&(n="Comment"),o.querySelector("#lotOccupancyOccupantAdd--occupantCommentTitle").textContent=n}),(t=o.querySelector("#form--lotOccupancyOccupantAdd")).addEventListener("submit",l),n=o.querySelector("#lotOccupancyOccupantCopy--searchResults"),(c=o.querySelector("#form--lotOccupancyOccupantCopy")).addEventListener("submit",e=>{e.preventDefault()}),o.querySelector("#lotOccupancyOccupantCopy--searchFilter").addEventListener("change",u),e=a},onremoved(){bulmaJS.toggleHtmlClipped(),document.querySelector("#button--addOccupant").focus()}})}),!l){var S;Object.defineProperty(exports,"__esModule",{value:!0});let e=exports.lotOccupancyComments;function b(t){const c=Number.parseInt(t.currentTarget.closest("tr").dataset.lotOccupancyCommentId,10),n=e.find(e=>e.lotOccupancyCommentId===c);let o,l;function r(t){t.preventDefault(),cityssm.postJSON(a.urlPrefix+"/lotOccupancies/doUpdateLotOccupancyComment",o,t=>{var c;t.success?(e=t.lotOccupancyComments,l(),T()):bulmaJS.alert({title:"Error Updating Comment",message:null!==(c=t.errorMessage)&&void 0!==c?c:"",contextualColorName:"danger"})})}cityssm.openHtmlModal("lotOccupancy-editComment",{onshow(e){a.populateAliases(e),e.querySelector("#lotOccupancyCommentEdit--lotOccupancyId").value=s,e.querySelector("#lotOccupancyCommentEdit--lotOccupancyCommentId").value=c.toString(),e.querySelector("#lotOccupancyCommentEdit--lotOccupancyComment").value=n.lotOccupancyComment;const t=e.querySelector("#lotOccupancyCommentEdit--lotOccupancyCommentDateString");t.value=n.lotOccupancyCommentDateString;const o=cityssm.dateToString(new Date);t.max=n.lotOccupancyCommentDateString<=o?o:n.lotOccupancyCommentDateString,e.querySelector("#lotOccupancyCommentEdit--lotOccupancyCommentTimeString").value=n.lotOccupancyCommentTimeString},onshown(e,t){bulmaJS.toggleHtmlClipped(),a.initializeDatePickers(e),e.querySelector("#lotOccupancyCommentEdit--lotOccupancyComment").focus(),(o=e.querySelector("form")).addEventListener("submit",r),l=t},onremoved(){bulmaJS.toggleHtmlClipped()}})}function C(t){const c=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:function(){cityssm.postJSON(a.urlPrefix+"/lotOccupancies/doDeleteLotOccupancyComment",{lotOccupancyId:s,lotOccupancyCommentId:c},t=>{var c;t.success?(e=t.lotOccupancyComments,T()):bulmaJS.alert({title:"Error Removing Comment",message:null!==(c=t.errorMessage)&&void 0!==c?c:"",contextualColorName:"danger"})})}},contextualColorName:"warning"})}function T(){var t,c,n;const o=document.querySelector("#container--lotOccupancyComments");if(0===e.length)return void(o.innerHTML='

There are no comments associated with this record.

');const a=document.createElement("table");a.className="table is-fullwidth is-striped is-hoverable",a.innerHTML='CommentorComment DateCommentOptions';for(const o of e){const e=document.createElement("tr");e.dataset.lotOccupancyCommentId=o.lotOccupancyCommentId.toString(),e.innerHTML=""+cityssm.escapeHTML(null!==(t=o.recordCreate_userName)&&void 0!==t?t:"")+""+(null!==(c=o.lotOccupancyCommentDateString)&&void 0!==c?c:"")+(0===o.lotOccupancyCommentTime?"":" "+o.lotOccupancyCommentTimeString)+""+cityssm.escapeHTML(null!==(n=o.lotOccupancyComment)&&void 0!==n?n:"")+'
',e.querySelector(".button--edit").addEventListener("click",b),e.querySelector(".button--delete").addEventListener("click",C),a.querySelector("tbody").append(e)}o.innerHTML="",o.append(a)}delete exports.lotOccupancyComments,null===(S=document.querySelector("#button--addComment"))||void 0===S||S.addEventListener("click",()=>{let t,c;function n(n){n.preventDefault(),cityssm.postJSON(a.urlPrefix+"/lotOccupancies/doAddLotOccupancyComment",t,t=>{var n;t.success?(e=t.lotOccupancyComments,c(),T()):bulmaJS.alert({title:"Error Adding Comment",message:null!==(n=t.errorMessage)&&void 0!==n?n:"",contextualColorName:"danger"})})}cityssm.openHtmlModal("lotOccupancy-addComment",{onshow(e){a.populateAliases(e),e.querySelector("#lotOccupancyCommentAdd--lotOccupancyId").value=s},onshown(e,o){bulmaJS.toggleHtmlClipped(),e.querySelector("#lotOccupancyCommentAdd--lotOccupancyComment").focus(),(t=e.querySelector("form")).addEventListener("submit",n),c=o},onremoved:()=>{bulmaJS.toggleHtmlClipped(),document.querySelector("#button--addComment").focus()}})}),T(),Object.defineProperty(exports,"__esModule",{value:!0});let t=exports.lotOccupancyFees;delete exports.lotOccupancyFees;const c=document.querySelector("#container--lotOccupancyFees");function x(){let e=0;for(const c of t)e+=(c.feeAmount+c.taxAmount)*c.quantity;return e}function L(e){const c=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:function(){cityssm.postJSON(a.urlPrefix+"/lotOccupancies/doDeleteLotOccupancyFee",{lotOccupancyId:s,feeId:c},e=>{var c;const n=e;n.success?(t=n.lotOccupancyFees,q()):bulmaJS.alert({title:"Error Deleting Fee",message:null!==(c=n.errorMessage)&&void 0!==c?c:"",contextualColorName:"danger"})})}}})}function q(){var e,n,o;if(0===t.length)return c.innerHTML='
\n

There are no fees associated with this record.

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

'+cityssm.escapeHTML(null!==(t=o.feeCategory)&&void 0!==t?t:"")+'

';let p=!1;for(const t of o.fees){if(null!==c.querySelector(`.container--lotOccupancyFee[data-fee-id='${t.feeId}'][data-include-quantity='0']`))continue;let l=!0;const m=((null!==(n=o.feeCategory)&&void 0!==n?n:"")+" "+(null!==(a=t.feeName)&&void 0!==a?a:"")+" "+(null!==(s=t.feeDescription)&&void 0!==s?s:"")).toLowerCase();for(const e of d)if(!m.includes(e)){l=!1;break}if(!l)continue;p=!0;const y=document.createElement("a");y.className="panel-block is-block container--fee",y.dataset.feeId=t.feeId.toString(),y.dataset.feeCategoryId=o.feeCategoryId.toString(),y.href="#",y.innerHTML=""+cityssm.escapeHTML(null!==(r=t.feeName)&&void 0!==r?r:"")+"
"+cityssm.escapeHTML(null!==(u=t.feeDescription)&&void 0!==u?u:"").replace(/\n/g,"
")+"
",y.addEventListener("click",i),e.querySelector(".panel").append(y)}p&&l.append(e)}}cityssm.openHtmlModal("lotOccupancy-addFee",{onshow(t){o=t.querySelector("#feeSelect--feeName"),l=t.querySelector("#resultsContainer--feeSelect"),cityssm.postJSON(a.urlPrefix+"/lotOccupancies/doGetFees",{lotOccupancyId:s},t=>{e=t.feeCategories,o.disabled=!1,o.addEventListener("keyup",u),o.focus(),u()})},onshown(){bulmaJS.toggleHtmlClipped()},onhidden(){q()},onremoved(){bulmaJS.toggleHtmlClipped(),n.focus()}})});let o=exports.lotOccupancyTransactions;delete exports.lotOccupancyTransactions;const l=document.querySelector("#container--lotOccupancyTransactions");function N(e){const t=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:function(){cityssm.postJSON(a.urlPrefix+"/lotOccupancies/doDeleteLotOccupancyTransaction",{lotOccupancyId:s,transactionIndex:t},e=>{var t;const c=e;c.success?(o=c.lotOccupancyTransactions,E()):bulmaJS.alert({title:"Error Deleting Transaction",message:null!==(t=c.errorMessage)&&void 0!==t?t:"",contextualColorName:"danger"})})}}})}function E(){var e,c,n;if(0===o.length)return void(l.innerHTML='

There are no transactions associated with this record.

');l.innerHTML=`\n \n \n \n \n \n \n \n \n \n \n \n \n
Date${a.escapedAliases.ExternalReceiptNumber}AmountOptions
Transaction Total
`;let s=0;for(const t of o){s+=t.transactionAmount;const o=document.createElement("tr");o.className="container--lotOccupancyTransaction",o.dataset.transactionIndex=t.transactionIndex.toString();let r="";""!==t.externalReceiptNumber&&(r=cityssm.escapeHTML(null!==(e=t.externalReceiptNumber)&&void 0!==e?e:""),a.dynamicsGPIntegrationIsEnabled&&(void 0===t.dynamicsGPDocument?r+=' \n \n ':t.dynamicsGPDocument.documentTotal.toFixed(2)===t.transactionAmount.toFixed(2)?r+=' \n \n ':r+=` \n \n `),r+="
"),o.innerHTML=""+(null!==(c=t.transactionDateString)&&void 0!==c?c:"")+""+r+""+cityssm.escapeHTML(null!==(n=t.transactionNote)&&void 0!==n?n:"")+'$'+t.transactionAmount.toFixed(2)+'',o.querySelector("button").addEventListener("click",N),l.querySelector("tbody").append(o)}l.querySelector("#lotOccupancyTransactions--grandTotal").textContent="$"+s.toFixed(2);const r=x();r.toFixed(2)!==s.toFixed(2)&&l.insertAdjacentHTML("afterbegin",'
Outstanding Balance
$'+(r-s).toFixed(2)+"
")}const r=document.querySelector("#button--addTransaction");r.addEventListener("click",()=>{let e,t,c;function n(e){e.preventDefault(),cityssm.postJSON(a.urlPrefix+"/lotOccupancies/doAddLotOccupancyTransaction",e.currentTarget,e=>{var t;const n=e;n.success?(o=n.lotOccupancyTransactions,c(),E()):bulmaJS.confirm({title:"Error Adding Transaction",message:null!==(t=n.errorMessage)&&void 0!==t?t:"",contextualColorName:"danger"})})}function l(){const c=t.value,n=t.closest(".control").querySelector(".icon"),o=t.closest(".field").querySelector(".help");if(""===c)return o.innerHTML=" ",void(n.innerHTML='');cityssm.postJSON(a.urlPrefix+"/lotOccupancies/doGetDynamicsGPDocument",{externalReceiptNumber:c},t=>{const c=t;c.success&&void 0!==c.dynamicsGPDocument?e.valueAsNumber===c.dynamicsGPDocument.documentTotal?(o.textContent="Matching Document Found",n.innerHTML=''):(o.textContent="Matching Document: $"+c.dynamicsGPDocument.documentTotal.toFixed(2),n.innerHTML=''):(o.textContent="No Matching Document Found",n.innerHTML='')})}cityssm.openHtmlModal("lotOccupancy-addTransaction",{onshow(c){a.populateAliases(c),c.querySelector("#lotOccupancyTransactionAdd--lotOccupancyId").value=s.toString();const n=x(),r=function(){let e=0;for(const t of o)e+=t.transactionAmount;return e}();if((e=c.querySelector("#lotOccupancyTransactionAdd--transactionAmount")).min=(-1*r).toFixed(2),e.max=Math.max(n-r,0).toFixed(2),e.value=Math.max(n-r,0).toFixed(2),a.dynamicsGPIntegrationIsEnabled){const n=(t=c.querySelector("#lotOccupancyTransactionAdd--externalReceiptNumber")).closest(".control");n.classList.add("has-icons-right"),n.insertAdjacentHTML("beforeend",''),n.insertAdjacentHTML("afterend",'

'),t.addEventListener("change",l),e.addEventListener("change",l),l()}},onshown(t,o){bulmaJS.toggleHtmlClipped(),e.focus(),c=o,t.querySelector("form").addEventListener("submit",n)},onremoved(){bulmaJS.toggleHtmlClipped(),r.focus()}})}),q()}})(); \ No newline at end of file +"use strict";Object.defineProperty(exports,"__esModule",{value:!0}),(()=>{var e,t,c,n,a;const o=exports.los,s=document.querySelector("#lotOccupancy--lotOccupancyId").value,l=""===s;let r=l;function i(){var e;o.setUnsavedChanges(),null===(e=document.querySelector("button[type='submit'][form='form--lotOccupancy']"))||void 0===e||e.classList.remove("is-light")}function u(){var e;o.clearUnsavedChanges(),null===(e=document.querySelector("button[type='submit'][form='form--lotOccupancy']"))||void 0===e||e.classList.add("is-light")}const d=document.querySelector("#form--lotOccupancy");d.addEventListener("submit",e=>{e.preventDefault(),cityssm.postJSON(o.urlPrefix+"/lotOccupancies/"+(l?"doCreateLotOccupancy":"doUpdateLotOccupancy"),d,e=>{var t;const c=e;c.success?(u(),l||r?window.location.href=o.getLotOccupancyURL(c.lotOccupancyId,!0,!0):bulmaJS.alert({message:`${o.escapedAliases.Occupancy} Updated Successfully`,contextualColorName:"success"})):bulmaJS.alert({title:"Error Saving "+o.escapedAliases.Occupancy,message:null!==(t=c.errorMessage)&&void 0!==t?t:"",contextualColorName:"danger"})})});const p=d.querySelectorAll("input, select");for(const e of p)e.addEventListener("change",i);function m(){cityssm.postJSON(o.urlPrefix+"/lotOccupancies/doCopyLotOccupancy",{lotOccupancyId:s},e=>{var t;const c=e;c.success?(u(),window.location.href=o.getLotOccupancyURL(c.lotOccupancyId,!0)):bulmaJS.alert({title:"Error Copying Record",message:null!==(t=c.errorMessage)&&void 0!==t?t:"",contextualColorName:"danger"})})}null===(S=document.querySelector("#button--copyLotOccupancy"))||void 0===S||S.addEventListener("click",e=>{e.preventDefault(),o.hasUnsavedChanges()?bulmaJS.alert({title:"Unsaved Changes",message:"Please save all unsaved changes before continuing.",contextualColorName:"warning"}):bulmaJS.confirm({title:`Copy ${o.escapedAliases.Occupancy} Record as New`,message:"Are you sure you want to copy this record to a new record?",contextualColorName:"info",okButton:{text:"Yes, Copy",callbackFunction:m}})}),null===(e=document.querySelector("#button--deleteLotOccupancy"))||void 0===e||e.addEventListener("click",e=>{e.preventDefault(),bulmaJS.confirm({title:`Delete ${o.escapedAliases.Occupancy} Record`,message:"Are you sure you want to delete this record?",contextualColorName:"warning",okButton:{text:"Yes, Delete",callbackFunction:function(){cityssm.postJSON(o.urlPrefix+"/lotOccupancies/doDeleteLotOccupancy",{lotOccupancyId:s},e=>{var t;const c=e;c.success?(u(),window.location.href=o.getLotOccupancyURL()):bulmaJS.alert({title:"Error Deleting Record",message:null!==(t=c.errorMessage)&&void 0!==t?t:"",contextualColorName:"danger"})})}}})}),null===(t=document.querySelector("#button--createWorkOrder"))||void 0===t||t.addEventListener("click",e=>{let t;function c(e){e.preventDefault(),cityssm.postJSON(o.urlPrefix+"/workOrders/doCreateWorkOrder",e.currentTarget,e=>{const c=e;c.success?(t(),bulmaJS.confirm({title:"Work Order Created Successfully",message:"Would you like to open the work order now?",contextualColorName:"success",okButton:{text:"Yes, Open the Work Order",callbackFunction:()=>{window.location.href=o.getWorkOrderURL(c.workOrderId,!0)}}})):bulmaJS.alert({title:"Error Creating Work Order",message:c.errorMessage,contextualColorName:"danger"})})}e.preventDefault(),cityssm.openHtmlModal("lotOccupancy-createWorkOrder",{onshow(e){var t;e.querySelector("#workOrderCreate--lotOccupancyId").value=s,e.querySelector("#workOrderCreate--workOrderOpenDateString").value=cityssm.dateToString(new Date);const c=e.querySelector("#workOrderCreate--workOrderTypeId"),n=exports.workOrderTypes;1===n.length&&(c.innerHTML="");for(const e of n){const n=document.createElement("option");n.value=e.workOrderTypeId.toString(),n.textContent=null!==(t=e.workOrderType)&&void 0!==t?t:"",c.append(n)}},onshown(e,n){var a;t=n,bulmaJS.toggleHtmlClipped(),e.querySelector("#workOrderCreate--workOrderTypeId").focus(),null===(a=e.querySelector("form"))||void 0===a||a.addEventListener("submit",c)},onremoved(){bulmaJS.toggleHtmlClipped(),document.querySelector("#button--createWorkOrder").focus()}})});const y=document.querySelector("#lotOccupancy--occupancyTypeId");if(l){const e=document.querySelector("#container--lotOccupancyFields");y.addEventListener("change",()=>{""!==y.value?cityssm.postJSON(o.urlPrefix+"/lotOccupancies/doGetOccupancyTypeFields",{occupancyTypeId:y.value},t=>{var c,n;const a=t;if(0===a.occupancyTypeFields.length)return void(e.innerHTML=`
\n

There are no additional fields for this ${o.escapedAliases.occupancy} type.

\n
`);e.innerHTML="";let s="";for(const t of a.occupancyTypeFields){s+=","+t.occupancyTypeFieldId.toString();const a="lotOccupancyFieldValue_"+t.occupancyTypeFieldId.toString(),o="lotOccupancy--"+a,l=document.createElement("div");if(l.className="field",l.innerHTML=`
`,l.querySelector("label").textContent=t.occupancyTypeField,""===(null!==(c=t.occupancyTypeFieldValues)&&void 0!==c?c:"")){const e=document.createElement("input");e.className="input",e.id=o,e.name=a,e.type="text",e.required=t.isRequired,e.minLength=t.minimumLength,e.maxLength=t.maximumLength,""!==(null!==(n=t.pattern)&&void 0!==n?n:"")&&(e.pattern=t.pattern),l.querySelector(".control").append(e)}else{l.querySelector(".control").innerHTML=`
\n \n
`;const e=l.querySelector("select");e.required=t.isRequired;const c=t.occupancyTypeFieldValues.split("\n");for(const t of c){const c=document.createElement("option");c.value=t,c.textContent=t,e.append(c)}}console.log(l),e.append(l)}e.insertAdjacentHTML("beforeend",``)}):e.innerHTML=`
\n

Select the ${o.escapedAliases.occupancy} type to load the available fields.

\n
`})}else{const e=y.value;y.addEventListener("change",()=>{y.value!==e&&bulmaJS.confirm({title:"Confirm Change",message:`Are you sure you want to change the ${o.escapedAliases.occupancy} type?\n\n This 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:()=>{r=!0}},cancelButton:{text:"Revert the Change",callbackFunction:()=>{y.value=e}}})})}const v=document.querySelector("#lotOccupancy--lotName");v.addEventListener("click",e=>{const t=e.currentTarget.value;let c,n,a,s;function l(e,t){document.querySelector("#lotOccupancy--lotId").value=e.toString(),document.querySelector("#lotOccupancy--lotName").value=t,i(),c()}function r(e){e.preventDefault();const t=e.currentTarget;l(t.dataset.lotId,t.dataset.lotName)}function u(){s.innerHTML=o.getLoadingParagraphHTML("Searching..."),cityssm.postJSON(o.urlPrefix+"/lots/doSearchLots",a,e=>{var t,c;const n=e;if(0===n.count)return void(s.innerHTML='
\n

No results.

\n
');const a=document.createElement("div");a.className="panel";for(const e of n.lots){const n=document.createElement("a");n.className="panel-block is-block",n.href="#",n.dataset.lotId=e.lotId.toString(),n.dataset.lotName=e.lotName,n.innerHTML='
'+cityssm.escapeHTML(null!==(t=e.lotName)&&void 0!==t?t:"")+'
'+cityssm.escapeHTML(null!==(c=e.mapName)&&void 0!==c?c:"")+'
'+cityssm.escapeHTML(e.lotStatus)+'
'+(e.lotOccupancyCount>0?"Currently Occupied":"")+"
",n.addEventListener("click",r),a.append(n)}s.innerHTML="",s.append(a)})}function d(e){e.preventDefault();const t=n.querySelector("#lotCreate--lotName").value;cityssm.postJSON(o.urlPrefix+"/lots/doCreateLot",e.currentTarget,e=>{var c;const n=e;n.success?l(n.lotId,t):bulmaJS.alert({title:`Error Creating ${o.escapedAliases.Lot}`,message:null!==(c=n.errorMessage)&&void 0!==c?c:"",contextualColorName:"danger"})})}cityssm.openHtmlModal("lotOccupancy-selectLot",{onshow(e){o.populateAliases(e)},onshown(e,o){var l;bulmaJS.toggleHtmlClipped(),n=e,c=o,bulmaJS.init(e);const r=e.querySelector("#lotSelect--lotName");""!==document.querySelector("#lotOccupancy--lotId").value&&(r.value=t),r.focus(),r.addEventListener("change",u);const i=e.querySelector("#lotSelect--occupancyStatus");if(i.addEventListener("change",u),""!==t&&(i.value=""),a=e.querySelector("#form--lotSelect"),s=e.querySelector("#resultsContainer--lotSelect"),a.addEventListener("submit",e=>{e.preventDefault()}),u(),exports.lotNamePattern){const t=exports.lotNamePattern;e.querySelector("#lotCreate--lotName").pattern=t.source}const p=e.querySelector("#lotCreate--lotTypeId");for(const e of exports.lotTypes){const t=document.createElement("option");t.value=e.lotTypeId.toString(),t.textContent=e.lotType,p.append(t)}const m=e.querySelector("#lotCreate--lotStatusId");for(const e of exports.lotStatuses){const t=document.createElement("option");t.value=e.lotStatusId.toString(),t.textContent=e.lotStatus,m.append(t)}const y=e.querySelector("#lotCreate--mapId");for(const e of exports.maps){const t=document.createElement("option");t.value=e.mapId.toString(),t.textContent=""===(null!==(l=e.mapName)&&void 0!==l?l:"")?"(No Name)":e.mapName,y.append(t)}e.querySelector("#form--lotCreate").addEventListener("submit",d)},onremoved(){bulmaJS.toggleHtmlClipped()}})}),null===(c=document.querySelector(".is-lot-view-button"))||void 0===c||c.addEventListener("click",()=>{const e=document.querySelector("#lotOccupancy--lotId").value;""===e?bulmaJS.alert({message:`No ${o.escapedAliases.lot} selected.`,contextualColorName:"info"}):window.open(o.urlPrefix+"/lots/"+e)}),null===(n=document.querySelector(".is-clear-lot-button"))||void 0===n||n.addEventListener("click",()=>{v.disabled?bulmaJS.alert({message:"You need to unlock the field before clearing it.",contextualColorName:"info"}):(v.value=`(No ${o.escapedAliases.Lot})`,document.querySelector("#lotOccupancy--lotId").value="",i())}),o.initializeDatePickers(d),null===(a=document.querySelector("#lotOccupancy--occupancyStartDateString"))||void 0===a||a.addEventListener("change",()=>{const e=document.querySelector("#lotOccupancy--occupancyEndDateString").bulmaCalendar.datePicker;e.min=document.querySelector("#lotOccupancy--occupancyStartDateString").value,e.refresh()}),o.initializeUnlockFieldButtons(d),Object.defineProperty(exports,"__esModule",{value:!0});let f=exports.lotOccupancyOccupants;function O(e){const t=Number.parseInt(e.currentTarget.closest("tr").dataset.lotOccupantIndex,10),c=f.find(e=>e.lotOccupantIndex===t);let n,a;function l(e){e.preventDefault(),cityssm.postJSON(o.urlPrefix+"/lotOccupancies/doUpdateLotOccupancyOccupant",n,e=>{var t;const c=e;c.success?(f=c.lotOccupancyOccupants,a(),h()):bulmaJS.alert({title:"Error Updating "+o.escapedAliases.Occupant,message:null!==(t=c.errorMessage)&&void 0!==t?t:"",contextualColorName:"danger"})})}cityssm.openHtmlModal("lotOccupancy-editOccupant",{onshow(e){var n;o.populateAliases(e),e.querySelector("#lotOccupancyOccupantEdit--lotOccupancyId").value=s,e.querySelector("#lotOccupancyOccupantEdit--lotOccupantIndex").value=t.toString();const a=e.querySelector("#lotOccupancyOccupantEdit--lotOccupantTypeId");let l=!1;for(const e of exports.lotOccupantTypes){const t=document.createElement("option");t.value=e.lotOccupantTypeId.toString(),t.textContent=e.lotOccupantType,t.dataset.occupantCommentTitle=e.occupantCommentTitle,t.dataset.fontAwesomeIconClass=e.fontAwesomeIconClass,e.lotOccupantTypeId===c.lotOccupantTypeId&&(t.selected=!0,l=!0),a.append(t)}if(!l){const e=document.createElement("option");e.value=c.lotOccupantTypeId.toString(),e.textContent=c.lotOccupantType,e.dataset.occupantCommentTitle=c.occupantCommentTitle,e.dataset.fontAwesomeIconClass=c.fontAwesomeIconClass,e.selected=!0,a.append(e)}e.querySelector("#lotOccupancyOccupantEdit--fontAwesomeIconClass").innerHTML=``,e.querySelector("#lotOccupancyOccupantEdit--occupantName").value=c.occupantName,e.querySelector("#lotOccupancyOccupantEdit--occupantFamilyName").value=c.occupantFamilyName,e.querySelector("#lotOccupancyOccupantEdit--occupantAddress1").value=c.occupantAddress1,e.querySelector("#lotOccupancyOccupantEdit--occupantAddress2").value=c.occupantAddress2,e.querySelector("#lotOccupancyOccupantEdit--occupantCity").value=c.occupantCity,e.querySelector("#lotOccupancyOccupantEdit--occupantProvince").value=c.occupantProvince,e.querySelector("#lotOccupancyOccupantEdit--occupantPostalCode").value=c.occupantPostalCode,e.querySelector("#lotOccupancyOccupantEdit--occupantPhoneNumber").value=c.occupantPhoneNumber,e.querySelector("#lotOccupancyOccupantEdit--occupantEmailAddress").value=c.occupantEmailAddress,e.querySelector("#lotOccupancyOccupantEdit--occupantCommentTitle").textContent=""===(null!==(n=c.occupantCommentTitle)&&void 0!==n?n:"")?"Comment":c.occupantCommentTitle,e.querySelector("#lotOccupancyOccupantEdit--occupantComment").value=c.occupantComment},onshown(e,t){bulmaJS.toggleHtmlClipped();const c=e.querySelector("#lotOccupancyOccupantEdit--lotOccupantTypeId");c.focus(),c.addEventListener("change",()=>{var t,n;const a=null!==(t=c.selectedOptions[0].dataset.fontAwesomeIconClass)&&void 0!==t?t:"user";e.querySelector("#lotOccupancyOccupantEdit--fontAwesomeIconClass").innerHTML=``;let o=null!==(n=c.selectedOptions[0].dataset.occupantCommentTitle)&&void 0!==n?n:"";""===o&&(o="Comment"),e.querySelector("#lotOccupancyOccupantEdit--occupantCommentTitle").textContent=o}),(n=e.querySelector("form")).addEventListener("submit",l),a=t},onremoved(){bulmaJS.toggleHtmlClipped()}})}function g(e){const t=e.currentTarget.closest("tr").dataset.lotOccupantIndex;bulmaJS.confirm({title:`Remove ${o.escapedAliases.Occupant}?`,message:`Are you sure you want to remove this ${o.escapedAliases.occupant}?`,okButton:{text:"Yes, Remove "+o.escapedAliases.Occupant,callbackFunction:function(){cityssm.postJSON(o.urlPrefix+"/lotOccupancies/doDeleteLotOccupancyOccupant",{lotOccupancyId:s,lotOccupantIndex:t},e=>{var t;const c=e;c.success?(f=c.lotOccupancyOccupants,h()):bulmaJS.alert({title:"Error Removing "+o.escapedAliases.Occupant,message:null!==(t=c.errorMessage)&&void 0!==t?t:"",contextualColorName:"danger"})})}},contextualColorName:"warning"})}function h(){var e,t,c,n,a,s,l,r,i,u,d;const p=document.querySelector("#container--lotOccupancyOccupants");if(cityssm.clearElement(p),0===f.length)return void(p.innerHTML=`
\n

There are no ${o.escapedAliases.occupants} associated with this record.

\n
`);const m=document.createElement("table");m.className="table is-fullwidth is-striped is-hoverable",m.innerHTML=`\n ${o.escapedAliases.Occupant}\n Address\n Other Contact\n Comment\n Options\n \n `;for(const o of f){const p=document.createElement("tr");p.dataset.lotOccupantIndex=o.lotOccupantIndex.toString(),p.innerHTML=""+cityssm.escapeHTML(""===(null!==(e=o.occupantName)&&void 0!==e?e:"")&&""===(null!==(t=o.occupantFamilyName)&&void 0!==t?t:"")?"(No Name)":o.occupantName+" "+o.occupantFamilyName)+'
'+cityssm.escapeHTML(o.lotOccupantType)+""+(""===(null!==(c=o.occupantAddress1)&&void 0!==c?c:"")?"":cityssm.escapeHTML(o.occupantAddress1)+"
")+(""===(null!==(n=o.occupantAddress2)&&void 0!==n?n:"")?"":cityssm.escapeHTML(o.occupantAddress2)+"
")+(""===(null!==(a=o.occupantCity)&&void 0!==a?a:"")?"":cityssm.escapeHTML(o.occupantCity)+", ")+cityssm.escapeHTML(null!==(s=o.occupantProvince)&&void 0!==s?s:"")+"
"+cityssm.escapeHTML(null!==(l=o.occupantPostalCode)&&void 0!==l?l:"")+""+(""===(null!==(r=o.occupantPhoneNumber)&&void 0!==r?r:"")?"":cityssm.escapeHTML(o.occupantPhoneNumber)+"
")+(""===(null!==(i=o.occupantEmailAddress)&&void 0!==i?i:"")?"":cityssm.escapeHTML(o.occupantEmailAddress))+''+cityssm.escapeHTML(null!==(d=o.occupantComment)&&void 0!==d?d:"")+'
',p.querySelector(".button--edit").addEventListener("click",O),p.querySelector(".button--delete").addEventListener("click",g),m.querySelector("tbody").append(p)}p.append(m)}if(delete exports.lotOccupancyOccupants,l){const e=document.querySelector("#lotOccupancy--lotOccupantTypeId");e.addEventListener("change",()=>{var t;const c=d.querySelectorAll("[data-table='LotOccupancyOccupant']");for(const t of c)t.disabled=""===e.value;let n=null!==(t=e.selectedOptions[0].dataset.occupantCommentTitle)&&void 0!==t?t:"";""===n&&(n="Comment"),d.querySelector("#lotOccupancy--occupantCommentTitle").textContent=n})}else h();if(null===(S=document.querySelector("#button--addOccupant"))||void 0===S||S.addEventListener("click",()=>{let e,t,c,n;function a(t){cityssm.postJSON(o.urlPrefix+"/lotOccupancies/doAddLotOccupancyOccupant",t,t=>{var c;const n=t;n.success?(f=n.lotOccupancyOccupants,e(),h()):bulmaJS.alert({title:`Error Adding ${o.escapedAliases.Occupant}`,message:null!==(c=n.errorMessage)&&void 0!==c?c:"",contextualColorName:"danger"})})}function l(e){e.preventDefault(),a(t)}let r=[];function i(e){e.preventDefault();const t=e.currentTarget,c=r[Number.parseInt(t.dataset.index,10)],n=t.closest(".modal").querySelector("#lotOccupancyOccupantCopy--lotOccupantTypeId").value;""===n?bulmaJS.alert({title:`No ${o.escapedAliases.Occupant} Type Selected`,message:`Select a type to apply to the newly added ${o.escapedAliases.occupant}.`,contextualColorName:"warning"}):(c.lotOccupantTypeId=Number.parseInt(n,10),c.lotOccupancyId=Number.parseInt(s,10),a(c))}function u(e){e.preventDefault(),""!==c.querySelector("#lotOccupancyOccupantCopy--searchFilter").value?(n.innerHTML=o.getLoadingParagraphHTML("Searching..."),cityssm.postJSON(o.urlPrefix+"/lotOccupancies/doSearchPastOccupants",c,e=>{var t,c,a,o,s,l,u,d,p;r=e.occupants;const m=document.createElement("div");m.className="panel";for(const[e,n]of r.entries()){const r=document.createElement("a");r.className="panel-block is-block",r.dataset.index=e.toString(),r.innerHTML=""+cityssm.escapeHTML(null!==(t=n.occupantName)&&void 0!==t?t:"")+" "+cityssm.escapeHTML(null!==(c=n.occupantFamilyName)&&void 0!==c?c:"")+'
'+cityssm.escapeHTML(null!==(a=n.occupantAddress1)&&void 0!==a?a:"")+"
"+(""===(null!==(o=n.occupantAddress2)&&void 0!==o?o:"")?"":cityssm.escapeHTML(n.occupantAddress2)+"
")+cityssm.escapeHTML(null!==(s=n.occupantCity)&&void 0!==s?s:"")+", "+cityssm.escapeHTML(null!==(l=n.occupantProvince)&&void 0!==l?l:"")+"
"+cityssm.escapeHTML(null!==(u=n.occupantPostalCode)&&void 0!==u?u:"")+'
'+(""===(null!==(d=n.occupantPhoneNumber)&&void 0!==d?d:"")?"":cityssm.escapeHTML(n.occupantPhoneNumber)+"
")+cityssm.escapeHTML(null!==(p=n.occupantEmailAddress)&&void 0!==p?p:"")+"
",r.addEventListener("click",i),m.append(r)}n.innerHTML="",n.append(m)})):n.innerHTML='

Enter a partial name or address in the search field above.

'}cityssm.openHtmlModal("lotOccupancy-addOccupant",{onshow(e){o.populateAliases(e),e.querySelector("#lotOccupancyOccupantAdd--lotOccupancyId").value=s;const t=e.querySelector("#lotOccupancyOccupantAdd--lotOccupantTypeId"),c=e.querySelector("#lotOccupancyOccupantCopy--lotOccupantTypeId");for(const e of exports.lotOccupantTypes){const n=document.createElement("option");n.value=e.lotOccupantTypeId.toString(),n.textContent=e.lotOccupantType,n.dataset.occupantCommentTitle=e.occupantCommentTitle,n.dataset.fontAwesomeIconClass=e.fontAwesomeIconClass,t.append(n),c.append(n.cloneNode(!0))}e.querySelector("#lotOccupancyOccupantAdd--occupantCity").value=exports.occupantCityDefault,e.querySelector("#lotOccupancyOccupantAdd--occupantProvince").value=exports.occupantProvinceDefault},onshown(a,o){bulmaJS.toggleHtmlClipped(),bulmaJS.init(a);const s=a.querySelector("#lotOccupancyOccupantAdd--lotOccupantTypeId");s.focus(),s.addEventListener("change",()=>{var e,t;const c=null!==(e=s.selectedOptions[0].dataset.fontAwesomeIconClass)&&void 0!==e?e:"user";a.querySelector("#lotOccupancyOccupantAdd--fontAwesomeIconClass").innerHTML=``;let n=null!==(t=s.selectedOptions[0].dataset.occupantCommentTitle)&&void 0!==t?t:"";""===n&&(n="Comment"),a.querySelector("#lotOccupancyOccupantAdd--occupantCommentTitle").textContent=n}),(t=a.querySelector("#form--lotOccupancyOccupantAdd")).addEventListener("submit",l),n=a.querySelector("#lotOccupancyOccupantCopy--searchResults"),(c=a.querySelector("#form--lotOccupancyOccupantCopy")).addEventListener("submit",e=>{e.preventDefault()}),a.querySelector("#lotOccupancyOccupantCopy--searchFilter").addEventListener("change",u),e=o},onremoved(){bulmaJS.toggleHtmlClipped(),document.querySelector("#button--addOccupant").focus()}})}),!l){var S;Object.defineProperty(exports,"__esModule",{value:!0});let e=exports.lotOccupancyComments;function b(t){const c=Number.parseInt(t.currentTarget.closest("tr").dataset.lotOccupancyCommentId,10),n=e.find(e=>e.lotOccupancyCommentId===c);let a,l;function r(t){t.preventDefault(),cityssm.postJSON(o.urlPrefix+"/lotOccupancies/doUpdateLotOccupancyComment",a,t=>{var c;t.success?(e=t.lotOccupancyComments,l(),T()):bulmaJS.alert({title:"Error Updating Comment",message:null!==(c=t.errorMessage)&&void 0!==c?c:"",contextualColorName:"danger"})})}cityssm.openHtmlModal("lotOccupancy-editComment",{onshow(e){o.populateAliases(e),e.querySelector("#lotOccupancyCommentEdit--lotOccupancyId").value=s,e.querySelector("#lotOccupancyCommentEdit--lotOccupancyCommentId").value=c.toString(),e.querySelector("#lotOccupancyCommentEdit--lotOccupancyComment").value=n.lotOccupancyComment;const t=e.querySelector("#lotOccupancyCommentEdit--lotOccupancyCommentDateString");t.value=n.lotOccupancyCommentDateString;const a=cityssm.dateToString(new Date);t.max=n.lotOccupancyCommentDateString<=a?a:n.lotOccupancyCommentDateString,e.querySelector("#lotOccupancyCommentEdit--lotOccupancyCommentTimeString").value=n.lotOccupancyCommentTimeString},onshown(e,t){bulmaJS.toggleHtmlClipped(),o.initializeDatePickers(e),e.querySelector("#lotOccupancyCommentEdit--lotOccupancyComment").focus(),(a=e.querySelector("form")).addEventListener("submit",r),l=t},onremoved(){bulmaJS.toggleHtmlClipped()}})}function C(t){const c=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:function(){cityssm.postJSON(o.urlPrefix+"/lotOccupancies/doDeleteLotOccupancyComment",{lotOccupancyId:s,lotOccupancyCommentId:c},t=>{var c;t.success?(e=t.lotOccupancyComments,T()):bulmaJS.alert({title:"Error Removing Comment",message:null!==(c=t.errorMessage)&&void 0!==c?c:"",contextualColorName:"danger"})})}},contextualColorName:"warning"})}function T(){var t,c,n;const a=document.querySelector("#container--lotOccupancyComments");if(0===e.length)return void(a.innerHTML='

There are no comments associated with this record.

');const o=document.createElement("table");o.className="table is-fullwidth is-striped is-hoverable",o.innerHTML='CommentorComment DateCommentOptions';for(const a of e){const e=document.createElement("tr");e.dataset.lotOccupancyCommentId=a.lotOccupancyCommentId.toString(),e.innerHTML=""+cityssm.escapeHTML(null!==(t=a.recordCreate_userName)&&void 0!==t?t:"")+""+(null!==(c=a.lotOccupancyCommentDateString)&&void 0!==c?c:"")+(0===a.lotOccupancyCommentTime?"":" "+a.lotOccupancyCommentTimeString)+""+cityssm.escapeHTML(null!==(n=a.lotOccupancyComment)&&void 0!==n?n:"")+'
',e.querySelector(".button--edit").addEventListener("click",b),e.querySelector(".button--delete").addEventListener("click",C),o.querySelector("tbody").append(e)}a.innerHTML="",a.append(o)}delete exports.lotOccupancyComments,null===(S=document.querySelector("#button--addComment"))||void 0===S||S.addEventListener("click",()=>{let t,c;function n(n){n.preventDefault(),cityssm.postJSON(o.urlPrefix+"/lotOccupancies/doAddLotOccupancyComment",t,t=>{var n;t.success?(e=t.lotOccupancyComments,c(),T()):bulmaJS.alert({title:"Error Adding Comment",message:null!==(n=t.errorMessage)&&void 0!==n?n:"",contextualColorName:"danger"})})}cityssm.openHtmlModal("lotOccupancy-addComment",{onshow(e){o.populateAliases(e),e.querySelector("#lotOccupancyCommentAdd--lotOccupancyId").value=s},onshown(e,a){bulmaJS.toggleHtmlClipped(),e.querySelector("#lotOccupancyCommentAdd--lotOccupancyComment").focus(),(t=e.querySelector("form")).addEventListener("submit",n),c=a},onremoved:()=>{bulmaJS.toggleHtmlClipped(),document.querySelector("#button--addComment").focus()}})}),T(),Object.defineProperty(exports,"__esModule",{value:!0});let t=exports.lotOccupancyFees;delete exports.lotOccupancyFees;const c=document.querySelector("#container--lotOccupancyFees");function x(){let e=0;for(const c of t)e+=(c.feeAmount+c.taxAmount)*c.quantity;return e}function L(e){const c=Number.parseInt(e.currentTarget.closest("tr").dataset.feeId,10),n=t.find(e=>e.feeId===c);if(void 0===n)return void bulmaJS.alert({title:"Fee Not Found",message:"Please refresh the page",contextualColorName:"danger"});let a;function l(e){e.preventDefault(),cityssm.postJSON(o.urlPrefix+"/lotOccupancies/doUpdateLotOccupancyFeeQuantity",e.currentTarget,e=>{const c=e;c.success?(t=c.lotOccupancyFees,N(),a()):bulmaJS.alert({title:"Error Updating Quantity",message:"Please try again.",contextualColorName:"danger"})})}cityssm.openHtmlModal("lotOccupancy-editFeeQuantity",{onshow(e){e.querySelector("#lotOccupancyFeeQuantity--lotOccupancyId").value=s,e.querySelector("#lotOccupancyFeeQuantity--feeId").value=n.feeId.toString(),e.querySelector("#lotOccupancyFeeQuantity--quantity").valueAsNumber=n.quantity,e.querySelector("#lotOccupancyFeeQuantity--quantityUnit").textContent=n.quantityUnit},onshown(e,t){var c;a=t,e.querySelector("#lotOccupancyFeeQuantity--quantity").focus(),null===(c=e.querySelector("form"))||void 0===c||c.addEventListener("submit",l)}})}function q(e){const c=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:function(){cityssm.postJSON(o.urlPrefix+"/lotOccupancies/doDeleteLotOccupancyFee",{lotOccupancyId:s,feeId:c},e=>{var c;const n=e;n.success?(t=n.lotOccupancyFees,N()):bulmaJS.alert({title:"Error Deleting Fee",message:null!==(c=n.errorMessage)&&void 0!==c?c:"",contextualColorName:"danger"})})}}})}function N(){var e,n,a,o,s,l,r;if(0===t.length)return c.innerHTML='
\n

There are no fees associated with this record.

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

'+cityssm.escapeHTML(null!==(t=a.feeCategory)&&void 0!==t?t:"")+'

';let p=!1;for(const t of a.fees){if(null!==c.querySelector(`.container--lotOccupancyFee[data-fee-id='${t.feeId}'][data-include-quantity='0']`))continue;let l=!0;const m=((null!==(n=a.feeCategory)&&void 0!==n?n:"")+" "+(null!==(o=t.feeName)&&void 0!==o?o:"")+" "+(null!==(s=t.feeDescription)&&void 0!==s?s:"")).toLowerCase();for(const e of d)if(!m.includes(e)){l=!1;break}if(!l)continue;p=!0;const y=document.createElement("a");y.className="panel-block is-block container--fee",y.dataset.feeId=t.feeId.toString(),y.dataset.feeCategoryId=a.feeCategoryId.toString(),y.href="#",y.innerHTML=""+cityssm.escapeHTML(null!==(r=t.feeName)&&void 0!==r?r:"")+"
"+cityssm.escapeHTML(null!==(u=t.feeDescription)&&void 0!==u?u:"").replace(/\n/g,"
")+"
",y.addEventListener("click",i),e.querySelector(".panel").append(y)}p&&l.append(e)}}cityssm.openHtmlModal("lotOccupancy-addFee",{onshow(t){a=t.querySelector("#feeSelect--feeName"),l=t.querySelector("#resultsContainer--feeSelect"),cityssm.postJSON(o.urlPrefix+"/lotOccupancies/doGetFees",{lotOccupancyId:s},t=>{e=t.feeCategories,a.disabled=!1,a.addEventListener("keyup",u),a.focus(),u()})},onshown(){bulmaJS.toggleHtmlClipped()},onhidden(){N()},onremoved(){bulmaJS.toggleHtmlClipped(),n.focus()}})});let a=exports.lotOccupancyTransactions;delete exports.lotOccupancyTransactions;const l=document.querySelector("#container--lotOccupancyTransactions");function E(e){const t=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:function(){cityssm.postJSON(o.urlPrefix+"/lotOccupancies/doDeleteLotOccupancyTransaction",{lotOccupancyId:s,transactionIndex:t},e=>{var t;const c=e;c.success?(a=c.lotOccupancyTransactions,I()):bulmaJS.alert({title:"Error Deleting Transaction",message:null!==(t=c.errorMessage)&&void 0!==t?t:"",contextualColorName:"danger"})})}}})}function I(){var e,c,n;if(0===a.length)return void(l.innerHTML='

There are no transactions associated with this record.

');l.innerHTML=`\n \n \n \n \n \n \n \n \n \n \n \n \n
Date${o.escapedAliases.ExternalReceiptNumber}AmountOptions
Transaction Total
`;let s=0;for(const t of a){s+=t.transactionAmount;const a=document.createElement("tr");a.className="container--lotOccupancyTransaction",a.dataset.transactionIndex=t.transactionIndex.toString();let r="";""!==t.externalReceiptNumber&&(r=cityssm.escapeHTML(null!==(e=t.externalReceiptNumber)&&void 0!==e?e:""),o.dynamicsGPIntegrationIsEnabled&&(void 0===t.dynamicsGPDocument?r+=' \n \n ':t.dynamicsGPDocument.documentTotal.toFixed(2)===t.transactionAmount.toFixed(2)?r+=' \n \n ':r+=` \n \n `),r+="
"),a.innerHTML=""+(null!==(c=t.transactionDateString)&&void 0!==c?c:"")+""+r+""+cityssm.escapeHTML(null!==(n=t.transactionNote)&&void 0!==n?n:"")+'$'+t.transactionAmount.toFixed(2)+'',a.querySelector("button").addEventListener("click",E),l.querySelector("tbody").append(a)}l.querySelector("#lotOccupancyTransactions--grandTotal").textContent="$"+s.toFixed(2);const r=x();r.toFixed(2)!==s.toFixed(2)&&l.insertAdjacentHTML("afterbegin",'
Outstanding Balance
$'+(r-s).toFixed(2)+"
")}const r=document.querySelector("#button--addTransaction");r.addEventListener("click",()=>{let e,t,c;function n(e){e.preventDefault(),cityssm.postJSON(o.urlPrefix+"/lotOccupancies/doAddLotOccupancyTransaction",e.currentTarget,e=>{var t;const n=e;n.success?(a=n.lotOccupancyTransactions,c(),I()):bulmaJS.confirm({title:"Error Adding Transaction",message:null!==(t=n.errorMessage)&&void 0!==t?t:"",contextualColorName:"danger"})})}function l(){const c=t.value,n=t.closest(".control").querySelector(".icon"),a=t.closest(".field").querySelector(".help");if(""===c)return a.innerHTML=" ",void(n.innerHTML='');cityssm.postJSON(o.urlPrefix+"/lotOccupancies/doGetDynamicsGPDocument",{externalReceiptNumber:c},t=>{const c=t;c.success&&void 0!==c.dynamicsGPDocument?e.valueAsNumber===c.dynamicsGPDocument.documentTotal?(a.textContent="Matching Document Found",n.innerHTML=''):(a.textContent="Matching Document: $"+c.dynamicsGPDocument.documentTotal.toFixed(2),n.innerHTML=''):(a.textContent="No Matching Document Found",n.innerHTML='')})}cityssm.openHtmlModal("lotOccupancy-addTransaction",{onshow(c){o.populateAliases(c),c.querySelector("#lotOccupancyTransactionAdd--lotOccupancyId").value=s.toString();const n=x(),r=function(){let e=0;for(const t of a)e+=t.transactionAmount;return e}();if((e=c.querySelector("#lotOccupancyTransactionAdd--transactionAmount")).min=(-1*r).toFixed(2),e.max=Math.max(n-r,0).toFixed(2),e.value=Math.max(n-r,0).toFixed(2),o.dynamicsGPIntegrationIsEnabled){const n=(t=c.querySelector("#lotOccupancyTransactionAdd--externalReceiptNumber")).closest(".control");n.classList.add("has-icons-right"),n.insertAdjacentHTML("beforeend",''),n.insertAdjacentHTML("afterend",'

'),t.addEventListener("change",l),e.addEventListener("change",l),l()}},onshown(t,a){bulmaJS.toggleHtmlClipped(),e.focus(),c=a,t.querySelector("form").addEventListener("submit",n)},onremoved(){bulmaJS.toggleHtmlClipped(),r.focus()}})}),N()}})(); \ No newline at end of file diff --git a/routes/lotOccupancies.js b/routes/lotOccupancies.js index 7b69d231..c50b2748 100644 --- a/routes/lotOccupancies.js +++ b/routes/lotOccupancies.js @@ -18,6 +18,7 @@ import handler_doUpdateLotOccupancyComment from '../handlers/lotOccupancies-post import handler_doDeleteLotOccupancyComment from '../handlers/lotOccupancies-post/doDeleteLotOccupancyComment.js'; import handler_doGetFees from '../handlers/lotOccupancies-post/doGetFees.js'; import handler_doAddLotOccupancyFee from '../handlers/lotOccupancies-post/doAddLotOccupancyFee.js'; +import handler_doUpdateLotOccupancyFeeQuantity from '../handlers/lotOccupancies-post/doUpdateLotOccupancyFeeQuantity.js'; import handler_doDeleteLotOccupancyFee from '../handlers/lotOccupancies-post/doDeleteLotOccupancyFee.js'; import handler_doGetDynamicsGPDocument from '../handlers/lotOccupancies-post/doGetDynamicsGPDocument.js'; import handler_doAddLotOccupancyTransaction from '../handlers/lotOccupancies-post/doAddLotOccupancyTransaction.js'; @@ -44,6 +45,7 @@ router.post('/doUpdateLotOccupancyComment', permissionHandlers.updatePostHandler router.post('/doDeleteLotOccupancyComment', permissionHandlers.updatePostHandler, handler_doDeleteLotOccupancyComment); router.post('/doGetFees', permissionHandlers.updatePostHandler, handler_doGetFees); router.post('/doAddLotOccupancyFee', permissionHandlers.updatePostHandler, handler_doAddLotOccupancyFee); +router.post('/doUpdateLotOccupancyFeeQuantity', permissionHandlers.updatePostHandler, handler_doUpdateLotOccupancyFeeQuantity); router.post('/doDeleteLotOccupancyFee', permissionHandlers.updatePostHandler, handler_doDeleteLotOccupancyFee); if (configFunctions.getProperty('settings.dynamicsGP.integrationIsEnabled')) { router.post('/doGetDynamicsGPDocument', permissionHandlers.updatePostHandler, handler_doGetDynamicsGPDocument); diff --git a/routes/lotOccupancies.ts b/routes/lotOccupancies.ts index 366c3e34..f8872a2c 100644 --- a/routes/lotOccupancies.ts +++ b/routes/lotOccupancies.ts @@ -25,6 +25,7 @@ import handler_doDeleteLotOccupancyComment from '../handlers/lotOccupancies-post import handler_doGetFees from '../handlers/lotOccupancies-post/doGetFees.js' import handler_doAddLotOccupancyFee from '../handlers/lotOccupancies-post/doAddLotOccupancyFee.js' +import handler_doUpdateLotOccupancyFeeQuantity from '../handlers/lotOccupancies-post/doUpdateLotOccupancyFeeQuantity.js' import handler_doDeleteLotOccupancyFee from '../handlers/lotOccupancies-post/doDeleteLotOccupancyFee.js' import handler_doGetDynamicsGPDocument from '../handlers/lotOccupancies-post/doGetDynamicsGPDocument.js' @@ -156,6 +157,12 @@ router.post( handler_doAddLotOccupancyFee as RequestHandler ) +router.post( + '/doUpdateLotOccupancyFeeQuantity', + permissionHandlers.updatePostHandler, + handler_doUpdateLotOccupancyFeeQuantity as RequestHandler +) + router.post( '/doDeleteLotOccupancyFee', permissionHandlers.updatePostHandler, diff --git a/views/lotOccupancy-edit.ejs b/views/lotOccupancy-edit.ejs index 34ecd0c6..f8c6759c 100644 --- a/views/lotOccupancy-edit.ejs +++ b/views/lotOccupancy-edit.ejs @@ -549,28 +549,28 @@ -
-
-
-
-
-
-
-

Fees

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

Fees

+
-
+
+
+ +
+
+
+
+