Merge pull request #11712 from jitendrapurohit/CRM-21795
[civicrm-core.git] / CRM / Report / Form / Contribute / Sybunt.php
1 <?php
2 /*
3 +--------------------------------------------------------------------+
4 | CiviCRM version 4.7 |
5 +--------------------------------------------------------------------+
6 | Copyright CiviCRM LLC (c) 2004-2018 |
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-2018
32 */
33 class CRM_Report_Form_Contribute_Sybunt extends CRM_Report_Form {
34
35 protected $_charts = array(
36 '' => 'Tabular',
37 'barChart' => 'Bar Chart',
38 'pieChart' => 'Pie Chart',
39 );
40
41 protected $_customGroupExtends = array(
42 'Contact',
43 'Individual',
44 'Contribution',
45 );
46
47 public $_drilldownReport = array('contribute/detail' => 'Link to Detail Report');
48
49 /**
50 * This report has been optimised for group filtering.
51 *
52 * CRM-19170
53 *
54 * @var bool
55 */
56 protected $groupFilterNotOptimised = FALSE;
57
58 /**
59 * Class constructor.
60 */
61 public function __construct() {
62 $this->_rollup = 'WITH ROLLUP';
63 $this->_autoIncludeIndexedFieldsAsOrderBys = 1;
64 $yearsInPast = 10;
65 $yearsInFuture = 1;
66 $date = CRM_Core_SelectValues::date('custom', NULL, $yearsInPast, $yearsInFuture);
67 $count = $date['maxYear'];
68 while ($date['minYear'] <= $count) {
69 $optionYear[$date['minYear']] = $date['minYear'];
70 $date['minYear']++;
71 }
72
73 // Check if CiviCampaign is a) enabled and b) has active campaigns
74 $config = CRM_Core_Config::singleton();
75 $campaignEnabled = in_array("CiviCampaign", $config->enableComponents);
76 if ($campaignEnabled) {
77 $getCampaigns = CRM_Campaign_BAO_Campaign::getPermissionedCampaigns(NULL, NULL, TRUE, FALSE, TRUE);
78 $this->activeCampaigns = $getCampaigns['campaigns'];
79 asort($this->activeCampaigns);
80 }
81
82 $this->_columns = array(
83 'civicrm_contact' => array(
84 'dao' => 'CRM_Contact_DAO_Contact',
85 'grouping' => 'contact-field',
86 'fields' => array(
87 'sort_name' => array(
88 'title' => ts('Donor Name'),
89 'required' => TRUE,
90 ),
91 'first_name' => array(
92 'title' => ts('First Name'),
93 ),
94 'middle_name' => array(
95 'title' => ts('Middle Name'),
96 ),
97 'last_name' => array(
98 'title' => ts('Last Name'),
99 ),
100 'id' => array(
101 'no_display' => TRUE,
102 'required' => TRUE,
103 ),
104 'gender_id' => array(
105 'title' => ts('Gender'),
106 ),
107 'birth_date' => array(
108 'title' => ts('Birth Date'),
109 ),
110 'age' => array(
111 'title' => ts('Age'),
112 'dbAlias' => 'TIMESTAMPDIFF(YEAR, contact_civireport.birth_date, CURDATE())',
113 ),
114 'contact_type' => array(
115 'title' => ts('Contact Type'),
116 ),
117 'contact_sub_type' => array(
118 'title' => ts('Contact Subtype'),
119 ),
120 ),
121 'order_bys' => array(
122 'sort_name' => array(
123 'title' => ts('Last Name, First Name'),
124 'default' => '1',
125 'default_weight' => '0',
126 'default_order' => 'ASC',
127 ),
128 'first_name' => array(
129 'name' => 'first_name',
130 'title' => ts('First Name'),
131 ),
132 'gender_id' => array(
133 'name' => 'gender_id',
134 'title' => ts('Gender'),
135 ),
136 'birth_date' => array(
137 'name' => 'birth_date',
138 'title' => ts('Birth Date'),
139 ),
140 'age_at_event' => array(
141 'name' => 'age_at_event',
142 'title' => ts('Age at Event'),
143 ),
144 'contact_type' => array(
145 'title' => ts('Contact Type'),
146 ),
147 'contact_sub_type' => array(
148 'title' => ts('Contact Subtype'),
149 ),
150 ),
151 'filters' => array(
152 'sort_name' => array(
153 'title' => ts('Donor Name'),
154 'operator' => 'like',
155 ),
156 'id' => array(
157 'title' => ts('Contact ID'),
158 'no_display' => TRUE,
159 ),
160 'gender_id' => array(
161 'title' => ts('Gender'),
162 'operatorType' => CRM_Report_Form::OP_MULTISELECT,
163 'options' => CRM_Core_PseudoConstant::get('CRM_Contact_DAO_Contact', 'gender_id'),
164 ),
165 'birth_date' => array(
166 'title' => ts('Birth Date'),
167 'operatorType' => CRM_Report_Form::OP_DATE,
168 ),
169 'contact_type' => array(
170 'title' => ts('Contact Type'),
171 ),
172 'contact_sub_type' => array(
173 'title' => ts('Contact Subtype'),
174 ),
175 ),
176 ),
177 'civicrm_line_item' => array(
178 'dao' => 'CRM_Price_DAO_LineItem',
179 ),
180 'civicrm_email' => array(
181 'dao' => 'CRM_Core_DAO_Email',
182 'grouping' => 'contact-field',
183 'fields' => array(
184 'email' => array(
185 'title' => ts('Email'),
186 'default' => TRUE,
187 ),
188 ),
189 ),
190 'civicrm_phone' => array(
191 'dao' => 'CRM_Core_DAO_Phone',
192 'grouping' => 'contact-field',
193 'fields' => array(
194 'phone' => array(
195 'title' => ts('Phone'),
196 'default' => TRUE,
197 ),
198 ),
199 ),
200 );
201 $this->_columns += $this->addAddressFields();
202 $this->_columns += array(
203 'civicrm_contribution' => array(
204 'dao' => 'CRM_Contribute_DAO_Contribution',
205 'fields' => array(
206 'contact_id' => array(
207 'title' => ts('contactId'),
208 'no_display' => TRUE,
209 'required' => TRUE,
210 'no_repeat' => TRUE,
211 ),
212 'total_amount' => array(
213 'title' => ts('Total Amount'),
214 'no_display' => TRUE,
215 'required' => TRUE,
216 'no_repeat' => TRUE,
217 ),
218 'receive_date' => array(
219 'title' => ts('Year'),
220 'no_display' => TRUE,
221 'required' => TRUE,
222 'no_repeat' => TRUE,
223 ),
224 ),
225 'filters' => array(
226 'yid' => array(
227 'name' => 'receive_date',
228 'title' => ts('This Year'),
229 'operatorType' => CRM_Report_Form::OP_SELECT,
230 'options' => $optionYear,
231 'default' => date('Y'),
232 'type' => CRM_Utils_Type::T_INT,
233 ),
234 'financial_type_id' => array(
235 'title' => ts('Financial Type'),
236 'type' => CRM_Utils_Type::T_INT,
237 'operatorType' => CRM_Report_Form::OP_MULTISELECT,
238 'options' => CRM_Financial_BAO_FinancialType::getAvailableFinancialTypes(),
239 ),
240 'contribution_status_id' => array(
241 'title' => ts('Contribution Status'),
242 'operatorType' => CRM_Report_Form::OP_MULTISELECT,
243 'options' => CRM_Contribute_PseudoConstant::contributionStatus(),
244 'default' => array('1'),
245 ),
246 ),
247 ),
248 );
249 $this->_columns += array(
250 'civicrm_financial_trxn' => array(
251 'dao' => 'CRM_Financial_DAO_FinancialTrxn',
252 'fields' => array(
253 'card_type_id' => array(
254 'title' => ts('Credit Card Type'),
255 'dbAlias' => 'GROUP_CONCAT(financial_trxn_civireport.card_type_id SEPARATOR ",")',
256 ),
257 ),
258 'filters' => array(
259 'card_type_id' => array(
260 'title' => ts('Credit Card Type'),
261 'operatorType' => CRM_Report_Form::OP_MULTISELECT,
262 'default' => NULL,
263 'options' => CRM_Financial_DAO_FinancialTrxn::buildOptions('card_type_id'),
264 'type' => CRM_Utils_Type::T_STRING,
265 ),
266 ),
267 ),
268 );
269
270 // If we have a campaign, build out the relevant elements
271 if ($campaignEnabled && !empty($this->activeCampaigns)) {
272 $this->_columns['civicrm_contribution']['fields']['campaign_id'] = array(
273 'title' => ts('Campaign'),
274 'default' => 'false',
275 );
276 $this->_columns['civicrm_contribution']['filters']['campaign_id'] = array(
277 'title' => ts('Campaign'),
278 'operatorType' => CRM_Report_Form::OP_MULTISELECT,
279 'options' => $this->activeCampaigns,
280 'type' => CRM_Utils_Type::T_INT,
281 );
282 }
283
284 $this->_groupFilter = TRUE;
285 $this->_tagFilter = TRUE;
286 parent::__construct();
287 }
288
289 public function preProcess() {
290 parent::preProcess();
291 }
292
293 public function select() {
294 $select = array();
295 $this->_columnHeaders = array();
296 $current_year = $this->_params['yid_value'];
297 $previous_year = $current_year - 1;
298 $previous_pyear = $current_year - 2;
299 $previous_ppyear = $current_year - 3;
300 $upTo_year = $current_year - 4;
301
302 foreach ($this->_columns as $tableName => $table) {
303 if (array_key_exists('fields', $table)) {
304 foreach ($table['fields'] as $fieldName => $field) {
305
306 if (!empty($field['required']) ||
307 !empty($this->_params['fields'][$fieldName])
308 ) {
309 if ($fieldName == 'total_amount') {
310 $select[] = "SUM({$field['dbAlias']}) as {$tableName}_{$fieldName}";
311
312 $this->_columnHeaders["civicrm_upto_{$upTo_year}"]['type'] = $field['type'];
313 $this->_columnHeaders["civicrm_upto_{$upTo_year}"]['title'] = ts("Up To %1", array(1 => $upTo_year));
314
315 $this->_columnHeaders["year_{$previous_ppyear}"]['type'] = $field['type'];
316 $this->_columnHeaders["year_{$previous_ppyear}"]['title'] = $previous_ppyear;
317
318 $this->_columnHeaders["year_{$previous_pyear}"]['type'] = $field['type'];
319 $this->_columnHeaders["year_{$previous_pyear}"]['title'] = $previous_pyear;
320
321 $this->_columnHeaders["year_{$previous_year}"]['type'] = $field['type'];
322 $this->_columnHeaders["year_{$previous_year}"]['title'] = $previous_year;
323
324 $this->_columnHeaders["civicrm_life_time_total"]['type'] = $field['type'];
325 $this->_columnHeaders["civicrm_life_time_total"]['title'] = ts('LifeTime');
326 }
327 elseif ($fieldName == 'receive_date') {
328 $select[] = self::fiscalYearOffset($field['dbAlias']) .
329 " as {$tableName}_{$fieldName}";
330 }
331 else {
332 $select[] = "{$field['dbAlias']} as {$tableName}_{$fieldName}";
333 $this->_columnHeaders["{$tableName}_{$fieldName}"]['type'] = CRM_Utils_Array::value('type', $field);
334 $this->_columnHeaders["{$tableName}_{$fieldName}"]['title'] = $field['title'];
335 }
336 if (!empty($field['no_display'])) {
337 $this->_columnHeaders["{$tableName}_{$fieldName}"]['no_display'] = TRUE;
338 }
339 }
340 }
341 }
342 }
343 $this->_selectClauses = $select;
344
345 $this->_select = "SELECT " . implode(', ', $select) . " ";
346 }
347
348 public function from() {
349 $this->setFromBase('civicrm_contribution', 'contact_id');
350 $this->_from .= "
351 INNER JOIN civicrm_contact {$this->_aliases['civicrm_contact']}
352 ON {$this->_aliases['civicrm_contact']}.id = {$this->_aliases['civicrm_contribution']}.contact_id
353 {$this->_aclFrom}";
354
355 if ($this->isTableSelected('civicrm_email')) {
356 $this->_from .= "
357 LEFT JOIN civicrm_email {$this->_aliases['civicrm_email']}
358 ON {$this->_aliases['civicrm_contact']}.id = {$this->_aliases['civicrm_email']}.contact_id
359 AND {$this->_aliases['civicrm_email']}.is_primary = 1";
360 }
361 if ($this->isTableSelected('civicrm_phone')) {
362 $this->_from .= "
363 LEFT JOIN civicrm_phone {$this->_aliases['civicrm_phone']}
364 ON {$this->_aliases['civicrm_contact']}.id = {$this->_aliases['civicrm_phone']}.contact_id AND
365 {$this->_aliases['civicrm_phone']}.is_primary = 1";
366 }
367 // for credit card type
368 $this->addFinancialTrxnFromClause();
369
370 $this->addAddressFromClause();
371 }
372
373 public function where() {
374 $this->_statusClause = "";
375 $clauses = array($this->_aliases['civicrm_contribution'] . '.is_test = 0');
376 foreach ($this->_columns as $tableName => $table) {
377 if (array_key_exists('filters', $table)) {
378 foreach ($table['filters'] as $fieldName => $field) {
379 $clause = NULL;
380 if ($fieldName == 'yid') {
381 $clause = "contribution_civireport.contact_id NOT IN
382 (SELECT distinct cont.id FROM civicrm_contact cont, civicrm_contribution contri
383 WHERE cont.id = contri.contact_id AND " .
384 self::fiscalYearOffset('contri.receive_date') .
385 " = {$this->_params['yid_value']} AND contri.is_test = 0 )";
386 }
387 elseif (CRM_Utils_Array::value('type', $field) & CRM_Utils_Type::T_DATE
388 ) {
389 $relative = CRM_Utils_Array::value("{$fieldName}_relative", $this->_params);
390 $from = CRM_Utils_Array::value("{$fieldName}_from", $this->_params);
391 $to = CRM_Utils_Array::value("{$fieldName}_to", $this->_params);
392
393 if ($relative || $from || $to) {
394 $clause = $this->dateClause($field['name'], $relative, $from, $to, $field['type']);
395 }
396 }
397 else {
398 $op = CRM_Utils_Array::value("{$fieldName}_op", $this->_params);
399 if ($op) {
400 $clause = $this->whereClause($field,
401 $op,
402 CRM_Utils_Array::value("{$fieldName}_value", $this->_params),
403 CRM_Utils_Array::value("{$fieldName}_min", $this->_params),
404 CRM_Utils_Array::value("{$fieldName}_max", $this->_params)
405 );
406 if (($fieldName == 'contribution_status_id' ||
407 $fieldName == 'financial_type_id') && !empty($clause)
408 ) {
409 $this->_statusClause .= " AND " . $clause;
410 }
411 }
412 }
413
414 if (!empty($clause)) {
415 $clauses[] = $clause;
416 }
417 }
418 }
419 }
420
421 $this->_where = "WHERE " . implode(' AND ', $clauses);
422
423 if ($this->_aclWhere) {
424 $this->_where .= " AND {$this->_aclWhere} ";
425 }
426 }
427
428 public function groupBy() {
429 $this->assign('chartSupported', TRUE);
430 $fiscalYearOffset = self::fiscalYearOffset("{$this->_aliases['civicrm_contribution']}.receive_date");
431 $this->_groupBy = "GROUP BY {$this->_aliases['civicrm_contribution']}.contact_id, {$fiscalYearOffset}";
432 $this->_select = CRM_Contact_BAO_Query::appendAnyValueToSelect($this->_selectClauses, array("{$this->_aliases['civicrm_contribution']}.contact_id", $fiscalYearOffset));
433 $this->_groupBy .= " {$this->_rollup}";
434 }
435
436 /**
437 * @param $rows
438 *
439 * @return array
440 */
441 public function statistics(&$rows) {
442 $statistics = parent::statistics($rows);
443
444 if (!empty($rows)) {
445 $select = "
446 SELECT
447 SUM({$this->_aliases['civicrm_contribution']}.total_amount ) as amount ";
448
449 $sql = "{$select} {$this->_from} {$this->_where}";
450 $dao = CRM_Core_DAO::executeQuery($sql);
451 if ($dao->fetch()) {
452 $statistics['counts']['amount'] = array(
453 'value' => $dao->amount,
454 'title' => ts('Total LifeTime'),
455 'type' => CRM_Utils_Type::T_MONEY,
456 );
457 }
458 }
459 return $statistics;
460 }
461
462 public function postProcess() {
463 // get ready with post process params
464 $this->beginPostProcess();
465 $this->buildACLClause($this->_aliases['civicrm_contact']);
466 $this->buildQuery();
467
468 $rows = $contactIds = array();
469 if (empty($this->_params['charts'])) {
470 $this->limit();
471 $getContacts = "SELECT SQL_CALC_FOUND_ROWS {$this->_aliases['civicrm_contact']}.id as cid {$this->_from} {$this->_where} GROUP BY {$this->_aliases['civicrm_contact']}.id {$this->_limit}";
472
473 $dao = CRM_Core_DAO::executeQuery($getContacts);
474
475 while ($dao->fetch()) {
476 $contactIds[] = $dao->cid;
477 }
478 $dao->free();
479 $this->setPager();
480 }
481
482 if (!empty($contactIds) || !empty($this->_params['charts'])) {
483 if (!empty($this->_params['charts'])) {
484 $sql = "{$this->_select} {$this->_from} {$this->_where} {$this->_groupBy}";
485 }
486 else {
487 $sql = "" .
488 "{$this->_select} {$this->_from} WHERE {$this->_aliases['civicrm_contact']}.id IN (" .
489 implode(',', $contactIds) .
490 ") AND {$this->_aliases['civicrm_contribution']}.is_test = 0 {$this->_statusClause} {$this->_groupBy} ";
491 }
492
493 $current_year = $this->_params['yid_value'];
494 $previous_year = $current_year - 1;
495 $previous_pyear = $current_year - 2;
496 $previous_ppyear = $current_year - 3;
497 $upTo_year = $current_year - 4;
498
499 $rows = $row = array();
500 $dao = CRM_Core_DAO::executeQuery($sql);
501 $contributionSum = 0;
502 $yearcal = array();
503 while ($dao->fetch()) {
504 if (!$dao->civicrm_contribution_contact_id) {
505 continue;
506 }
507 $row = array();
508 foreach ($this->_columnHeaders as $key => $value) {
509 if (property_exists($dao, $key)) {
510 $rows[$dao->civicrm_contribution_contact_id][$key] = $dao->$key;
511 }
512 }
513 if ($dao->civicrm_contribution_receive_date) {
514 if ($dao->civicrm_contribution_receive_date > $upTo_year) {
515 $contributionSum += $dao->civicrm_contribution_total_amount;
516 $rows[$dao->civicrm_contribution_contact_id]['year_' . $dao->civicrm_contribution_receive_date] = $dao->civicrm_contribution_total_amount;
517 }
518 }
519 else {
520 $rows[$dao->civicrm_contribution_contact_id]['civicrm_life_time_total'] = $dao->civicrm_contribution_total_amount;
521 if (($dao->civicrm_contribution_total_amount - $contributionSum) > 0
522 ) {
523 $rows[$dao->civicrm_contribution_contact_id]["civicrm_upto_{$upTo_year}"]
524 = $dao->civicrm_contribution_total_amount - $contributionSum;
525 }
526 $contributionSum = 0;
527 }
528 }
529 $dao->free();
530 }
531 // format result set.
532 $this->formatDisplay($rows, FALSE);
533
534 // assign variables to templates
535 $this->doTemplateAssignment($rows);
536
537 // do print / pdf / instance stuff if needed
538 $this->endPostProcess($rows);
539 }
540
541 /**
542 * @param $rows
543 */
544 public function buildChart(&$rows) {
545 $graphRows = array();
546 $count = 0;
547 $current_year = $this->_params['yid_value'];
548 $previous_year = $current_year - 1;
549 $previous_two_year = $current_year - 2;
550 $previous_three_year = $current_year - 3;
551 $upto = $current_year - 4;
552
553 $interval[$previous_year] = $previous_year;
554 $interval[$previous_two_year] = $previous_two_year;
555 $interval[$previous_three_year] = $previous_three_year;
556 $interval["upto_{$upto}"] = "Up To {$upto}";
557
558 foreach ($rows as $key => $row) {
559 $display["upto_{$upto}"]
560 = CRM_Utils_Array::value("upto_{$upto}", $display) + CRM_Utils_Array::value("civicrm_upto_{$upto}", $row);
561 $display[$previous_year]
562 = CRM_Utils_Array::value($previous_year, $display) + CRM_Utils_Array::value($previous_year, $row);
563 $display[$previous_two_year]
564 = CRM_Utils_Array::value($previous_two_year, $display) + CRM_Utils_Array::value($previous_two_year, $row);
565 $display[$previous_three_year]
566 = CRM_Utils_Array::value($previous_three_year, $display) + CRM_Utils_Array::value($previous_three_year, $row);
567 }
568
569 $graphRows['value'] = $display;
570 $config = CRM_Core_Config::Singleton();
571 $chartInfo = array(
572 'legend' => 'Sybunt Report',
573 'xname' => 'Year',
574 'yname' => "Amount ({$config->defaultCurrency})",
575 );
576 if ($this->_params['charts']) {
577 // build the chart.
578 CRM_Utils_OpenFlashChart::reportChart($graphRows, $this->_params['charts'], $interval, $chartInfo);
579 $this->assign('chartType', $this->_params['charts']);
580 }
581 }
582
583 /**
584 * Alter display of rows.
585 *
586 * Iterate through the rows retrieved via SQL and make changes for display purposes,
587 * such as rendering contacts as links.
588 *
589 * @param array $rows
590 * Rows generated by SQL, with an array for each row.
591 */
592 public function alterDisplay(&$rows) {
593 $entryFound = FALSE;
594
595 foreach ($rows as $rowNum => $row) {
596 //Convert Display name into link
597 if (array_key_exists('civicrm_contact_sort_name', $row) &&
598 array_key_exists('civicrm_contribution_contact_id', $row)
599 ) {
600 $url = CRM_Report_Utils_Report::getNextUrl('contribute/detail',
601 'reset=1&force=1&id_op=eq&id_value=' .
602 $row['civicrm_contribution_contact_id'],
603 $this->_absoluteUrl, $this->_id, $this->_drilldownReport
604 );
605 $rows[$rowNum]['civicrm_contact_sort_name_link'] = $url;
606 $rows[$rowNum]['civicrm_contact_sort_name_hover'] = ts("View Contribution Details for this Contact.");
607 $entryFound = TRUE;
608 }
609
610 // convert campaign_id to campaign title
611 if (array_key_exists('civicrm_contribution_campaign_id', $row)) {
612 if ($value = $row['civicrm_contribution_campaign_id']) {
613 $rows[$rowNum]['civicrm_contribution_campaign_id'] = $this->activeCampaigns[$value];
614 $entryFound = TRUE;
615 }
616 }
617
618 $entryFound = $this->alterDisplayAddressFields($row, $rows, $rowNum, 'contribute/detail', 'List all contribution(s)') ? TRUE : $entryFound;
619
620 //handle gender
621 if (array_key_exists('civicrm_contact_gender_id', $row)) {
622 if ($value = $row['civicrm_contact_gender_id']) {
623 $gender = CRM_Core_PseudoConstant::get('CRM_Contact_DAO_Contact', 'gender_id');
624 $rows[$rowNum]['civicrm_contact_gender_id'] = $gender[$value];
625 }
626 $entryFound = TRUE;
627 }
628
629 // display birthday in the configured custom format
630 if (array_key_exists('civicrm_contact_birth_date', $row)) {
631 $birthDate = $row['civicrm_contact_birth_date'];
632 if ($birthDate) {
633 $rows[$rowNum]['civicrm_contact_birth_date'] = CRM_Utils_Date::customFormat($birthDate, '%Y%m%d');
634 }
635 $entryFound = TRUE;
636 }
637
638 if (!empty($row['civicrm_financial_trxn_card_type_id'])) {
639 $rows[$rowNum]['civicrm_financial_trxn_card_type_id'] = $this->getLabels($row['civicrm_financial_trxn_card_type_id'], 'CRM_Financial_DAO_FinancialTrxn', 'card_type_id');
640 $entryFound = TRUE;
641 }
642
643 // skip looking further in rows, if first row itself doesn't
644 // have the column we need
645 if (!$entryFound) {
646 break;
647 }
648 }
649 }
650
651 /**
652 * Override "This Year" $op options
653 * @param string $type
654 * @param null $fieldName
655 *
656 * @return array
657 */
658 public function getOperationPair($type = "string", $fieldName = NULL) {
659 if ($fieldName == 'yid') {
660 return array(
661 'calendar' => ts('Is Calendar Year'),
662 'fiscal' => ts('Fiscal Year Starting'),
663 );
664 }
665 return parent::getOperationPair($type, $fieldName);
666 }
667
668 }