<?php
class DivisionRecherche {
    public static function getDivisionRechercheByNoFormulaireAndNoDivision($noFormulaire, $noDivision = 1) {
        $query = "SELECT * FROM divisionrecherche 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 getDivisionRechercheByNoFormulaire($noFormulaire) {
        $query = "SELECT * FROM divisionrecherche WHERE NoFormulaire=:noformulaire ORDER BY NoVisu";
        $statement = Connection::getStatement($query);
        $statement->bindParam(":noformulaire", $noFormulaire);
        $statement->execute();
        return $statement->fetchAll();
    }

    public static function getDivisionRechercheByNoFormulaireAndNoTable($noFormulaire, $NoTable) {
        $query = "SELECT * FROM divisionrecherche 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();
    }

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

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