本文整理汇总了PHP中CRM_Event_BAO_Event::buildCustomProfile方法的典型用法代码示例。如果您正苦于以下问题:PHP CRM_Event_BAO_Event::buildCustomProfile方法的具体用法?PHP CRM_Event_BAO_Event::buildCustomProfile怎么用?PHP CRM_Event_BAO_Event::buildCustomProfile使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类CRM_Event_BAO_Event
的用法示例。
在下文中一共展示了CRM_Event_BAO_Event::buildCustomProfile方法的10个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: processRegistration
//.........这里部分代码省略.........
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);
}
}
}
示例2: _assignMessageVariablesToTemplate
//.........这里部分代码省略.........
$template->assign('pcpBlock', TRUE);
$template->assign('pcp_display_in_roll', $softDAO->pcp_display_in_roll);
$template->assign('pcp_roll_nickname', $softDAO->pcp_roll_nickname);
$template->assign('pcp_personal_note', $softDAO->pcp_personal_note);
//assign the pcp page title for email subject
$pcpDAO = new CRM_PCP_DAO_PCP();
$pcpDAO->id = $softDAO->pcp_id;
if ($pcpDAO->find(TRUE)) {
$template->assign('title', $pcpDAO->title);
}
}
}
if ($this->financial_type_id) {
$values['financial_type_id'] = $this->financial_type_id;
}
$template->assign('trxn_id', $this->trxn_id);
$template->assign('receive_date', CRM_Utils_Date::mysqlToIso($this->receive_date));
$template->assign('contributeMode', 'notify');
$template->assign('action', $this->is_test ? 1024 : 1);
$template->assign('receipt_text', CRM_Utils_Array::value('receipt_text', $values));
$template->assign('is_monetary', 1);
$template->assign('is_recur', (bool) $recur);
$template->assign('currency', $this->currency);
$template->assign('address', CRM_Utils_Address::format($input));
if (!empty($values['customGroup'])) {
$template->assign('customGroup', $values['customGroup']);
}
if ($this->_component == 'event') {
$template->assign('title', $values['event']['title']);
$participantRoles = CRM_Event_PseudoConstant::participantRole();
$viewRoles = array();
foreach (explode(CRM_Core_DAO::VALUE_SEPARATOR, $this->_relatedObjects['participant']->role_id) as $k => $v) {
$viewRoles[] = $participantRoles[$v];
}
$values['event']['participant_role'] = implode(', ', $viewRoles);
$template->assign('event', $values['event']);
$template->assign('participant', $values['participant']);
$template->assign('location', $values['location']);
$template->assign('customPre', $values['custom_pre_id']);
$template->assign('customPost', $values['custom_post_id']);
$isTest = FALSE;
if ($this->_relatedObjects['participant']->is_test) {
$isTest = TRUE;
}
$values['params'] = array();
//to get email of primary participant.
$primaryEmail = CRM_Core_DAO::getFieldValue('CRM_Core_DAO_Email', $this->_relatedObjects['participant']->contact_id, 'email', 'contact_id');
$primaryAmount[] = array('label' => $this->_relatedObjects['participant']->fee_level . ' - ' . $primaryEmail, 'amount' => $this->_relatedObjects['participant']->fee_amount);
//build an array of cId/pId of participants
$additionalIDs = CRM_Event_BAO_Event::buildCustomProfile($this->_relatedObjects['participant']->id, NULL, $this->_relatedObjects['contact']->id, $isTest, TRUE);
unset($additionalIDs[$this->_relatedObjects['participant']->id]);
//send receipt to additional participant if exists
if (count($additionalIDs)) {
$template->assign('isPrimary', 0);
$template->assign('customProfile', NULL);
//set additionalParticipant true
$values['params']['additionalParticipant'] = TRUE;
foreach ($additionalIDs as $pId => $cId) {
$amount = array();
//to change the status pending to completed
$additional = new CRM_Event_DAO_Participant();
$additional->id = $pId;
$additional->contact_id = $cId;
$additional->find(TRUE);
$additional->register_date = $this->_relatedObjects['participant']->register_date;
$additional->status_id = 1;
$additionalParticipantInfo = CRM_Core_DAO::getFieldValue('CRM_Core_DAO_Email', $additional->contact_id, 'email', 'contact_id');
//if additional participant dont have email
//use display name.
if (!$additionalParticipantInfo) {
$additionalParticipantInfo = CRM_Contact_BAO_Contact::displayName($additional->contact_id);
}
$amount[0] = array('label' => $additional->fee_level, 'amount' => $additional->fee_amount);
$primaryAmount[] = array('label' => $additional->fee_level . ' - ' . $additionalParticipantInfo, 'amount' => $additional->fee_amount);
$additional->save();
$additional->free();
$template->assign('amount', $amount);
CRM_Event_BAO_Event::sendMail($cId, $values, $pId, $isTest, $returnMessageText);
}
}
//build an array of custom profile and assigning it to template
$customProfile = CRM_Event_BAO_Event::buildCustomProfile($this->_relatedObjects['participant']->id, $values, NULL, $isTest);
if (count($customProfile)) {
$template->assign('customProfile', $customProfile);
}
// for primary contact
$values['params']['additionalParticipant'] = FALSE;
$template->assign('isPrimary', 1);
$template->assign('amount', $primaryAmount);
$template->assign('register_date', CRM_Utils_Date::isoToMysql($this->_relatedObjects['participant']->register_date));
if ($this->payment_instrument_id) {
$paymentInstrument = CRM_Contribute_PseudoConstant::paymentInstrument();
$template->assign('paidBy', $paymentInstrument[$this->payment_instrument_id]);
}
// carry paylater, since we did not created billing,
// so need to pull email from primary location, CRM-4395
$values['params']['is_pay_later'] = $this->_relatedObjects['participant']->is_pay_later;
}
return $template;
}
示例3: buildQuickForm
/**
* Build the form object.
*
* @return void
*/
public function buildQuickForm()
{
$participantStatuses = CRM_Event_PseudoConstant::participantStatus();
$partiallyPaidStatusId = array_search('Partially paid', $participantStatuses);
$this->assign('partiallyPaidStatusId', $partiallyPaidStatusId);
if ($this->_showFeeBlock) {
return CRM_Event_Form_EventFees::buildQuickForm($this);
}
//need to assign custom data type to the template
$this->assign('customDataType', 'Participant');
$this->applyFilter('__ALL__', 'trim');
if ($this->_action & CRM_Core_Action::DELETE) {
if ($this->_single) {
$additionalParticipant = count(CRM_Event_BAO_Event::buildCustomProfile($this->_id, NULL, $this->_contactId, FALSE, TRUE)) - 1;
if ($additionalParticipant) {
$deleteParticipants = array(1 => ts('Delete this participant record along with associated participant record(s).'), 2 => ts('Delete only this participant record.'));
$this->addRadio('delete_participant', NULL, $deleteParticipants, NULL, '<br />');
$this->setDefaults(array('delete_participant' => 1));
$this->assign('additionalParticipant', $additionalParticipant);
}
}
$this->addButtons(array(array('type' => 'next', 'name' => ts('Delete'), 'spacing' => ' ', 'isDefault' => TRUE), array('type' => 'cancel', 'name' => ts('Cancel'))));
return;
}
if ($this->_single && $this->_context == 'standalone') {
$this->addEntityRef('contact_id', ts('Contact'), array('create' => TRUE, 'api' => array('extra' => array('email'))), TRUE);
}
$eventFieldParams = array('entity' => 'event', 'select' => array('minimumInputLength' => 0), 'api' => array('extra' => array('campaign_id', 'default_role_id', 'event_type_id')));
if ($this->_mode) {
// exclude events which are not monetary when credit card registration is used
$eventFieldParams['api']['params']['is_monetary'] = 1;
$this->add('select', 'payment_processor_id', ts('Payment Processor'), $this->_processors, TRUE);
}
$element = $this->addEntityRef('event_id', ts('Event'), $eventFieldParams, TRUE);
//frozen the field fix for CRM-4171
if ($this->_action & CRM_Core_Action::UPDATE && $this->_id) {
if (CRM_Core_DAO::getFieldValue('CRM_Event_DAO_ParticipantPayment', $this->_id, 'contribution_id', 'participant_id')) {
$element->freeze();
}
}
//CRM-7362 --add campaigns.
$campaignId = NULL;
if ($this->_id) {
$campaignId = CRM_Core_DAO::getFieldValue('CRM_Event_DAO_Participant', $this->_id, 'campaign_id');
}
if (!$campaignId) {
$eventId = CRM_Utils_Request::retrieve('eid', 'Positive', $this);
if ($eventId) {
$campaignId = CRM_Core_DAO::getFieldValue('CRM_Event_DAO_Event', $eventId, 'campaign_id');
}
}
CRM_Campaign_BAO_Campaign::addCampaign($this, $campaignId);
$this->addDateTime('register_date', ts('Registration Date'), TRUE, array('formatType' => 'activityDateTime'));
if ($this->_id) {
$this->assign('entityID', $this->_id);
}
$this->addSelect('role_id', array('multiple' => TRUE, 'class' => 'huge'), TRUE);
// CRM-4395
$checkCancelledJs = array('onchange' => "return sendNotification( );");
$confirmJS = NULL;
if ($this->_onlinePendingContributionId) {
$cancelledparticipantStatusId = array_search('Cancelled', CRM_Event_PseudoConstant::participantStatus());
$cancelledContributionStatusId = array_search('Cancelled', CRM_Contribute_PseudoConstant::contributionStatus(NULL, 'name'));
$checkCancelledJs = array('onchange' => "checkCancelled( this.value, {$cancelledparticipantStatusId},{$cancelledContributionStatusId});");
$participantStatusId = array_search('Pending from pay later', CRM_Event_PseudoConstant::participantStatus());
$contributionStatusId = array_search('Completed', CRM_Contribute_PseudoConstant::contributionStatus(NULL, 'name'));
$confirmJS = array('onclick' => "return confirmStatus( {$participantStatusId}, {$contributionStatusId} );");
}
// get the participant status names to build special status array which is used to show notification
// checkbox below participant status select
$participantStatusName = CRM_Event_PseudoConstant::participantStatus();
$notificationStatuses = array('Cancelled', 'Pending from waitlist', 'Pending from approval', 'Expired');
// get the required status and then implode only ids
$notificationStatusIds = implode(',', array_keys(array_intersect($participantStatusName, $notificationStatuses)));
$this->assign('notificationStatusIds', $notificationStatusIds);
$this->_participantStatuses = $statusOptions = CRM_Event_BAO_Participant::buildOptions('status_id', 'create');
// Only show refund status when editing
if ($this->_action & CRM_Core_Action::ADD) {
$pendingRefundStatusId = array_search('Pending refund', $participantStatusName);
if ($pendingRefundStatusId) {
unset($statusOptions[$pendingRefundStatusId]);
}
}
$this->addSelect('status_id', $checkCancelledJs + array('options' => $statusOptions, 'option_url' => 'civicrm/admin/participant_status'), TRUE);
$this->addElement('checkbox', 'is_notify', ts('Send Notification'), NULL);
$this->add('text', 'source', ts('Event Source'));
$noteAttributes = CRM_Core_DAO::getAttribute('CRM_Core_DAO_Note');
$this->add('textarea', 'note', ts('Notes'), $noteAttributes['note']);
$buttons[] = array('type' => 'upload', 'name' => ts('Save'), 'isDefault' => TRUE, 'js' => $confirmJS);
$path = CRM_Utils_System::currentPath();
$excludeForPaths = array('civicrm/contact/search', 'civicrm/group/search');
if (!in_array($path, $excludeForPaths)) {
$buttons[] = array('type' => 'upload', 'name' => ts('Save and New'), 'subName' => 'new', 'js' => $confirmJS);
}
$buttons[] = array('type' => 'cancel', 'name' => ts('Cancel'));
//.........这里部分代码省略.........
示例4: buildQuickForm
/**
* Function to build the form
*
* @return None
* @access public
*/
public function buildQuickForm()
{
if ($this->_showFeeBlock) {
return CRM_Event_Form_EventFees::buildQuickForm($this);
}
if ($this->_cdType) {
return CRM_Custom_Form_CustomData::buildQuickForm($this);
}
//need to assign custom data type to the template
$this->assign('customDataType', 'Participant');
$this->applyFilter('__ALL__', 'trim');
if ($this->_action & CRM_Core_Action::DELETE) {
if ($this->_single) {
$additionalParticipant = count(CRM_Event_BAO_Event::buildCustomProfile($this->_id, NULL, $this->_contactId, FALSE, TRUE)) - 1;
if ($additionalParticipant) {
$deleteParticipants = array(1 => ts('Delete this participant record along with associated participant record(s).'), 2 => ts('Delete only this participant record.'));
$this->addRadio('delete_participant', NULL, $deleteParticipants, NULL, '<br />');
$this->setDefaults(array('delete_participant' => 1));
$this->assign('additionalParticipant', $additionalParticipant);
}
}
$this->addButtons(array(array('type' => 'next', 'name' => ts('Delete'), 'spacing' => ' ', 'isDefault' => TRUE), array('type' => 'cancel', 'name' => ts('Cancel'))));
return;
}
if ($this->_single) {
$urlPath = 'civicrm/contact/view/participant';
$urlParams = "reset=1&cid={$this->_contactId}&context=participant";
if ($this->_context == 'standalone') {
CRM_Contact_Form_NewContact::buildQuickForm($this);
$urlParams = 'reset=1&context=standalone';
$urlPath = 'civicrm/participant/add';
}
if ($this->_id) {
$urlParams .= "&action=update&id={$this->_id}";
} else {
$urlParams .= "&action=add";
}
if ($this->_mode) {
$urlParams .= "&mode={$this->_mode}";
}
$url = CRM_Utils_System::url($urlPath, $urlParams, FALSE, NULL, FALSE);
} else {
$currentPath = CRM_Utils_System::currentPath();
$url = CRM_Utils_System::url($currentPath, '_qf_Participant_display=true', FALSE, NULL, FALSE);
}
$this->assign('refreshURL', $url);
$this->add('hidden', 'past_event');
$events = array();
if ($this->_eID) {
$eventEndDate = CRM_Core_DAO::getFieldValue('CRM_Event_DAO_Event', $this->_eID, 'end_date');
}
$this->assign('past', 0);
if ($this->_action & CRM_Core_Action::UPDATE) {
$events = CRM_Event_BAO_Event::getEvents(1, FALSE, FALSE);
} elseif ($this->getElementValue('past_event') || isset($eventEndDate) && CRM_Utils_Date::currentDBDate() > CRM_Utils_Date::processDate($eventEndDate)) {
$pastval = $this->getElementValue('past_event');
$events = CRM_Event_BAO_Event::getEvents($pastval);
$this->assign('past', $pastval);
} else {
$events = CRM_Event_BAO_Event::getEvents();
}
if ($this->_mode) {
//unset the event which are not monetary when credit card
//event registration is used
foreach ($events as $key => $val) {
$isPaid = CRM_Core_DAO::getFieldValue('CRM_Event_DAO_Event', $key, 'is_monetary');
if (!$isPaid) {
unset($events[$key]);
}
}
$this->add('select', 'payment_processor_id', ts('Payment Processor'), $this->_processors, TRUE);
}
// build array(event -> eventType) mapper
$query = "\nSELECT civicrm_event.id as id, civicrm_event.event_type_id as event_type_id\nFROM civicrm_event\nWHERE civicrm_event.is_template IS NULL OR civicrm_event.is_template = 0";
$dao = CRM_Core_DAO::executeQuery($query);
$eventAndTypeMapping = array();
while ($dao->fetch()) {
$eventAndTypeMapping[$dao->id] = $dao->event_type_id;
}
$eventAndTypeMapping = json_encode($eventAndTypeMapping);
// building of mapping ends --
//inherit the campaign from event.
$eventCampaigns = array();
$allEventIds = array_keys($events);
if (!empty($allEventIds)) {
CRM_Core_PseudoConstant::populate($eventCampaigns, 'CRM_Event_DAO_Event', TRUE, 'campaign_id');
}
$eventCampaigns = json_encode($eventCampaigns);
$element = $this->add('select', 'event_id', ts('Event'), array('' => ts('- select -')) + $events, TRUE, array('onchange' => "buildFeeBlock( this.value ); CRM.buildCustomData( 'Participant', this.value, {$this->_eventNameCustomDataTypeID} ); buildParticipantRole( this.value ); buildEventTypeCustomData( this.value, {$this->_eventTypeCustomDataTypeID}, '{$eventAndTypeMapping}' ); loadCampaign( this.value, {$eventCampaigns} );", 'class' => 'huge'));
// CRM-6111
// note that embedding JS within PHP files is quite awful, IMO
// but we do the same for the onChange element and this form is complex
// and i did not want to break it late in the 3.2 cycle
$preloadJSSnippet = NULL;
//.........这里部分代码省略.........
示例5: buildQuickForm
/**
* Function to build the form
*
* @return None
* @access public
*/
public function buildQuickForm()
{
if ($this->_showFeeBlock) {
return CRM_Event_Form_EventFees::buildQuickForm($this);
}
if ($this->_cdType) {
return CRM_Custom_Form_CustomData::buildQuickForm($this);
}
//need to assign custom data type to the template
$this->assign('customDataType', 'Participant');
$this->applyFilter('__ALL__', 'trim');
if ($this->_action & CRM_Core_Action::DELETE) {
if ($this->_single) {
require_once 'CRM/Event/BAO/Event.php';
$additionalParticipant = count(CRM_Event_BAO_Event::buildCustomProfile($this->_participantId, null, $this->_contactID, false, true)) - 1;
if ($additionalParticipant) {
$this->assign("additionalParticipant", $additionalParticipant);
}
}
$this->addButtons(array(array('type' => 'next', 'name' => ts('Delete'), 'spacing' => ' ', 'isDefault' => true), array('type' => 'cancel', 'name' => ts('Cancel'))));
return;
}
if ($this->_single) {
$urlPath = 'civicrm/contact/view/participant';
$urlParams = "reset=1&cid={$this->_contactID}&context=participant";
if ($this->_context == 'standalone') {
require_once 'CRM/Contact/Form/NewContact.php';
CRM_Contact_Form_NewContact::buildQuickForm($this);
$urlParams = "reset=1&context=standalone";
$urlPath = 'civicrm/participant/add';
}
if ($this->_participantId) {
$urlParams .= "&action=update&id={$this->_participantId}";
} else {
$urlParams .= "&action=add";
}
if (CRM_Utils_Request::retrieve('past', 'Boolean', $this)) {
$urlParams .= "&past=true";
}
if ($this->_mode) {
$urlParams .= "&mode={$this->_mode}";
}
$url = CRM_Utils_System::url($urlPath, $urlParams, false, null, false);
} else {
$currentPath = CRM_Utils_System::currentPath();
$url = CRM_Utils_System::url($currentPath, '_qf_Participant_display=true', false, null, false);
}
$this->assign("refreshURL", $url);
$url .= "&past=true";
$this->assign("pastURL", $url);
$events = array();
$this->assign("past", false);
require_once "CRM/Event/BAO/Event.php";
if (CRM_Utils_Request::retrieve('past', 'Boolean', $this) || $this->_action & CRM_Core_Action::UPDATE) {
$events = CRM_Event_BAO_Event::getEvents(true);
$this->assign("past", true);
} else {
$events = CRM_Event_BAO_Event::getEvents();
}
if ($this->_mode) {
//unset the event which are not monetary when credit card
//event registration is used
foreach ($events as $key => $val) {
$isPaid = CRM_Core_DAO::getFieldValue("CRM_Event_DAO_Event", $key, 'is_monetary');
if (!$isPaid) {
unset($events[$key]);
}
}
$this->add('select', 'payment_processor_id', ts('Payment Processor'), $this->_processors, true);
}
$element = $this->add('select', 'event_id', ts('Event'), array('' => ts('- select -')) + $events, true, array('onchange' => "buildFeeBlock( this.value ); buildCustomData( 'Participant', this.value, {$this->_eventNameCustomDataTypeID} );", 'class' => 'huge'));
//frozen the field fix for CRM-4171
if ($this->_action & CRM_Core_Action::UPDATE && $this->_participantId) {
if (CRM_Core_DAO::getFieldValue('CRM_Event_DAO_ParticipantPayment', $this->_participantId, 'contribution_id', 'participant_id')) {
$element->freeze();
}
}
$this->addDateTime('register_date', ts('Registration Date'), true);
if ($this->_participantId) {
$this->assign('entityID', $this->_participantId);
}
$this->add('select', 'role_id', ts('Participant Role'), array('' => ts('- select -')) + CRM_Event_PseudoConstant::participantRole(), true, array('onchange' => "buildCustomData( 'Participant', this.value, {$this->_roleCustomDataTypeID} );"));
// CRM-4395
$checkCancelledJs = array('onchange' => "return sendNotification( );");
if ($this->_onlinePendingContributionId) {
$cancelledparticipantStatusId = array_search('Cancelled', CRM_Event_PseudoConstant::participantStatus());
$cancelledContributionStatusId = array_search('Cancelled', CRM_Contribute_PseudoConstant::contributionStatus(null, 'name'));
$checkCancelledJs = array('onchange' => "checkCancelled( this.value, {$cancelledparticipantStatusId},{$cancelledContributionStatusId});");
}
$this->add('select', 'status_id', ts('Participant Status'), array('' => ts('- select -')) + CRM_Event_PseudoConstant::participantStatus(null, null, 'label'), true, $checkCancelledJs);
$this->addElement('checkbox', 'is_notify', ts('Send Notification'), null);
$this->add('text', 'source', ts('Event Source'));
$noteAttributes = CRM_Core_DAO::getAttribute('CRM_Core_DAO_Note');
$this->add('textarea', 'note', ts('Notes'), $noteAttributes['note']);
//.........这里部分代码省略.........
示例6: postProcess
//.........这里部分代码省略.........
if (isset($line['tax_amount']) && isset($line['tax_rate'])) {
$totalTaxAmount = $line['tax_amount'] + $totalTaxAmount;
if (isset($dataArray[$line['tax_rate']])) {
$dataArray[$line['tax_rate']] = $dataArray[$line['tax_rate']] + CRM_Utils_Array::value('tax_amount', $line);
} else {
$dataArray[$line['tax_rate']] = CRM_Utils_Array::value('tax_amount', $line);
}
}
}
}
}
if ($invoicing) {
$this->assign('dataArray', $dataArray);
$this->assign('totalTaxAmount', $totalTaxAmount);
}
}
//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);
}
$isTest = FALSE;
if ($this->_action & CRM_Core_Action::PREVIEW) {
$isTest = TRUE;
}
// for Transfer checkout.
// The concept of contributeMode is deprecated.
if (($this->_contributeMode == 'checkout' || $this->_contributeMode == 'notify') && empty($params[0]['is_pay_later']) && !$this->_allowWaitlist && !$this->_requireApproval && $this->_totalAmount > 0) {
$primaryParticipant = $this->get('primaryParticipant');
if (empty($primaryParticipant['participantID'])) {
$primaryParticipant['participantID'] = $registerByID;
}
//build an array of custom profile and assigning it to template
$customProfile = CRM_Event_BAO_Event::buildCustomProfile($registerByID, $this->_values, NULL, $isTest);
if (count($customProfile)) {
$this->assign('customProfile', $customProfile);
$this->set('customProfile', $customProfile);
}
// do a transfer only if a monetary payment greater than 0
if ($this->_values['event']['is_monetary'] && $primaryParticipant) {
if ($payment && is_object($payment)) {
//CRM 14512 provide line items of all participants to payment gateway
$primaryContactId = $this->get('primaryContactId');
//build an array of cId/pId of participants
$additionalIDs = CRM_Event_BAO_Event::buildCustomProfile($registerByID, NULL, $primaryContactId, $isTest, TRUE);
//need to copy, since we are unsetting on the way.
$copyParticipantCountLines = $participantCount;
//lets carry all participant params w/ values.
foreach ($additionalIDs as $participantID => $contactId) {
$participantNum = NULL;
$participantNum = $participantID;
if ($participantID == $registerByID) {
// This is the is primary participant.
$participantNum = 0;
} else {
if ($participantNum = array_search('participant', $copyParticipantCountLines)) {
//if no participant found break.
if ($participantNum === NULL) {
break;
}
//unset current particpant so we don't check them again
unset($copyParticipantCountLines[$participantNum]);
}
}
// get values of line items
if ($this->_amount) {
示例7: sendMail
//.........这里部分代码省略.........
$template->assign('receipt_text', CRM_Utils_Array::value('receipt_text', $values));
$template->assign('is_monetary', 1);
$template->assign('is_recur', $recur);
if ($recur) {
require_once 'CRM/Core/Payment.php';
$paymentObject =& CRM_Core_Payment::singleton($contribution->is_test ? 'test' : 'live', 'Contribute', $objects['paymentProcessor']);
$url = $paymentObject->cancelSubscriptionURL();
$template->assign('cancelSubscriptionUrl', $url);
if ($objects['paymentProcessor']['billing_mode'] & CRM_Core_Payment::BILLING_MODE_FORM) {
//direct mode showing billing block, so use directIPN for temporary
$template->assign('contributeMode', 'directIPN');
}
}
require_once 'CRM/Utils/Address.php';
$template->assign('address', CRM_Utils_Address::format($input));
if ($input['component'] == 'event') {
require_once 'CRM/Core/OptionGroup.php';
$participant_role = CRM_Core_OptionGroup::values('participant_role');
$values['event']['participant_role'] = $participant_role[$participant->role_id];
$template->assign('event', $values['event']);
$template->assign('location', $values['location']);
$template->assign('customPre', $values['custom_pre_id']);
$template->assign('customPost', $values['custom_post_id']);
$isTest = false;
if ($participant->is_test) {
$isTest = true;
}
$values['params'] = array();
require_once "CRM/Event/BAO/Event.php";
//to get email of primary participant.
$primaryEmail = CRM_Core_DAO::getFieldValue('CRM_Core_DAO_Email', $participant->contact_id, 'email', 'contact_id');
$primaryAmount[] = array('label' => $participant->fee_level . ' - ' . $primaryEmail, 'amount' => $participant->fee_amount);
//build an array of cId/pId of participants
$additionalIDs = CRM_Event_BAO_Event::buildCustomProfile($participant->id, null, $ids['contact'], $isTest, true);
unset($additionalIDs[$participant->id]);
//send receipt to additional participant if exists
if (count($additionalIDs)) {
$template->assign('isPrimary', 0);
$template->assign('customProfile', null);
//set additionalParticipant true
$values['params']['additionalParticipant'] = true;
foreach ($additionalIDs as $pId => $cId) {
$amount = array();
//to change the status pending to completed
$additional =& new CRM_Event_DAO_Participant();
$additional->id = $pId;
$additional->contact_id = $cId;
$additional->find(true);
$additional->register_date = $participant->register_date;
$additional->status_id = 1;
$additionalParticipantInfo = CRM_Core_DAO::getFieldValue('CRM_Core_DAO_Email', $additional->contact_id, 'email', 'contact_id');
//if additional participant dont have email
//use display name.
if (!$additionalParticipantInfo) {
require_once "CRM/Contact/BAO/Contact.php";
$additionalParticipantInfo = CRM_Contact_BAO_Contact::displayName($additional->contact_id);
}
$amount[0] = array('label' => $additional->fee_level, 'amount' => $additional->fee_amount);
$primaryAmount[] = array('label' => $additional->fee_level . ' - ' . $additionalParticipantInfo, 'amount' => $additional->fee_amount);
$additional->save();
$additional->free();
$template->assign('amount', $amount);
CRM_Event_BAO_Event::sendMail($cId, $values, $pId, $isTest, $returnMessageText);
}
}
//build an array of custom profile and assigning it to template
示例8: buildQuickForm
/**
* Function to build the form
*
* @return None
* @access public
*/
public function buildQuickForm()
{
if ($this->_showFeeBlock) {
return CRM_Event_Form_EventFees::buildQuickForm($this);
}
if ($this->_cdType) {
return CRM_Custom_Form_CustomData::buildQuickForm($this);
}
//need to assign custom data type to the template
$this->assign('customDataType', 'Participant');
$this->applyFilter('__ALL__', 'trim');
if ($this->_action & CRM_Core_Action::DELETE) {
if ($this->_single) {
require_once 'CRM/Event/BAO/Event.php';
$additionalParticipant = count(CRM_Event_BAO_Event::buildCustomProfile($this->_id, null, $this->_contactId, false, true)) - 1;
if ($additionalParticipant) {
$deleteParticipants = array(1 => ts('Delete this participant record along with associated participant record(s).'), 2 => ts('Delete only this participant record.'));
$this->addRadio('delete_participant', null, $deleteParticipants, null, '<br />');
$this->setDefaults(array('delete_participant' => 1));
$this->assign("additionalParticipant", $additionalParticipant);
}
}
$this->addButtons(array(array('type' => 'next', 'name' => ts('Delete'), 'spacing' => ' ', 'isDefault' => true), array('type' => 'cancel', 'name' => ts('Cancel'))));
return;
}
if ($this->_single) {
$urlPath = 'civicrm/contact/view/participant';
$urlParams = "reset=1&cid={$this->_contactId}&context=participant";
if ($this->_context == 'standalone') {
require_once 'CRM/Contact/Form/NewContact.php';
CRM_Contact_Form_NewContact::buildQuickForm($this);
$urlParams = "reset=1&context=standalone";
$urlPath = 'civicrm/participant/add';
}
if ($this->_id) {
$urlParams .= "&action=update&id={$this->_id}";
} else {
$urlParams .= "&action=add";
}
if ($this->_mode) {
$urlParams .= "&mode={$this->_mode}";
}
$url = CRM_Utils_System::url($urlPath, $urlParams, false, null, false);
} else {
$currentPath = CRM_Utils_System::currentPath();
$url = CRM_Utils_System::url($currentPath, '_qf_Participant_display=true', false, null, false);
}
$this->assign("refreshURL", $url);
$this->add('hidden', 'past_event');
$events = array();
$this->assign("past", false);
require_once "CRM/Event/BAO/Event.php";
if ($this->_action & CRM_Core_Action::UPDATE) {
$events = CRM_Event_BAO_Event::getEvents(true, false, false);
} elseif ($this->getElementValue('past_event')) {
$events = CRM_Event_BAO_Event::getEvents(true);
$this->assign("past", true);
} else {
$events = CRM_Event_BAO_Event::getEvents();
}
if ($this->_mode) {
//unset the event which are not monetary when credit card
//event registration is used
foreach ($events as $key => $val) {
$isPaid = CRM_Core_DAO::getFieldValue("CRM_Event_DAO_Event", $key, 'is_monetary');
if (!$isPaid) {
unset($events[$key]);
}
}
$this->add('select', 'payment_processor_id', ts('Payment Processor'), $this->_processors, true);
}
// build array(event -> eventType) mapper
$query = "\nSELECT civicrm_event.id as id, civicrm_event.event_type_id as event_type_id\nFROM civicrm_event\nWHERE civicrm_event.is_template IS NULL OR civicrm_event.is_template = 0";
$dao =& CRM_Core_DAO::executeQuery($query);
$eventAndTypeMapping = array();
while ($dao->fetch()) {
$eventAndTypeMapping[$dao->id] = $dao->event_type_id;
}
$eventAndTypeMapping = json_encode($eventAndTypeMapping);
// building of mapping ends --
$element = $this->add('select', 'event_id', ts('Event'), array('' => ts('- select -')) + $events, true, array('onchange' => "buildFeeBlock( this.value ); buildCustomData( 'Participant', this.value, {$this->_eventNameCustomDataTypeID} ); buildParticipantRole( this.value ); buildEventTypeCustomData( this.value, {$this->_eventTypeCustomDataTypeID}, '{$eventAndTypeMapping}' );", 'class' => 'huge'));
// CRM-6111
// note that embedding JS within PHP files is quite awful, IMO
// but we do the same for the onChange element and this form is complex
// and i did not want to break it late in the 3.2 cycle
$preloadJSSnippet = null;
if (CRM_Utils_Array::value('reset', $_GET)) {
$this->_eID = CRM_Utils_Request::retrieve('eid', 'Positive', $this);
if ($this->_eID) {
$preloadJSSnippet = "\ncj(function() {\ncj('#event_id').val( '{$this->_eID}' );\nbuildFeeBlock( {$this->_eID} ); \nbuildCustomData( 'Participant', {$this->_eID}, {$this->_eventNameCustomDataTypeID} );\nbuildEventTypeCustomData( {$this->_eID}, {$this->_eventTypeCustomDataTypeID}, '{$eventAndTypeMapping}' );\n});\n";
}
}
$this->assign('preloadJSSnippet', $preloadJSSnippet);
//frozen the field fix for CRM-4171
//.........这里部分代码省略.........
示例9: postProcess
//.........这里部分代码省略.........
if ($this->_allowConfirmation && !empty($this->_additionalParticipantIds)) {
$allParticipantIds = array_merge(array($registerByID), $this->_additionalParticipantIds);
}
$entityTable = 'civicrm_participant';
foreach ($this->_lineItem as $key => $value) {
if ($value != 'skip' && ($entityId = CRM_Utils_Array::value($key, $allParticipantIds))) {
// do cleanup line items if participant re-walking wizard.
if ($this->_allowConfirmation) {
CRM_Price_BAO_LineItem::deleteLineItems($entityId, $entityTable);
}
// create line.
foreach ($value as $line) {
$line['entity_id'] = $entityId;
$line['entity_table'] = $entityTable;
CRM_Price_BAO_LineItem::create($line);
}
}
}
}
//update status and send mail to cancelled additonal participants, CRM-4320
if ($this->_allowConfirmation && is_array($cancelledIds) && !empty($cancelledIds)) {
require_once 'CRM/Event/BAO/Participant.php';
require_once 'CRM/Event/PseudoConstant.php';
$cancelledId = array_search('Cancelled', CRM_Event_PseudoConstant::participantStatus(null, "class = 'Negative'"));
CRM_Event_BAO_Participant::transitionParticipants($cancelledIds, $cancelledId);
}
$isTest = false;
if ($this->_action & CRM_Core_Action::PREVIEW) {
$isTest = true;
}
// for Transfer checkout.
require_once "CRM/Event/BAO/Event.php";
if (($this->_contributeMode == 'checkout' || $this->_contributeMode == 'notify') && !CRM_Utils_Array::value('is_pay_later', $params[0]) && !$this->_allowWaitlist && !$this->_requireApproval && $this->_totalAmount > 0) {
$primaryParticipant = $this->get('primaryParticipant');
if (!CRM_Utils_Array::value('participantID', $primaryParticipant)) {
$primaryParticipant['participantID'] = $registerByID;
}
//build an array of custom profile and assigning it to template
$customProfile = CRM_Event_BAO_Event::buildCustomProfile($registerByID, $this->_values, null, $isTest);
if (count($customProfile)) {
$this->assign('customProfile', $customProfile);
$this->set('customProfile', $customProfile);
}
// do a transfer only if a monetary payment greater than 0
if ($this->_values['event']['is_monetary'] && $primaryParticipant && $payment) {
$payment->doTransferCheckout($primaryParticipant);
}
} else {
//otherwise send mail Confirmation/Receipt
$primaryContactId = $this->get('primaryContactId');
//build an array of cId/pId of participants
require_once "CRM/Event/BAO/Event.php";
$additionalIDs = CRM_Event_BAO_Event::buildCustomProfile($registerByID, null, $primaryContactId, $isTest, true);
//lets send mails to all with meaningful 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);
//build an array of custom profile and assigning it to template.
$customProfile = CRM_Event_BAO_Event::buildCustomProfile($participantID, $this->_values, null, $isTest);
if (count($customProfile)) {
$this->assign('customProfile', $customProfile);
$this->set('customProfile', $customProfile);
}
$this->_values['params']['additionalParticipant'] = false;
} else {
//take the Additional participant number.
if ($paticipantNum = array_search('participant', $participantCount)) {
unset($participantCount[$paticipantNum]);
}
$this->assign('isPrimary', 0);
$this->assign('customProfile', null);
//Additional Participant should get only it's payment information
if ($this->_amount) {
$amount = array();
$params = $this->get('params');
$amount[$paticipantNum]['label'] = $params[$paticipantNum]['amount_level'];
$amount[$paticipantNum]['amount'] = $params[$paticipantNum]['amount'];
$this->assign('amount', $amount);
}
if ($this->_lineItem) {
$lineItems = $this->_lineItem;
$lineItem = array();
$lineItem[] = CRM_Utils_Array::value($paticipantNum, $lineItems);
$this->assign('lineItem', $lineItem);
}
$this->_values['params']['additionalParticipant'] = true;
}
//pass these variables since these are run time calculated.
$this->_values['params']['isOnWaitlist'] = $this->_allowWaitlist;
$this->_values['params']['isRequireApproval'] = $this->_requireApproval;
//send mail to primary as well as additional participants.
$this->assign('contactID', $contactId);
$this->assign('participantID', $participantID);
CRM_Event_BAO_Event::sendMail($contactId, $this->_values, $participantID, $isTest);
}
}
}
示例10: processRegistration
public function processRegistration($params, $contactID = null)
{
$session =& CRM_Core_Session::singleton();
$contactID = $session->get('userID');
$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;
foreach ($params as $key => $value) {
if ($value != 'skip') {
$fields = null;
// setting register by Id and unset contactId.
if (!CRM_Utils_Array::value('is_primary', $value)) {
$contactID = null;
$registerByID = $this->get('registerByID');
if ($registerByID) {
$value['registered_by_id'] = $registerByID;
}
if (CRM_Utils_Array::value("email-{$this->_bltID}", $value)) {
$this->_participantInfo[] = $value["email-{$this->_bltID}"];
} else {
$this->_participantInfo[] = $value['first_name'] . ' ' . $value['last_name'];
}
}
require_once 'CRM/Event/Form/Registration/Confirm.php';
CRM_Event_Form_Registration_Confirm::fixLocationFields($value, $fields);
//for free event or additional participant, dont create billing email address.
if (!CRM_Utils_Array::value('is_primary', $value) || !$this->_values['event']['is_monetary']) {
unset($value["email-{$this->_bltID}"]);
}
$contactID =& CRM_Event_Form_Registration_Confirm::updateContactFields($contactID, $value, $fields);
// 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 (!$session->get('userID') && CRM_Utils_Array::value('is_primary', $value)) {
$session->set('transaction.userID', $contactID);
}
//lets get the status if require approval or waiting.
require_once 'CRM/Event/PseudoConstant.php';
$waitingStatuses = CRM_Event_PseudoConstant::participantStatus(null, "class = 'Waiting'");
if ($this->_allowWaitlist && !$this->_allowConfirmation) {
$value['participant_status_id'] = array_search('On waitlist', $waitingStatuses);
} else {
if ($this->_requireApproval && !$this->_allowConfirmation) {
$value['participant_status_id'] = 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 additonal participants, CRM-4320
if ($this->_allowConfirmation && is_array($cancelledIds) && !empty($cancelledIds)) {
require_once 'CRM/Event/BAO/Participant.php';
require_once 'CRM/Event/PseudoConstant.php';
$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
require_once "CRM/Event/BAO/Event.php";
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 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);
//.........这里部分代码省略.........