Import from SVN (r45945, r596)
[civicrm-core.git] / CRM / Report / Form / Member / Summary.php
CommitLineData
6a488035
TO
1<?php
2// $Id$
3
4/*
5 +--------------------------------------------------------------------+
6 | CiviCRM version 4.3 |
7 +--------------------------------------------------------------------+
8 | Copyright CiviCRM LLC (c) 2004-2013 |
9 +--------------------------------------------------------------------+
10 | This file is a part of CiviCRM. |
11 | |
12 | CiviCRM is free software; you can copy, modify, and distribute it |
13 | under the terms of the GNU Affero General Public License |
14 | Version 3, 19 November 2007 and the CiviCRM Licensing Exception. |
15 | |
16 | CiviCRM is distributed in the hope that it will be useful, but |
17 | WITHOUT ANY WARRANTY; without even the implied warranty of |
18 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. |
19 | See the GNU Affero General Public License for more details. |
20 | |
21 | You should have received a copy of the GNU Affero General Public |
22 | License and the CiviCRM Licensing Exception along |
23 | with this program; if not, contact CiviCRM LLC |
24 | at info[AT]civicrm[DOT]org. If you have questions about the |
25 | GNU Affero General Public License or the licensing of CiviCRM, |
26 | see the CiviCRM license FAQ at http://civicrm.org/licensing |
27 +--------------------------------------------------------------------+
28*/
29
30/**
31 *
32 * @package CRM
33 * @copyright CiviCRM LLC (c) 2004-2013
34 * $Id$
35 *
36 */
37class CRM_Report_Form_Member_Summary extends CRM_Report_Form {
38
39 protected $_summary = NULL;
40 protected $_interval = NULL;
41 protected $_charts = array(
42 '' => 'Tabular',
43 'barChart' => 'Bar Chart',
44 'pieChart' => 'Pie Chart',
45 );
46 protected $_add2groupSupported = FALSE;
47
48 protected $_customGroupExtends = array('Membership');
49 protected $_customGroupGroupBy = FALSE;
50 public $_drilldownReport = array('member/detail' => 'Link to Detail Report');
51
52 function __construct() {
53 // UI for selecting columns to appear in the report list
54 // array conatining the columns, group_bys and filters build and provided to Form
55
56 $this->_columns = array(
57 'civicrm_membership' =>
58 array(
59 'dao' => 'CRM_Member_DAO_MembershipType',
60 'grouping' => 'member-fields',
61 'fields' =>
62 array(
63 'membership_type_id' =>
64 array(
65 'title' => 'Membership Type',
66 'required' => TRUE,
67 ),
68 ),
69 'filters' =>
70 array(
71 'join_date' =>
72 array('title' => ts('Member Since'),
73 'type' => CRM_Utils_Type::T_DATE,
74 'operatorType' => CRM_Report_Form::OP_DATE,
75 ),
76 'membership_start_date' =>
77 array(
78 'name' => 'start_date',
79 'title' => ts('Membership Start Date'),
80 'type' => CRM_Utils_Type::T_DATE,
81 'operatorType' => CRM_Report_Form::OP_DATE,
82 ),
83 'membership_end_date' =>
84 array(
85 'name' => 'end_date',
86 'title' => ts('Membership End Date'),
87 'type' => CRM_Utils_Type::T_DATE,
88 'operatorType' => CRM_Report_Form::OP_DATE,
89 ),
90 'membership_type_id' =>
91 array('title' => ts('Membership Type'),
92 'operatorType' => CRM_Report_Form::OP_MULTISELECT,
93 'options' => CRM_Member_PseudoConstant::membershipType(),
94 ),
95 'status_id' =>
96 array('title' => ts('Membership Status'),
97 'operatorType' => CRM_Report_Form::OP_MULTISELECT,
98 'options' => CRM_Member_PseudoConstant::membershipStatus(NULL, NULL, 'label'),
99 ),
100 ),
101 'group_bys' =>
102 array(
103 'join_date' =>
104 array('title' => ts('Member Since'),
105 'default' => TRUE,
106 'frequency' => TRUE,
107 'chart' => TRUE,
108 'type' => 12,
109 ),
110 'membership_type_id' =>
111 array(
112 'title' => 'Membership Type',
113 'default' => TRUE,
114 'chart' => TRUE,
115 ),
116 ),
117 ),
118 'civicrm_contact' =>
119 array(
120 'dao' => 'CRM_Contact_DAO_Contact',
121 'fields' =>
122 array(
123 'contact_id' =>
124 array(
125 'no_display' => TRUE,
126 ),
127 ),
128 ),
129 'civicrm_contribution' =>
130 array(
131 'dao' => 'CRM_Contribute_DAO_Contribution',
132 'fields' =>
133 array(
134 'total_amount' =>
135 array('title' => ts('Amount Statistics'),
136 'required' => TRUE,
137 'statistics' =>
138 array('sum' => ts('Total Payments Made'),
139 'count' => ts('Contribution Count'),
140 'avg' => ts('Average'),
141 ),
142 ),
143 ),
144 'filters' =>
145 array(
146 'contribution_status_id' =>
147 array('title' => ts('Contribution Status'),
148 'operatorType' => CRM_Report_Form::OP_MULTISELECT,
149 'options' => CRM_Contribute_PseudoConstant::contributionStatus(),
150 ),
151 ),
152 'grouping' => 'member-fields',
153 ),
154 );
155 $this->_tagFilter = TRUE;
156 $this->_groupFilter = TRUE;
157 parent::__construct();
158 }
159
160 function select() {
161 $select = array();
162 $groupBys = FALSE;
163 $this->_columnHeaders = array();
164 $select[] = " COUNT( DISTINCT {$this->_aliases['civicrm_membership']}.id ) as civicrm_membership_member_count";
165 $select['joinDate'] = " {$this->_aliases['civicrm_membership']}.join_date as civicrm_membership_member_join_date";
166 $this->_columnHeaders["civicrm_membership_member_join_date"] = array('title' => ts('Member Since'),
167 'type' => CRM_Utils_Type::T_DATE,
168 );
169 foreach ($this->_columns as $tableName => $table) {
170 if (array_key_exists('group_bys', $table)) {
171 foreach ($table['group_bys'] as $fieldName => $field) {
172 if (CRM_Utils_Array::value($fieldName, $this->_params['group_bys'])) {
173
174 switch (CRM_Utils_Array::value($fieldName, $this->_params['group_bys_freq'])) {
175 case 'YEARWEEK':
176 $select[] = "DATE_SUB({$field['dbAlias']}, INTERVAL WEEKDAY({$field['dbAlias']}) DAY) AS {$tableName}_{$fieldName}_start";
177
178 $select[] = "YEARWEEK({$field['dbAlias']}) AS {$tableName}_{$fieldName}_subtotal";
179 $select[] = "WEEKOFYEAR({$field['dbAlias']}) AS {$tableName}_{$fieldName}_interval";
180 $field['title'] = 'Week';
181 break;
182
183 case 'YEAR':
184 $select[] = "MAKEDATE(YEAR({$field['dbAlias']}), 1) AS {$tableName}_{$fieldName}_start";
185 $select[] = "YEAR({$field['dbAlias']}) AS {$tableName}_{$fieldName}_subtotal";
186 $select[] = "YEAR({$field['dbAlias']}) AS {$tableName}_{$fieldName}_interval";
187 $field['title'] = 'Year';
188 break;
189
190 case 'MONTH':
191 $select[] = "DATE_SUB({$field['dbAlias']}, INTERVAL (DAYOFMONTH({$field['dbAlias']})-1) DAY) as {$tableName}_{$fieldName}_start";
192 $select[] = "MONTH({$field['dbAlias']}) AS {$tableName}_{$fieldName}_subtotal";
193 $select[] = "MONTHNAME({$field['dbAlias']}) AS {$tableName}_{$fieldName}_interval";
194 $field['title'] = 'Month';
195 break;
196
197 case 'QUARTER':
198 $select[] = "STR_TO_DATE(CONCAT( 3 * QUARTER( {$field['dbAlias']} ) -2 , '/', '1', '/', YEAR( {$field['dbAlias']} ) ), '%m/%d/%Y') AS {$tableName}_{$fieldName}_start";
199 $select[] = "QUARTER({$field['dbAlias']}) AS {$tableName}_{$fieldName}_subtotal";
200 $select[] = "QUARTER({$field['dbAlias']}) AS {$tableName}_{$fieldName}_interval";
201 $field['title'] = 'Quarter';
202 break;
203 }
204 if (CRM_Utils_Array::value($fieldName, $this->_params['group_bys_freq'])) {
205 $this->_interval = $field['title'];
206 $this->_columnHeaders["{$tableName}_{$fieldName}_start"]['title'] = $field['title'] . ' Beginning';
207 $this->_columnHeaders["{$tableName}_{$fieldName}_start"]['type'] = $field['type'];
208 $this->_columnHeaders["{$tableName}_{$fieldName}_start"]['group_by'] = $this->_params['group_bys_freq'][$fieldName];
209
210 // just to make sure these values are transfered to rows.
211 // since we need that for calculation purpose,
212 // e.g making subtotals look nicer or graphs
213 $this->_columnHeaders["{$tableName}_{$fieldName}_interval"] = array('no_display' => TRUE);
214 $this->_columnHeaders["{$tableName}_{$fieldName}_subtotal"] = array('no_display' => TRUE);
215 }
216 $groupBys = TRUE;
217 }
218 }
219 }
220 // end of select
221
222 if (array_key_exists('fields', $table)) {
223 foreach ($table['fields'] as $fieldName => $field) {
224 if (CRM_Utils_Array::value('required', $field) ||
225 CRM_Utils_Array::value($fieldName, $this->_params['fields'])
226 ) {
227
228 // only include statistics columns if set
229 if (CRM_Utils_Array::value('statistics', $field)) {
230 $this->_statFields[] = 'civicrm_membership_member_count';
231 foreach ($field['statistics'] as $stat => $label) {
232 switch (strtolower($stat)) {
233 case 'sum':
234 $select[] = "IFNULL(SUM({$field['dbAlias']}), 0) as {$tableName}_{$fieldName}_{$stat}";
235 $this->_columnHeaders["{$tableName}_{$fieldName}_{$stat}"]['title'] = $label;
236 $this->_columnHeaders["{$tableName}_{$fieldName}_{$stat}"]['type'] = $field['type'];
237 $this->_statFields[] = "{$tableName}_{$fieldName}_{$stat}";
238 break;
239
240 case 'count':
241 $select[] = "COUNT({$field['dbAlias']}) as {$tableName}_{$fieldName}_{$stat}";
242 $this->_columnHeaders["{$tableName}_{$fieldName}_{$stat}"]['type'] = CRM_Utils_Type::T_INT;
243 $this->_columnHeaders["{$tableName}_{$fieldName}_{$stat}"]['title'] = $label;
244 $this->_statFields[] = "{$tableName}_{$fieldName}_{$stat}";
245 break;
246
247 case 'avg':
248 $select[] = "IFNULL(ROUND(AVG({$field['dbAlias']}),2), 0) as {$tableName}_{$fieldName}_{$stat}";
249 $this->_columnHeaders["{$tableName}_{$fieldName}_{$stat}"]['type'] = $field['type'];
250 $this->_columnHeaders["{$tableName}_{$fieldName}_{$stat}"]['title'] = $label;
251 $this->_statFields[] = "{$tableName}_{$fieldName}_{$stat}";
252 break;
253 }
254 }
255 }
256 elseif ($fieldName == 'membership_type_id') {
257 if (!CRM_Utils_Array::value('membership_type_id', $this->_params['group_bys']) &&
258 CRM_Utils_Array::value('join_date', $this->_params['group_bys'])
259 ) {
260 $select[] = "GROUP_CONCAT(DISTINCT {$field['dbAlias']} ORDER BY {$field['dbAlias']} ) as {$tableName}_{$fieldName}";
261 }
262 else {
263 $select[] = "{$field['dbAlias']} as {$tableName}_{$fieldName}";
264 }
265 $this->_columnHeaders["{$tableName}_{$fieldName}"]['title'] = $field['title'];
266 $this->_columnHeaders["{$tableName}_{$fieldName}"]['operatorType'] = CRM_Utils_Array::value('operatorType', $field);
267 }
268 else {
269 $select[] = "{$field['dbAlias']} as {$tableName}_{$fieldName}";
270 $this->_columnHeaders["{$tableName}_{$fieldName}"]['title'] = $field['title'];
271 $this->_columnHeaders["{$tableName}_{$fieldName}"]['operatorType'] = CRM_Utils_Array::value('operatorType', $field);
272 }
273 }
274 }
275 }
276 $this->_columnHeaders["civicrm_membership_member_count"] = array('title' => ts('Member Count'),
277 'type' => CRM_Utils_Type::T_INT,
278 );
279 }
280 //If grouping is availabled then remove join date from field
281 if ($groupBys) {
282 unset($select['joinDate']);
283 unset($this->_columnHeaders["civicrm_membership_member_join_date"]);
284 }
285 $this->_select = "SELECT " . implode(', ', $select) . " ";
286 }
287
288 function from() {
289 $this->_from = "
290 FROM civicrm_membership {$this->_aliases['civicrm_membership']}
291
292 LEFT JOIN civicrm_contact {$this->_aliases['civicrm_contact']} ON ( {$this->_aliases['civicrm_membership']}.contact_id = {$this->_aliases['civicrm_contact']}.id )
293
294 LEFT JOIN civicrm_membership_status
295 ON ({$this->_aliases['civicrm_membership']}.status_id = civicrm_membership_status.id )
296 LEFT JOIN civicrm_membership_payment payment
297 ON ( {$this->_aliases['civicrm_membership']}.id = payment.membership_id )
298 LEFT JOIN civicrm_contribution {$this->_aliases['civicrm_contribution']}
299 ON payment.contribution_id = {$this->_aliases['civicrm_contribution']}.id";
300 }
301 // end of from
302
303 function where() {
304 $clauses = array();
305 foreach ($this->_columns as $tableName => $table) {
306 if (array_key_exists('filters', $table)) {
307 foreach ($table['filters'] as $fieldName => $field) {
308 $clause = NULL;
309
310 if ($field['operatorType'] & CRM_Utils_Type::T_DATE) {
311 $relative = CRM_Utils_Array::value("{$fieldName}_relative", $this->_params);
312 $from = CRM_Utils_Array::value("{$fieldName}_from", $this->_params);
313 $to = CRM_Utils_Array::value("{$fieldName}_to", $this->_params);
314
315 if ($relative || $from || $to) {
316 $clause = $this->dateClause($field['name'], $relative, $from, $to, $field['type']);
317 }
318 }
319 else {
320 $op = CRM_Utils_Array::value("{$fieldName}_op", $this->_params);
321 if ($op) {
322 $clause = $this->whereClause($field,
323 $op,
324 CRM_Utils_Array::value("{$fieldName}_value", $this->_params),
325 CRM_Utils_Array::value("{$fieldName}_min", $this->_params),
326 CRM_Utils_Array::value("{$fieldName}_max", $this->_params)
327 );
328 }
329 }
330 if (!empty($clause)) {
331 $clauses[$fieldName] = $clause;
332 }
333 }
334 }
335 }
336
337 if (!empty($clauses)) {
338 $this->_where = "WHERE {$this->_aliases['civicrm_membership']}.is_test = 0 AND " . implode(' AND ', $clauses);
339 }
340 else {
341 $this->_where = "WHERE {$this->_aliases['civicrm_membership']}.is_test = 0";
342 }
343 }
344
345 function groupBy() {
346 $this->_groupBy = "";
347 if (is_array($this->_params['group_bys']) &&
348 !empty($this->_params['group_bys'])
349 ) {
350 foreach ($this->_columns as $tableName => $table) {
351 if (array_key_exists('group_bys', $table)) {
352 foreach ($table['group_bys'] as $fieldName => $field) {
353 if (CRM_Utils_Array::value($fieldName, $this->_params['group_bys'])) {
354 if (CRM_Utils_Array::value('chart', $field)) {
355 $this->assign('chartSupported', TRUE);
356 }
357 if (CRM_Utils_Array::value('frequency', $table['group_bys'][$fieldName]) &&
358 CRM_Utils_Array::value($fieldName, $this->_params['group_bys_freq'])
359 ) {
360
361 $append = "YEAR({$field['dbAlias']}),";
362 if (in_array(strtolower($this->_params['group_bys_freq'][$fieldName]),
363 array('year')
364 )) {
365 $append = '';
366 }
367 $this->_groupBy[] = "$append {$this->_params['group_bys_freq'][$fieldName]}({$field['dbAlias']})";
368 $append = TRUE;
369 }
370 else {
371 $this->_groupBy[] = $field['dbAlias'];
372 }
373 }
374 }
375 }
376 }
377
378 $this->_rollup = ' WITH ROLLUP';
379 $this->_groupBy = 'GROUP BY ' . implode(', ', $this->_groupBy) . " {$this->_rollup} ";
380 }
381 else {
382 $this->_groupBy = "GROUP BY {$this->_aliases['civicrm_membership']}.join_date";
383 }
384 }
385
386 function statistics(&$rows) {
387 $statistics = parent::statistics($rows);
388
389 $select = "
390 SELECT COUNT({$this->_aliases['civicrm_contribution']}.total_amount ) as count,
391 IFNULL(SUM({$this->_aliases['civicrm_contribution']}.total_amount ), 0) as amount,
392 IFNULL(ROUND(AVG({$this->_aliases['civicrm_contribution']}.total_amount), 2),0) as avg,
393 COUNT( DISTINCT {$this->_aliases['civicrm_membership']}.id ) as memberCount
394 ";
395
396 $sql = "{$select} {$this->_from} {$this->_where}";
397 $dao = CRM_Core_DAO::executeQuery($sql);
398
399 if ($dao->fetch()) {
400 $statistics['counts']['amount'] = array(
401 'value' => $dao->amount,
402 'title' => 'Total Amount',
403 'type' => CRM_Utils_Type::T_MONEY,
404 );
405 $statistics['counts']['count '] = array(
406 'value' => $dao->count,
407 'title' => 'Total Donations',
408 );
409 $statistics['counts']['memberCount'] = array(
410 'value' => $dao->memberCount,
411 'title' => 'Total Members',
412 );
413 $statistics['counts']['avg '] = array(
414 'value' => $dao->avg,
415 'title' => 'Average',
416 'type' => CRM_Utils_Type::T_MONEY,
417 );
418
419 if (!(int)$statistics['counts']['amount']['value']) {
420 //if total amount is zero then hide Chart Options
421 $this->assign('chartSupported', FALSE);
422 }
423 }
424
425 return $statistics;
426 }
427
428 function postProcess() {
429 parent::postProcess();
430 }
431
432 function buildChart(&$rows) {
433 $graphRows = array();
434 $count = 0;
435 $membershipTypeValues = CRM_Member_PseudoConstant::membershipType();
436 $isMembershipType = CRM_Utils_Array::value('membership_type_id', $this->_params['group_bys']);
437 $isJoiningDate = CRM_Utils_Array::value('join_date', $this->_params['group_bys']);
438 if (CRM_Utils_Array::value('charts', $this->_params)) {
439 foreach ($rows as $key => $row) {
440 if (!($row['civicrm_membership_join_date_subtotal'] &&
441 $row['civicrm_membership_membership_type_id']
442 )) {
443 continue;
444 }
445 if ($isMembershipType) {
446 $join_date = CRM_Utils_Array::value('civicrm_membership_join_date_start', $row);
447 $displayInterval = CRM_Utils_Array::value('civicrm_membership_join_date_interval', $row);
448 if ($join_date) {
449 list($year, $month) = explode('-', $join_date);
450 }
451 if (CRM_Utils_Array::value('civicrm_membership_join_date_subtotal', $row)) {
452
453 switch ($this->_interval) {
454 case 'Month':
455 $displayRange = $displayInterval . ' ' . $year;
456 break;
457
458 case 'Quarter':
459 $displayRange = 'Quarter ' . $displayInterval . ' of ' . $year;
460 break;
461
462 case 'Week':
463 $displayRange = 'Week ' . $displayInterval . ' of ' . $year;
464 break;
465
466 case 'Year':
467 $displayRange = $year;
468 break;
469 }
470 $membershipType = $displayRange . "-" . $membershipTypeValues[$row['civicrm_membership_membership_type_id']];
471 }
472 else {
473
474 $membershipType = $membershipTypeValues[$row['civicrm_membership_membership_type_id']];
475 }
476
477 $interval[$membershipType] = $membershipType;
478 $display[$membershipType] = $row['civicrm_contribution_total_amount_sum'];
479 }
480 else {
481 $graphRows['receive_date'][] = CRM_Utils_Array::value('civicrm_membership_join_date_start', $row);
482 $graphRows[$this->_interval][] = CRM_Utils_Array::value('civicrm_membership_join_date_interval', $row);
483 $graphRows['value'][] = $row['civicrm_contribution_total_amount_sum'];
484 $count++;
485 }
486 }
487
488 // build chart.
489 if ($isMembershipType) {
490 $graphRows['value'] = $display;
491 $chartInfo = array(
492 'legend' => 'Membership Summary',
493 'xname' => 'Member Since / Member Type',
494 'yname' => 'Fees',
495 );
496 CRM_Utils_OpenFlashChart::reportChart($graphRows, $this->_params['charts'], $interval, $chartInfo);
497 }
498 else {
499 CRM_Utils_OpenFlashChart::chart($graphRows, $this->_params['charts'], $this->_interval);
500 }
501 }
502 $this->assign('chartType', $this->_params['charts']);
503 }
504
505 function alterDisplay(&$rows) {
506 // custom code to alter rows
507 $entryFound = FALSE;
508 foreach ($rows as $rowNum => $row) {
509 // make count columns point to detail report
510 if (CRM_Utils_Array::value('join_date', $this->_params['group_bys']) &&
511 CRM_Utils_Array::value('civicrm_membership_join_date_start', $row) &&
512 $row['civicrm_membership_join_date_start'] &&
513 $row['civicrm_membership_join_date_subtotal']
514 ) {
515
516 $dateStart = CRM_Utils_Date::customFormat($row['civicrm_membership_join_date_start'], '%Y%m%d');
517 $endDate = new DateTime($dateStart);
518 $dateEnd = array();
519
520 list($dateEnd['Y'], $dateEnd['M'], $dateEnd['d']) = explode(':', $endDate->format('Y:m:d'));
521
522 switch (strtolower($this->_params['group_bys_freq']['join_date'])) {
523 case 'month':
524 $dateEnd = date("Ymd", mktime(0, 0, 0, $dateEnd['M'] + 1,
525 $dateEnd['d'] - 1, $dateEnd['Y']
526 ));
527 break;
528
529 case 'year':
530 $dateEnd = date("Ymd", mktime(0, 0, 0, $dateEnd['M'],
531 $dateEnd['d'] - 1, $dateEnd['Y'] + 1
532 ));
533 break;
534
535 case 'yearweek':
536 $dateEnd = date("Ymd", mktime(0, 0, 0, $dateEnd['M'],
537 $dateEnd['d'] + 6, $dateEnd['Y']
538 ));
539 break;
540
541 case 'quarter':
542 $dateEnd = date("Ymd", mktime(0, 0, 0, $dateEnd['M'] + 3,
543 $dateEnd['d'] - 1, $dateEnd['Y']
544 ));
545 break;
546 }
547 $typeUrl = '';
548 if (CRM_Utils_Array::value('membership_type_id', $this->_params['group_bys']) &&
549 $typeID = $row['civicrm_membership_membership_type_id']
550 ) {
551 $typeUrl = "&tid_op=in&tid_value={$typeID}";
552 }
553 $statusUrl = '';
554 if (!empty($this->_params['status_id_value'])) {
555 $statusUrl = "&sid_op=in&sid_value=" . implode(",", $this->_params['status_id_value']);
556 }
557 $url = CRM_Report_Utils_Report::getNextUrl('member/detail',
558 "reset=1&force=1&join_date_from={$dateStart}&join_date_to={$dateEnd}{$typeUrl}{$statusUrl}",
559 $this->_absoluteUrl, $this->_id, $this->_drilldownReport
560 );
561 $row['civicrm_membership_join_date_start'] = CRM_Utils_Date::format($row['civicrm_membership_join_date_start']);
562 $rows[$rowNum]['civicrm_membership_join_date_start_link'] = $url;
563 $rows[$rowNum]['civicrm_membership_join_date_start_hover'] = ts("Lists Summary of Memberships for this date unit.");
564
565 $entryFound = TRUE;
566 }
567
568 // handle Membership Types
569 if (array_key_exists('civicrm_membership_membership_type_id', $row)) {
570 if ($value = $row['civicrm_membership_membership_type_id']) {
571 $value = explode(',', $value);
572 foreach ($value as $key => $id) {
573 $value[$key] = CRM_Member_PseudoConstant::membershipType($id, FALSE);
574 }
575 $rows[$rowNum]['civicrm_membership_membership_type_id'] = implode(' , ', $value);
576 }
577 $entryFound = TRUE;
578 }
579
580 // make subtotals look nicer
581 if (array_key_exists('civicrm_membership_join_date_subtotal', $row) &&
582 !$row['civicrm_membership_join_date_subtotal']
583 ) {
584 $this->fixSubTotalDisplay($rows[$rowNum], $this->_statFields);
585 $entryFound = TRUE;
586 }
587 elseif (array_key_exists('civicrm_membership_join_date_subtotal', $row) &&
588 $row['civicrm_membership_join_date_subtotal'] &&
589 !$row['civicrm_membership_membership_type_id']
590 ) {
591 $this->fixSubTotalDisplay($rows[$rowNum], $this->_statFields, FALSE);
592 $rows[$rowNum]['civicrm_membership_membership_type_id'] = '<b>SubTotal</b>';
593 $entryFound = TRUE;
594 }
595
596 // skip looking further in rows, if first row itself doesn't
597 // have the column we need
598 if (!$entryFound) {
599 break;
600 }
601 }
602 }
603}
604