<?php
session_start();
require('../cfg/res.php');
include('../_cfg/config.php');
include ('php_gene1.php');
include ('php_session.php');

$sql_clie1='select *from '.$_POST['tabla'].'11 where idnum1='.$_POST['indx'];
$res_clie1=mysql_query($sql_clie1,$link_vcrx);

// echo $sql_clie1;
$xdocu=mysql_result($res_clie1,0,'docu');
$xptoe=mysql_result($res_clie1,0,'ptoe');
$xnumero=mysql_result($res_clie1,0,'numero');
$xentid=mysql_result($res_clie1,0,'enti_descri');
$xconcepto=mysql_result($res_clie1,0,'concepto');

?>

<div align="left"; style="max-height:500px; overflow-y:scroll; margin-top:5px; font-size:12px;">
<?php
// echo '<b>'.$xdocu.'-->'.$xptoe.'-'.$xnumero.' /'.$xentid.'</b>';	
?>
<?php $ptabla=$_POST['tabla']; $pidnum=$_POST['indx']; include('vrsaydoc.php');?>
<table id="verdoc2" width="100%" border="0" cellspacing="0" cellpadding="2" style="border-collapse:collapse;font-size:12px; ">
<?php

	
$sql_clie2='select *from '.$_POST['tabla'].'12 where idnum2='.$_POST['indx'];
if($cfg_empr=='ecgl')
{$sql_clie2.=' order by itnum,iddet ';}
	
if($cfg_empr=='tgck')
{$sql_clie2.=' order by vhcl,iddet ';}
	
$res_clie2=mysql_query($sql_clie2,$link_vcrx);
// echo '/*/*/*'.$cfg_empr.$sql_clie2;

if(mysql_num_rows($res_clie2)==0)
{
?>
	<span>
	<strong> DOCUMENTO SIN DETALLE
	</span>
<?php
}
?>
	

<?php
if (mb_stristr('vtas.clie.carr.comp.prov.clte',$_POST['tabla']))
{
$xtdcto=mysql_result($res_clie1,0,'tdcto');
$xtice=mysql_result($res_clie1,0,'tice');
$xtiva=mysql_result($res_clie1,0,'tiva');
$xtirbp=mysql_result($res_clie1,0,'tirbp');
?>

<tr align="center" style="background: #F7F7F7; border-top:solid 1px#000;border-bottom:solid 1px#000">
    <th>ITEM</th>
    <th>DESCRI.</th>
    <th>CANT.</th>
    <th>P.UNI</th>
    <th>SUBT.</th>
    <?php if ($xtdcto!=0) { ?> <th>DCTO.</th> <?php } ?>
    <?php if ($xtice!=0) { ?> <th>ICE</th> <?php } ?>
    <?php if ($xtiva!=0) { ?> <th>IVA</th> <?php } ?>
    <?php if ($xtirbp!=0) { ?> <th>IRBP</th> <?php } ?>
    <th>TOTAL</th>
    <th>DETALLE</th>
    <?php if (mb_stristr('comp.prov',$_POST['tabla'])){?>
    <th>CAIR</th>
    <th>CUENTA</th>
    <th>CONTABLE</th>
    <th>R.RTA</th>
    <th>R.IVA</th>
    <?php }?>
    </tr>
<?php
}
?>

		
<?php
if (mb_stristr('caja.bcos.cjte',$_POST['tabla']))
{
?>


<tr align="center" style="background: #F7F7F7; border-top:solid 1px#000;border-bottom:solid 1px#000">
    <th></th>
    <th>DOCUMENTO</th>
    <th>DOCU</th>
    <th>NUMERO</th>
    <th>CANT.</th>
    <th>DETALLE</th>
    </tr>
<?php
}
?>


<?php
if (mb_stristr('retc.retp',$_POST['tabla']))
{
?>

<tr align="center" style="background: #F7F7F7; border-top:solid 1px#000;border-bottom:solid 1px#000">
    <th></th>
    <th>DOCUMENTO</th>
    <th>DOCU</th>
    <th>NUMERO</th>
    <th>CAIR</th>
    <th>BASE</th>
    <th>%</th>
    <th>VALOR</th>
    </tr>
<?php
}
?>
	
	
	

