<?
include 'concha.php';




mysql_connect("$host","$usuario","$contra");

mysql_select_db ("$basedatos");



$sql = "SELECT * FROM `configuracion` LIMIT 1";

$consulta = mysql_query ($sql);

while ($row = mysql_fetch_array($consulta))

{


$nombre_kiosco = $row["nombre_kiosco"];

}

mysql_free_result($consulta);





//opcion22 indica el tipo de tiquet a imprimir... el estilo.


$sql = "SELECT opcion22 FROM `configuracion` LIMIT 1";

$consulta = mysql_query ($sql);

while ($row = mysql_fetch_array($consulta))

{

$opcion22 = (int)$row["opcion22"];


}

mysql_free_result($consulta);



//opcion23 indica ancho del div que contiene el ticket


$sql = "SELECT opcion23 FROM `configuracion` LIMIT 1";

$consulta = mysql_query ($sql);

while ($row = mysql_fetch_array($consulta))

{

$opcion23 = (int)$row["opcion23"];
if ($opcion23 == 0) {$opcion23 = 100;}


}

mysql_free_result($consulta);



//opcion24 indica el padding left del div, sirve para dar lugar del lado izquierdo para impresoras que cortan
$sql = "SELECT opcion24 FROM `configuracion` LIMIT 1";

$consulta = mysql_query ($sql);

while ($row = mysql_fetch_array($consulta))

{

$opcion24 = (int)$row["opcion24"];


}
mysql_free_result($consulta);


 ?><!DOCTYPE html>
<html>

    <head>
        <meta charset="utf-8">
        <meta http-equiv="X-UA-Compatible" content="IE=edge">
        <title>Imprimir una Mesa</title>
        <meta name="description" content="Una guía interactiva de primeros pasos para Brackets.">
        <link rel="stylesheet" href="main.css">
        <meta name="viewport" content="width=device-width, initial-scale=1.0">
        <style type="text/css">

.Estilo2 {
	font-size: 19px;
	font-weight: bold;
	font-style: italic;
	font-family: Arial, Helvetica, sans-serif;
}
.Estilo3 {font-family: Arial, Helvetica, sans-serif; font-size: 19px;}


@media print{

  .oculto-impresion, .oculto-impresion *{

    display: none !important;

  }

}



        </style>
</head>
    <body>



