<?php session_start();?>
<?php include('../_cfg/config.php');?>
<?php include('php_gene1.php'); ?>
<?php include('php_session.php');?>
<?php $orient=$_POST['orient']; ?>
<?php $pant=$_POST['pant']; ?>
<?php $docu=$_POST['docu']; ?>
<?php $idnum=$_POST['idnum']; ?>
<?php $enti=$_POST['enti']; ?>
<?php $stat=$_POST['stat']; ?>
<?php $fecha1=$_POST['fecha1']; ?>
<?php $fecha2=$_POST['fecha2']; ?>
<?php $orient=$_POST['orient']; ?>

<?php

if($docu=='undefined'){$docu='';}
// if($user_codigo==""){die('Su sesión ha Expirado');}

$user_anul=0;
$user_elim=0;

if($user_tipo=='sist'){$user_anul=1;$user_elim=1;}
if($user_tipo=='supe'){$user_anul=1;$user_elim=1;}
if($user_tipo=='clie' and substr($docu,0,2)=='OP')
{$user_anul=1;}

$sql_pant ='select * from user0 where user_codigo="'.$user_codigo.'"';
$res_pant=mysql_query($sql_pant,$link_vcrx);

// echo $sql_pant;
$defaptov=mysql_result($res_pant,0,'user_ptov');
$defabode=mysql_result($res_pant,0,'user_bode');
$defacaba=mysql_result($res_pant,0,'user_caba');

if(empty($defaptov)){$defaptov='001001';}
if(empty($defabode)){$defabode='001001';}
if(empty($defacaba)){$defacaba='001001';}

$tabla=r_fiel('docu',$docu,'tabla');
$entilabel='ENTIDAD';

if($tabla=="")
{
	if($docu=='DD'){$tabla='cont';}
	if($docu=='FC'){$tabla='vtas';}
	if($docu=='AC'){$tabla='vtas';}
	if($docu=='AP'){$tabla='comp';}
	if($docu=='OP'){$tabla='clie';}
	if($docu=='PF'){$tabla='clie';}
	if($docu=='CA'){$tabla='carr';}
	if($docu=='NC'){$tabla='vtas';}
	if($docu=='FP'){$tabla='comp';}
	if($docu=='GR'){$tabla='guia';}
	if($docu=='RP'){$tabla='retp';}
	if($docu=='IB'){$tabla='inve'; $entilabel='PROVEEDOR';}
	if($docu=='EB'){$tabla='inve'; $entilabel='CLIENTE';}
	
	if($docu=='DC'){$tabla='bcos'; $entilabel='CLIENTE';}
	if($docu=='CH'){$tabla='bcos'; $entilabel='PROVEEDOR';}
	if($docu=='DP'){$tabla='bcos'; $entilabel='PROVEEDOR';}
	if($docu=='IE'){$tabla='caja'; $entilabel='CLIENTE';}
	if($docu=='IC'){$tabla='caja'; $entilabel='CLIENTE';}
	if($docu=='EE'){$tabla='caja'; $entilabel='PROVEEDOR';}
}

if($tabla!="")
{
	if(mb_stristr('vtas.clie.carr.retc.guia.',$tabla)){$entilabel='CLIENTE';}
	if(mb_stristr('comp.prov.retp.',$tabla)){$entilabel='PROVEEDOR';}
	if(mb_stristr('nomi.roln.suel',$tabla)){$entilabel='EMPLEADO';}
}

$xfontsize=12;
// if($mobile=='true' and $orient=='V'){$xfontsize=40;}
// if($mobile=='true' and $orient=='H'){$xfontsize=12;}
if($orient=='V'){$xfontsize=40;}
if($orient=='H'){$xfontsize=12;}

$hpant1 =ceil($screenh*0.30);
$hpant11=ceil($screenh*0.10);
$hpant2 =ceil($screenh*0.30);

$wpant1 =$screenw-20;
	
if ($orient=='V')
{
	$hpant1 =ceil($screenh*0.90);
	$hpant11=ceil($screenh*0.40);
	$hpant2 =ceil($screenh*0.90);
}

// TOTALES
{
	$docuitem=0;
	$docuiimp=0;
// 				$docuinve=0;
	$docudocu=0;
	$docurete=0;
	$docuctas=0;

	if($tabla!="")
	{
	if(mb_stristr('vtas.comp.clie.prov.inve.prod.guia.carr',$tabla)){$docuitem=1;}
	if(mb_stristr('vtas.comp.clie.prov.carr',$tabla)){$docuiimp=1;}
// 				if(mb_stristr('inve.prod.guia',$tabla)){$docuinve=1;}
	if(mb_stristr('caja.bcos.retc.retp',$tabla)){$docudocu=1;}
	if(mb_stristr('retc.retp',$tabla)){$docurete=1;}
	if(mb_stristr('cont',$tabla)){$docuctas=1;}
	}
	
	$total_sql ='max(detalle) as mdetalle,';
	$total_sql.='sum(tcant) as stcant,';
	$total_sql.='sum(tsubt) as stsubt,';
	if($docuiimp==1)
	{
		$total_sql.='sum(tsubtiva0) as stsubtiva0,';
		$total_sql.='sum(tsubtiva) as stsubtiva,';
		$total_sql.='sum(tsubtice) as stsubtice,';
		$total_sql.='sum(tdcto) as stdcto,';
		$total_sql.='sum(tice) as stice,';
		$total_sql.='sum(tiva) as stiva,';
		$total_sql.='sum(tirbp) as stirbp,';

		$total_sql.='max(dcto) as pdcto,';
		$total_sql.='max(ice) as pice,';
		$total_sql.='max(iva) as piva,';
		$total_sql.='max(irbp) as pirbp,';
	}

	if($tabla!="")
	{
	if(mb_stristr('comp',$tabla))
	{
		$total_sql.='sum(trrta) as strrta,';
		$total_sql.='sum(triva) as striva,';
	}
	if(mb_stristr('retc.retp',$tabla))
	{
		$total_sql.='sum(brta) as sbrta,';
		$total_sql.='max(prta) as sprta,';
		$total_sql.='sum(rrta) as srrta,';
		$total_sql.='sum(biva) as sbiva,';
		$total_sql.='max(piva) as spiva,';
		$total_sql.='sum(riva) as sriva,';
	}
	}
	$total_sql.='sum(total) as stotal ';

	$dispcolu=1;
	if($mobile=='true'){$dispcolu=0;}
}


?>


