Exponential 6.0.13 Exponential Enterprise Open Source CMS - PHP Class Reference

ezorderstatushistory.php
Go to the documentation of this file.
1 <?php
34 class eZOrderStatusHistory extends eZPersistentObject
35 {
36 public $StatusName;
37 public $StatusID;
38 public function __construct( $row )
39 {
40 parent::__construct( $row );
41 $this->Modifier = null;
42 $this->StatusName = null;
43 if ( isset( $row['status_name'] ) )
44 $this->StatusName = $row['status_name'];
45 }
46
50 static function definition()
51 {
52 return array( "fields" => array( "id" => array( 'name' => 'ID',
53 'datatype' => 'integer',
54 'default' => 0,
55 'required' => true ),
56 "order_id" => array( 'name' => 'OrderID',
57 'datatype' => 'integer',
58 'default' => 0,
59 'required' => true,
60 'foreign_class' => 'eZOrder',
61 'foreign_attribute' => 'id',
62 'multiplicity' => '1..*' ),
63 "status_id" => array( 'name' => 'StatusID',
64 'datatype' => 'integer',
65 'default' => 0,
66 'required' => true,
67 'foreign_class' => 'eZOrderStatus',
68 'foreign_attribute' => 'id',
69 'multiplicity' => '1..*' ),
70 "modifier_id" => array( 'name' => "ModifierID",
71 'datatype' => 'integer',
72 'default' => 0,
73 'required' => true,
74 'foreign_class' => 'eZUser',
75 'foreign_attribute' => 'contentobject_id',
76 'multiplicity' => '1..*' ),
77 "modified" => array( 'name' => "Modified",
78 'datatype' => 'integer',
79 'default' => 0,
80 'required' => true ) ),
81 'function_attributes' => array( 'modifier' => 'modifier',
82 'status_name' => 'fetchOrderStatusName',
83 'status' => 'fetchOrderStatus' ),
84 "keys" => array( "id" ),
85 "increment_key" => "id",
86 "class_name" => "eZOrderStatusHistory",
87 "name" => "ezorder_status_history" );
88 }
89
95 function modifier()
96 {
97 if ( $this->Modifier === null )
98 {
99 $this->Modifier = eZContentObject::fetch( $this->ModifierID );
100 }
101 return $this->Modifier;
102 }
103
108 function fetchOrderStatus()
109 {
110 $statusList = eZOrderStatus::fetchMap( true, true );
111 if ( isset( $statusList[$this->StatusID] ) )
112 {
113 return $statusList[$this->StatusID];
114 }
115 return false;
116 }
117
122 function fetchOrderStatusName()
123 {
124 if ( $this->StatusName === null )
125 {
126 $status = $this->fetchOrderStatus();
127 $this->StatusName = $status->attribute( 'name' );
128 }
129 return $this->StatusName;
130 }
131
136 function fetch( $id, $asObject = true )
137 {
138 return eZPersistentObject::fetchObject( eZOrderStatusHistory::definition(),
139 null,
140 array( "id" => $id ),
141 $asObject );
142 }
143
149 static function fetchListByOrder( $orderID, $asObject = true )
150 {
151 $db = eZDB::instance();
152
153 $orderID = (int)$orderID;
154 $rows = $db->arrayQuery( "SELECT ezorder_status_history.*, ezorder_status.name AS status_name " .
155 "FROM ezorder_status_history, ezorder_status " .
156 "WHERE order_id = $orderID AND" .
157 " ezorder_status.status_id = ezorder_status_history.status_id " .
158 "ORDER BY ezorder_status_history.modified DESC" );
159
160 return eZPersistentObject::handleRows( $rows, 'eZOrderStatusHistory', $asObject );
161 }
162
168 static function fetchCount( $orderID, $asObject = true )
169 {
170 $db = eZDB::instance();
171
172 $orderID = (int)$orderID;
173 $countArray = $db->arrayQuery( "SELECT count( * ) AS count FROM ezorder_status_history WHERE order_id = $orderID" );
174 return $countArray[0]['count'];
175 }
176
181 static function create( $orderID, $statusID, $userID = false, $timestamp = false )
182 {
183 if ( $timestamp === false )
184 {
185 $timestamp = time();
186 }
187 if ( $userID === false )
188 {
189 $userID = eZUser::currentUserID();
190 }
191 $row = array( 'id' => null,
192 'order_id' => $orderID,
193 'status_id' => $statusID,
194 'modifier_id' => $userID,
195 'modified' => $timestamp );
196 return new eZOrderStatusHistory( $row );
197 }
198
199
203 public $Modifier;
204 }
205
206 ?>
eZContentObject\fetch
static fetch( $id, $asObject=true)
Definition: ezcontentobject.php:885
eZDB\instance
static instance( $databaseImplementation=false, $databaseParameters=false, $forceNewInstance=false)
Definition: ezdb.php:117
eZOrderStatusHistory
Handles a list of status changes to an order item.
Definition: ezorderstatushistory.php:35
eZOrderStatusHistory\fetchOrderStatusName
fetchOrderStatusName()
Definition: ezorderstatushistory.php:122
eZOrderStatusHistory\modifier
modifier()
Definition: ezorderstatushistory.php:95
eZOrderStatusHistory\create
static create( $orderID, $statusID, $userID=false, $timestamp=false)
Definition: ezorderstatushistory.php:181
eZOrderStatusHistory\$Modifier
$Modifier
Definition: ezorderstatushistory.php:203
eZOrderStatusHistory\$StatusName
$StatusName
Definition: ezorderstatushistory.php:36
eZOrderStatusHistory\fetchListByOrder
static fetchListByOrder( $orderID, $asObject=true)
Definition: ezorderstatushistory.php:149
eZOrderStatusHistory\definition
static definition()
Definition: ezorderstatushistory.php:50
eZOrderStatusHistory\fetchOrderStatus
fetchOrderStatus()
Definition: ezorderstatushistory.php:108
eZOrderStatusHistory\fetch
fetch( $id, $asObject=true)
Definition: ezorderstatushistory.php:136
eZOrderStatusHistory\$StatusID
$StatusID
Definition: ezorderstatushistory.php:37
eZOrderStatusHistory\fetchCount
static fetchCount( $orderID, $asObject=true)
Definition: ezorderstatushistory.php:168
eZOrderStatusHistory\__construct
__construct( $row)
Definition: ezorderstatushistory.php:38
eZOrderStatus\fetchMap
static fetchMap( $asObject=true, $showInactive=false)
Definition: ezorderstatus.php:140
eZPersistentObject
Definition: ezpersistentobject.php:33
eZPersistentObject\fetchObject
static fetchObject( $def, $field_filters, $conds, $asObject=true, $grouping=null, $custom_fields=null)
Definition: ezpersistentobject.php:213
eZPersistentObject\handleRows
static handleRows( $rows, $class_name, $asObject)
Definition: ezpersistentobject.php:963
eZUser\currentUserID
static currentUserID()
Definition: ezuser.php:1731
Copyright © 1998 – 2026 7x. All rights reserved. Licensed under the GNU GPLv2+.