Commit | Line | Data |
---|---|---|
6a488035 | 1 | <?php |
6a488035 TO |
2 | /* |
3 | +--------------------------------------------------------------------+ | |
7e9e8871 | 4 | | CiviCRM version 4.7 | |
6a488035 | 5 | +--------------------------------------------------------------------+ |
fa938177 | 6 | | Copyright CiviCRM LLC (c) 2004-2016 | |
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 | |
fa938177 | 31 | * @copyright CiviCRM LLC (c) 2004-2016 |
6a488035 TO |
32 | * $Id$ |
33 | * | |
34 | */ | |
35 | class CRM_Report_Form_Contribute_LoggingSummary extends CRM_Logging_ReportSummary { | |
74cf4551 | 36 | /** |
74cf4551 | 37 | */ |
00be9182 | 38 | public function __construct() { |
6a488035 TO |
39 | $this->_columns = array( |
40 | 'civicrm_contact_altered_contact' => array( | |
41 | 'dao' => 'CRM_Contact_DAO_Contact', | |
42 | 'fields' => array( | |
43 | 'id' => array( | |
44 | 'no_display' => TRUE, | |
45 | 'required' => TRUE, | |
46 | ), | |
47 | 'display_name' => array( | |
48 | 'default' => TRUE, | |
49 | 'title' => ts('Altered Contact'), | |
50 | ), | |
51 | 'is_deleted' => array( | |
52 | 'no_display' => TRUE, | |
53 | 'required' => TRUE, | |
54 | ), | |
55 | ), | |
56 | 'filters' => array( | |
57 | 'altered_contact' => array( | |
58 | 'name' => 'display_name', | |
59 | 'title' => ts('Altered Contact'), | |
60 | 'type' => CRM_Utils_Type::T_STRING, | |
61 | ), | |
62 | ), | |
63 | ), | |
64 | 'log_civicrm_contribution' => array( | |
65 | 'dao' => 'CRM_Contribute_DAO_Contribution', | |
66 | 'fields' => array( | |
67 | 'id' => array( | |
68 | 'no_display' => TRUE, | |
69 | 'required' => TRUE, | |
70 | ), | |
71 | 'contact_id' => array( | |
72 | 'no_display' => TRUE, | |
73 | 'required' => TRUE, | |
74 | ), | |
75 | 'log_user_id' => array( | |
76 | 'no_display' => TRUE, | |
77 | 'required' => TRUE, | |
78 | ), | |
79 | 'log_date' => array( | |
80 | 'default' => TRUE, | |
81 | 'required' => TRUE, | |
82 | 'type' => CRM_Utils_Type::T_TIME, | |
83 | 'title' => ts('When'), | |
84 | ), | |
85 | 'log_conn_id' => array( | |
86 | 'no_display' => TRUE, | |
87 | 'required' => TRUE, | |
88 | ), | |
89 | 'log_action' => array( | |
90 | 'default' => TRUE, | |
91 | 'title' => ts('Action'), | |
92 | ), | |
b914f4e8 | 93 | 'financial_type_id' => array( |
6a488035 TO |
94 | 'no_display' => TRUE, |
95 | 'required' => TRUE, | |
96 | ), | |
97 | 'contribution_status_id' => array( | |
98 | 'no_display' => TRUE, | |
99 | 'required' => TRUE, | |
100 | ), | |
101 | 'aggregate_amount' => array( | |
102 | 'default' => TRUE, | |
103 | 'name' => 'total_amount', | |
104 | 'title' => ts('Aggregate Amount'), | |
105 | 'type' => CRM_Utils_Type::T_MONEY, | |
106 | ), | |
107 | ), | |
108 | 'filters' => array( | |
109 | 'log_date' => array( | |
110 | 'title' => ts('When'), | |
111 | 'operatorType' => CRM_Report_Form::OP_DATE, | |
112 | 'type' => CRM_Utils_Type::T_DATE, | |
113 | ), | |
114 | 'log_action' => array( | |
115 | 'operatorType' => CRM_Report_Form::OP_MULTISELECT, | |
116 | 'options' => array('Insert' => ts('Insert'), 'Update' => ts('Update'), 'Delete' => ts('Delete')), | |
117 | 'title' => ts('Action'), | |
118 | 'type' => CRM_Utils_Type::T_STRING, | |
119 | ), | |
120 | 'id' => array( | |
121 | 'no_display' => TRUE, | |
122 | 'type' => CRM_Utils_Type::T_INT, | |
123 | ), | |
124 | ), | |
125 | ), | |
b914f4e8 PN |
126 | 'civicrm_financial_type' => array( |
127 | 'dao' => 'CRM_Financial_DAO_FinancialType', | |
6a488035 TO |
128 | 'fields' => array( |
129 | 'id' => array( | |
130 | 'no_display' => TRUE, | |
131 | 'required' => TRUE, | |
132 | ), | |
133 | 'name' => array( | |
b914f4e8 | 134 | 'title' => ts('Financial Type'), |
6a488035 TO |
135 | 'type' => CRM_Utils_Type::T_STRING, |
136 | ), | |
137 | ), | |
138 | ), | |
139 | 'civicrm_contribution_status' => array( | |
140 | 'dao' => 'CRM_Core_DAO_OptionValue', | |
141 | 'fields' => array( | |
142 | 'id' => array( | |
143 | 'no_display' => TRUE, | |
144 | 'required' => TRUE, | |
145 | ), | |
146 | 'label' => array( | |
147 | 'title' => ts('Contribution Status'), | |
148 | 'type' => CRM_Utils_Type::T_STRING, | |
149 | ), | |
150 | ), | |
151 | ), | |
152 | 'civicrm_contact_altered_by' => array( | |
153 | 'dao' => 'CRM_Contact_DAO_Contact', | |
154 | 'fields' => array( | |
155 | 'id' => array( | |
156 | 'no_display' => TRUE, | |
157 | 'required' => TRUE, | |
158 | ), | |
159 | 'display_name' => array( | |
160 | 'default' => TRUE, | |
161 | 'title' => ts('Altered By'), | |
162 | ), | |
163 | ), | |
164 | 'filters' => array( | |
165 | 'altered_by' => array( | |
166 | 'name' => 'display_name', | |
167 | 'title' => ts('Altered By'), | |
168 | 'type' => CRM_Utils_Type::T_STRING, | |
169 | ), | |
170 | ), | |
171 | ), | |
172 | ); | |
173 | parent::__construct(); | |
174 | } | |
175 | ||
74cf4551 | 176 | /** |
ced9bfed EM |
177 | * Alter display of rows. |
178 | * | |
179 | * Iterate through the rows retrieved via SQL and make changes for display purposes, | |
180 | * such as rendering contacts as links. | |
181 | * | |
182 | * @param array $rows | |
183 | * Rows generated by SQL, with an array for each row. | |
74cf4551 | 184 | */ |
00be9182 | 185 | public function alterDisplay(&$rows) { |
6a488035 TO |
186 | // cache for id → is_deleted mapping |
187 | $isDeleted = array(); | |
188 | ||
189 | foreach ($rows as & $row) { | |
190 | if (!isset($isDeleted[$row['civicrm_contact_is_deleted']])) { | |
191 | $isDeleted[$row['civicrm_contact_is_deleted']] = CRM_Core_DAO::getFieldValue('CRM_Contact_DAO_Contact', $row['civicrm_contact_altered_contact_id'], 'is_deleted') !== '0'; | |
192 | } | |
193 | ||
194 | if (!$isDeleted[$row['civicrm_contact_is_deleted']]) { | |
195 | $row['civicrm_contact_altered_contact_display_name_link'] = CRM_Utils_System::url('civicrm/contact/view', 'reset=1&cid=' . $row['log_civicrm_contribution_contact_id']); | |
196 | $row['civicrm_contact_altered_contact_display_name_hover'] = ts('Go to contact summary'); | |
197 | } | |
198 | ||
199 | $row['civicrm_contact_altered_by_display_name_link'] = CRM_Utils_System::url('civicrm/contact/view', 'reset=1&cid=' . $row['log_civicrm_contribution_log_user_id']); | |
200 | $row['civicrm_contact_altered_by_display_name_hover'] = ts('Go to contact summary'); | |
201 | ||
202 | if ($row['civicrm_contact_altered_contact_is_deleted'] and ($row['log_civicrm_contribution_log_action'] == 'Update')) { | |
203 | $row['log_civicrm_contribution_log_action'] = ts('Delete'); | |
204 | } | |
205 | ||
206 | if ($row['log_civicrm_contribution_log_action'] == 'Update') { | |
207 | $q = "reset=1&log_conn_id={$row['log_civicrm_contribution_log_conn_id']}&log_date={$row['log_civicrm_contribution_log_date']}"; | |
208 | if ($this->cid) { | |
209 | $q .= '&cid=' . $this->cid; | |
210 | } | |
211 | ||
212 | $url = CRM_Report_Utils_Report::getNextUrl('logging/contribute/detail', $q, FALSE, TRUE); | |
213 | $row['log_civicrm_contribution_log_action_link'] = $url; | |
214 | $row['log_civicrm_contribution_log_action_hover'] = ts('View details for this update'); | |
d2f7ffaa | 215 | $row['log_civicrm_contribution_log_action'] = '<i class="crm-i fa-list-alt"></i> ' . ts('Update'); |
6a488035 TO |
216 | } |
217 | ||
218 | unset($row['log_civicrm_contribute_log_user_id']); | |
219 | unset($row['log_civicrm_contribute_log_conn_id']); | |
220 | } | |
221 | } | |
222 | ||
00be9182 | 223 | public function from() { |
6a488035 TO |
224 | $this->_from = " |
225 | FROM `{$this->loggingDB}`.log_civicrm_contribution {$this->_aliases['log_civicrm_contribution']} | |
226 | LEFT JOIN civicrm_contact {$this->_aliases['civicrm_contact_altered_by']} | |
227 | ON ({$this->_aliases['log_civicrm_contribution']}.log_user_id = {$this->_aliases['civicrm_contact_altered_by']}.id) | |
228 | LEFT JOIN civicrm_contact {$this->_aliases['civicrm_contact_altered_contact']} | |
229 | ON ({$this->_aliases['log_civicrm_contribution']}.contact_id = {$this->_aliases['civicrm_contact_altered_contact']}.id) | |
230 | LEFT JOIN civicrm_financial_type {$this->_aliases['civicrm_financial_type']} | |
231 | ON ({$this->_aliases['log_civicrm_contribution']}.financial_type_id = {$this->_aliases['civicrm_financial_type']}.id) | |
232 | LEFT JOIN civicrm_option_value {$this->_aliases['civicrm_contribution_status']} | |
233 | ON ({$this->_aliases['log_civicrm_contribution']}.contribution_status_id = {$this->_aliases['civicrm_contribution_status']}.value) | |
234 | INNER JOIN civicrm_option_group | |
235 | ON ({$this->_aliases['civicrm_contribution_status']}.option_group_id = civicrm_option_group.id | |
236 | AND civicrm_option_group.name = 'contribution_status') | |
237 | "; | |
238 | } | |
96025800 | 239 | |
6a488035 | 240 | } |