$op = key($value);
$value = $value[$op];
}
- print_r(strpos($op, 'IN') );
- if ($op == 'IN' || $op == 'NOT IN') {
+ if (strstr($op, 'IN')) {
+ $format = array();
foreach ($value as &$date) {
$date = CRM_Utils_Date::processDate($date);
if (!$appendTimeStamp) {
$date = substr($date, 0, 8);
}
+ $format[] = CRM_Utils_Date::customFormat($date);
}
$date = "('" . implode("','", $value) . "')";
+ $format = implode(', ', $format);
}
else {
$date = CRM_Utils_Date::processDate($value);
$date = substr($date, 0, 8);
}
$date = "'$date'";
+ $format = CRM_Utils_Date::customFormat($date);
}
if ($date) {
$this->_tables[$tableName] = $this->_whereTables[$tableName] = 1;
$op = CRM_Utils_Array::value($op, CRM_Core_SelectValues::getSearchBuilderOperators(), $op);
- $format = CRM_Utils_Date::customFormat($date);
$this->_qill[$grouping][] = "$fieldTitle $op \"$format\"";
}
}
$fldValue = CRM_Utils_Array::value($fldName, $fields);
$fldType = CRM_Utils_Array::value('type', $fldValue);
$type = CRM_Utils_Type::typeToString($fldType);
+
+ if (strstr($v[1], 'IN')) {
+ if (empty($v[2])) {
+ $errorMsg["value[$v[3]][$v[4]]"] = ts("Please enter a value.");
+ }
+ }
// Check Empty values for Integer Or Boolean Or Date type For operators other than IS NULL and IS NOT NULL.
- if (!in_array($v[1],
+ elseif (!in_array($v[1],
array('IS NULL', 'IS NOT NULL', 'IS EMPTY', 'IS NOT EMPTY'))
) {
if ((($type == 'Int' || $type == 'Boolean') && !is_array($v[2]) && !trim($v[2])) && $v[2] != '0') {
if ($type && empty($errorMsg)) {
// check for valid format while using IN Operator
- if ($v[1] == 'IN') {
+ if (strstr($v[1], 'IN')) {
if (!is_array($v[2])) {
$inVal = trim($v[2]);
//checking for format to avoid db errors
$parenValues = array();
$parenValues = is_array($v[2]) ? $v[2] : explode(',', trim($inVal, "(..)"));
foreach ($parenValues as $val) {
- $val = trim($val);
+ if ($type == 'Date' || $type == 'Timestamp') {
+ $val = CRM_Utils_Date::processDate($val);
+ if ($type == 'Date') {
+ $val = substr($val, 0, 8);
+ }
+ }
+ else {
+ $val = trim($val);
+ }
if (!$val && $val != '0') {
$errorMsg["value[$v[3]][$v[4]]"] = ts("Please enter the values correctly.");
}
}
// CRM-14983: verify if values are comma separated convert to array
- if (!is_array($value) && (strpos($value, ',') !== FALSE || strstr($value, '(')) && empty($isCustomField) && $params['operator'][$key][$k] == 'IN') {
- preg_match('#\((.*?)\)#', $value, $match);
- $tmpArray = explode(',', $match[1]);
- $value = array_combine(array_values($tmpArray), array_values($tmpArray));
+ if (strstr($params['operator'][$key][$k], 'IN') && !is_array($value) && (strpos($value, ',') !== FALSE || strstr($value, '(') || !empty($value)) && empty($isCustomField)) {
+ $value = explode(',', str_replace(array('(', ')'), '', $value));
}
if ($row) {