From d51e2817a8a850f3ebfb0e7075bafb8fe3580c08 Mon Sep 17 00:00:00 2001 From: "deb.monish" Date: Mon, 12 Jun 2017 19:45:25 +0530 Subject: [PATCH] CRM-20721: Add parameter to dateQueryBuilder fn to change date value to desired format --- CRM/Contact/BAO/Query.php | 16 +++++++++------- 1 file changed, 9 insertions(+), 7 deletions(-) diff --git a/CRM/Contact/BAO/Query.php b/CRM/Contact/BAO/Query.php index 4a8915abc3..715b32c604 100644 --- a/CRM/Contact/BAO/Query.php +++ b/CRM/Contact/BAO/Query.php @@ -5159,11 +5159,13 @@ SELECT COUNT( conts.total_amount ) as cancel_count, * @param string $dbFieldName * @param string $fieldTitle * @param bool $appendTimeStamp + * @param string $dateFormat */ public function dateQueryBuilder( &$values, $tableName, $fieldName, $dbFieldName, $fieldTitle, - $appendTimeStamp = TRUE + $appendTimeStamp = TRUE, + $dateFormat = 'YmdHis' ) { list($name, $op, $value, $grouping, $wildcard) = $values; @@ -5180,7 +5182,7 @@ SELECT COUNT( conts.total_amount ) as cancel_count, if ($name == $fieldName . '_low') { $firstOP = '>='; $firstPhrase = ts('greater than or equal to'); - $firstDate = CRM_Utils_Date::processDate($value); + $firstDate = CRM_Utils_Date::processDate($value, NULL, FALSE, $dateFormat); $secondValues = $this->getWhereValues("{$fieldName}_high", $grouping); if (!empty($secondValues) && $secondValues[2]) { @@ -5191,7 +5193,7 @@ SELECT COUNT( conts.total_amount ) as cancel_count, if ($appendTimeStamp && strlen($secondValue) == 10) { $secondValue .= ' 23:59:59'; } - $secondDate = CRM_Utils_Date::processDate($secondValue); + $secondDate = CRM_Utils_Date::processDate($secondValue, NULL, FALSE, $dateFormat); } } elseif ($name == $fieldName . '_high') { @@ -5201,14 +5203,14 @@ SELECT COUNT( conts.total_amount ) as cancel_count, if ($appendTimeStamp && strlen($value) == 10) { $value .= ' 23:59:59'; } - $firstDate = CRM_Utils_Date::processDate($value); + $firstDate = CRM_Utils_Date::processDate($value, NULL, FALSE, $dateFormat); $secondValues = $this->getWhereValues("{$fieldName}_low", $grouping); if (!empty($secondValues) && $secondValues[2]) { $secondOP = '>='; $secondPhrase = ts('greater than or equal to'); $secondValue = $secondValues[2]; - $secondDate = CRM_Utils_Date::processDate($secondValue); + $secondDate = CRM_Utils_Date::processDate($secondValue, NULL, FALSE, $dateFormat); } } @@ -5249,7 +5251,7 @@ SELECT COUNT( conts.total_amount ) as cancel_count, if (strstr($op, 'IN')) { $format = array(); foreach ($value as &$date) { - $date = CRM_Utils_Date::processDate($date); + $date = CRM_Utils_Date::processDate($date, NULL, FALSE, $dateFormat); if (!$appendTimeStamp) { $date = substr($date, 0, 8); } @@ -5259,7 +5261,7 @@ SELECT COUNT( conts.total_amount ) as cancel_count, $format = implode(', ', $format); } elseif ($value && (!strstr($op, 'NULL') && !strstr($op, 'EMPTY'))) { - $date = CRM_Utils_Date::processDate($value); + $date = CRM_Utils_Date::processDate($value, NULL, FALSE, $dateFormat); if (!$appendTimeStamp) { $date = substr($date, 0, 8); } -- 2.25.1