<? 
$nivel = $_GET["nivel"];
$nombrevar =$_GET["nombreuser"];
$numero =$_GET["numero"];;

 
$fecha =$_POST["fecha"];
$hora=date("H:i:s");
$fecha_ft=date('Y-m-d',strtotime($fecha));


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

$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");

?>
<!DOCTYPE html>

<html dir="ltr" lang="en-US"><head><!-- Created by Artisteer v4.3.0.60745 -->

    <meta charset="utf-8">
    <title>CIERRE DE CAJA</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 language="javascript">

function cerrar() {
	window.close();	
}

var total=0;

function sumar(valor) {
total += valor; 
document.formulario.total.value=total;
}

function restar(valor) {
total-=valor; 
document.formulario.total.value=total;
}

</script>
</head>
<body>
<div id="art-main">
    <div class="art-sheet clearfix">
<nav class="art-nav">
    <ul class="art-hmenu"><li></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%" >
        <div class="image-caption-wrapper" style="width: 100%">
        <h3>DIVICION DE CUENTA</h3>
        <br>
              <form name=formulario>

        <?
        $buscar='select *, SUM(cantidad) as cant, SUM(valor_total) as valor
		from detalles_pedido where numero like \'%'.$numero.'%\' group by 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="883" border="0">
          <tr bgcolor="#69BFE0" >
            <td width="195" bgcolor="#FFFFFF"><strong>Productos</strong></td>
            <td width="57" bgcolor="#FFFFFF"><strong>Cantidad</strong></td>
            <td width="78" bgcolor="#FFFFFF"><strong>Total </strong></td>
            <td width="535" rowspan="6" bgcolor="#FFFFFF">
            <input name="total" type="text" style="font-size:24px" value="0" class="art-button" readonly="readonly"></td>
          </tr>
          <tr bgcolor="#69BFE0" >
            <td colspan="3" bgcolor="#FFFFFF">----------------------------------------------------------------------------------</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))
				{ $valor=$row1["valor_total"];  ?>
              <br>-
              <?
		  ?>
            <input name="checkbox" type="checkbox" onClick="if (this.checked) sumar(<? echo $valor ?>); 
                    else restar(<? echo $valor ?>)" value="checkbox">
           <? $obs1=$row1["obs"]; echo $obs1; ?> $<? echo $valor;
				}}
		  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))
				{ 
		          $valor=$rows["valor_total"];
		 ?>
              <br>
              - <input name="checkbox" type="checkbox" onClick="if (this.checked) sumar(<? echo $valor ?>); 
                    else restar(<? echo $valor ?>)" value="checkbox">
                <? 
		  $obs=$rows["obs"]; if($obs==""){ echo "Sin agregado  $";  echo $valor;  }else{
		  echo $obs;  ?>$ <? echo  $valor; }}} ?>
              </td>
            <td align="right"><? echo $row["cant"] ?></td>
            <td align="right">$ <? echo $row["valor"] ?></td>
          </tr>
          <? }?>
          <tr>
            <td colspan="3">-----------------------------------------------------------------------------------</td>
          </tr>
          <tr>
            <td align="right">TOTAL A VENTA: <? echo $total_venta;  ?></td>
            <td align="right">&nbsp;</td>
            <td align="right">&nbsp;</td>
          </tr>
          <tr>
            <td colspan="3" >-----------------------------------------------------------------------------------</td>
          </tr>
        </table>
        <? } 
			else
			{
				echo "No hubieron coincidencias!";
     
			} ?>
      </div>
      </div>
    </div>
    </div>
</div>
</div>
</div>


</article></div>
                    </div>
                </div>
            </div><footer class="art-footer">
<p><br></p>
<p>Copyright © <? echo $ano; ?>. All Rights Reserved.</p>
</footer>

    </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>