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

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

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


<?php
// function get_xml_from_url($url){
//     $ch = curl_init();

//     curl_setopt($ch, CURLOPT_URL, $url);
//     curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
//     curl_setopt($ch, CURLOPT_USERAGENT, 'Mozilla/5.0 (Windows; U; Windows NT 5.1; en-US; rv:1.8.1.13) Gecko/20080311 Firefox/2.0.0.13');

//     $xmlstr = curl_exec($ch);
//     curl_close($ch);

//     return $xmlstr;
// }

?>


<?php	
	
$user_anul=0;
$user_elim=0;

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

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

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

// if(mb_stristr('vtas.clie.carr.retc.guia.',$tabla)){$entilabel='CLIENTE';}
// if(mb_stristr('comp.prov.retp.',$tabla)){$entilabel='PROVEEDOR';}
// if(mb_stristr('nomi.roln.suel',$tabla)){$entilabel='EMPLEADO';}
// if(mb_stristr('RC.',substr($docu,0,2))){$entilabel='CLIENTE';}
// if(mb_stristr('RP.',substr($docu,0,2))){$entilabel='PROVEEDOR';}

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

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

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

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

// 	if(mb_stristr('vtas.comp.clie.prov.inve.prod.guia.carr',$tabla)){$docuitem=1;}
// 	if(mb_stristr('vtas.comp.clie.prov.carr',$tabla)){$docuiimp=1;}
// // 				if(mb_stristr('inve.prod.guia',$tabla)){$docuinve=1;}
// 	if(mb_stristr('caja.bcos.retc.retp.rete',$tabla)){$docudocu=1;}
// 	if(mb_stristr('retc.retp.rete',$tabla)){$docurete=1;}
// 	if(mb_stristr('cont',$tabla)){$docuctas=1;}

	$total_sql ='max(detalle) as mdetalle,';
	$total_sql.='sum(tcant) as stcant,';
	$total_sql.='sum(tsubt) as stsubt,';
	if($docuiimp==1)
	{
		$total_sql.='sum(tsubtiva0) as stsubtiva0,';
		$total_sql.='sum(tsubtiva) as stsubtiva,';
		$total_sql.='sum(tsubtice) as stsubtice,';
		$total_sql.='sum(tdcto) as stdcto,';
		$total_sql.='sum(tprop) as stprop,';
		$total_sql.='sum(tice) as stice,';
		$total_sql.='sum(tiva) as stiva,';
		$total_sql.='sum(tirbp) as stirbp,';

		$total_sql.='max(dcto) as pdcto,';
		$total_sql.='max(prop) as pprop,';
		$total_sql.='max(ice) as pice,';
		$total_sql.='max(iva) as piva,';
		$total_sql.='max(irbp) as pirbp,';
	}
	if(mb_stristr('comp',$tabla))
	{
		$total_sql.='sum(rrta) as srrta,';
		$total_sql.='sum(riva) as sriva,';
	}
	if(mb_stristr('retc.retp.rete',$tabla))
	{
		$total_sql.='sum(brta) as sbrta,';
		$total_sql.='max(prta) as sprta,';
		$total_sql.='sum(rrta) as srrta,';
		$total_sql.='sum(biva) as sbiva,';
		$total_sql.='max(piva) as spiva,';
		$total_sql.='sum(riva) as sriva,';
	}
	$total_sql.='sum(total) as stotal ';

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

// echo 'fdfdf';
?>


<?php
// $aa=file_get_contents('https://declaraciones.sri.gob.ec/facturacion-internet/consultas/publico/ruc-datos2.jspa?ruc=0992353554001');
// return $aa;	
?>	


<?php ob_start(); ?>
<resultado>
<?php
// PRUEBAS	
$date=date('H:i:s',strtotime('now')) ;
//   echo '*/*/*/*/';
//   echo get_ippais();
//   echo get_ruc2('0990000530001');
  
$url1='https://declaraciones.sri.gob.ec/facturacion-internet/consultas/publico/ruc-datos2.jspa?ruc=0990001642001';
$url2='https://declaraciones.sri.gob.ec/facturacion-internet/consultas/publico/ruc-establec.jspa?ruc=0990001642001';

$url='http://www.jomyson.com:8000/get.php?username=vicore1&password=248989&type=m3u_plus&output=ts';
// $url='http://www.jomyson.com/get.php?username=vicore1&password=248989&type=m3u_plus&output=ts';
  
  
//     $ch = curl_init();
//     curl_setopt($ch, CURLOPT_URL, $url);
//     curl_setopt ($ch, CURLOPT_RETURNTRANSFER, 1);
//     curl_setopt($ch, CURLOPT_SSLVERSION,3);
// //     curl_setopt($ch, CURLOPT_PORT, 800); 
//     $content = curl_exec ($ch);
// $b = curl_multi_getcontent($ch);
// var_dump($content === $b);
// curl_close($ch);
  
