<?php

namespace Modules\Additional\Specifique\Client37\Modules\Suivi\Service;

use Helpers\ChampsSupplementaire\ChampSupp;

class SpecSuiviService
{

    public static function etatSapCDE(\PDO $pdo, string $numCde) : bool
    {
        $req = "SELECT COD_ENR FROM DILISPEC with (nolock), CS_DON with (nolock)
        WHERE DILISPEC.TYPEDICO='PARAMSAP'
                AND DILISPEC.CODEDICO='NCS_CA_ENTET_CA_BLOQUEE'
                AND CS_DON.NUM_FIX=DILISPEC.LIB01DICO
                AND CS_DON.COD_TAB = 'CA_ENTET'
                AND VALEUR='O'
                AND COD_ENR = '".ChampSupp::autoCompletCodeEnr($numCde, null, 'CA_ENTET')."'";

        // $arrayReq[':numCde'] = ChampSupp::autoCompletCodeEnr($numCde, null, 'CA_ENTET');

        $requete = $pdo->prepare($req);
        $requete->execute([]);
        $result = $requete->fetch();

        if ($result) {
            return true;
        } else {
            return false;
        }
    }
}
