<?php
//activamos almacenamiento en el buffer
//ob_start();
//session_start();
if (!isset($_SESSION['nombre'])) {
  header("Location: login.html");
}else{
  if ($_SESSION['ventas']==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="verificarymostar()" id="btnagregar"><i class="fa fa-plus-circle"></i> Agregar</button></h1>
                <div class="box-tools pull-right">
                  <h1 class="box-title">Control de Visita/Seguimiento de Visita   
                </div>
              </div>
              <!--box-header-->
              <!--centro-->
              <div class="callout callout-info" style="margin-bottom: 0!important;text-align: center;" id="listadosemana">
                <!-- <h4><i class="fa fa-info"></i> Note:</h4> -->
                <?php 
                  $fechaActual = date("d-m-Y");
                  $semanaActual = date("W", strtotime($fechaActual));
                ?>
               
                <h4 class="box-title"> 
                  <i class="fa fa-bullhorn"></i>  
                  La fecha actual es: <?php  echo  $fechaActual ?> 
                  y estamos en la semana número: <span class="bg-green"><?php  echo   $semanaActual ?></span>
                </h4>
              </div>
             
              <div class="panel-body table-responsive" id="listadoregistros">
                <table id="tbllistado" class="table table-striped table-bordered table-condensed table-hover">
                  <thead>
                    <th style="text-align:center" valign="middle">Opciones</th>
                    <th style="text-align:center" valign="middle">Fecha</th>
                    <th style="text-align:center" valign="middle">Semana</th>
                    <th style="text-align:center" valign="middle">Día</th>
                    <th style="text-align:center" valign="middle">Número</th>
                    <th style="text-align:center" valign="middle">Usuario</th>
                    <th style="text-align:center" valign="middle">Estado</th>
                  </thead>
                  <tbody>
                  </tbody>
                  <tfoot>
                    <th></th>
                    <th></th>
                    <th></th>
                    <th></th>
                    <th></th>
                    <th></th>
                    <th></th>
                  </tfoot>   
                </table>
              </div>
              <div class="box-body table-responsive pad" id="tarjetasdecliente">
                     <!-- Se muestran las tarjetas -->
              </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="idcontrolvisita" id="idcontrolvisita">
                    <input class="form-control" type="hidden" name="validado" id="validado">
                    <input class="form-control" type="hidden" name="impuesto" id="impuesto" value=<?php echo $_SESSION['iva_empresa'] ?>>
                    
                    <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'] ?>" >
                    <input class="form-control" type="hidden" name="idu" id="idu" value="<?php echo $_SESSION['idusuario'] ?>">
                    
                 
                  <div class="form-group col-lg-3 col-md-3 col-xs-12">
                    <label for="">Número de Control de Visita</label>
                    <input class="form-control" type="text" name="num_controlvisita" id="num_controlvisita" maxlength="50" placeholder="Número" required readonly>
                  </div>
                  <div class="form-group col-lg-3 col-md-3 col-xs-12">
                    <label for="">Fecha(*): </label>
                    <input class="form-control" type="date" name="fecha_hora" id="fecha_hora" required>
                  </div>
                  <div class="form-group col-lg-3 col-md-3 col-xs-12">
                    <label for="">Semana </label>
                    <input class="form-control" type="text" name="semana" id="semana" required readonly>
                  </div>
                  <div class="form-group col-lg-3 col-md-3 col-xs-12">
                    <label for="">Día </label>
                    <input class="form-control" type="text" name="dia" id="dia" required readonly>
                  </div>
                                    
                  
                  
                  <!-- table table-bordered table-hover -->
                  <!-- table table-striped table-bordered table-condensed table-hover -->
                  <div class="form-group col-lg-12 col-md-12 col-xs-12">
                    <span id="tabvisita"></span>
                    <!--<table id="detalles" class="table table-bordered table-condensed table-hover">
                      <thead style="background-color:#A9D0F5">
                         <th width=10>Opciones</th>
                        <th>Articulo</th>
                        <th>Cantidad</th>
                        <th>Precio Bs.</th>
                        <th>Precio $</th>
                        <th>Porcentaje</th>
                        <th>Descuento</th> 
                        <th>Subtotal</th>
                      </thead>
                      <tfoot>-->
                       <!-- <th>TOTAL</th>
                        <th></th>
                        <th></th>
                        <th></th>
                         <th></th>
                        <th></th> 
                        <th></th>
                        <th><h4 id="total">0.00 Bs.</h4><input type="hidden" name="total_venta" id="total_venta"></th>
                      </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="#myModalA">
                        <button type="button" class="btn bg-blue btn-app pull-left" id="btnAgregarArt"><i class="fa fa-inbox"></i>Productos Cafeteria</button>
                      </a>
                      <a data-toggle="modal" href="#myModalAb">
                        <button type="button" class="btn bg-yellow btn-app pull-left" id="btnAgregarArtb"><i class="fa fa-inbox"></i>Productos Bodegon</button>
                      </a>    
                      <a data-toggle="modal" href="#myModalB">
                        <button type="button" class="btn bg-yellow btn-app pull-left" id="btnAgregarBar"><i class="fa fa-envelope"></i>Barra</button>
                      </a> -->
                    </div>
                    <div class="form-group col-lg-4 col-md-4 col-xs-12">
                      <!-- <label id="label_cod_barra" name="label_cod_barra" for="">Ingrese en código de barra </label> -->
                      <input class="form-control" type="hidden" name="cod_barra" id="cod_barra" maxlength="30" placeholder="Codigo Barra Producto" >
                      <input class="form-control" type="hidden" name="cod_barra_tarjeta" id="cod_barra_tarjeta" maxlength="30" placeholder="Codigo Barra tarjeta" >
                    </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" id="btnCancelar"><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="myModalA" 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">Seleccione un Producto</h4>
          </div>
          <div class="modal-body">
            <table id="tblarticulos" 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>Precio Bs.</th>
                <th>Precio $.</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>Precio Bs.</th>
                <th>Precio $.</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="myModalAb" 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">Seleccione un Producto</h4>
          </div>
          <div class="modal-body">
            <table id="tblarticulosb" 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>Precio Bs.</th>
                <th>Precio $.</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>Precio Bs.</th>
                <th>Precio $.</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="myModalB" 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 Tarjeta de Cliente</h4>
          </div>
          <div class="modal-body">
            <table id="tblbarras" class="table table-striped table-bordered table-condensed table-hover">
              <thead>
                <th>Opciones</th>
                <th>Tarjeta</th>
                <th>Número Pedido</th>
                <th>Monto</th>
                <th>Estado</th>
              </thead>
              <tbody>
                
              </tbody>
              <tfoot>
                <th>Opciones</th>
                <th>Tarjeta</th>
                <th>Número Pedido</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="myModalPermiso" tabindex="-1" role="dialog" aria-labelledby="myModalLabel" aria-hidden="true">
      <div class="modal-dialog" style="width: 25% !important;">
        <form action="" method="post" name="formapermiso" id="formapermiso">
          <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">Ingrese clave</h4>
            </div>
            <div class="modal-body">
                <div class="form-group col-lg-12 col-md-12 col-xs-12">
                    <label for="">Usuario</label>
                    <input class="form-control" type="text" name="usuariopermiso" id="usuariopermiso" maxlength="50" placeholder="Clave de permiso" required>
                    <label for="">Clave</label>
                    <input class="form-control" type="password" name="clavepermiso" id="clavepermiso" maxlength="50" placeholder="Clave de permiso" required>
                </div>
            </div>
            <div class="modal-footer">
              <button class="btn btn-primary" type="submit">Enviar</button>
              <button class="btn btn-default" type="button" data-dismiss="modal">Cerrar</button>
            </div>
          </div>
        </form>  
      </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/controlvisita.js"></script>
  </body>
  </html> 
<?php 
}

ob_end_flush();
  ?>

