<?php

namespace Modules\Additional\Specifique\Client61\Modules\Panier\Service;

use Entity\Model\Centre;
use Entity\Model\CtcCtr;
use Entity\Model\OxaUserPanier;
use Helpers\ChampsSupplementaire\ChampSupp;
use Helpers\Outil\Sql;
use Modules\Panier\Service\PanierEnteteService;
use Modules\Panier\Service\PanierService;

class UpdateValueCtrLivraison
{
    /**
     * @param \PDO $pdo
     */
    public static function initCentreLivraisonSI(\PDO $pdo, ?string $si = null, ?string $idLigne = null, bool $returnValue = false) : bool
    {
        if ($idLigne) {
            return false;
        }
        $newsCentre = ChampSupp::getEnregByValueSpecific([
            'COD_TAB' => 'CENTRE',
            'VALEUR' => $si,
            'typedico' => 'PARNCS0061',
            'codedico' => 'NCS_CENTRE_CODE_CI',
        ], $pdo);

        return (new PanierService($pdo))->initCentre($pdo, $newsCentre['COD_ENR']??'');
    }

    /**
     * @param \PDO $pdo
     */
    public static function initCentreLivraisonCG(\PDO $pdo, ?string $cg = null, ?string $idLigne = null, ?string $codeSte = null) : bool
    {
        if ($idLigne) {
            return false;
        }
        
        $newsCentre = ChampSupp::getEnregByValueSpecific([
            'COD_TAB' => 'CENTRE',
            'VALEUR' => $cg,
            'typedico' => 'PARNCS0061',
            'codedico' => 'NCS_CENTRE_CODE_SITE',
        ], $pdo);

        return (new PanierService($pdo))->initCentre($pdo, $newsCentre['COD_ENR']);
    }
}
