<?php
session_start();
require('../cfg/cfg.php');
require('../cfg/res.php');
require('../../_lib/vr_updcol.php');

include('php_gene1.php');
include('php_session.php');

$pagina_descri='REGISTRO DE PAGOS ';
$pagina_nivel;
$pagina_tipo;

$xdocu=$_GET['docu'];
$xidnum=$_GET['idnum'];

$tabla=r_fiel('docu',$xdocu,'tabla');

$sql_pago ='select *, ';
if($tabla=='comp')
{
  $sql_pago.='sum(tsubtiva0) as stsubtiva0, ';
  $sql_pago.='sum(tsubtiva) as stsubtiva, ';
  $sql_pago.='sum(tiva) as stiva, ';
  $sql_pago.='sum(tice) as stice, ';
}
$sql_pago.='sum(total) as stotal ';
$sql_pago.='from '.$tabla.'12 where idnum1="'.$xidnum.'"';
$res_pago=mysql_query($sql_pago,$link_vcrx);


$res_pago=mysql_query($sql_pago,$link_vcrx);
// echo $sql_pago;

if(mysql_num_rows($res_pago)==0)
{
	die('NO SE ENCONTRARON RESULTADOS');
}
$idnum=@mysql_result($res_pago,0,'idnum1');
$docu=@mysql_result($res_pago,0,'docu');
$ptoe=@mysql_result($res_pago,0,'ptoe');
$numero=@mysql_result($res_pago,0,'numero');
$ptonumero=@mysql_result($res_pago,0,'ptonumero');
$ci=@mysql_result($res_pago,0,'enti');
// $docuenti=@mysql_result($res_pago,0,'docuenti1');
$docuenti=$docu.$ptoe.$numero.$ci;
$entidad=@mysql_result($res_pago,0,'enti_descri');
$tsubtiva0=@mysql_result($res_pago,0,'stsubtiva0');
$tsubtiva=@mysql_result($res_pago,0,'stsubtiva');
$tiva=@mysql_result($res_pago,0,'stiva');
$tice=@mysql_result($res_pago,0,'stice');
$valor=@mysql_result($res_pago,0,'stotal');
$abono=0;


if($tabla=='comp')
{
  
updt_itemce($docu,$idnum);
updt_ctascomp($docu,$idnum);
}

$fecha1 = date ( 'Y-m-01' , strtotime('today -1 month') );
$numret='000000001';

$ptoerp="001001";
if(mb_stristr('enm1.',$cfg_empr)){$ptoerp='001101';}

$sql_retp ='select ptoe from retp1 where status!="O" and status!="X" ';
// $sql_retp.=' and fecha>="'.$fecha1.'" ';
$sql_retp.=' and ptoe!="" and ptoe is not null';
$sql_retp.=' order by idnum1 desc limit 1';
$res_retp=mysql_query($sql_retp,$link_vcrx);
if(mysql_num_rows($res_retp)!=0){$ptoerp=@mysql_result($res_retp,0,'ptoe');}

$numret=nume_docu('RPRO',$ptoerp);


// $sql_pago2='select sum(abs(abono)) as abono from cxpa2 where docuenti2="'.$docuenti.'"';
// $res_pago2=mysql_query($sql_pago2,$link_vcrx);
// if(mysql_num_rows($res_pago2)!=0){$abono=@mysql_result($res_pago2,0,'abono');}

$sql_ucair = 'update retp2 set cair="-" where (cair ="" or cair is null)  and idnum2='.'"'.$xidnum.'"'; 	
$res_ucair=mysql_query($sql_ucair,$link_vcrx);


if($tabla=='comp')
{
  
$sql_ucair = 'update comp2,cair0 set rrta=cair_porc where trim(cair)=trim(cair_codigo) and (rrta=0 or rrta is null) and idnum2='.'"'.$xidnum.'"'; 	
$res_ucair=mysql_query($sql_ucair,$link_vcrx);

// $sql_rrta='select *from comp13 where idnum1='.'"'.$xidnum.'"';
$sql_rrta ='select cair,sum(tsubt) as tsubt, sum(tdcto) as tdcto, prrta, sum(rrta) as rrta from comp12 ';
$sql_rrta.=' where idnum1='.'"'.$xidnum.'" ';
$sql_rrta.=' group by idnum1,cair order by cair';

$sql_riva ='select iva, sum(tiva) as tiva, priva, sum(riva) as riva from comp12 ';
$sql_riva.=' where idnum1='.'"'.$xidnum.'" and iva>0';
$sql_riva.=' group by idnum1,priva order by priva';

}
// $saldo=$valor-abs($abono);


