<?php 
if (!isset($_SESSION['nombre'])) {
  header("Location: login.html");
}else{

  if ($_SESSION['almacen']==1) {
    ?>
      <!-- Main content -->
      <section class="content">
          <!-- Default box -->
        <div class="row">
          <div class="col-md-12">
            <div class="box">
                <div class="box-header with-border">
                    <button class="btn bg-green btn-app" onclick="mostrarform(true)" id="btnagregar"><i class="fa fa-plus-circle"></i>Agregar</button> 
                    <a target="_blank" href='<?php echo SERVERURL ?>reportes/rptarticulos.php'>
                    <button class="btn bg-blue btn-app" id="btnreporte"><i class="fa fa-clipboard"></i>Reporte</button></a></h1>
                    <div class="box-tools pull-right">
                      <h1 class="box-title">Almacen\Productos
                    </div>
                </div>
                <!--box-header-->
                <!--centro-->
                <div class="panel-body table-responsive" id="listadoregistros">
                  <table id="tbllistado" class="table table-striped table-bordered table-condensed table-hover">
                    <thead>
                      <th>Opciones</th>
                      <th>Nombre</th>
                      <th>Categoria</th>
                      <th>Codigo</th>
                      <th>Stock</th>
                      <th>Precio</th>
                      <th>Costo</th>
                      <th>Imagen</th>
                      <th>Descripcion</th>
                      <th>Estado</th>
                    </thead>
                    <tbody>
                    </tbody>
                    <tfoot>
                      <th>Opciones</th>
                      <th>Nombre</th>
                      <th>Categoria</th>
                      <th>Codigo</th>
                      <th>Stock</th>
                      <th>Precio</th>
                      <th>Costo</th>
                      <th>Imagen</th>
                      <th>Descripcion</th>
                      <th>Estado</th>
                    </tfoot>   
                  </table>
                </div>
               
                <div class="panel-body" id="formularioregistros">
                  <div class="form-group col-lg-12 col-md-12 col-xs-12">
                    <form action="" name="formulario" id="formulario" method="POST">   
                      <div class="form-group col-lg-5 col-md-5 col-xs-12">
                        <label for="">Nombre(*):</label>
                        <input class="form-control" type="hidden" name="idarticulo" id="idarticulo">
                        <input class="form-control" type="hidden" name="validado" id="validado">
                        <input class="form-control" type="text" name="nombre" id="nombre" maxlength="100" placeholder="Nombre" >
                      </div>
                      <div class="form-group col-lg-7 col-md-7 col-xs-12">
                        <label for="">Descripcion</label>
                        <input class="form-control" type="text" name="descripcion" id="descripcion" maxlength="256" placeholder="Descripcion">
                      </div>
                      <div class="form-group col-lg-3 col-md-3 col-xs-12">
                        <label for="">Almacen:</label>
                        <select name="idalmacen" id="idalmacen" class="form-control selectpicker" data-Live-search="true" ></select>
                      </div>
                      <div class="form-group col-lg-3 col-md-3 col-xs-12">
                        <label for="">Categoria:</label>
                        <select name="idcategoria" id="idcategoria" class="form-control selectpicker" data-Live-search="true" ></select>
                      </div>
                      <div class="form-group col-lg-3 col-md-3 col-xs-12">
                        <label for="">Categoria de Medida:</label>
                        <select name="idcategoriadeunidades" id="idcategoriadeunidades" class="form-control selectpicker" data-Live-search="true" ></select>
                      </div>
                      <div class="form-group col-lg-3 col-md-3 col-xs-12">
                        <label for="">Unidad de Medida</label>
                        <select name="idunidademedidad" id="idunidademedidad" class="form-control selectpicker" data-Live-search="true" ></select>
                      </div>
                      <div class="form-group col-lg-3 col-md-3 col-xs-12">
                        <label for="">Capacidad de Medida</label>
                        <input class="form-control" type="text" name="unidademedidad" id="unidademedidad"  >
                      </div>
                      <div class="form-group col-lg-3 col-md-3 col-xs-12">
                        <label for="">FactorConversión de Medida:</label>
                        <select name="idfactorunidademedidad" id="idfactorunidademedidad" class="form-control selectpicker" data-Live-search="true" ></select>
                      </div>
                      <div class="form-group col-lg-3 col-md-3 col-xs-12">
                        <label for="">Tipo Producto:</label>
                        <select name="idtipoarticulo" id="idtipoarticulo" class="form-control selectpicker" data-Live-search="true" ></select>
                      </div>
                      <div class="form-group col-lg-3 col-md-3 col-xs-12">
                        <label for="">Grado Alcohol:</label>
                        <input class="form-control" type="text" name="gradoalcohol" id="gradoalcohol" >
                      </div>
                      
                      <div class="form-group col-lg-3 col-md-3 col-xs-12">
                        <label for="">Precio Venta</label>
                        <input class="form-control" type="text" name="precio" id="precio"  >
                      </div>
                      <div class="form-group col-lg-3 col-md-3 col-xs-12">
                        <label for="">Precio (PVP)</label>
                        <input class="form-control" type="text" name="preciopvp" id="preciopvp"  >
                      </div>
                      <div class="form-group col-lg-3 col-md-3 col-xs-12">
                        <label for="">Impuesto Art. 18</label>
                        <input class="form-control" type="text" name="impuestoart18" id="impuestoart18"  >
                      </div>
                      <div class="form-group col-lg-3 col-md-3 col-xs-12">
                        <label for="">Costo</label>
                        <input class="form-control" type="text" name="costo" id="costo"  >
                      </div>
                      <div class="form-group col-lg-3 col-md-3 col-xs-12">
                        <label for="">Stock</label>
                        <input class="form-control" type="text" name="stock" id="stock" value="0" >
                      </div>
                      <div class="form-group col-lg-3 col-md-3 col-xs-12">
                        <label for="">Codigo:</label>
                        <input class="form-control" type="text" name="codigo" id="codigo" placeholder="codigo del producto" >
                        <div><br>
                          <button class="btn btn-success" type="button" onclick="generarbarcode()">Generar</button>
                          <button class="btn btn-info" type="button" onclick="imprimir()">Imprimir</button>
                        </div>
                        <div id="print">
                          <svg id="barcode"></svg>
                        </div>
                      </div>
                      <div class="form-group col-lg-3 col-md-3 col-xs-12">
                        <label for="">Imagen:</label>
                        <input class="form-control" type="file" name="imagen" id="imagen">
                        <input type="hidden" name="imagenactual" id="imagenactual">
                        <img src="" alt="" width="150px" height="120" id="imagenmuestra">
                      </div>
                      <div class="form-group col-lg-3 col-md-3 col-xs-12">
                        <label for="">Exento de iva:</label>
                        <br>
                        <input type="checkbox" name="exento" id="exento" value="si">
                        <input type="hidden" name="exento1" id="exento1">
                      </div>
                    </form> 
                  </div>
                </div>
                <!--fin centro-->
                <div class="box-footer" id="formularioregistros1">
                    <button class="btn bg-blue btn-app pull-right" type="submit" id="btnGuardar"><i class="fa fa-save"></i>  Guardar</button>
                    <button class="btn bg-red btn-app pull-right" onclick="cancelarform()" type="button"><i class="fa fa-arrow-circle-left"></i> Cancelar</button>
                </div>
              
            </div>

          </div>
        </div>
                    <!-- /.box -->
      </section>
      <!-- /.content -->
      </div>
          <!-- /.content-wrapper -->
  <?php 
  }else{
    require 'vistas/contenidos/noacceso-view.php'; 
  }
  ?>       
          <!-- Main Footer -->
          <?php include "vistas/modulos/mainfooter.php";?>
      </div>

      <!-- ./wrapper -->
      <!-- REQUIRED JS SCRIPTS -->
      <?php include "vistas/modulos/script.php";?>
      <script src="vistas/public/js/JsBarcode.all.min.js"></script>
      <script src="vistas/public/js/jquery.PrintArea.js"></script>
      <script src="vistas/scripts/articulo.js"></script>
  </body>
  </html> 
  <?php 
}
ob_end_flush();
?>