<?
require_once('../conf/connection.php');



 $mesa = $_GET["mesa"];
 
 $doc = $_GET["doc"];
 
 if($doc==2){ $nom_doc="Boleta"; }else{ $nom_doc="Factura"; }
 
 $subtotal = $_GET["subtotal"];
 $descuento = $_GET["descuento"];
 $final=$subtotal-$descuento;
 $f_pagos = $_GET["f_pagos"];
 
 switch ($f_pagos) {
				   //
                   case 1:
                     $forma="Efectivo";
				   break;		  
				   //		   
				   case 2:
                    $forma="Debito o Targeta";
				   break;   
				  //
				  case 3:
                   $forma="Cheques";
                  break;
				  
				  case 4:
                   $forma="Cuenta Cliente";
                  break;

				   default:          
				   $forma="ERROR: No ingreso forma de pagos...";
				   
			       }
 
 $numero = $_GET["numero"];
 
  date_default_timezone_set("America/Buenos aires" ) ; 
$hora = date('h:i a',time() - 3600*date('I')); 
 $fecha = $_GET["fecha"];

$query_mesa="SELECT * FROM mesa WHERE num_mesa='$mesa'";
$rs_query_mesa=mysql_query($query_mesa);
$nom_mesa=mysql_result($rs_query_mesa,0,"nombre_mesa");


$query_suma="SELECT  SUM(valor_total) AS total_venta  FROM detalles_pedido WHERE numero='$numero'";
$rs_query_suma=mysql_query($query_suma);
$total_venta=mysql_result($rs_query_suma,0,"total_venta");
$propina=$total_venta*(10/100); 
$total_pro=$total_venta+$propina;
?>
<!DOCTYPE html>

<html dir="ltr" lang="en-US"><head><!-- Created by Artisteer v4.3.0.60745 -->
    
    <meta charset="utf-8">
    <title>SELECCION DE MESAS</title>
    <meta name="viewport" content="initial-scale = 1.0, maximum-scale = 1.0, user-scalable = no, width = device-width">

    <!--[if lt IE 9]><script src="https://html5shiv.googlecode.com/svn/trunk/html5.js"></script><![endif]-->
    <link rel="stylesheet" href="../style.css" media="screen">
    <!--[if lte IE 7]><link rel="stylesheet" href="style.ie7.css" media="screen" /><![endif]-->
    <link rel="stylesheet" href="../style.responsive.css" media="all">


    <script src="../jquery.js"></script>
    <script src="../script.js"></script>
    <script src="../script.responsive.js"></script>



