A Qcodo based CMS/ecommerce framework
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

128 lines
4.7 KiB

12 years ago
  1. <?php
  2. if(!defined('QUASICMS') ) die("No quasi.");
  3. if (!defined("CHECKOUTITEMLISTMODULE.CLASS.PHP")){
  4. define("CHECKOUTITEMLISTMODULE.CLASS.PHP",1);
  5. /** Class CheckOutItemListModule - provides display/modification of the list of items in an order
  6. *
  7. * CheckOutItemListModule is a center page module displayed on the Checkout page.
  8. * It shows a detailed list of the items in an Order with quantity modification fields.
  9. *
  10. * NOTE: You must call initItemList() to initialize the list and the totals - this allows for AJAX refreshing
  11. * between panels when quantities are modified.
  12. *
  13. *@author Erik Winn <erikwinnmail@yahoo.com>
  14. *
  15. *
  16. * $Id: CheckOutItemListModule.class.php 197 2008-09-19 22:11:27Z erikwinn $
  17. *@version 0.1
  18. *
  19. *@copyright (C) 2008 by Erik Winn
  20. *@license GPL v.2
  21. This program is free software; you can redistribute it and/or modify
  22. it under the terms of the GNU General Public License as published by
  23. the Free Software Foundation; either version 2 of the License, or
  24. (at your option) any later version.
  25. This program is distributed in the hope that it will be useful,
  26. but WITHOUT ANY WARRANTY; without even the implied warranty of
  27. MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  28. GNU General Public License for more details.
  29. You should have received a copy of the GNU General Public License
  30. along with this program; if not, write to the Free Software
  31. Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111 USA
  32. *
  33. * @package Quasi
  34. * @subpackage Views
  35. *
  36. */
  37. class CheckOutItemListModule extends QPanel
  38. {
  39. protected $objControlBlock;
  40. protected $objCheckOutEditModule;
  41. protected $fltItemsTotalPrice;
  42. /**
  43. * @var array CheckOutItems - a list of products as cart items.
  44. */
  45. public $aryCheckOutItemViews;
  46. protected $blnModifiable;
  47. /**
  48. *@param QPanel objParentObject a reference to the CheckOutEditModule, DOM parent
  49. *@param QPanel objControlBlock a reference to the main CheckOutModule
  50. *@param bool blnModifiable - if true the quantity is modifiable
  51. */
  52. public function __construct($objParentObject, $objControlBlock, $blnModifiable=true)
  53. {
  54. try {
  55. parent::__construct($objParentObject);
  56. } catch (QCallerException $objExc) {
  57. $objExc->IncrementOffset();
  58. throw $objExc;
  59. }
  60. // a reference to the main CheckOutModule
  61. $this->objControlBlock =& $objControlBlock;
  62. // a reference to the immediate parent
  63. $this->objCheckOutEditModule =& $objParentObject;
  64. //lets avoid foreach complaint in template if there are no items ..
  65. $this->aryCheckOutItemViews = array();
  66. $this->blnModifiable = $blnModifiable;
  67. $this->Template = __QUASI_CORE_TEMPLATES__ . '/CheckOutItemListModule.tpl.php';
  68. $this->fltItemsTotalPrice = 0;
  69. }
  70. /**
  71. * This function initializes the item list display and and the total price. It may be called to
  72. * refresh the list and totals at any time after instantiation.
  73. *@param array aryOrderItems - an array of OrderItems from which to create a list view
  74. */
  75. public function initItemList($aryOrderItems)
  76. {
  77. $this->fltItemsTotalPrice = 0;
  78. $this->aryCheckOutItemViews = array();
  79. //construct the list of items
  80. foreach($aryOrderItems as $objOrderItem)
  81. {
  82. $objItemView = new CheckOutItemView( $this, $objOrderItem, $this->blnModifiable );
  83. $this->fltItemsTotalPrice += $objItemView->ItemTotal;
  84. $this->aryCheckOutItemViews[] = $objItemView;
  85. }
  86. }
  87. public function RefreshTotalPrice()
  88. {
  89. $this->fltItemsTotalPrice = 0;
  90. foreach($this->aryCheckOutItemViews as $objItemView)
  91. $this->fltItemsTotalPrice += $objItemView->ItemTotal;
  92. if($this->objCheckOutEditModule instanceof CheckOutEditModule)
  93. $this->objCheckOutEditModule->TotalItemsCharge = $this->fltItemsTotalPrice;
  94. }
  95. public function __get($strName)
  96. {
  97. switch ($strName)
  98. {
  99. case 'ItemsTotalPrice':
  100. return $this->fltItemsTotalPrice ;
  101. default:
  102. try {
  103. return parent::__get($strName);
  104. } catch (QCallerException $objExc) {
  105. $objExc->IncrementOffset();
  106. throw $objExc;
  107. }
  108. }
  109. }
  110. }// end class
  111. }//end define shield
  112. ?>