<?php
// ini_set('display_errors',1);
require_once('../../libreriasphp/html2pdf/_tcpdf_5.9.206/tcpdf.php');
date_default_timezone_set('America/Lima');
session_start();
require_once ("../../config/Cado.php");
require_once ("../../app/compra/cCompra.php");
$oCompra = new cCompra();
require_once ("../../app/empresa/cEmpresa.php");
$oEmpresa = new cEmpresa();
require_once ("../../app/venta/cVenta.php");
$oVenta = new cVenta();
require_once ("../../app/notacredito/cNotacredito.php");
$oNotacredito = new cNotacredito();
require_once("../../app/tipocambio/cTipocambio.php");
$oTipocambio = new ctipocambio();
$fec = date('Y-m-d');
require_once ("../../app/formatos/formato.php");
require_once ("../../app/formatos/fechas.php");
$dts=$oEmpresa->mostrarUno(1);
$dt = mysqli_fetch_array($dts);
	$emp_ruc=$dt['tb_empresa_ruc'];
	$emp_nomcom=$dt['tb_empresa_nomcom'];
	$emp_razsoc=$dt['tb_empresa_razsoc'];
	$emp_dir=$dt['tb_empresa_dir'];
	$emp_dir2=$dt['tb_empresa_dir2'];
	$emp_tel=$dt['tb_empresa_tel'];
	$emp_ema=$dt['tb_empresa_ema'];
	$emp_fir=$dt['tb_empresa_fir'];		
mysqli_free_result($dts);
$dtsid=$oEmpresa->mostrarUno(3);
$dtid = mysqli_fetch_array($dtsid);
	$emp_rucid=$dtid['tb_empresa_ruc'];
	$emp_nomcomid=$dtid['tb_empresa_nomcom'];
	$emp_razsocid=$dtid['tb_empresa_razsoc'];
	$emp_dirid=$dtid['tb_empresa_dir'];
	$emp_dir2id=$dtid['tb_empresa_dir2'];
	$emp_telid=$dtid['tb_empresa_tel'];
	$emp_emaid=$dtid['tb_empresa_ema'];
	$emp_firid=$dtid['tb_empresa_fir'];		
mysqli_free_result($dtsid);
$fec=date('d-m-Y');
	
	
	
	
	
	
	$dts1 =	$oCompra->mostrar_xperiodo($_GET['mes'],$_GET['anio'],'1');
	while($dt = mysqli_fetch_array($dts1)){
				
	if($dt['tb_moneda_id']==2){
	$rs = $oTipocambio->consultar(fecha_mysql($dt['tb_compra_fec']));  
	$r = mysqli_fetch_array($rs);	
	$tipcam = formato_money3($r['tb_tipocambio_dolsun']);
	}
	else{
	$tipcam = '1.00';	
	}
	
	$totvalvenvf += $dt['tb_compra_valven'] * $tipcam;
	$totigvvf += $dt['tb_compra_igv'] * $tipcam;
	$totvf += $dt['tb_compra_tot'] * $tipcam;
		
	}
	
	
	
	//NOTAS DE CREDITOO
	$tot = 0;
	 
	$dts1 =	$oNotacredito->mostrar_xperiodo($_GET['mes'],$_GET['anio'],'1');
	while($dt = mysqli_fetch_array($dts1)){
				
	if($dt['tb_moneda_id']==2){
	$rs = $oTipocambio->consultar(fecha_mysql($dt['tb_compra_fec']));  
	$r = mysqli_fetch_array($rs);	
	$tipcam = formato_money3($r['tb_tipocambio_dolsun']);
	}
	else{
	$tipcam = '1.00';	
	}
	
	$tot += $dt['tb_notacredito_tot'] * $tipcam;
	
	}
	
	$totvfnc = $tot;
	$totvalvenvfnc = $totvfnc / 1.18;
	$totigvvfnc = $totvalvenvfnc * 0.18;	
	
	
	//// VENTAAAAAAAS
	
	$tot = 0;
	
	$dts1 =	$oVenta->mostrar_xperiodo($_GET['mes'],$_GET['anio'],'1');
	while($dt = mysqli_fetch_array($dts1)){
		if($dt['tb_venta_estsun']==2){
			$tot +=0;
		}else{
			
	if($dt['tb_moneda_id']==2){
	$rs = $oTipocambio->consultar(fecha_mysql($dt['tb_compra_fec']));  
	$r = mysqli_fetch_array($rs);	
	$tipcam = formato_money3($r['tb_tipocambio_dolsun']);
	}
	else{
	$tipcam = '1.00';	
	}
		
	
	
	$tot += $dt['tb_venta_tot'] * $tipcam;
		}
		
	}
	
	$totvfv = $tot - $totvfnc;
	$totvalvenvfv = $totvfv / 1.18;
	$totigvvfv = $totvalvenvfv * 0.18;
	
	
	$tot = 0;
	
 $difvfvalven = $totvalvenvf - $totvalvenvfv;
 $difvfigv = $totigvvf - $totigvvfv;
 $difvftot = $totvf - $totvfv;
 
 $difjvvalven = $totvalvenjv - $totvalvenjvv;
 $difjvigv = $totigvjv - $totigvjvv;
 $difjvtot = $totjv - $totjvv;
 
 $difidvalven = $totvalvenid - $totvalvenidv;
 $difidigv = $totigvid - $totigvidv;
 $difidtot = $totid - $totidv;
	
	
	
 $i = $_GET['mes'];
    	                                                if($i=='01'){
															$lblmes = 'Enero';
														}else if($i=='02'){
															$lblmes = 'Febrero';
														}else if($i=='03'){
															$lblmes = 'Marzo';
														}else if($i=='04'){
															$lblmes = 'Abril';
														}else if($i=='05'){
															$lblmes = 'Mayo';
														}else if($i=='06'){
															$lblmes = 'Junio';
														}else if($i=='07'){
															$lblmes = 'Julio';
														}else if($i=='08'){
															$lblmes = 'Agosto';
														}else if($i=='09'){
															$lblmes = 'Septiembre';
														}else if($i=='10'){
															$lblmes = 'Octubre';
														}else if($i=='11'){
															$lblmes = 'Noviembre';
														}else if($i=='12'){
															$lblmes = 'Diciembre';
														}	
	
	
