3 +--------------------------------------------------------------------+
4 | Copyright CiviCRM LLC. All rights reserved. |
6 | This work is published under the GNU AGPLv3 license with some |
7 | permitted exceptions and without any warranty. For full license |
8 | and copyright information, see https://civicrm.org/licensing |
9 +--------------------------------------------------------------------+
15 * @copyright CiviCRM LLC https://civicrm.org/licensing
17 class CRM_Event_Page_ParticipantListing_NameStatusAndDate
extends CRM_Core_Page
{
21 protected $_participantListingID;
23 protected $_eventTitle;
27 public function preProcess() {
28 $this->_id
= CRM_Utils_Request
::retrieve('id', 'Integer', $this, TRUE);
30 // ensure that there is a particpant type for this
31 $this->_participantListingID
= CRM_Core_DAO
::getFieldValue('CRM_Event_DAO_Event',
33 'participant_listing_id'
35 if (!$this->_participantListingID
) {
36 CRM_Core_Error
::statusBounce(ts("The Participant Listing feature is not currently enabled for this event."));
39 // retrieve Event Title and include it in page title
40 $this->_eventTitle
= CRM_Core_DAO
::getFieldValue('CRM_Event_DAO_Event',
44 CRM_Utils_System
::setTitle(ts('%1 - Participants', [1 => $this->_eventTitle
]));
46 // we do not want to display recently viewed contacts since this is potentially a public page
47 $this->assign('displayRecent', FALSE);
53 public function run() {
58 INNER JOIN civicrm_participant ON civicrm_contact.id = civicrm_participant.contact_id
59 INNER JOIN civicrm_event ON civicrm_participant.event_id = civicrm_event.id
63 WHERE civicrm_event.id = %1";
65 $params = [1 => [$this->_id
, 'Integer']];
66 $this->pager($fromClause, $whereClause, $params);
67 $orderBy = $this->orderBy();
69 list($offset, $rowCount) = $this->_pager
->getOffsetAndRowCount();
72 SELECT civicrm_contact.id as contact_id ,
73 civicrm_contact.display_name as name ,
74 civicrm_contact.sort_name as sort_name ,
75 civicrm_participant.id as participant_id,
76 civicrm_participant.status_id as status_id ,
77 civicrm_participant.register_date as register_date
81 LIMIT $offset, $rowCount";
84 $object = CRM_Core_DAO
::executeQuery($query, $params);
85 $statusLookup = CRM_Event_PseudoConstant
::participantStatus(NULL, NULL, 'label');
86 while ($object->fetch()) {
87 $status = $statusLookup[$object->status_id
] ??
NULL;
89 'id' => $object->contact_id
,
90 'participantID' => $object->participant_id
,
91 'name' => $object->name
,
93 'date' => $object->register_date
,
97 $this->assign_by_ref('rows', $rows);
104 * @param $whereClause
105 * @param array $whereParams
107 public function pager($fromClause, $whereClause, $whereParams) {
111 $params['status'] = ts('Group') . ' %%StatusMessage%%';
112 $params['csvString'] = NULL;
113 $params['buttonTop'] = 'PagerTopButton';
114 $params['buttonBottom'] = 'PagerBottomButton';
115 $params['rowCount'] = $this->get(CRM_Utils_Pager
::PAGE_ROWCOUNT
);
116 if (!$params['rowCount']) {
117 $params['rowCount'] = CRM_Utils_Pager
::ROWCOUNT
;
121 SELECT count( civicrm_contact.id )
125 $params['total'] = CRM_Core_DAO
::singleValueQuery($query, $whereParams);
126 $this->_pager
= new CRM_Utils_Pager($params);
127 $this->assign_by_ref('pager', $this->_pager
);
133 public function orderBy() {
134 static $headers = NULL;
138 'name' => ts('Name'),
139 'sort' => 'civicrm_contact.sort_name',
140 'direction' => CRM_Utils_Sort
::ASCENDING
,
143 'name' => ts('Status'),
144 'sort' => 'civicrm_participant.status_id',
145 'direction' => CRM_Utils_Sort
::DONTCARE
,
148 'name' => ts('Register Date'),
149 'sort' => 'civicrm_participant.register_date',
150 'direction' => CRM_Utils_Sort
::DONTCARE
,
154 if ($this->get(CRM_Utils_Sort
::SORT_ID
)) {
155 $sortID = CRM_Utils_Sort
::sortIDValue($this->get(CRM_Utils_Sort
::SORT_ID
),
156 $this->get(CRM_Utils_Sort
::SORT_DIRECTION
)
159 $sort = new CRM_Utils_Sort($headers, $sortID);
160 $this->assign_by_ref('headers', $headers);
161 $this->assign_by_ref('sort', $sort);
162 $this->set(CRM_Utils_Sort
::SORT_ID
,
163 $sort->getCurrentSortID()
165 $this->set(CRM_Utils_Sort
::SORT_DIRECTION
,
166 $sort->getCurrentSortDirection()
169 return $sort->orderBy();