<?php
class Division {
    public static function getDivisionByNoFormulaireAndNoDivision($noFormulaire, $noDivision = 1) {
        $query = "SELECT * FROM division WHERE NoFormulaire=:noformulaire AND NoDivision=:nodivision ORDER BY NoVisu";
        $statement = Connection::getStatement($query);
        $statement->bindParam(":noformulaire", $noFormulaire);
        $statement->bindParam(":nodivision", $noDivision);
        $statement->execute();
        return $statement->fetchAll();
    }

    public static function getDivisionByNoFormulaireAndNoVisu($noFormulaire, $noVisu) {
        $query = "SELECT * FROM division WHERE NoFormulaire=:noformulaire AND NoVisu=:novisu ORDER BY NoVisu";
        $statement = Connection::getStatement($query);
        $statement->bindParam(":noformulaire", $noFormulaire);
        $statement->bindParam(":novisu", $noVisu);
        $statement->execute();
        return $statement->fetchAll();
    }

    public static function getDivisionByNoFormulaireAndGratherNoVisu($noFormulaire, $noVisu = 0) {
        $query = "SELECT * FROM division WHERE NoFormulaire=:noformulaire AND NoVisu>:novisu ORDER BY NoVisu";
        $statement = Connection::getStatement($query);
        $statement->bindParam(":noformulaire", $noFormulaire);
        $statement->bindParam(":novisu", $noVisu);
        $statement->execute();
        return $statement->fetchAll();
    }

    public static function getDivisionByNoFormulaire($noFormulaire) {
        $query = "SELECT * FROM division WHERE NoFormulaire=:noformulaire ORDER BY NoVisu";
        $statement = Connection::getStatement($query);
        $statement->bindParam(":noformulaire", $noFormulaire);
        $statement->execute();
        return $statement->fetchAll();
    }

    public static function getDivisionByNoFormulaireAndNoTable($noFormulaire, $noTable) {
        $query = "SELECT * FROM division WHERE NoFormulaire=:noformulaire  AND NoTable=:table ORDER BY NoVisu";
        $statement = Connection::getStatement($query);
        $statement->bindParam(":noformulaire", $noFormulaire);
        $statement->bindParam(":table", $noTable);
        $statement->execute();
        return $statement->fetchAll();
    }
}