From d4d7759aae065cd8a321ae8605534bc802a22051 Mon Sep 17 00:00:00 2001 From: Enric Prats Date: Fri, 27 Dec 2024 09:42:59 +0000 Subject: [PATCH] notqual corrected --- modules/KReports/KReportQuery.php | 42 +++++++++++++++++++++++++--- modules/KReports/js/kreportsbase2.js | 11 ++++++++ 2 files changed, 49 insertions(+), 4 deletions(-) diff --git a/modules/KReports/KReportQuery.php b/modules/KReports/KReportQuery.php index 48b0f3098b6..5b0336780f0 100644 --- a/modules/KReports/KReportQuery.php +++ b/modules/KReports/KReportQuery.php @@ -1552,7 +1552,7 @@ function getWhereOperatorClause($operator, $fieldname, $fieldid, $path, $value, // https://github.com/SinergiaTIC/SinergiaCRM/pull/524 // // STIC-Custom EPS 20241205 // // https://github.com/SinergiaTIC/SinergiaCRM/pull/505 - // $db = DBManagerFactory::getInstance(); + $db = DBManagerFactory::getInstance(); // // ENS STIC-Custom // ENS STIC-Custom @@ -1708,11 +1708,34 @@ function getWhereOperatorClause($operator, $fieldname, $fieldid, $path, $value, $thisWhereString .= ' SOUNDS LIKE \'' . $value . '\''; break; case 'notequal': - // STIC-Custom EPS 20241220 - only quote on some operators + // STIC-Custom EPS 20241220 - not equal not working on multi-enum // https://github.com/SinergiaTIC/SinergiaCRM/pull/523 + // $thisWhereString .= ' <> \'' . $value . '\''; $value = $db->quote($value); + if ($this->fieldNameMap[$fieldid]['customFunction'] == '' && $this->fieldNameMap[$fieldid]['sqlFunction'] == '') { + switch ($this->fieldNameMap[$fieldid]['type']) { + case 'multienum': + $thisWhereString .= ' NOT LIKE \'%^' . $value . '^%\''; + $thisWhereString .= ' AND ' . $this->get_field_name($path, $fieldname, $fieldid); + $thisWhereString .= ' NOT LIKE \'' . $value . '^%\''; + $thisWhereString .= ' AND ' . $this->get_field_name($path, $fieldname, $fieldid); + $thisWhereString .= ' NOT LIKE \'%^' . $value . '\''; + $thisWhereString .= ' AND ' . $this->get_field_name($path, $fieldname, $fieldid); + $thisWhereString .= ' <> \'' . $value . '\''; + break; + // case 'date': + // case 'datetime': + // $thisWhereString .= ' = \'' . $GLOBALS['timedate']->to_db_date($value, false) . '\''; + // break; + default: + $thisWhereString .= ' <> \'' . $value . '\''; + break; + } + } + else + $thisWhereString .= ' <> \'' . $value . '\''; + // END STIC-Custom - $thisWhereString .= ' <> \'' . $value . '\''; break; case 'greater': // STIC-Custom EPS 20241220 - only quote on some operators @@ -1837,8 +1860,19 @@ function getWhereOperatorClause($operator, $fieldname, $fieldid, $path, $value, foreach ($valueArray as $thisMultiEnumValue) { if ($multienumWhereString != '') $multienumWhereString .= ' OR ' . $this->get_field_name($path, $fieldname, $fieldid); + // STIC-Custom EPS 20241220 - oneof on multienum was potentially returning incorrect results + // https://github.com/SinergiaTIC/SinergiaCRM/pull/523 + // $multienumWhereString .= ' LIKE \'%' . $thisMultiEnumValue . '%\''; + $multienumWhereString .= ' LIKE \'%^' . $thisMultiEnumValue . '^%\''; + $multienumWhereString .= ' OR ' . $this->get_field_name($path, $fieldname, $fieldid); + $multienumWhereString .= ' LIKE \'' . $thisMultiEnumValue . '^%\''; + $multienumWhereString .= ' OR ' . $this->get_field_name($path, $fieldname, $fieldid); + $multienumWhereString .= ' LIKE \'%^' . $thisMultiEnumValue . '\''; + $multienumWhereString .= ' OR ' . $this->get_field_name($path, $fieldname, $fieldid); + $multienumWhereString .= ' = \'' . $thisMultiEnumValue . '\''; + // END STIC-Custom + - $multienumWhereString .= ' LIKE \'%' . $thisMultiEnumValue . '%\''; } $thisWhereString .= $multienumWhereString; } diff --git a/modules/KReports/js/kreportsbase2.js b/modules/KReports/js/kreportsbase2.js index c77295b652d..5fab3df626c 100644 --- a/modules/KReports/js/kreportsbase2.js +++ b/modules/KReports/js/kreportsbase2.js @@ -464,6 +464,7 @@ var bM = function (e, bH) { case "radioenum": case "dynamicenum": case "multienum": + alert('patata'); if ( e.record.data.operator == "starts" || e.record.data.operator == "notstarts" || @@ -479,6 +480,11 @@ var bM = function (e, bH) { case "oneof": case "oneofnot": case "oneofnotornull": + // STIC-Custom EPS 20241220 - equals & notequal must show multi-select also + // https://github.com/SinergiaTIC/SinergiaCRM/pull/523 + case "equals": + case "notequal": + // END STIC-Custom e.column.setEditor( new Ext.form.ComboBox({ typeAhead: false, @@ -639,6 +645,11 @@ var aL = function (e) { case "oneof": case "oneofnot": case "oneofnotornull": + // STIC-Custom EPS 20241220 - equals & notequal must show multi-select also + // https://github.com/SinergiaTIC/SinergiaCRM/pull/523 + case "equals": + case "notequal": + // END STIC-Custom var cR = e.column.getEditor().getStore(); var dc = ""; for (var i = 0; i < e.value.length; i++) {