<?php ob_start(); ?>
<resultado>
<?php val_usercodigo(); ?>
<?php if(mb_stristr('PANT0',$pant)) { ?>
<?php //$fecha1=date('Y-m-01',strtotime ('today')); ?>
<?php $fecha1=date('Y-m-d',strtotime ('today')); ?>
<?php $fecha2=$fechaa; ?>
		<?php if($mobile=='true' and $orient=="V") { ?>
		<?php }else{ ?>
		<div id="pant0" style="border:solid 2px; overflow:auto;">
			<?php //echo '***'.$empr_cont;?>
			<table width="100%" cellpadding="2" width="100%" border="0"
						style="font-size:<?php echo $xfontsize; ?>px;border-collapse:collapse; background-color:white;">
				<tr>
					<td   width="40%">
						<table width="100%" cellpadding="2" width="100%" border="0"
									 style="font-size:<?php echo $xfontsize; ?>px;border-collapse:collapse; background-color:white;">

							<tr style="display:table-row;">
							<?php $pidtxt='docu'; $pcaption='Documento'; $ptabla='docu'; $pdefa=$docu; $psize=$xfontsize; 
						 $ponblur="vali_docu();vali_docunume();";
						 include('vrgetcod.php'); ?>
							</tr>

							<tr style="display:none;" class="vtas clie">
							<?php $pcaption='PTO.VTA.'; $ptabla='ptov';  $pdefa=$defaptov;
						 			$ponblur="document.getElementById('ptoe').value=document.getElementById('ptov').value;";
						 			include('vrgetcod.php'); ?>
							</tr>

							<tr style="display:none;" class="inve">
							<?php $pidtxt='bode'; $pcaption='BODEGA'; $ptabla='bode';  $pdefa=$defabode;
						 			$ponblur="document.getElementById('ptoe').value=document.getElementById('bode').value;";
						 			include('vrgetcod.php'); ?>
							</tr>

							<tr style="display:none;" class="caba">
							<?php //$pcaption='CAJA/BCO.'; $ptabla='caba';  $pdefa=$defacaba;
// 						 			$ponblur="document.getElementById('ptoe').value=document.getElementById('caba').value;";
						 			//include('vrgetcod.php'); ?>
							</tr>

							<tr style="display:none;" class="caja">
							<?php $pcaption='CAJA'; $ptabla='caja';  $pdefa=$defacaba;
						 			$ponblur="document.getElementById('ptoe').value=document.getElementById('caja').value;";
						 			include('vrgetcod.php'); ?>
							</tr>

							<tr style="display:none;" class="bcos">
							<?php $pcaption='CTA.BANC.'; $ptabla='ctab';  $pdefa='000201';
						 			$ponblur="document.getElementById('ptoe').value=document.getElementById('ctab').value;";
						 			include('vrgetcod.php'); ?>
							</tr>

							<tr style="display:table-row;" class="comp prov retc retp rete" >
							<?php $pidtxt='ptoe'; $pcaption='Pto.Emision';  $pdefa='001001'; $plong=6; $psize=$xfontsize;
// 						 $ponblur="vali_ptoe();";
						 $ponblur="vali_ptoe();vali_docunume();";
 						 include('vrgetnum.php'); ?>
							</tr>

							<tr style="display:table-row;"  >
							<?php $pidtxt='numero'; $pcaption='Numero';  $pdefa=''; $plong=9; $psize=$xfontsize;
// 								$ponblur="vali_numero();";
						 		$ponblur="vali_numero();vali_docunume();";
						 include('vrgetnum.php'); ?>
							</tr>
							<tr style="display:table-row;"  >
							<?php $pcaption='ENTIDAD'; $ptabla='enti';  $pdefa=$cfg_ruc; $ponblur=''; include('vrgetcod.php'); ?>
							</tr>
							
							<tr style="display:table-row;"  >
							<?php $pcaption='CONCEPTO'; $plong=40; $prows=1.5;  $pdefa=''; $ponblur=''; include('vrgettxt.php'); ?>
							</tr>
							
						</table>
					</td>
					<td   width="30%" valign="top">
						<table width="100%" cellpadding="2" width="100%" border="0"
									style="font-size:<?php echo $xfontsize; ?>px;border-collapse:collapse; background-color:white;">
							<tr style="display:table-row;"  >
							<?php $pidtxt='fecha'; $pcaption='Fecha'; $pdefa=$fecha1; $psize=$xfontsize; include('vrgetfec.php'); ?>
							</tr>

							<tr id="tr_bode2" style="display:none;" class="inve">
							<?php $pidtxt='bode2'; $pcaption='BODEGA 2'; $ptabla='bode';  $pdefa=''; $ponblur=''; include('vrgetcod.php'); ?>
							</tr>

							<tr style="display:none;" class="caba">
							<?php $pidtxt='caba'; $pcaption='CAJA/BCO 2'; $ptabla='caba';  $pdefa=''; $ponblur=''; include('vrgetcod.php'); ?>
							</tr>

							<tr style="display:none;" class="caja">
							<?php $pidtxt='caja2'; $pcaption='CAJA 2'; $ptabla='caja';  $pdefa=''; $ponblur=''; include('vrgetcod.php'); ?>
							</tr>

							<tr style="display:none;" class="bcos">
							<?php $pidtxt='ctab2'; $pcaption='CTAB 2'; $ptabla='ctab';  $pdefa=''; $ponblur=''; include('vrgetcod.php'); ?>
							</tr>

							<tr style="display:none;" valign="top"  class="vtas clie comp prov">
							<?php $pidtxt='plazo'; $pcaption='Plazo';  $pdefa='001'; $plong=3; $psize=$xfontsize; include('vrgetnum.php'); ?>
							</tr>
							<tr style="display:none;" valign="top"  class="vtas clie comp prov">
							<?php $pidtxt='dcto'; $pcaption='%Dscto';  $pdefa=''; $plong=2; $psize=$xfontsize; include('vrgetval.php'); ?>
							</tr>

              <tr style="display:none;" valign="top"  class="vtas clie comp prov">
							<?php $pidtxt='fpag'; $pcaption='F.Pago';  $ptabla='fpag'; $psize=$xfontsize; include('vrgetcod.php');?>
							</tr>

              <tr style="display:none;" class="vtas clie">
							<?php $pidtxt='vndd'; $pcaption='Vendedor';  $ptabla='vndd'; $psize=$xfontsize; include('vrgetcod.php'); ?>
							</tr>
							<tr style="display:none;" class="vtas clie">
							<?php $pidtxt='zsub'; $pcaption='Zona';  $ptabla='zsub'; $psize=$xfontsize; include('vrgetcod.php'); ?>
							</tr>
							
							<?php if($empr_cont==1){ ?>
							<tr style="display:none;" class="comp prov">
							<?php $pidtxt='suco'; $pcaption='Sust.Comp.';  $ptabla='suco'; $psize=$xfontsize; include('vrgetcod.php'); ?>
							</tr>
							<tr style="display:none;" class="comp prov">
							<?php $pidtxt='atrz'; $pcaption='Num.Autor.'; $pdocu='FP10'; $pcolu='atrz'; $plong=10; $psize=$xfontsize; include('vrgetnum.php'); ?>
							</tr>
							<?php }?>
							
							<tr>
							<?php //$pidtxt='fecha2'; $pcaption='Hasta'; $psize=$xfontsize; include('vrgetfec.php'); ?>
							</tr>
						</table>
					</td>
					<td   width="30%" valign="top">
						<table width="100%" cellpadding="2" width="100%" border="0" 
									style="font-size:<?php echo $xfontsize; ?>px;border-collapse:collapse; background-color:white;">
							<tr style="display:table-row;" >
							<td>
								<?php  //$pidtxt='idnum11'; $pcaption='ID : 000000000'; $psize=18; $ponclick='gath_idnum();'; include('vrbutton.php');?>
								<?php  $pidtxt='idnum1'; $pcaption='ID-NUM'; $psize=12; $ponclick='gath_idnum();'; include('vrgetnum.php');?>
							</td>
							<td><?php //$pcaption='000000000'; include('vrbutton.php');?></td>
							<td><?php //$pidtxt='idnum1'; $pobj=1; $plong=9; $pdefa='000000000'; include('vrgettxt.php');?></td>
							</tr>
						</table>
						<div id="xpant11">
						</div>
					</td>
				</tr>
			</table>
		</div>
<!-- 		<hr> -->
		<div id="pant00" style="border:solid 0px; overflow:auto; display:none; padding:0px;">
		<table width="100%" cellspacing="0" cellpadding="1" width="100%" border="0"
						style="font-size:<?php echo $xfontsize; ?>px;border-collapse:collapse; background-color:white; ">
			<tbody style="display:block;">
			<tr align="center" valign="center" style="border-top: solid 0px;border-bottom: solid 2px; ">
				<?php $pcaption='FECHA'; $pidtxt="fecha2"; $pobj=2; $pclass='nomi'; include('vrgetfec.php'); ?> 
				<?php $pcaption='CEDULA'; $pidtxt="enti2"; $pobj=4; $ptabla='enti'; $pclass='rolp'; include('vrgetcod.php'); ?> 
				<?php $pcaption='ITEM'; $ptabla='item'; $pobj=4; 
						 $ponblur="vali_item()";
						 $pclass='vtas clie carr comp prov inve'; include('vrgetcod.php'); ?> 
				<?php $pcaption='NOVEDAD'; $ptabla='nvdd';  $pobj=4; $pclass='rolp'; include('vrgetcod.php'); ?> 
				<?php $pcaption='DOCU'; $ptabla='docu'; $pidtxt="docum"; $pobj=4; $pclass='caba caja bcos retc retp'; include('vrgetcod.php'); ?>  
				<?php $pcaption='P.EMIS.';  $pidtxt="ptoem"; $plong=6; $pobj=2; $pdefa='001001'; $pclass='caba caja bcos retc retp'; include('vrgetnum.php'); ?>  
				<?php $pcaption='NUMERO'; $pidtxt='numer'; $plong=9; $pobj=2; $ponclick=""; $pclass='caba caja bcos retc retp'; include('vrgetnum.php'); ?> 
				<?php $pcaption='CANT.'; $pidtxt='cant'; $pdefa=1; $plong=9; $pobj=2; $pclass='vtas clie comp prov inve caba caja bcos'; include('vrgetval.php'); ?>
				
		<!--  RCSA  -->
				<?php if($empr=='rcsa'){?>
				<?php $pcaption='P.UNIT.'; $pidtxt='puni_o'; $plong=8; $pobj=2; $pclass='vtas clie'; include('vrgetval.php'); ?>
				<?php $pcaption='P.ALT..'; $pidtxt='puni_a'; $plong=7; $pobj=2; $pclass='vtas clie'; include('vrgetval.php'); ?>
				<?php $pcaption='IMPO'; $pidtxt='impo'; $plong=1; $pobj=2; $pclass='vtas clie'; include('vrchkbox.php'); ?>
				<?php } ?>
		<!--  RCSA  -->

	<!--  PACO.PCS1.PSR1.IDMT  -->
				<?php if(mb_stristr('pcs1.prs1',$empr)){?>
				<?php $pcaption='CONTENEDOR'; $ptabla='cntn'; $pobj=2; $pclass='vtas'; include('vrgetcod.php'); ?>
				<?php $pcaption='DESDE'; $pidtxt='cntnf1'; $pobj=2; $pclass='vtas'; include('vrgetfec.php'); ?>
				<?php $pcaption='HASTA'; $pidtxt='cntnf2'; $pobj=2; $pclass='vtas'; include('vrgetfec.php'); ?>
				<?php $pcaption='CHASIS'; $pidtxt='chasis'; $plong=10; $pobj=2; $pclass='vtas'; include('vrgettxt.php'); ?>
				<?php }?>
	<!--  PACO  -->

				<?php $pcaption='P.UNIT.'; $pidtxt='puni'; $plong=9; $pobj=2; $pclass='vtas clie comp prov inve rolp'; include('vrgetval.php'); ?>
				<?php //$pcaption='P.V.P.'; $pidtxt='pvp1'; $plong=8; $pobj=2; $pclass=''; include('vrgetval.php'); ?> 
				<?php $pcaption='%ICE'; $pidtxt='ice'; $pobj=2; $pclass='comp prov'; include('vrgetval.php'); ?>
				<?php $pcaption='%DCTO'; $pidtxt='dcto'; $pobj=2; $pclass='vtas clie comp prov'; include('vrgetval.php'); ?> 
				<?php //$pcaption='%IVA'; $pidtxt='iva'; $pobj=2; $pdefa=14; $pclass=''; include('vrgetval.php'); ?> 
				<?php $pcaption='%IVA'; $pidtxt='iva'; $pobj=2; $pdefa=12; $pclass='vtas clie comp prov'; include('vrgetval.php'); ?> 
				<?php $pcaption='IRBP'; $pidtxt='irbp'; $pobj=2; $plong=4; $pclass='comp prov'; include('vrgetval.php'); ?> 
				
				<?php if($empr_cont==1){?> 
				<?php $pcaption='CAIR'; $ptabla='cair';  $pobj=2; $pclass='comp prov retc retp'; include('vrgetcod.php'); ?> 
				<?php $pcaption='CUENTA'; $ptabla='ctas'; $pobj=4; $pclass='comp prov cont caba caja bcos'; include('vrgetcod.php'); ?>
				<?php $pcaption='BASE'; $pidtxt='base'; $plong=9; $pobj=2; $pclass='retc retp'; include('vrgetval.php'); ?> 
				<?php $pcaption='%RET'; $pidtxt='porc'; $pobj=2; $pclass='retc retp'; include('vrgetval.php'); ?> 
				<?php $pcaption='DEBITO'; $pidtxt='debito'; $plong=9; $pobj=2; $pclass='cont'; include('vrgetval.php'); ?> 
				<?php $pcaption='CREDITO'; $pidtxt='credito'; $plong=9; $pobj=2; $pclass='cont'; include('vrgetval.php'); ?> 
				<?php $pcaption='C.SUB'; $ptabla='csub'; $pobj=2; $pclass='comp prov cont rolp'; include('vrgetcod.php'); ?> 
				<?php } ?>

				<?php if($empr_inve==1){?> 
				<?php $pcaption='# SERIE'; $pidtxt='numserie'; $plong=15; $pobj=2; $pdocu='IB'; $pcolu='numeserie'; $pclass='inve'; include('vrgettxt.php'); ?>  
				<?php if($empr_lote==1 or 1==1){?> 
				<?php $pcaption='LOTE'; $pidtxt='lote'; $plong=10; $pobj=2; $pdocu='IB'; $pcolu='lote'; $pclass='inve prod'; include('vrgettxt.php'); ?> 
				<?php } ?>
				<?php $pcaption='Cambio'; $ptabla='item'; $pidtxt='cambio';  $pobj=4; $pclass='inve'; include('vrgetcod.php'); ?> 
				<?php } ?>
				
				<?php if($empr_nomi==1){?> 
				<?php $pcaption='SUELDO'; $pidtxt='sueldo'; $plong=9; $pobj=2;  $ponblur='valsueldo();'; $pclass='nomi'; include('vrgetval.php'); ?>
				<?php $pcaption='% ANTI'; $pidtxt='poranti'; $pobj=2; $ponblur='valsueldo();'; $pclass='nomi'; include('vrgetval.php'); ?>
				<?php $pcaption='ANTICIPO'; $pidtxt='valanti'; $plong=9; $pobj=2; $ponblur='valsueldo();'; $pclass='nomi'; include('vrgetval.php'); ?>
				<?php $pcaption='IESS'; $pidtxt='iess'; $plong=1; $pobj=2; $pclass='nomi'; include('vrchkbox.php'); ?>
				<?php $pcaption='RELOJ'; $pidtxt='reloj'; $plong=1; $pobj=2; $pclass='nomi'; include('vrchkbox.php'); ?>
				<?php $pcaption='ATRASO'; $pidtxt='atraso'; $plong=1; $pobj=2; $pclass='nomi'; include('vrchkbox.php'); ?>
				<?php $pcaption='FALTA'; $pidtxt='falta'; $plong=1; $pobj=2; $pclass='nomi'; include('vrchkbox.php'); ?>
				<?php $pcaption='H_25%'; $pidtxt='h25'; $plong=1; $pobj=2; $pclass='nomi'; include('vrchkbox.php'); ?>
				<?php $pcaption='H_50%'; $pidtxt='h50'; $plong=1; $pobj=2; $pclass='nomi'; include('vrchkbox.php'); ?>
				<?php $pcaption='H100%'; $pidtxt='h100'; $plong=1; $pobj=2; $pclass='nomi'; include('vrchkbox.php'); ?>

				<?php $pcaption='D_13'; $pidtxt='de13'; $plong=1; $pobj=2; $pclass='nomi'; include('vrchkbox.php'); ?>
				<?php $pcaption='D_14'; $pidtxt='de14'; $plong=1; $pobj=2; $pclass='nomi'; include('vrchkbox.php'); ?>
				<?php $pcaption='F.RES'; $pidtxt='fres'; $plong=1; $pobj=2; $pclass='nomi'; include('vrchkbox.php'); ?>
				<?php } ?>
				
				<?php $pcaption='DETALLE'; $pidtxt='detalle'; $plong=50; $prows=1.5; $pobj=2; $pclass=''; include('vrgettxt.php'); ?>
				
			</tr>
			</tbody>
		</table>

		</div>
		<?php } ?>
		<hr>
		<div id="pant1" style="border:solid 0px; overflow:auto; font-family:arial;"></div>
<!-- 		<hr> -->
		<div id="pant11" style="border:solid 0px; overflow:auto; font-family:arial; display:none;"></div>
		<div id="pant2"  style="border:solid 1px; overflow:auto; font-family:arial; display:;"></div>
		<div id="pant9"></div>
<?php } ?>			

