Utilities for printed forms¶
Utilities for printed forms (injectors) are designed to process the data output to a template, including intermediate calculations and formatting.
The printed form for which the injector will be used must be defined in deploy.json, for example:
In this case, the listToDocx module is used, so a list of all objects of a certain class will be uploaded to the printed form.
For each such class in tplDir, you need to create a folder with the name of the namespace, and then put a file with the name of the class you need to unload from this namespace in it, for example:
Thus, a list of all objects of the ticketYear@khv-ticket-discount class will be uploaded to the document.
The utility itself is a .js script connected to the application in the module format in deploy.json, for example:
The .js file here is located at the “module” path.
After connecting, the utility must be included in the options of the printed form:
The injector script is compiled in the module format, provided that it must contain the this.inject function, into the parameter of which the object with the list of objects of the class specified earlier will be transferred to, for an example from this reference:
Example of the monthTicketStats.js file:
Example of an export configuration for this form in deploy.js:
Here you should pay attention to the params field - in it you can specify the parameters available in the export form in the application web service, as of 12.24.2019 the following types of parameters are possible:
“string” - text enter string,
“date” - an interactive calendar where you can select a date of interest
“reference” - a reference to the class, in this case, the export window will display a drop-down list of all objects of the class.
The passed parameters will be available in the script through the parameter of the this.inject function.