Custom reports
Special (Custom) report - is a universal report with its own design and specific formation for uploading the necessary data from the system to Excel or Pdf file.
Special reports can be created by a user with the permission to manage custom reports.
Users with access to reports or training reports are able to use Special reports - make selections of data in available fields (e.g. select users or tasks, specify a period)
Peculiarities of creating custom reports:
-
date_range is split into two variables: $dateFrom, $dateTo.
-
The variables that we create in the report, available in the code in the array $data.
Example:
$data['useAllTasks']
- Classes need to be written globally
Example:
Modules\Tasks\Model\TaskRefUser::STATUS_NOT_STARTED
- Use variable $pExcel for Excel formatting code
Automatically performed:
$pExcel = new \PHPExcel();
$pExcel->setActiveSheetIndex(0);
-
For parameters that select data from a query (Single choice, Multiple choice)
- the resulting array (res) must contain two fields: id, text
- For single choice, the value from the id field is returned.
- for plural: a string with id separated by commas.
-
To convert to pdf, use https://tcpdf.org
To output to pdf, we assign the html code to the $html variable.
Example: