1
|
|
|
<?php |
2
|
|
|
|
3
|
|
|
/** |
4
|
|
|
* Data for each in orderstep |
5
|
|
|
* for each country |
6
|
|
|
* |
7
|
|
|
*/ |
8
|
|
|
|
9
|
|
|
class EcommerceOrderStepCountryData extends DataObject |
10
|
|
|
{ |
11
|
|
|
private static $singular_name = "Country specific Order Step Information"; |
|
|
|
|
12
|
|
|
public function i18n_singular_name() |
13
|
|
|
{ |
14
|
|
|
return "Country specific Order Step Information"; |
15
|
|
|
} |
16
|
|
|
|
17
|
|
|
private static $plural_name = "Country specific Order Step Information Items"; |
|
|
|
|
18
|
|
|
public function i18n_plural_name() |
19
|
|
|
{ |
20
|
|
|
return "Country specific Order Step Information Items"; |
21
|
|
|
} |
22
|
|
|
|
23
|
|
|
private static $db = array( |
|
|
|
|
24
|
|
|
'CountrySpecificEmailSubject' => 'Varchar(255)', |
25
|
|
|
'CountrySpecificEmailMessage' => 'HTMLText' |
26
|
|
|
); |
27
|
|
|
|
28
|
|
|
private static $has_one = array( |
|
|
|
|
29
|
|
|
"OrderStep" => "OrderStep", |
30
|
|
|
"EcommerceCountry" => "EcommerceCountry" |
31
|
|
|
); |
32
|
|
|
|
33
|
|
|
private static $required_fields = array( |
34
|
|
|
"EcommerceCountryID" |
35
|
|
|
); |
36
|
|
|
|
37
|
|
|
private static $summary_fields = array( |
|
|
|
|
38
|
|
|
"EcommerceCountry.Title" => "Country", |
39
|
|
|
"OrderStep.Title" => "Step", |
40
|
|
|
"CountrySpecificEmailSubject" => "Subject" |
41
|
|
|
|
42
|
|
|
); |
43
|
|
|
|
44
|
|
|
private static $field_labels = array( |
|
|
|
|
45
|
|
|
"CountrySpecificEmailSubject" => "Email Subject", |
46
|
|
|
"CountrySpecificEmailMessage" => "Email Message" |
47
|
|
|
); |
48
|
|
|
|
49
|
|
|
|
50
|
|
|
public function getCMSFields() |
51
|
|
|
{ |
52
|
|
|
$fields = parent::getCMSFields(); |
53
|
|
|
$messageField = new HtmlEditorField('CountrySpecificEmailMessage', "Email Content"); |
54
|
|
|
$messageField->setRows(7); |
55
|
|
|
$fields->addFieldsToTab( |
56
|
|
|
'Root.Main', |
57
|
|
|
array( |
58
|
|
|
new TextField('CountrySpecificEmailSubject', "Subject"), |
59
|
|
|
$messageField |
60
|
|
|
) |
61
|
|
|
); |
62
|
|
|
$fields->addFieldToTab( |
63
|
|
|
"Root.Main", |
64
|
|
|
new DropdownField( |
65
|
|
|
"EcommerceCountryID", |
66
|
|
|
"Country", |
67
|
|
|
EcommerceCountry::get()->map() |
68
|
|
|
) |
69
|
|
|
); |
70
|
|
|
return $fields; |
71
|
|
|
} |
72
|
|
|
|
73
|
|
|
/** |
74
|
|
|
* make sure this entry does not exist yet... |
75
|
|
|
*/ |
76
|
|
|
public function validate() |
77
|
|
|
{ |
78
|
|
|
$valid = parent::validate(); |
79
|
|
|
$filter = array( |
80
|
|
|
"OrderStepID" => $this->OrderStepID, |
|
|
|
|
81
|
|
|
"EcommerceCountryID" => $this->EcommerceCountryID |
|
|
|
|
82
|
|
|
); |
83
|
|
|
$exclude = array("ID" => $this->ID); |
84
|
|
|
if (EcommerceOrderStepCountryData::get()->filter($filter)->exclude($exclude)->count()) { |
85
|
|
|
$valid->error('An entry for this country and order step already exists. Please change the country or review existing records.'); |
86
|
|
|
} |
87
|
|
|
return $valid; |
88
|
|
|
} |
89
|
|
|
} |
90
|
|
|
|