<?php
$resol=mysqli_query($con,"SELECT * FROM serie_factura where ser_estado='activo' and ser_tipo='electronica' and ser_tipo_documento='1' and empresa='$empresa'") or die(mysqli_error($con)); 
$res=mysqli_fetch_array($resol);
$result = mysqli_num_rows($resol);
$ser_inicio=$res['ser_inicio'];
$ser_resolucion=$res['ser_resolucion'];
$ser_fecha=$res['ser_fecha'];
$ser_fin=$res['ser_fin'];
$ser_fecha_ven=$res['ser_fecha_ven'];

$to=0;
$query=mysqli_query($con,"SELECT * , DATE_FORMAT(`ven_fecha`,'%d-%m-%Y') as ven_fecha FROM ventas where ven_id='$ven_id' and empresa='$empresa' ");
$roww=mysqli_fetch_array($query);
$ven_cc=$roww['ven_cc'];
$estado_dian=$roww['estado_dian'];

$Cliente_clie_id=$roww['Cliente_clie_id'];
$ven_nombre=$roww['ven_nombre'];
$ven_telefono=$roww['ven_telefono'];
$ven_fecha=$roww['ven_fecha'];
$ven_estado=$roww['ven_estado'];
$ven_prefijo=$roww['ven_prefijo']; 
$ven_n_venta=$roww['ven_n_venta']; 
$ven_forma_de_pago=$roww['ven_forma_de_pago'];
$ven_dias=$roww['ven_dias'];
$cufe=$roww['cufe'];
$vendedor=$roww['vendedor'];
$ven_tipo=$roww['ven_tipo'];
$observaciones=$roww['observaciones'];

$dir=mysqli_query($con,"SELECT * FROM cliente where clie_id='$Cliente_clie_id'") or die(mysqli_error($con)); 
$dire=mysqli_fetch_array($dir);
$clie_direccion=$dire['clie_direccion'];
$clie_correo=$dire['clie_correo'];
$clie_ciudad=$dire['clie_ciudad'];

$ciu=mysqli_query($api,"SELECT * from municipalities where id='$clie_ciudad'");
$ciud=mysqli_fetch_array($ciu);
$name=$ciud['name'];

$sql3=mysqli_query($con,"SELECT * from usuario where usu_id='$vendedor'");
$usu=mysqli_fetch_array($sql3);
$usu_nombre=$usu['usu_nombre'];

$vence = strtotime($ven_fecha."+ ".$ven_dias." days");
                date("Y-m-d",$vence) . "\n";
                $fecha=date('Y-m-d ');

$hasta=date("d-m-Y",$vence) . "\n";

         
$total_articulos=0;
$sumador_combo=0;
$sumador_total=0;
$neto=0;
$descuento_global=0;
$iva_global=0;
$retencion_global=0;

$ret=mysqli_query($con, "SELECT * FROM retencion_venta where ventas_ven_id='$ven_id' ") or die(mysqli_error($con)); 
$rets=mysqli_fetch_array($ret);
$ret_porcentaje=$rets['porcentaje'];

$sqli=mysqli_query($con, "SELECT COUNT(*) AS items from venta_detalle where ventas_ven_id='$ven_id'");
$rowi=mysqli_fetch_array($sqli);
$items=$rowi['items'];

