<?php

abstract class HelperTemplateFirmeImputationSuivi
{

    abstract protected function addWhereSQL(& $sql, $getResultArray, $societe, $type);

    abstract protected function init(& $array, $nomForm, $societe);

    protected $siVisible;

    protected $cdcVisible;

    protected $cgVisible;

    protected $scaVisible;

    protected $siValue;

    protected $cdcValue;

    protected $scaValue;

    protected $arrayAttributSQL;

    public function setInitDroitVisible(& $array)
    {
        $this->siVisible = $array['SI']['visible'] = $_SESSION['Session_SIVisibleBR'];

        /**
         * le conditionnement est opérationnel si nous devons avoir des regles d'affichages pour les CG
         */
        // if('' != trim($tab_valeur[ChampRecherche::SI]))
        // {
        //     $this->cgVisible = $array['CG']['visible'] = 0;
        // }
        // else
        // {
        //     $this->cgVisible = $array['CG']['visible'] = 0;
        // }

        
        $this->cgVisible = $array['CG']['visible'] = 0;

        $this->cdcVisible = $array['CDC']['visible'] = $_SESSION['Session_CDCVisibleBR'];
        $this->scaVisible = $array['SCA']['visible'] = $_SESSION['Session_SCAVisibleBR'];
    }

    public function setInitDroitVisibleNotBR(& $array)
    {
        $this->siVisible = $array['SI']['visible'] = BoolSql(SqlVisibilite::rqGetVisibiliteChamps('SI')->Trouve1()['VISIBLE']);
        $this->cdcVisible = $array['CDC']['visible'] = BoolSql(SqlVisibilite::rqGetVisibiliteChamps('CDC')->Trouve1()['VISIBLE']);
        $this->scaVisible = $array['SCA']['visible'] = BoolSql(SqlVisibilite::rqGetVisibiliteChamps('SCA')->Trouve1()['VISIBLE']);
    }

    public function setInitDroitValue(& $array)
    {
        $this->siValue = $array['SI']['!value'] =   $_SESSION['ariane'][0]['post']['SI'] ?? $_SESSION['Session_SectionImputation'];
        $this->cdcValue = $array['CDC']['!value'] =  $_SESSION['ariane'][0]['post']['CDC'] ??  $_SESSION['Session_CDC'];
        $this->cdcValue = $array['CG']['!value'] =  $_SESSION['ariane'][0]['post']['CG'] ??  '';
        $this->scaValue = $array['SCA']['!value'] =  $_SESSION['ariane'][0]['post']['SCA'] ??  $_SESSION['Session_SCA'];
        $this->siValue = $array['Direction']['!value'] =  $_SESSION['ariane'][0]['post']['Direction'] ?? '';
        $this->cdcValue = $array['CA']['!value'] =  $_SESSION['ariane'][0]['post']['Ca'] ??  '';
        $this->scaValue = $array['NA']['!value'] =  $_SESSION['ariane'][0]['post']['NA'] ?? '';
    }

    public function getAllPost(& $arrayGet)
    {
        $arrayGet['SI'] = getValue('SI');
        $arrayGet['CDC'] = getValue('CDC');
        $arrayGet['SCA'] = getValue('SCA');
        $arrayGet['CG'] = getValue('CG');
        
        $arrayGet['Direction'] = getValue('Direction');
        $arrayGet['NA'] = getValue('NA');
        $arrayGet['CA'] = getValue('CA');
    }

    public function setTableAttributSQL()
    {
        $this->arrayAttributSQL = array(
            'BR' => array(
                'si' => array(
                    'CA_LIGNE.SECTIMP',
                    'CA_ENTET.SECTIMP'
                ),
                'cdc' => array(
                    'CA_LIGNE.CODE_COMP',
                    'CA_ENTET.CODECOMP'
                ),
                'sca' => array(
                    'CA_LIGNE.SSCPTEANA',
                    'CA_ENTET.SSCPTEANA'
                )
            ),
            'BAP' => array(
                'si' => 'FAC_LIG.CODE_SI',
                'cdc' => 'FAC_LIG.CODE_CDC',
                'sca' => 'FAC_LIG.CODE_SCA'
            ),
            'DA' => array(
                'si' => array(
                    'DA_ENTET.SECTIMP',
                    'DA_LIGNE.SECTIMP'
                ),
                'cdc' => array(
                    'DA_ENTET.CODECOMP',
                    'DA_LIGNE.CODE_COMP'
                ),
                'sca' => array(
                    'DA_ENTET.SSCPTEANA',
                    'DA_LIGNE.SSCPTEANA'
                )
            ),
            'CDE' => array(
                'si' => array(
                    'CA_ENTET.SECTIMP',
                    'CA_LIGNE.SECTIMP'
                ),
                'cdc' => array(
                    'CA_ENTET.CODECOMP',
                    'CA_LIGNE.CODE_COMP'
                ),
                'sca' => array(
                    'CA_ENTET.SSCPTEANA',
                    'CA_LIGNE.SSCPTEANA'
                )
            )
        
        );
    }
}
    