<?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> 
                    <div class="box-tools pull-right">
                      <h1 class="box-title">Compras\Facturación Boleto
                    </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>Cliente</th>
                      <th>Usuario</th>
                      <th>Documento</th>
                      <th>Número</th>
                      <th>Total Venta</th>
                      <th>Estado</th>
                    </thead>
                    <tbody>
                    </tbody>
                    <tfoot>
                      <th>Opciones</th>
                      <th>Fecha</th>
                      <th>Cliente</th>
                      <th>Usuario</th>
                      <th>Documento</th>
                      <th>Número</th>
                      <th>Total Venta</th>
                      <th>Estado</th>
                    </tfoot>   
                  </table>
                </div>
                <form action="" name="formulario" id="formulario" method="POST">
                  <div class="panel-body" style="height: 400px;" id="formularioregistros">
                    <div class="form-group col-lg-8 col-md-8 col-xs-12">
                      <label for="">Cliente(*):</label>
                      <input class="form-control" type="hidden" name="idventa" id="idventa">
                      <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="">Fecha(*): </label>
                      <input class="form-control" type="date" name="fecha_hora" id="fecha_hora" required>
                    </div>
                    <div class="form-group col-lg-6 col-md-6 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="Ticket">Ticket</option>
                      </select>
                    </div>
                    <div class="form-group col-lg-2 col-md-2 col-xs-6">
                      <label for="">Nro. Control: </label>
                      <input class="form-control" type="hidden" name="idempresa_venta" id="idempresa_venta" value="<?php echo $_SESSION['idempresa_venta_empresa'] ?>" >
                      <input class="form-control" type="text" name="serie_comprobante" id="serie_comprobante" maxlength="7" placeholder="Serie">
                    </div>
                    <div class="form-group col-lg-2 col-md-2 col-xs-6">
                      <label for="">Nro. Factura: </label>
                      
                      <input class="form-control" type="text" name="num_comprobante" id="num_comprobante" maxlength="10" placeholder="Número" required>
                    </div>
                    <div class="form-group col-lg-2 col-md-2 col-xs-6">
                      <label for="">Impuesto: </label>
                      <input class="form-control" type="text" name="impuesto" id="impuesto">
                    </div>
                    <div class="form-group col-sm-6 col-xs-12">
                      
                    </div>
                    <div class="form-group col-lg-12 col-md-12 col-xs-12">
                      <table id="detalles" class="table table-striped table-bordered table-condensed table-hover">
                        <thead style="background-color:#A9D0F5">
                          <th>Opciones</th>
                          <th>Aerolinea/Servicio</th>
                          <th>Cantidad</th>
                          <th>Porcentaje</th>
                          <th>Monto</th>
                          <th>Subtotal</th>
                        </thead>
                        <tfoot>
                          <th>TOTAL</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>
                  </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-6 col-md-6 col-xs-12">
                        <a data-toggle="modal" href="#myModalB">
                          <button type="button" class="btn bg-purple btn-app pull-left" id="btnAgregarBol"><i class="fa fa-inbox"></i>Boleto</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-6 col-md-6 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>
                </form>
              <!--fin centro-->
            </div>
          </div>
        </div>
      <!-- /.box -->
      </section>
      <!-- /.content -->
    </div>
    <!--Modal-->
    <div class="modal fade" id="myModal" 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>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>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: 40% !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">Boleto</h4>
          </div>
          <div class="modal-body">
              <div class="form-group col-lg-6 col-md-6">
                <label for="">Tipo de Boleto</label>
                <select name="idtipoboleto" id="idtipoboleto" class="form-control selectpicker" data-Live-search="true" required></select>
                
              </div>
              <div class="form-group col-lg-6 col-md-6">
                <label for="">Buscar Boleto</label>
                <input type="file" id="file-input" />
              </div>
              
                
              <input class="form-control" type="hidden" name="idboleto1" id="idboleto1" >
              <input class="form-control" type="hidden" name="idlinea1" id="idlinea1">
              <input class="form-control" type="hidden" name="rif1" id="rif1">
              <div class="form-group col-lg-12 col-md-12">
                <label for="">LineaAerea</label>
                <input class="form-control" type="text" name="nombrelinea1" id="nombrelinea1">
              </div>
              <div class="form-group col-lg-6 col-md-6">
                <label for="">Pasajero</label>
                <input class="form-control" type="text" name="pasajero1" id="pasajero1">
              </div>
              <div class="form-group col-lg-6 col-md-6">
                <label for="">NroBoleto</label>
                <input class="form-control" type="text" name="nroboleto1" id="nroboleto1">
              </div> 
              <div class="form-group col-lg-6 col-md-6">
                <label for="">NroLinea</label>
                <input class="form-control" type="text" name="nrolinea1" id="nrolinea1">
              </div>
              <div class="form-group col-lg-6 col-md-6">
                <label for="">Identif.</label>
                <input class="form-control" type="text" name="identificador1" id="identificador1">
              </div>
              <div class="form-group col-lg-6 col-md-6">
                <label for="">Ruta</label>
                <input class="form-control" type="text" name="ruta1" id="ruta1">
              </div>        
              <div class="form-group col-lg-6 col-md-6">
                <label for="">Precio</label>
                <input class="form-control" type="text" name="monto1" id="monto1">
              </div>
              <div class="form-group col-lg-6 col-md-6">
                <label for="">Impuesto</label>
                <input class="form-control" type="text" name="montoimpuesto1" id="montoimpuesto1">
              </div>        
          </div>
          <div class="modal-footer">
            <button class="btn btn-primary" type="button" id="btnAgregarBoleto"><i class="fa fa-save"></i>  Agregar</button>
            <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-->
        <?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/ventaboleto.js"></script>
  </body>
  </html> 
<?php 
}

ob_end_flush();
  ?>