<style>
.art-content .art-postcontent-0 .layout-item-0 { margin-bottom: 10px;  }
.art-content .art-postcontent-0 .layout-item-1 { border-right-style:solid;border-right-width:1px;border-right-color:#C4C6BD; padding-right: 10px;padding-left: 10px;  }
.ie7 .art-post .art-layout-cell {border:none !important; padding:0 !important; }
.ie6 .art-post .art-layout-cell {border:none !important; padding:0 !important; }

.table { border:2px black solid;
 border-radius:10px;
 min-width:300px;
 min-height:300px;
 font-family: Helvetica,Arial;
}
</style>
<script>
function nobackbutton(){
	
   window.location.hash="no-back-button";
	
   window.location.hash="Again-No-back-button" //chrome
	
   window.onhashchange=function(){window.location.hash="no-back-button";}
	
}   
  </script>
<script>
function precuenta(){

			window.location.href = "precuenta2.php?mesa=<? echo $mesa ?>&numero=<? echo $numero ?>
			&descuento=<? echo $descuento ?>";
		}
</script>

</head>
<body onload="nobackbutton();">
<div id="art-main">
    <div class="art-sheet clearfix">
<nav class="art-nav">
    <ul class="art-hmenu">
    <li><a><font size="+1" color="#FF0000">Fecha: <? echo $fecha ?></font></a></li>
        <li><a><font size="+1" color="#FF0000">Hrs: <? echo $hora ?></font></a></li>
    <li><a><? echo  $nom_mesa;?></a></li>
    <li><a>PEDIDO:<? echo  $numero;?></a></li>
    <li><a href="pedido.php?mesa=<? echo $mesa ?>&numero=<? echo $numero ?>">VOLVER</a></li>
    </ul> 
    </nav>
<div class="art-layout-wrapper">
                <div class="art-content-layout">
                    <div class="art-content-layout-row">
                      <div class="art-layout-cell art-content"><article class="art-post art-article">
                                
                                                
                                <div class="art-postcontent art-postcontent-0 clearfix"><div class="art-content-layout-wrapper layout-item-0">
<div class="art-content-layout">
    <div class="art-content-layout-row">
    <div class="art-layout-cell layout-item-1" style="width: 100%" >
        <table border="0">
  <tr>
    <td>
      <center><img src="../images/logo.png"  width="140" height="132" class="img_logo"></center>
      </td>
    <td>&nbsp;</td>
    </tr>
  <tr>
    <td width="243"><div style="height:450px; width:300px;  overflow: auto;">
      <div style="height:300px; width:100%;  overflow: auto;">
        <?
        $buscar='select *, SUM(cantidad) as cant, SUM(valor_total) as valor
		from detalles_pedido where numero like \'%'.$numero.'%\' group by grupo, idplatos ';
		   $r=mysql_query($buscar,$conn) or die("Error en el query: ".mysql_error());
		   $n=mysql_num_rows($r);
		    //si hay registros los procesamos
			if($n>0)
			{
			?>
        <table  width="254" border="0">
          <tr bgcolor="#69BFE0" >
            <td bgcolor="#FFFFFF"><strong>Productos</strong></td>
            <td width="57" bgcolor="#FFFFFF"><strong>Cantidad</strong></td>
            <td width="49" bgcolor="#FFFFFF"><strong>Total </strong></td>
          </tr>
          <tr bgcolor="#69BFE0" >
            <td colspan="3" bgcolor="#FFFFFF"><hr></td>
          </tr>
          <?
				while($row=mysql_fetch_assoc($r))
				{ //Procesamos cada registro como una fila de tabla
					?>
          <tr>
            <?
					//$row["nomCampo"] estos nomCampo son los campos devueltos por el
					//query en la variable $r que procesa mysql_fetch_assoc
					?>
            <td><? $plato=$row["idplatos"];
					 $query="SELECT *  FROM platos WHERE idplatos='$plato'";
 					 $rs_query=mysql_query($query);
					 $nombre=mysql_result($rs_query,0,"descrip_plato");
					 $idgrupos=mysql_result($rs_query,0,"idgrupos");
                     echo $nombre; 
					 
					  ?>
              <? if($idgrupos==4 or $idgrupos==6 or $idgrupos==7 or $idgrupos==8 or $idgrupos==9 or $idgrupos==10 or $idgrupos==11 or $idgrupos==13  )
		  {
		  ?>
              <br>
              <? 
		   $query_obs1="SELECT *  FROM detalles_pedido WHERE idplatos='$plato' and numero='$numero'";
 		   $rs_query_obs1=mysql_query($query_obs1);
		   while($row1=mysql_fetch_assoc($rs_query_obs1))
				{  ?>
              <br>
              <?
		  $obs1=$row1["obs"]; echo $obs1;
				}}
		  else{
		   $query_obs="SELECT *  FROM detalles_pedido WHERE idplatos='$plato' and numero='$numero'";
 		   $rs_query_obs=mysql_query($query_obs);
		   while($rows=mysql_fetch_assoc($rs_query_obs))
				{ 
		 
		 ?>
              <br>
              - <em>
                <? 
		  $obs=$rows["obs"]; if($obs==""){ echo " * ";  }else{
		  echo $obs;}}} ?>
              </em></td>
            <td align="right"><? echo $row["cant"] ?></td>
            <td align="right">$ <? echo $row["valor"] ?></td>
          </tr>
          <? }?>
          <tr>
            <td colspan="3"><hr></td>
          </tr>
          <tr>
            <td colspan="3" align="right">TOTAL A VENTA: <? echo $total_venta;  ?></td>
          </tr>
          <tr>
            <td colspan="3" ><hr></td>
          </tr>
        </table>
        <? } 
			else
			{
				echo "No hubieron coincidencias!";
     
			} ?>
      </div></div></td>
    <td width="811" >
      <form action="funciones/add_reg2.php" id="final" name="final" method="post"> 
        <h4>
          <input type="hidden" id="doc" name="doc" value="<? echo $doc ?>">
          <input type="hidden" id="f_pagos" name="f_pagos" value="<? echo $f_pagos ?>">
          <input type="hidden" id="nuemero" name="numero" value="<? echo $numero ?>">
          <input type="hidden" id="mesa" name="mesa" value="<? echo $mesa ?>">
          <input type="hidden" name="descuento" id="descuento" value="<? echo $descuento; ?>">
           <input type="hidden" name="fecha" id="fecha" value="<? echo $fecha; ?>">
          
          <strong> 
          - Formas de Pago: <? echo $forma;  ?><br>
          - Tipo de documento: <? echo $nom_doc; ?> <br>
          - Sub total: <? echo $subtotal; ?><br>
          - Descuento: <? echo $descuento; ?><br>
          - Total final: <? echo $final; ?><br>
          </strong><br>
          </h4>
     
          <table width="730" border="0">
          <tr>
            <td width="155" height="9">RUT CLIENTE:</td>
            <td colspan="2"> <input type="text" id="rut" name="rut" style="font-size:18px">
              </td>
            </tr>
          <tr>
            <td height="9"></td>
            <td colspan="2">
              <div class='input'><input type="hidden" name="pago" id="pago" style="font-size:18px"></div>
            </td>
          </tr>
          <tr>
            <td height="51"></td>
            <td colspan="2">
              <div class='input'>
                <input type="hidden" name="efectivo" id="efectivo" value="<? echo $subtotal ?>"
               style="font-size:18px">
              </div>
            </td>
          </tr>
          <tr>
            <td height="47"></td>
            <td colspan="2">
              <div class='input'><input type="hidden" name="total" id="total" style="font-size:18px; background-color:#999"></div></td>
          </tr>
          <tr>
            <td height="32"><span class="input">
           </span></td>
            <td height="32"><span class="input">
              <input type="hidden" name="propina" id="propina" style="font-size:18px" value="<? echo $propina ?>">
            </span></td>
            <td width="337">&nbsp;</td>
          </tr>
          <tr>
            <td colspan="2">&nbsp;</td>
            <td width="337">
            <input type="submit" value="Finalizar" class="art-button" 
            style="height:50px; width:120px;" id="enviar" name="enviar">
            
            <input type="botton" value="Precuenta" class="art-button" style="height:50px; width:120px;"
            onClick="precuenta()" ></td>
          </tr>
          </table>
        
        </form>      
      </td>
  </tr>
  <tr>
    <td colspan="3" align="right" bgcolor="#46BBD2">&nbsp;</td>
  </tr>
</table>

    </div>
    </div>
</div>
</div>
</div>


</article></div>
                    </div>
                </div>
            </div>

    </div>
    <p class="art-page-footer">
        <span id="art-footnote-links"><a href="http://www.virtualsurchile.cl" target="_blank">Informatica Francisco Arias E.I.R.L.</a></span>
    </p>
</div>


</body></html>