<?php
require 'database.inc.php';
if (Test_User($lg_user, $lg_password) == TRUE) {
?>
  <html>

  <head>
    <meta http-equiv='content-type' content='text/html;charset=utf-8'>
    <SCRIPT language=JavaScript src='valideformulaire.js' type=text/javascript></SCRIPT>
    <SCRIPT language=JavaScript>
      this.window.resizeTo(800, 600);
    </SCRIPT>
    <title>WebBike V<?php echo VERSION; ?></title>
    <?php
    $size = 2;
    if ($ligne = Poste::getPostesByIP()) {
      $size = $ligne['Size'];
    }
    echo "<link href='css/style$size.css' rel='stylesheet' media='screen'>\n";

    echo "<link href='" . CSS_FOLDER . "style.css' rel='stylesheet' media='screen'>\n"
    ?>
  </head>

  <body>
    <?php
    if (!isset($Etape)) {
      $Etape = 0;
    }
    if (!isset($NoVisu)) {
      $NoVisu = 0;
    }
    switch ($Etape) {
      case 0:
        echo "  <form name='info'>\n";
        echo "   <input type='hidden' name='Etape' value='1'>\n";
        echo "   <input type='hidden' name='NoVisu' value='$NoVisu'>\n";
        echo "   <input type='hidden' name='NoClient' value='$NoClient'>\n";
        echo "   <input type='hidden' name='Commande' value='$Commande'>\n";
        echo "   <input type='hidden' name='AchatMarchandise' value='$AchatMarchandise'>\n";
        echo "   <input type='hidden' name='NbArticles' value='$NbArticles'>\n";
        Create_Recherche(1, $NoVisu);
        echo "   <button type='submit'>Rechercher</button>\n";
        echo "  </form>\n";
        break;
      case 1:
        echo "  <form name='info'>\n";
        echo "   <input type='hidden' name='Etape' value='2'>\n";
        echo "   <input type='hidden' name='NoVisu' value='$NoVisu'>\n";
        echo "   <input type='hidden' name='NoClient' value='$NoClient'>\n";
        echo "   <input type='hidden' name='Commande' value='$Commande'>\n";
        echo "   <input type='hidden' name='AchatMarchandise' value='$AchatMarchandise'>\n";
        echo "   <input type='hidden' name='NbArticles' value='$NbArticles'>\n";
        $nb_results = Affiche_Resultat_Recherche(1, 10, $NoVisu);
        if ($nb_results != 0) {
          echo "   <button type='submit'>Transferer</button>\n";
        }
        echo "  </form>\n";
    ?>
        <form action="recherche_vhc_find.php">
          <input type="hidden" name="NoClient" value="<?php echo $NoClient; ?>" />
          <input type="hidden" name="Commande" value="<?php echo $Commande; ?>" />
          <input type="hidden" name="AchatMarchandise" value="<?php echo $AchatMarchandise; ?>" />
          <input type="hidden" name="NbArticles" value="<?php echo $NbArticles; ?>" />
          <BUTTON type='submit'>Rechercher article</BUTTON>
        </form>
    <?php
        echo "<SCRIPT language=JavaScript>\n";
        echo "document.info.NoChasis.focus();\n";
        echo "this.document.onkeydown = formkeydown;\n";
        echo "actif = 0;\n";
        echo "</SCRIPT>\n";
        break;
      case 2:
        if ($ligne = Article::getArticleByNoArticle(addslashes($NoArticle))) {
          echo "<SCRIPT language=JavaScript>\n";
          $result = Affecte_Resultat_Article($ligne, $NoClient);
          echo "window.opener.local_eval(\"$result\");\n";
          echo "window.close();\n";
          echo "</SCRIPT>\n";
        }
        break;
    }
    ?>
  </body>

  </html>
<?php
}
?>