$(function () {
    
    $('.btn_anular').on('click', function() {

        var id = $(this).data("id");
    
        $('#delete_modal').modal({
            closable: false,
            onApprove : function() {
                sendDelete(id);
            }
        }).modal('show');  
    });       

    function sendDelete(id) {

        var data = {id_guia_remision : id};

        $.requestApi('/guia/anular', data, 'POST', function (resolve) {
            if (resolve) {
                $.showMessages(resolve, true, APP_URL+'/guia/listar');
            }
        }); 
        
        return false;
    };

    $('.btn_imprimir').on('click', function() {
        var id = $(this).data("id");
        window.open(APP_URL+'/../pdf/imprimeGuia.php?id_guia='+id, '_blank');
    }); 

    $('.btn_reenviar').on('click', function() {
        var id = $(this).data("id"); 
        $.requestApi('/xml/reenviarGuia', {"id" : id}, 'GET', function (resolve) {
            if (resolve) {
                $.showMessages(resolve, true, APP_URL+'/guia/detalles_electronico/'+id );
            }
        });
        
        return false;
    });


  	

});



