本文整理汇总了PHP中CRM_Contact_BAO_Contact_Location::getEmailDetails方法的典型用法代码示例。如果您正苦于以下问题:PHP CRM_Contact_BAO_Contact_Location::getEmailDetails方法的具体用法?PHP CRM_Contact_BAO_Contact_Location::getEmailDetails怎么用?PHP CRM_Contact_BAO_Contact_Location::getEmailDetails使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类CRM_Contact_BAO_Contact_Location
的用法示例。
在下文中一共展示了CRM_Contact_BAO_Contact_Location::getEmailDetails方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: preProcess
public function preProcess()
{
$this->_participantId = CRM_Utils_Request::retrieve('id', 'Positive', $this, TRUE);
$this->_contactId = CRM_Utils_Request::retrieve('cid', 'Positive', $this, TRUE);
$this->_eventId = CRM_Core_DAO::getFieldValue('CRM_Event_DAO_Participant', $this->_participantId, 'event_id');
$this->_fromEmails = CRM_Event_BAO_Event::getFromEmailIds($this->_eventId);
$this->_contributionId = CRM_Core_DAO::getFieldValue('CRM_Event_DAO_ParticipantPayment', $this->_participantId, 'contribution_id', 'participant_id');
if ($this->_contributionId) {
$this->_isPaidEvent = TRUE;
}
$this->_action = CRM_Utils_Request::retrieve('action', 'String', $this, TRUE);
list($this->_contributorDisplayName, $this->_contributorEmail) = CRM_Contact_BAO_Contact_Location::getEmailDetails($this->_contactId);
$this->assign('displayName', $this->_contributorDisplayName);
$this->assign('email', $this->_contributorEmail);
$this->_participantStatus = CRM_Core_DAO::getFieldValue('CRM_Event_BAO_Participant', $this->_participantId, 'status_id');
//set the payment mode - _mode property is defined in parent class
$this->_mode = CRM_Utils_Request::retrieve('mode', 'String', $this);
$this->assign('contactId', $this->_contactId);
$this->assign('id', $this->_participantId);
$paymentInfo = CRM_Contribute_BAO_Contribution::getPaymentInfo($this->_participantId, 'event');
$this->_paidAmount = $paymentInfo['paid'];
$this->assign('paymentInfo', $paymentInfo);
CRM_Core_Resources::singleton()->addSetting(array('feePaid' => $this->_paidAmount));
$title = "Change selections for {$this->_contributorDisplayName}";
if ($title) {
CRM_Utils_System::setTitle(ts('%1', array(1 => $title)));
}
}
示例2: run
function run()
{
require_once 'CRM/Utils/Request.php';
$contact_id = CRM_Utils_Request::retrieve('cid', 'Integer', CRM_Core_DAO::$_nullObject);
$subscribe_id = CRM_Utils_Request::retrieve('sid', 'Integer', CRM_Core_DAO::$_nullObject);
$hash = CRM_Utils_Request::retrieve('h', 'String', CRM_Core_DAO::$_nullObject);
$activity_id = CRM_Utils_Request::retrieve('a', 'String', CRM_Core_DAO::$_nullObject);
$petition_id = CRM_Utils_Request::retrieve('p', 'String', CRM_Core_DAO::$_nullObject);
if (!$contact_id || !$subscribe_id || !$hash) {
CRM_Core_Error::fatal(ts("Missing input parameters"));
}
require_once 'CRM/Mailing/Event/BAO/Confirm.php';
$result = $this->confirm($contact_id, $subscribe_id, $hash, $activity_id, $petition_id);
if ($result === false) {
$this->assign('success', $result);
} else {
$this->assign('success', true);
// $this->assign( 'group' , $result );
}
require_once 'CRM/Contact/BAO/Contact/Location.php';
list($displayName, $email) = CRM_Contact_BAO_Contact_Location::getEmailDetails($contact_id);
$this->assign('display_name', $displayName);
$this->assign('email', $email);
$this->assign('petition_id', $petition_id);
$this->assign('survey_id', $petition_id);
// send thank you email
require_once 'CRM/Campaign/Form/Petition/Signature.php';
$params['contactId'] = $contact_id;
$params['email-Primary'] = $email;
$params['sid'] = $petition_id;
$params['activityId'] = $activity_id;
CRM_Campaign_BAO_Petition::sendEmail($params, CRM_Campaign_Form_Petition_Signature::EMAIL_THANK);
parent::run();
}
示例3: confirm
/**
* Confirm a pending subscription
*
* @param int $contact_id The id of the contact
* @param int $subscribe_id The id of the subscription event
* @param string $hash The hash
*
* @return boolean True on success
* @access public
* @static
*/
public static function confirm($contact_id, $subscribe_id, $hash)
{
$se =& CRM_Mailing_Event_BAO_Subscribe::verify($contact_id, $subscribe_id, $hash);
if (!$se) {
return FALSE;
}
// before we proceed lets just check if this contact is already 'Added'
// if so, we should ignore this request and hence avoid sending multiple
// emails - CRM-11157
$details = CRM_Contact_BAO_GroupContact::getMembershipDetail($contact_id, $se->group_id);
if ($details && $details->status == 'Added') {
// This contact is already subscribed
// lets return the group title
return CRM_Core_DAO::getFieldValue('CRM_Contact_DAO_Group', $se->group_id, 'title');
}
$transaction = new CRM_Core_Transaction();
$ce = new CRM_Mailing_Event_BAO_Confirm();
$ce->event_subscribe_id = $se->id;
$ce->time_stamp = date('YmdHis');
$ce->save();
CRM_Contact_BAO_GroupContact::addContactsToGroup(array($contact_id), $se->group_id, 'Email', 'Added', $ce->id);
$transaction->commit();
$config = CRM_Core_Config::singleton();
$domain = CRM_Core_BAO_Domain::getDomain();
list($domainEmailName, $_) = CRM_Core_BAO_Domain::getNameAndEmail();
list($display_name, $email) = CRM_Contact_BAO_Contact_Location::getEmailDetails($se->contact_id);
$group = new CRM_Contact_DAO_Group();
$group->id = $se->group_id;
$group->find(TRUE);
$component = new CRM_Mailing_BAO_Component();
$component->is_default = 1;
$component->is_active = 1;
$component->component_type = 'Welcome';
$component->find(TRUE);
$emailDomain = CRM_Core_BAO_MailSettings::defaultDomain();
$html = $component->body_html;
if ($component->body_text) {
$text = $component->body_text;
} else {
$text = CRM_Utils_String::htmlToText($component->body_html);
}
$bao = new CRM_Mailing_BAO_Mailing();
$bao->body_text = $text;
$bao->body_html = $html;
$tokens = $bao->getTokens();
$html = CRM_Utils_Token::replaceDomainTokens($html, $domain, TRUE, $tokens['html']);
$html = CRM_Utils_Token::replaceWelcomeTokens($html, $group->title, TRUE);
$text = CRM_Utils_Token::replaceDomainTokens($text, $domain, FALSE, $tokens['text']);
$text = CRM_Utils_Token::replaceWelcomeTokens($text, $group->title, FALSE);
$mailParams = array('groupName' => 'Mailing Event ' . $component->component_type, 'subject' => $component->subject, 'from' => "\"{$domainEmailName}\" <do-not-reply@{$emailDomain}>", 'toEmail' => $email, 'toName' => $display_name, 'replyTo' => "do-not-reply@{$emailDomain}", 'returnPath' => "do-not-reply@{$emailDomain}", 'html' => $html, 'text' => $text);
// send - ignore errors because the desired status change has already been successful
$unused_result = CRM_Utils_Mail::send($mailParams);
return $group->title;
}
示例4: preProcess
public function preProcess()
{
$this->_participantId = CRM_Utils_Request::retrieve('id', 'Positive', $this, TRUE);
$this->_contactId = CRM_Utils_Request::retrieve('cid', 'Positive', $this, TRUE);
$this->_eventId = CRM_Core_DAO::getFieldValue('CRM_Event_DAO_Participant', $this->_participantId, 'event_id');
$this->_fromEmails = CRM_Event_BAO_Event::getFromEmailIds($this->_eventId);
$this->_contributionId = CRM_Core_DAO::getFieldValue('CRM_Event_DAO_ParticipantPayment', $this->_participantId, 'contribution_id', 'participant_id');
if (!$this->_contributionId) {
if ($primaryParticipantId = CRM_Core_DAO::getFieldValue('CRM_Event_BAO_Participant', $this->_participantId, 'registered_by_id')) {
$this->_contributionId = CRM_Core_DAO::getFieldValue('CRM_Event_BAO_ParticipantPayment', $primaryParticipantId, 'contribution_id', 'participant_id');
}
}
if ($this->_contributionId) {
$this->_isPaidEvent = TRUE;
}
$this->_action = CRM_Utils_Request::retrieve('action', 'String', $this, TRUE);
list($this->_contributorDisplayName, $this->_contributorEmail) = CRM_Contact_BAO_Contact_Location::getEmailDetails($this->_contactId);
$this->assign('displayName', $this->_contributorDisplayName);
$this->assign('email', $this->_contributorEmail);
$this->_participantStatus = CRM_Core_DAO::getFieldValue('CRM_Event_BAO_Participant', $this->_participantId, 'status_id');
//set the payment mode - _mode property is defined in parent class
$this->_mode = CRM_Utils_Request::retrieve('mode', 'String', $this);
$this->assign('contactId', $this->_contactId);
$this->assign('id', $this->_participantId);
$paymentInfo = CRM_Contribute_BAO_Contribution::getPaymentInfo($this->_participantId, 'event');
$this->_paidAmount = $paymentInfo['paid'];
$this->assign('paymentInfo', $paymentInfo);
$this->assign('feePaid', $this->_paidAmount);
$ids = CRM_Event_BAO_Participant::getParticipantIds($this->_contributionId);
if (count($ids) > 1) {
$total = 0;
foreach ($ids as $val) {
$total += CRM_Price_BAO_LineItem::getLineTotal($val, 'civicrm_participant');
}
$this->assign('totalLineTotal', $total);
$lineItemTotal = CRM_Price_BAO_LineItem::getLineTotal($this->_participantId, 'civicrm_participant');
$this->assign('lineItemTotal', $lineItemTotal);
}
$title = "Change selections for {$this->_contributorDisplayName}";
if ($title) {
CRM_Utils_System::setTitle(ts('%1', array(1 => $title)));
}
}
示例5: run
function run()
{
$contact_id = CRM_Utils_Request::retrieve('cid', 'Integer', CRM_Core_DAO::$_nullObject);
$subscribe_id = CRM_Utils_Request::retrieve('sid', 'Integer', CRM_Core_DAO::$_nullObject);
$hash = CRM_Utils_Request::retrieve('h', 'String', CRM_Core_DAO::$_nullObject);
if (!$contact_id || !$subscribe_id || !$hash) {
CRM_Core_Error::fatal(ts("Missing input parameters"));
}
$result = CRM_Mailing_Event_BAO_Confirm::confirm($contact_id, $subscribe_id, $hash);
if ($result === FALSE) {
$this->assign('success', $result);
} else {
$this->assign('success', TRUE);
$this->assign('group', $result);
}
list($displayName, $email) = CRM_Contact_BAO_Contact_Location::getEmailDetails($contact_id);
$this->assign('display_name', $displayName);
$this->assign('email', $email);
return parent::run();
}
示例6: run
/**
* @return string
* @throws Exception
*/
public function run()
{
CRM_Utils_System::addHTMLHead('<META NAME="ROBOTS" CONTENT="NOINDEX, NOFOLLOW">');
$contact_id = CRM_Utils_Request::retrieve('cid', 'Integer', CRM_Core_DAO::$_nullObject);
$subscribe_id = CRM_Utils_Request::retrieve('sid', 'Integer', CRM_Core_DAO::$_nullObject);
$hash = CRM_Utils_Request::retrieve('h', 'String', CRM_Core_DAO::$_nullObject);
$activity_id = CRM_Utils_Request::retrieve('a', 'String', CRM_Core_DAO::$_nullObject);
$petition_id = CRM_Utils_Request::retrieve('pid', 'String', CRM_Core_DAO::$_nullObject);
if (!$petition_id) {
$petition_id = CRM_Utils_Request::retrieve('p', 'String', CRM_Core_DAO::$_nullObject);
}
if (!$contact_id || !$subscribe_id || !$hash) {
CRM_Core_Error::fatal(ts("Missing input parameters"));
}
$result = $this->confirm($contact_id, $subscribe_id, $hash, $activity_id, $petition_id);
if ($result === FALSE) {
$this->assign('success', $result);
} else {
$this->assign('success', TRUE);
// $this->assign( 'group' , $result );
}
list($displayName, $email) = CRM_Contact_BAO_Contact_Location::getEmailDetails($contact_id);
$this->assign('display_name', $displayName);
$this->assign('email', $email);
$this->assign('petition_id', $petition_id);
$this->assign('survey_id', $petition_id);
$pparams['id'] = $petition_id;
$this->petition = array();
CRM_Campaign_BAO_Survey::retrieve($pparams, $this->petition);
$this->assign('is_share', CRM_Utils_Array::value('is_share', $this->petition));
$this->assign('thankyou_title', CRM_Utils_Array::value('thankyou_title', $this->petition));
$this->assign('thankyou_text', CRM_Utils_Array::value('thankyou_text', $this->petition));
CRM_Utils_System::setTitle(CRM_Utils_Array::value('thankyou_title', $this->petition));
// send thank you email
$params['contactId'] = $contact_id;
$params['email-Primary'] = $email;
$params['sid'] = $petition_id;
$params['activityId'] = $activity_id;
CRM_Campaign_BAO_Petition::sendEmail($params, CRM_Campaign_Form_Petition_Signature::EMAIL_THANK);
return parent::run();
}
示例7: run
function run()
{
require_once 'CRM/Utils/Request.php';
$contact_id = CRM_Utils_Request::retrieve('cid', 'Integer', CRM_Core_DAO::$_nullObject);
$subscribe_id = CRM_Utils_Request::retrieve('sid', 'Integer', CRM_Core_DAO::$_nullObject);
$hash = CRM_Utils_Request::retrieve('h', 'String', CRM_Core_DAO::$_nullObject);
if (!$contact_id || !$subscribe_id || !$hash) {
CRM_Core_Error::fatal(ts("Missing input parameters"));
}
require_once 'CRM/Mailing/Event/BAO/Confirm.php';
$result = CRM_Mailing_Event_BAO_Confirm::confirm($contact_id, $subscribe_id, $hash);
if ($result === false) {
$this->assign('success', $result);
} else {
$this->assign('success', true);
$this->assign('group', $result);
}
require_once 'CRM/Contact/BAO/Contact/Location.php';
list($displayName, $email) = CRM_Contact_BAO_Contact_Location::getEmailDetails($contact_id);
$this->assign('display_name', $displayName);
$this->assign('email', $email);
parent::run();
}
示例8: sendStatusUpdate
/**
* Send notfication email to supporter
* 1. when their PCP status is changed by site admin.
* 2. when supporter initially creates a Personal Campaign Page ($isInitial set to true).
*
* @param int $pcpId
* Campaign page id.
* @param int $newStatus
* Pcp status id.
* @param bool|int $isInitial is it the first time, campaign page has been created by the user
*
* @param string $component
*
* @throws Exception
* @return null
*/
public static function sendStatusUpdate($pcpId, $newStatus, $isInitial = FALSE, $component = 'contribute')
{
$pcpStatusName = CRM_Core_OptionGroup::values("pcp_status", FALSE, FALSE, FALSE, NULL, 'name');
$pcpStatus = CRM_Core_OptionGroup::values("pcp_status");
$config = CRM_Core_Config::singleton();
if (!isset($pcpStatus[$newStatus])) {
return FALSE;
}
require_once 'Mail/mime.php';
//set loginUrl
$loginURL = $config->userSystem->getLoginURL();
// used in subject templates
$contribPageTitle = self::getPcpPageTitle($pcpId, $component);
$tplParams = array('loginUrl' => $loginURL, 'contribPageTitle' => $contribPageTitle, 'pcpId' => $pcpId);
//get the default domain email address.
list($domainEmailName, $domainEmailAddress) = CRM_Core_BAO_Domain::getNameAndEmail();
if (!$domainEmailAddress || $domainEmailAddress == 'info@EXAMPLE.ORG') {
$fixUrl = CRM_Utils_System::url("civicrm/admin/domain", 'action=update&reset=1');
CRM_Core_Error::fatal(ts('The site administrator needs to enter a valid \'FROM Email Address\' in <a href="%1">Administer CiviCRM » Communications » FROM Email Addresses</a>. The email address used may need to be a valid mail account with your email service provider.', array(1 => $fixUrl)));
}
$receiptFrom = '"' . $domainEmailName . '" <' . $domainEmailAddress . '>';
// get recipient (supporter) name and email
$params = array('id' => $pcpId);
CRM_Core_DAO::commonRetrieve('CRM_PCP_DAO_PCP', $params, $pcpInfo);
list($name, $address) = CRM_Contact_BAO_Contact_Location::getEmailDetails($pcpInfo['contact_id']);
// get pcp block info
list($blockId, $eid) = self::getPcpBlockEntityId($pcpId, $component);
$params = array('id' => $blockId);
CRM_Core_DAO::commonRetrieve('CRM_PCP_DAO_PCPBlock', $params, $pcpBlockInfo);
// assign urls required in email template
if ($pcpStatusName[$newStatus] == 'Approved') {
$tplParams['isTellFriendEnabled'] = $pcpBlockInfo['is_tellfriend_enabled'];
if ($pcpBlockInfo['is_tellfriend_enabled']) {
$pcpTellFriendURL = CRM_Utils_System::url('civicrm/friend', "reset=1&eid={$pcpId}&blockId={$blockId}&pcomponent=pcp", TRUE, NULL, FALSE, TRUE);
$tplParams['pcpTellFriendURL'] = $pcpTellFriendURL;
}
}
$pcpInfoURL = CRM_Utils_System::url('civicrm/pcp/info', "reset=1&id={$pcpId}", TRUE, NULL, FALSE, TRUE);
$tplParams['pcpInfoURL'] = $pcpInfoURL;
$tplParams['contribPageTitle'] = $contribPageTitle;
if ($emails = CRM_Utils_Array::value('notify_email', $pcpBlockInfo)) {
$emailArray = explode(',', $emails);
$tplParams['pcpNotifyEmailAddress'] = $emailArray[0];
}
// get appropriate message based on status
$tplParams['pcpStatus'] = $pcpStatus[$newStatus];
$tplName = $isInitial ? 'pcp_supporter_notify' : 'pcp_status_change';
list($sent, $subject, $message, $html) = CRM_Core_BAO_MessageTemplate::sendTemplate(array('groupName' => 'msg_tpl_workflow_contribution', 'valueName' => $tplName, 'contactId' => $pcpInfo['contact_id'], 'tplParams' => $tplParams, 'from' => $receiptFrom, 'toName' => $name, 'toEmail' => $address));
return $sent;
}
示例9: emailReceipt
//.........这里部分代码省略.........
if (property_exists($form, '_groupTree') && !empty($form->_groupTree)) {
foreach ($form->_groupTree as $groupID => $group) {
if ($groupID == 'info') {
continue;
}
foreach ($group['fields'] as $k => $field) {
$field['title'] = $field['label'];
$customFields["custom_{$k}"] = $field;
}
}
}
$members = array(array('member_id', '=', $membership->id, 0, 0));
// check whether its a test drive
if ($form->_mode == 'test') {
$members[] = array('member_test', '=', 1, 0, 0);
}
CRM_Core_BAO_UFGroup::getValues($formValues['contact_id'], $customFields, $customValues, FALSE, $members);
if ($form->_mode) {
if (!empty($form->_params['billing_first_name'])) {
$name = $form->_params['billing_first_name'];
}
if (!empty($form->_params['billing_middle_name'])) {
$name .= " {$form->_params['billing_middle_name']}";
}
if (!empty($form->_params['billing_last_name'])) {
$name .= " {$form->_params['billing_last_name']}";
}
$form->assign('billingName', $name);
// assign the address formatted up for display
$addressParts = array("street_address-{$form->_bltID}", "city-{$form->_bltID}", "postal_code-{$form->_bltID}", "state_province-{$form->_bltID}", "country-{$form->_bltID}");
$addressFields = array();
foreach ($addressParts as $part) {
list($n, $id) = explode('-', $part);
if (isset($form->_params['billing_' . $part])) {
$addressFields[$n] = $form->_params['billing_' . $part];
}
}
$form->assign('address', CRM_Utils_Address::format($addressFields));
$date = CRM_Utils_Date::format($form->_params['credit_card_exp_date']);
$date = CRM_Utils_Date::mysqlToIso($date);
$form->assign('credit_card_exp_date', $date);
$form->assign('credit_card_number', CRM_Utils_System::mungeCreditCard($form->_params['credit_card_number']));
$form->assign('credit_card_type', $form->_params['credit_card_type']);
$form->assign('contributeMode', 'direct');
$form->assign('isAmountzero', 0);
$form->assign('is_pay_later', 0);
$form->assign('isPrimary', 1);
}
$form->assign('module', 'Membership');
$form->assign('contactID', $formValues['contact_id']);
$form->assign('membershipID', CRM_Utils_Array::value('membership_id', $form->_params, CRM_Utils_Array::value('membership_id', $form->_defaultValues)));
if (!empty($formValues['contribution_id'])) {
$form->assign('contributionID', $formValues['contribution_id']);
} elseif (isset($form->_onlinePendingContributionId)) {
$form->assign('contributionID', $form->_onlinePendingContributionId);
}
if (!empty($formValues['contribution_status_id'])) {
$form->assign('contributionStatusID', $formValues['contribution_status_id']);
$form->assign('contributionStatus', CRM_Contribute_PseudoConstant::contributionStatus($formValues['contribution_status_id'], 'name'));
}
if (!empty($formValues['is_renew'])) {
$form->assign('receiptType', 'membership renewal');
} else {
$form->assign('receiptType', 'membership signup');
}
$form->assign('receive_date', CRM_Utils_Date::processDate(CRM_Utils_Array::value('receive_date', $formValues)));
$form->assign('formValues', $formValues);
if (empty($lineItem)) {
$form->assign('mem_start_date', CRM_Utils_Date::customFormat($membership->start_date, '%B %E%f, %Y'));
if (!CRM_Utils_System::isNull($membership->end_date)) {
$form->assign('mem_end_date', CRM_Utils_Date::customFormat($membership->end_date, '%B %E%f, %Y'));
}
$form->assign('membership_name', CRM_Member_PseudoConstant::membershipType($membership->membership_type_id));
}
$form->assign('customValues', $customValues);
$isBatchProcess = is_a($form, 'CRM_Batch_Form_Entry');
if (empty($form->_contributorDisplayName) || empty($form->_contributorEmail) || $isBatchProcess) {
// in this case the form is being called statically from the batch editing screen
// having one class in the form layer call another statically is not greate
// & we should aim to move this function to the BAO layer in future.
// however, we can assume that the contact_id passed in by the batch
// function will be the recipient
list($form->_contributorDisplayName, $form->_contributorEmail) = CRM_Contact_BAO_Contact_Location::getEmailDetails($formValues['contact_id']);
if (empty($form->_receiptContactId) || $isBatchProcess) {
$form->_receiptContactId = $formValues['contact_id'];
}
}
$template = CRM_Core_Smarty::singleton();
$taxAmt = $template->get_template_vars('dataArray');
$eventTaxAmt = $template->get_template_vars('totalTaxAmount');
$prefixValue = CRM_Core_BAO_Setting::getItem(CRM_Core_BAO_Setting::CONTRIBUTE_PREFERENCES_NAME, 'contribution_invoice_settings');
$invoicing = CRM_Utils_Array::value('invoicing', $prefixValue);
if ((!empty($taxAmt) || isset($eventTaxAmt)) && (isset($invoicing) && isset($prefixValue['is_email_pdf']))) {
$isEmailPdf = TRUE;
} else {
$isEmailPdf = FALSE;
}
list($mailSend, $subject, $message, $html) = CRM_Core_BAO_MessageTemplate::sendTemplate(array('groupName' => 'msg_tpl_workflow_membership', 'valueName' => 'membership_offline_receipt', 'contactId' => $form->_receiptContactId, 'from' => $receiptFrom, 'toName' => $form->_contributorDisplayName, 'toEmail' => $form->_contributorEmail, 'PDFFilename' => ts('receipt') . '.pdf', 'isEmailPdf' => $isEmailPdf, 'contributionId' => $formValues['contribution_id'], 'isTest' => (bool) ($form->_action & CRM_Core_Action::PREVIEW)));
return TRUE;
}
示例10: buildQuickForm
/**
* Build the form object.
*
* @param CRM_Core_Form $form
*
* @return void
*/
public static function buildQuickForm(&$form)
{
if ($form->_eventId) {
$form->_isPaidEvent = CRM_Core_DAO::getFieldValue('CRM_Event_DAO_Event', $form->_eventId, 'is_monetary');
if ($form->_isPaidEvent) {
$form->addElement('hidden', 'hidden_feeblock', 1);
}
// make sure this is for backoffice registration.
if ($form->getName() == 'Participant') {
$eventfullMsg = CRM_Event_BAO_Participant::eventFullMessage($form->_eventId, $form->_pId);
$form->addElement('hidden', 'hidden_eventFullMsg', $eventfullMsg, array('id' => 'hidden_eventFullMsg'));
}
}
if ($form->_pId) {
if (CRM_Core_DAO::getFieldValue('CRM_Event_DAO_ParticipantPayment', $form->_pId, 'contribution_id', 'participant_id')) {
$form->_online = TRUE;
}
}
if ($form->_isPaidEvent) {
$params = array('id' => $form->_eventId);
CRM_Event_BAO_Event::retrieve($params, $event);
//retrieve custom information
$form->_values = array();
CRM_Event_Form_Registration::initEventFee($form, $event['id']);
CRM_Event_Form_Registration_Register::buildAmount($form, TRUE, $form->_discountId);
$lineItem = array();
$invoiceSettings = CRM_Core_BAO_Setting::getItem(CRM_Core_BAO_Setting::CONTRIBUTE_PREFERENCES_NAME, 'contribution_invoice_settings');
$invoicing = CRM_Utils_Array::value('invoicing', $invoiceSettings);
$totalTaxAmount = 0;
if (!CRM_Utils_System::isNull(CRM_Utils_Array::value('line_items', $form->_values))) {
$lineItem[] = $form->_values['line_items'];
foreach ($form->_values['line_items'] as $key => $value) {
$totalTaxAmount = $value['tax_amount'] + $totalTaxAmount;
}
}
if ($invoicing) {
$form->assign('totalTaxAmount', $totalTaxAmount);
}
$form->assign('lineItem', empty($lineItem) ? FALSE : $lineItem);
$discounts = array();
if (!empty($form->_values['discount'])) {
foreach ($form->_values['discount'] as $key => $value) {
$value = current($value);
$discounts[$key] = $value['name'];
}
$element = $form->add('select', 'discount_id', ts('Discount Set'), array(0 => ts('- select -')) + $discounts, FALSE, array('class' => "crm-select2"));
if ($form->_online) {
$element->freeze();
}
}
if ($form->_mode) {
CRM_Core_Payment_Form::buildPaymentForm($form, $form->_paymentProcessor, FALSE);
} elseif (!$form->_mode) {
$form->addElement('checkbox', 'record_contribution', ts('Record Payment?'), NULL, array('onclick' => "return showHideByValue('record_contribution','','payment_information','table-row','radio',false);"));
$form->add('select', 'financial_type_id', ts('Financial Type'), array('' => ts('- select -')) + CRM_Contribute_PseudoConstant::financialType());
$form->addDate('receive_date', ts('Received'), FALSE, array('formatType' => 'activityDate'));
$form->add('select', 'payment_instrument_id', ts('Paid By'), array('' => ts('- select -')) + CRM_Contribute_PseudoConstant::paymentInstrument(), FALSE, array('onChange' => "return showHideByValue('payment_instrument_id','4','checkNumber','table-row','select',false);"));
// don't show transaction id in batch update mode
$path = CRM_Utils_System::currentPath();
$form->assign('showTransactionId', FALSE);
if ($path != 'civicrm/contact/search/basic') {
$form->add('text', 'trxn_id', ts('Transaction ID'));
$form->addRule('trxn_id', ts('Transaction ID already exists in Database.'), 'objectExists', array('CRM_Contribute_DAO_Contribution', $form->_eventId, 'trxn_id'));
$form->assign('showTransactionId', TRUE);
}
$status = CRM_Contribute_PseudoConstant::contributionStatus();
// CRM-14417 suppressing contribution statuses that are NOT relevant to new participant registrations
$statusName = CRM_Contribute_PseudoConstant::contributionStatus(NULL, 'name');
foreach (array('Cancelled', 'Failed', 'In Progress', 'Overdue', 'Refunded', 'Pending refund') as $suppress) {
unset($status[CRM_Utils_Array::key($suppress, $statusName)]);
}
$form->add('select', 'contribution_status_id', ts('Payment Status'), $status);
$form->add('text', 'check_number', ts('Check Number'), CRM_Core_DAO::getAttribute('CRM_Contribute_DAO_Contribution', 'check_number'));
$form->add('text', 'total_amount', ts('Amount'), CRM_Core_DAO::getAttribute('CRM_Contribute_DAO_Contribution', 'total_amount'));
}
} else {
$form->add('text', 'amount', ts('Event Fee(s)'));
}
$form->assign('onlinePendingContributionId', $form->get('onlinePendingContributionId'));
$form->assign('paid', $form->_isPaidEvent);
$form->addElement('checkbox', 'send_receipt', ts('Send Confirmation?'), NULL, array('onclick' => "showHideByValue('send_receipt','','notice','table-row','radio',false); showHideByValue('send_receipt','','from-email','table-row','radio',false);"));
$form->add('select', 'from_email_address', ts('Receipt From'), $form->_fromEmails['from_email_id']);
$form->add('textarea', 'receipt_text', ts('Confirmation Message'));
// Retrieve the name and email of the contact - form will be the TO for receipt email ( only if context is not standalone)
if ($form->_context != 'standalone') {
if ($form->_contactId) {
list($form->_contributorDisplayName, $form->_contributorEmail) = CRM_Contact_BAO_Contact_Location::getEmailDetails($form->_contactId);
$form->assign('email', $form->_contributorEmail);
} else {
//show email block for batch update for event
$form->assign('batchEmail', TRUE);
}
}
//.........这里部分代码省略.........
示例11: sendAcknowledgment
/**
* Function to send Acknowledgment and create activity.
*
* @param object $form form object.
* @param array $params (reference ) an assoc array of name/value pairs.
* @access public
*
* @return None.
*/
function sendAcknowledgment(&$form, $params)
{
//handle Acknowledgment.
$allPayments = $payments = array();
//get All Payments status types.
$paymentStatusTypes = CRM_Contribute_PseudoConstant::contributionStatus(NULL, 'name');
$returnProperties = array('status_id', 'scheduled_amount', 'scheduled_date', 'contribution_id');
//get all paymnets details.
CRM_Core_DAO::commonRetrieveAll('CRM_Pledge_DAO_PledgePayment', 'pledge_id', $params['id'], $allPayments, $returnProperties);
if (!empty($allPayments)) {
foreach ($allPayments as $payID => $values) {
$contributionValue = $contributionStatus = array();
if (isset($values['contribution_id'])) {
$contributionParams = array('id' => $values['contribution_id']);
$returnProperties = array('contribution_status_id', 'receive_date');
CRM_Core_DAO::commonRetrieve('CRM_Contribute_DAO_Contribution', $contributionParams, $contributionStatus, $returnProperties);
$contributionValue = array('status' => CRM_Utils_Array::value('contribution_status_id', $contributionStatus), 'receive_date' => CRM_Utils_Array::value('receive_date', $contributionStatus));
}
$payments[$payID] = array_merge($contributionValue, array('amount' => CRM_Utils_Array::value('scheduled_amount', $values), 'due_date' => CRM_Utils_Array::value('scheduled_date', $values)));
//get the first valid payment id.
if (!isset($form->paymentId) && ($paymentStatusTypes[$values['status_id']] == 'Pending' || $paymentStatusTypes[$values['status_id']] == 'Overdue')) {
$form->paymentId = $values['id'];
}
}
}
//end
//assign pledge fields value to template.
$pledgeFields = array('create_date', 'total_pledge_amount', 'frequency_interval', 'frequency_unit', 'installments', 'frequency_day', 'scheduled_amount', 'currency');
foreach ($pledgeFields as $field) {
if (CRM_Utils_Array::value($field, $params)) {
$form->assign($field, $params[$field]);
}
}
//assign all payments details.
if ($payments) {
$form->assign('payments', $payments);
}
//assign honor fields.
$honor_block_is_active = FALSE;
//make sure we have values for it
if (CRM_Utils_Array::value('honor_type_id', $params) && (!empty($params['honor_first_name']) && !empty($params['honor_last_name']) || !empty($params['honor_email']))) {
$honor_block_is_active = TRUE;
$prefix = CRM_Core_PseudoConstant::get('CRM_Contact_DAO_Contact', 'prefix_id');
$honor = CRM_Core_PseudoConstant::get('CRM_Pledge_DAO_Pledge', 'honor_type_id');
$form->assign('honor_type', $honor[$params['honor_type_id']]);
$form->assign('honor_prefix', $prefix[$params['honor_prefix_id']]);
$form->assign('honor_first_name', $params['honor_first_name']);
$form->assign('honor_last_name', $params['honor_last_name']);
$form->assign('honor_email', $params['honor_email']);
}
$form->assign('honor_block_is_active', $honor_block_is_active);
//handle domain token values
$domain = CRM_Core_BAO_Domain::getDomain();
$tokens = array('domain' => array('name', 'phone', 'address', 'email'), 'contact' => CRM_Core_SelectValues::contactTokens());
$domainValues = array();
foreach ($tokens['domain'] as $token) {
$domainValues[$token] = CRM_Utils_Token::getDomainTokenReplacement($token, $domain);
}
$form->assign('domain', $domainValues);
//handle contact token values.
$ids = array($params['contact_id']);
$fields = array_merge(array_keys(CRM_Contact_BAO_Contact::importableFields()), array('display_name', 'checksum', 'contact_id'));
foreach ($fields as $key => $val) {
$returnProperties[$val] = TRUE;
}
$details = CRM_Utils_Token::getTokenDetails($ids, $returnProperties, TRUE, TRUE, NULL, $tokens, get_class($form));
$form->assign('contact', $details[0][$params['contact_id']]);
//handle custom data.
if (CRM_Utils_Array::value('hidden_custom', $params)) {
$groupTree = CRM_Core_BAO_CustomGroup::getTree('Pledge', CRM_Core_DAO::$_nullObject, $params['id']);
$pledgeParams = array(array('pledge_id', '=', $params['id'], 0, 0));
$customGroup = array();
// retrieve custom data
foreach ($groupTree as $groupID => $group) {
$customFields = $customValues = array();
if ($groupID == 'info') {
continue;
}
foreach ($group['fields'] as $k => $field) {
$field['title'] = $field['label'];
$customFields["custom_{$k}"] = $field;
}
//to build array of customgroup & customfields in it
CRM_Core_BAO_UFGroup::getValues($params['contact_id'], $customFields, $customValues, FALSE, $pledgeParams);
$customGroup[$group['title']] = $customValues;
}
$form->assign('customGroup', $customGroup);
}
//handle acknowledgment email stuff.
list($pledgerDisplayName, $pledgerEmail) = CRM_Contact_BAO_Contact_Location::getEmailDetails($params['contact_id']);
//check for online pledge.
//.........这里部分代码省略.........
示例12: sendMail
/**
* Process that send e-mails
*
* @return void
* @access public
*/
static function sendMail($contactID, &$values, $participantId, $isTest = false, $returnMessageText = false)
{
require_once 'CRM/Core/BAO/UFGroup.php';
$template = CRM_Core_Smarty::singleton();
$gIds = array('custom_pre_id' => $values['custom_pre_id'], 'custom_post_id' => $values['custom_post_id']);
//get the params submitted by participant.
$participantParams = CRM_Utils_Array::value($participantId, $values['params'], array());
if (!$returnMessageText) {
//send notification email if field values are set (CRM-1941)
foreach ($gIds as $key => $gId) {
if ($gId) {
$email = CRM_Core_DAO::getFieldValue('CRM_Core_DAO_UFGroup', $gId, 'notify');
if ($email) {
//get values of corresponding profile fields for notification
list($profileValues) = self::buildCustomDisplay($gId, null, $contactID, $template, $participantId, $isTest, true, $participantParams);
$val = array('id' => $gId, 'values' => $profileValues, 'email' => $email);
CRM_Core_BAO_UFGroup::commonSendMail($contactID, $val);
}
}
}
}
if ($values['event']['is_email_confirm'] || $returnMessageText) {
require_once 'CRM/Contact/BAO/Contact/Location.php';
//use primary email address, since we are not creating billing address for
//1. participant is pay later.
//2. participant might be additional participant.
//3. participant might be on waiting list.
//4. registration might require approval.
if (CRM_Utils_Array::value('is_pay_later', $values['params']) || CRM_Utils_Array::value('additionalParticipant', $values['params']) || CRM_Utils_Array::value('isOnWaitlist', $values['params']) || CRM_Utils_Array::value('isRequireApproval', $values['params']) || !CRM_Utils_Array::value('is_monetary', $values['event'])) {
list($displayName, $email) = CRM_Contact_BAO_Contact_Location::getEmailDetails($contactID);
} else {
// get the billing location type
$locationTypes =& CRM_Core_PseudoConstant::locationType();
$bltID = array_search('Billing', $locationTypes);
list($displayName, $email) = CRM_Contact_BAO_Contact_Location::getEmailDetails($contactID, false, $bltID);
}
//send email only when email is present
if (isset($email) || $returnMessageText) {
$preProfileID = $values['custom_pre_id'];
$postProfileID = $values['custom_post_id'];
if (CRM_Utils_Array::value('additionalParticipant', $values['params'])) {
$preProfileID = $values['additional_custom_pre_id'];
$postProfileID = $values['additional_custom_post_id'];
}
self::buildCustomDisplay($preProfileID, 'customPre', $contactID, $template, $participantId, $isTest, null, $participantParams);
self::buildCustomDisplay($postProfileID, 'customPost', $contactID, $template, $participantId, $isTest, null, $participantParams);
$sendTemplateParams = array('groupName' => 'msg_tpl_workflow_event', 'valueName' => 'event_online_receipt', 'contactId' => $contactID, 'isTest' => $isTest, 'tplParams' => array('email' => $email, 'confirm_email_text' => CRM_Utils_Array::value('confirm_email_text', $values['event']), 'isShowLocation' => CRM_Utils_Array::value('is_show_location', $values['event'])), 'PDFFilename' => 'civicrm.pdf');
// address required during receipt processing (pdf and email receipt)
if ($displayAddress = CRM_Utils_Array::value('address', $values)) {
$sendTemplateParams['tplParams']['address'] = $displayAddress;
$sendTemplateParams['tplParams']['contributeMode'] = null;
}
// set lineItem details
if ($lineItem = CRM_Utils_Array::value('lineItem', $values)) {
$sendTemplateParams['tplParams']['lineItem'] = $lineItem;
}
require_once 'CRM/Core/BAO/MessageTemplates.php';
if ($returnMessageText) {
list($sent, $subject, $message, $html) = CRM_Core_BAO_MessageTemplates::sendTemplate($sendTemplateParams);
return array('subject' => $subject, 'body' => $message, 'to' => $displayName, 'html' => $html);
} else {
$sendTemplateParams['from'] = "{$values['event']['confirm_from_name']} <{$values['event']['confirm_from_email']}>";
$sendTemplateParams['toName'] = $displayName;
$sendTemplateParams['toEmail'] = $email;
$sendTemplateParams['autoSubmitted'] = true;
$sendTemplateParams['cc'] = CRM_Utils_Array::value('cc_confirm', $values['event']);
$sendTemplateParams['bcc'] = CRM_Utils_Array::value('bcc_confirm', $values['event']);
CRM_Core_BAO_MessageTemplates::sendTemplate($sendTemplateParams);
}
}
}
}
示例13: processCreditCard
/**
* Process credit card payment.
*
* @param array $submittedValues
* @param array $lineItem
*
* @throws CRM_Core_Exception
*/
protected function processCreditCard($submittedValues, $lineItem)
{
$sendReceipt = $contribution = FALSE;
$unsetParams = array('trxn_id', 'payment_instrument_id', 'contribution_status_id', 'cancel_date', 'cancel_reason');
foreach ($unsetParams as $key) {
if (isset($submittedValues[$key])) {
unset($submittedValues[$key]);
}
}
$isTest = $this->_mode == 'test' ? 1 : 0;
// CRM-12680 set $_lineItem if its not set
if (empty($this->_lineItem) && !empty($lineItem)) {
$this->_lineItem = $lineItem;
}
//Get the require fields value only.
$params = $this->_params = $submittedValues;
$this->_paymentProcessor = CRM_Financial_BAO_PaymentProcessor::getPayment($this->_params['payment_processor_id'], $this->_mode);
// Get the payment processor id as per mode.
$this->_params['payment_processor'] = $params['payment_processor_id'] = $this->_params['payment_processor_id'] = $submittedValues['payment_processor_id'] = $this->_paymentProcessor['id'];
$now = date('YmdHis');
$fields = array();
// we need to retrieve email address
if ($this->_context == 'standalone' && !empty($submittedValues['is_email_receipt'])) {
list($this->userDisplayName, $this->userEmail) = CRM_Contact_BAO_Contact_Location::getEmailDetails($this->_contactID);
$this->assign('displayName', $this->userDisplayName);
}
// Set email for primary location.
$fields['email-Primary'] = 1;
$params['email-Primary'] = $this->userEmail;
// now set the values for the billing location.
foreach (array_keys($this->_fields) as $name) {
$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;
$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;
}
}
if (!empty($params['source'])) {
unset($params['source']);
}
$contactID = CRM_Contact_BAO_Contact::createProfileContact($params, $fields, $this->_contactID, NULL, NULL, $ctype);
// add all the additional payment params we need
if (!empty($this->_params["billing_state_province_id-{$this->_bltID}"])) {
$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}"]);
}
if (!empty($this->_params["billing_country_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}"]);
}
$legacyCreditCardExpiryCheck = FALSE;
if ($this->_paymentProcessor['payment_type'] & CRM_Core_Payment::PAYMENT_TYPE_CREDIT_CARD && !isset($this->_paymentFields)) {
$legacyCreditCardExpiryCheck = TRUE;
}
if ($legacyCreditCardExpiryCheck || in_array('credit_card_exp_date', array_keys($this->_paymentFields))) {
$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'] = $this->_params['total_amount'];
$this->_params['amount_level'] = 0;
$this->_params['description'] = ts('Office Credit Card contribution');
$this->_params['currencyID'] = CRM_Utils_Array::value('currency', $this->_params, CRM_Core_Config::singleton()->defaultCurrency);
$this->_params['payment_action'] = 'Sale';
if (!empty($this->_params['receive_date'])) {
$this->_params['receive_date'] = CRM_Utils_Date::processDate($this->_params['receive_date'], $this->_params['receive_date_time']);
}
if (!empty($params['soft_credit_to'])) {
$this->_params['soft_credit_to'] = $params['soft_credit_to'];
$this->_params['pcp_made_through_id'] = $params['pcp_made_through_id'];
}
$this->_params['pcp_display_in_roll'] = CRM_Utils_Array::value('pcp_display_in_roll', $params);
$this->_params['pcp_roll_nickname'] = CRM_Utils_Array::value('pcp_roll_nickname', $params);
$this->_params['pcp_personal_note'] = CRM_Utils_Array::value('pcp_personal_note', $params);
//Add common data to formatted params
CRM_Contribute_Form_AdditionalInfo::postProcessCommon($params, $this->_params, $this);
if (empty($this->_params['invoice_id'])) {
$this->_params['invoiceID'] = md5(uniqid(rand(), TRUE));
} else {
$this->_params['invoiceID'] = $this->_params['invoice_id'];
}
// 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;
//.........这里部分代码省略.........
示例14: submit
/**
* Process form submission.
*
* This function is also accessed by a unit test.
*/
protected function submit()
{
$this->storeContactFields($this->_params);
$this->beginPostProcess();
$now = CRM_Utils_Date::getToday(NULL, 'YmdHis');
$this->convertDateFieldsToMySQL($this->_params);
$this->assign('receive_date', $this->_params['receive_date']);
$this->processBillingAddress();
list($userName) = CRM_Contact_BAO_Contact_Location::getEmailDetails(CRM_Core_Session::singleton()->get('userID'));
$this->_params['total_amount'] = CRM_Utils_Array::value('total_amount', $this->_params, CRM_Core_DAO::getFieldValue('CRM_Member_DAO_MembershipType', $this->_memType, 'minimum_fee'));
$this->_membershipId = $this->_id;
$customFieldsFormatted = CRM_Core_BAO_CustomField::postProcess($this->_params, $this->_id, 'Membership');
if (empty($this->_params['financial_type_id'])) {
$this->_params['financial_type_id'] = CRM_Core_DAO::getFieldValue('CRM_Member_DAO_MembershipType', $this->_memType, 'financial_type_id');
}
$contributionRecurID = NULL;
$this->assign('membershipID', $this->_id);
$this->assign('contactID', $this->_contactID);
$this->assign('module', 'Membership');
$this->assign('receiptType', 'membership renewal');
$this->_params['currencyID'] = CRM_Core_Config::singleton()->defaultCurrency;
$this->_params['invoice_id'] = $this->_params['invoiceID'] = md5(uniqid(rand(), TRUE));
if (!empty($this->_params['send_receipt'])) {
$this->_params['receipt_date'] = $now;
$this->assign('receipt_date', CRM_Utils_Date::mysqlToIso($this->_params['receipt_date']));
} else {
$this->_params['receipt_date'] = NULL;
}
if ($this->_mode) {
$this->_params['register_date'] = $now;
$this->_params['description'] = ts("Contribution submitted by a staff person using member's credit card for renewal");
$this->_params['amount'] = $this->_params['total_amount'];
// 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 passed params
// so we copy stuff over to first_name etc.
$paymentParams = $this->_params;
if (!empty($this->_params['send_receipt'])) {
$paymentParams['email'] = $this->_contributorEmail;
}
$paymentParams['contactID'] = $this->_contributorContactID;
CRM_Core_Payment_Form::mapParams($this->_bltID, $this->_params, $paymentParams, TRUE);
$payment = $this->_paymentProcessor['object'];
if (!empty($this->_params['auto_renew'])) {
$contributionRecurParams = $this->processRecurringContribution($paymentParams);
$contributionRecurID = $contributionRecurParams['contributionRecurID'];
$paymentParams = array_merge($paymentParams, $contributionRecurParams);
}
$result = $payment->doPayment($paymentParams);
$this->_params = array_merge($this->_params, $result);
$this->_params['contribution_status_id'] = $result['payment_status_id'];
$this->_params['trxn_id'] = $result['trxn_id'];
$this->_params['payment_instrument_id'] = 1;
$this->_params['is_test'] = $this->_mode == 'live' ? 0 : 1;
$this->set('params', $this->_params);
$this->assign('trxn_id', $result['trxn_id']);
}
$renewalDate = !empty($this->_params['renewal_date']) ? $renewalDate = CRM_Utils_Date::processDate($this->_params['renewal_date']) : NULL;
// check for test membership.
$isTestMembership = CRM_Core_DAO::getFieldValue('CRM_Member_DAO_Membership', $this->_membershipId, 'is_test');
// chk for renewal for multiple terms CRM-8750
$numRenewTerms = 1;
if (is_numeric(CRM_Utils_Array::value('num_terms', $this->_params))) {
$numRenewTerms = $this->_params['num_terms'];
}
//if contribution status is pending then set pay later
$this->_params['is_pay_later'] = FALSE;
if ($this->_params['contribution_status_id'] == array_search('Pending', CRM_Contribute_PseudoConstant::contributionStatus())) {
$this->_params['is_pay_later'] = 1;
}
// These variable sets prior to renewMembership may not be required for this form. They were in
// a function this form shared with other forms.
$membershipSource = NULL;
if (!empty($this->_params['membership_source'])) {
$membershipSource = $this->_params['membership_source'];
}
$isPending = $this->_params['contribution_status_id'] == 2 ? TRUE : FALSE;
list($renewMembership) = CRM_Member_BAO_Membership::renewMembership($this->_contactID, $this->_params['membership_type_id'][1], $isTestMembership, $renewalDate, NULL, $customFieldsFormatted, $numRenewTerms, $this->_membershipId, $isPending, $contributionRecurID, $membershipSource, $this->_params['is_pay_later'], CRM_Utils_Array::value('campaign_id', $this->_params));
$this->endDate = CRM_Utils_Date::processDate($renewMembership->end_date);
$this->membershipTypeName = CRM_Core_DAO::getFieldValue('CRM_Member_DAO_MembershipType', $renewMembership->membership_type_id, 'name');
if (!empty($this->_params['record_contribution']) || $this->_mode) {
// set the source
$this->_params['contribution_source'] = "{$this->membershipTypeName} Membership: Offline membership renewal (by {$userName})";
//create line items
$lineItem = array();
$this->_params = $this->setPriceSetParameters($this->_params);
CRM_Price_BAO_PriceSet::processAmount($this->_priceSet['fields'], $this->_params, $lineItem[$this->_priceSetId]);
//CRM-11529 for quick config backoffice transactions
//when financial_type_id is passed in form, update the
//line items with the financial type selected in form
if ($submittedFinancialType = CRM_Utils_Array::value('financial_type_id', $this->_params)) {
foreach ($lineItem[$this->_priceSetId] as &$li) {
$li['financial_type_id'] = $submittedFinancialType;
}
}
if (!empty($lineItem)) {
//.........这里部分代码省略.........
示例15: postProcess
/**
* Process the form submission.
*/
public function postProcess()
{
if ($this->_action & CRM_Core_Action::DELETE) {
CRM_Pledge_BAO_Pledge::deletePledge($this->_id);
return;
}
// get the submitted form values.
$formValues = $this->controller->exportValues($this->_name);
// set the contact, when contact is selected
if (!empty($formValues['contact_id'])) {
$this->_contactID = $formValues['contact_id'];
}
$session = CRM_Core_Session::singleton();
// get All Payments status types.
$paymentStatusTypes = CRM_Contribute_PseudoConstant::contributionStatus(NULL, 'name');
$fields = array('frequency_unit', 'frequency_interval', 'frequency_day', 'installments', 'financial_type_id', 'initial_reminder_day', 'max_reminders', 'additional_reminder_day', 'contribution_page_id', 'campaign_id');
foreach ($fields as $f) {
$params[$f] = CRM_Utils_Array::value($f, $formValues);
}
// defaults status is "Pending".
// if update get status.
if ($this->_id) {
$params['pledge_status_id'] = $params['status_id'] = $this->_values['status_id'];
} else {
$params['pledge_status_id'] = $params['status_id'] = array_search('Pending', $paymentStatusTypes);
}
// format amount
$params['amount'] = CRM_Utils_Rule::cleanMoney(CRM_Utils_Array::value('amount', $formValues));
$params['currency'] = CRM_Utils_Array::value('currency', $formValues);
$params['original_installment_amount'] = $params['amount'] / $params['installments'];
$dates = array('create_date', 'start_date', 'acknowledge_date', 'cancel_date');
foreach ($dates as $d) {
if ($this->_id && !$this->_isPending && !empty($this->_values[$d])) {
if ($d == 'start_date') {
$params['scheduled_date'] = CRM_Utils_Date::processDate($this->_values[$d]);
}
$params[$d] = CRM_Utils_Date::processDate($this->_values[$d]);
} elseif (!empty($formValues[$d]) && !CRM_Utils_System::isNull($formValues[$d])) {
if ($d == 'start_date') {
$params['scheduled_date'] = CRM_Utils_Date::processDate($formValues[$d]);
}
$params[$d] = CRM_Utils_Date::processDate($formValues[$d]);
} else {
$params[$d] = 'null';
}
}
if (!empty($formValues['is_acknowledge'])) {
$params['acknowledge_date'] = date('Y-m-d');
}
// assign id only in update mode
if ($this->_action & CRM_Core_Action::UPDATE) {
$params['id'] = $this->_id;
}
$params['contact_id'] = $this->_contactID;
// format custom data
if (!empty($formValues['hidden_custom'])) {
$params['hidden_custom'] = 1;
$customFields = CRM_Core_BAO_CustomField::getFields('Pledge');
$params['custom'] = CRM_Core_BAO_CustomField::postProcess($formValues, $this->_id, 'Pledge');
}
// handle pending pledge.
$params['is_pledge_pending'] = $this->_isPending;
// create pledge record.
$pledge = CRM_Pledge_BAO_Pledge::create($params);
$statusMsg = NULL;
if ($pledge->id) {
// set the status msg.
if ($this->_action & CRM_Core_Action::ADD) {
$statusMsg = ts('Pledge has been recorded and the payment schedule has been created.<br />');
} elseif ($this->_action & CRM_Core_Action::UPDATE) {
$statusMsg = ts('Pledge has been updated.<br />');
}
}
// handle Acknowledgment.
if (!empty($formValues['is_acknowledge']) && $pledge->id) {
// calculate scheduled amount.
$params['scheduled_amount'] = round($params['amount'] / $params['installments']);
$params['total_pledge_amount'] = $params['amount'];
// get some required pledge values in params.
$params['id'] = $pledge->id;
$params['acknowledge_date'] = $pledge->acknowledge_date;
$params['is_test'] = $pledge->is_test;
$params['currency'] = $pledge->currency;
// retrieve 'from email id' for acknowledgement
$params['from_email_id'] = $formValues['from_email_address'];
$this->paymentId = NULL;
// send Acknowledgment mail.
CRM_Pledge_BAO_Pledge::sendAcknowledgment($this, $params);
if (!isset($this->userEmail)) {
list($this->userDisplayName, $this->userEmail) = CRM_Contact_BAO_Contact_Location::getEmailDetails($this->_contactID);
}
$statusMsg .= ' ' . ts("An acknowledgment email has been sent to %1.<br />", array(1 => $this->userEmail));
// build the payment urls.
if ($this->paymentId) {
$urlParams = "reset=1&action=add&cid={$this->_contactID}&ppid={$this->paymentId}&context=pledge";
$contribURL = CRM_Utils_System::url('civicrm/contact/view/contribution', $urlParams);
$urlParams .= "&mode=live";
//.........这里部分代码省略.........