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.

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