system queries + custom template selection
This commit is contained in:
parent
a085de6e2f
commit
f8a5183f1a
5 changed files with 52 additions and 8 deletions
|
@ -2,6 +2,7 @@ import { Request, Response } from "express";
|
|||
import { PdfExport } from "../../../helpers/pdfExport";
|
||||
import DynamicQueryBuilder from "../../../helpers/dynamicQueryBuilder";
|
||||
import QueryStoreService from "../../../service/configuration/queryStoreService";
|
||||
import InternalException from "../../../exceptions/internalException";
|
||||
|
||||
/**
|
||||
* @description print list by query and template
|
||||
|
@ -18,13 +19,19 @@ export async function printListByQueryAndTemplate(req: Request, res: Response):
|
|||
const headerHeight = req.body.headerHeight ?? null;
|
||||
const footerHeight = req.body.footerHeight ?? null;
|
||||
|
||||
// \/ integrate into query builder execution via shortcut
|
||||
//await MemberService.getByRunningMembership();
|
||||
//await MemberService.getAll({ noLimit:true });
|
||||
let query = queryStore;
|
||||
if (queryStore != "member" && queryStore != "memberByRunningMembership") {
|
||||
query = (await QueryStoreService.getById(queryStore)).query;
|
||||
}
|
||||
|
||||
let query = (await QueryStoreService.getById(queryStore)).query;
|
||||
let data = await DynamicQueryBuilder.executeQuery({
|
||||
query: query.startsWith("{") ? JSON.parse(query) : query,
|
||||
noLimit: true,
|
||||
});
|
||||
|
||||
await DynamicQueryBuilder.executeQuery({ query, noLimit: true });
|
||||
if (data.stats == "error") {
|
||||
throw new InternalException("Failed executing Query");
|
||||
}
|
||||
|
||||
let pdf = await PdfExport.renderFile({
|
||||
title: title,
|
||||
|
@ -32,6 +39,7 @@ export async function printListByQueryAndTemplate(req: Request, res: Response):
|
|||
saveToDisk: false,
|
||||
data: {
|
||||
today: new Date(),
|
||||
list: data.rows,
|
||||
},
|
||||
customTemplate: {
|
||||
headerId,
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue