<?php
session_start();
require('conexion.php');
$query1 = "SELECT DISTINCT id,presentacion FROM presentacion  GROUP BY presentacion HAVING COUNT(*)>=1";
$query2 = "SELECT DISTINCT id,marca FROM marca  GROUP BY marca HAVING COUNT(*)>=1";
$chofer1 = $mysqli->query($query1);
$chofer2 = $mysqli->query($query2);
$servidor = "localhost";
$usuario = "yoveraes_userdb";
$password ="t7@s5FxYn1GB";
$nombreBD = "yoveraes_botica";
?>
<!DOCTYPE html>
<html lang="es">

<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Productos</title>
    <style>
        /* Estilo para reducir la fuente */
        .tabla-pequena {
            font-size: 14px;
            /* Ajusta el tamaño de la fuente */
            border-collapse: collapse;
            width: 100%;
        }

        .tabla-pequena th,
        .tabla-pequena td {
            border: 1px solid #ddd;
            padding: 8px;
        }

        .tabla-pequena th {
            background-color: #3e64d3;
            text-align: left;
        }
    </style>
    <style>
        img {
            width: 250px;
            height: 200px;
            object-fit: cover;
            border: 1px solid #ccc;
            margin-top: 10px;
            display: none;
        }
    </style>
</head>

<form id="frmProductos" autocomplete="off">
    <div class="card mb-2">
        <div class="card-body">
            <input type="hidden" id="id_product" name="id_product">
            <div class="row">
                <div class="col-md-2">
                    <label for="" style="cursor:pointer;color:rgb(12,12,12);">Barcode <span
                            class="text-danger">*</span></label>
                    <div class="input-group mb-3">
                        <div class="input-group-prepend">
                            <span class="input-group-text"><i class="fas fa-barcode"></i></span>
                        </div>
                        <input style="cursor:pointer; width: 70px; font-size:14px; color:rgb(12,12,12);" type="text"
                            class="form-control" id="barcode" name="barcode" placeholder="Barcode">
                    </div>
                </div>
                <div class="col-md-4">
                    <label for="" style="cursor:pointer;color:rgb(12,12,12);">Nombre Producto <span
                            class="text-danger">*</span></label>
                    <div class="input-group mb-3">
                        <div class="input-group-prepend">
                            <span class="input-group-text"><i class="fas fa-list"></i></span>
                        </div>
                        <input style="cursor:pointer; width: 80px; font-size:14px;color:rgb(12,12,12);" type="text"
                            class="form-control" id="nombre" name="nombre" placeholder="Descripcion">
                    </div>
                </div>
                <div class="col-md-2">
                    <label for="" style="cursor:pointer;color:rgb(12,12,12);">Presentación <span
                            class="text-danger">*</span></label>
                    <div class="input-group mb-2">
                        <div class="input-group-prepend">
                            <span class="input-group-text"><i class="fas fa-clipboard-check"></i></span>
                        </div>
                        <select id="presentacion" name="presentacion" class="custom-select"
                            style="cursor:pointer; width:80px;font-size:13px;text-align:left;background-color: rgb(255,255,255);color: rgb(0,0,0);">
                            <option value="" style=" width: 500px; font-size:18px;"></option>
                            <?php while ($row = $chofer1->fetch_assoc()) { ?>
                                <option value="<?php echo $row['presentacion']; ?>">
                                    <?php echo $row['presentacion']; ?>
                                </option>
                            <?php } ?>
                        </select>
                    </div>
                </div>
                <div class="col-md-2">
                    <label for="" style="cursor:pointer;color:rgb(33,33,255);">Precio Venta <span
                            class="text-danger">*</span></label>
                    <div class="input-group mb-2">
                        <div class="input-group-prepend">
                            <span class="input-group-text"><i class="far fa-money-bill-alt"></i></span>
                        </div>
                        <input style="cursor:pointer; width: 80px; font-size:14px;text-align:right;color:rgb(12,12,12);"
                            type="text" class="form-control" id="precio" name="precio" placeholder="0.00">
                    </div>
                </div>
                <div class="col-md-2">
                    <label for="" style="cursor:pointer;color:rgb(39,168,68);">Stock Actual<span
                            class="text-danger">*</span></label>
                    <div class="input-group mb-2">
                        <div class="input-group-prepend">
                            <span class="input-group-text"><i class="fas fa-clipboard-list"></i></span>
                        </div>
                        <input
                            style="cursor:pointer; width: 80px; font-size:16px;text-align:center;color:rgb(12,12,12);"
                            type="text" class="form-control" id="stock" name="stock" placeholder="0">
                    </div>
                </div>
                <div class="col-md-2">
                    <label for="" style="cursor:pointer;color:rgb(255,33,33);">Precio Costo
                        <span class="text-danger">*</span></label>
                    <div class="input-group mb-2">
                        <div class="input-group-prepend">
                            <span class="input-group-text"><i class="fas fa-money-bill-wave"></i></span>
                        </div>
                        <input
                            style="cursor:pointer; width: 80px; font-size:14px; text-align:right; color:rgb(12,12,12);"
                            type="text" class="form-control" id="costos" name="costos" placeholder="0.00">
                    </div>
                </div>
                <div class="col-md-2">
                    <label for="" style="cursor:pointer;color:rgb(235,128,56);">Precio Por Tira <span
                            class="text-danger">*</span></label>
                    <div class="input-group mb-2">
                        <div class="input-group-prepend">
                            <span class="input-group-text"><i class="far fa-money-bill-alt"></i></span>
                        </div>
                        <input style="cursor:pointer; width: 80px; font-size:14px;text-align:right;color:rgb(12,12,12);"
                            type="text" class="form-control" id="pvpblister" name="pvpblister" placeholder="0.00">
                    </div>
                </div>
                <div class="col-md-2">
                    <label for="" style="cursor:pointer;color:rgb(235,128,56);">Cantidad Por Tira <span class="
                        text-danger">*</span></label>
                    <div class="input-group mb-2">
                        <div class="input-group-prepend">
                            <span class="input-group-text"><i class="fab fa-bootstrap"></i></span>
                        </div>
                        <input
                            style="cursor:pointer; width: 80px; font-size:14px;text-align:center;color:rgb(12,12,12);"
                            type="text" class="form-control" id="porblister" name="porblister" placeholder="0">
                    </div>
                </div>
                <div class="col-md-2">
                    <label for="" style="cursor:pointer;color:rgb(0,128,0);">Precio Caja <span
                            class="text-danger">*</span></label>
                    <div class="input-group mb-2">
                        <div class="input-group-prepend">
                            <span class="input-group-text"><i class="far fa-money-bill-alt"></i></span>
                        </div>
                        <input
                            style="cursor:pointer; width: 80px; font-size:14px;text-align:right; color:rgb(12,12,12);"
                            type="text" class="form-control" id="pvpcaja" name="pvpcaja" placeholder="0.00">
                    </div>
                </div>
                <div class="col-md-2">
                    <label for="" style="cursor:pointer;color:rgb(0,128,0);">Cantidad Por Caja <span
                            class="text-danger">*</span></label>
                    <div class="input-group mb-2">
                        <div class="input-group-prepend">
                            <span class="input-group-text"><i class="fas fa-box-open"></i></span>
                        </div>
                        <input
                            style="cursor:pointer; width: 80px; font-size:14px;text-align: center;color:rgb(12,12,12);"
                            type="text" class="form-control" id="porcaja" name="porcaja" placeholder="0">
                    </div>
                </div>
                <div class="col-md-2">
                    <label for="" style="cursor:pointer;color:rgb(0,114,198);">Marca<span
                            class="text-danger">*</span></label>
                    <div class="input-group mb-2">
                        <div class="input-group-prepend">
                            <span class="input-group-text"><i class="fas fa-folder-open"></i></span>
                        </div>
                        <select id="laboratorio" name="laboratorio" class="custom-select"
                            style="cursor:pointer; width:80px;font-size:13px;text-align:left;background-color: rgb(255,255,255);color: rgb(0,0,0);">
                            <option value="" style=" width: 500px; font-size:18px;"></option>
                            <?php while ($row = $chofer2->fetch_assoc()) { ?>
                                <option value="<?php echo $row['marca']; ?>">
                                    <?php echo $row['marca']; ?>
                                </option>
                            <?php } ?>
                        </select>
                    </div>
                </div>
            </div>
        </div>
        <div class="card-footer text-right">
            <button type="button" class="btn btn-danger" id="btn-nuevo">Nuevo</button>
            <button type="submit" class="btn btn-primary" id="btn-save">Guardar</button>
        </div>
    </div>
