<?php
  switch($Etape)
  {
    case 0:
      echo "<form name='info'>";
      echo "Nom du stock <input type='text' name='Stock' value='' size=10 MAXLENGTH=10><BR>";
      echo "No article <input type='text' name='NoArticle' value=''><BR>";
      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 "<button type='submit' name='action' value='zero'>Remise à zéro</button><br /><br />";
      echo "<button type='submit' name='action' value='lieux'>Reinitialise tous les lieux stoquage pour les articles où le quantité est 0</button>";
      echo "</form>";
    break;
    case 1:
	  switch ($action)
	  {
	    case "zero":
	      if ($Stock == "")
	      {
		    $requette="UPDATE stock".ID_GARAGE." SET EnStock=0 WHERE (LieuxStock IS NULL OR LieuxStock = '') AND NoArticleRR LIKE '".$NoArticle."%'";
		    Connection::executeRawQuery($requette);
	      }
          $requette="UPDATE stock".ID_GARAGE." SET EnStock=0 WHERE LieuxStock LIKE '".addslashes($Stock)."' AND NoArticleRR LIKE '".$NoArticle."%'";
          Connection::executeRawQuery($requette);
		break;
	    case "lieux":
		  $requette="UPDATE stock".ID_GARAGE." SET LieuxStock='' WHERE EnStock=0 AND EnTransfert=0";
      Connection::executeRawQuery($requette);
		break;		
	  }
    break;
  }
?>
