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