<?php
if (mb_stristr('cxco.cxpa',$_POST['tabla']))
{
?>
<tr align="center" style="background: #F7F7F7; border-top:solid 1px#000;border-bottom:solid 1px#000">
    <th>FECHA</th>
    <th>DOCUMENTO</th>
    <th>DOCU</th>
    <th>NUMERO</th>
    <th>CANT.</th>
    </tr>
<?php
}
?>




<?php
if (mb_stristr('inve.prod',$_POST['tabla']))
{
?>
<tr align="center" style="background: #F7F7F7; border-top:solid 1px#000;border-bottom:solid 1px#000">
    <th>ITEM</th>
    <th>DESCRI.</th>
    <th>CANT.</th>
    <th>P.UNI</th>
    <th>SUBT.</th>
    <th>TOTAL</th>
    <th>N.SERIE</th>
    <th>DETALLE</th>
    </tr>
<?php
}
?>

<?php
if (mb_stristr('cont',$_POST['tabla']))
{
?>
<tr align="center" style="background: #F7F7F7; border-top:solid 1px#000;border-bottom:solid 1px#000">
    <th>CUENTA</th>
    <th>DESCRI.</th>
    <th>DEBITO</th>
    <th>CREDITO</th>
    <th>CENTRO.S</th>
    <th>DETALLE</th>
    <th>CAIR</th>
    <th>ENTIDAD</th>
    <th>ITEM</th>
    </tr>
<?php
}
?>

<?php
if (mb_stristr('nvdd',$_POST['tabla']))
{
?>
<tr align="center" style="background: #F7F7F7; border-top:solid 1px#000;border-bottom:solid 1px#000">
    <th>EMPLEADO</th>
    <th>NOMBRE</th>
    <th>NOVEDAD</th>
    <th>DESRIPCION</th>
    <th>INGRESO</th>
    <th>DESCUENTO</th>
    <th>PROVISION</th>
    <th>DETALLE</th>
    </tr>
<?php
}
?>







<?php
$filax=0;
$idcont=0;
?>

