  <?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 ventas where usuario like '%".$usuario."%' and estado='Abierta' and ticket!='COTIZACION' and total>0 order by id_venta desc") or die(mysql_error());



	?>


  <style>
 td{
	 font-size:15px;
 }
 
  th{
	 font-size:18px;
 }
 
   .form-control{
	 font-size:18px;
 }
 
 
 </style>


 <div class="container" style="background:white; padding:15px">



        

		<div class="row">

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

        <div class="pan1el panel-default">
          <div class="p1anel-heading">
			     <span class="text-success pull-right"> <i class="bi bi-clock-history"></i> Ventas en espera</span>

       

            </div>

  <div class="pan1el-body">



        <a class="btn btn-success mb-2" href="javascript:void(0)" onClick="nueva()"><i class="bi bi-database-add"></i> Nueva venta</a>

         <br>

       

      
<small><b>Lista de Ventas  en espera( No cobradas)</b></small><br>
				<div class="table-responsive  p-3 mt-2">
<br>
          

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


              <th>Venta</th>

              <th>Monto</th>
			 

              <th>Accion</th>


						<tbody>

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

              $folio = $r["id_venta"];

              $c++;

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

              $balance+=$r["balance"];

              $costo+=$r["costo"];

              

              ?>

							<tr>


                  <td><a href='facturacion.php?id_venta=<?php echo $folio;?>'><i class='bi bi-stickies'></i>  <?php echo $r["hora"]." - ". $r["ticket"]?></a></td>



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

               

               

             

               <td><a class="text-success" href='facturacion.php?id_venta=<?php echo $folio;?>'><i class="bi bi-cash-coin"></i> Cobrar</a></td>

							</tr>

                                                        <?php }?>

						</tbody>

            <tfoot>

              <br>

              <th>

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

              </th>

              <th class="text-success">

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

              </th>





              

            </tfoot>

					</table>
   

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





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

function nueva(){

    window.location.href="_nueva_venta.php?caja="+myCaja+"&usuario="+myUser;

   }

  

function reimprimir(f){

   window.open('ticket_factura.php?folio='+f, '_blank', 'toolbar=no,scrollbars=no,resizable=no,top=500,left=500,width=700,height=800');

}





$("table").DataTable({

   "language": {

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

        }

});

      

     </script>



