<?php
namespace Modules\Fournisseur\Workflow;

class Parametrage
{
    /** *************** **/
    /* Partie Repository */
    /** *************** **/
    public function getNameColonneExport():string
    {
        return 'Fournisseur';
    }
    
    public function getWhere(&$post)
    {
        $req = '';
        
        if (isset($post['filter_IS_PROSPECT']) && $post['filter_IS_PROSPECT'] != '') {
            $req .=" AND '".$post['filter_IS_PROSPECT']."' = CASE
            when exists(SELECT * FROM WFT_DEM_LIG with (nolock) WHERE CODE_DEMANDE=WFT_DEM_ENT.CODE_DEMANDE AND CODE_CHAMP='PROSPECT' and VALEUR_CHAMP='1') then 'P'
            when exists(SELECT * FROM WFT_DEM_LIG with (nolock) WHERE CODE_DEMANDE=WFT_DEM_ENT.CODE_DEMANDE AND CODE_CHAMP='PROSPECT' and VALEUR_CHAMP='0') then 'R'
            when exists(SELECT * FROM FOURNISS with (nolock) WHERE FOURNISS.CODE = WFT_DEM_ENT.CODE_ENREG and PROSPECT=0x54) then 'P'
            else 'R'
            END";
            unset($post['filter_IS_PROSPECT']);
        }
        
        return $req;
    }
    
    public function getColonne()
    {
        return ', AO_ENTET.OBJET_AO';
    }
    
    public function getJointure()
    {
        return ' LEFT JOIN AO_ENTET with(nolock) on AO_ENTET.NO_AO = WFT_DEM_ENT.NO_AO';
    }
}
