/home/dvjjulio/softtrash/public/js/catalogo_js/metricas.js
$(function(){
    $.get(main_path+"/catalogo/metrica_op", {op:1}, function(resp){
        $('#metrica').html(resp);
    });
})
var Metrica = {
    op:function(e){
        $.get(main_path+"/catalogo/metrica_op", {op:$(e).data('op')}, function(resp){
            $('#metrica').html(resp);
            $("#filter-btn").attr('data-op',$(e).data('op'));
            $("#month-select").val("0");
            $("#year-select").val("0");
        });
    },
    tableFilter:function(e){
        var $panel = $('.filterable'),
        $filters = $panel.find('.filters input'),
        $tbody = $panel.find('.table tbody');
        if ($filters.prop('disabled') == true) {
            $filters.prop('disabled', false);
            $filters.first().focus();
        } else {
            $filters.val('').prop('disabled', true);
            $tbody.find('.no-result').remove();
            $tbody.find('tr').show();
        }
    },
    filter:function(e){
        let op = $(e).attr('data-op');
        let year = $("#year-select").val();
        let month = $("#month-select").val();
        $.get(main_path+"/catalogo/metrica_op", {op:op, year:year, month:month}, function(resp){
            $('#metrica').html(resp);
        });
    },
    print:function(e){
        var mywindow = window.open('', 'PRINT', 'height=1000,width=1000');

        mywindow.document.write('<html><head><title>' + document.title  + '</title>');
        mywindow.document.write('</head><body >');
        mywindow.document.write('<h1>' + document.title  + '</h1>');
        mywindow.document.write(document.getElementsByClassName('filterable')[0].innerHTML);
        mywindow.document.write('</body></html>');

        mywindow.document.close(); // necessary for IE >= 10
        mywindow.focus(); // necessary for IE >= 10*/

        mywindow.print();
        mywindow.close();

        return true;
    }
}