本文整理匯總了PHP中CRM_Utils_System::mungeCreditCard方法的典型用法代碼示例。如果您正苦於以下問題:PHP CRM_Utils_System::mungeCreditCard方法的具體用法?PHP CRM_Utils_System::mungeCreditCard怎麽用?PHP CRM_Utils_System::mungeCreditCard使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類CRM_Utils_System
的用法示例。
在下文中一共展示了CRM_Utils_System::mungeCreditCard方法的15個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的PHP代碼示例。
示例1: assignToTemplate
/**
* assign the minimal set of variables to the template
*
* @return void
* @access public
*/
function assignToTemplate()
{
$name = CRM_Utils_Array::value('billing_first_name', $this->_params);
if (CRM_Utils_Array::value('billing_middle_name', $this->_params)) {
$name .= " {$this->_params['billing_middle_name']}";
}
$name .= ' ' . CRM_Utils_Array::value('billing_last_name', $this->_params);
$name = trim($name);
$this->assign('billingName', $name);
$this->set('name', $name);
$this->assign('paymentProcessor', $this->_paymentProcessor);
$vars = array('amount', 'currencyID', 'credit_card_type', 'trxn_id', 'amount_level');
$config = CRM_Core_Config::singleton();
if (isset($this->_values['is_recur']) && CRM_Utils_Array::value('is_recur', $this->_paymentProcessor)) {
$this->assign('is_recur_enabled', 1);
$vars = array_merge($vars, array('is_recur', 'frequency_interval', 'frequency_unit', 'installments'));
}
if (in_array('CiviPledge', $config->enableComponents) && CRM_Utils_Array::value('is_pledge', $this->_params) == 1) {
$this->assign('pledge_enabled', 1);
$vars = array_merge($vars, array('is_pledge', 'pledge_frequency_interval', 'pledge_frequency_unit', 'pledge_installments'));
}
if (isset($this->_params['amount_other']) || isset($this->_params['selectMembership'])) {
$this->_params['amount_level'] = '';
}
foreach ($vars as $v) {
if (isset($this->_params[$v])) {
if ($v == 'frequency_unit' || $v == 'pledge_frequency_unit') {
$frequencyUnits = CRM_Core_OptionGroup::values('recur_frequency_units');
if (array_key_exists($this->_params[$v], $frequencyUnits)) {
$this->_params[$v] = $frequencyUnits[$this->_params[$v]];
}
}
if ($v == "amount" && $this->_params[$v] === 0) {
$this->_params[$v] = CRM_Utils_Money::format($this->_params[$v], NULL, NULL, TRUE);
}
$this->assign($v, $this->_params[$v]);
}
}
// assign the address formatted up for display
$addressParts = array("street_address-{$this->_bltID}", "city-{$this->_bltID}", "postal_code-{$this->_bltID}", "state_province-{$this->_bltID}", "country-{$this->_bltID}");
$addressFields = array();
foreach ($addressParts as $part) {
list($n, $id) = explode('-', $part);
$addressFields[$n] = CRM_Utils_Array::value('billing_' . $part, $this->_params);
}
$this->assign('address', CRM_Utils_Address::format($addressFields));
if (CRM_Utils_Array::value('hidden_onbehalf_profile', $this->_params)) {
$this->assign('onBehalfName', $this->_params['organization_name']);
$locTypeId = array_keys($this->_params['onbehalf_location']['email']);
$this->assign('onBehalfEmail', $this->_params['onbehalf_location']['email'][$locTypeId[0]]['email']);
}
//fix for CRM-3767
$assignCCInfo = FALSE;
if ($this->_amount > 0.0) {
$assignCCInfo = TRUE;
} elseif (CRM_Utils_array::value('selectMembership', $this->_params)) {
$memFee = CRM_Core_DAO::getFieldValue('CRM_Member_DAO_MembershipType', $this->_params['selectMembership'], 'minimum_fee');
if ($memFee > 0.0) {
$assignCCInfo = TRUE;
}
}
if ($this->_contributeMode == 'direct' && $assignCCInfo) {
if ($this->_paymentProcessor && $this->_paymentProcessor['payment_type'] & CRM_Core_Payment::PAYMENT_TYPE_DIRECT_DEBIT) {
$this->assign('payment_type', $this->_paymentProcessor['payment_type']);
$this->assign('account_holder', $this->_params['account_holder']);
$this->assign('bank_identification_number', $this->_params['bank_identification_number']);
$this->assign('bank_name', $this->_params['bank_name']);
$this->assign('bank_account_number', $this->_params['bank_account_number']);
} else {
$date = CRM_Utils_Date::format(CRM_Utils_array::value('credit_card_exp_date', $this->_params));
$date = CRM_Utils_Date::mysqlToIso($date);
$this->assign('credit_card_exp_date', $date);
$this->assign('credit_card_number', CRM_Utils_System::mungeCreditCard(CRM_Utils_array::value('credit_card_number', $this->_params)));
}
}
$this->assign('email', $this->controller->exportValue('Main', "email-{$this->_bltID}"));
// also assign the receipt_text
if (isset($this->_values['receipt_text'])) {
$this->assign('receipt_text', $this->_values['receipt_text']);
}
}
示例2: sendMail
/**
* Process that send e-mails
*
* @param $contactID
* @param $values
* @param $participantId
* @param bool $isTest
* @param bool $returnMessageText
*
* @return void
* @access public
*/
static function sendMail($contactID, &$values, $participantId, $isTest = FALSE, $returnMessageText = FALSE)
{
$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 => $gIdValues) {
if ($gIdValues) {
if (!is_array($gIdValues)) {
$gIdValues = array($gIdValues);
}
foreach ($gIdValues as $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);
list($profileValues) = $profileValues;
$val = array('id' => $gId, 'values' => $profileValues, 'email' => $email);
CRM_Core_BAO_UFGroup::commonSendMail($contactID, $val);
}
}
}
}
}
if ($values['event']['is_email_confirm'] || $returnMessageText) {
list($displayName, $email) = CRM_Contact_BAO_Contact_Location::getEmailDetails($contactID);
//send email only when email is present
if (isset($email) || $returnMessageText) {
$preProfileID = CRM_Utils_Array::value('custom_pre_id', $values);
$postProfileID = CRM_Utils_Array::value('custom_post_id', $values);
if (!empty($values['params']['additionalParticipant'])) {
$preProfileID = CRM_Utils_Array::value('additional_custom_pre_id', $values, $preProfileID);
$postProfileID = CRM_Utils_Array::value('additional_custom_post_id', $values, $postProfileID);
}
self::buildCustomDisplay($preProfileID, 'customPre', $contactID, $template, $participantId, $isTest, NULL, $participantParams);
self::buildCustomDisplay($postProfileID, 'customPost', $contactID, $template, $participantId, $isTest, NULL, $participantParams);
$sessions = CRM_Event_Cart_BAO_Conference::get_participant_sessions($participantId);
$tplParams = array_merge($values, $participantParams, 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']), 'contributeMode' => CRM_Utils_Array::value('contributeMode', $template->_tpl_vars), 'participantID' => $participantId, 'conference_sessions' => $sessions, 'credit_card_number' => CRM_Utils_System::mungeCreditCard(CRM_Utils_Array::value('credit_card_number', $participantParams)), 'credit_card_exp_date' => CRM_Utils_Date::mysqlToIso(CRM_Utils_Date::format(CRM_Utils_Array::value('credit_card_exp_date', $participantParams)))));
// CRM-13890 : NOTE wait list condition need to be given so that
// wait list message is shown properly in email i.e. WRT online event registration template
if (empty($tplParams['participant_status']) && empty($values['params']['isOnWaitlist'])) {
$statusId = CRM_Core_DAO::getFieldValue('CRM_Event_DAO_Participant', $participantId, 'status_id', 'id');
$tplParams['participant_status'] = CRM_Event_PseudoConstant::participantStatus($statusId, NULL, 'label');
}
$sendTemplateParams = array('groupName' => 'msg_tpl_workflow_event', 'valueName' => 'event_online_receipt', 'contactId' => $contactID, 'isTest' => $isTest, 'tplParams' => $tplParams, 'PDFFilename' => ts('confirmation') . '.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)) {
// check if additional prticipant, if so filter only to relevant ones
// CRM-9902
if (!empty($values['params']['additionalParticipant'])) {
$ownLineItems = array();
foreach ($lineItem as $liKey => $liValue) {
$firstElement = array_pop($liValue);
if ($firstElement['entity_id'] == $participantId) {
$ownLineItems[0] = $lineItem[$liKey];
break;
}
}
if (!empty($ownLineItems)) {
$sendTemplateParams['tplParams']['lineItem'] = $ownLineItems;
}
} else {
$sendTemplateParams['tplParams']['lineItem'] = $lineItem;
}
}
if ($returnMessageText) {
list($sent, $subject, $message, $html) = CRM_Core_BAO_MessageTemplate::sendTemplate($sendTemplateParams);
return array('subject' => $subject, 'body' => $message, 'to' => $displayName, 'html' => $html);
} else {
$sendTemplateParams['from'] = CRM_Utils_Array::value('confirm_from_name', $values['event']) . " <" . CRM_Utils_Array::value('confirm_from_email', $values['event']) . ">";
$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_MessageTemplate::sendTemplate($sendTemplateParams);
}
}
}
}
示例3: postProcess
//.........這裏部分代碼省略.........
$this->assign('totalAmount', $contributionParams['total_amount']);
if (isset($contributionParams['partial_payment_total'])) {
// balance amount
$balanceAmount = $contributionParams['partial_payment_total'] - $contributionParams['partial_amount_pay'];
$this->assign('balanceAmount', $balanceAmount);
}
$this->assign('isPrimary', 1);
$this->assign('checkNumber', CRM_Utils_Array::value('check_number', $params));
}
if ($this->_mode) {
if (!empty($params['billing_first_name'])) {
$name = $params['billing_first_name'];
}
if (!empty($params['billing_middle_name'])) {
$name .= " {$params['billing_middle_name']}";
}
if (!empty($params['billing_last_name'])) {
$name .= " {$params['billing_last_name']}";
}
$this->assign('billingName', $name);
// assign the address formatted up for display
$addressParts = array("street_address-{$this->_bltID}", "city-{$this->_bltID}", "postal_code-{$this->_bltID}", "state_province-{$this->_bltID}", "country-{$this->_bltID}");
$addressFields = array();
foreach ($addressParts as $part) {
list($n, $id) = explode('-', $part);
if (isset($this->_params['billing_' . $part])) {
$addressFields[$n] = $this->_params['billing_' . $part];
}
}
$this->assign('address', CRM_Utils_Address::format($addressFields));
$date = CRM_Utils_Date::format($params['credit_card_exp_date']);
$date = CRM_Utils_Date::mysqlToIso($date);
$this->assign('credit_card_exp_date', $date);
$this->assign('credit_card_number', CRM_Utils_System::mungeCreditCard($params['credit_card_number']));
$this->assign('credit_card_type', $params['credit_card_type']);
// The concept of contributeMode is deprecated.
$this->assign('contributeMode', 'direct');
$this->assign('isAmountzero', 0);
$this->assign('is_pay_later', 0);
$this->assign('isPrimary', 1);
}
$this->assign('register_date', $params['register_date']);
if ($params['receive_date']) {
$this->assign('receive_date', $params['receive_date']);
}
$participant = array(array('participant_id', '=', $participants[0]->id, 0, 0));
// check whether its a test drive ref CRM-3075
if (!empty($this->_defaultValues['is_test'])) {
$participant[] = array('participant_test', '=', 1, 0, 0);
}
$template = CRM_Core_Smarty::singleton();
$customGroup = array();
//format submitted data
foreach ($params['custom'] as $fieldID => $values) {
foreach ($values as $fieldValue) {
$customFields[$fieldID]['id'] = $fieldID;
$formattedValue = CRM_Core_BAO_CustomField::displayValue($fieldValue['value'], $fieldID, $participants[0]->id);
$customGroup[$customFields[$fieldID]['groupTitle']][$customFields[$fieldID]['label']] = str_replace(' ', '', $formattedValue);
}
}
foreach ($this->_contactIds as $num => $contactID) {
// Retrieve the name and email of the contact - this will be the TO for receipt email
list($this->_contributorDisplayName, $this->_contributorEmail, $this->_toDoNotEmail) = CRM_Contact_BAO_Contact::getContactDetails($contactID);
$this->_contributorDisplayName = $this->_contributorDisplayName == ' ' ? $this->_contributorEmail : $this->_contributorDisplayName;
$waitStatus = CRM_Event_PseudoConstant::participantStatus(NULL, "class = 'Waiting'");
if ($waitingStatus = CRM_Utils_Array::value($params['status_id'], $waitStatus)) {
示例4: processCreditCard
/**
* @param $submittedValues
*/
public function processCreditCard($submittedValues)
{
$config = CRM_Core_Config::singleton();
$session = CRM_Core_Session::singleton();
$unsetParams = array('trxn_id', 'payment_instrument_id', 'contribution_status_id');
foreach ($unsetParams as $key) {
if (isset($submittedValues[$key])) {
unset($submittedValues[$key]);
}
}
// Get the required fields value only.
$params = $this->_params = $submittedValues;
//get the payment processor id as per mode.
//@todo unclear relevance of mode - seems like a lot of duplicated params here!
$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->_contributorEmail;
// now set the values for the billing location.
foreach ($this->_fields as $name => $dontCare) {
$fields[$name] = 1;
}
// also add location name to the array
$params["address_name-{$this->_bltID}"] = CRM_Utils_Array::value('billing_first_name', $params) . ' ' . CRM_Utils_Array::value('billing_middle_name', $params) . ' ' . CRM_Utils_Array::value('billing_last_name', $params);
$params["address_name-{$this->_bltID}"] = trim($params["address_name-{$this->_bltID}"]);
$fields["address_name-{$this->_bltID}"] = 1;
$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.
$this->_params["state_province-{$this->_bltID}"] = $this->_params["billing_state_province-{$this->_bltID}"] = CRM_Core_PseudoConstant::stateProvinceAbbreviation($this->_params["billing_state_province_id-{$this->_bltID}"]);
$this->_params["country-{$this->_bltID}"] = $this->_params["billing_country-{$this->_bltID}"] = CRM_Core_PseudoConstant::countryIsoCode($this->_params["billing_country_id-{$this->_bltID}"]);
if ($this->_paymentProcessor['payment_type'] & CRM_Core_Payment::PAYMENT_TYPE_CREDIT_CARD) {
$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'];
// @todo - stop setting amount level in this function & call the CRM_Price_BAO_PriceSet::getAmountLevel
// function to get correct amount level consistently. Remove setting of the amount level in
// CRM_Price_BAO_PriceSet::processAmount. Extend the unit tests in CRM_Price_BAO_PriceSetTest
// to cover all variants.
$this->_params['amount_level'] = 0;
$this->_params['currencyID'] = CRM_Utils_Array::value('currency', $this->_params, $config->defaultCurrency);
if (!empty($this->_params['trxn_date'])) {
$this->_params['receive_date'] = CRM_Utils_Date::processDate($this->_params['trxn_date'], $this->_params['trxn_date_time']);
}
if (empty($this->_params['invoice_id'])) {
$this->_params['invoiceID'] = md5(uniqid(rand(), TRUE));
} else {
$this->_params['invoiceID'] = $this->_params['invoice_id'];
}
$this->assignBillingName($params);
$this->assign('address', CRM_Utils_Address::getFormattedBillingAddressFieldsFromParameters($params, $this->_bltID));
$date = CRM_Utils_Date::format($params['credit_card_exp_date']);
$date = CRM_Utils_Date::mysqlToIso($date);
$this->assign('credit_card_type', CRM_Utils_Array::value('credit_card_type', $params));
$this->assign('credit_card_exp_date', $date);
$this->assign('credit_card_number', CRM_Utils_System::mungeCreditCard($params['credit_card_number']));
//Add common data to formatted params
CRM_Contribute_Form_AdditionalInfo::postProcessCommon($params, $this->_params, $this);
// 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;
$paymentParams['contactID'] = $this->_contactId;
CRM_Core_Payment_Form::mapParams($this->_bltID, $this->_params, $paymentParams, TRUE);
// add some financial type details to the params list
// if folks need to use it
$paymentParams['contributionType_name'] = $this->_params['contributionType_name'] = $contributionType->name;
$paymentParams['contributionPageID'] = NULL;
if (!empty($this->_params['is_email_receipt'])) {
$paymentParams['email'] = $this->_contributorEmail;
$paymentParams['is_email_receipt'] = 1;
} else {
$paymentParams['is_email_receipt'] = 0;
$this->_params['is_email_receipt'] = 0;
}
if (!empty($this->_params['receive_date'])) {
$paymentParams['receive_date'] = $this->_params['receive_date'];
//.........這裏部分代碼省略.........
示例5: postProcess
//.........這裏部分代碼省略.........
$paymentInstrument = CRM_Contribute_PseudoConstant::paymentInstrument();
if (!$this->_mode) {
$this->assign('paidBy', CRM_Utils_Array::value($params['payment_instrument_id'], $paymentInstrument));
}
$this->assign('totalAmount', $contributionParams['total_amount']);
$this->assign('isPrimary', 1);
$this->assign('checkNumber', CRM_Utils_Array::value('check_number', $params));
}
if ($this->_mode) {
if (CRM_Utils_Array::value('billing_first_name', $params)) {
$name = $params['billing_first_name'];
}
if (CRM_Utils_Array::value('billing_middle_name', $params)) {
$name .= " {$params['billing_middle_name']}";
}
if (CRM_Utils_Array::value('billing_last_name', $params)) {
$name .= " {$params['billing_last_name']}";
}
$this->assign('billingName', $name);
// assign the address formatted up for display
$addressParts = array("street_address-{$this->_bltID}", "city-{$this->_bltID}", "postal_code-{$this->_bltID}", "state_province-{$this->_bltID}", "country-{$this->_bltID}");
$addressFields = array();
foreach ($addressParts as $part) {
list($n, $id) = explode('-', $part);
if (isset($this->_params['billing_' . $part])) {
$addressFields[$n] = $this->_params['billing_' . $part];
}
}
require_once 'CRM/Utils/Address.php';
$this->assign('address', CRM_Utils_Address::format($addressFields));
$date = CRM_Utils_Date::format($params['credit_card_exp_date']);
$date = CRM_Utils_Date::mysqlToIso($date);
$this->assign('credit_card_exp_date', $date);
$this->assign('credit_card_number', CRM_Utils_System::mungeCreditCard($params['credit_card_number']));
$this->assign('credit_card_type', $params['credit_card_type']);
$this->assign('contributeMode', 'direct');
$this->assign('isAmountzero', 0);
$this->assign('is_pay_later', 0);
$this->assign('isPrimary', 1);
}
$this->assign('register_date', $params['register_date']);
if ($params['receive_date']) {
$this->assign('receive_date', $params['receive_date']);
}
$participant = array(array('participant_id', '=', $participants[0]->id, 0, 0));
// check whether its a test drive ref CRM-3075
if (CRM_Utils_Array::value('is_test', $this->_defaultValues)) {
$participant[] = array('participant_test', '=', 1, 0, 0);
}
$template =& CRM_Core_Smarty::singleton();
$customGroup = array();
//format submitted data
foreach ($params['custom'] as $fieldID => $values) {
foreach ($values as $fieldValue) {
$customValue = array('data' => $fieldValue['value']);
$customFields[$fieldID]['id'] = $fieldID;
$formattedValue = CRM_Core_BAO_CustomGroup::formatCustomValues($customValue, $customFields[$fieldID]);
$customGroup[$customFields[$fieldID]['groupTitle']][$customFields[$fieldID]['label']] = str_replace(' ', '', $formattedValue);
}
}
foreach ($this->_contactIds as $num => $contactID) {
// Retrieve the name and email of the contact - this will be the TO for receipt email
list($this->_contributorDisplayName, $this->_contributorEmail, $this->_toDoNotEmail) = CRM_Contact_BAO_Contact::getContactDetails($contactID);
$this->_contributorDisplayName = $this->_contributorDisplayName == ' ' ? $this->_contributorEmail : $this->_contributorDisplayName;
$this->assign('customGroup', $customGroup);
$this->assign('contactID', $contactID);
示例6: postProcess
//.........這裏部分代碼省略.........
// retrieve custom data
require_once "CRM/Core/BAO/UFGroup.php";
$customFields = $customValues = array();
foreach ($this->_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 ($this->_mode) {
$members[] = array('member_test', '=', 1, 0, 0);
}
CRM_Core_BAO_UFGroup::getValues($this->_contactID, $customFields, $customValues, false, $members);
if ($this->_mode) {
if (CRM_Utils_Array::value('billing_first_name', $this->_params)) {
$name = $this->_params['billing_first_name'];
}
if (CRM_Utils_Array::value('billing_middle_name', $this->_params)) {
$name .= " {$this->_params['billing_middle_name']}";
}
if (CRM_Utils_Array::value('billing_last_name', $this->_params)) {
$name .= " {$this->_params['billing_last_name']}";
}
$this->assign('billingName', $name);
// assign the address formatted up for display
$addressParts = array("street_address-{$this->_bltID}", "city-{$this->_bltID}", "postal_code-{$this->_bltID}", "state_province-{$this->_bltID}", "country-{$this->_bltID}");
$addressFields = array();
foreach ($addressParts as $part) {
list($n, $id) = explode('-', $part);
if (isset($this->_params['billing_' . $part])) {
$addressFields[$n] = $this->_params['billing_' . $part];
}
}
require_once 'CRM/Utils/Address.php';
$this->assign('address', CRM_Utils_Address::format($addressFields));
$date = CRM_Utils_Date::format($this->_params['credit_card_exp_date']);
$date = CRM_Utils_Date::mysqlToIso($date);
$this->assign('credit_card_exp_date', $date);
$this->assign('credit_card_number', CRM_Utils_System::mungeCreditCard($this->_params['credit_card_number']));
$this->assign('credit_card_type', $this->_params['credit_card_type']);
$this->assign('contributeMode', 'direct');
$this->assign('isAmountzero', 0);
$this->assign('is_pay_later', 0);
$this->assign('isPrimary', 1);
}
$this->assign('module', 'Membership');
$this->assign('contactID', $this->_contactID);
$this->assign('membershipID', $params['membership_id']);
$this->assign('receiptType', 'membership signup');
$this->assign('receive_date', $params['receive_date']);
$this->assign('formValues', $formValues);
$this->assign('mem_start_date', CRM_Utils_Date::customFormat($calcDates['start_date']));
$this->assign('mem_end_date', CRM_Utils_Date::customFormat($calcDates['end_date']));
$this->assign('membership_name', CRM_Core_DAO::getFieldValue('CRM_Member_DAO_MembershipType', $formValues['membership_type_id'][1]));
$this->assign('customValues', $customValues);
require_once 'CRM/Core/BAO/MessageTemplates.php';
list($mailSend, $subject, $message, $html) = CRM_Core_BAO_MessageTemplates::sendTemplate(array('groupName' => 'msg_tpl_workflow_contribution', 'valueName' => 'contribution_offline_receipt', 'contactId' => $this->_contactID, 'from' => $receiptFrom, 'toName' => $this->_contributorDisplayName, 'toEmail' => $this->_contributorEmail, 'isTest' => (bool) ($this->_action & CRM_Core_Action::PREVIEW)));
}
if ($this->_action & CRM_Core_Action::UPDATE) {
$statusMsg = ts('Membership for %1 has been updated.', array(1 => $this->_contributorDisplayName));
if ($endDate) {
$endDate = CRM_Utils_Date::customFormat($endDate);
$statusMsg .= ' ' . ts('The membership End Date is %1.', array(1 => $endDate));
}
if ($receiptSend) {
$statusMsg .= ' ' . ts('A confirmation and receipt has been sent to %1.', array(1 => $this->_contributorEmail));
}
} elseif ($this->_action & CRM_Core_Action::ADD) {
require_once 'CRM/Core/DAO.php';
$memType = CRM_Core_DAO::getFieldValue('CRM_Member_DAO_MembershipType', $params['membership_type_id']);
$statusMsg = ts('%1 membership for %2 has been added.', array(1 => $memType, 2 => $this->_contributorDisplayName));
//get the end date from calculated dates.
$endDate = $endDate ? $endDate : CRM_Utils_Array::value('end_date', $calcDates);
if ($endDate) {
$endDate = CRM_Utils_Date::customFormat($endDate);
$statusMsg .= ' ' . ts('The new membership End Date is %1.', array(1 => $endDate));
}
if ($receiptSend && $mailSend) {
$statusMsg .= ' ' . ts('A membership confirmation and receipt has been sent to %1.', array(1 => $this->_contributorEmail));
}
}
CRM_Core_Session::setStatus($statusMsg);
$buttonName = $this->controller->getButtonName();
if ($this->_context == 'standalone') {
if ($buttonName == $this->getButtonName('upload', 'new')) {
$session->replaceUserContext(CRM_Utils_System::url('civicrm/member/add', 'reset=1&action=add&context=standalone'));
} else {
$session->replaceUserContext(CRM_Utils_System::url('civicrm/contact/view', "reset=1&cid={$this->_contactID}&selectedChild=member"));
}
} else {
if ($buttonName == $this->getButtonName('upload', 'new')) {
$session->replaceUserContext(CRM_Utils_System::url('civicrm/contact/view/membership', "reset=1&action=add&context=membership&cid={$this->_contactID}"));
}
}
}
示例7: submit
/**
* Process form submission.
*
* This function is also accessed by a unit test.
*/
protected function submit()
{
$this->storeContactFields($this->_params);
$now = CRM_Utils_Date::getToday(NULL, 'YmdHis');
$this->convertDateFieldsToMySQL($this->_params);
$this->assign('receive_date', $this->_params['receive_date']);
$this->processBillingAddress($now);
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');
}
$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->_paymentProcessor = CRM_Financial_BAO_PaymentProcessor::getPayment($this->_params['payment_processor_id']);
$this->_params['year'] = CRM_Core_Payment_Form::getCreditCardExpirationYear($this->_params);
$this->_params['month'] = CRM_Core_Payment_Form::getCreditCardExpirationMonth($this->_params);
$this->assign('credit_card_exp_date', CRM_Utils_Date::mysqlToIso(CRM_Utils_Date::format($this->_params['credit_card_exp_date'])));
$this->assign('credit_card_number', CRM_Utils_System::mungeCreditCard($this->_params['credit_card_number']));
$this->assign('credit_card_type', $this->_params['credit_card_type']);
$this->_params['description'] = ts("Contribution submitted by a staff person using member's credit card for renewal");
$this->_params['ip_address'] = CRM_Utils_System::ipAddress();
$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);
$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.
$contributionRecurID = isset($this->_params['contributionRecurID']) ? $this->_params['contributionRecurID'] : NULL;
$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();
$priceSetId = CRM_Member_BAO_Membership::createLineItems($this, $this->_params['membership_type_id']);
CRM_Price_BAO_PriceSet::processAmount($this->_priceSet['fields'], $this->_params, $lineItem[$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)) {
//.........這裏部分代碼省略.........
示例8: beginPostProcess
/**
* Begin post processing.
*
* This function aims to start to bring together common postProcessing functions.
*
* Eventually these are also shared with the front end forms & may need to be moved to where they can also
* access this function.
*/
protected function beginPostProcess()
{
if ($this->_mode) {
$this->_paymentProcessor = CRM_Financial_BAO_PaymentProcessor::getPayment($this->_params['payment_processor_id'], $this->_mode == 'test');
if (in_array('credit_card_exp_date', array_keys($this->_params))) {
$this->_params['year'] = CRM_Core_Payment_Form::getCreditCardExpirationYear($this->_params);
$this->_params['month'] = CRM_Core_Payment_Form::getCreditCardExpirationMonth($this->_params);
}
$this->assign('credit_card_exp_date', CRM_Utils_Date::mysqlToIso(CRM_Utils_Date::format($this->_params['credit_card_exp_date'])));
$this->assign('credit_card_number', CRM_Utils_System::mungeCreditCard($this->_params['credit_card_number']));
$this->assign('credit_card_type', CRM_Utils_Array::value('credit_card_type', $this->_params));
}
$this->_params['ip_address'] = CRM_Utils_System::ipAddress();
}
示例9: emailReceipt
/**
* Send email receipt.
*
* @param CRM_Core_Form $form
* instance of Contribution form.
* @param array $params
* (reference ) an assoc array of name/value pairs.
* @param bool $ccContribution
* is it credit card contribution.
*
* @return array
*/
public static function emailReceipt(&$form, &$params, $ccContribution = FALSE)
{
$form->assign('receiptType', 'contribution');
// Retrieve Financial Type Name from financial_type_id
$params['contributionType_name'] = CRM_Core_DAO::getFieldValue('CRM_Financial_DAO_FinancialType', $params['financial_type_id']);
if (!empty($params['payment_instrument_id'])) {
$paymentInstrument = CRM_Contribute_PseudoConstant::paymentInstrument();
$params['paidBy'] = $paymentInstrument[$params['payment_instrument_id']];
if ($params['paidBy'] != 'Check' && isset($params['check_number'])) {
unset($params['check_number']);
}
}
// retrieve individual prefix value for honoree
if (isset($params['soft_credit'])) {
$softCreditTypes = $softCredits = array();
foreach ($params['soft_credit'] as $key => $softCredit) {
$softCredits[$key] = array('Name' => $softCredit['contact_name'], 'Amount' => CRM_Utils_Money::format($softCredit['amount'], $softCredit['currency']));
$softCreditTypes[$key] = $softCredit['soft_credit_type_label'];
}
$form->assign('softCreditTypes', $softCreditTypes);
$form->assign('softCredits', $softCredits);
}
// retrieve premium product name and assigned fulfilled
// date to template
if (!empty($params['hidden_Premium'])) {
if (isset($params['product_name']) && is_array($params['product_name']) && !empty($params['product_name'])) {
$productDAO = new CRM_Contribute_DAO_Product();
$productDAO->id = $params['product_name'][0];
$productOptionID = $params['product_name'][1];
$productDAO->find(TRUE);
$params['product_name'] = $productDAO->name;
$params['product_sku'] = $productDAO->sku;
if (empty($params['product_option']) && !empty($form->_options[$productDAO->id])) {
$params['product_option'] = $form->_options[$productDAO->id][$productOptionID];
}
}
if (!empty($params['fulfilled_date'])) {
$form->assign('fulfilled_date', CRM_Utils_Date::processDate($params['fulfilled_date']));
}
}
$form->assign('ccContribution', $ccContribution);
if ($ccContribution) {
//build the name.
$name = CRM_Utils_Array::value('billing_first_name', $params);
if (!empty($params['billing_middle_name'])) {
$name .= " {$params['billing_middle_name']}";
}
$name .= ' ' . CRM_Utils_Array::value('billing_last_name', $params);
$name = trim($name);
$form->assign('billingName', $name);
//assign the address formatted up for display
$addressParts = array("street_address" => "billing_street_address-{$form->_bltID}", "city" => "billing_city-{$form->_bltID}", "postal_code" => "billing_postal_code-{$form->_bltID}", "state_province" => "state_province-{$form->_bltID}", "country" => "country-{$form->_bltID}");
$addressFields = array();
foreach ($addressParts as $name => $field) {
$addressFields[$name] = CRM_Utils_Array::value($field, $params);
}
$form->assign('address', CRM_Utils_Address::format($addressFields));
$date = CRM_Utils_Date::format($params['credit_card_exp_date']);
$date = CRM_Utils_Date::mysqlToIso($date);
$form->assign('credit_card_type', CRM_Utils_Array::value('credit_card_type', $params));
$form->assign('credit_card_exp_date', $date);
$form->assign('credit_card_number', CRM_Utils_System::mungeCreditCard($params['credit_card_number']));
} else {
//offline contribution
// assigned various dates to the templates
$form->assign('receipt_date', CRM_Utils_Date::processDate($params['receipt_date']));
if (!empty($params['cancel_date'])) {
$form->assign('cancel_date', CRM_Utils_Date::processDate($params['cancel_date']));
}
if (!empty($params['thankyou_date'])) {
$form->assign('thankyou_date', CRM_Utils_Date::processDate($params['thankyou_date']));
}
if ($form->_action & CRM_Core_Action::UPDATE) {
$form->assign('lineItem', empty($form->_lineItems) ? FALSE : $form->_lineItems);
}
}
//handle custom data
if (!empty($params['hidden_custom'])) {
$contribParams = array(array('contribution_id', '=', $params['contribution_id'], 0, 0));
if ($form->_mode == 'test') {
$contribParams[] = array('contribution_test', '=', 1, 0, 0);
}
//retrieve custom data
$customGroup = array();
foreach ($form->_groupTree as $groupID => $group) {
$customFields = $customValues = array();
if ($groupID == 'info') {
continue;
//.........這裏部分代碼省略.........
示例10: assignToTemplate
/**
* Assign the minimal set of variables to the template.
*/
public function assignToTemplate()
{
$name = CRM_Utils_Array::value('billing_first_name', $this->_params);
if (!empty($this->_params['billing_middle_name'])) {
$name .= " {$this->_params['billing_middle_name']}";
}
$name .= ' ' . CRM_Utils_Array::value('billing_last_name', $this->_params);
$name = trim($name);
$this->assign('billingName', $name);
$this->set('name', $name);
$this->assign('paymentProcessor', $this->_paymentProcessor);
$vars = array('amount', 'currencyID', 'credit_card_type', 'trxn_id', 'amount_level');
$config = CRM_Core_Config::singleton();
if (isset($this->_values['is_recur']) && !empty($this->_paymentProcessor['is_recur'])) {
$this->assign('is_recur_enabled', 1);
$vars = array_merge($vars, array('is_recur', 'frequency_interval', 'frequency_unit', 'installments'));
}
if (in_array('CiviPledge', $config->enableComponents) && CRM_Utils_Array::value('is_pledge', $this->_params) == 1) {
$this->assign('pledge_enabled', 1);
$vars = array_merge($vars, array('is_pledge', 'pledge_frequency_interval', 'pledge_frequency_unit', 'pledge_installments'));
}
// @todo - stop setting amount level in this function & call the CRM_Price_BAO_PriceSet::getAmountLevel
// function to get correct amount level consistently. Remove setting of the amount level in
// CRM_Price_BAO_PriceSet::processAmount. Extend the unit tests in CRM_Price_BAO_PriceSetTest
// to cover all variants.
if (isset($this->_params['amount_other']) || isset($this->_params['selectMembership'])) {
$this->_params['amount_level'] = '';
}
foreach ($vars as $v) {
if (isset($this->_params[$v])) {
if ($v == "amount" && $this->_params[$v] === 0) {
$this->_params[$v] = CRM_Utils_Money::format($this->_params[$v], NULL, NULL, TRUE);
}
$this->assign($v, $this->_params[$v]);
}
}
// assign the address formatted up for display
$addressParts = array("street_address-{$this->_bltID}", "city-{$this->_bltID}", "postal_code-{$this->_bltID}", "state_province-{$this->_bltID}", "country-{$this->_bltID}");
$addressFields = array();
foreach ($addressParts as $part) {
list($n, $id) = explode('-', $part);
$addressFields[$n] = CRM_Utils_Array::value('billing_' . $part, $this->_params);
}
$this->assign('address', CRM_Utils_Address::format($addressFields));
if (!empty($this->_params['onbehalf_profile_id']) && !empty($this->_params['onbehalf'])) {
$this->assign('onBehalfName', $this->_params['organization_name']);
$locTypeId = array_keys($this->_params['onbehalf_location']['email']);
$this->assign('onBehalfEmail', $this->_params['onbehalf_location']['email'][$locTypeId[0]]['email']);
}
//fix for CRM-3767
$assignCCInfo = FALSE;
if ($this->_amount > 0.0) {
$assignCCInfo = TRUE;
} elseif (!empty($this->_params['selectMembership'])) {
$memFee = CRM_Core_DAO::getFieldValue('CRM_Member_DAO_MembershipType', $this->_params['selectMembership'], 'minimum_fee');
if ($memFee > 0.0) {
$assignCCInfo = TRUE;
}
}
// The concept of contributeMode is deprecated.
// The payment processor object can provide info about the fields it shows.
if ($this->_contributeMode == 'direct' && $assignCCInfo) {
if ($this->_paymentProcessor && $this->_paymentProcessor['payment_type'] & CRM_Core_Payment::PAYMENT_TYPE_DIRECT_DEBIT) {
$this->assign('account_holder', $this->_params['account_holder']);
$this->assign('bank_identification_number', $this->_params['bank_identification_number']);
$this->assign('bank_name', $this->_params['bank_name']);
$this->assign('bank_account_number', $this->_params['bank_account_number']);
} else {
$date = CRM_Utils_Date::format(CRM_Utils_array::value('credit_card_exp_date', $this->_params));
$date = CRM_Utils_Date::mysqlToIso($date);
$this->assign('credit_card_exp_date', $date);
$this->assign('credit_card_number', CRM_Utils_System::mungeCreditCard(CRM_Utils_array::value('credit_card_number', $this->_params)));
}
}
$this->assign('email', $this->controller->exportValue('Main', "email-{$this->_bltID}"));
// also assign the receipt_text
if (isset($this->_values['receipt_text'])) {
$this->assign('receipt_text', $this->_values['receipt_text']);
}
}
示例11: postProcess
//.........這裏部分代碼省略.........
$processorParams['subscriptionId'] = $this->_subscriptionDetails->subscription_id;
$processorParams['amount'] = $this->_subscriptionDetails->amount;
$updateSubscription = $this->_paymentProcessorObj->updateSubscriptionBillingInfo($message, $processorParams);
if (is_a($updateSubscription, 'CRM_Core_Error')) {
CRM_Core_Error::displaySessionError($updateSubscription);
} elseif ($updateSubscription) {
$ctype = CRM_Core_DAO::getFieldValue('CRM_Contact_DAO_Contact', $this->_subscriptionDetails->contact_id, 'contact_type');
$contact =& CRM_Contact_BAO_Contact::createProfileContact($params, $fields, $this->_subscriptionDetails->contact_id, NULL, NULL, $ctype);
// build tpl params
if ($this->_subscriptionDetails->membership_id) {
$inputParams = array('id' => $this->_subscriptionDetails->membership_id);
CRM_Member_BAO_Membership::getValues($inputParams, $tplParams);
$tplParams = $tplParams[$this->_subscriptionDetails->membership_id];
$tplParams['membership_status'] = CRM_Core_DAO::getFieldValue('CRM_Member_DAO_MembershipStatus', $tplParams['status_id']);
$tplParams['membershipType'] = CRM_Core_DAO::getFieldValue('CRM_Member_DAO_MembershipType', $tplParams['membership_type_id']);
$status = ts('Billing details for your automatically renewed %1 membership have been updated.', array(1 => $tplParams['membershipType']));
$msgTitle = ts('Details Updated');
$msgType = 'success';
} else {
$status = ts('Billing details for the recurring contribution of %1, every %2 %3 have been updated.', array(1 => $this->_subscriptionDetails->amount, 2 => $this->_subscriptionDetails->frequency_interval, 3 => $this->_subscriptionDetails->frequency_unit));
$msgTitle = ts('Details Updated');
$msgType = 'success';
$tplParams = array('recur_frequency_interval' => $this->_subscriptionDetails->frequency_interval, 'recur_frequency_unit' => $this->_subscriptionDetails->frequency_unit, 'amount' => $this->_subscriptionDetails->amount);
}
// format new address for display
$addressParts = array("street_address", "city", "postal_code", "state_province", "country");
foreach ($addressParts as $part) {
$addressParts[$part] = CRM_Utils_Array::value($part, $processorParams);
}
$tplParams['address'] = CRM_Utils_Address::format($addressParts);
// format old address to store in activity details
$this->_defaults["state_province-{$this->_bltID}"] = CRM_Core_PseudoConstant::stateProvince($this->_defaults["state_province-{$this->_bltID}"], FALSE);
$this->_defaults["country-{$this->_bltID}"] = CRM_Core_PseudoConstant::country($this->_defaults["country-{$this->_bltID}"], FALSE);
$addressParts = array("street_address", "city", "postal_code", "state_province", "country");
foreach ($addressParts as $part) {
$key = "{$part}-{$this->_bltID}";
$addressParts[$part] = CRM_Utils_Array::value($key, $this->_defaults);
}
$this->_defaults['address'] = CRM_Utils_Address::format($addressParts);
// format new billing name
$name = $processorParams['first_name'];
if (!empty($processorParams['middle_name'])) {
$name .= " {$processorParams['middle_name']}";
}
$name .= ' ' . $processorParams['last_name'];
$name = trim($name);
$tplParams['billingName'] = $name;
// format old billing name
$name = $this->_defaults['first_name'];
if (!empty($this->_defaults['middle_name'])) {
$name .= " {$this->_defaults['middle_name']}";
}
$name .= ' ' . $this->_defaults['last_name'];
$name = trim($name);
$this->_defaults['billingName'] = $name;
$message .= "\n<br/><br/>New Billing Name and Address\n<br/>==============================\n<br/>{$tplParams['billingName']}\n<br/>{$tplParams['address']}\n\n<br/><br/>Previous Billing Name and Address\n<br/>==================================\n<br/>{$this->_defaults['billingName']}\n<br/>{$this->_defaults['address']}";
$activityParams = array('source_contact_id' => $this->_subscriptionDetails->contact_id, 'activity_type_id' => CRM_Core_OptionGroup::getValue('activity_type', 'Update Recurring Contribution Billing Details', 'name'), 'subject' => ts('Recurring Contribution Billing Details Updated'), 'details' => $message, 'activity_date_time' => date('YmdHis'), 'status_id' => CRM_Core_OptionGroup::getValue('activity_status', 'Completed', 'name'));
$session = CRM_Core_Session::singleton();
$cid = $session->get('userID');
if ($cid) {
$activityParams['target_contact_id'][] = $activityParams['source_contact_id'];
$activityParams['source_contact_id'] = $cid;
}
CRM_Activity_BAO_Activity::create($activityParams);
// send notification
if ($this->_subscriptionDetails->contribution_page_id) {
CRM_Core_DAO::commonRetrieveAll('CRM_Contribute_DAO_ContributionPage', 'id', $this->_subscriptionDetails->contribution_page_id, $value, array('title', 'receipt_from_name', 'receipt_from_email'));
$receiptFrom = '"' . CRM_Utils_Array::value('receipt_from_name', $value[$this->_subscriptionDetails->contribution_page_id]) . '" <' . $value[$this->_subscriptionDetails->contribution_page_id]['receipt_from_email'] . '>';
} else {
$domainValues = CRM_Core_BAO_Domain::getNameAndEmail();
$receiptFrom = "{$domainValues['0']} <{$domainValues['1']}>";
}
list($donorDisplayName, $donorEmail) = CRM_Contact_BAO_Contact::getContactDetails($this->_subscriptionDetails->contact_id);
$tplParams['contact'] = array('display_name' => $donorDisplayName);
$date = CRM_Utils_Date::format($processorParams['credit_card_exp_date']);
$tplParams['credit_card_exp_date'] = CRM_Utils_Date::mysqlToIso($date);
$tplParams['credit_card_number'] = CRM_Utils_System::mungeCreditCard($processorParams['credit_card_number']);
$tplParams['credit_card_type'] = $processorParams['credit_card_type'];
$sendTemplateParams = array('groupName' => $this->_subscriptionDetails->membership_id ? 'msg_tpl_workflow_membership' : 'msg_tpl_workflow_contribution', 'valueName' => $this->_subscriptionDetails->membership_id ? 'membership_autorenew_billing' : 'contribution_recurring_billing', 'contactId' => $this->_subscriptionDetails->contact_id, 'tplParams' => $tplParams, 'isTest' => $this->_subscriptionDetails->is_test, 'PDFFilename' => 'receipt.pdf', 'from' => $receiptFrom, 'toName' => $donorDisplayName, 'toEmail' => $donorEmail);
list($sent) = CRM_Core_BAO_MessageTemplate::sendTemplate($sendTemplateParams);
} else {
$status = ts('There was some problem updating the billing details.');
$msgTitle = ts('Update Error');
$msgType = 'error';
}
$session = CRM_Core_Session::singleton();
$userID = $session->get('userID');
if ($userID && $status) {
$session->setStatus($status, $msgTitle, $msgType);
} elseif (!$userID) {
if ($status) {
CRM_Utils_System::setUFMessage($status);
}
$result = (int) ($updateSubscription && isset($ctype));
if (isset($tplParams)) {
$session->set('resultParams', $tplParams);
}
return CRM_Utils_System::redirect(CRM_Utils_System::url('civicrm/contribute/subscriptionstatus', "reset=1&task=billing&result={$result}"));
}
}
示例12: postProcess
//.........這裏部分代碼省略.........
$recordContribution = array('total_amount', 'contribution_type_id', 'payment_instrument_id', 'trxn_id', 'contribution_status_id', 'invoice_id', 'check_number', 'is_test');
foreach ($recordContribution as $f) {
$contributionParams[$f] = CRM_Utils_Array::value($f, $formValues);
}
require_once 'CRM/Contribute/BAO/Contribution.php';
$contribution =& CRM_Contribute_BAO_Contribution::create($contributionParams, $ids);
require_once 'CRM/Member/DAO/MembershipPayment.php';
$mpDAO =& new CRM_Member_DAO_MembershipPayment();
$mpDAO->membership_id = $renewMembership->id;
$mpDAO->contribution_id = $contribution->id;
$mpDAO->save();
if ($this->_mode) {
$trxnParams = array('contribution_id' => $contribution->id, 'trxn_date' => $now, 'trxn_type' => 'Debit', 'total_amount' => $formValues['total_amount'], 'fee_amount' => CRM_Utils_Array::value('fee_amount', $result), 'net_amount' => CRM_Utils_Array::value('net_amount', $result, $formValues['total_amount']), 'currency' => $config->defaultCurrency, 'payment_processor' => $this->_paymentProcessor['payment_processor_type'], 'trxn_id' => $result['trxn_id']);
require_once 'CRM/Contribute/BAO/FinancialTrxn.php';
$trxn =& CRM_Contribute_BAO_FinancialTrxn::create($trxnParams);
}
}
if (CRM_Utils_Array::value('send_receipt', $formValues)) {
require_once 'CRM/Core/DAO.php';
CRM_Core_DAO::setFieldValue('CRM_Member_DAO_MembershipType', CRM_Utils_Array::value('membership_type_id', $params), 'receipt_text_renewal', $formValues['receipt_text_renewal']);
}
$receiptSend = false;
if (CRM_Utils_Array::value('send_receipt', $formValues)) {
$receiptSend = true;
// Retrieve the name and email of the contact - this will be the TO for receipt email
list($this->_contributorDisplayName, $this->_contributorEmail) = CRM_Contact_BAO_Contact_Location::getEmailDetails($this->_contactID);
$receiptFrom = '"' . $userName . '" <' . $userEmail . '>';
$paymentInstrument = CRM_Contribute_PseudoConstant::paymentInstrument();
$formValues['paidBy'] = $paymentInstrument[$formValues['payment_instrument_id']];
//get the group Tree
$this->_groupTree =& CRM_Core_BAO_CustomGroup::getTree('Membership', $this, $this->_id, false, $this->_memType);
// retrieve custom data
require_once "CRM/Core/BAO/UFGroup.php";
$customFields = $customValues = $fo = array();
foreach ($this->_groupTree as $groupID => $group) {
if ($groupID == 'info') {
continue;
}
foreach ($group['fields'] as $k => $field) {
$field['title'] = $field['label'];
$customFields["custom_{$k}"] = $field;
}
}
CRM_Core_BAO_UFGroup::getValues($this->_contactID, $customFields, $customValues, false, array(array('member_id', '=', $renewMembership->id, 0, 0)));
$this->assign_by_ref('formValues', $formValues);
$this->assign('receive_date', $renewalDate);
$this->assign('module', 'Membership');
$this->assign('receiptType', 'membership renewal');
$this->assign('mem_start_date', CRM_Utils_Date::customFormat($renewMembership->start_date));
$this->assign('mem_end_date', CRM_Utils_Date::customFormat($renewMembership->end_date));
$this->assign('membership_name', CRM_Core_DAO::getFieldValue('CRM_Member_DAO_MembershipType', $renewMembership->membership_type_id));
$this->assign('customValues', $customValues);
if ($this->_mode) {
if (CRM_Utils_Array::value('billing_first_name', $this->_params)) {
$name = $this->_params['billing_first_name'];
}
if (CRM_Utils_Array::value('billing_middle_name', $this->_params)) {
$name .= " {$this->_params['billing_middle_name']}";
}
if (CRM_Utils_Array::value('billing_last_name', $this->_params)) {
$name .= " {$this->_params['billing_last_name']}";
}
$this->assign('billingName', $name);
// assign the address formatted up for display
$addressParts = array("street_address-{$this->_bltID}", "city-{$this->_bltID}", "postal_code-{$this->_bltID}", "state_province-{$this->_bltID}", "country-{$this->_bltID}");
$addressFields = array();
foreach ($addressParts as $part) {
list($n, $id) = explode('-', $part);
if (isset($this->_params['billing_' . $part])) {
$addressFields[$n] = $this->_params['billing_' . $part];
}
}
require_once 'CRM/Utils/Address.php';
$this->assign('address', CRM_Utils_Address::format($addressFields));
$date = CRM_Utils_Date::format($this->_params['credit_card_exp_date']);
$date = CRM_Utils_Date::mysqlToIso($date);
$this->assign('credit_card_exp_date', $date);
$this->assign('credit_card_number', CRM_Utils_System::mungeCreditCard($this->_params['credit_card_number']));
$this->assign('credit_card_type', $this->_params['credit_card_type']);
$this->assign('contributeMode', 'direct');
$this->assign('isAmountzero', 0);
$this->assign('is_pay_later', 0);
$this->assign('isPrimary', 1);
if ($this->_mode == 'test') {
$this->assign('action', '1024');
}
}
require_once 'CRM/Core/BAO/MessageTemplates.php';
list($mailSend, $subject, $message, $html) = CRM_Core_BAO_MessageTemplates::sendTemplate(array('groupName' => 'msg_tpl_workflow_membership', 'valueName' => 'membership_offline_receipt', 'contactId' => $this->_contactID, 'from' => $receiptFrom, 'toName' => $this->_contributorDisplayName, 'toEmail' => $this->_contributorEmail, 'isTest' => $this->_mode == 'test'));
}
$statusMsg = ts('%1 membership for %2 has been renewed.', array(1 => $memType, 2 => $this->_contributorDisplayName));
$endDate = CRM_Utils_Date::customFormat(CRM_Core_DAO::getFieldValue("CRM_Member_DAO_Membership", $this->_id, "end_date"));
if ($endDate) {
$statusMsg .= ' ' . ts('The new membership End Date is %1.', array(1 => $endDate));
}
if ($receiptSend && $mailSend) {
$statusMsg .= ' ' . ts('A renewal confirmation and receipt has been sent to %1.', array(1 => $this->_contributorEmail));
}
CRM_Core_Session::setStatus($statusMsg);
}
示例13: emailReceipt
/**
* Function to send email receipt.
*
* @form object of Contribution form.
* @param array $params (reference ) an assoc array of name/value pairs.
* @$ccContribution boolen, is it credit card contribution.
* @access public.
* @return None.
*/
function emailReceipt(&$form, &$params, $ccContribution = false)
{
$this->assign('receiptType', 'contribution');
// Retrieve Contribution Type Name from contribution_type_id
$params['contributionType_name'] = CRM_Core_DAO::getFieldValue('CRM_Contribute_DAO_ContributionType', $params['contribution_type_id']);
if (CRM_Utils_Array::value('payment_instrument_id', $params)) {
require_once 'CRM/Contribute/PseudoConstant.php';
$paymentInstrument = CRM_Contribute_PseudoConstant::paymentInstrument();
$params['paidBy'] = $paymentInstrument[$params['payment_instrument_id']];
}
// retrieve individual prefix value for honoree
if (CRM_Utils_Array::value('hidden_Honoree', $params)) {
$individualPrefix = CRM_Core_PseudoConstant::individualPrefix();
$honor = CRM_Core_PseudoConstant::honor();
$params['honor_prefix'] = CRM_Utils_Array::value($params['honor_prefix_id'], $individualPrefix);
$params["honor_type"] = CRM_Utils_Array::value($params["honor_type_id"], $honor);
}
// retrieve premium product name and assigned fulfilled
// date to template
if (CRM_Utils_Array::value('hidden_Premium', $params)) {
if (CRM_Utils_Array::value($params['product_name'][0], $form->_options)) {
$params['product_option'] = $form->_options[$params['product_name'][0]][$params['product_name'][1]];
}
//fix for crm-4584
if (!empty($params['product_name'])) {
require_once 'CRM/Contribute/DAO/Product.php';
$productDAO = new CRM_Contribute_DAO_Product();
$productDAO->id = $params['product_name'][0];
$productDAO->find(true);
$params['product_name'] = $productDAO->name;
$params['product_sku'] = $productDAO->sku;
}
$this->assign('fulfilled_date', CRM_Utils_Date::processDate($params['fulfilled_date']));
}
$this->assign('ccContribution', $ccContribution);
if ($ccContribution) {
//build the name.
$name = CRM_Utils_Array::value('billing_first_name', $params);
if (CRM_Utils_Array::value('billing_middle_name', $params)) {
$name .= " {$params['billing_middle_name']}";
}
$name .= ' ' . CRM_Utils_Array::value('billing_last_name', $params);
$name = trim($name);
$this->assign('billingName', $name);
//assign the address formatted up for display
$addressParts = array("street_address" => "billing_street_address-{$form->_bltID}", "city" => "billing_city-{$form->_bltID}", "postal_code" => "billing_postal_code-{$form->_bltID}", "state_province" => "state_province-{$form->_bltID}", "country" => "country-{$form->_bltID}");
$addressFields = array();
foreach ($addressParts as $name => $field) {
$addressFields[$name] = CRM_Utils_Array::value($field, $params);
}
require_once 'CRM/Utils/Address.php';
$this->assign('address', CRM_Utils_Address::format($addressFields));
$date = CRM_Utils_Date::format($params['credit_card_exp_date']);
$date = CRM_Utils_Date::mysqlToIso($date);
$this->assign('credit_card_type', CRM_Utils_Array::value('credit_card_type', $params));
$this->assign('credit_card_exp_date', $date);
$this->assign('credit_card_number', CRM_Utils_System::mungeCreditCard($params['credit_card_number']));
} else {
//offline contribution
//Retrieve the name and email from receipt is to be send
$params['receipt_from_name'] = $form->userDisplayName;
$params['receipt_from_email'] = $form->userEmail;
// assigned various dates to the templates
$form->assign('receipt_date', CRM_Utils_Date::processDate($params['receipt_date']));
$form->assign('cancel_date', CRM_Utils_Date::processDate($params['cancel_date']));
if (CRM_Utils_Array::value('thankyou_date', $params)) {
$form->assign('thankyou_date', CRM_Utils_Date::processDate($params['thankyou_date']));
}
if ($form->_action & CRM_Core_Action::UPDATE) {
$form->assign('lineItem', empty($form->_lineItems) ? false : $form->_lineItems);
}
}
//handle custom data
if (CRM_Utils_Array::value('hidden_custom', $params)) {
$contribParams = array(array('contribution_id', '=', $params['contribution_id'], 0, 0));
if ($form->_mode == 'test') {
$contribParams[] = array('contribution_test', '=', 1, 0, 0);
}
//retrieve custom data
require_once "CRM/Core/BAO/UFGroup.php";
$customGroup = array();
foreach ($form->_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;
}
//build the array of customgroup contain customfields.
//.........這裏部分代碼省略.........
示例14: assignToTemplate
/**
* assign the minimal set of variables to the template
*
* @return void
* @access public
*/
function assignToTemplate()
{
//process only primary participant params
$this->_params = $this->get('params');
if (isset($this->_params[0])) {
$params = $this->_params[0];
}
$name = '';
if (CRM_Utils_Array::value('billing_first_name', $params)) {
$name = $params['billing_first_name'];
}
if (CRM_Utils_Array::value('billing_middle_name', $params)) {
$name .= " {$params['billing_middle_name']}";
}
if (CRM_Utils_Array::value('billing_last_name', $params)) {
$name .= " {$params['billing_last_name']}";
}
$this->assign('billingName', $name);
$this->set('name', $name);
$vars = array('amount', 'currencyID', 'credit_card_type', 'trxn_id', 'amount_level', 'receive_date');
foreach ($vars as $v) {
if (CRM_Utils_Array::value($v, $params)) {
if ($v == 'receive_date') {
$this->assign($v, CRM_Utils_Date::mysqlToIso($params[$v]));
} else {
$this->assign($v, $params[$v]);
}
} else {
if (CRM_Utils_Array::value('amount', $params) == 0) {
$this->assign($v, CRM_Utils_Array::value($v, $params));
}
}
}
// assign the address formatted up for display
$addressParts = array("street_address-{$this->_bltID}", "city-{$this->_bltID}", "postal_code-{$this->_bltID}", "state_province-{$this->_bltID}", "country-{$this->_bltID}");
$addressFields = array();
foreach ($addressParts as $part) {
list($n, $id) = explode('-', $part);
if (isset($params['billing_' . $part])) {
$addressFields[$n] = CRM_Utils_Array::value('billing_' . $part, $params);
}
}
require_once 'CRM/Utils/Address.php';
$this->assign('address', CRM_Utils_Address::format($addressFields));
if ($this->_contributeMode == 'direct' && !CRM_Utils_Array::value('is_pay_later', $params)) {
$date = CRM_Utils_Date::format(CRM_Utils_Array::value('credit_card_exp_date', $params));
$date = CRM_Utils_Date::mysqlToIso($date);
$this->assign('credit_card_exp_date', $date);
$this->assign('credit_card_number', CRM_Utils_System::mungeCreditCard(CRM_Utils_Array::value('credit_card_number', $params)));
}
$this->assign('email', $this->controller->exportValue('Register', "email-{$this->_bltID}"));
// assign is_email_confirm to templates
if (isset($this->_values['event']['is_email_confirm'])) {
$this->assign('is_email_confirm', $this->_values['event']['is_email_confirm']);
}
// assign pay later stuff
$params['is_pay_later'] = CRM_Utils_Array::value('is_pay_later', $params, false);
$this->assign('is_pay_later', $params['is_pay_later']);
if ($params['is_pay_later']) {
$this->assign('pay_later_text', $this->_values['event']['pay_later_text']);
$this->assign('pay_later_receipt', $this->_values['event']['pay_later_receipt']);
}
}
示例15: emailReceipt
/**
* Send email receipt.
*
* @param CRM_Core_Form $form
* Form object.
* @param array $formValues
* @param object $membership
* Object.
*
* @return bool
* true if mail was sent successfully
*/
public static function emailReceipt(&$form, &$formValues, &$membership)
{
// retrieve 'from email id' for acknowledgement
$receiptFrom = $formValues['from_email_address'];
if (!empty($formValues['payment_instrument_id'])) {
$paymentInstrument = CRM_Contribute_PseudoConstant::paymentInstrument();
$formValues['paidBy'] = $paymentInstrument[$formValues['payment_instrument_id']];
}
// retrieve custom data
$customFields = $customValues = array();
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
//.........這裏部分代碼省略.........