<?php
class Vehicule {
    public static function getVehiculeByNoChassis($noChassis) {
        $query = "SELECT * FROM vehicules WHERE NoChasis=:nochassis";
        $statement = Connection::getStatement($query);
        $statement->bindParam(":nochassis", $noChassis);
        $statement->execute();
        return $statement->fetch();
    }

    public static function getVehiculeByClient($client) {
        $query = "SELECT * FROM vehicules WHERE Client=:client ORDER BY NoChasis";
        $statement = Connection::getStatement($query);
        $statement->bindParam(":client", $client);
        $statement->execute();
        return $statement->fetchAll();
    }

    public static function getVehiculeByNoChassisAndTypeAndCommandAssocie($noChassis, $type = 'RV', $commandeAssocie = 0) {
        $query = "SELECT * FROM commande".ID_GARAGE." WHERE Type = :type AND Vehicule = :nochassis AND NoCommandeAssocie = :associe ORDER BY DateCommande DESC";
        $statement = Connection::getStatement($query);
        $statement->bindParam(":nochassis", $noChassis);
        $statement->bindParam(":type", $type);
        $statement->bindParam(":associe", $commandeAssocie);
        $statement->execute();
        return $statement->fetch();
    }		  
}