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.

144 lines
5.9 KiB

13 years ago
  1. <?php
  2. /**
  3. * This is a quick-and-dirty draft QPanel object to do Create, Edit, and Delete functionality
  4. * of the Product class. It uses the code-generated
  5. * ProductMetaControl class, which has meta-methods to help with
  6. * easily creating/defining controls to modify the fields of a Product columns.
  7. *
  8. * Any display customizations and presentation-tier logic can be implemented
  9. * here by overriding existing or implementing new methods, properties and variables.
  10. *
  11. * NOTE: This file is overwritten on any code regenerations. If you want to make
  12. * permanent changes, it is STRONGLY RECOMMENDED to move both product_edit.php AND
  13. * product_edit.tpl.php out of this Form Drafts directory.
  14. *
  15. * @package Quasi
  16. * @subpackage Drafts
  17. */
  18. class ProductEditPanel extends QPanel {
  19. // Local instance of the ProductMetaControl
  20. protected $mctProduct;
  21. // Controls for Product's Data Fields
  22. public $lblId;
  23. public $lblManufacturer;
  24. public $lblSupplier;
  25. public $lblCreationDate;
  26. public $txtName;
  27. public $txtModel;
  28. public $txtShortDescription;
  29. public $txtLongDescription;
  30. public $txtMsrp;
  31. public $txtWholesalePrice;
  32. public $txtRetailPrice;
  33. public $txtCost;
  34. public $txtWeight;
  35. public $txtHeight;
  36. public $txtWidth;
  37. public $txtDepth;
  38. public $chkIsVirtual;
  39. public $lstType;
  40. public $lstStatus;
  41. public $txtViewCount;
  42. public $lstUserPermissions;
  43. public $lstPublicPermissions;
  44. public $lstGroupPermissions;
  45. // Other ListBoxes (if applicable) via Unique ReverseReferences and ManyToMany References
  46. public $lstProductCategoriesAsCategory;
  47. public $lstParentProductsAsRelated;
  48. public $lstProductsAsRelated;
  49. // Other Controls
  50. public $btnSave;
  51. public $btnDelete;
  52. public $btnCancel;
  53. // Callback
  54. protected $strClosePanelMethod;
  55. public function __construct($objParentObject, $strClosePanelMethod, $intId = null, $strControlId = null) {
  56. // Call the Parent
  57. try {
  58. parent::__construct($objParentObject, $strControlId);
  59. } catch (QCallerException $objExc) {
  60. $objExc->IncrementOffset();
  61. throw $objExc;
  62. }
  63. // Setup Callback and Template
  64. $this->strTemplate = 'ProductEditPanel.tpl.php';
  65. $this->strClosePanelMethod = $strClosePanelMethod;
  66. // Construct the ProductMetaControl
  67. // MAKE SURE we specify "$this" as the MetaControl's (and thus all subsequent controls') parent
  68. $this->mctProduct = ProductMetaControl::Create($this, $intId);
  69. // Call MetaControl's methods to create qcontrols based on Product's data fields
  70. $this->lblId = $this->mctProduct->lblId_Create();
  71. $this->lblManufacturer = $this->mctProduct->lblManufacturerId_Create();
  72. $this->lblSupplier = $this->mctProduct->lblSupplierId_Create();
  73. $this->lblCreationDate = $this->mctProduct->lblCreationDate_Create();
  74. $this->txtName = $this->mctProduct->txtName_Create();
  75. $this->txtModel = $this->mctProduct->txtModel_Create();
  76. $this->txtShortDescription = $this->mctProduct->txtShortDescription_Create();
  77. $this->txtLongDescription = $this->mctProduct->txtLongDescription_Create();
  78. $this->txtMsrp = $this->mctProduct->txtMsrp_Create();
  79. $this->txtWholesalePrice = $this->mctProduct->txtWholesalePrice_Create();
  80. $this->txtRetailPrice = $this->mctProduct->txtRetailPrice_Create();
  81. $this->txtCost = $this->mctProduct->txtCost_Create();
  82. $this->txtWeight = $this->mctProduct->txtWeight_Create();
  83. $this->txtHeight = $this->mctProduct->txtHeight_Create();
  84. $this->txtWidth = $this->mctProduct->txtWidth_Create();
  85. $this->txtDepth = $this->mctProduct->txtDepth_Create();
  86. $this->chkIsVirtual = $this->mctProduct->chkIsVirtual_Create();
  87. $this->lstType = $this->mctProduct->lstType_Create();
  88. $this->lstStatus = $this->mctProduct->lstStatus_Create();
  89. $this->txtViewCount = $this->mctProduct->txtViewCount_Create();
  90. $this->lstUserPermissions = $this->mctProduct->lstUserPermissions_Create();
  91. $this->lstPublicPermissions = $this->mctProduct->lstPublicPermissions_Create();
  92. $this->lstGroupPermissions = $this->mctProduct->lstGroupPermissions_Create();
  93. // $this->lstProductCategoriesAsCategory = $this->mctProduct->lstProductCategoriesAsCategory_Create();
  94. // $this->lstParentProductsAsRelated = $this->mctProduct->lstParentProductsAsRelated_Create();
  95. // $this->lstProductsAsRelated = $this->mctProduct->lstProductsAsRelated_Create();
  96. // Create Buttons and Actions on this Form
  97. $this->btnSave = new QButton($this);
  98. $this->btnSave->Text = QApplication::Translate('Save');
  99. $this->btnSave->AddAction(new QClickEvent(), new QAjaxControlAction($this, 'btnSave_Click'));
  100. $this->btnSave->CausesValidation = $this;
  101. $this->btnCancel = new QButton($this);
  102. $this->btnCancel->Text = QApplication::Translate('Cancel');
  103. $this->btnCancel->AddAction(new QClickEvent(), new QAjaxControlAction($this, 'btnCancel_Click'));
  104. $this->btnDelete = new QButton($this);
  105. $this->btnDelete->Text = QApplication::Translate('Delete');
  106. $this->btnDelete->AddAction(new QClickEvent(), new QConfirmAction(QApplication::Translate('Are you SURE you want to DELETE this') . ' ' . QApplication::Translate('Product') . '?'));
  107. $this->btnDelete->AddAction(new QClickEvent(), new QAjaxControlAction($this, 'btnDelete_Click'));
  108. $this->btnDelete->Visible = $this->mctProduct->EditMode;
  109. }
  110. // Control AjaxAction Event Handlers
  111. public function btnSave_Click($strFormId, $strControlId, $strParameter) {
  112. // Delegate "Save" processing to the ProductMetaControl
  113. $this->mctProduct->SaveProduct();
  114. $this->CloseSelf(true);
  115. }
  116. public function btnDelete_Click($strFormId, $strControlId, $strParameter) {
  117. // Delegate "Delete" processing to the ProductMetaControl
  118. $this->mctProduct->DeleteProduct();
  119. $this->CloseSelf(true);
  120. }
  121. public function btnCancel_Click($strFormId, $strControlId, $strParameter) {
  122. $this->CloseSelf(false);
  123. }
  124. // Close Myself and Call ClosePanelMethod Callback
  125. protected function CloseSelf($blnChangesMade) {
  126. $strMethod = $this->strClosePanelMethod;
  127. $this->objForm->$strMethod($blnChangesMade);
  128. }
  129. }
  130. ?>