|
1
|
|
|
<?php |
|
2
|
|
|
/** |
|
3
|
|
|
* RepeatOrdersPage page shows order history and a form to allow |
|
4
|
|
|
* the member to edit his/her details. |
|
5
|
|
|
* |
|
6
|
|
|
* @package ecommerce |
|
7
|
|
|
* @subpackage ecommerce ecommerce_Repeatorders |
|
8
|
|
|
* @author nicolaas [at] sunnysideup.co.nz |
|
9
|
|
|
*/ |
|
10
|
|
|
class RepeatOrdersPage extends AccountPage |
|
11
|
|
|
{ |
|
12
|
|
|
|
|
13
|
|
|
/** |
|
14
|
|
|
* Standard SS method |
|
15
|
|
|
*/ |
|
16
|
|
|
private static $db = array( |
|
17
|
|
|
"WhatAreRepeatOrders" => "HTMLText", // explanation of repeat orders in general |
|
18
|
|
|
"OnceLoggedInYouCanCreateRepeatOrder" => "HTMLText" //explaining the benefits of logging in for Repeat Orders |
|
19
|
|
|
); |
|
20
|
|
|
|
|
21
|
|
|
/** |
|
22
|
|
|
* Standard SS method |
|
23
|
|
|
*/ |
|
24
|
|
|
private static $week_days = array( |
|
25
|
|
|
"Monday" => "Monday", |
|
26
|
|
|
"Tuesday" => "Tuesday", |
|
27
|
|
|
"Wednesday" => "Wednesday", |
|
28
|
|
|
"Thursday" => "Thursday", |
|
29
|
|
|
"Friday" => "Friday", |
|
30
|
|
|
"Saturday" => "Saturday", |
|
31
|
|
|
"Sunday" => "Sunday" |
|
32
|
|
|
); |
|
33
|
|
|
|
|
34
|
|
|
/** |
|
35
|
|
|
* Return a link to view the order on the account page. |
|
36
|
|
|
* actions are: create, update, view |
|
37
|
|
|
* @param String $action |
|
38
|
|
|
* @param int|string $orderID ID of the order |
|
|
|
|
|
|
39
|
|
|
*/ |
|
40
|
|
|
public static function get_repeat_order_link($action = 'view', $repeatOrderID = 0) |
|
41
|
|
|
{ |
|
42
|
|
|
$page = DataObject::get_one(__CLASS__); |
|
43
|
|
|
if (!$page) { |
|
44
|
|
|
user_error('No RepeatOrderPage was found. Please create one in the CMS!', E_USER_ERROR); |
|
45
|
|
|
} |
|
46
|
|
|
return $page->Link($action)."/".$repeatOrderID."/"; |
|
47
|
|
|
} |
|
48
|
|
|
|
|
49
|
|
|
/** |
|
50
|
|
|
* standard SS Method |
|
51
|
|
|
*/ |
|
52
|
|
|
public function canCreate($member = null) |
|
53
|
|
|
{ |
|
54
|
|
|
if(DataObject::get_one("RepeatOrdersPage")) { |
|
55
|
|
|
return false; |
|
56
|
|
|
} else { |
|
57
|
|
|
return parent::canCreate($member); |
|
58
|
|
|
} |
|
59
|
|
|
} |
|
60
|
|
|
|
|
61
|
|
|
|
|
62
|
|
|
/** |
|
63
|
|
|
* standard SS Method |
|
64
|
|
|
*/ |
|
65
|
|
|
public function getCMSFields() |
|
|
|
|
|
|
66
|
|
|
{ |
|
67
|
|
|
$fields = parent::getCMSFields(); |
|
68
|
|
|
$fields->addFieldToTab("Root.Content.ExplainingRepeatOrders", new HTMLEditorField($name = "WhatAreRepeatOrders", $title = "What Are Repeat Orders - Explanation Used throughout the site.", $rows = 3, $cols = 3)); |
|
69
|
|
|
$fields->addFieldToTab("Root.Content.ExplainingRepeatOrders", new HTMLEditorField($name = "OnceLoggedInYouCanCreateRepeatOrder", $title = "Explanation for people who are not logged-in yet explaining that they can turn an order into a Repeat order...", $rows = 3, $cols = 3)); |
|
70
|
|
|
return $fields; |
|
71
|
|
|
} |
|
72
|
|
|
|
|
73
|
|
|
/** |
|
74
|
|
|
* Returns all {@link Order} records for this |
|
75
|
|
|
* member that are completed. |
|
76
|
|
|
* |
|
77
|
|
|
* @return ArrayList |
|
78
|
|
|
*/ |
|
79
|
|
|
public function RepeatOrders() |
|
80
|
|
|
{ |
|
81
|
|
|
$memberID = Member::currentUserID(); |
|
82
|
|
|
return RepeatOrder::get() |
|
83
|
|
|
->where("\"MemberID\" = '$memberID' AND \"Status\" NOT IN ('MemberCancelled', 'AdminCancelled')") |
|
84
|
|
|
->sort("\"Created\" DESC"); |
|
85
|
|
|
} |
|
86
|
|
|
|
|
87
|
|
|
/** |
|
88
|
|
|
* Automatically create an AccountPage if one is not found |
|
89
|
|
|
* on the site at the time the database is built (dev/build). |
|
90
|
|
|
*/ |
|
91
|
|
|
public function requireDefaultRecords() |
|
92
|
|
|
{ |
|
93
|
|
|
parent::requireDefaultRecords(); |
|
94
|
|
|
if (!DataObject::get_one('RepeatOrdersPage')) { |
|
95
|
|
|
$page = new RepeatOrdersPage(); |
|
96
|
|
|
$page->Title = 'Repeat Orders'; |
|
97
|
|
|
$page->Content = '<p>This is the Repeat orders account page. It is used for shop users to login and create or change their Repeat orders.</p>'; |
|
98
|
|
|
$page->URLSegment = 'repeat-orders'; |
|
99
|
|
|
$page->WhatAreRepeatOrders = '<p>Repeat Orders allow you to regularly repeat an order.</p>'; |
|
100
|
|
|
$page->OnceLoggedInYouCanCreateRepeatOrder = '<p>Once logged in you can setup a repeating order.</p>'; |
|
101
|
|
|
$page->ShowInMenus = 0; |
|
102
|
|
|
$page->ShowInSearch = 0; |
|
103
|
|
|
$page->writeToStage('Stage'); |
|
104
|
|
|
$page->publish('Stage', 'Live'); |
|
105
|
|
|
if (method_exists('DB', 'alteration_message')) { |
|
106
|
|
|
DB::alteration_message('Repeat Order page \'Repeat Orders\' created', 'created'); |
|
107
|
|
|
} |
|
108
|
|
|
} |
|
109
|
|
|
} |
|
110
|
|
|
|
|
111
|
|
|
/** |
|
112
|
|
|
* Standard SS method |
|
113
|
|
|
* Sets the days available for repeating orders. |
|
114
|
|
|
*/ |
|
115
|
|
|
public function onBeforeWrite() |
|
116
|
|
|
{ |
|
117
|
|
|
parent::onBeforeWrite(); |
|
118
|
|
|
} |
|
119
|
|
|
} |
|
120
|
|
|
|
This check looks for PHPDoc comments describing methods or function parameters that do not exist on the corresponding method or function. It has, however, found a similar but not annotated parameter which might be a good fit.
Consider the following example. The parameter
$irelandis not defined by the methodfinale(...).The most likely cause is that the parameter was changed, but the annotation was not.