<?
//return;

require_once("modules/EcmStockStates/EcmStockState.php");
$ss=new EcmStockState();
set_time_limit(1000000);

$sarr=array();
$parr=array();
$w=$GLOBALS['db']->query("select stock_id,product_id from ecmstockoperations order by date_entered");
while($r=$GLOBALS['db']->fetchByAssoc($w)){
	if(!in_array($r['stock_id'],$sarr))$sarr[]=$r['stock_id'];
	if(!in_array($r['product_id'],$parr))$parr[]=$r['product_id'];
}
for($i=0;$i<count($parr);$i++){
	for($j=0;$j<count($sarr);$j++){
		if($parr[$j] && $sarr[$j])$ss->UpdateStockState($sarr[$j],$parr[$i]);
	}
}
?>