<?php

namespace Modules\GlobalApplication\Repository;

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