Commit | Line | Data |
---|---|---|
6a488035 TO |
1 | <?php |
2 | /* | |
3 | +--------------------------------------------------------------------+ | |
fee14197 | 4 | | CiviCRM version 5 | |
6a488035 | 5 | +--------------------------------------------------------------------+ |
6b83d5bd | 6 | | Copyright CiviCRM LLC (c) 2004-2019 | |
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 | |
6b83d5bd | 31 | * @copyright CiviCRM LLC (c) 2004-2019 |
6a488035 TO |
32 | * $Id$ |
33 | * | |
34 | */ | |
35 | class CRM_Report_Form_Extended extends CRM_Report_Form { | |
36 | protected $_addressField = FALSE; | |
37 | ||
38 | protected $_emailField = FALSE; | |
39 | ||
40 | protected $_summary = NULL; | |
41 | ||
be2fb01f | 42 | protected $_customGroupExtends = []; |
6a488035 TO |
43 | protected $_baseTable = 'civicrm_contact'; |
44 | ||
74cf4551 | 45 | /** |
688d37c6 | 46 | * |
74cf4551 | 47 | */ |
00be9182 | 48 | public function __construct() { |
6a488035 TO |
49 | parent::__construct(); |
50 | } | |
51 | ||
688d37c6 CW |
52 | /** |
53 | * | |
54 | */ | |
00be9182 | 55 | public function preProcess() { |
6a488035 TO |
56 | parent::preProcess(); |
57 | } | |
58 | ||
688d37c6 CW |
59 | /** |
60 | * | |
61 | */ | |
00be9182 | 62 | public function select() { |
6a488035 TO |
63 | parent::select(); |
64 | } | |
65 | ||
66 | ||
688d37c6 | 67 | /** |
6a488035 TO |
68 | * From clause build where baseTable & fromClauses are defined |
69 | */ | |
00be9182 | 70 | public function from() { |
6a488035 TO |
71 | if (!empty($this->_baseTable)) { |
72 | $this->buildACLClause($this->_aliases['civicrm_contact']); | |
73 | $this->_from = "FROM {$this->_baseTable} {$this->_aliases[$this->_baseTable]}"; | |
74 | $availableClauses = $this->getAvailableJoins(); | |
75 | foreach ($this->fromClauses() as $fromClause) { | |
76 | $fn = $availableClauses[$fromClause]['callback']; | |
77 | $this->$fn(); | |
78 | } | |
79 | if (strstr($this->_from, 'civicrm_contact')) { | |
80 | $this->_from .= $this->_aclFrom; | |
81 | } | |
82 | } | |
83 | } | |
84 | ||
74cf4551 | 85 | /** |
688d37c6 CW |
86 | * Define any from clauses in use (child classes to override) |
87 | * | |
74cf4551 EM |
88 | * @return array |
89 | */ | |
00be9182 | 90 | public function fromClauses() { |
be2fb01f | 91 | return []; |
6a488035 TO |
92 | } |
93 | ||
00be9182 | 94 | public function groupBy() { |
6a488035 TO |
95 | parent::groupBy(); |
96 | //@todo - need to re-visit this - bad behaviour from pa | |
97 | if ($this->_groupBy == 'GROUP BY') { | |
98 | $this->_groupBY = NULL; | |
99 | } | |
100 | // if a stat field has been selected the do a group by | |
101 | if (!empty($this->_statFields) && empty($this->_groupBy)) { | |
102 | $this->_groupBy[] = $this->_aliases[$this->_baseTable] . ".id"; | |
103 | } | |
104 | //@todo - this should be in the parent function or at parent level - perhaps build query should do this? | |
105 | if (!empty($this->_groupBy) && is_array($this->_groupBy)) { | |
106 | $this->_groupBy = 'GROUP BY ' . implode(',', $this->_groupBy); | |
107 | } | |
108 | } | |
109 | ||
00be9182 | 110 | public function orderBy() { |
6a488035 TO |
111 | parent::orderBy(); |
112 | } | |
113 | ||
74cf4551 | 114 | /** |
688d37c6 | 115 | * @param array $rows |
74cf4551 EM |
116 | * |
117 | * @return array | |
118 | */ | |
00be9182 | 119 | public function statistics(&$rows) { |
6a488035 TO |
120 | return parent::statistics($rows); |
121 | } | |
122 | ||
00be9182 | 123 | public function postProcess() { |
8cc574cf | 124 | if (!empty($this->_aclTable) && !empty($this->_aliases[$this->_aclTable])) { |
6a488035 TO |
125 | $this->buildACLClause($this->_aliases[$this->_aclTable]); |
126 | } | |
127 | parent::postProcess(); | |
128 | } | |
129 | ||
74cf4551 | 130 | /** |
ced9bfed EM |
131 | * Alter display of rows. |
132 | * | |
133 | * Iterate through the rows retrieved via SQL and make changes for display purposes, | |
134 | * such as rendering contacts as links. | |
135 | * | |
688d37c6 | 136 | * @param array $rows |
ced9bfed | 137 | * Rows generated by SQL, with an array for each row. |
74cf4551 | 138 | */ |
00be9182 | 139 | public function alterDisplay(&$rows) { |
6a488035 TO |
140 | parent::alterDisplay($rows); |
141 | ||
142 | //THis is all generic functionality which can hopefully go into the parent class | |
143 | // it introduces the option of defining an alter display function as part of the column definition | |
144 | // @tod tidy up the iteration so it happens in this function | |
145 | list($firstRow) = $rows; | |
146 | // no result to alter | |
147 | if (empty($firstRow)) { | |
148 | return; | |
149 | } | |
150 | $selectedFields = array_keys($firstRow); | |
151 | ||
be2fb01f | 152 | $alterfunctions = $altermap = []; |
6a488035 TO |
153 | foreach ($this->_columns as $tablename => $table) { |
154 | if (array_key_exists('fields', $table)) { | |
155 | foreach ($table['fields'] as $field => $specs) { | |
9d72cede EM |
156 | if (in_array($tablename . '_' . $field, $selectedFields) && |
157 | array_key_exists('alter_display', $specs) | |
158 | ) { | |
159 | $alterfunctions[$tablename . '_' . | |
160 | $field] = $specs['alter_display']; | |
6a488035 TO |
161 | $altermap[$tablename . '_' . $field] = $field; |
162 | } | |
163 | } | |
164 | } | |
165 | } | |
166 | if (empty($alterfunctions)) { | |
167 | // - no manipulation to be done | |
168 | return; | |
169 | } | |
170 | ||
171 | foreach ($rows as $index => & $row) { | |
172 | foreach ($row as $selectedfield => $value) { | |
173 | if (array_key_exists($selectedfield, $alterfunctions)) { | |
6ef04c72 | 174 | $rows[$index][$selectedfield] = $this->{$alterfunctions[$selectedfield]}($value, $row, $selectedfield, $altermap[$selectedfield]); |
6a488035 TO |
175 | } |
176 | } | |
177 | } | |
178 | } | |
179 | ||
74cf4551 EM |
180 | /** |
181 | * @return array | |
182 | */ | |
00be9182 | 183 | public function getLineItemColumns() { |
be2fb01f CW |
184 | return [ |
185 | 'civicrm_line_item' => [ | |
6a488035 | 186 | 'dao' => 'CRM_Price_BAO_LineItem', |
be2fb01f CW |
187 | 'fields' => [ |
188 | 'qty' => [ | |
9d72cede | 189 | 'title' => ts('Quantity'), |
6a488035 | 190 | 'type' => CRM_Utils_Type::T_INT, |
be2fb01f CW |
191 | 'statistics' => ['sum' => ts('Total Quantity Selected')], |
192 | ], | |
193 | 'unit_price' => [ | |
9d72cede | 194 | 'title' => ts('Unit Price'), |
be2fb01f CW |
195 | ], |
196 | 'line_total' => [ | |
9d72cede | 197 | 'title' => ts('Line Total'), |
6a488035 | 198 | 'type' => CRM_Utils_Type::T_MONEY, |
be2fb01f CW |
199 | 'statistics' => ['sum' => ts('Total of Line Items')], |
200 | ], | |
201 | ], | |
202 | 'participant_count' => [ | |
9d72cede | 203 | 'title' => ts('Participant Count'), |
be2fb01f CW |
204 | 'statistics' => ['sum' => ts('Total Participants')], |
205 | ], | |
206 | 'filters' => [ | |
207 | 'qty' => [ | |
9d72cede | 208 | 'title' => ts('Quantity'), |
6a488035 TO |
209 | 'type' => CRM_Utils_Type::T_INT, |
210 | 'operator' => CRM_Report_Form::OP_INT, | |
be2fb01f CW |
211 | ], |
212 | ], | |
213 | 'group_bys' => [ | |
214 | 'price_field_id' => [ | |
9d72cede | 215 | 'title' => ts('Price Field'), |
be2fb01f CW |
216 | ], |
217 | 'price_field_value_id' => [ | |
9d72cede | 218 | 'title' => ts('Price Field Option'), |
be2fb01f CW |
219 | ], |
220 | 'line_item_id' => [ | |
9d72cede | 221 | 'title' => ts('Individual Line Item'), |
6a488035 | 222 | 'name' => 'id', |
be2fb01f CW |
223 | ], |
224 | ], | |
225 | ], | |
226 | ]; | |
6a488035 TO |
227 | } |
228 | ||
74cf4551 EM |
229 | /** |
230 | * @return array | |
231 | */ | |
00be9182 | 232 | public function getPriceFieldValueColumns() { |
be2fb01f CW |
233 | return [ |
234 | 'civicrm_price_field_value' => [ | |
9da8dc8c | 235 | 'dao' => 'CRM_Price_BAO_PriceFieldValue', |
be2fb01f CW |
236 | 'fields' => [ |
237 | 'price_field_value_label' => [ | |
9d72cede | 238 | 'title' => ts('Price Field Value Label'), |
6a488035 | 239 | 'name' => 'label', |
be2fb01f CW |
240 | ], |
241 | ], | |
242 | 'filters' => [ | |
243 | 'price_field_value_label' => [ | |
9d72cede | 244 | 'title' => ts('Price Fields Value Label'), |
6a488035 TO |
245 | 'type' => CRM_Utils_Type::T_STRING, |
246 | 'operator' => 'like', | |
247 | 'name' => 'label', | |
be2fb01f CW |
248 | ], |
249 | ], | |
250 | 'order_bys' => [ | |
251 | 'label' => [ | |
9d72cede | 252 | 'title' => ts('Price Field Value Label'), |
be2fb01f CW |
253 | ], |
254 | ], | |
84178120 | 255 | 'group_bys' => //note that we have a requirement to group by label such that all 'Promo book' lines |
6a488035 TO |
256 | // are grouped together across price sets but there may be a separate need to group |
257 | // by id so that entries in one price set are distinct from others. Not quite sure what | |
258 | // to call the distinction for end users benefit | |
be2fb01f CW |
259 | [ |
260 | 'price_field_value_label' => [ | |
d5cc0fc2 | 261 | 'title' => ts('Price Field Value Label'), |
262 | 'name' => 'label', | |
be2fb01f CW |
263 | ], |
264 | ], | |
265 | ], | |
266 | ]; | |
6a488035 TO |
267 | } |
268 | ||
74cf4551 EM |
269 | /** |
270 | * @return array | |
271 | */ | |
00be9182 | 272 | public function getPriceFieldColumns() { |
be2fb01f CW |
273 | return [ |
274 | 'civicrm_price_field' => [ | |
9da8dc8c | 275 | 'dao' => 'CRM_Price_BAO_PriceField', |
be2fb01f CW |
276 | 'fields' => [ |
277 | 'price_field_label' => [ | |
9d72cede | 278 | 'title' => ts('Price Field Label'), |
6a488035 | 279 | 'name' => 'label', |
be2fb01f CW |
280 | ], |
281 | ], | |
282 | 'filters' => [ | |
283 | 'price_field_label' => [ | |
9d72cede | 284 | 'title' => ts('Price Field Label'), |
6a488035 TO |
285 | 'type' => CRM_Utils_Type::T_STRING, |
286 | 'operator' => 'like', | |
287 | 'name' => 'label', | |
be2fb01f CW |
288 | ], |
289 | ], | |
290 | 'order_bys' => [ | |
291 | 'price_field_label' => [ | |
9d72cede EM |
292 | 'title' => ts('Price Field Label'), |
293 | 'name' => 'label', | |
be2fb01f CW |
294 | ], |
295 | ], | |
296 | 'group_bys' => [ | |
297 | 'price_field_label' => [ | |
9d72cede | 298 | 'title' => ts('Price Field Label'), |
6a488035 | 299 | 'name' => 'label', |
be2fb01f CW |
300 | ], |
301 | ], | |
302 | ], | |
303 | ]; | |
6a488035 TO |
304 | } |
305 | ||
74cf4551 EM |
306 | /** |
307 | * @return array | |
308 | */ | |
00be9182 | 309 | public function getParticipantColumns() { |
be2fb01f | 310 | static $_events = []; |
6a488035 TO |
311 | if (!isset($_events['all'])) { |
312 | CRM_Core_PseudoConstant::populate($_events['all'], 'CRM_Event_DAO_Event', FALSE, 'title', 'is_active', "is_template IS NULL OR is_template = 0", 'end_date DESC'); | |
313 | } | |
be2fb01f CW |
314 | return [ |
315 | 'civicrm_participant' => [ | |
6a488035 | 316 | 'dao' => 'CRM_Event_DAO_Participant', |
be2fb01f CW |
317 | 'fields' => [ |
318 | 'participant_id' => ['title' => ts('Participant ID')], | |
319 | 'participant_record' => [ | |
6a488035 | 320 | 'name' => 'id', |
aa6228f8 | 321 | 'title' => ts('Participant ID'), |
be2fb01f CW |
322 | ], |
323 | 'event_id' => [ | |
9d72cede | 324 | 'title' => ts('Event ID'), |
6a488035 TO |
325 | 'type' => CRM_Utils_Type::T_STRING, |
326 | 'alter_display' => 'alterEventID', | |
be2fb01f CW |
327 | ], |
328 | 'status_id' => [ | |
9d72cede | 329 | 'title' => ts('Status'), |
6a488035 | 330 | 'alter_display' => 'alterParticipantStatus', |
be2fb01f CW |
331 | ], |
332 | 'role_id' => [ | |
9d72cede | 333 | 'title' => ts('Role'), |
6a488035 | 334 | 'alter_display' => 'alterParticipantRole', |
be2fb01f | 335 | ], |
6a488035 TO |
336 | 'participant_fee_level' => NULL, |
337 | 'participant_fee_amount' => NULL, | |
be2fb01f CW |
338 | 'participant_register_date' => ['title' => ts('Registration Date')], |
339 | ], | |
6a488035 | 340 | 'grouping' => 'event-fields', |
be2fb01f CW |
341 | 'filters' => [ |
342 | 'event_id' => [ | |
9d72cede | 343 | 'name' => 'event_id', |
6a488035 TO |
344 | 'title' => ts('Event'), |
345 | 'operatorType' => CRM_Report_Form::OP_MULTISELECT, | |
346 | 'options' => $_events['all'], | |
be2fb01f CW |
347 | ], |
348 | 'sid' => [ | |
6a488035 TO |
349 | 'name' => 'status_id', |
350 | 'title' => ts('Participant Status'), | |
351 | 'operatorType' => CRM_Report_Form::OP_MULTISELECT, | |
352 | 'options' => CRM_Event_PseudoConstant::participantStatus(NULL, NULL, 'label'), | |
be2fb01f CW |
353 | ], |
354 | 'rid' => [ | |
6a488035 TO |
355 | 'name' => 'role_id', |
356 | 'title' => ts('Participant Role'), | |
357 | 'operatorType' => CRM_Report_Form::OP_MULTISELECT, | |
358 | 'options' => CRM_Event_PseudoConstant::participantRole(), | |
be2fb01f CW |
359 | ], |
360 | 'participant_register_date' => [ | |
ccc29f8e | 361 | 'title' => ts('Registration Date'), |
6a488035 | 362 | 'operatorType' => CRM_Report_Form::OP_DATE, |
be2fb01f CW |
363 | ], |
364 | ], | |
365 | 'order_bys' => [ | |
366 | 'event_id' => [ | |
9d72cede EM |
367 | 'title' => ts('Event'), |
368 | 'default_weight' => '1', | |
21dfd5f5 | 369 | 'default_order' => 'ASC', |
be2fb01f CW |
370 | ], |
371 | ], | |
372 | 'group_bys' => [ | |
373 | 'event_id' => ['title' => ts('Event')], | |
374 | ], | |
375 | ], | |
376 | ]; | |
6a488035 TO |
377 | } |
378 | ||
74cf4551 EM |
379 | /** |
380 | * @return array | |
381 | */ | |
00be9182 | 382 | public function getMembershipColumns() { |
be2fb01f CW |
383 | return [ |
384 | 'civicrm_membership' => [ | |
6a488035 TO |
385 | 'dao' => 'CRM_Member_DAO_Membership', |
386 | 'grouping' => 'member-fields', | |
be2fb01f CW |
387 | 'fields' => [ |
388 | 'membership_type_id' => [ | |
ccc29f8e | 389 | 'title' => ts('Membership Type'), |
6a488035 TO |
390 | 'required' => TRUE, |
391 | 'alter_display' => 'alterMembershipTypeID', | |
be2fb01f CW |
392 | ], |
393 | 'status_id' => [ | |
ccc29f8e | 394 | 'title' => ts('Membership Status'), |
6a488035 TO |
395 | 'required' => TRUE, |
396 | 'alter_display' => 'alterMembershipStatusID', | |
be2fb01f | 397 | ], |
6a488035 | 398 | 'join_date' => NULL, |
be2fb01f | 399 | 'start_date' => [ |
6a488035 | 400 | 'title' => ts('Current Cycle Start Date'), |
be2fb01f CW |
401 | ], |
402 | 'end_date' => [ | |
6a488035 | 403 | 'title' => ts('Current Membership Cycle End Date'), |
be2fb01f CW |
404 | ], |
405 | ], | |
406 | 'group_bys' => [ | |
407 | 'membership_type_id' => [ | |
6a488035 | 408 | 'title' => ts('Membership Type'), |
be2fb01f CW |
409 | ], |
410 | ], | |
411 | 'filters' => [ | |
412 | 'join_date' => [ | |
6a488035 TO |
413 | 'type' => CRM_Utils_Type::T_DATE, |
414 | 'operatorType' => CRM_Report_Form::OP_DATE, | |
be2fb01f CW |
415 | ], |
416 | ], | |
417 | ], | |
418 | ]; | |
6a488035 TO |
419 | } |
420 | ||
74cf4551 EM |
421 | /** |
422 | * @return array | |
423 | */ | |
00be9182 | 424 | public function getMembershipTypeColumns() { |
be2fb01f CW |
425 | return [ |
426 | 'civicrm_membership_type' => [ | |
6a488035 TO |
427 | 'dao' => 'CRM_Member_DAO_MembershipType', |
428 | 'grouping' => 'member-fields', | |
be2fb01f CW |
429 | 'filters' => [ |
430 | 'gid' => [ | |
6a488035 TO |
431 | 'name' => 'id', |
432 | 'title' => ts('Membership Types'), | |
433 | 'operatorType' => CRM_Report_Form::OP_MULTISELECT, | |
434 | 'type' => CRM_Utils_Type::T_INT + CRM_Utils_Type::T_ENUM, | |
435 | 'options' => CRM_Member_PseudoConstant::membershipType(), | |
be2fb01f CW |
436 | ], |
437 | ], | |
438 | ], | |
439 | ]; | |
6a488035 TO |
440 | } |
441 | ||
74cf4551 EM |
442 | /** |
443 | * @return array | |
444 | */ | |
00be9182 | 445 | public function getEventColumns() { |
be2fb01f CW |
446 | return [ |
447 | 'civicrm_event' => [ | |
6a488035 | 448 | 'dao' => 'CRM_Event_DAO_Event', |
be2fb01f CW |
449 | 'fields' => [ |
450 | 'id' => [ | |
6a488035 TO |
451 | 'no_display' => TRUE, |
452 | 'required' => TRUE, | |
be2fb01f CW |
453 | ], |
454 | 'title' => [ | |
9d72cede | 455 | 'title' => ts('Event Title'), |
6a488035 | 456 | 'required' => TRUE, |
be2fb01f CW |
457 | ], |
458 | 'event_type_id' => [ | |
9d72cede | 459 | 'title' => ts('Event Type'), |
6a488035 TO |
460 | 'required' => TRUE, |
461 | 'alter_display' => 'alterEventType', | |
be2fb01f CW |
462 | ], |
463 | 'fee_label' => ['title' => ts('Fee Label')], | |
464 | 'event_start_date' => [ | |
9d72cede | 465 | 'title' => ts('Event Start Date'), |
be2fb01f CW |
466 | ], |
467 | 'event_end_date' => ['title' => ts('Event End Date')], | |
468 | 'max_participants' => [ | |
9d72cede | 469 | 'title' => ts('Capacity'), |
6a488035 | 470 | 'type' => CRM_Utils_Type::T_INT, |
be2fb01f CW |
471 | ], |
472 | ], | |
6a488035 | 473 | 'grouping' => 'event-fields', |
be2fb01f CW |
474 | 'filters' => [ |
475 | 'event_type_id' => [ | |
6a488035 TO |
476 | 'name' => 'event_type_id', |
477 | 'title' => ts('Event Type'), | |
478 | 'operatorType' => CRM_Report_Form::OP_MULTISELECT, | |
479 | 'options' => CRM_Core_OptionGroup::values('event_type'), | |
be2fb01f CW |
480 | ], |
481 | 'event_title' => [ | |
6a488035 TO |
482 | 'name' => 'title', |
483 | 'title' => ts('Event Title'), | |
484 | 'operatorType' => CRM_Report_Form::OP_STRING, | |
be2fb01f CW |
485 | ], |
486 | ], | |
487 | 'order_bys' => [ | |
488 | 'event_type_id' => [ | |
6a488035 TO |
489 | 'title' => ts('Event Type'), |
490 | 'default_weight' => '2', | |
491 | 'default_order' => 'ASC', | |
be2fb01f CW |
492 | ], |
493 | ], | |
494 | 'group_bys' => [ | |
495 | 'event_type_id' => [ | |
9d72cede | 496 | 'title' => ts('Event Type'), |
be2fb01f CW |
497 | ], |
498 | ], | |
499 | ], | |
500 | ]; | |
6a488035 TO |
501 | } |
502 | ||
74cf4551 EM |
503 | /** |
504 | * @return array | |
505 | */ | |
00be9182 | 506 | public function getContributionColumns() { |
be2fb01f CW |
507 | return [ |
508 | 'civicrm_contribution' => [ | |
6a488035 | 509 | 'dao' => 'CRM_Contribute_DAO_Contribution', |
be2fb01f CW |
510 | 'fields' => [ |
511 | 'contribution_id' => [ | |
6a488035 | 512 | 'name' => 'id', |
be2fb01f CW |
513 | ], |
514 | 'financial_type_id' => [ | |
9d72cede | 515 | 'title' => ts('Financial Type'), |
6a488035 TO |
516 | 'default' => TRUE, |
517 | 'alter_display' => 'alterContributionType', | |
be2fb01f CW |
518 | ], |
519 | 'payment_instrument_id' => [ | |
536f0e02 | 520 | 'title' => ts('Payment Method'), |
6a488035 | 521 | 'alter_display' => 'alterPaymentType', |
be2fb01f CW |
522 | ], |
523 | 'source' => ['title' => ts('Contribution Source')], | |
6a488035 | 524 | 'trxn_id' => NULL, |
be2fb01f | 525 | 'receive_date' => ['default' => TRUE], |
6a488035 TO |
526 | 'receipt_date' => NULL, |
527 | 'fee_amount' => NULL, | |
528 | 'net_amount' => NULL, | |
be2fb01f | 529 | 'total_amount' => [ |
9d72cede | 530 | 'title' => ts('Amount'), |
be2fb01f | 531 | 'statistics' => ['sum' => ts('Total Amount')], |
6a488035 | 532 | 'type' => CRM_Utils_Type::T_MONEY, |
be2fb01f CW |
533 | ], |
534 | ], | |
535 | 'filters' => [ | |
536 | 'receive_date' => ['operatorType' => CRM_Report_Form::OP_DATE], | |
537 | 'financial_type_id' => [ | |
9d72cede | 538 | 'title' => ts('Financial Type'), |
6a488035 TO |
539 | 'operatorType' => CRM_Report_Form::OP_MULTISELECT, |
540 | 'options' => CRM_Contribute_PseudoConstant::financialType(), | |
be2fb01f CW |
541 | ], |
542 | 'payment_instrument_id' => [ | |
9d72cede | 543 | 'title' => ts('Payment Type'), |
6a488035 TO |
544 | 'operatorType' => CRM_Report_Form::OP_MULTISELECT, |
545 | 'options' => CRM_Contribute_PseudoConstant::paymentInstrument(), | |
be2fb01f CW |
546 | ], |
547 | 'contribution_status_id' => [ | |
9d72cede | 548 | 'title' => ts('Contribution Status'), |
6a488035 TO |
549 | 'operatorType' => CRM_Report_Form::OP_MULTISELECT, |
550 | 'options' => CRM_Contribute_PseudoConstant::contributionStatus(), | |
be2fb01f CW |
551 | ], |
552 | 'total_amount' => ['title' => ts('Contribution Amount')], | |
553 | ], | |
554 | 'order_bys' => [ | |
555 | 'payment_instrument_id' => [ | |
536f0e02 | 556 | 'title' => ts('Payment Method'), |
be2fb01f CW |
557 | ], |
558 | 'financial_type_id' => [ | |
9d72cede | 559 | 'title' => ts('Financial Type'), |
be2fb01f CW |
560 | ], |
561 | ], | |
562 | 'group_bys' => [ | |
563 | 'financial_type_id' => ['title' => ts('Financial Type')], | |
564 | 'payment_instrument_id' => ['title' => ts('Payment Method')], | |
565 | 'contribution_id' => [ | |
9d72cede | 566 | 'title' => ts('Individual Contribution'), |
6a488035 | 567 | 'name' => 'id', |
be2fb01f CW |
568 | ], |
569 | 'source' => ['title' => ts('Contribution Source')], | |
570 | ], | |
6a488035 | 571 | 'grouping' => 'contribution-fields', |
be2fb01f CW |
572 | ], |
573 | ]; | |
6a488035 TO |
574 | } |
575 | ||
74cf4551 EM |
576 | /** |
577 | * @return array | |
578 | */ | |
00be9182 | 579 | public function getContactColumns() { |
be2fb01f CW |
580 | return [ |
581 | 'civicrm_contact' => [ | |
6a488035 | 582 | 'dao' => 'CRM_Contact_DAO_Contact', |
be2fb01f CW |
583 | 'fields' => [ |
584 | 'display_name' => [ | |
6a488035 | 585 | 'title' => ts('Contact Name'), |
be2fb01f CW |
586 | ], |
587 | 'id' => [ | |
6a488035 TO |
588 | 'title' => ts('Contact ID'), |
589 | 'alter_display' => 'alterContactID', | |
be2fb01f CW |
590 | ], |
591 | 'first_name' => [ | |
6a488035 | 592 | 'title' => ts('First Name'), |
be2fb01f CW |
593 | ], |
594 | 'last_name' => [ | |
6a488035 | 595 | 'title' => ts('Last Name'), |
be2fb01f CW |
596 | ], |
597 | 'nick_name' => [ | |
6a488035 TO |
598 | 'title' => ts('Nickname'), |
599 | 'alter_display' => 'alterNickname', | |
be2fb01f CW |
600 | ], |
601 | ], | |
602 | 'filters' => [ | |
603 | 'id' => [ | |
6a488035 | 604 | 'title' => ts('Contact ID'), |
be2fb01f CW |
605 | ], |
606 | 'sort_name' => [ | |
6a488035 | 607 | 'title' => ts('Contact Name'), |
be2fb01f CW |
608 | ], |
609 | ], | |
6a488035 | 610 | 'grouping' => 'contact-fields', |
be2fb01f CW |
611 | 'order_bys' => [ |
612 | 'sort_name' => [ | |
6a488035 TO |
613 | 'title' => ts('Last Name, First Name'), |
614 | 'default' => '1', | |
615 | 'default_weight' => '0', | |
616 | 'default_order' => 'ASC', | |
be2fb01f CW |
617 | ], |
618 | ], | |
619 | ], | |
620 | ]; | |
6a488035 TO |
621 | } |
622 | ||
74cf4551 EM |
623 | /** |
624 | * @return array | |
625 | */ | |
00be9182 | 626 | public function getCaseColumns() { |
be2fb01f CW |
627 | return [ |
628 | 'civicrm_case' => [ | |
6a488035 | 629 | 'dao' => 'CRM_Case_DAO_Case', |
be2fb01f CW |
630 | 'fields' => [ |
631 | 'id' => [ | |
6a488035 | 632 | 'title' => ts('Case ID'), |
21dfd5f5 | 633 | 'required' => FALSE, |
be2fb01f CW |
634 | ], |
635 | 'subject' => [ | |
6a488035 | 636 | 'title' => ts('Case Subject'), |
21dfd5f5 | 637 | 'default' => TRUE, |
be2fb01f CW |
638 | ], |
639 | 'status_id' => [ | |
6a488035 | 640 | 'title' => ts('Status'), |
21dfd5f5 | 641 | 'default' => TRUE, |
be2fb01f CW |
642 | ], |
643 | 'case_type_id' => [ | |
6a488035 | 644 | 'title' => ts('Case Type'), |
21dfd5f5 | 645 | 'default' => TRUE, |
be2fb01f CW |
646 | ], |
647 | 'case_start_date' => [ | |
6a488035 TO |
648 | 'title' => ts('Case Start Date'), |
649 | 'name' => 'start_date', | |
21dfd5f5 | 650 | 'default' => TRUE, |
be2fb01f CW |
651 | ], |
652 | 'case_end_date' => [ | |
6a488035 TO |
653 | 'title' => ts('Case End Date'), |
654 | 'name' => 'end_date', | |
21dfd5f5 | 655 | 'default' => TRUE, |
be2fb01f CW |
656 | ], |
657 | 'case_duration' => [ | |
6a488035 TO |
658 | 'name' => 'duration', |
659 | 'title' => ts('Duration (Days)'), | |
21dfd5f5 | 660 | 'default' => FALSE, |
be2fb01f CW |
661 | ], |
662 | 'case_is_deleted' => [ | |
6a488035 TO |
663 | 'name' => 'is_deleted', |
664 | 'title' => ts('Case Deleted?'), | |
9d72cede | 665 | 'default' => FALSE, |
21dfd5f5 | 666 | 'type' => CRM_Utils_Type::T_INT, |
be2fb01f CW |
667 | ], |
668 | ], | |
669 | 'filters' => [ | |
670 | 'case_start_date' => [ | |
6a488035 TO |
671 | 'title' => ts('Case Start Date'), |
672 | 'operatorType' => CRM_Report_Form::OP_DATE, | |
673 | 'type' => CRM_Utils_Type::T_DATE, | |
674 | 'name' => 'start_date', | |
be2fb01f CW |
675 | ], |
676 | 'case_end_date' => [ | |
6a488035 TO |
677 | 'title' => ts('Case End Date'), |
678 | 'operatorType' => CRM_Report_Form::OP_DATE, | |
679 | 'type' => CRM_Utils_Type::T_DATE, | |
21dfd5f5 | 680 | 'name' => 'end_date', |
be2fb01f CW |
681 | ], |
682 | 'case_type_id' => [ | |
6a488035 TO |
683 | 'title' => ts('Case Type'), |
684 | 'operatorType' => CRM_Report_Form::OP_MULTISELECT, | |
21dfd5f5 | 685 | 'options' => $this->case_types, |
be2fb01f CW |
686 | ], |
687 | 'case_status_id' => [ | |
6a488035 TO |
688 | 'title' => ts('Case Status'), |
689 | 'operatorType' => CRM_Report_Form::OP_MULTISELECT, | |
690 | 'options' => $this->case_statuses, | |
21dfd5f5 | 691 | 'name' => 'status_id', |
be2fb01f CW |
692 | ], |
693 | 'case_is_deleted' => [ | |
6a488035 TO |
694 | 'title' => ts('Case Deleted?'), |
695 | 'type' => CRM_Report_Form::OP_INT, | |
696 | 'operatorType' => CRM_Report_Form::OP_SELECT, | |
697 | 'options' => $this->deleted_labels, | |
698 | 'default' => 0, | |
21dfd5f5 | 699 | 'name' => 'is_deleted', |
be2fb01f CW |
700 | ], |
701 | ], | |
702 | ], | |
703 | ]; | |
6a488035 TO |
704 | } |
705 | ||
74cf4551 | 706 | /** |
fe482240 | 707 | * Get address columns to add to array. |
9d72cede | 708 | * |
74cf4551 | 709 | * @param array $options |
688d37c6 CW |
710 | * Options for the report. |
711 | * - prefix prefix to add (e.g. 'honor' when getting address details for honor contact | |
712 | * - prefix_label optional prefix lable eg. "Honoree " for front end | |
713 | * - group_by enable these fields for group by - default false | |
714 | * - order_by enable these fields for order by | |
715 | * - filters enable these fields for filtering | |
716 | * - defaults - (is this working?) values to pre-populate | |
9d72cede | 717 | * |
a6c01b45 CW |
718 | * @return array |
719 | * address columns definition | |
74cf4551 | 720 | */ |
be2fb01f CW |
721 | public function getAddressColumns($options = []) { |
722 | $defaultOptions = [ | |
6a488035 TO |
723 | 'prefix' => '', |
724 | 'prefix_label' => '', | |
9d72cede EM |
725 | 'group_by' => FALSE, |
726 | 'order_by' => TRUE, | |
727 | 'filters' => TRUE, | |
be2fb01f | 728 | 'defaults' => [ |
21dfd5f5 | 729 | 'country_id' => TRUE, |
be2fb01f CW |
730 | ], |
731 | ]; | |
6a488035 | 732 | |
9d72cede | 733 | $options = array_merge($defaultOptions, $options); |
6a488035 | 734 | |
be2fb01f CW |
735 | $addressFields = [ |
736 | $options['prefix'] . 'civicrm_address' => [ | |
6a488035 TO |
737 | 'dao' => 'CRM_Core_DAO_Address', |
738 | 'name' => 'civicrm_address', | |
739 | 'alias' => $options['prefix'] . 'civicrm_address', | |
be2fb01f CW |
740 | 'fields' => [ |
741 | $options['prefix'] . 'name' => [ | |
6a488035 TO |
742 | 'title' => ts($options['prefix_label'] . 'Address Name'), |
743 | 'default' => CRM_Utils_Array::value('name', $options['defaults'], FALSE), | |
744 | 'name' => 'name', | |
be2fb01f CW |
745 | ], |
746 | $options['prefix'] . 'street_address' => [ | |
6a488035 TO |
747 | 'title' => ts($options['prefix_label'] . 'Street Address'), |
748 | 'default' => CRM_Utils_Array::value('street_address', $options['defaults'], FALSE), | |
749 | 'name' => 'street_address', | |
be2fb01f CW |
750 | ], |
751 | $options['prefix'] . 'supplemental_address_1' => [ | |
9d72cede EM |
752 | 'title' => ts($options['prefix_label'] . |
753 | 'Supplementary Address Field 1'), | |
6a488035 TO |
754 | 'default' => CRM_Utils_Array::value('supplemental_address_1', $options['defaults'], FALSE), |
755 | 'name' => 'supplemental_address_1', | |
be2fb01f CW |
756 | ], |
757 | $options['prefix'] . 'supplemental_address_2' => [ | |
9d72cede EM |
758 | 'title' => ts($options['prefix_label'] . |
759 | 'Supplementary Address Field 2'), | |
6a488035 TO |
760 | 'default' => CRM_Utils_Array::value('supplemental_address_2', $options['defaults'], FALSE), |
761 | 'name' => 'supplemental_address_2', | |
be2fb01f CW |
762 | ], |
763 | $options['prefix'] . 'supplemental_address_3' => [ | |
207f62c6 AS |
764 | 'title' => ts($options['prefix_label'] . |
765 | 'Supplementary Address Field 3'), | |
766 | 'default' => CRM_Utils_Array::value('supplemental_address_3', $options['defaults'], FALSE), | |
767 | 'name' => 'supplemental_address_3', | |
be2fb01f CW |
768 | ], |
769 | $options['prefix'] . 'street_number' => [ | |
6a488035 TO |
770 | 'name' => 'street_number', |
771 | 'title' => ts($options['prefix_label'] . 'Street Number'), | |
772 | 'type' => 1, | |
773 | 'default' => CRM_Utils_Array::value('street_number', $options['defaults'], FALSE), | |
be2fb01f CW |
774 | ], |
775 | $options['prefix'] . 'street_name' => [ | |
6a488035 TO |
776 | 'name' => 'street_name', |
777 | 'title' => ts($options['prefix_label'] . 'Street Name'), | |
778 | 'type' => 1, | |
779 | 'default' => CRM_Utils_Array::value('street_name', $options['defaults'], FALSE), | |
be2fb01f CW |
780 | ], |
781 | $options['prefix'] . 'street_unit' => [ | |
6a488035 TO |
782 | 'name' => 'street_unit', |
783 | 'title' => ts($options['prefix_label'] . 'Street Unit'), | |
784 | 'type' => 1, | |
785 | 'default' => CRM_Utils_Array::value('street_unit', $options['defaults'], FALSE), | |
be2fb01f CW |
786 | ], |
787 | $options['prefix'] . 'city' => [ | |
6a488035 TO |
788 | 'title' => ts($options['prefix_label'] . 'City'), |
789 | 'default' => CRM_Utils_Array::value('city', $options['defaults'], FALSE), | |
790 | 'name' => 'city', | |
be2fb01f CW |
791 | ], |
792 | $options['prefix'] . 'postal_code' => [ | |
6a488035 TO |
793 | 'title' => ts($options['prefix_label'] . 'Postal Code'), |
794 | 'default' => CRM_Utils_Array::value('postal_code', $options['defaults'], FALSE), | |
795 | 'name' => 'postal_code', | |
be2fb01f CW |
796 | ], |
797 | $options['prefix'] . 'county_id' => [ | |
6a488035 TO |
798 | 'title' => ts($options['prefix_label'] . 'County'), |
799 | 'default' => CRM_Utils_Array::value('county_id', $options['defaults'], FALSE), | |
800 | 'alter_display' => 'alterCountyID', | |
801 | 'name' => 'county_id', | |
be2fb01f CW |
802 | ], |
803 | $options['prefix'] . 'state_province_id' => [ | |
6a488035 TO |
804 | 'title' => ts($options['prefix_label'] . 'State/Province'), |
805 | 'default' => CRM_Utils_Array::value('state_province_id', $options['defaults'], FALSE), | |
806 | 'alter_display' => 'alterStateProvinceID', | |
9d72cede | 807 | 'name' => 'state_province_id', |
be2fb01f CW |
808 | ], |
809 | $options['prefix'] . 'country_id' => [ | |
6a488035 TO |
810 | 'title' => ts($options['prefix_label'] . 'Country'), |
811 | 'default' => CRM_Utils_Array::value('country_id', $options['defaults'], FALSE), | |
812 | 'alter_display' => 'alterCountryID', | |
813 | 'name' => 'country_id', | |
be2fb01f CW |
814 | ], |
815 | ], | |
6a488035 | 816 | 'grouping' => 'location-fields', |
be2fb01f CW |
817 | ], |
818 | ]; | |
6a488035 TO |
819 | |
820 | if ($options['filters']) { | |
be2fb01f CW |
821 | $addressFields[$options['prefix'] . 'civicrm_address']['filters'] = [ |
822 | $options['prefix'] . 'street_number' => [ | |
6a488035 TO |
823 | 'title' => ts($options['prefix_label'] . 'Street Number'), |
824 | 'type' => 1, | |
825 | 'name' => 'street_number', | |
be2fb01f CW |
826 | ], |
827 | $options['prefix'] . 'street_name' => [ | |
6a488035 TO |
828 | 'title' => ts($options['prefix_label'] . 'Street Name'), |
829 | 'name' => $options['prefix'] . 'street_name', | |
830 | 'operator' => 'like', | |
be2fb01f CW |
831 | ], |
832 | $options['prefix'] . 'postal_code' => [ | |
6a488035 TO |
833 | 'title' => ts($options['prefix_label'] . 'Postal Code'), |
834 | 'type' => 1, | |
835 | 'name' => 'postal_code', | |
be2fb01f CW |
836 | ], |
837 | $options['prefix'] . 'city' => [ | |
6a488035 TO |
838 | 'title' => ts($options['prefix_label'] . 'City'), |
839 | 'operator' => 'like', | |
840 | 'name' => 'city', | |
be2fb01f CW |
841 | ], |
842 | $options['prefix'] . 'county_id' => [ | |
6a488035 TO |
843 | 'name' => 'county_id', |
844 | 'title' => ts($options['prefix_label'] . 'County'), | |
845 | 'type' => CRM_Utils_Type::T_INT, | |
846 | 'operatorType' => CRM_Report_Form::OP_MULTISELECT, | |
847 | 'options' => CRM_Core_PseudoConstant::county(), | |
be2fb01f CW |
848 | ], |
849 | $options['prefix'] . 'state_province_id' => [ | |
6a488035 TO |
850 | 'name' => 'state_province_id', |
851 | 'title' => ts($options['prefix_label'] . 'State/Province'), | |
852 | 'type' => CRM_Utils_Type::T_INT, | |
853 | 'operatorType' => CRM_Report_Form::OP_MULTISELECT, | |
854 | 'options' => CRM_Core_PseudoConstant::stateProvince(), | |
be2fb01f CW |
855 | ], |
856 | $options['prefix'] . 'country_id' => [ | |
6a488035 TO |
857 | 'name' => 'country_id', |
858 | 'title' => ts($options['prefix_label'] . 'Country'), | |
859 | 'type' => CRM_Utils_Type::T_INT, | |
860 | 'operatorType' => CRM_Report_Form::OP_MULTISELECT, | |
861 | 'options' => CRM_Core_PseudoConstant::country(), | |
be2fb01f CW |
862 | ], |
863 | ]; | |
6a488035 TO |
864 | } |
865 | ||
866 | if ($options['order_by']) { | |
9d72cede | 867 | $addressFields[$options['prefix'] . |
be2fb01f CW |
868 | 'civicrm_address']['order_bys'] = [ |
869 | $options['prefix'] . 'street_name' => [ | |
6a488035 TO |
870 | 'title' => ts($options['prefix_label'] . 'Street Name'), |
871 | 'name' => 'street_name', | |
be2fb01f CW |
872 | ], |
873 | $options['prefix'] . 'street_number' => [ | |
6a488035 TO |
874 | 'title' => ts($options['prefix_label'] . 'Odd / Even Street Number'), |
875 | 'name' => 'street_number', | |
be2fb01f CW |
876 | ], |
877 | $options['prefix'] . 'street_address' => [ | |
6a488035 TO |
878 | 'title' => ts($options['prefix_label'] . 'Street Address'), |
879 | 'name' => 'street_address', | |
be2fb01f CW |
880 | ], |
881 | $options['prefix'] . 'city' => [ | |
6a488035 TO |
882 | 'title' => ts($options['prefix_label'] . 'City'), |
883 | 'name' => 'city', | |
be2fb01f CW |
884 | ], |
885 | $options['prefix'] . 'postal_code' => [ | |
6a488035 TO |
886 | 'title' => ts($options['prefix_label'] . 'Post Code'), |
887 | 'name' => 'postal_code', | |
be2fb01f CW |
888 | ], |
889 | ]; | |
6a488035 TO |
890 | } |
891 | ||
892 | if ($options['group_by']) { | |
be2fb01f CW |
893 | $addressFields['civicrm_address']['group_bys'] = [ |
894 | $options['prefix'] . 'street_address' => [ | |
6a488035 TO |
895 | 'title' => ts($options['prefix_label'] . 'Street Address'), |
896 | 'name' => 'street_address', | |
be2fb01f CW |
897 | ], |
898 | $options['prefix'] . 'city' => [ | |
6a488035 TO |
899 | 'title' => ts($options['prefix_label'] . 'City'), |
900 | 'name' => 'city', | |
be2fb01f CW |
901 | ], |
902 | $options['prefix'] . 'postal_code' => [ | |
6a488035 TO |
903 | 'title' => ts($options['prefix_label'] . 'Post Code'), |
904 | 'name' => 'postal_code', | |
be2fb01f CW |
905 | ], |
906 | $options['prefix'] . 'state_province_id' => [ | |
6a488035 TO |
907 | 'title' => ts($options['prefix_label'] . 'State/Province'), |
908 | 'name' => 'state_province_id', | |
be2fb01f CW |
909 | ], |
910 | $options['prefix'] . 'country_id' => [ | |
6a488035 TO |
911 | 'title' => ts($options['prefix_label'] . 'Country'), |
912 | 'name' => 'country_id', | |
be2fb01f CW |
913 | ], |
914 | $options['prefix'] . 'county_id' => [ | |
6a488035 TO |
915 | 'title' => ts($options['prefix_label'] . 'County'), |
916 | 'name' => 'county_id', | |
be2fb01f CW |
917 | ], |
918 | ]; | |
6a488035 TO |
919 | } |
920 | return $addressFields; | |
921 | } | |
922 | ||
74cf4551 | 923 | /** |
fe482240 | 924 | * Get Information about advertised Joins. |
688d37c6 | 925 | * |
74cf4551 EM |
926 | * @return array |
927 | */ | |
00be9182 | 928 | public function getAvailableJoins() { |
be2fb01f CW |
929 | return [ |
930 | 'priceFieldValue_from_lineItem' => [ | |
6a488035 TO |
931 | 'leftTable' => 'civicrm_line_item', |
932 | 'rightTable' => 'civicrm_price_field_value', | |
933 | 'callback' => 'joinPriceFieldValueFromLineItem', | |
be2fb01f CW |
934 | ], |
935 | 'priceField_from_lineItem' => [ | |
6a488035 TO |
936 | 'leftTable' => 'civicrm_line_item', |
937 | 'rightTable' => 'civicrm_price_field', | |
938 | 'callback' => 'joinPriceFieldFromLineItem', | |
be2fb01f CW |
939 | ], |
940 | 'participant_from_lineItem' => [ | |
6a488035 TO |
941 | 'leftTable' => 'civicrm_line_item', |
942 | 'rightTable' => 'civicrm_participant', | |
943 | 'callback' => 'joinParticipantFromLineItem', | |
be2fb01f CW |
944 | ], |
945 | 'contribution_from_lineItem' => [ | |
6a488035 TO |
946 | 'leftTable' => 'civicrm_line_item', |
947 | 'rightTable' => 'civicrm_contribution', | |
948 | 'callback' => 'joinContributionFromLineItem', | |
be2fb01f CW |
949 | ], |
950 | 'membership_from_lineItem' => [ | |
6a488035 TO |
951 | 'leftTable' => 'civicrm_line_item', |
952 | 'rightTable' => 'civicrm_membership', | |
953 | 'callback' => 'joinMembershipFromLineItem', | |
be2fb01f CW |
954 | ], |
955 | 'contribution_from_participant' => [ | |
6a488035 TO |
956 | 'leftTable' => 'civicrm_participant', |
957 | 'rightTable' => 'civicrm_contribution', | |
958 | 'callback' => 'joinContributionFromParticipant', | |
be2fb01f CW |
959 | ], |
960 | 'contribution_from_membership' => [ | |
6a488035 TO |
961 | 'leftTable' => 'civicrm_membership', |
962 | 'rightTable' => 'civicrm_contribution', | |
963 | 'callback' => 'joinContributionFromMembership', | |
be2fb01f CW |
964 | ], |
965 | 'membership_from_contribution' => [ | |
6a488035 TO |
966 | 'leftTable' => 'civicrm_contribution', |
967 | 'rightTable' => 'civicrm_membership', | |
968 | 'callback' => 'joinMembershipFromContribution', | |
be2fb01f CW |
969 | ], |
970 | 'membershipType_from_membership' => [ | |
6a488035 TO |
971 | 'leftTable' => 'civicrm_membership', |
972 | 'rightTable' => 'civicrm_membership_type', | |
973 | 'callback' => 'joinMembershipTypeFromMembership', | |
be2fb01f CW |
974 | ], |
975 | 'lineItem_from_contribution' => [ | |
6a488035 TO |
976 | 'leftTable' => 'civicrm_contribution', |
977 | 'rightTable' => 'civicrm_line_item', | |
978 | 'callback' => 'joinLineItemFromContribution', | |
be2fb01f CW |
979 | ], |
980 | 'lineItem_from_membership' => [ | |
6a488035 TO |
981 | 'leftTable' => 'civicrm_membership', |
982 | 'rightTable' => 'civicrm_line_item', | |
983 | 'callback' => 'joinLineItemFromMembership', | |
be2fb01f CW |
984 | ], |
985 | 'contact_from_participant' => [ | |
6a488035 TO |
986 | 'leftTable' => 'civicrm_participant', |
987 | 'rightTable' => 'civicrm_contact', | |
988 | 'callback' => 'joinContactFromParticipant', | |
be2fb01f CW |
989 | ], |
990 | 'contact_from_membership' => [ | |
6a488035 TO |
991 | 'leftTable' => 'civicrm_membership', |
992 | 'rightTable' => 'civicrm_contact', | |
993 | 'callback' => 'joinContactFromMembership', | |
be2fb01f CW |
994 | ], |
995 | 'contact_from_contribution' => [ | |
6a488035 TO |
996 | 'leftTable' => 'civicrm_contribution', |
997 | 'rightTable' => 'civicrm_contact', | |
998 | 'callback' => 'joinContactFromContribution', | |
be2fb01f CW |
999 | ], |
1000 | 'event_from_participant' => [ | |
6a488035 TO |
1001 | 'leftTable' => 'civicrm_participant', |
1002 | 'rightTable' => 'civicrm_event', | |
1003 | 'callback' => 'joinEventFromParticipant', | |
be2fb01f CW |
1004 | ], |
1005 | 'address_from_contact' => [ | |
6a488035 TO |
1006 | 'leftTable' => 'civicrm_contact', |
1007 | 'rightTable' => 'civicrm_address', | |
1008 | 'callback' => 'joinAddressFromContact', | |
be2fb01f CW |
1009 | ], |
1010 | ]; | |
6a488035 TO |
1011 | } |
1012 | ||
688d37c6 | 1013 | /** |
6a488035 TO |
1014 | * Add join from contact table to address. Prefix will be added to both tables |
1015 | * as it's assumed you are using it to get address of a secondary contact | |
688d37c6 | 1016 | * |
74cf4551 EM |
1017 | * @param string $prefix |
1018 | */ | |
00be9182 | 1019 | public function joinAddressFromContact($prefix = '') { |
9d72cede EM |
1020 | $this->_from .= " LEFT JOIN civicrm_address {$this->_aliases[$prefix . |
1021 | 'civicrm_address']} | |
1022 | ON {$this->_aliases[$prefix . | |
1023 | 'civicrm_address']}.contact_id = {$this->_aliases[$prefix . | |
1024 | 'civicrm_contact']}.id"; | |
6a488035 TO |
1025 | } |
1026 | ||
00be9182 | 1027 | public function joinPriceFieldValueFromLineItem() { |
6a488035 TO |
1028 | $this->_from .= " LEFT JOIN civicrm_price_field_value {$this->_aliases['civicrm_price_field_value']} |
1029 | ON {$this->_aliases['civicrm_line_item']}.price_field_value_id = {$this->_aliases['civicrm_price_field_value']}.id"; | |
1030 | } | |
1031 | ||
00be9182 | 1032 | public function joinPriceFieldFromLineItem() { |
6a488035 TO |
1033 | $this->_from .= " |
1034 | LEFT JOIN civicrm_price_field {$this->_aliases['civicrm_price_field']} | |
1035 | ON {$this->_aliases['civicrm_line_item']}.price_field_id = {$this->_aliases['civicrm_price_field']}.id | |
1036 | "; | |
1037 | } | |
1038 | ||
688d37c6 | 1039 | /** |
fe482240 | 1040 | * Define join from line item table to participant table. |
6a488035 | 1041 | */ |
00be9182 | 1042 | public function joinParticipantFromLineItem() { |
6a488035 TO |
1043 | $this->_from .= " LEFT JOIN civicrm_participant {$this->_aliases['civicrm_participant']} |
1044 | ON ( {$this->_aliases['civicrm_line_item']}.entity_id = {$this->_aliases['civicrm_participant']}.id | |
1045 | AND {$this->_aliases['civicrm_line_item']}.entity_table = 'civicrm_participant') | |
1046 | "; | |
1047 | } | |
1048 | ||
688d37c6 | 1049 | /** |
6a488035 TO |
1050 | * Define join from line item table to Membership table. Seems to be still via contribution |
1051 | * as the entity. Have made 'inner' to restrict does that make sense? | |
1052 | */ | |
00be9182 | 1053 | public function joinMembershipFromLineItem() { |
6a488035 TO |
1054 | $this->_from .= " INNER JOIN civicrm_contribution {$this->_aliases['civicrm_contribution']} |
1055 | ON ( {$this->_aliases['civicrm_line_item']}.entity_id = {$this->_aliases['civicrm_contribution']}.id | |
1056 | AND {$this->_aliases['civicrm_line_item']}.entity_table = 'civicrm_contribution') | |
1057 | LEFT JOIN civicrm_membership_payment pp | |
1058 | ON {$this->_aliases['civicrm_contribution']}.id = pp.contribution_id | |
1059 | LEFT JOIN civicrm_membership {$this->_aliases['civicrm_membership']} | |
1060 | ON pp.membership_id = {$this->_aliases['civicrm_membership']}.id | |
1061 | "; | |
1062 | } | |
1063 | ||
688d37c6 | 1064 | /** |
fe482240 | 1065 | * Define join from Participant to Contribution table. |
6a488035 | 1066 | */ |
00be9182 | 1067 | public function joinContributionFromParticipant() { |
6a488035 TO |
1068 | $this->_from .= " LEFT JOIN civicrm_participant_payment pp |
1069 | ON {$this->_aliases['civicrm_participant']}.id = pp.participant_id | |
1070 | LEFT JOIN civicrm_contribution {$this->_aliases['civicrm_contribution']} | |
1071 | ON pp.contribution_id = {$this->_aliases['civicrm_contribution']}.id | |
1072 | "; | |
1073 | } | |
1074 | ||
688d37c6 | 1075 | /** |
fe482240 | 1076 | * Define join from Membership to Contribution table. |
6a488035 | 1077 | */ |
00be9182 | 1078 | public function joinContributionFromMembership() { |
6a488035 TO |
1079 | $this->_from .= " LEFT JOIN civicrm_membership_payment pp |
1080 | ON {$this->_aliases['civicrm_membership']}.id = pp.membership_id | |
1081 | LEFT JOIN civicrm_contribution {$this->_aliases['civicrm_contribution']} | |
1082 | ON pp.contribution_id = {$this->_aliases['civicrm_contribution']}.id | |
1083 | "; | |
1084 | } | |
1085 | ||
00be9182 | 1086 | public function joinParticipantFromContribution() { |
6a488035 TO |
1087 | $this->_from .= " LEFT JOIN civicrm_participant_payment pp |
1088 | ON {$this->_aliases['civicrm_contribution']}.id = pp.contribution_id | |
1089 | LEFT JOIN civicrm_participant {$this->_aliases['civicrm_participant']} | |
1090 | ON pp.participant_id = {$this->_aliases['civicrm_participant']}.id"; | |
1091 | } | |
1092 | ||
00be9182 | 1093 | public function joinMembershipFromContribution() { |
6a488035 TO |
1094 | $this->_from .= " |
1095 | LEFT JOIN civicrm_membership_payment pp | |
1096 | ON {$this->_aliases['civicrm_contribution']}.id = pp.contribution_id | |
1097 | LEFT JOIN civicrm_membership {$this->_aliases['civicrm_membership']} | |
1098 | ON pp.membership_id = {$this->_aliases['civicrm_membership']}.id"; | |
1099 | } | |
1100 | ||
00be9182 | 1101 | public function joinMembershipTypeFromMembership() { |
6a488035 TO |
1102 | $this->_from .= " |
1103 | LEFT JOIN civicrm_membership_type {$this->_aliases['civicrm_membership_type']} | |
1104 | ON {$this->_aliases['civicrm_membership']}.membership_type_id = {$this->_aliases['civicrm_membership_type']}.id | |
1105 | "; | |
1106 | } | |
1107 | ||
00be9182 | 1108 | public function joinContributionFromLineItem() { |
6a488035 TO |
1109 | |
1110 | // this can be stored as a temp table & indexed for more speed. Not done at this state. | |
1111 | // another option is to cache it but I haven't tried to put that code in yet (have used it before for one hour caching | |
1112 | $this->_from .= " LEFT JOIN (SELECT line_item_civireport.id as lid, contribution_civireport_direct.* | |
1113 | FROM civicrm_line_item line_item_civireport | |
1114 | LEFT JOIN civicrm_contribution contribution_civireport_direct | |
1115 | ON (line_item_civireport.line_total > 0 AND line_item_civireport.entity_id = contribution_civireport_direct.id AND line_item_civireport.entity_table = 'civicrm_contribution') | |
1116 | ||
1117 | ||
1118 | WHERE contribution_civireport_direct.id IS NOT NULL | |
1119 | ||
1120 | UNION SELECT line_item_civireport.id as lid, contribution_civireport.* | |
1121 | FROM civicrm_line_item line_item_civireport | |
1122 | LEFT JOIN civicrm_participant participant_civireport | |
1123 | ON (line_item_civireport.line_total > 0 AND line_item_civireport.entity_id = participant_civireport.id AND line_item_civireport.entity_table = 'civicrm_participant') | |
1124 | ||
1125 | LEFT JOIN civicrm_participant_payment pp | |
1126 | ON participant_civireport.id = pp.participant_id | |
1127 | LEFT JOIN civicrm_contribution contribution_civireport | |
1128 | ON pp.contribution_id = contribution_civireport.id | |
1129 | ||
1130 | UNION SELECT line_item_civireport.id as lid,contribution_civireport.* | |
1131 | FROM civicrm_line_item line_item_civireport | |
1132 | LEFT JOIN civicrm_membership membership_civireport | |
1133 | ON (line_item_civireport.line_total > 0 AND line_item_civireport.entity_id =membership_civireport.id AND line_item_civireport.entity_table = 'civicrm_membership') | |
1134 | ||
1135 | LEFT JOIN civicrm_membership_payment pp | |
1136 | ON membership_civireport.id = pp.membership_id | |
1137 | LEFT JOIN civicrm_contribution contribution_civireport | |
1138 | ON pp.contribution_id = contribution_civireport.id | |
1139 | ) as {$this->_aliases['civicrm_contribution']} | |
1140 | ON {$this->_aliases['civicrm_contribution']}.lid = {$this->_aliases['civicrm_line_item']}.id | |
1141 | "; | |
1142 | } | |
1143 | ||
00be9182 | 1144 | public function joinLineItemFromContribution() { |
6a488035 TO |
1145 | |
1146 | // this can be stored as a temp table & indexed for more speed. Not done at this stage. | |
1147 | // another option is to cache it but I haven't tried to put that code in yet (have used it before for one hour caching | |
1148 | $this->_from .= " | |
1149 | LEFT JOIN ( | |
1150 | SELECT contribution_civireport_direct.id AS contid, line_item_civireport.* | |
1151 | FROM civicrm_contribution contribution_civireport_direct | |
1152 | LEFT JOIN civicrm_line_item line_item_civireport ON (line_item_civireport.line_total > 0 AND line_item_civireport.entity_id = contribution_civireport_direct.id AND line_item_civireport.entity_table = 'civicrm_contribution') | |
1153 | WHERE line_item_civireport.id IS NOT NULL | |
1154 | ||
1155 | UNION | |
1156 | SELECT contribution_civireport_direct.id AS contid, line_item_civireport.* | |
1157 | FROM civicrm_contribution contribution_civireport_direct | |
1158 | LEFT JOIN civicrm_participant_payment pp ON contribution_civireport_direct.id = pp.contribution_id | |
1159 | LEFT JOIN civicrm_participant p ON pp.participant_id = p.id | |
1160 | LEFT JOIN civicrm_line_item line_item_civireport ON (line_item_civireport.line_total > 0 AND line_item_civireport.entity_id = p.id AND line_item_civireport.entity_table = 'civicrm_participant') | |
1161 | WHERE line_item_civireport.id IS NOT NULL | |
1162 | ||
1163 | UNION | |
1164 | ||
1165 | SELECT contribution_civireport_direct.id AS contid, line_item_civireport.* | |
1166 | FROM civicrm_contribution contribution_civireport_direct | |
1167 | LEFT JOIN civicrm_membership_payment pp ON contribution_civireport_direct.id = pp.contribution_id | |
1168 | LEFT JOIN civicrm_membership p ON pp.membership_id = p.id | |
1169 | LEFT JOIN civicrm_line_item line_item_civireport ON (line_item_civireport.line_total > 0 AND line_item_civireport.entity_id = p.id AND line_item_civireport.entity_table = 'civicrm_membership') | |
2f4c2f5d | 1170 | WHERE line_item_civireport.id IS NOT NULL |
6a488035 TO |
1171 | ) as {$this->_aliases['civicrm_line_item']} |
1172 | ON {$this->_aliases['civicrm_line_item']}.contid = {$this->_aliases['civicrm_contribution']}.id | |
1173 | ||
1174 | ||
1175 | "; | |
1176 | } | |
1177 | ||
00be9182 | 1178 | public function joinLineItemFromMembership() { |
6a488035 TO |
1179 | |
1180 | // this can be stored as a temp table & indexed for more speed. Not done at this stage. | |
1181 | // another option is to cache it but I haven't tried to put that code in yet (have used it before for one hour caching | |
1182 | $this->_from .= " | |
1183 | LEFT JOIN ( | |
1184 | SELECT contribution_civireport_direct.id AS contid, line_item_civireport.* | |
1185 | FROM civicrm_contribution contribution_civireport_direct | |
1186 | LEFT JOIN civicrm_line_item line_item_civireport | |
1187 | ON (line_item_civireport.line_total > 0 AND line_item_civireport.entity_id = contribution_civireport_direct.id AND line_item_civireport.entity_table = 'civicrm_contribution') | |
1188 | ||
2f4c2f5d | 1189 | WHERE line_item_civireport.id IS NOT NULL |
6a488035 TO |
1190 | |
1191 | UNION | |
1192 | ||
1193 | SELECT contribution_civireport_direct.id AS contid, line_item_civireport.* | |
1194 | FROM civicrm_contribution contribution_civireport_direct | |
1195 | LEFT JOIN civicrm_membership_payment pp ON contribution_civireport_direct.id = pp.contribution_id | |
1196 | LEFT JOIN civicrm_membership p ON pp.membership_id = p.id | |
1197 | LEFT JOIN civicrm_line_item line_item_civireport ON (line_item_civireport.line_total > 0 AND line_item_civireport.entity_id = p.id AND line_item_civireport.entity_table = 'civicrm_membership') | |
2f4c2f5d | 1198 | WHERE line_item_civireport.id IS NOT NULL |
6a488035 TO |
1199 | ) as {$this->_aliases['civicrm_line_item']} |
1200 | ON {$this->_aliases['civicrm_line_item']}.contid = {$this->_aliases['civicrm_contribution']}.id | |
1201 | "; | |
1202 | } | |
1203 | ||
00be9182 | 1204 | public function joinContactFromParticipant() { |
6a488035 TO |
1205 | $this->_from .= " LEFT JOIN civicrm_contact {$this->_aliases['civicrm_contact']} |
1206 | ON {$this->_aliases['civicrm_participant']}.contact_id = {$this->_aliases['civicrm_contact']}.id"; | |
1207 | } | |
1208 | ||
00be9182 | 1209 | public function joinContactFromMembership() { |
6a488035 TO |
1210 | $this->_from .= " LEFT JOIN civicrm_contact {$this->_aliases['civicrm_contact']} |
1211 | ON {$this->_aliases['civicrm_membership']}.contact_id = {$this->_aliases['civicrm_contact']}.id"; | |
1212 | } | |
1213 | ||
00be9182 | 1214 | public function joinContactFromContribution() { |
6a488035 TO |
1215 | $this->_from .= " LEFT JOIN civicrm_contact {$this->_aliases['civicrm_contact']} |
1216 | ON {$this->_aliases['civicrm_contribution']}.contact_id = {$this->_aliases['civicrm_contact']}.id"; | |
1217 | } | |
1218 | ||
00be9182 | 1219 | public function joinEventFromParticipant() { |
6a488035 TO |
1220 | $this->_from .= " LEFT JOIN civicrm_event {$this->_aliases['civicrm_event']} |
1221 | ON ({$this->_aliases['civicrm_event']}.id = {$this->_aliases['civicrm_participant']}.event_id ) AND | |
1222 | ({$this->_aliases['civicrm_event']}.is_template IS NULL OR | |
1223 | {$this->_aliases['civicrm_event']}.is_template = 0)"; | |
1224 | } | |
1225 | ||
74cf4551 | 1226 | /** |
fe482240 | 1227 | * Retrieve text for financial type from pseudoconstant. |
688d37c6 | 1228 | * |
74cf4551 | 1229 | * @param $value |
688d37c6 | 1230 | * @param array $row |
74cf4551 EM |
1231 | * |
1232 | * @return string | |
1233 | */ | |
00be9182 | 1234 | public function alterNickName($value, &$row) { |
9d72cede | 1235 | if (empty($row['civicrm_contact_id'])) { |
d5cc0fc2 | 1236 | return NULL; |
6a488035 TO |
1237 | } |
1238 | $contactID = $row['civicrm_contact_id']; | |
1239 | return "<div id=contact-{$contactID} class='crm-entity'> | |
1726c7d2 | 1240 | <span class='crm-editable crmf-nick_name crm-editable-enabled'> |
6a488035 TO |
1241 | " . $value . "</span></div>"; |
1242 | } | |
1243 | ||
74cf4551 | 1244 | /** |
fe482240 | 1245 | * Retrieve text for contribution type from pseudoconstant. |
688d37c6 | 1246 | * |
74cf4551 | 1247 | * @param $value |
688d37c6 | 1248 | * @param array $row |
74cf4551 EM |
1249 | * |
1250 | * @return array|string | |
1251 | */ | |
00be9182 | 1252 | public function alterContributionType($value, &$row) { |
b914f4e8 | 1253 | return is_string(CRM_Contribute_PseudoConstant::financialType($value, FALSE)) ? CRM_Contribute_PseudoConstant::financialType($value, FALSE) : ''; |
6a488035 TO |
1254 | } |
1255 | ||
74cf4551 | 1256 | /** |
fe482240 | 1257 | * Retrieve text for contribution status from pseudoconstant. |
688d37c6 | 1258 | * |
74cf4551 | 1259 | * @param $value |
688d37c6 | 1260 | * @param array $row |
74cf4551 EM |
1261 | * |
1262 | * @return array | |
1263 | */ | |
00be9182 | 1264 | public function alterContributionStatus($value, &$row) { |
6a488035 TO |
1265 | return CRM_Contribute_PseudoConstant::contributionStatus($value); |
1266 | } | |
1267 | ||
74cf4551 | 1268 | /** |
fe482240 | 1269 | * Retrieve text for payment instrument from pseudoconstant. |
688d37c6 | 1270 | * |
74cf4551 | 1271 | * @param $value |
688d37c6 | 1272 | * @param array $row |
74cf4551 EM |
1273 | * |
1274 | * @return array | |
1275 | */ | |
00be9182 | 1276 | public function alterEventType($value, &$row) { |
6a488035 TO |
1277 | return CRM_Event_PseudoConstant::eventType($value); |
1278 | } | |
1279 | ||
74cf4551 EM |
1280 | /** |
1281 | * @param $value | |
688d37c6 | 1282 | * @param array $row |
74cf4551 EM |
1283 | * |
1284 | * @return array|string | |
1285 | */ | |
00be9182 | 1286 | public function alterEventID($value, &$row) { |
6a488035 TO |
1287 | return is_string(CRM_Event_PseudoConstant::event($value, FALSE)) ? CRM_Event_PseudoConstant::event($value, FALSE) : ''; |
1288 | } | |
1289 | ||
74cf4551 EM |
1290 | /** |
1291 | * @param $value | |
688d37c6 | 1292 | * @param array $row |
74cf4551 EM |
1293 | * |
1294 | * @return array|string | |
1295 | */ | |
00be9182 | 1296 | public function alterMembershipTypeID($value, &$row) { |
6a488035 TO |
1297 | return is_string(CRM_Member_PseudoConstant::membershipType($value, FALSE)) ? CRM_Member_PseudoConstant::membershipType($value, FALSE) : ''; |
1298 | } | |
1299 | ||
74cf4551 EM |
1300 | /** |
1301 | * @param $value | |
688d37c6 | 1302 | * @param array $row |
74cf4551 EM |
1303 | * |
1304 | * @return array|string | |
1305 | */ | |
00be9182 | 1306 | public function alterMembershipStatusID($value, &$row) { |
6a488035 TO |
1307 | return is_string(CRM_Member_PseudoConstant::membershipStatus($value, FALSE)) ? CRM_Member_PseudoConstant::membershipStatus($value, FALSE) : ''; |
1308 | } | |
1309 | ||
74cf4551 EM |
1310 | /** |
1311 | * @param $value | |
688d37c6 | 1312 | * @param array $row |
74cf4551 | 1313 | * @param $selectedfield |
100fef9d | 1314 | * @param string $criteriaFieldName |
74cf4551 EM |
1315 | * |
1316 | * @return array | |
1317 | */ | |
00be9182 | 1318 | public function alterCountryID($value, &$row, $selectedfield, $criteriaFieldName) { |
6a488035 TO |
1319 | $url = CRM_Utils_System::url(CRM_Utils_System::currentPath(), "reset=1&force=1&{$criteriaFieldName}_op=in&{$criteriaFieldName}_value={$value}", $this->_absoluteUrl); |
1320 | $row[$selectedfield . '_link'] = $url; | |
9d72cede | 1321 | $row[$selectedfield . |
be2fb01f | 1322 | '_hover'] = ts("%1 for this country.", [1 => $value]); |
9d72cede EM |
1323 | $countries = CRM_Core_PseudoConstant::country($value, FALSE); |
1324 | if (!is_array($countries)) { | |
6a488035 TO |
1325 | return $countries; |
1326 | } | |
1327 | } | |
1328 | ||
74cf4551 EM |
1329 | /** |
1330 | * @param $value | |
688d37c6 | 1331 | * @param array $row |
74cf4551 | 1332 | * @param $selectedfield |
100fef9d | 1333 | * @param string $criteriaFieldName |
74cf4551 EM |
1334 | * |
1335 | * @return array | |
1336 | */ | |
00be9182 | 1337 | public function alterCountyID($value, &$row, $selectedfield, $criteriaFieldName) { |
6a488035 TO |
1338 | $url = CRM_Utils_System::url(CRM_Utils_System::currentPath(), "reset=1&force=1&{$criteriaFieldName}_op=in&{$criteriaFieldName}_value={$value}", $this->_absoluteUrl); |
1339 | $row[$selectedfield . '_link'] = $url; | |
9d72cede | 1340 | $row[$selectedfield . |
be2fb01f | 1341 | '_hover'] = ts("%1 for this county.", [1 => $value]); |
6a488035 | 1342 | $counties = CRM_Core_PseudoConstant::county($value, FALSE); |
9d72cede | 1343 | if (!is_array($counties)) { |
6a488035 TO |
1344 | return $counties; |
1345 | } | |
1346 | } | |
1347 | ||
74cf4551 EM |
1348 | /** |
1349 | * @param $value | |
688d37c6 | 1350 | * @param array $row |
74cf4551 | 1351 | * @param $selectedfield |
100fef9d | 1352 | * @param string $criteriaFieldName |
74cf4551 EM |
1353 | * |
1354 | * @return array | |
1355 | */ | |
00be9182 | 1356 | public function alterStateProvinceID($value, &$row, $selectedfield, $criteriaFieldName) { |
6a488035 TO |
1357 | $url = CRM_Utils_System::url(CRM_Utils_System::currentPath(), "reset=1&force=1&{$criteriaFieldName}_op=in&{$criteriaFieldName}_value={$value}", $this->_absoluteUrl); |
1358 | $row[$selectedfield . '_link'] = $url; | |
9d72cede | 1359 | $row[$selectedfield . |
be2fb01f | 1360 | '_hover'] = ts("%1 for this state.", [1 => $value]); |
6a488035 | 1361 | |
9d72cede EM |
1362 | $states = CRM_Core_PseudoConstant::stateProvince($value, FALSE); |
1363 | if (!is_array($states)) { | |
6a488035 TO |
1364 | return $states; |
1365 | } | |
1366 | } | |
1367 | ||
74cf4551 EM |
1368 | /** |
1369 | * @param $value | |
688d37c6 | 1370 | * @param array $row |
100fef9d | 1371 | * @param string $fieldname |
74cf4551 EM |
1372 | * |
1373 | * @return mixed | |
1374 | */ | |
00be9182 | 1375 | public function alterContactID($value, &$row, $fieldname) { |
9d72cede EM |
1376 | $row[$fieldname . '_link'] = CRM_Utils_System::url("civicrm/contact/view", |
1377 | 'reset=1&cid=' . $value, $this->_absoluteUrl); | |
6a488035 TO |
1378 | return $value; |
1379 | } | |
1380 | ||
74cf4551 EM |
1381 | /** |
1382 | * @param $value | |
1383 | * | |
1384 | * @return array | |
1385 | */ | |
00be9182 | 1386 | public function alterParticipantStatus($value) { |
6a488035 | 1387 | if (empty($value)) { |
d5cc0fc2 | 1388 | return NULL; |
6a488035 TO |
1389 | } |
1390 | return CRM_Event_PseudoConstant::participantStatus($value, FALSE, 'label'); | |
1391 | } | |
1392 | ||
74cf4551 EM |
1393 | /** |
1394 | * @param $value | |
1395 | * | |
688d37c6 | 1396 | * @return string|void |
74cf4551 | 1397 | */ |
00be9182 | 1398 | public function alterParticipantRole($value) { |
6a488035 | 1399 | if (empty($value)) { |
d5cc0fc2 | 1400 | return NULL; |
6a488035 TO |
1401 | } |
1402 | $roles = explode(CRM_Core_DAO::VALUE_SEPARATOR, $value); | |
be2fb01f | 1403 | $value = []; |
6a488035 TO |
1404 | foreach ($roles as $role) { |
1405 | $value[$role] = CRM_Event_PseudoConstant::participantRole($role, FALSE); | |
1406 | } | |
1407 | return implode(', ', $value); | |
1408 | } | |
1409 | ||
74cf4551 EM |
1410 | /** |
1411 | * @param $value | |
1412 | * | |
1413 | * @return mixed | |
1414 | */ | |
00be9182 | 1415 | public function alterPaymentType($value) { |
6a488035 TO |
1416 | $paymentInstruments = CRM_Contribute_PseudoConstant::paymentInstrument(); |
1417 | return $paymentInstruments[$value]; | |
1418 | } | |
96025800 | 1419 | |
6a488035 | 1420 | } |