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