<?php
if (mb_stristr('vtas.clie.carr.comp.prov.clte',$_POST['tabla']))
{
while($r_clie2=mysql_fetch_assoc($res_clie2))
{
$duni=$r_clie2['item_duni'];
?>

<tr style=" <?php if($filax!=3){$filax++;}else{echo 'border-bottom:dotted 1px #000000;'; $filax=0;}?> ">

    <td align="center"><?php echo $r_clie2['item'];?></td>
    <td><div style="word-wrap:break-word;"><?php echo $r_clie2['item_descri'];?></div></td>

	<!--     <td align="right"> -->
			<?php //echo number_format($r_clie2['tcant'],$duni);?>
<!-- 	</td> -->
		<?php $pvalor=$r_clie2['tcant']; $pdeci=$duni; $ptitle=''; include('vrsayval.php')?>
	
    <td align="right"><?php echo number_format($r_clie2['puni'],2);?></td>
    <td align="right"><?php echo number_format($r_clie2['tsubt'],2);?></td>
    <?php if ($xtdcto!=0) { ?>
    <td align="right"><?php echo '<span title="'.$r_clie2['dcto'].'%">'.number_format($r_clie2['tdcto'],2).'</span>';?></td>
    <?php } ?>
    <?php if ($xtice!=0) { ?>
    <td align="right"><?php echo '<span title="'.$r_clie2['ice'].'%">'.number_format($r_clie2['tice'],2).'</span>';?></td>
    <?php } ?>
    <?php if ($xtiva!=0) { ?>
    <td align="right"><?php echo '<span title="'.$r_clie2['iva'].'%">'.number_format($r_clie2['tiva'],2).'</span>';?></td>
    <?php } ?>
    <?php if ($xtirbp!=0) { ?>
    <td align="right"><?php echo '<span title="'.$r_clie2['irbp'].'%">'.number_format($r_clie2['tirbp'],2).'</span>';?></td>
    <?php } ?>
    <td align="right"><?php echo number_format($r_clie2['total'],2);?></td>
    <td align="left">
    <?php echo '&nbsp;'.$r_clie2['detalle']; ?>
    </td>

        <?php if($cfg_empr=='pcs1'){ ?>
        <td align="center"><?php echo $r_clie2['cntn'];?></td>
        <td align="center"><?php echo date('d/M/y',strtotime($r_clie2['cntnf1']));?></td>
        <td align="center"><?php echo date('d/M/y',strtotime($r_clie2['cntnf2']));?></td>
      <?php } ?>


      <?php if($cfg_empr=='tgck'){ ?>
        <td align="center"><?php echo $r_clie2['vhcl'];?></td>
        <td align="left"><?php echo r_fiel('vhcl',$r_clie2['vhcl']);?></td>
      <?php } ?>

  
    <?php 
    $eliminadet=0;
      if(mb_stristr('clte.clie',$_POST['tabla']))
      {
        if (mb_stristr('admi.sist.supe',substr($_SESSION['user_vcrx_tipo'],0,4))){$eliminadet=1;}
      }
    ?>

    <?php 
    if ($eliminadet==1)
    {
    ?>
    <td align="center">
          <input type="image" id="e_pedido" src="http://vcrxol.com/_img/ico_eliminar.png" tabIndex="-1" width="25" title="Eliminar"  onclick="deledeta('<?php echo $_POST['tabla'] ;?>','<?php echo $r_clie2['idnum1'];?>','<?php echo $r_clie2['iddet'];?>','X')" />
    </td>
    <?php
    }
//     else
//     {echo '&nbsp;'.$r_clie2['detalle']; }
    ?>
<!--     </td>
   -->
    <?php if (mb_stristr('comp.prov',$_POST['tabla'])){?>
    <td align="center"><?php echo $r_clie2['cair'];?></td>
    <td align="left"><?php echo $r_clie2['ctas'];?></td>
    <td align="left"><?php echo $r_clie2['ctas_descri'];?></td>
    <td align="center"><?php echo number_format($r_clie2['prrta'],2);?></td>
    <td align="center"><?php echo number_format($r_clie2['priva'],2);?></td>
    <?php}?>
    </tr>

	
<?php	
}
?>
<?php
}
?>


<?php
if (mb_stristr('caja.bcos.cjte',$_POST['tabla']))
{
while($r_clie2=mysql_fetch_assoc($res_clie2))
{
$duni=$r_clie2['item_duni'];
	
// aqui debo buscar el idnum1 del docu, numero, enti
$idnumdoc='';

$apli_sql='select * from docu0 where docu_codigo like "'.$r_clie2['docum'].'"';
$apli_res=mysql_query($apli_sql,$link_vcrx);
$aplitab=mysql_result($apli_res,0,'docu_tabla').'1';
//echo $apli_sql;	
$apli_sql='select * from '.$aplitab.' where docu like "'.$r_clie2['docum'].'" ';
$apli_sql.=' and enti like "'.$r_clie2['enti'].'" ';
$apli_sql.=' and ptoe like "'.$r_clie2['ptoem'].'" ';
$apli_sql.=' and numero like "'.$r_clie2['numer'].'" ';
$apli_sql.=' order by status desc, idnum1 desc ';
$apli_res=mysql_query($apli_sql,$link_vcrx);
$idnumdoc=@mysql_result($apli_res,0,'idnum1');
// 	echo $apli_sql;
	
	
?>
<tr style=" <?php if($filax!=3){$filax++;}else{echo 'border-bottom:dotted 1px #000000;'; $filax=0;}?> ">
  <td>
		<a href="../print1.php?prnt=1&docu=<?php echo $r_clie2['docum']; ?>&idnum=<?php echo $idnumdoc; ?>&formato=1" target="_blank">
<!--     <a href="../lib/celectop1.php?docu=<?php echo $r_clie2['docum']; ?>&idnum=<?php echo $idnumdoc; ?>&formato=1" target="_blank"> -->
		<img src="../img/print2.png" width="20"  title="Imprimir  <?php echo $r_clie2['docu'];?>-<?php echo $r_clie2['numero'];?>"  /></a>
	</td>
    <td><div style="max-width:200px; word-wrap:break-word;"><?php echo $r_clie2['docum_descri'];?></div></td>
    <td align="center"><?php echo $r_clie2['docum'];?></td>
    <td align="center"><?php echo $r_clie2['ptonumer'];?></td>
    <td align="right"><?php echo number_format($r_clie2['tcant'],2);?></td>
    <td align="left"><?php echo '&nbsp;'.$r_clie2['detalle'];?></td>
    </tr>
	
<?php	
}
?>
<?php
}
?>

