-
Notifications
You must be signed in to change notification settings - Fork 0
/
CreateDeskSchedule.gs
106 lines (91 loc) · 3.66 KB
/
CreateDeskSchedule.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
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
function makeDeskSchedule(title, folder, format_sheet, all_events) {
var desk_schedule = SpreadsheetApp.create(title);
DriveApp.getFileById(desk_schedule.getId()).moveTo(folder);
SpreadsheetApp.openById(format_sheet).getSheets()[0].copyTo(desk_schedule);
desk_schedule.deleteSheet(desk_schedule.getSheetByName("Sheet1"));
desk_schedule.getSheets()[0].getRange("A1").setValue(title);
var all = desk_schedule.createTextFinder("fill").findAll();
for(var i=0; i<all_events.length; i++){
switch(i){
case 0:
var day = "Monday";
for (var x=0; x<all_events[i].length; x++)
{
desk_schedule.getSheets()[0].getRange("A"+(x+4)).setValue(all_events[i][x].getTitle().split(' ')[1] + ' ' + all_events[i][x].getTitle().split(' ')[2]);
}
for (var x=0; x<all.length; x++){
if (all[x].getA1Notation().indexOf("A")>=0)
{
all[x].setValue(all_events[i][randNum(0, (all_events[i].length - 1))].getTitle().split(' ')[1]);
};
}
break;
case 1:
var day = "Teusday";
for (var x=0; x<all_events[i].length; x++)
{
desk_schedule.getSheets()[0].getRange("B"+(x+4)).setValue(all_events[i][x].getTitle().split(' ')[1] + ' ' + all_events[i][x].getTitle().split(' ')[2]);
}
for (var x=0; x<all.length; x++){
if (all[x].getA1Notation().indexOf("B")>=0)
{
all[x].setValue(all_events[i][randNum(0, (all_events[i].length - 1))].getTitle().split(' ')[1]);
};
}
break;
case 2:
var day = "Wednesday";
for (var x=0; x<all_events[i].length; x++)
{
desk_schedule.getSheets()[0].getRange("C"+(x+4)).setValue(all_events[i][x].getTitle().split(' ')[1] + ' ' + all_events[i][x].getTitle().split(' ')[2]);
}
for (var x=0; x<all.length; x++){
if (all[x].getA1Notation().indexOf("C")>=0)
{
all[x].setValue(all_events[i][randNum(0, (all_events[i].length - 1))].getTitle().split(' ')[1]);
};
}
break;
case 3:
var day = "Thursday";
for (var x=0; x<all_events[i].length; x++)
{
desk_schedule.getSheets()[0].getRange("D"+(x+4)).setValue(all_events[i][x].getTitle().split(' ')[1] + ' ' + all_events[i][x].getTitle().split(' ')[2]);
}
for (var x=0; x<all.length; x++){
if (all[x].getA1Notation().indexOf("D")>=0)
{
all[x].setValue(all_events[i][randNum(0, (all_events[i].length - 1))].getTitle().split(' ')[1]);
};
}
break;
case 4:
var day = "Friday";
for (var x=0; x<all_events[i].length; x++)
{
desk_schedule.getSheets()[0].getRange("E"+(x+4)).setValue(all_events[i][x].getTitle().split(' ')[1] + ' ' + all_events[i][x].getTitle().split(' ')[2]);
}
for (var x=0; x<all.length; x++){
if (all[x].getA1Notation().indexOf("E")>=0)
{
all[x].setValue(all_events[i][randNum(0, (all_events[i].length - 1))].getTitle().split(' ')[1]);
};
}
break;
case 5:
var day = "Saturday";
for (var x=0; x<all_events[i].length; x++)
{
desk_schedule.getSheets()[0].getRange("F"+(x+4)).setValue(all_events[i][x].getTitle().split(' ')[1] + ' ' + all_events[i][x].getTitle().split(' ')[2]);
}
for (var x=0; x<all.length; x++){
if (all[x].getA1Notation().indexOf("F")>=0)
{
all[x].setValue(all_events[i][randNum(0, (all_events[i].length - 1))].getTitle().split(' ')[1]);
};
}
break;
}
}
return desk_schedule;
}