<?php
  switch($Etape)
  {
    case 0:
      if(isset($Add))
      {
        $requette = "INSERT INTO compta (Vente, GM, Compte) VALUES (1, $Add, $Compte)";
        $resultat = Connection::executeRawQuery($requette);
      }
      if(isset($Modif))
      {
        $requette = "UPDATE compta SET Compte=$Compte WHERE Vente=1 AND GM=$Modif";
        $resultat = Connection::executeRawQuery($requette);
      }
      if(isset($Del))
      {
        $requette = "DELETE FROM compta WHERE Vente=1 AND GM=$Del";
        $resultat = Connection::executeRawQuery($requette);
      }
      $resultat=Compta::getByVente(1);
      echo "<table border=1>\n";
      echo "<tr><th>Groupe marchandise</th><th>Compte comptable</th><td>modifier</td><td>supprimer</td></tr>\n";
      foreach($resultat as $ligne)
      {
        echo "<tr><form>";
        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='0'>\n";
        echo "<input type='hidden' name='Modif' value='".$ligne['GM']."'>\n";
        echo "<td>".$ligne['GM']."</td><td><input type='text' name='Compte' value='".$ligne['Compte']."'></td><td><input type='submit' value='modifier'></td></form><form>";
        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='0'>\n";
        echo "<input type='hidden' name='Del' value='".$ligne['GM']."'>\n";
        echo "<td><input type='submit' value='supprimer'></td></form></tr>\n";
      }
      echo "<tr><form>";
      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='0'>\n";
      echo "<td><input type='text' name='Add'></td><td><input type='text' name='Compte'></td><td colspan=2><input type='submit' value='ajouter'></td>";
      echo "</form></tr>\n";
      echo "</table>\n";
    break;
  }
?>
