<?php

namespace Modules\Contrat\Repository;

use Helpers\Fichier\Fichier;
use Helpers\QueryBuilder\AbsRepository;
use Iterator;
use phpDocumentor\Reflection\Types\Iterable_;

class AccordCadreEventRepo extends AbsRepository
{

    private function getMainRequest() :string
    {
        return "SELECT 
                ACD_EVT.*,
                ACD_TYPE_EVT.LIB,
                HASTUTIL.NOM as Util_NOM  
            from ACD_EVT with (nolock)  
            left join ACD_TYPE_EVT with (nolock) 
                on ACD_EVT.CODE_EVT = ACD_TYPE_EVT.CODE_EVT 
            left join HASTUTIL with (nolock) on HASTUTIL.CODE = ACD_EVT.UTIL 
            where ACD_EVT.CODE_ACD = :idAcc ORDER BY NUM_ORDRE";
    }

    /**
     * Return the following event of a framework agreement
     * @param string $idAcc
     * @return array<array<string>>
     */
    public function listEvent(string $idAcc): array
    {
        return $this->fetchAssocAll(
            $this->getMainRequest(),
            [':idAcc' => $idAcc]
        );
    }

    /**
     * @param string $idAcc
     */
    public function export(string $idAcc): \PDOStatement
    {
        return $this->createStatement(
            $this->getMainRequest(),
            [':idAcc' => $idAcc]
        );
    }
}
