<?php
session_start();
require_once ("../conexion.php");
require_once('../include/sesiones.php');

$vena_id=$_GET['id']; 
$sql=mysqli_query($con, " SELECT * from ventas_apartadas  where vena_id='$vena_id' and empresa='$empresa' ");
$reg=mysqli_fetch_array($sql);
                   
?>                
<form method="post" action="" id="anular_apar">
    <div class="form-group">
        <label>Apartado N</label>
        <input type="hidden"  name="vena_id" value="<?php  echo $reg['vena_id']; ?>" class="form-control name_list" autocomplete="off" required readonly>
        <input type="text"  name="vena_n_venta" value="<?php  echo $reg['vena_n_venta']; ?>" class="form-control name_list" autocomplete="off" required readonly>
        <label>Cliente</label>
        <input type="hidden"  name="clie_id" value="<?php  echo $reg['Cliente_clie_id']; ?>" class="form-control name_list" autocomplete="off" required readonly>
        <input type="text"  name="clie_nombre" value="<?php  echo  $reg['vena_nombre']; ?>" class="form-control name_list" autocomplete="off" required readonly>
        <label>Detalle</label>
        <textarea name="detalle" class="form-control" rows="3"  required>Anulacion del Apartado <?php  echo $reg['vena_n_venta']; ?></textarea>
    </div>
    <div class="modal-footer">
        <button type="button" class="btn btn-default" data-dismiss="modal">Cancelar</button>
        <button type="submit" name="btn_anular" class="btn btn-success" value="btn_anular" id="btn_anular">Anular</button>
    </div>
</form>   

<script>
$("#anular_apar").submit(function( event ) {
$('#btn_anular').attr("disabled", true);
var parametros = $(this).serialize();
   $.ajax({
      type: "POST",
      url: "php_apartados/anular.php",
      data: parametros,
        beforeSend: function(objeto){
         $('#resultados').html('<center><img src="./img/ajax-loader.gif"> CARGANDO...</center>');
        },
        success: function(datos){
        $("#resultados").html(datos);
        $('#btn_abonar').attr("disabled", false);

        $('#anular').modal('hide');
        $('body').removeClass('modal-open');
        $('.modal-backdrop').remove();
        load(1);
      }
  });
  event.preventDefault();
})
</script>                         