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

<?php $orient=$_POST['orient']; ?>
<?php $pant=$_POST['pant']; ?>
<?php $ctlg=$_POST['ctlg']; ?>
<?php $docu=$_POST['docu']; ?>
<?php $idnum=$_POST['idnum']; ?>
<?php foreach($_POST as $campo => $valor){${$campo}=$valor;} ?>

<?php
// if($lsub==''){$lsub='ELECTRO';}
if($ctlg==''){$ctlg='item';}
if($docu==''){$docu='CAR1';}

$idcarr=get_carr();


$verpvp=0;
if($user_tipo!='invi' and $user_tipo!=''){$verpvp=1;}

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

if($oswin==0 and $screenr>=75){$xfontsize=20;}

$verpvp=1;

// $updt_puni='update item0 set item_puni=item_puni3';
// $res_puni=mysql_query($updt_puni,$link_vcrx);

// $sel_bus='';
// if($buscar!=''){$lsub='';$item='';}
// $busca=strtoupper(alltrim($buscar));
// $busca=explode(' ',$busca);
// for ($cbusca=0; $cbusca<count($busca); $cbusca++)
// {
// 	$sel_bus.='and (';
// 	$sel_bus.='item_codigo like "'.$busca[$cbusca].'%"';
// 	$sel_bus.='or item_codigov like "%'.$busca[$cbusca].'%"';
// 	$sel_bus.='or item_descri like "%'.$busca[$cbusca].'%"';
// 	$sel_bus.=')';
// }


$sql_ctlg ='select * from item0 ';
$sql_ctlg.=' where 1=1 ';
$sql_ctlg.='and item_hoja=1 ';
$sql_ctlg.='and item_status!="O" ';
$sql_ctlg.='and item_status!="X" ';
$sql_ctlg.='order by item_descri ';


// if(empty($buscar) and empty($item) and empty($lsub))
// {
//   $sql_ctlg.=' order by item_idate desc, item_descri, item_codigo ';
//   $sql_ctlg.=' limit 100 ';
// }
// else
// {  
//   if($lsub!=""){$sql_ctlg.=' and item_lsub like "'.$lsub.'%"';}
//   if($item!=""){$sql_ctlg.=' and item_codigo like "'.$item.'%"';}
//   if($buscar!=""){$sql_ctlg.=$sel_bus;}

//   $sql_ctlg.=' order by item_descri,item_codigo ';
// }

// $sql_ctlg.=' limit 10 ';

$res_ctlg=mysql_query($sql_ctlg,$link_vcrx);
$numrows=mysql_num_rows($res_ctlg);

// explain_sql($sql_ctlg);
?>

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

<div id="taginicial" style="float:inherit;"></div>		
<div width="100%" style="overflow:auto;">
<?php if($mobile=='true'){?>	
<br>
<?php } ?>
	
<?php $classtab='filtro'; ?>
<?php $classcol=$classtab.'_coligua'; ?>
<div style="height:20px;"></div>  
<table id="filtro" cellpadding="2" width="100%" border="0" class="<?php echo $classtab?>"
			 onclick="resizeTab('<?php echo $classtab?>','<?php echo $classcol; ?>');"  onmouseover="this.onclick();"
			style="font-size:<?php echo $xfontsize; ?>px;border-collapse:collapse;  ">
	<tr>
    <td>
      <table>
        <tr>
        <?php $pidtxt='enti'; $ptabla='enti'; $psize=$xfontsize; $pcaption='CEDULA'; $pobj=3; $pvalue=$enti; $pexact=1; include('vrgetcod.php'); ?>
        </tr>
        <tr>
        <?php //$pidtxt='enti'; $ptabla='enti'; $psize=$xfontsize; $pcaption='CLIENTE';  $pobj=3; $pvalue=$enti; include('vrgetcod.php'); ?>
        </tr>
        <tr>
        <?php $pidtxt='email'; $psize=$xfontsize; $pcaption='E-MAIL'; $plong=30;  $pobj=3; $pvalue=$email; include('vrgettxt.php'); ?>
        </tr>
        <tr>
        <?php $pidtxt='wsapp'; $pcaption='WhatsApp'; $plong=10; $psize=$xfontsize; $pobj=$xobj; include('vrgetnum.php'); ?>
        </tr>
        <tr>
        <?php $pidtxt='tlfn'; $pcaption='Telef.'; $plong=10; $psize=$xfontsize; $pobj=$xobj; include('vrgetnum.php'); ?>
        </tr>
        
    <?php if($mobile=='false'){?>
      </table>
    </td>

    <td>
      <table>
    <?php } ?>    
          <tr>
          <?php $pidtxt='calle1';  $psize=$xfontsize; $pcaption='CALLE 1'; $plong=30; $ptabla='enti'; $pcolu='calle1'; $pphold='Calle /Cdla'; include('vrgettxt.php'); ?>
          </tr>
          <tr>
          <?php $pidtxt='calle2';  $psize=$xfontsize; $pcaption='CALLE 2'; $plong=30; $ptabla='enti'; $pcolu='calle2'; $pphold='Calle2 /Mz.'; include('vrgettxt.php'); ?>
          </tr>
          <tr>
          <?php $pidtxt='callen';  $psize=$xfontsize; $pcaption='Num./Villa'; $plong=10;  include('vrgettxt.php'); ?>
          </tr>
          <tr>
          <?php $pidtxt='calle3';  $psize=$xfontsize; $pcaption='Referencia'; $plong=30;  $pphold='Referencia'; include('vrgettxt.php'); ?>
          </tr>
    
          <tr>
          <?php //$pidtxt='lsub';  $ptabla='lsub'; $ptodos=1; $psize=$xfontsize; $pcaption='LINEAS'; $pvalue=$lsub; include('vrgetcod.php'); ?>
          </tr>
          <tr>
          <?php //$pidtxt='item';  $ptabla='item'; $pnotob="1"; $psize=$xfontsize; $pcaption='ITEM'; $pvalue=$item; include('vrgetcod.php'); ?>
          </tr>
      </table>
    </td>
  </tr>

  <tr>
    
  </tr>
    <?php //$pidtxt='buscar'; $psize=$xfontsize; $pcaption='BUSCAR'; $plong='100%'; $pobj=1; $pvalue=$buscar; include('vrgettxt.php'); ?>
  <tr>
    <td width="10%" colspan="2">
      <?php 
