本文整理汇总了PHP中CRM_Contribute_BAO_ContributionSoft::getSoftContribution方法的典型用法代码示例。如果您正苦于以下问题:PHP CRM_Contribute_BAO_ContributionSoft::getSoftContribution方法的具体用法?PHP CRM_Contribute_BAO_ContributionSoft::getSoftContribution怎么用?PHP CRM_Contribute_BAO_ContributionSoft::getSoftContribution使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类CRM_Contribute_BAO_ContributionSoft
的用法示例。
在下文中一共展示了CRM_Contribute_BAO_ContributionSoft::getSoftContribution方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: buildQuickForm
/**
* Function used to build form element for soft credit block
*
* @param object $form form object
* @access public
*
* @return void
*/
static function buildQuickForm(&$form)
{
$prefix = 'soft_credit_';
// by default generate 5 blocks
$item_count = 6;
$showSoftCreditRow = 2;
$showCreateNew = TRUE;
if ($form->_action & CRM_Core_Action::UPDATE) {
$form->_softCreditInfo = CRM_Contribute_BAO_ContributionSoft::getSoftContribution($form->_id, TRUE);
if (!empty($form->_softCreditInfo['soft_credit'])) {
$showSoftCreditRow = count($form->_softCreditInfo['soft_credit']);
$showSoftCreditRow++;
$showCreateNew = FALSE;
}
}
for ($rowNumber = 1; $rowNumber <= $item_count; $rowNumber++) {
CRM_Contact_Form_NewContact::buildQuickForm($form, $rowNumber, NULL, FALSE, $prefix);
$form->addMoney("{$prefix}amount[{$rowNumber}]", ts('Amount'), FALSE, NULL, FALSE);
if (!empty($form->_softCreditInfo['soft_credit'][$rowNumber]['soft_credit_id'])) {
$form->add('hidden', "{$prefix}id[{$rowNumber}]", $form->_softCreditInfo['soft_credit'][$rowNumber]['soft_credit_id']);
}
}
// CRM-7368 allow user to set or edit PCP link for contributions
$siteHasPCPs = CRM_Contribute_PseudoConstant::pcPage();
if (!CRM_Utils_Array::crmIsEmptyArray($siteHasPCPs)) {
$form->assign('siteHasPCPs', 1);
$pcpDataUrl = CRM_Utils_System::url('civicrm/ajax/rest', 'className=CRM_Contact_Page_AJAX&fnName=getPCPList&json=1&context=contact&reset=1', FALSE, NULL, FALSE);
$form->assign('pcpDataUrl', $pcpDataUrl);
$form->addElement('text', 'pcp_made_through', ts('Credit to a Personal Campaign Page'));
$form->addElement('hidden', 'pcp_made_through_id', '', array('id' => 'pcp_made_through_id'));
$form->addElement('checkbox', 'pcp_display_in_roll', ts('Display in Honor Roll?'), NULL);
$form->addElement('text', 'pcp_roll_nickname', ts('Name (for Honor Roll)'));
$form->addElement('textarea', 'pcp_personal_note', ts('Personal Note (for Honor Roll)'));
}
$form->assign('showSoftCreditRow', $showSoftCreditRow);
$form->assign('rowCount', $item_count);
$form->assign('showCreateNew', $showCreateNew);
// Tell tpl to hide soft credit field if contribution is linked directly to a PCP Page
if (CRM_Utils_Array::value('pcp_made_through_id', $form->_values)) {
$form->assign('pcpLinked', 1);
}
}
示例2: setDefaultValues
/**
* Set the default values.
*/
public function setDefaultValues()
{
// check if the user is registered and we have a contact ID
$contactID = $this->getContactID();
if (!empty($contactID)) {
$fields = array();
$removeCustomFieldTypes = array('Contribution', 'Membership');
$contribFields = CRM_Contribute_BAO_Contribution::getContributionFields();
// remove component related fields
foreach ($this->_fields as $name => $dontCare) {
//don't set custom data Used for Contribution (CRM-1344)
if (substr($name, 0, 7) == 'custom_') {
$id = substr($name, 7);
if (!CRM_Core_BAO_CustomGroup::checkCustomField($id, $removeCustomFieldTypes)) {
continue;
}
// ignore component fields
} elseif (array_key_exists($name, $contribFields) || substr($name, 0, 11) == 'membership_' || substr($name, 0, 13) == 'contribution_') {
continue;
}
$fields[$name] = 1;
}
if (!empty($fields)) {
CRM_Core_BAO_UFGroup::setProfileDefaults($contactID, $fields, $this->_defaults);
}
$billingDefaults = $this->getProfileDefaults('Billing', $contactID);
$this->_defaults = array_merge($this->_defaults, $billingDefaults);
}
if (!empty($this->_ccid) && !empty($this->_pendingAmount)) {
$this->_defaults['total_amount'] = CRM_Utils_Money::format($this->_pendingAmount, NULL, '%a');
}
/*
* hack to simplify credit card entry for testing
*
* $this->_defaults['credit_card_type'] = 'Visa';
* $this->_defaults['amount'] = 168;
* $this->_defaults['credit_card_number'] = '4111111111111111';
* $this->_defaults['cvv2'] = '000';
* $this->_defaults['credit_card_exp_date'] = array('Y' => date('Y')+1, 'M' => '05');
* // hack to simplify direct debit entry for testing
* $this->_defaults['account_holder'] = 'Max Müller';
* $this->_defaults['bank_account_number'] = '12345678';
* $this->_defaults['bank_identification_number'] = '12030000';
* $this->_defaults['bank_name'] = 'Bankname';
*/
//build set default for pledge overdue payment.
if (!empty($this->_values['pledge_id'])) {
//used to record completed pledge payment ids used later for honor default
$completedContributionIds = array();
$pledgePayments = CRM_Pledge_BAO_PledgePayment::getPledgePayments($this->_values['pledge_id']);
$paymentAmount = 0;
$duePayment = FALSE;
foreach ($pledgePayments as $payId => $value) {
if ($value['status'] == 'Overdue') {
$this->_defaults['pledge_amount'][$payId] = 1;
$paymentAmount += $value['scheduled_amount'];
} elseif (!$duePayment && $value['status'] == 'Pending') {
$this->_defaults['pledge_amount'][$payId] = 1;
$paymentAmount += $value['scheduled_amount'];
$duePayment = TRUE;
} elseif ($value['status'] == 'Completed' && $value['contribution_id']) {
$completedContributionIds[] = $value['contribution_id'];
}
}
$this->_defaults['price_' . $this->_priceSetId] = $paymentAmount;
if (count($completedContributionIds)) {
$softCredit = array();
foreach ($completedContributionIds as $id) {
$softCredit = CRM_Contribute_BAO_ContributionSoft::getSoftContribution($id);
}
if (isset($softCredit['soft_credit'])) {
$this->_defaults['soft_credit_type_id'] = $softCredit['soft_credit'][1]['soft_credit_type'];
//since honoree profile fieldname of fields are prefixed with 'honor'
//we need to reformat the fieldname to append prefix during setting default values
CRM_Core_BAO_UFGroup::setProfileDefaults($softCredit['soft_credit'][1]['contact_id'], CRM_Core_BAO_UFGroup::getFields($this->_honoreeProfileId), $defaults);
foreach ($defaults as $fieldName => $value) {
$this->_defaults['honor[' . $fieldName . ']'] = $value;
}
}
}
} elseif (!empty($this->_values['pledge_block_id'])) {
//set default to one time contribution.
$this->_defaults['is_pledge'] = 0;
}
// to process Custom data that are appended to URL
$getDefaults = CRM_Core_BAO_CustomGroup::extractGetParams($this, "'Contact', 'Individual', 'Contribution'");
$this->_defaults = array_merge($this->_defaults, $getDefaults);
$config = CRM_Core_Config::singleton();
// set default country from config if no country set
if (empty($this->_defaults["billing_country_id-{$this->_bltID}"])) {
$this->_defaults["billing_country_id-{$this->_bltID}"] = $config->defaultContactCountry;
}
// set default state/province from config if no state/province set
if (empty($this->_defaults["billing_state_province_id-{$this->_bltID}"])) {
$this->_defaults["billing_state_province_id-{$this->_bltID}"] = $config->defaultContactStateProvince;
}
$entityId = $memtypeID = NULL;
//.........这里部分代码省略.........
示例3: submit
//.........这里部分代码省略.........
unset($formValues[$key]);
}
}
$contribution = $this->processCreditCard($formValues, $lineItem, $this->_contactID);
foreach ($paramsSetByPaymentProcessingSubsystem as $key) {
$formValues[$key] = $contribution->{$key};
}
} else {
// Offline Contribution.
$submittedValues = $this->unsetCreditCardFields($submittedValues);
// get the required field value only.
$params = $ids = array();
$params['contact_id'] = $this->_contactID;
$params['currency'] = $this->getCurrency($submittedValues);
//format soft-credit/pcp param first
CRM_Contribute_BAO_ContributionSoft::formatSoftCreditParams($submittedValues, $this);
$params = array_merge($params, $submittedValues);
$fields = array('financial_type_id', 'contribution_status_id', 'payment_instrument_id', 'cancel_reason', 'source', 'check_number');
foreach ($fields as $f) {
$params[$f] = CRM_Utils_Array::value($f, $formValues);
}
// CRM-5740 if priceset is used, no need to cleanup money.
if ($priceSetId) {
$params['skipCleanMoney'] = 1;
}
$dates = array('receive_date', 'receipt_date', 'cancel_date');
foreach ($dates as $d) {
$params[$d] = CRM_Utils_Date::processDate($formValues[$d], $formValues[$d . '_time'], TRUE);
}
if (!empty($formValues['is_email_receipt'])) {
$params['receipt_date'] = date("Y-m-d");
}
if ($params['contribution_status_id'] == CRM_Core_OptionGroup::getValue('contribution_status', 'Cancelled', 'name') || $params['contribution_status_id'] == CRM_Core_OptionGroup::getValue('contribution_status', 'Refunded', 'name')) {
if (CRM_Utils_System::isNull(CRM_Utils_Array::value('cancel_date', $params))) {
$params['cancel_date'] = date('YmdHis');
}
} else {
$params['cancel_date'] = $params['cancel_reason'] = 'null';
}
// Set is_pay_later flag for back-office offline Pending status contributions CRM-8996
// else if contribution_status is changed to Completed is_pay_later flag is changed to 0, CRM-15041
if ($params['contribution_status_id'] == CRM_Core_OptionGroup::getValue('contribution_status', 'Pending', 'name')) {
$params['is_pay_later'] = 1;
} elseif ($params['contribution_status_id'] == CRM_Core_OptionGroup::getValue('contribution_status', 'Completed', 'name')) {
$params['is_pay_later'] = 0;
}
$ids['contribution'] = $params['id'] = $this->_id;
// Add Additional common information to formatted params.
CRM_Contribute_Form_AdditionalInfo::postProcessCommon($formValues, $params, $this);
if ($pId) {
$params['contribution_mode'] = 'participant';
$params['participant_id'] = $pId;
$params['skipLineItem'] = 1;
} elseif ($isRelatedId) {
$params['contribution_mode'] = 'membership';
}
$params['line_item'] = $lineItem;
$params['payment_processor_id'] = $params['payment_processor'] = CRM_Utils_Array::value('id', $this->_paymentProcessor);
if (isset($submittedValues['tax_amount'])) {
$params['tax_amount'] = $submittedValues['tax_amount'];
}
//create contribution.
if ($isQuickConfig) {
$params['is_quick_config'] = 1;
}
$params['non_deductible_amount'] = $this->calculateNonDeductibleAmount($params, $formValues);
// we are already handling note below, so to avoid duplicate notes against $contribution
if (!empty($params['note']) && !empty($submittedValues['note'])) {
unset($params['note']);
}
$contribution = CRM_Contribute_BAO_Contribution::create($params, $ids);
// process associated membership / participant, CRM-4395
if ($contribution->id && $action & CRM_Core_Action::UPDATE) {
$this->statusMessage[] = $this->updateRelatedComponent($contribution->id, $contribution->contribution_status_id, CRM_Utils_Array::value('contribution_status_id', $this->_values), $contribution->receive_date);
}
array_unshift($this->statusMessage, ts('The contribution record has been saved.'));
$this->invoicingPostProcessHook($submittedValues, $action, $lineItem);
//send receipt mail.
if ($contribution->id && !empty($formValues['is_email_receipt'])) {
$formValues['contact_id'] = $this->_contactID;
$formValues['contribution_id'] = $contribution->id;
$formValues += CRM_Contribute_BAO_ContributionSoft::getSoftContribution($contribution->id);
// to get 'from email id' for send receipt
$this->fromEmailId = $formValues['from_email_address'];
if (CRM_Contribute_Form_AdditionalInfo::emailReceipt($this, $formValues)) {
$this->statusMessage[] = ts('A receipt has been emailed to the contributor.');
}
}
$this->statusMessageTitle = ts('Saved');
}
if ($contribution->id && isset($formValues['product_name'][0])) {
CRM_Contribute_Form_AdditionalInfo::processPremium($submittedValues, $contribution->id, $this->_premiumID, $this->_options);
}
if ($contribution->id && !empty($submittedValues['note'])) {
CRM_Contribute_Form_AdditionalInfo::processNote($submittedValues, $this->_contactID, $contribution->id, $this->_noteID);
}
CRM_Core_Session::setStatus(implode(' ', $this->statusMessage), $this->statusMessageTitle, 'success');
CRM_Contribute_BAO_Contribution::updateRelatedPledge($action, $pledgePaymentID, $contribution->id, CRM_Utils_Array::value('option_type', $formValues) == 2 ? TRUE : FALSE, $formValues['total_amount'], CRM_Utils_Array::value('total_amount', $this->_defaults), $formValues['contribution_status_id'], CRM_Utils_Array::value('contribution_status_id', $this->_defaults));
return $contribution;
}
示例4: _assignMessageVariablesToTemplate
/**
* Apply variables for message to smarty template - this function is part of analysing what is in the huge
* function & breaking it down into manageable chunks. Eventually it will be refactored into something else
* Note we send directly from this function in some cases because it is only partly refactored
* Don't call this function directly as the signature will change
*
* @param $values
* @param $input
* @param CRM_Core_SMARTY $template
* @param bool $recur
* @param bool $returnMessageText
*
* @return mixed
*/
public function _assignMessageVariablesToTemplate(&$values, $input, &$template, $recur = FALSE, $returnMessageText = TRUE)
{
$template->assign('first_name', $this->_relatedObjects['contact']->first_name);
$template->assign('last_name', $this->_relatedObjects['contact']->last_name);
$template->assign('displayName', $this->_relatedObjects['contact']->display_name);
if (!empty($values['lineItem']) && !empty($this->_relatedObjects['membership'])) {
$template->assign('useForMember', TRUE);
}
//assign honor information to receipt message
$softRecord = CRM_Contribute_BAO_ContributionSoft::getSoftContribution($this->id);
if (isset($softRecord['soft_credit'])) {
//if id of contribution page is present
if (!empty($values['id'])) {
$values['honor'] = array('honor_profile_values' => array(), 'honor_profile_id' => CRM_Core_DAO::getFieldValue('CRM_Core_DAO_UFJoin', $values['id'], 'uf_group_id', 'entity_id'), 'honor_id' => $softRecord['soft_credit'][1]['contact_id']);
$softCreditTypes = CRM_Core_OptionGroup::values('soft_credit_type');
$template->assign('soft_credit_type', $softRecord['soft_credit'][1]['soft_credit_type_label']);
$template->assign('honor_block_is_active', CRM_Core_DAO::getFieldValue('CRM_Core_DAO_UFJoin', $values['id'], 'is_active', 'entity_id'));
} else {
//offline contribution
$softCreditTypes = $softCredits = array();
foreach ($softRecord['soft_credit'] as $key => $softCredit) {
$softCreditTypes[$key] = $softCredit['soft_credit_type_label'];
$softCredits[$key] = array('Name' => $softCredit['contact_name'], 'Amount' => CRM_Utils_Money::format($softCredit['amount'], $softCredit['currency']));
}
$template->assign('softCreditTypes', $softCreditTypes);
$template->assign('softCredits', $softCredits);
}
}
$dao = new CRM_Contribute_DAO_ContributionProduct();
$dao->contribution_id = $this->id;
if ($dao->find(TRUE)) {
$premiumId = $dao->product_id;
$template->assign('option', $dao->product_option);
$productDAO = new CRM_Contribute_DAO_Product();
$productDAO->id = $premiumId;
$productDAO->find(TRUE);
$template->assign('selectPremium', TRUE);
$template->assign('product_name', $productDAO->name);
$template->assign('price', $productDAO->price);
$template->assign('sku', $productDAO->sku);
}
$template->assign('title', CRM_Utils_Array::value('title', $values));
$amount = CRM_Utils_Array::value('total_amount', $input, CRM_Utils_Array::value('amount', $input), NULL);
if (empty($amount) && isset($this->total_amount)) {
$amount = $this->total_amount;
}
$template->assign('amount', $amount);
// add the new contribution values
if (strtolower($this->_component) == 'contribute') {
//PCP Info
$softDAO = new CRM_Contribute_DAO_ContributionSoft();
$softDAO->contribution_id = $this->id;
if ($softDAO->find(TRUE)) {
$template->assign('pcpBlock', TRUE);
$template->assign('pcp_display_in_roll', $softDAO->pcp_display_in_roll);
$template->assign('pcp_roll_nickname', $softDAO->pcp_roll_nickname);
$template->assign('pcp_personal_note', $softDAO->pcp_personal_note);
//assign the pcp page title for email subject
$pcpDAO = new CRM_PCP_DAO_PCP();
$pcpDAO->id = $softDAO->pcp_id;
if ($pcpDAO->find(TRUE)) {
$template->assign('title', $pcpDAO->title);
}
}
}
if ($this->financial_type_id) {
$values['financial_type_id'] = $this->financial_type_id;
}
$template->assign('trxn_id', $this->trxn_id);
$template->assign('receive_date', CRM_Utils_Date::mysqlToIso($this->receive_date));
$template->assign('contributeMode', 'notify');
$template->assign('action', $this->is_test ? 1024 : 1);
$template->assign('receipt_text', CRM_Utils_Array::value('receipt_text', $values));
$template->assign('is_monetary', 1);
$template->assign('is_recur', (bool) $recur);
$template->assign('currency', $this->currency);
$template->assign('address', CRM_Utils_Address::format($input));
if (!empty($values['customGroup'])) {
$template->assign('customGroup', $values['customGroup']);
}
if ($this->_component == 'event') {
$template->assign('title', $values['event']['title']);
$participantRoles = CRM_Event_PseudoConstant::participantRole();
$viewRoles = array();
foreach (explode(CRM_Core_DAO::VALUE_SEPARATOR, $this->_relatedObjects['participant']->role_id) as $k => $v) {
$viewRoles[] = $participantRoles[$v];
//.........这里部分代码省略.........
示例5: import
//.........这里部分代码省略.........
return CRM_Contribute_Import_Parser::PLEDGE_PAYMENT_ERROR;
}
return CRM_Import_Parser::ERROR;
}
if ($onDuplicate != CRM_Import_Parser::DUPLICATE_UPDATE) {
$formatted['custom'] = CRM_Core_BAO_CustomField::postProcess($formatted, NULL, 'Contribution');
} else {
//fix for CRM-2219 - Update Contribution
// onDuplicate == CRM_Import_Parser::DUPLICATE_UPDATE
if (!empty($paramValues['invoice_id']) || !empty($paramValues['trxn_id']) || !empty($paramValues['contribution_id'])) {
$dupeIds = array('id' => CRM_Utils_Array::value('contribution_id', $paramValues), 'trxn_id' => CRM_Utils_Array::value('trxn_id', $paramValues), 'invoice_id' => CRM_Utils_Array::value('invoice_id', $paramValues));
$ids['contribution'] = CRM_Contribute_BAO_Contribution::checkDuplicateIds($dupeIds);
if ($ids['contribution']) {
$formatted['id'] = $ids['contribution'];
$formatted['custom'] = CRM_Core_BAO_CustomField::postProcess($formatted, $formatted['id'], 'Contribution');
//process note
if (!empty($paramValues['note'])) {
$noteID = array();
$contactID = CRM_Core_DAO::getFieldValue('CRM_Contribute_DAO_Contribution', $ids['contribution'], 'contact_id');
$daoNote = new CRM_Core_BAO_Note();
$daoNote->entity_table = 'civicrm_contribution';
$daoNote->entity_id = $ids['contribution'];
if ($daoNote->find(TRUE)) {
$noteID['id'] = $daoNote->id;
}
$noteParams = array('entity_table' => 'civicrm_contribution', 'note' => $paramValues['note'], 'entity_id' => $ids['contribution'], 'contact_id' => $contactID);
CRM_Core_BAO_Note::add($noteParams, $noteID);
unset($formatted['note']);
}
//need to check existing soft credit contribution, CRM-3968
if (!empty($formatted['soft_credit'])) {
$dupeSoftCredit = array('contact_id' => $formatted['soft_credit'], 'contribution_id' => $ids['contribution']);
//Delete all existing soft Contribution from contribution_soft table for pcp_id is_null
$existingSoftCredit = CRM_Contribute_BAO_ContributionSoft::getSoftContribution($dupeSoftCredit['contribution_id']);
if (isset($existingSoftCredit['soft_credit']) && !empty($existingSoftCredit['soft_credit'])) {
foreach ($existingSoftCredit['soft_credit'] as $key => $existingSoftCreditValues) {
if (!empty($existingSoftCreditValues['soft_credit_id'])) {
$deleteParams = array('id' => $existingSoftCreditValues['soft_credit_id'], 'pcp_id' => NULL);
CRM_Contribute_BAO_ContributionSoft::del($deleteParams);
}
}
}
}
$newContribution = CRM_Contribute_BAO_Contribution::create($formatted, $ids);
$this->_newContributions[] = $newContribution->id;
//return soft valid since we need to show how soft credits were added
if (!empty($formatted['soft_credit'])) {
return CRM_Contribute_Import_Parser::SOFT_CREDIT;
}
// process pledge payment assoc w/ the contribution
return self::processPledgePayments($formatted);
return CRM_Import_Parser::VALID;
} else {
$labels = array('id' => 'Contribution ID', 'trxn_id' => 'Transaction ID', 'invoice_id' => 'Invoice ID');
foreach ($dupeIds as $k => $v) {
if ($v) {
$errorMsg[] = "{$labels[$k]} {$v}";
}
}
$errorMsg = implode(' AND ', $errorMsg);
array_unshift($values, 'Matching Contribution record not found for ' . $errorMsg . '. Row was skipped.');
return CRM_Import_Parser::ERROR;
}
}
}
if ($this->_contactIdIndex < 0) {
示例6: civicrm_api3_contribution_get
/**
* Retrieve a set of contributions.
*
* @param array $params
* Input parameters.
*
* @return array
* Array of contributions, if error an array with an error id and error message
*/
function civicrm_api3_contribution_get($params)
{
$mode = CRM_Contact_BAO_Query::MODE_CONTRIBUTE;
$returnProperties = CRM_Contribute_BAO_Query::defaultReturnProperties($mode);
$contributions = _civicrm_api3_get_using_query_object('Contribution', $params, array(), NULL, $mode, $returnProperties);
foreach ($contributions as $id => $contribution) {
$softContribution = CRM_Contribute_BAO_ContributionSoft::getSoftContribution($id, TRUE);
$contributions[$id] = array_merge($contribution, $softContribution);
// format soft credit for backward compatibility
_civicrm_api3_format_soft_credit($contributions[$id]);
}
return civicrm_api3_create_success($contributions, $params, 'Contribution', 'get');
}
示例7: preProcess
/**
* Set variables up before form is built.
*
* @return void
*/
public function preProcess()
{
$id = $this->get('id');
$values = $ids = array();
$params = array('id' => $id);
$context = CRM_Utils_Request::retrieve('context', 'String', $this);
$this->assign('context', $context);
CRM_Contribute_BAO_Contribution::getValues($params, $values, $ids);
CRM_Contribute_BAO_Contribution::resolveDefaults($values);
$cancelledStatus = TRUE;
$status = CRM_Contribute_PseudoConstant::contributionStatus(NULL, 'name');
if (CRM_Utils_Array::value('contribution_status_id', $values) == array_search('Cancelled', $status)) {
$cancelledStatus = FALSE;
}
$this->assign('cancelledStatus', $cancelledStatus);
if (!empty($values['contribution_page_id'])) {
$contribPages = CRM_Contribute_PseudoConstant::contributionPage(NULL, TRUE);
$values['contribution_page_title'] = CRM_Utils_Array::value(CRM_Utils_Array::value('contribution_page_id', $values), $contribPages);
}
// get recieved into i.e to_financial_account_id from last trxn
$financialTrxnId = CRM_Core_BAO_FinancialTrxn::getFinancialTrxnId($values['contribution_id'], 'DESC');
$values['to_financial_account'] = '';
if (!empty($financialTrxnId['financialTrxnId'])) {
$values['to_financial_account_id'] = CRM_Core_DAO::getFieldValue('CRM_Financial_DAO_FinancialTrxn', $financialTrxnId['financialTrxnId'], 'to_financial_account_id');
if ($values['to_financial_account_id']) {
$values['to_financial_account'] = CRM_Contribute_PseudoConstant::financialAccount($values['to_financial_account_id']);
}
$values['payment_processor_id'] = CRM_Core_DAO::getFieldValue('CRM_Financial_DAO_FinancialTrxn', $financialTrxnId['financialTrxnId'], 'payment_processor_id');
if ($values['payment_processor_id']) {
$values['payment_processor_name'] = CRM_Core_DAO::getFieldValue('CRM_Financial_DAO_PaymentProcessor', $values['payment_processor_id'], 'name');
}
}
if (!empty($values['contribution_recur_id'])) {
$sql = "SELECT installments, frequency_interval, frequency_unit FROM civicrm_contribution_recur WHERE id = %1";
$params = array(1 => array($values['contribution_recur_id'], 'Integer'));
$dao = CRM_Core_DAO::executeQuery($sql, $params);
if ($dao->fetch()) {
$values['recur_installments'] = $dao->installments;
$values['recur_frequency_unit'] = $dao->frequency_unit;
$values['recur_frequency_interval'] = $dao->frequency_interval;
}
}
$groupTree = CRM_Core_BAO_CustomGroup::getTree('Contribution', $this, $id, 0, CRM_Utils_Array::value('financial_type_id', $values));
CRM_Core_BAO_CustomGroup::buildCustomDataView($this, $groupTree);
$premiumId = NULL;
if ($id) {
$dao = new CRM_Contribute_DAO_ContributionProduct();
$dao->contribution_id = $id;
if ($dao->find(TRUE)) {
$premiumId = $dao->id;
$productID = $dao->product_id;
}
}
if ($premiumId) {
$productDAO = new CRM_Contribute_DAO_Product();
$productDAO->id = $productID;
$productDAO->find(TRUE);
$this->assign('premium', $productDAO->name);
$this->assign('option', $dao->product_option);
$this->assign('fulfilled', $dao->fulfilled_date);
}
// Get Note
$noteValue = CRM_Core_BAO_Note::getNote(CRM_Utils_Array::value('id', $values), 'civicrm_contribution');
$values['note'] = array_values($noteValue);
// show billing address location details, if exists
if (!empty($values['address_id'])) {
$addressParams = array('id' => CRM_Utils_Array::value('address_id', $values));
$addressDetails = CRM_Core_BAO_Address::getValues($addressParams, FALSE, 'id');
$addressDetails = array_values($addressDetails);
$values['billing_address'] = $addressDetails[0]['display'];
}
//assign soft credit record if exists.
$SCRecords = CRM_Contribute_BAO_ContributionSoft::getSoftContribution($values['contribution_id'], TRUE);
if (!empty($SCRecords['soft_credit'])) {
$this->assign('softContributions', $SCRecords['soft_credit']);
unset($SCRecords['soft_credit']);
}
//assign pcp record if exists
foreach ($SCRecords as $name => $value) {
$this->assign($name, $value);
}
$lineItems = array();
if ($id) {
$lineItem = CRM_Price_BAO_LineItem::getLineItems($id, 'contribution', 1, TRUE, TRUE);
if (!empty($lineItem)) {
$lineItems[] = $lineItem;
}
}
$this->assign('lineItem', empty($lineItems) ? FALSE : $lineItems);
$values['totalAmount'] = $values['total_amount'];
//do check for campaigns
if ($campaignId = CRM_Utils_Array::value('campaign_id', $values)) {
$campaigns = CRM_Campaign_BAO_Campaign::getCampaigns($campaignId);
$values['campaign'] = $campaigns[$campaignId];
}
//.........这里部分代码省略.........
示例8: postProcess
//.........这里部分代码省略.........
if ($this->_action & CRM_Core_Action::ADD) {
$line = $lineItem;
} elseif ($this->_action & CRM_Core_Action::UPDATE) {
$line = $this->_lineItems;
}
foreach ($line as $key => $value) {
foreach ($value as $v) {
if (isset($taxRate[(string) CRM_Utils_Array::value('tax_rate', $v)])) {
$taxRate[(string) $v['tax_rate']] = $taxRate[(string) $v['tax_rate']] + CRM_Utils_Array::value('tax_amount', $v);
} else {
if (isset($v['tax_rate'])) {
$taxRate[(string) $v['tax_rate']] = CRM_Utils_Array::value('tax_amount', $v);
$getTaxDetails = TRUE;
}
}
}
}
}
if ($invoicing) {
if ($this->_action & CRM_Core_Action::UPDATE) {
if (isset($submittedValues['tax_amount'])) {
$totalTaxAmount = $submittedValues['tax_amount'];
} else {
$totalTaxAmount = $this->_values['tax_amount'];
}
$this->assign('totalTaxAmount', $totalTaxAmount);
$this->assign('dataArray', $taxRate);
} else {
if (!empty($submittedValues['price_set_id'])) {
$this->assign('totalTaxAmount', $submittedValues['tax_amount']);
$this->assign('getTaxDetails', $getTaxDetails);
$this->assign('dataArray', $taxRate);
$this->assign('taxTerm', CRM_Utils_Array::value('tax_term', $invoiceSettings));
} else {
$this->assign('totalTaxAmount', CRM_Utils_Array::value('tax_amount', $submittedValues));
}
}
}
//send receipt mail.
if ($contribution->id && !empty($formValues['is_email_receipt'])) {
$formValues['contact_id'] = $this->_contactID;
$formValues['contribution_id'] = $contribution->id;
$formValues += CRM_Contribute_BAO_ContributionSoft::getSoftContribution($contribution->id);
// to get 'from email id' for send receipt
$this->fromEmailId = $formValues['from_email_address'];
$sendReceipt = CRM_Contribute_Form_AdditionalInfo::emailReceipt($this, $formValues);
}
$pledgePaymentId = CRM_Core_DAO::getFieldValue('CRM_Pledge_DAO_PledgePayment', $contribution->id, 'id', 'contribution_id');
//update pledge payment status.
if ($this->_ppID && $contribution->id && $this->_action & CRM_Core_Action::ADD || $pledgePaymentId && $this->_action & CRM_Core_Action::UPDATE) {
if ($this->_ppID) {
//store contribution id in payment record.
CRM_Core_DAO::setFieldValue('CRM_Pledge_DAO_PledgePayment', $this->_ppID, 'contribution_id', $contribution->id);
} else {
$this->_ppID = CRM_Core_DAO::getFieldValue('CRM_Pledge_DAO_PledgePayment', $contribution->id, 'id', 'contribution_id');
$this->_pledgeID = CRM_Core_DAO::getFieldValue('CRM_Pledge_DAO_PledgePayment', $contribution->id, 'pledge_id', 'contribution_id');
}
$adjustTotalAmount = FALSE;
if (CRM_Utils_Array::value('option_type', $formValues) == 2) {
$adjustTotalAmount = TRUE;
}
$updatePledgePaymentStatus = FALSE;
//do only if either the status or the amount has changed
if ($this->_action & CRM_Core_Action::ADD) {
$updatePledgePaymentStatus = TRUE;
} elseif ($this->_action & CRM_Core_Action::UPDATE && ($this->_defaults['contribution_status_id'] != $formValues['contribution_status_id'] || $this->_defaults['total_amount'] != $formValues['total_amount'])) {
$updatePledgePaymentStatus = TRUE;
}
if ($updatePledgePaymentStatus) {
CRM_Pledge_BAO_PledgePayment::updatePledgePaymentStatus($this->_pledgeID, array($this->_ppID), $contribution->contribution_status_id, NULL, $contribution->total_amount, $adjustTotalAmount);
}
}
$statusMsg = ts('The contribution record has been saved.');
if (!empty($formValues['is_email_receipt']) && $sendReceipt) {
$statusMsg .= ' ' . ts('A receipt has been emailed to the contributor.');
}
if ($relatedComponentStatusMsg) {
$statusMsg .= ' ' . $relatedComponentStatusMsg;
}
CRM_Core_Session::setStatus($statusMsg, ts('Saved'), 'success');
//Offline Contribution ends.
}
$session = CRM_Core_Session::singleton();
$buttonName = $this->controller->getButtonName();
if ($this->_context == 'standalone') {
if ($buttonName == $this->getButtonName('upload', 'new')) {
$session->replaceUserContext(CRM_Utils_System::url('civicrm/contribute/add', 'reset=1&action=add&context=standalone'));
} else {
$session->replaceUserContext(CRM_Utils_System::url('civicrm/contact/view', "reset=1&cid={$this->_contactID}&selectedChild=contribute"));
}
} elseif ($this->_context == 'contribution' && $this->_mode && $buttonName == $this->getButtonName('upload', 'new')) {
$session->replaceUserContext(CRM_Utils_System::url('civicrm/contact/view/contribution', "reset=1&action=add&context={$this->_context}&cid={$this->_contactID}&mode={$this->_mode}"));
} elseif ($buttonName == $this->getButtonName('upload', 'new')) {
$session->replaceUserContext(CRM_Utils_System::url('civicrm/contact/view/contribution', "reset=1&action=add&context={$this->_context}&cid={$this->_contactID}"));
}
//store contribution ID if not yet set (on create)
if (empty($this->_id) && !empty($contribution->id)) {
$this->_id = $contribution->id;
}
}
示例9: civicrm_api3_contribution_get
/**
* Retrieve a set of contributions.
*
* @param array $params
* Input parameters.
*
* @return array
* Array of contributions, if error an array with an error id and error message
*/
function civicrm_api3_contribution_get($params)
{
$mode = CRM_Contact_BAO_Query::MODE_CONTRIBUTE;
list($dao, $query) = _civicrm_api3_get_query_object($params, $mode, 'Contribution');
$contribution = array();
while ($dao->fetch()) {
//CRM-8662
$contribution_details = $query->store($dao);
$softContribution = CRM_Contribute_BAO_ContributionSoft::getSoftContribution($dao->contribution_id, TRUE);
$contribution[$dao->contribution_id] = array_merge($contribution_details, $softContribution);
// format soft credit for backward compatibility
_civicrm_api3_format_soft_credit($contribution[$dao->contribution_id]);
}
return civicrm_api3_create_success($contribution, $params, 'Contribution', 'get', $dao);
}
示例10: processContribution
//.........这里部分代码省略.........
if (!empty($params['pcp_roll_nickname'][$key])) {
$value['pcp']['pcp_roll_nickname'] = $params['pcp_roll_nickname'][$key];
}
if (!empty($params['pcp_personal_note'][$key])) {
$value['pcp']['pcp_personal_note'] = $params['pcp_personal_note'][$key];
}
}
$value['custom'] = CRM_Core_BAO_CustomField::postProcess($value, NULL, 'Contribution');
foreach ($dates as $val) {
if (!empty($value[$val])) {
$value[$val] = CRM_Utils_Date::processDate($value[$val], $value[$val . '_time'], TRUE);
}
}
if (!empty($value['send_receipt'])) {
$value['receipt_date'] = date('Y-m-d His');
}
// these translations & date handling are required because we are calling BAO directly rather than the api
$fieldTranslations = array('financial_type' => 'financial_type_id', 'payment_instrument' => 'payment_instrument_id', 'contribution_source' => 'source', 'contribution_note' => 'note');
foreach ($fieldTranslations as $formField => $baoField) {
if (isset($value[$formField])) {
$value[$baoField] = $value[$formField];
}
unset($value[$formField]);
}
$params['actualBatchTotal'] += $value['total_amount'];
$value['batch_id'] = $this->_batchId;
$value['skipRecentView'] = TRUE;
// build line item params
$this->_priceSet['fields'][$priceFieldID]['options'][$priceFieldValueID]['amount'] = $value['total_amount'];
$value['price_' . $priceFieldID] = 1;
$lineItem = array();
CRM_Price_BAO_PriceSet::processAmount($this->_priceSet['fields'], $value, $lineItem[$priceSetId]);
// @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.
unset($value['amount_level']);
//CRM-11529 for back office transactions
//when financial_type_id is passed in form, update the
//line items with the financial type selected in form
// @todo - create a price set or price field per financial type & simply choose the appropriate
// price field rather than working around the fact that each price_field is supposed to have a financial
// type & we are allowing that to be overridden.
if (!empty($value['financial_type_id']) && !empty($lineItem[$priceSetId])) {
foreach ($lineItem[$priceSetId] as &$values) {
$values['financial_type_id'] = $value['financial_type_id'];
}
}
$value['line_item'] = $lineItem;
//finally call contribution create for all the magic
$contribution = CRM_Contribute_BAO_Contribution::create($value, CRM_Core_DAO::$_nullArray);
$batchTypes = CRM_Core_Pseudoconstant::get('CRM_Batch_DAO_Batch', 'type_id', array('flip' => 1), 'validate');
if (!empty($this->_batchInfo['type_id']) && $this->_batchInfo['type_id'] == $batchTypes['Pledge Payment']) {
$adjustTotalAmount = FALSE;
if (isset($params['option_type'][$key])) {
if ($params['option_type'][$key] == 2) {
$adjustTotalAmount = TRUE;
}
}
$pledgeId = $params['open_pledges'][$key];
if (is_numeric($pledgeId)) {
$result = CRM_Pledge_BAO_PledgePayment::getPledgePayments($pledgeId);
$pledgePaymentId = 0;
foreach ($result as $key => $values) {
if ($values['status'] != 'Completed') {
$pledgePaymentId = $values['id'];
break;
}
}
CRM_Core_DAO::setFieldValue('CRM_Pledge_DAO_PledgePayment', $pledgePaymentId, 'contribution_id', $contribution->id);
CRM_Pledge_BAO_PledgePayment::updatePledgePaymentStatus($pledgeId, array($pledgePaymentId), $contribution->contribution_status_id, NULL, $contribution->total_amount, $adjustTotalAmount);
}
}
//process premiums
if (!empty($value['product_name'])) {
if ($value['product_name'][0] > 0) {
list($products, $options) = CRM_Contribute_BAO_Premium::getPremiumProductInfo();
$value['hidden_Premium'] = 1;
$value['product_option'] = CRM_Utils_Array::value($value['product_name'][1], $options[$value['product_name'][0]]);
$premiumParams = array('product_id' => $value['product_name'][0], 'contribution_id' => $contribution->id, 'product_option' => $value['product_option'], 'quantity' => 1);
CRM_Contribute_BAO_Contribution::addPremium($premiumParams);
}
}
// end of premium
//send receipt mail.
if ($contribution->id && !empty($value['send_receipt'])) {
// add the domain email id
$domainEmail = CRM_Core_BAO_Domain::getNameAndEmail();
$domainEmail = "{$domainEmail['0']} <{$domainEmail['1']}>";
$value['from_email_address'] = $domainEmail;
$value['contribution_id'] = $contribution->id;
if (!empty($value['soft_credit'])) {
$value = array_merge($value, CRM_Contribute_BAO_ContributionSoft::getSoftContribution($contribution->id));
}
CRM_Contribute_Form_AdditionalInfo::emailReceipt($this, $value);
}
}
}
return TRUE;
}
示例11: buildQuickForm
/**
* Function used to build form element for soft credit block.
*
* @param CRM_Core_Form $form
*
* @return void
*/
public static function buildQuickForm(&$form)
{
if (!empty($form->_honor_block_is_active)) {
$ufJoinDAO = new CRM_Core_DAO_UFJoin();
$ufJoinDAO->module = 'soft_credit';
$ufJoinDAO->entity_id = $form->_id;
if ($ufJoinDAO->find(TRUE)) {
$jsonData = CRM_Contribute_BAO_ContributionPage::formatMultilingualHonorParams($ufJoinDAO->module_data, TRUE);
if ($jsonData) {
foreach (array('honor_block_title', 'honor_block_text') as $name) {
$form->assign($name, $jsonData[$name]);
}
$softCreditTypes = CRM_Core_OptionGroup::values("soft_credit_type", FALSE);
// radio button for Honor Type
foreach ($jsonData['soft_credit_types'] as $value) {
$honorTypes[$value] = $form->createElement('radio', NULL, NULL, $softCreditTypes[$value], $value);
}
$form->addGroup($honorTypes, 'soft_credit_type_id', NULL)->setAttribute('allowClear', TRUE);
}
}
return $form;
}
// by default generate 10 blocks
$item_count = 11;
$showSoftCreditRow = 2;
if ($form->getAction() & CRM_Core_Action::UPDATE) {
$form->_softCreditInfo = CRM_Contribute_BAO_ContributionSoft::getSoftContribution($form->_id, TRUE);
} elseif (!empty($form->_pledgeID)) {
//Check and select most recent completed contrubtion and use it to retrieve
//soft-credit information to use as default for current pledge payment, CRM-13981
$pledgePayments = CRM_Pledge_BAO_PledgePayment::getPledgePayments($form->_pledgeID);
foreach ($pledgePayments as $id => $record) {
if ($record['contribution_id']) {
$softCredits = CRM_Contribute_BAO_ContributionSoft::getSoftContribution($record['contribution_id'], TRUE);
if ($record['status'] == 'Completed' && count($softCredits) > 0) {
$form->_softCreditInfo = $softCredits;
}
}
}
}
if (property_exists($form, "_softCreditInfo")) {
if (!empty($form->_softCreditInfo['soft_credit'])) {
$showSoftCreditRow = count($form->_softCreditInfo['soft_credit']);
$showSoftCreditRow++;
}
}
for ($rowNumber = 1; $rowNumber <= $item_count; $rowNumber++) {
$form->addEntityRef("soft_credit_contact_id[{$rowNumber}]", ts('Contact'), array('create' => TRUE));
$form->addMoney("soft_credit_amount[{$rowNumber}]", ts('Amount'), FALSE, NULL, FALSE);
$form->addSelect("soft_credit_type[{$rowNumber}]", array('entity' => 'contribution_soft', 'field' => 'soft_credit_type_id', 'label' => ts('Type')));
if (!empty($form->_softCreditInfo['soft_credit'][$rowNumber]['soft_credit_id'])) {
$form->add('hidden', "soft_credit_id[{$rowNumber}]", $form->_softCreditInfo['soft_credit'][$rowNumber]['soft_credit_id']);
}
}
// CRM-7368 allow user to set or edit PCP link for contributions
$siteHasPCPs = CRM_Contribute_PseudoConstant::pcPage();
if (!CRM_Utils_Array::crmIsEmptyArray($siteHasPCPs)) {
$form->assign('siteHasPCPs', 1);
// Fixme: Not a true entityRef field. Relies on PCP.js.tpl
$form->add('text', 'pcp_made_through_id', ts('Credit to a Personal Campaign Page'), array('class' => 'twenty', 'placeholder' => ts('- select -')));
// stores the label
$form->add('hidden', 'pcp_made_through');
$form->addElement('checkbox', 'pcp_display_in_roll', ts('Display in Honor Roll?'), NULL);
$form->addElement('text', 'pcp_roll_nickname', ts('Name (for Honor Roll)'));
$form->addElement('textarea', 'pcp_personal_note', ts('Personal Note (for Honor Roll)'));
}
$form->assign('showSoftCreditRow', $showSoftCreditRow);
$form->assign('rowCount', $item_count);
$form->addElement('hidden', 'sct_default_id', CRM_Core_OptionGroup::getDefaultValue("soft_credit_type"), array('id' => 'sct_default_id'));
}
示例12: submit
//.........这里部分代码省略.........
unset($formValues[$key]);
}
}
$contribution = $this->processCreditCard($formValues, $lineItem, $this->_contactID);
foreach ($paramsSetByPaymentProcessingSubsystem as $key) {
$formValues[$key] = $contribution->{$key};
}
} else {
// Offline Contribution.
$submittedValues = $this->unsetCreditCardFields($submittedValues);
// get the required field value only.
$params = $ids = array();
$params['contact_id'] = $this->_contactID;
$params['currency'] = $this->getCurrency($submittedValues);
$fields = array('financial_type_id', 'contribution_status_id', 'payment_instrument_id', 'cancel_reason', 'source', 'check_number');
foreach ($fields as $f) {
$params[$f] = CRM_Utils_Array::value($f, $formValues);
}
if (!empty($pcp)) {
$params['pcp'] = $pcp;
}
if (!empty($softParams)) {
$params['soft_credit'] = $softParams;
$params['soft_credit_ids'] = $softIDs;
}
// CRM-5740 if priceset is used, no need to cleanup money.
if ($priceSetId) {
$params['skipCleanMoney'] = 1;
}
$dates = array('receive_date', 'receipt_date', 'cancel_date');
foreach ($dates as $d) {
$params[$d] = CRM_Utils_Date::processDate($formValues[$d], $formValues[$d . '_time'], TRUE);
}
if (!empty($formValues['is_email_receipt'])) {
$params['receipt_date'] = date("Y-m-d");
}
if ($params['contribution_status_id'] == CRM_Core_OptionGroup::getValue('contribution_status', 'Cancelled', 'name') || $params['contribution_status_id'] == CRM_Core_OptionGroup::getValue('contribution_status', 'Refunded', 'name')) {
if (CRM_Utils_System::isNull(CRM_Utils_Array::value('cancel_date', $params))) {
$params['cancel_date'] = date('Y-m-d');
}
} else {
$params['cancel_date'] = $params['cancel_reason'] = 'null';
}
// Set is_pay_later flag for back-office offline Pending status contributions CRM-8996
// else if contribution_status is changed to Completed is_pay_later flag is changed to 0, CRM-15041
if ($params['contribution_status_id'] == CRM_Core_OptionGroup::getValue('contribution_status', 'Pending', 'name')) {
$params['is_pay_later'] = 1;
} elseif ($params['contribution_status_id'] == CRM_Core_OptionGroup::getValue('contribution_status', 'Completed', 'name')) {
$params['is_pay_later'] = 0;
}
$ids['contribution'] = $params['id'] = $this->_id;
// Add Additional common information to formatted params.
CRM_Contribute_Form_AdditionalInfo::postProcessCommon($formValues, $params, $this);
if ($pId) {
$params['contribution_mode'] = 'participant';
$params['participant_id'] = $pId;
$params['skipLineItem'] = 1;
} elseif ($isRelatedId) {
$params['contribution_mode'] = 'membership';
}
$params['line_item'] = $lineItem;
$params['payment_processor_id'] = $params['payment_processor'] = CRM_Utils_Array::value('id', $this->_paymentProcessor);
if (isset($submittedValues['tax_amount'])) {
$params['tax_amount'] = $submittedValues['tax_amount'];
}
//create contribution.
if ($isQuickConfig) {
$params['is_quick_config'] = 1;
}
$params['non_deductible_amount'] = $this->calculateNonDeductibleAmount($params, $formValues);
$contribution = CRM_Contribute_BAO_Contribution::create($params, $ids);
// process associated membership / participant, CRM-4395
if ($contribution->id && $action & CRM_Core_Action::UPDATE) {
$this->statusMessage[] = $this->updateRelatedComponent($contribution->id, $contribution->contribution_status_id, CRM_Utils_Array::value('contribution_status_id', $this->_values), $contribution->receive_date);
}
array_unshift($this->statusMessage, ts('The contribution record has been saved.'));
$this->invoicingPostProcessHook($submittedValues, $action, $lineItem);
//send receipt mail.
if ($contribution->id && !empty($formValues['is_email_receipt'])) {
$formValues['contact_id'] = $this->_contactID;
$formValues['contribution_id'] = $contribution->id;
$formValues += CRM_Contribute_BAO_ContributionSoft::getSoftContribution($contribution->id);
// to get 'from email id' for send receipt
$this->fromEmailId = $formValues['from_email_address'];
if (CRM_Contribute_Form_AdditionalInfo::emailReceipt($this, $formValues)) {
$this->statusMessage[] = ts('A receipt has been emailed to the contributor.');
}
}
$this->statusMessageTitle = ts('Saved');
}
if ($contribution->id && !empty($formValues['product_name'][0])) {
CRM_Contribute_Form_AdditionalInfo::processPremium($submittedValues, $contribution->id, $this->_premiumID, $this->_options);
}
if ($contribution->id && isset($submittedValues['note'])) {
CRM_Contribute_Form_AdditionalInfo::processNote($submittedValues, $this->_contactID, $contribution->id, $this->_noteID);
}
CRM_Core_Session::setStatus(implode(' ', $this->statusMessage), $this->statusMessageTitle, 'success');
CRM_Contribute_BAO_Contribution::updateRelatedPledge($action, $pledgePaymentID, $contribution->id, CRM_Utils_Array::value('option_type', $formValues) == 2 ? TRUE : FALSE, $formValues['total_amount'], CRM_Utils_Array::value('total_amount', $this->_defaults), $formValues['contribution_status_id'], CRM_Utils_Array::value('contribution_status_id', $this->_defaults));
return $contribution;
}
示例13: buildQuickForm
/**
* Function used to build form element for soft credit block
*
* @param object $form form object
* @access public
*
* @return void
*/
static function buildQuickForm(&$form)
{
if ($form->_mode == 'live' && !empty($form->_values['honor_block_is_active'])) {
$ufJoinDAO = new CRM_Core_DAO_UFJoin();
$ufJoinDAO->module = 'soft_credit';
$ufJoinDAO->entity_id = $form->_id;
if ($ufJoinDAO->find(TRUE)) {
$jsonData = json_decode($ufJoinDAO->module_data);
if ($jsonData) {
$form->assign('honor_block_title', $jsonData->soft_credit->honor_block_title);
$form->assign('honor_block_text', $jsonData->soft_credit->honor_block_text);
$softCreditTypes = CRM_Core_OptionGroup::values("soft_credit_type", FALSE);
$extraOption = array('onclick' => "enableHonorType();");
// radio button for Honor Type
foreach ($jsonData->soft_credit->soft_credit_types as $value) {
$honorTypes[$value] = $form->createElement('radio', NULL, NULL, $softCreditTypes[$value], $value, $extraOption);
}
$form->addGroup($honorTypes, 'soft_credit_type_id', NULL);
}
}
return $form;
}
$prefix = 'soft_credit_';
// by default generate 5 blocks
$item_count = 6;
$showSoftCreditRow = 2;
$showCreateNew = TRUE;
if ($form->_action & CRM_Core_Action::UPDATE) {
$form->_softCreditInfo = CRM_Contribute_BAO_ContributionSoft::getSoftContribution($form->_id, TRUE);
} elseif ($form->_pledgeID) {
//Check and select most recent completed contrubtion and use it to retrieve
//soft-credit information to use as default for current pledge payment, CRM-13981
$pledgePayments = CRM_Pledge_BAO_PledgePayment::getPledgePayments($form->_pledgeID);
foreach ($pledgePayments as $id => $record) {
if ($record['contribution_id']) {
$softCredits = CRM_Contribute_BAO_ContributionSoft::getSoftContribution($record['contribution_id'], TRUE);
if ($record['status'] == 'Completed' && count($softCredits) > 0) {
$form->_softCreditInfo = $softCredits;
}
}
}
}
if (property_exists($form, "_softCreditInfo")) {
if (!empty($form->_softCreditInfo['soft_credit'])) {
$showSoftCreditRow = count($form->_softCreditInfo['soft_credit']);
$showSoftCreditRow++;
$showCreateNew = FALSE;
}
}
for ($rowNumber = 1; $rowNumber <= $item_count; $rowNumber++) {
CRM_Contact_Form_NewContact::buildQuickForm($form, $rowNumber, NULL, FALSE, $prefix);
$form->addMoney("{$prefix}amount[{$rowNumber}]", ts('Amount'), FALSE, NULL, FALSE);
$form->add('select', "{$prefix}type[{$rowNumber}]", ts('Soft Credit Type'), array('' => ts('- select -')) + CRM_Core_OptionGroup::values("{$prefix}type", FALSE));
if (!empty($form->_softCreditInfo['soft_credit'][$rowNumber]['soft_credit_id'])) {
$form->add('hidden', "{$prefix}id[{$rowNumber}]", $form->_softCreditInfo['soft_credit'][$rowNumber]['soft_credit_id']);
}
}
// CRM-7368 allow user to set or edit PCP link for contributions
$siteHasPCPs = CRM_Contribute_PseudoConstant::pcPage();
if (!CRM_Utils_Array::crmIsEmptyArray($siteHasPCPs)) {
$form->assign('siteHasPCPs', 1);
$pcpDataUrl = CRM_Utils_System::url('civicrm/ajax/rest', 'className=CRM_Contact_Page_AJAX&fnName=getPCPList&json=1&context=contact&reset=1', FALSE, NULL, FALSE);
$form->assign('pcpDataUrl', $pcpDataUrl);
$form->addElement('text', 'pcp_made_through', ts('Credit to a Personal Campaign Page'));
$form->addElement('hidden', 'pcp_made_through_id', '', array('id' => 'pcp_made_through_id'));
$form->addElement('checkbox', 'pcp_display_in_roll', ts('Display in Honor Roll?'), NULL);
$form->addElement('text', 'pcp_roll_nickname', ts('Name (for Honor Roll)'));
$form->addElement('textarea', 'pcp_personal_note', ts('Personal Note (for Honor Roll)'));
}
$form->assign('showSoftCreditRow', $showSoftCreditRow);
$form->assign('rowCount', $item_count);
$form->assign('showCreateNew', $showCreateNew);
$form->addElement('hidden', 'sct_default_id', CRM_Core_OptionGroup::getDefaultValue("{$prefix}type"), array('id' => 'sct_default_id'));
// Tell tpl to hide soft credit field if contribution is linked directly to a PCP Page
if (!empty($form->_values['pcp_made_through_id'])) {
$form->assign('pcpLinked', 1);
}
}
示例14: civicrm_api3_contribution_get
/**
* Retrieve a set of contributions, given a set of input params
*
* @param array $params (reference ) input parameters
* @param array $returnProperties Which properties should be included in the
* returned Contribution object. If NULL, the default
* set of properties will be included.
*
* @return array (reference ) array of contributions, if error an array with an error id and error message
* @static void
* @access public
* {@getfields Contribution_get}
* @example ContributionGet.php
*/
function civicrm_api3_contribution_get($params)
{
$options = _civicrm_api3_get_options_from_params($params, TRUE, 'contribution', 'get');
$sort = CRM_Utils_Array::value('sort', $options, NULL);
$offset = CRM_Utils_Array::value('offset', $options);
$rowCount = CRM_Utils_Array::value('limit', $options);
$smartGroupCache = CRM_Utils_Array::value('smartGroupCache', $params);
$inputParams = CRM_Utils_Array::value('input_params', $options, array());
$returnProperties = CRM_Utils_Array::value('return', $options, NULL);
if (empty($returnProperties)) {
$returnProperties = CRM_Contribute_BAO_Query::defaultReturnProperties(CRM_Contact_BAO_Query::MODE_CONTRIBUTE);
}
$newParams = CRM_Contact_BAO_Query::convertFormValues($inputParams);
$query = new CRM_Contact_BAO_Query($newParams, $returnProperties, NULL, FALSE, FALSE, CRM_Contact_BAO_Query::MODE_CONTRIBUTE);
list($select, $from, $where, $having) = $query->query();
$sql = "{$select} {$from} {$where} {$having}";
if (!empty($sort)) {
$sql .= " ORDER BY {$sort} ";
}
$sql .= " LIMIT {$offset}, {$rowCount} ";
$dao = CRM_Core_DAO::executeQuery($sql);
$contribution = array();
while ($dao->fetch()) {
//CRM-8662
$contribution_details = $query->store($dao);
$softContribution = CRM_Contribute_BAO_ContributionSoft::getSoftContribution($dao->contribution_id, TRUE);
$contribution[$dao->contribution_id] = array_merge($contribution_details, $softContribution);
if (isset($contribution[$dao->contribution_id]['financial_type_id'])) {
$contribution[$dao->contribution_id]['financial_type_id'] = $contribution[$dao->contribution_id]['financial_type_id'];
}
// format soft credit for backward compatibility
_civicrm_api3_format_soft_credit($contribution[$dao->contribution_id]);
}
return civicrm_api3_create_success($contribution, $params, 'contribution', 'get', $dao);
}
示例15: buildQuickForm
/**
* Function used to build form element for soft credit block.
*
* @param CRM_Core_Form $form
*
* @return \CRM_Core_Form
*/
public static function buildQuickForm(&$form)
{
if (!empty($form->_honor_block_is_active)) {
$ufJoinDAO = new CRM_Core_DAO_UFJoin();
$ufJoinDAO->module = 'soft_credit';
$ufJoinDAO->entity_id = $form->_id;
if ($ufJoinDAO->find(TRUE)) {
$jsonData = CRM_Contribute_BAO_ContributionPage::formatModuleData($ufJoinDAO->module_data, TRUE, 'soft_credit');
if ($jsonData) {
foreach (array('honor_block_title', 'honor_block_text') as $name) {
$form->assign($name, $jsonData[$name]);
}
$softCreditTypes = CRM_Core_OptionGroup::values("soft_credit_type", FALSE);
// radio button for Honor Type
foreach ($jsonData['soft_credit_types'] as $value) {
$honorTypes[$value] = $form->createElement('radio', NULL, NULL, $softCreditTypes[$value], $value);
}
$form->addGroup($honorTypes, 'soft_credit_type_id', NULL)->setAttribute('allowClear', TRUE);
}
}
return $form;
}
// by default generate 10 blocks
$item_count = 11;
$showSoftCreditRow = 2;
if ($form->getAction() & CRM_Core_Action::UPDATE) {
$form->_softCreditInfo = CRM_Contribute_BAO_ContributionSoft::getSoftContribution($form->_id, TRUE);
} elseif (!empty($form->_pledgeID)) {
//Check and select most recent completed contrubtion and use it to retrieve
//soft-credit information to use as default for current pledge payment, CRM-13981
$pledgePayments = CRM_Pledge_BAO_PledgePayment::getPledgePayments($form->_pledgeID);
foreach ($pledgePayments as $id => $record) {
if ($record['contribution_id']) {
$softCredits = CRM_Contribute_BAO_ContributionSoft::getSoftContribution($record['contribution_id'], TRUE);
if ($record['status'] == 'Completed' && count($softCredits) > 0) {
$form->_softCreditInfo = $softCredits;
}
}
}
}
if (property_exists($form, "_softCreditInfo")) {
if (!empty($form->_softCreditInfo['soft_credit'])) {
$showSoftCreditRow = count($form->_softCreditInfo['soft_credit']);
$showSoftCreditRow++;
}
}
for ($rowNumber = 1; $rowNumber <= $item_count; $rowNumber++) {
$form->addEntityRef("soft_credit_contact_id[{$rowNumber}]", ts('Contact'), array('create' => TRUE));
$form->addMoney("soft_credit_amount[{$rowNumber}]", ts('Amount'), FALSE, NULL, FALSE);
$form->addSelect("soft_credit_type[{$rowNumber}]", array('entity' => 'contribution_soft', 'field' => 'soft_credit_type_id', 'label' => ts('Type')));
if (!empty($form->_softCreditInfo['soft_credit'][$rowNumber]['soft_credit_id'])) {
$form->add('hidden', "soft_credit_id[{$rowNumber}]", $form->_softCreditInfo['soft_credit'][$rowNumber]['soft_credit_id']);
}
}
self::addPCPFields($form);
$form->assign('showSoftCreditRow', $showSoftCreditRow);
$form->assign('rowCount', $item_count);
$form->addElement('hidden', 'sct_default_id', CRM_Core_OptionGroup::getDefaultValue("soft_credit_type"), array('id' => 'sct_default_id'));
}