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.

192 lines
6.8 KiB

13 years ago
  1. <?php
  2. if(!defined('QUASICMS') ) die("No quasi.");
  3. if (!defined("CHECKOUTTOTALSVIEW.CLASS.PHP")){
  4. define("CHECKOUTTOTALSVIEW.CLASS.PHP",1);
  5. /**
  6. * Class CheckOutTotalsView - provides display of order totals, shipping and handling
  7. * charges for display during checkout
  8. *@author Erik Winn <erikwinnmail@yahoo.com>
  9. *
  10. *
  11. * $Id: CheckOutTotalsView.class.php 234 2008-09-30 15:49:13Z erikwinn $
  12. *@version 0.1
  13. *
  14. *@copyright (C) 2008 by Erik Winn
  15. *@license GPL v.2
  16. This program is free software; you can redistribute it and/or modify
  17. it under the terms of the GNU General Public License as published by
  18. the Free Software Foundation; either version 2 of the License, or
  19. (at your option) any later version.
  20. This program is distributed in the hope that it will be useful,
  21. but WITHOUT ANY WARRANTY; without even the implied warranty of
  22. MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  23. GNU General Public License for more details.
  24. You should have received a copy of the GNU General Public License
  25. along with this program; if not, write to the Free Software
  26. Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111 USA
  27. *
  28. *@package Quasi
  29. * @subpackage Classes
  30. */
  31. class CheckOutTotalsView extends QPanel
  32. {
  33. /**
  34. *@var CheckOutModule objControlBlock - the main control block for the check out module
  35. */
  36. protected $objControlBlock;
  37. /**
  38. *@var float fltShippingCharge - shipping for order
  39. */
  40. protected $fltShippingCharge;
  41. /**
  42. *@var float fltHandlingCharge - handling for order
  43. */
  44. protected $fltHandlingCharge;
  45. /**
  46. *@var float fltTaxesCharge - taxes for order
  47. */
  48. protected $fltTaxesCharge;
  49. /**
  50. *@var float fltTotalItemsCharge - sub total of all the items on an order
  51. */
  52. protected $fltTotalItemsCharge;
  53. /**
  54. *@var float fltTotalCharge - grand total of all charges for order
  55. */
  56. protected $fltTotalCharge;
  57. /**
  58. * @var QLabel lblHandlingCharge - display for handling charges ..
  59. */
  60. public $lblHandlingCharge;
  61. /**
  62. * @var QLabel lblShippingCharge - display for shipping charges ..
  63. */
  64. public $lblShippingCharge;
  65. /**
  66. * @var QLabel lblTaxesCharge - display for total taxes for the order
  67. */
  68. public $lblTaxesCharge;
  69. /**
  70. * @var QLabel lblTotalItemsCharge - display for total of Item charges for the order
  71. */
  72. public $lblTotalItemsCharge;
  73. /**
  74. * @var QLabel lblTotalCharge - display for grand total charges for the order
  75. */
  76. public $lblTotalCharge;
  77. /**
  78. * View constructor
  79. *@param CheckOutView objControlBlock - parent controller module.
  80. *@param Order objOrder - the
  81. */
  82. public function __construct( QPanel $objControlBlock)
  83. {
  84. try {
  85. parent::__construct($objControlBlock);
  86. } catch (QCallerException $objExc) {
  87. $objExc->IncrementOffset();
  88. throw $objExc;
  89. }
  90. $this->AutoRenderChildren = true;
  91. $this->strTemplate = __QUASI_CORE_TEMPLATES__ . '/CheckOutTotalsView.tpl.php';
  92. $this->lblShippingCharge = new QLabel($this);
  93. $this->lblHandlingCharge = new QLabel($this);
  94. $this->lblTotalItemsCharge = new QLabel($this);
  95. $this->lblTaxesCharge = new QLabel($this);
  96. $this->lblTotalCharge = new QLabel($this);
  97. }
  98. public function RefreshTotal()
  99. {
  100. $this->TotalCharge = $this->fltShippingCharge
  101. + $this->fltHandlingCharge
  102. + $this->fltTaxesCharge
  103. + $this->fltTotalItemsCharge;
  104. }
  105. /**
  106. * This Function is called when any input is sent - on failure the
  107. * fields are redrawn with optional error messages.
  108. */
  109. public function Validate()
  110. {
  111. $blnToReturn = true;
  112. // validate input here
  113. return $blnToReturn;
  114. }
  115. public function __get($strName)
  116. {
  117. switch ($strName)
  118. {
  119. case 'ShippingCharge':
  120. return $this->fltShippingCharge ;
  121. case 'HandlingCharge':
  122. return $this->fltHandlingCharge ;
  123. case 'TotalCharge':
  124. return $this->fltTotalCharge ;
  125. case 'TotalCharge':
  126. return $this->fltTotalItemsCharge ;
  127. case 'TaxesCharge':
  128. return $this->fltTaxesCharge ;
  129. default:
  130. try {
  131. return parent::__get($strName);
  132. } catch (QCallerException $objExc) {
  133. $objExc->IncrementOffset();
  134. throw $objExc;
  135. }
  136. }
  137. }
  138. public function __set($strName, $mixValue)
  139. {
  140. switch ($strName)
  141. {
  142. case 'ShippingCharge':
  143. $this->fltShippingCharge = $mixValue;
  144. $this->lblShippingCharge->Text = money_format('%n', $mixValue);
  145. $this->RefreshTotal();
  146. break;
  147. case 'HandlingCharge':
  148. $this->fltHandlingCharge = $mixValue;
  149. $this->lblHandlingCharge->Text = money_format('%n', $mixValue);
  150. $this->RefreshTotal();
  151. break;
  152. case 'TaxesCharge':
  153. $this->fltTaxesCharge = $mixValue;
  154. $this->lblTaxesCharge->Text = money_format('%n', $mixValue);
  155. $this->RefreshTotal();
  156. break;
  157. case 'TotalItemsCharge':
  158. $this->fltTotalItemsCharge = $mixValue;
  159. $this->lblTotalItemsCharge->Text = money_format('%n', $mixValue);
  160. $this->RefreshTotal();
  161. break;
  162. case 'TotalCharge':
  163. $this->fltTotalCharge = $mixValue;
  164. $this->lblTotalCharge->Text = money_format('%n', $mixValue);
  165. break;
  166. default:
  167. try {
  168. return (parent::__set($strName, $mixValue));
  169. } catch (QCallerException $objExc) {
  170. $objExc->IncrementOffset();
  171. throw $objExc;
  172. }
  173. }
  174. }
  175. }//end class
  176. }//end define
  177. ?>