<?php
 
	//BUSCAR NOTAS 
	$bus = mysqli_query($con ,"select * from dvnotcrd where n_reg = '$bbus'");
	$rr = mysqli_fetch_array($bus);
	//saco la cantidad
	$t = $rr['total'];
	//sumo al deudor
	$bus = mysqli_query($con ,"select * from dxbascpt where codigo = '".$rr['codigo']."'");
	$rrr = mysqli_fetch_array($bus);
	$cc = $rrr['sal_deu'] + $t;
	$bus = mysqli_query($con ,"update dxbascpt set sal_deu = '$cc' where codigo = '".$rr['codigo']."'");
	//restar datos
	//modificar datos para restar valor 
	@$sqlr = mysqli_query($con ,"select * from dvredocl where codigo = '".$rr['codigo']."' and num_doc = '".$rr['num_doc']."'");
	@$rep=mysqli_fetch_array($sqlr);
	$nc = $rep['tot_not'] - $t;
	$bus = mysqli_query($con ,"update dvredocl set tot_not = '$nc' where codigo = '".$rr['codigo']."' and num_doc = '".$rr['num_doc']."'");
	@$sqlr = mysqli_query($con ,"select * from dvredocl where codigo = '".$rr['codigo']."' and num_doc = '".$rr['num_doc']."'");
	@$rep=mysqli_fetch_array($sqlr);
	$cc = $rep['tot_doc'] - ($rep['tot_pag'] + $rep['tot_not']);
	$bus = mysqli_query($con ,"update dvredocl set tot_sal = '$cc' where codigo = '".$rr['codigo']."' and num_doc = '".$rr['num_doc']."'");
?>