Commit | Line | Data |
---|---|---|
6a488035 TO |
1 | <?php |
2 | /* | |
3 | +--------------------------------------------------------------------+ | |
fee14197 | 4 | | CiviCRM version 5 | |
6a488035 | 5 | +--------------------------------------------------------------------+ |
8c9251b3 | 6 | | Copyright CiviCRM LLC (c) 2004-2018 | |
6a488035 TO |
7 | +--------------------------------------------------------------------+ |
8 | | This file is a part of CiviCRM. | | |
9 | | | | |
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. | | |
13 | | | | |
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. | | |
18 | | | | |
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 | +--------------------------------------------------------------------+ | |
d25dd0ee | 26 | */ |
6a488035 TO |
27 | |
28 | /** | |
29 | * | |
30 | * @package CRM | |
8c9251b3 | 31 | * @copyright CiviCRM LLC (c) 2004-2018 |
6a488035 TO |
32 | */ |
33 | class CRM_Contribute_Page_UserDashboard extends CRM_Contact_Page_View_UserDashBoard { | |
34 | ||
35 | /** | |
fe482240 | 36 | * called when action is browse. |
6a488035 | 37 | */ |
00be9182 | 38 | public function listContribution() { |
9f6f062c DL |
39 | $controller = new CRM_Core_Controller_Simple( |
40 | 'CRM_Contribute_Form_Search', | |
41 | ts('Contributions'), | |
42 | NULL, | |
43 | FALSE, FALSE, TRUE, FALSE | |
44 | ); | |
6a488035 TO |
45 | $controller->setEmbedded(TRUE); |
46 | $controller->reset(); | |
47 | $controller->set('limit', 12); | |
48 | $controller->set('cid', $this->_contactId); | |
49 | $controller->set('context', 'user'); | |
50 | $controller->set('force', 1); | |
51 | $controller->process(); | |
52 | $controller->run(); | |
53 | ||
54 | //add honor block | |
6a488035 TO |
55 | $params = CRM_Contribute_BAO_Contribution::getHonorContacts($this->_contactId); |
56 | ||
57 | if (!empty($params)) { | |
58 | // assign vars to templates | |
59 | $this->assign('honorRows', $params); | |
60 | $this->assign('honor', TRUE); | |
61 | } | |
62 | ||
353ffa53 | 63 | $recur = new CRM_Contribute_DAO_ContributionRecur(); |
6a488035 | 64 | $recur->contact_id = $this->_contactId; |
353ffa53 | 65 | $recur->is_test = 0; |
6a488035 TO |
66 | $recur->find(); |
67 | ||
68 | $config = CRM_Core_Config::singleton(); | |
69 | ||
70 | $recurStatus = CRM_Contribute_PseudoConstant::contributionStatus(); | |
71 | ||
72 | $recurRow = array(); | |
73 | $recurIDs = array(); | |
74 | while ($recur->fetch()) { | |
75 | $mode = $recur->is_test ? 'test' : 'live'; | |
76 | $paymentProcessor = CRM_Contribute_BAO_ContributionRecur::getPaymentProcessor($recur->id, | |
77 | $mode | |
78 | ); | |
79 | if (!$paymentProcessor) { | |
80 | continue; | |
81 | } | |
82 | ||
6a488035 TO |
83 | require_once 'api/v3/utils.php'; |
84 | //@todo calling api functions directly is not supported | |
85 | _civicrm_api3_object_to_array($recur, $values); | |
86 | ||
87 | $values['recur_status'] = $recurStatus[$values['contribution_status_id']]; | |
88 | $recurRow[$values['id']] = $values; | |
89 | ||
90 | $action = array_sum(array_keys(CRM_Contribute_Page_Tab::recurLinks($recur->id, 'dashboard'))); | |
91 | ||
92 | $details = CRM_Contribute_BAO_ContributionRecur::getSubscriptionDetails($recur->id, 'recur'); | |
93 | $hideUpdate = $details->membership_id & $details->auto_renew; | |
94 | ||
95 | if ($hideUpdate) { | |
96 | $action -= CRM_Core_Action::UPDATE; | |
97 | } | |
98 | ||
99 | $recurRow[$values['id']]['action'] = CRM_Core_Action::formLink(CRM_Contribute_Page_Tab::recurLinks($recur->id, 'dashboard'), | |
100 | $action, array( | |
101 | 'cid' => $this->_contactId, | |
102 | 'crid' => $values['id'], | |
103 | 'cxt' => 'contribution', | |
87dab4a4 AH |
104 | ), |
105 | ts('more'), | |
106 | FALSE, | |
107 | 'contribution.dashboard.recurring', | |
108 | 'Contribution', | |
109 | $values['id'] | |
6a488035 TO |
110 | ); |
111 | ||
112 | $recurIDs[] = $values['id']; | |
113 | ||
114 | //reset $paymentObject for checking other paymenet processor | |
115 | //recurring url | |
116 | $paymentObject = NULL; | |
117 | } | |
118 | if (is_array($recurIDs) && !empty($recurIDs)) { | |
119 | $getCount = CRM_Contribute_BAO_ContributionRecur::getCount($recurIDs); | |
120 | foreach ($getCount as $key => $val) { | |
121 | $recurRow[$key]['completed'] = $val; | |
122 | $recurRow[$key]['link'] = CRM_Utils_System::url('civicrm/contribute/search', | |
123 | "reset=1&force=1&recur=$key" | |
124 | ); | |
125 | } | |
126 | } | |
127 | ||
128 | $this->assign('recurRows', $recurRow); | |
129 | if (!empty($recurRow)) { | |
130 | $this->assign('recur', TRUE); | |
131 | } | |
132 | else { | |
133 | $this->assign('recur', FALSE); | |
134 | } | |
135 | } | |
136 | ||
137 | /** | |
dc195289 | 138 | * the main function that is called when the page |
6a488035 | 139 | * loads, it decides the which action has to be taken for the page. |
6a488035 | 140 | */ |
00be9182 | 141 | public function run() { |
aaffa79f | 142 | $invoiceSettings = Civi::settings()->get('contribution_invoice_settings'); |
03b412ae | 143 | $invoicing = CRM_Utils_Array::value('invoicing', $invoiceSettings); |
58466af1 | 144 | $defaultInvoicePage = CRM_Utils_Array::value('default_invoice_page', $invoiceSettings); |
03b412ae | 145 | $this->assign('invoicing', $invoicing); |
58466af1 | 146 | $this->assign('defaultInvoicePage', $defaultInvoicePage); |
6a488035 TO |
147 | parent::preProcess(); |
148 | $this->listContribution(); | |
149 | } | |
96025800 | 150 | |
6a488035 | 151 | } |