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.

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