<?php
  switch($Etape)
  {
    case 0:
      echo "  <form>\n";
      echo "   <input type='hidden' name='Type' value=$Type>\n";
      echo "   <input type='hidden' name='Sous_Type' value=$Sous_Type>\n";
      echo "   <input type='hidden' name='Etape' value='1'>\n";
      echo "<table border=1>";
      echo "<tr><th>Date (montant cloture)</th><td>".Cree_Entree_Type("date",2,0,date("Y-m-d"),MODIFICATION)."</td></tr>";
      echo "<tr><th>Montant</th><td>".Cree_Entree_Type("montant",19,0,"0.00",MODIFICATION)."</td></tr>";
      echo "<tr><th>NoCaisse</th><td><select name='no_caisse'>";
      $nb_caisses = Config::getNbCaisse();

      for($cpt=1;$cpt<=$nb_caisses;$cpt++)
      {
        echo "<option value='$cpt'>$cpt</option>";
      }
      echo "</select></td></tr>";

      echo "</table>";
      echo "<button type='button' onClick='submit_ok(this.form);'>Valider</button>";
      echo "<button type='button' onClick='this.form.Etape.value=2;submit_ok(this.form);'>Supprimer mise à jour</button>";
      echo "</form>";
    break;
    case 1:
      $requette="INSERT INTO caisse".ID_GARAGE." (Date, NoCaisse, Montant) VALUES ('".Decode_Entree_Type($date,2)."', $no_caisse, $montant)";
      echo $requette;
      Connection::executeRawQuery($requette);
      $requette="UPDATE caisse".ID_GARAGE." SET Montant = $montant WHERE Date = '".Decode_Entree_Type($date,2)."' AND NoCaisse = $no_caisse";
      Connection::executeRawQuery($requette);
    break;
    case 2:
      $requette="DELETE FROM caisse".ID_GARAGE." WHERE Date = '".Decode_Entree_Type($date,2)."' AND NoCaisse = $no_caisse";
      echo $requette;
      Connection::executeRawQuery($requette);
    break;
  }
?>