<?
///comienza opcion22 estilo 0 cero
 if ($opcion22 == 0) { ?>

<div style="text-align:center; padding-left:<? echo $opcion24 ?>px;">
<div style="width:<? echo $opcion23 ?>%; text-align:left;">



<p class="Estilo3"><? echo $nombre_kiosco ?></p>
<p class="Estilo3">

   <div class="Estilo3" style="font-family:Arial, Helvetica, sans-serif; font-size:10px; margin-bottom: -17px;"><?php

$a = date(Y);
$m = date(m);
$d = date(d);
$h = date(H);
$min = date(i);




echo "$d/$m/$a - <b>$h:$min</b>"; ?></div>



<br>
<?

$ID_venta = (int)$_GET['ID'];

$barcode = $_POST['barcode'];
$cantidad = $_POST['cantidad'];
$varios = $_POST['varios'];

$precio_varios = $_POST['precio_varios'];



if ($multicaja == 1) { mysql_select_db ("$basedatos_multicaja"); };
$sql = "SELECT * FROM `articulos` WHERE `barcode` = '$barcode' LIMIT 1";

$consulta = mysql_query ($sql);

while ($row = mysql_fetch_array($consulta))

{

$ID_producto = $row["ID"];
$titulo = $row["titulo"];
$foto = $row["foto"];
$precio = $row["precio"];
$stock = $row["stock"];
$barcode = $row["barcode"];

}

mysql_free_result($consulta);

if ($multicaja == 1) { mysql_select_db ("$basedatos"); };


$total = 0;


mysql_connect("$host","$usuario","$contra");

mysql_select_db ("$basedatos");


$sql = "SELECT * FROM `movimientos` WHERE `ID_venta` = '$ID_venta'";


$consulta = mysql_query ($sql);

while ($row = mysql_fetch_array($consulta))

{
$ID_mov = $row["ID"];
$ID_articulo = $row["ID_articulo"];
$precio = $row["precio"];
$cantidad = $row["cantidad"];
$detalle = $row["detalle"];

if ($multicaja == 1) { mysql_select_db ("$basedatos_multicaja"); };

$sql22 = "SELECT * FROM `articulos` WHERE `ID` = '$ID_articulo' LIMIT 1";

$consulta22 = mysql_query ($sql22);

while ($row22 = mysql_fetch_array($consulta22))

{
$ID_producto = $row22["ID"];
$titulo = $row22["titulo"];
$foto = $row22["foto"];
$stock = $row22["stock"];
$barcode = $row22["barcode"];

}

mysql_free_result($consulta22);

if ($multicaja == 1) { mysql_select_db ("$basedatos"); };




$precio = $precio * $cantidad;
$total = $total + $precio;





?><div class="col-lg-6 col-sm-12 col-md-12" style="font-family: Arial, Helvetica, sans-serif; margin-bottom: 0px; margin-top: -18px;">_______________________</div>
<div class="col-lg-6 col-sm-12 col-md-12" style="font-family: Arial, Helvetica, sans-serif;">
<?php if($ID_articulo == 0) { echo $detalle; } else { echo $titulo; }; ?><br>
 x<?php echo $cantidad ?> = <b style="50px">$ <? echo $precio ?> </b>
</div>

<?



}

mysql_free_result($consulta);

?>

<div class="col-lg-6 col-sm-12 col-md-12" style="font-family: Arial, Helvetica, sans-serif;">_______________________</div>



<?php
$aa = 0;
include 'concha.php';

mysql_connect("$host","$usuario","$contra");

mysql_select_db ("$basedatos");

$sql = "SELECT * FROM `ventas` WHERE ID = '$ID_venta'  LIMIT 1";

$consulta = mysql_query ($sql);

while ($row = mysql_fetch_array($consulta))

{
$total = $row["total"];
$forma_pago = $row["forma_pago"];
}

mysql_free_result($consulta);


if ($forma_pago == 'DESCUENTO') { ?> <br> VENTA CON DESCUENTO <br><? } ?>


<span style="margin-top: -3px;  font-family: Arial, Helvetica, sans-serif;">TOTAL $ <b><? echo $total ?></b></span>
<br>




</div></div>

<?
///// fin opcion22 ticket estilo 0 cero.
 } ?>














 <?
 ///comienza opcion22 estilo 1 cero
  if ($opcion22 == 1) { ?>



 <p class="Estilo3"><? echo $nombre_kiosco ?></p>
 <p class="Estilo3">


 <div class="Estilo3" style="font-family:Arial, Helvetica, sans-serif; font-size:10px; margin-bottom: -17px;"><?php

 $a = date(Y);
 $m = date(m);
 $d = date(d);
 $h = date(H);
 $min = date(i);




 echo "$d/$m/$a - <b>$h:$min</b>"; ?></div>



 <br>
 <?

 $ID_venta = (int)$_GET['ID'];

 $barcode = $_POST['barcode'];
 $cantidad = $_POST['cantidad'];
 $varios = $_POST['varios'];

 $precio_varios = $_POST['precio_varios'];



 $sql = "SELECT * FROM `articulos` WHERE `barcode` = '$barcode' LIMIT 1";

 $consulta = mysql_query ($sql);

 while ($row = mysql_fetch_array($consulta))

 {

 $ID_producto = $row["ID"];
 $titulo = $row["titulo"];
 $foto = $row["foto"];
 $precio = $row["precio"];
 $stock = $row["stock"];
 $barcode = $row["barcode"];

 }

 mysql_free_result($consulta);


 $total = 0;


 mysql_connect("$host","$usuario","$contra");

 mysql_select_db ("$basedatos");


 $sql = "SELECT * FROM `movimientos` WHERE `ID_venta` = '$ID_venta'";


 $consulta = mysql_query ($sql);

 while ($row = mysql_fetch_array($consulta))

 {
 $ID_mov = $row["ID"];
 $ID_articulo = $row["ID_articulo"];
 $precio = $row["precio"];
 $cantidad = $row["cantidad"];
 $detalle = $row["detalle"];


 $sql22 = "SELECT * FROM `articulos` WHERE `ID` = '$ID_articulo' LIMIT 1";

 $consulta22 = mysql_query ($sql22);

 while ($row22 = mysql_fetch_array($consulta22))

 {
 $ID_producto = $row22["ID"];
 $titulo = $row22["titulo"];
 $foto = $row22["foto"];
 $stock = $row22["stock"];
 $barcode = $row22["barcode"];

 }

 mysql_free_result($consulta22);




 $precio = $precio * $cantidad;
 $total = $total + $precio;




 ?><div class="col-lg-6 col-sm-12 col-md-12" style="font-family: Arial, Helvetica, sans-serif; margin-bottom: 0px; margin-top: -18px;">_______________________</div>
 <div class="col-lg-6 col-sm-12 col-md-12" style="font-family: Arial, Helvetica, sans-serif;">
 <?php if($ID_articulo == 0) { echo $detalle; } else { echo $titulo; }; ?><br>
  x<?php echo $cantidad ?> = <b style="50px">$ <? echo $precio ?> </b>
 </div>

 <?



 }

 mysql_free_result($consulta);

 ?>

 <div class="col-lg-6 col-sm-12 col-md-12" style="font-family: Arial, Helvetica, sans-serif;">-------------------------</div>

 <h3 style="margin-top: -3px;">TOTAL: $ <? echo $total ?></h3>
 <br>






 <?
 ///// fin opcion22 ticket estilo 1 cero.
  } ?>











<hr>




<button onClick="javascript:imprimir()" class="oculto-impresion" style="font-size:19px;">Imprimir Ticket (F3)</button>
<br><br>
<button onClick="window.location.reload();" class="oculto-impresion" style="font-size:19px;">Actualizar</button>



        <script>

        $(document).on('click', '.panel-heading span.clickable', function(e){
    var $this = $(this);
	if(!$this.hasClass('panel-collapsed')) {
		$this.parents('.panel').find('.panel-body').slideUp();
		$this.addClass('panel-collapsed');
		$this.find('i').removeClass('glyphicon-chevron-down').addClass('glyphicon-chevron-up');

	} else {
		$this.parents('.panel').find('.panel-body').slideDown();
		$this.removeClass('panel-collapsed');
		$this.find('i').removeClass('glyphicon-chevron-up').addClass('glyphicon-chevron-down');

	}
})


function imprimir(){
    window.print();
}
        </script>
        
        

        
        
    </body>
</html>