$title = "REPORTE | CONTABLE CONSOLIDADAS IGV - ".$fec;
$nombre_archivo = 'REPORTE | CONTABLE CONSOLIDADAS IGV '.$fec.'.pdf';
// $file_name = 'FA-'.$serie.'-'.$numero.'-code.png';
// $path = 'temp/'.$file_name;
// $type = pathinfo($path, PATHINFO_EXTENSION);
// $data = file_get_contents($path);
// $base64 = 'data:image/' . $type . ';base64,' . base64_encode($data);
class MYPDF extends TCPDF
{
    public function Header() {	
      //$image_file = K_PATH_IMAGES.'logo.jpg';
      //$this->Image($image_file, 20, 10, 71, '', 'JPG', '', 'T', false, 300, '', false, false, 0, false, false, false);
      // Set font
      //$this->SetFont('helvetica', 'B', 20);
      // Title
      //$this->Cell(0, 15, '<< TCPDF Example 003 >>', 0, false, 'C', 0, '', 0, false, 'M', 'M');
    }
    public function Footer() 
    {
       $style = array(
        'position' => 'L',
        'align' => 'L',
        'stretch' => false,
        'fitwidth' => true,
        'cellfitalign' => '',
        'border' => false,
        'padding' => 0,
        'fgcolor' => array(0,0,0),
        'bgcolor' => false,
        'text' => false
      //     'font' => 'helvetica',
      //     'fontsize' => 8,
      //     'stretchtext' => 4
      );
      $this -> SetY(-12);
      // Page number
      $this->SetFont('helvetica', '', 9);
      //$this->SetTextColor(0,0,0);
      $this->Cell(0, 0, 'Página '.$this->getAliasNumPage().' de '.$this->getAliasNbPages(), 'T', 1, 'R', 0, '', 0, false, 'T', 'M');
      
      $codigo='CAV-'.str_pad($_GET['d1'], 4, "0", STR_PAD_LEFT);
      
    
      $this->Cell(0, 0, 'SERVICIOS Y SISTEMAS INFORMATICOS DEL PERU', 0, 1, 'C', 0, '', 0, false, 'T', 'M');      
    }
}
// create new PDF document
$pdf = new MYPDF(PDF_PAGE_ORIENTATION, PDF_UNIT, PDF_PAGE_FORMAT, true, 'UTF-8', false);
$pdf->SetCreator(PDF_CREATOR);
$pdf->SetAuthor('www.infosisperu.com');
$pdf->SetTitle($title);
$pdf->SetSubject('www.infosisperu.com');
$pdf->SetKeywords('www.infosisperu.com');
// set header and footer fonts
$pdf->setHeaderFont(Array(PDF_FONT_NAME_MAIN, '', PDF_FONT_SIZE_MAIN));
$pdf->setFooterFont(Array(PDF_FONT_NAME_DATA, '', PDF_FONT_SIZE_DATA));
// set default monospaced font
$pdf->SetDefaultMonospacedFont(PDF_FONT_MONOSPACED);
//set margins
$pdf->SetMargins(12, 15, 12);// left top right
$pdf->SetHeaderMargin(PDF_MARGIN_HEADER);
//$pdf->SetFooterMargin(PDF_MARGIN_FOOTER);
//set auto page breaks
$pdf->SetAutoPageBreak(TRUE, 15);
//set image scale factor
$pdf->setImageScale(PDF_IMAGE_SCALE_RATIO);
//set some language-dependent strings
$pdf->setLanguageArray($l);
// ---------------------------------------------------------
// add a page
$pdf->AddPage('P', 'A4');
//font-family: Consolas, monaco, monospace;
//helvetica, monaco, monospace;
// Introducimos HTML de prueba
$html = '
<!DOCTYPE html>
<html lang="es">
<head>
    <meta http-equiv="Content-Type" content="text/html;charset=utf-8"/>
	<link rel="shortcut icon" href="../../admin/bootstrap/images/favicon.png">
	
