  <?php

$usuario = $_COOKIE["usuario"];

$nivel = $_COOKIE["nivel"];

if($nivel=="Master"){$usuario="";}







	include_once("../header.php");

        include_once("../php/config.php");
		      ///mysql_query("delete from ventas where total<=0") or die(mysql_error());


        $sql = mysql_query("select * from mesas where total>0") or die(mysql_error());



	?>

<style>
th, td, a{
	font-size:18px;
}
</style>


    <div class="container">



        

		<div class="row">

			<div class="col-md-12">

        <div class="pan1el panel-default">
          <div class="p1anel-heading">
			     <span class="text-success h3 pull-right"> <i class="fa fa-clock"></i> CUENTAS ABIERTAS</span>

       

            </div>

  <div class="pan1el-body">



        <a class="btn btn-primary mb-2 " href="javascript:void(0)" onClick="nueva()"><i class="fa fa-file"></i> <b>VOLVER AL PUNTO DE VENTAS</b></a>

         

       

      

				<div class="table-responsive1  p-3">
<br>
          <span><b>Lista de Ventas  en espera( No cobradas)</b></span><br>

					 <table  class="table table-striped table-hover " data-page-length='8' style="width: 100%;">


							<th>Mesa</th>

							<th>Fecha apertura</th>

              <th>A nombre de</th>

              

              <th>Total</th>

             

              <th>Mesa</th>


						<tbody>

            <?php while($r=mysql_fetch_array($sql)){

              
              $total+=$r["total"];
			  $mesa=$r["nombre"];
              

              ?>

							<tr>

				 <td><a class="btn btn-default" href='../drink/vender.php?txt-mesa=<?php echo $mesa;?>'> <?php if($r['nombre']>178){ echo '<b>Directa</b>';}else{echo $r["nombre"];}?></a></td>

                <td><a href='../drink/vender.php?txt-mesa=<?php echo $mesa;?>'><span class="text-primary"><?php echo ($r["fecha"]).", ". ($r["hora"])?></span></a></td>

								<td><a href='../drink/vender.php?txt-mesa=<?php echo $mesa;?>'><?php echo $r["ticket"]?></a></td>






                 <td><?php echo decimal($r["total"])?></td>

               

               

             

               <td><a class="btn btn-success" href="javascript:void(0)" onClick="reimprimir('<?php echo $mesa?>')" ><i class="fa fa-edit"></i> Precuenta</a></td>

							</tr>

                                                        <?php }?>

						</tbody>

            </table>

              <br>

              <hr>

                Cant. ventas: <?php echo $c?> | 

                 Total: <?php echo decimal($total)?>

           





              

            

				
        </center>

				</div>

			</div>

		</div>

		

        </div>

      </div>

      





          

</div>

    </div>



	<!---Modal Cliente-->

	<div class="modal" id="modalBusqueda" data-backdrop="static" tabindex="-1" role="dialog" aria-labelledby="exampleModalLabel" aria-hidden="true">

      <div class="modal-dialog modal-md" role="document">

        <div class="modal-content">

          <div class="modal-header">

            <h2 class="modal-title text-success" id="exampleModalLabel"><i class="fa  fa-calendar"></i> Busqueda por fecha</h2>

            <button class="close" type="button" data-dismiss="modal" aria-label="Close">

              <span aria-hidden="true">×</span>

            </button>

          </div>

          <div class="modal-body">





		  <form name="frm" action="" method="POST" id="frm">

			 



			  

			   <div class="row">

          <label for="id" class="col-sm-3 col-form-label" >Desde</label>

          <div class="col-sm-9">

            <input autocomplete="off" type="date"  class="form-control mb-2 font-weight-bolde" id="fecha1" name="nombre" value="">

          </div>

        </div>



         <div class="row">

          <label for="codigo" class="col-sm-3 col-form-label" >Hasta</label>

          <div class="col-sm-9">

            <input autocomplete="off" type="date"  class="form-control mb-2" id="fecha2" name="fecha2" value="">

          </div>

        </div>



         



			  

			  

		  </form>

		  

		  </div>

          <div class="modal-footer">

            <button class="btn btn-success" type="button" onclick="buscar()"><i class="fa fa-w fa-save"></i> Grabar</button>





            <a class="btn btn-warning" data-dismiss="modal"> <i class="fa fa-w fa-home"></i> Salir</a>

          </div>

        </div>

      </div>

    </div>



        <?php

        include_once("../footer.php");



        function state($est) {



            if ($est == "1") {

                $b = "<span class='badge badge-success'>Activo</span>";

            } else {



                $b = "<span class='badge badge-danger'>Inactivo</span>";

            }



            return $b;

        }

        ?>

            

<script>


////nueva();


$("td").addClass("text-success");

function nueva(){

    window.location.href="../drink/vender.php?";

   }

  

function reimprimir(mesa){

   window.open('../drink/precuenta.php?mesa='+mesa, '_blank', 'toolbar=no,scrollbars=no,resizable=no,top=500,left=500,width=300,height=800');

}





$("table").DataTable({

   "language": {

            "url": "//cdn.datatables.net/plug-ins/9dcbecd42ad/i18n/Spanish.json"

        }

});

      

     </script>



