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