<?php

include ("../conexion.php");
    
require_once '../dompdf/autoload.inc.php';


require_once '../dompdf/lib/html5lib/Parser.php';
require_once '../dompdf/lib/php-font-lib/src/FontLib/Autoloader.php';
require_once '../dompdf/lib/php-svg-lib/src/autoload.php';
require_once '../dompdf/src/Autoloader.php';
Dompdf\Autoloader::register();

use Dompdf\Dompdf;

    
	
  $where     = "";
	


$codigoHTML='

<!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">





<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>Lista</title>

</head>

   <script type="text/php">


        if ( isset($pdf) ) {

          $font = Font_Metrics::get_font("helvetica", "bold");
          $pdf->page_text(72, 18, "Header: {PAGE_NUM} of {PAGE_COUNT}", $font, 6, array(0,0,0));

        }
        
</script>
<body>
<div align="center">
  <p>&nbsp;</p>';
  
    
       $parametros = "SELECT * FROM web_0000 ";
       $result_parametros = $mysqli->query($parametros);
       $row_para = $result_parametros->fetch_array();
     
	   $NombreComercial =  $row_para["NOMCOM"];
	   $razsoc          =  $row_para["RAZSOC"];
	   $Direccion       =  $row_para["DIREMP"];
	   $Cedula          =  $row_para["CEDJUR"];
	   $Telefono        =  $row_para["NUMTEL"];
	   
	   
				$subexepro = "0";
				$subgrapro = "0";
				$subpro    = "0";
				$desprotot = "0";
				$imppro    = "0";
				$flepro    = "0";
				$otrpro    = "0";
				$totpro    = "0";



 
$codigoHTML='
    <table width="100%"  cellpadding="0" cellspacing="0"  border="0">
      <tr>
        <td width="13%" rowspan="4"><img src="../img/logo.jpg"  /></td>
        <td width="87%"><font color="red" size=4><strong>'.$NombreComercial.'</strong></font></td>
      </tr>
      <tr>
        <td height="12"><font size=2 >Cedula Juridica '.$Cedula.'</font></td>
      </tr>
      <tr>
        <td height="12"><font size=2 >'.$Direccion.'</font></td>
      </tr>
      <tr>
        <td height="22"><font size=2 >Numero de Telefono '.$Telefono.'</font></td>
      </tr>
    </table>';
  
   
 	 $fecini    = $_GET["fechainicio"];
	 $fecfin    = $_GET["fechafin"];
	 $cdgtipven = $_GET["combotipoventa"];
	 $cdgcli    = $_GET["cdgcli"];
	 	
$fechainicio = implode("-", array_reverse(explode("-", $fecini))); 
$fechafin    = implode("-", array_reverse(explode("-", $fecfin))); 

	$where="1=1";
if ($cdgtipven <> "") { $where.=" AND  facturas.cdgtipven='$cdgtipven'"; }
if ($cdgcli <> "") { $where.=" AND  facturas.cdgcli='$cdgcli'"; }

if (($fechainicio<>"") and ($fechafin<>"")) {
	$where.=" AND facturas.fecha between '".$fechainicio."' AND '".$fechafin."'";
} else {
	if ($fechainicio<>"") {
		$where.=" and  facturas.fecha >='".$fechainicio."'";
	} else {
		if ($fechafin<>"") {
			$where.=" and  facturas.fecha <='".$fechafin."'";
		}
	}
}

 $fechainicio= implode("-", array_reverse(explode("-", $fecini))); 
 $fechafin= implode("-", array_reverse(explode("-", $fecfin))); 
	 
//$where.=" ORDER BY fecha ASC";					
		
 if ($cdgcli=="") {
	   
	   	$dsccli="TODOS LOS CLIENTES";
	 
	     } else {

	 
	   $query_codcaj="SELECT * FROM web_0301 WHERE cdgcli=$cdgcli ";
       $resultado = $mysqli->query( $query_codcaj);
       $row = $resultado->fetch_array();
        
		 $dsccli    = $row["DSCCLI"];
	
     }
		
	 
	 $codigoHTML.='
  <table width="100%" height="16%" border="1" cellpadding="0" cellspacing="0" >
      <tr>
      <td width="100%" height="21" colspan="3" align="center"><font size=3 ><strong>Reporte Analitico de '.$dsccli.' </strong></font></td>
      </tr>
      <tr>
        <td height="14" colspan="3" align="center">Fecha del <font size="2" >'.$fecini.'</font> al <font size="2" >'.$fecfin.'</font></td>
      </tr>
  </table>
  ';
	
	
	 $codigoHTML.='
