本文整理汇总了PHP中CRM_Contribute_BAO_Contribution::resolveDefaults方法的典型用法代码示例。如果您正苦于以下问题:PHP CRM_Contribute_BAO_Contribution::resolveDefaults方法的具体用法?PHP CRM_Contribute_BAO_Contribution::resolveDefaults怎么用?PHP CRM_Contribute_BAO_Contribution::resolveDefaults使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类CRM_Contribute_BAO_Contribution
的用法示例。
在下文中一共展示了CRM_Contribute_BAO_Contribution::resolveDefaults方法的7个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的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: 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);
}
示例4: _crm_update_contribution
function _crm_update_contribution($contribution, $values, $overwrite = true)
{
CRM_Contribute_BAO_Contribution::resolveDefaults($values, true);
if (!$overwrite) {
_crm_update_from_object($contribution, $values, true, true);
}
_crm_update_object($contribution, $values);
return $contribution;
}
示例5: 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'] . ')';
//.........这里部分代码省略.........
示例6: _civicrm_initialize
/**
*
* @param <type> $params
* @return <type>
*/
function &civicrm_contribution_format_create(&$params)
{
_civicrm_initialize();
// return error if we have no params
if (empty($params)) {
return civicrm_create_error('Input Parameters empty');
}
$error = _civicrm_contribute_check_params($params);
if (civicrm_error($error)) {
return $error;
}
$values = array();
$error = _civicrm_contribute_format_params($params, $values);
if (civicrm_error($error)) {
return $error;
}
$error = _civicrm_contribute_duplicate_check($params);
if (civicrm_error($error)) {
return $error;
}
$ids = array();
CRM_Contribute_BAO_Contribution::resolveDefaults($params, true);
$contribution = CRM_Contribute_BAO_Contribution::create($params, $ids);
_civicrm_object_to_array($contribution, $contributeArray);
return $contributeArray;
}
示例7: _crm_initialize
function &crm_create_contribution_formatted(&$params, $onDuplicate)
{
_crm_initialize();
// return error if we have no params
if (empty($params)) {
return _crm_error('Input Parameters empty');
}
$error = _crm_required_formatted_contribution($params);
if (is_a($error, 'CRM_Core_Error')) {
return $error;
}
$error = _crm_validate_formatted_contribution($params);
if (is_a($error, 'CRM_Core_Error')) {
return $error;
}
$error = _crm_duplicate_formatted_contribution($params);
if (is_a($error, 'CRM_Core_Error')) {
return $error;
}
$ids = array();
CRM_Contribute_BAO_Contribution::resolveDefaults($params, true);
$contribution = CRM_Contribute_BAO_Contribution::create($params, $ids);
return $contribution;
}