<?php
  switch($Etape)
  {
    case 0:
      if ($resultat = CatLoc::getCatloc())
      {
        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 "   <select name='NoCatLoc'>\n";
        foreach($resultat as $ligne)
        {
          echo "    <option value='" . $ligne['NoCatLoc'] . "'>" . $ligne['NoCatLoc']. " " . $ligne['Description']. "</option>\n";
        }
        echo "   </select><BR>\n";
        echo "   <button type='submit'>Modifier</button>\n";
        echo "  </form>\n";
      }
    break;
    case 1:
      echo "  <form name='info'>\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='NoCatLoc' value=$NoCatLoc>\n";
      echo "   <input type='hidden' name='Etape' value='2'>\n";
      echo "<TABLE border=1>\n";
      echo "   <TR><TH>NoCatLoc</TH><TD><input type='texte' name='NewNoCatLoc' value='$NoCatLoc' readonly></TD></TR>\n";
      $ligne = Catloc::getCatlocByNo($NoCatLoc);
      echo "   <TR><TH>Nom</TH><TD><input type='text' name='Description' value='".$ligne['Description']."'></TD></TR>\n";
      echo "   <TR><TH>Prêt</TH><TD><input type='checkbox' name='Pret' value='1'";
      if($ligne['Pret']==1)
      {
        echo " checked";
      }
      echo "></TD></TR>\n";
      echo "</TABLE>\n";
      echo "   <button type='submit'>Valider</button>\n";
      echo "  </form>\n";
    break;
    case 2:
      if(!isset($Pret))
      {
        $Pret=0;
      }
      $requette = "UPDATE catloc SET NoCatLoc=$NewNoCatLoc, Description='$Description', Pret='$Pret' WHERE NoCatLoc=$NoCatLoc";
      if ($resultat = Connection::executeRawQuery($requette))
      {
        echo "OK";
      }
    break;
  }
?>
