<?php //session_start();?>


<?php

// function solo la impresion (size, destino)
// function dobla (horizontal, vertical)


?>



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

$sql_docu='select * from docu0 where docu_codigo like "'.$docu.'%"';
$res_docu=mysql_query($sql_docu,$link_vcrx);
	
?>

<?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">
<?php //////////////////////////////////////////////////////////	?>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title><?php echo $docu.'-'.$xptonumero.'-'.r_fiel('enti',$xenti); ?></title>
	
<style type="text/css">
/* body{ font-family:"Courier New", Courier, monospace;} */
@media print {.noprint {display:none}}
@media screen{.noscreen {display:none}}
	
@page
{
/* size:<?php echo $papersize; ?>; */
size:A4 ;
margin: 10mm 10mm 10mm 10mm; /* 	top right bottom left */
/* font-size: 24px; */
/* 	@body{font-size: 16pt;}	 */
}

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

<?php //////////////////////////////////////////////////////////	?>
<body>
	
</body>	
<?php //////////////////////////////////////////////////////////	?>

</html>

	
	
<?php	
$docuhtml = ob_get_clean(); 
$docuhtml=alltrim($docuhtml);
file_put_contents($rutadoc.$docu.'_'.str_pad($idnum,9,"0",STR_PAD_LEFT).'.html',$docuhtml);
if(substr($xclaveacc,10,13)==$cfg_ruc)
{file_put_contents($rutace.$xclaveacc.'.html',$docuhtml);}
// else
// {file_put_contents($rutace.$xclaveacc.'.html',$docuhtml);}
return $docuhtml;	
	
}
?>



