SupportPal Documentation

Custom Reports

We have provided a framework that lets you create your own reports, requiring some knowledge of PHP. Existing reports are stored in /app/Reports and there is a folder for each category.

Step-by-Step Guide

  1. Take an existing report and make a copy under a new name, you can also set up a new category folder if desired.

  2. Open the newly created report file, and update the $record->title and $record->description with what you are going to call the report and what it will show.
  3. Update the timeframe option, there are the following options:
    1. monthly - Allows selection of data for report for each month.
    2. yearly - Allows selection of data for report for each year.
    3. custom - Allows to choose any window of time for the report as well as all time, defaults to one month from current date but can be overridden by setting $startDate and $endDate (UNIX timestamps).
    4. none - for reports where time options are not needed
  4. Update the charts option, which lets you define what charts are available to the user when viewing the report. The value is an array of strings, with the first item of the array being the chart that is shown by default when loading the report. There are the following options:
    1. pie - Pie chart, requires just two columns of data.
    2. bar - Bar chart, works with multiple columns of data
    3. column - Column chart, works with multiple columns of data
    4. histogram - Histogram, requires just two columns of data
    5. line - Line graph, requires three columns of data where one column is time-based
    6. area - Area graph, requires three columns of data where one column is time-based
    7. stacked - Stacked Area graph, similar to area graph but the various rows are stacked on top of each other
    8. stepped - Stepped Area graph, similar to area graph but the various rows are stacked on top of each other
    9. geo - Geo graph, requires just two columns of data where one is geographical-based
    10. table - Table, visible on another tab
  5. If it is a report related to tickets or users, you may wish to show the filtering options, set the $report->filtering value to either 'ticket' or 'user'. If the filtering options is not needed, it should be set to null.
  6. Update $report->query to fetch the data required for the report. We use the Eloquent ORM by Laravel, we recommend to read the documentation and view the other reports to get an idea on how it works. You will need to remember to import the model classes, such as
                use App\Modules\Ticket\Models\Message;
            
  7. Update the getData function to handle the data returned and convert it to a format that works with Google Charts. Each line in the existing reports are commented to explain what is being done and should help with what you're trying to do.