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.

100 lines
3.9 KiB

  1. <?php
  2. /**
  3. * This is a quick-and-dirty draft QPanel object to do Create, Edit, and Delete functionality
  4. * of the OrderItem class. It uses the code-generated
  5. * OrderItemMetaControl class, which has meta-methods to help with
  6. * easily creating/defining controls to modify the fields of a OrderItem 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_item_edit.php AND
  13. * order_item_edit.tpl.php out of this Form Drafts directory.
  14. *
  15. * @package Quinta
  16. * @subpackage Admin
  17. */
  18. class OrderItemEditPanel extends QPanel {
  19. // Local instance of the OrderItemMetaControl
  20. protected $mctOrderItem;
  21. // Controls for OrderItem's Data Fields
  22. public $lblProduct;
  23. public $lblOrder;
  24. public $txtQuantity;
  25. public $lstStatus;
  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, $intOrderId = null, $intProductId = 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 = 'OrderItemEditPanel.tpl.php';
  43. $this->strClosePanelMethod = $strClosePanelMethod;
  44. // Construct the OrderItemMetaControl
  45. // MAKE SURE we specify "$this" as the MetaControl's (and thus all subsequent controls') parent
  46. $this->mctOrderItem = OrderItemMetaControl::Create($this, $intOrderId, $intProductId);
  47. // Call MetaControl's methods to create qcontrols based on OrderItem's data fields
  48. $this->lblProduct = $this->mctOrderItem->lblProductId_Create();
  49. $this->lblOrder = $this->mctOrderItem->lblOrderId_Create();
  50. $this->txtQuantity = $this->mctOrderItem->txtQuantity_Create();
  51. $this->lstStatus = $this->mctOrderItem->lstStatus_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('OrderItem') . '?'));
  63. $this->btnDelete->AddAction(new QClickEvent(), new QAjaxControlAction($this, 'btnDelete_Click'));
  64. $this->btnDelete->Visible = $this->mctOrderItem->EditMode;
  65. }
  66. // Control AjaxAction Event Handlers
  67. public function btnSave_Click($strFormId, $strControlId, $strParameter) {
  68. // Delegate "Save" processing to the OrderItemMetaControl
  69. $this->mctOrderItem->SaveOrderItem();
  70. $this->CloseSelf(true);
  71. }
  72. public function btnDelete_Click($strFormId, $strControlId, $strParameter) {
  73. // Delegate "Delete" processing to the OrderItemMetaControl
  74. $this->mctOrderItem->DeleteOrderItem();
  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. ?>