//       $pidtxt='consul';  $pcaption='CONSULTAR'; $psize=$xfontsize; 
//       $ponclick ='';
//       $ponclick.='{location.href="?scri=ctlg_orel';
//       $ponclick.='&lsub="+document.getElementById("lsub").value+"';
//       $ponclick.='&buscar="+document.getElementById("buscar").value+"';
//       $ponclick.='&item="+document.getElementById("item").value+"';
//       $ponclick.='&"}';
//       include('vrbutton.php'); 
      ?>
    </td>
  </tr>
   
</table>	
<?php if($mobile=='true'){?>	
<br>
<?php } ?>
</div>
	<?php //echo '**'.$user_tipo;?>
<hr>
<?php $crow=0; ?>
<?php $ccol=0; ?>
<?php //echo explain_sql($sql_ctlg);?>
	
<?php if($numrows==0){?>
	<?php // echo 'NO SE ENCONTRARON RESULTADOS'; ?>
<?php }else{ ?>
  <div style="font-size:<?php echo $xfontsize*(1.2); ?>;">
  <?php //echo $numrows.' Resultados'; ?>
  </div>
<?php } ?>
		<hr size="5" noshade>

<?php $xfontsize=$xfontsize*2; ?>  
<table id="tpant1" cellpadding="10" border="1" align="center" 
         style="font-size:<?php echo $xfontsize; ?>px;border-collapse:collapse;  ">
<thead id="tpant1h">
  <tr style="border-top:solid 1px;border-bottom:solid 1px;" >
    <th>Producto</th>
    <th>Precio</th>
    <th>Cant.</th>
</thead>  
<?php while($aso_ctlg=mysql_fetch_assoc($res_ctlg)){ ?>
  <tr valign="top">
    <td>
      <?php echo $aso_ctlg['item_descri'];?>
    </td>
    <td align="center">
      <?php echo number_format($aso_ctlg['item_puni'],2);?>
    </td>
    <?php
      $psize=$xfontsize;
      $pidtxt='cant_'.$aso_ctlg['item_codigo'];
      $pobj=1;
      $pphold='00';
      $plong=3;
      include('vrgetnum.php');
    ?>
  </tr>  
<?php } ?>  
</table>
  
<div id="tagfinal" style="float:inherit;"></div>		
	
