<?php
  switch($Etape)
  {
    case 0:
      Create_Recherche_Form(1,$NoVisu);
    break;
    case 1:
      Create_Recherche_Form(1,$NoVisu);
      Affiche_Resultat_Recherche_Form(1,$NoVisu);
    break;
    case 2:
      echo "<form name='info'>";
      echo "<TABLE border=1><TR><TH>Date</TH><TD>".Cree_Entree_Type("intervalle",2,0,"",RECHERCHE)."</TD></TR>";
      echo "<TR><TH>Type commande</TH><TD>";
      $out = "Facture détaillée<input type='checkbox' name='DOFD' value='1' checked><BR>";
      $out .= "Bulletin de livraison<input type='checkbox' name='DOBP' value='1' checked><BR>";
      $out .= "Facture bulletin de livraison<input type='checkbox' name='DOFB' value='1' checked><BR>";
      $out .= "Facture véhicule neuf<input type='checkbox' name='DOFV' value='1' checked><BR>";
      $out .= "Facture véhicule occasion<input type='checkbox' name='DOFO' value='1' checked><BR>";
      $out .= "Facture location<input type='checkbox' name='DOFL' value='1' checked><BR>";
      $out .= "Facture interne<input type='checkbox' name='DOFI' value='1' checked><BR>";
      $out .= "Commande pièces<input type='checkbox' name='DOCP' value='1' checked><BR>";
      $out .= "Offre pièces<input type='checkbox' name='DOOP' value='1' checked><BR>";
      $out .= "Offre véhicule<input type='checkbox' name='DOOV' value='1' checked><BR>";
      $out .= "Devis<input type='checkbox' name='DODP' value='1' checked><BR>";
      $out .= "Garantie fourniseur<input type='checkbox' name='DOGF' value='1' checked><BR>";
      $out .= "Garantie garage<input type='checkbox' name='DOGG' value='1' checked><BR>";
      $out .= "Reprise véhicule<input type='checkbox' name='DORV' value='1' checked><BR>";
      $out .= "Note de crédit facture détaillée<input type='checkbox' name='DOND' value='1' checked><BR>";
      $out .= "Note de crédit facture bulletin liv<input type='checkbox' name='DONB' value='1' checked><BR>";
      $out .= "Note de crédit véhicule neuf<input type='checkbox' name='DONV' value='1' checked><BR>";
      $out .= "Note de crédit véhicule occasion<input type='checkbox' name='DONO' value='1' checked><BR>";
      $out .= "Note de crédit location<input type='checkbox' name='DONL' value='1' checked><BR>";
      $out .= "Achat marchandise<input type='checkbox' name='DOAM' value='1' checked><BR>";
      $out .= "Achat véhicule neuf<input type='checkbox' name='DOVV' value='1' checked><BR>";
      echo $out;
      echo "</TD></TR>";
      echo "</TABLE>";
      echo "<input type='hidden' name='Type' value=$Type>";
      echo "<input type='hidden' name='Sous_Type' value=$Sous_Type>";
      echo "<input type='hidden' name='Etape' value='3'>";
      echo "<input type='hidden' name='NoArticle' value='$NoArticle'>";
      echo "<script language=JavaScript>\n";
      echo "force_submit=true;\n";
      echo "this.document.forms['info'].elements[0].focus();\n";
      echo "</script>\n";
      echo "<button type='button' onClick='submit_ok(this.form);'>Rechercher</button>";
      echo "</form>";
    break;
    case 3:
      echo "<big>$NoArticle</big><br>\n";
      $plus='';
      if(!isset($DOFD))
      {
         $plus .= " AND commande".ID_GARAGE.".Type!='FD'";
      }
      if(!isset($DOBP))
      {
         $plus .= " AND commande".ID_GARAGE.".Type!='BP'";
      }
      if(!isset($DOFB))
      {
        $plus .= " AND commande".ID_GARAGE.".Type!='FB'";
      }
      if(!isset($DOFV))
      {
        $plus .= " AND commande".ID_GARAGE.".Type!='FV'";
      }
      if(!isset($DOFO))
      {
        $plus .= " AND commande".ID_GARAGE.".Type!='FO'";
      }
      if(!isset($DOFL))
      {
        $plus .= " AND commande".ID_GARAGE.".Type!='FL'";
      }
      if(!isset($DOFI))
      {
        $plus .= " AND commande".ID_GARAGE.".Type!='FI'";
      }
      if(!isset($DOCP))
      {
        $plus .= " AND commande".ID_GARAGE.".Type!='CP'";
      }
      if(!isset($DOOP))
      {
        $plus .= " AND commande".ID_GARAGE.".Type!='OP'";
      }
      if(!isset($DOOV))
      {
        $plus .= " AND commande".ID_GARAGE.".Type!='OV'";
      }
      if(!isset($DODP))
      {
        $plus .= " AND commande".ID_GARAGE.".Type!='DP'";
      }
      if(!isset($DOGF))
      {
        $plus .= " AND commande".ID_GARAGE.".Type!='GF'";
      }
      if(!isset($DOGG))
      {
        $plus .= " AND commande".ID_GARAGE.".Type!='GG'";
      }
      if(!isset($DORV))
      {
        $plus .= " AND commande".ID_GARAGE.".Type!='RV'";
      }
      if(!isset($DOND))
      {
        $plus .= " AND commande".ID_GARAGE.".Type!='ND'";
      }
      if(!isset($DONB))
      {
        $plus .= " AND commande".ID_GARAGE.".Type!='NB'";
      }
      if(!isset($DONV))
      {
        $plus .= " AND commande".ID_GARAGE.".Type!='NV'";
      }
      if(!isset($DONO))
      {
        $plus .= " AND commande".ID_GARAGE.".Type!='NO'";
      }
      if(!isset($DONL))
      {
        $plus .= " AND commande".ID_GARAGE.".Type!='NL'";
      }
      if(!isset($DOAM))
      {
        $plus .= " AND commande".ID_GARAGE.".Type!='AM'";
      }
      if(!isset($DOVV))
      {
        $plus .= " AND commande".ID_GARAGE.".Type!='VV'";
      }
      $requette="SELECT commande".ID_GARAGE.".NoCommande, commande".ID_GARAGE.".Type, commande".ID_GARAGE.".DateCommande, commandearticles".ID_GARAGE.".Quantite, commandearticles".ID_GARAGE.".PrixMulti FROM commande".ID_GARAGE." RIGHT JOIN commandearticles".ID_GARAGE." ON commande".ID_GARAGE.".NoCommande=commandearticles".ID_GARAGE.".NoCommande WHERE commandearticles".ID_GARAGE.".NoArticle='".addslashes($NoArticle)."' AND ".Requette_Recherche("DateCommande",18,$intervalle)."$plus ORDER BY commande".ID_GARAGE.".Type, commande".ID_GARAGE.".DateCommande";
	  echo $requette;
      $resultat=Connection::executeRawQueryWithfetchAll($requette);
      echo "<TABLE border=1>";
      foreach($resultat as $ligne)
      {
         echo "<TR><TD>".Cree_Entree_Type("date",32,0,$ligne[0],AFFICHAGE)."</TD><TD>".Cree_Entree_Type("date",21,0,$ligne[1],AFFICHAGE)."</TD><TD>".Cree_Entree_Type("date",2,0,$ligne[2],AFFICHAGE)."</TD><TD>".$ligne[3]."</TD><TD>".$ligne[4]."</TD></TR>";
      }
      echo "</TABLE>";
    break;
  }
?>
