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