$saldo=sal_docu($docu,$idnum);
$abono=$valor-$saldo;

?>
<?php 
	if(isset($xidnum) && !empty($xidnum))
	{
		$sql_cxpa='select *from cxpa2 where docuenti2="'.$docuenti.'" order by fecha desc,docum';
		$res_cxpa=mysql_query($sql_cxpa,$link_vcrx);

?>
	

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>Pago a Proveedores</title>
<style type="text/css">
body{ font-family:"Courier New", Courier, monospace; font-size:12px;}

body input {font-family: courier new; font-size:14px;}
body button {font-family: courier new; font-size:14px;}
body textarea {font-family: courier new; font-size:14px;}

</style>
<script type="text/javascript" src="../js/jquery-1.11.1.js"></script>
<script type="text/javascript" src="http://vcrxol.com/_js/js_gene1.js<?php echo $jsver?>"></script>
<script type="text/javascript">
  


var numero='<?php echo $numero;?>';
var idnum='<?php echo $xidnum;?>';
function valida_docu()
{

var docux=document.getElementById('docu').value;
var saldoxtot=<?php echo str_replace(',','.',$saldo);?>;
// var cant=parseInt(document.getElementById('cant').value);
// var base=parseInt(document.getElementById('base').value);
// var porc=parseInt(document.getElementById('porc').value);
var cant=parseFloat(document.getElementById('cant').value);
var base=parseFloat(document.getElementById('base').value);
var porc=parseFloat(document.getElementById('porc').value);
var reg='';

	
document.getElementById('msjerr').innerHTML='';
	
	
// reg=/(RP)/;
// if(reg.test(docu))
// {cant=base*porc/100;}	
  
if(docux.indexOf('RP')>=0){cant=base*porc/100; }	

	
// if(saldoxtot<cant)
if((cant-saldoxtot)>1/100)
{document.getElementById('msjerr').innerHTML='Cantidad ('+cant.toFixed(2)+') no puede ser mayor al Saldo :'+saldoxtot.toFixed(2);
return false;
}
// else
// {
// 	document.getElementById('msjerr').innerHTML='';
// }

if(cant<=0)
{
	console.log(cant);
	document.getElementById('msjerr').innerHTML='Cantidad no puede ser menor o igual a cero';
	return false;
}
// else
// {
// 	document.getElementById('msjerr').innerHTML='';
// }



docux=docux.trim();


if(docux.length!=4)
{
// 	document.getElementById('msjerr').innerHTML='Documento Incorrecto';
}
else
{
	document.getElementById('msjerr').innerHTML='';
	
}
graba_c();


}

function graba_c()
{
	
	
	var docu=document.getElementById('docu').value;
	var ptoe=document.getElementById('ptoe').value;
	var numer=document.getElementById('numero').value;
	var fecha=document.getElementById('fecha').value;	
	var cant=document.getElementById('cant').value;
	var caja=document.getElementById('caja').value;
	var ctab=document.getElementById('ctab').value;
	var benefic=document.getElementById('benefic').value;
	var cair=document.getElementById('cair').value;
	var base=document.getElementById('base').value;	
	var porc=document.getElementById('porc').value;
	var concepto=document.getElementById('concepto').value;
	var id_retorno;

	document.getElementById('msjerr').innerHTML='-*-';
  
// 	console.log(concepto);
	if(docu=="" && cant>""){docu="EE10";}
// console.log('grabando');
	
	reg=/(RP)/;
	if(reg.test(docu)){cant=base*porc/100;}
	
	
	msgconfir='GRABAR '+docu+' '+numer+' --> $'+cant+' ?';
	if (confirm(msgconfir)) 
	{
// console.log('grabando');
		$.ajax({
		cache:false,
		url:'../lib/vrpago2.php',
		datatype: "text",
	  async:true,
		type:'POST',
		data:{docu:docu,ptoe:ptoe,numer:numer,cant:cant,fecha:fecha,caja:caja,ctab:ctab,
					benefic:benefic,cair:cair,base:base,porc:porc,
					idnum:'<?php echo $idnum;?>',
					ci:'<?php echo $ci;?>',
					docum:'<?php echo $docu;?>',
					numero:'<?php echo $numero;?>',
					ptoem:'<?php echo $ptoe;?>',
					concepto:concepto},
   	beforeSend: function(jqXHR, textStatus){}, 
		success:function(dato, textStatus, jqXHR)
		{
// 			alert(dato);
			console.log(dato);
			document.getElementById('msjerr').innerHTML=dato;

      if(dato.toUpperCase().indexOf('ERROR')<0)
      {
        id_retorno=parseInt(dato);
        if(isNaN(id_retorno)){window.location.reload();}
      }
      
		},
		error:function(jqXHR,textStatus,errorThrown )
		{
// 			console.log(dato);
// 			document.getElementById('msjerr').innerHTML=dato;
           if (jqXHR.status === 0) {
              console.log('Not connect: Verify Network.');
           } else if (jqXHR.status == 404) {
               console.log('Requested page not found [404]');
           } else if (jqXHR.status == 500) {
               console.log('Internal Server Error [500].');
           } else if (exception === 'parsererror') {
               console.log('Requested JSON parse failed.');
           } else if (exception === 'timeout') {
               //console.log('Time out error.');
			   alert('Servidor no Responde');
           } else if (exception === 'abort') {
               console.log('Ajax request aborted.');
           } else {
               console.log('Uncaught Error: ' + jqXHR.responseText);
           }

		}, 
	    complete:function(jqXHR, textStatus)
    	{
			if(textStatus==='success')
	        {
			}           
		},
		timeout:30000
	});
	
	}
}

function _docu(e)
{
	
	var doc=document.getElementById('docu').value;
// 		doc=doc.toUpperCase();
	var reg='';
// 	var elemento=document.getElementsByClassName('th_caja').length;

	esconde();
	muestra('th_cant');

	document.getElementById('msjerr').innerHTML='DOCUMENTO NO VALIDO';
	
	reg=/(EE)|(EV)|(CH)|(RP)|(DP)|(AP)|(ND)|(CC2)/;	
	if(reg.test(doc))
	{
// 	document.getElementById('grabar').disabled='false';
	document.getElementById('msjerr').innerHTML='';
	
	muestra('th_numero');
	muestra('th_fecha');
	muestra('th_concepto');

	reg=/(EE)/;	
	if(reg.test(doc))
	{
		muestra('th_caja');
	}
	
	reg=/(^AP11)|(CC29)|(^CH)|(DB)|(DC)|(DP)|(ND)|(PR)|(EV)/;
	if(reg.test(doc))
	{
		muestra('th_ctab');
	}

	
	reg=/(CH)/;
	if(reg.test(doc))
	{
		muestra('th_benefic');
	}
	

	reg=/(EE)/;
	if(reg.test(doc))
	{
		document.getElementById('th_ptoe').style.display='none';
	}
	

	reg=/(RP)/;
	if(reg.test(doc))
	{		
		muestra('th_ptoe');
		muestra('th_cair');
		muestra('th_base');		
		muestra('th_porc');		
		document.getElementById('th_cant').style.display='none';
		document.getElementById('th_ctab').style.display='none';
	}
	
	//reg=/(*)/;
	if(doc=='*')
	{	
		muestra('th_caja');
   	muestra('th_ctab');	
   	muestra('th_benefic');	
		muestra('th_cair');
		muestra('th_base');		
	}
	}	
}


function muestra(columna)
{
	document.getElementById(columna).style.display='table-cell';
}

function esconde()
{
// 	document.getElementById('th_cant').style.display='none';
// 	document.getElementById('th_numero').style.display='none';
// 	document.getElementById('th_fecha').style.display='none';
// 	document.getElementById('th_concepto').style.display='none';

	document.getElementById('th_ptoe').style.display='none';
	document.getElementById('th_difer').style.display='none';
	document.getElementById('th_caja').style.display='none';
	document.getElementById('th_ctab').style.display='none';
	document.getElementById('th_benefic').style.display='none';
	document.getElementById('th_cair').style.display='none';
	document.getElementById('th_base').style.display='none';
	document.getElementById('th_porc').style.display='none';

// 	document.getElementById('grabar').disabled='true';

}


	
function fecha(e,e2)
{
//if(e.keyCode==9 || e.keyCode==13)
// validar fecha desde hasta
	var xnumbloq=document.getElementById(e2).value.toUpperCase();
		xvnum='0123456789-/';
		xnum='';
		for (i=0; i<xnumbloq.length;i++)
			{
				xcar=xnumbloq.substring(i,i+1);	
				if (xvnum.indexOf(xcar)>=0){xnum+=xcar;}
			}
		 	document.getElementById(e2).value=xnum;
	
	
var fn=document.getElementById(e2).value;
if(e.keyCode==13 || e.keyCode==9)
{
		fn=fecha_format(fn);
		document.getElementById(e2).value=fn;

		var xfecha=new Date(document.getElementById(e2).value);
		var xdate = new Date();
		var xdif=parseInt(xfecha-xdate)/(1000*60*60*24);
		var xdaten=xdate.getFullYear()+'-'+xdate.getMonth()+1+'-'+xdate.getDate();

		if (xdif>365){document.getElementById(e2).value=xdaten;}
		if (xdif<-30){document.getElementById(e2).value=xdaten;}
}	
}

function _cant()
{
	document.getElementById('th_difer').style.display='none';
	var xsaldo= document.getElementById("idsaldo").value;
	var xcant= document.getElementById("cant").value;
	xsaldo=parseFloat(xsaldo.replace(",",""));
	xcant=parseFloat(xcant.replace(",",""));
	var xdife=(xsaldo-xcant).toFixed(2);

	document.getElementById("difer").value=(xdife);
	if(xdife<0)
	{
		muestra('th_difer');
	}
}
	
	
function _numero(e)
{
	var pad0="000000000";
	var num1=parseInt(document.getElementById("numero").value)+"";
	num1=num1.trim();
	if(num1=="NaN")
	{
		num1="1";
	}
	if(e.keyCode==9 || e.keyCode==13)
	{
		document.getElementById("numero").value=pad0.substring(0, pad0.length-num1.length)+num1;
		document.getElementById("fecha").focus();
	}
	if(e.keyCode==13)
	{
//                 carga_reg_docu();
//                 carga_docu_deta();
	}
}
	
function _ptoe(e)
{
	if(e.keyCode==9 || e.keyCode==13)
	{
		var pad0="001001";
		var num1=parseInt(document.getElementById("ptoe").value)+"";
		num1=num1.trim();
		if(num1=="NaN")
		{
			num1="1";
		}
		//if(e.keyCode==9 || e.keyCode==13)
			document.getElementById("ptoe").value=pad0.substring(0, pad0.length-num1.length)+num1;
		if(e.keyCode==13)
		{
// 			busca_ndocu(document.getElementById('docu').value,document.getElementById('ptoe').value,'numero');
		}
		if(e.keyCode==9)
		{	
// 			document.getElementById('numero').focus();
		}
	
	}
}


	
function numbloq(e,e2)
{
	var xnumbloq=document.getElementById(e2).value.toUpperCase();
		xvnum='0123456789';
		xnum='';
		for (i=0; i<xnumbloq.length;i++)
			{
				xcar=xnumbloq.substring(i,i+1);	
				if (xvnum.indexOf(xcar)>=0){xnum+=xcar;}
			}
		 	document.getElementById(e2).value=xnum;
}

function valbloq(e,e2)
{
	var xnumbloq=document.getElementById(e2).value.toUpperCase();
		xvnum='0123456789.';
		xnum='';
		for (i=0; i<xnumbloq.length;i++)
			{
				xcar=xnumbloq.substring(i,i+1);	
				if (xvnum.indexOf(xcar)>=0){xnum+=xcar;}
				if (xcar=='.'){xvnum=xvnum.replace('.','');}
				if (xcar=='-'){xvnum=xvnum.replace('-','');}
				
			}
// 		xnum=xnum.replace('..','.')
		 	document.getElementById(e2).value=xnum;
}
	
<?php include('../../_js/busca_maes3.js');?>
<?php include('../../_js/lista_maes3.js');?>
<?php include('../../_js/fecha_format.js');?>

// 	window.onload=esconde();
</script>
</head>

<body>

<div align="center">
<div align="center" style="">

<?php include('../../_lib/cabecera2.php');?>
<br/>


<table width="100%" border="1" cellpadding="0" cellspacing="0" style="font-size:14px;">
<tr valign="top" style="">
	<td >
	<table border="0" cellpadding="2" cellspacing="0" >
    	<tr><td style="font-weight:bolder">DOCUMENTO:</td>
				<td><div><?php echo $docu.' - '.mysql_result($res_pago,0,'docu_descri');;?> </div></td></tr>
        <tr>
					<td style="font-weight:bolder">NUMERO :</td>
					<td><div>
						<a href="../lib/celectop1.php?docu=<?php echo mysql_result($res_pago,0,'docu'); ?>&idnum=<?php echo mysql_result($res_pago,0,'idnum1'); ?>&formato=1" target="_blank">
							<?php echo $ptonumero;?></a>
					</div></td>
				</tr>
        <tr>
					<td style="font-weight:bolder">PROVEEDOR :</td>
					<td><div>
						<a href="lblenti0.php?ci=<?php echo mysql_result($res_pago,0,'enti'); ?>" target="_blank">
						<?php echo mysql_result($res_pago,0,'enti')?></a>
						<?php echo' - '.$entidad;?> </div></td>
				</tr>
        <tr><td style="font-weight:bolder">SUSTENTO :</td><td style="font-size:12px;"><div><?php echo split_words(@mysql_result($res_pago,0,'suco').' - '.r_fiel('suco',@mysql_result($res_pago,0,'suco')));?> </div></td></tr>
        <tr><td style="font-weight:bolder">CONCEPTO :</td><td><div><?php echo @mysql_result($res_pago,0,'concepto');?> </div></td></tr>
	</table>    
    </td>
<!--     echo '<font color="red">' -->
  <?php
    $tiporuc=@mysql_result($res_pago,0,'enti_tiporuc');
    $rise=@mysql_result($res_pago,0,'enti_rise');
    $obcon='S';
    if($tiporuc=='N')
    {
     $obcon='N';
     if(mysql_result($res_pago,0,'enti_obcon')==1){$obcon='S';}
    }
  ?>
	<td>
	<table border="0" cellpadding="2" cellspacing="0" >
    	  <tr><td style="font-weight:bolder">FECHA :</td><td><div><?php echo mysql_result($res_pago,0,'fechadmy');?> </div></td></tr>
        <tr><td style="font-weight:bolder">VENCE :</td><td><div><?php echo mysql_result($res_pago,0,'vencedmy');?> </div></td></tr>
        <tr><td style="font-weight:bolder">T. RUC:</td><td><div><?php echo $tiporuc;?> </div></td></tr>
        <tr><td style="font-weight:bolder">CONTAB:</td><td><div><?php echo $obcon;?> </div></td></tr>
	</table>    
    </td>
    
	<td>
	<table border="0" cellpadding="2" cellspacing="0" >
    	<tr><td style="font-weight:bolder" align="right">S.TOT IVA 0:</td><td><div align="right"><?php echo number_format($tsubtiva0,2);?>  </div></td></tr>
    	<tr><td style="font-weight:bolder" align="right">S.TOT IVA:</td><td><div align="right"><?php echo number_format($tsubtiva,2);?>  </div></td></tr>
    	<tr><td style="font-weight:bolder" align="right">I.C.E.</td><td><div align="right"><?php echo number_format($tice,2);?>  </div></td></tr>
    	<tr><td style="font-weight:bolder" align="right">I.V.A.</td><td><div align="right"><?php echo number_format($tiva,2);?>  </div></td></tr>

	</table>    
    </td>
    
	<td>
	<table border="0" cellpadding="2" cellspacing="0" >
		
		
		
			<tr><td style="font-weight:bolder" align="right">TOTAL :</td><td><div align="right"><?php echo number_format($valor,2);?>  </div></td></tr>
       <tr><td style="font-weight:bolder" align="right">ABONO :</td><td><div align="right"><?php echo number_format($abono,2);?> </div></td></tr>
       <tr><td style="font-weight:bolder" align="right">SALDO :</td><td><div align="right"><?php echo number_format($saldo,2);?>  </div></td></tr>
				<tr><td>
				<div><input type="hidden" id="idsaldo" value="<?php echo number_format($saldo,2);?>" /></div>
					</td>
				</tr>
		
	</table>    
    </td>

	<td style="<?php if($tabla!='comp'){echo 'display:none;';} ?>">
	<table border="0" cellpadding="2" cellspacing="0" width ="100%" >
			<th align="center">CAIR</th>
			<th align="center">BASE</th>
			<th align="center">%</th>
			<th align="center">RETE</th>
			<?php
// 			echo explain_sql($sql_rrta);
			 $res_rrta=mysql_query($sql_rrta,$link_vcrx);
				while($row_rrta=@mysql_fetch_assoc($res_rrta) )
				{
			?>
			<tr>
				<td align="center"><?php echo $row_rrta['cair'];?></td>
				<td align="right"><?php echo number_format($row_rrta['tsubt']-$row_rrta['tdcto'],2);?></td>
				<td align="center"><?php echo number_format($row_rrta['prrta'],2);?></td>
				<td align="right"><?php echo number_format($row_rrta['rrta'],2);?></td>
			</tr>
			<?php
				}
			?>
			<?php
// 			echo explain_sql($sql_rrta);
			 $res_riva=mysql_query($sql_riva,$link_vcrx);
				while($row_riva=@mysql_fetch_assoc($res_riva) )
				{
			?>
			<tr>
				<td align="center"><?php echo 'IVA '.number_format($row_riva['iva'],0).'';?></td>
				<td align="right"><?php echo number_format($row_riva['tiva'],2);?></td>
				<td align="center"><?php echo number_format($row_riva['priva'],2);?></td>
				<td align="right"><?php echo number_format($row_riva['riva'],2);?></td>
			</tr>
			<?php
				}
			?>
	</table> 
	<table border="0" cellpadding="2" cellspacing="0" width ="100%">
	<?php $pcaption='NUM.RET'; $pidtxt='numret'; $pobj=3; $plong=9; $pdefa=fillzero($numret); include('vrgetnum.php'); ?>
  <?php //echo $fecha1;?>
  <?php //echo date('Y-m-d',strtotime($fecha1.' +5 days'));?>
	</table> 
	<table border="0" cellpadding="2" cellspacing="0" width ="100%">
  <?php $pidtxt='genrpro'; $pcaption='GEN.RET.'; $psize=$xfontsize;
    $ponclick="if(confirm('Generar RETENCIONES ?')){gen_rpro('".$idnum."'); window.location.reload();}";
    include('vrbutton.php'); ?>
	</table> 
	
  </td>
	
	
</tr>

</table>
	
<!-- <div id="msjerr" style="height:25px; margin:5px"></div> -->
<table width="100%" border="0" cellpadding="2" cellspacing="0"  style="border-collapse:collapse; background:#eee;">
<tr align="center" valign="top" style="border-top: solid 1px;border-bottom: solid 1px">
<?php $pcaption='DOCU'; $ptabla='docu'; $pobj=4; $plong=4; $ponblur='_docu(event);'; $pdefa='EE10'; include('vrgetcod.php'); ?>

<?php $pcaption='P.EMI.'; $pidtxt='ptoe'; $pobj=2; $plong=6; $pdefa=$ptoerp; include('vrgetnum.php'); ?>

<?php $pcaption='NUMERO'; $pidtxt='numero'; $pobj=2; $plong=9; include('vrgetnum.php'); ?>
	
<?php $pcaption='FECHA'; $pidtxt='fecha'; $pobj=2;     include('vrgetfec.php'); ?>
	
<?php $pcaption='CANTIDAD'; $pidtxt='cant'; $pobj=2;  $ponblur='_cant();'; include('vrgetval.php'); ?>

<?php $pcaption='DIFERENCIA'; $pidtxt='difer'; $pobj=2; $plong=9;  include('vrgetval.php'); ?>

<?php $pcaption='CAJA'; $ptabla='caja'; $pobj=2; $plong=4;  include('vrgetcod.php'); ?>

<?php $pcaption='CTA.BAN.'; $ptabla='ctab'; $pobj=2; $plong=4;  include('vrgetcod.php'); ?>


<?php $pcaption='BENEFICIARIO'; $pidtxt='benefic'; $pobj=2; $plong=20;  include('vrgettxt.php'); ?>

<?php $pcaption='CAIR'; $ptabla='cair'; $pobj=2; $plong=4;  include('vrgetcod.php'); ?>

<?php $pcaption='BASE'; $pidtxt='base'; $pobj=2;   include('vrgetval.php'); ?>

<?php $pcaption='%'; $pidtxt='porc'; $pobj=2;   include('vrgetval.php'); ?>
	
<?php $pcaption='CONCEPTO'; $pidtxt='concepto'; $pobj=2; $plong=20;  include('vrgettxt.php'); ?>

	<th align="left">
    <div><input type="button" accesskey="G" id="grabar"  width="88" height="22" src="http://vcrxol.com/_img/ico_plus2.png" onClick="valida_docu()" value="GRABAR" style="font-weight:bold"/></div>
<!-- 		<input src="http://vcrxol.com/_img/ico_plus.png"  type="image" onclick="valida_docu()" width="19"> -->
	</th>
</tr>

</table>

<?php include('vrmsjerr.php') ?>
<!-- <span id="msjerr" style="height:25px; margin:5px; color:red; font-weight:bold; font-size:20px;"></span> -->

<!-- <div align="left"><b>Detalle de Pagos	</b></div> -->
<div id="detalle">
<br/>
<table width="100%" border="0" cellpadding="2" cellspacing="0" class="tablitita"   style="border-collapse:collapse; font-size:14px;">
   <tr style="border-bottom:solid 2px;" align="center">
			<th></th>
			<th>DOCUMENTO</th>
			<th>NUMERO</th>
			<th>FECHA</th>
			<th>VALOR</th>
			<th>CONCEPTO</th>
			<th></th>
			<th></th>
			<th></th>
			<th></th>
		</tr>
<?php	$aux=0;	
	if(mysql_num_rows($res_cxpa)==0)
	{echo 'NO HAY DETALLE';}
	else
	{
		while($row_cxpa=mysql_fetch_assoc($res_cxpa))
		{
?>
		<tr align="center" style=" <?php if($aux==2){echo "border-bottom:dotted #000000 1px;"; $aux=0;}else{ $aux++;} ?>">
    <td>
    <a href="../lib/celectop1.php?docu=<?php echo $row_cxpa['docum']; ?>&idnum=<?php echo $row_cxpa['idnum1']; ?>&formato=1" target="_blank"><img src="../img/print2.png" width="20"  title="Imprimir :<?php echo $row_cxpa['docum'];?>-<?php echo $row_cxpa['ptonumer'];?>"  /></a>
			</td>
			<td align="left"><?php echo $row_cxpa['docum'].' -'.$row_cxpa['docu_descri'];?></td>
            <td><?php echo $row_cxpa['ptonumer'];?>  </td>
            <td><?php echo $row_cxpa['fechadmy'];?> </td>
            <td align="right"><?php echo number_format(abs($row_cxpa['tcant']),2);?></td>
            <td align="left"><?php echo $row_cxpa['concepto'];?></td>
            <td><?php echo $row_cxpa['caja_descri'];?></td>
            <td>
							<?php echo $row_cxpa['ctab_descri'];?>
							<?php if ($row_cxpa['benefic']>""){$row_cxpa['benefic'];}?>
						</td>
            <td><?php echo $row_cxpa['cair'];?></td>
            <td><?php  if($row_cxpa['puni']>0){echo number_format($row_cxpa['puni'],2).'%';}?></td>
<!--             <td></div></td> -->
    <td align="center" style="border-left:#000000 solid 1px;">
	       	<input type="image" id="a_pedido" src="http://vcrxol.com/_img/ico_anula.png" width="25" title="Anular <?php echo $row_cxpa['docum'];?>-<?php echo $row_cxpa['ptonumer'];?>"  onclick="docu_ox('<?php echo $row_cxpa['docum'];?>','<?php echo $row_cxpa['idnum1'];?>','','O');"  />
    </td>    
        </tr>
<?php			
		}
	}
?>
		</table>
<?php		
	}
?>
</div>


</div>
</div>

<?php		
// $xwidth=40;	
require('lista_car.php');
?>	
<!-- 
<div id="lista_temporal_contenedor" style=" display:none; padding:0px; margin:0px; background: #666; opacity:0.5; width:100%; min-height: 100%; height:auto !important;position: fixed;top:0;left:0; z-index:1;" ></div>
<div id="lista_cargador" style=" display:none; background:#FFF;position: fixed; top:50px;z-index:10;" ><img src="../img/ajax-loader.gif" /></div>    
<div id="lista_temporal" style=" display:none; background:#FFF;position: fixed; top:50px;z-index:10; overflow-y:scroll; min-height:50px; max-height:400px; width:100%;" ><img src="../img/ajax-loader.gif" /></div>    
 -->
</body>
<script>

window.onload=esconde();
</script>

</html>