<?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="mostrarform(true)" id="btnagregar"><i class="fa fa-plus-circle"></i> Agregar</button></h1>
                <div class="box-tools pull-right">
                  <h1 class="box-title">Proceso\Radar 
                </div>
              </div>
              <!--box-header-->
              <!--centro-->
              <!--Pedido-->
              <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>Saldo</th>
                    <th>N# de CxC</th>
                    <th>Doc. Más Antiguo</th>
                    <th>Estado</th>
                  </thead>
                  <tbody>
                  </tbody>
                  <tfoot>
                    <th>Opciones</th>
                    <th>Nombre</th>
                    <th>Saldo</th>
                    <th>N# de CxC</th>
                    <th>Doc. Más Antiguo</th>
                    <th>Estado</th>
                  </tfoot>   
                </table>
              </div>
              <div id="pedido">
                <div class="panel-body" style="height: 400px;" id="formularioregistros">
                  <form action="" name="formulario" id="formulario" method="POST">
                    <input class="form-control" type="hidden" name="idventa" id="idventa">
                    <input class="form-control" type="hidden" name="idtransportista" id="idtransportista" value="1">
                    <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="serie_comprobante" id="serie_comprobante" value="N/A">
                    <input class="form-control" type="hidden" name="num_comprobante" id="num_comprobante" value="N/A">
                    <input class="form-control" type="hidden" name="tipo_documento" id="tipo_documento">
                    <input class="form-control" type="hidden" name="num_documento" id="num_documento">
                    <input class="form-control" type="hidden" name="idvendedor" id="idvendedor">
                    <input class="form-control" type="hidden" name="tipo_comprobante" id="tipo_comprobante">
                    <!-- <input class="form-control" type="hidden" name="idcliente" id="idcliente"> -->
                    <input class="form-control" type="hidden" name="validar" id="validar">
                    <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'] ?>" >
                    <input class="form-control" type="hidden" name="impuestoart18_empresa" id="impuestoart18_empresa" value="<?php echo $_SESSION['impuestoart18_empresa'] ?>" >
                  
                                  
                    <div class="form-group col-lg-4 col-md-4 col-xs-12">
                      <label for="">Nombre</label>
                      <select name="idcliente" id="idcliente" class="form-control selectpicker" data-live-search="true" required>
                      </select>
                      
                    </div>
                    <div class="form-group col-lg-4 col-md-4 col-xs-12">
                      <label for="">Despacho</label>
                      <select name="idclientedespacho" id="idclientedespacho" 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="">Fecha: </label>
                      <input class="form-control" type="date" name="fecha_hora" id="fecha_hora" required>
                    </div>
                    <input class="form-control" type="hidden" name="impuesto" id="impuesto" maxlength="20" placeholder="IVA" value=<?php echo $_SESSION['iva_empresa'] ?> readonly>
                    
                    <div class="form-group col-lg-2 col-md-2 col-xs-6">
                      <label for="">Nro. Pedido: </label>
                      <input class="form-control" type="text" name="num_pedido" id="num_pedido" maxlength="20" placeholder="Número pedido" 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">
                      <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</th>
                          <th>Subtotal</th>
                        </thead>
                        <tfoot>
                          <tr>
                            <th></th>
                            <th></th>
                            <th></th>
                            <th>TOTAL</th>
                            <th align="right"><h4 align="right" id="totald"></h4>
                              <input type="hidden" name="total_venta1" id="total_venta1" disabled>
                              <input type="hidden" name="total_venta" id="total_venta">
                              <input type="hidden" name="total_ventad" id="total_ventad">
                            </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="#myModalA">
                        <button type="button" class="btn bg-blue btn-app pull-left" id="btnAgregarArt"><i class="fa fa-inbox"></i>Producto</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-inbox"></i>Producto</button>
                      </a> 
                      <a data-toggle="modal" href="#myModalAc">
                        <button type="button" class="btn bg-orange btn-app pull-left" id="btnAgregarArtc"><i class="fa fa-inbox"></i>Producto</button>
                      </a>   
                      <a data-toggle="modal" href="#myModalS">
                        <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="">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-bank"></i>  Agregar Pedido</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>
              </div>
              <!--Fin de Pedido-->
              <!--CxC-->
              <div id="cxc">
                <div class="panel-body" style="height: 400px;" id="formularioregistros2">
                  <form action="" name="formularioc" id="formularioc" method="POST">
                    <!-- CxC -->
                    <input class="form-control" type="hidden" name="idpagocliente" id="idpagocliente">
                    <input class="form-control" type="hidden" name="agenteretencion" id="agenteretencion">
                    <input class="form-control" type="hidden" name="tasacambioventa" id="tasacambioventa">
                    <input class="form-control" type="hidden" name="idpersona" id="idpersona">
                    <input class="form-control" type="hidden" name="idusuario" id="idusuario" value=<?php echo $_SESSION['idusuario'] ?>>
                    <input class="form-control" type="hidden" name="validado" id="validado">
                    <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="diferencia" id="diferencia" value="0.00">
                    
                    <div class="form-group col-lg-6 col-md-6 col-xs-12">
                      <label for="">Nombre</label>
                      <input class="form-control" type="text"  name="nombre" id="nombre" maxlength="100" placeholder="Nombre del cliente" readonly="readonly">
                    </div>
                    <div class="form-group col-lg-6 col-md-6 col-xs-12">
                      <label for="">Forma de Pago</label>
                      <select name="idformapago" id="idformapago" class="form-control selectpicker" data-Live-search="true" ></select>
                    </div>
                    <div class="form-group col-lg-6 col-md-6 col-xs-12">
                      <label for="">Tipo de Pago</label>
                      <select name="idtipopagos" id="idtipopagos" class="form-control selectpicker" data-Live-search="true" ></select>
                    </div>
                    <div class="form-group col-lg-6 col-md-6 col-xs-12">
                      <label for="">Cuenta de Banco</label>
                      <select name="idbancocuenta" id="idbancocuenta" 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="">Referencia de Pago</label>
                      <input class="form-control" type="text" name="referencia" id="referencia" maxlength="20" placeholder="Referencia de Pago">
                    </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="">Monto del Pago</label>
                      <input class="form-control" type="text" name="montopago" id="montopago"  value="0,00" placeholder="0,00">
                    </div>
                    <div class="form-group col-lg-3 col-md-3 col-xs-12">
                      <label for="">Diferencia</label>
                      <input class="form-control" type="text" name="montopagod" id="montopagod"  value="0,00" placeholder="0,00">
                    </div>
                    <div class="form-group col-lg-12 col-md-12 col-xs-12">
                      <table id="detalles2" class="table table-striped table-bordered table-condensed table-hover">
                        
                      </table>
                    </div>
                    
                  </form>
                </div>
                <div class="box-footer" id="formularioregistros12">
                  <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>  
              <!--Fin CxC-->




             
              
              <!--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 Articulo</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 Venta</th>
                          <th>Nro. Lote</th>
                          <th>Fecha Vec.</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 Venta</th>
                          <th>Nro. Lote</th>
                          <th>Fecha Vec.</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 Articulo</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 Venta</th>
                          <th>Nro. Lote</th>
                          <th>Fecha Vec.</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 Venta</th>
                          <th>Nro. Lote</th>
                          <th>Fecha Vec.</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="myModalAc" 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 Articulo</h4>
                    </div>
                    <div class="modal-body">
                      <table id="tblarticulosc" 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 Venta</th>
                          <th>Nro. Lote</th>
                          <th>Fecha Vec.</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 Venta</th>
                          <th>Nro. Lote</th>
                          <th>Fecha Vec.</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="myModalS" 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 Servicio</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>  

              <!-- fin Modal-->

              <!--fin centro-->
            </div>
          </div>
        </div>
      <!-- /.box -->
      </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/radar.js"></script>
  </body>
  </html> 
<?php 
}

ob_end_flush();
  ?>