<?php if(mb_stristr('PANT1',$pant)) { ?>
<?php mysql_query('update '.$tabla.'1 set status="-" where status="" or status is null',$link_vcrx); ?>
	<?php { 
		$sql_pant='select * from '.$tabla.'12 ';
		$sql_pant.=' where (fecha between "'.$fecha1.'" and "'.$fecha2.'")';
		$sql_pant.=' and docu like "'.$docu.'%"';
		if($user_tipo=="clie"){$sql_pant.=' and (trim(iuser)="'.$user_codigo.'")';}
// 		if($user_tipo==""){$sql_pant.=' and (1==2)';}
		if($enti!=""){$sql_pant.=' and (enti like "'.$enti.'%" or enti_descri like "%'.$enti.'%")';}
		if($stat!=""){$sql_pant.=' and (status="'.$stat.'")';}

		$sql_tpant=str_replace('select *','select *,'.$total_sql,$sql_pant);
		$sql_pant=str_replace('select *','select *,'.$total_sql,$sql_pant);
		$sql_tpant=$sql_pant;

		if(mb_stristr('retc.retp',$tabla))
		{$sql_pant.=' group by numero,fecha,enti';}
		else
		{$sql_pant.=' group by idnum1';}

		$sql_pant.=' order by fecha desc,ptoe,numero desc';

		$res_pant=mysql_query($sql_pant,$link_vcrx);
		$res_tpant=mysql_query($sql_tpant,$link_vcrx);

		$tcant=mysql_result($res_tpant,0,'stcant');
		$tsubt=mysql_result($res_tpant,0,'stsubt');
		if($docuiimp==1)
		{
			$tsubtiva0=mysql_result($res_tpant,0,'stsubtiva0');
			$tsubtiva=mysql_result($res_tpant,0,'stsubtiva');
			$tdcto=mysql_result($res_tpant,0,'stdcto');
			$tice=mysql_result($res_tpant,0,'stice');
			$tiva=mysql_result($res_tpant,0,'stiva');
			$tirbp=mysql_result($res_tpant,0,'stirbp');
		}

		if(mb_stristr('comp',$tabla))
		{
			$trrta=mysql_result($res_tpant,0,'strrta');
			$triva=mysql_result($res_tpant,0,'striva');
		}			

		if(mb_stristr('retc.retp',$tabla))
		{
			$tbrta=mysql_result($res_tpant,0,'sbrta');
			$tbiva=mysql_result($res_tpant,0,'sbiva');
			$tprta=mysql_result($res_tpant,0,'sprta');
			$tpiva=mysql_result($res_tpant,0,'spiva');
			$trrta=mysql_result($res_tpant,0,'srrta');
			$triva=mysql_result($res_tpant,0,'sriva');
		}

		$total=mysql_result($res_tpant,0,'stotal');

// 		if($dispcolu=='true')
		if($dispcolu==0)
		{
			$tsubt=0;
			$tsubtiva=0;	
			$tsubtiva0=0;
			$tdcto=0;
			$tiva=0;
			$tice=0;
			$tirbp=0;

			$trrta=0;
			$triva=0;
		}

	
	}	?>

	
	<?php $crow=0; ?>
	<?php $ccol=0; ?>
	<?php $tnumero=0; ?>
	<?php //echo '***'.date('H:i:s') .'<br>';?>
	<pant1>
	<?php	val_usercodigo(); ?>

		<table id="tpant1" class="pant1" border="0"
					 xonclick="resizeTab('<?php echo "tpant1"?>','');"
					 align="center" border="0" cellpadding="3" width="100%"
					 style="font-size:<?php if($orient=='V'){echo $xfontsize-8;}else{echo $xfontsize;} ?>px;
						border-collapse:collapse;background-color:white;"
						>
			<?php { // THEAD ?>
			<thead style="display:block; <?php if($mobile!='true'){echo 'max-width:'.($screenw-20).'px;';} ?>;background-color:#eee;">
				<tr style="border-bottom:solid 1px; cursor:pointer;" title="Reordenar">
					<th onclick="sortTable(this,<?php echo $ccol++; ?>);" title="Imprimir">I</th>
					<th onclick="sortTable(this,0<?php $ccol++; ?>);" title="Detalle" style="<?php if($dispcolu==0){echo'display:none;';}?>">D</th>
					<th onclick="sortTable(this,<?php echo $ccol++; ?>);"><?php if($mobile=='true'){echo 'NUM.';}else{echo 'NUMERO';} ?></th>
					<th onclick="sortTable(this,<?php echo $ccol++; ?>);">FECHA</th>
					<th onclick="sortTable(this,<?php echo $ccol++; ?>);" style="letter-spacing:1px;<?php if($dispcolu==0){echo'display:none;';}?>">CED/RUC</th>
					<th onclick="sortTable(this,<?php echo $ccol++; ?>);" style="letter-spacing:10px; "><?php echo $entilabel; ?></th>
					<th onclick="sortTable(this,<?php echo $ccol++; ?>);" style="<?php if($tsubt==0){echo'display:none;';}?> <?php echo 'font-size:'.($xfontsize*0.8).';' ?> ">SUB-TOT</th>			
					<?php if($docuiimp==1){?>
						<th onclick="sortTable(this,<?php echo $ccol++; ?>);" style="<?php if($tsubtiva0==0){echo'display:none;';}?> <?php echo 'font-size:'.($xfontsize*0.8).';' ?>">SUBT-IVA0</th>
						<th onclick="sortTable(this,<?php echo $ccol++; ?>);" style="<?php if($tsubtiva==0){echo'display:none;';}?> <?php echo 'font-size:'.($xfontsize*0.8).';' ?>">SUBT-IVA</th>	
						<th onclick="sortTable(this,<?php echo $ccol++; ?>);" style="<?php if($tdcto==0){echo'display:none;';}?> <?php echo 'font-size:'.($xfontsize*0.8).';' ?>">DCTO</th>	
						<th onclick="sortTable(this,<?php echo $ccol++; ?>);" style="<?php if($tice==0){echo'display:none;';}?> <?php echo 'font-size:'.($xfontsize*0.8).';' ?>">ICE</th>	
						<th onclick="sortTable(this,<?php echo $ccol++; ?>);" style="<?php if($tiva==0){echo'display:none;';}?> <?php echo 'font-size:'.($xfontsize*0.8).';' ?>">IVA</th>	
						<th onclick="sortTable(this,<?php echo $ccol++; ?>);" style="<?php if($tirbp==0){echo'display:none;';}?> <?php echo 'font-size:'.($xfontsize*0.8).';' ?>">IRBP</th>
					<?php }?>
					<?php if(mb_stristr('retc.retp',$tabla)){?>
						<th onclick="sortTable(this,<?php echo $ccol++; ?>);" style="<?php if($dispcolu==0){echo'display:none;';} ?>">Base RTA</th>
						<th onclick="sortTable(this,<?php echo $ccol++; ?>);" style="<?php if($dispcolu==0){echo'display:none;';} ?>">%Ret.</th>
						<th onclick="sortTable(this,<?php echo $ccol++; ?>);" style="<?php if($dispcolu==0){echo'display:none;';} ?>">Ret.RTA</th>
						<th onclick="sortTable(this,<?php echo $ccol++; ?>);" style="<?php if($dispcolu==0){echo'display:none;';} ?>">Base IVA</th>
						<th onclick="sortTable(this,<?php echo $ccol++; ?>);" style="<?php if($dispcolu==0){echo'display:none;';} ?>">%Ret.</th>
						<th onclick="sortTable(this,<?php echo $ccol++; ?>);" style="<?php if($dispcolu==0){echo'display:none;';} ?>" >Ret.IVA</th>
					<?php } ?>
					<th onclick="sortTable(this,<?php echo $ccol++; ?>);" >TOTAL</th>
					<th onclick="sortTable(this,<?php echo $ccol++; ?>);" 
							style="letter-spacing:10px;max-width:400px;<?php if($dispcolu==0){echo'display:none;';}?>">CONCEPTO</th>
					<th onclick="sortTable(this,<?php echo $ccol++; ?>);">ST</th>
					<th onclick="sortTable(this,<?php echo $ccol++; ?>);"
							title="
							<?php if($user_anul==1){echo 'Anular';}?>
							<?php if($user_elim==1){echo '/Eliminar';}?>
										 ">
						<?php if($user_anul==1){echo 'O';}?>
						<?php if($user_elim==1){echo 'X';}?>
					</th>
				</tr>
			</thead>
			<?php } ?>
			<?php { // TBODY ?>
			<tbody id="tpant1b" style="overflow-y:auto; display:block; 
							<?php if($orient=='V'){echo'min-height:'.($hpant1-7).'px;';}		else{echo'min-height:'.($hpant1-75).'px;';}  ?> 
							<?php if($orient=='V'){echo'height:'.($hpant1-7)*(2.4).'px;';}	else{echo'height:'.($hpant1-75)*(2.4).'px;';}  ?> 
							">
				<?php //echo explain_sql($sql_pant);	?>
				<?php while($aso_pant=mysql_fetch_assoc($res_pant)){ ?>
				<?php $crow++; ?> 
				<?php $tipoid=$aso_pant['enti_tipoid']; ?>
				<?php $tiporuc=$aso_pant['enti_tiporuc']; ?>
				<?php $struc=$aso_pant['enti_struc']; ?>
				<tr id="tr_fila<?php echo $crow;?>" class="tr_fila"   height="<?php //if($mobile=='true'){echo '55px';};?>"
						style="<?php if ($crow%5==0){echo 'border-bottom:dotted 1px;'; } ?> "
						onclick="_filabg(event,'tr_fila','<?php echo $crow; ?>','');
										info_docu('PANT2','<?php echo $aso_pant['docu']; ?>','<?php echo $aso_pant['idnum1']; ?>');
										<?php if($touchs=='true'){?>
										<?php } ?>
										 "
						ondblclick="{document.getElementById('detadocu').checked='true';document.getElementById('detadocu').onchange();this.onclick();}"
						>
					<td align="center"><span style="display:none;"><?php echo fillzero($crow,5); ?></span>
					<?php ?>
					</td>
					<td align="center" style="<?php if($dispcolu==0){echo'display:none;';}?>" title="<?php echo 'ID:'.$aso_pant['idnum1'];?>"
							onclick="
										<?php if($touchs=='false'){?>
										info_docu('PANT2','<?php echo $aso_pant['docu']; ?>','<?php echo $aso_pant['idnum1']; ?>');
										<?php } ?>
										 ">
						<?php if($mobile!='true'){$pidtxt='radio'.'tr_fila'.$crow; $pname='rtr_fila'; $pcaption=''; $psize=$xfontsize; include('vrradio.php');} ?>
					</td>
					<td align="center" title="<?php echo $aso_pant['docu'].'-'.$aso_pant['ptonumero']; ?>">
						<?php if($mobile=='true'){echo intval($aso_pant['numero'])	;}else{echo $aso_pant['numero'];} ?>
					</td>
					<td align="center">
						<div style="display:none;"><?php echo $aso_pant['fecha']; ?></div>
						<?php echo $aso_pant['fechadmy']; ?>
					</td>
					<td align="center" style="<?php if($dispcolu==0){echo'display:none;';}?>"
							title="<?php if($tipoid=='R'){ echo 'RUC:'.$tiporuc.'-'.$struc;}else{echo 'ID:'.$tipoid;};?>">
						<?php echo substr($aso_pant['enti'],0,10); ?>
					</td>
					<td align="left" style="<?php if($mobile!='true' and strlen(trim($aso_pant['enti_descri']))>20){echo 'font-size:'.($xfontsize-2).'px;';}else{} ?>"
							title="<?php echo ' /RS: '.$aso_pant['enti_razsoc']; ?>">
						<?php if($mobile=='true'){echo substr($aso_pant['enti_descri'],0,20);}else{echo $aso_pant['enti_descri'];} ?>
					</td>
					<td align="right" style="<?php if($tsubt==0){echo'display:none;';}?>">
						<div style="display:none;"><?php echo fillzero($aso_pant['stsubt'],15); ?></div>
						<?php echo number_format(abs($aso_pant['stsubt']),2); ?>
					</td>	
					<?php if($docuiimp){ ?>
						<td align="right" style="<?php if($tsubtiva0==0){echo'display:none;';}?>">
							<div style="display:none;"><?php echo fillzero($aso_pant['stsubtiva0'],15); ?></div>
							<?php echo number_format(abs($aso_pant['stsubtiva0']),2); ?>
						</td>	
						<td align="right" style="<?php if($tsubtiva==0){echo'display:none;';}?>">
							<div style="display:none;"><?php echo fillzero($aso_pant['stsubtiva'],15); ?></div>
							<?php echo number_format(abs($aso_pant['stsubtiva']),2); ?>
						</td>	
						<td align="right" style="<?php if($tdcto==0){echo'display:none;';}?> font-style:italic;">
							<div style="display:none;"><?php echo fillzero($aso_pant['stdcto'],9); ?></div>
							<?php echo number_format(abs($aso_pant['stdcto']),2); ?>
						</td>	
						<td align="right" style="<?php if($tice==0){echo'display:none;';}?> font-style:italic;">
							<div style="display:none;"><?php echo fillzero($aso_pant['stice'],9); ?></div>
							<?php echo number_format(abs($aso_pant['stice']),2); ?>
						</td>	
						<td align="right" style="<?php if($tiva==0){echo'display:none;';}?> font-style:italic;" >
							<div style="display:none;"><?php echo fillzero($aso_pant['stiva'],9); ?></div>
							<?php echo number_format(abs($aso_pant['stiva']),2); ?>
						</td>	
						<td align="right" style="<?php if($tirbp==0){echo'display:none;';}?> font-style:italic;">
							<div style="display:none;"><?php echo fillzero($aso_pant['stirbp'],9); ?></div>
							<?php echo number_format(abs($aso_pant['stirbp']),2); ?>
						</td>	
				<?php } ?>
					<?php if(mb_stristr('retc.retp',$tabla)){?>
						<td align="right" style="<?php if($dispcolu==0){echo'display:none;';} ?>"> 
							<div style="display:none;"><?php echo fillzero($aso_pant['sbrta'],15); ?></div>
							<?php echo number_format(abs($aso_pant['sbrta']),2); ?>
						</td>
						<?php if(ceil($aso_pant['sprta'])==floor($aso_pant['sprta'])){$dval=0;}else{$dval=2;}?>
						<td align="center" style="<?php if($dispcolu==0){echo'display:none;';} ?>"> 
							<div style="display:none;"><?php echo fillzero($aso_pant['sprta'],7); ?></div>
							<?php echo number_format(abs($aso_pant['sprta']),$dval).'%'; ?>
						</td>
						<td align="right" style="font-style:italic;<?php if($dispcolu==0){echo'display:none;';} ?>">
							<div style="display:none;"><?php echo fillzero($aso_pant['srrta'],15); ?></div>
							<?php echo number_format(abs($aso_pant['srrta']),2); ?>
						</td>
						<td align="right" style="<?php if($dispcolu==0){echo'display:none;';} ?>"> 
							<div style="display:none;"><?php echo fillzero($aso_pant['sbiva'],15); ?></div>
							<?php echo number_format(abs($aso_pant['sbiva']),2); ?>
						</td>
						<?php if(ceil($aso_pant['spiva'])==floor($aso_pant['spiva'])){$dval=0;}else{$dval=2;}?>
						<td align="center" style="<?php if($dispcolu==0){echo'display:none;';} ?>"> 
							<div style="display:none;"><?php echo fillzero($aso_pant['spiva'],7); ?></div>
							<?php echo number_format(abs($aso_pant['spiva']),$dval).'%'; ?>
						</td>
						<td align="right" style="font-style:italic;<?php if($dispcolu==0){echo'display:none;';} ?>"> 
							<div style="display:none;"><?php echo fillzero($aso_pant['sriva'],15); ?></div>
							<?php echo number_format(abs($aso_pant['sriva']),2); ?>
						</td>
					<?php } ?>	
					<td align="right" > 
						<div style="display:none;"><?php echo fillzero($aso_pant['stotal'],15); ?></div>
						<?php echo number_format(abs($aso_pant['stotal']),2); ?>
					</td>
					<td style="<?php if($dispcolu==0){echo'display:none;';}?>max-width:400px;
										 <?php if(strlen(trim($aso_pant['concepto']))>50){echo 'font-size:'.($xfontsize-2).'px';} ?>"
							title="<?php echo trim($aso_pant['suco_descri']); ?>"
							>
						<?php echo trim($aso_pant['concepto']); ?>
					</td>
					<td align="center"><?php echo $aso_pant['status']; ?></td>
					<td align="center" >
					<?php
						if($aso_pant['status']!='O' and $aso_pant['status']!='X'){$tnumero++;}

						if(!mb_stristr('ROX',$aso_pant['status']) and $user_anul==1)
						{
							$pcaption='Anular: '.$aso_pant['docu'].'-'.$aso_pant['numero']; $pabrev='O';
							$pidtxt='anul'.'tr_fila'.$crow; $pname='itr_fila';
							$pidnum=$aso_pant['idnum1'];$pdocu=$aso_pant['docu'];
							$psize=$xfontsize;
							$ponclick="anul_docu('".$aso_pant['docu']."','".$aso_pant['idnum1']."','".$aso_pant['numero']."');";
							include('vrbutton.php');
						}

						if($aso_pant['status']=='O' and $user_elim==1)
						{
							$pcaption='Eliminar: '.$aso_pant['docu'].'-'.$aso_pant['numero']; $pabrev='X';
							$pidtxt='anul'.'tr_fila'.$crow; $pname='itr_fila';
							$pidnum=$aso_pant['idnum1'];$pdocu=$aso_pant['docu'];
							$psize=$xfontsize;
							$ponclick="elim_docu('".$aso_pant['docu']."','".$aso_pant['idnum1']."','".$aso_pant['numero']."');";
							include('vrbutton.php');
						}

// 						if(!mb_stristr('RX',$aso_pant['status']))
// 						{
// 							$pidtxt='anul'.'tr_fila'.$crow; $pname='itr_fila';
// 							$pidnum=$aso_pant['idnum1'];$pdocu=$aso_pant['docu'];
// 							$psize=$xfontsize;
// 							$ponclick='info_docu("PANTX","'.$aso_pant['idnum1'].'")';
// 							include('vrbutton.php');
// 						}
					?>
					</td>
				</tr>
				<?php } ?>
			</tbody>
		<?php } ?>	
			<?php { // FOOT ?>
			<tfoot style="display:block; <?php if($mobile!='true'){echo 'max-width:'.($screenw-20).'px;';} ?>;background-color:#eee;">
				<tr style="border-top:solid 1px;">
					<th></th>
					<th style="<?php if($dispcolu==0){echo'display:none;';}?>"></th>
					<th><?php echo ($tnumero).'/'.($crow); ?></th>
					<th></th>
					<th style="letter-spacing:1px; <?php if($dispcolu==0){echo'display:none;';}?>"><?php if($dispcolu==0){echo 'TOTAL';} ?></th>
					<th style="max-width:250px;letter-spacing:10px; "><?php if(1==1){echo 'TOTALES';} ?></th>
					<th align="right" style="<?php if($tsubt==0){echo'display:none;';}?>">
						<?php echo number_format(abs($tsubt),2); ?>
					</th>	
					<?php if($docuiimp==1){ ?>
						<th align="right" style="<?php if($tsubtiva0==0){echo'display:none;';}?>">
							<?php echo number_format(abs($tsubtiva0),2); ?>
						</th>
						<th align="right" style="<?php if($tsubtiva==0){echo'display:none;';}?>">
							<?php echo number_format(abs($tsubtiva),2); ?>
						</th>	
						<th align="right" style="<?php if($tdcto==0){echo'display:none;';}?> font-style:italic;">
							<?php echo number_format(abs($tdcto),2); ?>
						</th>	
						<th align="right" style="<?php if($tice==0){echo'display:none;';}?> font-style:italic;">
							<?php echo number_format(abs($tice),2); ?>
						</th>	
						<th align="right" style="<?php if($tiva==0){echo'display:none;';}?> font-style:italic;" >
							<?php echo number_format(abs($tiva),2); ?>
						</th>	
						<th align="right" style="<?php if($tirbp==0){echo'display:none;';}?> font-style:italic;">
							<?php echo number_format(abs($tirbp),2); ?>
						</th>	
				<?php } ?>
					<?php if(mb_stristr('retc.retp',$tabla)){ ?>
						<th align="right" style="font-style: ;<?php if($dispcolu==0){echo'display:none;';} ?>">
							<?php echo number_format(abs($tbrta),2); ?>
						</th>	
						<th></th>
						<th align="right" style="font-style:italic;<?php if($dispcolu==0){echo'display:none;';} ?>">
							<?php echo number_format(abs($trrta),2); ?>
						</th>	
						<th align="right" style="font-style: ;<?php if($dispcolu==0){echo'display:none;';} ?>">
							<?php echo number_format(abs($tbiva),2); ?>
						</th>	
						<th></th>
						<th align="right" style="font-style:italic;<?php if($dispcolu==0){echo'display:none;';} ?>">
							<?php echo number_format(abs($triva),2); ?>
						</th>	
					<?php } ?>
					<th align="right">
						<?php echo number_format(abs($total),2); ?>
					</th>
					<th></th>
					<th></th>
					<th></th>
				</tr>
				<?phpif($tnumero>0){?>
				<tr style="border-top:solid 1px;">
					<th></th>
					<th style="<?php if($dispcolu==0){echo'display:none;';}?>"></th>
					<th></th>
					<th></th>
					<th style="letter-spacing:1px; <?php if($dispcolu==0){echo'display:none;';}?>" ><?php if($dispcolu==0){echo'PROM.';}?></th>
					<th style="letter-spacing:5px;" ><?php if(1==1){echo'PROMEDIOS';}?></th>
					<th align="right" style="<?php if($tsubt==0){echo'display:none;';}?>">
						<?php echo number_format(abs($tsubt/$tnumero),2); ?>
					</th>
					<?php if($docuiimp==1){ ?>
						<th align="right" style="<?php if($tsubtiva0==0){echo'display:none;';}?>">
							<?php echo number_format(abs($tsubtiva0/$tnumero),2); ?>
						</th>
						<th align="right" style="<?php if($tsubtiva==0){echo'display:none;';}?>">
							<?php echo number_format(abs($tsubtiva/$tnumero),2); ?>
						</th>
						<th align="right" style="<?php if($tdcto==0){echo'display:none;';}?> font-style:italic;">
							<?php echo number_format(abs($tdcto/$tnumero),2); ?>
						</th>
						<th align="right" style="<?php if($tice==0){echo'display:none;';}?> font-style:italic;">
							<?php echo number_format(abs($tice/$tnumero),2); ?>
						</th>
						<th align="right" style="<?php if($tiva==0){echo'display:none;';}?> font-style:italic;">
							<?php echo number_format(abs($tiva/$tnumero),2); ?>
						</th>
						<th align="right" style="<?php if($tirbp==0){echo'display:none;';}?> font-style:italic;">
							<?php echo number_format(abs($tirbp/$tnumero),2); ?>
						</th>
					<?php }?>
					<?php if(mb_stristr('retc.retp',$tabla)){?>
						<th align="right" style="font-style: ;<?php if($dispcolu==0){echo'display:none;';} ?>">
							<?php echo number_format(abs($tbrta/$tnumero),2); ?>
						</th>	
						<th></th>
						<th align="right" style="font-style:italic;<?php if($dispcolu==0){echo'display:none;';} ?>">
							<?php echo number_format(abs($trrta/$tnumero),2); ?>
						</th>	
						<th align="right" style="font-style: ;<?php if($dispcolu==0){echo'display:none;';} ?>">
							<?php echo number_format(abs($tbiva/$tnumero),2); ?>
						</th>	
						<th></th>
						<th align="right" style="font-style:italic;<?php if($dispcolu==0){echo'display:none;';} ?>">
							<?php echo number_format(abs($triva/$tnumero),2); ?>
						</th>	
					<?php } ?>
					<th align="right" style="<?php if($total==0){echo'display:none;';}?> ">
						<?php echo number_format(abs($total/$tnumero),2); ?>
					</th>
					<th></th>
					<th></th>
					<th></th>
				</tr>
				<?php}?>
			</tfoot>
			<?php } ?>	
		</table>
	<pant1>
	<?php //echo '***'.date('H:i:s') .'<br>';?>
				
<?php } ?>			
			
