-
Notifications
You must be signed in to change notification settings - Fork 0
/
EveryoneFunctions.js
155 lines (106 loc) · 3.62 KB
/
EveryoneFunctions.js
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
function sendAllCragAssignments(tellme) {
const action = tellme
var sconn = Jdbc.getConnection(url, username, password);
var sstmt = sconn.createStatement();
let product_id = setupCell("Dashboard","B5")
//var product_id = "3103";
var order_results = sstmt.executeQuery('SELECT distinct order_id from wp_order_product_customer_lookup where product_id="' + product_id + '" AND status="wc-processing" AND cc_attendance="pending" LIMIT 99');
let active_user = Session.getActiveUser().getEmail();
let currentUnixTime = Date.now();
//var order_results = sstmt.executeQuery('select "3575"');
while (order_results.next()) {
scores_arr = [];
for (let col = 0; col < 1; col++) {
scores_arr.push(order_results.getString(col + 1));
}
console.log(scores_arr);
let order_id = scores_arr[0];
if (action === "close") {
var data = {
"status": "completed",
"meta_data": [
{
"key": "cc_attendance_set_by",
"value": active_user
},
{
"key": "cc_attendance_set_at",
"value": currentUnixTime
},
{
"key": "cc_attendance",
"value": "attended"
}
]
}
Logger.log(data);
pokeToWordPressOrders(data, order_id);
} /*else if (action === "location") {
if (Browser.msgBox("This will finalise the locations and email everyone their locations immediately", Browser.Buttons.OK_CANCEL) == "ok") {
if (Browser.msgBox("This should be done after 12:00 on Wed", Browser.Buttons.OK_CANCEL) == "ok") {
if (Browser.msgBox("This cannot be undone", Browser.Buttons.OK_CANCEL) == "ok") {
var data = {
"id": order_id,
"status": "on-hold",
"meta_data": [
{
"key": "cc_location_signed_off_by",
"value": active_user
},
{
"key": "cc_location_finalised_at",
"value": currentUnixTime
}
]
}
Logger.log(data);
pokeToWordPressOrders(data, order_id);
}
}
}
} else {
console.log("All done")
}
//conn.close();
//console.log("done")
}
if (action === "close") {
var data = {
"status": "private",
"meta_data": [
{
"key": "cc_post_set_private_set_by",
"value": active_user
},
{
"key": "cc_post_set_private_set_at",
"value": currentUnixTime
}
]
}
console.log("data");
pokeToWordPressProducts(data, product_id);
} */
else {
console.log("All done")
}
}}
//console.log(cell);
function markAttendedAndCloseEvent() {
if (Browser.msgBox("This will mark all those who haven't been cancelled as ATTENDED and will close the event", Browser.Buttons.OK_CANCEL) == "ok") {
if (Browser.msgBox("This should be done on the evening after the end of the trip", Browser.Buttons.OK_CANCEL) == "ok") {
if (Browser.msgBox("This cannot be undone", Browser.Buttons.OK_CANCEL) == "ok") {
sendAllCragAssignments("close");
try {
readData(); // Attempt to call the readData function
} catch (e) {
console.error("Error encountered during readData execution:", e); // Log any errors that occur
} //markEventComplete;
/// Close the event
}}}
}
/*
function finaliseCragLocations() {
sendAllCragAssignments("location");
}
*/