Commit 197a297e authored by Melikhov Arsenii's avatar Melikhov Arsenii


Text reorganized until 'Creating diagramm entity' section
parent 594bfa91
......@@ -9,36 +9,44 @@
<a name = 'reports'></a>
## Creating reports
This section shows how to create reports.
Create a Health Department report for the current month - how many requests were closed.
As an example, we will create the Health Department report that shows how many requests were closed for the current month.
On the Administrator menu (UI / Reports) Create a new report
First, we need to go to Reports panel(Administrator->UI->Reports) and create a new one.
In the TEMPLATE section, create a data output template using the mustache template
:exclamation: In the `Model` field use the name of the directory that you have created in `models` directory(`models/_your_module_name_`).
The template is written in a simple language consisting of several types of tags. Tags are framed by two or three braces on each side. You can use nested templates.
Data that the template works with is called a context. The tag name indicates to which context field it is necessary to address.
There are four basic types of tags in Mustache: variable, section, comment and connection of an additional template.
* The variable outputs data with escaping the HTML entities `{{header}}` and without escaping `{{{content}}}`. They differ in the number of brackets.
* The section is a paired tag. The principle of its operation depends on the type of data with which it operates. If there is a combo box in the context of the section name, the template passes through its elements and the text inside the pair tag is processed once for each list item. A list item is substituted for a tag point.
If the function name matches the function, then the result of its execution will be used for the substitution.
If the field corresponding to the section name is neither a list nor a function, it will be used as the context for processing the contents of the tag.
* The comment is made in the form of a tag with an exclamation mark, for example, `{{! Comment content}} `.
:exclamation: Save the report before continuing.
To describe a section for a table row, in the first column, double-click or select it in the Edit / Section menu.
Use the editor to build such a template
The `TEMPLATE` section allows to create template of your report using [Mustache](
It works by expanding tags in a template using values provided in a hash or object.
> Mustache is a logic-less template syntax. It can be used for HTML, config files, source code - anything.
> It works by expanding tags in a template using values provided in a hash or object.
> You can find more info about it on:
> * <>
> * <>
Use the editor to build a template such this:
As a result, you should get code like this (Tools / Source code)
As a result, you should get the code(Tools / Source code) something like this:
<h1 style="text-align: center;">Request List current month</h1>
......@@ -65,16 +73,20 @@ As a result, you should get code like this (Tools / Source code)
:exclamation: Save the report before continuing.
In the CODE section, you need to describe the operation of the template and getting the data.
To request data from the database, use the Repository for the client side.
Documents reference!/api/ClientRepository
In the `CODE` section, you need to describe how the template gets the data and what it does with it.
Add this code to the CODE section
To get data for the report we need to use the [ClientRepository](!/api/ClientRepository).
> ClientRepository - Repository for client-side data retrieve.
The following code lets us do what we want. Add it to the `CODE` section.
exports.reportCode = {
buildReport: function(reportParams){
......@@ -87,7 +99,7 @@ buildReport: function(reportParams){
return UB.Repository('req_reqList')
.attrs(['reqDate', 'applicantInfo', 'reqText','answer','status'])
.where('department','equal', 331308542722153) //Set your departments ID from Departmments form!!
.where('department','equal', YOUR_DEPARTMENT_ID) //Set your departments ID from Departmments form!!!
.where('status', 'equal', 'CLOSED') //get closed requests
.where('reqDate', '>=', mBegin) //get requests in current month
.where('reqDate', '<', mEnd)
......@@ -105,12 +117,23 @@ buildReport: function(reportParams){
:exclamation: Don't forget to set your Department ID from the Departments form.
:exclamation: Save the report before continuing.
Save the template and test it using the Test button.
The template and the code to it are stored in the `models\requests\public\reports\' folder - you can remove templates from there only manually.
Now, the report is ready. You can preview it in different formats by pressing on the `Test` button with the corresponding format.
Templates and their code are stored in `models/YOUR_MODEL_NAME/public/reports` directory.
<a name = 'diagrams'></a>
## Creating diagramm entity
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment