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.

162 lines
4.4 KiB

  1. <?php
  2. if(!defined('QUINTACMS') ) die("No quinta.");
  3. if (!defined("CHECKOUTTOTALSCONTROLLER.CLASS.PHP")){
  4. define("CHECKOUTTOTALSCONTROLLER.CLASS.PHP",1);
  5. /**
  6. * Class CheckOutTotalsController - provides display of order totals, shipping and handling
  7. * charges for display during checkout
  8. *@author Erik Winn <sidewalksoftware@gmail.com>
  9. *
  10. *@version 0.3
  11. *
  12. *@package Quinta
  13. * @subpackage Classes
  14. */
  15. class CheckOutTotalsController extends QPanel{
  16. /**
  17. *@var CheckOutModule objControlBlock - the main control block for the check out module
  18. */
  19. protected $objControlBlock;
  20. /**
  21. *@var float fltShippingCharge - shipping for order
  22. */
  23. protected $fltShippingCharge;
  24. /**
  25. *@var float fltHandlingCharge - handling for order
  26. */
  27. protected $fltHandlingCharge;
  28. /**
  29. *@var float fltTaxesCharge - taxes for order
  30. */
  31. protected $fltTaxesCharge;
  32. /**
  33. *@var float fltTotalItemsCharge - sub total of all the items on an order
  34. */
  35. protected $fltTotalItemsCharge;
  36. /**
  37. *@var float fltTotalCharge - grand total of all charges for order
  38. */
  39. protected $fltTotalCharge;
  40. /**
  41. * @var QLabel lblHandlingCharge - display for handling charges ..
  42. */
  43. public $lblHandlingCharge;
  44. /**
  45. * @var QLabel lblShippingCharge - display for shipping charges ..
  46. */
  47. public $lblShippingCharge;
  48. /**
  49. * @var QLabel lblTaxesCharge - display for total taxes for the order
  50. */
  51. public $lblTaxesCharge;
  52. /**
  53. * @var QLabel lblTotalItemsCharge - display for total of Item charges for the order
  54. */
  55. public $lblTotalItemsCharge;
  56. /**
  57. * @var QLabel lblTotalCharge - display for grand total charges for the order
  58. */
  59. public $lblTotalCharge;
  60. /**
  61. * CheckOutTotalsController constructor
  62. *@param CheckOutView objControlBlock - parent controller module.
  63. */
  64. public function __construct( QPanel $objControlBlock){
  65. try {
  66. parent::__construct($objControlBlock);
  67. } catch (QCallerException $objExc) {
  68. $objExc->IncrementOffset();
  69. throw $objExc;
  70. }
  71. $this->AutoRenderChildren = true;
  72. $this->strTemplate = __QUINTA_CORE_VIEWS__ . '/CheckOutTotalsView.tpl.php';
  73. $this->lblShippingCharge = new QLabel($this);
  74. $this->lblHandlingCharge = new QLabel($this);
  75. $this->lblTotalItemsCharge = new QLabel($this);
  76. $this->lblTaxesCharge = new QLabel($this);
  77. $this->lblTotalCharge = new QLabel($this);
  78. }
  79. public function RefreshTotal(){
  80. $this->TotalCharge = $this->fltShippingCharge
  81. + $this->fltHandlingCharge
  82. + $this->fltTaxesCharge
  83. + $this->fltTotalItemsCharge;
  84. }
  85. /**
  86. * This Function is called when any input is sent - on failure the
  87. * fields are redrawn with optional error messages.
  88. */
  89. public function Validate(){
  90. $blnToReturn = true;
  91. // validate input here
  92. return $blnToReturn;
  93. }
  94. public function __get($strName){
  95. switch ($strName){
  96. case 'ShippingCharge':
  97. return $this->fltShippingCharge ;
  98. case 'HandlingCharge':
  99. return $this->fltHandlingCharge ;
  100. case 'TotalCharge':
  101. return $this->fltTotalCharge ;
  102. case 'TotalCharge':
  103. return $this->fltTotalItemsCharge ;
  104. case 'TaxesCharge':
  105. return $this->fltTaxesCharge ;
  106. default:
  107. try {
  108. return parent::__get($strName);
  109. } catch (QCallerException $objExc) {
  110. $objExc->IncrementOffset();
  111. throw $objExc;
  112. }
  113. }
  114. }
  115. public function __set($strName, $mixValue){
  116. switch ($strName){
  117. case 'ShippingCharge':
  118. $this->fltShippingCharge = $mixValue;
  119. $this->lblShippingCharge->Text = money_format('%n', $mixValue);
  120. $this->RefreshTotal();
  121. break;
  122. case 'HandlingCharge':
  123. $this->fltHandlingCharge = $mixValue;
  124. $this->lblHandlingCharge->Text = money_format('%n', $mixValue);
  125. $this->RefreshTotal();
  126. break;
  127. case 'TaxesCharge':
  128. $this->fltTaxesCharge = $mixValue;
  129. $this->lblTaxesCharge->Text = money_format('%n', $mixValue);
  130. $this->RefreshTotal();
  131. break;
  132. case 'TotalItemsCharge':
  133. $this->fltTotalItemsCharge = $mixValue;
  134. $this->lblTotalItemsCharge->Text = money_format('%n', $mixValue);
  135. $this->RefreshTotal();
  136. break;
  137. case 'TotalCharge':
  138. $this->fltTotalCharge = $mixValue;
  139. $this->lblTotalCharge->Text = money_format('%n', $mixValue);
  140. break;
  141. default:
  142. try {
  143. return (parent::__set($strName, $mixValue));
  144. } catch (QCallerException $objExc) {
  145. $objExc->IncrementOffset();
  146. throw $objExc;
  147. }
  148. }
  149. }
  150. }//end class
  151. }//end define
  152. ?>