|
1
|
|
|
<?php |
|
2
|
|
|
/** |
|
3
|
|
|
* An extension to {@link SSReport} that allows a user |
|
4
|
|
|
* to view all Order instances in the system. |
|
5
|
|
|
* |
|
6
|
|
|
* |
|
7
|
|
|
* @authors: Silverstripe, Jeremy, Nicolaas |
|
8
|
|
|
* |
|
9
|
|
|
* @package: ecommerce |
|
10
|
|
|
* @sub-package: reports |
|
11
|
|
|
* |
|
12
|
|
|
**/ |
|
13
|
|
|
|
|
14
|
|
|
class AllOrdersReport extends SS_Report |
|
|
|
|
|
|
15
|
|
|
{ |
|
16
|
|
|
protected $title = 'All orders'; |
|
17
|
|
|
|
|
18
|
|
|
protected $description = 'Show all orders in the system.'; |
|
19
|
|
|
|
|
20
|
|
|
public function sourceRecords($params, $sort = "", $limit = "") |
|
|
|
|
|
|
21
|
|
|
{ |
|
22
|
|
|
$filters = array(); |
|
23
|
|
|
if (isset($params['OrderID']) && $params['OrderID']) { |
|
24
|
|
|
$filters[] = "\"ID\" = ".$params['OrderID']; |
|
25
|
|
|
} |
|
26
|
|
|
if (isset($params['Status']) && $params['Status']) { |
|
27
|
|
|
$filters[] = "\"Status\" = '".$params['Status']."'"; |
|
28
|
|
|
} |
|
29
|
|
|
$sort = ""; |
|
30
|
|
|
$filter = implode(" AND ", $filters); |
|
31
|
|
|
return DataObject::get('Order', $filter, $sort, "", $limit); |
|
32
|
|
|
} |
|
33
|
|
|
|
|
34
|
|
|
public function columns() |
|
35
|
|
|
{ |
|
36
|
|
|
$cols = Order::get_summary_fields(); |
|
37
|
|
|
$cols['Invoice'] = 'Invoice'; |
|
38
|
|
|
return $cols; |
|
39
|
|
|
} |
|
40
|
|
|
|
|
41
|
|
|
public function getReportField() |
|
42
|
|
|
{ |
|
43
|
|
|
$tlf = parent::getReportField(); |
|
44
|
|
|
$tlf->setFieldFormatting(array( |
|
45
|
|
|
'Invoice' => '<a target=\"_blank\" href=\"OrderReport_Popup/invoice/$ID\">'.i18n::_t('Report.VIEW', 'view').'</a> ' . |
|
46
|
|
|
'<a target=\"_blank\" href=\"OrderReport_Popup/index/$ID?print=1\">'.i18n::_t('Report.PRINT', 'print').'</a>', |
|
47
|
|
|
)); |
|
48
|
|
|
$tlf->setFieldCasting(array( |
|
49
|
|
|
'Created' => 'Date->Long', |
|
50
|
|
|
'Total' => 'Currency->Nice' |
|
51
|
|
|
)); |
|
52
|
|
|
$tlf->setPermissions(array('edit', 'show', 'export', 'delete', 'print')); |
|
53
|
|
|
return $tlf; |
|
54
|
|
|
} |
|
55
|
|
|
|
|
56
|
|
|
public function parameterFields() |
|
57
|
|
|
{ |
|
58
|
|
|
$fields = new FieldSet( |
|
59
|
|
|
new TextField('OrderID', 'Order No'), |
|
60
|
|
|
new DateField('Created', 'Created'), |
|
61
|
|
|
//new TextField('FirstName','First Name'), |
|
|
|
|
|
|
62
|
|
|
//new TextField('Surname','Surname'), |
|
|
|
|
|
|
63
|
|
|
//new NumericField('Total','Total'), |
|
|
|
|
|
|
64
|
|
|
$ddf = new DropdownField('StatusID', 'Status', DataObject::get("OrderStep")->toDropdownMap()) |
|
65
|
|
|
); |
|
66
|
|
|
$ddf->setHasEmptyDefault(true); |
|
67
|
|
|
return $fields; |
|
68
|
|
|
} |
|
69
|
|
|
} |
|
70
|
|
|
|
You can fix this by adding a namespace to your class:
When choosing a vendor namespace, try to pick something that is not too generic to avoid conflicts with other libraries.