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.

135 lines
4.5 KiB

  1. <?php
  2. if(!defined('QUINTACMS') ) die("No quinta.");
  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 <sidewalksoftware@gmail.com>
  9. *
  10. *@version 0.3
  11. *
  12. * @package Quinta
  13. * @subpackage Classes
  14. */
  15. class AccountPersonEditPanel extends QPanel{
  16. // Local instance of the PersonMetaControl
  17. protected $mctPerson;
  18. protected $objPerson;
  19. protected $objControlBlock;
  20. // Controls for Person's Data Fields
  21. public $txtNamePrefix;
  22. public $txtFirstName;
  23. public $txtMiddleName;
  24. public $txtLastName;
  25. public $txtNameSuffix;
  26. public $txtNickName;
  27. // public $txtEmailAddress;
  28. // public $txtPhoneNumber;
  29. public $txtAvatarUri;
  30. public $txtCompanyName;
  31. public $lstUsergroups;
  32. // Other Controls
  33. public $btnSave;
  34. public $btnDelete;
  35. public $btnCancel;
  36. // Callback
  37. protected $strClosePanelMethod;
  38. public function __construct($objParentObject,
  39. $objControlBlock,
  40. $strClosePanelMethod,
  41. $intId = null,
  42. $strControlId = null)
  43. {
  44. try {
  45. parent::__construct($objParentObject, $strControlId);
  46. } catch (QCallerException $objExc) {
  47. $objExc->IncrementOffset();
  48. throw $objExc;
  49. }
  50. $this->objControlBlock =& $objControlBlock;
  51. $this->strTemplate = __QUINTA_CORE_VIEWS__ . '/AccountPersonEditPanel.tpl.php';
  52. $this->strClosePanelMethod = $strClosePanelMethod;
  53. $this->mctPerson = PersonMetaControl::Create($this, $intId);
  54. $this->objPerson = $this->mctPerson->Person;
  55. $this->txtNamePrefix = $this->mctPerson->txtNamePrefix_Create();
  56. $this->txtFirstName = $this->mctPerson->txtFirstName_Create();
  57. $this->txtMiddleName = $this->mctPerson->txtMiddleName_Create();
  58. $this->txtLastName = $this->mctPerson->txtLastName_Create();
  59. $this->txtNameSuffix = $this->mctPerson->txtNameSuffix_Create();
  60. $this->txtNickName = $this->mctPerson->txtNickName_Create();
  61. // $this->txtEmailAddress = $this->mctPerson->txtEmailAddress_Create();
  62. // $this->txtEmailAddress->Required = false;
  63. //
  64. // $this->txtPhoneNumber = $this->mctPerson->txtPhoneNumber_Create();
  65. $this->txtAvatarUri = $this->mctPerson->txtAvatarUri_Create();
  66. $this->txtCompanyName = $this->mctPerson->txtCompanyName_Create();
  67. $this->lstUsergroups = $this->mctPerson->lstUsergroups_Create();
  68. $this->btnSave = new QButton($this);
  69. $this->btnSave->Text = QApplication::Translate('Save');
  70. if(IndexPage::$blnAjaxOk)
  71. $this->btnSave->AddAction(new QClickEvent(), new QAjaxControlAction($this, 'btnSave_Click'));
  72. else
  73. $this->btnSave->AddAction(new QClickEvent(), new QServerControlAction($this, 'btnSave_Click'));
  74. $this->btnSave->CausesValidation = $this;
  75. $this->btnCancel = new QButton($this);
  76. $this->btnCancel->Text = QApplication::Translate('Cancel');
  77. if(IndexPage::$blnAjaxOk)
  78. $this->btnCancel->AddAction(new QClickEvent(), new QAjaxControlAction($this, 'btnCancel_Click'));
  79. else
  80. $this->btnCancel->AddAction(new QClickEvent(), new QServerControlAction($this, 'btnCancel_Click'));
  81. $this->btnDelete = new QButton($this);
  82. $this->btnDelete->Text = QApplication::Translate('Delete');
  83. $strDeleteMsg = QApplication::Translate('Are you SURE you want to DELETE this Person') . '?';
  84. $this->btnDelete->AddAction(new QClickEvent(), new QConfirmAction($strDeleteMsg));
  85. if(IndexPage::$blnAjaxOk)
  86. $this->btnDelete->AddAction(new QClickEvent(), new QAjaxControlAction($this, 'btnDelete_Click'));
  87. else
  88. $this->btnDelete->AddAction(new QClickEvent(), new QServerControlAction($this, 'btnDelete_Click'));
  89. $this->btnDelete->Visible = $this->mctPerson->EditMode;
  90. }
  91. public function btnSave_Click($strFormId, $strControlId, $strParameter){
  92. $this->objPerson->OwnerPersonId = $this->objControlBlock->Account->PersonId;
  93. $this->objPerson->IsVirtual = true;
  94. if( '' == $this->txtEmailAddress->Text )
  95. $this->txtEmailAddress->Text = $this->objPerson->EmailAddress;
  96. $this->mctPerson->SavePerson();
  97. $this->CloseSelf(true);
  98. }
  99. public function btnDelete_Click($strFormId, $strControlId, $strParameter){
  100. $this->mctPerson->DeletePerson();
  101. $this->CloseSelf(true);
  102. }
  103. public function btnCancel_Click($strFormId, $strControlId, $strParameter) {
  104. $this->CloseSelf(false);
  105. }
  106. // Close Myself and Call ClosePanelMethod Callback
  107. protected function CloseSelf($blnChangesMade) {
  108. $strMethod = $this->strClosePanelMethod;
  109. $this->objControlBlock->$strMethod($blnChangesMade);
  110. }
  111. }//end class
  112. }//end define
  113. ?>