</head>
<style type="text/css">
    body {
        color: black;
        font-family: Verdana, Arial, Consolas;
        font-size: 7.5pt;
    }
    .header_row th {
		font-size:28px;
		background-color:#eee;
        border-bottom: 0.9px solid #010101;
        border-right: 0.9px solid #010101;
        border-left: 0.9px solid #010101;
        border-top: 0.9px solid #010101;
    }
    .odd_row td {
        background-color: transparent;
        border-bottom: 0.9px solid #010101;
        padding-top: 5px;
        padding-bottom: 5px;
    }
    .even_row td {
        padding-top: 5px;
        padding-bottom: 5px;
        background-color: #f6f6f6;
        border-bottom: 0.9px solid #010101;
    }
    .row td{
        border-right: 0.9px solid #010101;
        border-left: 0.9px solid #010101;
    }
	
	
	
	div#div_tabla {  }
	div#div_tabla table { border-collapse: collapse; width: 100%; }
	div#div_tabla table td, div#div_tabla table th { border: 1px solid #eee;font-family:arial; font-size:25px; }
	div#div_tabla table th { height:18px;font-size:20px; }
	div#div_tabla table td { height:17px;font-size:20px; }
	
</style>
<style media="print">
    .oculto{
        display: none;
    }
</style>
<body>
<table style="width: 100%; margin-bottom: 10px">
	<tr>
	<td width="22%">
	<img src="../../imagenes/logo1.png" alt="" />
	</td>
        <td style="text-align:center;" width="50%">
		<br />
		<br />
            <strong style="font-size:40px">'.$emp_razsoc.'</strong>
			<br>
            '.$emp_dir.'<br />   <strong>Telf.: '.$emp_tel.'  E-mail.: '.$emp_ema.'</strong> 
			<br />       
		</td>  		
	    <td style="text-align: center;border-top-style:solid;border-right-style:solid;border-bottom-style:solid;border-left-style:solid;padding:2px;" width="30%">
		<br />
		<br />
		<br />
		   <strong style="font-size: 40px">CONTABLE IGV<br>'.$lblmes.' | '.$_GET['anio'].'</strong>
        </td>
    </tr>
