Exponential 6.0.13 Exponential Enterprise Open Source CMS - PHP Class Reference

ezorder.php
Go to the documentation of this file.
1 <?php
19 class eZOrder extends eZPersistentObject
20 {
21 public $ProductCollectionID;
22 public $IgnoreVAT;
23 public $OrderNr;
24 public $StatusID;
25 public $StatusModified;
26 public $StatusModifierID;
27 public $AccountIdentifier;
28 const SHOW_NORMAL = 0;
29 const SHOW_ARCHIVED = 1;
30 const SHOW_ALL = 2;
31
32 public function __construct( $row )
33 {
34 parent::__construct( $row );
35 $this->Status = null;
36 }
37
38 static function definition()
39 {
40 return array( "fields" => array( "id" => array( 'name' => 'ID',
41 'datatype' => 'integer',
42 'default' => 0,
43 'required' => true ),
44 "order_nr" => array( 'name' => "OrderNr",
45 'datatype' => 'integer',
46 'default' => 0,
47 'required' => true ),
48 "is_temporary" => array( 'name' => "IsTemporary",
49 'datatype' => 'integer',
50 'default' => 1,
51 'required' => true ),
52 "user_id" => array( 'name' => "UserID",
53 'datatype' => 'integer',
54 'default' => 0,
55 'required' => true,
56 'foreign_class' => 'eZUser',
57 'foreign_attribute' => 'contentobject_id',
58 'multiplicity' => '1..*' ),
59 "productcollection_id" => array( 'name' => "ProductCollectionID",
60 'datatype' => 'integer',
61 'default' => 0,
62 'required' => true,
63 'foreign_class' => 'eZProductCollection',
64 'foreign_attribute' => 'id',
65 'multiplicity' => '1..*' ),
66 "data_text_1" => array( 'name' => "DataText1",
67 'datatype' => 'text',
68 'default' => '',
69 'required' => true ),
70 "data_text_2" => array( 'name' => "DataText2",
71 'datatype' => 'text',
72 'default' => '',
73 'required' => true ),
74 "account_identifier" => array( 'name' => "AccountIdentifier",
75 'datatype' => 'string',
76 'default' => 'default',
77 'required' => true ),
78 "created" => array( 'name' => "Created",
79 'datatype' => 'integer',
80 'default' => 0,
81 'required' => true ),
82 "ignore_vat" => array( 'name' => "IgnoreVAT",
83 'datatype' => 'integer',
84 'default' => 0,
85 'required' => true ),
86 "email" => array( 'name' => "Email",
87 'datatype' => 'string',
88 'default' => '',
89 'required' => true ),
90 "status_id" => array( 'name' => 'StatusID',
91 'datatype' => 'integer',
92 'default' => 0,
93 'required' => false,
94 'foreign_class' => 'eZOrderStatus',
95 'foreign_attribute' => 'id',
96 'multiplicity' => '1..*' ),
97 "status_modified" => array( 'name' => "StatusModified",
98 'datatype' => 'integer',
99 'default' => 0,
100 'required' => true ),
101 "status_modifier_id" => array( 'name' => "StatusModifierID",
102 'datatype' => 'integer',
103 'default' => 0,
104 'required' => true,
105 'foreign_class' => 'eZUser',
106 'foreign_attribute' => 'contentobject_id',
107 'multiplicity' => '1..*' ),
108 "is_archived" => array( 'name' => "IsArchived",
109 'datatype' => 'integer',
110 'default' => 0,
111 'required' => true ) ),
112 'function_attributes' => array( 'status_name' => 'statusName',
113 'status' => 'statusObject',
114 'status_modification_list' => 'statusModificationList',
115 'product_items' => 'productItems',
116 'product_items_ordered' => 'productItemsOrdered',
117 'order_items' => 'orderItems',
118 'product_total_inc_vat' => 'productTotalIncVAT',
119 'product_total_ex_vat' => 'productTotalExVAT',
120 'total_inc_vat' => 'totalIncVAT',
121 'total_ex_vat' => 'totalExVAT',
122 'user' => 'user',
123 'account_view_template' => 'accountViewTemplate',
124 'account_information' => 'accountInformation',
125 'account_name' => 'accountName',
126 'account_email' => 'accountEmail',
127 'productcollection' => 'productCollection',
128 'order_info' => 'orderInfo' ),
129 "keys" => array( "id" ),
130 "increment_key" => "id",
131 "class_name" => "eZOrder",
132 "name" => "ezorder" );
133 }
134
135
144 function detachProductCollection()
145 {
146 $collection = $this->productCollection();
147 if ( !$collection )
148 {
149 $retValue = false;
150 return $retValue;
151 }
152
153 $db = eZDB::instance();
154 $db->begin();
155 $newCollection = $collection->copy();
156 if ( !$newCollection )
157 {
158 $db->commit();
159 $retValue = false;
160 return $retValue;
161 }
162 $this->setAttribute( 'productcollection_id', $newCollection->attribute( 'id' ) );
163 $this->store();
164
165 $db->commit();
166 return $newCollection;
167 }
168
172 function productCollection()
173 {
174 return eZProductCollection::fetch( $this->attribute( 'productcollection_id' ) );
175 }
176
177 static function fetch( $id, $asObject = true )
178 {
179 return eZPersistentObject::fetchObject( eZOrder::definition(),
180 null,
181 array( "id" => $id ),
182 $asObject );
183 }
184
185 static function fetchList( $asObject = true )
186 {
187 return eZPersistentObject::fetchObjectList( eZOrder::definition(),
188 null, null,
189 array( "created" => "desc" ), null,
190 $asObject );
191 }
192
193 static function activeByUserID( $userID, $asObject = true )
194 {
195 return eZPersistentObject::fetchObjectList( eZOrder::definition(),
196 null,
197 array( "user_id" => $userID,
198 'is_temporary' => 0 ),
199 array( "created" => "desc" ), null,
200 $asObject );
201 }
202
203 static function getShowOrdersQuery( $show, $table = null )
204 {
205 $table = ( $table === null ? '' : $table . '.' );
206
207 switch( $show )
208 {
209 case eZOrder::SHOW_NORMAL : return $table."is_archived = '0'"; break;
210 case eZOrder::SHOW_ARCHIVED : return $table."is_archived = '1'"; break;
211 case eZOrder::SHOW_ALL :
212 default : return $table."is_archived IN (0, 1)"; break;
213 }
214 }
215
216
220 static function active( $asObject = true, $offset = 0, $limit = 100000, $sortField = "created", $sortOrder = "asc", $show = eZOrder::SHOW_NORMAL )
221 {
222 if ( $sortField == "user_name" )
223 {
224 $db = eZDB::instance();
225
226 $db_params = array();
227 $db_params["offset"] =(int) $offset;
228 $db_params["limit"] =(int) $limit;
229 $sortOrder = $db->escapeString( $sortOrder );
230
231 $query = "SELECT ezorder.*
232 FROM
233 ezorder,
234 ezcontentobject
235 WHERE
236 ".eZOrder::getShowOrdersQuery( $show, "ezorder" )." AND
237 ezorder.is_temporary = '0' AND
238 ezcontentobject.id = ezorder.user_id
239 ORDER BY ezcontentobject.name $sortOrder";
240 $orderArray = $db->arrayQuery( $query, $db_params );
241 if ( $asObject )
242 {
243 $retOrders = array();
244 foreach ( $orderArray as $order )
245 {
246 $order = new eZOrder( $order );
247 $retOrders[] = $order;
248 }
249 return $retOrders;
250 }
251 else
252 {
253 return $orderArray;
254 }
255 }
256 else
257 {
258 $where['is_temporary'] = 0;
259 if ( $show != eZOrder::SHOW_ALL )
260 {
261 $where['is_archived'] = $show;
262 }
263
264 return eZPersistentObject::fetchObjectList( eZOrder::definition(),
265 null,
266 $where ,
267 array( $sortField => $sortOrder ),
268 array( 'offset' => $offset,
269 'length' => $limit ), $asObject );
270 }
271 }
272
276 static function activeCount( $show = eZOrder::SHOW_NORMAL )
277 {
278 $db = eZDB::instance();
279
280 $query = 'SELECT count( * ) AS count FROM ezorder WHERE ' . eZOrder::getShowOrdersQuery( $show ) . ' AND is_temporary=\'0\'';
281 $countArray = $db->arrayQuery( $query );
282 return isset( $countArray[0]['count'] ) ? $countArray[0]['count'] : 0;
283 }
284
289 static function orderStatistics( $year = false, $month = false )
290 {
291 if ( $year == false )
292 {
293 $startDate = 0;
294 $stopDate = mktime( 0, 0, 0, 12, 31, 2037 );
295 }
296 else if ( $year != false and $month == false )
297 {
298 $startDate = mktime( 0, 0, 0, 1, 1, $year );
299 $stopDate = mktime( 0, 0, 0, 1, 1, $year + 1 );
300 }
301 else if ( $year != false and $month != false )
302 {
303 $startDate = mktime( 0, 0, 0, $month, 1, $year );
304 $stopDate = mktime( 23, 59, 59, $month + 1, 0, $year );
305 }
306
307 $db = eZDB::instance();
308 $productArray = $db->arrayQuery( "SELECT ezproductcollection_item.*, ignore_vat, ezorder.created, currency_code FROM ezorder, ezproductcollection_item, ezproductcollection
309 WHERE ezproductcollection.id=ezproductcollection_item.productcollection_id
310 AND ezproductcollection_item.productcollection_id=ezorder.productcollection_id
311 AND is_temporary='0'
312 AND ezorder.created >= '$startDate' AND ezorder.created < '$stopDate'
313 ORDER BY contentobject_id, currency_code" );
314 $currentContentObjectID = 0;
315 $productItemArray = array();
316 $itemCount = 0;
317 $name = false;
318 $productInfo = array();
319 $totalSumInfo = array();
320 $firstPass = true;
321 // Hash of ContentObject ID, the value will be replaced by the correct object once all IDs are known.
322 $contentObjectIDHash = array();
323 foreach( $productArray as $productItem )
324 {
325 $itemCount++;
326 $contentObjectID = $productItem['contentobject_id'];
327
328 if ( $firstPass )
329 {
330 $contentObjectIDHash[$currentContentObjectID] = true;
331 $currentContentObjectID = $contentObjectID;
332 $firstPass = false;
333 }
334
335 if ( $currentContentObjectID != $contentObjectID && $itemCount != 1 )
336 {
337 $productItemArray[] = array(
338 'name' => $name,
339 // Reference to the entry that will contain the ContentObject at the end
340 'product' => &$contentObjectIDHash[$currentContentObjectID],
341 'product_info' => $productInfo
342 );
343 $productInfo = array();
344 $name = $productItem['name'];
345 $currentContentObjectID = $contentObjectID;
346 $contentObjectIDHash[$currentContentObjectID] = true;
347 }
348
349 $currencyCode = $productItem['currency_code'];
350 if ( $currencyCode == '' )
351 {
352 $currencyCode = eZOrder::fetchLocaleCurrencyCode();
353 }
354
355 if ( !isset( $productInfo[$currencyCode] ) )
356 {
357 $productInfo[$currencyCode] = array( 'sum_count' => 0,
358 'sum_ex_vat' => 0,
359 'sum_inc_vat' => 0 );
360 }
361 if ( !isset( $totalSumInfo[$currencyCode] ) )
362 {
363 $totalSumInfo[$currencyCode] = array( 'sum_ex_vat' => 0,
364 'sum_inc_vat' => 0 );
365 }
366
367 if ( $productItem['ignore_vat']== true )
368 {
369 $vatValue = 0;
370 }
371 else
372 {
373 $vatValue = $productItem['vat_value'];
374 }
375
376 $price = $productItem['price'];
377
378 if ( $productItem['is_vat_inc'] )
379 {
380 $priceExVAT = $price / ( 100 + $vatValue ) * 100;
381 $priceIncVAT = $price;
382
383 }
384 else
385 {
386 $priceExVAT = $price;
387 $priceIncVAT = $price * ( 100 + $vatValue ) / 100;
388 }
389
390 $count = $productItem['item_count'];
391 $realPricePercent = ( 100 - $productItem['discount'] ) / 100;
392 $totalPriceExVAT = round( $count * $priceExVAT * $realPricePercent, 2 );
393 $totalPriceIncVAT = round( $count * $priceIncVAT * $realPricePercent, 2 );
394 $totalSumInfo[$currencyCode]['sum_ex_vat'] += $totalPriceExVAT;
395 $totalSumInfo[$currencyCode]['sum_inc_vat'] += $totalPriceIncVAT;
396
397 $productInfo[$currencyCode]['sum_count'] += $count;
398 $productInfo[$currencyCode]['sum_ex_vat'] += $totalPriceExVAT;
399 $productInfo[$currencyCode]['sum_inc_vat'] += $totalPriceIncVAT;
400 }
401
402 // add last product info
403 if ( !empty( $productArray ) )
404 {
405 $productItemArray[] = array(
406 'name' => $name,
407 // Reference to the entry that will contain the ContentObject at the end
408 'product' => &$contentObjectIDHash[$currentContentObjectID],
409 'product_info' => $productInfo
410 );
411
412 // Fetching all ContentObject ids in one query, filling the hash with the corresponding ContentObject
413 foreach ( eZContentObject::fetchList( true, array( "id" => array( array_keys( $contentObjectIDHash ) ) ) ) as $contentObject )
414 {
415 $contentObjectIDHash[$contentObject->ID] = $contentObject;
416 }
417 }
418
419 return array(
420 array(
421 'product_list' => $productItemArray,
422 'total_sum_info' => $totalSumInfo
423 )
424 );
425 }
426
430 static function orderList( $CustomID, $Email )
431 {
432 $db = eZDB::instance();
433 $CustomID =(int) $CustomID;
434 $Email = $db->escapeString( $Email );
435 if ( $Email == false )
436 {
437 $orderArray = $db->arrayQuery( "SELECT ezorder.* FROM ezorder
438 WHERE user_id='$CustomID'
439 AND is_archived='0'
440 AND is_temporary='0'
441 ORDER BY order_nr" );
442 }
443 else
444 {
445 $orderArray = $db->arrayQuery( "SELECT ezorder.* FROM ezorder
446 WHERE user_id='$CustomID'
447 AND is_archived='0'
448 AND is_temporary='0'
449 AND email='$Email'
450 ORDER BY order_nr" );
451 }
452 $retOrders = array();
453 foreach( $orderArray as $orderRows )
454 {
455 $retOrders[] = new eZOrder( $orderRows );
456 }
457 return $retOrders;
458 }
459
463 static function productList( $CustomID, $Email )
464 {
465 $db = eZDB::instance();
466 $CustomID =(int) $CustomID;
467 $Email = $db->escapeString( $Email );
468 if ( $Email == false )
469 {
470 $productArray = $db->arrayQuery( "SELECT ezproductcollection_item.*, ignore_vat, currency_code FROM ezorder, ezproductcollection_item, ezproductcollection
471 WHERE ezproductcollection.id=ezproductcollection_item.productcollection_id
472 AND ezproductcollection_item.productcollection_id=ezorder.productcollection_id
473 AND user_id='$CustomID'
474 AND is_archived='0'
475 AND is_temporary='0'
476 ORDER BY contentobject_id, currency_code" );
477 }
478 else
479 {
480 $productArray = $db->arrayQuery( "SELECT ezproductcollection_item.*, ignore_vat, currency_code FROM ezorder, ezproductcollection_item, ezproductcollection
481 WHERE ezproductcollection.id=ezproductcollection_item.productcollection_id
482 AND ezproductcollection_item.productcollection_id=ezorder.productcollection_id
483 AND user_id='$CustomID'
484 AND is_archived='0'
485 AND is_temporary='0'
486 AND email='$Email'
487 ORDER BY contentobject_id, currency_code" );
488 }
489 $currentContentObjectID = 0;
490 $productItemArray = array();
491 $productObject = null;
492 $itemCount = 0;
493 $name = false;
494 $productInfo = array();
495
496 foreach( $productArray as $productItem )
497 {
498 $itemCount++;
499 $contentObjectID = $productItem['contentobject_id'];
500 if ( $productObject == null )
501 {
502 if ( $contentObjectID != 0 )
503 {
504 $productObject = eZContentObject::fetch( $contentObjectID );
505 }
506 else
507 {
508 $productObject = null;
509 $name = $productItem['name'];
510 }
511 $currentContentObjectID = $contentObjectID;
512 }
513 if ( $currentContentObjectID != $contentObjectID && $itemCount != 1 )
514 {
515 $productItemArray[] = array( 'name' => $name,
516 'product' => $productObject,
517 'product_info' => $productInfo );
518 unset( $productObject );
519 $productInfo = array();
520 $name = $productItem['name'];
521 $currentContentObjectID = $contentObjectID;
522 if ( $contentObjectID != 0 )
523 {
524 $productObject = eZContentObject::fetch( $currentContentObjectID );
525 }
526 else
527 {
528 $productObject = null;
529 }
530 }
531
532 $currencyCode = $productItem['currency_code'];
533 if ( $currencyCode == '' )
534 {
535 $currencyCode = eZOrder::fetchLocaleCurrencyCode();
536 }
537
538 if ( !isset( $productInfo[$currencyCode] ) )
539 {
540 $productInfo[$currencyCode] = array( 'sum_count' => 0,
541 'sum_ex_vat' => 0,
542 'sum_inc_vat' => 0 );
543 }
544
545 if ( $productItem['ignore_vat'] == true )
546 {
547 $vatValue = 0;
548 }
549 else
550 {
551 $vatValue = $productItem['vat_value'];
552 }
553
554 $price = $productItem['price'];
555
556 if ( $productItem['is_vat_inc'] )
557 {
558 $priceExVAT = $price / ( 100 + $vatValue ) * 100;
559 $priceIncVAT = $price;
560 }
561 else
562 {
563 $priceExVAT = $price;
564 $priceIncVAT = $price * ( 100 + $vatValue ) / 100;
565 }
566
567 $count = $productItem['item_count'];
568 $realPricePercent = ( 100 - $productItem['discount'] ) / 100;
569
570 $productInfo[$currencyCode]['sum_count'] += $count;
571 $productInfo[$currencyCode]['sum_ex_vat'] += round( $count * $priceExVAT * $realPricePercent, 2 );
572 $productInfo[$currencyCode]['sum_inc_vat'] += round( $count * $priceIncVAT * $realPricePercent, 2 );
573 }
574 if ( count( $productArray ) != 0 )
575 {
576 $productItemArray[] = array( 'name' => $name,
577 'product' => $productObject,
578 'product_info' => $productInfo );
579 }
580 return $productItemArray;
581 }
582
586 static function customerCount( )
587 {
588 $db = eZDB::instance();
589 $countArray = $db->arrayQuery( "SELECT count( DISTINCT email) AS count FROM ezorder WHERE is_temporary='0'" );
590 return $countArray[0]['count'];
591 }
592
596 static function customerList( $offset, $limit )
597 {
598 $db = eZDB::instance();
599
600 $db_params = array();
601 $db_params["offset"] =(int) $offset;
602 $db_params["limit"] =(int) $limit;
603
604 $customEmailResult = $db->arrayQuery( "SELECT DISTINCT email FROM ezorder WHERE is_temporary='0' ORDER BY email", $db_params );
605 $customEmailArray = array();
606
607 foreach( $customEmailResult as $customEmailRow )
608 {
609 $customEmail = $customEmailRow['email'];
610 $customEmailArray[] = "'" . $customEmail . "'";
611 }
612
613 $emailString = implode( ", ", $customEmailArray );
614 if ( !strlen( $emailString ) )
615 {
616 $emailString = "''";
617 }
618
619 $productItemArray = $db->arrayQuery( "SELECT ezorder.id as order_id, user_id, email, ignore_vat, currency_code, ezproductcollection_item.*
620 FROM ezorder, ezproductcollection_item, ezproductcollection
621 WHERE ezproductcollection_item.productcollection_id=ezorder.productcollection_id
622 AND is_temporary='0'
623 AND ezproductcollection_item.productcollection_id=ezproductcollection.id
624 AND email in ( $emailString )
625 ORDER BY user_id, email, order_id" );
626
627
628 $siteIni = eZINI::instance();
629 $anonymousUserID = $siteIni->variable( 'UserSettings', 'AnonymousUserID' );
630
631 $currentUserID = 0;
632 $currentOrderID = 0;
633 $currentUserEmail = "";
634 $customArray = array();
635 $accountName = null;
636 $itemCount = 0;
637 $hash = 0;
638 $currencyCode = '';
639 $ordersInfo = array();
640
641 foreach( $productItemArray as $productItem )
642 {
643 $itemCount++;
644 $currencyCode = $productItem['currency_code'];
645 if ( $currencyCode == '' )
646 {
647 $currencyCode = eZOrder::fetchLocaleCurrencyCode();
648 }
649
650 $userID = $productItem['user_id'];
651 $orderID = $productItem['order_id'];
652 $order = eZOrder::fetch( $orderID );
653
654 if ( $currentUserID != $userID && $itemCount != 1 )
655 {
656 $customArray[] = array( 'account_name' => $accountName,
657 'orders_info' => $ordersInfo,
658 'user_id' => $currentUserID,
659 'email' => urlencode( $currentUserEmail ) );
660
661 $ordersInfo = array();
662 $accountName = $order->attribute( 'account_name' );
663 $accountEmail = $order->attribute( 'account_email' );
664 }
665
666 $currentUserID = $userID;
667
668 // If the custom is anoymous user
669 if ( $currentUserID == $anonymousUserID )
670 {
671 $accountEmail = $order->attribute( 'email' );
672 if ( $currentUserEmail == "" )
673 {
674 $accountName = $order->attribute( 'account_name' );
675 $currentUserEmail = $accountEmail;
676 }
677
678 if ( $currentUserEmail != $accountEmail )
679 {
680 $customArray[] = array( 'account_name' => $accountName,
681 'orders_info' => $ordersInfo,
682 'user_id' => $currentUserID,
683 'email' => urlencode( $currentUserEmail ) );
684
685 $ordersInfo = array();
686 $accountName = $order->attribute( 'account_name' );
687 $accountEmail = $order->attribute( 'account_email' );
688 $currentUserEmail = $accountEmail;
689 }
690 $currentUserEmail = $accountEmail;
691 }
692 else
693 {
694 $currentUserEmail = 0;
695 }
696
697 $accountName = $order->attribute( 'account_name' );
698
699 if ( !isset( $ordersInfo[$currencyCode] ) )
700 {
701 $ordersInfo[$currencyCode] = array( 'order_count' => 0,
702 'sum_ex_vat' => 0,
703 'sum_inc_vat' => 0 );
704 }
705
706 if ( $currentOrderID != $orderID )
707 {
708 $ordersInfo[$currencyCode]['order_count']++;
709 }
710 $currentOrderID = $orderID;
711
712 if ( $productItem['ignore_vat'] == true )
713 {
714 $vatValue = 0;
715 }
716 else
717 {
718 $vatValue = $productItem['vat_value'];
719 }
720
721 $price = $productItem['price'];
722
723 if ( $productItem['is_vat_inc'] )
724 {
725 $priceExVAT = $price / ( 100 + $vatValue ) * 100;
726 $priceIncVAT = $price;
727 }
728 else
729 {
730 $priceExVAT = $price;
731 $priceIncVAT = $price * ( 100 + $vatValue ) / 100;
732 }
733
734 $count = $productItem['item_count'];
735 $realPricePercent = ( 100 - $productItem['discount'] ) / 100;
736 $ordersInfo[$currencyCode]['sum_ex_vat'] += round( $count * $priceExVAT * $realPricePercent, 2 );
737 $ordersInfo[$currencyCode]['sum_inc_vat'] += round( $count * $priceIncVAT * $realPricePercent, 2 );
738 }
739 if ( count( $productItemArray ) != 0 )
740 $customArray[] = array( 'account_name' => $accountName,
741 'orders_info' => $ordersInfo,
742 'user_id' => $currentUserID,
743 'email' => urlencode( $currentUserEmail ) );
744 return $customArray;
745 }
746
750 static function discount( $userID, $object )
751 {
752 return eZDiscount::discountPercent(
753 eZUser::fetch( $userID ),
754 array(
755 'contentclass_id' => $object->attribute( 'contentclass_id'),
756 'contentobject_id' => $object->attribute( 'id' ),
757 'section_id' => $object->attribute( 'section_id')
758 )
759 );
760 }
761
768 function productItems( $asObject = true, ?array $sorts = null )
769 {
770 $productItems = eZPersistentObject::fetchObjectList( eZProductCollectionItem::definition(),
771 null,
772 array( 'productcollection_id' => $this->ProductCollectionID ),
773 $sorts,
774 null,
775 $asObject );
776
777 $addedProducts = array();
778 foreach ( $productItems as $productItem )
779 {
780 $contentObject = $productItem->attribute( 'contentobject' );
781
782 if ( $this->IgnoreVAT == true )
783 {
784 $vatValue = 0;
785 }
786 else
787 {
788 $vatValue = $productItem->attribute( 'vat_value' );
789 }
790 if ( $contentObject )
791 {
792 $nodeID = $contentObject->attribute( 'main_node_id' );
793 $objectName = $contentObject->attribute( 'name' );
794 }
795 else
796 {
797 $nodeID = false;
798 $objectName = $productItem->attribute( 'name' );
799 }
800
801 $price = $productItem->attribute( 'price' );
802
803 if ( $productItem->attribute( 'is_vat_inc' ) )
804 {
805 $priceExVAT = $price / ( 100 + $vatValue ) * 100;
806 $priceIncVAT = $price;
807 }
808 else
809 {
810 $priceExVAT = $price;
811 $priceIncVAT = $price * ( 100 + $vatValue ) / 100;
812 }
813
814 $count = $productItem->attribute( 'item_count' );
815 $discountPercent = $productItem->attribute( 'discount' );
816 $realPricePercent = ( 100 - $discountPercent ) / 100;
817 $addedProducts[] = array( "id" => $productItem->attribute( 'id' ),
818 "vat_value" => $vatValue,
819 "item_count" => $count,
820 "node_id" => $nodeID,
821 "object_name" => $objectName,
822 "price_ex_vat" => $priceExVAT,
823 "price_inc_vat" => $priceIncVAT,
824 "discount_percent" => $discountPercent,
825 "total_price_ex_vat" => round( $count * $priceExVAT * $realPricePercent, 2 ),
826 "total_price_inc_vat" => round( $count * $priceIncVAT * $realPricePercent, 2 ),
827 'item_object' => $productItem );
828 }
829 return $addedProducts;
830 }
831
838 function productItemsOrdered( $asObject = true, $order = true )
839 {
840 return $this->productItems( $asObject, array( 'id' => ( $order ? 'asc' : 'desc' )) );
841 }
842
843 function productTotalIncVAT()
844 {
845 $items = $this->productItems();
846
847 $total = 0.0;
848 foreach ( $items as $item )
849 {
850 $total += $item['total_price_inc_vat'];
851 }
852 return round( $total, 2 );
853 }
854
855 function productTotalExVAT()
856 {
857 $items = $this->productItems();
858
859 $total = 0.0;
860 foreach ( $items as $item )
861 {
862 $total += $item['total_price_ex_vat'];
863 }
864 return round( $total, 2 );
865 }
866
867 function orderTotalIncVAT()
868 {
869 $items = $this->orderItems();
870
871 $total = 0.0;
872 if ( count( $items ) > 0 )
873 {
874 foreach ( $items as $item )
875 {
876 $total += $item->attribute( 'price_inc_vat' );
877 }
878 }
879 return round( $total, 2 );
880 }
881
882 function orderTotalExVAT()
883 {
884 $items = $this->orderItems();
885
886 $total = 0.0;
887 if ( count( $items ) > 0 )
888 {
889 foreach ( $items as $item )
890 {
891 $total += $item->attribute( 'price_ex_vat' );
892 }
893 }
894 return round( $total, 2 );
895 }
896
897 function totalIncVAT()
898 {
899 return $this->productTotalIncVAT() + $this->orderTotalIncVAT();
900 }
901
902 function totalExVAT()
903 {
904 return $this->productTotalExVAT() + $this->orderTotalExVAT();
905 }
906
918 function purge( $removeCollection = true )
919 {
920 $db = eZDB::instance();
921 $db->begin();
922 if ( $removeCollection )
923 $this->removeCollection();
924 $this->removeHistory();
925 $this->removeOrderItems();
926 $this->remove();
927 $db->commit();
928 }
929
935 function removeCollection()
936 {
937 $collection = eZProductCollection::fetch( $this->attribute( 'productcollection_id' ) );
938 if ( $collection !== null )
939 $collection->remove();
940 }
941
946 function removeHistory()
947 {
948 $db = eZDB::instance();
949 $orderID = (int)$this->OrderNr;
950 $db->query( "DELETE FROM ezorder_status_history WHERE order_id=$orderID" );
951 }
952
953 function removeOrderItems()
954 {
955 $db = eZDB::instance();
956 $orderID = (int) $this->ID;
957 $db->query( "DELETE FROM ezorder_item WHERE order_id=$orderID" );
958 }
959
965 static function removeItem( $itemID )
966 {
967 $item = eZProductCollectionItem::fetch( $itemID );
968 if ( $item !== null )
969 $item->remove();
970 }
971
975 function totalVAT()
976 {
977 return false;
978 }
979
980 function orderItems()
981 {
982 $id = $this->attribute( 'id' );
983 return eZOrderItem::fetchList( $id );
984 }
985
989 function orderItemsByType( $itemType )
990 {
991 return eZOrderItem::fetchListByType( $this->ID, $itemType );
992 }
993
997 function user()
998 {
999 return eZUser::fetch( $this->UserID );
1000 }
1001
1006 function accountInformation()
1007 {
1008 // Fetch the shop account handler
1009 $accountHandler = eZShopAccountHandler::instance();
1010 return $accountHandler->accountInformation( $this );
1011 }
1012
1013
1018 function accountName()
1019 {
1020 // Fetch the shop account handler
1021 $accountHandler = eZShopAccountHandler::instance();
1022
1023 return $accountHandler->accountName( $this );
1024 }
1025
1030 function accountEmail()
1031 {
1032 // Fetch the shop account handler
1033 $accountHandler = eZShopAccountHandler::instance();
1034
1035 return $accountHandler->email( $this );
1036 }
1037
1041 function status( $asObject = false )
1042 {
1043 if ( $asObject )
1044 return eZOrderStatus::fetch( $this->StatusID );
1045 else
1046 return $this->StatusID;
1047 }
1048
1052 function canModifyStatus( $statusID, $user = false )
1053 {
1054 if ( $user === false )
1055 $user = eZUser::currentUser();
1056 else if ( is_numeric( $user ) )
1057 $user = eZUser::fetch( $user );
1058
1059 if ( !is_object( $user ) )
1060 {
1061 eZDebug::writeError( "Cannot check status access without a user", __METHOD__ );
1062 return false;
1063 }
1064
1065 $accessResult = $user->hasAccessTo( 'shop' , 'setstatus' );
1066 $accessWord = $accessResult['accessWord'];
1067 $access = false;
1068
1069 $currentStatusID = $this->attribute( "status_id" );
1070
1071 if ( $accessWord == 'yes' )
1072 $access = true;
1073
1074 if ( $accessWord == 'limited' )
1075 {
1076 $limitationList = $accessResult['policies'];
1077 $access = true;
1078 foreach ( $limitationList as $pid => $limit )
1079 {
1080 $access = true;
1081 foreach ( $limit as $name => $value )
1082 {
1083 if ( $name == 'FromStatus' )
1084 {
1085 if ( !in_array( $currentStatusID, $value ) )
1086 $access = false;
1087 }
1088 if ( $name == 'ToStatus' )
1089 {
1090 if ( !in_array( $statusID, $value ) )
1091 $access = false;
1092 }
1093 if ( !$access )
1094 break;
1095 }
1096 if ( $access )
1097 break;
1098 }
1099 }
1100 return $access;
1101 }
1102
1108 function statusModificationList( $user = false )
1109 {
1110 if ( $user === false )
1111 $user = eZUser::currentUser();
1112 else if ( is_numeric( $user ) )
1113 $user = eZUser::fetch( $user );
1114
1115 if ( !is_object( $user ) )
1116 {
1117 eZDebug::writeError( "Cannot calculate status access list without a user", __METHOD__ );
1118 return false;
1119 }
1120
1121 $accessResult = $user->hasAccessTo( 'shop' , 'setstatus' );
1122 $accessWord = $accessResult['accessWord'];
1123 $access = false;
1124
1125 $currentStatusID = $this->attribute( "status_id" );
1126
1127 $statusList = array();
1128 if ( $accessWord == 'yes' )
1129 {
1130 // We have full access so we return all of them
1131 $statusList = eZOrderStatus::fetchOrderedList( true, false );
1132 return $statusList;
1133 }
1134
1135 if ( $accessWord == 'limited' )
1136 {
1137 $limitationList = $accessResult['policies'];
1138 $access = true;
1139 // All 'to' statues will be appended to this array
1140 $accessList = array();
1141 foreach ( $limitationList as $pid => $limit )
1142 {
1143 $access = true;
1144 foreach ( $limit as $name => $value )
1145 {
1146 if ( $name == 'FromStatus' )
1147 {
1148 if ( !in_array( $currentStatusID, $value ) )
1149 $access = false;
1150 }
1151 if ( !$access )
1152 break;
1153 }
1154 if ( $access )
1155 {
1156 if ( isset( $limit['ToStatus'] ) )
1157 {
1158 $accessList = array_merge( $accessList, $limit['ToStatus'] );
1159 }
1160 else
1161 {
1162 // We have full access for the current status so we return all of them
1163 $statusList = eZOrderStatus::fetchOrderedList( true, false );
1164 return $statusList;
1165 }
1166 }
1167 }
1168 if ( count( $accessList ) > 0 )
1169 {
1170 $accessList = array_unique( array_merge( $accessList, array( $currentStatusID ) ) );
1171 $statuses = eZOrderStatus::fetchOrderedList( true, false );
1172 foreach ( $statuses as $status )
1173 {
1174 if ( in_array( $status->attribute( 'status_id' ), $accessList ) )
1175 $statusList[] = $status;
1176 }
1177 }
1178 }
1179 return $statusList;
1180 }
1181
1191 function modifyStatus( $statusID, $userID = false )
1192 {
1193 $db = eZDB::instance();
1194 $db->begin();
1195
1196 $time = time();
1197 if ( $userID === false )
1198 $userID = eZUser::currentUserID();
1199
1200 $history = eZOrderStatusHistory::create( $this->OrderNr, $statusID, $userID, $time );
1201 $history->store();
1202
1203 $this->StatusID = $statusID;
1204 $this->StatusModified = $time;
1205 $this->StatusModifierID = $userID;
1206
1207 $this->store();
1208
1209 $db->commit();
1210 }
1211
1219 function createStatusHistory()
1220 {
1221 $history = eZOrderStatusHistory::create( $this->OrderNr, // Note: Use the order nr, not id
1222 $this->StatusID,
1223 $this->StatusModifierID,
1224 $this->StatusModified );
1225 $history->store();
1226 return $history;
1227 }
1228
1233 function setStatus( $status )
1234 {
1235 if ( $status instanceof eZOrderStatus )
1236 $this->StatusID = $status->attribute( 'id' );
1237 else
1238 $this->StatusID = $status;
1239 $this->setStatusModified( time() );
1240 }
1241
1245 function setStatusModified( $timestamp )
1246 {
1247 $this->StatusModified = $timestamp;
1248 }
1249
1255 function statusName()
1256 {
1257 if ( $this->Status === null )
1258 {
1259 $this->Status = eZOrderStatus::fetchByStatus( $this->StatusID );
1260 }
1261 return $this->Status->attribute( 'name' );
1262 }
1263
1269 function statusObject()
1270 {
1271 if ( $this->Status === null )
1272 {
1273 $this->Status = eZOrderStatus::fetchByStatus( $this->StatusID );
1274 }
1275 return $this->Status;
1276 }
1277
1300 function activate()
1301 {
1302 if( $this->attribute( 'is_temporary' ) )
1303 {
1304 $this->setAttribute( 'is_temporary', 0 );
1305
1306 $nextID = $this->getNewID();
1307 $this->setAttribute( 'order_nr', $nextID );
1308 $this->store();
1309
1310 // Create an order status history element that matches the current status
1311 $this->createStatusHistory();
1312 }
1313 }
1314
1320 function getNewID()
1321 {
1322 $db = eZDB::instance();
1323 if( $db->supportsDefaultValuesInsertion() )
1324 {
1325 $db->query( 'INSERT INTO ezorder_nr_incr DEFAULT VALUES' );
1326 }
1327 else
1328 {
1329 $db->query( 'INSERT INTO ezorder_nr_incr(id) VALUES(DEFAULT)' );
1330 }
1331
1332 return $db->lastSerialID( 'ezorder_nr_incr', 'id' );
1333 }
1334
1338 function accountViewTemplate()
1339 {
1340 return $this->AccountIdentifier;
1341 }
1342
1349 static function cleanupOrder( $orderID )
1350 {
1351 $db = eZDB::instance();
1352 $orderID =(int) $orderID;
1353 $rows = $db->arrayQuery( "SELECT productcollection_id, order_nr FROM ezorder WHERE id='$orderID'" );
1354 if ( count( $rows ) > 0 )
1355 {
1356 // Who deletes which order in shop should be logged.
1357 eZAudit::writeAudit( 'order-delete', array( 'Order ID' => $orderID,
1358 'Comment' => 'Removed the order and its related data from the database: eZOrder::cleanupOrder()' ) );
1359
1360 $productCollectionID = $rows[0]['productcollection_id'];
1361 $orderNr = (int)$rows[0]['order_nr'];
1362 $db = eZDB::instance();
1363 $db->begin();
1364 $db->query( "DELETE FROM ezorder where id='$orderID'" );
1365 $db->query( "DELETE FROM ezproductcollection where id='$productCollectionID'" );
1366 $db->query( "DELETE FROM ezproductcollection_item where productcollection_id='$productCollectionID'" );
1367 $db->query( "DELETE FROM ezorder_status_history WHERE order_id=$orderNr" );
1368 $db->commit();
1369 }
1370 }
1371
1378 static function archiveOrder( $orderID )
1379 {
1380 $db = eZDB::instance();
1381 $orderID =(int) $orderID;
1382 $db->query( "UPDATE ezorder SET is_archived='1' WHERE id='$orderID' " );
1383 }
1384
1391 static function unArchiveOrder( $orderID )
1392 {
1393 $db = eZDB::instance();
1394 $orderID =(int) $orderID;
1395 $db->query( "UPDATE ezorder SET is_archived='0' WHERE id='$orderID' " );
1396 }
1397
1404 static function cleanup()
1405 {
1406 $db = eZDB::instance();
1407 $rows = $db->arrayQuery( "SELECT productcollection_id FROM ezorder" );
1408
1409 $db = eZDB::instance();
1410 $db->begin();
1411 if ( count( $rows ) > 0 )
1412 {
1413 $productCollectionIDList = array();
1414 foreach ( $rows as $row )
1415 {
1416 $productCollectionIDList[] = $row['productcollection_id'];
1417 }
1418 eZProductCollection::cleanupList( $productCollectionIDList );
1419 }
1420 // Who deletes which order in shop should be logged.
1421 eZAudit::writeAudit( 'order-delete', array( 'Comment' => 'Removed all orders from the database: eZOrder::cleanup()' ) );
1422
1423 eZOrderItem::cleanup();
1424 $db->query( "DELETE FROM ezorder_status_history" );
1425 $db->query( "DELETE FROM ezorder" );
1426 $db->commit();
1427 }
1428
1429 function orderInfo()
1430 {
1431 $returnArray = array();
1432
1433 $items = $this->productItems();
1434 foreach ( $items as $item )
1435 {
1436 $totalPriceExVat = $item['total_price_ex_vat'];
1437 $totalPriceIncVat = $item['total_price_inc_vat'];
1438 $totalPriceVat = $totalPriceIncVat - $totalPriceExVat;
1439 $vatValue = $item['vat_value'];
1440 if ( !isset( $returnArray['price_info']['items'][$vatValue]['total_price_ex_vat'] ) )
1441 {
1442 $returnArray['price_info']['items'][$vatValue]['total_price_ex_vat'] = $totalPriceExVat;
1443 $returnArray['price_info']['items'][$vatValue]['total_price_inc_vat'] = $totalPriceIncVat;
1444 $returnArray['price_info']['items'][$vatValue]['total_price_vat'] = $totalPriceVat;
1445 }
1446 else
1447 {
1448 $returnArray['price_info']['items'][$vatValue]['total_price_ex_vat'] += $totalPriceExVat;
1449 $returnArray['price_info']['items'][$vatValue]['total_price_inc_vat'] += $totalPriceIncVat;
1450 $returnArray['price_info']['items'][$vatValue]['total_price_vat'] += $totalPriceVat;
1451 }
1452
1453 if ( !isset( $returnArray['total_price_info']['total_price_ex_vat'] ) )
1454 {
1455 $returnArray['total_price_info']['total_price_ex_vat'] = $totalPriceExVat;
1456 $returnArray['total_price_info']['total_price_inc_vat'] = $totalPriceIncVat;
1457 $returnArray['total_price_info']['total_price_vat'] = $totalPriceVat;
1458 }
1459 else
1460 {
1461 $returnArray['total_price_info']['total_price_ex_vat'] += $totalPriceExVat;
1462 $returnArray['total_price_info']['total_price_inc_vat'] += $totalPriceIncVat;
1463 $returnArray['total_price_info']['total_price_vat'] += $totalPriceVat;
1464 }
1465 }
1466
1467 $orderItems = $this->orderItems();
1468 if ( count( $orderItems ) > 0 )
1469 {
1470 foreach ( $orderItems as $orderItem )
1471 {
1472 $totalPriceExVat = $orderItem->attribute( 'price_ex_vat' );
1473 $totalPriceIncVat = $orderItem->attribute( 'price_inc_vat' );
1474 $totalPriceVat = $totalPriceIncVat - $totalPriceExVat;
1475 $vatValue = $orderItem->attribute( 'vat_value' );
1476 $type = $orderItem->attribute( 'type' );
1477
1478 if ( !isset( $returnArray['price_info']['items'][$vatValue]['total_price_ex_vat'] ) )
1479 {
1480 $returnArray['price_info']['items'][$vatValue]['total_price_ex_vat'] = $totalPriceExVat;
1481 $returnArray['price_info']['items'][$vatValue]['total_price_inc_vat'] = $totalPriceIncVat;
1482 $returnArray['price_info']['items'][$vatValue]['total_price_vat'] = $totalPriceVat;
1483 }
1484 else
1485 {
1486 $returnArray['price_info']['items'][$vatValue]['total_price_ex_vat'] += $totalPriceExVat;
1487 $returnArray['price_info']['items'][$vatValue]['total_price_inc_vat'] += $totalPriceIncVat;
1488 $returnArray['price_info']['items'][$vatValue]['total_price_vat'] += $totalPriceVat;
1489 }
1490
1491 if ( !isset( $returnArray['total_price_info']['total_price_ex_vat'] ) )
1492 {
1493 $returnArray['total_price_info']['total_price_ex_vat'] = $totalPriceExVat;
1494 $returnArray['total_price_info']['total_price_inc_vat'] = $totalPriceIncVat;
1495 $returnArray['total_price_info']['total_price_vat'] = $totalPriceVat;
1496 }
1497 else
1498 {
1499 $returnArray['total_price_info']['total_price_ex_vat'] += $totalPriceExVat;
1500 $returnArray['total_price_info']['total_price_inc_vat'] += $totalPriceIncVat;
1501 $returnArray['total_price_info']['total_price_vat'] += $totalPriceVat;
1502 }
1503
1504 if ( !isset( $returnArray['additional_info'][$type]['items'][$vatValue]['total_price_ex_vat'] ) )
1505 {
1506 $returnArray['additional_info'][$type]['items'][$vatValue]['total_price_ex_vat'] = $totalPriceExVat;
1507 $returnArray['additional_info'][$type]['items'][$vatValue]['total_price_inc_vat'] = $totalPriceIncVat;
1508 $returnArray['additional_info'][$type]['items'][$vatValue]['total_price_vat'] = $totalPriceVat;
1509 }
1510 else
1511 {
1512 $returnArray['additional_info'][$type]['items'][$vatValue]['total_price_ex_vat'] += $totalPriceExVat;
1513 $returnArray['additional_info'][$type]['items'][$vatValue]['total_price_inc_vat'] += $totalPriceIncVat;
1514 $returnArray['additional_info'][$type]['items'][$vatValue]['total_price_vat'] += $totalPriceVat;
1515 }
1516
1517 if ( !isset( $returnArray['additional_info'][$type]['total']['total_price_ex_vat'] ) )
1518 {
1519 $returnArray['additional_info'][$type]['total']['total_price_ex_vat'] = $totalPriceExVat;
1520 $returnArray['additional_info'][$type]['total']['total_price_inc_vat'] = $totalPriceIncVat;
1521 $returnArray['additional_info'][$type]['total']['total_price_vat'] = $totalPriceVat;
1522 }
1523 else
1524 {
1525 $returnArray['additional_info'][$type]['total']['total_price_ex_vat'] += $totalPriceExVat;
1526 $returnArray['additional_info'][$type]['total']['total_price_inc_vat'] += $totalPriceIncVat;
1527 $returnArray['additional_info'][$type]['total']['total_price_vat'] += $totalPriceVat;
1528 }
1529
1530 }
1531
1532 // sort the array based on VAT.
1533 foreach ( array_keys( $returnArray['additional_info'] ) as $type )
1534 {
1535 ksort( $returnArray['additional_info'][$type]['items'] );
1536 }
1537 }
1538 else
1539 {
1540 $returnArray['additional_info'] = array();
1541 }
1542
1543 ksort( $returnArray['price_info']['items'] );
1544
1545 return $returnArray;
1546 }
1547
1556 function currencyCode( $collection = false )
1557 {
1558 if ( is_string( $collection ) and $collection != '' )
1559 {
1560 $currencyCode = $collection;
1561 }
1562 else
1563 {
1564 if ( ( $collection instanceof eZProductCollection ) === false )
1565 {
1566 $collection = eZProductCollection::fetch( $this->attribute( 'productcollection_id' ) );
1567 }
1568 $currencyCode = $collection->attribute( 'currency_code' );
1569 }
1570
1571 // Backwards compability for orders done with the price datatype.
1572 if ( $currencyCode == '' )
1573 {
1574 $currencyCode = eZOrder::fetchLocaleCurrencyCode();
1575 }
1576 return $currencyCode;
1577 }
1578
1583 static function fetchLocaleCurrencyCode()
1584 {
1585 $locale = eZLocale::instance();
1586 $currencyCode = $locale->currencyShortName();
1587 return $currencyCode;
1588 }
1589
1592 public $Status;
1593
1594 }
1595
1596 ?>
eZAudit\writeAudit
static writeAudit( $auditName, $auditAttributes=array())
Definition: ezaudit.php:51
eZContentObject\fetch
static fetch( $id, $asObject=true)
Definition: ezcontentobject.php:885
eZContentObject\fetchList
static fetchList( $asObject=true, $conditions=null, $offset=false, $limit=false)
Definition: ezcontentobject.php:1185
eZDB\instance
static instance( $databaseImplementation=false, $databaseParameters=false, $forceNewInstance=false)
Definition: ezdb.php:117
eZDebug\writeError
static writeError( $string, $label="", $backgroundClass="")
Definition: ezdebug.php:545
eZDiscount\discountPercent
static discountPercent( $user, $params)
Definition: ezdiscount.php:20
eZLocale\instance
static instance( $localeString=false)
Definition: ezlocale.php:1536
eZOrderItem\cleanup
cleanup()
Definition: ezorderitem.php:127
eZOrderItem\fetchList
static fetchList( $orderID, $asObject=true)
Definition: ezorderitem.php:71
eZOrderItem\fetchListByType
static fetchListByType( $orderID, $itemType, $asObject=true)
Definition: ezorderitem.php:81
eZOrderStatusHistory\create
static create( $orderID, $statusID, $userID=false, $timestamp=false)
Definition: ezorderstatushistory.php:181
eZOrderStatus
Handles statuses which can be used on orders.
Definition: ezorderstatus.php:47
eZOrderStatus\fetchOrderedList
static fetchOrderedList( $asObject=true, $showInactive=false)
Definition: ezorderstatus.php:219
eZOrderStatus\fetchByStatus
static fetchByStatus( $statusID, $asObject=true)
Definition: ezorderstatus.php:124
eZOrderStatus\fetch
static fetch( $id, $asObject=true)
Definition: ezorderstatus.php:111
eZOrder
eZOrder handles orders
Definition: ezorder.php:20
eZOrder\totalVAT
totalVAT()
Definition: ezorder.php:975
eZOrder\accountInformation
accountInformation()
Definition: ezorder.php:1006
eZOrder\detachProductCollection
detachProductCollection()
Definition: ezorder.php:144
eZOrder\user
user()
Definition: ezorder.php:997
eZOrder\activeByUserID
static activeByUserID( $userID, $asObject=true)
Definition: ezorder.php:193
eZOrder\$AccountIdentifier
$AccountIdentifier
Definition: ezorder.php:27
eZOrder\statusName
statusName()
Definition: ezorder.php:1255
eZOrder\cleanup
static cleanup()
Definition: ezorder.php:1404
eZOrder\$Status
$Status
Definition: ezorder.php:1592
eZOrder\SHOW_ARCHIVED
const SHOW_ARCHIVED
Definition: ezorder.php:29
eZOrder\currencyCode
currencyCode( $collection=false)
Definition: ezorder.php:1556
eZOrder\productItems
productItems( $asObject=true, ?array $sorts=null)
Definition: ezorder.php:768
eZOrder\customerCount
static customerCount()
Definition: ezorder.php:586
eZOrder\SHOW_ALL
const SHOW_ALL
Definition: ezorder.php:30
eZOrder\discount
static discount( $userID, $object)
Definition: ezorder.php:750
eZOrder\totalIncVAT
totalIncVAT()
Definition: ezorder.php:897
eZOrder\getNewID
getNewID()
Definition: ezorder.php:1320
eZOrder\orderItemsByType
orderItemsByType( $itemType)
Definition: ezorder.php:989
eZOrder\canModifyStatus
canModifyStatus( $statusID, $user=false)
Definition: ezorder.php:1052
eZOrder\setStatus
setStatus( $status)
Definition: ezorder.php:1233
eZOrder\archiveOrder
static archiveOrder( $orderID)
Definition: ezorder.php:1378
eZOrder\modifyStatus
modifyStatus( $statusID, $userID=false)
Definition: ezorder.php:1191
eZOrder\accountName
accountName()
Definition: ezorder.php:1018
eZOrder\removeHistory
removeHistory()
Definition: ezorder.php:946
eZOrder\accountViewTemplate
accountViewTemplate()
Definition: ezorder.php:1338
eZOrder\productTotalIncVAT
productTotalIncVAT()
Definition: ezorder.php:843
eZOrder\$ProductCollectionID
$ProductCollectionID
Definition: ezorder.php:21
eZOrder\orderStatistics
static orderStatistics( $year=false, $month=false)
Definition: ezorder.php:289
eZOrder\productCollection
productCollection()
Definition: ezorder.php:172
eZOrder\status
status( $asObject=false)
Definition: ezorder.php:1041
eZOrder\removeCollection
removeCollection()
Definition: ezorder.php:935
eZOrder\accountEmail
accountEmail()
Definition: ezorder.php:1030
eZOrder\active
static active( $asObject=true, $offset=0, $limit=100000, $sortField="created", $sortOrder="asc", $show=eZOrder::SHOW_NORMAL)
Definition: ezorder.php:220
eZOrder\activeCount
static activeCount( $show=eZOrder::SHOW_NORMAL)
Definition: ezorder.php:276
eZOrder\setStatusModified
setStatusModified( $timestamp)
Definition: ezorder.php:1245
eZOrder\orderTotalIncVAT
orderTotalIncVAT()
Definition: ezorder.php:867
eZOrder\orderItems
orderItems()
Definition: ezorder.php:980
eZOrder\removeOrderItems
removeOrderItems()
Definition: ezorder.php:953
eZOrder\$OrderNr
$OrderNr
Definition: ezorder.php:23
eZOrder\__construct
__construct( $row)
Definition: ezorder.php:32
eZOrder\$StatusID
$StatusID
Definition: ezorder.php:24
eZOrder\activate
activate()
Definition: ezorder.php:1300
eZOrder\purge
purge( $removeCollection=true)
Definition: ezorder.php:918
eZOrder\unArchiveOrder
static unArchiveOrder( $orderID)
Definition: ezorder.php:1391
eZOrder\orderList
static orderList( $CustomID, $Email)
Definition: ezorder.php:430
eZOrder\totalExVAT
totalExVAT()
Definition: ezorder.php:902
eZOrder\getShowOrdersQuery
static getShowOrdersQuery( $show, $table=null)
Definition: ezorder.php:203
eZOrder\$StatusModified
$StatusModified
Definition: ezorder.php:25
eZOrder\SHOW_NORMAL
const SHOW_NORMAL
Definition: ezorder.php:28
eZOrder\$IgnoreVAT
$IgnoreVAT
Definition: ezorder.php:22
eZOrder\fetchList
static fetchList( $asObject=true)
Definition: ezorder.php:185
eZOrder\cleanupOrder
static cleanupOrder( $orderID)
Definition: ezorder.php:1349
eZOrder\definition
static definition()
Definition: ezorder.php:38
eZOrder\customerList
static customerList( $offset, $limit)
Definition: ezorder.php:596
eZOrder\statusObject
statusObject()
Definition: ezorder.php:1269
eZOrder\productTotalExVAT
productTotalExVAT()
Definition: ezorder.php:855
eZOrder\$StatusModifierID
$StatusModifierID
Definition: ezorder.php:26
eZOrder\orderTotalExVAT
orderTotalExVAT()
Definition: ezorder.php:882
eZOrder\removeItem
static removeItem( $itemID)
Definition: ezorder.php:965
eZOrder\createStatusHistory
createStatusHistory()
Definition: ezorder.php:1219
eZOrder\statusModificationList
statusModificationList( $user=false)
Definition: ezorder.php:1108
eZOrder\fetch
static fetch( $id, $asObject=true)
Definition: ezorder.php:177
eZOrder\orderInfo
orderInfo()
Definition: ezorder.php:1429
eZOrder\productItemsOrdered
productItemsOrdered( $asObject=true, $order=true)
Definition: ezorder.php:838
eZOrder\productList
static productList( $CustomID, $Email)
Definition: ezorder.php:463
eZOrder\fetchLocaleCurrencyCode
static fetchLocaleCurrencyCode()
Definition: ezorder.php:1583
eZPersistentObject
Definition: ezpersistentobject.php:33
eZPersistentObject\$Email
$Email
Definition: ezpersistentobject.php:1508
eZPersistentObject\fetchObject
static fetchObject( $def, $field_filters, $conds, $asObject=true, $grouping=null, $custom_fields=null)
Definition: ezpersistentobject.php:213
eZPersistentObject\store
store( $fieldFilters=null)
Definition: ezpersistentobject.php:304
eZPersistentObject\setAttribute
setAttribute( $attr, $val)
Definition: ezpersistentobject.php:1374
eZPersistentObject\count
static count( $def, $conds=null, $field=null)
Definition: ezpersistentobject.php:187
eZPersistentObject\attribute
attribute( $attr, $noFunction=false)
Definition: ezpersistentobject.php:1329
eZPersistentObject\fetchObjectList
static fetchObjectList( $def, $field_filters=null, $conds=null, $sorts=null, $limit=null, $asObject=true, $grouping=false, $custom_fields=null, $custom_tables=null, $custom_conds=null)
Definition: ezpersistentobject.php:806
eZProductCollectionItem\fetch
static fetch( $id, $asObject=true)
Definition: ezproductcollectionitem.php:116
eZProductCollectionItem\definition
static definition()
Definition: ezproductcollectionitem.php:21
eZProductCollection
Definition: ezproductcollection.php:16
eZProductCollection\cleanupList
static cleanupList( $productCollectionIDList)
Definition: ezproductcollection.php:153
eZProductCollection\fetch
static fetch( $productCollectionID, $asObject=true)
Definition: ezproductcollection.php:90
eZShopAccountHandler\instance
static instance()
Definition: ezshopaccounthandler.php:20
eZUser\fetch
static fetch( $id, $asObject=true)
Definition: ezuser.php:351
eZUser\currentUserID
static currentUserID()
Definition: ezuser.php:1731
eZUser\currentUser
static currentUser()
Definition: ezuser.php:1716
Copyright © 1998 – 2026 7x. All rights reserved. Licensed under the GNU GPLv2+.