3 +--------------------------------------------------------------------+
5 +--------------------------------------------------------------------+
6 | Copyright CiviCRM LLC (c) 2004-2019 |
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-2019
33 class CRM_Contribute_Page_UserDashboard
extends CRM_Contact_Page_View_UserDashBoard
{
36 * called when action is browse.
38 public function listContribution() {
39 $rows = civicrm_api3('Contribution', 'get', [
40 'options' => ['limit' => 12],
42 'contact_id' => $this->_contactId
,
45 'contribution_recur_id',
49 'contribution_status',
53 'contribution_source',
57 foreach ($rows as $index => $row) {
58 // This is required for tpl logic. We should move away from hard-code this to adding an array of actions to the row
59 // which the tpl can iterate through - this should allow us to cope with competing attempts to add new buttons
60 // and allow extensions to assign new ones through the pageRun hook
61 $row[0]['contribution_status_name'] = CRM_Core_PseudoConstant
::getName('CRM_Contribute_BAO_Contribution', 'contribution_status_id', $row['contribution_status_id']);;
64 $this->assign('contribute_rows', $rows);
65 $this->assign('contributionSummary', ['total_amount' => civicrm_api3('Contribution', 'getcount', ['contact_id' => $this->_contactId
])]);
68 $params = CRM_Contribute_BAO_Contribution
::getHonorContacts($this->_contactId
);
70 if (!empty($params)) {
71 // assign vars to templates
72 $this->assign('honorRows', $params);
73 $this->assign('honor', TRUE);
76 $recur = new CRM_Contribute_DAO_ContributionRecur();
77 $recur->contact_id
= $this->_contactId
;
81 $recurStatus = CRM_Contribute_PseudoConstant
::contributionStatus();
85 while ($recur->fetch()) {
86 if (empty($recur->payment_processor_id
)) {
87 // it's not clear why we continue here as any without a processor id would likely
88 // be imported from another system & still seem valid.
92 require_once 'api/v3/utils.php';
93 //@todo calling api functions directly is not supported
94 _civicrm_api3_object_to_array($recur, $values);
96 $values['recur_status'] = $recurStatus[$values['contribution_status_id']];
97 $recurRow[$values['id']] = $values;
99 $action = array_sum(array_keys(CRM_Contribute_Page_Tab
::recurLinks($recur->id
, 'dashboard')));
101 $details = CRM_Contribute_BAO_ContributionRecur
::getSubscriptionDetails($recur->id
, 'recur');
102 $hideUpdate = $details->membership_id
& $details->auto_renew
;
105 $action -= CRM_Core_Action
::UPDATE
;
108 $recurRow[$values['id']]['action'] = CRM_Core_Action
::formLink(CRM_Contribute_Page_Tab
::recurLinks($recur->id
, 'dashboard'),
110 'cid' => $this->_contactId
,
111 'crid' => $values['id'],
112 'cxt' => 'contribution',
116 'contribution.dashboard.recurring',
121 $recurIDs[] = $values['id'];
123 if (is_array($recurIDs) && !empty($recurIDs)) {
124 $getCount = CRM_Contribute_BAO_ContributionRecur
::getCount($recurIDs);
125 foreach ($getCount as $key => $val) {
126 $recurRow[$key]['completed'] = $val;
127 $recurRow[$key]['link'] = CRM_Utils_System
::url('civicrm/contribute/search',
128 "reset=1&force=1&recur=$key"
133 $this->assign('recurRows', $recurRow);
134 if (!empty($recurRow)) {
135 $this->assign('recur', TRUE);
138 $this->assign('recur', FALSE);
143 * the main function that is called when the page
144 * loads, it decides the which action has to be taken for the page.
146 public function run() {
147 $this->assign('invoicing', CRM_Invoicing_Utils
::isInvoicingEnabled());
148 $this->assign('defaultInvoicePage', CRM_Invoicing_Utils
::getDefaultPaymentPage());
149 parent
::preProcess();
150 $this->listContribution();