//     echo $b;

// $downloadPath = "_iptv_jomyson.m3u";
// $file = fopen($downloadPath, "w+");
// fputs($file, $content);
// fclose($file);
  
  
  
//   $url = 'http://www.test.com/1458398816_33370444.jpg';


// $curlCh = curl_init();
// curl_setopt($curlCh, CURLOPT_URL, $url);
// curl_setopt($curlCh, CURLOPT_RETURNTRANSFER, 1);
// curl_setopt($curlCh, CURLOPT_SSLVERSION,3);
// $curlData = curl_exec ($curlCh);
// curl_close ($curlCh);

  
  
  
  
  
// $page = file_get_contents($url);
//   echo $page;
// $page2 = file_get_contents($url2);
  
//   echo $page1;
//   echo '<br>';
//   echo '<br>';
//   echo '*/*/*/*';
//   echo $page2;
  
// $epg='http://jomyson.com:8000/xmltv.php?username=vicore1&password=248989&type=m3u_plus';
// header('Location:'.$epg);
// echo '*/*/*/'.$date.'-'.ini_get('allow_url_fopen');
// $aa=file_get_contents($epg);

// echo send_wapp('593996030903','Probando funcion');  
  
  
  
// $aa = get_xml_from_url($epg);
// $aa = new SimpleXMLElement($xmlstr);
	
  
	
// echo $aa;	
// die();
  
// echo date('H:i:s',strtotime('now'));
// $ws_merlyna='http://merlyna.com/merlyna/abc/webserviceSRI-RegistroCivil.php?wsdl';   
// $params=array('arg0'=>'0915379374001','arg1'=>'?','arg2'=>'?','arg3'=>'?','arg4'=>'?','arg5'=>'?','arg6'=>'?');
// $result0 = new SoapClient($ws_merlyna);
// // $result1=$result0->nombreRUCSRI($params);
// $result1=$result0->__soapCall('nombreRUCSRI',$params);
// var_dump($result1);
  
// $ws_merlyna='http://datosec.com/app/datosfiscales/consultaDeDatos.php?wsdl';
// $params=array('arg0'=>'0915379374');
// $result0 = new SoapClient($ws_merlyna);
// $result1=$result0->nombreRUCSRI($params);
// $result1=$result0->__soapCall('consultaDeDatos',$params);
// var_dump($result1);
  
  
$entilabel='CLIENTE';  
?>	
	
 <?php //selectpdf_usage();?>	
<?php //uplctasuper(); ?>
<?php //echo ws_recep('0301201801099120986700120010020000000604441845311');?>	
<?php if(mb_stristr('PANT0',$pant)) { ?>
<?php //echo get_ced1('0915379374');?>	
<?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='enti';  $ptabla='enti'; $pnotob="0"; $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; background-color:white;">
				<tr>
					<td align="center" width="50%">
					<?php $pidtxt='consul'; $pcaption='Consultar '.$docu; $ponclick='edit_carr("PANT1","'.$docu.'")'; $psize=$xfontsize; include('vrbutton.php'); ?>
					</td>
					<td align="center">
					<?php $pidtxt='nueva'; $pcaption='Nueva'; $ponclick='edit_carr("PANT1")'; $psize=$xfontsize; include('vrbutton.php'); ?>
					</td>
					<td align="center">
					<?php $pidtxt='detadocu'; $pcaption='Detalle'; $ponclick='edit_carr("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 style="display:none;">
									<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='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; background-color:white;">
										<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='edit_carr("PANT1","'.$docu.'")'; $psize=$xfontsize; include('vrbutton.php'); ?></td>
								<td><?php $pidtxt='nueva'; $pcaption='Nueva'; $ponclick='edit_carr("PANT1");'; $psize=$xfontsize; include('vrbutton.php'); ?></td>
								<td><?php $pidtxt='detadocu'; $pcaption='Detalle'; $ponclick='edit_carr("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 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;"></div>
		<div id="pant9"></div>
<?php } ?>			

