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.

122 lines
4.7 KiB

  1. <?php
  2. /**
  3. * This is a quick-and-dirty draft QPanel object to do Create, Edit, and Delete functionality
  4. * of the Address class. It uses the code-generated
  5. * AddressMetaControl class, which has meta-methods to help with
  6. * easily creating/defining controls to modify the fields of a Address 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 address_edit.php AND
  13. * address_edit.tpl.php out of this Form Drafts directory.
  14. *
  15. * @package Quinta
  16. * @subpackage AdminUI
  17. */
  18. class AddressEditPanel extends QPanel {
  19. // Local instance of the AddressMetaControl
  20. protected $mctAddress;
  21. // Controls for Address's Data Fields
  22. public $lblId;
  23. public $txtTitle;
  24. public $lstPerson;
  25. public $txtStreet1;
  26. public $txtStreet2;
  27. public $txtSuburb;
  28. public $txtCity;
  29. public $txtCounty;
  30. public $lstZone;
  31. public $lstCountry;
  32. public $txtPostalCode;
  33. public $chkIsCurrent;
  34. public $lstType;
  35. public $lblCreationDate;
  36. public $lblLastModification;
  37. // Other ListBoxes (if applicable) via Unique ReverseReferences and ManyToMany References
  38. // Other Controls
  39. public $btnSave;
  40. public $btnDelete;
  41. public $btnCancel;
  42. // Callback
  43. protected $strClosePanelMethod;
  44. public function __construct($objParentObject, $strClosePanelMethod, $intId = null, $strControlId = null) {
  45. // Call the Parent
  46. try {
  47. parent::__construct($objParentObject, $strControlId);
  48. } catch (QCallerException $objExc) {
  49. $objExc->IncrementOffset();
  50. throw $objExc;
  51. }
  52. // Setup Callback and Template
  53. $this->strTemplate = 'AddressEditPanel.tpl.php';
  54. $this->strClosePanelMethod = $strClosePanelMethod;
  55. // Construct the AddressMetaControl
  56. // MAKE SURE we specify "$this" as the MetaControl's (and thus all subsequent controls') parent
  57. $this->mctAddress = AddressMetaControl::Create($this, $intId);
  58. // Call MetaControl's methods to create qcontrols based on Address's data fields
  59. $this->lblId = $this->mctAddress->lblId_Create();
  60. $this->txtTitle = $this->mctAddress->txtTitle_Create();
  61. $this->lstPerson = $this->mctAddress->lstPerson_Create();
  62. $this->txtStreet1 = $this->mctAddress->txtStreet1_Create();
  63. $this->txtStreet2 = $this->mctAddress->txtStreet2_Create();
  64. $this->txtSuburb = $this->mctAddress->txtSuburb_Create();
  65. $this->txtCity = $this->mctAddress->txtCity_Create();
  66. $this->txtCounty = $this->mctAddress->txtCounty_Create();
  67. $this->lstZone = $this->mctAddress->lstZone_Create();
  68. $this->lstCountry = $this->mctAddress->lstCountry_Create();
  69. $this->txtPostalCode = $this->mctAddress->txtPostalCode_Create();
  70. $this->chkIsCurrent = $this->mctAddress->chkIsCurrent_Create();
  71. $this->lstType = $this->mctAddress->lstType_Create();
  72. $this->lblCreationDate = $this->mctAddress->lblCreationDate_Create();
  73. $this->lblLastModification = $this->mctAddress->lblLastModification_Create();
  74. // Create Buttons and Actions on this Form
  75. $this->btnSave = new QButton($this);
  76. $this->btnSave->Text = QApplication::Translate('Save');
  77. $this->btnSave->AddAction(new QClickEvent(), new QAjaxControlAction($this, 'btnSave_Click'));
  78. $this->btnSave->CausesValidation = $this;
  79. $this->btnCancel = new QButton($this);
  80. $this->btnCancel->Text = QApplication::Translate('Cancel');
  81. $this->btnCancel->AddAction(new QClickEvent(), new QAjaxControlAction($this, 'btnCancel_Click'));
  82. $this->btnDelete = new QButton($this);
  83. $this->btnDelete->Text = QApplication::Translate('Delete');
  84. $this->btnDelete->AddAction(new QClickEvent(), new QConfirmAction(QApplication::Translate('Are you SURE you want to DELETE this') . ' ' . QApplication::Translate('Address') . '?'));
  85. $this->btnDelete->AddAction(new QClickEvent(), new QAjaxControlAction($this, 'btnDelete_Click'));
  86. $this->btnDelete->Visible = $this->mctAddress->EditMode;
  87. }
  88. // Control AjaxAction Event Handlers
  89. public function btnSave_Click($strFormId, $strControlId, $strParameter) {
  90. // Delegate "Save" processing to the AddressMetaControl
  91. $this->mctAddress->SaveAddress();
  92. $this->CloseSelf(true);
  93. }
  94. public function btnDelete_Click($strFormId, $strControlId, $strParameter) {
  95. // Delegate "Delete" processing to the AddressMetaControl
  96. $this->mctAddress->DeleteAddress();
  97. $this->CloseSelf(true);
  98. }
  99. public function btnCancel_Click($strFormId, $strControlId, $strParameter) {
  100. $this->CloseSelf(false);
  101. }
  102. // Close Myself and Call ClosePanelMethod Callback
  103. protected function CloseSelf($blnChangesMade) {
  104. $strMethod = $this->strClosePanelMethod;
  105. $this->objForm->$strMethod($blnChangesMade);
  106. }
  107. }
  108. ?>