CRM-18246 Lybunt group clause not being included in temp table due to order of operations
[civicrm-core.git] / CRM / Report / Form / Contribute / Bookkeeping.php
1 <?php
2 /*
3 +--------------------------------------------------------------------+
4 | CiviCRM version 4.7 |
5 +--------------------------------------------------------------------+
6 | Copyright CiviCRM LLC (c) 2004-2015 |
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-2015
32 * $Id$
33 *
34 */
35 class CRM_Report_Form_Contribute_Bookkeeping extends CRM_Report_Form {
36 protected $_addressField = FALSE;
37
38 protected $_emailField = FALSE;
39
40 protected $_summary = NULL;
41
42 protected $_customGroupExtends = array(
43 'Contact',
44 'Individual',
45 'Contribution',
46 'Membership',
47 );
48
49 /**
50 */
51 public function __construct() {
52 $this->_autoIncludeIndexedFieldsAsOrderBys = 1;
53 $this->_columns = array(
54 'civicrm_contact' => array(
55 'dao' => 'CRM_Contact_DAO_Contact',
56 'fields' => array(
57 'sort_name' => array(
58 'title' => ts('Contact Name'),
59 'required' => TRUE,
60 'no_repeat' => TRUE,
61 ),
62 'first_name' => array(
63 'title' => ts('First Name'),
64 ),
65 'middle_name' => array(
66 'title' => ts('Middle Name'),
67 ),
68 'last_name' => array(
69 'title' => ts('Last Name'),
70 ),
71 'id' => array(
72 'no_display' => TRUE,
73 'required' => TRUE,
74 ),
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 ),
85 'contact_type' => array(
86 'title' => ts('Contact Type'),
87 ),
88 'contact_sub_type' => array(
89 'title' => ts('Contact Subtype'),
90 ),
91 ),
92 'grouping' => 'contact-fields',
93 'order_bys' => array(
94 'sort_name' => array(
95 'title' => ts('Last Name, First Name'),
96 'default' => '1',
97 'default_weight' => '0',
98 'default_order' => 'ASC',
99 ),
100 'first_name' => array(
101 'name' => 'first_name',
102 'title' => ts('First Name'),
103 ),
104 'gender_id' => array(
105 'name' => 'gender_id',
106 'title' => ts('Gender'),
107 ),
108 'birth_date' => array(
109 'name' => 'birth_date',
110 'title' => ts('Birth Date'),
111 ),
112 'contact_type' => array(
113 'title' => ts('Contact Type'),
114 ),
115 'contact_sub_type' => array(
116 'title' => ts('Contact Subtype'),
117 ),
118 ),
119 'filters' => array(
120 'sort_name' => array(
121 'title' => ts('Contact Name'),
122 'operator' => 'like',
123 ),
124 'id' => array(
125 'title' => ts('Contact ID'),
126 'no_display' => TRUE,
127 ),
128 'gender_id' => array(
129 'title' => ts('Gender'),
130 'operatorType' => CRM_Report_Form::OP_MULTISELECT,
131 'options' => CRM_Core_PseudoConstant::get('CRM_Contact_DAO_Contact', 'gender_id'),
132 ),
133 'birth_date' => array(
134 'title' => ts('Birth Date'),
135 'operatorType' => CRM_Report_Form::OP_DATE,
136 ),
137 'contact_type' => array(
138 'title' => ts('Contact Type'),
139 ),
140 'contact_sub_type' => array(
141 'title' => ts('Contact Subtype'),
142 ),
143 ),
144 ),
145 'civicrm_membership' => array(
146 'dao' => 'CRM_Member_DAO_Membership',
147 'fields' => array(
148 'id' => array(
149 'title' => ts('Membership #'),
150 'no_display' => TRUE,
151 'required' => TRUE,
152 ),
153 ),
154 ),
155 'civicrm_financial_account' => array(
156 'dao' => 'CRM_Financial_DAO_FinancialAccount',
157 'fields' => array(
158 'debit_accounting_code' => array(
159 'title' => ts('Financial Account Code - Debit'),
160 'name' => 'accounting_code',
161 'alias' => 'financial_account_civireport_debit',
162 'default' => TRUE,
163 ),
164 'credit_accounting_code' => array(
165 'title' => ts('Financial Account Code - Credit'),
166 'name' => 'accounting_code',
167 'alias' => 'financial_account_civireport_credit',
168 'default' => TRUE,
169 ),
170 'debit_name' => array(
171 'title' => ts('Financial Account Name - Debit'),
172 'name' => 'name',
173 'alias' => 'financial_account_civireport_debit',
174 'default' => TRUE,
175 ),
176 'credit_name' => array(
177 'title' => ts('Financial Account Name - Credit'),
178 'name' => 'name',
179 'alias' => 'financial_account_civireport_credit',
180 'default' => TRUE,
181 ),
182 ),
183 'filters' => array(
184 'debit_accounting_code' => array(
185 'title' => ts('Financial Account Code - Debit'),
186 'operatorType' => CRM_Report_Form::OP_MULTISELECT,
187 'options' => CRM_Contribute_PseudoConstant::financialAccount(NULL, NULL, 'accounting_code', 'accounting_code'),
188 'name' => 'accounting_code',
189 'alias' => 'financial_account_civireport_debit',
190 ),
191 'credit_accounting_code' => array(
192 'title' => ts('Financial Account Code - Credit'),
193 'type' => CRM_Utils_Type::T_INT,
194 'operatorType' => CRM_Report_Form::OP_MULTISELECT,
195 'options' => CRM_Contribute_PseudoConstant::financialAccount(NULL, NULL, 'accounting_code', 'accounting_code'),
196 ),
197 'debit_name' => array(
198 'title' => ts('Financial Account Name - Debit'),
199 'type' => CRM_Utils_Type::T_STRING,
200 'operatorType' => CRM_Report_Form::OP_MULTISELECT,
201 'options' => CRM_Contribute_PseudoConstant::financialAccount(),
202 'name' => 'id',
203 'alias' => 'financial_account_civireport_debit',
204 ),
205 'credit_name' => array(
206 'title' => ts('Financial Account Name - Credit'),
207 'type' => CRM_Utils_Type::T_STRING,
208 'operatorType' => CRM_Report_Form::OP_MULTISELECT,
209 'options' => CRM_Contribute_PseudoConstant::financialAccount(),
210 ),
211 ),
212 ),
213 'civicrm_line_item' => array(
214 'dao' => 'CRM_Price_DAO_LineItem',
215 'fields' => array(
216 'financial_type_id' => array(
217 'title' => ts('Financial Type'),
218 'default' => TRUE,
219 ),
220 ),
221 'filters' => array(
222 'financial_type_id' => array(
223 'title' => ts('Financial Type'),
224 'type' => CRM_Utils_Type::T_INT,
225 'operatorType' => CRM_Report_Form::OP_MULTISELECT,
226 'options' => CRM_Financial_BAO_FinancialType::getAvailableFinancialTypes(),
227 ),
228 ),
229 'order_bys' => array(
230 'financial_type_id' => array('title' => ts('Financial Type')),
231 ),
232 ),
233 'civicrm_contribution' => array(
234 'dao' => 'CRM_Contribute_DAO_Contribution',
235 'fields' => array(
236 'receive_date' => array(
237 'default' => TRUE,
238 ),
239 'invoice_id' => array(
240 'title' => ts('Invoice ID'),
241 'default' => TRUE,
242 ),
243 'contribution_status_id' => array(
244 'title' => ts('Contribution Status'),
245 'default' => TRUE,
246 ),
247 'id' => array(
248 'title' => ts('Contribution #'),
249 'default' => TRUE,
250 ),
251 ),
252 'filters' => array(
253 'receive_date' => array('operatorType' => CRM_Report_Form::OP_DATE),
254 'contribution_status_id' => array(
255 'title' => ts('Contribution Status'),
256 'operatorType' => CRM_Report_Form::OP_MULTISELECT,
257 'options' => CRM_Contribute_PseudoConstant::contributionStatus(),
258 'default' => array(1),
259 ),
260 ),
261 'order_bys' => array(
262 'contribution_id' => array('title' => ts('Contribution #')),
263 'contribution_status_id' => array('title' => ts('Contribution Status')),
264 ),
265 'grouping' => 'contri-fields',
266 ),
267 'civicrm_financial_trxn' => array(
268 'dao' => 'CRM_Financial_DAO_FinancialTrxn',
269 'fields' => array(
270 'check_number' => array(
271 'title' => ts('Cheque #'),
272 'default' => TRUE,
273 ),
274 'payment_instrument_id' => array(
275 'title' => ts('Payment Method'),
276 'default' => TRUE,
277 ),
278 'currency' => array(
279 'required' => TRUE,
280 'no_display' => TRUE,
281 ),
282 'trxn_date' => array(
283 'title' => ts('Transaction Date'),
284 'default' => TRUE,
285 'type' => CRM_Utils_Type::T_DATE,
286 ),
287 'trxn_id' => array(
288 'title' => ts('Trans #'),
289 'default' => TRUE,
290 ),
291 ),
292 'filters' => array(
293 'payment_instrument_id' => array(
294 'title' => ts('Payment Method'),
295 'type' => CRM_Utils_Type::T_INT,
296 'operatorType' => CRM_Report_Form::OP_MULTISELECT,
297 'options' => CRM_Contribute_PseudoConstant::paymentInstrument(),
298 ),
299 'currency' => array(
300 'title' => 'Currency',
301 'operatorType' => CRM_Report_Form::OP_MULTISELECT,
302 'options' => CRM_Core_OptionGroup::values('currencies_enabled'),
303 'default' => NULL,
304 'type' => CRM_Utils_Type::T_STRING,
305 ),
306 'trxn_date' => array(
307 'title' => ts('Transaction Date'),
308 'operatorType' => CRM_Report_Form::OP_DATE,
309 'type' => CRM_Utils_Type::T_DATE,
310 ),
311 ),
312 'order_bys' => array(
313 'payment_instrument_id' => array('title' => ts('Payment Method')),
314 ),
315 ),
316 'civicrm_entity_financial_trxn' => array(
317 'dao' => 'CRM_Financial_DAO_EntityFinancialTrxn',
318 'fields' => array(
319 'amount' => array(
320 'title' => ts('Amount'),
321 'default' => TRUE,
322 'type' => CRM_Utils_Type::T_STRING,
323 ),
324 ),
325 'filters' => array(
326 'amount' => array('title' => ts('Amount')),
327 ),
328 ),
329 );
330
331 $this->_groupFilter = TRUE;
332 $this->_tagFilter = TRUE;
333 parent::__construct();
334 }
335
336 public function preProcess() {
337 parent::preProcess();
338 }
339
340 public function select() {
341 $select = array();
342
343 $this->_columnHeaders = array();
344 foreach ($this->_columns as $tableName => $table) {
345 if (array_key_exists('fields', $table)) {
346 foreach ($table['fields'] as $fieldName => $field) {
347 if (!empty($field['required']) ||
348 !empty($this->_params['fields'][$fieldName])
349 ) {
350 switch ($fieldName) {
351 case 'credit_accounting_code':
352 $select[] = " CASE
353 WHEN {$this->_aliases['civicrm_financial_trxn']}.from_financial_account_id IS NOT NULL
354 THEN {$this->_aliases['civicrm_financial_account']}_credit_1.accounting_code
355 ELSE {$this->_aliases['civicrm_financial_account']}_credit_2.accounting_code
356 END AS civicrm_financial_account_credit_accounting_code ";
357 break;
358
359 case 'amount':
360 $select[] = " CASE
361 WHEN {$this->_aliases['civicrm_entity_financial_trxn']}_item.entity_id IS NOT NULL
362 THEN {$this->_aliases['civicrm_entity_financial_trxn']}_item.amount
363 ELSE {$this->_aliases['civicrm_entity_financial_trxn']}.amount
364 END AS civicrm_entity_financial_trxn_amount ";
365 break;
366
367 case 'credit_name':
368 $select[] = " CASE
369 WHEN {$this->_aliases['civicrm_financial_trxn']}.from_financial_account_id IS NOT NULL
370 THEN {$this->_aliases['civicrm_financial_account']}_credit_1.name
371 ELSE {$this->_aliases['civicrm_financial_account']}_credit_2.name
372 END AS civicrm_financial_account_credit_name ";
373 break;
374
375 default:
376 $select[] = "{$field['dbAlias']} as {$tableName}_{$fieldName}";
377 break;
378 }
379 $this->_columnHeaders["{$tableName}_{$fieldName}"]['title'] = $field['title'];
380 $this->_columnHeaders["{$tableName}_{$fieldName}"]['type'] = CRM_Utils_Array::value('type', $field);
381 }
382 }
383 }
384 }
385
386 $this->_select = 'SELECT ' . implode(', ', $select) . ' ';
387 }
388
389 public function from() {
390 $this->_from = NULL;
391
392 $this->_from = "FROM civicrm_contact {$this->_aliases['civicrm_contact']} {$this->_aclFrom}
393 INNER JOIN civicrm_contribution {$this->_aliases['civicrm_contribution']}
394 ON {$this->_aliases['civicrm_contact']}.id = {$this->_aliases['civicrm_contribution']}.contact_id AND
395 {$this->_aliases['civicrm_contribution']}.is_test = 0
396 LEFT JOIN civicrm_membership_payment payment
397 ON ( {$this->_aliases['civicrm_contribution']}.id = payment.contribution_id )
398 LEFT JOIN civicrm_membership {$this->_aliases['civicrm_membership']}
399 ON payment.membership_id = {$this->_aliases['civicrm_membership']}.id
400 LEFT JOIN civicrm_entity_financial_trxn {$this->_aliases['civicrm_entity_financial_trxn']}
401 ON ({$this->_aliases['civicrm_contribution']}.id = {$this->_aliases['civicrm_entity_financial_trxn']}.entity_id AND
402 {$this->_aliases['civicrm_entity_financial_trxn']}.entity_table = 'civicrm_contribution')
403 LEFT JOIN civicrm_financial_trxn {$this->_aliases['civicrm_financial_trxn']}
404 ON {$this->_aliases['civicrm_financial_trxn']}.id = {$this->_aliases['civicrm_entity_financial_trxn']}.financial_trxn_id
405 LEFT JOIN civicrm_financial_account {$this->_aliases['civicrm_financial_account']}_debit
406 ON {$this->_aliases['civicrm_financial_trxn']}.to_financial_account_id = {$this->_aliases['civicrm_financial_account']}_debit.id
407 LEFT JOIN civicrm_financial_account {$this->_aliases['civicrm_financial_account']}_credit_1
408 ON {$this->_aliases['civicrm_financial_trxn']}.from_financial_account_id = {$this->_aliases['civicrm_financial_account']}_credit_1.id
409 LEFT JOIN civicrm_entity_financial_trxn {$this->_aliases['civicrm_entity_financial_trxn']}_item
410 ON ({$this->_aliases['civicrm_financial_trxn']}.id = {$this->_aliases['civicrm_entity_financial_trxn']}_item.financial_trxn_id AND
411 {$this->_aliases['civicrm_entity_financial_trxn']}_item.entity_table = 'civicrm_financial_item')
412 LEFT JOIN civicrm_financial_item fitem
413 ON fitem.id = {$this->_aliases['civicrm_entity_financial_trxn']}_item.entity_id
414 LEFT JOIN civicrm_financial_account {$this->_aliases['civicrm_financial_account']}_credit_2
415 ON fitem.financial_account_id = {$this->_aliases['civicrm_financial_account']}_credit_2.id
416 LEFT JOIN civicrm_line_item {$this->_aliases['civicrm_line_item']}
417 ON fitem.entity_id = {$this->_aliases['civicrm_line_item']}.id AND fitem.entity_table = 'civicrm_line_item' ";
418 $this->getPermissionedFTQuery($this, "civicrm_line_item_1");
419 }
420
421 public function orderBy() {
422 parent::orderBy();
423
424 // please note this will just add the order-by columns to select query, and not display in column-headers.
425 // This is a solution to not throw fatal errors when there is a column in order-by, not present in select/display columns.
426 foreach ($this->_orderByFields as $orderBy) {
427 if (!array_key_exists($orderBy['name'], $this->_params['fields']) &&
428 empty($orderBy['section'])
429 ) {
430 $this->_select .= ", {$orderBy['dbAlias']} as {$orderBy['tplField']}";
431 }
432 }
433 }
434
435 public function where() {
436 foreach ($this->_columns as $tableName => $table) {
437 if (array_key_exists('filters', $table)) {
438 foreach ($table['filters'] as $fieldName => $field) {
439 $clause = NULL;
440 if ($fieldName == 'credit_accounting_code') {
441 $field['dbAlias'] = "CASE
442 WHEN financial_trxn_civireport.from_financial_account_id IS NOT NULL
443 THEN financial_account_civireport_credit_1.accounting_code
444 ELSE financial_account_civireport_credit_2.accounting_code
445 END";
446 }
447 elseif ($fieldName == 'credit_name') {
448 $field['dbAlias'] = "CASE
449 WHEN financial_trxn_civireport.from_financial_account_id IS NOT NULL
450 THEN financial_account_civireport_credit_1.id
451 ELSE financial_account_civireport_credit_2.id
452 END";
453 }
454 if (CRM_Utils_Array::value('type', $field) & CRM_Utils_Type::T_DATE) {
455 $relative = CRM_Utils_Array::value("{$fieldName}_relative", $this->_params);
456 $from = CRM_Utils_Array::value("{$fieldName}_from", $this->_params);
457 $to = CRM_Utils_Array::value("{$fieldName}_to", $this->_params);
458
459 $clause = $this->dateClause($field['name'], $relative, $from, $to, $field['type']);
460 }
461 else {
462 $op = CRM_Utils_Array::value("{$fieldName}_op", $this->_params);
463 if ($op) {
464 $clause = $this->whereClause($field,
465 $op,
466 CRM_Utils_Array::value("{$fieldName}_value", $this->_params),
467 CRM_Utils_Array::value("{$fieldName}_min", $this->_params),
468 CRM_Utils_Array::value("{$fieldName}_max", $this->_params)
469 );
470 }
471 }
472 if (!empty($clause)) {
473 $clauses[] = $clause;
474 }
475 }
476 }
477 }
478 if (empty($clauses)) {
479 $this->_where = 'WHERE ( 1 )';
480 }
481 else {
482 $this->_where = 'WHERE ' . implode(' AND ', $clauses);
483 }
484 }
485
486 public function postProcess() {
487 // get the acl clauses built before we assemble the query
488 $this->buildACLClause($this->_aliases['civicrm_contact']);
489 parent::postProcess();
490 }
491
492 public function groupBy() {
493 $this->_groupBy = " GROUP BY {$this->_aliases['civicrm_entity_financial_trxn']}.id, {$this->_aliases['civicrm_line_item']}.id ";
494 }
495
496 /**
497 * @param $rows
498 *
499 * @return array
500 */
501 public function statistics(&$rows) {
502 $statistics = parent::statistics($rows);
503 $tempTableName = CRM_Core_DAO::createTempTableName('civicrm_contribution');
504 $select = "SELECT {$this->_aliases['civicrm_contribution']}.id, {$this->_aliases['civicrm_entity_financial_trxn']}.id as trxnID, {$this->_aliases['civicrm_contribution']}.currency,
505 CASE
506 WHEN {$this->_aliases['civicrm_entity_financial_trxn']}_item.entity_id IS NOT NULL
507 THEN {$this->_aliases['civicrm_entity_financial_trxn']}_item.amount
508 ELSE {$this->_aliases['civicrm_entity_financial_trxn']}.amount
509 END as amount
510 ";
511
512 $tempQuery = "CREATE TEMPORARY TABLE {$tempTableName} CHARACTER SET utf8 COLLATE utf8_unicode_ci AS
513 {$select} {$this->_from} {$this->_where} {$this->_groupBy} ";
514 CRM_Core_DAO::executeQuery($tempQuery);
515
516 $sql = "SELECT COUNT(trxnID) as count, SUM(amount) as amount, currency
517 FROM {$tempTableName}
518 GROUP BY currency";
519 $dao = CRM_Core_DAO::executeQuery($sql);
520 $amount = $avg = array();
521 while ($dao->fetch()) {
522 $amount[] = CRM_Utils_Money::format($dao->amount, $dao->currency);
523 $avg[] = CRM_Utils_Money::format(round(($dao->amount /
524 $dao->count), 2), $dao->currency);
525 }
526
527 $statistics['counts']['amount'] = array(
528 'value' => implode(', ', $amount),
529 'title' => 'Total Amount',
530 'type' => CRM_Utils_Type::T_STRING,
531 );
532 $statistics['counts']['avg'] = array(
533 'value' => implode(', ', $avg),
534 'title' => 'Average',
535 'type' => CRM_Utils_Type::T_STRING,
536 );
537 return $statistics;
538 }
539
540 /**
541 * Alter display of rows.
542 *
543 * Iterate through the rows retrieved via SQL and make changes for display purposes,
544 * such as rendering contacts as links.
545 *
546 * @param array $rows
547 * Rows generated by SQL, with an array for each row.
548 */
549 public function alterDisplay(&$rows) {
550 $contributionTypes = CRM_Contribute_PseudoConstant::financialType();
551 $paymentInstruments = CRM_Contribute_PseudoConstant::paymentInstrument();
552 $contributionStatus = CRM_Contribute_PseudoConstant::contributionStatus();
553 foreach ($rows as $rowNum => $row) {
554 // convert display name to links
555 if (array_key_exists('civicrm_contact_sort_name', $row) &&
556 !empty($rows[$rowNum]['civicrm_contact_sort_name']) &&
557 array_key_exists('civicrm_contact_id', $row)
558 ) {
559 $url = CRM_Utils_System::url('civicrm/contact/view',
560 'reset=1&cid=' . $row['civicrm_contact_id'],
561 $this->_absoluteUrl
562 );
563 $rows[$rowNum]['civicrm_contact_sort_name_link'] = $url;
564 $rows[$rowNum]['civicrm_contact_sort_name_hover'] = ts('View Contact Summary for this Contact.');
565 }
566
567 // handle contribution status id
568 if ($value = CRM_Utils_Array::value('civicrm_contribution_contribution_status_id', $row)) {
569 $rows[$rowNum]['civicrm_contribution_contribution_status_id'] = $contributionStatus[$value];
570 }
571
572 // handle payment instrument id
573 if ($value = CRM_Utils_Array::value('civicrm_financial_trxn_payment_instrument_id', $row)) {
574 $rows[$rowNum]['civicrm_financial_trxn_payment_instrument_id'] = $paymentInstruments[$value];
575 }
576
577 // handle financial type id
578 if ($value = CRM_Utils_Array::value('civicrm_line_item_financial_type_id', $row)) {
579 $rows[$rowNum]['civicrm_line_item_financial_type_id'] = $contributionTypes[$value];
580 }
581 if ($value = CRM_Utils_Array::value('civicrm_entity_financial_trxn_amount', $row)) {
582 $rows[$rowNum]['civicrm_entity_financial_trxn_amount'] = CRM_Utils_Money::format($rows[$rowNum]['civicrm_entity_financial_trxn_amount'], $rows[$rowNum]['civicrm_financial_trxn_currency']);
583 }
584
585 //handle gender
586 if (array_key_exists('civicrm_contact_gender_id', $row)) {
587 if ($value = $row['civicrm_contact_gender_id']) {
588 $gender = CRM_Core_PseudoConstant::get('CRM_Contact_DAO_Contact', 'gender_id');
589 $rows[$rowNum]['civicrm_contact_gender_id'] = $gender[$value];
590 }
591 $entryFound = TRUE;
592 }
593
594 // display birthday in the configured custom format
595 if (array_key_exists('civicrm_contact_birth_date', $row)) {
596 $birthDate = $row['civicrm_contact_birth_date'];
597 if ($birthDate) {
598 $rows[$rowNum]['civicrm_contact_birth_date'] = CRM_Utils_Date::customFormat($birthDate, '%Y%m%d');
599 }
600 $entryFound = TRUE;
601 }
602
603 }
604 }
605
606 }