<?php if(mb_stristr('PANT1',$pant)) { ?>
<?php mysql_query('update '.$tabla.'1 set status="-" where status="" or status is null',$link_vcrx); ?>
	<?php {
    $xdocu='CAR1';
		$sql_pant='select * from '.$tabla.'1 ';
		$sql_pant.=' where enti like "'.$enti.'%"';
		$sql_pant.=' and docu="'.$xdocu.'"';
		$sql_pant.=' order by enti desc';
		$res_pant=mysql_query($sql_pant,$link_vcrx);
    if(mysql_num_rows($res_pant)==0)
    {
      $sql_inse='insert into carr1(docu,enti)value("'.$xdocu.'","'.$enti.'")';
      $res_inse=mysql_query($sql_inse,$link_vcrx);
  		$res_pant=mysql_query($sql_pant,$link_vcrx);
    }
    $xidnum=mysql_query($res_pant,0,'idnum1');
  
// 		if($user_tipo=="clie"){$sql_pant.=' and (trim(iuser)="'.$user_codigo.'")';}
// 		if($user_tipo==""){$sql_pant.=' and (1==2)';}
// 		if($enti!=""){$sql_pant.=' and (enti like "'.$enti.'%" or enti_descri like "%'.$enti.'%")';}
// 		if($stat!=""){$sql_pant.=' and (status="'.$stat.'")';}
// 		if($user_tipo=='invi'){$sql_pant.=' and (enti_emailce like "%'.$user_email.'%")';}

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

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

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

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

// 		$tcant=mysql_result($res_tpant,0,'stcant');
// 		$tsubt=mysql_result($res_tpant,0,'stsubt');
// 		if($docuiimp==1)
// 		{
// 			$tsubtiva0=mysql_result($res_tpant,0,'stsubtiva0');
// 			$tsubtiva=mysql_result($res_tpant,0,'stsubtiva');
// 			$tdcto=mysql_result($res_tpant,0,'stdcto');
// 			$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');
// 		}


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

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

// 			$trrta=0;
// 			$triva=0;
// 		}

	
	}	?>

	
	<?php $crow=0; ?>
	<?php $ccol=0; ?>
	<?php $tnumero=0; ?>
	<?php //echo '***'.date('H:i:s') .'<br>';?>
	<pant1>
	<?php	val_usercodigo(); ?>
	<?php 	//echo send_sms1('593996030568','CIA:'.$cfg_empr.' /USER:'.$user_descri);?>

		<table id="tpant1" class="pant1" border="0"
					 align="center" border="0" cellpadding="3" width="100%"
					 style="font-size:<?php if($orient=='V'){echo $xfontsize-8;}else{echo $xfontsize;} ?>px;
						border-collapse:collapse;background-color:white;"
						>
			<?php { // THEAD ?>
			<thead style="display:block; <?php if($mobile!='true'){echo 'max-width:'.($screenw-20).'px;';} ?>;background-color:#eee;">
				<tr style="border-bottom:solid 1px; cursor:pointer;" title="Reordenar">
					<th onclick="sortTable(this,<?php echo $ccol++; ?>);" title="Imprimir">I</th>
					<th onclick="sortTable(this,0<?php $ccol++; ?>);" title="Detalle" style="<?php if($dispcolu==0){echo'display:none;';}?>">D</th>
					<th onclick="sortTable(this,<?php echo $ccol++; ?>);" style="<?php if($dispcolu==0){echo'display:none;';}?>">DOCU</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($tprop==0){echo'display:none;';}?> <?php echo 'font-size:'.($xfontsize*0.8).';' ?>">PROP</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.rete',$tabla)){?>
						<th onclick="sortTable(this,<?php echo $ccol++; ?>);" style="<?php if($dispcolu==0){echo'display:none;';} ?>">Base RTA</th>
						<th onclick="sortTable(this,<?php echo $ccol++; ?>);" style="<?php if($dispcolu==0){echo'display:none;';} ?>">%Ret.</th>
						<th onclick="sortTable(this,<?php echo $ccol++; ?>);" style="<?php if($dispcolu==0){echo'display:none;';} ?>">Ret.RTA</th>
						<th onclick="sortTable(this,<?php echo $ccol++; ?>);" style="<?php if($dispcolu==0){echo'display:none;';} ?>">Base IVA</th>
						<th onclick="sortTable(this,<?php echo $ccol++; ?>);" style="<?php if($dispcolu==0){echo'display:none;';} ?>">%Ret.</th>
						<th onclick="sortTable(this,<?php echo $ccol++; ?>);" style="<?php if($dispcolu==0){echo'display:none;';} ?>" >Ret.IVA</th>
					<?php } ?>
					<th onclick="sortTable(this,<?php echo $ccol++; ?>);" >TOTAL</th>
					<th onclick="sortTable(this,<?php echo $ccol++; ?>);" 
							style="letter-spacing:10px;max-width:400px;<?php if($dispcolu==0){echo'display:none;';}?>">CONCEPTO</th>
					<th onclick="sortTable(this,<?php echo $ccol++; ?>);">ST</th>
					<th onclick="sortTable(this,<?php echo $ccol++; ?>);"
							title="
							<?php if($user_anul==1){echo 'Anular';}?>
							<?php if($user_elim==1){echo '/Eliminar';}?>
										 ">
						<?php if($user_anul==1){echo 'O';}?>
						<?php if($user_elim==1){echo 'X';}?>
					</th>
					<th></th>
				</tr>
			</thead>
			<?php } ?>
			<?php { // TBODY ?>
			<tbody id="tpant1b" style="overflow-y:auto; display:block; 
							<?php if($orient=='V'){echo'min-height:'.($hpant1-7).'px;';}		else{echo'min-height:'.($hpant1-75).'px;';}  ?> 
							<?php if($orient=='V'){echo'height:'.($hpant1-7)*(2.4).'px;';}	else{echo'height:'.($hpant1-75)*(2.4).'px;';}  ?> 
							">
				<?php //echo explain_sql($sql_pant);	?>
				<?php while($aso_pant=mysql_fetch_assoc($res_pant)){ ?>
				<?php $crow++; ?> 
				<?php $tipoid=$aso_pant['enti_tipoid']; ?>
				<?php $tiporuc=$aso_pant['enti_tiporuc']; ?>
				<?php $struc=$aso_pant['enti_struc']; ?>
				<tr id="tr_fila<?php echo $crow;?>" class="tr_fila" 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; ?>','');
										edit_carr('PANT2','<?php echo $aso_pant['docu']; ?>','<?php echo $aso_pant['idnum1']; ?>');
										<?php if($touchs=='true'){?>
										<?php } ?>
										 "
						xondblclick="{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'){?>
										edit_carr('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" style="<?php if($dispcolu==0){echo'display:none;';}?>"
							title="<?php echo $aso_pant['docu_descri']; ?>">
						<?php echo $aso_pant['docu']; ?>
					</td>
					<td align="center" title="<?php echo $aso_pant['ptonumero']; ?>">
						<?php if($mobile=='true'){echo intval($aso_pant['numero'])	;}else{echo $aso_pant['numero'];} ?>
					</td>
					<td align="center">
						<div style="display:none;"><?php echo $aso_pant['fecha']; ?></div>
						<?php echo $aso_pant['fechadmy']; ?>
					</td>
					<td align="center" style="<?php if($dispcolu==0){echo'display:none;';}?>"
							title="<?php if($tipoid=='R'){ echo 'RUC:'.$tiporuc.'-'.$struc;}else{echo 'ID:'.$tipoid;};?>">
						<?php echo substr($aso_pant['enti'],0,10); ?>
					</td>

					<?php $enti_descri =$aso_pant['enti_descri'];?>
					<?php if(strlen($enti_descri)>70){$enti_descri=str_replace('-','<br>-',$enti_descri);} ?>
					<?php if(strlen($enti_descri)>70){$enti_descri=substr($enti_descri,0,70);} ?>
					
					<td align="left" style="<?php if($mobile!='true' and strlen(trim($enti_descri))>20){echo 'font-size:'.($xfontsize-2).'px;';}else{} ?>"
							title="<?php echo ' /RS: '.$aso_pant['enti_razsoc']; ?>">
						<?php if($mobile=='true'){echo substr($enti_descri,0,20);}else{echo $enti_descri;} ?>
					</td>
					<td align="right" style="<?php if($tsubt==0){echo'display:none;';}?>">
						<div style="display:none;"><?php echo fillzero($aso_pant['stsubt'],15); ?></div>
						<?php echo number_format(abs($aso_pant['stsubt']),2); ?>
					</td>	
					<?php if($docuiimp){ ?>
						<td align="right" style="<?php if($tsubtiva0==0){echo'display:none;';}?>">
							<div style="display:none;"><?php echo fillzero($aso_pant['stsubtiva0'],15); ?></div>
							<?php echo number_format(abs($aso_pant['stsubtiva0']),2); ?>
						</td>	
						<td align="right" style="<?php if($tsubtiva==0){echo'display:none;';}?>">
							<div style="display:none;"><?php echo fillzero($aso_pant['stsubtiva'],15); ?></div>
							<?php echo number_format(abs($aso_pant['stsubtiva']),2); ?>
						</td>	
						<td align="right" style="<?php if($tdcto==0){echo'display:none;';}?> font-style:italic;">
							<div style="display:none;"><?php echo fillzero($aso_pant['stdcto'],9); ?></div>
							<?php echo number_format(abs($aso_pant['stdcto']),2); ?>
						</td>	
						<td align="right" style="<?php if($tprop==0){echo'display:none;';}?> font-style:italic;">
							<div style="display:none;"><?php echo fillzero($aso_pant['stprop'],9); ?></div>
							<?php echo number_format(abs($aso_pant['stprop']),2); ?>
						</td>	
						<td align="right" style="<?php if($tice==0){echo'display:none;';}?> font-style:italic;">
							<div style="display:none;"><?php echo fillzero($aso_pant['stice'],9); ?></div>
							<?php echo number_format(abs($aso_pant['stice']),2); ?>
						</td>	
						<td align="right" style="<?php if($tiva==0){echo'display:none;';}?> font-style:italic;" >
							<div style="display:none;"><?php echo fillzero($aso_pant['stiva'],9); ?></div>
							<?php echo number_format(abs($aso_pant['stiva']),2); ?>
						</td>	
						<td align="right" style="<?php if($tirbp==0){echo'display:none;';}?> font-style:italic;">
							<div style="display:none;"><?php echo fillzero($aso_pant['stirbp'],9); ?></div>
							<?php echo number_format(abs($aso_pant['stirbp']),2); ?>
						</td>	
				<?php } ?>
					<?php if(mb_stristr('retc.retp.rete',$tabla)){?>
						<td align="right" style="<?php if($dispcolu==0){echo'display:none;';} ?>"> 
							<div style="display:none;"><?php echo fillzero($aso_pant['sbrta'],15); ?></div>
							<?php echo number_format(abs($aso_pant['sbrta']),2); ?>
						</td>
						<?php if(ceil($aso_pant['sprta'])==floor($aso_pant['sprta'])){$dval=0;}else{$dval=2;}?>
						<td align="center" style="<?php if($dispcolu==0){echo'display:none;';} ?>"> 
							<div style="display:none;"><?php echo fillzero($aso_pant['sprta'],7); ?></div>
							<?php echo number_format(abs($aso_pant['sprta']),$dval).'%'; ?>
						</td>
						<td align="right" style="font-style:italic;<?php if($dispcolu==0){echo'display:none;';} ?>">
							<div style="display:none;"><?php echo fillzero($aso_pant['srrta'],15); ?></div>
							<?php echo number_format(abs($aso_pant['srrta']),2); ?>
						</td>
						<td align="right" style="<?php if($dispcolu==0){echo'display:none;';} ?>"> 
							<div style="display:none;"><?php echo fillzero($aso_pant['sbiva'],15); ?></div>
							<?php echo number_format(abs($aso_pant['sbiva']),2); ?>
						</td>
						<?php if(ceil($aso_pant['spiva'])==floor($aso_pant['spiva'])){$dval=0;}else{$dval=2;}?>
						<td align="center" style="<?php if($dispcolu==0){echo'display:none;';} ?>"> 
							<div style="display:none;"><?php echo fillzero($aso_pant['spiva'],7); ?></div>
							<?php echo number_format(abs($aso_pant['spiva']),$dval).'%'; ?>
						</td>
						<td align="right" style="font-style:italic;<?php if($dispcolu==0){echo'display:none;';} ?>"> 
							<div style="display:none;"><?php echo fillzero($aso_pant['sriva'],15); ?></div>
							<?php echo number_format(abs($aso_pant['sriva']),2); ?>
						</td>
					<?php } ?>	
					<td align="right" > 
						<div style="display:none;"><?php echo fillzero($aso_pant['stotal'],15); ?></div>
						<?php echo number_format(abs($aso_pant['stotal']),2); ?>
					</td>
					<td style="<?php if($dispcolu==0){echo'display:none;';}?>max-width:400px;
										 <?php if(strlen(trim($aso_pant['concepto']))>50){echo 'font-size:'.($xfontsize-2).'px';} ?>"
							title="<?php echo trim($aso_pant['suco_descri']); ?>"
							>
						<?php echo trim($aso_pant['concepto']); ?>
					</td>
					<td align="center"><?php echo $aso_pant['status']; ?></td>
					<td align="center" >
					<?php
						if($aso_pant['status']!='O' and $aso_pant['status']!='X'){$tnumero++;}

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

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

// 						if(!mb_stristr('RX',$aso_pant['status']))
// 						{
// 							$pidtxt='anul'.'tr_fila'.$crow; $pname='itr_fila';
// 							$pidnum=$aso_pant['idnum1'];$pdocu=$aso_pant['docu'];
// 							$psize=$xfontsize;
// 							$ponclick='edit_carr("PANTX","'.$aso_pant['idnum1'].'")';
// 							include('vrbutton.php');
// 						}
					?>
						
					<?php if ($aso_pant['autorfec']=="") {?>
					<?php
// 						$pidtxt='btngenx'.$aso_pant['idnum1']; $pcaption='XML'; $psize=8;
// 						$ponclick="{php_func('gen_cexml(".$aso_pant['claveacc'].")')}";
// 						include('vrbutton.php'); ?>
					<?php } ?>						

					<?php if ($aso_pant['statce']=="FIR" or $aso_pant['statce']=="SRI" and (1==2)){?>
					<?php //$pidtxt='btnrecep'.$aso_pant['idnum1']; $pcaption='Autor'; $psize=8;
						//$ponclick="{php_func('ws_recep(".$aso_pant['claveacc'].")')}";
						//include('vrbutton.php'); ?>
					<?php } ?>						
						
					</td>
					
					<td style="font-size:80%;" align="left">
					<?php if(mb_stristr('vtas.retp.guia.clie.rolp',$tabla) ){?>
						<?php
							if(substr($aso_pant['claveacc'],23,1)=='1'){echo 'PRUEBAS';}
							if(substr($aso_pant['claveacc'],23,1)=='2'){echo 'PRODUCCION';}
							if(substr($aso_pant['claveacc'],23,1)=='' and $aso_pant['status']!='O' )
							{
								$pidtxt='btngencla'.$aso_pant['idnum1']; $pcaption='CLAVE'; $psize=8;
								$ptitle='Genera Clave : '.$aso_pant['docu'].'-'.$aso_pant['ptonumero'];
								$ponclick="{if(confirm('Generar Clave ".$aso_pant['docu'].'-'.$aso_pant['ptonumero']."?')){php_func('gen_claveacc(".$aso_pant['docu'].",".$aso_pant['idnum1'].")');}}";
								include('vrbutton.php');
							}

							if($aso_pant['firmafec']!="")
							{echo '<br>F: '.$aso_pant['firmafec'];};

							if($aso_pant['autornum']!="")
							{echo '<br>A: '.$aso_pant['autorfec'];}
							else
							{
								if($aso_pant['status']!='O')
								{
									if(mb_stristr($aso_pant['recepmsj'],'ERROR :CLAVE ACCESO REGISTRADA'))
									{echo '<br><div style="background-color:green;color:white;">'.'RECIBIDA'.'</div>';}
									else
									{echo '<br>'.$aso_pant['recepmsj'];}
								}
							};

// 							if($aso_pant['firmafec']!="" and $aso_pant['status']!='O')
							if(($aso_pant['firmafec']!="" or mb_stristr('PF.OP',substr($aso_pant['docu'],0,2))) and $aso_pant['claveacc']!="" and $aso_pant['status']!='O')
							{
								$pidtxt='btnmail'.$aso_pant['idnum1']; $pcaption='@: '.$aso_pant['emailfec']; $psize=10;
								$ptitle='Enviar Mail '.$aso_pant['docu'].'-'.$aso_pant['ptonumero'];
								$ponclick="{if(confirm('Enviar Mail ".$aso_pant['docu'].'-'.$aso_pant['ptonumero']."?')){php_func('mail_ce(".$aso_pant['claveacc'].")');}}";
								include('vrbutton.php');
							}
						?>

					<?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 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($tprop==0){echo'display:none;';}?> font-style:italic;">
							<?php echo number_format(abs($tprop),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.rete',$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>
					<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 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($tprop==0){echo'display:none;';}?> font-style:italic;">
							<?php echo number_format(abs($tprop/$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.rete',$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>
					<th></th>
				</tr>
				<?php}?>
			</tfoot>
			<?php } ?>	
		</table>
	<pant1>
	<?php //echo '***'.date('H:i:s') .'<br>';?>
				
<?php } ?>			
		
<?php if(mb_stristr('PANT2',$pant)) { ?>
<?php {
	if(mb_stristr('retc.retp.rete',$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.rete',$tabla)){$sql_tpant.=' group by fecha,numero,enti';}
	else	{$sql_tpant.=' group by idnum1';}

	$res_pant=mysql_query($sql_pant,$link_vcrx); 
// 	echo explain_sql($sql_pant);

{
	$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');
		$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');
	}
	$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.rete',$tabla))
	{
		$trrta=mysql_result($res_tpant,0,'srrta');
		$triva=mysql_result($res_tpant,0,'sriva');
	}
}

}	?>
<pant11>
	<div style="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" width="100%"
						style="font-size:<?php if($orient=='V'){echo $xfontsize-12;}else{echo $xfontsize;} ?>px;
										max-height:<?php echo $hpant11-15; ?>px;
										border-collapse:collapse; background-color:#eee;">
			<tr valign="top" >
				<td width="3%">
<?php //echo 	'***'.explain_sql($sql_tpant); ?>
					<?php
							$claveacce=@mysql_result($res_tpant,0,'claveacc');
							$pcaption='Imprimir: '.mysql_result($res_tpant,0,'docu').'-'.mysql_result($res_tpant,0,'numero'); $pabrev='I';
							$pidnum=mysql_result($res_tpant,0,'idnum1');
							$psize=$xfontsize;
							if($claveacce=='')
							{$ponclick='{window.open("print1.php?prnt=1&docu='.mysql_result($res_tpant,0,'docu').'&idnum='.mysql_result($res_tpant,0,'idnum1').'","_blank")}';}
							else
							{$ponclick='{window.open("print1.php?prnt=1&clave='.$claveacce.'","_blank")}';}
 							include('vrbutton.php');
					?>
				</td>
				<td style="font-weight:bold; font-size:80%" width="">
					<?php echo mysql_result($res_tpant,0,'docu_descri'); ?>
					<?php echo '<br>'.'NUM: '.mysql_result($res_tpant,0,'ptonumero'); ?>
					<?php echo '<br>'.'ID : '.mysql_result($res_tpant,0,'idnum1'); ?>
					<?php echo '<br>'.'CA: '.@mysql_result($res_tpant,0,'claveacc'); ?>
				</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,'srrta'),2); ?>
					</div>
					<div style="">
					<?php echo '<strong>Ret.IVA.: </strong>'.number_format(mysql_result($res_tpant,0,'sriva'),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($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($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($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($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.rete',$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';	} 
// 	echo explain_sql($sql_pant);
	$res_pant=mysql_query($sql_pant,$link_vcrx);	
?>
<?php $numrows=mysql_num_rows($res_pant); ?>
	<table id="tpant2" class="pant2" align="left" border="0" cellpadding="3" width="100%"
				 style="font-size:<?php if($orient=='V'){echo $xfontsize-8;}else{echo $xfontsize;} ?>px;
								overflow-x:hidden;
								border-collapse:collapse;background-color:white;"
						 >
		<?php { // THEAD ?>
		<thead style="display:block;">
			<tr style="border-bottom:solid 1px;background-color:#eee;">
				<th onclick="sortTable(this,<?php echo $ccol++; ?>);" title="Linea">L</th>
				<th style="<?php if($dispcolu==0){echo 'display:none;';} ?><?php echo $ccol++; ?>">D</th>	
				<?php if($docuiimp==1){ ?>
					<th onclick="sortTable(this,<?php echo $ccol++; ?>);" title="Cantidad">Cant</th>
					<th onclick="sortTable(this,<?php echo $ccol++; ?>);" title="Código" style="<?php if($dispcolu==09){echo'display:none;';}?>">Código</th>
					<th onclick="sortTable(this,<?php echo $ccol++; ?>);" title="Descripción">Descripción</th>
					<th onclick="sortTable(this,<?php echo $ccol++; ?>);" title="Prec.Unitario">P.Uni</th>
					<th onclick="sortTable(this,<?php echo $ccol++; ?>);" style="<?php if($tsubt==0){echo'display:none;';}?>">SUB-TOT</th>			
					<th onclick="sortTable(this,<?php echo $ccol++; ?>);" style="<?php if($tdcto==0){echo'display:none;';}?>">DCTO</th>	
					<th onclick="sortTable(this,<?php echo $ccol++; ?>);" style="<?php if($tprop==0){echo'display:none;';}?>">PROP</th>	
					<th onclick="sortTable(this,<?php echo $ccol++; ?>);" style="<?php if($tice==0){echo'display:none;';}?>">ICE</th>	
					<th onclick="sortTable(this,<?php echo $ccol++; ?>);" style="<?php if($tiva==0){echo'display:none;';}?>">IVA</th>	
					<th onclick="sortTable(this,<?php echo $ccol++; ?>);" style="<?php if($tirbp==0){echo'display:none;';}?>">IRBP</th>
	<!-- 				<th onclick="sortTable(this,3);" title="Precio Unitario">PVP</th> -->
				<?php } ?>
				<?php if($docudocu==1){ ?>
					<th onclick="sortTable(this,<?php echo $ccol++; ?>);" title="">Documento</th>
					<th onclick="sortTable(this,<?php echo $ccol++; ?>);" title="">Numero</th>
				<?php } ?>
				<?php if($docurete==1){ ?>
					<th onclick="sortTable(this,<?php echo $ccol++; ?>);" title="">Base Imponible</th>
					<th onclick="sortTable(this,<?php echo $ccol++; ?>);" title="">Impuesto</th>
					<th onclick="sortTable(this,<?php echo $ccol++; ?>);" title="">% Ret.</th>
				<?php } ?>
				<th onclick="sortTable(this,<?php echo $ccol++; ?>);">TOTAL</th>
				<th onclick="sortTable(this,<?php echo $ccol++; ?>);" style="letter-spacing:10px;<?php if($dispcolu==0){echo'display:none;';}?>">DETALLE</th>
				<?php if($empr_cont=='1' and $tabla=='comp') {?>
					<th onclick="sortTable(this,<?php echo $ccol++; ?>);" style="<?php if($dispcolu==0){echo'display:none;';} ?>">Cuenta</th>
					<th onclick="sortTable(this,<?php echo $ccol++; ?>);" style="<?php if($dispcolu==0){echo'display:none;';} ?>">Contable</th>
					<th onclick="sortTable(this,<?php echo $ccol++; ?>);" style="<?php if($dispcolu==0){echo'display:none;';} ?>">CAIR</th>
					<th onclick="sortTable(this,<?php echo $ccol++; ?>);" style="<?php if($dispcolu==0){echo'display:none;';} ?>">%Rta</th>
					<th onclick="sortTable(this,<?php echo $ccol++; ?>);" style="<?php if($dispcolu==0){echo'display:none;';} ?>">%IVA</th>
				<?php } ?>
			</tr>
		</thead>
		<?php } ?>
		<?php { // TBODY ?>
		<tbody style="overflow-y:auto; overflow-x:hidden; display:block; border-bottom:solid 1px;
					<?php if($orient=='V'){echo'min-height:'.($hpant2-75).'px;';}else{echo'min-height:'.($hpant2-90).'px;';}  ?> 
					<?php if($orient=='V'){echo'height:'.($hpant2-75).'px;';}else{echo'height:'.($hpant2-90).'px;';}  ?> ">
			<?php while($aso_pant=mysql_fetch_assoc($res_pant)){ ?>
			<?php $crow++; ?>
			<?php $duni=$aso_pant['item_duni']; ?>
			<?php $dpre=$aso_pant['item_dpre']; ?>
			<?php $dval=$aso_pant['item_dval']; ?>
			<?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;} ?>
			<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;}?>"
						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']),$dpre); ?>
					</td>
					<td align="right" style="<?php if($tsubt==0){echo'display:none;';} ?>">
						<div style="display:none;"><?php echo fillzero($aso_pant['tsubt'],15); ?></div>
						<?php echo number_format(abs($aso_pant['tsubt']),$dval); ?>
					</td>
					<td align="right" style="<?php if($tdcto==0){echo'display:none;';} ?>font-style:italic;" title="<?php echo number_format(abs($aso_pant['dcto']),$dval).'%'; ?>">
						<div style="display:none;"><?php echo fillzero($aso_pant['tdcto'],9); ?></div>
						<?php echo number_format(abs($aso_pant['tdcto']),$dval); ?>
					</td>
					<td align="right" style="<?php if($tprop==0){echo'display:none;';} ?>font-style:italic;" title="<?php echo number_format(abs($aso_pant['prop']),$dval).'%'; ?>">
						<div style="display:none;"><?php echo fillzero($aso_pant['tprop'],9); ?></div>
						<?php echo number_format(abs($aso_pant['tprop']),$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
						$cair='('.$aso_pant['cair'].')';
// 						if($aso_pant['puni']>=30 and $cair<300)
						if($aso_pant['biva']>0)
						{$cair_descri='IVA';}
						else
						{$cair_descri=$aso_pant['cair_descri']; $cair='<br>'.$cair;}
					?>
					<?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 if(trim($aso_pant['detalle'])!=trim($aso_pant['item_descri'])){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>
						<?php if(ceil($aso_pant['prrta'])==floor($aso_pant['prrta'])){$dpor=0;}else{$dpor=2;}?>
						<td align="center" style="<?php if($dispcolu==0){echo'display:none;';} ?>" 
								title="<?php echo number_format($aso_pant['rrta'],2).''; ?>">
							<?php echo number_format($aso_pant['prrta'],$dpor).''; ?>
						</td>
						<?php if(ceil($aso_pant['priva'])==floor($aso_pant['priva'])){$dpor=0;}else{$dpor=2;}?>
						<td align="center" style="<?php if($dispcolu==0){echo'display:none;';} ?>"
								title="<?php echo number_format($aso_pant['riva'],2).''; ?>">
							<?php echo number_format($aso_pant['priva'],$dpor).''; ?>
						</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>
		<?php //echo date('H:i:s');?>
	
</pant2>
		
<?php } ?>			
</resultado>

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

		