<?php

include "checklog.php";

if ($HTTP_POST_VARS["reset"] != "reset") {
	die();
}
$sql = "INSERT IGNORE INTO giacenze (codice) SELECT DISTINCT codice FROM dettaglio WHERE codice <> ''";
$result = mysql_query($sql);

$sql = "INSERT IGNORE INTO giacenze (codice) SELECT DISTINCT codice FROM opcodici WHERE codice <> ''";
$result = mysql_query($sql);

$sql = "UPDATE giacenze SET giacenza = 0 WHERE giacenza IS NULL";
if ($result = mysql_query($sql)) {
	$na = mysql_affected_rows();
	$Out = "<b>Aggiornamento completato.</b><BR>Codici aggiornati: <b>$na</b>";
}
?>
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=windows-1252">
<base target="_self">
<link rel="stylesheet" href="backoffice.css" type="text/css">
</head>
<body topmargin="0" leftmargin="4" marginwidth="4" marginheight="0" class="pagina">
<table width="100%" border="0" cellspacing="0" cellpadding="0">
  <tr> 
    <td width="50%"><span class="titolo">Gestione Giacenze - </span><span class="sottotitolo">Importazione</span></td>
    <td width="25%"><span class="sottotitolo"><a href="bogiac1.php" target="_self">&gt;&gt;Articoli</a></span></td>
    <td width="25%"><span class="sottotitolo"><a href="bogiac2.php" target="_self">&gt;&gt;Varianti</a></span></td>
    <td width="25%"><span class="sottotitolo"><a href="bogiac4.php" target="_self">&gt;&gt;Esportazione</a></span></td>
  </tr>
</table>
<p>&nbsp;</p>
<form action="bogiac3.php" method="GET">
  <table border="0" cellpadding="2" class="form">
    <tr> 
      <td nowrap> 
        <?=$Out?>
      </td>
      <td align="left" valign="middle" nowrap>&nbsp;&nbsp;&nbsp;</td>
      <td align="left" valign="middle" width="100%"> 
        <input type="submit" name="Submit" value="OK" class="pulsante">
      </td>
    </tr>
  </table>
</form>
</body>
</html>