Commit d175f821 authored by Laurent Lecluse's avatar Laurent Lecluse
Browse files

Ajout du OR

parent 420761c3
Loading
Loading
Loading
Loading
+23 −0
Changes for module/Application/src/Model/FormuleCalcul.php: 23 added lines, 0 removed lines.
Original line number Diff line number Diff line
@@ -889,6 +889,7 @@ END FORMULE_" . $this->getName() . ";";
        $functions = [
            'IF'  => 'traductionFunctionIf',
            'AND' => 'traductionFunctionAnd',
            'OR'  => 'traductionFunctionOr',
        ];

        if (array_key_exists($term['name'], $functions)) {
@@ -1000,6 +1001,28 @@ END FORMULE_" . $this->getName() . ";";



    private function traductionFunctionOr(array &$expr, int $i): string
    {
        $term  = $expr[$i];
        $plsql = '';

        if (!empty($term['exprs'])) {
            $plExprs = [];
            foreach ($term['exprs'] as $e => $fExpr) {
                $plExprs[$e] = $this->traductionExpr($fExpr);
            }
            $plsql .= implode(' OR ', $plExprs);
        }

        if (count($expr) === 1) {
            return $plsql;
        } else {
            return '(' . $plsql . ')';
        }
    }



    private function indent(string $plsql, int $levels = 1): string
    {