# Report Templates

## Overview

{% hint style="info" %}

* Report template is used to generated PDF reports using data from an order. This feature is useful to generate end of order report for auditing, or even to generate a certificate of analysis.
* When generating a PDF report we can incorporate any data from activities that were submitted, including pictures, and we have the ability to format the report to our liking.
* The process of creating a report template is split into two steps.
  * First we filter the data that is relevant to this report, which activities are to be read and displayed and which order attribute should be listed.
  * Then we work on a HTML template. This HTML Template is what allows you to format the final PDF the way you need, adding your company logo, fonts and colours.

This guide details the process for creating and managing report templates within our system, focusing on producing PDF reports through various configurations and customisations.
{% endhint %}

## Navigation

Navigate to ***Settings > Configuration > Report Template*** to go to the configuration page.

<figure><img src="/files/6HyBvG2whufa5UQTkn3f" alt=""><figcaption></figcaption></figure>

## Creating a Report Template

Click on the **Create** button, then you should be presented with a multi step modal with fields like below.

<table><thead><tr><th width="209">Name</th><th>Desc</th></tr></thead><tbody><tr><td>Name</td><td>The name of the report</td></tr><tr><td>Description</td><td>Description of the Report</td></tr><tr><td>Data type</td><td>ORDER or EVENT or ACTIVITY</td></tr><tr><td>Asset Classes</td><td>The option to choose what Asset classes will be included in the report.</td></tr><tr><td>HTML Template</td><td>Choose to create a new HTML template or an existing one if there is one. Choose 'New from Blank' for a completely blank template.<br>It is recommended to choose 'New from Starter Template' if you don't have any HTML and handlerbars scripting experience.</td></tr><tr><td>Attributes</td><td>The option to choose which attributes will be included in the report.</td></tr><tr><td>Activities</td><td>The option to choose which activities will be included in the report.</td></tr><tr><td>Operations</td><td>The option to choose which order template operations, will be included in the report.<br><strong>Note:</strong> this must be written in a comma separated list.</td></tr><tr><td>Include Images</td><td>The checkbox option to include images in your report.</td></tr><tr><td>Sort By</td><td>You can choose to sort the Activities in the Report by Completed At date or Issued At Date</td></tr><tr><td>Sort Direction</td><td>Sort direction of the chosen sort by field</td></tr></tbody></table>

For this example, we will make a **Order Report** of type **ORDER.** After filling out the details, click on **Save and Open**.

<figure><img src="/files/72DsnxEtvToa7IPIQ9J8" alt=""><figcaption></figcaption></figure>

<figure><img src="/files/Xop91rwzj8ulfOYtNDJW" alt=""><figcaption></figcaption></figure>

<figure><img src="/files/6tYSnjlSUEe7Z5zh6V4I" alt=""><figcaption></figcaption></figure>

<figure><img src="/files/sSkQqYj7iM0jWAV0d5nt" alt=""><figcaption></figcaption></figure>

## Editing your HTML Template

Utilise the HTML editor to begin designing your report. This is where you can format and lay out your report. We use a templating engine called [Mustache](https://mustache.github.io/mustache.5.html), which allows dynamic data insertion using curly braces, e.g., `{{order.order_number}}`.

<figure><img src="/files/t5CUAf8in2pAJz641sfU" alt=""><figcaption></figcaption></figure>

To make the editing process easier, you can simulate the form with an actual order by **scrolling down to the bottom of the page and click "Select and Order".**

<figure><img src="/files/pvDsCuPCkl0p5ziizEnD" alt=""><figcaption></figcaption></figure>

{% hint style="warning" %}
Referencing Activity Items' values

For referencing activity items' values, you need to reference it like this

```handlebars
<td>
  {{#if this.stringValue}}
    {{this.stringValue}}
  {{else if this.numericValue}}
    {{this.numericValue}}
  {{else if this.booleanValue}}
    {{this.booleanValue}}
  {{else}}
    {{this.value}}
  {{/if}}
</td>
```

Referencing with only this.value will displays the item's raw value, which might not be nicely formatted.
{% endhint %}

Then you will be presented with three views.

* The **Preview HTML** view shows you what the HTML you have on the editor will render in one scroll in the page.
* The **Preview PDF** will render a PDF file that is formatted with your HTML and this file can be saved and viewed in pages.
* The **Order Data** will show you what data is available based on not just the chosen preview order but also the data from all the assets, attributes and activities that you had chosen before. This can be utilized to figure out how to write your data insertion.

<figure><img src="/files/7BMeg4i9jAXUSufKkZd3" alt=""><figcaption></figcaption></figure>

## HTML Templates

HTML Templates are managed separately from Report Templates and can be shared across multiple Report Templates.

The HTML Template editor and preview panels are displayed as top-level expansion cards within the Report Template configuration page.

<figure><img src="/files/y0JRYuBTXqYhkCRtV9gB" alt=""><figcaption></figcaption></figure>

Expanding the HTML Template card gives you access to the full editor and preview.

<figure><img src="/files/uCLmPAMrz1xmAbaNDEFk" alt=""><figcaption></figcaption></figure>

{% hint style="warning" %}
If an HTML Template is used by more than one Report Template, editing it will display a warning listing the other Report Templates that share that HTML Template. Review the list before saving to avoid unintended changes to other reports.
{% endhint %}

## Creating an Order Report

Now after creating your template, go back to the Homepage, then click on **Orders**. Choose any Order then click on **Details**. Next to the name there is a little button with a printer icon.

Here if you have more than one templates, more than one will pop up, but **"Order Template"** is the one we just made.

<figure><img src="/files/LuoMdXqizULemtbe0DXl" alt=""><figcaption></figcaption></figure>

Afterwards, a dialogue will pop up like below that will let you download the report.

<figure><img src="/files/uQPYvV3jwwxE5DlltMlA" alt=""><figcaption></figcaption></figure>


---

# Agent Instructions: Querying This Documentation

If you need additional information that is not directly available in this page, you can query the documentation dynamically by asking a question.

Perform an HTTP GET request on the current page URL with the `ask` query parameter:

```
GET https://help.tillit.cloud/tillit/knowledge-base/setting-up-tillit/configuration/creating-and-using-report-templates.md?ask=<question>
```

The question should be specific, self-contained, and written in natural language.
The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
