<?php

//error_reporting(E_ALL);

//echo 'gfuygbn';

session_start();
require_once ("../../config/Cado.php");	
require_once ("../formatos/formato.php");
require_once ("../kardex/cKardex.php");
$oKardex = new cKardex();

require_once("../stock/cStock.php");
$oStock = new cStock();

$rs = $oKardex->kardexrecuperar();

while($dts = mysqli_fetch_array($rs)){
	
	$totent = $dts['kdentra'];
	$totsal = $dts['kdsale'];
	$preid = $dts['tb_presentacion_id'];
	$marid = $dts['tb_marca_id'];
	
	
			$dts1=$oStock->stock_por_presentacion($preid,$marid,'2');
			$dt = mysqli_fetch_array($dts1);
			$sto_id		=$dt['tb_stock_id'];
			$sto_num	=$dt['tb_stock_num'];
			mysqli_free_result($dts1);
	
	$tot = $totent - $totsal;
	
	$oStock->modificar($sto_id,$tot);
	
	
	echo 'an '.$sto_num.' ah '.$tot.' --- '.$dts['tb_producto_nom'].'</br>';
	
}



?>