<?php
die();
// TIRILLA WASAPP  caracteres

function selectpdf_usage()
{
	include('../_cfg/config.php');
	include('php_session.php');
	
	$api_usage = "https://selectpdf.com/api2/usage/?key=".$selectpdfkey."&get_history=True";
	$pdf_usage=file_get_contents($api_usage);
	$obj = json_decode($pdf_usage);	
// 	echo $obj->{'limit'};
// 	echo $obj->{'used'};
// 	echo $obj->{'available'};
	return;
}


function html2pdf($urlhtml,$filepdf)
{
  return;
	include('../_cfg/config.php');
	include('php_session.php');
	
	$api_endpoint = "https://selectpdf.com/api2/convert/";
// 	$selectpdfkey='a08354d5-92b4-4a2b-a1a4-ab82c90a5c78';
	
	$filepdf=str_replace('.pdf','',$filepdf).'.pdf';
	$parameters = array ('key' => $selectpdfkey, 'url' => $urlhtml, 'page_size' => 'A4');
 	$result = @file_get_contents("$api_endpoint?" . http_build_query($parameters));
 
	if(!$result)
	{	
		echo "HTTP Response: " . $http_response_header[0] . "<br/>";
		$error = error_get_last();
		echo "Error Message: " . $error['message'];
	}
	else
	{file_put_contents($filepdf, $result);}	
}

function prnt_docu0($docu,$idnum,$formato=1,$destino='screen')
{
include('../_cfg/config.php');
include('php_session.php');

if(empty($formato)){$formato=1;}    
     
if($docu=='GR10')     
{val_guia($docu,$idnum);}
     
$docu=trim($docu);
$sql_docu='select * from docu0 where docu_codigo like "'.$docu.'%"';
$res_docu=msql_query($sql_docu,$link_vcrx);
     
if(mb_stristr('DD.DT.DI',substr($docu,0,2))){$formato=1;}
$tabla=strtolower(msql_result($res_docu,0,'docu_tabla'));	
$ppsize=msql_result($res_docu,0,'docu_ppsize');	
$pporient=msql_result($res_docu,0,'docu_pporient');	

$width=msql_result($res_docu,0,'docu_width');	
$height=msql_result($res_docu,0,'docu_height');	 
$orient=msql_result($res_docu,0,'docu_orient');	

$doble=msql_result($res_docu,0,'docu_doble');	
$copia=msql_result($res_docu,0,'docu_copia');	
     

$docu_tipo=msql_result($res_docu,0,'docu_tipo');	
  
if($ppsize==''){$ppsize='A4';}
if($pporient==''){$pporient='V';}
if($docu=='DA16'){$pporient='H';}
if($width==0){$width=210;}
if($height==0){$width=297;}
if($orient==''){$orient='V';}	
if($copia==0){$copia=1;}	

if($user_codigo=='')
{
	$ppsize='A4';
	$pporient='V';
	$width=210;
	$height=297;
	$orient='V';
	$copia=1;
}	
  

$sql_tra1='select * from '.$tabla.'1 where idnum1="'.$idnum.'"';
$res_tra1=msql_query($sql_tra1,$link_vcrx);	
$xenti=@msql_result($res_tra1,0,'enti');
$xentidesc=r_fiel('enti',$xenti);
$xptonumero=@msql_result($res_tra1,0,'ptonumero');
$xptoe=@msql_result($res_tra1,0,'ptoe');
$xnumero=@msql_result($res_tra1,0,'numero');
$xstatus=@msql_result($res_tra1,0,'status');
$xclaveacc=@msql_result($res_tra1,0,'claveacc');

if($xclaveacc!='' or substr($xptoe,3,1)=='2')
{
  $doble=0;
//   $copia=1;
}

$filelogo=$rutalogo.$logofile2;	
$xfontsize=12; 
$xfontfamily='font-family:arial;';  
  
// if($cfg_empr=='omaq'){$destino='mat';}     
     
if($docu_tipo=='TRAN')
{$docu1=prnt_docu2($docu,$idnum,$formato,$destino);}
  
if($docu_tipo=='MAES')
{$docu1=prnt_maes2($docu,$idnum,$formato,$destino);}
  
  
// if($formato!=2 and mb_stristr('FP.FC.AP.AC',substr($docu,0,2)))
if($formato!=2 and mb_stristr('FP.FC.AP.AC.PC.PF',substr($docu,0,2)))
{
	$docur=prnt_docur($docu,$xptoe,$xnumero,$xenti,$destino);
	$docu1=str_replace('</footer1>','</footer1>'.$docur,$docu1);
	$docu1=str_replace('</footer1>','</footer1><br>',$docu1);
} 
   
if($formato!=2 and mb_stristr('FP.FC.AP.AC',substr($docu,0,2)))
{
	$docucair=prnt_docucair($docu,$idnum,$destino);
	$docu1=str_replace('</footer1>','</footer1>'.$docucair,$docu1);
	$docu1=str_replace('</footer1>','</footer1><br>',$docu1);
} 
   
if($formato!=2 and mb_stristr('FP.FC.NC.DA',substr($docu,0,2)))
{
	$docui=prnt_docui($docu,$xptoe,$xnumero,$xenti,$destino);
	$docu1=str_replace('</footer1>','</footer1>'.$docui,$docu1);
	$docu1=str_replace('</footer1>','</footer1><br>',$docu1);
} 
   
if(mb_stristr('PLA',substr($docu,0,3)))
{
// 	$docur=prnt_compara($docu,$xptoe,$xnumero,$xenti,$destino);
	$docur=prnt_compara($docu,$idnum,$destino);
	$docu1=str_replace('</footer1>','</footer1>'.$docur,$docu1);
	$docu1=str_replace('</footer1>','</footer1><br>',$docu1);
} 

  $entiruc = msql_result($res_tra1,0,'enti') ;
//   set_facon();
  
if($formato==3 )	
{
	if(mb_stristr('retc.retp',$tabla))
	{
		$sql_rete ='select idnum1,docu,numero,fecha,enti from '.$tabla.'1';
		$sql_rete.=' where enti="'.msql_result($res_tra1,0,'enti').'" ';
		$sql_rete.=' and numero="'.msql_result($res_tra1,0,'numero').'" ';
		$sql_rete.=' and fecha="'.msql_result($res_tra1,0,'fecha').'" ';
		$sql_rete.=' and status!="O" and status!="X"';
		$sql_rete.=' order by idnum1 desc';
		$res_rete=msql_query($sql_rete,$link_vcrx);	
		$docu1=str_replace('</footer1>','</footer1><br>',$docu1);
		while($aso_rete=msql_fetch_assoc($res_rete))
		{
			$docu2=prnt_docu2($aso_rete['docu'],$aso_rete['idnum1'],'2',$destino);
			$docu2=substr($docu2,strpos($docu2,'<detalle>'));
			$docu2=substr($docu2,0,strpos($docu2,'</detalle>')+10);
			$docu1=str_replace('</footer1>','</footer1>'.$docu2,$docu1);
		}
		$docu1=str_replace('</footer1>','</footer1><br>',$docu1);
	}
	else
	{
//           echo '*/*/*/*'.$formato;
		$docu2=prnt_docu2($docu,$idnum,'2',$destino);
		$docu1=str_replace('</footer1>','</footer1><br>',$docu1);
		$docu2=substr($docu2,strpos($docu2,'<detalle>'));
		$docu2=substr($docu2,0,strpos($docu2,'</detalle>')+10);
		$docu1=str_replace('</footer1>','</footer1>'.$docu2,$docu1);
		$docu1=str_replace('</footer1>','</footer1><br>',$docu1);
		
	}
}

$lblbox=0;

if($formato==1 and mb_stristr('vtas.clie',$tabla))  
{
  if(mb_stristr('dly1.gmny.gnya.demo.',$cfg_empr))
  {
    $lblbox=1;
  }  
}
  
if(@mb_stristr('invi.clie',$user_tipo) or $user_tipo=='')
{$lblbox=0;}
  
  
if($lblbox==1)
{
    $docug = $docu1;

    $docug1 = substr($docug,strpos($docug,'<emite>'),strpos($docug,'</emite>')-strpos($docug,'<emite>')+8);
    $docug1 = str_replace('EMISOR','REMITENTE',$docug1);

    $docug2 = substr($docug,strpos($docug,'<recibe>'),strpos($docug,'</recibe>')-strpos($docug,'<recibe>')+9);
    $docug2 = str_replace('CLIENTE','DESTINATARIO',$docug2);
    $docug2 = str_replace('ADQUIRIENTE','DESTINATARIO',$docug2);
//    
    $docug ='<p class="saltodepagina" /></p>';
    $docug.='<div id="guiam" style="border:solid 0px; width:210mm; ">';
    $docug.= $docug2;
    $docug.= '<div style="height:5mm;"></div>';
    $docug.= $docug1;
    $docug.='</div>';
    $docug = str_replace($xfontsize.'px',($xfontsize*1.7).'px',$docug);
    $docug = str_replace('style="','style="font-weight:bolder;',$docug);

    $docu1.= $docug;
}

if($cheque>0)
{
  //1 solo
  //2 voucher
  
}
  
// MATRICIAL  
//   echo '*/*/*/'.$destino;
// if(@mb_stristr('pos.txt',$destino))
// {$xfontsize-=4; $xfontfamily='font-family:Courier New; font-weight:bolder; white-space:pre-wrap; width:55mm; ';}
  
// if(@mb_stristr('pos.txt',$destino))
// { $xfontfamily='font-family:Courier New; font-weight:bolder; white-space:pre-wrap; width:80mm; ';}
  
if(@mb_stristr('pos.txt',$destino))
{ $xfontfamily='font-family:Courier New; white-space:pre-wrap; width:80mm; font-weight:bolder;';}
  
// if(@mb_stristr('pos.txt',$destino))
// { $xfontfamily='font-family:Arial; white-space:pre-wrap; width:80mm; font-weight:bolder;';}
  
?>

<?php ob_start(); ?>
<?php //////////////////////////////////////////////////////////	?>
<!-- <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"> -->
<!-- <html xmlns="http://www.w3.org/1999/xhtml"> -->
<!DOCTYPE html>
<html>
<?php //////////////////////////////////////////////////////////	?>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title><?php echo $docu.'-'.$xptonumero.'-'.$xentidesc; ?></title>
<style type="text/css">

p.saltodepagina
{page-break-after: always;}
/* <p class="saltodepagina" /></p>	 */
 
#header
{display:none;}

/* @font-face {font-family:'EanP36Tt'; src:url('../_font/EAN13_36.ttf') format('truetype');} */
@font-face {font-family:'Barcode'; src:url('/_font/BarcodeFont.ttf') format('truetype');}
	
/* ean13 {font-family:'EanP36Tt';} */
barcode {font-family:'Barcode';}
	
@media print {.noprint {display:none}}
@media screen{.noscreen {display:none}}

     
<?php 
     $tirilla=0;
     if($cfg_empr=='anml' and $docu=='FC10') {$tirilla=1; } 
     if($cfg_empr=='cada' and $docu=='FC10') {$tirilla=1; } 
     if($cfg_empr=='hg01' and $docu=='FC10') {$tirilla=1; } 
  ?>
<?php if ($tirilla ==1){ ?> 
@page
{
margin: 0mm 5mm 0mm 0mm; /* 	top right bottom left */
     
     }     
<?php } ?>     
<?php if ($tirilla ==0){ ?>     
@page
{
     
size: <?php echo $ppsize.' '; if($pporient=='H'){echo ' landscape;';}else{echo ' portrait;';}; ?>
	
<?php if($copia==1) { ?>
margin: 10mm 10mm 10mm 10mm; /* 	top right bottom left */
<?php } ?>

<?php if($copia==1 and mb_stristr('tgck.sawo.ztej',$cfg_empr) and substr($docu,0,2)=='FC') { ?>
margin: 10mm 35mm 10mm 10mm; /* 	top right bottom left */
<?php } ?>
  
  
<?php if($copia==2 and $pporient=='V') { ?>
margin: 10mm 5mm 10mm 5mm; /* 	top right bottom left */
<?php } ?>

<?php if($copia==2 and $pporient=='H') { ?>
margin: 10mm 10mm 10mm 10mm; /* 	top right bottom left */
<?php } ?>

<?php if($copia>=3 and $pporient=='V') { ?>
margin: 10mm 10mm 10mm 10mm; /* 	top right bottom left */
<?php } ?>

<?php if($copia>=3 and $pporient=='H') { ?>
margin: 10mm 10mm 10mm 10mm; /* 	top right bottom left */
<?php } ?>

}
<?php } ?>     
</style>
<script type="text/javascript" src="https://vcrxol.com/_js/js_gene1.js"></script>

</head>
<?php //////////////////////////////////////////////////////////	?>

<?php //////////////////////////////////////////////////////////	?>
<body>
<?php //echo $docu1; ?>  
<?php //echo '*/*/*/'.$copia; ?>
<?php //echo '*/*/*/'.$pporient; ?>
<div style="font-size:<?php echo $xfontsize; ?>;<?php echo $xfontfamily;?>">
<?php if($copia==1){echo $docu1;} ?>
	
<?php
if($copia==2 and $pporient=='H')
{
?>
	<table align="center" border="0" width="100%" cellpadding="0" cellspacing="10mm" style="border-collapse:collapse;">
		<tr>
			<td width="45%" align="left"><?php echo $docu1; ?></td>
			<td width="10%" class="noscreen"></td>
			<td width="45%" align="right" class="noscreen"><?php echo $docu1; ?></td>
		</tr>
	</table>
<?php
}
?>
	
<?php
if($copia==2 and $pporient=='V')
{ 
?>
	<table border="0" width="100%" cellpadding="0" cellspacing="0" style="border-collapse:collapse;">
		<tr><td width="100%" align="center"><?php echo $docu1; ?></td></tr>
		<tr class="noscreen"><td width="100%" align="center"><?php echo $docu1; ?></td></tr>
	</table>
<?php
}
?>

<?php
if($copia>=3)
{
?>
	<table border="0" width="100%" cellpadding="0" cellspacing="0" style="border-collapse:collapse;">
		<tr>
			<td width="50%" align="left"><?php echo $docu1; ?></td>
			<td width="50%" align="right"><?php echo $docu1; ?></td>
		</tr>
		<tr>
			<td width="50%" align="left"><?php echo $docu1; ?></td>
			<td width="50%" align="right"><?php echo $docu1; ?></td>
		</tr>
	</table>
<?php
}
?>
	
</div>	
</body>	
<?php //////////////////////////////////////////////////////////	?>

</html>

	
	
<?php	
// 		echo $expla;

$docuhtml = ob_get_clean(); 
if(!@mb_stristr('pos.txt',$destino))
{$docuhtml = limpiahtml($docuhtml);}
$docu_idnum=$docu.'_'.str_pad($idnum,9,"0",STR_PAD_LEFT);	
file_put_contents($rutadoc.$docu_idnum.'.html',$docuhtml);

     
return $docuhtml;	
	
}
?>

<?php
function prnt_docu2($docu,$idnum,$formato=1,$destino='screen')
{
//    msql_query("flush user_resources");  
 	include('php_session.php');
	include('../_cfg/config.php');
     
     
          $mes_nombre[1]='Enero';
          $mes_nombre[2]='Febrero';
          $mes_nombre[3]='Marzo';
          $mes_nombre[4]='Abril';
          $mes_nombre[5]='Mayo';
          $mes_nombre[6]='Junio';
          $mes_nombre[7]='Julio';
          $mes_nombre[8]='Agosto';
          $mes_nombre[9]='Septiembre';
          $mes_nombre[10]='Octubre';
          $mes_nombre[11]='Noviembre';
          $mes_nombre[12]='Diciembre';
  
     
//      set_duni();
//   msql_query("SET NAMES 'utf8'");  
  
  if($docu==''){return '*** NO DOCUMENT ***';}
  if($docu=='DA16'){$formato=5;}
  
$mtime=microtime(true);
$nota1='';	
$eol="<br>";
$eol="\r\n";  
// $eol="\r";  
$pgbr=" \r\n\f";  
$gris1='#F7F7F7';
$gris1='lightgrey';
$gris1='gainsboro';
// if($destino=='screen'){$eol="<br>";}
// if($destino=='file'){$eol=" \r\n";}
$coltxt=40;
// $coltxt=38;     
$padtxt=' ';
$carbot='- ';
if($cfg_empr=='hg01')
{$carbot='  ';}
     
  
$saldo0=1/100;

// ob_start();
// 		formatos
// 			1 - general
// 			2 - diario contable (directo de la tabla cont1)
// 			3 - diario contable (desde el modulo a cont.idfrom)
//			5 - egreso detallado
	
// 		destino
// 			screen
// 			mat tricial
// 			txt pos 
	
// echo sal_docu($docu,$idnum);	

	
	$empr_cont=r_fiel('empr',$cfg_empr,'empr_cont');
	$empr_ceuser=r_fiel('empr',$cfg_empr,'empr_ceuser');
// echo '***'.$tabla;

  
//   echo '*//*/*/'.$formato;
//   echo '*//*/*/'.$empr_cont;
// die();
     
if($formato=='2' and $empr_cont!=1){return; }
 
$tabla=r_fiel('docu',$docu,'tabla');

if($cfg_empr=='tfle')
{
//   tfle_plan($docu,$idnum,'PLAN-0000','I');
//   tfle_plan($docu,$idnum,'FNAL-0000','X');
//   tfle_plan($docu,$idnum,'PSUS-0000','X');
}
  
if($cfg_empr=='pcs1')
{
//   $sql_cele='update '.$tabla.'1 set stfin=null where idnum1="'.$idnum.'"';
//   $res_cele=msql_query($sql_cele,$link_vcrx);
}  

  
  
// 	if(mb_stristr('FP',substr($docu,0,2)) and $cfg_empr=='demo'){echo gen_rpro($docu,$idnum);}
 
//  $atrz=get_atrz0($docu,$idnum);
//   echo 'aaaa'.$atrz;
    
// esta parte solo cuando formato!=2  
 vali_regidocu($docu,$idnum);
  
// updt_invepvta($docu,$idnum);
//   echo '*/*/*/'.$empr_cele;
   if($empr_cele==1)
   {
     if(mb_stristr('FP03.FP11',$docu)){gen_claveacc($docu,$idnum);}
     if(mb_stristr('PF.PC.PP',substr($docu,0,2))){gen_claveacc($docu,$idnum);}
     if(mb_stristr('FC.NC.GR',substr($docu,0,2))){gen_claveacc($docu,$idnum);}
   }
  
   if(mb_stristr('DD.DT.DI',substr($docu,0,2))){$formato=1;}
   if(mb_stristr('FP03.FP11',$docu)){get_atrz0($docu,$idnum); }
   if(mb_stristr('RPRO',$docu)){get_atrz0($docu,$idnum); }
   if(mb_stristr('FC',substr($docu,0,2))){$serie_lote=get_serie_lote($docu,$idnum);}
   if(mb_stristr('FP.NP',substr($docu,0,2))){updt_itemce($docu,$idnum);updt_ctascomp($docu,$idnum);}
//    if(mb_stristr('FP',substr($docu,0,2))){gen_invent($docu,$idnum);}
   if(mb_stristr('FP.RC',substr($docu,0,2))){get_atrz1($docu,$idnum);}
   if(mb_stristr('CH',substr($docu,0,2))){$regche=reg_ch10($idnum);}
   if(mb_stristr('ICH',substr($docu,0,3))){$depche=ich1_depo($docu,$idnum);}
   if(mb_stristr('IB11',$docu)){ib11_eb11($docu,$idnum);}
   if(mb_stristr('ATV1',$docu)){tfle_getplan($docu,$idnum);}

  
   if(mb_stristr('EB13',$docu)){gen_invent($docu,$idnum);}
  
  
   if(mb_stristr('caja.bcos',$tabla)){$caba13=gen_caba13($docu,$idnum);}
   if(mb_stristr('bcos',$tabla)){val_bcos1($docu,$idnum); }

   if(mb_stristr('PF.OP.PC.FC',substr($docu,0,2)) and $cfg_empr=='dly1'){dly1_calc1($docu,$idnum);}
   if(mb_stristr('PF.OP.PC.FC',substr($docu,0,2)) and $cfg_empr=='ecgl'){ecgl_calc1($docu,$idnum);}
   if(mb_stristr('FC',substr($docu,0,2)) and $cfg_empr=='pcs1'){pcs1_calc1($docu,$idnum);}

  
//   if($formato==2 and $tabla!='cont'){$contab=gen_contab($docu,$idnum);}		
//      echo '*/*/*/'.$formato;
  if(($formato==2 and $tabla!='cont') or ($cfg_empr=='imcp' and $tabla!='cont')){$contab=gen_contab($docu,$idnum);}		

  ecgl_calc3($docu,$idnum);
  gnya_comi0($docu,$idnum);
  
//   gmny_op10($docu,$idnum);
  
	$sql_tra0='select * from '.$tabla.'12 where idnum1='.$idnum.' limit 1 ';
	$res_tra0=msql_query($sql_tra0,$link_vcrx);	
  
  $enti=@msql_result($res_tra0,0,'enti');
  $fecha=@msql_result($res_tra0,0,'fecha');
  $entides=@msql_result($res_tra0,0,'enti_descri');
  $entiraz=@msql_result($res_tra0,0,'enti_razsoc');
  $entinom=@msql_result($res_tra0,0,'enti_nomcom');
  $idfrom=@msql_result($res_tra0,0,'idfrom');
     
     
//      echo '*/*/*'.substr($docu,0,2).$cfg_empr.$fecha;
   if(mb_stristr('FC.NC',substr($docu,0,2)) and $cfg_empr=='pcs1' and $fecha>="2022-01-01"){gen_invent($docu,$idnum);}
   if(mb_stristr('FC',substr($docu,0,2)) and $cfg_empr=='hg01' and $fecha>="2022-07-12"){gen_invent($docu,$idnum);}
     
//   $entides=r_fiel('enti',$enti,'descri');
//   $entiraz=r_fiel('enti',$enti,'razsoc');
//   $entinom=r_fiel('enti',$enti,'nomcom');
  if(mb_stristr($entides.$entiraz,'sri.gob.ec'))
  {
    $sql_uent='update enti0 set enti_razsoc=enti_nomcom where (enti_razsoc="" or enti_razsoc is null or enti_razsoc like "%sri.gob%") and  enti_codigo like "'.$enti.'%"' ;
    $res_uent=msql_query($sql_uent,$link_vcrx);
    $sql_uent='update enti0 set enti_descri=enti_razsoc where (enti_descri="" or enti_descri is null or enti_descri like "%sri.gob%") and  enti_codigo like "'.$enti.'%"' ;
    $res_uent=msql_query($sql_uent,$link_vcrx);
  }

  if(mb_stristr($entides.$entiraz,'***'))
  {
    $sql_uent='update enti0 set enti_descri=enti_razsoc where (enti_descri="" or enti_descri is null or enti_descri like "%***%") and enti_codigo like "'.$enti.'%" and ifnull(enti_razsoc,"")!=""' ;
    $res_uent=msql_query($sql_uent,$link_vcrx);
  }
     
     
  if(mb_stristr($entides.$entiraz.$entinom,'sp;') or $entides=='' or $entiraz=='' or $entinom=='')
  {reg_cedruc($enti);}
     
  
  $numeroxx=@msql_result($res_tra0,0,'numero');
  $claveacc=@msql_result($res_tra0,0,'claveacc');
  $ambice=substr($claveacc,23,1);

	$ccc=0;
	$overpdf=0;	
	$docu_idnum=$docu.'_'.fillzero($idnum);	
	if($destino==''){$destino='screen';}	
	if($destino=='pdf'){$overpdf=1;}	
// 	if(mb_stristr($destino,'mail') or $destino=='pdf' or $destino=='M'){$destino='mail';}
	if(mb_stristr($destino,'mail') or $destino=='M'){$destino='mail';}

{
	$mdisplay=2;
	if(mb_stristr($destino,'mail')){$mdisplay=1; $destino='mail';}
	if(mb_stristr('pos.txt',$destino)){$mdisplay=1;}
	if($formato==2){$tabla='cont';}

  
	$sql_docu='select * from docu0 where docu_codigo like "'.$docu.'%"';
	$res_docu=msql_query($sql_docu,$link_vcrx);
	$tabla=strtolower(msql_result($res_docu,0,'docu_tabla'));	
  
	$ppsize=@msql_result($res_docu,0,'docu_ppsize');	
	$pporient=@msql_result($res_docu,0,'docu_pporient');	

	$width=@msql_result($res_docu,0,'docu_width');	
	$height=@msql_result($res_docu,0,'docu_height');	
	$orient=@msql_result($res_docu,0,'docu_orient');	

	$doble=@msql_result($res_docu,0,'docu_doble');	
	$copia=@msql_result($res_docu,0,'docu_copia');	

	$mindeta=@msql_result($res_docu,0,'docu_mindeta');	
	$docupdf=@msql_result($res_docu,0,'docu_pdf');	
	$margin_top=@msql_result($res_docu,0,'docu_top');	
	$margin_left=@msql_result($res_docu,0,'docu_left');
  
  if($ambice=='2'){$margin_top=0;}

	$doculogo=0;
	$firmas=0;
	$marcas=0;
	$notas=1;
  $obser=0;
	$guiaremi=0;
	if(mb_stristr('FC.OP.PC.PF.NC..GR..RP..PP..IE.IC..CH.ND...CA',substr($docu,0,2))){$doculogo=1;}
 	if(mb_stristr('FC.OP.PC.PF.NC..GR..RP..PP..IE.EE.IC..CH..EB',substr($docu,0,2))){$firmas=1;}
	if(mb_stristr('FP11.FP03',substr($docu,0,4))){$doculogo=1; $firmas=1;}
 	if(mb_stristr('DD.RP.RC.',substr($docu,0,2))){$notas=0;}
	if(mb_stristr('GR',substr($docu,0,2))){$guiaremi=1;}
	if(mb_stristr('clie.vtas',$tabla)){$marcas=1;}
	if(mb_stristr('inve',$tabla) and $cfg_empr=='hfre'){$firmas=1;}
	if(mb_stristr('inve',$tabla)){$firmas=1;}
	if($destino=='mail'){$margin_top=0; $firmas=0;}
	if($margin_top>0){$doculogo=0;}
  if(mb_stristr('inve',$tabla) and $cfg_empr=='hfre'){$doculogo=1;}
  

 	if(mb_stristr('OP',substr($docu,0,2)) and mb_stristr('gmny',$cfg_empr)){$obser=1;}
  
	if($ppsize==''){$ppsize='A4';}
	if($pporient==''){$pporient='V';}
	if($width==0){$width=210;}
	if($height==0){$height=297;}
	if($orient==''){$orient='V';}	
	if($copia==0){$copia=1;}	
  if($formato==1){$copia=1;}

//      echo '*/*/*'.$destino;
//      die();
     
  if(mb_stristr('pos.txt',$destino))
  {
    $mdisplay=1;
    $copia=1;
    $margin_top=0;
    $doculogo=0;
    $firmas=0;
  }

	if($user_codigo=='')
	{
		$ppsize='A4';
		$pporient='V';
		$width=210;
		$height=297;
		$orient='V';
		$copia=1;
	}	
	
	$xfontsize=12;
	$screensize=12;
	$printsize=12;
	if($width<=150)
	{
		$xfontsize=12;
		$screensize=12;
		$printsize=8;
	}
	if($width<=110)
	{
		$xfontsize=12;
		$screensize=12;
		$printsize=6;
	}


    if($cfg_empr=='anml' and $docu=='FC10'){$width=90;}
    if($cfg_empr=='cada' and $docu=='FC10'){$width=90;}
    if($cfg_empr=='hg01' and $docu=='FC10'){$width=90; $printsize=12; $xfontsize=12;}
	// $width=70;
// 	$tirilla=0;	
//      if($tirilla==1)     
    if($width<=90)
	{
		$tirilla=1;
		$xfontsize=12;
		$screensize=12;
		$printsize=12;
	}
  
  

	if($formato==2 and $tabla!='cont')
	{
			$sql_tra1='select * from cont1 where idfrom="'.$idnum.'" and mdfrom="'.$tabla.'"';
			$res_tra1=msql_query($sql_tra1,$link_vcrx);
			$idnum=@msql_result($res_tra1,0,'idnum1');
			$tabla='cont';
	}	
	
	
	if($formato>=2)
	{
		$xfontsize=12;
		$screensize=12;
		$printsize=12;
		$ppsize='A4';
		$pporient='V';
		$width=210;
		$height=297;
		$orient='V';
		$copia=1;
		$doculogo=0;
		$firmas=1;
		$marcas=0;
		$notas=0;
		$guiaremi=0;
		$xmdetalle='-';
		$margin_top=0;
	}
  
	if($formato==5)
	{
//     echo '*/*/*/';
		$xfontsize=12;
		$screensize=12;
		$printsize=12;
		$ppsize='A4';
		$pporient='H';
		$width=297;
		$height=210;
		$orient='H';
		$copia=1;
		$doculogo=0;
		$firmas=1;
		$marcas=0;
		$notas=0;
		$guiaremi=0;
		$xmdetalle='-';
		$margin_top=0;
	}
  
	
	{	
		$sql_emis='select * from empr0 left join enti00 on empr_ruc=enti_codigo limit 1';
		$res_emis=msql_query($sql_emis,$link_vcrx);
//     if(msql_errno!=0)
    if(msql_errno($link_vcrx)!=0)
    {
      $sql_emis='select * from empr0 left join enti0 on empr_ruc=enti_codigo limit 1';
      $res_emis=msql_query($sql_emis,$link_vcrx);
    }

      if($cfg_empr=='gnya' and $tabla=='vtas')
      {
         $sql_emis='select * from enti0 where enti_codigo like "1900318468%"  order by enti_codigo desc limit 1';
         $res_emis=msql_query($sql_emis,$link_vcrx);
      }
//     $empr_lote=@msql_result($res_emis,0,'empr_lote');  

     $empr_lote=0;
      if(mb_stristr('inve.prod.vtas.clie.tfin',$tabla))
      {$empr_lote=r_fiel('empr',$cfg_empr,'empr_lote');}
//           echo '*/*/*'.$empr_lote;
          
      
    {
      $sql_total=sql_total($tabla);
      $dispcolu=1;
      if($mobile=='true'){$dispcolu=0;}
		}

		$sql_tra1='select * from '.$tabla.'12 where idnum1="'.$idnum.'"';
		if(mb_stristr('retc.retp',$tabla))
		{
			$sql_tra1 ='select * from '.$tabla.'12 where status!="O" and status!="X" and cant>0 and ';
			$sql_tra1.='concat(numero,fecha,enti) in (select concat(numero,fecha,enti) as numero from '.$tabla.'1 where idnum1="'.$idnum.'" )';
		}
    
		if(mb_stristr('CE10',$docu))
    {
      $sql_tra1.=' and nvdd_tipo<3 ';      
    }
      
		$sql_tra2=$sql_tra1;
      
      
//       if(mb_stristr('vtas',$tabla) and mb_stristr('gmny.gnya',$cfg_empr))
//       {$sql_tra1.=' group by item_raiz '}
      
      
		$sql_tra1=str_replace('*','*,'.$sql_total,$sql_tra1);
          
//           echo '=== '.$sql_tra1;
      

    $sql_tra2.='order by iddet ';
		if($cfg_empr=='ecgl' and mb_stristr('vtas.clie.prod',$tabla)){$sql_tra2=str_replace('order by',' order by itnum,',$sql_tra2);}
		if(mb_stristr('tgck.sawo.ztej',$cfg_empr)  and mb_stristr('vtas.clie',$tabla)){$sql_tra2=str_replace('order by',' order by vhcl,',$sql_tra2);}
		if($cfg_empr=='gmny' and mb_stristr('prod',$tabla)){$sql_tra2=str_replace('order by',' order by item,',$sql_tra2);}
		if(mb_stristr('cont',$tabla)){$sql_tra2=str_replace('order by','order by ctas,cant desc,',$sql_tra2);}
		if(mb_stristr('nomi',$tabla)){$sql_tra2=str_replace('order by','order by enti2,nvdd,',$sql_tra2);}
		if(mb_stristr('empl',$tabla)){$sql_tra2=str_replace('order by','order by nvdd_tipo,nvdd,fecha2,',$sql_tra2);}
		if(mb_stristr('susa',$tabla)){$sql_tra2=str_replace('order by','order by fecha2,',$sql_tra2);}
		if(mb_stristr('IB00',$docu)){$sql_tra2=str_replace('order by','order by item_lsub,item_descri,',$sql_tra2);}

    $res_tra1=msql_query($sql_tra1,$link_vcrx);	
    
    $enti_codigo=msql_result($res_tra1,0,'enti');
    $enti_descri=msql_result($res_tra1,0,'enti_descri');
    $enti_razsoc=msql_result($res_tra1,0,'enti_razsoc');
    $enti_nom1=msql_result($res_tra1,0,'enti_nom1');
    $enti_matriz=msql_result($res_tra1,0,'enti_matriz');
    $enti_direccion=msql_result($res_tra1,0,'enti_direccion');
//     $enti_matriz=r_fiel('enti',$enti_codigo,'enti_matriz');
//     $enti_ciudad=r_fiel('enti',$enti_codigo,'enti_ciudad');
    $enti_parroq= msql_result($res_tra1,0,'enti_parroq');
//     $enti_parroq= r_fiel('enti',$enti_codigo,'enti_parroq');
    $ptoemi=msql_result($res_tra1,0,'ptoe');
    
    $logosucur='logo'.$cfg_empr.substr($ptoemi,0,3).'.png';
    if(file_exists($rutalogo.$logosucur)){$logofile2=$logosucur;}

		if($enti_razsoc=='' or mb_stristr($enti_razsoc,'sp;')){reg_cedruc($enti_codigo);}
		if( (strlen(trim($enti_descri))<=3 and strlen(trim($enti_razsoc))<=3) or (empty($enti_descri)) or (mb_stristr('<LINK',$enti_descri)) )
    {get_ruc0($enti_codigo);}
    
      
//     if(date('Y-m-d')<='2020-09-30')
    {get_rime($enti_codigo);}
    
//     if(date('Y-m-d')<='2020-09-30')
    {get_agret($enti_codigo);}
    
    $enti_orig=$enti_codigo;
//     $sql_adqu='select * from enti00 where enti_codigo like "'.$enti_codigo.'%" order by enti_codigo desc';
    $sql_adqu='select * from enti00 where enti_codigo = "'.$enti_codigo.'" order by enti_codigo desc';
		$res_adqu=msql_query($sql_adqu,$link_vcrx);

    $xtoenti=@msql_result($res_tra1,0,'toenti');
		$sql_toen=$sql_adqu;
		if($tabla=='comp'){$sql_toen='select * from enti00 where enti_codigo like "'.$xtoenti.'%" order by enti_codigo desc';}
		if($tabla=='retc'){$sql_toen='select * from enti00 where enti_codigo like "'.$xtoenti.'%" order by enti_codigo desc';}
		$res_toen=msql_query($sql_toen,$link_vcrx);
    
    if(msql_num_rows($res_toen)==0)
    {
      get_ruc0($xtoenti);
      $res_toen=msql_query($sql_toen,$link_vcrx);
    }

    
		$xptonumero=msql_result($res_tra1,0,'ptonumero');
		$xenti=msql_result($res_tra1,0,'enti');
		
		$entipdf=0;
		$entipdf=@r_fiel('enti',$xenti,'pdf');

    $enticomi=0;
    if(mb_stristr('vtas.clie',$tabla)){$enticomi=@r_fiel('enti',$xenti,'comi');}
		
		if(mb_stristr('clie.prov',$tabla)){$xclaveacc=msql_result($res_tra1,0,'claveacc');}
		
		if(mb_stristr('vtas.comp.retc.retp.guia.comp.prod',$tabla))
		{
			$xclaveacc=msql_result($res_tra1,0,'claveacc');
			$xautornum=msql_result($res_tra1,0,'autornum');
			$xautorfec=@msql_result($res_tra1,0,'autorfec');
			$xatrz=msql_result($res_tra1,0,'atrz');
			$xatrzvali=@msql_result($res_tra1,0,'atrzvali');
		}
    
// 		$fecha=msql_result($res_tra1,0,'fecha');
// 		$fcobro=msql_result($res_tra1,0,'fcobro');
		$xstatus=msql_result($res_tra1,0,'status');
		$xstfin=msql_result($res_tra1,0,'stfin');
		$xambi=substr($xclaveacc,23,1);
		$docu_descri=msql_result($res_tra1,0,'docu_descri');
		$tiporuc=msql_result($res_tra1,0,'enti_tiporuc');
		if($tiporuc=='N'){$docupdf=0; $entipdf=0;}

		$tipo_descri='';
		if(substr($xclaveacc,8,2)=='01'){$tipo_descri='FACTURA';}
		if(substr($xclaveacc,8,2)=='03'){$tipo_descri='LIQUIDACION DE COMPRA';}
		if(substr($xclaveacc,8,2)=='04'){$tipo_descri='NOTA DE CREDITO';}
		if(substr($xclaveacc,8,2)=='06'){$tipo_descri='GUIA DE REMISION';}
		if(substr($xclaveacc,8,2)=='07'){$tipo_descri='RETENCION';}
// 		if($docu_descri=="" or $empr=="cfg_demo"){$docu_descri=$tipo_descri;}
// 		if($docu_descri=="" or $empr=="demo"){$docu_descri=$tipo_descri;}
		if($tipo_descri!=''){$docu_descri=$tipo_descri;}
		
		$xmdetalle=trim(msql_result($res_tra1,0,'mdetalle'));
		$xldetalle=trim(msql_result($res_tra1,0,'ldetalle'));
		$xlitemdescri=trim(@msql_result($res_tra1,0,'litemdescri'));
		$xmctas=@msql_result($res_tra1,0,'mctas');
		$xmcsub=@msql_result($res_tra1,0,'mcsub');
		$xmcair=@msql_result($res_tra1,0,'mcair');
		$xmitem=@msql_result($res_tra1,0,'mitem');

		$xmlote=@msql_result($res_tra1,0,'mlote');
          $xmserie=@msql_result($res_tra1,0,'mserie');
          if($empr_lote==0){$xmlote='';}
          if($empr_srie==0){$xmserie='';}
		
    $xmcntn=@msql_result($res_tra1,0,'mcntn');
    $xmvhcl=@msql_result($res_tra1,0,'mvhcl');
    
//     echo '*/*/*/'.$sql_tra1;
//     echo '*/*/*/'.$xmlote;
    
    $xmclor=@msql_result($res_tra1,0,'mclor');
    $xmtlla=@msql_result($res_tra1,0,'mtlla');
    
    $xmarcl=@msql_result($res_tra1,0,'marcl');
    $xmisdi=@msql_result($res_tra1,0,'misdi');

    //ecgl
    $xstlmn=@msql_result($res_tra1,0,'stlmn');
    $xstmt1=@msql_result($res_tra1,0,'stmt1');
		$xstmt2=@msql_result($res_tra1,0,'stmt2');
	
    if($tirilla==1){$xmdetalle='';}

		$xtunid=0;
		$xipuni=1;
		$xideta=1;
		$xpdcto=0;
		$xpprop=0;
		$xpice=0;
		$xpiva=0;
		$xpirbp=0;
		$xtdcto=0;
		$xtprop=0;
		$xtsubtice=0;
		$xtice=0;
		$xtsubtiva0=0;
		$xtsubtiva=0;
		$xtiva=0;
		$xtirbp=0;
    $xipvp=0;

    
// 		if(mb_stristr('vtas.clie.carr', $tabla) and mb_stristr('gmny.gnya',$cfg_empr))
//     {$xipvp=1;}
    
    
		$xtcant=msql_result($res_tra1,0,'stcant');
//           echo '*/*/*'.$xtcant;
		$xtsubt=abs(msql_result($res_tra1,0,'stsubt'));
          $xtpeso=@msql_result($res_tra1,0,'speso');
          
          if($docu=='DA16' and $fecha>="2022-01-01")
          {
               $sql_item20 ='select sum(cant) as stcant20, sum(cant*puni) as stsubt20, sum(peso) as speso20 ';
               $sql_item20.='from prov1 left join prov2 on idnum1=idnum2 ';
               $sql_item20.='where item like "20%" and idnum1="'.$idnum.'"';
               $res_item20=msql_query($sql_item20,$link_vcrx);
               
               $xtcant20=msql_result($res_item20,0,'stcant20');
               $xtsubt20=abs(msql_result($res_item20,0,'stsubt20'));
               $xtpeso20=@msql_result($res_item20,0,'speso20');
               
               $xtcant=$xtcant20;
               $xtsubt=$xtsubt20;
               $xtpeso=$xtpeso20;
     //          echo '--++';
//           echo '*/*/*'.$xtcant;
          }
          
          
      if($xipuni==0){$xtsubt=0;}
		
		if(mb_stristr('retc.retp', $tabla))
		{
      $xtrrta=msql_result($res_tra1,0,'srrta');
      $xtriva=msql_result($res_tra1,0,'sriva');
		}

		$xtotal=msql_result($res_tra1,0,'stotal');
		$xconcepto=msql_result($res_tra1,0,'concepto');
          $xconcepto=str_replace(',',', ',$xconcepto);
          $xconcepto=str_replace(',  ',', ',$xconcepto);
    
    if($tabla=='susa'){$xtotal=get_susa($enti);  }
    
//     if($docu=='DA16'){$xtsubt=0;}
    
		$xcntn=@msql_result($res_tra1,0,'cntn');
		$ximpor=@msql_result($res_tra1,0,'impor');
// 		$ximpor=@msql_result($res_tra1,0,'impor2');
		$xcostoe1=@msql_result($res_tra1,0,'costoe1');
		$xseguro1=@msql_result($res_tra1,0,'seguro1');
		$xflete1=@msql_result($res_tra1,0,'flete1');
		$xcostol1=@msql_result($res_tra1,0,'costol1');
          
		$xcostoe1d=@msql_result($res_tra1,0,'costoe1d');
		$xseguro1d=@msql_result($res_tra1,0,'seguro1d');
		$xflete1d=@msql_result($res_tra1,0,'flete1d');
		$xcostol1d=@msql_result($res_tra1,0,'costol1d');
          
          switch($xcostoe1d)
          {
               case 1:$xcostoe1dd='UNDS';break;
               case 2:$xcostoe1dd='VALOR';break;
               case 3:$xcostoe1dd='PESO';break;
               default:$xcostoe1dd='-';break;
          }
          
          switch($xcostol1d)
          {
               case 1:$xcostol1dd='UNDS';break;
               case 2:$xcostol1dd='VALOR';break;
               case 3:$xcostol1dd='PESO';break;
               default:$xcostol1dd='-';break;
          }
          
          switch($xseguro1d)
          {
               case 1:$xseguro1dd='UNDS';break;
               case 2:$xseguro1dd='VALOR';break;
               case 3:$xseguro1dd='PESO';break;
               default:$xseguro1dd='-';break;
          }
          
          switch($xflete1d)
          {
               case 1:$xflete1dd='UNDS';break;
               case 2:$xflete1dd='VALOR';break;
               case 3:$xflete1dd='PESO';break;
               default:$xflete1dd='-';break;
          }
          
    $xfob1=$xcostoe1+$xtsubt;
    $xcif1=$xfob1+$xseguro1+$xflete1;
		$xadva=@msql_result($res_tra1,0,'sadva');
		$xespe=@msql_result($res_tra1,0,'sespe');
		$xdump=@msql_result($res_tra1,0,'sdump');
		$xfodi=@msql_result($res_tra1,0,'sfodi');
		$xicei=@msql_result($res_tra1,0,'sicei');
		$xivai=@msql_result($res_tra1,0,'sivai');
      $xivai=0;
    
    
		$xbenefic=@msql_result($res_tra1,0,'benefic');
		$xattn=@msql_result($res_tra1,0,'attn');
    $xattndes=r_fiel('enti',$xattn);

		if($guiaremi==1)
		{
			$motivo=@msql_result($res_tra1,0,'motivo');
			$idfrom=msql_result($res_tra1,0,'idfrom');
			$mdfrom=msql_result($res_tra1,0,'mdfrom');
			
      
      if($idfrom!='')
      {$sql_orig='select * from '.$mdfrom.'12 where idnum1="'.$idfrom.'"';}
			
      
      if(($numfac*1)!=0)
      {
        $sql_orig ='select * from vtas12 ';
//         $sql_orig ='select * from vtas1 ';
        $sql_orig.='where numero="'.$numfac.'"';
        $sql_orig.=' and status!="O"';
        $sql_orig.=' and status!="X"';
        $sql_orig.=' order by fecha desc ';
        $sql_orig.=' limit 1 ';
      }
      $res_orig=msql_query($sql_orig,$link_vcrx);
      
			$docuorig=@msql_result($res_orig,0,'docu');
			$docuorigd=@msql_result($res_orig,0,'docu_descri');
			$numeroorig=@msql_result($res_orig,0,'ptonumero');
			$fechaorig=@msql_result($res_orig,0,'fechadmy');
			$autororig=@msql_result($res_orig,0,'claveacc');
      if(substr($docuorig,0,2)=='FC'){$docuorigd='FACTURA';}
      if(substr($docuorig,0,2)=='EB'){$docuorigd='EGRESO DE BODEGA';}
			if(substr($docuorig,0,2)=='FC'){$motivo='VENTA';}
			if(substr($docuorig,0,2)=='EB'){$motivo='TRANSFERENCIA';}
			if(substr($docuorig,0,4)=='EB10'){$motivo='VENTA';}
			if(substr($docuorig,0,4)=='EB13'){$motivo='TRANSFERENCIA';}
			
		}
			
		$xvndd='';
		$xfpag='';
		$xsuco='';

		if(mb_stristr('cont', $tabla))
		{
			$xtdebito=msql_result($res_tra1,0,'stdebito');
			$xtcredito=msql_result($res_tra1,0,'stcredito');
			$xdifer=msql_result($res_tra1,0,'sdiferencia');
		}
		if(mb_stristr('nomi.empl', $tabla))
		{
			$xtremun=msql_result($res_tra1,0,'stingreso');
			$xtdeduc=abs(msql_result($res_tra1,0,'stegreso'));
			$xtprovi=msql_result($res_tra1,0,'stprovis');
               $xtotal=$xtremun-$xtdeduc;
		}
		if(mb_stristr('vtas.clie.comi.comp.prov.dxco.dxpa.inve.prod.carr.tfin', $tabla))
		{
      //costos
		  $xipuni=1;
			$xtunid=$xtcant;
			$xfpag=@msql_result($res_tra1,0,'fpag');
			if(mb_stristr('vtas.clie.comi.comp.prov.carr', $tabla))
			{
				$xipuni=1;
				$xpdcto=msql_result($res_tra1,0,'pdcto');
				$xpprop=msql_result($res_tra1,0,'pprop');
				$xpice=msql_result($res_tra1,0,'pice');
				$xpiva=msql_result($res_tra1,0,'piva');
				$xpirbp=msql_result($res_tra1,0,'pirbp');
				$xtdcto=msql_result($res_tra1,0,'stdcto');
				$xtprop=msql_result($res_tra1,0,'stprop');
				$xtsubtice=msql_result($res_tra1,0,'stsubtice');
				$xtice=msql_result($res_tra1,0,'stice');
				$xtsubtiva0=abs(msql_result($res_tra1,0,'stsubtiva0'));
				$xtsubtiva=abs(msql_result($res_tra1,0,'stsubtiva'));
				$xtiva=abs(msql_result($res_tra1,0,'stiva'));
				$xtirbp=msql_result($res_tra1,0,'stirbp');
			}
			if(mb_stristr('nomi.empl', $tabla))
			{
//                     $tremun=@msql_result($res_tra1,0,'tingreso');
//                     $tdeduc=@msql_result($res_tra1,0,'tegreso');
			}
			if(mb_stristr('vtas.clie.comi.carr', $tabla))
			{
				$xtbien=@msql_result($res_tra1,0,'stbien');
				$xtserv=@msql_result($res_tra1,0,'stserv');
				$xtunid=$xtbien;
				$xvndd=@msql_result($res_tra1,0,'vndd');
				$xvndddes=r_fiel('enti',$xvndd);
			}
			if(mb_stristr('comp.prov', $tabla))
			{
				$xsuco=msql_result($res_tra1,0,'suco');
			}
			if(mb_stristr('inve.prod.tfin', $tabla))
			{
//                     $user_codigo=115;
           $docuacce='COST';
           include('php_useracce.php');
           $xipuni=$user_cons;
//                     echo '*/*/*'.$xipuni;
//             $xipuni=0;
			}
		}

		if(mb_stristr('prod', $tabla) and $cfg_empr=='ecgl'){$xtunid=0;$xtotal=0;}
//				$xtpeso=@msql_result($res_tra1,0,'speso');
    
		$xiuser=msql_result($res_tra1,0,'iuser');
		$xidate=msql_result($res_tra1,0,'idate');
		$xudate=msql_result($res_tra1,0,'udate');
    if($xidate==''){$xidate=msql_result($res_tra1,0,'fecha');}


		$lblruc1='EMISOR';
		$lblruc2='ADQUIRIENTE';

		if(mb_stristr('cont',$tabla))
		{$lblruc1='EMPRESA';}
		
		if(mb_stristr('comp.retc',$tabla))
		{
			$res_emis=msql_query($sql_adqu,$link_vcrx);
			$res_adqu=msql_query($sql_emis,$link_vcrx);
// 			if($cfg_empr =='demo')
			if(mb_stristr('demo.cele',$cfg_empr))
			{$res_adqu=msql_query($sql_toen,$link_vcrx);	}
		}
          
          if($empr_ceuser==1)
          {
               $xemis =@msql_result($res_tra1,0,'vndd');
               $sql_emis='select * from enti0 where enti_codigo="'.substr($xemis,0,10).'"';
               $res_emis=msql_query($sql_emis,$link_vcrx);
               
          }
          
          

		if(mb_stristr('OP.QP',substr($docu,0,2)))
		{$lblruc2='TALLER';}

		if(mb_stristr('PC.PF.AC',substr($docu,0,2)))
		{$lblruc2='CLIENTE';}

		if(mb_stristr('IE.IC.IV.DC',substr($docu,0,2)))
		{$lblruc2='CLIENTE';}

		if(mb_stristr('EE.CH.EV.DP.RP.PP.AP',substr($docu,0,2)))
		{$lblruc2='PROVEEDOR';}

		if(mb_stristr('RCLI',substr($docu,0,4)))
		{
      $lblruc1='CLIENTE';
      $lblruc2='PROVEEDOR';
    }

    if(mb_stristr('inve.tfin',$tabla))
		{$lblruc2='ENTIDAD';}

		if(mb_stristr('susa.rolp.empl',$tabla))
		{$lblruc2='EMPLEADO';}

		if(mb_stristr('plan',$tabla))
		{
      $lblruc1='ENTIDAD';
      $lblruc2='CLIENTE';
    }

		if(mb_stristr('atvd',$tabla))
		{
      $lblruc1='ENTIDAD';
      $lblruc2='EMPLEADO';
    }

		if(mb_stristr('DB.DC',substr($docu,0,2)))
		{
      $lblruc1='ENTIDAD';
      $lblruc2='DEPOSITANTE';
    }

		if(mb_stristr('FP11.FP03.IB10',substr($docu,0,4)))
		{
			$lblruc2='PROVEEDOR';
			$res_emis=msql_query($sql_emis,$link_vcrx);
			$res_adqu=msql_query($sql_adqu,$link_vcrx);
		}

				
	}	
}	

  
?>	


<?php //////////////////////////////////////////////////////////	?>
<?php  $subdce=mk_subdce($claveacc); ?>

	<?php $xfontsize=$screensize; ?>
	<?php $filexml=$rutace.$xclaveacc.'.xml'; ?>
	<?php $filepdf=$rutace.$xclaveacc.'.pdf'; ?>
	<?php $filepdf2=$rutadoc.$docu_idnum.'.pdf'; ?>

	<?php $filexml=$rutace.$subdce.$xclaveacc.'.xml'; ?>
	<?php $filepdf=$rutace.$subdce.$xclaveacc.'.pdf'; ?>
	<?php $filepdf2=$rutadoc.$docu_idnum.'.pdf'; ?>


	<?php // if($destino=='mail'){ ?>
	<?php	//echo '<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">'; ?>
	<?php	//echo '<html xmlns="http://www.w3.org/1999/xhtml">'; ?>
	<?php // } ?>



<?php ob_start(); ?>
<style>
@page{margin: 10mm 5mm 0mm 5mm; }     
</style>
<div class="noprint">
<?php //echo date('H:i:s'); ?>
</div>
	<?php for($cdisplay=1;$cdisplay<=$mdisplay;$cdisplay++) { ?>

  <?php 
    $xfontfamily='font-family:arial;';  
    if($cfg_empr=='ecgl' and mb_stristr('FC',substr($docu,0,2))){$destino='mat';}
    if($cfg_empr=='dly1' and mb_stristr('FC.PC',substr($docu,0,2)) and $destino!='mail' and $cdisplay==2){$destino='mat';}
//     if($cfg_empr=='omaq' and mb_stristr('FC.PC',substr($docu,0,2)) and $destino!='mail' and $cdisplay==2){$destino='mat';}
//     if(substr($destino,0,3)=='mat'){$xfontsize+=2; $xfontfamily='font-family:Courier New; font-weight:bolder;';$doculogo=0;}
    if(substr($destino,0,3)=='mat'){$xfontsize+=4; $xfontfamily='font-family:Courier New; font-weight:bolder;';$doculogo=0;}
    if(mb_stristr('pos.txt',$destino)){$xfontsize-=4; $xfontfamily='font-family:Courier New; font-weight:bolder;white-space:pre-wrap;';}
  ?>

	<?php if($cdisplay==2){?>
	  <div id="border-top" style="width:10mm; height:<?php echo $margin_top;?>mm"></div>
    <?php if(mb_stristr('tgck.sawo.ztej',$cfg_empr)  and substr($docu,0,2)=='FC') { ?>
      <div id="border-left" style="float:left; width:<?php echo $margin_left;?>mm; height:10mm;">
      </div>
    <?php } ?>
	<?php } ?>
	<div id="cele<?php echo $cdisplay;?>" 
			 style="border:solid 0px; <?php echo $xfontfamily;?>; 
              float:left; 
               <?php if($cdisplay==1)
                {
                  if($width<=210){echo 'width:210mm;';}
                  else{echo 'width:'.($width).'mm;';}
                }
                else{echo 'width:'.($width).'mm;';}
              ?>
							<?php if($mdisplay>1){?>
							<?php //{echo 'width:'.$width.'mm;';}?>
							<?php } ?>
							font-size:<?php echo $xfontsize; ?>px;
							overflow:hidden;
							transform: scale(1);
							<?php if($cdisplay=='rotate'){echo 'transform:rotate(180deg);';} ?>;
              "
						 <?php  if($cdisplay==1){{echo 'class="noprint";';}}else{echo 'class="noscreen";';}?>>	

    
    
  <?php
  $docu_pdf = new FPDF('P','mm', $ppsize);
  $docu_pdf->AddPage();
	$docu_pdf->SetTitle($docu_descri.' '.$xptonumero);
	$docu_pdf->SetAuthor('Vicente Ruiz Espinoza - 09 96030568');																									
  $docu_pdf->setFillColor(240,240,240);                                                      
  $pdf_ancho=$docu_pdf->GetPageWidth()-20;
  $pdf_centro=$docu_pdf->GetPageWidth()/2-10;
  $ffamilyPDF='Arial';  
  $fsizePDF=$xfontsize;                                              
  if(mb_stristr(strtolower($xfontfamily),'courier'))                                                        
  {
    $ffamilyPDF='Arial';  
    $fsizePDF=$xfontsize-2;                                              
  }
  ?>    

	<cabecera>
	<table border="0" width="96%" cellpadding="2" cellspacing="0" style="border-collapse:collapse;font-size:<?php echo $xfontsize; ?>px;">
			<tr style="font-weight:bolder; font-size:<?php echo $xfontsize; ?>px; background:<?php echo $gris1;?>; 
								 border-top:solid 1px; border-bottom:solid 1px;">
				<td width="20%">
				</td>
				<td width="60%" align="center" style="letter-spacing:5pt;">
				<?php
					if($formato==2){$titulcompro= 'DIARIO - CONTABLE';}
					else
					{
            $titulcompro='COMPROBANTE';
            if($xclaveacc!="" and ($xambi!=1 or $cdisplay!=2)){$titulcompro.=' - ELECTRONICO';}
            if($tabla=='inve' and $cfg_empr=='hfre'){$titulcompro=$docu.' - '.$docu_descri;}
					}
          echo $titulcompro;
        ?>
				</td>
        
        <?php
          $docu_txt='';                                                        
          $docu_txt.=str_repeat('=',$coltxt).$eol;
          $docu_txt.=str_pad(''.$titulcompro.' ',$coltxt,$carbot,STR_PAD_BOTH).$eol;
          $docu_txt.=str_repeat('=',$coltxt).$eol;
				?>

        <?php 
          $docu_pdf->SetFont($ffamilyPDF,'B',$fsizePDF-2);
          $docu_pdf->SetFontSize($fsizePDF-2);
          $docu_pdf->Cell(0,5,$titulcompro,'TB',0,'C',false);
          $docu_pdf->ln();
          $posY1=$docu_pdf->getY()+1;                                                        
          $posY2=$docu_pdf->getY()+1;                                                        
        ?>
        
				<td width="20%" align="right" style="font-size:50%;">
					<?php if($xiuser!="" and $destino!='mail'){?>
					<?php echo 'REGISTRADO POR: ';?>
					<?php echo r_fiel('user',$xiuser);?>
					<?php echo '<br>';?>
					<?php } ?>
					<?php echo date('d/M/y H:i:s',strtotime($xidate));?>
					<?php //echo '<br>';?>
					<?php //echo date('d/M/y H:i:s',strtotime($xudate));?>
				</td>
			</tr>
		</table>		
	</cabecera>

		<?php $hlogo=20; if($cdisplay!=1){if($width<=150){$hlogo=15;}; if($width<=110){$hlogo=10;};} ?>
		<table border="0" width="96%" cellpadding="2" cellspacing="0" style="border-collapse:collapse;font-size:<?php echo $xfontsize; ?>px;">
			<tr>
				<?php //210*297 =62370 ?>
				<?php ///// COLUMNA IZQUIERDA ?>
				<td width="<?php if($width>=150 or 1==1){echo '60%';}else{echo '100%';}?>" <?php if($width>=150  or 1==1){}else{echo ' colspan="2"';}?> valign="top">

					<?php  ////  LOGO ?>
					<logo>
					<table border="1" width="100%" cellpadding="2" cellspacing="0" style="border-collapse:collapse;font-size:<?php echo $xfontsize; ?>px;">
						<tr>
							<?php if($doculogo==1 and file_exists($rutalogo.$logofile2) and ($width<150 or 1==1)){ ?>
							<td align="center" style="">
							<?php if($empr_website!=''){?>
							<a target="_blank"  href="https://<?php echo $empr_website; ?>">
							<?php }else{ ?>
								<?php if($xclaveacc!=''){?>
								<a href="<?php echo 'https://'.$cfg_empr.'.vcrxol.com/?prnt=1&clave='.$xclaveacc;?>">
								<?php }else{ ?>
								<a href="<?php echo 'https://'.$cfg_empr.'.vcrxol.com/?prnt=1&docu='.$docu.'&idnum='.$idnum.'&formato='.$formato;?>">
								<?php } ?>
							<?php } ?>
							<img src="<?php 
                          $xav = msql_result($res_tra1,0,'ptov'); 
                          if ($cfg_empr == 'jzsa')
                              {
                                if ($xav == '001102')
                                    $logofile2 = 'logojzsa102.png';
                                else
                                    $logofile2 = 'logojzsa101.png';
                                  
                              }
                                      
                          if ($cfg_empr == 'mmlm')
                             {
                               if ($xav == '001101')
                                  $logofile2 = "logommlm4.png";
                               else
                                  $logofile2 = "logommlm3.png";
                             }
                          echo 'https://vcrxol.com/_logo/'.$logofile2;
                          
                   ?> " alt=""
                   
									 title="<?php echo $empr_website; ?>" style="max-width:100%; max-height:<?php echo $hlogo;?>mm;">		
							</a>
							</td>
                <?php {
                  $xsrc='https://vcrxol.com/_logo/'.$logofile2;
                  $xsrc_fgc=file_get_contents($xsrc);                                                                                        
                  $img_xy=getimagesizefromstring($xsrc_fgc);
                  $img_w=$img_xy[0];
                  $img_h=$img_xy[1];
                  $img_rel=$img_w/$img_h;
                  $cel_w=$pdf_ancho*.6;                                                                                        
                  $cel_h=25;
                  if($img_w<$cel_w){$img_w=$cel_w;}
                  if($img_h<$cel_h){$img_h=$cel_h;}
                  if($img_h>=$cel_h){$img_h=$cel_h; $img_w=$img_rel*$img_h;}
                  if($img_w>=$cel_w){$img_w=$cel_w; $img_h=$img_rel/$img_w;}

                  if(mb_stristr($img_xy['mime'],'jpeg'))                                                                                                  
                  {$docu_pdf->Image($xsrc,(($cel_w-$img_w)/2)+10,$docu_pdf->getY()+(($cel_h-$img_h)/2)+3,$img_w,$img_h,'JPG');}
                  if(mb_stristr($img_xy['mime'],'png'))                                                                                                  
                  {$docu_pdf->Image($xsrc,(($cel_w-$img_w)/2)+10,$docu_pdf->getY()+(($cel_h-$img_h)/2)+3,$img_w,$img_h,'PNG');}

                  $docu_pdf->setY($posY1);                                                                                                  
                  $docu_pdf->Cell($pdf_ancho*.6,30,'','LRTB',0,'C',false);
                  $docu_pdf->ln();                                                                                                  
                  $posY1=$docu_pdf->getY()+1;
                  } ?>
							<?php } ?>
                
						</tr>
					</table>
					</logo>
					<div style="font-size:25%;"><br></div>

					<?php ///// BLOQUE L1 ?>
					<?php if($margin_top==0){ ?>
					<?php //{ ?>
          <emite>
					<?php $enti_codigo=@msql_result($res_emis,0,'enti_codigo'); ?>
					<?php $enti_razsoc=@msql_result($res_emis,0,'enti_razsoc'); ?>
					<?php $enti_nomcom=@msql_result($res_emis,0,'enti_nomcom'); ?>
					<?php $telefono=@msql_result($res_emis,0,'enti_telefono'); ?>
						<?php $coesp=@msql_result($res_emis,0,'enti_coesp'); ?>
						<?php $coesn=@msql_result($res_emis,0,'enti_coesn'); ?>
						<?php $rise=@msql_result($res_emis,0,'enti_rise'); ?>
						<?php $rime=@msql_result($res_emis,0,'enti_rime'); ?>
            <?php $rimpe=@msql_result($res_emis,0,'enti_rimpe'); ?>
            <?php $obcon=@msql_result($res_emis,0,'enti_obcon'); ?>
						<?php $agret=@msql_result($res_emis,0,'enti_agret'); ?>
						<?php $agren=@msql_result($res_emis,0,'enti_agren'); ?>
						<?php //$agret=0; ?>
						<?php //$agren=0; ?>

             <?php
               if($tabla=='susa')
               {
                  $enti_codigo=$cfg_ruc;
                  $enti_razsoc=$cfg_descri;
               }
             ?>
					<table border="1" width="100%" cellpadding="2" cellspacing="0"
                 style="border-collapse:collapse; border-radius:10px;font-size:
                        <?php echo $xfontsize; ?>px;<?php echo $xfontfamily;?>;
                        <?php if($docu=='DA16' or $docu=='PLA1' or $docu=='ATV1'){echo 'display:none;';}?>
                        <?php if($cfg_empr=='gnya' and $tabla=='vtas'){echo 'display:none;';}?>
                        ">
						<tr style="border:solid 1px; font-weight:bolder; background:<?php echo $gris1;?>;">
							<td align="center" colspan=3 style="letter-spacing:10px" ><?php echo $lblruc1; ?></td>
						</tr>
						<tr valign="top">
							<td width="25%">RUC/C.I.</td>
							<td width="75%"><?php echo $enti_codigo; if($enti_codigo==''){echo '*** '.$enti_orig.' ***';} ?></td>
						</tr>
						<tr valign="top" style="font-weight:bolder;">
							<td>RAZ. SOCIAL</td>
							<td><?php echo @msql_result($res_emis,0,'enti_razsoc');?></td>
						</tr>
						<?php if(trim(@msql_result($res_emis,0,'enti_razsoc'))!=trim(@msql_result($res_emis,0,'enti_nomcom')) and msql_result($res_emis,0,'enti_nomcom')!=""){?>
						<tr valign="top">
							<td>NOM.COMERCIAL</td>
							<td><?php echo msql_result($res_emis,0,'enti_nomcom');?></td>
						</tr>
						<?php } ?>

						<?php if(@mb_stristr('comp.prov',$tabla)  and ($coesp==1 or $rise==12 or $rime==12 or $agret==1)){?>
                <tr valign="top">
                  <td>CONTRIB. </td>
                  <td>
                    <?php if($coesp==1){echo 'ESPECIAL'.' ('.$coesn.')';};?>
                    <?php if($rise==12){echo 'RISE';}?>
                    <?php if($rime==12){echo 'MICRO EMPRESA';}?>
                    <?php if($rime==12 and $agret==1){echo '<br>';} ?>
                    <?php if($agret==1){echo 'AGENTE DE RETENCION'.' ('.$agren.')';};?>
                  </td>
                </tr>
               <?php }else{ ?>
                <?php if(!empty($coesp) or !empty($coesn)){?>
                <tr valign="top">
                  <td>CONTRIBUYENTE </td>
                  <td><?php if($coesp==1){echo 'ESPECIAL';}else{echo '';}; echo ' ('.$coesn.')';?></td>
                </tr>
                <?php } ?>

                <?php if(!empty($agret) or !empty($agren)){?>
                <tr valign="top">
                  <td>CONTRIBUYENTE</td>
                  <td>
                     <?php 
                       if($agret==1){echo 'AGENTE DE RETENCION '.'<br> RESOLUCION No NACDNCRASC20-00000001 ';} 
                     ?>
                     <?php //if($agret==1 and $cfg_empr=='cpc1'){echo ' RESOLUCION No NACDNCRASC20-00000001 ';};?>
                  </td>
                </tr>
                <?php } ?>

                <?php if(!empty($rise) and 1==2){?>
                <tr valign="top">
                  <td>CONTRIBUYENTE</td>
                  <td><?php if($rise==12){echo 'RISE';}else{echo '';};?></td>
                </tr>
                <?php } ?>
                  
                <?php if(!empty($rime) and 1==2){?>
                <tr valign="top">
                  <td>CONTRIBUYENTE</td>
                  <td><?php if($rime==12){echo 'REGIMEN MICROEMPRESA';}else{echo '';};?></td>
                </tr>
                <?php } ?>
            
                <?php if(!empty($rimpe)){?>
                <tr valign="top">
                  <td>REGIMEN</td>
                  <td>
                      <?php  $titrimpe = '';
                          if($rimpe> 0)
                             {
                                if($rimpe == 1)
                                   $titrimpe = 'RIMPE EMPRENDEDOR';
                                if($rimpe == 2)
                                   $titrimpe = 'NEGOCIO POPULAR';
                                if($rimpe == 3)
                                   $titrimpe = 'GENERAL';
            
//                           if($rimpe==1)
//                             {
//                                 if (substr($entiruc,2,1) == '9')
//                                     $titrimpe = 'REGIMEN RIMPE';
//                                 else
//                                     $titrimpe = 'RIMPE EMPRENDEDOR';
//                              }
//                           else
//                             {
//                                if($rimpe==2)
//                                  $titrimpe = 'RIMPE NEGOCIO POPULAR';
//                             }
                            }
                          echo $titrimpe ;

                      ?>
                  </td>
                </tr>
                <?php } 
            // XMA
            ?>
                <tr>
<?php                     if($obcon==1){ ?>
   							  <td>CONTRIBUYENTE</td>
		  					  <td>OBLIGADO A CONTABILIDAD </td>
                                        <?php } ?>  
						    </tr>

            <?php } ?>
            
						<?php if(!@mb_stristr('caja.bcos.inve.prod.susa.cont.tfin',$tabla)){?>
						<tr valign="top">
							<td>MATRIZ</td>
							<td><?php echo @msql_result($res_emis,0,'enti_matriz');?></td>
						</tr>
						<tr valign="top">
							<td>TELEFONO </td>
							<td><?php echo $telefono;?></td>
						</tr>
            <?php $xemail= strtolower(@msql_result($res_emis,0,'enti_email')); ?>
            <?php $xemail=alltrim(str_replace(';','; ',$xemail)); ?>
						<tr valign="top">
							<td>E-MAIL</td>
							<td><?php echo $xemail; ?></td>
						</tr>
						<?php } ?>
						
					</table>
					<div style="font-size:25%;"><br></div>
          </emite>
          <?php
             $docu_txt.=str_pad($lblruc1.' ',$coltxt,$carbot,STR_PAD_BOTH).$eol;
             $docu_txt.='RUC     : '.$enti_codigo.$eol;
             $docu_txt.='RAZ.SOC.: '.@msql_result($res_emis,0,'enti_razsoc').$eol;
             if($enti_razsoc!=$enti_nomcom and $enti_nomcom!='')
             {$docu_txt.='NOM.COM.: '.@msql_result($res_emis,0,'enti_nomcom').$eol;}
           ?>                                     
                                     
						<?php if(@mb_stristr('comp.prov',$tabla)  and ($coesp==1 or $rise==12 or $rime==12 or $agret==1)){?>
               <?php }else{ ?>
                <?php if(!empty($coesp) or !empty($coesn)){?>
             <?php $docu_txt.='CONTRIBUYENTE : ESPECIAL '.$eol; ?>
                <?php } ?>

                <?php if(!empty($agret) or !empty($agren)){?>
             <?php $docu_txt.='CONTRIBUYENTE : AGENTE DE RETENCION '.$eol; ?>
                <?php } ?>

                <?php if(!empty($rise)){?>
             <?php //$docu_txt.='CONTRIBUYENTE : RISE '.$eol; ?>
                <?php } ?>
                  
                <?php if(!empty($rime)){?>
             <?php //$docu_txt.='CONTRIBUYENTE : REGIMEN MICROEMPRESA '.$eol; ?>
                <?php } ?>
            <?php } ?>
                                     
                                     
          <?php                                     
             $docu_txt.='MATRIZ  : '.trim(@msql_result($res_emis,0,'enti_matriz')).$eol;
             $docu_txt.='TELEF.  : '.@msql_result($res_emis,0,'enti_telefono').$eol;
             $docu_txt.='E-MAIL  : '.trim(@msql_result($res_emis,0,'enti_email')).$eol;
             //$docu_txt.=$eol;
          ?>
            
            <?php {
    //           $posY1=48;
              $docu_pdf->SetFont($ffamilyPDF,'B',$fsizePDF-2);
              $docu_pdf->SetY($posY1);
              $docu_pdf->Cell($pdf_ancho*.6,5,$lblruc1,'LRTB',0,'C',true);
              $docu_pdf->ln();
              $docu_pdf->SetFont($ffamilyPDF,'',$fsizePDF-3);
              $docu_pdf->Cell($pdf_ancho*.2,5,'RUC :','LRT',0,'L',false);
              $docu_pdf->MultiCell($pdf_ancho*.4,5,$enti_codigo,'LRT','L',false);

              $docu_pdf->Cell($pdf_ancho*.2,5,'RAZ. SOCIAL :','LRT',0,'L',false);
              $docu_pdf->MultiCell($pdf_ancho*.4,5,@msql_result($res_emis,0,'enti_razsoc'),'LRT','L',false);

              if(trim(@msql_result($res_emis,0,'enti_razsoc'))!=trim(@msql_result($res_emis,0,'enti_nomcom')) and msql_result($res_emis,0,'enti_nomcom')!="")
              {
                $docu_pdf->Cell($pdf_ancho*.2,5,'NOM. COMERCIAL :','LRT',0,'L',false);
                $docu_pdf->MultiCell($pdf_ancho*.4,5,@msql_result($res_emis,0,'enti_nomcom'),'LRT','L',false);
              }  
             
           ?>                                     
                                     
						<?php if(@mb_stristr('comp.prov',$tabla)  and ($coesp==1 or $rise==12 or $rime==12 or $agret==1)){?>
               <?php }else{ ?>
                <?php if(!empty($coesp) or !empty($coesn)){?>
                <?php
                $docu_pdf->Cell($pdf_ancho*.2,5,'CONTRIBUYENTE :','LRT',0,'L',false);
                $docu_pdf->MultiCell($pdf_ancho*.4,5,'ESPECIAL','LRT','L',false);
                ?>
                <?php } ?>

                <?php if(!empty($agret) or !empty($agren)){?>
                <?php
                $docu_pdf->Cell($pdf_ancho*.2,5,'CONTRIBUYENTE :','LRT',0,'L',false);
                $docu_pdf->MultiCell($pdf_ancho*.4,5,'AGENTE DE RETENCION','LRT','L',false);
                ?>
                <?php } ?>

                <?php if(!empty($rise)){?>
                <?php
//                 $docu_pdf->Cell($pdf_ancho*.2,5,'CONTRIBUYENTE :','LRT',0,'L',false);
//                 $docu_pdf->MultiCell($pdf_ancho*.4,5,'RISE','LRT','L',false);
                ?>
                <?php } ?>
                  
                <?php if(!empty($rime)){?>
                <?php
//                 $docu_pdf->Cell($pdf_ancho*.2,5,'CONTRIBUYENTE :','LRT',0,'L',false);
//                 $docu_pdf->MultiCell($pdf_ancho*.4,5,'REGIMEN MICROEMPRESA','LRT','L',false);
                ?>
                <?php } ?>
                              
                <?php if(!empty($rimpe)){?>
                <?php
                $docu_pdf->Cell($pdf_ancho*.2,5,'CONTRIBUYENTE :','LRT',0,'L',false);
                $docu_pdf->MultiCell($pdf_ancho*.4,5,'REGIMEN RIMPE','LRT','L',false);
                ?>
                <?php } ?>
                              
            <?php } ?>
                                     
                                     
          <?php                                     

              $docu_pdf->Cell($pdf_ancho*.2,5,'CONTRIBUYENTE:','LRT',0,'L',false);
              if ($obcon==1)
                 $docu_pdf->MultiCell($pdf_ancho*.4,5,'OBLIGADO A CONTABILIDAD','LRT','L',false);
              else
                 $docu_pdf->MultiCell($pdf_ancho*.4,5,'NO OBLIGADO A CONTABILIDAD','LRT','L',false);

              $docu_pdf->Cell($pdf_ancho*.2,5,'MATRIZ :','LRT',0,'L',false);
              $docu_pdf->MultiCell($pdf_ancho*.4,5,utf8_decode(@msql_result($res_emis,0,'enti_matriz')),'LRT','L',false);
              $docu_pdf->Cell($pdf_ancho*.2,5,'TELEFONO :','LRT',0,'L',false);
              $docu_pdf->MultiCell($pdf_ancho*.4,5,@msql_result($res_emis,0,'enti_telefono'),'LRT','L',false);
              $docu_pdf->Cell($pdf_ancho*.2,5,'E-MAIL :','LRT',0,'L',false);
              $docu_pdf->SetFontSize($fsizePDF-3);
              $docu_pdf->MultiCell($pdf_ancho*.4,5,strtolower(@msql_result($res_emis,0,'enti_email')),'LRT','L',false);
              $docu_pdf->Cell($pdf_ancho*.2,1,'','T',0,'',false);
              $docu_pdf->MultiCell($pdf_ancho*.4,1,'','T','',false);

              $posY1=$docu_pdf->getY();

              } ?>

					<?php } ?>

					<?php ///// BLOQUE L2 ?>
					<?php
// 					if($guiaremi==0 and $formato!=2)
					if(!mb_stristr('guia.cont.nomi',$tabla))
					{
					?>
					<recibe>
					<table border="1" width="100%" cellpadding="2" cellspacing="0" 
								 style="border-collapse:collapse;font-size:<?php echo $xfontsize; ?>px;<?php echo $xfontfamily;?>;
                        <?php if(mb_stristr('DA16.EB13.IB13.EB17.IB17',$docu)){echo 'display:none;';}?>"
								 >
						<tr style="border:solid 1px; font-weight:bolder; background: <?php echo $gris1;?>;">
							<td align="center" colspan=2 style="letter-spacing:10px" ><?php echo $lblruc2; ?></td>
						</tr>
						<?php $enti_codigo=@msql_result($res_adqu,0,'enti_codigo'); ?>
						<?php $enti_descri=@msql_result($res_adqu,0,'enti_descri'); ?>
						<?php $enti_razsoc=@msql_result($res_adqu,0,'enti_razsoc'); ?>
						<?php $enti_nomcom=@msql_result($res_adqu,0,'enti_nomcom'); ?>
            
            <?php if(empty($enti_razsoc)){$enti_razsoc=$enti_descri;}?>
						<?php $tipoId=@msql_result($res_adqu,0,'enti_tipoid'); ?>
						<?php $coesp=@msql_result($res_adqu,0,'enti_coesp'); ?>
						<?php $coesn=@msql_result($res_adqu,0,'enti_coesn'); ?>
						<?php $rise=@msql_result($res_adqu,0,'enti_rise'); ?>
						<?php $rime=@msql_result($res_adqu,0,'enti_rime'); ?>
						<?php $agret=@msql_result($res_adqu,0,'enti_agret'); ?>
						<?php $agren=@msql_result($res_adqu,0,'enti_agren'); ?>
            <?php
              $tipoIdComp='04';
              {
                if($tipoId=='R'){$tipoIdComp='04';}
                if($tipoId=='C'){$tipoIdComp='05';}
                if($tipoId=='P'){$tipoIdComp='06';}
                if($tipoId=='F'){$tipoIdComp='07';}
                if($tipoId=='E'){$tipoIdComp='08';}
                if($tipoId=='V'){$tipoIdComp='09';}
              }
              if(mb_stristr('06',$tipoIdComp)){$enti_codigo=msql_result($res_adqu,0,'enti_pasaporte');}  
              if(mb_stristr('08',$tipoIdComp)){$enti_codigo=msql_result($res_adqu,0,'enti_idexterior');}
//               if($enti_razsoc==''){reg_cedruc($enti_codigo);}
						  if(@msql_result($res_adqu,0,'enti_tipoid')=='P'){$enti_codigo=@msql_result($res_adqu,0,'enti_pasaporte');};
            ?>
            
            <?php if(empty($enti_razsoc)){get_ruc0($enti_codigo);}?>
            <?php if(empty($enti_razsoc) and substr($enti_codigo,0,2)!='99'){?>
						<tr valign="top" style="font-weight:bolder;">
							<td>USUARIO </td>
							<td><?php echo r_fiel('user',msql_result($res_tra1,0,'iuser'));?></td>
						</tr>
            <?php } ?>
						<tr valign="top">
							<td width="25%">RUC/C.I.</td>
							<td width="75%"><?php echo $enti_codigo;?></td>
						</tr>
						<tr valign="top" style="font-weight:bolder;">
							<td>RAZ. SOCIAL</td>
							<td><?php echo $enti_razsoc;?></td>
						</tr>
            
            
						<?php if(trim(@msql_result($res_adqu,0,'enti_razsoc'))!=trim(@msql_result($res_adqu,0,'enti_nomcom')) and @msql_result($res_adqu,0,'enti_nomcom')!=""){?>
						<tr valign="top">
							<td>NOM. COMERCIAL</td>
							<td><?php echo msql_result($res_adqu,0,'enti_nomcom');?></td>
						</tr>
						<?php } ?>

            
						<?php if(substr($enti_codigo,0,10)!=substr($cfg_ruc,0,10)){?>
            
            <?php if(!empty($coesp) or !empty($coesn)){?>
						<tr valign="top">
							<td>CONT.ESPECIAL</td>
							<td><?php if($coesp==1){echo 'SI';}else{echo 'NO';}; echo ' ('.$coesn.')';?></td>
						</tr>
            <?php } ?>
            
            
						<?php $matriz=@msql_result($res_adqu,0,'enti_matriz');	?>
						<?php $direccion=@msql_result($res_adqu,0,'enti_direccion');	?>
						<?php $ciudad=@msql_result($res_adqu,0,'enti_ciudad');	?>
						<?php $calle1=@msql_result($res_adqu,0,'enti_calle1');	?>
						<?php $calle2=@msql_result($res_adqu,0,'enti_calle2');	?>
						<?php $calle3=@msql_result($res_adqu,0,'enti_calle3');	?>
						<?php $callen=@msql_result($res_adqu,0,'enti_callen');	?>
						<?php $parroq=@msql_result($res_adqu,0,'enti_parroq');	?>
            <?php //$parroq=r_fiel('enti',$enti_codigo,'enti_parroq'); ?>
						<?php $adqu_email1=@msql_result($res_adqu,0,'enti_email');	?>
						<?php $adqu_email2=@msql_result($res_adqu,0,'enti_emailce');	?>
						<?php $adqu_wsapp=@msql_result($res_adqu,0,'enti_wsapp');	?>
						<?php $matriz=alltrim(str_replace('/',' /',$matriz));	?>
						<?php $parroq=alltrim(str_replace('/',' /',$parroq));	?>

            
					<?php if(@mb_stristr('retp',$tabla) and ($coesp==1 or $rise==12 or $rime==12 or $agret==1)){?>
                <tr valign="top">
                  <td>CONTRIB. </td>
                  <td>
                    <?php if($coesp==1){echo 'ESPECIAL'.' ('.$coesn.')';};?>
                    <?php if($rise==12){echo 'RISE';}?>
                    <?php if($rime==12){echo ' REGIMEN MICRO EMPRESA';}?>
                    <?php if($rime==12 and $agret==1){echo '<br>';} ?>
                    <?php if($agret==1){echo ' AGENTE DE RETENCION';}?>
                  </td>
                </tr>
               <?php  } ?>
            
            
						<?php //if(!mb_stristr('caja.bcos.inve.prod.susa.tfin',$tabla)){?>
						<?php if(mb_stristr('vtas.clie.comp.prov.prod.inve',$tabla)){?>
						
            <?php
              $href='';              
              if($cdisplay==1 and $destino=='screen' and (mb_stristr('vtas.clie.prod.',$tabla) or $docu=='EB10' ))              
              {$href='?elbl=1&codigo='.$enti_codigo.'&tipo=" target="_blank"';}
            ?>          
            
            <?php if($matriz!=''){?>
						<tr valign="top">
							<td>MATRIZ</td>
							<td>
            <?php if(!empty($href)){echo '<a href="'.$href.'">';} ?>
                <?php $parroq=''; ?>                        
                <?php echo $matriz.'<br>'.$parroq;?>
            <?php if(!empty($href)){echo '</a>';} ?>
              </td>
						</tr>
						<?php } ?>
            
						<?php if($ciudad!=''){?>
						<tr valign="top">
							<td>CIUDAD</td>
							<td>
              <?php echo $ciudad;?>
              </td>
						</tr>
						<?php } ?>
						
						<?php //if($matriz=='' and strlen(trim($direccion))>5){?>
						<?php if(strlen(trim($direccion))>5){?>
						<tr valign="top">
							<td>DIRECCION</td>
							<td><?php echo $direccion;?></td>
						</tr>
						<?php } ?>
						
                              <?php $direccion2=$calle1.'('.trim($callen).') /'.$calle2; ?>
						<?php if(strlen(trim($direccion2))>5){?>
						<tr valign="top">
							<td>DIRECCION</td>
							<td>
              <?php echo $calle1.'('.$callen.') /'.$calle2;?>
							<?php if($calle3!=''){echo '<br>Ref: '.$calle3;}?>
              </td>
						</tr>
						<?php } ?>

                              <?php
                               $xtelefono=@msql_result($res_adqu,0,'enti_telefono');
                               $xwsapp=@msql_result($res_adqu,0,'enti_wsapp');
                              $xtelefono=trim($xtelefono);
                              $xwsapp=trim($xwsapp);
//                  https://orel.vcrxol.com/print1.php?clave=1807202291090818526700110011010000008376507706116
                               $xurlclave='https://'.$cfg_empr.'.vcrxol.com/print1.php?clave='.$claveacc;
                               $xsend1='https://api.whatsapp.com/send/?phone=593'.substr($xtelefono,-10).'&text='.$xurlclave.'&type=phone_number&app_absent=0';
                               $xsend2='https://api.whatsapp.com/send/?phone=593'.substr($xwsapp,-10).'&text='.$xurlclave.'&type=phone_number&app_absent=0';
// https://api.whatsapp.com/send/?phone=5930996030568&text=prueba&type=123456&app_absent=1                 
                              ?>
						
						<tr valign="top">
							<td>TELEFONO </td>
							<td>
                                        <a href="<?php echo $xsend1;?>" target="_blank">
                                        <?php echo $xtelefono;?>
                                        </a>
                                   </td>
						</tr>
                              
                              <?php if(!empty($adqu_wsapp)){  ?>
                              <?php $href=''; ?>
                              <?php if(!empty($user_codigo))
                              {
// https://api.whatsapp.com/send/?phone=5930996030903&text=urlencodedtext                              
                                   $href='http://wa.me/593'.$adqu_wsapp.'/';
                                   $href.='?text=https://'.$cfg_empr.'.vcrxol.com/print1.php?clave='.$xclaveacc.'';
                                   $href.='&app_absent=1';
                              } ?>
						<tr valign="top">
							<td>WhatsApp</td>
                                   <td><a href="<?php echo $href; ?>" target="_blank"><?php echo $adqu_wsapp; ?></a></td>
						</tr>
                              <?php } ?>

                              							<?php
							$adqu_email2=str_replace($adqu_email1,'',$adqu_email2);
							$adqu_email=trim($adqu_email1).';'.trim($adqu_email2);
							  $adqu_email=str_replace(';','; ',$adqu_email); 
							  $adqu_email=str_replace(',','; ',$adqu_email); 
							  $adqu_email=str_replace(';;',';',$adqu_email); 
                                    ?>

                              <?php $href=''; ?>
                              <?php if(!empty($user_codigo)){$href='mailto:'.str_replace(';','<'.$enti_razsoc.'>;',strtolower($adqu_email)).'?subject='.$docu_descri.'-'.msql_result($res_tra1,0,'ptonumero') ;} ?>
                              
						<tr valign="top">
							<td>E-MAIL</td>
                                   <td><a href="<?php echo $href; ?>" target="_blank"><?php echo strtolower($adqu_email);?></a></td>
                                   
                                   
                                   
						</tr>
						<?php } ?>
						<?php } ?>
					</table>			
          <?php
             $docu_txt.=str_pad($lblruc2.' ',$coltxt,$carbot,STR_PAD_BOTH).$eol;
             $docu_txt.='RUC     : '.$enti_codigo.$eol;
             $docu_txt.='RAZ.SOC.: '.@msql_result($res_adqu,0,'enti_razsoc').$eol;
             if($enti_razsoc!=$enti_nomcom and $enti_nomcom!='')
             {$docu_txt.='NOM.COM.: '.@msql_result($res_adqu,0,'enti_nomcom').$eol;}
             $docu_txt.='MATRIZ  : '.trim(@msql_result($res_adqu,0,'enti_matriz')).$eol;
             $docu_txt.='TELEF.  : '.@msql_result($res_adqu,0,'enti_telefono').$eol;
             $docu_txt.='E-MAIL  : '.$adqu_email.$eol;
//             $docu_txt.=$eol;
          ?>
        <?php 
//           $posY=84;
					$adqu_email=str_replace('; ',';',$adqu_email);
          $docu_pdf->SetFont($ffamilyPDF,'B',$fsizePDF-2);
          $docu_pdf->SetY($posY1);
          $docu_pdf->Cell($pdf_ancho*.6,5,$lblruc2,'LRTB',0,'C',true);
          $docu_pdf->SetFont($ffamilyPDF,'',$fsizePDF-3);
          $docu_pdf->ln();

          $docu_pdf->Cell($pdf_ancho*.2,5,'RUC :','LRT',0,'L',false);
          $docu_pdf->MultiCell($pdf_ancho*.4,5,$enti_codigo,'LRT','L',false);
          $docu_pdf->Cell($pdf_ancho*.2,5,'RAZ. SOCIAL :','LRT',0,'L',false);
          $docu_pdf->MultiCell($pdf_ancho*.4,5,@msql_result($res_adqu,0,'enti_razsoc'),'LRT','L',false);
          if(trim(@msql_result($res_adqu,0,'enti_razsoc'))!=trim(@msql_result($res_adqu,0,'enti_nomcom')) and @msql_result($res_adqu,0,'enti_nomcom')!="")
          {
          $docu_pdf->Cell($pdf_ancho*.2,5,'NOM. COMERCIAL :','LRT',0,'L',false);
          $docu_pdf->MultiCell($pdf_ancho*.4,5,@msql_result($res_adqu,0,'enti_nomcom'),'LRT','L',false);
          }
          $docu_pdf->Cell($pdf_ancho*.2,5,'MATRIZ :','LRT',0,'L',false);
          $docu_pdf->MultiCell($pdf_ancho*.4,5,utf8_decode(@msql_result($res_adqu,0,'enti_matriz')),'LRT','L',false);
          $docu_pdf->Cell($pdf_ancho*.2,5,'TELEFONO :','LRT',0,'L',false);
          $docu_pdf->MultiCell($pdf_ancho*.4,5,@msql_result($res_adqu,0,'enti_telefono'),'LRT','L',false);
          $docu_pdf->Cell($pdf_ancho*.2,5,'E-MAIL :','LRT',0,'L',false);
          $docu_pdf->SetFontSize($fsizePDF-3);
          $docu_pdf->MultiCell($pdf_ancho*.4,5,strtolower($adqu_email),'LRT','L',false);
          $docu_pdf->Cell($pdf_ancho*.2,1,'','T',0,'',false);
          $docu_pdf->MultiCell($pdf_ancho*.4,1,'','T','',false);
          $posY1=$docu_pdf->getY();
                                
        ?>
            
					</recibe>	
						
					<?php } ?>

					<?php ///// BLOQUE L3 ?>
					<?php{?>
					<div style="font-size:25%;"><br></div>
					<table border="1" width="100%" cellpadding="2" cellspacing="0" 
                 style="border-collapse:collapse;font-size:<?php echo $xfontsize; ?>px;<?php echo $xfontfamily;?>">
						<tr style="border:solid 1px; font-weight:bolder; background: <?php echo $gris1;?>;">
							<td align="center" colspan=2 ><?php echo 'INFORMACION ADICIONAL'; ?></td>
						</tr>
						<tr style="display:none;">
							<td width="30%"></td>
							<td></td>
						</tr>

						<?php if(mb_stristr('cont', $tabla)){?>
							<tr>
								<td>ENTIDAD</td>
								<td><?php echo @msql_result($res_tra1,0,'enti_descri');?></td>
							</tr>
						<?php } ?>

						<?php if(mb_stristr('vtas', $tabla) and $cfg_empr=='xxxvfjw'){?>
							<tr>
								<td>CONTRIBUYENTE</td>
								<td>REGIMEN MICRO-EMPRESA</td>
							</tr>
						<?php } ?>


						<?php if(mb_stristr('carr', $tabla)){?>
                  <?php $toenti=@msql_result($res_tra1,0,'toenti'); ?>
							<tr>
								<td>FACTURAR</td>
								<td><?php echo $toenti;?></td>
							</tr>
						<?php } ?>


						<tr valign="top" style=<?php if($xconcepto==""){echo 'display:none;';}?>>
							<td>CONCEPTO</td>
							<td><?php echo $xconcepto;?></td>
						</tr>

						<tr valign="top" style=<?php if($xcntn==""){echo 'display:none;';}?>>
							<td>CONTENEDOR</td>
							<td><?php echo $xcntn ;?></td>
						</tr>

						<?php if(mb_stristr('comp.vtas', $tabla)){ ?>
                              <?php $enti_xcp=@msql_result($res_tra1,0,'enti_xcp'); ?>
                              <?php if($enti!=$enti_xcp and !empty($enti_xcp)){ ?>
							<tr>
								<td>TERCERO</td>
								<td><?php echo $enti_xcp.' - '.r_fiel('enti',$enti_xcp); ?></td>
							</tr>
						<?php } ?>
						<?php } ?>

            
						<?php if(mb_stristr('inve.tfin', $tabla)){?>
							<?php $bode=@msql_result($res_tra1,0,'bode') ;?>
							<?php $bode2=@msql_result($res_tra1,0,'bode2') ;?>
							<?php $numfac=@msql_result($res_tra1,0,'numfac') ;?>
						<?php } ?>
            
            
            <?php if($ximpor!="") {?>
						<tr style="font-weight:bolder;">
							<td align="center" colspan="3">IMPORTACION :<?php echo $ximpor;?></td>
<!-- 							<td align="center"><?php echo $ximpor;?></td> -->
						</tr>
            <?php } ?>

						<?php if(mb_stristr('EB10',$docu)){?>
							<tr>
								<td>FACTURA:</td>
								<td><?php echo $numfac; ?></td>
							</tr>
						<?php }?>
						<?php if(mb_stristr('EB19',$docu)){?>
							<tr>
								<td>ORDEN:</td>
								<td><?php echo $numfac; ?></td>
							</tr>
						<?php }?>
            
						<?php if(mb_stristr('FC10',$docu)){?>
            <?php $xidinve=get_idinve($docu,$idnum); ?>
            <?php $xebodega=r_fiel('inve1',$xidinve,'numero'); ?>
               <?php $efectivo=@msql_result($res_tra1,0,'efectivo'); ?>
               <?php $credito=@msql_result($res_tra1,0,'credito'); ?>
               <?php $pcnt=@msql_result($res_tra1,0,'pcnt'); ?>
                              
						<?php if($xebodega!=''){?>
							<tr style="text-transform:uppercase">
								<td>EGRE.BODEGA:</td>
								<td><?php echo $xebodega; ?></td>
							</tr>
						<?php }?>
						<?php if(!empty($pcnt)){?>
                              <?php 
                                                   
                              ?>
							<tr style="text-transform:uppercase">
								<td>PACIENTE : </td>
								<td><?php echo r_fiel('enti',$pcnt,'nom1'); ?></td>
							</tr>
						<?php }?>
						<?php if($efectivo>0){?>
							<tr style="text-transform:uppercase">
								<td>EFECTIVO:</td>
								<td><?php echo number_format($efectivo,2); ?></td>
							</tr>
						<?php }?>
						<?php if($credito>0){?>
							<tr style="text-transform:uppercase">
								<td>CREDITO:</td>
								<td><?php echo number_format($credito,2); ?></td>
							</tr>
						<?php }?>
  					<?php }?>
            
            
            
            <?php if($docu=='FP16'){?>
						<tr>
							<td>SEGURO</td>
							<td align="right"><?php echo number_format($xseguro1,2);?></td>
						</tr>
						<tr>
							<td>FLETE</td>
							<td align="right"><?php echo number_format($xflete1,2);?></td>
						</tr>
            <?php } ?>

            
						<?php if(@mb_stristr('DA16.',$docu)){?>
             <tr>
                  <td valign="top">
                  <table border="1" width="100%" cellpadding="2" cellspacing="0" 
                 style="border-collapse:collapse;font-size:<?php echo $xfontsize; ?>px;<?php echo $xfontfamily;?>">
            <?php if($xcostoe1!=0){?>
            <tr align="right" style="font-weight:;">
							<td>COSTO EXT:</td>
							<td><?php echo number_format($xcostoe1,2);?></td>
						</tr>
            <?php } ?>
						<tr align="right" style="font-weight:;">
							<td>FOB:</td>
							<td><?php echo number_format($xfob1,2);?></td>
							<td><?php echo $xcostoe1dd ;?></td>
						</tr>
						<tr align="right" style="font-weight:;">
							<td>SEGURO:</td>
							<td><?php echo number_format($xseguro1,2);?></td>
							<td><?php echo $xseguro1dd;?></td>
						</tr>
						<tr align="right" style="font-weight:;">
							<td>FLETE:</td>
							<td><?php echo number_format($xflete1,2);?></td>
							<td><?php echo $xflete1dd;?></td>
						</tr>
						<tr align="right" style="font-weight:bolder;<?php if($xcif1==0){echo 'display:none;';} ?>">
							<td>CIF:</td>
							<td><?php echo number_format($xcif1,2);?></td>
						</tr>
                  </table>
                  </td>
                  <td valign="top">
                  <table border="1" width="100%" cellpadding="2" cellspacing="0" 
                 style="border-collapse:collapse;font-size:<?php echo $xfontsize; ?>px;<?php echo $xfontfamily;?>">
						<tr align="right" style="font-weight:;">
							<td>AD-VALOR:</td>
							<td><?php echo number_format($xadva,2);?></td>
						</tr>
						<tr align="right" style="font-weight:;">
							<td>ESPECIFICO:</td>
							<td><?php echo number_format($xespe,2);?></td>
						</tr>
						<tr align="right" style="font-weight:;">
							<td>DUMPING:</td>
							<td><?php echo number_format($xdump,2);?></td>
						</tr>
						<tr align="right" style="font-weight:;">
							<td>FODINFA:</td>
							<td><?php echo number_format($xfodi,2);?></td>
						</tr>
						<tr align="right" style="font-weight:;">
<!-- 							<td>IVA:</td> -->
<!-- 							<td><?php //echo number_format($xivai,2);?></td> -->
						</tr>
						<tr align="right" style="font-weight:;<?php if($xicei==0){echo 'display:none;';} ?>">
							<td>ICE:</td>
							<td><?php echo number_format($xicei,2);?></td>
						</tr>
                  </table>
                  </td>
                  <td valign="top">
                  <table border="1" width="100%" cellpadding="2" cellspacing="0" 
                 style="border-collapse:collapse;font-size:<?php echo $xfontsize; ?>px;<?php echo $xfontfamily;?>">
						<tr align="right" style="font-weight:;">
							<td>COSTO LOC:</td>
							<td><?php echo number_format($xcostol1,2);?></td>
							<td><?php echo $xcostol1dd;?></td>
						</tr>
                  </table>
                  </td>
             </tr>       
                              
            <?php $xtiva=abs($xtiva);?>
            <?php //$totalimpo=$xcostoe1+$xfob1+$xseguro1+$xflete1+$xcif1+$xadva+$xfodi+$xicei+$xcostol1;  ?>
            <?php $totalimpo=$xcostoe1+$xfob1+$xseguro1+$xflete1+$xcif1+$xadva+$xespe+$xdump+$xfodi+$xicei+$xcostol1;  ?>
						<?php } ?>
            
            
						<?php if(@mb_stristr('CH.DP', substr($docu,0,2))){?>
              <tr style=<?php if($xbenefic ==""){echo 'display:none;';}?>>
                <td>BENEFICIARIO</td>
                <td><?php echo $xbenefic;?></td>
              </tr>
						<?php } ?>
            
            <?php if($cfg_empr=='gnya' and @mb_stristr('FC',substr($docu,0,2))) { ?>
            <?php
              $sql_user='select * from user0 where user_cedula like "'.substr($enti_codigo,0,10).'%" order by user_codigo desc';
              $res_user=msql_query($sql_user,$link_vcrx);
              $user_enti=@msql_result($res_user,0,'user_codigo');
              $user_referidox=@msql_result($res_user,0,'user_referidox');
              $referxdesc=r_fiel('user',$user_referidox);                        
            ?>
						<tr style=<?php if($user_enti==""){echo 'display:none;';}?>>
							<td>CODIGO</td>
							<td><?php echo $user_enti;?></td>
						</tr>
						<tr style=<?php if($referxdesc==""){echo 'display:none;';}?>>
							<td>REFERIDO X</td>
							<td><?php echo $referxdesc;?></td>
						</tr>
            <?php } ?>

            <?php if($cfg_empr=='gmny' and mb_stristr('CA',substr($docu,0,2))) { ?>
						<tr style=<?php if($attn==""){echo 'display:none;';}?>>
							<td>ATENCION</td>
							<td><?php echo $attn;?></td>
						</tr>
            <?php } ?>

						<tr style=<?php if($xattn==""){echo 'display:none;';}?>>
							<td>ATENCION</td>
							<td><?php echo $xattndes;?></td>
						</tr>

            
          <?php
             $docu_txt.=str_pad('INFO ADICIONAL ',$coltxt,$carbot,STR_PAD_BOTH).$eol;
             //if($xconcepto!='')
             if(!empty($xconcepto))
             {$docu_txt.='CONCEPTO : '.$xconcepto.$eol;}
             //$docu_txt.=$eol;
          ?>
            
        <?php 
          $docu_pdf->SetFont($ffamilyPDF,'B',$fsizePDF-2);
          $docu_pdf->SetY($posY1);
          $docu_pdf->Cell($pdf_ancho*.6,5,'INFORMACION ADICIONAL','LRTB',0,'C',true);
          $docu_pdf->SetFont($ffamilyPDF,'',$fsizePDF-3);
          $docu_pdf->ln();
             
         ?>
            <?php if($xattn!=''){ ?>
            <?php
            $docu_pdf->Cell($pdf_ancho*.2,5,'ATENCION :','LRT',0,'L',false);
            $docu_pdf->MultiCell($pdf_ancho*.4,5,utf8_decode($xattndes),'LRT','L',false);
            $posY1=$docu_pdf->getY();
            ?>
            <?php}?>
            
            <?php if($xconcepto!=''){ ?>
            <?php
            $docu_pdf->Cell($pdf_ancho*.2,5,'CONCEPTO :','LRT',0,'L',false);
            $docu_pdf->MultiCell($pdf_ancho*.4,5,utf8_decode($xconcepto),'LRT','L',false);
            $posY1=$docu_pdf->getY();
            ?>
            <?php}?>
            
            <?php $drtr=@msql_result($res_tra1,0,'drtr'); ?>
            <?php $drtr_descri=r_fiel('enti',$drtr); ?>
            <?php if($drtr!=''){ ?>
            <?php
              $docu_pdf->Cell($pdf_ancho*.2,5,'DIRECTOR :','LRT',0,'L',false);
              $docu_pdf->MultiCell($pdf_ancho*.4,5,utf8_decode($drtr_descri),'LRT','L',false);
              $posY1=$docu_pdf->getY();
            ?>
            <?php}?>
            
            <?php
              $docu_pdf->Cell($pdf_ancho*.2,1,'','T',0,'',false);
              $docu_pdf->MultiCell($pdf_ancho*.4,1,'','T','',false);
              $posY1=$docu_pdf->getY();
            ?>
            
            
						<?php if(mb_stristr('comp', $tabla)){ ?>
						<?php $adicionales=@msql_result($res_tra1,0,'infoadic'); ?>
						<?php $adicionales=str_replace('[[','',$adicionales); ?>
						<?php $adicionales=str_replace(']]',' : ',$adicionales); ?>
						<?php $adicionales=str_replace('||','<br>',$adicionales); ?>
            
						<?php $adicionales=str_replace('{"','',$adicionales); ?>
						<?php $adicionales=str_replace('":"',' : ',$adicionales); ?>
						<?php $adicionales=str_replace('"}','<br>',$adicionales); ?>
						<tr style="display:none;">
							<td>ADICIONAL</td>
							<td><?php //echo $adicionales;?></td>
						</tr>
						<?php } ?>
            
						<?php 
						 if(mb_stristr('vtas.clie.comi.carr.comp', $tabla))
						 {
							 $adicionales=@msql_result($res_tra1,0,'infoadic'); 
							 $adicionales='<tr>'.$adicionales.'</tr>';
							 $adicionales=str_replace(',',', ',$adicionales); 
							 $adicionales=str_replace('  ',' ',$adicionales); 
							 $adicionales=str_replace('[[','<td>',$adicionales); 
							 $adicionales=str_replace(']]','</td><td>',$adicionales); 
							 $adicionales=str_replace('||','</td></tr><tr>',$adicionales); 
               
							 $adicionales=str_replace('{"','<td>',$adicionales); 
							 $adicionales=str_replace('":"','</td><td>',$adicionales); 
							 $adicionales=str_replace('"}','</td></tr><tr>',$adicionales); 
               
               
							 $adicionales=str_replace('|','| ',$adicionales); 
               
               $adicionales=str_replace('; ',';',$adicionales); 
               $adicionales=str_replace('; ',';',$adicionales); 
               $adicionales=str_replace('; ',';',$adicionales); 
               $adicionales=str_replace(';','; ',$adicionales); 
               
							 if(mb_stristr($adicionales,'<td>')) 
							 {echo $adicionales;}
						 } 
						?>

						<?php if(mb_stristr('comp.prov', $tabla)){?>
						<tr style="font-size:75%;<?php if($xsuco==0){echo 'display:none;';}?>" >
							<td>SUSTENT.COMP.</td>
							<td><?php echo msql_result($res_tra1,0,'suco_descri');?></td>
						</tr>
						<?php}?>

            <?php if(mb_stristr('clie.vtas', $tabla) and $cfg_empr=='dly1'){?>
            <?php $drtr=msql_result($res_tra1,0,'drtr'); ?>
            <?php $drtr_descri=r_fiel('enti',$drtr); ?>
						<tr style="font-size:100%;<?php if($drtr==''){echo 'display:none;';}?>" >
							<td>DIRECTOR</td>
							<td><?php echo $drtr.' /'.$drtr_descri; ?></td>
						</tr>
						<?php}?>

         </table>					
					<?php}?>

				<?php if($width>=150 or 1==1){?>					
				</td>
					
				<?php if($tirilla==1){ ?>
				</tr><tr>	
				<?php } ?>	

      
      
      
      
				<?php ///// COLUMNA DERECHA ?>
				<td width=40% valign="top">
				<?php }else{ ?>
				</tr>	
				<tr valign="top">
					<td width=50% valign="top">
				<?php } ?>
					
					<?php  //// CODEBAR ?>
					<table border="1" width="100%" cellpadding="2" cellspacing="0" 
                 style="border-collapse:collapse;font-size:<?php echo $xfontsize; ?>px;<?php echo $xfontfamily;?>">
						<tr>
							<?php if($doculogo==1 and file_exists($rutalogo.$logofile2) and ($width<150 or 1==1)){ ?>
							<td align="center" height="<?php echo $hlogo;?>mm" style="max-height:<?php echo $hlogo*2;?>mm">
							<?php if($destino=='mail' or 1==1){ ?>
								<?php if($xclaveacc!=""){?>
									<?php gen_bcod($xclaveacc);?>
                                   
                  <?php if($tiporuc=='N'){?>
<!-- 									<a href="<?php //echo 'https://'.$cfg_empr.'.vcrxol.com/print1.php?clave='.$xclaveacc;?>"> -->
                  <?php }else{ ?>
<!-- 									<a href="<?php //echo 'https://vcrxol.com/_cel/'.$subdce.$claveacc.'.pdf'; ?>"> -->
                  <?php } ?>
                                                 
<?php
$hrefpdf='https://vcrxol.com/_lib/down_celepdf.php?empr='.$cfg_empr.'&docu='.$docu.'&idnum='.$idnum; 
$hrefpdf1=$hrefpdf.'&desti=1'; 
$hrefpdf2=$hrefpdf.'&desti=2'; 
$hrefpdf3=$hrefpdf.'&desti=3'; 
?>                 
                                        
                                             <?php $xsrc='https://vcrxol.com/_bcod/'.$xclaveacc.'.jpg'; ?>
									<a href="<?php echo $hrefpdf2; ?>">
									<img src="<?php echo $xsrc;?>" alt="" title="DESCARGAR PDF" style="max-width:100%; max-height:<?php echo $hlogo;?>mm;">		
									</a>
									<?php }else{?>
									<?php gen_bcod($cfg_ruc.'_'.$xptonumero);?>
                                             <?php $xsrc='https://vcrxol.com/_bcod/'.$cfg_ruc.'_'.$xptonumero.'.jpg'; ?> 
									<img src="<?php echo $xsrc;?>" alt=""
											 title="<?php echo $xptonumero;?>" style="max-width:50%; max-height:<?php echo $hlogo;?>mm;">		
									<?php }?>
							<?php }else{ ?>
								<barcode style="font-size:28px; padding:0px; margin:1px; letter-spacing:1pt; font-weight:normal;">
								<?php if($xclaveacc!=""){echo $xclaveacc;}else{echo $cfg_ruc.' '.$xptonumero;}	?>
								</barcode>	
							<?php } ?>
							</td>
        <?php 
//           $docu_pdf->Image($xsrc,$pdf_ancho*.605+15,20,$pdf_ancho*.35,10,'JPG');
          $docu_pdf->Image($xsrc,$pdf_ancho*.605+15,16,$pdf_ancho*.35,18,'JPG');
          $docu_pdf->Link($pdf_ancho*.605+15,20,$pdf_ancho*.35,10,'https://'.$cfg_empr.'.vcrxol.com/print1.php?clave='.$xclaveacc);
          $docu_pdf->setY($posY2);
          $docu_pdf->setX($pdf_ancho*.605+10);
          $docu_pdf->Cell($pdf_ancho*.4,20,'.','LRTB',0,'R',false);
          $docu_pdf->ln();
          $posY2=$docu_pdf->getY()+1;                                                                                                  
        ?>
							<?php } ?>
            
						</tr>
					</table>
					<div style="font-size:25%;"><br></div>
						
						
						
					<?php ///// BLOQUE R1 ?>
					<datos>
					<?php  if (1==1) { ?>
					<table border="1" width="100%" cellpadding="2" cellspacing="0" 
                 style="border-collapse:collapse;font-size:<?php echo $xfontsize; ?>px;<?php echo $xfontfamily;?>">
						<tr style="border:solid 1px; font-weight:bolder; background: <?php echo $gris1;?>;">
							<td align="center" colspan=2 ><?php echo 'DATOS DEL COMPROBANTE'; ?></td>
						</tr>
						<tr style="display:none;">
							<td width="30%"></td>
							<td></td>
						</tr>
						<tr>
							<?php if(mb_stristr('retc.retp',$tabla)){$docu_descri='RETENCION';}?>
							<td align="right">TIPO:</td>
							<td>
                <?php if($tabla=='inve'){echo $docu.'-';}?>
                <?php echo $docu_descri;?>
              </td>
						</tr>
						<tr style="font-weight:bolder;">
							<td align="right">NUMERO:</td>
							<td><?php echo msql_result($res_tra1,0,'ptonumero');?></td>
						</tr>
                              <?php
                              $xfecha=msql_result($res_tra1,0,'fdian').' - '.msql_result($res_tra1,0,'fechadmy');
                             if($cfg_empr=='hfre'){$xfecha.=' ('.msql_result($res_tra1,0,'fsema').')';}
                              ?>
						<tr style="text-transform:uppercase">
							<td align="right">FECHA:</td>
							<td><?php echo $xfecha;?></td>
						</tr>
						<?php if(mb_stristr('prod',$tabla)){?>
							<tr style="text-transform:uppercase">
								<td align="right">ENTREGA:</td>
								<td><?php echo msql_result($res_tra1,0,'vencedian').' - '.msql_result($res_tra1,0,'vencedmy');?></td>
							</tr>
                              <?php }?>
						<?php if(mb_stristr('vtas.comp.clie.prov',$tabla)){?>
							<?php if(msql_result($res_tra1,0,'plazo')>1){?>
							<tr style="text-transform:uppercase">
								<td align="right">VENCE:</td>
								<td><?php echo @msql_result($res_tra1,0,'vencedian').' - '.msql_result($res_tra1,0,'vencedmy');?></td>
							</tr>
							<?php}?>
							<?php if($xvndd!=""){?>
							<tr style="">
								<td align="right">VENDEDOR:</td>
								<td><?php echo $xvndd.' - '.$xvndddes;?></td>
							</tr>
							<?php}?>
						<?php }?>

						<?php if(mb_stristr('caja.bcos',$tabla)){ ?>
							<?php $caba=msql_result($res_tra1,0,'caba') ; ?>
                                  <?php if($tabla=='caja'){$caba=msql_result($res_tra1,0,'caja');}?>
                                  <?php if($tabla=='bcos'){$caba=msql_result($res_tra1,0,'ctab');}?>
							<?php $caba2=@msql_result($res_tra1,0,'caba2') ;?>
							<tr style="text-transform:uppercase">
								<td align="right"><?php if($tabla=='caja'){echo 'CAJA:';}else{echo 'CTA.BANC:';}?></td>
								<td><?php echo $caba.' - '.r_fiel('caba',$caba); ?></td>
							</tr>
							<?php if($caba!=$caba2 and $caba2!=''){?>
							<tr style="text-transform:uppercase">
								<?php if(mb_stristr('IE.DB',substr($docu,0,2))){?>
								<td align="right">ORIGEN:</td>
								<?php}else{?>
								<td align="right">DESTINO:</td>
								<?php}?>
								<td><?php echo $caba2.' - '.r_fiel('caba',$caba2); ?></td>
							</tr>
							<?php}?>
              <?php $fechadepo=@msql_result($res_tra1,0,'fechadepo'); ?>
              <?php $ctabdepo=@msql_result($res_tra1,0,'ctabdepo'); ?>
              <?php $numedepo=@msql_result($res_tra1,0,'numedepo'); ?>
              <?php $fcobro=@msql_result($res_tra1,0,'fcobro'); ?>
              <?php 
                if(!empty($numedepo)) 
                {
                  $sql_depo ='select * from bcos1 ';
                  $sql_depo.='where docu like "DB%" and numero="'.$numedepo.'" and fecha>="'.$fecha.'"';
                  $sql_depo.=' and status!="O" and status!="X"';
                  $res_depo=msql_query($sql_depo,$link_vcrx);
                  $docudepo=msql_result($res_depo,0,'docu');
                  $idnumdepo=msql_result($res_depo,0,'idnum1');
                }
              ?>
                  <?php if(@mb_stristr('ICH1.',$docu)){?>
                  <?php //echo '*/*/*/*'.$fcobro.' - '.$fecha; ?>
                     <?php if($fcobro>$fecha){  ?>
                        <tr style="; border-top:solid 2px;">
                        <td align="right">FEC.COBRO.:</td>
                        <td><?php if($fcobro!=''){echo date('D d/M/y',strtotime($fcobro));} ?></td>
                        </tr>
                     <?php } ?>
                     <?php if($numedepo!='' and $fechadepo<=$fechaa){?>
                        <tr style="text-transform:uppercase; border-top:solid 2px;">
                        <td align="right">FEC.DEPO.:</td>
                        <td><?php echo date('D d/M/y',strtotime($fechadepo)); ?></td>
                        </tr>
                        <tr>
                        <td align="right">CTA.DEPO.:</td>
                        <td><?php echo $ctabdepo.' - '.r_fiel('ctab',$ctabdepo);; ?></td>
                        </tr>
                        <tr>
                        <td align="right">NUM.DEPO.:</td>
                        <td>
                        <a href="<?php echo 'https://'.$cfg_empr.'.vcrxol.com/?prnt=1&docu='.$docudepo.'&idnum='.$idnumdepo.'&formato='.$formato;?>"  target="_blank" >
                        <?php echo $numedepo; ?>
                        </a>
                        </td>
                        </tr>
                     <?php }?>
                  <?php }?>
                  <?php if(@mb_stristr('CH10.',$docu)){?>
                     <?php {?>
                        <tr style="text-transform:uppercase; border-top:solid 2px;">
                        <td align="right">FEC.COBRO.:</td>
                        <td><?php if($fcobro!=''){echo date('D d/M/y',strtotime($fcobro));} ?></td>
                        </tr>
                     <?php }?>
                  <?php }?>
					<?php }?>
						
            
						<?php if(mb_stristr('inve.prod.tfin',$tabla)){?>
                              <?php if($docu=='EB13' or $docu=='IB13'){$numfac=0;} ?>
                                   <?php if(!empty($numfac)){?>
							<tr style="text-transform:uppercase">
                                        <?php if(mb_stristr('IB10.EB10.IB12.EB12',$docu)){?>
								<td align="right"># FAC/NC:</td>
                                        <?php } ?>
                                        <?php if(mb_stristr('EB19',$docu)){?>
								<td align="right"># ORDEN:</td>
                                        <?php } ?>
								<td><?php echo $numfac; ?></td>
							</tr>
                                   <?php } ?>
							<tr style="text-transform:uppercase">
								<td align="right">BODEGA:</td>
								<td><?php echo $bode.' - '.r_fiel('bode',$bode); ?></td>
							</tr>
							<?php if(substr($docu,2,2)=="13"){?>
							<tr style="text-transform:uppercase">
								<td align="right">BODEGA 2:</td>
								<td><?php echo $bode2.' - '.r_fiel('bode',$bode2) ;?></td>
							</tr>
							<?php}?>
						<?php }?>
            
          <?php if(mb_stristr('IB13.EB13',$docu)){ ?>
              <?php
                if($docu=='EB13')
                {
                  $sql_ib13='select * from inve1 where idfrom="'.$idnum.'" and docu="IB13" and status!="X" ';
                  $res_ib13=msql_query($sql_ib13,$link_vcrx);
                  $iddesti=@msql_result($res_ib13,0,'idnum1');
                  $docudesti=@msql_result($res_ib13,0,'docu');
                  $numedesti=@msql_result($res_ib13,0,'numero');
                  
//                   echo $sql_ib13; 
                  if(msql_num_rows($res_ib13)==0)
                  {
                      $xcaption='';
                      $xonclick='';
                  }
                  else
                  {
                    echo '<tr>';
                    echo '<td align="right">';
                    echo 'DOC.REL.';
                    echo '</td>';
                    echo '<td align="left">';
                    echo '<a href="?prnt=1&docu=IB13&idnum='.$iddesti.'&formato=" target="_blank">';
                    echo 'IB13-'.$numedesti;  
                    echo '</a>';
                    echo '</td>';
                    echo '</tr>';
                    
                  }
                }
                                   
                if($docu=='IB13')
                {
                  $sql_ib13='select * from inve1 where idnum1="'.$idfrom.'" and docu="EB13" and status!="X" ';
                  $res_ib13=msql_query($sql_ib13,$link_vcrx);
                  $iddesti=@msql_result($res_ib13,0,'idnum1');
                  $docudesti=@msql_result($res_ib13,0,'docu');
                  $numedesti=@msql_result($res_ib13,0,'numero');
                     
//                      echo '**/*/'.$sql_ib13;
                  
//                   echo $sql_ib13; 
                  if(msql_num_rows($res_ib13)==0)
                  {
                      $xcaption='';
                      $xonclick='';
                  }
                  else
                  {
                    echo '<tr>';
                    echo '<td align="right">';
                    echo 'DOC.REL.';
                    echo '</td>';
                    echo '<td align="left">';
                    echo '<a href="?prnt=1&docu=EB13&idnum='.$iddesti.'&formato=" target="_blank">';
                    echo 'EB13-'.$numedesti;  
                    echo '</a>';
                    echo '</td>';
                    echo '</tr>';
                    
                  }
                }
              ?>
          <?php } ?>
            

            
            
						<?php if(mb_stristr('vtas.comp.retp.retc.guia.',$tabla)){  //echo '*/*/*'.$xclaveacc; ?>
						<?php if($xclaveacc!=""){ ?>
                              <?php if($xambi==2){$xambides='PRODUCCION';}else{$xambides='PRUEBAS';} ?>
						<tr style="font-size:80%; <?php if($xambi==1 and $cdisplay==2){ echo 'display:;';}?><?php if($xambi==1){ echo 'color:darkred;font-weight:bold;';}?>">
							<td align="right">AMBIENTE :</td>
							<td><?php echo $xambides;?></td>
						</tr>
						<?php } ?>
						<?php 

                                   $subdce=mk_subdce($claveacc);
							$filexml = $xclaveacc.'.xml';
							$filexmlb = $xclaveacc.'.xml';
							if(file_exists ('../../_cel/'.$subdce.$xclaveacc.'b.xml')){$filexmlb = $xclaveacc.'b.xml';}
						?>
						<?php if($xclaveacc!=""){ ?>
						<tr style="font-size:70%; <?php if(($xambi==1 and $cdisplay==2)or($cdisplay==2 and $xautornum!="")){ echo 'display:;';}?>">
							<td align="right">CLAVE ACCESO:</td>
							<td>
								<a href="<?php if($cdisplay==1){echo 'https://vcrxol.com/_cel/'.$subdce.$filexmlb;}?>" 
									 title="Descargar XML" target="_blank"
										<?php if($xautornum=="" or $destino=='mail'){ ?>
 									 download="<?php echo substr($docu,0,1).'_'.substr($xclaveacc,10,13).'_'.substr($xclaveacc,24,6).'_'.substr($xclaveacc,30,9).''; ?>" 
									 <?php } ?>
									 >
								<?php
// 						 			if($cdisplay==1){echo substr($claveacc,0,24).' '.substr($claveacc,24);}
						 			if($cdisplay==1){echo $xclaveacc;}
						 			else{echo substr($xclaveacc,0,8).'.'.substr($xclaveacc,8,2).'.'.substr($xclaveacc,10,13).'.'.substr($xclaveacc,23,1)
										.'<br>'.substr($xclaveacc,24,6).'.'.substr($xclaveacc,30,9).'.'.substr($xclaveacc,39,8).'.'.substr($xclaveacc,47,2);}
								?>
								</a>
							</td>
						</tr>
						<?php } ?>
            
						<?php if($xautornum!=""){ ?>
						<tr style="font-size:70%; <?php if($xambi==1 and $cdisplay==2){ echo 'display:none;';}?>">
							<td align="right">AUTORIZACION:</td>
							<td>
								<a href="<?php if($cdisplay==1){echo 'https://vcrxol.com/_cel/'.$subdce.$filexml;}?>" 
									 title="Descargar XML AUTORIZADO"
									 download="<?php echo substr($docu,0,1).'_'.substr($xclaveacc,10,13).'_'.substr($xclaveacc,24,6).'_'.substr($xclaveacc,30,9).''; ?>">
								<?php
// 						 			if($cdisplay==1){echo substr($xautornum,0,24).' '.substr($xautornum,24);}
						 			if($cdisplay==1){echo $xautornum;}
						 			else
										{
											if($xautornum==$xclaveacc)
											{
												echo substr($xautornum,0,8).'.'.substr($xautornum,8,2).'.'.substr($xautornum,10,13).'.'.substr($xautornum,23,1)
												.'<br>'.substr($xautornum,24,6).'.'.substr($xautornum,30,9).'.'.substr($xautornum,39,8).'.'.substr($xautornum,47,2);
											}
											else
											{
												echo substr($xautornum,0,8).'.'.substr($xautornum,8,3).'.'.substr($xautornum,11,6)
												.'<br>'.substr($xautornum,17,9).'.'.substr($xautornum,26,10).'.'.substr($xautornum,36,1);
											}
										}
								?>
								</a>
							</td>
						</tr>
						<?php } ?>

						<?php if($xautorfec!="" and mb_stristr('FP.RC.',substr($docu,0,2))){ ?>
						<tr style="font-size:70%; <?php if($xambi==1 and $cdisplay==2){ echo 'display:none;';}?>">
							<td align="right">FECHA AUT.:</td>
							<td>
								<a href="<?php if($cdisplay==1){echo 'https://vcrxol.com/_cel/'.$subdce.$filexml;}?>" 
									 title="Descargar XML AUTORIZADO"
									 download="<?php echo substr($docu,0,1).'_'.substr($xclaveacc,10,13).'_'.substr($xclaveacc,24,6).'_'.substr($xclaveacc,30,9).''; ?>">
    								<?php echo $xautorfec;	?>
								</a>
							</td>
						</tr>
						<?php } ?>

						<?php if($xatrz!="" and mb_stristr('FP.RC',substr($docu,0,2)) and $xautorfec==""){ ?>
						<tr>
							<td align="right">AUTORIZACION:</td>
							<td align="left" style="<?php if($xatrzvali=='X'){echo 'color:red;';}?><?php if($xatrzvali=='O'){echo 'color:yellow;';}?>">
                <?php echo $xatrz; ?>
                <?php echo ' ('.$xatrzvali.')'; ?>
              </td>
						</tr>
						<?php } ?>
            
						<?php } ?>

						<?php if(mb_stristr($filepdf,'/.pdf')){$filepdf='';}?>
						
						<?php if(($docupdf==1 or $entipdf==1) and 1==2){?>
						<?php if(file_exists($filepdf) or $mdisplay==1){?>
						<tr class="noprint">
						<td align="right" style="font-size:70%;">DESCARGAR</td>
						<td align="center">
							<a href="<?php if($cdisplay==1){echo 'https://vcrxol.com/_cel/'.$subdce.$xclaveacc.'.pdf';}?>" 
								 title="Descargar RIDE"
								 download="<?php echo substr($docu,0,1).'_'.substr($xclaveacc,10,13).'_'.substr($xclaveacc,24,6).'_'.substr($xclaveacc,30,9).''; ?>"
								 >Formato RIDE </a>
						</td>
						</tr>
						<?php } ?>
						<?php }?>
						
						<?php if($xstatus!="-" and $xstatus!=''){ ?>
						<tr>
							<td align="right">STATUS:</td>
							<td style="<?php if(mb_stristr('XO',$xstatus)){
									echo 'background-color:darkred;color:white;font-weight:bolder;letter-spacing:5px;text-align:center;';} ?>">
								<?php echo @msql_result($res_tra1,0,'stat_descri');?></td>
						</tr>
						<tr>
							<td align="right">USER / DATE:</td>
							<td xstyle="<?php if(mb_stristr('XO',$xstatus)){
									echo 'background-color:darkred;color:white;font-weight:bolder;letter-spacing:5px;text-align:center;';} ?>">
								<?php echo @msql_result($res_tra1,0,'ouser').' - '.r_fiel('user',@msql_result($res_tra1,0,'ouser'));?>
								<?php echo '<br>';?>
								<?php echo @msql_result($res_tra1,0,'odate');?>
                                   </td>
						</tr>
						<?php}?>
						<?php if($xclaveacc!="" and $cdisplay==2){ ?>
						<?php } ?>
					</table>
					<?php}?>

          <?php
             $docu_txt.=str_pad('DATOS DEL COMPROBANTE ',$coltxt,$carbot,STR_PAD_BOTH).$eol;
             $docu_txt.= 'TIPO         : '.$docu_descri.$eol;
             $docu_txt.= 'NUMERO       : '.@msql_result($res_tra1,0,'ptonumero').$eol;
             $docu_txt.= 'FECHA        : '.@msql_result($res_tra1,0,'fdian').' '.@msql_result($res_tra1,0,'fechadmy').' '.substr(@msql_result($res_tra1,0,'idate'),-8).$eol;
             if($vndd!='')
             {$docu_txt.= 'VENDEDOR     : '.$vndd.$eol;}
             if($claveacc!='')
             {
               $docu_txt.= 'AMBIENTE     : '.$xambides.$eol;
               $docu_txt.= 'CLAVE ACCESO : '.$eol;
               $docu_txt.= format_claveacc($claveacc).$eol;
             }
//             $docu_txt.=$eol;
               
          ?>
        <?php 
//           $posY=48;
          $docu_pdf->SetFont($ffamilyPDF,'B',$fsizePDF-2);
          $docu_pdf->SetY($posY2);
          $docu_pdf->SetX($pdf_ancho*.605+10);
          $docu_pdf->Cell($pdf_ancho*.4,5,'DATOS DEL COMPROBANTE','LRTB',0,'C',true);
          $docu_pdf->SetFont($ffamilyPDF,'',$fsizePDF-3);
          $docu_pdf->ln();
          $docu_pdf->SetX($pdf_ancho*.605+10);
          $docu_pdf->Cell($pdf_ancho*.1,5,'TIPO :','LRT',0,'R',false);
          $docu_pdf->MultiCell($pdf_ancho*.3,5,$docu_descri,'LRT','L',false);
          $docu_pdf->SetFont($ffamilyPDF,'B',$fsizePDF-3);
          $docu_pdf->SetX($pdf_ancho*.605+10);
          $docu_pdf->Cell($pdf_ancho*.1,5,'NUMERO :','LRT',0,'R',false);
          $docu_pdf->MultiCell($pdf_ancho*.3,5,@msql_result($res_tra1,0,'ptonumero'),'LRT','L',false);
          $docu_pdf->SetFont($ffamilyPDF,'',$fsizePDF-3);
          $docu_pdf->SetX($pdf_ancho*.605+10);
          $docu_pdf->Cell($pdf_ancho*.1,5,'FECHA :','LRT',0,'R',false);
          $docu_pdf->MultiCell($pdf_ancho*.3,5,utf8_decode(@msql_result($res_tra1,0,'fdian')).' '.@msql_result($res_tra1,0,'fechadmy'),'LRT','L',false);
					if(mb_stristr('vtas.comp.clie.prov',$tabla) and msql_result($res_tra1,0,'plazo')>1 )
					{
          $docu_pdf->SetX($pdf_ancho*.605+10);
          $docu_pdf->Cell($pdf_ancho*.1,5,'VENCE :','LRT',0,'R',false);
          $docu_pdf->MultiCell($pdf_ancho*.3,5,@msql_result($res_tra1,0,'vencedmy'),'LRT','L',false);
					}
          $docu_pdf->SetX($pdf_ancho*.605+10);
          $docu_pdf->SetFontSize($fsizePDF-4);

// 					if($xclaveacc!='')
					if($xclaveacc!='' and mb_stristr('01.03.04.05.06.07',substr($xclaveacc,8,2)))
					{
            $subdce=mk_subdce($claveacc);
            
            $docu_pdf->Cell($pdf_ancho*.1,5,'AMBIENTE :','LRT',0,'R',false);
            $docu_pdf->MultiCell($pdf_ancho*.3,5,$xambides,'LRT','L',false);

						$docu_pdf->SetFontSize($fsizePDF-6.5);
						$docu_pdf->SetTextColor(0,0,0);
          	$docu_pdf->SetFont($ffamilyPDF,'');
						$docu_pdf->Link($pdf_ancho*.605+10,$docu_pdf->GetY(),$pdf_ancho*.4,5,'https://vcrxol.com/_cel/'.$subdce.$filexmlb);
						$docu_pdf->SetX($pdf_ancho*.605+10);
						$docu_pdf->Cell($pdf_ancho*.1,5,'CLAVE ACCESO :','LRT',0,'R',false);
						$docu_pdf->SetFont($ffamilyPDF,'U');
						$docu_pdf->SetTextColor(0,0,255);
						$docu_pdf->MultiCell($pdf_ancho*.3,5,$xclaveacc,'LRT','L',false);

						$docu_pdf->SetTextColor(0,0,0);
          	$docu_pdf->SetFont($ffamilyPDF,'');
						$docu_pdf->Link($pdf_ancho*.605+10,$docu_pdf->GetY(),$pdf_ancho*.4,5,'https://vcrxol.com/_cel/'.$subdce.$filexml);
						$docu_pdf->SetX($pdf_ancho*.605+10);
						$docu_pdf->Cell($pdf_ancho*.1,5,'AUTORIZACION :','LRT',0,'R',false);
						$docu_pdf->SetFont($ffamilyPDF,'U');
						$docu_pdf->SetTextColor(0,0,255);
						$docu_pdf->MultiCell($pdf_ancho*.3,5,$xclaveacc,'LRT','L',false);

						$docu_pdf->SetTextColor(0,0,0);
          	$docu_pdf->SetFont($ffamilyPDF,'',$fsizePDF-3);
					}
																												
          $docu_pdf->SetFontSize($fsizePDF-2);
          $docu_pdf->SetX($pdf_ancho*.605+10);
          $docu_pdf->Cell($pdf_ancho*.1,1,'','T',0,'',false);
          $docu_pdf->MultiCell($pdf_ancho*.3,1,'','T','',false);

          $posY2=$docu_pdf->getY();
                                                        
        ?>

        </datos>

				<?php if($width>=150 or 1==1){?>					
					<div style="font-size:25%;"><br></div>
				<?php }else{ ?>
					</td>
					<td width=50% valign="top">
				<?php } ?>

					<?php ///// BLOQUE R2 ?>
					<resumen>
					<?php if (1==1) {?>
					<table border="1" width="100%" cellpadding="2" cellspacing="0" 
                 style="border-collapse:collapse;font-size:<?php echo $xfontsize; ?>px;<?php echo $xfontfamily;?>">
						<tr style="border:solid 1px; font-weight:bolder; background: <?php echo $gris1;?>;">
							<td align="center" colspan="2" style="letter-spacing:5px;"><?php echo 'RESUMEN'; ?></td>
						</tr>
						<tr style="display:none;">
							<td width="70%"></td>
							<td></td>
						</tr>
						<tr align="right" style="<?php if($xtunid<=0){echo 'display:none;';} ?>">
							<td>UNIDADES:</td>
							<td><?php echo number_format($xtunid,2);?></td>
						</tr>
						<tr align="right" style="<?php if($xtserv<=0){echo 'display:none;';} ?>">
							<td>SERVICIOS:</td>
							<td><?php echo number_format($xtserv,2);?></td>
						</tr>
                              
            <?php if(mb_stristr('nomi.empl', $tabla)){?>
                <tr align="right">
                  <td>REMUNERACION:</td>
                  <td><?php echo number_format($xtremun,2);?></td>
                </tr>
                <tr align="right">
                  <td>DEDUCCION:</td>
                  <td><?php echo number_format($xtdeduc,2);?></td>
                </tr>
                <tr><td colspan="2"></td></tr>
						<?php } ?>
                              
						<?php if(mb_stristr('guia', $tabla)){?>
              <tr>
                <td align="right">MOTIVO:</td>
                <td><?php echo $motivo;?></td>
              </tr>
              <?php if($docuorigd!='') {?>
                <tr>
                  <td align="right">COMPROBANTE:</td>
                  <td><?php echo $docuorigd;?></td>
                </tr>
                <tr>
                  <td align="right">FECHA:</td>
                  <td><?php echo $fechaorig;?></td>
                </tr>
                <tr>
                  <td align="right">NUMERO:</td>
                  <td><?php echo $numeroorig;?></td>
                </tr>
                <tr style="font-size:75%; <?php if($autororig==''){echo 'display:none;';} ?>">
                  <td align="right">AUTORIZACION:</td>
                  <td>
                    <?php
                      if($cdisplay==1){echo $autororig;}
                      else
                        {
                          echo substr($autororig,0,8).'.'.substr($autororig,8,2).'.'.substr($autororig,10,13).'.'.substr($autororig,23,1)
                          .'<br>'.substr($autororig,24,6).'.'.substr($autororig,30,9).'.'.substr($autororig,39,8).'.'.substr($autororig,47,2);
                        }
                    ?>
                  </td>
                </tr>
              <?php}?>	
						<?php}?>	
						<?php if(mb_stristr('cont', $tabla)){?>
						<tr align="right">
							<td>DEBITOS</td>
							<td><?php echo number_format($xtdebito,2);?></td>
						</tr>
						<tr align="right">
							<td>CREDITOS</td>
							<td><?php echo number_format($xtcredito,2);?></td>
						</tr>
							<?php //if($xdifer!=0){?>
							<?php if(abs($xdifer)>$saldo0){?>
							<tr align="right" >
								<td>DIFERENCIA</td>
								<td style="color:red;"><?php echo number_format($xdifer,2);?></td>
							</tr>
							<?php } ?>
						<?php } ?>
            <?php if(mb_stristr('clie.prod.vtas', $tabla)){?>
              <?php if($cfg_empr=='ecgl'){?>
                <tr align="right">
                  <td>LAMINAS:</td>
                  <td><?php echo number_format($xstlmn,2);?></td>
                </tr>
                <tr align="right">
                  <td>MTS:</td>
                  <td><?php echo number_format($xstmt1,2);?></td>
                </tr>
                <tr align="right">
                  <td>MT<sup>2</sup>:</td>
                  <td><?php echo number_format($xstmt2,2);?></td>
                </tr>
                <tr><td colspan="2"></td></tr>
              <?php } ?>
						<?php } ?>
            
						<?php if(mb_stristr('vtas.comp.clie.carr.prov.comi', $tabla)){?>
						<tr align="right">
							<td>SUB-TOTAL:</td>
							<td><?php echo number_format($xtsubt,2);?></td>
						</tr>
						<?php if($xpdcto!=0){?>
						<tr align="right" style="font-style:italic;">
							<td>DESCUENTO:</td>
							<td><?php echo number_format($xtdcto,2);?></td>
						</tr>
						<?php } ?>
						<?php if($xpprop!=0){?>
						<tr align="right" style="font-style:italic;">
							<td>PROPINA:</td>
							<td><?php echo number_format($xtprop,2);?></td>
						</tr>
						<?php } ?>
						<?php if($xpice!=0){?>
						<tr align="right" style="">
							<td>SUB-TOTAL ICE <?php echo number_format($xpice,0)?>%:</td>
							<td><?php echo number_format($xtsubtice,2);?></td>
						</tr>
						<tr align="right" style="font-style:italic;">
							<td>ICE <?php echo number_format($xpice,0)?>%:</td>
							<td><?php echo number_format($xtice,2);?></td>
						</tr>
						<?php } ?>
						<tr align="right" style="<?php if($docu=='DA16'){echo 'display:none;';} ?>" >
							<td>SUB-TOTAL IVA 0%:</td>
							<td><?php echo number_format($xtsubtiva0,2);?></td>
						</tr>
						<?php if($xpiva!=0){?>
						<tr align="right" style="">
							<td>SUB-TOTAL IVA <?php echo number_format($xpiva,0)?>%:</td>
							<td><?php echo number_format($xtsubtiva,2);?></td>
						</tr>
						<tr align="right" style="font-style:italic;">
							<td>IVA <?php echo number_format($xpiva,0)?>%:</td>
							<td><?php echo number_format($xtiva,2);?></td>
						</tr>
						<?php } ?>
						<?php}?>	
            
						<?php if(mb_stristr('retc.retp.', $tabla)){?>
						<tr align="right">
							<td>RET.IVA:</td>
							<td><?php echo number_format($xtriva,2);?></td>
						</tr>
						<tr align="right">
							<td>RET.RTA:</td>
							<td><?php echo number_format($xtrrta,2);?></td>
						</tr>
						<?php}?>	
						
						<?php if(mb_stristr('plan', $tabla)){?>
                  <?php $xvalorpla=@msql_result($res_tra1,0,'valorpla');?>
                  <?php $xtotatvd=tfle_totatvd($docu,$idnum);?>
						<tr align="right">
							<td>VALORACION</td>
							<td><?php echo @msql_result($res_tra1,0,'empr1');?></td>
							<td><?php echo number_format($xvalorpla,2);?></td>
						</tr>
						<tr align="right">
							<td>HORAS</td>
							<td><?php echo number_format($xtcant,2);?></td>
                     <td><?php echo number_format($xtotatvd[1],2);?></td>
						</tr>
						<tr align="right">
							<td>COSTO</td>
							<td><?php echo number_format(0,2);?></td>
                     <td><?php echo number_format($xtotatvd[2],2);?></td>
						</tr>
                  
						<?php}?>	
						
						<?php if(mb_stristr('atvd', $tabla)){?>
						<tr align="right">
							<td>EMPRESA</td>
							<td><?php echo @msql_result($res_tra1,0,'csub1');?></td>
						</tr>
						<tr align="right">
							<td>HORAS</td>
							<td><?php echo number_format($xtcant,2);?></td>
						</tr>
						<?php}?>	
						
            <?php if($docu=='DA16'){ ?>
            <?php
               $sql_da16='select sum(cant*cuni) as ctotal from '.$tabla.'12 where idnum1="'.$idnum.'"';
               $res_da16=msql_query($sql_da16,$link_vcrx);
               $xctotal=@msql_result($res_da16,0,'ctotal');
               $xtotal=$xctotal;
               
            ?>
            <?php } ?>

            <?php $href='';?>
            <?php if(substr($docu,0,2)=='CH'){$href='?ch10=1&docu='.$docu.'&idnum='.$idnum.'" target="_blank"';} ?>
            
						<?php if(!mb_stristr('guia.cont.',$tabla)){?>
						<tr align="right" style="font-weight:bolder;<?php if($xtotal==0 or $xipuni==0){echo 'display:none;';} ?>">
							<td>TOTAL:</td>
							<td>
            <?php if(!empty($href)){echo '<a href="'.$href.'">';} ?>
                <?php echo number_format(abs($xtotal),2);?>
            <?php if(!empty($href)){echo '</a>';} ?>
              </td>
						</tr>
						<?php } ?>

						<?php if(@mb_stristr('FP15.DA16.FP16',$docu)){?>
						<tr align="right" style="font-weight:bolder;">
							<td>PESO KG.:</td>
							<td><?php echo number_format(abs($xtpeso),2);?></td>
						</tr>
						<?php } ?>

            <?php if(mb_stristr('clie', $tabla)){?>
              <?php if($cfg_empr=='dly1' and $xcomi>0){?>
                <?php $xcomi=$xtotal* $enticomi /100; ?>
                <?php $xapagar=$xtotal-$xcomi; ?>
                <tr><td colspan="2"></td></tr>
                <tr align="right">
                  <td>COMISION:</td>
                  <td><?php echo number_format($xcomi,2);?></td>
                </tr>
                <tr align="right" style="font-weight:bolder;">
                  <td>A PAGAR:</td>
                  <td><?php echo number_format($xapagar,2);?></td>
                </tr>
                <tr><td colspan="2"></td></tr>
              <?php } ?>
						<?php } ?>
            
						
					</table>					
					<?php}?>
					</resumen>

        <?php 
//           $posY=48;
          $docu_pdf->SetFont($ffamilyPDF,'B',$fsizePDF-2);
          $docu_pdf->SetY($posY2);
          $docu_pdf->SetX($pdf_ancho*.605+10);
          $docu_pdf->Cell($pdf_ancho*.4,5,'RESUMEN','LRTB',0,'C',true);
          $docu_pdf->SetFont($ffamilyPDF,'',$fsizePDF-3);
          $docu_pdf->ln();
					if(mb_stristr('vtas.comp.clie.carr.prov.comi',$tabla))
					{

            if(mb_stristr('vtas.clie.comi.carr',$tabla))
            {
              if($xtunid>0)
              {
                $docu_pdf->SetX($pdf_ancho*.605+10);
                $docu_pdf->Cell($pdf_ancho*.25,5,'UNIDADES :','LRT',0,'R',false);
                $docu_pdf->MultiCell($pdf_ancho*.15,5,number_format($xtunid,2),'LRT','R',false);
              }

              if($xtserv>0)
              {
                $docu_pdf->SetX($pdf_ancho*.605+10);
                $docu_pdf->Cell($pdf_ancho*.25,5,'SERVICIOS :','LRT',0,'R',false);
                $docu_pdf->MultiCell($pdf_ancho*.15,5,number_format($xtserv,2),'LRT','R',false);
              }
            }
            
						$docu_pdf->SetX($pdf_ancho*.605+10);
						$docu_pdf->Cell($pdf_ancho*.25,5,'SUB-TOTAL :','LRT',0,'R',false);
						$docu_pdf->MultiCell($pdf_ancho*.15,5,number_format($xtsubt,2),'LRT','R',false);
            
						if($xtdcto>0)
            {
              $docu_pdf->SetX($pdf_ancho*.605+10);
              $docu_pdf->Cell($pdf_ancho*.25,5,'DESCUENTO :','LRT',0,'R',false);
              $docu_pdf->MultiCell($pdf_ancho*.15,5,number_format($xtdcto,2),'LRT','R',false);
            }
            
						$docu_pdf->SetX($pdf_ancho*.605+10);
						$docu_pdf->Cell($pdf_ancho*.25,5,'SUB-TOTAL IVA 0% :','LRT',0,'R',false);
						$docu_pdf->MultiCell($pdf_ancho*.15,5,number_format($xtsubtiva0,2),'LRT','R',false);
						if($xpiva>0) 
						{
              $docu_pdf->SetX($pdf_ancho*.605+10);
              $docu_pdf->Cell($pdf_ancho*.25,5,'SUB-TOTAL IVA '.number_format($xpiva,0).'%:','LRT',0,'R',false);
              $docu_pdf->MultiCell($pdf_ancho*.15,5,number_format($xtsubtiva,2),'LRT','R',false);

              $docu_pdf->SetX($pdf_ancho*.605+10);
              $docu_pdf->Cell($pdf_ancho*.25,5,'IVA :','LRT',0,'R',false);
              $docu_pdf->MultiCell($pdf_ancho*.15,5,number_format($xtiva,2),'LRT','R',false);
            }
					}

          if(mb_stristr('retc.retp',$tabla))
					{
						$docu_pdf->SetX($pdf_ancho*.605+10);
						$docu_pdf->Cell($pdf_ancho*.25,5,'RET.IVA :','LRT',0,'R',false);
						$docu_pdf->MultiCell($pdf_ancho*.15,5,number_format($xtriva,2),'LRT','R',false);
						$docu_pdf->SetX($pdf_ancho*.605+10);
						$docu_pdf->Cell($pdf_ancho*.25,5,'RET.RTA :','LRT',0,'R',false);
						$docu_pdf->MultiCell($pdf_ancho*.15,5,number_format($xtrrta,2),'LRT','R',false);
					}
    
					if(mb_stristr('guia',$tabla))
					{
            $docu_pdf->SetFontSize($fsizePDF-4);
						$docu_pdf->SetX($pdf_ancho*.605+10);
						$docu_pdf->Cell($pdf_ancho*.10,5,'MOTIVO :','LRT',0,'R',false);
						$docu_pdf->MultiCell($pdf_ancho*.30,5,$motivo,'LRT','L',false);
            if($docuorigd!='')
            {
              $docu_pdf->SetX($pdf_ancho*.605+10);
              $docu_pdf->Cell($pdf_ancho*.10,5,'COMPROB.:','LRT',0,'R',false);
              $docu_pdf->MultiCell($pdf_ancho*.30,5,$docuorigd,'LRT','L',false);
              $docu_pdf->SetX($pdf_ancho*.605+10);
              $docu_pdf->Cell($pdf_ancho*.10,5,'FECHA :','LRT',0,'R',false);
              $docu_pdf->MultiCell($pdf_ancho*.30,5,$fechaorig,'LRT','L',false);
              $docu_pdf->SetX($pdf_ancho*.605+10);
              $docu_pdf->Cell($pdf_ancho*.10,5,'NUMERO :','LRT',0,'R',false);
              $docu_pdf->MultiCell($pdf_ancho*.30,5,$numeroorig,'LRT','L',false);
              $docu_pdf->SetX($pdf_ancho*.605+10);

              $docu_pdf->SetFontSize($fsizePDF-6);
              $docu_pdf->Cell($pdf_ancho*.10,5,'AUTORIZACION :','LRT',0,'R',false);
              $docu_pdf->MultiCell($pdf_ancho*.30,5,$autororig,'LRT','L',false);
            }
					}
                                                        
          $docu_pdf->SetFont($ffamilyPDF,'B',$fsizePDF-3);
          $docu_pdf->SetX($pdf_ancho*.605+10);
          $docu_pdf->Cell($pdf_ancho*.25,5,'TOTAL :','LRT',0,'R',false);
          $docu_pdf->MultiCell($pdf_ancho*.15,5,number_format(abs($xtotal),2),'LRT','R',false);
          $docu_pdf->SetX($pdf_ancho*.605+10);
          $docu_pdf->Cell($pdf_ancho*.25,1,'','T',0,'',false);
          $docu_pdf->MultiCell($pdf_ancho*.15,1,'','T','',false);
                                                        
          $posY2=$docu_pdf->getY();
        ?>
            
				<?php if($width>=150 or 1==1){?>					
				<?php }else{ ?>
					</td>
					</tr>
					<tr>
					<td>
				<?php } ?>
            
					<?php ///// BLOQUE R3 ?>
					<?php  if (1==1) {?>
					<?php if(mb_stristr('vtas.comp', $tabla)){?>
					<div style="font-size:25%;"><br></div>
					<table border="1" width="100%" cellpadding="2" cellspacing="0" 
                 style="border-collapse:collapse;font-size:<?php echo $xfontsize; ?>px;<?php echo $xfontfamily;?>">
						<?php if(mb_stristr('NC.NP',substr($docu,0,2)) or $docu=='FC50' or $docu=='FP05'){?>
						<?php
							$xtoenti=@msql_result($res_tra1,0,'enti');
							$xtodocu=@msql_result($res_tra1,0,'todocu');
							$xtoptoe=@msql_result($res_tra1,0,'toptoe');
							$xtonumero=@msql_result($res_tra1,0,'tonume');
//           echo '*/*/*/'.$xtodocu;
              if($xtodocu!='')
              {
                if(mb_stristr('FC',substr($xtodocu,0,2)))
                {$sql_todoc='select * from vtas12 where enti="'.$xtoenti.'" and docu="'.$xtodocu.'" and numero="'.$xtonumero.'" and ptoe="'.$xtoptoe.'"';}
                if(mb_stristr('FP',substr($xtodocu,0,2)))
                {$sql_todoc='select * from comp12 where enti="'.$xtoenti.'" and docu="'.$xtodocu.'" and numero="'.$xtonumero.'" and ptoe="'.$xtoptoe.'"';}
                $res_todoc=msql_query($sql_todoc,$link_vcrx);
                
                
                if(msql_num_rows($res_todoc)==0)
                {
                  upl_cexml(msql_result($res_tra1,0,'claveacc'));
                  $res_todoc=msql_query($sql_todoc,$link_vcrx);
                  if(msql_num_rows($res_todoc)==0)
                  {
                    if(mb_stristr('FC',substr($xtodocu,0,2)))
                    {$sql_todoc='select * from vtas12 where enti="'.$xtoenti.'" and docu="'.$xtodocu.'" and numero="'.$xtonumero.'"';}
                    if(mb_stristr('FP',substr($xtodocu,0,2)))
                    {$sql_todoc='select * from comp12 where enti="'.$xtoenti.'" and docu="'.$xtodocu.'" and numero="'.$xtonumero.'"';}
                    $res_todoc=msql_query($sql_todoc,$link_vcrx);
                  }
                }
                $xtofecha=@msql_result($res_todoc,0,'fechadmy');
  							$xtoidnum=@msql_result($res_todoc,0,'idnum1');
              }
                
						?>
						<tr style="border:solid 1px; font-weight:bolder; background: <?php echo $gris1;?>;">
							<td align="center" colspan="2">MODIFICA</td>
						</tr>
						<tr>
								<td>COMPROBANTE</td>
								<td>FACTURA</td>
						</tr>
						<tr>
								<td>NUMERO</td>
								<td>
                <?php if($copia==1){?>
                  <a href="<?php //echo 'https://'.$cfg_empr.'.vcrxol.com/?prnt=1&docu='.$xtodocu.'&idnum='.$xtoidnum.'&formato='.$formato;?>"  target="_blank" >
                  <a href="<?php echo 'https://'.$cfg_empr.'.vcrxol.com/?prnt=1&docu='.$xtodocu.'&idnum='.$xtoidnum.'&formato='.$formato;?>"  target="_blank" >
                <?php } ?>                  
                    <?php echo $xtoptoe.'-'.$xtonumero;?>
                <?php if($copia==1){?>
                  </a>
                <?php } ?>                  
                </td>
						</tr>
						<tr>
								<td>FECHA</td>
								<td><?php echo $xtofecha;?></td>
						</tr>
						<?php } ?>
						<?php if(!mb_stristr('NC.NP',substr($docu,0,2))){ ?>
						<tr style="border:solid 1px; font-weight:bolder; background: <?php echo $gris1;?>;<?php if($xfpag==0){echo 'display:none;';} ?>">
							<td align="center" >FORMA DE PAGO</td>
							<td></td>
						</tr>
						<tr style="<?php if($xfpag==0){echo 'display:none;';} ?>">
							<td style="font-size:70%;"><?php echo msql_result($res_tra1,0,'fpag_descri'); ?></td>
							<td align="right"><?php echo number_format(abs($xtotal),2);?></td>
						</tr>
          <?php
             $docu_txt.=str_pad('FORMA DE PAGO ',$coltxt,$carbot,STR_PAD_BOTH).$eol;
             if(!empty($efectivo))                                                                            
             {$docu_txt.= str_pad('EFECTIVO : '.number_format(abs($efectivo),2),$coltxt,' ',STR_PAD_LEFT).$eol;}
             if(!empty($credito))                                                                            
             {$docu_txt.= str_pad('CREDITO : '.number_format(abs($credito),2),$coltxt,' ',STR_PAD_LEFT).$eol;}
             $docu_txt.= ''.msql_result($res_tra1,0,'fpag_descri').$eol;
             $docu_txt.= str_pad(number_format(abs($xtotal),2),$coltxt,' ',STR_PAD_LEFT).$eol;
             //$docu_txt.=$eol;
          ?>
            
        <?php 
//           $posY=48;
          $docu_pdf->SetFont($ffamilyPDF,'B',$fsizePDF-2);
          $docu_pdf->SetY($posY2);
          $docu_pdf->SetX($pdf_ancho*.605+10);
          $docu_pdf->Cell($pdf_ancho*.4,5,'FORMA DE PAGO','LRTB',0,'C',true);
          $docu_pdf->ln();
          $docu_pdf->SetFont($ffamilyPDF,'',$fsizePDF-6);
          $docu_pdf->SetX($pdf_ancho*.605+10);
          $docu_pdf->Cell($pdf_ancho*.3,5,msql_result($res_tra1,0,'fpag_descri').':','LRT',0,'R',false);
          $docu_pdf->SetFont($ffamilyPDF,'',$fsizePDF-5);
          $docu_pdf->MultiCell($pdf_ancho*.1,5,number_format(abs($xtotal),2),'LRT','R',false);
          $docu_pdf->SetX($pdf_ancho*.605+10);
          $docu_pdf->Cell($pdf_ancho*.25,1,'','T',0,'',false);
          $docu_pdf->MultiCell($pdf_ancho*.15,1,'','T','',false);
                                                        
          $posY2=$docu_pdf->getY();
        ?>

            <?php } ?>
					</table>					
					<?php}?>
					<?php}?>

				<?php if($width>=150 or 1==1){?>					
				<?php }else{ ?>
					</td>
					</tr>
				<?php } ?>

      </td>
			</tr>
		</table>



<?php
          $docu_pdf->setY($posY1+2);
          if($posY2>$posY1){$docu_pdf->setY($posY2+2);}
          $docu_pdf->SetFont($ffamilyPDF,'B',$fsizePDF-2);
?>


<?php //////////////////////////////////////////////////////////	?>
<?php // DETALLE	?>
		<?php $crow=0;?>
		<?php $ccol=0;?>
		<?php $filag=5; ?>
		<?php if($cfg_empr=='ecgl' and mb_stristr('clie.vtas.prod',$tabla)){$filag=1000;} ?>
		<?php if($cfg_empr=='ecgl' and mb_stristr('clie.vtas',$tabla)){$xideta=0;} ?>
		<?php if($cfg_empr=='ecgl' and mb_stristr('prod',$tabla)){$xideta=0;} ?>
		<?php
			if(@mb_stristr('OP',substr($docu,0,2)) and $cfg_empr=='ecgl')
			{
				$xipuni=0;
				$xtdcto=0;
				$xtprop=0;
				$xtiva=0;
				$xtice=0;
				$xtirbp=0;
			}
		?>
      

		<div style="font-size:25%;"><br></div>
		<?php if($guiaremi==1){?>
      <?php
        $plazo=@msql_result($res_tra1,0,'plazo');
        $fecha1=msql_result($res_tra1,0,'fecha1');
        $fecha2=msql_result($res_tra1,0,'fecha2');

        if($fecha1==''){$fecha1=msql_result($res_tra1,0,'fecha');}
        if($fecha2=='' or $fecha2<$fecha1){$fecha2=date('Ymd',strtotime($fecha1.' '.$plazo.'  days'));}
        $fecha1=date('d/M/Y', strtotime($fecha1));
        $fecha2=date('d/M/Y', strtotime($fecha2));
                                                        
        $placa=msql_result($res_tra1,0,'placa');
        $placades=r_fiel('vhcl',$placa);
        $ruta=msql_result($res_tra1,0,'ruta');

        $cedula1=msql_result($res_tra1,0,'cedula1');
        $cedula2=msql_result($res_tra1,0,'cedula2');
        $nombre1=msql_result($res_tra1,0,'nombre1');
        $nombre2=msql_result($res_tra1,0,'nombre2');
        $punto1=msql_result($res_tra1,0,'punto1');
        $punto2=msql_result($res_tra1,0,'punto2');
    ?>

		<table border="0" width="96%" cellpadding="2" cellspacing="0" 
           style="border-collapse:collapse;font-size:<?php echo $xfontsize; ?>px;<?php echo $xfontfamily;?>">
			<tr style="background:<?php echo $gris1;?>;font-weight:bolder; border-top:solid 1px; border-bottom:solid 1px; letter-spacing: 1px;">
				<td colspan="6">DATOS DEL TRANSPORTE</td></tr>
			<tr>
				<td width="1%"></td>
				<td width="24%"></td>
				<td width="25%"></td>
				<td width="1%"></td>
				<td width="24%"></td>
				<td width="25%"></td>
			</tr>
			<tr>
        <td style="border-left:solid 1px;"></td>
				<td>INICIO DE TRANSPORTE :</td>
				<td><?php echo $fecha1;?></td>
        <td style="border-left:solid 1px;"></td>
				<td>FIN DE TRANSPORTE :</td>
				<td><?php echo $fecha2;?></td>
			</tr>
			<tr>
        <td style="border-left:solid 1px;"></td>
				<td>No.ID. CONDUCTOR :</td>
				<td><?php echo $cedula1;?></td>
        <td style="border-left:solid 1px;"></td>
				<td>No.ID. DESTINATARIO :</td>
				<td><?php echo $cedula2;?></td>
			</tr>
			<tr>
        <td style="border-left:solid 1px;"></td>
				<td>NOM. CONDUCTOR :</td>
				<td><?php echo $nombre1;?></td>
        <td style="border-left:solid 1px;"></td>
				<td>NOM. DESTINATARIO :</td>
				<td><?php echo $nombre2;?></td>
			</tr>
			<tr>
        <td style="border-left:solid 1px;"></td>
				<td>PLACA DEL VEHICULO :</td>
				<td><?php echo $placa;?></td>
        <td style="border-left:solid 1px;"></td>
				<td>RUTA :</td>
				<td><?php echo $ruta;?></td>
			</tr>
			<tr>
        <td style="border-left:solid 1px;"></td>
				<td></td>
				<td><?php echo $placades;?></td>
        <td style="border-left:solid 1px;"></td>
				<td></td>
				<td></td>
			</tr>
			<tr style="vertical-align:text-top;">
        <td style="border-left:solid 1px;"></td>
				<td>PUNTO DE PARTIDA :</td>
				<td><?php echo $punto1;?></td>
        <td style="border-left:solid 1px;"></td>
				<td>PUNTO DE LLEGADA :</td>
				<td><?php echo $punto2;?></td>
			</tr>
		</table>
		<br>


      <?php
          $docu_pdf->SetFont($ffamilyPDF,'B',$fsizePDF-3);
          $docu_pdf->Cell($pdf_ancho*1,5,'DATOS DEL TRANSPORTE ','TB',0,'L',true);
          $docu_pdf->ln();

          $docu_pdf->SetFont($ffamilyPDF,'',$fsizePDF-4);
          $posX=$docu_pdf->GetX();
          $posY=$docu_pdf->GetY();
      

          $docu_pdf->Cell($pdf_ancho*.20,5,'INICIO DE TRANSPORTE :','L',0,'L');
          $docu_pdf->Cell($pdf_ancho*.30,5,$fecha1,'',0,'L');
          $docu_pdf->Cell($pdf_ancho*.20,5,'FIN DE TRANSPORTE :','L',0,'L');
          $docu_pdf->Cell($pdf_ancho*.30,5,$fecha2,'',0,'L');
          $docu_pdf->ln();
      
          $docu_pdf->Cell($pdf_ancho*.20,5,'No. ID. CONDUCTOR :','L',0,'L');
          $docu_pdf->Cell($pdf_ancho*.30,5,$cedula1,'',0,'L');
          $docu_pdf->Cell($pdf_ancho*.20,5,'No. ID DESTINATARIO :','L',0,'L');
          $docu_pdf->Cell($pdf_ancho*.30,5,$cedula2,'',0,'L');
          $docu_pdf->ln();
      
          $posY1=$docu_pdf->GetY();
          $docu_pdf->Cell($pdf_ancho*.20,5,'Nom. CONDUCTOR :','L',0,'L');
          $docu_pdf->MultiCell($pdf_ancho*.30,5,$nombre1,'','',false);
          $posY2=$docu_pdf->GetY();

          $docu_pdf->SetXY($pdf_ancho*.5+10,$posY1);
          $docu_pdf->Cell($pdf_ancho*.20,5,'Nom. DESTINATARIO :','L',0,'L');
          $docu_pdf->MultiCell($pdf_ancho*.30,5,$nombre2,'','',false);
          $docu_pdf->ln();
      
          $docu_pdf->Cell($pdf_ancho*.20,5,'PLACA DEL VEHICULO :','L',0,'L');
          $docu_pdf->Cell($pdf_ancho*.30,5,$placa,'',0,'L');
          $docu_pdf->Cell($pdf_ancho*.20,5,'RUTA :','L',0,'L');
          $docu_pdf->Cell($pdf_ancho*.30,5,$ruta,'',0,'L');
          $docu_pdf->ln();

          $posY1=$docu_pdf->GetY();
          $docu_pdf->Cell($pdf_ancho*.20,5,'PUNTO DE PARTIDA :','L',0,'L');
          $docu_pdf->MultiCell($pdf_ancho*.30,5,$punto1,'','',false);
          $posY2=$docu_pdf->GetY();

          $docu_pdf->SetXY($pdf_ancho*.5+10,$posY1);
          $docu_pdf->Cell($pdf_ancho*.20,5,'PUNTO DE LLEGADA :','L',0,'L');
          $docu_pdf->MultiCell($pdf_ancho*.30,5,$punto2,'','',false);
          $docu_pdf->ln();

      
      ?>




		<?php } ?>

<?php
          $docu_pdf->SetFont($ffamilyPDF,'B',$fsizePDF-3);
          $docu_pdf->Cell($pdf_ancho*1,5,'DETALLE','TB',0,'L',true);
          $docu_pdf->ln();
?>


<?php
          
    $xtfob=0;
    $xtseguro=0;
    $xtflete=0;
    $xtcif=0;
    $xtadva=0;
    $xtespe=0;
    $xtdump=0;
    $xtfodi=0;
    $xtisd=0;
    $xtcostol=0;
    $xtcostot=0;


?>

    <?php //explain_sql($sql_tra2); ?>
		<table border="0" width="96%" cellpadding="2" cellspacing="0" 
           style="border-collapse:collapse;font-size:<?php echo $xfontsize; ?>px;<?php echo $xfontfamily;?>;">
			<tr style="background:<?php echo $gris1;?>;font-weight:bolder; border-top:solid 1px; letter-spacing: 10px;"><td>DETALLE</td></tr>
		</table>
		<div style="font-size:25%;"><br></div>
		<detalle>
    <?php $xfontsize2=$xfontsize;?>
    <?php if($docu=='DA16'){$xfontsize2=$xfontsize*.8;}?>
		<table id="deta_<?php echo $tabla.'_'.$cdisplay;?>" class="deta<?php echo $cdisplay;?>"
					 border="0" width="96%" cellpadding="2" cellspacing="0"
					 style="border-collapse:collapse;font-size:<?php echo $xfontsize2; ?>px;<?php echo $xfontfamily;?>">
		<thead>
         <?php if($formato==2) { ?>
 			<tr style="border-top:solid 1px; border-bottom:solid 1px; font-weight:bolder; background:<?php echo $gris1;?>;">
            <th colspan="10">CONTABILIDAD</th>
        </tr>
         <?php } ?>
		<tr style="background:<?php echo $gris1;?>; border-top:solid 1px; border-bottom:solid 1px; cursor:pointer;" title="Reordenar">
				<th onclick="sortTable(this,<?php echo $ccol++; ?>);" style="display:none;">L</th>
			<?php if(mb_stristr('cont',$tabla)){?>
				<th onclick="sortTable(this,<?php echo $ccol++; ?>);">CUENTA</th>
				<th onclick="sortTable(this,<?php echo $ccol++; ?>);" width="25%" style="letter-spacing: 5px;">CONTABLE</th>
				<th onclick="sortTable(this,<?php echo $ccol++; ?>,'N');" width="10%">DEBITOS</th>
				<th onclick="sortTable(this,<?php echo $ccol++; ?>,'N');" width="10%">CREDITOS</th>
				<th onclick="sortTable(this,<?php echo $ccol++; ?>);" style="<?php if($xmcsub==""){echo 'display:none;';}?>;">C.SUB</th>
				<th onclick="sortTable(this,<?php echo $ccol++; ?>);" style="<?php if($xmcair==""){echo 'display:none;';}?>;">CAIR</th>
				<th onclick="sortTable(this,<?php echo $ccol++; ?>);" style="<?php if($xmitem==""){echo 'display:none;';}?>;">ITEM</th>
				<th onclick="sortTable(this,<?php echo $ccol++; ?>);" width="30%">DETALLE</th>
			<?php}?>
			<?php if(mb_stristr('nomi.',$tabla)){?>
				<th onclick="sortTable(this,<?php echo $ccol++; ?>);" width="5%">CEDULA</th>
				<th onclick="sortTable(this,<?php echo $ccol++; ?>);" width="15%" style="letter-spacing: 5px;">EMPLEADO</th>
			<?php}?>
      
			<?php if(mb_stristr('.empl',$tabla)){?>
				<th onclick="sortTable(this,<?php echo $ccol++; ?>);" width="10%">FECHA</th>
			<?php}?>
			<?php if(mb_stristr('nomi.empl',$tabla)){?>
				<th onclick="sortTable(this,<?php echo $ccol++; ?>);" width="5%">NVDD</th>
				<th onclick="sortTable(this,<?php echo $ccol++; ?>);" width="15%" style="letter-spacing: 5px;">NOVEDAD</th>
				<th onclick="sortTable(this,<?php echo $ccol++; ?>,'N');" width="5%">CANT/BASE</th>
				<th onclick="sortTable(this,<?php echo $ccol++; ?>,'N');" width="5%">V.UNIT.</th>
				<th onclick="sortTable(this,<?php echo $ccol++; ?>,'N');" width="10%">REMUN.</th>
				<th onclick="sortTable(this,<?php echo $ccol++; ?>,'N');" width="10%">DEDUC.</th>
				<th onclick="sortTable(this,<?php echo $ccol++; ?>,'N');" width="10%">PROVI.</th>
				<th onclick="sortTable(this,<?php echo $ccol++; ?>,'N');" width="15%">DETALLE</th>
			<?php}?>
      
      
			<?php if(mb_stristr('susa',$tabla)){?>
				<th onclick="sortTable(this,<?php echo $ccol++; ?>);">FECHA</th>
				<th onclick="sortTable(this,<?php echo $ccol++; ?>);" >C.SUB</th>
				<th onclick="sortTable(this,<?php echo $ccol++; ?>);" >CARGO</th>
				<th onclick="sortTable(this,<?php echo $ccol++; ?>,'N');" >SUELDO</th>
				<th onclick="sortTable(this,<?php echo $ccol++; ?>,'N');" >ANTIC.</th>
				<th onclick="sortTable(this,<?php echo $ccol++; ?>,'N');" >%ANT.</th>
				<th onclick="sortTable(this,<?php echo $ccol++; ?>,'N');" >ALIM.</th>
				<th onclick="sortTable(this,<?php echo $ccol++; ?>,'N');" >MOVIL.</th>
				<th onclick="sortTable(this,<?php echo $ccol++; ?>,'N');" >COMIS.</th>
				<th onclick="sortTable(this,<?php echo $ccol++; ?>,'N');" >D.13</th>
				<th onclick="sortTable(this,<?php echo $ccol++; ?>,'N');" >D.14</th>
				<th onclick="sortTable(this,<?php echo $ccol++; ?>,'N');" >F.RES</th>
				<th onclick="sortTable(this,<?php echo $ccol++; ?>,'N');" >TOTAL</th>
			<?php}?>
			<?php if(mb_stristr('guia',$tabla)){?>
				<th onclick="sortTable(this,<?php echo $ccol++; ?>);">ITEM</th>
				<th onclick="sortTable(this,<?php echo $ccol++; ?>);"style="letter-spacing: 5px;">DESCRIPCION</th>
				<th onclick="sortTable(this,<?php echo $ccol++; ?>);"style="letter-spacing: 5px;"></th>
				<th onclick="sortTable(this,<?php echo $ccol++; ?>,'N');">CANT.</th>
				<th onclick="sortTable(this,<?php echo $ccol++; ?>);">UNID.</th>

      <?php
          $docu_pdf->SetFont($ffamilyPDF,'B',$fsizePDF-3);
          $docu_pdf->Cell($pdf_ancho*.1,5,'CODIGO','TB',0,'C',true);
          $docu_pdf->Cell($pdf_ancho*.3,5,'DESCRIPCION','TB',0,'C',true);
          $docu_pdf->Cell($pdf_ancho*.1,5,'CANT.','TB',0,'C',true);
          $docu_pdf->Cell($pdf_ancho*.03,5,'','TB',0,'C',true);
          $docu_pdf->Cell($pdf_ancho*.1,5,'','TB',0,'C',true);
          $docu_pdf->ln();
      
      ?>
      
			<?php}?>
			<?php if(mb_stristr('inve.prod',$tabla)){?>
				<th onclick="sortTable(this,<?php echo $ccol++; ?>);">L-SUB</th>
               <?php } ?>
			<?php if(mb_stristr('vtas.comp.clie.carr.prov.inve.prod.comi.tfin',$tabla)){?>
                    <?php if(mb_stristr('anml.cada',$cfg_empr) and $tirilla==1) { ?>
				<th onclick="sortTable(this,<?php echo $ccol++; ?>);">L</th>
               <?php }else{ ?>
				<th onclick="sortTable(this,<?php echo $ccol++; ?>);">ITEM</th>
               <?php } ?>
				<th onclick="sortTable(this,<?php echo $ccol++; ?>);"style="<?php if($xlitemdescri<15){echo 'letter-spacing: 2px;';}else{echo 'letter-spacing: 5px;';} ?>">DESCRIPCION</th>
				<th onclick="sortTable(this,<?php echo $ccol++; ?>,'N');">CANT.</th>
				<th onclick="sortTable(this,<?php echo $ccol++; ?>);"></th>
        <?php if($xipvp==1){ ?>
				<th onclick="sortTable(this,<?php echo $ccol++; ?>,'N');" style="<?php if($xipuni==0){echo 'display:;';}?>">P.V.P.</th>
        <?php }else{ ?>
				<th onclick="sortTable(this,<?php echo $ccol++; ?>,'N');" style="<?php if($xipuni==0){echo 'display:none;';}?>">UNIT.</th>
				<th onclick="sortTable(this,<?php echo $ccol++; ?>,'N');" style="<?php if($xipuni==0){echo 'display:none;';}?>">SUBT.</th>
				<?php if(mb_stristr('vtas.comp.clie.carr.prov',$tabla)){?>
					<th onclick="sortTable(this,<?php echo $ccol++; ?>,'N');" style="<?php if($xipuni*$xtdcto==0){echo 'display:none;';}?>;">DESC</th>
					<th onclick="sortTable(this,<?php echo $ccol++; ?>,'N');" style="<?php if($xipuni*$xtprop==0){echo 'display:none;';}?>;">PROP</th>
					<th onclick="sortTable(this,<?php echo $ccol++; ?>,'N');" style="<?php if($xipuni*$xtice==0) {echo 'display:none;';}?>;">ICE</th>
					<th onclick="sortTable(this,<?php echo $ccol++; ?>,'N');" style="<?php if($xipuni*$xtiva==0) {echo 'display:none;';}?>;">IVA</th>
					<th onclick="sortTable(this,<?php echo $ccol++; ?>,'N');" style="<?php if($xipuni*$xtirbp==0){echo 'display:none;';}?>;">IRBP</th>
				<?php}?>
        <?php } ?>
      
				<th onclick="sortTable(this,<?php echo $ccol++; ?>,'N');" style="<?php if($xtotal==0){echo '';}?>;<?php if($xipuni==0){echo 'display:none;';}?>">TOTAL</th>
				<th onclick="sortTable(this,<?php echo $ccol++; ?>);"max-width="50%" style="letter-spacing: 2px; <?php if($xmdetalle==""){echo 'display:none;';}?> ">DETALLE</th>

<?php
                                                        
             $docu_txt.=str_pad('DETALLE ',$coltxt,$carbot,STR_PAD_BOTH).$eol;
             $docu_txt.=str_repeat('-',$coltxt).$eol;
//              $docu_txt.=str_pad('|CODIGO',13,$padtxt,STR_PAD_RIGHT);
             $docu_txt.=str_pad('COD/CANT',14,$padtxt,STR_PAD_BOTH);
             $docu_txt.=str_pad('|',1,$padtxt,STR_PAD_LEFT);
//              $docu_txt.=str_pad('   ',3,$padtxt,STR_PAD_BOTH);
             $docu_txt.=str_pad('P.UNI.|',10,$padtxt,STR_PAD_LEFT);
             $docu_txt.=str_pad('TOTAL|',10,$padtxt,STR_PAD_LEFT);
             $docu_txt.=$eol;
             $docu_txt.=str_repeat('-',$coltxt).$eol;
                                                        
?>
      <?php
          $docu_pdf->SetFont($ffamilyPDF,'B',$fsizePDF-3);
          $docu_pdf->Cell($pdf_ancho*.1,5,'CODIGO','TB',0,'C',true);
          $docu_pdf->Cell($pdf_ancho*.3,5,'DESCRIPCION','TB',0,'C',true);
          $docu_pdf->Cell($pdf_ancho*.1,5,'CANT.','TB',0,'C',true);
          $docu_pdf->Cell($pdf_ancho*.03,5,'','TB',0,'C',true);
          $docu_pdf->Cell($pdf_ancho*.1,5,'P.UNIT','TB',0,'C',true);
          $docu_pdf->Cell($pdf_ancho*.1,5,'SUBT.','TB',0,'C',true);
          if($xtdcto>0)
          {$docu_pdf->Cell($pdf_ancho*.07,5,'DCTO','TB',0,'C',true);}
          if($xtice>0)
          {$docu_pdf->Cell($pdf_ancho*.05,5,'ICE','TB',0,'C',true);}
          if($xtiva>0)
          {$docu_pdf->Cell($pdf_ancho*.05,5,'IVA','TB',0,'C',true);}
          $docu_pdf->Cell($pdf_ancho*.1,5,'TOTAL','TB',0,'C',true);
          $docu_pdf->ln();
        ?>
			<?php}?>

			<?php //$empr_cont=5 ;?>
			<?php if($empr_cont=='1' and ($tabla=='comp' or $docu=='APx10')){?>
				<th onclick="sortTable(this,<?php echo $ccol++; ?>);" style="<?php if($xmctas==""){echo 'display:none;';}?>">CUENTA</th>
				<th onclick="sortTable(this,<?php echo $ccol++; ?>);" style="<?php if($xmctas==""){echo 'display:none;';}?>">CONTABLE</th>
        <?php if(mb_stristr('FP15.DA16',$docu)){?>
				<th onclick="sortTable(this,<?php echo $ccol++; ?>,'N');" style="font-size:80%">PESO</th>
        <?php } ?>
        <?php if(mb_stristr('DA16.FP16',$docu)){?>
				<th onclick="sortTable(this,<?php echo $ccol++; ?>,'N');" style="font-size:80%">AD-VALOR</th>
				<th onclick="sortTable(this,<?php echo $ccol++; ?>,'N');" style="font-size:80%">FODINFA</th>
				<th onclick="sortTable(this,<?php echo $ccol++; ?>,'N');" style="font-size:80%">C.UNIT.</th>
        <?php } ?>
        <?php if(!mb_stristr('FP15.FP16',$docu)){?>
				<th onclick="sortTable(this,<?php echo $ccol++; ?>);" style="font-size:80%">CAIR</th>
				<th onclick="sortTable(this,<?php echo $ccol++; ?>,'N');" style="font-size:80%">%Rta</th>
				<th onclick="sortTable(this,<?php echo $ccol++; ?>,'N');" style="font-size:80%">%IVA</th>
        <?php } ?>
			<?php}?>
      
			<?php if(mb_stristr('retc.retp',$tabla)){?>
				<th onclick="sortTable(this,<?php echo $ccol++; ?>);">EJERCICIO<br>FISCAL</th>
				<th onclick="sortTable(this,<?php echo $ccol++; ?>,'N');">BASE<br>IMPONIBLE</th>
				<th onclick="sortTable(this,<?php echo $ccol++; ?>);" width="30%">IMPUESTO</th>
				<th onclick="sortTable(this,<?php echo $ccol++; ?>,'N');">% Ret</th>
				<th onclick="sortTable(this,<?php echo $ccol++; ?>,'N');">VALOR<br>RETENIDO</th>
				<th onclick="sortTable(this,<?php echo $ccol++; ?>);">COMPROBANTE</th>
				<th onclick="sortTable(this,<?php echo $ccol++; ?>);">NUMERO</th>
      <?php
          $docu_pdf->SetFont($ffamilyPDF,'B',$fsizePDF-4);
          $docu_pdf->Cell($pdf_ancho*.1,10,'EJER.FISCAL','TB',0,'C',true);
          $docu_pdf->Cell($pdf_ancho*.1,10,'BASE IMP.','TB',0,'C',true);
          $docu_pdf->SetFont($ffamilyPDF,'B',$fsizePDF-3);
          $docu_pdf->Cell($pdf_ancho*.3,10,'IMPUESTO','TB',0,'C',true);
          $docu_pdf->Cell($pdf_ancho*.1,10,'%RET.','TB',0,'C',true);
          $docu_pdf->Cell($pdf_ancho*.1,10,'VAL.RETEN.','TB',0,'C',true);
          $docu_pdf->Cell($pdf_ancho*.15,10,'COMPROB.','TB',0,'C',true);
          $docu_pdf->Cell($pdf_ancho*.15,10,'NUMERO','TB',0,'C',true);
          $docu_pdf->ln();
        ?>
			
			<?php}?>

			<?php if(mb_stristr('caja.bcos.dxco.dxpa',$tabla)){?>
				<th onclick="sortTable(this,<?php echo $ccol++; ?>);">COMP.</th>
				<th onclick="sortTable(this,<?php echo $ccol++; ?>);">NUMERO</th>
        <?php if(mb_stristr('dxco.dxpa',$tabla)){?>      
				<th onclick="sortTable(this,<?php echo $ccol++; ?>,'N');">CANT.</th>
				<th onclick="sortTable(this,<?php echo $ccol++; ?>,'N');">P.UNI</th>
  			<?php}?>
				<th onclick="sortTable(this,<?php echo $ccol++; ?>,'N');">VALOR</th>
				<th onclick="sortTable(this,<?php echo $ccol++; ?>);">CUENTA</th>
				<th onclick="sortTable(this,<?php echo $ccol++; ?>);">CONTABLE</th>
				<th onclick="sortTable(this,<?php echo $ccol++; ?>);">DETALLE</th>
			<?php}?>
      
			<?php if(mb_stristr('vtas.clie.inve.prod.tfin',$tabla)){?>
				<th onclick="sortTable(this,<?php echo $ccol++; ?>);" style="<?php if($xmlote==''){echo 'display:none;';} ?>">LOTE</th>
			<?php}?>
      
			<?php if(mb_stristr('inve.prod.tfin',$tabla)){?>
				<th onclick="sortTable(this,<?php echo $ccol++; ?>);" style="<?php if($xmserie==''){echo 'display:none;';} ?>"># SERIE</th>
			<?php}?>
      
            <?php if(mb_stristr('IB11.EB11',$docu)){ ?>
      				<th onclick="sortTable(this,<?php echo $ccol++; ?>);" style="">CAMBIO</th>
            <?php } ?>
      
			<?php if(@mb_stristr('DA16',$docu) and $formato==5){?>
				<th onclick="sortTable(this,<?php echo $ccol++; ?>,'N');" style="<?php if($xtpeso==0){echo 'display:;';} ?>">PESO</th>
				<th onclick="sortTable(this,<?php echo $ccol++; ?>);" style="<?php if($xmarcl==0){echo 'display:;';} ?>">ARANCEL</th>
				<th onclick="sortTable(this,<?php echo $ccol++; ?>,'N');" style="<?php if($xcostoe1==0){echo 'display:none;';} ?>">COSTO EXT.</th>
				<th onclick="sortTable(this,<?php echo $ccol++; ?>,'N');" style="<?php if($xfob1==0){echo 'display:;';} ?>">FOB</th>
				<th onclick="sortTable(this,<?php echo $ccol++; ?>,'N');" style="<?php if($xseguro1==0){echo 'display:;';} ?>">SEGURO</th>
				<th onclick="sortTable(this,<?php echo $ccol++; ?>,'N');" style="<?php if($xflete1==0){echo 'display:;';} ?>">FLETE</th>
				<th onclick="sortTable(this,<?php echo $ccol++; ?>,'N');" style="<?php if($xcif1==0){echo 'display:;';} ?>">CIF</th>
				<th onclick="sortTable(this,<?php echo $ccol++; ?>,'N');" style="<?php if($xadva==0){echo 'display:none;';} ?>">AD-VALOR</th>
				<th onclick="sortTable(this,<?php echo $ccol++; ?>,'N');" style="<?php if($xespe==0){echo 'display:none;';} ?>">ARA-ESPE</th>
				<th onclick="sortTable(this,<?php echo $ccol++; ?>,'N');" style="<?php if($xdump==0){echo 'display:none;';} ?>">DUMPING</th>
				<th onclick="sortTable(this,<?php echo $ccol++; ?>,'N');" style="<?php if($xfodi==0){echo 'display:none;';} ?>">FODINFA</th>
				<th onclick="sortTable(this,<?php echo $ccol++; ?>,'N');" style="<?php if($xivai==0){echo 'display:none;';} ?>">IVA</th>
				<th onclick="sortTable(this,<?php echo $ccol++; ?>,'N');" style="<?php if($xmisdi==0){echo 'display:none;';} ?>">ISD</th>
				<th onclick="sortTable(this,<?php echo $ccol++; ?>,'N');" style="<?php if($xcostol1==0){echo 'display:;';} ?>">C.LOCAL</th>
				<th onclick="sortTable(this,<?php echo $ccol++; ?>,'N');" style="<?php if($xadva==0){echo 'display:;';} ?>">C.TOTAL</th>
				<th onclick="sortTable(this,<?php echo $ccol++; ?>,'N');" style="<?php if($xadva==0){echo 'display:;';} ?>">C.UNIT.</th>
			<?php}?>
      
      
			<?php if(mb_stristr('plan.atvd',$tabla)){?>
				<th onclick="sortTable(this,<?php echo $ccol++; ?>);">ACTIVIDAD</th>
				<th onclick="sortTable(this,<?php echo $ccol++; ?>);">DESCRIPCION</th>
				<th onclick="sortTable(this,<?php echo $ccol++; ?>,'N');">HORAS</th>
   			<?php if(mb_stristr('atvd',$tabla)){?>
				<th onclick="sortTable(this,<?php echo $ccol++; ?>);">EMPR</th>
				<th onclick="sortTable(this,<?php echo $ccol++; ?>,'N');">#PLAN</th>
	   		<?php}?>
   			<?php if(mb_stristr('plan',$tabla)){?>
				<th onclick="sortTable(this,<?php echo $ccol++; ?>);"></th>
	   		<?php}?>
				<th onclick="sortTable(this,<?php echo $ccol++; ?>);">
          <?php if($tabla=='plan'){echo 'RECURSO';}?>
          <?php if($tabla=='atvd'){echo 'CLIENTE';}?>
        </th>
				<th onclick="sortTable(this,<?php echo $ccol++; ?>,'N');">VALOR</th>
				<th onclick="sortTable(this,<?php echo $ccol++; ?>,'N');">SUBTOTAL</th>
			<?php}?>

      <?php if($cfg_empr=='pcs1' and substr($docu,0,2)=='FC') {?>
			<th onclick="sortTable(this,<?php echo $ccol++; ?>);" style="<?php if($xmcntn==""){echo 'display:none;';}?>;">CONTENEDOR</th>
			<th style="<?php if($xmcntn==""){echo 'display:none;';}?>;">DESDE</th>
			<th style="<?php if($xmcntn==""){echo 'display:none;';}?>;">HASTA</th>
			<?php}?>

      
      <?php if(mb_stristr('tgck.sawo.ztej',$cfg_empr)  and substr($docu,0,2)=='FC') {?>
			<th onclick="sortTable(this,<?php echo $ccol++; ?>);" style="<?php if($xmvhcl==""){echo 'display:none;';}?>;">VEHICULO</th>
			<th onclick="sortTable(this,<?php echo $ccol++; ?>);" style="<?php if($xmvhcl==""){echo 'display:none;';}?>;"></th>
			<?php}?>
      
      <?php if(mb_stristr('gmny.gnya',$cfg_empr) and mb_stristr('vtas.clie.carr.prod.inve',$tabla)) {?>
			<th onclick="sortTable(this,<?php echo $ccol++; ?>);" style="<?php if($xmclor==""){echo 'display:none;';}?>;">C</th>
			<th onclick="sortTable(this,<?php echo $ccol++; ?>);" style="<?php if($xmtlla==""){echo 'display:none;';}?>;">T</th>
			<?php}?>
      
      
		</tr>
		</thead>
		<?php $lvhcl=''; ?>
		<?php $filax=0; ?>
    <?php //msql_data_seek($res_tra2,0);?>
		<?php $res_tra2=msql_query($sql_tra2,$link_vcrx); ?>
    <?php //echo explain_sql($sql_tra2);?>  
		<tbody>
		<?php while($aso_tra2=msql_fetch_assoc($res_tra2)){?>	
      <?php $mtime=microtime(true)-$mtime;?>
				<?php
				$filax++;
				$iddet=$aso_tra2['iddet'];
				$duni=$aso_tra2['item_duni'];
				$dpre=$aso_tra2['item_dpre'];
				$dval=$aso_tra2['item_dval'];
				$umdd=$aso_tra2['item_umdd'];
				$icodigov=$aso_tra2['item_codigov'];
				$item_lsub=$aso_tra2['item_lsub'];
				$item_codigo=$aso_tra2['item'];
				$item_codigoce=$aso_tra2['itemce'];
				$item_codigoce2=$aso_tra2['itemce2'];
				$item_descri=$aso_tra2['item_descri'];
                                                          
                    if($aso_tra2['item_status']=='I')
                    {$item_descri.=' ==>(INACTIVO)';}
                                                          
                                                          
				$item_mrca=$aso_tra2['item_mrca'];
				$mrca_descri=r_fiel('mrca',$item_mrca);
                    if(mb_stristr('pcs1',$cfg_empr)){$item_descri.=' /'.$mrca_descri;}
				$ctas_descri=@$aso_tra2['ctas_descri'];
			  $ctas_descri=split_words($ctas_descri,40);
                                                     
        $long_itemdes=strlen($item_descri);
        $long_ctasdes=strlen($ctas_descri);
	
// 				$detalle=$aso_tra2['detalle'];
				$detalle=$aso_tra2['detalle'];
                    $detalle=str_replace(',',', ',$detalle);
                    $detalle=str_replace('/',' /',$detalle);
                    $detalle=str_replace('  ',' ',$detalle);
// echo '*/*/*'.$detalle;                                
                                                                                                                    
				$pcp1=$aso_tra2['puni']*$aso_tra2['cant']*(1-$aso_tra2['dcto']/100);
				$uxpre=@$aso_tra2['uxpre'];
				$facon=@$aso_tra2['facon'];
				$cantumdd=@$aso_tra2['cantumdd'];
          
        //corrige duplicidad del usuario
                    $detalle=str_replace($xconcepto,' ',$detalle);
				$detalle=str_replace($item_descri,' ',$detalle);
                                                          
        if(@mb_stristr($item_descri,$detalle)){$detalle='';}                                                     
        $long_detalle=strlen($detalle);                                                     
				if($item_descri!="" and $item_codigo!="-" and substr($item_codigo,0,4)!="9999" and mb_stristr('cont',$tabla))
				{$detalle.='<div style="font-size:80%;">'.' /'.$item_descri.'</div>';}

        $detcantumdd='';                                                     
        if($uxpre*$facon!=0 and $uxpre*$facon!=1)
        {
          $detcantumdd.='<br>';
          $detcantumdd.=' ==> (';
          $detcantumdd.=number_format($uxpre,2);
          $detcantumdd.=' /';
          $detcantumdd.=number_format($facon,2);
          $detcantumdd.=') ';
          $detcantumdd.=number_format($cantumdd,2).' '.$umdd;
          $detcantumdd.=' ($'.number_format($pcp1/$cantumdd,2).')';
        }  
        $detalle.=$detcantumdd;                                                     
                                                     
          if($icodigov==""){$icodigov=$aso_tra2['item'];}

          if(mb_stristr('anml.cada',$cfg_empr) and $tirilla==1)
          {$icodigov=++$xclind;}
                                                          
        if(substr($item_codigo,0,4)=="9999"){$item_descri=$detalle; $detalle='';}
        if(substr($item_codigo,0,4)=="8888"){$item_descri=$detalle; $detalle='';}
                                                     
          if(substr($item_codigo,0,4)=="9999")
        {
          $item_codigo ='99-';
          $item_codigo.=$aso_tra2['itemce'];
          $item_codigo.=' /'.$aso_tra2['itemce2'];
        }
				if($item_codigo==""){$item_codigo=$aso_tra2['item'];}

//           if(mb_stristr('anml',$cfg_empr) and $tirilla==1)
//           {$item_codigo="";}
                                                     
				if($duni==0){$duni=2;}
				if($dpre==0){$dpre=2;}
				if($dval==0){$dval=2;}
				if(ceil($aso_tra2['cant'])!=floor($aso_tra2['cant']) and $duni==0){$duni=2;}
				?>
				<?php if($cfg_empr=='ecgl' and mb_stristr('clie.vtas.prod',$tabla) and substr($item_descri,0,4)=='VIDR'){ ?>
					<?php if($aso_tra2['itnum']>1){echo '<tr><td><br></td></tr>';}?>
          <?php
            $itsubt=0;
            $itdcto=0;
            $itiva=0;
            $itotal=0;
                                                                                                              
            if($tabla!='prod')                                                                                                             
            {                                                                                             
              $sql_itnum ='select * from '.$tabla.'12 where idnum1="'.$aso_tra2['idnum1'].'" and itnum="'.$aso_tra2['itnum'].'"';
              $res_itnum=msql_query($sql_itnum,$link_vcrx);
              while($aso_itnum=@msql_fetch_assoc($res_itnum))
              {
                $itsubt+=$aso_itnum['tsubt'];
                $itdcto+=$aso_itnum['tdcto'];
                $itiva+=$aso_itnum['tiva'];
                $itotal+=$aso_itnum['total'];
              }
            }
        ?>
					<tr style="<?php if($tabla=='prod' or 1==1){echo 'font-size:125%';} ?>">
					<td align="center" style="font-weight:bolder;"><?php echo '#'.fillzero($aso_tra2['itnum'],2);?>	</td>
					<td style="border:solid 1px; font-weight:bolder; background:<?php echo $gris1;?>;">
					<?php $mm_e=substr($item_descri,strpos($item_descri,'MM')-2,2); ?>	
					<?php echo 'LAMINAS : '.$aso_tra2['lmns'];?>	
					<?php echo ' ('.$mm_e.'mm. ';?>	
					<?php echo ' X '.$aso_tra2['mm_l'].' ';?>	
					<?php echo ' X '.$aso_tra2['mm_a'].' )';?>	
					</td>
          <td align="right"><?php echo number_format($aso_tra2['lmns']);?></td>
          <td align="left">LAM.</td>
          <?php if($tabla=='prod'){ ?> 
            <?php
              $pulido='';
              $templar='';
              if($aso_tra2['puli']==1){$pulido='MATE';}
              if($aso_tra2['puli']==2){$pulido='BRILLANTE';}
              if($aso_tra2['tmpl']<=1){$templar='CRUDO';}
              if($aso_tra2['tmpl']==2){$templar='TEMPLAR';}
          
              $tsaques=number_format($aso_tra2['saqu0']+$aso_tra2['saqu1']+$aso_tra2['saqu2'],0);
              $tperfor=number_format($aso_tra2['perf0']+$aso_tra2['perf1']+$aso_tra2['perf2'],0);
              $tmts=number_format(($aso_tra2['mm_l']+$aso_tra2['mm_a'])*2/1000,2);
              $tmt2=number_format(($aso_tra2['mm_l']*$aso_tra2['mm_a'])/1000000,2);
            ?>
            <td align="center"><?php if($tsaques!=0){echo '| SAQ.: '.$tsaques.' ';}?></td>
            <td align="center"><?php if($tperfor!=0){echo '| PER.: '.$tperfor.' ';}?></td>
            <td align="center"><?php if($pulido!=''){echo '| PUL.: '.$pulido.' ';}?></td>
            <td align="right"><?php if($templar!=''){echo '| '.$templar.' |';}?></td>
          <?php }?>
          <?php if($tabla!='prod'){ ?>                                                                                                              
            <td align="right"><?php echo number_format($itsubt/$aso_tra2['lmns'],2);?></td>
            <td align="right"><?php echo number_format($itsubt,2);?></td>
            <td align="right" style="<?php if($xtdcto==0){echo 'display:none;';}?>;"><?php echo number_format($itdcto,2);?></td>
            <td align="right"><?php echo number_format($itiva,2);?></td>
            <td align="right"><?php echo number_format($itotal,2);?></td>
          <?php }?>
					</tr>	
				<?php	} ?>
      
      
			<tr valign="top" style="<?php if($filax %$filag==0){echo 'border-bottom:dotted 1px;';} ?> 
          <?php //if($cfg_empr=='ecgl' and mb_stristr('clie.vtas',$tabla)) {echo 'display:none';} ?>" >
                    
					<td align="center" style="display:none;"><?php echo fillzero($crow++);?></td>
					
					<?php if(mb_stristr('cont',$tabla)){ ?>
						<td align="left"><?php echo $aso_tra2['ctas'];?></td>
						<td align="left"><?php echo $ctas_descri;?></td>
						<td align="right">
							<?php echo number_format($aso_tra2['tdebito'],$duni);?>
						</td>
						<td align="right">
							<?php echo number_format($aso_tra2['tcredito'],$duni);?>
						</td>
						<td align="center" style="<?php if($xmcsub==""){echo 'display:none;';}?>;"><?php echo $aso_tra2['csub'];?></td>
						<td align="center" style="<?php if($xmcair==""){echo 'display:none;';}?>;"><?php echo $aso_tra2['cair'];?></td>
						<td align="center" style="<?php if($xmitem==""){echo 'display:none;';}?>;font-size:80%;"><?php echo $aso_tra2['item'];?></td>
						<td align="left"><?php echo $detalle;?></td>
					<?php } ?>
					<?php if(mb_stristr('nomi.',$tabla)){?>
            <?php //$empl_descri=r_fiel('enti',$aso_tra2['enti'],'enti_ape1').' '.r_fiel('enti',$aso_tra2['enti'],'enti_nom1'); ?>
            <?php $empl_descri=$aso_tra2['enti_ape1'].' '.$aso_tra2['enti_nom1']; ?>
            <?php if((trim($empl_descri)=='')){$empl_descri=$aso_tra2['enti_descri']; }?>
						<td align="center"><?php echo $aso_tra2['enti2'];?></td>
						<td align="left"><?php echo $empl_descri; ?></td>
					<?php } ?>
        
					<?php if(mb_stristr('nomi.empl',$tabla)){?>
            <?php
//               $xpuni=$aso_tra2['puni'];
//               $ddig=decimaldigit($xpuni)+1;
          $ddig=4;
              $tremun=$aso_tra2['tingreso'];
              $tdeduc=$aso_tra2['tegreso'];
              $tprovi=$aso_tra2['tprovis'];
            ?>
					<?php if(mb_stristr('.empl',$tabla)){?>
						<td align="center"><?php echo $aso_tra2['fecha2'];?></td>
                              <?php $ddig=2; ?>
              <?php } ?>
						<td align="center"><?php echo $aso_tra2['nvdd'];?></td>
						<td align="left"><?php echo $aso_tra2['nvdd_descri'];?></td>
						<td align="right"><?php echo number_format($aso_tra2['cant'],2);?></td>
						<td align="right"><?php echo number_format($aso_tra2['puni'],$ddig);?></td>
						<td align="right">
              <?php if($tremun!=0){ ?>
              <?php echo number_format($tremun,2);?>
              <?php } ?>
            </td>
						<td align="right">
              <?php if($tdeduc!=0){ ?>
              <?php echo number_format(abs($tdeduc),2);?>
              <?php } ?>
            </td>
						<td align="right">
              <?php if($tprovi!=0){ ?>
              <?php echo number_format($tprovi,2);?>
              <?php } ?>
            </td>
						<td align="left"><?php echo $aso_tra2['detalle'];?></td>
					<?php } ?>
        
					<?php if(mb_stristr('susa',$tabla)){?>
						<td align="center"><?php echo $aso_tra2['fecha2'];?></td>
						<td align="center"><?php echo $aso_tra2['csub'];?></td>
						<td align="center"><?php echo $aso_tra2['cargo'];?></td>
						<td align="right"><?php echo number_format($aso_tra2['sueldo'],2);?></td>
						<td align="right"><?php echo number_format($aso_tra2['valanti'],2);?></td>
						<td align="right"><?php echo number_format($aso_tra2['poranti'],2);?></td>
						<td align="right"><?php echo number_format($aso_tra2['alimentacion'],2);?></td>
						<td align="right"><?php echo number_format($aso_tra2['movilizacion'],2);?></td>
						<td align="right"><?php echo number_format($aso_tra2['comision'],2);?></td>
						<td align="center"><?php echo $aso_tra2['de13'];?></td>
						<td align="center"><?php echo $aso_tra2['de14'];?></td>
						<td align="center"><?php echo $aso_tra2['fres'];?></td>
						<td align="right"><?php echo number_format($aso_tra2['total'],2);?></td>
					<?php } ?>
        
        
					<?php if(mb_stristr('guia',$tabla)){?>
					<?php $xcant=$aso_tra2['cant']; ?>
					<?php $xumdd=$aso_tra2['item_umdd']; ?>
						<td align="left"><?php echo $aso_tra2['item'];?></td>
						<td align="left"><?php echo $item_descri;?></td>
						<td align="left"><?php echo $aso_tra2['detalle'];?></td>
						<td align="<?php if($duni==0){echo 'center';}else{echo 'right';}?>" >
							<?php echo number_format($xcant,$duni);?>
						</td>
						<td align="left"><?php echo $xumdd;?></td>
        
        <?php
                                                          
					if($filax %$filag==0){$lrtb='B';}else{$lrtb='';}																																				 

          $posY=$docu_pdf->GetY();

          $docu_pdf->SetFont($ffamilyPDF,'',$fsizePDF-4);
          if(strlen(trim($icodigov))>5){$docu_pdf->SetFont($ffamilyPDF,'',$fsizePDF-5);}                                                               
          $docu_pdf->Cell($pdf_ancho*.1,5,$icodigov,$lrtb,0,'L',false);
          $docu_pdf->SetFont($ffamilyPDF,'',$fsizePDF-5);
          $posX=$docu_pdf->GetX();
          $col_width=$pdf_ancho*.3;
          $docu_pdf->MultiCell($col_width,5,utf8_decode($item_descri),$lrtb,'L',false);
          $posYb=$docu_pdf->GetY();
          $posX=$posX+$col_width;
          $docu_pdf->SetXY($posX,$posY);
                                                                         
          $docu_pdf->SetFont($ffamilyPDF,'',$fsizePDF-4);
          $docu_pdf->Cell($pdf_ancho*.1,5,number_format($xcant,2),$lrtb,0,'R',false);
          $docu_pdf->SetFont($ffamilyPDF,'',$fsizePDF-6);
          $docu_pdf->Cell($pdf_ancho*.03,5,$xumdd,$lrtb,0,'L',false);
          $docu_pdf->SetFont($ffamilyPDF,'',$fsizePDF-4);
          $docu_pdf->ln();

          $docu_pdf->SetY($posYb);
                                                                         
        ?>

        
					<?php } ?>
					<?php if(mb_stristr('vtas.comp.clie.carr.prov.inve.prod.comi.tfin',$tabla)){?>
					<?php $xcant=$aso_tra2['cant']; ?>
					<?php $xpuni=$aso_tra2['puni']; ?>
					<?php $xpvp=@$aso_tra2['pvp']; ?>
        
					<?php $xumdd=$aso_tra2['item_umdd']; ?>
        
					<?php $xsubt=$aso_tra2['tsubt']; ?>
					<?php $xdcto=$aso_tra2['tdcto']; ?>
					<?php $xprop=$aso_tra2['tprop']; ?>
					<?php $xice=$aso_tra2['tice']; ?>
					<?php $xiva=abs($aso_tra2['tiva']); ?>
					<?php $xirbp=$aso_tra2['tirbp']; ?>
					<?php $xttotal=$aso_tra2['total']; ?>
					<?php $xumdd=$aso_tra2['item_umdd']; ?>
					<?php $dpre=$aso_tra2['item_dpre']; ?>
					<?php $dcos=$aso_tra2['item_dcos']; ?>
					<?php if($dpre==0){$dpre=2;} ?>
					<?php $xcantp=$xcant/$xtcant*100; ?>

          <?php //costos ?>
					<?php //$xipuni=0; ?>
					<?php //$xpuni=0; ?>
					<?php //$xsubt=0; ?>
					<?php //$xttotal=0; ?>
					<?php //$xtotal=0; ?>
        
        
          <?php
            if(mb_stristr('comp.prov.inve.prod.tfin',$tabla))
            {
              $xxpuni=$xpuni;
              $xxpuni=trim($xpuni,'0');
              $xxpuni=substr($xxpuni,strpos($xxpuni,'.')+1);
//               $dpre=strlen($xxpuni);
            }
          ?>
          <?php //if(mb_stristr('comp.prov',$tabla)){$xumdd='';} ?>
          <?php if(($uxpre!=0 and $uxpre!=1)or($facon!=0 and $facon!=1)){$xumdd='';} ?>
			<?php if(mb_stristr('inve.prod',$tabla)){?>
					<td><?php echo $item_lsub;?></td>
               <?php } ?>
						<?php if(mb_stristr('vtas.clie.comi.carr.prod.comi',$tabla)){?>
						<td align="left"><span style="display:none;"><?php echo $aso_tra2['item'];?></span>
							<?php echo $icodigov;?></td>
						<?php }else{?>
						<td align="left"><?php echo $item_codigo;?></td>
						<?php } ?>
					<td align="left"  style="<?php if(substr($item_codigo,0,4)=='9900'){ echo 'font-size:75%;';} ?>">
						<?php echo $item_descri;?>
					</td>
					<td align="<?php if($duni==0){echo 'center';}else{echo 'right';}?>" >
						<?php echo number_format($xcant,$duni);?>
					</td>
					<td align="left" valign="" style="font-size:80%;">
						<?php echo $xumdd;?>
					</td>

<?php
             $docu_txt.=str_pad(''.$icodigov,13,$padtxt,STR_PAD_RIGHT);
             $docu_txt.=' |'.substr(str_replace($icodigov,'',$item_descri),0,$coltxt-14).$eol;
                                                                         
             $docu_txt.=str_pad(number_format($xcant,2),9,$padtxt,STR_PAD_LEFT).' '.$xumdd.'|';
             $docu_txt.=str_pad(number_format($xpuni,$dpre),9,$padtxt,STR_PAD_LEFT).'|';
//              $docu_txt.=str_pad(number_format($xsubt+$xiva,$dval),9,$padtxt,STR_PAD_LEFT).'|';
             $docu_txt.=str_pad(number_format($xttotal+$xdcto,$dval),9,$padtxt,STR_PAD_LEFT).'|';
             if($xiva>0){$docu_txt.='I';}
             $docu_txt.=$eol;
             if($xdcto>0)
             {$docu_txt.=''.str_pad('DCTO: '.number_format($xdcto,$dval),34,$padtxt,STR_PAD_LEFT);}
             $docu_txt.=$eol;
?>

        <?php
					if($filax %$filag==0){$lrtb='B';}else{$lrtb='';}																																				 

          $posY=$docu_pdf->GetY();

          $docu_pdf->SetFont($ffamilyPDF,'',$fsizePDF-4);
          if(strlen(trim($icodigov))>5){$docu_pdf->SetFont($ffamilyPDF,'',$fsizePDF-5);}                                                               
          $docu_pdf->Cell($pdf_ancho*.1,5,$icodigov,$lrtb,0,'L',false);
          $docu_pdf->SetFont($ffamilyPDF,'',$fsizePDF-5);
//           $docu_pdf->Cell($pdf_ancho*.3,5,substr(utf8_decode($item_descri),0,30),$lrtb,0,'L',false);

          $posX=$docu_pdf->GetX();
          $col_width=$pdf_ancho*.3;
          $docu_pdf->MultiCell($col_width,5,utf8_decode($item_descri),$lrtb,'L',false);
          $posYb=$docu_pdf->GetY();
          $posX=$posX+$col_width;
          $docu_pdf->SetXY($posX,$posY);
                                                                         
          $docu_pdf->SetFont($ffamilyPDF,'',$fsizePDF-4);
//           $docu_pdf->Cell($pdf_ancho*.1,5,number_format($xcant,2).' '.$xumdd,$lrtb,0,'R',false);
          $docu_pdf->Cell($pdf_ancho*.1,5,number_format($xcant,2),$lrtb,0,'R',false);
          $docu_pdf->SetFont($ffamilyPDF,'',$fsizePDF-6);
          $docu_pdf->Cell($pdf_ancho*.03,5,$xumdd,$lrtb,0,'L',false);
          $docu_pdf->SetFont($ffamilyPDF,'',$fsizePDF-4);
          $docu_pdf->Cell($pdf_ancho*.1,5,number_format($xpuni,$dpre),$lrtb,0,'R',false);
          $docu_pdf->Cell($pdf_ancho*.1,5,number_format($xsubt,$dval),$lrtb,0,'R',false);
          if($xtdcto>0)
          {$docu_pdf->Cell($pdf_ancho*.07,5,number_format($xdcto,$dval),$lrtb,0,'R',false);}
          if($xtice>0)
          {$docu_pdf->Cell($pdf_ancho*.05,5,number_format($xice,$dval),$lrtb,0,'R',false);}
          if($xtiva>0)
          {$docu_pdf->Cell($pdf_ancho*.05,5,number_format($xiva,$dval),$lrtb,0,'R',false);}
          $docu_pdf->Cell($pdf_ancho*.1,5,number_format($xttotal,$dval),$lrtb,0,'R',false);
                                                                                                  
          if(mb_stristr('tgck.sawo.ztej',$cfg_empr))
          {$docu_pdf->Cell($pdf_ancho*.1,5,$aso_tra2['vhcl'],$lrtb,0,'R',false);}
                                                                                                  
          $docu_pdf->ln();

          $docu_pdf->SetY($posYb);
//                              echo '*/*/*'.$dpre;                                            
        ?>

        <?php if($xipvp==1){ ?>
					<td align="right" style="<?php if($xipuni==0){echo 'display:;';}?>">
						<?php echo number_format($xpvp,$dpre);?></td>
        <?php }else{ ?>
        
        
          <?php if($xideta==1){ ?>
					<td align="right" style="<?php if($xipuni==0){echo 'display:none;';}?>">
						<?php echo number_format($xpuni,$dpre);?></td>
					<td align="right" style="<?php if($xipuni==0){echo 'display:none;';}?>">
						<?php echo number_format(abs($xsubt),$dval);?></td>
        
				<?php if(mb_stristr('vtas.comp.clie.carr.prov',$tabla)){?>
					<td align="right" style="<?php if($xipuni*$xtdcto==0){echo 'display:none;';}?><?php if($xdcto==0){echo 'font-size:70%;';}?>font-style: italic;" title="<?php echo number_format($aso_tra2['dcto'],$dval)."%";?>">
						<?php echo number_format($xdcto,$dval);?></td>
					<td align="right" style="<?php if($xipuni*$xtprop==0){echo 'display:none;';}?><?php if($xprop==0){echo 'font-size:70%;';}?>font-style: italic;" title="<?php echo number_format($aso_tra2['prop'],$dval)."%";?>">
						<?php echo number_format($xprop,$dval);?></td>
					<td align="right" style="<?php if($xipuni*$xtice==0){echo 'display:none;';}?><?php if($xice==0){echo 'font-size:70%;';}?>font-style: italic;" title="<?php echo number_format($aso_tra2['ice'],$dval)."%";?>">
						<?php echo number_format($xice,$dval);?></td>
					<td align="right" style="<?php if($xipuni*$xtiva==0){echo 'display:none;';}?><?php if($xiva==0){echo 'font-size:70%;';}?>font-style: italic;" title="<?php echo number_format($aso_tra2['iva'],$dval)."%";?>">
						<?php echo number_format($xiva,$dval);?></td>
					<td align="right" style="<?php if($xipuni*$xtirbp==0){echo 'display:none;';}?><?php if($xirbp==0){echo 'font-size:70%;';}?>font-style: italic;" title="<?php echo number_format($aso_tra2['irbp'],$dval)."";?>">
						<?php echo number_format($xirbp,$dval);?></td>
        <?php } ?>

          <?php } ?>
        
        <?php } ?>
        
					<td align="right" style="<?php if($xipuni==0){echo 'display:none;';}?>">
						<?php echo number_format(abs($xttotal),$dval);?>
            </td>
<?php        
// echo '<br>*/*/*'.$aso_tra2['detalle'];                                                          
// echo '<br>*/*/*'.$detalle;                                                          
 ?>                   
                    
          <td align="left" style="<?php if($xmdetalle==""){echo 'display:none;';}?>">
						<?php if(trim($detalle)!=trim($item_descri)){echo $detalle;};?></td>

          <?php if(mb_stristr('ecgl.',$cfg_empr)  and mb_stristr('clie.prod.vtas',$tabla)  ) {?>
              <?php if(mb_stristr($aso_tra2['item_descri'],'PERFOR')) {?>
                <td align="left" colspan="5" style=""><?php echo $aso_tra2['perfor1']; ?></td>
              <?php}?>	
              <?php if(mb_stristr($aso_tra2['item_descri'],'SAQUE')) {?>
                <td align="left" colspan="5" style=""><?php echo $aso_tra2['saques1']; ?></td>
              <?php}?>	
          <?php}?>	
        

          <?php}?>	

					<?php if($empr_cont=='1' and ($tabla=='comp' or $docu=='APX10')) {?>
					<td align="left" colspan="1" style="<?php if($xmctas==""){echo 'display:none;';}?>">
            <?php echo $aso_tra2['ctas'];?>
          </td>
					<td align="left" colspan="1" style="<?php if($xmctas==""){echo 'display:none;';}?>">
            <?php echo '<span style="font-size:75%;">'.$aso_tra2['ctas_descri'].'</span>'; ?>
            <?php //echo '<span style="font-size:75%;">'.$ctas_descri.'</span>'; ?>
          </td>
              <?php if(mb_stristr('FP15',$docu)){?>
              <td align="right"><div style="display:none;">
                <?php echo fillzero($aso_tra2['peso'],9); ?></div><?php echo number_format($aso_tra2['peso'],2);?>
              </td>
              <td align="left"><?php echo $aso_tra2['arcl'];?></td>
              <?php } ?>
              <?php if(mb_stristr('FP16',$docu)){?>
              <td align="left"><?php echo $aso_tra2['arcl'];?></td>
              <td align="right"><div style="display:none;">
                <?php echo fillzero($aso_tra2['adva'],9); ?></div><?php echo number_format($aso_tra2['adva'],2);?>
              </td>
              <td align="right"><div style="display:none;">
                <?php echo fillzero($aso_tra2['espe'],9); ?></div><?php echo number_format($aso_tra2['espe'],2);?>
              </td>
              <td align="right"><div style="display:none;">
                <?php echo fillzero($aso_tra2['dump'],9); ?></div><?php echo number_format($aso_tra2['dump'],2);?>
              </td>
              <td align="right"><div style="display:none;">
                <?php echo fillzero($aso_tra2['fodi'],9); ?></div><?php echo number_format($aso_tra2['fodi'],2);?>
              </td>
              <?php } ?>
              <?php if(!mb_stristr('FP15.DA16.FP16',$docu)){?>
              <td align="center"><?php echo $aso_tra2['cair'];?></td>
              <td align="center"><div style="display:none;">
                <?php echo fillzero($aso_tra2['prrta'],9); ?></div><?php echo number_format($aso_tra2['prrta'],2);?>
              </td>
              <td align="center"><div style="display:none;">
                <?php echo fillzero($aso_tra2['priva'],9); ?></div><?php echo number_format($aso_tra2['priva'],2);?>
              </td>
              <?php } ?>
					<?php}?>	
					
					<?php if(mb_stristr('retc.retp',$tabla)){?>
					<td align="center"><?php echo $aso_tra2['fanio'];?></td>
					<td align="right" style="<?php if(mb_stristr('retc.retp',$tabla)){echo 'padding-right:20px;';}?>">
						<?php echo number_format($aso_tra2['cant'],2);?></td>
					<?php
						$cair='('.$aso_tra2['cair'].')';
						$docum_descri=$aso_tra2['docum_descri'];
						if(substr($aso_tra2['docum_descri'],0,4)=='FACT'){$docum_descri='FACTURA';}
						if($aso_tra2['biva']>0)
						{$cair_descri='IVA';}
						else
						{$cair_descri=$aso_tra2['cair_descri']; $cair='<br>'.$cair;}
					?>
					<td align="center"><?php echo $cair_descri.' '.$cair;?></td>
					<?php if(ceil($aso_tra2['puni'])==floor($aso_tra2['puni'])){$dval=0;} ?>
					<td align="center">
						<?php echo number_format($aso_tra2['puni'],$dval);?>%</td>
					<td align="right" style="<?php if(mb_stristr('retc.retp',$tabla)){echo 'padding-right:20px;';}?>">
						<?php echo number_format(abs($aso_tra2['total']),2);?></td>
					<td align="center"><?php echo $docum_descri;?></td>
          <?php if($cdisplay==1){?>
					<?php
            if($tabla=='retc'){$tdocum='vtas1';}
            if($tabla=='retp'){$tdocum='comp1';}
            $sql_docum ='select * from '.$tdocum.' ';
            $sql_docum.='where numero="'.$aso_tra2['numer'].'" and ptoe="'.$aso_tra2['ptoem'].'" ';
            $sql_docum.=' and enti="'.$aso_tra2['enti'].'" and status !="O" and status!="X"';
            $res_docum=msql_query($sql_docum,$link_vcrx);
//             echo '*/*/'.msql_error().$sql_docum;
            $clavedocum=@msql_result($res_docum,0,'claveacc');                    
            $idnumdocum=@msql_result($res_docum,0,'idnum1');                                    
            $docudocum=@msql_result($res_docum,0,'docu');                                    
          ?>	
					<td align="center">
            <?php if($clavedocum!=""){?>
                <?php if(mb_stristr($clavedocum,$cfg_ruc)){?>
                  <a href="<?php echo 'https://'.$cfg_empr.'.vcrxol.com/?prnt=1&clave='.$clavedocum;?>"  target="_blank" >
                <?php }else{ ?>
                  <a href="<?php echo 'https://'.'demo'.'.vcrxol.com/?prnt=1&clave='.$clavedocum;?>"  target="_blank" >
                <?php }?>
            <?php }else{ ?>
                <?php if($idnumdocum!=""){?>
                <a href="<?php echo 'https://'.$cfg_empr.'.vcrxol.com/?prnt=1&docu='.$docudocum.'&idnum='.$idnumdocum.'&formato='.$formato;?>"  target="_blank" >
                <?php }?>
            <?php }?>
                <?php echo $aso_tra2['ptonumer'];?>
                </a>
          </td>
					<?php}else{?>	
					<td align="center"><?php echo $aso_tra2['ptonumer'];?></td>
					<?php}?>	
				<?php
					$cair=str_replace('<br>','',$cair);
					$cair_descri=str_replace('<br>','',$cair_descri);
					if($filax %$filag==0){$lrtb='B';}else{$lrtb='';}

                                                
          $posY=$docu_pdf->GetY();
          $docu_pdf->SetFont($ffamilyPDF,'',$fsizePDF-3);
          $docu_pdf->Cell($pdf_ancho*.1,5,$aso_tra2['fanio'],$lrtb,0,'C',false);
          $docu_pdf->Cell($pdf_ancho*.1,5,number_format($aso_tra2['cant'],2),$lrtb,0,'R',false);
// 					$cair_descri=str_repeat(' 2 4 6 8 0',8);
					if(strlen($cair_descri)>25)
					{$docu_pdf->SetFont($ffamilyPDF,'',$fsizePDF-4);}
					if(strlen($cair_descri)>50)
					{$docu_pdf->SetFont($ffamilyPDF,'',$fsizePDF-5);}
					if(strlen($cair_descri)>75)
					{$docu_pdf->SetFont($ffamilyPDF,'',$fsizePDF-6);}
//           $docu_pdf->Cell($pdf_ancho*.3,5,$cair_descri.' '.$cair,$lrtb,0,'C',false);

          $posX=$docu_pdf->GetX();
          $col_width=$pdf_ancho*.3;
          $docu_pdf->MultiCell($col_width,5,$cair.' '.$cair_descri,$lrtb,'C',false);
          $posYb=$docu_pdf->GetY();
          $posX=$posX+$col_width;
          $docu_pdf->SetXY($posX,$posY);
                                                
                                                
          $docu_pdf->SetFont($ffamilyPDF,'',$fsizePDF-3);
//           $docu_pdf->Cell($pdf_ancho*.1,5,number_format(abs($aso_tra2['puni']),0).'%',$lrtb,0,'C',false);
          $docu_pdf->Cell($pdf_ancho*.1,5,number_format(abs($aso_tra2['puni']),2).'%',$lrtb,0,'C',false);
          $docu_pdf->Cell($pdf_ancho*.1,5,number_format(abs($aso_tra2['total']),2),$lrtb,0,'R',false);
//           $docu_pdf->SetFont($ffamilyPDF,'',$fsizePDF-4);
          $docu_pdf->Cell($pdf_ancho*.15,5,$docum_descri,$lrtb,0,'C',false);
          $docu_pdf->Cell($pdf_ancho*.15,5,$aso_tra2['ptonumer'],$lrtb,0,'C',false);
          $docu_pdf->ln();


          $docu_pdf->SetY($posYb);
				?>
					<?php}?>	

					<?php if(mb_stristr('caja.bcos.dxco.dxpa',$tabla)){?>
					<?php 	$docum_descri=$aso_tra2['docum_descri'];?>
					<td align="center"><?php echo $docum_descri;?></td>

          <td align="center">
            <?php $xidfrom=$aso_tra2['idfrom'];?>
            <?php
              if($xidfrom=='')
              {
                $tdocum=r_fiel('docu',$aso_tra2['docum'],'tabla');
                $sql_docum ='select * from '.$tdocum.'1 ';
//                 $sql_docum.=' where numero="'.$aso_tra2['numer'].'" and ptoe="'.$aso_tra2['ptoem'].'" ';
                $sql_docum.=' where docu="'.$aso_tra2['docum'].'" and numero="'.$aso_tra2['numer'].'" and ptoe="'.$aso_tra2['ptoem'].'" ';
                $sql_docum.=' and enti like "'.substr($aso_tra2['enti'],0,10).'%" ';
                $sql_docum.=' and status not in("O","X")';
                $res_docum=msql_query($sql_docum,$link_vcrx);
//                 echo msql_error($res_docum). $sql_docum;
                
                if(@msql_num_rows($res_docum)==0)
                {
                  
                }
//                 echo '*/*/*/'.$tdocum.$xidfrom.$sql_docum;
                $xidfrom=@msql_result($res_docum,0,'idnum1');
              }
            ?>
            <?php if($xidfrom!=''){ ?>
            <a href="<?php echo 'https://'.$cfg_empr.'.vcrxol.com/?prnt=1&docu='.$aso_tra2['docum'].'&idnum='.$xidfrom.'&formato='.$formato;?>"  target="_blank" >
            <?php } ?>
            <?php echo $aso_tra2['ptonumer'];?>
            </a>
          </td>
					<td align="right" >
						<?php echo number_format($aso_tra2['cant'],2);?></td>
          <?php if(mb_stristr('dxco.dxpa',$tabla)){?>
					<td align="right" >
						<?php echo number_format($aso_tra2['puni'],2);?></td>
					<td align="right" >
						<?php echo number_format($aso_tra2['total'],2);?></td>
          <?php } ?>
					<td align="center"><?php echo $aso_tra2['ctas'];?></td>
<!-- 					<td align="left"><?php //echo $aso_tra2['ctas_descri'];?></td> -->
					<td align="left"><?php echo $ctas_descri;?></td>
					<td align="left"><?php echo $detalle;?></td>
					<?php}?>	
                    
					<?php if(mb_stristr('vtas.clie.inve.prod.tfin',$tabla)){?>
					<td align="center" style="<?php if($xmlote==''){echo 'display:none;';} ?>">
                              <?php echo $aso_tra2['lote'];?>
                         </td>
                         <?php } ?>
                    
					<?php if(mb_stristr('inve.prod.tfin',$tabla)){?>
					<td align="left" style="<?php if($xmserie==''){echo 'display:none;';} ?>"><?php echo $aso_tra2['numserie'];?></td>
                         <?php } ?>
                    
					<?php if(substr($docu,0,2)=='EB'){?>
					<td style="color:red; font-size:1.8em;">
                              <?php
                                    $salitem=sal_item($aso_tra2['item'],'',$aso_tra2['fecha'],$aso_tra2['bode'],$aso_tra2['lote']);
                                   if($salitem[4]<0)
                                   {echo ' *';}
                              ?>
                         </td>
                         <?php } ?>
                    
            <?php if(mb_stristr('IB11.EB11',$docu)){ ?>
            <?php $itemcambio=$aso_tra2['cambio'].' - '.r_fiel('item',$aso_tra2['cambio']); ?>
            <?php $itemcambio=split_words($itemcambio);?>
            <td><?php echo $itemcambio; ?></td>
            <?php } ?>

                    
          <?php if(mb_stristr('DA16',$docu) and $formato==5){?>
          <?php 
              $xcant=$aso_tra2['cant'];
              $xsubt=abs($aso_tra2['tsubt']);
              $xpeso=abs($aso_tra2['peso']);
              $xarcl=$aso_tra2['arcl'];
                                   
              $costoe1=$aso_tra2['costoe1']; 
              $costoe1d=$aso_tra2['costoe1d']; 
              if($costoe1d==1){$costoe2=abs($costoe1/$xtunid*$xcant);}
              if($costoe1d==2){$costoe2=abs($costoe1/$xtsubt*$xsubt);}
              if($costoe1d==3){$costoe2=abs($costoe1/$xtpeso*$xpeso);}
              $fob2=$xsubt+$costoe2;
          
              $seguro1=$aso_tra2['seguro1']; 
              $seguro1d=$aso_tra2['seguro1d']; 
              if($seguro1d==1){$seguro2=abs($seguro1/$xtunid*$xcant);}
              if($seguro1d==2){$seguro2=abs($seguro1/$xtsubt*$xsubt);}
              if($seguro1d==3){$seguro2=abs($seguro1/$xtpeso*$xpeso);}
          
              $flete1=$aso_tra2['flete1']; 
              $flete1d=$aso_tra2['flete1d']; 
              if($flete1d==1){$flete2=abs($flete1/$xtunid*$xcant);}
              if($flete1d==2){$flete2=abs($flete1/$xtsubt*$xsubt);}
              if($flete1d==3){$flete2=abs($flete1/$xtpeso*$xpeso);}
          
              $cif2=$fob2+$seguro2+$flete2;

              $adva2=abs($aso_tra2['adva']); 
              $espe2=abs($aso_tra2['espe']);
              $dump2=abs($aso_tra2['dump']);
              $fodi2=abs($aso_tra2['fodi']);
              $iva2=abs($aso_tra2['ivai']);
              $isd2=$fob2*r_fiel('arcl',$xarcl,'isd')/100;


              $costol1=$aso_tra2['costol1']; 
              $costol1d=$aso_tra2['costol1d']; 
              if($costol1d==1){$costol2=abs($costol1/$xtunid*$xcant);}
              if($costol1d==2){$costol2=abs($costol1/$xtsubt*$xsubt);}
              if($costol1d==3){$costol2=abs($costol1/$xtpeso*$xpeso);}
          
//               $costot2=$cif2+$adva2+$fodi2+$isd2+$costol2;
              $costot2=$cif2+$adva2+$espe2+$dump2+$fodi2+$isd2+$costol2;
          
//           echo '<br>';
//           echo '<br>'.$cif2;
//           echo '<br>'.$adva2;
//           echo '<br>'.$fodi2;
//           echo '<br>'.$isd2;
//           echo '<br>'.$costol2;
          
              $costou2=$costot2/$xcant;
// echo '*/*/*/'.$costou2;
          
              $xtfob+=$fob2;
              $xtseguro+=$seguro2;
              $xtflete+=$flete2;
              $xtcif+=$cif2;
              $xtadva+=$adva2;
              $xtespe+=$espe2;
              $xtdump+=$dump2;
              $xtfodi+=$fodi2;
              $xtivai+=$ivai2;
              $xtisd+=$isd2;
              $xtcostol+=$costol2;
              $xtcostot+=$costot2;
          
//           echo '*/*/*/*'.$xtadva;
          
              $sql_cuni='update '.$tabla.'2 set cuni='.round($costou2,6).' where idnum2='.$idnum.' and iddet='.$iddet.'';
              $res_cuni=msql_query($sql_cuni,$link_vcrx);
          
          
              if($costou2<2)
              {
              $decimales = explode('.',$costou2);
//           echo $decimales[1];
              $cdeci=strlen($decimales[1]);
              if($cdeci==0){$dcos=0;}
              if($cdeci>=1){$dcos=2;}
              if($cdeci>=3){$dcos=4;}
              if($cdeci>=5){$dcos=6;}
              }
                         
                         
              
          
//           echo $sql_cuni;
//               echo msql_error($link_vcrx);
         
          ?>
          <td align="right" style="<?php if($xpeso==0){echo 'display:;';}?>" >
            <div style="display:none;">
            <?php echo fillzero($xpeso,9); ?></div><?php echo number_format($xpeso,2);?>
          </td>
          <td align="left" style="<?php if($xmarcl==''){echo 'display:;';}?>"><?php echo $aso_tra2['arcl'];?></td>
          <td align="right" style="<?php if($costoe1==0){echo 'display:none;';}?>" >
            <div style="display:none;">
            <?php echo fillzero($costoe2,9); ?></div><?php echo number_format($costoe2,2);?>
          </td>
          <td align="right"><div style="display:none;">
            <?php echo fillzero($fob2,9); ?></div><?php echo number_format($fob2,2);?>
          </td>
          <td align="right"><div style="display:none;">
            <?php echo fillzero($seguro2,9); ?></div><?php echo number_format($seguro2,2);?>
          </td>
          <td align="right"><div style="display:none;">
            <?php echo fillzero($flete2,9); ?></div><?php echo number_format($flete2,2);?>
          </td>
          <td align="right"><div style="display:none;">
            <?php echo fillzero($cif2,9); ?></div><?php echo number_format($cif2,2);?>
          </td>
          <td align="right" style="<?php if($xadva==0){echo 'display:none;';}?>"><div style="display:none;">
            <?php echo fillzero($adva2,9); ?></div><?php echo number_format($adva2,2);?>
          </td>
          <td align="right" style="<?php if($xespe==0){echo 'display:none;';}?>"><div style="display:none;">
            <?php echo fillzero($espe2,9); ?></div><?php echo number_format($espe2,2);?>
          </td>
          <td align="right" style="<?php if($xdump==0){echo 'display:none;';}?>"><div style="display:none;">
            <?php echo fillzero($dump2,9); ?></div><?php echo number_format($dump2,2);?>
          </td>
          <td align="right" style="<?php if($xfodi==0){echo 'display:none;';}?>"><div style="display:none;">
            <?php echo fillzero($fodi2,9); ?></div><?php echo number_format($fodi2,2);?>
          </td>
          <td align="right" style="<?php if($xivai==0){echo 'display:none;';}?>"><div style="display:none;">
            <?php echo fillzero($ivai2,9); ?></div><?php echo number_format($ivai2,2);?>
          </td>
          <td align="right" style="<?php if($xmisdi==0){echo 'display:none;';}?>"><div style="display:none;">
            <?php echo fillzero($isd2,9); ?></div><?php echo number_format($isd2,2);?>
          </td>
          <td align="right"><div style="display:none;">
            <?php echo fillzero($costol2,9); ?></div><?php echo number_format($costol2,2);?>
          </td>
          <td align="right"><div style="display:none;">
            <?php echo fillzero($costot2,9); ?></div><?php echo number_format($costot2,2);?>
          </td>
          <td align="right"><div style="display:none;">
            <?php echo fillzero($costou2,9); ?></div><?php echo number_format($costou2,$dcos);?>
          </td>
          <?php } ?>
                    
                    
                    
          <?php if(mb_stristr('plan.atvd',$tabla)){?>
					<td align="center"><?php echo $aso_tra2['asub'];?></td>
					<td align="left"><?php echo $aso_tra2['asub_descri'];?></td>
					<td align="right" >
						<?php echo number_format($aso_tra2['cant'],2);?>
					</td>
               <?php if(mb_stristr('atvd',$tabla)){?>
					<td align="center"><?php echo $aso_tra2['empr2'];?></td>
					<td align="center"><?php echo $aso_tra2['numerpla'];?></td>
                <?php}?>
               <?php if(mb_stristr('plan',$tabla)){?>
					<td align="center"><?php echo $aso_tra2[''];?></td>
                <?php}?>
					<td align="left"><?php echo r_fiel('enti',$aso_tra2['enti2']);
//                                                 echo ' - '. $aso_tra2['numerpla'];?></td>
					<td align="right" >
						<?php echo number_format($aso_tra2['puni'],2);?>
					</td>
					<td align="right" >
						<?php echo number_format($aso_tra2['tsubt'],2);?>
					</td>
          <?php}?>
        
        
          <?php if($cfg_empr=='pcs1' and substr($docu,0,2)=='FC' and $aso_tra2['cntn']!="") {?>
            <td align="center" style="font-family:courier;"><?php echo $aso_tra2['cntn'];?></td>
            <td align="center"><?php echo date('d/M/y',strtotime($aso_tra2['cntnf1']));?></td>
            <td align="center"><?php echo date('d/M/y',strtotime($aso_tra2['cntnf2']));?></td>
          <?php }?>
					
          <?php if(mb_stristr('tgck.sawo.ztej',$cfg_empr)  and substr($docu,0,2)=='FC' and $aso_tra2['vhcl']!="") {?>
            <td align="left">
              <?php
                $avhcl=$aso_tra2['vhcl'];
                echo $avhcl;
                if($avhcl!=$lvhcl)
                {echo '<td>'.r_fiel('vhcl',$avhcl).'</td>'; $lvhcl=$avhcl;}
              ?>
            </td>
          <?php }?>
	
          <?php //if(1==1) {?>
          <?php if($cfg_empr=='imcp' and (substr($docu,0,2)=='FC' or substr($docu,0,2)=='PF') and $aso_tra2['item_descri2']!="") {?>
            <td align="left">
              <?php echo $aso_tra2['item_descri2']; ?>
            </td>
          <?php }?>
	
          <?php //{?>
          <?php if($cfg_empr=='imcp' and substr($docu,0,2)=='PF' and $aso_tra2['lote']==""  ) {?>
            <td align="left">
              <?php echo 'L: '.lote_disp($aso_tra2['item']); ?>
            </td>
          <?php }?>

          <?php
            $clor_codigo=$aso_tra2['item_clor'];
            $clor_descri='';
            $clor_hexa='';
            if((int)$clor_codigo*1>0)
            {
              $sql_clor='select * from clor0 where clor_codigo="'.$clor_codigo.'"';
              $res_clor=msql_query($sql_clor,$link_vcrx);
              $clor_descri=msql_result($res_clor,0,'clor_descri');
              $clor_hexa=msql_result($res_clor,0,'clor_hexa');
            }
          ?>
                    
          <?php if(mb_stristr('gmny.gnya',$cfg_empr) and mb_stristr('vtas.clie.carr.prod.inve',$tabla)) {?>
            <td align="center" style="font-size:80%; font-weight:bold; color:black; background:<?php echo $clor_hexa; ?>;"><?php {echo $clor_descri;}?></td>
            <td align="center"  style="font-size:80%;" ><?php if((int)$aso_tra2['item_tlla']>0){echo substr(r_fiel('tlla',$aso_tra2['item_tlla']),0,6);}?></td>
          <?php }?>
                    
                    
                    
				</tr>
		<?php}?>	
			
		<?php if($marcas==1){?>
			<?php $sql_mrca='select distinct item_mrca from '.$tabla.'12 where idnum2="'.$idnum.'" and item_mrca!="" and item_mrca is not null and item_mrca!="-"';?>
			<?php $res_mrca=msql_query($sql_mrca,$link_vcrx);	?>
			<tr id="logomarcas"><td colspan="10">
			<?php while($aso_mrca=msql_fetch_assoc($res_mrca)){?>	
				<?php //$mrcafile=strtolower('mrca'.$aso_mrca['item_mrca'].'.png');?>
				<?php $mrcafile=strtolower($aso_mrca['item_mrca'].'.png');?>
				<?php if(file_exists($rutamrca.$mrcafile) or 1==1){ ?>
					<?php $crow++; ?>
					<img src="<?php echo 'https://'.$cfg_empr.'.vcrxol.com/mrca/'.$mrcafile; ?>" alt=""
							 title="<?php echo ''; ?>" style="max-width:100%; max-height:10mm;">		
				<?php } ?>
			<?php}?>	
			</tr></td>
		<?php}?>	
			
			<?php $mindeta=$mindeta-$crow; ?>
			<?php for($clinbr=1;$clinbr<=$mindeta;$clinbr++){?>
			<tr><?php echo str_repeat('<td><br></td>',$ccol); ?></tr>
			<?php } ?>
		</tbody>
		<tfoot>
		<tr style="background:<?php echo $gris1;?>; border-top:solid 1px; border-bottom:solid 1px; font-weight:bolder;">
			
			<?php if(mb_stristr('cont',$tabla)){?>
				<th></th>
				<th  colspan=1 style="letter-spacing: 5px;">TOTAL</th>
				<th align="right"><?php echo number_format($xtdebito,2);?></th>
				<th align="right"><?php echo number_format($xtcredito,2);?></th>
			<?php}?>
         
			<?php if(mb_stristr('susa',$tabla)){$xtotal=0;}?>
			
			<?php if(mb_stristr('guia',$tabla)){?>
				<th></th>
				<th  colspan=1 style="letter-spacing: 5px;">TOTAL</th>
				<th></th>
      
      <?php
          $lrtb='TB';                                                                  
          $docu_pdf->SetFont($ffamilyPDF,'B',$fsizePDF-4);
          $docu_pdf->Cell($pdf_ancho*.1,5,' ',$lrtb,0,'L',true);
          $docu_pdf->SetFont($ffamilyPDF,'B',$fsizePDF-5);
          $docu_pdf->Cell($pdf_ancho*.3,5,'TOTALES',$lrtb,0,'C',true);
          $docu_pdf->SetFont($ffamilyPDF,'B',$fsizePDF-4);
          $docu_pdf->Cell($pdf_ancho*.1,5,number_format($xtcant,2),$lrtb,0,'R',true);
          $docu_pdf->Cell($pdf_ancho*.03,5,'',$lrtb,0,'R',true);
          $docu_pdf->Cell($pdf_ancho*.1,5,'',$lrtb,0,'R',true);
//           $docu_pdf->Cell($pdf_ancho*.1,5,number_format($xtsubt,$dval),$lrtb,0,'R',true);
//           if($xtdcto>0)
//           {$docu_pdf->Cell($pdf_ancho*.07,5,number_format($xtdcto,$dval),$lrtb,0,'R',true);}
//           if($xtice>0)
//           {$docu_pdf->Cell($pdf_ancho*.05,5,number_format($xtice,$dval),$lrtb,0,'R',true);}
//           if($xtiva>0)
//           {$docu_pdf->Cell($pdf_ancho*.05,5,number_format($xtiva,$dval),$lrtb,0,'R',true);}
// //           $docu_pdf->Cell($pdf_ancho*.1,5,'',$lrtb,0,'R',false);
//           $docu_pdf->Cell($pdf_ancho*.1,5,number_format($xtotal,$dval),$lrtb,0,'R',true);
          $docu_pdf->ln();
        ?>
      
			<?php}?>

			<?php if(mb_stristr('inve.prod',$tabla)){?>
				<th></th>
			<?php}?>
			
			<?php if(mb_stristr('vtas.comp.clie.carr.prov.inve.prod.comi.plan.atvd.tfin.',$tabla)){?>
				<th></th>
				<th  colspan=1 style="letter-spacing: 5px;">TOTALES</th>
				<?php if(ceil($xtcant)!=floor($xtcant)  and $duni==0){$duni=2;} ?>
				<th align="<?php if($duni==0){echo 'center';}else{echo 'right';}?>">
          <?php echo number_format($xtcant,$duni).'';?>
        </th>
				<th></th>

        <?php if($xipvp==1){ ?>
				<th style="<?php if($xipuni==0){echo 'display:none;';}?>"></th>
        <?php }else{ ?>
				<th style="<?php if($xipuni==0){echo 'display:none;';}?>"></th>
				<th align="right" style="<?php if($xipuni==0){echo 'display:none;';}?>"><?php echo number_format(abs($xtsubt),$dval).'';?></th>
				<?php if(mb_stristr('vtas.comp.clie.carr.prov',$tabla)){?>
					<th align="right" style="<?php if($xipuni*$xtdcto==0){echo 'display:none;';}?>font-style: italic;"><?php echo number_format($xtdcto,$dval);?></th>
					<th align="right" style="<?php if($xipuni*$xtprop==0){echo 'display:none;';}?>font-style: italic;"><?php echo number_format($xtprop,$dval);?></th>
					<th align="right" style="<?php if($xipuni*$xtice==0) {echo 'display:none;';}?>font-style: italic;"><?php echo number_format($xtice,$dval);?></th>
					<th align="right" style="<?php if($xipuni*$xtiva==0) {echo 'display:none;';}?>font-style: italic;"><?php echo number_format($xtiva,$dval);?></th>
					<th align="right" style="<?php if($xipuni*$xtirbp==0){echo 'display:none;';}?>font-style: italic;"><?php echo number_format($xtirbp,$dval);?></th>
				<?php}?>

        <?php } ?>
      
      <?php
          $lrtb='TB';                                                                  
          $docu_pdf->SetFont($ffamilyPDF,'B',$fsizePDF-4);
          $docu_pdf->Cell($pdf_ancho*.1,5,' ',$lrtb,0,'L',true);
          $docu_pdf->SetFont($ffamilyPDF,'B',$fsizePDF-5);
          $docu_pdf->Cell($pdf_ancho*.3,5,'TOTALES',$lrtb,0,'C',true);
          $docu_pdf->SetFont($ffamilyPDF,'B',$fsizePDF-4);
          $docu_pdf->Cell($pdf_ancho*.1,5,number_format($xtcant,2),$lrtb,0,'R',true);
          $docu_pdf->Cell($pdf_ancho*.03,5,'',$lrtb,0,'R',true);
          $docu_pdf->Cell($pdf_ancho*.1,5,'',$lrtb,0,'R',true);
          $docu_pdf->Cell($pdf_ancho*.1,5,number_format($xtsubt,$dval),$lrtb,0,'R',true);
          if($xtdcto>0)
          {$docu_pdf->Cell($pdf_ancho*.07,5,number_format($xtdcto,$dval),$lrtb,0,'R',true);}
          if($xtice>0)
          {$docu_pdf->Cell($pdf_ancho*.05,5,number_format($xtice,$dval),$lrtb,0,'R',true);}
          if($xtiva>0)
          {$docu_pdf->Cell($pdf_ancho*.05,5,number_format($xtiva,$dval),$lrtb,0,'R',true);}
//           $docu_pdf->Cell($pdf_ancho*.1,5,'',$lrtb,0,'R',false);
          $docu_pdf->Cell($pdf_ancho*.1,5,number_format(abs($xtotal),$dval),$lrtb,0,'R',true);
          
               
                                                                                                   
          $docu_pdf->ln();
        ?>

			<?php}?>
			
			<?php if(mb_stristr('retc.retp',$tabla)){?>
			<?php $dval=2; ?>
			<th></th>
			<th></th>
			<th  colspan=1 style="letter-spacing: 5px;">TOTALES</th>
			<th></th>
      <?php
          $lrtb='TB';                                                                  
          $docu_pdf->SetFont($ffamilyPDF,'B',$fsizePDF-3);
          $docu_pdf->Cell($pdf_ancho*.1,5,' ',$lrtb,0,'L',true);
          $docu_pdf->Cell($pdf_ancho*.1,5,' ',$lrtb,0,'L',true);
          $docu_pdf->Cell($pdf_ancho*.3,5,'TOTALES',$lrtb,0,'C',true);
          $docu_pdf->Cell($pdf_ancho*.1,5,'',$lrtb,0,'R',true);
          $docu_pdf->Cell($pdf_ancho*.1,5,number_format(abs($xtotal),$dval),$lrtb,0,'R',true);
          $docu_pdf->Cell($pdf_ancho*.15,5,' ',$lrtb,0,'L',true);
          $docu_pdf->Cell($pdf_ancho*.15,5,' ',$lrtb,0,'L',true);
          $docu_pdf->ln();
        ?>
			<?php } ?>
			
			<?php if(mb_stristr('caja.bcos.dxco.dxpa',$tabla)){?>
			<?php $dval=2; ?>
			<th></th>
			<th  colspan=1 style="letter-spacing: 5px;">TOTAL</th>
			<?php } ?>
			<?php if(mb_stristr('dxco.dxpa',$tabla)){?>
      <th align="right"><?php echo number_format($xtcant,2); ?></th>
      <th></th>
			<?php } ?>
			
				<?php if(mb_stristr('nomi.empl',$tabla)){?>
      <th></th>
			<?php } ?>
				<?php if(mb_stristr('nomi.empl',$tabla)){?>
        <?php $xtcant=0; //dias ?>
        <?php $xtotal=0; ?>
        <?php $xipuni=0; ?>
				<th></th>
        <th colspan=1 style="letter-spacing: 5px;">TOTALES</th>
				<?php if(mb_stristr('nomi.',$tabla)){?>
        <th></th>
        <th></th>
        <?php } ?>
        <th align="right">
          <?php //echo number_format($xtcant,2);?>
        </th>
        <th></th>
        <th align="right">
          <?php echo number_format($xtremun,2);?>
        </th>
        <th align="right">
          <?php echo number_format($xtdeduc,2);?>
        </th>
        <th align="right">
          <?php echo number_format($xtprovi,2);?>
        </th>
        <?php } ?>
      
      
			<th align="right" 
          style="<?php if(mb_stristr('retc.retp',$tabla)){echo 'padding-right:20px;';}?>
                 <?php if($xipuni==0){echo 'display:none;';}?>">
				<?php
                         if($docu=='DA16'){$xtotal=$xtsubt;}
					if(mb_stristr('cont',$tabla))
					{
						if(abs($xdifer)>$saldo0)
						{
							echo '<div style="color:red;">';
							echo number_format(abs($xdifer),$dval);
							echo '</div>';
						}
					}
					else{echo number_format(abs($xtotal),$dval);}
				?>
			</th>

			<th align="right" style="<?php if($xmdetalle==""){echo 'display:none;';}?>"></th>
         
      <?php if(@mb_stristr('FP15',$docu)){?>
        <th><?php echo number_format($xtpeso,2); ?></th>
      <?php } ?>
      
      <?php if(@mb_stristr('DA16',$docu)){?>
        <th style="<?php if($xtpeso==0){echo 'display:;';} ?>"><?php echo number_format($xtpeso,2); ?></th>
        <th style="<?php if($xmarcl==''){echo 'display:;';} ?>"></th>
        <th style="<?php if($costoe1==0){echo 'display:none;';} ?>"><?php echo number_format($costoe1,2); ?></th>
        <th><?php echo number_format($xtfob,2); ?></th>
        <th><?php echo number_format($xtseguro,2); ?></th>
        <th><?php echo number_format($xtflete,2); ?></th>
        <th><?php echo number_format($xtcif,2); ?></th>
        <th style="<?php if($xadva==0){echo 'display:none;';} ?>"><?php echo number_format($xtadva,2); ?></th>
        <th style="<?php if($xespe==0){echo 'display:none;';} ?>"><?php echo number_format($xtespe,2); ?></th>
        <th style="<?php if($xdump==0){echo 'display:none;';} ?>"><?php echo number_format($xtdump,2); ?></th>
        <th style="<?php if($xfodi==0){echo 'display:none;';} ?>"><?php echo number_format($xtfodi,2); ?></th>
        <th style="<?php if($xivai==0){echo 'display:none;';} ?>"><?php echo number_format($xtivai,2); ?></th>
        <th style="<?php if($xmisdi==0){echo 'display:none;';} ?>"><?php echo number_format($xtisd,2); ?></th>
        <th><?php echo number_format($xtcostol,2); ?></th>
        <th><?php echo number_format($xtcostot,2); ?></th>
      <?php } ?>
      
      <?php if($cfg_empr=='pcs1' and substr($docu,0,2)=='FC' and $xmcntn!="") {?>
        <th></th>
        <th></th>
        <th></th>
      <?php } ?>
      
      <?php if(mb_stristr('tgck.sawo.ztej',$cfg_empr)  and substr($docu,0,2)=='FC' and $xmvhcl!="") {?>
        <th></th>
      <?php } ?>

      <?php if(mb_stristr('gmny.gnya',$cfg_empr) and mb_stristr('vtas.clie.carr.prod.inve',$tabla)) {?>
        <th></th>
        <th></th>
      <?php } ?>
      
	
		</tr>
		</tfoot>
		</table>
		</detalle>


          <?php
             $docu_txt.=str_repeat('-',$coltxt).$eol.$eol;
             $colval=12;
             $docu_txt.=str_pad('RESUMEN ',$coltxt,$carbot,STR_PAD_BOTH).$eol;
						 if(mb_stristr('vtas.comp.clie.prov',$tabla))
						 {
               $docu_txt.= str_pad('S.TOTAL :',($coltxt-$colval),' ',STR_PAD_LEFT).str_pad(number_format($xtsubt,2),$colval,'.',STR_PAD_LEFT).$eol;
							 if($xtdcto>0)
               {$docu_txt.= str_pad('DESCUENTO :',$coltxt-$colval,' ',STR_PAD_LEFT).str_pad(number_format($xtdcto,2),$colval,'.',STR_PAD_LEFT).$eol;}
               $docu_txt.= str_pad('S.TOTAL IVA 0% :',($coltxt-$colval),' ',STR_PAD_LEFT).str_pad(number_format($xtsubtiva0,2),$colval,'.',STR_PAD_LEFT).$eol;
							 if($xpiva>0)
							 {$docu_txt.= str_pad('S.TOTAL IVA '.number_format($xpiva,0).'% :',$coltxt-$colval,' ',STR_PAD_LEFT).str_pad(number_format($xtsubtiva,2),$colval,'.',STR_PAD_LEFT).$eol;}
               if($xtice>0)
							 {$docu_txt.= str_pad('ICE :',$coltxt-$colval,' ',STR_PAD_LEFT).str_pad(number_format($xtice,2),$colval,'.',STR_PAD_LEFT).$eol;}
							 $docu_txt.=  str_pad('IVA :',$coltxt-$colval,' ',STR_PAD_LEFT).str_pad(number_format($xtiva,2),$colval,'.',STR_PAD_LEFT).$eol;
               if($xtirbp>0)
							 {$docu_txt.= str_pad('IRBP :',$coltxt-$colval,' ',STR_PAD_LEFT).str_pad(number_format($xtirbp,2),$colval,'.',STR_PAD_LEFT).$eol;}
						 }
						 $docu_txt.= str_pad('TOTAL :',$coltxt-$colval,' ',STR_PAD_LEFT).str_pad('> '.number_format(abs($xtotal),2),$colval,' =',STR_PAD_LEFT).$eol;
             $docu_txt.=$eol;
          ?>



<?php //////////////////////////////////////////////////////////	?>
<?php // PIE DE PAGINA	?>
		<footer1>
      
		<div style="font-size:25%;"><br></div>
		<table border="0" width="96%" cellpadding="2" cellspacing="0" 
           style="border-collapse:collapse;font-size:<?php echo $xfontsize; ?>px;<?php echo $xfontfamily;?>">
      <tr>
				<?php ///// PIE COLUMNA IZQUIERDA ?>
				<td width=50% valign="top">
					<?php if($notas==1){?>
					<table border="0" width="100%" cellpadding="2" cellspacing="0" 
                 style="border-collapse:collapse;font-size:<?php echo $xfontsize; ?>px;<?php echo $xfontfamily;?>">
					<tr style="background:<?php echo $gris1;?>; border-top:solid 1px; border-bottom:solid 1px; font-weight:bolder;">
						<th style="letter-spacing:5pt;">NOTAS</th>
					</tr>
                              
                         <?php if(mb_stristr('vtas.clie',$tabla)){ ?>     
                         <?php $cfg_payphone = cfg_payphone($cfg_empr); ?>     
                         <?php if(!empty($cfg_payphone['token'])) { ?>
                              <?php                                   
                              $hrefqr='https://vcrxol.com/_lib/btn_payphone.php?emprdocuid='.$cfg_empr.$docu.$idnum;
                              $qrpng='qr'.date('His').'.png';
                              $qr = new QR_BarCode(); 
                              // create text QR code 
                              $qr->text($hrefqr); 
                              // display QR code image
                              // $qr->qrCode();
                              // echo getcwd();
                              // save QR code image
                              $qr->qrCode(350,$rutabcod.$qrpng);      
                               ?>                                  
                               <?php $href='https://vcrxol.com/_lib/btn_payphone.php?empr='.$cfg_empr.'&docu='.$docu.'&idnum='.$idnum; ?>
                              <th align="left">
                                   <b>PARA PAGO EN LINEA:</b>
                               <br>
                               <a href="http://payp.page.link/Pfxb" target="_blank">
                               <img src="https://vcrxol.com/_logo/payphone2.png" alt="Pago en Linea con PayPhone" width="82" height="20">
                               </a>
                               <br>
                               <a href="<?php echo $href; ?>" target="_blank" >
                               <img src="https://vcrxol.com/_bcod/<?php echo $qrpng;?>" alt="Pago en Linea con PayPhone" width="100" height="100">
                               </a>
                                   
                              </th>
                           <?php } ?>
                         <?php } ?>     
                         <?php if($serie_lote!=''){?>
                                        <tr>
                                             <td><?php echo $serie_lote; ?></td>
                                        </tr>
                         <?php } ?>
					<?php if($xambi==2 and $xclaveacc!='' and mb_stristr('vtas.retp',$tabla)){?>
					<tr>
						<td style="font-size:70%;">
<!-- 						ESTA IMPRESION SOLO TIENE FINES INFORMATIVOS Y DE CONSULTA<br> -->
<!-- 						ESTA IMPRESION NO TIENE VALIDEZ TRIBUTARIA<br> -->
						Mas información en :
						<?php if($cdisplay==1) {?>
						<a target="_blank" href="https://www.sri.gob.ec/web/guest/facturacion-electronica">PORTAL S.R.I.</a> / 
						<a target="_blank" href="https://srienlinea.sri.gob.ec/comprobantes-electronicos-internet/publico/validezComprobantes.jsf">VALIDADOR S.R.I.</a>
              
						<?php } ?>
						<?php if($cdisplay==2) { echo ' www.sri.gob.ec';}?>
						</td>
					</tr>
					<?php}?>
					<?php if(mb_stristr('vare',$cfg_empr) and mb_stristr('vtas',$tabla)) {?>
					<tr>
						<td>
							<b>PARA DEPOSITO O TRANSFERENCIA:</b>
							<br>BCO. GUAYAQUIL
							<br>CTA. AHORROS # 00 4756 9791
							<br>
							<br>BCO. PRODUBANCO
							<br>CTA. AHORROS # 1800 519 3308
							<br>
							<br>BCO. PACIFICO
							<br>CTA. CORRIENTE # 556 7424
							<br>
						</td>
					</tr>
					<?php } ?>
					<?php if(mb_stristr('ptsa',$cfg_empr) and mb_stristr('vtas',$tabla)) {?>
					<tr>
						<td>
							<b>PARA DEPOSITO O TRANSFERENCIA:</b>
							<br>BCO. PRODUBANCO
							<br>CTA. AHORROS # 1200 665 4245
							<br>
						</td>
					</tr>
					<?php } ?>
					<?php if(mb_stristr('ecgl.',$cfg_empr) and mb_stristr('clie',$tabla)) {?>
					<tr>
						<td>
							FORMA DE PAGO : 70% A LA ACEPTACION DE ESTA PROFORMA
							<br>SALDO CONTRA ENTREGA
							<br>FECHA DE ENTREGA : 5 DIAS LABORABLES
						</td>
					</tr>
					<?php } ?>
					<?php if(mb_stristr('gmny.gnya',$cfg_empr) and mb_stristr('clie',$tabla)) { ?>
					<tr>
						<td>
							<b>CUENTAS PARA DEPOSITO O TRANSFERENCIA:</b>
							<br>BCO. PICHINCHA - (Germania Zambrano M.)
<!-- 							<br>CTA. AHORROS # 448 268 2100 -->
							<br>CTA. AHORROS # 220 256 7299
<!-- 							<br> -->
<!--               <br>BCO. BOLIVARIANO - (Germania Zambrano M.) -->
<!-- 							<br>CTA. AHORROS # 002 129 8665  -->
						</td>
					</tr>
					<?php } ?>
					<?php if(mb_stristr('gmny',$cfg_empr) and mb_stristr('prod',$tabla)) {?>
					<tr>
						<td>
							EL PRODUCTO DEBE SER ENTREGADO EN LA FECHA INDICADA
							<br>HABRA UNA PENALIZACION POR CADA DIA DE RETRASO
						</td>
					</tr>
					<?php } ?>
					<?php if(mb_stristr('mzlj',$cfg_empr) and mb_stristr('clie',$tabla) and mb_stristr('PC10',$docu)) {?>
					<tr>
						<td style="font-size:120%;font-weight:bold;">
              <br>
							*** ESTE COMPROBANTE NO ES UNA FACTURA ***
						</td>
					</tr>
					<?php } ?>
					</table>
					<div style="height:10mm;"></div>
					<?php } ?>
					<?php if($obser==1){?>
					<table border="0" width="100%" cellpadding="2" cellspacing="0" 
                 style="border-collapse:collapse;font-size:<?php echo $xfontsize; ?>px;<?php echo $xfontfamily;?>">
					<tr style="background:<?php echo $gris1;?>; border-top:solid 1px; border-bottom:solid 1px; font-weight:bolder;">
						<th style="letter-spacing:5pt;">OBSERVACIONES</th>
					</tr>
					<?php if(mb_stristr('gmny',$cfg_empr) and mb_stristr('prod',$tabla)) {?>
					<tr style="border-bottom:solid 1px; height:8mm;">
						<td><br></td>
					</tr>
					<tr style="border-bottom:solid 1px; height:8mm;">
						<td><br></td>
					</tr>
					<?php } ?>
					</table>
					<div style="height:10mm;"></div>
					<?php } ?>

        </td>

				<?php ///// PIE COLUMNA DERECHA ?>
				<td width=50% valign="top">
					<table border="0" width="100%" cellpadding="2" cellspacing="0" 
                 style="border-collapse:collapse;font-size:<?php echo $xfontsize; ?>px;<?php echo $xfontfamily;?>">
					<?php if(!mb_stristr('guia.cont',$tabla)){?>
					<tr>
						<td align="right" style="font-weight:bolder;">
						<?php if($xtotal!=0 and $xipuni==1){echo 'SON : '.num2let(round(abs($xtotal),2));}?>
						</td>
					</tr>
					<?php } ?>
					</table>
				</td>
			</tr>

			<?php
        if(substr($docu,0,2)!='GR')
        {
          $docu_pdf->ln();
          $docu_pdf->SetFont($ffamilyPDF,'B',$fsizePDF-2);
          $docu_pdf->Cell(0,5,'SON : '.num2let(round(abs($xtotal),2)),'',0,'R',false);
          $docu_pdf->ln();
        }
      ?>
      <?php
          $docu_txt.=str_pad('NOTAS ',$coltxt,$carbot,STR_PAD_BOTH).$eol;
//           $docu_txt.=str_repeat('-',$coltxt).$eol;
          if($claveacc!='')
          {$docu_txt.='DESCARGUE SU COMPROBANTE ELECTRONICO EN : ';
          $docu_txt.=$cfg_empr.'.vcrxol.com';}
          $docu_txt.=$eol;                                                        
      ?>
    </table>
		</footer1>


<?php //if(mb_stristr('vtas.clie.retp.',$tabla) or mb_stristr('',substr($docu,0,2))){ ?>
<?php if($firmas==1){ ?>
<?php if($cdisplay==2){ ?>
	<table border="0" width="100%" cellpadding="2" cellspacing="0" 
         style="border-collapse:collapse;font-size:<?php echo $xfontsize; ?>px;<?php echo $xfontfamily;?>">
		<tr style="height:10mm;"></tr>
		<tr style="height:10mm; font-size:100%;">

      <?php if($formato<=1){?>
			<?php if(mb_stristr('cont',$tabla)){?>
				<td></td>
				<td align="center" valign="top" style="width:40mm; border-top:solid 1px;">FIRMA AUTORIZADA</td>
				<td></td>
			<?php } ?>
			<?php if(mb_stristr('vtas.bcos.caja',$tabla)){?>
				<td></td>
				<td align="center" valign="top" style="width:40mm; border-top:solid 1px;">FIRMA AUTORIZADA</td>
				<td></td>
				<td align="center" valign="top" style="width:40mm; border-top:solid 1px;">RECIBI CONFORME</td>
				<td></td>
			<?php } ?>
			<?php if(mb_stristr('guia',$tabla)){?>
				<td></td>
				<td align="center" valign="top" style="width:40mm; border-top:solid 1px;">FIRMA AUTORIZADA</td>
				<td></td>
				<td align="center" valign="top" style="width:40mm; border-top:solid 1px;">CONDUCTOR</td>
				<td></td>
				<td align="center" valign="top" style="width:40mm; border-top:solid 1px;">RECIBI CONFORME</td>
				<td></td>
			<?php } ?>
			<?php if(mb_stristr('clie',$tabla)){?>
				<td></td>
				<td align="center" valign="top" style="width:40mm; border-top:solid 1px;">FIRMA AUTORIZADA</td>
				<td></td>
				<td></td>
				<td></td>
			<?php } ?>
			<?php if(mb_stristr('inve',$tabla) and substr($docu,0,2)=='IB'){?>
				<td></td>
				<td align="center" valign="top" style="width:40mm; border-top:solid 1px;">RECIBIDO POR</td>
				<td></td>
				<td align="center" valign="top" style="width:40mm; border-top:solid 1px;">REVISADO POR</td>
				<td></td>
			<?php } ?>
			<?php if(mb_stristr('inve',$tabla) and substr($docu,0,2)=='EB'){?>
				<td></td>
				<td align="center" valign="top" style="width:40mm; border-top:solid 1px;">ELABORADO POR</td>
				<td></td>
				<td align="center" valign="top" style="width:40mm; border-top:solid 1px;">REVISADO POR</td>
				<td></td>
				<td align="center" valign="top" style="width:40mm; border-top:solid 1px;">RECIBIDO POR</td>
				<td></td>
			<?php } ?>
			<?php if(mb_stristr('prod',$tabla)){?>
				<td></td>
				<td align="center" valign="top" style="width:40mm; border-top:solid 1px;">ENTREGADO POR</td>
				<td></td>
				<td align="center" valign="top" style="width:40mm; border-top:solid 1px;">RECIBIDO POR</td>
				<td></td>
				<td align="center" valign="top" style="width:40mm; border-top:solid 1px;">PRODUCTO TERMINADO</td>
				<td></td>
			<?php } ?>
			<?php if(mb_stristr('retp',$tabla)){?>
				<td></td>
				<td align="center" valign="top" style="width:40mm; border-top:solid 1px;">AGENTE DE RETENCION</td>
				<td></td>
				<td align="center" valign="top" style="width:40mm; border-top:solid 1px;">SUJETO RETENIDO</td>
				<td></td>
			<?php } ?>
			<?php }else{ ?>
				<td></td>
				<td align="center" valign="top" style="width:40mm; border-top:solid 1px;">FIRMA AUTORIZADA</td>
				<td></td>
			<?php } ?>
		</tr>		
	</table>
<?php } ?>
<?php } ?>

<?php $pagare1= ''; ?>
<?php $pagare2= ''; ?>
<?php
 if(mb_stristr('mzlj.demo',$cfg_empr))
 { 
   $pagare1.= 'Debo(emos) y Pagaré(mos) incondicionalmente a la orden de '.r_fiel('enti',$cfg_ruc).' en el lugar y fecha que se estime conveniente'; 
   $pagare1.= ' el valor total expresado en este documento, en caso de mora, reconoceré el interés permitido por la ley <br>'; 
   $pagare1.= 'Autorizo(amos) expresa e irrevocablemente a '.r_fiel('enti',$cfg_ruc).' para que obtenga cuantas veces sean necesarias, '; 
   $pagare1.= 'de cualquier fuente de información, incluidos burós de crédito, mi informacion de riesgos crediticios, de igual forma '; 
   $pagare1.= r_fiel('enti',$cfg_ruc).' queda expresamente autorizado para que pueda transferir o entregar dicha información a los burós de crédito'; 
   $pagare1.= ' y/o a la Central de Riesgos si fuera pertinente.'; 

   $pagare2.= 'Estimado cliente sírvase enviarnos el comprobante de retención dentro de los cinco primeros días de recibida la presente Factura,'; 
   $pagare2.= ' caso contrario no se aceptará el descuento por el monto de la retención. '; 
   $pagare2.= ' Art.50 Regimen Tributario Interno'; 
 }
?>

<?php
 if(mb_stristr('sawo',$cfg_empr))
 { 
   $pagare1.='Autorizo (amos) a SUAREZ ALBAN WILSON OSWALDO a consultar mis datos, y a publicar los valores incurridos en MORA '; 
   $pagare1.='que puedan generarse de las operaciones de orden crediticio en cualquier buro de crédito autorizado.';
      
   $pagare2.='Pagaré.- "He recibido en cantidad y calidad lo detallado en esta factura por el valor indicado en "TOTAL" suma que DEBO Y PAGARE sin protesto, ';
   $pagare2.='incondicionalmente, en esta ciudad, a SUAREZ ALBAN WILSON OSWALDO, en el plazo estipulado contado desde hoy. ';
   $pagare2.='En caso de mora me sujeto a los intereses máximos de mora previstos en la ley y a ser demandado en juicio ejecutivo o en verbal sumario ';
   $pagare2.='a elección del actor, ante los jueces de esta ciudad, para lo cual renuncio a otro domicilio".';
      
 }
?>



<?php if(substr($docu,0,2)=='FC' and $formato==1 and $pagare1.$pagare2!=''){ ?>
      <table border="0" width="100%" cellpadding="2" cellspacing="0" 
             style="border-collapse:collapse;font-size:<?php echo $xfontsize; ?>px;<?php echo $xfontfamily;?>">
          <tr style="font-size:60%; border-top:solid 1px; border-bottom:solid 1px; text-align:justify; vertical-align:top;">
            <td width="60%" style="">
            <?php echo $pagare1;?>
            </td>
            <td width="5%"  >
            </td>
            <td width="35%"  >
            <?php echo $pagare2;?>
            </td>
          </tr>
        </table>

    <br>
<?php } ?>

	<table border="0" width="100%" cellpadding="2" cellspacing="0" 
         style="border-collapse:collapse;font-size:<?php echo $xfontsize; ?>px;<?php echo $xfontfamily;?>;">
			<tr style="font-size:50%; border-top:solid 1px; border-bottom:solid 1px; font-weight:bolder; background:<?php echo $gris1;?>;">
				<td width="33%">
				<?php echo 'ID:'.$idnum;?>
				</td>
				<td width="34%" align="center" style="font-size:150%">
<!-- 				<a target="_blank" href="https://www.vcrxol.com">WWW.VCRXOL.COM - SISTEMAS EN LINEA</a> -->
				</td>
				<td width="33%" align="right" >
				<?php if($user_codigo!="" and $destino!='mail'){ ?>
				<?php echo 'IMPRESO POR: ';?>
				<?php //echo r_fiel('enti',$user_cedula,'nom1').' '.r_fiel('enti',$user_cedula,'ape1');?>
				<?php echo r_fiel('user',$user_codigo);?>
				<?php echo '<br>'; ?>
				<?php } ?>
				<?php echo date('d/M/y H:i:s');?>
				</td>
			</tr>
		</table>
        <?php 
          $docu_pdf->ln();
          $docu_pdf->ln();
          $docu_pdf->SetFont($ffamilyPDF,'B',$fsizePDF-2);
          $docu_pdf->SetFontSize($fsizePDF-8);
          $docu_pdf->Cell($pdf_ancho*.5,5,'ID:'.$idnum,'TB',0,'L',false);
          $docu_pdf->Cell($pdf_ancho*.5,5,date('d/M/y H:i:s'),'TB',0,'R',false);
          $docu_pdf->ln();
        ?>
        <?php
             $docu_txt.=str_repeat('-',$coltxt).$eol;
//              $docu_txt.= msql_result($res_tra1,0,'iuser');
             $docu_txt.= date('d/M/y');
             $docu_txt.= str_pad(date('H:i:s'),$coltxt-9,' ',STR_PAD_LEFT);
             $docu_txt.= $eol;
             $docu_txt.= str_repeat('-',$coltxt);
             $docu_txt.= $eol;
       

       
       
          if($cfg_empr=='hg01' and substr($enti,2)!='99' and msql_result($res_tra1,0,'credito')>0)
          {
               $mes_prox=msql_result($res_tra1,0,'fecha');
               $mes_prox=date('Y-m-01',strtotime(msql_result($res_tra1,0,'fecha').' +1 month'));
//                sql_result($res_docu,0,'fecha'),'+1 month'));
               
               $docu_txt.= $eol;
               $docu_txt.= $eol;
               $docu_txt.= $eol;
               $docu_txt.='Guayaquii,'.date('d').' de '.$mes_nombre[date('m')*1].' del '.date('Y').$eol;
               $docu_txt.='Señores'.$eol;
               $docu_txt.='LABORATORIOS HG C.A.'.$eol;
               $docu_txt.='Ciudad.'.$eol;
               $docu_txt.=$eol;
               $docu_txt.='Yo '.$enti_razsoc.', portador de la cédula de ciudadania No.'.substr($enti,0,10).' ';
               $docu_txt.='autorizo de manera expresa a mi empleador, ';
               $docu_txt.='para que sea descontado de mi remuneración del mes de '.$mes_nombre[substr($mes_prox,5,2)*1].' del '.substr($mes_prox,0,4).' ';
               $docu_txt.='la suma de $'.number_format($credito,2).' dólares de los Estados Unidos de América, ';
               $docu_txt.='correspondiente a la compra de medicamentos y/o cosméticos según factura #'.$xptonumero;
               $docu_txt.= $eol;
               $docu_txt.= $eol;
               $docu_txt.='Atentamente,'.$eol;
               $docu_txt.= $eol;
               $docu_txt.= $eol;
               $docu_txt.= $eol;
               $docu_txt.='___________________'.$eol;
               $docu_txt.='ci #'.substr($enti,0,10).$eol;
               
                    
          }
       
       
       
       
             $docu_txt.= $pgbr;
          
//              $docu_txt.='<p class="saltodepagina" /></p>';

       
       
        ?>		
  <?php	if(mb_stristr('PF.OP.PC',substr($docu,0,2)) and $cfg_empr=='ecgl'){ecgl_dise1($docu,$idnum);}?>

		
	</div>	
	<br>
	<?php $xfontsize=$printsize; ?>
	<?php } ?>

	<?php // if($destino=='mail'){ ?>
	<?php	//echo '</html>'; ?>
	<?php//  } ?>
	
<?php //////////////////////////////////////////////////////////	?>
<?php //echo date('H:i:s'); ?>

<?php	
$docuhtml = ob_get_clean(); 
// $docuhtml = alltrim($docuhtml);
if(!mb_stristr('pos.txt.mail',$destino))  
{$docuhtml = limpiahtml($docuhtml);}
?>
<?php //if($cfg_empr=='ecgl' and mb_stristr('FC',substr($docu,0,2))) {$docuhtml=str_replace('<tr>','<tr style="font-weight:bolder;">',$docuhtml);} ?>
<?php
  
// if($destino=='mail')
if($formato==1 or $claveacc!='' )
{
  $subdce=mk_subdce($claveacc);
  @unlink($rutace.$subdce.$xclaveacc.'.pdf');

//   echo $rutace.$subdce.$xclaveacc.'.pdf';
//   if(mb_stristr('P.J',$tiporuc))
//   {$docu_pdf->Output('F',$rutace.$subdce.$xclaveacc.'.pdf',true);}
  
}
  
if(mb_stristr('pos.txt',$destino))
{
//   file_put_contents($rutace.$subdce.$claveacc.'.txt',$docu_txt);
//   $docu_txt.='<p class="saltodepagina" /></p>';
  return $docu_txt;
}  
// if(substr($destino,0,3)=='pdf'){return file_get_contents($rutace.$subdce.$xclaveacc.'.pdf');} 
//   echo '***'.$destino;
// if(substr($destino,0,3)=='pdf'){return 'AAA';} 
// if(substr($destino,0,3)=='pdf'){return $docu_pdf;}  

// $overpdf=1;  
     // lubrisa
     //expalsa
if(mb_stristr('0991231366.0990637679',substr($enti_codigo,0,10)))     
{pdf_sri($docu,$idnum);}

if($cfg_empr=='yptc')     
{pdf_sri($docu,$idnum); }
          
if($destino=='mail' and ($docupdf==1 or $entipdf==1))	
{
	file_put_contents($rutadoc.$docu_idnum.'.htm',$docuhtml);
	if($xclaveacc!="")
	{if(!file_exists($filepdf) or $overpdf==1){pdf_sri($docu,$idnum);}}
}	
else	
{file_put_contents($rutadoc.$docu_idnum.'.html',$docuhtml);}	

// file_get_contents($hrefpdf3);  

return $docuhtml;	
}
?>

<?php
function Xprnt_maes2($docu,$idnum,$formato=1,$destino='screen')
{
//    msql_query("flush user_resources");  
 	include('php_session.php');
	include('../_cfg/config.php');
  
//   msql_query("SET NAMES 'utf8'");  
  if($docu==''){return '*** NO DOCUMENT ***';}
  
$mtime=microtime(true);
$nota1='';	
$eol="<br>";
$eol=" \r\n";  
$gris1='#F7F7F7';
$gris1='lightgrey';
$gris1='gainsboro';
// if($destino=='screen'){$eol="<br>";}
// if($destino=='file'){$eol=" \r\n";}
$coltxt=40;
$padtxt=' ';
$carbot='- ';
if($cfg_empr=='hg01')
{$carbot='-     ';}
$saldo0=1/100;
  
// ob_start();
// 		formatos
// 			1 - general
// 			2 - diario contable (directo de la tabla cont1)
// 			3 - diario contable (desde el modulo a cont.idfrom)
//			5 - egreso detallado
	
// 		destino
// 			screen
// 			mat tricial
// 			txt pos 
	
// echo sal_docu($docu,$idnum);	

	
	//$empr_cont=r_fiel('empr',$cfg_empr,'empr_cont');
// echo '***'.$tabla;

  
// if($formato=='2' and $empr_cont!=1){return; }
 
$tabla=r_fiel('docu',$docu,'tabla');

//  vali_regidocu($docu,$idnum);
  
  
//    if(mb_stristr('DD.DT.DI',substr($docu,0,2))){$formato=1;}
//    if(mb_stristr('FP03.FP11',$docu)){gen_claveacc($docu,$idnum);}
//    if(mb_stristr('FP03.FP11',$docu)){get_atrz0($docu,$idnum); }
//    if(mb_stristr('RPRO',$docu)){get_atrz0($docu,$idnum); }
//    if(mb_stristr('PF.PC.PP',substr($docu,0,2))){gen_claveacc($docu,$idnum);}
//    if(mb_stristr('FC',substr($docu,0,2))){$serie_lote=get_serie_lote($docu,$idnum);}
//    if(mb_stristr('FP.NP',substr($docu,0,2))){updt_itemce($docu,$idnum);updt_ctascomp($docu,$idnum);}
//    if(mb_stristr('FP',substr($docu,0,2))){gen_invent($docu,$idnum);}
//    if(mb_stristr('FP.RC',substr($docu,0,2))){get_atrz1($docu,$idnum);}
//    if(mb_stristr('CH',substr($docu,0,2))){$regche=reg_ch10($idnum);}
//    if(mb_stristr('ICH',substr($docu,0,3))){$depche=ich1_depo($docu,$idnum);}
//    if(mb_stristr('IB11',$docu)){ib11_eb11($docu,$idnum);}
//    if(mb_stristr('ATV1',$docu)){tfle_getplan($docu,$idnum);}
//    if(mb_stristr('EB13',$docu)){gen_invent($docu,$idnum);}
//    if(mb_stristr('caja.bcos',$tabla)){$caba13=gen_caba13($docu,$idnum);}
//    if(mb_stristr('bcos',$tabla)){val_bcos1($docu,$idnum);}
//    if(mb_stristr('PF.OP.PC.FC',substr($docu,0,2)) and $cfg_empr=='dly1'){dly1_calc1($docu,$idnum);}
//    if(mb_stristr('PF.OP.PC.FC',substr($docu,0,2)) and $cfg_empr=='ecgl'){ecgl_calc1($docu,$idnum);}
//    if(mb_stristr('FC',substr($docu,0,2)) and $cfg_empr=='pcs1'){pcs1_calc1($docu,$idnum);}

  
//   if($formato==2 and $tabla!='cont'){$contab=gen_contab($docu,$idnum);}		

//   ecgl_calc3($docu,$idnum);
//   gnya_comi0($docu,$idnum);
  
//   gmny_op10($docu,$idnum);
  
	$sql_tra0='select * from '.$tabla.'0 where '.$tabla.'0_codigo='.$idnum.'  ';
	$res_tra0=msql_query($sql_tra0,$link_vcrx);	
  
//   $enti=@msql_result($res_tra0,0,'enti');
//   $entides=@msql_result($res_tra0,0,'enti_descri');
//   $entiraz=@msql_result($res_tra0,0,'enti_razsoc');
//   $entinom=@msql_result($res_tra0,0,'enti_nomcom');
//   $entides=r_fiel('enti',$enti,'descri');
//   $entiraz=r_fiel('enti',$enti,'razsoc');
//   $entinom=r_fiel('enti',$enti,'nomcom');
//   if(mb_stristr($entides.$entiraz,'sri.gob.ec'))
//   {
//     $sql_uent='update enti0 set enti_razsoc=enti_nomcom where (enti_razsoc="" or enti_razsoc is null or enti_razsoc like "%sri.gob%") and  enti_codigo like "'.$enti.'%"' ;
//     $res_uent=msql_query($sql_uent,$link_vcrx);
//     $sql_uent='update enti0 set enti_descri=enti_razsoc where (enti_descri="" or enti_descri is null or enti_descri like "%sri.gob%") and  enti_codigo like "'.$enti.'%"' ;
//     $res_uent=msql_query($sql_uent,$link_vcrx);
//   }

//   if(mb_stristr($entides.$entiraz.$entinom,'sp;') or $entides=='' or $entiraz=='' or $entinom=='')
//   {reg_cedruc($enti);}
  
//   $numeroxx=@msql_result($res_tra0,0,'numero');
//   $claveacc=@msql_result($res_tra0,0,'claveacc');
//   $ambice=substr($claveacc,23,1);

	$ccc=0;
	$overpdf=0;	
// 	$docu_idnum=$docu.'_'.fillzero($idnum);	
	if($destino==''){$destino='screen';}	
	if($destino=='pdf'){$overpdf=1;}	
// 	if(mb_stristr($destino,'mail') or $destino=='pdf' or $destino=='M'){$destino='mail';}
	if(mb_stristr($destino,'mail') or $destino=='M'){$destino='mail';}

{
	$mdisplay=2;
// 	$mdisplay=1;
	if(mb_stristr($destino,'mail')){$mdisplay=1; $destino='mail';}
	if(mb_stristr('pos.txt',$destino)){$mdisplay=1;}
// 	if($formato==2){$tabla='cont';}

	$sql_docu='select * from docu0 where docu_codigo like "'.$docu.'%"';
	$res_docu=msql_query($sql_docu,$link_vcrx);
	$tabla=strtolower(msql_result($res_docu,0,'docu_tabla'));	
  
	$ppsize=@msql_result($res_docu,0,'docu_ppsize');	
	$pporient=@msql_result($res_docu,0,'docu_pporient');	

	$width=@msql_result($res_docu,0,'docu_width');	
	$height=@msql_result($res_docu,0,'docu_height');	
	$orient=@msql_result($res_docu,0,'docu_orient');	

	$doble=@msql_result($res_docu,0,'docu_doble');	
	$copia=@msql_result($res_docu,0,'docu_copia');	

	$mindeta=@msql_result($res_docu,0,'docu_mindeta');	
	$docupdf=@msql_result($res_docu,0,'docu_pdf');	
	$margin_top=@msql_result($res_docu,0,'docu_top');	
	$margin_left=@msql_result($res_docu,0,'docu_left');
  
//   if($ambice=='2'){$margin_top=0;}
  

	$doculogo=0;
	$firmas=0;
	$marcas=0;
	$notas=1;
  $obser=0;
	$guiaremi=0;
// 	if(mb_stristr('FC.OP.PC.PF.NC..GR..RP..PP..IE.IC..CH.ND...CA',substr($docu,0,2))){$doculogo=1;}
//  	if(mb_stristr('FC.OP.PC.PF.NC..GR..RP..PP..IE.EE.IC..CH..EB',substr($docu,0,2))){$firmas=1;}
// 	if(mb_stristr('FP11.FP03',substr($docu,0,4))){$doculogo=1; $firmas=1;}
//  	if(mb_stristr('DD.RP.RC.',substr($docu,0,2))){$notas=0;}
// 	if(mb_stristr('GR',substr($docu,0,2))){$guiaremi=1;}
// 	if(mb_stristr('clie.vtas',$tabla)){$marcas=1;}
// 	if(mb_stristr('inve',$tabla) and $cfg_empr=='hfre'){$firmas=1;}
// 	if(mb_stristr('inve',$tabla)){$firmas=1;}
// 	if($destino=='mail'){$margin_top=0; $firmas=0;}
// 	if($margin_top>0){$doculogo=0;}
//   if(mb_stristr('inve',$tabla) and $cfg_empr=='hfre'){$doculogo=1;}
//  	if(mb_stristr('OP',substr($docu,0,2)) and mb_stristr('gmny',$cfg_empr)){$obser=1;}
  
	if($ppsize==''){$ppsize='A4';}
	if($pporient==''){$pporient='V';}
	if($width==0){$width=210;}
	if($height==0){$height=297;}
	if($orient==''){$orient='V';}	
	if($copia==0){$copia=1;}	
  if($formato==1){$copia=1;}

  if(mb_stristr('pos.txt',$destino))
  {
    $mdisplay=1;
    $copia=1;
    $margin_top=0;
    $doculogo=0;
    $firmas=0;
  }

	if($user_codigo=='')
	{
		$ppsize='A4';
		$pporient='V';
		$width=210;
		$height=297;
		$orient='V';
		$copia=1;
	}	
	
	$xfontsize=12;
	$screensize=12;
	$printsize=12;
	if($width<=150)
	{
		$xfontsize=12;
		$screensize=12;
		$printsize=8;
	}
	if($width<=110)
	{
		$xfontsize=12;
		$screensize=12;
		$printsize=6;
	}

	// $width=70;
	$tirilla=0;	
	if($width<=90)
	{
		$tirilla=1;
		$xfontsize=12;
		$screensize=12;
		$printsize=6;
	}

// 	if($formato==2 and $tabla!='cont')
// 	{
// 			$sql_tra1='select * from cont1 where idfrom="'.$idnum.'" and mdfrom="'.$tabla.'"';
// 			$res_tra1=msql_query($sql_tra1,$link_vcrx);
// 			$idnum=@msql_result($res_tra1,0,'idnum1');
// 			$tabla='cont';
// 	}	
	
	
	if($formato>=2)
	{
		$xfontsize=12;
		$screensize=12;
		$printsize=12;
		$ppsize='A4';
		$pporient='V';
		$width=210;
		$height=297;
		$orient='V';
		$copia=1;
		$doculogo=0;
		$firmas=1;
		$marcas=0;
		$notas=0;
		$guiaremi=0;
		$xmdetalle='-';
		$margin_top=0;
	}
  
	if($formato==5)
	{
//     echo '*/*/*/';
		$xfontsize=12;
		$screensize=12;
		$printsize=12;
		$ppsize='A4';
		$pporient='H';
		$width=297;
		$height=210;
		$orient='H';
		$copia=1;
		$doculogo=0;
		$firmas=1;
		$marcas=0;
		$notas=0;
		$guiaremi=0;
		$xmdetalle='-';
		$margin_top=0;
	}
  
	
	{	
		$sql_emis='select * from empr0 left join enti00 on empr_ruc=enti_codigo limit 1';
		$res_emis=msql_query($sql_emis,$link_vcrx);
    if(msql_errno!=0)
    {
      $sql_emis='select * from empr0 left join enti0 on empr_ruc=enti_codigo limit 1';
      $res_emis=msql_query($sql_emis,$link_vcrx);
    }

//       if($cfg_empr=='gnya' and $tabla=='vtas')
//       {
//          $sql_emis='select * from enti0 where enti_codigo like "1900318468%"  order by enti_codigo desc limit 1';
//          $res_emis=msql_query($sql_emis,$link_vcrx);
//       }
//     $empr_lote=@msql_result($res_emis,0,'empr_lote');  

     $empr_lote=0;
      if(mb_stristr('inve.prod.vtas.clie.tfin',$tabla))
      {$empr_lote=r_fiel('empr',$cfg_empr,'empr_lote');}
      
    {
      $sql_total=sql_total($tabla);
      $dispcolu=1;
      if($mobile=='true'){$dispcolu=0;}
		}

// 		$sql_tra1='select * from '.$tabla.'12 where idnum1="'.$idnum.'"';
// 		if(mb_stristr('retc.retp',$tabla))
// 		{
// 			$sql_tra1 ='select * from '.$tabla.'12 where status!="O" and status!="X" and cant>0 and ';
// 			$sql_tra1.='concat(numero,fecha,enti) in (select concat(numero,fecha,enti) as numero from '.$tabla.'1 where idnum1="'.$idnum.'" )';
// 		}
    
// 		if(mb_stristr('CE10',$docu))
//     {
//       $sql_tra1.=' and nvdd_tipo<3 ';      
//     }
      
// 		$sql_tra2=$sql_tra1;

//     echo '*/*/*/*'.$sql_tra1;
//     echo '======'.$sql_tra2;
    
      
//       if(mb_stristr('vtas',$tabla) and mb_stristr('gmny.gnya',$cfg_empr))
//       {$sql_tra1.=' group by item_raiz '}
      
      
// 		$sql_tra1=str_replace('*','*,'.$sql_total,$sql_tra1);
      

//     $sql_tra2.='order by iddet ';
// 		if($cfg_empr=='ecgl' and mb_stristr('vtas.clie.prod',$tabla)){$sql_tra2=str_replace('order by',' order by itnum,',$sql_tra2);}
// 		if($cfg_empr=='tgck' and mb_stristr('vtas.clie',$tabla)){$sql_tra2=str_replace('order by',' order by vhcl,',$sql_tra2);}
// 		if($cfg_empr=='gmny' and mb_stristr('prod',$tabla)){$sql_tra2=str_replace('order by',' order by item,',$sql_tra2);}
// 		if(mb_stristr('cont',$tabla)){$sql_tra2=str_replace('order by','order by ctas,cant desc,',$sql_tra2);}
// 		if(mb_stristr('nomi',$tabla)){$sql_tra2=str_replace('order by','order by enti2,nvdd,',$sql_tra2);}
// 		if(mb_stristr('empl',$tabla)){$sql_tra2=str_replace('order by','order by nvdd_tipo,nvdd,fecha2,',$sql_tra2);}
// 		if(mb_stristr('IB00',$docu)){$sql_tra2=str_replace('order by','order by item_lsub,item_descri,',$sql_tra2);}

//     $res_tra1=msql_query($sql_tra1,$link_vcrx);	
    
//     $enti_codigo=msql_result($res_tra1,0,'enti');
//     $enti_descri=msql_result($res_tra1,0,'enti_descri');
//     $enti_razsoc=msql_result($res_tra1,0,'enti_razsoc');
//     $enti_nom1=msql_result($res_tra1,0,'enti_nom1');
//     $enti_matriz=msql_result($res_tra1,0,'enti_matriz');
//     $enti_matriz=r_fiel('enti',$enti_codigo,'enti_matriz');
//     $enti_ciudad=r_fiel('enti',$enti_codigo,'enti_ciudad');
//     $enti_parroq= msql_result($res_tra1,0,'enti_parroq');
//     $enti_parroq= r_fiel('enti',$enti_codigo,'enti_parroq');

// 		if($enti_razsoc=='' or mb_stristr($enti_razsoc,'sp;')){reg_cedruc($enti_codigo);}
// 		if( (strlen(trim($enti_descri))<=3 and strlen(trim($enti_razsoc))<=3) or (empty($enti_descri)) or (mb_stristr('<LINK',$enti_descri)) )
//     {get_ruc0($enti_codigo);}
      
      
//     if(date('Y-m-d')<='2020-09-30')
//     {get_rime($enti_codigo);}
    
//     if(date('Y-m-d')<='2020-09-30')
//     {get_agret($enti_codigo);}
    
//     $enti_orig=$enti_codigo;
//     $sql_adqu='select * from enti00 where enti_codigo like "'.$enti_codigo.'%" order by enti_codigo desc';
//     $sql_adqu='select * from enti00 where enti_codigo = "'.$enti_codigo.'" order by enti_codigo desc';
// 		$res_adqu=msql_query($sql_adqu,$link_vcrx);

//     $xtoenti=@msql_result($res_tra1,0,'toenti');
// 		$sql_toen=$sql_adqu;
// 		if($tabla=='comp'){$sql_toen='select * from enti00 where enti_codigo like "'.$xtoenti.'%" order by enti_codigo desc';}
// 		if($tabla=='retc'){$sql_toen='select * from enti00 where enti_codigo like "'.$xtoenti.'%" order by enti_codigo desc';}
// 		$res_toen=msql_query($sql_toen,$link_vcrx);
    
//     if(msql_num_rows($res_toen)==0){get_ruc0($xtoenti);$res_toen=msql_query($sql_toen,$link_vcrx);}
		
// 		$xptonumero=msql_result($res_tra1,0,'ptonumero');
// 		$xenti=msql_result($res_tra1,0,'enti');
		
		$entipdf=0;
// 		$entipdf=@r_fiel('enti',$xenti,'pdf');

    $enticomi=0;
//     if(mb_stristr('vtas.clie',$tabla)){$enticomi=@r_fiel('enti',$xenti,'comi');}
		
// 		if(mb_stristr('clie.prov',$tabla)){$xclaveacc=msql_result($res_tra1,0,'claveacc');}
		
// 		if(mb_stristr('vtas.comp.retc.retp.guia.comp.prod',$tabla))
// 		{
// 			$xclaveacc=msql_result($res_tra1,0,'claveacc');
// 			$xautornum=msql_result($res_tra1,0,'autornum');
// 			$xautorfec=@msql_result($res_tra1,0,'autorfec');
// 			$xatrz=msql_result($res_tra1,0,'atrz');
// 			$xatrzvali=@msql_result($res_tra1,0,'atrzvali');
// 		}
    
// 		$fecha=msql_result($res_tra1,0,'fecha');
// 		$fcobro=msql_result($res_tra1,0,'fcobro');
// 		$xstatus=msql_result($res_tra1,0,'status');
// 		$xstfin=msql_result($res_tra1,0,'stfin');
// 		$xambi=substr($xclaveacc,23,1);
// 		$docu_descri=msql_result($res_tra1,0,'docu_descri');
// 		$tiporuc=msql_result($res_tra1,0,'enti_tiporuc');
// 		if($tiporuc=='N'){$docupdf=0; $entipdf=0;}

// 		$tipo_descri='';
// 		if(substr($xclaveacc,8,2)=='01'){$tipo_descri='FACTURA';}
// 		if(substr($xclaveacc,8,2)=='03'){$tipo_descri='LIQUIDACION DE COMPRA';}
// 		if(substr($xclaveacc,8,2)=='04'){$tipo_descri='NOTA DE CREDITO';}
// 		if(substr($xclaveacc,8,2)=='06'){$tipo_descri='GUIA DE REMISION';}
// 		if(substr($xclaveacc,8,2)=='07'){$tipo_descri='RETENCION';}
// 		if($docu_descri=="" or $empr=="cfg_demo"){$docu_descri=$tipo_descri;}
// 		if($docu_descri=="" or $empr=="demo"){$docu_descri=$tipo_descri;}
// 		if($tipo_descri!=''){$docu_descri=$tipo_descri;}
		
// 		$xmdetalle=trim(msql_result($res_tra1,0,'mdetalle'));
// 		$xldetalle=trim(msql_result($res_tra1,0,'ldetalle'));
// 		$xlitemdescri=trim(@msql_result($res_tra1,0,'litemdescri'));
// 		$xmctas=@msql_result($res_tra1,0,'mctas');
// 		$xmcsub=@msql_result($res_tra1,0,'mcsub');
// 		$xmcair=@msql_result($res_tra1,0,'mcair');
// 		$xmitem=@msql_result($res_tra1,0,'mitem');

// 		$xmlote=@msql_result($res_tra1,0,'mlote');
//     $xmserie=@msql_result($res_tra1,0,'mserie');
//     if($empr_lote==0){$xmlote='';}
//     if($empr_srie==0){$xmserie='';}
		
//     $xmcntn=@msql_result($res_tra1,0,'mcntn');
//     $xmvhcl=@msql_result($res_tra1,0,'mvhcl');
    
// //     echo '*/*/*/'.$sql_tra1;
    
//     $xmclor=@msql_result($res_tra1,0,'mclor');
//     $xmtlla=@msql_result($res_tra1,0,'mtlla');
    
//     $xmarcl=@msql_result($res_tra1,0,'marcl');
//     $xmisdi=@msql_result($res_tra1,0,'misdi');

//     //ecgl
//     $xstlmn=@msql_result($res_tra1,0,'stlmn');
//     $xstmt1=@msql_result($res_tra1,0,'stmt1');
// 		$xstmt2=@msql_result($res_tra1,0,'stmt2');
	
//     if($tirilla==1){$xmdetalle='';}

// 		$xtunid=0;
// 		$xipuni=1;
// 		$xideta=1;
// 		$xpdcto=0;
// 		$xpprop=0;
// 		$xpice=0;
// 		$xpiva=0;
// 		$xpirbp=0;
// 		$xtdcto=0;
// 		$xtprop=0;
// 		$xtsubtice=0;
// 		$xtice=0;
// 		$xtsubtiva0=0;
// 		$xtsubtiva=0;
// 		$xtiva=0;
// 		$xtirbp=0;
//     $xipvp=0;

    
// // 		if(mb_stristr('vtas.clie.carr', $tabla) and mb_stristr('gmny.gnya',$cfg_empr))
// //     {$xipvp=1;}
    
    
// 		$xtcant=msql_result($res_tra1,0,'stcant');
// 		$xtsubt=abs(msql_result($res_tra1,0,'stsubt'));
//       if($xipuni==0){$xtsubt=0;}
		
// 		if(mb_stristr('retc.retp', $tabla))
// 		{
//       $xtrrta=msql_result($res_tra1,0,'srrta');
//       $xtriva=msql_result($res_tra1,0,'sriva');
// 		}

// 		$xtotal=msql_result($res_tra1,0,'stotal');
// 		$xconcepto=msql_result($res_tra1,0,'concepto');
    
//     if($tabla=='susa'){$xtotal=get_susa($enti);  }
    
// //     if($docu=='DA16'){$xtsubt=0;}
    
// 		$ximpor=@msql_result($res_tra1,0,'impor');
// // 		$ximpor=@msql_result($res_tra1,0,'impor2');
// 		$xcostoe1=@msql_result($res_tra1,0,'costoe1');
// 		$xseguro1=@msql_result($res_tra1,0,'seguro1');
// 		$xflete1=@msql_result($res_tra1,0,'flete1');
// 		$xcostol1=@msql_result($res_tra1,0,'costol1');
//     $xfob1=$xcostoe1+$xtsubt;
//     $xcif1=$xfob1+$xseguro1+$xflete1;
// 		$xadva=@msql_result($res_tra1,0,'sadva');
// 		$xfodi=@msql_result($res_tra1,0,'sfodi');
// 		$xicei=@msql_result($res_tra1,0,'sicei');
// 		$xivai=@msql_result($res_tra1,0,'sivai');
//       $xivai=0;
    
    
// 		$xbenefic=@msql_result($res_tra1,0,'benefic');
// 		$xattn=@msql_result($res_tra1,0,'attn');
//     $xattndes=r_fiel('enti',$xattn);

// 		if($guiaremi==1)
// 		{
// 			$motivo=@msql_result($res_tra1,0,'motivo');
// 			$idfrom=msql_result($res_tra1,0,'idfrom');
// 			$mdfrom=msql_result($res_tra1,0,'mdfrom');
			
      
//       if($idfrom!='')
//       {$sql_orig='select * from '.$mdfrom.'12 where idnum1="'.$idfrom.'"';}
			
      
//       if(($numfac*1)!=0)
//       {
//         $sql_orig ='select * from vtas12 ';
// //         $sql_orig ='select * from vtas1 ';
//         $sql_orig.='where numero="'.$numfac.'"';
//         $sql_orig.=' and status!="O"';
//         $sql_orig.=' and status!="X"';
//         $sql_orig.=' order by fecha desc ';
//         $sql_orig.=' limit 1 ';
//       }
//       $res_orig=msql_query($sql_orig,$link_vcrx);
      
// 			$docuorig=@msql_result($res_orig,0,'docu');
// 			$docuorigd=@msql_result($res_orig,0,'docu_descri');
// 			$numeroorig=@msql_result($res_orig,0,'ptonumero');
// 			$fechaorig=@msql_result($res_orig,0,'fechadmy');
// 			$autororig=@msql_result($res_orig,0,'claveacc');
//       if(substr($docuorig,0,2)=='FC'){$docuorigd='FACTURA';}
//       if(substr($docuorig,0,2)=='EB'){$docuorigd='EGRESO DE BODEGA';}
// 			if(substr($docuorig,0,2)=='FC'){$motivo='VENTA';}
// 			if(substr($docuorig,0,2)=='EB'){$motivo='TRANSFERENCIA';}
// 			if(substr($docuorig,0,4)=='EB10'){$motivo='VENTA';}
// 			if(substr($docuorig,0,4)=='EB13'){$motivo='TRANSFERENCIA';}
			
// 		}
			
// 		$xvndd='';
// 		$xfpag='';
// 		$xsuco='';

// 		if(mb_stristr('cont', $tabla))
// 		{
// 			$xtdebito=msql_result($res_tra1,0,'stdebito');
// 			$xtcredito=msql_result($res_tra1,0,'stcredito');
// 			$xdifer=msql_result($res_tra1,0,'sdiferencia');
// 		}
// 		if(mb_stristr('nomi.empl', $tabla))
// 		{
// 			$xtremun=msql_result($res_tra1,0,'stingreso');
// 			$xtdeduc=abs(msql_result($res_tra1,0,'stegreso'));
// 			$xtprovi=msql_result($res_tra1,0,'stprovis');
// 		}
// 		if(mb_stristr('vtas.clie.comi.comp.prov.dxco.dxpa.inve.prod.carr.tfin', $tabla))
// 		{
//       //costos
// 		  $xipuni=1;
// 			$xtunid=$xtcant;
// 			$xfpag=@msql_result($res_tra1,0,'fpag');
// 			if(mb_stristr('vtas.clie.comi.comp.prov.carr', $tabla))
// 			{
// 				$xipuni=1;
// 				$xpdcto=msql_result($res_tra1,0,'pdcto');
// 				$xpprop=msql_result($res_tra1,0,'pprop');
// 				$xpice=msql_result($res_tra1,0,'pice');
// 				$xpiva=msql_result($res_tra1,0,'piva');
// 				$xpirbp=msql_result($res_tra1,0,'pirbp');
// 				$xtdcto=msql_result($res_tra1,0,'stdcto');
// 				$xtprop=msql_result($res_tra1,0,'stprop');
// 				$xtsubtice=msql_result($res_tra1,0,'stsubtice');
// 				$xtice=msql_result($res_tra1,0,'stice');
// 				$xtsubtiva0=abs(msql_result($res_tra1,0,'stsubtiva0'));
// 				$xtsubtiva=abs(msql_result($res_tra1,0,'stsubtiva'));
// 				$xtiva=abs(msql_result($res_tra1,0,'stiva'));
// 				$xtirbp=msql_result($res_tra1,0,'stirbp');
// 			}
// 			if(mb_stristr('vtas.clie.comi.carr', $tabla))
// 			{
// 				$xtbien=@msql_result($res_tra1,0,'stbien');
// 				$xtserv=@msql_result($res_tra1,0,'stserv');
// 				$xtunid=$xtbien;
// 				$xvndd=@msql_result($res_tra1,0,'vndd');
// 				$xvndddes=r_fiel('enti',$xvndd);
// 			}
// 			if(mb_stristr('comp.prov', $tabla))
// 			{
// 				$xsuco=msql_result($res_tra1,0,'suco');
// 			}
// 			if(mb_stristr('inve.prod.tfin', $tabla))
// 			{
//            $docuacce='COST';
//            include('php_useracce.php');
//            $xipuni=$user_cons;
// //             $xipuni=0;
// 			}
// 		}

// 		if(mb_stristr('prod', $tabla) and $cfg_empr=='ecgl'){$xtunid=0;$xtotal=0;}
// 				$xtpeso=@msql_result($res_tra1,0,'speso');

    
    $sql_tra1 ='select * from '.$tabla.'0 ';
    if($tabla=='item')
    {
      $sql_tra1.='left join lsub0 on '.$tabla.'_lsub=lsub_codigo ';
      $sql_tra1.='left join mrca0 on '.$tabla.'_mrca=mrca_codigo ';
      $sql_tra1.='left join clor0 on '.$tabla.'_clor=clor_codigo ';
      $sql_tra1.='left join tlla0 on '.$tabla.'_tlla=tlla_codigo ';
    }
    $sql_tra1.='where '.$tabla.'_codigo="'.$idnum.'"';
    $res_tra1=msql_query($sql_tra1,$link_vcrx);
    
    
		$xiuser=msql_result($res_tra1,0,$tabla.'_iuser');
		$xidate=msql_result($res_tra1,0,$tabla.'_idate');
//     if($xidate==''){$xidate=msql_result($res_tra1,0,$tabla.'_idate');}


// 		$lblruc1='EMISOR';
// 		$lblruc2='ADQUIRIENTE';

// 		if(mb_stristr('cont',$tabla))
// 		{$lblruc1='EMPRESA';}
		
// 		if(mb_stristr('comp.retc',$tabla))
// 		{
// 			$res_emis=msql_query($sql_adqu,$link_vcrx);
// 			$res_adqu=msql_query($sql_emis,$link_vcrx);
// // 			if($cfg_empr =='demo')
// 			if(mb_stristr('demo.cele',$cfg_empr))
// 			{$res_adqu=msql_query($sql_toen,$link_vcrx);	}
// 		}

// 		if(mb_stristr('OP.QP',substr($docu,0,2)))
// 		{$lblruc2='TALLER';}

// 		if(mb_stristr('PC.PF.AC',substr($docu,0,2)))
// 		{$lblruc2='CLIENTE';}

// 		if(mb_stristr('IE.IC.IV.DC',substr($docu,0,2)))
// 		{$lblruc2='CLIENTE';}

// 		if(mb_stristr('EE.CH.EV.DP.RP.PP.AP',substr($docu,0,2)))
// 		{$lblruc2='PROVEEDOR';}

// 		if(mb_stristr('RCLI',substr($docu,0,4)))
// 		{
//       $lblruc1='CLIENTE';
//       $lblruc2='PROVEEDOR';
//     }

//     if(mb_stristr('inve.tfin',$tabla))
// 		{$lblruc2='ENTIDAD';}

// 		if(mb_stristr('susa.rolp.empl',$tabla))
// 		{$lblruc2='EMPLEADO';}

// 		if(mb_stristr('plan',$tabla))
// 		{
//       $lblruc1='ENTIDAD';
//       $lblruc2='CLIENTE';
//     }

// 		if(mb_stristr('atvd',$tabla))
// 		{
//       $lblruc1='ENTIDAD';
//       $lblruc2='EMPLEADO';
//     }

// 		if(mb_stristr('DB.DC',substr($docu,0,2)))
// 		{
//       $lblruc1='ENTIDAD';
//       $lblruc2='DEPOSITANTE';
//     }

// 		if(mb_stristr('FP11.FP03.IB10',substr($docu,0,4)))
// 		{
// 			$lblruc2='PROVEEDOR';
// 			$res_emis=msql_query($sql_emis,$link_vcrx);
// 			$res_adqu=msql_query($sql_adqu,$link_vcrx);
// 		}

				
	}	
}	

$lblruc1='EMISOR';  
  
?>	


<?php //////////////////////////////////////////////////////////	?>
<?php // $subdce=mk_subdce($claveacc); ?>

	<?php $xfontsize=$screensize; ?>
	<?php $filexml=$rutace.$xclaveacc.'.xml'; ?>
	<?php $filepdf=$rutace.$xclaveacc.'.pdf'; ?>
	<?php $filepdf2=$rutadoc.$docu_idnum.'.pdf'; ?>

	<?php $filexml=$rutace.$subdce.$xclaveacc.'.xml'; ?>
	<?php $filepdf=$rutace.$subdce.$xclaveacc.'.pdf'; ?>
	<?php $filepdf2=$rutadoc.$docu_idnum.'.pdf'; ?>


	<?php // if($destino=='mail'){ ?>
	<?php	//echo '<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "https://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">'; ?>
	<?php	//echo '<html xmlns="http://www.w3.org/1999/xhtml">'; ?>
	<?php // } ?>



<?php ob_start(); ?>
<div class="noprint">
<?php //echo date('H:i:s'); ?>
</div>

	<?php for($cdisplay=1;$cdisplay<=$mdisplay;$cdisplay++) { ?>

  <?php 
    $xfontfamily='font-family:arial;';  
//     if($cfg_empr=='ecgl' and mb_stristr('FC',substr($docu,0,2))){$destino='mat';}
//     if($cfg_empr=='dly1' and mb_stristr('FC.PC',substr($docu,0,2)) and $destino!='mail' and $cdisplay==2){$destino='mat';}
//     if(substr($destino,0,3)=='mat'){$xfontsize+=2; $xfontfamily='font-family:Courier New; font-weight:bolder;';$doculogo=0;}
    if(substr($destino,0,3)=='mat'){$xfontsize+=6; $xfontfamily='font-family:Courier New; font-weight:bolder;';$doculogo=0;}
    if(mb_stristr('pos.txt',$destino)){$xfontsize-=4; $xfontfamily='font-family:Courier New; font-weight:bolder;white-space:pre-wrap;';}
  ?>

	<?php if($cdisplay==2){?>
	  <div id="border-top" style="width:10mm; height:<?php echo $margin_top;?>mm"></div>
    <?php if(mb_stristr('tgck.sawo.ztej',$cfg_empr)  and substr($docu,0,2)=='FC') { ?>
      <div id="border-left" style="float:left; width:<?php echo $margin_left;?>mm; height:10mm;">
      </div>
    <?php } ?>
	<?php } ?>
	<div id="cele<?php echo $cdisplay;?>" 
			 style="border:solid 0px; <?php echo $xfontfamily;?>; 
              float:left;
							<?php if($cdisplay==1)
                {
                  if($width<=210){echo 'width:210mm;';}
                  else{echo 'width:'.$width.'mm;';}
                }
                else{echo 'width:'.$width.'mm;';}
              ?>
							<?php if($mdisplay>1){?>
							<?php //{echo 'width:'.$width.'mm;';}?>
							<?php } ?>
							font-size:<?php echo $xfontsize; ?>px;
							overflow:hidden;
							transform: scale(1);
							<?php if($cdisplay=='rotate'){echo 'transform:rotate(180deg);';} ?>;
              "
						 <?php  if($cdisplay==1){{echo 'class="noprint";';}}else{echo 'class="noscreen";';}?>>	

    
    
  <?php
  $docu_pdf = new FPDF('P','mm', $ppsize);
  $docu_pdf->AddPage();
	$docu_pdf->SetTitle($docu_descri.' '.$xptonumero);
	$docu_pdf->SetAuthor('Vicente Ruiz Espinoza - 09 96030568');																									
  $docu_pdf->setFillColor(240,240,240);                                                      
  $pdf_ancho=$docu_pdf->GetPageWidth()-20;
  $pdf_centro=$docu_pdf->GetPageWidth()/2-10;
  $ffamilyPDF='Arial';  
  $fsizePDF=$xfontsize;                                              
  if(mb_stristr(strtolower($xfontfamily),'courier'))                                                        
  {
    $ffamilyPDF='Arial';  
    $fsizePDF=$xfontsize-2;                                              
  }
  ?>    

<?php //$res_tra1=msql_query($sql_tra1,$link_vcrx); ?>    
    
<?php //msql_data_seek($res_tra1,0); ?>    
    
<?php
   // echo '*/*/*/'.$sql_tra1;
    ?>        
	<cabecera>
	<table border="0" width="100%" cellpadding="2" cellspacing="0" style="border-collapse:collapse;font-size:<?php echo $xfontsize; ?>px;">
			<tr style="font-weight:bolder; font-size:<?php echo $xfontsize; ?>px; background:<?php echo $gris1;?>; 
								 border-top:solid 1px; border-bottom:solid 1px;">
				<td width="20%">
				</td>
				<td width="60%" align="center" style="letter-spacing:5pt;">
				<?php
// 					if($formato==2){$titulcompro= 'DIARIO - CONTABLE';}
// 					else
					{
            $titulcompro='FICHA';
//             if($xclaveacc!="" and ($xambi!=1 or $cdisplay!=2)){$titulcompro.=' - ELECTRONICO';}
            if($tabla=='item' ){$titulcompro= 'FICHA DE ITEM';}
            if($tabla=='enti' ){$titulcompro= 'FICHA DE ENTIDAD';}
					}
          echo $titulcompro;
        ?>
				</td>
        
        <?php
          $docu_txt='';                                                        
          $docu_txt.=str_repeat('=',$coltxt).$eol;
          $docu_txt.=str_pad(''.$titulcompro.' ',$coltxt,$carbot,STR_PAD_BOTH).$eol;
          $docu_txt.=str_repeat('=',$coltxt).$eol;
				?>

        <?php 
          $docu_pdf->SetFont($ffamilyPDF,'B',$fsizePDF-2);
          $docu_pdf->SetFontSize($fsizePDF-2);
          $docu_pdf->Cell(0,5,$titulcompro,'TB',0,'C',false);
          $docu_pdf->ln();
          $posY1=$docu_pdf->getY()+1;                                                        
          $posY2=$docu_pdf->getY()+1;                                                        
        ?>
        
				<td width="20%" align="right" style="font-size:50%;">
					<?php if($xiuser!="" and $destino!='mail'){?>
					<?php echo 'REGISTRADO POR: ';?>
					<?php //echo r_fiel('enti',$xiuser,'nom1').' '.r_fiel('enti',$xiuser,'ape1');?>
					<?php echo r_fiel('user',$xiuser);?>
					<?php echo '<br>';?>
					<?php } ?>
					<?php echo date('d/M/y H:i:s',strtotime($xidate));?>
				</td>
			</tr>
		</table>		
	</cabecera>

		<?php $hlogo=20; if($cdisplay!=1){if($width<=150){$hlogo=15;}; if($width<=110){$hlogo=10;};} ?>
		<table border="0" width="100%" cellpadding="2" cellspacing="0" style="border-collapse:collapse;font-size:<?php echo $xfontsize; ?>px;">
			<tr>
				<?php //210*297 =62370 ?>
				<?php ///// COLUMNA IZQUIERDA ?>
				<td width="<?php if($width>=150 or 1==1){echo '60%';}else{echo '100%';}?>" <?php if($width>=150  or 1==1){}else{echo ' colspan="2"';}?> valign="top">

					<?php  ////  LOGO ?>
					<logo>
					<table border="1" width="100%" cellpadding="2" cellspacing="0" style="border-collapse:collapse;font-size:<?php echo $xfontsize; ?>px;">
						<tr>
							<?php //if(mb_stristr('FC.PF.GR.RP.IE',substr($docu,0,2)) and file_exists('../..'.$empr_logo2) and ($width<150 or 1==1)){ ?>
							<?php if($doculogo==1 and file_exists($rutalogo.$logofile2) and ($width<150 or 1==1)){ ?>
							<td align="center" style="">
							<?php if($empr_website!=''){?>
							<a target="_blank"  href="https://<?php echo $empr_website; ?>">
							<?php }else{ ?>
								<?php if($xclaveacc!=''){?>
								<a href="<?php echo 'https://'.$cfg_empr.'.vcrxol.com/?prnt=1&clave='.$xclaveacc;?>">
								<?php }else{ ?>
								<a href="<?php echo 'https://'.$cfg_empr.'.vcrxol.com/?prnt=1&docu='.$docu.'&idnum='.$idnum.'&formato='.$formato;?>">
								<?php } ?>
							<?php } ?>
							<img src="<?php echo 'https://vcrxol.com/_logo/'.$logofile2;?>" alt=""
									 title="<?php echo $empr_website; ?>" style="max-width:100%; max-height:<?php echo $hlogo;?>mm;">		
							</a>
							</td>
                <?php {
                  $xsrc='https://vcrxol.com/_logo/'.$logofile2;
                  $xsrc_fgc=file_get_contents($xsrc);                                                                                        
                  $img_xy=getimagesizefromstring($xsrc_fgc);
                  $img_w=$img_xy[0];
                  $img_h=$img_xy[1];
                  $img_rel=$img_w/$img_h;
                  $cel_w=$pdf_ancho*.6;                                                                                        
                  $cel_h=25;
                  if($img_w<$cel_w){$img_w=$cel_w;}
                  if($img_h<$cel_h){$img_h=$cel_h;}
                  if($img_h>=$cel_h){$img_h=$cel_h; $img_w=$img_rel*$img_h;}
                  if($img_w>=$cel_w){$img_w=$cel_w; $img_h=$img_rel/$img_w;}

                  if(mb_stristr($img_xy['mime'],'jpeg'))                                                                                                  
                  {$docu_pdf->Image($xsrc,(($cel_w-$img_w)/2)+10,$docu_pdf->getY()+(($cel_h-$img_h)/2)+3,$img_w,$img_h,'JPG');}
                  if(mb_stristr($img_xy['mime'],'png'))                                                                                                  
                  {$docu_pdf->Image($xsrc,(($cel_w-$img_w)/2)+10,$docu_pdf->getY()+(($cel_h-$img_h)/2)+3,$img_w,$img_h,'PNG');}

                  $docu_pdf->setY($posY1);                                                                                                  
                  $docu_pdf->Cell($pdf_ancho*.6,30,'','LRTB',0,'C',false);
                  $docu_pdf->ln();                                                                                                  
                  $posY1=$docu_pdf->getY()+1;
                  } ?>
							<?php } ?>
                
						</tr>
					</table>
					</logo>
					<div style="font-size:25%;"><br></div>

					<?php ///// BLOQUE L1 ?>
					<?php { ?>
					<table border="1" width="100%" cellpadding="2" cellspacing="0" 
                 style="border-collapse:collapse;font-size:<?php echo $xfontsize; ?>px;<?php echo $xfontfamily;?>">
						<tr style="border:solid 1px; font-weight:bolder; background: <?php echo $gris1;?>;">
							<td align="center" colspan=2 ><?php echo 'DATOS GENERALES'; ?></td>
						</tr>
						<tr style="display:none;">
							<td width="10%"></td>
							<td></td>
						</tr>
						<tr>
							<td align="right">CODIGO:</td>
							<td style="font-weight:bold;"><?php echo $idnum;?></td>
						</tr>
						<tr valign="top">
							<td align="right">DESCRIP:</td>
							<td>
                <?php echo msql_result($res_tra1,0,$tabla.'_descri');?>
              </td>
						</tr>

            <?php if($tabla=='enti'){ ?>
						<tr>
							<td align="right">RAZ.SOC.:</td>
							<td style="font-weight:bold;">
                <?php echo msql_result($res_tra1,0,'enti_razsoc');?>
              </td>
						</tr>
						<tr>
							<td align="right">NOM.COM.:</td>
							<td>
                <?php echo msql_result($res_tra1,0,'enti_nomcom');?>
              </td>
						</tr>
						<tr>
							<td align="right">MATRIZ:</td>
							<td>
                <?php echo msql_result($res_tra1,0,'enti_matriz');?>
              </td>
						</tr>
						<tr>
							<td align="right">DIRECCION:</td>
							<td>
                <?php echo msql_result($res_tra1,0,'enti_direccion');?>
              </td>
						</tr>
						<tr>
							<td align="right">CIUDAD:</td>
							<td>
                <?php echo msql_result($res_tra1,0,'enti_ciudad');?>
              </td>
						</tr>
							<td align="right">TELEFONO:</td>
							<td>
                <?php echo msql_result($res_tra1,0,'enti_telefono');?>
              </td>
						</tr>
            <?php } ?>
            
            
            
            <?php if($tabla=='item'){ ?>
						<tr>
							<td align="right" >MODELO:</td>
							<td style="font-weight:bold;">
                <?php echo msql_result($res_tra1,0,'item_mdlo');?>
              </td>
						</tr>
						<tr>
							<td align="right">MARCA:</td>
							<td>
                <?php echo msql_result($res_tra1,0,'mrca_descri');?>
              </td>
						</tr>
						<tr>
							<td align="right">EAN:</td>
							<td>
                <?php echo msql_result($res_tra1,0,'item_ean');?>
              </td>
						</tr>
						<tr>
							<td align="right">SKU:</td>
							<td>
                <?php echo msql_result($res_tra1,0,'item_sku').' /'.msql_result($res_tra1,0,'item_codigov');?>
              </td>
						</tr>
						<tr>
							<td align="right">COLOR:</td>
							<td>
                <?php echo msql_result($res_tra1,0,'clor_descri');?>
              </td>
						</tr>
            <?php } ?>
            
						<tr style="display:none;">
							<td align="right">TIPO:</td>
							<td>
                <?php if($tabla=='inve'){echo $docu.'-';}?>
                <?php echo $docu_descri;?>
              </td>
						</tr>
						<?php if(mb_stristr('prod',$tabla)){?>
							<tr style="text-transform:uppercase">
								<td align="right">ENTREGA:</td>
								<td><?php echo msql_result($res_tra1,0,'vencedian').' - '.msql_result($res_tra1,0,'vencedmy');?></td>
							</tr>
            <?php }?>
						<?php if(mb_stristr('vtas.comp.clie.prov',$tabla)){?>
							<?php if(msql_result($res_tra1,0,'plazo')>1){?>
							<tr style="text-transform:uppercase">
								<td align="right">VENCE:</td>
								<td><?php echo @msql_result($res_tra1,0,'vencedian').' - '.msql_result($res_tra1,0,'vencedmy');?></td>
							</tr>
							<?php}?>
							<?php if($xvndd!=""){?>
							<tr style="">
								<td align="right">VENDEDOR:</td>
								<td><?php echo $xvndd.' - '.$xvndddes;?></td>
							</tr>
							<?php}?>
						<?php }?>

						<?php if(mb_stristr('caja.bcos',$tabla)){?>
							<?php $caba=msql_result($res_tra1,0,'caba') ; ?>
              <?php if($tabla=='caja'){$caba=msql_result($res_tra1,0,'caja');}?>
              <?php if($tabla=='bcos'){$caba=msql_result($res_tra1,0,'ctab');}?>
							<?php $caba2=@msql_result($res_tra1,0,'caba2') ;?>
							<tr style="text-transform:uppercase">
								<td align="right"><?php if($tabla=='caja'){echo 'CAJA:';}else{echo 'CTA.BANC:';}?></td>
								<td><?php echo $caba.' - '.r_fiel('caba',$caba); ?></td>
							</tr>
							<?php if($caba!=$caba2 and $caba2!=''){?>
							<tr style="text-transform:uppercase">
								<?php if(mb_stristr('IE.DB',substr($docu,0,2))){?>
								<td align="right">ORIGEN:</td>
								<?php}else{?>
								<td align="right">DESTINO:</td>
								<?php}?>
								<td><?php echo $caba2.' - '.r_fiel('caba',$caba2); ?></td>
							</tr>
							<?php}?>
              <?php $fechadepo=@msql_result($res_tra1,0,'fechadepo'); ?>
              <?php $ctabdepo=@msql_result($res_tra1,0,'ctabdepo'); ?>
              <?php $numedepo=@msql_result($res_tra1,0,'numedepo'); ?>
              <?php $fcobro=@msql_result($res_tra1,0,'fcobro'); ?>
              <?php 
                if(!empty($numedepo)) 
                {
                  $sql_depo='select * from bcos1 ';
                  $sql_depo.='where docu like "DB%" and numero="'.$numedepo.'" and fecha>="'.$fecha.'"';
                  $sql_depo.=' and status!="O" and status!="X"';
                  $res_depo=msql_query($sql_depo,$link_vcrx);
                  $docudepo=msql_result($res_depo,0,'docu');
                  $idnumdepo=msql_result($res_depo,0,'idnum1');
                  
                }
              ?>
                  <?php if(@mb_stristr('ICH1.',$docu)){?>
                  <?php //echo '*/*/*/*'.$fcobro.' - '.$fecha; ?>
                     <?php if($fcobro>$fecha){  ?>
                        <tr style="; border-top:solid 2px;">
                        <td align="right">FEC.COBRO.:</td>
                        <td><?php if($fcobro!=''){echo date('D d/M/y',strtotime($fcobro));} ?></td>
                        </tr>
                     <?php } ?>
                     <?php if($numedepo!='' and $fechadepo<=$fechaa){?>
                        <tr style="text-transform:uppercase; border-top:solid 2px;">
                        <td align="right">FEC.DEPO.:</td>
                        <td><?php echo date('D d/M/y',strtotime($fechadepo)); ?></td>
                        </tr>
                        <tr style="text-transform:uppercase">
                        <td align="right">CTA.DEPO.:</td>
                        <td><?php echo $ctabdepo.' - '.r_fiel('ctab',$ctabdepo);; ?></td>
                        </tr>
                        <tr style="text-transform:uppercase">
                        <td align="right">NUM.DEPO.:</td>
                        <td>
                        <a href="<?php echo 'https://'.$cfg_empr.'.vcrxol.com/?prnt=1&docu='.$docudepo.'&idnum='.$idnumdepo.'&formato='.$formato;?>"  target="_blank" >
                        <?php echo $numedepo; ?>
                        </a>
                        </td>
                        </tr>
                     <?php }?>
                  <?php }?>
                  <?php if(@mb_stristr('CH10.',$docu)){?>
                     <?php {?>
                        <tr style="text-transform:uppercase; border-top:solid 2px;">
                        <td align="right">FEC.COBRO.:</td>
                        <td><?php if($fcobro!=''){echo date('D d/M/y',strtotime($fcobro));} ?></td>
                        </tr>
                     <?php }?>
                  <?php }?>
					<?php }?>
						
						<?php if(mb_stristr('inve.prod.tfin',$tabla)){?>
							<tr style="text-transform:uppercase">
								<td align="right">BODEGA:</td>
								<td><?php echo $bode.' - '.r_fiel('bode',$bode); ?></td>
							</tr>
							<?php if(substr($docu,2,2)=="13"){?>
							<tr style="text-transform:uppercase">
								<td align="right">BODEGA 2:</td>
								<td><?php echo $bode2.' - '.r_fiel('bode',$bode2) ;?></td>
							</tr>
							<?php}?>
						<?php }?>

						<?php if(mb_stristr('vtas.comp.retp.retc.guia.',$tabla)){?>
						<?php if($xclaveacc!=""){ ?>
            <?php if($xambi==2){$xambides='PRODUCCION';}else{$xambides='PRUEBAS';} ?>
						<tr style="font-size:80%; <?php if($xambi==1 and $cdisplay==2){ echo 'display:none;';}?>">
							<td align="right">AMBIENTE:</td>
							<td><?php echo $xambides;?></td>
						</tr>
						<?php } ?>
						<?php 

              $subdce=mk_subdce($claveacc);
							$filexml = $xclaveacc.'.xml';
							$filexmlb = $xclaveacc.'.xml';
							if(file_exists ('../../_cel/'.$subdce.$xclaveacc.'b.xml')){$filexmlb = $xclaveacc.'b.xml';}
						?>
						<?php if($xclaveacc!=""){ ?>
						<tr style="font-size:70%; <?php if(($xambi==1 and $cdisplay==2)or($cdisplay==2 and $xautornum!="")){ echo 'display:none;';}?>">
							<td align="right">CLAVE ACCESO:</td>
							<td>
								<a href="<?php if($cdisplay==1){echo 'https://vcrxol.com/_cel/'.$subdce.$filexmlb;}?>" 
									 title="Descargar XML" target="_blank"
										<?php if($xautornum=="" or $destino=='mail'){ ?>
 									 download="<?php echo substr($docu,0,1).'_'.substr($xclaveacc,10,13).'_'.substr($xclaveacc,24,6).'_'.substr($xclaveacc,30,9).''; ?>" 
									 <?php } ?>
									 >
								<?php
						 			if($cdisplay==1){echo $xclaveacc;}
						 			else{echo substr($xclaveacc,0,8).'.'.substr($xclaveacc,8,2).'.'.substr($xclaveacc,10,13).'.'.substr($xclaveacc,23,1)
										.'<br>'.substr($xclaveacc,24,6).'.'.substr($xclaveacc,30,9).'.'.substr($xclaveacc,39,8).'.'.substr($xclaveacc,47,2);}
								?>
								</a>
							</td>
						</tr>
						<?php } ?>
            
						<?php if($xautornum!=""){ ?>
						<tr style="font-size:70%; <?php if($xambi==1 and $cdisplay==2){ echo 'display:none;';}?>">
							<td align="right">AUTORIZACION:</td>
							<td>
								<a href="<?php if($cdisplay==1){echo 'https://vcrxol.com/_cel/'.$subdce.$filexml;}?>" 
									 title="Descargar XML AUTORIZADO"
									 download="<?php echo substr($docu,0,1).'_'.substr($xclaveacc,10,13).'_'.substr($xclaveacc,24,6).'_'.substr($xclaveacc,30,9).''; ?>">
								<?php
						 			if($cdisplay==1){echo $xautornum;}
						 			else
										{
											if($xautornum==$xclaveacc)
											{
												echo substr($xautornum,0,8).'.'.substr($xautornum,8,2).'.'.substr($xautornum,10,13).'.'.substr($xautornum,23,1)
												.'<br>'.substr($xautornum,24,6).'.'.substr($xautornum,30,9).'.'.substr($xautornum,39,8).'.'.substr($xautornum,47,2);
											}
											else
											{
												echo substr($xautornum,0,8).'.'.substr($xautornum,8,3).'.'.substr($xautornum,11,6)
												.'<br>'.substr($xautornum,17,9).'.'.substr($xautornum,26,10).'.'.substr($xautornum,36,1);
											}
										}
								?>
								</a>
							</td>
						</tr>
						<?php } ?>

						<?php if($xautorfec!="" and mb_stristr('FP.RC.',substr($docu,0,2))){ ?>
						<tr style="font-size:70%; <?php if($xambi==1 and $cdisplay==2){ echo 'display:none;';}?>">
							<td align="right">FECHA AUT.:</td>
							<td>
								<a href="<?php if($cdisplay==1){echo 'https://vcrxol.com/_cel/'.$subdce.$filexml;}?>" 
									 title="Descargar XML AUTORIZADO"
									 download="<?php echo substr($docu,0,1).'_'.substr($xclaveacc,10,13).'_'.substr($xclaveacc,24,6).'_'.substr($xclaveacc,30,9).''; ?>">
    								<?php echo $xautorfec;	?>
								</a>
							</td>
						</tr>
						<?php } ?>

						<?php if($xatrz!="" and mb_stristr('FP.RC',substr($docu,0,2)) and $xautorfec==""){ ?>
						<tr>
							<td align="right">AUTORIZACION:</td>
							<td align="left" style="<?php if($xatrzvali=='X'){echo 'color:red;';}?><?php if($xatrzvali=='O'){echo 'color:yellow;';}?>">
                <?php echo $xatrz; ?>
                <?php echo ' ('.$xatrzvali.')'; ?>
              </td>
						</tr>
						<?php } ?>
            
						<?php } ?>

						<?php if(mb_stristr($filepdf,'/.pdf')){$filepdf='';}?>
						
						<?php if(($docupdf==1 or $entipdf==1) and 1==2){?>
						<?php if(file_exists($filepdf) or $mdisplay==1){?>
						<tr class="noprint">
						<td align="right" style="font-size:70%;">DESCARGAR</td>
						<td align="center">
							<a href="<?php if($cdisplay==1){echo 'https://vcrxol.com/_cel/'.$subdce.$xclaveacc.'.pdf';}?>" 
								 title="Descargar RIDE"
								 download="<?php echo substr($docu,0,1).'_'.substr($xclaveacc,10,13).'_'.substr($xclaveacc,24,6).'_'.substr($xclaveacc,30,9).''; ?>"
								 >Formato RIDE </a>
						</td>
						</tr>
						<?php } ?>
						<?php }?>
						
						<?php if($xstatus!="-" and $xstatus!=''){ ?>
						<tr>
							<td align="right">STATUS:</td>
							<td style="<?php if(mb_stristr('XO',$xstatus)){
									echo 'background-color:darkred;color:white;font-weight:bolder;letter-spacing:5px;text-align:center;';} ?>">
								<?php echo @msql_result($res_tra1,0,'stat_descri');?></td>
						</tr>
						<?php}?>
						<?php if($xclaveacc!="" and $cdisplay==2){ ?>
						<?php } ?>
					</table>
					<?php}?>

					<?php ///// BLOQUE L2 ?>
					<?php
// 					if($guiaremi==0 and $formato!=2)
					if(!mb_stristr('guia.cont.nomi',$tabla) and 1==2)
					{
					?>
					<recibe>
					<table border="1" width="100%" cellpadding="2" cellspacing="0" 
								 style="border-collapse:collapse;font-size:<?php echo $xfontsize; ?>px;<?php echo $xfontfamily;?>;
                        <?php if(mb_stristr('DA16.EB13.IB13.EB17.IB17',$docu)){echo 'display:none;';}?>"
								 >
						<tr style="border:solid 1px; font-weight:bolder; background: <?php echo $gris1;?>;">
							<td align="center" colspan=2 style="letter-spacing:10px" ><?php echo $lblruc2; ?></td>
						</tr>
						<?php $enti_codigo=@msql_result($res_adqu,0,'enti_codigo'); ?>
						<?php $enti_razsoc=@msql_result($res_adqu,0,'enti_razsoc'); ?>
						<?php $enti_nomcom=@msql_result($res_adqu,0,'enti_nomcom'); ?>
						<?php $tipoId=@msql_result($res_adqu,0,'enti_tipoid'); ?>
						<?php $coesp=@msql_result($res_adqu,0,'enti_coesp'); ?>
						<?php $coesn=@msql_result($res_adqu,0,'enti_coesn'); ?>
						<?php $rise=@msql_result($res_adqu,0,'enti_rise'); ?>
						<?php $rime=@msql_result($res_adqu,0,'enti_rime'); ?>
						<?php $agret=@msql_result($res_adqu,0,'enti_agret'); ?>
						<?php $agren=@msql_result($res_adqu,0,'enti_agren'); ?>
            <?php
              $tipoIdComp='04';
              {
                if($tipoId=='R'){$tipoIdComp='04';}
                if($tipoId=='C'){$tipoIdComp='05';}
                if($tipoId=='P'){$tipoIdComp='06';}
                if($tipoId=='F'){$tipoIdComp='07';}
                if($tipoId=='E'){$tipoIdComp='08';}
                if($tipoId=='V'){$tipoIdComp='09';}
              }
              if(mb_stristr('06',$tipoIdComp)){$enti_codigo=msql_result($res_adqu,0,'enti_pasaporte');}  
              if(mb_stristr('08',$tipoIdComp)){$enti_codigo=msql_result($res_adqu,0,'enti_idexterior');}
//               if($enti_razsoc==''){reg_cedruc($enti_codigo);}
						  if(@msql_result($res_adqu,0,'enti_tipoid')=='P'){$enti_codigo=@msql_result($res_adqu,0,'enti_pasaporte');};
            ?>
						<tr valign="top">
							<td width="25%">RUC/C.I.</td>
							<td width="75%"><?php echo $enti_codigo;?></td>
						</tr>
						<tr valign="top" style="font-weight:bolder;">
							<td>RAZ. SOCIAL</td>
							<td><?php echo @msql_result($res_adqu,0,'enti_razsoc');?></td>
						</tr>
            
						<?php if(trim(@msql_result($res_adqu,0,'enti_razsoc'))!=trim(@msql_result($res_adqu,0,'enti_nomcom')) and @msql_result($res_adqu,0,'enti_nomcom')!=""){?>
						<tr valign="top">
							<td>NOM. COMERCIAL</td>
							<td><?php echo msql_result($res_adqu,0,'enti_nomcom');?></td>
						</tr>
						<?php } ?>

            <?php if(!empty($coesp) or !empty($coesn)){?>
						<tr valign="top">
							<td>CONT.ESPECIAL</td>
							<td><?php if($coesp==1){echo 'SI';}else{echo 'NO';}; echo ' ('.$coesn.')';?></td>
						</tr>
            <?php } ?>
            
            
						<?php $matriz=@msql_result($res_adqu,0,'enti_matriz');	?>
						<?php $direccion=@msql_result($res_adqu,0,'enti_direccion');	?>
						<?php $ciudad=@msql_result($res_adqu,0,'enti_ciudad');	?>
						<?php $calle1=@msql_result($res_adqu,0,'enti_calle1');	?>
						<?php $calle2=@msql_result($res_adqu,0,'enti_calle2');	?>
						<?php $calle3=@msql_result($res_adqu,0,'enti_calle3');	?>
						<?php $callen=@msql_result($res_adqu,0,'enti_callen');	?>
						<?php $parroq=@msql_result($res_adqu,0,'enti_parroq');	?>
            <?php //$parroq=r_fiel('enti',$enti_codigo,'enti_parroq'); ?>
						<?php $adqu_email1=@msql_result($res_adqu,0,'enti_email');	?>
						<?php $adqu_email2=@msql_result($res_adqu,0,'enti_emailce');	?>
						<?php $matriz=alltrim(str_replace('/',' /',$matriz));	?>
						<?php $parroq=alltrim(str_replace('/',' /',$parroq));	?>

                              <?php if(empty($direccion)){$direccion=@msql_result($res_adqu,0,'enti_matriz');} ?>
            
					<?php if(@mb_stristr('retp',$tabla) and ($coesp==1 or $rise==12 or $rime==12 or $agret==1)){?>
                <tr valign="top">
                  <td>CONTRIB. </td>
                  <td>
                    <?php if($coesp==1){echo 'ESPECIAL'.' ('.$coesn.')';};?>
                    <?php if($rise==12){echo 'RISE';}?>
                    <?php if($rime==12){echo ' REGIMEN MICRO EMPRESA';}?>
                    <?php if($rime==12 and $agret==1){echo '<br>';} ?>
                    <?php if($agret==1){echo 'AGENTE DE RETENCION';}?>
                  </td>
                </tr>
               <?php  } ?>
            
            
						<?php if(!mb_stristr('caja.bcos.inve.prod.susa.tfin',$tabla)){?>

						<?php if($matriz!='' or 1==1){?>
						<tr valign="top">
							<td>MATRIZ</td>
                                   <?php $parroq='';?>
							<td><?php echo $matriz.'<br>'.$parroq;?></td>
						</tr>
						<?php } ?>
						
						<?php if($matriz=='' and strlen(trim($direccion))>5){?>
						<tr valign="top">
							<td>DIRECCION</td>
							<td><?php echo $direccion;?></td>
						</tr>
						<?php } ?>
						
						<?php if($calle1!=''){?>
						<tr valign="top">
							<td>DIRECCION</td>
							<td>
              <?php echo $calle1.'('.$callen.') /'.$calle2;?>
							<?php if($calle3!=''){echo '<br>Ref: '.$calle3;}?>
              </td>
						</tr>
						<?php } ?>
						
						<?php if($ciudad!=''){?>
						<tr valign="top">
							<td>CIUDAD</td>
							<td>
              <?php echo $ciudad;?>
              </td>
						</tr>
						<?php } ?>
						
						<tr valign="top">
							<td>TELEFONO</td>
							<td><?php echo @msql_result($res_adqu,0,'enti_telefono');?></td>
						</tr>
						<tr valign="top">
							<?php
								  $adqu_email2=str_replace($adqu_email1,'',$adqu_email2);
									$adqu_email=trim($adqu_email1).';'.trim($adqu_email2);
							    $adqu_email=str_replace(';','; ',$adqu_email); 
							    $adqu_email=str_replace(',','; ',$adqu_email); 
              ?>
							<td>E-MAIL</td>
							<td><?php echo strtolower($adqu_email);?></td>
						</tr>
						<?php } ?>
						
					</table>			
          <?php
             $docu_txt.=str_pad($lblruc2.' ',$coltxt,$carbot,STR_PAD_BOTH).$eol;
             $docu_txt.='RUC     : '.$enti_codigo.$eol;
             $docu_txt.='RAZ.SOC.: '.@msql_result($res_adqu,0,'enti_razsoc').$eol;
             if($enti_razsoc!=$enti_nomcom and $enti_nomcom!='')
             {$docu_txt.='NOM.COM.: '.@msql_result($res_adqu,0,'enti_nomcom').$eol;}
             $docu_txt.='MATRIZ  : '.trim(@msql_result($res_adqu,0,'enti_matriz')).$eol;
             $docu_txt.='TELEF.  : '.@msql_result($res_adqu,0,'enti_telefono').$eol;
             $docu_txt.='E-MAIL  : '.$adqu_email.$eol;
             $docu_txt.=$eol;
          ?>
        <?php 
//           $posY=84;
					$adqu_email=str_replace('; ',';',$adqu_email);
          $docu_pdf->SetFont($ffamilyPDF,'B',$fsizePDF-2);
          $docu_pdf->SetY($posY1);
          $docu_pdf->Cell($pdf_ancho*.6,5,$lblruc2,'LRTB',0,'C',true);
          $docu_pdf->SetFont($ffamilyPDF,'',$fsizePDF-3);
          $docu_pdf->ln();

          $docu_pdf->Cell($pdf_ancho*.2,5,'RUC :','LRT',0,'L',false);
          $docu_pdf->MultiCell($pdf_ancho*.4,5,$enti_codigo,'LRT','L',false);
          $docu_pdf->Cell($pdf_ancho*.2,5,'RAZ. SOCIAL :','LRT',0,'L',false);
          $docu_pdf->MultiCell($pdf_ancho*.4,5,@msql_result($res_adqu,0,'enti_razsoc'),'LRT','L',false);
          if(trim(@msql_result($res_adqu,0,'enti_razsoc'))!=trim(@msql_result($res_adqu,0,'enti_nomcom')) and @msql_result($res_adqu,0,'enti_nomcom')!="")
          {
          $docu_pdf->Cell($pdf_ancho*.2,5,'NOM. COMERCIAL :','LRT',0,'L',false);
          $docu_pdf->MultiCell($pdf_ancho*.4,5,@msql_result($res_adqu,0,'enti_nomcom'),'LRT','L',false);
          }
          $docu_pdf->Cell($pdf_ancho*.2,5,'MATRIZ :','LRT',0,'L',false);
          $docu_pdf->MultiCell($pdf_ancho*.4,5,utf8_decode(@msql_result($res_adqu,0,'enti_matriz')),'LRT','L',false);
          $docu_pdf->Cell($pdf_ancho*.2,5,'TELEFONO :','LRT',0,'L',false);
          $docu_pdf->MultiCell($pdf_ancho*.4,5,@msql_result($res_adqu,0,'enti_telefono'),'LRT','L',false);
          $docu_pdf->Cell($pdf_ancho*.2,5,'E-MAIL :','LRT',0,'L',false);
          $docu_pdf->SetFontSize($fsizePDF-3);
          $docu_pdf->MultiCell($pdf_ancho*.4,5,strtolower($adqu_email),'LRT','L',false);
          $docu_pdf->Cell($pdf_ancho*.2,1,'','T',0,'',false);
          $docu_pdf->MultiCell($pdf_ancho*.4,1,'','T','',false);
          $posY1=$docu_pdf->getY();
                                
        ?>
            
					</recibe>	
						
					<?php}?>

					<?php ///// BLOQUE L3 ?>
					<?php{?>
					<div style="font-size:25%;"><br></div>
					<table border="1" width="100%" cellpadding="2" cellspacing="0" 
                 style="border-collapse:collapse;font-size:<?php echo $xfontsize; ?>px;<?php echo $xfontfamily;?>">
						<tr style="border:solid 1px; font-weight:bolder; background: <?php echo $gris1;?>;">
							<td align="center" colspan=2 ><?php echo 'INFORMACION ADICIONAL'; ?></td>
						</tr>
						<tr style="display:none;">
							<td width="30%"></td>
							<td></td>
						</tr>

						<?php if(mb_stristr('cont', $tabla)){?>
							<tr>
								<td>ENTIDAD</td>
								<td><?php echo @msql_result($res_tra1,0,'enti_descri');?></td>
							</tr>
						<?php } ?>



						<?php if(mb_stristr('carr', $tabla)){?>
                  <?php $toenti=@msql_result($res_tra1,0,'toenti'); ?>
							<tr>
								<td>FACTURAR</td>
								<td><?php echo $toenti;?></td>
							</tr>
						<?php } ?>


						<tr style=<?php if($xconcepto==""){echo 'display:none;';}?>>
							<td>CONCEPTO</td>
							<td><?php echo $xconcepto;?></td>
						</tr>

            
						<?php if(mb_stristr('inve.tfin', $tabla)){?>
							<?php $bode=@msql_result($res_tra1,0,'bode') ;?>
							<?php $bode2=@msql_result($res_tra1,0,'bode2') ;?>
							<?php $numfac=@msql_result($res_tra1,0,'numfac') ;?>
						<?php } ?>
            
            
            <?php if($ximpor!="") {?>
						<tr style="font-weight:bolder;">
							<td align="center" colspan="3">IMPORTACION :<?php echo $ximpor;?></td>
<!-- 							<td align="center"><?php echo $ximpor;?></td> -->
						</tr>
            <?php } ?>

						<?php if(mb_stristr('EB10.EB19',$docu)){?>
							<tr>
								<td>FACTURA:</td>
								<td><?php echo $numfac; ?></td>
							</tr>
						<?php }?>
            
						<?php if(mb_stristr('FC10',$docu)){?>
            <?php $xidinve=get_idinve($docu,$idnum); ?>
            <?php $xebodega=r_fiel('inve1',$xidinve,'numero'); ?>
						<?php if($xebodega!=''){?>
							<tr style="text-transform:uppercase">
								<td>EGRE.BODEGA:</td>
								<td><?php echo $xebodega; ?></td>
							</tr>
						<?php }?>
  					<?php }?>
            
            
            
            <?php if($docu=='FP16'){?>
						<tr>
							<td>SEGURO</td>
							<td align="right"><?php echo number_format($xseguro1,2);?></td>
						</tr>
						<tr>
							<td>FLETE</td>
							<td align="right"><?php echo number_format($xflete1,2);?></td>
						</tr>
            <?php } ?>

            
						<?php if(@mb_stristr('DA16.',$docu)){?>
            <?php if($xcostoe1!=0){?>
            <tr align="right" style="font-weight:;">
							<td>COSTO EXT:</td>
							<td><?php echo number_format($xcostoe1,2);?></td>
						</tr>
            <?php } ?>
						<tr align="right" style="font-weight:;">
							<td>FOB:</td>
							<td><?php echo number_format($xfob1,2);?></td>
						</tr>
						<tr align="right" style="font-weight:;">
							<td>SEGURO:</td>
							<td><?php echo number_format($xseguro1,2);?></td>
						</tr>
						<tr align="right" style="font-weight:;">
							<td>FLETE:</td>
							<td><?php echo number_format($xflete1,2);?></td>
						</tr>
						<tr align="right" style="font-weight:bolder;<?php if($xcif1==0){echo 'display:none;';} ?>">
							<td>CIF:</td>
							<td><?php echo number_format($xcif1,2);?></td>
						</tr>
<!-- 						<tr><td colspan="2"><hr></td></tr> -->
						<tr align="right" style="font-weight:;">
							<td>AD-VALOR:</td>
							<td><?php echo number_format($xadva,2);?></td>
						</tr>
						<tr align="right" style="font-weight:;">
							<td>ESPECIFICO:</td>
							<td><?php echo number_format($xespe,2);?></td>
						</tr>
						<tr align="right" style="font-weight:;">
							<td>DUMPING:</td>
							<td><?php echo number_format($xdump,2);?></td>
						</tr>
						<tr align="right" style="font-weight:;">
							<td>FODINFA:</td>
							<td><?php echo number_format($xfodi,2);?></td>
						</tr>
						<tr align="right" style="font-weight:;">
<!-- 							<td>IVA:</td> -->
<!-- 							<td><?php //echo number_format($xivai,2);?></td> -->
						</tr>
						<tr align="right" style="font-weight:;<?php if($xicei==0){echo 'display:none;';} ?>">
							<td>ICE:</td>
							<td><?php echo number_format($xicei,2);?></td>
						</tr>
						<tr align="right" style="font-weight:;">
							<td>COSTO LOC:</td>
							<td><?php echo number_format($xcostol1,2);?></td>
						</tr>
            <?php $xtiva=abs($xtiva);?>
            <?php $totalimpo=$xcostoe1+$xfob1+$xseguro1+$xflete1+$xcif1+$xadva+$xespe+$xdump+$xfodi+$xicei+$xcostol1;  ?>
						<?php } ?>
            
            
						<?php if(@mb_stristr('CH', substr($docu,0,2))){?>
              <tr style=<?php if($xbenefic ==""){echo 'display:none;';}?>>
                <td>BENEFICIARIO</td>
                <td><?php echo $xbenefic;?></td>
              </tr>
						<?php } ?>
            
            <?php if($cfg_empr=='gnya' and @mb_stristr('FC',substr($docu,0,2))) { ?>
            <?php
              $sql_user='select * from user0 where user_cedula like "'.substr($enti_codigo,0,10).'%" order by user_codigo desc';
              $res_user=msql_query($sql_user,$link_vcrx);
              $user_enti=@msql_result($res_user,0,'user_codigo');
              $user_referidox=@msql_result($res_user,0,'user_referidox');
              $referxdesc=r_fiel('user',$user_referidox);                        
            ?>
						<tr style=<?php if($user_enti==""){echo 'display:none;';}?>>
							<td>CODIGO</td>
							<td><?php echo $user_enti;?></td>
						</tr>
						<tr style=<?php if($referxdesc==""){echo 'display:none;';}?>>
							<td>REFERIDO X</td>
							<td><?php echo $referxdesc;?></td>
						</tr>
            <?php } ?>

            <?php if($cfg_empr=='gmny' and mb_stristr('CA',substr($docu,0,2))) { ?>
						<tr style=<?php if($attn==""){echo 'display:none;';}?>>
							<td>ATENCION</td>
							<td><?php echo $attn;?></td>
						</tr>
            <?php } ?>

						<tr style=<?php if($xattn==""){echo 'display:none;';}?>>
							<td>ATENCION</td>
							<td><?php echo $xattndes;?></td>
						</tr>

            
          <?php
             $docu_txt.=str_pad('INFO ADICIONAL ',$coltxt,$carbot,STR_PAD_BOTH).$eol;
             if($xconcepto!='')
             {$docu_txt.='CONCEPTO : '.$xconcepto.$eol;}
             $docu_txt.=$eol;
          ?>
            
        <?php 
          $docu_pdf->SetFont($ffamilyPDF,'B',$fsizePDF-2);
          $docu_pdf->SetY($posY1);
          $docu_pdf->Cell($pdf_ancho*.6,5,'INFORMACION ADICIONAL','LRTB',0,'C',true);
          $docu_pdf->SetFont($ffamilyPDF,'',$fsizePDF-3);
          $docu_pdf->ln();
             
         ?>
            <?php if($xattn!=''){ ?>
            <?php
            $docu_pdf->Cell($pdf_ancho*.2,5,'ATENCION :','LRT',0,'L',false);
            $docu_pdf->MultiCell($pdf_ancho*.4,5,utf8_decode($xattndes),'LRT','L',false);
            $posY1=$docu_pdf->getY();
            ?>
            <?php}?>
            
            <?php if($xconcepto!=''){ ?>
            <?php
            $docu_pdf->Cell($pdf_ancho*.2,5,'CONCEPTO :','LRT',0,'L',false);
            $docu_pdf->MultiCell($pdf_ancho*.4,5,utf8_decode($xconcepto),'LRT','L',false);
            $posY1=$docu_pdf->getY();
            ?>
            <?php}?>
            
            <?php $drtr=@msql_result($res_tra1,0,'drtr'); ?>
            <?php $drtr_descri=r_fiel('enti',$drtr); ?>
            <?php if($drtr!=''){ ?>
            <?php
              $docu_pdf->Cell($pdf_ancho*.2,5,'DIRECTOR :','LRT',0,'L',false);
              $docu_pdf->MultiCell($pdf_ancho*.4,5,utf8_decode($drtr_descri),'LRT','L',false);
              $posY1=$docu_pdf->getY();
            ?>
            <?php}?>
            
            <?php
              $docu_pdf->Cell($pdf_ancho*.2,1,'','T',0,'',false);
              $docu_pdf->MultiCell($pdf_ancho*.4,1,'','T','',false);
              $posY1=$docu_pdf->getY();
            ?>
            
            
						<?php if(mb_stristr('comp', $tabla)){ ?>
						<?php $adicionales=@msql_result($res_tra1,0,'infoadic'); ?>
						<?php $adicionales=str_replace('[[','',$adicionales); ?>
						<?php $adicionales=str_replace(']]',' : ',$adicionales); ?>
						<?php $adicionales=str_replace('||','<br>',$adicionales); ?>
            
						<?php $adicionales=str_replace('{"','',$adicionales); ?>
						<?php $adicionales=str_replace('":"',' : ',$adicionales); ?>
						<?php $adicionales=str_replace('"}','<br>',$adicionales); ?>
						<tr style="display:none;">
							<td>ADICIONAL</td>
							<td><?php //echo $adicionales;?></td>
						</tr>
						<?php } ?>
            
						<?php 
						 if(mb_stristr('vtas.clie.comi.carr.comp', $tabla))
						 {
							 $adicionales=@msql_result($res_tra1,0,'infoadic'); 
							 $adicionales='<tr>'.$adicionales.'</tr>';
							 $adicionales=str_replace(',',', ',$adicionales); 
							 $adicionales=str_replace('  ',' ',$adicionales); 
							 $adicionales=str_replace('[[','<td>',$adicionales); 
							 $adicionales=str_replace(']]','</td><td>',$adicionales); 
							 $adicionales=str_replace('||','</td></tr><tr>',$adicionales); 
               
							 $adicionales=str_replace('{"','<td>',$adicionales); 
							 $adicionales=str_replace('":"','</td><td>',$adicionales); 
							 $adicionales=str_replace('"}','</td></tr><tr>',$adicionales); 
               
               
							 $adicionales=str_replace('|','| ',$adicionales); 
               
               $adicionales=str_replace('; ',';',$adicionales); 
               $adicionales=str_replace('; ',';',$adicionales); 
               $adicionales=str_replace('; ',';',$adicionales); 
               $adicionales=str_replace(';','; ',$adicionales); 
               
							 if(mb_stristr($adicionales,'<td>')) 
							 {echo $adicionales;}
						 } 
						?>

						<?php if(mb_stristr('comp.prov', $tabla)){?>
						<tr style="font-size:75%;<?php if($xsuco==0){echo 'display:none;';}?>" >
							<td>SUSTENT.COMP.</td>
							<td><?php echo msql_result($res_tra1,0,'suco_descri');?></td>
						</tr>
						<?php}?>

            <?php if(mb_stristr('clie.vtas', $tabla) and $cfg_empr=='dly1'){?>
            <?php $drtr=msql_result($res_tra1,0,'drtr'); ?>
            <?php $drtr_descri=r_fiel('enti',$drtr); ?>
						<tr style="font-size:100%;<?php if($drtr==''){echo 'display:none;';}?>" >
							<td>DIRECTOR</td>
							<td><?php echo $drtr.' /'.$drtr_descri; ?></td>
						</tr>
						<?php}?>

         </table>					
					<?php}?>

				<?php if($width>=150 or 1==1){?>					
				</td>
					
				<?php if($tirilla==1){ ?>
				</tr><tr>	
				<?php } ?>	

      
      
      
      
				<?php ///// COLUMNA DERECHA ?>
				<td width=40% valign="top">
				<?php }else{ ?>
				</tr>	
				<tr valign="top">
					<td width=50% valign="top">
				<?php } ?>
					
					<?php  //// CODEBAR ?>
					<table border="1" width="100%" cellpadding="2" cellspacing="0" 
                 style="border-collapse:collapse;font-size:<?php echo $xfontsize; ?>px;<?php echo $xfontfamily;?>">
						<tr>
							<?php if($doculogo==1 and file_exists($rutalogo.$logofile2) and ($width<150 or 1==1)){ ?>
							<td align="center" style="" height="<?php echo $hlogo*3;?>mm"</td>
							<?php if($destino=='mail' or 1==1){ ?>
								<?php if($xclaveacc!=""){?>
									<?php gen_bcod($xclaveacc);?>
                  <?php if($tiporuc=='N'){?>
									<a href="<?php echo 'https://'.$cfg_empr.'.vcrxol.com/print1.php?clave='.$xclaveacc;?>">
                  <?php }else{ ?>
									<a href="<?php echo 'https://vcrxol.com/_cel/'.$subdce.$claveacc.'.pdf'; ?>">
                  <?php } ?>
                  <?php $xsrc='https://vcrxol.com/_bcod/'.$xclaveacc.'.jpg'; ?>
									<img src="<?php echo $xsrc;?>" alt=""
											 title="PDF" style="max-width:100%; max-height:<?php echo $hlogo;?>mm;">		
									</a>
									<?php }else{?>
									<?php gen_bcod($cfg_ruc.'_'.$xptonumero);?>
                  <?php $xsrc='https://vcrxol.com/_bcod/'.$cfg_ruc.'_'.$xptonumero.'.jpg'; ?> 
									<img src="<?php echo $xsrc;?>" alt=""
											 title="<?php echo $xptonumero;?>" style="max-width:100%; max-height:<?php echo $hlogo;?>mm;">		
									<?php }?>
							<?php }else{ ?>
								<barcode style="font-size:28px; padding:0px; margin:1px; letter-spacing:1pt; font-weight:normal;">
								<?php if($xclaveacc!=""){echo $xclaveacc;}else{echo $cfg_ruc.' '.$xptonumero;}	?>
								</barcode>	
							<?php } ?>
							</td>
        <?php 
//           $docu_pdf->Image($xsrc,$pdf_ancho*.605+15,20,$pdf_ancho*.35,10,'JPG');
          $docu_pdf->Image($xsrc,$pdf_ancho*.605+15,16,$pdf_ancho*.35,18,'JPG');
          $docu_pdf->Link($pdf_ancho*.605+15,20,$pdf_ancho*.35,10,'https://'.$cfg_empr.'.vcrxol.com/print1.php?clave='.$xclaveacc);
          $docu_pdf->setY($posY2);
          $docu_pdf->setX($pdf_ancho*.605+10);
          $docu_pdf->Cell($pdf_ancho*.4,20,'.','LRTB',0,'R',false);
          $docu_pdf->ln();
          $posY2=$docu_pdf->getY()+1;                                                                                                  
        ?>
							<?php } ?>
            
						</tr>
					</table>
					<div style="font-size:25%;"><br></div>
						
						
						
					<?php ///// BLOQUE R1 ?>
					<datos>
					<?php   { ?>

            <?php if($tabla=='enti'){ ?>
            
            <?php
              $xtipoenti='';
              $sql_docu='select * from vtas1 where enti like "'.substr($idnum,0,10).'%" and status not in("O","X") limit 1';
              $res_docu=msql_query($sql_docu,$link_vcrx);
              if(msql_num_rows($res_docu)>0){$xtipoenti.=' /CLIENTE';}

              $sql_docu='select * from comp1 where enti like "'.substr($idnum,0,10).'%" and status not in("O","X") limit 1';
              $res_docu=msql_query($sql_docu,$link_vcrx);
              if(msql_num_rows($res_docu)>0){$xtipoenti.=' /PROVEEDOR';}
                                  
              $sql_docu='select * from nomi2 where enti like "'.substr($idnum,0,10).'%" and status not in("O","X") limit 1';
              $res_docu=msql_query($sql_docu,$link_vcrx);
              if(msql_num_rows($res_docu)>0){$xtipoenti.=' /EMPLEADO';}
                                  
            ?>
            
          <table id="deta_<?php echo $tabla.'_'.$cdisplay;?>" class="deta<?php echo $cdisplay;?>"
                 border="1" width="100%" cellpadding="2" cellspacing="0"
                 style="border-collapse:collapse;font-size:<?php echo $xfontsize; ?>px;<?php echo $xfontfamily;?>">
            <tr style="border:solid 1px; font-weight:bold; background-color:<?php echo $gris1;?>;"><th colspan="2">OTROS</th></tr>
						<tr>
							<td align="right">TIPO</td>
							<td>
                <?php echo $xtipoenti;?>
              </td>
						</tr>
						<tr>
							<td align="right" valign="top">ACTIVIDAD:</td>
							<td style="font-size:<?php echo $xfontsize * 0.8;?>px">
                <?php echo msql_result($res_tra1,0,'enti_actividad');?>
              </td>
						</tr>
						<tr>
							<td align="right">INI.ACTIV.:</td>
							<td>
                <?php echo msql_result($res_tra1,0,'enti_fechaini');?>
              </td>
						</tr>
						<tr>
							<td align="right">ST.RUC:</td>
							<td>
                <?php echo msql_result($res_tra1,0,'enti_struc');?>
              </td>
						</tr>
						<tr>
							<td align="right">CONTRIB.:</td>
							<td>
                <?php
                  if(msql_result($res_tra1,0,'enti_coesp')==1){echo 'ESPECIAL';}
                  if(msql_result($res_tra1,0,'enti_rise')==1){echo 'RISE';}
                  if(msql_result($res_tra1,0,'enti_rime')==1){echo 'RIME';}
               if(msql_result($res_tra1,0,'enti_rime')==1 and msql_result($res_tra1,0,'enti_agret')==1){echo '<br>';} 
                  if(msql_result($res_tra1,0,'enti_agret')==1){echo 'AGENTE DE RETENCION';}
                ?>
              </td>
						</tr>
						<tr>
							<td align="right">OBLI.CONT.</td>
							<td>
                <?php
                  if(msql_result($res_tra1,0,'enti_obcon')==1){echo 'SI';}else{echo 'NO';}
                ?>
              </td>
						</tr>
            
            </table>
            <?php } ?>
            
            
            <?php if($tabla=='item'){ ?>
          <table id="deta_<?php echo $tabla.'_'.$cdisplay;?>" class="deta<?php echo $cdisplay;?>"
                 border="1" width="100%" cellpadding="2" cellspacing="0"
                 style="border-collapse:collapse;font-size:<?php echo $xfontsize; ?>px;<?php echo $xfontfamily;?>">
            <tr style="border:solid 1px; font-weight:bold; background-color:<?php echo $gris1;?>;"><th colspan="2">OTROS</th></tr>
						<tr>
							<td align="right">LINEA:</td>
							<td>
                <?php echo r_fiel('lsub',substr(msql_result($res_tra1,0,'item_lsub'),0,5));?>
              </td>
						</tr>
							<td align="right">SUB-LINEA:</td>
							<td>
                <?php echo msql_result($res_tra1,0,'lsub_descri');?>
              </td>
						</tr>
            </table>
            <?php } ?>
            
            
      
    <?php if($tabla=='item'){ ?>
      
    <?php
         $sql_pant ='select distinct clor_codigo,clor_descri,clor_hexa ';
          $sql_pant.='from item0 left join clor0 on item_clor=clor_codigo  ';
          $sql_pant.='where item_mdlo="'.msql_result($res_tra1,0,'item_mdlo').'"  ';
//           $sql_pant.='and item_codigo like "'.$codigo.'%" ';
          $sql_pant.='and item_clor>0 ';
//           $sql_pant.='group by substring(item_codigo,1,8),teki_dato ';
          $sql_pant.='order by item_clor ';
          $res_pant=msql_query($sql_pant,$link_vcrx);
    
          $numclor=msql_num_rows($res_pant);
          $widclor=round(100/$numclor,0)-1;
          $widclor=1;
//     echo $sql_pant;
    ?>  
    <?php if(msql_num_rows($res_pant)>0){?>  
  <br>            
		<table id="deta_<?php echo $tabla.'_'.$cdisplay;?>" class="deta<?php echo $cdisplay;?>"
					 border="0" width="100%" cellpadding="2" cellspacing="0"
					 style="border-collapse:collapse;font-size:<?php echo $xfontsize; ?>px;<?php echo $xfontfamily;?>">
      <tr style="border:solid 1px; font-weight:bold; background-color:<?php echo $gris1;?>;"><th colspan="2">COLORES</th></tr>
      <?php msql_data_seek($res_pant,0); ?>
      <?php while($aso_pant=msql_fetch_assoc($res_pant)){ ?>
      <tr>
        <td align="center"  
            style="border:solid 1px; font-weight:bold;background-color:<?php echo $aso_pant['clor_hexa']; ?>;">
            <?php echo msql_result($res_tra1,0,'item_mdlo').'.'.$aso_pant['clor_codigo'];?></td>
        <td align="center" 
            style="border:solid 1px; font-weight:bold;background-color:<?php echo $aso_pant['clor_hexa']; ?>;">
            <?php echo str_replace(' ',' ',$aso_pant['clor_descri']);?></td>
      </tr>
      <?php } ?>
      </table>      

    <?php } ?>
    <?php } ?>
            
            
					<?php}?>

          <?php
             $docu_txt.=str_pad('DATOS DEL COMPROBANTE ',$coltxt,$carbot,STR_PAD_BOTH).$eol;
             $docu_txt.= 'TIPO         : '.$docu_descri.$eol;
             $docu_txt.= 'NUMERO       : '.@msql_result($res_tra1,0,'ptonumero').$eol;
             $docu_txt.= 'FECHA        : '.@msql_result($res_tra1,0,'fdian').' '.@msql_result($res_tra1,0,'fechadmy').$eol;
             if($vndd!='')
             {$docu_txt.= 'VENDEDOR     : '.$vndd.$eol;}
             if($claveacc!='')
             {
               $docu_txt.= 'AMBIENTE     : '.$xambides.$eol;
               $docu_txt.= 'CLAVE ACCESO : '.$eol;
               $docu_txt.= format_claveacc($claveacc).$eol;
             }
             $docu_txt.=$eol;
               
          ?>
        <?php 
//           $posY=48;
          $docu_pdf->SetFont($ffamilyPDF,'B',$fsizePDF-2);
          $docu_pdf->SetY($posY2);
          $docu_pdf->SetX($pdf_ancho*.605+10);
          $docu_pdf->Cell($pdf_ancho*.4,5,'DATOS DEL COMPROBANTE','LRTB',0,'C',true);
          $docu_pdf->SetFont($ffamilyPDF,'',$fsizePDF-3);
          $docu_pdf->ln();
          $docu_pdf->SetX($pdf_ancho*.605+10);
          $docu_pdf->Cell($pdf_ancho*.1,5,'TIPO :','LRT',0,'R',false);
          $docu_pdf->MultiCell($pdf_ancho*.3,5,$docu_descri,'LRT','L',false);
          $docu_pdf->SetFont($ffamilyPDF,'B',$fsizePDF-3);
          $docu_pdf->SetX($pdf_ancho*.605+10);
          $docu_pdf->Cell($pdf_ancho*.1,5,'NUMERO :','LRT',0,'R',false);
          $docu_pdf->MultiCell($pdf_ancho*.3,5,@msql_result($res_tra1,0,'ptonumero'),'LRT','L',false);
          $docu_pdf->SetFont($ffamilyPDF,'',$fsizePDF-3);
          $docu_pdf->SetX($pdf_ancho*.605+10);
          $docu_pdf->Cell($pdf_ancho*.1,5,'FECHA :','LRT',0,'R',false);
          $docu_pdf->MultiCell($pdf_ancho*.3,5,utf8_decode(@msql_result($res_tra1,0,'fdian')).' '.@msql_result($res_tra1,0,'fechadmy'),'LRT','L',false);
					if(mb_stristr('vtas.comp.clie.prov',$tabla) and msql_result($res_tra1,0,'plazo')>1 )
					{
          $docu_pdf->SetX($pdf_ancho*.605+10);
          $docu_pdf->Cell($pdf_ancho*.1,5,'VENCE :','LRT',0,'R',false);
          $docu_pdf->MultiCell($pdf_ancho*.3,5,@msql_result($res_tra1,0,'vencedmy'),'LRT','L',false);
					}
          $docu_pdf->SetX($pdf_ancho*.605+10);
          $docu_pdf->SetFontSize($fsizePDF-4);

// 					if($xclaveacc!='')
					if($xclaveacc!='' and mb_stristr('01.03.04.05.06.07',substr($xclaveacc,8,2)))
					{
            $subdce=mk_subdce($claveacc);
            
            $docu_pdf->Cell($pdf_ancho*.1,5,'AMBIENTE :','LRT',0,'R',false);
            $docu_pdf->MultiCell($pdf_ancho*.3,5,$xambides,'LRT','L',false);

						$docu_pdf->SetFontSize($fsizePDF-6.5);
						$docu_pdf->SetTextColor(0,0,0);
          	$docu_pdf->SetFont($ffamilyPDF,'');
						$docu_pdf->Link($pdf_ancho*.605+10,$docu_pdf->GetY(),$pdf_ancho*.4,5,'https://vcrxol.com/_cel/'.$subdce.$filexmlb);
						$docu_pdf->SetX($pdf_ancho*.605+10);
						$docu_pdf->Cell($pdf_ancho*.1,5,'CLAVE ACCESO :','LRT',0,'R',false);
						$docu_pdf->SetFont($ffamilyPDF,'U');
						$docu_pdf->SetTextColor(0,0,255);
						$docu_pdf->MultiCell($pdf_ancho*.3,5,$xclaveacc,'LRT','L',false);

						$docu_pdf->SetTextColor(0,0,0);
          	$docu_pdf->SetFont($ffamilyPDF,'');
						$docu_pdf->Link($pdf_ancho*.605+10,$docu_pdf->GetY(),$pdf_ancho*.4,5,'https://vcrxol.com/_cel/'.$subdce.$filexml);
						$docu_pdf->SetX($pdf_ancho*.605+10);
						$docu_pdf->Cell($pdf_ancho*.1,5,'AUTORIZACION :','LRT',0,'R',false);
						$docu_pdf->SetFont($ffamilyPDF,'U');
						$docu_pdf->SetTextColor(0,0,255);
						$docu_pdf->MultiCell($pdf_ancho*.3,5,$xclaveacc,'LRT','L',false);

						$docu_pdf->SetTextColor(0,0,0);
          	$docu_pdf->SetFont($ffamilyPDF,'',$fsizePDF-3);
					}
																												
          $docu_pdf->SetFontSize($fsizePDF-2);
          $docu_pdf->SetX($pdf_ancho*.605+10);
          $docu_pdf->Cell($pdf_ancho*.1,1,'','T',0,'',false);
          $docu_pdf->MultiCell($pdf_ancho*.3,1,'','T','',false);

          $posY2=$docu_pdf->getY();
                                                        
        ?>

        </datos>

				<?php if($width>=150 or 1==1){?>					
					<div style="font-size:25%;"><br></div>
				<?php }else{ ?>
					</td>
					<td width=50% valign="top">
				<?php } ?>

					<?php ///// BLOQUE R2 ?>
					<resumen>
					<?php{?>
					<table border="1" width="100%" cellpadding="2" cellspacing="0" 
                 style="border-collapse:collapse;font-size:<?php echo $xfontsize; ?>px;<?php echo $xfontfamily;?>">
						<tr style="border:solid 1px; font-weight:bolder; background: <?php echo $gris1;?>;">
							<td align="center" colspan="2" style="letter-spacing:5px;"><?php echo 'RESUMEN'; ?></td>
						</tr>
						<tr style="display:none;">
							<td width="70%"></td>
							<td></td>
						</tr>
						<tr align="right" style="<?php if($xtunid<=0){echo 'display:none;';} ?>">
							<td>UNIDADES:</td>
							<td><?php echo number_format($xtunid,2);?></td>
						</tr>
						<tr align="right" style="<?php if($xtserv<=0){echo 'display:none;';} ?>">
							<td>SERVICIOS:</td>
							<td><?php echo number_format($xtserv,2);?></td>
						</tr>
						<?php if(mb_stristr('guia', $tabla)){?>
              <tr>
                <td align="right">MOTIVO:</td>
                <td><?php echo $motivo;?></td>
              </tr>
              <?php if($docuorigd!='') {?>
                <tr>
                  <td align="right">COMPROBANTE:</td>
                  <td><?php echo $docuorigd;?></td>
                </tr>
                <tr>
                  <td align="right">FECHA:</td>
                  <td><?php echo $fechaorig;?></td>
                </tr>
                <tr>
                  <td align="right">NUMERO:</td>
                  <td><?php echo $numeroorig;?></td>
                </tr>
                <tr style="font-size:75%; <?php if($autororig==''){echo 'display:none;';} ?>">
                  <td align="right">AUTORIZACION:</td>
                  <td>
                    <?php
                      if($cdisplay==1){echo $autororig;}
                      else
                        {
                          echo substr($autororig,0,8).'.'.substr($autororig,8,2).'.'.substr($autororig,10,13).'.'.substr($autororig,23,1)
                          .'<br>'.substr($autororig,24,6).'.'.substr($autororig,30,9).'.'.substr($autororig,39,8).'.'.substr($autororig,47,2);
                        }
                    ?>
                  </td>
                </tr>
              <?php}?>	
						<?php}?>	
						<?php if(mb_stristr('cont', $tabla)){?>
						<tr align="right">
							<td>DEBITOS</td>
							<td><?php echo number_format($xtdebito,2);?></td>
						</tr>
						<tr align="right">
							<td>CREDITOS</td>
							<td><?php echo number_format($xtcredito,2);?></td>
						</tr>
							<?php //if($xdifer!=0){?>
							<?php if(abs($xdifer)>$saldo0){?>
							<tr align="right" >
								<td>DIFERENCIA</td>
								<td style="color:red;"><?php echo number_format($xdifer,2);?></td>
							</tr>
							<?php } ?>
						<?php } ?>
            <?php if(mb_stristr('clie.prod.vtas', $tabla)){?>
              <?php if($cfg_empr=='ecgl'){?>
                <tr align="right">
                  <td>LAMINAS:</td>
                  <td><?php echo number_format($xstlmn,2);?></td>
                </tr>
                <tr align="right">
                  <td>MTS:</td>
                  <td><?php echo number_format($xstmt1,2);?></td>
                </tr>
                <tr align="right">
                  <td>MT<sup>2</sup>:</td>
                  <td><?php echo number_format($xstmt2,2);?></td>
                </tr>
                <tr><td colspan="2"></td></tr>
              <?php } ?>
						<?php } ?>
            
            
						<?php if(mb_stristr('vtas.comp.clie.carr.prov.comi', $tabla)){?>
						<tr align="right">
							<td>SUB-TOTAL:</td>
							<td><?php echo number_format($xtsubt,2);?></td>
						</tr>
						<?php if($xpdcto!=0){?>
						<tr align="right" style="font-style:italic;">
							<td>DESCUENTO:</td>
							<td><?php echo number_format($xtdcto,2);?></td>
						</tr>
						<?php } ?>
						<?php if($xpprop!=0){?>
						<tr align="right" style="font-style:italic;">
							<td>PROPINA:</td>
							<td><?php echo number_format($xtprop,2);?></td>
						</tr>
						<?php } ?>
						<?php if($xpice!=0){?>
						<tr align="right" style="">
							<td>SUB-TOTAL ICE <?php echo number_format($xpice,0)?>%:</td>
							<td><?php echo number_format($xtsubtice,2);?></td>
						</tr>
						<tr align="right" style="font-style:italic;">
							<td>ICE <?php echo number_format($xpice,0)?>%:</td>
							<td><?php echo number_format($xtice,2);?></td>
						</tr>
						<?php } ?>
						<tr align="right" style="<?php if($docu=='DA16'){echo 'display:none;';} ?>" >
							<td>SUB-TOTAL IVA 0%:</td>
							<td><?php echo number_format($xtsubtiva0,2);?></td>
						</tr>
						<?php if($xpiva!=0){?>
						<tr align="right" style="">
							<td>SUB-TOTAL IVA <?php echo number_format($xpiva,0)?>%:</td>
							<td><?php echo number_format($xtsubtiva,2);?></td>
						</tr>
						<tr align="right" style="font-style:italic;">
							<td>IVA <?php echo number_format($xpiva,0)?>%:</td>
							<td><?php echo number_format($xtiva,2);?></td>
						</tr>
						<?php } ?>
						<?php}?>	
            
						<?php if(mb_stristr('retc.retp.', $tabla)){?>
						<tr align="right">
							<td>RET.IVA:</td>
							<td><?php echo number_format($xtriva,2);?></td>
						</tr>
						<tr align="right">
							<td>RET.RTA:</td>
							<td><?php echo number_format($xtrrta,2);?></td>
						</tr>
						<?php}?>	
						
						<?php if(mb_stristr('plan', $tabla)){?>
                  <?php $xvalorpla=@msql_result($res_tra1,0,'valorpla');?>
                  <?php $xtotatvd=tfle_totatvd($docu,$idnum);?>
						<tr align="right">
							<td>VALORACION</td>
							<td><?php echo @msql_result($res_tra1,0,'empr1');?></td>
							<td><?php echo number_format($xvalorpla,2);?></td>
						</tr>
						<tr align="right">
							<td>HORAS</td>
							<td><?php echo number_format($xtcant,2);?></td>
                     <td><?php echo number_format($xtotatvd[1],2);?></td>
						</tr>
						<tr align="right">
							<td>COSTO</td>
							<td><?php echo number_format(0,2);?></td>
                     <td><?php echo number_format($xtotatvd[2],2);?></td>
						</tr>
                  
						<?php}?>	
						
						<?php if(mb_stristr('atvd', $tabla)){?>
						<tr align="right">
							<td>EMPRESA</td>
							<td><?php echo @msql_result($res_tra1,0,'csub1');?></td>
						</tr>
						<tr align="right">
							<td>HORAS</td>
							<td><?php echo number_format($xtcant,2);?></td>
						</tr>
						<?php}?>	
						
            <?php if($docu=='DA16'){ ?>
            <?php
               $sql_da16='select sum(cant*cuni) as ctotal from '.$tabla.'12 where idnum1="'.$idnum.'"';
               $res_da16=msql_query($sql_da16,$link_vcrx);
               $xctotal=@msql_result($res_da16,0,'ctotal');
               $xtotal=$xctotal;
               
            ?>
            <?php } ?>

            
            
						<?php if(!mb_stristr('guia.cont.',$tabla)){?>
						<tr align="right" style="font-weight:bolder;<?php if($xtotal==0 or $xipuni==0){echo 'display:none;';} ?>">
							<td>TOTAL:</td>
							<td>
                <?php echo number_format(abs($xtotal),2);?>
              </td>
						</tr>
						<?php } ?>

						<?php if(@mb_stristr('FP15.DA16.FP16',$docu)){?>
						<tr align="right" style="font-weight:bolder;">
							<td>PESO KG.:</td>
							<td><?php echo number_format(abs($xtpeso),2);?></td>
						</tr>
						<?php } ?>

            <?php if(mb_stristr('clie', $tabla)){?>
              <?php if($cfg_empr=='dly1' and $xcomi>0){?>
                <?php $xcomi=$xtotal* $enticomi /100; ?>
                <?php $xapagar=$xtotal-$xcomi; ?>
                <tr><td colspan="2"></td></tr>
                <tr align="right">
                  <td>COMISION:</td>
                  <td><?php echo number_format($xcomi,2);?></td>
                </tr>
                <tr align="right" style="font-weight:bolder;">
                  <td>A PAGAR:</td>
                  <td><?php echo number_format($xapagar,2);?></td>
                </tr>
                <tr><td colspan="2"></td></tr>
              <?php } ?>
						<?php } ?>
            
						
					</table>					
					<?php}?>
					</resumen>

        <?php 
//           $posY=48;
          $docu_pdf->SetFont($ffamilyPDF,'B',$fsizePDF-2);
          $docu_pdf->SetY($posY2);
          $docu_pdf->SetX($pdf_ancho*.605+10);
          $docu_pdf->Cell($pdf_ancho*.4,5,'RESUMEN','LRTB',0,'C',true);
          $docu_pdf->SetFont($ffamilyPDF,'',$fsizePDF-3);
          $docu_pdf->ln();
					if(mb_stristr('vtas.comp.clie.carr.prov.comi',$tabla))
					{

            if(mb_stristr('vtas.clie.comi.carr',$tabla))
            {
              if($xtunid>0)
              {
                $docu_pdf->SetX($pdf_ancho*.605+10);
                $docu_pdf->Cell($pdf_ancho*.25,5,'UNIDADES :','LRT',0,'R',false);
                $docu_pdf->MultiCell($pdf_ancho*.15,5,number_format($xtunid,2),'LRT','R',false);
              }

              if($xtserv>0)
              {
                $docu_pdf->SetX($pdf_ancho*.605+10);
                $docu_pdf->Cell($pdf_ancho*.25,5,'SERVICIOS :','LRT',0,'R',false);
                $docu_pdf->MultiCell($pdf_ancho*.15,5,number_format($xtserv,2),'LRT','R',false);
              }
            }
            
						$docu_pdf->SetX($pdf_ancho*.605+10);
						$docu_pdf->Cell($pdf_ancho*.25,5,'SUB-TOTAL :','LRT',0,'R',false);
						$docu_pdf->MultiCell($pdf_ancho*.15,5,number_format($xtsubt,2),'LRT','R',false);
            
						if($xtdcto>0)
            {
              $docu_pdf->SetX($pdf_ancho*.605+10);
              $docu_pdf->Cell($pdf_ancho*.25,5,'DESCUENTO :','LRT',0,'R',false);
              $docu_pdf->MultiCell($pdf_ancho*.15,5,number_format($xtdcto,2),'LRT','R',false);
            }
            
						$docu_pdf->SetX($pdf_ancho*.605+10);
						$docu_pdf->Cell($pdf_ancho*.25,5,'SUB-TOTAL IVA 0% :','LRT',0,'R',false);
						$docu_pdf->MultiCell($pdf_ancho*.15,5,number_format($xtsubtiva0,2),'LRT','R',false);
						if($xpiva>0) 
						{
              $docu_pdf->SetX($pdf_ancho*.605+10);
              $docu_pdf->Cell($pdf_ancho*.25,5,'SUB-TOTAL IVA '.number_format($xpiva,0).'%:','LRT',0,'R',false);
              $docu_pdf->MultiCell($pdf_ancho*.15,5,number_format($xtsubtiva,2),'LRT','R',false);

              $docu_pdf->SetX($pdf_ancho*.605+10);
              $docu_pdf->Cell($pdf_ancho*.25,5,'IVA :','LRT',0,'R',false);
              $docu_pdf->MultiCell($pdf_ancho*.15,5,number_format($xtiva,2),'LRT','R',false);
            }
					}

          if(mb_stristr('retc.retp',$tabla))
					{
						$docu_pdf->SetX($pdf_ancho*.605+10);
						$docu_pdf->Cell($pdf_ancho*.25,5,'RET.IVA :','LRT',0,'R',false);
						$docu_pdf->MultiCell($pdf_ancho*.15,5,number_format($xtriva,2),'LRT','R',false);
						$docu_pdf->SetX($pdf_ancho*.605+10);
						$docu_pdf->Cell($pdf_ancho*.25,5,'RET.RTA :','LRT',0,'R',false);
						$docu_pdf->MultiCell($pdf_ancho*.15,5,number_format($xtrrta,2),'LRT','R',false);
					}
    
					if(mb_stristr('guia',$tabla))
					{
            $docu_pdf->SetFontSize($fsizePDF-4);
						$docu_pdf->SetX($pdf_ancho*.605+10);
						$docu_pdf->Cell($pdf_ancho*.10,5,'MOTIVO :','LRT',0,'R',false);
						$docu_pdf->MultiCell($pdf_ancho*.30,5,$motivo,'LRT','L',false);
            if($docuorigd!='')
            {
              $docu_pdf->SetX($pdf_ancho*.605+10);
              $docu_pdf->Cell($pdf_ancho*.10,5,'COMPROB.:','LRT',0,'R',false);
              $docu_pdf->MultiCell($pdf_ancho*.30,5,$docuorigd,'LRT','L',false);
              $docu_pdf->SetX($pdf_ancho*.605+10);
              $docu_pdf->Cell($pdf_ancho*.10,5,'FECHA :','LRT',0,'R',false);
              $docu_pdf->MultiCell($pdf_ancho*.30,5,$fechaorig,'LRT','L',false);
              $docu_pdf->SetX($pdf_ancho*.605+10);
              $docu_pdf->Cell($pdf_ancho*.10,5,'NUMERO :','LRT',0,'R',false);
              $docu_pdf->MultiCell($pdf_ancho*.30,5,$numeroorig,'LRT','L',false);
              $docu_pdf->SetX($pdf_ancho*.605+10);

              $docu_pdf->SetFontSize($fsizePDF-6);
              $docu_pdf->Cell($pdf_ancho*.10,5,'AUTORIZACION :','LRT',0,'R',false);
              $docu_pdf->MultiCell($pdf_ancho*.30,5,$autororig,'LRT','L',false);
            }
					}
                                                        
          $docu_pdf->SetFont($ffamilyPDF,'B',$fsizePDF-3);
          $docu_pdf->SetX($pdf_ancho*.605+10);
          $docu_pdf->Cell($pdf_ancho*.25,5,'TOTAL :','LRT',0,'R',false);
          $docu_pdf->MultiCell($pdf_ancho*.15,5,number_format(abs($xtotal),2),'LRT','R',false);
          $docu_pdf->SetX($pdf_ancho*.605+10);
          $docu_pdf->Cell($pdf_ancho*.25,1,'','T',0,'',false);
          $docu_pdf->MultiCell($pdf_ancho*.15,1,'','T','',false);
                                                        
          $posY2=$docu_pdf->getY();
        ?>
            
				<?php if($width>=150 or 1==1){?>					
				<?php }else{ ?>
					</td>
					</tr>
					<tr>
					<td>
				<?php } ?>
            
					<?php ///// BLOQUE R3 ?>
					<?php{?>
					<?php if(mb_stristr('vtas.comp', $tabla)){?>
					<div style="font-size:25%;"><br></div>
					<table border="1" width="100%" cellpadding="2" cellspacing="0" 
                 style="border-collapse:collapse;font-size:<?php echo $xfontsize; ?>px;<?php echo $xfontfamily;?>">
						<?php if(mb_stristr('NC.NP',substr($docu,0,2)) or $docu=='FC50' or $docu=='FP05'){?>
						<?php
							$xtoenti=@msql_result($res_tra1,0,'enti');
							$xtodocu=@msql_result($res_tra1,0,'todocu');
							$xtoptoe=@msql_result($res_tra1,0,'toptoe');
							$xtonumero=@msql_result($res_tra1,0,'tonume');
//           echo '*/*/*/'.$xtodocu;
              if($xtodocu!='')
              {
                if(mb_stristr('FC',substr($xtodocu,0,2)))
                {$sql_todoc='select * from vtas12 where enti="'.$xtoenti.'" and docu="'.$xtodocu.'" and numero="'.$xtonumero.'" and ptoe="'.$xtoptoe.'"';}
                if(mb_stristr('FP',substr($xtodocu,0,2)))
                {$sql_todoc='select * from comp12 where enti="'.$xtoenti.'" and docu="'.$xtodocu.'" and numero="'.$xtonumero.'" and ptoe="'.$xtoptoe.'"';}
                $res_todoc=msql_query($sql_todoc,$link_vcrx);
                
                
                if(msql_num_rows($res_todoc)==0)
                {
                  upl_cexml(msql_result($res_tra1,0,'claveacc'));
                  $res_todoc=msql_query($sql_todoc,$link_vcrx);
                  if(msql_num_rows($res_todoc)==0)
                  {
                    if(mb_stristr('FC',substr($xtodocu,0,2)))
                    {$sql_todoc='select * from vtas12 where enti="'.$xtoenti.'" and docu="'.$xtodocu.'" and numero="'.$xtonumero.'"';}
                    if(mb_stristr('FP',substr($xtodocu,0,2)))
                    {$sql_todoc='select * from comp12 where enti="'.$xtoenti.'" and docu="'.$xtodocu.'" and numero="'.$xtonumero.'"';}
                    $res_todoc=msql_query($sql_todoc,$link_vcrx);
                  }
                }
                $xtofecha=@msql_result($res_todoc,0,'fechadmy');
  							$xtoidnum=@msql_result($res_todoc,0,'idnum1');
              }
                
						?>
						<tr style="border:solid 1px; font-weight:bolder; background: <?php echo $gris1;?>;">
							<td align="center" colspan="2">MODIFICA</td>
						</tr>
						<tr>
								<td>COMPROBANTE</td>
								<td>FACTURA</td>
						</tr>
						<tr>
								<td>NUMERO</td>
								<td>
                <?php if($copia==1){?>
                  <a href="<?php //echo 'https://'.$cfg_empr.'.vcrxol.com/?prnt=1&docu='.$xtodocu.'&idnum='.$xtoidnum.'&formato='.$formato;?>"  target="_blank" >
                  <a href="<?php echo 'https://'.$cfg_empr.'.vcrxol.com/?prnt=1&docu='.$xtodocu.'&idnum='.$xtoidnum.'&formato='.$formato;?>"  target="_blank" >
                <?php } ?>                  
                    <?php echo $xtoptoe.'-'.$xtonumero;?>
                <?php if($copia==1){?>
                  </a>
                <?php } ?>                  
                </td>
						</tr>
						<tr>
								<td>FECHA</td>
								<td><?php echo $xtofecha;?></td>
						</tr>
						<?php } ?>
						<?php if(!mb_stristr('NC.NP',substr($docu,0,2))){ ?>
						<tr style="border:solid 1px; font-weight:bolder; background: <?php echo $gris1;?>;<?php if($xfpag==0){echo 'display:none;';} ?>">
							<td align="center" >FORMA DE PAGO</td>
							<td></td>
						</tr>
						<tr style="<?php if($xfpag==0){echo 'display:none;';} ?>">
							<td style="font-size:70%;"><?php echo msql_result($res_tra1,0,'fpag_descri'); ?></td>
							<td align="right"><?php echo number_format(abs($xtotal),2);?></td>
						</tr>
          <?php
             $docu_txt.=str_pad('FORMA DE PAGO ',$coltxt,$carbot,STR_PAD_BOTH).$eol;
             $docu_txt.= ''.msql_result($res_tra1,0,'fpag_descri').$eol;
             $docu_txt.= str_pad(number_format(abs($xtotal),2),$coltxt,' ',STR_PAD_LEFT).$eol;
             $docu_txt.=$eol;
          ?>
            
        <?php 
//           $posY=48;
          $docu_pdf->SetFont($ffamilyPDF,'B',$fsizePDF-2);
          $docu_pdf->SetY($posY2);
          $docu_pdf->SetX($pdf_ancho*.605+10);
          $docu_pdf->Cell($pdf_ancho*.4,5,'FORMA DE PAGO','LRTB',0,'C',true);
          $docu_pdf->ln();
          $docu_pdf->SetFont($ffamilyPDF,'',$fsizePDF-6);
          $docu_pdf->SetX($pdf_ancho*.605+10);
          $docu_pdf->Cell($pdf_ancho*.3,5,msql_result($res_tra1,0,'fpag_descri').':','LRT',0,'R',false);
          $docu_pdf->SetFont($ffamilyPDF,'',$fsizePDF-5);
          $docu_pdf->MultiCell($pdf_ancho*.1,5,number_format(abs($xtotal),2),'LRT','R',false);
          $docu_pdf->SetX($pdf_ancho*.605+10);
          $docu_pdf->Cell($pdf_ancho*.25,1,'','T',0,'',false);
          $docu_pdf->MultiCell($pdf_ancho*.15,1,'','T','',false);
                                                        
          $posY2=$docu_pdf->getY();
        ?>

            <?php } ?>
					</table>					
					<?php}?>
					<?php}?>

				<?php if($width>=150 or 1==1){?>					
				<?php }else{ ?>
					</td>
					</tr>
				<?php } ?>

      </td>
			</tr>
		</table>



<?php
          $docu_pdf->setY($posY1+2);
          if($posY2>$posY1){$docu_pdf->setY($posY2+2);}
          $docu_pdf->SetFont($ffamilyPDF,'B',$fsizePDF-2);
?>


<?php //////////////////////////////////////////////////////////	?>
<?php // DETALLE	?>
		<?php $crow=0;?>
		<?php $ccol=0;?>
		<?php $filag=5; ?>
		<?php if($cfg_empr=='ecgl' and mb_stristr('clie.vtas.prod',$tabla)){$filag=1000;} ?>
		<?php if($cfg_empr=='ecgl' and mb_stristr('clie.vtas',$tabla)){$xideta=0;} ?>
		<?php if($cfg_empr=='ecgl' and mb_stristr('prod',$tabla)){$xideta=0;} ?>
		<?php
			if(@mb_stristr('OP',substr($docu,0,2)) and $cfg_empr=='ecgl')
			{
				$xipuni=0;
				$xtdcto=0;
				$xtprop=0;
				$xtiva=0;
				$xtice=0;
				$xtirbp=0;
			}
		?>
      

		<div style="font-size:25%;"><br></div>
		<?php if($guiaremi==1){?>
      <?php
        $plazo=@msql_result($res_tra1,0,'plazo');
        $fecha1=msql_result($res_tra1,0,'fecha1');
        $fecha2=msql_result($res_tra1,0,'fecha2');

        if($fecha1==''){$fecha1=msql_result($res_tra1,0,'fecha');}
        if($fecha2=='' or $fecha2<$fecha1){$fecha2=date('Ymd',strtotime($fecha1.' '.$plazo.'  days'));}
        $fecha1=date('d/M/Y', strtotime($fecha1));
        $fecha2=date('d/M/Y', strtotime($fecha2));
                                                        
        $placa=msql_result($res_tra1,0,'placa');
        $placades=r_fiel('vhcl',$placa);
        $ruta=msql_result($res_tra1,0,'ruta');

        $cedula1=msql_result($res_tra1,0,'cedula1');
        $cedula2=msql_result($res_tra1,0,'cedula2');
        $nombre1=msql_result($res_tra1,0,'nombre1');
        $nombre2=msql_result($res_tra1,0,'nombre2');
        $punto1=msql_result($res_tra1,0,'punto1');
        $punto2=msql_result($res_tra1,0,'punto2');
    ?>

		<table border="0" width="100%" cellpadding="2" cellspacing="0" 
           style="border-collapse:collapse;font-size:<?php echo $xfontsize; ?>px;<?php echo $xfontfamily;?>">
			<tr style="background:<?php echo $gris1;?>;font-weight:bolder; border-top:solid 1px; border-bottom:solid 1px; letter-spacing: 1px;">
				<td colspan="6">DATOS DEL TRANSPORTE</td></tr>
			<tr>
				<td width="1%"></td>
				<td width="24%"></td>
				<td width="25%"></td>
				<td width="1%"></td>
				<td width="24%"></td>
				<td width="25%"></td>
			</tr>
			<tr>
        <td style="border-left:solid 1px;"></td>
				<td>INICIO DE TRANSPORTE :</td>
				<td><?php echo $fecha1;?></td>
        <td style="border-left:solid 1px;"></td>
				<td>FIN DE TRANSPORTE :</td>
				<td><?php echo $fecha2;?></td>
			</tr>
			<tr>
        <td style="border-left:solid 1px;"></td>
				<td>No.ID. CONDUCTOR :</td>
				<td><?php echo $cedula1;?></td>
        <td style="border-left:solid 1px;"></td>
				<td>No.ID. DESTINATARIO :</td>
				<td><?php echo $cedula2;?></td>
			</tr>
			<tr>
        <td style="border-left:solid 1px;"></td>
				<td>NOM. CONDUCTOR :</td>
				<td><?php echo $nombre1;?></td>
        <td style="border-left:solid 1px;"></td>
				<td>NOM. DESTINATARIO :</td>
				<td><?php echo $nombre2;?></td>
			</tr>
			<tr>
        <td style="border-left:solid 1px;"></td>
				<td>PLACA DEL VEHICULO :</td>
				<td><?php echo $placa;?></td>
        <td style="border-left:solid 1px;"></td>
				<td>RUTA :</td>
				<td><?php echo $ruta;?></td>
			</tr>
			<tr>
        <td style="border-left:solid 1px;"></td>
				<td></td>
				<td><?php echo $placades;?></td>
        <td style="border-left:solid 1px;"></td>
				<td></td>
				<td></td>
			</tr>
			<tr style="vertical-align:text-top;">
        <td style="border-left:solid 1px;"></td>
				<td>PUNTO DE PARTIDA :</td>
				<td><?php echo $punto1;?></td>
        <td style="border-left:solid 1px;"></td>
				<td>PUNTO DE LLEGADA :</td>
				<td><?php echo $punto2;?></td>
			</tr>
		</table>
		<br>


      <?php
          $docu_pdf->SetFont($ffamilyPDF,'B',$fsizePDF-3);
          $docu_pdf->Cell($pdf_ancho*1,5,'DATOS DEL TRANSPORTE ','TB',0,'L',true);
          $docu_pdf->ln();

          $docu_pdf->SetFont($ffamilyPDF,'',$fsizePDF-4);
          $posX=$docu_pdf->GetX();
          $posY=$docu_pdf->GetY();
      

          $docu_pdf->Cell($pdf_ancho*.20,5,'INICIO DE TRANSPORTE :','L',0,'L');
          $docu_pdf->Cell($pdf_ancho*.30,5,$fecha1,'',0,'L');
          $docu_pdf->Cell($pdf_ancho*.20,5,'FIN DE TRANSPORTE :','L',0,'L');
          $docu_pdf->Cell($pdf_ancho*.30,5,$fecha2,'',0,'L');
          $docu_pdf->ln();
      
          $docu_pdf->Cell($pdf_ancho*.20,5,'No. ID. CONDUCTOR :','L',0,'L');
          $docu_pdf->Cell($pdf_ancho*.30,5,$cedula1,'',0,'L');
          $docu_pdf->Cell($pdf_ancho*.20,5,'No. ID DESTINATARIO :','L',0,'L');
          $docu_pdf->Cell($pdf_ancho*.30,5,$cedula2,'',0,'L');
          $docu_pdf->ln();
      
          $posY1=$docu_pdf->GetY();
          $docu_pdf->Cell($pdf_ancho*.20,5,'Nom. CONDUCTOR :','L',0,'L');
          $docu_pdf->MultiCell($pdf_ancho*.30,5,$nombre1,'','',false);
          $posY2=$docu_pdf->GetY();

          $docu_pdf->SetXY($pdf_ancho*.5+10,$posY1);
          $docu_pdf->Cell($pdf_ancho*.20,5,'Nom. DESTINATARIO :','L',0,'L');
          $docu_pdf->MultiCell($pdf_ancho*.30,5,$nombre2,'','',false);
          $docu_pdf->ln();
      
          $docu_pdf->Cell($pdf_ancho*.20,5,'PLACA DEL VEHICULO :','L',0,'L');
          $docu_pdf->Cell($pdf_ancho*.30,5,$placa,'',0,'L');
          $docu_pdf->Cell($pdf_ancho*.20,5,'RUTA :','L',0,'L');
          $docu_pdf->Cell($pdf_ancho*.30,5,$ruta,'',0,'L');
          $docu_pdf->ln();

          $posY1=$docu_pdf->GetY();
          $docu_pdf->Cell($pdf_ancho*.20,5,'PUNTO DE PARTIDA :','L',0,'L');
          $docu_pdf->MultiCell($pdf_ancho*.30,5,$punto1,'','',false);
          $posY2=$docu_pdf->GetY();

          $docu_pdf->SetXY($pdf_ancho*.5+10,$posY1);
          $docu_pdf->Cell($pdf_ancho*.20,5,'PUNTO DE LLEGADA :','L',0,'L');
          $docu_pdf->MultiCell($pdf_ancho*.30,5,$punto2,'','',false);
          $docu_pdf->ln();

      
      ?>




		<?php } ?>

<?php
          $docu_pdf->SetFont($ffamilyPDF,'B',$fsizePDF-3);
          $docu_pdf->Cell($pdf_ancho*1,5,'DETALLE','TB',0,'L',true);
          $docu_pdf->ln();
?>


<?php
          
    $xtfob=0;
    $xtseguro=0;
    $xtflete=0;
    $xtcif=0;
    $xtadva=0;
    $xtespe=0;
    $xtdump=0;
    $xtfodi=0;
    $xtisd=0;
    $xtcostol=0;
    $xtcostot=0;


?>

    <?php //explain_sql($sql_tra2); ?>
		<table border="0" width="100%" cellpadding="2" cellspacing="0" 
           style="border-collapse:collapse;font-size:<?php echo $xfontsize; ?>px;<?php echo $xfontfamily;?>">
			<tr style="background:<?php echo $gris1;?>;font-weight:bolder; border-top:solid 1px; letter-spacing: 10px;"><td>DETALLE</td></tr>
		</table>
		<div style="font-size:25%;"><br></div>
		<detalle>
    <?php $xfontsize2=$xfontsize;?>
    <?php if($docu=='DA16'){$xfontsize2=$xfontsize*.8;}?>
		<table id="deta_<?php echo $tabla.'_'.$cdisplay;?>" class="deta<?php echo $cdisplay;?>"
					 border="0" width="100%" cellpadding="2" cellspacing="0"
					 style="border-collapse:collapse;font-size:<?php echo $xfontsize2; ?>px;<?php echo $xfontfamily;?>">
		<thead>
         <?php if($formato==2) { ?>
 			<tr style="border-top:solid 1px; border-bottom:solid 1px; font-weight:bolder; background:<?php echo $gris1;?>;">
            <th colspan="10">CONTABILIDAD</th>
        </tr>
         <?php } ?>
		<tr style="background:<?php echo $gris1;?>; border-top:solid 1px; border-bottom:solid 1px; cursor:pointer;" title="Reordenar">
				<th onclick="sortTable(this,<?php echo $ccol++; ?>);" style="display:none;">L</th>
			<?php if(mb_stristr('cont',$tabla)){?>
				<th onclick="sortTable(this,<?php echo $ccol++; ?>);">CUENTA</th>
				<th onclick="sortTable(this,<?php echo $ccol++; ?>);" width="25%" style="letter-spacing: 5px;">CONTABLE</th>
				<th onclick="sortTable(this,<?php echo $ccol++; ?>,'N');" width="10%">DEBITOS</th>
				<th onclick="sortTable(this,<?php echo $ccol++; ?>,'N');" width="10%">CREDITOS</th>
				<th onclick="sortTable(this,<?php echo $ccol++; ?>);" style="<?php if($xmcsub==""){echo 'display:none;';}?>;">C.SUB</th>
				<th onclick="sortTable(this,<?php echo $ccol++; ?>);" style="<?php if($xmcair==""){echo 'display:none;';}?>;">CAIR</th>
				<th onclick="sortTable(this,<?php echo $ccol++; ?>);" style="<?php if($xmitem==""){echo 'display:none;';}?>;">ITEM</th>
				<th onclick="sortTable(this,<?php echo $ccol++; ?>);" width="30%">DETALLE</th>
			<?php}?>
			<?php if(mb_stristr('nomi.',$tabla)){?>
				<th onclick="sortTable(this,<?php echo $ccol++; ?>);" width="5%">CEDULA</th>
				<th onclick="sortTable(this,<?php echo $ccol++; ?>);" width="15%" style="letter-spacing: 5px;">EMPLEADO</th>
			<?php}?>
      
			<?php if(mb_stristr('nomi.empl',$tabla)){?>
				<th onclick="sortTable(this,<?php echo $ccol++; ?>);" width="5%">NVDD</th>
				<th onclick="sortTable(this,<?php echo $ccol++; ?>);" width="15%" style="letter-spacing: 5px;">NOVEDAD</th>
				<th onclick="sortTable(this,<?php echo $ccol++; ?>,'N');" width="5%">BASE</th>
				<th onclick="sortTable(this,<?php echo $ccol++; ?>,'N');" width="5%">V.UNIT.</th>
				<th onclick="sortTable(this,<?php echo $ccol++; ?>,'N');" width="10%">REMUN.</th>
				<th onclick="sortTable(this,<?php echo $ccol++; ?>,'N');" width="10%">DEDUC.</th>
				<th onclick="sortTable(this,<?php echo $ccol++; ?>,'N');" width="10%">PROVI.</th>
				<th onclick="sortTable(this,<?php echo $ccol++; ?>,'N');" width="15%">DETALLE</th>
			<?php}?>
      
      
			<?php if(mb_stristr('susa',$tabla)){?>
				<th onclick="sortTable(this,<?php echo $ccol++; ?>);">FECHA</th>
				<th onclick="sortTable(this,<?php echo $ccol++; ?>,'N');" >SUELDO</th>
				<th onclick="sortTable(this,<?php echo $ccol++; ?>,'N');" >ANTIC.</th>
				<th onclick="sortTable(this,<?php echo $ccol++; ?>,'N');" >%ANT.</th>
				<th onclick="sortTable(this,<?php echo $ccol++; ?>,'N');" >ALIM.</th>
				<th onclick="sortTable(this,<?php echo $ccol++; ?>,'N');" >MOVIL.</th>
				<th onclick="sortTable(this,<?php echo $ccol++; ?>,'N');" >COMIS.</th>
				<th onclick="sortTable(this,<?php echo $ccol++; ?>,'N');" >D.13</th>
				<th onclick="sortTable(this,<?php echo $ccol++; ?>,'N');" >D.14</th>
				<th onclick="sortTable(this,<?php echo $ccol++; ?>,'N');" >F.RES</th>
				<th onclick="sortTable(this,<?php echo $ccol++; ?>,'N');" >TOTAL</th>
			<?php}?>
			<?php if(mb_stristr('guia',$tabla)){?>
				<th onclick="sortTable(this,<?php echo $ccol++; ?>);">ITEM</th>
				<th onclick="sortTable(this,<?php echo $ccol++; ?>);"style="letter-spacing: 5px;">DESCRIPCION</th>
				<th onclick="sortTable(this,<?php echo $ccol++; ?>,'N');">CANT.</th>
				<th onclick="sortTable(this,<?php echo $ccol++; ?>);">UNID.</th>

      <?php
          $docu_pdf->SetFont($ffamilyPDF,'B',$fsizePDF-3);
          $docu_pdf->Cell($pdf_ancho*.1,5,'CODIGO','TB',0,'C',true);
          $docu_pdf->Cell($pdf_ancho*.3,5,'DESCRIPCION','TB',0,'C',true);
          $docu_pdf->Cell($pdf_ancho*.1,5,'CANT.','TB',0,'C',true);
          $docu_pdf->Cell($pdf_ancho*.03,5,'','TB',0,'C',true);
          $docu_pdf->Cell($pdf_ancho*.1,5,'','TB',0,'C',true);
          $docu_pdf->ln();
      
      ?>
      
			<?php}?>
               
			<?php if(mb_stristr('vtas.comp.clie.carr.prov.inve.prod.comi.tfin',$tabla)){?>
				<th onclick="sortTable(this,<?php echo $ccol++; ?>);">ITEM</th>
				<th onclick="sortTable(this,<?php echo $ccol++; ?>);"style="<?php if($xlitemdescri<15){echo 'letter-spacing: 2px;';}else{echo 'letter-spacing: 5px;';} ?>">DESCRIPCION</th>
				<th onclick="sortTable(this,<?php echo $ccol++; ?>,'N');">CANT.</th>
				<th onclick="sortTable(this,<?php echo $ccol++; ?>);"></th>
        <?php if($xipvp==1){ ?>
				<th onclick="sortTable(this,<?php echo $ccol++; ?>,'N');" style="<?php if($xipuni==0){echo 'display:;';}?>">P.V.P.</th>
        <?php }else{ ?>
				<th onclick="sortTable(this,<?php echo $ccol++; ?>,'N');" style="<?php if($xipuni==0){echo 'display:none;';}?>">UNIT.</th>
				<th onclick="sortTable(this,<?php echo $ccol++; ?>,'N');" style="<?php if($xipuni==0){echo 'display:none;';}?>">SUBT.</th>
				<?php if(mb_stristr('vtas.comp.clie.carr.prov',$tabla)){?>
					<th onclick="sortTable(this,<?php echo $ccol++; ?>,'N');" style="<?php if($xipuni*$xtdcto==0){echo 'display:none;';}?>;">DESC</th>
					<th onclick="sortTable(this,<?php echo $ccol++; ?>,'N');" style="<?php if($xipuni*$xtprop==0){echo 'display:none;';}?>;">PROP</th>
					<th onclick="sortTable(this,<?php echo $ccol++; ?>,'N');" style="<?php if($xipuni*$xtice==0) {echo 'display:none;';}?>;">ICE</th>
					<th onclick="sortTable(this,<?php echo $ccol++; ?>,'N');" style="<?php if($xipuni*$xtiva==0) {echo 'display:none;';}?>;">IVA</th>
					<th onclick="sortTable(this,<?php echo $ccol++; ?>,'N');" style="<?php if($xipuni*$xtirbp==0){echo 'display:none;';}?>;">IRBP</th>
				<?php}?>
        <?php } ?>
      
				<th onclick="sortTable(this,<?php echo $ccol++; ?>,'N');" style="<?php if($xtotal==0){echo '';}?>;<?php if($xipuni==0){echo 'display:none;';}?>">TOTAL</th>
				<th onclick="sortTable(this,<?php echo $ccol++; ?>);"max-width="50%" style="letter-spacing: 2px; <?php if($xmdetalle==""){echo 'display:none;';}?> ">DETALLE</th>

<?php
                                                        
             $docu_txt.=str_pad('DETALLE ',$coltxt,$carbot,STR_PAD_BOTH).$eol;
             $docu_txt.=str_repeat('-',$coltxt).$eol;
//              $docu_txt.=str_pad('|CODIGO',13,$padtxt,STR_PAD_RIGHT);
             $docu_txt.=str_pad('COD/CANT',14,$padtxt,STR_PAD_BOTH);
             $docu_txt.=str_pad('|',1,$padtxt,STR_PAD_LEFT);
//              $docu_txt.=str_pad('   ',3,$padtxt,STR_PAD_BOTH);
             $docu_txt.=str_pad('P.UNI.|',10,$padtxt,STR_PAD_LEFT);
             $docu_txt.=str_pad('TOTAL|',10,$padtxt,STR_PAD_LEFT);
             $docu_txt.=$eol;
             $docu_txt.=str_repeat('-',$coltxt).$eol;
                                                        
?>
      <?php
          $docu_pdf->SetFont($ffamilyPDF,'B',$fsizePDF-3);
          $docu_pdf->Cell($pdf_ancho*.1,5,'CODIGO','TB',0,'C',true);
          $docu_pdf->Cell($pdf_ancho*.3,5,'DESCRIPCION','TB',0,'C',true);
          $docu_pdf->Cell($pdf_ancho*.1,5,'CANT.','TB',0,'C',true);
          $docu_pdf->Cell($pdf_ancho*.03,5,'','TB',0,'C',true);
          $docu_pdf->Cell($pdf_ancho*.1,5,'P.UNIT','TB',0,'C',true);
          $docu_pdf->Cell($pdf_ancho*.1,5,'SUBT.','TB',0,'C',true);
          if($xtdcto>0)
          {$docu_pdf->Cell($pdf_ancho*.07,5,'DCTO','TB',0,'C',true);}
          if($xtice>0)
          {$docu_pdf->Cell($pdf_ancho*.05,5,'ICE','TB',0,'C',true);}
          if($xtiva>0)
          {$docu_pdf->Cell($pdf_ancho*.05,5,'IVA','TB',0,'C',true);}
          $docu_pdf->Cell($pdf_ancho*.1,5,'TOTAL','TB',0,'C',true);
          $docu_pdf->ln();
        ?>
			<?php}?>

			<?php //$empr_cont=5 ;?>
			<?php if($empr_cont=='1' and ($tabla=='comp' or $docu=='APx10')){?>
				<th onclick="sortTable(this,<?php echo $ccol++; ?>);" style="<?php if($xmctas==""){echo 'display:none;';}?>">CUENTA</th>
				<th onclick="sortTable(this,<?php echo $ccol++; ?>);" style="<?php if($xmctas==""){echo 'display:none;';}?>">CONTABLE</th>
        <?php if(mb_stristr('FP15.DA16',$docu)){?>
				<th onclick="sortTable(this,<?php echo $ccol++; ?>,'N');" style="font-size:80%">PESO</th>
        <?php } ?>
        <?php if(mb_stristr('DA16.FP16',$docu)){?>
				<th onclick="sortTable(this,<?php echo $ccol++; ?>,'N');" style="font-size:80%">AD-VALOR</th>
				<th onclick="sortTable(this,<?php echo $ccol++; ?>,'N');" style="font-size:80%">FODINFA</th>
				<th onclick="sortTable(this,<?php echo $ccol++; ?>,'N');" style="font-size:80%">C.UNIT.</th>
        <?php } ?>
        <?php if(!mb_stristr('FP15.FP16',$docu)){?>
				<th onclick="sortTable(this,<?php echo $ccol++; ?>);" style="font-size:80%">CAIR</th>
				<th onclick="sortTable(this,<?php echo $ccol++; ?>,'N');" style="font-size:80%">%Rta</th>
				<th onclick="sortTable(this,<?php echo $ccol++; ?>,'N');" style="font-size:80%">%IVA</th>
        <?php } ?>
			<?php}?>
      
			<?php if(mb_stristr('retc.retp',$tabla)){?>
				<th onclick="sortTable(this,<?php echo $ccol++; ?>);">EJERCICIO<br>FISCAL</th>
				<th onclick="sortTable(this,<?php echo $ccol++; ?>,'N');">BASE<br>IMPONIBLE</th>
				<th onclick="sortTable(this,<?php echo $ccol++; ?>);" width="30%">IMPUESTO</th>
				<th onclick="sortTable(this,<?php echo $ccol++; ?>,'N');">% Ret</th>
				<th onclick="sortTable(this,<?php echo $ccol++; ?>,'N');">VALOR<br>RETENIDO</th>
				<th onclick="sortTable(this,<?php echo $ccol++; ?>);">COMPROBANTE</th>
				<th onclick="sortTable(this,<?php echo $ccol++; ?>);">NUMERO</th>
      <?php
          $docu_pdf->SetFont($ffamilyPDF,'B',$fsizePDF-4);
          $docu_pdf->Cell($pdf_ancho*.1,10,'EJER.FISCAL','TB',0,'C',true);
          $docu_pdf->Cell($pdf_ancho*.1,10,'BASE IMP.','TB',0,'C',true);
          $docu_pdf->SetFont($ffamilyPDF,'B',$fsizePDF-3);
          $docu_pdf->Cell($pdf_ancho*.3,10,'IMPUESTO','TB',0,'C',true);
          $docu_pdf->Cell($pdf_ancho*.1,10,'%RET.','TB',0,'C',true);
          $docu_pdf->Cell($pdf_ancho*.1,10,'VAL.RETEN.','TB',0,'C',true);
          $docu_pdf->Cell($pdf_ancho*.15,10,'COMPROB.','TB',0,'C',true);
          $docu_pdf->Cell($pdf_ancho*.15,10,'NUMERO','TB',0,'C',true);
          $docu_pdf->ln();
        ?>
			
			<?php}?>

			<?php if(mb_stristr('caja.bcos.dxco.dxpa',$tabla)){?>
				<th onclick="sortTable(this,<?php echo $ccol++; ?>);">COMP.</th>
				<th onclick="sortTable(this,<?php echo $ccol++; ?>);">NUMERO</th>
        <?php if(mb_stristr('dxco.dxpa',$tabla)){?>      
				<th onclick="sortTable(this,<?php echo $ccol++; ?>,'N');">CANT.</th>
				<th onclick="sortTable(this,<?php echo $ccol++; ?>,'N');">P.UNI</th>
  			<?php}?>
				<th onclick="sortTable(this,<?php echo $ccol++; ?>,'N');">VALOR</th>
				<th onclick="sortTable(this,<?php echo $ccol++; ?>);">CUENTA</th>
				<th onclick="sortTable(this,<?php echo $ccol++; ?>);">CONTABLE</th>
				<th onclick="sortTable(this,<?php echo $ccol++; ?>);">DETALLE</th>
			<?php}?>
      
			<?php if(mb_stristr('vtas.clie.inve.prod.tfin',$tabla)){?>
				<th onclick="sortTable(this,<?php echo $ccol++; ?>);" style="<?php if($xmlote==''){echo 'display:none;';} ?>">LOTE</th>
			<?php}?>
      
			<?php if(mb_stristr('inve.prod.tfin',$tabla)){?>
				<th onclick="sortTable(this,<?php echo $ccol++; ?>);" style="<?php if($xmserie==''){echo 'display:none;';} ?>"># SERIE</th>
			<?php}?>
      
            <?php if(mb_stristr('IB11.EB11',$docu)){ ?>
      				<th onclick="sortTable(this,<?php echo $ccol++; ?>);" style="">CAMBIO</th>
            <?php } ?>
      
			<?php if(@mb_stristr('DA16',$docu) and $formato==5){?>
				<th onclick="sortTable(this,<?php echo $ccol++; ?>,'N');" style="<?php if($xtpeso==0){echo 'display:;';} ?>">PESO</th>
				<th onclick="sortTable(this,<?php echo $ccol++; ?>);" style="<?php if($xmarcl==0){echo 'display:;';} ?>">ARANCEL</th>
				<th onclick="sortTable(this,<?php echo $ccol++; ?>,'N');" style="<?php if($xcostoe1==0){echo 'display:none;';} ?>">COSTO EXT.</th>
				<th onclick="sortTable(this,<?php echo $ccol++; ?>,'N');" style="<?php if($xfob1==0){echo 'display:;';} ?>">FOB</th>
				<th onclick="sortTable(this,<?php echo $ccol++; ?>,'N');" style="<?php if($xseguro1==0){echo 'display:;';} ?>">SEGURO</th>
				<th onclick="sortTable(this,<?php echo $ccol++; ?>,'N');" style="<?php if($xflete1==0){echo 'display:;';} ?>">FLETE</th>
				<th onclick="sortTable(this,<?php echo $ccol++; ?>,'N');" style="<?php if($xcif1==0){echo 'display:;';} ?>">CIF</th>
				<th onclick="sortTable(this,<?php echo $ccol++; ?>,'N');" style="<?php if($xadva==0){echo 'display:none;';} ?>">AD-VALOR</th>
				<th onclick="sortTable(this,<?php echo $ccol++; ?>,'N');" style="<?php if($xespe==0){echo 'display:none;';} ?>">ESPECIFICO</th>
				<th onclick="sortTable(this,<?php echo $ccol++; ?>,'N');" style="<?php if($xdump==0){echo 'display:none;';} ?>">DUMPING</th>
				<th onclick="sortTable(this,<?php echo $ccol++; ?>,'N');" style="<?php if($xfodi==0){echo 'display:none;';} ?>">FODINFA</th>
				<th onclick="sortTable(this,<?php echo $ccol++; ?>,'N');" style="<?php if($xivai==0){echo 'display:none;';} ?>">IVA</th>
				<th onclick="sortTable(this,<?php echo $ccol++; ?>,'N');" style="<?php if($xmisdi==0){echo 'display:none;';} ?>">ISD</th>
				<th onclick="sortTable(this,<?php echo $ccol++; ?>,'N');" style="<?php if($xcostol1==0){echo 'display:;';} ?>">COSTO LOC.</th>
				<th onclick="sortTable(this,<?php echo $ccol++; ?>,'N');" style="<?php if($xadva==0){echo 'display:;';} ?>">C.TOTAL</th>
				<th onclick="sortTable(this,<?php echo $ccol++; ?>,'N');" style="<?php if($xadva==0){echo 'display:;';} ?>">C.UNIT.</th>
			<?php}?>
      
      
			<?php if(mb_stristr('plan.atvd',$tabla)){?>
				<th onclick="sortTable(this,<?php echo $ccol++; ?>);">ACTIVIDAD</th>
				<th onclick="sortTable(this,<?php echo $ccol++; ?>);">DESCRIPCION</th>
				<th onclick="sortTable(this,<?php echo $ccol++; ?>,'N');">HORAS</th>
   			<?php if(mb_stristr('atvd',$tabla)){?>
				<th onclick="sortTable(this,<?php echo $ccol++; ?>);">EMPR</th>
				<th onclick="sortTable(this,<?php echo $ccol++; ?>,'N');">#PLAN</th>
	   		<?php}?>
   			<?php if(mb_stristr('plan',$tabla)){?>
				<th onclick="sortTable(this,<?php echo $ccol++; ?>);"></th>
	   		<?php}?>
				<th onclick="sortTable(this,<?php echo $ccol++; ?>);">
          <?php if($tabla=='plan'){echo 'RECURSO';}?>
          <?php if($tabla=='atvd'){echo 'CLIENTE';}?>
        </th>
				<th onclick="sortTable(this,<?php echo $ccol++; ?>,'N');">VALOR</th>
				<th onclick="sortTable(this,<?php echo $ccol++; ?>,'N');">SUBTOTAL</th>
			<?php}?>

      <?php if($cfg_empr=='pcs1' and substr($docu,0,2)=='FC') {?>
			<th onclick="sortTable(this,<?php echo $ccol++; ?>);" style="<?php if($xmcntn==""){echo 'display:none;';}?>;">CONTENEDOR</th>
			<th style="<?php if($xmcntn==""){echo 'display:none;';}?>;">DESDE</th>
			<th style="<?php if($xmcntn==""){echo 'display:none;';}?>;">HASTA</th>
			<?php}?>

      
      <?php if(mb_stristr('tgck.sawo.ztej',$cfg_empr)  and substr($docu,0,2)=='FC') {?>
			<th onclick="sortTable(this,<?php echo $ccol++; ?>);" style="<?php if($xmvhcl==""){echo 'display:none;';}?>;">VEHICULO</th>
			<th onclick="sortTable(this,<?php echo $ccol++; ?>);" style="<?php if($xmvhcl==""){echo 'display:none;';}?>;"></th>
			<?php}?>
      
      <?php if(mb_stristr('gmny.gnya',$cfg_empr) and mb_stristr('vtas.clie.carr.prod.inve',$tabla)) {?>
			<th onclick="sortTable(this,<?php echo $ccol++; ?>);" style="<?php if($xmclor==""){echo 'display:none;';}?>;">C</th>
			<th onclick="sortTable(this,<?php echo $ccol++; ?>);" style="<?php if($xmtlla==""){echo 'display:none;';}?>;">T</th>
			<?php}?>
      
      
		</tr>
		</thead>
		<?php $lvhcl=''; ?>
		<?php $filax=0; ?>
    <?php //msql_data_seek($res_tra2,0);?>
		<?php $res_tra2=msql_query($sql_tra2,$link_vcrx); ?>
    <?php //echo explain_sql($sql_tra2);?>  
		<tbody>
		<?php while($aso_tra2=msql_fetch_assoc($res_tra2)){?>	
      <?php $mtime=microtime(true)-$mtime;?>
				<?php
				$filax++;
				$iddet=$aso_tra2['iddet'];
				$duni=$aso_tra2['item_duni'];
				$dpre=$aso_tra2['item_dpre'];
				$dval=$aso_tra2['item_dval'];
				$icodigov=$aso_tra2['item_codigov'];
				$item_codigo=$aso_tra2['item'];
				$item_codigoce=$aso_tra2['itemce'];
				$item_codigoce2=$aso_tra2['itemce2'];
				$item_descri=$aso_tra2['item_descri'];
				$item_mrca=$aso_tra2['item_mrca'];
				$mrca_descri=r_fiel('mrca',$item_mrca);
                    if(mb_stristr('pcs1',$cfg_empr)){$item_descri.=' /'.$mrca_descri;}
				$ctas_descri=@$aso_tra2['ctas_descri'];
			  $ctas_descri=split_words($ctas_descri,40);
                                                     
        $long_itemdes=strlen($item_descri);
        $long_ctasdes=strlen($ctas_descri);
	
				$detalle=$aso_tra2['detalle'];
        //corrige duplicidad del usuario
				$detalle=str_replace($xconcepto,'',$detalle);
				$detalle=str_replace($item_descri,'',$detalle);
        if(@mb_stristr($item_descri,$detalle)){$detalle='';}                                                     
        $long_detalle=strlen($detalle);                                                     
				if($item_descri!="" and $item_codigo!="-" and substr($item_codigo,0,4)!="9999" and mb_stristr('cont',$tabla))
				{$detalle.='<div style="font-size:80%;">'.' /'.$item_descri.'</div>';}
			
				if($icodigov==""){$icodigov=$aso_tra2['item'];}
        if(substr($item_codigo,0,4)=="9999"){$item_descri=$detalle; $detalle='';}
        if(substr($item_codigo,0,4)=="8888"){$item_descri=$detalle; $detalle='';}
                                                     
				if(substr($item_codigo,0,4)=="9999")
        {
          $item_codigo ='99-';
          $item_codigo.=$aso_tra2['itemce'];
          $item_codigo.=' /'.$aso_tra2['itemce2'];
        }
				if($item_codigo==""){$item_codigo=$aso_tra2['item'];}
                                                     
				if($duni==0){$duni=2;}
				if($dpre==0){$dpre=2;}
				if($dval==0){$dval=2;}
				if(ceil($aso_tra2['cant'])!=floor($aso_tra2['cant']) and $duni==0){$duni=2;}
				?>
				<?php if($cfg_empr=='ecgl' and mb_stristr('clie.vtas.prod',$tabla) and substr($item_descri,0,4)=='VIDR'){ ?>
					<?php if($aso_tra2['itnum']>1){echo '<tr><td><br></td></tr>';}?>
          <?php
            $itsubt=0;
            $itdcto=0;
            $itiva=0;
            $itotal=0;
                                                                                                              
            if($tabla!='prod')                                                                                                             
            {                                                                                             
              $sql_itnum ='select * from '.$tabla.'12 where idnum1="'.$aso_tra2['idnum1'].'" and itnum="'.$aso_tra2['itnum'].'"';
              $res_itnum=msql_query($sql_itnum,$link_vcrx);
              while($aso_itnum=@msql_fetch_assoc($res_itnum))
              {
                $itsubt+=$aso_itnum['tsubt'];
                $itdcto+=$aso_itnum['tdcto'];
                $itiva+=$aso_itnum['tiva'];
                $itotal+=$aso_itnum['total'];
              }
            }
      
        ?>
					<tr style="<?php if($tabla=='prod' or 1==1){echo 'font-size:125%';} ?>">
					<td align="center" style="font-weight:bolder;"><?php echo '#'.fillzero($aso_tra2['itnum'],2);?>	</td>
					<td style="border:solid 1px; font-weight:bolder; background:<?php echo $gris1;?>;">
					<?php $mm_e=substr($item_descri,strpos($item_descri,'MM')-2,2); ?>	
					<?php echo 'LAMINAS : '.$aso_tra2['lmns'];?>	
					<?php echo ' ('.$mm_e.'mm. ';?>	
					<?php echo ' X '.$aso_tra2['mm_l'].' ';?>	
					<?php echo ' X '.$aso_tra2['mm_a'].' )';?>	
					</td>
          <td align="right"><?php echo number_format($aso_tra2['lmns']);?></td>
          <td align="left">LAM.</td>
          <?php if($tabla=='prod'){ ?> 
            <?php
              $pulido='';
              $templar='';
              if($aso_tra2['puli']==1){$pulido='MATE';}
              if($aso_tra2['puli']==2){$pulido='BRILLANTE';}
              if($aso_tra2['tmpl']<=1){$templar='CRUDO';}
              if($aso_tra2['tmpl']==2){$templar='TEMPLAR';}
          
              $tsaques=number_format($aso_tra2['saqu0']+$aso_tra2['saqu1']+$aso_tra2['saqu2'],0);
              $tperfor=number_format($aso_tra2['perf0']+$aso_tra2['perf1']+$aso_tra2['perf2'],0);
              $tmts=number_format(($aso_tra2['mm_l']+$aso_tra2['mm_a'])*2/1000,2);
              $tmt2=number_format(($aso_tra2['mm_l']*$aso_tra2['mm_a'])/1000000,2);
            ?>
            <td align="center"><?php if($tsaques!=0){echo '| SAQ.: '.$tsaques.' ';}?></td>
            <td align="center"><?php if($tperfor!=0){echo '| PER.: '.$tperfor.' ';}?></td>
            <td align="center"><?php if($pulido!=''){echo '| PUL.: '.$pulido.' ';}?></td>
            <td align="right"><?php if($templar!=''){echo '| '.$templar.' |';}?></td>
          <?php }?>
          <?php if($tabla!='prod'){ ?>                                                                                                              
            <td align="right"><?php echo number_format($itsubt/$aso_tra2['lmns'],2);?></td>
            <td align="right"><?php echo number_format($itsubt,2);?></td>
            <td align="right" style="<?php if($xtdcto==0){echo 'display:none;';}?>;"><?php echo number_format($itdcto,2);?></td>
            <td align="right"><?php echo number_format($itiva,2);?></td>
            <td align="right"><?php echo number_format($itotal,2);?></td>
          <?php }?>
					</tr>	
				<?php	} ?>
      
      
			<tr valign="top" style="<?php if($filax %$filag==0){echo 'border-bottom:dotted 1px;';} ?> 
          <?php //if($cfg_empr=='ecgl' and mb_stristr('clie.vtas',$tabla)) {echo 'display:none';} ?>" >
					<td align="center" style="display:none;"><?php echo fillzero($crow++);?></td>
					
					<?php if(mb_stristr('cont',$tabla)){ ?>
						<td align="left"><?php echo $aso_tra2['ctas'];?></td>
						<td align="left"><?php echo $ctas_descri;?></td>
						<td align="right">
							<?php echo number_format($aso_tra2['tdebito'],$duni);?>
						</td>
						<td align="right">
							<?php echo number_format($aso_tra2['tcredito'],$duni);?>
						</td>
						<td align="center" style="<?php if($xmcsub==""){echo 'display:none;';}?>;"><?php echo $aso_tra2['csub'];?></td>
						<td align="center" style="<?php if($xmcair==""){echo 'display:none;';}?>;"><?php echo $aso_tra2['cair'];?></td>
						<td align="center" style="<?php if($xmitem==""){echo 'display:none;';}?>;font-size:80%;"><?php echo $aso_tra2['item'];?></td>
						<td align="left"><?php echo $detalle;?></td>
					<?php } ?>
					<?php if(mb_stristr('nomi.',$tabla)){?>
            <?php //$empl_descri=r_fiel('enti',$aso_tra2['enti'],'enti_ape1').' '.r_fiel('enti',$aso_tra2['enti'],'enti_nom1'); ?>
            <?php $empl_descri=$aso_tra2['enti_ape1'].' '.$aso_tra2['enti_nom1']; ?>
            <?php if((trim($empl_descri)=='')){$empl_descri=$aso_tra2['enti_descri']; }?>
						<td align="center"><?php echo $aso_tra2['enti2'];?></td>
						<td align="left"><?php echo $empl_descri; ?></td>
					<?php } ?>
        
					<?php if(mb_stristr('nomi.empl',$tabla)){?>
            <?php
//               $xpuni=$aso_tra2['puni'];
//               $ddig=decimaldigit($xpuni)+1;
          $ddig=4;
              $tremun=$aso_tra2['tingreso'];
              $tdeduc=$aso_tra2['tegreso'];
              $tprovi=$aso_tra2['tprovis'];
            ?>
						<td align="center"><?php echo $aso_tra2['nvdd'];?></td>
						<td align="left"><?php echo $aso_tra2['nvdd_descri'];?></td>
						<td align="right"><?php echo number_format($aso_tra2['cant'],2);?></td>
						<td align="right"><?php echo number_format($aso_tra2['puni'],$ddig);?></td>
						<td align="right">
              <?php if($tremun!=0){ ?>
              <?php echo number_format($tremun,2);?>
              <?php } ?>
            </td>
						<td align="right">
              <?php if($tdeduc!=0){ ?>
              <?php echo number_format(abs($tdeduc),2);?>
              <?php } ?>
            </td>
						<td align="right">
              <?php if($tprovi!=0){ ?>
              <?php echo number_format($tprovi,2);?>
              <?php } ?>
            </td>
						<td align="left"><?php echo $aso_tra2['detalle'];?></td>
					<?php } ?>
        
					<?php if(mb_stristr('susa',$tabla)){?>
						<td align="center"><?php echo $aso_tra2['fecha2'];?></td>
						<td align="right"><?php echo number_format($aso_tra2['sueldo'],2);?></td>
						<td align="right"><?php echo number_format($aso_tra2['valanti'],2);?></td>
						<td align="right"><?php echo number_format($aso_tra2['poranti'],2);?></td>
						<td align="right"><?php echo number_format($aso_tra2['alimentacion'],2);?></td>
						<td align="right"><?php echo number_format($aso_tra2['movilizacion'],2);?></td>
						<td align="right"><?php echo number_format($aso_tra2['comision'],2);?></td>
						<td align="center"><?php echo $aso_tra2['de13'];?></td>
						<td align="center"><?php echo $aso_tra2['de14'];?></td>
						<td align="center"><?php echo $aso_tra2['fres'];?></td>
						<td align="right"><?php echo number_format($aso_tra2['total'],2);?></td>
					<?php } ?>
					<?php if(mb_stristr('guia',$tabla)){?>
						<td align="left"><?php echo $aso_tra2['item'];?></td>
						<td align="left"><?php echo $item_descri;?></td>
						<td align="<?php if($duni==0){echo 'center';}else{echo 'right';}?>" >
							<?php echo number_format($aso_tra2['cant'],$duni);?>
						</td>
						<td align="left"><?php echo $aso_tra2['item_umdd'];?></td>
					<?php $xcant=$aso_tra2['cant']; ?>
					<?php $xumdd=$aso_tra2['item_umdd']; ?>
        
        <?php
					if($filax %$filag==0){$lrtb='B';}else{$lrtb='';}																																				 

          $posY=$docu_pdf->GetY();

          $docu_pdf->SetFont($ffamilyPDF,'',$fsizePDF-4);
          if(strlen(trim($icodigov))>5){$docu_pdf->SetFont($ffamilyPDF,'',$fsizePDF-5);}                                                               
          $docu_pdf->Cell($pdf_ancho*.1,5,$icodigov,$lrtb,0,'L',false);
          $docu_pdf->SetFont($ffamilyPDF,'',$fsizePDF-5);
          $posX=$docu_pdf->GetX();
          $col_width=$pdf_ancho*.3;
          $docu_pdf->MultiCell($col_width,5,utf8_decode($item_descri),$lrtb,'L',false);
          $posYb=$docu_pdf->GetY();
          $posX=$posX+$col_width;
          $docu_pdf->SetXY($posX,$posY);
                                                                         
          $docu_pdf->SetFont($ffamilyPDF,'',$fsizePDF-4);
          $docu_pdf->Cell($pdf_ancho*.1,5,number_format($xcant,2),$lrtb,0,'R',false);
          $docu_pdf->SetFont($ffamilyPDF,'',$fsizePDF-6);
          $docu_pdf->Cell($pdf_ancho*.03,5,$xumdd,$lrtb,0,'L',false);
          $docu_pdf->SetFont($ffamilyPDF,'',$fsizePDF-4);
          $docu_pdf->ln();

          $docu_pdf->SetY($posYb);
                                                                         
        ?>

        
					<?php } ?>
					<?php if(mb_stristr('vtas.comp.clie.carr.prov.inve.prod.comi.tfin',$tabla)){?>
					<?php $xcant=$aso_tra2['cant']; ?>
					<?php $xpuni=$aso_tra2['puni']; ?>
					<?php $xpvp=@$aso_tra2['pvp']; ?>
        
        
					<?php $xsubt=$aso_tra2['tsubt']; ?>
					<?php $xdcto=$aso_tra2['tdcto']; ?>
					<?php $xprop=$aso_tra2['tprop']; ?>
					<?php $xice=$aso_tra2['tice']; ?>
					<?php $xiva=abs($aso_tra2['tiva']); ?>
					<?php $xirbp=$aso_tra2['tirbp']; ?>
					<?php $xttotal=$aso_tra2['total']; ?>
					<?php $xumdd=$aso_tra2['item_umdd']; ?>
					<?php $dpre=$aso_tra2['item_dpre']; ?>
					<?php $dcos=$aso_tra2['item_dcos']; ?>
					<?php if($dpre==0){$dpre=2;} ?>
					<?php $xcantp=$xcant/$xtcant*100; ?>

          <?php //costos ?>
					<?php //$xipuni=0; ?>
					<?php //$xpuni=0; ?>
					<?php //$xsubt=0; ?>
					<?php //$xttotal=0; ?>
					<?php //$xtotal=0; ?>
        
        
          <?php
            if(mb_stristr('comp.prov.inve.prod.tfin',$tabla))
            {
              $xxpuni=$xpuni;
              $xxpuni=trim($xpuni,'0');
              $xxpuni=substr($xxpuni,strpos($xxpuni,'.')+1);
//               $dpre=strlen($xxpuni);
            }
          ?>
        
						<?php if(mb_stristr('vtas.clie.comi.carr.prod.comi',$tabla)){?>
						<td align="left"><span style="display:none;"><?php echo $aso_tra2['item'];?></span>
							<?php echo $icodigov;?></td>
						<?php }else{?>
						<td align="left"><?php echo $item_codigo;?></td>
						<?php } ?>
					<td align="left"  style="<?php if(substr($item_codigo,0,4)=='9900'){ echo 'font-size:75%;';} ?>">
						<?php echo $item_descri;?>
					</td>
					<td align="<?php if($duni==0){echo 'center';}else{echo 'right';}?>" >
						<?php echo number_format($aso_tra2['cant'],$duni);?>
					</td>
					<td align="left" valign="" style="font-size:80%;">
						<?php echo ' '.$aso_tra2['item_umdd'];?>
					</td>

<?php
             $docu_txt.=str_pad(''.$icodigov,13,$padtxt,STR_PAD_RIGHT);
             $docu_txt.=' |'.substr(str_replace($icodigov,'',$item_descri),0,$coltxt-14).$eol;
                                                                         
             $docu_txt.=str_pad(number_format($xcant,2),9,$padtxt,STR_PAD_LEFT).' '.$xumdd.'|';
             $docu_txt.=str_pad(number_format($xpuni,$dpre),9,$padtxt,STR_PAD_LEFT).'|';
//              $docu_txt.=str_pad(number_format($xsubt+$xiva,$dval),9,$padtxt,STR_PAD_LEFT).'|';
             $docu_txt.=str_pad(number_format($xttotal+$xdcto,$dval),9,$padtxt,STR_PAD_LEFT).'|';
             if($xiva>0){$docu_txt.='I';}
             $docu_txt.=$eol;
             if($xdcto>0)
             {$docu_txt.=''.str_pad('DCTO: '.number_format($xdcto,$dval),34,$padtxt,STR_PAD_LEFT);}
             $docu_txt.=$eol;
?>

        <?php
					if($filax %$filag==0){$lrtb='B';}else{$lrtb='';}																																				 

          $posY=$docu_pdf->GetY();

          $docu_pdf->SetFont($ffamilyPDF,'',$fsizePDF-4);
          if(strlen(trim($icodigov))>5){$docu_pdf->SetFont($ffamilyPDF,'',$fsizePDF-5);}                                                               
          $docu_pdf->Cell($pdf_ancho*.1,5,$icodigov,$lrtb,0,'L',false);
          $docu_pdf->SetFont($ffamilyPDF,'',$fsizePDF-5);
//           $docu_pdf->Cell($pdf_ancho*.3,5,substr(utf8_decode($item_descri),0,30),$lrtb,0,'L',false);

          $posX=$docu_pdf->GetX();
          $col_width=$pdf_ancho*.3;
          $docu_pdf->MultiCell($col_width,5,utf8_decode($item_descri),$lrtb,'L',false);
          $posYb=$docu_pdf->GetY();
          $posX=$posX+$col_width;
          $docu_pdf->SetXY($posX,$posY);
                                                                         
          $docu_pdf->SetFont($ffamilyPDF,'',$fsizePDF-4);
//           $docu_pdf->Cell($pdf_ancho*.1,5,number_format($xcant,2).' '.$xumdd,$lrtb,0,'R',false);
          $docu_pdf->Cell($pdf_ancho*.1,5,number_format($xcant,2),$lrtb,0,'R',false);
          $docu_pdf->SetFont($ffamilyPDF,'',$fsizePDF-6);
          $docu_pdf->Cell($pdf_ancho*.03,5,$xumdd,$lrtb,0,'L',false);
          $docu_pdf->SetFont($ffamilyPDF,'',$fsizePDF-4);
          $docu_pdf->Cell($pdf_ancho*.1,5,number_format($xpuni,$dpre),$lrtb,0,'R',false);
          $docu_pdf->Cell($pdf_ancho*.1,5,number_format($xsubt,$dval),$lrtb,0,'R',false);
          if($xtdcto>0)
          {$docu_pdf->Cell($pdf_ancho*.07,5,number_format($xdcto,$dval),$lrtb,0,'R',false);}
          if($xtice>0)
          {$docu_pdf->Cell($pdf_ancho*.05,5,number_format($xice,$dval),$lrtb,0,'R',false);}
          if($xtiva>0)
          {$docu_pdf->Cell($pdf_ancho*.05,5,number_format($xiva,$dval),$lrtb,0,'R',false);}
          $docu_pdf->Cell($pdf_ancho*.1,5,number_format($xttotal,$dval),$lrtb,0,'R',false);
          $docu_pdf->ln();

          $docu_pdf->SetY($posYb);
//                              echo '*/*/*'.$dpre;                                            
        ?>

        <?php if($xipvp==1){ ?>
					<td align="right" style="<?php if($xipuni==0){echo 'display:;';}?>">
						<?php echo number_format($xpvp,$dpre);?></td>
        <?php }else{ ?>
        
        
          <?php if($xideta==1){ ?>
					<td align="right" style="<?php if($xipuni==0){echo 'display:none;';}?>">
						<?php echo number_format($xpuni,$dpre);?></td>
					<td align="right" style="<?php if($xipuni==0){echo 'display:none;';}?>">
						<?php echo number_format(abs($xsubt),$dval);?></td>
        
				<?php if(mb_stristr('vtas.comp.clie.carr.prov',$tabla)){?>
					<td align="right" style="<?php if($xipuni*$xtdcto==0){echo 'display:none;';}?><?php if($xdcto==0){echo 'font-size:70%;';}?>font-style: italic;" title="<?php echo number_format($aso_tra2['dcto'],$dval)."%";?>">
						<?php echo number_format($xdcto,$dval);?></td>
					<td align="right" style="<?php if($xipuni*$xtprop==0){echo 'display:none;';}?><?php if($xprop==0){echo 'font-size:70%;';}?>font-style: italic;" title="<?php echo number_format($aso_tra2['prop'],$dval)."%";?>">
						<?php echo number_format($xprop,$dval);?></td>
					<td align="right" style="<?php if($xipuni*$xtice==0){echo 'display:none;';}?><?php if($xice==0){echo 'font-size:70%;';}?>font-style: italic;" title="<?php echo number_format($aso_tra2['ice'],$dval)."%";?>">
						<?php echo number_format($xice,$dval);?></td>
					<td align="right" style="<?php if($xipuni*$xtiva==0){echo 'display:none;';}?><?php if($xiva==0){echo 'font-size:70%;';}?>font-style: italic;" title="<?php echo number_format($aso_tra2['iva'],$dval)."%";?>">
						<?php echo number_format($xiva,$dval);?></td>
					<td align="right" style="<?php if($xipuni*$xtirbp==0){echo 'display:none;';}?><?php if($xirbp==0){echo 'font-size:70%;';}?>font-style: italic;" title="<?php echo number_format($aso_tra2['irbp'],$dval)."";?>">
						<?php echo number_format($xirbp,$dval);?></td>
        <?php } ?>

          <?php } ?>
        
        <?php } ?>
        
					<td align="right" style="<?php if($xipuni==0){echo 'display:none;';}?>">
						<?php echo number_format(abs($xttotal),$dval);?>
            </td>
        
          <td align="left" style="<?php if($xmdetalle==""){echo 'display:;';}?>">
						<?php if(trim($detalle)!=trim($item_descri)){echo $detalle;};?></td>

          <?php if(mb_stristr('ecgl.',$cfg_empr)  and mb_stristr('clie.prod.vtas',$tabla)  ) {?>
              <?php if(mb_stristr($aso_tra2['item_descri'],'PERFOR')) {?>
                <td align="left" colspan="5" style=""><?php echo $aso_tra2['perfor1']; ?></td>
              <?php}?>	
              <?php if(mb_stristr($aso_tra2['item_descri'],'SAQUE')) {?>
                <td align="left" colspan="5" style=""><?php echo $aso_tra2['saques1']; ?></td>
              <?php}?>	
          <?php}?>	
        

          <?php}?>	

					<?php if($empr_cont=='1' and ($tabla=='comp' or $docu=='APX10')) {?>
					<td align="left" colspan="1" style="<?php if($xmctas==""){echo 'display:none;';}?>">
            <?php echo $aso_tra2['ctas'];?>
          </td>
					<td align="left" colspan="1" style="<?php if($xmctas==""){echo 'display:none;';}?>">
            <?php echo '<span style="font-size:75%;">'.$aso_tra2['ctas_descri'].'</span>'; ?>
            <?php //echo '<span style="font-size:75%;">'.$ctas_descri.'</span>'; ?>
          </td>
              <?php if(mb_stristr('FP15',$docu)){?>
              <td align="right"><div style="display:none;">
                <?php echo fillzero($aso_tra2['peso'],9); ?></div><?php echo number_format($aso_tra2['peso'],2);?>
              </td>
              <td align="left"><?php echo $aso_tra2['arcl'];?></td>
              <?php } ?>
              <?php if(mb_stristr('FP16',$docu)){?>
              <td align="left"><?php echo $aso_tra2['arcl'];?></td>
              <td align="right"><div style="display:none;">
                <?php echo fillzero($aso_tra2['adva'],9); ?></div><?php echo number_format($aso_tra2['adva'],2);?>
              </td>
              <td align="right"><div style="display:none;">
                <?php echo fillzero($aso_tra2['fodi'],9); ?></div><?php echo number_format($aso_tra2['fodi'],2);?>
              </td>
              <?php } ?>
              <?php if(!mb_stristr('FP15.DA16.FP16',$docu)){?>
              <td align="center"><?php echo $aso_tra2['cair'];?></td>
              <td align="center"><div style="display:none;">
                <?php echo fillzero($aso_tra2['prrta'],9); ?></div><?php echo number_format($aso_tra2['prrta'],2);?>
              </td>
              <td align="center"><div style="display:none;">
                <?php echo fillzero($aso_tra2['priva'],9); ?></div><?php echo number_format($aso_tra2['priva'],2);?>
              </td>
              <?php } ?>
					<?php}?>	
					
					<?php if(mb_stristr('retc.retp',$tabla)){?>
					<td align="center"><?php echo $aso_tra2['fanio'];?></td>
					<td align="right" style="<?php if(mb_stristr('retc.retp',$tabla)){echo 'padding-right:20px;';}?>">
						<?php echo number_format($aso_tra2['cant'],2);?></td>
					<?php
						$cair='('.$aso_tra2['cair'].')';
						$docum_descri=$aso_tra2['docum_descri'];
						if(substr($aso_tra2['docum_descri'],0,4)=='FACT'){$docum_descri='FACTURA';}
						if($aso_tra2['biva']>0)
						{$cair_descri='IVA';}
						else
						{$cair_descri=$aso_tra2['cair_descri']; $cair='<br>'.$cair;}
					?>
					<td align="center"><?php echo $cair_descri.' '.$cair;?></td>
					<?php if(ceil($aso_tra2['puni'])==floor($aso_tra2['puni'])){$dval=0;} ?>
					<td align="center">
						<?php echo number_format($aso_tra2['puni'],$dval);?>%</td>
					<td align="right" style="<?php if(mb_stristr('retc.retp',$tabla)){echo 'padding-right:20px;';}?>">
						<?php echo number_format(abs($aso_tra2['total']),2);?></td>
					<td align="center"><?php echo $docum_descri;?></td>
          <?php if($cdisplay==1){?>
					<?php
            if($tabla=='retc'){$tdocum='vtas1';}
            if($tabla=='retp'){$tdocum='comp1';}
            $sql_docum ='select * from '.$tdocum.' ';
            $sql_docum.='where numero="'.$aso_tra2['numer'].'" and ptoe="'.$aso_tra2['ptoem'].'" ';
            $sql_docum.=' and enti="'.$aso_tra2['enti'].'" and status !="O" and status!="X"';
            $res_docum=msql_query($sql_docum,$link_vcrx);
//             echo '*/*/'.msql_error().$sql_docum;
            $clavedocum=@msql_result($res_docum,0,'claveacc');                    
            $idnumdocum=@msql_result($res_docum,0,'idnum1');                                    
            $docudocum=@msql_result($res_docum,0,'docu');                                    
          ?>	
					<td align="center">
            <?php if($clavedocum!=""){?>
                <?php if(mb_stristr($clavedocum,$cfg_ruc)){?>
                  <a href="<?php echo 'https://'.$cfg_empr.'.vcrxol.com/?prnt=1&clave='.$clavedocum;?>"  target="_blank" >
                <?php }else{ ?>
                  <a href="<?php echo 'https://'.'demo'.'.vcrxol.com/?prnt=1&clave='.$clavedocum;?>"  target="_blank" >
                <?php }?>
            <?php }else{ ?>
                <?php if($idnumdocum!=""){?>
                <a href="<?php echo 'https://'.$cfg_empr.'.vcrxol.com/?prnt=1&docu='.$docudocum.'&idnum='.$idnumdocum.'&formato='.$formato;?>"  target="_blank" >
                <?php }?>
            <?php }?>
                <?php echo $aso_tra2['ptonumer'];?>
                </a>
          </td>
					<?php}else{?>	
					<td align="center"><?php echo $aso_tra2['ptonumer'];?></td>
					<?php}?>	
				<?php
					$cair=str_replace('<br>','',$cair);
					$cair_descri=str_replace('<br>','',$cair_descri);
					if($filax %$filag==0){$lrtb='B';}else{$lrtb='';}

                                                
          $posY=$docu_pdf->GetY();
          $docu_pdf->SetFont($ffamilyPDF,'',$fsizePDF-3);
          $docu_pdf->Cell($pdf_ancho*.1,5,$aso_tra2['fanio'],$lrtb,0,'C',false);
          $docu_pdf->Cell($pdf_ancho*.1,5,number_format($aso_tra2['cant'],2),$lrtb,0,'R',false);
// 					$cair_descri=str_repeat(' 2 4 6 8 0',8);
					if(strlen($cair_descri)>25)
					{$docu_pdf->SetFont($ffamilyPDF,'',$fsizePDF-4);}
					if(strlen($cair_descri)>50)
					{$docu_pdf->SetFont($ffamilyPDF,'',$fsizePDF-5);}
					if(strlen($cair_descri)>75)
					{$docu_pdf->SetFont($ffamilyPDF,'',$fsizePDF-6);}
//           $docu_pdf->Cell($pdf_ancho*.3,5,$cair_descri.' '.$cair,$lrtb,0,'C',false);

          $posX=$docu_pdf->GetX();
          $col_width=$pdf_ancho*.3;
          $docu_pdf->MultiCell($col_width,5,$cair.' '.$cair_descri,$lrtb,'C',false);
          $posYb=$docu_pdf->GetY();
          $posX=$posX+$col_width;
          $docu_pdf->SetXY($posX,$posY);
                                                
                                                
          $docu_pdf->SetFont($ffamilyPDF,'',$fsizePDF-3);
//           $docu_pdf->Cell($pdf_ancho*.1,5,number_format(abs($aso_tra2['puni']),0).'%',$lrtb,0,'C',false);
          $docu_pdf->Cell($pdf_ancho*.1,5,number_format(abs($aso_tra2['puni']),2).'%',$lrtb,0,'C',false);
          $docu_pdf->Cell($pdf_ancho*.1,5,number_format(abs($aso_tra2['total']),2),$lrtb,0,'R',false);
//           $docu_pdf->SetFont($ffamilyPDF,'',$fsizePDF-4);
          $docu_pdf->Cell($pdf_ancho*.15,5,$docum_descri,$lrtb,0,'C',false);
          $docu_pdf->Cell($pdf_ancho*.15,5,$aso_tra2['ptonumer'],$lrtb,0,'C',false);
          $docu_pdf->ln();


          $docu_pdf->SetY($posYb);
				?>
					<?php}?>	

					<?php if(mb_stristr('caja.bcos.dxco.dxpa',$tabla)){?>
					<?php 	$docum_descri=$aso_tra2['docum_descri'];?>
					<td align="center"><?php echo $docum_descri;?></td>

          <td align="center">
            <?php $xidfrom=$aso_tra2['idfrom'];?>
            <?php
              if($xidfrom=='')
              {
                $tdocum=r_fiel('docu',$aso_tra2['docum'],'tabla');
                $sql_docum ='select * from '.$tdocum.'1 ';
//                 $sql_docum.=' where numero="'.$aso_tra2['numer'].'" and ptoe="'.$aso_tra2['ptoem'].'" ';
                $sql_docum.=' where docu="'.$aso_tra2['docum'].'" and numero="'.$aso_tra2['numer'].'" and ptoe="'.$aso_tra2['ptoem'].'" ';
                $sql_docum.=' and enti like "'.substr($aso_tra2['enti'],0,10).'%" ';
                $sql_docum.=' and status not in("O","X")';
                $res_docum=msql_query($sql_docum,$link_vcrx);
//                 echo msql_error($res_docum). $sql_docum;
                
                if(@msql_num_rows($res_docum)==0)
                {
                  
                }
//                 echo '*/*/*/'.$tdocum.$xidfrom.$sql_docum;
                $xidfrom=@msql_result($res_docum,0,'idnum1');
              }
            ?>
            <?php if($xidfrom!=''){ ?>
            <a href="<?php echo 'https://'.$cfg_empr.'.vcrxol.com/?prnt=1&docu='.$aso_tra2['docum'].'&idnum='.$xidfrom.'&formato='.$formato;?>"  target="_blank" >
            <?php } ?>
            <?php echo $aso_tra2['ptonumer'];?>
            </a>
          </td>
					<td align="right" >
						<?php echo number_format($aso_tra2['cant'],2);?></td>
          <?php if(mb_stristr('dxco.dxpa',$tabla)){?>
					<td align="right" >
						<?php echo number_format($aso_tra2['puni'],2);?></td>
					<td align="right" >
						<?php echo number_format($aso_tra2['total'],2);?></td>
          <?php } ?>
					<td align="center"><?php echo $aso_tra2['ctas'];?></td>
<!-- 					<td align="left"><?php //echo $aso_tra2['ctas_descri'];?></td> -->
					<td align="left"><?php echo $ctas_descri;?></td>
					<td align="left"><?php echo $detalle;?></td>
					<?php}?>	
                    
					<?php if(mb_stristr('vtas.clie.inve.prod.tfin',$tabla)){?>
					<td align="center" style="<?php if($xmlote==''){echo 'display:none;';} ?>"><?php echo $aso_tra2['lote'];?></td>
                         <?php } ?>
                    
					<?php if(mb_stristr('inve.prod.tfin',$tabla)){?>
					<td align="left" style="<?php if($xmserie==''){echo 'display:none;';} ?>"><?php echo $aso_tra2['numserie'];?></td>
                         <?php } ?>
                    
            <?php if(mb_stristr('IB11.EB11',$docu)){ ?>
            <?php $itemcambio=$aso_tra2['cambio'].' - '.r_fiel('item',$aso_tra2['cambio']); ?>
            <?php $itemcambio=split_words($itemcambio);?>
            <td><?php echo $itemcambio; ?></td>
            <?php } ?>

                    
          <?php //if(mb_stristr('DA16',$docu) and $formato==5){?>
          <?php if(mb_stristr('DA16',$docu)){ ?>
          <?php 
              $xcant=$aso_tra2['cant'];
              $xsubt=abs($aso_tra2['tsubt']);
              $xpeso=abs($aso_tra2['peso']);
              $xarcl=$aso_tra2['arcl'];

          
              $costoe1=$aso_tra2['costoe1']; 
              $costoe1d=$aso_tra2['costoe1d']; 
              if($costoe1d==1){$costoe2=abs($costoe1/$xtunid*$xcant);}
              if($costoe1d==2){$costoe2=abs($costoe1/$xtsubt*$xsubt);}
              if($costoe1d==3){$costoe2=abs($costoe1/$xtpeso*$xpeso);}
              $fob2=$xsubt+$costoe2;
          
              $seguro1=$aso_tra2['seguro1']; 
              $seguro1d=$aso_tra2['seguro1d']; 
              if($seguro1d==1){$seguro2=abs($seguro1/$xtunid*$xcant);}
              if($seguro1d==2){$seguro2=abs($seguro1/$xtsubt*$xsubt);}
              if($seguro1d==3){$seguro2=abs($seguro1/$xtpeso*$xpeso);}
          
              $flete1=$aso_tra2['flete1']; 
              $flete1d=$aso_tra2['flete1d']; 
              if($flete1d==1){$flete2=abs($flete1/$xtunid*$xcant);}
              if($flete1d==2){$flete2=abs($flete1/$xtsubt*$xsubt);}
              if($flete1d==3){$flete2=abs($flete1/$xtpeso*$xpeso);}
          
              $cif2=$fob2+$seguro2+$flete2;

              $adva2=abs($aso_tra2['adva']);
              $fodi2=abs($aso_tra2['fodi']);
              $iva2=abs($aso_tra2['ivai']);
              $isd2=$fob2*r_fiel('arcl',$xarcl,'isd')/100;


              $costol1=$aso_tra2['costol1']; 
              $costol1d=$aso_tra2['costol1d']; 
              if($costol1d==1){$costol2=abs($costol1/$xtunid*$xcant);}
              if($costol1d==2){$costol2=abs($costol1/$xtsubt*$xsubt);}
              if($costol1d==3){$costol2=abs($costol1/$xtpeso*$xpeso);}
          
              $costot2=$cif2+$adva2+$fodi2+$isd2+$costol2;
          
//           echo '<br>'.$cif2;
//           echo '<br>'.$adva2;
//           echo '<br>'.$fodi2;
//           echo '<br>'.$isd2;
//           echo '<br>'.$costol2;
          
              $costou2=$costot2/$xcant;
// echo '*/*/*/'.$costou2;
          
              $xtfob+=$fob2;
              $xtseguro+=$seguro2;
              $xtflete+=$flete2;
              $xtcif+=$cif2;
              $xtadva+=$adva2;
              $xtfodi+=$fodi2;
              $xtivai+=$ivai2;
              $xtisd+=$isd2;
              $xtcostol+=$costol2;
              $xtcostot+=$costot2;
          
//           echo '*/*/*/*'.$xtadva;
          
              $sql_cuni='update '.$tabla.'2 set cuni='.round($costou2,6).' where idnum2='.$idnum.' and iddet='.$iddet.'';
              $res_cuni=msql_query($sql_cuni,$link_vcrx);
// echo '<br>'.$sql_cuni;                         
          
          
              $decimales = explode('.',$costou2);
//           echo $decimales[1];
              $cdeci=strlen($decimales[1]);
              if($cdeci==0){$dcos=0;}
              if($cdeci>=1){$dcos=2;}
              if($cdeci>=3){$dcos=4;}
              if($cdeci>=5){$dcos=6;}
              
          
//           echo $sql_cuni;
//               echo msql_error($link_vcrx);
         
          ?>
          <td align="right" style="<?php if($xpeso==0){echo 'display:;';}?>" >
            <div style="display:none;">
            <?php echo fillzero($xpeso,9); ?></div><?php echo number_format($xpeso,2);?>
          </td>
          <td align="left" style="<?php if($xmarcl==''){echo 'display:;';}?>"><?php echo $aso_tra2['arcl'];?></td>
          <td align="right" style="<?php if($costoe1==0){echo 'display:none;';}?>" >
            <div style="display:none;">
            <?php echo fillzero($costoe2,9); ?></div><?php echo number_format($costoe2,2);?>
          </td>
          <td align="right"><div style="display:none;">
            <?php echo fillzero($fob2,9); ?></div><?php echo number_format($fob2,2);?>
          </td>
          <td align="right"><div style="display:none;">
            <?php echo fillzero($seguro2,9); ?></div><?php echo number_format($seguro2,2);?>
          </td>
          <td align="right"><div style="display:none;">
            <?php echo fillzero($flete2,9); ?></div><?php echo number_format($flete2,2);?>
          </td>
          <td align="right"><div style="display:none;">
            <?php echo fillzero($cif2,9); ?></div><?php echo number_format($cif2,2);?>
          </td>
          <td align="right" style="<?php if($xadva==0){echo 'display:none;';}?>"><div style="display:none;">
            <?php echo fillzero($adva2,9); ?></div><?php echo number_format($adva2,2);?>
          </td>
          <td align="right" style="<?php if($xfodi==0){echo 'display:none;';}?>"><div style="display:none;">
            <?php echo fillzero($fodi2,9); ?></div><?php echo number_format($fodi2,2);?>
          </td>
          <td align="right" style="<?php if($xivai==0){echo 'display:none;';}?>"><div style="display:none;">
            <?php echo fillzero($ivai2,9); ?></div><?php echo number_format($ivai2,2);?>
          </td>
          <td align="right" style="<?php if($xmisdi==0){echo 'display:none;';}?>"><div style="display:none;">
            <?php echo fillzero($isd2,9); ?></div><?php echo number_format($isd2,2);?>
          </td>
          <td align="right"><div style="display:none;">
            <?php echo fillzero($costol2,9); ?></div><?php echo number_format($costol2,2);?>
          </td>
          <td align="right"><div style="display:none;">
            <?php echo fillzero($costot2,9); ?></div><?php echo number_format($costot2,2);?>
          </td>
          <td align="right"><div style="display:none;">
            <?php echo fillzero($costou2,9); ?></div><?php echo number_format($costou2,$dcos);?>
          </td>
          <?php } ?>
                    
                    
                    
          <?php if(mb_stristr('plan.atvd',$tabla)){?>
					<td align="center"><?php echo $aso_tra2['asub'];?></td>
					<td align="left"><?php echo $aso_tra2['asub_descri'];?></td>
					<td align="right" >
						<?php echo number_format($aso_tra2['cant'],2);?>
					</td>
               <?php if(mb_stristr('atvd',$tabla)){?>
					<td align="center"><?php echo $aso_tra2['empr2'];?></td>
					<td align="center"><?php echo $aso_tra2['numerpla'];?></td>
                <?php}?>
               <?php if(mb_stristr('plan',$tabla)){?>
					<td align="center"><?php echo $aso_tra2[''];?></td>
                <?php}?>
					<td align="left"><?php echo r_fiel('enti',$aso_tra2['enti2']);
//                                                 echo ' - '. $aso_tra2['numerpla'];?></td>
					<td align="right" >
						<?php echo number_format($aso_tra2['puni'],2);?>
					</td>
					<td align="right" >
						<?php echo number_format($aso_tra2['tsubt'],2);?>
					</td>
          <?php}?>
        
        
          <?php if($cfg_empr=='pcs1' and substr($docu,0,2)=='FC' and $aso_tra2['cntn']!="") {?>
            <td align="center" style="font-family:courier;"><?php echo $aso_tra2['cntn'];?></td>
            <td align="center"><?php echo date('d/M/y',strtotime($aso_tra2['cntnf1']));?></td>
            <td align="center"><?php echo date('d/M/y',strtotime($aso_tra2['cntnf2']));?></td>
          <?php }?>
					
          <?php if(mb_stristr('tgck.sawo.ztej',$cfg_empr)  and substr($docu,0,2)=='FC' and $aso_tra2['vhcl']!="") {?>
            <td align="left">
              <?php
                $avhcl=$aso_tra2['vhcl'];
                echo $avhcl;
                if($avhcl!=$lvhcl)
                {echo '<td>'.r_fiel('vhcl',$avhcl).'</td>'; $lvhcl=$avhcl;}
              ?>
            </td>
          <?php }?>
	
          <?php
            $clor_codigo=$aso_tra2['item_clor'];
            $clor_descri='';
            $clor_hexa='';
            if($clor_codigo*1>0)
            {
              $sql_clor='select * from clor0 where clor_codigo="'.$clor_codigo.'"';
              $res_clor=msql_query($sql_clor,$link_vcrx);
              $clor_descri=msql_result($res_clor,0,'clor_descri');
              $clor_hexa=msql_result($res_clor,0,'clor_hexa');
            }
          ?>
                    
          <?php if(mb_stristr('gmny.gnya',$cfg_empr) and mb_stristr('vtas.clie.carr.prod.inve',$tabla)) {?>
            <td align="center" style="font-size:80%; font-weight:bold; color:black; background:<?php echo $clor_hexa; ?>;"><?php {echo $clor_descri;}?></td>
            <td align="center" ><?php if($aso_tra2['item_tlla']*1>0){echo r_fiel('tlla',$aso_tra2['item_tlla']);}?></td>
          <?php }?>
                    
                    
                    
				</tr>
		<?php}?>	
			
		<?php if($marcas==1){?>
			<?php $sql_mrca='select distinct item_mrca from '.$tabla.'12 where idnum2="'.$idnum.'" and item_mrca!="" and item_mrca is not null and item_mrca!="-"';?>
			<?php $res_mrca=msql_query($sql_mrca,$link_vcrx);	?>
			<tr id="logomarcas"><td colspan="10">
			<?php while($aso_mrca=msql_fetch_assoc($res_mrca)){?>	
				<?php $mrcafile=strtolower('mrca'.$aso_mrca['item_mrca'].'.png');?>
				<?php if(file_exists($rutalogo.$mrcafile)){ ?>
					<?php $crow++; ?>
					<img src="<?php echo 'https://vcrxol.com/_logo/'.$mrcafile; ?>" alt=""
							 title="<?php echo ''; ?>" style="max-width:100%; max-height:10mm;">		
				<?php } ?>
			<?php}?>	
			</tr></td>
		<?php}?>	
			
			<?php $mindeta=$mindeta-$crow; ?>
			<?php for($clinbr=1;$clinbr<=$mindeta;$clinbr++){?>
			<tr><?php echo str_repeat('<td><br></td>',$ccol); ?></tr>
			<?php } ?>
		</tbody>
		<tfoot>
		<tr style="background:<?php echo $gris1;?>; border-top:solid 1px; border-bottom:solid 1px; font-weight:bolder;">
			
			<?php if(mb_stristr('cont',$tabla)){?>
				<th></th>
				<th  colspan=1 style="letter-spacing: 5px;">TOTAL</th>
				<th align="right"><?php echo number_format($xtdebito,2);?></th>
				<th align="right"><?php echo number_format($xtcredito,2);?></th>
			<?php}?>
         
			<?php if(mb_stristr('susa',$tabla)){$xtotal=0;}?>
			
			<?php if(mb_stristr('guia',$tabla)){?>
				<th></th>
				<th  colspan=1 style="letter-spacing: 5px;">TOTAL</th>
      
      <?php
          $lrtb='TB';                                                                  
          $docu_pdf->SetFont($ffamilyPDF,'B',$fsizePDF-4);
          $docu_pdf->Cell($pdf_ancho*.1,5,' ',$lrtb,0,'L',true);
          $docu_pdf->SetFont($ffamilyPDF,'B',$fsizePDF-5);
          $docu_pdf->Cell($pdf_ancho*.3,5,'TOTALES',$lrtb,0,'C',true);
          $docu_pdf->SetFont($ffamilyPDF,'B',$fsizePDF-4);
          $docu_pdf->Cell($pdf_ancho*.1,5,number_format($xtcant,2),$lrtb,0,'R',true);
          $docu_pdf->Cell($pdf_ancho*.03,5,'',$lrtb,0,'R',true);
          $docu_pdf->Cell($pdf_ancho*.1,5,'',$lrtb,0,'R',true);
//           $docu_pdf->Cell($pdf_ancho*.1,5,number_format($xtsubt,$dval),$lrtb,0,'R',true);
//           if($xtdcto>0)
//           {$docu_pdf->Cell($pdf_ancho*.07,5,number_format($xtdcto,$dval),$lrtb,0,'R',true);}
//           if($xtice>0)
//           {$docu_pdf->Cell($pdf_ancho*.05,5,number_format($xtice,$dval),$lrtb,0,'R',true);}
//           if($xtiva>0)
//           {$docu_pdf->Cell($pdf_ancho*.05,5,number_format($xtiva,$dval),$lrtb,0,'R',true);}
// //           $docu_pdf->Cell($pdf_ancho*.1,5,'',$lrtb,0,'R',false);
//           $docu_pdf->Cell($pdf_ancho*.1,5,number_format($xtotal,$dval),$lrtb,0,'R',true);
          $docu_pdf->ln();
        ?>
      
			<?php}?>
			
			<?php if(mb_stristr('vtas.comp.clie.carr.prov.inve.prod.comi.plan.atvd.tfin.',$tabla)){?>
				<th></th>
				<th  colspan=1 style="letter-spacing: 5px;">TOTALES</th>
				<?php if(ceil($xtcant)!=floor($xtcant)  and $duni==0){$duni=2;} ?>
				<th align="<?php if($duni==0){echo 'center';}else{echo 'right';}?>">
          <?php echo number_format($xtcant,$duni);?>
        </th>
				<th></th>

        <?php if($xipvp==1){ ?>
				<th style="<?php if($xipuni==0){echo 'display:none;';}?>"></th>
        <?php }else{ ?>
				<th style="<?php if($xipuni==0){echo 'display:none;';}?>"></th>
				<th align="right" style="<?php if($xipuni==0){echo 'display:none;';}?>"><?php echo number_format(abs($xtsubt),$dval);?></th>
				<?php if(mb_stristr('vtas.comp.clie.carr.prov',$tabla)){?>
					<th align="right" style="<?php if($xipuni*$xtdcto==0){echo 'display:none;';}?>font-style: italic;"><?php echo number_format($xtdcto,$dval);?></th>
					<th align="right" style="<?php if($xipuni*$xtprop==0){echo 'display:none;';}?>font-style: italic;"><?php echo number_format($xtprop,$dval);?></th>
					<th align="right" style="<?php if($xipuni*$xtice==0) {echo 'display:none;';}?>font-style: italic;"><?php echo number_format($xtice,$dval);?></th>
					<th align="right" style="<?php if($xipuni*$xtiva==0) {echo 'display:none;';}?>font-style: italic;"><?php echo number_format($xtiva,$dval);?></th>
					<th align="right" style="<?php if($xipuni*$xtirbp==0){echo 'display:none;';}?>font-style: italic;"><?php echo number_format($xtirbp,$dval);?></th>
				<?php}?>

        <?php } ?>
      
      <?php
          $lrtb='TB';                                                                  
          $docu_pdf->SetFont($ffamilyPDF,'B',$fsizePDF-4);
          $docu_pdf->Cell($pdf_ancho*.1,5,' ',$lrtb,0,'L',true);
          $docu_pdf->SetFont($ffamilyPDF,'B',$fsizePDF-5);
          $docu_pdf->Cell($pdf_ancho*.3,5,'TOTALES',$lrtb,0,'C',true);
          $docu_pdf->SetFont($ffamilyPDF,'B',$fsizePDF-4);
          $docu_pdf->Cell($pdf_ancho*.1,5,number_format($xtcant,2),$lrtb,0,'R',true);
          $docu_pdf->Cell($pdf_ancho*.03,5,'',$lrtb,0,'R',true);
          $docu_pdf->Cell($pdf_ancho*.1,5,'',$lrtb,0,'R',true);
          $docu_pdf->Cell($pdf_ancho*.1,5,number_format($xtsubt,$dval),$lrtb,0,'R',true);
          if($xtdcto>0)
          {$docu_pdf->Cell($pdf_ancho*.07,5,number_format($xtdcto,$dval),$lrtb,0,'R',true);}
          if($xtice>0)
          {$docu_pdf->Cell($pdf_ancho*.05,5,number_format($xtice,$dval),$lrtb,0,'R',true);}
          if($xtiva>0)
          {$docu_pdf->Cell($pdf_ancho*.05,5,number_format($xtiva,$dval),$lrtb,0,'R',true);}
//           $docu_pdf->Cell($pdf_ancho*.1,5,'',$lrtb,0,'R',false);
          $docu_pdf->Cell($pdf_ancho*.1,5,number_format(abs($xtotal),$dval),$lrtb,0,'R',true);
          $docu_pdf->ln();
        ?>

			<?php}?>
			
			<?php if(mb_stristr('retc.retp',$tabla)){?>
			<?php $dval=2; ?>
			<th></th>
			<th></th>
			<th  colspan=1 style="letter-spacing: 5px;">TOTALES</th>
			<th></th>
      <?php
          $lrtb='TB';                                                                  
          $docu_pdf->SetFont($ffamilyPDF,'B',$fsizePDF-3);
          $docu_pdf->Cell($pdf_ancho*.1,5,' ',$lrtb,0,'L',true);
          $docu_pdf->Cell($pdf_ancho*.1,5,' ',$lrtb,0,'L',true);
          $docu_pdf->Cell($pdf_ancho*.3,5,'TOTALES',$lrtb,0,'C',true);
          $docu_pdf->Cell($pdf_ancho*.1,5,'',$lrtb,0,'R',true);
          $docu_pdf->Cell($pdf_ancho*.1,5,number_format(abs($xtotal),$dval),$lrtb,0,'R',true);
          $docu_pdf->Cell($pdf_ancho*.15,5,' ',$lrtb,0,'L',true);
          $docu_pdf->Cell($pdf_ancho*.15,5,' ',$lrtb,0,'L',true);
          $docu_pdf->ln();
        ?>
			<?php } ?>
			
			<?php if(mb_stristr('caja.bcos.dxco.dxpa',$tabla)){?>
			<?php $dval=2; ?>
			<th></th>
			<th  colspan=1 style="letter-spacing: 5px;">TOTAL</th>
			<?php } ?>
			<?php if(mb_stristr('dxco.dxpa',$tabla)){?>
      <th align="right"><?php echo number_format($xtcant,2); ?></th>
      <th></th>
			<?php } ?>
			
				<?php if(mb_stristr('nomi.empl',$tabla)){?>
        <?php $xtcant=0; //dias ?>
        <?php $xtotal=0; ?>
        <?php $xipuni=0; ?>
				<th></th>
        <th colspan=1 style="letter-spacing: 5px;">TOTALES</th>
				<?php if(mb_stristr('nomi.',$tabla)){?>
        <th></th>
        <th></th>
        <?php } ?>
        <th align="right">
          <?php //echo number_format($xtcant,2);?>
        </th>
        <th></th>
        <th align="right">
          <?php echo number_format($xtremun,2);?>
        </th>
        <th align="right">
          <?php echo number_format($xtdeduc,2);?>
        </th>
        <th align="right">
          <?php echo number_format($xtprovi,2);?>
        </th>
        <?php } ?>
      
      
			<th align="right" 
          style="<?php if(mb_stristr('retc.retp',$tabla)){echo 'padding-right:20px;';}?>
                 <?php if($xipuni==0){echo 'display:none;';}?>">
				<?php
					if(mb_stristr('cont',$tabla))
					{
						if(abs($xdifer)>$saldo0)
						{
							echo '<div style="color:red;">';
							echo number_format(abs($xdifer),$dval);
							echo '</div>';
						}
					}
					else{echo number_format(abs($xtotal),$dval);}
				?>
			</th>

			<th align="right" style="<?php if($xmdetalle==""){echo 'display:none;';}?>"></th>
         
      <?php if(@mb_stristr('FP15',$docu)){?>
        <th><?php echo number_format($xtpeso,2); ?></th>
      <?php } ?>
      
      <?php if(@mb_stristr('DA16',$docu)){?>
        <th style="<?php if($xtpeso==0){echo 'display:;';} ?>"><?php echo number_format($xtpeso,2); ?></th>
        <th style="<?php if($xmarcl==''){echo 'display:;';} ?>"></th>
        <th style="<?php if($costoe1==0){echo 'display:none;';} ?>"><?php echo number_format($costoe1,2); ?></th>
        <th><?php echo number_format($xtfob,2); ?></th>
        <th><?php echo number_format($xtseguro,2); ?></th>
        <th><?php echo number_format($xtflete,2); ?></th>
        <th><?php echo number_format($xtcif,2); ?></th>
        <th style="<?php if($xadva==0){echo 'display:none;';} ?>"><?php echo number_format($xtadva,2); ?></th>
        <th style="<?php if($xfodi==0){echo 'display:none;';} ?>"><?php echo number_format($xtfodi,2); ?></th>
        <th style="<?php if($xivai==0){echo 'display:none;';} ?>"><?php echo number_format($xtivai,2); ?></th>
        <th style="<?php if($xmisdi==0){echo 'display:none;';} ?>"><?php echo number_format($xtisd,2); ?></th>
        <th><?php echo number_format($xtcostol,2); ?></th>
        <th><?php echo number_format($xtcostot,2); ?></th>
      <?php } ?>
      
      <?php if($cfg_empr=='pcs1' and substr($docu,0,2)=='FC' and $xmcntn!="") {?>
        <th></th>
        <th></th>
        <th></th>
      <?php } ?>
      
      <?php if(mb_stristr('tgck.sawo.ztej',$cfg_empr)  and substr($docu,0,2)=='FC' and $xmvhcl!="") {?>
        <th></th>
      <?php } ?>

      <?php if(mb_stristr('gmny.gnya',$cfg_empr) and mb_stristr('vtas.clie.carr.prod.inve',$tabla)) {?>
        <th></th>
        <th></th>
      <?php } ?>
      
	
		</tr>
		</tfoot>
		</table>

      
    <?php if($tabla=='item' and 1==2){ ?>
      
    <?php
         $sql_pant ='select distinct clor_codigo,clor_descri,clor_hexa ';
          $sql_pant.='from item0 left join clor0 on item_clor=clor_codigo  ';
          $sql_pant.='where item_mdlo="'.msql_result($res_tra1,0,'item_mdlo').'"  ';
//           $sql_pant.='and item_codigo like "'.$codigo.'%" ';
          $sql_pant.='and item_clor>0 ';
//           $sql_pant.='group by substring(item_codigo,1,8),teki_dato ';
          $sql_pant.='order by item_clor ';
          $res_pant=msql_query($sql_pant,$link_vcrx);
    
          $numclor=msql_num_rows($res_pant);
          $widclor=round(100/$numclor,0)-1;
          $widclor=1;
//     echo $sql_pant;
    ?>  
    <?php if(msql_num_rows($res_pant)>0){?>  
      <br>
		<table id="deta_<?php echo $tabla.'_'.$cdisplay;?>" class="deta<?php echo $cdisplay;?>"
					 border="0" width="100%" cellpadding="2" cellspacing="0"
					 style="border-collapse:collapse;font-size:<?php echo $xfontsize2; ?>px;<?php echo $xfontfamily;?>">
      <caption style="border:solid 1px; font-weight:bold; background-color:<?php echo $gris1;?>;">COLORES</caption>
      <tr>
      <?php msql_data_seek($res_pant,0); ?>
      <?php while($aso_pant=msql_fetch_assoc($res_pant)){ ?>
        <td align="center" widht="<?php echo $widclor; ?>%" 
            style="border:solid 1px; font-weight:bold;background-color:<?php echo $aso_pant['clor_hexa']; ?>;">
            <?php echo msql_result($res_tra1,0,'item_mdlo').'.'.$aso_pant['clor_codigo'];?></td>
        <td width="1%">-</td>
      <?php } ?>
      </tr>
      <tr>
      <?php msql_data_seek($res_pant,0); ?>
      <?php while($aso_pant=msql_fetch_assoc($res_pant)){ ?>
        <td align="center" widht="<?php echo $widclor; ?>%" 
            style="border:solid 1px; font-weight:bold;background-color:<?php echo $aso_pant['clor_hexa']; ?>;">
            <?php echo str_replace(' ','<br>',$aso_pant['clor_descri']);?></td>
        <td width="1%"></td>
      <?php } ?>
      </tr>
      </table>      

    <?php } ?>
    <?php } ?>
      
      
    <?php if($tabla=='item'){ ?>
        <?php
             $sql_pant ='select * ';
    //           $sql_pant.='item_status ';
              $sql_pant.='from item00 left join teki0 on item_codigo=teki_item  ';
              $sql_pant.='where item_clor="00" and teki_valor>0 ';
              $sql_pant.='and item_codigo like "'.$idnum.'%" ';
              $sql_pant.='group by substring(item_codigo,1,8),teki_dato ';
              $sql_pant.='order by item_tlla,item_codigo,teki_dato ';
              $res_pant=msql_query($sql_pant,$link_vcrx);
        ?>  
        <?php
          $sql_tlla ='select distinct tlla_codigo, tlla_descri from item0 ';
          $sql_tlla.='left join tlla0 on item_tlla=tlla_codigo ';
          $sql_tlla.='left join teki0 on item_codigo=teki_item ';
          $sql_tlla.='where item_clor="00" and teki_valor>0 ';
          $sql_tlla.='and item_codigo like "'.$idnum.'%" ';
          $res_tlla=msql_query($sql_tlla,$link_vcrx);
        ?>
    <?php if(msql_num_rows($res_pant)>0){?>  
      <br>
		<table id="deta_<?php echo $tabla.'_'.$cdisplay;?>" class="deta<?php echo $cdisplay;?>"
					 border="0" width="100%" cellpadding="2" cellspacing="0"
					 style="border-collapse:collapse;font-size:<?php echo $xfontsize2; ?>px;<?php echo $xfontfamily;?>">
      <caption style="border:solid 1px; font-weight:bold; background-color:<?php echo $gris1;?>;">MEDIDAS TERMINADAS</caption>
		<thead>
 			<tr style="border-top:solid 1px; border-bottom:solid 1px; font-weight:bolder; background:<?php echo $gris1;?>;">
      <th width="15%">MEDIDAS / TALLAS</th>
            <?php while($aso_tlla=msql_fetch_assoc($res_tlla)){ ?>
            <th width="10%" onclick="sortTable(this,<?php echo $ccol++; ?>);"><?php echo substr($aso_tlla['tlla_descri'],0,6); ?></th>
            <?php } ?>
      <th>-</th>
      </tr>
    </thead>
    <tbody>
      <?php $filax=0; ?>
      <?php $filag=3; ?>
      <?php while($aso_pant=msql_fetch_assoc($res_pant)){ ?>
      <?php $filax++; ?>
      <tr style="<?php if($filax %$filag==0){echo 'border-bottom:dotted 1px;';} ?>">
        <td><?php echo $aso_pant['teki_dato']; ?></td>
            <?php msql_data_seek($res_tlla,0); ?>
            <?php while($aso_tlla=msql_fetch_assoc($res_tlla)){ ?>
            <?php $tekivalor=r_teki(substr($aso_pant['item_codigo'],0,8).'00'.$aso_tlla['tlla_codigo'],$aso_pant['teki_dato']); ?>
            <td align="right" ><?php echo number_format($tekivalor,2); ?></td>
            <?php } ?>
      </tr>
      <?php } ?>
    </tbody>
    </table>
      
    <?php } ?>  
    <?php } ?>  
		</detalle>


          <?php
             $docu_txt.=str_repeat('-',$coltxt).$eol.$eol;
             $colval=12;
             $docu_txt.=str_pad('RESUMEN ',$coltxt,$carbot,STR_PAD_BOTH).$eol;
						 if(mb_stristr('vtas.comp.clie.prov',$tabla))
						 {
               $docu_txt.= str_pad('S.TOTAL :',($coltxt-$colval),' ',STR_PAD_LEFT).str_pad(number_format($xtsubt,2),$colval,'.',STR_PAD_LEFT).$eol;
							 if($xtdcto>0)
               {$docu_txt.= str_pad('DESCUENTO :',$coltxt-$colval,' ',STR_PAD_LEFT).str_pad(number_format($xtdcto,2),$colval,'.',STR_PAD_LEFT).$eol;}
               $docu_txt.= str_pad('S.TOTAL IVA 0% :',($coltxt-$colval),' ',STR_PAD_LEFT).str_pad(number_format($xtsubtiva0,2),$colval,'.',STR_PAD_LEFT).$eol;
							 if($xpiva>0)
							 {$docu_txt.= str_pad('S.TOTAL IVA '.number_format($xpiva,0).'% :',$coltxt-$colval,' ',STR_PAD_LEFT).str_pad(number_format($xtsubtiva,2),$colval,'.',STR_PAD_LEFT).$eol;}
               if($xtice>0)
							 {$docu_txt.= str_pad('ICE :',$coltxt-$colval,' ',STR_PAD_LEFT).str_pad(number_format($xtice,2),$colval,'.',STR_PAD_LEFT).$eol;}
							 $docu_txt.=  str_pad('IVA :',$coltxt-$colval,' ',STR_PAD_LEFT).str_pad(number_format($xtiva,2),$colval,'.',STR_PAD_LEFT).$eol;
               if($xtirbp>0)
							 {$docu_txt.= str_pad('IRBP :',$coltxt-$colval,' ',STR_PAD_LEFT).str_pad(number_format($xtirbp,2),$colval,'.',STR_PAD_LEFT).$eol;}
						 }
						 $docu_txt.= str_pad('TOTAL :',$coltxt-$colval,' ',STR_PAD_LEFT).str_pad('> '.number_format(abs($xtotal),2),$colval,' =',STR_PAD_LEFT).$eol;
             $docu_txt.=$eol;
          ?>



<?php //////////////////////////////////////////////////////////	?>
<?php // PIE DE PAGINA	?>
		<footer1>
      
		<div style="font-size:25%;"><br></div>
		<table border="0" width="100%" cellpadding="2" cellspacing="0" 
           style="border-collapse:collapse;font-size:<?php echo $xfontsize; ?>px;<?php echo $xfontfamily;?>">
      <tr>
				<?php ///// PIE COLUMNA IZQUIERDA ?>
				<td width=50% valign="top">
					<?php if($notas==1){?>
					<table border="0" width="100%" cellpadding="2" cellspacing="0" 
                 style="border-collapse:collapse;font-size:<?php echo $xfontsize; ?>px;<?php echo $xfontfamily;?>">
					<tr style="background:<?php echo $gris1;?>; border-top:solid 1px; border-bottom:solid 1px; font-weight:bolder;">
						<th style="letter-spacing:5pt;">NOTAS</th>
					</tr>
          <?php if($serie_lote!=''){?>
					<tr>
						<td><?php echo $serie_lote; ?></td>
					</tr>
          <?php } ?>
					<?php if($xambi==2 and $xclaveacc!='' and mb_stristr('vtas.retp',$tabla)){?>
					<tr>
						<td style="font-size:70%;">
<!-- 						ESTA IMPRESION SOLO TIENE FINES INFORMATIVOS Y DE CONSULTA<br> -->
<!-- 						ESTA IMPRESION NO TIENE VALIDEZ TRIBUTARIA<br> -->
						Mas información en :
						<?php if($cdisplay==1) {?>
						<a target="_blank" href="https://www.sri.gob.ec/web/guest/facturacion-electronica">PORTAL S.R.I.</a> / 
						<a target="_blank" href="https://srienlinea.sri.gob.ec/comprobantes-electronicos-internet/publico/validezComprobantes.jsf">VALIDADOR S.R.I.</a>
              
						<?php } ?>
						<?php if($cdisplay==2) { echo ' www.sri.gob.ec';}?>
						</td>
					</tr>
					<?php}?>
					<?php if(mb_stristr('vare',$cfg_empr) and mb_stristr('vtas',$tabla)) {?>
					<tr>
						<td>
							<b>PARA DEPOSITO O TRANSFERENCIA:</b>
							<br>BCO. PRODUBANCO
							<br>CTA. AHORROS # 1800 519 3308
							<br>
							<br>BCO. PACIFICO
							<br>CTA. CORRIENTE # 556 7424
							<br>
						</td>
					</tr>
					<?php } ?>
					<?php if(mb_stristr('ptsa',$cfg_empr) and mb_stristr('vtas',$tabla)) {?>
					<tr>
						<td>
							<b>PARA DEPOSITO O TRANSFERENCIA:</b>
							<br>BCO. PRODUBANCO
							<br>CTA. AHORROS # 1200 665 4245
							<br>
						</td>
					</tr>
					<?php } ?>
					<?php if(mb_stristr('ecgl.',$cfg_empr) and mb_stristr('clie',$tabla)) {?>
					<tr>
						<td>
							FORMA DE PAGO : 70% A LA ACEPTACION DE ESTA PROFORMA
							<br>SALDO CONTRA ENTREGA
							<br>FECHA DE ENTREGA : 5 DIAS LABORABLES
						</td>
					</tr>
					<?php } ?>
					<?php if(mb_stristr('gmny.gnya',$cfg_empr) and mb_stristr('clie',$tabla)) { ?>
					<tr>
						<td>
							<b>CUENTAS PARA DEPOSITO O TRANSFERENCIA:</b>
							<br>BCO. PICHINCHA - (Germania Zambrano M.)
<!-- 							<br>CTA. AHORROS # 448 268 2100 -->
							<br>CTA. AHORROS # 220 256 7299
<!-- 							<br> -->
<!--               <br>BCO. BOLIVARIANO - (Germania Zambrano M.) -->
<!-- 							<br>CTA. AHORROS # 002 129 8665  -->
						</td>
					</tr>
					<?php } ?>
					<?php if(mb_stristr('gmny',$cfg_empr) and mb_stristr('prod',$tabla)) {?>
					<tr>
						<td>
							EL PRODUCTO DEBE SER ENTREGADO EN LA FECHA INDICADA
							<br>HABRA UNA PENALIZACION POR CADA DIA DE RETRASO
						</td>
					</tr>
					<?php } ?>
					<?php if(mb_stristr('mzlj',$cfg_empr) and mb_stristr('clie',$tabla) and mb_stristr('PC10',$docu)) {?>
					<tr>
						<td style="font-size:120%;font-weight:bold;">
              <br>
							*** ESTE COMPROBANTE NO ES UNA FACTURA ***
						</td>
					</tr>
					<?php } ?>
					</table>
					<div style="height:10mm;"></div>
					<?php } ?>
					<?php if($obser==1){?>
					<table border="0" width="100%" cellpadding="2" cellspacing="0" 
                 style="border-collapse:collapse;font-size:<?php echo $xfontsize; ?>px;<?php echo $xfontfamily;?>">
					<tr style="background:<?php echo $gris1;?>; border-top:solid 1px; border-bottom:solid 1px; font-weight:bolder;">
						<th style="letter-spacing:5pt;">OBSERVACIONES</th>
					</tr>
					<?php if(mb_stristr('gmny',$cfg_empr) and mb_stristr('prod',$tabla)) {?>
					<tr style="border-bottom:solid 1px; height:8mm;">
						<td><br></td>
					</tr>
					<tr style="border-bottom:solid 1px; height:8mm;">
						<td><br></td>
					</tr>
					<?php } ?>
					</table>
					<div style="height:10mm;"></div>
					<?php } ?>

        </td>

				<?php ///// PIE COLUMNA DERECHA ?>
				<td width=50% valign="top">
					<table border="0" width="100%" cellpadding="2" cellspacing="0" 
                 style="border-collapse:collapse;font-size:<?php echo $xfontsize; ?>px;<?php echo $xfontfamily;?>">
					<?php if(!mb_stristr('guia.cont',$tabla)){?>
					<tr>
						<td align="right" style="font-weight:bolder;">
						<?php if($xtotal!=0 and $xipuni==1){echo 'SON : '.num2let(round(abs($xtotal),2));}?>
						</td>
					</tr>
					<?php } ?>
					</table>
				</td>
			</tr>

			<?php
        if(substr($docu,0,2)!='GR')
        {
          $docu_pdf->ln();
          $docu_pdf->SetFont($ffamilyPDF,'B',$fsizePDF-2);
          $docu_pdf->Cell(0,5,'SON : '.num2let(round(abs($xtotal),2)),'',0,'R',false);
          $docu_pdf->ln();
        }
      ?>
      <?php
          $docu_txt.=str_pad('NOTAS ',$coltxt,$carbot,STR_PAD_BOTH).$eol;
//           $docu_txt.=str_repeat('-',$coltxt).$eol;
          if($claveacc!='')
          {$docu_txt.='DESCARGUE SU COMPROBANTE ELECTRONICO EN : ';
          $docu_txt.=$cfg_empr.'.vcrxol.com';}
          $docu_txt.=$eol;                                                        
      ?>
    </table>
		</footer1>


<?php //if(mb_stristr('vtas.clie.retp.',$tabla) or mb_stristr('',substr($docu,0,2))){ ?>
<?php if($firmas==1){ ?>
<?php if($cdisplay==2){ ?>
	<table border="0" width="100%" cellpadding="2" cellspacing="0" 
         style="border-collapse:collapse;font-size:<?php echo $xfontsize; ?>px;<?php echo $xfontfamily;?>">
		<tr style="height:10mm;"></tr>
		<tr style="height:10mm; font-size:100%;">

      <?php if($formato<=1){?>
			<?php if(mb_stristr('cont',$tabla)){?>
				<td></td>
				<td align="center" valign="top" style="width:40mm; border-top:solid 1px;">FIRMA AUTORIZADA</td>
				<td></td>
			<?php } ?>
			<?php if(mb_stristr('vtas.bcos.caja',$tabla)){?>
				<td></td>
				<td align="center" valign="top" style="width:40mm; border-top:solid 1px;">FIRMA AUTORIZADA</td>
				<td></td>
				<td align="center" valign="top" style="width:40mm; border-top:solid 1px;">RECIBI CONFORME</td>
				<td></td>
			<?php } ?>
			<?php if(mb_stristr('guia',$tabla)){?>
				<td></td>
				<td align="center" valign="top" style="width:40mm; border-top:solid 1px;">FIRMA AUTORIZADA</td>
				<td></td>
				<td align="center" valign="top" style="width:40mm; border-top:solid 1px;">CONDUCTOR</td>
				<td></td>
				<td align="center" valign="top" style="width:40mm; border-top:solid 1px;">RECIBI CONFORME</td>
				<td></td>
			<?php } ?>
			<?php if(mb_stristr('clie',$tabla)){?>
				<td></td>
				<td align="center" valign="top" style="width:40mm; border-top:solid 1px;">FIRMA AUTORIZADA</td>
				<td></td>
				<td></td>
				<td></td>
			<?php } ?>
			<?php if(mb_stristr('inve',$tabla) and substr($docu,0,2)=='IB'){?>
				<td></td>
				<td align="center" valign="top" style="width:40mm; border-top:solid 1px;">RECIBIDO POR</td>
				<td></td>
				<td align="center" valign="top" style="width:40mm; border-top:solid 1px;">REVISADO POR</td>
				<td></td>
			<?php } ?>
			<?php if(mb_stristr('inve',$tabla) and substr($docu,0,2)=='EB'){?>
				<td></td>
				<td align="center" valign="top" style="width:40mm; border-top:solid 1px;">ELABORADO POR</td>
				<td></td>
				<td align="center" valign="top" style="width:40mm; border-top:solid 1px;">REVISADO POR</td>
				<td></td>
				<td align="center" valign="top" style="width:40mm; border-top:solid 1px;">RECIBIDO POR</td>
				<td></td>
			<?php } ?>
			<?php if(mb_stristr('prod',$tabla)){?>
				<td></td>
				<td align="center" valign="top" style="width:40mm; border-top:solid 1px;">ENTREGADO POR</td>
				<td></td>
				<td align="center" valign="top" style="width:40mm; border-top:solid 1px;">RECIBIDO POR</td>
				<td></td>
				<td align="center" valign="top" style="width:40mm; border-top:solid 1px;">PRODUCTO TERMINADO</td>
				<td></td>
			<?php } ?>
			<?php if(mb_stristr('retp',$tabla)){?>
				<td></td>
				<td align="center" valign="top" style="width:40mm; border-top:solid 1px;">AGENTE DE RETENCION</td>
				<td></td>
				<td align="center" valign="top" style="width:40mm; border-top:solid 1px;">SUJETO RETENIDO</td>
				<td></td>
			<?php } ?>
			<?php }else{ ?>
				<td></td>
				<td align="center" valign="top" style="width:40mm; border-top:solid 1px;">FIRMA AUTORIZADA</td>
				<td></td>
			<?php } ?>
		</tr>		
	</table>
<?php } ?>
<?php } ?>

<?php $pagare1= ''; ?>
<?php $pagare2= ''; ?>
<?php
 if(mb_stristr('mzlj.demo',$cfg_empr))
 { 
   $pagare1.= 'Debo(emos) y Pagaré(mos) incondicionalmente a la orden de '.r_fiel('enti',$cfg_ruc).' en el lugar y fecha que se estime conveniente'; 
   $pagare1.= ' el valor total expresado en este documento, en caso de mora, reconoceré el interés permitido por la ley <br>'; 
   $pagare1.= 'Autorizo(amos) expresa e irrevocablemente a '.r_fiel('enti',$cfg_ruc).' para que obtenga cuantas veces sean necesarias, '; 
   $pagare1.= 'de cualquier fuente de información, incluidos burós de crédito, mi informacion de riesgos crediticios, de igual forma '; 
   $pagare1.= r_fiel('enti',$cfg_ruc).' queda expresamente autorizado para que pueda transferir o entregar dicha información a los burós de crédito'; 
   $pagare1.= ' y/o a la Central de Riesgos si fuera pertinente.'; 

   $pagare2.= 'Estimado cliente sírvase enviarnos el comprobante de retención dentro de los cinco primeros días de recibida la presente Factura,'; 
   $pagare2.= ' caso contrario no se aceptará el descuento por el monto de la retención. '; 
   $pagare2.= ' Art.50 Regimen Tributario Interno'; 
 }
?>


<?php if(substr($docu,0,2)=='FC' and $formato==1 and $pagare1.$pagare2!=''){ ?>
      <table border="0" width="100%" cellpadding="2" cellspacing="0" 
             style="border-collapse:collapse;font-size:<?php echo $xfontsize; ?>px;<?php echo $xfontfamily;?>">
          <tr style="font-size:60%; border-top:solid 1px; border-bottom:solid 1px; text-align:justify; vertical-align:top;">
            <td width="60%" style="">
            <?php echo $pagare1;?>
            </td>
            <td width="5%"  >
            </td>
            <td width="35%"  >
            <?php echo $pagare2;?>
            </td>
          </tr>
        </table>

    <br>
<?php } ?>

	<table border="0" width="100%" cellpadding="2" cellspacing="0" 
         style="border-collapse:collapse;font-size:<?php echo $xfontsize; ?>px;<?php echo $xfontfamily;?>;">
			<tr style="font-size:50%; border-top:solid 1px; border-bottom:solid 1px; font-weight:bolder; background:<?php echo $gris1;?>;">
				<td width="33%">
				<?php echo 'ID:'.$idnum;?>
				</td>
				<td width="34%" align="center" style="font-size:150%">
<!-- 				<a target="_blank" href="https://www.vcrxol.com">WWW.VCRXOL.COM - SISTEMAS EN LINEA</a> -->
				</td>
				<td width="33%" align="right" >
				<?php if($user_codigo!="" and $destino!='mail'){ ?>
				<?php echo 'IMPRESO POR: ';?>
				<?php //echo r_fiel('enti',$user_cedula,'nom1').' '.r_fiel('enti',$user_cedula,'ape1');?>
				<?php echo r_fiel('user',$user_codigo);?>
				<?php echo '<br>'; ?>
				<?php } ?>
				<?php echo date('d/M/y H:i:s');?>
				</td>
			</tr>
		</table>
        <?php 
          $docu_pdf->ln();
          $docu_pdf->ln();
          $docu_pdf->SetFont($ffamilyPDF,'B',$fsizePDF-2);
          $docu_pdf->SetFontSize($fsizePDF-8);
          $docu_pdf->Cell($pdf_ancho*.5,5,'ID:'.$idnum,'TB',0,'L',false);
          $docu_pdf->Cell($pdf_ancho*.5,5,date('d/M/y H:i:s'),'TB',0,'R',false);
          $docu_pdf->ln();
        ?>
        <?php
             $docu_txt.=str_repeat('-',$coltxt).$eol;
//              $docu_txt.= msql_result($res_tra1,0,'iuser');
             $docu_txt.= date('d/M/y');
             $docu_txt.= str_pad(date('H:i:s'),$coltxt-9,' ',STR_PAD_LEFT);
             $docu_txt.= $eol;
             $docu_txt.= str_repeat('-',$coltxt);
//              $docu_txt.='<p class="saltodepagina" /></p>';
                                                        
        ?>		
  <?php	if(mb_stristr('PF.OP.PC',substr($docu,0,2)) and $cfg_empr=='ecgl'){ecgl_dise1($docu,$idnum);}?>

		
	</div>	
	<br>
	<?php $xfontsize=$printsize; ?>
	<?php } ?>

	<?php // if($destino=='mail'){ ?>
	<?php	//echo '</html>'; ?>
	<?php//  } ?>
	
<?php //////////////////////////////////////////////////////////	?>
<?php //echo date('H:i:s'); ?>

<?php	
$docuhtml = ob_get_clean(); 
// $docuhtml = alltrim($docuhtml);
if(!mb_stristr('pos.txt.mail',$destino))  
{$docuhtml = limpiahtml($docuhtml);}
?>
<?php //if($cfg_empr=='ecgl' and mb_stristr('FC',substr($docu,0,2))) {$docuhtml=str_replace('<tr>','<tr style="font-weight:bolder;">',$docuhtml);} ?>
<?php
  
// if($destino=='mail')
if($formato==1 or $claveacc!='' )
{
  $subdce=mk_subdce($claveacc);
  @unlink($rutace.$subdce.$xclaveacc.'.pdf');

//   echo $rutace.$subdce.$xclaveacc.'.pdf';
//   if(mb_stristr('P.J',$tiporuc))
//   {$docu_pdf->Output('F',$rutace.$subdce.$xclaveacc.'.pdf',true);}
  
}
  
if(mb_stristr('pos.txt',$destino))
{
//   file_put_contents($rutace.$subdce.$claveacc.'.txt',$docu_txt);
//   $docu_txt.='<p class="saltodepagina" /></p>';
  return $docu_txt;
}  
// if(substr($destino,0,3)=='pdf'){return file_get_contents($rutace.$subdce.$xclaveacc.'.pdf');} 
//   echo '***'.$destino;
// if(substr($destino,0,3)=='pdf'){return 'AAA';} 
// if(substr($destino,0,3)=='pdf'){return $docu_pdf;}  
  
if($destino=='mail' and ($docupdf==1 or $entipdf==1))	
{
	file_put_contents($rutadoc.$docu_idnum.'.htm',$docuhtml);
	if($xclaveacc!="")
	{if(!file_exists($filepdf) or $overpdf==1 ){pdf_sri($docu,$idnum);}}
}	
else	
{file_put_contents($rutadoc.$docu_idnum.'.html',$docuhtml);}	

//       pdf_sri($docu,$idnum);
  

return $docuhtml;	
}
?>



<?php
function prnt_docucair($pdocu,$pidnum,$destino='screen')
{
	include('../_cfg/config.php');
     
     $rete=tot_rpro($pdocu,$pidnum);
     if($rete['rta']!=0 and $rete['iva']!=0){return;}
     
     $tabla=r_fiel('docu',$pdocu,'tabla');
     $xfontsize=12;
     $gris1='gainsboro';

     ob_start();
     $sql_comp ='select * ';
     $sql_comp.='from comp12 ';
     $sql_comp.='where docu="'.$pdocu.'" ';
     $sql_comp.='and idnum1="'.$pidnum.'" ';
     $sql_comp.='group by cair ';
     
     $sql_total=sql_total($tabla);
     $sql_comp=str_replace('*','*,'.$sql_total,$sql_comp);
     $res_comp=msql_query($sql_comp,$link_vcrx);
?>     
<?php     
  if(msql_num_rows($res_comp)!=0)
  {
?>
    <table id="" border="0" width="100%" cellpadding="0" cellspacing="0" 
           style="border-collapse:collapse;font-size:<?php echo $xfontsize; ?>px;<?php echo $xfontfamily;?>">
 			<tr style="border-top:solid 1px; border-bottom:solid 1px; font-weight:bolder; background:<?php echo $gris1;?>;">
            <th colspan="10">RETENC.</th>
        </tr>
     </table>
    <table id="tabcair" border="0" width="100%" cellpadding="0" cellspacing="0" 
           style="border-collapse:collapse;font-size:<?php echo $xfontsize; ?>px;<?php echo $xfontfamily;?>">
    <thead>
	<tr style="border-top:solid 1px; border-bottom:solid 1px; font-weight:bolder; background:<?php echo $gris1;?>;">
      <th onclick="sortTable(this,<?php echo $ccol++; ?>);" width="40%">DESCRIPCION</th>
      <th onclick="sortTable(this,<?php echo $ccol++; ?>);">CAIR</th>
      <th onclick="sortTable(this,<?php echo $ccol++; ?>,'N');">BASE RTA.</th>
      <th onclick="sortTable(this,<?php echo $ccol++; ?>,'N');">% RTA.</th>
      <th onclick="sortTable(this,<?php echo $ccol++; ?>,'N');">RET.RTA.</th>
      <th>_</th>
      <th onclick="sortTable(this,<?php echo $ccol++; ?>,'N');">BASE IVA.</th>
      <th onclick="sortTable(this,<?php echo $ccol++; ?>,'N');">% IVA</th>
      <th onclick="sortTable(this,<?php echo $ccol++; ?>,'N');">RET.IVA</th>
      </tr>
    </thead>
    <tbody>
    <?php //msql_data_seek($res_comp,0);?>
    <?php while($aso_comp=@msql_fetch_assoc($res_comp)){ ?>
     <?php 
          $baserta= $aso_comp['stsubt']-$aso_comp['stdcto']; 
          $retrta = ($aso_comp['stsubt']-$aso_comp['stdcto'])*$aso_comp['cair_porc']/100; 
          $totbaserta=$totbaserta +$baserta; 
          $totretrta =$totretrta +$retrta; 
                                                     
          $baseiva= $aso_comp['stiva']; 
          $retiva = ($aso_comp['stiva'])*$aso_comp['priva']/100; 
          $totbaseiva=$totbaseiva +$baseiva; 
          $totretiva =$totretiva +$retiva; 
     ?>
      <tr>
      <td align="center"><?php echo $aso_comp['cair_descri']; ?></td>
      <td align="center"><?php echo $aso_comp['cair']; ?></td>
      <td align="right"><?php echo number_format($baserta,2); ?></td>
      <td align="center"><?php echo $aso_comp['cair_porc']; ?></td>
      <td align="right"><?php echo number_format($retrta,2).''; ?></td>
      <td></td>
           
      <td align="right"><?php echo number_format($baseiva,2); ?></td>
      <td align="center"><?php echo $aso_comp['priva']; ?></td>
      <td align="right"><?php echo number_format($retiva,2).''; ?></td>
      </tr>
    <?php } ?>  
    </tbody>
    <tfoot>
			<tr style="border-top:solid 1px; border-bottom:solid 1px; font-weight:bolder; background:<?php echo $gris1;?>;">
      <th>TOTAL</th>
      <th></th>
      <th align="right"> <?php echo number_format($totbaserta,2);?> </th>
      <th></th>
      <th align="right"> <?php echo number_format($totretrta,2);?> </th>
      <th></th>
      <th align="right"> <?php echo number_format($totbaseiva,2);?> </th>
      <th></th>
      <th align="right"> <?php echo number_format($totretiva,2);?> </th>
      </tr>
    </tfoot>
    </table>
    <br>  
<?php  } ?>
<?php  
  $docucair = ob_get_clean(); 
//   $docurela=alltrim($docurela);
  $docucair=limpiahtml($docucair);
  return $docucair;
     
}
?>



<?php
function prnt_docur($pdocu,$pptoe,$pnumero,$penti,$destino='screen')
{
	include('../_cfg/config.php');
  $xfontsize=12;
  $gris1='gainsboro';
  
  ob_start();
  
  if(substr($pdocu,0,2)=='FP'){$tret='retp12'; $tdoc='comp12';}
  if(substr($pdocu,0,2)=='FC'){$tret='retc12'; $tdoc='vtas12';}
  if(substr($pdocu,0,2)=='AP'){$tret='retp12'; $tdoc='dxpa12';}
  if(substr($pdocu,0,2)=='AC'){$tret='retc12'; $tdoc='dxco12';}
  
//   $xwhere=' where docu="'.$pdocu.'" and ptoe="'.$pptoe.'" and numero="'.$pnumero.'" and enti="'.$penti.'" ';
  $xwhere=' where docu="'.$pdocu.'" and ptoe="'.$pptoe.'" and numero="'.$pnumero.'" and enti like "'.substr($penti,0,10).'%" ';
  
  $sql_tdoc='select sum(total) as total from '.$tdoc.$xwhere;
  $res_tdoc=msql_query($sql_tdoc,$link_vcrx);
  $total=msql_result($res_tdoc,0,'total');
  
//   $xwhere=' where docum="'.$pdocu.'" and ptoem="'.$pptoe.'" and numer="'.$pnumero.'" and enti="'.$penti.'" and status!="O" ';
//   $xwhere=' where docum="'.$pdocu.'" and ptoem="'.$pptoe.'" and numer="'.$pnumero.'" and enti="'.$penti.'" and status!="O" ';
  $xwhere=' where docum="'.$pdocu.'" and ptoem="'.$pptoe.'" and numer="'.$pnumero.'" and enti like "'.substr($penti,0,10).'%" and status!="O" ';
  $xwhere.=' and docu not like "AC10%" ';
  $xwhere.=' and docu not like "AP10%" ';
  $xwhere.=' and docu not like "EC%" ';
  $xwhere.=' and docu not like "F%" ';
  $xwhere.=' and docu not like "XC00" ';
  $xwhere.=' and docu not like "XP00" ';
  
  $sql_rete='select * from '.$tret.$xwhere.' order by fecha,idnum1';
  $res_rete=msql_query($sql_rete,$link_vcrx);
  
  $sql_caja='select * from caja12 '.$xwhere.' order by fecha,idnum1';
  $res_caja=msql_query($sql_caja,$link_vcrx);
  
  $sql_bcos='select * from bcos12 '.$xwhere.' order by fecha,idnum1';
  $res_bcos=msql_query($sql_bcos,$link_vcrx);
  
  $sql_dxco='select * from dxco12 '.$xwhere.' order by fecha,idnum1';
  $res_dxco=msql_query($sql_dxco,$link_vcrx);
  
  $sql_dxpa='select * from dxpa12 '.$xwhere.' order by fecha,idnum1';
  $res_dxpa=msql_query($sql_dxpa,$link_vcrx);
  
  $xwhere=str_replace('docum','todocu',$xwhere);
  $xwhere=str_replace('ptoem','toptoe',$xwhere);
  $xwhere=str_replace('numer','tonume',$xwhere);
  $sql_ncre='select * from '.$tdoc.' '.$xwhere.' order by fecha,idnum1';
  $res_ncre=msql_query($sql_ncre,$link_vcrx);
  
//   explain_sql($sql_ncre);
  
//   echo $sql_caja;
//   echo $sql_bcos;
//   $sql_retc='select * from retc12 where docum="'.$docu.'" and ptoem="'.$ptoe.'" and numer="'.$xnumero.'" and enti="'.$xenti.'" order by fecha,idnum1';
//   $res_retc=msql_query($sql_retc,$link_vcrx);
?>
<?php
  if(msql_num_rows($res_rete)!=0 
     or msql_num_rows($res_caja)!=0
     or msql_num_rows($res_bcos)!=0
     or msql_num_rows($res_ncre)!=0
     or msql_num_rows($res_dxco)!=0
     or msql_num_rows($res_dxpa)!=0
    )
  {
?>
    <table id="" border="0" width="100%" cellpadding="0" cellspacing="0" 
           style="border-collapse:collapse;font-size:<?php echo $xfontsize; ?>px;<?php echo $xfontfamily;?>">
 			<tr style="border-top:solid 1px; border-bottom:solid 1px; font-weight:bolder; background:<?php echo $gris1;?>;">
            <th colspan="10">ABONOS</th>
        </tr>
     </table>
    <table id="tabdocua" border="0" width="100%" cellpadding="0" cellspacing="0" 
           style="border-collapse:collapse;font-size:<?php echo $xfontsize; ?>px;<?php echo $xfontfamily;?>">
    <thead>
			<tr style="border-top:solid 1px; border-bottom:solid 1px; font-weight:bolder; background:<?php echo $gris1;?>;">
      <th onclick="sortTable(this,<?php echo $ccol++; ?>);">FECHA</th>
      <th onclick="sortTable(this,<?php echo $ccol++; ?>);">DOCUMENTO</th>
      <th onclick="sortTable(this,<?php echo $ccol++; ?>);">NUMERO</th>
      <th onclick="sortTable(this,<?php echo $ccol++; ?>,'N');">VALOR</th>
      <th onclick="sortTable(this,<?php echo $ccol++; ?>);">CAIR</th>
      <th onclick="sortTable(this,<?php echo $ccol++; ?>,'N');">BASE</th>
      <th onclick="sortTable(this,<?php echo $ccol++; ?>,'N');">%</th>
      <th onclick="sortTable(this,<?php echo $ccol++; ?>);">DETALLE</th>
      </tr>
    </thead>
    <tbody>
    <?php $abono=0;?>
    <?php while($aso_deta=@msql_fetch_assoc($res_rete)){ ?>
      <tr>
      <td align="center"><?php echo $aso_deta['fecha']; ?></td>
      <td align="center"><?php echo $aso_deta['docu_descri']; ?></td>
      <td align="center">
        <a href="<?php echo 'https://'.$cfg_empr.'.vcrxol.com/?prnt=1&docu='. $aso_deta['docu'].'&idnum='. $aso_deta['idnum1'].'&formato='.$formato;?>"  target="_blank" >
        <?php echo $aso_deta['ptonumero']; ?>
        </a>
      </td>
      <td align="right"><?php echo number_format(abs($aso_deta['total']),2); ?></td>
      <td align="center"><?php echo $aso_deta['cair']; ?></td>
      <td align="center"><?php echo number_format(abs($aso_deta['cant']),2).''; ?></td>
      <td align="center"><?php echo number_format(abs($aso_deta['puni']),2).''; ?></td>
      </tr>
      <?php $abono+=abs($aso_deta['total']); ?>
    <?php } ?>  
    <?php while($aso_deta=@msql_fetch_assoc($res_bcos)){ ?>
      <tr>
      <td align="center"><?php echo $aso_deta['fecha']; ?></td>
      <td align="center"><?php echo $aso_deta['docu_descri']; ?></td>
      <td align="center">
        <a href="<?php echo 'https://'.$cfg_empr.'.vcrxol.com/?prnt=1&docu='. $aso_deta['docu'].'&idnum='. $aso_deta['idnum1'].'&formato='.$formato;?>"  target="_blank" >
        <?php echo $aso_deta['ptonumero']; ?>
        </a>
      </td>      
           <?php $xabono=abs($aso_deta['total']); ?>
           <?php
               if(substr($aso_deta['docum'],0,2)=='FP' and substr($aso_deta['docu'],0,2)=='DB')
               {$xabono=abs($aso_deta['total'])*(-1);}
           ?>
           <?php
               if(substr($aso_deta['docum'],0,2)=='FC' and substr($aso_deta['docu'],0,2)=='PR')
               {$xabono=abs($aso_deta['total'])*(-1);}
           ?>
      <td align="right"><?php echo number_format($xabono,2); ?></td>
      <td align="center"><?php //echo $aso_deta['cair']; ?></td>
      <td align="center"><?php //echo number_format(abs($aso_deta['cant']),2).''; ?></td>
      <td align="center"><?php //echo number_format(abs($aso_deta['puni']),2).''; ?></td>
      <td align="center"><?php echo $aso_deta['detalle'].' - '.$aso_deta['benefic']; ?></td>
      </tr>
      <?php $abono+=$xabono; ?>
    <?php } ?>  
    <?php while($aso_deta=@msql_fetch_assoc($res_caja)){ ?>
      <tr>
      <td align="center"><?php echo $aso_deta['fecha']; ?></td>
      <td align="center"><?php echo $aso_deta['docu_descri']; ?></td>
      <td align="center">
        <a href="<?php echo 'https://'.$cfg_empr.'.vcrxol.com/?prnt=1&docu='. $aso_deta['docu'].'&idnum='. $aso_deta['idnum1'].'&formato='.$formato;?>"  target="_blank" >
        <?php echo $aso_deta['ptonumero']; ?>
        </a>
      </td>      
      <td align="right"><?php echo number_format(abs($aso_deta['total']),2); ?></td>
      <td align="center"><?php //echo $aso_deta['cair']; ?></td>
      <td align="center"><?php //echo number_format(abs($aso_deta['cant']),2).''; ?></td>
      <td align="center"><?php //echo number_format(abs($aso_deta['puni']),2).''; ?></td>
      <td align="center"><?php echo $aso_deta['detalle'].' - '.$aso_deta['benefic']; ?></td>
      </tr>
      <?php $abono+=abs($aso_deta['total']); ?>
    <?php } ?>  
    <?php while($aso_deta=@msql_fetch_assoc($res_ncre)){ ?>
      <tr>
      <td align="center"><?php echo $aso_deta['fecha']; ?></td>
      <td align="center"><?php echo $aso_deta['docu_descri']; ?></td>
      <td align="center">
        <a href="<?php echo 'https://'.$cfg_empr.'.vcrxol.com/?prnt=1&docu='. $aso_deta['docu'].'&idnum='. $aso_deta['idnum1'].'&formato='.$formato;?>"  target="_blank" >
        <?php echo $aso_deta['ptonumero']; ?>
        </a>
      </td>      
      <td align="right"><?php echo number_format(abs($aso_deta['total']),2); ?></td>
      <td align="center"><?php //echo $aso_deta['cair']; ?></td>
      <td align="center"><?php //echo number_format(abs($aso_deta['cant']),2).''; ?></td>
      <td align="center"><?php //echo number_format(abs($aso_deta['puni']),2).''; ?></td>
      <td align="center"><?php //echo $aso_deta['detalle'].' - '.$aso_deta['benefic']; ?></td>
      </tr>
      <?php $abono+=abs($aso_deta['total']); ?>
    <?php } ?>  
    <?php while($aso_deta=@msql_fetch_assoc($res_dxco)){ ?>
      <tr>
      <td align="center"><?php echo $aso_deta['fecha']; ?></td>
      <td align="center"><?php echo $aso_deta['docu_descri']; ?></td>
      <td align="center">
        <a href="<?php echo 'https://'.$cfg_empr.'.vcrxol.com/?prnt=1&docu='. $aso_deta['docu'].'&idnum='. $aso_deta['idnum1'].'&formato='.$formato;?>"  target="_blank" >
        <?php echo $aso_deta['ptonumero']; ?>
        </a>
      </td>      <td align="right"><?php echo number_format(($aso_deta['total'])*(-1),2); ?></td>
      <td align="center"><?php //echo $aso_deta['cair']; ?></td>
      <td align="center"><?php //echo number_format(abs($aso_deta['cant']),2).''; ?></td>
      <td align="center"><?php //echo number_format(abs($aso_deta['puni']),2).''; ?></td>
      <td align="center"><?php echo $aso_deta['detalle'].' - '.$aso_deta['benefic']; ?></td>
      </tr>
      <?php $abono+=($aso_deta['total'])*(-1); ?>
    <?php } ?>  
    <?php while($aso_deta=@msql_fetch_assoc($res_dxpa)){ ?>
      <tr>
      <td align="center"><?php echo $aso_deta['fecha']; ?></td>
      <td align="center"><?php echo $aso_deta['docu_descri']; ?></td>
      <td align="center">
        <a href="<?php echo 'https://'.$cfg_empr.'.vcrxol.com/?prnt=1&docu='. $aso_deta['docu'].'&idnum='. $aso_deta['idnum1'].'&formato='.$formato;?>"  target="_blank" >
        <?php echo $aso_deta['ptonumero']; ?>
        </a>
      </td>      <td align="right"><?php echo number_format(($aso_deta['total'])*(-1),2); ?></td>
      <td align="center"><?php //echo $aso_deta['cair']; ?></td>
      <td align="center"><?php //echo number_format(abs($aso_deta['cant']),2).''; ?></td>
      <td align="center"><?php //echo number_format(abs($aso_deta['puni']),2).''; ?></td>
      <td align="center"><?php echo $aso_deta['detalle'].' - '.$aso_deta['benefic']; ?></td>
      </tr>
      <?php $abono+=($aso_deta['total'])*(-1); ?>
    <?php } ?>  
    </tbody>
    <tfoot>
			<tr style="border-top:solid 1px; border-bottom:solid 1px; font-weight:bolder; background:<?php echo $gris1;?>;">
      <th></th>
      <th></th>
      <th>TOTAL</th>
      <th align="right"><?php echo number_format($abono,2);?></th>
      <th></th>
      <th></th>
      <th></th>
      <th align="right">SALDO : <?php echo number_format($total-$abono,2);?> </th>
      </tr>
    </tfoot>
    </table>
    <br>  
<?php  } ?>
<?php  
  $docurela = ob_get_clean(); 
//   $docurela=alltrim($docurela);
  $docurela=limpiahtml($docurela);
  return $docurela;
  
}
?>


<?php
function prnt_docui($pdocu,$pptoe,$pnumero,$penti,$destino='screen')
{
//      return;
	include('../_cfg/config.php');
  $xfontsize=12;
  $gris1='gainsboro';
  
// echo '*/*/*/*/*';     
     
  ob_start();
  $docuo='----';
  if(!mb_stristr('FC.FP.NC.DA',substr($pdocu,0,2))){return;}
  if(substr($pdocu,0,2)=='FP'){$docui='IB10'; $docuo='comp';}
  if(substr($pdocu,0,2)=='FC'){$docui='EB10'; $docuo='vtas';}
  if(substr($pdocu,0,2)=='NC'){$docui='IB12'; $docuo='vtas';}
  if(substr($pdocu,0,2)=='DA'){$docui='IB15'; $docuo='prov';}
     
     if(substr($pdocu,0,2)=='FC')
     {
          $autocon=r_fiel('ptov',$pptoe,'autocon');
          if($autocon==1){$docui='EB19';$penti='';}
     }
  
       $sql_docuo='select *,sum(cant) as stcant from '.$docuo.'12 where docu="'.$pdocu.'" and numero="'.$pnumero.'" ';
       $sql_docuo='select *,sum(cant) as stcant from '.$docuo.'12 where docu="'.$pdocu.'" and ptoe="'.$pptoe.'" and numero="'.$pnumero.'" ';
       if($docuo=='comp')
       {$sql_docuo.='and enti="'.$penti.'" ';}
       $sql_docuo.='and status!="O"';
     
//      echo '=== '.$sql_docuo;
       
       $res_docuo=msql_query($sql_docuo,$link_vcrx);
       $stcant=msql_result($res_docuo,0,'stcant');
     
  if($docui=='IB15')
  {
       $pnumero=msql_result($res_docuo,0,'impor');
       
  }
//        echo '*/*/*/*/'.$sql_docuo.$stcant;
  
  $sql_inve='select * from inve12';
  $sql_inve.=' where status!="O" ';
  $sql_inve.=' and docu = "'.$docui.'"  ';
  if($docui=='IB15')
  {$sql_inve.=' and impor="'.$pnumero.'"  ';}
  else
  {
  $sql_inve.=' and numfac="'.$pnumero.'"  ';
  $sql_inve.=' and enti like "'.substr($penti,0,10).'%" ';
  }
  $sql_inve.=' order by fecha,idnum1,item ';
  $res_inve=msql_query($sql_inve,$link_vcrx);
//   $total=msql_result($res_tdoc,0,'total');
// echo '*/*/*/'.$sql_inve;
     //    explain_sql($sql_inve);
?>

<?php
if(msql_num_rows($res_inve)!=0){
?>
<?php if($docui=='IB15'){ ?>
<p class="saltodepagina" /></p>
<?php } ?>
<?php $ccol=0; ?>
     <table border="0" width="100%" cellpadding="0" cellspacing="0" 
            style="border-collapse:collapse;font-size:<?php echo $xfontsize; ?>px;<?php echo $xfontfamily;?>">
 	<tr style="border-top:solid 1px; border-bottom:solid 1px; font-weight:bolder; background:<?php echo $gris1;?>;">
     <th colspan="10">BODEGAS</th>
     </tr>
     </table>
     <table id="tabdocui" border="0" width="100%" cellpadding="0" cellspacing="0" 
            style="border-collapse:collapse;font-size:<?php echo $xfontsize; ?>px;<?php echo $xfontfamily;?>">
     <thead>
 			<tr style="border-top:solid 1px; border-bottom:solid 1px; font-weight:bolder; background:<?php echo $gris1;?>;">
       <th width="10%" onclick="sortTable(this,<?php echo $ccol++; ?>);">FECHA</th>
       <th width="5%" onclick="sortTable(this,<?php echo $ccol++; ?>);">DOCU</th>
       <th width="10%" onclick="sortTable(this,<?php echo $ccol++; ?>);">NUMERO</th>
       <th onclick="sortTable(this,<?php echo $ccol++; ?>);">ITEM</th>
       <th onclick="sortTable(this,<?php echo $ccol++; ?>);">DESCRIPCION</th>
       <th onclick="sortTable(this,<?php echo $ccol++; ?>,'N');">CANT</th>
     <?php if(mb_stristr('comp.prov',$docuo)) { ?>                    
       <th onclick="sortTable(this,<?php echo $ccol++; ?>,'N');">P.UNI</th>
       <th onclick="sortTable(this,<?php echo $ccol++; ?>,'N');">SUB-TOT</th>
     <?php } ?>                    
       <th onclick="sortTable(this,<?php echo $ccol++; ?>);">LOTE</th>
       <th <?php if($docui=='IB15'){echo 'width="10%"';} ?> onclick="sortTable(this,<?php echo $ccol++; ?>);">DETALLE</th>
       </tr>
     </thead>
     <tbody>
     <?php $abono=0;?>
     <?php $unidadesinve=0;?>
    <?php $filax=0;?>
    <?php $filag=5;?>
          
          
     <?php while($aso_deta=@msql_fetch_assoc($res_inve)){ ?>
       <?php $filax++; ?>
       <tr valign="top" style="<?php if($filax %$filag==0){echo 'border-bottom:dotted 1px;';} ?>">
       <td align="center"><?php echo $aso_deta['fecha']; ?></td>
       <td align="center"><?php echo $aso_deta['docu']; ?></td>
       <td align="center">
         <a href="<?php echo 'https://'.$cfg_empr.'.vcrxol.com/?prnt=1&docu='. $aso_deta['docu'].'&idnum='. $aso_deta['idnum1'].'&formato='.$formato;?>"  target="_blank" >
         <?php echo $aso_deta['numero']; ?>
         </a>
       </td>
       <td align="center"><?php echo $aso_deta['item_codigov']; ?></td>
       <td align="left"><?php echo split_words($aso_deta['item_descri'],40); ?></td>
       <td align="right"><?php echo number_format(abs($aso_deta['cant']),2).''; ?></td>
     <?php if(mb_stristr('comp.prov',$docuo)) { ?>         
       <td align="right"><?php echo number_format(abs($aso_deta['puni']),$aso_deta['item_dcos']).''; ?></td>
       <td align="right"><?php echo number_format(abs($aso_deta['total']),2).''; ?></td>
     <?php } ?>                    
       <td align="center"><?php echo $aso_deta['lote']; ?></td>
       <td align="left"><?php echo $aso_deta['detalle']; ?></td>
       </tr>
       <?php $abono+=abs($aso_deta['total']); ?>
       <?php $unidadesinve+=abs($aso_deta['cant']); ?>
     <?php } ?>  
     </tbody>
     <tfoot>
 			<tr style="border-top:solid 1px; border-bottom:solid 1px; font-weight:bolder; background:<?php echo $gris1;?>;">
       <th></th>
       <th></th>
       <th></th>
       <th></th>
       <th>TOTAL</th>
       <th align="right"><?php echo number_format($unidadesinve,2);?></th>
       <th></th>
     <?php if(mb_stristr('comp.prov',$docuo)) { ?>                    
       <th align="right"><?php echo number_format($abono,2);?></th>
       <th></th>
     <?php } ?>    
       <th align="right">PENDIENTE : <?php echo number_format($stcant-$unidadesinve,2);?> </th>
     <?php //$unidinve=unid_inve($docu,$aso_pant['idnum1']); ?>
       </tr>
     </tfoot>
     </table>
     <br>  
 <?php  } 
?>
 <?php  
   $docurela = ob_get_clean(); 
 //   $docurela=alltrim($docurela);
   $docurela=limpiahtml($docurela);
//      echo $sql_inve;
   return $docurela;
  
 }
?>




<?php
function prnt_compara($pdocu,$pidnum,$destino='screen')
{
	include('../_cfg/config.php');
  $xfontsize=12;
  $gris1='gainsboro';
  
  $sql_docu='select * from plan1 where idnum1="'.$pidnum.'"';
  $res_docu=msql_query($sql_docu,$link_vcrx);
  $xnumero=msql_result($res_docu,0,'numero');
   
  ob_start();

  $sql_atvd ='select * from atvd12 ';
  $sql_atvd.=' where status!="O"';
  $sql_atvd.=' and numerpla="'.$xnumero.'"';
//   $sql_atvd.=' and substring(asub,1,4)in(select substring(asub,1,4) from plan2 where idnum2="'.$pidnum.'")';
  $sql_atvd.=' order by substring(asub,1,4),fecha,idnum1,iddet';
  $res_atvd=msql_query($sql_atvd,$link_vcrx);
//    echo $sql_atvd;
//    return;
   
?>
<?php
  if(msql_num_rows($res_atvd)!=0)
  {
?>
    <table border="0" width="100%" cellpadding="0" cellspacing="0" 
           style="border-collapse:collapse;font-size:<?php echo $xfontsize; ?>px;<?php echo $xfontfamily;?>">
    <thead>
			<tr style="border-top:solid 1px; border-bottom:solid 1px; font-weight:bolder; background:<?php echo $gris1;?>;">
      <th>ACT.</th>
      <th width="25%">ACTIVIDAD</th> 
      <th>FECHA</th>
      <th>NUMERO</th>
      <th width="20%">EMPLEADO</th>
      <th>C.COSTO</th>
      <th>HORAS</th>
      <th>VALOR</th>
      <th>TOTAL</th>
      <th></th>
      </tr>
    </thead>
    <tbody>
    <?php $xthoras=0;?>
    <?php $xtvalor=0;?>
    <?php $filax=0;?>
    <?php $filag=5;?>
    <?php while($aso_atvd=@msql_fetch_assoc($res_atvd)){ ?>
       <?php $filax++; ?>
      <tr valign="top" style="<?php if($filax %$filag==0){echo 'border-bottom:dotted 1px;';} ?>" >
      <td align="center"><?php echo $aso_atvd['asub']; ?></td>
      <td align="left"><?php echo $aso_atvd['asub_descri']; ?></td>
      <td align="center"><?php echo $aso_atvd['fechadmy']; ?></td>
      <td align="center">
        <a href="<?php echo 'https://'.$cfg_empr.'.vcrxol.com/?prnt=1&docu='. $aso_atvd['docu'].'&idnum='. $aso_atvd['idnum1'].'&formato='.$formato;?>"  target="_blank" >
        <?php echo $aso_atvd['numero']; ?>
        </a>
      </td>
      <?php $empl_descri=r_fiel('enti',$aso_atvd['enti'],'enti_ape1').' '.r_fiel('enti',$aso_atvd['enti'],'enti_nom1'); ?>
      <?php if((trim($empl_descri)=='')){$empl_descri=$aso_atvd['enti_descri']; }?>
      <td align="left"><?php echo $empl_descri; ?></td>
      <td align="center"><?php echo $aso_atvd['csub1']; ?></td>
      <td align="right"><?php echo number_format(abs($aso_atvd['cant']),2).''; ?></td>
      <td align="right"><?php echo number_format(abs($aso_atvd['puni']),2).''; ?></td>
      <td align="right"><?php echo number_format(abs($aso_atvd['total']),2).''; ?></td>
      <td align="left"><?php //echo $aso_atvd['detalle']; ?></td>
      </tr>
      <?php $xthoras+=abs($aso_atvd['cant']); ?>
      <?php $xtvalor+=abs($aso_atvd['total']); ?>
    <?php } ?>  
    </tbody>
    <tfoot>
			<tr style="border-top:solid 1px; border-bottom:solid 1px; font-weight:bolder; background:<?php echo $gris1;?>;">
      <th></th>
      <th></th>
      <th></th>
      <th>TOTAL</th>
      <th></th>
      <th></th>
      <th align="right"><?php echo number_format($xthoras,2);?></th>
      <th></th>
      <th align="right"><?php echo number_format($xtvalor,2);?></th>
      <th></th>
      </tr>
    </tfoot>
    </table>
    <br>  
<?php  } ?>
<?php  
  $docurela = ob_get_clean(); 
//   $docurela=alltrim($docurela);
  $docurela=limpiahtml($docurela);
  return $docurela;
  
}
?>


<?php
function pdf_sri($docu,$idnum)
{
include('../_cfg/config.php');
include('php_session.php');
msql_query("SET NAMES 'utf8'");  

	$tabla=r_fiel('docu',$docu,'tabla');
	$sql_docu='select * from '.$tabla.'12 where idnum1="'.$idnum.'" order by iddet';
	$res_docu=msql_query($sql_docu,$link_vcrx);

	$sql_emis='select * from enti0 where enti_codigo="'.$cfg_ruc.'"';
	$res_emis=msql_query($sql_emis,$link_vcrx);

	$sql_rece='select * from enti0 where enti_codigo="'.msql_result($res_docu,0,'enti').'"';
	$res_rece=msql_query($sql_rece,$link_vcrx);
  
	if(substr($docu,0,1)=='F'){$docu_descri='FACTURA';}
	if(substr($docu,0,1)=='R'){$docu_descri='COMPROBANTE DE RETENCION';}
	if(substr($docu,0,1)=='N'){$docu_descri='NOTA DE CREDITO';}
	if(substr($docu,0,1)=='L'){$docu_descri='LIQUIDACION DE COMPRA';}
	if(substr($docu,0,1)=='G'){$docu_descri='GUIA DE REMISION';}
	
	$concepto=@msql_result($res_docu,0,'concepto');
//       $direccion=@msql_result($res_rece,0,'enti_direccion');
//       if(empty($direccion))
      {$direccion=@msql_result($res_rece,0,'enti_matriz');}
      $telefono=@msql_result($res_rece,0,'enti_telefono');
     
     
	$claveacc=@msql_result($res_docu,0,'claveacc');
       $autorfec=@msql_result($res_docu,0,'autorfec');
       if($autorfec=='')
       {$autorfec=@msql_result($res_docu,0,'fecha');}
    
	$ambice=substr($claveacc,23,1);
	if($claveacc==''){return;}
	if($ambice=='1'){$ambice='PRUEBAS';}
	if($ambice=='2'){$ambice='PRODUCCION';}

	gen_bcod($claveacc);
  $xsrc='https://vcrxol.com/_bcod/'.$claveacc.'.jpg'; 
  $ffamilyPDF='Arial';
	
  $docu_pdf = new FPDF('P','mm', 'A4');
  $docu_pdf->AddPage();
  $pdf_ancho=$docu_pdf->GetPageWidth()-10;
	 
	$docu_pdf->SetFont($ffamilyPDF,'',10);
	$docu_pdf->SetLineWidth(0.1);
	
	$docu_pdf->Rect(5, 65, 							$pdf_ancho*.495, 55,'D');	
	$docu_pdf->Rect($pdf_ancho*.53, 10, $pdf_ancho*.495, 110,'D');	
	$docu_pdf->Rect(5, 125, $pdf_ancho, 15,'D');	

	$docu_pdf->SetLeftMargin(5);
	$docu_pdf->SetY(17);
	$docu_pdf->SetFont($ffamilyPDF,'B',34);
	$docu_pdf->SetTextColor(250,0,0);
	
  $xsrcl='https://vcrxol.com/_logo/'.$logofile2;
  if(file_exists($xsrcl))
  {$docu_pdf->Image($xsrcl,30,20,30,0,'JPG');}
  else
  {$docu_pdf->Write(5,'NO TIENE LOGO');}
  
	$docu_pdf->SetFont($ffamilyPDF,'',8);
	$docu_pdf->SetTextColor(0,0,0);
	
	$docu_pdf->SetLeftMargin(10);
	$docu_pdf->SetY(67);
	$docu_pdf->SetFontSize(8);
	$docu_pdf->Write(5,msql_result($res_emis,0,'enti_razsoc'));
	$docu_pdf->ln(10);
	$docu_pdf->Write(5,msql_result($res_emis,0,'enti_nomcom'));
	$docu_pdf->ln(10);
	$docu_pdf->Write(5,utf8_decode('Dirección    '.msql_result($res_emis,0,'enti_matriz')));
	$docu_pdf->ln(3);
	$docu_pdf->Write(5,'Matriz:');
	$docu_pdf->ln(10);
	$docu_pdf->Write(5,utf8_decode('Dirección    '.msql_result($res_emis,0,'enti_matriz')));
	$docu_pdf->ln(3);
	$docu_pdf->Write(5,'Sucursal:');
	$docu_pdf->ln(10);
  if(msql_result($res_docu,0,'enti_obcon')=='1'){$obcon='SI';}else{$obcon='NO';}
	$docu_pdf->Write(5,'OBLIGADO A LLEVAR CONTABILIDAD : '.$obcon);
	
	$docu_pdf->SetLeftMargin($pdf_ancho*.53);
	$docu_pdf->SetY(12);
	$docu_pdf->SetFontSize(13);
	$docu_pdf->Write(5,'R.U.C.:       '.msql_result($res_emis,0,'enti_codigo'));
	$docu_pdf->ln(10);
	$docu_pdf->SetFontSize(15);
	$docu_pdf->Write(5,$docu_descri);
	$docu_pdf->ln(10);	
	$docu_pdf->SetFontSize(8);
	$docu_pdf->Write(5,'No.         '.msql_result($res_docu,0,'ptonumero'));
	$docu_pdf->ln(10);
	$docu_pdf->Write(5,'NUMERO DE AUTORIZACION');
	$docu_pdf->ln();	
	$docu_pdf->Write(5,msql_result($res_docu,0,'claveacc'));
	$docu_pdf->ln(10);
	$docu_pdf->Write(5,'FECHA Y HORA DE ');
	$docu_pdf->ln(3);
// 	$docu_pdf->Write(5,'AUTORIZACION:                    '.date('d/m/y H:i:s',strtotime(@msql_result($res_docu,0,'autorfec'))));
	$docu_pdf->Write(5,'AUTORIZACION:                    '.date('d/m/y H:i:s',strtotime($autorfec)));
	$docu_pdf->ln(10);
	$docu_pdf->Write(5,'AMBIENTE:                    	       '.$ambice);
	$docu_pdf->ln(10);
	$docu_pdf->Write(5,'EMISION:                                '.'NORMAL');
	$docu_pdf->ln(10);
	$docu_pdf->Write(5,'CLAVE DE ACCESO');
	$docu_pdf->Image($xsrc,$pdf_ancho*.54,95,$pdf_ancho*.5,20,'JPG');

	$docu_pdf->SetLeftMargin(5);
	$docu_pdf->SetY(125);
	$docu_pdf->Write(5,utf8_decode('Razón Social / Nombres y                           '.msql_result($res_rece,0,'enti_razsoc')));
	$docu_pdf->ln();
	$docu_pdf->Write(5,utf8_decode('Identificación           '.msql_result($res_rece,0,'enti_codigo')));
	$docu_pdf->ln();
	$docu_pdf->Write(5,'Fecha                      '.date('d/m/Y',strtotime(msql_result($res_docu,0,'fecha'))));


  
	if(substr($docu,0,1)=='F')
  {
    $docu_pdf->SetFontSize(7);
    $posY=145;
    $posX=5;
    
    $col_width=$pdf_ancho*.068;
    $docu_pdf->SetXY($posX,$posY);
    $docu_pdf->MultiCell($col_width,4.5,'Cod. Principal','LRTB','C',false);
    $posX=$posX+$col_width;

    $col_width=$pdf_ancho*.068;
    $docu_pdf->SetXY($posX,$posY);
    $docu_pdf->MultiCell($col_width,4.5,utf8_decode('Cod. Auxiliar'),'LRTB','C',false);
    $posX=$posX+$col_width;

    $col_width=$pdf_ancho*.068;
    $docu_pdf->SetXY($posX,$posY);
    $docu_pdf->MultiCell($col_width,9,utf8_decode('Cantidad'),'LRTB','C',false);
    $posX=$posX+$col_width;

    $col_width=$pdf_ancho*.186;
    $docu_pdf->SetXY($posX,$posY);
    $docu_pdf->MultiCell($col_width,9,utf8_decode('Descripción'),'LRTB','C',false);
    $posX=$posX+$col_width;

    $col_width=$pdf_ancho*.135;
    $docu_pdf->SetXY($posX,$posY);
    $docu_pdf->MultiCell($col_width,9,utf8_decode('Detalle Adicional'),'LRTB','C',false);
    $posX=$posX+$col_width;

    $col_width=$pdf_ancho*.095;
    $docu_pdf->SetXY($posX,$posY);
    $docu_pdf->MultiCell($col_width,9,'Precio Unitario','LRTB','C',false);
    $posX=$posX+$col_width;

    $col_width=$pdf_ancho*.095;
    $docu_pdf->SetXY($posX,$posY);
    $docu_pdf->MultiCell($col_width,9,'Subsidio','LRTB','C',false);
    $posX=$posX+$col_width;

    $col_width=$pdf_ancho*.095;
    $docu_pdf->SetXY($posX,$posY);
    $docu_pdf->MultiCell($col_width,4.5,'Precio sin Subsidio','LRTB','C',false);
    $posX=$posX+$col_width;

    $col_width=$pdf_ancho*.095;
    $docu_pdf->SetXY($posX,$posY);
    $docu_pdf->MultiCell($col_width,9,'Descuento','LRTB','C',false);
    $posX=$posX+$col_width;

    $col_width=$pdf_ancho*.095;
    $docu_pdf->SetXY($posX,$posY);
    $docu_pdf->MultiCell($col_width,9,'Precio Total','LRTB','C',false);
    $posX=$posX+$col_width;

    $tsubtiva0=0;
    $tsubtiva12=0;
    $tnooiva=0;
    $texeiva=0;
    $tsinimp=0;
    $tdcto=0;
    $tice=0;
    $tiva=0;
    $tirbp=0;
    $tprop=0;
    $total=0;

          
          
      $posY=$posY+9;
          
    $docu_pdf->SetFontSize(7);
    
    $res_docu=msql_query($sql_docu,$link_vcrx);
    while($aso_docu=msql_fetch_assoc($res_docu))
    {
      $docum_descri=$aso_docu['docum_descri'];
      if(substr($docum_descri,0,1)=='F'){$docum_descri='FACTURA';}
      $impto_descri='IVA';
      if(@mb_stristr('3.4',substr($aso_docu['cair'],0,1))){$impto_descri='Impuesto a la Renta';}

      $docu_pdf->SetFontSize(6.5);
//       $posY=$posY+9;
      $posX=5;

         $docu_pdf->SetFontSize(5);
      $col_width=$pdf_ancho*.068;
      $docu_pdf->SetXY($posX,$posY);
      $docu_pdf->MultiCell($col_width,9,$aso_docu['item'],'LRTB','C',false);
      $posX=$posX+$col_width;
      $lposY=$docu_pdf->getY();

      $col_width=$pdf_ancho*.068;
      $docu_pdf->SetXY($posX,$posY);
      $docu_pdf->MultiCell($col_width,9,$aso_docu['item'],'LRTB','C',false);
      $posX=$posX+$col_width;
//       if($docu_pdf->getY()>$lposY){$lposY=$docu_pdf->getY();}

    $docu_pdf->SetFontSize(7);
      $col_width=$pdf_ancho*.068;
      $docu_pdf->SetXY($posX,$posY);
      $docu_pdf->MultiCell($col_width,9,number_format($aso_docu['cant'],2,'.',''),'LRTB','R',false);
      $posX=$posX+$col_width;
//       if($docu_pdf->getY()>$lposY){$lposY=$docu_pdf->getY();}

      $col_width=$pdf_ancho*.186;
      $docu_pdf->SetXY($posX,$posY);
      $docu_pdf->MultiCell($col_width,3,utf8_decode($aso_docu['item_descri']),'LRTB','L',false);
      $posX=$posX+$col_width;
      if($docu_pdf->getY()>$lposY){$lposY=$docu_pdf->getY();}
         
      $col_width=$pdf_ancho*.135;
      $docu_pdf->SetXY($posX,$posY);
      $docu_pdf->MultiCell($col_width,3,utf8_decode($aso_docu['detalle']),'LRTB','L',false);
      $posX=$posX+$col_width;
      if($docu_pdf->getY()>$lposY)
         
      $col_width=$pdf_ancho*.095;
      $docu_pdf->SetXY($posX,$posY);
      $docu_pdf->MultiCell($col_width,9,number_format($aso_docu['puni'],2,'.',''),'LRTB','R',false);
      $posX=$posX+$col_width;

      $col_width=$pdf_ancho*.095;
      $docu_pdf->SetXY($posX,$posY);
      $docu_pdf->MultiCell($col_width,9,number_format(0,2,'.',''),'LRTB','R',false);
      $posX=$posX+$col_width;

      $col_width=$pdf_ancho*.095;
      $docu_pdf->SetXY($posX,$posY);
      $docu_pdf->MultiCell($col_width,9,number_format(0,2,'.',''),'LRTB','R',false);
      $posX=$posX+$col_width;

      $col_width=$pdf_ancho*.095;
      $docu_pdf->SetXY($posX,$posY);
      $docu_pdf->MultiCell($col_width,9,number_format($aso_docu['tdcto'],2,'.',''),'LRTB','R',false);
      $posX=$posX+$col_width;

      $col_width=$pdf_ancho*.095;
      $docu_pdf->SetXY($posX,$posY);
      $docu_pdf->MultiCell($col_width,9,number_format($aso_docu['tsubt'],2,'.',''),'LRTB','R',false);
      $posX=$posX+$col_width;

      $tsubtiva0+=$aso_docu['tsubtiva0'];
      $tsubtiva12+=$aso_docu['tsubtiva12'];
      $tnooiva=0;
      $texeiva=0;
      $tsinimp=0;
      $tdcto+=$aso_docu['tdcto'];
      $tice+=$aso_docu['tice'];
      $tiva+=$aso_docu['tiva'];
      $tirbp+=$aso_docu['tirbp'];
      $tprop=0;
      $total+=$aso_docu['total'];
      $vhcl=$aso_docu['vhcl'];

      $posY=$posY+9;
         
      $lindetalle=ceil(strlen($aso_docu['detalle'])/45)-1;
      $posY=$posY+9*$lindetalle;
         
         
    }			

//       $direccion=@msql_result($res_adqu,0,'enti_direccion');
//       if(empty($direccion)){$direccion=@msql_result($res_adqu,0,'enti_matriz');}
//      $direccion='*/*/*';          
    

    $posY=$posY+1;
    $docu_pdf->SetY($posY+1);
//     $docu_pdf->SetY($lposY+1);
    $docu_pdf->SetFontSize(7);
    $docu_pdf->SetLeftMargin(5);
    $docu_pdf->MultiCell($pdf_ancho*.6,5,utf8_decode('Información Adicional'),'LRTB','C',false);

    $docu_pdf->MultiCell($pdf_ancho*.6,5,utf8_decode('Descripción:                               '.$concepto),'LR','L',false);
    $docu_pdf->MultiCell($pdf_ancho*.6,5,utf8_decode('Dirección:                                    '.$direccion),'LR','L',false);
    $docu_pdf->MultiCell($pdf_ancho*.6,5,utf8_decode('Teléfono:                                     '.$telefono),'LR','L',false);
?>
						<?php $coesp=@msql_result($res_emis,0,'enti_coesp'); ?>
						<?php $coesn=@msql_result($res_emis,0,'enti_coesn'); ?>
						<?php $rise=@msql_result($res_emis,0,'enti_rise'); ?>
						<?php $rime=@msql_result($res_emis,0,'enti_rime'); ?>
						<?php $agret=@msql_result($res_emis,0,'enti_agret'); ?>
						<?php $agren=@msql_result($res_emis,0,'enti_agren'); ?>
                <?php if(!empty($coesp) or !empty($coesn)){?>
                <?php
                $docu_pdf->Cell($pdf_ancho*.2,5,'CONTRIBUYENTE :','LRT',0,'L',false);
                $docu_pdf->MultiCell($pdf_ancho*.4,5,'ESPECIAL','LRT','L',false);
                ?>
                <?php } ?>

                <?php if(!empty($agret) or !empty($agren)){?>
                <?php
//                 $docu_pdf->Cell($pdf_ancho*.2,5,'CONTRIBUYENTE :','LRT',0,'L',false);
                $docu_pdf->MultiCell($pdf_ancho*.6,5,'CONTRIBUYENTE : AGENTE DE RETENCION - RESOLUCION No NACDNCRASC20-00000001 ','LR','L',false);
                ?>
                <?php } ?>

                <?php if(!empty($rise)){?>
                <?php
//                 $docu_pdf->MultiCell($pdf_ancho*.6,5,'CONTRIBUYENTE :RISE','LR','L',false);
                ?>
                <?php } ?>
                  
                <?php if(!empty($rime)){?>
                <?php
                $docu_pdf->MultiCell($pdf_ancho*.6,5,'CONTRIBUYENTE : REGIMEN MICROEMPRESA','LR','L',false);
                ?>
                <?php } ?>
    
<?php    $docu_pdf->MultiCell($pdf_ancho*.6,5,'','T','L',false); ?>
<?php    
    $posY=$posY-1;
    
    $posX=$pdf_ancho*.645;
    $col_width=$pdf_ancho*.285;
    $docu_pdf->SetXY($posX,$posY);
    $docu_pdf->MultiCell($col_width,4.5,'SUBTOTAL 15%','LRTB','L',false);
    $posX=$posX+$col_width;

    $col_width=$pdf_ancho*.095;
    $docu_pdf->SetXY($posX,$posY);
    $docu_pdf->MultiCell($col_width,4.5,number_format($tsubtiva12,2,'.',''),'LRTB','R',false);
    $posX=$posX+$col_width;
    $posY=$posY+4.5;
 
    $posX=$pdf_ancho*.645;
    $col_width=$pdf_ancho*.285;
    $docu_pdf->SetXY($posX,$posY);
    $docu_pdf->MultiCell($col_width,4.5,'SUBTOTAL 0%','LRTB','L',false);
    $posX=$posX+$col_width;

    $col_width=$pdf_ancho*.095;
    $docu_pdf->SetXY($posX,$posY);
    $docu_pdf->MultiCell($col_width,4.5,number_format($tsubtiva0,2,'.',''),'LRTB','R',false);
    $posX=$posX+$col_width;
    $posY=$posY+4.5;
 
    $posX=$pdf_ancho*.645;
    $col_width=$pdf_ancho*.285;
    $docu_pdf->SetXY($posX,$posY);
    $docu_pdf->MultiCell($col_width,4.5,'SUBTOTAL NO OBJETO DE IVA','LRTB','L',false);
    $posX=$posX+$col_width;

    $col_width=$pdf_ancho*.095;
    $docu_pdf->SetXY($posX,$posY);
    $docu_pdf->MultiCell($col_width,4.5,number_format($tnooiva,2,'.',''),'LRTB','R',false);
    $posX=$posX+$col_width;
    $posY=$posY+4.5;
 
    $posX=$pdf_ancho*.645;
    $col_width=$pdf_ancho*.285;
    $docu_pdf->SetXY($posX,$posY);
    $docu_pdf->MultiCell($col_width,4.5,'SUBTOTAL EXENTO DE IVA','LRTB','L',false);
    $posX=$posX+$col_width;

    $col_width=$pdf_ancho*.095;
    $docu_pdf->SetXY($posX,$posY);
    $docu_pdf->MultiCell($col_width,4.5,number_format($texeiva,2,'.',''),'LRTB','R',false);
    $posX=$posX+$col_width;
    $posY=$posY+4.5;
 
    $posX=$pdf_ancho*.645;
    $col_width=$pdf_ancho*.285;
    $docu_pdf->SetXY($posX,$posY);
    $docu_pdf->MultiCell($col_width,4.5,'SUBTOTAL SIN IMPUESTOS','LRTB','L',false);
    $posX=$posX+$col_width;

    $col_width=$pdf_ancho*.095;
    $docu_pdf->SetXY($posX,$posY);
    $docu_pdf->MultiCell($col_width,4.5,number_format($tsubtiva0+$tsubtiva12,2,'.',''),'LRTB','R',false);
    $posX=$posX+$col_width;
    $posY=$posY+4.5;
 
    $posX=$pdf_ancho*.645;
    $col_width=$pdf_ancho*.285;
    $docu_pdf->SetXY($posX,$posY);
    $docu_pdf->MultiCell($col_width,4.5,'TOTAL DESCUENTO','LRTB','L',false);
    $posX=$posX+$col_width;

    $col_width=$pdf_ancho*.095;
    $docu_pdf->SetXY($posX,$posY);
    $docu_pdf->MultiCell($col_width,4.5,number_format($tdcto,2,'.',''),'LRTB','R',false);
    $posX=$posX+$col_width;
    $posY=$posY+4.5;
 
    $posX=$pdf_ancho*.645;
    $col_width=$pdf_ancho*.285;
    $docu_pdf->SetXY($posX,$posY);
    $docu_pdf->MultiCell($col_width,4.5,'ICE','LRTB','L',false);
    $posX=$posX+$col_width;

    $col_width=$pdf_ancho*.095;
    $docu_pdf->SetXY($posX,$posY);
    $docu_pdf->MultiCell($col_width,4.5,number_format($tice,2,'.',''),'LRTB','R',false);
    $posX=$posX+$col_width;
    $posY=$posY+4.5;
 
    $posX=$pdf_ancho*.645;
    $col_width=$pdf_ancho*.285;
    $docu_pdf->SetXY($posX,$posY);
    $docu_pdf->MultiCell($col_width,4.5,'IVA','LRTB','L',false);
    $posX=$posX+$col_width;

    $col_width=$pdf_ancho*.095;
    $docu_pdf->SetXY($posX,$posY);
    $docu_pdf->MultiCell($col_width,4.5,number_format($tiva,2,'.',''),'LRTB','R',false);
    $posX=$posX+$col_width;
    $posY=$posY+4.5;
 
    $posX=$pdf_ancho*.645;
    $col_width=$pdf_ancho*.285;
    $docu_pdf->SetXY($posX,$posY);
    $docu_pdf->MultiCell($col_width,4.5,'IRBPNR','LRTB','L',false);
    $posX=$posX+$col_width;

    $col_width=$pdf_ancho*.095;
    $docu_pdf->SetXY($posX,$posY);
    $docu_pdf->MultiCell($col_width,4.5,number_format($tirbp,2,'.',''),'LRTB','R',false);
    $posX=$posX+$col_width;
    $posY=$posY+4.5;
 
    $posX=$pdf_ancho*.645;
    $col_width=$pdf_ancho*.285;
    $docu_pdf->SetXY($posX,$posY);
    $docu_pdf->MultiCell($col_width,4.5,'PROPINA','LRTB','L',false);
    $posX=$posX+$col_width;

    $col_width=$pdf_ancho*.095;
    $docu_pdf->SetXY($posX,$posY);
    $docu_pdf->MultiCell($col_width,4.5,number_format($tprop,2,'.',''),'LRTB','R',false);
    $posX=$posX+$col_width;
    $posY=$posY+4.5;
 
    $posX=$pdf_ancho*.645;
    $col_width=$pdf_ancho*.285;
    $docu_pdf->SetXY($posX,$posY);
    $docu_pdf->MultiCell($col_width,4.5,'TOTAL','LRTB','L',false);
    $posX=$posX+$col_width;

    $col_width=$pdf_ancho*.095;
    $docu_pdf->SetXY($posX,$posY);
    $docu_pdf->MultiCell($col_width,4.5,number_format($total,2,'.',''),'LRTB','R',false);
    $posX=$posX+$col_width;
    $posY=$posY+4.5;
 
    $posY=$posY+1;
    $posX=$pdf_ancho*.645;
    $col_width=$pdf_ancho*.285;
    $docu_pdf->SetXY($posX,$posY);
    $docu_pdf->MultiCell($col_width,4.5,'VALOR TOTAL SIN SUBSIDIO','LT','L',false);
    $posX=$posX+$col_width;

    $col_width=$pdf_ancho*.095;
    $docu_pdf->SetXY($posX,$posY);
    $docu_pdf->MultiCell($col_width,4.5,number_format(0,2,'.',''),'RT','R',false);
    $posX=$posX+$col_width;
    $posY=$posY+4.5;
 
    $posX=$pdf_ancho*.645;
    $col_width=$pdf_ancho*.285;
    $docu_pdf->SetXY($posX,$posY);
    $docu_pdf->MultiCell($col_width,4.5,'AHORRO POR SUBSIDIO','L','L',false);
    $posX=$posX+$col_width;

    $col_width=$pdf_ancho*.095;
    $docu_pdf->SetXY($posX,$posY);
    $docu_pdf->MultiCell($col_width,4.5,number_format(0,2,'.',''),'R','R',false);
    $posX=$posX+$col_width;
    $posY=$posY+4.5;
    $posX=$pdf_ancho*.645;
    $col_width=$pdf_ancho*.285;
    $docu_pdf->SetXY($posX,$posY);
    $docu_pdf->MultiCell($col_width,4.5,'Incluye IVA cuando corresponda','LB','L',false);
    $posX=$posX+$col_width;

    $col_width=$pdf_ancho*.095;
    $docu_pdf->SetXY($posX,$posY);
    $docu_pdf->MultiCell($col_width,4.5,'','RB','R',false);
    $posX=$posX+$col_width;
    $posY=$posY+4.5;
 
    
    $docu_pdf->AddPage();
  }
  
  
  
	if(substr($docu,0,1)=='R')
  {
    $posY=145;
    $posX=5;

    $col_width=$pdf_ancho*.12;
    $docu_pdf->SetXY($posX,$posY);
    $docu_pdf->MultiCell($col_width,9,'Comprobante','LRTB','C',false);
    $posX=$posX+$col_width;

    $col_width=$pdf_ancho*.1;
    $docu_pdf->SetXY($posX,$posY);
    $docu_pdf->MultiCell($col_width,9,utf8_decode('Número'),'LRTB','C',false);
    $posX=$posX+$col_width;

    $col_width=$pdf_ancho*.12;
    $docu_pdf->SetXY($posX,$posY);
    $docu_pdf->MultiCell($col_width,9,utf8_decode('Fecha Emisión'),'LRTB','C',false);
    $posX=$posX+$col_width;

    $col_width=$pdf_ancho*.08;
    $docu_pdf->SetXY($posX,$posY);
    $docu_pdf->MultiCell($col_width,4.5,'Ejercicio Fiscal','LRTB','C',false);
    $posX=$posX+$col_width;

    $col_width=$pdf_ancho*.15;
    $docu_pdf->SetXY($posX,$posY);
    $docu_pdf->MultiCell($col_width,4.5,utf8_decode('Base Imponible para la Retención'),'LRTB','C',false);
    $posX=$posX+$col_width;

    $col_width=$pdf_ancho*.18;
    $docu_pdf->SetXY($posX,$posY);
    $docu_pdf->MultiCell($col_width,9,'Impuesto','LRTB','C',false);
    $posX=$posX+$col_width;

    $col_width=$pdf_ancho*.1;
    $docu_pdf->SetXY($posX,$posY);
    $docu_pdf->MultiCell($col_width,4.5,'Porcentaje Retencion','LRTB','C',false);
    $posX=$posX+$col_width;

    $col_width=$pdf_ancho*.15;
    $docu_pdf->SetXY($posX,$posY);
    $docu_pdf->MultiCell($col_width,9,'Valor Retenido','LRTB','C',false);

    $docu_pdf->SetFontSize(7);
    $res_docu=msql_query($sql_docu,$link_vcrx);
  // 	$docu_pdf->Cell($col_width,10,'ERROR:'.msql_error(),0,'LRTB','C',false);
    while($aso_docu=msql_fetch_assoc($res_docu))
    {
      $docum_descri=$aso_docu['docum_descri'];
      if(substr($docum_descri,0,1)=='F'){$docum_descri='FACTURA';}
      $impto_descri='IVA';
      if(@mb_stristr('3.4',substr($aso_docu['cair'],0,1))){$impto_descri='Impuesto a la Renta';}

      $posY=$posY+9;
      $posX=5;

      $col_width=$pdf_ancho*.12;
      $docu_pdf->SetXY($posX,$posY);
      $docu_pdf->MultiCell($col_width,9,$docum_descri,'LRTB','C',false);
      $posX=$posX+$col_width;

      $col_width=$pdf_ancho*.1;
      $docu_pdf->SetXY($posX,$posY);
      $docu_pdf->MultiCell($col_width,4.5,$aso_docu['ptoem'].$aso_docu['numer'],'LRTB','L',false);
      $posX=$posX+$col_width;

      $col_width=$pdf_ancho*.12;
      $docu_pdf->SetXY($posX,$posY);
      $docu_pdf->MultiCell($col_width,9,date('d/m/Y',strtotime($aso_docu['fecha'])),'LRTB','L',false);
      $posX=$posX+$col_width;

      $col_width=$pdf_ancho*.08;
      $docu_pdf->SetXY($posX,$posY);
      $docu_pdf->MultiCell($col_width,9,date('m/Y',strtotime($aso_docu['fecha'])),'LRTB','C',false);
      $posX=$posX+$col_width;

      $col_width=$pdf_ancho*.15;
      $docu_pdf->SetXY($posX,$posY);
      $docu_pdf->MultiCell($col_width,9,number_format($aso_docu['cant'],2,'.',''),'LRTB','C',false);
      $posX=$posX+$col_width;

      $col_width=$pdf_ancho*.18;
      $docu_pdf->SetXY($posX,$posY);
      $docu_pdf->MultiCell($col_width,9,$impto_descri,'LRTB','C',false);
      $posX=$posX+$col_width;

      $col_width=$pdf_ancho*.1;
      $docu_pdf->SetXY($posX,$posY);
//       $docu_pdf->MultiCell($col_width,9,number_format($aso_docu['puni'],1,'.',''),'LRTB','C',false);
         //peggy
      $docu_pdf->MultiCell($col_width,9,number_format($aso_docu['puni'],2,'.',''),'LRTB','C',false);
      $posX=$posX+$col_width;

      $col_width=$pdf_ancho*.15;
      $docu_pdf->SetXY($posX,$posY);
      $docu_pdf->MultiCell($col_width,9,number_format(abs($aso_docu['total']),2,'.',''),'LRTB','R',false);

    }			

    $posY=$posY+15;

    $docu_pdf->Rect(5, $posY,$pdf_ancho*.65, 45,'D');
    $docu_pdf->Rect(10, $posY+10,$pdf_ancho*.6, 20,'D');

    $docu_pdf->SetFontSize(10);
    $docu_pdf->SetY($posY+1);
    $docu_pdf->SetX(40);
    $docu_pdf->Write(5,utf8_decode('Información Adicional'));

    $docu_pdf->SetFontSize(7);
    $docu_pdf->SetY($posY+10);
    $docu_pdf->SetX(10);
    $docu_pdf->MultiCell($pdf_ancho*.6,5,utf8_decode('Información Adicional'),'B','C',false);

    $docu_pdf->SetLeftMargin(10);
    $docu_pdf->MultiCell($pdf_ancho*.6,5,utf8_decode('Descripción:                               '.$concepto),'LR','L',false);
    $docu_pdf->MultiCell($pdf_ancho*.6,5,utf8_decode('Dirección:                                    '.$direccion),'LR','L',false);
    $docu_pdf->MultiCell($pdf_ancho*.6,5,utf8_decode('Teléfono:                                     '.$telefono),'LR','L',false);
//     if(!empty($vhcl))
//     {$docu_pdf->MultiCell($pdf_ancho*.6,5,utf8_decode('Placa:                                     '.$vhcl),'LR','L',false);}
    $docu_pdf->MultiCell($pdf_ancho*.6,5,'','T','L',false);
  }

  $subdce=mk_subdce($claveacc);
  @unlink($rutace.$subdce.$claveacc.'.pdf');
  $docu_pdf->Output('F',$rutace.$subdce.$claveacc.'.pdf',true);
     
  	
}


?>

