<?php

namespace Modules\Stock\Repository;

use Helpers\QueryBuilder\AbsRepository;

class CsDonRepo extends AbsRepository
{
    /**
     * @param string $codTab
     * @param string $codEnr
     * @return array<int,array<string,mixed>>
     */
    public function findAllDuplicableFromCodes(string $codTab, string $codEnr): array
    {
        $requete = "SELECT DISTINCT CD.* FROM CS_DON CD
                    LEFT JOIN CS_CHPS CC ON CD.COD_TAB=CC.COD_TAB AND CD.NUM_FIX=CC.NUM_FIX
                    WHERE CC.NONDUPLI=0x46 AND CD.COD_TAB=:codTab AND CD.COD_ENR=:codEnr";

        $arrayReq = ['codTab' => $codTab, 'codEnr' => $codEnr];

        return $this->fetchAssocAll($requete, $arrayReq);
    }
}
