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.

116 lines
4.8 KiB

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