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.

169 lines
7.0 KiB

13 years ago
  1. <?php
  2. /**
  3. * This is the abstract Panel class for the List All functionality
  4. * of the Account class. This code-generated class
  5. * contains a datagrid to display an HTML page that can
  6. * list a collection of Account objects. It includes
  7. * functionality to perform pagination and sorting on columns.
  8. *
  9. * To take advantage of some (or all) of these control objects, you
  10. * must create a new QPanel which extends this AccountListPanelBase
  11. * class.
  12. *
  13. * Any and all changes to this file will be overwritten with any subsequent re-
  14. * code generation.
  15. *
  16. * @package Quasi
  17. * @subpackage Drafts
  18. *
  19. */
  20. class AccountListPanel extends QPanel {
  21. // Local instance of the Meta DataGrid to list Accounts
  22. public $dtgAccounts;
  23. // Other public QControls in this panel
  24. public $btnCreateNew;
  25. public $pxyEdit;
  26. public $objPaginator;
  27. public $lblMessage;
  28. public $txtNameSearch;
  29. public $txtNumberSearch;
  30. // Callback Method Names
  31. protected $strSetEditPanelMethod;
  32. protected $strCloseEditPanelMethod;
  33. public function __construct($objParentObject, $strSetEditPanelMethod, $strCloseEditPanelMethod, $strControlId = null) {
  34. // Call the Parent
  35. try {
  36. parent::__construct($objParentObject, $strControlId);
  37. } catch (QCallerException $objExc) {
  38. $objExc->IncrementOffset();
  39. throw $objExc;
  40. }
  41. // Record Method Callbacks
  42. $this->strSetEditPanelMethod = $strSetEditPanelMethod;
  43. $this->strCloseEditPanelMethod = $strCloseEditPanelMethod;
  44. // Setup the Template
  45. $this->Template = 'AccountListPanel.tpl.php';
  46. //messages (eg. Name not found ..)
  47. $this->lblMessage = new QLabel($this);
  48. // a search field for Account by name ..
  49. $this->txtNameSearch = new QTextBox($this);
  50. $this->txtNameSearch->AddAction(new QEnterKeyEvent(), new QServerControlAction($this, 'txtNameSearch_Click'));
  51. $this->txtNameSearch->Name = 'Search by Name:';
  52. // a search field for Account by number ..
  53. $this->txtNumberSearch = new QIntegerTextBox($this);
  54. $this->txtNumberSearch->AddAction(new QEnterKeyEvent(), new QServerControlAction($this, 'txtNumberSearch_Click'));
  55. $this->txtNumberSearch->Name = 'Search by Number:';
  56. $this->txtNumberSearch->CausesValidation = $this->txtNumberSearch;
  57. // Instantiate the Meta DataGrid
  58. $this->dtgAccounts = new AccountDataGrid($this);
  59. $this->dtgAccounts->CssClass = 'datagrid';
  60. $this->dtgAccounts->AlternateRowStyle->CssClass = 'alternate';
  61. $this->objPaginator = new QPaginator($this->dtgAccounts);
  62. $this->dtgAccounts->Paginator = $this->objPaginator;
  63. $this->dtgAccounts->ItemsPerPage = 25;
  64. // Create an Edit Column
  65. $this->pxyEdit = new QControlProxy($this);
  66. $this->pxyEdit->AddAction(new QClickEvent(), new QAjaxControlAction($this, 'pxyEdit_Click'));
  67. // $this->dtgAccounts->MetaAddEditProxyColumn($this->pxyEdit, 'Edit', 'Edit');
  68. $this->dtgAccounts->MetaAddProxyColumn($this->pxyEdit, QQN::Account()->Person);
  69. $this->dtgAccounts->MetaAddColumn('Id');
  70. $this->dtgAccounts->GetColumn(1)->Name = 'Account Number';
  71. $this->dtgAccounts->MetaAddColumn('RegistrationDate');
  72. $this->dtgAccounts->MetaAddColumn('Username');
  73. // $this->dtgAccounts->MetaAddColumn('Password');
  74. // $this->dtgAccounts->MetaAddColumn('Notes');
  75. $this->dtgAccounts->MetaAddColumn('LastLogin');
  76. $this->dtgAccounts->MetaAddColumn('LoginCount');
  77. $this->dtgAccounts->MetaAddColumn('Online');
  78. // $this->dtgAccounts->MetaAddColumn('OnetimePassword');
  79. // $this->dtgAccounts->MetaAddColumn('ValidPassword');
  80. $this->dtgAccounts->MetaAddTypeColumn('TypeId', 'AccountType');
  81. $this->dtgAccounts->MetaAddTypeColumn('StatusId', 'AccountStatusType');
  82. // Setup the Create New button
  83. $this->btnCreateNew = new QButton($this);
  84. $this->btnCreateNew->Text = QApplication::Translate('Create a New') . ' ' . QApplication::Translate('Account');
  85. $this->btnCreateNew->AddAction(new QClickEvent(), new QAjaxControlAction($this, 'btnCreateNew_Click'));
  86. }
  87. public function pxyEdit_Click($strFormId, $strControlId, $strParameter)
  88. {
  89. $this->lblMessage->Text = '';
  90. $strParameterArray = explode(',', $strParameter);
  91. $objEditPanel = new AccountEditPanel($this, $this->strCloseEditPanelMethod, $strParameterArray[0]);
  92. $strMethodName = $this->strSetEditPanelMethod;
  93. $this->objForm->$strMethodName($objEditPanel);
  94. }
  95. public function txtNumberSearch_Click($strFormId, $strControlId, $strParameter)
  96. {
  97. $intAccountId = $this->txtNumberSearch->Text;
  98. if(Account::Load($intAccountId))
  99. {
  100. $this->lblMessage->Text = '';
  101. $objEditPanel = new AccountEditPanel($this, $this->strCloseEditPanelMethod, $intAccountId );
  102. $strMethodName = $this->strSetEditPanelMethod;
  103. $this->objForm->$strMethodName($objEditPanel);
  104. }
  105. else
  106. $this->lblMessage->Text = 'Account ' . $intAccountId . ' not found.';
  107. }
  108. public function txtNameSearch_Click($strFormId, $strControlId, $strParameter)
  109. {
  110. $this->lblMessage->Text = '';
  111. $aryNamesToFind = explode(' ', $this->txtNameSearch->Text);
  112. $aryPersons = array();
  113. $aryPersonIds = array();
  114. if(sizeof($aryNamesToFind) > 1 )
  115. {
  116. $aryPersons = Person::QueryArray(
  117. QQ::AndCondition(
  118. QQ::Like(QQN::Person()->FirstName, $aryNamesToFind[0]),
  119. QQ::Like(QQN::Person()->LastName, $aryNamesToFind[1])
  120. )
  121. );
  122. }
  123. elseif(sizeof($aryNamesToFind) == 1 )
  124. {
  125. $aryPersons = Person::QueryArray(
  126. QQ::OrCondition(
  127. QQ::Like(QQN::Person()->FirstName, $this->txtNameSearch->Text),
  128. QQ::Like(QQN::Person()->LastName, $this->txtNameSearch->Text)
  129. )
  130. );
  131. }
  132. foreach( $aryPersons as $objPerson )
  133. $aryPersonIds[] = $objPerson->Id;
  134. $aryAccounts = Account::QueryArray( QQ::In( QQN::Account()->PersonId, $aryPersonIds) );
  135. $this->dtgAccounts->TotalItemCount = sizeof($aryAccounts);
  136. $this->dtgAccounts->DataSource = $aryAccounts;
  137. $this->dtgAccounts->Refresh();
  138. }
  139. public function btnCreateNew_Click($strFormId, $strControlId, $strParameter) {
  140. $objEditPanel = new AccountEditPanel($this, $this->strCloseEditPanelMethod, null);
  141. $strMethodName = $this->strSetEditPanelMethod;
  142. $this->objForm->$strMethodName($objEditPanel);
  143. }
  144. }
  145. ?>