-
Notifications
You must be signed in to change notification settings - Fork 0
/
AssignCrags.js
256 lines (178 loc) · 5.16 KB
/
AssignCrags.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
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
function sendWindgather(){
let crag = "Windgather"
let metavalue = "windgather"
sendtoCrag(crag, metavalue)
}
function sendSummitUp(){
let crag = "Summit Up Climbing Centre"
let metavalue = "Summit Up Climbing Centre"
sendtoCrag(crag, metavalue)
}
function sendCowsMouthQuarry(){
let crag = "Cow's Mouth Quarry"
let metavalue = "Cows Mouth Quarry"
sendtoCrag(crag, metavalue)
}
function sendRockover(){
let crag = "Rockover Climbing Centre"
let metavalue = "Rockover Climbing Centre"
sendtoCrag(crag, metavalue)
}
function sendCastleNaze(){
let crag = "Castle Naze"
let metavalue = "castlenaze"
sendtoCrag(crag, metavalue)
}
function sendWilton3(){
let crag = "Wilton 3"
let metavalue = "wilton3"
sendtoCrag(crag, metavalue)
}
function sendCadshaw(){
let crag = "Castle Cadshaw Rocks"
let metavalue = "cadshaw"
sendtoCrag(crag, metavalue)
}
function sendWilton1(){
let crag = "Wilton 1"
let metavalue = "wilton1"
sendtoCrag(crag, metavalue)
}
function sendWilton2(){
let crag = "Wilton 2"
let metavalue = "wilton2"
sendtoCrag(crag, metavalue)
}
function sendWilton4(){
let crag = "Wilton 4"
let metavalue = "wilton4"
sendtoCrag(crag, metavalue)
}
function sendEgerton(){
let crag = "Egerton Quarry"
let metavalue = "egerton"
sendtoCrag(crag, metavalue)
}
function sendAnglezarke(){
let crag = "Anglezarke Quarry"
let metavalue = "anglezarke"
sendtoCrag(crag, metavalue)
}
function sendDenham(){
let crag = "Denham Quarry"
let metavalue = "denham"
sendtoCrag(crag, metavalue)
}
function sendHorsethief(){
let crag = "Horsethief Quarry"
let metavalue = "horsethief"
sendtoCrag(crag, metavalue)
}
function sendkHarpurHill(){
let crag = "Harpur Hill"
let metavalue = "harpurhill"
sendtoCrag(crag, metavalue)
}
function sendHorseshoe(){
let crag = "Horseshoe Quarry"
let metavalue = "horseshoe"
sendtoCrag(crag, metavalue)
}
function sendPuleHill(){
let crag = "Pule Hill Rocks"
let metavalue = "pule_hill"
sendtoCrag(crag, metavalue)
}
function sendRunningHill(){
let crag = "Running Hill Pitts"
let metavalue = "Running Hill Pitts"
sendtoCrag(crag, metavalue)
}
function sendHobsonMoor(){
let crag = "Hobson Moor Quarry"
let metavalue = "hobsonmoor"
sendtoCrag(crag, metavalue)
}
// Western Grit far
function sendStanagePopular(){
let crag = "Stanage Popular"
let metavalue = "stanage_popular"
sendtoCrag(crag, metavalue)
}
function sendBamford(){
let crag = "Bamford Edge"
let metavalue = "bamford_edge"
sendtoCrag(crag, metavalue)
}
function sendFroggatt(){
let crag = "Froggatt Edge"
let metavalue = "froggatt"
sendtoCrag(crag, metavalue)
}
function sendRoaches(){
let crag = "The Roaches"
let metavalue = "roaches"
sendtoCrag(crag, metavalue)
}
function sendHeptonstall(){
let crag = "Heptonstall Rocks"
let metavalue = "heptonstall"
sendtoCrag(crag, metavalue)
}
function sendCheesden(){
let crag = "Cheesden Lumb Mill"
let metavalue = "Cheesden Lumb Mill"
sendtoCrag(crag, metavalue)
}
function sendtoCrag(crag, metavalue ) {
var spreadsheet = SpreadsheetApp.getActive();
var sheet = spreadsheet.getSheetByName('Crags');
var active_range = sheet.getActiveRange();
var currentRow = active_range.getRowIndex();
//var currentRow = "5";
console.log(currentRow);
if(currentRow <=1){Browser.msgBox('Select an actual signup', Browser.Buttons.OK); return;}
if(currentRow >=100){Browser.msgBox('Select an actual signup', Browser.Buttons.OK); return;}
var order_id = sheet.getRange(currentRow, 18,1,1).getValue(); /// get submission ID 1 BV ( was 67)
var first_name = sheet.getRange(currentRow, 3,1,1).getValue(); /// get submission ID 1 BV ( was 67)
console.log(order_id);
if(order_id === "" || order_id === "order_id"){Browser.msgBox('No Order ID Found', Browser.Buttons.OK); return;}
/**
var encodedAuthInformation = Utilities.base64Encode(apiusername+ ":" + apipassword);
var headers = {"Authorization" : "Basic " + encodedAuthInformation};
var options = {
'method' : 'get',
'contentType': 'application/json',
'headers': headers, // Convert the JavaScript object to a JSON string.
'payload' : JSON.stringify(data)
};
url="https://www."+ apidomain + "/wp-json/wc/v3/orders/" + order_id
var response = UrlFetchApp.fetch(url, options);
console.log(response);
*/
// if (Browser.msgBox("Send " +first_name + " to " + crag + "? \n Order " + order_id, Browser.Buttons.OK_CANCEL) == "ok") {
var cc_outdoor_assigner = Session.getActiveUser().getEmail();
var data = {"meta_data": [
{"key": "cc_outdoor_location",
"value": metavalue},
{"key": "cc_outdoor_location_assigned_by",
"value": cc_outdoor_assigner }
],
"status": "processing"
};
//console.log(orderstatus);
var encodedAuthInformation = Utilities.base64Encode(apiusername+ ":" + apipassword);
var headers = {"Authorization" : "Basic " + encodedAuthInformation};
var options = {
'method' : 'post',
'contentType': 'application/json',
'headers': headers, // Convert the JavaScript object to a JSON string.
'payload' : JSON.stringify(data)
};
url="https://www."+ apidomain + "/wp-json/wc/v3/orders/" + order_id
var response = UrlFetchApp.fetch(url, options);
console.log(response);
let venue =[[metavalue]];
sheet.getRange(currentRow, 1,1,1).setValues(venue);
//}
}