<?php

namespace Modules\Facture\Repository;

use Helpers\QueryBuilder\AbsRepository;

class PopupFacture extends AbsRepository
{

    public function blockNote($id)
    {
        $req =
        "SELECT FABNOTE.NUM_FACT, FABNOTE.NM_BNOTE, MEMOS.CONTMEMO
        FROM FABNOTE WITH (NOLOCK) 
        JOIN MEMOS WITH (NOLOCK) ON NODEMEMO = NM_BNOTE 
        WHERE NUM_FACT = :id";
        $arrayReq[':id'] = $id;
        
        $note = $this->pdo->prepare($req);
        $note->execute($arrayReq);
        return $note->fetch();
    }
    
    public function signataireAttendu($id)
    {
        $req =
        "SELECT HASTUTIL.CODE, HASTUTIL.NOM, SIG_BAP.ORDRE, 
        (substring(SIG_BAP.DTE_MISE,7,2)+'/'+substring(SIG_BAP.DTE_MISE,5,2)+'/'+substring(SIG_BAP.DTE_MISE,1,4)) DTE_MISE, 
        FAROLES, INFORME, ltrim(rtrim(FAROLES)) ROLE
        FROM SIG_BAP WITH (NOLOCK)
        LEFT JOIN HASTUTIL WITH (NOLOCK) ON SIG_BAP.SIGNAT = HASTUTIL.CODE
        WHERE SIG_BAP.NO_FAC = :value
        ORDER BY SIG_BAP.ORDRE";
        $arrayReq[':value'] = $id;
        
        return $this->fetchAssocAll($req, $arrayReq);
    }
}