</form>
<div class="card">
    <div class="card-body">
        <div class="table-responsive">
            <table class="table table-striped table-hover tabla-pequena" style="width: 100%;" id="table_productos">
                <thead class="table-dark table-bordered">
                    <tr>
                        <th style=" cursor:pointer;color:rgb(255,255,255);text-align:center;" scope="col">Id</th>
                        <th style="cursor:pointer;color:rgb(255,255,255);text-align:center;" scope="col">Barcod.</th>
                        <th style="cursor:pointer;color:rgb(255,255,255);text-align:center;" scope="col">Producto
                        </th>
                        <th style="cursor:pointer;color:rgb(255,255,255);text-align:center;" scope="col">Present.</th>
                        <th style="cursor:pointer;color:rgb(255,255,255);text-align:center;" scope="col">Stock</th>
                        <th style="cursor:pointer;color:rgb(255,255,255);text-align:center;" scope="col">Costo</th>
                        <th style="cursor:pointer;color:rgb(255,255,255);text-align:center;" scope="col">Venta</th>
                        <th style="cursor:pointer;color:rgb(255,255,255);text-align:center;" scope="col">P.Tira</th>
                        <th style="cursor:pointer;color:rgb(255,255,255);text-align:center;" scope="col">C.Tira</th>
                        <th style="cursor:pointer;color:rgb(255,255,255);text-align:center;" scope="col">P.Caja</th>
                        <th style="cursor:pointer;color:rgb(255,255,255);text-align:center;" scope="col">C.Caja</th>
                        <th style="cursor:pointer;color:rgb(255,255,255);text-align:center;" scope="col">Marca</th>
                        <th></th>
                    </tr>
                </thead>
                <tbody>
                </tbody>
            </table>
        </div>
    </div>
</div>