<script language="javascript">
document.getElementById('xndocumento').value = '';
</script>

<?php
session_start();

include("conexion.php");

@$xserie = $_REQUEST['xserie'];
@$xpagodocumento = $_REQUEST['xpagodocumento'];

$r_doc = mysqli_query($conexion,"SELECT * FROM documento_pago d WHERE docpag_codi=$xpagodocumento;");
while($row_doc=mysqli_fetch_array($r_doc)){
	$xcomtip_codigo_fk = $row_doc['comtip_codigo_fk'];
}


?>
<script language="javascript">
//alert("<?php echo $xcomtip_codigo_fk; ?> :xpagodocumento: <?php echo $xpagodocumento; ?> :xserie: <?php echo $xserie; ?>");
</script>
<?php



$r = mysqli_query($conexion,"SELECT * FROM comprobante_serie c WHERE comser_serie='$xserie' AND comtip_codigo_fk='$xcomtip_codigo_fk';");
while($row=mysqli_fetch_array($r)){
	$xcor = "0000000".$row['comser_correlativo'];
	$xcodigo = substr($xcor, strlen($xcor)-7, 7);
	
	$ncomprobante = $xserie."-".$xcodigo;
	
	//echo $ncomprobante;
	?>
	<script language="javascript">
	//alert("ncomprobante: <?php echo $ncomprobante; ?>");
	</script>
	<?php
	
	
	
	?>	
	<script language="javascript">
	
	
	document.getElementById('xndocumento').value = '<?php echo $ncomprobante;?>';
	//document.getElementById('xndocumento_nota').value = '<?php echo $ncomprobante;?>';	
	</script>
	<?php	
}

?>

