show lot occupancy count on dashboard
parent
01c086da96
commit
90c107b0f3
|
|
@ -1,6 +1,7 @@
|
||||||
import { dateToString } from '@cityssm/expressjs-server-js/dateTimeFns.js';
|
import { dateToString } from '@cityssm/expressjs-server-js/dateTimeFns.js';
|
||||||
import { getWorkOrderMilestones } from '../../helpers/lotOccupancyDB/getWorkOrderMilestones.js';
|
import { getWorkOrderMilestones } from '../../helpers/lotOccupancyDB/getWorkOrderMilestones.js';
|
||||||
import { getWorkOrders } from '../../helpers/lotOccupancyDB/getWorkOrders.js';
|
import { getWorkOrders } from '../../helpers/lotOccupancyDB/getWorkOrders.js';
|
||||||
|
import { getLotOccupancies } from '../../helpers/lotOccupancyDB/getLotOccupancies.js';
|
||||||
export async function handler(_request, response) {
|
export async function handler(_request, response) {
|
||||||
const currentDateString = dateToString(new Date());
|
const currentDateString = dateToString(new Date());
|
||||||
const workOrderMilestones = await getWorkOrderMilestones({
|
const workOrderMilestones = await getWorkOrderMilestones({
|
||||||
|
|
@ -16,10 +17,20 @@ export async function handler(_request, response) {
|
||||||
limit: 1,
|
limit: 1,
|
||||||
offset: 0
|
offset: 0
|
||||||
});
|
});
|
||||||
|
const lotOccupancyResults = await getLotOccupancies({
|
||||||
|
occupancyStartDateString: currentDateString
|
||||||
|
}, {
|
||||||
|
limit: 1,
|
||||||
|
offset: 0,
|
||||||
|
includeFees: false,
|
||||||
|
includeOccupants: false,
|
||||||
|
includeTransactions: false
|
||||||
|
});
|
||||||
response.render('dashboard', {
|
response.render('dashboard', {
|
||||||
headTitle: 'Dashboard',
|
headTitle: 'Dashboard',
|
||||||
workOrderMilestones,
|
workOrderMilestones,
|
||||||
workOrderCount: workOrderResults.count
|
workOrderCount: workOrderResults.count,
|
||||||
|
lotOccupancyCount: lotOccupancyResults.count
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
export default handler;
|
export default handler;
|
||||||
|
|
|
||||||
|
|
@ -4,8 +4,12 @@ import { dateToString } from '@cityssm/expressjs-server-js/dateTimeFns.js'
|
||||||
|
|
||||||
import { getWorkOrderMilestones } from '../../helpers/lotOccupancyDB/getWorkOrderMilestones.js'
|
import { getWorkOrderMilestones } from '../../helpers/lotOccupancyDB/getWorkOrderMilestones.js'
|
||||||
import { getWorkOrders } from '../../helpers/lotOccupancyDB/getWorkOrders.js'
|
import { getWorkOrders } from '../../helpers/lotOccupancyDB/getWorkOrders.js'
|
||||||
|
import { getLotOccupancies } from '../../helpers/lotOccupancyDB/getLotOccupancies.js'
|
||||||
|
|
||||||
export async function handler(_request: Request, response: Response): Promise<void> {
|
export async function handler(
|
||||||
|
_request: Request,
|
||||||
|
response: Response
|
||||||
|
): Promise<void> {
|
||||||
const currentDateString = dateToString(new Date())
|
const currentDateString = dateToString(new Date())
|
||||||
|
|
||||||
const workOrderMilestones = await getWorkOrderMilestones(
|
const workOrderMilestones = await getWorkOrderMilestones(
|
||||||
|
|
@ -24,15 +28,29 @@ export async function handler(_request: Request, response: Response): Promise<vo
|
||||||
workOrderOpenDateString: currentDateString
|
workOrderOpenDateString: currentDateString
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
limit: 1,
|
limit: 1, // only using the count
|
||||||
offset: 0
|
offset: 0
|
||||||
}
|
}
|
||||||
)
|
)
|
||||||
|
|
||||||
|
const lotOccupancyResults = await getLotOccupancies(
|
||||||
|
{
|
||||||
|
occupancyStartDateString: currentDateString
|
||||||
|
},
|
||||||
|
{
|
||||||
|
limit: 1, // only using the count
|
||||||
|
offset: 0,
|
||||||
|
includeFees: false,
|
||||||
|
includeOccupants: false,
|
||||||
|
includeTransactions: false
|
||||||
|
}
|
||||||
|
)
|
||||||
|
|
||||||
response.render('dashboard', {
|
response.render('dashboard', {
|
||||||
headTitle: 'Dashboard',
|
headTitle: 'Dashboard',
|
||||||
workOrderMilestones,
|
workOrderMilestones,
|
||||||
workOrderCount: workOrderResults.count
|
workOrderCount: workOrderResults.count,
|
||||||
|
lotOccupancyCount: lotOccupancyResults.count
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -3,9 +3,9 @@ import { dateIntegerToString, dateStringToInteger } from '@cityssm/expressjs-ser
|
||||||
import * as configFunctions from '../functions.config.js';
|
import * as configFunctions from '../functions.config.js';
|
||||||
import { getOccupancyTypeById } from '../functions.cache.js';
|
import { getOccupancyTypeById } from '../functions.cache.js';
|
||||||
import { getLotOccupancyOccupants } from './getLotOccupancyOccupants.js';
|
import { getLotOccupancyOccupants } from './getLotOccupancyOccupants.js';
|
||||||
|
import { getLotOccupancyFees } from './getLotOccupancyFees.js';
|
||||||
|
import { getLotOccupancyTransactions } from './getLotOccupancyTransactions.js';
|
||||||
import { getLotNameWhereClause, getOccupancyTimeWhereClause, getOccupantNameWhereClause } from '../functions.sqlFilters.js';
|
import { getLotNameWhereClause, getOccupancyTimeWhereClause, getOccupantNameWhereClause } from '../functions.sqlFilters.js';
|
||||||
import getLotOccupancyFees from './getLotOccupancyFees.js';
|
|
||||||
import getLotOccupancyTransactions from './getLotOccupancyTransactions.js';
|
|
||||||
function buildWhereClause(filters) {
|
function buildWhereClause(filters) {
|
||||||
let sqlWhereClause = ' where o.recordDelete_timeMillis is null';
|
let sqlWhereClause = ' where o.recordDelete_timeMillis is null';
|
||||||
const sqlParameters = [];
|
const sqlParameters = [];
|
||||||
|
|
|
||||||
|
|
@ -11,16 +11,18 @@ import {
|
||||||
import * as configFunctions from '../functions.config.js'
|
import * as configFunctions from '../functions.config.js'
|
||||||
|
|
||||||
import { getOccupancyTypeById } from '../functions.cache.js'
|
import { getOccupancyTypeById } from '../functions.cache.js'
|
||||||
import { getLotOccupancyOccupants } from './getLotOccupancyOccupants.js'
|
|
||||||
|
|
||||||
import type * as recordTypes from '../../types/recordTypes'
|
import { getLotOccupancyOccupants } from './getLotOccupancyOccupants.js'
|
||||||
|
import { getLotOccupancyFees } from './getLotOccupancyFees.js'
|
||||||
|
import { getLotOccupancyTransactions } from './getLotOccupancyTransactions.js'
|
||||||
|
|
||||||
import {
|
import {
|
||||||
getLotNameWhereClause,
|
getLotNameWhereClause,
|
||||||
getOccupancyTimeWhereClause,
|
getOccupancyTimeWhereClause,
|
||||||
getOccupantNameWhereClause
|
getOccupantNameWhereClause
|
||||||
} from '../functions.sqlFilters.js'
|
} from '../functions.sqlFilters.js'
|
||||||
import getLotOccupancyFees from './getLotOccupancyFees.js'
|
|
||||||
import getLotOccupancyTransactions from './getLotOccupancyTransactions.js'
|
import type * as recordTypes from '../../types/recordTypes'
|
||||||
|
|
||||||
interface GetLotOccupanciesFilters {
|
interface GetLotOccupanciesFilters {
|
||||||
lotId?: number | string
|
lotId?: number | string
|
||||||
|
|
|
||||||
|
|
@ -155,6 +155,9 @@
|
||||||
<span class="fa-layers fa-4x fa-fw" aria-hidden="true">
|
<span class="fa-layers fa-4x fa-fw" aria-hidden="true">
|
||||||
<i class="fas fa-vector-square"></i>
|
<i class="fas fa-vector-square"></i>
|
||||||
<i class="fas fa-user" data-fa-transform="shrink-10"></i>
|
<i class="fas fa-user" data-fa-transform="shrink-10"></i>
|
||||||
|
<% if (lotOccupancyCount > 0) { %>
|
||||||
|
<span class="fa-layers-counter has-background-success"><%= lotOccupancyCount %></span>
|
||||||
|
<% } %>
|
||||||
</span>
|
</span>
|
||||||
</div>
|
</div>
|
||||||
<div class="media-content has-text-black">
|
<div class="media-content has-text-black">
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue