PageRenderTime 42ms CodeModel.GetById 15ms RepoModel.GetById 0ms app.codeStats 0ms

/includes/formbase_classes/ContactListFormBase.class.php

http://tracmor.googlecode.com/
PHP | 175 lines | 122 code | 22 blank | 31 comment | 8 complexity | 579e488f28600adb589b85d0b3ae2ac5 MD5 | raw file
Possible License(s): GPL-2.0, LGPL-2.1
  1. <?php
  2. /**
  3. * This is the abstract Form class for the List All functionality
  4. * of the Contact class. This code-generated class
  5. * contains a Qform datagrid to display an HTML page that can
  6. * list a collection of Contact 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 Form which extends this ContactListFormBase
  11. * class.
  12. *
  13. * Any and all changes to this file will be overwritten with any subsequent re-
  14. * code generation.
  15. *
  16. * @package My Application
  17. * @subpackage FormBaseObjects
  18. *
  19. */
  20. abstract class ContactListFormBase extends QForm {
  21. protected $dtgContact;
  22. // DataGrid Columns
  23. protected $colEditLinkColumn;
  24. protected $colContactId;
  25. protected $colCompanyId;
  26. protected $colAddressId;
  27. protected $colFirstName;
  28. protected $colLastName;
  29. protected $colTitle;
  30. protected $colEmail;
  31. protected $colPhoneOffice;
  32. protected $colPhoneHome;
  33. protected $colPhoneMobile;
  34. protected $colFax;
  35. protected $colDescription;
  36. protected $colCreatedBy;
  37. protected $colCreationDate;
  38. protected $colModifiedBy;
  39. protected $colModifiedDate;
  40. protected $colContactCustomFieldHelper;
  41. protected function Form_Create() {
  42. // Setup DataGrid Columns
  43. $this->colEditLinkColumn = new QDataGridColumn(QApplication::Translate('Edit'), '<?= $_FORM->dtgContact_EditLinkColumn_Render($_ITEM) ?>');
  44. $this->colEditLinkColumn->HtmlEntities = false;
  45. $this->colContactId = new QDataGridColumn(QApplication::Translate('Contact Id'), '<?= $_ITEM->ContactId; ?>', array('OrderByClause' => QQ::OrderBy(QQN::Contact()->ContactId), 'ReverseOrderByClause' => QQ::OrderBy(QQN::Contact()->ContactId, false)));
  46. $this->colCompanyId = new QDataGridColumn(QApplication::Translate('Company Id'), '<?= $_FORM->dtgContact_Company_Render($_ITEM); ?>');
  47. $this->colAddressId = new QDataGridColumn(QApplication::Translate('Address Id'), '<?= $_FORM->dtgContact_Address_Render($_ITEM); ?>');
  48. $this->colFirstName = new QDataGridColumn(QApplication::Translate('First Name'), '<?= QString::Truncate($_ITEM->FirstName, 200); ?>', array('OrderByClause' => QQ::OrderBy(QQN::Contact()->FirstName), 'ReverseOrderByClause' => QQ::OrderBy(QQN::Contact()->FirstName, false)));
  49. $this->colLastName = new QDataGridColumn(QApplication::Translate('Last Name'), '<?= QString::Truncate($_ITEM->LastName, 200); ?>', array('OrderByClause' => QQ::OrderBy(QQN::Contact()->LastName), 'ReverseOrderByClause' => QQ::OrderBy(QQN::Contact()->LastName, false)));
  50. $this->colTitle = new QDataGridColumn(QApplication::Translate('Title'), '<?= QString::Truncate($_ITEM->Title, 200); ?>', array('OrderByClause' => QQ::OrderBy(QQN::Contact()->Title), 'ReverseOrderByClause' => QQ::OrderBy(QQN::Contact()->Title, false)));
  51. $this->colEmail = new QDataGridColumn(QApplication::Translate('Email'), '<?= QString::Truncate($_ITEM->Email, 200); ?>', array('OrderByClause' => QQ::OrderBy(QQN::Contact()->Email), 'ReverseOrderByClause' => QQ::OrderBy(QQN::Contact()->Email, false)));
  52. $this->colPhoneOffice = new QDataGridColumn(QApplication::Translate('Phone Office'), '<?= QString::Truncate($_ITEM->PhoneOffice, 200); ?>', array('OrderByClause' => QQ::OrderBy(QQN::Contact()->PhoneOffice), 'ReverseOrderByClause' => QQ::OrderBy(QQN::Contact()->PhoneOffice, false)));
  53. $this->colPhoneHome = new QDataGridColumn(QApplication::Translate('Phone Home'), '<?= QString::Truncate($_ITEM->PhoneHome, 200); ?>', array('OrderByClause' => QQ::OrderBy(QQN::Contact()->PhoneHome), 'ReverseOrderByClause' => QQ::OrderBy(QQN::Contact()->PhoneHome, false)));
  54. $this->colPhoneMobile = new QDataGridColumn(QApplication::Translate('Phone Mobile'), '<?= QString::Truncate($_ITEM->PhoneMobile, 200); ?>', array('OrderByClause' => QQ::OrderBy(QQN::Contact()->PhoneMobile), 'ReverseOrderByClause' => QQ::OrderBy(QQN::Contact()->PhoneMobile, false)));
  55. $this->colFax = new QDataGridColumn(QApplication::Translate('Fax'), '<?= QString::Truncate($_ITEM->Fax, 200); ?>', array('OrderByClause' => QQ::OrderBy(QQN::Contact()->Fax), 'ReverseOrderByClause' => QQ::OrderBy(QQN::Contact()->Fax, false)));
  56. $this->colDescription = new QDataGridColumn(QApplication::Translate('Description'), '<?= QString::Truncate($_ITEM->Description, 200); ?>', array('OrderByClause' => QQ::OrderBy(QQN::Contact()->Description), 'ReverseOrderByClause' => QQ::OrderBy(QQN::Contact()->Description, false)));
  57. $this->colCreatedBy = new QDataGridColumn(QApplication::Translate('Created By'), '<?= $_FORM->dtgContact_CreatedByObject_Render($_ITEM); ?>');
  58. $this->colCreationDate = new QDataGridColumn(QApplication::Translate('Creation Date'), '<?= $_FORM->dtgContact_CreationDate_Render($_ITEM); ?>', array('OrderByClause' => QQ::OrderBy(QQN::Contact()->CreationDate), 'ReverseOrderByClause' => QQ::OrderBy(QQN::Contact()->CreationDate, false)));
  59. $this->colModifiedBy = new QDataGridColumn(QApplication::Translate('Modified By'), '<?= $_FORM->dtgContact_ModifiedByObject_Render($_ITEM); ?>');
  60. $this->colModifiedDate = new QDataGridColumn(QApplication::Translate('Modified Date'), '<?= QString::Truncate($_ITEM->ModifiedDate, 200); ?>', array('OrderByClause' => QQ::OrderBy(QQN::Contact()->ModifiedDate), 'ReverseOrderByClause' => QQ::OrderBy(QQN::Contact()->ModifiedDate, false)));
  61. $this->colContactCustomFieldHelper = new QDataGridColumn(QApplication::Translate('Contact Custom Field Helper'), '<?= $_FORM->dtgContact_ContactCustomFieldHelper_Render($_ITEM); ?>');
  62. // Setup DataGrid
  63. $this->dtgContact = new QDataGrid($this);
  64. $this->dtgContact->CellSpacing = 0;
  65. $this->dtgContact->CellPadding = 4;
  66. $this->dtgContact->BorderStyle = QBorderStyle::Solid;
  67. $this->dtgContact->BorderWidth = 1;
  68. $this->dtgContact->GridLines = QGridLines::Both;
  69. // Datagrid Paginator
  70. $this->dtgContact->Paginator = new QPaginator($this->dtgContact);
  71. $this->dtgContact->ItemsPerPage = 10;
  72. // Specify Whether or Not to Refresh using Ajax
  73. $this->dtgContact->UseAjax = false;
  74. // Specify the local databind method this datagrid will use
  75. $this->dtgContact->SetDataBinder('dtgContact_Bind');
  76. $this->dtgContact->AddColumn($this->colEditLinkColumn);
  77. $this->dtgContact->AddColumn($this->colContactId);
  78. $this->dtgContact->AddColumn($this->colCompanyId);
  79. $this->dtgContact->AddColumn($this->colAddressId);
  80. $this->dtgContact->AddColumn($this->colFirstName);
  81. $this->dtgContact->AddColumn($this->colLastName);
  82. $this->dtgContact->AddColumn($this->colTitle);
  83. $this->dtgContact->AddColumn($this->colEmail);
  84. $this->dtgContact->AddColumn($this->colPhoneOffice);
  85. $this->dtgContact->AddColumn($this->colPhoneHome);
  86. $this->dtgContact->AddColumn($this->colPhoneMobile);
  87. $this->dtgContact->AddColumn($this->colFax);
  88. $this->dtgContact->AddColumn($this->colDescription);
  89. $this->dtgContact->AddColumn($this->colCreatedBy);
  90. $this->dtgContact->AddColumn($this->colCreationDate);
  91. $this->dtgContact->AddColumn($this->colModifiedBy);
  92. $this->dtgContact->AddColumn($this->colModifiedDate);
  93. $this->dtgContact->AddColumn($this->colContactCustomFieldHelper);
  94. }
  95. public function dtgContact_EditLinkColumn_Render(Contact $objContact) {
  96. return sprintf('<a href="contact_edit.php?intContactId=%s">%s</a>',
  97. $objContact->ContactId,
  98. QApplication::Translate('Edit'));
  99. }
  100. public function dtgContact_Company_Render(Contact $objContact) {
  101. if (!is_null($objContact->Company))
  102. return $objContact->Company->__toString();
  103. else
  104. return null;
  105. }
  106. public function dtgContact_Address_Render(Contact $objContact) {
  107. if (!is_null($objContact->Address))
  108. return $objContact->Address->__toString();
  109. else
  110. return null;
  111. }
  112. public function dtgContact_CreatedByObject_Render(Contact $objContact) {
  113. if (!is_null($objContact->CreatedByObject))
  114. return $objContact->CreatedByObject->__toString();
  115. else
  116. return null;
  117. }
  118. public function dtgContact_CreationDate_Render(Contact $objContact) {
  119. if (!is_null($objContact->CreationDate))
  120. return $objContact->CreationDate->__toString(QDateTime::FormatDisplayDateTime);
  121. else
  122. return null;
  123. }
  124. public function dtgContact_ModifiedByObject_Render(Contact $objContact) {
  125. if (!is_null($objContact->ModifiedByObject))
  126. return $objContact->ModifiedByObject->__toString();
  127. else
  128. return null;
  129. }
  130. public function dtgContact_ContactCustomFieldHelper_Render(Contact $objContact) {
  131. if (!is_null($objContact->ContactCustomFieldHelper))
  132. return $objContact->ContactCustomFieldHelper->__toString();
  133. else
  134. return null;
  135. }
  136. protected function dtgContact_Bind() {
  137. // Because we want to enable pagination AND sorting, we need to setup the $objClauses array to send to LoadAll()
  138. // Remember! We need to first set the TotalItemCount, which will affect the calcuation of LimitClause below
  139. $this->dtgContact->TotalItemCount = Contact::CountAll();
  140. // Setup the $objClauses Array
  141. $objClauses = array();
  142. // If a column is selected to be sorted, and if that column has a OrderByClause set on it, then let's add
  143. // the OrderByClause to the $objClauses array
  144. if ($objClause = $this->dtgContact->OrderByClause)
  145. array_push($objClauses, $objClause);
  146. // Add the LimitClause information, as well
  147. if ($objClause = $this->dtgContact->LimitClause)
  148. array_push($objClauses, $objClause);
  149. // Set the DataSource to be the array of all Contact objects, given the clauses above
  150. $this->dtgContact->DataSource = Contact::LoadAll($objClauses);
  151. }
  152. }
  153. ?>