|
1
|
|
|
<?php |
|
2
|
|
|
|
|
3
|
|
|
|
|
4
|
|
|
/** |
|
5
|
|
|
* @authors: Nicolaas [at] Sunny Side Up .co.nz |
|
6
|
|
|
* @package: ecommerce |
|
7
|
|
|
* @sub-package: model |
|
8
|
|
|
* @inspiration: Silverstripe Ltd, Jeremy |
|
9
|
|
|
**/ |
|
10
|
|
|
class OrderStatusLog_DeviceDetails extends OrderStatusLog |
|
11
|
|
|
{ |
|
12
|
|
|
private static $db = array( |
|
|
|
|
|
|
13
|
|
|
'IPAddress' => 'Varchar(255)', |
|
14
|
|
|
'UserAgent' => 'Varchar(255)', |
|
15
|
|
|
'AcceptLanguage' => 'Varchar(255)', |
|
16
|
|
|
'SessionAge' => 'Decimal', |
|
17
|
|
|
'SessionID' => 'Varchar(255)' |
|
18
|
|
|
); |
|
19
|
|
|
|
|
20
|
|
|
public function canCreate($member = null) |
|
21
|
|
|
{ |
|
22
|
|
|
return false; |
|
23
|
|
|
} |
|
24
|
|
|
|
|
25
|
|
View Code Duplication |
public function canEdit($member = null) |
|
|
|
|
|
|
26
|
|
|
{ |
|
27
|
|
|
$order = $this->Order(); |
|
|
|
|
|
|
28
|
|
|
if ($order && $order->exists()) { |
|
29
|
|
|
$status = $order->MyStep(); |
|
30
|
|
|
if ($status && $status->Code == 'RECORD_DEVICE_DETAILS') { |
|
31
|
|
|
return parent::canEdit($member); |
|
32
|
|
|
} else { |
|
33
|
|
|
return false; |
|
34
|
|
|
} |
|
35
|
|
|
} else { |
|
36
|
|
|
return parent::canEdit($member); |
|
37
|
|
|
} |
|
38
|
|
|
} |
|
39
|
|
|
|
|
40
|
|
|
/** |
|
41
|
|
|
* adding a sequential order number. |
|
42
|
|
|
*/ |
|
43
|
|
|
public function onBeforeWrite() |
|
44
|
|
|
{ |
|
45
|
|
|
parent::onBeforeWrite(); |
|
46
|
|
|
|
|
47
|
|
|
$order = $this->Order(); |
|
|
|
|
|
|
48
|
|
|
$this->SessionID = $order->SessionID; |
|
|
|
|
|
|
49
|
|
|
|
|
50
|
|
|
if (Controller::has_curr()) { |
|
51
|
|
|
$this->IPAddress = Controller::curr()->getRequest()->getIP(); |
|
|
|
|
|
|
52
|
|
|
} |
|
53
|
|
|
|
|
54
|
|
|
$session = Session::get_all(); |
|
55
|
|
|
if (isset($session['HTTP_USER_AGENT'])) { |
|
56
|
|
|
$this->UserAgent = $session['HTTP_USER_AGENT']; |
|
|
|
|
|
|
57
|
|
|
} |
|
58
|
|
|
|
|
59
|
|
|
|
|
60
|
|
|
if (isset($_SERVER['HTTP_ACCEPT_LANGUAGE'])) { |
|
61
|
|
|
$this->AcceptLanguage = $_SERVER['HTTP_ACCEPT_LANGUAGE']; |
|
|
|
|
|
|
62
|
|
|
} |
|
63
|
|
|
} |
|
64
|
|
|
} |
|
65
|
|
|
|