1
|
|
|
<?php |
2
|
|
|
/** |
3
|
|
|
* This is a stand-alone controller, designed to be |
4
|
|
|
* used with the eCommerce reporting system. |
5
|
|
|
* |
6
|
|
|
* It allows a user to view a template for a packing |
7
|
|
|
* slip of an order, or an invoice with status logs. |
8
|
|
|
* |
9
|
|
|
* @see CurrentOrdersReport |
10
|
|
|
* @see UnprintedOrderReport |
11
|
|
|
* |
12
|
|
|
* |
13
|
|
|
* |
14
|
|
|
* @authors: Silverstripe, Jeremy, Nicolaas |
15
|
|
|
* |
16
|
|
|
* @package: ecommerce |
17
|
|
|
* @sub-package: reports |
18
|
|
|
* |
19
|
|
|
**/ |
20
|
|
|
|
21
|
|
|
class OrderReport_Popup extends Controller |
|
|
|
|
22
|
|
|
{ |
23
|
|
|
|
24
|
|
|
//basic security for controller |
25
|
|
|
public static $allowed_actions = array( |
26
|
|
|
'index' => 'SHOPADMIN', |
27
|
|
|
'packingslip' => 'SHOPADMIN', |
28
|
|
|
'invoice' => 'SHOPADMIN' |
29
|
|
|
); |
30
|
|
|
|
31
|
|
|
public function init() |
|
|
|
|
32
|
|
|
{ |
33
|
|
|
parent::init(); |
34
|
|
|
//include print javascript, if print argument is provided |
35
|
|
|
if (isset($_REQUEST['print']) && $_REQUEST['print']) { |
36
|
|
|
Requirements::customScript("if(document.location.href.indexOf('print=1') > 0) {window.print();}"); |
|
|
|
|
37
|
|
|
} |
38
|
|
|
$this->Title = i18n::_t("ORDER.INVOICE", "Invoice"); |
|
|
|
|
39
|
|
|
if ($id = $this->urlParams['ID']) { |
40
|
|
|
$this->Title .= " #$id"; |
|
|
|
|
41
|
|
|
} |
42
|
|
|
/*Requirements::themedCSS("reset");*/ |
|
|
|
|
43
|
|
|
/*Requirements::themedCSS("OrderReport");*/ |
|
|
|
|
44
|
|
|
/*Requirements::themedCSS("OrderReport_Print", "print");*/ |
|
|
|
|
45
|
|
|
} |
46
|
|
|
|
47
|
|
|
/** |
48
|
|
|
* This is the default action of this |
49
|
|
|
* controller without calling any |
50
|
|
|
* explicit action, such as "show". |
51
|
|
|
* |
52
|
|
|
* This default "action" will show |
53
|
|
|
* order information in a printable view. |
54
|
|
|
*/ |
55
|
|
|
public function index() |
56
|
|
|
{ |
57
|
|
|
Requirements::themedCSS("OrderReport"); |
58
|
|
|
return $this->renderWith('Order_Printable'); |
59
|
|
|
} |
60
|
|
|
|
61
|
|
|
|
62
|
|
|
public function Link($action = null) |
|
|
|
|
63
|
|
|
{ |
64
|
|
|
return "OrderReport_Popup/$action"; |
65
|
|
|
} |
66
|
|
|
|
67
|
|
|
/** |
68
|
|
|
* This method is used primarily for cheque orders. |
69
|
|
|
* |
70
|
|
|
* @return unknown |
|
|
|
|
71
|
|
|
*/ |
72
|
|
|
public function SingleOrder() |
73
|
|
|
{ |
74
|
|
|
$id = $this->urlParams['ID']; |
75
|
|
|
|
76
|
|
|
if (is_numeric($id)) { |
77
|
|
|
$order = Order::get_by_id_if_can_view($id); |
78
|
|
|
$payment = $order->Payment(); |
79
|
|
|
$cheque = false; |
80
|
|
|
|
81
|
|
|
if ($record = $payment->First()) { |
82
|
|
|
if ($record->ClassName == 'ChequePayment') { |
83
|
|
|
$cheque = true; |
84
|
|
|
} |
85
|
|
|
} |
86
|
|
|
|
87
|
|
|
return new ArrayData(array( |
88
|
|
|
'DisplayFinalisedOrder' => $order, |
89
|
|
|
'IsCheque' => $cheque |
90
|
|
|
)); |
91
|
|
|
} |
92
|
|
|
|
93
|
|
|
return false; |
94
|
|
|
} |
95
|
|
|
|
96
|
|
|
/** |
97
|
|
|
* @TODO Get orders by ID or using current filter if ID is not numeric (for getting all orders) |
98
|
|
|
* @TODO Define what the role of this method is. Is it for templates, is it for a report? |
99
|
|
|
* |
100
|
|
|
* @return unknown |
101
|
|
|
*/ |
102
|
|
|
public function DisplayFinalisedOrder() |
|
|
|
|
103
|
|
|
{ |
104
|
|
|
$id = $this->urlParams['ID']; |
105
|
|
|
|
106
|
|
|
if (is_numeric($id)) { |
107
|
|
|
$order = Order::get_by_id_if_can_view($id); |
108
|
|
|
if (isset($_REQUEST['print'])) { |
|
|
|
|
109
|
|
|
//$order->updatePrinted(true); |
|
|
|
|
110
|
|
|
} |
111
|
|
|
|
112
|
|
|
return $order; |
113
|
|
|
} |
114
|
|
|
|
115
|
|
|
return false; |
116
|
|
|
} |
117
|
|
|
|
118
|
|
|
public function SiteConfig() |
119
|
|
|
{ |
120
|
|
|
return SiteConfig::current_site_config(); |
121
|
|
|
} |
122
|
|
|
} |
123
|
|
|
|
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.