</table>
<br />
<br />		
';
 
	$html.='
	<div id="div_tabla">
		<table id="tabla_resumen_todos" width="100%" style="font-size:11px;" class="">
			<tr class="header_row" style="font-weight:bold;font-size:16px;">
				<th class="bg-yellow"  style="background-color:#ffca28;"  colspan = "3" >COMPRAS</th>
				<th class="bg-green"   style="background-color:#26a69a;" colspan = "3"  >VENTAS</th>
				<th class="bg-blue"  style="background-color:#29b6f6;"  colspan = "3" >DIFERENCIAS</th>
				<th class="bg-red"  style="background-color:#ef5350;" colspan = "2" >IGV TOTAL</th>
			</tr>
			
			<tr class="header_row" style="font-weight:bold;font-size:16px;">
				<th>VAL. IMP. GRAB.</th>
				<th>IGV</th>
				<th>TOTAL</th>
				<th>VAL. IMP. GRAB.</th>
				<th>IGV</th>
				<th>TOTAL</th>
				<th>VAL. IMP. GRAB.</th>
				<th>IGV</th>
				<th>TOTAL</th>
				<th>ANTERIOR</th>
				<th>TOTAL</th>	
			</tr>
		  
		  
		  
		  <tr  >			
			<td nowrap align="right" >'.formato_money($totvalvenvf).'</td>			
			<td nowrap align="right" >'.formato_money($totigvvf) .'</td>			
			<td nowrap align="right" >'.formato_money($totvf) .'</td>	
			<td nowrap align="right" >'.formato_money($totvalvenvfv) .'</td>			
			<td nowrap align="right" >'.formato_money($totigvvfv) .'</td>			
			<td nowrap align="right" >'.formato_money($totvfv) .'</td>
			<td nowrap align="right" >'.formato_money($difvfvalven) .'</td>			
			<td nowrap align="right" >'.formato_money($difvfigv) .'</td>			
			<td nowrap align="right" >'.formato_money($difvftot) .'</td>	
										
			</tr>	
		</table> 
	  </div> ';
	 
	  
	  
	  
	  if($_GET['vista']==1){
		  
		$html.='
		<div id="div_tabla">
			<table>
		<tr class="header_row">
		<th colspan="8" style="background-color:#0d47a1;color:#fff;"  >DETALLES DE COMPRAS</th>
		</tr>
		
		 <tr class="header_row" >
                <th width="60" class="" >FECHA</th>
                <th width="100" >DOCUMENTO</th>                    
                <th width="250" >PROVEEDOR</th>             
                <th width="67.5" >RUC</th>                  
                <th width="58" NOWRAP class="" align="right">VALOR</th>
                <th width="58" NOWRAP class="" align="right">IGV</th>
                <th width="58" NOWRAP class="" align="right">TOTAL</th>
        </tr>
		';
		
		 
		$dtc1 = $oCompra->mostrar_detalle_agru($_GET['mes'],$_GET['anio']);
		while($dtc = mysqli_fetch_array($dtc1)){
		
		$dtc1d = $oCompra->mostrar_detalle_des($_GET['mes'],$_GET['anio'],$dtc['empid']);
		while($dt = mysqli_fetch_array($dtc1d)){
		
		 $i = $dt['tb_compra_permes'];
    	                                                if($i=='01'){
															$lblmes = 'Enero';
														}else if($i=='02'){
															$lblmes = 'Febrero';
														}else if($i=='03'){
															$lblmes = 'Marzo';
														}else if($i=='04'){
															$lblmes = 'Abril';
														}else if($i=='05'){
															$lblmes = 'Mayo';
														}else if($i=='06'){
															$lblmes = 'Junio';
														}else if($i=='07'){
															$lblmes = 'Julio';
														}else if($i=='08'){
															$lblmes = 'Agosto';
														}else if($i=='09'){
															$lblmes = 'Septiembre';
														}else if($i=='10'){
															$lblmes = 'Octubre';
														}else if($i=='11'){
															$lblmes = 'Noviembre';
														}else if($i=='12'){
															$lblmes = 'Diciembre';
														}
														
		if($dt['tb_moneda_id']== 2){
				$rs = $oTipocambio->consultar(fecha_mysql($dt['tb_compra_fec']));  
				$r = mysqli_fetch_array($rs);	
				$tipcam = formato_money3($r['tb_tipocambio_dolsun']);
		}
		else{
				$tipcam = '1.00';	
		}
		
		$valvenc = 0;
		$igvc = 0;
		$totc = 0;
		
		
		$valvenc = $dt['tb_compra_valven'] * $tipcam;
		$igvc = $dt['tb_compra_igv'] * $tipcam;
		$totc = $dt['tb_compra_tot'] * $tipcam;
		
		//if($dt['tb_empresa_id'] == 2){
			//echo $totc;
		//}
		
		
		$totalc  += $totc; 
		$igvtotalc  += $igvc; 
		$valventotalc  += $valvenc; 
		
		$html .='
		<tr>
		<td nowrap="nowrap">'. mostrarFecha($dt['tb_compra_fec']).'</td>
        <td >  '. $dt['tb_documento_abr'].' - '.$dt['tb_compra_numdoc'].'</td>
        <td NOWRAP >'. $dt['tb_proveedor_nom'].'</td>
		<td  nowrap="nowrap">'. $dt['tb_proveedor_doc'].'</td>
		 <td NOWRAP align="right">'.''.formato_money($valvenc).'</td>
		 <td NOWRAP align="right">'.''.formato_money($igvc).'</td>
		 <td NOWRAP align="right">'.''.formato_money($totc).'</td>
		</tr>
		';
		
		
		} 
		$html.='
		<tr class="bg-blue" style="background-color:#b2dfdb;" >
		<td colspan="4" align="left">'.$dtc['emp'].'</td>
		<td NOWRAP align="right" >'.formato_money($valventotalc).'</td>
		<td NOWRAP align="right" >'.formato_money($igvtotalc).'</td>
		<td NOWRAP align="right" >'.formato_money($totalc).'</td>
		</tr>
		';
				
		$totalc  = 0;
		$igvtotalc  = 0;
		$valventotalc  = 0;
		}
		
		
		mysqli_free_result($dtc1);
		$html .='</table>
		</div>
		' ; 		  
	  }
	  	  
	    
	  if($_GET['vista']==1){
		  
		$html.='
		<div id="div_tabla">
		<table>
		<tr class="header_row" >
		<th colspan="8" style="background-color:#007E33;color:#fff;" >DETALLES DE VENTAS</th>
		</tr>
		
		 <tr class="header_row" >
                <th width="60" class="" >FECHA</th>
                <th width="100" >DOCUMENTO</th>                    
                <th width="250" >CLIENTE</th>             
                <th width="67.5" >RUC</th>    
                <th width="58" NOWRAP class="" align="right">VALOR</th>
                <th width="58" NOWRAP class="" align="right">IGV</th>
                <th width="58" NOWRAP class="" align="right">TOTAL</th>
        </tr>
		';
		
		$dtc1 = $oVenta->mostrar_detalle_agru($_GET['mes'],$_GET['anio'],''); 
		while($dtc = mysqli_fetch_array($dtc1)){
		
		$dtc1d = $oVenta->mostrar_detalle_des($_GET['mes'],$_GET['anio'],$dtc['empid']);
		while($dt = mysqli_fetch_array($dtc1d)){
			
			if($dt['tb_venta_estsun']==2){
			$valvenv = 0;
			$igvv = 0;
			$totv = 0;
		}else{
		
		if($dt['tb_moneda_id']==2){
				$rs = $oTipocambio->consultar(fecha_mysql($dt['tb_venta_fec']));  
				$r = mysqli_fetch_array($rs);	
				$tipcam = formato_money3($r['tb_tipocambio_dolsun']);
		}
		else{
				$tipcam = '1.00';	
		}
		
		
		$valvenv = 0;
		$igvv = 0;
		$totv = 0;
		
		$valvenv = $dt['tb_venta_valven'] * $tipcam;
		$igvv = $dt['tb_venta_igv'] * $tipcam;
		$totv = $dt['tb_venta_tot'] * $tipcam;
		}
		
		$totalv  += $totv; 
		$igvtotalv  += $igvv; 
		$valventotalv  += $valvenv; 
		
		
		$html .='
		<tr>
		<td  nowrap="nowrap">'. mostrarFecha($dt['tb_venta_fec']).'</td>
        <td  >  '. $dt['tb_documento_abr'].' - '.$dt['tb_venta_numdoc'].'</td>
        <td NOWRAP >'. $dt['tb_cliente_nom'].'</td>
		<td  nowrap="nowrap">'. $dt['tb_cliente_doc'].'</td>
		 <td  NOWRAP align="right">'.''.formato_money($valvenv).'</td>
		 <td  NOWRAP align="right">'.''.formato_money($igvv).'</td>
		 <td  NOWRAP align="right">'.''.formato_money($totv).'</td>
		</tr>
		';
		
		
		} 
		$html.='
		<tr class="bg-blue" style="background-color:#b2dfdb;" >
		<td colspan="4" align="left">'.$dtc['emp'].'</td>
		<td NOWRAP align="right" >'.formato_money($valventotalv).'</td>
		<td NOWRAP align="right" >'.formato_money($igvtotalv).'</td>
		<td NOWRAP align="right" >'.formato_money($totalv).'</td>
		</tr>
		';
				
		$totalv  = 0;
		$igvtotalv  = 0;
		$valventotalv  = 0;
		}
		
		
		mysqli_free_result($dtc1);
		$html .='</table>
		
		
		
		
		
		
		
		
		
		
		</div>
		' ; 		  
	  }
	  
	  
	  
	  
	  
	  
	    if($_GET['vista']==1){
		  
		$html.='
		<div id="div_tabla">
		<table>
		<tr class="header_row" >
		<th colspan="8" style="background-color:#CC0000;color:#fff;" >DETALLES DE NOTAS DE CREDITO</th>
		</tr>
		
		 <tr class="header_row" >
                <th width="60" class="" >FECHA</th>
                <th width="100" >DOCUMENTO</th>                    
                <th width="250" >CLIENTE</th>             
                <th width="67.5" >RUC</th>           
                <th width="58" NOWRAP class="" align="right">VALOR</th>
                <th width="58" NOWRAP class="" align="right">IGV</th>
                <th width="58" NOWRAP class="" align="right">TOTAL</th>
        </tr>
		';
		
		$dtc1 = $oNotacredito->mostrar_detalle_agru($_GET['mes'],$_GET['anio']); 
		while($dtc = mysqli_fetch_array($dtc1)){
		
		$dtc1d = $oNotacredito->mostrar_detalle_des($_GET['mes'],$_GET['anio'],$dtc['tb_empresa_id']);
		while($dt = mysqli_fetch_array($dtc1d)){
		
		if($dt['tb_moneda_id']==2){
				$rs = $oTipocambio->consultar(fecha_mysql($dt['tb_notacredito_fec']));  
				$r = mysqli_fetch_array($rs);	
				$tipcam = formato_money3($r['tb_tipocambio_dolsun']);
		}
		else{
				$tipcam = '1.00';	
		}
		
		
		$valvenv = 0;
		$igvv = 0;
		$totv = 0;
		
		$totv = $dt['tb_notacredito_tot'] * $tipcam;	
		$valvenv = $totv/1.18;
		$igvv = $valvenv* 0.18;
		
		$totalv  += $totv; 
		$igvtotalv  += $igvv; 
		$valventotalv  += $valvenv; 
		
		
		$html .='
		<tr>
		<td  nowrap="nowrap">'. mostrarFecha($dt['tb_notacredito_fec']).'</td>
        <td >  '. $dt['tb_documento_abr'].' - '.$dt['tb_notacredito_numdoc'].'</td>
        <td  NOWRAP >'. $dt['tb_cliente_nom'].'</td>
		<td  nowrap="nowrap">'. $dt['tb_cliente_doc'].'</td>
		 <td  NOWRAP align="right">'.''.formato_money($valvenv).'</td>
		 <td  NOWRAP align="right">'.''.formato_money($igvv).'</td>
		 <td  NOWRAP align="right">'.''.formato_money($totv).'</td>
		</tr>
		';
		
		
		} 
		$html.='
		<tr class="bg-blue" style="background-color:#b2dfdb;" >
		<td colspan="4" align="left">'.$dtc['tb_empresa_razsoc'].'</td>
		<td NOWRAP align="right" >'.formato_money($valventotalv).'</td>
		<td NOWRAP align="right" >'.formato_money($igvtotalv).'</td>
		<td NOWRAP align="right" >'.formato_money($totalv).'</td>
		</tr>
		';
				
		$totalv  = 0;
		$igvtotalv  = 0;
		$valventotalv  = 0;
		}
		
		
		mysqli_free_result($dtc1);
		$html .='</table>
		
		
		
		
		
		
		
		
		
		
		</div>
		' ; 		  
	  }
	  
	  
	  
	  
	   
	  
	  
	  
	  
	  
$html.='
<br />
<br />
<br />
</body>
</html>';
$pdf->writeHTML($html, true, 0, true, true);
//$pdf->write2DBarcode($ruc_empresa.'|'.$idcomprobante.'|'.$serie.'|'.$numero.'|'.$toigv.'|'.$importetotal.'|'.fecha_mysql($fecha).'|'.$idtipodni.'|'.$ruc.'|', 'QRCODE,Q', 157, 99, 40, 40, $style, 'N');
$pdf->Output($nombre_archivo, 'I');
set_time_limit (3000);
?>