
app.controller("imprimirControllerF4", function ($scope) {
        $scope.ano = new Date().getFullYear();
        $scope.comNumero = false;
        
        $scope.printFichaMapaBens = function (excel) {
            var comNumero = 0;
            if ($scope.comNumero == true)
                comNumero = 1;
            var xls = 0;
            if (excel == true)
                xls = 1;

            var ano = $scope.ano;
            
            var loc = window.location.origin;
            var endereco = loc + '' + window.location.pathname.replace('app/index.html', '') + '/api/mapas/status';
            var w = window.open("../api/fmapabens/?ano=" + ano + "&numinv=" + comNumero + "&excel=" + xls + "&tk=" + sessionStorage.getItem("CibeAtk"));
            
            var sc =
                   'var counter = 0;' +
                   'var xhttp = new XMLHttpRequest();' +
                   'function update() {' +
                   
                   '    counter++;' +
                   '    document.getElementById("timeCounter").innerHTML = counter;' +
                   '    xhttp.open("GET", "' + endereco + '", true);' +
                   '    xhttp.send();'+
                   '}' +

                   'function startInterval() {' +
                   '    setInterval(function () { update() }, 20000);' +
                   '}'+
                   'startInterval();';
            
            var s = w.document.createElement("script");
            s.type = "text/javascript";
            //s.src = "";
            s.innerHTML = sc;
            w.document.head.appendChild(s);

            $(w.document.body).html('<p align="center">Por Favor Aguarde. Este Processo pode demorar um pouco...</p><label id="timeCounter"></label>');
           
        };

    });
