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.

138 lines
5.6 KiB

  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 Quinta
  16. * @subpackage AdminUI
  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. // Other ListBoxes (if applicable) via Unique ReverseReferences and ManyToMany References
  43. public $lstProductCategories;
  44. public $lstParentProductsAsRelated;
  45. public $lstProductsAsRelated;
  46. // Other Controls
  47. public $btnSave;
  48. public $btnDelete;
  49. public $btnCancel;
  50. // Callback
  51. protected $strClosePanelMethod;
  52. public function __construct($objParentObject, $strClosePanelMethod, $intId = null, $strControlId = null) {
  53. // Call the Parent
  54. try {
  55. parent::__construct($objParentObject, $strControlId);
  56. } catch (QCallerException $objExc) {
  57. $objExc->IncrementOffset();
  58. throw $objExc;
  59. }
  60. // Setup Callback and Template
  61. $this->strTemplate = 'ProductEditPanel.tpl.php';
  62. $this->strClosePanelMethod = $strClosePanelMethod;
  63. // Construct the ProductMetaControl
  64. // MAKE SURE we specify "$this" as the MetaControl's (and thus all subsequent controls') parent
  65. $this->mctProduct = ProductMetaControl::Create($this, $intId);
  66. // Call MetaControl's methods to create qcontrols based on Product's data fields
  67. $this->lblId = $this->mctProduct->lblId_Create();
  68. $this->lblManufacturer = $this->mctProduct->lblManufacturerId_Create();
  69. $this->lblSupplier = $this->mctProduct->lblSupplierId_Create();
  70. $this->lblCreationDate = $this->mctProduct->lblCreationDate_Create();
  71. $this->txtName = $this->mctProduct->txtName_Create();
  72. $this->txtModel = $this->mctProduct->txtModel_Create();
  73. $this->txtShortDescription = $this->mctProduct->txtShortDescription_Create();
  74. $this->txtLongDescription = $this->mctProduct->txtLongDescription_Create();
  75. $this->txtMsrp = $this->mctProduct->txtMsrp_Create();
  76. $this->txtWholesalePrice = $this->mctProduct->txtWholesalePrice_Create();
  77. $this->txtRetailPrice = $this->mctProduct->txtRetailPrice_Create();
  78. $this->txtCost = $this->mctProduct->txtCost_Create();
  79. $this->txtWeight = $this->mctProduct->txtWeight_Create();
  80. $this->txtHeight = $this->mctProduct->txtHeight_Create();
  81. $this->txtWidth = $this->mctProduct->txtWidth_Create();
  82. $this->txtDepth = $this->mctProduct->txtDepth_Create();
  83. $this->chkIsVirtual = $this->mctProduct->chkIsVirtual_Create();
  84. $this->lstType = $this->mctProduct->lstType_Create();
  85. $this->lstStatus = $this->mctProduct->lstStatus_Create();
  86. $this->txtViewCount = $this->mctProduct->txtViewCount_Create();
  87. $this->lstProductCategories = $this->mctProduct->lstProductCategories_Create();
  88. $this->lstParentProductsAsRelated = $this->mctProduct->lstParentProductsAsRelated_Create();
  89. $this->lstProductsAsRelated = $this->mctProduct->lstProductsAsRelated_Create();
  90. // Create Buttons and Actions on this Form
  91. $this->btnSave = new QButton($this);
  92. $this->btnSave->Text = QApplication::Translate('Save');
  93. $this->btnSave->AddAction(new QClickEvent(), new QAjaxControlAction($this, 'btnSave_Click'));
  94. $this->btnSave->CausesValidation = $this;
  95. $this->btnCancel = new QButton($this);
  96. $this->btnCancel->Text = QApplication::Translate('Cancel');
  97. $this->btnCancel->AddAction(new QClickEvent(), new QAjaxControlAction($this, 'btnCancel_Click'));
  98. $this->btnDelete = new QButton($this);
  99. $this->btnDelete->Text = QApplication::Translate('Delete');
  100. $this->btnDelete->AddAction(new QClickEvent(), new QConfirmAction(QApplication::Translate('Are you SURE you want to DELETE this') . ' ' . QApplication::Translate('Product') . '?'));
  101. $this->btnDelete->AddAction(new QClickEvent(), new QAjaxControlAction($this, 'btnDelete_Click'));
  102. $this->btnDelete->Visible = $this->mctProduct->EditMode;
  103. }
  104. // Control AjaxAction Event Handlers
  105. public function btnSave_Click($strFormId, $strControlId, $strParameter) {
  106. // Delegate "Save" processing to the ProductMetaControl
  107. $this->mctProduct->SaveProduct();
  108. $this->CloseSelf(true);
  109. }
  110. public function btnDelete_Click($strFormId, $strControlId, $strParameter) {
  111. // Delegate "Delete" processing to the ProductMetaControl
  112. $this->mctProduct->DeleteProduct();
  113. $this->CloseSelf(true);
  114. }
  115. public function btnCancel_Click($strFormId, $strControlId, $strParameter) {
  116. $this->CloseSelf(false);
  117. }
  118. // Close Myself and Call ClosePanelMethod Callback
  119. protected function CloseSelf($blnChangesMade) {
  120. $strMethod = $this->strClosePanelMethod;
  121. $this->objForm->$strMethod($blnChangesMade);
  122. }
  123. }
  124. ?>