<?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>
    <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>
    <script language=JavaScript>
      document.onkeydown = mykeydown;
      actif = "info";
      special_submit = 0;

      function mykeydown(ev) {
        var code;
        var ff = false;
        if (ev) {
          ff = true;
          code = ev.which;
          event = ev;
        } else {
          code = event.keyCode;
        }
        if (code == 13) {
          switch (special_submit) {
            case 0:
              document.forms[actif].submit();
              break;
            case 13:
              window.event.which = 9;
              window.event.returnValue = false;
              transfert_no_client3("<?php echo $Cible ?>");
              return false;
              break;
          }
        }
      }

      function transfert_no_client(Cible) {
        cpt = this.document.recherche.NoClient.selectedIndex;
        if (cpt != -1) {
          cpt = this.document.recherche.NoClient.options[cpt].value;
          window.opener.document.forms["info"].elements[Cible].value = cpt;
          window.close();
        }
      }

      function transfert_no_client2(Cible) {
        cpt = this.document.recherche.NoClient.selectedIndex;
        if (cpt != -1) {
          cpt = this.document.recherche.NoClient.options[cpt].value;
          window.opener.document.forms["info"].elements[Cible].value = cpt;
          window.opener.document.forms["info"].elements[Cible + "Nom"].value = Noms[cpt];
          window.opener.document.forms["info"].elements[Cible + "Prenom"].value = Prenoms[cpt];
          window.close();
        }
      }

      function transfert_no_client3(Cible) {
        cpt = this.document.info.NoClient.selectedIndex;
        if (cpt != -1) {
          cpt = this.document.info.NoClient.options[cpt].value;
          window.opener.document.forms["info"].elements[Cible].value = cpt;
          window.close();
        }
      }

      function transfert_no_chasis(Cible) {
        cpt = this.document.info.NoChasis.selectedIndex;
        if (cpt != -1) {
          cpt = this.document.info.NoChasis.options[cpt].value;
          window.opener.document.forms["info"].elements[Cible].value = cpt;
          window.close();
        }
      }

      function transfert_no_commande(Cible) {
        cpt = this.document.info.NoCommande.selectedIndex;
        if (cpt != -1) {
          cpt = this.document.info.NoCommande.options[cpt].value;
          window.opener.document.forms["info"].elements[Cible].value = cpt;
          window.close();
        }
      }
    </script>
    <?php
    //require 'database.inc.php';
    //session_start();
    //session_register("lg_user");
    //session_register("lg_password");
    //session_register("lg_admin");
    //session_register("lg_menu1");
    //session_register("lg_menu2");
    //session_register("lg_menu3");
    //session_register("lg_menu4");
    //session_register("lg_menu5");
    if (Test_User($lg_user, $lg_password) == TRUE) {
      if (isset($Type) == False) {
        $Type = 0;
      }
      if (isset($Detail) == False) {
        $Detail = 0;
      }
      if (isset($Etape) == False) {
        $Etape = 0;
      }
      //  echo "<big>recherche</big>\n";
      switch ($Type) {
        case 0:
          echo "recherche<BR>\n";
          break;
        case 1:
          switch ($Etape) {
            case 0:
              /*	  	    echo "  <form>\n";
            echo "   <input type='hidden' name='Type' value=$Type>\n";
            echo "   <input type='hidden' name='Etape' value='1'>\n";
            echo "   <input type='hidden' name='Detail' value='$Detail'>\n";
            echo "   <input type='hidden' name='NoClient' value='$NoClient'>\n";
            Create_Recherche(1);
            echo "   <button type='submit'>Rechercher</button>\n";
            echo "  </form>\n";*/
              if (isset($param1)) {
                $NoClient = $param1;
              }
              if (isset($param2)) {
                $Detail = $param2;
              }
              if (isset($NoVisu) == False) {
                $NoVisu = 0;
              }
              if (isset($NoClient) == False) {
                $NoClient = 0;
              }
              echo "<SCRIPT language=JavaScript src='valideformulaire.js' type=text/javascript></SCRIPT>\n";
              Affiche_No_Visu_recherche(1, VISU_DATA, '', $NoClient, $Detail);
              echo "  <form name='info'>\n";
              Create_Recherche(1, $NoVisu);
              echo "<script language=JavaScript>\n";
              echo  "this.document.forms['info'].elements[0].focus();\n";
              echo "</script>\n";
              echo "   <input type='hidden' name='Type' value=$Type>\n";
              echo "   <input type='hidden' name='Etape' value='1'>\n";
              echo "   <input type='hidden' name='Detail' value='$Detail'>\n";
              echo "   <input type='hidden' name='NoClient' value='$NoClient'>\n";
              echo "   <input type='hidden' name='NoVisu' value='$NoVisu'>\n";
              echo "   <button type='button' onClick='submit_ok(this.form);'>Rechercher</button>\n";
              echo "  </form>\n";
              //            Create_Recherche_Form(1,$NoVisu);
              break;
            case 1:
              /*	  	    echo "  <form>\n";
            echo "   <input type='hidden' name='Type' value=$Type>\n";
            echo "   <input type='hidden' name='Etape' value='1'>\n";
            echo "   <input type='hidden' name='Detail' value='$Detail'>\n";
            echo "   <input type='hidden' name='NoClient' value='$NoClient'>\n";
            Create_Recherche(1);
            echo "   <button type='submit'>Rechercher</button>\n";
            echo "  </form>\n";*/
              if (isset($param1)) {
                $NoClient = $param1;
              }
              if (isset($param2)) {
                $Detail = $param2;
              }
              if (isset($NoVisu) == False) {
                $NoVisu = 0;
              }
              if (isset($NoClient) == False) {
                $NoClient = 0;
              }
              echo "<SCRIPT language=JavaScript src='valideformulaire.js' type=text/javascript></SCRIPT>\n";
              Affiche_No_Visu_recherche(1, VISU_DATA, '', $NoClient, $Detail);
              echo "  <form name='info'>\n";
              Create_Recherche(1, $NoVisu);
              echo "   <input type='hidden' name='Type' value=$Type>\n";
              echo "   <input type='hidden' name='Etape' value='1'>\n";
              echo "   <input type='hidden' name='Detail' value='$Detail'>\n";
              echo "   <input type='hidden' name='NoClient' value='$NoClient'>\n";
              echo "   <input type='hidden' name='NoVisu' value='$NoVisu'>\n";
              echo "   <button type='button' onClick='submit_ok(this.form);'>Rechercher</button>\n";
              echo "  </form>\n";
              echo "  <form>\n";
              echo "   <input type='hidden' name='Type' value=$Type>\n";
              echo "   <input type='hidden' name='Etape' value='2'>\n";
              echo "   <input type='hidden' name='Detail' value='$Detail'>\n";
              echo "   <input type='hidden' name='NoClient' value='$NoClient'>\n";
              if ($Detail == 3)
                Affiche_Resultat_Recherche(1, 2);
              else
                Affiche_Resultat_Recherche(1, 1);
              echo "  </form>\n";
              break;
              /*	  	case 2:
	  	    echo "  <form>\n";
            echo "   <input type='hidden' name='Type' value=$Type>\n";
            echo "   <input type='hidden' name='Etape' value='1'>\n";
            echo "   <input type='hidden' name='Detail' value='$Detail'>\n";
            echo "   <input type='hidden' name='NoClient' value='$NoClient'>\n";
            Create_Recherche(1);
            echo "   <button type='submit'>Rechercher</button>\n";
            echo "  </form>\n";
			$requette="SELECT * FROM articles WHERE NoArticle='$NoArticle'";
			echo $requette . "<BR>\n";
            if ($resultat = mysql_query($requette))
            {
              $ligne = mysql_fetch_array( $resultat );
			  $no_type_rabais=0;
			  $requette2="SELECT * FROM clients WHERE NoClient=$NoClient";
              if ($resultat2 = mysql_query($requette2))
              {
              	if ($ligne2 = mysql_fetch_array( $resultat2 ))
              	{
              		$no_type_rabais=$ligne2['TypeRabais'];
				}
			  }	
              echo "<HR>\n";
              echo "<BIG><BIG>Article</BIG></BIG><BR>\n";
              echo "<TABLE border=1>\n";
              echo "<TR><TH>Numéro article</TH><TD>" . $NoArticle . "</TD></TR>\n";
              echo "<TR><TH>Description</TH><TD>" . $ligne['Description'] . "</TD></TR>\n";
              echo "<TR><TH>Prix</TH><TD>" . $ligne['PrixImportateur'] . "</TD></TR>\n";
              echo "<TR><TH>Rabais</TH><TD>" . $ligne['RabaisType' . $no_type_rabais] . "</TD></TR>\n";
              echo "<TR><TH>TVA</TH><TD>" . $ligne['TVA'] . "</TD></TR>\n";
              echo "<TR><TH>Groupe Marchandise</TH><TD>" . $ligne['GroupeMarchandise'] . "</TD></TR>\n";
              echo "</TABLE>\n";
              echo "  <button type='button' onClick='window.opener.document.forms[" . '"' . "info" . '"' . "].elements[" . '"' . "NoArticle" . '"' . "].value = " . '"' . "$NoArticle" . '"' . ";" ;
              echo " alert($Detail);";
			  if ($Detail==2)
              {
			    echo " window.opener.document.forms[" . '"' . "info" . '"' . "].elements[" . '"' . "Description" . '"' . "].value = " . '"' . $ligne['Description']  .'"' . ";";
			    echo " window.opener.document.forms[" . '"' . "info" . '"' . "].elements[" . '"' . "Prix" . '"' . "].value = " . '"' . $ligne['PrixImportateur']  .'"' . ";";
			    echo " window.opener.document.forms[" . '"' . "info" . '"' . "].elements[" . '"' . "TVA" . '"' . "].value = " . '"' . $ligne['TVA']  .'"' . ";";
			    echo " window.opener.document.forms[" . '"' . "info" . '"' . "].elements[" . '"' . "GM" . '"' . "].value = " . '"' . $ligne['GroupeMarchandise']  .'"' . ";";
			    echo " window.opener.document.forms[" . '"' . "info" . '"' . "].elements[" . '"' . "Rabais" . '"' . "].value = " . '"' . $ligne['RabaisType'.$no_type_rabais] . '"' . ";";
			    echo " window.opener.document.forms[" . '"' . "info" . '"' . "].elements[" . '"' . "Quantite" . '"' . "].value = " . '"1.00"' . ";";
			    echo " window.opener.document.forms[" . '"' . "info" . '"' . "].elements[" . '"' . "Quantite" . '"' . "].focus();";
			    echo " window.opener.document.forms[" . '"' . "info" . '"' . "].elements[" . '"' . "Quantite" . '"' . "].select();";
			  }
			  if($Detail==3)
			  {
			    echo " window.opener.document.forms[" . '"' . "info" . '"' . "].elements[" . '"' . "Description" . '"' . "].value = " . '"' . $ligne['Description']  .'"' . ";";
			    echo " window.opener.document.forms[" . '"' . "info" . '"' . "].elements[" . '"' . "Prix" . '"' . "].value = " . '"' . $ligne['PrixImportateur']  .'"' . ";";
			    echo " window.opener.document.forms[" . '"' . "info" . '"' . "].elements[" . '"' . "TVA" . '"' . "].value = " . '"' . $ligne['TVA']  .'"' . ";";
			    echo " window.opener.document.forms[" . '"' . "info" . '"' . "].elements[" . '"' . "GM" . '"' . "].value = " . '"' . $ligne['GroupeMarchandise']  .'"' . ";";
			    echo " window.opener.document.forms[" . '"' . "info" . '"' . "].elements[" . '"' . "Rabais" . '"' . "].value = " . '"-' . $ligne['Rabais'] . '"' . ";";
			    echo " window.opener.document.forms[" . '"' . "info" . '"' . "].elements[" . '"' . "Quantite" . '"' . "].value = " . '"1.00"' . ";";
			    echo " window.opener.document.forms[" . '"' . "info" . '"' . "].elements[" . '"' . "Quantite" . '"' . "].focus();";
			    echo " window.opener.document.forms[" . '"' . "info" . '"' . "].elements[" . '"' . "Quantite" . '"' . "].select();";
			  }
			  echo " '>transfert</button><BR><BR>\n";
			  $requette="SELECT * FROM articles WHERE NoArticle='" . $ligne['Description'] . "'";
			  echo $requette . "<BR>\n";
			  $resultat = mysql_query($requette);
			  foreach($resultat as $ligne)
			  {
                echo "<HR>\n";
                echo "<TABLE border=1>\n";
                echo "<TR><TH>Numéro article</TH><TD>" . $ligne['NoArticle'] . "</TD></TR>\n";
                echo "<TR><TH>Description</TH><TD>" . $ligne['Description'] . "</TD></TR>\n";
                echo "<TR><TH>Prix</TH><TD>" . $ligne['PrixImportateur'] . "</TD></TR>\n";
                echo "<TR><TH>Rabais</TH><TD>" . $ligne['RabaisType' . $no_type_rabais] . "</TD></TR>\n";
                echo "<TR><TH>TVA</TH><TD>" . $ligne['TVA'] . "</TD></TR>\n";
                echo "<TR><TH>Groupe Marchandise</TH><TD>" . $ligne['GroupeMarchandise'] . "</TD></TR>\n";
                echo "</TABLE>\n";
                echo "  <button type='button' onClick='window.opener.document.forms[" . '"' . "info" . '"' . "].elements[" . '"' . "NoArticle" . '"' . "].value = " . '"' . $ligne['NoArticle'] . '"' . ";" ;
                if ($Detail==2)
                {
			      echo " window.opener.document.forms[" . '"' . "info" . '"' . "].elements[" . '"' . "Description" . '"' . "].value = " . '"' . $ligne['Description']  .'"' . ";";
			      echo " window.opener.document.forms[" . '"' . "info" . '"' . "].elements[" . '"' . "Prix" . '"' . "].value = " . '"' . $ligne['PrixImportateur']  .'"' . ";";
			      echo " window.opener.document.forms[" . '"' . "info" . '"' . "].elements[" . '"' . "TVA" . '"' . "].value = " . '"' . $ligne['TVA']  .'"' . ";";
			      echo " window.opener.document.forms[" . '"' . "info" . '"' . "].elements[" . '"' . "GM" . '"' . "].value = " . '"' . $ligne['GroupeMarchandise']  .'"' . ";";
			      echo " window.opener.document.forms[" . '"' . "info" . '"' . "].elements[" . '"' . "Rabais" . '"' . "].value = " . '"' . $ligne['RabaisType'.$no_type_rabais] . '"' . ";";
			      echo " window.opener.document.forms[" . '"' . "info" . '"' . "].elements[" . '"' . "Quantite" . '"' . "].value = " . '"1.00"' . ";";
			      echo " window.opener.document.forms[" . '"' . "info" . '"' . "].elements[" . '"' . "Quantite" . '"' . "].focus();";
			      echo " window.opener.document.forms[" . '"' . "info" . '"' . "].elements[" . '"' . "Quantite" . '"' . "].select();";
			    }
                if ($Detail==3)
                {
			      echo " window.opener.document.forms[" . '"' . "info" . '"' . "].elements[" . '"' . "Description" . '"' . "].value = " . '"' . $ligne['Description']  .'"' . ";";
			      echo " window.opener.document.forms[" . '"' . "info" . '"' . "].elements[" . '"' . "Prix" . '"' . "].value = " . '"' . $ligne['PrixImportateur']  .'"' . ";";
			      echo " window.opener.document.forms[" . '"' . "info" . '"' . "].elements[" . '"' . "TVA" . '"' . "].value = " . '"' . $ligne['TVA']  .'"' . ";";
			      echo " window.opener.document.forms[" . '"' . "info" . '"' . "].elements[" . '"' . "GM" . '"' . "].value = " . '"' . $ligne['GroupeMarchandise']  .'"' . ";";
			      echo " window.opener.document.forms[" . '"' . "info" . '"' . "].elements[" . '"' . "Rabais" . '"' . "].value = " . '"-' . $ligne['Rabais'] . '"' . ";";
			      echo " window.opener.document.forms[" . '"' . "info" . '"' . "].elements[" . '"' . "Quantite" . '"' . "].value = " . '"1.00"' . ";";
			      echo " window.opener.document.forms[" . '"' . "info" . '"' . "].elements[" . '"' . "Quantite" . '"' . "].focus();";
			      echo " window.opener.document.forms[" . '"' . "info" . '"' . "].elements[" . '"' . "Quantite" . '"' . "].select();";
			    }
			    echo " '>transfert</button><BR><BR>\n";
			    $requette="SELECT * FROM articles WHERE NoArticle='" . $ligne['Description'] . "'";
			    echo $requette . "<BR>\n";
			    $resultat = mysql_query($requette);
			  }

            }
          }
	  	break;*/
          }
          break;
        case 2:
          switch ($Etape) {
            case 0:
              echo "  <form>\n";
              echo "   <input type='hidden' name='Type' value=$Type>\n";
              echo "   <input type='hidden' name='Etape' value='1'>\n";
              echo "   <input type='hidden' name='Detail' value='$Detail'>\n";
              Create_Recherche(2);
              echo "   <button type='submit'>Rechercher</button>\n";
              echo "  </form>\n";
              break;
            case 1:
              echo "  <form>\n";
              echo "   <input type='hidden' name='Type' value=$Type>\n";
              echo "   <input type='hidden' name='Etape' value='1'>\n";
              echo "   <input type='hidden' name='Detail' value='$Detail'>\n";
              Create_Recherche(2);
              echo "   <button type='submit'>Rechercher</button>\n";
              echo "  </form>\n";
              echo "<HR>\n";
              echo "  <form>\n";
              echo "   <input type='hidden' name='Type' value=$Type>\n";
              echo "   <input type='hidden' name='Etape' value='2'>\n";
              echo "   <input type='hidden' name='Detail' value='$Detail'>\n";
              Affiche_Resultat_Recherche(2);
              echo "  </form>\n";
              break;
            case 2:
              echo "  <form>\n";
              echo "   <input type='hidden' name='Type' value=$Type>\n";
              echo "   <input type='hidden' name='Etape' value='1'>\n";
              echo "   <input type='hidden' name='Detail' value='$Detail'>\n";
              Create_Recherche(2);
              echo "   <button type='submit'>Rechercher</button>\n";
              echo "  </form>\n";
              $ligne = Vehicule::getVehiculeByNoChassis($NoChasis);
              echo "<HR>\n";
              echo "<BIG><BIG>Vehicule</BIG></BIG><BR>\n";
              echo "<TABLE border=1>\n";
              echo "<TR><TH>Numéro chasis</TH><TD>" . $NoChasis . "</TD></TR>\n";
              echo "<TR><TH>Marque</TH><TD>" . $ligne['MarqueModel'] . "</TD></TR>\n";
              echo "<TR><TH>Model</TH><TD>" . $ligne['Model'] . "</TD></TR>\n";
              echo "<TR><TH>Km</TH><TD>" . $ligne['Km'] . "</TD></TR>\n";
              echo "<TR><TH>Numéro de plaques</TH><TD>" . $ligne['NoPlaque'] . "</TD></TR>\n";
              echo "</TABLE>\n";
              echo "  <button type='button' onClick='window.opener.document.forms[" . '"' . "info" . '"' . "].elements[" . '"' . "NoChasis" . '"' . "].value = " . '"' . "$NoChasis" . '"' . ";";
              if ($Detail == 2) {
                echo " window.opener.document.forms[" . '"' . "info" . '"' . "].elements[" . '"' . "Marque" . '"' . "].value = " . '"' . $ligne['MarqueModel']  . '"' . ";" .
                  " window.opener.document.forms[" . '"' . "info" . '"' . "].elements[" . '"' . "Model" . '"' . "].value = " . '"' . $ligne['Model']  . '"' . ";" .
                  " window.opener.document.forms[" . '"' . "info" . '"' . "].elements[" . '"' . "Km" . '"' . "].value = " . '"' . $ligne['Km']  . '"' . ";" .
                  " window.opener.document.forms[" . '"' . "info" . '"' . "].elements[" . '"' . "NoPlaque" . '"' . "].value = " . '"' . $ligne['NoPlaque']  . '"' . ";";
              }
              echo " '>transfert</button><BR><BR>\n";
              if ($Detail == 2) {
                if ($ligne2 = Client::getClientByNoClient($ligne['Client'])) {
                  echo "<HR>\n";
                  echo "<BIG><BIG>Client</BIG></BIG><BR>\n";
                  echo "<TABLE border=1>\n";
                  echo "<TR><TH>Numéro client</TH><TD>" . $ligne2['NoClient'] . "</TD></TR>\n";
                  echo "<TR><TH>Nom</TH><TD>" . $ligne2['Nom'] . "</TD></TR>\n";
                  echo "<TR><TH>Prénom</TH><TD>" . $ligne2['Prenom'] . "</TD></TR>\n";
                  echo "</TABLE>\n";
                  echo "  <button type='button' onClick='window.opener.document.forms[" . '"' . "info" . '"' . "].elements[" . '"' . "NoClient" . '"' . "].value = " . '"' . $ligne2['NoClient']  . '"' . ";";
                  echo " window.opener.document.forms[" . '"' . "info" . '"' . "].elements[" . '"' . "Nom" . '"' . "].value = " . '"' . $ligne2['Nom']  . '"' . ";" .
                    " window.opener.document.forms[" . '"' . "info" . '"' . "].elements[" . '"' . "Prenom" . '"' . "].value = " . '"' . $ligne2['Prenom']  . '"' . ";";
                  echo " '>transfert</button><BR><BR>\n";
                }
              }
              break;
          }
          break;
        case 3:
          switch ($Etape) {
            case 0:
              echo "  <form>\n";
              echo "   <input type='hidden' name='Type' value=$Type>\n";
              echo "   <input type='hidden' name='Etape' value='1'>\n";
              echo "   <input type='hidden' name='Detail' value='$Detail'>\n";
              Create_Recherche(3);
              echo "   <button type='submit'>Rechercher</button>\n";
              echo "  </form>\n";
              echo "<HR>\n";
              echo "  <form action='new.php'>\n";
              echo "   <input type='hidden' name='Type' value=$Type>\n";
              echo "   <button type='submit'>Nouveau client</button>\n";
              echo "  </form>\n";
              break;
            case 1:
              echo "  <form>\n";
              echo "   <input type='hidden' name='Type' value=$Type>\n";
              echo "   <input type='hidden' name='Etape' value='1'>\n";
              echo "   <input type='hidden' name='Detail' value='$Detail'>\n";
              Create_Recherche(3);
              echo "   <button type='submit'>Rechercher</button>\n";
              echo "  </form>\n";
              echo "<HR>\n";
              echo "  <form>\n";
              echo "   <input type='hidden' name='Type' value=$Type>\n";
              echo "   <input type='hidden' name='Etape' value='2'>\n";
              echo "   <input type='hidden' name='Detail' value='$Detail'>\n";
              Affiche_Resultat_Recherche(3, 3);
              echo "  </form>\n";
              echo "<HR>\n";
              break;
            case 2:
              echo "  <form>\n";
              echo "   <input type='hidden' name='Type' value=$Type>\n";
              echo "   <input type='hidden' name='Etape' value='1'>\n";
              echo "   <input type='hidden' name='Detail' value='$Detail'>\n";
              Create_Recherche(3);
              echo "   <button type='submit'>Rechercher</button>\n";
              echo "  </form>\n";
              $ligne = Client::getClientByNoClient($NoClient);
              echo "<HR>\n";
              echo "<BIG><BIG>Client</BIG></BIG><BR>\n";
              echo "<TABLE border=1>\n";
              echo "<TR><TH>Numéro client</TH><TD>" . $NoClient . "</TD></TR>\n";
              echo "<TR><TH>Nom</TH><TD>" . $ligne['Nom'] . "</TD></TR>\n";
              echo "<TR><TH>Prénom</TH><TD>" . $ligne['Prenom'] . "</TD></TR>\n";
              echo "</TABLE>\n";
              echo "  <button type='button' onClick='window.opener.document.forms[" . '"' . "info" . '"' . "].elements[" . '"' . "NoClient" . '"' . "].value = $NoClient;";
              if ($Detail == 2) {
                echo " window.opener.document.forms[" . '"' . "info" . '"' . "].elements[" . '"' . "Nom" . '"' . "].value = " . '"' . $ligne['Nom']  . '"' . ";" .
                  " window.opener.document.forms[" . '"' . "info" . '"' . "].elements[" . '"' . "Prenom" . '"' . "].value = " . '"' . $ligne['Prenom']  . '"' . ";";
              }
              echo " '>transfert</button><BR><BR>\n";
              if ($Detail == 2) {
                if ($resultat2 = Vehicule::getVehiculeByClient($NoClient)) {
                  echo "<HR>\n";
                  echo "<BIG><BIG>Vehicules</BIG></BIG><BR>\n";
                  foreach ($resultat2 as $ligne2) {
                    echo "<TABLE border=1>\n";
                    echo "<TR><TH>Numéro chasis</TH><TD>" . $ligne2['NoChasis'] . "</TD></TR>\n";
                    echo "<TR><TH>Marque</TH><TD>" . $ligne2['MarqueModel'] . "</TD></TR>\n";
                    echo "<TR><TH>Model</TH><TD>" . $ligne2['Model'] . "</TD></TR>\n";
                    echo "<TR><TH>Km</TH><TD>" . $ligne2['Km'] . "</TD></TR>\n";
                    echo "<TR><TH>Numéro de plaques</TH><TD>" . $ligne2['NoPlaque'] . "</TD></TR>\n";
                    echo "</TABLE>\n";
                    echo "  <button type='button' onClick='window.opener.document.forms[" . '"' . "info" . '"' . "].elements[" . '"' . "NoChasis" . '"' . "].value = " . '"' . $ligne2['NoChasis'] . '"' . ";" .
                      " window.opener.document.forms[" . '"' . "info" . '"' . "].elements[" . '"' . "Marque" . '"' . "].value = " . '"' . $ligne2['MarqueModel']  . '"' . ";" .
                      " window.opener.document.forms[" . '"' . "info" . '"' . "].elements[" . '"' . "Model" . '"' . "].value = " . '"' . $ligne2['Model']  . '"' . ";" .
                      " window.opener.document.forms[" . '"' . "info" . '"' . "].elements[" . '"' . "Km" . '"' . "].value = " . '"' . $ligne2['Km']  . '"' . ";" .
                      " window.opener.document.forms[" . '"' . "info" . '"' . "].elements[" . '"' . "NoPlaque" . '"' . "].value = " . '"' . $ligne2['NoPlaque']  . '"' . ";" .
                      " '>transfert</button><BR><BR>\n";
                  }
                }
              }
              break;
          }
          break;
        case 4:
          switch ($Etape) {
            case 0:
              echo "  <form>\n";
              echo "   <input type='hidden' name='Type' value=$Type>\n";
              echo "   <input type='hidden' name='Etape' value='1'>\n";
              echo "   <input type='hidden' name='Detail' value='$Detail'>\n";
              Create_Recherche(4);
              echo "   <button type='submit'>Rechercher</button>\n";
              echo "  </form>\n";
              break;
            case 1:
              echo "  <form>\n";
              echo "   <input type='hidden' name='Type' value=$Type>\n";
              echo "   <input type='hidden' name='Etape' value='1'>\n";
              echo "   <input type='hidden' name='Detail' value='$Detail'>\n";
              Create_Recherche(4);
              echo "   <button type='submit'>Rechercher</button>\n";
              echo "  </form>\n";
              echo "<HR>\n";
              echo "  <form>\n";
              echo "   <input type='hidden' name='Type' value=$Type>\n";
              echo "   <input type='hidden' name='Etape' value='2'>\n";
              echo "   <input type='hidden' name='Detail' value='$Detail'>\n";
              Affiche_Resultat_Recherche(4);
              echo "  <button type='button' onClick='transfert_no_client(" . '"' . $Cible . '"' . ");'>transfert</button><BR>\n";
              echo "  </form>\n";
              break;
            case 2:
              echo "<>";
              break;
          }
          break;
        case 11:
          switch ($Etape) {
            case 0:
              echo "  <form>\n";
              echo "   <input type='hidden' name='Type' value=$Type>\n";
              echo "   <input type='hidden' name='Etape' value='1'>\n";
              echo "   <input type='hidden' name='Detail' value='$Detail'>\n";
              echo "   <input type='hidden' name='Cible' value='$Cible'>\n";
              Create_Recherche(1);
              echo "   <button type='submit'>Rechercher</button>\n";
              echo "  </form>\n";
              echo "  $Cible\n";
              break;
            case 1:
              echo "  <form>\n";
              echo "   <input type='hidden' name='Type' value=$Type>\n";
              echo "   <input type='hidden' name='Etape' value='1'>\n";
              echo "   <input type='hidden' name='Detail' value='$Detail'>\n";
              echo "   <input type='hidden' name='Cible' value='$Cible'>\n";
              Create_Recherche(1);
              echo "   <button type='submit'>Rechercher</button>\n";
              echo "  </form>\n";
              echo "<HR>\n";
              echo "  <form>\n";
              echo "   <input type='hidden' name='Type' value=$Type>\n";
              echo "   <input type='hidden' name='Etape' value='2'>\n";
              echo "   <input type='hidden' name='Detail' value='$Detail'>\n";
              echo "   <input type='hidden' name='Cible' value='$Cible'>\n";
              Affiche_Resultat_Recherche(1);
              echo "  </form>\n";
              echo "  $Cible\n";
              echo "<HR>\n";
              break;
            case 2:
              echo "  <form>\n";
              echo "   <input type='hidden' name='Type' value=$Type>\n";
              echo "   <input type='hidden' name='Etape' value='1'>\n";
              echo "   <input type='hidden' name='Detail' value='$Detail'>\n";
              echo "   <input type='hidden' name='Cible' value='$Cible'>\n";
              Create_Recherche(1);
              echo "   <button type='submit'>Rechercher</button>\n";
              echo "  </form>\n";
              $ligne = Article::getArticleByNoArticle($NoArticle);
              echo "<HR>\n";
              echo "<BIG><BIG>Client</BIG></BIG><BR>\n";
              echo "<TABLE border=1>\n";
              echo "<TR><TH>Numéro client</TH><TD>" . $NoArticle . "</TD></TR>\n";
              echo "<TR><TH>Description</TH><TD>" . $ligne['Description'] . "</TD></TR>\n";
              echo "</TABLE>\n";
              echo "  <button type='button' onClick='window.opener.document.forms[" . '"' . "info" . '"' . "].elements[" . '"' . $Cible . '"' . "].value = " . '"' . $NoArticle . '"' . ";window.close();'>transfert</button><BR><BR>\n";
              echo "  $Cible\n";
              break;
          }
          break;
        case 12:
          switch ($Etape) {
            case 0:
              echo "  <form name='info'>\n";
              Create_Recherche(2);
              echo "<script language=JavaScript>\n";
              echo "force_submit=true;\n";
              echo "this.document.forms['info'].elements[0].focus();\n";
              echo "</script>\n";
              echo "   <input type='hidden' name='Type' value=$Type>\n";
              echo "   <input type='hidden' name='Etape' value='1'>\n";
              echo "   <input type='hidden' name='Detail' value='$Detail'>\n";
              echo "   <input type='hidden' name='Cible' value='$Cible'>\n";
              echo "   <button type='submit'>Rechercher</button>\n";
              echo "  </form>\n";
              echo "  $Cible\n";
              break;
            case 1:
              echo "  <form>\n";
              echo "   <input type='hidden' name='Type' value=$Type>\n";
              echo "   <input type='hidden' name='Etape' value='1'>\n";
              echo "   <input type='hidden' name='Detail' value='$Detail'>\n";
              echo "   <input type='hidden' name='Cible' value='$Cible'>\n";
              Create_Recherche(2);
              echo "   <button type='submit'>Rechercher</button>\n";
              echo "  </form>\n";
              echo "<HR>\n";
              echo "  <form name='info'>\n";
              Affiche_Resultat_Recherche(2, 4);
              echo "<script language=JavaScript>\n";
              echo "force_submit=true;\n";
              echo "this.document.forms['info'].elements[0].focus();\n";
              echo "</script>\n";
              echo "   <input type='hidden' name='Type' value=$Type>\n";
              echo "   <input type='hidden' name='Etape' value='2'>\n";
              echo "   <input type='hidden' name='Detail' value='$Detail'>\n";
              echo "   <input type='hidden' name='Cible' value='$Cible'>\n";
              echo "  <button type='button' onClick='transfert_no_chasis(" . '"' . $Cible . '"' . ");'>transfert</button><BR>\n";
              echo "  </form>\n";
              echo "  $Cible\n";
              echo "<HR>\n";
              break;
          }
          break;
        case 13:
          switch ($Etape) {
            case 0:
              echo "  <form name='info'>\n";
              Create_Recherche(3);
              echo "<script language=JavaScript>\n";
              echo "force_submit=true;\n";
              echo "this.document.forms['info'].elements[0].focus();\n";
              echo "</script>\n";
              echo "   <input type='hidden' name='Type' value=$Type>\n";
              echo "   <input type='hidden' name='Etape' value='1'>\n";
              echo "   <input type='hidden' name='Detail' value='$Detail'>\n";
              echo "   <input type='hidden' name='Cible' value='$Cible'>\n";
              echo "   <button type='submit'>Rechercher</button>\n";
              echo "  </form>\n";
              echo "  $Cible\n";
              break;
            case 1:
              echo "  <form>\n";
              Create_Recherche(3);
              echo "   <input type='hidden' name='Type' value=$Type>\n";
              echo "   <input type='hidden' name='Etape' value='1'>\n";
              echo "   <input type='hidden' name='Detail' value='$Detail'>\n";
              echo "   <input type='hidden' name='Cible' value='$Cible'>\n";
              echo "   <button type='submit'>Rechercher</button>\n";
              echo "  </form>\n";
              echo "<HR>\n";
              echo "  <form name='info'>\n";
              Affiche_Resultat_Recherche(3, 4);
              echo "<script language=JavaScript>\n";
              echo "force_submit=false;\n";
              echo "ignore_submit=true;\n";
              echo "special_submit=13;\n";
              echo "this.document.forms['info'].elements[0].focus();\n";
              echo "</script>\n";
              echo "   <input type='hidden' name='Type' value=$Type>\n";
              echo "   <input type='hidden' name='Etape' value='2'>\n";
              echo "   <input type='hidden' name='Detail' value='$Detail'>\n";
              echo "   <input type='hidden' name='Cible' value='$Cible'>\n";
              echo "  <button type='button' onClick='transfert_no_client3(" . '"' . $Cible . '"' . ");'>transfert</button><BR>\n";
              echo "  </form>\n";
              echo "  $Cible\n";
              echo "<HR>\n";
              break;
          }
          break;
        case 1333:
          switch ($Etape) {
            case 0:
              /*	  	    echo "  <form>\n";
            echo "   <input type='hidden' name='Type' value=$Type>\n";
            echo "   <input type='hidden' name='Etape' value='1'>\n";
            echo "   <input type='hidden' name='Detail' value='$Detail'>\n";
            echo "   <input type='hidden' name='Cible' value='$Cible'>\n";
            Create_Recherche(3);
            echo "   <button type='submit'>Rechercher</button>\n";
            echo "  </form>\n";
            echo "  $Cible\n";*/
              if (isset($param1)) {
                $Cible = $param1;
              }
              if (isset($NoVisu) == False) {
                $NoVisu = 0;
              }
              echo "<SCRIPT language=JavaScript src='valideformulaire.js' type=text/javascript></SCRIPT>\n";
              Affiche_No_Visu_recherche(3, VISU_DATA, '', $Cible);
              echo "  <form name='info'>\n";
              Create_Recherche(3, $NoVisu);
              echo "<script language=JavaScript>\n";
              echo  "this.document.forms['info'].elements[0].focus();\n";
              echo "</script>\n";
              echo "   <input type='hidden' name='Type' value=$Type>\n";
              echo "   <input type='hidden' name='Etape' value='1'>\n";
              echo "   <input type='hidden' name='Detail' value='$Detail'>\n";
              echo "   <input type='hidden' name='Cible' value='$Cible'>\n";
              echo "   <input type='hidden' name='NoVisu' value='$NoVisu'>\n";
              echo "   <button type='button' onClick='submit_ok(this.form);'>Rechercher</button>\n";
              echo "  </form>\n";
              break;
            case 1:
              if (isset($param1)) {
                $Cible = $param1;
              }
              if (isset($NoVisu) == False) {
                $NoVisu = 0;
              }
              echo "<SCRIPT language=JavaScript src='valideformulaire.js' type=text/javascript></SCRIPT>\n";
              Affiche_No_Visu_recherche(3, VISU_DATA, '', $Cible);
              echo "  <form name='info'>\n";
              Create_Recherche(3, $NoVisu);
              echo "   <input type='hidden' name='Type' value=$Type>\n";
              echo "   <input type='hidden' name='Etape' value='1'>\n";
              echo "   <input type='hidden' name='Detail' value='$Detail'>\n";
              echo "   <input type='hidden' name='Cible' value='$Cible'>\n";
              echo "   <input type='hidden' name='NoVisu' value='$NoVisu'>\n";
              echo "   <button type='button' onClick='submit_ok(this.form);'>Rechercher</button>\n";
              echo "  </form>\n";
              echo "  <form name='recherche'>\n";
              Affiche_Resultat_Recherche(3, 9);
              echo "<script language=JavaScript>\n";
              echo  "if(this.document.forms['recherche'].elements[0]!=null)\n";
              echo "{\n";
              echo  "  this.document.forms['recherche'].elements[0].focus();\n";
              echo  "  actif='recherche';\n";
              echo "}\n";
              echo "</script>\n";
              echo "   <input type='hidden' name='Type' value=$Type>\n";
              echo "   <input type='hidden' name='Etape' value='2'>\n";
              echo "   <input type='hidden' name='Detail' value='$Detail'>\n";
              echo "   <input type='hidden' name='Cible' value='$Cible'>\n";
              echo "  <button type='button' onClick='transfert_no_client(" . '"' . $Cible . '"' . ");'>transfert</button><BR>\n";
              //            echo "  <button type='button' onClick='transfert_no_client2(".'"'.$Cible.'"'.");'>transfert</button><BR>\n";
              echo "  </form>\n";
              /*            
	  	    echo "  <form>\n";
            echo "   <input type='hidden' name='Type' value=$Type>\n";
            echo "   <input type='hidden' name='Etape' value='1'>\n";
            echo "   <input type='hidden' name='Detail' value='$Detail'>\n";
            echo "   <input type='hidden' name='Cible' value='$Cible'>\n";
            Create_Recherche(3);
            echo "   <button type='submit'>Rechercher</button>\n";
            echo "  </form>\n";
            echo "<HR>\n";
	  	    echo "  <form name='info'>\n";
            echo "   <input type='hidden' name='Type' value=$Type>\n";
            echo "   <input type='hidden' name='Etape' value='2'>\n";
            echo "   <input type='hidden' name='Detail' value='$Detail'>\n";
            echo "   <input type='hidden' name='Cible' value='$Cible'>\n";
            Affiche_Resultat_Recherche(3,4);
            echo "  <button type='button' onClick='transfert_no_client2(".'"'.$Cible.'"'.");'>transfert</button><BR>\n";
            echo "  </form>\n";
            echo "  $Cible\n";
            echo "<HR>\n";*/
              break;
            case 2:
              echo "<script language=JavaScript>\n";
              echo "window.opener.document.forms['info'].elements['$Cible'].value = $NoClient;\n";
              echo "window.close();\n";
              echo "</script>\n";
              /*	  	    echo "  <form>\n";
            echo "   <input type='hidden' name='Type' value=$Type>\n";
            echo "   <input type='hidden' name='Etape' value='1'>\n";
            echo "   <input type='hidden' name='Detail' value='$Detail'>\n";
            echo "   <input type='hidden' name='Cible' value='$Cible'>\n";
            Create_Recherche(3);
            echo "   <button type='submit'>Rechercher</button>\n";
            echo "  </form>\n";
			$requette="SELECT * FROM clients WHERE NoClient=$NoClient";
            if ($resultat = mysql_query($requette))
            {
              $ligne = mysql_fetch_array( $resultat );
              echo "<HR>\n";
              echo "<BIG><BIG>Client</BIG></BIG><BR>\n";
              echo "<TABLE border=1>\n";
              echo "<TR><TH>Numéro client</TH><TD>" . $NoClient . "</TD></TR>\n";
              echo "<TR><TH>Nom</TH><TD>" . $ligne['Nom'] . "</TD></TR>\n";
              echo "<TR><TH>Prénom</TH><TD>" . $ligne['Prenom'] . "</TD></TR>\n";
              echo "</TABLE>\n";
              echo "<script language=JavaScript>\n";
			  echo "\n";
			  echo "</script>\n";
              echo "  <button type='button' onClick='window.opener.document.forms[" . '"' . "info" . '"' . "].elements[" . '"' . $Cible . '"' . "].value = $NoClient;";
              echo "window.opener.document.info.elements[" . '"' . $Cible . "Nom". '"' . "].value = " . '"' . $ligne['Nom'] . '"' . ";";
              echo "window.opener.document.info.elements[" . '"' . $Cible . "Prenom". '"' . "].value = " . '"' . $ligne['Prenom'] . '"' . ";";
			  echo " '>transfert</button><BR><BR>\n";
            }
            echo "  $Cible\n";*/
              break;
          }
          break;
        case 14:
          switch ($Etape) {
            case 0:
              echo "  <form>\n";
              echo "   <input type='hidden' name='Type' value=$Type>\n";
              echo "   <input type='hidden' name='Etape' value='1'>\n";
              echo "   <input type='hidden' name='Detail' value='$Detail'>\n";
              echo "   <input type='hidden' name='Cible' value='$Cible'>\n";
              Create_Recherche(4);
              echo "   <button type='submit'>Rechercher</button>\n";
              echo "  </form>\n";
              echo "  $Cible\n";
              break;
            case 1:
              echo "  <form>\n";
              echo "   <input type='hidden' name='Type' value=$Type>\n";
              echo "   <input type='hidden' name='Etape' value='1'>\n";
              echo "   <input type='hidden' name='Detail' value='$Detail'>\n";
              echo "   <input type='hidden' name='Cible' value='$Cible'>\n";
              Create_Recherche(4);
              echo "   <button type='submit'>Rechercher</button>\n";
              echo "  </form>\n";
              echo "<HR>\n";
              echo "  <form name='info'>\n";
              echo "   <input type='hidden' name='Type' value=$Type>\n";
              echo "   <input type='hidden' name='Etape' value='2'>\n";
              echo "   <input type='hidden' name='Detail' value='$Detail'>\n";
              echo "   <input type='hidden' name='Cible' value='$Cible'>\n";
              Affiche_Resultat_Recherche(4, 4);
              echo "  <button type='button' onClick='transfert_no_commande(" . '"' . $Cible . '"' . ");'>transfert</button><BR>\n";
              echo "  </form>\n";
              echo "  $Cible\n";
              echo "<HR>\n";
              break;
          }
          break;
      }
    }
    ?>
  </body>

  </html>
<?php
}
?>