3 +--------------------------------------------------------------------+
4 | CiviCRM version 4.4 |
5 +--------------------------------------------------------------------+
6 | Copyright CiviCRM LLC (c) 2004-2013 |
7 +--------------------------------------------------------------------+
8 | This file is a part of CiviCRM. |
10 | CiviCRM is free software; you can copy, modify, and distribute it |
11 | under the terms of the GNU Affero General Public License |
12 | Version 3, 19 November 2007 and the CiviCRM Licensing Exception. |
14 | CiviCRM is distributed in the hope that it will be useful, but |
15 | WITHOUT ANY WARRANTY; without even the implied warranty of |
16 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. |
17 | See the GNU Affero General Public License for more details. |
19 | You should have received a copy of the GNU Affero General Public |
20 | License and the CiviCRM Licensing Exception along |
21 | with this program; if not, contact CiviCRM LLC |
22 | at info[AT]civicrm[DOT]org. If you have questions about the |
23 | GNU Affero General Public License or the licensing of CiviCRM, |
24 | see the CiviCRM license FAQ at http://civicrm.org/licensing |
25 +--------------------------------------------------------------------+
31 * @copyright CiviCRM LLC (c) 2004-2013
37 * This class generates form components for Payment-Instrument
40 class CRM_Contribute_Form_ContributionView
extends CRM_Core_Form
{
43 * Function to set variables up before form is built
48 public function preProcess() {
49 $id = $this->get('id');
50 $values = $ids = array();
51 $params = array('id' => $id);
52 $context = CRM_Utils_Request
::retrieve('context', 'String', $this);
53 $this->assign('context', $context);
55 CRM_Contribute_BAO_Contribution
::getValues($params, $values, $ids);
56 CRM_Contribute_BAO_Contribution
::resolveDefaults($values);
58 if (CRM_Utils_Array
::value('contribution_page_id', $values)) {
59 $contribPages = CRM_Contribute_PseudoConstant
::contributionPage(NULL, TRUE);
60 $values['contribution_page_title'] = CRM_Utils_Array
::value(CRM_Utils_Array
::value('contribution_page_id', $values), $contribPages);
63 // get recieved into i.e to_financial_account_id from last trxn
64 $financialTrxnId = CRM_Core_BAO_FinancialTrxn
::getFinancialTrxnId($values['contribution_id'], 'DESC');
65 $values['to_financial_account'] = '';
66 if (CRM_Utils_Array
::value('financialTrxnId', $financialTrxnId)) {
67 $values['to_financial_account_id'] = CRM_Core_DAO
::getFieldValue('CRM_Financial_DAO_FinancialTrxn', $financialTrxnId['financialTrxnId'], 'to_financial_account_id');
68 if ($values['to_financial_account_id']) {
69 $values['to_financial_account'] = CRM_Contribute_PseudoConstant
::financialAccount($values['to_financial_account_id']);
73 if (CRM_Utils_Array
::value('honor_contact_id', $values)) {
74 $sql = "SELECT display_name FROM civicrm_contact WHERE id = %1";
75 $params = array(1 => array($values['honor_contact_id'], 'Integer'));
76 $dao = CRM_Core_DAO
::executeQuery($sql, $params);
78 $url = CRM_Utils_System
::url('civicrm/contact/view', "reset=1&cid=$values[honor_contact_id]");
79 $values['honor_display'] = "<A href = $url>" . $dao->display_name
. "</A>";
81 $honor = CRM_Core_PseudoConstant
::get('CRM_Contribute_DAO_Contribution', 'honor_type_id');
82 $values['honor_type'] = CRM_Utils_Array
::value(CRM_Utils_Array
::value('honor_type_id', $values), $honor);
85 if (CRM_Utils_Array
::value('contribution_recur_id', $values)) {
86 $sql = "SELECT installments, frequency_interval, frequency_unit FROM civicrm_contribution_recur WHERE id = %1";
87 $params = array(1 => array($values['contribution_recur_id'], 'Integer'));
88 $dao = CRM_Core_DAO
::executeQuery($sql, $params);
90 $values['recur_installments'] = $dao->installments
;
91 $values['recur_frequency_unit'] = $dao->frequency_unit
;
92 $values['recur_frequency_interval'] = $dao->frequency_interval
;
96 $groupTree = CRM_Core_BAO_CustomGroup
::getTree('Contribution', $this, $id, 0, CRM_Utils_Array
::value('financial_type_id', $values));
97 CRM_Core_BAO_CustomGroup
::buildCustomDataView($this, $groupTree);
101 $dao = new CRM_Contribute_DAO_ContributionProduct();
102 $dao->contribution_id
= $id;
103 if ($dao->find(TRUE)) {
104 $premiumId = $dao->id
;
105 $productID = $dao->product_id
;
110 $productDAO = new CRM_Contribute_DAO_Product();
111 $productDAO->id
= $productID;
112 $productDAO->find(TRUE);
114 $this->assign('premium', $productDAO->name
);
115 $this->assign('option', $dao->product_option
);
116 $this->assign('fulfilled', $dao->fulfilled_date
);
120 $noteValue = CRM_Core_BAO_Note
::getNote(CRM_Utils_Array
::value('id', $values), 'civicrm_contribution');
121 $values['note'] = array_values($noteValue);
123 // show billing address location details, if exists
124 if (CRM_Utils_Array
::value('address_id', $values)) {
125 $addressParams = array('id' => CRM_Utils_Array
::value('address_id', $values));
126 $addressDetails = CRM_Core_BAO_Address
::getValues($addressParams, FALSE, 'id');
127 $addressDetails = array_values($addressDetails);
128 $values['billing_address'] = $addressDetails[0]['display'];
131 //get soft credit record if exists.
132 $values['softContributions'] = CRM_Contribute_BAO_ContributionSoft
::getSoftContribution($values['contribution_id']);
134 $lineItems = array();
136 $lineItem = CRM_Price_BAO_LineItem
::getLineItems($id, 'contribution', 1);
137 empty($lineItem) ?
null :$lineItems[] = $lineItem;
139 $this->assign('lineItem', empty($lineItems) ?
FALSE : $lineItems);
140 $values['totalAmount'] = $values['total_amount'];
142 //do check for campaigns
143 if ($campaignId = CRM_Utils_Array
::value('campaign_id', $values)) {
144 $campaigns = CRM_Campaign_BAO_Campaign
::getCampaigns($campaignId);
145 $values['campaign'] = $campaigns[$campaignId];
148 // assign values to the template
149 $this->assign($values);
151 $displayName = CRM_Contact_BAO_Contact
::displayName($values['contact_id']);
152 $this->assign('displayName', $displayName);
154 // Check if this is default domain contact CRM-10482
155 if (CRM_Contact_BAO_Contact
::checkDomainContact($values['contact_id'])) {
156 $displayName .= ' (' . ts('default organization') . ')';
159 // omitting contactImage from title for now since the summary overlay css doesn't work outside of our crm-container
160 CRM_Utils_System
::setTitle(ts('View Contribution from') . ' ' . $displayName);
162 // add viewed contribution to recent items list
163 $url = CRM_Utils_System
::url('civicrm/contact/view/contribution',
164 "action=view&reset=1&id={$values['id']}&cid={$values['contact_id']}&context=home"
167 $title = $displayName . ' - (' . CRM_Utils_Money
::format($values['total_amount']) . ' ' . ' - ' . $values['financial_type'] . ')';
169 $recentOther = array();
170 if (CRM_Core_Permission
::checkActionPermission('CiviContribute', CRM_Core_Action
::UPDATE
)) {
171 $recentOther['editUrl'] = CRM_Utils_System
::url('civicrm/contact/view/contribution',
172 "action=update&reset=1&id={$values['id']}&cid={$values['contact_id']}&context=home"
175 if (CRM_Core_Permission
::checkActionPermission('CiviContribute', CRM_Core_Action
::DELETE
)) {
176 $recentOther['deleteUrl'] = CRM_Utils_System
::url('civicrm/contact/view/contribution',
177 "action=delete&reset=1&id={$values['id']}&cid={$values['contact_id']}&context=home"
180 CRM_Utils_Recent
::add($title,
184 $values['contact_id'],
191 * Function to build the form
196 public function buildQuickForm() {
198 $this->addButtons(array(
201 'name' => ts('Done'),
202 'spacing' => ' ',