<?php
//activamos almacenamiento en el buffer
//ob_start();
//session_start();

if (!isset($_SESSION['nombre'])) {
  header("Location: login.html");
}else{
  if ($_SESSION['distribucion']==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,true)" 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\Día de Visita - Reporte 
                </div>
                </br>
              </div>
              
              <!--box-header-->
              <!--centro-->
              <div class="panel-body table-responsive" id="listadoregistros">

                <span id="tabvisita"></span>
                <!-- Tab Para Cada vendedor -->
                


                <!-- <table id="tbllistado" class="table table-striped table-bordered table-condensed table-hover">
                  <thead>
                    <th>Opciones</th>
                    <th>Fecha Emisión</th>
                    <th>Fecha Despacho</th>
                    <th>Cliente</th>
                   
                    <th>N# Nota Entrega</th>
                    <th>N# Factura</th>
                    <th>Vendedor</th>
                    <th>Zona</th>
                   
                    <th>Estado</th>
                  </thead>
                  <tbody>
                  </tbody>
                  <tfoot>
                    <th></th>
                    <th></th>
                    <th></th>
                    <th></th>
                    <th></th>
                    <th></th>
                    <th></th>
                    <th></th>
                    <th></th>
                  </tfoot>   
                </table> -->
              </div>
              <div class="panel-body" style="height: 400px;" id="formularioregistros">
                <form action="" name="formulario" id="formulario" method="POST">
                  
                  
                  
                  <!-- 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">
                    <table id="detalles" class="table table-bordered table-condensed table-hover">
                    </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-barcode"></i><span id=listaa>Productos</span></button>
                      </a>
                      <a data-toggle="modal" href="#myModalAb">
                        <button type="button" class="btn bg-green btn-app pull-left" id="btnAgregarArtb"><i class="fa fa-barcode"></i><span id=listab>Productos</span></button>
                      </a> 
                      <a data-toggle="modal" href="#myModalAc">
                        <button type="button" class="btn bg-yellow btn-app pull-left" id="btnAgregarArtc"><i class="fa fa-barcode"></i><span id=listac>Productos</span></button>
                      </a> 
                      <a data-toggle="modal" href="#myModalAd">
                        <button type="button" class="btn bg-orange btn-app pull-left"   id="btnAgregarArtd"><i class="fa fa-barcode"></i><span id=listad>Productos</span></button>
                      </a>
                      <a data-toggle="modal" href="#myModalAe">
                        <button type="button" class="btn bg-navy btn-app pull-left"   id="btnAgregarArte"><i class="fa fa-barcode"></i><span id=listae>Productos</span></button>
                      </a>
                      <a data-toggle="modal" href="#myModalB">
                        <button type="button" class="btn bg-olive btn-app pull-left" id="btnAgregarPed"><i class="fa fa-inbox"></i>Pedidos</button>
                      </a>  
                      <a data-toggle="modal" href="#myModalS">
                        <button type="button" class="btn bg-purple btn-app pull-left" id="btnAgregarSer"><i class="fa fa-edit"></i>Servicios</button>
                      </a>
                    </div>
                    <div class="form-group col-lg-4 col-md-4 col-xs-12" >
                      <label for="">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> -->
                      <!-- <a data-toggle="modal" href="#myModalT"> -->
                        <button class="btn bg-blue btn-app pull-right" type="submit" id="btnFacturar"><i class="fa fa-save"></i> Procesar</button>
                      <!-- </a> -->  
                      <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>
              
              <!--Modal-->
              
              <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>
             
              <div class="modal fade" id="myModalCliente" tabindex="-1" role="dialog" aria-labelledby="myModalLabel" aria-hidden="true">
                <div class="modal-dialog" style="width: 40% !important;">
                  <div class="modal-content">
                    <form action="" method="post" name="formaguardarcliente" id="formaguardarcliente">    
                      <div class="modal-header">
                        <button type="button" class="close" data-dismiss="modal" aria-hidden="true">&times;</button>
                        <h4 class="modal-title">Datos del cliente</h4>
                      </div>
                      <div class="modal-body">
                        
                          <div class="form-group col-lg-6 col-md-6 col-xs-12">
                            <label for="">Tipo Dcumento</label>
                            <select class="form-control select-picker" name="tipo_documento1" id="tipo_documento1">
                              <option value="RIF">RIF</option>
                              <option value="CEDULA">CEDULA</option>
                            </select>
                          </div>
                          <div class="form-group col-lg-6 col-md-6 col-xs-12">
                            <label for="">Razon Social/Cedula</label>
                            <input class="form-control" type="text" name="num_documento1" id="num_documento1" maxlength="20" placeholder="Razon Social/Cedula">
                            <input class="form-control" type="hidden" name="tipo_persona1" id="tipo_persona1" value="Cliente">
                          </div>
                          <div class="form-group col-lg-12 col-md-12 col-xs-12">
                            <label for="">Nombre</label>
                            <input class="form-control" type="text" name="nombre1" id="nombre1" maxlength="200" placeholder="Nombre del cliente" autofocus required>
                          </div>
                          <div class="form-group col-lg-12 col-md-12 col-xs-12">
                            <label for="">Direccion</label>
                            <input class="form-control" type="text" name="direccion1" id="direccion1" maxlength="600" placeholder="Direccion">
                          </div>
                          <div class="form-group col-lg-6 col-md-6 col-xs-12">
                            <label for="">Telefono</label>
                            <input class="form-control" type="text" name="telefono1" id="telefono1" maxlength="20" placeholder="Número de Telefono">
                          </div>
                          <div class="form-group col-lg-6 col-md-6 col-xs-12">
                            <label for="">Email</label>
                            <input class="form-control" type="email" name="email1" id="email1" maxlength="50" placeholder="Email">
                          </div>
                      </div>
                      <div class="modal-footer">
                        <button class="btn btn-default" type="button" data-dismiss="modal">Cerrar</button>
                        <button class="btn btn-success" type="submit" id="btnGuardarCliente">Guardar</button>
                    
                    
                      </div>
                    </form>
                  </div>
                </div>
              </div>
              
              <div class="modal fade" id="myModalstock" tabindex="-1" role="dialog" aria-labelledby="myModalLabel" aria-hidden="true">
                <div class="modal-dialog" style="width: 25% !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">Stock x Almacén</h4>
                    </div>
                    <div class="modal-body">
                      <table id="tblstock" class="table table-striped table-bordered table-condensed table-hover">
                        <thead>
                          <th>Almacén</th>
                          <th>Stock</th>
                          
                        </thead>
                        <tbody>
                          
                        </tbody>
                        <tfoot>
                          <th>Almacén</th>
                          <th>Stock</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="myModalFechadespacho" tabindex="-1" role="dialog" aria-labelledby="myModalLabel" aria-hidden="true">
                <div class="modal-dialog" style="width: 20% !important;">
                  <div class="modal-content">
                    <!--  <form action="" method="post" name="formaguardarFechadespacho" id="formaguardarFechadespacho">  -->    
                      <div class="modal-header">
                        <button type="button" class="close" data-dismiss="modal" aria-hidden="true">&times;</button>
                        <h4 class="modal-title">Actualizar Fecha de Despacho</h4>
                      </div>
                      <div class="modal-body">
                        
                        <div class="form-group col-lg-12 col-md-12 col-xs-12">
                          <label for="">Fecha</label>
                          <input class="form-control" type="date" name="fecha_despacho1" id="fecha_despacho1" required>
                        </div>
                      </div>
                      <div class="modal-footer">
                        <button class="btn btn-default" type="button" data-dismiss="modal">Cerrar</button>
                        <!-- <button class="btn btn-primary" data-bs-target="#myModalFechadespachoestado" data-bs-toggle="modal">Guardar</button> -->
                        <button class="btn btn-success" type="button" id="btnGuardarFechadespacho">Guardar</button> 
                    
                    
                      </div>
                     <!-- </form>  -->
                  </div>
                </div>
              </div>
             
              <div class="modal fade" id="myModalFechadespachoestado" tabindex="-1" role="dialog" aria-labelledby="myModalLabel" aria-hidden="true">
                <div class="modal-dialog" style="width: 40% !important;">
                    <div class="modal-content">
                      <form action="" method="post" name="formaguarestado" id="formaguarestado">     
                        <div class="modal-header">
                          <button type="button" class="close" data-dismiss="modal" aria-hidden="true">&times;</button>
                          <h4 class="modal-title">Actualizar Estado de Documento</h4>
                        </div>
                        <div class="modal-body">
                          <table id="tbestado" class="table table-striped table-bordered table-condensed table-hover" style="width:100%">
                            <thead>
                              <th>Documento</th>
                              <th>Status</th>
                              <th>Fecha</th>
                            
                            </thead>
                            <tbody>
                              
                            </tbody>
                            <tfoot>
                              <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>
                          <button class="btn btn-success" type="button" id="btnGuardardespachoestado">Guardar</button>
                      
                      
                        </div>
                      </form> 
                    </div>
                </div>
              </div>

              <div class="modal fade" id="myModalFechayEstadodespachogrupo" tabindex="-1" role="dialog" aria-labelledby="myModalLabel" aria-hidden="true">
                <div class="modal-dialog" style="width: 30% !important;">
                  <div class="modal-content">
                     <form action="" method="post" name="formaguardarFechayEstadodespachogrupo" id="formaguardarFechayEstadodespachogrupo">  
                        <div class="modal-header">
                          <button type="button" class="close" data-dismiss="modal" aria-hidden="true">&times;</button>
                          <h4 class="modal-title">Actualizar Estado y Fecha de Despacho</h4>
                        </div>
                        <div class="modal-body">
                          <div class="form-group col-lg-12 col-md-12 col-xs-12">
                            <label for="">Estado </label>
                            <select name="estadodg" id="estadodg" class="form-control selectpicker" required>
                              <option value="Pendiente">Pendiente9999</option>
                              <option value="Despachada">Despachada</option>
                              <option value="Despachada-Parcial">Despachada-Parcial</option>
                              <option value="EnTransito">EnTransito</option>

                              
                              
                            </select>
                          </div>
                        
                          <div class="form-group col-lg-12 col-md-12 col-xs-12">
                            <label for="">Fecha</label>
                            <input class="form-control" type="date" name="fecha_despachog" id="fecha_despachog" required>
                          </div>
                          <input type="hidden" name="iddocumentog[]" id="iddocumentog[]" value=''>
                        </div>
                        <div class="modal-footer">
                          <button class="btn btn-default" type="button" data-dismiss="modal">Cerrar</button>
                          <!-- <button class="btn btn-primary" data-bs-target="#myModalFechadespachoestado" data-bs-toggle="modal">Guardar</button> -->
                          <button class="btn btn-success" type="button" id="btnGuardarFechayEstadodespacho">Guardar</button> 
                      
                      
                        </div>
                     </form>  
                  </div>
                </div>
              </div>

              <!-- fin Modal-->

                <!--fin centro-->
            </div>
             <!-- /.box -->
          </div>
          <!-- /.col-md-12 -->
        </div>
         <!-- /.row -->
      </section>
      <!-- /.content -->
    </div>
    
  <?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/diadevisitavendedor1.js"></script>
  </body>
  </html> 
<?php 
}

ob_end_flush();
  ?>

