A QCodo powered CMS
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.

181 lines
5.9 KiB

  1. <?php
  2. if(!defined('QUINTACMS') ) die("No quinta.");
  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 <sidewalksoftware@gmail.com>
  8. *
  9. *
  10. *@version 0.3
  11. *
  12. *@package Quinta
  13. * @subpackage Modules
  14. */
  15. class CheckOutConfirmationModule extends QPanel{
  16. /**
  17. *@var CheckOutModule objControlBlock - the main control block for the check out module
  18. */
  19. protected $objControlBlock;
  20. /**
  21. *@var Order objOrder - local reference to the order
  22. */
  23. protected $objOrder;
  24. /**
  25. * @var array CheckOutItems - a list of products as cart items.
  26. */
  27. public $aryCheckOutItemControllers;
  28. /**
  29. * @var OrderTotalsController - module to display shipping, handling and total price for order
  30. */
  31. public $objOrderTotalsController;
  32. /**
  33. * @var AddressController objShippingAddressController - display for the shipping address
  34. */
  35. public $objShippingAddressController;
  36. /**
  37. * @var AddressController objBillingAddressController - display for the billing address
  38. */
  39. public $objBillingAddressController;
  40. /**
  41. * @var QPanel pnlPaymentMethod - panel to display information about the selected method
  42. */
  43. public $pnlPaymentMethod;
  44. /**
  45. * @var QPanel pnlShippinggMethod - panel to display information about the selected method
  46. */
  47. public $pnlShippingMethod;
  48. /**
  49. * Note that this is initialized by CheckOutModule based on payment status
  50. * @var QLabel lblMessage - used to display the message of confirmed or declined payment.
  51. */
  52. public $lblMessage;
  53. /**
  54. * Module constructor
  55. *@param QPanel pnlParentObject - the DOM parent
  56. *@param CheckOutModule objControlBlock - parent controller module.
  57. *@param Order objOrder - the Order being reviewed.
  58. */
  59. public function __construct( QPanel $pnlParentObject, $objControlBlock, Order $objOrder){
  60. try {
  61. parent::__construct($pnlParentObject, 'CheckOutConfirmationModule');
  62. } catch (QCallerException $objExc) {
  63. $objExc->IncrementOffset();
  64. throw $objExc;
  65. }
  66. $this->objControlBlock =& $objControlBlock;
  67. $this->objOrder =& $objOrder;
  68. $this->AutoRenderChildren = true;
  69. $this->strTemplate = __QUINTA_CORE_VIEWS__ . '/CheckOutConfirmationModule.tpl.php';
  70. $this->lblMessage = new QLabel($this);
  71. $this->lblMessage->HtmlEntities = false;
  72. $this->init();
  73. }
  74. protected function init(){
  75. $this->aryCheckOutItemControllers = array();
  76. //construct the list of items
  77. $aryOrderItems = $this->objOrder->GetNewOrderItemsArray();
  78. foreach( $aryOrderItems as $objOrderItem)
  79. {
  80. $objItemView = new CheckOutItemController( $this, $objOrderItem, false );
  81. $this->aryCheckOutItemControllers[] = $objItemView;
  82. }
  83. $this->objOrderTotalsController = new OrderTotalsController($this, $this->objOrder, false);
  84. $this->objShippingAddressController = new AddressController($this,
  85. $this->objOrder->ShippingAddressId,
  86. 'ShippingAddress: ');
  87. $this->objShippingAddressController->CssClass = 'ShippingAddressReview';
  88. $this->objShippingAddressController->AutoRenderChildren = true;
  89. $this->objBillingAddressController = new AddressController($this,
  90. $this->objOrder->BillingAddressId,
  91. 'BillingAddress: ');
  92. $this->objBillingAddressController->CssClass = 'BillingAddressReview';
  93. $this->objBillingAddressController->AutoRenderChildren = true;
  94. if($this->objControlBlock->PaymentMethod instanceof PaymentMethod){
  95. $objPaymentMethod = $this->objControlBlock->PaymentMethod;
  96. $this->pnlPaymentMethod = new QPanel($this);
  97. $this->pnlPaymentMethod->HtmlEntities = false;
  98. $this->pnlPaymentMethod->CssClass = 'PaymentMethodReview';
  99. $this->pnlPaymentMethod->AutoRenderChildren = true;
  100. $strText = '<div class="heading">' . Quinta::Translate('Payment Method') . ':</div>';
  101. $strText .= sprintf( '<div class="heading"> %s </div> <br /> %s ',
  102. $objPaymentMethod->Title,
  103. $objPaymentMethod->Description );
  104. $this->pnlPaymentMethod->Text = $strText;
  105. }
  106. if($this->objControlBlock->ShippingMethod instanceof ShippingMethod){
  107. $objShippingMethod = $this->objControlBlock->ShippingMethod;
  108. $this->pnlShippingMethod = new QPanel($this);
  109. $this->pnlShippingMethod->HtmlEntities = false;
  110. $this->pnlShippingMethod->CssClass = 'ShippingMethodReview';
  111. $this->pnlShippingMethod->AutoRenderChildren = true;
  112. $strText = '<div class="heading">' . Quinta::Translate('Shipping Method') . ': </div>';
  113. $strText .= sprintf( '<div class="heading"> %s </div> <br /> %s ',
  114. $objShippingMethod->Title,
  115. $objShippingMethod->Description );
  116. $this->pnlShippingMethod->Text = $strText;
  117. }
  118. }
  119. public function __get($strName){
  120. switch ($strName){
  121. case 'Order':
  122. return $this->objOrder ;
  123. case 'Message':
  124. return $this->lblMessage->Text ;
  125. default:
  126. try {
  127. return parent::__get($strName);
  128. } catch (QCallerException $objExc) {
  129. $objExc->IncrementOffset();
  130. throw $objExc;
  131. }
  132. }
  133. }
  134. public function __set($strName, $mixValue){
  135. switch ($strName){
  136. case 'Order':
  137. try {
  138. return ($this->objOrder = QType::Cast($mixValue, 'Order' ));
  139. } catch (QInvalidCastException $objExc) {
  140. $objExc->IncrementOffset();
  141. throw $objExc;
  142. }
  143. case 'Message':
  144. try {
  145. return ($this->lblMessage->Text = QType::Cast($mixValue, QType::String ));
  146. } catch (QInvalidCastException $objExc) {
  147. $objExc->IncrementOffset();
  148. throw $objExc;
  149. }
  150. default:
  151. try {
  152. return (parent::__set($strName, $mixValue));
  153. } catch (QCallerException $objExc) {
  154. $objExc->IncrementOffset();
  155. throw $objExc;
  156. }
  157. }
  158. }
  159. }//end class
  160. }//end define
  161. ?>