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.

210 lines
8.6 KiB

12 years ago
  1. <?php
  2. if(!defined('QUASICMS') ) die("No quasi.");
  3. if (!defined("CHECKOUTCONFIRMATIONMODULE.CLASS.PHP")){
  4. define("CHECKOUTCONFIRMATIONMODULE.CLASS.PHP",1);
  5. /**
  6. * Class CheckOutConfirmationModule - provides display of order information for review during checkout
  7. *@author Erik Winn <erikwinnmail@yahoo.com>
  8. *
  9. *
  10. * $Id: CheckOutConfirmationModule.class.php 272 2008-10-08 15:40:08Z erikwinn $
  11. *@version 0.1
  12. *
  13. *@copyright (C) 2008 by Erik Winn
  14. *@license GPL v.2
  15. This program is free software; you can redistribute it and/or modify
  16. it under the terms of the GNU General Public License as published by
  17. the Free Software Foundation; either version 2 of the License, or
  18. (at your option) any later version.
  19. This program is distributed in the hope that it will be useful,
  20. but WITHOUT ANY WARRANTY; without even the implied warranty of
  21. MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  22. GNU General Public License for more details.
  23. You should have received a copy of the GNU General Public License
  24. along with this program; if not, write to the Free Software
  25. Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111 USA
  26. *
  27. *@package Quasi
  28. * @subpackage Modules
  29. */
  30. class CheckOutConfirmationModule extends QPanel
  31. {
  32. /**
  33. *@var CheckOutModule objControlBlock - the main control block for the check out module
  34. */
  35. protected $objControlBlock;
  36. /**
  37. *@var Order objOrder - local reference to the order
  38. */
  39. protected $objOrder;
  40. /**
  41. * @var array CheckOutItems - a list of products as cart items.
  42. */
  43. public $aryCheckOutItemViews;
  44. /**
  45. * @var OrderTotalsView - module to display shipping, handling and total price for order
  46. */
  47. public $objOrderTotalsView;
  48. /**
  49. * @var AddressView objShippingAddressView - display for the shipping address
  50. */
  51. public $objShippingAddressView;
  52. /**
  53. * @var AddressView objBillingAddressView - display for the billing address
  54. */
  55. public $objBillingAddressView;
  56. /**
  57. * @var QPanel pnlPaymentMethod - panel to display information about the selected method
  58. */
  59. public $pnlPaymentMethod;
  60. /**
  61. * @var QPanel pnlShippinggMethod - panel to display information about the selected method
  62. */
  63. public $pnlShippingMethod;
  64. /**
  65. * Note that this is initialized by CheckOutModule based on payment status
  66. * @var QLabel lblMessage - used to display the message of confirmed or declined payment.
  67. */
  68. public $lblMessage;
  69. /**
  70. * Module constructor
  71. *@param QPanel pnlParentObject - the DOM parent
  72. *@param CheckOutModule objControlBlock - parent controller module.
  73. *@param Order objOrder - the Order being reviewed.
  74. */
  75. public function __construct( QPanel $pnlParentObject, $objControlBlock, Order $objOrder)
  76. {
  77. try {
  78. parent::__construct($pnlParentObject, 'CheckOutConfirmationModule');
  79. } catch (QCallerException $objExc) {
  80. $objExc->IncrementOffset();
  81. throw $objExc;
  82. }
  83. $this->objControlBlock =& $objControlBlock;
  84. $this->objOrder =& $objOrder;
  85. $this->AutoRenderChildren = true;
  86. $this->strTemplate = __QUASI_CORE_TEMPLATES__ . '/CheckOutConfirmationModule.tpl.php';
  87. $this->lblMessage = new QLabel($this);
  88. $this->lblMessage->HtmlEntities = false;
  89. $this->init();
  90. }
  91. protected function init()
  92. {
  93. $this->aryCheckOutItemViews = array();
  94. //construct the list of items
  95. $aryOrderItems = $this->objOrder->GetNewOrderItemsArray();
  96. foreach( $aryOrderItems as $objOrderItem)
  97. {
  98. $objItemView = new CheckOutItemView( $this, $objOrderItem, false );
  99. $this->aryCheckOutItemViews[] = $objItemView;
  100. }
  101. $this->objOrderTotalsView = new OrderTotalsView($this, $this->objOrder, false);
  102. $this->objShippingAddressView = new AddressView($this,
  103. $this->objOrder->ShippingAddressId,
  104. 'ShippingAddress: ');
  105. $this->objShippingAddressView->CssClass = 'ShippingAddressReview';
  106. $this->objShippingAddressView->AutoRenderChildren = true;
  107. $this->objBillingAddressView = new AddressView($this,
  108. $this->objOrder->BillingAddressId,
  109. 'BillingAddress: ');
  110. $this->objBillingAddressView->CssClass = 'BillingAddressReview';
  111. $this->objBillingAddressView->AutoRenderChildren = true;
  112. if($this->objControlBlock->PaymentMethod instanceof PaymentMethod)
  113. {
  114. $objPaymentMethod = $this->objControlBlock->PaymentMethod;
  115. $this->pnlPaymentMethod = new QPanel($this);
  116. $this->pnlPaymentMethod->HtmlEntities = false;
  117. $this->pnlPaymentMethod->CssClass = 'PaymentMethodReview';
  118. $this->pnlPaymentMethod->AutoRenderChildren = true;
  119. $strText = '<div class="heading">' . Quasi::Translate('Payment Method') . ':</div>';
  120. $strText .= sprintf( '<div class="heading"> %s </div> <br /> %s ',
  121. $objPaymentMethod->Title,
  122. $objPaymentMethod->Description );
  123. $this->pnlPaymentMethod->Text = $strText;
  124. }
  125. if($this->objControlBlock->ShippingMethod instanceof ShippingMethod)
  126. {
  127. $objShippingMethod = $this->objControlBlock->ShippingMethod;
  128. $this->pnlShippingMethod = new QPanel($this);
  129. $this->pnlShippingMethod->HtmlEntities = false;
  130. $this->pnlShippingMethod->CssClass = 'ShippingMethodReview';
  131. $this->pnlShippingMethod->AutoRenderChildren = true;
  132. $strText = '<div class="heading">' . Quasi::Translate('Shipping Method') . ': </div>';
  133. $strText .= sprintf( '<div class="heading"> %s </div> <br /> %s ',
  134. $objShippingMethod->Title,
  135. $objShippingMethod->Description );
  136. $this->pnlShippingMethod->Text = $strText;
  137. }
  138. }
  139. // public function Validate(){ return true;}
  140. public function __get($strName)
  141. {
  142. switch ($strName)
  143. {
  144. case 'Order':
  145. return $this->objOrder ;
  146. case 'Message':
  147. return $this->lblMessage->Text ;
  148. default:
  149. try {
  150. return parent::__get($strName);
  151. } catch (QCallerException $objExc) {
  152. $objExc->IncrementOffset();
  153. throw $objExc;
  154. }
  155. }
  156. }
  157. public function __set($strName, $mixValue)
  158. {
  159. switch ($strName)
  160. {
  161. case 'Order':
  162. try {
  163. return ($this->objOrder = QType::Cast($mixValue, 'Order' ));
  164. } catch (QInvalidCastException $objExc) {
  165. $objExc->IncrementOffset();
  166. throw $objExc;
  167. }
  168. case 'Message':
  169. try {
  170. return ($this->lblMessage->Text = QType::Cast($mixValue, QType::String ));
  171. } catch (QInvalidCastException $objExc) {
  172. $objExc->IncrementOffset();
  173. throw $objExc;
  174. }
  175. default:
  176. try {
  177. return (parent::__set($strName, $mixValue));
  178. } catch (QCallerException $objExc) {
  179. $objExc->IncrementOffset();
  180. throw $objExc;
  181. }
  182. }
  183. }
  184. }//end class
  185. }//end define
  186. ?>