I am sure we have all experienced this with the in built Dashboard feature.
Reports & Charts with a filter (Page_selecting) that are added to the dashboard.
My solution below, was created for the need to add CHARTS to a dashboard and filter data based on user level and location.
REQUIREMENTS
a. PHPmaker (preferably v2020)
b. External Text Editor like Notepad++.
- Create report and chart as you normally would (or as per Help File). eg. invoices summary report
- Create custom PHP file (include common files) e.g dash.php
- Save & generate Project.
- Open the report file (OR BOTH) in the editor of choice.
- In the report file, we are looking for 3 parts:
a) Create page object e.g
// Create page object
$Daily_Sales_Expenses_summary = new Daily_Sales_Expenses_summary();
b) Run page object e.g
// Run the page
$Daily_Sales_Expenses_summary->run();
c) The code that generates the chart on the report page e.g (has the condition if (!$DashboardReport) and is towards the lower part of the file)
if (!$DashboardReport) {
// Set up page break
if (($Daily_Sales_Expenses_summary->isExport(“print”) || $Daily_Sales_Expenses_summary->isExport(“pdf”) || $Daily_Sales_Expenses_summary->isExport(“email”) || $Daily_Sales_Expenses_summary->isExport(“excel”) && Config(“USE_PHPEXCEL”) || $Daily_Sales_Expenses_summary->isExport(“word”) && Config(“USE_PHPWORD”)) && $Daily_Sales_Expenses_summary->ExportChartPageBreak) {
// Page_Breaking server event
$Daily_Sales_Expenses_summary->Page_Breaking($Daily_Sales_Expenses_summary->ExportChartPageBreak, $Daily_Sales_Expenses_summary->PageBreakContent);
$Daily_Sales_Expenses->Daily_Sales_Expenses->PageBreakType = “after”; // Page break type
$Daily_Sales_Expenses->Daily_Sales_Expenses->PageBreak = $Daily_Sales_Expenses_summary->ExportChartPageBreak;
$Daily_Sales_Expenses->Daily_Sales_Expenses->PageBreakContent = $Daily_Sales_Expenses_summary->PageBreakContent;
}
// Set up chart drilldown
$Daily_Sales_Expenses->Daily_Sales_Expenses->DrillDownInPanel = $Daily_Sales_Expenses_summary->DrillDownInPanel;
$Daily_Sales_Expenses->Daily_Sales_Expenses->setParameter(“clickurl”, “daily_sales_expensessmry.php”); // Add click URL
$Daily_Sales_Expenses->Daily_Sales_Expenses->render();
}
- Copy these and add them to a layout of your choice in the Content section of your custom file ie CustomTemplates->TableSpecific->CustomFile->Content e.g in a card element as below:
Today's Sales & Expenses
- Generate your project and check your file. You may style the content as you desire/required. This works for all chart types.
Let me now how it goes.