<script src="<?= ruta_base() ?>public/assets/js/vue-treeselect.umd.min.js"></script>
<link rel="stylesheet" href="<?= ruta_base() ?>public/assets/css/vue-treeselect.min.css">
<div class="container" id="appEditarProductos" v-cloak>
    <input type="hidden" id="id_producto" value="<?= $producto['pro_id']; ?>">
    <div class="page-inner">
        <div class="page-header">
            <h4 class="page-title">Producto</h4>
            <ul class="breadcrumbs">
                <li class="nav-home">
                    <a href="<?= ruta_base() ?>">
                        <i class="flaticon-home"></i>
                    </a>
                </li>
                <li class="separator">
                    <i class="flaticon-right-arrow"></i>
                </li>
                <li class="nav-item">
                    <a href="<?= ruta_base() ?>productos/editar/<?= $producto['pro_id']; ?>">ver</a>
                </li>
                <li class="separator">
                    <i class="flaticon-right-arrow"></i>
                </li>
                <li class="nav-item">
                    <a href="<?= ruta_base() ?>productos/editar/<?= $producto['pro_id']; ?>" id="gui_cliente"><?= $producto['pro_descripcion']; ?></a>
                </li>
            </ul>
            <div class="ml-md-auto" style="display: flex;">
                <a href="<?= ruta_base() ?>productos" class="btn btn-info btn-round btn-sm mr-2"  data-toggle="modal" data-target="#modal_id_producto"><span class="fa fa-search"></span> Buscar producto</a>
                <a href="<?= ruta_base() ?>productos" class="btn btn-sm btn-info btn-border btn-round mr-2"><span class="fa fa-flip-horizontal fa-share"></span> Productos</a>
                <div class="dropdown d-inline mr-3 mr-md-2">
                    <button class="btn btn-sm btn-info btn-round dropdown-toggle" type="button" id="dropdownMenuButton" data-toggle="dropdown" aria-haspopup="true" aria-expanded="false">
                        Opciones
                    </button>
                    <div class="dropdown-menu">
                        <a class="dropdown-item" href="<?= url('fabricantes') ?>">Fabricantes</a>
                        <a class="dropdown-item" href="<?= url('proveedores') ?>">Proveedores</a>
                        <a class="dropdown-item" href="<?= url('categorias') ?>">Categorias</a>
                        <a class="dropdown-item" href="<?= url('tarifas') ?>">Tarifas</a>
                        <a class="dropdown-item" href="<?= url('almacenes') ?>">Almacenes</a>
                    </div>
                </div>
                <a href="<?= ruta_base() ?>productos/crear" class="btn btn-sm btn-info btn-border btn-round mr-2"><span class="fa fa-save"></span> Nuevo Producto</a>
            </div>
        </div>
        <div class="row">
            <div class="col-12 col-md-2">
                <div class="nav flex-column nav-pills nav-secondary nav-pills-no-bd nav-pills-icons" id="v-pills-tab" role="tablist" aria-orientation="vertical">
                    <a class="nav-link active" data-toggle="pill" href="#pills-productos" role="tab" aria-controls="pills-productos" aria-selected="true">
                        <?php if ($producto['pro_tipo'] == 1) :  ?>
                            Producto
                        <?php endif; ?>
                        <?php if ($producto['pro_tipo'] == 2) :  ?>
                            Producto Compuesto
                        <?php endif; ?>
                        <?php if ($producto['pro_tipo'] == 3) :  ?>
                            Servicio
                        <?php endif; ?>
                    </a>
                     <?php if (($producto['pro_tipo'] == 1) || ($producto['pro_tipo'] == 2)) :  ?>
                        <a class="nav-link" data-toggle="pill" href="#pills-peso" role="tab" aria-controls="pills-peso" aria-selected="false">Peso</a>
                    <?php endif; ?>
                    <?php if ($producto['pro_tipo'] != 3) :  ?>
                        <a class="nav-link" href="#" @click="modalCodBarra">Cod. barra</a>
                    <?php endif; ?>
                    <a class="nav-link" href="#" @click="modalFactorProducto">Factor</a>
                    <?php if ($producto['pro_tipo'] != 2) :  ?>
                        <a class="nav-link" data-toggle="pill" href="#pills-precio" role="tab" aria-controls="pills-precio" aria-selected="false">Precio</a>
                    <?php endif;  ?>
                    <?php if ($producto['pro_tipo'] != 3) :  ?>
                        <a class="nav-link" data-toggle="pill" href="#pills-stock" role="tab" aria-controls="pills-stock" aria-selected="false">Stock</a>
                    <?php endif;  ?>
                    <a class="nav-link" data-toggle="pill" href="#pills-imagen" role="tab" aria-controls="pills-imagen" aria-selected="false">Imagen</a>
                    <a class="nav-link" data-toggle="pill" href="#pills-bitacora" role="tab" aria-controls="pills-bitacora" aria-selected="false">Bitácora</a>
                    <?php if ($producto['pro_tipo'] != 3) :  ?>
                        <a class="nav-link" data-toggle="pill" href="#pills-bitacora-stock" role="tab" aria-controls="pills-bitacora-stock" aria-selected="false" @click="obtenerBitacoraStock">Movimientos</a>
                    <?php endif;  ?>
                    <?php if ($producto['pro_tipo'] != 3) :  ?>
                        <a class="nav-link" data-toggle="pill" href="#pills-ubicacion" role="tab" aria-controls="pills-ubicacion-stock" aria-selected="false">Ubicación</a>
                    <?php endif;  ?>
                    <a class="nav-link" data-toggle="pill" href="#pills-clientes" role="tab" aria-controls="pills-clientes" aria-selected="false">Clientes</a>
                </div>
            </div>
            <div class="col-12 col-md-10">
                <?php require 'form/tab_barra.php'; ?>
                <?php require 'form/modal_factorproducto.php'; ?>
                <div class="tab-content" id="pills-tabContent">
                    <div class="tab-pane fade active show" id="pills-productos" role="tabpanel" aria-labelledby="pills-productos-tab">
                        <?php require 'form/form_productos.php'; ?>
                    </div>
                    <div class="tab-pane fade" id="pills-precio" role="tabpanel" aria-labelledby="pills-precio-tab">
                        <?php if ($editar_precio) : ?>
                            <?php require 'form/form_precio.php'; ?>
                        <?php else : ?>
                            <div class="col-sm-12">
                                <div class="alert alert-warning">
                                    No posee permisos para editar el precio
                                </div>
                            </div>
                        <?php endif; ?>
                    </div>
                    <div class="tab-pane fade" id="pills-peso" role="tabpanel" aria-labelledby="pills-peso-tab">
                        <?php require 'form/tab_peso.php'; ?>
                    </div>
                    <div class="tab-pane fade" id="pills-bitacora" role="tabpanel" aria-labelledby="pills-bitacora-tab">
                        <?php require 'form/tab_bitacora.php'; ?>
                    </div>
                    <?php if ($producto['pro_tipo'] != 3) :  ?>
                        <div class="tab-pane fade" id="pills-stock" role="tabpanel" aria-labelledby="pills-stock-tab">
                            <?php if ($cargar_stock) : ?>
                                <?php require 'form/form_stock.php'; ?>
                            <?php else : ?>
                                <div class="col-sm-12">
                                    <div class="alert alert-warning">
                                        No posee permisos para cargar en stock
                                    </div>
                                </div>
                            <?php endif; ?>
                        </div>
                    <?php endif; ?>
                    
                    <div class="tab-pane fade" id="pills-imagen" role="tabpanel" aria-labelledby="pills-imagen-tab">
                        <?php require 'form/form_imagen.php'; ?>
                    </div>
                    <?php if ($producto['pro_tipo'] != 3) :  ?>
                        <div class="tab-pane fade" id="pills-bitacora-stock" role="tabpanel" aria-labelledby="pills-bitacora-stock-tab">
                            <?php require 'form/tab_bitacora_stock.php'; ?>
                        </div>
                        <div class="tab-pane fade" id="pills-ubicacion" role="tabpanel" aria-labelledby="pills-ubicacion-tab">
                            <?php require 'form/tab_ubicacion.php'; ?>
                        </div>
                    <?php endif; ?>
                    <div class="tab-pane fade" id="pills-clientes" role="tabpanel" aria-labelledby="pills-clientes-tab">
                            <?php require 'form/tab_clientes.php'; ?>
                        </div>
                </div>
            </div>
        </div>
    </div>
      <?php include 'modal_ticket.php'; ?>
</div>
<script src="<?= asset('assets/vue-select.js') ?>"></script> 
<link rel="stylesheet" href="<?= asset('assets/vue-select.css') ?>">
<script src="<?= asset('assets/vue-the-mask.js') ?>"></script>
<script src="<?= asset('assets/moment.min.js') ?>"></script>
<script src="<?= asset('assets/underscore-min.js') ?>"></script>
<link rel="stylesheet" href="<?= asset('assets/ubicaciontreeview.css') ?>">
<script src="<?= asset('assetsvuejs/productos/editar.js') ?>"></script>