<table width="100%" role="rows" cellpadding="0" cellspacing="0" border="1">
    <tr>
    
        <td width="38%" align="center"bgcolor="#CCCCCC" ><font size=1 ><strong>Factura</strong></font></td>
        <td width="16%" align="center" bgcolor="#CCCCCC" ><font size=1 ><strong>Fecha</strong></font></td>
		<td width="5%" align="center" bgcolor="#CCCCCC"><font size=1 ><strong>Plazo</strong></font></td>
        <td width="17%" align="right" bgcolor="#CCCCCC"><font size=1 ><strong>Sub.Exento </strong></font></td> 
	    <td width="17%" align="right" bgcolor="#CCCCCC"><font size=1 ><strong>Sub.Gravado </strong></font></td>
	    <td width="17%" align="right" bgcolor="#CCCCCC"><font size=1 ><strong>Subtotal </strong></font></td>
        <td width="17%" align="right" bgcolor="#CCCCCC"><font size=1 ><strong>Descuento </strong></font></td>
		<td width="17%" align="right" bgcolor="#CCCCCC"><font size=1 ><strong>Impuesto </strong></font></td>
        <td width="17%" align="right" bgcolor="#CCCCCC"><font size=1 ><strong>Total </strong></font></td>
 
    </tr>
  </table>';
        
		  
                 
				   
				      //////////////////////////////////////  Agrupado por codigo de cliente DIFERENTE  a 9999 /////////////////////////////////////////////// 
		 
		if ( ( $cdgcli<>9999 ) || ( $cdgcli=="" )  )  { 
			

	$sel_resultado="SELECT  *  FROM facturas,web_0301 WHERE facturas.cdgcli=web_0301.CDGCLI AND facturas.borrado=0 AND facturas.cdgcli <> 9999  AND ".$where. "  ORDER BY facturas.dsccli,facturas.fecha ASC " ;
		if ($resultado3 = $mysqli->query($sel_resultado)) 		
		if($dato = $resultado3->fetch_assoc()){ 
      	$cdgcli_actual = $dato['cdgcli']; } 
      	$count     = 0;	
	    $contador=0;	
		if ($resultado2 = $mysqli->query($sel_resultado)) 		  
  		while ($dato1 = $resultado2->fetch_assoc()) {     //  si encuentra datos
		
				$codfactura = $dato1['codfactura'];
				$numfactura = $dato1['numfactura'];
				$fecha      = $dato1['fecha'];
 				$fecha      = implode("-", array_reverse(explode("-", $fecha))); 		
				$cdgcli     = $dato1['cdgcli'];
				$cdgcli     = sprintf('%04d',$cdgcli) ;
				$dsccli     = $dato1['dsccli'];
				$dsccli     = substr($dsccli, 0, 45);
				$pladia     = $dato1['pladia'];
				$totalfactura = $dato1['totalfactura'];
				$subtot     = $dato1['subtot'];
				$impven     = $dato1['impven'];
				$destot     = $dato1['destot'];		

	
	      if ($contador==0){     //   coloca enzabezado al primer codigo  //


  $codigoHTML.='
  <table width="100%"  rules="none" border="0">
    
      <tr>
		<td width="38%"> <strong><font size=1 >'.$cdgcli.' - '.$dsccli.'</font></strong></td>
   	    <td width="16%">  <font size=1 align="right"></font></td>
		<td width="5%" align="center">  <font size=1 ></font></td>
        <td width="17%" align="right">  <font size=1 ></font></td>
		<td width="17%" align="right">  <font size=1 ></font></td>
		<td width="17%" align="right">  <font size=1 ></font></td>
        <td width="17%" align="right">  <font size=1 ></font></td>
		<td width="17%" align="right">  <font size=1 ></font></td>
		<td width="17%" align="right">  <font size=1 ></font></td>
	  </tr>

      
  </table>';


 } 


		    if($count == 0   )		
                $codigoHTML.='<table width="100%"  rules="none" border="0">';
				

							
			if ($cdgcli <>  $cdgcli_actual  ){   

				 $cdgcli_actual  = $dato1['cdgcli'];
				 
				 
				 $codigoHTML.='
     
      <tr>
	  	<td width="18%">  <font size=1 ></font></td>
   	    <td width="18%">  <font size=1 align="right"></font></td>
		<td width="5%" align="center">  <font size=1 ></font></td>
		<td width="20%" align="right">  <strong><font size=1 >_______________</font></strong></td>
		<td width="20%" align="right">  <strong><font size=1 >_______________</font></strong></td>
		<td width="20%" align="right">  <strong><font size=1 >_______________</font></strong></td>
 		<td width="20%" align="right">  <strong><font size=1 >_______________</font></strong></td>
		<td width="20%" align="right">  <strong><font size=1 >_______________</font></strong></td>
		<td width="20%" align="right">  <strong><font size=1 >_______________</font></strong></td>
      </tr>

      <tr>
	  	<td width="38%">  <font size=1 ></font></td>
   	    <td width="16%">  <font size=1 align="right"></font></td>
		<td width="5%" align="center">  <font size=1 ></font></td>
		<td width="17%" align="right">  <strong><font size=1 >'.number_format($subexepro, 2).'</font></strong></td>
        <td width="17%" align="right">  <strong><font size=1 >'.number_format($subgrapro, 2).'</font></strong></td>
	    <td width="17%" align="right">  <strong><font size=1 >'.number_format($subpro, 2).'</font></strong></td>
        <td width="17%" align="right">  <strong><font size=1 >'.number_format($desprotot, 2).'</font></strong></td>
		<td width="17%" align="right">  <strong><font size=1 >'.number_format($imppro, 2).'</font></strong></td>
		<td width="17%" align="right">  <strong><font size=1 >'.number_format($totpro, 2).'</font></strong></td>
      </tr>


    
      <tr>
		<td width="38%"> <strong><font size=1 >'.$cdgcli.' - '.$dsccli.'</font></strong></td>
   	    <td width="16%">  <font size=1 align="right"></font></td>
		<td width="5%" align="center">  <font size=1 ></font></td>
        <td width="17%" align="right">  <font size=1 ></font></td>
		<td width="17%" align="right">  <font size=1 ></font></td>
		<td width="17%" align="right">  <font size=1 ></font></td>
        <td width="17%" align="right">  <font size=1 ></font></td>
		<td width="17%" align="right">  <font size=1 ></font></td>
		<td width="17%" align="right">  <font size=1 ></font></td>
	</tr>';

      


				$subexepro = "0";
				$subgrapro = "0";
				$subpro    = "0";
				$desprotot = "0";
				$imppro    = "0";
				$flepro    = "0";
				$otrpro    = "0";
				$totpro    = "0";
				
				
			 } 
				
		
				 
				$subexe        = $dato1['subexe'];
				$subgra        = $dato1['subgra'];
				$pladia        = $dato1['pladia'];
				$totalfactura  = $dato1['totalfactura'];
				$subtot        = $dato1['subtot'];
				$impven        = $dato1['impven'];
				$destot        = $dato1['destot'];		
				
				$subexepro  = $subexepro+$subexe;
				$subgrapro  = $subgrapro+$subgra;
				$subpro     = $subpro+$subtot;
				$desprotot  = $desprotot+$destot;
				$imppro     = $imppro+$impven;
				$totpro     = $totpro+$totalfactura;
			
			

	$codigoHTML.='
   
    
      <tr>
        <td width="38%">  <font size=1 >'.$numfactura.'</font></td>
   	    <td width="16%">  <font size=1 align="right">'.$fecha.'</font></td>
		<td width="5%" align="center">  <font size=1 >'.$pladia.'</font></td>
        <td width="17%" align="right">  <font size=1 >'.number_format($subexe, 2).'</font></td>
		<td width="17%" align="right">  <font size=1 >'.number_format($subgra, 2).'</font></td>
		<td width="17%" align="right">  <font size=1 >'.number_format($subtot, 2).'</font></td>
        <td width="17%" align="right">  <font size=1 >'.number_format($destot, 2).'</font></td>
		<td width="17%" align="right">  <font size=1 >'.number_format($impven, 2).'</font></td>
		<td width="17%" align="right">  <font size=1 >'.number_format($totalfactura, 2).'</font></td>
      </tr>';


	    $contador++;
  	        
	  $count++;
       }
	   
	   
   
        if($count > 1) 
            $codigoHTML.='</table>';
			

       }
                                           //    totaliza el ultimo codigo //
   $codigoHTML.='  
