/** * Function to actually build the form * * @return None * @access public */ public function buildQuickForm() { $this->addElement('text', 'api_key', ts('API Key'), array('size' => 48)); $status = CRM_Event_PseudoConstant::participantStatus(NULL, NULL, 'label'); foreach ($status as $id => $Name) { $this->addElement('checkbox', "participant_status_id[{$id}]", NULL, $Name); } $accessToken = CRM_Core_BAO_Setting::getItem(self::WEBINAR_SETTING_GROUP, 'access_token', NULL, FALSE); $organizerKey = CRM_Core_BAO_Setting::getItem(self::WEBINAR_SETTING_GROUP, 'organizer_key', NULL, FALSE); if ($accessToken && $organizerKey) { $upcomingWebinars = CRM_Gotowebinar_Form_Setting::findUpcomingWebinars(); if (isset($upcomingWebinars['int_err_code']) and $upcomingWebinars['int_err_code'] != '') { $this->assign('error', $upcomingWebinars); } else { $this->assign('responseKey', TRUE); $this->assign('upcomingWebinars', $upcomingWebinars); $buttons = array(array('type' => 'submit', 'name' => ts('Save Status'))); $this->addButtons($buttons); } } else { $this->add('text', "email_address", ts('Email Address'), CRM_Core_DAO::getAttribute('CRM_Core_DAO_Email', 'email'), TRUE); $this->add('text', "password", ts('Password'), array('size' => 48), TRUE); $buttons = array(array('type' => 'submit', 'name' => ts('Connect To My GoToWebinar'))); // Add the Buttons. $this->addButtons($buttons); $this->assign('initial', TRUE); } }
/** * Basic page run function. */ public function run() { // Get link options for managing events. $enableCart = CRM_Core_BAO_Setting::getItem(CRM_Core_BAO_Setting::EVENT_PREFERENCES_NAME, 'enable_cart'); $tabs = CRM_Event_Page_ManageEvent::tabs($enableCart); foreach ($tabs as $tab => $tabInfo) { $tabs[$tab]['name'] = $tabInfo['title']; $tabs[$tab]['qs'] = $tab == 'reminder' ? 'reset=1&action=browse&setTab=1&id=%%id%%' : 'reset=1&action=update&id=%%id%%'; } // Get link options for participant listings. $statusTypes = CRM_Event_PseudoConstant::participantStatus(NULL, 'is_counted = 1'); $statusTypesPending = CRM_Event_PseudoConstant::participantStatus(NULL, 'is_counted = 0'); $participantLinks = array(); if (1 || !empty($statusTypes)) { $participantLinks[2] = array('name' => implode(', ', array_values($statusTypes)), 'url' => 'civicrm/event/search', 'qs' => 'reset=1&force=1&status=true&event=%%id%%', 'title' => ts('Counted', array('domain' => 'com.aghstrategies.eventpermissions'))); } if (!empty($statusTypesPending)) { $participantLinks[3] = array('name' => implode(', ', array_values($statusTypesPending)), 'url' => 'civicrm/event/search', 'qs' => 'reset=1&force=1&status=false&event=%%id%%', 'title' => ts('Not Counted', array('domain' => 'com.aghstrategies.eventpermissions'))); } $participantLinks[4] = array('name' => ts('Public Participant Listing', array('domain' => 'com.aghstrategies.eventpermissions')), 'url' => 'civicrm/event/participant', 'qs' => 'reset=1&id=%%id%%', 'title' => ts('Public Participant Listing', array('domain' => 'com.aghstrategies.eventpermissions'))); // Get link options for event links. $eventLinks = array(array('name' => ts('Register Participant', array('domain' => 'com.aghstrategies.eventpermissions')), 'url' => 'civicrm/participant/add', 'qs' => 'reset=1&action=add&context=standalone&eid=%%id%%', 'title' => ts('Register Participant', array('domain' => 'com.aghstrategies.eventpermissions'))), array('name' => ts('Event Info', array('domain' => 'com.aghstrategies.eventpermissions')), 'url' => 'civicrm/event/info', 'qs' => 'reset=1&id=%%id%%', 'title' => ts('Event Info', array('domain' => 'com.aghstrategies.eventpermissions'))), array('name' => ts('Online Registration (Test-drive)', array('domain' => 'com.aghstrategies.eventpermissions')), 'url' => 'civicrm/event/register', 'qs' => 'reset=1&action=preview&id=%%id%%', 'title' => ts('Online Registration (Test-drive)', array('domain' => 'com.aghstrategies.eventpermissions'))), array('name' => ts('Online Registration (Live)', array('domain' => 'com.aghstrategies.eventpermissions')), 'url' => 'civicrm/event/register', 'qs' => 'reset=1&id=%%id%%', 'title' => ts('Online Registration (Live)', array('domain' => 'com.aghstrategies.eventpermissions')))); $utils = new CRM_Eventpermissions_Utils(); $events = array(); foreach ($utils->myUpcomingEvents() as $id => $event) { $events[] = array('title' => CRM_Utils_System::href($event['title'], 'civicrm/event/info', "id={$id}&reset=1"), 'links' => CRM_Core_Action::formLink($tabs, NULL, array('id' => $id), ts('Configure', array('domain' => 'com.aghstrategies.eventpermissions')), TRUE, 'eventpermissions.myevents.configure', 'Event', $id), 'participantLinks' => CRM_Core_Action::formLink($participantLinks, $event['participant_listing_id'] ? 6 : 3, array('id' => $id), ts('Participants', array('domain' => 'com.aghstrategies.eventpermissions')), TRUE, 'eventpermissions.myevents.participants', 'Event', $id), 'eventLinks' => CRM_Core_Action::formLink($eventLinks, NULL, array('id' => $id), ts('Event Links', array('domain' => 'com.aghstrategies.eventpermissions')), TRUE, 'eventpermissions.myevents.links', 'Event', $id)); } $this->assign('events', $events); parent::run(); }
/** * Set up the fields. */ public function __construct() { $this->_columns = array('civicrm_contact' => array('dao' => 'CRM_Contact_DAO_Contact', 'fields' => array('sort_name_linked' => array('title' => ts('Participant Name'), 'dbAlias' => 'contact_civireport.sort_name'), 'first_name' => array('title' => ts('First Name')), 'middle_name' => array('title' => ts('Middle Name')), 'last_name' => array('title' => ts('Last Name')), 'id' => array('no_display' => TRUE, 'required' => TRUE)), 'grouping' => 'contact-fields', 'order_bys' => array('sort_name' => array('title' => ts('Sort Name'))), 'filters' => array('sort_name' => array('title' => ts('Participant Name'), 'operator' => 'like'), 'employer_id' => array('title' => ts('Employer Name')), 'contact_type' => array('title' => ts('Contact Type (Participant)')), 'contact_sub_type' => array('title' => ts('Contact Subtype (Participant)')))), 'organization' => array('name' => 'civicrm_contact', 'dao' => 'CRM_Contact_DAO_Contact', 'fields' => array('display_name' => array('title' => ts('Organization Name'), 'default' => TRUE)), 'order_bys' => array('org_sort_name' => array('name' => 'sort_name', 'title' => ts('Organization Name'), 'default' => '1', 'default_weight' => '0', 'default_order' => 'ASC')), 'group_bys' => array('org_id' => array('name' => 'id', 'title' => ts('Organization')))), 'civicrm_event' => array('dao' => 'CRM_Event_DAO_Event', 'grouping' => 'event-fields', 'filters' => array('eid' => array('name' => 'event_type_id', 'title' => ts('Event Type (Recent Period)'), 'operatorType' => CRM_Report_Form::OP_MULTISELECT, 'options' => CRM_Core_OptionGroup::values('event_type'), 'joinclause' => TRUE), 'event_start_date1' => array('title' => ts('Event Start Date (Recent Period)'), 'type' => CRM_Utils_Type::T_DATE, 'operatorType' => CRM_Report_Form::OP_DATE, 'name' => 'event_start_date', 'default' => 'this.year', 'joinclause' => TRUE))), 'civicrm_participant' => array('dao' => 'CRM_Event_DAO_Participant', 'fields' => array('participant_id' => array('title' => 'Participant ID (Recent Period)'), 'participant_record' => array('name' => 'id', 'no_display' => TRUE, 'required' => TRUE), 'event_id' => array('default' => TRUE, 'title' => ts('Events Attended (Recent Period)'), 'statistics' => array('count_distinct' => ts('Events Attended (Recent Period)'))), 'unique_staff' => array('name' => 'contact_id', 'default' => TRUE, 'title' => ts('Unique Staff'), 'statistics' => array('count_distinct' => ts('Unique Staff (Recent Period)')))), 'grouping' => 'event-fields', 'filters' => array('event_id' => array('name' => 'event_id', 'title' => ts('Event (Recent Period)'), 'operatorType' => CRM_Report_Form::OP_ENTITYREF, 'type' => CRM_Utils_Type::T_INT, 'attributes' => array('entity' => 'event', 'select' => array('minimumInputLength' => 0)), 'joinclause' => TRUE), 'sid' => array('name' => 'status_id', 'title' => ts('Participant Status (Recent Period)'), 'operatorType' => CRM_Report_Form::OP_MULTISELECT, 'options' => CRM_Event_PseudoConstant::participantStatus(NULL, NULL, 'label'), 'joinclause' => TRUE), 'rid' => array('name' => 'role_id', 'title' => ts('Participant Role (Recent Period)'), 'operatorType' => CRM_Report_Form::OP_MULTISELECT, 'options' => CRM_Event_PseudoConstant::participantRole(), 'joinclause' => TRUE), 'participant_register_date' => array('title' => ts('Registration Date (Recent Period)'), 'operatorType' => CRM_Report_Form::OP_DATE, 'joinclause' => TRUE))), 'civicrm_event2' => array('name' => 'civicrm_event', 'dao' => 'CRM_Event_DAO_Event', 'grouping' => 'event-fields', 'filters' => array('eid2' => array('name' => 'event_type_id', 'title' => ts('Event Type (Prior Period)'), 'operatorType' => CRM_Report_Form::OP_MULTISELECT, 'options' => CRM_Core_OptionGroup::values('event_type'), 'joinclause' => TRUE), 'event_start_date2' => array('title' => ts('Event Start Date (Prior Period)'), 'type' => CRM_Utils_Type::T_DATE, 'operatorType' => CRM_Report_Form::OP_DATE, 'name' => 'event_start_date', 'default' => 'previous.year', 'joinclause' => TRUE))), 'civicrm_participant2' => array('name' => 'civicrm_participant', 'dao' => 'CRM_Event_DAO_Participant', 'fields' => array('participant_id' => array('title' => 'Participant ID (Prior Period)'), 'participant_record2' => array('name' => 'id', 'no_display' => TRUE, 'required' => TRUE), 'event_id2' => array('name' => 'event_id', 'default' => TRUE, 'title' => ts('Events Attended (Prior Period)'), 'statistics' => array('count_distinct' => ts('Events Attended (Prior Period)'))), 'unique_staff2' => array('name' => 'contact_id', 'default' => TRUE, 'title' => ts('Unique Staff (Prior Period)'), 'statistics' => array('count_distinct' => ts('Unique Staff (Prior Period)')))), 'grouping' => 'event-fields', 'filters' => array('event_id2' => array('name' => 'event_id', 'title' => ts('Event (Prior Period)'), 'operatorType' => CRM_Report_Form::OP_ENTITYREF, 'type' => CRM_Utils_Type::T_INT, 'attributes' => array('entity' => 'event', 'select' => array('minimumInputLength' => 0)), 'joinclause' => TRUE), 'sid2' => array('name' => 'status_id', 'title' => ts('Participant Status (Prior Period)'), 'operatorType' => CRM_Report_Form::OP_MULTISELECT, 'options' => CRM_Event_PseudoConstant::participantStatus(NULL, NULL, 'label'), 'joinclause' => TRUE), 'rid' => array('name' => 'role_id', 'title' => ts('Participant Role (Prior Period)'), 'operatorType' => CRM_Report_Form::OP_MULTISELECT, 'options' => CRM_Event_PseudoConstant::participantRole(), 'joinclause' => TRUE), 'participant_register_date2' => array('name' => 'participant_register_date', 'title' => ts('Registration Date (Prior Period)'), 'operatorType' => CRM_Report_Form::OP_DATE, 'joinclause' => TRUE)))); $this->_groupFilter = TRUE; $this->_tagFilter = TRUE; parent::__construct(); $this->_columns['civicrm_group']['filters']['gid']['title'] = ts('Group (Employer)'); $this->_columns['civicrm_tag']['filters']['tagid']['title'] = ts('Tag (Employer)'); }
/** * @param array $params * @param $participant * @param $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(); $paymentParticpant = 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; }
public function buildQuickForm() { // CRM_Event_Form_Task_Batch::buildQuickForm() gets ufGroupId // from the form, so set it here to the id of the reserved profile $dao = new CRM_Core_DAO_UFGroup(); $dao->name = 'participant_status'; $dao->find(TRUE); $this->set('ufGroupId', $dao->id); $statuses = CRM_Event_PseudoConstant::participantStatus(NULL, NULL, 'label'); asort($statuses, SORT_STRING); $this->add('select', 'status_change', ts('Change All Statuses'), array('' => ts('- select status -')) + $statuses); $this->assign('context', 'statusChange'); # CRM-4321: display info on users being notified if any of the below statuses is enabled parent::assignToTemplate(); parent::buildQuickForm(); }
function run() { $this->preProcess(); $fromClause = "\nFROM civicrm_contact\nINNER JOIN civicrm_participant ON civicrm_contact.id = civicrm_participant.contact_id \nINNER JOIN civicrm_event ON civicrm_participant.event_id = civicrm_event.id\n"; $whereClause = "\nWHERE civicrm_event.id = %1"; $params = array(1 => array($this->_id, 'Integer')); $this->pager($fromClause, $whereClause, $params); $orderBy = $this->orderBy(); list($offset, $rowCount) = $this->_pager->getOffsetAndRowCount(); $query = "\nSELECT civicrm_contact.id as contact_id ,\n civicrm_contact.display_name as name ,\n civicrm_contact.sort_name as sort_name ,\n civicrm_participant.id as participant_id,\n civicrm_participant.status_id as status_id ,\n civicrm_participant.register_date as register_date\n {$fromClause}\n {$whereClause}\nORDER BY {$orderBy}\nLIMIT {$offset}, {$rowCount}"; $rows = array(); $object = CRM_Core_DAO::executeQuery($query, $params); $statusLookup = CRM_Event_PseudoConstant::participantStatus(); while ($object->fetch()) { $row = array('id' => $object->contact_id, 'participantID' => $object->participant_id, 'name' => $object->name, 'email' => $object->email, 'status' => CRM_Utils_Array::value($object->status_id, $statusLookup), 'date' => $object->register_date); $rows[] = $row; } $this->assign_by_ref('rows', $rows); return parent::run(); }
function buildQuickForm() { // CRM_Event_Form_Task_Batch::buildQuickForm() gets ufGroupId // from the form, so set it here to the id of the reserved profile require_once 'CRM/Core/DAO/UFGroup.php'; $dao = new CRM_Core_DAO_UFGroup(); $dao->name = 'participant_status'; $dao->find(true); $this->set('ufGroupId', $dao->id); require_once 'CRM/Event/PseudoConstant.php'; $statuses =& CRM_Event_PseudoConstant::participantStatus(); asort($statuses, SORT_STRING); $this->add('select', 'status_change', ts('Change All Statuses'), array('' => ts('- select status -')) + $statuses, null, array('onchange' => "if (this.value) setStatusesTo(this.value);")); $this->assign('context', 'statusChange'); # CRM-4321: display info on users being notified if any of the below statuses is enabled require_once 'CRM/Event/PseudoConstant.php'; $notifyingStatuses = array(ts('Pending from waitlist'), ts('Pending from approval'), ts('Expired'), ts('Cancelled')); $notifyingStatuses = array_intersect($notifyingStatuses, CRM_Event_PseudoConstant::participantStatus()); $this->assign('notifyingStatuses', implode(', ', $notifyingStatuses)); parent::buildQuickForm(); }
/** * @return mixed */ public static function get_pending_in_cart_status_id() { $status_types = CRM_Event_PseudoConstant::participantStatus(NULL, "name='Pending in cart'"); $status_names = array_keys($status_types); return end($status_names); }
/** * Get additional participant Ids for cascading with primary participant status. * * @param int $participantId * Participant id. * @param int $oldStatusId * Previous status. * @param int $newStatusId * New status. * * @return bool * true if allowed */ public static function getValidAdditionalIds($participantId, $oldStatusId, $newStatusId) { $additionalParticipantIds = array(); static $participantStatuses = array(); if (empty($participantStatuses)) { $participantStatuses = CRM_Event_PseudoConstant::participantStatus(); } if (CRM_Utils_Array::value($participantStatuses[$oldStatusId], self::$_statusTransitionsRules) && in_array($participantStatuses[$newStatusId], self::$_statusTransitionsRules[$participantStatuses[$oldStatusId]])) { $additionalParticipantIds = self::getAdditionalParticipantIds($participantId, TRUE, $oldStatusId); } return $additionalParticipantIds; }
/** * Function to process the form * * @access public * * @return void */ public function postProcess() { //get the button. $buttonName = $this->controller->getButtonName(); $participantId = $this->_participantId; if ($buttonName == '_qf_ParticipantConfirm_next') { //lets get contact id in session. $session = CRM_Core_Session::singleton(); $session->set('userID', $this->_csContactID); $this->postProcessHook(); //check user registration status is from pending class $url = CRM_Utils_System::url('civicrm/event/register', "reset=1&id={$this->_eventId}&participantId={$participantId}"); CRM_Utils_System::redirect($url); } elseif ($buttonName == '_qf_ParticipantConfirm_submit') { //need to registration status to 'cancelled'. $cancelledId = array_search('Cancelled', CRM_Event_PseudoConstant::participantStatus(NULL, "class = 'Negative'")); $additionalParticipantIds = CRM_Event_BAO_Participant::getAdditionalParticipantIds($participantId); $participantIds = array_merge(array($participantId), $additionalParticipantIds); $results = CRM_Event_BAO_Participant::transitionParticipants($participantIds, $cancelledId, NULL, TRUE); if (count($participantIds) > 1) { $statusMessage = ts("%1 Event registration(s) have been cancelled.", array(1 => count($participantIds))); } else { $statusMessage = ts("Your event registration has been cancelled."); } if (!empty($results['mailedParticipants'])) { foreach ($results['mailedParticipants'] as $key => $displayName) { $statusMessage .= "<br />" . ts("Email has been sent to : %1", array(1 => $displayName)); } } $this->postProcessHook(); CRM_Core_Error::statusBounce($statusMessage, CRM_Utils_System::url('civicrm/event/info', "reset=1&id={$this->_eventId}&noFullMsg=1", FALSE, NULL, FALSE, TRUE)); } }
/** * Returns all the rows in the given offset and rowCount. * * @param string $action * The action being performed. * @param int $offset * The row number to start from. * @param int $rowCount * The number of rows to return. * @param string $sort * The sql string that describes the sort order. * @param string $output * What should the result set include (web/email/csv). * * @return array * rows in the given offset and rowCount */ public function &getRows($action, $offset, $rowCount, $sort, $output = NULL) { $result = $this->_query->searchQuery($offset, $rowCount, $sort, FALSE, FALSE, FALSE, FALSE, FALSE, $this->_eventClause); // process the result of the query $rows = array(); //lets handle view, edit and delete separately. CRM-4418 $permissions = array(CRM_Core_Permission::VIEW); if (CRM_Core_Permission::check('edit event participants')) { $permissions[] = CRM_Core_Permission::EDIT; } if (CRM_Core_Permission::check('delete in CiviEvent')) { $permissions[] = CRM_Core_Permission::DELETE; } $mask = CRM_Core_Action::mask($permissions); $statusTypes = CRM_Event_PseudoConstant::participantStatus(); $statusClasses = CRM_Event_PseudoConstant::participantStatusClass(); $participantRoles = CRM_Event_PseudoConstant::participantRole(); $sep = CRM_Core_DAO::VALUE_SEPARATOR; //get all campaigns. $allCampaigns = CRM_Campaign_BAO_Campaign::getCampaigns(NULL, NULL, FALSE, FALSE, FALSE, TRUE); while ($result->fetch()) { $row = array(); // the columns we are interested in foreach (self::$_properties as $property) { if (isset($result->{$property})) { $row[$property] = $result->{$property}; } } //carry campaign on selectors. $row['campaign'] = CRM_Utils_Array::value($result->participant_campaign_id, $allCampaigns); $row['campaign_id'] = $result->participant_campaign_id; // gross hack to show extra information for pending status $statusClass = NULL; if (isset($row['participant_status_id']) && ($statusId = array_search($row['participant_status_id'], $statusTypes))) { $statusClass = $statusClasses[$statusId]; } $row['showConfirmUrl'] = $statusClass == 'Pending' ? TRUE : FALSE; if (!empty($row['participant_is_test'])) { $row['participant_status'] .= ' (' . ts('test') . ')'; } $row['checkbox'] = CRM_Core_Form::CB_PREFIX . $result->participant_id; $links = self::links($this->_key, $this->_context, $this->_compContext); if ($statusTypes[$row['participant_status_id']] == 'Partially paid') { $links[CRM_Core_Action::ADD] = array('name' => ts('Record Payment'), 'url' => 'civicrm/payment', 'qs' => 'reset=1&id=%%id%%&cid=%%cid%%&action=add&component=event', 'title' => ts('Record Payment')); } if ($statusTypes[$row['participant_status_id']] == 'Pending refund') { $links[CRM_Core_Action::ADD] = array('name' => ts('Record Refund'), 'url' => 'civicrm/payment', 'qs' => 'reset=1&id=%%id%%&cid=%%cid%%&action=add&component=event', 'title' => ts('Record Refund')); } $row['action'] = CRM_Core_Action::formLink($links, $mask, array('id' => $result->participant_id, 'cid' => $result->contact_id, 'cxt' => $this->_context), ts('more'), FALSE, 'participant.selector.row', 'Participant', $result->participant_id); $row['contact_type'] = CRM_Contact_BAO_Contact_Utils::getImage($result->contact_sub_type ? $result->contact_sub_type : $result->contact_type, FALSE, $result->contact_id); $row['paid'] = CRM_Event_BAO_Event::isMonetary($row['event_id']); if (!empty($row['participant_fee_level'])) { CRM_Event_BAO_Participant::fixEventLevel($row['participant_fee_level']); } if (CRM_Event_BAO_Event::usesPriceSet($row['event_id'])) { // add line item details if applicable $lineItems[$row['participant_id']] = CRM_Price_BAO_LineItem::getLineItems($row['participant_id']); } if (!empty($row['participant_role_id'])) { $viewRoles = array(); foreach (explode($sep, $row['participant_role_id']) as $k => $v) { $viewRoles[] = $participantRoles[$v]; } $row['participant_role_id'] = implode(', ', $viewRoles); } $rows[] = $row; } CRM_Core_Selector_Controller::$_template->assign_by_ref('lineItems', $lineItems); return $rows; }
/** * Add activity for Membership/Event/Contribution. * * @param object $activity * (reference) particular component object. * @param string $activityType * For Membership Signup or Renewal. * @param int $targetContactID * * @return bool|NULL */ public static function addActivity(&$activity, $activityType = 'Membership Signup', $targetContactID = NULL) { if ($activity->__table == 'civicrm_membership') { $membershipType = CRM_Member_PseudoConstant::membershipType($activity->membership_type_id); if (!$membershipType) { $membershipType = ts('Membership'); } $subject = "{$membershipType}"; if (!empty($activity->source) && $activity->source != 'null') { $subject .= " - {$activity->source}"; } if ($activity->owner_membership_id) { $query = "\nSELECT display_name\n FROM civicrm_contact, civicrm_membership\n WHERE civicrm_contact.id = civicrm_membership.contact_id\n AND civicrm_membership.id = {$activity->owner_membership_id}\n"; $displayName = CRM_Core_DAO::singleValueQuery($query); $subject .= " (by {$displayName})"; } $subject .= " - Status: " . CRM_Core_DAO::getFieldValue('CRM_Member_DAO_MembershipStatus', $activity->status_id, 'label'); // CRM-72097 changed from start date to today $date = date('YmdHis'); $component = 'Membership'; } elseif ($activity->__table == 'civicrm_participant') { $event = CRM_Event_BAO_Event::getEvents(1, $activity->event_id, TRUE, FALSE); $roles = CRM_Event_PseudoConstant::participantRole(); $status = CRM_Event_PseudoConstant::participantStatus(); $subject = $event[$activity->event_id]; if (!empty($roles[$activity->role_id])) { $subject .= ' - ' . $roles[$activity->role_id]; } if (!empty($status[$activity->status_id])) { $subject .= ' - ' . $status[$activity->status_id]; } $date = date('YmdHis'); if ($activityType != 'Email') { $activityType = 'Event Registration'; } $component = 'Event'; } elseif ($activity->__table == 'civicrm_contribution') { // create activity record only for Completed Contributions if ($activity->contribution_status_id != 1) { return NULL; } $subject = NULL; $subject .= CRM_Utils_Money::format($activity->total_amount, $activity->currency); if (!empty($activity->source) && $activity->source != 'null') { $subject .= " - {$activity->source}"; } $date = CRM_Utils_Date::isoToMysql($activity->receive_date); $activityType = $component = 'Contribution'; } $activityParams = array('source_contact_id' => $activity->contact_id, 'source_record_id' => $activity->id, 'activity_type_id' => CRM_Core_OptionGroup::getValue('activity_type', $activityType, 'name'), 'subject' => $subject, 'activity_date_time' => $date, 'is_test' => $activity->is_test, 'status_id' => CRM_Core_OptionGroup::getValue('activity_status', 'Completed', 'name'), 'skipRecentView' => TRUE, 'campaign_id' => $activity->campaign_id); // create activity with target contacts $session = CRM_Core_Session::singleton(); $id = $session->get('userID'); if ($id) { $activityParams['source_contact_id'] = $id; $activityParams['target_contact_id'][] = $activity->contact_id; } // CRM-14945 if (property_exists($activity, 'details')) { $activityParams['details'] = $activity->details; } //CRM-4027 if ($targetContactID) { $activityParams['target_contact_id'][] = $targetContactID; } if (is_a(self::create($activityParams), 'CRM_Core_Error')) { CRM_Core_Error::fatal("Failed creating Activity for {$component} of id {$activity->id}"); return FALSE; } }
function __construct() { $this->_columns = array('civicrm_event' => array('dao' => 'CRM_Event_DAO_Event', 'fields' => array('title' => array('title' => ts('Event'), 'required' => TRUE), 'id' => array('no_display' => TRUE, 'required' => TRUE), 'event_type_id' => array('title' => ts('Event Type')), 'fee_label' => array('title' => ts('Fee Label')), 'event_start_date' => array('title' => ts('Event Start Date')), 'event_end_date' => array('title' => ts('Event End Date')), 'max_participants' => array('title' => ts('Capacity'), 'type' => CRM_Utils_Type::T_INT)), 'filters' => array('id' => array('title' => ts('Event Title'), 'operatorType' => CRM_Report_Form::OP_MULTISELECT, 'options' => CRM_Event_PseudoConstant::event(NULL, NULL, "is_template IS NULL OR is_template = 0")), 'event_type_id' => array('name' => 'event_type_id', 'title' => ts('Event Type'), 'operatorType' => CRM_Report_Form::OP_MULTISELECT, 'options' => CRM_Core_OptionGroup::values('event_type')), 'event_start_date' => array('title' => ts('Event Start Date'), 'operatorType' => CRM_Report_Form::OP_DATE), 'event_end_date' => array('title' => ts('Event End Date'), 'operatorType' => CRM_Report_Form::OP_DATE))), 'civicrm_line_item' => array('dao' => 'CRM_Price_DAO_LineItem', 'fields' => array('participant_count' => array('title' => ts('Participants'), 'default' => TRUE, 'statistics' => array('count' => ts('Participants'))), 'line_total' => array('title' => ts('Income Statistics'), 'type' => CRM_Utils_Type::T_MONEY, 'default' => TRUE, 'statistics' => array('sum' => ts('Income'), 'avg' => ts('Average'))))), 'civicrm_participant' => array('dao' => 'CRM_Event_DAO_Participant', 'filters' => array('sid' => array('name' => 'status_id', 'title' => ts('Participant Status'), 'operatorType' => CRM_Report_Form::OP_MULTISELECT, 'options' => CRM_Event_PseudoConstant::participantStatus()), 'rid' => array('name' => 'role_id', 'title' => ts('Participant Role'), 'operatorType' => CRM_Report_Form::OP_MULTISELECT, 'options' => CRM_Event_PseudoConstant::participantRole()), 'participant_register_date' => array('title' => ts('Registration Date'), 'operatorType' => CRM_Report_Form::OP_DATE)))); parent::__construct(); }
/** * Retrieve list of Scheduled Reminders * * @param bool $namesOnly return simple list of names * * @param null $entityValue * @param null $id * * @return array (reference) reminder list * @static * @access public */ static function &getList($namesOnly = FALSE, $entityValue = NULL, $id = NULL) { $activity_type = CRM_Core_PseudoConstant::activityType(TRUE, TRUE); $activity_status = CRM_Core_PseudoConstant::activityStatus(); $event_type = CRM_Event_PseudoConstant::eventType(); $civicrm_event = CRM_Event_PseudoConstant::event(NULL, FALSE, "( is_template IS NULL OR is_template != 1 )"); $civicrm_participant_status_type = CRM_Event_PseudoConstant::participantStatus(NULL, NULL, 'label'); $event_template = CRM_Event_PseudoConstant::eventTemplates(); $civicrm_contact = self::getDateFields(); $auto_renew_options = CRM_Core_OptionGroup::values('auto_renew_options'); $contact_date_reminder_options = CRM_Core_OptionGroup::values('contact_date_reminder_options'); $civicrm_membership_type = CRM_Member_PseudoConstant::membershipType(); $entity = array('civicrm_activity' => 'Activity', 'civicrm_participant' => 'Event', 'civicrm_membership' => 'Member', 'civicrm_contact' => 'Contact'); $query = "\nSELECT\n title,\n cam.entity,\n cas.id as id,\n cam.entity_value as entityValue,\n cas.entity_value as entityValueIds,\n cam.entity_status as entityStatus,\n cas.entity_status as entityStatusIds,\n cas.start_action_date as entityDate,\n cas.start_action_offset,\n cas.start_action_unit,\n cas.start_action_condition,\n cas.absolute_date,\n is_repeat,\n is_active\n\nFROM civicrm_action_schedule cas\nLEFT JOIN civicrm_action_mapping cam ON (cam.id = cas.mapping_id)\n"; $params = CRM_Core_DAO::$_nullArray; if ($entityValue and $id) { $where = "\nWHERE cas.entity_value = {$id} AND\n cam.entity_value = '{$entityValue}'"; $query .= $where; $params = array(1 => array($id, 'Integer'), 2 => array($entityValue, 'String')); } $dao = CRM_Core_DAO::executeQuery($query); while ($dao->fetch()) { $list[$dao->id]['id'] = $dao->id; $list[$dao->id]['title'] = $dao->title; $list[$dao->id]['start_action_offset'] = $dao->start_action_offset; $list[$dao->id]['start_action_unit'] = $dao->start_action_unit; $list[$dao->id]['start_action_condition'] = $dao->start_action_condition; $list[$dao->id]['entityDate'] = ucwords(str_replace('_', ' ', $dao->entityDate)); $list[$dao->id]['absolute_date'] = $dao->absolute_date; $status = $dao->entityStatus; $statusArray = explode(CRM_Core_DAO::VALUE_SEPARATOR, $dao->entityStatusIds); foreach ($statusArray as &$s) { $s = CRM_Utils_Array::value($s, ${$status}); } $statusIds = implode(', ', $statusArray); $value = $dao->entityValue; $valueArray = explode(CRM_Core_DAO::VALUE_SEPARATOR, $dao->entityValueIds); foreach ($valueArray as &$v) { $v = CRM_Utils_Array::value($v, ${$value}); } $valueIds = implode(', ', $valueArray); $list[$dao->id]['entity'] = $entity[$dao->entity]; $list[$dao->id]['value'] = $valueIds; $list[$dao->id]['status'] = $statusIds; $list[$dao->id]['is_repeat'] = $dao->is_repeat; $list[$dao->id]['is_active'] = $dao->is_active; } return $list; }
/** * @param $params * * @return bool */ static function checkRegistration($params) { $alreadyRegistered = FALSE; if (empty($params['contact_id'])) { return $alreadyRegistered; } $statusTypes = CRM_Event_PseudoConstant::participantStatus(NULL, 'is_counted = 1'); $participant = new CRM_Event_DAO_Participant(); $participant->copyValues($params); $participant->is_test = CRM_Utils_Array::value('is_test', $params, 0); $participant->selectAdd(); $participant->selectAdd('status_id'); if ($participant->find(TRUE) && array_key_exists($participant->status_id, $statusTypes)) { $alreadyRegistered = TRUE; } return $alreadyRegistered; }
/** * Function to record additional payment for partial and refund contributions. * * @param int $contributionId * is the invoice contribution id (got created after processing participant payment). * @param array $trxnsData * to take user provided input of transaction details. * @param string $paymentType * 'owed' for purpose of recording partial payments, 'refund' for purpose of recording refund payments. * @param int $participantId * * @return null|object */ public static function recordAdditionalPayment($contributionId, $trxnsData, $paymentType = 'owed', $participantId = NULL) { $statusId = CRM_Core_OptionGroup::getValue('contribution_status', 'Completed', 'name'); $getInfoOf['id'] = $contributionId; $defaults = array(); $contributionDAO = CRM_Contribute_BAO_Contribution::retrieve($getInfoOf, $defaults, CRM_Core_DAO::$_nullArray); if ($paymentType == 'owed') { // build params for recording financial trxn entry $params['contribution'] = $contributionDAO; $params = array_merge($defaults, $params); $params['skipLineItem'] = TRUE; $params['partial_payment_total'] = $contributionDAO->total_amount; $params['partial_amount_pay'] = $trxnsData['total_amount']; $trxnsData['trxn_date'] = !empty($trxnsData['trxn_date']) ? $trxnsData['trxn_date'] : date('YmdHis'); $trxnsData['net_amount'] = !empty($trxnsData['net_amount']) ? $trxnsData['net_amount'] : $trxnsData['total_amount']; // record the entry $financialTrxn = CRM_Contribute_BAO_Contribution::recordFinancialAccounts($params, $trxnsData); $relationTypeId = key(CRM_Core_PseudoConstant::accountOptionValues('account_relationship', NULL, " AND v.name LIKE 'Accounts Receivable Account is' ")); $toFinancialAccount = CRM_Contribute_PseudoConstant::financialAccountType($contributionDAO->financial_type_id, $relationTypeId); $trxnId = CRM_Core_BAO_FinancialTrxn::getBalanceTrxnAmt($contributionId, $contributionDAO->financial_type_id); if (!empty($trxnId)) { $trxnId = $trxnId['trxn_id']; } elseif (!empty($contributionDAO->payment_instrument_id)) { $trxnId = CRM_Financial_BAO_FinancialTypeAccount::getInstrumentFinancialAccount($contributionDAO->payment_instrument_id); } else { $relationTypeId = key(CRM_Core_PseudoConstant::accountOptionValues('financial_account_type', NULL, " AND v.name LIKE 'Asset' ")); $queryParams = array(1 => array($relationTypeId, 'Integer')); $trxnId = CRM_Core_DAO::singleValueQuery("SELECT id FROM civicrm_financial_account WHERE is_default = 1 AND financial_account_type_id = %1", $queryParams); } // update statuses // criteria for updates contribution total_amount == financial_trxns of partial_payments $sql = "SELECT SUM(ft.total_amount) as sum_of_payments, SUM(ft.net_amount) as net_amount_total\nFROM civicrm_financial_trxn ft\nLEFT JOIN civicrm_entity_financial_trxn eft\n ON (ft.id = eft.financial_trxn_id)\nWHERE eft.entity_table = 'civicrm_contribution'\n AND eft.entity_id = {$contributionId}\n AND ft.to_financial_account_id != {$toFinancialAccount}\n AND ft.status_id = {$statusId}\n"; $query = CRM_Core_DAO::executeQuery($sql); $query->fetch(); $sumOfPayments = $query->sum_of_payments; // update statuses if ($contributionDAO->total_amount == $sumOfPayments) { // update contribution status and // clean cancel info (if any) if prev. contribution was updated in case of 'Refunded' => 'Completed' $contributionDAO->contribution_status_id = $statusId; $contributionDAO->cancel_date = 'null'; $contributionDAO->cancel_reason = NULL; $netAmount = !empty($trxnsData['net_amount']) ? NULL : $trxnsData['total_amount']; $contributionDAO->net_amount = $query->net_amount_total + $netAmount; $contributionDAO->fee_amount = $contributionDAO->total_amount - $contributionDAO->net_amount; $contributionDAO->save(); //Change status of financial record too $financialTrxn->status_id = $statusId; $financialTrxn->save(); // note : not using the self::add method, // the reason because it performs 'status change' related code execution for financial records // which in 'Partial Paid' => 'Completed' is not useful, instead specific financial record updates // are coded below i.e. just updating financial_item status to 'Paid' if ($participantId) { // update participant status $participantStatuses = CRM_Event_PseudoConstant::participantStatus(); $ids = CRM_Event_BAO_Participant::getParticipantIds($contributionId); foreach ($ids as $val) { $participantUpdate['id'] = $val; $participantUpdate['status_id'] = array_search('Registered', $participantStatuses); CRM_Event_BAO_Participant::add($participantUpdate); } } // update financial item statuses $financialItemStatus = CRM_Core_PseudoConstant::get('CRM_Financial_DAO_FinancialItem', 'status_id'); $paidStatus = array_search('Paid', $financialItemStatus); $baseTrxnId = CRM_Core_BAO_FinancialTrxn::getFinancialTrxnId($contributionId); $sqlFinancialItemUpdate = "\nUPDATE civicrm_financial_item fi\n LEFT JOIN civicrm_entity_financial_trxn eft\n ON (eft.entity_id = fi.id AND eft.entity_table = 'civicrm_financial_item')\nSET status_id = {$paidStatus}\nWHERE eft.financial_trxn_id IN ({$trxnId}, {$baseTrxnId['financialTrxnId']})\n"; CRM_Core_DAO::executeQuery($sqlFinancialItemUpdate); } } elseif ($paymentType == 'refund') { // build params for recording financial trxn entry $params['contribution'] = $contributionDAO; $params = array_merge($defaults, $params); $params['skipLineItem'] = TRUE; $trxnsData['trxn_date'] = !empty($trxnsData['trxn_date']) ? $trxnsData['trxn_date'] : date('YmdHis'); $trxnsData['total_amount'] = -$trxnsData['total_amount']; $relationTypeId = key(CRM_Core_PseudoConstant::accountOptionValues('account_relationship', NULL, " AND v.name LIKE 'Accounts Receivable Account is' ")); $trxnsData['from_financial_account_id'] = CRM_Contribute_PseudoConstant::financialAccountType($contributionDAO->financial_type_id, $relationTypeId); $trxnsData['status_id'] = CRM_Core_OptionGroup::getValue('contribution_status', 'Refunded', 'name'); // record the entry $financialTrxn = CRM_Contribute_BAO_Contribution::recordFinancialAccounts($params, $trxnsData); // note : not using the self::add method, // the reason because it performs 'status change' related code execution for financial records // which in 'Pending Refund' => 'Completed' is not useful, instead specific financial record updates // are coded below i.e. just updating financial_item status to 'Paid' $contributionDetails = CRM_Core_DAO::setFieldValue('CRM_Contribute_BAO_Contribution', $contributionId, 'contribution_status_id', $statusId); // add financial item entry $financialItemStatus = CRM_Core_PseudoConstant::get('CRM_Financial_DAO_FinancialItem', 'status_id'); $getLine['entity_id'] = $contributionDAO->id; $getLine['entity_table'] = 'civicrm_contribution'; $lineItemId = CRM_Price_BAO_LineItem::retrieve($getLine, CRM_Core_DAO::$_nullArray); if (!empty($lineItemId->id)) { $addFinancialEntry = array('transaction_date' => $financialTrxn->trxn_date, 'contact_id' => $contributionDAO->contact_id, 'amount' => $financialTrxn->total_amount, 'status_id' => array_search('Paid', $financialItemStatus), 'entity_id' => $lineItemId->id, 'entity_table' => 'civicrm_line_item'); $trxnIds['id'] = $financialTrxn->id; CRM_Financial_BAO_FinancialItem::create($addFinancialEntry, NULL, $trxnIds); } if ($participantId) { // update participant status $participantStatuses = CRM_Event_PseudoConstant::participantStatus(); $ids = CRM_Event_BAO_Participant::getParticipantIds($contributionId); foreach ($ids as $val) { $participantUpdate['id'] = $val; $participantUpdate['status_id'] = array_search('Registered', $participantStatuses); CRM_Event_BAO_Participant::add($participantUpdate); } } } // activity creation if (!empty($financialTrxn)) { if ($participantId) { $inputParams['id'] = $participantId; $values = array(); $ids = array(); $component = 'event'; $entityObj = CRM_Event_BAO_Participant::getValues($inputParams, $values, $ids); $entityObj = $entityObj[$participantId]; } $activityType = $paymentType == 'refund' ? 'Refund' : 'Payment'; self::addActivityForPayment($entityObj, $financialTrxn, $activityType, $component, $contributionId); } return $financialTrxn; }
/** * Build the form object. */ public function buildQuickForm() { //need to assign custom data type and subtype to the template $this->assign('customDataType', 'Event'); if ($this->_eventType) { $this->assign('customDataSubType', $this->_eventType); } $this->assign('entityId', $this->_id); $this->_first = TRUE; $this->applyFilter('__ALL__', 'trim'); $attributes = CRM_Core_DAO::getAttribute('CRM_Event_DAO_Event'); if ($this->_isTemplate) { $this->add('text', 'template_title', ts('Template Title'), $attributes['template_title'], TRUE); } if ($this->_action & CRM_Core_Action::ADD) { $eventTemplates = CRM_Event_PseudoConstant::eventTemplates(); if (CRM_Utils_System::isNull($eventTemplates) && !$this->_isTemplate) { $url = CRM_Utils_System::url('civicrm/admin/eventTemplate', array('reset' => 1)); CRM_Core_Session::setStatus(ts('If you find that you are creating multiple events with similar settings, you may want to use the <a href="%1">Event Templates</a> feature to streamline your workflow.', array(1 => $url)), ts('Tip'), 'info'); } if (!CRM_Utils_System::isNull($eventTemplates)) { $this->add('select', 'template_id', ts('From Template'), array('' => ts('- select -')) + $eventTemplates, FALSE, array('class' => 'crm-select2 huge')); } // Make sure this form redirects properly $this->preventAjaxSubmit(); } // add event title, make required if this is not a template $this->add('text', 'title', ts('Event Title'), $attributes['event_title'], !$this->_isTemplate); $this->addSelect('event_type_id', array('onChange' => "CRM.buildCustomData( 'Event', this.value );"), TRUE); //CRM-7362 --add campaigns. $campaignId = NULL; if ($this->_id) { $campaignId = CRM_Core_DAO::getFieldValue('CRM_Event_DAO_Event', $this->_id, 'campaign_id'); } CRM_Campaign_BAO_Campaign::addCampaign($this, $campaignId); $this->addSelect('default_role_id', array(), TRUE); $this->addSelect('participant_listing_id', array('placeholder' => ts('Disabled'), 'option_url' => NULL)); $this->add('textarea', 'summary', ts('Event Summary'), $attributes['summary']); $this->add('wysiwyg', 'description', ts('Complete Description'), $attributes['event_description']); $this->addElement('checkbox', 'is_public', ts('Public Event')); $this->addElement('checkbox', 'is_share', ts('Allow sharing through social media?')); $this->addElement('checkbox', 'is_map', ts('Include Map to Event Location')); $this->addDateTime('start_date', ts('Start Date'), FALSE, array('formatType' => 'activityDateTime')); $this->addDateTime('end_date', ts('End Date / Time'), FALSE, array('formatType' => 'activityDateTime')); $this->add('text', 'max_participants', ts('Max Number of Participants'), array('onchange' => "if (this.value != '') {cj('#id-waitlist').show(); showHideByValue('has_waitlist','0','id-waitlist-text','table-row','radio',false); showHideByValue('has_waitlist','0','id-event_full','table-row','radio',true); return;} else {cj('#id-event_full, #id-waitlist, #id-waitlist-text').hide(); return;}")); $this->addRule('max_participants', ts('Max participants should be a positive number'), 'positiveInteger'); $participantStatuses = CRM_Event_PseudoConstant::participantStatus(); $waitlist = 0; if (in_array('On waitlist', $participantStatuses) and in_array('Pending from waitlist', $participantStatuses)) { $this->addElement('checkbox', 'has_waitlist', ts('Offer a Waitlist?'), NULL, array('onclick' => "showHideByValue('has_waitlist','0','id-event_full','table-row','radio',true); showHideByValue('has_waitlist','0','id-waitlist-text','table-row','radio',false);")); $this->add('textarea', 'waitlist_text', ts('Waitlist Message'), $attributes['waitlist_text']); $waitlist = 1; } $this->assign('waitlist', $waitlist); $this->add('textarea', 'event_full_text', ts('Message if Event Is Full'), $attributes['event_full_text']); $this->addElement('checkbox', 'is_active', ts('Is this Event Active?')); $this->addFormRule(array('CRM_Event_Form_ManageEvent_EventInfo', 'formRule')); parent::buildQuickForm(); }
/** * Handle the values in summary mode. * * @param array $values * The array of values belonging to this line. * * @return bool * the result of this processing */ public function summary(&$values) { $erroneousField = NULL; $response = $this->setActiveFieldValues($values, $erroneousField); $errorRequired = FALSE; $index = -1; if ($this->_eventIndex > -1 && $this->_eventTitleIndex > -1) { array_unshift($values, ts('Select either EventID OR Event Title')); return CRM_Import_Parser::ERROR; } elseif ($this->_eventTitleIndex > -1) { $index = $this->_eventTitleIndex; } elseif ($this->_eventIndex > -1) { $index = $this->_eventIndex; } $params =& $this->getActiveFieldParams(); if (!($index < 0 || $this->_participantStatusIndex < 0)) { $errorRequired = !CRM_Utils_Array::value($this->_participantStatusIndex, $values); if (empty($params['event_id']) && empty($params['event_title'])) { CRM_Contact_Import_Parser_Contact::addToErrorMsg('Event', $missingField); } if (empty($params['participant_status_id'])) { CRM_Contact_Import_Parser_Contact::addToErrorMsg('Participant Status', $missingField); } } else { $errorRequired = TRUE; $missingField = NULL; if ($index < 0) { CRM_Contact_Import_Parser_Contact::addToErrorMsg('Event', $missingField); } if ($this->_participantStatusIndex < 0) { CRM_Contact_Import_Parser_Contact::addToErrorMsg('Participant Status', $missingField); } } if ($errorRequired) { array_unshift($values, ts('Missing required field(s) :') . $missingField); return CRM_Import_Parser::ERROR; } $errorMessage = NULL; //for date-Formats $session = CRM_Core_Session::singleton(); $dateType = $session->get('dateTypes'); foreach ($params as $key => $val) { if ($val && $key == 'participant_register_date') { if ($dateValue = CRM_Utils_Date::formatDate($params[$key], $dateType)) { $params[$key] = $dateValue; } else { CRM_Contact_Import_Parser_Contact::addToErrorMsg('Register Date', $errorMessage); } } elseif ($val && ($key == 'participant_role_id' || $key == 'participant_role')) { $roleIDs = CRM_Event_PseudoConstant::participantRole(); $val = explode(',', $val); if ($key == 'participant_role_id') { foreach ($val as $role) { if (!in_array(trim($role), array_keys($roleIDs))) { CRM_Contact_Import_Parser_Contact::addToErrorMsg('Participant Role Id', $errorMessage); break; } } } else { foreach ($val as $role) { if (!CRM_Contact_Import_Parser_Contact::in_value(trim($role), $roleIDs)) { CRM_Contact_Import_Parser_Contact::addToErrorMsg('Participant Role', $errorMessage); break; } } } } elseif ($val && ($key == 'participant_status_id' || $key == 'participant_status')) { $statusIDs = CRM_Event_PseudoConstant::participantStatus(); if ($key == 'participant_status_id') { if (!in_array(trim($val), array_keys($statusIDs))) { CRM_Contact_Import_Parser_Contact::addToErrorMsg('Participant Status Id', $errorMessage); break; } } elseif (!CRM_Contact_Import_Parser_Contact::in_value($val, $statusIDs)) { CRM_Contact_Import_Parser_Contact::addToErrorMsg('Participant Status', $errorMessage); break; } } } //date-Format part ends $params['contact_type'] = 'Participant'; //checking error in custom data CRM_Contact_Import_Parser_Contact::isErrorInCustomData($params, $errorMessage); if ($errorMessage) { $tempMsg = "Invalid value for field(s) : {$errorMessage}"; array_unshift($values, $tempMsg); $errorMessage = NULL; return CRM_Import_Parser::ERROR; } return CRM_Import_Parser::VALID; }
/** * 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); } }
/** * This function process contribution related objects. * * @param int $contributionId * @param int $statusId * @param int|null $previousStatusId * * @return null|string */ protected function updateRelatedComponent($contributionId, $statusId, $previousStatusId = NULL, $receiveDate = NULL) { $statusMsg = NULL; if (!$contributionId || !$statusId) { return $statusMsg; } $params = array('contribution_id' => $contributionId, 'contribution_status_id' => $statusId, 'previous_contribution_status_id' => $previousStatusId, 'receive_date' => $receiveDate); $updateResult = CRM_Contribute_BAO_Contribution::transitionComponents($params); if (!is_array($updateResult) || !($updatedComponents = CRM_Utils_Array::value('updatedComponents', $updateResult)) || !is_array($updatedComponents) || empty($updatedComponents)) { return $statusMsg; } // get the user display name. $sql = "\n SELECT display_name as displayName\n FROM civicrm_contact\nLEFT JOIN civicrm_contribution on (civicrm_contribution.contact_id = civicrm_contact.id )\n WHERE civicrm_contribution.id = {$contributionId}"; $userDisplayName = CRM_Core_DAO::singleValueQuery($sql); // get the status message for user. foreach ($updatedComponents as $componentName => $updatedStatusId) { if ($componentName == 'CiviMember') { $updatedStatusName = CRM_Utils_Array::value($updatedStatusId, CRM_Member_PseudoConstant::membershipStatus()); if ($updatedStatusName == 'Cancelled') { $statusMsg .= "<br />" . ts("Membership for %1 has been Cancelled.", array(1 => $userDisplayName)); } elseif ($updatedStatusName == 'Expired') { $statusMsg .= "<br />" . ts("Membership for %1 has been Expired.", array(1 => $userDisplayName)); } else { $endDate = CRM_Utils_Array::value('membership_end_date', $updateResult); if ($endDate) { $statusMsg .= "<br />" . ts("Membership for %1 has been updated. The membership End Date is %2.", array(1 => $userDisplayName, 2 => $endDate)); } } } if ($componentName == 'CiviEvent') { $updatedStatusName = CRM_Utils_Array::value($updatedStatusId, CRM_Event_PseudoConstant::participantStatus()); if ($updatedStatusName == 'Cancelled') { $statusMsg .= "<br />" . ts("Event Registration for %1 has been Cancelled.", array(1 => $userDisplayName)); } elseif ($updatedStatusName == 'Registered') { $statusMsg .= "<br />" . ts("Event Registration for %1 has been updated.", array(1 => $userDisplayName)); } } if ($componentName == 'CiviPledge') { $updatedStatusName = CRM_Utils_Array::value($updatedStatusId, CRM_Contribute_PseudoConstant::contributionStatus(NULL, 'name')); if ($updatedStatusName == 'Cancelled') { $statusMsg .= "<br />" . ts("Pledge Payment for %1 has been Cancelled.", array(1 => $userDisplayName)); } elseif ($updatedStatusName == 'Failed') { $statusMsg .= "<br />" . ts("Pledge Payment for %1 has been Failed.", array(1 => $userDisplayName)); } elseif ($updatedStatusName == 'Completed') { $statusMsg .= "<br />" . ts("Pledge Payment for %1 has been updated.", array(1 => $userDisplayName)); } } } return $statusMsg; }
/** * 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); } } else { //check if discount is selected if (!empty($params['discount_id'])) { $discountId = $params['discount_id']; } else { $discountId = $params['discount_id'] = 'null'; } //lets carry currency, CRM-4453 $params['fee_currency'] = $config->defaultCurrency; CRM_Price_BAO_PriceSet::processAmount($this->_values['fee'], $params, $lineItem[0]); //CRM-11529 for quick config backoffice transactions //when financial_type_id is passed in form, update the //lineitems with the financial type selected in form $submittedFinancialType = CRM_Utils_Array::value('financial_type_id', $params); $isPaymentRecorded = CRM_Utils_Array::value('record_contribution', $params); if ($isPaymentRecorded && $this->_quickConfig && $submittedFinancialType) { foreach ($lineItem[0] as &$values) { $values['financial_type_id'] = $submittedFinancialType; } } $params['fee_level'] = $params['amount_level']; $contributionParams['total_amount'] = $params['amount']; if ($this->_quickConfig && !empty($params['total_amount']) && $params['status_id'] != array_search('Partially paid', $participantStatus)) { $params['fee_amount'] = $params['total_amount']; } else { //fix for CRM-3086 $params['fee_amount'] = $params['amount']; } } if (isset($params['priceSetId'])) { if (!empty($lineItem[0])) { $this->set('lineItem', $lineItem); $this->_lineItem = $lineItem; $lineItem = array_merge($lineItem, $additionalParticipantDetails); $participantCount = array(); foreach ($lineItem as $k) { foreach ($k as $v) { if (CRM_Utils_Array::value('participant_count', $v) > 0) { $participantCount[] = $v['participant_count']; } } } } if (isset($participantCount)) { $this->assign('pricesetFieldsCount', $participantCount); } $this->assign('lineItem', empty($lineItem[0]) || $this->_quickConfig ? FALSE : $lineItem); } else { $this->assign('amount_level', $params['amount_level']); } } $this->_params = $params; $amountOwed = NULL; if (isset($params['amount'])) { $amountOwed = $params['amount']; unset($params['amount']); } $params['register_date'] = CRM_Utils_Date::processDate($params['register_date'], $params['register_date_time']); $params['receive_date'] = CRM_Utils_Date::processDate(CRM_Utils_Array::value('receive_date', $params), CRM_Utils_Array::value('receive_date_time', $params)); $params['contact_id'] = $this->_contactId; // overwrite actual payment amount if entered if (!empty($params['total_amount'])) { $contributionParams['total_amount'] = CRM_Utils_Array::value('total_amount', $params); } // Retrieve the name and email of the current user - this will be the FROM for the receipt email $userName = CRM_Core_Session::singleton()->getLoggedInContactDisplayName(); if ($this->_contactId) { list($this->_contributorDisplayName, $this->_contributorEmail, $this->_toDoNotEmail) = CRM_Contact_BAO_Contact::getContactDetails($this->_contactId); } //modify params according to parameter used in create //participant method (addParticipant) $this->_params['participant_status_id'] = $params['status_id']; $this->_params['participant_role_id'] = is_array($params['role_id']) ? $params['role_id'] : explode(',', $params['role_id']); $this->_params['participant_register_date'] = $params['register_date']; $roleIdWithSeparator = implode(CRM_Core_DAO::VALUE_SEPARATOR, $this->_params['participant_role_id']); if ($this->_mode) { if (!$this->_isPaidEvent) { CRM_Core_Error::fatal(ts('Selected Event is not Paid Event ')); } $eventTitle = CRM_Core_DAO::getFieldValue('CRM_Event_DAO_Event', $params['event_id'], 'title'); // set source if not set if (empty($params['source'])) { $this->_params['participant_source'] = ts('Offline Registration for Event: %2 by: %1', array(1 => $userName, 2 => $eventTitle)); } else { $this->_params['participant_source'] = $params['source']; } $this->_params['description'] = $this->_params['participant_source']; $this->_paymentProcessor = CRM_Financial_BAO_PaymentProcessor::getPayment($this->_params['payment_processor_id'], $this->_mode); $now = date('YmdHis'); $fields = array(); // set email for primary location. $fields['email-Primary'] = 1; $params['email-Primary'] = $params["email-{$this->_bltID}"] = $this->_contributorEmail; $params['register_date'] = $now; // now set the values for the billing location. foreach ($this->_fields as $name => $dontCare) { $fields[$name] = 1; } // also add location name to the array $params["address_name-{$this->_bltID}"] = CRM_Utils_Array::value('billing_first_name', $params) . ' ' . CRM_Utils_Array::value('billing_middle_name', $params) . ' ' . CRM_Utils_Array::value('billing_last_name', $params); $params["address_name-{$this->_bltID}"] = trim($params["address_name-{$this->_bltID}"]); $fields["address_name-{$this->_bltID}"] = 1; $fields["email-{$this->_bltID}"] = 1; $ctype = CRM_Core_DAO::getFieldValue('CRM_Contact_DAO_Contact', $this->_contactId, 'contact_type'); $nameFields = array('first_name', 'middle_name', 'last_name'); foreach ($nameFields as $name) { $fields[$name] = 1; if (array_key_exists("billing_{$name}", $params)) { $params[$name] = $params["billing_{$name}"]; $params['preserveDBName'] = TRUE; } } $contactID = CRM_Contact_BAO_Contact::createProfileContact($params, $fields, $this->_contactId, NULL, NULL, $ctype); } if (!empty($this->_params['participant_role_id'])) { $customFieldsRole = array(); foreach ($this->_params['participant_role_id'] as $roleKey) { $customFieldsRole = CRM_Utils_Array::crmArrayMerge(CRM_Core_BAO_CustomField::getFields('Participant', FALSE, FALSE, $roleKey, $this->_roleCustomDataTypeID), $customFieldsRole); } $customFieldsEvent = CRM_Core_BAO_CustomField::getFields('Participant', FALSE, FALSE, CRM_Utils_Array::value('event_id', $params), $this->_eventNameCustomDataTypeID); $customFieldsEventType = CRM_Core_BAO_CustomField::getFields('Participant', FALSE, FALSE, $this->_eventTypeId, $this->_eventTypeCustomDataTypeID); $customFields = CRM_Utils_Array::crmArrayMerge($customFieldsRole, CRM_Core_BAO_CustomField::getFields('Participant', FALSE, FALSE, NULL, NULL, TRUE)); $customFields = CRM_Utils_Array::crmArrayMerge($customFieldsEvent, $customFields); $customFields = CRM_Utils_Array::crmArrayMerge($customFieldsEventType, $customFields); $params['custom'] = CRM_Core_BAO_CustomField::postProcess($params, $this->_id, 'Participant'); } //do cleanup line items if participant edit the Event Fee. if (($this->_lineItem || !isset($params['proceSetId'])) && !$this->_paymentId && $this->_id) { CRM_Price_BAO_LineItem::deleteLineItems($this->_id, 'civicrm_participant'); } if ($this->_mode) { // add all the additional payment params we need $this->_params["state_province-{$this->_bltID}"] = $this->_params["billing_state_province-{$this->_bltID}"] = CRM_Core_PseudoConstant::stateProvinceAbbreviation($this->_params["billing_state_province_id-{$this->_bltID}"]); $this->_params["country-{$this->_bltID}"] = $this->_params["billing_country-{$this->_bltID}"] = CRM_Core_PseudoConstant::countryIsoCode($this->_params["billing_country_id-{$this->_bltID}"]); $this->_params['year'] = CRM_Core_Payment_Form::getCreditCardExpirationYear($this->_params); $this->_params['month'] = CRM_Core_Payment_Form::getCreditCardExpirationMonth($this->_params); $this->_params['ip_address'] = CRM_Utils_System::ipAddress(); $this->_params['amount'] = $params['fee_amount']; $this->_params['amount_level'] = $params['amount_level']; $this->_params['currencyID'] = $config->defaultCurrency; $this->_params['invoiceID'] = md5(uniqid(rand(), TRUE)); // at this point we've created a contact and stored its address etc // all the payment processors expect the name and address to be in the // so we copy stuff over to first_name etc. $paymentParams = $this->_params; if (!empty($this->_params['send_receipt'])) { $paymentParams['email'] = $this->_contributorEmail; } // The only reason for merging in the 'contact_id' rather than ensuring it is set // is that this patch is being done around the time of the stable release // so more conservative approach is called for. // In fact the use of $params and $this->_params & $this->_contactId vs $contactID // needs rationalising. $mapParams = array_merge(array('contact_id' => $contactID), $this->_params); CRM_Core_Payment_Form::mapParams($this->_bltID, $mapParams, $paymentParams, TRUE); $payment = $this->_paymentProcessor['object']; // CRM-15622: fix for incorrect contribution.fee_amount $paymentParams['fee_amount'] = NULL; $result = $payment->doPayment($paymentParams); if (is_a($result, 'CRM_Core_Error')) { CRM_Core_Error::displaySessionError($result); CRM_Utils_System::redirect(CRM_Utils_System::url('civicrm/contact/view/participant', "reset=1&action=add&cid={$this->_contactId}&context=participant&mode={$this->_mode}")); } if ($result) { $this->_params = array_merge($this->_params, $result); } $this->_params['receive_date'] = $now; if (!empty($this->_params['send_receipt'])) { $this->_params['receipt_date'] = $now; } else { $this->_params['receipt_date'] = NULL; } $this->set('params', $this->_params); $this->assign('trxn_id', $result['trxn_id']); $this->assign('receive_date', CRM_Utils_Date::processDate($this->_params['receive_date'])); //add contribution record $this->_params['financial_type_id'] = CRM_Core_DAO::getFieldValue('CRM_Event_DAO_Event', $params['event_id'], 'financial_type_id'); $this->_params['mode'] = $this->_mode; //add contribution record $contributions[] = $contribution = CRM_Event_Form_Registration_Confirm::processContribution($this, $this->_params, $result, $contactID, FALSE); // add participant record $participants = array(); if (!empty($this->_params['role_id']) && is_array($this->_params['role_id'])) { $this->_params['role_id'] = implode(CRM_Core_DAO::VALUE_SEPARATOR, $this->_params['role_id']); } //CRM-15372 patch to fix fee amount replacing amount $this->_params['fee_amount'] = $this->_params['amount']; $participants[] = CRM_Event_Form_Registration::addParticipant($this, $contactID); //add custom data for participant CRM_Core_BAO_CustomValueTable::postProcess($this->_params, 'civicrm_participant', $participants[0]->id, 'Participant'); //add participant payment $paymentParticipant = array('participant_id' => $participants[0]->id, 'contribution_id' => $contribution->id); $ids = array(); CRM_Event_BAO_ParticipantPayment::create($paymentParticipant, $ids); $this->_contactIds[] = $this->_contactId; } else { $participants = array(); if ($this->_single) { if ($params['role_id']) { $params['role_id'] = $roleIdWithSeparator; } else { $params['role_id'] = 'NULL'; } $participants[] = CRM_Event_BAO_Participant::create($params); } else { foreach ($this->_contactIds as $contactID) { $commonParams = $params; $commonParams['contact_id'] = $contactID; if ($commonParams['role_id']) { $commonParams['role_id'] = $commonParams['role_id'] = str_replace(',', CRM_Core_DAO::VALUE_SEPARATOR, $params['role_id']); } else { $commonParams['role_id'] = 'NULL'; } $participants[] = CRM_Event_BAO_Participant::create($commonParams); } } if (isset($params['event_id'])) { $eventTitle = CRM_Core_DAO::getFieldValue('CRM_Event_DAO_Event', $params['event_id'], 'title'); } if ($this->_single) { $this->_contactIds[] = $this->_contactId; } $contributions = array(); if (!empty($params['record_contribution'])) { if (!empty($params['id'])) { if ($this->_onlinePendingContributionId) { $ids['contribution'] = $this->_onlinePendingContributionId; } else { $ids['contribution'] = CRM_Core_DAO::getFieldValue('CRM_Event_DAO_ParticipantPayment', $params['id'], 'contribution_id', 'participant_id'); } } unset($params['note']); //build contribution params if (!$this->_onlinePendingContributionId) { if (empty($params['source'])) { $contributionParams['source'] = ts('%1 : Offline registration (by %2)', array(1 => $eventTitle, 2 => $userName)); } else { $contributionParams['source'] = $params['source']; } } $contributionParams['currency'] = $config->defaultCurrency; $contributionParams['non_deductible_amount'] = 'null'; $contributionParams['receipt_date'] = !empty($params['send_receipt']) ? CRM_Utils_Array::value('receive_date', $params) : 'null'; $recordContribution = array('contact_id', 'financial_type_id', 'payment_instrument_id', 'trxn_id', 'contribution_status_id', 'receive_date', 'check_number', 'campaign_id'); foreach ($recordContribution as $f) { $contributionParams[$f] = CRM_Utils_Array::value($f, $params); if ($f == 'trxn_id') { $this->assign('trxn_id', $contributionParams[$f]); } } //insert financial type name in receipt. $this->assign('financialTypeName', CRM_Core_DAO::getFieldValue('CRM_Financial_DAO_FinancialType', $contributionParams['financial_type_id'])); // legacy support $this->assign('contributionTypeName', CRM_Core_DAO::getFieldValue('CRM_Financial_DAO_FinancialType', $contributionParams['financial_type_id'])); $contributionParams['skipLineItem'] = 1; if ($this->_id) { $contributionParams['contribution_mode'] = 'participant'; $contributionParams['participant_id'] = $this->_id; } // Set is_pay_later flag for back-office offline Pending status contributions if ($contributionParams['contribution_status_id'] == CRM_Core_OptionGroup::getValue('contribution_status', 'Pending', 'name')) { $contributionParams['is_pay_later'] = 1; } elseif ($contributionParams['contribution_status_id'] == CRM_Core_OptionGroup::getValue('contribution_status', 'Completed', 'name')) { $contributionParams['is_pay_later'] = 0; } if ($params['status_id'] == array_search('Partially paid', $participantStatus)) { if (!$amountOwed && $this->_action & CRM_Core_Action::UPDATE) { $amountOwed = $params['fee_amount']; } // if multiple participants are link, consider contribution total amount as the amount Owed if ($this->_id && CRM_Event_BAO_Participant::isPrimaryParticipant($this->_id)) { $amountOwed = CRM_Core_DAO::getFieldValue('CRM_Contribute_DAO_Contribution', $ids['contribution'], 'total_amount'); } // CRM-13964 partial_payment_total if ($amountOwed > $params['total_amount']) { // the owed amount $contributionParams['partial_payment_total'] = $amountOwed; // the actual amount paid $contributionParams['partial_amount_pay'] = $params['total_amount']; } } if (CRM_Utils_Array::value('tax_amount', $this->_params)) { $contributionParams['tax_amount'] = $this->_params['tax_amount']; } if ($this->_single) { if (empty($ids)) { $ids = array(); } $contributions[] = CRM_Contribute_BAO_Contribution::create($contributionParams, $ids); } else { $ids = array(); foreach ($this->_contactIds as $contactID) { $contributionParams['contact_id'] = $contactID; $contributions[] = CRM_Contribute_BAO_Contribution::create($contributionParams, $ids); } } //insert payment record for this participation if (empty($ids['contribution'])) { foreach ($this->_contactIds as $num => $contactID) { $ppDAO = new CRM_Event_DAO_ParticipantPayment(); $ppDAO->participant_id = $participants[$num]->id; $ppDAO->contribution_id = $contributions[$num]->id; $ppDAO->save(); } } // next create the transaction record $transaction = new CRM_Core_Transaction(); // CRM-11124 if ($this->_params['discount_id']) { CRM_Event_BAO_Participant::createDiscountTrxn($this->_eventId, $contributionParams, NULL, CRM_Price_BAO_PriceSet::parseFirstPriceSetValueIDFromParams($this->_params)); } $transaction->commit(); } } // also store lineitem stuff here if ($this->_lineItem & $this->_action & CRM_Core_Action::ADD || $this->_lineItem && CRM_Core_Action::UPDATE && !$this->_paymentId) { foreach ($this->_contactIds as $num => $contactID) { foreach ($this->_lineItem as $key => $value) { if (is_array($value) && $value != 'skip') { foreach ($value as $lineKey => $line) { //10117 update the line items for participants if contribution amount is recorded if ($this->_quickConfig && !empty($params['total_amount']) && $params['status_id'] != array_search('Partially paid', $participantStatus)) { $line['unit_price'] = $line['line_total'] = $params['total_amount']; if (!empty($params['tax_amount'])) { $line['unit_price'] = $line['unit_price'] - $params['tax_amount']; $line['line_total'] = $line['line_total'] - $params['tax_amount']; } } $lineItem[$this->_priceSetId][$lineKey] = $line; } CRM_Price_BAO_LineItem::processPriceSet($participants[$num]->id, $lineItem, CRM_Utils_Array::value($num, $contributions, NULL), 'civicrm_participant'); CRM_Contribute_BAO_Contribution::addPayments($value, $contributions); } } } } $updateStatusMsg = NULL; //send mail when participant status changed, CRM-4326 if ($this->_id && $this->_statusId && $this->_statusId != CRM_Utils_Array::value('status_id', $params) && !empty($params['is_notify'])) { $updateStatusMsg = CRM_Event_BAO_Participant::updateStatusMessage($this->_id, $params['status_id'], $this->_statusId); } $sent = array(); $notSent = array(); if (!empty($params['send_receipt'])) { if (array_key_exists($params['from_email_address'], $this->_fromEmails['from_email_id'])) { $receiptFrom = $params['from_email_address']; } $this->assign('module', 'Event Registration'); //use of the message template below requires variables in different format $event = $events = array(); $returnProperties = array('fee_label', 'start_date', 'end_date', 'is_show_location', 'title'); //get all event details. CRM_Core_DAO::commonRetrieveAll('CRM_Event_DAO_Event', 'id', $params['event_id'], $events, $returnProperties); $event = $events[$params['event_id']]; unset($event['start_date']); unset($event['end_date']); $role = CRM_Event_PseudoConstant::participantRole(); $participantRoles = CRM_Utils_Array::value('role_id', $params); if (is_array($participantRoles)) { $selectedRoles = array(); foreach ($participantRoles as $roleId) { $selectedRoles[] = $role[$roleId]; } $event['participant_role'] = implode(', ', $selectedRoles); } else { $event['participant_role'] = CRM_Utils_Array::value($participantRoles, $role); } $event['is_monetary'] = $this->_isPaidEvent; if ($params['receipt_text']) { $event['confirm_email_text'] = $params['receipt_text']; } $this->assign('isAmountzero', 1); $this->assign('event', $event); $this->assign('isShowLocation', $event['is_show_location']); if (CRM_Utils_Array::value('is_show_location', $event) == 1) { $locationParams = array('entity_id' => $params['event_id'], 'entity_table' => 'civicrm_event'); $location = CRM_Core_BAO_Location::getValues($locationParams, TRUE); $this->assign('location', $location); } $status = CRM_Event_PseudoConstant::participantStatus(); if ($this->_isPaidEvent) { $paymentInstrument = CRM_Contribute_PseudoConstant::paymentInstrument(); if (!$this->_mode) { if (isset($params['payment_instrument_id'])) { $this->assign('paidBy', CRM_Utils_Array::value($params['payment_instrument_id'], $paymentInstrument)); } } $this->assign('totalAmount', $contributionParams['total_amount']); if (isset($contributionParams['partial_payment_total'])) { // balance amount $balanceAmount = $contributionParams['partial_payment_total'] - $contributionParams['partial_amount_pay']; $this->assign('balanceAmount', $balanceAmount); } $this->assign('isPrimary', 1); $this->assign('checkNumber', CRM_Utils_Array::value('check_number', $params)); } if ($this->_mode) { if (!empty($params['billing_first_name'])) { $name = $params['billing_first_name']; } if (!empty($params['billing_middle_name'])) { $name .= " {$params['billing_middle_name']}"; } if (!empty($params['billing_last_name'])) { $name .= " {$params['billing_last_name']}"; } $this->assign('billingName', $name); // assign the address formatted up for display $addressParts = array("street_address-{$this->_bltID}", "city-{$this->_bltID}", "postal_code-{$this->_bltID}", "state_province-{$this->_bltID}", "country-{$this->_bltID}"); $addressFields = array(); foreach ($addressParts as $part) { list($n, $id) = explode('-', $part); if (isset($this->_params['billing_' . $part])) { $addressFields[$n] = $this->_params['billing_' . $part]; } } $this->assign('address', CRM_Utils_Address::format($addressFields)); $date = CRM_Utils_Date::format($params['credit_card_exp_date']); $date = CRM_Utils_Date::mysqlToIso($date); $this->assign('credit_card_exp_date', $date); $this->assign('credit_card_number', CRM_Utils_System::mungeCreditCard($params['credit_card_number'])); $this->assign('credit_card_type', $params['credit_card_type']); // The concept of contributeMode is deprecated. $this->assign('contributeMode', 'direct'); $this->assign('isAmountzero', 0); $this->assign('is_pay_later', 0); $this->assign('isPrimary', 1); } $this->assign('register_date', $params['register_date']); if ($params['receive_date']) { $this->assign('receive_date', $params['receive_date']); } $participant = array(array('participant_id', '=', $participants[0]->id, 0, 0)); // check whether its a test drive ref CRM-3075 if (!empty($this->_defaultValues['is_test'])) { $participant[] = array('participant_test', '=', 1, 0, 0); } $template = CRM_Core_Smarty::singleton(); $customGroup = array(); //format submitted data foreach ($params['custom'] as $fieldID => $values) { foreach ($values as $fieldValue) { $customFields[$fieldID]['id'] = $fieldID; $formattedValue = CRM_Core_BAO_CustomField::displayValue($fieldValue['value'], $fieldID, $participants[0]->id); $customGroup[$customFields[$fieldID]['groupTitle']][$customFields[$fieldID]['label']] = str_replace(' ', '', $formattedValue); } } foreach ($this->_contactIds as $num => $contactID) { // Retrieve the name and email of the contact - this will be the TO for receipt email list($this->_contributorDisplayName, $this->_contributorEmail, $this->_toDoNotEmail) = CRM_Contact_BAO_Contact::getContactDetails($contactID); $this->_contributorDisplayName = $this->_contributorDisplayName == ' ' ? $this->_contributorEmail : $this->_contributorDisplayName; $waitStatus = CRM_Event_PseudoConstant::participantStatus(NULL, "class = 'Waiting'"); if ($waitingStatus = CRM_Utils_Array::value($params['status_id'], $waitStatus)) { $this->assign('isOnWaitlist', TRUE); } $this->assign('customGroup', $customGroup); $this->assign('contactID', $contactID); $this->assign('participantID', $participants[$num]->id); $this->_id = $participants[$num]->id; if ($this->_isPaidEvent) { // fix amount for each of participants ( for bulk mode ) $eventAmount = array(); $invoiceSettings = Civi::settings()->get('contribution_invoice_settings'); $invoicing = CRM_Utils_Array::value('invoicing', $invoiceSettings); $totalTaxAmount = 0; //add dataArray in the receipts in ADD and UPDATE condition $dataArray = array(); if ($this->_action & CRM_Core_Action::ADD) { $line = $lineItem[0]; } elseif ($this->_action & CRM_Core_Action::UPDATE) { $line = $this->_values['line_items']; } if ($invoicing) { foreach ($line as $key => $value) { if (isset($value['tax_amount'])) { $totalTaxAmount += $value['tax_amount']; if (isset($dataArray[(string) $value['tax_rate']])) { $dataArray[(string) $value['tax_rate']] = $dataArray[(string) $value['tax_rate']] + CRM_Utils_Array::value('tax_amount', $value); } else { $dataArray[(string) $value['tax_rate']] = CRM_Utils_Array::value('tax_amount', $value); } } } $this->assign('totalTaxAmount', $totalTaxAmount); $this->assign('taxTerm', CRM_Utils_Array::value('tax_term', $invoiceSettings)); $this->assign('dataArray', $dataArray); } if (!empty($additionalParticipantDetails)) { $params['amount_level'] = preg_replace('//', '', $params['amount_level']) . ' - ' . $this->_contributorDisplayName; } $eventAmount[$num] = array('label' => preg_replace('//', '', $params['amount_level']), 'amount' => $params['fee_amount']); //as we are using same template for online & offline registration. //So we have to build amount as array. $eventAmount = array_merge($eventAmount, $additionalParticipantDetails); $this->assign('amount', $eventAmount); } $sendTemplateParams = array('groupName' => 'msg_tpl_workflow_event', 'valueName' => 'event_offline_receipt', 'contactId' => $contactID, 'isTest' => !empty($this->_defaultValues['is_test']), 'PDFFilename' => ts('confirmation') . '.pdf'); // try to send emails only if email id is present // and the do-not-email option is not checked for that contact if ($this->_contributorEmail and !$this->_toDoNotEmail) { $sendTemplateParams['from'] = $receiptFrom; $sendTemplateParams['toName'] = $this->_contributorDisplayName; $sendTemplateParams['toEmail'] = $this->_contributorEmail; $sendTemplateParams['cc'] = CRM_Utils_Array::value('cc', $this->_fromEmails); $sendTemplateParams['bcc'] = CRM_Utils_Array::value('bcc', $this->_fromEmails); } //send email with pdf invoice $template = CRM_Core_Smarty::singleton(); $taxAmt = $template->get_template_vars('dataArray'); $contributionId = CRM_Core_DAO::getFieldValue('CRM_Event_DAO_ParticipantPayment', $this->_id, 'contribution_id', 'participant_id'); $prefixValue = Civi::settings()->get('contribution_invoice_settings'); $invoicing = CRM_Utils_Array::value('invoicing', $prefixValue); if (count($taxAmt) > 0 && (isset($invoicing) && isset($prefixValue['is_email_pdf']))) { $sendTemplateParams['isEmailPdf'] = TRUE; $sendTemplateParams['contributionId'] = $contributionId; } list($mailSent, $subject, $message, $html) = CRM_Core_BAO_MessageTemplate::sendTemplate($sendTemplateParams); if ($mailSent) { $sent[] = $contactID; foreach ($participants as $ids => $values) { if ($values->contact_id == $contactID) { $values->details = CRM_Utils_Array::value('receipt_text', $params); CRM_Activity_BAO_Activity::addActivity($values, 'Email'); break; } } } else { $notSent[] = $contactID; } } } // set the participant id if it is not set if (!$this->_id) { $this->_id = $participants[0]->id; } if ($this->_action & CRM_Core_Action::UPDATE) { $statusMsg = ts('Event registration information for %1 has been updated.', array(1 => $this->_contributorDisplayName)); if (!empty($params['send_receipt']) && count($sent)) { $statusMsg .= ' ' . ts('A confirmation email has been sent to %1', array(1 => $this->_contributorEmail)); } if ($updateStatusMsg) { $statusMsg = "{$statusMsg} {$updateStatusMsg}"; } } elseif ($this->_action & CRM_Core_Action::ADD) { if ($this->_single) { $statusMsg = ts('Event registration for %1 has been added.', array(1 => $this->_contributorDisplayName)); if (!empty($params['send_receipt']) && count($sent)) { $statusMsg .= ' ' . ts('A confirmation email has been sent to %1.', array(1 => $this->_contributorEmail)); } } else { $statusMsg = ts('Total Participant(s) added to event: %1.', array(1 => count($this->_contactIds))); if (count($notSent) > 0) { $statusMsg .= ' ' . ts('Email has NOT been sent to %1 contact(s) - communication preferences specify DO NOT EMAIL OR valid Email is NOT present. ', array(1 => count($notSent))); } elseif (isset($params['send_receipt'])) { $statusMsg .= ' ' . ts('A confirmation email has been sent to ALL participants'); } } } CRM_Core_Session::setStatus($statusMsg, ts('Saved'), 'success'); $session = CRM_Core_Session::singleton(); $buttonName = $this->controller->getButtonName(); if ($this->_context == 'standalone') { if ($buttonName == $this->getButtonName('upload', 'new')) { $urlParams = 'reset=1&action=add&context=standalone'; if ($this->_mode) { $urlParams .= '&mode=' . $this->_mode; } if ($this->_eID) { $urlParams .= '&eid=' . $this->_eID; } $session->replaceUserContext(CRM_Utils_System::url('civicrm/participant/add', $urlParams)); } else { $session->replaceUserContext(CRM_Utils_System::url('civicrm/contact/view', "reset=1&cid={$this->_contactId}&selectedChild=participant")); } } elseif ($buttonName == $this->getButtonName('upload', 'new')) { $session->replaceUserContext(CRM_Utils_System::url('civicrm/contact/view/participant', "reset=1&action=add&context={$this->_context}&cid={$this->_contactId}")); } }
/** * Cancel this participant and finish, send cancellation email. At this point no * auto-cancellation of payment is handled, so payment needs to be manually cancelled * * return @void */ public function cancelParticipant($params) { //set participant record status to Cancelled, refund payment if possible // send email to participant and admin, and log Activity $value = array(); $value['id'] = $this->_participant_id; $cancelledId = array_search('Cancelled', CRM_Event_PseudoConstant::participantStatus(NULL, "class = 'Negative'")); $value['status_id'] = $cancelledId; CRM_Event_BAO_Participant::create($value); $domainValues = array(); $domain = CRM_Core_BAO_Domain::getDomain(); $tokens = array('domain' => array('name', 'phone', 'address', 'email'), 'contact' => CRM_Core_SelectValues::contactTokens()); foreach ($tokens['domain'] as $token) { $domainValues[$token] = CRM_Utils_Token::getDomainTokenReplacement($token, $domain); } $participantRoles = array(); $participantRoles = CRM_Event_PseudoConstant::participantRole(); $participantDetails = array(); $query = "SELECT * FROM civicrm_participant WHERE id = {$this->_participant_id}"; $dao = CRM_Core_DAO::executeQuery($query); while ($dao->fetch()) { $participantDetails[$dao->id] = array('id' => $dao->id, 'role' => $participantRoles[$dao->role_id], 'is_test' => $dao->is_test, 'event_id' => $dao->event_id, 'status_id' => $dao->status_id, 'fee_amount' => $dao->fee_amount, 'contact_id' => $dao->contact_id, 'register_date' => $dao->register_date, 'registered_by_id' => $dao->registered_by_id); } $eventDetails = array(); $eventParams = array('id' => $this->_event_id); CRM_Event_BAO_Event::retrieve($eventParams, $eventDetails[$this->_event_id]); //get default participant role. $eventDetails[$this->_event_id]['participant_role'] = CRM_Utils_Array::value($eventDetails[$this->_event_id]['default_role_id'], $participantRoles); //get the location info $locParams = array('entity_id' => $this->_event_id, 'entity_table' => 'civicrm_event'); $eventDetails[$this->_event_id]['location'] = CRM_Core_BAO_Location::getValues($locParams, TRUE); //get contact details $contactIds[$this->_contact_id] = $this->_contact_id; list($currentContactDetails) = CRM_Utils_Token::getTokenDetails($contactIds, NULL, FALSE, FALSE, NULL, array(), 'CRM_Event_BAO_Participant'); foreach ($currentContactDetails as $contactId => $contactValues) { $contactDetails[$this->_contact_id] = $contactValues; } //send a 'cancelled' email to user, and cc the event's cc_confirm email $mail = CRM_Event_BAO_Participant::sendTransitionParticipantMail($this->_participant_id, $participantDetails[$this->_participant_id], $eventDetails[$this->_event_id], $contactDetails[$this->_contact_id], $domainValues, "Cancelled", ""); $statusMsg = ts('Event registration information for %1 has been updated.', array(1 => $this->_contact_name)); $statusMsg .= ' ' . ts('A cancellation email has been sent to %1.', array(1 => $this->_contact_email)); CRM_Core_Session::setStatus($statusMsg, ts('Saved'), 'success'); $url = CRM_Utils_System::url('civicrm/event/info', "reset=1&id={$this->_event_id}&noFullMsg=true"); CRM_Utils_System::redirect($url); }
/** * 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) { $processContribution = true; } } } else { if ($contributionStatusId == array_search('Failed', $contributionStatuses)) { if ($membership) { $membership->status_id = array_search('Expired', $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) { $processContribution = true; } } } else { if ($contributionStatusId == array_search('Completed', $contributionStatuses)) { // only pending contribution related object processed. if ($previousContriStatusId && $previousContriStatusId != array_search('Pending', $contributionStatuses)) { // this is case when we already processed contribution object. return $updateResult; } else { if (!$previousContriStatusId && $contribution->contribution_status_id != array_search('Pending', $contributionStatuses)) { // this is case when we will going to process contribution object. return $updateResult; } } if ($membership) { $format = '%Y%m%d'; require_once 'CRM/Member/BAO/MembershipType.php'; //CRM-4523 $currentMembership = CRM_Member_BAO_Membership::getContactMembership($membership->contact_id, $membership->membership_type_id, $membership->is_test, $membership->id); if ($currentMembership) { CRM_Member_BAO_Membership::fixMembershipStatusBeforeRenew($currentMembership, $changeToday = null); $dates = CRM_Member_BAO_MembershipType::getRenewalDatesForMembershipType($membership->id, $changeToday = null); $dates['join_date'] = CRM_Utils_Date::customFormat($currentMembership['join_date'], $format); } else { $dates = CRM_Member_BAO_MembershipType::getDatesForMembershipType($membership->membership_type_id); } //get the status for membership. require_once 'CRM/Member/BAO/MembershipStatus.php'; $calcStatus = CRM_Member_BAO_MembershipStatus::getMembershipStatusByDate($dates['start_date'], $dates['end_date'], $dates['join_date'], 'today', true); $formatedParams = array('status_id' => CRM_Utils_Array::value('id', $calcStatus, array_search('Current', $membershipStatuses)), 'join_date' => CRM_Utils_Date::customFormat($dates['join_date'], $format), 'start_date' => CRM_Utils_Date::customFormat($dates['start_date'], $format), 'end_date' => CRM_Utils_Date::customFormat($dates['end_date'], $format), 'reminder_date' => CRM_Utils_Date::customFormat($dates['reminder_date'], $format)); $membership->copyValues($formatedParams); $membership->save(); //updating the membership log $membershipLog = array(); $membershipLog = $formatedParams; $logStartDate = CRM_Utils_Date::customFormat($dates['log_start_date'], $format); $logStartDate = $logStartDate ? CRM_Utils_Date::isoToMysql($logStartDate) : $formatedParams['start_date']; $membershipLog['start_date'] = $logStartDate; $membershipLog['membership_id'] = $membership->id; $membershipLog['modified_id'] = $membership->contact_id; $membershipLog['modified_date'] = date('Ymd'); require_once 'CRM/Member/BAO/MembershipLog.php'; CRM_Member_BAO_MembershipLog::add($membershipLog, CRM_Core_DAO::$_nullArray); //update related Memberships. CRM_Member_BAO_Membership::updateRelatedMemberships($membership->id, $formatedParams); $updateResult['membership_end_date'] = CRM_Utils_Date::customFormat($dates['end_date'], '%B %E%f, %Y'); $updateResult['updatedComponents']['CiviMember'] = $membership->status_id; if ($processContributionObject) { $processContribution = true; } } if ($participant) { $updatedStatusId = array_search('Registered', $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) { $processContribution = true; } } } } } // process contribution object. if ($processContribution) { require_once 'CRM/Contribute/BAO/Contribution.php'; $contributionParams = array(); $fields = array('contact_id', 'total_amount', 'receive_date', 'is_test', 'payment_instrument_id', 'trxn_id', 'invoice_id', 'contribution_type_id', 'contribution_status_id', 'non_deductible_amount', 'receipt_date', 'check_number'); foreach ($fields as $field) { if (!CRM_Utils_Array::value($field, $params)) { continue; } $contributionParams[$field] = $params[$field]; } $ids = array('contribution' => $contributionId); require_once 'CRM/Contribute/BAO/Contribution.php'; $contribution =& CRM_Contribute_BAO_Contribution::create($contributionParams, $ids); } return $updateResult; }
function alterDisplay(&$rows) { // custom code to alter rows $entryFound = false; $eventType = CRM_Core_OptionGroup::values('event_type'); foreach ($rows as $rowNum => $row) { // make count columns point to detail report // convert display name to links if (array_key_exists('civicrm_participant_event_id', $row)) { if ($value = $row['civicrm_participant_event_id']) { $rows[$rowNum]['civicrm_participant_event_id'] = CRM_Event_PseudoConstant::event($value, false); $url = CRM_Report_Utils_Report::getNextUrl('event/income', 'reset=1&force=1&id_op=in&id_value=' . $value, $this->_absoluteUrl, $this->_id); $rows[$rowNum]['civicrm_participant_event_id_link'] = $url; $rows[$rowNum]['civicrm_participant_event_id_hover'] = ts("View Event Income Details for this Event"); } $entryFound = true; } // handle event type id if (array_key_exists('civicrm_event_event_type_id', $row)) { if ($value = $row['civicrm_event_event_type_id']) { $rows[$rowNum]['civicrm_event_event_type_id'] = $eventType[$value]; } $entryFound = true; } // handle participant status id if (array_key_exists('civicrm_participant_status_id', $row)) { if ($value = $row['civicrm_participant_status_id']) { $rows[$rowNum]['civicrm_participant_status_id'] = CRM_Event_PseudoConstant::participantStatus($value, false); } $entryFound = true; } // handle participant role id if (array_key_exists('civicrm_participant_role_id', $row)) { if ($value = $row['civicrm_participant_role_id']) { $rows[$rowNum]['civicrm_participant_role_id'] = CRM_Event_PseudoConstant::participantRole($value, false); } $entryFound = true; } // skip looking further in rows, if first row itself doesn't // have the column we need if (!$entryFound) { break; } } }
/** * 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"); } $participantRoles = CRM_Event_PseudoConstant::participantRole(); $displayName = CRM_Contact_BAO_Contact::displayName($values[$participantID]['contact_id']); $participantCount = array(); $invoiceSettings = Civi::settings()->get('contribution_invoice_settings'); $invoicing = CRM_Utils_Array::value('invoicing', $invoiceSettings); $totalTaxAmount = 0; foreach ($lineItem as $k => $v) { if (CRM_Utils_Array::value('participant_count', $lineItem[$k]) > 0) { $participantCount[] = $lineItem[$k]['participant_count']; } $totalTaxAmount = $v['tax_amount'] + $totalTaxAmount; } if ($invoicing) { $this->assign('totalTaxAmount', $totalTaxAmount); } if ($participantCount) { $this->assign('pricesetFieldsCount', $participantCount); } $this->assign('displayName', $displayName); // omitting contactImage from title for now since the summary overlay css doesn't work outside of our crm-container CRM_Utils_System::setTitle(ts('View Event Registration for') . ' ' . $displayName); $roleId = CRM_Utils_Array::value('role_id', $values[$participantID]); $title = $displayName . ' (' . CRM_Utils_Array::value($roleId, $participantRoles) . ' - ' . $eventTitle . ')'; $sep = CRM_Core_DAO::VALUE_SEPARATOR; $viewRoles = array(); foreach (explode($sep, $values[$participantID]['role_id']) as $k => $v) { $viewRoles[] = $participantRoles[$v]; } $values[$participantID]['role_id'] = implode(', ', $viewRoles); $this->assign('role', $values[$participantID]['role_id']); // add Participant to Recent Items CRM_Utils_Recent::add($title, $url, $values[$participantID]['id'], 'Participant', $values[$participantID]['contact_id'], NULL, $recentOther); }
function alterParticipantStatus($value) { if (empty($value)) { return; } return CRM_Event_PseudoConstant::participantStatus($value, FALSE, 'label'); }
/** * Alter display of rows. * * Iterate through the rows retrieved via SQL and make changes for display purposes, * such as rendering contacts as links. * * @param array $rows * Rows generated by SQL, with an array for each row. */ public function alterDisplay(&$rows) { $entryFound = FALSE; $eventType = CRM_Core_OptionGroup::values('event_type'); $financialTypes = CRM_Contribute_PseudoConstant::financialType(); $contributionStatus = CRM_Contribute_PseudoConstant::contributionStatus(); $paymentInstruments = CRM_Contribute_PseudoConstant::paymentInstrument(); foreach ($rows as $rowNum => $row) { // make count columns point to detail report // convert display name to links if (array_key_exists('civicrm_participant_event_id', $row)) { $eventId = $row['civicrm_participant_event_id']; if ($eventId) { $rows[$rowNum]['civicrm_participant_event_id'] = CRM_Event_PseudoConstant::event($eventId, FALSE); $url = CRM_Report_Utils_Report::getNextUrl('event/income', 'reset=1&force=1&id_op=in&id_value=' . $eventId, $this->_absoluteUrl, $this->_id, $this->_drilldownReport); $rows[$rowNum]['civicrm_participant_event_id_link'] = $url; $rows[$rowNum]['civicrm_participant_event_id_hover'] = ts("View Event Income Details for this Event"); } $entryFound = TRUE; } // handle event type id $this->_initBasicRow($rows, $entryFound, $row, 'civicrm_event_event_type_id', $rowNum, $eventType); // handle participant status id if (array_key_exists('civicrm_participant_status_id', $row)) { $statusId = $row['civicrm_participant_status_id']; if ($statusId) { $rows[$rowNum]['civicrm_participant_status_id'] = CRM_Event_PseudoConstant::participantStatus($statusId, FALSE, 'label'); } $entryFound = TRUE; } // handle participant role id if (array_key_exists('civicrm_participant_role_id', $row)) { $roleId = $row['civicrm_participant_role_id']; if ($roleId) { $roles = explode(CRM_Core_DAO::VALUE_SEPARATOR, $roleId); $roleId = array(); foreach ($roles as $role) { $roleId[$role] = CRM_Event_PseudoConstant::participantRole($role, FALSE); } $rows[$rowNum]['civicrm_participant_role_id'] = implode(', ', $roleId); } $entryFound = TRUE; } // Handel value seperator in Fee Level if (array_key_exists('civicrm_participant_participant_fee_level', $row)) { $feeLevel = $row['civicrm_participant_participant_fee_level']; if ($feeLevel) { CRM_Event_BAO_Participant::fixEventLevel($feeLevel); $rows[$rowNum]['civicrm_participant_participant_fee_level'] = $feeLevel; } $entryFound = TRUE; } // Convert display name to link $displayName = CRM_Utils_Array::value('civicrm_contact_sort_name_linked', $row); $cid = CRM_Utils_Array::value('civicrm_contact_id', $row); $id = CRM_Utils_Array::value('civicrm_participant_participant_record', $row); if ($displayName && $cid && $id) { $url = CRM_Report_Utils_Report::getNextUrl('contact/detail', "reset=1&force=1&id_op=eq&id_value={$cid}", $this->_absoluteUrl, $this->_id, $this->_drilldownReport); $viewUrl = CRM_Utils_System::url("civicrm/contact/view/participant", "reset=1&id={$id}&cid={$cid}&action=view&context=participant"); $contactTitle = ts('View Contact Details'); $participantTitle = ts('View Participant Record'); $rows[$rowNum]['civicrm_contact_sort_name_linked'] = "<a title='{$contactTitle}' href={$url}>{$displayName}</a>"; if ($this->_outputMode !== 'csv') { $rows[$rowNum]['civicrm_contact_sort_name_linked'] .= "<span style='float: right;'><a title='{$participantTitle}' href={$viewUrl}>" . ts('View') . "</a></span>"; } $entryFound = TRUE; } // Handle country id if (array_key_exists('civicrm_address_country_id', $row)) { $countryId = $row['civicrm_address_country_id']; if ($countryId) { $rows[$rowNum]['civicrm_address_country_id'] = CRM_Core_PseudoConstant::country($countryId, TRUE); } $entryFound = TRUE; } // Handle state/province id if (array_key_exists('civicrm_address_state_province_id', $row)) { $provinceId = $row['civicrm_address_state_province_id']; if ($provinceId) { $rows[$rowNum]['civicrm_address_state_province_id'] = CRM_Core_PseudoConstant::stateProvince($provinceId, TRUE); } $entryFound = TRUE; } // Handle employer id if (array_key_exists('civicrm_contact_employer_id', $row)) { $employerId = $row['civicrm_contact_employer_id']; if ($employerId) { $rows[$rowNum]['civicrm_contact_employer_id'] = CRM_Contact_BAO_Contact::displayName($employerId); $url = CRM_Utils_System::url('civicrm/contact/view', 'reset=1&cid=' . $employerId, $this->_absoluteUrl); $rows[$rowNum]['civicrm_contact_employer_id_link'] = $url; $rows[$rowNum]['civicrm_contact_employer_id_hover'] = ts('View Contact Summary for this Contact.'); } } // Convert campaign_id to campaign title $this->_initBasicRow($rows, $entryFound, $row, 'civicrm_participant_campaign_id', $rowNum, $this->activeCampaigns); // handle contribution status $this->_initBasicRow($rows, $entryFound, $row, 'civicrm_contribution_contribution_status_id', $rowNum, $contributionStatus); // handle payment instrument $this->_initBasicRow($rows, $entryFound, $row, 'civicrm_contribution_payment_instrument_id', $rowNum, $paymentInstruments); // handle financial type $this->_initBasicRow($rows, $entryFound, $row, 'civicrm_contribution_financial_type_id', $rowNum, $financialTypes); $entryFound = $this->alterDisplayContactFields($row, $rows, $rowNum, 'event/participantListing', 'View Event Income Details') ? TRUE : $entryFound; // display birthday in the configured custom format if (array_key_exists('civicrm_contact_birth_date', $row)) { $birthDate = $row['civicrm_contact_birth_date']; if ($birthDate) { $rows[$rowNum]['civicrm_contact_birth_date'] = CRM_Utils_Date::customFormat($birthDate, '%Y%m%d'); } $entryFound = TRUE; } // skip looking further in rows, if first row itself doesn't // have the column we need if (!$entryFound) { break; } } }
function checkRegistration($params) { $alreadyRegistered = false; if (!CRM_Utils_Array::value('contact_id', $params)) { return $alreadyRegistered; } require_once 'CRM/Event/PseudoConstant.php'; require_once 'CRM/Event/DAO/Participant.php'; $statusTypes = CRM_Event_PseudoConstant::participantStatus(null, "is_counted = 1"); $participant = new CRM_Event_DAO_Participant(); $participant->copyValues($params); $participant->is_test = CRM_Utils_Array::value('is_test', $params, 0); $participant->selectAdd(); $participant->selectAdd('status_id'); if ($participant->find(true) && array_key_exists($participant->status_id, $statusTypes)) { $alreadyRegistered = true; } return $alreadyRegistered; }
/** * Process Registration of free event. * * @param array $params * Form values. * @param int $contactID */ public function processRegistration($params, $contactID = NULL) { $session = CRM_Core_Session::singleton(); $this->_participantInfo = array(); // CRM-4320, lets build array of cancelled additional participant ids // those are drop or skip by primary at the time of confirmation. // get all in and then unset those are confirmed. $cancelledIds = $this->_additionalParticipantIds; $participantCount = array(); foreach ($params as $participantNum => $record) { if ($record == 'skip') { $participantCount[$participantNum] = 'skip'; } elseif ($participantNum) { $participantCount[$participantNum] = 'participant'; } } $registerByID = NULL; foreach ($params as $key => $value) { if ($value != 'skip') { $fields = NULL; // setting register by Id and unset contactId. if (empty($value['is_primary'])) { $contactID = NULL; $registerByID = $this->get('registerByID'); if ($registerByID) { $value['registered_by_id'] = $registerByID; } // get an email if one exists for the participant $participantEmail = ''; foreach (array_keys($value) as $valueName) { if (substr($valueName, 0, 6) == 'email-') { $participantEmail = $value[$valueName]; } } if ($participantEmail) { $this->_participantInfo[] = $participantEmail; } else { $this->_participantInfo[] = $value['first_name'] . ' ' . $value['last_name']; } } elseif (!empty($value['contact_id'])) { $contactID = $value['contact_id']; } else { $contactID = $this->getContactID(); } CRM_Event_Form_Registration_Confirm::fixLocationFields($value, $fields, $this); //for free event or additional participant, dont create billing email address. if (empty($value['is_primary']) || !$this->_values['event']['is_monetary']) { unset($value["email-{$this->_bltID}"]); } $contactID = CRM_Event_Form_Registration_Confirm::updateContactFields($contactID, $value, $fields, $this); // lets store the contactID in the session // we dont store in userID in case the user is doing multiple // transactions etc // for things like tell a friend if (!$this->getContactID() && !empty($value['is_primary'])) { $session->set('transaction.userID', $contactID); } //lets get the status if require approval or waiting. $waitingStatuses = CRM_Event_PseudoConstant::participantStatus(NULL, "class = 'Waiting'"); if ($this->_allowWaitlist && !$this->_allowConfirmation) { $value['participant_status_id'] = $value['participant_status'] = array_search('On waitlist', $waitingStatuses); } elseif ($this->_requireApproval && !$this->_allowConfirmation) { $value['participant_status_id'] = $value['participant_status'] = array_search('Awaiting approval', $waitingStatuses); } $this->set('value', $value); $this->confirmPostProcess($contactID, NULL, NULL); //lets get additional participant id to cancel. if ($this->_allowConfirmation && is_array($cancelledIds)) { $additonalId = CRM_Utils_Array::value('participant_id', $value); if ($additonalId && ($key = array_search($additonalId, $cancelledIds))) { unset($cancelledIds[$key]); } } } } // update status and send mail to cancelled additional participants, CRM-4320 if ($this->_allowConfirmation && is_array($cancelledIds) && !empty($cancelledIds)) { $cancelledId = array_search('Cancelled', CRM_Event_PseudoConstant::participantStatus(NULL, "class = 'Negative'")); CRM_Event_BAO_Participant::transitionParticipants($cancelledIds, $cancelledId); } //set information about additional participants if exists if (count($this->_participantInfo)) { $this->set('participantInfo', $this->_participantInfo); } //send mail Confirmation/Receipt if ($this->_contributeMode != 'checkout' || $this->_contributeMode != 'notify') { $isTest = FALSE; if ($this->_action & CRM_Core_Action::PREVIEW) { $isTest = TRUE; } //handle if no additional participant. if (!$registerByID) { $registerByID = $this->get('registerByID'); } $primaryContactId = $this->get('primaryContactId'); //build an array of custom profile and assigning it to template. $additionalIDs = CRM_Event_BAO_Event::buildCustomProfile($registerByID, NULL, $primaryContactId, $isTest, TRUE); //lets carry all participant params w/ values. foreach ($additionalIDs as $participantID => $contactId) { $participantNum = NULL; if ($participantID == $registerByID) { $participantNum = 0; } else { if ($participantNum = array_search('participant', $participantCount)) { unset($participantCount[$participantNum]); } } if ($participantNum === NULL) { break; } //carry the participant submitted values. $this->_values['params'][$participantID] = $params[$participantNum]; } //lets send mails to all with meanigful text, CRM-4320. $this->assign('isOnWaitlist', $this->_allowWaitlist); $this->assign('isRequireApproval', $this->_requireApproval); foreach ($additionalIDs as $participantID => $contactId) { if ($participantID == $registerByID) { //set as Primary Participant $this->assign('isPrimary', 1); $customProfile = CRM_Event_BAO_Event::buildCustomProfile($participantID, $this->_values, NULL, $isTest); if (count($customProfile)) { $this->assign('customProfile', $customProfile); $this->set('customProfile', $customProfile); } } else { $this->assign('isPrimary', 0); $this->assign('customProfile', NULL); } //send Confirmation mail to Primary & additional Participants if exists CRM_Event_BAO_Event::sendMail($contactId, $this->_values, $participantID, $isTest); } } }
static function updatePendingOnlineContribution($participantId, $statusId) { if (!$participantId || !$statusId) { return; } $contributionId = CRM_Contribute_BAO_Contribution::checkOnlinePendingContribution($participantId, 'Event'); if (!$contributionId) { return; } //status rules. //1. participant - positive => contribution - completed. //2. participant - negative => contribution - cancelled. $positiveStatuses = CRM_Event_PseudoConstant::participantStatus(NULL, "class = 'Positive'"); $negativeStatuses = CRM_Event_PseudoConstant::participantStatus(NULL, "class = 'Negative'"); $contributionStatuses = CRM_Contribute_PseudoConstant::contributionStatus(NULL, 'name'); $contributionStatusId = NULL; if (array_key_exists($statusId, $positiveStatuses)) { $contributionStatusId = array_search('Completed', $contributionStatuses); } if (array_key_exists($statusId, $negativeStatuses)) { $contributionStatusId = array_search('Cancelled', $contributionStatuses); } if (!$contributionStatusId) { return; } $params = array('component_id' => $participantId, 'componentName' => 'Event', 'contribution_id' => $contributionId, 'contribution_status_id' => $contributionStatusId); //change related contribution status. $updatedStatusId = CRM_Core_Payment_BaseIPN::updateContributionStatus($params); return $updatedStatusId; }