Commit | Line | Data |
---|---|---|
6a488035 | 1 | <?php |
6a488035 TO |
2 | /* |
3 | +--------------------------------------------------------------------+ | |
7e9e8871 | 4 | | CiviCRM version 4.7 | |
6a488035 | 5 | +--------------------------------------------------------------------+ |
e7112fa7 | 6 | | Copyright CiviCRM LLC (c) 2004-2015 | |
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 | |
e7112fa7 | 31 | * @copyright CiviCRM LLC (c) 2004-2015 |
6a488035 TO |
32 | * $Id$ |
33 | * | |
34 | */ | |
35 | class CRM_Report_Form_Contact_Detail extends CRM_Report_Form { | |
7da04cde | 36 | const ROW_COUNT_LIMIT = 10; |
6a488035 TO |
37 | |
38 | protected $_summary = NULL; | |
39 | ||
40 | protected $_customGroupExtends = array( | |
9d72cede EM |
41 | 'Contact', |
42 | 'Individual', | |
43 | 'Household', | |
21dfd5f5 | 44 | 'Organization', |
9d72cede | 45 | ); |
6a488035 | 46 | |
74cf4551 | 47 | /** |
74cf4551 EM |
48 | */ |
49 | /** | |
74cf4551 | 50 | */ |
00be9182 | 51 | public function __construct() { |
6a488035 TO |
52 | $this->_autoIncludeIndexedFieldsAsOrderBys = 1; |
53 | $this->_columns = array( | |
9d72cede | 54 | 'civicrm_contact' => array( |
6a488035 | 55 | 'dao' => 'CRM_Contact_DAO_Contact', |
9d72cede EM |
56 | 'fields' => array( |
57 | 'sort_name' => array( | |
58 | 'title' => ts('Contact Name'), | |
6a488035 TO |
59 | 'required' => TRUE, |
60 | 'no_repeat' => TRUE, | |
61 | ), | |
30f85891 RN |
62 | 'first_name' => array( |
63 | 'title' => ts('First Name'), | |
6a488035 | 64 | ), |
70bea8e2 | 65 | 'middle_name' => array( |
66 | 'title' => ts('Middle Name'), | |
67 | ), | |
30f85891 RN |
68 | 'last_name' => array( |
69 | 'title' => ts('Last Name'), | |
6a488035 | 70 | ), |
9d72cede | 71 | 'id' => array( |
6a488035 TO |
72 | 'no_display' => TRUE, |
73 | 'required' => TRUE, | |
74 | ), | |
70bea8e2 | 75 | 'gender_id' => array( |
76 | 'title' => ts('Gender'), | |
77 | ), | |
78 | 'birth_date' => array( | |
79 | 'title' => ts('Birth Date'), | |
80 | ), | |
81 | 'age' => array( | |
82 | 'title' => ts('Age'), | |
83 | 'dbAlias' => 'TIMESTAMPDIFF(YEAR, contact_civireport.birth_date, CURDATE())', | |
84 | ), | |
9d72cede | 85 | 'contact_type' => array( |
30f85891 RN |
86 | 'title' => ts('Contact Type'), |
87 | ), | |
9d72cede | 88 | 'contact_sub_type' => array( |
b8f96eb8 | 89 | 'title' => ts('Contact Subtype'), |
30f85891 | 90 | ), |
6a488035 | 91 | ), |
9d72cede EM |
92 | 'filters' => array( |
93 | 'id' => array( | |
94 | 'title' => ts('Contact ID'), | |
6a488035 TO |
95 | 'no_display' => TRUE, |
96 | ), | |
9d72cede EM |
97 | 'sort_name' => array( |
98 | 'title' => ts('Contact Name'), | |
6a488035 | 99 | ), |
70bea8e2 | 100 | 'gender_id' => array( |
101 | 'title' => ts('Gender'), | |
102 | 'operatorType' => CRM_Report_Form::OP_MULTISELECT, | |
103 | 'options' => CRM_Core_PseudoConstant::get('CRM_Contact_DAO_Contact', 'gender_id'), | |
104 | ), | |
9d72cede | 105 | 'birth_date' => array( |
c0568199 RN |
106 | 'title' => ts('Birth Date'), |
107 | 'operatorType' => CRM_Report_Form::OP_DATE, | |
108 | ), | |
70bea8e2 | 109 | 'contact_type' => array( |
110 | 'title' => ts('Contact Type'), | |
111 | ), | |
112 | 'contact_sub_type' => array( | |
113 | 'title' => ts('Contact Subtype'), | |
114 | ), | |
6a488035 TO |
115 | ), |
116 | 'grouping' => 'contact-fields', | |
9d72cede EM |
117 | 'order_bys' => array( |
118 | 'sort_name' => array( | |
119 | 'title' => ts('Last Name, First Name'), | |
120 | 'default' => '1', | |
121 | 'default_weight' => '0', | |
21dfd5f5 | 122 | 'default_order' => 'ASC', |
9d72cede | 123 | ), |
70bea8e2 | 124 | 'first_name' => array( |
125 | 'title' => ts('First Name'), | |
126 | ), | |
127 | 'gender_id' => array( | |
128 | 'name' => 'gender_id', | |
129 | 'title' => ts('Gender'), | |
130 | ), | |
131 | 'birth_date' => array( | |
132 | 'name' => 'birth_date', | |
133 | 'title' => ts('Birth Date'), | |
134 | ), | |
135 | 'contact_type' => array( | |
136 | 'title' => ts('Contact Type'), | |
137 | ), | |
138 | 'contact_sub_type' => array( | |
139 | 'title' => ts('Contact Subtype'), | |
140 | ), | |
6a488035 TO |
141 | ), |
142 | ), | |
9d72cede | 143 | 'civicrm_address' => array( |
6a488035 TO |
144 | 'dao' => 'CRM_Core_DAO_Address', |
145 | 'grouping' => 'contact-fields', | |
9d72cede | 146 | 'fields' => array( |
6a488035 TO |
147 | 'street_address' => NULL, |
148 | 'city' => NULL, | |
149 | 'postal_code' => NULL, | |
9d72cede EM |
150 | 'state_province_id' => array( |
151 | 'title' => ts('State/Province'), | |
6a488035 TO |
152 | ), |
153 | ), | |
9d72cede EM |
154 | 'order_bys' => array( |
155 | 'state_province_id' => array('title' => 'State/Province'), | |
6a488035 TO |
156 | 'city' => array('title' => 'City'), |
157 | 'postal_code' => array('title' => 'Postal Code'), | |
158 | ), | |
159 | ), | |
9d72cede | 160 | 'civicrm_country' => array( |
6a488035 | 161 | 'dao' => 'CRM_Core_DAO_Country', |
9d72cede EM |
162 | 'fields' => array( |
163 | 'name' => array('title' => 'Country', 'default' => TRUE), | |
6a488035 | 164 | ), |
9d72cede EM |
165 | 'order_bys' => array( |
166 | 'name' => array('title' => 'Country'), | |
6a488035 TO |
167 | ), |
168 | 'grouping' => 'contact-fields', | |
169 | ), | |
9d72cede | 170 | 'civicrm_email' => array( |
6a488035 | 171 | 'dao' => 'CRM_Core_DAO_Email', |
9d72cede EM |
172 | 'fields' => array( |
173 | 'email' => array( | |
174 | 'title' => ts('Email'), | |
6a488035 TO |
175 | 'no_repeat' => TRUE, |
176 | ), | |
177 | ), | |
178 | 'grouping' => 'contact-fields', | |
9d72cede EM |
179 | 'order_bys' => array( |
180 | 'email' => array( | |
181 | 'title' => ts('Email'), | |
6a488035 TO |
182 | ), |
183 | ), | |
184 | ), | |
9d72cede | 185 | 'civicrm_contribution' => array( |
6a488035 | 186 | 'dao' => 'CRM_Contribute_DAO_Contribution', |
9d72cede EM |
187 | 'fields' => array( |
188 | 'contact_id' => array( | |
6a488035 TO |
189 | 'no_display' => TRUE, |
190 | 'required' => TRUE, | |
191 | ), | |
9d72cede EM |
192 | 'contribution_id' => array( |
193 | 'title' => ts('Contribution'), | |
6a488035 TO |
194 | 'no_repeat' => TRUE, |
195 | 'default' => TRUE, | |
196 | ), | |
197 | 'total_amount' => array('default' => TRUE), | |
9d72cede EM |
198 | 'financial_type_id' => array( |
199 | 'title' => ts('Financial Type'), | |
6a488035 TO |
200 | 'default' => TRUE, |
201 | ), | |
202 | 'trxn_id' => NULL, | |
203 | 'receive_date' => array('default' => TRUE), | |
204 | 'receipt_date' => NULL, | |
9d72cede EM |
205 | 'contribution_status_id' => array( |
206 | 'title' => ts('Contribution Status'), | |
6a488035 TO |
207 | 'default' => TRUE, |
208 | ), | |
209 | 'contribution_source' => NULL, | |
210 | ), | |
211 | ), | |
9d72cede | 212 | 'civicrm_membership' => array( |
6a488035 | 213 | 'dao' => 'CRM_Member_DAO_Membership', |
9d72cede EM |
214 | 'fields' => array( |
215 | 'contact_id' => array( | |
6a488035 TO |
216 | 'no_display' => TRUE, |
217 | 'required' => TRUE, | |
218 | ), | |
9d72cede EM |
219 | 'membership_id' => array( |
220 | 'title' => ts('Membership'), | |
6a488035 TO |
221 | 'no_repeat' => TRUE, |
222 | 'default' => TRUE, | |
223 | ), | |
9d72cede EM |
224 | 'membership_type_id' => array( |
225 | 'title' => ts('Membership Type'), | |
6a488035 TO |
226 | 'default' => TRUE, |
227 | ), | |
228 | 'join_date' => NULL, | |
9d72cede EM |
229 | 'membership_start_date' => array( |
230 | 'title' => ts('Start Date'), | |
6a488035 TO |
231 | 'default' => TRUE, |
232 | ), | |
9d72cede EM |
233 | 'membership_end_date' => array( |
234 | 'title' => ts('End Date'), | |
6a488035 TO |
235 | 'default' => TRUE, |
236 | ), | |
237 | 'membership_status_id' => array( | |
238 | 'name' => 'status_id', | |
239 | 'title' => ts('Membership Status'), | |
240 | 'default' => TRUE, | |
241 | ), | |
242 | 'source' => array('title' => 'Membership Source'), | |
243 | ), | |
244 | ), | |
9d72cede | 245 | 'civicrm_participant' => array( |
6a488035 | 246 | 'dao' => 'CRM_Event_DAO_Participant', |
9d72cede EM |
247 | 'fields' => array( |
248 | 'contact_id' => array( | |
6a488035 TO |
249 | 'no_display' => TRUE, |
250 | 'required' => TRUE, | |
251 | ), | |
9d72cede EM |
252 | 'participant_id' => array( |
253 | 'title' => ts('Participant'), | |
6a488035 TO |
254 | 'no_repeat' => TRUE, |
255 | 'default' => TRUE, | |
256 | ), | |
257 | 'event_id' => array('default' => TRUE), | |
258 | 'participant_status_id' => array( | |
259 | 'name' => 'status_id', | |
260 | 'title' => ts('Participant Status'), | |
261 | 'default' => TRUE, | |
262 | ), | |
9d72cede EM |
263 | 'role_id' => array( |
264 | 'title' => ts('Role'), | |
6a488035 TO |
265 | 'default' => TRUE, |
266 | ), | |
9d72cede EM |
267 | 'participant_register_date' => array( |
268 | 'title' => ts('Register Date'), | |
6a488035 TO |
269 | 'default' => TRUE, |
270 | ), | |
9d72cede EM |
271 | 'fee_level' => array( |
272 | 'title' => ts('Fee Level'), | |
6a488035 TO |
273 | 'default' => TRUE, |
274 | ), | |
9d72cede EM |
275 | 'fee_amount' => array( |
276 | 'title' => ts('Fee Amount'), | |
6a488035 TO |
277 | 'default' => TRUE, |
278 | ), | |
279 | ), | |
280 | ), | |
9d72cede | 281 | 'civicrm_relationship' => array( |
6a488035 | 282 | 'dao' => 'CRM_Contact_DAO_Relationship', |
9d72cede EM |
283 | 'fields' => array( |
284 | 'relationship_id' => array( | |
6a488035 TO |
285 | 'name' => 'id', |
286 | 'title' => ts('Relationship'), | |
287 | 'no_repeat' => TRUE, | |
288 | 'default' => TRUE, | |
289 | ), | |
9d72cede EM |
290 | 'relationship_type_id' => array( |
291 | 'title' => ts('Relationship Type'), | |
6a488035 TO |
292 | 'default' => TRUE, |
293 | ), | |
9d72cede EM |
294 | 'contact_id_b' => array( |
295 | 'title' => ts('Relationship With'), | |
6a488035 TO |
296 | 'default' => TRUE, |
297 | ), | |
9d72cede | 298 | 'start_date' => array( |
6a488035 TO |
299 | 'title' => 'Start Date ', |
300 | 'type' => CRM_Report_Form::OP_DATE, | |
301 | ), | |
9d72cede | 302 | 'end_date' => array( |
6a488035 TO |
303 | 'title' => 'End Date ', |
304 | 'type' => CRM_Report_Form::OP_DATE, | |
305 | ), | |
306 | ), | |
307 | ), | |
9d72cede | 308 | 'civicrm_activity' => array( |
6a488035 | 309 | 'dao' => 'CRM_Activity_DAO_Activity', |
9d72cede EM |
310 | 'fields' => array( |
311 | 'id' => array( | |
312 | 'title' => ts('Activity'), | |
6a488035 TO |
313 | 'no_repeat' => TRUE, |
314 | 'default' => TRUE, | |
315 | ), | |
9d72cede EM |
316 | 'activity_type_id' => array( |
317 | 'title' => ts('Activity Type'), | |
6a488035 TO |
318 | 'default' => TRUE, |
319 | ), | |
9d72cede EM |
320 | 'subject' => array( |
321 | 'title' => ts('Subject'), | |
6a488035 TO |
322 | 'default' => TRUE, |
323 | ), | |
9d72cede EM |
324 | 'activity_date_time' => array( |
325 | 'title' => ts('Activity Date'), | |
6a488035 TO |
326 | 'default' => TRUE, |
327 | ), | |
9d72cede | 328 | 'activity_status_id' => array( |
6a488035 TO |
329 | 'name' => 'status_id', |
330 | 'title' => ts('Activity Status'), | |
331 | 'default' => TRUE, | |
332 | ), | |
333 | ), | |
334 | 'grouping' => 'activity-fields', | |
335 | ), | |
9d72cede | 336 | 'civicrm_activity_target' => array( |
4e3d3cfc | 337 | 'dao' => 'CRM_Activity_DAO_ActivityContact', |
9d72cede EM |
338 | 'fields' => array( |
339 | 'target_contact_id' => array( | |
340 | 'title' => ts('With Contact'), | |
ecaec004 | 341 | 'name' => 'contact_id', |
6a488035 TO |
342 | 'default' => TRUE, |
343 | ), | |
344 | ), | |
345 | 'grouping' => 'activity-fields', | |
346 | ), | |
9d72cede | 347 | 'civicrm_activity_assignment' => array( |
4e3d3cfc | 348 | 'dao' => 'CRM_Activity_DAO_ActivityContact', |
9d72cede EM |
349 | 'fields' => array( |
350 | 'assignee_contact_id' => array( | |
351 | 'title' => ts('Assigned to'), | |
ecaec004 | 352 | 'name' => 'contact_id', |
6a488035 TO |
353 | 'default' => TRUE, |
354 | ), | |
355 | ), | |
356 | 'grouping' => 'activity-fields', | |
357 | ), | |
9d72cede EM |
358 | 'civicrm_activity_source' => array( |
359 | 'dao' => 'CRM_Activity_DAO_ActivityContact', | |
360 | 'fields' => array( | |
361 | 'source_contact_id' => array( | |
362 | 'title' => ts('Added By'), | |
363 | 'name' => 'contact_id', | |
364 | 'default' => TRUE, | |
ecaec004 | 365 | ), |
9d72cede | 366 | ), |
ecaec004 | 367 | 'grouping' => 'activity-fields', |
8ef12e64 | 368 | ), |
9d72cede | 369 | 'civicrm_phone' => array( |
6a488035 | 370 | 'dao' => 'CRM_Core_DAO_Phone', |
9d72cede | 371 | 'fields' => array( |
74cf4551 | 372 | 'phone' => NULL, |
9d72cede | 373 | 'phone_ext' => array( |
21dfd5f5 TO |
374 | 'title' => ts('Phone Extension'), |
375 | ), | |
476c4ae5 | 376 | ), |
6a488035 TO |
377 | 'grouping' => 'contact-fields', |
378 | ), | |
379 | ); | |
16e2e80c | 380 | $this->_groupFilter = TRUE; |
6a488035 TO |
381 | $this->_tagFilter = TRUE; |
382 | parent::__construct(); | |
383 | } | |
384 | ||
00be9182 | 385 | public function preProcess() { |
6a488035 TO |
386 | $this->_csvSupported = FALSE; |
387 | parent::preProcess(); | |
388 | } | |
389 | ||
00be9182 | 390 | public function select() { |
6a488035 TO |
391 | $select = array(); |
392 | $this->_columnHeaders = array(); | |
9d72cede EM |
393 | $this->_component = array( |
394 | 'contribution_civireport', | |
395 | 'membership_civireport', | |
396 | 'participant_civireport', | |
397 | 'relationship_civireport', | |
21dfd5f5 | 398 | 'activity_civireport', |
9d72cede | 399 | ); |
6a488035 TO |
400 | foreach ($this->_columns as $tableName => $table) { |
401 | if (array_key_exists('fields', $table)) { | |
402 | foreach ($table['fields'] as $fieldName => $field) { | |
9d72cede EM |
403 | if (!empty($field['required']) || |
404 | !empty($this->_params['fields'][$fieldName]) | |
405 | ) { | |
6a488035 TO |
406 | //isolate the select clause compoenent wise |
407 | if (in_array($table['alias'], $this->_component)) { | |
408 | $select[$table['alias']][] = "{$field['dbAlias']} as {$tableName}_{$fieldName}"; | |
409 | $this->_columnHeadersComponent[$table['alias']]["{$tableName}_{$fieldName}"]['type'] = CRM_Utils_Array::value('type', $field); | |
410 | $this->_columnHeadersComponent[$table['alias']]["{$tableName}_{$fieldName}"]['title'] = CRM_Utils_Array::value('title', $field); | |
411 | } | |
9d72cede EM |
412 | elseif ($table['alias'] == |
413 | $this->_aliases['civicrm_activity_target'] || | |
414 | $table['alias'] == | |
415 | $this->_aliases['civicrm_activity_assignment'] || | |
ecaec004 | 416 | $table['alias'] == $this->_aliases['civicrm_activity_source'] |
6a488035 | 417 | ) { |
9d72cede EM |
418 | if ($table['alias'] == $this->_aliases['civicrm_activity_target'] |
419 | ) { | |
ecaec004 RN |
420 | $addContactId = 'civicrm_activity_target.contact_id as target_contact_id'; |
421 | } | |
9d72cede EM |
422 | elseif ($table['alias'] == |
423 | $this->_aliases['civicrm_activity_source'] | |
424 | ) { | |
ecaec004 | 425 | $addContactId = 'civicrm_activity_source.contact_id'; |
6a488035 TO |
426 | } |
427 | else { | |
ecaec004 | 428 | $addContactId = 'civicrm_activity_assignment.contact_id as assignee_contact_id'; |
6a488035 | 429 | } |
4e3d3cfc | 430 | |
6a488035 | 431 | $tableName = $table['alias']; |
4e3d3cfc | 432 | $select['activity_civireport'][] = "$tableName.display_name as {$tableName}_{$fieldName}, $addContactId "; |
6a488035 TO |
433 | $this->_columnHeadersComponent['activity_civireport']["{$tableName}_{$fieldName}"]['type'] = CRM_Utils_Array::value('type', $field); |
434 | $this->_columnHeadersComponent['activity_civireport']["{$tableName}_{$fieldName}"]['title'] = CRM_Utils_Array::value('title', $field); | |
435 | } | |
436 | else { | |
437 | $select[] = "{$field['dbAlias']} as {$tableName}_{$fieldName}"; | |
438 | $this->_columnHeaders["{$tableName}_{$fieldName}"]['type'] = CRM_Utils_Array::value('type', $field); | |
439 | $this->_columnHeaders["{$tableName}_{$fieldName}"]['title'] = $field['title']; | |
440 | } | |
441 | } | |
442 | } | |
443 | } | |
444 | } | |
445 | ||
446 | foreach ($this->_component as $val) { | |
a7488080 | 447 | if (!empty($select[$val])) { |
ae5ffbb7 | 448 | $this->_selectComponent[$val] = "SELECT " . implode(', ', $select[$val]) . " "; |
6a488035 TO |
449 | unset($select[$val]); |
450 | } | |
451 | } | |
452 | ||
453 | $this->_select = "SELECT " . implode(', ', $select) . " "; | |
454 | } | |
455 | ||
74cf4551 EM |
456 | /** |
457 | * @param $fields | |
458 | * @param $files | |
459 | * @param $self | |
460 | * | |
461 | * @return array | |
462 | */ | |
00be9182 | 463 | public static function formRule($fields, $files, $self) { |
6a488035 TO |
464 | $errors = array(); |
465 | return $errors; | |
466 | } | |
467 | ||
00be9182 | 468 | public function from() { |
6a488035 TO |
469 | $group = " "; |
470 | $this->_from = " | |
471 | FROM civicrm_contact {$this->_aliases['civicrm_contact']} {$this->_aclFrom}"; | |
472 | ||
9d72cede EM |
473 | if ($this->isTableSelected('civicrm_country') || |
474 | $this->isTableSelected('civicrm_address') | |
475 | ) { | |
6a488035 TO |
476 | $this->_from .= " |
477 | LEFT JOIN civicrm_address {$this->_aliases['civicrm_address']} | |
478 | ON ({$this->_aliases['civicrm_contact']}.id = {$this->_aliases['civicrm_address']}.contact_id AND | |
479 | {$this->_aliases['civicrm_address']}.is_primary = 1 ) "; | |
480 | } | |
481 | ||
482 | if ($this->isTableSelected('civicrm_email')) { | |
483 | $this->_from .= " | |
484 | LEFT JOIN civicrm_email {$this->_aliases['civicrm_email']} | |
485 | ON ({$this->_aliases['civicrm_contact']}.id = {$this->_aliases['civicrm_email']}.contact_id AND | |
486 | {$this->_aliases['civicrm_email']}.is_primary = 1) "; | |
487 | } | |
488 | ||
489 | if ($this->isTableSelected('civicrm_phone')) { | |
490 | $this->_from .= " | |
491 | LEFT JOIN civicrm_phone {$this->_aliases['civicrm_phone']} | |
492 | ON {$this->_aliases['civicrm_contact']}.id = {$this->_aliases['civicrm_phone']}.contact_id AND | |
493 | {$this->_aliases['civicrm_phone']}.is_primary = 1 "; | |
494 | } | |
495 | ||
496 | if ($this->isTableSelected('civicrm_country')) { | |
497 | $this->_from .= " | |
498 | LEFT JOIN civicrm_country {$this->_aliases['civicrm_country']} | |
499 | ON {$this->_aliases['civicrm_address']}.country_id = {$this->_aliases['civicrm_country']}.id AND | |
500 | {$this->_aliases['civicrm_address']}.is_primary = 1 "; | |
501 | } | |
502 | ||
503 | $this->_from .= "{$group}"; | |
504 | ||
505 | foreach ($this->_component as $val) { | |
a7488080 | 506 | if (!empty($this->_selectComponent['contribution_civireport'])) { |
6a488035 TO |
507 | $this->_formComponent['contribution_civireport'] = " FROM |
508 | civicrm_contact {$this->_aliases['civicrm_contact']} | |
509 | INNER JOIN civicrm_contribution {$this->_aliases['civicrm_contribution']} | |
510 | ON {$this->_aliases['civicrm_contact']}.id = {$this->_aliases['civicrm_contribution']}.contact_id | |
511 | {$group} | |
512 | "; | |
513 | } | |
a7488080 | 514 | if (!empty($this->_selectComponent['membership_civireport'])) { |
6a488035 TO |
515 | $this->_formComponent['membership_civireport'] = " FROM |
516 | civicrm_contact {$this->_aliases['civicrm_contact']} | |
517 | INNER JOIN civicrm_membership {$this->_aliases['civicrm_membership']} | |
518 | ON {$this->_aliases['civicrm_contact']}.id = {$this->_aliases['civicrm_membership']}.contact_id | |
519 | {$group} "; | |
520 | } | |
a7488080 | 521 | if (!empty($this->_selectComponent['participant_civireport'])) { |
6a488035 TO |
522 | $this->_formComponent['participant_civireport'] = " FROM |
523 | civicrm_contact {$this->_aliases['civicrm_contact']} | |
524 | INNER JOIN civicrm_participant {$this->_aliases['civicrm_participant']} | |
525 | ON {$this->_aliases['civicrm_contact']}.id = {$this->_aliases['civicrm_participant']}.contact_id | |
526 | {$group} "; | |
527 | } | |
528 | ||
a7488080 | 529 | if (!empty($this->_selectComponent['activity_civireport'])) { |
e7e657f0 | 530 | $activityContacts = CRM_Core_OptionGroup::values('activity_contacts', FALSE, FALSE, FALSE, NULL, 'name'); |
9e74e3ce | 531 | $assigneeID = CRM_Utils_Array::key('Activity Assignees', $activityContacts); |
532 | $targetID = CRM_Utils_Array::key('Activity Targets', $activityContacts); | |
ecaec004 | 533 | $sourceID = CRM_Utils_Array::key('Activity Source', $activityContacts); |
f813f78e | 534 | |
6a488035 TO |
535 | $this->_formComponent['activity_civireport'] = "FROM |
536 | civicrm_activity {$this->_aliases['civicrm_activity']} | |
4e3d3cfc | 537 | LEFT JOIN civicrm_activity_contact civicrm_activity_target ON |
538 | {$this->_aliases['civicrm_activity']}.id = civicrm_activity_target.activity_id AND | |
9e74e3ce | 539 | civicrm_activity_target.record_type_id = {$targetID} |
4e3d3cfc | 540 | LEFT JOIN civicrm_activity_contact civicrm_activity_assignment ON |
ecaec004 RN |
541 | {$this->_aliases['civicrm_activity']}.id = civicrm_activity_assignment.activity_id AND civicrm_activity_assignment.record_type_id = {$assigneeID} |
542 | LEFT JOIN civicrm_activity_contact civicrm_activity_source | |
543 | ON {$this->_aliases['civicrm_activity']}.id = civicrm_activity_source.activity_id AND | |
8ef12e64 | 544 | civicrm_activity_source.record_type_id = {$sourceID} |
4e3d3cfc | 545 | LEFT JOIN civicrm_contact {$this->_aliases['civicrm_activity_target']} ON |
546 | civicrm_activity_target.contact_id = {$this->_aliases['civicrm_activity_target']}.id | |
6a488035 TO |
547 | |
548 | LEFT JOIN civicrm_contact {$this->_aliases['civicrm_activity_assignment']} ON | |
4e3d3cfc | 549 | civicrm_activity_assignment.contact_id = {$this->_aliases['civicrm_activity_assignment']}.id |
ecaec004 RN |
550 | LEFT JOIN civicrm_contact {$this->_aliases['civicrm_activity_source']} ON |
551 | civicrm_activity_source.contact_id = {$this->_aliases['civicrm_activity_source']}.id | |
6a488035 TO |
552 | LEFT JOIN civicrm_option_value ON |
553 | ( {$this->_aliases['civicrm_activity']}.activity_type_id = civicrm_option_value.value ) | |
554 | LEFT JOIN civicrm_option_group ON | |
555 | civicrm_option_group.id = civicrm_option_value.option_group_id | |
556 | LEFT JOIN civicrm_case_activity ON | |
557 | civicrm_case_activity.activity_id = {$this->_aliases['civicrm_activity']}.id | |
558 | LEFT JOIN civicrm_case ON | |
559 | civicrm_case_activity.case_id = civicrm_case.id | |
560 | LEFT JOIN civicrm_case_contact ON | |
561 | civicrm_case_contact.case_id = civicrm_case.id "; | |
562 | } | |
563 | ||
a7488080 | 564 | if (!empty($this->_selectComponent['relationship_civireport'])) { |
6a488035 TO |
565 | $this->_formComponent['relationship_civireport'] = "FROM |
566 | civicrm_relationship {$this->_aliases['civicrm_relationship']} | |
567 | ||
568 | LEFT JOIN civicrm_contact {$this->_aliases['civicrm_contact']} ON | |
569 | {$this->_aliases['civicrm_contact']}.id = {$this->_aliases['civicrm_relationship']}.contact_id_b | |
570 | LEFT JOIN civicrm_contact contact_a ON | |
571 | contact_a.id = {$this->_aliases['civicrm_relationship']}.contact_id_a "; | |
572 | } | |
573 | } | |
574 | } | |
575 | ||
00be9182 | 576 | public function where() { |
6a488035 TO |
577 | $clauses = array(); |
578 | ||
579 | foreach ($this->_columns as $tableName => $table) { | |
580 | if (array_key_exists('filters', $table)) { | |
581 | foreach ($table['filters'] as $fieldName => $field) { | |
582 | $clause = NULL; | |
84178120 | 583 | if (CRM_Utils_Array::value('operatorType', $field) & CRM_Report_Form::OP_DATE |
9d72cede | 584 | ) { |
f98dd91b | 585 | $relative = CRM_Utils_Array::value("{$fieldName}_relative", $this->_params); |
9d72cede EM |
586 | $from = CRM_Utils_Array::value("{$fieldName}_from", $this->_params); |
587 | $to = CRM_Utils_Array::value("{$fieldName}_to", $this->_params); | |
f98dd91b BS |
588 | |
589 | $clause = $this->dateClause($field['dbAlias'], $relative, $from, $to); | |
590 | } | |
591 | else { | |
592 | $op = CRM_Utils_Array::value("{$fieldName}_op", $this->_params); | |
6a488035 TO |
593 | $clause = $this->whereClause($field, |
594 | $op, | |
595 | CRM_Utils_Array::value("{$fieldName}_value", $this->_params), | |
596 | CRM_Utils_Array::value("{$fieldName}_min", $this->_params), | |
597 | CRM_Utils_Array::value("{$fieldName}_max", $this->_params) | |
598 | ); | |
599 | } | |
600 | if (!empty($clause)) { | |
601 | $clauses[] = $clause; | |
602 | } | |
603 | } | |
604 | } | |
605 | } | |
606 | ||
607 | if (empty($clauses)) { | |
608 | $this->_where = "WHERE ( 1 ) "; | |
609 | } | |
610 | else { | |
611 | $this->_where = "WHERE " . implode(' AND ', $clauses); | |
612 | } | |
613 | ||
614 | if ($this->_aclWhere) { | |
615 | $this->_where .= " AND {$this->_aclWhere} "; | |
616 | } | |
617 | ||
618 | $this->_where .= " GROUP BY {$this->_aliases['civicrm_contact']}.id "; | |
619 | } | |
620 | ||
74cf4551 EM |
621 | /** |
622 | * @return array | |
623 | */ | |
00be9182 | 624 | public function clauseComponent() { |
6a488035 | 625 | $selectedContacts = implode(',', $this->_contactSelected); |
9d72cede EM |
626 | $contribution = $membership = $participant = NULL; |
627 | $eligibleResult = $rows = $tempArray = array(); | |
6a488035 | 628 | foreach ($this->_component as $val) { |
9d72cede EM |
629 | if (!empty($this->_selectComponent[$val]) && |
630 | ($val != 'activity_civireport' && $val != 'relationship_civireport') | |
631 | ) { | |
6a488035 TO |
632 | $sql = "{$this->_selectComponent[$val]} {$this->_formComponent[$val]} |
633 | WHERE {$this->_aliases['civicrm_contact']}.id IN ( $selectedContacts ) | |
634 | GROUP BY {$this->_aliases['civicrm_contact']}.id,{$val}.id "; | |
635 | ||
636 | $dao = CRM_Core_DAO::executeQuery($sql); | |
637 | while ($dao->fetch()) { | |
638 | $countRecord = 0; | |
639 | $eligibleResult[$val] = $val; | |
4e3d3cfc | 640 | $CC = 'civicrm_' . substr_replace($val, '', -11, 11) . '_contact_id'; |
6a488035 TO |
641 | $row = array(); |
642 | foreach ($this->_columnHeadersComponent[$val] as $key => $value) { | |
643 | $countRecord++; | |
644 | $row[$key] = $dao->$key; | |
645 | } | |
646 | ||
647 | //if record exist for component(except contact_id) | |
648 | //since contact_id is selected for every component | |
649 | if ($countRecord > 1) { | |
650 | $rows[$dao->$CC][$val][] = $row; | |
651 | } | |
652 | $tempArray[$dao->$CC] = $dao->$CC; | |
653 | } | |
654 | } | |
655 | } | |
656 | ||
a7488080 | 657 | if (!empty($this->_selectComponent['relationship_civireport'])) { |
6a488035 TO |
658 | |
659 | $relTypes = CRM_Contact_BAO_Relationship::getContactRelationshipType(NULL, 'null', NULL, NULL, TRUE); | |
660 | ||
661 | $val = 'relationship_civireport'; | |
662 | $eligibleResult[$val] = $val; | |
663 | $sql = "{$this->_selectComponent[$val]},{$this->_aliases['civicrm_contact']}.display_name as contact_b_name, contact_a.id as contact_a_id , contact_a.display_name as contact_a_name {$this->_formComponent[$val]} | |
664 | WHERE ({$this->_aliases['civicrm_contact']}.id IN ( $selectedContacts ) | |
665 | OR | |
666 | contact_a.id IN ( $selectedContacts ) ) AND | |
667 | {$this->_aliases['civicrm_relationship']}.is_active = 1 AND | |
668 | contact_a.is_deleted = 0 AND | |
669 | {$this->_aliases['civicrm_contact']}.is_deleted = 0 | |
670 | GROUP BY {$this->_aliases['civicrm_relationship']}.id"; | |
671 | ||
672 | $dao = CRM_Core_DAO::executeQuery($sql); | |
673 | while ($dao->fetch()) { | |
674 | foreach ($this->_columnHeadersComponent[$val] as $key => $value) { | |
675 | if ($key == 'civicrm_relationship_contact_id_b') { | |
676 | $row[$key] = $dao->contact_b_name; | |
677 | continue; | |
678 | } | |
679 | ||
680 | $row[$key] = $dao->$key; | |
681 | } | |
682 | ||
9d72cede EM |
683 | $relTitle = "" . $dao->civicrm_relationship_relationship_type_id . |
684 | '_a_b'; | |
6a488035 TO |
685 | $row['civicrm_relationship_relationship_type_id'] = $relTypes[$relTitle]; |
686 | ||
687 | $rows[$dao->contact_a_id][$val][] = $row; | |
688 | ||
689 | $row['civicrm_relationship_contact_id_b'] = $dao->contact_a_name; | |
9d72cede EM |
690 | $relTitle = "" . $dao->civicrm_relationship_relationship_type_id . |
691 | '_b_a'; | |
6a488035 TO |
692 | if (isset($relTypes[$relTitle])) { |
693 | $row['civicrm_relationship_relationship_type_id'] = $relTypes[$relTitle]; | |
694 | } | |
695 | $rows[$dao->civicrm_relationship_contact_id_b][$val][] = $row; | |
696 | } | |
697 | } | |
698 | ||
a7488080 | 699 | if (!empty($this->_selectComponent['activity_civireport'])) { |
6a488035 TO |
700 | |
701 | $componentClause = "civicrm_option_value.component_id IS NULL"; | |
9d72cede EM |
702 | $componentsIn = NULL; |
703 | $compInfo = CRM_Core_Component::getEnabledComponents(); | |
6a488035 TO |
704 | foreach ($compInfo as $compObj) { |
705 | if ($compObj->info['showActivitiesInCore']) { | |
9d72cede EM |
706 | $componentsIn = $componentsIn ? ($componentsIn . ', ' . |
707 | $compObj->componentID) : $compObj->componentID; | |
6a488035 TO |
708 | } |
709 | } | |
710 | if ($componentsIn) { | |
711 | $componentClause = "( $componentClause OR | |
712 | civicrm_option_value.component_id IN ($componentsIn) )"; | |
713 | } | |
714 | ||
715 | $val = 'activity_civireport'; | |
716 | $eligibleResult[$val] = $val; | |
717 | $sql = "{$this->_selectComponent[$val]} , | |
ecaec004 | 718 | {$this->_aliases['civicrm_activity_source']}.display_name as added_by {$this->_formComponent[$val]} |
6a488035 | 719 | |
ecaec004 | 720 | WHERE ( civicrm_activity_source.contact_id IN ($selectedContacts) OR |
4e3d3cfc | 721 | civicrm_activity_target.contact_id IN ($selectedContacts) OR |
722 | civicrm_activity_assignment.contact_id IN ($selectedContacts) OR | |
6a488035 | 723 | civicrm_case_contact.contact_id IN ($selectedContacts) ) AND |
4e3d3cfc | 724 | civicrm_option_group.name = 'activity_type' AND |
725 | {$this->_aliases['civicrm_activity']}.is_test = 0 AND | |
726 | ($componentClause) | |
6a488035 TO |
727 | |
728 | GROUP BY {$this->_aliases['civicrm_activity']}.id | |
729 | ||
730 | ORDER BY {$this->_aliases['civicrm_activity']}.activity_date_time desc "; | |
731 | ||
732 | $dao = CRM_Core_DAO::executeQuery($sql); | |
733 | while ($dao->fetch()) { | |
734 | foreach ($this->_columnHeadersComponent[$val] as $key => $value) { | |
735 | if ($key == 'civicrm_activity_source_contact_id') { | |
736 | $row[$key] = $dao->added_by; | |
737 | continue; | |
738 | } | |
739 | $row[$key] = $dao->$key; | |
740 | } | |
741 | ||
742 | if (isset($dao->civicrm_activity_source_contact_id)) { | |
743 | $rows[$dao->civicrm_activity_source_contact_id][$val][] = $row; | |
744 | } | |
745 | if (isset($dao->target_contact_id)) { | |
746 | $rows[$dao->target_contact_id][$val][] = $row; | |
747 | } | |
748 | if (isset($dao->assignee_contact_id)) { | |
749 | $rows[$dao->assignee_contact_id][$val][] = $row; | |
750 | } | |
751 | } | |
752 | ||
753 | //unset the component header if data is not present | |
754 | foreach ($this->_component as $val) { | |
755 | if (!in_array($val, $eligibleResult)) { | |
756 | ||
757 | unset($this->_columnHeadersComponent[$val]); | |
758 | } | |
759 | } | |
760 | } | |
761 | ||
762 | return $rows; | |
763 | } | |
764 | ||
74cf4551 EM |
765 | /** |
766 | * @param $rows | |
767 | * | |
768 | * @return array | |
769 | */ | |
00be9182 | 770 | public function statistics(&$rows) { |
6a488035 TO |
771 | $statistics = array(); |
772 | ||
773 | $count = count($rows); | |
774 | if ($this->_rollup && ($this->_rollup != '')) { | |
775 | $count++; | |
776 | } | |
777 | ||
778 | $this->countStat($statistics, $count); | |
779 | $this->filterStat($statistics); | |
780 | ||
781 | return $statistics; | |
782 | } | |
783 | ||
74cf4551 | 784 | /** |
4f1f1f2a | 785 | * Override to set limit is 10 |
74cf4551 EM |
786 | * @param int $rowCount |
787 | */ | |
00be9182 | 788 | public function limit($rowCount = self::ROW_COUNT_LIMIT) { |
6a488035 TO |
789 | parent::limit($rowCount); |
790 | } | |
791 | ||
74cf4551 | 792 | /** |
4f1f1f2a | 793 | * Override to set pager with limit is 10 |
74cf4551 EM |
794 | * @param int $rowCount |
795 | */ | |
00be9182 | 796 | public function setPager($rowCount = self::ROW_COUNT_LIMIT) { |
6a488035 TO |
797 | parent::setPager($rowCount); |
798 | } | |
799 | ||
00be9182 | 800 | public function postProcess() { |
6a488035 TO |
801 | |
802 | $this->beginPostProcess(); | |
803 | ||
804 | // get the acl clauses built before we assemble the query | |
805 | $this->buildACLClause($this->_aliases['civicrm_contact']); | |
806 | ||
807 | $sql = $this->buildQuery(TRUE); | |
808 | ||
809 | $rows = $graphRows = $this->_contactSelected = array(); | |
810 | $this->buildRows($sql, $rows); | |
811 | foreach ($rows as $key => $val) { | |
812 | $rows[$key]['contactID'] = $val['civicrm_contact_id']; | |
813 | $this->_contactSelected[] = $val['civicrm_contact_id']; | |
814 | } | |
815 | ||
816 | $this->formatDisplay($rows); | |
817 | ||
818 | if (!empty($this->_contactSelected)) { | |
819 | $componentRows = $this->clauseComponent(); | |
820 | $this->alterComponentDisplay($componentRows); | |
821 | ||
822 | //unset Conmponent id and contact id from display | |
823 | foreach ($this->_columnHeadersComponent as $componentTitle => $headers) { | |
ae5ffbb7 | 824 | $id_header = 'civicrm_' . substr_replace($componentTitle, '', -11, 11) . '_' . |
9d72cede | 825 | substr_replace($componentTitle, '', -11, 11) . '_id'; |
ae5ffbb7 | 826 | $contact_header = 'civicrm_' . substr_replace($componentTitle, '', -11, 11) . |
9d72cede | 827 | '_contact_id'; |
6a488035 | 828 | if ($componentTitle == 'activity_civireport') { |
ae5ffbb7 | 829 | $id_header = 'civicrm_' . substr_replace($componentTitle, '', -11, 11) . '_id'; |
6a488035 TO |
830 | } |
831 | ||
832 | unset($this->_columnHeadersComponent[$componentTitle][$id_header]); | |
833 | unset($this->_columnHeadersComponent[$componentTitle][$contact_header]); | |
834 | } | |
835 | ||
836 | $this->assign_by_ref('columnHeadersComponent', $this->_columnHeadersComponent); | |
837 | $this->assign_by_ref('componentRows', $componentRows); | |
838 | } | |
839 | ||
840 | $this->doTemplateAssignment($rows); | |
841 | $this->endPostProcess(); | |
842 | } | |
843 | ||
74cf4551 | 844 | /** |
ced9bfed EM |
845 | * Alter display of rows. |
846 | * | |
847 | * Iterate through the rows retrieved via SQL and make changes for display purposes, | |
848 | * such as rendering contacts as links. | |
849 | * | |
850 | * @param array $rows | |
851 | * Rows generated by SQL, with an array for each row. | |
74cf4551 | 852 | */ |
00be9182 | 853 | public function alterDisplay(&$rows) { |
6a488035 TO |
854 | |
855 | $entryFound = FALSE; | |
856 | ||
857 | foreach ($rows as $rowNum => $row) { | |
858 | // make count columns point to detail report | |
859 | ||
860 | // change contact name with link | |
861 | if (array_key_exists('civicrm_contact_sort_name', $row) && | |
862 | array_key_exists('civicrm_contact_id', $row) | |
863 | ) { | |
864 | ||
4e3d3cfc | 865 | $url = CRM_Utils_System::url('civicrm/contact/view', |
6a488035 TO |
866 | 'reset=1&cid=' . $row['civicrm_contact_id'], |
867 | $this->_absoluteUrl | |
868 | ); | |
869 | $rows[$rowNum]['civicrm_contact_sort_name_link'] = $url; | |
4e3d3cfc | 870 | $rows[$rowNum]['civicrm_contact_sort_name_hover'] = ts('View Contact Summary for this Contact'); |
6a488035 TO |
871 | $entryFound = TRUE; |
872 | } | |
873 | ||
70bea8e2 | 874 | //handle gender |
875 | if (array_key_exists('civicrm_contact_gender_id', $row)) { | |
876 | if ($value = $row['civicrm_contact_gender_id']) { | |
877 | $gender = CRM_Core_PseudoConstant::get('CRM_Contact_DAO_Contact', 'gender_id'); | |
878 | $rows[$rowNum]['civicrm_contact_gender_id'] = $gender[$value]; | |
879 | } | |
880 | $entryFound = TRUE; | |
881 | } | |
882 | ||
883 | // display birthday in the configured custom format | |
884 | if (array_key_exists('civicrm_contact_birth_date', $row)) { | |
885 | $birthDate = $row['civicrm_contact_birth_date']; | |
886 | if ($birthDate) { | |
887 | $rows[$rowNum]['civicrm_contact_birth_date'] = CRM_Utils_Date::customFormat($birthDate, '%Y%m%d'); | |
888 | } | |
889 | $entryFound = TRUE; | |
890 | } | |
891 | ||
6a488035 TO |
892 | if (array_key_exists('civicrm_address_state_province_id', $row)) { |
893 | if ($value = $row['civicrm_address_state_province_id']) { | |
894 | $rows[$rowNum]['civicrm_address_state_province_id'] = CRM_Core_PseudoConstant::stateProvince($value, FALSE); | |
895 | } | |
896 | $entryFound = TRUE; | |
897 | } | |
898 | ||
6a488035 TO |
899 | // skip looking further in rows, if first row itself doesn't |
900 | // have the column we need | |
901 | if (!$entryFound) { | |
902 | break; | |
903 | } | |
904 | } | |
905 | } | |
906 | ||
74cf4551 EM |
907 | /** |
908 | * @param $componentRows | |
909 | */ | |
00be9182 | 910 | public function alterComponentDisplay(&$componentRows) { |
6a488035 TO |
911 | // custom code to alter rows |
912 | $activityTypes = CRM_Core_PseudoConstant::activityType(TRUE, TRUE, FALSE, 'label', TRUE); | |
913 | $activityStatus = CRM_Core_PseudoConstant::activityStatus(); | |
914 | ||
915 | $entryFound = FALSE; | |
916 | foreach ($componentRows as $contactID => $components) { | |
917 | foreach ($components as $component => $rows) { | |
918 | foreach ($rows as $rowNum => $row) { | |
919 | // handle contribution | |
920 | if ($component == 'contribution_civireport') { | |
b914f4e8 | 921 | if ($val = CRM_Utils_Array::value('civicrm_contribution_financial_type_id', $row)) { |
ae5ffbb7 | 922 | $componentRows[$contactID][$component][$rowNum]['civicrm_contribution_financial_type_id'] = CRM_Contribute_PseudoConstant::financialType($val, FALSE); |
6a488035 TO |
923 | } |
924 | ||
925 | if ($val = CRM_Utils_Array::value('civicrm_contribution_contribution_status_id', $row)) { | |
926 | $componentRows[$contactID][$component][$rowNum]['civicrm_contribution_contribution_status_id'] = CRM_Contribute_PseudoConstant::contributionStatus($val); | |
927 | } | |
928 | $entryFound = TRUE; | |
929 | } | |
930 | ||
931 | if ($component == 'membership_civireport') { | |
932 | if ($val = CRM_Utils_Array::value('civicrm_membership_membership_type_id', $row)) { | |
933 | $componentRows[$contactID][$component][$rowNum]['civicrm_membership_membership_type_id'] = CRM_Member_PseudoConstant::membershipType($val, FALSE); | |
934 | } | |
935 | ||
936 | if ($val = CRM_Utils_Array::value('civicrm_membership_status_id', $row)) { | |
937 | $componentRows[$contactID][$component][$rowNum]['civicrm_membership_status_id'] = CRM_Member_PseudoConstant::membershipStatus($val, FALSE); | |
938 | } | |
939 | $entryFound = TRUE; | |
940 | } | |
941 | ||
942 | if ($component == 'participant_civireport') { | |
943 | if ($val = CRM_Utils_Array::value('civicrm_participant_event_id', $row)) { | |
944 | $componentRows[$contactID][$component][$rowNum]['civicrm_participant_event_id'] = CRM_Event_PseudoConstant::event($val, FALSE); | |
945 | $url = CRM_Report_Utils_Report::getNextUrl('event/income', | |
946 | 'reset=1&force=1&id_op=in&id_value=' . $val, | |
947 | $this->_absoluteUrl, $this->_id | |
948 | ); | |
949 | $componentRows[$contactID][$component][$rowNum]['civicrm_participant_event_id_link'] = $url; | |
4e3d3cfc | 950 | $componentRows[$contactID][$component][$rowNum]['civicrm_participant_event_id_hover'] = ts('View Event Income details for this Event.'); |
6a488035 TO |
951 | $entryFound = TRUE; |
952 | } | |
953 | ||
954 | if ($val = CRM_Utils_Array::value('civicrm_participant_participant_status_id', $row)) { | |
955 | $componentRows[$contactID][$component][$rowNum]['civicrm_participant_participant_status_id'] = CRM_Event_PseudoConstant::participantStatus($val, FALSE); | |
956 | } | |
957 | if ($val = CRM_Utils_Array::value('civicrm_participant_role_id', $row)) { | |
958 | $roles = explode(CRM_Core_DAO::VALUE_SEPARATOR, $val); | |
959 | $value = array(); | |
960 | foreach ($roles as $role) { | |
961 | $value[$role] = CRM_Event_PseudoConstant::participantRole($role, FALSE); | |
962 | } | |
963 | $componentRows[$contactID][$component][$rowNum]['civicrm_participant_role_id'] = implode(', ', $value); | |
964 | } | |
965 | ||
966 | $entryFound = TRUE; | |
967 | } | |
968 | ||
969 | if ($component == 'activity_civireport') { | |
970 | if ($val = CRM_Utils_Array::value('civicrm_activity_activity_type_id', $row)) { | |
971 | $componentRows[$contactID][$component][$rowNum]['civicrm_activity_activity_type_id'] = $activityTypes[$val]; | |
972 | } | |
973 | if ($val = CRM_Utils_Array::value('civicrm_activity_activity_status_id', $row)) { | |
974 | $componentRows[$contactID][$component][$rowNum]['civicrm_activity_activity_status_id'] = $activityStatus[$val]; | |
975 | } | |
976 | ||
977 | $entryFound = TRUE; | |
978 | } | |
979 | if ($component == 'membership_civireport') { | |
980 | if ($val = CRM_Utils_Array::value('civicrm_membership_membership_status_id', $row)) { | |
981 | $componentRows[$contactID][$component][$rowNum]['civicrm_membership_membership_status_id'] = CRM_Member_PseudoConstant::membershipStatus($val); | |
982 | } | |
983 | $entryFound = TRUE; | |
984 | } | |
985 | ||
986 | // skip looking further in rows, if first row itself doesn't | |
987 | // have the column we need | |
988 | if (!$entryFound) { | |
989 | break; | |
990 | } | |
991 | } | |
992 | } | |
993 | } | |
994 | } | |
96025800 | 995 | |
6a488035 | 996 | } |