(2024.1) Custom Reports
- 1 About Custom Reports
- 1.1 Overview
- 2 Writing a Custom Report
- 2.1 Creating a New Report
- 2.1.1 Logic Tab
- 2.1.1.1 Custom Report Functions
- 2.1.2 assign: Assigns a variable from the Logic to be used in the Template
- 2.1.2.1 Example
- 2.1.3 loadReport: Loads another Report based on the Report Identifier
- 2.1.3.1 Example
- 2.1.4 barcode: Generates an HTML IMG tag of a barcode
- 2.1.5 Parameters Tab
- 2.1.6 Template Tab
- 2.1.7 Options Tab
- 2.1.8 Attachments Tab
- 2.1.9 Batch Processing Tab
- 2.1.1 Logic Tab
- 2.2 Updating an Existing Report
- 2.1 Creating a New Report
- 3 Linking a Custom Report
- 4 Running a Custom Report
- 4.1 Back Office generating the Report
- 4.1.1 Admin: Custom Reports
- 4.1.2 Reporting: Available Reports
- 4.1.3 Report Preview
- 4.1.4 Saved Reports
- 4.2 CustomerCenter providing the Report
- 4.3 Automatically running the Report
- 4.3.1 Report Batch Process
- 4.3.1.1 Invoice - Logic
- 4.3.1.2 Invoice - Template
- 4.3.1 Report Batch Process
- 4.1 Back Office generating the Report
About Custom Reports
Overview
Custom Reports is a built-in HTML Templating Engine using HTML Coding and external frameworks to allow Users to write their unique Reports using PCR-360 data and format them however your Organization desires. Before writing a Report, a User should be familiar with HTML programming and should first read the external documentation for Smarty and Bootstrap 4.0.
Custom Reports was created within PCR-360 to empower users to customize their organization's customer experience. Your organization can make the Reports available on CustomerCenter or directly on specific backend application forms. PCR has structured the Custom Report creation process to best mimic the workflow needed to build the Report.
Additionally, Custom Reports allow Users to run a Report and save the output directly to the server so that that report can be shared with others without having to re-run the Report and not have to worry about the data within the Report changing.
An example Custom Report is available at the bottom of this article.
Writing a Custom Report
The Admin > Reports > Custom Reports menu option brings the User to the Custom Reports grid. From this grid a User can [Add], [Edit Selected], and [Delete Selected] Custom Reports.
Creating a New Report
A Custom Report is comprised of multiple components. Every Custom Report has a unique Identifier, a Report Name and Roles assigned to access the Report.
Custom Reports are also comprised of Logic (for querying system Data), Parameters (for determining Report content), a Template for formatting the Report, Options (for adding a Report Title, Footer, and additional CSS), Attachments (for external files to be used within the Report) and details to define it for Batch Processing.
Custom Reports also maintains a short term log of any Debug information, which is useful for refining the Logic of the Report and checking for possible errors within that Logic.
Logic Tab
Custom Reports utilizes the internal PCR-360 Custom Logic functionality that is also available to Custom Events, Custom API and Custom Validations.
Custom Report Functions
assign: Assigns a variable from the Logic to be used in the Template
Example
/**
* @param string $name - name of the assigned variable in the Smarty Template
* @param array $value - value of the assigned variable in the Smarty Template
* @return void
*/
$this->assign('variableName', $variableValue);
loadReport: Loads another Report based on the Report Identifier
Example
/**
* @param string $identifier - another report's identifier
* @param array $params - array of parameters used to render the other report
* @return string - the Rendered Report
*/
$report = $this->loadReport('customReportIdentifier', ['paramName' => $parameterValue]);
barcode: Generates an HTML IMG tag of a barcode
Example
/**
* @param string $code - string text to encode
* @return string - barcode IMG tag
*/
$barcodeImgTag = $this->barcode('test test');
addError: Forces the Report to render an Error Message instead of the Report
Example
The Logic Tab is used for querying PCR-360 data. The Logic section has two parameters available for use in the (2024.1) Custom Logic: $params and $user.
$params
A key/value paired array of parameters that were passed into the Report are available within this array. Any changes to this array are also assigned to be accessed from the Smarty HTML Template.
$user
A key/value paired array of User information about the currently logged in User. The example below shows the options that are available within this array. This data enables Custom Reports to be specifically tailored to the User viewing the Report.
Debug Tab
Only data sent to the debug() function is displayed in the Debug section. Debug information only exists for 24 hours before it is automatically cleared out by the system. For more information on the debug() function, please see our article on Syntax.
Parameters Tab
A User can click the [Add] button to define each Parameter for the Report.
Parameters require a Name to be accessed within the Report Logic, as well as a Description to allow the User to know what they are entering. Parameters must also be defined as a specific Input Type, much like User-Defined Fields are. Parameters can also be assigned an Order value to determine the order in which they are presented to be populated by the Report generator. Finally, all Parameters have a Display checkbox to determine if that Parameter value will be shown in the Report's Preview.
Input Types accepted:
Checkbox
This is the only type of Input that can not be defined as required, as checkboxes are either Checked or Not Checked.
Currency
Date
Date/Time
Decimal
Drop Down
When a Drop Down Input is assigned, the User will need to define the Value and Text for each option within the Drop Down menu.
Number
Picker
When an Input is assigned to the Picker Type, the User must also define what type of Picker it is. Almost all types of Record within PCR-360 can be accessed by a Picker
Text
When a User runs a Custom Report, the related Parameters will be available to be set in the panel on the left side of the screen.
Template Tab
The Template Tab is where the bulk of the Report is made. The User can write HTML code here to access the information obtained in the Logic Tab, and format it into it's desired finished product. A User should be familiar with HTML programming and should first read the external documentation for Smarty and Bootstrap 4.0 before attempting to develop the Template for a Report.
Options Tab
The Options Tab is used for creating the Report's Title (either a fixed Title, or generated based on information obtained when the Report was run, with a 100 character limit), as well as adding in additional Footer and other general CSS formatting. The Report's Footer is limited to 500 characters or less.
Attachments Tab
Before Files can be Uploaded to a Custom Report, the Custom Report must first be saved.
Unlike other Attachment Tabs within PCR-360, files Attached to a Custom Report are uploaded to the /media/custom/ directory on the Server. This makes ALL Attachments to ANY Custom Report available to all other Custom Reports, as long as the User using the image to know the path to the file name.
Uploaded files can be set to have Availability to be displayed on other Report's Attachment Tabs by setting that File to All Reports when it is uploaded. Setting the File to be available for Only this Report will cause the File to not be displayed as such, even though it can still be accessed.
It should be warned, because all files are easily accessed using the same basic File Path, Uploading a File with the same name as a previously uploaded File will overwrite that File on the Server. Additionally, if a File is removed from the Attachment Tab, any other Reports that use that File will become broken, as the File will no longer exist on the Server.
Note: It is highly recommended to NOT attach JavaScript files to Custom Reports as that can be a serious security risk
Batch Processing Tab
The Batch Processing Tab displays information about Scheduled Batches, and allows a User to , , and Batches. For more information on the Batch Process, please see the section of this article for Automatically creating the Report.
Updating an Existing Report
To edit a Custom Report, a User simply needs to select the desired Report from the Custom Reports grid and click on the [Edit Selected] button. This will open the Report and the User can change any Logic, Parameters, Options, Attachments Batches, or the Template as needed.
Linking a Custom Report
Reports can be linked to Data-Entry forms or Data Grids. When opening a Custom Report that has been linked a single parameter called “recid” is passed. To process this parameter the report requires that the “recid” parameter is added to the Parameters tab in the Report Builder.
Running a Custom Report
Back Office generating the Report
Back office users can generate Custom Reports from multiple places in PCR-360: Admin, the Reporting menu, CustomerCenter, Form → Reports menus, and Grid → Reports menus.
Admin: Custom Reports
From the Custom Reports grid Users can click on [Open Report] to generate a Report.
Reporting: Available Reports
Users can generate new Reports from the Main > Reporting > Custom Reports > Available Reports menu option. However, when accessed from the Main menu, the Grid is limited based on the logged in User's assigned Roles, based on what Reports are assigned to those Roles.
To view a Report, a User must select the Report from the grid and click on [View Report]. For User convenience, a User can also [Bookmark Selected] Reports to access more quickly through the PCR-360 Footer.
Report Preview
On the Report Preview page the User will need to fill in any required parameters and then click on the [Open Report] button to open the report in a new tab. A preview of the report may be run by clicking the "Refresh" button after entering the required parameters.
When a Report is run, Users can share the Report through the using the functions provided.
The [Copy Link] button will copy a link to the Report, including the parameters, to the User's clipboard so that they can share it as a Web URL. | |
The [Save a Copy] button will save the Report so that it becomes available from the Saved Reports grid. | |
The [Download PDF] button will download a PDF Copy of the Report to the User's local system. |
Saved Reports
Alternatively, Users can view previously saved Reports from the Main > Reporting > Custom Reports > Saved Reports menu option.
From this grid, the User can click on [View Report] to open the saved Report directly or click on [Delete Selected] to delete the saved Report.
Admin Users can also click on [Bulk Assign] to have a Report display for other Users.
CustomerCenter providing the Report
Custom Reports are available in CustomerCenter. Just like the Main > Reporting > Custom Reports > Available Reports menu option, the page is limited based on the logged in User's assigned Roles, based on what Reports are assigned to those Roles.
Automatically running the Report
From the Custom Reports grid, Users can open a Report, and click the button on the “Batch Processing” tab of that report.
Report Batch Process
The Report Batch Process allows an Admin User to apply SQL Filters, define a Notification Message when the Report Batch is generated, and set a specific Schedule for the Report to run automatically.
When the Batch executes, each Record from the User defined SQL Filter Query will be fed into the Report's Logic as the parameters. Each unique row of the Filter Query will generate a particular Report. The CONTACTS_RECID of each record will determine which Contacts are assigned to the individual Reports.
Users can define a custom Subject Line for an automatic notification, as well as provide a message for the Notification. Users can also opt to attach the PDF of the Report to the Notification automatically.
Users can have a Batch run Immediately or set a Frequency for the Report to execute on, as well as set a date for when to run the Report next.
The Frequency can be set for:
Run Once
Daily
Weekdays
Weekly
Monthly
Quarterly
Yearly
Example Custom Report: Invoice
Below is an example of how Custom Reports can be used to generate a Custom Invoice.
Invoice - Logic
Invoice - Logic
Invoice - Parameters
Invoice - Template
Invoice - Options