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.

158 lines
5.9 KiB

13 years ago
  1. <?php
  2. if(!defined('QUASICMS') ) die("No quasi.");
  3. if (!defined("ACCOUNTPERSONEDITPANEL.CLASS.PHP")){
  4. define("ACCOUNTPERSONEDITPANEL.CLASS.PHP",1);
  5. /**
  6. * AccountPersonEditPanel - provides a panel for user viewing and modification of a Person
  7. *
  8. *@author Erik Winn <erikwinnmail@yahoo.com>
  9. *
  10. *
  11. * $Id: AccountPersonEditPanel.class.php 286 2008-10-10 23:33:36Z erikwinn $
  12. *@version 0.1
  13. *
  14. *@copyright (C) 2008 by Erik Winn
  15. *@license GPL v.2
  16. This program is free software; you can redistribute it and/or modify
  17. it under the terms of the GNU General Public License as published by
  18. the Free Software Foundation; either version 2 of the License, or
  19. (at your option) any later version.
  20. This program is distributed in the hope that it will be useful,
  21. but WITHOUT ANY WARRANTY; without even the implied warranty of
  22. MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  23. GNU General Public License for more details.
  24. You should have received a copy of the GNU General Public License
  25. along with this program; if not, write to the Free Software
  26. Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111 USA
  27. *
  28. * @package Quasi
  29. * @subpackage Classes
  30. */
  31. class AccountPersonEditPanel extends QPanel
  32. {
  33. // Local instance of the PersonMetaControl
  34. protected $mctPerson;
  35. protected $objPerson;
  36. protected $objControlBlock;
  37. // Controls for Person's Data Fields
  38. public $txtNamePrefix;
  39. public $txtFirstName;
  40. public $txtMiddleName;
  41. public $txtLastName;
  42. public $txtNameSuffix;
  43. public $txtNickName;
  44. public $txtEmailAddress;
  45. public $txtPhoneNumber;
  46. public $txtAvatarUri;
  47. public $txtCompanyName;
  48. public $lstUsergroups;
  49. // Other Controls
  50. public $btnSave;
  51. public $btnDelete;
  52. public $btnCancel;
  53. // Callback
  54. protected $strClosePanelMethod;
  55. public function __construct($objParentObject,
  56. $objControlBlock,
  57. $strClosePanelMethod,
  58. $intId = null,
  59. $strControlId = null)
  60. {
  61. try {
  62. parent::__construct($objParentObject, $strControlId);
  63. } catch (QCallerException $objExc) {
  64. $objExc->IncrementOffset();
  65. throw $objExc;
  66. }
  67. $this->objControlBlock =& $objControlBlock;
  68. $this->strTemplate = __QUASI_CORE_TEMPLATES__ . '/AccountPersonEditPanel.tpl.php';
  69. $this->strClosePanelMethod = $strClosePanelMethod;
  70. $this->mctPerson = PersonMetaControl::Create($this, $intId);
  71. $this->objPerson = $this->mctPerson->Person;
  72. $this->txtNamePrefix = $this->mctPerson->txtNamePrefix_Create();
  73. $this->txtFirstName = $this->mctPerson->txtFirstName_Create();
  74. $this->txtMiddleName = $this->mctPerson->txtMiddleName_Create();
  75. $this->txtLastName = $this->mctPerson->txtLastName_Create();
  76. $this->txtNameSuffix = $this->mctPerson->txtNameSuffix_Create();
  77. $this->txtNickName = $this->mctPerson->txtNickName_Create();
  78. $this->txtEmailAddress = $this->mctPerson->txtEmailAddress_Create();
  79. $this->txtEmailAddress->Required = false;
  80. $this->txtPhoneNumber = $this->mctPerson->txtPhoneNumber_Create();
  81. $this->txtAvatarUri = $this->mctPerson->txtAvatarUri_Create();
  82. $this->txtCompanyName = $this->mctPerson->txtCompanyName_Create();
  83. $this->lstUsergroups = $this->mctPerson->lstUsergroups_Create();
  84. $this->btnSave = new QButton($this);
  85. $this->btnSave->Text = QApplication::Translate('Save');
  86. if(IndexPage::$blnAjaxOk)
  87. $this->btnSave->AddAction(new QClickEvent(), new QAjaxControlAction($this, 'btnSave_Click'));
  88. else
  89. $this->btnSave->AddAction(new QClickEvent(), new QServerControlAction($this, 'btnSave_Click'));
  90. $this->btnSave->CausesValidation = $this;
  91. $this->btnCancel = new QButton($this);
  92. $this->btnCancel->Text = QApplication::Translate('Cancel');
  93. if(IndexPage::$blnAjaxOk)
  94. $this->btnCancel->AddAction(new QClickEvent(), new QAjaxControlAction($this, 'btnCancel_Click'));
  95. else
  96. $this->btnCancel->AddAction(new QClickEvent(), new QServerControlAction($this, 'btnCancel_Click'));
  97. $this->btnDelete = new QButton($this);
  98. $this->btnDelete->Text = QApplication::Translate('Delete');
  99. $strDeleteMsg = QApplication::Translate('Are you SURE you want to DELETE this Person') . '?';
  100. $this->btnDelete->AddAction(new QClickEvent(), new QConfirmAction($strDeleteMsg));
  101. if(IndexPage::$blnAjaxOk)
  102. $this->btnDelete->AddAction(new QClickEvent(), new QAjaxControlAction($this, 'btnDelete_Click'));
  103. else
  104. $this->btnDelete->AddAction(new QClickEvent(), new QServerControlAction($this, 'btnDelete_Click'));
  105. $this->btnDelete->Visible = $this->mctPerson->EditMode;
  106. }
  107. public function btnSave_Click($strFormId, $strControlId, $strParameter)
  108. {
  109. $this->objPerson->OwnerPersonId = $this->objControlBlock->Account->PersonId;
  110. $this->objPerson->IsVirtual = true;
  111. if( '' == $this->txtEmailAddress->Text )
  112. $this->txtEmailAddress->Text = $this->objPerson->EmailAddress;
  113. $this->mctPerson->SavePerson();
  114. $this->CloseSelf(true);
  115. }
  116. public function btnDelete_Click($strFormId, $strControlId, $strParameter)
  117. {
  118. $this->mctPerson->DeletePerson();
  119. $this->CloseSelf(true);
  120. }
  121. public function btnCancel_Click($strFormId, $strControlId, $strParameter) {
  122. $this->CloseSelf(false);
  123. }
  124. // Close Myself and Call ClosePanelMethod Callback
  125. protected function CloseSelf($blnChangesMade) {
  126. $strMethod = $this->strClosePanelMethod;
  127. $this->objControlBlock->$strMethod($blnChangesMade);
  128. }
  129. }//end class
  130. }//end define
  131. ?>