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.

98 lines
4.0 KiB

  1. <?php
  2. /**
  3. * This is a quick-and-dirty draft QPanel object to do Create, Edit, and Delete functionality
  4. * of the ShoppingCartItem class. It uses the code-generated
  5. * ShoppingCartItemMetaControl class, which has meta-methods to help with
  6. * easily creating/defining controls to modify the fields of a ShoppingCartItem 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 shopping_cart_item_edit.php AND
  13. * shopping_cart_item_edit.tpl.php out of this Form Drafts directory.
  14. *
  15. * @package Quinta
  16. * @subpackage AdminUI
  17. */
  18. class ShoppingCartItemEditPanel extends QPanel {
  19. // Local instance of the ShoppingCartItemMetaControl
  20. protected $mctShoppingCartItem;
  21. // Controls for ShoppingCartItem's Data Fields
  22. public $lstShoppingCart;
  23. public $lstProduct;
  24. public $txtQuantity;
  25. // Other ListBoxes (if applicable) via Unique ReverseReferences and ManyToMany References
  26. // Other Controls
  27. public $btnSave;
  28. public $btnDelete;
  29. public $btnCancel;
  30. // Callback
  31. protected $strClosePanelMethod;
  32. public function __construct($objParentObject, $strClosePanelMethod, $intShoppingCartId = null, $intProductId = null, $strControlId = null) {
  33. // Call the Parent
  34. try {
  35. parent::__construct($objParentObject, $strControlId);
  36. } catch (QCallerException $objExc) {
  37. $objExc->IncrementOffset();
  38. throw $objExc;
  39. }
  40. // Setup Callback and Template
  41. $this->strTemplate = 'ShoppingCartItemEditPanel.tpl.php';
  42. $this->strClosePanelMethod = $strClosePanelMethod;
  43. // Construct the ShoppingCartItemMetaControl
  44. // MAKE SURE we specify "$this" as the MetaControl's (and thus all subsequent controls') parent
  45. $this->mctShoppingCartItem = ShoppingCartItemMetaControl::Create($this, $intShoppingCartId, $intProductId);
  46. // Call MetaControl's methods to create qcontrols based on ShoppingCartItem's data fields
  47. $this->lstShoppingCart = $this->mctShoppingCartItem->lstShoppingCart_Create();
  48. $this->lstProduct = $this->mctShoppingCartItem->lstProduct_Create();
  49. $this->txtQuantity = $this->mctShoppingCartItem->txtQuantity_Create();
  50. // Create Buttons and Actions on this Form
  51. $this->btnSave = new QButton($this);
  52. $this->btnSave->Text = QApplication::Translate('Save');
  53. $this->btnSave->AddAction(new QClickEvent(), new QAjaxControlAction($this, 'btnSave_Click'));
  54. $this->btnSave->CausesValidation = $this;
  55. $this->btnCancel = new QButton($this);
  56. $this->btnCancel->Text = QApplication::Translate('Cancel');
  57. $this->btnCancel->AddAction(new QClickEvent(), new QAjaxControlAction($this, 'btnCancel_Click'));
  58. $this->btnDelete = new QButton($this);
  59. $this->btnDelete->Text = QApplication::Translate('Delete');
  60. $this->btnDelete->AddAction(new QClickEvent(), new QConfirmAction(QApplication::Translate('Are you SURE you want to DELETE this') . ' ' . QApplication::Translate('ShoppingCartItem') . '?'));
  61. $this->btnDelete->AddAction(new QClickEvent(), new QAjaxControlAction($this, 'btnDelete_Click'));
  62. $this->btnDelete->Visible = $this->mctShoppingCartItem->EditMode;
  63. }
  64. // Control AjaxAction Event Handlers
  65. public function btnSave_Click($strFormId, $strControlId, $strParameter) {
  66. // Delegate "Save" processing to the ShoppingCartItemMetaControl
  67. $this->mctShoppingCartItem->SaveShoppingCartItem();
  68. $this->CloseSelf(true);
  69. }
  70. public function btnDelete_Click($strFormId, $strControlId, $strParameter) {
  71. // Delegate "Delete" processing to the ShoppingCartItemMetaControl
  72. $this->mctShoppingCartItem->DeleteShoppingCartItem();
  73. $this->CloseSelf(true);
  74. }
  75. public function btnCancel_Click($strFormId, $strControlId, $strParameter) {
  76. $this->CloseSelf(false);
  77. }
  78. // Close Myself and Call ClosePanelMethod Callback
  79. protected function CloseSelf($blnChangesMade) {
  80. $strMethod = $this->strClosePanelMethod;
  81. $this->objForm->$strMethod($blnChangesMade);
  82. }
  83. }
  84. ?>