$sql=mysqli_query($con, "SELECT * from venta_detalle where ventas_ven_id='$ven_id'");
while ($row=mysqli_fetch_array($sql))
{
    
    $vend_referencia=$row['vend_referencia'];
    $vend_nombre=$row['vend_nombre'];
    $vend_cantidad=$row['vend_cantidad'];
    //$vend_precio=$row['vend_precio']; //1.000.000
    $vend_precio1=$row['vend_precio']; //1.000.000
    $vend_iva=$row['vend_iva']; //19%
    $vend_descuento=$row['vend_desc']; //10%

    $suma_por_retencion=(($vend_precio1*$ret_porcentaje)/(100-$ret_porcentaje));
    $vend_precio=$vend_precio1+$suma_por_retencion; //1.000.000

    $iva0=$vend_iva/100; //0.19
    $iva1=1+$iva0; //1.19

    $precio_unitario_sin_iva=$vend_precio/$iva1;  //840.336
    $precio_total_sin_iva=$precio_unitario_sin_iva*$vend_cantidad;
    $descuento_unitario=($vend_descuento/100)*$precio_unitario_sin_iva;  //84033
    $descuento_item=$descuento_unitario*$vend_cantidad;  //84033
    $neto_item=$precio_total_sin_iva;
    $iva_item=($vend_precio-$precio_unitario_sin_iva)*$vend_cantidad;
    $neto+=$precio_total_sin_iva;
    $descuento_global+=$descuento_item;
    $iva_global+=$iva_item;

    $retencion_unitaria=(($precio_unitario_sin_iva)*($ret_porcentaje/100));
    $retencion_item=$retencion_unitaria*$vend_cantidad; 
    $retencion_global+=$retencion_item;
}
$sumador_total=($neto+$iva_global)-$descuento_global;


$sumador_combo=0;
$sql2=mysqli_query($con, "SELECT * from venta_detalle_combo where ven_id='$ven_id'");
while ($row2=mysqli_fetch_array($sql2))
{

    $precio=($row2['combo_cantidad']*$row2['combo_precio']);
    $sumador_combo+=$precio;
}
$total_factura=$sumador_total+$sumador_combo;



$dir = '../../temp/';
if (!file_exists($dir))
    mkdir($dir);
$filename = $dir.'test.png';
$numfac=$ven_prefijo.$ven_n_venta;//numero de factura
$fecfac=$ven_fecha;//fecha de facturas
$nitfac=$emp_nit;//nit de empresa
$docadq=$ven_cc;//documento del clienta
$valfac=round($neto,2);//neto
$valiva=round($iva_global,2);//iva
$valotroim=round($descuento_global,2);//descuento
$valfaclm=round($sumador_total,2);//total
$cufe=$cufe;//cufe
$tamaño = 10; //Tamaño de Pixel
$level = 'L'; //Precisión Baja
$framSize = 3; //Tamaño en blanco
$contenido = 'NumFac: '.$numfac.PHP_EOL.'FecFac: '.$fecfac.PHP_EOL.'NitFac: '.$nitfac.PHP_EOL.'DocAdq: '.$docadq.PHP_EOL.'ValFac: '.$valfac.PHP_EOL.'ValIva: '.$valiva.PHP_EOL.'ValOtroIm: '.$valotroim.PHP_EOL.'ValTotal: '.$valfaclm.PHP_EOL.'CUFE: '.$cufe.PHP_EOL.'https://catalogo-vpfe.dian.gov.co/document/searchqr?documentkey='.$cufe; //Texto

QRcode::png($contenido, $filename, $level, $tamaño, $framSize); 
$qr=$dir.basename($filename);





$sql_re=mysqli_query($con, "SELECT count(*) from venta_detalle where ventas_ven_id='$ven_id'");
$row_client = mysqli_fetch_row($sql_re);
 $nb_page = $row_client[0];

$sql_re=mysqli_query($con, 'SELECT abs(FLOOR(-' . $nb_page . '/10))');
$row_client = mysqli_fetch_row($sql_re);
$nb_page = $row_client[0];

$num_page = 1; 
$limit_inf = 0; 
$limit_sup = 10;


