-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathresourceBank.gs
52 lines (48 loc) · 1.43 KB
/
resourceBank.gs
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
function setEmployeesResource() {
var employeeList = getEmployeesList();
var lR = getNextRow(getEmployeesList());
var values = findMissingResourceBank();
employeeList.deleteColumn(9);
employeeList.insertColumnAfter(8);
employeeList.getRange('I:I').getCell(1, 1).setValue('Resource Bank').setFontWeight('bold');
var row = 0, missing;
for(var i = 0; i < lR; i++) {
if(values[i]) {
row = values[i].row + 1;
if(values[i].missing) {
missing = 'Missing';
} else {
missing = 'Completed';
}
employeeList.getRange('I:I').getCell(row, 1).setValue(missing);
}
}
}
function findMissingResourceBank() {
var responses = getResourceBank().getRange('B2:B1000').getValues();
var lastResponse = getNextRow(getResourceBank());
var employeeEmail = getEmployeesList().getRange('D:D').getValues();
var lR = getNextRow(getEmployeesList());
var values = [], row, column, e = 0;
values.total = 0;
for(var i = 0; i < lR; i++) {
if(i != 0) {
values[e] = {
'email': employeeEmail[i],
'missing': true,
'row': i
}
values.total = values.total + 1;
for(var r = 0; r < lastResponse; r++) {
responses[r].forEach(function (email, index) {
if(email == employeeEmail[i] && email != '') {
values[e].missing = false;
values.total = values.total - 1;
};
});
}
e++;
}
}
return values;
}