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.

114 lines
4.7 KiB

12 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 ShippingMethod class. It uses the code-generated
  5. * ShippingMethodMetaControl class, which has meta-methods to help with
  6. * easily creating/defining controls to modify the fields of a ShippingMethod 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_method_edit.php AND
  13. * shipping_method_edit.tpl.php out of this Form Drafts directory.
  14. *
  15. * @package Quasi
  16. * @subpackage Drafts
  17. */
  18. class ShippingMethodEditPanel extends QPanel {
  19. // Local instance of the ShippingMethodMetaControl
  20. protected $mctShippingMethod;
  21. // Controls for ShippingMethod's Data Fields
  22. public $lblId;
  23. public $txtTitle;
  24. public $txtCarrier;
  25. public $txtServiceType;
  26. public $txtClassName;
  27. public $txtTransitTime;
  28. public $txtDescription;
  29. public $chkActive;
  30. public $chkIsInternational;
  31. public $chkTestMode;
  32. public $txtSortOrder;
  33. // Other ListBoxes (if applicable) via Unique ReverseReferences and ManyToMany References
  34. // Other Controls
  35. public $btnSave;
  36. public $btnDelete;
  37. public $btnCancel;
  38. // Callback
  39. protected $strClosePanelMethod;
  40. public function __construct($objParentObject, $strClosePanelMethod, $intId = null, $strControlId = null) {
  41. // Call the Parent
  42. try {
  43. parent::__construct($objParentObject, $strControlId);
  44. } catch (QCallerException $objExc) {
  45. $objExc->IncrementOffset();
  46. throw $objExc;
  47. }
  48. // Setup Callback and Template
  49. $this->strTemplate = 'ShippingMethodEditPanel.tpl.php';
  50. $this->strClosePanelMethod = $strClosePanelMethod;
  51. // Construct the ShippingMethodMetaControl
  52. // MAKE SURE we specify "$this" as the MetaControl's (and thus all subsequent controls') parent
  53. $this->mctShippingMethod = ShippingMethodMetaControl::Create($this, $intId);
  54. // Call MetaControl's methods to create qcontrols based on ShippingMethod's data fields
  55. $this->lblId = $this->mctShippingMethod->lblId_Create();
  56. $this->txtTitle = $this->mctShippingMethod->txtTitle_Create();
  57. $this->txtCarrier = $this->mctShippingMethod->txtCarrier_Create();
  58. $this->txtServiceType = $this->mctShippingMethod->txtServiceType_Create();
  59. $this->txtClassName = $this->mctShippingMethod->txtClassName_Create();
  60. $this->txtTransitTime = $this->mctShippingMethod->txtTransitTime_Create();
  61. $this->txtDescription = $this->mctShippingMethod->txtDescription_Create();
  62. $this->chkActive = $this->mctShippingMethod->chkActive_Create();
  63. $this->chkIsInternational = $this->mctShippingMethod->chkIsInternational_Create();
  64. $this->chkTestMode = $this->mctShippingMethod->chkTestMode_Create();
  65. $this->txtSortOrder = $this->mctShippingMethod->txtSortOrder_Create();
  66. // Create Buttons and Actions on this Form
  67. $this->btnSave = new QButton($this);
  68. $this->btnSave->Text = QApplication::Translate('Save');
  69. $this->btnSave->AddAction(new QClickEvent(), new QAjaxControlAction($this, 'btnSave_Click'));
  70. $this->btnSave->CausesValidation = $this;
  71. $this->btnCancel = new QButton($this);
  72. $this->btnCancel->Text = QApplication::Translate('Cancel');
  73. $this->btnCancel->AddAction(new QClickEvent(), new QAjaxControlAction($this, 'btnCancel_Click'));
  74. $this->btnDelete = new QButton($this);
  75. $this->btnDelete->Text = QApplication::Translate('Delete');
  76. $this->btnDelete->AddAction(new QClickEvent(), new QConfirmAction(QApplication::Translate('Are you SURE you want to DELETE this') . ' ' . QApplication::Translate('ShippingMethod') . '?'));
  77. $this->btnDelete->AddAction(new QClickEvent(), new QAjaxControlAction($this, 'btnDelete_Click'));
  78. $this->btnDelete->Visible = $this->mctShippingMethod->EditMode;
  79. }
  80. // Control AjaxAction Event Handlers
  81. public function btnSave_Click($strFormId, $strControlId, $strParameter) {
  82. // Delegate "Save" processing to the ShippingMethodMetaControl
  83. $this->mctShippingMethod->SaveShippingMethod();
  84. $this->CloseSelf(true);
  85. }
  86. public function btnDelete_Click($strFormId, $strControlId, $strParameter) {
  87. // Delegate "Delete" processing to the ShippingMethodMetaControl
  88. $this->mctShippingMethod->DeleteShippingMethod();
  89. $this->CloseSelf(true);
  90. }
  91. public function btnCancel_Click($strFormId, $strControlId, $strParameter) {
  92. $this->CloseSelf(false);
  93. }
  94. // Close Myself and Call ClosePanelMethod Callback
  95. protected function CloseSelf($blnChangesMade) {
  96. $strMethod = $this->strClosePanelMethod;
  97. $this->objForm->$strMethod($blnChangesMade);
  98. }
  99. }
  100. ?>