You're browsing the documentation for an old version of SupportPal. Consider upgrading to the latest version.
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
-
Take an existing report and make a copy under a new name, you can also set up a new category folder if desired.
- 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. -
Update the timeframe option, there are the following options:
monthly
- Allows selection of data for report for each month.yearly
- Allows selection of data for report for each year.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).none
- for reports where time options are not needed
- 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:
pie
- Pie chart, requires just two columns of data.bar
- Bar chart, works with multiple columns of datacolumn
- Column chart, works with multiple columns of datahistogram
- Histogram, requires just two columns of dataline
- Line graph, requires three columns of data where one column is time-basedarea
- Area graph, requires three columns of data where one column is time-basedstacked
- Stacked Area graph, similar to area graph but the various rows are stacked on top of each otherstepped
- Stepped Area graph, similar to area graph but the various rows are stacked on top of each othergeo
- Geo graph, requires just two columns of data where one is geographical-basedtable
- Table, visible on another tab
- 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. -
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 asuse App\Modules\Ticket\Models\Message;
-
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.XSS Attacks
Please ensure all output data is passed through thehtmlentities(string)
function ore(string)
for short. Alternatively, if you need to output user-defined HTML use thePurifier::clean(string)
function.