<?php
  switch($Etape)
  {
    case 0:
      if ($resultat = TypeRabais::getActiveTypeRabais())
      {
        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'>\n";
        echo "<tr><th>Code rabais</th><td><input type='text' name='NewCodeRabais' value=''></td></tr>\n";
        foreach($resultat as $ligne)
        {
          echo "<tr><th>" . $ligne['NoRabais'] . " " . htmlspecialchars($ligne['Description']) . "</th><td>";
          echo "<input type='text' name='Rabais" . $ligne['NoRabais'] . "' value='0.00'>";
          echo "</td></tr>\n";
        }
        echo "</table>\n";
        echo "   <button type='submit'>Valider</button>\n";
        echo "  </form>\n";
      }
    break;
    case 1:
      if ($resultat = TypeRabais::getActiveTypeRabais())
      {
        $requette2="INSERT INTO defaultrabais (CodeRabais";
        $requette3=') VALUES ("' . addslashes($NewCodeRabais) . '"';
        foreach($resultat as $ligne)
        {
          $requette2 .= " , RabaisType" . $ligne['NoRabais'];
          $requette3 .= ' , "' . ${"Rabais".$ligne['NoRabais']} . '"';
        }
        $requette2 .= $requette3 . ")";
        echo $requette2 . "<BR>\n";
        if ($resultat2 = Connection::executeRawQuery($requette2))
        {
        }
      }
    break;
  }
?>
