Created
September 2, 2020 12:29
-
-
Save wellington1993/30eb25dc52c87a4a132b714753c5957d to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
var app = angular.module('horasTrabalhadasPrevistasApp', []); | |
app.controller('horasTrabalhadasPrevistasController', function($scope, $http) { | |
$scope.colaborador; | |
$scope.urlbase; | |
$scope.chaveApiPublica; | |
$scope.horasTrabalhadasPrevistasMesCorrente = function () { | |
document.getElementById("carregarHorasPrevistasMesCorrente").style.display = "none"; | |
document.getElementById("panelHorasTrabalhadasMesCorrente").style.display = "block"; | |
document.getElementById("panelHorasPrevistasMesCorrente").style.display = "block"; | |
$http({ | |
method: 'GET', | |
url: $scope.urlbase + '/api/horasTrabalhadasPrevistas?a=mc&colaborador='+$scope.colaborador+'&h='+$scope.chaveApiPublica, | |
timeout: 10000 | |
// data: {colaborador: colaboradorSincronizado} | |
}).then(function successCallback(response) { | |
document.getElementById("horasTrabalhadasMesCorrente").innerHTML = response.data.horasTrabalhadas; | |
document.getElementById("horasPrevistasMesCorrente").innerHTML = response.data.horasPrevistas; | |
var horasTrabalhadas = valorHoras(response.data.horasTrabalhadas); | |
var horasPrevistas = valorHoras(response.data.horasPrevistas); | |
if (horasPrevistas != "-") { | |
if (horasTrabalhadas > horasPrevistas) { | |
document.getElementById("horasTrabalhadasMesCorrente").style.color = '#1ABB9C'; | |
} | |
} | |
}, function errorCallback(response) { | |
document.getElementById("mesCorrente").innerHTML = 'Não foi possível buscar suas horas.<br> Recarregue a página para tentar novamente.'; | |
}); | |
}; | |
$scope.horasTrabalhadasPrevistasMesAnterior = function () { | |
document.getElementById("carregarHorasPrevistasMesAnterior").style.display = "none"; | |
document.getElementById("panelHorasTrabalhadasMesAnterior").style.display = "block"; | |
document.getElementById("panelHorasPrevistasMesAnterior").style.display = "block"; | |
$http({ | |
method: 'GET', | |
url: $scope.urlbase + '/api/horasTrabalhadasPrevistas?a=ma&colaborador='+$scope.colaborador+'&h='+$scope.chaveApiPublica, | |
timeout: 10000 | |
// data: {colaborador: colaboradorSincronizado} | |
}).then(function successCallback(response) { | |
document.getElementById("horasTrabalhadasMesAnterior").innerHTML = response.data.horasTrabalhadas; | |
document.getElementById("horasPrevistasMesAnterior").innerHTML = response.data.horasPrevistas; | |
var horasTrabalhadas = valorHoras(response.data.horasTrabalhadas); | |
var horasPrevistas = valorHoras(response.data.horasPrevistas); | |
if (horasPrevistas != "-") { | |
if (horasTrabalhadas > horasPrevistas) { | |
document.getElementById("horasTrabalhadasMesAnterior").style.color = '#1ABB9C'; | |
} else if (horasTrabalhadas < horasPrevistas) { | |
document.getElementById("horasTrabalhadasMesAnterior").style.color = '#D9534F'; | |
} | |
} | |
}, function errorCallback(response) { | |
document.getElementById("mesAnterior").innerHTML = 'Não foi possível buscar suas horas.<br> Recarregue a página para tentar novamente.'; | |
}); | |
}; | |
function valorHoras(horas) { | |
if (horas == "-") { | |
return horas; | |
} else { | |
var horasSplited = horas.split(':'); | |
return parseInt(horasSplited[0] + "" + horasSplited[1]); | |
} | |
} | |
}); | |
if(document.getElementById("App2")){ | |
angular.bootstrap(document.getElementById("App2"), ['horasTrabalhadasPrevistasApp']); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment