<style type="text/css" media="print">
@page{
   @margin: 2px;
}

@import url('https://fonts.googleapis.com/css?family=Open+Sans');

* {
  font-family:"Arial";
  @font-weight: 100;
  font-size:13px;
}
h3{
	font-size:14px;
	font-weight:100;
}
h5{
	font-size:12px
}
th{
	background: green;
	color:white;
	text-align: center;

}
td{
	font-size:13px;
}
.datos_empres2{
	font-size: 20px;
	font-weight: 100;
	font-family: "Lucida console";
}

img{
	width:150px;
	height:150px;
}
</style>

<style>
	img{
	width:150px;
	height:150px;
	}
</style>

<?php
$folio = $_GET['folio'];
include_once("../php/config.php");
$sql_venta = mysql_query("select * from ventas where id_venta='$folio'") or die (mysql_error());
$sql_detalle = mysql_query("select * from detalle_venta where folio='$folio'") or die (mysql_error());

$cliente = @mysql_result($sql_venta,0,"cliente");

$sql_cliente = mysql_query("select * from clientes where nombre='$cliente'") or die (mysql_error());


?>
<div style="margin-left: 5px; margin-right: 20px;">
<center>

<?php

$sql_empresa = mysql_query("SELECT * FROM empresa") or die(mysql_error());
$enombre= @mysql_result($sql_empresa,0,"nombre");
$etelefono= @mysql_result($sql_empresa,0,"telefono");	
$edireccion= @mysql_result($sql_empresa,0,"direccion");	
$ernc= @mysql_result($sql_empresa,0,"rnc");	
$eemail= @mysql_result($sql_empresa,0,"email");	
$logo= @mysql_result($sql_empresa,0,"logo");
	
?>
<span class="datos_empres2" style="font-size: 18px;font-weight: bolder;font-family: 'Arial black'">
<?php if($logo!=""){?>
<?php echo "<img src = '../LOGOS/$logo'>";?>
<?php }?>

<?php echo $enombre;?></span><b><br>
<span class="datos_empres1"><?php echo $etelefono;?> | <?php echo $eemail;?> </span><br>
<span class="datos_empres1"><?php echo $edireccion;?> </span><br>
<span class="datos_empres1"><?php echo $ernc;?></span><br>
<?php 
	if(@mysql_result($sql_venta,0,"termino")=="Conduce"){
?>
	<h2>CONDUCE</h2>
<?php }else{?>
	
<?php }?>
<br>
<i>ORIGINAL</i>
</center>


<font color="blue">Orden #: <?php echo @mysql_result($sql_venta,0,"folio")?><br>
Fecha : <?php echo  @mysql_result($sql_venta,0,"hora");?><br>
Termino: <?php echo @mysql_result($sql_venta,0,"termino");?><br>


Cliente: <?php echo $cliente?><br>
RNC/ Cedula: <?php echo @mysql_result($sql_cliente,0,"cedula");?><br>
Telefono: <?php echo @mysql_result($sql_cliente,0,"telefono");?><br>
Direccion: <?php echo @mysql_result($sql_cliente,0,"direccion");?><br>

</font>

<div style="float: right;">
<?php echo @mysql_result($sql_venta,0,"tipo_ncf");?><br>
NCF:  <?php echo @mysql_result($sql_venta,0,"ncf");?><br>
</div>


<table class="" style="width:100%">
	<thead>             
		<th>Item | Cantidad X Precio = Total</th>
		<th></th>
		
		
	</thead>
<tbody>
<?php while($r=mysql_fetch_array($sql_detalle)){?>
			<tr>
			
                
				<td><?php echo $r["descripcion"]?> 
				<br><?php echo decimal($r["cantidad"])." X ".decimal($r["precio"])." = ".decimal($r["total_precio"])?></td>
                
                <td> <?php 
                if($r["tipo_impuesto"]=="18.00"){
                    echo "I18";
                }
                
                if($r["tipo_impuesto"]=="16.00"){
                    echo "I16";
                }
                
                 if($r["tipo_impuesto"]=="0.00"){
                    echo "IE";
                }
                ?>
                
                </td>
             
               
			</tr>
         <?php }?>
	</tbody>
</table>


<div style="float: right; width: auto;">
<span style="float: left">Impuestos: </span> <span style="float: right;"><?php echo @decimal(mysql_result($sql_venta,0,"impuesto"))?></span><br>

<span style="float: left">TOTAL VENTA: </span> <span style="float: right;"><?php echo @decimal(mysql_result($sql_venta,0,"total"))?></span><br>


	<b><span style="float: left">Efectivo: </span> <span style="float: right;"><?php echo @decimal(mysql_result($sql_venta,0,"efectivo"))?></span></b><br><br>
	<span style="float: left">Tarjeta: </span> <span style="float: right;"><?php echo @decimal(mysql_result($sql_venta,0,"monto_tarjeta"))?></span><br>
	<span style="float: left">Cheque: </span> <span style="float: right;"><?php echo @decimal(mysql_result($sql_venta,0,"cheque")."#: ".@mysql_result($sql_venta,0,"numero_cheque"))?></span><br>
	
	<span style="float: left">Su cambio: </span> <span style="float: right;"><?php echo @decimal(mysql_result($sql_venta,0,"devuelta")."#: ".@mysql_result($sql_venta,0,"numero_cheque"))?></span><br>
	<hr>
	<span style="float: left">Balance pendiente: </span> <span style="float: right;"><?php echo @decimal(mysql_result($sql_venta,0,"balance"))?></span><br>
	
	
</div>
<br>

<br>
<br>
<br>
<center>
	________________________<br>
	Firma cliente
</center>


<div style="float:left">

Le atendio: <b><?php echo @mysql_result($sql_venta,0,"usuario")?></b>

</div>
</div>

<script>

	window.print()

	
	setTimeout(function(){
		///window.close()
		var folio = "<?php echo $folio?>";
		window.location.href="ticket_factura_carta2.php?folio="+folio;
		

	},5000)
</script>