<?php

class Class_newFiche
{
    private $pdo = null;


    public function __construct(PdoGsb $pDO)
    {
        $this->pdo = $pDO->getPdoGsb();
    }

    public function listFraisForfaitaires(): array
    {
        $req = 'SELECT "fLibelle", round("fMontant", 2) AS "fMontant", "fId" FROM forfait';
        $result = $this->pdo->prepare($req);
        $result->execute();

        return $result->fetchAll();
    }

    public function listFraisHF():array
    {
        //
    }

    public function endInter(string $id)
    {
        $req = "UPDATE intervention
			SET iHeureFin = NOW()
			WHERE iCis = :cis AND iId = :idInter AND iHeureFin IS NULL";

        $cis = explode('-', $id)[0];
        $idInter = explode('-', $id)[1];

        $result = PdoBD::$monPdo->prepare($req);
        $result->bindParam(':cis', $cis);
        $result->bindParam(':idInter', $idInter);
        $result->execute();
    }
}