lot reports

deepsource-autofix-76c6eb20
Dan Gowans 2022-09-27 10:58:25 -04:00
parent eb11c0b11e
commit 62a4506a49
5 changed files with 204 additions and 2 deletions

View File

@ -1,12 +1,17 @@
import * as dateTimeFunctions from "@cityssm/expressjs-server-js/dateTimeFns.js"; import * as dateTimeFunctions from "@cityssm/expressjs-server-js/dateTimeFns.js";
import { getMaps } from "../../helpers/lotOccupancyDB/getMaps.js"; import { getMaps } from "../../helpers/lotOccupancyDB/getMaps.js";
import { getLotStatuses, getLotTypes } from "../../helpers/functions.cache.js";
export const handler = (_request, response) => { export const handler = (_request, response) => {
const rightNow = new Date(); const rightNow = new Date();
const maps = getMaps(); const maps = getMaps();
const lotTypes = getLotTypes();
const lotStatuses = getLotStatuses();
response.render("report-search", { response.render("report-search", {
headTitle: "Reports", headTitle: "Reports",
todayDateString: dateTimeFunctions.dateToString(rightNow), todayDateString: dateTimeFunctions.dateToString(rightNow),
maps maps,
lotTypes,
lotStatuses
}); });
}; };
export default handler; export default handler;

View File

@ -3,16 +3,21 @@ import type { RequestHandler } from "express";
import * as dateTimeFunctions from "@cityssm/expressjs-server-js/dateTimeFns.js"; import * as dateTimeFunctions from "@cityssm/expressjs-server-js/dateTimeFns.js";
import { getMaps } from "../../helpers/lotOccupancyDB/getMaps.js"; import { getMaps } from "../../helpers/lotOccupancyDB/getMaps.js";
import { getLotStatuses, getLotTypes } from "../../helpers/functions.cache.js";
export const handler: RequestHandler = (_request, response) => { export const handler: RequestHandler = (_request, response) => {
const rightNow = new Date(); const rightNow = new Date();
const maps = getMaps(); const maps = getMaps();
const lotTypes = getLotTypes();
const lotStatuses = getLotStatuses();
response.render("report-search", { response.render("report-search", {
headTitle: "Reports", headTitle: "Reports",
todayDateString: dateTimeFunctions.dateToString(rightNow), todayDateString: dateTimeFunctions.dateToString(rightNow),
maps maps,
lotTypes,
lotStatuses
}); });
}; };

View File

