<?php

namespace Modules\GlobalApplication\Repository;

class ContactsFournisseur
{
    
    private $pdo;
    
    public function __construct(\PDO $pdo)
    {
        $this->pdo = $pdo;
    }
    
    /**
     * lastContact
     * @param string $codeFou
     * @return array<string>
     */
    public function lastContact(string $codeFou) : ?array
    {
        $req = "SELECT MAX(IND_FOU) MAX_IND_FOU
            FROM CONTFOUR with (nolock)
            WHERE CONTFOUR.CODE_FOU = :codeFou";
        
        $arrayReq = [
            ':codeFou' => $codeFou,
        ];
        
        $nbr = $this->pdo->prepare($req);
        $nbr->execute($arrayReq);
        return $nbr->fetch($this->pdo::FETCH_ASSOC);
    }

    /**
     * lastContact
     * @param string $codeGF
     * @return array<string>
     */
    public function lastContactContGF(string $codeGF) : ?array
    {
        $req = "SELECT MAX(IND_FOU) MAX_IND_FOU
            FROM CONTGF with (nolock)
            WHERE CONTGF.CODE_GF = :codeGF";
        
        $arrayReq = [
            ':codeGF' => $codeGF,
        ];
        
        $nbr = $this->pdo->prepare($req);
        $nbr->execute($arrayReq);
        return $nbr->fetch($this->pdo::FETCH_ASSOC);
    }
}
