render protocol by template
This commit is contained in:
parent
da219eb5f4
commit
58213923e5
8 changed files with 950 additions and 3 deletions
|
@ -22,6 +22,7 @@ import { SynchronizeProtocolDecisionCommand } from "../../command/protocolDecisi
|
|||
import { SynchronizeProtocolVotingCommand } from "../../command/protocolVotingCommand";
|
||||
import { ProtocolVotingViewModel } from "../../viewmodel/admin/protocolVoting.models";
|
||||
import ProtocolVotingCommandHandler from "../../command/protocolVotingCommandHandler";
|
||||
import { PdfExport } from "../../helpers/pdfExport";
|
||||
|
||||
/**
|
||||
* @description get all protocols
|
||||
|
@ -289,3 +290,47 @@ export async function synchronizeProtocolPrecenseById(req: Request, res: Respons
|
|||
|
||||
res.sendStatus(204);
|
||||
}
|
||||
|
||||
/**
|
||||
* @description render protocol to file by id
|
||||
* @param req {Request} Express req object
|
||||
* @param res {Response} Express res object
|
||||
* @returns {Promise<*>}
|
||||
*/
|
||||
export async function printPdf(req: Request, res: Response): Promise<any> {
|
||||
let protocolId = parseInt(req.params.protocolId);
|
||||
let protocol = await ProtocolService.getById(protocolId);
|
||||
let agenda = await ProtocolAgendaService.getAll(protocolId);
|
||||
let decisions = await ProtocolDecisionService.getAll(protocolId);
|
||||
let presence = await ProtocolPresenceService.getAll(protocolId);
|
||||
let votings = await ProtocolVotingService.getAll(protocolId);
|
||||
|
||||
await PdfExport.renderFile({
|
||||
template: "protocol.template.html",
|
||||
title: protocol.title,
|
||||
data: {
|
||||
title: protocol.title,
|
||||
summary: protocol.summary,
|
||||
date: new Date(protocol.date).toLocaleDateString("de-DE", {
|
||||
weekday: "long",
|
||||
day: "2-digit",
|
||||
month: "2-digit",
|
||||
year: "numeric",
|
||||
}),
|
||||
start: new Date(protocol.starttime).toLocaleTimeString("de-DE", {
|
||||
minute: "2-digit",
|
||||
hour: "2-digit",
|
||||
}),
|
||||
end: new Date(protocol.endtime).toLocaleTimeString("de-DE", {
|
||||
minute: "2-digit",
|
||||
hour: "2-digit",
|
||||
}),
|
||||
agenda,
|
||||
decisions,
|
||||
presence: presence.map((p) => p.member),
|
||||
votings,
|
||||
},
|
||||
});
|
||||
|
||||
res.sendStatus(204);
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue