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.

99 lines
3.9 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 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 Quasi
  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. // Other ListBoxes (if applicable) via Unique ReverseReferences and ManyToMany References
  26. // Other Controls
  27. public $btnSave;
  28. public $btnDelete;
  29. public $btnCancel;
  30. // Callback
  31. protected $strClosePanelMethod;
  32. public function __construct($objParentObject, $strClosePanelMethod, $intProductId = null, $intOrderId = null, $strControlId = null)
  33. {
  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, $intProductId, $intOrderId);
  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. // Create Buttons and Actions on this Form
  52. $this->btnSave = new QButton($this);
  53. $this->btnSave->Text = QApplication::Translate('Save');
  54. $this->btnSave->AddAction(new QClickEvent(), new QAjaxControlAction($this, 'btnSave_Click'));
  55. $this->btnSave->CausesValidation = $this;
  56. $this->btnCancel = new QButton($this);
  57. $this->btnCancel->Text = QApplication::Translate('Cancel');
  58. $this->btnCancel->AddAction(new QClickEvent(), new QAjaxControlAction($this, 'btnCancel_Click'));
  59. $this->btnDelete = new QButton($this);
  60. $this->btnDelete->Text = QApplication::Translate('Delete');
  61. $this->btnDelete->AddAction(new QClickEvent(), new QConfirmAction(QApplication::Translate('Are you SURE you want to DELETE this') . ' ' . QApplication::Translate('OrderItem') . '?'));
  62. $this->btnDelete->AddAction(new QClickEvent(), new QAjaxControlAction($this, 'btnDelete_Click'));
  63. $this->btnDelete->Visible = $this->mctOrderItem->EditMode;
  64. }
  65. // Control AjaxAction Event Handlers
  66. public function btnSave_Click($strFormId, $strControlId, $strParameter) {
  67. // Delegate "Save" processing to the OrderItemMetaControl
  68. $this->mctOrderItem->SaveOrderItem();
  69. $this->CloseSelf(true);
  70. }
  71. public function btnDelete_Click($strFormId, $strControlId, $strParameter) {
  72. // Delegate "Delete" processing to the OrderItemMetaControl
  73. $this->mctOrderItem->DeleteOrderItem();
  74. $this->CloseSelf(true);
  75. }
  76. public function btnCancel_Click($strFormId, $strControlId, $strParameter) {
  77. $this->CloseSelf(false);
  78. }
  79. // Close Myself and Call ClosePanelMethod Callback
  80. protected function CloseSelf($blnChangesMade) {
  81. $strMethod = $this->strClosePanelMethod;
  82. $this->objForm->$strMethod($blnChangesMade);
  83. }
  84. }
  85. ?>