Commit | Line | Data |
---|---|---|
6a488035 | 1 | <?php |
6a488035 TO |
2 | |
3 | /* | |
4 | +--------------------------------------------------------------------+ | |
232624b1 | 5 | | CiviCRM version 4.4 | |
6a488035 TO |
6 | +--------------------------------------------------------------------+ |
7 | | Copyright CiviCRM LLC (c) 2004-2013 | | |
8 | +--------------------------------------------------------------------+ | |
9 | | This file is a part of CiviCRM. | | |
10 | | | | |
11 | | CiviCRM is free software; you can copy, modify, and distribute it | | |
12 | | under the terms of the GNU Affero General Public License | | |
13 | | Version 3, 19 November 2007 and the CiviCRM Licensing Exception. | | |
14 | | | | |
15 | | CiviCRM is distributed in the hope that it will be useful, but | | |
16 | | WITHOUT ANY WARRANTY; without even the implied warranty of | | |
17 | | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. | | |
18 | | See the GNU Affero General Public License for more details. | | |
19 | | | | |
20 | | You should have received a copy of the GNU Affero General Public | | |
21 | | License and the CiviCRM Licensing Exception along | | |
22 | | with this program; if not, contact CiviCRM LLC | | |
23 | | at info[AT]civicrm[DOT]org. If you have questions about the | | |
24 | | GNU Affero General Public License or the licensing of CiviCRM, | | |
25 | | see the CiviCRM license FAQ at http://civicrm.org/licensing | | |
26 | +--------------------------------------------------------------------+ | |
27 | */ | |
28 | ||
29 | /** | |
30 | * | |
31 | * @package CRM | |
32 | * @copyright CiviCRM LLC (c) 2004-2013 | |
33 | * $Id$ | |
34 | * | |
35 | */ | |
36 | class CRM_Report_Form_ActivitySummary extends CRM_Report_Form { | |
37 | ||
38 | protected $_emailField = FALSE; | |
430ae6dd TO |
39 | protected $_phoneField = FALSE; |
40 | ||
41 | function __construct() { | |
6a488035 TO |
42 | $this->_columns = array( |
43 | 'civicrm_contact' => | |
44 | array( | |
45 | 'dao' => 'CRM_Contact_DAO_Contact', | |
46 | 'fields' => | |
47 | array( | |
48 | 'id' => | |
49 | array( | |
50 | 'required' => TRUE, | |
51 | 'no_display' => TRUE, | |
52 | ), | |
53 | 'sort_name' => | |
54 | array('title' => ts('Contact Name'), | |
55 | 'default' => TRUE, | |
56 | 'no_repeat' => TRUE, | |
57 | ), | |
58 | ), | |
59 | 'filters' => | |
60 | array( | |
61 | 'sort_name' => | |
62 | array('title' => ts('Contact Name'), | |
63 | ), | |
64 | ), | |
65 | 'group_bys' => | |
66 | array( | |
67 | 'sort_name' => | |
68 | array( | |
69 | 'name' => 'id', | |
70 | 'title' => ts('Contact'), | |
71 | 'default' => TRUE, | |
72 | ), | |
73 | ), | |
74 | 'order_bys' => | |
75 | array( | |
76 | 'sort_name' => | |
77 | array('title' => ts('Contact Name')), | |
78 | ), | |
79 | 'grouping' => 'contact-fields', | |
80 | ), | |
81 | 'civicrm_email' => | |
82 | array( | |
83 | 'dao' => 'CRM_Core_DAO_Email', | |
84 | 'fields' => | |
85 | array( | |
86 | 'email' => | |
87 | array( | |
88 | 'title' => 'Email', | |
89 | 'default' => TRUE, | |
90 | ), | |
91 | ), | |
92 | 'order_bys' => | |
93 | array( | |
94 | 'email' => | |
95 | array('title' => ts('Email')), | |
96 | ), | |
97 | 'grouping' => 'contact-fields', | |
98 | ), | |
99 | 'civicrm_phone' => | |
100 | array( | |
101 | 'dao' => 'CRM_Core_DAO_Email', | |
102 | 'fields' => | |
103 | array( | |
104 | 'phone' => | |
105 | array('title' => 'Phone'), | |
106 | ), | |
107 | 'grouping' => 'contact-fields', | |
108 | ), | |
109 | 'civicrm_activity' => | |
110 | array( | |
111 | 'dao' => 'CRM_Activity_DAO_Activity', | |
112 | 'fields' => | |
113 | array( | |
114 | 'activity_type_id' => | |
115 | array('title' => ts('Activity Type'), | |
116 | 'default' => TRUE, | |
117 | 'type' => CRM_Utils_Type::T_STRING, | |
118 | ), | |
119 | 'duration' => | |
120 | array( | |
121 | 'title' => 'Duration', | |
122 | 'statistics' => | |
123 | array( | |
124 | 'sum' => ts('Total Duration'), | |
125 | ), | |
126 | ), | |
127 | 'id' => | |
128 | array( | |
129 | 'title' => 'Total Activities', | |
130 | 'required' => TRUE, | |
131 | 'statistics' => | |
132 | array( | |
133 | 'count' => ts('Activity Count'), | |
134 | ), | |
135 | ), | |
136 | ), | |
137 | 'filters' => | |
138 | array( | |
139 | 'activity_date_time' => | |
140 | array('operatorType' => CRM_Report_Form::OP_DATE), | |
141 | 'activity_type_id' => | |
142 | array('title' => ts('Activity Type'), | |
143 | 'operatorType' => CRM_Report_Form::OP_MULTISELECT, | |
144 | 'options' => CRM_Core_PseudoConstant::activityType(TRUE, TRUE, FALSE, 'label', TRUE), | |
145 | ), | |
146 | 'status_id' => | |
147 | array('title' => ts('Activity Status'), | |
148 | 'operatorType' => CRM_Report_Form::OP_MULTISELECT, | |
149 | 'options' => CRM_Core_PseudoConstant::activityStatus(), | |
150 | ), | |
151 | 'priority_id' => | |
152 | array('title' => ts('Priority'), | |
153 | 'operatorType' => CRM_Report_Form::OP_MULTISELECT, | |
cbf48754 | 154 | 'options' => CRM_Core_PseudoConstant::get('CRM_Activity_DAO_Activity', 'priority_id'), |
6a488035 TO |
155 | ), |
156 | ), | |
157 | 'group_bys' => | |
158 | array( | |
159 | 'activity_date_time' => | |
160 | array('title' => ts('Activity Date'), | |
161 | 'frequency' => TRUE, | |
162 | ), | |
163 | 'activity_type_id' => | |
164 | array('title' => ts('Activity Type'), | |
165 | 'default' => TRUE, | |
166 | ), | |
167 | ), | |
168 | 'order_bys' => | |
169 | array( | |
170 | 'activity_date_time' => | |
171 | array('title' => ts('Activity Date')), | |
172 | 'activity_type_id' => | |
173 | array('title' => ts('Activity Type')), | |
174 | ), | |
175 | 'grouping' => 'activity-fields', | |
176 | 'alias' => 'activity', | |
177 | ), | |
178 | ); | |
179 | ||
180 | parent::__construct(); | |
181 | } | |
182 | ||
183 | function select() { | |
184 | $select = array(); | |
185 | $this->_columnHeaders = array(); | |
186 | foreach ($this->_columns as $tableName => $table) { | |
187 | if (array_key_exists('group_bys', $table)) { | |
188 | foreach ($table['group_bys'] as $fieldName => $field) { | |
189 | if (CRM_Utils_Array::value($fieldName, $this->_params['group_bys'])) { | |
190 | ||
191 | switch (CRM_Utils_Array::value($fieldName, $this->_params['group_bys_freq'])) { | |
192 | case 'YEARWEEK': | |
193 | $select[] = "DATE_SUB({$field['dbAlias']}, INTERVAL WEEKDAY({$field['dbAlias']}) DAY) AS {$tableName}_{$fieldName}_start"; | |
194 | ||
195 | $select[] = "YEARWEEK({$field['dbAlias']}) AS {$tableName}_{$fieldName}_subtotal"; | |
196 | $select[] = "WEEKOFYEAR({$field['dbAlias']}) AS {$tableName}_{$fieldName}_interval"; | |
197 | $field['title'] = 'Week'; | |
198 | break; | |
199 | ||
200 | case 'YEAR': | |
201 | $select[] = "MAKEDATE(YEAR({$field['dbAlias']}), 1) AS {$tableName}_{$fieldName}_start"; | |
202 | $select[] = "YEAR({$field['dbAlias']}) AS {$tableName}_{$fieldName}_subtotal"; | |
203 | $select[] = "YEAR({$field['dbAlias']}) AS {$tableName}_{$fieldName}_interval"; | |
204 | $field['title'] = 'Year'; | |
205 | break; | |
206 | ||
207 | case 'MONTH': | |
208 | $select[] = "DATE_SUB({$field['dbAlias']}, INTERVAL (DAYOFMONTH({$field['dbAlias']})-1) DAY) as {$tableName}_{$fieldName}_start"; | |
209 | $select[] = "MONTH({$field['dbAlias']}) AS {$tableName}_{$fieldName}_subtotal"; | |
210 | $select[] = "MONTHNAME({$field['dbAlias']}) AS {$tableName}_{$fieldName}_interval"; | |
211 | $field['title'] = 'Month'; | |
212 | break; | |
213 | ||
214 | case 'QUARTER': | |
215 | $select[] = "STR_TO_DATE(CONCAT( 3 * QUARTER( {$field['dbAlias']} ) -2 , '/', '1', '/', YEAR( {$field['dbAlias']} ) ), '%m/%d/%Y') AS {$tableName}_{$fieldName}_start"; | |
216 | $select[] = "QUARTER({$field['dbAlias']}) AS {$tableName}_{$fieldName}_subtotal"; | |
217 | $select[] = "QUARTER({$field['dbAlias']}) AS {$tableName}_{$fieldName}_interval"; | |
218 | $field['title'] = 'Quarter'; | |
219 | break; | |
220 | } | |
221 | if (CRM_Utils_Array::value($fieldName, $this->_params['group_bys_freq'])) { | |
222 | $this->_interval = $field['title']; | |
223 | $this->_columnHeaders["{$tableName}_{$fieldName}_start"]['title'] = $field['title'] . ' Beginning'; | |
224 | $this->_columnHeaders["{$tableName}_{$fieldName}_start"]['type'] = $field['type']; | |
225 | $this->_columnHeaders["{$tableName}_{$fieldName}_start"]['group_by'] = $this->_params['group_bys_freq'][$fieldName]; | |
226 | ||
227 | // just to make sure these values are transfered to rows. | |
228 | // since we need that for calculation purpose, | |
229 | // e.g making subtotals look nicer or graphs | |
230 | $this->_columnHeaders["{$tableName}_{$fieldName}_interval"] = array('no_display' => TRUE); | |
231 | $this->_columnHeaders["{$tableName}_{$fieldName}_subtotal"] = array('no_display' => TRUE); | |
232 | } | |
233 | } | |
234 | } | |
235 | } | |
236 | if (array_key_exists('fields', $table)) { | |
237 | foreach ($table['fields'] as $fieldName => $field) { | |
238 | if (CRM_Utils_Array::value('required', $field) || | |
239 | CRM_Utils_Array::value($fieldName, $this->_params['fields']) | |
240 | ) { | |
241 | if ($tableName == 'civicrm_email') { | |
242 | $this->_emailField = TRUE; | |
243 | } | |
244 | if ($tableName == 'civicrm_phone') { | |
245 | $this->_phoneField = TRUE; | |
246 | } | |
247 | if (CRM_Utils_Array::value('statistics', $field)) { | |
248 | foreach ($field['statistics'] as $stat => $label) { | |
249 | switch (strtolower($stat)) { | |
250 | case 'count': | |
251 | $select[] = "COUNT(DISTINCT({$field['dbAlias']})) as {$tableName}_{$fieldName}_{$stat}"; | |
252 | $this->_columnHeaders["{$tableName}_{$fieldName}_{$stat}"]['type'] = CRM_Utils_Type::T_INT; | |
253 | $this->_columnHeaders["{$tableName}_{$fieldName}_{$stat}"]['title'] = $label; | |
254 | $this->_statFields[] = "{$tableName}_{$fieldName}_{$stat}"; | |
255 | break; | |
256 | ||
257 | case 'sum': | |
258 | $select[] = "SUM({$field['dbAlias']}) as {$tableName}_{$fieldName}_{$stat}"; | |
259 | $this->_columnHeaders["{$tableName}_{$fieldName}_{$stat}"]['type'] = CRM_Utils_Type::T_INT; | |
260 | $this->_columnHeaders["{$tableName}_{$fieldName}_{$stat}"]['title'] = $label; | |
261 | $this->_statFields[] = "{$tableName}_{$fieldName}_{$stat}"; | |
262 | break; | |
263 | } | |
264 | } | |
265 | } | |
266 | elseif ($fieldName == 'activity_type_id') { | |
267 | if (!CRM_Utils_Array::value('activity_type_id', $this->_params['group_bys'])) { | |
268 | $select[] = "GROUP_CONCAT(DISTINCT {$field['dbAlias']} ORDER BY {$field['dbAlias']} ) as {$tableName}_{$fieldName}"; | |
269 | } | |
270 | else { | |
271 | $select[] = "{$field['dbAlias']} as {$tableName}_{$fieldName}"; | |
272 | } | |
273 | $this->_columnHeaders["{$tableName}_{$fieldName}"]['type'] = CRM_Utils_Array::value('type', $field); | |
274 | $this->_columnHeaders["{$tableName}_{$fieldName}"]['title'] = CRM_Utils_Array::value('title', $field); | |
275 | $this->_columnHeaders["{$tableName}_{$fieldName}"]['no_display'] = CRM_Utils_Array::value('no_display', $field); | |
276 | } | |
277 | else { | |
278 | $select[] = "{$field['dbAlias']} as {$tableName}_{$fieldName}"; | |
279 | $this->_columnHeaders["{$tableName}_{$fieldName}"]['type'] = CRM_Utils_Array::value('type', $field); | |
280 | $this->_columnHeaders["{$tableName}_{$fieldName}"]['title'] = CRM_Utils_Array::value('title', $field); | |
281 | $this->_columnHeaders["{$tableName}_{$fieldName}"]['no_display'] = CRM_Utils_Array::value('no_display', $field); | |
282 | } | |
283 | } | |
284 | } | |
285 | } | |
286 | } | |
287 | ||
288 | $this->_select = "SELECT " . implode(', ', $select) . " "; | |
289 | } | |
290 | ||
291 | function from() { | |
ecaec004 RN |
292 | $activityContacts = CRM_Core_OptionGroup::values('activity_contacts', FALSE, FALSE, FALSE, NULL, 'name'); |
293 | $assigneeID = CRM_Utils_Array::key('Activity Assignees', $activityContacts); | |
294 | $targetID = CRM_Utils_Array::key('Activity Targets', $activityContacts); | |
295 | $sourceID = CRM_Utils_Array::key('Activity Source', $activityContacts); | |
6a488035 TO |
296 | |
297 | $this->_from = " | |
298 | FROM civicrm_activity {$this->_aliases['civicrm_activity']} | |
2f4c2f5d | 299 | |
ecaec004 RN |
300 | LEFT JOIN civicrm_activity_contact target_activity |
301 | ON {$this->_aliases['civicrm_activity']}.id = target_activity.activity_id AND | |
302 | target_activity.record_type_id = {$targetID} | |
303 | LEFT JOIN civicrm_activity_contact assignment_activity | |
304 | ON {$this->_aliases['civicrm_activity']}.id = assignment_activity.activity_id AND | |
305 | assignment_activity.record_type_id = {$assigneeID} | |
306 | LEFT JOIN civicrm_activity_contact source_activity | |
307 | ON {$this->_aliases['civicrm_activity']}.id = source_activity.activity_id AND | |
308 | source_activity.record_type_id = {$sourceID} | |
309 | LEFT JOIN civicrm_contact contact_civireport | |
310 | ON target_activity.contact_id = contact_civireport.id | |
311 | LEFT JOIN civicrm_contact civicrm_contact_assignee | |
312 | ON assignment_activity.contact_id = civicrm_contact_assignee.id | |
313 | LEFT JOIN civicrm_contact civicrm_contact_source | |
314 | ON source_activity.contact_id = civicrm_contact_source.id | |
6a488035 | 315 | {$this->_aclFrom} |
2f4c2f5d | 316 | LEFT JOIN civicrm_option_value |
6a488035 | 317 | ON ( {$this->_aliases['civicrm_activity']}.activity_type_id = civicrm_option_value.value ) |
2f4c2f5d | 318 | LEFT JOIN civicrm_option_group |
6a488035 | 319 | ON civicrm_option_group.id = civicrm_option_value.option_group_id |
2f4c2f5d | 320 | LEFT JOIN civicrm_case_activity |
6a488035 | 321 | ON civicrm_case_activity.activity_id = {$this->_aliases['civicrm_activity']}.id |
2f4c2f5d | 322 | LEFT JOIN civicrm_case |
6a488035 | 323 | ON civicrm_case_activity.case_id = civicrm_case.id |
2f4c2f5d | 324 | LEFT JOIN civicrm_case_contact |
6a488035 TO |
325 | ON civicrm_case_contact.case_id = civicrm_case.id "; |
326 | ||
327 | if ($this->_emailField) { | |
328 | $this->_from .= " | |
329 | LEFT JOIN civicrm_email {$this->_aliases['civicrm_email']} | |
330 | ON {$this->_aliases['civicrm_contact']}.id = {$this->_aliases['civicrm_email']}.contact_id AND | |
331 | {$this->_aliases['civicrm_email']}.is_primary = 1 "; | |
332 | } | |
333 | ||
334 | if ($this->_phoneField) { | |
335 | $this->_from .= " | |
336 | LEFT JOIN civicrm_phone {$this->_aliases['civicrm_phone']} | |
337 | ON {$this->_aliases['civicrm_contact']}.id = {$this->_aliases['civicrm_phone']}.contact_id AND | |
338 | {$this->_aliases['civicrm_phone']}.is_primary = 1 "; | |
339 | } | |
340 | } | |
341 | ||
342 | function where() { | |
2f4c2f5d | 343 | $this->_where = " WHERE civicrm_option_group.name = 'activity_type' AND |
6a488035 TO |
344 | {$this->_aliases['civicrm_activity']}.is_test = 0 AND |
345 | {$this->_aliases['civicrm_activity']}.is_deleted = 0 AND | |
346 | {$this->_aliases['civicrm_activity']}.is_current_revision = 1"; | |
347 | ||
348 | $clauses = array(); | |
349 | foreach ($this->_columns as $tableName => $table) { | |
350 | if (array_key_exists('filters', $table)) { | |
351 | ||
352 | foreach ($table['filters'] as $fieldName => $field) { | |
353 | $clause = NULL; | |
354 | if (CRM_Utils_Array::value('type', $field) & CRM_Utils_Type::T_DATE) { | |
355 | $relative = CRM_Utils_Array::value("{$fieldName}_relative", $this->_params); | |
356 | $from = CRM_Utils_Array::value("{$fieldName}_from", $this->_params); | |
357 | $to = CRM_Utils_Array::value("{$fieldName}_to", $this->_params); | |
358 | ||
359 | $clause = $this->dateClause($field['name'], $relative, $from, $to, $field['type']); | |
360 | } | |
361 | else { | |
362 | $op = CRM_Utils_Array::value("{$fieldName}_op", $this->_params); | |
363 | if ($op) { | |
364 | $clause = $this->whereClause($field, | |
365 | $op, | |
366 | CRM_Utils_Array::value("{$fieldName}_value", $this->_params), | |
367 | CRM_Utils_Array::value("{$fieldName}_min", $this->_params), | |
368 | CRM_Utils_Array::value("{$fieldName}_max", $this->_params) | |
369 | ); | |
370 | } | |
371 | } | |
372 | ||
373 | if (!empty($clause)) { | |
374 | $clauses[] = $clause; | |
375 | } | |
376 | } | |
377 | } | |
378 | } | |
379 | ||
380 | if (empty($clauses)) { | |
381 | $this->_where .= " "; | |
382 | } | |
383 | else { | |
384 | $this->_where .= " AND " . implode(' AND ', $clauses); | |
385 | } | |
386 | ||
387 | if ($this->_aclWhere) { | |
388 | $this->_where .= " AND {$this->_aclWhere} "; | |
389 | } | |
390 | } | |
391 | ||
392 | function groupBy() { | |
393 | $this->_groupBy = array(); | |
394 | if (is_array($this->_params['group_bys']) && | |
395 | !empty($this->_params['group_bys']) | |
396 | ) { | |
397 | foreach ($this->_columns as $tableName => $table) { | |
398 | if (array_key_exists('group_bys', $table)) { | |
399 | foreach ($table['group_bys'] as $fieldName => $field) { | |
400 | if (CRM_Utils_Array::value($fieldName, $this->_params['group_bys'])) { | |
401 | if (CRM_Utils_Array::value('chart', $field)) { | |
402 | $this->assign('chartSupported', TRUE); | |
403 | } | |
404 | if (CRM_Utils_Array::value('frequency', $table['group_bys'][$fieldName]) && | |
405 | CRM_Utils_Array::value($fieldName, $this->_params['group_bys_freq']) | |
406 | ) { | |
407 | ||
408 | $append = "YEAR({$field['dbAlias']}),"; | |
409 | if (in_array(strtolower($this->_params['group_bys_freq'][$fieldName]), | |
410 | array('year') | |
411 | )) { | |
412 | $append = ''; | |
413 | } | |
414 | $this->_groupBy[] = "$append {$this->_params['group_bys_freq'][$fieldName]}({$field['dbAlias']})"; | |
415 | $append = TRUE; | |
416 | } | |
417 | else { | |
418 | $this->_groupBy[] = $field['dbAlias']; | |
419 | } | |
420 | } | |
421 | } | |
422 | } | |
423 | } | |
424 | ||
425 | $this->_groupBy = "GROUP BY " . implode(', ', $this->_groupBy); | |
426 | } | |
427 | else { | |
428 | $this->_groupBy = "GROUP BY {$this->_aliases['civicrm_contact']}.id "; | |
429 | } | |
430 | } | |
431 | ||
432 | function formRule($fields, $files, $self) { | |
433 | $errors = array(); | |
434 | $contactFields = array('sort_name', 'email', 'phone'); | |
435 | if (CRM_Utils_Array::value('group_bys', $fields)) { | |
436 | ||
437 | if (CRM_Utils_Array::value('activity_type_id', $fields['group_bys']) && | |
438 | !CRM_Utils_Array::value('sort_name', $fields['group_bys']) | |
439 | ) { | |
440 | foreach ($fields['fields'] as $fieldName => $val) { | |
441 | if (in_array($fieldName, $contactFields)) { | |
442 | $errors['fields'] = ts("Please select GroupBy 'Contact' to display Contact Fields"); | |
443 | break; | |
444 | } | |
445 | } | |
446 | } | |
447 | ||
448 | if (CRM_Utils_Array::value('activity_date_time', $fields['group_bys'])) { | |
449 | if (CRM_Utils_Array::value('sort_name', $fields['group_bys'])) { | |
450 | $errors['fields'] = ts("Please do not select GroupBy 'Activity Date' with GroupBy 'Contact'"); | |
451 | } | |
452 | else { | |
453 | foreach ($fields['fields'] as $fieldName => $val) { | |
454 | if (in_array($fieldName, $contactFields)) { | |
455 | $errors['fields'] = ts("Please do not select any Contact Fields with GroupBy 'Activity Date'"); | |
456 | break; | |
457 | } | |
458 | } | |
459 | } | |
460 | } | |
461 | } | |
462 | return $errors; | |
463 | } | |
464 | ||
465 | function postProcess() { | |
466 | // get the acl clauses built before we assemble the query | |
467 | $this->buildACLClause($this->_aliases['civicrm_contact']); | |
468 | parent::postProcess(); | |
469 | } | |
470 | ||
471 | function alterDisplay(&$rows) { | |
472 | // custom code to alter rows | |
473 | ||
474 | $entryFound = FALSE; | |
475 | $activityType = CRM_Core_PseudoConstant::activityType(TRUE, TRUE, FALSE, 'label', TRUE); | |
476 | $flagContact = 0; | |
477 | ||
478 | $onHover = ts('View Contact Summary for this Contact'); | |
479 | foreach ($rows as $rowNum => $row) { | |
480 | ||
481 | if (array_key_exists('civicrm_contact_sort_name', $row) && $this->_outputMode != 'csv') { | |
482 | if ($value = $row['civicrm_contact_id']) { | |
483 | ||
484 | if ($rowNum == 0) { | |
485 | $priviousContact = $value; | |
486 | } | |
487 | else { | |
488 | if ($priviousContact == $value) { | |
489 | $flagContact = 1; | |
490 | $priviousContact = $value; | |
491 | } | |
492 | else { | |
493 | $flagContact = 0; | |
494 | $priviousContact = $value; | |
495 | } | |
496 | } | |
497 | ||
498 | if ($flagContact == 1) { | |
499 | $rows[$rowNum]['civicrm_contact_sort_name'] = ""; | |
500 | ||
501 | if (array_key_exists('civicrm_email_email', $row)) { | |
502 | $rows[$rowNum]['civicrm_email_email'] = ""; | |
503 | } | |
504 | if (array_key_exists('civicrm_phone_phone', $row)) { | |
505 | $rows[$rowNum]['civicrm_phone_phone'] = ""; | |
506 | } | |
507 | } | |
508 | else { | |
509 | $url = CRM_Utils_System::url('civicrm/contact/view', | |
510 | 'reset=1&cid=' . $value, | |
511 | $this->_absoluteUrl | |
512 | ); | |
513 | ||
514 | $rows[$rowNum]['civicrm_contact_sort_name'] = "<a href='$url'>" . $row['civicrm_contact_sort_name'] . '</a>'; | |
515 | } | |
516 | $entryFound = TRUE; | |
517 | } | |
518 | } | |
519 | ||
520 | if (array_key_exists('civicrm_activity_activity_type_id', $row)) { | |
521 | if ($value = $row['civicrm_activity_activity_type_id']) { | |
522 | ||
523 | $value = explode(',', $value); | |
524 | foreach ($value as $key => $id) { | |
525 | $value[$key] = $activityType[$id]; | |
526 | } | |
527 | ||
528 | $rows[$rowNum]['civicrm_activity_activity_type_id'] = implode(' , ', $value); | |
529 | $entryFound = TRUE; | |
530 | } | |
531 | } | |
532 | ||
533 | if (!$entryFound) { | |
534 | break; | |
535 | } | |
536 | } | |
537 | } | |
538 | } | |
539 |