diff --git a/handlers/lotOccupancies-get/print.d.ts b/handlers/lotOccupancies-get/print.d.ts new file mode 100644 index 00000000..9621c611 --- /dev/null +++ b/handlers/lotOccupancies-get/print.d.ts @@ -0,0 +1,3 @@ +import type { RequestHandler } from "express"; +export declare const handler: RequestHandler; +export default handler; diff --git a/handlers/lotOccupancies-get/print.js b/handlers/lotOccupancies-get/print.js new file mode 100644 index 00000000..71d22633 --- /dev/null +++ b/handlers/lotOccupancies-get/print.js @@ -0,0 +1,13 @@ +import * as configFunctions from "../../helpers/functions.config.js"; +import { getLotOccupancy } from "../../helpers/lotOccupancyDB/getLotOccupancy.js"; +export const handler = (request, response) => { + const lotOccupancy = getLotOccupancy(request.params.lotOccupancyId); + if (!lotOccupancy) { + return response.redirect(configFunctions.getProperty("reverseProxy.urlPrefix") + "/lotOccupancies/?error=lotOccupancyIdNotFound"); + } + return response.render("lotOccupancy-print", { + headTitle: configFunctions.getProperty("aliases.lot") + " " + configFunctions.getProperty("aliases.occupancy") + " Print", + lotOccupancy + }); +}; +export default handler; diff --git a/handlers/lotOccupancies-get/print.ts b/handlers/lotOccupancies-get/print.ts new file mode 100644 index 00000000..f5067354 --- /dev/null +++ b/handlers/lotOccupancies-get/print.ts @@ -0,0 +1,27 @@ +import type { + RequestHandler +} from "express"; + +import * as configFunctions from "../../helpers/functions.config.js"; + +import { + getLotOccupancy +} from "../../helpers/lotOccupancyDB/getLotOccupancy.js"; + + +export const handler: RequestHandler = (request, response) => { + + const lotOccupancy = getLotOccupancy(request.params.lotOccupancyId); + + if (!lotOccupancy) { + return response.redirect(configFunctions.getProperty("reverseProxy.urlPrefix") + "/lotOccupancies/?error=lotOccupancyIdNotFound"); + } + + return response.render("lotOccupancy-print", { + headTitle: configFunctions.getProperty("aliases.lot") + " " + configFunctions.getProperty("aliases.occupancy") + " Print", + lotOccupancy + }); +}; + + +export default handler; \ No newline at end of file diff --git a/routes/lotOccupancies.js b/routes/lotOccupancies.js index 3704d4aa..ea373333 100644 --- a/routes/lotOccupancies.js +++ b/routes/lotOccupancies.js @@ -2,6 +2,7 @@ import { Router } from "express"; import handler_search from "../handlers/lotOccupancies-get/search.js"; import handler_doSearchLotOccupancies from "../handlers/lotOccupancies-post/doSearchLotOccupancies.js"; import handler_view from "../handlers/lotOccupancies-get/view.js"; +import handler_print from "../handlers/lotOccupancies-get/print.js"; import handler_new from "../handlers/lotOccupancies-get/new.js"; import handler_doGetOccupancyTypeFields from "../handlers/lotOccupancies-post/doGetOccupancyTypeFields.js"; import handler_doCreateLotOccupancy from "../handlers/lotOccupancies-post/doCreateLotOccupancy.js"; @@ -27,6 +28,7 @@ router.get("/new", permissionHandlers.updateGetHandler, handler_new); router.post("/doGetOccupancyTypeFields", permissionHandlers.updatePostHandler, handler_doGetOccupancyTypeFields); router.post("/doCreateLotOccupancy", permissionHandlers.updatePostHandler, handler_doCreateLotOccupancy); router.get("/:lotOccupancyId", handler_view); +router.get("/:lotOccupancyId/print", handler_print); router.get("/:lotOccupancyId/edit", permissionHandlers.updateGetHandler, handler_edit); router.post("/doUpdateLotOccupancy", permissionHandlers.updatePostHandler, handler_doUpdateLotOccupancy); router.post("/doDeleteLotOccupancy", permissionHandlers.updatePostHandler, handler_doDeleteLotOccupancy); diff --git a/routes/lotOccupancies.ts b/routes/lotOccupancies.ts index 1bd079c0..80319918 100644 --- a/routes/lotOccupancies.ts +++ b/routes/lotOccupancies.ts @@ -6,6 +6,7 @@ import handler_search from "../handlers/lotOccupancies-get/search.js"; import handler_doSearchLotOccupancies from "../handlers/lotOccupancies-post/doSearchLotOccupancies.js"; import handler_view from "../handlers/lotOccupancies-get/view.js"; +import handler_print from "../handlers/lotOccupancies-get/print.js"; import handler_new from "../handlers/lotOccupancies-get/new.js"; import handler_doGetOccupancyTypeFields from "../handlers/lotOccupancies-post/doGetOccupancyTypeFields.js"; @@ -62,6 +63,9 @@ router.post("/doCreateLotOccupancy", router.get("/:lotOccupancyId", handler_view); +router.get("/:lotOccupancyId/print", + handler_print); + // Edit router.get("/:lotOccupancyId/edit", diff --git a/views/lotOccupancy-edit.ejs b/views/lotOccupancy-edit.ejs index 2b5bf6d8..9b9eb163 100644 --- a/views/lotOccupancy-edit.ejs +++ b/views/lotOccupancy-edit.ejs @@ -17,7 +17,7 @@ <% if (!isCreate) { %>