<!-- 	
<table id="tpant1" class="pant1" border="0"
			 onclick="resizeTab('<?php echo "tpant1"?>','');"
			 align="center" border="0" cellpadding="3" width="100%"
			 style="font-size:<?php if($mobile=='true'){echo $xfontsize-8;}else{echo $xfontsize;} ?>px;
							 border-collapse:collapse; "
				 >

	<?php { // THEAD ?>
	<thead style="display:block; <?php if($mobile!='true'){echo 'max-width:'.($screenw-20).'px;';} ?>;background-color:#eee;">
		<tr style="border-bottom:solid 1px; cursor:pointer;" title="Reordenar">
			<th onclick="sortTable(this,<?php echo $ccol++; ?>);" title="Imprimir">I</th>
			<th onclick="sortTable(this,0<?php $ccol++; ?>);" title="Detalle" style="<?php if($dispcolu==0){echo'display:none;';}?>">D</th>
			<th onclick="sortTable(this,<?php echo $ccol++; ?>);"><?php if($mobile=='true'){echo 'NUM.';}else{echo 'NUMERO';} ?></th>
			<th onclick="sortTable(this,<?php echo $ccol++; ?>);">LINEA</th>
			<th onclick="sortTable(this,<?php echo $ccol++; ?>);">CODIGO</th>
			<th onclick="sortTable(this,<?php echo $ccol++; ?>);">DESCRIPCION</th>
			<th onclick="sortTable(this,<?php echo $ccol++; ?>);" style="letter-spacing:1px;<?php if($dispcolu==0){echo'display:none;';}?>">CED/RUC</th>
			<th onclick="sortTable(this,<?php echo $ccol++; ?>);" style="letter-spacing:10px; "><?php echo $entilabel; ?></th>
			<th onclick="sortTable(this,<?php echo $ccol++; ?>);" style="<?php if($tsubt==0){echo'display:none;';}?> <?php echo 'font-size:'.($xfontsize*0.8).';' ?> ">SUB-TOT</th>			
			<th onclick="sortTable(this,<?php echo $ccol++; ?>);" >TOTAL</th>
			<th onclick="sortTable(this,<?php echo $ccol++; ?>);" 
					style="letter-spacing:10px;<?php if($dispcolu==0){echo'display:none;';}?>">CONCEPTO</th>
			<th onclick="sortTable(this,<?php echo $ccol++; ?>);">ST</th>
			<th>OX</th>
		</tr>
	</thead>
	<?php } ?>
	<?php { // TBODY ?>
	<tbody id="tpant1b" style="overflow-y:auto; display:block; 
					<?php if($orient=='V'){echo'min-height:'.($hpant1-7).'px;';}		else{echo'min-height:'.($hpant1-75).'px;';}  ?> 
					<?php if($orient=='V'){echo'height:'.($hpant1-7)*(2.4).'px;';}	else{echo'height:'.($hpant1-75)*(2.4).'px;';}  ?> 
					">
		<?php while($aso_ctlg=mysql_fetch_assoc($res_ctlg)){ ?>
		<?php $crow++; ?> 
		<?php //$struc=$aso_ctlg['enti_struc']; ?>
		<tr id="tr_fila<?php echo $crow;?>" class="tr_fila" valign="top" height="<?php //if($mobile=='true'){echo '55px';};?>"
				style="<?php if ($crow%5==0){echo 'border-bottom:dotted 1px;'; } ?> "
				onclick="_filabg(event,'tr_fila','<?php echo $crow; ?>','');
								<?php if($touchs=='true'){?>
								info_docu('PANT2','<?php echo $aso_ctlg['item_codigo']; ?>','<?php echo $aso_ctlg['idnum1']; ?>');
								<?php } ?>
								 "
				ondblclick="{document.getElementById('detadocu').checked='true';document.getElementById('detadocu').onchange();this.onclick();}"
				>
			<td align="center"><span style="display:none;"><?php echo fillzero($crow,5); ?></span>
			<?php
				echo $aso_ctlg['item_codigo'];
				echo '<br>';
				echo $aso_ctlg['item_descri'];
				echo '<br>';
				echo $aso_ctlg['item_puni3'];
			?>
			</td>
		</tr>
		<?php } ?>
	</tbody>
<?php } ?>	
	<?php { // FOOT ?>
	<tfoot style="display:block; <?php if($mobile!='true'){echo 'max-width:'.($screenw-20).'px;';} ?>;background-color:#eee;">
		<tr style="border-top:solid 1px;">
			<th></th>
			<th></th>
			<th></th>
		</tr>
	</tfoot>
	<?php } ?>	
</table>
	
	 -->
<?php $pant='X';?>
	
