show work orders on occupancy views
parent
e7e84ef499
commit
926e20d3d5
|
|
@ -6,6 +6,7 @@ import { getLotOccupancyComments } from "./getLotOccupancyComments.js";
|
||||||
import { getLotOccupancyFields } from "./getLotOccupancyFields.js";
|
import { getLotOccupancyFields } from "./getLotOccupancyFields.js";
|
||||||
import { getLotOccupancyFees } from "./getLotOccupancyFees.js";
|
import { getLotOccupancyFees } from "./getLotOccupancyFees.js";
|
||||||
import { getLotOccupancyTransactions } from "./getLotOccupancyTransactions.js";
|
import { getLotOccupancyTransactions } from "./getLotOccupancyTransactions.js";
|
||||||
|
import { getWorkOrders } from "./getWorkOrders.js";
|
||||||
export const getLotOccupancy = (lotOccupancyId, connectedDatabase) => {
|
export const getLotOccupancy = (lotOccupancyId, connectedDatabase) => {
|
||||||
const database = connectedDatabase ||
|
const database = connectedDatabase ||
|
||||||
sqlite(databasePath, {
|
sqlite(databasePath, {
|
||||||
|
|
@ -33,6 +34,12 @@ export const getLotOccupancy = (lotOccupancyId, connectedDatabase) => {
|
||||||
lotOccupancy.lotOccupancyComments = getLotOccupancyComments(lotOccupancyId, database);
|
lotOccupancy.lotOccupancyComments = getLotOccupancyComments(lotOccupancyId, database);
|
||||||
lotOccupancy.lotOccupancyFees = getLotOccupancyFees(lotOccupancyId, database);
|
lotOccupancy.lotOccupancyFees = getLotOccupancyFees(lotOccupancyId, database);
|
||||||
lotOccupancy.lotOccupancyTransactions = getLotOccupancyTransactions(lotOccupancyId, database);
|
lotOccupancy.lotOccupancyTransactions = getLotOccupancyTransactions(lotOccupancyId, database);
|
||||||
|
lotOccupancy.workOrders = getWorkOrders({
|
||||||
|
lotOccupancyId
|
||||||
|
}, {
|
||||||
|
limit: -1,
|
||||||
|
offset: 0
|
||||||
|
}, database).workOrders;
|
||||||
}
|
}
|
||||||
if (!connectedDatabase) {
|
if (!connectedDatabase) {
|
||||||
database.close();
|
database.close();
|
||||||
|
|
|
||||||
|
|
@ -14,6 +14,8 @@ import { getLotOccupancyFees } from "./getLotOccupancyFees.js";
|
||||||
|
|
||||||
import { getLotOccupancyTransactions } from "./getLotOccupancyTransactions.js";
|
import { getLotOccupancyTransactions } from "./getLotOccupancyTransactions.js";
|
||||||
|
|
||||||
|
import { getWorkOrders } from "./getWorkOrders.js";
|
||||||
|
|
||||||
import type * as recordTypes from "../../types/recordTypes";
|
import type * as recordTypes from "../../types/recordTypes";
|
||||||
|
|
||||||
export const getLotOccupancy = (
|
export const getLotOccupancy = (
|
||||||
|
|
@ -55,6 +57,17 @@ export const getLotOccupancy = (
|
||||||
lotOccupancyId,
|
lotOccupancyId,
|
||||||
database
|
database
|
||||||
);
|
);
|
||||||
|
|
||||||
|
lotOccupancy.workOrders = getWorkOrders(
|
||||||
|
{
|
||||||
|
lotOccupancyId
|
||||||
|
},
|
||||||
|
{
|
||||||
|
limit: -1,
|
||||||
|
offset: 0
|
||||||
|
},
|
||||||
|
database
|
||||||
|
).workOrders;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!connectedDatabase) {
|
if (!connectedDatabase) {
|
||||||
|
|
|
||||||
|
|
@ -1,3 +1,4 @@
|
||||||
|
import sqlite from "better-sqlite3";
|
||||||
import type * as recordTypes from "../../types/recordTypes";
|
import type * as recordTypes from "../../types/recordTypes";
|
||||||
interface GetWorkOrdersFilters {
|
interface GetWorkOrdersFilters {
|
||||||
workOrderTypeId?: number | string;
|
workOrderTypeId?: number | string;
|
||||||
|
|
@ -5,6 +6,7 @@ interface GetWorkOrdersFilters {
|
||||||
workOrderOpenDateString?: string;
|
workOrderOpenDateString?: string;
|
||||||
occupantName?: string;
|
occupantName?: string;
|
||||||
lotName?: string;
|
lotName?: string;
|
||||||
|
lotOccupancyId?: number | string;
|
||||||
}
|
}
|
||||||
interface GetWorkOrdersOptions {
|
interface GetWorkOrdersOptions {
|
||||||
limit: number;
|
limit: number;
|
||||||
|
|
@ -13,7 +15,7 @@ interface GetWorkOrdersOptions {
|
||||||
includeComments?: boolean;
|
includeComments?: boolean;
|
||||||
includeMilestones?: boolean;
|
includeMilestones?: boolean;
|
||||||
}
|
}
|
||||||
export declare const getWorkOrders: (filters: GetWorkOrdersFilters, options?: GetWorkOrdersOptions) => {
|
export declare const getWorkOrders: (filters: GetWorkOrdersFilters, options?: GetWorkOrdersOptions, connectedDatabase?: sqlite.Database) => {
|
||||||
count: number;
|
count: number;
|
||||||
workOrders: recordTypes.WorkOrder[];
|
workOrders: recordTypes.WorkOrder[];
|
||||||
};
|
};
|
||||||
|
|
|
||||||
|
|
@ -42,15 +42,21 @@ const buildWhereClause = (filters) => {
|
||||||
sqlParameters.push(lotNamePiece);
|
sqlParameters.push(lotNamePiece);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
if (filters.lotOccupancyId) {
|
||||||
|
sqlWhereClause +=
|
||||||
|
" and w.workOrderId in (select workOrderId from WorkOrderLotOccupancies where recordDelete_timeMillis is null and lotOccupancyId = ?)";
|
||||||
|
sqlParameters.push(filters.lotOccupancyId);
|
||||||
|
}
|
||||||
return {
|
return {
|
||||||
sqlWhereClause,
|
sqlWhereClause,
|
||||||
sqlParameters
|
sqlParameters
|
||||||
};
|
};
|
||||||
};
|
};
|
||||||
export const getWorkOrders = (filters, options) => {
|
export const getWorkOrders = (filters, options, connectedDatabase) => {
|
||||||
const database = sqlite(databasePath, {
|
const database = connectedDatabase ||
|
||||||
readonly: true
|
sqlite(databasePath, {
|
||||||
});
|
readonly: true
|
||||||
|
});
|
||||||
database.function("userFn_dateIntegerToString", dateIntegerToString);
|
database.function("userFn_dateIntegerToString", dateIntegerToString);
|
||||||
const { sqlWhereClause, sqlParameters } = buildWhereClause(filters);
|
const { sqlWhereClause, sqlParameters } = buildWhereClause(filters);
|
||||||
const count = database
|
const count = database
|
||||||
|
|
@ -111,7 +117,9 @@ export const getWorkOrders = (filters, options) => {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
database.close();
|
if (!connectedDatabase) {
|
||||||
|
database.close();
|
||||||
|
}
|
||||||
return {
|
return {
|
||||||
count,
|
count,
|
||||||
workOrders
|
workOrders
|
||||||
|
|
|
||||||
|
|
@ -20,6 +20,7 @@ interface GetWorkOrdersFilters {
|
||||||
workOrderOpenDateString?: string;
|
workOrderOpenDateString?: string;
|
||||||
occupantName?: string;
|
occupantName?: string;
|
||||||
lotName?: string;
|
lotName?: string;
|
||||||
|
lotOccupancyId?: number | string;
|
||||||
}
|
}
|
||||||
|
|
||||||
interface GetWorkOrdersOptions {
|
interface GetWorkOrdersOptions {
|
||||||
|
|
@ -74,6 +75,12 @@ const buildWhereClause = (
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (filters.lotOccupancyId) {
|
||||||
|
sqlWhereClause +=
|
||||||
|
" and w.workOrderId in (select workOrderId from WorkOrderLotOccupancies where recordDelete_timeMillis is null and lotOccupancyId = ?)";
|
||||||
|
sqlParameters.push(filters.lotOccupancyId);
|
||||||
|
}
|
||||||
|
|
||||||
return {
|
return {
|
||||||
sqlWhereClause,
|
sqlWhereClause,
|
||||||
sqlParameters
|
sqlParameters
|
||||||
|
|
@ -82,14 +89,17 @@ const buildWhereClause = (
|
||||||
|
|
||||||
export const getWorkOrders = (
|
export const getWorkOrders = (
|
||||||
filters: GetWorkOrdersFilters,
|
filters: GetWorkOrdersFilters,
|
||||||
options?: GetWorkOrdersOptions
|
options?: GetWorkOrdersOptions,
|
||||||
|
connectedDatabase?: sqlite.Database
|
||||||
): {
|
): {
|
||||||
count: number;
|
count: number;
|
||||||
workOrders: recordTypes.WorkOrder[];
|
workOrders: recordTypes.WorkOrder[];
|
||||||
} => {
|
} => {
|
||||||
const database = sqlite(databasePath, {
|
const database =
|
||||||
readonly: true
|
connectedDatabase ||
|
||||||
});
|
sqlite(databasePath, {
|
||||||
|
readonly: true
|
||||||
|
});
|
||||||
|
|
||||||
database.function("userFn_dateIntegerToString", dateIntegerToString);
|
database.function("userFn_dateIntegerToString", dateIntegerToString);
|
||||||
|
|
||||||
|
|
@ -134,7 +144,10 @@ export const getWorkOrders = (
|
||||||
) {
|
) {
|
||||||
for (const workOrder of workOrders) {
|
for (const workOrder of workOrders) {
|
||||||
if (options.includeComments) {
|
if (options.includeComments) {
|
||||||
workOrder.workOrderComments = getWorkOrderComments(workOrder.workOrderId as number, database);
|
workOrder.workOrderComments = getWorkOrderComments(
|
||||||
|
workOrder.workOrderId as number,
|
||||||
|
database
|
||||||
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (options.includeLotsAndLotOccupancies) {
|
if (options.includeLotsAndLotOccupancies) {
|
||||||
|
|
@ -176,7 +189,9 @@ export const getWorkOrders = (
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
database.close();
|
if (!connectedDatabase) {
|
||||||
|
database.close();
|
||||||
|
}
|
||||||
|
|
||||||
return {
|
return {
|
||||||
count,
|
count,
|
||||||
|
|
|
||||||
|
|
@ -195,6 +195,7 @@ export interface LotOccupancy extends Record {
|
||||||
lotOccupancyOccupants?: LotOccupancyOccupant[];
|
lotOccupancyOccupants?: LotOccupancyOccupant[];
|
||||||
lotOccupancyFees?: LotOccupancyFee[];
|
lotOccupancyFees?: LotOccupancyFee[];
|
||||||
lotOccupancyTransactions?: LotOccupancyTransaction[];
|
lotOccupancyTransactions?: LotOccupancyTransaction[];
|
||||||
|
workOrders?: WorkOrder[];
|
||||||
}
|
}
|
||||||
export interface WorkOrderType extends Record {
|
export interface WorkOrderType extends Record {
|
||||||
workOrderTypeId?: number;
|
workOrderTypeId?: number;
|
||||||
|
|
|
||||||
|
|
@ -258,6 +258,7 @@ export interface LotOccupancy extends Record {
|
||||||
lotOccupancyOccupants?: LotOccupancyOccupant[];
|
lotOccupancyOccupants?: LotOccupancyOccupant[];
|
||||||
lotOccupancyFees?: LotOccupancyFee[];
|
lotOccupancyFees?: LotOccupancyFee[];
|
||||||
lotOccupancyTransactions?: LotOccupancyTransaction[];
|
lotOccupancyTransactions?: LotOccupancyTransaction[];
|
||||||
|
workOrders?: WorkOrder[];
|
||||||
}
|
}
|
||||||
|
|
||||||
/*
|
/*
|
||||||
|
|
|
||||||
|
|
@ -381,11 +381,6 @@
|
||||||
</div>
|
</div>
|
||||||
<div class="dropdown-menu">
|
<div class="dropdown-menu">
|
||||||
<div class="dropdown-content">
|
<div class="dropdown-content">
|
||||||
<a class="dropdown-item" id="button--createWorkOrder" href="#">
|
|
||||||
<span class="icon is-small"><i class="fas fa-plus" aria-hidden="true"></i></span>
|
|
||||||
<span>Create a Work Order</span>
|
|
||||||
</a>
|
|
||||||
<hr class="dropdown-divider" />
|
|
||||||
<a class="dropdown-item" id="button--copyLotOccupancy" href="#">
|
<a class="dropdown-item" id="button--copyLotOccupancy" href="#">
|
||||||
<span class="icon is-small"><i class="far fa-copy" aria-hidden="true"></i></span>
|
<span class="icon is-small"><i class="far fa-copy" aria-hidden="true"></i></span>
|
||||||
<span>Copy <%= configFunctions.getProperty("aliases.occupancy") %> Record as New</span>
|
<span>Copy <%= configFunctions.getProperty("aliases.occupancy") %> Record as New</span>
|
||||||
|
|
@ -449,6 +444,76 @@
|
||||||
<div class="panel-block is-block" id="container--lotOccupancyComments"></div>
|
<div class="panel-block is-block" id="container--lotOccupancyComments"></div>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
|
<%
|
||||||
|
const workOrderOpenDateAlias = configFunctions.getProperty("aliases.workOrderOpenDate");
|
||||||
|
const workOrderCloseDateAlias = configFunctions.getProperty("aliases.workOrderCloseDate");
|
||||||
|
%>
|
||||||
|
<div class="panel">
|
||||||
|
<div class="panel-heading">
|
||||||
|
<div class="level is-mobile">
|
||||||
|
<div class="level-left">
|
||||||
|
<h2 class="title is-4">Work Orders</h2>
|
||||||
|
</div>
|
||||||
|
<div class="level-right">
|
||||||
|
<div class="level-item">
|
||||||
|
<button class="button is-small is-success is-hidden-print" id="button--createWorkOrder" type="button">
|
||||||
|
<span class="icon is-small"><i class="fas fa-plus" aria-hidden="true"></i></span>
|
||||||
|
<span>Create a Work Order</span>
|
||||||
|
</button>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
<div class="panel-block is-block">
|
||||||
|
<% if (lotOccupancy.workOrders.length === 0) { %>
|
||||||
|
<div class="message is-info">
|
||||||
|
<p class="message-body">
|
||||||
|
There are no work orders associated with this record.
|
||||||
|
</p>
|
||||||
|
</div>
|
||||||
|
<% } else { %>
|
||||||
|
<table class="table is-fullwidth is-striped is-hoverable">
|
||||||
|
<thead>
|
||||||
|
<tr>
|
||||||
|
<th>Work Order Number</th>
|
||||||
|
<th>Description</th>
|
||||||
|
<th>Date</th>
|
||||||
|
</tr>
|
||||||
|
</thead>
|
||||||
|
<tbody>
|
||||||
|
<% for (const workOrder of lotOccupancy.workOrders) { %>
|
||||||
|
<tr>
|
||||||
|
<td>
|
||||||
|
<a class="has-text-weight-bold" href="<%= urlPrefix %>/workOrders/<%= workOrder.workOrderId %>">
|
||||||
|
<%= workOrder.workOrderNumber %>
|
||||||
|
</a>
|
||||||
|
</td>
|
||||||
|
<td>
|
||||||
|
<%= workOrder.workOrderType %><br />
|
||||||
|
<span class="is-size-7"><%= workOrder.workOrderDescription %></span>
|
||||||
|
</td>
|
||||||
|
<td class="is-nowrap">
|
||||||
|
<span class="has-tooltip-left" data-tooltip="<%= workOrderOpenDateAlias %>">
|
||||||
|
<i class="fas fa-fw fa-play" aria-label="<%= workOrderOpenDateAlias %>"></i>
|
||||||
|
<%= workOrder.workOrderOpenDateString %>
|
||||||
|
</span><br />
|
||||||
|
<span class="has-tooltip-left" data-tooltip="<%= workOrderCloseDateAlias %>">
|
||||||
|
<i class="fas fa-fw fa-stop" aria-label="<%= workOrderCloseDateAlias %>"></i>
|
||||||
|
<% if (workOrder.workOrderCloseDate) { %>
|
||||||
|
<%= workOrder.workOrderCloseDateString %>
|
||||||
|
<% } else { %>
|
||||||
|
<span class="has-text-grey">(No <%= workOrderCloseDateAlias %>)</span>
|
||||||
|
<% } %>
|
||||||
|
</span>
|
||||||
|
</td>
|
||||||
|
</tr>
|
||||||
|
<% } %>
|
||||||
|
</tbody>
|
||||||
|
</table>
|
||||||
|
<% } %>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
|
||||||
<div class="columns">
|
<div class="columns">
|
||||||
<div class="column">
|
<div class="column">
|
||||||
<div class="panel">
|
<div class="panel">
|
||||||
|
|
|
||||||
|
|
@ -230,6 +230,56 @@
|
||||||
</div>
|
</div>
|
||||||
<% } %>
|
<% } %>
|
||||||
|
|
||||||
|
<% if (lotOccupancy.workOrders.length > 0) { %>
|
||||||
|
<%
|
||||||
|
const workOrderOpenDateAlias = configFunctions.getProperty("aliases.workOrderOpenDate");
|
||||||
|
const workOrderCloseDateAlias = configFunctions.getProperty("aliases.workOrderCloseDate");
|
||||||
|
%>
|
||||||
|
<div class="panel">
|
||||||
|
<h2 class="panel-heading">Work Orders</h2>
|
||||||
|
<div class="panel-block is-block">
|
||||||
|
<table class="table is-fullwidth is-striped is-hoverable">
|
||||||
|
<thead>
|
||||||
|
<tr>
|
||||||
|
<th>Work Order Number</th>
|
||||||
|
<th>Description</th>
|
||||||
|
<th>Date</th>
|
||||||
|
</tr>
|
||||||
|
</thead>
|
||||||
|
<tbody>
|
||||||
|
<% for (const workOrder of lotOccupancy.workOrders) { %>
|
||||||
|
<tr>
|
||||||
|
<td>
|
||||||
|
<a class="has-text-weight-bold" href="<%= urlPrefix %>/workOrders/<%= workOrder.workOrderId %>">
|
||||||
|
<%= workOrder.workOrderNumber %>
|
||||||
|
</a>
|
||||||
|
</td>
|
||||||
|
<td>
|
||||||
|
<%= workOrder.workOrderType %><br />
|
||||||
|
<span class="is-size-7"><%= workOrder.workOrderDescription %></span>
|
||||||
|
</td>
|
||||||
|
<td class="is-nowrap">
|
||||||
|
<span class="has-tooltip-left" data-tooltip="<%= workOrderOpenDateAlias %>">
|
||||||
|
<i class="fas fa-fw fa-play" aria-label="<%= workOrderOpenDateAlias %>"></i>
|
||||||
|
<%= workOrder.workOrderOpenDateString %>
|
||||||
|
</span><br />
|
||||||
|
<span class="has-tooltip-left" data-tooltip="<%= workOrderCloseDateAlias %>">
|
||||||
|
<i class="fas fa-fw fa-stop" aria-label="<%= workOrderCloseDateAlias %>"></i>
|
||||||
|
<% if (workOrder.workOrderCloseDate) { %>
|
||||||
|
<%= workOrder.workOrderCloseDateString %>
|
||||||
|
<% } else { %>
|
||||||
|
<span class="has-text-grey">(No <%= workOrderCloseDateAlias %>)</span>
|
||||||
|
<% } %>
|
||||||
|
</span>
|
||||||
|
</td>
|
||||||
|
</tr>
|
||||||
|
<% } %>
|
||||||
|
</tbody>
|
||||||
|
</table>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
<% } %>
|
||||||
|
|
||||||
<div class="columns">
|
<div class="columns">
|
||||||
<div class="column">
|
<div class="column">
|
||||||
<div class="panel">
|
<div class="panel">
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue