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.

98 lines
3.7 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 TaxRate class. It uses the code-generated
  5. * TaxRateMetaControl class, which has meta-methods to help with
  6. * easily creating/defining controls to modify the fields of a TaxRate 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 tax_rate_edit.php AND
  13. * tax_rate_edit.tpl.php out of this Form Drafts directory.
  14. *
  15. * @package Quasi
  16. * @subpackage Drafts
  17. */
  18. class TaxRateEditPanel extends QPanel {
  19. // Local instance of the TaxRateMetaControl
  20. protected $mctTaxRate;
  21. // Controls for TaxRate's Data Fields
  22. public $lblId;
  23. public $lstZone;
  24. public $txtRate;
  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, $intId = 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 = 'TaxRateEditPanel.tpl.php';
  42. $this->strClosePanelMethod = $strClosePanelMethod;
  43. // Construct the TaxRateMetaControl
  44. // MAKE SURE we specify "$this" as the MetaControl's (and thus all subsequent controls') parent
  45. $this->mctTaxRate = TaxRateMetaControl::Create($this, $intId);
  46. // Call MetaControl's methods to create qcontrols based on TaxRate's data fields
  47. $this->lblId = $this->mctTaxRate->lblId_Create();
  48. $this->lstZone = $this->mctTaxRate->lstZone_Create();
  49. $this->txtRate = $this->mctTaxRate->txtRate_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('TaxRate') . '?'));
  61. $this->btnDelete->AddAction(new QClickEvent(), new QAjaxControlAction($this, 'btnDelete_Click'));
  62. $this->btnDelete->Visible = $this->mctTaxRate->EditMode;
  63. }
  64. // Control AjaxAction Event Handlers
  65. public function btnSave_Click($strFormId, $strControlId, $strParameter) {
  66. // Delegate "Save" processing to the TaxRateMetaControl
  67. $this->mctTaxRate->SaveTaxRate();
  68. $this->CloseSelf(true);
  69. }
  70. public function btnDelete_Click($strFormId, $strControlId, $strParameter) {
  71. // Delegate "Delete" processing to the TaxRateMetaControl
  72. $this->mctTaxRate->DeleteTaxRate();
  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. ?>