<?php
   include_once("../php/config.php");
$filtro = $_GET["filtro"];

if($_COOKIE['nivel']!="Vendedor"){
 $sql = mysql_query("select * from ventas where estado='Espera' and ticket like '%".$_GET['filtro']."%' and ticket!='COTIZACION' and total>0  order by id_venta desc") or die(mysql_error());
}else{
  $sql = mysql_query("select * from ventas where estado='Abierta' and ticket like '%".$_GET['filtro']."%' and ticket!='COTIZACION' and total>0 and usuario like '".$_COOKIE['usuario']."'order by id_venta desc") or die(mysql_error());
}


?>


<table  class="table table-striped table-hover "  style="width: 100%;">

							<th>Fecha</th>

              <th>Cliente</th>

              <th>Tcket</th>

              <th>Monto</th>

             

              <th>Editar</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;?>'><span class="text-primary"><?php echo ($r["hora"])?></span></a></td>

								<td><a href='facturacion.php?id_venta=<?php echo $folio;?>'><?php echo $r["cliente"]?></a></td>



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



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

               

               

             

               <td><a class="btn btn-success"  href="facturacion.php?id_venta=<?php echo $folio;?>"><i class="fa fa-coins fa-lg"></i> Cobrar </a></td>

							</tr>

                                                        <?php }?>

						</tbody>

            <tfoot>

              <br>

              <th>

                Cant. ventas: <span id="lbClistaEspera"><?php echo $c?></span>

              </th>

              <th class="text-success">

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

              </th>





              

            </tfoot>

					</table>