While ($num_page <= $nb_page)
{

?>
<page backtop="1mm" backbottom="5mm" backleft="5mm" backright="5mm" style="font-size: 11pt; font-family: arial" >
     <table cellspacing="0" style="width: 100%;" >
        <tr>
            <td style="width: 33%; color: #444444;">
                <img style="width: 80%;" src="../../../img/<?php echo $empresa;?>.png" alt="Logo"><br>
            </td>
			<td style="width: 34%; font-size:12px;text-align:center;">
				<strong style="font-size:15px"><?php echo $emp_nombre;?></strong><br>
				<strong>Nit: <?php echo $emp_nit;?></strong> <br>
				<strong><?php echo $emp_direccion;?></strong><br>
				<strong><?php echo $emp_correo;?></strong><br>
				<strong>Tel: <?php echo $emp_cel;?> / <?php echo $emp_telefono;?></strong><br>
				<!--<strong>Responsable de IVA </strong><br> 
				<strong>Agente de retención en el impuesto sobre las ventas</strong>-->
			</td>
			<td style="width: 21%;"></td>
			<?php if($estado_dian=='Aprobada'){?>
			<td style="width: 12%;"><img style="width: 100%;" align="right" src="<?php echo $qr; ?>" alt="Logo"></td>
		    <?php } ?>
        </tr>
    </table>
    <div style="text-align: center;font-size:9px;padding-bottom:0px;">
		<p><?php echo $texto_cabeza; ?></p>
	</div>
	<?php if($ven_tipo=='electronica'){?>
		<div style="text-align: right;font-size:8px;padding-bottom:0px;"><p>Resolucion de Facturación Electronica No. <?php echo $ser_resolucion; ?> de <?php echo $ser_fecha; ?>, Rango <?php echo $ser_inicio; ?> Al <?php echo $ser_fin; ?> - Vigencia Desde: <?php echo $ser_fecha ?> Hasta: <?php echo $ser_fecha_ven; ?></p></div>
	<?php } else {?>
		<hr style="display: block;height: 1px;border: 1px solid #bdc3c7;">
 	<?php } ?>	
 	<table cellspacing="0" style="width: 100%;" >
        <tr>
            <td style="width: 70%;">
                <table cellspacing="0">
                    <tr>
                        <td style="background-color:#bdc3c7;padding:2px;text-align:center;"> 
                            <strong style="font-size:10px;color: #000" >DATOS DEL CLIENTE</strong>
                        </td>
                    </tr>
					
					<tr>
						<td style="width: 100%;text-align:left;border:solid 1px #bdc3c7;font-size:10px ;padding-left: 15px"> 
							<p style="padding:-10px;"><strong>NOMBRE: </strong><?php echo $ven_nombre;?></p>
							<p style="padding:-10px;"><strong>DOCUMENTO: </strong><?php echo $ven_cc;?></p>
							<p style="padding:-10px;"><strong>DIRECCION: </strong><?php echo $clie_direccion;?> <?php echo mb_strtoupper($name);?></p>
							<p style="padding:-10px;"><strong>TELEFONO: </strong><?php echo $ven_telefono;?></p>
							<p style="padding:-10px;"><strong>CORREO: </strong><?php echo mb_strtoupper($clie_correo);?></p>
							<p style="padding:-10px;"><strong>FORMA DE PAGO: </strong><?php echo mb_strtoupper($ven_forma_de_pago);?></p>
						</td>
					</tr>
			    </table>
            </td>
			<td style="width: 30%;">
				<table cellspacing="0" style="width: 100%; padding-left:5px">
			        <tr>
						<td style="width: 100%;color:white;background-color:#bdc3c7;padding:2px;text-align:center"> 
							<strong style="font-size:10px;color: #000" >FACTURA DE VENTA N°</strong>
						</td>
					</tr>
					<tr>
						<td style="width: 100%;padding:2px;text-align:center;border:solid 1px #bdc3c7;font-size:12px"> 
							<strong style="color: red"><?php echo $ven_prefijo;echo $ven_n_venta;?></strong>
						</td>
					</tr>
			    </table>
			    <table cellspacing="0" style="width: 100%;padding-left: 5px; padding-top: 5px;">
					<tr>
						<td style="width: 100%;text-align:left;border:solid 1px #bdc3c7;font-size:10px ;padding-left: 15px;"> 
							<p style="padding:-10px;"><strong>FECHA FACTURACION: </strong><?php echo $ven_fecha;?></p>
							<p style="padding:-10px;"><strong>FECHA VENCIMIENTO: </strong><?php echo $hasta;?></p>
							<p style="padding:-10px;"><strong>VENDEDOR: </strong><?php echo $usu_nombre;?></p>
						</td>
					</tr>
			    </table>
			</td>
		</tr>
    </table>



	<table cellspacing="0" style="width: 100%; padding-top: 5px;">
        <tr>
			<td style="width: 10%;color:white;background-color:#bdc3c7;padding:2px;text-align:center"> 
				<strong style="font-size:10px;color: #000">REF</strong>
			</td>
			<td style="width: 5%; color:white;background-color:#bdc3c7;padding:2px;text-align:center"> 
				<strong style="font-size:10px;color: #000">CANT</strong>
			</td>
			<td style="width: 5%; color:white;background-color:#bdc3c7;padding:2px;text-align:center"> 
				<strong style="font-size:10px;color: #000">GTIA</strong>
			</td>
			<td style="width: 50%; color:white;background-color:#bdc3c7;padding:2px;text-align:center"> 
				<strong style="font-size:10px;color: #000">DESCRIPCIÓN</strong>
			</td>
			<td style="width: 8%; color:white;background-color:#bdc3c7;padding:2px;text-align:center"> 
				<strong style="font-size:10px;color: #000">PRECIO U</strong>
			</td>
			<td style="width: 6%; color:white;background-color:#bdc3c7;padding:2px;text-align:center"> 
				<strong style="font-size:10px;color: #000">IVA %</strong>
			</td>
			<td style="width: 7%; color:white;background-color:#bdc3c7;padding:2px;text-align:center"> 
				<strong style="font-size:10px;color: #000">DESC %</strong>
			</td>
			<td style="width:9%; color:white;background-color:#bdc3c7;padding:2px;text-align:center"> 
				<strong style="font-size:10px;color: #000">TOTAL</strong>
			</td>
		</tr>
<?php
$suma=0;



$ret=mysqli_query($con, "SELECT * FROM retencion_venta where ventas_ven_id='$ven_id' ") or die(mysqli_error($con)); 
$rets=mysqli_fetch_array($ret);
$ret_porcentaje=$rets['porcentaje'];

$sql=mysqli_query($con, "SELECT count(*) filas from venta_detalle where ventas_ven_id='$ven_id'  LIMIT  ".$limit_inf." , ".$limit_sup."");

$row1=mysqli_fetch_array($sql);
 $filas=$row1['filas'];
 $resta=10-$filas;

$sql=mysqli_query($con, "SELECT * from venta_detalle where ventas_ven_id='$ven_id'  LIMIT  ".$limit_inf." , ".$limit_sup."  ");
while ($row=mysqli_fetch_array($sql))
{
    
    $vend_id=$row['vend_id'];
    $vend_art_id=$row['vend_art_id'];
    $vend_referencia=$row['vend_referencia'];
    $vend_nombre=$row['vend_nombre'];
    $vend_cantidad=$row['vend_cantidad'];
    //$vend_precio=$row['vend_precio']; //1.000.000
    $vend_precio1=$row['vend_precio']; //1.000.000
    $vend_iva=$row['vend_iva']; //19%
    $vend_descuento=$row['vend_desc']; //10%
    $suma+=$row['vend_cantidad'];

    $suma_por_retencion=(($vend_precio1*$ret_porcentaje)/(100-$ret_porcentaje));
    $vend_precio=$vend_precio1+$suma_por_retencion; //1.000.000

    $iva0=$vend_iva/100; //0.19
    $iva1=1+$iva0; //1.19

    $precio_unitario_sin_iva=$vend_precio/$iva1;  //840.336
    $precio_total_sin_iva=$precio_unitario_sin_iva*$vend_cantidad;
    $descuento_unitario=($vend_descuento/100)*$precio_unitario_sin_iva;  //84033
    $descuento_item=$descuento_unitario*$vend_cantidad;  //84033
    $neto_item=$precio_total_sin_iva;
    $iva_item=($vend_precio-$precio_unitario_sin_iva)*$vend_cantidad;


    $gar=mysqli_query($con,"SELECT * FROM articulos where art_id='$vend_art_id' and empresa='$empresa'") ;
    $gar=mysqli_fetch_array($gar);

?>		
		<tr>
			<td style="width:10%;padding:2px;text-align:center;border-left:solid 1px #bdc3c7; border-bottom:solid 1px #bdc3c7;font-size:9px"> 
				<?php echo $vend_referencia;?>
			</td>
			<td style="width:5%;padding:2px;text-align:center;border-left:solid 1px #bdc3c7; border-bottom:solid 1px #bdc3c7;font-size:9px"> 
				<?php echo $vend_cantidad;?>
			</td>
			<td style="width:5%;padding:2px;text-align:center;border-left:solid 1px #bdc3c7; border-bottom:solid 1px #bdc3c7;font-size:9px"> 
				<?php echo $gar['art_garantia'];?>
			</td>
			<td style="width: 50%;padding:2px;text-align:left;border-left:solid 1px #bdc3c7; border-bottom:solid 1px #bdc3c7;font-size:9px"> 
				<?php echo $vend_nombre;?>
				<?php 
				$sql4=mysqli_query($con,"SELECT * from seriales where venta_detalle_vend_id='$vend_id'");
				$result4=mysqli_num_rows($sql4);
				if($result4>0)
				{ 
					echo '(- ';
					while ($row4=mysqli_fetch_array($sql4))
					{
						echo $row4['ser_codigo'];
						echo ' - ';
					}
					echo ')';
				}
				?>
			</td>
			<td style="width:8%;padding:2px;text-align:right;border-left:solid 1px #bdc3c7; border-bottom:solid 1px #bdc3c7;font-size:9px"> 
				<?php echo number_format($precio_unitario_sin_iva,0);?>
			</td>
			<td style="width:6%;padding:2px;text-align:center;border-left:solid 1px #bdc3c7; border-bottom:solid 1px #bdc3c7;font-size:9px"> 
				<?php echo $vend_iva;?>
			</td>
			<td style="width:7%;padding:2px;text-align:center;border-left:solid 1px #bdc3c7; border-bottom:solid 1px #bdc3c7;font-size:9px"> 
				<?php echo $vend_descuento;?>
			</td>
			<td style="width: 9%;padding:2px;text-align:right;border-left:solid 1px #bdc3c7;border-right:solid 1px #bdc3c7; border-bottom:solid 1px #bdc3c7;font-size:9px"> 
				<?php echo number_format($precio_total_sin_iva,0);?>
			</td>
		</tr>
<?php }  		

?>

<?php
    $sumador_combo1=0;
    $sql2=mysqli_query($con, "SELECT * from venta_detalle_combo where ven_id='$ven_id'");
    while ($row2=mysqli_fetch_array($sql2))
        {

            $precio=($row2['combo_cantidad']*$row2['combo_precio']);
            $sumador_combo1+=$precio;
?>
       <tr>
			<td style="width:10%;padding:2px;text-align:center;border-left:solid 1px #bdc3c7; border-bottom:solid 1px #bdc3c7;font-size:9px"> 
				<?php //echo $row2['combo_nombre']; ?>
			</td>
			
			<td style="width:5%;padding:2px;text-align:center;border-left:solid 1px #bdc3c7; border-bottom:solid 1px #bdc3c7;font-size:9px"> 
				<?php echo $row2['combo_cantidad'];?>
			</td>
			<td style="width: 5%;padding:2px;text-align:left;border-left:solid 1px #bdc3c7; border-bottom:solid 1px #bdc3c7;font-size:9px"> 
				
			</td>
			<td style="width:50%;padding:2px;text-align:left;border-left:solid 1px #bdc3c7; border-bottom:solid 1px #bdc3c7;font-size:9px"> 
				<?php echo $row2['combo_nombre'];?>
			</td>
			<td style="width:8%;padding:2px;text-align:right;border-left:solid 1px #bdc3c7; border-bottom:solid 1px #bdc3c7;font-size:9px"> 
				<?php echo number_format($row2['combo_precio'],0);?>
			</td>
			<td style="width:6%;padding:2px;text-align:center;border-left:solid 1px #bdc3c7; border-bottom:solid 1px #bdc3c7;font-size:9px"> 
				<?php //echo $vend_iva;?>
			</td>
			<td style="width:7%;padding:2px;text-align:center;border-left:solid 1px #bdc3c7; border-bottom:solid 1px #bdc3c7;font-size:9px"> 
				<?php echo $row2['combo_desc'];?>
			</td>
			<td style="width: 9%;padding:2px;text-align:right;border-left:solid 1px #bdc3c7;border-right:solid 1px #bdc3c7; border-bottom:solid 1px #bdc3c7;font-size:9px"> 
				<?php echo number_format($precio,0);?>
			</td>
		</tr>
<?php }
?>
<?php 


for($x=0; $x<$resta; $x++) 
{
?>

     <tr>
			<td style="width:10%;padding:2px;text-align:center;border-left:solid 1px #bdc3c7; border-bottom:solid 1px #bdc3c7;font-size:9px"> 
				<br>
			</td>

			<td style="width:5%;padding:2px;text-align:center;border-left:solid 1px #bdc3c7; border-bottom:solid 1px #bdc3c7;font-size:9px"> 
			</td>

			<td style="width:5%;padding:2px;text-align:center;border-left:solid 1px #bdc3c7; border-bottom:solid 1px #bdc3c7;font-size:9px"> 
			</td>

			<td style="width: 50%;padding:2px;text-align:left;border-left:solid 1px #bdc3c7; border-bottom:solid 1px #bdc3c7;font-size:9px"> 
			</td>

			<td style="width:8%;padding:2px;text-align:right;border-left:solid 1px #bdc3c7; border-bottom:solid 1px #bdc3c7;font-size:9px"> 
			</td>

			<td style="width:6%;padding:2px;text-align:center;border-left:solid 1px #bdc3c7; border-bottom:solid 1px #bdc3c7;font-size:9px"> 
			</td>

			<td style="width:7%;padding:2px;text-align:center;border-left:solid 1px #bdc3c7; border-bottom:solid 1px #bdc3c7;font-size:9px"> 
			</td>

			<td style="width: 9%;padding:2px;text-align:right;border-left:solid 1px #bdc3c7;border-right:solid 1px #bdc3c7; border-bottom:solid 1px #bdc3c7;font-size:9px"> 
			</td>
		</tr>

<?php } ?>

		<tr>
			<td style="width: 10%;padding:2px;text-align:center;border-left:solid 1px #bdc3c7;border-bottom:solid 1px #bdc3c7;font-size:8px">Total Articulos</td>
			<td style="width: 5%;padding:2px;text-align:center;border-left:solid 1px #bdc3c7;border-bottom:solid 1px #bdc3c7;font-size:8px"><?php echo $suma; ?></td>
			<td colspan="6" style="width: 10%;padding:2px;text-align:center;border-left:solid 1px #bdc3c7;border-right:solid 1px #bdc3c7; border-bottom:solid 1px #bdc3c7;font-size:8px"></td>
		</tr>
    </table>


    <table cellspacing="0" style="width: 100%;padding-top: 5px;">
        <tr>
            <td style="width: 64%;">
            	<table cellspacing="0" style="width: 100%;">
			        <tr>
						<td style="width: 100%;color:white;background-color:#bdc3c7;padding:2px;text-align:center;"> 
							<strong style="font-size:10px;color: #000" >OBSERVACIONES</strong>
						</td>
					</tr>
				
					<tr>
						<td style="width: 100%;border-left:solid 1px #bdc3c7;border-bottom:solid 1px #bdc3c7;border-right:solid 1px #bdc3c7;"><strong style="font-size:8px;"><?php echo $observaciones;?> </strong>
						</td>
					</tr>
					<tr>
						<td>
							<table cellspacing="0" style="width: 100%;" >
								<tr>
									<td colspan="3" style="width: 100%;padding-bottom: 36px"></td>
								</tr>
								<tr>
									<td style="width: 45%;">_______________________________</td>
									<td style="width: 5%;"></td>
									<td style="width: 45%;">_____________________________</td>	
								</tr>
								<tr>
									<td style="width: 45%;font-size:8px;">Cliente C.C</td>
									<td style="width: 5%;"></td>
									<td style="width: 45%;font-size:8px;">Vendedor C.C</td>		
								</tr>
						    </table>
						</td>
					</tr>
			    </table>
            </td>
            <td style="width: 1%;"></td>
			<td style="width: 35%;">
				<table cellspacing="0" style="width: 100%;">
			        <tr>
						<td colspan="2" style="width: 100%;color:white;background-color:#bdc3c7;text-align:center;padding:2px;"> 
							<strong style="font-size:10px;color: #000" >TOTALES</strong>
						</td>
					</tr>
					<tr>
						<td style="width: 50%;padding:2px;text-align:center;border-bottom:solid 1px #bdc3c7;border-left:solid 1px #bdc3c7;font-size:10px;text-align:right;"> 
							NET0
						</td>
						<td style="width: 50%;padding:2px;text-align:center;border-bottom:solid 1px #bdc3c7;border-left:solid 1px #bdc3c7;border-right:solid 1px #bdc3c7;font-size:10px;text-align:right;"> 
							<?php echo number_format($neto+$sumador_combo,0); ?>
						</td>
					</tr>
					<tr>
						<td style="width: 50%;padding:2px;text-align:center;border-bottom:solid 1px #bdc3c7;border-left:solid 1px #bdc3c7;font-size:10px;text-align:right;"> 
							DESCUENTO
						</td>
						<td style="width: 50%;padding:2px;text-align:center;border-bottom:solid 1px #bdc3c7;border-left:solid 1px #bdc3c7;border-right:solid 1px #bdc3c7;font-size:10px;text-align:right;"> 
							<?php echo number_format($descuento_global,0); ?>
						</td>
					</tr>
					<tr>
						<td style="width: 50%;padding:2px;text-align:center;border-bottom:solid 1px #bdc3c7;border-left:solid 1px #bdc3c7;font-size:10px;text-align:right;"> 
							IVA
						</td>
						<td style="width: 50%;padding:2px;text-align:center;border-bottom:solid 1px #bdc3c7;border-left:solid 1px #bdc3c7;border-right:solid 1px #bdc3c7;font-size:10px;text-align:right;"> 
							<?php echo number_format($iva_global,0); ?>
						</td>
					</tr>
					<tr>
						<td style="width: 50%;padding:2px;text-align:center;border-bottom:solid 1px #bdc3c7;border-left:solid 1px #bdc3c7;font-size:10px;text-align:right;"> 
							RETENCION
						</td>
						<td style="width: 50%;padding:2px;text-align:center;border-bottom:solid 1px #bdc3c7;border-left:solid 1px #bdc3c7;border-right:solid 1px #bdc3c7;font-size:10px;text-align:right;"> 
							<?php echo number_format($retencion_global,0); ?>
						</td>
					</tr>
					<tr>
						<td style="width: 50%;padding:4px;text-align:center;border-bottom:solid 1px #bdc3c7;border-left:solid 1px #bdc3c7;font-size:10px;text-align:right;"> 
							TOTAL
						</td>
						<td style="width: 50%;padding:4px;text-align:center;border-bottom:solid 1px #bdc3c7;border-left:solid 1px #bdc3c7;border-right:solid 1px #bdc3c7;font-size:10px;text-align:right;"> 
							<?php echo number_format($total_factura,0); ?>
						</td>
					</tr>
			    </table>
			</td>
		</tr>
    </table>

    <table cellspacing="0" style="width: 100%;padding-top: 5px">
        <tr>
			<td style="width: 100%;color:white;background-color:#bdc3c7;padding:2px;text-align:center;"> 
				<strong style="font-size:10px;color: #000" >CONDICIONES DE GARANTIA</strong>
			</td>
		</tr>
	
		<tr>
			<td style="width: 100%;border-left:solid 1px #bdc3c7;border-bottom:solid 1px #bdc3c7;border-right:solid 1px #bdc3c7;"><strong style="font-size:8px;"><?php echo $condiciones;?> </strong>
			</td>
		</tr>
    </table>
    <?php if($ven_tipo=='electronica'){?>
		<div style="font-size:8px;text-align: center;padding: 2px">Cufe: <?php echo $cufe;?></div>
	<?php } ?>
	
    <div style="font-size:8px; padding: 2px;text-align: center;">Impreso por | <?php echo $empresa;?> - VICPOS - V 2.5. Pag 1</div>
	<div style="width:100%; border-top:dashed 1px;margin-top:1mm;"></div>
	
</page>	

<?php
		
	$num_page++; 
    $limit_inf += 10; 
    $limit_sup + 10; 
}
?>