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

<?php $orient=$_POST['orient']; ?>

<?php

$sql_updt='alter table item0 add column item_grupo varchar(13)';
$res_updt=mysql_query($sql_updt,$link_vcrx);

$sql_updt='alter table item0 add column item_ctlg varchar(1)';
$res_updt=mysql_query($sql_updt,$link_vcrx);

$sql_updt='update item0 set item_grupo=left(item_codigo,10) where length(trim(item_codigo))=10 or length(trim(item_codigo))=13';
$res_updt=mysql_query($sql_updt,$link_vcrx);

$sql_updt='update item0 set item_grupo=left(item_codigo,6) where length(trim(item_codigo))=6 or length(trim(item_codigo))=8';
$res_updt=mysql_query($sql_updt,$link_vcrx);


$total_sql ='max(item_mrca) as tmrca,';
$total_sql ='max(item_nctlg) as tnctlg,';
$total_sql ='max(item_pctlg) as tpctlg,';
$total_sql.='max(item_modelo) as tmodelo,';
$total_sql.='max(item_ice) as tice,';
$total_sql.='max(item_iva) as tiva,';
$total_sql.='max(item_irbp) as tirbp';


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

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

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

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

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

?>

<?php ob_start(); ?>
<resultado>
	
<?php if(mb_stristr('PANT0',$pant)) { ?>
<?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; background-color:white;">
				<tr><?php $pidtxt='lsub';  $ptabla='lsub'; $pnotob="1"; $psize=$xfontsize; $pcaption='LINEA'; include('vrgetcod.php'); ?></tr>
				<tr><?php $pidtxt='item';  $ptabla='item'; $pnotob="1"; $psize=$xfontsize; $pcaption='ITEM'; 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; background-color:white;">
				<tr>
					<td align="center" width="50%">
					<?php $pidtxt='consul'; $pcaption='Consultar '.$docu; $ponclick='mant_item("PANT1","'.$docu.'")'; $psize=$xfontsize; include('vrbutton.php'); ?>
					</td>
					<td align="center">
					<?php $pidtxt='nueva'; $pcaption='Nuevo'; $ponclick='mant_item("PANT1")'; $psize=$xfontsize; include('vrbutton.php'); ?>
					</td>
					<td align="center">
					<?php $pidtxt='detadocu'; $pcaption='Detalle'; $ponclick='mant_item("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; background-color:white;">
				<tr>
					<td>
						<table width="100%" cellpadding="2" width="100%" border="0"
									style="font-size:<?php echo $xfontsize; ?>px;border-collapse:collapse; background-color:white;">
							<tr>
								<td>
									<table width="100%" cellpadding="2" width="100%" border="0"
												style="font-size:<?php echo $xfontsize; ?>px;border-collapse:collapse; background-color:white;">
										<tr>
											<td><?php $pidtxt='lsub'; $ptabla='lsub'; $pnotob="1"; $psize=$xfontsize; $pcaption='LINEA'; include('vrgetcod.php'); ?></td>
										</tr>
										<tr>
											<td><?php $pidtxt='item'; $ptabla='item'; $pnotob="1"; $psize=$xfontsize; $pcaption='ITEM'; 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='mant_item("PANT1","'.$docu.'")'; $psize=$xfontsize; include('vrbutton.php'); ?></td>
								<td><?php $pidtxt='nuevo'; $pcaption='Nuevo'; $ponclick='mant_item("PANT1");'; $psize=$xfontsize; include('vrbutton.php'); ?></td>
								<td><?php $pidtxt='detadocu'; $pcaption='Detalle'; $ponclick='mant_item("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)) { ?>
	<?php { 
		$sql_pant='select * from item00 ';
		$sql_pant.=' where item_codigo*1>100000 and item_status!="X" ';
		if($lsub!=""){$sql_pant.=' and (lsub_codigo like "'.$lsub.'%" or lsub_descri like "%'.$lsub.'%")';}
		if($item!=""){$sql_pant.=' and (item_codigo like "'.$item.'%" or item_descri like "%'.$item.'%")';}
		if($stat!=""){$sql_pant.=' and (item_status="'.$stat.'")';}

		$sql_tpant=str_replace('select *','select *,'.$total_sql,$sql_pant);
// 		$sql_pant=str_replace('select *','select *,'.$total_sql,$sql_pant);
// 		$sql_tpant=$sql_pant;
	
		{$sql_pant.=' group by item_grupo';}

		$sql_pant.=' order by lsub_descri, item_descri, item_codigo';

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

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

	
// 		if($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>
						<?php //explain_sql($sql_pant); die();?>

		<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;background-color:white;"
						 >
			<?php { // THEAD ?>
			<thead style="display:block; <?php if($mobile!='true'){echo 'max-width:'.($screenw-20).'px;';} ?>;background-color:#eee;">
				<tr style="border-bottom:solid 1px; cursor:pointer;" title="Reordenar">
					<th onclick="sortTable(this,<?php echo $ccol++; ?>);" title="Imprimir">I</th>
					<th onclick="sortTable(this,0<?php $ccol++; ?>);" title="Detalle" style="<?php if($dispcolu==0){echo'display:none;';}?>">D</th>
					<th onclick="sortTable(this,<?php echo $ccol++; ?>);">LINEA</th>
					<th onclick="sortTable(this,<?php echo $ccol++; ?>);">CODIGO</th>
					<th onclick="sortTable(this,<?php echo $ccol++; ?>);">DESCRIPCION</th>
					<?php if($tmarca!=""){?>
					<th onclick="sortTable(this,<?php echo $ccol++; ?>);">MARCA</th>
					<?php } ?>
					<?php if($tmodelo!=""){?>
					<th onclick="sortTable(this,<?php echo $ccol++; ?>);">MODELO</th>
					<?php } ?>
					<th onclick="sortTable(this,<?php echo $ccol++; ?>);">PVP</th>
					<th onclick="sortTable(this,<?php echo $ccol++; ?>);">TV</th>
					<th onclick="sortTable(this,<?php echo $ccol++; ?>);"></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_pant=mysql_fetch_assoc($res_pant)){ ?>
				<?php $crow++; ?> 
				<?php $pvp1=$aso_pant['enti_puni']; ?>
				<?php //$item_codigo=str_replace(trim($aso_pant['item_tlla']),'',$aso_pant['item_codigo']); ?>
				<?php $item_codigo=$aso_pant['item_grupo'];?>
				<?php $item_descri=str_replace(trim($aso_pant['tlla_descri']),'',$aso_pant['item_descri']); ?>
				<?php $item_modelo=substr($aso_pant['item_modelo'],0,6);?>
				<?php //$struc=$aso_pant['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; ?>','');
										mant_item('PANT2','<?php echo $aso_pant['docu']; ?>','<?php echo $aso_pant['idnum1']; ?>');
										<?php if($touchs=='true'){?>
										<?php } ?>
										 "
						ondblclick="{document.getElementById('detadocu').checked='true';document.getElementById('detadocu').onchange();this.onclick();}"
						>
					<td align="center"><span style="display:none;"><?php echo fillzero($crow,5); ?></span>
					<?php ?>
					</td>
					<td align="center" style="<?php if($dispcolu==0){echo'display:none;';}?>" title="<?php echo 'ID:'.$aso_pant['idnum1'];?>"
							onclick="
										<?php if($touchs=='false'){?>
										mant_item('PANT2','<?php echo $aso_pant['docu']; ?>','<?php echo $aso_pant['idnum1']; ?>');
										<?php } ?>
										 ">
						<?php if($mobile!='true'){$pidtxt='radio'.'tr_fila'.$crow; $pname='rtr_fila'; $pcaption=''; $psize=$xfontsize; include('vrradio.php');} ?>
					</td>
					<td align="center">
						<div style="display:none;"><?php echo $aso_pant['lsub_descri']; ?></div>
						<?php echo $aso_pant['lsub_descri']; ?>
					</td>
					<td align="left"><?php echo $aso_pant['item_codigo']; ?></td>
					<td align="left"><?php echo $item_descri; ?></td>
					<?php if($tmarca!=""){?>
					<td align="center"><?php echo $aso_pant['mrca_descri']; ?></td>
					<?php } ?>
					<td align="left"><?php echo $aso_pant['item_modelo']; ?></td>
					<td align="center">
						<?php  $pobj=1; $ptabla='item'; $pfila=$aso_pant['item_codigo']; $pcolu='ctlg'; include('vrchkbox.php'); ?>
					</td>
					<td align="right" style="">
						<div style="display:none;"><?php echo fillzero($aso_pant['item_pvp0'],15); ?></div>
						<?php echo number_format(abs($aso_pant['item_pvp0']),2); ?>
					</td>	
					<td valign="top">
						<?php
							$sql_imgi='select * from imgi0 ';
							$sql_imgi.='where imgi_item like "'.$item_modelo.'%" ';
							$sql_imgi.=' and imgi_file is not null';
							$sql_imgi.=' and imgi_status!="O"';
							$sql_imgi.=' and imgi_status!="X"';
							$sql_imgi.='order by imgi_defa desc, imgi_file limit 1';
							$res_imgi=mysql_query($sql_imgi,$link_vcrx);
						?>
						<?php if(mysql_num_rows($res_imgi)>0){?>
								<?php while($aso_imgi=mysql_fetch_assoc($res_imgi))	{ ?>
								<?php $imgfile=$aso_imgi['imgi_file'];?>
								<?php if(file_exists('../imgi/'.$imgfile)){?>
									<img id="img_<?php echo $imgfile;?>"
											 src="../imgi/<?php echo $imgfile;?>" 
											 width="50px" 
											 onclick="_clickimg('img_<?php echo $imgfile;?>');" 
											 onmouseover="{document.getElementById('img_<?php echo $item_modelo;?>	big').src=this.src;}" 
											 title="<?php echo $imgfile;?>"
											 >
								<?php } ?>
								<?php } ?>
						<?php } ?>

										
									</td>
									<td align="center"><?php echo $aso_pant['item_status']; ?></td>
									<td align="center" >
									<?php
										if($aso_pant['item_status']!='O' and $aso_pant['item_status']!='X'){$tnumero++;}
										if($aso_pant['item_status']=='O')
										{$pcaption='Eliminar: '.$aso_pant['docu'].'-'.$aso_pant['codigo']; $pabrev='X';}
										if(!mb_stristr('ROX',$aso_pant['item_status']))
										{$pcaption='Anular: '.$aso_pant['docu'].'-'.$aso_pant['codigo']; $pabrev='O';}
										if(!mb_stristr('RX',$aso_pant['item_status']))
										{
											$pidtxt='anul'.'tr_fila'.$crow; $pname='itr_fila';
											$pidnum=$aso_pant['idnum1'];$pdocu=$aso_pant['docu'];
											$psize=$xfontsize;
											$ponclick='mant_item("PANTX","'.$aso_pant['idnum1'].'")';
											include('vrbutton.php');
										}
									?>
									</td>
								</tr>
								<?php } ?>
			</tbody>
		<?php } ?>	
			<?php { // FOOT ?>
			<tfoot style="display:block; <?php if($mobile!='true'){echo 'max-width:'.($screenw-20).'px;';} ?>;background-color:#eee;">
				<tr style="border-top:solid 1px;">
					<?php echo str_repeat('<th></th>',$ccol);?>
				</tr>
			</tfoot>
			<?php } ?>	
		</table>
	<pant1>
	<?php //echo '***'.date('H:i:s') .'<br>';?>
				
<?php } ?>			
			
<?php if(mb_stristr('PANT2',$pant)) { ?>

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

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

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

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

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

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

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

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

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

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

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

		