<?php 
//activamos almacenamiento en el buffer
//ob_start();
//session_start();
if (!isset($_SESSION['nombre'])) {
  header("Location: login.html");
}else{
  //Solo para daniel es acceso y no venta
  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="mostrarform(true)" id="btnagregar"><i class="fa fa-plus-circle"></i>Agregar</button> 
              <div class="box-tools pull-right">
                <h1 class="box-title">Ventas\Clientes
              </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>Documento</th>
                      <th>Numero</th>
                      <th>Telefono</th>
                      <th>Email</th>
                      <th>Estado</th>
                    </thead>
                    <tbody>
                    </tbody>
                    <tfoot>
                      <th>Opciones</th>
                      <th>Nombre</th>
                      <th>Documento</th>
                      <th>Numero</th>
                      <th>Telefono</th>
                      <th>Email</th>
                      <th>Estado</th>
                    </tfoot>   
                  </table>
            </div>
            <!-- Menu de tab -->
            <div class="nav-tabs-custom" id="formularioregistros">
              <ul class="nav nav-tabs">
                <li class="active"><a href="#tab_1" data-toggle="tab">Cliente y Despacho</a></li>
                <li><a href="#tab_2" data-toggle="tab">Información Financiera</a></li>
                
                <li class="pull-right"><a href="#" class="text-muted"><i class="fa fa-gear"></i></a></li>
              </ul>
              <div class="tab-content" >
                <div class="tab-pane active" id="tab_1">
                  <div class="panel-body" >
                    <form action="" name="formulario" id="formulario" method="POST">
                        <input class="form-control" type="hidden" name="idpersona" id="idpersona">
                        <input class="form-control" type="hidden" name="validado" id="validado">
                        <input class="form-control" type="hidden" name="tipo_persona" id="tipo_persona" value="Cliente">
                        <input class="form-control" type="hidden" name="listaiddocumento[]" id="listaiddocumento[]">
                        
                        <div class="form-group has-warning">
                            <label class="control-label" for="inputWarning"><i class="fa fa-bell-o"></i> Advertencia: </label>
                  
                            <span class="help-block">Para prevenir errores, no debe utilizar caracteres especiales. Únicamente se permiten caracteres alfanuméricos.</span>
                        </div>
                        
                        
                        <div class="form-group col-lg-2 col-md-2 col-xs-12">
                        <label for="">Tipo Documento</label>
                        <select class="form-control select-picker" name="tipo_documento" id="tipo_documento" required>
                            <option value="RIF">JURÍDICA</option>
                            <option value="CEDULA">CÉDULA</option>
                            <option value="GUB">GUBERNAMENTAL</option>
                            <option value="EXT">EXTRANJERO</option>
                        </select>
                        </div>
                        <div class="form-group col-lg-2 col-md-2 col-xs-12">
                          <label for="">Nro. Documento</label>
                          <input class="form-control" type="text" name="num_documento" id="num_documento"  placeholder="Razón Social/Cédula">
                        </div>
                        <div class="form-group col-lg-4 col-md-4 col-xs-12">
                          <label for="">Nombre (Razón Social)</label>
                          <input class="form-control" type="text" name="nombre" id="nombre"  placeholder="Nombre del cliente" required>
                        </div>
                        <div class="form-group col-lg-4 col-md-4 col-xs-12">
                          <label for="">Nombre (Fantasía)</label>
                          <input class="form-control" type="text" name="nombref" id="nombref"  placeholder="Nombre Fantasía" required>
                        </div>
                        
                        
                        <div class="form-group col-lg-2 col-md-2 col-xs-12">
                          <label for="">Licencia de Licor</label>
                          <input class="form-control" type="text" name="licencia_licor" id="licencia_licor"  placeholder="licencia de licor">
                        </div>
                        <div class="form-group col-lg-2 col-md-2 col-xs-12">
                          <label for="">Teléfono</label>
                          <input class="form-control" type="text" name="telefono" id="telefono"  placeholder="Número de Teléfono">
                        </div>
                        <div class="form-group col-lg-2 col-md-2 col-xs-12">
                          <label for="">Email</label>
                          <input class="form-control" type="email" name="email" id="email"  placeholder="Email">
                        </div>
                        <div class="form-group col-lg-6 col-md-6 col-xs-12">
                        <label for="">Dirección Fiscal</label>
                          <input class="form-control" type="text" name="direccion" id="direccion" placeholder="Dirección">
                        </div>
                        
                        
                        <div class="form-group col-lg-2 col-md-2 col-xs-12">
                            <label for="">Lista Precio</label>
                            <select name="idlistaprecio" id="idlistaprecio" class="form-control selectpicker" data-Live-search="true" ></select>
                        </div>
                        <div class="form-group col-lg-2 col-md-2 col-xs-12">
                            <label for="">Zona</label>
                            <select name="idzona" id="idzona" class="form-control selectpicker" data-Live-search="true" ></select>
                        </div>
                        <div class="form-group col-lg-2 col-md-2 col-xs-12">
                        <label for="">Estado</label>
                          <select class="form-control select-picker" name="idestado" id="idestado" required>
                            <option value="1">AMAZONAS</option>
                            <option value="1">ANZOATEGUI</option>
                            <option value="1">APURE</option>
                            <option value="1">ARAGUA</option>
                            <option value="1">BARINAS</option>
                            <option value="1">BOLÍVAR</option>
                            <option value="1">CARABOBO</option>
                            <option value="1">COJEDES</option>
                            <option value="1">DELTA AMACURO</option>
                            <option value="1">DISTRITO CAPITAL</option>
                            <option value="1">FALCÓN</option>
                            <option value="1">GUÁRICO</option>
                            <option value="1">LARA</option>
                            <option value="1">MÉRIDA</option>
                            <option value="1">MIRANDA</option>
                            <option value="1">MONAGAS</option>
                            <option value="1">NUEVA ESPARTA</option>
                            <option value="1">PORTUGUESA</option>
                            <option value="1">SUCRE</option>
                            <option value="1">TÁCHIRA</option>
                            <option value="1">TRUJILLO</option>
                            <option value="1">LA GUAIRA</option>
                            <option value="1">YARACUY</option>
                            <option value="1">ZULIA</option>
                          </select>
                        </div>
                        <div class="form-group col-lg-2 col-md-2 col-xs-12">
                            <label for="">Vendedor</label>
                            <select name="idvendedor" id="idvendedor" class="form-control selectpicker" data-Live-search="true" ></select>
                        </div>
                        <div class="form-group col-lg-3 col-md-3 col-xs-12">
                          <div class="form-group col-lg-5 col-md-5 col-xs-12">
                              <label for="">Retención Iva</label>
                              <br>
                              <input type="checkbox" name="contribuyente" id="contribuyente" value="no">
                              
                          </div>
                          
                          <div class="form-group col-lg-7 col-md-7 col-xs-12">
                                <label for="">% Retención</label>
                                <select class="form-control select-picker" name="contribuyentep" id="contribuyentep" required>
                                  <option value="0">Seleccione Retención</option>
                                  <option value="75">75%</option>
                                  <option value="100">100%</option>
                                </select>
                          </div>
                        </div>
                        
                        <div class="form-group col-lg-1 col-md-1 col-xs-12">
                            <label for="">Reseña $</label>
                            <br>
                            <input type="checkbox" name="resenaendollar" id="resenaendollar" value="si">
                        </div>

                        <div id="listaiddocumento">

                        </div>
                        
                        <div class="form-group col-lg-12 col-md-12 col-xs-12">
                          <h5 class="page-header">Despacho</h5>
                        </div>
                        <table id="detalles" class="table table-bordered table-condensed table-hover"> 
                          <tbody>
                            <tr class="filas" id="fila1">
                              <td>
                                <div class="form-group col-lg-2 col-md-2 col-xs-12">
                                    <label for="">Tipo Documento</label>
                                    <select class="form-control select-picker" name="tipo_documentod[]" id="tipo_documentod[]" required>
                                    <option value="RIF">JURÍDICA</option>
                                        <option value="CEDULA">CÉDULA</option>
                                        <option value="GUB">GUBERNAMENTAL</option>
                                        <option value="EXT">EXTRANJERO</option>
                                    </select>
                                </div>
                                <div class="form-group col-lg-2 col-md-2 col-xs-12">
                                    <label for="">Nro. Documento</label>
                                    <input class="form-control" type="text" name="num_documentod[]" id="num_documentod[]"  placeholder="Razón Social/Cédula">
                                </div>
                                <div class="form-group col-lg-6 col-md-6 col-xs-12">
                                    <label for="">Nombre(Razón Social)</label>
                                    <input class="form-control" type="text" name="nombred[]" id="nombred[]"  placeholder="Nombre del cliente" required>
                                </div>
                                    
                                
                                <div class="form-group col-lg-2 col-md-2 col-xs-12">
                                    <label for="">Licencia de Licor</label>
                                    <input class="form-control" type="text" name="licencia_licord[]" id="licencia_licord[]"  placeholder="licencia de licor">
                                </div>
                                <div class="form-group col-lg-6 col-md-6 col-xs-12">
                                    <label for="">Dirección Despacho</label>
                                    <input class="form-control" type="text" name="direcciond[]" id="direcciond[]"  placeholder="Dirección">
                                </div>
                                <div class="form-group col-lg-2 col-md-2 col-xs-12">
                                    <label for="">Teléfono</label>
                                    <input class="form-control" type="text" name="telefonod[]" id="telefonod[]"  placeholder="Número de Teléfono">
                                </div>
                                <div class="form-group col-lg-2 col-md-2 col-xs-12">
                                    <label for="">Email</label>
                                    <input class="form-control" type="email" name="emaild[]" id="emaild[]"  placeholder="Email">
                                </div>
                                <div class="form-group col-lg-2 col-md-2 col-xs-12">
                                    <label for="">Cod. Proveedor</label>
                                    <input class="form-control" type="text" name="cproveedor[]" id="cproveedor[]"  placeholder="Código Proveedor">
                                </div>
                              </td>  
                            </tr>
                          </tbody>
                        </table>
                    </form>
                  </div>
                  <div class="box-footer" id="formularioregistros1">
                    <button class="btn bg-green btn-app pull-left" onclick="agregardespacho()" type="button"><i class="fa fa-plus-circle"></i> Agregar Despacho</button>
                    <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 class="tab-pane" id="tab_2">
                  <div class="panel-body">
                    <form action="" name="formulario1" id="formulario1" method="POST">
                      <input class="form-control" type="hidden" name="idpersona1" id="idpersona1">
                      <input class="form-control" type="hidden" name="idpersona2" id="idpersona2">
                      <input class="form-control" type="hidden" name="validado" id="validado">
                      <input class="form-control" type="hidden" name="tipo_persona1" id="tipo_persona1" value="Cliente">
                      <div class="form-group col-lg-6 col-md-6 col-xs-12">
                        <label for="">Persona Contacto</label>
                        <input type="text" class="form-control" name="personacontacto" id="personacontacto" placeholder="Persona de Contacto">
                        
                      </div>
                      <div class="form-group col-lg-6 col-md-6 col-xs-12">
                        <label for="">Cédula</label>
                        <input type="text" class="form-control" name="personacontactocedula" id="personacontactocedula" placeholder="Persona de Contacto Cédula">
                        
                      </div>
                      <div class="form-group col-lg-6 col-md-6 col-xs-12">
                        <label for="">Teléfono</label>
                        <input type="text" class="form-control" name="personacontactotelefono" id="personacontactotelefono" placeholder="Persona de Contacto Teléfono">
                        
                      </div>
                      
                      <div class="form-group col-lg-6 col-md-6 col-xs-12">
                        <label for="">Gerente</label>
                        <select class="form-control select-picker" name="idgerente" id="idgerente" required>
                                                       
                        </select>
                      </div>
                     

                      <div class="form-group col-lg-6 col-md-6 col-xs-12">
                        <label for="">Canal de Venta</label>
                        <select class="form-control select-picker" name="idtipocadena" id="idtipocadena" required>
                          
                        </select>
                      </div>
                      

                      <div class="form-group col-lg-6 col-md-6 col-xs-12">
                        <label for="">Tipo de Cliente</label>
                        <select class="form-control select-picker" name="idtipocliente" id="idtipocliente" required>
                           

                        </select>
                      </div>
                      <div class="form-group col-lg-6 col-md-6 col-xs-12">
                        <label for="">Frecuencia de Visita</label>
                        <select class="form-control select-picker" name="idfrecuenciavisita" id="idfrecuenciavisita" required>
                           
                        </select>
                      </div>

                      <div class="form-group col-lg-6 col-md-6 col-xs-12">
                        <label for="">Días de Visita</label>
                        <select class="form-control select-picker" name="iddiasdevisita" id="iddiasdevisita" required>
                            
                        </select>
                      </div>
                      <div class="form-group col-lg-6 col-md-6 col-xs-12">
                        <label for="">Días de Recepción</label>
                        <select class="form-control select-picker" name="iddiasderecepcion" id="iddiasderecepcion" required>
                            
                        </select>
                      </div>

                      <div class="form-group col-lg-6 col-md-6 col-xs-12">
                        <label for="">Horario de Recepción</label>
                        <select class="form-control select-picker" name="idhorarioderecepcion" id="idhorarioderecepcion" required>
                            
                        </select>
                       
                      </div>
                      <div class="form-group col-lg-6 col-md-6 col-xs-12">
                        <label for="">Días de Créditos</label>
                        <select class="form-control select-picker" name="iddiasdecredito" id="iddiasdecredito" required>
                           
                        </select>
                      </div>

                      <div class="form-group col-lg-6 col-md-6 col-xs-12">
                        <label for="">Persona que Recibe</label>
                        <input class="form-control" type="text" name="personarecibe" id="personarecibe" placeholder="Persona que Recibe" >
                      </div>

                     
                      <div class="form-group col-lg-6 col-md-6 col-xs-12">
                        <label for="">Observaciones</label>
                        <input class="form-control" type="text" name="observaciones" id="observaciones" placeholder="Observaciones" >
                      </div>
                      
                      <div class="form-group col-lg-12 col-md-12 col-sm-12 col-xs-12">
                        <button class="btn btn-primary pull-right" type="submit" id="btnGuardarClienteAdicional"><i class="fa fa-save"></i>  Guardar</button>
                        <button class="btn btn-danger pull-right" onclick="cancelarform()" type="button"><i class="fa fa-arrow-circle-left"></i> Cancelar</button>
                      </div>
                    </form>
                  </div> 
                </div>


              </div>
                <!-- /.tab-pane -->
                <!-- /.tab-content -->
              
                <!-- Fin de Menu de Tab -->
                 <!--fin centro-->
            
           
            </div>
          </div>
      <!-- /.box -->
      </div>
    </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/cliente.js"></script>
 </body>
  </html> 
<?php  
}
  ob_end_flush();
?>