<?php
/*-------------------------
Autor: Delmar Lopez
Web: www.softwys.com
Mail: softwysop@gmail.com
---------------------------*/
include 'is_logged.php'; //Archivo verifica que el usario que intenta acceder a la URL esta logueado
/* Connect To Database*/
require_once "../db.php";
require_once "../php_conexion.php";
require_once "../funciones.php";
$moneda = get_row('perfil', 'moneda', 'id_perfil', 1);
// escaping, additionally removing everything that could be (html/javascript-) code
//$linea_id = intval($_REQUEST['linea_id']);
$sTable = "factura_tmp_pos, clientes";
$sWhere = "";
$sWhere .= " WHERE clientes.id_cliente=factura_tmp_pos.id_cliente";
$sWhere .= " order by id_factura DESC";
include 'pagination.php'; //include pagination file
//pagination variables
$page      = (isset($_REQUEST['page']) && !empty($_REQUEST['page'])) ? $_REQUEST['page'] : 1;
$per_page  = 9; //how much records you want to show
$adjacents = 4; //gap between pages after number of adjacents
$offset    = ($page - 1) * $per_page;
//Count the total number of row in your table*/
$count_query = mysqli_query($conexion, "SELECT count(*) AS numrows FROM $sTable  $sWhere");
$row         = mysqli_fetch_array($count_query);
$numrows     = $row['numrows'];
$total_pages = ceil($numrows / $per_page);
$reload      = '../pos.php';
//main query to fetch the data
$sql   = "SELECT * FROM  $sTable $sWhere LIMIT $offset,$per_page";
$query = mysqli_query($conexion, $sql);
//loop through fetched data
if ($numrows > 0) {

    ?>

 <div class="row">
        <?php
$nums = 1;
    while ($row = mysqli_fetch_array($query)) {
        $id_pos      = $row['id_factura'];
        $id_cliente  = $row['id_cliente'];
        $id_vendedor = $row['id_vendedor'];
        $monto       = $row['monto_factura'];
        $cliente     = $row['nombre_cliente'];
        ?>
            <!--<a tabindex="-1" href="" data-toggle="modal" data-target="#control">
                <div class="col-sm-6 col-lg-2">
                    <div class="widget-simple text-center card-box bg-<?php echo $color; ?>">
                        <h4 class="text-white counter"><?php echo $nombre_mesa; ?></h4>
                        <p class="text-white"><?php echo $alerta; ?></p>
                    </div>
                </div>
            </a>-->
             <div class="col-lg-12 col-md-12">
                <a href="#" onclick="detalle_pos('<?php echo $id_pos ?>')" data-toggle="tooltip" title="Ver detalle">
                    <div class="widget-simple text-center card-box" style="background-color: #D4E6F1;">
                        <p class="font-bold mt-0" style="font-size: 12px; color: #17202A;">Pedido:<?php echo $id_pos; ?></p>
                        <p class="font-bold mt-0" style="font-size: 10px; color: #17202A;">Cliente: <?php echo $cliente; ?></p>
                        <p class=" mb-0 font-bold" style="font-size: 12px; color: #17202A;">Total: <?php echo $moneda . ' ' . formato($monto); ?></p>
                        <div class="text-right">
                    </div>

                    </div>
                    </a>
                </div>
                <!--<input type="hidden" class="form-control" style="text-align:center" id="cantidad_<?php echo $id_producto; ?>"  value="1" >
                <input type="hidden" class="form-control" style="text-align:right" id="precio_venta_<?php echo $id_producto; ?>"  value="<?php echo $precio_venta; ?>" >-->

            <?php
}
    ?>
        </div>
            <!-- end row -->
        <span class="pull-center" style="font-size: 10px;">
            <?php
//echo paginate($reload, $page, $total_pages, $adjacents);
    ?></span>


            <?php
}
//Este else Fue agregado de Prueba de prodria Quitar
else {
    ?>
    <div class="alert alert-warning alert-dismissible" role="alert" align="center">
      <strong>Aviso!</strong> No hay Pedidos
  </div>
  <?php
}
// fin else
