本文整理汇总了PHP中CRM_Event_BAO_Participant::totalEventSeats方法的典型用法代码示例。如果您正苦于以下问题:PHP CRM_Event_BAO_Participant::totalEventSeats方法的具体用法?PHP CRM_Event_BAO_Participant::totalEventSeats怎么用?PHP CRM_Event_BAO_Participant::totalEventSeats使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类CRM_Event_BAO_Participant
的用法示例。
在下文中一共展示了CRM_Event_BAO_Participant::totalEventSeats方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: getParticipantCount
/**
* Function to get participant count
*
* @param boolean $considerStatus consider status for participant count.
* @param boolean $status consider counted participant.
* @param boolean $considerRole consider role for participant count.
* @param boolean $role consider counted( is filter role) participant.
* @param array $eventIds consider participants from given events.
* @param boolean $countWithStatus retrieve participant count w/ each participant status.
*
* @access public
* @return array array with count of participants for each event based on status/role
*/
function getParticipantCount($considerStatus = true, $status = true, $considerRole = true, $role = true, $eventIds = array(), $countWithStatus = false)
{
// consider both role and status for counted participants, CRM-4924.
require_once 'CRM/Event/PseudoConstant.php';
require_once 'CRM/Event/BAO/Participant.php';
$operator = " AND ";
// not counted participant.
if ($considerStatus && $considerRole && !$status && !$role) {
$operator = " OR ";
}
$clause = array();
if ($considerStatus) {
$statusTypes = CRM_Event_PseudoConstant::participantStatus(null, 'is_counted = 1');
$statusClause = 'NOT IN';
if ($status) {
$statusClause = 'IN';
}
$status = implode(',', array_keys($statusTypes));
if (empty($status)) {
$status = 0;
}
$clause[] = "civicrm_participant.status_id {$statusClause} ( {$status} ) ";
}
if ($considerRole) {
$roleTypes = CRM_Event_PseudoConstant::participantRole(null, 'filter = 1');
$roleClause = 'NOT IN';
if ($role) {
$roleClause = 'IN';
}
$roles = implode(',', array_keys($roleTypes));
if (empty($roles)) {
$roles = 0;
}
$clause[] = "civicrm_participant.role_id {$roleClause} ( {$roles} )";
}
$sqlClause = '';
if (!empty($clause)) {
$sqlClause = ' AND ( ' . implode($operator, $clause) . ' )';
}
$eventLimit = 10;
if (is_array($eventIds) && !empty($eventIds)) {
$eventLimit = null;
$sqlClause .= ' AND civicrm_event.id IN (' . implode(',', $eventIds) . ')';
}
$select = '
SELECT civicrm_event.id as id,
civicrm_participant.id as participantId';
$from = '
FROM civicrm_event
INNER JOIN civicrm_participant ON ( civicrm_event.id = civicrm_participant.event_id )
INNER JOIN civicrm_contact contact ON ( contact.id = civicrm_participant.contact_id AND contact.is_deleted = 0 )';
if ($countWithStatus) {
$select .= ', status_id as statusId, status_type.class as statusClass';
$from .= '
INNER JOIN civicrm_participant_status_type status_type ON ( civicrm_participant.status_id = status_type.id )';
}
$where = "\n WHERE ( civicrm_participant.is_test = 0 OR civicrm_participant.is_test IS NULL ) \n AND civicrm_event.is_active = 1\n {$sqlClause}";
$orderBy = 'Order By civicrm_event.end_date DESC';
$participantIds = $participantCount = array();
$query = "{$select} {$from} {$where} {$orderBy}";
$event = CRM_Core_DAO::executeQuery($query);
while ($event->fetch()) {
//we are interested in first 10 events only.
if ($eventLimit && count(array_keys($participantIds)) > $eventLimit) {
break;
}
if ($countWithStatus) {
$participantIds[$event->id][$event->statusId]['pIds'][$event->participantId] = $event->participantId;
$participantIds[$event->id][$event->statusId]['statusClass'] = $event->statusClass;
} else {
$participantIds[$event->id][$event->participantId] = $event->participantId;
}
}
//poped last 11th events participants.
if ($eventLimit && count(array_keys($participantIds)) > $eventLimit) {
array_pop($participantIds);
}
//pickup event seats
foreach ($participantIds as $eventId => $pInfo) {
$pIds = $pInfo;
if ($countWithStatus) {
foreach ($pInfo as $statusId => $values) {
$participantCount[$eventId][$statusId]['count'] = CRM_Event_BAO_Participant::totalEventSeats($values['pIds']);
$participantCount[$eventId][$statusId]['class'] = $values['statusClass'];
}
} else {
$participantCount[$eventId] = CRM_Event_BAO_Participant::totalEventSeats($pIds);
//.........这里部分代码省略.........
示例2: buildQuickForm
/**
* Build the form
*
* @access public
* @return void
*/
function buildQuickForm()
{
$this->addElement('text', 'sort_name', ts('Participant Name or Email'), CRM_Core_DAO::getAttribute('CRM_Contact_DAO_Contact', 'sort_name'));
require_once 'CRM/Event/BAO/Query.php';
CRM_Event_BAO_Query::buildSearchForm($this);
/*
* add form checkboxes for each row. This is needed out here to conform to QF protocol
* of all elements being declared in builQuickForm
*/
$rows = $this->get('rows');
if (is_array($rows)) {
$lineItems = $participantIds = array();
require_once 'CRM/Event/BAO/Event.php';
require_once 'CRM/Event/BAO/Participant.php';
if (!$this->_single) {
$this->addElement('checkbox', 'toggleSelect', null, null, array('onclick' => "toggleTaskAction( true ); return toggleCheckboxVals('mark_x_',this);"));
}
foreach ($rows as $row) {
$participantIds[] = $row['participant_id'];
if (!$this->_single) {
$this->addElement('checkbox', $row['checkbox'], null, null, array('onclick' => "toggleTaskAction( true ); return checkSelectedBox('" . $row['checkbox'] . "', '" . $this->getName() . "');"));
}
if (CRM_Event_BAO_Event::usesPriceSet($row['event_id'])) {
// add line item details if applicable
require_once 'CRM/Price/BAO/LineItem.php';
$lineItems[$row['participant_id']] = CRM_Price_BAO_LineItem::getLineItems($row['participant_id']);
}
}
$participantCount = CRM_Event_BAO_Participant::totalEventSeats($participantIds);
$this->assign('participantCount', $participantCount);
$this->assign('lineItems', $lineItems);
$total = $cancel = 0;
require_once "CRM/Core/Permission.php";
$permission = CRM_Core_Permission::getPermission();
require_once 'CRM/Event/Task.php';
$tasks = array('' => ts('- actions -')) + CRM_Event_Task::permissionedTaskTitles($permission);
if (isset($this->_ssID)) {
if ($permission == CRM_Core_Permission::EDIT) {
require_once "CRM/Contact/Task.php";
$tasks = $tasks + CRM_Event_Task::optionalTaskTitle();
}
$savedSearchValues = array('id' => $this->_ssID, 'name' => CRM_Contact_BAO_SavedSearch::getName($this->_ssID, 'title'));
$this->assign_by_ref('savedSearch', $savedSearchValues);
$this->assign('ssID', $this->_ssID);
}
$this->add('select', 'task', ts('Actions:') . ' ', $tasks);
$this->add('submit', $this->_actionButtonName, ts('Go'), array('class' => 'form-submit', 'id' => 'Go', 'onclick' => "return checkPerformAction('mark_x', '" . $this->getName() . "', 0);"));
$this->add('submit', $this->_printButtonName, ts('Print'), array('class' => 'form-submit', 'onclick' => "return checkPerformAction('mark_x', '" . $this->getName() . "', 1);"));
// need to perform tasks on all or selected items ? using radio_ts(task selection) for it
$this->addElement('radio', 'radio_ts', null, '', 'ts_sel', array('checked' => 'checked'));
$this->addElement('radio', 'radio_ts', null, '', 'ts_all', array('onclick' => $this->getName() . ".toggleSelect.checked = false; toggleCheckboxVals('mark_x_',this); toggleTaskAction( true );"));
}
// add buttons
$this->addButtons(array(array('type' => 'refresh', 'name' => ts('Search'), 'isDefault' => true)));
}