Skip to content
Snippets Groups Projects
Commit e62d24b9 authored by Uma's avatar Uma
Browse files

Fixes #1024 ::Uma:: List Conditions on Not equal to was not filtering the records properly

parent 55127e11
No related branches found
No related tags found
1 merge request!456Fixes #1024 ::Uma:: List Conditions on Not equal to was not filtering the records properly
......@@ -667,27 +667,36 @@ class EnhancedQueryGenerator extends QueryGenerator {
}
foreach ($valueSqlList as $valueSql) {
if (in_array($baseFieldName, $this->referenceFieldList)) {
if ($conditionInfo['operator'] == 'y') {
$trim = 'TRIM';
$moduleList = $this->referenceFieldInfoList[$baseFieldName];
if(in_array('Users', $moduleList)) {
$columnSqlTable = 'vtiger_users'.$parentReferenceField.$fieldName;
$columnSql = getSqlForNameInDisplayFormat(array('first_name'=>$columnSqlTable.'.first_name',
'last_name'=>$columnSqlTable.'.last_name'),'Users');
} else if(in_array('DocumentFolders', $moduleList)) {
$columnSql = "vtiger_attachmentsfolder".$fieldName.".foldername";
} else if(in_array('Currency', $moduleList)) {
$columnSql = "vtiger_currency_info$parentReferenceField$fieldName.currency_name";
if($fieldName == 'currency_id' && is_numeric($conditionInfo['value'])){
$columnSql = "vtiger_currency_info$parentReferenceField$fieldName.id";
}
} else if ($baseFieldName == 'roleid'){
$columnSql = 'vtiger_role.rolename';
}else {
$trim = '';
$columnSql = 'vtiger_crmentity'.$parentReferenceField.$fieldName.'.label';
}
if($conditionInfo['operator'] == 'y' || ($conditionInfo['operator'] == 'e' && $valueSql == "= ''")) {
$columnName = $field->getColumnName();
// We are checking for zero since many reference fields will be set to 0 if it doest not have any value
$fieldSql .= "$fieldGlue $tableName.$columnName $valueSql OR $tableName.$columnName = '0'";
// We are checking for NULL as well since for custom relationships if the record is deleted the value will be retained and will not become 0
$fieldSql .= "$fieldGlue $trim($columnSql) IS NULL OR $tableName.$columnName $valueSql OR $tableName.$columnName = '0'";
$fieldGlue = ' OR';
} else {
$moduleList = $this->referenceFieldInfoList[$baseFieldName];
if (in_array('Users', $moduleList)) {
$columnSqlTable = 'vtiger_users'.$parentReferenceField.$fieldName;
$columnSql = getSqlForNameInDisplayFormat(array('first_name' => $columnSqlTable.'.first_name',
'last_name' => $columnSqlTable.'.last_name'), 'Users');
} else if (in_array('DocumentFolders', $moduleList)) {
$columnSql = "vtiger_attachmentsfolder".$fieldName.".foldername";
} else if (in_array('Currency', $moduleList)) {
$columnSql = "vtiger_currency_info$parentReferenceField$fieldName.currency_name";
} else if ($baseFieldName == 'roleid') {
$columnSql = 'vtiger_role.rolename';
} else {
$columnSql = 'vtiger_crmentity'.$parentReferenceField.$fieldName.'.label';
}
$fieldSql .= "$fieldGlue trim($columnSql) $valueSql";
} else if ($conditionInfo['operator'] == 'k' || $conditionInfo['operator'] == 'n') {
$fieldSql .= " $fieldGlue ( $trim($columnSql) $valueSql OR $trim($columnSql) IS NULL )";
$fieldGlue = 'OR';
} else{
$fieldSql .= "$fieldGlue $trim($columnSql) $valueSql";
$fieldGlue = ' OR';
}
} elseif (in_array($baseFieldName, $this->ownerFields)) {
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment