So my people, first of all, would like to say that I'm a beginner and I started learning this week so take it easy with me, please u.u
So I'm tinkering with a test site here and I have the following situation: I have three employees and each of them has worked a certain amount of hours a day. This information is all in one bd. In the script, the names of the employees are identified by: Obj [1] [i] .name and the hours worked are identified by Obj [1] [i] .horas. What I want to do is add up all the hours each employee has worked and show them in their respective column.
Well, I tried to do the following:
I created an array with the names of the employees to compare with the names of the database and if the names are the same, the times will be added byéeeeeem, I do not know how to make it appear in the table. I do not know if what I did is right (probably not) but I tried the part of the code I did it in here:
if (Obj !== null) {
if (Obj[0].tipo === 1) {
var data = [];
nomes = new Array ("Alex", "Yamilla", "Fernanda");
jQuery("#status_projetos").html("");
jQuery("#resumo_alocacao").html("");
for(var x = 0; x < nomes.length; x++ )
{
soma = 0;
for (var i = 0; i < Obj[1].length; i++) {
var obj = {
label: Obj[1][i].nome_projeto,
data: Obj[1][i].horas
};
if(nome == Obj[l][i].nome)
{
soma+=horas;
}
}
ps: Ignore where Obj [1] [i] .project_name is written, that's something else. If they can help beauty, if not, ok too :)