<?php if(mb_stristr('PANT0',$pant) and 1==2) { ?>
<?php $fecha1=date('Y-m-01',strtotime ('today')); ?>
<?php $fecha2=$fechaa; ?>
		<div id="pant0" style="border:solid 2px; overflow:auto;">
		<?php if($mobile=='true' and $orient=="V") { ?>
			<table id="tpant0" cellpadding="2" width="100%" border="0"
						 style="font-size:<?php echo $xfontsize; ?>px;border-collapse:collapse; ">
				<tr><?php $pidtxt='fecha1'; $pcaption='Desde'; $pdefa=$fecha1; $psize=$xfontsize; include('vrgetfec.php'); ?></tr>
				<tr><?php $pidtxt='fecha2'; $pcaption='Hasta'; $psize=$xfontsize; include('vrgetfec.php'); ?></tr>
				<tr><?php $pidtxt='enti';  $ptabla='enti'; $pnotob="1"; $psize=$xfontsize; $pcaption=$entilabel; include('vrgetcod.php'); ?></tr>
				<tr><?php $pidtxt='stat'; $pcaption='Status'; $ptabla='stat'; $pnotob="1"; $psize=$xfontsize; include('vrgetcod.php'); ?></tr>
			</table>	
			<br>
			<table id="tpant00" cellpadding="2" width="100%" border="0"
						 style="font-size:<?php echo $xfontsize; ?>px;border-collapse:collapse; ">
				<tr>
					<td align="center" width="50%">
					<?php $pidtxt='consul'; $pcaption='Consultar '.$docu; $ponclick='info_docu("PANT1","'.$docu.'")'; $psize=$xfontsize; include('vrbutton.php'); ?>
					</td>
					<td align="center">
					<?php $pidtxt='nueva'; $pcaption='Nueva'; $ponclick='info_docu("PANT1")'; $psize=$xfontsize; include('vrbutton.php'); ?>
					</td>
					<td align="center">
					<?php $pidtxt='detadocu'; $pcaption='Detalle'; $ponclick='info_docu("DETA")'; $psize=$xfontsize; $pdefa=0; include('vrchkbox.php'); ?>
					</td>
				</tr>
			</table>			
			<br>
		<?php }else{ ?>
			<table id="tpant0" cellpadding="2" width="100%" border="0"
					 style="font-size:<?php echo $xfontsize; ?>px;border-collapse:collapse; ">
				<tr>
					<td>
						<table width="100%" cellpadding="2" width="100%" border="0"
									style="font-size:<?php echo $xfontsize; ?>px;border-collapse:collapse; ">
							<tr>
								<td>
									<table width="100%" cellpadding="2" width="100%" border="0"
												 style="font-size:<?php echo $xfontsize; ?>px;border-collapse:collapse;">
										<tr>
											<td><?php $pidtxt='fecha1'; $pcaption='Desde'; $pdefa=$fecha1; $psize=$xfontsize; include('vrgetfec.php'); ?></td>
										</tr>
										<tr>
											<td><?php $pidtxt='fecha2'; $pcaption='Hasta'; $psize=$xfontsize; include('vrgetfec.php'); ?></td>
										</tr>
									</table>
								</td>
								<td>
									<table width="100%" cellpadding="2" width="100%" border="0"
												style="font-size:<?php echo $xfontsize; ?>px;border-collapse:collapse; ">
										<tr>
											<td><?php $pidtxt='enti'; $ptabla='enti'; $pnotob="1"; $psize=$xfontsize; $pcaption=$entilabel; include('vrgetcod.php'); ?></td>
										</tr>
										<tr>
											<td><?php $pidtxt='stat'; $pcaption='Status'; $ptabla='stat'; $pnotob="1"; $psize=$xfontsize; include('vrgetcod.php'); ?></td>
										</tr>
									</table>
								</td>
								<td><?php $pidtxt='consul'; $pcaption='Consultar '.$docu; $ponclick='info_docu("PANT1","'.$docu.'")'; $psize=$xfontsize; include('vrbutton.php'); ?></td>
								<td><?php $pidtxt='nueva'; $pcaption='Nueva'; $ponclick='info_docu("PANT1");'; $psize=$xfontsize; include('vrbutton.php'); ?></td>
								<td><?php $pidtxt='detadocu'; $pcaption='Detalle'; $ponclick='info_docu("DETA");'; $psize=$xfontsize; $pdefa=0; include('vrchkbox.php'); ?></td>
							</tr>
						</table>
					</td>	
				</tr>	
			</table>
		<?php } ?>
		</div>	
		<div id="pant1" style="border:solid 1px; overflow:auto; font-family:arial;"></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;"></div>
		<div id="pant9"></div>
<?php } ?>			
	
<?php if(mb_stristr('PANT1',$pant) and 1==2) { ?>
	<?php { 
		$sql_pant='select * from '.$tabla.'12 ';
		$sql_pant.=' where (fecha between "'.$fecha1.'" and "'.$fecha2.'")';
		$sql_pant.=' and docu like "'.$docu.'%"';
		if($enti!=""){$sql_pant.=' and (enti like "'.$enti.'%" or enti_descri like "%'.$enti.'%")';}
		if($stat!=""){$sql_pant.=' and (status="'.$stat.'")';}

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

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

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

		$res_ctlg=mysql_query($sql_pant,$link_vcrx);
		$tpant_res=mysql_query($tpant_sql,$link_vcrx);

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

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

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

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

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

			$trrta=0;
			$triva=0;
		}

	}	?>

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

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

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

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

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

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

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

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

	if(mb_stristr('retc.retp',$tabla))
	{
		$trrta=mysql_result($tpant_res,0,'srrta');
		$triva=mysql_result($tpant_res,0,'sriva');
	}
}
// explain_sql($sql_pant);
}	?>

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

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

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

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

		