<table width="100%" role="rows" cellpadding="0" cellspacing="0" >
     <tr>
	  	<td width="18%">  <font size=1 ></font></td>
   	    <td width="18%">  <font size=1 align="right"></font></td>
		<td width="5%" align="center">  <font size=1 ></font></td>
		<td width="20%" align="right">  <strong><font size=1 >_______________</font></strong></td>
		<td width="20%" align="right">  <strong><font size=1 >_______________</font></strong></td>
		<td width="20%" align="right">  <strong><font size=1 >_______________</font></strong></td>
 		<td width="20%" align="right">  <strong><font size=1 >_______________</font></strong></td>
		<td width="20%" align="right">  <strong><font size=1 >_______________</font></strong></td>
		<td width="20%" align="right">  <strong><font size=1 >_______________</font></strong></td>
      </tr>

      <tr>
	  	<td width="38%">  <font size=1 ></font></td>
   	    <td width="16%">  <font size=1 align="right"></font></td>
		<td width="5%" align="center">  <font size=1 ></font></td>
		<td width="17%" align="right">  <strong><font size=1 >'.number_format($subexepro, 2).'</font></strong></td>
        <td width="17%" align="right">  <strong><font size=1 >'.number_format($subgrapro, 2).'</font></strong></td>
	    <td width="17%" align="right">  <strong><font size=1 >'.number_format($subpro, 2).'</font></strong></td>
        <td width="17%" align="right">  <strong><font size=1 >'.number_format($desprotot, 2).'</font></strong></td>
		<td width="17%" align="right">  <strong><font size=1 >'.number_format($imppro, 2).'</font></strong></td>
		<td width="17%" align="right">  <strong><font size=1 >'.number_format($totpro, 2).'</font></strong></td>
      </tr>
  </table>';
			         /////////////////////////////////   cierra llave de if doble condicion cdgcli diferente a  9999 
		 
		
		
     //////////////////////////////////////  Agrupado por codigo de cliente igual  a 9999 /////////////////////////////////////////////// 
		
   $cdgcli=$_GET["cdgcli"]; 
		if ( ( $cdgcli==9999 ) || ( $cdgcli=="" )  )  { 

				 
				 
		$sel_resultado="SELECT  *  FROM facturas,web_0301 WHERE facturas.cdgcli=web_0301.cdgcli AND facturas.borrado=0 AND facturas.cdgcli = 9999  AND ".$where. "  ORDER BY facturas.dsccli,facturas.fecha ASC " ;		
			if ($resultado3 = $mysqli->query($sel_resultado)) 		
		if($dato = $resultado3->fetch_assoc()){ 
      	$dsccli_actual = $dato['dsccli']; } 
        $count =0;
	    $contador=0;	
		if ($resultado2 = $mysqli->query($sel_resultado)) 		  
  		while ($dato1 = $resultado2->fetch_assoc()) {     //  si encuentra datos
		
		
				$codfactura = $dato1['codfactura'];
				$numfactura = $dato1['numfactura'];
				$fecha      = $dato1['fecha'];
 				$fecha      = implode("-", array_reverse(explode("-", $fecha))); 		
				$cdgcli     = $dato1['cdgcli'];
				$cdgcli     = sprintf('%04d',$cdgcli) ;
				$dsccli     = $dato1['dsccli'];
				$dsccli     = substr($dsccli, 0, 45);
				$pladia     = $dato1['pladia'];
				$totalfactura = $dato1['totalfactura'];
				$subtot     = $dato1['subtot'];
				$impven     = $dato1['impven'];
				$destot     = $dato1['destot'];		
			 
				 	

          if ($contador==0){       //   coloca enzabezado al primer codigo  //


  $codigoHTML.='
  <table width="100%"  rules="none" border="0">    
    
      <tr>
		<td width="38%"> <strong><font size=1 >'.$cdgcli.' - '.$dsccli.'</font></strong></td>
   	    <td width="16%">  <font size=1 align="right"></font></td>
		<td width="5%" align="center">  <font size=1 ></font></td>
        <td width="17%" align="right">  <font size=1 ></font></td>
		<td width="17%" align="right">  <font size=1 ></font></td>
		<td width="17%" align="right">  <font size=1 ></font></td>
        <td width="17%" align="right">  <font size=1 ></font></td>
		<td width="17%" align="right">  <font size=1 ></font></td>
		<td width="17%" align="right">  <font size=1 ></font></td>
      </tr>

      
  </table>';


 } 

	    if($count == 0   )		
                $codigoHTML.='<table width="100%"  rules="none" border="0">';
				
							
			if ($dsccli <>  $dsccli_actual  ){ 
	
				 $dsccli_actual =  $dato1['dsccli'];
				 
				 
				 $codigoHTML.='



      <tr>
	  	<td width="18%">  <font size=1 ></font></td>
   	    <td width="18%">  <font size=1 align="right"></font></td>
		<td width="5%" align="center">  <font size=1 ></font></td>
		<td width="20%" align="right">  <strong><font size=1 >_______________</font></strong></td>
		<td width="20%" align="right">  <strong><font size=1 >_______________</font></strong></td>
		<td width="20%" align="right">  <strong><font size=1 >_______________</font></strong></td>
 		<td width="20%" align="right">  <strong><font size=1 >_______________</font></strong></td>
		<td width="20%" align="right">  <strong><font size=1 >_______________</font></strong></td>
		<td width="20%" align="right">  <strong><font size=1 >_______________</font></strong></td>
      </tr>
      <tr>
	  	<td width="38%">  <font size=1 ></font></td>
   	    <td width="16%">  <font size=1 align="right"></font></td>
		<td width="5%" align="center">  <font size=1 ></font></td>
		<td width="17%" align="right">  <strong><font size=1 >'.number_format($subexepro, 2).'</font></strong></td>
        <td width="17%" align="right">  <strong><font size=1 >'.number_format($subgrapro, 2).'</font></strong></td>
	    <td width="17%" align="right">  <strong><font size=1 >'.number_format($subpro, 2).'</font></strong></td>
        <td width="17%" align="right">  <strong><font size=1 >'.number_format($desprotot, 2).'</font></strong></td>
		<td width="17%" align="right">  <strong><font size=1 >'.number_format($imppro, 2).'</font></strong></td>
		<td width="17%" align="right">  <strong><font size=1 >'.number_format($totpro, 2).'</font></strong></td>
      </tr>
 
      <tr>
		<td width="38%"> <strong><font size=1 >'.$cdgcli.' - '.$dsccli.'</font></strong></td>
   	    <td width="16%">  <font size=1 align="right"></font></td>
		<td width="5%" align="center">  <font size=1 ></font></td>
        <td width="17%" align="right">  <font size=1 ></font></td>
		<td width="17%" align="right">  <font size=1 ></font></td>
		<td width="17%" align="right">  <font size=1 ></font></td>
        <td width="17%" align="right">  <font size=1 ></font></td>
		<td width="17%" align="right">  <font size=1 ></font></td>
		<td width="17%" align="right">  <font size=1 ></font></td>
      </tr>';
  
  				$subexepro = "0";
				$subgrapro = "0";
				$subpro    = "0";
				$desprotot = "0";
				$imppro    = "0";
				$flepro    = "0";
				$otrpro    = "0";
				$totpro    = "0";

				
			 } 
				

				
				$subexe        = $dato1['subexe'];
				$subgra        = $dato1['subgra'];
				$pladia        = $dato1['pladia'];
				$totalfactura  = $dato1['totalfactura'];
				$subtot        = $dato1['subtot'];
				$impven        = $dato1['impven'];
				$destot        = $dato1['destot'];	
				
				$subexepro  = $subexepro+$subexe;
				$subgrapro  = $subgrapro+$subgra;
				$subpro     = $subpro+$subtot;
				$desprotot  = $desprotot+$destot;
				$imppro     = $imppro+$impven;
				$totpro     = $totpro+$totalfactura;
			
			

				

$codigoHTML.='
 
      <tr>
        <td width="38%">  <font size=1 >'.$numfactura.'</font></td>
   	    <td width="16%">  <font size=1 align="right">'.$fecha.'</font></td>
		<td width="5%" align="center">  <font size=1 >'.$pladia.'</font></td>
        <td width="17%" align="right">  <font size=1 >'.number_format($subexe, 2).'</font></td>
		<td width="17%" align="right">  <font size=1 >'.number_format($subgra, 2).'</font></td>
		<td width="17%" align="right">  <font size=1 >'.number_format($subtot, 2).'</font></td>
        <td width="17%" align="right">  <font size=1 >'.number_format($destot, 2).'</font></td>
		<td width="17%" align="right">  <font size=1 >'.number_format($impven, 2).'</font></td>
		<td width="17%" align="right">  <font size=1 >'.number_format($totalfactura, 2).'</font></td>
      </tr>';

   $contador++;
  	        
	  $count++;
       }
   
        if($count > 1) 
            $codigoHTML.='</table>';
			
	

       }
 
		 
		 
		  ///////////////////  cierra el if de condicion cdgcli = a 9999  y a  ""  ////////////////////////////////////////////////////////
		 
		  
        ///////////////////////////////////    calcula totales de todo el reporte //////////////////////////////////////////////////
		 
	

