-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathCode.gs
More file actions
157 lines (108 loc) · 3.62 KB
/
Copy pathCode.gs
File metadata and controls
157 lines (108 loc) · 3.62 KB
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
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
/*
Things to do:
- access logged in user
- create a calendar event
- show a calendar layout that makes sense
- access staff schedules
- access staff merit badges
- know when a calendar event has been deleted?
- find a calendar event matching a description
- find all calender events.
*/
// at link: https://tinyurl.com/gumh-reserve
var currentUser = "";
function doGet(e) {
Logger.log("opening");
parameter = e.parameter;
var page= e.parameter.page;
if(!page){
page = 'index';
}
return HtmlService
.createTemplateFromFile(page)
// .setXFrameOptionsMode(HtmlService.XFrameOptionsMode.ALLOWALL)
.evaluate();
}
//// Get Staff Informations
function getStaffChecklist(filter, sort){
var stafflist = {};
var allStaffData = staffChecklist
.getActiveSheet()
.getDataRange()
.getValues();
var checklistData = dataIntoHashRows(allStaffData, 1, 2); //, function(row){ return row['NetId'] == netId;}).data;
stafflist.checklistData = checklistData;
return stafflist;
}
function getStaffData(netId){
var staffData = {foo:"va"};
var allStaffData = staffChecklist
.getActiveSheet()
.getDataRange()
.getValues();
var checklistData = dataIntoHashRows(allStaffData, 1, 2, function(row){
if(row["NetId"].match(new RegExp(netId, "i"))){
return true;
}
return false;
}); //, function(row){ return row['NetId'] == netId;}).data;
checklistData.data = checklistData.data[0];
staffData.checklistData = JSON.parse(JSON.stringify(checklistData));
return staffData;
}
/// Get Merit Badge Information
function getMeritBadgeIconList(filter, sort){
var allmeritBadgeIconData = meritBadgeIconList
.getActiveSheet()
.getDataRange()
.getValues();
var meritbadgeiconlist = dataIntoHashRows(allmeritBadgeIconData, 0, 1).data; //, function(row){ return row['NetId'] == netId;}).data;
var meritBadgeIconHash = {};
for (var i = 0; i < meritbadgeiconlist.length; i++){
meritBadgeIconHash[meritbadgeiconlist[i]["Badge Name"]] = meritbadgeiconlist[i];
}
var meritBadgeHash = {};
for (var j = 0; j < MeritBadges.length; j++){
if(meritBadgeIconHash[MeritBadges[j]]){
meritBadgeHash[MeritBadges[j]] = meritBadgeIconHash[MeritBadges[j]];
}else{
meritBadgeHash[MeritBadges[j]] = {};
}
}
return meritBadgeHash;
}
////// clever bits for scheduling
// get all staff available for a particular set of merit badges, within a date range, along with their schedules
// get schedule for a staff person between a date range
function organizeStaffByMeritBadges(startDate, endDate){
var meritBadgeStaff = {};
if(!startDate){
startDate= "Wed Oct 25 2017 00:00:00 GMT-0400";
}
if(!endDate){
endDate = "Thu Oct 26 2017 00:00:00 GMT-0400";
}
staffSchedules = getStaffSchedules(startDate, endDate);
//return JSON.parse(JSON.stringify(staffSchedules));
var emails = Object.keys(staffSchedules);
Logger.log("working on it");
for(var i = 0; i< emails.length ; i++){
var netid = emails[i].split("@")[0];
var staffInfo = getStaffData(netid);
for(var j = 0 ; j< MeritBadges.length; j++){
var mb = MeritBadges[j];
if(!meritBadgeStaff[mb]){
meritBadgeStaff[mb] = {};
}
if(staffInfo.checklistData.data[mb]){
if(!meritBadgeStaff[mb][netid]){
meritBadgeStaff[mb][netid] = {};
}
meritBadgeStaff[mb][netid].data = staffInfo.checklistData.data;
meritBadgeStaff[mb][netid].schedule = staffSchedules[emails[i]];
}
}
}
return JSON.parse(JSON.stringify(meritBadgeStaff));
}
/////////////// get equipment and merit badge information