<?php
function vricont1d($grupo,$idnum,$fini,$ffin)
{
	$enti=$_POST['enti'];
	$item=$_POST['item'];
	if(isset($_POST['fini']) && !empty($_POST['fini']))
	{
		$fini=$_POST['fini'];
	}
	else
	{
		$fini=date('2000-01-01');
	}
	
	if(isset($_POST['ffin']) && !empty($_POST['ffin']))
	{
		$ffin=$_POST['ffin'];
	}
	else
	{
		$ffin=date('Y-m-d');
	}

	
	
	require('../cfg/res.php');
	mysql_query("SET NAMES 'utf8'");



?>


<?php
if($grupo=='D')
{
// 	$sql_ctas0 ='select * from ctas0 where ctas_codigo= "'.$idnum.'"' ;
//   $res_ctas0=mysql_query($sql_ctas0,$link_vcrx);
	
	$sql_ctas0 ='select * from cont12 where idnum1="'.$idnum.'" and cant!=0 order by ctas' ;
  $res_ctas0=mysql_query($sql_ctas0,$link_vcrx);
// 	echo $sql_ctas;
	echo '<b>'.mysql_result($res_ctas0,0,'docu').'-'.mysql_result($res_ctas0,0,'ptonumero').'</b>';
}
else
{	
	$sql_ctas0 ='select * from ctas0 where ctas_codigo= "'.$idnum.'"' ;
  $res_ctas0=mysql_query($sql_ctas0,$link_vcrx);
	echo '<b>'.mysql_result($res_ctas0,0,'ctas_descri').'</b>';
	
	$sql_ctas ='select * from cont12 where ctas like "'.$idnum.'%" and fecha>="'.$fini.'" and fecha<="'.$ffin.'" ' ;
	if($enti!='')
	{$sql_ctas.=' and (enti like "'.substr($enti,0,10).'%" or enti_descri like "%'.$enti.'%")' ;}
	$sql_ctas.=' order by fecha desc, idnum1' ;
  $res_ctas=mysql_query($sql_ctas,$link_vcrx);
}
// 	echo '*/*/*/'.$enti;
?>

<div style="overflow-y:scroll; height:250px; font-size:12px;">

<table id="tabla_icont1"  border="0" width="90%" cellpadding="2" cellspacing="0" style="border-collapse:collapse">

<?php if($grupo=='D'){ ?>
	<tr style="border-top:solid 1px; border-bottom:solid 1px;">
	<th>CUENTA</th>
	<th>DESCRIPCION</th>
	<th>DEBITO</th>
	<th>CREDITO</th>
	<th>CSUB</th>
	<th>DETALLE</th>
	</tr>
<?php
	$filax=0;
		$res_icont2=mysql_query($sql_ctas0,$link_vcrx);
		while($r_icont2=mysql_fetch_assoc($res_icont2))
		{			
	?>
	
	<?php $filax++; ?>
	<tr style="<?php if($filax % 5==0){echo 'border-bottom:dotted 1px;';} ?>">	
	<td><?php echo trim($r_icont2['ctas']); ?></td>
	<td><?php echo trim($r_icont2['ctas_descri']); ?></td>
	<td align="right"><?php echo number_format($r_icont2['tdebito'],2); ?></td>
	<td align="right"><?php echo number_format($r_icont2['tcredito'],2); ?></td>
	<td><?php echo $r_icont2['csub_descri']; ?></td>
	<td><?php echo $r_icont2['detalle']; ?></td>
	</tr>	
	
	<?php } ?>
	
	
	
<?php }else{ ?>
	
	
<tr align="center" style="background: #F7F7F7; border-top:solid 1px#000;border-bottom:solid 1px#000">


	<th></th>
	<th>DOCU</th>
	<th>PTO/NUMERO</th>
	<th>FECHA</th>
	<th>DEBITO</th>
	<th>CREDITO</th>
	<th>.</th>
	<th>CSUB</th>
	<th>CONCEPTO /DETALLE</th>
	<th>ENTIDAD</th>
	<th>ST</th>
</tr>
<?php 
$filax=0; 

while($r_ctas=mysql_fetch_assoc($res_ctas))
{ ?>

	
<tr style=" <?php if($filax!=3){$filax++;}else{echo 'border-bottom:dotted 1px #000000;'; $filax=0;}?> ">
<td>
	<?php if ($r_ctas['idfrom']=="") {?>
			<a href="../lib/celectop1.php?docu=<?php echo $r_ctas['docu']; ?>&idnum=<?php echo $r_ctas['idnum1']; ?>&formato=1" target="_blank">
			<img src="../img/print2.png" width="20"  title="Diario : <?php echo $r_ctas['docu'];?>-<?php echo $r_ctas['numero'];?>"  /></a>
	<?php }else{ ?>
			<a href="../lib/celectop1.php?docu=<?php echo $r_ctas['docu']; ?>&idnum=<?php echo $r_ctas['idfrom']; ?>&formato=3" target="_blank">
			<img src="../img/print2.png" width="20"  title="Diario : <?php echo $r_ctas['docu'];?>-<?php echo $r_ctas['numero'];?>"  /></a>

			<a href="../lib/celectop1.php?docu=<?php echo $r_ctas['docu']; ?>&idnum=<?php echo $r_ctas['idfrom']; ?>&formato=1" target="_blank">
			<img src="../img/print2.png" width="20"  title="Documento : <?php echo $r_ctas['docu'];?>-<?php echo $r_ctas['numero'];?>"  /></a>
	<?php } ?>
	</td>
  <td align="center"><?php echo $r_ctas['docu']; ?></td>
  <td align="center"><?php echo '<span title="'.$r_ctas['ptonumero'].'">'.$r_ctas['numero']; ?></td>
  <td align="center"><?php echo $r_ctas['fechadmy']; ?></td>
  <td align="right"><?php if($r_ctas['tdebito']!=0){echo number_format($r_ctas['tdebito'],2);} ?></td>
  <td align="right"><?php if($r_ctas['tcredito']!=0){echo '<i>'.number_format($r_ctas['tcredito'],2);} ?></td>
  <th></th>
  <td align="center"><?php echo $r_ctas['csub']; ?></td>
  <td align="left"><?php echo $r_ctas['concepto'].' /'.$r_ctas['detalle']; ?></td>
  <td align="left"><?php echo $r_ctas['enti_descri']; ?></td>
  <td align="center"><?php echo $r_ctas['status']; ?></td>


</tr>

<?php }?>

	
<?php } ?>	
	
	
</table>
<hr/>

<div>

<?php }?>