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.

122 lines
4.8 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 Person class. It uses the code-generated
  5. * PersonMetaControl class, which has meta-methods to help with
  6. * easily creating/defining controls to modify the fields of a Person 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 person_edit.php AND
  13. * person_edit.tpl.php out of this Form Drafts directory.
  14. *
  15. * @package Quasi
  16. * @subpackage Drafts
  17. */
  18. class PersonEditPanel extends QPanel {
  19. // Local instance of the PersonMetaControl
  20. protected $mctPerson;
  21. // Controls for Person's Data Fields
  22. public $lblId;
  23. public $txtNamePrefix;
  24. public $txtFirstName;
  25. public $txtMiddleName;
  26. public $txtLastName;
  27. public $txtNameSuffix;
  28. public $txtNickName;
  29. public $txtEmailAddress;
  30. public $txtPhoneNumber;
  31. public $txtAvatarUri;
  32. public $txtCompanyName;
  33. public $lstOwnerPerson;
  34. public $chkIsVirtual;
  35. // Other ListBoxes (if applicable) via Unique ReverseReferences and ManyToMany References
  36. public $lstAccount;
  37. public $lstUsergroups;
  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 = 'PersonEditPanel.tpl.php';
  54. $this->strClosePanelMethod = $strClosePanelMethod;
  55. // Construct the PersonMetaControl
  56. // MAKE SURE we specify "$this" as the MetaControl's (and thus all subsequent controls') parent
  57. $this->mctPerson = PersonMetaControl::Create($this, $intId);
  58. // Call MetaControl's methods to create qcontrols based on Person's data fields
  59. $this->lblId = $this->mctPerson->lblId_Create();
  60. $this->txtNamePrefix = $this->mctPerson->txtNamePrefix_Create();
  61. $this->txtFirstName = $this->mctPerson->txtFirstName_Create();
  62. $this->txtMiddleName = $this->mctPerson->txtMiddleName_Create();
  63. $this->txtLastName = $this->mctPerson->txtLastName_Create();
  64. $this->txtNameSuffix = $this->mctPerson->txtNameSuffix_Create();
  65. $this->txtNickName = $this->mctPerson->txtNickName_Create();
  66. $this->txtEmailAddress = $this->mctPerson->txtEmailAddress_Create();
  67. $this->txtPhoneNumber = $this->mctPerson->txtPhoneNumber_Create();
  68. $this->txtAvatarUri = $this->mctPerson->txtAvatarUri_Create();
  69. $this->txtCompanyName = $this->mctPerson->txtCompanyName_Create();
  70. $this->lstOwnerPerson = $this->mctPerson->lstOwnerPerson_Create();
  71. $this->chkIsVirtual = $this->mctPerson->chkIsVirtual_Create();
  72. $this->lstAccount = $this->mctPerson->lstAccount_Create();
  73. $this->lstUsergroups = $this->mctPerson->lstUsergroups_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('Person') . '?'));
  85. $this->btnDelete->AddAction(new QClickEvent(), new QAjaxControlAction($this, 'btnDelete_Click'));
  86. $this->btnDelete->Visible = $this->mctPerson->EditMode;
  87. }
  88. // Control AjaxAction Event Handlers
  89. public function btnSave_Click($strFormId, $strControlId, $strParameter) {
  90. // Delegate "Save" processing to the PersonMetaControl
  91. $this->mctPerson->SavePerson();
  92. $this->CloseSelf(true);
  93. }
  94. public function btnDelete_Click($strFormId, $strControlId, $strParameter) {
  95. // Delegate "Delete" processing to the PersonMetaControl
  96. $this->mctPerson->DeletePerson();
  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. ?>