Hello people, this one has been driving my mad all afternoon
I am trying to set up a custom report with some selection criteria - nothing I haven't done a hundred times before (code fragment below)
The problem is that the selected parameter array is not being passed into sourceRecords()
Or, to be more accurate, an empty array is being passed regardless of what is selected in the dropdown field
This results is that the report is return all records, not just the ones for the selected client
Also, the selection is not being preserved after clicking the Filter button
That is, when the report screen refreshes the dropdown field has returned to the default value
The code, as far as i can see, is identical to what I have used in all my other ss reports, all of which work correctly so this makes no sense to me
Can anyone out there explain why this is not working?
(In case it is relevant - the site is running under SS 3.1.3)
Thanks in advance for any help you can offer
class powerbankOrderExport extends SS_Report {
public function parameterFields() {
return new FieldList (
DropdownField::create('Client')->setTitle('Client')
->setSource (
array (0 => '[ all ]') +
powerbankClient::get()->map('ID', 'Name')->toArray()
)
);
}
public function sourceRecords($params, $sort, $limit) {
$where = 'powerbankOrderLine.ProductID > 0 and powerbankOrderLine.LogoID > 0';
if ((int) $params['Client'] > 0)
$where .= ' and powerbankOrder.ClientID = ' . (int) $params['Client'];
$orderLines = powerbankOrderLine::get()
->leftJoin ('powerbankOrder', 'powerbankOrder.ID = powerbankOrderLine.OrderID')
->leftJoin ('powerbankClient', 'powerbankClient.ID = powerbankOrder.ClientID')
->where ($where)
->sort ('powerbankClient.Name, powerbankOrder.OrderRef, powerbankOrder.PONumber, powerbankOrderLine.ID');
return $orderLines;
}
} // end class powerbankOrderExport