<?php
  switch($Etape)
  {
    case 0:
      echo "<form name='info'>";
      echo "<TABLE border=1><TR><TH>Date</TH><TD>".Cree_Entree_Type("intervalle",2,0,"",RECHERCHE)."</TD></TR></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='1'>";
      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 1:
      $requette="SELECT * FROM commande".ID_GARAGE." WHERE ".Requette_Recherche("DateCommande",18,$intervalle)." AND Type='TR' ORDER BY DateCommande";
      $resultat=Connection::executeRawQueryWithfetchAll($requette);
      echo "<TABLE border=1>";
      echo "<TR><TH>No commande</TH><TH>Date</TH><TH>Montant out</TH><TH>Source</TH><TH>Montant in</TH><TH>Destination</TH></TR>";
      foreach($resultat as $ligne)
      {
        echo "<TR><TD>".$ligne["NoCommande"]."</TD><TD>".Cree_Entree_Type("date",2,0,$ligne["DateCommande"],AFFICHAGE)."</TD>";
        $resultat2=DBCash::getDBCashByNoCommande($ligne["NoCommande"]);
        if($ligne2=$resultat2[0])
        {
          $resultat3=ModePayement::getModePayementsByNoModeAndNoCaisse($ligne2["ModePayement"], $ligne2["NoCaisse"]);
          $ligne3=$resultat3[0];
          echo "<TD align='right'>".number_format($ligne2["Somme"],2,'.',"'")."</TD><TD align='right'>".$ligne3["Description"]." caisse ".$ligne2["NoCaisse"]."</TD>";
          if($ligne2=$resultat2[1])
          {
            $resultat3=ModePayement::getModePayementsByNoModeAndNoCaisse($ligne2["ModePayement"], $ligne2["NoCaisse"]);
            $ligne3=$resultat3[0];
            echo "<TD align='right'>".number_format($ligne2["Somme"],2,'.',"'")."</TD><TD align='right'>".$ligne3["Description"]." caisse ".$ligne2["NoCaisse"]."</TD>";
          }
          else
          {
            echo "<TD>&nbsp;</TD><TD>&nbsp;</TD>";
          }
        }
        else
        {
          echo "<TD>&nbsp;</TD><TD>&nbsp;</TD><TD>&nbsp;</TD><TD>&nbsp;</TD>";
        }
        echo "</TR>\n";
      }
    break;
  }
?>
<script language="javascript">
jQuery(document).ready(function($) { 
  jQuery('input').blur();
});
</script>

