<?php
namespace Modules\Catalogue\Repository;

use Entity\Model\CFormats;
use Helpers\Ariane\Ariane;
use Helpers\QueryBuilder\AbsRepository;
use Skeleton\Controller\Controller;

class CatalogueExterneRepository extends AbsRepository
{
    /**
     * Summary of getListeCatalogue
     * @param array<mixed> $post
     * @return array<mixed>
     */
    public function getListeCatalogue($post)
    {
        $req = "select 
                    CATAENT.*,
                    CFORMATS.DESCFRMT,CFORMATS.TYPDATAS,
                    FOURNISS.RS RS_FRS,
                    GRPFOU.RS RS_GRP,
                    createur.NOM CREATEUR, 
                    modifieur.NOM MODIFIEUR
                from CATAENT with (nolock)
                left join CFORMATS with (nolock) on CFORMATS.IDFORMAT = CATAENT.IDFORMAT
                left join FOURNISS with (nolock) on FOURNISS.CODE = CATAENT.REGRFOUR
                left join GRPFOU with (nolock) on GRPFOU.CODE = CATAENT.REGRFOUR
                left join HASTUTIL createur with (nolock) on createur.CODE = CATAENT.CREATPAR
                left join HASTUTIL modifieur with (nolock) on modifieur.CODE = CATAENT.MODIFPAR
                where 1=1";

        $arrayReq = [];

        $req = $this->applyFilter($req, $arrayReq, $post);

        $paginatorGestion = new \Helpers\Pagination\PaginatorGestion();
        $paginatorGestion->injecterSqlCount(
            $req,
            $post,
            $arrayReq,
            $this->pdo,
            false,
        );

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