<?php
//activamos almacenamiento en el buffer
//ob_start();
//session_start();
if (!isset($_SESSION['nombre'])) {
  header("Location: login.html");
}else{
  if ($_SESSION['compras']==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> 
                    <div class="box-tools pull-right">
                      <h1 class="box-title">Compras\Entradas
                    </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>Fecha</th>
                        <th>Proveedor</th>
                        <th>Usuario</th>
                        <th>Documento</th>
                        <th>Número</th>
                        <th>Total Compra</th>
                        <th>Estado</th>
                      </thead>
                      <tbody>
                      </tbody>
                      <tfoot>
                        <th>Opciones</th>
                        <th>Fecha</th>
                        <th>Proveedor</th>
                        <th>Usuario</th>
                        <th>Documento</th>
                        <th>Número</th>
                        <th>Total Compra</th>
                        <th>Estado</th>
                      </tfoot> 
                    </table>
                  </div>
                    
                  <div class="panel-body" style="height: 400px;" id="formularioregistros">
                    <form action="" name="formulario" id="formulario" method="POST">
                        <input class="form-control" type="hidden" name="idingreso" id="idingreso">
                        <input class="form-control" type="hidden" name="idordencompraingreso" id="idordencompraingreso">
                        <!-- <input class="form-control" type="hidden" name="idalmacen" id="idalmacen" value="1"> -->
                        <input class="form-control" type="hidden" name="validado" id="validado">
                        <input class="form-control" type="hidden" name="tasa_dollar" id="tasa_dollar">
                        <input class="form-control" type="hidden" name="tasa_euro" id="tasa_euro">
                        <input class="form-control" type="hidden" name="idempresa_venta" id="idempresa_venta" value="<?php echo $_SESSION['idempresa_venta_empresa'] ?>" >
                      <div class="form-group col-lg-4 col-md-4 col-xs-12">
                        <label for="">Proveedor:</label>
                        
                        <select name="idproveedor" id="idproveedor" class="form-control selectpicker" data-live-search="true" required>
                          
                        </select>
                      </div>
                      <div class="form-group col-lg-2 col-md-2 col-xs-12">
                        <label for="">Almacen </label>
                        <select name="idalmacen" id="idalmacen" class="form-control selectpicker" required>
                          
                        </select>
                      </div>
                      <div class="form-group col-lg-2 col-md-2 col-xs-12">
                        <label for="">Tipo Comprobante: </label>
                        <select name="tipo_comprobante" id="tipo_comprobante" class="form-control selectpicker" required>
                          <option value="Factura">Factura</option>
                          <option value="NotaEntrega">NotaEntrega</option>
                          <option value="Suministro">Suministro</option>
                        </select>
                      </div>
                      <div class="form-group col-lg-2 col-md-2 col-xs-12" id="serie_comprobante1">
                        <label for="">Nro. Factura: </label>
                        <input class="form-control" type="text" name="serie_comprobante" id="serie_comprobante" maxlength="20" placeholder="Nro. Factura" required>
                      </div>
                      <div class="form-group col-lg-2 col-md-2 col-xs-12" id="num_comprobante1">
                        <label for="">Nro. Control: </label>
                        <input class="form-control" type="text" name="num_comprobante" id="num_comprobante" maxlength="20" placeholder="Nro. Control" required>
                      </div>
                      <div class="form-group col-lg-2 col-md-2 col-xs-12" id="num_suministro1">
                        <label for="">Suministro: </label>
                        <input class="form-control" type="text" name="num_suministro" id="num_suministro" maxlength="20" placeholder="Nro. Suministro" required>
                      </div>
                      <div class="form-group col-lg-2 col-md-2 col-xs-12">
                        <label for="">Fecha Compra: </label>
                        <input class="form-control" type="date" name="fecha_hora" id="fecha_hora" required>
                      </div>
                      <div class="form-group col-lg-2 col-md-2 col-xs-12">
                        <label for="">Fecha Libro: </label>
                        <input class="form-control" type="date" name="fecha_horar" id="fecha_horar" required>
                      </div>
                      <div class="form-group col-lg-2 col-md-2 col-xs-12">
                        <label for="">Impuesto: </label>
                        <input class="form-control" type="text" name="impuesto" id="impuesto">
                      </div>
                      <div class="form-group col-lg-4 col-md-4 col-xs-12" id="igtf1">
                        <label for="">Observación </label>
                        <input class="form-control" type="text" name="observacion" id="observacion">
                      </div>
                      <div class="form-group col-lg-2 col-md-2 col-xs-12" id="igtf">
                        <table border="1" bordercolor="666633" cellpadding="3" cellspacing="3"> 
                          <tr>
                            <td>
                              <div class="form-group col-lg-3 col-md-3 col-xs-12">
                                <label for="igtfvalor">
                                  IGTF
                                  <br>
                                  <div class="icheck-primary d-inline">
                                    <input type="checkbox" id="igtfvalor">
                                  </div>
                                </label>
                                <input class="form-control" type="hidden" name="modopago" id="modopago">
                              </div>
                              <div class="form-group col-lg-9 col-md-9 col-xs-12">
                                <label for="">Monto $ </label>
                                <input class="form-control" type="text" name="montoigtf" id="montoigtf">
                                <input class="form-control" type="hidden" name="montoigtfb" id="montoigtfb">
                              </div>
                            </td>
                          </tr> 
                          <tr>
                            <td>
                              <div class="form-group col-lg-12 col-md-12 col-xs-12" >
                                <label for="">Total IGTF</label>
                                <input class="form-control" type="text" name="montoigtfporcentaje" id="montoigtfporcentaje" readonly>
                                <input class="form-control" type="hidden" name="montoigtfporcentajeb" id="montoigtfporcentajeb" >
                              </div> 
                            </td>
                          </tr>
                        </table>
                      </div>

                      <div class="form-group col-lg-2 col-md-2 col-xs-12" id="igfttotal">
                        <label for="">Total IGTF</label>
                        <input class="form-control" type="text" name="montoigtfporcentajet" id="montoigtfporcentajet" readonly>
                      </div>

                      <div class="form-group table-responsive no-padding col-lg-12 col-md-12 col-xs-12">
                        <!-- <table id="detalles" class="table table-striped table-bordered table-condensed table-hover"> -->
                        <table id="detalles" class="table table-hover"> 
                          <thead style="background-color:#A9D0F5">
                            <th>Opciones</th>
                            <th>Articulo</th>
                            <th>Cantidad</th>
                            <th>Precio Contable Bs</th> 
                            <th>Precio Contable $</th>
                            <th>Precio Análisis Bs</th>
                            <th>Precio Análisis $</th> 
                            <?php if ($_SESSION['paisdeorigen_empresa']=='si') {?>
                              <th>Nro. Cointainer</th>
                              <th>Fecha Llegada</th>
                            <?php }else{ ?>
                              <th>Lote</th>
                              <th>Fecha Venc.</th>
                            <?php } ?>  
                            <th>Subtotal</th>
                          </thead>
                          <tfoot>
                            <tr>
                              <th></th>
                              <th></th>
                              <th></th>
                              <th></th>
                              <th></th>
                              <th></th> 
                              <th></th>
                              <th>SUB-TOTAL</th>
                              <th>
                              <h4 id="totald" style="text-align:left;">$. 0.00</h4>
                              </th>
                              <th>
                                <h4 id="total" style="text-align:left;">Bs. 0.00</h4>
                                <input type="hidden" name="total_compra" id="total_compra">
                                <input type="hidden" name="total_comprad" id="total_comprad">
                                <input type="hidden" name="total_comprai" id="total_comprai">
                                <input type="hidden" name="total_compraid" id="total_compraid">
                              </th>
                            </tr>
                            <tr>
                              <th></th>
                              <th></th>
                              <th></th>
                              <th></th>
                              <th></th>
                              <th></th> 
                              <th></th>
                              <th>IVA</th>
                              <th>
                              <h4 id="totalivad" style="text-align:left;">$. 0.00</h4>
                              </th>
                              <th>
                                <h4 id="totaliva" style="text-align:left;">Bs. 0.00</h4>
                              
                              </th>
                            </tr>
                            <tr>
                              <th></th>
                              <th></th>
                              <th></th>
                              <th></th>
                              <th></th>
                              <th></th> 
                              <th></th>
                              <th>TOTAL</th>
                              <th>
                              <h4 id="totaltd">$. 0.00</h4>
                              </th>
                              <th>
                                <h4 id="totalt">Bs. 0.00</h4>
                                
                              </th>
                            </tr>
                          </tfoot>
                          <tbody>
                            
                          </tbody>
                        </table>
                      </div>
                    </form>
                  </div>
                  <div class="box-footer" id="formularioregistros1">
                    <div class="btn-group col-lg-12 col-md-12 col-xs-12">
                      <div class="form-group col-lg-4 col-md-4 col-xs-12">
                      <!-- <a data-toggle="modal" href="#myModalArt"> -->
                          <button type="button" class="btn bg-blue btn-app pull-left" id="btnAgregarArt"><i class="fa fa-barcode"></i>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;Productos&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</button>
                          <!-- <button type="button" class="btn bg-green btn-app pull-left" id="btnAgregarArto"><i class="fa fa-th-list"></i>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;Oficina&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</button> -->
                          <button type="button" class="btn bg-navy btn-app pull-left" id="btnAgregarArti"><i class="fa fa-th-list"></i>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;Insumo&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</button>
                          <!-- <a data-toggle="modal" href="#myModalOrdedecompra">
                           <button type="button" class="btn bg-yellow btn-app pull-left" id="btnAgregarOrd"><i class="fa fa-truck"></i>Orden de Compra</button> -->
                          <!-- </a> -->
                        <!-- </a> -->  
                        <!-- <a data-toggle="modal" href="#myModalSer"> -->
                          <button type="button" class="btn bg-yellow btn-app pull-left" id="btnAgregarSer"><i class="fa fa-envelope"></i>Servicios</button>
                        <!-- </a> -->
                      </div>
                      <div class="form-group col-lg-4 col-md-4 col-xs-12">
                          <label for="" id="labelcodigobarra">Ingrese en codigo de barra </label>
                          <input class="form-control" type="text" name="cod_barra" id="cod_barra" maxlength="30" placeholder="Codigo Barra Producto" >
                          
                       
                      </div>
                      <div class="form-group col-lg-4 col-md-4 col-xs-12">
                        <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>
                    
                  <!--fin centro-->
              </div>
            </div>
          </div>
          <!-- /.box -->
        </section>
      <!-- /.content -->
    </div>

      <!--Modal-->
        <div class="modal fade" id="myModalArt" tabindex="-1" role="dialog" aria-labelledby="myModalLabel" aria-hidden="true">
          <div class="modal-dialog" style="width: 90% !important;">
            <div class="modal-content">
              <div class="modal-header">
                <button type="button" class="close" data-dismiss="modal" aria-hidden="true">&times;</button>
                <h4 class="modal-title">Seleccione un Artículo</h4>
              </div>
              <div class="modal-body table-responsive no-padding">
                <table id="tblarticulos" class="table table-hover" style="width: 100%">
                  <thead>
                    <th>Opciones</th>
                    <th>Nombre</th>
                    <th>Categoria</th>
                    <th>Código</th>
                    <th>Stock</th>
                    <th>Imagen</th>
                  </thead>
                  <tbody>
                    
                  </tbody>
                  <tfoot>
                    <th>Opciones</th>
                    <th>Nombre</th>
                    <th>Categoria</th>
                    <th>Código</th>
                    <th>Stock</th>
                    <th>Imagen</th>
                  </tfoot>
                </table>
              </div>
              <div class="modal-footer">
                <button class="btn btn-default" type="button" data-dismiss="modal">Cerrar</button>
              </div>
            </div>
          </div>
        </div>
        <div class="modal fade" id="myModalArto" tabindex="-1" role="dialog" aria-labelledby="myModalLabel" aria-hidden="true">
          <div class="modal-dialog" style="width: 55% !important;">
            <div class="modal-content">
              <div class="modal-header">
                <button type="button" class="close" data-dismiss="modal" aria-hidden="true">&times;</button>
                <h4 class="modal-title">Seleccione un Artículo</h4>
              </div>
              <div class="modal-body">
                <table id="tblarticuloso" class="table table-striped table-bordered table-condensed table-hover">
                  <thead>
                    <th>Opciones</th>
                    <th>Nombre</th>
                    <th>Categoria</th>
                    <th>Código</th>
                    <th>Stock</th>
                    <th>Imagen</th>
                  </thead>
                  <tbody>
                    
                  </tbody>
                  <tfoot>
                    <th>Opciones</th>
                    <th>Nombre</th>
                    <th>Categoria</th>
                    <th>Código</th>
                    <th>Stock</th>
                    <th>Imagen</th>
                  </tfoot>
                </table>
              </div>
              <div class="modal-footer">
                <button class="btn btn-default" type="button" data-dismiss="modal">Cerrar</button>
              </div>
            </div>
          </div>
        </div>
        <div class="modal fade" id="myModalArti" tabindex="-1" role="dialog" aria-labelledby="myModalLabel" aria-hidden="true">
          <div class="modal-dialog" style="width: 55% !important;">
            <div class="modal-content">
              <div class="modal-header">
                <button type="button" class="close" data-dismiss="modal" aria-hidden="true">&times;</button>
                <h4 class="modal-title">Seleccione un Insumo</h4>
              </div>
              <div class="modal-body">
                <table id="tblarticulosi" class="table table-striped table-bordered table-condensed table-hover">
                  <thead>
                    <th>Opciones</th>
                    <th>Nombre</th>
                    <th>Categoria</th>
                    <th>Código</th>
                    <th>Stock</th>
                    <th>Imagen</th>
                  </thead>
                  <tbody>
                    
                  </tbody>
                  <tfoot>
                    <th>Opciones</th>
                    <th>Nombre</th>
                    <th>Categoria</th>
                    <th>Código</th>
                    <th>Stock</th>
                    <th>Imagen</th>
                  </tfoot>
                </table>
              </div>
              <div class="modal-footer">
                <button class="btn btn-default" type="button" data-dismiss="modal">Cerrar</button>
              </div>
            </div>
          </div>
        </div>                      

        <div class="modal fade" id="myModalSer" tabindex="-1" role="dialog" aria-labelledby="myModalLabel" aria-hidden="true">
          <div class="modal-dialog" style="width: 45% !important;">
            <div class="modal-content">
              <div class="modal-header">
                <button type="button" class="close" data-dismiss="modal" aria-hidden="true">&times;</button>
                <h4 class="modal-title">Seleccione un Servicios</h4>
              </div>
              <div class="modal-body">
                <table id="tblservicios" class="table table-striped table-bordered table-condensed table-hover">
                    <thead>
                      <th>Opciones</th>
                      <th>Nombre</th>
                      <th>Categoria</th>
                      <th>Precio</th>
                      <th>Porcenjate</th>
                    </thead>
                    <tbody>
                      
                    </tbody>
                    <tfoot>
                      <th>Opciones</th>
                      <th>Nombre</th>
                      <th>Categoria</th>
                      <th>Precio</th>
                      <th>Porcentaje</th>
                    </tfoot>
                </table>
              </div>
              <div class="modal-footer">
                <button class="btn btn-default" type="button" data-dismiss="modal">Cerrar</button>
              </div>
            </div>
          </div>
        </div>

        <div class="modal fade" id="myModalOrd" tabindex="-1" role="dialog" aria-labelledby="myModalLabel" aria-hidden="true">
          <div class="modal-dialog" style="width: 55% !important;">
            <div class="modal-content">
              <div class="modal-header">
                <button type="button" class="close" data-dismiss="modal" aria-hidden="true">&times;</button>
                <h4 class="modal-title">Seleccione una Orden de Compra</h4>
              </div>
              <div class="modal-body">
                <!-- "0"=>$boton,
						"1"=>$reg->fecha,
						"2"=>$reg->proveedor,
						"3"=>$reg->usuario,
						"4"=>$reg->tipo_comprobante,
						"5"=>$reg->num_ordencompraingreso,
						"6"=>number_format($reg->total_comprad,2,',','.'),
						/* "7"=>($reg->estado=='Aceptado')?'<span class="label bg-green">Aceptado</span>':'<span class="label bg-red">Anulado</span>' */
						"7"=>$estado	 -->
                <table id="tblordens" class="table table-striped table-bordered table-condensed table-hover">
                    <thead>
                      <th>Opciones</th>
                      <th>fecha</th>
                      <th>proveedor</th>
                      <th>usuario</th>
                      <th>Tipo</th>
                      <th># Ingreso</th>
                      <th>Monto</th>
                      <th>Estado</th>
                    </thead>
                    <tbody>
                      
                    </tbody>
                    <tfoot>
                    <th>Opciones</th>
                      <th>fecha</th>
                      <th>proveedor</th>
                      <th>usuario</th>
                      <th>Tipo</th>
                      <th># Ingreso</th>
                      <th>Monto</th>
                      <th>Estado</th>
                    </tfoot>
                </table>
              </div>
              <div class="modal-footer">
                <button class="btn btn-default" type="button" data-dismiss="modal">Cerrar</button>
              </div>
            </div>
          </div>
        </div>

        <div class="modal fade" id="myModalIngresobs" tabindex="-1" role="dialog" aria-labelledby="myModalLabel" aria-hidden="true">
          <div class="modal-dialog" style="width: 65% !important;">
            <div class="modal-content">
              <div class="modal-header">
                <button type="button" class="close" data-dismiss="modal" aria-hidden="true">&times;</button>
                <h4 class="modal-title">Número Factura :<label id="nrofactura"></label> Número Entrega: <label id="nroentrega"></label> </h4>
              </div>
              <div class="modal-body">
                <table id="tbingresobs" class="table table-striped table-bordered table-condensed table-hover" style="width:100%">
                  <thead>

                    <th>Fecha</th>
                    <th>Compras Bs.</th>
                    <th>Iva Bs.</th>
                    <th>Retención Iva Bs.</th>
                    <th>Retención ISLR Bs.</th>
                    <th>IGTF Bs.</th>
                    <th>Monto Bs.</th>
                    
                  </thead>
                  <tbody>
                    
                  </tbody>
                  <tfoot>
                    <th></th>
                    <th></th>
                    <th></th>
                    <th></th>
                    <th></th>
                    <th></th>
                    <th></th>
                    
                    
                    
                  </tfoot>
                </table>
              </div>
              <div class="modal-footer">
                <button class="btn btn-default" type="button" data-dismiss="modal">Cerrar</button>
              </div>
            </div>
          </div>
        </div>

      <!-- fin Modal-->
  <?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/scripts/ingresoinsumocosto.js"></script>
  </body>
  </html>
  <?php 
}
ob_end_flush();
?>

