<?php
 
session_start();
include("DMMYSQLG.php");
?>
<html>
<link rel="stylesheet" href="css/estilo1.css" type="text/css"/>
<script type="text/javascript" language="JavaScript1.2" src="DSSCRIPT.js"></script>
<body>
<?php

	$sqq = mysqli_query($con ,"select * from dgtipven where tip_ven = '".$_SESSION['tipven']."'");
	$rrrr = mysqli_fetch_array($sqq);

	 $_SESSION['rec_caj'] = $_REQUEST['n_r'];

	$sql=mysqli_query($con ,"select pedido from dgger_cajerosj where n_rec = '".$_REQUEST['n_r']."'");
	$rrr = mysqli_fetch_array($sql);

	$sq=mysqli_query($con ,"SELECT sum(importe) as can FROM dgger_cajerosd where n_rec in (select n_rec from dgger_cajerosj where pedido='".$rrr['pedido']."')");
	$rr = mysqli_fetch_array($sq);

	if($_REQUEST['ipa'] >= $_REQUEST['ipp']){
		$p = "S";
	}
	$can_nue = $sc + $_REQUEST['ipp'];
	$sql=mysqli_query($con ,"SELECT * FROM dgger_cajerosj where n_rec = '".$_REQUEST['n_r']."'");
	$bus = mysqli_fetch_array($sql);

	$sqlx=mysqli_query($con ,"update dgpemema set imp_pag ='".$rr['can']."', pagado = '$p' where fol_ven = '".$bus['pedido']."'");
	echo '<meta content="0; url=DG24000_RE.php?bot='.$_REQUEST['n_r'].'" HTTP-EQUIV="REFRESH">';

?>
</body>
</html>