本文整理汇总了PHP中CRM_Core_BAO_Address::getValues方法的典型用法代码示例。如果您正苦于以下问题:PHP CRM_Core_BAO_Address::getValues方法的具体用法?PHP CRM_Core_BAO_Address::getValues怎么用?PHP CRM_Core_BAO_Address::getValues使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类CRM_Core_BAO_Address
的用法示例。
在下文中一共展示了CRM_Core_BAO_Address::getValues方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: preProcess
/**
* Call preprocess.
*/
public function preProcess()
{
parent::preProcess();
$this->_locBlockNo = CRM_Utils_Request::retrieve('locno', 'Positive', $this, TRUE, NULL, $_REQUEST);
$this->assign('blockId', $this->_locBlockNo);
$addressSequence = CRM_Core_BAO_Address::addressSequence();
$this->assign('addressSequence', $addressSequence);
$this->_values = array();
$this->_addressId = CRM_Utils_Request::retrieve('aid', 'Positive', $this, FALSE, NULL, $_REQUEST);
$this->_action = CRM_Core_Action::ADD;
if ($this->_addressId) {
$params = array('id' => $this->_addressId);
$address = CRM_Core_BAO_Address::getValues($params, FALSE, 'id');
$this->_values['address'][$this->_locBlockNo] = array_pop($address);
$this->_action = CRM_Core_Action::UPDATE;
} else {
$this->_addressId = 0;
}
$this->assign('action', $this->_action);
$this->assign('addressId', $this->_addressId);
// parse street address, CRM-5450
$this->_parseStreetAddress = $this->get('parseStreetAddress');
if (!isset($this->_parseStreetAddress)) {
$addressOptions = CRM_Core_BAO_Setting::valueOptions(CRM_Core_BAO_Setting::SYSTEM_PREFERENCES_NAME, 'address_options');
$this->_parseStreetAddress = FALSE;
if (!empty($addressOptions['street_address']) && !empty($addressOptions['street_address_parsing'])) {
$this->_parseStreetAddress = TRUE;
}
$this->set('parseStreetAddress', $this->_parseStreetAddress);
}
$this->assign('parseStreetAddress', $this->_parseStreetAddress);
}
示例2: run
/**
* Run the page.
*
* This method is called after the page is created.
*/
public function run()
{
// get the emails for this contact
$contactId = CRM_Utils_Request::retrieve('cid', 'Positive', CRM_Core_DAO::$_nullObject, TRUE, NULL, $_REQUEST);
$locBlockNo = CRM_Utils_Request::retrieve('locno', 'Positive', CRM_Core_DAO::$_nullObject, TRUE, NULL, $_REQUEST);
$addressId = CRM_Utils_Request::retrieve('aid', 'Positive', CRM_Core_DAO::$_nullObject, FALSE, NULL, $_REQUEST);
$address = array();
if ($addressId > 0) {
$locationTypes = CRM_Core_PseudoConstant::get('CRM_Core_DAO_Address', 'location_type_id', array('labelColumn' => 'display_name'));
$entityBlock = array('id' => $addressId);
$address = CRM_Core_BAO_Address::getValues($entityBlock, FALSE, 'id');
if (!empty($address)) {
foreach ($address as $key => &$value) {
$value['location_type'] = $locationTypes[$value['location_type_id']];
}
}
}
// we just need current address block
$currentAddressBlock['address'][$locBlockNo] = array_pop($address);
if (!empty($currentAddressBlock['address'][$locBlockNo])) {
// get contact name of shared contact names
$sharedAddresses = array();
$shareAddressContactNames = CRM_Contact_BAO_Contact_Utils::getAddressShareContactNames($currentAddressBlock['address']);
foreach ($currentAddressBlock['address'] as $key => $addressValue) {
if (!empty($addressValue['master_id']) && !$shareAddressContactNames[$addressValue['master_id']]['is_deleted']) {
$sharedAddresses[$key]['shared_address_display'] = array('address' => $addressValue['display'], 'name' => $shareAddressContactNames[$addressValue['master_id']]['name']);
}
}
$idValue = $currentAddressBlock['address'][$locBlockNo]['id'];
if (!empty($currentAddressBlock['address'][$locBlockNo]['master_id'])) {
$idValue = $currentAddressBlock['address'][$locBlockNo]['master_id'];
}
// add custom data of type address
$groupTree = CRM_Core_BAO_CustomGroup::getTree('Address', $this, $idValue);
// we setting the prefix to dnc_ below so that we don't overwrite smarty's grouptree var.
$currentAddressBlock['address'][$locBlockNo]['custom'] = CRM_Core_BAO_CustomGroup::buildCustomDataView($this, $groupTree, FALSE, NULL, "dnc_");
$this->assign("dnc_viewCustomData", NULL);
$this->assign('add', $currentAddressBlock['address'][$locBlockNo]);
$this->assign('sharedAddresses', $sharedAddresses);
}
$contact = new CRM_Contact_BAO_Contact();
$contact->id = $contactId;
$contact->find(TRUE);
$privacy = array();
foreach (CRM_Contact_BAO_Contact::$_commPrefs as $name) {
if (isset($contact->{$name})) {
$privacy[$name] = $contact->{$name};
}
}
$this->assign('contactId', $contactId);
$this->assign('locationIndex', $locBlockNo);
$this->assign('addressId', $addressId);
$this->assign('privacy', $privacy);
// check logged in user permission
CRM_Contact_Page_View::checkUserPermission($this, $contactId);
// finally call parent
parent::run();
}
示例3: run
/**
* Run the page.
*
* This method is called after the page is created.
*
* @return void
* @access public
*
*/
function run()
{
// get the emails for this contact
$contactId = CRM_Utils_Request::retrieve('cid', 'Positive', CRM_Core_DAO::$_nullObject, TRUE, NULL, $_REQUEST);
$locBlockNo = CRM_Utils_Request::retrieve('locno', 'Positive', CRM_Core_DAO::$_nullObject, TRUE, NULL, $_REQUEST);
$addressId = CRM_Utils_Request::retrieve('aid', 'Positive', CRM_Core_DAO::$_nullObject, FALSE, NULL, $_REQUEST);
$address = array();
if ($addressId > 0) {
$locationTypes = CRM_Core_PseudoConstant::locationDisplayName();
$entityBlock = array('id' => $addressId);
$address = CRM_Core_BAO_Address::getValues($entityBlock, FALSE, 'id');
if (!empty($address)) {
foreach ($address as $key => &$value) {
$value['location_type'] = $locationTypes[$value['location_type_id']];
}
}
}
// we just need current address block
$currentAddressBlock['address'][$locBlockNo] = array_pop($address);
if (!empty($currentAddressBlock['address'][$locBlockNo])) {
// get contact name of shared contact names
$sharedAddresses = array();
$shareAddressContactNames = CRM_Contact_BAO_Contact_Utils::getAddressShareContactNames($currentAddressBlock['address']);
foreach ($currentAddressBlock['address'] as $key => $addressValue) {
if (CRM_Utils_Array::value('master_id', $addressValue) && !$shareAddressContactNames[$addressValue['master_id']]['is_deleted']) {
$sharedAddresses[$key]['shared_address_display'] = array('address' => $addressValue['display'], 'name' => $shareAddressContactNames[$addressValue['master_id']]['name']);
}
}
// add custom data of type address
$groupTree = CRM_Core_BAO_CustomGroup::getTree('Address', $this, $currentAddressBlock['address'][$locBlockNo]['id']);
// we setting the prefix to dnc_ below so that we don't overwrite smarty's grouptree var.
$currentAddressBlock['address'][$locBlockNo]['custom'] = CRM_Core_BAO_CustomGroup::buildCustomDataView($this, $groupTree, FALSE, NULL, "dnc_");
$this->assign("dnc_viewCustomData", NULL);
$this->assign('add', $currentAddressBlock['address'][$locBlockNo]);
$this->assign('sharedAddresses', $sharedAddresses);
}
$this->assign('contactId', $contactId);
$this->assign('locationIndex', $locBlockNo);
$this->assign('addressId', $addressId);
$appendBlockIndex = CRM_Core_BAO_Address::getAddressCount($contactId);
// check if we are adding new address, then only append add link
if ($appendBlockIndex == $locBlockNo) {
if ($appendBlockIndex) {
$appendBlockIndex++;
}
} else {
$appendBlockIndex = 0;
}
$this->assign('appendBlockIndex', $appendBlockIndex);
// check logged in user permission
CRM_Contact_Page_View::checkUserPermission($this, $contactId);
// finally call parent
parent::run();
}
示例4: _gatherMessageValues
/**
* Gather values for contribution mail - this function has been created
* as part of CRM-9996 refactoring as a step towards simplifying the composeMessage function
* Values related to the contribution in question are gathered
*
* @param array $input
* Input into function (probably from payment processor).
* @param array $values
* @param array $ids
* The set of ids related to the input.
*
* @return array
*/
public function _gatherMessageValues($input, &$values, $ids = array())
{
// set display address of contributor
if ($this->address_id) {
$addressParams = array('id' => $this->address_id);
$addressDetails = CRM_Core_BAO_Address::getValues($addressParams, FALSE, 'id');
$addressDetails = array_values($addressDetails);
$values['address'] = $addressDetails[0]['display'];
}
if ($this->_component == 'contribute') {
if (isset($this->contribution_page_id)) {
CRM_Contribute_BAO_ContributionPage::setValues($this->contribution_page_id, $values);
if ($this->contribution_page_id) {
// CRM-8254 - override default currency if applicable
$config = CRM_Core_Config::singleton();
$config->defaultCurrency = CRM_Utils_Array::value('currency', $values, $config->defaultCurrency);
}
} else {
// Handle re-print receipt for offline contributions (call from PDF.php - no contribution_page_id)
$values['is_email_receipt'] = 1;
$values['title'] = 'Contribution';
}
// set lineItem for contribution
if ($this->id) {
$lineItem = CRM_Price_BAO_LineItem::getLineItems($this->id, 'contribution', 1);
if (!empty($lineItem)) {
$itemId = key($lineItem);
foreach ($lineItem as &$eachItem) {
if (is_array($this->_relatedObjects['membership']) && array_key_exists($eachItem['membership_type_id'], $this->_relatedObjects['membership'])) {
$eachItem['join_date'] = CRM_Utils_Date::customFormat($this->_relatedObjects['membership'][$eachItem['membership_type_id']]->join_date);
$eachItem['start_date'] = CRM_Utils_Date::customFormat($this->_relatedObjects['membership'][$eachItem['membership_type_id']]->start_date);
$eachItem['end_date'] = CRM_Utils_Date::customFormat($this->_relatedObjects['membership'][$eachItem['membership_type_id']]->end_date);
}
}
$values['lineItem'][0] = $lineItem;
$values['priceSetID'] = CRM_Core_DAO::getFieldValue('CRM_Price_DAO_PriceField', $lineItem[$itemId]['price_field_id'], 'price_set_id');
}
}
$relatedContact = CRM_Contribute_BAO_Contribution::getOnbehalfIds($this->id, $this->contact_id);
// if this is onbehalf of contribution then set related contact
if (!empty($relatedContact['individual_id'])) {
$values['related_contact'] = $ids['related_contact'] = $relatedContact['individual_id'];
}
} else {
// event
$eventParams = array('id' => $this->_relatedObjects['event']->id);
$values['event'] = array();
CRM_Event_BAO_Event::retrieve($eventParams, $values['event']);
// add custom fields for event
$eventGroupTree = CRM_Core_BAO_CustomGroup::getTree('Event', $this->_relatedObjects['event'], $this->_relatedObjects['event']->id);
$eventCustomGroup = array();
foreach ($eventGroupTree as $key => $group) {
if ($key === 'info') {
continue;
}
foreach ($group['fields'] as $k => $customField) {
$groupLabel = $group['title'];
if (!empty($customField['customValue'])) {
foreach ($customField['customValue'] as $customFieldValues) {
$eventCustomGroup[$groupLabel][$customField['label']] = CRM_Utils_Array::value('data', $customFieldValues);
}
}
}
}
$values['event']['customGroup'] = $eventCustomGroup;
//get participant details
$participantParams = array('id' => $this->_relatedObjects['participant']->id);
$values['participant'] = array();
CRM_Event_BAO_Participant::getValues($participantParams, $values['participant'], $participantIds);
// add custom fields for event
$participantGroupTree = CRM_Core_BAO_CustomGroup::getTree('Participant', $this->_relatedObjects['participant'], $this->_relatedObjects['participant']->id);
$participantCustomGroup = array();
foreach ($participantGroupTree as $key => $group) {
if ($key === 'info') {
continue;
}
foreach ($group['fields'] as $k => $customField) {
$groupLabel = $group['title'];
if (!empty($customField['customValue'])) {
foreach ($customField['customValue'] as $customFieldValues) {
$participantCustomGroup[$groupLabel][$customField['label']] = CRM_Utils_Array::value('data', $customFieldValues);
}
}
}
}
$values['participant']['customGroup'] = $participantCustomGroup;
//get location details
//.........这里部分代码省略.........
示例5: printPDF
/**
* Process the PDf and email with activity and attachment.
* on click of Print Invoices
*
* @param array $contribIDs
* Contribution Id.
* @param array $params
* Associated array of submitted values.
* @param array $contactIds
* Contact Id.
* @param CRM_Core_Form $form
* Form object.
*/
public static function printPDF($contribIDs, &$params, $contactIds, &$form)
{
// get all the details needed to generate a invoice
$messageInvoice = array();
$invoiceTemplate = CRM_Core_Smarty::singleton();
$invoiceElements = CRM_Contribute_Form_Task_PDF::getElements($contribIDs, $params, $contactIds);
// gives the status id when contribution status is 'Refunded'
$contributionStatusID = CRM_Contribute_PseudoConstant::contributionStatus(NULL, 'name');
$refundedStatusId = CRM_Utils_Array::key('Refunded', $contributionStatusID);
// getting data from admin page
$prefixValue = CRM_Core_BAO_Setting::getItem(CRM_Core_BAO_Setting::CONTRIBUTE_PREFERENCES_NAME, 'contribution_invoice_settings');
foreach ($invoiceElements['details'] as $contribID => $detail) {
$input = $ids = $objects = array();
if (in_array($detail['contact'], $invoiceElements['excludeContactIds'])) {
continue;
}
$input['component'] = $detail['component'];
$ids['contact'] = $detail['contact'];
$ids['contribution'] = $contribID;
$ids['contributionRecur'] = NULL;
$ids['contributionPage'] = NULL;
$ids['membership'] = CRM_Utils_Array::value('membership', $detail);
$ids['participant'] = CRM_Utils_Array::value('participant', $detail);
$ids['event'] = CRM_Utils_Array::value('event', $detail);
if (!$invoiceElements['baseIPN']->validateData($input, $ids, $objects, FALSE)) {
CRM_Core_Error::fatal();
}
$contribution =& $objects['contribution'];
$input['amount'] = $contribution->total_amount;
$input['invoice_id'] = $contribution->invoice_id;
$input['receive_date'] = $contribution->receive_date;
$input['contribution_status_id'] = $contribution->contribution_status_id;
$input['organization_name'] = $contribution->_relatedObjects['contact']->organization_name;
$objects['contribution']->receive_date = CRM_Utils_Date::isoToMysql($objects['contribution']->receive_date);
$addressParams = array('contact_id' => $contribution->contact_id);
$addressDetails = CRM_Core_BAO_Address::getValues($addressParams);
// to get billing address if present
$billingAddress = array();
foreach ($addressDetails as $key => $address) {
if (isset($address['is_billing']) && $address['is_billing'] == 1 && (isset($address['is_primary']) && $address['is_primary'] == 1) && $address['contact_id'] == $contribution->contact_id) {
$billingAddress[$address['contact_id']] = $address;
break;
} elseif ($address['is_billing'] == 0 && $address['is_primary'] == 1 || isset($address['is_billing']) && $address['is_billing'] == 1 && $address['contact_id'] == $contribution->contact_id) {
$billingAddress[$address['contact_id']] = $address;
}
}
if (!empty($billingAddress[$contribution->contact_id]['state_province_id'])) {
$stateProvinceAbbreviation = CRM_Core_PseudoConstant::stateProvinceAbbreviation($billingAddress[$contribution->contact_id]['state_province_id']);
} else {
$stateProvinceAbbreviation = '';
}
if ($contribution->contribution_status_id == $refundedStatusId) {
$creditNoteId = CRM_Utils_Array::value('credit_notes_prefix', $prefixValue) . "" . $contribution->id;
}
$invoiceId = CRM_Utils_Array::value('invoice_prefix', $prefixValue) . "" . $contribution->id;
//to obtain due date for PDF invoice
$contributionReceiveDate = date('F j,Y', strtotime(date($input['receive_date'])));
$invoiceDate = date("F j, Y");
$dueDate = date('F j ,Y', strtotime($contributionReceiveDate . "+" . $prefixValue['due_date'] . "" . $prefixValue['due_date_period']));
if ($input['component'] == 'contribute') {
$eid = $contribID;
$etable = 'contribution';
$lineItem = CRM_Price_BAO_LineItem::getLineItems($eid, $etable, NULL, TRUE, TRUE);
} else {
$eid = $contribution->_relatedObjects['participant']->id;
$etable = 'participant';
$lineItem = CRM_Price_BAO_LineItem::getLineItems($eid, $etable);
}
//TO DO: Need to do changes for partially paid to display amount due on PDF invoice
$amountDue = $input['amount'] - $input['amount'];
// retreiving the subtotal and sum of same tax_rate
$dataArray = array();
$subTotal = 0;
foreach ($lineItem as $entity_id => $taxRate) {
if (isset($dataArray[(string) $taxRate['tax_rate']])) {
$dataArray[(string) $taxRate['tax_rate']] = $dataArray[(string) $taxRate['tax_rate']] + CRM_Utils_Array::value('tax_amount', $taxRate);
} else {
$dataArray[(string) $taxRate['tax_rate']] = CRM_Utils_Array::value('tax_amount', $taxRate);
}
$subTotal += CRM_Utils_Array::value('subTotal', $taxRate);
}
// to email the invoice
$mailDetails = array();
$values = array();
if ($contribution->_component == 'event') {
$daoName = 'CRM_Event_DAO_Event';
$pageId = $contribution->_relatedObjects['event']->id;
//.........这里部分代码省略.........
示例6: 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];
}
//.........这里部分代码省略.........
示例7: testGetValues
/**
* GetValues() method (get Address fields)
*/
public function testGetValues()
{
$contactId = Contact::createIndividual();
$params = array();
$params['address']['1'] = array('street_address' => 'Oberoi Garden', 'supplemental_address_1' => 'Attn: Accounting', 'supplemental_address_2' => 'Powai', 'city' => 'Athens', 'postal_code' => '01903', 'state_province_id' => '1000', 'country_id' => '1228', 'geo_code_1' => '18.219023', 'geo_code_2' => '-105.00973', 'location_type_id' => '1', 'is_primary' => '1', 'is_billing' => '0');
$params['contact_id'] = $contactId;
$fixAddress = TRUE;
CRM_Core_BAO_Address::create($params, $fixAddress, $entity = NULL);
$addressId = $this->assertDBNotNull('CRM_Core_DAO_Address', $contactId, 'id', 'contact_id', 'Database check for created address.');
$entityBlock = array('contact_id' => $contactId);
$address = CRM_Core_BAO_Address::getValues($entityBlock);
$this->assertEquals($address[1]['id'], $addressId);
$this->assertEquals($address[1]['contact_id'], $contactId);
$this->assertEquals($address[1]['street_address'], 'Oberoi Garden');
Contact::delete($contactId);
}
示例8: addContributionToBatch
/**
* Given an array of contributionIDs, add them to a batch
*
* @param array $contributionIDs (reference ) the array of contribution ids to be added
* @param int $batchID - the batchID to be added to
*
* @return array (total, added, notAdded) ids of contributions added to the batch
* @access public
* @static
*/
static function addContributionToBatch($contributionIDs, $batchID)
{
$date = date('YmdHis');
$contributionsAdded = array();
$contributionsNotAdded = array();
require_once "DirectDebit/Utils/DirectDebit.php";
require_once "CRM/Contribute/BAO/Contribution.php";
require_once 'CRM/Core/DAO/EntityBatch.php';
require_once "CRM/Core/BAO/Address.php";
require_once "CRM/Contact/BAO/Contact.php";
require_once "CRM/Utils/Address.php";
foreach ($contributionIDs as $contributionID) {
$batchContribution =& new CRM_Core_DAO_EntityBatch();
$batchContribution->entity_table = 'civicrm_contribution';
$batchContribution->entity_id = $contributionID;
// check if the selected contribution id already in a batch
// if not, add to batchContribution else keep the count of contributions that are not added
if ($batchContribution->find(true)) {
$contributionsNotAdded[] = $contributionID;
continue;
}
// get additional info
// get contribution details from Contribution using contribution id
$params = array('id' => $contributionID);
CRM_Contribute_BAO_Contribution::retrieve($params, $contribution, $ids);
$contactId = $contribution['contact_id'];
// check if contribution is valid for gift aid
if (DirectDebit_Utils_DirectDebit::isEligibleForGiftAid($contactId, $contribution['receive_date'], $contributionID)) {
$batchContribution->batch_id = $batchID;
$batchContribution->save();
// get display name
$displayName = CRM_Contact_BAO_Contact::displayName($contactId);
// get Address & Postal Code from Address
$params = array('contact_id' => $contactId, 'is_primary' => 1);
$address = CRM_Core_BAO_Address::getValues($params);
$address = $address[1];
//adds all address lines to the report
$fullFormatedAddress = CRM_Utils_Address::format($address);
// Use addslashes function to avoid error of the fields have single quotes
$displayName = addslashes($displayName);
$fullFormatedAddress = addslashes($fullFormatedAddress);
$address['postal_code'] = addslashes($address['postal_code']);
// FIXME: check if there is customTable method
//$query = "INSERT INTO civicrm_value_direct_debit_details
// (entity_id, name, address, post_code, amount)
// VALUES ({$contributionID}, '{$displayName}', '{$fullFormatedAddress}', '{$address['postal_code']}', {$contribution['total_amount']})
// ON DUPLICATE KEY UPDATE name = '{$displayName}' , address = '{$fullFormatedAddress}' , post_code = '{$address['postal_code']}' , amount = '{$contribution['total_amount']}'";
$query = "UPDATE civicrm_value_direct_debit_details SET added_to_direct_debit = 1 WHERE entity_id = '{$contributionID}'";
CRM_Core_DAO::executeQuery($query);
$contributionsAdded[] = $contributionID;
} else {
$contributionsNotAdded[] = $contributionID;
}
}
if (!empty($contributionsAdded)) {
// if there is any extra work required to be done for contributions that are batched,
// should be done via hook
DirectDebit_Utils_Hook::batchContributions($batchID, $contributionsAdded);
}
return array(count($contributionIDs), count($contributionsAdded), count($contributionsNotAdded));
}
示例9: getAddressDisplay
static function getAddressDisplay()
{
$contactId = CRM_Utils_Array::value('contact_id', $_POST);
if (!$contactId) {
$addressVal["error_message"] = "no contact id found";
} else {
$entityBlock = array('contact_id' => $contactId, 'entity_id' => $contactId);
$addressVal = CRM_Core_BAO_Address::getValues($entityBlock);
}
echo json_encode($addressVal);
CRM_Utils_System::civiExit();
}
示例10: sendMail
function sendMail(&$input, &$ids, &$objects, &$values, $recur = false, $returnMessageText = false)
{
$contribution =& $objects['contribution'];
$membership =& $objects['membership'];
$participant =& $objects['participant'];
$event =& $objects['event'];
if (empty($values)) {
$values = array();
if ($input['component'] == 'contribute') {
require_once 'CRM/Contribute/BAO/ContributionPage.php';
if (isset($contribution->contribution_page_id)) {
CRM_Contribute_BAO_ContributionPage::setValues($contribution->contribution_page_id, $values);
} else {
// Handle re-print receipt for offline contributions (call from PDF.php - no contribution_page_id)
$values['is_email_receipt'] = 1;
$values['title'] = 'Contribution';
}
} else {
// event
$eventParams = array('id' => $objects['event']->id);
$values['event'] = array();
require_once 'CRM/Event/BAO/Event.php';
CRM_Event_BAO_Event::retrieve($eventParams, $values['event']);
$eventParams = array('id' => $objects['event']->id);
$values['event'] = array();
require_once 'CRM/Event/BAO/Event.php';
CRM_Event_BAO_Event::retrieve($eventParams, $values['event']);
//get location details
$locationParams = array('entity_id' => $objects['event']->id, 'entity_table' => 'civicrm_event');
require_once 'CRM/Core/BAO/Location.php';
require_once 'CRM/Event/Form/ManageEvent/Location.php';
$values['location'] = CRM_Core_BAO_Location::getValues($locationParams);
require_once 'CRM/Core/BAO/UFJoin.php';
$ufJoinParams = array('entity_table' => 'civicrm_event', 'entity_id' => $ids['event'], 'weight' => 1);
$values['custom_pre_id'] = CRM_Core_BAO_UFJoin::findUFGroupId($ufJoinParams);
$ufJoinParams['weight'] = 2;
$values['custom_post_id'] = CRM_Core_BAO_UFJoin::findUFGroupId($ufJoinParams);
}
}
$template =& CRM_Core_Smarty::singleton();
// CRM_Core_Error::debug('tpl',$template);
//assign honor infomation to receiptmessage
if ($honarID = CRM_Core_DAO::getFieldValue('CRM_Contribute_DAO_Contribution', $contribution->id, 'honor_contact_id')) {
$honorDefault = array();
$honorIds = array();
$honorIds['contribution'] = $contribution->id;
$idParams = array('id' => $honarID, 'contact_id' => $honarID);
require_once "CRM/Contact/BAO/Contact.php";
CRM_Contact_BAO_Contact::retrieve($idParams, $honorDefault, $honorIds);
require_once "CRM/Core/PseudoConstant.php";
$honorType = CRM_Core_PseudoConstant::honor();
$prefix = CRM_Core_PseudoConstant::individualPrefix();
$template->assign('honor_block_is_active', 1);
$template->assign('honor_prefix', $prefix[$honorDefault["prefix_id"]]);
$template->assign('honor_first_name', CRM_Utils_Array::value("first_name", $honorDefault));
$template->assign('honor_last_name', CRM_Utils_Array::value("last_name", $honorDefault));
$template->assign('honor_email', CRM_Utils_Array::value("email", $honorDefault["email"][1]));
$template->assign('honor_type', $honorType[$contribution->honor_type_id]);
}
require_once 'CRM/Contribute/DAO/ContributionProduct.php';
$dao =& new CRM_Contribute_DAO_ContributionProduct();
$dao->contribution_id = $contribution->id;
if ($dao->find(true)) {
$premiumId = $dao->product_id;
$template->assign('option', $dao->product_option);
require_once 'CRM/Contribute/DAO/Product.php';
$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);
}
// add the new contribution values
if ($input['component'] == 'contribute') {
$template->assign('title', $values['title']);
$template->assign('amount', $input['amount']);
//PCP Info
require_once 'CRM/Contribute/DAO/ContributionSoft.php';
$softDAO =& new CRM_Contribute_DAO_ContributionSoft();
$softDAO->contribution_id = $contribution->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
require_once 'CRM/Contribute/DAO/PCP.php';
$pcpDAO =& new CRM_Contribute_DAO_PCP();
$pcpDAO->id = $softDAO->pcp_id;
if ($pcpDAO->find(true)) {
$template->assign('title', $pcpDAO->title);
}
}
} else {
$template->assign('title', $values['event']['title']);
$template->assign('totalAmount', $input['amount']);
}
$template->assign('trxn_id', $contribution->trxn_id);
//.........这里部分代码省略.........
示例11: 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'] . ')';
//.........这里部分代码省略.........
示例12: getAddressDisplay
static function getAddressDisplay()
{
$contactId = CRM_Utils_Array::value('contact_id', $_REQUEST);
if (!$contactId) {
$addressVal["error_message"] = "no contact id found";
} else {
$entityBlock = array('contact_id' => $contactId, 'entity_id' => $contactId);
$addressVal = CRM_Core_BAO_Address::getValues($entityBlock);
}
CRM_Utils_JSON::output($addressVal);
}
示例13: addContributionToBatch
/**
* Given an array of contributionIDs, add them to a batch
*
* @param array $contributionIDs (reference ) the array of contribution ids to be added
* @param int $batchID - the batchID to be added to
*
* @return array (total, added, notAdded) ids of contributions added to the batch
* @access public
* @static
*/
static function addContributionToBatch($contributionIDs, $batchID)
{
$date = date('YmdHis');
$contributionsAdded = array();
$contributionsNotAdded = array();
require_once "GiftAid/Utils/GiftAid.php";
require_once "CRM/Contribute/BAO/Contribution.php";
require_once 'CRM/Core/DAO/EntityBatch.php';
require_once "CRM/Core/BAO/Address.php";
require_once "CRM/Contact/BAO/Contact.php";
require_once "CRM/Utils/Address.php";
$charityColumnExists = CRM_Core_DAO::checkFieldExists('civicrm_value_gift_aid_submission', 'charity');
foreach ($contributionIDs as $contributionID) {
$batchContribution =& new CRM_Core_DAO_EntityBatch();
$batchContribution->entity_table = 'civicrm_contribution';
$batchContribution->entity_id = $contributionID;
// check if the selected contribution id already in a batch
// if not, add to batchContribution else keep the count of contributions that are not added
if ($batchContribution->find(true)) {
$contributionsNotAdded[] = $contributionID;
continue;
}
// get additional info
// get contribution details from Contribution using contribution id
$params = array('id' => $contributionID);
CRM_Contribute_BAO_Contribution::retrieve($params, $contribution, $ids);
$contactId = $contribution['contact_id'];
// check if contribution is valid for gift aid
if (GiftAid_Utils_GiftAid::isEligibleForGiftAid($contactId, $contribution['receive_date'], $contributionID)) {
$batchContribution->batch_id = $batchID;
$batchContribution->save();
// get display name
$displayName = CRM_Contact_BAO_Contact::displayName($contactId);
// get Address & Postal Code from Address
$params = array('contact_id' => $contactId, 'is_primary' => 1);
$address = CRM_Core_BAO_Address::getValues($params);
$address = $address[1];
//adds all address lines to the report
$fullFormatedAddress = CRM_Utils_Address::format($address);
// get gift aid amount
$giftAidAmount = self::_calculateGiftAidAmt($contribution['total_amount']);
// FIXME: check if there is customTable method
$query = "\nINSERT INTO civicrm_value_gift_aid_submission \n(entity_id, eligible_for_gift_aid, name, address, post_code, amount, gift_aid_amount) \nVALUES \n ( %1, 1, %2, %3, %4, %5, %6 )\nON DUPLICATE KEY UPDATE \nname = %2, \naddress = %3,\npost_code = %4,\namount = %5,\ngift_aid_amount = %6\n";
$sqlParams = array(1 => array($contributionID, 'Integer'), 2 => array($displayName, 'String'), 3 => array($fullFormatedAddress, 'String'), 4 => array($address['postal_code'], 'String'), 5 => array($contribution['total_amount'], 'Money'), 6 => array($giftAidAmount, 'Money'));
CRM_Core_DAO::executeQuery($query, $sqlParams);
$contributionsAdded[] = $contributionID;
} else {
$contributionsNotAdded[] = $contributionID;
}
}
if (!empty($contributionsAdded)) {
// if there is any extra work required to be done for contributions that are batched,
// should be done via hook
GiftAid_Utils_Hook::batchContributions($batchID, $contributionsAdded);
}
return array(count($contributionIDs), count($contributionsAdded), count($contributionsNotAdded));
}
示例14: setDefaultValues
/**
* Set default values for address block.
*
* @param array $defaults
* Defaults associated array.
* @param CRM_Core_Form $form
* Form object.
*/
public static function setDefaultValues(&$defaults, &$form)
{
$addressValues = array();
if (isset($defaults['address']) && is_array($defaults['address']) && !CRM_Utils_System::isNull($defaults['address'])) {
// start of contact shared adddress defaults
$sharedAddresses = array();
$masterAddress = array();
// get contact name of shared contact names
$shareAddressContactNames = CRM_Contact_BAO_Contact_Utils::getAddressShareContactNames($defaults['address']);
foreach ($defaults['address'] as $key => $addressValue) {
if (!empty($addressValue['master_id']) && !$shareAddressContactNames[$addressValue['master_id']]['is_deleted']) {
$master_cid = $shareAddressContactNames[$addressValue['master_id']]['contact_id'];
$sharedAddresses[$key]['shared_address_display'] = array('address' => $addressValue['display'], 'name' => $shareAddressContactNames[$addressValue['master_id']]['name'], 'options' => CRM_Core_BAO_Address::getValues(array('entity_id' => $master_cid, 'contact_id' => $master_cid)), 'master_id' => $addressValue['master_id']);
$defaults['address'][$key]['master_contact_id'] = $master_cid;
} else {
$defaults['address'][$key]['use_shared_address'] = 0;
}
//check if any address is shared by any other contacts
$masterAddress[$key] = CRM_Core_BAO_Address::checkContactSharedAddress($addressValue['id']);
}
$form->assign('sharedAddresses', $sharedAddresses);
$form->assign('masterAddress', $masterAddress);
// end of shared address defaults
// start of parse address functionality
// build street address, CRM-5450.
if ($form->_parseStreetAddress) {
$parseFields = array('street_address', 'street_number', 'street_name', 'street_unit');
foreach ($defaults['address'] as $cnt => &$address) {
$streetAddress = NULL;
foreach (array('street_number', 'street_number_suffix', 'street_name', 'street_unit') as $fld) {
if (in_array($fld, array('street_name', 'street_unit'))) {
$streetAddress .= ' ';
}
$streetAddress .= CRM_Utils_Array::value($fld, $address);
}
$streetAddress = trim($streetAddress);
if (!empty($streetAddress)) {
$address['street_address'] = $streetAddress;
}
if (isset($address['street_number'])) {
$address['street_number'] .= CRM_Utils_Array::value('street_number_suffix', $address);
}
// build array for set default.
foreach ($parseFields as $field) {
$addressValues["{$field}_{$cnt}"] = CRM_Utils_Array::value($field, $address);
}
// don't load fields, use js to populate.
foreach (array('street_number', 'street_name', 'street_unit') as $f) {
if (isset($address[$f])) {
unset($address[$f]);
}
}
}
$form->assign('allAddressFieldValues', json_encode($addressValues));
//hack to handle show/hide address fields.
$parsedAddress = array();
if ($form->_contactId && !empty($_POST['address']) && is_array($_POST['address'])) {
foreach ($_POST['address'] as $cnt => $values) {
$showField = 'streetAddress';
foreach (array('street_number', 'street_name', 'street_unit') as $fld) {
if (!empty($values[$fld])) {
$showField = 'addressElements';
break;
}
}
$parsedAddress[$cnt] = $showField;
}
}
$form->assign('showHideAddressFields', $parsedAddress);
$form->assign('loadShowHideAddressFields', empty($parsedAddress) ? FALSE : TRUE);
}
// end of parse address functionality
}
}
示例15: 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);
}