<?php
namespace Modules\API\APIExterne\Repository;

class Hiveo
{
    
    private \PDO $pdo;
    
    public function __construct(\PDO $pdo)
    {
        $this->pdo = $pdo;
    }

    /**
     * getContactFrsWithEmail
     * @param String $codeFrs
     * @return Array<string>
     */
    public function getContactFrsWithEmail(String $codeFrs) : ?array
    {
        $req ="select TOP 1 * from CONTFOUR with (nolock) where CODE_FOU =:codeFrs and EMAIL != '' ";
         
        $arrayReq = [':codeFrs' => $codeFrs];

        $req = $this->pdo->prepare($req);
        $req->execute($arrayReq);
  
        return $req->fetch();
    }

    /**
     * getInvitWithEmail
     * @param String $codeFrs
     * @return Array<string>
     */
    public function getInvitWithEmail(String $codeFrs) : ?array
    {
        $req ="select * from PARAMDICO where TYPEDICO = 'INVIT_PARTFOU' and ID3 = :codeFrs and ID1 ='HIVEO' AND ALPHA4 != ''";
         
        $arrayReq = [':codeFrs' => $codeFrs];

        $req = $this->pdo->prepare($req);
        $req->execute($arrayReq);
  
        return $req->fetch();
    }
}