<?php
if (mb_stristr('retc.retp',$_POST['tabla']))
{
while($r_clie2=mysql_fetch_assoc($res_clie2))
{
$duni=$r_clie2['item_duni'];

$idnumdoc='';

$apli_sql='select * from docu0 where docu_codigo like "'.$r_clie2['docum'].'"';
$apli_res=mysql_query($apli_sql,$link_vcrx);
$aplitab=mysql_result($apli_res,0,'docu_tabla').'1';
	
$apli_sql='select * from '.$aplitab.' where docu like "'.$r_clie2['docum'].'" ';
$apli_sql.=' and enti like "'.$r_clie2['enti'].'" ';
$apli_sql.=' and ptoe like "'.$r_clie2['ptoem'].'" ';
$apli_sql.=' and numero like "'.$r_clie2['numer'].'" ';
$apli_sql.=' order by status desc, idnum1 desc ';
$apli_res=mysql_query($apli_sql,$link_vcrx);
$idnumdoc=@mysql_result($apli_res,0,'idnum1');
	
?>
<tr style=" <?php if($filax!=3){$filax++;}else{echo 'border-bottom:dotted 1px #000000;'; $filax=0;}?> ">
  <td>
<!--     <a href="../lib/celectop1.php?docu=<?php echo $r_clie2['docum']; ?>&idnum=<?php echo $idnumdoc; ?>&formato=1" target="_blank"> -->
		<a href="../print1.php?prnt=1&docu=<?php echo $r_clie2['docum']; ?>&idnum=<?php echo $idnumdoc; ?>&formato=1" target="_blank">
		<img src="../img/print2.png" width="20"  title="Imprimir  <?php echo $r_clie2['docu'];?>-<?php echo $r_clie2['numero'];?>"  /></a>
	</td>
    <td><div style="max-width:200px; word-wrap:break-word;"><?php echo $r_clie2['docum_descri'];?></div></td>
    <td align="center"><?php echo $r_clie2['docum'];?></td>
    <td align="center"><?php echo $r_clie2['ptonumer'];?></td>
    <td align="center"><?php echo $r_clie2['cair'];?></td>
    <td align="right"><?php echo number_format($r_clie2['cant'],2);?></td>
    <td align="center"><?php echo number_format($r_clie2['puni'],2);?></td>
    <td align="right"><?php echo number_format(abs($r_clie2['total']),2);?></td>
    </tr>
	
<?php	
}
?>
<?php
}
?>



<?php
if (mb_stristr('cxco.cxpa',$_POST['tabla']))
{
while($r_clie2=mysql_fetch_assoc($res_clie2))
{
$duni=$r_clie2['item_duni'];
?>
<tr style=" <?php if($filax!=3){$filax++;}else{echo 'border-bottom:dotted 1px #000000;'; $filax=0;}?> ">
    <td align="center"><?php echo $r_clie2['fechadmy'];?></td>
    <td><div style="max-width:200px; word-wrap:break-word;"><?php echo $r_clie2['docu_descri'];?></div></td>
    <td align="center"><?php echo $r_clie2['docu'];?></td>
    <td align="center"><?php echo $r_clie2['ptonumero'];?></td>
    <td align="right"><?php echo number_format($r_clie2['tcant'],2);?></td>
    </tr>
	
<?php	
}
?>
<?php
}
?>



