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

traduction de COM.MICROSOFT.IFS en CASE WHEN

parent 375f19a6
Loading
Loading
Loading
Loading
+25 −1
Changes for module/Application/src/Model/FormuleCalcul.php: 25 added lines, 1 removed line.
Original line number Diff line number Diff line
@@ -974,6 +974,7 @@ END FORMULE_" . $this->getName() . ";";
            'ISBLANK'           => 'traductionFunctionIsBlank',
            'SUMIF'             => 'traductionFunctionSumIf',
            'MID'               => 'traductionFunctionMid',
            'COM.MICROSOFT.IFS' => 'traductionFunctionIfs',
        ];

        if (array_key_exists($term['name'], $functions)) {
@@ -1024,7 +1025,7 @@ END FORMULE_" . $this->getName() . ";";
        $begin = Calc::cellNameToCoords($range['begin']);
        $end = Calc::cellNameToCoords($range['end']);

        if ($begin['col'] === $end['col'] && $begin['row'] <= $this->mainLine && $end['row'] > 500) {
        if ($begin['col'] === $end['col'] && $begin['row'] <= $this->mainLine && $end['row'] >= 500) {
            $col = Calc::numberToLetter($begin['col']);

            return "calcFnc('$name','$col')";
@@ -1063,6 +1064,29 @@ END FORMULE_" . $this->getName() . ";";



    private function traductionFunctionIfs(array &$expr, int $i): string
    {
        $term = $expr[$i];
        $plsql = 'CASE' . "\n";

        $exprs = $term['exprs'];

        $index = 0;
        while (array_key_exists($index, $exprs)) {
            $test = $exprs[$index];
            $val = $exprs[$index + 1];

            $plsql .= '  WHEN ' . $this->traductionExpr($test) . ' THEN ' . $this->traductionExpr($val) . "\n";
            $index += 2;
        }

        $plsql .= 'END;';

        return $plsql;
    }



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