<?php
require('../cfg/res.php'); 
	// Actualizado 2016-02-17
session_start();

$xvalor = str_replace('  ',' ',$_POST['codigo']);
$xvalor = str_replace('  ',' ',$xvalor);
$xvalor = str_replace('  ',' ',$xvalor);

$enti=$_POST['enti'];
$tabla=$_POST['tabla'];
$tabla11=$_POST['tabla'].'11';
$saldo0= 1/100;

// $sort;
// $tipo;
//?sqle(xcnx,'select *from cxpa11 where enti like "0915379374%"')

$enti_sql='select *from enti00';
$enti_sql.=' where enti_codigo like "'.$enti.'%"';
$enti_sql.=	' order by enti_lused ';
// echo $enti_sql;


$list_sql='select * ';
// $list_sql.=' sum'
$list_sql.=' from '.$tabla11 ;
$list_sql.=' where saldo>'.$saldo0;
$list_sql.=	' and enti like "'.$enti.'%"';
$list_sql.=	' order by fecha ';
$list_sql.=	' limit 50 ';


$xwhered= '(1=1)';	
$xacceso=0;

if($tabla=='docu')
{
if (!mb_stristr('sist.supe',$_SESSION['user_vcrx_tipo']))
	{
// 		$xwhered='(docu_codigo in(select docu from usrdoc1 where user="'.	$_SESSION['user_vcrx_id'].'" and (nuev=1 or modi=1 or proc=1 or anul=1 or cons=1 or info=1)))';
	}
}
	
// echo $list_sql;
$ind_list=0;

$enti_res=mysql_query($enti_sql,$link_vcrx);
$list_res=mysql_query($list_sql,$link_vcrx);


?>
<div style=" max-height:100px; margin-top:5px;">
	<table width="100%">
		<tr>
			<th align="left"><?php echo $enti.' - '.mysql_result($enti_res,0,'enti_descri') ?></th>
			<th align="right">
			<div><input  type="image" style="width:20px;" src="http://vcrxol.com/_img/ico_eliminar.png" onclick="document.getElementById('lista_temporal_contenedor').style.display='none';document.getElementById('lista_temporal').style.display='none';" /></div>
			</th>
		</tr>
	</table>
</div>

<div style=" max-height:400px; overflow-y:scroll; margin-top:5px;">	
<table border="0" id="tablita" align="center" width="90%" cellpadding="2" cellspacing="0" style="border-collapse:collapse; font-size:12px;">
<tr align="center" style="background: #F7F7F7; border-top:solid 1px#000;border-bottom:solid 1px#000">
<th></th>
<th>DOCU</th>
<th >PTO.EMI.</th>
<th >NUMERO</th>
<th>FECHA</th>
<th>VALOR</th>
<th>ABONO</th>
<th>SALDO</th>
<th>DIAS</th>
</tr>

<?php 
// echo $list_sql;
$filax=0;

while($r_list=mysql_fetch_assoc($list_res))
{ 
$ind_list++;?>

<tr id="list_fila<?php echo $ind_list;?>" class="list_filax" style=" <?php if($filax>=3){echo 'border-top:dotted 1px #000;';$filax=1;}else{$filax++;} ?>" onkeypress="if(event.keyCode==13){list_agrega('<?php echo $ind_list;?>','<?php echo $_POST['list_cod'];?>','<?php echo $_POST['list_desc'];?>','');}" onkeyup="if(event.keyCode==27){ document.getElementById('lista_temporal_contenedor').style.display='none';document.getElementById('lista_temporal').style.display='none';};"ondblclick="list_agrega('<?php echo $ind_list;?>');">
<td <?php if($ind_list==1){echo ' tabIndex="1"';}?> >
	<input 
				 <?php if($ind_list==1){echo 'checked';}?> 
				 type="radio"  
				 name="lista" 
				 class="opt" 
				 onfocus="list_filabg('<?php echo $ind_list;?>');"
				 xondblclick="list_agrega('<?php echo $ind_list;?>','<?php echo $_POST['list_cod'];?>','<?php echo $_POST['list_desc'];?>','');"
				 ondblclick="list_addcxcp('<?php echo $ind_list;?>','<?php echo 'docum';?>','<?php echo 'ptoem';?>','<?php echo 'numer';?>','<?php echo 'saldo';?>','');"
	/>
</td>
<td align="center"><?php echo $r_list['docu'];?></td>
<td align="center"><?php echo $r_list['ptoe'];?></td>
<td align="center"><?php echo $r_list['numero'];?></td>
<td align="center" style="border-left:solid 1px;border-right:solid 1px"><?php echo $r_list['fechadmy'];?></td>
<td align="right"><?php echo number_format($r_list['total'],2);?></td>
<td align="right" style="border-left:dotted 1px;border-right:dotted 1px"><?php echo number_format(abs($r_list['abono']),2);?></td>
<td align="right" style="font-weight:bold"><?php echo number_format($r_list['saldo'],2);?></td>
<td align="right"><?php if($r_list['diasv']>0){echo number_format($r_list['diasv'],0);}?></td>
<?php }?>

</tr>

</table>
</div>