$consulta= ("SELECT SUM(totalfactura) AS total , SUM(subtot) AS subtot, SUM(destot) AS descuento , SUM(impven) AS impuesto , SUM(subexe) AS subexento, SUM(subgra) AS subgravado FROM facturas WHERE borrado=0 AND ".$where );
		if ($resultado = $mysqli->query($consulta)) 

  		while ($dato = $resultado->fetch_assoc()) {

				$subexento    = $dato["subexento"];
				$subgravado   = $dato["subgravado"];
				$subtot       = $dato["subtot"];
				$descuento    = $dato["descuento"];
				$impuesto     = $dato["impuesto"];
				$total        = $dato["total"];
			 } 
	 
				 $codigoHTML.='
<table width="100%" role="rows" cellpadding="0" cellspacing="0" >
       <tr>
	  	<td width="18%">  <font size=1 ></font></td>
   	    <td width="18%">  <font size=1 align="right"></font></td>
		<td width="5%" align="center">  <font size=1 ></font></td>
		<td width="20%" align="right">  <strong><font size=1 >_______________</font></strong></td>
		<td width="20%" align="right">  <strong><font size=1 >_______________</font></strong></td>
		<td width="20%" align="right">  <strong><font size=1 >_______________</font></strong></td>
 		<td width="20%" align="right">  <strong><font size=1 >_______________</font></strong></td>
		<td width="20%" align="right">  <strong><font size=1 >_______________</font></strong></td>
		<td width="20%" align="right">  <strong><font size=1 >_______________</font></strong></td>
      </tr>

      <tr>
	  	<td width="38%">  <font size=1 ></font></td>
   	    <td width="16%">  <font size=1 align="right"></font></td>
		<td width="5%" align="center">  <font size=1 ></font></td>
		<td width="17%" align="right">  <strong><font size=1 >'.number_format($subexepro, 2).'</font></strong></td>
        <td width="17%" align="right">  <strong><font size=1 >'.number_format($subgrapro, 2).'</font></strong></td>
	    <td width="17%" align="right">  <strong><font size=1 >'.number_format($subpro, 2).'</font></strong></td>
        <td width="17%" align="right">  <strong><font size=1 >'.number_format($desprotot, 2).'</font></strong></td>
		<td width="17%" align="right">  <strong><font size=1 >'.number_format($imppro, 2).'</font></strong></td>
		<td width="17%" align="right">  <strong><font size=1 >'.number_format($totpro, 2).'</font></strong></td>
      </tr>

      
  </table>';
  	
	
