<?php
session_start();
require_once ("../conexion.php");
require_once('../include/sesiones.php');
$gar_id=$_GET['id'];
?>
<form method="post" action="" name="form_pdf" id="form_pdf" enctype="multipart/form-data">
    <div  class="col-md-12">
        <div class="form-group">
            <label for="comprobante">Abjuntar Comprobante ( PDF )</label>
            <input type="file"  name="comprobante" id="comprobante">
            <input type="hidden" name="gar_id" value="<?php  echo $gar_id; ?>" required readonly>
        </div>
    </div> <!-- /.form-group -->
    <div class="modal-footer">
        <button type="button" class="btn btn-default" data-dismiss="modal">Cancelar</button>
        <button type="submit" class="btn btn-info" name="subir" value="subir" id="subir">Subir</button>
    </div>
</form>
           
<script type="text/javascript">
$( "#form_pdf" ).submit(function( event ) {
    $('#subir').attr("disabled", true);
    var formData = new FormData($("#form_pdf")[0]);
    var ruta = "php_garantias_proveedor/subir_pdf.php";
    $.ajax({
        type: "POST",
        url: ruta,
        data: formData,
        contentType: false,
        processData: false, 
        beforeSend: function(objeto){
         $('#resultados').html('<center><img src="./img/ajax-loader.gif"> CARGANDO...</center>');
        },
        success: function(datos){
        $("#resultados").html(datos);
        $('#subir').attr("disabled", false);
        $('#pdf').modal('hide');
        $('body').removeClass('modal-open');
        $('.modal-backdrop').remove();
        load(1);
      }
    });
    event.preventDefault();
})
</script>
<style type="text/css">
input[type="file"]#comprobante {
 width: 0.1px;
 height: 0.1px;
 opacity: 0;
 overflow: hidden;
 position: absolute;
 z-index: -1;
 }

label[for="comprobante"] {
 font-size: 14px;
 font-weight: 600;
 color: #fff;
 background-color: #106BA0;
 display: inline-block;
 cursor: pointer;
 padding: 5px 40px ;
 width: fit-content;
 text-align: center;
 }
</style>