Skip to content

Commit

Permalink
Hotfix - Flujos de trabajo - Evaluar valores vacíos en campos numéric…
Browse files Browse the repository at this point in the history
…os (#8)
  • Loading branch information
enricsinergia authored and AlbertoSTIC committed Jan 18, 2024
1 parent 3120ed9 commit fe01bd4
Showing 1 changed file with 19 additions and 3 deletions.
22 changes: 19 additions & 3 deletions modules/AOW_WorkFlow/AOW_WorkFlow.php
Original file line number Diff line number Diff line change
Expand Up @@ -919,7 +919,7 @@ public function check_valid_bean(SugarBean $bean)
break;
}

if (!($this->compare_condition($field, $value, $condition->operator))) {
if (!($this->compare_condition($field, $value, $condition->operator, $type))) {
return false;
}
}
Expand Down Expand Up @@ -950,8 +950,16 @@ public function check_valid_bean(SugarBean $bean)
return true;
}

public function compare_condition($var1, $var2, $operator = 'Equal_To')
// STIC-Custom 20231228 EPS - numeric null condition does not work properly
// https://github.com/SinergiaTIC/SinergiaCRM/pull/8
// public function compare_condition($var1, $var2, $operator = 'Equal_To')
// {
public function compare_condition($var1, $var2, $operator = 'Equal_To', $type= '')
{

$numericTypes = array('double','decimal','currency','float','uint','ulong','long','short','tinyint','int');
// END STIC-Custom

switch ($operator) {
case "Not_Equal_To": return $var1 != $var2;
case "Greater_Than": return $var1 > $var2;
Expand All @@ -961,7 +969,15 @@ public function compare_condition($var1, $var2, $operator = 'Equal_To')
case "Contains": return strpos(strtolower($var1), strtolower($var2)) !== false;
case "Starts_With": return substr(strtolower($var1), 0, strlen($var2) ) === strtolower($var2);
case "Ends_With": return substr(strtolower($var1), -strlen($var2) ) === strtolower($var2);
case "is_null": return $var1 == '';
// STIC-Custom 20231228 EPS - numeric null condition does not work properly
// https://github.com/SinergiaTIC/SinergiaCRM/pull/8
// case "is_null": return $var1 == '';
case "is_null":
if (in_array($type, $numericTypes) && $var1 == 'NULL') {
$var1 = "";
}
return $var1 == '';
// END STIC-Custom
case "One_of":
if (is_array($var1)) {
foreach ($var1 as $var) {
Expand Down

0 comments on commit fe01bd4

Please sign in to comment.