<?php
if (mb_stristr('inve.prod',$_POST['tabla']))
{
while($r_clie2=mysql_fetch_assoc($res_clie2))
{
$duni=$r_clie2['item_duni'];
$dval=$r_clie2['item_dval'];
$idcont++;
?>

<tr style=" <?php if($filax!=3){$filax++;}else{echo 'border-bottom:dotted 1px #000000;'; $filax=0;}?> ">

    <td align="center"><?php echo $r_clie2['item'];?></td>
    <td><div style="word-wrap:break-word;"><?php echo $r_clie2['item_descri'];?></div></td>
    <td align="right"><?php echo number_format($r_clie2['tcant'],$duni);?></td>
    <td align="right"><?php echo number_format($r_clie2['puni'],2);?></td>
    <td align="right"><?php echo number_format($r_clie2['tsubt'],2);?></td>
    <td align="right"><?php echo number_format($r_clie2['total'],2);?></td>
    <td><div style="word-wrap:break-word;"><?php echo $r_clie2['numserie'];?></div></td>
    <td align="left">
    <?php 
    if(mb_stristr('clte.clie',$_POST['tabla']))
    if (mb_stristr('admi',substr($_SESSION['user_vcrx_tipo'],0,4)))
    {
    {
    ?>
	<td align="center">
       	<input type="image" id="e_pedido" src="http://vcrxol.com/_img/ico_eliminar.png" tabIndex="-1" width="25" title="Eliminar"  onclick="deledeta('<?php echo $_POST['tabla'] ;?>','<?php echo $r_clie2['idnum1'];?>','<?php echo $r_clie2['iddet'];?>','X')" />
	</td>
    <?php
    }}
    else
    {
	echo '&nbsp;'.$r_clie2['detalle'];
    }
    ?>
    </td>
	<td>
	<?php $pidtxt='puni_'.$idcont; $plong=10; $pobj=1; include('vrgetval.php');?>
	</td>

    </tr>
<?php	
}
?>
<?php
}
?>



<?php
if (mb_stristr('cont',$_POST['tabla']))
{
//echo $sql_clie2;
while($r_clie2=mysql_fetch_assoc($res_clie2))
{
$duni=$r_clie2['item_duni'];
?>
<tr style=" <?php if($filax!=3){$filax++;}else{echo 'border-bottom:dotted 1px #000000;'; $filax=0;}?> ">
    <td align="left"><?php echo $r_clie2['ctas'];?></td>
    <td><div style="max-width:200px; word-wrap:break-word;"><?php echo $r_clie2['ctas_descri'];?></div></td>
    <td align="right"><?php echo number_format($r_clie2['tdebito'],2);?></td>
    <td align="right"><?php echo number_format($r_clie2['tcredito'],2);?></td>
    <td align="center"><?php echo $r_clie2['csub'];?></td>
    <td align="left"><?php echo '&nbsp;'.$r_clie2['detalle'];?></td>
    <td align="center"><?php echo $r_clie2['cair'];?></td>
    <td align="left"><?php echo $r_clie2['enti_descri'];?></td>
    <td align="left"><?php echo $r_clie2['item_descri'];?></td>
    </tr>
	
<?php	
}
?>
<?php
}
?>



<?php
if (mb_stristr('nvdd',$_POST['tabla']))
{
//echo $sql_clie2;
while($r_clie2=mysql_fetch_assoc($res_clie2))
{
// $duni=$r_clie2['item_duni'];
?>
<tr style=" <?php if($filax!=3){$filax++;}else{echo 'border-bottom:dotted 1px #000000;'; $filax=0;}?> ">
    <td align="center"><?php echo $r_clie2['enti2'];?></td>
    <td><div style="max-width:200px; word-wrap:break-word;"><?php echo $r_clie2['enti_descri'];?></div></td>
    <td align="center"><?php echo $r_clie2['nvdd'];?></td>
    <td><div style="max-width:200px; word-wrap:break-word;"><?php echo $r_clie2['nvdd_descri'];?></div></td>
    <td align="right"><?php echo number_format($r_clie2['tingreso'],2);?></td>
    <td align="right"><?php echo number_format(abs($r_clie2['tegreso']),2);?></td>
    <td align="right"><?php echo number_format($r_clie2['tprovi'],2);?></td>
    <td align="left"><?php echo '&nbsp;'.$r_clie2['detalle'];?></td>
    </tr>
	
<?php	
}
?>
<?php
}
?>




</table>

<br>

<div>

