* @param string $fieldName
* @param string $op
* @param array|string|int $value
+ *
+ * @throws \CiviCRM_API3_Exception
*/
public static function decodeRelativeFields(&$formValues, $fieldName, $op, $value) {
// check if its a custom date field, if yes then 'searchDate' format the value
- $isCustomDateField = CRM_Contact_BAO_Query::isCustomDateField($fieldName);
-
- // select date range as default
- if ($isCustomDateField) {
- if (array_key_exists('relative_dates', $formValues) && array_key_exists($fieldName, $formValues['relative_dates'])) {
- $formValues[$fieldName . '_relative'] = $formValues['relative_dates'][$fieldName];
- }
- else {
- $formValues[$fieldName . '_relative'] = 0;
- }
+ if (CRM_Contact_BAO_Query::isCustomDateField($fieldName)) {
+ return;
}
+
switch ($op) {
case 'BETWEEN':
- if ($isCustomDateField) {
- list($formValues[$fieldName . '_from'], $formValues[$fieldName . '_from_time']) = CRM_Utils_Date::setDateDefaults($value[0], 'searchDate');
- list($formValues[$fieldName . '_to'], $formValues[$fieldName . '_to_time']) = CRM_Utils_Date::setDateDefaults($value[1], 'searchDate');
- }
- else {
- list($formValues[$fieldName . '_from'], $formValues[$fieldName . '_to']) = $value;
- }
+ list($formValues[$fieldName . '_from'], $formValues[$fieldName . '_to']) = $value;
break;
case '>=':
- if ($isCustomDateField) {
- list($formValues[$fieldName . '_from'], $formValues[$fieldName . '_from_time']) = CRM_Utils_Date::setDateDefaults($value, 'searchDate');
- }
- else {
- $formValues[$fieldName . '_from'] = $value;
- }
+ $formValues[$fieldName . '_from'] = $value;
break;
case '<=':
- if ($isCustomDateField) {
- list($formValues[$fieldName . '_to'], $formValues[$fieldName . '_to_time']) = CRM_Utils_Date::setDateDefaults($value, 'searchDate');
- }
- else {
- $formValues[$fieldName . '_to'] = $value;
- }
+ $formValues[$fieldName . '_to'] = $value;
break;
}
}