<?php
class AbsenceEmploye {
    public static function getAbsence($noClient, $date) {
        $query = "SELECT * FROM absenceemploye".ID_GARAGE." WHERE NoClient=:noclient AND (((Debut>=:date)AND(Debut<=:date))OR((Fin>=:date)AND(Fin<=:date))OR((Debut<:date)AND(Fin>:date))) ORDER BY Debut, DebutMA";
        $statement = Connection::getStatement($query);
        $statement->bindParam(":noclient", $noClient);
        $statement->bindParam(":date", $date);
        $statement->execute();
        return $statement->fetchAll();
    }

    public static function getAbsencePeriod($debut, $fin) {
        $query = "SELECT * FROM absenceemploye".ID_GARAGE." WHERE Debut<= :start AND Fin>=:end";     
        $statement = Connection::getStatement($query);
        $statement->bindParam(":start", $debut);
        $statement->bindParam(":end", $fin);
        $statement->execute();
        return $statement->fetchAll();
    }

    public static function getAbsenceByNoClientAndPeriod($noClient, $debut, $fin) {
        $query = "SELECT * FROM absenceemploye".ID_GARAGE." WHERE NoClient=:noclient AND (((Debut>=:start)AND(Debut<=:end))OR((Fin>=:start)AND(Fin<=:end))OR((Debut<:start)AND(Fin>:end))) ORDER BY Debut, DebutMA";
        $statement = Connection::getStatement($query);
        $statement->bindParam(":noclient", $noClient);
        $statement->bindParam(":start", $debut);
        $statement->bindParam(":end", $fin);
        $statement->execute();
        return $statement->fetchAll();
    }

     
}