$codigoHTML.='
   <table width="100%" height="15" role="rows" cellpadding="0" cellspacing="0" border="1">
     <tr>
       <td height="15"><table width="100%" border="0" cellpadding="0" cellspacing="0">
         <tr>
            <td width="59%" height="12" align="left"><strong><font size=2 > TOTALES FINALES</font></strong></td>
              <td width="17%" align="right"><strong><font size=1 >'.number_format($subexento, 2).'</font></strong></td>
			  <td width="17%" align="right"><strong><font size=1 >'.number_format($subgravado, 2).'</font></strong></td>
              <td width="17%" align="right"><strong><font size=1 >'.number_format($subtot, 2).'</font></strong></td>
               <td width="17%" align="right"><strong><font size=1 >'.number_format($descuento, 2).'</font></strong></td>
			  <td width="17%" align="right"><strong><font size=1 >'.number_format($impuesto, 2).'</font></strong></td>
		      <td width="17%" align="right"><strong><font size=1 >'.number_format($total, 2).'</font></strong></td>
         </tr>
       </table></td>
     </tr>
   </table>
   <p>';
   
    
$codigoHTML.='

   </p>

</div>
</body>
</html>';

$codigoHTML=utf8_decode($codigoHTML);
$dompdf=new DOMPDF();
$dompdf->set_paper( "A4", "landscape" ); // a4,horizontal
$dompdf->load_html($codigoHTML);
$dompdf->render();
// add the header
//$canvas = $dompdf->get_canvas();
//$font = Font_Metrics::get_font("helvetica", "bold");
//
//// the same call as in my previous example
//$canvas->page_text(745, 555, "Pagina : {PAGE_NUM} de {PAGE_COUNT}",
//                   $font, 8, array(0,0,0));

ini_set("memory_limit","7000M");

$dompdf->stream("Reporte_ventas_D151.pdf", array("Attachment" => false));
 


?>
