本文整理汇总了PHP中CRM_Event_BAO_Participant类的典型用法代码示例。如果您正苦于以下问题:PHP CRM_Event_BAO_Participant类的具体用法?PHP CRM_Event_BAO_Participant怎么用?PHP CRM_Event_BAO_Participant使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
在下文中一共展示了CRM_Event_BAO_Participant类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: registerParticipant
/**
* Register a participant.
*
* @param array $params
* @param CRM_Event_BAO_Participant $participant
* @param CRM_Event_BAO_Event $event
*
* @return mixed
*/
public function registerParticipant($params, &$participant, $event)
{
$transaction = new CRM_Core_Transaction();
// handle register date CRM-4320
$registerDate = date('YmdHis');
$participantParams = array('id' => $participant->id, 'event_id' => $event->id, 'register_date' => $registerDate, 'source' => CRM_Utils_Array::value('participant_source', $params, $this->description), 'is_pay_later' => $this->is_pay_later, 'fee_amount' => CRM_Utils_Array::value('amount', $params, 0), 'fee_currency' => CRM_Utils_Array::value('currencyID', $params));
if ($participant->must_wait) {
$participant_status = 'On waitlist';
} elseif (CRM_Utils_Array::value('is_pay_later', $params, FALSE)) {
$participant_status = 'Pending from pay later';
} else {
$participant_status = 'Registered';
}
$participant_statuses = CRM_Event_PseudoConstant::participantStatus();
$participantParams['status_id'] = array_search($participant_status, $participant_statuses);
$participant_status_label = CRM_Utils_Array::value($participantParams['status_id'], CRM_Event_PseudoConstant::participantStatus(NULL, NULL, 'label'));
$participantParams['participant_status'] = $participant_status_label;
$this->assign('isOnWaitlist', $participant->must_wait);
if ($this->_action & CRM_Core_Action::PREVIEW || CRM_Utils_Array::value('mode', $params) == 'test') {
$participantParams['is_test'] = 1;
} else {
$participantParams['is_test'] = 0;
}
if (self::is_administrator()) {
if (!empty($params['note'])) {
$note_params = array('participant_id' => $participant->id, 'contact_id' => self::getContactID(), 'note' => $params['note']);
CRM_Event_BAO_Participant::update_note($note_params);
}
}
$participant->copyValues($participantParams);
$participant->save();
if (!empty($params['contributionID'])) {
$payment_params = array('participant_id' => $participant->id, 'contribution_id' => $params['contributionID']);
$ids = array();
CRM_Event_BAO_ParticipantPayment::create($payment_params, $ids);
}
$transaction->commit();
$event_values = array();
CRM_Core_DAO::storeValues($event, $event_values);
$location = array();
if (CRM_Utils_Array::value('is_show_location', $event_values) == 1) {
$locationParams = array('entity_id' => $participant->event_id, 'entity_table' => 'civicrm_event');
$location = CRM_Core_BAO_Location::getValues($locationParams, TRUE);
CRM_Core_BAO_Address::fixAddress($location['address'][1]);
}
list($pre_id, $post_id) = CRM_Event_Cart_Form_MerParticipant::get_profile_groups($participant->event_id);
$payer_values = array('email' => '', 'name' => '');
if ($this->payer_contact_id) {
$payer_contact_details = CRM_Contact_BAO_Contact::getContactDetails($this->payer_contact_id);
$payer_values = array('email' => $payer_contact_details[1], 'name' => $payer_contact_details[0]);
}
$values = array('params' => array($participant->id => $participantParams), 'event' => $event_values, 'location' => $location, 'custom_pre_id' => $pre_id, 'custom_post_id' => $post_id, 'payer' => $payer_values);
CRM_Event_BAO_Event::sendMail($participant->contact_id, $values, $participant->id);
return $participant;
}
示例2: find_all_by_params
public static function find_all_by_params($params)
{
$participant = new CRM_Event_BAO_Participant();
$participant->copyValues($params);
$result = array();
if ($participant->find()) {
while ($participant->fetch()) {
$result[] = new CRM_Event_Cart_BAO_MerParticipant(clone $participant);
}
}
return $result;
}
示例3: preProcess
public function preProcess()
{
$this->_id = CRM_Utils_Request::retrieve('id', 'Positive', $this, TRUE);
$this->_contactId = CRM_Utils_Request::retrieve('cid', 'Positive', $this, TRUE);
$this->_component = CRM_Utils_Request::retrieve('component', 'String', $this, TRUE);
$this->_view = CRM_Utils_Request::retrieve('view', 'String', $this, FALSE);
$this->_action = CRM_Utils_Request::retrieve('action', 'String', $this, FALSE);
$this->assign('component', $this->_component);
$this->assign('id', $this->_id);
$this->assign('suppressPaymentFormButtons', $this->isBeingCalledFromSelectorContext());
if ($this->_view == 'transaction' && $this->_action & CRM_Core_Action::BROWSE) {
$paymentInfo = CRM_Contribute_BAO_Contribution::getPaymentInfo($this->_id, $this->_component, TRUE);
$transactionRows = $paymentInfo['transaction'];
$title = ts('View Payment');
if ($this->_component == 'event') {
$info = CRM_Event_BAO_Participant::participantDetails($this->_id);
$title .= " - {$info['title']}";
}
CRM_Utils_System::setTitle($title);
$this->assign('transaction', TRUE);
$this->assign('rows', $transactionRows);
return;
}
$this->_fromEmails = CRM_Core_BAO_Email::getFromEmail();
$this->_formType = CRM_Utils_Array::value('formType', $_GET);
$enitityType = NULL;
if ($this->_component == 'event') {
$enitityType = 'participant';
$this->_contributionId = CRM_Core_DAO::getFieldValue('CRM_Event_DAO_ParticipantPayment', $this->_id, 'contribution_id', 'participant_id');
}
$eventId = CRM_Core_DAO::getFieldValue('CRM_Event_DAO_Participant', $this->_id, 'event_id', 'id');
$this->_fromEmails = CRM_Event_BAO_Event::getFromEmailIds($eventId);
$paymentInfo = CRM_Core_BAO_FinancialTrxn::getPartialPaymentWithType($this->_id, $enitityType);
$paymentDetails = CRM_Contribute_BAO_Contribution::getPaymentInfo($this->_id, $this->_component, FALSE, TRUE);
$this->_amtPaid = $paymentDetails['paid'];
$this->_amtTotal = $paymentDetails['total'];
if (!empty($paymentInfo['refund_due'])) {
$paymentAmt = $this->_refund = $paymentInfo['refund_due'];
$this->_paymentType = 'refund';
} elseif (!empty($paymentInfo['amount_owed'])) {
$paymentAmt = $this->_owed = $paymentInfo['amount_owed'];
$this->_paymentType = 'owed';
} else {
CRM_Core_Error::fatal(ts('No payment information found for this record'));
}
//set the payment mode - _mode property is defined in parent class
$this->_mode = CRM_Utils_Request::retrieve('mode', 'String', $this);
if (!empty($this->_mode) && $this->_paymentType == 'refund') {
CRM_Core_Error::fatal(ts('Credit card payment is not for Refund payments use'));
}
list($this->_contributorDisplayName, $this->_contributorEmail) = CRM_Contact_BAO_Contact_Location::getEmailDetails($this->_contactId);
$this->assignPaymentRelatedVariables();
$this->assign('contributionMode', $this->_mode);
$this->assign('contactId', $this->_contactId);
$this->assign('paymentType', $this->_paymentType);
$this->assign('paymentAmt', abs($paymentAmt));
$this->setPageTitle($this->_refund ? ts('Refund') : ts('Payment'));
}
示例4: postProcess
/**
* Process the form after the input has been submitted and validated.
*
*
* @return void
*/
public function postProcess()
{
$params = $this->exportValues();
$value = array();
foreach ($this->_participantIds as $participantId) {
$value['id'] = $participantId;
// Cancelled status id = 4
$value['status_id'] = 4;
CRM_Event_BAO_Participant::create($value);
}
}
示例5: preProcess
/**
* Function to set variables up before form is built
*
* @return void
* @access public
*/
public function preProcess()
{
require_once 'CRM/Event/BAO/Participant.php';
$values = $ids = array();
$participantID = CRM_Utils_Request::retrieve('id', 'Positive', $this, true);
$contactID = CRM_Utils_Request::retrieve('cid', 'Positive', $this, true);
$params = array('id' => $participantID);
CRM_Event_BAO_Participant::getValues($params, $values, $ids);
if (empty($values)) {
require_once 'CRM/Core/Error.php';
CRM_Core_Error::statusBounce(ts('The requested participant record does not exist (possibly the record was deleted).'));
}
CRM_Event_BAO_Participant::resolveDefaults($values[$participantID]);
if (CRM_Utils_Array::value('fee_level', $values[$participantID])) {
CRM_Event_BAO_Participant::fixEventLevel($values[$participantID]['fee_level']);
}
if ($values[$participantID]['is_test']) {
$values[$participantID]['status'] .= ' (test) ';
}
// Get Note
$noteValue = CRM_Core_BAO_Note::getNote($participantID, 'civicrm_participant');
$values[$participantID]['note'] = array_values($noteValue);
require_once 'CRM/Price/BAO/LineItem.php';
// Get Line Items
$lineItem = CRM_Price_BAO_LineItem::getLineItems($participantID);
if (!CRM_Utils_System::isNull($lineItem)) {
$values[$participantID]['lineItem'][] = $lineItem;
}
$values[$participantID]['totalAmount'] = $values[$participantID]['fee_amount'];
// get the option value for custom data type
$roleCustomDataTypeID = CRM_Core_OptionGroup::getValue('custom_data_type', 'ParticipantRole', 'name');
$eventNameCustomDataTypeID = CRM_Core_OptionGroup::getValue('custom_data_type', 'ParticipantEventName', 'name');
$eventTypeCustomDataTypeID = CRM_Core_OptionGroup::getValue('custom_data_type', 'ParticipantEventType', 'name');
$roleGroupTree =& CRM_Core_BAO_CustomGroup::getTree('Participant', $this, $participantID, null, $values[$participantID]['role_id'], $roleCustomDataTypeID);
$eventGroupTree =& CRM_Core_BAO_CustomGroup::getTree('Participant', $this, $participantID, null, $values[$participantID]['event_id'], $eventNameCustomDataTypeID);
$eventTypeID = CRM_Core_DAO::getFieldValue("CRM_Event_DAO_Event", $values[$participantID]['event_id'], 'event_type_id', 'id');
$eventTypeGroupTree =& CRM_Core_BAO_CustomGroup::getTree('Participant', $this, $participantID, null, $eventTypeID, $eventTypeCustomDataTypeID);
$groupTree = CRM_Utils_Array::crmArrayMerge($roleGroupTree, $eventGroupTree);
$groupTree = CRM_Utils_Array::crmArrayMerge($groupTree, $eventTypeGroupTree);
$groupTree = CRM_Utils_Array::crmArrayMerge($groupTree, CRM_Core_BAO_CustomGroup::getTree('Participant', $this, $participantID));
CRM_Core_BAO_CustomGroup::buildCustomDataView($this, $groupTree);
$this->assign($values[$participantID]);
// add viewed participant to recent items list
require_once 'CRM/Utils/Recent.php';
require_once 'CRM/Contact/BAO/Contact.php';
$url = CRM_Utils_System::url('civicrm/contact/view/participant', "action=view&reset=1&id={$values[$participantID]['id']}&cid={$values[$participantID]['contact_id']}&context=home");
$participantRoles = CRM_Event_PseudoConstant::participantRole();
$eventTitle = CRM_Core_DAO::getFieldValue('CRM_Event_DAO_Event', $values[$participantID]['event_id'], 'title');
$displayName = CRM_Contact_BAO_Contact::displayName($contactID);
$this->assign('displayName', $displayName);
$title = $displayName . ' (' . $participantRoles[$values[$participantID]['role_id']] . ' - ' . $eventTitle . ')';
// add Participant to Recent Items
CRM_Utils_Recent::add($title, $url, $values[$participantID]['id'], 'Participant', $values[$participantID]['contact_id'], null);
}
示例6: postProcess
/**
* process the form after the input has been submitted and validated
*
* @access public
* @return None
*/
public function postProcess()
{
$deletedParticipants = 0;
require_once 'CRM/Event/BAO/Participant.php';
foreach ($this->_participantIds as $participantId) {
if (CRM_Event_BAO_Participant::deleteParticipant($participantId)) {
$deletedParticipants++;
}
}
$status = array(ts('Deleted Participation(s): %1', array(1 => $deletedParticipants)), ts('Total Selected Participation(s): %1', array(1 => count($this->_participantIds))));
CRM_Core_Session::setStatus($status);
}
示例7: checkEventCapacity
/**
* @param $event_id
*
* @return bool|int|null|string
*/
function checkEventCapacity($event_id)
{
$empty_seats = CRM_Event_BAO_Participant::eventFull($event_id, TRUE);
if (is_numeric($empty_seats)) {
return $empty_seats;
}
if (is_string($empty_seats)) {
return 0;
} else {
return NULL;
}
}
示例8: _addParticipantWithPayment
function _addParticipantWithPayment($feeTotal, $actualPaidAmt)
{
// creating price set, price field
$paramsSet['title'] = 'Price Set';
$paramsSet['name'] = CRM_Utils_String::titleToVar('Price Set');
$paramsSet['is_active'] = FALSE;
$paramsSet['extends'] = 1;
$priceset = CRM_Price_BAO_PriceSet::create($paramsSet);
CRM_Price_BAO_PriceSet::addTo('civicrm_event', $this->_eventId, $priceset->id);
$priceSetId = $priceset->id;
//Checking for priceset added in the table.
$this->assertDBCompareValue('CRM_Price_BAO_PriceSet', $priceSetId, 'title', 'id', $paramsSet['title'], 'Check DB for created priceset');
$paramsField = array('label' => 'Price Field', 'name' => CRM_Utils_String::titleToVar('Price Field'), 'html_type' => 'Text', 'price' => $feeTotal, 'option_label' => array('1' => 'Price Field'), 'option_value' => array('1' => $feeTotal), 'option_name' => array('1' => $feeTotal), 'option_weight' => array('1' => 1), 'option_amount' => array('1' => 1), 'is_display_amounts' => 1, 'weight' => 1, 'options_per_line' => 1, 'is_active' => array('1' => 1), 'price_set_id' => $priceset->id, 'is_enter_qty' => 1);
$ids = array();
$pricefield = CRM_Price_BAO_PriceField::create($paramsField, $ids);
//Checking for priceset added in the table.
$this->assertDBCompareValue('CRM_Price_BAO_PriceField', $pricefield->id, 'label', 'id', $paramsField['label'], 'Check DB for created pricefield');
// create participant record
$eventId = $this->_eventId;
$participantParams = array('send_receipt' => 1, 'is_test' => 0, 'is_pay_later' => 0, 'event_id' => $eventId, 'register_date' => date('Y-m-d') . " 00:00:00", 'role_id' => 1, 'status_id' => 14, 'source' => 'Event_' . $eventId, 'contact_id' => $this->_contactId, 'note' => 'Note added for Event_' . $eventId, 'fee_level' => 'Price_Field - 55');
$participant = CRM_Event_BAO_Participant::add($participantParams);
// create participant contribution with partial payment
$contributionParams = array('total_amount' => $actualPaidAmt, 'source' => 'Fall Fundraiser Dinner: Offline registration', 'currency' => 'USD', 'non_deductible_amount' => 'null', 'receipt_date' => date('Y-m-d') . " 00:00:00", 'contact_id' => $this->_contactId, 'financial_type_id' => 4, 'payment_instrument_id' => 4, 'contribution_status_id' => 1, 'receive_date' => date('Y-m-d') . " 00:00:00", 'skipLineItem' => 1, 'partial_payment_total' => $feeTotal, 'partial_amount_pay' => $actualPaidAmt);
$contribution = CRM_Contribute_BAO_Contribution::create($contributionParams, CRM_Core_DAO::$_nullArray);
$contributionId = $contribution->id;
// add participant payment entry
$this->participantPaymentCreate($participant->id, $contributionId);
// -- processing priceSet using the BAO
$lineItem = array();
$priceSet = CRM_Price_BAO_PriceSet::getSetDetail($priceSetId, TRUE, FALSE);
$priceSet = CRM_Utils_Array::value($priceSetId, $priceSet);
$feeBlock = CRM_Utils_Array::value('fields', $priceSet);
$params['price_2'] = $feeTotal;
CRM_Price_BAO_PriceSet::processAmount($feeBlock, $params, $lineItem);
$lineItemVal[$priceSetId] = $lineItem;
CRM_Price_BAO_LineItem::processPriceSet($participant->id, $lineItemVal, $contribution, 'civicrm_participant');
return array($participant, $contribution);
}
示例9: postProcess
/**
* process the form after the input has been submitted and validated
*
* @access public
*
* @return void
*/
public function postProcess()
{
$params = $this->controller->exportValues($this->_name);
if (CRM_Utils_Array::value('delete_participant', $params) == 2) {
$links = array();
foreach ($this->_participantIds as $participantId) {
$additionalId = CRM_Event_BAO_Participant::getAdditionalParticipantIds($participantId);
$participantLinks = CRM_Event_BAO_Participant::getAdditionalParticipantUrl($additionalId);
}
}
$deletedParticipants = $additionalCount = 0;
foreach ($this->_participantIds as $participantId) {
if (CRM_Utils_Array::value('delete_participant', $params) == 1) {
if (CRM_Event_BAO_Participant::isPrimaryParticipant($participantId)) {
$additionalIds = CRM_Event_BAO_Participant::getAdditionalParticipantIds($participantId);
$additionalCount = count($additionalIds);
foreach ($additionalIds as $value) {
CRM_Event_BAO_Participant::deleteParticipant($value);
}
CRM_Event_BAO_Participant::deleteParticipant($participantId);
}
$deletedParticipants++;
} else {
CRM_Event_BAO_Participant::deleteParticipant($participantId);
$deletedParticipants++;
}
}
if ($additionalCount) {
$deletedParticipants += $additionalCount;
}
$status = array(ts('Participant(s) Deleted: %1', array(1 => $deletedParticipants)), ts('Total Selected Participant(s): %1', array(1 => $deletedParticipants)));
if (!empty($participantLinks)) {
$status[] = ts('The following participants no longer have an event fee recorded. You can edit their registration and record a replacement contribution by clicking the links below:') . '<br>' . $participantLinks;
}
CRM_Core_Session::setStatus($status);
}
示例10: processFirstParticipant
/**
* set the first participant ID if not set, CRM-10032
*
* @param int $participantID
*/
public function processFirstParticipant($participantID)
{
$this->_participantId = $participantID;
$this->set('participantId', $this->_participantId);
$ids = $participantValues = array();
$participantParams = array('id' => $this->_participantId);
CRM_Event_BAO_Participant::getValues($participantParams, $participantValues, $ids);
$this->_values['participant'] = $participantValues[$this->_participantId];
$this->set('values', $this->_values);
// also set the allow confirmation stuff
if (array_key_exists($this->_values['participant']['status_id'], CRM_Event_PseudoConstant::participantStatus(NULL, "class = 'Pending'"))) {
$this->_allowConfirmation = TRUE;
$this->set('allowConfirmation', TRUE);
}
}
示例11: whereClauseSingle
/**
* @param $values
* @param $query
*/
public static function whereClauseSingle(&$values, &$query)
{
list($name, $op, $value, $grouping, $wildcard) = $values;
$fields = array_merge(CRM_Event_BAO_Event::fields(), CRM_Event_BAO_Participant::exportableFields());
switch ($name) {
case 'event_start_date_low':
case 'event_start_date_high':
$query->dateQueryBuilder($values, 'civicrm_event', 'event_start_date', 'start_date', 'Start Date');
return;
case 'event_end_date_low':
case 'event_end_date_high':
$query->dateQueryBuilder($values, 'civicrm_event', 'event_end_date', 'end_date', 'End Date');
return;
case 'event_include_repeating_events':
/**
* Include Repeating Events
*/
//Get parent of this event
$exEventId = '';
if ($query->_where[$grouping]) {
foreach ($query->_where[$grouping] as $key => $val) {
if (strstr($val, 'civicrm_event.id =')) {
$exEventId = $val;
$extractEventId = explode(" ", $val);
$value = $extractEventId[2];
$where = $query->_where[$grouping][$key];
} else {
if (strstr($val, 'civicrm_event.id IN')) {
//extract the first event id if multiple events are selected
preg_match('/civicrm_event.id IN \\(\\"(\\d+)/', $val, $matches);
$value = $matches[1];
$where = $query->_where[$grouping][$key];
}
}
}
if ($exEventId) {
$extractEventId = explode(" ", $exEventId);
$value = $extractEventId[2];
} else {
if (!empty($matches[1])) {
$value = $matches[1];
}
}
$where = $query->_where[$grouping][$key];
}
$thisEventHasParent = CRM_Core_BAO_RecurringEntity::getParentFor($value, 'civicrm_event');
if ($thisEventHasParent) {
$getAllConnections = CRM_Core_BAO_RecurringEntity::getEntitiesForParent($thisEventHasParent, 'civicrm_event');
$allEventIds = array();
foreach ($getAllConnections as $key => $val) {
$allEventIds[] = $val['id'];
}
if (!empty($allEventIds)) {
$op = "IN";
$value = "(" . implode(",", $allEventIds) . ")";
}
}
$query->_where[$grouping][] = "{$where} OR civicrm_event.id {$op} {$value}";
$query->_qill[$grouping][] = ts('Include Repeating Events');
$query->_tables['civicrm_event'] = $query->_whereTables['civicrm_event'] = 1;
return;
case 'participant_is_test':
$key = array_search('civicrm_participant.is_test = 0', $query->_where[$grouping]);
if (!empty($key)) {
unset($query->_where[$grouping][$key]);
}
case 'participant_test':
// We dont want to include all tests for sql OR CRM-7827
if (!$value || $query->getOperator() != 'OR') {
$query->_where[$grouping][] = CRM_Contact_BAO_Query::buildClause("civicrm_participant.is_test", $op, $value, "Boolean");
$isTest = $value ? 'a Test' : 'not a Test';
$query->_qill[$grouping][] = ts("Participant is %1", array(1 => $isTest));
$query->_tables['civicrm_participant'] = $query->_whereTables['civicrm_participant'] = 1;
}
return;
case 'participant_fee_id':
foreach ($value as $k => &$val) {
$val = CRM_Core_DAO::getFieldValue('CRM_Price_DAO_PriceFieldValue', $val, 'label');
$val = CRM_Core_DAO::escapeString(trim($val));
}
$feeLabel = implode('|', $value);
$query->_where[$grouping][] = "civicrm_participant.fee_level REGEXP '{$feeLabel}'";
$query->_qill[$grouping][] = ts("Fee level") . " IN " . implode(', ', $value);
$query->_tables['civicrm_participant'] = $query->_whereTables['civicrm_participant'] = 1;
return;
case 'participant_fee_amount_high':
case 'participant_fee_amount_low':
$query->numberRangeBuilder($values, 'civicrm_participant', 'participant_fee_amount', 'fee_amount', 'Fee Amount');
return;
case 'participant_status_id':
if ($value && is_array($value) && strpos($op, 'IN') === FALSE) {
$op = 'IN';
}
case 'participant_status':
case 'participant_source':
case 'participant_id':
//.........这里部分代码省略.........
示例12: preProcess
/**
* Set variables up before form is built.
*
* @return void
*/
public function preProcess()
{
$values = $ids = array();
$participantID = CRM_Utils_Request::retrieve('id', 'Positive', $this, TRUE);
$contactID = CRM_Utils_Request::retrieve('cid', 'Positive', $this, TRUE);
$params = array('id' => $participantID);
CRM_Event_BAO_Participant::getValues($params, $values, $ids);
if (empty($values)) {
CRM_Core_Error::statusBounce(ts('The requested participant record does not exist (possibly the record was deleted).'));
}
CRM_Event_BAO_Participant::resolveDefaults($values[$participantID]);
if (!empty($values[$participantID]['fee_level'])) {
CRM_Event_BAO_Participant::fixEventLevel($values[$participantID]['fee_level']);
}
$this->assign('contactId', $contactID);
$this->assign('participantId', $participantID);
$paymentId = CRM_Core_DAO::getFieldValue('CRM_Event_DAO_ParticipantPayment', $participantID, 'id', 'participant_id');
$this->assign('hasPayment', $paymentId);
if ($parentParticipantId = CRM_Core_DAO::getFieldValue('CRM_Event_DAO_Participant', $participantID, 'registered_by_id')) {
$parentHasPayment = CRM_Core_DAO::getFieldValue('CRM_Event_DAO_ParticipantPayment', $parentParticipantId, 'id', 'participant_id');
$this->assign('parentHasPayment', $parentHasPayment);
}
$statusId = CRM_Core_DAO::getFieldValue('CRM_Event_BAO_Participant', $participantID, 'status_id', 'id');
$status = CRM_Core_DAO::getFieldValue('CRM_Event_BAO_ParticipantStatusType', $statusId, 'name', 'id');
$status = CRM_Core_DAO::getFieldValue('CRM_Event_BAO_ParticipantStatusType', $statusId, 'name', 'id');
if ($status == 'Transferred') {
$transferId = CRM_Core_DAO::getFieldValue('CRM_Event_BAO_Participant', $participantID, 'transferred_to_contact_id', 'id');
$pid = CRM_Core_DAO::getFieldValue('CRM_Event_BAO_Participant', $transferId, 'id', 'contact_id');
$transferName = current(CRM_Contact_BAO_Contact::getContactDetails($transferId));
$this->assign('pid', $pid);
$this->assign('transferId', $transferId);
$this->assign('transferName', $transferName);
}
$participantStatuses = CRM_Event_PseudoConstant::participantStatus();
if ($values[$participantID]['is_test']) {
$values[$participantID]['status'] .= ' (test) ';
}
// Get Note
$noteValue = CRM_Core_BAO_Note::getNote($participantID, 'civicrm_participant');
$values[$participantID]['note'] = array_values($noteValue);
// Get Line Items
$lineItem = CRM_Price_BAO_LineItem::getLineItems($participantID);
if (!CRM_Utils_System::isNull($lineItem)) {
$values[$participantID]['lineItem'][] = $lineItem;
}
$values[$participantID]['totalAmount'] = CRM_Utils_Array::value('fee_amount', $values[$participantID]);
// Get registered_by contact ID and display_name if participant was registered by someone else (CRM-4859)
if (!empty($values[$participantID]['participant_registered_by_id'])) {
$values[$participantID]['registered_by_contact_id'] = CRM_Core_DAO::getFieldValue("CRM_Event_DAO_Participant", $values[$participantID]['participant_registered_by_id'], 'contact_id', 'id');
$values[$participantID]['registered_by_display_name'] = CRM_Contact_BAO_Contact::displayName($values[$participantID]['registered_by_contact_id']);
}
// Check if this is a primaryParticipant (registered for others) and retrieve additional participants if true (CRM-4859)
if (CRM_Event_BAO_Participant::isPrimaryParticipant($participantID)) {
$values[$participantID]['additionalParticipants'] = CRM_Event_BAO_Participant::getAdditionalParticipants($participantID);
}
// get the option value for custom data type
$roleCustomDataTypeID = CRM_Core_OptionGroup::getValue('custom_data_type', 'ParticipantRole', 'name');
$eventNameCustomDataTypeID = CRM_Core_OptionGroup::getValue('custom_data_type', 'ParticipantEventName', 'name');
$eventTypeCustomDataTypeID = CRM_Core_OptionGroup::getValue('custom_data_type', 'ParticipantEventType', 'name');
$allRoleIDs = explode(CRM_Core_DAO::VALUE_SEPARATOR, $values[$participantID]['role_id']);
$groupTree = array();
$finalTree = array();
foreach ($allRoleIDs as $k => $v) {
$roleGroupTree = CRM_Core_BAO_CustomGroup::getTree('Participant', $this, $participantID, NULL, $v, $roleCustomDataTypeID);
$eventGroupTree = CRM_Core_BAO_CustomGroup::getTree('Participant', $this, $participantID, NULL, $values[$participantID]['event_id'], $eventNameCustomDataTypeID);
$eventTypeID = CRM_Core_DAO::getFieldValue("CRM_Event_DAO_Event", $values[$participantID]['event_id'], 'event_type_id', 'id');
$eventTypeGroupTree = CRM_Core_BAO_CustomGroup::getTree('Participant', $this, $participantID, NULL, $eventTypeID, $eventTypeCustomDataTypeID);
$groupTree = CRM_Utils_Array::crmArrayMerge($roleGroupTree, $eventGroupTree);
$groupTree = CRM_Utils_Array::crmArrayMerge($groupTree, $eventTypeGroupTree);
$groupTree = CRM_Utils_Array::crmArrayMerge($groupTree, CRM_Core_BAO_CustomGroup::getTree('Participant', $this, $participantID));
foreach ($groupTree as $treeId => $trees) {
$finalTree[$treeId] = $trees;
}
}
CRM_Core_BAO_CustomGroup::buildCustomDataView($this, $finalTree, FALSE, NULL, NULL, NULL, $participantID);
$eventTitle = CRM_Core_DAO::getFieldValue('CRM_Event_DAO_Event', $values[$participantID]['event_id'], 'title');
//CRM-7150, show event name on participant view even if the event is disabled
if (empty($values[$participantID]['event'])) {
$values[$participantID]['event'] = $eventTitle;
}
//do check for campaigns
if ($campaignId = CRM_Utils_Array::value('campaign_id', $values[$participantID])) {
$campaigns = CRM_Campaign_BAO_Campaign::getCampaigns($campaignId);
$values[$participantID]['campaign'] = $campaigns[$campaignId];
}
$this->assign($values[$participantID]);
// add viewed participant to recent items list
$url = CRM_Utils_System::url('civicrm/contact/view/participant', "action=view&reset=1&id={$values[$participantID]['id']}&cid={$values[$participantID]['contact_id']}&context=home");
$recentOther = array();
if (CRM_Core_Permission::check('edit event participants')) {
$recentOther['editUrl'] = CRM_Utils_System::url('civicrm/contact/view/participant', "action=update&reset=1&id={$values[$participantID]['id']}&cid={$values[$participantID]['contact_id']}&context=home");
}
if (CRM_Core_Permission::check('delete in CiviEvent')) {
$recentOther['deleteUrl'] = CRM_Utils_System::url('civicrm/contact/view/participant', "action=delete&reset=1&id={$values[$participantID]['id']}&cid={$values[$participantID]['contact_id']}&context=home");
}
//.........这里部分代码省略.........
示例13: testfixEventLevel
/**
* FixEventLevel() method (Setting ',' values), resolveDefaults(assinging value to array) method
*/
public function testfixEventLevel()
{
$paramsSet['title'] = 'Price Set';
$paramsSet['name'] = CRM_Utils_String::titleToVar('Price Set');
$paramsSet['is_active'] = FALSE;
$paramsSet['extends'] = 1;
$priceset = CRM_Price_BAO_PriceSet::create($paramsSet);
//Checking for priceset added in the table.
$this->assertDBCompareValue('CRM_Price_BAO_PriceSet', $priceset->id, 'title', 'id', $paramsSet['title'], 'Check DB for created priceset');
$paramsField = array('label' => 'Price Field', 'name' => CRM_Utils_String::titleToVar('Price Field'), 'html_type' => 'Text', 'price' => 10, 'option_label' => array('1' => 'Price Field'), 'option_value' => array('1' => 10), 'option_name' => array('1' => 10), 'option_weight' => array('1' => 1), 'is_display_amounts' => 1, 'weight' => 1, 'options_per_line' => 1, 'is_active' => array('1' => 1), 'price_set_id' => $priceset->id, 'is_enter_qty' => 1);
$ids = array();
$pricefield = CRM_Price_BAO_PriceField::create($paramsField, $ids);
//Checking for priceset added in the table.
$this->assertDBCompareValue('CRM_Price_BAO_PriceField', $pricefield->id, 'label', 'id', $paramsField['label'], 'Check DB for created pricefield');
$eventId = $this->_eventId;
$participantParams = array('send_receipt' => 1, 'is_test' => 0, 'is_pay_later' => 0, 'event_id' => $eventId, 'register_date' => date('Y-m-d') . " 00:00:00", 'role_id' => 1, 'status_id' => 1, 'source' => 'Event_' . $eventId, 'contact_id' => $this->_contactId, 'note' => 'Note added for Event_' . $eventId, 'fee_level' => 'Price_Field - 55');
$participant = CRM_Event_BAO_Participant::add($participantParams);
//Checking for participant added in the table.
$this->assertDBCompareValue('CRM_Event_BAO_Participant', $this->_contactId, 'id', 'contact_id', $participant->id, 'Check DB for created participant');
$values = array();
$ids = array();
$params = array('id' => $participant->id);
CRM_Event_BAO_Participant::getValues($params, $values, $ids);
$this->assertNotEquals(count($values), 0, 'Checking for empty array.');
CRM_Event_BAO_Participant::resolveDefaults($values[$participant->id]);
if ($values[$participant->id]['fee_level']) {
CRM_Event_BAO_Participant::fixEventLevel($values[$participant->id]['fee_level']);
}
$deletePricefield = CRM_Price_BAO_PriceField::deleteField($pricefield->id);
$this->assertDBNull('CRM_Price_BAO_PriceField', $pricefield->id, 'name', 'id', 'Check DB for non-existence of Price Field.');
$deletePriceset = CRM_Price_BAO_PriceSet::deleteSet($priceset->id);
$this->assertDBNull('CRM_Price_BAO_PriceSet', $priceset->id, 'title', 'id', 'Check DB for non-existence of Price Set.');
Participant::delete($participant->id);
Contact::delete($this->_contactId);
Event::delete($eventId);
}
示例14: transitionComponents
/**
* This function update contribution as well as related objects.
*/
function transitionComponents($params, $processContributionObject = false)
{
// get minimum required values.
$contactId = CRM_Utils_Array::value('contact_id', $params);
$componentId = CRM_Utils_Array::value('component_id', $params);
$componentName = CRM_Utils_Array::value('componentName', $params);
$contributionId = CRM_Utils_Array::value('contribution_id', $params);
$contributionStatusId = CRM_Utils_Array::value('contribution_status_id', $params);
// if we already processed contribution object pass previous status id.
$previousContriStatusId = CRM_Utils_Array::value('previous_contribution_status_id', $params);
$updateResult = array();
require_once 'CRM/Contribute/PseudoConstant.php';
$contributionStatuses = CRM_Contribute_PseudoConstant::contributionStatus(null, 'name');
// we process only ( Completed, Cancelled, or Failed ) contributions.
if (!$contributionId || !in_array($contributionStatusId, array(array_search('Completed', $contributionStatuses), array_search('Cancelled', $contributionStatuses), array_search('Failed', $contributionStatuses)))) {
return $updateResult;
}
if (!$componentName || !$componentId) {
// get the related component details.
$componentDetails = self::getComponentDetails($contributionId);
} else {
$componentDetails['contact_id'] = $contactId;
$componentDetails['component'] = $componentName;
if ($componentName = 'event') {
$componentDetails['participant'] = $componentId;
} else {
$componentDetails['membership'] = $componentId;
}
}
if (CRM_Utils_Array::value('contact_id', $componentDetails)) {
$componentDetails['contact_id'] = CRM_Core_DAO::getFieldValue('CRM_Contribute_DAO_Contribution', $contributionId, 'contact_id');
}
// do check for required ids.
if (!CRM_Utils_Array::value('membership', $componentDetails) && !CRM_Utils_Array::value('participant', $componentDetails) && !CRM_Utils_Array::value('pledge_payment', $componentDetails) || !CRM_Utils_Array::value('contact_id', $componentDetails)) {
return $updateResult;
}
//now we are ready w/ required ids, start processing.
require_once 'CRM/Core/Payment/BaseIPN.php';
$baseIPN = new CRM_Core_Payment_BaseIPN();
$input = $ids = $objects = array();
$input['component'] = CRM_Utils_Array::value('component', $componentDetails);
$ids['contribution'] = $contributionId;
$ids['contact'] = CRM_Utils_Array::value('contact_id', $componentDetails);
$ids['membership'] = CRM_Utils_Array::value('membership', $componentDetails);
$ids['participant'] = CRM_Utils_Array::value('participant', $componentDetails);
$ids['event'] = CRM_Utils_Array::value('event', $componentDetails);
$ids['pledge_payment'] = CRM_Utils_Array::value('pledge_payment', $componentDetails);
$ids['contributionRecur'] = null;
$ids['contributionPage'] = null;
if (!$baseIPN->validateData($input, $ids, $objects, false)) {
CRM_Core_Error::fatal();
}
$membership =& $objects['membership'];
$participant =& $objects['participant'];
$pledgePayment =& $objects['pledge_payment'];
$contribution =& $objects['contribution'];
if ($pledgePayment) {
require_once 'CRM/Pledge/BAO/Payment.php';
$pledgePaymentIDs = array();
foreach ($pledgePayment as $key => $object) {
$pledgePaymentIDs[] = $object->id;
}
$pledgeID = $pledgePayment[0]->pledge_id;
}
require_once 'CRM/Event/PseudoConstant.php';
require_once 'CRM/Event/BAO/Participant.php';
require_once 'CRM/Pledge/BAO/Pledge.php';
require_once 'CRM/Member/PseudoConstant.php';
require_once 'CRM/Member/BAO/Membership.php';
$membershipStatuses = CRM_Member_PseudoConstant::membershipStatus();
if ($participant) {
$participantStatuses = CRM_Event_PseudoConstant::participantStatus();
$oldStatus = CRM_Core_DAO::getFieldValue("CRM_Event_DAO_Participant", $participant->id, 'status_id');
}
// we might want to process contribution object.
$processContribution = false;
if ($contributionStatusId == array_search('Cancelled', $contributionStatuses)) {
if ($membership) {
$membership->status_id = array_search('Cancelled', $membershipStatuses);
$membership->save();
$updateResult['updatedComponents']['CiviMember'] = $membership->status_id;
if ($processContributionObject) {
$processContribution = true;
}
}
if ($participant) {
$updatedStatusId = array_search('Cancelled', $participantStatuses);
CRM_Event_BAO_Participant::updateParticipantStatus($participant->id, $oldStatus, $updatedStatusId, true);
$updateResult['updatedComponents']['CiviEvent'] = $updatedStatusId;
if ($processContributionObject) {
$processContribution = true;
}
}
if ($pledgePayment) {
CRM_Pledge_BAO_Payment::updatePledgePaymentStatus($pledgeID, $pledgePaymentIDs, $contributionStatusId);
$updateResult['updatedComponents']['CiviPledge'] = $contributionStatusId;
if ($processContributionObject) {
//.........这里部分代码省略.........
示例15: postProcess
/**
* Process the form submission.
*/
public function postProcess()
{
// get the submitted form values.
$params = $this->controller->exportValues($this->_name);
if ($this->_action & CRM_Core_Action::DELETE) {
if (CRM_Utils_Array::value('delete_participant', $params) == 2) {
$additionalId = CRM_Event_BAO_Participant::getAdditionalParticipantIds($this->_id);
$participantLinks = CRM_Event_BAO_Participant::getAdditionalParticipantUrl($additionalId);
}
if (CRM_Utils_Array::value('delete_participant', $params) == 1) {
$additionalIds = CRM_Event_BAO_Participant::getAdditionalParticipantIds($this->_id);
foreach ($additionalIds as $value) {
CRM_Event_BAO_Participant::deleteParticipant($value);
}
}
CRM_Event_BAO_Participant::deleteParticipant($this->_id);
CRM_Core_Session::setStatus(ts('Selected participant was deleted successfully.'), ts('Record Deleted'), 'success');
if (!empty($participantLinks)) {
$status = ts('The following participants no longer have an event fee recorded. You can edit their registration and record a replacement contribution by clicking the links below:') . '<br/>' . $participantLinks;
CRM_Core_Session::setStatus($status, ts('Group Payment Deleted'));
}
return;
}
// When adding a single contact, the formRule prevents you from adding duplicates
// (See above in formRule()). When adding more than one contact, the duplicates are
// removed automatically and the user receives one notification.
if ($this->_action & CRM_Core_Action::ADD) {
$event_id = $this->_eventId;
if (empty($event_id) && !empty($params['event_id'])) {
$event_id = $params['event_id'];
}
if (!$this->_single && !empty($event_id)) {
$duplicateContacts = 0;
while (list($k, $dupeCheckContactId) = each($this->_contactIds)) {
// Eliminate contacts that have already been assigned to this event.
$dupeCheck = new CRM_Event_BAO_Participant();
$dupeCheck->contact_id = $dupeCheckContactId;
$dupeCheck->event_id = $event_id;
$dupeCheck->find(TRUE);
if (!empty($dupeCheck->id)) {
$duplicateContacts++;
unset($this->_contactIds[$k]);
}
}
if ($duplicateContacts > 0) {
$msg = ts("%1 contacts have already been assigned to this event. They were not added a second time.", array(1 => $duplicateContacts));
CRM_Core_Session::setStatus($msg);
}
if (count($this->_contactIds) == 0) {
CRM_Core_Session::setStatus(ts("No participants were added."));
return;
}
// We have to re-key $this->_contactIds so each contact has the same
// key as their corresponding record in the $participants array that
// will be created below.
$this->_contactIds = array_values($this->_contactIds);
}
}
$participantStatus = CRM_Event_PseudoConstant::participantStatus();
// set the contact, when contact is selected
if (!empty($params['contact_id'])) {
$this->_contactId = $params['contact_id'];
}
if ($this->_priceSetId && ($isQuickConfig = CRM_Core_DAO::getFieldValue('CRM_Price_DAO_PriceSet', $this->_priceSetId, 'is_quick_config'))) {
$this->_quickConfig = $isQuickConfig;
}
if ($this->_id) {
$params['id'] = $this->_id;
}
$config = CRM_Core_Config::singleton();
if ($this->_isPaidEvent) {
$contributionParams = array();
$lineItem = array();
$additionalParticipantDetails = array();
if (CRM_Contribute_BAO_Contribution::checkContributeSettings('deferred_revenue_enabled')) {
$eventStartDate = CRM_Core_DAO::getFieldValue('CRM_Event_DAO_Event', $this->_eventId, 'start_date');
if ($eventStartDate) {
$contributionParams['revenue_recognition_date'] = date('Ymd', strtotime($eventStartDate));
}
}
if ($this->_id && $this->_action & CRM_Core_Action::UPDATE && $this->_paymentId) {
$participantBAO = new CRM_Event_BAO_Participant();
$participantBAO->id = $this->_id;
$participantBAO->find(TRUE);
$contributionParams['total_amount'] = $participantBAO->fee_amount;
$params['discount_id'] = NULL;
//re-enter the values for UPDATE mode
$params['fee_level'] = $params['amount_level'] = $participantBAO->fee_level;
$params['fee_amount'] = $participantBAO->fee_amount;
if (isset($params['priceSetId'])) {
$lineItem[0] = CRM_Price_BAO_LineItem::getLineItems($this->_id);
}
//also add additional participant's fee level/priceset
if (CRM_Event_BAO_Participant::isPrimaryParticipant($this->_id)) {
$additionalIds = CRM_Event_BAO_Participant::getAdditionalParticipantIds($this->_id);
$hasLineItems = CRM_Utils_Array::value('priceSetId', $params, FALSE);
$additionalParticipantDetails = CRM_Event_BAO_Participant::getFeeDetails($additionalIds, $hasLineItems);
//.........这里部分代码省略.........