From 153b5662d02bc67b4a46a4a3bea117e614b76217 Mon Sep 17 00:00:00 2001 From: Web Access Date: Thu, 14 Apr 2016 17:36:12 +0530 Subject: [PATCH] CRM-18379: QA fix --- CRM/Core/BAO/CustomField.php | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) diff --git a/CRM/Core/BAO/CustomField.php b/CRM/Core/BAO/CustomField.php index 9634e840b4..f4ea4fc68f 100644 --- a/CRM/Core/BAO/CustomField.php +++ b/CRM/Core/BAO/CustomField.php @@ -898,11 +898,16 @@ class CRM_Core_BAO_CustomField extends CRM_Core_DAO_CustomField { case 'Select Date': $attr = array('data-crm-custom' => $dataCrmCustomVal); + //CRM-18379: Fix for date range of 'Select Date' custom field when include in profile. + $minYear = isset($field->start_date_years) ? (date('Y') - $field->start_date_years) : NULL; + $maxYear = isset($field->end_date_years) ? (date('Y') + $field->end_date_years) : NULL; + $params = array( 'date' => $field->date_format, - 'minDate' => isset($field->start_date_years) ? (date('Y') - $field->start_date_years) . '-01-01' : NULL, - 'maxDate' => isset($field->end_date_years) ? (date('Y') + $field->end_date_years) . '-01-01' : NULL, + 'minDate' => isset($minYear) ? $minYear . '-01-01' : NULL, + 'maxDate' => isset($maxYear) ? $maxYear . '-01-01' : NULL, 'time' => $field->time_format ? $field->time_format * 12 : FALSE, + 'yearRange' => "{$minYear}:{$maxYear}", ); if ($field->is_search_range && $search) { $qf->add('datepicker', $elementName . '_from', $label, $attr + array('placeholder' => ts('From')), FALSE, $params); -- 2.25.1