<?php
function prnt_docu1($docu,$idnum,$formato=1,$destino='')
{
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
	
	include('../_cfg/config.php');
 	include('php_session.php');

	$mdisp=2;
	if($destino=='mail'){$mdisp=1;}
	
	$tabla=r_fiel('docu',$docu,'tabla');

 	$ps_a4 ='210mm 297mm';	
	$ps_a4l='297mm 210mm';	
	$ps_a5 ='148mm 210mm';	
	$ps_a5l='210mm 148mm';	
	$ps_a6 ='105mm 148mm';	
	$ps_a6l='148mm 105mm';	

	$papersize=$ps_a4;
	$xfontsize=16;
	$screensize=16;
	$printsize=32;
	
	$sql_emis='select * from empr0 left join enti00 on empr_ruc=enti_codigo limit 1';
	$res_emis=mysql_query($sql_emis,$link_vcrx);

	$sql_tra1='select * from '.$tabla.'11 where idnum1="'.$idnum.'"';
	$res_tra1=mysql_query($sql_tra1,$link_vcrx);	
	
	$sql_tra2 ='select * from '.$tabla.'12 where idnum1="'.$idnum.'" ';
	$sql_tra2.='order by iddet';
	$res_tra2=mysql_query($sql_tra2,$link_vcrx);	
	
	$sql_adqu='select * from enti00 where enti_codigo="'.mysql_result($res_tra1,0,'enti').'"';
	$res_adqu=mysql_query($sql_adqu,$link_vcrx);

	$xptonumero=mysql_result($res_tra1,0,'ptonumero');
	$xenti=mysql_result($res_tra1,0,'enti');
	$xclaveacc=mysql_result($res_tra1,0,'claveacc');
	$xautornum=mysql_result($res_tra1,0,'autornum');
	$xstatus=mysql_result($res_tra1,0,'status');
	$xambi=substr($xclaveacc,23,1);
	
	$xmdetalle=mysql_result($res_tra1,0,'mdetalle');
	

	$xtunid=0;

	$xpdcto=0;
	$xpice=0;
	$xpiva=0;
	$xpirbp=0;
	$xtdcto=0;
	$xtsubtice=0;
	$xtice=0;
	$xtsubtiva0=0;
	$xtsubtiva=0;
	$xtiva=0;
	$xtirbp=0;

	$xtcant=mysql_result($res_tra1,0,'tcant');
	$xtsubt=mysql_result($res_tra1,0,'tsubt');
	$xtotal=mysql_result($res_tra1,0,'total');
	$xconcepto=mysql_result($res_tra1,0,'concepto');
	
	$xvndd='';
	$xfpag='';
	$xsuco='';
	
	if(mb_stristr('vtas.clie.comp.prov.inve.pro', $tabla))
	{
		$xtunid=$xtcant;
		$xsuco=mysql_result($res_tra1,0,'suco');
		$xfpag=mysql_result($res_tra1,0,'fpag');
		if(mb_stristr('vtas.clie.comp.prov', $tabla))
		{
			$xpdcto=mysql_result($res_tra1,0,'pdcto');
			$xpice=mysql_result($res_tra1,0,'pice');
			$xpiva=mysql_result($res_tra1,0,'piva');
			$xpirbp=mysql_result($res_tra1,0,'pirbp');
			$xtdcto=mysql_result($res_tra1,0,'tdcto');
			$xtsubtice=mysql_result($res_tra1,0,'tsubtice');
			$xtice=mysql_result($res_tra1,0,'tice');
			$xtsubtiva0=mysql_result($res_tra1,0,'tsubtiva0');
			$xtsubtiva=mysql_result($res_tra1,0,'tsubtiva');
			$xtiva=mysql_result($res_tra1,0,'tiva');
			$xtirbp=mysql_result($res_tra1,0,'tirbp');
		}
		if(mb_stristr('vtas.clie', $tabla))
		{
			$xtbien=mysql_result($res_tra1,0,'tbien');
			$xtunid=$xtbien;
			$xvndd=mysql_result($res_tra1,0,'vndd');
			$xvndd=r_fiel('enti',mysql_result($res_tra1,0,'vndd'));
		}
	}
	

	$xiuser=mysql_result($res_tra1,0,'iuser');
	$xidate=mysql_result($res_tra1,0,'idate');

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

	if (mb_stristr('comp.retc',$tabla))
	{
	$res_emis=mysql_query($sql_adqu,$link_vcrx);
	$res_adqu=mysql_query($sql_emis,$link_vcrx);
	}

	if (mb_stristr('FP11',substr($docu,0,4)))
	{
	$lblruc2='PROVEEDOR';
	$res_emis=mysql_query($sql_emis,$link_vcrx);
	$res_adqu=mysql_query($sql_adqu,$link_vcrx);
	}
	
	if (mb_stristr('IE.IC.IV.DC',substr($docu,0,2)))
	{$lblruc2='CLIENTE';}

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


<?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">
<?php //////////////////////////////////////////////////////////	?>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title><?php echo $docu.'-'.$xptonumero.'-'.r_fiel('enti',$xenti); ?></title>
	
<style type="text/css">
/* body{ font-family:"Courier New", Courier, monospace;} */
@media print {.noprint {display:none}}
@media screen{.noscreen {display:none}}
	
@page
{
/* size:<?php echo $papersize; ?>; */
size:A4 ;
margin: 10mm 10mm 10mm 10mm; /* 	top right bottom left */
/* font-size: 24px; */
/* 	@body{font-size: 16pt;}	 */
}

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

<?php //////////////////////////////////////////////////////////	?>
<body>
	<?php $xfontsize=$screensize; ?>
	
	<?php for($cdisp=1;$cdisp<=$mdisp;$cdisp++){ ?>
	<div id="cele" style="border:solid 0px; font-family:courier; font-size:<?php echo $xfontsize; ?>px;" <?php if($cdisp==1){echo 'class="noprint";';}else{echo 'class="noscreen";';}?>>	
		
	<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; border-top:solid 1px; border-bottom:solid 1px;">
				<td width="20%">
				<?php echo '';?>
				</td>
				<td width="60%" align="center" style="letter-spacing:5pt;">
				<?php if($xclaveacc==""){echo 'COMPROBANTE';}else{echo 'COMPROBANTE-ELECTRONICO';}	?>
				</td>
				<td width="20%" align="right" style="font-size:<?php echo $xfontsize-6; ?>px;">
				<?php echo 'REGISTRADO POR:';?>
				<?php //echo '<br>';?>
				<?php echo r_fiel('enti',$xiuser,'nom1').' '.r_fiel('enti',$xiuser,'ape1');?>
				<?php echo '<br>';?>
				<?php echo date('d/M/y H:i:s',strtotime($xidate));?>
				</td>
			</tr>
		</table>		
		
		<table border="0" width="100%" cellpadding="2" cellspacing="0" style="border-collapse:collapse;font-size:<?php echo $xfontsize; ?>px;">
			<tr>
				<?php ///// COLUMNA IZQUIERDA ?>
				<td width=50% valign="top">
					
					<?php ///// BLOQUE 1 ?>
					<?php{?>
					<table border="1" width="100%" cellpadding="2" cellspacing="0" style="border-collapse:collapse;">
						<tr style="border:solid 1px; font-weight:bolder; background:#F7F7F7;">
							<td align="center" colspan=2 style="letter-spacing: 10px" ><?php echo $lblruc1; ?></td>
						</tr>
						<tr style="display:none;">
							<td width="30%"></td>
							<td></td>
						</tr>
						<tr>
							<td>RUC/C.I.</td>
							<td><?php echo mysql_result($res_emis,0,'enti_codigo');?></td>
						</tr>
						<tr>
							<td>RAZON SOCIAL-</td>
							<td><?php echo mysql_result($res_emis,0,'enti_razsoc');?></td>
						</tr>
						<tr>
							<td>NOMBRE COMERCIAL</td>
							<td><?php echo mysql_result($res_emis,0,'enti_nomcom');?></td>
						</tr>
						<tr>
							<td>MATRIZ</td>
							<td><?php echo mysql_result($res_emis,0,'enti_matriz');?></td>
						</tr>
						<tr>
							<td>TELEFONO</td>
							<td><?php echo mysql_result($res_emis,0,'enti_telefono');?></td>
						</tr>
						<tr>
							<td>E-MAIL</td>
							<td><?php echo mysql_result($res_emis,0,'enti_email');?></td>
						</tr>
					</table>
					<?php}?>

					<?php ///// BLOQUE 2 ?>
					<?php{?>
					<div style="font-size:<?php echo $xfontsize-12; ?>px;"><br></div>
					<table border="1" width="100%" cellpadding="2" cellspacing="0" style="border-collapse:collapse;">
						<tr style="border:solid 1px; font-weight:bolder; background: #F7F7F7;">
							<td align="center" colspan=2 style="letter-spacing: 10px" ><?php echo $lblruc2; ?></td>
						</tr>
						<tr style="display:none;">
							<td width="30%"></td>
							<td></td>
						</tr>
						<tr>
							<td>RUC/C.I.</td>
							<td><?php echo mysql_result($res_adqu,0,'enti_codigo');?></td>
						</tr>
						<tr>
							<td>RAZON SOCIAL</td>
							<td><?php echo mysql_result($res_adqu,0,'enti_razsoc');?></td>
						</tr>
						<tr>
							<td>NOMBRE COMERCIAL</td>
							<td><?php echo mysql_result($res_adqu,0,'enti_nomcom');?></td>
						</tr>
						<tr>
							<td>MATRIZ</td>
							<td><?php echo mysql_result($res_adqu,0,'enti_matriz');?></td>
						</tr>
						<tr>
							<td>TELEFONO</td>
							<td><?php echo mysql_result($res_adqu,0,'enti_telefono');?></td>
						</tr>
						<tr>
							<td>E-MAIL</td>
							<td><?php echo mysql_result($res_adqu,0,'enti_email');?></td>
						</tr>
					</table>					
					<?php}?>

					<?php ///// BLOQUE 3 ?>
					<?php{?>
					<div style="font-size:<?php echo $xfontsize-12; ?>px;"><br></div>
					<table border="1" width="100%" cellpadding="2" cellspacing="0" style="border-collapse:collapse;">
						<tr style="border:solid 1px; font-weight:bolder; background: #F7F7F7;">
							<td align="center" colspan=2 ><?php echo 'INFORMACION ADICIONAL'; ?></td>
						</tr>
						<tr style="display:none;">
							<td width="30%"></td>
							<td></td>
						</tr>
						<tr style=<?php if($xconcepto==""){echo 'display:none;';}?>>
							<td>CONCEPTO</td>
							<td><?php echo $xconcepto;?></td>
						</tr>
						<?php if(mb_stristr('comp.prov', $tabla)){?>
						<tr style="font-size:<?php echo $xfontsize-4; ?>px;<?php if($xsuco==0){echo 'display:none;';}?>" >
							<td>SUSTENT.COMP.</td>
							<td><?php echo mysql_result($res_tra1,0,'suco_descri');?></td>
						</tr>
						<?php}?>
					</table>					
					<?php}?>

				</td>

				<?php ///// COLUMNA DERECHA ?>
				<td width=50% valign="top">
					
					<?php ///// BLOQUE 1 ?>
					<?php{?>
					<table border="1" width="100%" cellpadding="2" cellspacing="0" style="border-collapse:collapse;">
						<tr style="border:solid 1px; font-weight:bolder; background: #F7F7F7;">
							<td align="center" colspan=2 ><?php echo 'DATOS DEL COMPROBANTE'; ?></td>
						</tr>
						<tr style="display:none;">
							<td width="30%"></td>
							<td></td>
						</tr>
						<tr>
							<td align="right">TIPO:</td>
							<td><?php echo mysql_result($res_tra1,0,'docu_descri');?></td>
						</tr>
						<tr style="<?php if($xambi==0){echo 'display:none;';} ?>">
							<td align="right">AMBIENTE:</td>
							<td><?php if($xambi==2){echo 'PRODUCCION';}else{echo 'PRUEBAS';};?></td>
						</tr>
						<tr style="font-weight:bolder;">
							<td align="right">NUMERO:</td>
							<td><?php echo mysql_result($res_tra1,0,'ptonumero');?></td>
						</tr>
						<tr>
							<td align="right">FECHA:</td>
							<td><?php echo mysql_result($res_tra1,0,'fechadmy');?></td>
						</tr>
						<tr>
							<td align="right">VENCE:</td>
							<td><?php echo mysql_result($res_tra1,0,'vencedmy');?></td>
						</tr>
						<tr style="<?php if($xvndd==""){echo 'display:none;';} ?>">
							<td align="right">VENDEDOR:</td>
							<td><?php echo $xvndd;?></td>
						</tr>
						<tr style="font-size:<?php echo $xfontsize-6; ?>px;<?php if($xclaveacc==""){echo 'display:none;';} ?>">
							<td align="right">CLAVE ACCESO:</td>
							<td>
								<a <?php if($cdisp==1){echo 'href="http://vcrxol.com/_cel/'.$xclaveacc.'.xml"';}?> download="">
								<?php
						 			if($cdisp==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>
						<tr style="font-size:<?php echo $xfontsize-6; ?>px;<?php if($xautornum==""){echo 'display:none;';} ?>">
							<td align="right">AUTORIZACION:</td>
							<td>
								<a target="_blank" 
								<?php if($cdisp==1){echo 'href="https://declaraciones.sri.gob.ec/comprobantes-electronicos-internet/publico/validezComprobantes.jsf"';}?>>
								<?php
						 			if($cdisp==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 if(mysql_result($res_tra1,0,'status')!="-"){ ?>
						<tr>
							<td align="right">STATUS:</td>
							<td style="<?php if(mb_stristr('XO',$xstatus)){echo 'color:red;';} ?>"><?php echo mysql_result($res_tra1,0,'stat_descri');?></td>
						</tr>
						<?php}?>
					</table>
					<?php}?>

					<?php ///// BLOQUE 2 ?>
					<?php{?>
					<div style="font-size:<?php echo $xfontsize-12; ?>px;"><br></div>
					<table border="1" width="100%" cellpadding="2" cellspacing="0" style="border-collapse:collapse;">
						<tr style="border:solid 1px; font-weight:bolder; background: #F7F7F7;">
							<td align="center" colspan=2 ><?php echo 'R E S U M E N'; ?></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>
						<?php if(mb_stristr('vtas.comp.clie.prov', $tabla)){?>
						<tr align="right">
							<td>SUB-TOTAL:</td>
							<td><?php echo number_format($xtsubt,2);?></td>
						</tr>
						<tr align="right" style="<?php if($xpdcto==0){echo 'display:none;';} ?>">
<!-- 							<td >DESCUENTO <?php echo number_format($xpdcto,0)?>%:</td> -->
							<td >DESCUENTO:</td>
							<td><?php echo number_format(mysql_result($res_tra1,0,'tdcto'),2);?></td>
						</tr>
						<tr align="right" style="<?php if($xpice==0){echo 'display:none;';} ?>">
							<td >SUB-TOTAL ICE <?php echo number_format($xpice,0)?>%:</td>
							<td><?php echo number_format(mysql_result($res_tra1,0,'tsubtice'),2);?></td>
						</tr>
						<tr align="right" style="<?php if($xpice==0){echo 'display:none;';} ?>">
							<td >ICE <?php echo number_format($xpice,0)?>%:</td>
							<td><?php echo number_format($xtice,2);?></td>
						</tr>
						<tr align="right">
							<td >SUB-TOTAL IVA 0%:</td>
							<td><?php echo number_format($xtsubtiva0,2);?></td>
						</tr>
						<tr align="right" style="<?php if($xpiva==0){echo 'display:none;';} ?>">
							<td >SUB-TOTAL IVA <?php echo number_format($xpiva,0)?>%:</td>
							<td><?php echo number_format($xtsubtiva,2);?></td>
						</tr>
						<tr align="right" style="<?php if($xpiva==0){echo 'display:none;';} ?>">
							<td >IVA <?php echo number_format($xpiva,0)?>%:</td>
							<td><?php echo number_format($xtiva,2);?></td>
						</tr>
						<tr align="right" style="font-weight:bolder;">
							<td >TOTAL:</td>
							<td><?php echo number_format($xtotal,2);?></td>
						</tr>
						<?php}?>	
					</table>					
					<?php}?>

					<?php ///// BLOQUE 3 ?>
					<?php if(mb_stristr('vtas.comp', $tabla)){?>
					<div style="font-size:<?php echo $xfontsize-12; ?>px;"><br></div>
					<table border="1" width="100%" cellpadding="2" cellspacing="0" style="border-collapse:collapse;">
						<tr style="border:solid 1px; font-weight:bolder; background: #F7F7F7;">
							<td align="center" ><?php echo 'FORMA DE PAGO'; ?></td>
							<td></td>
						</tr>
						<tr style="<?php if($xfpag==0){echo 'display:none;';} ?>">
							<td style="font-size:<?php echo $xfontsize-6; ?>px;"><?php echo mysql_result($res_tra1,0,'fpag_descri') ?></td>
							<td><?php echo number_format(mysql_result($res_tra1,0,'total'),2);?></td>
						</tr>
					</table>					
					<?php}?>

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

<?php //////////////////////////////////////////////////////////	?>
<?php // DETALLE	?>
		<div style="font-size:<?php echo $xfontsize-12; ?>px;"><br></div>
		<table border="0" width="100%" cellpadding="2" cellspacing="0" style="border-collapse:collapse;font-size:<?php echo $xfontsize; ?>px;">
			<tr style="background:#f7f7f7;font-weight:bolder; border-top:solid 1px; "><td>D E T A L L E</td></tr>
		</table>
	
		<table border="0" width="100%" cellpadding="2" cellspacing="0" style="border-collapse:collapse;font-size:<?php echo $xfontsize; ?>px;">
		<tr style="background:#f7f7f7; border-top:solid 1px; border-bottom:solid 1px;">
			<?php if(mb_stristr('vtas.comp.clie.prov.inve.prod',$tabla)){?>
				<th>ITEM</th>
				<th>DESCRIPCION</th>
				<th>CANT.</th>
				<th>UNIT.</th>
				<th>SUBT.</th>
				<?php if(mb_stristr('vtas.comp.clie.prov',$tabla)){?>
					<th style="<?php if($xtdcto==0){echo 'display:none;';}?>">DESC</th>
					<th style="<?php if($xtice==0) {echo 'display:none;';}?>">ICE</th>
					<th style="<?php if($xtiva==0) {echo 'display:none;';}?>">IVA</th>
					<th style="<?php if($xtirbp==0){echo 'display:none;';}?>">IRBP</th>
				<?php}?>
				<th>TOTAL</th>
				<th max-width="50%" style="<?php if($xmdetalle==""){echo 'display:none;';}?> ">DETALLE</th>
			<?php}?>
		</tr>
		<?php 	$res_tra2=mysql_query($sql_tra2,$link_vcrx); ?>
		<?php while($aso_tra2=mysql_fetch_assoc($res_tra2)){?>	
				<?php
				$filax++;
				$duni=$aso_tra2['item_duni'];
				$dval=$aso_tra2['item_dval'];
				if($dval==0){$dval=2;}
				?>
				<tr valign="top" style="<?php if($filax %3==0){echo 'border-bottom:dotted 1px;';} ?>" >
					<?php if(mb_stristr('vtas.comp.clie.prov.inve.prod',$tabla)){?>
					<td align="left"><?php echo $aso_tra2['item'];?></td>
					<td align="left"><?php echo $aso_tra2['item_descri'];?></td>
					<td align="right"><?php echo number_format($aso_tra2['cant'],$duni);?></td>
					<td align="right"><?php echo number_format($aso_tra2['puni'],$dval);?></td>
					<td align="right"><?php echo number_format($aso_tra2['tsubt'],$dval);?></td>
					<td align="right" style="<?php if($xtdcto==0){echo 'display:none;';}?>"><?php echo number_format($aso_tra2['tdcto'],$dval);?></td>
					<td align="right" style="<?php if($xtice==0){echo 'display:none;';}?>"><?php echo number_format($aso_tra2['tice'],$dval);?></td>
					<td align="right" style="<?php if($xtiva==0){echo 'display:none;';}?>"><?php echo number_format($aso_tra2['tiva'],$dval);?></td>
					<td align="right" style="<?php if($xtirbp==0){echo 'display:none;';}?>"><?php echo number_format($aso_tra2['tirbp'],$dval);?></td>
					<td align="right"><?php echo number_format($aso_tra2['total'],$dval);?></td>
					<td align="left" style="<?php if($xmdetalle==""){echo 'display:none;';}?>"><?php echo $aso_tra2['detalle'];?></td>
					<?php}?>	
				</tr>
		<?php}?>	

		<tr style="background:#f7f7f7; border-top:solid 1px; border-bottom:solid 1px; font-weight:bolder;">
			<?php if(mb_stristr('vtas.comp.clie.prov.inve.prod',$tabla)){?>
				<td align="center" colspan=2>T O T A L E S</td>
<!-- 				<td></td> -->
				<td align="right"><?php echo number_format($xtcant,$duni);?></td>
				<td></td>
				<td align="right"><?php echo number_format($xtsubt,$dval);?></td>
				<?php if(mb_stristr('vtas.comp.clie.prov',$tabla)){?>
					<td align="right" style="<?php if($xtdcto==0){echo 'display:none;';}?>"><?php echo number_format($xtdcto,$dval);?></td>
					<td align="right" style="<?php if($xtice==0) {echo 'display:none;';}?>"><?php echo number_format($xtice,$dval);?></td>
					<td align="right" style="<?php if($xtiva==0) {echo 'display:none;';}?>"><?php echo number_format($xtiva,$dval);?></td>
					<td align="right" style="<?php if($xtirbp==0){echo 'display:none;';}?>"><?php echo number_format($xtirbp,$dval);?></td>
				<?php}?>
				<td align="right"><?php echo number_format($xtotal,$dval);?></td>
				<td align="right" style="<?php if($xmdetalle==""){echo 'display:none;';}?>"></td>
			<?php}?>
		</tr>
		</table>
<?php //////////////////////////////////////////////////////////	?>
<?php // PIE DE PAGINA	?>
		<div style="font-size:<?php echo $xfontsize-12; ?>px;"><br></div>
		<table border="0" width="100%" cellpadding="2" cellspacing="0" style="border-collapse:collapse;font-size:<?php echo $xfontsize; ?>px;">
			<tr>
				<?php ///// PIE COLUMNA IZQUIERDA ?>
				<td width=50% valign="top">
					<table border="0" width="100%" cellpadding="2" cellspacing="0" style="border-collapse:collapse;font-size:<?php echo $xfontsize; ?>px;">
					<tr style="background:#f7f7f7; border-top:solid 1px; border-bottom:solid 1px; font-weight:bolder;">
						<th>N O T A S</th>
					</tr>
					<?php if($xambi==2){?>
					<tr>
						<td style="font-size:<?php echo $xfontsize-6; ?>px;">
						ESTA IMPRESION SOLO TIENE FINES INFORMATIVOS Y DE CONSULTA<br>
						ESTA IMPRESION NO TIENE VALIDEZ TRIBUTARIA<br>
						Mas informacion en : <a target="_blank" href="http://www.sri.gob.ec/web/10138/145">PORTAL S.R.I.</a>
						<a target="_blank" href="https://declaraciones.sri.gob.ec/comprobantes-electronicos-internet/publico/validezComprobantes.jsf">VALIDADOR S.R.I.</a>
						</td>
					</tr>
					<?php}?>
					</table>
				</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;">
					<tr>
						<td align="right" style="font-weight:bolder;">
						<?php echo 'SON:'.num2let($xtotal);?>
						</td>
					</tr>
					<tr>
					</tr>
					</table>
				</td>
			</tr>
		</table>
	
		<table border="0" width="100%" cellpadding="2" cellspacing="0" style="border-collapse:collapse;font-size:<?php echo $xfontsize; ?>px;">
			<tr style="font-size:<?php echo $xfontsize-6; ?>px; border-top:solid 1px; border-bottom:solid 1px;">
				<td width="33%">
				<?php echo 'ID:'.$idnum;?>
				</td>
				<td width="34%" align="center">
<!-- 				<a target="_blank" href="http://www.vcrxol.com">WWW.VCRXOL.COM _ SISTEMAS ON-LINE</a> -->
				</td>
				<td width="33%" align="right" >
				<?php echo 'IMPRESO POR:';?>
				<?php //echo '<br>';?>
				<?php echo r_fiel('enti',$user_cedula,'nom1').' '.r_fiel('enti',$user_cedula,'ape1');?>
				<?php echo '<br>'; ?>
				<?php echo date('d/M/y H:i:s');?>
				</td>
			</tr>
		</table>
		
		
	</div>	
	<br>
	<?php $xfontsize=$printsize; ?>
	<?php } ?>
	
</body>
<?php //////////////////////////////////////////////////////////	?>

</html>




<?php	
$docuhtml = ob_get_clean(); 
$docuhtml=alltrim($docuhtml);
file_put_contents($rutadoc.$docu.'_'.str_pad($idnum,9,"0",STR_PAD_LEFT).'.html',$docuhtml);
if(substr($xclaveacc,10,13)==$cfg_ruc)
{file_put_contents($rutace.$xclaveacc.'.html',$docuhtml);}
// else
// {file_put_contents($rutace.$xclaveacc.'.html',$docuhtml);}
return $docuhtml;	
}
?>