本文整理汇总了PHP中CRM_Core_BAO_CustomValueTable::postProcess方法的典型用法代码示例。如果您正苦于以下问题:PHP CRM_Core_BAO_CustomValueTable::postProcess方法的具体用法?PHP CRM_Core_BAO_CustomValueTable::postProcess怎么用?PHP CRM_Core_BAO_CustomValueTable::postProcess使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类CRM_Core_BAO_CustomValueTable
的用法示例。
在下文中一共展示了CRM_Core_BAO_CustomValueTable::postProcess方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: postProcess
/**
* Function to process the form
*
* @access public
*/
public function postProcess()
{
if ($this->_action & CRM_Core_Action::DELETE) {
require_once "CRM/Event/BAO/Participant.php";
CRM_Event_BAO_Participant::deleteParticipant($this->_participantId);
return;
}
// get the submitted form values.
$params = $this->controller->exportValues($this->_name);
// set the contact, when contact is selected
if (CRM_Utils_Array::value('contact_select_id', $params)) {
$this->_contactID = CRM_Utils_Array::value('contact_select_id', $params);
}
$config =& CRM_Core_Config::singleton();
//check if discount is selected
if (CRM_Utils_Array::value('discount_id', $params)) {
$discountId = $params['discount_id'];
} else {
$params['discount_id'] = 'null';
$discountId = null;
}
if ($this->_isPaidEvent) {
//lets carry currency, CRM-4453
$params['fee_currency'] = $config->defaultCurrency;
// fix for CRM-3088
if ($discountId && !empty($this->_values['discount'][$discountId])) {
$params['amount_level'] = $this->_values['discount'][$discountId][$params['amount']]['label'];
$params['amount'] = $this->_values['discount'][$discountId][$params['amount']]['value'];
$this->assign('amount_level', $params['amount_level']);
} else {
if (!isset($params['priceSetId'])) {
$params['amount_level'] = $this->_values['fee'][$params['amount']]['label'];
$params['amount'] = $this->_values['fee'][$params['amount']]['value'];
$this->assign('amount_level', $params['amount_level']);
} else {
if (!$this->_online) {
$lineItem = array();
CRM_Price_BAO_Set::processAmount($this->_values['fee']['fields'], $params, $lineItem[0]);
$this->set('lineItem', $lineItem);
$this->assign('lineItem', $lineItem);
$this->_lineItem = $lineItem;
}
}
}
$params['fee_level'] = $params['amount_level'];
$contributionParams = array();
$contributionParams['total_amount'] = $params['amount'];
}
//fix for CRM-3086
$params['fee_amount'] = $params['amount'];
$this->_params = $params;
unset($params['amount']);
$params['register_date'] = CRM_Utils_Date::processDate($params['register_date'], $params['register_date_time']);
$params['receive_date'] = CRM_Utils_Date::processDate(CRM_Utils_Array::value('receive_date', $params));
$params['contact_id'] = $this->_contactID;
if ($this->_participantId) {
$params['id'] = $this->_participantId;
}
$status = null;
if ($this->_action & CRM_Core_Action::UPDATE) {
$participantBAO =& new CRM_Event_BAO_Participant();
$participantBAO->id = $this->_participantId;
$participantBAO->find();
while ($participantBAO->fetch()) {
$status = $participantBAO->status_id;
$contributionParams['total_amount'] = $participantBAO->fee_amount;
}
$params['discount_id'] = null;
//re-enter the values for UPDATE mode
$params['fee_level'] = $params['amount_level'] = $participantBAO->fee_level;
$params['fee_amount'] = $participantBAO->fee_amount;
}
require_once 'CRM/Contact/BAO/Contact.php';
// Retrieve the name and email of the current user - this will be the FROM for the receipt email
$session =& CRM_Core_Session::singleton();
$userID = $session->get('userID');
list($userName, $userEmail) = CRM_Contact_BAO_Contact_Location::getEmailDetails($userID);
require_once "CRM/Event/BAO/Participant.php";
if ($this->_mode) {
if (!$this->_isPaidEvent) {
CRM_Core_Error::fatal(ts('Selected Event is not Paid Event '));
}
//modify params according to parameter used in create
//participant method (addParticipant)
$params['participant_status_id'] = $params['status_id'];
$params['participant_role_id'] = $params['role_id'];
$params['participant_register_date'] = $params['register_date'];
$params['participant_source'] = $params['source'];
require_once 'CRM/Core/BAO/PaymentProcessor.php';
$this->_paymentProcessor = CRM_Core_BAO_PaymentProcessor::getPayment($this->_params['payment_processor_id'], $this->_mode);
require_once "CRM/Contact/BAO/Contact.php";
$now = date('YmdHis');
$fields = array();
// set email for primary location.
$fields["email-Primary"] = 1;
//.........这里部分代码省略.........
示例2: postProcess
/**
* Process the form.
*
* @return void
*/
public function postProcess()
{
// Process / save custom data
// Get the form values and groupTree
$params = $this->controller->exportValues($this->_name);
CRM_Core_BAO_CustomValueTable::postProcess($params, 'civicrm_contact', $this->_contactId, $this->_entityType);
$this->log();
// reset the group contact cache for this group
CRM_Contact_BAO_GroupContactCache::remove();
$this->response();
}
示例3: postProcess
/**
* Process the user submitted custom data values.
*/
public function postProcess()
{
// Get the form values and groupTree
//CRM-18183
$params = $this->controller->exportValues($this->_name);
CRM_Core_BAO_CustomValueTable::postProcess($params, 'civicrm_contact', $this->_tableID, $this->_entityType);
$table = CRM_Core_DAO::getFieldValue('CRM_Core_DAO_CustomGroup', $this->_groupID, 'table_name');
$cgcount = CRM_Core_BAO_CustomGroup::customGroupDataExistsForEntity($this->_tableID, $table, TRUE);
$cgcount += 1;
$buttonName = $this->controller->getButtonName();
if ($buttonName == $this->getButtonName('upload', 'new')) {
CRM_Core_Session::singleton()->pushUserContext(CRM_Utils_System::url('civicrm/contact/view/cd/edit', "reset=1&type={$this->_contactType}&groupID={$this->_groupID}&entityID={$this->_tableID}&cgcount={$cgcount}&multiRecordDisplay=single&mode=add"));
}
// Add entry in the log table
CRM_Core_BAO_Log::register($this->_tableID, 'civicrm_contact', $this->_tableID);
if (CRM_Core_Resources::isAjaxMode()) {
$this->ajaxResponse += CRM_Contact_Form_Inline::renderFooter($this->_tableID);
}
// reset the group contact cache for this group
CRM_Contact_BAO_GroupContactCache::remove();
}
示例4: testMultiRecordFieldList
/**
* Test multi-record custom fields
*/
public function testMultiRecordFieldList()
{
//create multi record custom group
$ids = $this->CustomGroupMultipleCreateWithFields(array('style' => 'Tab with table'));
$params = array('contact_type' => 'Individual', 'first_name' => 'Test', 'last_name' => 'Contact');
$customFields = $ids['custom_field_id'];
$result = $this->callAPISuccess('contact', 'create', $params);
$contactId = $result['id'];
//enter values for custom fields
$customParams = array("custom_{$customFields[0]}_-1" => "test value {$customFields[0]} one", "custom_{$customFields[0]}_-2" => "test value {$customFields[0]} two", "custom_{$customFields[0]}_-3" => "test value {$customFields[0]} three", "custom_{$customFields[1]}_-1" => "test value {$customFields[1]} one", "custom_{$customFields[1]}_-2" => "test value {$customFields[1]} two", "custom_{$customFields[1]}_-3" => "test value {$customFields[1]} three", "custom_{$customFields[2]}_-1" => "test value {$customFields[2]} one", "custom_{$customFields[2]}_-2" => "test value {$customFields[2]} two", "custom_{$customFields[2]}_-3" => "test value {$customFields[2]} three");
CRM_Core_BAO_CustomValueTable::postProcess($customParams, "civicrm_contact", $contactId, NULL);
$_GET = array('cid' => $contactId, 'cgid' => $ids['custom_group_id'], 'is_unit_test' => TRUE);
$multiRecordFields = CRM_Custom_Page_AJAX::getMultiRecordFieldList();
//check sorting
foreach ($customFields as $fieldId) {
$columnName = "field_{$fieldId}{$ids['custom_group_id']}_{$fieldId}";
$_GET['columns'][] = array('data' => $columnName);
}
// get the results in descending order
$_GET['order'] = array('0' => array('column' => 0, 'dir' => 'desc'));
$sortedRecords = CRM_Custom_Page_AJAX::getMultiRecordFieldList();
$this->assertEquals(3, $sortedRecords['recordsTotal']);
$this->assertEquals(3, $multiRecordFields['recordsTotal']);
foreach ($customFields as $fieldId) {
$columnName = "field_{$fieldId}{$ids['custom_group_id']}_{$fieldId}";
$this->assertEquals("test value {$fieldId} one", $multiRecordFields['data'][0][$columnName]['data']);
$this->assertEquals("test value {$fieldId} two", $multiRecordFields['data'][1][$columnName]['data']);
$this->assertEquals("test value {$fieldId} three", $multiRecordFields['data'][2][$columnName]['data']);
// this should be sorted in descending order.
$this->assertEquals("test value {$fieldId} two", $sortedRecords['data'][0][$columnName]['data']);
$this->assertEquals("test value {$fieldId} three", $sortedRecords['data'][1][$columnName]['data']);
$this->assertEquals("test value {$fieldId} one", $sortedRecords['data'][2][$columnName]['data']);
}
$sorted = FALSE;
// sorted order result should be two, three, one
$sortedCount = array(1 => 2, 2 => 3, 3 => 1);
foreach (array($multiRecordFields, $sortedRecords) as $records) {
$count = 1;
foreach ($records['data'] as $key => $val) {
//check links for result sorted in descending order
if ($sorted) {
$initialCount = $count;
$count = $sortedCount[$count];
}
// extract view, edit, copy links and assert the recId, cgcount.
preg_match_all('!https?://\\S+!', $val['action'], $matches);
foreach ($matches[0] as $match) {
$parts = parse_url($match);
$parts['query'] = str_replace('&', '&', $parts['query']);
parse_str($parts['query'], $query);
switch (trim($query['mode'], '"')) {
case 'view':
$this->assertEquals($count, $query['recId']);
break;
case 'edit':
$this->assertEquals($count, $query['cgcount']);
break;
case 'copy':
$this->assertEquals(4, $query['cgcount']);
break;
}
}
if (!empty($initialCount)) {
$count = $initialCount;
}
$count++;
}
$sorted = TRUE;
}
}
示例5: postProcessMembership
/**
* Process the Memberships.
*
* @param array $membershipParams
* Array of membership fields.
* @param int $contactID
* Contact id.
* @param CRM_Contribute_Form_Contribution_Confirm $form
* Confirmation form object.
*
* @param array $premiumParams
* @param null $customFieldsFormatted
* @param null $includeFieldTypes
*
* @param array $membershipDetails
*
* @param array $membershipTypeIDs
*
* @param bool $isPaidMembership
* @param array $membershipID
*
* @param $isProcessSeparateMembershipTransaction
*
* @param int $defaultContributionTypeID
* @param array $membershipLineItems
* Line items specific to membership payment that is separate to contribution.
* @param $isPayLater
*
* @throws \CRM_Core_Exception
*/
public static function postProcessMembership($membershipParams, $contactID, &$form, $premiumParams, $customFieldsFormatted = NULL, $includeFieldTypes = NULL, $membershipDetails, $membershipTypeIDs, $isPaidMembership, $membershipID, $isProcessSeparateMembershipTransaction, $defaultContributionTypeID, $membershipLineItems, $isPayLater)
{
$result = $membershipContribution = NULL;
$isTest = CRM_Utils_Array::value('is_test', $membershipParams, FALSE);
$errors = $createdMemberships = array();
//@todo move this into the calling function & pass in the correct financialTypeID
if (isset($paymentParams['financial_type'])) {
$financialTypeID = $paymentParams['financial_type'];
} else {
$financialTypeID = $defaultContributionTypeID;
}
if (CRM_Utils_Array::value('membership_source', $form->_params)) {
$membershipParams['contribution_source'] = $form->_params['membership_source'];
}
if ($isPaidMembership) {
$result = CRM_Contribute_BAO_Contribution_Utils::processConfirm($form, $membershipParams, $premiumParams, $contactID, $financialTypeID, 'membership', array(), $isTest, $isPayLater);
if (is_a($result[1], 'CRM_Core_Error')) {
$errors[1] = CRM_Core_Error::getMessages($result[1]);
} elseif (!empty($result[1])) {
// Save the contribution ID so that I can be used in email receipts
// For example, if you need to generate a tax receipt for the donation only.
$form->_values['contribution_other_id'] = $result[1]->id;
//note that this will be over-written if we are using a separate membership transaction. Otherwise there is only one
$membershipContribution = $result[1];
}
}
if ($isProcessSeparateMembershipTransaction) {
try {
$lineItems = $form->_lineItem = $membershipLineItems;
if (empty($form->_params['auto_renew']) && !empty($membershipParams['is_recur'])) {
unset($membershipParams['is_recur']);
}
$membershipContribution = self::processSecondaryFinancialTransaction($contactID, $form, $membershipParams, $isTest, $membershipLineItems, CRM_Utils_Array::value('minimum_fee', $membershipDetails, 0), CRM_Utils_Array::value('financial_type_id', $membershipDetails));
} catch (CRM_Core_Exception $e) {
$errors[2] = $e->getMessage();
$membershipContribution = NULL;
}
}
$membership = NULL;
if (!empty($membershipContribution) && !is_a($membershipContribution, 'CRM_Core_Error')) {
$membershipContributionID = $membershipContribution->id;
}
//@todo - why is this nested so deep? it seems like it could be just set on the calling function on the form layer
if (isset($membershipParams['onbehalf']) && !empty($membershipParams['onbehalf']['member_campaign_id'])) {
$form->_params['campaign_id'] = $membershipParams['onbehalf']['member_campaign_id'];
}
//@todo it should no longer be possible for it to get to this point & membership to not be an array
if (is_array($membershipTypeIDs) && !empty($membershipContributionID)) {
$typesTerms = CRM_Utils_Array::value('types_terms', $membershipParams, array());
foreach ($membershipTypeIDs as $memType) {
$numTerms = CRM_Utils_Array::value($memType, $typesTerms, 1);
$createdMemberships[$memType] = self::createOrRenewMembership($membershipParams, $contactID, $customFieldsFormatted, $membershipID, $memType, $isTest, $numTerms, $membershipContribution, $form);
}
if ($form->_priceSetId && !empty($form->_useForMember) && !empty($form->_lineItem)) {
foreach ($form->_lineItem[$form->_priceSetId] as &$priceFieldOp) {
if (!empty($priceFieldOp['membership_type_id']) && isset($createdMemberships[$priceFieldOp['membership_type_id']])) {
$membershipOb = $createdMemberships[$priceFieldOp['membership_type_id']];
$priceFieldOp['start_date'] = $membershipOb->start_date ? CRM_Utils_Date::customFormat($membershipOb->start_date, '%B %E%f, %Y') : '-';
$priceFieldOp['end_date'] = $membershipOb->end_date ? CRM_Utils_Date::customFormat($membershipOb->end_date, '%B %E%f, %Y') : '-';
} else {
$priceFieldOp['start_date'] = $priceFieldOp['end_date'] = 'N/A';
}
}
$form->_values['lineItem'] = $form->_lineItem;
$form->assign('lineItem', $form->_lineItem);
}
}
if (!empty($errors)) {
$message = self::compileErrorMessage($errors);
throw new CRM_Core_Exception($message);
//.........这里部分代码省略.........
示例6: postProcessMembership
/**
* Process the Memberships.
*
* @param array $membershipParams
* Array of membership fields.
* @param int $contactID
* Contact id.
* @param CRM_Contribute_Form_Contribution_Confirm $form
* Confirmation form object.
*
* @param array $premiumParams
* @param null $customFieldsFormatted
* @param null $includeFieldTypes
*
* @param array $membershipDetails
*
* @param array $membershipTypeIDs
*
* @param bool $isPaidMembership
* @param array $membershipID
*
* @param bool $isProcessSeparateMembershipTransaction
*
* @param int $financialTypeID
* @param array $membershipLineItems
* Line items specific to membership payment that is separate to contribution.
* @param bool $isPayLater
* @param bool $isPending
*
* @throws \CRM_Core_Exception
*/
protected function postProcessMembership($membershipParams, $contactID, &$form, $premiumParams, $customFieldsFormatted = NULL, $includeFieldTypes = NULL, $membershipDetails, $membershipTypeIDs, $isPaidMembership, $membershipID, $isProcessSeparateMembershipTransaction, $financialTypeID, $membershipLineItems, $isPayLater, $isPending)
{
$membershipContribution = NULL;
$isTest = CRM_Utils_Array::value('is_test', $membershipParams, FALSE);
$errors = $createdMemberships = $paymentResults = array();
$form->_values['isMembership'] = TRUE;
$isRecurForFirstTransaction = CRM_Utils_Array::value('is_recur', $form->_values, CRM_Utils_Array::value('is_recur', $membershipParams));
$totalAmount = $membershipParams['amount'];
if ($isPaidMembership) {
if ($isProcessSeparateMembershipTransaction) {
// If we have 2 transactions only one can use the invoice id.
$membershipParams['invoiceID'] .= '-2';
if (!empty($membershipParams['auto_renew'])) {
$isRecurForFirstTransaction = FALSE;
}
}
$paymentResult = CRM_Contribute_BAO_Contribution_Utils::processConfirm($form, $membershipParams, $contactID, $financialTypeID, 'membership', $isTest, $isRecurForFirstTransaction);
if (!empty($paymentResult['contribution'])) {
$this->postProcessPremium($premiumParams, $paymentResult['contribution']);
//note that this will be over-written if we are using a separate membership transaction. Otherwise there is only one
$membershipContribution = $paymentResult['contribution'];
// Save the contribution ID so that I can be used in email receipts
// For example, if you need to generate a tax receipt for the donation only.
$form->_values['contribution_other_id'] = $membershipContribution->id;
}
}
if ($isProcessSeparateMembershipTransaction) {
try {
$form->_lineItem = $membershipLineItems;
if (empty($form->_params['auto_renew']) && !empty($membershipParams['is_recur'])) {
unset($membershipParams['is_recur']);
}
list($membershipContribution, $secondPaymentResult) = $this->processSecondaryFinancialTransaction($contactID, $form, $membershipParams, $isTest, $membershipLineItems, CRM_Utils_Array::value('minimum_fee', $membershipDetails, 0), CRM_Utils_Array::value('financial_type_id', $membershipDetails));
$paymentResults[] = array('contribution_id' => $membershipContribution->id, 'result' => $secondPaymentResult);
} catch (CRM_Core_Exception $e) {
$errors[2] = $e->getMessage();
$membershipContribution = NULL;
}
}
$membership = NULL;
if (!empty($membershipContribution) && !is_a($membershipContribution, 'CRM_Core_Error')) {
$membershipContributionID = $membershipContribution->id;
}
//@todo - why is this nested so deep? it seems like it could be just set on the calling function on the form layer
if (isset($membershipParams['onbehalf']) && !empty($membershipParams['onbehalf']['member_campaign_id'])) {
$form->_params['campaign_id'] = $membershipParams['onbehalf']['member_campaign_id'];
}
//@todo it should no longer be possible for it to get to this point & membership to not be an array
if (is_array($membershipTypeIDs) && !empty($membershipContributionID)) {
$typesTerms = CRM_Utils_Array::value('types_terms', $membershipParams, array());
foreach ($membershipTypeIDs as $memType) {
$numTerms = CRM_Utils_Array::value($memType, $typesTerms, 1);
if (!empty($membershipContribution)) {
$pendingStatus = CRM_Core_OptionGroup::getValue('contribution_status', 'Pending', 'name');
$pending = $membershipContribution->contribution_status_id == $pendingStatus ? TRUE : FALSE;
} else {
$pending = $isPending;
}
$contributionRecurID = isset($form->_params['contributionRecurID']) ? $form->_params['contributionRecurID'] : NULL;
$membershipSource = NULL;
if (!empty($form->_params['membership_source'])) {
$membershipSource = $form->_params['membership_source'];
} elseif (isset($form->_values['title']) && !empty($form->_values['title'])) {
$membershipSource = ts('Online Contribution:') . ' ' . $form->_values['title'];
}
$isPayLater = NULL;
if (isset($form->_params)) {
$isPayLater = CRM_Utils_Array::value('is_pay_later', $form->_params);
}
//.........这里部分代码省略.........
示例7: postProcess
/**
* Process the form submission.
*/
public function postProcess()
{
// get the submitted form values.
$params = $this->controller->exportValues($this->_name);
if ($this->_action & CRM_Core_Action::DELETE) {
if (CRM_Utils_Array::value('delete_participant', $params) == 2) {
$additionalId = CRM_Event_BAO_Participant::getAdditionalParticipantIds($this->_id);
$participantLinks = CRM_Event_BAO_Participant::getAdditionalParticipantUrl($additionalId);
}
if (CRM_Utils_Array::value('delete_participant', $params) == 1) {
$additionalIds = CRM_Event_BAO_Participant::getAdditionalParticipantIds($this->_id);
foreach ($additionalIds as $value) {
CRM_Event_BAO_Participant::deleteParticipant($value);
}
}
CRM_Event_BAO_Participant::deleteParticipant($this->_id);
CRM_Core_Session::setStatus(ts('Selected participant was deleted successfully.'), ts('Record Deleted'), 'success');
if (!empty($participantLinks)) {
$status = ts('The following participants no longer have an event fee recorded. You can edit their registration and record a replacement contribution by clicking the links below:') . '<br/>' . $participantLinks;
CRM_Core_Session::setStatus($status, ts('Group Payment Deleted'));
}
return;
}
// When adding a single contact, the formRule prevents you from adding duplicates
// (See above in formRule()). When adding more than one contact, the duplicates are
// removed automatically and the user receives one notification.
if ($this->_action & CRM_Core_Action::ADD) {
$event_id = $this->_eventId;
if (empty($event_id) && !empty($params['event_id'])) {
$event_id = $params['event_id'];
}
if (!$this->_single && !empty($event_id)) {
$duplicateContacts = 0;
while (list($k, $dupeCheckContactId) = each($this->_contactIds)) {
// Eliminate contacts that have already been assigned to this event.
$dupeCheck = new CRM_Event_BAO_Participant();
$dupeCheck->contact_id = $dupeCheckContactId;
$dupeCheck->event_id = $event_id;
$dupeCheck->find(TRUE);
if (!empty($dupeCheck->id)) {
$duplicateContacts++;
unset($this->_contactIds[$k]);
}
}
if ($duplicateContacts > 0) {
$msg = ts("%1 contacts have already been assigned to this event. They were not added a second time.", array(1 => $duplicateContacts));
CRM_Core_Session::setStatus($msg);
}
if (count($this->_contactIds) == 0) {
CRM_Core_Session::setStatus(ts("No participants were added."));
return;
}
// We have to re-key $this->_contactIds so each contact has the same
// key as their corresponding record in the $participants array that
// will be created below.
$this->_contactIds = array_values($this->_contactIds);
}
}
$participantStatus = CRM_Event_PseudoConstant::participantStatus();
// set the contact, when contact is selected
if (!empty($params['contact_id'])) {
$this->_contactId = $params['contact_id'];
}
if ($this->_priceSetId && ($isQuickConfig = CRM_Core_DAO::getFieldValue('CRM_Price_DAO_PriceSet', $this->_priceSetId, 'is_quick_config'))) {
$this->_quickConfig = $isQuickConfig;
}
if ($this->_id) {
$params['id'] = $this->_id;
}
$config = CRM_Core_Config::singleton();
if ($this->_isPaidEvent) {
$contributionParams = array();
$lineItem = array();
$additionalParticipantDetails = array();
if (CRM_Contribute_BAO_Contribution::checkContributeSettings('deferred_revenue_enabled')) {
$eventStartDate = CRM_Core_DAO::getFieldValue('CRM_Event_DAO_Event', $this->_eventId, 'start_date');
if ($eventStartDate) {
$contributionParams['revenue_recognition_date'] = date('Ymd', strtotime($eventStartDate));
}
}
if ($this->_id && $this->_action & CRM_Core_Action::UPDATE && $this->_paymentId) {
$participantBAO = new CRM_Event_BAO_Participant();
$participantBAO->id = $this->_id;
$participantBAO->find(TRUE);
$contributionParams['total_amount'] = $participantBAO->fee_amount;
$params['discount_id'] = NULL;
//re-enter the values for UPDATE mode
$params['fee_level'] = $params['amount_level'] = $participantBAO->fee_level;
$params['fee_amount'] = $participantBAO->fee_amount;
if (isset($params['priceSetId'])) {
$lineItem[0] = CRM_Price_BAO_LineItem::getLineItems($this->_id);
}
//also add additional participant's fee level/priceset
if (CRM_Event_BAO_Participant::isPrimaryParticipant($this->_id)) {
$additionalIds = CRM_Event_BAO_Participant::getAdditionalParticipantIds($this->_id);
$hasLineItems = CRM_Utils_Array::value('priceSetId', $params, FALSE);
$additionalParticipantDetails = CRM_Event_BAO_Participant::getFeeDetails($additionalIds, $hasLineItems);
//.........这里部分代码省略.........
示例8: processContribution
//.........这里部分代码省略.........
if (CRM_Utils_Array::value('pcp_made_through_id', $params)) {
$contribSoftParams['pcp_id'] = $params['pcp_made_through_id'];
$contribSoftParams['contact_id'] = CRM_Core_DAO::getFieldValue('CRM_Contribute_DAO_PCP', $params['pcp_made_through_id'], 'contact_id');
} else {
$contribSoftParams['contact_id'] = CRM_Utils_Array::value('soft_credit_to', $params);
}
$softContribution = CRM_Contribute_BAO_Contribution::addSoftContribution($contribSoftParams);
}
//handle pledge stuff.
if (!CRM_Utils_Array::value('separate_membership_payment', $form->_params) && CRM_Utils_Array::value('pledge_block_id', $form->_values) && (CRM_Utils_Array::value('is_pledge', $form->_params) || CRM_Utils_Array::value('pledge_id', $form->_values))) {
if (CRM_Utils_Array::value('pledge_id', $form->_values)) {
//when user doing pledge payments.
//update the schedule when payment(s) are made
require_once 'CRM/Pledge/BAO/Payment.php';
foreach ($form->_params['pledge_amount'] as $paymentId => $dontCare) {
$pledgePaymentParams = array('id' => $paymentId, 'contribution_id' => $contribution->id, 'status_id' => $contribution->contribution_status_id);
CRM_Pledge_BAO_Payment::add($pledgePaymentParams);
}
//update pledge status according to the new payment statuses
CRM_Pledge_BAO_Payment::updatePledgePaymentStatus($form->_values['pledge_id']);
} else {
//when user creating pledge record.
$pledgeParams = array();
$pledgeParams['contact_id'] = $contribution->contact_id;
$pledgeParams['installment_amount'] = $contribution->total_amount;
$pledgeParams['contribution_id'] = $contribution->id;
$pledgeParams['contribution_page_id'] = $contribution->contribution_page_id;
$pledgeParams['contribution_type_id'] = $contribution->contribution_type_id;
$pledgeParams['frequency_interval'] = $params['pledge_frequency_interval'];
$pledgeParams['installments'] = $params['pledge_installments'];
$pledgeParams['frequency_unit'] = $params['pledge_frequency_unit'];
$pledgeParams['frequency_day'] = 1;
$pledgeParams['create_date'] = $pledgeParams['start_date'] = $pledgeParams['scheduled_date'] = date("Ymd");
$pledgeParams['status_id'] = $contribution->contribution_status_id;
$pledgeParams['max_reminders'] = $form->_values['max_reminders'];
$pledgeParams['initial_reminder_day'] = $form->_values['initial_reminder_day'];
$pledgeParams['additional_reminder_day'] = $form->_values['additional_reminder_day'];
$pledgeParams['is_test'] = $contribution->is_test;
$pledgeParams['acknowledge_date'] = date('Ymd');
require_once 'CRM/Pledge/BAO/Pledge.php';
$pledge = CRM_Pledge_BAO_Pledge::create($pledgeParams);
$form->_params['pledge_id'] = $pledge->id;
//send acknowledgment email. only when pledge is created
if ($pledge->id) {
//build params to send acknowledgment.
$pledgeParams['id'] = $pledge->id;
$pledgeParams['receipt_from_name'] = $form->_values['receipt_from_name'];
$pledgeParams['receipt_from_email'] = $form->_values['receipt_from_email'];
//scheduled amount will be same as installment_amount.
$pledgeParams['scheduled_amount'] = $pledgeParams['installment_amount'];
//get total pledge amount.
$pledgeParams['total_pledge_amount'] = $pledge->amount;
require_once 'CRM/Pledge/BAO/Pledge.php';
CRM_Pledge_BAO_Pledge::sendAcknowledgment($form, $pledgeParams);
}
}
}
if ($online) {
require_once 'CRM/Core/BAO/CustomValueTable.php';
CRM_Core_BAO_CustomValueTable::postProcess($form->_params, CRM_Core_DAO::$_nullArray, 'civicrm_contribution', $contribution->id, 'Contribution');
} else {
//handle custom data.
$params['contribution_id'] = $contribution->id;
if (CRM_Utils_Array::value('custom', $params) && is_array($params['custom']) && !is_a($contribution, 'CRM_Core_Error')) {
require_once 'CRM/Core/BAO/CustomValueTable.php';
CRM_Core_BAO_CustomValueTable::store($params['custom'], 'civicrm_contribution', $contribution->id);
}
}
require_once "CRM/Contribute/BAO/Contribution/Utils.php";
if (isset($params['related_contact'])) {
$contactID = $params['related_contact'];
} else {
if (isset($params['cms_contactID'])) {
$contactID = $params['cms_contactID'];
}
}
CRM_Contribute_BAO_Contribution_Utils::createCMSUser($params, $contactID, 'email-' . $form->_bltID);
// return if pending
if ($pending) {
return $contribution;
}
// next create the transaction record
if ((!$online || $form->_values['is_monetary']) && $result['trxn_id']) {
$trxnParams = array('contribution_id' => $contribution->id, 'trxn_date' => $now, 'trxn_type' => 'Debit', 'total_amount' => $params['amount'], 'fee_amount' => CRM_Utils_Array::value('fee_amount', $result), 'net_amount' => CRM_Utils_Array::value('net_amount', $result, $params['amount']), 'currency' => $params['currencyID'], 'payment_processor' => $form->_paymentProcessor['payment_processor_type'], 'trxn_id' => $result['trxn_id'], 'trxn_result_code' => $result['trxn_result_code']);
require_once 'CRM/Contribute/BAO/FinancialTrxn.php';
$trxn =& CRM_Contribute_BAO_FinancialTrxn::create($trxnParams);
}
//create contribution activity w/ individual and target
//activity w/ organisation contact id when onbelf, CRM-4027
$targetContactID = null;
if (CRM_Utils_Array::value('is_for_organization', $params)) {
$targetContactID = $contribution->contact_id;
$contribution->contact_id = $contactID;
}
// create an activity record
require_once 'CRM/Activity/BAO/Activity.php';
CRM_Activity_BAO_Activity::addActivity($contribution, null, $targetContactID);
$transaction->commit();
return $contribution;
}
示例9: postProcessMembership
/**
* Process the Memberships
*
* @param array $membershipParams array of membership fields
* @param int $contactID contact id
* @param object $form form object
*
* @return void
* @access public
*/
public static function postProcessMembership($membershipParams, $contactID, &$form, &$premiumParams, $customFieldsFormatted = NULL, $includeFieldTypes = NULL)
{
$tempParams = $membershipParams;
$paymentDone = FALSE;
$result = NULL;
$isTest = CRM_Utils_Array::value('is_test', $membershipParams, FALSE);
$form->assign('membership_assign', TRUE);
$form->set('membershipTypeID', $membershipParams['selectMembership']);
$singleMembershipTypeID = $membershipTypeID = $membershipParams['selectMembership'];
if (is_array($membershipTypeID) && count($membershipTypeID) == 1) {
$singleMembershipTypeID = $membershipTypeID[0];
}
$membershipDetails = self::buildMembershipTypeValues($form, $singleMembershipTypeID);
$form->assign('membership_name', CRM_Utils_Array::value('name', $membershipDetails));
$minimumFee = CRM_Utils_Array::value('minimum_fee', $membershipDetails);
$contributionTypeId = NULL;
if ($form->_values['amount_block_is_active']) {
$contributionTypeId = $form->_values['financial_type_id'];
} else {
$paymentDone = TRUE;
$params['amount'] = $minimumFee;
$contributionTypeId = CRM_Utils_Array::value('financial_type_id', $membershipDetails);
if (!$contributionTypeId) {
$contributionTypeId = CRM_Utils_Array::value('financial_type_id', $membershipParams);
}
}
//amount must be greater than zero for
//adding contribution record to contribution table.
//this condition arises when separate membership payment is
//enabled and contribution amount is not selected. fix for CRM-3010
if ($form->_amount > 0.0 && $membershipParams['amount']) {
$result = CRM_Contribute_BAO_Contribution_Utils::processConfirm($form, $membershipParams, $premiumParams, $contactID, $contributionTypeId, 'membership');
} else {
// we need to explicitly create a CMS user in case of free memberships
// since the below has already been done under processConfirm for paid memberships
CRM_Contribute_BAO_Contribution_Utils::createCMSUser($membershipParams, $membershipParams['cms_contactID'], 'email-' . $form->_bltID);
}
$errors = array();
if (is_a($result[1], 'CRM_Core_Error')) {
$errors[1] = CRM_Core_Error::getMessages($result[1]);
} elseif (CRM_Utils_Array::value(1, $result)) {
// Save the contribution ID so that I can be used in email receipts
// For example, if you need to generate a tax receipt for the donation only.
$form->_values['contribution_other_id'] = $result[1]->id;
$contribution[1] = $result[1];
}
$memBlockDetails = CRM_Member_BAO_Membership::getMembershipBlock($form->_id);
if (CRM_Utils_Array::value('is_separate_payment', $memBlockDetails) && !$paymentDone) {
$form->_lineItem = $form->_memLineItem;
$contributionType = new CRM_Financial_DAO_FinancialType();
$contributionType->id = CRM_Utils_Array::value('financial_type_id', $membershipDetails);
if (!$contributionType->find(TRUE)) {
CRM_Core_Error::fatal(ts("Could not find a system table"));
}
$tempParams['amount'] = $minimumFee;
$invoiceID = md5(uniqid(rand(), TRUE));
$tempParams['invoiceID'] = $invoiceID;
//we don't allow recurring membership.CRM-3781.
if (CRM_Utils_Array::value('is_recur', $tempParams)) {
$tempParams['is_recur'] = 0;
}
$result = NULL;
if ($form->_values['is_monetary'] && !$form->_params['is_pay_later'] && $minimumFee > 0.0) {
$payment = CRM_Core_Payment::singleton($form->_mode, $form->_paymentProcessor, $form);
if ($form->_contributeMode == 'express') {
$result =& $payment->doExpressCheckout($tempParams);
} else {
$result =& $payment->doDirectPayment($tempParams);
}
}
if (is_a($result, 'CRM_Core_Error')) {
$errors[2] = CRM_Core_Error::getMessages($result);
} else {
//assign receive date when separate membership payment
//and contribution amount not selected.
if ($form->_amount == 0) {
$now = date('YmdHis');
$form->_params['receive_date'] = $now;
$receiveDate = CRM_Utils_Date::mysqlToIso($now);
$form->set('params', $form->_params);
$form->assign('receive_date', $receiveDate);
}
$form->set('membership_trx_id', $result['trxn_id']);
$form->set('membership_amount', $minimumFee);
$form->assign('membership_trx_id', $result['trxn_id']);
$form->assign('membership_amount', $minimumFee);
// we dont need to create the user twice, so lets disable cms_create_account
// irrespective of the value, CRM-2888
$tempParams['cms_create_account'] = 0;
$pending = $form->_params['is_pay_later'] ? CRM_Utils_Array::value('minimum_fee', $membershipDetails, 0) > 0.0 ? TRUE : FALSE : FALSE;
//.........这里部分代码省略.........
示例10: postProcessMembership
/**
* Process the Memberships.
*
* @param array $membershipParams
* Array of membership fields.
* @param int $contactID
* Contact id.
* @param CRM_Contribute_Form_Contribution_Confirm $form
* Confirmation form object.
*
* @param array $premiumParams
* @param null $customFieldsFormatted
* @param null $includeFieldTypes
*
* @param array $membershipDetails
*
* @param array $membershipTypeIDs
*
* @param bool $isPaidMembership
* @param array $membershipID
*
* @param bool $isProcessSeparateMembershipTransaction
*
* @param int $financialTypeID
* @param array $membershipLineItems
* Line items specific to membership payment that is separate to contribution.
* @param bool $isPayLater
* @param bool $isPending
*
* @throws \CRM_Core_Exception
*/
protected function postProcessMembership($membershipParams, $contactID, &$form, $premiumParams, $customFieldsFormatted = NULL, $includeFieldTypes = NULL, $membershipDetails, $membershipTypeIDs, $isPaidMembership, $membershipID, $isProcessSeparateMembershipTransaction, $financialTypeID, $membershipLineItems, $isPayLater, $isPending)
{
$membershipContribution = NULL;
$isTest = CRM_Utils_Array::value('is_test', $membershipParams, FALSE);
$errors = $createdMemberships = $paymentResult = array();
if ($isPaidMembership) {
if ($isProcessSeparateMembershipTransaction) {
// If we have 2 transactions only one can use the invoice id.
$membershipParams['invoiceID'] .= '-2';
}
$paymentResult = CRM_Contribute_BAO_Contribution_Utils::processConfirm($form, $membershipParams, $contactID, $financialTypeID, 'membership', array(), $isTest, $isPayLater);
if (!empty($paymentResult['contribution'])) {
$this->postProcessPremium($premiumParams, $paymentResult['contribution']);
//note that this will be over-written if we are using a separate membership transaction. Otherwise there is only one
$membershipContribution = $paymentResult['contribution'];
// Save the contribution ID so that I can be used in email receipts
// For example, if you need to generate a tax receipt for the donation only.
$form->_values['contribution_other_id'] = $membershipContribution->id;
}
}
if ($isProcessSeparateMembershipTransaction) {
try {
$form->_lineItem = $membershipLineItems;
if (empty($form->_params['auto_renew']) && !empty($membershipParams['is_recur'])) {
unset($membershipParams['is_recur']);
}
$membershipContribution = $this->processSecondaryFinancialTransaction($contactID, $form, $membershipParams, $isTest, $membershipLineItems, CRM_Utils_Array::value('minimum_fee', $membershipDetails, 0), CRM_Utils_Array::value('financial_type_id', $membershipDetails));
} catch (CRM_Core_Exception $e) {
$errors[2] = $e->getMessage();
$membershipContribution = NULL;
}
}
$membership = NULL;
if (!empty($membershipContribution) && !is_a($membershipContribution, 'CRM_Core_Error')) {
$membershipContributionID = $membershipContribution->id;
}
//@todo - why is this nested so deep? it seems like it could be just set on the calling function on the form layer
if (isset($membershipParams['onbehalf']) && !empty($membershipParams['onbehalf']['member_campaign_id'])) {
$form->_params['campaign_id'] = $membershipParams['onbehalf']['member_campaign_id'];
}
//@todo it should no longer be possible for it to get to this point & membership to not be an array
if (is_array($membershipTypeIDs) && !empty($membershipContributionID)) {
$typesTerms = CRM_Utils_Array::value('types_terms', $membershipParams, array());
foreach ($membershipTypeIDs as $memType) {
$numTerms = CRM_Utils_Array::value($memType, $typesTerms, 1);
if (!empty($membershipContribution)) {
$pendingStatus = CRM_Core_OptionGroup::getValue('contribution_status', 'Pending', 'name');
$pending = $membershipContribution->contribution_status_id == $pendingStatus ? TRUE : FALSE;
} else {
$pending = $isPending;
}
$contributionRecurID = isset($form->_params['contributionRecurID']) ? $form->_params['contributionRecurID'] : NULL;
$membershipSource = NULL;
if (!empty($form->_params['membership_source'])) {
$membershipSource = $form->_params['membership_source'];
} elseif (isset($form->_values['title']) && !empty($form->_values['title'])) {
$membershipSource = ts('Online Contribution:') . ' ' . $form->_values['title'];
}
$isPayLater = NULL;
if (isset($form->_params)) {
$isPayLater = CRM_Utils_Array::value('is_pay_later', $form->_params);
}
$campaignId = NULL;
if (isset($form->_values) && is_array($form->_values) && !empty($form->_values)) {
$campaignId = CRM_Utils_Array::value('campaign_id', $form->_params);
if (!array_key_exists('campaign_id', $form->_params)) {
$campaignId = CRM_Utils_Array::value('campaign_id', $form->_values);
}
}
//.........这里部分代码省略.........
示例11: confirmPostProcess
/**
* Function to handle process after the confirmation of payment by User
*
* @return None
* @access public
*/
function confirmPostProcess($contactID = null, $contribution = null, $payment = null)
{
// add/update contact information
$fields = array();
unset($this->_params['note']);
//to avoid conflict overwrite $this->_params
$this->_params = $this->get('value');
// create CMS user
if (CRM_Utils_Array::value('cms_create_account', $this->_params)) {
$this->_params['contactID'] = $contactID;
$mail = 'email-5';
// we should use primary email for
// 1. free event registration.
// 2. pay later participant.
// 3. waiting list participant.
// 4. require approval participant.
if (CRM_Utils_Array::value('is_pay_later', $this->_params) || $this->_allowWaitlist || $this->_requireApproval || !CRM_Utils_Array::value('is_monetary', $this->_values['event'])) {
$mail = 'email-Primary';
}
require_once "CRM/Core/BAO/CMSUser.php";
if (!CRM_Core_BAO_CMSUser::create($this->_params, $mail)) {
CRM_Core_Error::statusBounce(ts('Your profile is not saved and Account is not created.'));
}
}
//get the amount of primary participant
if (CRM_Utils_Array::value('is_primary', $this->_params)) {
$this->_params['fee_amount'] = $this->get('primaryParticipantAmount');
}
// add participant record
$participant = $this->addParticipant($this->_params, $contactID);
$this->_participantIDS[] = $participant->id;
//setting register_by_id field and primaryContactId
if (CRM_Utils_Array::value('is_primary', $this->_params)) {
$this->set('registerByID', $participant->id);
$this->set('primaryContactId', $contactID);
}
require_once 'CRM/Core/BAO/CustomValueTable.php';
CRM_Core_BAO_CustomValueTable::postProcess($this->_params, CRM_Core_DAO::$_nullArray, 'civicrm_participant', $participant->id, 'Participant');
$createPayment = $this->_params['amount'] != 0 ? true : false;
// force to create zero amount payment, CRM-5095
if (!$createPayment && $contribution->id && $this->_params['amount'] == 0 && $this->_priceSetId && $this->_lineItem) {
$createPayment = true;
}
if ($createPayment && $this->_values['event']['is_monetary'] && CRM_Utils_Array::value('contributionID', $this->_params)) {
require_once 'CRM/Event/BAO/ParticipantPayment.php';
$paymentParams = array('participant_id' => $participant->id, 'contribution_id' => $contribution->id);
$ids = array();
$paymentPartcipant = CRM_Event_BAO_ParticipantPayment::create($paymentParams, $ids);
}
//set only primary participant's params for transfer checkout.
if (($this->_contributeMode == 'checkout' || $this->_contributeMode == 'notify') && CRM_Utils_Array::value('is_primary', $this->_params)) {
$this->_params['participantID'] = $participant->id;
$this->set('primaryParticipant', $this->_params);
}
$this->assign('action', $this->_action);
}
示例12: processContribution
//.........这里部分代码省略.........
}
} elseif (!CRM_Utils_Array::value('is_quick_config', $form->_params)) {
CRM_Contribute_Form_AdditionalInfo::processPriceSet($contribution->id, $form->_lineItem);
}
if (!$form->_separateMembershipPayment && CRM_Utils_Array::value('is_quick_config', $form->_params)) {
$form->_lineItem = null;
}
}
//handle pledge stuff.
if (!CRM_Utils_Array::value('separate_membership_payment', $form->_params) && CRM_Utils_Array::value('pledge_block_id', $form->_values) && (CRM_Utils_Array::value('is_pledge', $form->_params) || CRM_Utils_Array::value('pledge_id', $form->_values))) {
if (CRM_Utils_Array::value('pledge_id', $form->_values)) {
//when user doing pledge payments.
//update the schedule when payment(s) are made
foreach ($form->_params['pledge_amount'] as $paymentId => $dontCare) {
$scheduledAmount = CRM_Core_DAO::getFieldValue('CRM_Pledge_DAO_PledgePayment', $paymentId, 'scheduled_amount', 'id');
$pledgePaymentParams = array('id' => $paymentId, 'contribution_id' => $contribution->id, 'status_id' => $contribution->contribution_status_id, 'actual_amount' => $scheduledAmount);
CRM_Pledge_BAO_PledgePayment::add($pledgePaymentParams);
}
//update pledge status according to the new payment statuses
CRM_Pledge_BAO_PledgePayment::updatePledgePaymentStatus($form->_values['pledge_id']);
} else {
//when user creating pledge record.
$pledgeParams = array();
$pledgeParams['contact_id'] = $contribution->contact_id;
$pledgeParams['installment_amount'] = $pledgeParams['actual_amount'] = $contribution->total_amount;
$pledgeParams['contribution_id'] = $contribution->id;
$pledgeParams['contribution_page_id'] = $contribution->contribution_page_id;
$pledgeParams['contribution_type_id'] = $contribution->contribution_type_id;
$pledgeParams['frequency_interval'] = $params['pledge_frequency_interval'];
$pledgeParams['installments'] = $params['pledge_installments'];
$pledgeParams['frequency_unit'] = $params['pledge_frequency_unit'];
if ($pledgeParams['frequency_unit'] == 'month') {
$pledgeParams['frequency_day'] = intval(date("d"));
} else {
$pledgeParams['frequency_day'] = 1;
}
$pledgeParams['create_date'] = $pledgeParams['start_date'] = $pledgeParams['scheduled_date'] = date("Ymd");
$pledgeParams['status_id'] = $contribution->contribution_status_id;
$pledgeParams['max_reminders'] = $form->_values['max_reminders'];
$pledgeParams['initial_reminder_day'] = $form->_values['initial_reminder_day'];
$pledgeParams['additional_reminder_day'] = $form->_values['additional_reminder_day'];
$pledgeParams['is_test'] = $contribution->is_test;
$pledgeParams['acknowledge_date'] = date('Ymd');
$pledgeParams['original_installment_amount'] = $pledgeParams['installment_amount'];
//inherit campaign from contirb page.
$pledgeParams['campaign_id'] = $campaignId;
$pledge = CRM_Pledge_BAO_Pledge::create($pledgeParams);
$form->_params['pledge_id'] = $pledge->id;
//send acknowledgment email. only when pledge is created
if ($pledge->id) {
//build params to send acknowledgment.
$pledgeParams['id'] = $pledge->id;
$pledgeParams['receipt_from_name'] = $form->_values['receipt_from_name'];
$pledgeParams['receipt_from_email'] = $form->_values['receipt_from_email'];
//scheduled amount will be same as installment_amount.
$pledgeParams['scheduled_amount'] = $pledgeParams['installment_amount'];
//get total pledge amount.
$pledgeParams['total_pledge_amount'] = $pledge->amount;
CRM_Pledge_BAO_Pledge::sendAcknowledgment($form, $pledgeParams);
}
}
}
if ($online && $contribution) {
CRM_Core_BAO_CustomValueTable::postProcess($form->_params, CRM_Core_DAO::$_nullArray, 'civicrm_contribution', $contribution->id, 'Contribution');
} elseif ($contribution) {
//handle custom data.
$params['contribution_id'] = $contribution->id;
if (CRM_Utils_Array::value('custom', $params) && is_array($params['custom']) && !is_a($contribution, 'CRM_Core_Error')) {
CRM_Core_BAO_CustomValueTable::store($params['custom'], 'civicrm_contribution', $contribution->id);
}
}
if (isset($params['related_contact'])) {
$contactID = $params['related_contact'];
} elseif (isset($params['cms_contactID'])) {
$contactID = $params['cms_contactID'];
}
CRM_Contribute_BAO_Contribution_Utils::createCMSUser($params, $contactID, 'email-' . $form->_bltID);
// return if pending
if ($pending) {
return $contribution;
}
// next create the transaction record
if ($contribution && (!$online || $form->_values['is_monetary']) && $result['trxn_id']) {
$trxnParams = array('contribution_id' => $contribution->id, 'trxn_date' => $now, 'trxn_type' => 'Debit', 'total_amount' => $params['amount'], 'fee_amount' => CRM_Utils_Array::value('fee_amount', $result), 'net_amount' => CRM_Utils_Array::value('net_amount', $result, $params['amount']), 'currency' => $params['currencyID'], 'payment_processor' => $form->_paymentProcessor['payment_processor_type'], 'trxn_id' => $result['trxn_id'], 'trxn_result_code' => isset($result['trxn_result_code']) ? $result['trxn_result_code'] : FALSE);
$trxn = CRM_Core_BAO_FinancialTrxn::create($trxnParams);
}
//create contribution activity w/ individual and target
//activity w/ organisation contact id when onbelf, CRM-4027
$targetContactID = NULL;
if (CRM_Utils_Array::value('hidden_onbehalf_profile', $params)) {
$targetContactID = $contribution->contact_id;
$contribution->contact_id = $contactID;
}
// create an activity record
if ($contribution) {
CRM_Activity_BAO_Activity::addActivity($contribution, NULL, $targetContactID);
}
$transaction->commit();
return $contribution;
}
示例13: postProcess
/**
* process the form
*
* @return void
* @access public
*/
public function postProcess()
{
// need to process / save custom data
// Get the form values and groupTree
$params = $this->controller->exportValues($this->_name);
CRM_Core_BAO_CustomValueTable::postProcess($params, $this->_groupTree[$this->_groupID]['fields'], 'civicrm_contact', $this->_contactId, $this->_entityType);
// reset the group contact cache for this group
CRM_Contact_BAO_GroupContactCache::remove();
$response = array('status' => 'save');
$this->postProcessHook();
echo json_encode($response);
CRM_Utils_System::civiExit();
}
示例14: processFormContribution
//.........这里部分代码省略.........
// available at hook_post_process, CRM-8908
$params['soft_credit_to'] = $contribSoftContactId;
}
if (isset($params['amount'])) {
$contribParams = self::getContributionParams($params, $contactID, $financialType->id, $online, $contributionPageId, $nonDeductibleAmount, $campaignId, $isMonetary, $pending, $result, $receiptDate, $recurringContributionID, $isTest, $addressID, $contribSoftContactId, $lineItems);
$contribution = CRM_Contribute_BAO_Contribution::add($contribParams);
$invoiceSettings = CRM_Core_BAO_Setting::getItem(CRM_Core_BAO_Setting::CONTRIBUTE_PREFERENCES_NAME, 'contribution_invoice_settings');
$invoicing = CRM_Utils_Array::value('invoicing', $invoiceSettings);
if ($invoicing) {
$dataArray = array();
foreach ($form->_lineItem as $lineItemKey => $lineItemValue) {
foreach ($lineItemValue as $key => $value) {
if (isset($value['tax_amount']) && isset($value['tax_rate'])) {
if (isset($dataArray[$value['tax_rate']])) {
$dataArray[$value['tax_rate']] = $dataArray[$value['tax_rate']] + CRM_Utils_Array::value('tax_amount', $value);
} else {
$dataArray[$value['tax_rate']] = CRM_Utils_Array::value('tax_amount', $value);
}
}
}
}
$smarty = CRM_Core_Smarty::singleton();
$smarty->assign('dataArray', $dataArray);
$smarty->assign('totalTaxAmount', $params['tax_amount']);
}
if (is_a($contribution, 'CRM_Core_Error')) {
$message = CRM_Core_Error::getMessages($contribution);
CRM_Core_Error::fatal($message);
}
// lets store it in the form variable so postProcess hook can get to this and use it
$form->_contributionID = $contribution->id;
}
//CRM-13981, processing honor contact into soft-credit contribution
CRM_Contact_Form_ProfileContact::postProcess($form);
// process soft credit / pcp pages
CRM_Contribute_Form_Contribution_Confirm::processPcpSoft($params, $contribution);
//handle pledge stuff.
if ($isPledge) {
if ($pledgeID) {
//when user doing pledge payments.
//update the schedule when payment(s) are made
foreach ($form->_params['pledge_amount'] as $paymentId => $dontCare) {
$scheduledAmount = CRM_Core_DAO::getFieldValue('CRM_Pledge_DAO_PledgePayment', $paymentId, 'scheduled_amount', 'id');
$pledgePaymentParams = array('id' => $paymentId, 'contribution_id' => $contribution->id, 'status_id' => $contribution->contribution_status_id, 'actual_amount' => $scheduledAmount);
CRM_Pledge_BAO_PledgePayment::add($pledgePaymentParams);
}
//update pledge status according to the new payment statuses
CRM_Pledge_BAO_PledgePayment::updatePledgePaymentStatus($pledgeID);
} else {
//when user creating pledge record.
$pledgeParams = array();
$pledgeParams['contact_id'] = $contribution->contact_id;
$pledgeParams['installment_amount'] = $pledgeParams['actual_amount'] = $contribution->total_amount;
$pledgeParams['contribution_id'] = $contribution->id;
$pledgeParams['contribution_page_id'] = $contribution->contribution_page_id;
$pledgeParams['financial_type_id'] = $contribution->financial_type_id;
$pledgeParams['frequency_interval'] = $params['pledge_frequency_interval'];
$pledgeParams['installments'] = $params['pledge_installments'];
$pledgeParams['frequency_unit'] = $params['pledge_frequency_unit'];
if ($pledgeParams['frequency_unit'] == 'month') {
$pledgeParams['frequency_day'] = intval(date("d"));
} else {
$pledgeParams['frequency_day'] = 1;
}
$pledgeParams['create_date'] = $pledgeParams['start_date'] = $pledgeParams['scheduled_date'] = date("Ymd");
$pledgeParams['status_id'] = $contribution->contribution_status_id;
示例15: postProcessMembership
/**
* Process the Memberships
*
* @param array $membershipParams array of membership fields
* @param int $contactID contact id
* @param object $form form object
*
* @return void
* @access public
*/
public function postProcessMembership($membershipParams, $contactID, &$form, &$premiumParams)
{
$tempParams = $membershipParams;
$paymentDone = false;
$result = null;
$isTest = CRM_Utils_Array::value('is_test', $membershipParams, false);
$form->assign('membership_assign', true);
$form->set('membershipTypeID', $membershipParams['selectMembership']);
require_once 'CRM/Member/BAO/MembershipType.php';
require_once 'CRM/Member/BAO/Membership.php';
$membershipTypeID = $membershipParams['selectMembership'];
$membershipDetails = self::buildMembershipTypeValues($form, $membershipTypeID);
$form->assign('membership_name', $membershipDetails['name']);
$minimumFee = CRM_Utils_Array::value('minimum_fee', $membershipDetails);
$contributionTypeId = null;
if ($form->_values['amount_block_is_active']) {
$contributionTypeId = $form->_values['contribution_type_id'];
} else {
$paymentDone = true;
$params['amount'] = $minimumFee;
$contributionTypeId = $membershipDetails['contribution_type_id'];
}
//amount must be greater than zero for
//adding contribution record to contribution table.
//this condition is arises when separate membership payment is
//enable and contribution amount is not selected. fix for CRM-3010
require_once 'CRM/Contribute/BAO/Contribution/Utils.php';
if ($form->_amount > 0.0) {
$result = CRM_Contribute_BAO_Contribution_Utils::processConfirm($form, $membershipParams, $premiumParams, $contactID, $contributionTypeId, 'membership');
} else {
// create the CMS contact here since we normally do this under processConfirm
CRM_Contribute_BAO_Contribution_Utils::createCMSUser($membershipParams, $membershipParams['cms_contactID'], 'email-' . $form->_bltID);
}
$errors = array();
if (is_a($result[1], 'CRM_Core_Error')) {
$errors[1] = CRM_Core_Error::getMessages($result[1]);
} else {
$contribution[1] = $result[1];
}
$memBlockDetails = CRM_Member_BAO_Membership::getMembershipBlock($form->_id);
if ($memBlockDetails['is_separate_payment'] && !$paymentDone) {
require_once 'CRM/Contribute/DAO/ContributionType.php';
$contributionType = new CRM_Contribute_DAO_ContributionType();
$contributionType->id = $membershipDetails['contribution_type_id'];
if (!$contributionType->find(true)) {
CRM_Core_Error::fatal("Could not find a system table");
}
$tempParams['amount'] = $minimumFee;
$invoiceID = md5(uniqid(rand(), true));
$tempParams['invoiceID'] = $invoiceID;
//we don't allow recurring membership.CRM-3781.
if (CRM_Utils_Array::value('is_recur', $tempParams)) {
$tempParams['is_recur'] = 0;
}
$result = null;
if ($form->_values['is_monetary'] && !$form->_params['is_pay_later']) {
require_once 'CRM/Core/Payment.php';
$payment =& CRM_Core_Payment::singleton($form->_mode, $form->_paymentProcessor, $form);
if ($form->_contributeMode == 'express') {
$result =& $payment->doExpressCheckout($tempParams);
} else {
$result =& $payment->doDirectPayment($tempParams);
}
}
if (is_a($result, 'CRM_Core_Error')) {
$errors[2] = CRM_Core_Error::getMessages($result);
} else {
//assign receive date when separate membership payment
//and contribution amount not selected.
if ($form->_amount == 0) {
$now = date('YmdHis');
$form->_params['receive_date'] = $now;
$receiveDate = CRM_Utils_Date::mysqlToIso($now);
$form->set('params', $form->_params);
$form->assign('receive_date', $receiveDate);
}
$form->set('membership_trx_id', $result['trxn_id']);
$form->set('membership_amount', $minimumFee);
$form->assign('membership_trx_id', $result['trxn_id']);
$form->assign('membership_amount', $minimumFee);
// we dont need to create the user twice, so lets disable cms_create_account
// irrespective of the value, CRM-2888
$tempParams['cms_create_account'] = 0;
$pending = $form->_params['is_pay_later'] ? true : false;
//set this variable as we are not creating pledge for
//separate membership payment contribution.
//so for differentiating membership contributon from
//main contribution.
$form->_params['separate_membership_payment'] = 1;
$contribution[2] = CRM_Contribute_Form_Contribution_Confirm::processContribution($form, $tempParams, $result, $contactID, $contributionType, false, $pending);
//.........这里部分代码省略.........