<?php
require 'database.inc.php';
if (Test_User($lg_user, $lg_password) == TRUE) {
  $requette = "SELECT * FROM location" . ID_GARAGE . " WHERE NoChasis='" . addslashes($vhc) . "' AND ((Debut>'$debut' AND Debut<'$fin')OR(Fin>='$debut' AND Fin<='$fin')OR(Debut<'$debut' AND Fin>='$fin'))";
  if ($new == 0) {
    if ($vhc == $old_vhc) {
      $requette .= " AND Debut <> '$Start'";
    }
  }
  //echo "$requette\n";
  $resultat = Connection::executeRawQueryWithfetchAll($requette);
  $first = true;
  foreach ($resultat as $ligne) {
    if ($first) {
      $first = false;
      //echo $requette."\n";
      echo "Locations deja existantes sur la meme periode";
    }
    echo "\n" . $ligne["Nom"] . " " . substr($ligne["Debut"], 8, 2) . "." . substr($ligne["Debut"], 5, 2) . "." . substr($ligne["Debut"], 0, 4) . " " . substr($ligne["Debut"], 11, 5) . " -> " . substr($ligne["Fin"], 8, 2) . "." . substr($ligne["Fin"], 5, 2) . "." . substr($ligne["Fin"], 0, 4) . " " . substr($ligne["Fin"], 11, 5);
  }
}
