<?php
class AtelierSuite {
    public static function getSumAsuTempByDate($date) : float {
        $query = "SELECT SUM(asu.Temps) FROM atelier_suite".ID_GARAGE." AS asu WHERE asu.Date = :date";
        $statement = Connection::getStatement($query);
        $statement->bindParam(":date", $date);
        $statement->execute();
        $result = $statement->fetch();
        if($result) {
            if(is_null($result[0])) {
                return 0.0;
            }
            return $result[0];
        }
        return 0.0;
    }

    public static function getSumAsuTempByDateAndMecano($date,$mecano) : float {
        $query = "SELECT SUM(asu.Temps) FROM atelier_suite".ID_GARAGE." AS asu WHERE asu.Date = :date AND asu.Mecano = :mecano";
        $statement = Connection::getStatement($query);
        $statement->bindParam(":date", $date);
        $statement->bindParam(":mecano", $mecano);
        $statement->execute();
        $result = $statement->fetch();
        if($result) {
            if(is_null($result[0])) {
                return 0.0;
            }
            return $result[0];
        }
        return 0.0;
    }
}