<?php

namespace Modules\Parametrage\Oxaproc\Repository;

use Helpers\QueryBuilder\AbsRepository;

class ParametrageOxaproc extends AbsRepository
{

    /**
     * listeParamChpsFrsOxaproc
     *
     * @param  bool $all
     * @param  string $bloc
     * @return array<mixed>
     */
    public function listeParamChpsFrsOxaproc(bool $all = true, string $bloc = ''): ?array
    {
        $req = '' ;
        if ($all) {
            $req = "select * from PARAMDICO with (nolock) where (TYPEDICO= :type_dico1 or TYPEDICO= :type_dico2)";
            $arrayReq =
            [
                ':type_dico1' => 'OXAPROC_FOURN_CHP',
                ':type_dico2' => 'OXAPROC_FOURN_STR',
            
            ];
        } else {
            $req = "select * from PARAMDICO with (nolock) where TYPEDICO= :type_dico1";

            $arrayReq =
            [
                ':type_dico1' => 'OXAPROC_FOURN_CHP',
            
            ];
        }
        if ($bloc != '') {
            $req .= ' and ID3 = :ID3';
            $arrayReq[':ID3'] = $bloc;
        }

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

    /**
     * @return array<mixed>
     */
    public function getListeParamOxaproc()
    {
        $req = "select * from PARAVRAC with (nolock) 
                where TYPEPARV in ('OXAPROC', 'GEST_FOURN', 'INTUITION', 'INTRAVISIB') 
                or (TYPEPARV = 'PARAMGEN' AND CODEPARV = 'ACCES_PORTAIL')
                or (TYPEPARV = 'HAPLUS' AND CODEPARV = 'RECH_ART_HAPLUS')
                or (TYPEPARV = 'PARAMGEN' AND CODEPARV = 'MSGORIMAIL')
                or (TYPEPARV = 'OXACAT' AND CODEPARV = 'DELAI_ECHEANCE')
                ";

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