<?php session_start();?>
<?php include('../_cfg/config.php');?>
<?php include('php_gene1.php'); ?>
<?php include('php_session.php');?>

<?php  $xhora1=date('H:i:s'); ?>
<?php foreach($_POST as $campo => $valor){${$campo}=$valor;} ?>


<?php //foreach($_POST as $campo => $valor){setcookie($campo,$valor);} ?>

<?php $dispcolu=1; ?>
<?php $iddet=$iddet*1; ?>

<?php $tabulado=0; ?>
<?php $xsaldo0=1/100; ?>


<?php //$docxcob='"XC","FC","AC","NV","PR"';?>
<?php //$docxpag='"XP","FP","AP"';?>

<?php if(@mb_stristr('CXCO.CXPA',$modu)){$xsaldo0=1/100;}?>

<?php //$xuser_cedula=r_fiel('user',$user,'cedula'); ?>
<?php $user_cargo=r_fiel('user',$user,'cargo'); ?>

<?php $docux=$docu; ?>
<?php if($docux=='IEBX'){$docu='IB'; $limit1=50; $enti='';} ?>
<?php if($docux=='RPXX'){$docu='RP'; $limit1=15; $cair='';} ?>
<?php if($docux=='FPXX'){$docu='FP'; $limit1=15;} ?>
<?php if($docux=='ATXX'){$docu='AT'; $limit1=100;} ?>

<?php if($pant==''){$pant='PANT0';}?>

<?php if(!@mb_stristr('PANT.IMPR',substr($pant,0,4))){return;} ?>

<?php if($user_codigo==''){echo ('<msgalert>Usuario desconectado...</msgalert>');}?>


<?php
//   $paraiddet=$iddet;
//   ini_set('memory_limit', '512M');
$fecha0='2010-01-01';
$fecha0=fecha_modu($modu);

$fechadtr="2000-01-01";
if($modu=='CONT')
{$fechadtr=get_fechadtr();}


if($fecha1==''){$fecha1='2010-01-01';}
if($fecha2==''){$fecha2=$fechaa;}
// if($fecha1>$fecha2){$fecha1=date('Y-m-01',strtotime($fecha2));}
if($fecha1>$fecha2){$fecha2=date('Y-m-t',strtotime($fecha1));}
if($numero1==''){$numero1='1';}
if($numero2==''){$numero2='999999999';}

$numero1=fillzero($numero1);
$numero2=fillzero($numero2);

$gris1='gainsboro';

?>


<?php	

$user_nuev=0;
$user_cons=0;
$user_modi=0;
$user_anul=0;
$user_elim=0;
$user_proc=0;
$user_clon=0;

$cel_stat=0;
$ver_rete=0;
$ver_guia=0;
$ver_apli=0;
$ver_fact=0;
$ver_doco=0;
$ver_cele=0;
$ver_abono=0;
$ver_saldo=0;
$ver_valor=1;
$ver_subtot=1;

$ver_cost=0;
$ver_rota=0;
// $ver_total=1;
$tsaldo=0;

$dias_anul=180;
// $dias_anul=360;
$dias_rpro=30;
$dias_guia=30;
$dias_fact=15;

if($user_email=='ptama@hotmail.com'){$dias_anul=365;}
if($user_email=='vicore@hotmail.com'){$dias_anul=365;}


$docuacce='COST';  
include('php_useracce.php');
$user_cost=$user_cons;
// $user_cost=0;


$docuacce=$docu;  
include('php_useracce.php');

if($user_tipo=='supe')
{
  $user_nuev=1;
  $user_cons=1;
  $user_modi=1;
  $user_anul=1;
  $user_elim=1;
  $user_clon=1;
}

if($user_tipo=='clie' and substr($docu,0,2)=='PC')
{
  $user_nuev=1;
  $user_cons=1;
  $user_modi=0;
  $user_anul=1;
  $user_elim=0;
  $user_clon=0;
  
  $ver_rete=0;
//   $ver_fact=0;
}

if($user_tipo=='clie' and substr($docu,0,2)=='FC')
{
  $user_nuev=0;
  $user_cons=1;
  $user_modi=0;
  $user_anul=0;
  $user_elim=0;
  $user_clon=0;
  $ver_rete=0;
}

// echo '*/*/*/=>'.$user_cons;


if($user_nuev==1){$user_cons=1;}

if(mb_stristr('PANT2.IMPR2',$pant))
{$repo='eecc';}

if(mb_stristr('IMPR1',$pant))
{ 
 $ver_rete=0; 
 $ver_apli=0; 
 $ver_fact=0; 
 $ver_cele=0; 
 $ver_guia=0; 
   $ver_doco=0; 
} 

if(mb_stristr('PANT3.IMPR3',$pant))
{ 
 $ver_rete=0; 
 $ver_apli=0; 
 $ver_fact=0; 
 $ver_cele=0; 
 $ver_guia=0; 
//    $ver_doco=0; 
//    $mconcepto.=$mdetalle;
} 


if(@mb_stristr('retc.retp.caja.bcos.',$tabla)){$user_clon=0;}


//   $user_modi=0;
//   $user_anul=0;


if($docu=='undefined')
{$docu='';}
else
{
  $docu=trim(substr($docu,0,4));
}

// if(strlen($docu)==4)
// {$tabla=r_fiel('docu',$docu,'tabla');}
// else
// {$tabla=r_fiel('docu',substr($docu,0,2).'10','tabla');}  


$entilabel='ENTIDAD';
if($tabla=="")
{
  $tabla=strtolower($modu);
}

if($modu=='CONT'){$master='ctas';}
if($modu=='INVE'){$master='item';}
if($modu=='NOMI'){$master='enti'; $entilabel='EMPLEADOS';}
if($modu=='CXCO'){$master='enti'; $tabla='cxcob'; $entilabel='CLIENTES';}
if($modu=='CXPA'){$master='enti'; $tabla='cxpag'; $entilabel='PROVEEDORES';}
// if($modu=='VTAS'){$master='vtas'; $tabla='vtas'; $entilabel='CLIENTES';}

// echo '*/*/*'.$docu.$tablas;


if(@mb_stristr('acce.atvd.',$tabla)){$entilabel='USUARIO';}
if(@mb_stristr('vtas.clie.retc.carr.guia',$tabla)){$entilabel='CLIENTE'; $entilabeltipo='ZONA';}
if(@mb_stristr('comi.inve',$tabla)){$entilabel='ENTIDAD';}
if(@mb_stristr('prod',$tabla)){$entilabel='TALLER';}
if(@mb_stristr('comp.prov.retp.',$tabla)){$entilabel='PROVEEDOR'; $entilabeltipo='T.PROV.';}
if(@mb_stristr('nomi.nvdd.roln.suel',$tabla)){$entilabel='EMPLEADO';}
if(@mb_stristr('RC.',substr($docu,0,2))){$entilabel='CLIENTE';}
if(@mb_stristr('RP.',substr($docu,0,2))){$entilabel='PROVEEDOR';}


if($tabla=='acce'){$user_anul=0;$user_elim=0;}


if(@mb_stristr('vtas.retp.guia.clie.rolp',$tabla)){$cel_stat=1;}

if(@mb_stristr('vtas.retp.guia.rolp',$tabla) and @mb_stristr('sist.supe',$user_tipo) and $vercele=='true')
{$ver_cele=1;}

if($vercele!='true'){$ver_cele=0;}
if($vercost=='true'){$ver_cost=$user_cost;}
if($verrota=='true'){$ver_rota=1;}
if($verdtr1=='true'){$ver_dtr1=1;}

if(substr($pant,0,4)=='IMPR' and $vercele!='true'){$ver_cele=0; $cel_stat=0;}

if(@mb_stristr('clie',$tabla))
{$ver_fact=1;}

if(@mb_stristr('guia.inve',$tabla))
{$ver_doco=1;}

if(@mb_stristr('vtas.',$tabla))
{$ver_doco=1;}

if(@mb_stristr('vtas.comp',$tabla) and substr($docu,0,1)=='F' and $versaldo=='true')
{$ver_saldo=1;}

if($versaldo!='true'){$ver_saldo=0;}

if(@mb_stristr('vtas.inve',$tabla) and mb_stristr('F.E',substr($docu,0,1)) and $empr_guia==1 and $verguia=='true')
{$ver_guia=1;}

if($verguia!='true'){$ver_guia=0;}

if((@mb_stristr('vtas',$tabla) or (@mb_stristr('comp',$tabla) and $empr_cont==1)) and $verrete=='true')
{$ver_rete=1;}

if($verrete!='true'){$ver_rete=0;}

if(@mb_stristr('retc.retp.rete.caja.bcos',$tabla))
{$ver_apli=1;}

if(@mb_stristr('atvd.plan',$tabla) and $user_cargo=='ASIS')
{$ver_valor=0;}


if(@mb_stristr('comp',$tabla) and $docu!='FP11')
{$ver_cele=0; $cel_stat=0;}

if(@mb_stristr('vtas.comp',$tabla) and mb_stristr('NC.NP',substr($docu,0,2)))
{$ver_apli=1;}

if(@mb_stristr('FP03.FP11',$docu)){$cel_stat=1;}
if(@mb_stristr('FP03.FP11',$docu) and $vercele=='true'){$ver_cele=1;}

if($docu=='RBCO'){$ver_apli=0;}

if($docux=='IEBX'){$ver_doco=0;}
if($docux=='RPXX'){$ver_cele=0;}
if($mobile=='true' and $orient=='V'){$ver_guia=0;}

if(substr($pant,0,4)=='IMPR')
{
  $user_anul=0;
  $user_elim=0;
  $user_clon=0;
  $ver_cele=0;
  $ver_rete=0;
  $ver_doco=0;
//   $ver_guia=0;
}


$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);
// $vpant2 =ceil($screenv*0.30);

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

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

	if(@mb_stristr('vtas.comp.clie.prov.carr.inve.prod.guia',$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.rete',$tabla)){$docudocu=1;}
	if(@mb_stristr('caja.bcos',$tabla)){$docudocu=1;}
	if(@mb_stristr('comi',$tabla)){$docuitem=1;}
	if(@mb_stristr('retc.retp.rete',$tabla)){$docurete=1;}
	if(@mb_stristr('cont',$tabla)){$docuctas=1;}
  
  $total_sql=sql_total($tabla);

	if($mobile=='true'){$dispcolu=0;}
  if(substr($pant,0,4)=='IMPR'){$dispcolu=1;}  
// 	if($pant=='PANT3'){$dispcolu=0;}
}

?>



<?php ob_start(); ?>
<resultado>
  
<?php	val_usercodigo(); ?>

  
<?php $indirotat=array(); ?>  
  
<?php $tdisplay=''; ?>  
<?php if(substr($pant,0,4)=='PANT'){$tdisplay='display:block;';}?>  
  
  
<?php if(mb_stristr('PANT0',$pant)){ ?>
<?php if(@mb_stristr('invi.clie.prov',$user_tipo) or $user_tipo=='') {}else{?>
<?php } ?>
<?php $fecha1=date('Y-m-01',strtotime ('-5 days')); ?>
<?php $fecha1=date('Y-m-01',strtotime ('-1 month')); ?>
<?php //if(mb_stristr('amay.',$cfg_empr)){$fecha1=date('Y-m-d',strtotime ('-1 day'));} ?>
<?php if(@mb_stristr('PLA.ATV',substr($docu,0,3))){$fecha1=date('Y-m-01',strtotime ('-180 day'));} ?>
<?php $fecha2=date('Y-m-01',strtotime ('today')); ?>

  
  <?php $ptabla='item'; include('vrsetlist.php'); ?>
  <?php $ptabla='ctas'; include('vrsetlist.php'); ?>
  <?php $ptabla='ctab'; include('vrsetlist.php'); ?>
  <?php $ptabla='cair'; include('vrsetlist.php'); ?>
  <?php $ptabla='suco'; include('vrsetlist.php'); ?>
  <?php $ptabla='fpag'; include('vrsetlist.php'); ?>
  <?php $pidtxt='dl_impor'; $pdocu='FP'; $pcolu='impor'; include('vrsetlist.php'); ?>
  <?php $pidtxt='dl_pret'; $pdocu='RP'; $pcolu='puni'; $pwhere='(puni>0)'; include('vrsetlist.php'); ?>
  

		<div id="pant0" style="border:solid 2px; overflow:auto; width:100%;">
		<?php { ?>
			<table id="tpant0" cellpadding="2" width="99%" border="0"
					 style="font-size:<?php echo $xfontsize; ?>px;border-collapse:collapse; background-color:snow;">
				<tr>
          <td valign="top">
          <table width="100%" cellpadding="2" border="0" caption=""
                 style="font-size:<?php echo $xfontsize; ?>px;border-collapse:collapse; background-color:snow;">
              <tr>
                <?php if($mobile!='true'){?>        
                <td width="10%">
                </td>
                <?php } ?>
                <td colspan="2" align="center" <?php if($mobile=='false'){echo 'style="display:none;"';}else{echo 'style="text-transform:uppercase;font-weight:bold;font-family:arial;font-size:'.($xfontsize*1.2).';"';} ?> >
                  <titulo>Informes X Módulos</titulo>
                </td>
              </tr>
            <tr>
              <?php $pidtxt='fecha1'; $pcaption='Fec. Ini.'; $pdefa=$fecha1;  $psize=$xfontsize; include('vrgetfec.php'); ?>
            </tr>
            <tr>
              <?php $pidtxt='fecha2'; $pcaption='Fec. Fin'; $psize=$xfontsize; include('vrgetfec.php'); ?>
            </tr>
            
            <tr><?php // $pidtxt='concepto';  $psize=$xfontsize; $pcaption='CONCEPTO'; $plong=20; include('vrgettxt.php'); ?></tr>
          <?php if($mobile!='true'){?>        
          </table>

          </td>
          <td valign="top">
            
            <table width="100%" cellpadding="2" border="0"
                  style="font-size:<?php echo $xfontsize; ?>px;border-collapse:collapse; background-color:snow;">
          
              <tr>
                <td width="10%"></td>
              </tr>
          <?php } ?>
              <tr>
                <?php $pidtxt='modu'; $pcaption='modulo'; $ptabla='modu';  $psize=$xfontsize; $pdefa=$modu; $pvalue=$pdefa;   $pobj=3;  $pnotob=0; 
                   $ponblur="vali_modu();opt_modu();";
//                    if(strlen($modu)==4){$preado=1;}                          
                   include('vrgetcod.php'); ?>              
              </tr>

              <tr>
                <?php $pidtxt='repo'; $pcaption='Reporte';  $psize=$xfontsize; $pdefa=$docu;   $pvalue=$pdefa; $pobj=3;  $pnotob=0; 
                   $poptions ='';
                   $poptions.='idnum1,Transacción;';
                   include('vrselopt.php'); ?>              
              </tr>
          <?php if($mobile!='true'){?>        
            </table>
          </td>
          <td valign="top">
            
            <table width="100%" cellpadding="2" border="0" caption=""
                 style="font-size:<?php echo $xfontsize; ?>px;border-collapse:collapse; background-color:snow;">
            <tr>
              <td width="10%"></td>
            </tr>
          <?php } ?>
              

							<tr style="display:none;" class="cont">
                <?php $pidtxt='ctas'; $pcaption='CUENTA'; $ptabla='ctas'; $pnotob="1"; $psize=$xfontsize; $pobj=3; $pclass='cont';
                include('vrgetcod.php'); ?>
              </tr>

							<tr style="display:none;" class="cont">
                <?php $pidtxt='csub'; $pcaption='CENTRO'; $ptabla='csub'; $pnotob="1"; $psize=$xfontsize; $pobj=3; $pclass='cont';
                include('vrgetcod.php'); ?>
              </tr>

							<tr style="display:none;" class="cont comp">
                <?php $pidtxt='nivel'; $pcaption='NIVEL'; $pnotob="1"; $psize=$xfontsize; $pobj=3; $pclass='cont';
                $pdefa='3'; $pvalue=$pdefa; 
//                 $poptions='3;1;2;3;4;5';
                $poptn1=1; $poptn2=5;
                include('vrselopt.php'); ?>
              </tr>

              <?php if($empr_impo==1){?>
              <tr style="display:none;" class="modu comp impo">
                <?php $pidtxt='impor'; $pcaption='Import.'; $psize=$xfontsize;  $pobj=3; $pclass='comp impo'; $plist='dl_impor'; $plong=10; include('vrgettxt.php'); ?>
              </tr>
              <tr style="display:none;" class="modu comp impo">
                <?php // $pidtxt='peso'; $pcaption='Peso KG'; $psize=$xfontsize;  $pobj=3; $pclass='comp'; $preado=1; include('vrgettxt.php'); ?>
              </tr>
              <?php } ?>
              

          <?php if($mobile!='true'){?>        
            </table>
          </td>
          <td valign="top">
            
            <table width="100%" cellpadding="2" border="0" caption=""
                 style="font-size:<?php echo $xfontsize; ?>px;border-collapse:collapse; background-color:snow;">
            <tr>
              <td width="10%"></td>
            </tr>
          <?php } ?>
              <tr>
                <?php $pidtxt='docu'; $pcaption='docu'; $ptabla='docu';  $psize=$xfontsize; $pdefa=$docu;   $pvalue=$pdefa; $pobj=3;  $pnotob=0; $pclass='vtas comp'; 
                   $pwhere='(docu_tipo="TRAN")';  $ponblur="";
//                    if(@mb_stristr('invi.clie.prov',$user_tipo) or $user_tipo==''){$phide=1;}
                  $phide=1;
                   if(strlen($docu)==4){$preado=1;}                          
                   include('vrgetcod.php'); 
                ?>              
              </tr>
							<tr style="display:none;" class="vtas comp clie prov inve nomi caja bcos cont cxco cxpa retc retp">
                <?php $pidtxt='enti'; $pcaption=$entilabel; $ptabla='enti'; $pnotob="1"; $psize=$xfontsize;  $pobj=3; 
                    $pclass='vtas comp clie prov inve nomi caja bcos cont cxco cxpa retc retp'; 
                   if(@mb_stristr('invi.clie.prov',$user_tipo) or $user_tipo==''){$pexact=0;$pdatalist=1;}             
                   include('vrgetcod.php'); ?>
              </tr>

               <tr style="display:none;" class="vtas comp clie prov inve">
                <?php $pidtxt='item'; $pcaption='ITEM'; $ptabla='item'; $pnotob="1"; $psize=$xfontsize; $pobj=3; $pclass='vtas comp clie prov inve';
                include('vrgetcod.php'); ?>
              </tr>
               <tr style="display:none;" class="nomi">
                <?php $pidtxt='nvdd'; $pcaption='NOVEDAD'; $ptabla='nvdd'; $pnotob="1"; $psize=$xfontsize; $pobj=3; $pclass='nomi';
                include('vrgetcod.php'); ?>
              </tr>
          <?php if($mobile!='true'){?>        
          </table>

          </td>
          <td valign="top" width="10%">

            <table width="100%" cellpadding="2" border="0"
                style="font-size:<?php echo $xfontsize; ?>px;border-collapse:collapse; background-color:snow; <?php if($mobile=='true'){echo 'display:none;';} ?>">
            <tr>
              <td width="10%"></td>
            </tr>
          <?php } ?>

            <tr style="display:none;" class="vtas">
              <?php $pidtxt='ptov'; $pcaption='PTO.VTA.'; $ptabla='ptov'; $psize=$xfontsize; $pobj=3; $pclass='vtas'; include('vrgetcod.php'); ?>
            </tr>
            <tr style="display:none;" class="inve">
              <?php $pidtxt='bode'; $pcaption='BODEGA'; $ptabla='bode'; $psize=$xfontsize;  $pobj=3; $pclass='inve'; include('vrgetcod.php'); ?>
            </tr>
            <tr style="display:none;" class="guia">
              <?php $pidtxt='placa'; $pcaption='PLACA'; $ptabla='vhcl'; $psize=$xfontsize;  $pobj=3; $pclass='guia'; include('vrgetcod.php'); ?>
            </tr>
            <tr style="display:none;" class="bcos">
              <?php $pidtxt='ctab'; $pcaption='CTA:BANC.'; $ptabla='ctab'; $psize=$xfontsize;  $pobj=3; $pclass='ctab'; include('vrgetcod.php'); ?>
            </tr>
            <tr style="display:none;" class="comp retc retp">
              <?php $pidtxt='cair'; $pcaption='CAIR'; $ptabla='cair'; $psize=$xfontsize;  $pobj=6; $pclass='comp retc retp'; include('vrgetcod.php'); ?>
            </tr>
            <tr style="display:none;" class="comp retc retp">
              <?php $pidtxt='suco'; $pcaption='Sust.Comp.'; $ptabla='suco'; $psize=$xfontsize;  $pobj=6; $pclass='comp retc retp'; include('vrgetcod.php'); ?>
            </tr>
            <tr style="display:none;" class="vtas">
              <?php $pidtxt='zsub'; $pcaption='ZONA'; $ptabla='zsub'; $psize=$xfontsize; $plong=4; $pobj=3; $pclass='vtas cxco'; include('vrgetcod.php'); ?>
            </tr>
            <tr style="display:none;" class="nomi">
              <?php $pidtxt='csub'; $pcaption='CENTRO'; $ptabla='csub'; $psize=$xfontsize; $plong=4; $pobj=3; $pclass='csub'; include('vrgetcod.php'); ?>
            </tr>
            <tr style="display:none;" class="comp">
              <?php $pidtxt='tpro'; $pcaption='T.PROV'; $ptabla='tpro'; $psize=$xfontsize; $plong=4; $pobj=3; $pclass='comp cxpa'; include('vrgetcod.php'); ?>
            </tr>
            <tr style="display:none;" class="vtas inve">
              <?php $pidtxt='lsub'; $pcaption='LINEA'; $ptabla='lsub'; $psize=$xfontsize; $plong=4; $pobj=3; $pclass='vtas inve'; include('vrgetcod.php'); ?>
            </tr>
            <tr style="display:none;" class="vtas">
              <?php //$pidtxt='vndd'; $pcaption='VENDEDOR'; $ptabla='vndd'; $psize=$xfontsize; $plong=4; $pobj=3; $pclass='vtas cxco'; include('vrgetcod.php'); ?>
            </tr>
              
            <tr style="display:none;" class="">
              <?php $pidtxt='fmes'; $plong=10; $pobj=1; $phide=1; include('vrgettxt.php'); ?>
            </tr>
              
            <tr style="display:none;" class="">
              <?php $pidtxt='fsema'; $plong=10; $pobj=1; $phide=1; include('vrgettxt.php'); ?>
            </tr>
              
            <tr style="display:none;" class="">
              <?php $pidtxt='fecha'; $plong=10; $pobj=1; $phide=1; include('vrgettxt.php'); ?>
            </tr>
              
              
              
            <?php if(mb_stristr('pcs1.prs1',$cfg_empr)){?>
            <tr style="display:none;" class="vtas ">
              <?php $pidtxt='cntn'; $pcaption='CNTN'; $ptabla='cntn'; $psize=$xfontsize; $plong=4; $pobj=3; $pclass='vtas'; $pnotob="1"; include('vrgetcod.php'); ?>
            </tr>
            <?php } ?>
              
              
              
            <?php if($cfg_empr=='tgck'){?>
            <tr style="display:none;" class="vtas ">
              <?php $pidtxt='vhcl'; $pcaption='VHCL'; $ptabla='vhcl'; $psize=$xfontsize; $plong=4; $pobj=3; $pclass='vtas'; $pnotob="1"; include('vrgetcod.php'); ?>
            </tr>
            <?php } ?>
          </table>

          <?php if($mobile!='true'){?>        
          </td>
          <td valign="top">
          <?php } ?>

            <table width="100%" cellpadding="2" border="0"
                style="font-size:<?php echo $xfontsize; ?>px;border-collapse:collapse; background-color:snow;">
              <tr>
                <td width="10%"></td>
              </tr>
              <tr>
              <?php if($mobile=='true'){?>        
              <td>
              <?php } ?>  
              <?php $pidtxt='detadocu'; $pcaption='Detalle'; $ponclick='info_modu("DETA");'; $psize=$xfontsize; $pdefa=0;  $pvalue=$pdefa; $pclass=''; include('vrchkbox.php'); ?>
              <?php if($mobile=='true'){?>        
              </td>
              <td valign="top">
              <?php }else{ ?>
              </tr>
              <tr style="display:none;" >
              <?php } ?>
              <?php  //$pidtxt='rise'; $pcaption='Solo RISE'; $ponclick=''; $psize=$xfontsize; $pdefa=0; $pclass="comp"; $phide=1; include('vrchkbox.php'); ?>
              <?php if($mobile=='true'){?>        
              </td>
              <td valign="top">
              <?php }else{ ?>
              </tr>
              <tr style="display:none;" >
              <?php } ?>
              <?php $pidtxt='verdtr1'; $pcaption='Incl.DTR'; $ponclick=''; $psize=$xfontsize; $pdefa=0;  $pvalue=$pdefa; $pclass="cont"; $phide=1; include('vrchkbox.php'); ?>
              <?php // $pidtxt='versaldo'; $pcaption='Saldos'; $ponclick=''; $psize=$xfontsize; $pdefa=0; $pclass="vtas comp"; $phide=1; include('vrchkbox.php'); ?>
              <?php if($mobile=='true'){?>        
              </td>
              <td valign="top">
              <?php }else{ ?>
              </tr>
              <tr style="display:none;" >
              <?php } ?>
              <?php $pidtxt='vercost'; $pcaption='Costos'; $ponclick=''; $psize=$xfontsize; $pdefa=0;  $pvalue=$pdefa; $pclass="vtas inve"; $phide=1; include('vrchkbox.php'); ?>
              <?php if($mobile=='true'){?>        
              </td>
              <td valign="top">
              <?php }else{ ?>
              </tr>
              <tr style="display:none;" >
              <?php } ?>
              <?php $pidtxt='verrota'; $pcaption='Rotación'; $ponclick=''; $psize=$xfontsize; $pdefa=0;  $pvalue=$pdefa; $pclass="inve"; $phide=1; include('vrchkbox.php'); ?>
              <?php if($mobile=='true'){?>        
              </td>
              <?php } ?>  
              </tr>

              <?php if($mobile=='true'){?>        
              <tr><td><br></td></tr>
              <?php } ?>

            </table>

          <?php if($mobile!='true'){?>        
          </td>
          <td valign="top">
          <?php } ?>
                       
          <table width="100%" cellpadding="2" border="0"
                style="font-size:<?php echo $xfontsize; ?>px;border-collapse:collapse; background-color:snow;">

            <tr>
            <td style="display:;">
					<?php $pidtxt='acepta'; $pcaption='Aceptar '; $ponclick='info_modu("PANT1",'.'document.getElementById("modu").value'.')'; $psize=$xfontsize; include('vrbutton.php'); ?>
            </td>  
            <?php if($mobile!='true'){?>        
            </tr>
            <tr>
            <?php } ?>              
            <td>
            <?php //if($user_tipo!='sist'){$phide=1;}; ?>
            <?php // $pidtxt='acep3'; $pcaption='Acepta3 '; $ponclick='info_modu("PANT3",'.'document.getElementById("modu").value'.')'; $psize=$xfontsize;
//         include('vrbutton.php'); 
              ?>
            </td>  
            <?php if($mobile!='true'){?>        
            </tr>
            <tr>
            <?php } ?>              
            <td>
					<?php $pidtxt='imprim'; $pcaption='Imprimir '; $ponclick='info_modu("IMPR1",'.'document.getElementById("modu").value'.')'; $psize=$xfontsize; include('vrbutton.php'); ?>
            </td>  
            <?php if($mobile!='true'){?>        
            </tr>
            <tr>
            <?php } ?>              
            <td>
					<?php $pidtxt='old'; $pcaption='COMP.OLD.'; $ponclick='location.href=\'?scri=vrcompt0\';'; $phref='?scri=vrcompt0'; $psize=$xfontsize; $pclass="comp";  include('vrbutton.php'); ?>
            </td>  
            <?php if($mobile!='true'){?>        
            </tr>
            <tr>
            <?php } ?>              
            <td>
            

          <?php if(@mb_stristr('sist',$user_tipo) or $cfg_empr=='tfle')
                   { ?>            
                <?php 
                  $pidtxt='nueva'; $pcaption='Nuevo ';
//                 $phref="?scri=vrcompt0"
            $ponclick='';
            $ponclick.=""; 
            $ponclick.="info_modu('PANT1',document.getElementById('docu').value);"; 
                  $psize=$xfontsize; include('vrbutton.php');
                 ?>
                
            <?php } ?>
              </td>
            <tr>
                <td><div id='idnum_creadocu'style='display:none;'></div></td>
            </tr>
            <?php if($mobile=='true'){?>        
              <tr><td><br></td></tr>
            <?php } ?>              
              
            </table>
         </td>

				</tr>	
			</table>
		<?php } ?>
		</div>	
		<div id="pant1" style="border:solid 1px; overflow:auto; font-family:arial;">
		<div id="tpant1b"></div>
    </div>
		<hr>
		<div id="pant11" style="border:solid 1px; overflow:auto; font-family:arial; display:none;"></div>
		<div id="pant2"  style="border:solid 1px; overflow:auto; font-family:arial; display:none;
					<?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-40).'px;';}  ?> 
           "></div>
		<div id="pant9"></div>
<?php } ?>			

<?php if(mb_stristr('PANT1.IMPR1',$pant)){ ?>
<?php 
  $sql_stat ='update '.$tabla.'1 set status="-" ';
  $sql_stat.=' where (status="" or status is null) ';
  $sql_stat.=' and (fecha between "'.$fecha1.'" and "'.$fecha2.'")';
//   mysql_query($sql_stat,$link_vcrx); 
?>

<?php
    { 
   if($modu=='CONT')
   {
      $sql_dtr1='select * from cont1 where docu like "DTR%" and status!="O" and status!="X" and fecha<="'.$fecha2.'" order by fecha desc limit 1';
      $res_dtr1=mysql_query($sql_dtr1,$link_vcrx);
      $fecdtr1=@mysql_result($res_dtr1,0,'fecha');
      $iddtr1=0;
      if($fecdtr1==$fecha2)
      {$iddtr1=@mysql_result($res_dtr1,0,'idnum1');}
     
      $fecha0=fecha_modu($modu);
      {
        if(mb_stristr('lldd',$repo))
        {
          $nivel=5;
          $ctas='';
          $csub='';
          $sql_pant ='select '.$tabla.'12.*, ';
          $sql_pant.=' sum(tdebito) as stdebito,';
          $sql_pant.=' sum(tcredito) as stcredito,';
          $sql_pant.=' sum(tcant) as stcant';
          $sql_pant.=' from '.$tabla.'12';
          $sql_pant.=' where status!="O"';
          $sql_pant.=' and fecha>="'.$fecha1.'"';
          $sql_pant.=' and fecha<="'.$fecha2.'"';
          if(!empty($enti))
          {$sql_pant.=' and (enti like "'.$enti.'%" or enti_descri like "%'.$enti.'%")';}
          
          
          if($repo=='ddxx')
          {
            $sql_pant.=' and idnum1 in  ';
            $sql_pant.=' (select idnum1 from cont11 ';
            $sql_pant.=' where fecha>="'.$fecha1.'" and fecha<="'.$fecha2.'" and abs(tcant)>1/100) ';
          }
          
          
          $sql_tpant=$sql_pant;
          
//           $sql_pant.=' group by idnum1,iddet ';
          $sql_pant.=' group by fecha,idnum1,mdfrom,docu,numero,iddet ';
          $sql_pant.=' order by fecha,idnum1,mdfrom,docu,numero,ctas ';

          
         
//           $sql_tpant.=' grou'
          
        }
        else
        {
          $sql_where=' fecha<="'.$fecha2.'"';
          if($ctas!=''){$sql_where.=' and ctas like "'.$ctas.'%"';}
          if($csub!=''){$sql_where.=' and csub like "'.$csub.'%"';}

          $sql_where.=' and status!="O"';
          $sql_where.=' and fecha>="'.$fecha0.'"';
          if(mb_stristr('ssff.sfcc',$repo)){$sql_where.=' and substring(ctas,1,1) in(1,2,3) ';}
          if(mb_stristr('rrii.ricc',$repo)){$sql_where.=' and substring(ctas,1,1) in(4,5,6) ';}
          if(mb_stristr('rrii.ricc',$repo)){$sql_where.=' and fecha>="'.$fecha1.'" ';}
          
          if($ver_dtr1==0 and $iddtr1!=0){$sql_where.=' and idnum1!="'.$iddtr1.'" ';}

          $sql_pant='select '.$tabla.'12.*,';
          $sql_pant.=$nivel.' as nivel,';
          $sql_pant.='ctan'.$nivel.' as ctas_codi,';
          $sql_pant.='descri'.$nivel.' as ctas_desc,';
          if(mb_stristr('ssss.ssnn.sscc',$repo))
          {
            $sql_pant.='sum(case when fecha<"'.$fecha1.'" then tcant end) as saldoi, ';
            $sql_pant.='sum(case when fecha>="'.$fecha1.'" and fecha<="'.$fecha2.'" then tdebito end) as stdebito, ';
            $sql_pant.='sum(case when fecha>="'.$fecha1.'" and fecha<="'.$fecha2.'" then tcredito end) as stcredito, ';
          }

          if(mb_stristr('sscc.sfcc.ricc',$repo))
          {
            $xfecha=date('Y-m-01',strtotime($fecha1));
            while($xfecha<=$fecha2)
            {
              $xanio=date('Y',strtotime($xfecha));
              $xmes=date('m',strtotime($xfecha));
              $xaniomes=$xanio.$xmes;
              
              // aqui filtrar DTR
              if(mb_stristr('sscc.ricc',$repo))
              {$sql_pant.='sum(case when concat(fanio,fmes)="'.$xaniomes.'" and docu not like "DTR%" then tcant end) as m_'.$xaniomes.', ';}
              else
              {$sql_pant.='sum(case when concat(fanio,fmes)<="'.$xaniomes.'" then tcant end) as m_'.$xaniomes.', ';}
              
              $xfecha=date('Y-m-01',strtotime($xfecha .'+1 month'));
            }

          }


          $sql_pant.='sum(tcant) as saldo,';
          $sql_pant.='1 as cta_detalle ';
          $sql_pant.=' from '.$tabla.'12';
          $sql_pant.=' where '.$sql_where;      

          $sql_tpant=$sql_pant;

          $sql_tpant1=$sql_pant;
          $sql_tpant1.=' group by ctan1 ';
          $sql_tpant1.=' order by ctan1 ';

          $sql_pant.=' group by ctan'.$nivel;

          //UNIONS
          if(mb_stristr('ssnn.ssff.rrii.sfcc.ricc',$repo))
          {
            $xfniv=$nivel-1;	
            while ($xfniv>0)
            {
              $sql_pant.=' union ';
              $sql_pant.='select '.$tabla.'12.*,';
              $sql_pant.=$xfniv.' as nivel,';
              $sql_pant.='ctan'.$xfniv.' as ctas_codi,';
              $sql_pant.='descri'.$xfniv.' as ctas_desc,';
              if(mb_stristr('ssss.ssnn',$repo))
              {
                $sql_pant.='sum(case when fecha<"'.$fecha1.'" then tcant end) as saldoi, ';
                $sql_pant.='sum(case when fecha>="'.$fecha1.'" and fecha<="'.$fecha2.'" then tdebito end) as stdebito, ';
                $sql_pant.='sum(case when fecha>="'.$fecha1.'" and fecha<="'.$fecha2.'" then tcredito end) as stcredito, ';
              }

              if(mb_stristr('sscc.sfcc.ricc',$repo))
              {
                $xfecha=date('Y-m-01',strtotime($fecha1));
                while($xfecha<=$fecha2)
                {
                  $xanio=date('Y',strtotime($xfecha));
                  $xmes=date('m',strtotime($xfecha));
                  $xaniomes=$xanio.$xmes;
                  if(mb_stristr('ricc',$repo))
                  {$sql_pant.='sum(case when concat(fanio,fmes)="'.$xaniomes.'" and docu not like "DTR%" then tcant end) as m_'.$xaniomes.', ';}
                  else
                  {$sql_pant.='sum(case when concat(fanio,fmes)<="'.$xaniomes.'" then tcant end) as m_'.$xaniomes.', ';}
                  $xfecha=date('Y-m-01',strtotime($xfecha .'+1 month'));
                }

              }
              
              
              $sql_pant.='sum(tcant) as saldo,';
              $sql_pant.='0 as cta_detalle ';
              $sql_pant.='from '.$tabla.'12 ';
              $sql_pant.='where '.$sql_where;

              
//               echo '<br>';
//               echo '<br>';
//               echo '<br>TTTT';
//               echo $sql_tpant;
//               $sql_tpant.=$sql_pant;

              
              $sql_pant.=' group by ctan'.$xfniv;
              $xfniv--;
              
              
//                             echo '<br>';
//               echo '<br>';
//               echo '<br>SSSS';
//               echo $sql_pant;

              
            }	
          }

          $sql_pant.=' order by ctas_codi,nivel,cta_detalle ';
        }        
        
      }
     
   }
      

   if($modu=='INVE')
   {
     
     
    if(mb_stristr('inve.prod',$tabla) and $repo=='evta' and $ver_cost==1)
    {
         $sql_inve ='select * from '.$tabla.'1 ';
         $sql_inve.='where status!="O" ';
         $sql_inve.=' and docu="EB10"';
         $sql_inve.=' and fecha>="'.$fecha1.'"';
         $sql_inve.=' and fecha<="'.$fecha2.'"';
//          $sql_inve.=' and (pvta=0 or pvta is null)';
          $res_inve= mysql_query($sql_inve,$link_vcrx);
          while($aso_inve=mysql_fetch_assoc($res_inve))
          {updt_invepvta($aso_inve['docu'],$aso_inve['idnum1']);}
    }
     
     
     
     
     
     $fecha0=fecha_modu($modu);
      {
        $sql_pant ='select '.$tabla.'12.*,';
        $sql_pant.='item as codigo,';
        $sql_pant.='item_descri as codigodesc,';
        {
          $sql_pant.='sum(case when fecha<"'.$fecha1.'" then tcant end) as saldoiu, ';
          $sql_pant.='sum(case when fecha<"'.$fecha1.'" then tsubt end) as saldoi, ';
          $sql_pant.='sum(case when fecha>="'.$fecha1.'" and fecha<="'.$fecha2.'" then tingreso end) as stingreso, ';
          $sql_pant.='sum(case when fecha>="'.$fecha1.'" and fecha<="'.$fecha2.'" then tegreso end) as stegreso, ';
          $sql_pant.='sum(case when fecha>="'.$fecha1.'" and fecha<="'.$fecha2.'" then tdebito end) as stdebito, ';
          $sql_pant.='sum(case when fecha>="'.$fecha1.'" and fecha<="'.$fecha2.'" then tcredito end) as stcredito, ';
        }
        
        if($repo=='ssbb')
        {
          $bode='';
          $sql_bode='select distinct bode from inve1 where status not in("O","X") order by bode';
          $res_bode=mysql_query($sql_bode,$link_vcrx);
          while($aso_bode=mysql_fetch_assoc($res_bode))
          {
            $xbode=$aso_bode['bode'];
            $sql_pant.='sum(case when bode="'.$xbode.'" then tcant end) as bu_'.$xbode.', ';
            $sql_pant.='sum(case when bode="'.$xbode.'" then tsubt end) as b_'.$xbode.', ';
          }
        }

        
        $sql_where=' fecha<="'.$fecha2.'"';
        $sql_where.=' and fecha>="'.$fecha0.'"';
        $sql_where.=' and status!="O"';
        if($bode!=''){$sql_where.=' and bode like "'.$bode.'" ';}
        if($lsub!=''){$sql_where.=' and item_lsub like "'.$lsub.'%" ';}
        if($mrca!=''){$sql_where.=' and item_mrca like "'.$mrca.'" ';}
        if($item!=''){$sql_where.=' and item like "'.$item.'%" or item_descri like "%'.$item.'%" ';}
        
        if($repo=='evta')
        {
          $sql_where.=' and docu="EB10" ';
          $sql_where.=' and fecha>="'.$fecha1.'"';
        }
        
        $sql_pant.='sum(tcant) as saldou,';
        $sql_pant.='sum(tsubt) as saldo,';
        $sql_pant.='sum(tpvta) as stpvta,';
        $sql_pant.='sum(tutil) as stutil,';
        $sql_pant.='1 as stat ';
        $sql_pant.=' from '.$tabla.'12';
        $sql_pant.=' where '.$sql_where;      

        $sql_tpant=$sql_pant;
        
//         $sql_tpant1=$sql_pant;
//         $sql_tpant1.=' group by item ';
//         $sql_tpant1.=' order by lsub_descri, item_descri, item ';

//         $sql_pant.=' group by item';
        $sql_pant.=' group by lsub_descri, item_lsub, item_descri, item ';
        $sql_pant.=' order by lsub_descri, item_lsub, item_descri, item ';
        
        
        
      }
     
   }
      
      
      
   if($modu=='IMPO')
   {
     $sql_pant ='select * from prov12 ';
     $sql_pant.='where (impor!="" and impor is not null) ';
     
     if($impor!='')
     {$sql_pant.='and impor like "'.$impor.'"';}
//      echo '*/*/*'.$sql_pant;
     $sql_pant.=' order by impor, fecha';
     
      if(mb_stristr('cost',$repo))     
      {}  
     
   }

      
   if($modu=='CXCO' or $modu=='CXPA')
   {
     $fecha0=fecha_modu($modu);
      {
        
        {
          $sql_where=' fecha<="'.$fecha2.'"';
          if($enti!=''){$sql_where.=' and (enti like "'.substr($enti,0,10).'%" or enti_descri like "%'.$enti.'%")';}
          if($zsub!=''){$sql_where.=' and enti_zsub like "'.$zsub.'%"';}
          if($tpro!=''){$sql_where.=' and enti_tpro like "'.$tpro.'%"';}

          if($modu=='CXCO')
          {$sql_where.=' and substring(docum,1,2) in('.$docxcob.')';}
          if($modu=='CXPA')
          {$sql_where.=' and substring(docum,1,2) in('.$docxpag.')';}
          
          $sql_where.=' and docum!=""';
          $sql_where.=' and (numer*1)>0';
          $sql_where.=' and docum is not null';
          $sql_where.=' and numer is not null';
          $sql_where.=' and status!="O"';
          $sql_where.=' and fecha>="'.$fecha0.'" ';

          $sql_pant='select '.$tabla.'12.*,';
          $sql_pant.='enti,enti_descri,';
//           if(mb_stristr('ssss',$repo))
          {
            $sql_pant.='sum(case when fecha<"'.$fecha1.'" then total end) as saldoi, ';
            $sql_pant.='sum(case when fecha>="'.$fecha1.'" and fecha<="'.$fecha2.'" then tdebito end) as stdebito, ';
            $sql_pant.='sum(case when fecha>="'.$fecha1.'" and fecha<="'.$fecha2.'" then tcredito end) as stcredito, ';
          }

          $sql_pant.='sum(total) as saldo,';
          $sql_pant.='concepto,detalle,';
          $sql_pant.='1 as cta_detalle ';
          $sql_pant.=' from '.$tabla.'12';
          $sql_pant.=' where '.$sql_where;      

          $sql_tpant=$sql_pant;

 
          if(mb_stristr('ssee',$repo))
          {
//             $sql_pant.=' group by enti';
            if($tabla=='cxcob')
            {
              $sql_pant.=' group by enti_zsub,enti_descri ';
              $sql_pant.=' order by enti_zsub,enti_descri';
            }
            if($tabla=='cxpag')
            {
              $sql_pant.=' group by enti_tpro,enti_descri ';
              $sql_pant.=' order by enti_tpro,enti_descri';
            }
          }

          if(mb_stristr('ssdd',$repo))
          {
//             $sql_pant.=' group by docum,ptoem,numer';
//             $sql_pant.=' order by fecha,docu,ptoe,numero';
            $sql_pant.=' group by fecha,docum,ptoem,numer';
            $sql_pant.=' order by fecha,docum,ptoem,numer,docu,ptoe,numero';
          }

          if(mb_stristr('lldd',$repo))
          {
//             $sql_pant.=' group by docum,ptoem,numer,mdfrom,idnum1 ';
            $sql_pant.=' group by docum,ptoem,numer,cabdet,fecha,mdfrom,idnum1 ';
            $sql_pant.=' order by docum,ptoem,numer,cabdet,fecha';
//             $sql_pant.=' order by docum desc, ptoem,numer,cabdet,fecha';
          }

        }        
        
      }
     
   }
      
      
    $sql_total=sql_total($tabla);
       
//     echo '<msgalert>';   
//        echo '*/*/*/'.$tabla;
//        echo '*/*/*/'.$sql_total;
//     echo '</msgalert>';   
      
   if(mb_stristr('VTAS.CLIE.COMP.PROV.RETC.RETP',$modu))
   {
     if($repo=='fmes')
     {
       $fecha1=date('Y-m-01',strtotime($fecha1));
       $fecha2=date('Y-m-t',strtotime($fecha2));
     }

     if($repo=='fsema')
     {
//       $fecha1 = date('d/M',strtotime(sema_ini($fecha1)));
//       $fecha2 = date('d/M',strtotime(sema_fin($fecha2)));
      $fecha1 = date('Y-m-d',strtotime(sema_ini($fecha1)));
      $fecha2 = date('Y-m-d',strtotime(sema_fin($fecha2)));
     }

     
     if(mb_stristr('VTAS.CLIE',$modu))
     {
       $tpro='';$cair='';$suco='';
     }
      
     if(mb_stristr('COMP.PROV.RETC.RETP',$modu))
     {
       $zsub='';$vndd='';
     }
      
    if(mb_stristr('vtas.clie.carr',$tabla))
    {
      if($ver_cost==1)
      {
         $sql_vtas ='select * from '.$tabla.'1 ';
         $sql_vtas.='where status!="O" ';
         $sql_vtas.=' and fecha>="'.$fecha1.'"';
         $sql_vtas.=' and fecha<="'.$fecha2.'"';
          $res_vtas= mysql_query($sql_vtas,$link_vcrx);
          while($aso_vtas=mysql_fetch_assoc($res_vtas))
          {updt_vtascuni($aso_vtas['docu'],$aso_vtas['idnum1']);}
      }
    }
     
     
     $sql_pant ='select * from '.$tabla.'12 ';
     $sql_pant.='where status!="O" ';
     $sql_pant.=' and fecha>="'.$fecha1.'"';
     $sql_pant.=' and fecha<="'.$fecha2.'"';
     if($docu!='')
     {$sql_pant.=' and docu like "'.$docu.'%" ';}
     if($enti!='')
     {$sql_pant.=' and (enti like "'.$enti.'%" or enti_descri like "%'.$enti.'%") ';}
     if($item!='')
     {$sql_pant.=' and (item like "'.$item.'%" or item_descri like "%'.$item.'%") ';}
     if($zsub!='')
     {$sql_pant.=' and (zsub like "'.$zsub.'%") ';}
     if($vndd!='')
     {$sql_pant.=' and (vndd like "'.$vndd.'%") ';}
     if($tpro!='')
     {$sql_pant.=' and (tpro like "'.$tpro.'%") ';}
     if($cair!='')
     {$sql_pant.=' and (cair = "'.$cair.'") ';}
//      {$sql_pant.=' and (cair like "'.$cair.'%") ';}
     if($suco!='')
     {$sql_pant.=' and (suco = "'.$suco.'") ';}

      if($repo=='cair' and mb_stristr('RETC.RETP',$modu))
      {$sql_pant.= ' and substring(cair,1,1)in(3,4,5) ';}
     
      if($repo=='iva' and mb_stristr('RETC.RETP',$modu))
      {$sql_pant.= ' and substring(cair,1,1) not in(3,4,5) ';}
     
      $groupby = ' group by '.$repo;
      $orderby = ' order by '.$repo;

      if(mb_stristr('cair.porc',$repo) and mb_stristr('RETC.RETP',$modu))
      {
        $groupby = 'group by cair,puni ';
        $orderby = 'order by cair,puni ';
      }

      if($repo=='iva' and mb_stristr('RETC.RETP',$modu))
      {
        $groupby = 'group by puni ';
        $orderby = 'order by puni ';
      }


      if($repo=='enti')
      {
        $groupby = 'group by substr(enti,1,10) ';
        $orderby = 'order by zsub,enti_descri ';
      }

      if($repo=='rise')
      {
        $groupby = 'group by enti_rise,docu ';
        $orderby = 'order by enti_rise desc,docu ';
      }

      if($repo=='item')
      {
//         $groupby = 'group by item ';
        $groupby = 'group by item_lsub,item_descri ';
        $orderby = 'order by item_lsub,item_descri ';
      }

      if($repo=='lsub')
      {
        $groupby = 'group by item_lsub ';
        $orderby = 'order by item_lsub ';
      }

      if($repo=='tpro')
      {
        $groupby = 'group by enti_tpro ';
        $orderby = 'order by enti_tpro ';
      }

      if($repo=='fmes')
      {
//         $groupby = 'group by fanio,fmes ';
        $groupby = 'group by substring(fecha,1,7) ';
//         $orderby = 'order by fanio,fmes ';
        $orderby = 'order by fanio,fmes ';
      }

      if($repo=='fsema')
      {
//         $groupby = 'group by fanio,fsema ';
        $groupby = 'group by date_format(fecha,"%v")';
        $orderby = 'order by fanio,fsema ';
      }

      if($repo=='iddet')
      {
        $groupby = 'group by idnum1,iddet ';
        $orderby = 'order by idnum1,iddet ';
      }

      if(mb_stristr('ptoe.ptov',$repo))
      { 
        $groupby = 'group by ptoe ';
        $orderby = 'order by ptoe ';
      }

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

      $sql_pant.=$groupby;
      $sql_pant.=$orderby.',idnum1,iddet ';
   }      
      
   if($modu=='NOMI')
   {
      $fecha2b=date('Y-m-t',strtotime($fecha1));
      gen_nov1($fecha1,$fecha2b,$enti); 
      
     $sql_pant ='select * from '.$tabla.'12 ';
     $sql_pant.='where status!="O" ';
     $sql_pant.=' and fecha>="'.$fecha1.'"';
     $sql_pant.=' and fecha<="'.$fecha2.'"';
     if($docu!='')
     {$sql_pant.=' and docu like "'.$docu.'%" ';}
     if($enti!='')
     {$sql_pant.=' and (enti2 like "'.$enti.'%" or enti_descri like "%'.$enti.'%") ';}
     if($csub!='')
     {$sql_pant.=' and (csub like "'.$csub.'%") ';}
     
      $groupby = ' group by '.$repo;
      $orderby = ' order by '.$repo;


      if($repo=='enti')
      {
        $groupby = 'group by substr(enti2,1,10) ';
        $orderby = 'order by csub,enti_descri ';
      }


      if($repo=='nvdd')
      {
        $groupby = 'group by nvdd ';
        $orderby = 'order by nvdd ';
      }

      if($repo=='fmes')
      {
        $groupby = 'group by substring(fecha,1,7) ';
        $orderby = 'order by fanio,fmes ';
      }

      if($repo=='fsema')
      {
        $groupby = 'group by date_format(fecha,"%v")';
        $orderby = 'order by fanio,fsema ';
      }

      if($repo=='iddet')
      {
        $groupby = 'group by idnum1,iddet ';
        $orderby = 'order by idnum1,iddet ';
      }

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

      $sql_pant.=$groupby;
      $sql_pant.=$orderby.',idnum1,iddet ';
      
      
      
      
   }

   if(mb_stristr('sria',$repo))
   {
     $fecha1=date('Y-m-01',strtotime($fecha1));
     $fecha2=date('Y-m-t',strtotime($fecha2));
     
     $sql_pant='';
     
     $sql_pant.='select ';
     $sql_pant.='docu,fanio,fmes,fecha,enti,';

     $sql_pant.='sum(case when tabla="vtas" then tsubt end) as vtastsubt, ';
     $sql_pant.='sum(case when tabla="vtas" then tsubtiva0 end) as vtastsubtiva0, ';
     $sql_pant.='sum(case when tabla="vtas" then tsubtiva end) as vtastsubtiva, ';
     $sql_pant.='sum(case when tabla="vtas" then tiva end) as vtastiva, ';
     $sql_pant.='sum(case when tabla="vtas" then total end) as vtastotal, ';
     $sql_pant.='count(distinct case when tabla="vtas" then idnum1 end) as vtascid,';
     $sql_pant.='count(distinct case when tabla="vtas" and status!="O" then enti end) as vtascenti,';
     
     $sql_pant.='count(distinct case when tabla="vta0" then idnum1 end) as vta0cid,';
     $sql_pant.='count(distinct case when tabla="vta0" then enti end) as vta0centi,';
     
     $sql_pant.='sum(case when tabla="comp" then tsubt end) as comptsubt, ';
     $sql_pant.='sum(case when tabla="comp" then tsubtiva0 end) as comptsubtiva0, ';
     $sql_pant.='sum(case when tabla="comp" then tsubtiva end) as comptsubtiva, ';
     $sql_pant.='sum(case when tabla="comp" then tiva end) as comptiva, ';
     $sql_pant.='sum(case when tabla="comp" then total end) as comptotal, ';
     $sql_pant.='count(distinct case when tabla="comp" then idnum1 end) as compcid,';
     
     $sql_pant.='sum(case when tabla="retc" then tsubt end) as retcvalbase, ';
     $sql_pant.='sum(case when tabla="retc" then tsubtiva0 end) as retcbrta, ';
     $sql_pant.='sum(case when tabla="retc" then tsubtiva end) as retcrrta, ';
     $sql_pant.='count(distinct case when tabla="retc" and substring(cair,1,1)in(3,4,5)then idnum1 end) as retccidr,';
     $sql_pant.='sum(case when tabla="retc" then tiva end) as retcbiva, ';
     $sql_pant.='sum(case when tabla="retc" then total end) as retcriva, ';
     $sql_pant.='count(distinct case when tabla="retc" and substring(cair,1,1)not in(3,4,5)then idnum1 end) as retccidi,';
     
     $sql_pant.='count(distinct case when tabla="retp" then idnum1 end) as retpcid,';
     $sql_pant.='sum(case when tabla="retp" then tsubt end) as retpvalbase, ';
     $sql_pant.='sum(case when tabla="retp" then tsubtiva0 end) as retpbrta, ';
     $sql_pant.='sum(case when tabla="retp" then tsubtiva end) as retprrta, ';
     $sql_pant.='count(distinct case when tabla="retp" and substring(cair,1,1)in(3,4,5)then idnum1 end) as retpcidr,';
     $sql_pant.='sum(case when tabla="retp" then tiva end) as retpbiva, ';
     $sql_pant.='sum(case when tabla="retp" then total end) as retpriva, ';
     $sql_pant.='count(distinct case when tabla="retp" and substring(cair,1,1)not in(3,4,5)then idnum1 end) as retpcidi,';

     $sql_pant.=' sum(case when tabla="vtas" then (tsubtiva0+tsubtiva) ';
     $sql_pant.='else case when tabla="comp" then (tsubtiva0+tsubtiva)*(-1) ';
     $sql_pant.='else 0 end end ) ';
     $sql_pant.='as stotal, ';
     
     $sql_pant.=' sum(case when tabla="vtas" then tiva ';
     $sql_pant.='else case when tabla="retc" then total*(-1) ';
     $sql_pant.='else case when tabla="comp" then tiva*(-1) ';
     $sql_pant.='else case when tabla="retp" then total ';
     $sql_pant.='else 0 end end end end) ';
     $sql_pant.='as stotaliva, ';
     

     $sql_pant.='status ';

     $sql_pant.=' from(';
     
     $sql_pant.='select ';
     $sql_pant.='"vtas" as tabla,';
     $sql_pant.='docu,fanio,fmes,fecha,enti,iva,';
     $sql_pant.='tsubt,tsubtiva0,tsubtiva,tiva,total,cair,';
     $sql_pant.='idnum1,iddet,status ';
     $sql_pant.='from vtas12 ';
     $sql_pant.='where status!="O" ';
     $sql_pant.=' and fecha>="'.$fecha1.'"';
     $sql_pant.=' and fecha<="'.$fecha2.'"';
     
     $sql_pant.=' union ';
     $sql_pant.='select ';
     $sql_pant.='"vta0" as tabla,';
     $sql_pant.='docu,fanio,fmes,fecha,enti,iva,';
     $sql_pant.='tsubt,tsubtiva0,tsubtiva,tiva,total,cair,';
     $sql_pant.='idnum1,iddet,status ';
     $sql_pant.='from vtas12 ';
     $sql_pant.='where status="O" ';
     $sql_pant.=' and fecha>="'.$fecha1.'"';
     $sql_pant.=' and fecha<="'.$fecha2.'"';
     
     $sql_pant.=' union ';
     $sql_pant.='select ';
     $sql_pant.='"comp" as tabla,';
     $sql_pant.='docu,fanio,fmes,fecha,enti,iva,';
     $sql_pant.='tsubt,tsubtiva0,tsubtiva,tiva,total,cair,';
     $sql_pant.='idnum1,iddet,status ';
     $sql_pant.='from comp12 ';
     $sql_pant.='where status!="O" ';
     $sql_pant.=' and fecha>="'.$fecha1.'"';
     $sql_pant.=' and fecha<="'.$fecha2.'"';
     $sql_pant.=' and docu_tico!=""';
     $sql_pant.=' and docu_tico is not null';
//      $sql_pant.=' and docu not like "FP90"';
     
     $sql_pant.=' union ';
     $sql_pant.='select ';
     $sql_pant.='"retc" as tabla,';
     $sql_pant.='docu,fanio,fmes,fecha,enti,puni,';
     $sql_pant.='valbase,brta,rrta,biva,riva,cair,';
     $sql_pant.='idnum1,iddet,status ';
     $sql_pant.='from retc12 ';
     $sql_pant.='where status!="O" ';
     $sql_pant.=' and fecha>="'.$fecha1.'"';
     $sql_pant.=' and fecha<="'.$fecha2.'"';
     
     $sql_pant.=' union ';
     $sql_pant.='select ';
     $sql_pant.='"retp" as tabla,';
     $sql_pant.='docu,fanio,fmes,fecha,enti,puni,';
     $sql_pant.='valbase,brta,rrta,biva,riva,cair,';
     $sql_pant.='idnum1,iddet,status ';
     $sql_pant.='from retp12 ';
     $sql_pant.='where status!="O" ';
     $sql_pant.=' and fecha>="'.$fecha1.'"';
     $sql_pant.=' and fecha<="'.$fecha2.'"';
     
     $sql_pant.=' ) as vcr ';
     
     $sql_pant.='where 1=1 ';

     $sql_tpant=$sql_pant;
     $sql_pant.= 'group by substring(fecha,1,7) ';
     $sql_pant.=' order by fanio,fmes,idnum1,iddet ';
     
     
     
   }
      
   if(mb_stristr('sri4',$repo))
   {
     $fecha1=date('Y-m-01',strtotime($fecha1));
     $fecha2=date('Y-m-t',strtotime($fecha2));
     
     $sql_pant='';
     
     $sql_pant.='select ';
     $sql_pant.='docu,fanio,fmes,fecha,enti,';

     $sql_pant.='sum(case when tabla="vtas" then tsubt end) as vtastsubt, ';
     $sql_pant.='sum(case when tabla="vtas" then tsubtiva0 end) as vtastsubtiva0, ';
     $sql_pant.='sum(case when tabla="vtas" then tsubtiva end) as vtastsubtiva, ';
     $sql_pant.='sum(case when tabla="vtas" then tiva end) as vtastiva, ';
     $sql_pant.='sum(case when tabla="vtas" then total end) as vtastotal, ';
     $sql_pant.='count(distinct case when tabla="vtas" then idnum1 end) as vtascid,';
     $sql_pant.='count(distinct case when tabla="vtas" and status!="O" then enti end) as vtascenti,';
     
     $sql_pant.='count(distinct case when tabla="vta0" then idnum1 end) as vta0cid,';
     $sql_pant.='count(distinct case when tabla="vta0" then enti end) as vta0centi,';
     
     $sql_pant.='sum(case when tabla="comp" then tsubt end) as comptsubt, ';
     $sql_pant.='sum(case when tabla="comp" then tsubtiva0 end) as comptsubtiva0, ';
     $sql_pant.='sum(case when tabla="comp" then tsubtiva end) as comptsubtiva, ';
     $sql_pant.='sum(case when tabla="comp" then tiva end) as comptiva, ';
     $sql_pant.='sum(case when tabla="comp" then total end) as comptotal, ';
     $sql_pant.='count(distinct case when tabla="comp" then idnum1 end) as compcid,';
     
     $sql_pant.='sum(case when tabla="retc" then tsubt end) as retcvalbase, ';
     $sql_pant.='sum(case when tabla="retc" then tsubtiva0 end) as retcbrta, ';
     $sql_pant.='sum(case when tabla="retc" then tsubtiva end) as retcrrta, ';
     $sql_pant.='count(distinct case when tabla="retc" and substring(cair,1,1)in(3,4,5)then idnum1 end) as retccidr,';
     $sql_pant.='sum(case when tabla="retc" then tiva end) as retcbiva, ';
     $sql_pant.='sum(case when tabla="retc" then total end) as retcriva, ';
     $sql_pant.='count(distinct case when tabla="retc" and substring(cair,1,1)not in(3,4,5)then idnum1 end) as retccidi,';
     
     $sql_pant.='count(distinct case when tabla="retp" then idnum1 end) as retpcid,';
     $sql_pant.='sum(case when tabla="retp" then tsubt end) as retpvalbase, ';
     $sql_pant.='sum(case when tabla="retp" then tsubtiva0 end) as retpbrta, ';
     $sql_pant.='sum(case when tabla="retp" then tsubtiva end) as retprrta, ';
     $sql_pant.='count(distinct case when tabla="retp" and substring(cair,1,1)in(3,4,5)then idnum1 end) as retpcidr,';
     $sql_pant.='sum(case when tabla="retp" then tiva end) as retpbiva, ';
     $sql_pant.='sum(case when tabla="retp" then total end) as retpriva, ';
     $sql_pant.='count(distinct case when tabla="retp" and substring(cair,1,1)not in(3,4,5)then idnum1 end) as retpcidi,';

     $sql_pant.=' sum(case when tabla="vtas" then (tsubtiva0+tsubtiva) ';
     $sql_pant.='else case when tabla="comp" then (tsubtiva0+tsubtiva)*(-1) ';
     $sql_pant.='else 0 end end ) ';
     $sql_pant.='as stotal, ';
     
     $sql_pant.=' sum(case when tabla="vtas" then tiva ';
     $sql_pant.='else case when tabla="retc" then total*(-1) ';
     $sql_pant.='else case when tabla="comp" then tiva*(-1) ';
     $sql_pant.='else case when tabla="retp" then total ';
     $sql_pant.='else 0 end end end end) ';
     $sql_pant.='as stotaliva, ';
     

     $sql_pant.='status ';

     $sql_pant.=' from(';
     
     $sql_pant.='select ';
     $sql_pant.='"vtas" as tabla,';
     $sql_pant.='docu,fanio,fmes,fecha,enti,iva,';
     $sql_pant.='tsubt,tsubtiva0,tsubtiva,tiva,total,cair,';
     $sql_pant.='idnum1,iddet,status ';
     $sql_pant.='from vtas12 ';
     $sql_pant.='where status!="O" ';
     $sql_pant.=' and fecha>="'.$fecha1.'"';
     $sql_pant.=' and fecha<="'.$fecha2.'"';
     
     $sql_pant.=' union ';
     $sql_pant.='select ';
     $sql_pant.='"vta0" as tabla,';
     $sql_pant.='docu,fanio,fmes,fecha,enti,iva,';
     $sql_pant.='tsubt,tsubtiva0,tsubtiva,tiva,total,cair,';
     $sql_pant.='idnum1,iddet,status ';
     $sql_pant.='from vtas12 ';
     $sql_pant.='where status="O" ';
     $sql_pant.=' and fecha>="'.$fecha1.'"';
     $sql_pant.=' and fecha<="'.$fecha2.'"';
     
     $sql_pant.=' union ';
     $sql_pant.='select ';
     $sql_pant.='"comp" as tabla,';
     $sql_pant.='docu,fanio,fmes,fecha,enti,iva,';
     $sql_pant.='tsubt,tsubtiva0,tsubtiva,tiva,total,cair,';
     $sql_pant.='idnum1,iddet,status ';
     $sql_pant.='from comp12 ';
     $sql_pant.='where status!="O" ';
     $sql_pant.=' and fecha>="'.$fecha1.'"';
     $sql_pant.=' and fecha<="'.$fecha2.'"';
     $sql_pant.=' and docu_tico!=""';
     $sql_pant.=' and docu_tico is not null';
//      $sql_pant.=' and docu not like "FP90"';
     
     $sql_pant.=' union ';
     $sql_pant.='select ';
     $sql_pant.='"retc" as tabla,';
     $sql_pant.='docu,fanio,fmes,fecha,enti,puni,';
     $sql_pant.='valbase,brta,rrta,biva,riva,cair,';
     $sql_pant.='idnum1,iddet,status ';
     $sql_pant.='from retc12 ';
     $sql_pant.='where status!="O" ';
     $sql_pant.=' and fecha>="'.$fecha1.'"';
     $sql_pant.=' and fecha<="'.$fecha2.'"';
     
     $sql_pant.=' union ';
     $sql_pant.='select ';
     $sql_pant.='"retp" as tabla,';
     $sql_pant.='docu,fanio,fmes,fecha,enti,puni,';
     $sql_pant.='valbase,brta,rrta,biva,riva,cair,';
     $sql_pant.='idnum1,iddet,status ';
     $sql_pant.='from retp12 ';
     $sql_pant.='where status!="O" ';
     $sql_pant.=' and fecha>="'.$fecha1.'"';
     $sql_pant.=' and fecha<="'.$fecha2.'"';
     
     $sql_pant.=' ) as vcr ';
     
     $sql_pant.='where 1=1 ';

     $sql_tpant=$sql_pant;
     $sql_pant.= 'group by substring(fecha,1,7) ';
     $sql_pant.=' order by fanio,fmes,idnum1,iddet ';
     
     
     
   }
      
    if($user_cons==0)
    {$sql_pant='';$sql_tpant='';}
      
//     echo '/*/*/*'.$sql_pant; die();
 
      
    $res_pant=mysql_query($sql_pant,$link_vcrx);
		$res_tpant=mysql_query($sql_tpant,$link_vcrx);
      
      
    if(mb_stristr('ssff.rrii.sfcc.ricc',$repo))
    {$res_tpant1=mysql_query($sql_tpant1,$link_vcrx);}

		$docuok=@mysql_result($res_tpant,0,'docuok');
		$mconcepto=@mysql_result($res_tpant,0,'mconcepto');
		$mdetalle=@mysql_result($res_tpant,0,'mdetalle');
		$tcant=@mysql_result($res_tpant,0,'stcant');
		$tsubt=@mysql_result($res_tpant,0,'stsubt');
// 		$mimpor=@mysql_result($res_tpant,0,'mimpor');
		$lconcepto=@mysql_result($res_tpant,0,'lconcepto');

		if($modu=='CONT')
		{
			$mcsub=@mysql_result($res_tpant,0,'mcsub');
			$mcair=@mysql_result($res_tpant,0,'mcair');
			$mitem=@mysql_result($res_tpant,0,'mitem');
			$tsaldoi=@mysql_result($res_tpant,0,'saldoi');
			$tsaldo=@mysql_result($res_tpant,0,'saldo');
			$tdebito=@mysql_result($res_tpant,0,'stdebito');
			$tcredito=@mysql_result($res_tpant,0,'stcredito');
			$tdiferencia=@mysql_result($res_tpant,0,'sdiferencia');
      if(mb_stristr('rrii.ricc',$repo))
      {$tsaldo=$tsaldo*(-1);}  
		}			

		if($modu=='INVE')
		{
			$mcsub=@mysql_result($res_tpant,0,'mcsub');
			$mcair=@mysql_result($res_tpant,0,'mcair');
			$mitem=@mysql_result($res_tpant,0,'mitem');
      
			$tsaldoiu=@mysql_result($res_tpant,0,'saldoiu');
			$tsaldou=@mysql_result($res_tpant,0,'saldou');
			$tingreso=@mysql_result($res_tpant,0,'stingreso');
			$tegreso=@mysql_result($res_tpant,0,'stegreso');
      
      if($ver_rota==1)
      {
        $indirota=indi_rota('',$fecha2);
        $indirotat[3]=$indirotat[3]+$indirota[3];
        $indirotat[4]=$indirotat[4]+$indirota[4];
      }

			$tsaldoi=@mysql_result($res_tpant,0,'saldoi');
			$tsaldo=@mysql_result($res_tpant,0,'saldo');
			$tdebito=@mysql_result($res_tpant,0,'stdebito');
			$tcredito=@mysql_result($res_tpant,0,'stcredito');

      $tpvta=@mysql_result($res_tpant,0,'stpvta');
      $tutil=@mysql_result($res_tpant,0,'stutil');
      
			$tdiferencia=@mysql_result($res_tpant,0,'sdiferencia');
      if(mb_stristr('rrii.ricc',$repo))
      {$tsaldo=$tsaldo*(-1);}  
		}			
 
		if($modu=='CXCO' or $modu=='CXPA')
		{
			$tsaldoi=@mysql_result($res_tpant,0,'saldoi');
			$tsaldo=@mysql_result($res_tpant,0,'saldo');
			$tdebito=@mysql_result($res_tpant,0,'stdebito');
			$tcredito=@mysql_result($res_tpant,0,'stcredito');
		}			

		if(@mb_stristr('inve.prod',$tabla))
		{
			$mserie=@mysql_result($res_tpant,0,'mserie');
			$mlote=@mysql_result($res_tpant,0,'mlote');
		}			

      
//     if($docuiimp==1)
    if(mb_stristr('VTAS.CLIE.COMP.PROV.CARR',$modu))
    {
      $tsubtiva0=mysql_result($res_tpant,0,'stsubtiva0');
      $tsubtiva=mysql_result($res_tpant,0,'stsubtiva');
      $tcuni=mysql_result($res_tpant,0,'stcuni');
      $acuni=mysql_result($res_tpant,0,'acuni');
      $apuni=mysql_result($res_tpant,0,'apuni');
      $tutil=mysql_result($res_tpant,0,'stutil');
      $tdcto=mysql_result($res_tpant,0,'stdcto');
      $tssid=mysql_result($res_tpant,0,'stssid');
      $tprop=mysql_result($res_tpant,0,'stprop');
      $tice=mysql_result($res_tpant,0,'stice');
      $tiva=mysql_result($res_tpant,0,'stiva');
      $tirbp=mysql_result($res_tpant,0,'stirbp');
    }
      

    if(mb_stristr('INVE.PROD',$modu))
    {
      $tutil=mysql_result($res_tpant,0,'stutil');
      $putil=0;
      if($tutil>0)
      {$putil=$tutil/$tpvta*100;}
    }
      

      
    if(mb_stristr('RETC.RETP',$modu))
    {
			$mcair=@mysql_result($res_tpant,0,'mcair');
			$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');
      $tsubt=0;
      $mconcepto='';
      $mdetalle='';
    }

       
       
    if(mb_stristr('NOMI',$modu))
    {
       $tingreso=mysql_result($res_tpant,0,'stingreso');
       $tegreso=mysql_result($res_tpant,0,'stegreso');
       $tprovis=mysql_result($res_tpant,0,'stprovis');
       $tpercibir=mysql_result($res_tpant,0,'stpercibir');
       $tneto=mysql_result($res_tpant,0,'stneto');
    }
       
       
    if(mb_stristr('sria.sri4',$repo))
    {
			$svtastsubt=@mysql_result($res_tpant,0,'vtastsubt');
			$svtastsubtiva0=@mysql_result($res_tpant,0,'vtastsubtiva0');
			$svtastsubtiva=@mysql_result($res_tpant,0,'vtastsubtiva');
			$svtastiva=@mysql_result($res_tpant,0,'vtastiva');

			$sretcbrta=@mysql_result($res_tpant,0,'retcbrta');
			$sretcrrta=@mysql_result($res_tpant,0,'retcrrta');
			$sretcbiva=@mysql_result($res_tpant,0,'retcbiva');
			$sretcriva=@mysql_result($res_tpant,0,'retcriva');

      $scomptsubt=@mysql_result($res_tpant,0,'comptsubt');
			$scomptsubtiva0=@mysql_result($res_tpant,0,'comptsubtiva0');
			$scomptsubtiva=@mysql_result($res_tpant,0,'comptsubtiva');
			$scomptiva=@mysql_result($res_tpant,0,'comptiva');

      $sretpbrta=@mysql_result($res_tpant,0,'retpbrta');
			$sretprrta=@mysql_result($res_tpant,0,'retprrta');
			$sretpbiva=@mysql_result($res_tpant,0,'retpbiva');
			$sretpriva=@mysql_result($res_tpant,0,'retpriva');

      $total=@mysql_result($res_tpant,0,'totiva');

      
			$svtascenti=@mysql_result($res_tpant,0,'vtascenti');
			$svtascid=@mysql_result($res_tpant,0,'vtascid');
			$scompcid=@mysql_result($res_tpant,0,'compcid');
			$sretccidr=@mysql_result($res_tpant,0,'retccidr');
			$sretccidi=@mysql_result($res_tpant,0,'retccidi');
			$sretpcidr=@mysql_result($res_tpant,0,'retpcidr');
			$sretpcidi=@mysql_result($res_tpant,0,'retpcidi');
      
			$porciva=@mysql_result($res_tpant,0,'piva');
      
      
      $tsubt=0;
      $mconcepto='';
      $mdetalle='';
    }
      
      
		$total=@mysql_result($res_tpant,0,'stotal');
		$totaliva=@mysql_result($res_tpant,0,'stotaliva');
		$tdocu=@mysql_num_rows($res_pant);
		$tcidnum1=@mysql_result($res_tpant,0,'cidnum1');
// 		$tcenti=@mysql_result($res_tpant,0,'centi');
    $tporpar=0;
      
    if(@mb_stristr('guia',$tabla))
    {
      $tsubt=0;
    }
      
    if(@mb_stristr('atvd.plan',$tabla))
    {
      $tsubt=0;
      $total=0;
    }
      
    if($docux=='IEBX')
    {
      $ver_doco=0;
      $tsubt=0;
      $total=0;
    }

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

			$trrta=0;
			$triva=0;
		}

	
	}	
    
?>

	
	<?php $crow=0; ?>
	<?php $clin=0; ?>
	<?php $cidnum=0; ?>
	<?php $ccol=0; ?>
	<?php $tnumero=0; ?>
	<?php //echo '***'.date('H:i:s') .'<br>';?>
  
  
<pant1>
    
<?php if(mb_stristr('PANT3.IMPR3',$pant)){$mconcepto.=$mdetalle;} ?> 
    
<?php if(mb_stristr('IMPR1.IMPR2',$pant)){ ?>
<?php $xfontsize=$xfontsize*(1.2); ?>  
<?php $xfontfamily='font-family:arial;';  ?>
<?php
  $pageorient='portrait';                   
  if($modu=='VTAS' and $ver_cost==1)
  {
    $pageorient='landscape';
    $xfontsize=$xfontsize/(1.12)*(0.9);
  }
  if($modu=='INVE' and mb_stristr('ssss.',$repo) and $ver_cost==1)
  {
    $pageorient='landscape';
    $xfontsize=$xfontsize/(1.12)*(0.9);
  }
  if($modu=='CONT' and mb_stristr('sscc.sfcc.ricc',$repo))
  {
    $pageorient='landscape';
    $xfontsize=$xfontsize/(1.12)*(0.9);
  }                                       
  if($modu=='SRI1' and mb_stristr('sria.sri4',$repo))
  {
    $pageorient='landscape';
    $xfontsize=$xfontsize/(1.12)*(0.9);
  }
                                       
?>    
<!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><?php echo strtoupper($cfg_empr).' -  '.r_fiel('docu',$docu); ?></title>
<style type="text/css">
p.saltodepagina{page-break-after: always;}
#header{display:none;}
@font-face{font-family:'Barcode'; src:url('/_font/BarcodeFont.ttf') format('truetype');}
barcode{font-family:'Barcode';}
@media print {.noprint {display:none}}
@media screen{.noscreen {display:none}}
	
  /* 	top right bottom left */
@page
{
  size: A4 <?php echo $pageorient; ?>;
  margin: 10mm 5mm 10mm 5mm;
}
</style>
</head>
<body>
<div style="font-size:<?php echo $xfontsize; ?>;<?php echo $xfontfamily;?> width:; ">
<?php } ?>
  
<?php if(mb_stristr('IMPR1',$pant)){ ?>
  
<?php 
  $repodes='INFORME';
  if($modu=='CONT')
  {
    if($repo=='ssss'){$repodes='SUMAS Y SALDOS';}
    if($repo=='ssnn'){$repodes='SUMAS Y SALDOS (X NIVEL)';}
    if($repo=='sscc'){$repodes='SALDOS (COMPARATIVO)';}
    if($repo=='ssff'){$repodes='SITUACION FINANCIERA';}
    if($repo=='sfcc'){$repodes='SITUACION FINANCIERA (COMPARATIVO)';}
    if($repo=='rrii'){$repodes='RESULTADO INTEGRAL';}
    if($repo=='ricc'){$repodes='RESULTADO INTEGRAL (COMPARATIVO)';}
    if($repo=='lldd'){$repodes='LIBRO DIARIO';}
  }

  if($modu=='INVE')
  {
    if($repo=='ssss'){$repodes='SALDOS DE INVENTARIO';}
    if($repo=='ssbb'){$repodes='SALDOS X BODEGA';}
    if($repo=='evta'){$repodes='EGRESOS X VENTA';}
  }
      
  if($modu=='CXCO')
  {
    if($repo=='ssee'){$repodes='CTAS.X COBRAR (CLIENTE)';}
    if($repo=='ssdd'){$repodes='CTAS.X COBRAR (DOCUMENTO)';}
    if($repo=='lldd'){$repodes='CTAS.X COBRAR (DETALLE) ';}
  }

  if($modu=='CXPA')
  {
    if($repo=='ssee'){$repodes='CTAS.X PAGAR (CLIENTE)';}
    if($repo=='ssdd'){$repodes='CTAS.X PAGAR (DOCUMENTO)';}
    if($repo=='lldd'){$repodes='CTAS.X PAGAR (DETALLE) ';}
  }

  $modudescri=r_fiel('modu',$modu);
  if(mb_stristr('VTAS.CLIE.COMP.PROV',$modu))
  {
    if($repo=='enti'){$repodes=$modudescri.' X CLIENTE';}
    if($repo=='rise'){$repodes=$modudescri.' X RISE';}
    if($repo=='item'){$repodes=$modudescri.' X PROD./SERV.';}
    if($repo=='vndd'){$repodes=$modudescri.' X VENDEDOR ';}
    if($repo=='tpro'){$repodes=$modudescri.' X TIPO PROV. ';}
    if($repo=='zsub'){$repodes=$modudescri.' X ZONAS ';}
    if($repo=='ptoe'){$repodes=$modudescri.' X PTO.EMISION ';}
    if($repo=='ptov'){$repodes=$modudescri.' X PTO.EMISION ';}
    if($repo=='lsub'){$repodes=$modudescri.' X LINEAS ';}
    if($repo=='fmes'){$repodes=$modudescri.' X MES ';}
    if($repo=='fsema'){$repodes=$modudescri.' X SEMANA ';}
    if($repo=='fecha'){$repodes=$modudescri.' X DIA ';}
    if($repo=='docu'){$repodes=$modudescri.' X DOCUMENTO ';}
    if($repo=='idnum1'){$repodes=$modudescri.' X TRANSACCION ';}
    if($repo=='iddet'){$repodes=$modudescri.' (DETALLE) ';}
    if($repo=='cair'){$repodes=$modudescri.' X CODIGO IMP.RTA. ';}
    if($repo=='suco'){$repodes=$modudescri.' X CODIGO SUST.COMP. ';}
  }
      
  if(mb_stristr('NOMI',$modu))
  {
    if($repo=='enti'){$repodes='NOMINA X EMPLEADOS ';}
    if($repo=='nvdd'){$repodes='NOMINA X NOVEDADES ';}
  }
      
  if(mb_stristr('RETC.RETP',$modu))
  {
    if($repo=='cair'){$repodes='RETENCIONES DE RENTA ';}
    if($repo=='iva'){$repodes='RETENCIONES DE IVA ';}
    if($repo=='porc'){$repodes='RETENCIONES TOTALES ';}
  }
      
  if(mb_stristr('SRI1',$modu))
  {
    if($repo=='sria'){$repodes='ANEXO TRANSACCIONAL SIMPLIFICADO';}
    if($repo=='sri4'){$repodes='FORMULARIO 104';}
  }
      
?>
  
<table id="titulos" class="pant1" border="0"
       align="center" cellpadding="3" width="100%"
       style="font-size:<?php {echo $xfontsize;} ?>px;
        border-collapse:collapse;background-color:snow; position:;"
        >
<tr style="background-color:<?php echo $gris1; ?>; border-top:solid 2px; border-bottom:solid 2px; font-weight:bold">
  <td width="20%"  style="font-size:<?php {echo $xfontsize*1.3;} ?>px;">
    <?php echo $repodes;  ?>
  </td>
  <td width="60%" align="center" style="font-size:<?php {echo $xfontsize*1.3;} ?>px;">
    <?php echo r_fiel('enti',$cfg_ruc).'<br> RUC : '.$cfg_ruc; ?>
  </td>
  <td width="20%" align="right" style="font-size:<?php {echo $xfontsize*.7;} ?>px;">
    <?php echo 'USUARIO : '.$user_codigo.' - '.r_fiel('user',$user_codigo); ?>
    <br>
    <?php echo 'FECHA : '.date('D d/M/y'); ?> 
    <br>
    <?php echo 'HORA : '.date('H:i:s'); ?> 
  </td>
</tr>
</table>  

  
<table id="filtros" class="pant1" border="0"
       align="center" cellpadding="3" width="100%"
       style="font-size:<?php {echo $xfontsize*.75;} ?>px;
        border-collapse:collapse;background-color:snow; position:;"
        >
<tr>
  <td width="50%" valign="top">
    <table id="" class="" border="1"
       align="center" cellpadding="3" width="100%"
       style="font-size:<?php {echo $xfontsize;} ?>px;
        border-collapse:collapse;background-color:snow; position:;">
      <tr style="background-color:<?php echo $gris1; ?>;">
        <td align="center" colspan="2" style="font-weight:bold;">FILTROS</td>
      </tr>  
      <tr>
        <td style="font-weight:bold;">FECHAS</td>
        <?php if(mb_stristr('CONT',$modu)){?>
          <?php if(mb_stristr('ssff',$repo)){?>
          <td><?php echo date('d/M/y',strtotime($fecha2)); ?></td>
          <?php }else{ ?>
          <?php //if(mb_stristr('ssss.ssnn.rrii',$repo)){?>
          <td><?php echo date('d/M/y',strtotime($fecha1)).' - '.date('d/M/y',strtotime($fecha2)); ?></td>
          <?php } ?>
        <?php } ?>
        <?php if(mb_stristr('CXCO.CXPA',$modu)){?>
          <?php if(mb_stristr('ssee.ssdd.lldd',$repo)){?>
          <td><?php echo date('d/M/y',strtotime($fecha1)).' - '.date('d/M/y',strtotime($fecha2)); ?></td>
          <?php }else{ ?>
          <td><?php echo date('d/M/y',strtotime($fecha2)); ?></td>
          <?php } ?>
        <?php } ?>
        <?php if(mb_stristr('VTAS.COMP.INVE.CLIE.PROV.NOMI.RETC.RETP.SRI1',$modu)){?>
        <td><?php echo date('d/M/y',strtotime($fecha1)).' - '.date('d/M/y',strtotime($fecha2)); ?></td>
        <?php } ?>
      </tr>  
      <tr style="display:none;">
        <td width="20%"  style="font-weight:bold;">DOCUMENTO</td>
        <td style="font-weight:bold;"><?php echo $docu.' - '.r_fiel('docu',$docu); ?></td>
      </tr>  
      <?php if(mb_stristr('comp.retp.retc',$tabla)){ ?>
      <tr>
        <td style="font-weight:bold;">PTO.EMISION</td>
        <td><?php if($ptoe==''){echo 'TODOS';}else{echo r_fiel('ptoe',$ptoe);}; ?></td>
      </tr>  
      <?php } ?>
      <?php if(mb_stristr('vtas.clie.carr',$tabla)){ ?>
      <tr>
        <td style="font-weight:bold;">PTO.VENTA</td>
        <td><?php if($ptov==''){echo 'TODOS';}else{echo r_fiel('ptov',$ptov);}; ?></td>
      </tr>  
      <?php } ?>
      <?php if(mb_stristr('caja',$tabla)){ ?>
      <tr>
        <td style="font-weight:bold;">CAJA</td>
        <td><?php if($caja==''){echo 'TODOS';}else{echo r_fiel('caja',$caja);}; ?></td>
      </tr>  
      <?php } ?>
      <?php if(mb_stristr('bcos',$tabla)){ ?>
      <tr>
        <td style="font-weight:bold;">CTA.BANC.</td>
        <td><?php if($ctab==''){echo 'TODOS';}else{echo r_fiel('ctab',$ctab);}; ?></td>
      </tr>  
      <?php } ?>
      <?php if(mb_stristr('INVE',$modu)){ ?>
      <tr>
        <td style="font-weight:bold;">BODEGA</td>
        <td><?php if($bode==''){echo 'TODOS';}else{echo r_fiel('bode',$bode);}; ?></td>
      </tr>  
      <tr>
        <td style="font-weight:bold;">LINEA</td>
        <td><?php if($lsub==''){echo 'TODOS';}else{echo r_fiel('lsub',$lsub);}; ?></td>
      </tr>  
      <tr>
        <td style="font-weight:bold;">ITEM</td>
        <td><?php if($item==''){echo 'TODOS';}else{echo r_fiel('item',$item);}; ?></td>
      </tr>  
      <?php } ?>
      <tr style="display:none;">
        <td style="font-weight:bold;">NUMEROS</td>
        <td><?php echo $numero1.' - '.$numero2; ?></td>
      </tr>  
      <?php if(mb_stristr('vtas.comp.clie.prov.carr.inve.nomi.',$tabla)){ ?>
      <tr>
        <td style="font-weight:bold;"><?php echo $entilabel?></td>
        <td><?php if($enti==''){echo 'TODOS';}else{echo $enti;}; ?></td>
      </tr>  
      <?php } ?>
      
      <?php if(mb_stristr('nomi.',$tabla)){ ?>
      <tr>
        <td style="font-weight:bold;">NOVEDAD</td>
        <td><?php if($nvdd==''){echo 'TODOS';}else{echo $nvdd.' - '.r_fiel('nvdd',$nvdd);}; ?></td>
      </tr>  
      <tr>
        <td style="font-weight:bold;">C.SUB</td>
        <td><?php if($csub==''){echo 'TODOS';}else{echo $csub.' - '.r_fiel('csub',$csub);}; ?></td>
      </tr>  
      <?php } ?>
      
      <?php if(mb_stristr('vtas.comp.clie.prov.carr.inve.',$tabla)){ ?>
      <tr>
        <td style="font-weight:bold;">ITEM</td>
        <td><?php if($item==''){echo 'TODOS';}else{echo $item;}; ?></td>
      </tr>  
      <?php } ?>
      
      <?php if(mb_stristr('CXCO.CXPA',$modu)){ ?>
      <?php $entidescri=''; ?>
      <tr>
        <td style="font-weight:bold;"><?php echo $entilabel?></td>
        <td><?php if($enti==''){echo 'TODOS';}else{$entidescri=r_fiel('enti',$enti); echo $enti.' - '.$entidescri;}; ?></td>
      </tr>  
      <?php if($entidescri!=''){ ?>
            <tr valign="top">
              <td style="font-weight:bold;">MATRIZ</td>
              <td><?php echo r_fiel('enti',$enti,'matriz'); ?></td>
            </tr>  
            <tr valign="top">
              <td style="font-weight:bold;">E-MAIL</td>
              <td><?php echo r_fiel('enti',$enti,'email'); ?></td>
            </tr>  
            <tr valign="top">
              <td style="font-weight:bold;">TELEFONO</td>
              <td><?php echo r_fiel('enti',$enti,'telefono'); ?></td>
            </tr>  
      <?php } ?>
      
      <?php } ?>
      
      <?php if(mb_stristr('CONT.COMP',$modu)){ ?>
      <tr>
        <td style="font-weight:bold;"><?php echo 'CUENTAS'?></td>
        <td><?php if($ctas==''){echo 'TODOS';}else{echo $ctas.' - '.r_fiel('ctas',$ctas);}; ?></td>
      </tr>  
      <?php } ?>
      <?php if(mb_stristr('CONT',$modu) and mb_stristr('lldd',$repo)){ ?>
      <tr>
        <td style="font-weight:bold;"><?php echo 'ENTIDAD'?></td>
        <td><?php if($enti==''){echo 'TODOS';}else{echo $enti.' - '.r_fiel('enti',$enti);}; ?></td>
      </tr>
      <?php } ?>
      <?php if(mb_stristr('CONT',$modu) and !mb_stristr('lldd',$repo)){ ?>
      <tr>
        <td style="font-weight:bold;"><?php echo 'CENTRO'?></td>
        <td><?php if($csub==''){echo 'TODOS';}else{echo $csub.' - '.r_fiel('csub',$csub);}; ?></td>
      </tr>
      <tr>
        <td style="font-weight:bold;"><?php echo 'NIVEL'?></td>
        <td><?php echo $nivel; ?></td>
      </tr>  
      <tr>
        <td style="font-weight:bold;"><?php echo 'INCL.DTR'?></td>
        <td><?php if($ver_dtr1==1){echo 'SI';}else{echo 'NO';}; ?></td>
      </tr>  
      <?php } ?>
      <?php if($cair!=''){ ?>
      <tr>
        <td style="font-weight:bold;">CAIR</td>
        <td><?php echo $cair.' - '.r_fiel('cair0',$cair); ?></td>
      </tr>  
      <?php } ?>
      <?php if($vhcl!=''){ ?>
      <tr>
        <td style="font-weight:bold;">VEHICULO</td>
        <td><?php echo $vhcl.' - '.r_fiel('vhcl',$vhcl); ?></td>
      </tr>  
      <?php } ?>
      <?php if($placa!=''){ ?>
      <tr>
        <td style="font-weight:bold;">PLACA</td>
        <td><?php echo $placa.' - '.r_fiel('vhcl',$placa); ?></td>
      </tr>  
      <?php } ?>
      
      <tr style="display:none;">
        <td style="font-weight:bold;">STATUS</td>
        <td><?php if($stat==''){echo 'TODOS';}else{echo r_fiel('stat',$stat);}; ?></td>
      </tr>  
    </table>
  </td>
  <td width="50%" valign="top">
    <table id="" class="" border="1"
       align="center" cellpadding="3" width="100%"
       style="font-size:<?php {echo $xfontsize;} ?>px;
        border-collapse:collapse;background-color:snow; position:;">
      <tr align="center" style="background-color:<?php echo $gris1; ?>;">
        <td colspan="2" style="font-weight:bold;">RESUMEN</td>
      </tr>  
      <tr align="right" style="display:none;">
        <td style="font-weight:bold;"><?php if($pant=='IMPR1'){echo 'DOCUMENTOS';}else{echo 'REGISTROS';}?></td>
        <td width="20%" style="font-weight:bold;" align="center"><?php echo $tdocu; ?></td>
      </tr> 
      <?php if(mb_stristr('CONT.INVE.CXCO.CXPA',$modu)){ ?>
          <?php if(mb_stristr('lldd',$repo)){ ?>
              <?php if(mb_stristr('CXCO.CXPA',$modu)){ ?>
              <tr align="right">
                <td style="font-weight:bold;">INICIAL</td>
                <td><?php echo number_format(abs($tsaldoi),2); ?></td>
              </tr>
              <?php } ?>
              <tr align="right">
                <td style="font-weight:bold;">DEBITOS</td>
                <td><?php echo number_format(abs($tdebito),2); ?></td>
              </tr>
              <tr align="right">
                <td style="font-weight:bold;">CREDITOS</td>
                <td><?php echo number_format(abs($tcredito),2); ?></td>
              </tr>
              <?php if(mb_stristr('CONT',$modu)){ ?>
              <tr align="right">
                <td style="font-weight:bold;">DIFER.</td>
                <td><?php echo number_format(abs($tsaldo),2); ?></td>
              </tr>
              <?php } ?>
              <?php if(mb_stristr('CXCO.CXPA',$modu)){ ?>
              <tr align="right">
                <td style="font-weight:bold;">SALDO</td>
                <td><?php echo number_format(abs($tsaldo),2); ?></td>
              </tr>
              <?php } ?>
          <?php } ?>
          <?php if(mb_stristr('ssss.ssnn.ssee.ssdd',$repo)){ ?>
              <tr align="right">
                <td style="font-weight:bold;">INICIAL</td>
                <td><?php echo number_format(abs($tsaldoi),2); ?></td>
              </tr>
              <tr align="right">
                <td style="font-weight:bold;">DEBITOS</td>
                <td><?php echo number_format(abs($tdebito),2); ?></td>
              </tr>
              <tr align="right">
                <td style="font-weight:bold;">CREDITOS</td>
                <td><?php echo number_format(abs($tcredito),2); ?></td>
              </tr>
              <tr align="right">
                <td style="font-weight:bold;">SALDO</td>
                <td><?php echo number_format(abs($tsaldo),2); ?></td>
              </tr>
              <?php $total=abs($tdebito)-abs($tcredito);?>
              <?php $tsubt=0;?>
              <?php $ctas_tot=0;?>
              <?php $ctas_123=0;?>
              <?php $ctas_456=0;?>
              <?php $ctas_4=0;?>
          <?php } ?>
          <?php if(mb_stristr('evta',$repo)){ ?>
              
              <tr align="right">
                <td style="font-weight:bold;">CANTIDAD</td>
                <td><?php echo number_format(abs($tsaldou),2); ?></td>
              </tr>
              <tr align="right">
                <td style="font-weight:bold;">COSTO</td>
                <td><?php echo number_format(abs($tsaldo),2); ?></td>
              </tr>
              <tr align="right">
                <td style="font-weight:bold;">VENTA</td>
                <td><?php echo number_format(abs($tpvta),2); ?></td>
              </tr>
              <tr align="right">
                <td style="font-weight:bold;">UTIL.B</td>
                <td><?php echo number_format(abs($tutil),2); ?></td>
              </tr>
              <tr align="right">
                <td style="font-weight:bold;">% RENTA</td>
                <td><?php echo number_format(abs($putil),2).'%'; ?></td>
              </tr>
          <?php } ?>
      
          <?php if(mb_stristr('ssff.rrii.sfcc.ricc',$repo)){ ?>
              <?php while($aso_tpant1=@mysql_fetch_assoc($res_tpant1)){ ?>
                <?php $ctas_codi=$aso_tpant1['ctas_codi']; ?>
                <?php $ctas_desc=$aso_tpant1['descri1']; ?>
                <?php $ctas_sald=$aso_tpant1['saldo']; ?>
                <?php if(mb_stristr('rrii.ricc',$repo)){$ctas_sald=$ctas_sald*(-1);} ?>
                <tr align="right">
                  <td style="font-weight:bold;"><?php echo $ctas_desc?></td>
                  <td><?php echo number_format($ctas_sald,2); ?></td>
                </tr>
                <?php $ctas_tot=$ctas_tot+$ctas_sald;?>
                <?php if(mb_stristr('1.2.3',substr($ctas_codi,0,1))){$ctas_123=$ctas_123+$ctas_sald;}?>
                <?php if(mb_stristr('4.5.6',substr($ctas_codi,0,1))){$ctas_456=$ctas_456+$ctas_sald;}?>
                <?php if(mb_stristr('4.',substr($ctas_codi,0,1))){$ctas_4=$ctas_4+$ctas_sald;}?>
              <?php } ?>
              <?php if($ctas_123!=0){?>
                <tr align="right">
                  <td style="font-weight:bold;"><?php echo 'ACT-(PAS+PAT)';?></td>
                  <td><?php echo number_format($ctas_123,2); ?></td>
                </tr>
              <?php } ?>
              <?php if($ctas_456!=0){?>
                <tr align="right">
                  <td style="font-weight:bold;"><?php if($ctas_456>0){echo 'UTILIDAD';}else{echo 'PERDIDA';}?></td>
                  <td><?php echo number_format($ctas_456,2); ?></td>
                </tr>
                <tr align="right">
                  <td style="font-weight:bold;">% UTIL.</td>
                  <td><?php echo number_format($ctas_456/$ctas_4*100,2).'%'; ?></td>
                </tr>
              <?php } ?>
          <?php } ?>
      <?php } ?>
      <tr align="right" style="display:none;">
        <td style="font-weight:bold;">CANTIDAD</td>
        <td align="right"><?php echo number_format($tcant,2); ?></td>
      </tr>  
			<?php if(@mb_stristr('inve',$tabla) and 1==2){?>
      <tr align="right">
        <td style="font-weight:bold;">SUB-TOT</td>
        <td><?php echo number_format(abs($tsubt),2); ?></td>
      </tr>  
      <?php } ?>
       <?php if($modu=='NOMI'){$tsubt=0;}?>
       
      <?php if($tsubt!=0){ ?>
      <tr align="right">
        <td style="font-weight:bold;">SUB-TOTAL</td>
        <td><?php echo number_format(abs($tsubt),2); ?></td>
      </tr>
      <?php } ?>
       
      <?php if($tabla=='nomi'){ ?> 
         <?php if($tingreso!=0){ ?>
         <tr align="right">
           <td style="font-weight:bold;">PERCEPCION</td>
           <td><?php echo number_format($tingreso,2); ?></td>
         </tr>
         <?php } ?>
         <?php if($tegreso!=0){ ?>
         <tr align="right">
           <td style="font-weight:bold;">DEDUCCION</td>
           <td><?php echo number_format($tegreso,2); ?></td>
         </tr>
         <?php } ?>
         <?php if($tpercibir!=0){ ?>
         <tr align="right">
           <td style="font-weight:bold;">PERCIBIR</td>
           <td><?php echo number_format($tpercibir,2); ?></td>
         </tr>
         <?php } ?>
         <?php if($tprovis!=0){ ?>
         <tr align="right">
           <td style="font-weight:bold;">PROVISION</td>
           <td><?php echo number_format($tprovis,2); ?></td>
         </tr>
         <?php } ?>
       
      <?php } ?>
       
       
      <?php if($tdcto!=0){ ?>
      <tr align="right">
        <td style="font-weight:bold;">DESCUENTOS</td>
        <td><?php echo number_format($tdcto,2); ?></td>
      </tr>
      <?php } ?>
      <?php if($tssid!=0){ ?>
      <tr align="right">
        <td style="font-weight:bold;">SUBSIDIO</td>
        <td><?php echo number_format($tssid,2); ?></td>
      </tr>
      <?php } ?>
      <?php if($tice!=0){ ?>
      <tr align="right">
        <td style="font-weight:bold;">ICE</td>
        <td><?php echo number_format($tice,2); ?></td>
      </tr>
      <?php } ?>
      <?php if($tsubtiva0!=0){ ?>
      <tr align="right">
        <td style="font-weight:bold;">SUB-TOT IVA 0%</td>
        <td><?php echo number_format($tsubtiva0,2); ?></td>
      </tr>
      <?php } ?>
      <?php if($tsubtiva!=0){ ?>
      <tr align="right">
        <td style="font-weight:bold;">SUB-TOT IVA</td>
        <td><?php echo number_format($tsubtiva,2); ?></td>
      </tr>
      <?php } ?>
      <?php if($tiva!=0){ ?>
      <tr align="right">
        <td style="font-weight:bold;">IVA</td>
        <td><?php echo number_format($tiva,2); ?></td>
      </tr>
      <?php } ?>
      <?php if($tbrta!=0){ ?>
      <tr align="right">
        <td style="font-weight:bold;">BASE RENTA</td>
        <td><?php echo number_format($tbrta,2); ?></td>
      </tr>
      <tr align="right">
        <td style="font-weight:bold;">RET. RENTA</td>
        <td><?php echo number_format($trrta,2); ?></td>
      </tr>
      <?php } ?>
      <?php if($tbiva!=0){ ?>
      <tr align="right">
        <td style="font-weight:bold;">BASE IVA</td>
        <td><?php echo number_format($tbiva,2); ?></td>
      </tr>
      <tr align="right">
        <td style="font-weight:bold;">RET. IVA</td>
        <td><?php echo number_format($triva,2); ?></td>
      </tr>
      <?php } ?>
      
      <?php if($total!=0){ ?>
      <tr align="right">
        <td style="font-weight:bold;">TOTAL</td>
        <td><?php echo number_format(abs($total),2); ?></td>
      </tr>
      <?php } ?>
      
      
      <?php if(abs($total)>$xsaldo0 and $modu=='CONT'){ ?>
      <tr align="right">
        <td style="font-weight:bold;"><?php if($tabla=='cont'){echo 'DIFER.';}else{echo 'TOTAL';} ?></td>
        <td style="font-weight:bold; <?php if($tdiferencia!=0){ echo 'color:red;';}?>"><?php echo number_format(abs($total),2); ?></td>
      </tr>
      <?php } ?>
    </table>
  </td>
</tr>  

</table>

<hr>
<?php } ?>  
  
  
<?php
//   explain_sql($sql_pant,1);
?>
          
  
<?php // $dispcolu=0; ?>
<?php $tmaxwidth=''; ?>
<?php $xporcre=100;?>
  
<?php if($modu=='CONT'){ ?>  
		<table id="tpant1" class="pant1" border="0"
					 align="center" cellpadding="3" width="100%"
					 style="font-size:<?php if($orient=='V'){echo $xfontsize-8;}else{echo $xfontsize;} ?>px;
						border-collapse:collapse;background-color:snow; position:; <?php if($pant=='IMPR' and 1==2 ){echo 'max-width:210mm;';}?>"
						>
			<?php { // THEAD ?>
			<thead style="<?php echo $tdisplay; ?><?php if($mobile!='true'){echo 'max-width:'.($screenw-20).'px;';} ?>;background-color:<?php echo $gris1; ?>;">
				<tr style="border-top:solid 1px;border-bottom:solid 1px; cursor:pointer;" >
          <th onclick="sortTable(this,0);" style="display:none;"><?php  $ccol++; ?></th>
          <?php if(substr($pant,0,4)=='PANT'){?>
					<th onclick="sortTable(this,<?php echo $ccol++; ?>);" title="Imprimir">I</th>
          <?php } ?>
          
          <?php if(mb_stristr('lldd',$repo)){ ?>          
              <th onclick="sortTable(this,<?php echo $ccol++; ?>);">FECHA</th>
              <th onclick="sortTable(this,<?php echo $ccol++; ?>);">DOCU</th>
              <th onclick="sortTable(this,<?php echo $ccol++; ?>);">PTOE</th>
              <th onclick="sortTable(this,<?php echo $ccol++; ?>);">NUMERO</th>
              <th onclick="sortTable(this,<?php echo $ccol++; ?>);">CODIGO</th>
              <th onclick="sortTable(this,<?php echo $ccol++; ?>);">CUENTA</th>
              <th onclick="sortTable(this,<?php echo $ccol++; ?>,'N');">DEBITO</th>
              <th onclick="sortTable(this,<?php echo $ccol++; ?>,'N');">CREDITO</th>
              <th onclick="sortTable(this,<?php echo $ccol++; ?>);">C.SUB</th>
              <th onclick="sortTable(this,<?php echo $ccol++; ?>);">CONCEPTO</th>
              <th onclick="sortTable(this,<?php echo $ccol++; ?>);">STAT</th>
          <?php }else{ ?>
              <th onclick="sortTable(this,<?php echo $ccol++; ?>);">CODIGO</th>
              <th onclick="sortTable(this,<?php echo $ccol++; ?>);">CUENTA</th>
              <?php if(mb_stristr('ssss.ssnn',$repo)){ ?>
              <th onclick="sortTable(this,<?php echo $ccol++; ?>,'N');">INICIAL</th>
              <th onclick="sortTable(this,<?php echo $ccol++; ?>,'N');">DEBITOS</th>
              <th onclick="sortTable(this,<?php echo $ccol++; ?>,'N');">CREDITOS</th>
              <?php } ?>
              <?php if(mb_stristr('sscc.sfcc.ricc',$repo)){ ?>
                  <?php $xfecha=date('Y-m-01',strtotime($fecha1));?>
                  <?php while($xfecha<=$fecha2){ ?>
                    <?php $xaniomes=date('Y-m',strtotime($xfecha)); ?>
                    <th onclick="sortTable(this,<?php echo $ccol++; ?>);">
                      <?php echo $xaniomes; ?>
                    </th>
                    <?php $xfecha=date('Y-m-01',strtotime($xfecha .'+1 month')); ?>
                  <?php } ?>
               <?php } ?>

              <th onclick="sortTable(this,<?php echo $ccol++; ?>,'N');">SALDO</th>
              <?php if(mb_stristr('ssss.ssnn',$repo)){ ?>
              <th onclick="sortTable(this,<?php echo $ccol++; ?>,'N');">VARIAC.</th>
              <th onclick="sortTable(this,<?php echo $ccol++; ?>,'N');">%V.</th>
              <?php } ?>
              <?php if(mb_stristr('ssff.rrii',$repo)){ ?>
              <th onclick="sortTable(this,<?php echo $ccol++; ?>,'N');">%</th>
              <?php } ?>
              <?php if(mb_stristr('ssff.rrii',$repo) and $tabulado==1){ ?>
              <?php //if($nivel>=3){echo '<th></th><th></th>';}?>
              <?php //if($nivel>=5){echo '<th></th><th></th>';}?>
              <?php if($nivel>=4){echo '<th></th><th></th>';}?>
              <?php if($nivel=5){echo '<th></th><th></th>';}?>
              <?php } ?>
          <?php } ?>

          
          <th style="font-size:<?php echo $xfontsize*.5;?>px;" title="Descargar XLS">
            <a href="#" id="downxls1" onClick="javascript:fnExcelReport('tpant1',this,'<?php echo $cfg_empr.'_'.$modu.'_'.date('Ymd_His');?>');">XLS</a>
          </th>
				</tr>
			</thead>
			<?php } ?>
      <?php $timew1=date('U'); ?>
      
			<?php  {// TBODY ?>
			<tbody id="tpant1b" valign="top" style="overflow-y:auto; <?php echo $tdisplay; ?>; 
							<?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 if(@mysql_num_rows($res_pant)==0){?>
          <tr><td style="font-weight:bold;">
            <?php echo 'NO HAY DATOS'; ?>  
            <?php echo '<br>==>'.date('H:i:s'); ?>
            <?php //echo '<br>'.$docu.' /'.$enti; ?>
          </td></tr>
        <?php }?>
        <?php if($user_cons==0){?>
          <tr><td style="font-weight:bold;color:red;">NO TIENE ACCESO PARA CONSULTAR ==> <?php echo $modu.' - '.r_fiel('modu',$modu);?></td></tr>
        <?php }?>

        <?php $last_codi=''; ?>
        <?php $last_idnum=0;?>
        <?php $last_base=0; ?>
        <?php $last_niv1=0; ?>
        <?php $cctas=0; ?>
        
            <?php while($aso_pant=@mysql_fetch_assoc($res_pant)){ ?>
            <?php $status=$aso_pant['status']; ?>
            <?php $id_trfila=fillzero($crow);?> 
            <?php $lineaok=1;?>
              <?php $xidnum =$aso_pant['idnum1'];?>
        
              <?php $xcodi=@$aso_pant['codigo'];?>
              <?php $xdesc=@$aso_pant['codigodesc'];?>
        
              <?php if($modu=='CONT'){?>
              <?php $xcodi=@$aso_pant['ctas_codi'];?>
              <?php $xdesc=@$aso_pant['ctas_desc'];?>
              <?php if(empty($xdesc))
                {
                  $sql_ctax='select * from ctas0 where ctas_codigo like "'.$xcodi.'%" order by ctas_codigo limit 1';
                  $res_ctax=mysql_query($sql_ctax,$link_vcrx);
                  $xdesc=@mysql_result($res_ctax,0,'ctas_descri');
                //               $xdesc=r_fiel('ctas',$xcodi);
                } 
              ?>
              <?php } ?>
        
              <?php $xdesclen=strlen($xdesc);?>
              <?php $xsaldoi=$aso_pant['saldoi']; ?>
              <?php $xtdeb=$aso_pant['stdebito']; ?>
              <?php $xtcre=$aso_pant['stcredito']; ?>
              <?php $xsaldo=$aso_pant['saldo']; ?>
              <?php $xnivel =$aso_pant['nivel']; ?>
              <?php $xvarval=$xsaldo-$xsaldoi; ?>
              <?php $xvarpor=0; ?>
              <?php if($xsaldoi!=0){$xvarpor=($xvarval/$xsaldoi)*100;} ?>
              <?php if(mb_stristr('rrii.ricc',$repo)){$xsaldo=$xsaldo*(-1);}?>
              <?php // $last_codi=$xcodi; ?>
              <?php if(mb_stristr('ssss.ssnn.sscc',$repo) ){?>
                <?php if(abs($xsaldoi)<=$xsaldo0 and abs($xtdeb)<=$xsaldo0 and abs($xtcre)<=$xsaldo0 and abs($xsaldo)<=$xsaldo0){$lineaok=0;} ?>
                <?php if($xdesc=='' and $xnivel<$nivel){$lineaok=0;}?>
              <?php } ?>
                <?php if($xcodi==$last_codi){$lineaok=0;} ?>
                <?php if($repo=='lldd'){$lineaok=1;}?>
        
            <?php
                if(mb_stristr('pcs1',$empr_codigo))
                {if($aso_pant['ctas_nivel']==5 and substr($xcodi,0,3)=='610'){$lineaok=1;}}
            ?>        
        

            <?php if($last_niv1!=substr($xcodi,0,1)){?>
            <?php //$last_niv1=substr($xcodi,0,1); ?>
            <?php //$last_base=$xsaldo; ?>
            <?php } ?>
        
            <?php if($last_niv1!=$aso_pant['ctan1']){?>
              <?php $last_niv1=$aso_pant['ctan1']; ?>
              <?php $last_base=$xsaldo; ?>
            <?php } ?>
        
        
            <?php $xporpar=0; ?>
            <?php if($last_base!=0){$xporpar=($xsaldo/$last_base)*100;} ?>

            <?php if($aso_pant['cta_detalle']==1){$cctas++;} ?>
        
            <?php echo '<div></div>'; ?>
        
            <?php if($lineaok==1)
            { ?>
            <?php $last_codi=$xcodi; ?>
            <?php // $last_idnum= $xidnum;?>
            <?php $crow++; ?> 
            <?php $clin++; ?> 


            <tr id="tr_fila<?php echo $crow;?>" class="tr_fila"  <?php //if($mobile=='true'){echo 'height="55px"';};?>
                style="
                       <?php //if($lineaok==0){echo 'display:none;';}?>
                       <?php //if($aso_pant['nivel']==$nivel-1){echo 'border-bottom:solid 1px;'; $clin=0; } ?>
                       <?php if($aso_pant['nivel']==1){echo 'font-size:'.$xfontsize*(1.3).'; vertical-align:bottom;height:'.$xfontsize*(3).'px;'; } ?>
                       <?php if($aso_pant['nivel']==1 and $nivel>1)
                        {echo 'background-color:;font-weight:bold;font-size:'.$xfontsize*(1.3).';'; $clin=1;} ?>
                       <?php if($aso_pant['nivel']==2 and $nivel>2)
                        {echo 'background-color:;font-weight:bold;font-style:italic;font-size:'.$xfontsize*(1.1).'; border-top:solid 1px;'; $clin=1;} ?>
                       <?php if($aso_pant['nivel']==3 and $nivel>3)
                        {echo 'background-color:;font-weight:;font-style:italic;font-size:'.$xfontsize*(1.1).';'; } ?>
                       <?php //if($aso_pant['nivel']==3 and $nivel==3){$clin=1;} ?>
                       <?php if($repo=='lldd' and $last_idnum!=$xidnum){$cidnum++; $last_idnum=$xidnum; echo 'border-top: 4px double;'; $clin=1;}?>
                       <?php //if($aso_pant['nivel']==4 and $nivel>4){$clin=1;} ?>
                       <?php if($clin%5==0){echo 'border-bottom:dotted 1px;'; } ?>
                       "
                <?php if(substr($pant,0,1)=='P'){?> 
                onmouseover="_filabg(event,'tr_fila','<?php echo $crow; ?>','');"
                <?php } ?>
                onclick="_filabg(event,'tr_fila','<?php echo $crow; ?>','');
                        <?php if(substr($pant,0,1)=='P' and $repo!='lldd'){?> 
                        {info_modu('PANT2','<?php echo $modu; ?>','<?php echo $xcodi; ?>');}
                        <?php } ?> 
                         "
                >
                <td style="display:none;"><?php echo fillzero($crow,5); ?></td>

                <?php if(substr($pant,0,4)=='PANT'){?>
                <td align="center">
                  <?php
                    $pidtxt='impri'.$crow;
                    
                    $pabrev="I";
                    if($repo=='lldd')
                    {
                      $idocu=$aso_pant['docu'];
                      $iidnum=$aso_pant['idfrom'];
                      if(mb_stristr('DD.DI',substr($idocu,0,2))){$iidnum=$aso_pant['idnum1'];}
                      $ponclick='{window.open("?prnt=1&docu='.$idocu.'&idnum='.$iidnum.'&formato=3","_blank")}';
                      $pcaption="Imprimir DIARIO";
                    }
                    else
                    {$ponclick='{info_modu("IMPR2","'.$modu.'","'.$xcodi.'");}'; $pcaption="Imprimir MAYOR";}
                    include('vrbutton.php');
                  ?>
                </td>
                <?php } ?>

                <?php if($repo=='lldd'){ ?>
                    <td align="center">
                      <div style="display:none;"><?php echo $aso_pant['fecha']; ?></div>
                      <div class="hidden"><?php echo $xidnum.$aso_pant['iddet']; ?></div>
                      <div class="noxls"><?php echo $aso_pant['fechadmy']; ?></div>
                    </td>
                    <td align="center" title="<?php echo $aso_pant['docu_descri'];?>">
                      <div class="hidden"><?php echo $aso_pant['mdfrom']; ?></div>
                      <?php echo $aso_pant['docu']; ?>
                    </td>
                    <td align="center" ><?php echo $aso_pant['ptoe']; ?></td>
                    <td align="center" style="font-weight:bold;"><?php echo $aso_pant['numero']; ?></td>
                    <td><?php echo $aso_pant['ctas']; ?></td>
                    <td><?php echo $aso_pant['ctas_descri']; ?></td>
                    <td align="right" >
                      <?php echo number_format($xtdeb,2) ?>
                    </td>
                    <td align="right" >
                      <?php echo number_format($xtcre,2) ?>
                    </td>
                    <td><?php echo $aso_pant['csub_descri']; ?></td>
                    <td style="font-size:75%;" width="30%">
                      <?php echo $aso_pant['concepto'].' /'.$aso_pant['detalle'].' /'.$aso_pant['enti_descri'].' /'.$aso_pant['item_descri']; ?>
                    </td>
                    <td align="center" ><?php echo $aso_pant['status']; ?></td>

                <?php }else{ ?>

                    <td>
                      <div class="hidden"><?php echo $xcodi.'0000000000000' ?></div>
                      <?php echo $xcodi; ?>
                    </td>
                    <td style="<?php if($aso_pant['nivel']==1 and $xdesclen<15){echo 'letter-spacing:10px;'; }?>
                               <?php if($aso_pant['nivel']==1 and $xdesclen>=15){echo 'letter-spacing:3px;'; }?>">
                      <div class="hidden"><?php echo $aso_pant['ctas_desc'].'0000000000000'.$xcodi ?></div>
                      <?php if(mb_stristr('ssff.rrii',$repo)){ ?>
                        <?php if($aso_pant['nivel']>=4){ echo '.';}?>
                        <?php if($aso_pant['nivel']==5){ echo '.';}?>
                      <?php } ?>

                      <?php //echo $aso_pant['ctas_desc']; ?>
                      <?php echo $xdesc; ?>
                    </td>
                  <?php if(mb_stristr('ssss.ssnn',$repo)){ ?>
                    <td align="right">
                      <?php echo number_format($xsaldoi,2); ?>
                    </td>
                    <td align="right">
                      <?php echo number_format($xtdeb,2); ?>
                    </td>
                    <td align="right">
                      <?php echo number_format($xtcre,2); ?>
                    </td>
                  <?php } ?>

                  <?php if(mb_stristr('sscc.sfcc.ricc',$repo)){ ?>
                    <?php $xfecha=date('Y-m-01',strtotime($fecha1));?>
                    <?php while($xfecha<=$fecha2){ ?>
                      <?php $xaniomes=date('Ym',strtotime($xfecha)); ?>
                      <?php $xvalaniomes=$aso_pant['m_'.$xaniomes]; ?>
                      <?php //if(mb_stristr('sscc.sfcc.ricc',$repo)){$xvalaniomes=$xvalaniomes*(-1);}?>
                      <?php if(mb_stristr('ricc',$repo)){$xvalaniomes=$xvalaniomes*(-1);}?>
                        <td align="right">
                          <?php echo number_format($xvalaniomes,2); ?>
                        </td>
                      <?php $xfecha=date('Y-m-01',strtotime($xfecha .'+1 month')); ?>
                    <?php } ?>

                  <?php } ?>

                  <?php if(mb_stristr('ssff.rrii',$repo) and $tabulado==1){ ?>
                      <?php //if($aso_pant['nivel']<=2){ echo '<td></td><td></td>';}?>
                      <?php //if($aso_pant['nivel']<=4){ echo '<td></td><td></td>';}?>
                      <?php if($aso_pant['nivel']<5){ echo '<td></td><td></td>';}?>
                      <?php if($aso_pant['nivel']<=3){ echo '<td></td><td></td>';}?>
                  <?php } ?>

                    <td align="right">
                      <?php echo number_format($xsaldo,2); ?>
                    </td>
                  <?php if(mb_stristr('ssss.ssnn',$repo)){ ?>
                    <td align="right">
                      <?php echo number_format($xvarval,2); ?>
                    </td>
                    <td align="right">
                      <?php echo number_format($xvarpor,2).'%'; ?>
                    </td>
                  <?php } ?>
                  <?php if(mb_stristr('ssff.rrii',$repo)){ ?>
                    <td align="right">
                      <?php echo number_format($xporpar,2).'%'; ?>
                    </td>
                  <?php } ?>
               <?php } ?>


            </tr>
              <?php } ?>
            <?php } ?>
        
            <?php 
//               if(abs($tsaldoi)<$xsaldo0 and abs($tdebito)<$xsaldo0 and abs($tcredito)<$xsaldo0 and abs($tsaldo)<$xsaldo0)
//               {echo '<tr><td>TODAS LAS CUENTAS EN CERO</td><td>0</td></tr>';} 
            ?>
        
			</tbody>
		<?php } ?>	
  
      <?php $timew2=date('U'); ?>
      <?php { // FOOT ?>
			<tfoot style="<?php echo $tdisplay; ?><?php if($mobile!='true'){echo 'max-width:'.($screenw-20).'px;';} ?>;background-color:<?php echo $gris1; ?>; font-size:<?php echo $xfontsize*1;?>px;">
				<tr style="border-top:solid 1px;border-bottom:solid 1px;">
          <th style="display:none;"<?php $ccol--; ?>></th>
          

          <?php if(substr($pant,0,4)=='PANT'){?>
					<th <?php $ccol--; ?>></th>
          <?php } ?>
          <?php if(mb_stristr('lldd',$repo)){ ?>
  					<th <?php $ccol--; ?>></th>
  					<th <?php $ccol--; ?>></th>
  					<th <?php $ccol--; ?>><?php echo($cidnum); ?></th>
  					<th <?php $ccol--; ?>></th>
  					<th <?php $ccol--; ?>></th>
          <?php }else{ ?>
					<th <?php $ccol--; ?>><?php echo($crow); ?></th>
          <?php } ?>
          
					<th <?php $ccol--; ?> style="max-width:;letter-spacing:5px; ">TOTALES</th>
          <?php if(mb_stristr('lldd',$repo)){ ?>
					<th <?php $ccol--; ?> align="right">
						<?php echo number_format($tdebito,2); ?>
					</th>
					<th <?php $ccol--; ?> align="right">
						<?php echo number_format($tcredito,2); ?>
					</th>
          <?php $tsaldo=$tdebito-$tcredito; ?>
          <?php }?>          
          
          <?php if(mb_stristr('ssss.ssnn',$repo)){ ?>
					<th <?php $ccol--; ?> align="right">
						<?php echo number_format($tsaldoi,2); ?>
					</th>
					<th <?php $ccol--; ?> align="right">
						<?php echo number_format($tdebito,2); ?>
					</th>
					<th <?php $ccol--; ?> align="right">
						<?php echo number_format($tcredito,2); ?>
					</th>
          <?php } ?>
          

          <?php if(mb_stristr('sscc.sfcc.ricc',$repo)){ ?>
            <?php $xfecha=date('Y-m-01',strtotime($fecha1));?>
            <?php while($xfecha<=$fecha2){ ?>
              <?php $xaniomes=date('Ym',strtotime($xfecha)); ?>
              <?php //mysql_data_seek($res_tpant,0); ?>
              <?php $xvalaniomes=mysql_result($res_tpant,0,'m_'.$xaniomes); ?>
              <?php if(mb_stristr('ricc',$repo)){$xvalaniomes=$xvalaniomes*(-1);}?>
                <td align="right" style="font-weight:bold;">
                  <?php echo number_format($xvalaniomes,2); ?>
                </td>
              <?php $xfecha=date('Y-m-01',strtotime($xfecha .'+1 month')); ?>
            <?php } ?>

          <?php } ?>
          
          

					<th <?php $ccol--; ?> align="right">
						<?php echo number_format($tsaldo,2); ?>
					</th>
          
          <?php if($ccol<0){$ccol=0;}?>
          <?php if(mb_stristr($pant,'PANT')){?>
          <?php echo str_repeat('<th></th>',$ccol); ?>
          <?php } ?>
				</tr>
        
        
			</tfoot>
			<?php } ?>	
		</table>
  
<?php } ?>
  
<?php if($modu=='INVE'){ ?>  
		<table id="tpant1" class="pant1" border="0"
					 align="center" cellpadding="3" width="100%"
					 style="font-size:<?php if($orient=='V'){echo $xfontsize-8;}else{echo $xfontsize;} ?>px;
						border-collapse:collapse;background-color:snow; position:; <?php if($pant=='IMPR' and 1==2 ){echo 'max-width:210mm;';}?>"
						>
			<?php { // THEAD ?>
			<thead style="<?php echo $tdisplay; ?><?php if($mobile!='true'){echo 'max-width:'.($screenw-20).'px;';} ?>;background-color:<?php echo $gris1; ?>;">
				<tr style="border-top:solid 1px;border-bottom:solid 1px; cursor:pointer;" >
          <th onclick="sortTable(this,0);" style="display:none;"><?php  $ccol++; ?></th>
          
          <?php if(substr($pant,0,4)=='PANT'){?>
					<th onclick="sortTable(this,<?php echo $ccol++; ?>);" title="Imprimir">I</th>
          <?php } ?>
					<th onclick="sortTable(this,<?php echo $ccol++; ?>);">LINEA</th>
					<th onclick="sortTable(this,<?php echo $ccol++; ?>);">CODIGO</th>
					<th onclick="sortTable(this,<?php echo $ccol++; ?>);">DESCRIPCION</th>
          
          <?php if(mb_stristr('ssss.',$repo)){ ?>
					<th onclick="sortTable(this,<?php echo $ccol++; ?>,'N');">INIC</th>
					<th onclick="sortTable(this,<?php echo $ccol++; ?>,'N');">INGR</th>
					<th onclick="sortTable(this,<?php echo $ccol++; ?>,'N');">EGRE</th>
          <?php } ?>
          <?php if(mb_stristr('ssbb.',$repo)){ ?>
            <?php $res_bode=mysql_query($sql_bode,$link_vcrx);?>
            <?php while($aso_bode=mysql_fetch_assoc($res_bode)){ ?>
            <?php $xbode=$aso_bode['bode']; ?>
            <?php $xbode=r_fiel('bode',$aso_bode['bode']); ?>
            <th onclick="sortTable(this,<?php echo $ccol++; ?>,'N');"><?php echo $xbode; ?></th>
            <?php } ?>
          <?php } ?>
          <?php if(mb_stristr('ssss.ssbb',$repo)){ ?>
					<th onclick="sortTable(this,<?php echo $ccol++; ?>,'N');">SALDO</th>
          <?php } ?>
          <?php if(mb_stristr('evta',$repo)){ ?>
					<th onclick="sortTable(this,<?php echo $ccol++; ?>,'N');">CANTIDAD</th>
          <?php } ?>
          <?php if(mb_stristr('ssss.',$repo)){ ?>
					<th onclick="sortTable(this,<?php echo $ccol++; ?>,'N');">VAR.</th>
					<th onclick="sortTable(this,<?php echo $ccol++; ?>,'N');">%V</th>
					<th onclick="sortTable(this,<?php echo $ccol++; ?>,'N');" title="Consumo Promedio Diario">CPD</th>
          <?php } ?>
          
          <?php if($ver_cost==1){ ?>
          <?php if(mb_stristr('ssss.',$repo)){ ?>
					<th onclick="sortTable(this,<?php echo $ccol++; ?>,'N');">$ INI.</th>
					<th onclick="sortTable(this,<?php echo $ccol++; ?>,'N');">DEB.</th>
					<th onclick="sortTable(this,<?php echo $ccol++; ?>,'N');">CRE.</th>
          <?php } ?>
          <?php if(mb_stristr('ssbb.',$repo)){ ?>
            <?php $res_bode=mysql_query($sql_bode,$link_vcrx);?>
            <?php while($aso_bode=mysql_fetch_assoc($res_bode)){ ?>
            <?php $xbode=$aso_bode['bode']; ?>
            <?php $xbode=r_fiel('bode',$aso_bode['bode']); ?>
            <th onclick="sortTable(this,<?php echo $ccol++; ?>,'N');"><?php echo $xbode; ?></th>
            <?php } ?>
          <?php } ?>
          <?php if(mb_stristr('ssss.ssbb',$repo)){ ?>
					<th onclick="sortTable(this,<?php echo $ccol++; ?>,'N');">$ SALDO</th>
          <?php } ?>
          <?php if(mb_stristr('evta',$repo)){ ?>
					<th onclick="sortTable(this,<?php echo $ccol++; ?>,'N');">$ COSTO</th>
					<th onclick="sortTable(this,<?php echo $ccol++; ?>,'N');">VENTA</th>
					<th onclick="sortTable(this,<?php echo $ccol++; ?>,'N');">UTIL.B.</th>
					<th onclick="sortTable(this,<?php echo $ccol++; ?>,'N');" titlte="Utilidad">%</th>
          <?php } ?>
          <?php if(mb_stristr('ssss.',$repo)){ ?>
					<th onclick="sortTable(this,<?php echo $ccol++; ?>,'N');">VAR.</th>
					<th onclick="sortTable(this,<?php echo $ccol++; ?>,'N');">%V.</th>
					<th onclick="sortTable(this,<?php echo $ccol++; ?>,'N');" title="Costo Promedio">COST.P</th>
          <?php } ?>
          <?php } ?>
          
          <?php if($ver_rota==1){ ?>
					<th onclick="sortTable(this,<?php echo $ccol++; ?>,'N');" title="Indice Rotacion">I.R.</th>
					<th onclick="sortTable(this,<?php echo $ccol++; ?>,'N');" title="Dias Rotacion">D.R.</th>
          <?php } ?>
          
          <th style="font-size:<?php echo $xfontsize*.5;?>px;" title="Descargar XLS">
            <a href="#" id="downxls1" onClick="javascript:fnExcelReport('tpant1',this,'<?php echo $cfg_empr.'_'.$modu.'_'.date('Ymd_His');?>');">XLS</a>
          </th>
				</tr>
			</thead>
			<?php } ?>
      
      <?php $timew1=date('U'); ?>
      
			<?php  {// TBODY ?>
			<tbody id="tpant1b" valign="top" style="overflow-y:auto; <?php echo $tdisplay; ?>; 
							<?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 if(@mysql_num_rows($res_pant)==0){?>
          <tr><td style="font-weight:bold;">
            <?php echo 'NO HAY DATOS'; ?>  
            <?php echo '<br>==>'.date('H:i:s'); ?>
          </td></tr>
        <?php }?>
        <?php if($docu==''){?>
<!--           <tr><td style="font-weight:bold;color:red;">DEBE ESPECIFICAR UN DOCUMENTO</td></tr> -->
        <?php }?>
        <?php if($user_cons==0){?>
          <tr><td style="font-weight:bold;color:red;">NO TIENE ACCESO PARA CONSULTAR ==> <?php echo $docu.' - '.r_fiel('docu',$docu);?></td></tr>
        <?php }?>

        <?php $last_codi=''; ?>
        <?php $last_base=0; ?>
        <?php $last_niv1=0; ?>
        <?php $cctas=0; ?>
        
        
        <?php if($modu=='CONT'){ ?>
          <?php while($aso_pant=@mysql_fetch_assoc($res_pant)){ ?>
          <?php $status=$aso_pant['status']; ?>
          <?php $id_trfila=fillzero($crow);?> 
          <?php $lineaok=1;?>
            <?php $xcodi=$aso_pant['ctas_codi'];?>
            <?php $xdesc=$aso_pant['ctas_desc'];?>
            <?php $xdesclen=strlen($xdesc);?>
            <?php $xsaldoi=$aso_pant['saldoi']; ?>
            <?php $xtdeb=$aso_pant['stdebito']; ?>
            <?php $xtcre=$aso_pant['stcredito']; ?>
            <?php $xsaldo=$aso_pant['saldo']; ?>
            <?php $xnivel =$aso_pant['nivel']; ?>
            <?php $xvarval=$xsaldo-$xsaldoi; ?>
            <?php $xvarpor=0;?>
            <?php if($xsaldoi!=0){$xvarpor=($xvarval/$xsaldoi)*100;} ?>
            <?php if(mb_stristr('rrii.ricc',$repo)){$xsaldo=$xsaldo*(-1);}?>
            <?php // $last_codi=$xcodi; ?>
            <?php if(mb_stristr('ssss.ssnn',$repo)){ ?>
              <?php if(abs($xsaldoi)<=$xsaldo0 and abs($xtdeb)<=$xsaldo0 and abs($xtcre)<=$xsaldo0 and abs($xsaldo)<=$xsaldo0){$lineaok=0;} ?>
              <?php if($xcodi==$last_codi){$lineaok=0;} ?>
              <?php if($xdesc=='' and $xnivel<$nivel){$lineaok=0;}?>
            <?php } ?>

          <?php if($last_niv1!=substr($xcodi,0,1)){?>
          <?php $last_niv1=substr($xcodi,0,1); ?>
          <?php $last_base=$xsaldo; ?>
          <?php } ?>
            <?php $xporpar=0;?>
            <?php if($last_base!=0){$xporpar=($xsaldo/$last_base)*100;} ?>

          <?php if($aso_pant['cta_detalle']==1){$cctas++;} ?>

            <?php echo '<div></div>'; ?>
          <?php if($lineaok==1){ ?>
          <?php $last_codi=$xcodi; ?>
          <?php $crow++; ?> 

          <tr id="tr_fila<?php echo $crow;?>" class="tr_fila"  <?php //if($mobile=='true'){echo 'height="55px"';};?>
              style="<?php if($crow%5==0){echo 'border-bottom:dotted 1px;'; } ?>
                     <?php if($aso_pant['nivel']==1 and $nivel>1){echo 'background-color:;font-weight:bold;font-size:'.$xfontsize*(1.3).';'; } ?>
                     <?php if($aso_pant['nivel']==1){echo 'font-size:'.$xfontsize*(1.3).';vertical-align:bottom;height:'.$xfontsize*(3).'px;'; } ?>
                     <?php if($aso_pant['nivel']==2 and $nivel>2){echo 'background-color:;font-weight:bold;font-style:italic;font-size:'.$xfontsize*(1.1).';'; } ?>
                     <?php if($aso_pant['nivel']==3 and $nivel>3){echo 'background-color:;font-weight:;font-style:italic;font-size:'.$xfontsize*(1.1).';'; } ?>
                     <?php //if($aso_pant['cta_detalle']==1){echo 'background-color:;font-weight:;font-style:italic;font-size:'.$xfontsize*(1.0).';'; } ?>
                     "
              <?php if(substr($pant,0,1)=='P'){?> 
              onmouseover="_filabg(event,'tr_fila','<?php echo $crow; ?>','');"
              <?php } ?>
              onclick="_filabg(event,'tr_fila','<?php echo $crow; ?>','');
                      <?php if(substr($pant,0,1)=='P' and $repo!='lldd'){?> 
                      {info_modu('PANT2','<?php echo $modu; ?>','<?php echo $aso_pant['codigo']; ?>');}
                      <?php } ?> 
                       "
              >

              <td style="display:none;"><?php echo fillzero($crow,5); ?></td>
            
              <?php if(substr($pant,0,4)=='PANT'){?>
              <td align="center" title="Imprimir : <?php echo $xcodi; ?>">
                <?php 
                    $pidtxt='impri'.$crow;
                    $pcaption="Imprimir "; $pabrev="I";
                    $ponclick='{info_modu("IMPR2","'.$modu.'","'.$xcodi.'");}';
                    include('vrbutton.php');
                ?>
              </td>
              <?php } ?>
              <td>
                <div class="hidden"><?php echo $xcodi.'0000000000000' ?></div>
                <?php echo $xcodi; ?>
              </td>
              <td style="<?php if($aso_pant['nivel']==1 and $xdesclen<15){echo 'letter-spacing:10px;'; }?>
                         <?php if($aso_pant['nivel']==1 and $xdesclen>=15){echo 'letter-spacing:3px;'; }?>">
                <div class="hidden"><?php echo $aso_pant['ctas_desc'].'0000000000000'.$xcodi ?></div>
                <?php echo $aso_pant['ctas_desc']; ?>
              </td>
            <?php if(mb_stristr('ssss.ssnn',$repo)){ ?>
              <td align="right">
                <?php echo number_format($xsaldoi,2); ?>
              </td>
              <td align="right">
                <?php echo number_format($xtdeb,2); ?>
              </td>
              <td align="right">
                <?php echo number_format($xtcre,2); ?>
              </td>
            <?php } ?>
              <td align="right" style="<?php if(mb_stristr('ssxss.ssxnn',$repo)){ echo 'font-weight:bold;';} ?>">
                <?php echo number_format($xsaldo,2); ?>
              </td>
            <?php if(mb_stristr('ssss.ssnn',$repo)){ ?>
              <td align="right">
                <?php echo number_format($xvarval,2); ?>
              </td>
              <td align="right">
                <?php echo number_format($xvarpor,2).'%'; ?>
              </td>
            <?php } ?>
            <?php if(mb_stristr('ssff.rrii',$repo)){ ?>
              <td align="right">
                <?php echo number_format($xporpar,2).'%'; ?>
              </td>
            <?php } ?>
          </tr>
            <?php } ?>
          <?php } ?>
        <?php } ?>
        
        <?php if($modu=='INVE'){ ?>
          <?php while($aso_pant=@mysql_fetch_assoc($res_pant)){ ?>
          <?php $status=$aso_pant['status']; ?>
          <?php $id_trfila=fillzero($crow);?> 
          <?php $lineaok=1;?>
            <?php $xlsub=$aso_pant['lsub'];?>
            <?php $xlsubdes=$aso_pant['lsub_descri'];?>
            <?php $xcodi=$aso_pant['item'];?>
            <?php $xdesc=$aso_pant['item_descri'];?>
            <?php $xdesclen=strlen($xdesc);?>

            <?php $xsaldoi=$aso_pant['saldoi']; ?>
            <?php $xsaldoiu=$aso_pant['saldoiu']; ?>
            <?php $xting=$aso_pant['stingreso']; ?>
            <?php $xtegr=$aso_pant['stegreso']; ?>
            <?php $xtdeb=$aso_pant['stdebito']; ?>
            <?php $xtcre=$aso_pant['stcredito']; ?>
            <?php $xsaldo=$aso_pant['saldo']; ?>
            <?php $xsaldou=$aso_pant['saldou']; ?>

        
            <?php $xtpvta=$aso_pant['stpvta']; ?>
            <?php $xtutil=$aso_pant['stutil']; ?>
            <?php $xputil=0; ?>
            <?php if($xtpvta>0){$xputil=$xtutil/$xtpvta*100;}?>

            <?php $xnivel =$aso_pant['nivel']; ?>
            <?php $duni =$aso_pant['item_duni']; ?>
            <?php $dpre =$aso_pant['item_dpre']; ?>
            <?php $dcos =$aso_pant['item_dcos']; ?>
            <?php $xvarvalu=$xsaldou-$xsaldoiu; ?>
            <?php $xvarporu=$xvarvalu/$xsaldoiu*100; ?>
            <?php //$consprom=cons_prom($xcodi,$fecha2,'D'); ?>
            <?php $consprom=cons_prom($xcodi,$fecha2); ?>
            <?php if($ver_rota==1){?>      
            <?php $indirota=indi_rota($xcodi,$fecha2);?>
            <?php } ?>
            <?php //$diasrota=bcdiv(365,$indirota,2);?>
        
            <?php $xvarval=$xsaldo-$xsaldoi; ?>
            <?php $xvarpor=$xvarval/$xsaldoi*100; ?>
            <?php if($ver_cost==1){$xcospro=cost_prom($xcodi);} ?>
            <?php  ?>
            <?php // if($xcospro>=2){$dcos=2;}?> 
        
            <?php //if(mb_stristr('rrii.ricc',$repo)){$xsaldo=$xsaldo*(-1);}?>
            <?php // $last_codi=$xcodi; ?>
          <?php if(abs($xsaldoi)<=$xsaldo0 and abs($xtdeb)<=$xsaldo0 and abs($xtcre)<=$xsaldo0 and abs($xsaldo)<=$xsaldo0){$lineaok=0;} ?>
          <?php if($xcodi==$last_codi){$lineaok=0;} ?>
          <?php if($xdesc=='' and $xnivel<$nivel){$lineaok=0;}?>

          <?php if($last_niv1!=substr($xcodi,0,1)){?>
          <?php $last_niv1=substr($xcodi,0,1); ?>
          <?php $last_base=$xsaldo; ?>
          <?php } ?>
            <?php $xporpar=$xsaldo/$last_base*100; ?>

            <?php echo '<div></div>'; ?>
          <?php $cctas++; ?>
          <?php if($lineaok==1){ ?>
          <?php $last_codi=$xcodi; ?>
          <?php $crow++; ?> 

          <tr id="tr_fila<?php echo $crow;?>" class="tr_fila"  <?php //if($mobile=='true'){echo 'height="55px"';};?>
              style="<?php if($crow%5==0){echo 'border-bottom:dotted 1px;'; } ?>
                     "
              <?php if(substr($pant,0,1)=='P'){?> 
              onmouseover="_filabg(event,'tr_fila','<?php echo $crow; ?>','');"
              <?php } ?>
              onclick="_filabg(event,'tr_fila','<?php echo $crow; ?>','');
                      <?php if(substr($pant,0,1)=='P' and $repo!='lldd'){?>
                      {info_modu('PANT2','<?php echo $modu; ?>','<?php echo $aso_pant['codigo']; ?>');}
                      <?php } ?> 
                       "
              >
              <td style="display:none;"><?php echo fillzero($crow,5); ?></td>
            
              <?php if(substr($pant,0,4)=='PANT'){?>
              <td align="center" title="Imprimir : <?php echo $xcodi; ?>">
                <?php 
                    $pidtxt='impri'.$crow;
                    $pcaption="Imprimir KARDEX"; $pabrev="I";
                    $ponclick='{info_modu("IMPR2","'.$modu.'","'.$xcodi.'");}';
                    include('vrbutton.php');
                ?>
              </td>
              <?php } ?>
              <td>
                <?php echo $lsubdes; ?>
              </td>
              <td>
                <div class="hidden"><?php echo $xcodi.'' ?></div>
                <?php echo $xcodi; ?>
              </td>
              <td style="<?php if($aso_pant['nivel']==1 and $xdesclen<15){echo 'letter-spacing:10px;'; }?>
                         <?php if($aso_pant['nivel']==1 and $xdesclen>=15){echo 'letter-spacing:3px;'; }?>">
                <div class="hidden"><?php echo $aso_pant['ctas_desc'].'0000000000000'.$xcodi ?></div>
                <?php echo $xdesc; ?>
              </td>
            
            <?php if(mb_stristr('ssss.ssnn',$repo)){ ?>
              <td align="right" style="font-weight:bold;">
                <?php echo number_format($xsaldoiu,$duni); ?>
              </td>
              <td align="right">
                <?php echo number_format($xting,$duni); ?>
              </td>
              <td align="right">
                <?php echo number_format($xtegr,$duni); ?>
              </td>
            <?php } ?>
            
            <?php if(mb_stristr('ssbb.',$repo)){ ?>
              <?php $res_bode=mysql_query($sql_bode,$link_vcrx);?>
              <?php while($aso_bode=mysql_fetch_assoc($res_bode)){ ?>
              <?php $xbode=$aso_bode['bode']; ?>
              <td align="right">
                <?php echo number_format($aso_pant['bu_'.$xbode],$duni); ?>
              </td>
              <?php } ?>
            <?php } ?>
            
              <td align="right" style="font-weight:bold;">
                <?php echo number_format($xsaldou,$duni); ?>
              </td>
            <?php if(mb_stristr('ssss',$repo)){ ?>
              <td align="right">
                <?php echo number_format($xvarvalu,$duni); ?>
              </td>
              <td align="right">
                <?php echo number_format($xvarporu,2).'%'; ?>
              </td>
              <td align="right">
                <?php echo number_format($consprom[1],$duni); ?>
              </td>
            <?php } ?>
            
            
            <?php if($ver_cost==1){ ?>
            <?php $duni=2; ?>
            <?php if(mb_stristr('ssss.ssnn',$repo)){ ?>
              <td align="right" style="font-weight:bold;">
                <?php echo number_format($xsaldoi,$duni); ?>
              </td>
              <td align="right">
                <?php echo number_format($xtdeb,$duni); ?>
              </td>
              <td align="right">
                <?php echo number_format($xtcre,$duni); ?>
              </td>
            <?php } ?>
            
            <?php if(mb_stristr('ssbb.',$repo)){ ?>
              <?php $res_bode=mysql_query($sql_bode,$link_vcrx);?>
              <?php while($aso_bode=mysql_fetch_assoc($res_bode)){ ?>
              <?php $xbode=$aso_bode['bode']; ?>
              <td align="right">
                <?php echo number_format($aso_pant['b_'.$xbode],$duni); ?>
              </td>
              <?php } ?>
            <?php } ?>
            
              <td align="right" style="font-weight:bold;">
                <?php echo number_format($xsaldo,$duni); ?>
              </td>
            
            <?php if(mb_stristr('evta.',$repo)){ ?>
              <td align="right" style="font-weight:;">
                <?php echo number_format($xtpvta,$duni); ?>
              </td>
              <td align="right" style="font-weight:bold;">
                <?php echo number_format($xtutil,$duni); ?>
              </td>
              <td align="right" style="font-weight:bold;">
                <?php echo number_format($xputil,$duni); ?>
              </td>
            <?php } ?>
            
            <?php if(mb_stristr('ssss.ssnn',$repo)){ ?>
              <td align="right">
                <?php echo number_format($xvarval,$duni); ?>
              </td>
              <td align="right">
                <?php echo number_format($xvarpor,2).'%'; ?>
              </td>
              <td align="right" style="font-weight:bold;">
                <?php echo number_format($xcospro,$dcos); ?>
              </td>
            <?php } ?>
            
            
            <?php } ?>

              <?php if($ver_rota==1){?>
              <td align="right">
                <?php echo number_format($indirota[1],2); ?>
              </td>
              <td align="right">
                <?php echo number_format($indirota[2],0); ?>
              </td>
              <?php } ?>
            
            
          </tr>
            <?php } ?>
          <?php } ?>
        <?php } ?>
        
        
        
			</tbody>
		<?php } ?>	
  
      <?php $timew2=date('U'); ?>
      <?php { // FOOT ?>
			<tfoot style="<?php echo $tdisplay; ?><?php if($mobile!='true'){echo 'max-width:'.($screenw-20).'px;';} ?>;background-color:<?php echo $gris1; ?>; font-size:<?php echo $xfontsize*1;?>px;">
				<tr style="border-top:solid 1px;border-bottom:solid 1px;">
          <th style="display:none;"<?php $ccol--; ?>></th>

          <?php if(substr($pant,0,4)=='PANT'){?>
					<th <?php $ccol--; ?>></th>
          <?php } ?>
					<th <?php $ccol--; ?>></th>
					<th <?php $ccol--; ?>><?php echo($crow); ?></th>
					<th <?php $ccol--; ?> style="max-width:;letter-spacing:5px; " >TOTALES</th>
          
          <?php if($modu=='CONT'){?>
            <?php if(mb_stristr('ssss.ssnn',$repo)){ ?>
            <th <?php $ccol--; ?> align="right">
              <?php echo number_format($tsaldoi,2); ?>
            </th>
            <th <?php $ccol--; ?> align="right">
              <?php echo number_format($tdebito,2); ?>
            </th>
            <th <?php $ccol--; ?> align="right">
              <?php echo number_format($tcredito,2); ?>
            </th>
            <?php } ?>
            <th <?php $ccol--; ?> align="right">
              <?php echo number_format($tsaldo,2); ?>
            </th>
          <?php } ?>
          
          <?php if($modu=='INVE'){?>
            <?php if(mb_stristr('ssss.',$repo)){ ?>
            <th <?php $ccol--; ?> align="right">
              <?php echo number_format($tsaldoiu,2); ?>
            </th>
            <th <?php $ccol--; ?> align="right">
              <?php echo number_format($tingreso,2); ?>
            </th>
            <th <?php $ccol--; ?> align="right">
              <?php echo number_format($tegreso,2); ?>
            </th>
            <?php } ?>
          
            <?php if(mb_stristr('ssbb.',$repo)){ ?>
              <?php mysql_data_seek($res_tpant); ?>
              <?php $res_bode=mysql_query($sql_bode,$link_vcrx);?>
              <?php while($aso_bode=mysql_fetch_assoc($res_bode)){ ?>
              <?php $xbode=$aso_bode['bode']; ?>
              <th align="right">
                <?php echo number_format(@mysql_result($res_tpant,0,'bu_'.$xbode),$duni); ?>
              </th>
              <?php } ?>
            <?php } ?>
          
          
            <th <?php $ccol--; ?> align="right">
              <?php echo number_format($tsaldou,2); ?>
            </th>
          
            <?php if(mb_stristr('ssss.ssbb',$repo)){ ?>
            <th></th>
            <th></th>
            <th></th>
            <?php } ?>
          
          <?php } ?>
          
          <?php if($modu=='INVE' and $ver_cost==1){ ?>
          
          
            <?php if(mb_stristr('ssbb.',$repo)){ ?>
              <?php mysql_data_seek($res_tpant); ?>
              <?php $res_bode=mysql_query($sql_bode,$link_vcrx);?>
              <?php while($aso_bode=mysql_fetch_assoc($res_bode)){ ?>
              <?php $xbode=$aso_bode['bode']; ?>
              <th align="right">
                <?php echo number_format(@mysql_result($res_tpant,0,'b_'.$xbode),$duni); ?>
              </th>
              <?php } ?>
            <?php } ?>
          
          <?php if(mb_stristr('ssss.ssnn',$repo)){ ?>
          
					<th <?php $ccol--; ?> align="right">
						<?php echo number_format($tsaldoi,2); ?>
					</th>
					<th <?php $ccol--; ?> align="right">
						<?php echo number_format($tdebito,2); ?>
					</th>
					<th <?php $ccol--; ?> align="right">
						<?php echo number_format($tcredito,2); ?>
					</th>
          <?php } ?>
            
					<th <?php $ccol--; ?> align="right">
						<?php echo number_format($tsaldo,2); ?>
					</th>
          
            <?php if(mb_stristr('evta',$repo)){ ?>
              <th <?php $ccol--; ?> align="right">
                <?php echo number_format($tpvta,2); ?>
              </th>
              <th <?php $ccol--; ?> align="right">
                <?php echo number_format($tutil,2); ?>
              </th>
              <th <?php $ccol--; ?> align="right">
                <?php echo number_format($putil,2); ?>
              </th>
            <?php } ?>
          
          
          <th></th>
          <th></th>
          <th></th>

          
          
          <?php } ?>
          
          
            <?php if($ver_rota==1){ ?>
            <th <?php $ccol--; ?> align="right">
              <?php echo number_format($indirota[1],2); ?>
            </th>
            <th <?php $ccol--; ?> align="right">
              <?php echo number_format($indirota[2],0); ?>
            </th>
            <?php } ?>

          <?php if($modu=='CXCO' or $modu=='CXPA'){?>
            <?php if(mb_stristr('ssee',$repo)){ ?>
            <th <?php $ccol--; ?> align="right">
              <?php echo number_format($tsaldoi,2); ?>
            </th>
            <th <?php $ccol--; ?> align="right">
              <?php echo number_format($tdebito,2); ?>
            </th>
            <th <?php $ccol--; ?> align="right">
              <?php echo number_format($tcredito,2); ?>
            </th>
            <?php } ?>
            <th <?php $ccol--; ?> align="right">
              <?php echo number_format($tsaldo,2); ?>
            </th>
          <?php } ?>
          
          
          
          <?php if($ccol<0){$ccol=0;}?>
          <?php if(mb_stristr($pant,'PANT')){?>
          <?php echo str_repeat('<th></th>',$ccol); ?>
          <?php } ?>
				</tr>
        
        
			</tfoot>
			<?php } ?>	
		</table>
  
<?php } ?>
  
<?php if($modu=='CXCO' or $modu=='CXPA'){ ?>  
		<table id="tpant1" class="pant1" border="0"
					 align="center" cellpadding="3" width="100%"
					 style="font-size:<?php if($orient=='V'){echo $xfontsize-8;}else{echo $xfontsize;} ?>px;
						border-collapse:collapse;background-color:snow; position:; <?php if($pant=='IMPR' and 1==2 ){echo 'max-width:210mm;';}?>"
						>
			<?php { // THEAD ?>
			<thead style="<?php echo $tdisplay; ?><?php if($mobile!='true'){echo 'max-width:'.($screenw-20).'px;';} ?>;background-color:<?php echo $gris1; ?>;">
				<tr style="border-top:solid 1px;border-bottom:solid 1px; cursor:pointer;" >
          <th onclick="sortTable(this,0);" style="display:none;"><?php  $ccol++; ?></th>
          
          <?php if(substr($pant,0,4)=='PANT'){?>
					<th onclick="sortTable(this,<?php echo $ccol++; ?>);" title="Imprimir">I</th>
          <?php } ?>

          <?php if(mb_stristr('ssdd.lldd',$repo)){ ?>          
              <th onclick="sortTable(this,<?php echo $ccol++; ?>);">FECHA</th>
              <th onclick="sortTable(this,<?php echo $ccol++; ?>);">DOCU</th>
              <th onclick="sortTable(this,<?php echo $ccol++; ?>);">PTOE</th>
              <th onclick="sortTable(this,<?php echo $ccol++; ?>);">NUMERO</th>
          <?php } ?>
          
          <?php if(mb_stristr('ssee.ssdd.lldd',$repo)){ ?>
              <th onclick="sortTable(this,<?php echo $ccol++; ?>);"><?php if($tabla=='cxcob'){echo 'ZONA';}else{echo 'T.PRO';} ?></th>
              <th onclick="sortTable(this,<?php echo $ccol++; ?>);">CED / RUC</th>
              <th onclick="sortTable(this,<?php echo $ccol++; ?>);"><?php if($tabla=='cxcob'){echo 'CLIENTE';}else{echo 'PROVEEDOR';} ?></th>
          <?php } ?>
          <?php if(mb_stristr('ssee.ssdd',$repo)){ ?>
              <th onclick="sortTable(this,<?php echo $ccol++; ?>,'N');">INICIAL</th>
              <th onclick="sortTable(this,<?php echo $ccol++; ?>,'N');">DEBITOS</th>
              <th onclick="sortTable(this,<?php echo $ccol++; ?>,'N');">CREDITOS</th>
              <th onclick="sortTable(this,<?php echo $ccol++; ?>,'N');">SALDO</th>
          <?php } ?>

          <?php if(mb_stristr('lldd',$repo)){ ?>
              <th onclick="sortTable(this,<?php echo $ccol++; ?>,'N');">VALOR</th>
              <th onclick="sortTable(this,<?php echo $ccol++; ?>,'N');">SALDO</th>
          <?php } ?>
          
          <?php if(mb_stristr('ssdd.lldd',$repo)){ ?>          
              <th onclick="sortTable(this,<?php echo $ccol++; ?>,'');" title="Días Vencido">DV</th>
              <th onclick="sortTable(this,<?php echo $ccol++; ?>);">CONCEPTO</th>
          <?php } ?>
          <?php if(mb_stristr('ssee',$repo)){ ?>          
              <th onclick="sortTable(this,<?php echo $ccol++; ?>,'N');">%</th>
              <th onclick="sortTable(this,<?php echo $ccol++; ?>);">CONTACTO</th>
          <?php } ?>
          
          
          
          <th style="font-size:<?php echo $xfontsize*.5;?>px;" title="Descargar XLS">
            <a href="#" id="downxls1" onClick="javascript:fnExcelReport('tpant1',this,'<?php echo $cfg_empr.'_'.$modu.'_'.date('Ymd_His');?>');">XLS</a>
          </th>
				</tr>
			</thead>
			<?php } ?>
      <?php $timew1=date('U'); ?>

      <?php //die();?>
      
			<?php  {// TBODY ?>
			<tbody id="tpant1b" valign="top" style="overflow-y:auto; <?php echo $tdisplay; ?>; 
							<?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 if(@mysql_num_rows($res_pant)==0){?>
          <tr><td style="font-weight:bold;">
            <?php echo 'NO HAY DATOS'; ?>  
            <?php echo '<br>==>'.date('H:i:s'); ?>
            <?php //echo '<br>'.$docu.' /'.$enti; ?>
          </td></tr>
        <?php }?>
        <?php if($user_cons==0){?>
          <tr><td style="font-weight:bold;color:red;">NO TIENE ACCESO PARA CONSULTAR ==> <?php echo $modu.' - '.r_fiel('modu',$modu);?></td></tr>
        <?php }?>

        <?php $last_codi=''; ?>
        <?php $last_idnum='';?>
        <?php $last_base=0; ?>
        <?php $last_niv1=0; ?>
        <?php $cctas=0; ?>
        <?php $xdocusal0=''; ?>
        
            <?php while($aso_pant=@mysql_fetch_assoc($res_pant)){ ?>
            <?php $status=$aso_pant['status']; ?>
            <?php $id_trfila=fillzero($crow);?> 
            <?php $lineaok=1;?>
              <?php $xidnum =$aso_pant['idnum1'];?>
        
              <?php $xdocum =$aso_pant['docum'];?>
              <?php $xptoem =$aso_pant['ptoem'];?>
              <?php $xnumer =$aso_pant['numer'];?>
        
              <?php if($modu=='CXCO'){$xtipo=@$aso_pant['zsub_descri'];}?>
              <?php if($modu=='CXPA'){$xtipo=@$aso_pant['tpro_descri'];}?>
              <?php $xcodi=@$aso_pant['enti'];?>
              <?php $xdesc=@$aso_pant['enti_descri'];?>
        
              <?php $xdesclen=strlen($xdesc);?>
              <?php $xsaldoi=$aso_pant['saldoi']; ?>
              <?php $xtdeb=$aso_pant['stdebito']; ?>
              <?php $xtcre=$aso_pant['stcredito']; ?>
              <?php $xsaldo=$aso_pant['saldo']; ?>
              <?php $xnivel =$aso_pant['nivel']; ?>
              <?php $xvarval=$xsaldo-$xsaldoi; ?>
              <?php $xvarpor=0; ?>
              <?php $xsaldoc=0; ?>
              <?php if($xsaldoi!=0){$xvarpor=($xvarval/$xsaldoi)*100;} ?>

            <?php
              if($repo=='lldd' and $aso_pant['cabdet']==1)
              {
                $xsaldoc=sal_docum($xdocum,$xidnum,$fecha1,$fecha2);
                if($xsaldoc[1]<=$xsaldo0 and $xsaldoc[2]<=$xsaldo0 and $xsaldoc[3]<=$xsaldo0 and $xsaldoc[4]<=$xsaldo0)
                {$xdocusal0=$xdocum.$xptoem.$xnumer;}
//                 $xsaldo=$xsaldoc[4];
              }
            ?>

        
            <?php $xporpar=0; ?>
            <?php if($tsaldo!=0){$xporpar=($xsaldo/$tsaldo)*100; $tporpar+=$xporpar;} ?>
            <?php if(mb_stristr('lldd',$repo)){ ?>
              <?php if($xdocusal0==$xdocum.$xptoem.$xnumer){$lineaok=0;} ?>
            <?php } ?>

            <?php if(mb_stristr('ssee.ssdd',$repo)){ ?>
              <?php if(abs($xsaldoi)<=$xsaldo0 and abs($xtdeb)<=$xsaldo0 and abs($xtcre)<=$xsaldo0 and abs($xsaldo)<=$xsaldo0){$lineaok=0;} ?>
            <?php } ?>
        
            <?php echo '<div></div>'; ?>
        
            <?php if($lineaok==1){ ?>
            <?php $last_codi=$xcodi; ?>
            <?php $crow++; ?> 
            <?php $clin++; ?> 
        
            <tr id="tr_fila<?php echo $crow;?>" class="tr_fila" 
                style="
                       <?php if($repo=='lldd' and $aso_pant['cabdet']==1){ echo '';}?>
                       <?php if($repo=='lldd' and $last_idnum!=$xdocum.$xptoem.$xnumer)
                            {$cidnum++; $last_idnum=$xdocum.$xptoem.$xnumer; echo 'border-top: 4px double;'; $clin=1;}?>
                       <?php if($clin%5==0){echo 'border-bottom:dotted 1px;'; } ?>
                       "
                <?php if(substr($pant,0,1)=='P'){?> 
                onmouseover="_filabg(event,'tr_fila','<?php echo $crow; ?>','');"
                <?php } ?>
                onclick="_filabg(event,'tr_fila','<?php echo $crow; ?>','');
                        <?php if(substr($pant,0,1)=='P' and $repo=='ssee'){?> 
                        {info_modu('PANT2','<?php echo $modu; ?>','<?php echo $xcodi; ?>');}
                        <?php } ?> 
                        <?php if(substr($pant,0,1)=='P' and $repo=='ssdd'){?> 
                        {info_modu('PANT2','<?php echo $modu; ?>','<?php echo $xcodi.$xdocum.$xptoem.$xnumer; ?>');}
                        <?php } ?> 
                         "
                >
              
                <td style="display:none;"><?php echo fillzero($crow,5); ?></td>

                <?php if(substr($pant,0,4)=='PANT'){?>
                <td align="center">
                  <?php
                    $pidtxt='impri'.$crow;
                    
                    $pabrev="I";
                    if($repo=='ssee')
                    {$ponclick='{info_modu("IMPR2","'.$modu.'","'.$xcodi.'");}'; $pcaption="Imprimir Est.Cta.";}
                    if(mb_stristr('ssdd.lldd',$repo))
                    {$ponclick='{window.open("?prnt=1&docu='.$aso_pant['docu'].'&idnum='.$aso_pant['idnum1'].'&formato=1","_blank")}'; $pcaption="Imprimir COMPROBANTE";}
                    include('vrbutton.php');
                  ?>
                </td>
                <?php } ?>

                <?php if(mb_stristr('ssdd.lldd',$repo)){ ?>
                    <td align="center">
                      <div style="display:none;"><?php echo $aso_pant['fecha']; ?></div>
                      <div class="hidden"><?php echo $xidnum.$aso_pant['iddet']; ?></div>
                      <div class="noxls"><?php echo $aso_pant['fechadmy']; ?></div>
                    </td>
                    <td align="center" title="<?php echo $aso_pant['docu_descri'];?>">
                      <div class="hidden"><?php echo $aso_pant['mdfrom']; ?></div>
                      <?php echo $aso_pant['docu']; ?>
                    </td>
                    <td align="center" ><?php echo $aso_pant['ptoe']; ?></td>
                    <td align="center" style="font-weight:bold;"><?php echo $aso_pant['numero']; ?></td>
               <?php } ?>

                <?php if(mb_stristr('ssee.ssdd.lldd',$repo)){ ?>
                    <td align="center"><?php echo $xtipo; ?></td>
                    <td><?php echo $xcodi; ?></td>
                    <td style="<?php if($mobile!='true' and strlen(trim($xdesc))>20){echo 'font-size:'.($xfontsize-2).'px;';} ?>"
                        title="<?php echo '/RS: '.$xdesc; ?>">
                      <?php if($mobile=='true'){echo substr($xdesc,0,20);}else{echo substr($xdesc,0,50);} ?>
                    </td>
              
                  <?php if(mb_stristr('ssee.ssdd',$repo)){ ?>
                    <td align="right">
                      <?php echo number_format($xsaldoi,2); ?>
                    </td>
                    <td align="right">
                      <?php echo number_format($xtdeb,2); ?>
                    </td>
                    <td align="right">
                      <?php echo number_format($xtcre,2); ?>
                    </td>
                  <?php } ?>

                    <td align="right" style="
                      <?php if($repo!='lldd'){echo 'font-weight:bold;';}?>
                      <?php if($repo=='lldd' and $aso_pant['cabdet']==1){echo 'font-weight:bold;';} ?>
                      <?php if($xsaldo<0 and $repo!='lldd'){echo 'color:red;';} ?>
                      <?php if($xsaldo<0 and $repo=='lldd'){echo 'font-style:italic;';} ?>">
                      <?php echo number_format($xsaldo,2); ?>
                    </td>
                <?php } ?>

                <?php if(mb_stristr('ssee',$repo)){ ?>
                  <td align="right">
                    <?php echo number_format($xporpar,2).'%'; ?>
                  </td>
                <?php } ?>
              
                <?php
                  if($repo=='lldd' and $aso_pant['cabdet']==1)
                  {$xsaldo=$xsaldoc[4];}
                ?>
              
                <?php if(mb_stristr('lldd',$repo)){ ?>
                  <td align="right" style="font-weight:bold;">
                    <div style="<?php if($aso_pant['cabdet']==1){}else{echo 'display:none;';} ?>">
                      <?php echo number_format($xsaldo,2); ?></div>
                  </td>
                <?php } ?>
              
              
                <?php if(mb_stristr('ssdd.lldd',$repo)){ ?>
                <?php //if($xsaldo<=$xsaldo0){$xdiasv=0;}else{$xdiasv=$aso_pant['diasv'];} ?>
                <?php 
                  if($aso_pant['cabdet']==1)
                  {if($xsaldo<=$xsaldo0){$xdiasv=0;}else{$xdiasv=$aso_pant['diasv'];}}
                ?>
                    <td align="center">
                      <div class="hidden">
                        <?php echo fillzero($xdiasv,4).$aso_pant['docum'].$aso_pant['ptoem'].$aso_pant['numer']; ?>
                      </div>
                      <div style="
                                  <?php if($aso_pant['cabdet']==1){echo 'font-weight:bold;';}else{echo 'display:none;';} ?>
                                  <?php if($xdiasv>(-15) and $xdiasv<=0){echo 'background:lightgreen;';} ?>
                                  <?php if($xdiasv>0 and $xdiasv<=30){echo 'background:yellow;';} ?>
                                  <?php if($xdiasv>30 and $xdiasv<=60){echo 'background:gold';} ?>
                                  <?php if($xdiasv>60 and $xdiasv<=90){echo 'background:orange;';} ?>
                                  <?php if($xdiasv>90 and $xdiasv<=120){echo 'background:crimson;';} ?>
                                  <?php if($xdiasv>120){echo 'background:red;';} ?>
                                  ">
                        <?php echo number_format($xdiasv,0); ?></div>
                    </td>
                    <td style="font-size:75%;">
                      <?php echo $aso_pant['concepto'].' /'.$aso_pant['detalle'].' /'.$aso_pant['item_descri']; ?>
                    </td>
               <?php } ?>

              
            </tr>
              <?php } 
            ?>
            <?php } ?>
        
            <?php 
//               if(abs($tsaldoi)<$xsaldo0 and abs($tdebito)<$xsaldo0 and abs($tcredito)<$xsaldo0 and abs($tsaldo)<$xsaldo0)
//               {echo '<tr><td>TODAS LAS CUENTAS EN CERO</td><td>0</td></tr>';} 
            ?>
        
			</tbody>
		<?php } ?>	
  
      <?php $timew2=date('U'); ?>
      <?php { // FOOT ?>
			<tfoot style="<?php echo $tdisplay; ?><?php if($mobile!='true'){echo 'max-width:'.($screenw-20).'px;';} ?>;background-color:<?php echo $gris1; ?>; font-size:<?php echo $xfontsize*1;?>px;">
				<tr style="border-top:solid 1px;border-bottom:solid 1px;">
          <th style="display:none;"<?php $ccol--; ?>></th>

          <?php if(substr($pant,0,4)=='PANT'){?>
					<th <?php $ccol--; ?>></th>
          <?php } ?>
  					<th <?php $ccol--; ?>></th>
          <?php if(mb_stristr('ssdd',$repo)){ ?>
  					<th <?php $ccol--; ?>></th>
  					<th <?php $ccol--; ?>></th>
  					<th <?php $ccol--; ?>><?php echo($crow); ?></th>
  					<th <?php $ccol--; ?>></th>
  					<th <?php $ccol--; ?>></th>
          <?php } ?>
          <?php if(mb_stristr('ssee',$repo)){ ?>
					<th <?php $ccol--; ?>><?php echo($crow); ?></th>
          <?php } ?>

          <?php if(mb_stristr('lldd',$repo)){ ?>
					<th <?php $ccol--; ?>><?php echo($cidnum); ?></th>
          <?php } ?>

          <?php if(mb_stristr('lldd',$repo)){ ?>
  					<th <?php $ccol--; ?>></th>
  					<th <?php $ccol--; ?>></th>
  					<th <?php $ccol--; ?>></th>
  					<th <?php $ccol--; ?>></th>
          <?php } ?>
          
					<th <?php $ccol--; ?> style="max-width:;letter-spacing:5px; " >TOTALES</th>

          <?php if(mb_stristr('ssee.ssdd',$repo)){ ?>
					<th <?php $ccol--; ?> align="right">
						<?php echo number_format($tsaldoi,2); ?>
					</th>
					<th <?php $ccol--; ?> align="right">
						<?php echo number_format($tdebito,2); ?>
					</th>
					<th <?php $ccol--; ?> align="right">
						<?php echo number_format($tcredito,2); ?>
					</th>
          <?php } ?>

          <?php if(mb_stristr('lldd',$repo)){ ?>
  					<th <?php $ccol--; ?>></th>
          <?php } ?>
          
					<th <?php $ccol--; ?> align="right">
						<?php echo number_format($tsaldo,2); ?>
					</th>
          <?php if(mb_stristr('ssee',$repo)){ ?>
					<th <?php $ccol--; ?> align="right">
						<?php echo number_format($tporpar,2).'%'; ?>
					</th>
          <?php } ?>
          
          <?php if($ccol<0){$ccol=0;}?>
          <?php if(mb_stristr($pant,'PANT')){?>
          <?php echo str_repeat('<th></th>',$ccol); ?>
          <?php } ?>
				</tr>
        
        
			</tfoot>
			<?php } ?>	
		</table>
  
<?php } ?>
  
<?php if(mb_stristr('VTAS.CLIE.COMP.PROV',$modu)){ ?>  
		<table id="tpant1" class="pant1" border="0"
					 align="center" cellpadding="3" width="100%"
					 style="font-size:<?php if($orient=='V'){echo $xfontsize-8;}else{echo $xfontsize;} ?>px;
						border-collapse:collapse;background-color:snow; position:; <?php if($pant=='IMPR' and 1==2 ){echo 'max-width:210mm;';}?>"
						>
			<?php { // THEAD ?>
			<thead style="<?php echo $tdisplay; ?><?php if($mobile!='true'){echo 'max-width:'.($screenw-20).'px;';} ?>;background-color:<?php echo $gris1; ?>;">
				<tr style="border-top:solid 1px;border-bottom:solid 1px; cursor:pointer;" >
          <th onclick="sortTable(this,0);" style="display:none;"><?php  $ccol++; ?></th>
          
          <?php if(substr($pant,0,4)=='PANT'){?>
					<th onclick="sortTable(this,<?php echo $ccol++; ?>);" title="Imprimir">I</th>
          <?php } ?>
          
          <?php if($repo=='enti'){ ?>
					<th onclick="sortTable(this,<?php echo $ccol++; ?>,'N');" title="">#</th>
					<th onclick="sortTable(this,<?php echo $ccol++; ?>);" title=""><?php echo $entilabeltipo; ?></th>
					<th onclick="sortTable(this,<?php echo $ccol++; ?>);" title="">ENTIDAD</th>
					<th onclick="sortTable(this,<?php echo $ccol++; ?>);" title=""><?php echo $entilabel; ?></th>
					<th onclick="sortTable(this,<?php echo $ccol++; ?>);" title="" style="font-size:<?php echo $xfontsize*0.8;?>px;">RISE</th>
          <?php } ?>

          <?php if($repo=='item'){ ?>
					<th onclick="sortTable(this,<?php echo $ccol++; ?>,'N');" title="">#</th>
					<th onclick="sortTable(this,<?php echo $ccol++; ?>);" title="">LSUB</th>
					<th onclick="sortTable(this,<?php echo $ccol++; ?>);" title="">ITEM</th>
					<th onclick="sortTable(this,<?php echo $ccol++; ?>);" title="">PROD/SERV</th>
          <?php } ?>

          <?php if($repo=='docu'){ ?>
					<th onclick="sortTable(this,<?php echo $ccol++; ?>,'N');" title="">#</th>
					<th onclick="sortTable(this,<?php echo $ccol++; ?>);" title=""></th>
					<th onclick="sortTable(this,<?php echo $ccol++; ?>);" title="">DOCU</th>
					<th onclick="sortTable(this,<?php echo $ccol++; ?>);" title="">DESCRIP</th>
          <?php } ?>

          <?php if($repo=='rise'){ ?>
					<th onclick="sortTable(this,<?php echo $ccol++; ?>,'N');" title="">#</th>
					<th onclick="sortTable(this,<?php echo $ccol++; ?>);" title="">RISE</th>
					<th onclick="sortTable(this,<?php echo $ccol++; ?>);" title="">DOCU</th>
					<th onclick="sortTable(this,<?php echo $ccol++; ?>);" title="">DESCRIP</th>
          <?php } ?>

          <?php if($repo=='lsub'){ ?>
					<th onclick="sortTable(this,<?php echo $ccol++; ?>,'N');" title="">#</th>
					<th onclick="sortTable(this,<?php echo $ccol++; ?>);" title=""></th>
					<th onclick="sortTable(this,<?php echo $ccol++; ?>);" title="">LSUB</th>
					<th onclick="sortTable(this,<?php echo $ccol++; ?>);" title="">LINEAS</th>
          <?php } ?>

          <?php if($repo=='vndd'){ ?>
					<th onclick="sortTable(this,<?php echo $ccol++; ?>,'N');" title="">#</th>
					<th onclick="sortTable(this,<?php echo $ccol++; ?>);" title=""></th>
					<th onclick="sortTable(this,<?php echo $ccol++; ?>);" title="">VNDD</th>
					<th onclick="sortTable(this,<?php echo $ccol++; ?>);" title="">VENDEDOR</th>
          <?php } ?>
          
          <?php if($repo=='zsub'){ ?>
					<th onclick="sortTable(this,<?php echo $ccol++; ?>,'N');" title="">#</th>
					<th onclick="sortTable(this,<?php echo $ccol++; ?>);" title=""></th>
					<th onclick="sortTable(this,<?php echo $ccol++; ?>);" title="">ZSUB</th>
					<th onclick="sortTable(this,<?php echo $ccol++; ?>);" title="">ZONA</th>
          <?php } ?>

          <?php if($repo=='tpro'){ ?>
					<th onclick="sortTable(this,<?php echo $ccol++; ?>,'N');" title="">#</th>
					<th onclick="sortTable(this,<?php echo $ccol++; ?>);" title=""></th>
					<th onclick="sortTable(this,<?php echo $ccol++; ?>);" title="">TPRO</th>
					<th onclick="sortTable(this,<?php echo $ccol++; ?>);" title="">TIPO.PROV.</th>
          <?php } ?>

          <?php if($repo=='fmes'){ ?>
					<th onclick="sortTable(this,<?php echo $ccol++; ?>,'N');" title="">#</th>
					<th onclick="sortTable(this,<?php echo $ccol++; ?>);" title="">AÑO</th>
					<th onclick="sortTable(this,<?php echo $ccol++; ?>);" title="">MES</th>
					<th onclick="sortTable(this,<?php echo $ccol++; ?>);" title="">DESCRI</th>
          <?php } ?>

          <?php if($repo=='fsema'){ ?>
					<th onclick="sortTable(this,<?php echo $ccol++; ?>,'N');" title="">#</th>
					<th onclick="sortTable(this,<?php echo $ccol++; ?>);" title="">AÑO</th>
					<th onclick="sortTable(this,<?php echo $ccol++; ?>);" title="">SEMANA</th>
					<th onclick="sortTable(this,<?php echo $ccol++; ?>);" title="">DESCRI</th>
          <?php } ?>

          <?php if($repo=='fecha'){ ?>
					<th onclick="sortTable(this,<?php echo $ccol++; ?>,'N');" title="">#</th>
					<th onclick="sortTable(this,<?php echo $ccol++; ?>);" title="">DIA</th>
					<th onclick="sortTable(this,<?php echo $ccol++; ?>);" title="">FECHA</th>
					<th onclick="sortTable(this,<?php echo $ccol++; ?>);" title="">DESCRI</th>
          <?php } ?>

          <?php if($repo=='idnum1'){ ?>
					<th onclick="sortTable(this,<?php echo $ccol++; ?>);" title="">DOCU</th>
					<th onclick="sortTable(this,<?php echo $ccol++; ?>);" title="">NUMERO</th>
					<th onclick="sortTable(this,<?php echo $ccol++; ?>);" title="">FECHA</th>
					<th onclick="sortTable(this,<?php echo $ccol++; ?>);" title="">ENTI</th>
					<th onclick="sortTable(this,<?php echo $ccol++; ?>);" title=""><?php echo $entilabel; ?></th>
          <?php } ?>

          <?php if($repo=='iddet'){ ?>
					<th onclick="sortTable(this,<?php echo $ccol++; ?>);" title="">DOCU</th>
					<th onclick="sortTable(this,<?php echo $ccol++; ?>);" title="">NUMERO</th>
					<th onclick="sortTable(this,<?php echo $ccol++; ?>);" title="">FECHA</th>
					<th onclick="sortTable(this,<?php echo $ccol++; ?>);" title="">ITEM</th>
					<th onclick="sortTable(this,<?php echo $ccol++; ?>);" title="">DESCRIP</th>
					<th onclick="sortTable(this,<?php echo $ccol++; ?>,'N');" style="<?php echo 'font-size:'.($xfontsize*0.8).';'?>" title="">P.UNIT</th>
          <?php } ?>

          <?php if(mb_stristr('ctas',$repo)){ ?>
					<th onclick="sortTable(this,<?php echo $ccol++; ?>,'N');" title="">#</th>
					<th onclick="sortTable(this,<?php echo $ccol++; ?>);" title=""></th>
					<th onclick="sortTable(this,<?php echo $ccol++; ?>);" title="">CODIGO</th>
					<th onclick="sortTable(this,<?php echo $ccol++; ?>);" title="">CUENTA</th>
          <?php } ?>

          <?php if(mb_stristr('cair',$repo)){ ?>
					<th onclick="sortTable(this,<?php echo $ccol++; ?>,'N');" title="">#</th>
					<th onclick="sortTable(this,<?php echo $ccol++; ?>);" title=""></th>
					<th onclick="sortTable(this,<?php echo $ccol++; ?>);" title="">CODIGO</th>
					<th onclick="sortTable(this,<?php echo $ccol++; ?>);" title="">IMP. RTA.</th>
          <?php } ?>

          <?php if(mb_stristr('suco',$repo)){ ?>
					<th onclick="sortTable(this,<?php echo $ccol++; ?>,'N');" title="">#</th>
					<th onclick="sortTable(this,<?php echo $ccol++; ?>);" title=""></th>
					<th onclick="sortTable(this,<?php echo $ccol++; ?>);" title="">CODIGO</th>
					<th onclick="sortTable(this,<?php echo $ccol++; ?>);" title="">SUST.COMP.</th>
          <?php } ?>

					<?php if($docuiimp==1 or 1==1){?>
						<th onclick="sortTable(this,<?php echo $ccol++; ?>,'N');" style="<?php if($tcant==0){echo'display:;';}?> <?php echo 'font-size:'.($xfontsize*0.8).'; ' ?>">CANT.</th>	
						<th onclick="sortTable(this,<?php echo $ccol++; ?>,'N');" style="<?php if($tdcto==0){echo'display:;';}?> <?php echo 'font-size:'.($xfontsize*0.8).'; ' ?>">SUB-TOTAL</th>	
						<th onclick="sortTable(this,<?php echo $ccol++; ?>,'N');" style="<?php if($tdcto==0){echo'display:none;';}?> <?php echo 'font-size:'.($xfontsize*0.8).'; text-decoration:underline;' ?>">DCTO</th>	
						<th onclick="sortTable(this,<?php echo $ccol++; ?>,'N');" style="<?php if($tssid==0){echo'display:none;';}?> <?php echo 'font-size:'.($xfontsize*0.8).'; text-decoration:underline;' ?>">SSID</th>	
						<th onclick="sortTable(this,<?php echo $ccol++; ?>,'N');" style="<?php if($tice==0){echo'display:none;';}?> <?php echo 'font-size:'.($xfontsize*0.8).'; font-style:italic;' ?> ">ICE</th>	
						<th onclick="sortTable(this,<?php echo $ccol++; ?>,'N');" 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++; ?>,'N');" 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++; ?>,'N');" style="<?php if($tprop==0){echo'display:none;';}?> <?php echo 'font-size:'.($xfontsize*0.8).';' ?>">PROP</th>	
						<th onclick="sortTable(this,<?php echo $ccol++; ?>,'N');" style="<?php if($tiva==0){echo'display:none;';}?> <?php echo 'font-size:'.($xfontsize*0.8).'; font-style:italic;' ?>">IVA</th>	
						<th onclick="sortTable(this,<?php echo $ccol++; ?>,'N');" style="<?php if($tirbp==0){echo'display:none;';}?> <?php echo 'font-size:'.($xfontsize*0.8).'; font-style:italic;' ?>">IRBP</th>
					<?php }?>
          
					<th onclick="sortTable(this,<?php echo $ccol++; ?>,'N');" title="">TOTAL</th>
					<th onclick="sortTable(this,<?php echo $ccol++; ?>,'N');" title="Participación">%</th>

              <?php if($modu=='VTAS' and mb_stristr('fmes.fsema.fecha',$repo)){ ?>
    					<th onclick="sortTable(this,<?php echo $ccol++; ?>,'N');" title="Crecimiento">%</th>
                
              <?php } ?>
              
          
          <?php if($modu=='VTAS' and $ver_cost==1){ ?>
          <?php if($repo=='iddet'){ ?> 
					<th onclick="sortTable(this,<?php echo $ccol++; ?>,'N');">C.UNIT</th>
          <?php } ?>
					<th onclick="sortTable(this,<?php echo $ccol++; ?>,'N');">COSTO</th>
					<th onclick="sortTable(this,<?php echo $ccol++; ?>,'N');">UTIL.B.</th>
					<th onclick="sortTable(this,<?php echo $ccol++; ?>,'N');" titlte="Utilidad">%</th>
          <?php } ?>
          
          
          <th style="font-size:<?php echo $xfontsize*.5;?>px;" title="Descargar XLS">
            <a href="#" id="downxls1" onClick="javascript:fnExcelReport('tpant1',this,'<?php echo $cfg_empr.'_'.$modu.'_'.date('Ymd_His');?>');">XLS</a>
          </th>
				</tr>
			</thead>
			<?php } ?>
      <?php $timew1=date('U'); ?>

      <?php //die();?>
      
			<?php  {// TBODY ?>
			<tbody id="tpant1b" valign="top" style="overflow-y:auto; <?php echo $tdisplay; ?>; 
							<?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 if(@mysql_num_rows($res_pant)==0){?>
          <tr><td style="font-weight:bold;">
            <?php echo 'NO HAY DATOS'; ?>  
            <?php echo '<br>==>'.date('H:i:s'); ?>
            <?php //echo '<br>'.$docu.' /'.$enti; ?>
          </td></tr>
        <?php }?>
        <?php if($user_cons==0){?>
          <tr><td style="font-weight:bold;color:red;">NO TIENE ACCESO PARA CONSULTAR ==> <?php echo $modu.' - '.r_fiel('modu',$modu);?></td></tr>
        <?php }?>

        <?php $last_codi=''; ?>
        <?php $last_idnum='';?>
        <?php $last_base=0; ?>
        <?php $last_niv1=0; ?>
        <?php $cctas=0; ?>
        <?php $xdocusal0=''; ?>
        
            <?php while($aso_pant=@mysql_fetch_assoc($res_pant)){ ?>
            <?php $status=$aso_pant['status']; ?>
            <?php $id_trfila=fillzero($crow);?> 
            <?php $lineaok=1;?>
              <?php $xidnum =$aso_pant['idnum1'];?>
        
              <?php $xdocum =$aso_pant['docum'];?>
              <?php $xptoem =$aso_pant['ptoem'];?>
              <?php $xnumer =$aso_pant['numer'];?>
        
            <?php $duni =$aso_pant['item_duni']; ?>
            <?php $dpre =$aso_pant['item_dpre']; ?>
            <?php $dcos =$aso_pant['item_dcos']; ?>
              
              <?php if($repo=='enti'){ ?>
                <?php if(mb_stristr('VTAS.CLIE',$modu)){$xtipo=@$aso_pant['zsub_descri'];}?>
                <?php if(mb_stristr('COMP.PROV',$modu)){$xtipo=@$aso_pant['tpro_descri'];}?>
                <?php $xcodi=@$aso_pant['enti'];?>
                <?php $xdesc=@$aso_pant['enti_descri'];?>
              <?php } ?>
        
              <?php if($repo=='item'){ ?>
                <?php $xtipo=@$aso_pant['lsub'];?>
                <?php $xcodi=@$aso_pant['item'];?>
                <?php $xdesc=@$aso_pant['item_descri'];?>
              <?php } ?>
        
              <?php if($repo=='lsub'){ ?>
                <?php $xtipo=@$aso_pant[''];?>
                <?php $xcodi=@$aso_pant['item_lsub'];?>
                <?php $xdesc=@$aso_pant['lsub_descri'];?>
              <?php } ?>
        
              <?php if($repo=='docu'){ ?>
                <?php $xtipo=@$aso_pant[''];?>
                <?php $xcodi=@$aso_pant['docu'];?>
                <?php $xdesc=@$aso_pant['docu_descri'];?>
              <?php } ?>
        
              <?php if($repo=='rise'){ ?>
                <?php $xtipo=@$aso_pant['enti_rise'];?>
                <?php $xcodi=@$aso_pant['docu'];?>
                <?php $xdesc=@$aso_pant['docu_descri'];?>
                <?php if($xtipo==1){$xtipo='SI';}else{$xtipo='NO';} ?>
              <?php } ?>
        
              <?php if($repo=='vndd'){ ?>
                <?php $xtipo=@$aso_pant[''];?>
                <?php $xcodi=@$aso_pant['vndd'];?>
                <?php $xdesc=@$aso_pant['vndd_descri'];?>
              <?php } ?>
        
              <?php if(mb_stristr('ptoe.ptov',$repo)){ ?>
                <?php $xtipo=@substr($aso_pant['ptoe'],0,3);?>
                <?php $xcodi=@substr($aso_pant['ptoe'],3,3);?>
                <?php $xdesc=r_fiel('ptoe',$aso_pant['ptoe']);?>
              <?php } ?>
        
              <?php if($repo=='zsub'){ ?>
                <?php $xtipo=@$aso_pant[''];?>
                <?php $xcodi=@$aso_pant['zsub'];?>
                <?php $xdesc=@$aso_pant['zsub_descri'];?>
              <?php } ?>
        
              <?php if($repo=='tpro'){ ?>
                <?php $xtipo=@$aso_pant[''];?>
                <?php $xcodi=@$aso_pant['enti_tpro'];?>
                <?php $xdesc=@$aso_pant['tpro_descri'];?>
              <?php } ?>
        
              <?php if($repo=='ctas'){ ?>
                <?php $xtipo=@$aso_pant[''];?>
                <?php $xcodi=@$aso_pant['ctas'];?>
                <?php $xdesc=@$aso_pant['ctas_descri'];?>
              <?php } ?>
        
              <?php if($repo=='cair'){ ?>
                <?php $xtipo=@$aso_pant[''];?>
                <?php $xcodi=@$aso_pant['cair'];?>
                <?php $xdesc=@$aso_pant['cair_descri'];?>
              <?php } ?>
        
              <?php if($repo=='suco'){ ?>
                <?php $xtipo=@$aso_pant[''];?>
                <?php $xcodi=@$aso_pant['suco'];?>
                <?php $xdesc=@$aso_pant['suco_descri'];?>
              <?php } ?>
        
              <?php if($repo=='idnum1' or  $repo=='iddet'){ ?>
                <?php $xtipo=@$aso_pant['docu'];?>
                <?php $xcodi=@$aso_pant['numero'];?>
                <?php $xdesc=@$aso_pant['fecha'];?>
              <?php } ?>
        
              <?php if($repo=='fmes'){ ?>
                <?php $xtipo=@$aso_pant['fanio'];?>
                <?php $xcodi=@$aso_pant['fmes'];?>
                <?php $xdesc=@date('M / Y' ,strtotime($aso_pant['fecha']));?>
              <?php } ?>
        
              <?php if($repo=='fsema'){ ?>
                <?php $xtipo=@$aso_pant['fanio'];?>
                <?php $xcodi=@$aso_pant['fsema'];?>
                <?php $xdesc=@$aso_pant['fanio'].' /'.@$aso_pant['fsema'];?>
              <?php } ?>
        
              <?php if($repo=='fecha'){ ?>
                <?php $xtipo=@date('z' ,strtotime($aso_pant['fecha']));?>
                <?php $xtipo=@fillzero(date('z' ,strtotime($aso_pant['fecha'])),3);?>
                <?php $xcodi=@$aso_pant['fecha'];?>
                <?php $xdesc=@date('N-D' ,strtotime($aso_pant['fecha']));?>
              <?php } ?>

              <?php if(empty($xdesc))
              {$xdesc='<a href="?prnt=1&docu='.@$aso_pant['docu'].'&idnum='.@$aso_pant['idnum1'].'&formato=" target="_blank">'.@$aso_pant['docu'].'-'.@$aso_pant['numero'].'</a>';} ?>

              <?php $xdesclen=strlen($xdesc);?>
              <?php $xsaldoi=$aso_pant['saldoi']; ?>
              <?php $xtdeb=$aso_pant['stdebito']; ?>
              <?php $xtcre=$aso_pant['stcredito']; ?>
              <?php $xsaldo=$aso_pant['saldo']; ?>
              <?php $xnivel =$aso_pant['nivel']; ?>
              <?php $xtotal =$aso_pant['stotal']; ?>
              <?php $xvarval=$xsaldo-$xsaldoi; ?>
              <?php $xvarpor=0; ?>
              <?php $xsaldoc=0; ?>
              <?php if($xsaldoi!=0){$xvarpor=($xvarval/$xsaldoi)*100;} ?>

              <?php if($total!=0){$xporpar=($xtotal/$total)*100; $tporpar+=$xporpar;} ?>
        
        
            <?php echo '<div></div>'; ?>
        
            <?php if($lineaok==1){ ?>
            <?php $last_codi=$xcodi; ?>
            <?php $crow++; ?> 
            <?php $clin++; ?> 
        
            <tr id="tr_fila<?php echo $crow;?>" class="tr_fila" 
                style="
                       <?php if($clin%5==0){echo 'border-bottom:dotted 1px;'; } ?>
                       "
                <?php if(substr($pant,0,1)=='P'){?> 
                onmouseover="_filabg(event,'tr_fila','<?php echo $crow; ?>','');"
                <?php } ?>
                onclick="_filabg(event,'tr_fila','<?php echo $crow; ?>','');
                        <?php //if(substr($pant,0,1)=='P' and $repo=='enti'){?> 
                        <?php if(substr($pant,0,1)=='P' and $repo!='lldd'){?> 
                         <?php
                         $ponclick='';
                         $ponclick.='document.getElementById("'.$repo.'").value="'.$aso_pant[$repo].'";';
                         $ponclick.='info_docu("PANT1",'.'document.getElementById("modu").value'.');'; 
                         $ponclick.='document.getElementById("'.$repo.'").value="";';
                         $ponclick=str_replace('"',"'",$ponclick);                                                                        
                         echo $ponclick; 
                         ?>
                        <?php } ?> 
                         "
                >
<!--                         {info_modu('PANT2','<?php //echo //$modu; ?>','<?php //echo //$xcodi; ?>');} -->
              
                <td style="display:none;"><?php echo fillzero($crow,5); ?></td>
  
              
              
              
              <?php if(substr($pant,0,4)=='PANT'){ ?>
                <td>
                <?php

  
                 if(mb_stristr('idnum1.iddet',$repo))
                 {
                  $idocu=$aso_pant['docu'];
                  $iidnum=$aso_pant['idnum1'];
                  $pidtxt='i_'.$crow; 
                  $psize=$xfontsize;
                  $pcaption='Imprimir';
                  $pabrev='I';
//                   {$ponclick='{window.open("?prnt=1&clave='.$claveacce.'","_blank")}';}
                  {$ponclick='{window.open("?prnt=1&docu='.$idocu.'&idnum='.$iidnum.'","_blank")}';}
                  if(mb_stristr($pant,'PANT') and $mobile!='true'){include('vrbutton.php');}
                 }
                 else
                 {
                  $pidtxt='imprim'; $pcaption='Imprimir'; $pabrev='I';
                  $ponclick='';
                  $ponclick.='document.getElementById("'.$repo.'").value="'.$aso_pant[$repo].'";';
                  $ponclick.='info_docu("IMPR1",'.'document.getElementById("modu").value'.');'; 
                  $ponclick.='document.getElementById("'.$repo.'").value="";';
                  $psize=$xfontsize; 
                  if(mb_stristr($pant,'PANT') and $mobile!='true'){include('vrbutton.php');}
                 }
  
                ?>
                </td>  
              <?php } ?>
              
                <?php //if($repo=='enti') { ?>
                <?php { ?>
                <?php if($repo!='idnum1' and $repo!='iddet'){?>
                <td align="center" style="">
                  <?php echo $aso_pant['cidnum1']; ?>
                </td>	
                <?php } ?>
                <td align="center" style="">
                  <?php echo $xtipo; ?>
                </td>	
                <td align="<?php if(mb_stristr('enti.fmes.fsema.fecha.zsub.tpro.cair.suco',$repo)){echo 'center';} ?>" style="">
                  <?php if(mb_stristr('fmes.fsema.fecha',$repo)){ ?>
                      <div style="display:none;"><?php echo $xtipo; ?></div>
                  <?php } ?>
                  <?php echo $xcodi; ?>
                </td>	
                <td align="<?php if(mb_stristr('fmes.fsema.fecha.idnum1.',$repo)){echo 'center';} ?>" style="border-right:solid 1px;">
                  <?php if(mb_stristr('fmes.fsema.',$repo)){ ?>
                      <div style="display:none;"><?php echo $xcodi.$xtipo; ?></div>
                  <?php } ?>
                  <?php if(substr($pant,0,4)=='PANT'){echo split_words($xdesc);} else {echo $xdesc;} ?>
                  <?php //echo split_words($xdesc); ?>
                  <?php if(mb_stristr('fecha.idnum1',$repo)){ ?>
                      <div style="display:none;"><?php echo $xcodi.$xtipo; ?></div>
                  <?php } ?>
                </td>	
                <?php } ?>
              
                <?php if($repo=='idnum1'){ ?>
                  <td align="center" style="">
                    <?php echo $aso_pant['enti']; ?>
                  </td>	
                  <td align="" style="border-right:dotted 1px;">
                  <?php if(substr($pant,0,4)=='PANT'){echo split_words($aso_pant['enti_descri']);} else {echo $aso_pant['enti_descri'];} ?>
                    <?php //echo split_words($aso_pant['enti_descri']); ?>
                  </td>	
                <?php } ?>

                <?php if($repo=='iddet'){ ?>
                  <td align="center" style="">
                    <?php echo $aso_pant['item']; ?>
                  </td>	
                  <td align="" style="border-right:dotted 1px;">
                  <?php if(substr($pant,0,4)=='PANT'){echo split_words($aso_pant['item_descri']);} else {echo $aso_pant['item_descri'];} ?>
                  </td>	
                  <td align="right" style="<?php if($tcant==0){echo'display:;';}else{echo'';}?> ">
                    <?php echo number_format(($aso_pant['puni']),$dpre); ?>
                  </td>	
                <?php } ?>

                <?php if($repo=='enti'){ ?>
                  <td align="center" style="">
                    <?php if($aso_pant['enti_rise']==1){echo 'S';}else{echo 'N';}; ?>
                  </td>	
                <?php } ?>

                <?php if($docuiimp){ ?>
                  <td align="right" style="<?php if($tcant==0){echo'display:;';}else{echo'';}?> ">
                    <?php echo number_format(($aso_pant['stcant']),2); ?>
                  </td>	
                  <td align="right" style="<?php if($tdcto==0){echo'display:;';}else{echo'';}?> ">
                    <?php echo number_format(($aso_pant['stsubt']),2); ?>
                  </td>	
                  <td align="right" style="<?php if($tdcto==0){echo'display:none;';}else{echo'text-decoration:underline;';}?> font-style:italic;">
                    <?php echo number_format(($aso_pant['stdcto']),2); ?>
                  </td>	
                  <td align="right" style="<?php if($tssid==0){echo'display:none;';}else{echo'text-decoration:underline;';}?> font-style:italic;">
                    <?php echo number_format(($aso_pant['stssid']),2); ?>
                  </td>	
                  <td align="right" style="<?php if($tice==0){echo'display:none;';}?> font-style:italic;">
                    <?php echo number_format(($aso_pant['stice']),2); ?>
                  </td>	
                  <td align="right" style="<?php if($tsubtiva0==0){echo'display:none;';}?>">
                    <?php echo number_format(($aso_pant['stsubtiva0']),2); ?>
                  </td>	
                  <td align="right" style="<?php if($tsubtiva==0){echo'display:none;';}?>">
                    <?php echo number_format(($aso_pant['stsubtiva']),2); ?>
                  </td>	
                  <td align="right" style="<?php if($tprop==0){echo'display:none;';}?> font-style:italic;">
                    <?php echo number_format(($aso_pant['stprop']),2); ?>
                  </td>	
                  <td align="right" style="<?php if($tiva==0){echo'display:none;';}?> font-style:italic;">
                    <?php echo number_format(($aso_pant['stiva']),2); ?>
                  </td>	
                  <td align="right" style="<?php if($tirbp==0){echo'display:none;';}?> font-style:italic;">
                    <?php echo number_format(($aso_pant['stirbp']),2); ?>
                  </td>	
              <?php } ?>

              
              <td align="right" style="font-weight:bold;"> 
                <?php echo number_format(($aso_pant['stotal']),2); ?>
              </td>
              
              <td align="right" style="font-weight:bold;"> 
                <?php echo number_format(($xporpar),2).'%'; ?>
              </td>

              <?php if($modu=='VTAS' and mb_stristr('fmes.fsema.fecha',$repo)){ ?>
              <?php if($totalante!=0){$xporcre=(($aso_pant['stotal']/$totalante)-1)*100;}?>
              <?php $totalante=$aso_pant['stotal']; ?>
              <td align="right" style="font-weight:bold;"> 
                <?php echo number_format(($xporcre),2).'%'; ?>
              </td>
              <?php } ?>
              
              <?php if($modu=='VTAS' and $ver_cost==1){ ?>
              <?php if($repo=='iddet'){?>
                <td align="right"> 
                  <?php echo number_format(($aso_pant['cuni']),$dcos); ?>
                </td>
              <?php } ?>
                <td align="right"> 
                  <?php echo number_format(($aso_pant['stcuni']),2); ?>
                </td>
                <td align="right" style="font-weight:bold;"> 
                  <?php echo number_format(($aso_pant['stutil']),2); ?>
                </td>
                <td align="right" style="font-weight:bold;"> 
                  <?php echo number_format(($aso_pant['stutil'])/$aso_pant['stotal']*100,2).'%'; ?>
                </td>
              <?php } ?>

              
            </tr>
              <?php } 
            ?>
            <?php } ?>
        
        
			</tbody>
		<?php } ?>	
  
      <?php $timew2=date('U'); ?>
      <?php $ccolbak=$ccol; ?>
      <?php { // FOOT ?>
			<tfoot style="<?php echo $tdisplay; ?><?php if($mobile!='true'){echo 'max-width:'.($screenw-20).'px;';} ?>;background-color:<?php echo $gris1; ?>; font-size:<?php echo $xfontsize*1;?>px;">
				<tr style="border-top:solid 1px;border-bottom:solid 1px;">
          <th style="display:none;"<?php $ccol--; ?>></th>

          <?php if(substr($pant,0,4)=='PANT'){?>
					<th <?php $ccol--; ?>></th>
          <?php } ?>
          
          <?php if($repo!='idnum1' and $repo!='iddet'){?>
          <th <?php $ccol--; ?>> <?php echo $tcidnum1; ?></th>
          <?php } ?>
          

          <?php if(mb_stristr('enti.item.docu.vndd.zsub.lsub.tpro,rise.fmes.fsema.fecha.ptov.ptoe.idnum1.ctas.cair.iva.porc',$repo)){ ?>
            <th <?php $ccol--; ?>></th>
            <th <?php $ccol--; ?>><?php echo $crow; ?></th>
          <?php } ?>
          
          <?php if(mb_stristr('idnum1.',$repo)){ ?>
            <th <?php $ccol--; ?>></th>
            <th <?php $ccol--; ?>></th>
          <?php } ?>
          
          <?php if(mb_stristr('.iddet',$repo)){ ?>
            <th <?php $ccol--; ?>></th>
            <th <?php $ccol--; ?>></th>
            <th <?php $ccol--; ?>></th>
            <th <?php $ccol--; ?>></th>
          <?php } ?>
          
					<th <?php $ccol--; ?> style="max-width:;letter-spacing:5px; ">TOTALES</th>
          
          <?php if(mb_stristr('enti',$repo)){ ?>
            <th <?php $ccol--; ?>></th>
          <?php } ?>
          

            
					<?php //if($docuiimp==1){ ?>
					<?php if(mb_stristr('VTAS.CLIE.CARR.COMP.PROV',$modu)){ ?>
            <?php if(mb_stristr('iddet',$repo)){ ?>
              <th <?php $ccol--; ?>></th>
            <?php } ?>
          
						<th <?php $ccol--; ?>align="right" style="<?php if($tcant==0){echo'display:;';}?> ">
							<?php echo number_format(abs($tcant),2); ?>
						</th>	
						<th <?php $ccol--; ?>align="right" style="<?php if($tdcto==0){echo'display:;';}?> ">
							<?php echo number_format(abs($tsubt),2); ?>
						</th>	
						<th <?php $ccol--; ?>align="right" style="<?php if($tdcto==0){echo'display:none;';}?> font-style:italic;text-decoration:underline;">
							<?php echo number_format(abs($tdcto),2); ?>
						</th>	
						<th <?php $ccol--; ?>align="right" style="<?php if($tssid==0){echo'display:none;';}?> font-style:italic;text-decoration:underline;">
							<?php echo number_format(abs($tssid),2); ?>
						</th>	
						<th <?php $ccol--; ?>align="right" style="<?php if($tice==0){echo'display:none;';}?> font-style:italic;">
							<?php echo number_format(abs($tice),2); ?>
						</th>	
						<th <?php $ccol--; ?>align="right" style="<?php if($tsubtiva0==0){echo'display:none;';}?>">
							<?php echo number_format(abs($tsubtiva0),2); ?>
						</th>
						<th <?php $ccol--; ?>align="right" style="<?php if($tsubtiva==0){echo'display:none;';}?>">
							<?php echo number_format(abs($tsubtiva),2); ?>
						</th>	
						<th <?php $ccol--; ?>align="right" style="<?php if($tprop==0){echo'display:none;';}?> font-style:italic;">
							<?php echo number_format(abs($tprop),2); ?>
						</th>	
						<th <?php $ccol--; ?>align="right" style="<?php if($tiva==0){echo'display:none;';}?> font-style:italic;">
							<?php echo number_format(abs($tiva),2); ?>
						</th>	
						<th <?php $ccol--; ?>align="right" style="<?php if($tirbp==0){echo'display:none;';}?> font-style:italic;">
							<?php echo number_format(abs($tirbp),2); ?>
						</th>	
            <?php //$tsaldo=$total;?>
				<?php } ?>
          
          
          
					<th <?php $ccol--; ?> align="right">
						<?php echo number_format($total,2); ?>
					</th>
          
					<th <?php $ccol--; ?> align="right">
						<?php echo number_format($tporpar,2).'%'; ?>
					</th>
          
              <?php if($modu=='VTAS' and mb_stristr('fmes.fsema.fecha',$repo)){ ?>
                <th><?php $ccol--; ?></th>
              <?php } ?>
          
              <?php if(mb_stristr('VTAS.COMP.CLIE.CARR.PROV',$modu) and $ver_cost==1){ ?>
              <?php if($repo=='iddet'){ ?>
                <th><?php $ccol--; ?></th>
              <?php } ?>
                <th align="right" style=""> 
                  <?php echo number_format($tcuni,2); ?>
                </th>
                <th align="right" style=""> 
                  <?php echo number_format($tutil,2); ?>
                </th>
                <th align="right" style=""> 
                  <?php echo number_format($tutil/$total*100,2).'%'; ?>
                </th>
              <?php } ?>

          
          
          
          <?php if($ccol<0){$ccol=0;}?>
          <?php if(mb_stristr($pant,'PANT')){?>
          <?php echo str_repeat('<th></th>',$ccol); ?>
          <?php } ?>
				</tr>

        <?php $ccol=$ccolbak; ?>
        
				<tr style="border-top:solid 1px;border-bottom:solid 1px;">
          <th style="display:none;"<?php $ccol--; ?>></th>

          <?php if(substr($pant,0,4)=='PANT'){?>
					<th <?php $ccol--; ?>></th>
          <?php } ?>
          
          <?php if($repo!='idnum1' and $repo!='iddet'){?>
          <th <?php $ccol--; ?>> <?php echo number_format($tcidnum1/$crow,0); ?></th>
          <?php } ?>
          

          <?php if(mb_stristr('enti.item.docu.vndd.zsub.lsub.tpro,rise.fmes.fsema.fecha.ptov.ptoe.idnum1.ctas.cair.iva.porc',$repo)){ ?>
            <th <?php $ccol--; ?>></th>
            <th <?php $ccol--; ?>><?php //echo $crow; ?></th>
          <?php } ?>
          
          <?php if(mb_stristr('idnum1.',$repo)){ ?>
            <th <?php $ccol--; ?>></th>
            <th <?php $ccol--; ?>></th>
          <?php } ?>
          
          <?php if(mb_stristr('.iddet',$repo)){ ?>
            <th <?php $ccol--; ?>></th>
            <th <?php $ccol--; ?>></th>
            <th <?php $ccol--; ?>></th>
            <th <?php $ccol--; ?>></th>
          <?php } ?>
          
					<th <?php $ccol--; ?> style="max-width:;letter-spacing:5px; ">PROMEDIOS</th>
          
          <?php if(mb_stristr('enti',$repo)){ ?>
            <th <?php $ccol--; ?>></th>
          <?php } ?>
          

            
					<?php //if($docuiimp==1){ ?>
					<?php if(mb_stristr('VTAS.CLIE.CARR.COMP.PROV',$modu)){ ?>
            <?php if(mb_stristr('iddet',$repo)){ ?>
              <th <?php $ccol--; ?>></th>
            <?php } ?>
          
						<th <?php $ccol--; ?>align="right" style="<?php if($tcant==0){echo'display:;';}?> ">
							<?php echo number_format(abs($tcant/$crow),2); ?>
						</th>	
						<th <?php $ccol--; ?>align="right" style="<?php if($tdcto==0){echo'display:;';}?> ">
							<?php echo number_format(abs($tsubt/$crow),2); ?>
						</th>	
						<th <?php $ccol--; ?>align="right" style="<?php if($tdcto==0){echo'display:none;';}?> font-style:italic;text-decoration:underline;">
							<?php echo number_format(abs($tdcto/$crow),2); ?>
						</th>	
						<th <?php $ccol--; ?>align="right" style="<?php if($tssid==0){echo'display:none;';}?> font-style:italic;text-decoration:underline;">
							<?php echo number_format(abs($tssid/$crow),2); ?>
						</th>	
						<th <?php $ccol--; ?>align="right" style="<?php if($tice==0){echo'display:none;';}?> font-style:italic;">
							<?php echo number_format(abs($tice/$crow),2); ?>
						</th>	
						<th <?php $ccol--; ?>align="right" style="<?php if($tsubtiva0==0){echo'display:none;';}?>">
							<?php echo number_format(abs($tsubtiva0/$crow),2); ?>
						</th>
						<th <?php $ccol--; ?>align="right" style="<?php if($tsubtiva==0){echo'display:none;';}?>">
							<?php echo number_format(abs($tsubtiva/$crow),2); ?>
						</th>	
						<th <?php $ccol--; ?>align="right" style="<?php if($tprop==0){echo'display:none;';}?> font-style:italic;">
							<?php echo number_format(abs($tprop/$crow),2); ?>
						</th>	
						<th <?php $ccol--; ?>align="right" style="<?php if($tiva==0){echo'display:none;';}?> font-style:italic;">
							<?php echo number_format(abs($tiva/$crow),2); ?>
						</th>	
						<th <?php $ccol--; ?>align="right" style="<?php if($tirbp==0){echo'display:none;';}?> font-style:italic;">
							<?php echo number_format(abs($tirbp/$crow),2); ?>
						</th>	
            <?php //$tsaldo=$total;?>
				<?php } ?>
          
          
          
					<th <?php $ccol--; ?> align="right">
						<?php echo number_format($total/$crow,2); ?>
					</th>
          
					<th <?php $ccol--; ?> align="right">
						<?php echo number_format($tporpar/$crow,2).'%'; ?>
					</th>
          
              <?php if($modu=='VTAS' and mb_stristr('fmes.fsema.fecha',$repo)){ ?>
                <th><?php $ccol--; ?></th>
              <?php } ?>
          
              <?php if(mb_stristr('VTAS.COMP.CLIE.CARR.PROV',$modu) and $ver_cost==1){ ?>
              <?php if($repo=='iddet'){ ?>
                <th><?php $ccol--; ?></th>
              <?php } ?>
                <th align="right" style=""> 
                  <?php echo number_format($tcuni/$crow,2); ?>
                </th>
                <th align="right" style=""> 
                  <?php echo number_format($tutil/$crow,2); ?>
                </th>
                <th align="right" style=""> 
                  <?php echo number_format($tutil/$total*100/$crow,2).'%'; ?>
                </th>
              <?php } ?>

          
          
          
          <?php if($ccol<0){$ccol=0;}?>
          <?php if(mb_stristr($pant,'PANT')){?>
          <?php echo str_repeat('<th></th>',$ccol); ?>
          <?php } ?>
				</tr>
        
			</tfoot>
			<?php } ?>	
		</table>
  
<?php } ?>
  
<?php if(mb_stristr('NOMI',$modu)){ ?>  
		<table id="tpant1" class="pant1" border="0"
					 align="center" cellpadding="3" width="100%"
					 style="font-size:<?php if($orient=='V'){echo $xfontsize-8;}else{echo $xfontsize;} ?>px;
						border-collapse:collapse;background-color:snow; position:; <?php if($pant=='IMPR' and 1==2 ){echo 'max-width:210mm;';}?>"
						>
			<?php { // THEAD ?>
			<thead style="<?php echo $tdisplay; ?><?php if($mobile!='true'){echo 'max-width:'.($screenw-20).'px;';} ?>;background-color:<?php echo $gris1; ?>;">
				<tr style="border-top:solid 1px;border-bottom:solid 1px; cursor:pointer;" >
          <th onclick="sortTable(this,0);" style="display:none;"><?php  $ccol++; ?></th>
          
          <?php if(substr($pant,0,4)=='PANT'){?>
					<th onclick="sortTable(this,<?php echo $ccol++; ?>);" title="Imprimir">I</th>
          <?php } ?>
          
          <?php if($repo=='enti'){ ?>
					<th onclick="sortTable(this,<?php echo $ccol++; ?>,'N');" title="">#</th>
					<th onclick="sortTable(this,<?php echo $ccol++; ?>);" title=""><?php echo $entilabeltipo; ?></th>
					<th onclick="sortTable(this,<?php echo $ccol++; ?>);" title="">ENTIDAD</th>
					<th onclick="sortTable(this,<?php echo $ccol++; ?>);" title=""><?php echo $entilabel; ?></th>
          <?php } ?>

          <?php if($repo=='nvdd'){ ?>
					<th onclick="sortTable(this,<?php echo $ccol++; ?>,'N');" title="">#</th>
					<th onclick="sortTable(this,<?php echo $ccol++; ?>);" title=""></th>
					<th onclick="sortTable(this,<?php echo $ccol++; ?>);" title="">NVDD</th>
					<th onclick="sortTable(this,<?php echo $ccol++; ?>);" title="">NOVEDAD</th>
          <?php } ?>

          <?php if($repo=='docu'){ ?>
					<th onclick="sortTable(this,<?php echo $ccol++; ?>,'N');" title="">#</th>
					<th onclick="sortTable(this,<?php echo $ccol++; ?>);" title=""></th>
					<th onclick="sortTable(this,<?php echo $ccol++; ?>);" title="">DOCU</th>
					<th onclick="sortTable(this,<?php echo $ccol++; ?>);" title="">DESCRIP</th>
          <?php } ?>


          <?php if($repo=='csub'){ ?>
					<th onclick="sortTable(this,<?php echo $ccol++; ?>,'N');" title="">#</th>
					<th onclick="sortTable(this,<?php echo $ccol++; ?>);" title=""></th>
					<th onclick="sortTable(this,<?php echo $ccol++; ?>);" title="">CSUB</th>
					<th onclick="sortTable(this,<?php echo $ccol++; ?>);" title="">CENTROS</th>
          <?php } ?>


          <?php if($repo=='fmes'){ ?>
					<th onclick="sortTable(this,<?php echo $ccol++; ?>,'N');" title="">#</th>
					<th onclick="sortTable(this,<?php echo $ccol++; ?>);" title="">AÑO</th>
					<th onclick="sortTable(this,<?php echo $ccol++; ?>);" title="">MES</th>
					<th onclick="sortTable(this,<?php echo $ccol++; ?>);" title="">DESCRI</th>
          <?php } ?>

          <?php if($repo=='fsema'){ ?>
					<th onclick="sortTable(this,<?php echo $ccol++; ?>,'N');" title="">#</th>
					<th onclick="sortTable(this,<?php echo $ccol++; ?>);" title="">AÑO</th>
					<th onclick="sortTable(this,<?php echo $ccol++; ?>);" title="">SEMANA</th>
					<th onclick="sortTable(this,<?php echo $ccol++; ?>);" title="">DESCRI</th>
          <?php } ?>

          <?php if($repo=='fecha'){ ?>
					<th onclick="sortTable(this,<?php echo $ccol++; ?>,'N');" title="">#</th>
					<th onclick="sortTable(this,<?php echo $ccol++; ?>);" title="">DIA</th>
					<th onclick="sortTable(this,<?php echo $ccol++; ?>);" title="">FECHA</th>
					<th onclick="sortTable(this,<?php echo $ccol++; ?>);" title="">DESCRI</th>
          <?php } ?>

          <?php if($repo=='idnum1'){ ?>
					<th onclick="sortTable(this,<?php echo $ccol++; ?>);" title="">DOCU</th>
					<th onclick="sortTable(this,<?php echo $ccol++; ?>);" title="">NUMERO</th>
					<th onclick="sortTable(this,<?php echo $ccol++; ?>);" title="">FECHA</th>
					<th onclick="sortTable(this,<?php echo $ccol++; ?>);" title="">ENTI</th>
					<th onclick="sortTable(this,<?php echo $ccol++; ?>);" title=""><?php echo $entilabel; ?></th>
          <?php } ?>

          <?php if($repo=='iddet'){ ?>
					<th onclick="sortTable(this,<?php echo $ccol++; ?>);" title="">DOCU</th>
					<th onclick="sortTable(this,<?php echo $ccol++; ?>);" title="">NUMERO</th>
					<th onclick="sortTable(this,<?php echo $ccol++; ?>);" title="">FECHA</th>
					<th onclick="sortTable(this,<?php echo $ccol++; ?>);" title="">ITEM</th>
					<th onclick="sortTable(this,<?php echo $ccol++; ?>);" title="">DESCRIP</th>
					<th onclick="sortTable(this,<?php echo $ccol++; ?>,'N');" style="<?php echo 'font-size:'.($xfontsize*0.8).';'?>" title="">P.UNIT</th>
          <?php } ?>

          <?php if(mb_stristr('ctas',$repo)){ ?>
					<th onclick="sortTable(this,<?php echo $ccol++; ?>,'N');" title="">#</th>
					<th onclick="sortTable(this,<?php echo $ccol++; ?>);" title=""></th>
					<th onclick="sortTable(this,<?php echo $ccol++; ?>);" title="">CODIGO</th>
					<th onclick="sortTable(this,<?php echo $ccol++; ?>);" title="">CUENTA</th>
          <?php } ?>

						<th onclick="sortTable(this,<?php echo $ccol++; ?>,'N');" style="<?php if($tingreso==0){echo'display:;';}?> <?php echo 'font-size:'.($xfontsize*0.8).'; ' ?>">PERCEP.</th>	
						<th onclick="sortTable(this,<?php echo $ccol++; ?>,'N');" style="<?php if($tegreso==0){echo'display:;';}?> <?php echo 'font-size:'.($xfontsize*0.8).'; ' ?>">DEDUCC.</th>	
						<th onclick="sortTable(this,<?php echo $ccol++; ?>,'N');" style="<?php if($tegreso==0){echo'display:;';}?> <?php echo 'font-size:'.($xfontsize*0.8).'; ' ?>">PERCIBIR.</th>	
						<th onclick="sortTable(this,<?php echo $ccol++; ?>,'N');" style="<?php if($tprovis==0){echo'display:;';}?> <?php echo 'font-size:'.($xfontsize*0.8).'; ' ?>">PROVIS.</th>	

					<?php if($docuiimp==1 and 1==2){?>
						<th onclick="sortTable(this,<?php echo $ccol++; ?>,'N');" style="<?php if($tcant==0){echo'display:;';}?> <?php echo 'font-size:'.($xfontsize*0.8).'; ' ?>">CANT.</th>	
						<th onclick="sortTable(this,<?php echo $ccol++; ?>,'N');" style="<?php if($tdcto==0){echo'display:;';}?> <?php echo 'font-size:'.($xfontsize*0.8).'; ' ?>">SUB-TOTAL</th>	
						<th onclick="sortTable(this,<?php echo $ccol++; ?>,'N');" style="<?php if($tdcto==0){echo'display:none;';}?> <?php echo 'font-size:'.($xfontsize*0.8).'; text-decoration:underline;' ?>">DCTO</th>	
						<th onclick="sortTable(this,<?php echo $ccol++; ?>,'N');" style="<?php if($tssid==0){echo'display:none;';}?> <?php echo 'font-size:'.($xfontsize*0.8).'; text-decoration:underline;' ?>">SSID</th>	
						<th onclick="sortTable(this,<?php echo $ccol++; ?>,'N');" style="<?php if($tice==0){echo'display:none;';}?> <?php echo 'font-size:'.($xfontsize*0.8).'; font-style:italic;' ?> ">ICE</th>	
						<th onclick="sortTable(this,<?php echo $ccol++; ?>,'N');" 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++; ?>,'N');" 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++; ?>,'N');" style="<?php if($tprop==0){echo'display:none;';}?> <?php echo 'font-size:'.($xfontsize*0.8).';' ?>">PROP</th>	
						<th onclick="sortTable(this,<?php echo $ccol++; ?>,'N');" style="<?php if($tiva==0){echo'display:none;';}?> <?php echo 'font-size:'.($xfontsize*0.8).'; font-style:italic;' ?>">IVA</th>	
						<th onclick="sortTable(this,<?php echo $ccol++; ?>,'N');" style="<?php if($tirbp==0){echo'display:none;';}?> <?php echo 'font-size:'.($xfontsize*0.8).'; font-style:italic;' ?>">IRBP</th>
					<?php }?>
          
					<th onclick="sortTable(this,<?php echo $ccol++; ?>,'N');" title="">TOTAL</th>
					<th onclick="sortTable(this,<?php echo $ccol++; ?>,'N');" title="Participación">%</th>

              
          
          <?php if($modu=='VTAS' and $ver_cost==1 and 1==2){ ?>
          <?php if($repo=='iddet'){ ?> 
					<th onclick="sortTable(this,<?php echo $ccol++; ?>,'N');">C.UNIT</th>
          <?php } ?>
					<th onclick="sortTable(this,<?php echo $ccol++; ?>,'N');">COSTO</th>
					<th onclick="sortTable(this,<?php echo $ccol++; ?>,'N');">UTIL.B.</th>
					<th onclick="sortTable(this,<?php echo $ccol++; ?>,'N');" titlte="Utilidad">%</th>
          <?php } ?>
          
          
          <th style="font-size:<?php echo $xfontsize*.5;?>px;" title="Descargar XLS">
            <a href="#" id="downxls1" onClick="javascript:fnExcelReport('tpant1',this,'<?php echo $cfg_empr.'_'.$modu.'_'.date('Ymd_His');?>');">XLS</a>
          </th>
				</tr>
			</thead>
			<?php } ?>
      <?php $timew1=date('U'); ?>

      <?php //die();?>
      
			<?php  {// TBODY ?>
			<tbody id="tpant1b" valign="top" style="overflow-y:auto; <?php echo $tdisplay; ?>; 
							<?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 if(@mysql_num_rows($res_pant)==0){?>
          <tr><td style="font-weight:bold;">
            <?php echo 'NO HAY DATOS'; ?>  
            <?php echo '<br>==>'.date('H:i:s'); ?>
            <?php //echo '<br>'.$docu.' /'.$enti; ?>
          </td></tr>
        <?php }?>
        <?php if($user_cons==0){?>
          <tr><td style="font-weight:bold;color:red;">NO TIENE ACCESO PARA CONSULTAR ==> <?php echo $modu.' - '.r_fiel('modu',$modu);?></td></tr>
        <?php }?>

        <?php $last_codi=''; ?>
        <?php $last_idnum='';?>
        <?php $last_base=0; ?>
        <?php $last_niv1=0; ?>
        <?php $cctas=0; ?>
        <?php $xdocusal0=''; ?>
        
            <?php while($aso_pant=@mysql_fetch_assoc($res_pant)){ ?>
            <?php $status=$aso_pant['status']; ?>
            <?php $id_trfila=fillzero($crow);?> 
            <?php $lineaok=1;?>
              <?php $xidnum =$aso_pant['idnum1'];?>
        
              <?php $xdocum =$aso_pant['docum'];?>
              <?php $xptoem =$aso_pant['ptoem'];?>
              <?php $xnumer =$aso_pant['numer'];?>
        
            <?php $duni =$aso_pant['item_duni']; ?>
            <?php $dpre =$aso_pant['item_dpre']; ?>
            <?php $dcos =$aso_pant['item_dcos']; ?>
              
              <?php if($repo=='enti'){ ?>
                <?php if(mb_stristr('NOMI',$modu)){$xtipo=@$aso_pant['csub_descri'];}?>
                <?php $xcodi=@$aso_pant['enti2'];?>
                <?php $xdesc=@$aso_pant['enti_descri'];?>
              <?php } ?>
        
              <?php if($repo=='nvdd'){ ?>
                <?php $xtipo=@$aso_pant[''];?>
                <?php $xcodi=@$aso_pant['nvdd'];?>
                <?php $xdesc=@$aso_pant['nvdd_descri'];?>
              <?php } ?>
        
              <?php if($repo=='csub'){ ?>
                <?php $xtipo=@$aso_pant[''];?>
                <?php $xcodi=@$aso_pant['enti_csub'];?>
                <?php $xdesc=@$aso_pant['csub_descri'];?>
              <?php } ?>
        
              <?php if($repo=='docu'){ ?>
                <?php $xtipo=@$aso_pant[''];?>
                <?php $xcodi=@$aso_pant['docu'];?>
                <?php $xdesc=@$aso_pant['docu_descri'];?>
              <?php } ?>
        
        
              <?php if($repo=='ctas'){ ?>
                <?php $xtipo=@$aso_pant[''];?>
                <?php $xcodi=@$aso_pant['ctas'];?>
                <?php $xdesc=@$aso_pant['ctas_descri'];?>
              <?php } ?>
        
              <?php if($repo=='idnum1' or  $repo=='iddet'){ ?>
                <?php $xtipo=@$aso_pant['docu'];?>
                <?php $xcodi=@$aso_pant['numero'];?>
                <?php $xdesc=@$aso_pant['fecha'];?>
              <?php } ?>
        
              <?php if($repo=='fmes'){ ?>
                <?php $xtipo=@$aso_pant['fanio'];?>
                <?php $xcodi=@$aso_pant['fmes'];?>
                <?php $xdesc=@date('M / Y' ,strtotime($aso_pant['fecha']));?>
              <?php } ?>
        
              <?php if($repo=='fsema'){ ?>
                <?php $xtipo=@$aso_pant['fanio'];?>
                <?php $xcodi=@$aso_pant['fsema'];?>
                <?php $xdesc=@$aso_pant['fanio'].' /'.@$aso_pant['fsema'];?>
              <?php } ?>
        
              <?php if($repo=='fecha'){ ?>
                <?php $xtipo=@date('z' ,strtotime($aso_pant['fecha']));?>
                <?php $xtipo=@fillzero(date('z' ,strtotime($aso_pant['fecha'])),3);?>
                <?php $xcodi=@$aso_pant['fecha'];?>
                <?php $xdesc=@date('N-D' ,strtotime($aso_pant['fecha']));?>
              <?php } ?>

              <?php if(empty($xdesc))
              {$xdesc='<a href="?prnt=1&docu='.@$aso_pant['docu'].'&idnum='.@$aso_pant['idnum1'].'&formato=" target="_blank">'.@$aso_pant['docu'].'-'.@$aso_pant['numero'].'</a>';} ?>

            
            
              <?php $xtingreso=$aso_pant['stingreso']; ?>
              <?php $xtegreso=$aso_pant['stegreso']; ?>
              <?php $xtprovis=$aso_pant['stprovis']; ?>
              <?php $xtpercibir=$aso_pant['stpercibir']; ?>
              <?php $xtneto=$aso_pant['stneto']; ?>
            
            
              <?php $xdesclen=strlen($xdesc);?>
              <?php $xsaldoi=$aso_pant['saldoi']; ?>
              <?php $xtdeb=$aso_pant['stdebito']; ?>
              <?php $xtcre=$aso_pant['stcredito']; ?>
              <?php $xsaldo=$aso_pant['saldo']; ?>
              <?php $xnivel =$aso_pant['nivel']; ?>
              <?php $xtotal =$aso_pant['stotal']; ?>
              <?php $xvarval=$xsaldo-$xsaldoi; ?>
              <?php $xvarpor=0; ?>
              <?php $xsaldoc=0; ?>
              <?php if($xsaldoi!=0){$xvarpor=($xvarval/$xsaldoi)*100;} ?>

              <?php if($total!=0){$xporpar=($xtotal/$total)*100; $tporpar+=$xporpar;} ?>
        
        
            <?php echo '<div></div>'; ?>
        
            <?php if($lineaok==1){ ?>
            <?php $last_codi=$xcodi; ?>
            <?php $crow++; ?> 
            <?php $clin++; ?> 
        
            <tr id="tr_fila<?php echo $crow;?>" class="tr_fila" 
                style="
                       <?php if($clin%5==0){echo 'border-bottom:dotted 1px;'; } ?>
                       "
                <?php if(substr($pant,0,1)=='P'){?> 
                onmouseover="_filabg(event,'tr_fila','<?php echo $crow; ?>','');"
                <?php } ?>
                onclick="_filabg(event,'tr_fila','<?php echo $crow; ?>','');
                        <?php //if(substr($pant,0,1)=='P' and $repo=='enti'){?> 
                        <?php if(substr($pant,0,1)=='P' and $repo!='lldd'){?> 
                         <?php
                         $ponclick='';
                         $ponclick.='document.getElementById("'.$repo.'").value="'.$aso_pant[$repo].'";';
                         $ponclick.='info_docu("PANT1",'.'document.getElementById("modu").value'.');'; 
                         $ponclick.='document.getElementById("'.$repo.'").value="";';
                         $ponclick=str_replace('"',"'",$ponclick);                                                                        
                         echo $ponclick; 
                         ?>
                        <?php } ?> 
                         "
                >
<!--                         {info_modu('PANT2','<?php //echo //$modu; ?>','<?php //echo //$xcodi; ?>');} -->
              
                <td style="display:none;"><?php echo fillzero($crow,5); ?></td>
  
              
              
              
              <?php if(substr($pant,0,4)=='PANT'){ ?>
                <td>
                <?php

  
                 if(mb_stristr('idnum1.iddet',$repo))
                 {
                  $idocu=$aso_pant['docu'];
                  $iidnum=$aso_pant['idnum1'];
                  $pidtxt='i_'.$crow; 
                  $psize=$xfontsize;
                  $pcaption='Imprimir';
                  $pabrev='I';
//                   {$ponclick='{window.open("?prnt=1&clave='.$claveacce.'","_blank")}';}
                  {$ponclick='{window.open("?prnt=1&docu='.$idocu.'&idnum='.$iidnum.'","_blank")}';}
                  if(mb_stristr($pant,'PANT') and $mobile!='true'){include('vrbutton.php');}
                 }
                 else
                 {
                  $pidtxt='imprim'; $pcaption='Imprimir'; $pabrev='I';
                  $ponclick='';
                  $ponclick.='document.getElementById("'.$repo.'").value="'.$aso_pant[$repo].'";';
                  $ponclick.='info_docu("IMPR1",'.'document.getElementById("modu").value'.');'; 
                  $ponclick.='document.getElementById("'.$repo.'").value="";';
                  $psize=$xfontsize; 
                  if(mb_stristr($pant,'PANT') and $mobile!='true'){include('vrbutton.php');}
                 }
  
                ?>
                </td>  
              <?php } ?>
              
                <?php //if($repo=='enti') { ?>
                <?php { ?>
                <?php if($repo!='idnum1' and $repo!='iddet'){?>
                <td align="center" style="">
                  <?php echo $aso_pant['cidnum1']; ?>
                </td>	
                <?php } ?>
                <td align="center" style="">
                  <?php echo $xtipo; ?>
                </td>	
                <td align="<?php if(mb_stristr('enti.fmes.fsema.fecha.csub',$repo)){echo 'center';} ?>" style="">
                  <?php if(mb_stristr('fmes.fsema.fecha',$repo)){ ?>
                      <div style="display:none;"><?php echo $xtipo; ?></div>
                  <?php } ?>
                  <?php echo $xcodi; ?>
                </td>	
                <td align="<?php if(mb_stristr('fmes.fsema.fecha.idnum1.',$repo)){echo 'center';} ?>" style="border-right:solid 1px;">
                  <?php if(mb_stristr('fmes.fsema.',$repo)){ ?>
                      <div style="display:none;"><?php echo $xcodi.$xtipo; ?></div>
                  <?php } ?>
                  <?php if(substr($pant,0,4)=='PANT'){echo split_words($xdesc);} else {echo $xdesc;} ?>
                  <?php //echo split_words($xdesc); ?>
                  <?php if(mb_stristr('fecha.idnum1',$repo)){ ?>
                      <div style="display:none;"><?php echo $xcodi.$xtipo; ?></div>
                  <?php } ?>
                </td>	
                <?php } ?>
              
                <?php if($repo=='idnum1'){ ?>
                  <td align="center" style="">
                    <?php echo $aso_pant['enti']; ?>
                  </td>	
                  <td align="" style="border-right:dotted 1px;">
                  <?php if(substr($pant,0,4)=='PANT'){echo split_words($aso_pant['enti_descri']);} else {echo $aso_pant['enti_descri'];} ?>
                    <?php //echo split_words($aso_pant['enti_descri']); ?>
                  </td>	
                <?php } ?>

                <?php if($repo=='iddet'){ ?>
                  <td align="center" style="">
                    <?php echo $aso_pant['item']; ?>
                  </td>	
                  <td align="" style="border-right:dotted 1px;">
                  <?php if(substr($pant,0,4)=='PANT'){echo split_words($aso_pant['nvdd_descri']);} else {echo $aso_pant['nvdd_descri'];} ?>
                  </td>	
                  <td align="right" style="<?php if($tcant==0){echo'display:;';}else{echo'';}?> ">
                    <?php echo number_format(($aso_pant['puni']),$dpre); ?>
                  </td>	
                <?php } ?>

               
              <td align="right" style="font-weight:;"> 
                <?php echo number_format(($aso_pant['stingreso']),2); ?>
              </td>
              <td align="right" style="font-weight:;"> 
                <?php echo number_format(($aso_pant['stegreso']),2); ?>
              </td>
              <td align="right" style="font-weight:bold;"> 
                <?php echo number_format(($aso_pant['stpercibir']),2); ?>
              </td>
              <td align="right" style="font-style:italic;"> 
                <?php echo number_format(($aso_pant['stprovis']),2); ?>
              </td>
              
               

                <?php if($docuiimp and 1==2){ ?>
                  <td align="right" style="<?php if($tcant==0){echo'display:;';}else{echo'';}?> ">
                    <?php echo number_format(($aso_pant['stcant']),2); ?>
                  </td>	
                  <td align="right" style="<?php if($tdcto==0){echo'display:;';}else{echo'';}?> ">
                    <?php echo number_format(($aso_pant['stsubt']),2); ?>
                  </td>	
                  <td align="right" style="<?php if($tdcto==0){echo'display:none;';}else{echo'text-decoration:underline;';}?> font-style:italic;">
                    <?php echo number_format(($aso_pant['stdcto']),2); ?>
                  </td>	
                  <td align="right" style="<?php if($tssid==0){echo'display:none;';}else{echo'text-decoration:underline;';}?> font-style:italic;">
                    <?php echo number_format(($aso_pant['stssid']),2); ?>
                  </td>	
                  <td align="right" style="<?php if($tice==0){echo'display:none;';}?> font-style:italic;">
                    <?php echo number_format(($aso_pant['stice']),2); ?>
                  </td>	
                  <td align="right" style="<?php if($tsubtiva0==0){echo'display:none;';}?>">
                    <?php echo number_format(($aso_pant['stsubtiva0']),2); ?>
                  </td>	
                  <td align="right" style="<?php if($tsubtiva==0){echo'display:none;';}?>">
                    <?php echo number_format(($aso_pant['stsubtiva']),2); ?>
                  </td>	
                  <td align="right" style="<?php if($tprop==0){echo'display:none;';}?> font-style:italic;">
                    <?php echo number_format(($aso_pant['stprop']),2); ?>
                  </td>	
                  <td align="right" style="<?php if($tiva==0){echo'display:none;';}?> font-style:italic;">
                    <?php echo number_format(($aso_pant['stiva']),2); ?>
                  </td>	
                  <td align="right" style="<?php if($tirbp==0){echo'display:none;';}?> font-style:italic;">
                    <?php echo number_format(($aso_pant['stirbp']),2); ?>
                  </td>	
              <?php } ?>

              
              <td align="right" style="font-weight:bold;"> 
                <?php //echo number_format(($aso_pant['stotal']),2); ?>
                <?php echo number_format(($aso_pant['stneto']),2); ?>
              </td>
              
              <td align="right" style="font-weight:bold;"> 
                <?php echo number_format(($xporpar),2).'%'; ?>
              </td>

              <?php if($modu=='VTAS' and mb_stristr('fmes.fsema.fecha',$repo)){ ?>
              <?php if($totalante!=0){$xporcre=(($aso_pant['stotal']/$totalante)-1)*100;}?>
              <?php $totalante=$aso_pant['stotal']; ?>
              <td align="right" style="font-weight:bold;"> 
                <?php echo number_format(($xporcre),2).'%'; ?>
              </td>
              <?php } ?>
              
              <?php if($modu=='VTAS' and $ver_cost==1){ ?>
              <?php if($repo=='iddet'){?>
                <td align="right"> 
                  <?php echo number_format(($aso_pant['cuni']),$dcos); ?>
                </td>
              <?php } ?>
                <td align="right"> 
                  <?php echo number_format(($aso_pant['stcuni']),2); ?>
                </td>
                <td align="right" style="font-weight:bold;"> 
                  <?php echo number_format(($aso_pant['stutil']),2); ?>
                </td>
                <td align="right" style="font-weight:bold;"> 
                  <?php echo number_format(($aso_pant['stutil'])/$aso_pant['stotal']*100,2).'%'; ?>
                </td>
              <?php } ?>

              
            </tr>
              <?php } 
            ?>
            <?php } ?>
        
        
			</tbody>
		<?php } ?>	
  
      <?php $timew2=date('U'); ?>
      <?php $ccolbak=$ccol; ?>
      <?php { // FOOT ?>
			<tfoot style="<?php echo $tdisplay; ?><?php if($mobile!='true'){echo 'max-width:'.($screenw-20).'px;';} ?>;background-color:<?php echo $gris1; ?>; font-size:<?php echo $xfontsize*1;?>px;">
				<tr style="border-top:solid 1px;border-bottom:solid 1px;">
          <th style="display:none;"<?php $ccol--; ?>></th>

          <?php if(substr($pant,0,4)=='PANT'){?>
					<th <?php $ccol--; ?>></th>
          <?php } ?>
          
          <?php if($repo!='idnum1' and $repo!='iddet'){?>
          <th <?php $ccol--; ?>> <?php echo $tcidnum1; ?></th>
          <?php } ?>
          

          <?php if(mb_stristr('enti.nvdd.docu.csub.fmes.fsema.fecha.idnum1.ctas.',$repo)){ ?>
            <th <?php $ccol--; ?>></th>
            <th <?php $ccol--; ?>><?php echo $crow; ?></th>
          <?php } ?>
          
          <?php if(mb_stristr('idnum1.',$repo)){ ?>
            <th <?php $ccol--; ?>></th>
            <th <?php $ccol--; ?>></th>
          <?php } ?>
          
          <?php if(mb_stristr('.iddet',$repo)){ ?>
            <th <?php $ccol--; ?>></th>
            <th <?php $ccol--; ?>></th>
            <th <?php $ccol--; ?>></th>
            <th <?php $ccol--; ?>></th>
          <?php } ?>
          
					<th <?php $ccol--; ?> style="max-width:;letter-spacing:5px; ">TOTALES</th>
          
          <?php if(mb_stristr('enti',$repo) and 1==2){ ?>
            <th <?php $ccol--; ?>></th>
          <?php } ?>
          

					<?php if(mb_stristr('NOMI',$modu)){ ?>
						<th <?php $ccol--; ?>align="right" style="<?php if($tcant==0){echo'display:;';}?> ">
							<?php echo number_format(abs($tingreso),2); ?>
						</th>	
						<th <?php $ccol--; ?>align="right" style="<?php if($tcant==0){echo'display:;';}?> ">
							<?php echo number_format(($tegreso),2); ?>
						</th>	
						<th <?php $ccol--; ?>align="right" style="<?php if($tcant==0){echo'display:;';}?> ">
							<?php echo number_format(abs($tneto),2); ?>
						</th>	
						<th <?php $ccol--; ?>align="right" style="<?php if($tcant==0){echo'display:;';}?> font-style:italic;">
							<?php echo number_format(abs($tprovis),2); ?>
						</th>	
               <?php } ?>
            
					<?php if(mb_stristr('VTAS.CLIE.CARR.COMP.PROV',$modu) and 1==2){ ?>
            <?php if(mb_stristr('iddet',$repo)){ ?>
              <th <?php $ccol--; ?>></th>
            <?php } ?>
          
						<th <?php $ccol--; ?>align="right" style="<?php if($tcant==0){echo'display:;';}?> ">
							<?php echo number_format(abs($tcant),2); ?>
						</th>	
						<th <?php $ccol--; ?>align="right" style="<?php if($tdcto==0){echo'display:;';}?> ">
							<?php echo number_format(abs($tsubt),2); ?>
						</th>	
						<th <?php $ccol--; ?>align="right" style="<?php if($tdcto==0){echo'display:none;';}?> font-style:italic;text-decoration:underline;">
							<?php echo number_format(abs($tdcto),2); ?>
						</th>	
						<th <?php $ccol--; ?>align="right" style="<?php if($tssid==0){echo'display:none;';}?> font-style:italic;text-decoration:underline;">
							<?php echo number_format(abs($tssid),2); ?>
						</th>	
						<th <?php $ccol--; ?>align="right" style="<?php if($tice==0){echo'display:none;';}?> font-style:italic;">
							<?php echo number_format(abs($tice),2); ?>
						</th>	
						<th <?php $ccol--; ?>align="right" style="<?php if($tsubtiva0==0){echo'display:none;';}?>">
							<?php echo number_format(abs($tsubtiva0),2); ?>
						</th>
						<th <?php $ccol--; ?>align="right" style="<?php if($tsubtiva==0){echo'display:none;';}?>">
							<?php echo number_format(abs($tsubtiva),2); ?>
						</th>	
						<th <?php $ccol--; ?>align="right" style="<?php if($tprop==0){echo'display:none;';}?> font-style:italic;">
							<?php echo number_format(abs($tprop),2); ?>
						</th>	
						<th <?php $ccol--; ?>align="right" style="<?php if($tiva==0){echo'display:none;';}?> font-style:italic;">
							<?php echo number_format(abs($tiva),2); ?>
						</th>	
						<th <?php $ccol--; ?>align="right" style="<?php if($tirbp==0){echo'display:none;';}?> font-style:italic;">
							<?php echo number_format(abs($tirbp),2); ?>
						</th>	
            <?php //$tsaldo=$total;?>
				<?php } ?>
          
          
          
					<th <?php $ccol--; ?> align="right">
						<?php echo number_format($total,2); ?>
					</th>
          
					<th <?php $ccol--; ?> align="right">
						<?php echo number_format($tporpar,2).'%'; ?>
					</th>
          
              <?php if($modu=='VTAS' and mb_stristr('fmes.fsema.fecha',$repo)){ ?>
                <th><?php $ccol--; ?></th>
              <?php } ?>
          

          
          
          
          <?php if($ccol<0){$ccol=0;}?>
          <?php if(mb_stristr($pant,'PANT')){?>
          <?php echo str_repeat('<th></th>',$ccol); ?>
          <?php } ?>
				</tr>

        <?php $ccol=$ccolbak; ?>
        
				<tr style="border-top:solid 1px;border-bottom:solid 1px;">
          <th style="display:none;"<?php $ccol--; ?>></th>

          <?php if(substr($pant,0,4)=='PANT'){?>
					<th <?php $ccol--; ?>></th>
          <?php } ?>
          
          <?php if($repo!='idnum1' and $repo!='iddet'){?>
          <th <?php $ccol--; ?>> <?php echo number_format($tcidnum1/$crow,0); ?></th>
          <?php } ?>
          

          <?php if(mb_stristr('enti.nvdd.docu.csub.fmes.fsema.fecha.idnum1.ctas.',$repo)){ ?>
            <th <?php $ccol--; ?>></th>
            <th <?php $ccol--; ?>><?php //echo $crow; ?></th>
          <?php } ?>
          
          <?php if(mb_stristr('idnum1.',$repo)){ ?>
            <th <?php $ccol--; ?>></th>
            <th <?php $ccol--; ?>></th>
          <?php } ?>
          
          <?php if(mb_stristr('.iddet',$repo)){ ?>
            <th <?php $ccol--; ?>></th>
            <th <?php $ccol--; ?>></th>
            <th <?php $ccol--; ?>></th>
            <th <?php $ccol--; ?>></th>
          <?php } ?>
          
					<th <?php $ccol--; ?> style="max-width:;letter-spacing:5px; ">PROMEDIOS</th>
          
          <?php if(mb_stristr('enti',$repo) and 1==2){ ?>
            <th <?php $ccol--; ?>></th>
          <?php } ?>
          

					<?php if(mb_stristr('NOMI',$modu)){ ?>
						<th <?php $ccol--; ?>align="right" style="<?php if($tcant==0){echo'display:;';}?> ">
							<?php echo number_format(abs($tingreso/$crow),2); ?>
						</th>	
						<th <?php $ccol--; ?>align="right" style="<?php if($tcant==0){echo'display:;';}?> ">
							<?php echo number_format(($tegreso/$crow),2); ?>
						</th>	
						<th <?php $ccol--; ?>align="right" style="<?php if($tcant==0){echo'display:;';}?> ">
							<?php echo number_format(abs($tneto/$crow),2); ?>
						</th>	
						<th <?php $ccol--; ?>align="right" style="<?php if($tcant==0){echo'display:;';}?> font-style:italic;">
							<?php echo number_format(abs($tprovis/$crow),2); ?>
						</th>	
               <?php } ?>
               
               
            
					<?php //if($docuiimp==1){ ?>
					<?php if(mb_stristr('VTAS.CLIE.CARR.COMP.PROV',$modu) and 1==2){ ?>
            <?php if(mb_stristr('iddet',$repo)){ ?>
              <th <?php $ccol--; ?>></th>
            <?php } ?>
          
						<th <?php $ccol--; ?>align="right" style="<?php if($tcant==0){echo'display:;';}?> ">
							<?php echo number_format(abs($tcant/$crow),2); ?>
						</th>	
						<th <?php $ccol--; ?>align="right" style="<?php if($tdcto==0){echo'display:;';}?> ">
							<?php echo number_format(abs($tsubt/$crow),2); ?>
						</th>	
						<th <?php $ccol--; ?>align="right" style="<?php if($tdcto==0){echo'display:none;';}?> font-style:italic;text-decoration:underline;">
							<?php echo number_format(abs($tdcto/$crow),2); ?>
						</th>	
						<th <?php $ccol--; ?>align="right" style="<?php if($tssid==0){echo'display:none;';}?> font-style:italic;text-decoration:underline;">
							<?php echo number_format(abs($tssid/$crow),2); ?>
						</th>	
						<th <?php $ccol--; ?>align="right" style="<?php if($tice==0){echo'display:none;';}?> font-style:italic;">
							<?php echo number_format(abs($tice/$crow),2); ?>
						</th>	
						<th <?php $ccol--; ?>align="right" style="<?php if($tsubtiva0==0){echo'display:none;';}?>">
							<?php echo number_format(abs($tsubtiva0/$crow),2); ?>
						</th>
						<th <?php $ccol--; ?>align="right" style="<?php if($tsubtiva==0){echo'display:none;';}?>">
							<?php echo number_format(abs($tsubtiva/$crow),2); ?>
						</th>	
						<th <?php $ccol--; ?>align="right" style="<?php if($tprop==0){echo'display:none;';}?> font-style:italic;">
							<?php echo number_format(abs($tprop/$crow),2); ?>
						</th>	
						<th <?php $ccol--; ?>align="right" style="<?php if($tiva==0){echo'display:none;';}?> font-style:italic;">
							<?php echo number_format(abs($tiva/$crow),2); ?>
						</th>	
						<th <?php $ccol--; ?>align="right" style="<?php if($tirbp==0){echo'display:none;';}?> font-style:italic;">
							<?php echo number_format(abs($tirbp/$crow),2); ?>
						</th>	
            <?php //$tsaldo=$total;?>
				<?php } ?>
          
          
          
					<th <?php $ccol--; ?> align="right">
						<?php echo number_format($total/$crow,2); ?>
					</th>
          
					<th <?php $ccol--; ?> align="right">
						<?php echo number_format($tporpar/$crow,2).'%'; ?>
					</th>
          
              <?php if($modu=='VTAS' and mb_stristr('fmes.fsema.fecha',$repo)){ ?>
                <th><?php $ccol--; ?></th>
              <?php } ?>
          
              <?php if(mb_stristr('VTAS.COMP.CLIE.CARR.PROV',$modu) and $ver_cost==1){ ?>
              <?php if($repo=='iddet'){ ?>
                <th><?php $ccol--; ?></th>
              <?php } ?>
                <th align="right" style=""> 
                  <?php echo number_format($tcuni/$crow,2); ?>
                </th>
                <th align="right" style=""> 
                  <?php echo number_format($tutil/$crow,2); ?>
                </th>
                <th align="right" style=""> 
                  <?php echo number_format($tutil/$total*100/$crow,2).'%'; ?>
                </th>
              <?php } ?>

          
          
          
          <?php if($ccol<0){$ccol=0;}?>
          <?php if(mb_stristr($pant,'PANT')){?>
          <?php echo str_repeat('<th></th>',$ccol); ?>
          <?php } ?>
				</tr>
        
			</tfoot>
			<?php } ?>	
		</table>
  
<?php } ?>
  
  
<?php if(mb_stristr('RETC.RETP',$modu)){ ?>  
		<table id="tpant1" class="pant1" border="0"
					 align="center" cellpadding="3" width="100%"
					 style="font-size:<?php if($orient=='V'){echo $xfontsize-8;}else{echo $xfontsize;} ?>px;
						border-collapse:collapse;background-color:snow; position:; <?php if($pant=='IMPR' and 1==2 ){echo 'max-width:210mm;';}?>"
						>
			<?php { // THEAD ?>
			<thead style="<?php echo $tdisplay; ?><?php if($mobile!='true'){echo 'max-width:'.($screenw-20).'px;';} ?>;background-color:<?php echo $gris1; ?>;">
				<tr style="border-top:solid 1px;border-bottom:solid 1px; cursor:pointer;" >
          <th onclick="sortTable(this,0);" style="display:none;"><?php  $ccol++; ?></th>
          
          <?php if(substr($pant,0,4)=='PANT'){?>
					<th onclick="sortTable(this,<?php echo $ccol++; ?>);" title="Imprimir">I</th>
          <?php } ?>
          
          <?php if($repo=='enti'){ ?>
					<th onclick="sortTable(this,<?php echo $ccol++; ?>,'N');" title="">#</th>
					<th onclick="sortTable(this,<?php echo $ccol++; ?>);" title=""><?php echo $entilabeltipo; ?></th>
					<th onclick="sortTable(this,<?php echo $ccol++; ?>);" title="">ENTIDAD</th>
					<th onclick="sortTable(this,<?php echo $ccol++; ?>);" title=""><?php echo $entilabel; ?></th>
					<th onclick="sortTable(this,<?php echo $ccol++; ?>);" title="" style="font-size:<?php echo $xfontsize*0.8;?>px;">RISE</th>
          <?php } ?>


          <?php if($repo=='tpro'){ ?>
					<th onclick="sortTable(this,<?php echo $ccol++; ?>,'N');" title="">#</th>
					<th onclick="sortTable(this,<?php echo $ccol++; ?>);" title=""></th>
					<th onclick="sortTable(this,<?php echo $ccol++; ?>);" title="">TPRO</th>
					<th onclick="sortTable(this,<?php echo $ccol++; ?>);" title="">TIPO.PROV.</th>
          <?php } ?>

          <?php if($repo=='fmes'){ ?>
					<th onclick="sortTable(this,<?php echo $ccol++; ?>,'N');" title="">#</th>
					<th onclick="sortTable(this,<?php echo $ccol++; ?>);" title="">AÑO</th>
					<th onclick="sortTable(this,<?php echo $ccol++; ?>);" title="">MES</th>
					<th onclick="sortTable(this,<?php echo $ccol++; ?>);" title="">DESCRI</th>
          <?php } ?>


          <?php if($repo=='idnum1'){ ?>
					<th onclick="sortTable(this,<?php echo $ccol++; ?>);" title="">DOCU</th>
					<th onclick="sortTable(this,<?php echo $ccol++; ?>);" title="">NUMERO</th>
					<th onclick="sortTable(this,<?php echo $ccol++; ?>);" title="">FECHA</th>
					<th onclick="sortTable(this,<?php echo $ccol++; ?>);" title="">ENTI</th>
					<th onclick="sortTable(this,<?php echo $ccol++; ?>);" title=""><?php echo $entilabel; ?></th>
          <?php } ?>

          <?php if($repo=='iddet'){ ?>
					<th onclick="sortTable(this,<?php echo $ccol++; ?>);" title="">DOCU</th>
					<th onclick="sortTable(this,<?php echo $ccol++; ?>);" title="">NUMERO</th>
					<th onclick="sortTable(this,<?php echo $ccol++; ?>);" title="">FECHA</th>
					<th onclick="sortTable(this,<?php echo $ccol++; ?>);" title="">ITEM</th>
					<th onclick="sortTable(this,<?php echo $ccol++; ?>);" title="">DESCRIP</th>
          <?php } ?>


          <?php if(mb_stristr('cair',$repo)){ ?>
					<th onclick="sortTable(this,<?php echo $ccol++; ?>,'N');" title="">#</th>
					<th onclick="sortTable(this,<?php echo $ccol++; ?>);" title="">TIPO</th>
					<th onclick="sortTable(this,<?php echo $ccol++; ?>);" title="">CODIGO</th>
					<th onclick="sortTable(this,<?php echo $ccol++; ?>);" title="">IMP. RTA.</th>
          <?php } ?>

          <?php if(mb_stristr('suco',$repo)){ ?>
					<th onclick="sortTable(this,<?php echo $ccol++; ?>,'N');" title="">#</th>
					<th onclick="sortTable(this,<?php echo $ccol++; ?>);" title="">TIPO</th>
					<th onclick="sortTable(this,<?php echo $ccol++; ?>);" title="">CODIGO</th>
					<th onclick="sortTable(this,<?php echo $ccol++; ?>);" title="">SUST.COMP.</th>
          <?php } ?>

          <?php if(mb_stristr('iva',$repo)){ ?>
					<th onclick="sortTable(this,<?php echo $ccol++; ?>,'N');" title="">#</th>
					<th onclick="sortTable(this,<?php echo $ccol++; ?>);" title="">TIPO</th>
					<th onclick="sortTable(this,<?php echo $ccol++; ?>);" title="">CODIGO</th>
					<th onclick="sortTable(this,<?php echo $ccol++; ?>);" title="">DESCRI</th>
          <?php } ?>

          <?php if(mb_stristr('porc',$repo)){ ?>
					<th onclick="sortTable(this,<?php echo $ccol++; ?>,'N');" title="">#</th>
					<th onclick="sortTable(this,<?php echo $ccol++; ?>);" title="">TIPO</th>
					<th onclick="sortTable(this,<?php echo $ccol++; ?>);" title="">CODIGO</th>
					<th onclick="sortTable(this,<?php echo $ccol++; ?>);" title="">DESCRI</th>
          <?php } ?>

          
            <?php if($dispcolu!=0){?>
              <th onclick="sortTable(this,<?php echo $ccol++; ?>,'N');">B.Rta.</th>
            <?php } ?>
              <th onclick="sortTable(this,<?php echo $ccol++; ?>,'N');">%Rta.</th>
            <?php if($dispcolu!=0){?>
              <th onclick="sortTable(this,<?php echo $ccol++; ?>,'N');">R.Rta.</th>
            <?php } ?>
            <?php if($dispcolu!=0){?>
              <th onclick="sortTable(this,<?php echo $ccol++; ?>,'N');">B.IVA</th>
            <?php } ?>
              <th onclick="sortTable(this,<?php echo $ccol++; ?>,'N');">%IVA</th>
            <?php if($dispcolu!=0){?>
              <th onclick="sortTable(this,<?php echo $ccol++; ?>,'N');">R.IVA</th>
            <?php } ?>
          
          

          
          
					<th onclick="sortTable(this,<?php echo $ccol++; ?>,'N');" title="">TOTAL</th>
					<th onclick="sortTable(this,<?php echo $ccol++; ?>,'N');" title="">%</th>
          
          <th style="font-size:<?php echo $xfontsize*.5;?>px;" title="Descargar XLS">
            <a href="#" id="downxls1" onClick="javascript:fnExcelReport('tpant1',this,'<?php echo $cfg_empr.'_'.$modu.'_'.date('Ymd_His');?>');">XLS</a>
          </th>
				</tr>
			</thead>
			<?php } ?>
      <?php $timew1=date('U'); ?>

      <?php //die();?>
      
			<?php  {// TBODY ?>
			<tbody id="tpant1b" valign="top" style="overflow-y:auto; <?php echo $tdisplay; ?>; 
							<?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 if(@mysql_num_rows($res_pant)==0){?>
          <tr><td style="font-weight:bold;">
            <?php echo 'NO HAY DATOS'; ?>  
            <?php echo '<br>==>'.date('H:i:s'); ?>
            <?php //echo '<br>'.$docu.' /'.$enti; ?>
          </td></tr>
        <?php }?>
        <?php if($user_cons==0){?>
          <tr><td style="font-weight:bold;color:red;">NO TIENE ACCESO PARA CONSULTAR ==> <?php echo $modu.' - '.r_fiel('modu',$modu);?></td></tr>
        <?php }?>

        <?php $last_codi=''; ?>
        <?php $last_idnum='';?>
        <?php $last_base=0; ?>
        <?php $last_niv1=0; ?>
        <?php $cctas=0; ?>
        <?php $xdocusal0=''; ?>
        
            <?php while($aso_pant=@mysql_fetch_assoc($res_pant)){ ?>
            <?php $status=$aso_pant['status']; ?>
            <?php $id_trfila=fillzero($crow);?> 
            <?php $lineaok=1;?>
              <?php $xidnum =$aso_pant['idnum1'];?>
        
              <?php $xdocum =$aso_pant['docum'];?>
              <?php $xptoem =$aso_pant['ptoem'];?>
              <?php $xnumer =$aso_pant['numer'];?>
        
              
              <?php if($repo=='enti'){ ?>
                <?php if(mb_stristr('VTAS.CLIE',$modu)){$xtipo=@$aso_pant['zsub_descri'];}?>
                <?php if(mb_stristr('COMP.PROV',$modu)){$xtipo=@$aso_pant['tpro_descri'];}?>
                <?php $xcodi=@$aso_pant['enti'];?>
                <?php $xdesc=@$aso_pant['enti_descri'];?>
              <?php } ?>
        
        
              <?php if($repo=='tpro'){ ?>
                <?php $xtipo=@$aso_pant[''];?>
                <?php $xcodi=@$aso_pant['enti_tpro'];?>
                <?php $xdesc=@$aso_pant['tpro_descri'];?>
              <?php } ?>
        
        
              <?php if($repo=='cair'){ ?>
                <?php $xtipo='RTA.';?>
                <?php $xcodi=@$aso_pant['cair'];?>
                <?php $xdesc=@$aso_pant['cair_descri'];?>
              <?php } ?>
        
              <?php if($repo=='suco'){ ?>
                <?php $xtipo='';?>
                <?php $xcodi=@$aso_pant['suco'];?>
                <?php $xdesc=@$aso_pant['suco_descri'];?>
              <?php } ?>
        
              <?php if($repo=='iva'){ ?>
                <?php $xtipo='IVA';?>
                <?php $xcodi=@$aso_pant['cair'];?>
                <?php $xdesc=@$aso_pant['cair_descri'];?>
              <?php } ?>
        
              <?php if($repo=='porc'){ ?>
                <?php $xtipo='RTA.';?>
                <?php $xcodi=@$aso_pant['cair'];?>
                <?php $xdesc=@$aso_pant['cair_descri'];?>
                <?php if(!mb_stristr('3456',substr($xcodi,0,1))){ ?>
                  <?php $xtipo='IVA';?>
                  <?php $xcodi='-';?>
                  <?php $xdesc=@number_format($aso_pant['puni'],2).'%';?>
                <?php } ?>
        
              <?php } ?>
        
              <?php if($repo=='idnum1' or  $repo=='iddet'){ ?>
                <?php $xtipo=@$aso_pant['docu'];?>
                <?php $xcodi=@$aso_pant['numero'];?>
                <?php $xdesc=@$aso_pant['fecha'];?>
              <?php } ?>
        
              <?php if($repo=='fmes'){ ?>
                <?php $xtipo=@$aso_pant['fanio'];?>
                <?php $xcodi=@$aso_pant['fmes'];?>
                <?php $xdesc=@date('M / Y' ,strtotime($aso_pant['fecha']));?>
              <?php } ?>
        
        
              <?php $xdesclen=strlen($xdesc);?>
              <?php $xtotal =$aso_pant['stotal']; ?>
              <?php $xvarval=$xsaldo-$xsaldoi; ?>
              <?php $xvarpor=0; ?>
              <?php $xsaldoc=0; ?>
              <?php if($xsaldoi!=0){$xvarpor=($xvarval/$xsaldoi)*100;} ?>

              <?php if($total!=0){$xporpar=($xtotal/$total)*100; $tporpar+=$xporpar;} ?>
        
        
            <?php echo '<div></div>'; ?>
        
            <?php if($lineaok==1){ ?>
            <?php $last_codi=$xcodi; ?>
            <?php $crow++; ?> 
            <?php $clin++; ?> 
        
            <tr id="tr_fila<?php echo $crow;?>" class="tr_fila" 
                style="
                       <?php if($clin%5==0){echo 'border-bottom:dotted 1px;'; } ?>
                       "
                <?php if(substr($pant,0,1)=='P'){?> 
                onmouseover="_filabg(event,'tr_fila','<?php echo $crow; ?>','');"
                <?php } ?>
                onclick="_filabg(event,'tr_fila','<?php echo $crow; ?>','');
                        <?php if(substr($pant,0,1)=='P' and $repo!='lldd'){?> 
                        {info_modu('PANT2','<?php echo $modu; ?>','<?php echo $xcodi; ?>');}
                        <?php } ?> 
                         "
                >
              
                <td style="display:none;"><?php echo fillzero($crow,5); ?></td>
  
              <?php if(substr($pant,0,4)=='PANT'){ ?>
                <td>
                <?php $pidtxt='imprim'; $pcaption='Imprimir '; $pabrev='I';
                  $ponclick='';
                  $ponclick.='document.getElementById("'.$repo.'").value="'.$aso_pant['enti'].'";';
                  $ponclick.='info_docu("IMPR1",'.'document.getElementById("docu").value'.');'; 
                  $ponclick.='document.getElementById("'.$repo.'").value="";';
                  $psize=$xfontsize; 
                if(mb_stristr($pant,'PANT') and $mobile!='true'){include('vrbutton.php');}
                               
                ?>
                </td>  
              <?php } ?>
              
                <?php //if($repo=='enti') { ?>
                <?php { ?>
              
                <?php if($repo!='idnum1' and $repo!='iddet'){?>
                <td align="center" style="">
                  <?php echo $aso_pant['cidnum1']; ?>
                </td>	
                <?php } ?>
              
              
                <td align="center" style="">
                  <?php echo $xtipo; ?>
                </td>	
                <td align="<?php if(mb_stristr('enti.fmes.fsema.fecha.zsub.tpro.cair.suco',$repo)){echo 'center';} ?>" style="">
                  <?php if(mb_stristr('fmes.fsema.fecha',$repo)){ ?>
                      <div style="display:none;"><?php echo $xtipo; ?></div>
                  <?php } ?>
                  <?php echo $xcodi; ?>
                </td>	
                <td align="<?php if(mb_stristr('fmes.fsema.fecha.idnum1.',$repo)){echo 'center';} ?>" style="border-right:solid 1px;">
                  <?php if(mb_stristr('fmes.fsema.',$repo)){ ?>
                      <div style="display:none;"><?php echo $xcodi.$xtipo; ?></div>
                  <?php } ?>
                  <?php if(substr($pant,0,4)=='PANT'){echo split_words($xdesc);} else {echo $xdesc;} ?>
                  <?php //echo split_words($xdesc); ?>
                  <?php if(mb_stristr('fecha.idnum1',$repo)){ ?>
                      <div style="display:none;"><?php echo $xcodi.$xtipo; ?></div>
                  <?php } ?>
                </td>	
                <?php } ?>
              
                <?php if($repo=='idnum1'){ ?>
                  <td align="center" style="">
                    <?php echo $aso_pant['enti']; ?>
                  </td>	
                  <td align="" style="">
                  <?php if(substr($pant,0,4)=='PANT'){echo split_words($aso_pant['enti_descri']);} else {echo $aso_pant['enti_descri'];} ?>
                    <?php //echo split_words($aso_pant['enti_descri']); ?>
                  </td>	
                <?php } ?>

                <?php if($repo=='iddet'){ ?>
                  <td align="center" style="">
                    <?php echo $aso_pant['item']; ?>
                  </td>	
                  <td align="" style="">
                  <?php if(substr($pant,0,4)=='PANT'){echo split_words($aso_pant['item_descri']);} else {echo $aso_pant['item_descri'];} ?>
                  </td>	
                <?php } ?>

                <?php if($repo=='enti'){ ?>
                  <td align="center" style="">
                    <?php if($aso_pant['enti_rise']==1){echo 'S';}else{echo 'N';}; ?>
                  </td>	
                <?php } ?>

                <?php if($docuiimp){ ?>
                  <td align="right" style="<?php if($tcant==0){echo'display:;';}else{echo'';}?> ">
                    <?php echo number_format(abs($aso_pant['stcant']),2); ?>
                  </td>	
                  <td align="right" style="<?php if($tdcto==0){echo'display:;';}else{echo'';}?> ">
                    <?php echo number_format(abs($aso_pant['stsubt']),2); ?>
                  </td>	
                  <td align="right" style="<?php if($tdcto==0){echo'display:none;';}else{echo'text-decoration:underline;';}?> font-style:italic;">
                    <?php echo number_format(abs($aso_pant['stdcto']),2); ?>
                  </td>	
                  <td align="right" style="<?php if($tssid==0){echo'display:none;';}else{echo'text-decoration:underline;';}?> font-style:italic;">
                    <?php echo number_format(abs($aso_pant['stssid']),2); ?>
                  </td>	
                  <td align="right" style="<?php if($tice==0){echo'display:none;';}?> font-style:italic;">
                    <?php echo number_format(abs($aso_pant['stice']),2); ?>
                  </td>	
                  <td align="right" style="<?php if($tsubtiva0==0){echo'display:none;';}?>">
                    <?php echo number_format(abs($aso_pant['stsubtiva0']),2); ?>
                  </td>	
                  <td align="right" style="<?php if($tsubtiva==0){echo'display:none;';}?>">
                    <?php echo number_format(abs($aso_pant['stsubtiva']),2); ?>
                  </td>	
                  <td align="right" style="<?php if($tprop==0){echo'display:none;';}?> font-style:italic;">
                    <?php echo number_format(abs($aso_pant['stprop']),2); ?>
                  </td>	
                  <td align="right" style="<?php if($tiva==0){echo'display:none;';}?> font-style:italic;">
                    <?php echo number_format(abs($aso_pant['stiva']),2); ?>
                  </td>	
                  <td align="right" style="<?php if($tirbp==0){echo'display:none;';}?> font-style:italic;">
                    <?php echo number_format(abs($aso_pant['stirbp']),2); ?>
                  </td>	
              <?php } ?>

              
					<?php if(mb_stristr('retc.retp.rete',$tabla)){?>
              <?php if($dispcolu!=0){?>
                <td align="right" style="font-style:italic;"> 
                  <?php echo number_format(abs($aso_pant['sbrta']),2); ?>
                </td>
              <?php } ?>
                <?php if(ceil($aso_pant['sprta'])==floor($aso_pant['sprta'])){$dval=0;}else{$dval=2;}?>
                <td align="center" style=" font-size:<?php echo $xfontsize-2;?>px;"> 
                  <?php echo number_format(abs($aso_pant['sprta']),$dval).'%'; ?>
                </td>
              <?php if($dispcolu!=0){?>
                <td align="right" style="border-right:dotted 1px;">
                  <?php echo number_format(abs($aso_pant['srrta']),2); ?>
                </td>
              <?php } ?>
              <?php if($dispcolu!=0){?>
                <td align="right" style="font-style:italic;"> 
                  <?php echo number_format(abs($aso_pant['sbiva']),2); ?>
                </td>
              <?php } ?>
                <?php if(ceil($aso_pant['spiva'])==floor($aso_pant['spiva'])){$dval=0;}else{$dval=2;}?>
                <td align="center" style=" font-size:<?php echo $xfontsize-2;?>px;"> 
                  <?php echo number_format(abs($aso_pant['spiva']),$dval).'%'; ?>
                </td>
              <?php if($dispcolu!=0){?>
                <td align="right" style="border-right:dotted 1px;">
                  <?php echo number_format(abs($aso_pant['sriva']),2); ?>
                </td>
              <?php } ?>
					<?php } ?>	
              
              
              
              <td align="right" style="font-weight:bold;"> 
                <?php echo number_format(abs($aso_pant['stotal']),2); ?>
              </td>
              
              <td align="right" style="font-weight:bold;"> 
                <?php echo number_format(abs($xporpar),2).'%'; ?>
              </td>
              

              
            </tr>
              <?php } 
            ?>
            <?php } ?>
        
        
			</tbody>
		<?php } ?>	
  
      <?php $timew2=date('U'); ?>
      <?php { // FOOT ?>
			<tfoot style="<?php echo $tdisplay; ?><?php if($mobile!='true'){echo 'max-width:'.($screenw-20).'px;';} ?>;background-color:<?php echo $gris1; ?>; font-size:<?php echo $xfontsize*1;?>px;">
				<tr style="border-top:solid 1px;border-bottom:solid 1px;">
          <th style="display:none;"<?php $ccol--; ?>></th>

          <?php if(substr($pant,0,4)=='PANT'){?>
					<th <?php $ccol--; ?>></th>
          <?php } ?>
          <th <?php $ccol--; ?>><?php echo $tcidnum1; ?></th>
          <th <?php $ccol--; ?>></th>
          

          <?php if(mb_stristr('enti.item.vndd.zsub.lsub.tpro.fmes.fsema.fecha.ptov.ptoe.idnum1.ctas.cair.iva.porc',$repo)){ ?>
            <th <?php $ccol--; ?>><?php echo $crow; ?></th>
          <?php } ?>
          
          <?php if(mb_stristr('idnum1.iddet',$repo)){ ?>
            <th <?php $ccol--; ?>></th>
            <th <?php $ccol--; ?>></th>
          <?php } ?>
          
					<th <?php $ccol--; ?> style="max-width:;letter-spacing:5px; " >TOTALES</th>
          
					<?php if(mb_stristr('RETC.RETP',$modu)){ ?>
          <?php if($dispcolu!=0){?>
						<th <?php $ccol--; ?>align="right" style="font-style: ;">
							<?php echo number_format(abs($tbrta),2); ?>
						</th>	
          <?php } ?>
						<th <?php $ccol--; ?>></th>
          <?php if($dispcolu!=0){?>
						<th <?php $ccol--; ?>align="right" style="font-style:italic;">
							<?php echo number_format(abs($trrta),2); ?>
						</th>	
          <?php } ?>
          <?php if($dispcolu!=0){?>
						<th <?php $ccol--; ?>align="right">
							<?php echo number_format(abs($tbiva),2); ?>
						</th>	
          <?php } ?>
						<th <?php $ccol--; ?>></th>
          <?php if($dispcolu!=0){?>
						<th <?php $ccol--; ?>align="right" style="font-style:italic;">
							<?php echo number_format(abs($triva),2); ?>
						</th>	
          <?php } ?>
            <?php //$tsaldo=$total;?>
            <?php //$ccol--;?>
					<?php } ?>
          
          
					<th <?php $ccol--; ?> align="right">
						<?php echo number_format(abs($total),2); ?>
					</th>
          
					<th <?php $ccol--; ?> align="right">
						<?php echo number_format($tporpar,2).'%'; ?>
					</th>
          
          <?php if($ccol<0){$ccol=0;}?>
          <?php if(mb_stristr($pant,'PANT')){?>
          <?php echo str_repeat('<th></th>',$ccol); ?>
          <?php } ?>
				</tr>
        
        
			</tfoot>
			<?php } ?>	
		</table>
  
<?php } ?>
  

<?php if(mb_stristr('SRI1',$modu)){ ?>  
		<table id="tpant1" class="pant1" border="0"
					 align="center" cellpadding="3" width="100%"
					 style="font-size:<?php if($orient=='V'){echo $xfontsize-8;}else{echo $xfontsize;} ?>px;
						border-collapse:collapse;background-color:snow; position:; <?php if($pant=='IMPR' and 1==2 ){echo 'max-width:210mm;';}?>"
						>
			<?php { // THEAD ?>
			<thead style="<?php echo $tdisplay; ?><?php if($mobile!='true'){echo 'max-width:'.($screenw-20).'px;';} ?>;background-color:<?php echo $gris1; ?>;">
        
        <?php if(1==1){?>        
				<tr style="border-top:solid 1px;border-bottom:solid 1px; cursor:pointer;" border="0">
            <?php if(substr($pant,0,4)=='PANT'){?>
<!--             <th colspan="1"></th> -->
            <th colspan="4"></th>
            <?php } ?>
            <th colspan="3"></th>
            <th colspan="4">VENTAS</th>
            <th colspan="3" title="Retenciones de Ventas en Renta">R.V. RENTA</th>
            <th colspan="3" title="Retenciones de Ventas en IVA">R.V. IVA</th>
            <th colspan="4">COMPRAS</th>
            <th colspan="3" title="Retenciones de Compras en Renta">R.C. RENTA</th>
            <th colspan="3" title="Retenciones de Compras en IVA">R.C. IVA</th>
            <th colspan="3"></th>
        </tr>
        <?php }?>
				<tr style="border-top:solid 1px;border-bottom:solid 1px; cursor:pointer; " >
          <th onclick="sortTable(this,0);" style="display:none;"><?php  $ccol++; ?></th>
          
          <?php if(substr($pant,0,4)=='PANT'){?>
					<th onclick="sortTable(this,<?php echo $ccol++; ?>);" title="Imprimir">I</th>
          <?php } ?>
          
          <?php if($repo=='sria'){ ?>
            <?php if(substr($pant,0,4)=='PANT'){?>
            <th onclick="sortTable(this,<?php echo $ccol++; ?>);" title="103">3</th>
            <th onclick="sortTable(this,<?php echo $ccol++; ?>);" title="104">4</th>
            <th onclick="sortTable(this,<?php echo $ccol++; ?>);" title="ATS">A</th>
            <?php } ?>
            <th onclick="sortTable(this,<?php echo $ccol++; ?>);" title="">AÑO</th>
            <th onclick="sortTable(this,<?php echo $ccol++; ?>);" title="">MES</th>
            <th onclick="sortTable(this,<?php echo $ccol++; ?>);" title="" style="border-right:;">DESCRI</th>
          <?php // echo number_format($porciva,0);?>
            <th onclick="sortTable(this,<?php echo $ccol++; ?>,'N');" title=""><span style="display:none;">VTAS. </span>IVA 0</th>
            <th onclick="sortTable(this,<?php echo $ccol++; ?>,'N');" title=""><span style="display:none;">VTAS. </span>IVA </th>
            <th onclick="sortTable(this,<?php echo $ccol++; ?>,'N');" title="" style="font-style:italic;"><span style="display:none;">IVA VTAS. </span>%</th>
            <th onclick="sortTable(this,<?php echo $ccol++; ?>,'N');" title="">#V</th>
          
            <th onclick="sortTable(this,<?php echo $ccol++; ?>,'N');" title=""><span style="display:none;">R.V. Rta. </span>Base</th>
            <th onclick="sortTable(this,<?php echo $ccol++; ?>,'N');" title=""><span style="display:none;">R.V. Rta. </span>Rete</th>
            <th onclick="sortTable(this,<?php echo $ccol++; ?>,'N');" title=""><span style="display:none;">R.V. Rta. </span>#R</th>
            <th onclick="sortTable(this,<?php echo $ccol++; ?>,'N');" title=""><span style="display:none;">R.V. IVA </span>Base</th>
            <th onclick="sortTable(this,<?php echo $ccol++; ?>,'N');" title="" style="font-style:italic;"><span style="display:none;">R.V. IVA </span>Rete</th>
            <th onclick="sortTable(this,<?php echo $ccol++; ?>,'N');" title=""><span style="display:none;">R.V. IVA. </span>#I</th>
          
            <th onclick="sortTable(this,<?php echo $ccol++; ?>,'N');" title=""><span style="display:none;">COMP. </span>IVA 0</th>
            <th onclick="sortTable(this,<?php echo $ccol++; ?>,'N');" title=""><span style="display:none;">COMP. </span>IVA</th>
            <th onclick="sortTable(this,<?php echo $ccol++; ?>,'N');" title="" style="font-style:italic;"><span style="display:none;">IVA COMP. </span>%</th>
            <th onclick="sortTable(this,<?php echo $ccol++; ?>,'N');" title="">#C</th>
          
            <th onclick="sortTable(this,<?php echo $ccol++; ?>,'N');" title=""><span style="display:none;">R.C. Rta. </span>Base</th>
            <th onclick="sortTable(this,<?php echo $ccol++; ?>,'N');" title=""><span style="display:none;">R.C. Rta. </span>Rete</th>
            <th onclick="sortTable(this,<?php echo $ccol++; ?>,'N');" title=""><span style="display:none;">R.C. Rta. </span>#R</th>
            <th onclick="sortTable(this,<?php echo $ccol++; ?>,'N');" title=""><span style="display:none;">R.C. IVA </span>Base</th>
            <th onclick="sortTable(this,<?php echo $ccol++; ?>,'N');" title="" style="font-style:italic;"><span style="display:none;">R.C. IVA </span>Rete</th>
            <th onclick="sortTable(this,<?php echo $ccol++; ?>,'N');" title=""><span style="display:none;">R.C. IVA. </span>#I</th>
          
          <?php } ?>

					<th onclick="sortTable(this,<?php echo $ccol++; ?>,'N');" title="">TOTAL</th>
					<th onclick="sortTable(this,<?php echo $ccol++; ?>,'N');" title="">%</th>
					<th onclick="sortTable(this,<?php echo $ccol++; ?>,'N');" title="" style="font-style:italic;">IVA</th>
          
          <th style="font-size:<?php echo $xfontsize*.5;?>px;" title="Descargar XLS">
            <a href="#" id="downxls1" onClick="javascript:fnExcelReport('tpant1',this,'<?php echo $cfg_empr.'_'.$modu.'_'.date('Ymd_His');?>');">XLS</a>
          </th>
				</tr>
			</thead>
			<?php } ?>
      <?php $timew1=date('U'); ?>

      <?php //die();?>
      
			<?php  {// TBODY ?>
			<tbody id="tpant1b" valign="top" style="overflow-y:auto; <?php echo $tdisplay; ?>; 
							<?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 if(@mysql_num_rows($res_pant)==0){?>
          <tr><td style="font-weight:bold;">
            <?php echo 'NO HAY DATOS'; ?>  
            <?php echo '<br>==>'.date('H:i:s'); ?>
            <?php //echo '<br>'.$docu.' /'.$enti; ?>
          </td></tr>
        <?php }?>
        <?php if($user_cons==0){?>
          <tr><td style="font-weight:bold;color:red;">NO TIENE ACCESO PARA CONSULTAR ==> <?php echo $modu.' - '.r_fiel('modu',$modu);?></td></tr>
        <?php }?>

        <?php $last_codi=''; ?>
        <?php $last_idnum='';?>
        <?php $last_base=0; ?>
        <?php $last_niv1=0; ?>
        <?php $cctas=0; ?>
        <?php $xdocusal0=''; ?>
        
            <?php while($aso_pant=@mysql_fetch_assoc($res_pant)){ ?>
            <?php $status=$aso_pant['status']; ?>
            <?php $id_trfila=fillzero($crow);?> 
            <?php $lineaok=1;?>
              <?php $xidnum =$aso_pant['idnum1'];?>
        
              <?php $xdocum =$aso_pant['docum'];?>
              <?php $xptoem =$aso_pant['ptoem'];?>
              <?php $xnumer =$aso_pant['numer'];?>
        
              
        
              <?php if($repo=='sria'){ ?>
                <?php $xtipo=@$aso_pant['fanio'];?>
                <?php $xcodi=@$aso_pant['fmes'];?>
                <?php $xdesc=@date('M /Y' ,strtotime($aso_pant['fecha']));?>
              <?php } ?>
        
        
              <?php $xdesclen=strlen($xdesc);?>
              <?php $xtotal =$aso_pant['stotal']; ?>
              <?php $xvarval=$xsaldo-$xsaldoi; ?>
              <?php $xvarpor=0; ?>
              <?php $xsaldoc=0; ?>
              <?php if($xsaldoi!=0){$xvarpor=($xvarval/$xsaldoi)*100;} ?>

              <?php if($total!=0){$xporpar=($xtotal/$total)*100; $tporpar+=$xporpar;} ?>
        
        
            <?php echo '<div></div>'; ?>
        
            <?php if($lineaok==1){ ?>
            <?php $last_codi=$xcodi; ?>
            <?php $crow++; ?> 
            <?php $clin++; ?> 
        
            <tr id="tr_fila<?php echo $crow;?>" class="tr_fila" 
                style="
                       <?php if($clin%5==0){echo 'border-bottom:dotted 1px;'; } ?>
                       "
                <?php if(substr($pant,0,1)=='P'){?> 
                onmouseover="_filabg(event,'tr_fila','<?php echo $crow; ?>','');"
                <?php } ?>
                onclick="_filabg(event,'tr_fila','<?php echo $crow; ?>','');
                        <?php if(substr($pant,0,1)=='P' and $repo!='lldd'){?> 
                        {info_modu('PANT2','<?php echo $modu; ?>','<?php echo $xcodi; ?>');}
                        <?php } ?> 
                         "
                >
              
                <td style="display:none;"><?php echo fillzero($crow,5); ?></td>
  
              <?php if(substr($pant,0,4)=='PANT'){ ?>
                <td>
                <?php $pidtxt='imprim'; $pcaption='Imprimir '; $pabrev='I';
                  $ponclick='';
                  $ponclick.='document.getElementById("fecha1").value="'.$aso_pant['enti'].'";';
                  $ponclick.='info_modu("IMPR1",'.'document.getElementById("docu").value'.');'; 
                  $ponclick.='document.getElementById("'.$repo.'").value="";';
                  $psize=$xfontsize; 
                if(mb_stristr($pant,'PANT') and $mobile!='true'){include('vrbutton.php');}
                               
                ?>
                </td>  
              <?php } ?>
              
                <?php { ?>
                <?php if(mb_stristr($pant,'PANT')) { ?>
              
                <td align="center" title="Descargar F-103" style="">
                  <?php $xonclick="gen_103('".$aso_pant['fanio']."','".$aso_pant['fmes']."');"?>
                  <?php $xonclick.="down_url('_doc/F103_".$aso_pant['fanio'].$aso_pant['fmes']."_".$cfg_empr.".xml');"?>
                  <?php $xonclick.="down_url('_doc/F103_".$aso_pant['fanio'].$aso_pant['fmes']."_".$cfg_empr.".html');"?>
                  <a href="#" onclick="<?php echo $xonclick; ?>" >3</a>
                </td>	
                <td align="center" title="Descargar F-104" style="">
                  <?php $xonclick="gen_104('".$aso_pant['fanio']."','".$aso_pant['fmes']."');"?>
                  <?php $xonclick.="down_url('_doc/F104_".$aso_pant['fanio'].$aso_pant['fmes']."_".$cfg_empr.".xml');"?>
                  <?php $xonclick.="down_url('_doc/F104_".$aso_pant['fanio'].$aso_pant['fmes']."_".$cfg_empr.".html');"?>
                  <a href="#" onclick="<?php echo $xonclick; ?>" >4</a>
                </td>	
                <td align="center" title="Descargar <?php echo 'ATS_'.$aso_pant['fanio'].$aso_pant['fmes'];?>">
<!--                 <a href="../lib/vratsxml1.php?fanio=<?php //echo $aso_pant['fanio']; ?>&fmes=<?php echo $aso_pant['fmes']; ?>" >A</a> -->

                <?php //echo ' / '; ?>
                  
                  <?php $xonclick="gen_ats('".$aso_pant['fanio']."','".$aso_pant['fmes']."');"?>
                  <?php $xonclick.="down_url('_doc/ATS_".$aso_pant['fanio'].$aso_pant['fmes']."_".$cfg_empr.".xml')"?>
                  <a href="#" onclick="<?php echo $xonclick; ?>" >A</a>
                </td>
                <?php } ?>

              
                <td align="center" style="">
                  <?php echo $xtipo; ?>
                </td>	
              
                <td align="<?php if(mb_stristr('enti.fmes.fsema.fecha.zsub.tpro.cair.suco.sria',$repo)){echo 'center';} ?>" style="">
                  <?php if(mb_stristr('fmes.fsema.fecha.sria',$repo)){ ?>
                      <div style="display:none;"><?php echo $xtipo; ?></div>
                  <?php } ?>
                  <?php echo $xcodi; ?>
                </td>	
              
                <td align="<?php if(mb_stristr('fmes.fsema.fecha.idnum1.sria',$repo)){echo 'center';} ?>" style="border-right:solid 1px;">
                  <?php if(mb_stristr('fmes.fsema.sria',$repo)){ ?>
                      <div style="display:none;"><?php echo $xcodi.$xtipo; ?></div>
                  <?php } ?>
                  <?php if(substr($pant,0,4)=='PANT'){echo split_words($xdesc);} else {echo $xdesc;} ?>
                  <?php //echo split_words($xdesc); ?>
                  <?php if(mb_stristr('fecha.idnum1',$repo)){ ?>
                      <div style="display:none;"><?php echo $xcodi.$xtipo; ?></div>
                  <?php } ?>
                </td>	
                <?php } ?>
              

                <?php if($repo=='sria'){ ?>
                  <td align="right" style="">
                    <?php echo number_format(($aso_pant['vtastsubtiva0']),2); ?>
                  </td>	
                  <td align="right" style="">
                    <?php echo number_format(($aso_pant['vtastsubtiva']),2); ?>
                  </td>	
                  <td align="right" style="font-style:italic;">
                    <?php echo number_format(($aso_pant['vtastiva']),2); ?>
                  </td>	
                  <td align="center" style="border-right:solid 1px;">
                    <?php echo number_format(($aso_pant['vtascenti']),0); ?>
                    <?php if ($aso_pant['vta0cid']>0){?>
                    <?php echo '('.number_format(($aso_pant['vta0cid']),0).')'; ?>
                    <?php } ?>
                  </td>	
              
                  <td align="right" style="">
                    <?php echo number_format(($aso_pant['retcbrta']),2); ?>
                  </td>	
                  <td align="right" style="">
                    <?php echo number_format(($aso_pant['retcrrta']),2); ?>
                  </td>	
                  <td align="center" style="border-right:dotted 1px;">
                    <?php echo number_format(($aso_pant['retccidr']),0); ?>
                  </td>	
                  <td align="right" style="">
                    <?php echo number_format(($aso_pant['retcbiva']),2); ?>
                  </td>	
                  <td align="right" style="font-style:italic;">
                    <?php echo number_format(($aso_pant['retcriva']),2); ?>
                  </td>	
                  <td align="center" style="border-right:solid 1px;">
                    <?php echo number_format(($aso_pant['retccidi']),0); ?>
                  </td>	
              
                  <td align="right" style="">
                    <?php echo number_format(($aso_pant['comptsubtiva0']),2); ?>
                  </td>	
                  <td align="right" style="">
                    <?php echo number_format(($aso_pant['comptsubtiva']),2); ?>
                  </td>	
                  <td align="right" style="font-style:italic;">
                    <?php echo number_format(($aso_pant['comptiva']),2); ?>
                  </td>	
                  <td align="center" style="border-right:solid 1px;">
                    <?php echo number_format(($aso_pant['compcid']),0); ?>
                  </td>	
              
                  <td align="right" style="">
                    <?php echo number_format(($aso_pant['retpbrta']),2); ?>
                  </td>	
                  <td align="right" style="">
                    <?php echo number_format(($aso_pant['retprrta']),2); ?>
                  </td>	
                  <td align="center" style="border-right:dotted 1px;">
                    <?php echo number_format(($aso_pant['retpcidr']),0); ?>
                  </td>	
                  <td align="right" style="">
                    <?php echo number_format(($aso_pant['retpbiva']),2); ?>
                  </td>	
                  <td align="right" style="font-style:italic;">
                    <?php echo number_format(($aso_pant['retpriva']),2); ?>
                  </td>	
                  <td align="center" style="border-right:solid 1px;">
                    <?php echo number_format(($aso_pant['retpcidi']),0); ?>
                  </td>	
              
              <?php } ?>

              
              
              
              
              <td align="right" style="font-weight:bold;"> 
                <?php echo number_format(($aso_pant['stotal']),2); ?>
              </td>
              
              <td align="right" style="font-weight:bold;"> 
                <?php echo number_format(($xporpar),2).'%'; ?>
              </td>
              
              <td align="right" style="font-weight:bold;font-style:italic;"> 
                <?php echo number_format(($aso_pant['stotaliva']),2); ?>
              </td>
              

              
            </tr>
              <?php } 
            ?>
            <?php } ?>
        
        
			</tbody>
		<?php } ?>	
  
      <?php $timew2=date('U'); ?>
      <?php { // FOOT ?>
			<tfoot style="<?php echo $tdisplay; ?><?php if($mobile!='true'){echo 'max-width:'.($screenw-20).'px;';} ?>;background-color:<?php echo $gris1; ?>; font-size:<?php echo $xfontsize*1;?>px;">
				<tr style="border-top:solid 1px;border-bottom:solid 1px;">
          <th style="display:none;"<?php $ccol--; ?>></th>

          <?php if(substr($pant,0,4)=='PANT'){?>
					<th <?php $ccol--; ?>></th>
          <?php } ?>
          <th <?php $ccol--; ?>></th>
          <?php if(mb_stristr($pant,'PANT')) { ?>
          <th <?php $ccol--; ?>></th>
          <th <?php $ccol--; ?>></th>
          <th <?php $ccol--; ?>></th>
          <?php } ?>
          
          <?php if(mb_stristr('sria',$repo)){ ?>
            <th <?php $ccol--; ?>><?php echo $crow; ?></th>
          <?php } ?>

          
					<th <?php $ccol--; ?> style="max-width:;letter-spacing:5px; " >TOTALES</th>

            
					<?php if(mb_stristr('SRI1',$modu)){ ?>
						<th <?php $ccol--; ?>align="right" style="font-style: ;">
							<?php echo number_format(($svtastsubtiva0),2); ?>
						</th>	
						<th <?php $ccol--; ?>align="right" style="font-style: ;">
							<?php echo number_format(($svtastsubtiva),2); ?>
						</th>	
						<th <?php $ccol--; ?>align="right" style="font-style:italic ;">
							<?php echo number_format(($svtastiva),2); ?>
						</th>	
						<th <?php $ccol--; ?>align="center" style="font-style: ;">
							<?php echo number_format(($svtascid),0); ?>
							<?php //echo number_format(($svtascenti),0); ?>
						</th>	
          
						<th <?php $ccol--; ?>align="right" style="font-style: ;">
							<?php echo number_format(abs($sretcbrta),2); ?>
						</th>	
						<th <?php $ccol--; ?>align="right" style="font-style: ;">
							<?php echo number_format(abs($sretcrrta),2); ?>
						</th>	
						<th <?php $ccol--; ?>align="center" style="font-style: ;">
							<?php echo number_format(($sretccidr),0); ?>
						</th>	
						<th <?php $ccol--; ?>align="right" style="font-style: ;">
							<?php echo number_format(abs($sretcbiva),2); ?>
						</th>	
						<th <?php $ccol--; ?>align="right" style="font-style:italic ;">
							<?php echo number_format(abs($sretcriva),2); ?>
						</th>	
						<th <?php $ccol--; ?>align="center" style="font-style: ;">
							<?php echo number_format(($sretccidi),0); ?>
						</th>	
          
						<th <?php $ccol--; ?>align="right" style="font-style: ;">
							<?php echo number_format(($scomptsubtiva0),2); ?>
						</th>	
						<th <?php $ccol--; ?>align="right" style="font-style: ;">
							<?php echo number_format(($scomptsubtiva),2); ?>
						</th>	
						<th <?php $ccol--; ?>align="right" style="font-style:italic ;">
							<?php echo number_format(($scomptiva),2); ?>
						</th>	
						<th <?php $ccol--; ?>align="center" style="font-style: ;">
							<?php echo number_format(($scompcid),0); ?>
						</th>	
          
						<th <?php $ccol--; ?>align="right" style="font-style: ;">
							<?php echo number_format(abs($sretpbrta),2); ?>
						</th>	
						<th <?php $ccol--; ?>align="right" style="font-style: ;">
							<?php echo number_format(abs($sretprrta),2); ?>
						</th>	
						<th <?php $ccol--; ?>align="center" style="font-style: ;">
							<?php echo number_format(($sretpcidr),0); ?>
						</th>	
						<th <?php $ccol--; ?>align="right" style="font-style: ;">
							<?php echo number_format(abs($sretpbiva),2); ?>
						</th>	
						<th <?php $ccol--; ?>align="right" style="font-style:italic ;">
							<?php echo number_format(abs($sretpriva),2); ?>
						</th>	
						<th <?php $ccol--; ?>align="center" style="font-style: ;">
							<?php echo number_format(($sretpcidi),0); ?>
						</th>	
          
          
					<?php } ?>
          
          
					<th <?php $ccol--; ?> align="right">
						<?php echo number_format(($total),2); ?>
					</th>
          
					<th <?php $ccol--; ?> align="right">
						<?php echo number_format($tporpar,2).'%'; ?>
					</th>
          
					<th <?php $ccol--; ?> align="right" style="font-style:italic;">
						<?php echo number_format(($totaliva),2); ?>
					</th>
          
          
          <?php if($ccol<0){$ccol=0;}?>
          <?php if(mb_stristr($pant,'PANT')){?>
          <?php echo str_repeat('<th></th>',$ccol); ?>
          <?php } ?>
				</tr>
        
        
			</tfoot>
			<?php } ?>	
		</table>
  
<?php } ?>
  
  

      <msgsistemas <?php if($user_tipo!='sist' or 1==1){echo 'style="display:none;"';} ?> >
      <?php
//       if($user_tipo=='sist')
      {
        echo ' Recs: '.($crow) ; 
        echo ' Segs: '.($timew2-$timew1); 
        echo ' Speed: '.@(number_format($crow/($timew2-$timew1),2)) .' r/s'; 
      }
      ?> 
      </msgsistemas>
    
  
<?php if(mb_stristr('IMPR',$pant)){ ?>
  
</div>	
</body>	
<?php //////////////////////////////////////////////////////////	?>

</html>

  
<?php } ?>  
  
    
    
	</pant1>

  <?php //echo '***'.date('H:i:s') .'<br>';?>
				
<?php } ?>			
		
<?php if(mb_stristr('PANT2.IMPR2',$pant)){ ?>
<?php {

  if(mb_stristr('CONT.',$modu))
  {
    $sql_pant ='select '.$tabla.'12.*  ';
    $sql_pant.=' from '.$tabla.'12 ';
    $sql_pant.=' where ctas like "'.$codigo.'%"';
    $sql_pant.=' and fecha>="'.$fecha1.'"';
    $sql_pant.=' and fecha<="'.$fecha2.'"';
//     $sql_pant.=' order by ctas,fecha,mdfrom,docu,idnum1 ';
    $sql_pant.=' order by ctas,fecha, ';
    if(mb_stristr('1.2.3',substr($codigo,0,1)))
    {$sql_pant.=' tdebito desc,mdfrom,docu,idnum1 ';}
    else
    {$sql_pant.=' tcredito desc,mdfrom,docu,idnum1 ';}
    $res_pant=mysql_query($sql_pant,$link_vcrx); 
    $xsaldos=sal_ctas($codigo.'%',$fecha1,$fecha2);
  }
    
  if(mb_stristr('INVE.',$modu))
  {
    $sql_pant ='select '.$tabla.'12.*  ';
    $sql_pant.=' from '.$tabla.'12 ';
    $sql_pant.=' where item like "'.$codigo.'%"';
    $sql_pant.=' and fecha>="'.$fecha1.'"';
    $sql_pant.=' and fecha<="'.$fecha2.'"';
    if($bode!='')
    {$sql_pant.=' and bode="'.$bode.'"';}
    $sql_pant.=' order by item,fecha,signo desc, docu, idnum1 ';
    $res_pant=mysql_query($sql_pant,$link_vcrx); 
    $xsaldos=sal_item($codigo.'%',$fecha1,$fecha2,$bode);
  }
    
  if(mb_stristr('CXCO.CXPA.',$modu))
  {
    $xdocum=substr($codigo,10);
    $sql_pant ='select '.$tabla.'12.* ';
    $sql_pant.=' from '.$tabla.'12 ';
//     $sql_pant.=' where enti like "'.$codigo.'%"';
    $sql_pant.=' where enti like "'.substr($codigo,0,10).'%"';
    if(!empty($xdocum))
    {$sql_pant.=' and concat(docum,ptoem,numer)="'.$xdocum.'"';}
    $sql_pant.=' and fecha>="'.$fecha1.'"';
    $sql_pant.=' and fecha<="'.$fecha2.'"';
    if($modu=='CXCO')
    {$sql_pant.=' and substring(docum,1,2) in('.$docxcob.')';}
    if($modu=='CXPA')
    {$sql_pant.=' and substring(docum,1,2) in('.$docxpag.')';}
    
    $sql_where.=' and docum!=""';
    $sql_where.=' and (numer*1)>0';
    $sql_where.=' and docum is not null';
    $sql_where.=' and numer is not null';
//     $sql_where.=' and status!="O"';
    $sql_where.=' and fecha>="'.$fecha0.'" ';
    
    $sql_pant.=$sql_where;

    
    
    $sql_pant.=' order by fecha,cabdet,mdfrom,docu,idnum1 ';
    $res_pant=mysql_query($sql_pant,$link_vcrx); 
// $xhora1=date('H:i:s');

    
  
    if(mb_stristr($pant,'IMPR'))
    {    
      if($modu=='CXCO'){$xsaldos=sal_enti($codigo,$fecha1,$fecha2,'C');}
      if($modu=='CXPA'){$xsaldos=sal_enti($codigo,$fecha1,$fecha2,'P');}
    }
  }
    
    

}	?>

<?php if(mb_stristr('PANT2',$pant)){ ?>

<pant11>
	<div style="border-top:solid 1px;font-size:<?php echo $xfontsize; ?>px;">
		<?php //echo date('H:i:s');?>
		<table border="0" width="<?php if($orient=='V'){echo '200%';}else{echo '100%';} ?>" cellpadding="2" 
						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:<?php echo $gris1; ?>;">
			<tr valign="top" style="">
				<td width="1%">
				</td>
        
				<?php if(@mb_stristr('CONT.INVE.CXCO.CXPA',$modu)) { ?>
                <td style="font-weight:bold; " >
                  <?php if($modu=='CONT'){echo 'CODIGO : '.$codigo.' <br> '.r_fiel('ctas',$codigo);} ?>
                  <?php if($modu=='INVE'){echo 'CODIGO : '.$codigo.' <br> '.r_fiel('item',$codigo);} ?>
                  <?php if($modu=='CXCO'){echo 'CLIENTE : '.$codigo.' <br> '.r_fiel('enti',$codigo);} ?>
                  <?php if($modu=='CXPA'){echo 'PROVEEDOR : '.$codigo.' <br> '.r_fiel('enti',$codigo);} ?>
                </td>
                <td align="right" style="font-weight:bold;">INICIAL <?php echo date('d/M/y', strtotime($fecha1));?>:</td>
                <td><?php echo number_format($xsaldos[1],2); ?></td>
        
                <td align="right" style="font-weight:bold;">
                  <?php if(@mb_stristr('CONT.CXCO.CXPA',$modu)){echo 'DEBITOS :';}?>
                  <?php if($modu=='INVE'){echo 'INGRESOS :';}?>
                </td>
                <td><?php echo number_format($xsaldos[2],2); ?></td>
        
                <td align="right" style="font-weight:bold;">
                  <?php if(@mb_stristr('CONT.CXCO.CXPA',$modu)){echo 'CREDITOS :';}?>
                  <?php if($modu=='INVE'){echo 'EGRESOS :';}?>
                </td>
                <td><?php echo number_format($xsaldos[3],2); ?></td>
        
                <td align="right" style="font-weight:bold;">SALDO <?php echo date('d/M/y', strtotime($fecha2));?>:</td>
                <td><?php echo number_format($xsaldos[4],2); ?></td>
                <td width="25%"></td>
				<?php } ?>
        

        
			</tr>
		</table>
	</div>
	<?php if($mobile=='true'){?>
	<div style="font-size:<?php echo $xfontsize; ?>px;">
		<table width="100%" cellpadding="2" border="0"
						 style="font-size:<?php if($mobile=='true'){echo $xfontsize-8;}else{echo $xfontsize;} ?>px;
										border-collapse:collapse; background-color:<?php echo $gris1; ?>;">
			<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($tssid!=0){ ?><th align="center">SSID:</th><?php }?>
				<?php if($tprop!=0){ ?><th align="center">PROP:</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($tdebito!=0){ ?><th align="center">DEBITOS:</th><?php }?>
				<?php if($tcredito!=0){ ?><th align="center">CREDITOS:</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($tssid!=0){ ?><td align="center"><?php echo number_format($tssid,2); ?></td><?php }?>
					<?php if($tprop!=0){ ?><td align="center"><?php echo number_format($tprop,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($tdebito!=0){ ?><td align="center"><?php echo number_format($tdebito,2); ?></td><?php }?>
					<?php if($tcredito!=0){ ?><td align="center"><?php echo number_format($tcredito,2); ?></td><?php }?>
					<?php if($total!=0){ ?><td align="center"><?php echo number_format(abs($total),2); ?></td><?php }?>
			</tr>
		</table>
	</div>
	<?php } ?>

<div id="pant11a" style="display:none">
  <?php 
  ?>
</div>
  
  
<div id="pant11b" style="display:none">
  <table border="0" cellpadding="0" cellspacing="0" align="right"
         style="
                border-collapse:collapse
								padding:0px;
								margin:0px;
								width:100%;
								max-width:100%;
								font-family:arial;
								font-weight:bold;
								font-size:<?php echo $xfontsize*1.2;?>px;
         ">
    <tr><td td width=""></td><td width="1%"></td></tr>
    <?php if($tsubt!=0){?>
    <tr>
      <td align="right">
        <input type="button" value="SUB-TOTAL" style="font-weight:bold;font-size:<?php echo $xfontsize;?>px;">
      </td>
      <td align="right" >
        <?php echo number_format(abs($tsubt),2);?>
      </td>
    </tr>
    <?php } ?>
    <?php if($tdcto!=0){?>
    <tr>
      <td align="right">
        <input type="button" value="DSCTO." style="font-weight:bold;font-size:<?php echo $xfontsize;?>px;">
      </td>
      <td align="right" >
        <?php echo number_format(abs($tdcto)*-1,2);?>
      </td>
    </tr>
    <?php } ?>
    <?php if($tssid!=0){?>
    <tr>
      <td align="right">
        <input type="button" value="SSID." style="font-weight:bold;font-size:<?php echo $xfontsize;?>px;">
      </td>
      <td align="right" >
        <?php echo number_format(abs($tssid)*-1,2);?>
      </td>
    </tr>
    <?php } ?>
    <?php if($tsubtiva0!=0){?>
    <tr>
      <td align="right">
        <input type="button" value="S-TOT.IVA 0%" style="font-weight:bold;font-size:<?php echo $xfontsize;?>px;">
      </td>
      <td align="right" >
        <?php echo number_format(abs($tsubtiva0),2);?>
      </td>
    </tr>
    <?php } ?>
    <?php if($tsubtiva!=0){?>
    <tr>
      <td align="right">
        <input type="button" value="S-TOT.IVA" style="font-weight:bold;font-size:<?php echo $xfontsize;?>px;">
      </td>
      <td align="right" >
        <?php echo number_format(abs($tsubtiva),2);?>
      </td>
    </tr>
    <?php } ?>
    <?php if($tprop!=0){?>
    <tr>
      <td align="right">
        <input type="button" value="PROP." style="font-weight:bold;font-size:<?php echo $xfontsize;?>px;">
      </td>
      <td align="right" >
        <?php echo number_format(abs($tprop),2);?>
      </td>
    </tr>
    <?php } ?>
    <?php if($tice!=0){?>
    <tr>
      <td align="right">
        <input type="button" value="ICE" style="font-weight:bold;font-style:italic;font-size:<?php echo $xfontsize;?>px;">
      </td>
      <td align="right" style="font-style:italic;">
        <?php echo number_format(abs($tice),2);?>
      </td>
    </tr>
    <?php } ?>
    <?php if($tiva!=0){?>
    <tr>
      <td align="right">
        <input type="button" value="IVA" style="font-weight:bold;font-style:italic;font-size:<?php echo $xfontsize;?>px;">
      </td>
      <td align="right" style="font-style:italic;">
        <?php echo number_format(abs($tiva),2);?>
      </td>
    </tr>
    <?php } ?>
    <?php if($tirbp!=0){?>
    <tr>
      <td align="right">
        <input type="button" value="IVA" style="font-weight:bold;font-style:italic;font-size:<?php echo $xfontsize;?>px;">
      </td>
      <td align="right" style="font-style:italic;">
        <?php echo number_format(abs($tirbp),2);?>
      </td>
    </tr>
    <?php } ?>
    <?php if($tdebito!=0){?>
    <tr>
      <td align="right">
        <input type="button" value="DEBITOS" style="font-weight:bold;font-size:<?php echo $xfontsize;?>px;">
      </td>
      <td align="right" style="">
        <?php echo number_format(abs($tdebito),2);?>
      </td>
    </tr>
    <?php } ?>
    <?php if($tcredito!=0){?>
    <tr>
      <td align="right">
        <input type="button" value="CREDITOS" style="font-weight:bold;font-style:italic;font-size:<?php echo $xfontsize;?>px;">
      </td>
      <td align="right" style="font-style:italic;">
        <?php echo number_format(abs($tcredito),2);?>
      </td>
    </tr>
    <?php } ?>
    <?php if($tdifer!=0){?>
    <tr>
      <td align="right">
        <input type="button" value="DIFERENCIA" style="font-weight:bold;font-size:<?php echo $xfontsize;?>px;">
      </td>
      <td align="right" style="color:red;">
        <?php echo number_format(($tdifer),2);?>
      </td>
    </tr>
    <?php } ?>
    
    <?php if($total!=0){?>
    <tr>
      <td align="right">
        <input type="button" value="TOTAL" style="font-weight:bold;font-size:<?php echo $xfontsize*1.5;?>px;">
      </td>
      <td align="right" style=" font-size:<?php echo $xfontsize*1.5;?>px;">
        <div style="min-width:<?php echo $xfontsize*3*2;?>px;"></div>
        <?php echo ' '. number_format(abs($total),2);?>
      </td>
    </tr>
    <?php } ?>
  </table>
</div>
  
  
</pant11>

<?php } ?>  
    
<pant2>
<?php $crow=0; ?>
<?php $ccol=0; ?>
  
  
<?php if(mb_stristr('IMPR2',$pant)){ ?>
<?php $xfontsize=$xfontsize*(1.2); ?>  
<?php $xfontfamily='font-family:arial;';  ?>
    
<!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><?php echo strtoupper($cfg_empr).' -  '.r_fiel('modu',$modu); ?></title>
<style type="text/css">
p.saltodepagina{page-break-after: always;}
#header{display:none;}
@font-face{font-family:'Barcode'; src:url('/_font/BarcodeFont.ttf') format('truetype');}
barcode{font-family:'Barcode';}
@media print {.noprint {display:none}}
@media screen{.noscreen {display:none}}
  /* 	top right bottom left */
@page
{
  size: A4 <?php if(mb_stristr('sscc.sfcc.ricc',$repo)){echo 'landscape';}else{echo 'portrait';} ?>;
  margin: 10mm 5mm 10mm 5mm;
}
</style>
</head>
<body>
<div style="font-size:<?php echo $xfontsize; ?>;<?php echo $xfontfamily;?> width:; ">
<?php } ?>

<?php
  $sql_pant0=$sql_pant;
  $codigo0=$codigo;
                                       
  $sql_codis=$sql_pant0;                                       

  if($modu=='CONT')
  {
    if(mb_stristr('PANT2',$pant))
    {$sql_codis=str_replace($tabla.'12.* ','distinct '.$codigo0.' as codigo ',$sql_codis);}
    else
    {$sql_codis=str_replace($tabla.'12.* ','distinct ctas as codigo ',$sql_codis);}
  }
  if($modu=='INVE')
  {
    if(mb_stristr('PANT2',$pant))
    {$sql_codis=str_replace($tabla.'12.* ','distinct '.$codigo0.' as codigo ',$sql_codis);}
    else
    {$sql_codis=str_replace($tabla.'12.* ','distinct item as codigo ',$sql_codis);}
  }
  if(mb_stristr('CXCO.CXPA',$modu))
  {
    if(mb_stristr('PANT2',$pant))
    {$sql_codis=str_replace($tabla.'12.* ','distinct '.$codigo0.' as codigo ',$sql_codis);}
    else
    {$sql_codis=str_replace($tabla.'12.* ','distinct enti as codigo ',$sql_codis);}
  }

  if(mb_stristr('IMPR2',$pant))
  {$res_codis=mysql_query($sql_codis,$link_vcrx);}
                                       
?>

  
<?php
   if(@mysql_num_rows($res_pant)==0 and mb_stristr($pant,'PANT'))
   {
     $xdeci=2;
//     if(mb_stristr('IMPR2',$pant)){ echo '</body>'; }
      echo '<div style="font-weight:bold;">';
      echo 'NO HAY MOVIMIENTOS';  
      echo '<br>==>'.date('H:i:s'); 
      echo '</div>';
   }
?>
<?php
                                       
                                       
  $numcodis=mysql_num_rows($res_codis);
  $rowcodis=0;

  mysql_data_seek($res_codis,0);
//   while($aso_codis=mysql_fetch_assoc($res_codis))
  ($aso_codis=mysql_fetch_assoc($res_codis));
  do{
    $rowcodis++;
    $codigo=trim($aso_codis['codigo']);
    if(empty($codigo)){$codigo=$codigo0;}
    
    if(mb_stristr('CXCO.CXPA',$modu)){$codigo=fillzero($codigo,10);} 
    
    if($modu=='CONT')
    {
      $sql_gcta='select * from cont12 where ctas="'.$codigo.'" limit 1';
      $res_gcta=mysql_query($sql_gcta,$link_vcrx);
      $ctan1=@mysql_result($res_gcta,0,'ctan1');
      $ctan2=@mysql_result($res_gcta,0,'ctan2');
      $ctan3=@mysql_result($res_gcta,0,'ctan3');
      $ctan4=@mysql_result($res_gcta,0,'ctan4');
      $ctan5=@mysql_result($res_gcta,0,'ctan5');
      $descri1=@mysql_result($res_gcta,0,'descri1');
      $descri2=@mysql_result($res_gcta,0,'descri2');
      $descri3=@mysql_result($res_gcta,0,'descri3');
      $descri4=@mysql_result($res_gcta,0,'descri4');
      $descri5=@mysql_result($res_gcta,0,'descri5');
    }
    
    if($ctan5==$ctan4){$ctan5='';}
    if($ctan4==$ctan3){$ctan4='';}
    if($ctan3==$ctan2){$ctan3='';}
    if($ctan2==$ctan1){$ctan2='';}
    
    
    $sql_pant=$sql_pant0;
    $sql_pant=str_replace($codigo0,$codigo,$sql_pant);
    if(mb_stristr('IMPR2',$pant))
    {$sql_pant=str_replace('%"','"',$sql_pant);}
    
    $clin=0;
    $crow=0;
    $xdeci=2
      
?>  

  <?php if(mb_stristr('IMPR2',$pant)){ ?>
  <?php 
    $repodes='ESTADO DE CUENTA';
    if($modu=='CONT'){$repodes='LIBRO MAYOR'; $xsaldos=sal_ctas($codigo,$fecha1,$fecha2); }
    if($modu=='CXCO'){$repodes='ESTADO DE CTA.X COBRAR'; 
//                       $xsaldos=sal_enti($codigo,$fecha1,$fecha2,'C');
                     }
    if($modu=='CXPA'){$repodes='ESTADO DE CTA.X PAGAR'; 
//                       $xsaldos=sal_enti($codigo,$fecha1,$fecha2,'P');
                     }
    if($modu=='INVE')
    {
     $repodes='KARDEX'; 
     $dcos=r_fiel('item',$codigo,'dcos');
     $xsaldos=sal_item($codigo,$fecha1,$fecha2,$bode);
//      $xconsprom=cons_prom($codigo,$fecha2,'D');
     $xconsprom=cons_prom($codigo,$fecha2);
     $xcostprom=cost_prom($codigo,$fecha2); 
    }
  ?>
  
  <table id="titulos" class="pant1" border="0"
         align="center" cellpadding="3" width="100%"
         style="font-size:<?php {echo $xfontsize;} ?>px;
          border-collapse:collapse;background-color:snow; position:;"
          >
  <tr style="background-color:<?php echo $gris1; ?>; border-top:solid 2px; border-bottom:solid 2px; font-weight:bold">
    <td width="20%"  style="font-size:<?php {echo $xfontsize*1.3;} ?>px;">
      <?php echo $repodes;  ?>
    </td>
    <td width="60%" align="center" style="font-size:<?php {echo $xfontsize*1.3;} ?>px;">
      <?php echo r_fiel('enti',$cfg_ruc).'<br> RUC : '.$cfg_ruc; ?>
    </td>
    <td width="20%" align="right" style="font-size:<?php {echo $xfontsize*.7;} ?>px;">
      <?php echo 'USUARIO : '.$user_codigo.' - '.r_fiel('user',$user_codigo); ?>
      <br>
      <?php echo 'FECHA : '.date('D d/M/y'); ?> 
      <br>
      <?php echo 'HORA : '.date('H:i:s'); ?> 
    </td>
  </tr>
  </table>  
  

  <table id="filtros" class="pant1" border="0"
         align="center" cellpadding="3" width="100%"
         style="font-size:<?php {echo $xfontsize*.75;} ?>px;
          border-collapse:collapse;background-color:snow; position:;"
          >
  <tr>
    <td width="50%" valign="top">
      <table id="" class="" border="1"
         align="center" cellpadding="3" width="100%"
         style="font-size:<?php {echo $xfontsize;} ?>px;
          border-collapse:collapse;background-color:snow; position:;">
        <tr style="background-color:<?php echo $gris1; ?>;">
          <td align="center" colspan="2" style="font-weight:bold;">FILTROS</td>
        </tr>  
        <tr>
          <td width="20%" style="font-weight:bold;">FECHAS</td>
            <td><?php echo date('d/M/y',strtotime($fecha1)).' - '.date('d/M/y',strtotime($fecha2)); ?></td>
        </tr>  
        <?php if(mb_stristr('CONT',$modu)){?>
            <?php if(1==1){ ?>
            <tr valign="top">
              <td style="font-weight:bold;">GRUPO</td>
              <td><?php echo $ctan1.' - '.$descri1; ?></td>
            </tr>  
            <?php } ?>
            <?php if($codigo>=$ctan2 and !empty($ctan2)){ ?>
            <tr valign="top">
              <td style="font-weight:bold;">SUB-GRUPO</td>
              <td style="<?php if($codigo==$ctan2){echo 'font-weight:bold;';} ?>"><?php echo $ctan2.' - '.$descri2; ?></td>
            </tr>  
            <?php } ?>
            <?php if($codigo>=$ctan3 and !empty($ctan3)){ ?>
            <tr valign="top">
              <td style="font-weight:bold;">CUENTA</td>
              <td style="<?php if($codigo==$ctan3){echo 'font-weight:bold;';} ?>"><?php echo $ctan3.' - '.$descri3; ?></td>
            </tr>  
            <?php } ?>
            <?php if($codigo>=$ctan4 and !empty($ctan4)){ ?>
            <tr valign="top">
              <td style="font-weight:bold;">SUB-CUENTA</td>
              <td style="<?php if($codigo==$ctan4){echo 'font-weight:bold;';} ?>"><?php echo $ctan4.' - '.$descri4; ?></td>
            </tr>  
            <?php } ?>
            <?php if($codigo>$ctan5 and !empty($ctan5)){ ?>
            <tr valign="top">
              <td style="font-weight:bold;">CTA.MOVIMIENTO</td>
              <td style="<?php if($codigo==$ctan5){echo 'font-weight:bold;';} ?>"><?php echo $ctan5.' - '.$descri5; ?></td>
            </tr>  
            <?php } ?>
        <?php } ?>
        <?php if(mb_stristr('INVE',$modu)){?>
            <tr valign="top">
              <td style="font-weight:bold;">CODIGO</td>
              <td style="font-weight:bold;"><?php echo $codigo.' <br> '.r_fiel('item',$codigo); ?></td>
            </tr>  
            <tr valign="top">
              <td style="font-weight:bold;">BODEGA</td>
              <td><?php if($bode==''){echo 'TODAS';}else{echo $bode.' - '.r_fiel('bode',$bode);} ?></td>
            </tr>  
            <tr valign="top">
              <?php $umdd=r_fiel('item',$codigo,'umdd'); ?>
              <?php $umdddes=r_fiel('umdd',$umdd); ?>
              <td style="font-weight:bold;">MEDIDA</td>
              <td><?php echo $umdd.' - '.$umdddes; ?></td>
            </tr>  
        <?php } ?>

        <?php if(mb_stristr('CXCO.CXPA',$modu)){?>
            <tr valign="top">
              <td style="font-weight:bold;"><?php if($modu=='CXCO'){echo 'CLIENTE';}else{echo 'PROVEEDOR';}?></td>
              <td style="font-weight:bold;"><?php echo $codigo.' - '.r_fiel('enti',$codigo); ?></td>
            </tr>  
            <tr valign="top">
              <td style="font-weight:bold;">MATRIZ</td>
              <td><?php echo r_fiel('enti',$codigo,'matriz'); ?></td>
            </tr>  
            <tr valign="top">
              <td style="font-weight:bold;">E-MAIL</td>
              <td><?php echo r_fiel('enti',$codigo,'email'); ?></td>
            </tr>  
            <tr valign="top">
              <td style="font-weight:bold;">TELEFONO</td>
              <td><?php echo r_fiel('enti',$codigo,'telefono'); ?></td>
            </tr>  
        <?php } ?>

      </table>
    </td>
    <td width="50%" valign="top">
      <table id="" class="" border="1"
         align="center" cellpadding="3" width="100%"
         style="font-size:<?php {echo $xfontsize;} ?>px;
          border-collapse:collapse;background-color:snow; position:;">
        <tr align="center" style="background-color:<?php echo $gris1; ?>;">
          <td colspan="3" style="font-weight:bold;">RESUMEN</td>
        </tr>  
        <tr align="right" style="display:none;">
          <td style="font-weight:bold;"><?php if($pant=='IMPR1'){echo 'DOCUMENTOS';}else{echo 'REGISTROS';}?></td>
          <td width="20%" style="font-weight:bold;" align="center"><?php echo $tdocu; ?></td>
        </tr> 
        <?php if(mb_stristr('CONT.CXCO.CXPA',$modu)){$xdeci=2;} ?>
        <?php if(mb_stristr('CONT.INVE.CXCO.CXPA',$modu)){ ?>
            <?php  { ?>
                <tr align="right">
                  <td style="font-weight:bold;">INICIAL</td>
                  <td><?php echo number_format($xsaldos[1],$xdeci); ?></td>
                  <?php if($modu=='INVE' and $ver_cost==1){ ?>
                  <td><?php echo '$ '.number_format($xsaldos[5],2); ?></td>
                  <?php }?>
                </tr>

                <tr align="right">
                  <td align="right" style="font-weight:bold;">
                    <?php if($modu=='CONT'){echo 'DEBITOS :';}?>
                    <?php if($modu=='INVE'){echo 'INGRESOS :';}?>
                    <?php if($modu=='CXCO'){echo 'DEBITOS :';}?>
                    <?php if($modu=='CXPA'){echo 'DEBITOS :';}?>
                  </td>
                  <td><?php echo number_format($xsaldos[2],$xdeci); ?></td>
                  <?php if($modu=='INVE' and $ver_cost==1){ ?>
                  <td><?php echo '$ '.number_format($xsaldos[6],2); ?></td>
                  <?php }?>
                </tr>

                <tr align="right">
                  <td align="right" style="font-weight:bold;">
                    <?php if($modu=='INVE'){echo 'EGRESOS :';}?>
                    <?php if($modu=='CONT'){echo 'CREDITOS :';}?>
                    <?php if($modu=='CXCO'){echo 'CREDITOS :';}?>
                    <?php if($modu=='CXPA'){echo 'CREDITOS :';}?>
                  </td>
                  <td><?php echo number_format($xsaldos[3],$xdeci); ?></td>
                  <?php if($modu=='INVE' and $ver_cost==1){ ?>
                  <td><?php echo '$ '.number_format($xsaldos[7],2); ?></td>
                  <?php }?>
                </tr>


                <tr align="right">
                  <td style="font-weight:bold;">SALDO</td>
                  <td><?php echo number_format($xsaldos[4],$xdeci); ?></td>
                  <?php if($modu=='INVE' and $ver_cost==1){ ?>
                  <td><?php echo '$ '.number_format($xsaldos[8],2); ?></td>
                  <?php }?>
                </tr>
        
        
                <?php if($modu=='INVE'){?>
                <tr align="right">
                  <td style="font-weight:bold;">CONSUM.
                    <?php if($ver_cost==1){echo ' /COSTO '; }?>
                    PROM.
                  </td>
                  <td><?php echo number_format($xconsprom[1],$xdeci); ?></td>
                  <?php if($modu=='INVE' and $ver_cost==1){ ?>
                  <td><?php echo '$ '.number_format($xcostprom,$dcos); ?></td>
                  <?php }?>
                </tr>
                <?php } ?>
        

                <?php $total=abs($tdebito)-abs($tcredito);?>
                <?php $tsubt=0;?>
                <?php $ctas_tot=0;?>
                <?php $ctas_123=0;?>
                <?php $ctas_456=0;?>
            <?php } ?>
            <?php if(mb_stristr('ssff.rrii.sfcc.ricc',$repo)){ ?>
                <?php while($aso_tpant1=@mysql_fetch_assoc($res_tpant1)){ ?>
                  <?php $ctas_codi=$aso_tpant1['ctas_codi']; ?>
                  <?php $ctas_desc=$aso_tpant1['descri1']; ?>
                  <?php $ctas_sald=$aso_tpant1['saldo']; ?>
                  <?php if(mb_stristr('rrii.ricc',$repo)){$ctas_sald=$ctas_sald*(-1);} ?>
                  <tr align="right">
                    <td style="font-weight:bold;"><?php echo $ctas_desc?></td>
                    <td><?php echo number_format($ctas_sald,2); ?></td>
                  </tr>
                  <?php $ctas_tot=$ctas_tot+$ctas_sald;?>
                  <?php if(mb_stristr('1.2.3',substr($ctas_codi,0,1))){$ctas_123=$ctas_123+$ctas_sald;}?>
                  <?php if(mb_stristr('4.5,6',substr($ctas_codi,0,1))){$ctas_456=$ctas_456+$ctas_sald;}?>
                <?php } ?>
                <?php if($ctas_123!=0){?>
                  <tr align="right">
                    <td style="font-weight:bold;"><?php echo 'ACT-(PAS+PAT)';?></td>
                    <td><?php echo number_format($ctas_123,2); ?></td>
                  </tr>
                <?php } ?>
                <?php if($ctas_456!=0){?>
                  <tr align="right">
                    <td style="font-weight:bold;"><?php if($ctas_456>0){echo 'UTILIDAD';}else{echo 'PERDIDA';}?></td>
                    <td><?php echo number_format($ctas_456,2); ?></td>
                  </tr>
                <?php } ?>
            <?php } ?>
        <?php } ?>
      </table>
    </td>
  </tr>  

  </table>

  <hr>
  
  <?php } ?>  
  
  
<?php
  if(mb_stristr('CXCO.CXPA',$modu))
  {

//     $sql_pant.=' order by fecha,cabdet,mdfrom,docu,idnum1 ';
//     $sql_pant=str_replace('order by ',' group by docu,ptoe,numero order by ',$sql_pant);    

    $sql_pant=str_replace($tabla.'12.* ',$tabla.'12.*, '.'sum(tdebito) as tdebito, sum(tcredito) as tcredito ',$sql_pant);    
//     $sql_pant=str_replace('order by ',' group by docu,ptoe,numero order by ',$sql_pant);    
    $sql_pant=str_replace('order by ',' group by fecha,docu,ptoe,numero order by ',$sql_pant);    
  }
?>
  
<?php $xhora2 = date('H:i:s'); ?>
  
<?php //$res_pant=mysql_query($sql_pant,$link_vcrx);	?>
<?php mysql_data_seek($res_pant,0); ?>  
<?php $numrows=@mysql_num_rows($res_pant); ?>
<?php $ccol=0; ?>
<?php //echo '<br>'.$xhora1; ?>  
<?php //echo '<br>'.$xhora2; ?>  
<?php //explain_sql($sql_pant);?>
	<table id="tpant2" class="pant2"  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:snow;"
						 >
		<?php { // THEAD ?>
		<thead style="<?php echo $tdisplay; ?>">
			<tr style="border-top:solid 1px;border-bottom:solid 2px;background-color:<?php echo $gris1; ?>;">
          <th onclick="sortTable(this,0);" style="display:none;"><?php  $ccol++; ?></th>
        
        <?php if(substr($pant,0,4)=='PANT'){?>
				<th onclick="sortTable(this,0<?php echo $ccol++; ?>);" title="Imprimir">I</th>
				<th onclick="sortTable(this,<?php echo $ccol++; ?>);">Codigo</th>
				<th onclick="sortTable(this,<?php echo $ccol++; ?>);">Descripción</th>
        <?php } ?>
				<th onclick="sortTable(this,<?php echo $ccol++; ?>);">Fecha</th>
				<th onclick="sortTable(this,<?php echo $ccol++; ?>);">Docu</th>
				<th onclick="sortTable(this,<?php echo $ccol++; ?>);">Pto.Emi.</th>
				<th onclick="sortTable(this,<?php echo $ccol++; ?>);">Numero</th>
				<th onclick="sortTable(this,<?php echo $ccol++; ?>,'N');">
          <?php if(mb_stristr('CONT.CXCO.CXPA',$modu)){echo 'Debito';}?>
          <?php if($modu=='INVE'){echo 'Ingreso';}?>
        </th>
				<th onclick="sortTable(this,<?php echo $ccol++; ?>,'N');">
          <?php if(mb_stristr('CONT.CXCO.CXPA',$modu)){echo 'Credito';}?>
          <?php if($modu=='INVE'){echo 'Egreso';}?>
        </th>
				<th onclick="sortTable(this,<?php echo $ccol++; ?>);">Saldo</th>
        <?php if($modu=='INVE' and $ver_cost==1){?>
				<th onclick="sortTable(this,<?php echo $ccol++; ?>,'N');">V.Unit</th>
				<th onclick="sortTable(this,<?php echo $ccol++; ?>,'N');">Debito</th>
				<th onclick="sortTable(this,<?php echo $ccol++; ?>,'N');">Credito</th>
				<th onclick="sortTable(this,<?php echo $ccol++; ?>);">Saldo</th>
        <?php } ?>
				<th onclick="sortTable(this,<?php echo $ccol++; ?>);">
          <?php if($modu=='CONT'){echo 'Centro';} ?>
          <?php if($modu=='INVE'){echo 'Bodega';} ?>
          <?php if($modu=='CXCO'){echo 'Zona';} ?>
          <?php if($modu=='CXPA'){echo 'T.Prov.';} ?>
        </th>
				<th onclick="sortTable(this,<?php echo $ccol++; ?>);">Detalle</th>
				<th onclick="sortTable(this,<?php echo $ccol++; ?>);">Status</th>
        <th style="font-size:<?php echo $xfontsize*.5;?>px;" title="Descargar XLS">
          <a href="#" id="downxls1" onClick="javascript:fnExcelReport('tpant2',this,'<?php echo $cfg_empr.'_'.$modu.'_'.$codigo.'_'.date('Ymd_His');?>');">XLS</a>
        </th>
			</tr>
		</thead>
		<?php } ?>
    
		<?php { // TBODY ?>
		<tbody id="bodytpant2" style="overflow-y:auto;border-bottom:solid 1px;<?php echo $tdisplay; ?> 
					<?php if($orient=='V'){echo'min-height:'.($hpant2-75).'px;';}else{echo'min-height:'.($hpant2*.7).'px;';}  ?> 
					<?php if($orient=='V'){echo'height:'.($hpant2-75).'px;';}else{echo'height:'.($hpant2*.7).'px;';}  ?>">

      <?php if(@mysql_num_rows($res_pant)==0){?>
          <tr><td style="font-weight:bold;">
            <?php echo 'NO HAY MOVIMIENTOS'; ?>  
            <?php echo '<br>==>'.date('H:i:s'); ?>
            <?php //echo '<br>'.$docu.' /'.$enti; ?>
          </td></tr>
        <?php }?>
      
      <?php $saldia=$xsaldos[1]; ?>
      <?php $saldiau=$xsaldos[1]; ?>
      <?php $totdebitos=0; ?>
      <?php $totcreditos=0; ?>
      <?php $totingresos=0; ?>
      <?php $totegresos=0; ?>
			<?php while($aso_pant=@mysql_fetch_assoc($res_pant)){ ?>
			<?php $crow++; ?>
			<?php $duni=$aso_pant['item_duni']; ?>
			<?php $dpre=$aso_pant['item_dpre']; ?>
			<?php $dval=$aso_pant['item_dval']; ?>
			<?php $dcos=$aso_pant['item_dcos']; ?>
      <?php $totdebitos=$totdebitos+$aso_pant['tdebito']; ?> 
      <?php $totcreditos=$totcreditos+$aso_pant['tcredito']; ?> 
      <?php $saldia=$saldia+$aso_pant['tdebito']-$aso_pant['tcredito']; ?> 
      <?php $totingresos=$totingresos+$aso_pant['tingreso']; ?> 
      <?php $totegresos=$totegresos+$aso_pant['tegreso']; ?> 
      <?php $saldiau=$saldiau+$aso_pant['tingreso']-$aso_pant['tegreso']; ?> 
			<?php if($dval==0){$dval=2;} ?>
			<?php if($dpre==0){$dpre=2;} ?>
			<?php if($duni==0){$duni=0;} ?>
			<?php if(ceil($aso_pant['cant'])!=floor($aso_pant['cant']) and $duni==0){$duni=2;} ?>
      <?php $id_trfila = 'tr_filad'.fillzero($crow,4); ?>
			<tr id="tr_filad<?php echo $crow;?>" class="tr_filad" valign="top" 
						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;}?>"
						onmouseover="_filabg(event,'tr_filad','<?php echo $crow; ?>','');"
						onclick="_filabg(event,'tr_filad','<?php echo $crow; ?>','');"
						>
         <td style="display:none;"><?php echo fillzero($crow,5); ?></td>
          
          <?php if(substr($pant,0,4)=='PANT'){?>
          <td align="center">
					  
            <?php
              $formato=1;
              if($modu=='CONT'){$formato=3;}
              $pidtxt='impri'.$crow;
              $pcaption="Imprimir"; $pabrev="I";
              $xidfrom=$aso_pant['idfrom'];
              if($xidfrom==''){$xidfrom=$aso_pant['idnum1'];}
              $ponclick='{window.open("?prnt=1&docu='.$aso_pant['docu'].'&idnum='.$xidfrom.'&formato='.$formato.'","_blank")}';
              include('vrbutton.php');
            ?>
          </td>
          <?php if($modu=='CONT'){?>
              <?php $xdeci=2; ?>
              <td><?php echo $aso_pant['ctas']; ?></td>
              <td><?php echo $aso_pant['ctas_descri']; ?></td>
          <?php } ?>
        
          <?php if($modu=='INVE'){?>
              <td><?php echo $aso_pant['item']; ?></td>
              <td><?php echo $aso_pant['item_descri']; ?></td>
          <?php } ?>
        
          <?php if(mb_stristr('CXCO.CXPA',$modu)){?>
              <?php $xdeci=2; ?>
              <td><?php echo $aso_pant['enti']; ?></td>
              <td><?php echo $aso_pant['enti_descri']; ?></td>
          <?php } ?>
        
          <?php } ?>
        
          <td align="center">
            <div class="hidden"><?php echo $aso_pant['fecha']; ?></div>
            <div class="hidden"><?php echo $xidnum.$aso_pant['iddet']; ?></div>
            <div class="noxls"><?php echo $aso_pant['fechadmy']; ?></div>
          </td>
        
          <td align="center" title="<?php echo $aso_pant['docu_descri']; ?>" >
            <div><?php echo $aso_pant['docu']; ?></div>
          </td>
        
          <td align="center">
            <div><?php echo $aso_pant['ptoe']; ?></div>
          </td>
        
          <td align="center">
            <div><?php echo $aso_pant['numero']; ?></div>
          </td>
        
          <?php if(mb_stristr('CONT.CXCO.CXPA',$modu)){?>
              <td align="right">
                <div><?php echo number_format($aso_pant['tdebito'],$xdeci); ?></div>
              </td>

              <td align="right">
                <div><?php echo number_format($aso_pant['tcredito'],$xdeci); ?></div>
              </td>

              <td align="right">
                <div class="hidden"><?php echo fillzero($crow); ?></div>
                <div><?php echo number_format($saldia,$xdeci); ?></div>
              </td>
          <?php } ?>

          <?php if($modu=='INVE'){?>
              <td align="right">
                <div><?php echo number_format($aso_pant['tingreso'],$duni); ?></div>
              </td>

              <td align="right">
                <div><?php echo number_format($aso_pant['tegreso'],$duni); ?></div>
              </td>

              <td align="right" style="font-weight:bold;">
                <div class="hidden"><?php echo fillzero($crow); ?></div>
                <div><?php echo number_format($saldiau,$duni); ?></div>
              </td>
              <?php if($ver_cost==1){?>
                  <?php $dcos=2; ?>
                  <?php $xpuni=$aso_pant['puni']; ?>
                  <?php if($xpuni<=1){$dcos=4;}; ?>
                  <td align="right" style="font-style:italic;font-size:90%;">
                    <div><?php echo number_format($xpuni,$dcos); ?></div>
                  </td>

                  <td align="right">
                    <div><?php echo number_format($aso_pant['tdebito'],$xdeci); ?></div>
                  </td>

                  <td align="right">
                    <div><?php echo number_format($aso_pant['tcredito'],$xdeci); ?></div>
                  </td>

                  <td align="right" style="font-weight:bold;">
                    <div class="hidden"><?php echo fillzero($crow); ?></div>
                    <div><?php echo number_format($saldia,$xdeci); ?></div>
                  </td>
              <?php } ?>
          <?php } ?>

        
          <td align="center">
            <?php if($modu=='CONT'){echo $aso_pant['csub'];} ?>
            <?php if($modu=='INVE'){echo $aso_pant['bode'];} ?>
            <?php if($modu=='CXCO'){echo $aso_pant['zsub'];} ?>
            <?php if($modu=='CXPA'){echo $aso_pant['tpro'];} ?>
          </td>
        
        
          <td style="font-size:75%;" width="40%">
            <?php $detalles=''; ?>
            <?php $detalles.=$aso_pant['concepto']; ?>
            <?php $detalles.=' /'.$aso_pant['detalle']; ?>
            <?php if(!mb_stristr('CXCO.CXPA',$modu)){$detalles.=' /'.$aso_pant['enti_descri'];} ?>
            <?php if(!mb_stristr('INVE',$modu)){$detalles.=' /'.$aso_pant['item_descri'];} ?>
            <?php echo $detalles; ?>
          </td>
        
          <td align="center">
            <div><?php echo $aso_pant['status']; ?></div>
          </td>
        
				</tr>
			<?php } ?>
			</tbody>	
		<?php } ?>
		<?php { // TFOOT ?>
			<tfoot id="detafoot" style="<?php echo $tdisplay; ?>">
				<tr style="border-bottom:solid 1px;background-color:<?php echo $gris1; ?>;">
          <th style="display:none;"<?php $ccol--; ?>></th>
          
          <?php if(substr($pant,0,4)=='PANT'){?>
          <th><?php$ccol--;?></th>
          <th><?php$ccol--;?></th>
          <th><?php$ccol--;?></th>
          <?php } ?>
          <th><?php$ccol--;?> </th>
          <th><?php$ccol--;?> </th>
          <th><?php$ccol--;?><?php echo $crow;?> </th>
          <th><?php$ccol--;?>TOTALES </th>
          <?php if(mb_stristr('CONT.CXCO.CXPA',$modu)){ ?>
              <th align="right"><?php$ccol--;?><?php echo number_format($totdebitos,2);?></th>
              <th align="right"><?php$ccol--;?><?php echo number_format($totcreditos,2);?></th>
          <?php } ?>
          <?php if($modu=='INVE'){ ?>
              <th align="right"><?php$ccol--;?><?php echo number_format($totingresos,2);?></th>
              <th align="right"><?php$ccol--;?><?php echo number_format($totegresos,2);?></th>
              <th></th>
              <?php if($ver_cost==1){ ?>
                  <th></th>
                  <th align="right"><?php$ccol--;?><?php echo number_format($totdebitos,2);?></th>
                  <th align="right"><?php$ccol--;?><?php echo number_format($totcreditos,2);?></th>
                  <th></th>
              <?php } ?>
          <?php } ?>
          <?php$ccol--;?>
          <?php if($ccol<0){$ccol=0;}?>
          <?php echo str_repeat('<th></th>',$ccol); ?>
        </tr>
			</tfoot>
		<?php } ?>
	</table>

  <?php if($rowcodis<$numcodis){ ?>
  <p class="saltodepagina" /></p>
  <?php } ?>
  
<?php }while($aso_codis=mysql_fetch_assoc($res_codis)); 
?>
  
<?php if(mb_stristr('IMPR',$pant)){ ?>
</div>	
</body>	
</html>  
<?php } ?>  
  
</pant2>
		
<?php } ?>	
</resultado>

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

<?php //$obstart=substr($obstart,strpos($obstart,'<resultado>')) ;?>
<?php //echo '*/*/*/*/*/'.strpos($obstart,'<resultado>');?>

<?php //$obstart = trim($obstart) ?>
<?php// echo $obstart;	?>
<?php //if(mb_stristr($obstart,'CUENTAS EN CERO'))?>
<?php //if(abs($tsaldoi)>$xsaldo0 or abs($tdebito)>$xsaldo0 or abs($tcredito)>$xsaldo0 or abs($tsaldo)>$xsaldo0) ?>
<?php {$obstart = limpiahtml($obstart);} ?>

<?php $obstart = str_replace('border="0"','',$obstart); ?>
<?php // $obstart = str_replace('> ','>',$obstart); ?>
<?php // $obstart = str_replace(' <','<',$obstart); ?>
<?php $obstart = str_replace('align="left"','',$obstart); ?>
<?php // $obstart = str_replace('&','',$obstart); ?>

<?php $obstart = str_replace('<div></div>','',$obstart); ?>
<?php $obstart = str_replace('title=""','',$obstart); ?>
<?php $obstart = str_replace('position:;','',$obstart); ?>
<?php $obstart = str_replace('" "','""',$obstart); ?>
<?php $obstart = str_replace(';;',';',$obstart); ?>
<?php // $obstart = str_replace('" ','"',$obstart); ?>
<?php // $obstart = str_replace(' "','"',$obstart); ?>
<?php $obstart = str_replace('onclick=""','',$obstart); ?>
<?php if(mb_stristr('IMPR1.IMPR2',$pant)){ ?>
  <?php // $obstart = str_replace('display:block','',$obstart); ?>
  <?php $obstart = str_replace('tfoot','tfoot1',$obstart); ?>
  <?php $obstart=remove_href($obstart); ?>
<?php } ?>

<?php echo $obstart;	?>

		