<?php if(mb_stristr('PANT2',$pant)) { ?>

<?php updt_itemce($idnum); ?>

<?php {
	if(mb_stristr('retc.retp',$tabla))
	{
		$sql_pant ='select * from '.$tabla.'12 where status!="O" and ';
		$sql_pant.='concat(numero,fecha,enti) in (select concat(numero,fecha,enti) as numero from '.$tabla.'1 where idnum1="'.$idnum.'" )';
	}
	else
	{$sql_pant ='select * from '.$tabla.'12 where idnum1="'.$idnum.'"';}

	$sql_tpant =str_replace('select *','select *,'.$total_sql,$sql_pant);

	if(mb_stristr('retc.retp',$tabla)){$sql_tpant.=' group by fecha,numero,enti';}
	else	{$sql_tpant.=' group by idnum1';}

	$res_pant=mysql_query($sql_pant,$link_vcrx); 

{
	$res_tpant=mysql_query($sql_tpant,$link_vcrx); 
	$tsubt=mysql_result($res_tpant,0,'stsubt');
	$tcant=mysql_result($res_tpant,0,'stcant');

	if($docuiimp==1)
	{
		$tsubtiva0=mysql_result($res_tpant,0,'stsubtiva0');
		$tsubtiva=mysql_result($res_tpant,0,'stsubtiva');
		$tdcto=mysql_result($res_tpant,0,'stdcto');
		$tice=mysql_result($res_tpant,0,'stice');
		$tiva=mysql_result($res_tpant,0,'stiva');
		$tirbp=mysql_result($res_tpant,0,'stirbp');
	}
	$total=mysql_result($res_tpant,0,'stotal');

	if($tabla=='comp')
	{
		$trrta=mysql_result($res_tpant,0,'strrta');
		$triva=mysql_result($res_tpant,0,'striva');
	}

	if(mb_stristr('retc.retp',$tabla))
	{
		$trrta=mysql_result($res_tpant,0,'srrta');
		$triva=mysql_result($res_tpant,0,'sriva');
	}
}

}	?>

		
<pant11 style="display:none">
	<div style="font-size:<?php echo $xfontsize; ?>px;">
		<table border="0" width="<?php if($orient=='V'){echo '200%';}else{echo '100%';} ?>" cellpadding="2" width="100%"
						style="font-size:<?php if($orient=='V'){echo $xfontsize-12;}else{echo $xfontsize;} ?>px;
										max-height:<?php echo $hpant11-15; ?>px;
										border-collapse:collapse; background-color:#eee;">
			<tr   >
				<td>
<?php //echo 	'***'.explain_sql($sql_tpant); ?>
					<?php
							$pcaption='Imprimir: '.mysql_result($res_tpant,0,'docu').'-'.mysql_result($res_tpant,0,'numero'); $pabrev='I';
							$pidnum=mysql_result($res_tpant,0,'idnum1');
							$psize=$xfontsize;
// 							$ponclick='print_docu("'.mysql_result($res_tpant,0,'docu').'","'.mysql_result($res_tpant,0,'idnum1').'")';
							$ponclick='{window.open("print1.php?docu='.mysql_result($res_tpant,0,'docu').'&idnum='.mysql_result($res_tpant,0,'idnum1').'","_blank")}';
 							include('vrbutton.php');
					?>
				</td>
				<td style="font-weight:bold; font-size:80%" width="10%">
					<?php echo mysql_result($res_tpant,0,'docu_descri').'<br>'.mysql_result($res_tpant,0,'ptonumero'); ?><br>
					<?php echo 'ID: '.mysql_result($res_tpant,0,'idnum1'); ?>
				</td>
				<td>
					<div style="font-weight:bold;">
					<?php echo substr(mysql_result($res_pant,0,'enti_descri'),0,200); ?>
					</div>
					<div style="font-size:<?php if($mobile=='true' and strlen(mysql_result($res_tpant,0,'concepto')>100)){echo $xfontsize-16;}?>px" ;>
					<?php echo substr(mysql_result($res_tpant,0,'concepto'),0,200); ?>
					</div>
				</td>
				<?php if($empr_cont=='1' and $tabla=='comp'){ ?>
				<td>
					<div style="">
					<?php echo '<strong>SUSTENTO:</strong>'.mysql_result($res_tpant,0,'suco_descri'); ?>
					</div>
				</td>
				<td align="right">
					<div style="">
					<?php echo '<strong>Ret.RTA.: </strong>'.number_format(mysql_result($res_tpant,0,'strrta'),2); ?>
					</div>
					<div style="">
					<?php echo '<strong>Ret.IVA.: </strong>'.number_format(mysql_result($res_tpant,0,'striva'),2); ?>
					</div>
				</td>
				<?php } ?>
			</tr>
		</table>
	</div>
	<?php if($mobile=='true'){?>
	<div style="font-size:<?php echo $xfontsize; ?>px;">
		<table width="100%" cellpadding="2" width="100%" border="0"
						 style="font-size:<?php if($mobile=='true'){echo $xfontsize-8;}else{echo $xfontsize;} ?>px;
										border-collapse:collapse; background-color:#eee;">
			<tr>
				<?php if($tsubt!=0){ ?><th align="center">SUBT:</th><?php }?>
				<?php if($tsubtiva0!=0){ ?><th align="center">SUBT-IVA0:</th><?php }?>
				<?php if($tsubtiva!=0){ ?><th align="center">SUBT-IVA:</th><?php }?>
				<?php if($tdcto!=0){ ?><th align="center">DCTO:</th><?php }?>
				<?php if($tice!=0){ ?><th align="center">ICE:</th><?php }?>
				<?php if($tiva!=0){ ?><th align="center">IVA:</th><?php }?>
				<?php if($tirbp!=0){ ?><th align="center">IRBP:</th><?php }?>
				<?php if($trrta!=0){ ?><th align="center">RENTA:</th><?php }?>
				<?php if($triva!=0){ ?><th align="center">IVA:</th><?php }?>
				<?php if($total!=0){ ?><th align="center">TOTAL:</th><?php }?>
			</tr>
			<tr>
					<?php if($tsubt!=0){ ?><td align="center"><?php echo number_format(abs($tsubt),2); ?></td><?php }?>
					<?php if($tsubtiva0!=0){ ?><td align="center"><?php echo number_format($tsubtiva0,2); ?></td><?php }?>
					<?php if($tsubtiva!=0){ ?><td align="center"><?php echo number_format($tsubtiva,2); ?></td><?php }?>
					<?php if($tdcto!=0){ ?><td align="center"><?php echo number_format($tdcto,2); ?></td><?php }?>
					<?php if($tice!=0){ ?><td align="center"><?php echo number_format($tice,2); ?></td><?php }?>
					<?php if($tiva!=0){ ?><td align="center"><?php echo number_format($tiva,2); ?></td><?php }?>
					<?php if($tirbp!=0){ ?><td align="center"><?php echo number_format($tirbp,2); ?></td><?php }?>
					<?php if($trrta!=0){ ?><td align="center"><?php echo number_format($trrta,2); ?></td><?php }?>
					<?php if($triva!=0){ ?><td align="center"><?php echo number_format($triva,2); ?></td><?php }?>
					<?php if($total!=0){ ?><td align="center"><?php echo number_format(abs($total),2); ?></td><?php }?>
			</tr>
		</table>
	</div>
	<?php } ?>
</pant11>
	
<pant2>
<?php $crow=0; ?>
<?php $ccol=0; ?>
<?php
	if(mb_stristr('retc.retp',$tabla)){
	 $sql_pant='select * from '.$tabla.'12 where status!="O" and concat(fecha,numero,enti) in ';	
	 $sql_pant.='(select concat(fecha,numero,enti) as numero from '.$tabla.'1 where idnum1="'.$idnum.'") order by numer,cair';
	}
	else{$sql_pant='select * from '.$tabla.'12 where idnum2="'.$idnum.'" order by iddet';	} 
	$res_pant=mysql_query($sql_pant,$link_vcrx);	
?>
<?php $numrows=mysql_num_rows($res_pant); ?>
	<table id="tpant2" class="pant2" align="left" border="0" cellpadding="3" width="100%"
				 style="font-size:<?php if($orient=='V'){echo $xfontsize-8;}else{echo $xfontsize;} ?>px;
								overflow-x:hidden;
								border-collapse:collapse;background-color:white;"
						 >
		<?php { // THEAD ?>
		<thead style="display:block;">
			<tr style="border-bottom:solid 1px;background-color:#eee;">
				<th onclick="sortTable(this,<?php echo $ccol++; ?>);" title="Linea">L</th>
				<th style="<?php if($dispcolu==0){echo 'display:none;';} ?><?php echo $ccol++; ?>">D</th>	
				<?php if($docuiimp==1){ ?>
					<th onclick="sortTable(this,<?php echo $ccol++; ?>);" title="Cantidad">Cant</th>
					<th onclick="sortTable(this,<?php echo $ccol++; ?>);" title="Código" style="<?php if($dispcolu==09){echo'display:none;';}?>">Código</th>
					<th onclick="sortTable(this,<?php echo $ccol++; ?>);" title="Descripción">Descripción</th>
					<th onclick="sortTable(this,<?php echo $ccol++; ?>);" title="Prec.Unitario">P.Uni</th>
					<th onclick="sortTable(this,<?php echo $ccol++; ?>);" style="<?php if($tsubt==0){echo'display:none;';}?>">SUB-TOT</th>			
					<th onclick="sortTable(this,<?php echo $ccol++; ?>);" style="<?php if($tdcto==0){echo'display:none;';}?>">DCTO</th>	
					<th onclick="sortTable(this,<?php echo $ccol++; ?>);" style="<?php if($tice==0){echo'display:none;';}?>">ICE</th>	
					<th onclick="sortTable(this,<?php echo $ccol++; ?>);" style="<?php if($tiva==0){echo'display:none;';}?>">IVA</th>	
					<th onclick="sortTable(this,<?php echo $ccol++; ?>);" style="<?php if($tirbp==0){echo'display:none;';}?>">IRBP</th>
	<!-- 				<th onclick="sortTable(this,3);" title="Precio Unitario">PVP</th> -->
				<?php } ?>
				<?php if($docudocu==1){ ?>
					<th onclick="sortTable(this,<?php echo $ccol++; ?>);" title="">Documento</th>
					<th onclick="sortTable(this,<?php echo $ccol++; ?>);" title="">Numero</th>
				<?php } ?>
				<?php if($docurete==1){ ?>
					<th onclick="sortTable(this,<?php echo $ccol++; ?>);" title="">Base Imponible</th>
					<th onclick="sortTable(this,<?php echo $ccol++; ?>);" title="">Impuesto</th>
					<th onclick="sortTable(this,<?php echo $ccol++; ?>);" title="">% Ret.</th>
				<?php } ?>
				<th onclick="sortTable(this,<?php echo $ccol++; ?>);">TOTAL</th>
				<th onclick="sortTable(this,<?php echo $ccol++; ?>);" style="letter-spacing:10px;<?php if($dispcolu==0){echo'display:none;';}?>">DETALLE</th>
				<?php if($empr_cont=='1' and $tabla=='comp') {?>
					<th onclick="sortTable(this,<?php echo $ccol++; ?>);" style="<?php if($dispcolu==0){echo'display:none;';} ?>">Cuenta</th>
					<th onclick="sortTable(this,<?php echo $ccol++; ?>);" style="<?php if($dispcolu==0){echo'display:none;';} ?>">Contable</th>
					<th onclick="sortTable(this,<?php echo $ccol++; ?>);" style="<?php if($dispcolu==0){echo'display:none;';} ?>">CAIR</th>
					<th onclick="sortTable(this,<?php echo $ccol++; ?>);" style="<?php if($dispcolu==0){echo'display:none;';} ?>">%Rta</th>
					<th onclick="sortTable(this,<?php echo $ccol++; ?>);" style="<?php if($dispcolu==0){echo'display:none;';} ?>">%IVA</th>
				<?php } ?>
			</tr>
		</thead>
		<?php } ?>
		<?php { // TBODY ?>
		<tbody style="overflow-y:auto; overflow-x:hidden; display:block; border-bottom:solid 1px;
					<?php if($orient=='V'){echo'min-height:'.($hpant2-75).'px;';}else{echo'min-height:'.($hpant2-90).'px;';}  ?> 
					<?php if($orient=='V'){echo'height:'.($hpant2-75).'px;';}else{echo'height:'.($hpant2-90).'px;';}  ?> ">
			<?php while($aso_pant=mysql_fetch_assoc($res_pant)){ ?>
			<?php $crow++; ?>
			<?php $duni=$aso_pant['item_duni']; ?>
			<?php $dval=$aso_pant['item_dval']; ?>
			<?php if($dval==0){$dval=2;} ?>
			<?php if($duni==0){$duni=0;} ?>
			<?php if(ceil($aso_pant['cant'])!=floor($aso_pant['cant']) and $duni==0){$duni=2;} ?>
			<tr id="tr_filad<?php echo $crow;?>" class="tr_filad"  
						style="<?php if ($crow%5==0){echo 'border-bottom:dotted 1px;'; } ?><?php if ($crow==$numrows){echo 'border-bottom:solid 2px;'; } ?>
									 font-size:<?php if($orient=='V'){echo $xfontsize-8;}else{echo $xfontsize;}?>"
						onclick="_filabg(event,'tr_filad','<?php echo $crow; ?>','');";
						>
				<td align="center" style="font-size:80%;">
					<span style="display:none;"><?php echo fillzero($crow); ?></span><?php echo $aso_pant['iddet']; ?>
				</td>
				<td align="center" style="<?php if($dispcolu==0){echo'display:none;';}?>">
					<?php $pidtxt='radio'.'tr_filad'.$crow; $pname='rtr_filad'; $pcaption=''; $psize=$xfontsize; include('vrradio.php'); ?>
				</td>
				<?php if($docuiimp==1){ ?>
					<td align="center"><?php echo number_format(abs($aso_pant['cant']),$duni); ?></td>
					<td align="left" style="<?php if($dispcolu==09){echo'display:none;';}?>" title="<?php echo $aso_pant['itemce']; ?>">
						<?php echo $aso_pant['item']; ?>
					</td>
					<td align="left" title="<?php echo $aso_pant['itemce']; ?>"
								style="<?php if(strlen(trim($aso_pant['item_descri']))>20){echo 'font-size:80%';} ?>">
						<?php echo $aso_pant['item_descri']; ?>
					</td>
					<td align="right">
						<div style="display:none;"><?php echo fillzero($aso_pant['puni'],15); ?></div>
						<?php echo number_format(abs($aso_pant['puni']),$dval); ?>
					</td>
					<td align="right" style="<?php if($tsubt==0){echo'display:none;';} ?>">
						<div style="display:none;"><?php echo fillzero($aso_pant['tsubt'],15); ?></div>
						<?php echo number_format(abs($aso_pant['tsubt']),$dval); ?>
					</td>
					<td align="right" style="<?php if($tdcto==0){echo'display:none;';} ?>font-style:italic;" title="<?php echo number_format(abs($aso_pant['dcto']),$dval).'%'; ?>">
						<div style="display:none;"><?php echo fillzero($aso_pant['tdcto'],9); ?></div>
						<?php echo number_format(abs($aso_pant['tdcto']),$dval); ?>
					</td>
					<td align="right" style="<?php if($tice==0){echo'display:none;';} ?>font-style:italic;" title="<?php echo number_format(abs($aso_pant['ice']),$dval).'%'; ?>">
						<div style="display:none;"><?php echo fillzero($aso_pant['tice'],9); ?></div>
						<?php echo number_format(abs($aso_pant['tice']),$dval); ?>
					</td>
					<td align="right" style="<?php if($tiva==0){echo'display:none;';} ?>font-style:italic;" title="<?php echo number_format(abs($aso_pant['iva']),$dval).'%'; ?>">
						<div style="display:none;"><?php echo fillzero($aso_pant['tiva'],9); ?></div>
						<?php echo number_format(abs($aso_pant['tiva']),$dval); ?>
					</td>
					<td align="right" style="<?php if($tirbp==0){echo'display:none;';} ?>font-style:italic;" title="<?php echo number_format(abs($aso_pant['irbp']),$dval); ?>">
						<div style="display:none;"><?php echo fillzero($aso_pant['tirbp'],9); ?></div>
						<?php echo number_format(abs($aso_pant['tirbp']),$dval); ?>
					</td>
				<?php } ?>
				<?php if($docudocu==1){ ?>
				<?php $duni=2;$dval=2; ?>
				<?php if($dispcolu==0){$docum=$aso_pant['docum'];}else{$docum=$aso_pant['docum_descri'];} ?>
					<td align="center" style=""><?php echo $docum; ?></td>
					<?php if($dispcolu==0){$numer=$aso_pant['numer'];}else{$numer=$aso_pant['ptonumer'];} ?>
					<td align="center" style="" ><?php echo $numer; ?></td>
					<td align="center"><?php echo number_format(abs($aso_pant['cant']),$duni); ?></td>
					<?php if($aso_pant['puni']>=30 and $aso_pant['cair']==0){$cair='IVA';$cair_descri='';}
						else{$cair='('.$aso_pant['cair'].')';$cair_descri=$aso_pant['cair_descri'];}?>
					<?php if($dispcolu==0){$cair_descri='';} ?>
					<td align="center" ><?php echo $cair_descri.' '.$cair; ?></td>
					<?php if(ceil($aso_pant['puni'])==floor($aso_pant['puni'])){$dval=0;}else{$dval=2;}?>
					<td align="right"><div style="display:none;"><?php echo fillzero($aso_pant['puni'],9); ?></div>
						<?php echo number_format(abs($aso_pant['puni']),$dval).'%'; ?></td>
						<?php $duni=2;$dval=2; ?>
					<?php } ?>
					
						<td align="right" style="<?php if($total==0){echo'display:none;';} ?>">
								<div style="display:none;"><?php echo fillzero($aso_pant['total'],15); ?></div>
								<?php echo number_format(abs($aso_pant['total']),$dval); ?>
						</td>
						<td align="left" style="<?php if($dispcolu==0){echo'display:none;';} ?>
																		<?php if(strlen(trim($aso_pant['detalle']))>20){echo 'font-size:80%';} ?>">
							<?php echo $aso_pant['detalle']; ?></td>

					 <?php if($empr_cont=='1' and $tabla=='comp' and $mobile!='true') {?>
						<td align="left" style="<?php if($dispcolu==0){echo'display:none;';} ?>">
							<?php echo $aso_pant['ctas']; ?>
						</td>
						<td align="left" style="<?php if($dispcolu==0){echo'display:none;';} ?>">
							<?php echo $aso_pant['ctas_descri']; ?>
						</td>
						<td align="center" title="<?php echo $aso_pant['cair_descri']; ?>">
							<?php echo $aso_pant['cair']; ?>
						</td>
						<td align="right" style="<?php if($dispcolu==0){echo'display:none;';} ?>" 
								title="<?php echo number_format($aso_pant['rrta'],2).'%'; ?>">
							<?php echo number_format($aso_pant['rrta'],2).''; ?>
						</td>
						<td align="right" style="<?php if($dispcolu==0){echo'display:none;';} ?>"
								title="<?php echo number_format($aso_pant['riva'],2).'%'; ?>">
							<?php echo number_format($aso_pant['riva'],2).''; ?>
						</td>
						<?php } ?>
				</tr>

			<?php } ?>
			</tbody>	
		<?php } ?>
		<?php { // TFOOT ?>
			<tfoot style="display:block;">
				<tr style="border-top:solid 1px;background-color:#eee;"><?php echo str_repeat('<th></th>',$ccol); ?></tr>
			</tfoot>
		<?php } ?>
	</table>
</pant2>
		
<?php } ?>			
</resultado>

<?php $obstart = ob_get_clean(); ?>
<?php $obstart = alltrim($obstart) ?>
<?php echo $obstart;	?>

		