本文整理汇总了PHP中CRM_Contribute_BAO_Contribution::getValues方法的典型用法代码示例。如果您正苦于以下问题:PHP CRM_Contribute_BAO_Contribution::getValues方法的具体用法?PHP CRM_Contribute_BAO_Contribution::getValues怎么用?PHP CRM_Contribute_BAO_Contribution::getValues使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类CRM_Contribute_BAO_Contribution
的用法示例。
在下文中一共展示了CRM_Contribute_BAO_Contribution::getValues方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: preProcess
/**
* Function to set variables up before form is built
*
* @return void
* @access public
*/
function preProcess()
{
require_once 'CRM/Contribute/BAO/Contribution.php';
$values = array();
$ids = array();
$params = array('id' => $this->get('id'));
CRM_Contribute_BAO_Contribution::getValues($params, $values, $ids);
CRM_Contribute_BAO_Contribution::resolveDefaults($values);
$groupTree =& CRM_Core_BAO_CustomGroup::getTree('Contribution', $this->get('id'));
CRM_Core_BAO_CustomGroup::buildViewHTML($this, $groupTree);
$id = $this->get('id');
if ($id) {
require_once 'CRM/Contribute/DAO/ContributionProduct.php';
$dao =& new CRM_Contribute_DAO_ContributionProduct();
$dao->contribution_id = $id;
if ($dao->find(true)) {
$premiumId = $dao->id;
$productID = $dao->product_id;
}
}
if ($premiumId) {
require_once 'CRM/Contribute/DAO/Product.php';
$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);
}
$this->assign($values);
}
示例2: 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];
}
//.........这里部分代码省略.........
示例3: checkTaxAmount
/**
* Check tax amount.
*
* @param array $params
* @param bool $isLineItem
*
* @return mixed
*/
public static function checkTaxAmount($params, $isLineItem = FALSE)
{
$taxRates = CRM_Core_PseudoConstant::getTaxRates();
// Update contribution.
if (!empty($params['id'])) {
$id = $params['id'];
$values = $ids = array();
$contrbutionParams = array('id' => $id);
$prevContributionValue = CRM_Contribute_BAO_Contribution::getValues($contrbutionParams, $values, $ids);
// To assign pervious finantial type on update of contribution
if (!isset($params['financial_type_id'])) {
$params['financial_type_id'] = $prevContributionValue->financial_type_id;
} elseif (isset($params['financial_type_id']) && !array_key_exists($params['financial_type_id'], $taxRates)) {
// Assisn tax Amount on update of contrbution
if (!empty($prevContributionValue->tax_amount)) {
$params['tax_amount'] = 'null';
CRM_Price_BAO_LineItem::getLineItemArray($params, array($params['id']));
foreach ($params['line_item'] as $setID => $priceField) {
foreach ($priceField as $priceFieldID => $priceFieldValue) {
$params['line_item'][$setID][$priceFieldID]['tax_amount'] = $params['tax_amount'];
}
}
}
}
}
// New Contrbution and update of contribution with tax rate financial type
if (isset($params['financial_type_id']) && array_key_exists($params['financial_type_id'], $taxRates) && empty($params['skipLineItem']) && !$isLineItem) {
$taxRateParams = $taxRates[$params['financial_type_id']];
$taxAmount = CRM_Contribute_BAO_Contribution_Utils::calculateTaxAmount($params['total_amount'], $taxRateParams);
$params['tax_amount'] = round($taxAmount['tax_amount'], 2);
// Get Line Item on update of contribution
if (isset($params['id'])) {
CRM_Price_BAO_LineItem::getLineItemArray($params, array($params['id']));
} else {
CRM_Price_BAO_LineItem::getLineItemArray($params);
}
foreach ($params['line_item'] as $setID => $priceField) {
foreach ($priceField as $priceFieldID => $priceFieldValue) {
$params['line_item'][$setID][$priceFieldID]['tax_amount'] = $params['tax_amount'];
}
}
$params['total_amount'] = $params['total_amount'] + $params['tax_amount'];
} elseif (isset($params['api.line_item.create'])) {
// Update total amount of contribution using lineItem
$taxAmountArray = array();
foreach ($params['api.line_item.create'] as $key => $value) {
if (isset($value['financial_type_id']) && array_key_exists($value['financial_type_id'], $taxRates)) {
$taxRate = $taxRates[$value['financial_type_id']];
$taxAmount = CRM_Contribute_BAO_Contribution_Utils::calculateTaxAmount($value['line_total'], $taxRate);
$taxAmountArray[] = round($taxAmount['tax_amount'], 2);
}
}
$params['tax_amount'] = array_sum($taxAmountArray);
$params['total_amount'] = $params['total_amount'] + $params['tax_amount'];
} else {
// update line item of contrbution
if (isset($params['financial_type_id']) && array_key_exists($params['financial_type_id'], $taxRates) && $isLineItem) {
$taxRate = $taxRates[$params['financial_type_id']];
$taxAmount = CRM_Contribute_BAO_Contribution_Utils::calculateTaxAmount($params['line_total'], $taxRate);
$params['tax_amount'] = round($taxAmount['tax_amount'], 2);
}
}
return $params;
}
示例4: preProcess
/**
* Function to set variables up before form is built
*
* @return void
* @access public
*/
public function preProcess()
{
$id = $this->get('id');
$values = $ids = array();
$params = array('id' => $id);
require_once 'CRM/Contribute/BAO/Contribution.php';
CRM_Contribute_BAO_Contribution::getValues($params, $values, $ids);
$softParams = array('contribution_id' => $values['contribution_id']);
if ($softContribution = CRM_Contribute_BAO_Contribution::getSoftContribution($softParams, true)) {
$values = array_merge($values, $softContribution);
}
CRM_Contribute_BAO_Contribution::resolveDefaults($values);
if (CRM_Utils_Array::value('honor_contact_id', $values)) {
$sql = "SELECT display_name FROM civicrm_contact WHERE id = %1";
$params = array(1 => array($values['honor_contact_id'], 'Integer'));
$dao = CRM_Core_DAO::executeQuery($sql, $params);
if ($dao->fetch()) {
$url = CRM_Utils_System::url('civicrm/contact/view', "reset=1&cid={$values['honor_contact_id']}");
$values["honor_display"] = "<A href = {$url}>" . $dao->display_name . "</A>";
}
$honor = CRM_Core_PseudoConstant::honor();
$values['honor_type'] = $honor[$values['honor_type_id']];
}
if (CRM_Utils_Array::value('contribution_recur_id', $values)) {
$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, $values['contribution_type_id']);
CRM_Core_BAO_CustomGroup::buildCustomDataView($this, $groupTree);
$premiumId = null;
if ($id) {
require_once 'CRM/Contribute/DAO/ContributionProduct.php';
$dao =& new CRM_Contribute_DAO_ContributionProduct();
$dao->contribution_id = $id;
if ($dao->find(true)) {
$premiumId = $dao->id;
$productID = $dao->product_id;
}
}
if ($premiumId) {
require_once 'CRM/Contribute/DAO/Product.php';
$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($values['id'], 'civicrm_contribution');
$values['note'] = array_values($noteValue);
// show billing address location details, if exists
if (CRM_Utils_Array::value('address_id', $values)) {
$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'];
}
//get soft credit record if exists.
if ($softContribution = CRM_Contribute_BAO_Contribution::getSoftContribution($softParams)) {
$softContribution['softCreditToName'] = CRM_Core_DAO::getFieldValue('CRM_Contact_DAO_Contact', $softContribution['soft_credit_to'], 'display_name');
//hack to avoid dispalyName conflict
//for viewing softcredit record.
$softContribution['displayName'] = CRM_Core_DAO::getFieldValue('CRM_Contact_DAO_Contact', $values['contact_id'], 'display_name');
$values = array_merge($values, $softContribution);
}
require_once 'CRM/Price/BAO/Set.php';
$lineItems = array();
if ($id && CRM_Price_BAO_Set::getFor('civicrm_contribution', $id)) {
require_once 'CRM/Price/BAO/LineItem.php';
$lineItems[] = CRM_Price_BAO_LineItem::getLineItems($id, 'contribution');
}
$this->assign('lineItem', empty($lineItems) ? false : $lineItems);
$values['totalAmount'] = $values['total_amount'];
// assign values to the template
$this->assign($values);
// add viewed contribution to recent items list
require_once 'CRM/Utils/Recent.php';
require_once 'CRM/Utils/Money.php';
require_once 'CRM/Contact/BAO/Contact.php';
$url = CRM_Utils_System::url('civicrm/contact/view/contribution', "action=view&reset=1&id={$values['id']}&cid={$values['contact_id']}");
$title = CRM_Core_DAO::getFieldValue('CRM_Contact_DAO_Contact', $values['contact_id'], 'display_name') . ' - (' . CRM_Utils_Money::format($values['total_amount']) . ' ' . ' - ' . $values['contribution_type'] . ')';
CRM_Utils_Recent::add($title, $url, $values['id'], 'Contribution', $values['contact_id'], null);
}
示例5: setDefaultValues
function setDefaultValues()
{
$defaults = array();
if ($this->_action & CRM_CORE_ACTION_DELETE) {
return $defaults;
}
if ($this->_id) {
$ids = array();
$params = array('id' => $this->_id);
CRM_Contribute_BAO_Contribution::getValues($params, $defaults, $ids);
$this->_contactID = $defaults['contact_id'];
} else {
$now = date("Y-m-d");
$defaults['receive_date'] = $now;
}
if (isset($this->_groupTree)) {
CRM_Core_BAO_CustomGroup::setDefaults($this->_groupTree, $defaults, false, false);
}
$this->assign('showOption', true);
// for Premium section
if ($this->_premiumId) {
$this->assign('showOption', false);
require_once 'CRM/Contribute/DAO/ContributionProduct.php';
$dao =& new CRM_Contribute_DAO_ContributionProduct();
$dao->id = $this->_premiumId;
$dao->find(true);
//if($this->_options[$dao->product_id];)
$options = $this->_options[$dao->product_id];
if (!$options) {
$this->assign('showOption', true);
}
$options_key = CRM_Utils_Array::key($dao->product_option, $options);
if ($options_key) {
$defaults['product_name'] = array($dao->product_id, trim($options_key));
} else {
$defaults['product_name'] = array($dao->product_id);
}
$defaults['fulfilled_date'] = $dao->fulfilled_date;
}
return $defaults;
}
示例6: _crm_initialize
/**
* Get an existing contribution.
*
* Returns a single existing Contribution object which matches ALL property
* values passed in $params. An error object is returned if there is
* no match, or more than one match. This API can be used to retrieve
* the CRM internal identifier (contribution_id) based on a unique property.
* It can also be used to retrieve any desired
* contribution properties based on a known contribution_id.
*
* @param array $params Associative array of property name/value
* pairs to attempt to match on.
* @param array $returnProperties Which properties should be included in the
* returned Contribution object. If NULL, the default
* set of properties will be included.
*
* @return CRM_Contribution|CRM_Core_Error Return the Contribution Object if found, else
* Error Object
*
* @access public
*
*/
function &crm_get_contribution($params, $returnProperties = null)
{
_crm_initialize();
// empty parameters ?
if (empty($params)) {
return _crm_error('$params is empty');
}
// correct parameter format ?
if (!is_array($params)) {
return _crm_error('$params is not an array');
}
if (!CRM_Utils_Array::value('contribution_id', $params)) {
$returnProperties = array('trxn_id');
$contributions = crm_contribution_search($params, $returnProperties);
if (count($contributions) != 1) {
return _crm_error(count($contributions) . " contributions matching input params.");
}
$contributionIds = array_keys($contributions);
$params['contribution_id'] = $contributionIds[0];
}
$params['id'] = $params['contribution_id'];
$ids = array();
$contribution =& CRM_Contribute_BAO_Contribution::getValues($params, $defaults, $ids);
if ($contribution == null || is_a($contribution, 'CRM_Core_Error') || !$contribution->id) {
return _crm_error('Did not find contribution object for ' . $params['contribution_id']);
}
unset($params['id']);
$contribution->contribution_type_object = CRM_Contribute_BAO_Contribution::getValues($params, $defaults, $ids);
$contribution->custom_values =& CRM_Core_BAO_CustomValue::getContributionValues($contribution->id);
return $contribution;
}
示例7: recordAdjustedAmt
/**
* Record adjusted amount.
*
* @param int $updatedAmount
* @param int $paidAmount
* @param int $contributionId
*
* @param int $taxAmount
* @param bool $updateAmountLevel
*
* @return bool|\CRM_Core_BAO_FinancialTrxn
*/
public static function recordAdjustedAmt($updatedAmount, $paidAmount, $contributionId, $taxAmount = NULL, $updateAmountLevel = NULL)
{
$pendingAmount = CRM_Core_BAO_FinancialTrxn::getBalanceTrxnAmt($contributionId);
$pendingAmount = CRM_Utils_Array::value('total_amount', $pendingAmount, 0);
$balanceAmt = $updatedAmount - $paidAmount;
if ($paidAmount != $pendingAmount) {
$balanceAmt -= $pendingAmount;
}
$contributionStatuses = CRM_Contribute_PseudoConstant::contributionStatus(NULL, 'name');
$partiallyPaidStatusId = array_search('Partially paid', $contributionStatuses);
$pendingRefundStatusId = array_search('Pending refund', $contributionStatuses);
$completedStatusId = array_search('Completed', $contributionStatuses);
$updatedContributionDAO = new CRM_Contribute_BAO_Contribution();
$adjustedTrxn = $skip = FALSE;
if ($balanceAmt) {
if ($balanceAmt > 0 && $paidAmount != 0) {
$contributionStatusVal = $partiallyPaidStatusId;
} elseif ($balanceAmt < 0 && $paidAmount != 0) {
$contributionStatusVal = $pendingRefundStatusId;
} elseif ($paidAmount == 0) {
//skip updating the contribution status if no payment is made
$skip = TRUE;
$updatedContributionDAO->cancel_date = 'null';
$updatedContributionDAO->cancel_reason = NULL;
}
// update contribution status and total amount without trigger financial code
// as this is handled in current BAO function used for change selection
$updatedContributionDAO->id = $contributionId;
if (!$skip) {
$updatedContributionDAO->contribution_status_id = $contributionStatusVal;
}
$updatedContributionDAO->total_amount = $updatedContributionDAO->net_amount = $updatedAmount;
$updatedContributionDAO->fee_amount = 0;
$updatedContributionDAO->tax_amount = $taxAmount;
if (!empty($updateAmountLevel)) {
$updatedContributionDAO->amount_level = $updateAmountLevel;
}
$updatedContributionDAO->save();
// adjusted amount financial_trxn creation
$updatedContribution = CRM_Contribute_BAO_Contribution::getValues(array('id' => $contributionId), CRM_Core_DAO::$_nullArray, CRM_Core_DAO::$_nullArray);
$relationTypeId = key(CRM_Core_PseudoConstant::accountOptionValues('account_relationship', NULL, " AND v.name LIKE 'Accounts Receivable Account is' "));
$toFinancialAccount = CRM_Contribute_PseudoConstant::financialAccountType($updatedContribution->financial_type_id, $relationTypeId);
$adjustedTrxnValues = array('from_financial_account_id' => NULL, 'to_financial_account_id' => $toFinancialAccount, 'total_amount' => $balanceAmt, 'status_id' => $completedStatusId, 'payment_instrument_id' => $updatedContribution->payment_instrument_id, 'contribution_id' => $updatedContribution->id, 'trxn_date' => date('YmdHis'), 'currency' => $updatedContribution->currency);
$adjustedTrxn = CRM_Core_BAO_FinancialTrxn::create($adjustedTrxnValues);
}
return $adjustedTrxn;
}
示例8: setDefaultValues
/**
* Set default values for the form. MobileProvider that in edit/view mode
* the default values are retrieved from the database
*
*
* @return void
*/
public function setDefaultValues()
{
if ($this->_cdType) {
return CRM_Custom_Form_CustomData::setDefaultValues($this);
}
if ($this->_priceSetId) {
return CRM_Price_BAO_PriceSet::setDefaultPriceSet($this, $defaults);
}
$defaults = parent::setDefaultValues();
//setting default join date and receive date
list($now, $currentTime) = CRM_Utils_Date::setDateDefaults();
if ($this->_action == CRM_Core_Action::ADD) {
$defaults['receive_date'] = $now;
$defaults['receive_date_time'] = $currentTime;
}
if (is_numeric($this->_memType)) {
$defaults['membership_type_id'] = array();
$defaults['membership_type_id'][0] = CRM_Core_DAO::getFieldValue('CRM_Member_DAO_MembershipType', $this->_memType, 'member_of_contact_id', 'id');
$defaults['membership_type_id'][1] = $this->_memType;
} else {
$defaults['membership_type_id'] = $this->_memType;
}
$defaults['num_terms'] = 1;
if (!empty($defaults['id'])) {
if ($this->_onlinePendingContributionId) {
$defaults['record_contribution'] = $this->_onlinePendingContributionId;
} else {
$contributionId = CRM_Core_DAO::singleValueQuery("\n SELECT contribution_id\n FROM civicrm_membership_payment\n WHERE membership_id = {$this->_id}\n ORDER BY contribution_id\n DESC limit 1");
if ($contributionId) {
$defaults['record_contribution'] = $contributionId;
}
}
}
//set Soft Credit Type to Gift by default
$scTypes = CRM_Core_OptionGroup::values("soft_credit_type");
$defaults['soft_credit_type_id'] = CRM_Utils_Array::value(ts('Gift'), array_flip($scTypes));
if (!empty($defaults['record_contribution']) && !$this->_mode) {
$contributionParams = array('id' => $defaults['record_contribution']);
$contributionIds = array();
//keep main object campaign in hand.
$memberCampaignId = CRM_Utils_Array::value('campaign_id', $defaults);
CRM_Contribute_BAO_Contribution::getValues($contributionParams, $defaults, $contributionIds);
//get back original object campaign id.
$defaults['campaign_id'] = $memberCampaignId;
if (!empty($defaults['receive_date'])) {
list($defaults['receive_date']) = CRM_Utils_Date::setDateDefaults($defaults['receive_date']);
}
// Contribution::getValues() over-writes the membership record's source field value - so we need to restore it.
if (!empty($defaults['membership_source'])) {
$defaults['source'] = $defaults['membership_source'];
}
}
//CRM-13420
if (empty($defaults['payment_instrument_id'])) {
$defaults['payment_instrument_id'] = key(CRM_Core_OptionGroup::values('payment_instrument', FALSE, FALSE, FALSE, 'AND is_default = 1'));
}
// User must explicitly choose to send a receipt in both add and update mode.
$defaults['send_receipt'] = 0;
if ($this->_action & CRM_Core_Action::UPDATE) {
// in this mode by default uncheck this checkbox
unset($defaults['record_contribution']);
}
if (!empty($defaults['id'])) {
$subscriptionCancelled = CRM_Member_BAO_Membership::isSubscriptionCancelled($this->_id);
}
$alreadyAutoRenew = FALSE;
if (!empty($defaults['contribution_recur_id']) && !$subscriptionCancelled) {
$defaults['auto_renew'] = 1;
$alreadyAutoRenew = TRUE;
}
$this->assign('alreadyAutoRenew', $alreadyAutoRenew);
$this->assign('member_is_test', CRM_Utils_Array::value('member_is_test', $defaults));
$this->assign('membership_status_id', CRM_Utils_Array::value('status_id', $defaults));
if (!empty($defaults['is_pay_later'])) {
$this->assign('is_pay_later', TRUE);
}
if ($this->_mode) {
// set default country from config if no country set
$config = CRM_Core_Config::singleton();
if (empty($defaults["billing_country_id-{$this->_bltID}"])) {
$defaults["billing_country_id-{$this->_bltID}"] = $config->defaultContactCountry;
}
if (empty($defaults["billing_state_province_id-{$this->_bltID}"])) {
$defaults["billing_state_province_id-{$this->_bltID}"] = $config->defaultContactStateProvince;
}
$billingDefaults = $this->getProfileDefaults('Billing', $this->_contactID);
$defaults = array_merge($defaults, $billingDefaults);
// // hack to simplify credit card entry for testing
// $defaults['credit_card_type'] = 'Visa';
// $defaults['credit_card_number'] = '4807731747657838';
// $defaults['cvv2'] = '000';
// $defaults['credit_card_exp_date'] = array( 'Y' => '2012', 'M' => '05' );
}
//.........这里部分代码省略.........
示例9: preProcess
/**
* Function to set variables up before form is built
*
* @return void
* @access public
*/
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);
$softParams = array('contribution_id' => $values['contribution_id']);
if ($softContribution = CRM_Contribute_BAO_Contribution::getSoftContribution($softParams, TRUE)) {
$values = array_merge($values, $softContribution);
}
CRM_Contribute_BAO_Contribution::resolveDefaults($values);
if (CRM_Utils_Array::value('contribution_page_id', $values)) {
$contribPages = CRM_Contribute_PseudoConstant::contributionPage(NULL, TRUE);
$values['contribution_page_title'] = CRM_Utils_Array::value(CRM_Utils_Array::value('contribution_page_id', $values), $contribPages);
}
if (CRM_Utils_Array::value('honor_contact_id', $values)) {
$sql = "SELECT display_name FROM civicrm_contact WHERE id = %1";
$params = array(1 => array($values['honor_contact_id'], 'Integer'));
$dao = CRM_Core_DAO::executeQuery($sql, $params);
if ($dao->fetch()) {
$url = CRM_Utils_System::url('civicrm/contact/view', "reset=1&cid={$values['honor_contact_id']}");
$values['honor_display'] = "<A href = {$url}>" . $dao->display_name . "</A>";
}
$honor = CRM_Core_PseudoConstant::honor();
$values['honor_type'] = CRM_Utils_Array::value(CRM_Utils_Array::value('honor_type_id', $values), $honor);
}
if (CRM_Utils_Array::value('contribution_recur_id', $values)) {
$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, $values['contribution_type_id']);
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($values['id'], 'civicrm_contribution');
$values['note'] = array_values($noteValue);
// show billing address location details, if exists
if (CRM_Utils_Array::value('address_id', $values)) {
$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'];
}
//get soft credit record if exists.
if ($softContribution = CRM_Contribute_BAO_Contribution::getSoftContribution($softParams)) {
$softContribution['softCreditToName'] = CRM_Core_DAO::getFieldValue('CRM_Contact_DAO_Contact', $softContribution['soft_credit_to'], 'display_name');
//hack to avoid dispalyName conflict
//for viewing softcredit record.
$softContribution['displayName'] = CRM_Core_DAO::getFieldValue('CRM_Contact_DAO_Contact', $values['contact_id'], 'display_name');
$values = array_merge($values, $softContribution);
}
$lineItems = array();
if ($id) {
$lineItem = CRM_Price_BAO_LineItem::getLineItems($id, 'contribution', 1);
empty($lineItem) ? null : ($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];
}
// assign values to the template
$this->assign($values);
// add viewed contribution to recent items list
$url = CRM_Utils_System::url('civicrm/contact/view/contribution', "action=view&reset=1&id={$values['id']}&cid={$values['contact_id']}&context=home");
$displayName = CRM_Core_DAO::getFieldValue('CRM_Contact_DAO_Contact', $values['contact_id'], 'display_name');
$this->assign('displayName', $displayName);
$title = $displayName . ' - (' . CRM_Utils_Money::format($values['total_amount']) . ' ' . ' - ' . $values['contribution_type'] . ')';
//.........这里部分代码省略.........
示例10: recordAdjustedAmt
/**
* @param $updatedAmount
* @param $paidAmount
* @param $contributionId
*/
static function recordAdjustedAmt($updatedAmount, $paidAmount, $contributionId)
{
$balanceAmt = $updatedAmount - $paidAmount;
$contributionStatuses = CRM_Contribute_PseudoConstant::contributionStatus(NULL, 'name');
$partiallyPaidStatusId = array_search('Partially paid', $contributionStatuses);
$pendngRefundStatusId = array_search('Pending refund', $contributionStatuses);
$completedStatusId = array_search('Completed', $contributionStatuses);
$updatedContributionDAO = new CRM_Contribute_BAO_Contribution();
if ($balanceAmt) {
if ($balanceAmt > 0 && $paidAmount != 0) {
$contributionStatusVal = $partiallyPaidStatusId;
} elseif ($balanceAmt < 0 && $paidAmount != 0) {
$contributionStatusVal = $pendngRefundStatusId;
} elseif ($paidAmount == 0) {
$contributionStatusVal = $completedStatusId;
$updatedContributionDAO->cancel_date = 'null';
$updatedContributionDAO->cancel_reason = NULL;
}
// update contribution status and total amount without trigger financial code
// as this is handled in current BAO function used for change selection
$updatedContributionDAO->id = $contributionId;
$updatedContributionDAO->contribution_status_id = $contributionStatusVal;
$updatedContributionDAO->total_amount = $updatedAmount;
$updatedContributionDAO->save();
$ftDetail = CRM_Core_BAO_FinancialTrxn::getBalanceTrxnAmt($contributionId);
// adjusted amount financial_trxn creation
if (empty($ftDetail['trxn_id'])) {
$updatedContribution = CRM_Contribute_BAO_Contribution::getValues(array('id' => $contributionId), CRM_Core_DAO::$_nullArray, CRM_Core_DAO::$_nullArray);
$relationTypeId = key(CRM_Core_PseudoConstant::accountOptionValues('account_relationship', NULL, " AND v.name LIKE 'Accounts Receivable Account is' "));
$toFinancialAccount = CRM_Contribute_PseudoConstant::financialAccountType($updatedContribution->financial_type_id, $relationTypeId);
$adjustedTrxnValues = array('from_financial_account_id' => NULL, 'to_financial_account_id' => $toFinancialAccount, 'total_amount' => $balanceAmt, 'status_id' => CRM_Core_OptionGroup::getValue('contribution_status', 'Completed', 'name'), 'payment_instrument_id' => $updatedContribution->payment_instrument_id, 'contribution_id' => $updatedContribution->id, 'trxn_date' => date('YmdHis'), 'currency' => $updatedContribution->currency);
$adjustedTrxn = CRM_Core_BAO_FinancialTrxn::create($adjustedTrxnValues);
} else {
// update the financial trxn amount as well, as the fee selections has been updated
if ($balanceAmt != $ftDetail['total_amount']) {
CRM_Core_DAO::setFieldValue('CRM_Core_BAO_FinancialTrxn', $ftDetail['trxn_id'], 'total_amount', $balanceAmt);
}
}
}
}
示例11: completeOrder
/**
* Complete an order.
*
* Do not call this directly - use the contribution.completetransaction api as this function is being refactored.
*
* Currently overloaded to complete a transaction & repeat a transaction - fix!
*
* Moving it out of the BaseIPN class is just the first step.
*
* @param array $input
* @param array $ids
* @param array $objects
* @param CRM_Core_Transaction $transaction
* @param int $recur
* @param CRM_Contribute_BAO_Contribution $contribution
* @param bool $isRecurring
* Duplication of param needs review. Only used by AuthorizeNetIPN
* @param int $isFirstOrLastRecurringPayment
* Deprecated param only used by AuthorizeNetIPN.
*/
public static function completeOrder(&$input, &$ids, $objects, $transaction, $recur, $contribution, $isRecurring, $isFirstOrLastRecurringPayment)
{
$primaryContributionID = isset($contribution->id) ? $contribution->id : $objects['first_contribution']->id;
// The previous details are used when calculating line items so keep it before any code that 'does something'
if (!empty($contribution->id)) {
$input['prevContribution'] = CRM_Contribute_BAO_Contribution::getValues(array('id' => $contribution->id), CRM_Core_DAO::$_nullArray, CRM_Core_DAO::$_nullArray);
}
$inputContributionWhiteList = array('fee_amount', 'net_amount', 'trxn_id', 'check_number', 'payment_instrument_id', 'is_test', 'campaign_id', 'receive_date', 'receipt_date', 'contribution_status_id');
if (self::isSingleLineItem($primaryContributionID)) {
$inputContributionWhiteList[] = 'financial_type_id';
}
$participant = CRM_Utils_Array::value('participant', $objects);
$memberships = CRM_Utils_Array::value('membership', $objects);
$recurContrib = CRM_Utils_Array::value('contributionRecur', $objects);
$recurringContributionID = empty($recurContrib->id) ? NULL : $recurContrib->id;
$event = CRM_Utils_Array::value('event', $objects);
$paymentProcessorId = '';
if (isset($objects['paymentProcessor'])) {
if (is_array($objects['paymentProcessor'])) {
$paymentProcessorId = $objects['paymentProcessor']['id'];
} else {
$paymentProcessorId = $objects['paymentProcessor']->id;
}
}
$completedContributionStatusID = CRM_Core_PseudoConstant::getKey('CRM_Contribute_BAO_Contribution', 'contribution_status_id', 'Completed');
$contributionParams = array_merge(array('contribution_status_id' => $completedContributionStatusID, 'source' => self::getRecurringContributionDescription($contribution, $event)), array_intersect_key($input, array_fill_keys($inputContributionWhiteList, 1)));
$contributionParams['payment_processor'] = $input['payment_processor'] = $paymentProcessorId;
if ($recurringContributionID) {
$contributionParams['contribution_recur_id'] = $recurringContributionID;
}
$changeDate = CRM_Utils_Array::value('trxn_date', $input, date('YmdHis'));
if (empty($contributionParams['receive_date']) && $changeDate) {
$contributionParams['receive_date'] = $changeDate;
}
self::repeatTransaction($contribution, $input, $contributionParams, $paymentProcessorId);
$contributionParams['financial_type_id'] = $contribution->financial_type_id;
if (is_numeric($memberships)) {
$memberships = array($objects['membership']);
}
$values = array();
if (isset($input['is_email_receipt'])) {
$values['is_email_receipt'] = $input['is_email_receipt'];
}
if ($input['component'] == 'contribute') {
if ($contribution->contribution_page_id) {
// Figure out what we gain from this.
CRM_Contribute_BAO_ContributionPage::setValues($contribution->contribution_page_id, $values);
} elseif ($recurContrib && $recurringContributionID) {
$values['amount'] = $recurContrib->amount;
$values['financial_type_id'] = $objects['contributionType']->id;
$values['title'] = $source = ts('Offline Recurring Contribution');
}
if ($recurContrib && $recurringContributionID && !isset($input['is_email_receipt'])) {
//CRM-13273 - is_email_receipt setting on recurring contribution should take precedence over contribution page setting
// but CRM-16124 if $input['is_email_receipt'] is set then that should not be overridden.
$values['is_email_receipt'] = $recurContrib->is_email_receipt;
}
if (!empty($memberships)) {
foreach ($memberships as $membershipTypeIdKey => $membership) {
if ($membership) {
$membershipParams = array('id' => $membership->id, 'contact_id' => $membership->contact_id, 'is_test' => $membership->is_test, 'membership_type_id' => $membership->membership_type_id);
$currentMembership = CRM_Member_BAO_Membership::getContactMembership($membershipParams['contact_id'], $membershipParams['membership_type_id'], $membershipParams['is_test'], $membershipParams['id']);
// CRM-8141 update the membership type with the value recorded in log when membership created/renewed
// this picks up membership type changes during renewals
$sql = "\nSELECT membership_type_id\nFROM civicrm_membership_log\nWHERE membership_id={$membershipParams['id']}\nORDER BY id DESC\nLIMIT 1;";
$dao = CRM_Core_DAO::executeQuery($sql);
if ($dao->fetch()) {
if (!empty($dao->membership_type_id)) {
$membershipParams['membership_type_id'] = $dao->membership_type_id;
}
}
$dao->free();
$membershipParams['num_terms'] = $contribution->getNumTermsByContributionAndMembershipType($membershipParams['membership_type_id'], $primaryContributionID);
$dates = array_fill_keys(array('join_date', 'start_date', 'end_date'), NULL);
if ($currentMembership) {
/*
* Fixed FOR CRM-4433
* In BAO/Membership.php(renewMembership function), we skip the extend membership date and status
* when Contribution mode is notify and membership is for renewal )
*/
//.........这里部分代码省略.........
示例12: setDefaultValues
/**
* This function sets the default values for the form. MobileProvider that in edit/view mode
* the default values are retrieved from the database
*
* @access public
* @return None
*/
public function setDefaultValues()
{
if ($this->_cdType) {
return CRM_Custom_Form_CustomData::setDefaultValues($this);
}
$defaults = array();
$defaults =& parent::setDefaultValues();
//setting default join date and receive date
list($now) = CRM_Utils_Date::setDateDefaults();
if ($this->_action == CRM_Core_Action::ADD) {
$defaults['receive_date'] = $now;
}
if (is_numeric($this->_memType)) {
$defaults["membership_type_id"] = array();
$defaults["membership_type_id"][0] = CRM_Core_DAO::getFieldValue('CRM_Member_DAO_MembershipType', $this->_memType, 'member_of_contact_id', 'id');
$defaults["membership_type_id"][1] = $this->_memType;
} else {
$defaults["membership_type_id"] = $this->_memType;
}
if (CRM_Utils_Array::value('id', $defaults)) {
if ($this->_onlinePendingContributionId) {
$defaults['record_contribution'] = $this->_onlinePendingContributionId;
} else {
$defaults['record_contribution'] = CRM_Core_DAO::getFieldValue('CRM_Member_DAO_MembershipPayment', $defaults['id'], 'contribution_id', 'membership_id');
}
}
if ($this->_memType) {
$defaults['contribution_type_id'] = CRM_Core_DAO::getFieldValue('CRM_Member_DAO_MembershipType', $this->_memType, 'contribution_type_id');
$defaults['total_amount'] = CRM_Core_DAO::getFieldValue('CRM_Member_DAO_MembershipType', $this->_memType, 'minimum_fee');
}
if (CRM_Utils_Array::value('record_contribution', $defaults) && !$this->_mode) {
$contributionParams = array('id' => $defaults['record_contribution']);
$contributionIds = array();
require_once "CRM/Contribute/BAO/Contribution.php";
CRM_Contribute_BAO_Contribution::getValues($contributionParams, $defaults, $contributionIds);
// Contribution::getValues() over-writes the membership record's source field value - so we need to restore it.
if (CRM_Utils_Array::value('membership_source', $defaults)) {
$defaults['source'] = $defaults['membership_source'];
}
}
// User must explicitly choose to send a receipt in both add and update mode.
$defaults['send_receipt'] = 0;
if ($this->_action & CRM_Core_Action::UPDATE) {
// in this mode by default uncheck this checkbox
unset($defaults['record_contribution']);
}
if ($defaults['membership_type_id'][1]) {
$defaults['receipt_text_signup'] = CRM_Core_DAO::getFieldValue('CRM_Member_DAO_MembershipType', $defaults['membership_type_id'][1], 'receipt_text_signup');
}
$this->assign("member_is_test", CRM_Utils_Array::value('member_is_test', $defaults));
$this->assign('membership_status_id', CRM_Utils_Array::value('status_id', $defaults));
if (CRM_Utils_Array::value('is_pay_later', $defaults)) {
$this->assign('is_pay_later', true);
}
if ($this->_mode) {
$fields = array();
foreach ($this->_fields as $name => $dontCare) {
$fields[$name] = 1;
}
$names = array("first_name", "middle_name", "last_name", "street_address-{$this->_bltID}", "city-{$this->_bltID}", "postal_code-{$this->_bltID}", "country_id-{$this->_bltID}", "state_province_id-{$this->_bltID}");
foreach ($names as $name) {
$fields[$name] = 1;
}
$fields["state_province-{$this->_bltID}"] = 1;
$fields["country-{$this->_bltID}"] = 1;
$fields["email-{$this->_bltID}"] = 1;
$fields["email-Primary"] = 1;
if ($this->_contactID) {
require_once "CRM/Core/BAO/UFGroup.php";
CRM_Core_BAO_UFGroup::setProfileDefaults($this->_contactID, $fields, $this->_defaults);
}
// use primary email address if billing email address is empty
if (empty($this->_defaults["email-{$this->_bltID}"]) && !empty($this->_defaults["email-Primary"])) {
$defaults["email-{$this->_bltID}"] = $this->_defaults["email-Primary"];
}
foreach ($names as $name) {
if (!empty($this->_defaults[$name])) {
$defaults["billing_" . $name] = $this->_defaults[$name];
}
}
}
$dates = array('join_date', 'start_date', 'end_date');
foreach ($dates as $key) {
if (CRM_Utils_Array::value($key, $defaults)) {
list($defaults[$key]) = CRM_Utils_Date::setDateDefaults(CRM_Utils_Array::value($key, $defaults));
}
}
//setting default join date if there is no join date
if (!CRM_Utils_Array::value('join_date', $defaults)) {
$defaults['join_date'] = $now;
}
return $defaults;
}
示例13: preProcess
//.........这里部分代码省略.........
$this->assign('bltID', $this->_bltID);
$this->_fields = array();
require_once 'CRM/Core/Payment.php';
require_once 'CRM/Core/Payment/Form.php';
// payment fields are depending on payment type
if ($this->_processors['payment_type'] & CRM_Core_Payment::PAYMENT_TYPE_DIRECT_DEBIT) {
CRM_Core_Payment_Form::setDirectDebitFields($this);
} else {
CRM_Core_Payment_Form::setCreditCardFields($this);
}
if ($this->_action & CRM_Core_Action::DELETE) {
return;
}
$config =& CRM_Core_Config::singleton();
if (in_array("CiviPledge", $config->enableComponents) && !$this->_formType) {
//get the payment values associated with given pledge payment id OR check for payments due.
$this->_pledgeValues = array();
if ($this->_ppID) {
$payParams = array('id' => $this->_ppID);
require_once "CRM/Pledge/BAO/Payment.php";
CRM_Pledge_BAO_Payment::retrieve($payParams, $this->_pledgeValues['pledgePayment']);
$this->_pledgeID = CRM_Utils_Array::value('pledge_id', $this->_pledgeValues['pledgePayment']);
$paymentStatusID = CRM_Utils_Array::value('status_id', $this->_pledgeValues['pledgePayment']);
$this->_id = CRM_Utils_Array::value('contribution_id', $this->_pledgeValues['pledgePayment']);
//get all status
$allStatus = CRM_Contribute_PseudoConstant::contributionStatus();
if (!($paymentStatusID == array_search('Pending', $allStatus) || $paymentStatusID == array_search('Overdue', $allStatus))) {
CRM_Core_Error::fatal(ts("Pledge payment status should be 'Pending' or 'Overdue'."));
}
//get the pledge values associated with given pledge payment.
require_once 'CRM/Pledge/BAO/Pledge.php';
$ids = array();
$pledgeParams = array('id' => $this->_pledgeID);
CRM_Pledge_BAO_Pledge::getValues($pledgeParams, $this->_pledgeValues, $ids);
$this->assign('ppID', $this->_ppID);
} else {
// Not making a pledge payment, so check if pledge payment(s) are due for this contact so we can alert the user. CRM-5206
if (isset($this->_contactID)) {
require_once "CRM/Pledge/BAO/Pledge.php";
$contactPledges = array();
$contactPledges = CRM_Pledge_BAO_Pledge::getContactPledges($this->_contactID);
if (!empty($contactPledges)) {
$payments = null;
$paymentsDue = null;
$multipleDue = false;
require_once "CRM/Pledge/BAO/Payment.php";
foreach ($contactPledges as $key => $pledgeId) {
$payments = CRM_Pledge_BAO_Payment::getOldestPledgePayment($pledgeId);
if ($payments) {
if ($paymentsDue) {
$multipleDue = true;
break;
} else {
$paymentsDue = $payments;
}
}
}
if ($multipleDue) {
// Show link to pledge tab since more than one pledge has a payment due
$pledgeTab = CRM_Utils_System::url('civicrm/contact/view', "reset=1&force=1&cid={$this->_contactID}&selectedChild=pledge");
CRM_Core_Session::setStatus(ts('This contact has pending or overdue pledge payments. <a href="%1">Click here to view their Pledges tab</a> and verify whether this contribution should be applied as a pledge payment.', array(1 => $pledgeTab)));
} else {
if ($paymentsDue) {
// Show user link to oldest Pending or Overdue pledge payment
require_once 'CRM/Utils/Date.php';
require_once 'CRM/Utils/Money.php';
示例14: buildValuesAndAssignOnline_Note_Type
/**
* @param int $id
* @param $values
*/
public function buildValuesAndAssignOnline_Note_Type($id, &$values)
{
$ids = array();
$params = array('id' => $id);
CRM_Contribute_BAO_Contribution::getValues($params, $values, $ids);
//Check if this is an online transaction (financial_trxn.payment_processor_id NOT NULL)
$this->_online = FALSE;
$fids = CRM_Core_BAO_FinancialTrxn::getFinancialTrxnId($id);
if (!empty($fids['financialTrxnId'])) {
$this->_online = CRM_Core_DAO::getFieldValue('CRM_Financial_DAO_FinancialTrxn', $fids['financialTrxnId'], 'payment_processor_id');
}
// Also don't allow user to update some fields for recurring contributions.
if (!$this->_online) {
$this->_online = CRM_Utils_Array::value('contribution_recur_id', $values);
}
$this->assign('isOnline', $this->_online ? TRUE : FALSE);
//to get note id
$daoNote = new CRM_Core_BAO_Note();
$daoNote->entity_table = 'civicrm_contribution';
$daoNote->entity_id = $id;
if ($daoNote->find(TRUE)) {
$this->_noteID = $daoNote->id;
$values['note'] = $daoNote->note;
}
$this->_contributionType = $values['financial_type_id'];
}
示例15: setDefaultValues
/**
* This function sets the default values for the form.
* the default values are retrieved from the database
*
* @access public
* @return None
*/
public function setDefaultValues()
{
$defaults = array();
$defaults =& parent::setDefaultValues();
$this->_memType = $defaults["membership_type_id"];
$defaults['renewal_date'] = CRM_Utils_Date::getToday($defaults['renewal_date'], 'm/d/Y');
if ($defaults['id']) {
$defaults['record_contribution'] = CRM_Core_DAO::getFieldValue('CRM_Member_DAO_MembershipPayment', $defaults['id'], 'contribution_id', 'membership_id');
}
$defaults['contribution_type_id'] = CRM_Core_DAO::getFieldValue('CRM_Member_DAO_MembershipType', $this->_memType, 'contribution_type_id');
$defaults['total_amount'] = CRM_Core_DAO::getFieldValue('CRM_Member_DAO_MembershipType', $this->_memType, 'minimum_fee');
$defaults['record_contribution'] = 0;
if ($defaults['record_contribution']) {
$contributionParams = array('id' => $defaults['record_contribution']);
$contributionIds = array();
require_once "CRM/Contribute/BAO/Contribution.php";
CRM_Contribute_BAO_Contribution::getValues($contributionParams, $defaults, $contributionIds);
}
$defaults['send_receipt'] = 0;
if ($defaults['membership_type_id']) {
$defaults['receipt_text_renewal'] = CRM_Core_DAO::getFieldValue('CRM_Member_DAO_MembershipType', $defaults['membership_type_id'], 'receipt_text_renewal');
}
$this->assign("member_is_test", CRM_Utils_Array::value('member_is_test', $defaults));
if ($this->_mode) {
$fields = array();
foreach ($this->_fields as $name => $dontCare) {
$fields[$name] = 1;
}
$names = array("first_name", "middle_name", "last_name", "street_address-{$this->_bltID}", "city-{$this->_bltID}", "postal_code-{$this->_bltID}", "country_id-{$this->_bltID}", "state_province_id-{$this->_bltID}");
foreach ($names as $name) {
$fields[$name] = 1;
}
$fields["state_province-{$this->_bltID}"] = 1;
$fields["country-{$this->_bltID}"] = 1;
$fields["email-{$this->_bltID}"] = 1;
$fields["email-Primary"] = 1;
require_once "CRM/Core/BAO/UFGroup.php";
CRM_Core_BAO_UFGroup::setProfileDefaults($this->_contactID, $fields, $this->_defaults);
// use primary email address if billing email address is empty
if (empty($this->_defaults["email-{$this->_bltID}"]) && !empty($this->_defaults["email-Primary"])) {
$defaults["email-{$this->_bltID}"] = $this->_defaults["email-Primary"];
}
foreach ($names as $name) {
if (!empty($this->_defaults[$name])) {
$defaults["billing_" . $name] = $this->_defaults[$name];
}
}
}
return $defaults;
}