<?php
 
	//sumar para los totales del encabezado
	$sqlr = mysqli_query($con ,"select * from dvnotcrd where n_nota = '$n1'");
	$iii = 0;
	$sss = 0;
	$ttt = 0;
	$can = 0;
	while($rep=mysqli_fetch_array($sqlr)){
		$iii += $rep['iva_sub'];
		$sss += $rep['sub_tot'];
		$ttt += $rep['total'];
	}
	$bus = mysqli_query($con ,"update dvnotcre set iva_not = '$iii',sub_not='$sss',tot_not='$ttt' where n_reg = '$n1'");
	//restar a dxbascpt restar saldo deudo
	$sqlr = mysqli_query($con ,"select * from dxbascpt where codigo = '$n2'");
	$ress=mysqli_fetch_array($sqlr); 	
	//echo $_REQUEST['tt7'].'<br>';
	//echo $ress['sal_deu'].'<br>';
	$can = $ress['sal_deu'] - $n4;
	//echo $can.'<br>';
	$bus = mysqli_query($con ,"update dxbascpt set sal_deu = '$can' where codigo = '$n2'");
	//sumar para sacar saldo de dvredocl
	@$sqlr = mysqli_query($con ,"select * from dvredocl where codigo = '$n2' and num_doc = '$n3'");
	@$rep=mysqli_fetch_array($sqlr);
	$nc = $rep['tot_not'] + $n4;
	$bus = mysqli_query($con ,"update dvredocl set tot_not = '$nc' where codigo = '$n2' and num_doc = '$n3'");
	@$sqlr = mysqli_query($con ,"select * from dvredocl where codigo = '$n2' and num_doc = '$n3'");
	@$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 = '$n2' and num_doc = '$n3'");
?>