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.

150 lines
5.6 KiB

12 years ago
  1. <?php
  2. if(!defined('QUASICMS') ) die("No quasi.");
  3. /**
  4. * ProductItemView - provides a panel for the display of a single Product
  5. *
  6. *@author Erik Winn <erikwinnmail@yahoo.com>
  7. *
  8. *
  9. * $Id: ProductItemView.class.php 286 2008-10-10 23:33:36Z erikwinn $
  10. *@version 0.1
  11. *
  12. *@copyright (C) 2008 by Erik Winn
  13. *@license GPL v.2
  14. This program is free software; you can redistribute it and/or modify
  15. it under the terms of the GNU General Public License as published by
  16. the Free Software Foundation; either version 2 of the License, or
  17. (at your option) any later version.
  18. This program is distributed in the hope that it will be useful,
  19. but WITHOUT ANY WARRANTY; without even the implied warranty of
  20. MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  21. GNU General Public License for more details.
  22. You should have received a copy of the GNU General Public License
  23. along with this program; if not, write to the Free Software
  24. Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111 USA
  25. *
  26. * @package Quasi
  27. * @subpackage Classes
  28. */
  29. class ProductItemView extends QPanel
  30. {
  31. private $objControlBlock;
  32. // Local instance of the ProductMetaControl
  33. protected $mctProduct;
  34. // Controls for Product's Data Fields
  35. public $lblId;
  36. public $lblManufacturer;
  37. public $lblSupplier;
  38. public $lblCreationDate;
  39. public $lblName;
  40. public $lblModel;
  41. public $lblShortDescription;
  42. public $lblLongDescription;
  43. public $lblMsrp;
  44. public $lblWholesalePrice;
  45. public $lblRetailPrice;
  46. public $lblWeight;
  47. public $lblHeight;
  48. public $lblWidth;
  49. public $lblDepth;
  50. public $lblType;
  51. public $lblViewCount;
  52. public $lblProductCategoriesAsCategory;
  53. public $lblParentProductsAsRelated;
  54. public $lblProductsAsRelated;
  55. public $ctlImageLabel;
  56. public $btnBack;
  57. public $btnAddToCart;
  58. public $strImageLink;
  59. // Callback
  60. protected $strClosePanelMethod;
  61. public function __construct($objParentObject,
  62. $objControlBlock,
  63. $strClosePanelMethod,
  64. $intProductId = null,
  65. $strControlId = null)
  66. {
  67. $this->objControlBlock =& $objControlBlock;
  68. try {
  69. parent::__construct($objParentObject, $strControlId);
  70. } catch (QCallerException $objExc) {
  71. $objExc->IncrementOffset();
  72. throw $objExc;
  73. }
  74. $this->strTemplate = __QUASI_CORE_TEMPLATES__ . '/ProductItemView.tpl.php';
  75. $this->strClosePanelMethod = $strClosePanelMethod;
  76. $this->mctProduct = ProductMetaControl::Create($this, $intProductId);
  77. $this->lblId = $this->mctProduct->lblId_Create();
  78. $this->lblManufacturer = $this->mctProduct->lblManufacturer_Create();
  79. $this->lblSupplier = $this->mctProduct->lblSupplier_Create();
  80. $this->lblCreationDate = $this->mctProduct->lblCreationDate_Create();
  81. $this->lblName = $this->mctProduct->lblName_Create();
  82. $this->lblModel = $this->mctProduct->lblModel_Create();
  83. $this->lblShortDescription = $this->mctProduct->lblShortDescription_Create();
  84. $this->lblLongDescription = $this->mctProduct->lblLongDescription_Create();
  85. $this->lblLongDescription->HtmlEntities = false;
  86. /*
  87. $this->lblMsrp = $this->mctProduct->lblMsrp_Create();
  88. $this->lblWholesalePrice = $this->mctProduct->lblWholesalePrice_Create();
  89. */
  90. $this->lblRetailPrice = $this->mctProduct->lblRetailPrice_Create();
  91. $this->lblWeight = $this->mctProduct->lblWeight_Create();
  92. $this->lblHeight = $this->mctProduct->lblHeight_Create();
  93. $this->lblWidth = $this->mctProduct->lblWidth_Create();
  94. $this->lblDepth = $this->mctProduct->lblDepth_Create();
  95. $this->lblType = $this->mctProduct->lblType_Create();
  96. $this->lblProductCategoriesAsCategory = $this->mctProduct->lblProductCategoriesAsCategory_Create();
  97. $this->lblParentProductsAsRelated = $this->mctProduct->lblParentProductsAsRelated_Create();
  98. $this->lblProductsAsRelated = $this->mctProduct->lblProductsAsRelated_Create();
  99. $this->btnBack = new QButton($this);
  100. $this->btnBack->Text = Quasi::Translate('Back');
  101. if(IndexPage::$blnAjaxOk)
  102. $this->btnBack->AddAction(new QClickEvent(), new QAjaxControlAction($this, 'btnBack_Click'));
  103. else
  104. $this->btnBack->AddAction(new QClickEvent(), new QServerControlAction($this, 'btnBack_Click'));
  105. $this->btnAddToCart = new QButton($this);
  106. $this->btnAddToCart->Text = Quasi::Translate('Add to Cart');
  107. if(IndexPage::$blnAjaxOk)
  108. $this->btnAddToCart->AddAction(new QClickEvent(), new QAjaxControlAction($this, 'btnAddToCart_Click'));
  109. else
  110. $this->btnAddToCart->AddAction(new QClickEvent(), new QServerControlAction($this, 'btnAddToCart_Click'));
  111. $this->btnAddToCart->ActionParameter = $intProductId;
  112. $this->ctlImageLabel = new ProductImageLabel( $this, $intProductId );
  113. }
  114. public function btnBack_Click($strFormId, $strControlId, $strParameter)
  115. {
  116. $strMethod = $this->strClosePanelMethod;
  117. //close indicating no changes
  118. $this->objControlBlock->$strMethod(false);
  119. }
  120. public function btnAddToCart_Click($strFormId, $strControlId, $intProductId)
  121. {
  122. if($intProductId && IndexPage::$objShoppingCart instanceof ShoppingCart )
  123. IndexPage::$objShoppingCart->AddItem($intProductId);
  124. }
  125. }
  126. ?>