Custom Reports
WHMCS includes a wide range of reports to give you in-depth reporting and analytics on the performance of your business. You can find them at Reports > Reports.
You can easily modify any of WHMCS’s default reports or create your own custom new reports. All of WHMCS’s reports are available as unencoded files in the /modules/reports/
directory.
Creating Reports
In addition to customizing the reports that ship with WHMCS, you can add your own custom reports to WHMCS’s modular reporting system.
To create your own report, we recommend looking at the format of one of the current files from one of the stock reports in the /modules/reports
directory.
- The WHMCS-included reports are open source and you can copy the format from them for use in your custom report.
- The report name you choose must be unique, all lowercase, and contain only letters and numbers (
a
–z
,0
–9
). It must start with a letter.
Upload your report to the /modules/reports
directory. You can then access it at Reports > More or in the list at Reports > Reports.
Report Format
Reports use the following general format, which includes the title of the report, the description, a header, a table of data with headings, and footer text:
<?php
# The title of your report
$reportdata["title"] = "";
# The description of your report
$reportdata["description"] = "";
# Header text - this gets displayed above the report table of data
$reportdata["headertext"] = "";
# Report Table of Data Column Headings - should be an array of values
$reportdata["tableheadings"] = array("Column 1", "Column 2", "Column 3");
# Report Table Values - one of these lines for each row you want in the table
# should be an array of values to match the column headings
$reportdata["tablevalues"][] = array("Data 1", "Data 2", "Data 3");
$reportdata["tablevalues"][] = array("Data 1", "Data 2", "Data 3");
$reportdata["tablevalues"][] = array("Data 1", "Data 2", "Data 3");
# Report Footer Text - this gets displayed below the report table of data
$data["footertext"] = "";
Adding Google Charts
WHMCS uses the Google Charts API to generate graphical reports.
To add a Google chart to a report, use the drawChart
function. It accepts the following parameters in the order below:
- The type of chart that you wish to use.
- The data that you wish to use.
- The configuration that defines the chart’s visual display (for example, color or legend position).
- Height (defaults to
300px
). - Width (defaults to
100%
).
This example uses the drawChart function to create a pie chart:
$reportdata["headertext"] = $chart->drawChart('Pie', $chartdata, $args, '300px', '100%');
Last modified: October 30, 2024