<?php

namespace Modules\Additional\Specifique\Client128\Modules\BonsDeReception\Repository;

use Helpers\QueryBuilder\AbsRepository;
use PDO;

class CreationBR extends AbsRepository
{
    /**
     * __construct
     */
    public function __construct(PDO $pdo)
    {
        parent::__construct($pdo);
    }

    /**
     * amountReceipt
     *
     * @param  string $order
     * @return array<mixed>
     */
    public function amountReceipt(string $order): array
    {
        $query = "SELECT cs.VALEUR 
        FROM CA_ENTET ca with(nolock), CS_DON cs with(nolock)
        WHERE NO_CDE = :NO_CDE 
            AND cs.COD_TAB = 'TYPDOC' 
            AND cs.COD_ENR = ca.TYP_DOC 
            AND cs.NUM_FIX = 
                (
                    SELECT LIB01DICO 
                    FROM DILISPEC with(nolock)
                    WHERE TYPEDICO ='PARNCS0128' 
                        AND CODEDICO = 'NCS_TYPDOC_RECEP_EN_MT'
                )";

        $params = [
            ':NO_CDE' => $order
        ];

        return $this->fetchAssocOne($query, $params);
    }
}