@ -51,6 +51,45 @@ export const getReportData = (reportName, reportParameters) => {
case "lots-all": case "lots-all":
sql = "select * from Lots"; sql = "select * from Lots";
break; break;
case "lots-byLotTypeId":
sql =
"select l.lotId," +
" m.mapName, l.lotName," +
" t.lotType, s.lotStatus" +
" from Lots l" +
" left join LotTypes t on l.lotTypeId = t.lotTypeId" +
" left join LotStatuses s on l.lotStatusId = s.lotStatusId" +
" left join Maps m on l.mapId = m.mapId" +
" where l.recordDelete_timeMillis is null" +
" and l.lotTypeId = ?";
sqlParameters.push(reportParameters.lotTypeId);
break;
case "lots-byLotStatusId":
sql =
"select l.lotId," +
" m.mapName, l.lotName," +
" t.lotType, s.lotStatus" +
" from Lots l" +
" left join LotTypes t on l.lotTypeId = t.lotTypeId" +
" left join LotStatuses s on l.lotStatusId = s.lotStatusId" +
" left join Maps m on l.mapId = m.mapId" +
" where l.recordDelete_timeMillis is null" +
" and l.lotStatusId = ?";
sqlParameters.push(reportParameters.lotStatusId);
break;
case "lots-byMapId":
sql =
"select l.lotId," +
" m.mapName, l.lotName," +
" t.lotType, s.lotStatus" +
" from Lots l" +
" left join LotTypes t on l.lotTypeId = t.lotTypeId" +
" left join LotStatuses s on l.lotStatusId = s.lotStatusId" +
" left join Maps m on l.mapId = m.mapId" +
" where l.recordDelete_timeMillis is null" +
" and l.mapId = ?";
sqlParameters.push(reportParameters.mapId);
break;
case "lotComments-all": case "lotComments-all":
sql = "select * from LotComments"; sql = "select * from LotComments";
break; break;

View File

@ -70,6 +70,54 @@ export const getReportData = (
sql = "select * from Lots"; sql = "select * from Lots";
break; break;
case "lots-byLotTypeId":
sql =
"select l.lotId," +
" m.mapName, l.lotName," +
" t.lotType, s.lotStatus" +
" from Lots l" +
" left join LotTypes t on l.lotTypeId = t.lotTypeId" +
" left join LotStatuses s on l.lotStatusId = s.lotStatusId" +
" left join Maps m on l.mapId = m.mapId" +
" where l.recordDelete_timeMillis is null" +
" and l.lotTypeId = ?";
sqlParameters.push(reportParameters.lotTypeId);
break;
case "lots-byLotStatusId":
sql =
"select l.lotId," +
" m.mapName, l.lotName," +
" t.lotType, s.lotStatus" +
" from Lots l" +
" left join LotTypes t on l.lotTypeId = t.lotTypeId" +
" left join LotStatuses s on l.lotStatusId = s.lotStatusId" +
" left join Maps m on l.mapId = m.mapId" +
" where l.recordDelete_timeMillis is null" +
" and l.lotStatusId = ?";
sqlParameters.push(reportParameters.lotStatusId);
break;
case "lots-byMapId":
sql =
"select l.lotId," +
" m.mapName, l.lotName," +
" t.lotType, s.lotStatus" +
" from Lots l" +
" left join LotTypes t on l.lotTypeId = t.lotTypeId" +
" left join LotStatuses s on l.lotStatusId = s.lotStatusId" +
" left join Maps m on l.mapId = m.mapId" +
" where l.recordDelete_timeMillis is null" +
" and l.mapId = ?";
sqlParameters.push(reportParameters.mapId);
break;
case "lotComments-all": case "lotComments-all":
sql = "select * from LotComments"; sql = "select * from LotComments";
break; break;

View File

@ -114,6 +114,111 @@
</div> </div>
<div class="is-hidden" id="tab--lots"> <div class="is-hidden" id="tab--lots">
<h1 class="title is-1"><%= configFunctions.getProperty("aliases.lot") %> Reports</h1> <h1 class="title is-1"><%= configFunctions.getProperty("aliases.lot") %> Reports</h1>
<div class="panel">
<form class="panel-block align-items-flex-start" method="get" action="<%= urlPrefix %>/reports/lots-byMapId">
<div class="has-text-centered my-2 ml-2 mr-3">
<span class="icon has-text-info">
<i class="fas fa-2x fa-file" aria-hidden="true"></i>
</span><br />
<span class="tag is-info">CSV</span>
</div>
<div>
<h3 class="title is-5 is-marginless"><%= configFunctions.getProperty("aliases.lots") %> By <%= configFunctions.getProperty("aliases.map") %></h3>
<div class="field has-addons mt-2">
<div class="control">
<label class="button is-small is-static" for="lots-byMapId--mapId">
<%= configFunctions.getProperty("aliases.map") %>
</label>
</div>
<div class="control is-expanded">
<div class="select is-small is-fullwidth">
<select id="lots-byMapId--mapId" name="mapId">
<% for (const map of maps) { %>
<option value="<%= map.mapId %>">
<%= map.mapName || "(No Name)" %>
</option>
<% } %>
</select>
</div>
</div>
<div class="control">
<button class="button is-small is-primary" type="submit">
Export
</button>
</div>
</div>
</div>
</form>
<form class="panel-block align-items-flex-start" method="get" action="<%= urlPrefix %>/reports/lots-byLotTypeId">
<div class="has-text-centered my-2 ml-2 mr-3">
<span class="icon has-text-info">
<i class="fas fa-2x fa-file" aria-hidden="true"></i>
</span><br />
<span class="tag is-info">CSV</span>
</div>
<div>
<h3 class="title is-5 is-marginless"><%= configFunctions.getProperty("aliases.lots") %> By Type</h3>
<div class="field has-addons mt-2">
<div class="control">
<label class="button is-small is-static" for="lots-byLotTypeId--lotTypeId">
<%= configFunctions.getProperty("aliases.lot") %> Type
</label>
</div>
<div class="control is-expanded">
<div class="select is-small is-fullwidth">
<select id="lots-byLotTypeId--lotTypeId" name="lotTypeId">
<% for (const lotType of lotTypes) { %>
<option value="<%= lotType.lotTypeId %>">
<%= lotType.lotType %>
</option>
<% } %>
</select>
</div>
</div>
<div class="control">
<button class="button is-small is-primary" type="submit">
Export
</button>
</div>
</div>
</div>
</form>
<form class="panel-block align-items-flex-start" method="get" action="<%= urlPrefix %>/reports/lots-byLotStatusId">
<div class="has-text-centered my-2 ml-2 mr-3">
<span class="icon has-text-info">
<i class="fas fa-2x fa-file" aria-hidden="true"></i>
</span><br />
<span class="tag is-info">CSV</span>
</div>
<div>
<h3 class="title is-5 is-marginless"><%= configFunctions.getProperty("aliases.lots") %> By Status</h3>
<div class="field has-addons mt-2">
<div class="control">
<label class="button is-small is-static" for="lots-byLotStatusId--lotStatusId">
<%= configFunctions.getProperty("aliases.lot") %> Status
</label>
</div>
<div class="control is-expanded">
<div class="select is-small is-fullwidth">
<select id="lots-byLotStatusId--lotStatusId" name="lotStatusId">
<% for (const lotStatus of lotStatuses) { %>
<option value="<%= lotStatus.lotStatusId %>">
<%= lotStatus.lotStatus %>
</option>
<% } %>
</select>
</div>
</div>
<div class="control">
<button class="button is-small is-primary" type="submit">
Export
</button>
</div>
</div>
</div>
</form>
</div>
</div> </div>
<div class="is-hidden" id="tab--maps"> <div class="is-hidden" id="tab--maps">
<h1 class="title is-1"><%= configFunctions.getProperty("aliases.map") %> Reports</h1> <h1 class="title is-1"><%= configFunctions.getProperty("aliases.map") %> Reports</h1>