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.

155 lines
6.4 KiB

12 years ago
  1. <?php
  2. if(!defined('QUASICMS') ) die("No quasi.");
  3. /**
  4. * ProductListView - provides a panel for the display of a list of Products
  5. *
  6. *@author Erik Winn <erikwinnmail@yahoo.com>
  7. *
  8. *
  9. * $Id: ProductListView.class.php 290 2008-10-12 02:22:54Z 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 ProductListView extends QPanel
  30. {
  31. private $objControlBlock;
  32. private $objAccount;
  33. // Local instance of the Meta DataGrid to list Products
  34. public $dtgProducts;
  35. public $pxtViewItem;
  36. public $pxyAddToCart;
  37. // Callback Method Names
  38. protected $strSetItemViewMethod;
  39. protected $strCloseItemViewMethod;
  40. public function __construct($objParentObject,
  41. $objControlBlock,
  42. $strSetItemViewMethod,
  43. $strCloseItemViewMethod,
  44. $strControlId = null)
  45. {
  46. // Call the Parent
  47. try {
  48. parent::__construct($objParentObject, $strControlId);
  49. } catch (QCallerException $objExc) {
  50. $objExc->IncrementOffset();
  51. throw $objExc;
  52. }
  53. $this->objControlBlock =& $objControlBlock;
  54. $this->objAccount = IndexPage::$objAccount;
  55. // Record Method Callbacks
  56. $this->strSetItemViewMethod = $strSetItemViewMethod;
  57. $this->strCloseItemViewMethod = $strCloseItemViewMethod;
  58. $this->Template =__QUASI_CORE_TEMPLATES__ . '/ProductListView.tpl.php';
  59. $this->dtgProducts = new ProductDataGrid($this);
  60. $this->dtgProducts->CssClass = 'datagrid';
  61. $this->dtgProducts->AlternateRowStyle->CssClass = 'alternate';
  62. $this->dtgProducts->Paginator = new QPaginator($this->dtgProducts);
  63. $this->dtgProducts->ItemsPerPage = 15;
  64. $this->pxtViewItem = new QControlProxy($this);
  65. if(IndexPage::$blnAjaxOk)
  66. $this->pxtViewItem->AddAction(new QClickEvent(), new QAjaxControlAction($this, 'pxtViewItem_Click'));
  67. else
  68. $this->pxtViewItem->AddAction(new QClickEvent(), new QServerControlAction($this, 'pxtViewItem_Click'));
  69. $this->dtgProducts->MetaAddEditProxyColumn($this->pxtViewItem, 'View', 'View');
  70. $this->dtgProducts->MetaAddColumn('Id');
  71. $this->dtgProducts->MetaAddColumn('Name');
  72. $this->dtgProducts->MetaAddColumn('Model');
  73. $this->dtgProducts->MetaAddColumn('RetailPrice');
  74. /*other possible columns:
  75. $this->dtgProducts->MetaAddColumn(QQN::Product()->Manufacturer);
  76. $this->dtgProducts->MetaAddColumn(QQN::Product()->Supplier);
  77. $this->dtgProducts->MetaAddColumn('CreationDate');
  78. $this->dtgProducts->MetaAddColumn('ShortDescription');
  79. $this->dtgProducts->MetaAddColumn('LongDescription');
  80. $this->dtgProducts->MetaAddColumn('Msrp');
  81. $this->dtgProducts->MetaAddColumn('WholesalePrice');
  82. $this->dtgProducts->MetaAddColumn('Cost');
  83. $this->dtgProducts->MetaAddColumn('Weight');
  84. $this->dtgProducts->MetaAddColumn('Height');
  85. $this->dtgProducts->MetaAddColumn('Width');
  86. $this->dtgProducts->MetaAddColumn('Depth');
  87. $this->dtgProducts->MetaAddColumn('IsVirtual');
  88. $this->dtgProducts->MetaAddTypeColumn('TypeId', 'ProductType');
  89. */
  90. $this->pxyAddToCart = new QControlProxy($this);
  91. if(IndexPage::$blnAjaxOk)
  92. $this->pxyAddToCart->AddAction(new QClickEvent(), new QAjaxControlAction($this, 'pxyAddToCart_Click'));
  93. else
  94. $this->pxyAddToCart->AddAction(new QClickEvent(), new QServerControlAction($this, 'pxyAddToCart_Click'));
  95. $this->dtgProducts->MetaAddEditProxyColumn($this->pxyAddToCart, 'Add To Cart', '');
  96. }
  97. /**
  98. * This function accepts an Id for a Product item to view, called when user clicks "View"
  99. * in the list item.
  100. * The Product is displayed in a separate panel by the ControlBlock
  101. *
  102. *@param string strFormId - contains the CSS id of the main QForm (ie. IndexPage)
  103. *@param string strControlId - contains the CSS id of the calling control (ie. the datagrid )
  104. *@param integer intProductId - contains the id of the Product to add
  105. *@return void
  106. */
  107. public function pxtViewItem_Click($strFormId, $strControlId, $intProductId)
  108. {
  109. $objItemView = new ProductItemView($this,
  110. $this->objControlBlock,
  111. $this->strCloseItemViewMethod,
  112. $intProductId);
  113. $strMethodName = $this->strSetItemViewMethod;
  114. $this->objControlBlock->$strMethodName($objItemView);
  115. }
  116. /**
  117. * This function accepts an Id for a Product to add to the shopping cart, called when user clicks "Add to Cart"
  118. * in the list item.
  119. * The Product is then added to the cart as a ShoppingCartItem. If a ShoppingCartItem already exists
  120. * for this product, the quantity is incremented.
  121. *
  122. *
  123. *@param string strFormId - contains the CSS id of the main QForm (ie. IndexPage)
  124. *@param string strControlId - contains the CSS id of the calling control (ie. the datagrid )
  125. *@param integer intProductId - contains the id of the Product to add
  126. *@return void
  127. */
  128. public function pxyAddToCart_Click($strFormId, $strControlId, $intProductId)
  129. {
  130. if($intProductId && IndexPage::$objShoppingCart instanceof ShoppingCart )
  131. IndexPage::$objShoppingCart->AddItem($intProductId);
  132. }
  133. }
  134. ?>