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