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.

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