QBench templates use the Jinja templating engine to organize and format all of your data. Jinja combines HTML and Python-like expressions to read and display variables from QBench. Important fields that you will want to display in your templates include core fields, user-created fields, and worksheet variables. Click on the link below for more details.
Creating a Report Template
To create a Report Template, navigate to Applications > Templates > Reports.
In the Report Landing Page, click on "+New Report Template Configuration."
There are three different report type options: Order Report, Sample Report, and Test Report. Each Report determines what type of information can be passed.
Design
As noticed on the bottom of the page, when "Order" is selected for the Report Level, it is possible to Preview the Orders that was entered.
When "Sample" is selected for the Report Level, the information that can be passed through would be Samples.
Lastly, when "Test" is chosen for the Report Level, Test information can be passed through for the report.
Save As New Version - When clicking on "Save As New Version" a pop-up box will appear with two options: Save As Draft and Submit for Approval.
Save As Draft - When a Report is "Saved As a Draft" the Versions Tab will display the Report as "Draft."
Submit For Approval - When a Report is "Submitted for Approval" the status will display as "Pending."
Versions
The Versions Tab displays all of the Versions that was saved for the Report Design. This is where the Status can be changed.
Changing "Draft" to "Pending" - In order to change the "Draft" to "Pending" for Approval, click directly on the Status and a pop-up box will appear.
Changing Status From "Pending" To "Approve" or "Reject" - When the Report Design is ready for to the submitted, the status will change to "Pending" and an Administrator can either "Approve" or "Reject" the design.
Active Version - Once a design has been Approved, it is possible to set the Version As Active, where it can be used by technicians or administrators.
An Approved Template will also display the approvers name and the date.
Attachments
Attaching a file can be done in the Attachments Tab. By attaching a file, it can be referenced within the Report itself.
Coding an Order Level Report
To create an Order Report, "Order" must be selected for the Report Level.
QBench’s Report Configurations uses HTML/CSS for formatting and styling reports. The following code is the basic requirement needed to set up a Report.
<style></style>
1. By using <style> tag, the Style information can be defined in document.
<body></body>
2. By using <body> tag, information contains a web page's content, including hyperlinks, images, tables, text, etc. It is required in every HTML document, and there may only be one <body> tag per page.
Adding Images to Report
In order to add images to a Report, it must be uploaded as an Attachment first.
Once the image has been uploaded, the following code below can be used to reference the uploaded image:
<img src="file://{{report_config_attachments['header.png'].asset_id|download_file_to_local_tmp }}">
*Note - header.png will need to be replaced with the full file name and extension that it was uploaded as.
Below references the file that has been uploaded "0.png"
Changing Picture Size
When an Image File is uploaded and used for the report, it will default to the properties of the image size. In order to change the Image Size within the report the following can be inserted into the code to shrink it.
style = "width:100px" ;
In an Order Level Report, information can be pulled in from Qbench using Python. Below denotes information from an Order that was entered previously. Orders contain many different information: Customer Name, Customer Account Number, Samples, Test etc, all of which can be used in the Order Level Report. Below we will teach you the basics of creating an Order Level - Report Template.
Starting off, an Order Level Report typically contains a few key elements: Customer Information, Order Information, Sample Information, and Test Information. The first step is to pull in Customer Information. Using the syntax below, it is possible to pull Customer information into the report.
{{customer.xxxxx}}
Below is an example of accessing data from the customer information.
{{customer.customer_name}}
{{customer.account_number}}
{{customer.special_instructions}}
As you can tell, the information has not been stylized yet. By default, texts will automatically align next to each other if a style has not been set.
In order to set up different sections in a Report <div> tags can be used.
<div></div>
<div> tags define a section or division in HTML. It can be used to stylize a section as well. Below is the basic syntax for stylization.
<div style = " REPLACE WITH STYLE ;"></div>
Here is an example:
<div style = " font-size: 20pt;"></div>
Notice how the contained <div> tags has made the whole section of text larger.
When a float is used within the <div>, it is possible to format and position content. As shown below, float:left and float:right was used to position the text.
Text directly entered will become static (where it does not change) as shown with Order ID, Date Completed, and Date Created.
To create more of a distinct separation, two borders were added to the report.
<div style = "border-top:1px solid black; padding:5px;"></div>
<div style = "border-bottom:1px solid black; padding:30px;"></div>
Another type of container is <table> tag. <table> allows for text to be contained in the table.
<table></table>
Within the <table> there could be: <tr> , <th> , <td>.
<tr> tag defines a row in an HTML table.
<tr></tr>
<th> tag defines a header cell in an HTML table.
<th></th>
<td> tag defines a standard data cell in an HTML table.
<td></td>
Below is an example on how a <table> , <tr> , and <td> tags has been used.
Referencing Related Data Indirectly
Sometimes a QBench object can have a variable that is a list of other objects e.g. Orders can have many Samples and Samples can have many Tests. To iterate through these lists, we use Jinja’s for loop syntax. Below depicts how a for loop can be used.
Adding a Signature - Often times Reports contain signatures. In order to reference the uploaded signature for your user profile, the syntax below can be used.
Below references the signature that was uploaded in the User Settings.
This references the image file of the signature.
src="file://{{signature.path}}
This references the typed out signature from the User Settings.
{% if signature.name_string %}{{signature.name_string.replace('\n', '<br>')|safe}}{% endif %}
Formatting
Formatting the entire page
Just like in a word doc, it is completely possible to adjust margins and spacings of the report. In order to adjust the page margin, @page is used within the <style> tag.
<style>
@page
{
}
</style>
Adjusting Styles can also be done in any of the tags.
Comments
0 comments
Article is closed for comments.