Browse code

added Conversations page and improved mobile compatibility

DoubleBastionAdmin authored on 02/04/2024 00:47:37
Showing 1 changed files
1 1
new file mode 100644
... ...
@@ -0,0 +1,936 @@
1
+/**
2
+ * @copyright 2021 Double Bastion LLC <www.doublebastion.com>
3
+ *
4
+ * @author Double Bastion LLC
5
+ *
6
+ * @license GNU AGPL version 3 or any later version
7
+ *
8
+ * This program is free software; you can redistribute it and/or
9
+ * modify it under the terms of the GNU AFFERO GENERAL PUBLIC LICENSE
10
+ * License as published by the Free Software Foundation; either
11
+ * version 3 of the License, or any later version.
12
+ *
13
+ * This program is distributed in the hope that it will be useful,
14
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
15
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
16
+ * GNU AFFERO GENERAL PUBLIC LICENSE for more details.
17
+ *
18
+ * You should have received a copy of the GNU Affero General Public
19
+ * License along with this program.  If not, see <http://www.gnu.org/licenses/>.
20
+ *
21
+ */
22
+
23
+$(document).ready(function() {
24
+
25
+  var userid = "<?php p($userId); ?>";
26
+  var isadm = '';
27
+  var ctappdir = 'apps';
28
+
29
+  // Get app directory
30
+  var getappdirurl = OC.generateUrl('/apps/sms_relentless/user/getappdirectory');
31
+
32
+  $.ajax({
33
+     method: 'GET',
34
+     url: getappdirurl + '/' + userid,
35
+     contentType: 'application/json',
36
+     success: function(appdirfdb) {
37
+
38
+                  ctappdir = appdirfdb;
39
+
40
+		  // Get personal settings
41
+		  var baseUrlget = OC.generateUrl('/apps/sms_relentless/user/getsettings');
42
+
43
+		  $.ajax({
44
+		     method: 'GET',
45
+		     url: baseUrlget + '/' + userid,
46
+		     contentType: 'application/json',
47
+		     success: function(settingsfromdb) {
48
+
49
+			 // Add the webhook URLs section, if the user is not an admin
50
+			 if (settingsfromdb.adminornot == 'reguser') {
51
+
52
+			     isadm = 'reguser';
53
+
54
+			     $("#appTitlePrg").append('<p id="settings-dscr"><h3>Enter your options in the fields from below. As a non-admin user, you can use any of the SMS service providers from \
55
+				  below (Telnyx/Plivo/Twilio/Flowroute), on the condition that an admin has shared with you his API keys for that provider. If an admin has shared with you his API \
56
+				  keys for a provider, to be able to use them properly, you will have to generate the two webhook URLs for that provider by clicking the corresponding \
57
+				  "Generate new webhook URL ..." buttons from below, then click "Save" at the bottom of this page:</h3></p><br>');
58
+
59
+			     $("#nadmProvSection").append('<div class="providerSettings"><p><label for="telapi_url_rec" class="setlabeltext"><b>Telnyx webhook URL for incoming SMS/MMS</b> (Generate \
60
+				  the URL by pressing the button from below. Don\'t forget to also click the \'Save\' button at the bottom of this page after entering all the options, to save \
61
+				  all the settings to the database.)</label></p> \
62
+				  <input type="button" id="generate_tel_rcpt" class="generateUrl" value="Generate new webhook URL for incoming SMS/MMS" /> \
63
+				  <input type="text" class="smsr_textboxspec" id="telapi_url_rec" name="telapi_url_rec" autocomplete="false" /> \
64
+				  <span id="copyToClipboardtel" class="icon icon-clippy" title="Copy to clipboard"></span><br><br> \
65
+				  \
66
+				  <p><label for="telapi_url" class="setlabeltext"><b>Telnyx webhook URL for delivery receipts</b> (This URL will be included by SMS Relentless in message sending \
67
+				  requests, so that Telnyx will know where to send the delivery receipts. Just generate it by pressing the button from below. Don\'t forget to click the \'Save\' \
68
+				  button at the bottom of this page after entering all the options, to save all the settings to the database.)</label></p> \
69
+				  <input type="button" id="generate_tel_delrcpt" class="generateUrl" value="Generate new webhook URL for delivery receipts" /> \
70
+				  <input type="text" id="telapi_url" name="telapi_url" autocomplete="false" /></div><br><br> \
71
+				  \
72
+				  <div class="providerSettings"><p><label for="nexapi_url_rec" class="setlabeltext"><b>Plivo webhook URL for incoming SMS/MMS</b> (Generate the URL by pressing \
73
+				  the button from below. Don\'t forget to also click the \'Save\' button at the bottom of this page after entering all the options, to save all the settings \
74
+				  to the database.)</label></p> \
75
+				  <input type="button" id="generate_nex_rcpt" class="generateUrl" value="Generate new webhook URL for incoming SMS/MMS" /> \
76
+				  <input type="text" class="smsr_textboxspec" id="nexapi_url_rec" name="nexapi_url_rec" autocomplete="false" /> \
77
+				  <span id="copyToClipboardnex" class="icon icon-clippy" title="Copy to clipboard"></span><br><br> \
78
+				  \
79
+				  <p><label for="nexapi_url" class="setlabeltext"><b>Plivo webhook URL for delivery receipts</b> (This URL will be included by SMS Relentless in message sending \
80
+				  requests, so that Plivo will know where to send the delivery receipts. Just generate it by pressing the button from below. Don\'t forget to click the \'Save\' \
81
+				  button at the bottom of this page after entering all the options, to save all the settings to the database.)</label></p> \
82
+				  <input type="button" id="generate_nex_delrcpt" class="generateUrl" value="Generate new webhook URL for delivery receipts" /> \
83
+				  <input type="text" id="nexapi_url" name="nexapi_url" autocomplete="false" /></div><br><br> \
84
+				  \
85
+				  <div class="providerSettings"><p><label for="twilapi_url_rec" class="setlabeltext"><b>Twilio webhook URL for incoming SMS/MMS</b> (Generate the URL by pressing \
86
+				  the button from below. Don\'t forget to also click the \'Save\' button at the bottom of this page after entering all the options, to save all the settings to \
87
+				  the database.)</label></p> \
88
+				  <input type="button" id="generate_twil_rcpt" class="generateUrl" value="Generate new webhook URL for incoming SMS/MMS" /> \
89
+				  <input type="text" class="smsr_textboxspec" id="twilapi_url_rec" name="twilapi_url_rec" autocomplete="false" /> \
90
+				  <span id="copyToClipboardtwil" class="icon icon-clippy" title="Copy to clipboard"></span><br><br> \
91
+				  \
92
+				  <p><label for="twilapi_url" class="setlabeltext"><b>Twilio webhook URL for delivery receipts</b> (This URL will be included by SMS Relentless in message sending \
93
+				  requests, so that Twilio will know where to send the delivery receipts. Just generate it by pressing the button from below. Don\'t forget to click the \'Save\' \
94
+				  button at the bottom of this page after entering all the options, to save all the settings to the database.)</label></p> \
95
+				  <input type="button" id="generate_twil_delrcpt" class="generateUrl" value="Generate new webhook URL for delivery receipts" /> \
96
+				  <input type="text" id="twilapi_url" name="twilapi_url" autocomplete="false" /></div><br><br> \
97
+				  \
98
+				  <div class="providerSettings"><p><label for="flowapi_url_rec" class="setlabeltext"><b>Flowroute webhook URL for incoming SMS/MMS</b> (Generate the URL by pressing \
99
+				  the button from below. Don\'t forget to also click the \'Save\' button at the bottom of this page after entering all the options, to save all the settings to \
100
+				  the database.)</label></p> \
101
+				  <input type="button" id="generate_flow_rcpt" class="generateUrl" value="Generate new webhook URL for incoming SMS/MMS" /> \
102
+				  <input type="text" class="smsr_textboxspec" id="flowapi_url_rec" name="flowapi_url_rec" autocomplete="false" /> \
103
+				  <span id="copyToClipboardflow" class="icon icon-clippy" title="Copy to clipboard"></span><br><br> \
104
+				  \
105
+				  <p><label for="flowapi_url" class="setlabeltext"><b>Flowroute webhook URL for delivery receipts</b> (This URL will be included by SMS Relentless in message sending \
106
+				  requests, so that Flowroute will know where to send the delivery receipts. Just generate it by pressing the button from below. Don\'t forget to click the \'Save\' \
107
+				  button at the bottom of this page after entering all the options, to save all the settings to the database.)</label></p> \
108
+				  <input type="button" id="generate_flow_delrcpt" class="generateUrl" value="Generate new webhook URL for delivery receipts" /> \
109
+				  <input type="text" id="flowapi_url" name="flowapi_url" autocomplete="false" /><br><br> \
110
+				  Flowroute only supports sending/receiving SMS/MMS messages within USA and Canada and it doesn\'t support Alphanumeric Sender IDs.</div><br>');
111
+
112
+
113
+				  $("#telapi_url_rec").val(settingsfromdb.telapi_url_rec);
114
+				  $("#telapi_url").val(settingsfromdb.telapi_url);
115
+				  $("#nexapi_url_rec").val(settingsfromdb.nexapi_url_rec);
116
+				  $("#nexapi_url").val(settingsfromdb.nexapi_url);
117
+				  $("#twilapi_url_rec").val(settingsfromdb.twilapi_url_rec);
118
+				  $("#twilapi_url").val(settingsfromdb.twilapi_url);
119
+				  $("#flowapi_url_rec").val(settingsfromdb.flowapi_url_rec);
120
+				  $("#flowapi_url").val(settingsfromdb.flowapi_url);
121
+				  $("#messagesperpage").val(settingsfromdb.messagesperpage);
122
+				  $("#archivedconvnmbr").val(settingsfromdb.archived_conv_nmbr);
123
+				  $("#msgcheckinterval").val(settingsfromdb.msg_check_interval);
124
+
125
+
126
+				  if (settingsfromdb.get_notify == 1) {
127
+				      $("#get_notify").attr('checked', true);
128
+				  } else {
129
+				      $("#get_notify").attr('checked', false);
130
+				  }
131
+
132
+				  $("#notification_email").val(settingsfromdb.notification_email);
133
+
134
+				  if (settingsfromdb.getsmsinemail == 1) {
135
+				      $("#includesmsinemail").attr('checked', true);
136
+				  } else {
137
+				      $("#includesmsinemail").attr('checked', false);
138
+				  }
139
+
140
+				  if (settingsfromdb.show_display_names == 1) {
141
+				      $("#showdisplaynames").attr('checked', true);
142
+				  } else {
143
+				      $("#showdisplaynames").attr('checked', false);
144
+				  }
145
+
146
+				  if (settingsfromdb.add_display_names == 1) {
147
+				      $("#adddisplaynames").attr('checked', true);
148
+				  } else {
149
+				      $("#adddisplaynames").attr('checked', false);
150
+				  }
151
+
152
+				  function randomStr(strlength) {
153
+					var fintext = "";
154
+					var keyspace = '0123456789abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ';
155
+					for (var i = 0; i < strlength; i++) {
156
+					     fintext += keyspace.charAt(Math.floor(Math.random() * keyspace.length));
157
+					}
158
+					return fintext;
159
+				  }
160
+
161
+				  $("#generate_tel_rcpt").on("click", function(event) {
162
+
163
+				     var teltokenrec = randomStr(70);
164
+				     var telnyxwhurlrec = window.location.origin + OC.generateUrl('/apps/sms_relentless/api/recsmstel?telrecparam=') + teltokenrec;
165
+
166
+				     $("#telapi_url_rec").val(telnyxwhurlrec);
167
+				  });
168
+
169
+				  $("#copyToClipboardtel").on("click", function(event) {
170
+				     var $tempEl = $("<input>");
171
+				     $("body").append($tempEl);
172
+				     $tempEl.val($("#telapi_url_rec").val()).select();
173
+				     document.execCommand("Copy");
174
+				     $tempEl.remove();
175
+				     showAlert("The link has been copied to your clipboard!");
176
+				  });
177
+
178
+				  $("#generate_tel_delrcpt").on("click", function(event) {
179
+
180
+				     var teltoken = randomStr(70);
181
+				     var telnyxwhurl = window.location.origin + OC.generateUrl('/apps/sms_relentless/api/recdeliverytel?teldrparam=') + teltoken;
182
+
183
+				     $("#telapi_url").val(telnyxwhurl);
184
+				  });
185
+
186
+
187
+				  $("#generate_nex_rcpt").on("click", function(event) {
188
+
189
+				     var plivotokenrec = randomStr(70);
190
+				     var plivowhurlrec = window.location.origin + OC.generateUrl('/apps/sms_relentless/api/recsmsnex?plivorecparam=') + plivotokenrec;
191
+
192
+				     $("#nexapi_url_rec").val(plivowhurlrec);
193
+				  });
194
+
195
+				  $("#copyToClipboardnex").on("click", function(event) {
196
+				     var $tempElpl = $("<input>");
197
+				     $("body").append($tempElpl);
198
+				     $tempElpl.val($("#nexapi_url_rec").val()).select();
199
+				     document.execCommand("Copy");
200
+				     $tempElpl.remove();
201
+				     showAlert("The link has been copied to your clipboard!");
202
+				  });
203
+
204
+				  $("#generate_nex_delrcpt").on("click", function(event) {
205
+
206
+				     var plivotoken = randomStr(70);
207
+				     var plivodrwhurl = window.location.origin + OC.generateUrl('/apps/sms_relentless/api/recdeliverynex?plivodrparam=') + plivotoken;
208
+
209
+				     $("#nexapi_url").val(plivodrwhurl);
210
+				  });
211
+
212
+
213
+				  $("#generate_twil_rcpt").on("click", function(event) {
214
+
215
+				     var twiltokenrec = randomStr(35);
216
+				     var twilwhurlrec = window.location.origin + OC.generateUrl('/apps/sms_relentless/api/recsmstwil?twilrecparam=') + twiltokenrec;
217
+
218
+				     $("#twilapi_url_rec").val(twilwhurlrec);
219
+				  });
220
+
221
+				  $("#copyToClipboardtwil").on("click", function(event) {
222
+				     var $tempElpl = $("<input>");
223
+				     $("body").append($tempElpl);
224
+				     $tempElpl.val($("#twilapi_url_rec").val()).select();
225
+				     document.execCommand("Copy");
226
+				     $tempElpl.remove();
227
+				     showAlert("The link has been copied to your clipboard!");
228
+				  });
229
+
230
+				  $("#generate_twil_delrcpt").on("click", function(event) {
231
+
232
+				     var twiltoken = randomStr(35);
233
+				     var twildrwhurl = window.location.origin + OC.generateUrl('/apps/sms_relentless/api/recdeliverytwil?twildrparam=') + twiltoken;
234
+
235
+				     $("#twilapi_url").val(twildrwhurl);
236
+				  });
237
+
238
+
239
+				  $("#generate_flow_rcpt").on("click", function(event) {
240
+
241
+				     var flowtokenrec = randomStr(70);
242
+				     var flowwhurlrec = window.location.origin + OC.generateUrl('/apps/sms_relentless/api/recsmsflow?flowrecparam=') + flowtokenrec;
243
+
244
+				     $("#flowapi_url_rec").val(flowwhurlrec);
245
+				  });
246
+
247
+				  $("#copyToClipboardflow").on("click", function(event) {
248
+				     var $tempElpl = $("<input>");
249
+				     $("body").append($tempElpl);
250
+				     $tempElpl.val($("#flowapi_url_rec").val()).select();
251
+				     document.execCommand("Copy");
252
+				     $tempElpl.remove();
253
+				     showAlert("The link has been copied to your clipboard!");
254
+				  });
255
+
256
+				  $("#generate_flow_delrcpt").on("click", function(event) {
257
+
258
+				     var flowtoken = randomStr(70);
259
+				     var flowdrwhurl = window.location.origin + OC.generateUrl('/apps/sms_relentless/api/recdeliveryflow?flowdrparam=') + flowtoken;
260
+
261
+				     $("#flowapi_url").val(flowdrwhurl);
262
+				  });
263
+
264
+
265
+			 } else if (settingsfromdb.adminornot == 'admin') {
266
+
267
+				  $("#appTitlePrg").append('<p id="settings-dscr"><h3>First enter your credentials on the admin settings page of the app (on the left panel, under Administration, \
268
+				                            click on SMS Relentless), then enter your options in the fields from below:</h3></p><br>');
269
+				  isadm = 'admin';
270
+
271
+				  $("#messagesperpage").val(settingsfromdb.messagesperpage);
272
+                                  $("#archivedconvnmbr").val(settingsfromdb.archived_conv_nmbr);
273
+				  $("#msgcheckinterval").val(settingsfromdb.msg_check_interval);
274
+
275
+				  if (settingsfromdb.get_notify == 1) {
276
+				      $("#get_notify").attr('checked', true);
277
+				  } else {
278
+				      $("#get_notify").attr('checked', false);
279
+				  }
280
+
281
+				  $("#notification_email").val(settingsfromdb.notification_email);
282
+
283
+				  if (settingsfromdb.getsmsinemail == 1) {
284
+				      $("#includesmsinemail").attr('checked', true);
285
+				  } else {
286
+				      $("#includesmsinemail").attr('checked', false);
287
+				  }
288
+
289
+				  if (settingsfromdb.show_display_names == 1) {
290
+				      $("#showdisplaynames").attr('checked', true);
291
+				  } else {
292
+				      $("#showdisplaynames").attr('checked', false);
293
+				  }
294
+
295
+				  if (settingsfromdb.add_display_names == 1) {
296
+				      $("#adddisplaynames").attr('checked', true);
297
+				  } else {
298
+				      $("#adddisplaynames").attr('checked', false);
299
+				  }
300
+			 }
301
+
302
+
303
+			 // Auto-reply settings
304
+
305
+			 // Get the available phone numbers from all providers associated with the access keys entered on the Settings page (restrictions are applied to numbers for non-admins)
306
+			 $("#autoRplPhoneNb").addClass('icon-loading');
307
+			 var getnumbersUrl = OC.generateUrl("/apps/sms_relentless/user/getautoreplyconf");
308
+
309
+			 $.ajax({
310
+				  url: getnumbersUrl + '/' + userid,
311
+				  type: "GET",
312
+				  contentType: 'application/json',
313
+				  success: function(autoreplydata) {
314
+
315
+				                    $("#autoRplPhoneNb").removeClass('icon-loading');
316
+				                    var cusrDisplayName = autoreplydata.userdisplayname;
317
+				                    var availPhoneNmbrs = autoreplydata.phonenumbers;
318
+				                    var autorpldata = autoreplydata.autoreplies;
319
+
320
+						    if (autorpldata.length > 0) { 
321
+							var arplNmb = autorpldata.length;
322
+						    } else { 
323
+							var arplNmb = 0; 
324
+						    }
325
+
326
+						    // List the auto-replies for the phone numbers available for the current user
327
+						    if (arplNmb == 0) {
328
+
329
+							$("#autoReplyTbl").append("<tr><td><input type='text' class='arplAuthor' value='"+ cusrDisplayName +"' disabled></td><td><select id='arpphn-"+ arplNmb +"' class='arplPhoneNmbr'></select></td><td><div id='arplmode-"+ arplNmb +"' class='arplMode'><select id='modeselect-"+ arplNmb +"' class='selectArplMode'><option value='' selected>Select mode</option><option value='daily'>Daily mode</option><option value='vacation'>Vacation mode</option></select><div id='modecont-"+ arplNmb +"' class='modeContent'></div></div></td><td><textarea id='arpltxt-"+ arplNmb +"' class='arplText' rows='20' cols='40' placeholder='Enter the auto-reply message here.'></textarea></td><td><img id='rmRow-"+ arplNmb +"' class='removeRow' src='/" + ctappdir + "/sms_relentless/img/closewnd.svg' title='Remove this row from the database' style='cursor:pointer;margin:9px 8px 0px 18px;'></td><td><input type='submit' id='arplsave-"+ arplNmb +"' class='saveAutoReply' value='Save' title='Save Row' /></td></tr>");
330
+							$("#autoReplyTbl").append("<div><img id='addArplRow' src='/" + ctappdir + "/sms_relentless/img/add.svg' title='Add Row'></div>");
331
+
332
+						    } else {
333
+
334
+							for (k = 0; k < arplNmb; k++) {
335
+
336
+				                             if (autorpldata[k].days_of_week != '') {
337
+
338
+				                                 var slctdMode = "<option value=''>Select mode</option><option value='daily' selected>Daily mode</option><option value='vacation'>Vacation mode</option>";
339
+				                                 var dailyStartArr = autorpldata[k].daily_start.split(":");
340
+				                                 var dailyEndArr = autorpldata[k].daily_end.split(":");
341
+
342
+						                 var dlHrStartOptions = "";
343
+							         for (var hr = 0; hr < 24; hr++) {
344
+						                      if (dailyStartArr[0] != hr.toLocaleString('en-US', {minimumIntegerDigits: 2, useGrouping:false})) {
345
+							                  dlHrStartOptions += "<option value='"+ hr.toLocaleString('en-US', {minimumIntegerDigits: 2, useGrouping:false}) +"'>"+ hr.toLocaleString('en-US', {minimumIntegerDigits: 2, useGrouping:false}) +"</option>";
346
+						                      } else {
347
+							                  dlHrStartOptions += "<option value='"+ hr.toLocaleString('en-US', {minimumIntegerDigits: 2, useGrouping:false}) +"' selected>"+ hr.toLocaleString('en-US', {minimumIntegerDigits: 2, useGrouping:false}) +"</option>";
348
+						                      }
349
+							         }
350
+
351
+						                 var dlMnStartOptions = "";
352
+							         for (var mn = 0; mn < 60; mn++) {
353
+						                      if (dailyStartArr[1] != mn.toLocaleString('en-US', {minimumIntegerDigits: 2, useGrouping:false})) {
354
+							                  dlMnStartOptions += "<option value='"+ mn.toLocaleString('en-US', {minimumIntegerDigits: 2, useGrouping:false}) +"'>"+ mn.toLocaleString('en-US', {minimumIntegerDigits: 2, useGrouping:false}) +"</option>";
355
+						                      } else {
356
+							                  dlMnStartOptions += "<option value='"+ mn.toLocaleString('en-US', {minimumIntegerDigits: 2, useGrouping:false}) +"' selected>"+ mn.toLocaleString('en-US', {minimumIntegerDigits: 2, useGrouping:false}) +"</option>";
357
+						                      }
358
+							         }
359
+
360
+						                 var dlHrEndOptions = "";
361
+							         for (var hr = 0; hr < 24; hr++) {
362
+						                      if (dailyEndArr[0] != hr.toLocaleString('en-US', {minimumIntegerDigits: 2, useGrouping:false})) {
363
+							                  dlHrEndOptions += "<option value='"+ hr.toLocaleString('en-US', {minimumIntegerDigits: 2, useGrouping:false}) +"'>"+ hr.toLocaleString('en-US', {minimumIntegerDigits: 2, useGrouping:false}) +"</option>";
364
+						                      } else {
365
+							                  dlHrEndOptions += "<option value='"+ hr.toLocaleString('en-US', {minimumIntegerDigits: 2, useGrouping:false}) +"' selected>"+ hr.toLocaleString('en-US', {minimumIntegerDigits: 2, useGrouping:false}) +"</option>";
366
+						                      }
367
+							         }
368
+
369
+						                 var dlMnEndOptions = "";
370
+							         for (var mn = 0; mn < 60; mn++) {
371
+						                      if (dailyEndArr[1] != mn.toLocaleString('en-US', {minimumIntegerDigits: 2, useGrouping:false})) {
372
+							                  dlMnEndOptions += "<option value='"+ mn.toLocaleString('en-US', {minimumIntegerDigits: 2, useGrouping:false}) +"'>"+ mn.toLocaleString('en-US', {minimumIntegerDigits: 2, useGrouping:false}) +"</option>";
373
+						                      } else {
374
+							                  dlMnEndOptions += "<option value='"+ mn.toLocaleString('en-US', {minimumIntegerDigits: 2, useGrouping:false}) +"' selected>"+ mn.toLocaleString('en-US', {minimumIntegerDigits: 2, useGrouping:false}) +"</option>";
375
+						                      }
376
+							         }
377
+
378
+				                                 var modeContent = "<div class='daysOfWeek'>Days of the week:<div class='tooltipautoreply'><div id='infoautoreply'>i</div><div class='autorpltooltip'>Enter the order number of the days of the week in which the auto-reply will be sent. For example, to send the auto-reply every day from Monday to Friday outside the time interval specified below, enter 1,2,3,4,5 To send the auto-reply only Monday, Thursday and Friday enter 1,4,5 To send the auto-reply every day of the week enter 1,2,3,4,5,6,7 As an exception, if you want the auto-reply to be sent during an entire day, irrespective of the specified interval, add (full) after the number of that day. For example, if you want the auto-reply to be sent from Monday to Friday outside the interval specified below, and also during the entire days of Saturday and Sunday, enter 1,2,3,4,5,6(full),7(full)</div></div></div><input type='text' id='weekdays-"+ k +"' class='daysInWeek' value='"+ autorpldata[k].days_of_week +"'><div class='chooseTInterval'>Send auto-reply <span style='color:#ad0202'>outside</span> this interval:<div class='tooltipautoreplyst'><div id='infoautoreplyst'>i</div><div class='autorpltooltipst'>These fields specify the time of the server. If the server is located in a time zone that is different from that of the owner/company, the time interval entered here should be adjusted accordingly.</div></div></div><div class='selectArplHours'><select id='dmstarthr-"+ k +"' class='selectHrMin'>"+ dlHrStartOptions +"</select><select id='dmstartmn-"+ k +"' class='selectHrMin'>"+ dlMnStartOptions +"</select><span style='font-weight: 600'> — </span><select id='dmendhr-"+ k +"' class='selectHrMin'>"+ dlHrEndOptions +"</select><select id='dmendmn-"+ k +"' class='selectHrMin'>"+ dlMnEndOptions +"</select></div>";
379
+
380
+				                             } else {
381
+
382
+				                                 var vctnStart = autorpldata[k].vacation_start.split(" ")[0];
383
+				                                 var vctnEnd = autorpldata[k].vacation_end.split(" ")[0];
384
+
385
+				                                 var slctdMode = "<option value=''>Select mode</option><option value='daily'>Daily mode</option><option value='vacation' selected>Vacation mode</option>";
386
+				                                 var modeContent = "<div class='chooseDateIntvl'>Send auto-reply <span style='color:#ad0202'>inside</span> this interval:</div><div class='arplstrtendDates'><div class='stdtTitle'>Start Date</div><input type='text' id='startDT-"+ k +"' class='startDate' placeholder='Pick a date' value='"+ vctnStart +"'><div class='enddtTitle'>End Date</div><input type='text' id='endDT-"+ k +"' class='endDate' placeholder='Pick a date' value='"+ vctnEnd +"'></div>"
387
+				                             }
388
+
389
+							     $("#autoReplyTbl").append("<tr><td><input type='text' class='arplAuthor' value='"+ autorpldata[k].saved_by_dsplname +"' disabled></td><td><select id='arpphn-"+ k +"' class='arplPhoneNmbr' style='pointer-events:none'><option selected>"+ autorpldata[k].phone_number +"</option></select></td><td><div id='arplmode-"+ k +"' class='arplMode'><select id='modeselect-"+ k +"' class='selectArplMode'>"+ slctdMode +"</select><div id='modecont-"+ k +"' class='modeContent'>"+ modeContent +"</div></div></td><td><textarea id='arpltxt-"+ k +"' class='arplText' rows='20' cols='40' placeholder='Enter the auto-reply message here.'>"+ autorpldata[k].message_text +"</textarea></td><td><img id='rmRow-"+ k +"' class='removeRow' src='/" + ctappdir + "/sms_relentless/img/closewnd.svg' title='Remove this row from the database' style='cursor:pointer;margin:9px 8px 0px 18px;'></td><td><input type='submit' id='arplsave-"+ k +"' class='saveAutoReply' value='Edit' title='Edit Row' /></td></tr>");
390
+							}
391
+							$("#autoReplyTbl").append("<div><img id='addArplRow' src='/" + ctappdir + "/sms_relentless/img/add.svg' title='Add Row'></div>");
392
+						    }
393
+
394
+
395
+						    // Create a list with all the available phone numbers
396
+				                    var numbersListItems = "<option value='' selected>Select phone number</option>";
397
+
398
+						    $.each(availPhoneNmbrs, function(key, indsmsnmb) {
399
+							   numbersListItems += "<option value='"+ indsmsnmb +"'>"+ indsmsnmb +"</option>";
400
+						    });
401
+
402
+				                    if (arplNmb == 0) {
403
+							$("#arpphn-"+ arplNmb).append(numbersListItems);
404
+				                    }
405
+
406
+				                    // Initialize the date picker
407
+						    $('[id^="endDT-"]').datepicker({ dateFormat: "yy-mm-dd" });
408
+						    $('[id^="startDT-"]').datepicker({ dateFormat: "yy-mm-dd" });
409
+
410
+
411
+				                    // Select the auto-reply mode
412
+				                    function selectMode() {
413
+
414
+						            $('[id^="modeselect-"]').change(function() {
415
+
416
+						               var crtnmbr = $(this).attr("id").replace("modeselect-", "");
417
+
418
+						               var dailyHrStart = "";
419
+						               for (var h = 0; h < 24; h++) {
420
+						                    dailyHrStart += "<option value='"+ h.toLocaleString('en-US', {minimumIntegerDigits: 2, useGrouping:false}) +"'>"+ h.toLocaleString('en-US', {minimumIntegerDigits: 2, useGrouping:false}) +"</option>";
421
+						               }
422
+
423
+						               var dailyMnStart = "";
424
+						               for (var m = 0; m < 60; m++) {
425
+						                    dailyMnStart += "<option value='"+ m.toLocaleString('en-US', {minimumIntegerDigits: 2, useGrouping:false}) +"'>"+ m.toLocaleString('en-US', {minimumIntegerDigits: 2, useGrouping:false}) +"</option>";
426
+						               }
427
+
428
+						               var dailyHrEnd = dailyHrStart;
429
+						               var dailyMnEnd = dailyMnStart;
430
+
431
+						               if ($(this).val() == 'daily') {
432
+						                   $("#modecont-"+ crtnmbr).empty();
433
+						                   $("#modecont-"+ crtnmbr).append("<div class='daysOfWeek'>Days of the week:<div class='tooltipautoreply'><div id='infoautoreply'>i</div><div class='autorpltooltip'>Enter the order number of the days of the week in which the auto-reply will be sent. For example, to send the auto-reply every day from Monday to Friday outside the time interval specified below, enter 1,2,3,4,5 To send the auto-reply only Monday, Thursday and Friday enter 1,4,5 To send the auto-reply every day of the week enter 1,2,3,4,5,6,7 As an exception, if you want the auto-reply to be sent during an entire day, irrespective of the specified interval, add (full) after the number of that day. For example, if you want the auto-reply to be sent from Monday to Friday outside the interval specified below, and also during the entire days of Saturday and Sunday, enter 1,2,3,4,5,6(full),7(full)</div></div></div><input type='text' id='weekdays-"+ crtnmbr +"' class='daysInWeek'><div class='chooseTInterval'>Send auto-reply <span style='color:#ad0202'>outside</span> this interval:<div class='tooltipautoreplyst'><div id='infoautoreplyst'>i</div><div class='autorpltooltipst'>These fields specify the time of the server. If the server is located in a time zone that is different from that of the owner/company, the time interval entered here should be adjusted accordingly.</div></div></div><div class='selectArplHours'><select id='dmstarthr-"+ crtnmbr +"' class='selectHrMin'>"+ dailyHrStart +"</select><select id='dmstartmn-"+ crtnmbr +"' class='selectHrMin'>"+ dailyMnStart +"</select><span style='font-weight: 600'> — </span><select id='dmendhr-"+ crtnmbr +"' class='selectHrMin'>"+ dailyHrEnd +"</select><select id='dmendmn-"+ crtnmbr +"' class='selectHrMin'>"+ dailyMnEnd +"</select></div>");
434
+						               } else if ($(this).val() == 'vacation') {
435
+						                   $("#modecont-"+ crtnmbr).empty();
436
+						                   $("#modecont-"+ crtnmbr).append("<div class='chooseDateIntvl'>Send auto-reply <span style='color:#ad0202'>inside</span> this interval:</div><div class='arplstrtendDates'><div class='stdtTitle'>Start Date</div><input type='text' id='startDT-"+ crtnmbr +"' class='startDate' placeholder='Pick a date'><div class='enddtTitle'>End Date</div><input type='text' id='endDT-"+ crtnmbr +"' class='endDate' placeholder='Pick a date' /></div>");
437
+						               }
438
+
439
+							       $("#endDT-"+ crtnmbr +"").datepicker({ dateFormat: "yy-mm-dd" });
440
+							       $("#startDT-"+ crtnmbr +"").datepicker({ dateFormat: "yy-mm-dd" });
441
+						          });
442
+				                  }
443
+				                  selectMode();
444
+
445
+						  // Save the data
446
+						  function saveArplRow() {
447
+
448
+						     $('[id^="arplsave-"]').unbind("click");
449
+						     $('[id^="arplsave-"]').click(function(event) {
450
+
451
+							event.preventDefault();
452
+							var crntrwnmbr = $(this).attr("id").replace("arplsave-", "");
453
+
454
+							if ($(this).attr("value") == "Save") {
455
+
456
+							    var phoneNmbr = $("#arpphn-"+ crntrwnmbr).val();
457
+							    var arplText = $("#arpltxt-"+ crntrwnmbr).val();
458
+							    var slctdMode = $("#modeselect-"+ crntrwnmbr).val();
459
+
460
+							    var slctddmDays = "";
461
+							    var slctdHrStart = "";
462
+							    var slctdMnStart = "";
463
+							    var slctdHrEnd = "";
464
+							    var slctdMnEnd = "";
465
+
466
+							    var vcStartDate = null;
467
+							    var vcEndDate = null;
468
+
469
+							    if (slctdMode == 'daily') {
470
+
471
+								slctddmDays = $("#weekdays-"+ crntrwnmbr).val().trim();
472
+								slctdHrStart = $("#dmstarthr-"+ crntrwnmbr).val().trim();
473
+								slctdMnStart = $("#dmstartmn-"+ crntrwnmbr).val().trim();
474
+								slctdHrEnd = $("#dmendhr-"+ crntrwnmbr).val().trim();
475
+								slctdMnEnd = $("#dmendmn-"+ crntrwnmbr).val().trim();
476
+
477
+				                                if (slctdHrStart != '' && slctdMnStart != '') {
478
+				                                    var hrmnStartComp = slctdHrStart +":"+ slctdMnStart;
479
+				                                } else { var hrmnStartComp = ""; }
480
+
481
+				                                if (slctdHrEnd != '' && slctdMnEnd != '') {
482
+				                                    var hrmnEndComp = slctdHrEnd +":"+ slctdMnEnd;
483
+				                                } else { var hrmnEndComp = ""; }
484
+
485
+				                                if (!(/^[1-7ful\,\(\)]+$/.test(slctddmDays))) {
486
+								    showAlert("The 'Days of the week' field can contain only digits from 1 to 7, the lowercase letters f, u and l, round brackets ()() and commas (,).");
487
+								    return;
488
+				                                }
489
+
490
+				                                if (!(/^[0-9]+$/.test(slctdHrStart + slctdMnStart + slctdHrEnd + slctdMnEnd))) {
491
+								    showAlert("The starting and ending values of the time interval for the 'Daily mode' can contain only digits from 0 to 9.");
492
+								    return;
493
+				                                }
494
+
495
+				                                if (slctddmDays.trim() == '' || (slctdHrStart == slctdHrEnd && slctdMnStart == slctdMnEnd)) {
496
+								    showAlert("For the 'Daily mode', you have to enter the order number of the days of the week for which you want the auto-reply to be sent, and you have to set a starting time that is different from the ending time!");
497
+								    return;
498
+				                                }
499
+
500
+							    } else if (slctdMode == 'vacation') {
501
+				
502
+				                                if ($("#startDT-"+ crntrwnmbr).val().trim() == '' || $("#endDT-"+ crntrwnmbr).val().trim() == '') {
503
+
504
+								    showAlert("For the 'Vacation mode', you have to enter both a start date and an end date.");
505
+								    return;
506
+
507
+				                                } else {
508
+
509
+				                                    if (!(/^[0-9\-]+$/.test($("#startDT-"+ crntrwnmbr).val().trim() + $("#endDT-"+ crntrwnmbr).val().trim()))) {
510
+								        showAlert("The start date and end date values for the 'Vacation mode' can contain only digits from 0 to 9 and hyphens (-).");
511
+								        return;
512
+				                                    }
513
+
514
+						                    vcStartDate = $("#startDT-"+ crntrwnmbr).val().trim() +" 00:00:00";
515
+								    vcEndDate = $("#endDT-"+ crntrwnmbr).val().trim() +" 23:59:59";
516
+								    var strtDateCmp = new Date(vcStartDate).toJSON().slice(0, 10) +" 00:00:00";
517
+								    var endDateCmp = new Date(vcEndDate).toJSON().slice(0, 10) +" 23:59:59";
518
+								    var crntDate = new Date().toJSON().slice(0, 10) +" 23:59:59";
519
+
520
+				                                    if (vcStartDate.trim() == "" || vcEndDate.trim() == "" || (strtDateCmp >= endDateCmp || ((strtDateCmp < crntDate) && (endDateCmp < crntDate)))) {
521
+								        showAlert("For 'Vacation mode', you have to enter both a start date and an end date, the start date must be before the end date and at least the ending of the time interval must be in the future.");
522
+								        return;
523
+				                                    }
524
+				                                }
525
+							    }
526
+
527
+
528
+							    if (phoneNmbr != '') {
529
+
530
+							      if (arplText.trim() != '') {
531
+
532
+								if (slctdMode != '') {
533
+
534
+								    var saveArplUrl = OC.generateUrl('/apps/sms_relentless/user/updateautoreplies');
535
+								    var arpldata = {
536
+								         userId: userid,
537
+								         savedByDsplname: cusrDisplayName,
538
+								         phoneNumber: phoneNmbr,
539
+								         daysOfWeek: slctddmDays,
540
+								         dailyStart: hrmnStartComp,
541
+								         dailyEnd: hrmnEndComp,
542
+								         vacationStart: vcStartDate,
543
+								         vacationEnd: vcEndDate,
544
+								         messageText: arplText
545
+								    };
546
+
547
+								    $.ajax({
548
+								      method: 'PUT',
549
+								      url: saveArplUrl + '/' + userid,
550
+								      contentType: 'application/json',
551
+								      data: JSON.stringify(arpldata),
552
+								      success: function(messagereceived) {
553
+
554
+								                   if (messagereceived == 'success') {
555
+								                       showAlert('The auto-reply has been successfully saved to the database!');
556
+								                   } else if (messagereceived == 'failure') {
557
+								                       showAlert('Error while trying to save the auto-reply!');
558
+								                   } else if (messagereceived == 'not allowed') {
559
+				                                                       showAlert('You cannot change an auto-reply that was saved by a different user.');
560
+				                                                   }
561
+								      },
562
+								      error: function() {
563
+										   showAlert('Error while attempting to save the auto-reply! You can check the Nextcloud log to find more details about this issue.');
564
+								      }
565
+								    });
566
+
567
+
568
+				                                } else { showAlert("Please select the auto-reply mode."); return; }
569
+
570
+				                              } else { showAlert("Please enter the text of the auto-reply."); return; }
571
+
572
+				                            } else { showAlert("Please select a phone number if at least one number is available in the 'Phone Number' drop-down list. Otherwise, you should contact the administrator."); return; }
573
+
574
+				                            $(this).attr("value", "Edit");
575
+
576
+				                        } else {
577
+				                            $("#arplsave-"+ crntrwnmbr).attr("value", "Save");
578
+				                        }
579
+
580
+				                     });
581
+
582
+						  }
583
+				                  saveArplRow();
584
+
585
+
586
+						  // Remove a row
587
+						  function removeArplRow() {
588
+						       $('[id^="rmRow-"]').click(function() {
589
+
590
+							  var slctRowRm = $(this).attr("id").replace("rmRow-", "");
591
+							  var crntPhnNmbr = $("#arpphn-"+ slctRowRm).val();
592
+
593
+							  confirmAlert("Do you really want to remove this row from the database ?");
594
+
595
+							  $("#confirmCancel").click(function() { $("#alertMsgOverlay").remove(); $("#alertConfMessage").remove(); });
596
+
597
+							  $("#confirmOk").click(function() {
598
+
599
+							      $("#alertMsgOverlay").remove();
600
+							      $("#alertConfMessage").remove();
601
+
602
+							      var rmvArplUrl = OC.generateUrl('/apps/sms_relentless/user/removeautoreplies');
603
+							      $.ajax({
604
+								   url: rmvArplUrl + '/' + userid,
605
+								   method: "POST",
606
+								   dataType: "text",
607
+								   data: { phoneNumber: crntPhnNmbr },
608
+								   success: function(delresult) {
609
+
610
+										     if (delresult.indexOf("success") > -1) {
611
+										         showAlert("The auto-reply has been removed successfully!");
612
+										         $("#arpphn-"+ slctRowRm).closest("tr").remove();
613
+										     } else if (delresult.indexOf("failure") > -1) {
614
+										         showAlert("Error while trying to remove auto-reply data!");
615
+										     } else if (delresult.indexOf("not allowed") > -1) {
616
+				                                                         showAlert("You cannot remove the auto-reply saved by another user.");
617
+				                                                     }
618
+								   },
619
+								   error: function() { showAlert("Error while attempting to remove auto-reply data! You can check the Nextcloud log to find more details about this issue."); }
620
+							       });
621
+							  });
622
+						       });
623
+						  }
624
+						  removeArplRow();
625
+
626
+				                  // Add a new row
627
+				                  $("#addArplRow").click(function() {
628
+
629
+				                     if ($("#autoReplyTbl").find("tr:last-child").find(".arplPhoneNmbr").length > 0) {
630
+				                         var lastarpl = $("#autoReplyTbl").find("tr:last-child").find(".arplPhoneNmbr").attr("id").replace("arpphn-", "");
631
+				                         var indArplAdd = parseInt(lastarpl + 1);
632
+				                     } else { var indArplAdd = 0; }
633
+						     $("#autoReplyTbl").append("<tr><td><input type='text' class='arplAuthor' value='"+ cusrDisplayName +"' disabled></td><td><select id='arpphn-"+ indArplAdd +"' class='arplPhoneNmbr'>"+ numbersListItems +"</select></td><td><div id='arplmode-"+ indArplAdd +"' class='arplMode'><select id='modeselect-"+ indArplAdd +"' class='selectArplMode'><option value='' selected>Select mode</option><option value='daily'>Daily mode</option><option value='vacation'>Vacation mode</option></select><div id='modecont-"+ indArplAdd +"' class='modeContent'></div></div></td><td><textarea id='arpltxt-"+ indArplAdd +"' class='arplText' rows='20' cols='40' placeholder='Enter the auto-reply message here.'></textarea></td><td><img id='rmRow-"+ indArplAdd +"' class='removeRow' src='/" + ctappdir + "/sms_relentless/img/closewnd.svg' title='Remove this row from the database' style='cursor:pointer;margin:9px 8px 0px 18px;'></td><td><input type='submit' id='arplsave-"+ indArplAdd +"' class='saveAutoReply' value='Save' title='Save Row' /></td></tr>");
634
+
635
+				                     selectMode();
636
+				                     saveArplRow();
637
+				                     removeArplRow();
638
+
639
+						     // Check if there is an auto-reply set for the same phone number
640
+						     $("#arpphn-"+ indArplAdd).change(function() {
641
+							 var selectedPhNb = $("#arpphn-"+ indArplAdd).val();
642
+							 var allArplPhNmbrs = $("#autoReplyTbl").find("tr").find(".arplPhoneNmbr");
643
+							 var phNbChck = 0;
644
+							 allArplPhNmbrs.each(function() {
645
+							    var slctphnb = ($(this).val())? $(this).val() : $(this).text();
646
+							    if (selectedPhNb == slctphnb) { phNbChck++; }
647
+							 });
648
+
649
+							 if (phNbChck == 2) {
650
+							     showAlert("There is already an auto-reply set up for this phone number. Please edit its own row, or choose a different phone number.");
651
+							     $(this).val('');
652
+							     return;
653
+							 }
654
+						     });
655
+				                  });
656
+
657
+				  },
658
+				  error: function() {
659
+				                    $("#autoRplPhoneNb").removeClass('icon-loading'); 
660
+				                    showAlert("Error while attempting to get the auto-reply settings! You can check the Nextcloud log to find more details about this issue.");
661
+				  }
662
+			 });
663
+
664
+		     },
665
+		     error: function() {
666
+				  showAlert('Error while getting the settings! You can check the Nextcloud log to find more details about this issue.');
667
+		     }
668
+		  });
669
+
670
+
671
+
672
+		  // Save personal settings for non-admin users
673
+		  $("#save_sms_settings").on("click", function(event) {
674
+
675
+		     if (isadm == 'reguser') {
676
+
677
+			    event.preventDefault();
678
+			    var baseUrlsave = OC.generateUrl('/apps/sms_relentless/user/updatesettings');
679
+
680
+			    var messagesperpageinit = $("#messagesperpage").val();
681
+			    var messagesperpagesec = messagesperpageinit.replace(/[^0-9]/g, '');
682
+			    var messagesperpageproc = 100;
683
+
684
+			    if (messagesperpagesec != '') {
685
+				if (messagesperpagesec > 0 && messagesperpagesec < 4294967296) {
686
+				    messagesperpageproc = messagesperpagesec;
687
+				} else { alert("The field 'Number of messages per page' must contain a number between 1 and 4294967295."); return; }
688
+			    }
689
+
690
+                            var archconvnmbrinit = $("#archivedconvnmbr").val();
691
+                            var archconvnmbrsec = archconvnmbrinit.replace(/[^0-9]/g, '');
692
+                            var archConvNmbr = null;
693
+
694
+			    if (archconvnmbrsec != '') {
695
+				if (archconvnmbrsec >= 0 && archconvnmbrsec <= 4294967295) {
696
+				    archConvNmbr = archconvnmbrsec;
697
+				} else { alert("The field 'Number of archived conversations to display' must contain a number between 0 and 4294967295."); return; }
698
+			    }
699
+
700
+			    var msgcheckintervalinit = $("#msgcheckinterval").val();
701
+			    var msgcheckintervalsec = msgcheckintervalinit.replace(/[^0-9]/g, '');
702
+			    var msgsCheckInterval = 5;
703
+
704
+			    if (msgcheckintervalsec != '') {
705
+				if (msgcheckintervalsec > 0 && msgcheckintervalsec < 86401) {
706
+				    msgsCheckInterval = msgcheckintervalsec;
707
+				} else { alert("The field 'Time interval in seconds before checking if a new message has arrived' must contain a number between 1 and 86400."); return; }
708
+			    }
709
+
710
+			    var getnotify = 0;
711
+
712
+			    if ($("#get_notify").is(':checked')) {
713
+				getnotify = 1;
714
+			    }
715
+
716
+			    var emailaddressinit = $("#notification_email").val();
717
+
718
+			    function validate_email($email) {
719
+				var email_reg = /^([\w-\.]+@([\w-]+\.)+[\w-]{2,4})?$/;
720
+				return email_reg.test($email);
721
+			    }
722
+
723
+			    if (validate_email(emailaddressinit)) {
724
+				 var notifyemail = emailaddressinit;
725
+			    } else {
726
+				 var notifyemail = '';
727
+			    }
728
+
729
+			    var includesmsinemail = 0;
730
+			    if ($("#includesmsinemail").is(':checked')) {
731
+				includesmsinemail = 1;
732
+				if ($("#notification_email").val().trim() == '') {
733
+				    showAlert("Please enter an email address in the field: 'I want to receive a notification to the email address from below ...', or uncheck the checkbox: 'Include the SMS/MMS message in the email notification itself'.");
734
+				    return;
735
+				}
736
+			    }
737
+
738
+			    var showdisplaynm = 0;
739
+			    if ($("#showdisplaynames").is(':checked')) {
740
+				showdisplaynm = 1;
741
+			    }
742
+
743
+			    var adddisplaynm = 0;
744
+			    if ($("#adddisplaynames").is(':checked')) {
745
+				adddisplaynm = 1;
746
+			    }
747
+
748
+			    var datatosave = {
749
+					      userId: userid,
750
+					      telapiUrlRec: $("#telapi_url_rec").val(),
751
+					      telapiUrl: $("#telapi_url").val(),
752
+					      nexapiUrlRec: $("#nexapi_url_rec").val(),
753
+					      nexapiUrl: $("#nexapi_url").val(),
754
+					      twilapiUrlRec: $("#twilapi_url_rec").val(),
755
+					      twilapiUrl: $("#twilapi_url").val(),
756
+					      flowapiUrlRec: $("#flowapi_url_rec").val(),
757
+					      flowapiUrl: $("#flowapi_url").val(),
758
+					      messagesperpage: messagesperpageproc,
759
+                                              archivedConvNmbr: archConvNmbr,
760
+		 	                      msgCheckInterval: msgsCheckInterval,
761
+					      getNotify: getnotify,
762
+					      notificationEmail: notifyemail,
763
+					      getsmsinemail: includesmsinemail,
764
+					      showDisplayNames: showdisplaynm,
765
+				              addDisplayNames: adddisplaynm
766
+			    };
767
+
768
+
769
+			    $.ajax({
770
+			       method: 'PUT',
771
+			       url: baseUrlsave + '/' + userid,
772
+			       contentType: 'application/json',
773
+			       data: JSON.stringify(datatosave),
774
+			       success: function() {
775
+				               OC.msg.startAction('#smsr_save_msg', t('sms_relentless', 'Saved'));
776
+			       },
777
+			       error: function() {
778
+				    showAlert('Error while attempting to save the settings! You can check the Nextcloud log to find more details about this issue.');
779
+			       }
780
+			    });
781
+
782
+
783
+		     } else if (isadm == 'admin') {
784
+
785
+			    // Save personal settings for admins
786
+			    event.preventDefault();
787
+			    var baseUrlsaveadm = OC.generateUrl('/apps/sms_relentless/user/updatepersadmnsettings');
788
+
789
+			    var messagesperpageinit = $("#messagesperpage").val();
790
+			    var messagesperpagesec = messagesperpageinit.replace(/[^0-9]/g, '');
791
+			    var messagesperpageproc = 100;
792
+
793
+			    if (messagesperpagesec != '') {
794
+				if (messagesperpagesec > 0 && messagesperpagesec < 4294967296) {
795
+				    messagesperpageproc = messagesperpagesec;
796
+				} else { alert("The field 'Number of messages per page' must contain a number between 1 and 4294967295."); return; }
797
+			    }
798
+
799
+                            var archconvnmbrinit = $("#archivedconvnmbr").val();
800
+                            var archconvnmbrsec = archconvnmbrinit.replace(/[^0-9]/g, '');
801
+                            var archConvNmbr = null;
802
+
803
+			    if (archconvnmbrsec != '') {
804
+				if (archconvnmbrsec >= 0 && archconvnmbrsec <= 4294967295) {
805
+				    archConvNmbr = archconvnmbrsec;
806
+				} else { alert("The field 'Number of archived conversations to display' must contain a number between 0 and 4294967295."); return; }
807
+			    }
808
+
809
+			    var msgcheckintervalinit = $("#msgcheckinterval").val();
810
+			    var msgcheckintervalsec = msgcheckintervalinit.replace(/[^0-9]/g, '');
811
+			    var msgsCheckInterval = 5;
812
+
813
+			    if (msgcheckintervalsec != '') {
814
+				if (msgcheckintervalsec > 0 && msgcheckintervalsec < 86401) {
815
+				    msgsCheckInterval = msgcheckintervalsec;
816
+				} else { alert("The field 'Time interval in seconds before checking if a new message has arrived' must contain a number between 1 and 86400."); return; }
817
+			    }
818
+
819
+			    var getnotify = 0;
820
+
821
+			    if ($("#get_notify").is(':checked')) {
822
+				getnotify = 1;
823
+			    }
824
+
825
+			    var emailaddressinit = $("#notification_email").val();
826
+
827
+			    function validate_email($email) {
828
+				var email_reg = /^([\w-\.]+@([\w-]+\.)+[\w-]{2,4})?$/;
829
+				return email_reg.test($email);
830
+			    }
831
+
832
+			    if (validate_email(emailaddressinit)) {
833
+				 var notifyemail = emailaddressinit;
834
+			    } else {
835
+				 var notifyemail = '';
836
+			    }
837
+
838
+			    var includesmsinemail = 0;
839
+			    if ($("#includesmsinemail").is(':checked')) {
840
+				includesmsinemail = 1;
841
+				if ($("#notification_email").val().trim() == '') {
842
+				    showAlert("Please enter an email address in the field: 'I want to receive a notification to the email address from below ...', or uncheck the checkbox: 'Include the SMS/MMS message in the email notification itself'.");
843
+				    return;
844
+				}
845
+			    }
846
+
847
+			    var showdisplaynm = 0;
848
+			    if ($("#showdisplaynames").is(':checked')) {
849
+				showdisplaynm = 1;
850
+			    }
851
+
852
+			    var adddisplaynm = 0;
853
+			    if ($("#adddisplaynames").is(':checked')) {
854
+				adddisplaynm = 1;
855
+			    }
856
+
857
+			    var datatosave = {
858
+					      userId: userid,
859
+					      messagesperpage: messagesperpageproc,
860
+                                              archivedConvNmbr: archConvNmbr,
861
+					      msgCheckInterval: msgsCheckInterval,
862
+					      getNotify: getnotify,
863
+					      notificationEmail: notifyemail,
864
+					      getsmsinemail: includesmsinemail,
865
+					      showDisplayNames: showdisplaynm,
866
+				              addDisplayNames: adddisplaynm
867
+			    };
868
+
869
+
870
+			    $.ajax({
871
+			       method: 'PUT',
872
+			       url: baseUrlsaveadm + '/' + userid,
873
+			       contentType: 'application/json',
874
+			       data: JSON.stringify(datatosave),
875
+			       success: function() {
876
+				               OC.msg.startAction('#smsr_save_msg', t('sms_relentless', 'Saved'));
877
+			       },
878
+			       error: function() {
879
+				    showAlert('Error while attempting to save the settings! You can check the Nextcloud log to find more details about this issue.');
880
+			       }
881
+			    });
882
+
883
+		     }
884
+		  });
885
+
886
+		  function showAlert(alertText) {
887
+
888
+		     let alertwnd = "<div id='alertMessage'>";
889
+		     alertwnd += "<a id='closeAlertWnd' title='Close this window'></a>";
890
+		     alertwnd += "<div id='alertTextWrap'>"+ alertText +"</div>";
891
+		     alertwnd += "<input type='submit' id='alertOk' value='OK'>";
892
+		     alertwnd += "</div>";
893
+
894
+		     $("#content").append("<div id='alertMsgOverlay'></div>");
895
+		     $("#content").append(alertwnd);
896
+
897
+		     let topDist = parseInt((window.innerHeight / 2).toFixed(2) - 152) +"px";
898
+		     let leftDist = parseInt((window.innerWidth / 2).toFixed(2) - 150) +"px";
899
+		     $("#alertMessage").css({ "top" : topDist, "left" : leftDist });
900
+
901
+		     $("#closeAlertWnd").click(function() { $("#alertMsgOverlay").remove(); $("#alertMessage").remove(); });
902
+		     $("#alertMsgOverlay").click(function() { $("#alertMsgOverlay").remove(); $("#alertMessage").remove(); });
903
+		     $("#alertOk").click(function() { $("#alertMsgOverlay").remove(); $("#alertMessage").remove(); });
904
+		  }
905
+
906
+		  function confirmAlert(alertText) {
907
+
908
+		     $("#alertMsgOverlay").remove();
909
+		     $("#alertConfMessage").remove();
910
+
911
+		     let alertwndcf = "<div id='alertConfMessage'>";
912
+		     alertwndcf += "<a id='closeAlertWndcf' title='Close this window'></a>";
913
+		     alertwndcf += "<div id='alertTextWrap'>"+ alertText +"</div>";
914
+		     alertwndcf += "<div id='cancelOkWrap'><input type='submit' id='confirmCancel' value='Cancel'>";
915
+		     alertwndcf += "<input type='submit' id='confirmOk' value='OK'></div>";
916
+		     alertwndcf += "</div>";
917
+
918
+		     $("#content").append("<div id='alertMsgOverlay'></div>");
919
+		     $("#content").append(alertwndcf);
920
+
921
+		     let topDist = parseInt((window.innerHeight / 2).toFixed(2) - 152) +"px";
922
+		     let leftDist = parseInt((window.innerWidth / 2).toFixed(2) - 150) +"px";
923
+		     $("#alertConfMessage").css({ "top" : topDist, "left" : leftDist });
924
+
925
+		     $("#closeAlertWndcf").click(function() { $("#alertMsgOverlay").remove(); $("#alertConfMessage").remove(); });
926
+		     $("#alertMsgOverlay").click(function() { $("#alertMsgOverlay").remove(); $("#alertConfMessage").remove(); });
927
+		  }
928
+
929
+
930
+     },
931
+     error: function(appdirfdb) {
932
+                alert("An error occurred while getting the app's directory. You can check the Nextcloud log to find more details about this issue.");
933
+     }
934
+   });
935
+
936
+});
Browse code

removed appinfo/info.xml appinfo/signature.json appinfo/routes.php CHANGELOG.txt README.md css/style.css js/showsmstables.js js/settings.js js/sendsms.js lib/Controller/AuthorApiController.php lib/Controller/SmsrelentlessController.php lib/Service/SmsrelentlessService.php templates/navigation/index.php templates/settings/personal.php img/arrow-top.svg

DoubleBastionAdmin authored on 02/04/2024 00:07:07
Showing 1 changed files
1 1
deleted file mode 100644
... ...
@@ -1,911 +0,0 @@
1
-/**
2
- * @copyright 2021 Double Bastion LLC <www.doublebastion.com>
3
- *
4
- * @author Double Bastion LLC
5
- *
6
- * @license GNU AGPL version 3 or any later version
7
- *
8
- * This program is free software; you can redistribute it and/or
9
- * modify it under the terms of the GNU AFFERO GENERAL PUBLIC LICENSE
10
- * License as published by the Free Software Foundation; either
11
- * version 3 of the License, or any later version.
12
- *
13
- * This program is distributed in the hope that it will be useful,
14
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
15
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
16
- * GNU AFFERO GENERAL PUBLIC LICENSE for more details.
17
- *
18
- * You should have received a copy of the GNU Affero General Public
19
- * License along with this program.  If not, see <http://www.gnu.org/licenses/>.
20
- *
21
- */
22
-
23
-$(document).ready(function() {
24
-
25
-  var userid = "<?php p($userId); ?>";
26
-  var isadm = '';
27
-  var ctappdir = 'apps';
28
-
29
-  // Get app directory
30
-  var getappdirurl = OC.generateUrl('/apps/sms_relentless/user/getappdirectory');
31
-
32
-  $.ajax({
33
-     method: 'GET',
34
-     url: getappdirurl + '/' + userid,
35
-     contentType: 'application/json',
36
-     success: function(appdirfdb) {
37
-
38
-                  ctappdir = appdirfdb;
39
-
40
-		  // Get personal settings
41
-		  var baseUrlget = OC.generateUrl('/apps/sms_relentless/user/getsettings');
42
-
43
-		  $.ajax({
44
-		     method: 'GET',
45
-		     url: baseUrlget + '/' + userid,
46
-		     contentType: 'application/json',
47
-		     success: function(settingsfromdb) {
48
-
49
-			 // Add the webhook URLs section, if the user is not an admin
50
-			 if (settingsfromdb.adminornot == 'reguser') {
51
-
52
-			     isadm = 'reguser';
53
-
54
-			     $("#appTitlePrg").append('<p id="settings-dscr"><h3>Enter your options in the fields from below. As a non-admin user, you can use any of the SMS service providers from \
55
-				  below (Telnyx/Plivo/Twilio/Flowroute), on the condition that an admin has shared with you his API keys for that provider. If an admin has shared with you his API \
56
-				  keys for a provider, to be able to use them properly, you will have to generate the two webhook URLs for that provider by clicking the corresponding \
57
-				  "Generate new webhook URL ..." buttons from below, then click "Save" at the bottom of this page:</h3></p><br>');
58
-
59
-			     $("#nadmProvSection").append('<div class="providerSettings"><p><label for="telapi_url_rec" class="setlabeltext"><b>Telnyx webhook URL for incoming SMS/MMS</b> (Generate \
60
-				  the URL by pressing the button from below. Don\'t forget to also click the \'Save\' button at the bottom of this page after entering all the options, to save \
61
-				  all the settings to the database.)</label></p> \
62
-				  <input type="button" id="generate_tel_rcpt" class="generateUrl" value="Generate new webhook URL for incoming SMS/MMS" /> \
63
-				  <input type="text" class="smsr_textboxspec" id="telapi_url_rec" name="telapi_url_rec" autocomplete="false" /> \
64
-				  <span id="copyToClipboardtel" class="icon icon-clippy" title="Copy to clipboard"></span><br><br> \
65
-				  \
66
-				  <p><label for="telapi_url" class="setlabeltext"><b>Telnyx webhook URL for delivery receipts</b> (This URL will be included by SMS Relentless in message sending \
67
-				  requests, so that Telnyx will know where to send the delivery receipts. Just generate it by pressing the button from below. Don\'t forget to click the \'Save\' \
68
-				  button at the bottom of this page after entering all the options, to save all the settings to the database.)</label></p> \
69
-				  <input type="button" id="generate_tel_delrcpt" class="generateUrl" value="Generate new webhook URL for delivery receipts" /> \
70
-				  <input type="text" id="telapi_url" name="telapi_url" autocomplete="false" /></div><br><br> \
71
-				  \
72
-				  <div class="providerSettings"><p><label for="nexapi_url_rec" class="setlabeltext"><b>Plivo webhook URL for incoming SMS/MMS</b> (Generate the URL by pressing \
73
-				  the button from below. Don\'t forget to also click the \'Save\' button at the bottom of this page after entering all the options, to save all the settings \
74
-				  to the database.)</label></p> \
75
-				  <input type="button" id="generate_nex_rcpt" class="generateUrl" value="Generate new webhook URL for incoming SMS/MMS" /> \
76
-				  <input type="text" class="smsr_textboxspec" id="nexapi_url_rec" name="nexapi_url_rec" autocomplete="false" /> \
77
-				  <span id="copyToClipboardnex" class="icon icon-clippy" title="Copy to clipboard"></span><br><br> \
78
-				  \
79
-				  <p><label for="nexapi_url" class="setlabeltext"><b>Plivo webhook URL for delivery receipts</b> (This URL will be included by SMS Relentless in message sending \
80
-				  requests, so that Plivo will know where to send the delivery receipts. Just generate it by pressing the button from below. Don\'t forget to click the \'Save\' \
81
-				  button at the bottom of this page after entering all the options, to save all the settings to the database.)</label></p> \
82
-				  <input type="button" id="generate_nex_delrcpt" class="generateUrl" value="Generate new webhook URL for delivery receipts" /> \
83
-				  <input type="text" id="nexapi_url" name="nexapi_url" autocomplete="false" /></div><br><br> \
84
-				  \
85
-				  <div class="providerSettings"><p><label for="twilapi_url_rec" class="setlabeltext"><b>Twilio webhook URL for incoming SMS/MMS</b> (Generate the URL by pressing \
86
-				  the button from below. Don\'t forget to also click the \'Save\' button at the bottom of this page after entering all the options, to save all the settings to \
87
-				  the database.)</label></p> \
88
-				  <input type="button" id="generate_twil_rcpt" class="generateUrl" value="Generate new webhook URL for incoming SMS/MMS" /> \
89
-				  <input type="text" class="smsr_textboxspec" id="twilapi_url_rec" name="twilapi_url_rec" autocomplete="false" /> \
90
-				  <span id="copyToClipboardtwil" class="icon icon-clippy" title="Copy to clipboard"></span><br><br> \
91
-				  \
92
-				  <p><label for="twilapi_url" class="setlabeltext"><b>Twilio webhook URL for delivery receipts</b> (This URL will be included by SMS Relentless in message sending \
93
-				  requests, so that Twilio will know where to send the delivery receipts. Just generate it by pressing the button from below. Don\'t forget to click the \'Save\' \
94
-				  button at the bottom of this page after entering all the options, to save all the settings to the database.)</label></p> \
95
-				  <input type="button" id="generate_twil_delrcpt" class="generateUrl" value="Generate new webhook URL for delivery receipts" /> \
96
-				  <input type="text" id="twilapi_url" name="twilapi_url" autocomplete="false" /></div><br><br> \
97
-				  \
98
-				  <div class="providerSettings"><p><label for="flowapi_url_rec" class="setlabeltext"><b>Flowroute webhook URL for incoming SMS/MMS</b> (Generate the URL by pressing \
99
-				  the button from below. Don\'t forget to also click the \'Save\' button at the bottom of this page after entering all the options, to save all the settings to \
100
-				  the database.)</label></p> \
101
-				  <input type="button" id="generate_flow_rcpt" class="generateUrl" value="Generate new webhook URL for incoming SMS/MMS" /> \
102
-				  <input type="text" class="smsr_textboxspec" id="flowapi_url_rec" name="flowapi_url_rec" autocomplete="false" /> \
103
-				  <span id="copyToClipboardflow" class="icon icon-clippy" title="Copy to clipboard"></span><br><br> \
104
-				  \
105
-				  <p><label for="flowapi_url" class="setlabeltext"><b>Flowroute webhook URL for delivery receipts</b> (This URL will be included by SMS Relentless in message sending \
106
-				  requests, so that Flowroute will know where to send the delivery receipts. Just generate it by pressing the button from below. Don\'t forget to click the \'Save\' \
107
-				  button at the bottom of this page after entering all the options, to save all the settings to the database.)</label></p> \
108
-				  <input type="button" id="generate_flow_delrcpt" class="generateUrl" value="Generate new webhook URL for delivery receipts" /> \
109
-				  <input type="text" id="flowapi_url" name="flowapi_url" autocomplete="false" /><br><br> \
110
-				  Flowroute only supports sending/receiving SMS/MMS messages within USA and Canada and it doesn\'t support Alphanumeric Sender IDs.</div><br>');
111
-
112
-
113
-				  $("#telapi_url_rec").val(settingsfromdb.telapi_url_rec);
114
-				  $("#telapi_url").val(settingsfromdb.telapi_url);
115
-				  $("#nexapi_url_rec").val(settingsfromdb.nexapi_url_rec);
116
-				  $("#nexapi_url").val(settingsfromdb.nexapi_url);
117
-				  $("#twilapi_url_rec").val(settingsfromdb.twilapi_url_rec);
118
-				  $("#twilapi_url").val(settingsfromdb.twilapi_url);
119
-				  $("#flowapi_url_rec").val(settingsfromdb.flowapi_url_rec);
120
-				  $("#flowapi_url").val(settingsfromdb.flowapi_url);
121
-				  $("#messagesperpage").val(settingsfromdb.messagesperpage);
122
-				  $("#msgcheckinterval").val(settingsfromdb.msg_check_interval);
123
-
124
-				  if (settingsfromdb.get_notify == 1) {
125
-				      $("#get_notify").attr('checked', true);
126
-				  } else {
127
-				      $("#get_notify").attr('checked', false);
128
-				  }
129
-
130
-				  $("#notification_email").val(settingsfromdb.notification_email);
131
-
132
-				  if (settingsfromdb.getsmsinemail == 1) {
133
-				      $("#includesmsinemail").attr('checked', true);
134
-				  } else {
135
-				      $("#includesmsinemail").attr('checked', false);
136
-				  }
137
-
138
-				  if (settingsfromdb.show_display_names == 1) {
139
-				      $("#showdisplaynames").attr('checked', true);
140
-				  } else {
141
-				      $("#showdisplaynames").attr('checked', false);
142
-				  }
143
-
144
-				  if (settingsfromdb.add_display_names == 1) {
145
-				      $("#adddisplaynames").attr('checked', true);
146
-				  } else {
147
-				      $("#adddisplaynames").attr('checked', false);
148
-				  }
149
-
150
-				  function randomStr(strlength) {
151
-					var fintext = "";
152
-					var keyspace = '0123456789abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ';
153
-					for (var i = 0; i < strlength; i++) {
154
-					     fintext += keyspace.charAt(Math.floor(Math.random() * keyspace.length));
155
-					}
156
-					return fintext;
157
-				  }
158
-
159
-				  $("#generate_tel_rcpt").on("click", function(event) {
160
-
161
-				     var teltokenrec = randomStr(70);
162
-				     var telnyxwhurlrec = window.location.origin + OC.generateUrl('/apps/sms_relentless/api/recsmstel?telrecparam=') + teltokenrec;
163
-
164
-				     $("#telapi_url_rec").val(telnyxwhurlrec);
165
-				  });
166
-
167
-				  $("#copyToClipboardtel").on("click", function(event) {
168
-				     var $tempEl = $("<input>");
169
-				     $("body").append($tempEl);
170
-				     $tempEl.val($("#telapi_url_rec").val()).select();
171
-				     document.execCommand("Copy");
172
-				     $tempEl.remove();
173
-				     showAlert("The link has been copied to your clipboard!");
174
-				  });
175
-
176
-				  $("#generate_tel_delrcpt").on("click", function(event) {
177
-
178
-				     var teltoken = randomStr(70);
179
-				     var telnyxwhurl = window.location.origin + OC.generateUrl('/apps/sms_relentless/api/recdeliverytel?teldrparam=') + teltoken;
180
-
181
-				     $("#telapi_url").val(telnyxwhurl);
182
-				  });
183
-
184
-
185
-				  $("#generate_nex_rcpt").on("click", function(event) {
186
-
187
-				     var plivotokenrec = randomStr(70);
188
-				     var plivowhurlrec = window.location.origin + OC.generateUrl('/apps/sms_relentless/api/recsmsnex?plivorecparam=') + plivotokenrec;
189
-
190
-				     $("#nexapi_url_rec").val(plivowhurlrec);
191
-				  });
192
-
193
-				  $("#copyToClipboardnex").on("click", function(event) {
194
-				     var $tempElpl = $("<input>");
195
-				     $("body").append($tempElpl);
196
-				     $tempElpl.val($("#nexapi_url_rec").val()).select();
197
-				     document.execCommand("Copy");
198
-				     $tempElpl.remove();
199
-				     showAlert("The link has been copied to your clipboard!");
200
-				  });
201
-
202
-				  $("#generate_nex_delrcpt").on("click", function(event) {
203
-
204
-				     var plivotoken = randomStr(70);
205
-				     var plivodrwhurl = window.location.origin + OC.generateUrl('/apps/sms_relentless/api/recdeliverynex?plivodrparam=') + plivotoken;
206
-
207
-				     $("#nexapi_url").val(plivodrwhurl);
208
-				  });
209
-
210
-
211
-				  $("#generate_twil_rcpt").on("click", function(event) {
212
-
213
-				     var twiltokenrec = randomStr(35);
214
-				     var twilwhurlrec = window.location.origin + OC.generateUrl('/apps/sms_relentless/api/recsmstwil?twilrecparam=') + twiltokenrec;
215
-
216
-				     $("#twilapi_url_rec").val(twilwhurlrec);
217
-				  });
218
-
219
-				  $("#copyToClipboardtwil").on("click", function(event) {
220
-				     var $tempElpl = $("<input>");
221
-				     $("body").append($tempElpl);
222
-				     $tempElpl.val($("#twilapi_url_rec").val()).select();
223
-				     document.execCommand("Copy");
224
-				     $tempElpl.remove();
225
-				     showAlert("The link has been copied to your clipboard!");
226
-				  });
227
-
228
-				  $("#generate_twil_delrcpt").on("click", function(event) {
229
-
230
-				     var twiltoken = randomStr(35);
231
-				     var twildrwhurl = window.location.origin + OC.generateUrl('/apps/sms_relentless/api/recdeliverytwil?twildrparam=') + twiltoken;
232
-
233
-				     $("#twilapi_url").val(twildrwhurl);
234
-				  });
235
-
236
-
237
-				  $("#generate_flow_rcpt").on("click", function(event) {
238
-
239
-				     var flowtokenrec = randomStr(70);
240
-				     var flowwhurlrec = window.location.origin + OC.generateUrl('/apps/sms_relentless/api/recsmsflow?flowrecparam=') + flowtokenrec;
241
-
242
-				     $("#flowapi_url_rec").val(flowwhurlrec);
243
-				  });
244
-
245
-				  $("#copyToClipboardflow").on("click", function(event) {
246
-				     var $tempElpl = $("<input>");
247
-				     $("body").append($tempElpl);
248
-				     $tempElpl.val($("#flowapi_url_rec").val()).select();
249
-				     document.execCommand("Copy");
250
-				     $tempElpl.remove();
251
-				     showAlert("The link has been copied to your clipboard!");
252
-				  });
253
-
254
-				  $("#generate_flow_delrcpt").on("click", function(event) {
255
-
256
-				     var flowtoken = randomStr(70);
257
-				     var flowdrwhurl = window.location.origin + OC.generateUrl('/apps/sms_relentless/api/recdeliveryflow?flowdrparam=') + flowtoken;
258
-
259
-				     $("#flowapi_url").val(flowdrwhurl);
260
-				  });
261
-
262
-
263
-			 } else if (settingsfromdb.adminornot == 'admin') {
264
-
265
-				  $("#appTitlePrg").append('<p id="settings-dscr"><h3>First enter your credentials on the admin settings page of the app (on the left panel, under Administration, \
266
-				                            click on SMS Relentless), then enter your options in the fields from below:</h3></p><br>');
267
-				  isadm = 'admin';
268
-
269
-				  $("#messagesperpage").val(settingsfromdb.messagesperpage);
270
-				  $("#msgcheckinterval").val(settingsfromdb.msg_check_interval);
271
-
272
-				  if (settingsfromdb.get_notify == 1) {
273
-				      $("#get_notify").attr('checked', true);
274
-				  } else {
275
-				      $("#get_notify").attr('checked', false);
276
-				  }
277
-
278
-				  $("#notification_email").val(settingsfromdb.notification_email);
279
-
280
-				  if (settingsfromdb.getsmsinemail == 1) {
281
-				      $("#includesmsinemail").attr('checked', true);
282
-				  } else {
283
-				      $("#includesmsinemail").attr('checked', false);
284
-				  }
285
-
286
-				  if (settingsfromdb.show_display_names == 1) {
287
-				      $("#showdisplaynames").attr('checked', true);
288
-				  } else {
289
-				      $("#showdisplaynames").attr('checked', false);
290
-				  }
291
-
292
-				  if (settingsfromdb.add_display_names == 1) {
293
-				      $("#adddisplaynames").attr('checked', true);
294
-				  } else {
295
-				      $("#adddisplaynames").attr('checked', false);
296
-				  }
297
-			 }
298
-
299
-
300
-			 // Auto-reply settings
301
-
302
-			 // Get the available phone numbers from all providers associated with the access keys entered on the Settings page (restrictions are applied to numbers for non-admins)
303
-			 $("#autoRplPhoneNb").addClass('icon-loading');
304
-			 var getnumbersUrl = OC.generateUrl("/apps/sms_relentless/user/getautoreplyconf");
305
-
306
-			 $.ajax({
307
-				  url: getnumbersUrl + '/' + userid,
308
-				  type: "GET",
309
-				  contentType: 'application/json',
310
-				  success: function(autoreplydata) {
311
-
312
-				                    $("#autoRplPhoneNb").removeClass('icon-loading');
313
-				                    var cusrDisplayName = autoreplydata.userdisplayname;
314
-				                    var availPhoneNmbrs = autoreplydata.phonenumbers;
315
-				                    var autorpldata = autoreplydata.autoreplies;
316
-
317
-						    if (autorpldata.length > 0) { 
318
-							var arplNmb = autorpldata.length;
319
-						    } else { 
320
-							var arplNmb = 0; 
321
-						    }
322
-
323
-						    // List the auto-replies for the phone numbers available for the current user
324
-						    if (arplNmb == 0) {
325
-
326
-							$("#autoReplyTbl").append("<tr><td><input type='text' class='arplAuthor' value='"+ cusrDisplayName +"' disabled></td><td><select id='arpphn-"+ arplNmb +"' class='arplPhoneNmbr'></select></td><td><div id='arplmode-"+ arplNmb +"' class='arplMode'><select id='modeselect-"+ arplNmb +"' class='selectArplMode'><option value='' selected>Select mode</option><option value='daily'>Daily mode</option><option value='vacation'>Vacation mode</option></select><div id='modecont-"+ arplNmb +"' class='modeContent'></div></div></td><td><textarea id='arpltxt-"+ arplNmb +"' class='arplText' rows='20' cols='40' placeholder='Enter the auto-reply message here.'></textarea></td><td><img id='rmRow-"+ arplNmb +"' class='removeRow' src='/" + ctappdir + "/sms_relentless/img/closewnd.svg' title='Remove this row from the database' style='cursor:pointer;margin:9px 8px 0px 18px;'></td><td><input type='submit' id='arplsave-"+ arplNmb +"' class='saveAutoReply' value='Save' title='Save Row' /></td></tr>");
327
-							$("#autoReplyTbl").append("<div><img id='addArplRow' src='/" + ctappdir + "/sms_relentless/img/add.svg' title='Add Row'></div>");
328
-
329
-						    } else {
330
-
331
-							for (k = 0; k < arplNmb; k++) {
332
-
333
-				                             if (autorpldata[k].days_of_week != '') {
334
-
335
-				                                 var slctdMode = "<option value=''>Select mode</option><option value='daily' selected>Daily mode</option><option value='vacation'>Vacation mode</option>";
336
-				                                 var dailyStartArr = autorpldata[k].daily_start.split(":");
337
-				                                 var dailyEndArr = autorpldata[k].daily_end.split(":");
338
-
339
-						                 var dlHrStartOptions = "";
340
-							         for (var hr = 0; hr < 24; hr++) {
341
-						                      if (dailyStartArr[0] != hr.toLocaleString('en-US', {minimumIntegerDigits: 2, useGrouping:false})) {
342
-							                  dlHrStartOptions += "<option value='"+ hr.toLocaleString('en-US', {minimumIntegerDigits: 2, useGrouping:false}) +"'>"+ hr.toLocaleString('en-US', {minimumIntegerDigits: 2, useGrouping:false}) +"</option>";
343
-						                      } else {
344
-							                  dlHrStartOptions += "<option value='"+ hr.toLocaleString('en-US', {minimumIntegerDigits: 2, useGrouping:false}) +"' selected>"+ hr.toLocaleString('en-US', {minimumIntegerDigits: 2, useGrouping:false}) +"</option>";
345
-						                      }
346
-							         }
347
-
348
-						                 var dlMnStartOptions = "";
349
-							         for (var mn = 0; mn < 60; mn++) {
350
-						                      if (dailyStartArr[1] != mn.toLocaleString('en-US', {minimumIntegerDigits: 2, useGrouping:false})) {
351
-							                  dlMnStartOptions += "<option value='"+ mn.toLocaleString('en-US', {minimumIntegerDigits: 2, useGrouping:false}) +"'>"+ mn.toLocaleString('en-US', {minimumIntegerDigits: 2, useGrouping:false}) +"</option>";
352
-						                      } else {
353
-							                  dlMnStartOptions += "<option value='"+ mn.toLocaleString('en-US', {minimumIntegerDigits: 2, useGrouping:false}) +"' selected>"+ mn.toLocaleString('en-US', {minimumIntegerDigits: 2, useGrouping:false}) +"</option>";
354
-						                      }
355
-							         }
356
-
357
-						                 var dlHrEndOptions = "";
358
-							         for (var hr = 0; hr < 24; hr++) {
359
-						                      if (dailyEndArr[0] != hr.toLocaleString('en-US', {minimumIntegerDigits: 2, useGrouping:false})) {
360
-							                  dlHrEndOptions += "<option value='"+ hr.toLocaleString('en-US', {minimumIntegerDigits: 2, useGrouping:false}) +"'>"+ hr.toLocaleString('en-US', {minimumIntegerDigits: 2, useGrouping:false}) +"</option>";
361
-						                      } else {
362
-							                  dlHrEndOptions += "<option value='"+ hr.toLocaleString('en-US', {minimumIntegerDigits: 2, useGrouping:false}) +"' selected>"+ hr.toLocaleString('en-US', {minimumIntegerDigits: 2, useGrouping:false}) +"</option>";
363
-						                      }
364
-							         }
365
-
366
-						                 var dlMnEndOptions = "";
367
-							         for (var mn = 0; mn < 60; mn++) {
368
-						                      if (dailyEndArr[1] != mn.toLocaleString('en-US', {minimumIntegerDigits: 2, useGrouping:false})) {
369
-							                  dlMnEndOptions += "<option value='"+ mn.toLocaleString('en-US', {minimumIntegerDigits: 2, useGrouping:false}) +"'>"+ mn.toLocaleString('en-US', {minimumIntegerDigits: 2, useGrouping:false}) +"</option>";
370
-						                      } else {
371
-							                  dlMnEndOptions += "<option value='"+ mn.toLocaleString('en-US', {minimumIntegerDigits: 2, useGrouping:false}) +"' selected>"+ mn.toLocaleString('en-US', {minimumIntegerDigits: 2, useGrouping:false}) +"</option>";
372
-						                      }
373
-							         }
374
-
375
-				                                 var modeContent = "<div class='daysOfWeek'>Days of the week:<div class='tooltipautoreply'><div id='infoautoreply'>i</div><div class='autorpltooltip'>Enter the order number of the days of the week in which the auto-reply will be sent. For example, to send the auto-reply every day from Monday to Friday outside the time interval specified below, enter 1,2,3,4,5 To send the auto-reply only Monday, Thursday and Friday enter 1,4,5 To send the auto-reply every day of the week enter 1,2,3,4,5,6,7 As an exception, if you want the auto-reply to be sent during an entire day, irrespective of the specified interval, add (full) after the number of that day. For example, if you want the auto-reply to be sent from Monday to Friday outside the interval specified below, and also during the entire days of Saturday and Sunday, enter 1,2,3,4,5,6(full),7(full)</div></div></div><input type='text' id='weekdays-"+ k +"' class='daysInWeek' value='"+ autorpldata[k].days_of_week +"'><div class='chooseTInterval'>Send auto-reply <span style='color:#ad0202'>outside</span> this interval:<div class='tooltipautoreplyst'><div id='infoautoreplyst'>i</div><div class='autorpltooltipst'>These fields specify the time of the server. If the server is located in a time zone that is different from that of the owner/company, the time interval entered here should be adjusted accordingly.</div></div></div><div class='selectArplHours'><select id='dmstarthr-"+ k +"' class='selectHrMin'>"+ dlHrStartOptions +"</select><select id='dmstartmn-"+ k +"' class='selectHrMin'>"+ dlMnStartOptions +"</select><span style='font-weight: 600'> — </span><select id='dmendhr-"+ k +"' class='selectHrMin'>"+ dlHrEndOptions +"</select><select id='dmendmn-"+ k +"' class='selectHrMin'>"+ dlMnEndOptions +"</select></div>";
376
-
377
-				                             } else {
378
-
379
-				                                 var vctnStart = autorpldata[k].vacation_start.split(" ")[0];
380
-				                                 var vctnEnd = autorpldata[k].vacation_end.split(" ")[0];
381
-
382
-				                                 var slctdMode = "<option value=''>Select mode</option><option value='daily'>Daily mode</option><option value='vacation' selected>Vacation mode</option>";
383
-				                                 var modeContent = "<div class='chooseDateIntvl'>Send auto-reply <span style='color:#ad0202'>inside</span> this interval:</div><div class='arplstrtendDates'><div class='stdtTitle'>Start Date</div><input type='text' id='startDT-"+ k +"' class='startDate' placeholder='Pick a date' value='"+ vctnStart +"'><div class='enddtTitle'>End Date</div><input type='text' id='endDT-"+ k +"' class='endDate' placeholder='Pick a date' value='"+ vctnEnd +"'></div>"
384
-				                             }
385
-
386
-							     $("#autoReplyTbl").append("<tr><td><input type='text' class='arplAuthor' value='"+ autorpldata[k].saved_by_dsplname +"' disabled></td><td><select id='arpphn-"+ k +"' class='arplPhoneNmbr' style='pointer-events:none'><option selected>"+ autorpldata[k].phone_number +"</option></select></td><td><div id='arplmode-"+ k +"' class='arplMode'><select id='modeselect-"+ k +"' class='selectArplMode'>"+ slctdMode +"</select><div id='modecont-"+ k +"' class='modeContent'>"+ modeContent +"</div></div></td><td><textarea id='arpltxt-"+ k +"' class='arplText' rows='20' cols='40' placeholder='Enter the auto-reply message here.'>"+ autorpldata[k].message_text +"</textarea></td><td><img id='rmRow-"+ k +"' class='removeRow' src='/" + ctappdir + "/sms_relentless/img/closewnd.svg' title='Remove this row from the database' style='cursor:pointer;margin:9px 8px 0px 18px;'></td><td><input type='submit' id='arplsave-"+ k +"' class='saveAutoReply' value='Edit' title='Edit Row' /></td></tr>");
387
-							}
388
-							$("#autoReplyTbl").append("<div><img id='addArplRow' src='/" + ctappdir + "/sms_relentless/img/add.svg' title='Add Row'></div>");
389
-						    }
390
-
391
-
392
-						    // Create a list with all the available phone numbers
393
-				                    var numbersListItems = "<option value='' selected>Select phone number</option>";
394
-
395
-						    $.each(availPhoneNmbrs, function(key, indsmsnmb) {
396
-							   numbersListItems += "<option value='"+ indsmsnmb +"'>"+ indsmsnmb +"</option>";
397
-						    });
398
-
399
-				                    if (arplNmb == 0) {
400
-							$("#arpphn-"+ arplNmb).append(numbersListItems);
401
-				                    }
402
-
403
-				                    // Initialize the date picker
404
-						    $('[id^="endDT-"]').datepicker({ dateFormat: "yy-mm-dd" });
405
-						    $('[id^="startDT-"]').datepicker({ dateFormat: "yy-mm-dd" });
406
-
407
-
408
-				                    // Select the auto-reply mode
409
-				                    function selectMode() {
410
-
411
-						            $('[id^="modeselect-"]').change(function() {
412
-
413
-						               var crtnmbr = $(this).attr("id").replace("modeselect-", "");
414
-
415
-						               var dailyHrStart = "";
416
-						               for (var h = 0; h < 24; h++) {
417
-						                    dailyHrStart += "<option value='"+ h.toLocaleString('en-US', {minimumIntegerDigits: 2, useGrouping:false}) +"'>"+ h.toLocaleString('en-US', {minimumIntegerDigits: 2, useGrouping:false}) +"</option>";
418
-						               }
419
-
420
-						               var dailyMnStart = "";
421
-						               for (var m = 0; m < 60; m++) {
422
-						                    dailyMnStart += "<option value='"+ m.toLocaleString('en-US', {minimumIntegerDigits: 2, useGrouping:false}) +"'>"+ m.toLocaleString('en-US', {minimumIntegerDigits: 2, useGrouping:false}) +"</option>";
423
-						               }
424
-
425
-						               var dailyHrEnd = dailyHrStart;
426
-						               var dailyMnEnd = dailyMnStart;
427
-
428
-						               if ($(this).val() == 'daily') {
429
-						                   $("#modecont-"+ crtnmbr).empty();
430
-						                   $("#modecont-"+ crtnmbr).append("<div class='daysOfWeek'>Days of the week:<div class='tooltipautoreply'><div id='infoautoreply'>i</div><div class='autorpltooltip'>Enter the order number of the days of the week in which the auto-reply will be sent. For example, to send the auto-reply every day from Monday to Friday outside the time interval specified below, enter 1,2,3,4,5 To send the auto-reply only Monday, Thursday and Friday enter 1,4,5 To send the auto-reply every day of the week enter 1,2,3,4,5,6,7 As an exception, if you want the auto-reply to be sent during an entire day, irrespective of the specified interval, add (full) after the number of that day. For example, if you want the auto-reply to be sent from Monday to Friday outside the interval specified below, and also during the entire days of Saturday and Sunday, enter 1,2,3,4,5,6(full),7(full)</div></div></div><input type='text' id='weekdays-"+ crtnmbr +"' class='daysInWeek'><div class='chooseTInterval'>Send auto-reply <span style='color:#ad0202'>outside</span> this interval:<div class='tooltipautoreplyst'><div id='infoautoreplyst'>i</div><div class='autorpltooltipst'>These fields specify the time of the server. If the server is located in a time zone that is different from that of the owner/company, the time interval entered here should be adjusted accordingly.</div></div></div><div class='selectArplHours'><select id='dmstarthr-"+ crtnmbr +"' class='selectHrMin'>"+ dailyHrStart +"</select><select id='dmstartmn-"+ crtnmbr +"' class='selectHrMin'>"+ dailyMnStart +"</select><span style='font-weight: 600'> — </span><select id='dmendhr-"+ crtnmbr +"' class='selectHrMin'>"+ dailyHrEnd +"</select><select id='dmendmn-"+ crtnmbr +"' class='selectHrMin'>"+ dailyMnEnd +"</select></div>");
431
-						               } else if ($(this).val() == 'vacation') {
432
-						                   $("#modecont-"+ crtnmbr).empty();
433
-						                   $("#modecont-"+ crtnmbr).append("<div class='chooseDateIntvl'>Send auto-reply <span style='color:#ad0202'>inside</span> this interval:</div><div class='arplstrtendDates'><div class='stdtTitle'>Start Date</div><input type='text' id='startDT-"+ crtnmbr +"' class='startDate' placeholder='Pick a date'><div class='enddtTitle'>End Date</div><input type='text' id='endDT-"+ crtnmbr +"' class='endDate' placeholder='Pick a date' /></div>");
434
-						               }
435
-
436
-							       $("#endDT-"+ crtnmbr +"").datepicker({ dateFormat: "yy-mm-dd" });
437
-							       $("#startDT-"+ crtnmbr +"").datepicker({ dateFormat: "yy-mm-dd" });
438
-						          });
439
-				                  }
440
-				                  selectMode();
441
-
442
-						  // Save the data
443
-						  function saveArplRow() {
444
-
445
-						     $('[id^="arplsave-"]').unbind("click");
446
-						     $('[id^="arplsave-"]').click(function(event) {
447
-
448
-							event.preventDefault();
449
-							var crntrwnmbr = $(this).attr("id").replace("arplsave-", "");
450
-
451
-							if ($(this).attr("value") == "Save") {
452
-
453
-							    var phoneNmbr = $("#arpphn-"+ crntrwnmbr).val();
454
-							    var arplText = $("#arpltxt-"+ crntrwnmbr).val();
455
-							    var slctdMode = $("#modeselect-"+ crntrwnmbr).val();
456
-
457
-							    var slctddmDays = "";
458
-							    var slctdHrStart = "";
459
-							    var slctdMnStart = "";
460
-							    var slctdHrEnd = "";
461
-							    var slctdMnEnd = "";
462
-
463
-							    var vcStartDate = null;
464
-							    var vcEndDate = null;
465
-
466
-							    if (slctdMode == 'daily') {
467
-
468
-								slctddmDays = $("#weekdays-"+ crntrwnmbr).val().trim();
469
-								slctdHrStart = $("#dmstarthr-"+ crntrwnmbr).val().trim();
470
-								slctdMnStart = $("#dmstartmn-"+ crntrwnmbr).val().trim();
471
-								slctdHrEnd = $("#dmendhr-"+ crntrwnmbr).val().trim();
472
-								slctdMnEnd = $("#dmendmn-"+ crntrwnmbr).val().trim();
473
-
474
-				                                if (slctdHrStart != '' && slctdMnStart != '') {
475
-				                                    var hrmnStartComp = slctdHrStart +":"+ slctdMnStart;
476
-				                                } else { var hrmnStartComp = ""; }
477
-
478
-				                                if (slctdHrEnd != '' && slctdMnEnd != '') {
479
-				                                    var hrmnEndComp = slctdHrEnd +":"+ slctdMnEnd;
480
-				                                } else { var hrmnEndComp = ""; }
481
-
482
-				                                if (!(/^[1-7ful\,\(\)]+$/.test(slctddmDays))) {
483
-								    showAlert("The 'Days of the week' field can contain only digits from 1 to 7, the lowercase letters f, u and l, round brackets ()() and commas (,).");
484
-								    return;
485
-				                                }
486
-
487
-				                                if (!(/^[0-9]+$/.test(slctdHrStart + slctdMnStart + slctdHrEnd + slctdMnEnd))) {
488
-								    showAlert("The starting and ending values of the time interval for the 'Daily mode' can contain only digits from 0 to 9.");
489
-								    return;
490
-				                                }
491
-
492
-				                                if (slctddmDays.trim() == '' || (slctdHrStart == slctdHrEnd && slctdMnStart == slctdMnEnd)) {
493
-								    showAlert("For the 'Daily mode', you have to enter the order number of the days of the week for which you want the auto-reply to be sent, and you have to set a starting time that is different from the ending time!");
494
-								    return;
495
-				                                }
496
-
497
-							    } else if (slctdMode == 'vacation') {
498
-				
499
-				                                if ($("#startDT-"+ crntrwnmbr).val().trim() == '' || $("#endDT-"+ crntrwnmbr).val().trim() == '') {
500
-
501
-								    showAlert("For the 'Vacation mode', you have to enter both a start date and an end date.");
502
-								    return;
503
-
504
-				                                } else {
505
-
506
-				                                    if (!(/^[0-9\-]+$/.test($("#startDT-"+ crntrwnmbr).val().trim() + $("#endDT-"+ crntrwnmbr).val().trim()))) {
507
-								        showAlert("The start date and end date values for the 'Vacation mode' can contain only digits from 0 to 9 and hyphens (-).");
508
-								        return;
509
-				                                    }
510
-
511
-						                    vcStartDate = $("#startDT-"+ crntrwnmbr).val().trim() +" 00:00:00";
512
-								    vcEndDate = $("#endDT-"+ crntrwnmbr).val().trim() +" 23:59:59";
513
-								    var strtDateCmp = new Date(vcStartDate).toJSON().slice(0, 10) +" 00:00:00";
514
-								    var endDateCmp = new Date(vcEndDate).toJSON().slice(0, 10) +" 23:59:59";
515
-								    var crntDate = new Date().toJSON().slice(0, 10) +" 23:59:59";
516
-
517
-				                                    if (vcStartDate.trim() == "" || vcEndDate.trim() == "" || (strtDateCmp >= endDateCmp || ((strtDateCmp < crntDate) && (endDateCmp < crntDate)))) {
518
-								        showAlert("For 'Vacation mode', you have to enter both a start date and an end date, the start date must be before the end date and at least the ending of the time interval must be in the future.");
519
-								        return;
520
-				                                    }
521
-				                                }
522
-							    }
523
-
524
-
525
-							    if (phoneNmbr != '') {
526
-
527
-							      if (arplText.trim() != '') {
528
-
529
-								if (slctdMode != '') {
530
-
531
-								    var saveArplUrl = OC.generateUrl('/apps/sms_relentless/user/updateautoreplies');
532
-								    var arpldata = {
533
-								         userId: userid,
534
-								         savedByDsplname: cusrDisplayName,
535
-								         phoneNumber: phoneNmbr,
536
-								         daysOfWeek: slctddmDays,
537
-								         dailyStart: hrmnStartComp,
538
-								         dailyEnd: hrmnEndComp,
539
-								         vacationStart: vcStartDate,
540
-								         vacationEnd: vcEndDate,
541
-								         messageText: arplText
542
-								    };
543
-
544
-								    $.ajax({
545
-								      method: 'PUT',
546
-								      url: saveArplUrl + '/' + userid,
547
-								      contentType: 'application/json',
548
-								      data: JSON.stringify(arpldata),
549
-								      success: function(messagereceived) {
550
-
551
-								                   if (messagereceived == 'success') {
552
-								                       showAlert('The auto-reply has been successfully saved to the database!');
553
-								                   } else if (messagereceived == 'failure') {
554
-								                       showAlert('Error while trying to save the auto-reply!');
555
-								                   } else if (messagereceived == 'not allowed') {
556
-				                                                       showAlert('You cannot change an auto-reply that was saved by a different user.');
557
-				                                                   }
558
-								      },
559
-								      error: function() {
560
-										   showAlert('Error while attempting to save the auto-reply! You can check the Nextcloud log to find more details about this issue.');
561
-								      }
562
-								    });
563
-
564
-
565
-				                                } else { showAlert("Please select the auto-reply mode."); return; }
566
-
567
-				                              } else { showAlert("Please enter the text of the auto-reply."); return; }
568
-
569
-				                            } else { showAlert("Please select a phone number if at least one number is available in the 'Phone Number' drop-down list. Otherwise, you should contact the administrator."); return; }
570
-
571
-				                            $(this).attr("value", "Edit");
572
-
573
-				                        } else {
574
-				                            $("#arplsave-"+ crntrwnmbr).attr("value", "Save");
575
-				                        }
576
-
577
-				                     });
578
-
579
-						  }
580
-				                  saveArplRow();
581
-
582
-
583
-						  // Remove a row
584
-						  function removeArplRow() {
585
-						       $('[id^="rmRow-"]').click(function() {
586
-
587
-							  var slctRowRm = $(this).attr("id").replace("rmRow-", "");
588
-							  var crntPhnNmbr = $("#arpphn-"+ slctRowRm).val();
589
-
590
-							  confirmAlert("Do you really want to remove this row from the database ?");
591
-
592
-							  $("#confirmCancel").click(function() { $("#alertMsgOverlay").remove(); $("#alertConfMessage").remove(); });
593
-
594
-							  $("#confirmOk").click(function() {
595
-
596
-							      $("#alertMsgOverlay").remove();
597
-							      $("#alertConfMessage").remove();
598
-
599
-							      var rmvArplUrl = OC.generateUrl('/apps/sms_relentless/user/removeautoreplies');
600
-							      $.ajax({
601
-								   url: rmvArplUrl + '/' + userid,
602
-								   method: "POST",
603
-								   dataType: "text",
604
-								   data: { phoneNumber: crntPhnNmbr },
605
-								   success: function(delresult) {
606
-
607
-										     if (delresult.indexOf("success") > -1) {
608
-										         showAlert("The auto-reply has been removed successfully!");
609
-										         $("#arpphn-"+ slctRowRm).closest("tr").remove();
610
-										     } else if (delresult.indexOf("failure") > -1) {
611
-										         showAlert("Error while trying to remove auto-reply data!");
612
-										     } else if (delresult.indexOf("not allowed") > -1) {
613
-				                                                         showAlert("You cannot remove the auto-reply saved by another user.");
614
-				                                                     }
615
-								   },
616
-								   error: function() { showAlert("Error while attempting to remove auto-reply data! You can check the Nextcloud log to find more details about this issue."); }
617
-							       });
618
-							  });
619
-						       });
620
-						  }
621
-						  removeArplRow();
622
-
623
-				                  // Add a new row
624
-				                  $("#addArplRow").click(function() {
625
-
626
-				                     if ($("#autoReplyTbl").find("tr:last-child").find(".arplPhoneNmbr").length > 0) {
627
-				                         var lastarpl = $("#autoReplyTbl").find("tr:last-child").find(".arplPhoneNmbr").attr("id").replace("arpphn-", "");
628
-				                         var indArplAdd = parseInt(lastarpl + 1);
629
-				                     } else { var indArplAdd = 0; }
630
-						     $("#autoReplyTbl").append("<tr><td><input type='text' class='arplAuthor' value='"+ cusrDisplayName +"' disabled></td><td><select id='arpphn-"+ indArplAdd +"' class='arplPhoneNmbr'>"+ numbersListItems +"</select></td><td><div id='arplmode-"+ indArplAdd +"' class='arplMode'><select id='modeselect-"+ indArplAdd +"' class='selectArplMode'><option value='' selected>Select mode</option><option value='daily'>Daily mode</option><option value='vacation'>Vacation mode</option></select><div id='modecont-"+ indArplAdd +"' class='modeContent'></div></div></td><td><textarea id='arpltxt-"+ indArplAdd +"' class='arplText' rows='20' cols='40' placeholder='Enter the auto-reply message here.'></textarea></td><td><img id='rmRow-"+ indArplAdd +"' class='removeRow' src='/" + ctappdir + "/sms_relentless/img/closewnd.svg' title='Remove this row from the database' style='cursor:pointer;margin:9px 8px 0px 18px;'></td><td><input type='submit' id='arplsave-"+ indArplAdd +"' class='saveAutoReply' value='Save' title='Save Row' /></td></tr>");
631
-
632
-				                     selectMode();
633
-				                     saveArplRow();
634
-				                     removeArplRow();
635
-
636
-						     // Check if there is an auto-reply set for the same phone number
637
-						     $("#arpphn-"+ indArplAdd).change(function() {
638
-							 var selectedPhNb = $("#arpphn-"+ indArplAdd).val();
639
-							 var allArplPhNmbrs = $("#autoReplyTbl").find("tr").find(".arplPhoneNmbr");
640
-							 var phNbChck = 0;
641
-							 allArplPhNmbrs.each(function() {
642
-							    var slctphnb = ($(this).val())? $(this).val() : $(this).text();
643
-							    if (selectedPhNb == slctphnb) { phNbChck++; }
644
-							 });
645
-
646
-							 if (phNbChck == 2) {
647
-							     showAlert("There is already an auto-reply set up for this phone number. Please edit its own row, or choose a different phone number.");
648
-							     $(this).val('');
649
-							     return;
650
-							 }
651
-						     });
652
-				                  });
653
-
654
-				  },
655
-				  error: function() {
656
-				                    $("#autoRplPhoneNb").removeClass('icon-loading'); 
657
-				                    showAlert("Error while attempting to get the auto-reply settings! You can check the Nextcloud log to find more details about this issue.");
658
-				  }
659
-			 });
660
-
661
-		     },
662
-		     error: function() {
663
-				  showAlert('Error while getting the settings! You can check the Nextcloud log to find more details about this issue.');
664
-		     }
665
-		  });
666
-
667
-
668
-
669
-		  // Save personal settings for non-admin users
670
-		  $("#save_sms_settings").on("click", function(event) {
671
-
672
-		     if (isadm == 'reguser') {
673
-
674
-			    event.preventDefault();
675
-			    var baseUrlsave = OC.generateUrl('/apps/sms_relentless/user/updatesettings');
676
-
677
-			    var messagesperpageinit = $("#messagesperpage").val();
678
-			    var messagesperpagesec = messagesperpageinit.replace(/[^0-9]/g, '');
679
-			    var messagesperpageproc = 100;
680
-
681
-			    if (messagesperpagesec != '') {
682
-				if (messagesperpagesec > 0 && messagesperpagesec < 4294967296) {
683
-				    messagesperpageproc = messagesperpagesec;
684
-				} else { alert("The field 'Number of messages per page' must contain a number between 1 and 4294967295."); return; }
685
-			    }
686
-
687
-			    var msgcheckintervalinit = $("#msgcheckinterval").val();
688
-			    var msgcheckintervalsec = msgcheckintervalinit.replace(/[^0-9]/g, '');
689
-			    var msgsCheckInterval = 5;
690
-
691
-			    if (msgcheckintervalsec != '') {
692
-				if (msgcheckintervalsec > 0 && msgcheckintervalsec < 86401) {
693
-				    msgsCheckInterval = msgcheckintervalsec;
694
-				} else { alert("The field 'Time interval in seconds before checking if a new message has arrived' must contain a number between 1 and 86400."); return; }
695
-			    }
696
-
697
-			    var getnotify = 0;
698
-
699
-			    if ($("#get_notify").is(':checked')) {
700
-				getnotify = 1;
701
-			    }
702
-
703
-			    var emailaddressinit = $("#notification_email").val();
704
-
705
-			    function validate_email($email) {
706
-				var email_reg = /^([\w-\.]+@([\w-]+\.)+[\w-]{2,4})?$/;
707
-				return email_reg.test($email);
708
-			    }
709
-
710
-			    if (validate_email(emailaddressinit)) {
711
-				 var notifyemail = emailaddressinit;
712
-			    } else {
713
-				 var notifyemail = '';
714
-			    }
715
-
716
-			    var includesmsinemail = 0;
717
-			    if ($("#includesmsinemail").is(':checked')) {
718
-				includesmsinemail = 1;
719
-				if ($("#notification_email").val().trim() == '') {
720
-				    showAlert("Please enter an email address in the field: 'I want to receive a notification to the email address from below ...', or uncheck the checkbox: 'Include the SMS/MMS message in the email notification itself'.");
721
-				    return;
722
-				}
723
-			    }
724
-
725
-			    var showdisplaynm = 0;
726
-			    if ($("#showdisplaynames").is(':checked')) {
727
-				showdisplaynm = 1;
728
-			    }
729
-
730
-			    var adddisplaynm = 0;
731
-			    if ($("#adddisplaynames").is(':checked')) {
732
-				adddisplaynm = 1;
733
-			    }
734
-
735
-			    var datatosave = {
736
-					      userId: userid,
737
-					      telapiUrlRec: $("#telapi_url_rec").val(),
738
-					      telapiUrl: $("#telapi_url").val(),
739
-					      nexapiUrlRec: $("#nexapi_url_rec").val(),
740
-					      nexapiUrl: $("#nexapi_url").val(),
741
-					      twilapiUrlRec: $("#twilapi_url_rec").val(),
742
-					      twilapiUrl: $("#twilapi_url").val(),
743
-					      flowapiUrlRec: $("#flowapi_url_rec").val(),
744
-					      flowapiUrl: $("#flowapi_url").val(),
745
-					      messagesperpage: messagesperpageproc,
746
-		 	                      msgCheckInterval: msgsCheckInterval,
747
-					      getNotify: getnotify,
748
-					      notificationEmail: notifyemail,
749
-					      getsmsinemail: includesmsinemail,
750
-					      showDisplayNames: showdisplaynm,
751
-				              addDisplayNames: adddisplaynm
752
-			    };
753
-
754
-
755
-			    $.ajax({
756
-			       method: 'PUT',
757
-			       url: baseUrlsave + '/' + userid,
758
-			       contentType: 'application/json',
759
-			       data: JSON.stringify(datatosave),
760
-			       success: function() {
761
-				               OC.msg.startAction('#smsr_save_msg', t('sms_relentless', 'Saved'));
762
-			       },
763
-			       error: function() {
764
-				    showAlert('Error while attempting to save the settings! You can check the Nextcloud log to find more details about this issue.');
765
-			       }
766
-			    });
767
-
768
-
769
-		     } else if (isadm == 'admin') {
770
-
771
-			    // Save personal settings for admins
772
-			    event.preventDefault();
773
-			    var baseUrlsaveadm = OC.generateUrl('/apps/sms_relentless/user/updatepersadmnsettings');
774
-
775
-			    var messagesperpageinit = $("#messagesperpage").val();
776
-			    var messagesperpagesec = messagesperpageinit.replace(/[^0-9]/g, '');
777
-			    var messagesperpageproc = 100;
778
-
779
-			    if (messagesperpagesec != '') {
780
-				if (messagesperpagesec > 0 && messagesperpagesec < 4294967296) {
781
-				    messagesperpageproc = messagesperpagesec;
782
-				} else { alert("The field 'Number of messages per page' must contain a number between 1 and 4294967295."); return; }
783
-			    }
784
-
785
-			    var msgcheckintervalinit = $("#msgcheckinterval").val();
786
-			    var msgcheckintervalsec = msgcheckintervalinit.replace(/[^0-9]/g, '');
787
-			    var msgsCheckInterval = 5;
788
-
789
-			    if (msgcheckintervalsec != '') {
790
-				if (msgcheckintervalsec > 0 && msgcheckintervalsec < 86401) {
791
-				    msgsCheckInterval = msgcheckintervalsec;
792
-				} else { alert("The field 'Time interval in seconds before checking if a new message has arrived' must contain a number between 1 and 86400."); return; }
793
-			    }
794
-
795
-			    var getnotify = 0;
796
-
797
-			    if ($("#get_notify").is(':checked')) {
798
-				getnotify = 1;
799
-			    }
800
-
801
-			    var emailaddressinit = $("#notification_email").val();
802
-
803
-			    function validate_email($email) {
804
-				var email_reg = /^([\w-\.]+@([\w-]+\.)+[\w-]{2,4})?$/;
805
-				return email_reg.test($email);
806
-			    }
807
-
808
-			    if (validate_email(emailaddressinit)) {
809
-				 var notifyemail = emailaddressinit;
810
-			    } else {
811
-				 var notifyemail = '';
812
-			    }
813
-
814
-			    var includesmsinemail = 0;
815
-			    if ($("#includesmsinemail").is(':checked')) {
816
-				includesmsinemail = 1;
817
-				if ($("#notification_email").val().trim() == '') {
818
-				    showAlert("Please enter an email address in the field: 'I want to receive a notification to the email address from below ...', or uncheck the checkbox: 'Include the SMS/MMS message in the email notification itself'.");
819
-				    return;
820
-				}
821
-			    }
822
-
823
-			    var showdisplaynm = 0;
824
-			    if ($("#showdisplaynames").is(':checked')) {
825
-				showdisplaynm = 1;
826
-			    }
827
-
828
-			    var adddisplaynm = 0;
829
-			    if ($("#adddisplaynames").is(':checked')) {
830
-				adddisplaynm = 1;
831
-			    }
832
-
833
-			    var datatosave = {
834
-					      userId: userid,
835
-					      messagesperpage: messagesperpageproc,
836
-					      msgCheckInterval: msgsCheckInterval,
837
-					      getNotify: getnotify,
838
-					      notificationEmail: notifyemail,
839
-					      getsmsinemail: includesmsinemail,
840
-					      showDisplayNames: showdisplaynm,
841
-				              addDisplayNames: adddisplaynm
842
-			    };
843
-
844
-
845
-			    $.ajax({
846
-			       method: 'PUT',
847
-			       url: baseUrlsaveadm + '/' + userid,
848
-			       contentType: 'application/json',
849
-			       data: JSON.stringify(datatosave),
850
-			       success: function() {
851
-				               OC.msg.startAction('#smsr_save_msg', t('sms_relentless', 'Saved'));
852
-			       },
853
-			       error: function() {
854
-				    showAlert('Error while attempting to save the settings! You can check the Nextcloud log to find more details about this issue.');
855
-			       }
856
-			    });
857
-
858
-		     }
859
-		  });
860
-
861
-		  function showAlert(alertText) {
862
-
863
-		     let alertwnd = "<div id='alertMessage'>";
864
-		     alertwnd += "<a id='closeAlertWnd' title='Close this window'></a>";
865
-		     alertwnd += "<div id='alertTextWrap'>"+ alertText +"</div>";
866
-		     alertwnd += "<input type='submit' id='alertOk' value='OK'>";
867
-		     alertwnd += "</div>";
868
-
869
-		     $("#content").append("<div id='alertMsgOverlay'></div>");
870
-		     $("#content").append(alertwnd);
871
-
872
-		     let topDist = parseInt((window.innerHeight / 2).toFixed(2) - 152) +"px";
873
-		     let leftDist = parseInt((window.innerWidth / 2).toFixed(2) - 150) +"px";
874
-		     $("#alertMessage").css({ "top" : topDist, "left" : leftDist });
875
-
876
-		     $("#closeAlertWnd").click(function() { $("#alertMsgOverlay").remove(); $("#alertMessage").remove(); });
877
-		     $("#alertMsgOverlay").click(function() { $("#alertMsgOverlay").remove(); $("#alertMessage").remove(); });
878
-		     $("#alertOk").click(function() { $("#alertMsgOverlay").remove(); $("#alertMessage").remove(); });
879
-		  }
880
-
881
-		  function confirmAlert(alertText) {
882
-
883
-		     $("#alertMsgOverlay").remove();
884
-		     $("#alertConfMessage").remove();
885
-
886
-		     let alertwndcf = "<div id='alertConfMessage'>";
887
-		     alertwndcf += "<a id='closeAlertWndcf' title='Close this window'></a>";
888
-		     alertwndcf += "<div id='alertTextWrap'>"+ alertText +"</div>";
889
-		     alertwndcf += "<div id='cancelOkWrap'><input type='submit' id='confirmCancel' value='Cancel'>";
890
-		     alertwndcf += "<input type='submit' id='confirmOk' value='OK'></div>";
891
-		     alertwndcf += "</div>";
892
-
893
-		     $("#content").append("<div id='alertMsgOverlay'></div>");
894
-		     $("#content").append(alertwndcf);
895
-
896
-		     let topDist = parseInt((window.innerHeight / 2).toFixed(2) - 152) +"px";
897
-		     let leftDist = parseInt((window.innerWidth / 2).toFixed(2) - 150) +"px";
898
-		     $("#alertConfMessage").css({ "top" : topDist, "left" : leftDist });
899
-
900
-		     $("#closeAlertWndcf").click(function() { $("#alertMsgOverlay").remove(); $("#alertConfMessage").remove(); });
901
-		     $("#alertMsgOverlay").click(function() { $("#alertMsgOverlay").remove(); $("#alertConfMessage").remove(); });
902
-		  }
903
-
904
-
905
-     },
906
-     error: function(appdirfdb) {
907
-                alert("An error occurred while getting the app's directory. You can check the Nextcloud log to find more details about this issue.");
908
-     }
909
-   });
910
-
911
-});
Browse code

added appinfo/info.xml appinfo/signature.json appinfo/routes.php CHANGELOG.txt README.md css/style.css js/settings.js js/sendsms.js js/adminsettings.js js/showsmstables.js templates/settings/admin.php templates/settings/personal.php templates/navigation/index.php lib/Controller/SmsrelentlessController.php lib/Service/SmsrelentlessService.php l10n/en_GB.js l10n/en_GB.json l10n/en_US.js l10n/en_US.json lib/Migration/Version133Date20240215094712.php

DoubleBastionAdmin authored on 14/02/2024 22:47:20
Showing 1 changed files
1 1
new file mode 100644
... ...
@@ -0,0 +1,911 @@
1
+/**
2
+ * @copyright 2021 Double Bastion LLC <www.doublebastion.com>
3
+ *
4
+ * @author Double Bastion LLC
5
+ *
6
+ * @license GNU AGPL version 3 or any later version
7
+ *
8
+ * This program is free software; you can redistribute it and/or
9
+ * modify it under the terms of the GNU AFFERO GENERAL PUBLIC LICENSE
10
+ * License as published by the Free Software Foundation; either
11
+ * version 3 of the License, or any later version.
12
+ *
13
+ * This program is distributed in the hope that it will be useful,
14
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
15
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
16
+ * GNU AFFERO GENERAL PUBLIC LICENSE for more details.
17
+ *
18
+ * You should have received a copy of the GNU Affero General Public
19
+ * License along with this program.  If not, see <http://www.gnu.org/licenses/>.
20
+ *
21
+ */
22
+
23
+$(document).ready(function() {
24
+
25
+  var userid = "<?php p($userId); ?>";
26
+  var isadm = '';
27
+  var ctappdir = 'apps';
28
+
29
+  // Get app directory
30
+  var getappdirurl = OC.generateUrl('/apps/sms_relentless/user/getappdirectory');
31
+
32
+  $.ajax({
33
+     method: 'GET',
34
+     url: getappdirurl + '/' + userid,
35
+     contentType: 'application/json',
36
+     success: function(appdirfdb) {
37
+
38
+                  ctappdir = appdirfdb;
39
+
40
+		  // Get personal settings
41
+		  var baseUrlget = OC.generateUrl('/apps/sms_relentless/user/getsettings');
42
+
43
+		  $.ajax({
44
+		     method: 'GET',
45
+		     url: baseUrlget + '/' + userid,
46
+		     contentType: 'application/json',
47
+		     success: function(settingsfromdb) {
48
+
49
+			 // Add the webhook URLs section, if the user is not an admin
50
+			 if (settingsfromdb.adminornot == 'reguser') {
51
+
52
+			     isadm = 'reguser';
53
+
54
+			     $("#appTitlePrg").append('<p id="settings-dscr"><h3>Enter your options in the fields from below. As a non-admin user, you can use any of the SMS service providers from \
55
+				  below (Telnyx/Plivo/Twilio/Flowroute), on the condition that an admin has shared with you his API keys for that provider. If an admin has shared with you his API \
56
+				  keys for a provider, to be able to use them properly, you will have to generate the two webhook URLs for that provider by clicking the corresponding \
57
+				  "Generate new webhook URL ..." buttons from below, then click "Save" at the bottom of this page:</h3></p><br>');
58
+
59
+			     $("#nadmProvSection").append('<div class="providerSettings"><p><label for="telapi_url_rec" class="setlabeltext"><b>Telnyx webhook URL for incoming SMS/MMS</b> (Generate \
60
+				  the URL by pressing the button from below. Don\'t forget to also click the \'Save\' button at the bottom of this page after entering all the options, to save \
61
+				  all the settings to the database.)</label></p> \
62
+				  <input type="button" id="generate_tel_rcpt" class="generateUrl" value="Generate new webhook URL for incoming SMS/MMS" /> \
63
+				  <input type="text" class="smsr_textboxspec" id="telapi_url_rec" name="telapi_url_rec" autocomplete="false" /> \
64
+				  <span id="copyToClipboardtel" class="icon icon-clippy" title="Copy to clipboard"></span><br><br> \
65
+				  \
66
+				  <p><label for="telapi_url" class="setlabeltext"><b>Telnyx webhook URL for delivery receipts</b> (This URL will be included by SMS Relentless in message sending \
67
+				  requests, so that Telnyx will know where to send the delivery receipts. Just generate it by pressing the button from below. Don\'t forget to click the \'Save\' \
68
+				  button at the bottom of this page after entering all the options, to save all the settings to the database.)</label></p> \
69
+				  <input type="button" id="generate_tel_delrcpt" class="generateUrl" value="Generate new webhook URL for delivery receipts" /> \
70
+				  <input type="text" id="telapi_url" name="telapi_url" autocomplete="false" /></div><br><br> \
71
+				  \
72
+				  <div class="providerSettings"><p><label for="nexapi_url_rec" class="setlabeltext"><b>Plivo webhook URL for incoming SMS/MMS</b> (Generate the URL by pressing \
73
+				  the button from below. Don\'t forget to also click the \'Save\' button at the bottom of this page after entering all the options, to save all the settings \
74
+				  to the database.)</label></p> \
75
+				  <input type="button" id="generate_nex_rcpt" class="generateUrl" value="Generate new webhook URL for incoming SMS/MMS" /> \
76
+				  <input type="text" class="smsr_textboxspec" id="nexapi_url_rec" name="nexapi_url_rec" autocomplete="false" /> \
77
+				  <span id="copyToClipboardnex" class="icon icon-clippy" title="Copy to clipboard"></span><br><br> \
78
+				  \
79
+				  <p><label for="nexapi_url" class="setlabeltext"><b>Plivo webhook URL for delivery receipts</b> (This URL will be included by SMS Relentless in message sending \
80
+				  requests, so that Plivo will know where to send the delivery receipts. Just generate it by pressing the button from below. Don\'t forget to click the \'Save\' \
81
+				  button at the bottom of this page after entering all the options, to save all the settings to the database.)</label></p> \
82
+				  <input type="button" id="generate_nex_delrcpt" class="generateUrl" value="Generate new webhook URL for delivery receipts" /> \
83
+				  <input type="text" id="nexapi_url" name="nexapi_url" autocomplete="false" /></div><br><br> \
84
+				  \
85
+				  <div class="providerSettings"><p><label for="twilapi_url_rec" class="setlabeltext"><b>Twilio webhook URL for incoming SMS/MMS</b> (Generate the URL by pressing \
86
+				  the button from below. Don\'t forget to also click the \'Save\' button at the bottom of this page after entering all the options, to save all the settings to \
87
+				  the database.)</label></p> \
88
+				  <input type="button" id="generate_twil_rcpt" class="generateUrl" value="Generate new webhook URL for incoming SMS/MMS" /> \
89
+				  <input type="text" class="smsr_textboxspec" id="twilapi_url_rec" name="twilapi_url_rec" autocomplete="false" /> \
90
+				  <span id="copyToClipboardtwil" class="icon icon-clippy" title="Copy to clipboard"></span><br><br> \
91
+				  \
92
+				  <p><label for="twilapi_url" class="setlabeltext"><b>Twilio webhook URL for delivery receipts</b> (This URL will be included by SMS Relentless in message sending \
93
+				  requests, so that Twilio will know where to send the delivery receipts. Just generate it by pressing the button from below. Don\'t forget to click the \'Save\' \
94
+				  button at the bottom of this page after entering all the options, to save all the settings to the database.)</label></p> \
95
+				  <input type="button" id="generate_twil_delrcpt" class="generateUrl" value="Generate new webhook URL for delivery receipts" /> \
96
+				  <input type="text" id="twilapi_url" name="twilapi_url" autocomplete="false" /></div><br><br> \
97
+				  \
98
+				  <div class="providerSettings"><p><label for="flowapi_url_rec" class="setlabeltext"><b>Flowroute webhook URL for incoming SMS/MMS</b> (Generate the URL by pressing \
99
+				  the button from below. Don\'t forget to also click the \'Save\' button at the bottom of this page after entering all the options, to save all the settings to \
100
+				  the database.)</label></p> \
101
+				  <input type="button" id="generate_flow_rcpt" class="generateUrl" value="Generate new webhook URL for incoming SMS/MMS" /> \
102
+				  <input type="text" class="smsr_textboxspec" id="flowapi_url_rec" name="flowapi_url_rec" autocomplete="false" /> \
103
+				  <span id="copyToClipboardflow" class="icon icon-clippy" title="Copy to clipboard"></span><br><br> \
104
+				  \
105
+				  <p><label for="flowapi_url" class="setlabeltext"><b>Flowroute webhook URL for delivery receipts</b> (This URL will be included by SMS Relentless in message sending \
106
+				  requests, so that Flowroute will know where to send the delivery receipts. Just generate it by pressing the button from below. Don\'t forget to click the \'Save\' \
107
+				  button at the bottom of this page after entering all the options, to save all the settings to the database.)</label></p> \
108
+				  <input type="button" id="generate_flow_delrcpt" class="generateUrl" value="Generate new webhook URL for delivery receipts" /> \
109
+				  <input type="text" id="flowapi_url" name="flowapi_url" autocomplete="false" /><br><br> \
110
+				  Flowroute only supports sending/receiving SMS/MMS messages within USA and Canada and it doesn\'t support Alphanumeric Sender IDs.</div><br>');
111
+
112
+
113
+				  $("#telapi_url_rec").val(settingsfromdb.telapi_url_rec);
114
+				  $("#telapi_url").val(settingsfromdb.telapi_url);
115
+				  $("#nexapi_url_rec").val(settingsfromdb.nexapi_url_rec);
116
+				  $("#nexapi_url").val(settingsfromdb.nexapi_url);
117
+				  $("#twilapi_url_rec").val(settingsfromdb.twilapi_url_rec);
118
+				  $("#twilapi_url").val(settingsfromdb.twilapi_url);
119
+				  $("#flowapi_url_rec").val(settingsfromdb.flowapi_url_rec);
120
+				  $("#flowapi_url").val(settingsfromdb.flowapi_url);
121
+				  $("#messagesperpage").val(settingsfromdb.messagesperpage);
122
+				  $("#msgcheckinterval").val(settingsfromdb.msg_check_interval);
123
+
124
+				  if (settingsfromdb.get_notify == 1) {
125
+				      $("#get_notify").attr('checked', true);
126
+				  } else {
127
+				      $("#get_notify").attr('checked', false);
128
+				  }
129
+
130
+				  $("#notification_email").val(settingsfromdb.notification_email);
131
+
132
+				  if (settingsfromdb.getsmsinemail == 1) {
133
+				      $("#includesmsinemail").attr('checked', true);
134
+				  } else {
135
+				      $("#includesmsinemail").attr('checked', false);
136
+				  }
137
+
138
+				  if (settingsfromdb.show_display_names == 1) {
139
+				      $("#showdisplaynames").attr('checked', true);
140
+				  } else {
141
+				      $("#showdisplaynames").attr('checked', false);
142
+				  }
143
+
144
+				  if (settingsfromdb.add_display_names == 1) {
145
+				      $("#adddisplaynames").attr('checked', true);
146
+				  } else {
147
+				      $("#adddisplaynames").attr('checked', false);
148
+				  }
149
+
150
+				  function randomStr(strlength) {
151
+					var fintext = "";
152
+					var keyspace = '0123456789abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ';
153
+					for (var i = 0; i < strlength; i++) {
154
+					     fintext += keyspace.charAt(Math.floor(Math.random() * keyspace.length));
155
+					}
156
+					return fintext;
157
+				  }
158
+
159
+				  $("#generate_tel_rcpt").on("click", function(event) {
160
+
161
+				     var teltokenrec = randomStr(70);
162
+				     var telnyxwhurlrec = window.location.origin + OC.generateUrl('/apps/sms_relentless/api/recsmstel?telrecparam=') + teltokenrec;
163
+
164
+				     $("#telapi_url_rec").val(telnyxwhurlrec);
165
+				  });
166
+
167
+				  $("#copyToClipboardtel").on("click", function(event) {
168
+				     var $tempEl = $("<input>");
169
+				     $("body").append($tempEl);
170
+				     $tempEl.val($("#telapi_url_rec").val()).select();
171
+				     document.execCommand("Copy");
172
+				     $tempEl.remove();
173
+				     showAlert("The link has been copied to your clipboard!");
174
+				  });
175
+
176
+				  $("#generate_tel_delrcpt").on("click", function(event) {
177
+
178
+				     var teltoken = randomStr(70);
179
+				     var telnyxwhurl = window.location.origin + OC.generateUrl('/apps/sms_relentless/api/recdeliverytel?teldrparam=') + teltoken;
180
+
181
+				     $("#telapi_url").val(telnyxwhurl);
182
+				  });
183
+
184
+
185
+				  $("#generate_nex_rcpt").on("click", function(event) {
186
+
187
+				     var plivotokenrec = randomStr(70);
188
+				     var plivowhurlrec = window.location.origin + OC.generateUrl('/apps/sms_relentless/api/recsmsnex?plivorecparam=') + plivotokenrec;
189
+
190
+				     $("#nexapi_url_rec").val(plivowhurlrec);
191
+				  });
192
+
193
+				  $("#copyToClipboardnex").on("click", function(event) {
194
+				     var $tempElpl = $("<input>");
195
+				     $("body").append($tempElpl);
196
+				     $tempElpl.val($("#nexapi_url_rec").val()).select();
197
+				     document.execCommand("Copy");
198
+				     $tempElpl.remove();
199
+				     showAlert("The link has been copied to your clipboard!");
200
+				  });
201
+
202
+				  $("#generate_nex_delrcpt").on("click", function(event) {
203
+
204
+				     var plivotoken = randomStr(70);
205
+				     var plivodrwhurl = window.location.origin + OC.generateUrl('/apps/sms_relentless/api/recdeliverynex?plivodrparam=') + plivotoken;
206
+
207
+				     $("#nexapi_url").val(plivodrwhurl);
208
+				  });
209
+
210
+
211
+				  $("#generate_twil_rcpt").on("click", function(event) {
212
+
213
+				     var twiltokenrec = randomStr(35);
214
+				     var twilwhurlrec = window.location.origin + OC.generateUrl('/apps/sms_relentless/api/recsmstwil?twilrecparam=') + twiltokenrec;
215
+
216
+				     $("#twilapi_url_rec").val(twilwhurlrec);
217
+				  });
218
+
219
+				  $("#copyToClipboardtwil").on("click", function(event) {
220
+				     var $tempElpl = $("<input>");
221
+				     $("body").append($tempElpl);
222
+				     $tempElpl.val($("#twilapi_url_rec").val()).select();
223
+				     document.execCommand("Copy");
224
+				     $tempElpl.remove();
225
+				     showAlert("The link has been copied to your clipboard!");
226
+				  });
227
+
228
+				  $("#generate_twil_delrcpt").on("click", function(event) {
229
+
230
+				     var twiltoken = randomStr(35);
231
+				     var twildrwhurl = window.location.origin + OC.generateUrl('/apps/sms_relentless/api/recdeliverytwil?twildrparam=') + twiltoken;
232
+
233
+				     $("#twilapi_url").val(twildrwhurl);
234
+				  });
235
+
236
+
237
+				  $("#generate_flow_rcpt").on("click", function(event) {
238
+
239
+				     var flowtokenrec = randomStr(70);
240
+				     var flowwhurlrec = window.location.origin + OC.generateUrl('/apps/sms_relentless/api/recsmsflow?flowrecparam=') + flowtokenrec;
241
+
242
+				     $("#flowapi_url_rec").val(flowwhurlrec);
243
+				  });
244
+
245
+				  $("#copyToClipboardflow").on("click", function(event) {
246
+				     var $tempElpl = $("<input>");
247
+				     $("body").append($tempElpl);
248
+				     $tempElpl.val($("#flowapi_url_rec").val()).select();
249
+				     document.execCommand("Copy");
250
+				     $tempElpl.remove();
251
+				     showAlert("The link has been copied to your clipboard!");
252
+				  });
253
+
254
+				  $("#generate_flow_delrcpt").on("click", function(event) {
255
+
256
+				     var flowtoken = randomStr(70);
257
+				     var flowdrwhurl = window.location.origin + OC.generateUrl('/apps/sms_relentless/api/recdeliveryflow?flowdrparam=') + flowtoken;
258
+
259
+				     $("#flowapi_url").val(flowdrwhurl);
260
+				  });
261
+
262
+
263
+			 } else if (settingsfromdb.adminornot == 'admin') {
264
+
265
+				  $("#appTitlePrg").append('<p id="settings-dscr"><h3>First enter your credentials on the admin settings page of the app (on the left panel, under Administration, \
266
+				                            click on SMS Relentless), then enter your options in the fields from below:</h3></p><br>');
267
+				  isadm = 'admin';
268
+
269
+				  $("#messagesperpage").val(settingsfromdb.messagesperpage);
270
+				  $("#msgcheckinterval").val(settingsfromdb.msg_check_interval);
271
+
272
+				  if (settingsfromdb.get_notify == 1) {
273
+				      $("#get_notify").attr('checked', true);
274
+				  } else {
275
+				      $("#get_notify").attr('checked', false);
276
+				  }
277
+
278
+				  $("#notification_email").val(settingsfromdb.notification_email);
279
+
280
+				  if (settingsfromdb.getsmsinemail == 1) {
281
+				      $("#includesmsinemail").attr('checked', true);
282
+				  } else {
283
+				      $("#includesmsinemail").attr('checked', false);
284
+				  }
285
+
286
+				  if (settingsfromdb.show_display_names == 1) {
287
+				      $("#showdisplaynames").attr('checked', true);
288
+				  } else {
289
+				      $("#showdisplaynames").attr('checked', false);
290
+				  }
291
+
292
+				  if (settingsfromdb.add_display_names == 1) {
293
+				      $("#adddisplaynames").attr('checked', true);
294
+				  } else {
295
+				      $("#adddisplaynames").attr('checked', false);
296
+				  }
297
+			 }
298
+
299
+
300
+			 // Auto-reply settings
301
+
302
+			 // Get the available phone numbers from all providers associated with the access keys entered on the Settings page (restrictions are applied to numbers for non-admins)
303
+			 $("#autoRplPhoneNb").addClass('icon-loading');
304
+			 var getnumbersUrl = OC.generateUrl("/apps/sms_relentless/user/getautoreplyconf");
305
+
306
+			 $.ajax({
307
+				  url: getnumbersUrl + '/' + userid,
308
+				  type: "GET",
309
+				  contentType: 'application/json',
310
+				  success: function(autoreplydata) {
311
+
312
+				                    $("#autoRplPhoneNb").removeClass('icon-loading');
313
+				                    var cusrDisplayName = autoreplydata.userdisplayname;
314
+				                    var availPhoneNmbrs = autoreplydata.phonenumbers;
315
+				                    var autorpldata = autoreplydata.autoreplies;
316
+
317
+						    if (autorpldata.length > 0) { 
318
+							var arplNmb = autorpldata.length;
319
+						    } else { 
320
+							var arplNmb = 0; 
321
+						    }
322
+
323
+						    // List the auto-replies for the phone numbers available for the current user
324
+						    if (arplNmb == 0) {
325
+
326
+							$("#autoReplyTbl").append("<tr><td><input type='text' class='arplAuthor' value='"+ cusrDisplayName +"' disabled></td><td><select id='arpphn-"+ arplNmb +"' class='arplPhoneNmbr'></select></td><td><div id='arplmode-"+ arplNmb +"' class='arplMode'><select id='modeselect-"+ arplNmb +"' class='selectArplMode'><option value='' selected>Select mode</option><option value='daily'>Daily mode</option><option value='vacation'>Vacation mode</option></select><div id='modecont-"+ arplNmb +"' class='modeContent'></div></div></td><td><textarea id='arpltxt-"+ arplNmb +"' class='arplText' rows='20' cols='40' placeholder='Enter the auto-reply message here.'></textarea></td><td><img id='rmRow-"+ arplNmb +"' class='removeRow' src='/" + ctappdir + "/sms_relentless/img/closewnd.svg' title='Remove this row from the database' style='cursor:pointer;margin:9px 8px 0px 18px;'></td><td><input type='submit' id='arplsave-"+ arplNmb +"' class='saveAutoReply' value='Save' title='Save Row' /></td></tr>");
327
+							$("#autoReplyTbl").append("<div><img id='addArplRow' src='/" + ctappdir + "/sms_relentless/img/add.svg' title='Add Row'></div>");
328
+
329
+						    } else {
330
+
331
+							for (k = 0; k < arplNmb; k++) {
332
+
333
+				                             if (autorpldata[k].days_of_week != '') {
334
+
335
+				                                 var slctdMode = "<option value=''>Select mode</option><option value='daily' selected>Daily mode</option><option value='vacation'>Vacation mode</option>";
336
+				                                 var dailyStartArr = autorpldata[k].daily_start.split(":");
337
+				                                 var dailyEndArr = autorpldata[k].daily_end.split(":");
338
+
339
+						                 var dlHrStartOptions = "";
340
+							         for (var hr = 0; hr < 24; hr++) {
341
+						                      if (dailyStartArr[0] != hr.toLocaleString('en-US', {minimumIntegerDigits: 2, useGrouping:false})) {
342
+							                  dlHrStartOptions += "<option value='"+ hr.toLocaleString('en-US', {minimumIntegerDigits: 2, useGrouping:false}) +"'>"+ hr.toLocaleString('en-US', {minimumIntegerDigits: 2, useGrouping:false}) +"</option>";
343
+						                      } else {
344
+							                  dlHrStartOptions += "<option value='"+ hr.toLocaleString('en-US', {minimumIntegerDigits: 2, useGrouping:false}) +"' selected>"+ hr.toLocaleString('en-US', {minimumIntegerDigits: 2, useGrouping:false}) +"</option>";
345
+						                      }
346
+							         }
347
+
348
+						                 var dlMnStartOptions = "";
349
+							         for (var mn = 0; mn < 60; mn++) {
350
+						                      if (dailyStartArr[1] != mn.toLocaleString('en-US', {minimumIntegerDigits: 2, useGrouping:false})) {
351
+							                  dlMnStartOptions += "<option value='"+ mn.toLocaleString('en-US', {minimumIntegerDigits: 2, useGrouping:false}) +"'>"+ mn.toLocaleString('en-US', {minimumIntegerDigits: 2, useGrouping:false}) +"</option>";
352
+						                      } else {
353
+							                  dlMnStartOptions += "<option value='"+ mn.toLocaleString('en-US', {minimumIntegerDigits: 2, useGrouping:false}) +"' selected>"+ mn.toLocaleString('en-US', {minimumIntegerDigits: 2, useGrouping:false}) +"</option>";
354
+						                      }
355
+							         }
356
+
357
+						                 var dlHrEndOptions = "";
358
+							         for (var hr = 0; hr < 24; hr++) {
359
+						                      if (dailyEndArr[0] != hr.toLocaleString('en-US', {minimumIntegerDigits: 2, useGrouping:false})) {
360
+							                  dlHrEndOptions += "<option value='"+ hr.toLocaleString('en-US', {minimumIntegerDigits: 2, useGrouping:false}) +"'>"+ hr.toLocaleString('en-US', {minimumIntegerDigits: 2, useGrouping:false}) +"</option>";
361
+						                      } else {
362
+							                  dlHrEndOptions += "<option value='"+ hr.toLocaleString('en-US', {minimumIntegerDigits: 2, useGrouping:false}) +"' selected>"+ hr.toLocaleString('en-US', {minimumIntegerDigits: 2, useGrouping:false}) +"</option>";
363
+						                      }
364
+							         }
365
+
366
+						                 var dlMnEndOptions = "";
367
+							         for (var mn = 0; mn < 60; mn++) {
368
+						                      if (dailyEndArr[1] != mn.toLocaleString('en-US', {minimumIntegerDigits: 2, useGrouping:false})) {
369
+							                  dlMnEndOptions += "<option value='"+ mn.toLocaleString('en-US', {minimumIntegerDigits: 2, useGrouping:false}) +"'>"+ mn.toLocaleString('en-US', {minimumIntegerDigits: 2, useGrouping:false}) +"</option>";
370
+						                      } else {
371
+							                  dlMnEndOptions += "<option value='"+ mn.toLocaleString('en-US', {minimumIntegerDigits: 2, useGrouping:false}) +"' selected>"+ mn.toLocaleString('en-US', {minimumIntegerDigits: 2, useGrouping:false}) +"</option>";
372
+						                      }
373
+							         }
374
+
375
+				                                 var modeContent = "<div class='daysOfWeek'>Days of the week:<div class='tooltipautoreply'><div id='infoautoreply'>i</div><div class='autorpltooltip'>Enter the order number of the days of the week in which the auto-reply will be sent. For example, to send the auto-reply every day from Monday to Friday outside the time interval specified below, enter 1,2,3,4,5 To send the auto-reply only Monday, Thursday and Friday enter 1,4,5 To send the auto-reply every day of the week enter 1,2,3,4,5,6,7 As an exception, if you want the auto-reply to be sent during an entire day, irrespective of the specified interval, add (full) after the number of that day. For example, if you want the auto-reply to be sent from Monday to Friday outside the interval specified below, and also during the entire days of Saturday and Sunday, enter 1,2,3,4,5,6(full),7(full)</div></div></div><input type='text' id='weekdays-"+ k +"' class='daysInWeek' value='"+ autorpldata[k].days_of_week +"'><div class='chooseTInterval'>Send auto-reply <span style='color:#ad0202'>outside</span> this interval:<div class='tooltipautoreplyst'><div id='infoautoreplyst'>i</div><div class='autorpltooltipst'>These fields specify the time of the server. If the server is located in a time zone that is different from that of the owner/company, the time interval entered here should be adjusted accordingly.</div></div></div><div class='selectArplHours'><select id='dmstarthr-"+ k +"' class='selectHrMin'>"+ dlHrStartOptions +"</select><select id='dmstartmn-"+ k +"' class='selectHrMin'>"+ dlMnStartOptions +"</select><span style='font-weight: 600'> — </span><select id='dmendhr-"+ k +"' class='selectHrMin'>"+ dlHrEndOptions +"</select><select id='dmendmn-"+ k +"' class='selectHrMin'>"+ dlMnEndOptions +"</select></div>";
376
+
377
+				                             } else {
378
+
379
+				                                 var vctnStart = autorpldata[k].vacation_start.split(" ")[0];
380
+				                                 var vctnEnd = autorpldata[k].vacation_end.split(" ")[0];
381
+
382
+				                                 var slctdMode = "<option value=''>Select mode</option><option value='daily'>Daily mode</option><option value='vacation' selected>Vacation mode</option>";
383
+				                                 var modeContent = "<div class='chooseDateIntvl'>Send auto-reply <span style='color:#ad0202'>inside</span> this interval:</div><div class='arplstrtendDates'><div class='stdtTitle'>Start Date</div><input type='text' id='startDT-"+ k +"' class='startDate' placeholder='Pick a date' value='"+ vctnStart +"'><div class='enddtTitle'>End Date</div><input type='text' id='endDT-"+ k +"' class='endDate' placeholder='Pick a date' value='"+ vctnEnd +"'></div>"
384
+				                             }
385
+
386
+							     $("#autoReplyTbl").append("<tr><td><input type='text' class='arplAuthor' value='"+ autorpldata[k].saved_by_dsplname +"' disabled></td><td><select id='arpphn-"+ k +"' class='arplPhoneNmbr' style='pointer-events:none'><option selected>"+ autorpldata[k].phone_number +"</option></select></td><td><div id='arplmode-"+ k +"' class='arplMode'><select id='modeselect-"+ k +"' class='selectArplMode'>"+ slctdMode +"</select><div id='modecont-"+ k +"' class='modeContent'>"+ modeContent +"</div></div></td><td><textarea id='arpltxt-"+ k +"' class='arplText' rows='20' cols='40' placeholder='Enter the auto-reply message here.'>"+ autorpldata[k].message_text +"</textarea></td><td><img id='rmRow-"+ k +"' class='removeRow' src='/" + ctappdir + "/sms_relentless/img/closewnd.svg' title='Remove this row from the database' style='cursor:pointer;margin:9px 8px 0px 18px;'></td><td><input type='submit' id='arplsave-"+ k +"' class='saveAutoReply' value='Edit' title='Edit Row' /></td></tr>");
387
+							}
388
+							$("#autoReplyTbl").append("<div><img id='addArplRow' src='/" + ctappdir + "/sms_relentless/img/add.svg' title='Add Row'></div>");
389
+						    }
390
+
391
+
392
+						    // Create a list with all the available phone numbers
393
+				                    var numbersListItems = "<option value='' selected>Select phone number</option>";
394
+
395
+						    $.each(availPhoneNmbrs, function(key, indsmsnmb) {
396
+							   numbersListItems += "<option value='"+ indsmsnmb +"'>"+ indsmsnmb +"</option>";
397
+						    });
398
+
399
+				                    if (arplNmb == 0) {
400
+							$("#arpphn-"+ arplNmb).append(numbersListItems);
401
+				                    }
402
+
403
+				                    // Initialize the date picker
404
+						    $('[id^="endDT-"]').datepicker({ dateFormat: "yy-mm-dd" });
405
+						    $('[id^="startDT-"]').datepicker({ dateFormat: "yy-mm-dd" });
406
+
407
+
408
+				                    // Select the auto-reply mode
409
+				                    function selectMode() {
410
+
411
+						            $('[id^="modeselect-"]').change(function() {
412
+
413
+						               var crtnmbr = $(this).attr("id").replace("modeselect-", "");
414
+
415
+						               var dailyHrStart = "";
416
+						               for (var h = 0; h < 24; h++) {
417
+						                    dailyHrStart += "<option value='"+ h.toLocaleString('en-US', {minimumIntegerDigits: 2, useGrouping:false}) +"'>"+ h.toLocaleString('en-US', {minimumIntegerDigits: 2, useGrouping:false}) +"</option>";
418
+						               }
419
+
420
+						               var dailyMnStart = "";
421
+						               for (var m = 0; m < 60; m++) {
422
+						                    dailyMnStart += "<option value='"+ m.toLocaleString('en-US', {minimumIntegerDigits: 2, useGrouping:false}) +"'>"+ m.toLocaleString('en-US', {minimumIntegerDigits: 2, useGrouping:false}) +"</option>";
423
+						               }
424
+
425
+						               var dailyHrEnd = dailyHrStart;
426
+						               var dailyMnEnd = dailyMnStart;
427
+
428
+						               if ($(this).val() == 'daily') {
429
+						                   $("#modecont-"+ crtnmbr).empty();
430
+						                   $("#modecont-"+ crtnmbr).append("<div class='daysOfWeek'>Days of the week:<div class='tooltipautoreply'><div id='infoautoreply'>i</div><div class='autorpltooltip'>Enter the order number of the days of the week in which the auto-reply will be sent. For example, to send the auto-reply every day from Monday to Friday outside the time interval specified below, enter 1,2,3,4,5 To send the auto-reply only Monday, Thursday and Friday enter 1,4,5 To send the auto-reply every day of the week enter 1,2,3,4,5,6,7 As an exception, if you want the auto-reply to be sent during an entire day, irrespective of the specified interval, add (full) after the number of that day. For example, if you want the auto-reply to be sent from Monday to Friday outside the interval specified below, and also during the entire days of Saturday and Sunday, enter 1,2,3,4,5,6(full),7(full)</div></div></div><input type='text' id='weekdays-"+ crtnmbr +"' class='daysInWeek'><div class='chooseTInterval'>Send auto-reply <span style='color:#ad0202'>outside</span> this interval:<div class='tooltipautoreplyst'><div id='infoautoreplyst'>i</div><div class='autorpltooltipst'>These fields specify the time of the server. If the server is located in a time zone that is different from that of the owner/company, the time interval entered here should be adjusted accordingly.</div></div></div><div class='selectArplHours'><select id='dmstarthr-"+ crtnmbr +"' class='selectHrMin'>"+ dailyHrStart +"</select><select id='dmstartmn-"+ crtnmbr +"' class='selectHrMin'>"+ dailyMnStart +"</select><span style='font-weight: 600'> — </span><select id='dmendhr-"+ crtnmbr +"' class='selectHrMin'>"+ dailyHrEnd +"</select><select id='dmendmn-"+ crtnmbr +"' class='selectHrMin'>"+ dailyMnEnd +"</select></div>");
431
+						               } else if ($(this).val() == 'vacation') {
432
+						                   $("#modecont-"+ crtnmbr).empty();
433
+						                   $("#modecont-"+ crtnmbr).append("<div class='chooseDateIntvl'>Send auto-reply <span style='color:#ad0202'>inside</span> this interval:</div><div class='arplstrtendDates'><div class='stdtTitle'>Start Date</div><input type='text' id='startDT-"+ crtnmbr +"' class='startDate' placeholder='Pick a date'><div class='enddtTitle'>End Date</div><input type='text' id='endDT-"+ crtnmbr +"' class='endDate' placeholder='Pick a date' /></div>");
434
+						               }
435
+
436
+							       $("#endDT-"+ crtnmbr +"").datepicker({ dateFormat: "yy-mm-dd" });
437
+							       $("#startDT-"+ crtnmbr +"").datepicker({ dateFormat: "yy-mm-dd" });
438
+						          });
439
+				                  }
440
+				                  selectMode();
441
+
442
+						  // Save the data
443
+						  function saveArplRow() {
444
+
445
+						     $('[id^="arplsave-"]').unbind("click");
446
+						     $('[id^="arplsave-"]').click(function(event) {
447
+
448
+							event.preventDefault();
449
+							var crntrwnmbr = $(this).attr("id").replace("arplsave-", "");
450
+
451
+							if ($(this).attr("value") == "Save") {
452
+
453
+							    var phoneNmbr = $("#arpphn-"+ crntrwnmbr).val();
454
+							    var arplText = $("#arpltxt-"+ crntrwnmbr).val();
455
+							    var slctdMode = $("#modeselect-"+ crntrwnmbr).val();
456
+
457
+							    var slctddmDays = "";
458
+							    var slctdHrStart = "";
459
+							    var slctdMnStart = "";
460
+							    var slctdHrEnd = "";
461
+							    var slctdMnEnd = "";
462
+
463
+							    var vcStartDate = null;
464
+							    var vcEndDate = null;
465
+
466
+							    if (slctdMode == 'daily') {
467
+
468
+								slctddmDays = $("#weekdays-"+ crntrwnmbr).val().trim();
469
+								slctdHrStart = $("#dmstarthr-"+ crntrwnmbr).val().trim();
470
+								slctdMnStart = $("#dmstartmn-"+ crntrwnmbr).val().trim();
471
+								slctdHrEnd = $("#dmendhr-"+ crntrwnmbr).val().trim();
472
+								slctdMnEnd = $("#dmendmn-"+ crntrwnmbr).val().trim();
473
+
474
+				                                if (slctdHrStart != '' && slctdMnStart != '') {
475
+				                                    var hrmnStartComp = slctdHrStart +":"+ slctdMnStart;
476
+				                                } else { var hrmnStartComp = ""; }
477
+
478
+				                                if (slctdHrEnd != '' && slctdMnEnd != '') {
479
+				                                    var hrmnEndComp = slctdHrEnd +":"+ slctdMnEnd;
480
+				                                } else { var hrmnEndComp = ""; }
481
+
482
+				                                if (!(/^[1-7ful\,\(\)]+$/.test(slctddmDays))) {
483
+								    showAlert("The 'Days of the week' field can contain only digits from 1 to 7, the lowercase letters f, u and l, round brackets ()() and commas (,).");
484
+								    return;
485
+				                                }
486
+
487
+				                                if (!(/^[0-9]+$/.test(slctdHrStart + slctdMnStart + slctdHrEnd + slctdMnEnd))) {
488
+								    showAlert("The starting and ending values of the time interval for the 'Daily mode' can contain only digits from 0 to 9.");
489
+								    return;
490
+				                                }
491
+
492
+				                                if (slctddmDays.trim() == '' || (slctdHrStart == slctdHrEnd && slctdMnStart == slctdMnEnd)) {
493
+								    showAlert("For the 'Daily mode', you have to enter the order number of the days of the week for which you want the auto-reply to be sent, and you have to set a starting time that is different from the ending time!");
494
+								    return;
495
+				                                }
496
+
497
+							    } else if (slctdMode == 'vacation') {
498
+				
499
+				                                if ($("#startDT-"+ crntrwnmbr).val().trim() == '' || $("#endDT-"+ crntrwnmbr).val().trim() == '') {
500
+
501
+								    showAlert("For the 'Vacation mode', you have to enter both a start date and an end date.");
502
+								    return;
503
+
504
+				                                } else {
505
+
506
+				                                    if (!(/^[0-9\-]+$/.test($("#startDT-"+ crntrwnmbr).val().trim() + $("#endDT-"+ crntrwnmbr).val().trim()))) {
507
+								        showAlert("The start date and end date values for the 'Vacation mode' can contain only digits from 0 to 9 and hyphens (-).");
508
+								        return;
509
+				                                    }
510
+
511
+						                    vcStartDate = $("#startDT-"+ crntrwnmbr).val().trim() +" 00:00:00";
512
+								    vcEndDate = $("#endDT-"+ crntrwnmbr).val().trim() +" 23:59:59";
513
+								    var strtDateCmp = new Date(vcStartDate).toJSON().slice(0, 10) +" 00:00:00";
514
+								    var endDateCmp = new Date(vcEndDate).toJSON().slice(0, 10) +" 23:59:59";
515
+								    var crntDate = new Date().toJSON().slice(0, 10) +" 23:59:59";
516
+
517
+				                                    if (vcStartDate.trim() == "" || vcEndDate.trim() == "" || (strtDateCmp >= endDateCmp || ((strtDateCmp < crntDate) && (endDateCmp < crntDate)))) {
518
+								        showAlert("For 'Vacation mode', you have to enter both a start date and an end date, the start date must be before the end date and at least the ending of the time interval must be in the future.");
519
+								        return;
520
+				                                    }
521
+				                                }
522
+							    }
523
+
524
+
525
+							    if (phoneNmbr != '') {
526
+
527
+							      if (arplText.trim() != '') {
528
+
529
+								if (slctdMode != '') {
530
+
531
+								    var saveArplUrl = OC.generateUrl('/apps/sms_relentless/user/updateautoreplies');
532
+								    var arpldata = {
533
+								         userId: userid,
534
+								         savedByDsplname: cusrDisplayName,
535
+								         phoneNumber: phoneNmbr,
536
+								         daysOfWeek: slctddmDays,
537
+								         dailyStart: hrmnStartComp,
538
+								         dailyEnd: hrmnEndComp,
539
+								         vacationStart: vcStartDate,
540
+								         vacationEnd: vcEndDate,
541
+								         messageText: arplText
542
+								    };
543
+
544
+								    $.ajax({
545
+								      method: 'PUT',
546
+								      url: saveArplUrl + '/' + userid,
547
+								      contentType: 'application/json',
548
+								      data: JSON.stringify(arpldata),
549
+								      success: function(messagereceived) {
550
+
551
+								                   if (messagereceived == 'success') {
552
+								                       showAlert('The auto-reply has been successfully saved to the database!');
553
+								                   } else if (messagereceived == 'failure') {
554
+								                       showAlert('Error while trying to save the auto-reply!');
555
+								                   } else if (messagereceived == 'not allowed') {
556
+				                                                       showAlert('You cannot change an auto-reply that was saved by a different user.');
557
+				                                                   }
558
+								      },
559
+								      error: function() {
560
+										   showAlert('Error while attempting to save the auto-reply! You can check the Nextcloud log to find more details about this issue.');
561
+								      }
562
+								    });
563
+
564
+
565
+				                                } else { showAlert("Please select the auto-reply mode."); return; }
566
+
567
+				                              } else { showAlert("Please enter the text of the auto-reply."); return; }
568
+
569
+				                            } else { showAlert("Please select a phone number if at least one number is available in the 'Phone Number' drop-down list. Otherwise, you should contact the administrator."); return; }
570
+
571
+				                            $(this).attr("value", "Edit");
572
+
573
+				                        } else {
574
+				                            $("#arplsave-"+ crntrwnmbr).attr("value", "Save");
575
+				                        }
576
+
577
+				                     });
578
+
579
+						  }
580
+				                  saveArplRow();
581
+
582
+
583
+						  // Remove a row
584
+						  function removeArplRow() {
585
+						       $('[id^="rmRow-"]').click(function() {
586
+
587
+							  var slctRowRm = $(this).attr("id").replace("rmRow-", "");
588
+							  var crntPhnNmbr = $("#arpphn-"+ slctRowRm).val();
589
+
590
+							  confirmAlert("Do you really want to remove this row from the database ?");
591
+
592
+							  $("#confirmCancel").click(function() { $("#alertMsgOverlay").remove(); $("#alertConfMessage").remove(); });
593
+
594
+							  $("#confirmOk").click(function() {
595
+
596
+							      $("#alertMsgOverlay").remove();
597
+							      $("#alertConfMessage").remove();
598
+
599
+							      var rmvArplUrl = OC.generateUrl('/apps/sms_relentless/user/removeautoreplies');
600
+							      $.ajax({
601
+								   url: rmvArplUrl + '/' + userid,
602
+								   method: "POST",
603
+								   dataType: "text",
604
+								   data: { phoneNumber: crntPhnNmbr },
605
+								   success: function(delresult) {
606
+
607
+										     if (delresult.indexOf("success") > -1) {
608
+										         showAlert("The auto-reply has been removed successfully!");
609
+										         $("#arpphn-"+ slctRowRm).closest("tr").remove();
610
+										     } else if (delresult.indexOf("failure") > -1) {
611
+										         showAlert("Error while trying to remove auto-reply data!");
612
+										     } else if (delresult.indexOf("not allowed") > -1) {
613
+				                                                         showAlert("You cannot remove the auto-reply saved by another user.");
614
+				                                                     }
615
+								   },
616
+								   error: function() { showAlert("Error while attempting to remove auto-reply data! You can check the Nextcloud log to find more details about this issue."); }
617
+							       });
618
+							  });
619
+						       });
620
+						  }
621
+						  removeArplRow();
622
+
623
+				                  // Add a new row
624
+				                  $("#addArplRow").click(function() {
625
+
626
+				                     if ($("#autoReplyTbl").find("tr:last-child").find(".arplPhoneNmbr").length > 0) {
627
+				                         var lastarpl = $("#autoReplyTbl").find("tr:last-child").find(".arplPhoneNmbr").attr("id").replace("arpphn-", "");
628
+				                         var indArplAdd = parseInt(lastarpl + 1);
629
+				                     } else { var indArplAdd = 0; }
630
+						     $("#autoReplyTbl").append("<tr><td><input type='text' class='arplAuthor' value='"+ cusrDisplayName +"' disabled></td><td><select id='arpphn-"+ indArplAdd +"' class='arplPhoneNmbr'>"+ numbersListItems +"</select></td><td><div id='arplmode-"+ indArplAdd +"' class='arplMode'><select id='modeselect-"+ indArplAdd +"' class='selectArplMode'><option value='' selected>Select mode</option><option value='daily'>Daily mode</option><option value='vacation'>Vacation mode</option></select><div id='modecont-"+ indArplAdd +"' class='modeContent'></div></div></td><td><textarea id='arpltxt-"+ indArplAdd +"' class='arplText' rows='20' cols='40' placeholder='Enter the auto-reply message here.'></textarea></td><td><img id='rmRow-"+ indArplAdd +"' class='removeRow' src='/" + ctappdir + "/sms_relentless/img/closewnd.svg' title='Remove this row from the database' style='cursor:pointer;margin:9px 8px 0px 18px;'></td><td><input type='submit' id='arplsave-"+ indArplAdd +"' class='saveAutoReply' value='Save' title='Save Row' /></td></tr>");
631
+
632
+				                     selectMode();
633
+				                     saveArplRow();
634
+				                     removeArplRow();
635
+
636
+						     // Check if there is an auto-reply set for the same phone number
637
+						     $("#arpphn-"+ indArplAdd).change(function() {
638
+							 var selectedPhNb = $("#arpphn-"+ indArplAdd).val();
639
+							 var allArplPhNmbrs = $("#autoReplyTbl").find("tr").find(".arplPhoneNmbr");
640
+							 var phNbChck = 0;
641
+							 allArplPhNmbrs.each(function() {
642
+							    var slctphnb = ($(this).val())? $(this).val() : $(this).text();
643
+							    if (selectedPhNb == slctphnb) { phNbChck++; }
644
+							 });
645
+
646
+							 if (phNbChck == 2) {
647
+							     showAlert("There is already an auto-reply set up for this phone number. Please edit its own row, or choose a different phone number.");
648
+							     $(this).val('');
649
+							     return;
650
+							 }
651
+						     });
652
+				                  });
653
+
654
+				  },
655
+				  error: function() {
656
+				                    $("#autoRplPhoneNb").removeClass('icon-loading'); 
657
+				                    showAlert("Error while attempting to get the auto-reply settings! You can check the Nextcloud log to find more details about this issue.");
658
+				  }
659
+			 });
660
+
661
+		     },
662
+		     error: function() {
663
+				  showAlert('Error while getting the settings! You can check the Nextcloud log to find more details about this issue.');
664
+		     }
665
+		  });
666
+
667
+
668
+
669
+		  // Save personal settings for non-admin users
670
+		  $("#save_sms_settings").on("click", function(event) {
671
+
672
+		     if (isadm == 'reguser') {
673
+
674
+			    event.preventDefault();
675
+			    var baseUrlsave = OC.generateUrl('/apps/sms_relentless/user/updatesettings');
676
+
677
+			    var messagesperpageinit = $("#messagesperpage").val();
678
+			    var messagesperpagesec = messagesperpageinit.replace(/[^0-9]/g, '');
679
+			    var messagesperpageproc = 100;
680
+
681
+			    if (messagesperpagesec != '') {
682
+				if (messagesperpagesec > 0 && messagesperpagesec < 4294967296) {
683
+				    messagesperpageproc = messagesperpagesec;
684
+				} else { alert("The field 'Number of messages per page' must contain a number between 1 and 4294967295."); return; }
685
+			    }
686
+
687
+			    var msgcheckintervalinit = $("#msgcheckinterval").val();
688
+			    var msgcheckintervalsec = msgcheckintervalinit.replace(/[^0-9]/g, '');
689
+			    var msgsCheckInterval = 5;
690
+
691
+			    if (msgcheckintervalsec != '') {
692
+				if (msgcheckintervalsec > 0 && msgcheckintervalsec < 86401) {
693
+				    msgsCheckInterval = msgcheckintervalsec;
694
+				} else { alert("The field 'Time interval in seconds before checking if a new message has arrived' must contain a number between 1 and 86400."); return; }
695
+			    }
696
+
697
+			    var getnotify = 0;
698
+
699
+			    if ($("#get_notify").is(':checked')) {
700
+				getnotify = 1;
701
+			    }
702
+
703
+			    var emailaddressinit = $("#notification_email").val();
704
+
705
+			    function validate_email($email) {
706
+				var email_reg = /^([\w-\.]+@([\w-]+\.)+[\w-]{2,4})?$/;
707
+				return email_reg.test($email);
708
+			    }
709
+
710
+			    if (validate_email(emailaddressinit)) {
711
+				 var notifyemail = emailaddressinit;
712
+			    } else {
713
+				 var notifyemail = '';
714
+			    }
715
+
716
+			    var includesmsinemail = 0;
717
+			    if ($("#includesmsinemail").is(':checked')) {
718
+				includesmsinemail = 1;
719
+				if ($("#notification_email").val().trim() == '') {
720
+				    showAlert("Please enter an email address in the field: 'I want to receive a notification to the email address from below ...', or uncheck the checkbox: 'Include the SMS/MMS message in the email notification itself'.");
721
+				    return;
722
+				}
723
+			    }
724
+
725
+			    var showdisplaynm = 0;
726
+			    if ($("#showdisplaynames").is(':checked')) {
727
+				showdisplaynm = 1;
728
+			    }
729
+
730
+			    var adddisplaynm = 0;
731
+			    if ($("#adddisplaynames").is(':checked')) {
732
+				adddisplaynm = 1;
733
+			    }
734
+
735
+			    var datatosave = {
736
+					      userId: userid,
737
+					      telapiUrlRec: $("#telapi_url_rec").val(),
738
+					      telapiUrl: $("#telapi_url").val(),
739
+					      nexapiUrlRec: $("#nexapi_url_rec").val(),
740
+					      nexapiUrl: $("#nexapi_url").val(),
741
+					      twilapiUrlRec: $("#twilapi_url_rec").val(),
742
+					      twilapiUrl: $("#twilapi_url").val(),
743
+					      flowapiUrlRec: $("#flowapi_url_rec").val(),
744
+					      flowapiUrl: $("#flowapi_url").val(),
745
+					      messagesperpage: messagesperpageproc,
746
+		 	                      msgCheckInterval: msgsCheckInterval,
747
+					      getNotify: getnotify,
748
+					      notificationEmail: notifyemail,
749
+					      getsmsinemail: includesmsinemail,
750
+					      showDisplayNames: showdisplaynm,
751
+				              addDisplayNames: adddisplaynm
752
+			    };
753
+
754
+
755
+			    $.ajax({
756
+			       method: 'PUT',
757
+			       url: baseUrlsave + '/' + userid,
758
+			       contentType: 'application/json',
759
+			       data: JSON.stringify(datatosave),
760
+			       success: function() {
761
+				               OC.msg.startAction('#smsr_save_msg', t('sms_relentless', 'Saved'));
762
+			       },
763
+			       error: function() {
764
+				    showAlert('Error while attempting to save the settings! You can check the Nextcloud log to find more details about this issue.');
765
+			       }
766
+			    });
767
+
768
+
769
+		     } else if (isadm == 'admin') {
770
+
771
+			    // Save personal settings for admins
772
+			    event.preventDefault();
773
+			    var baseUrlsaveadm = OC.generateUrl('/apps/sms_relentless/user/updatepersadmnsettings');
774
+
775
+			    var messagesperpageinit = $("#messagesperpage").val();
776
+			    var messagesperpagesec = messagesperpageinit.replace(/[^0-9]/g, '');
777
+			    var messagesperpageproc = 100;
778
+
779
+			    if (messagesperpagesec != '') {
780
+				if (messagesperpagesec > 0 && messagesperpagesec < 4294967296) {
781
+				    messagesperpageproc = messagesperpagesec;
782
+				} else { alert("The field 'Number of messages per page' must contain a number between 1 and 4294967295."); return; }
783
+			    }
784
+
785
+			    var msgcheckintervalinit = $("#msgcheckinterval").val();
786
+			    var msgcheckintervalsec = msgcheckintervalinit.replace(/[^0-9]/g, '');
787
+			    var msgsCheckInterval = 5;
788
+
789
+			    if (msgcheckintervalsec != '') {
790
+				if (msgcheckintervalsec > 0 && msgcheckintervalsec < 86401) {
791
+				    msgsCheckInterval = msgcheckintervalsec;
792
+				} else { alert("The field 'Time interval in seconds before checking if a new message has arrived' must contain a number between 1 and 86400."); return; }
793
+			    }
794
+
795
+			    var getnotify = 0;
796
+
797
+			    if ($("#get_notify").is(':checked')) {
798
+				getnotify = 1;
799
+			    }
800
+
801
+			    var emailaddressinit = $("#notification_email").val();
802
+
803
+			    function validate_email($email) {
804
+				var email_reg = /^([\w-\.]+@([\w-]+\.)+[\w-]{2,4})?$/;
805
+				return email_reg.test($email);
806
+			    }
807
+
808
+			    if (validate_email(emailaddressinit)) {
809
+				 var notifyemail = emailaddressinit;
810
+			    } else {
811
+				 var notifyemail = '';
812
+			    }
813
+
814
+			    var includesmsinemail = 0;
815
+			    if ($("#includesmsinemail").is(':checked')) {
816
+				includesmsinemail = 1;
817
+				if ($("#notification_email").val().trim() == '') {
818
+				    showAlert("Please enter an email address in the field: 'I want to receive a notification to the email address from below ...', or uncheck the checkbox: 'Include the SMS/MMS message in the email notification itself'.");
819
+				    return;
820
+				}
821
+			    }
822
+
823
+			    var showdisplaynm = 0;
824
+			    if ($("#showdisplaynames").is(':checked')) {
825
+				showdisplaynm = 1;
826
+			    }
827
+
828
+			    var adddisplaynm = 0;
829
+			    if ($("#adddisplaynames").is(':checked')) {
830
+				adddisplaynm = 1;
831
+			    }
832
+
833
+			    var datatosave = {
834
+					      userId: userid,
835
+					      messagesperpage: messagesperpageproc,
836
+					      msgCheckInterval: msgsCheckInterval,
837
+					      getNotify: getnotify,
838
+					      notificationEmail: notifyemail,
839
+					      getsmsinemail: includesmsinemail,
840
+					      showDisplayNames: showdisplaynm,
841
+				              addDisplayNames: adddisplaynm
842
+			    };
843
+
844
+
845
+			    $.ajax({
846
+			       method: 'PUT',
847
+			       url: baseUrlsaveadm + '/' + userid,
848
+			       contentType: 'application/json',
849
+			       data: JSON.stringify(datatosave),
850
+			       success: function() {
851
+				               OC.msg.startAction('#smsr_save_msg', t('sms_relentless', 'Saved'));
852
+			       },
853
+			       error: function() {
854
+				    showAlert('Error while attempting to save the settings! You can check the Nextcloud log to find more details about this issue.');
855
+			       }
856
+			    });
857
+
858
+		     }
859
+		  });
860
+
861
+		  function showAlert(alertText) {
862
+
863
+		     let alertwnd = "<div id='alertMessage'>";
864
+		     alertwnd += "<a id='closeAlertWnd' title='Close this window'></a>";
865
+		     alertwnd += "<div id='alertTextWrap'>"+ alertText +"</div>";
866
+		     alertwnd += "<input type='submit' id='alertOk' value='OK'>";
867
+		     alertwnd += "</div>";
868
+
869
+		     $("#content").append("<div id='alertMsgOverlay'></div>");
870
+		     $("#content").append(alertwnd);
871
+
872
+		     let topDist = parseInt((window.innerHeight / 2).toFixed(2) - 152) +"px";
873
+		     let leftDist = parseInt((window.innerWidth / 2).toFixed(2) - 150) +"px";
874
+		     $("#alertMessage").css({ "top" : topDist, "left" : leftDist });
875
+
876
+		     $("#closeAlertWnd").click(function() { $("#alertMsgOverlay").remove(); $("#alertMessage").remove(); });
877
+		     $("#alertMsgOverlay").click(function() { $("#alertMsgOverlay").remove(); $("#alertMessage").remove(); });
878
+		     $("#alertOk").click(function() { $("#alertMsgOverlay").remove(); $("#alertMessage").remove(); });
879
+		  }
880
+
881
+		  function confirmAlert(alertText) {
882
+
883
+		     $("#alertMsgOverlay").remove();
884
+		     $("#alertConfMessage").remove();
885
+
886
+		     let alertwndcf = "<div id='alertConfMessage'>";
887
+		     alertwndcf += "<a id='closeAlertWndcf' title='Close this window'></a>";
888
+		     alertwndcf += "<div id='alertTextWrap'>"+ alertText +"</div>";
889
+		     alertwndcf += "<div id='cancelOkWrap'><input type='submit' id='confirmCancel' value='Cancel'>";
890
+		     alertwndcf += "<input type='submit' id='confirmOk' value='OK'></div>";
891
+		     alertwndcf += "</div>";
892
+
893
+		     $("#content").append("<div id='alertMsgOverlay'></div>");
894
+		     $("#content").append(alertwndcf);
895
+
896
+		     let topDist = parseInt((window.innerHeight / 2).toFixed(2) - 152) +"px";
897
+		     let leftDist = parseInt((window.innerWidth / 2).toFixed(2) - 150) +"px";
898
+		     $("#alertConfMessage").css({ "top" : topDist, "left" : leftDist });
899
+
900
+		     $("#closeAlertWndcf").click(function() { $("#alertMsgOverlay").remove(); $("#alertConfMessage").remove(); });
901
+		     $("#alertMsgOverlay").click(function() { $("#alertMsgOverlay").remove(); $("#alertConfMessage").remove(); });
902
+		  }
903
+
904
+
905
+     },
906
+     error: function(appdirfdb) {
907
+                alert("An error occurred while getting the app's directory. You can check the Nextcloud log to find more details about this issue.");
908
+     }
909
+   });
910
+
911
+});
Browse code

removed appinfo/info.xml appinfo/signature.json appinfo/routes.php CHANGELOG.txt README.md css/style.css js/settings.js js/sendsms.js js/adminsettings.js js/showsmstables.js templates/settings/admin.php templates/settings/personal.php templates/navigation/index.php lib/Controller/SmsrelentlessController.php lib/Service/SmsrelentlessService.php l10n/en_GB.js l10n/en_GB.json l10n/en_US.js l10n/en_US.json

DoubleBastionAdmin authored on 14/02/2024 22:37:16
Showing 1 changed files
1 1
deleted file mode 100644
... ...
@@ -1,866 +0,0 @@
1
-/**
2
- * @copyright 2021 Double Bastion LLC <www.doublebastion.com>
3
- *
4
- * @author Double Bastion LLC
5
- *
6
- * @license GNU AGPL version 3 or any later version
7
- *
8
- * This program is free software; you can redistribute it and/or
9
- * modify it under the terms of the GNU AFFERO GENERAL PUBLIC LICENSE
10
- * License as published by the Free Software Foundation; either
11
- * version 3 of the License, or any later version.
12
- *
13
- * This program is distributed in the hope that it will be useful,
14
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
15
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
16
- * GNU AFFERO GENERAL PUBLIC LICENSE for more details.
17
- *
18
- * You should have received a copy of the GNU Affero General Public
19
- * License along with this program.  If not, see <http://www.gnu.org/licenses/>.
20
- *
21
- */
22
-
23
-$(document).ready(function() {
24
-
25
-  var userid = "<?php p($userId); ?>";
26
-  var isadm = '';
27
-
28
-  // Get personal settings
29
-  var baseUrlget = OC.generateUrl('/apps/sms_relentless/user/getsettings');
30
-
31
-  $.ajax({
32
-     method: 'GET',
33
-     url: baseUrlget + '/' + userid,
34
-     contentType: 'application/json',
35
-     success: function(settingsfromdb) {
36
-
37
-         // Add the webhook URLs section, if the user is not an admin
38
-         if (settingsfromdb.adminornot == 'reguser') {
39
-
40
-             isadm = 'reguser';
41
-
42
-             $("#appTitlePrg").append('<p id="settings-dscr"><h3>Enter your options in the fields from below. As a non-admin user, you can use any of the SMS service providers from \
43
-                  below (Telnyx/Plivo/Twilio/Flowroute), on the condition that an admin has shared with you his API keys for that provider. If an admin has shared with you his API \
44
-                  keys for a provider, to be able to use them properly, you will have to generate the two webhook URLs for that provider by clicking the corresponding \
45
-                  "Generate new webhook URL ..." buttons from below, then click "Save" at the bottom of this page:</h3></p><br>');
46
-
47
-             $("#nadmProvSection").append('<div class="providerSettings"><p><label for="telapi_url_rec" class="setlabeltext"><b>Telnyx webhook URL for incoming SMS/MMS</b> (Generate \
48
-                  the URL by pressing the button from below. Don\'t forget to also click the \'Save\' button at the bottom of this page after entering all the options, to save \
49
-                  all the settings to the database.)</label></p> \
50
-                  <input type="button" id="generate_tel_rcpt" class="generateUrl" value="Generate new webhook URL for incoming SMS/MMS" /> \
51
-                  <input type="text" class="smsr_textboxspec" id="telapi_url_rec" name="telapi_url_rec" autocomplete="false" /> \
52
-                  <span id="copyToClipboardtel" class="icon icon-clippy" title="Copy to clipboard"></span><br><br> \
53
-                  \
54
-                  <p><label for="telapi_url" class="setlabeltext"><b>Telnyx webhook URL for delivery receipts</b> (This URL will be included by SMS Relentless in message sending \
55
-                  requests, so that Telnyx will know where to send the delivery receipts. Just generate it by pressing the button from below. Don\'t forget to click the \'Save\' \
56
-                  button at the bottom of this page after entering all the options, to save all the settings to the database.)</label></p> \
57
-                  <input type="button" id="generate_tel_delrcpt" class="generateUrl" value="Generate new webhook URL for delivery receipts" /> \
58
-                  <input type="text" id="telapi_url" name="telapi_url" autocomplete="false" /></div><br><br> \
59
-                  \
60
-                  <div class="providerSettings"><p><label for="nexapi_url_rec" class="setlabeltext"><b>Plivo webhook URL for incoming SMS/MMS</b> (Generate the URL by pressing \
61
-                  the button from below. Don\'t forget to also click the \'Save\' button at the bottom of this page after entering all the options, to save all the settings \
62
-                  to the database.)</label></p> \
63
-                  <input type="button" id="generate_nex_rcpt" class="generateUrl" value="Generate new webhook URL for incoming SMS/MMS" /> \
64
-                  <input type="text" class="smsr_textboxspec" id="nexapi_url_rec" name="nexapi_url_rec" autocomplete="false" /> \
65
-                  <span id="copyToClipboardnex" class="icon icon-clippy" title="Copy to clipboard"></span><br><br> \
66
-                  \
67
-                  <p><label for="nexapi_url" class="setlabeltext"><b>Plivo webhook URL for delivery receipts</b> (This URL will be included by SMS Relentless in message sending \
68
-                  requests, so that Plivo will know where to send the delivery receipts. Just generate it by pressing the button from below. Don\'t forget to click the \'Save\' \
69
-                  button at the bottom of this page after entering all the options, to save all the settings to the database.)</label></p> \
70
-                  <input type="button" id="generate_nex_delrcpt" class="generateUrl" value="Generate new webhook URL for delivery receipts" /> \
71
-                  <input type="text" id="nexapi_url" name="nexapi_url" autocomplete="false" /></div><br><br> \
72
-                  \
73
-                  <div class="providerSettings"><p><label for="twilapi_url_rec" class="setlabeltext"><b>Twilio webhook URL for incoming SMS/MMS</b> (Generate the URL by pressing \
74
-                  the button from below. Don\'t forget to also click the \'Save\' button at the bottom of this page after entering all the options, to save all the settings to \
75
-                  the database.)</label></p> \
76
-                  <input type="button" id="generate_twil_rcpt" class="generateUrl" value="Generate new webhook URL for incoming SMS/MMS" /> \
77
-                  <input type="text" class="smsr_textboxspec" id="twilapi_url_rec" name="twilapi_url_rec" autocomplete="false" /> \
78
-                  <span id="copyToClipboardtwil" class="icon icon-clippy" title="Copy to clipboard"></span><br><br> \
79
-                  \
80
-                  <p><label for="twilapi_url" class="setlabeltext"><b>Twilio webhook URL for delivery receipts</b> (This URL will be included by SMS Relentless in message sending \
81
-                  requests, so that Twilio will know where to send the delivery receipts. Just generate it by pressing the button from below. Don\'t forget to click the \'Save\' \
82
-                  button at the bottom of this page after entering all the options, to save all the settings to the database.)</label></p> \
83
-                  <input type="button" id="generate_twil_delrcpt" class="generateUrl" value="Generate new webhook URL for delivery receipts" /> \
84
-                  <input type="text" id="twilapi_url" name="twilapi_url" autocomplete="false" /></div><br><br> \
85
-                  \
86
-                  <div class="providerSettings"><p><label for="flowapi_url_rec" class="setlabeltext"><b>Flowroute webhook URL for incoming SMS/MMS</b> (Generate the URL by pressing \
87
-                  the button from below. Don\'t forget to also click the \'Save\' button at the bottom of this page after entering all the options, to save all the settings to \
88
-                  the database.)</label></p> \
89
-                  <input type="button" id="generate_flow_rcpt" class="generateUrl" value="Generate new webhook URL for incoming SMS/MMS" /> \
90
-                  <input type="text" class="smsr_textboxspec" id="flowapi_url_rec" name="flowapi_url_rec" autocomplete="false" /> \
91
-                  <span id="copyToClipboardflow" class="icon icon-clippy" title="Copy to clipboard"></span><br><br> \
92
-                  \
93
-                  <p><label for="flowapi_url" class="setlabeltext"><b>Flowroute webhook URL for delivery receipts</b> (This URL will be included by SMS Relentless in message sending \
94
-                  requests, so that Flowroute will know where to send the delivery receipts. Just generate it by pressing the button from below. Don\'t forget to click the \'Save\' \
95
-                  button at the bottom of this page after entering all the options, to save all the settings to the database.)</label></p> \
96
-                  <input type="button" id="generate_flow_delrcpt" class="generateUrl" value="Generate new webhook URL for delivery receipts" /> \
97
-                  <input type="text" id="flowapi_url" name="flowapi_url" autocomplete="false" /><br><br> \
98
-                  Flowroute only supports sending/receiving SMS/MMS messages within USA and Canada and it doesn\'t support Alphanumeric Sender IDs.</div><br>');
99
-
100
-
101
-		  $("#telapi_url_rec").val(settingsfromdb.telapi_url_rec);
102
-		  $("#telapi_url").val(settingsfromdb.telapi_url);
103
-		  $("#nexapi_url_rec").val(settingsfromdb.nexapi_url_rec);
104
-		  $("#nexapi_url").val(settingsfromdb.nexapi_url);
105
-		  $("#twilapi_url_rec").val(settingsfromdb.twilapi_url_rec);
106
-		  $("#twilapi_url").val(settingsfromdb.twilapi_url);
107
-		  $("#flowapi_url_rec").val(settingsfromdb.flowapi_url_rec);
108
-		  $("#flowapi_url").val(settingsfromdb.flowapi_url);
109
-		  $("#messagesperpage").val(settingsfromdb.messagesperpage);
110
-
111
-		  if (settingsfromdb.get_notify == 1) {
112
-		      $("#get_notify").attr('checked', true);
113
-		  } else {
114
-		      $("#get_notify").attr('checked', false);
115
-		  }
116
-
117
-		  $("#notification_email").val(settingsfromdb.notification_email);
118
-
119
-		  if (settingsfromdb.getsmsinemail == 1) {
120
-		      $("#includesmsinemail").attr('checked', true);
121
-		  } else {
122
-		      $("#includesmsinemail").attr('checked', false);
123
-		  }
124
-
125
-		  if (settingsfromdb.show_display_names == 1) {
126
-		      $("#showdisplaynames").attr('checked', true);
127
-		  } else {
128
-		      $("#showdisplaynames").attr('checked', false);
129
-		  }
130
-
131
-		  if (settingsfromdb.add_display_names == 1) {
132
-		      $("#adddisplaynames").attr('checked', true);
133
-		  } else {
134
-		      $("#adddisplaynames").attr('checked', false);
135
-		  }
136
-
137
-		  function randomStr(strlength) {
138
-			var fintext = "";
139
-			var keyspace = '0123456789abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ';
140
-			for (var i = 0; i < strlength; i++) {
141
-			     fintext += keyspace.charAt(Math.floor(Math.random() * keyspace.length));
142
-			}
143
-			return fintext;
144
-		  }
145
-
146
-		  $("#generate_tel_rcpt").on("click", function(event) {
147
-
148
-		     var teltokenrec = randomStr(70);
149
-		     var telnyxwhurlrec = window.location.origin + OC.generateUrl('/apps/sms_relentless/api/recsmstel?telrecparam=') + teltokenrec;
150
-
151
-		     $("#telapi_url_rec").val(telnyxwhurlrec);
152
-		  });
153
-
154
-		  $("#copyToClipboardtel").on("click", function(event) {
155
-		     var $tempEl = $("<input>");
156
-		     $("body").append($tempEl);
157
-		     $tempEl.val($("#telapi_url_rec").val()).select();
158
-		     document.execCommand("Copy");
159
-		     $tempEl.remove();
160
-		     showAlert("The link has been copied to your clipboard!");
161
-		  });
162
-
163
-		  $("#generate_tel_delrcpt").on("click", function(event) {
164
-
165
-		     var teltoken = randomStr(70);
166
-		     var telnyxwhurl = window.location.origin + OC.generateUrl('/apps/sms_relentless/api/recdeliverytel?teldrparam=') + teltoken;
167
-
168
-		     $("#telapi_url").val(telnyxwhurl);
169
-		  });
170
-
171
-
172
-		  $("#generate_nex_rcpt").on("click", function(event) {
173
-
174
-		     var plivotokenrec = randomStr(70);
175
-		     var plivowhurlrec = window.location.origin + OC.generateUrl('/apps/sms_relentless/api/recsmsnex?plivorecparam=') + plivotokenrec;
176
-
177
-		     $("#nexapi_url_rec").val(plivowhurlrec);
178
-		  });
179
-
180
-		  $("#copyToClipboardnex").on("click", function(event) {
181
-		     var $tempElpl = $("<input>");
182
-		     $("body").append($tempElpl);
183
-		     $tempElpl.val($("#nexapi_url_rec").val()).select();
184
-		     document.execCommand("Copy");
185
-		     $tempElpl.remove();
186
-		     showAlert("The link has been copied to your clipboard!");
187
-		  });
188
-
189
-		  $("#generate_nex_delrcpt").on("click", function(event) {
190
-
191
-		     var plivotoken = randomStr(70);
192
-		     var plivodrwhurl = window.location.origin + OC.generateUrl('/apps/sms_relentless/api/recdeliverynex?plivodrparam=') + plivotoken;
193
-
194
-		     $("#nexapi_url").val(plivodrwhurl);
195
-		  });
196
-
197
-
198
-		  $("#generate_twil_rcpt").on("click", function(event) {
199
-
200
-		     var twiltokenrec = randomStr(35);
201
-		     var twilwhurlrec = window.location.origin + OC.generateUrl('/apps/sms_relentless/api/recsmstwil?twilrecparam=') + twiltokenrec;
202
-
203
-		     $("#twilapi_url_rec").val(twilwhurlrec);
204
-		  });
205
-
206
-		  $("#copyToClipboardtwil").on("click", function(event) {
207
-		     var $tempElpl = $("<input>");
208
-		     $("body").append($tempElpl);
209
-		     $tempElpl.val($("#twilapi_url_rec").val()).select();
210
-		     document.execCommand("Copy");
211
-		     $tempElpl.remove();
212
-		     showAlert("The link has been copied to your clipboard!");
213
-		  });
214
-
215
-		  $("#generate_twil_delrcpt").on("click", function(event) {
216
-
217
-		     var twiltoken = randomStr(35);
218
-		     var twildrwhurl = window.location.origin + OC.generateUrl('/apps/sms_relentless/api/recdeliverytwil?twildrparam=') + twiltoken;
219
-
220
-		     $("#twilapi_url").val(twildrwhurl);
221
-		  });
222
-
223
-
224
-		  $("#generate_flow_rcpt").on("click", function(event) {
225
-
226
-		     var flowtokenrec = randomStr(70);
227
-		     var flowwhurlrec = window.location.origin + OC.generateUrl('/apps/sms_relentless/api/recsmsflow?flowrecparam=') + flowtokenrec;
228
-
229
-		     $("#flowapi_url_rec").val(flowwhurlrec);
230
-		  });
231
-
232
-		  $("#copyToClipboardflow").on("click", function(event) {
233
-		     var $tempElpl = $("<input>");
234
-		     $("body").append($tempElpl);
235
-		     $tempElpl.val($("#flowapi_url_rec").val()).select();
236
-		     document.execCommand("Copy");
237
-		     $tempElpl.remove();
238
-		     showAlert("The link has been copied to your clipboard!");
239
-		  });
240
-
241
-		  $("#generate_flow_delrcpt").on("click", function(event) {
242
-
243
-		     var flowtoken = randomStr(70);
244
-		     var flowdrwhurl = window.location.origin + OC.generateUrl('/apps/sms_relentless/api/recdeliveryflow?flowdrparam=') + flowtoken;
245
-
246
-		     $("#flowapi_url").val(flowdrwhurl);
247
-		  });
248
-
249
-
250
-         } else if (settingsfromdb.adminornot == 'admin') {
251
-
252
-                  $("#appTitlePrg").append('<p id="settings-dscr"><h3>First enter your credentials on the admin settings page of the app (on the left panel, under Administration, \
253
-                                            click on SMS Relentless), then enter your options in the fields from below:</h3></p><br>');
254
-                  isadm = 'admin';
255
-
256
-		  $("#messagesperpage").val(settingsfromdb.messagesperpage);
257
-
258
-		  if (settingsfromdb.get_notify == 1) {
259
-		      $("#get_notify").attr('checked', true);
260
-		  } else {
261
-		      $("#get_notify").attr('checked', false);
262
-		  }
263
-
264
-		  $("#notification_email").val(settingsfromdb.notification_email);
265
-
266
-		  if (settingsfromdb.getsmsinemail == 1) {
267
-		      $("#includesmsinemail").attr('checked', true);
268
-		  } else {
269
-		      $("#includesmsinemail").attr('checked', false);
270
-		  }
271
-
272
-		  if (settingsfromdb.show_display_names == 1) {
273
-		      $("#showdisplaynames").attr('checked', true);
274
-		  } else {
275
-		      $("#showdisplaynames").attr('checked', false);
276
-		  }
277
-
278
-		  if (settingsfromdb.add_display_names == 1) {
279
-		      $("#adddisplaynames").attr('checked', true);
280
-		  } else {
281
-		      $("#adddisplaynames").attr('checked', false);
282
-		  }
283
-         }
284
-
285
-
286
-         // Auto-reply settings
287
-
288
-         // Get the available phone numbers from all providers associated with the access keys entered on the Settings page (restrictions are applied to numbers for non-admins)
289
-         $("#autoRplPhoneNb").addClass('icon-loading');
290
-         var getnumbersUrl = OC.generateUrl("/apps/sms_relentless/user/getautoreplyconf");
291
-
292
-	 $.ajax({
293
-		  url: getnumbersUrl + '/' + userid,
294
-		  type: "GET",
295
-                  contentType: 'application/json',
296
-		  success: function(autoreplydata) {
297
-
298
-                                    $("#autoRplPhoneNb").removeClass('icon-loading');
299
-                                    var cusrDisplayName = autoreplydata.userdisplayname;
300
-                                    var availPhoneNmbrs = autoreplydata.phonenumbers;
301
-                                    var autorpldata = autoreplydata.autoreplies;
302
-
303
-				    if (autorpldata.length > 0) { 
304
-				        var arplNmb = autorpldata.length;
305
-				    } else { 
306
-				        var arplNmb = 0; 
307
-				    }
308
-
309
-				    // List the auto-replies for the phone numbers available for the current user
310
-				    if (arplNmb == 0) {
311
-
312
-				        $("#autoReplyTbl").append("<tr><td><input type='text' class='arplAuthor' value='"+ cusrDisplayName +"' disabled></td><td><select id='arpphn-"+ arplNmb +"' class='arplPhoneNmbr'></select></td><td><div id='arplmode-"+ arplNmb +"' class='arplMode'><select id='modeselect-"+ arplNmb +"' class='selectArplMode'><option value='' selected>Select mode</option><option value='daily'>Daily mode</option><option value='vacation'>Vacation mode</option></select><div id='modecont-"+ arplNmb +"' class='modeContent'></div></div></td><td><textarea id='arpltxt-"+ arplNmb +"' class='arplText' rows='20' cols='40' placeholder='Enter the auto-reply message here.'></textarea></td><td><img id='rmRow-"+ arplNmb +"' class='removeRow' src='/apps/sms_relentless/img/closewnd.svg' title='Remove this row from the database' style='cursor:pointer;margin:9px 8px 0px 18px;'></td><td><input type='submit' id='arplsave-"+ arplNmb +"' class='saveAutoReply' value='Save' title='Save Row' /></td></tr>");
313
-				        $("#autoReplyTbl").append("<div><img id='addArplRow' src='/apps/sms_relentless/img/add.svg' title='Add Row'></div>");
314
-
315
-				    } else {
316
-
317
-				        for (k = 0; k < arplNmb; k++) {
318
-
319
-                                             if (autorpldata[k].days_of_week != '') {
320
-
321
-                                                 var slctdMode = "<option value=''>Select mode</option><option value='daily' selected>Daily mode</option><option value='vacation'>Vacation mode</option>";
322
-                                                 var dailyStartArr = autorpldata[k].daily_start.split(":");
323
-                                                 var dailyEndArr = autorpldata[k].daily_end.split(":");
324
-
325
-		                                 var dlHrStartOptions = "";
326
-			                         for (var hr = 0; hr < 24; hr++) {
327
-		                                      if (dailyStartArr[0] != hr.toLocaleString('en-US', {minimumIntegerDigits: 2, useGrouping:false})) {
328
-			                                  dlHrStartOptions += "<option value='"+ hr.toLocaleString('en-US', {minimumIntegerDigits: 2, useGrouping:false}) +"'>"+ hr.toLocaleString('en-US', {minimumIntegerDigits: 2, useGrouping:false}) +"</option>";
329
-		                                      } else {
330
-			                                  dlHrStartOptions += "<option value='"+ hr.toLocaleString('en-US', {minimumIntegerDigits: 2, useGrouping:false}) +"' selected>"+ hr.toLocaleString('en-US', {minimumIntegerDigits: 2, useGrouping:false}) +"</option>";
331
-		                                      }
332
-			                         }
333
-
334
-		                                 var dlMnStartOptions = "";
335
-			                         for (var mn = 0; mn < 60; mn++) {
336
-		                                      if (dailyStartArr[1] != mn.toLocaleString('en-US', {minimumIntegerDigits: 2, useGrouping:false})) {
337
-			                                  dlMnStartOptions += "<option value='"+ mn.toLocaleString('en-US', {minimumIntegerDigits: 2, useGrouping:false}) +"'>"+ mn.toLocaleString('en-US', {minimumIntegerDigits: 2, useGrouping:false}) +"</option>";
338
-		                                      } else {
339
-			                                  dlMnStartOptions += "<option value='"+ mn.toLocaleString('en-US', {minimumIntegerDigits: 2, useGrouping:false}) +"' selected>"+ mn.toLocaleString('en-US', {minimumIntegerDigits: 2, useGrouping:false}) +"</option>";
340
-		                                      }
341
-			                         }
342
-
343
-		                                 var dlHrEndOptions = "";
344
-			                         for (var hr = 0; hr < 24; hr++) {
345
-		                                      if (dailyEndArr[0] != hr.toLocaleString('en-US', {minimumIntegerDigits: 2, useGrouping:false})) {
346
-			                                  dlHrEndOptions += "<option value='"+ hr.toLocaleString('en-US', {minimumIntegerDigits: 2, useGrouping:false}) +"'>"+ hr.toLocaleString('en-US', {minimumIntegerDigits: 2, useGrouping:false}) +"</option>";
347
-		                                      } else {
348
-			                                  dlHrEndOptions += "<option value='"+ hr.toLocaleString('en-US', {minimumIntegerDigits: 2, useGrouping:false}) +"' selected>"+ hr.toLocaleString('en-US', {minimumIntegerDigits: 2, useGrouping:false}) +"</option>";
349
-		                                      }
350
-			                         }
351
-
352
-		                                 var dlMnEndOptions = "";
353
-			                         for (var mn = 0; mn < 60; mn++) {
354
-		                                      if (dailyEndArr[1] != mn.toLocaleString('en-US', {minimumIntegerDigits: 2, useGrouping:false})) {
355
-			                                  dlMnEndOptions += "<option value='"+ mn.toLocaleString('en-US', {minimumIntegerDigits: 2, useGrouping:false}) +"'>"+ mn.toLocaleString('en-US', {minimumIntegerDigits: 2, useGrouping:false}) +"</option>";
356
-		                                      } else {
357
-			                                  dlMnEndOptions += "<option value='"+ mn.toLocaleString('en-US', {minimumIntegerDigits: 2, useGrouping:false}) +"' selected>"+ mn.toLocaleString('en-US', {minimumIntegerDigits: 2, useGrouping:false}) +"</option>";
358
-		                                      }
359
-			                         }
360
-
361
-                                                 var modeContent = "<div class='daysOfWeek'>Days of the week:<div class='tooltipautoreply'><div id='infoautoreply'>i</div><div class='autorpltooltip'>Enter the order number of the days of the week in which the auto-reply will be sent. For example, to send the auto-reply every day from Monday to Friday outside the time interval specified below, enter 1,2,3,4,5 To send the auto-reply only Monday, Thursday and Friday enter 1,4,5 To send the auto-reply every day of the week enter 1,2,3,4,5,6,7 As an exception, if you want the auto-reply to be sent during an entire day, irrespective of the specified interval, add (full) after the number of that day. For example, if you want the auto-reply to be sent from Monday to Friday outside the interval specified below, and also during the entire days of Saturday and Sunday, enter 1,2,3,4,5,6(full),7(full)</div></div></div><input type='text' id='weekdays-"+ k +"' class='daysInWeek' value='"+ autorpldata[k].days_of_week +"'><div class='chooseTInterval'>Send auto-reply <span style='color:#ad0202'>outside</span> this interval:<div class='tooltipautoreplyst'><div id='infoautoreplyst'>i</div><div class='autorpltooltipst'>These fields specify the time of the server. If the server is located in a time zone that is different from that of the owner/company, the time interval entered here should be adjusted accordingly.</div></div></div><div class='selectArplHours'><select id='dmstarthr-"+ k +"' class='selectHrMin'>"+ dlHrStartOptions +"</select><select id='dmstartmn-"+ k +"' class='selectHrMin'>"+ dlMnStartOptions +"</select><span style='font-weight: 600'> — </span><select id='dmendhr-"+ k +"' class='selectHrMin'>"+ dlHrEndOptions +"</select><select id='dmendmn-"+ k +"' class='selectHrMin'>"+ dlMnEndOptions +"</select></div>";
362
-
363
-                                             } else {
364
-
365
-                                                 var vctnStart = autorpldata[k].vacation_start.split(" ")[0];
366
-                                                 var vctnEnd = autorpldata[k].vacation_end.split(" ")[0];
367
-
368
-                                                 var slctdMode = "<option value=''>Select mode</option><option value='daily'>Daily mode</option><option value='vacation' selected>Vacation mode</option>";
369
-                                                 var modeContent = "<div class='chooseDateIntvl'>Send auto-reply <span style='color:#ad0202'>inside</span> this interval:</div><div class='arplstrtendDates'><div class='stdtTitle'>Start Date</div><input type='text' id='startDT-"+ k +"' class='startDate' placeholder='Pick a date' value='"+ vctnStart +"'><div class='enddtTitle'>End Date</div><input type='text' id='endDT-"+ k +"' class='endDate' placeholder='Pick a date' value='"+ vctnEnd +"'></div>"
370
-                                             }
371
-
372
-				             $("#autoReplyTbl").append("<tr><td><input type='text' class='arplAuthor' value='"+ autorpldata[k].saved_by_dsplname +"' disabled></td><td><select id='arpphn-"+ k +"' class='arplPhoneNmbr' style='pointer-events:none'><option selected>"+ autorpldata[k].phone_number +"</option></select></td><td><div id='arplmode-"+ k +"' class='arplMode'><select id='modeselect-"+ k +"' class='selectArplMode'>"+ slctdMode +"</select><div id='modecont-"+ k +"' class='modeContent'>"+ modeContent +"</div></div></td><td><textarea id='arpltxt-"+ k +"' class='arplText' rows='20' cols='40' placeholder='Enter the auto-reply message here.'>"+ autorpldata[k].message_text +"</textarea></td><td><img id='rmRow-"+ k +"' class='removeRow' src='/apps/sms_relentless/img/closewnd.svg' title='Remove this row from the database' style='cursor:pointer;margin:9px 8px 0px 18px;'></td><td><input type='submit' id='arplsave-"+ k +"' class='saveAutoReply' value='Edit' title='Edit Row' /></td></tr>");
373
-				        }
374
-				        $("#autoReplyTbl").append("<div><img id='addArplRow' src='/apps/sms_relentless/img/add.svg' title='Add Row'></div>");
375
-				    }
376
-
377
-
378
-				    // Create a list with all the available phone numbers
379
-                                    var numbersListItems = "<option value='' selected>Select phone number</option>";
380
-
381
-				    $.each(availPhoneNmbrs, function(key, indsmsnmb) {
382
-				           numbersListItems += "<option value='"+ indsmsnmb +"'>"+ indsmsnmb +"</option>";
383
-				    });
384
-
385
-                                    if (arplNmb == 0) {
386
-				        $("#arpphn-"+ arplNmb).append(numbersListItems);
387
-                                    }
388
-
389
-                                    // Initialize the date picker
390
-			            $('[id^="endDT-"]').datepicker({ dateFormat: "yy-mm-dd" });
391
-			            $('[id^="startDT-"]').datepicker({ dateFormat: "yy-mm-dd" });
392
-
393
-
394
-                                    // Select the auto-reply mode
395
-                                    function selectMode() {
396
-
397
-		                            $('[id^="modeselect-"]').change(function() {
398
-
399
-		                               var crtnmbr = $(this).attr("id").replace("modeselect-", "");
400
-
401
-		                               var dailyHrStart = "";
402
-		                               for (var h = 0; h < 24; h++) {
403
-		                                    dailyHrStart += "<option value='"+ h.toLocaleString('en-US', {minimumIntegerDigits: 2, useGrouping:false}) +"'>"+ h.toLocaleString('en-US', {minimumIntegerDigits: 2, useGrouping:false}) +"</option>";
404
-		                               }
405
-
406
-		                               var dailyMnStart = "";
407
-		                               for (var m = 0; m < 60; m++) {
408
-		                                    dailyMnStart += "<option value='"+ m.toLocaleString('en-US', {minimumIntegerDigits: 2, useGrouping:false}) +"'>"+ m.toLocaleString('en-US', {minimumIntegerDigits: 2, useGrouping:false}) +"</option>";
409
-		                               }
410
-
411
-		                               var dailyHrEnd = dailyHrStart;
412
-		                               var dailyMnEnd = dailyMnStart;
413
-
414
-		                               if ($(this).val() == 'daily') {
415
-		                                   $("#modecont-"+ crtnmbr).empty();
416
-		                                   $("#modecont-"+ crtnmbr).append("<div class='daysOfWeek'>Days of the week:<div class='tooltipautoreply'><div id='infoautoreply'>i</div><div class='autorpltooltip'>Enter the order number of the days of the week in which the auto-reply will be sent. For example, to send the auto-reply every day from Monday to Friday outside the time interval specified below, enter 1,2,3,4,5 To send the auto-reply only Monday, Thursday and Friday enter 1,4,5 To send the auto-reply every day of the week enter 1,2,3,4,5,6,7 As an exception, if you want the auto-reply to be sent during an entire day, irrespective of the specified interval, add (full) after the number of that day. For example, if you want the auto-reply to be sent from Monday to Friday outside the interval specified below, and also during the entire days of Saturday and Sunday, enter 1,2,3,4,5,6(full),7(full)</div></div></div><input type='text' id='weekdays-"+ crtnmbr +"' class='daysInWeek'><div class='chooseTInterval'>Send auto-reply <span style='color:#ad0202'>outside</span> this interval:<div class='tooltipautoreplyst'><div id='infoautoreplyst'>i</div><div class='autorpltooltipst'>These fields specify the time of the server. If the server is located in a time zone that is different from that of the owner/company, the time interval entered here should be adjusted accordingly.</div></div></div><div class='selectArplHours'><select id='dmstarthr-"+ crtnmbr +"' class='selectHrMin'>"+ dailyHrStart +"</select><select id='dmstartmn-"+ crtnmbr +"' class='selectHrMin'>"+ dailyMnStart +"</select><span style='font-weight: 600'> — </span><select id='dmendhr-"+ crtnmbr +"' class='selectHrMin'>"+ dailyHrEnd +"</select><select id='dmendmn-"+ crtnmbr +"' class='selectHrMin'>"+ dailyMnEnd +"</select></div>");
417
-		                               } else if ($(this).val() == 'vacation') {
418
-		                                   $("#modecont-"+ crtnmbr).empty();
419
-		                                   $("#modecont-"+ crtnmbr).append("<div class='chooseDateIntvl'>Send auto-reply <span style='color:#ad0202'>inside</span> this interval:</div><div class='arplstrtendDates'><div class='stdtTitle'>Start Date</div><input type='text' id='startDT-"+ crtnmbr +"' class='startDate' placeholder='Pick a date'><div class='enddtTitle'>End Date</div><input type='text' id='endDT-"+ crtnmbr +"' class='endDate' placeholder='Pick a date' /></div>");
420
-		                               }
421
-
422
-					       $("#endDT-"+ crtnmbr +"").datepicker({ dateFormat: "yy-mm-dd" });
423
-					       $("#startDT-"+ crtnmbr +"").datepicker({ dateFormat: "yy-mm-dd" });
424
-		                          });
425
-                                  }
426
-                                  selectMode();
427
-
428
-				  // Save the data
429
-				  function saveArplRow() {
430
-
431
-				     $('[id^="arplsave-"]').unbind("click");
432
-				     $('[id^="arplsave-"]').click(function(event) {
433
-
434
-				        event.preventDefault();
435
-				        var crntrwnmbr = $(this).attr("id").replace("arplsave-", "");
436
-
437
-				        if ($(this).attr("value") == "Save") {
438
-
439
-				            var phoneNmbr = $("#arpphn-"+ crntrwnmbr).val();
440
-				            var arplText = $("#arpltxt-"+ crntrwnmbr).val();
441
-				            var slctdMode = $("#modeselect-"+ crntrwnmbr).val();
442
-
443
-				            var slctddmDays = "";
444
-				            var slctdHrStart = "";
445
-				            var slctdMnStart = "";
446
-				            var slctdHrEnd = "";
447
-				            var slctdMnEnd = "";
448
-
449
-				            var vcStartDate = null;
450
-				            var vcEndDate = null;
451
-
452
-				            if (slctdMode == 'daily') {
453
-
454
-				                slctddmDays = $("#weekdays-"+ crntrwnmbr).val().trim();
455
-				                slctdHrStart = $("#dmstarthr-"+ crntrwnmbr).val().trim();
456
-				                slctdMnStart = $("#dmstartmn-"+ crntrwnmbr).val().trim();
457
-				                slctdHrEnd = $("#dmendhr-"+ crntrwnmbr).val().trim();
458
-				                slctdMnEnd = $("#dmendmn-"+ crntrwnmbr).val().trim();
459
-
460
-                                                if (slctdHrStart != '' && slctdMnStart != '') {
461
-                                                    var hrmnStartComp = slctdHrStart +":"+ slctdMnStart;
462
-                                                } else { var hrmnStartComp = ""; }
463
-
464
-                                                if (slctdHrEnd != '' && slctdMnEnd != '') {
465
-                                                    var hrmnEndComp = slctdHrEnd +":"+ slctdMnEnd;
466
-                                                } else { var hrmnEndComp = ""; }
467
-
468
-                                                if (!(/^[1-7ful\,\(\)]+$/.test(slctddmDays))) {
469
-				                    showAlert("The 'Days of the week' field can contain only digits from 1 to 7, the lowercase letters f, u and l, round brackets ()() and commas (,).");
470
-				                    return;
471
-                                                }
472
-
473
-                                                if (!(/^[0-9]+$/.test(slctdHrStart + slctdMnStart + slctdHrEnd + slctdMnEnd))) {
474
-				                    showAlert("The starting and ending values of the time interval for the 'Daily mode' can contain only digits from 0 to 9.");
475
-				                    return;
476
-                                                }
477
-
478
-                                                if (slctddmDays.trim() == '' || (slctdHrStart == slctdHrEnd && slctdMnStart == slctdMnEnd)) {
479
-				                    showAlert("For the 'Daily mode', you have to enter the order number of the days of the week for which you want the auto-reply to be sent, and you have to set a starting time that is different from the ending time!");
480
-				                    return;
481
-                                                }
482
-
483
-				            } else if (slctdMode == 'vacation') {
484
-		
485
-                                                if ($("#startDT-"+ crntrwnmbr).val().trim() == '' || $("#endDT-"+ crntrwnmbr).val().trim() == '') {
486
-
487
-				                    showAlert("For the 'Vacation mode', you have to enter both a start date and an end date.");
488
-				                    return;
489
-
490
-                                                } else {
491
-
492
-                                                    if (!(/^[0-9\-]+$/.test($("#startDT-"+ crntrwnmbr).val().trim() + $("#endDT-"+ crntrwnmbr).val().trim()))) {
493
-				                        showAlert("The start date and end date values for the 'Vacation mode' can contain only digits from 0 to 9 and hyphens (-).");
494
-				                        return;
495
-                                                    }
496
-
497
-		                                    vcStartDate = $("#startDT-"+ crntrwnmbr).val().trim() +" 00:00:00";
498
-				                    vcEndDate = $("#endDT-"+ crntrwnmbr).val().trim() +" 23:59:59";
499
-				                    var strtDateCmp = new Date(vcStartDate).toJSON().slice(0, 10) +" 00:00:00";
500
-				                    var endDateCmp = new Date(vcEndDate).toJSON().slice(0, 10) +" 23:59:59";
501
-				                    var crntDate = new Date().toJSON().slice(0, 10) +" 23:59:59";
502
-
503
-                                                    if (vcStartDate.trim() == "" || vcEndDate.trim() == "" || (strtDateCmp >= endDateCmp || ((strtDateCmp < crntDate) && (endDateCmp < crntDate)))) {
504
-				                        showAlert("For 'Vacation mode', you have to enter both a start date and an end date, the start date must be before the end date and at least the ending of the time interval must be in the future.");
505
-				                        return;
506
-                                                    }
507
-                                                }
508
-				            }
509
-
510
-
511
-				            if (phoneNmbr != '') {
512
-
513
-				              if (arplText.trim() != '') {
514
-
515
-				                if (slctdMode != '') {
516
-
517
-				                    var saveArplUrl = OC.generateUrl('/apps/sms_relentless/user/updateautoreplies');
518
-				                    var arpldata = {
519
-				                         userId: userid,
520
-				                         savedByDsplname: cusrDisplayName,
521
-				                         phoneNumber: phoneNmbr,
522
-				                         daysOfWeek: slctddmDays,
523
-				                         dailyStart: hrmnStartComp,
524
-				                         dailyEnd: hrmnEndComp,
525
-				                         vacationStart: vcStartDate,
526
-				                         vacationEnd: vcEndDate,
527
-				                         messageText: arplText
528
-				                    };
529
-
530
-					            $.ajax({
531
-					              method: 'PUT',
532
-					              url: saveArplUrl + '/' + userid,
533
-					              contentType: 'application/json',
534
-					              data: JSON.stringify(arpldata),
535
-				                      success: function(messagereceived) {
536
-
537
-				                                   if (messagereceived == 'success') {
538
-				                                       showAlert('The auto-reply has been successfully saved to the database!');
539
-				                                   } else if (messagereceived == 'failure') {
540
-				                                       showAlert('Error while trying to save the auto-reply!');
541
-				                                   } else if (messagereceived == 'not allowed') {
542
-                                                                       showAlert('You cannot change an auto-reply that was saved by a different user.');
543
-                                                                   }
544
-				                      },
545
-					              error: function() {
546
-						                   showAlert('Error while attempting to save the auto-reply! You can check the Nextcloud log to find more details about this issue.');
547
-					              }
548
-					            });
549
-
550
-
551
-                                                } else { showAlert("Please select the auto-reply mode."); return; }
552
-
553
-                                              } else { showAlert("Please enter the text of the auto-reply."); return; }
554
-
555
-                                            } else { showAlert("Please select a phone number if at least one number is available in the 'Phone Number' drop-down list. Otherwise, you should contact the administrator."); return; }
556
-
557
-                                            $(this).attr("value", "Edit");
558
-
559
-                                        } else {
560
-                                            $("#arplsave-"+ crntrwnmbr).attr("value", "Save");
561
-                                        }
562
-
563
-                                     });
564
-
565
-				  }
566
-                                  saveArplRow();
567
-
568
-
569
-				  // Remove a row
570
-				  function removeArplRow() {
571
-				       $('[id^="rmRow-"]').click(function() {
572
-
573
-					  var slctRowRm = $(this).attr("id").replace("rmRow-", "");
574
-					  var crntPhnNmbr = $("#arpphn-"+ slctRowRm).val();
575
-
576
-				          confirmAlert("Do you really want to remove this row from the database ?");
577
-
578
-				          $("#confirmCancel").click(function() { $("#alertMsgOverlay").remove(); $("#alertConfMessage").remove(); });
579
-
580
-				          $("#confirmOk").click(function() {
581
-
582
-				              $("#alertMsgOverlay").remove();
583
-				              $("#alertConfMessage").remove();
584
-
585
-					      var rmvArplUrl = OC.generateUrl('/apps/sms_relentless/user/removeautoreplies');
586
-					      $.ajax({
587
-						   url: rmvArplUrl + '/' + userid,
588
-						   method: "POST",
589
-						   dataType: "text",
590
-						   data: { phoneNumber: crntPhnNmbr },
591
-						   success: function(delresult) {
592
-
593
-						                     if (delresult.indexOf("success") > -1) {
594
-						                         showAlert("The auto-reply has been removed successfully!");
595
-						                         $("#arpphn-"+ slctRowRm).closest("tr").remove();
596
-						                     } else if (delresult.indexOf("failure") > -1) {
597
-						                         showAlert("Error while trying to remove auto-reply data!");
598
-						                     } else if (delresult.indexOf("not allowed") > -1) {
599
-                                                                         showAlert("You cannot remove the auto-reply saved by another user.");
600
-                                                                     }
601
-						   },
602
-						   error: function() { showAlert("Error while attempting to remove auto-reply data! You can check the Nextcloud log to find more details about this issue."); }
603
-					       });
604
-					  });
605
-				       });
606
-				  }
607
-				  removeArplRow();
608
-
609
-                                  // Add a new row
610
-                                  $("#addArplRow").click(function() {
611
-
612
-                                     if ($("#autoReplyTbl").find("tr:last-child").find(".arplPhoneNmbr").length > 0) {
613
-                                         var lastarpl = $("#autoReplyTbl").find("tr:last-child").find(".arplPhoneNmbr").attr("id").replace("arpphn-", "");
614
-                                         var indArplAdd = parseInt(lastarpl + 1);
615
-                                     } else { var indArplAdd = 0; }
616
-			             $("#autoReplyTbl").append("<tr><td><input type='text' class='arplAuthor' value='"+ cusrDisplayName +"' disabled></td><td><select id='arpphn-"+ indArplAdd +"' class='arplPhoneNmbr'>"+ numbersListItems +"</select></td><td><div id='arplmode-"+ indArplAdd +"' class='arplMode'><select id='modeselect-"+ indArplAdd +"' class='selectArplMode'><option value='' selected>Select mode</option><option value='daily'>Daily mode</option><option value='vacation'>Vacation mode</option></select><div id='modecont-"+ indArplAdd +"' class='modeContent'></div></div></td><td><textarea id='arpltxt-"+ indArplAdd +"' class='arplText' rows='20' cols='40' placeholder='Enter the auto-reply message here.'></textarea></td><td><img id='rmRow-"+ indArplAdd +"' class='removeRow' src='/apps/sms_relentless/img/closewnd.svg' title='Remove this row from the database' style='cursor:pointer;margin:9px 8px 0px 18px;'></td><td><input type='submit' id='arplsave-"+ indArplAdd +"' class='saveAutoReply' value='Save' title='Save Row' /></td></tr>");
617
-
618
-                                     selectMode();
619
-                                     saveArplRow();
620
-                                     removeArplRow();
621
-
622
-			             // Check if there is an auto-reply set for the same phone number
623
-				     $("#arpphn-"+ indArplAdd).change(function() {
624
-					 var selectedPhNb = $("#arpphn-"+ indArplAdd).val();
625
-					 var allArplPhNmbrs = $("#autoReplyTbl").find("tr").find(".arplPhoneNmbr");
626
-					 var phNbChck = 0;
627
-					 allArplPhNmbrs.each(function() {
628
-					    var slctphnb = ($(this).val())? $(this).val() : $(this).text();
629
-					    if (selectedPhNb == slctphnb) { phNbChck++; }
630
-					 });
631
-
632
-					 if (phNbChck == 2) {
633
-					     showAlert("There is already an auto-reply set up for this phone number. Please edit its own row, or choose a different phone number.");
634
-					     $(this).val('');
635
-					     return;
636
-					 }
637
-				     });
638
-                                  });
639
-
640
-		  },
641
-		  error: function() {
642
-                                    $("#autoRplPhoneNb").removeClass('icon-loading'); 
643
-                                    showAlert("Error while attempting to get the auto-reply settings! You can check the Nextcloud log to find more details about this issue.");
644
-                  }
645
-         });
646
-
647
-     },
648
-     error: function() {
649
-                  showAlert('Error while getting the settings! You can check the Nextcloud log to find more details about this issue.');
650
-     }
651
-  });
652
-
653
-
654
-
655
-  // Save personal settings for non-admin users
656
-  $("#save_sms_settings").on("click", function(event) {
657
-
658
-     if (isadm == 'reguser') {
659
-
660
-	    event.preventDefault();
661
-	    var baseUrlsave = OC.generateUrl('/apps/sms_relentless/user/updatesettings');
662
-
663
-	    var messagesperpageinit = $("#messagesperpage").val();
664
-	    var messagesperpagesec = messagesperpageinit.replace(/[^0-9]/g, '');
665
-
666
-	    if (messagesperpagesec != '') {
667
-		var messagesperpageproc = messagesperpagesec;
668
-	    } else {
669
-		var messagesperpageproc = 100;
670
-	    }
671
-
672
-	    var getnotify = 0;
673
-
674
-	    if ($("#get_notify").is(':checked')) {
675
-		getnotify = 1;
676
-	    }
677
-
678
-	    var emailaddressinit = $("#notification_email").val();
679
-
680
-	    function validate_email($email) {
681
-		var email_reg = /^([\w-\.]+@([\w-]+\.)+[\w-]{2,4})?$/;
682
-		return email_reg.test($email);
683
-	    }
684
-
685
-	    if (validate_email(emailaddressinit)) {
686
-		 var notifyemail = emailaddressinit;
687
-	    } else {
688
-		 var notifyemail = '';
689
-	    }
690
-
691
-	    var includesmsinemail = 0;
692
-	    if ($("#includesmsinemail").is(':checked')) {
693
-		includesmsinemail = 1;
694
-                if ($("#notification_email").val().trim() == '') {
695
-                    showAlert("Please enter an email address in the field: 'I want to receive a notification to the email address from below ...', or uncheck the checkbox: 'Include the SMS/MMS message in the email notification itself'.");
696
-                    return;
697
-                }
698
-	    }
699
-
700
-	    var showdisplaynm = 0;
701
-	    if ($("#showdisplaynames").is(':checked')) {
702
-		showdisplaynm = 1;
703
-	    }
704
-
705
-	    var adddisplaynm = 0;
706
-	    if ($("#adddisplaynames").is(':checked')) {
707
-		adddisplaynm = 1;
708
-	    }
709
-
710
-	    var datatosave = {
711
-			      userId: userid,
712
-		              telapiUrlRec: $("#telapi_url_rec").val(),
713
-		              telapiUrl: $("#telapi_url").val(),
714
-		              nexapiUrlRec: $("#nexapi_url_rec").val(),
715
-		              nexapiUrl: $("#nexapi_url").val(),
716
-		              twilapiUrlRec: $("#twilapi_url_rec").val(),
717
-		              twilapiUrl: $("#twilapi_url").val(),
718
-		              flowapiUrlRec: $("#flowapi_url_rec").val(),
719
-		              flowapiUrl: $("#flowapi_url").val(),
720
-			      messagesperpage: messagesperpageproc,
721
-			      getNotify: getnotify,
722
-			      notificationEmail: notifyemail,
723
-			      getsmsinemail: includesmsinemail,
724
-			      showDisplayNames: showdisplaynm,
725
-                              addDisplayNames: adddisplaynm
726
-	    };
727
-
728
-
729
-	    $.ajax({
730
-	       method: 'PUT',
731
-	       url: baseUrlsave + '/' + userid,
732
-	       contentType: 'application/json',
733
-	       data: JSON.stringify(datatosave),
734
-	       success: function() {
735
-                               OC.msg.startAction('#smsr_save_msg', t('sms_relentless', 'Saved'));
736
-	       },
737
-	       error: function() {
738
-		    showAlert('Error while attempting to save the settings! You can check the Nextcloud log to find more details about this issue.');
739
-	       }
740
-	    });
741
-
742
-
743
-     } else if (isadm == 'admin') {
744
-
745
-	    // Save personal settings for admins
746
-	    event.preventDefault();
747
-	    var baseUrlsaveadm = OC.generateUrl('/apps/sms_relentless/user/updatepersadmnsettings');
748
-
749
-	    var messagesperpageinit = $("#messagesperpage").val();
750
-	    var messagesperpagesec = messagesperpageinit.replace(/[^0-9]/g, '');
751
-
752
-	    if (messagesperpagesec != '') {
753
-		var messagesperpageproc = messagesperpagesec;
754
-	    } else {
755
-		var messagesperpageproc = 100;
756
-	    }
757
-
758
-	    var getnotify = 0;
759
-
760
-	    if ($("#get_notify").is(':checked')) {
761
-		getnotify = 1;
762
-	    }
763
-
764
-	    var emailaddressinit = $("#notification_email").val();
765
-
766
-	    function validate_email($email) {
767
-		var email_reg = /^([\w-\.]+@([\w-]+\.)+[\w-]{2,4})?$/;
768
-		return email_reg.test($email);
769
-	    }
770
-
771
-	    if (validate_email(emailaddressinit)) {
772
-		 var notifyemail = emailaddressinit;
773
-	    } else {
774
-		 var notifyemail = '';
775
-	    }
776
-
777
-	    var includesmsinemail = 0;
778
-	    if ($("#includesmsinemail").is(':checked')) {
779
-		includesmsinemail = 1;
780
-                if ($("#notification_email").val().trim() == '') {
781
-                    showAlert("Please enter an email address in the field: 'I want to receive a notification to the email address from below ...', or uncheck the checkbox: 'Include the SMS/MMS message in the email notification itself'.");
782
-                    return;
783
-                }
784
-	    }
785
-
786
-	    var showdisplaynm = 0;
787
-	    if ($("#showdisplaynames").is(':checked')) {
788
-		showdisplaynm = 1;
789
-	    }
790
-
791
-	    var adddisplaynm = 0;
792
-	    if ($("#adddisplaynames").is(':checked')) {
793
-		adddisplaynm = 1;
794
-	    }
795
-
796
-	    var datatosave = {
797
-			      userId: userid,
798
-			      messagesperpage: messagesperpageproc,
799
-			      getNotify: getnotify,
800
-			      notificationEmail: notifyemail,
801
-			      getsmsinemail: includesmsinemail,
802
-			      showDisplayNames: showdisplaynm,
803
-                              addDisplayNames: adddisplaynm
804
-	    };
805
-
806
-
807
-	    $.ajax({
808
-	       method: 'PUT',
809
-	       url: baseUrlsaveadm + '/' + userid,
810
-	       contentType: 'application/json',
811
-	       data: JSON.stringify(datatosave),
812
-	       success: function() {
813
-                               OC.msg.startAction('#smsr_save_msg', t('sms_relentless', 'Saved'));
814
-	       },
815
-	       error: function() {
816
-		    showAlert('Error while attempting to save the settings! You can check the Nextcloud log to find more details about this issue.');
817
-	       }
818
-	    });
819
-
820
-     }
821
-  });
822
-
823
-  function showAlert(alertText) {
824
-
825
-     let alertwnd = "<div id='alertMessage'>";
826
-     alertwnd += "<a id='closeAlertWnd' title='Close this window'></a>";
827
-     alertwnd += "<div id='alertTextWrap'>"+ alertText +"</div>";
828
-     alertwnd += "<input type='submit' id='alertOk' value='OK'>";
829
-     alertwnd += "</div>";
830
-
831
-     $("#content").append("<div id='alertMsgOverlay'></div>");
832
-     $("#content").append(alertwnd);
833
-
834
-     let topDist = parseInt((window.innerHeight / 2).toFixed(2) - 152) +"px";
835
-     let leftDist = parseInt((window.innerWidth / 2).toFixed(2) - 150) +"px";
836
-     $("#alertMessage").css({ "top" : topDist, "left" : leftDist });
837
-
838
-     $("#closeAlertWnd").click(function() { $("#alertMsgOverlay").remove(); $("#alertMessage").remove(); });
839
-     $("#alertMsgOverlay").click(function() { $("#alertMsgOverlay").remove(); $("#alertMessage").remove(); });
840
-     $("#alertOk").click(function() { $("#alertMsgOverlay").remove(); $("#alertMessage").remove(); });
841
-  }
842
-
843
-  function confirmAlert(alertText) {
844
-
845
-     $("#alertMsgOverlay").remove();
846
-     $("#alertConfMessage").remove();
847
-
848
-     let alertwndcf = "<div id='alertConfMessage'>";
849
-     alertwndcf += "<a id='closeAlertWndcf' title='Close this window'></a>";
850
-     alertwndcf += "<div id='alertTextWrap'>"+ alertText +"</div>";
851
-     alertwndcf += "<div id='cancelOkWrap'><input type='submit' id='confirmCancel' value='Cancel'>";
852
-     alertwndcf += "<input type='submit' id='confirmOk' value='OK'></div>";
853
-     alertwndcf += "</div>";
854
-
855
-     $("#content").append("<div id='alertMsgOverlay'></div>");
856
-     $("#content").append(alertwndcf);
857
-
858
-     let topDist = parseInt((window.innerHeight / 2).toFixed(2) - 152) +"px";
859
-     let leftDist = parseInt((window.innerWidth / 2).toFixed(2) - 150) +"px";
860
-     $("#alertConfMessage").css({ "top" : topDist, "left" : leftDist });
861
-
862
-     $("#closeAlertWndcf").click(function() { $("#alertMsgOverlay").remove(); $("#alertConfMessage").remove(); });
863
-     $("#alertMsgOverlay").click(function() { $("#alertMsgOverlay").remove(); $("#alertConfMessage").remove(); });
864
-  }
865
-
866
-});
Browse code

added files to implement CSS changes required by Nextcloud 28

DoubleBastionAdmin authored on 17/12/2023 01:12:45
Showing 1 changed files
1 1
new file mode 100644
... ...
@@ -0,0 +1,866 @@
1
+/**
2
+ * @copyright 2021 Double Bastion LLC <www.doublebastion.com>
3
+ *
4
+ * @author Double Bastion LLC
5
+ *
6
+ * @license GNU AGPL version 3 or any later version
7
+ *
8
+ * This program is free software; you can redistribute it and/or
9
+ * modify it under the terms of the GNU AFFERO GENERAL PUBLIC LICENSE
10
+ * License as published by the Free Software Foundation; either
11
+ * version 3 of the License, or any later version.
12
+ *
13
+ * This program is distributed in the hope that it will be useful,
14
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
15
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
16
+ * GNU AFFERO GENERAL PUBLIC LICENSE for more details.
17
+ *
18
+ * You should have received a copy of the GNU Affero General Public
19
+ * License along with this program.  If not, see <http://www.gnu.org/licenses/>.
20
+ *
21
+ */
22
+
23
+$(document).ready(function() {
24
+
25
+  var userid = "<?php p($userId); ?>";
26
+  var isadm = '';
27
+
28
+  // Get personal settings
29
+  var baseUrlget = OC.generateUrl('/apps/sms_relentless/user/getsettings');
30
+
31
+  $.ajax({
32
+     method: 'GET',
33
+     url: baseUrlget + '/' + userid,
34
+     contentType: 'application/json',
35
+     success: function(settingsfromdb) {
36
+
37
+         // Add the webhook URLs section, if the user is not an admin
38
+         if (settingsfromdb.adminornot == 'reguser') {
39
+
40
+             isadm = 'reguser';
41
+
42
+             $("#appTitlePrg").append('<p id="settings-dscr"><h3>Enter your options in the fields from below. As a non-admin user, you can use any of the SMS service providers from \
43
+                  below (Telnyx/Plivo/Twilio/Flowroute), on the condition that an admin has shared with you his API keys for that provider. If an admin has shared with you his API \
44
+                  keys for a provider, to be able to use them properly, you will have to generate the two webhook URLs for that provider by clicking the corresponding \
45
+                  "Generate new webhook URL ..." buttons from below, then click "Save" at the bottom of this page:</h3></p><br>');
46
+
47
+             $("#nadmProvSection").append('<div class="providerSettings"><p><label for="telapi_url_rec" class="setlabeltext"><b>Telnyx webhook URL for incoming SMS/MMS</b> (Generate \
48
+                  the URL by pressing the button from below. Don\'t forget to also click the \'Save\' button at the bottom of this page after entering all the options, to save \
49
+                  all the settings to the database.)</label></p> \
50
+                  <input type="button" id="generate_tel_rcpt" class="generateUrl" value="Generate new webhook URL for incoming SMS/MMS" /> \
51
+                  <input type="text" class="smsr_textboxspec" id="telapi_url_rec" name="telapi_url_rec" autocomplete="false" /> \
52
+                  <span id="copyToClipboardtel" class="icon icon-clippy" title="Copy to clipboard"></span><br><br> \
53
+                  \
54
+                  <p><label for="telapi_url" class="setlabeltext"><b>Telnyx webhook URL for delivery receipts</b> (This URL will be included by SMS Relentless in message sending \
55
+                  requests, so that Telnyx will know where to send the delivery receipts. Just generate it by pressing the button from below. Don\'t forget to click the \'Save\' \
56
+                  button at the bottom of this page after entering all the options, to save all the settings to the database.)</label></p> \
57
+                  <input type="button" id="generate_tel_delrcpt" class="generateUrl" value="Generate new webhook URL for delivery receipts" /> \
58
+                  <input type="text" id="telapi_url" name="telapi_url" autocomplete="false" /></div><br><br> \
59
+                  \
60
+                  <div class="providerSettings"><p><label for="nexapi_url_rec" class="setlabeltext"><b>Plivo webhook URL for incoming SMS/MMS</b> (Generate the URL by pressing \
61
+                  the button from below. Don\'t forget to also click the \'Save\' button at the bottom of this page after entering all the options, to save all the settings \
62
+                  to the database.)</label></p> \
63
+                  <input type="button" id="generate_nex_rcpt" class="generateUrl" value="Generate new webhook URL for incoming SMS/MMS" /> \
64
+                  <input type="text" class="smsr_textboxspec" id="nexapi_url_rec" name="nexapi_url_rec" autocomplete="false" /> \
65
+                  <span id="copyToClipboardnex" class="icon icon-clippy" title="Copy to clipboard"></span><br><br> \
66
+                  \
67
+                  <p><label for="nexapi_url" class="setlabeltext"><b>Plivo webhook URL for delivery receipts</b> (This URL will be included by SMS Relentless in message sending \
68
+                  requests, so that Plivo will know where to send the delivery receipts. Just generate it by pressing the button from below. Don\'t forget to click the \'Save\' \
69
+                  button at the bottom of this page after entering all the options, to save all the settings to the database.)</label></p> \
70
+                  <input type="button" id="generate_nex_delrcpt" class="generateUrl" value="Generate new webhook URL for delivery receipts" /> \
71
+                  <input type="text" id="nexapi_url" name="nexapi_url" autocomplete="false" /></div><br><br> \
72
+                  \
73
+                  <div class="providerSettings"><p><label for="twilapi_url_rec" class="setlabeltext"><b>Twilio webhook URL for incoming SMS/MMS</b> (Generate the URL by pressing \
74
+                  the button from below. Don\'t forget to also click the \'Save\' button at the bottom of this page after entering all the options, to save all the settings to \
75
+                  the database.)</label></p> \
76
+                  <input type="button" id="generate_twil_rcpt" class="generateUrl" value="Generate new webhook URL for incoming SMS/MMS" /> \
77
+                  <input type="text" class="smsr_textboxspec" id="twilapi_url_rec" name="twilapi_url_rec" autocomplete="false" /> \
78
+                  <span id="copyToClipboardtwil" class="icon icon-clippy" title="Copy to clipboard"></span><br><br> \
79
+                  \
80
+                  <p><label for="twilapi_url" class="setlabeltext"><b>Twilio webhook URL for delivery receipts</b> (This URL will be included by SMS Relentless in message sending \
81
+                  requests, so that Twilio will know where to send the delivery receipts. Just generate it by pressing the button from below. Don\'t forget to click the \'Save\' \
82
+                  button at the bottom of this page after entering all the options, to save all the settings to the database.)</label></p> \
83
+                  <input type="button" id="generate_twil_delrcpt" class="generateUrl" value="Generate new webhook URL for delivery receipts" /> \
84
+                  <input type="text" id="twilapi_url" name="twilapi_url" autocomplete="false" /></div><br><br> \
85
+                  \
86
+                  <div class="providerSettings"><p><label for="flowapi_url_rec" class="setlabeltext"><b>Flowroute webhook URL for incoming SMS/MMS</b> (Generate the URL by pressing \
87
+                  the button from below. Don\'t forget to also click the \'Save\' button at the bottom of this page after entering all the options, to save all the settings to \
88
+                  the database.)</label></p> \
89
+                  <input type="button" id="generate_flow_rcpt" class="generateUrl" value="Generate new webhook URL for incoming SMS/MMS" /> \
90
+                  <input type="text" class="smsr_textboxspec" id="flowapi_url_rec" name="flowapi_url_rec" autocomplete="false" /> \
91
+                  <span id="copyToClipboardflow" class="icon icon-clippy" title="Copy to clipboard"></span><br><br> \
92
+                  \
93
+                  <p><label for="flowapi_url" class="setlabeltext"><b>Flowroute webhook URL for delivery receipts</b> (This URL will be included by SMS Relentless in message sending \
94
+                  requests, so that Flowroute will know where to send the delivery receipts. Just generate it by pressing the button from below. Don\'t forget to click the \'Save\' \
95
+                  button at the bottom of this page after entering all the options, to save all the settings to the database.)</label></p> \
96
+                  <input type="button" id="generate_flow_delrcpt" class="generateUrl" value="Generate new webhook URL for delivery receipts" /> \
97
+                  <input type="text" id="flowapi_url" name="flowapi_url" autocomplete="false" /><br><br> \
98
+                  Flowroute only supports sending/receiving SMS/MMS messages within USA and Canada and it doesn\'t support Alphanumeric Sender IDs.</div><br>');
99
+
100
+
101
+		  $("#telapi_url_rec").val(settingsfromdb.telapi_url_rec);
102
+		  $("#telapi_url").val(settingsfromdb.telapi_url);
103
+		  $("#nexapi_url_rec").val(settingsfromdb.nexapi_url_rec);
104
+		  $("#nexapi_url").val(settingsfromdb.nexapi_url);
105
+		  $("#twilapi_url_rec").val(settingsfromdb.twilapi_url_rec);
106
+		  $("#twilapi_url").val(settingsfromdb.twilapi_url);
107
+		  $("#flowapi_url_rec").val(settingsfromdb.flowapi_url_rec);
108
+		  $("#flowapi_url").val(settingsfromdb.flowapi_url);
109
+		  $("#messagesperpage").val(settingsfromdb.messagesperpage);
110
+
111
+		  if (settingsfromdb.get_notify == 1) {
112
+		      $("#get_notify").attr('checked', true);
113
+		  } else {
114
+		      $("#get_notify").attr('checked', false);
115
+		  }
116
+
117
+		  $("#notification_email").val(settingsfromdb.notification_email);
118
+
119
+		  if (settingsfromdb.getsmsinemail == 1) {
120
+		      $("#includesmsinemail").attr('checked', true);
121
+		  } else {
122
+		      $("#includesmsinemail").attr('checked', false);
123
+		  }
124
+
125
+		  if (settingsfromdb.show_display_names == 1) {
126
+		      $("#showdisplaynames").attr('checked', true);
127
+		  } else {
128
+		      $("#showdisplaynames").attr('checked', false);
129
+		  }
130
+
131
+		  if (settingsfromdb.add_display_names == 1) {
132
+		      $("#adddisplaynames").attr('checked', true);
133
+		  } else {
134
+		      $("#adddisplaynames").attr('checked', false);
135
+		  }
136
+
137
+		  function randomStr(strlength) {
138
+			var fintext = "";
139
+			var keyspace = '0123456789abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ';
140
+			for (var i = 0; i < strlength; i++) {
141
+			     fintext += keyspace.charAt(Math.floor(Math.random() * keyspace.length));
142
+			}
143
+			return fintext;
144
+		  }
145
+
146
+		  $("#generate_tel_rcpt").on("click", function(event) {
147
+
148
+		     var teltokenrec = randomStr(70);
149
+		     var telnyxwhurlrec = window.location.origin + OC.generateUrl('/apps/sms_relentless/api/recsmstel?telrecparam=') + teltokenrec;
150
+
151
+		     $("#telapi_url_rec").val(telnyxwhurlrec);
152
+		  });
153
+
154
+		  $("#copyToClipboardtel").on("click", function(event) {
155
+		     var $tempEl = $("<input>");
156
+		     $("body").append($tempEl);
157
+		     $tempEl.val($("#telapi_url_rec").val()).select();
158
+		     document.execCommand("Copy");
159
+		     $tempEl.remove();
160
+		     showAlert("The link has been copied to your clipboard!");
161
+		  });
162
+
163
+		  $("#generate_tel_delrcpt").on("click", function(event) {
164
+
165
+		     var teltoken = randomStr(70);
166
+		     var telnyxwhurl = window.location.origin + OC.generateUrl('/apps/sms_relentless/api/recdeliverytel?teldrparam=') + teltoken;
167
+
168
+		     $("#telapi_url").val(telnyxwhurl);
169
+		  });
170
+
171
+
172
+		  $("#generate_nex_rcpt").on("click", function(event) {
173
+
174
+		     var plivotokenrec = randomStr(70);
175
+		     var plivowhurlrec = window.location.origin + OC.generateUrl('/apps/sms_relentless/api/recsmsnex?plivorecparam=') + plivotokenrec;
176
+
177
+		     $("#nexapi_url_rec").val(plivowhurlrec);
178
+		  });
179
+
180
+		  $("#copyToClipboardnex").on("click", function(event) {
181
+		     var $tempElpl = $("<input>");
182
+		     $("body").append($tempElpl);
183
+		     $tempElpl.val($("#nexapi_url_rec").val()).select();
184
+		     document.execCommand("Copy");
185
+		     $tempElpl.remove();
186
+		     showAlert("The link has been copied to your clipboard!");
187
+		  });
188
+
189
+		  $("#generate_nex_delrcpt").on("click", function(event) {
190
+
191
+		     var plivotoken = randomStr(70);
192
+		     var plivodrwhurl = window.location.origin + OC.generateUrl('/apps/sms_relentless/api/recdeliverynex?plivodrparam=') + plivotoken;
193
+
194
+		     $("#nexapi_url").val(plivodrwhurl);
195
+		  });
196
+
197
+
198
+		  $("#generate_twil_rcpt").on("click", function(event) {
199
+
200
+		     var twiltokenrec = randomStr(35);
201
+		     var twilwhurlrec = window.location.origin + OC.generateUrl('/apps/sms_relentless/api/recsmstwil?twilrecparam=') + twiltokenrec;
202
+
203
+		     $("#twilapi_url_rec").val(twilwhurlrec);
204
+		  });
205
+
206
+		  $("#copyToClipboardtwil").on("click", function(event) {
207
+		     var $tempElpl = $("<input>");
208
+		     $("body").append($tempElpl);
209
+		     $tempElpl.val($("#twilapi_url_rec").val()).select();
210
+		     document.execCommand("Copy");
211
+		     $tempElpl.remove();
212
+		     showAlert("The link has been copied to your clipboard!");
213
+		  });
214
+
215
+		  $("#generate_twil_delrcpt").on("click", function(event) {
216
+
217
+		     var twiltoken = randomStr(35);
218
+		     var twildrwhurl = window.location.origin + OC.generateUrl('/apps/sms_relentless/api/recdeliverytwil?twildrparam=') + twiltoken;
219
+
220
+		     $("#twilapi_url").val(twildrwhurl);
221
+		  });
222
+
223
+
224
+		  $("#generate_flow_rcpt").on("click", function(event) {
225
+
226
+		     var flowtokenrec = randomStr(70);
227
+		     var flowwhurlrec = window.location.origin + OC.generateUrl('/apps/sms_relentless/api/recsmsflow?flowrecparam=') + flowtokenrec;
228
+
229
+		     $("#flowapi_url_rec").val(flowwhurlrec);
230
+		  });
231
+
232
+		  $("#copyToClipboardflow").on("click", function(event) {
233
+		     var $tempElpl = $("<input>");
234
+		     $("body").append($tempElpl);
235
+		     $tempElpl.val($("#flowapi_url_rec").val()).select();
236
+		     document.execCommand("Copy");
237
+		     $tempElpl.remove();
238
+		     showAlert("The link has been copied to your clipboard!");
239
+		  });
240
+
241
+		  $("#generate_flow_delrcpt").on("click", function(event) {
242
+
243
+		     var flowtoken = randomStr(70);
244
+		     var flowdrwhurl = window.location.origin + OC.generateUrl('/apps/sms_relentless/api/recdeliveryflow?flowdrparam=') + flowtoken;
245
+
246
+		     $("#flowapi_url").val(flowdrwhurl);
247
+		  });
248
+
249
+
250
+         } else if (settingsfromdb.adminornot == 'admin') {
251
+
252
+                  $("#appTitlePrg").append('<p id="settings-dscr"><h3>First enter your credentials on the admin settings page of the app (on the left panel, under Administration, \
253
+                                            click on SMS Relentless), then enter your options in the fields from below:</h3></p><br>');
254
+                  isadm = 'admin';
255
+
256
+		  $("#messagesperpage").val(settingsfromdb.messagesperpage);
257
+
258
+		  if (settingsfromdb.get_notify == 1) {
259
+		      $("#get_notify").attr('checked', true);
260
+		  } else {
261
+		      $("#get_notify").attr('checked', false);
262
+		  }
263
+
264
+		  $("#notification_email").val(settingsfromdb.notification_email);
265
+
266
+		  if (settingsfromdb.getsmsinemail == 1) {
267
+		      $("#includesmsinemail").attr('checked', true);
268
+		  } else {
269
+		      $("#includesmsinemail").attr('checked', false);
270
+		  }
271
+
272
+		  if (settingsfromdb.show_display_names == 1) {
273
+		      $("#showdisplaynames").attr('checked', true);
274
+		  } else {
275
+		      $("#showdisplaynames").attr('checked', false);
276
+		  }
277
+
278
+		  if (settingsfromdb.add_display_names == 1) {
279
+		      $("#adddisplaynames").attr('checked', true);
280
+		  } else {
281
+		      $("#adddisplaynames").attr('checked', false);
282
+		  }
283
+         }
284
+
285
+
286
+         // Auto-reply settings
287
+
288
+         // Get the available phone numbers from all providers associated with the access keys entered on the Settings page (restrictions are applied to numbers for non-admins)
289
+         $("#autoRplPhoneNb").addClass('icon-loading');
290
+         var getnumbersUrl = OC.generateUrl("/apps/sms_relentless/user/getautoreplyconf");
291
+
292
+	 $.ajax({
293
+		  url: getnumbersUrl + '/' + userid,
294
+		  type: "GET",
295
+                  contentType: 'application/json',
296
+		  success: function(autoreplydata) {
297
+
298
+                                    $("#autoRplPhoneNb").removeClass('icon-loading');
299
+                                    var cusrDisplayName = autoreplydata.userdisplayname;
300
+                                    var availPhoneNmbrs = autoreplydata.phonenumbers;
301
+                                    var autorpldata = autoreplydata.autoreplies;
302
+
303
+				    if (autorpldata.length > 0) { 
304
+				        var arplNmb = autorpldata.length;
305
+				    } else { 
306
+				        var arplNmb = 0; 
307
+				    }
308
+
309
+				    // List the auto-replies for the phone numbers available for the current user
310
+				    if (arplNmb == 0) {
311
+
312
+				        $("#autoReplyTbl").append("<tr><td><input type='text' class='arplAuthor' value='"+ cusrDisplayName +"' disabled></td><td><select id='arpphn-"+ arplNmb +"' class='arplPhoneNmbr'></select></td><td><div id='arplmode-"+ arplNmb +"' class='arplMode'><select id='modeselect-"+ arplNmb +"' class='selectArplMode'><option value='' selected>Select mode</option><option value='daily'>Daily mode</option><option value='vacation'>Vacation mode</option></select><div id='modecont-"+ arplNmb +"' class='modeContent'></div></div></td><td><textarea id='arpltxt-"+ arplNmb +"' class='arplText' rows='20' cols='40' placeholder='Enter the auto-reply message here.'></textarea></td><td><img id='rmRow-"+ arplNmb +"' class='removeRow' src='/apps/sms_relentless/img/closewnd.svg' title='Remove this row from the database' style='cursor:pointer;margin:9px 8px 0px 18px;'></td><td><input type='submit' id='arplsave-"+ arplNmb +"' class='saveAutoReply' value='Save' title='Save Row' /></td></tr>");
313
+				        $("#autoReplyTbl").append("<div><img id='addArplRow' src='/apps/sms_relentless/img/add.svg' title='Add Row'></div>");
314
+
315
+				    } else {
316
+
317
+				        for (k = 0; k < arplNmb; k++) {
318
+
319
+                                             if (autorpldata[k].days_of_week != '') {
320
+
321
+                                                 var slctdMode = "<option value=''>Select mode</option><option value='daily' selected>Daily mode</option><option value='vacation'>Vacation mode</option>";
322
+                                                 var dailyStartArr = autorpldata[k].daily_start.split(":");
323
+                                                 var dailyEndArr = autorpldata[k].daily_end.split(":");
324
+
325
+		                                 var dlHrStartOptions = "";
326
+			                         for (var hr = 0; hr < 24; hr++) {
327
+		                                      if (dailyStartArr[0] != hr.toLocaleString('en-US', {minimumIntegerDigits: 2, useGrouping:false})) {
328
+			                                  dlHrStartOptions += "<option value='"+ hr.toLocaleString('en-US', {minimumIntegerDigits: 2, useGrouping:false}) +"'>"+ hr.toLocaleString('en-US', {minimumIntegerDigits: 2, useGrouping:false}) +"</option>";
329
+		                                      } else {
330
+			                                  dlHrStartOptions += "<option value='"+ hr.toLocaleString('en-US', {minimumIntegerDigits: 2, useGrouping:false}) +"' selected>"+ hr.toLocaleString('en-US', {minimumIntegerDigits: 2, useGrouping:false}) +"</option>";
331
+		                                      }
332
+			                         }
333
+
334
+		                                 var dlMnStartOptions = "";
335
+			                         for (var mn = 0; mn < 60; mn++) {
336
+		                                      if (dailyStartArr[1] != mn.toLocaleString('en-US', {minimumIntegerDigits: 2, useGrouping:false})) {
337
+			                                  dlMnStartOptions += "<option value='"+ mn.toLocaleString('en-US', {minimumIntegerDigits: 2, useGrouping:false}) +"'>"+ mn.toLocaleString('en-US', {minimumIntegerDigits: 2, useGrouping:false}) +"</option>";
338
+		                                      } else {
339
+			                                  dlMnStartOptions += "<option value='"+ mn.toLocaleString('en-US', {minimumIntegerDigits: 2, useGrouping:false}) +"' selected>"+ mn.toLocaleString('en-US', {minimumIntegerDigits: 2, useGrouping:false}) +"</option>";
340
+		                                      }
341
+			                         }
342
+
343
+		                                 var dlHrEndOptions = "";
344
+			                         for (var hr = 0; hr < 24; hr++) {
345
+		                                      if (dailyEndArr[0] != hr.toLocaleString('en-US', {minimumIntegerDigits: 2, useGrouping:false})) {
346
+			                                  dlHrEndOptions += "<option value='"+ hr.toLocaleString('en-US', {minimumIntegerDigits: 2, useGrouping:false}) +"'>"+ hr.toLocaleString('en-US', {minimumIntegerDigits: 2, useGrouping:false}) +"</option>";
347
+		                                      } else {
348
+			                                  dlHrEndOptions += "<option value='"+ hr.toLocaleString('en-US', {minimumIntegerDigits: 2, useGrouping:false}) +"' selected>"+ hr.toLocaleString('en-US', {minimumIntegerDigits: 2, useGrouping:false}) +"</option>";
349
+		                                      }
350
+			                         }
351
+
352
+		                                 var dlMnEndOptions = "";
353
+			                         for (var mn = 0; mn < 60; mn++) {
354
+		                                      if (dailyEndArr[1] != mn.toLocaleString('en-US', {minimumIntegerDigits: 2, useGrouping:false})) {
355
+			                                  dlMnEndOptions += "<option value='"+ mn.toLocaleString('en-US', {minimumIntegerDigits: 2, useGrouping:false}) +"'>"+ mn.toLocaleString('en-US', {minimumIntegerDigits: 2, useGrouping:false}) +"</option>";
356
+		                                      } else {
357
+			                                  dlMnEndOptions += "<option value='"+ mn.toLocaleString('en-US', {minimumIntegerDigits: 2, useGrouping:false}) +"' selected>"+ mn.toLocaleString('en-US', {minimumIntegerDigits: 2, useGrouping:false}) +"</option>";
358
+		                                      }
359
+			                         }
360
+
361
+                                                 var modeContent = "<div class='daysOfWeek'>Days of the week:<div class='tooltipautoreply'><div id='infoautoreply'>i</div><div class='autorpltooltip'>Enter the order number of the days of the week in which the auto-reply will be sent. For example, to send the auto-reply every day from Monday to Friday outside the time interval specified below, enter 1,2,3,4,5 To send the auto-reply only Monday, Thursday and Friday enter 1,4,5 To send the auto-reply every day of the week enter 1,2,3,4,5,6,7 As an exception, if you want the auto-reply to be sent during an entire day, irrespective of the specified interval, add (full) after the number of that day. For example, if you want the auto-reply to be sent from Monday to Friday outside the interval specified below, and also during the entire days of Saturday and Sunday, enter 1,2,3,4,5,6(full),7(full)</div></div></div><input type='text' id='weekdays-"+ k +"' class='daysInWeek' value='"+ autorpldata[k].days_of_week +"'><div class='chooseTInterval'>Send auto-reply <span style='color:#ad0202'>outside</span> this interval:<div class='tooltipautoreplyst'><div id='infoautoreplyst'>i</div><div class='autorpltooltipst'>These fields specify the time of the server. If the server is located in a time zone that is different from that of the owner/company, the time interval entered here should be adjusted accordingly.</div></div></div><div class='selectArplHours'><select id='dmstarthr-"+ k +"' class='selectHrMin'>"+ dlHrStartOptions +"</select><select id='dmstartmn-"+ k +"' class='selectHrMin'>"+ dlMnStartOptions +"</select><span style='font-weight: 600'> — </span><select id='dmendhr-"+ k +"' class='selectHrMin'>"+ dlHrEndOptions +"</select><select id='dmendmn-"+ k +"' class='selectHrMin'>"+ dlMnEndOptions +"</select></div>";
362
+
363
+                                             } else {
364
+
365
+                                                 var vctnStart = autorpldata[k].vacation_start.split(" ")[0];
366
+                                                 var vctnEnd = autorpldata[k].vacation_end.split(" ")[0];
367
+
368
+                                                 var slctdMode = "<option value=''>Select mode</option><option value='daily'>Daily mode</option><option value='vacation' selected>Vacation mode</option>";
369
+                                                 var modeContent = "<div class='chooseDateIntvl'>Send auto-reply <span style='color:#ad0202'>inside</span> this interval:</div><div class='arplstrtendDates'><div class='stdtTitle'>Start Date</div><input type='text' id='startDT-"+ k +"' class='startDate' placeholder='Pick a date' value='"+ vctnStart +"'><div class='enddtTitle'>End Date</div><input type='text' id='endDT-"+ k +"' class='endDate' placeholder='Pick a date' value='"+ vctnEnd +"'></div>"
370
+                                             }
371
+
372
+				             $("#autoReplyTbl").append("<tr><td><input type='text' class='arplAuthor' value='"+ autorpldata[k].saved_by_dsplname +"' disabled></td><td><select id='arpphn-"+ k +"' class='arplPhoneNmbr' style='pointer-events:none'><option selected>"+ autorpldata[k].phone_number +"</option></select></td><td><div id='arplmode-"+ k +"' class='arplMode'><select id='modeselect-"+ k +"' class='selectArplMode'>"+ slctdMode +"</select><div id='modecont-"+ k +"' class='modeContent'>"+ modeContent +"</div></div></td><td><textarea id='arpltxt-"+ k +"' class='arplText' rows='20' cols='40' placeholder='Enter the auto-reply message here.'>"+ autorpldata[k].message_text +"</textarea></td><td><img id='rmRow-"+ k +"' class='removeRow' src='/apps/sms_relentless/img/closewnd.svg' title='Remove this row from the database' style='cursor:pointer;margin:9px 8px 0px 18px;'></td><td><input type='submit' id='arplsave-"+ k +"' class='saveAutoReply' value='Edit' title='Edit Row' /></td></tr>");
373
+				        }
374
+				        $("#autoReplyTbl").append("<div><img id='addArplRow' src='/apps/sms_relentless/img/add.svg' title='Add Row'></div>");
375
+				    }
376
+
377
+
378
+				    // Create a list with all the available phone numbers
379
+                                    var numbersListItems = "<option value='' selected>Select phone number</option>";
380
+
381
+				    $.each(availPhoneNmbrs, function(key, indsmsnmb) {
382
+				           numbersListItems += "<option value='"+ indsmsnmb +"'>"+ indsmsnmb +"</option>";
383
+				    });
384
+
385
+                                    if (arplNmb == 0) {
386
+				        $("#arpphn-"+ arplNmb).append(numbersListItems);
387
+                                    }
388
+
389
+                                    // Initialize the date picker
390
+			            $('[id^="endDT-"]').datepicker({ dateFormat: "yy-mm-dd" });
391
+			            $('[id^="startDT-"]').datepicker({ dateFormat: "yy-mm-dd" });
392
+
393
+
394
+                                    // Select the auto-reply mode
395
+                                    function selectMode() {
396
+
397
+		                            $('[id^="modeselect-"]').change(function() {
398
+
399
+		                               var crtnmbr = $(this).attr("id").replace("modeselect-", "");
400
+
401
+		                               var dailyHrStart = "";
402
+		                               for (var h = 0; h < 24; h++) {
403
+		                                    dailyHrStart += "<option value='"+ h.toLocaleString('en-US', {minimumIntegerDigits: 2, useGrouping:false}) +"'>"+ h.toLocaleString('en-US', {minimumIntegerDigits: 2, useGrouping:false}) +"</option>";
404
+		                               }
405
+
406
+		                               var dailyMnStart = "";
407
+		                               for (var m = 0; m < 60; m++) {
408
+		                                    dailyMnStart += "<option value='"+ m.toLocaleString('en-US', {minimumIntegerDigits: 2, useGrouping:false}) +"'>"+ m.toLocaleString('en-US', {minimumIntegerDigits: 2, useGrouping:false}) +"</option>";
409
+		                               }
410
+
411
+		                               var dailyHrEnd = dailyHrStart;
412
+		                               var dailyMnEnd = dailyMnStart;
413
+
414
+		                               if ($(this).val() == 'daily') {
415
+		                                   $("#modecont-"+ crtnmbr).empty();
416
+		                                   $("#modecont-"+ crtnmbr).append("<div class='daysOfWeek'>Days of the week:<div class='tooltipautoreply'><div id='infoautoreply'>i</div><div class='autorpltooltip'>Enter the order number of the days of the week in which the auto-reply will be sent. For example, to send the auto-reply every day from Monday to Friday outside the time interval specified below, enter 1,2,3,4,5 To send the auto-reply only Monday, Thursday and Friday enter 1,4,5 To send the auto-reply every day of the week enter 1,2,3,4,5,6,7 As an exception, if you want the auto-reply to be sent during an entire day, irrespective of the specified interval, add (full) after the number of that day. For example, if you want the auto-reply to be sent from Monday to Friday outside the interval specified below, and also during the entire days of Saturday and Sunday, enter 1,2,3,4,5,6(full),7(full)</div></div></div><input type='text' id='weekdays-"+ crtnmbr +"' class='daysInWeek'><div class='chooseTInterval'>Send auto-reply <span style='color:#ad0202'>outside</span> this interval:<div class='tooltipautoreplyst'><div id='infoautoreplyst'>i</div><div class='autorpltooltipst'>These fields specify the time of the server. If the server is located in a time zone that is different from that of the owner/company, the time interval entered here should be adjusted accordingly.</div></div></div><div class='selectArplHours'><select id='dmstarthr-"+ crtnmbr +"' class='selectHrMin'>"+ dailyHrStart +"</select><select id='dmstartmn-"+ crtnmbr +"' class='selectHrMin'>"+ dailyMnStart +"</select><span style='font-weight: 600'> — </span><select id='dmendhr-"+ crtnmbr +"' class='selectHrMin'>"+ dailyHrEnd +"</select><select id='dmendmn-"+ crtnmbr +"' class='selectHrMin'>"+ dailyMnEnd +"</select></div>");
417
+		                               } else if ($(this).val() == 'vacation') {
418
+		                                   $("#modecont-"+ crtnmbr).empty();
419
+		                                   $("#modecont-"+ crtnmbr).append("<div class='chooseDateIntvl'>Send auto-reply <span style='color:#ad0202'>inside</span> this interval:</div><div class='arplstrtendDates'><div class='stdtTitle'>Start Date</div><input type='text' id='startDT-"+ crtnmbr +"' class='startDate' placeholder='Pick a date'><div class='enddtTitle'>End Date</div><input type='text' id='endDT-"+ crtnmbr +"' class='endDate' placeholder='Pick a date' /></div>");
420
+		                               }
421
+
422
+					       $("#endDT-"+ crtnmbr +"").datepicker({ dateFormat: "yy-mm-dd" });
423
+					       $("#startDT-"+ crtnmbr +"").datepicker({ dateFormat: "yy-mm-dd" });
424
+		                          });
425
+                                  }
426
+                                  selectMode();
427
+
428
+				  // Save the data
429
+				  function saveArplRow() {
430
+
431
+				     $('[id^="arplsave-"]').unbind("click");
432
+				     $('[id^="arplsave-"]').click(function(event) {
433
+
434
+				        event.preventDefault();
435
+				        var crntrwnmbr = $(this).attr("id").replace("arplsave-", "");
436
+
437
+				        if ($(this).attr("value") == "Save") {
438
+
439
+				            var phoneNmbr = $("#arpphn-"+ crntrwnmbr).val();
440
+				            var arplText = $("#arpltxt-"+ crntrwnmbr).val();
441
+				            var slctdMode = $("#modeselect-"+ crntrwnmbr).val();
442
+
443
+				            var slctddmDays = "";
444
+				            var slctdHrStart = "";
445
+				            var slctdMnStart = "";
446
+				            var slctdHrEnd = "";
447
+				            var slctdMnEnd = "";
448
+
449
+				            var vcStartDate = null;
450
+				            var vcEndDate = null;
451
+
452
+				            if (slctdMode == 'daily') {
453
+
454
+				                slctddmDays = $("#weekdays-"+ crntrwnmbr).val().trim();
455
+				                slctdHrStart = $("#dmstarthr-"+ crntrwnmbr).val().trim();
456
+				                slctdMnStart = $("#dmstartmn-"+ crntrwnmbr).val().trim();
457
+				                slctdHrEnd = $("#dmendhr-"+ crntrwnmbr).val().trim();
458
+				                slctdMnEnd = $("#dmendmn-"+ crntrwnmbr).val().trim();
459
+
460
+                                                if (slctdHrStart != '' && slctdMnStart != '') {
461
+                                                    var hrmnStartComp = slctdHrStart +":"+ slctdMnStart;
462
+                                                } else { var hrmnStartComp = ""; }
463
+
464
+                                                if (slctdHrEnd != '' && slctdMnEnd != '') {
465
+                                                    var hrmnEndComp = slctdHrEnd +":"+ slctdMnEnd;
466
+                                                } else { var hrmnEndComp = ""; }
467
+
468
+                                                if (!(/^[1-7ful\,\(\)]+$/.test(slctddmDays))) {
469
+				                    showAlert("The 'Days of the week' field can contain only digits from 1 to 7, the lowercase letters f, u and l, round brackets ()() and commas (,).");
470
+				                    return;
471
+                                                }
472
+
473
+                                                if (!(/^[0-9]+$/.test(slctdHrStart + slctdMnStart + slctdHrEnd + slctdMnEnd))) {
474
+				                    showAlert("The starting and ending values of the time interval for the 'Daily mode' can contain only digits from 0 to 9.");
475
+				                    return;
476
+                                                }
477
+
478
+                                                if (slctddmDays.trim() == '' || (slctdHrStart == slctdHrEnd && slctdMnStart == slctdMnEnd)) {
479
+				                    showAlert("For the 'Daily mode', you have to enter the order number of the days of the week for which you want the auto-reply to be sent, and you have to set a starting time that is different from the ending time!");
480
+				                    return;
481
+                                                }
482
+
483
+				            } else if (slctdMode == 'vacation') {
484
+		
485
+                                                if ($("#startDT-"+ crntrwnmbr).val().trim() == '' || $("#endDT-"+ crntrwnmbr).val().trim() == '') {
486
+
487
+				                    showAlert("For the 'Vacation mode', you have to enter both a start date and an end date.");
488
+				                    return;
489
+
490
+                                                } else {
491
+
492
+                                                    if (!(/^[0-9\-]+$/.test($("#startDT-"+ crntrwnmbr).val().trim() + $("#endDT-"+ crntrwnmbr).val().trim()))) {
493
+				                        showAlert("The start date and end date values for the 'Vacation mode' can contain only digits from 0 to 9 and hyphens (-).");
494
+				                        return;
495
+                                                    }
496
+
497
+		                                    vcStartDate = $("#startDT-"+ crntrwnmbr).val().trim() +" 00:00:00";
498
+				                    vcEndDate = $("#endDT-"+ crntrwnmbr).val().trim() +" 23:59:59";
499
+				                    var strtDateCmp = new Date(vcStartDate).toJSON().slice(0, 10) +" 00:00:00";
500
+				                    var endDateCmp = new Date(vcEndDate).toJSON().slice(0, 10) +" 23:59:59";
501
+				                    var crntDate = new Date().toJSON().slice(0, 10) +" 23:59:59";
502
+
503
+                                                    if (vcStartDate.trim() == "" || vcEndDate.trim() == "" || (strtDateCmp >= endDateCmp || ((strtDateCmp < crntDate) && (endDateCmp < crntDate)))) {
504
+				                        showAlert("For 'Vacation mode', you have to enter both a start date and an end date, the start date must be before the end date and at least the ending of the time interval must be in the future.");
505
+				                        return;
506
+                                                    }
507
+                                                }
508
+				            }
509
+
510
+
511
+				            if (phoneNmbr != '') {
512
+
513
+				              if (arplText.trim() != '') {
514
+
515
+				                if (slctdMode != '') {
516
+
517
+				                    var saveArplUrl = OC.generateUrl('/apps/sms_relentless/user/updateautoreplies');
518
+				                    var arpldata = {
519
+				                         userId: userid,
520
+				                         savedByDsplname: cusrDisplayName,
521
+				                         phoneNumber: phoneNmbr,
522
+				                         daysOfWeek: slctddmDays,
523
+				                         dailyStart: hrmnStartComp,
524
+				                         dailyEnd: hrmnEndComp,
525
+				                         vacationStart: vcStartDate,
526
+				                         vacationEnd: vcEndDate,
527
+				                         messageText: arplText
528
+				                    };
529
+
530
+					            $.ajax({
531
+					              method: 'PUT',
532
+					              url: saveArplUrl + '/' + userid,
533
+					              contentType: 'application/json',
534
+					              data: JSON.stringify(arpldata),
535
+				                      success: function(messagereceived) {
536
+
537
+				                                   if (messagereceived == 'success') {
538
+				                                       showAlert('The auto-reply has been successfully saved to the database!');
539
+				                                   } else if (messagereceived == 'failure') {
540
+				                                       showAlert('Error while trying to save the auto-reply!');
541
+				                                   } else if (messagereceived == 'not allowed') {
542
+                                                                       showAlert('You cannot change an auto-reply that was saved by a different user.');
543
+                                                                   }
544
+				                      },
545
+					              error: function() {
546
+						                   showAlert('Error while attempting to save the auto-reply! You can check the Nextcloud log to find more details about this issue.');
547
+					              }
548
+					            });
549
+
550
+
551
+                                                } else { showAlert("Please select the auto-reply mode."); return; }
552
+
553
+                                              } else { showAlert("Please enter the text of the auto-reply."); return; }
554
+
555
+                                            } else { showAlert("Please select a phone number if at least one number is available in the 'Phone Number' drop-down list. Otherwise, you should contact the administrator."); return; }
556
+
557
+                                            $(this).attr("value", "Edit");
558
+
559
+                                        } else {
560
+                                            $("#arplsave-"+ crntrwnmbr).attr("value", "Save");
561
+                                        }
562
+
563
+                                     });
564
+
565
+				  }
566
+                                  saveArplRow();
567
+
568
+
569
+				  // Remove a row
570
+				  function removeArplRow() {
571
+				       $('[id^="rmRow-"]').click(function() {
572
+
573
+					  var slctRowRm = $(this).attr("id").replace("rmRow-", "");
574
+					  var crntPhnNmbr = $("#arpphn-"+ slctRowRm).val();
575
+
576
+				          confirmAlert("Do you really want to remove this row from the database ?");
577
+
578
+				          $("#confirmCancel").click(function() { $("#alertMsgOverlay").remove(); $("#alertConfMessage").remove(); });
579
+
580
+				          $("#confirmOk").click(function() {
581
+
582
+				              $("#alertMsgOverlay").remove();
583
+				              $("#alertConfMessage").remove();
584
+
585
+					      var rmvArplUrl = OC.generateUrl('/apps/sms_relentless/user/removeautoreplies');
586
+					      $.ajax({
587
+						   url: rmvArplUrl + '/' + userid,
588
+						   method: "POST",
589
+						   dataType: "text",
590
+						   data: { phoneNumber: crntPhnNmbr },
591
+						   success: function(delresult) {
592
+
593
+						                     if (delresult.indexOf("success") > -1) {
594
+						                         showAlert("The auto-reply has been removed successfully!");
595
+						                         $("#arpphn-"+ slctRowRm).closest("tr").remove();
596
+						                     } else if (delresult.indexOf("failure") > -1) {
597
+						                         showAlert("Error while trying to remove auto-reply data!");
598
+						                     } else if (delresult.indexOf("not allowed") > -1) {
599
+                                                                         showAlert("You cannot remove the auto-reply saved by another user.");
600
+                                                                     }
601
+						   },
602
+						   error: function() { showAlert("Error while attempting to remove auto-reply data! You can check the Nextcloud log to find more details about this issue."); }
603
+					       });
604
+					  });
605
+				       });
606
+				  }
607
+				  removeArplRow();
608
+
609
+                                  // Add a new row
610
+                                  $("#addArplRow").click(function() {
611
+
612
+                                     if ($("#autoReplyTbl").find("tr:last-child").find(".arplPhoneNmbr").length > 0) {
613
+                                         var lastarpl = $("#autoReplyTbl").find("tr:last-child").find(".arplPhoneNmbr").attr("id").replace("arpphn-", "");
614
+                                         var indArplAdd = parseInt(lastarpl + 1);
615
+                                     } else { var indArplAdd = 0; }
616
+			             $("#autoReplyTbl").append("<tr><td><input type='text' class='arplAuthor' value='"+ cusrDisplayName +"' disabled></td><td><select id='arpphn-"+ indArplAdd +"' class='arplPhoneNmbr'>"+ numbersListItems +"</select></td><td><div id='arplmode-"+ indArplAdd +"' class='arplMode'><select id='modeselect-"+ indArplAdd +"' class='selectArplMode'><option value='' selected>Select mode</option><option value='daily'>Daily mode</option><option value='vacation'>Vacation mode</option></select><div id='modecont-"+ indArplAdd +"' class='modeContent'></div></div></td><td><textarea id='arpltxt-"+ indArplAdd +"' class='arplText' rows='20' cols='40' placeholder='Enter the auto-reply message here.'></textarea></td><td><img id='rmRow-"+ indArplAdd +"' class='removeRow' src='/apps/sms_relentless/img/closewnd.svg' title='Remove this row from the database' style='cursor:pointer;margin:9px 8px 0px 18px;'></td><td><input type='submit' id='arplsave-"+ indArplAdd +"' class='saveAutoReply' value='Save' title='Save Row' /></td></tr>");
617
+
618
+                                     selectMode();
619
+                                     saveArplRow();
620
+                                     removeArplRow();
621
+
622
+			             // Check if there is an auto-reply set for the same phone number
623
+				     $("#arpphn-"+ indArplAdd).change(function() {
624
+					 var selectedPhNb = $("#arpphn-"+ indArplAdd).val();
625
+					 var allArplPhNmbrs = $("#autoReplyTbl").find("tr").find(".arplPhoneNmbr");
626
+					 var phNbChck = 0;
627
+					 allArplPhNmbrs.each(function() {
628
+					    var slctphnb = ($(this).val())? $(this).val() : $(this).text();
629
+					    if (selectedPhNb == slctphnb) { phNbChck++; }
630
+					 });
631
+
632
+					 if (phNbChck == 2) {
633
+					     showAlert("There is already an auto-reply set up for this phone number. Please edit its own row, or choose a different phone number.");
634
+					     $(this).val('');
635
+					     return;
636
+					 }
637
+				     });
638
+                                  });
639
+
640
+		  },
641
+		  error: function() {
642
+                                    $("#autoRplPhoneNb").removeClass('icon-loading'); 
643
+                                    showAlert("Error while attempting to get the auto-reply settings! You can check the Nextcloud log to find more details about this issue.");
644
+                  }
645
+         });
646
+
647
+     },
648
+     error: function() {
649
+                  showAlert('Error while getting the settings! You can check the Nextcloud log to find more details about this issue.');
650
+     }
651
+  });
652
+
653
+
654
+
655
+  // Save personal settings for non-admin users
656
+  $("#save_sms_settings").on("click", function(event) {
657
+
658
+     if (isadm == 'reguser') {
659
+
660
+	    event.preventDefault();
661
+	    var baseUrlsave = OC.generateUrl('/apps/sms_relentless/user/updatesettings');
662
+
663
+	    var messagesperpageinit = $("#messagesperpage").val();
664
+	    var messagesperpagesec = messagesperpageinit.replace(/[^0-9]/g, '');
665
+
666
+	    if (messagesperpagesec != '') {
667
+		var messagesperpageproc = messagesperpagesec;
668
+	    } else {
669
+		var messagesperpageproc = 100;
670
+	    }
671
+
672
+	    var getnotify = 0;
673
+
674
+	    if ($("#get_notify").is(':checked')) {
675
+		getnotify = 1;
676
+	    }
677
+
678
+	    var emailaddressinit = $("#notification_email").val();
679
+
680
+	    function validate_email($email) {
681
+		var email_reg = /^([\w-\.]+@([\w-]+\.)+[\w-]{2,4})?$/;
682
+		return email_reg.test($email);
683
+	    }
684
+
685
+	    if (validate_email(emailaddressinit)) {
686
+		 var notifyemail = emailaddressinit;
687
+	    } else {
688
+		 var notifyemail = '';
689
+	    }
690
+
691
+	    var includesmsinemail = 0;
692
+	    if ($("#includesmsinemail").is(':checked')) {
693
+		includesmsinemail = 1;
694
+                if ($("#notification_email").val().trim() == '') {
695
+                    showAlert("Please enter an email address in the field: 'I want to receive a notification to the email address from below ...', or uncheck the checkbox: 'Include the SMS/MMS message in the email notification itself'.");
696
+                    return;
697
+                }
698
+	    }
699
+
700
+	    var showdisplaynm = 0;
701
+	    if ($("#showdisplaynames").is(':checked')) {
702
+		showdisplaynm = 1;
703
+	    }
704
+
705
+	    var adddisplaynm = 0;
706
+	    if ($("#adddisplaynames").is(':checked')) {
707
+		adddisplaynm = 1;
708
+	    }
709
+
710
+	    var datatosave = {
711
+			      userId: userid,
712
+		              telapiUrlRec: $("#telapi_url_rec").val(),
713
+		              telapiUrl: $("#telapi_url").val(),
714
+		              nexapiUrlRec: $("#nexapi_url_rec").val(),
715
+		              nexapiUrl: $("#nexapi_url").val(),
716
+		              twilapiUrlRec: $("#twilapi_url_rec").val(),
717
+		              twilapiUrl: $("#twilapi_url").val(),
718
+		              flowapiUrlRec: $("#flowapi_url_rec").val(),
719
+		              flowapiUrl: $("#flowapi_url").val(),
720
+			      messagesperpage: messagesperpageproc,
721
+			      getNotify: getnotify,
722
+			      notificationEmail: notifyemail,
723
+			      getsmsinemail: includesmsinemail,
724
+			      showDisplayNames: showdisplaynm,
725
+                              addDisplayNames: adddisplaynm
726
+	    };
727
+
728
+
729
+	    $.ajax({
730
+	       method: 'PUT',
731
+	       url: baseUrlsave + '/' + userid,
732
+	       contentType: 'application/json',
733
+	       data: JSON.stringify(datatosave),
734
+	       success: function() {
735
+                               OC.msg.startAction('#smsr_save_msg', t('sms_relentless', 'Saved'));
736
+	       },
737
+	       error: function() {
738
+		    showAlert('Error while attempting to save the settings! You can check the Nextcloud log to find more details about this issue.');
739
+	       }
740
+	    });
741
+
742
+
743
+     } else if (isadm == 'admin') {
744
+
745
+	    // Save personal settings for admins
746
+	    event.preventDefault();
747
+	    var baseUrlsaveadm = OC.generateUrl('/apps/sms_relentless/user/updatepersadmnsettings');
748
+
749
+	    var messagesperpageinit = $("#messagesperpage").val();
750
+	    var messagesperpagesec = messagesperpageinit.replace(/[^0-9]/g, '');
751
+
752
+	    if (messagesperpagesec != '') {
753
+		var messagesperpageproc = messagesperpagesec;
754
+	    } else {
755
+		var messagesperpageproc = 100;
756
+	    }
757
+
758
+	    var getnotify = 0;
759
+
760
+	    if ($("#get_notify").is(':checked')) {
761
+		getnotify = 1;
762
+	    }
763
+
764
+	    var emailaddressinit = $("#notification_email").val();
765
+
766
+	    function validate_email($email) {
767
+		var email_reg = /^([\w-\.]+@([\w-]+\.)+[\w-]{2,4})?$/;
768
+		return email_reg.test($email);
769
+	    }
770
+
771
+	    if (validate_email(emailaddressinit)) {
772
+		 var notifyemail = emailaddressinit;
773
+	    } else {
774
+		 var notifyemail = '';
775
+	    }
776
+
777
+	    var includesmsinemail = 0;
778
+	    if ($("#includesmsinemail").is(':checked')) {
779
+		includesmsinemail = 1;
780
+                if ($("#notification_email").val().trim() == '') {
781
+                    showAlert("Please enter an email address in the field: 'I want to receive a notification to the email address from below ...', or uncheck the checkbox: 'Include the SMS/MMS message in the email notification itself'.");
782
+                    return;
783
+                }
784
+	    }
785
+
786
+	    var showdisplaynm = 0;
787
+	    if ($("#showdisplaynames").is(':checked')) {
788
+		showdisplaynm = 1;
789
+	    }
790
+
791
+	    var adddisplaynm = 0;
792
+	    if ($("#adddisplaynames").is(':checked')) {
793
+		adddisplaynm = 1;
794
+	    }
795
+
796
+	    var datatosave = {
797
+			      userId: userid,
798
+			      messagesperpage: messagesperpageproc,
799
+			      getNotify: getnotify,
800
+			      notificationEmail: notifyemail,
801
+			      getsmsinemail: includesmsinemail,
802
+			      showDisplayNames: showdisplaynm,
803
+                              addDisplayNames: adddisplaynm
804
+	    };
805
+
806
+
807
+	    $.ajax({
808
+	       method: 'PUT',
809
+	       url: baseUrlsaveadm + '/' + userid,
810
+	       contentType: 'application/json',
811
+	       data: JSON.stringify(datatosave),
812
+	       success: function() {
813
+                               OC.msg.startAction('#smsr_save_msg', t('sms_relentless', 'Saved'));
814
+	       },
815
+	       error: function() {
816
+		    showAlert('Error while attempting to save the settings! You can check the Nextcloud log to find more details about this issue.');
817
+	       }
818
+	    });
819
+
820
+     }
821
+  });
822
+
823
+  function showAlert(alertText) {
824
+
825
+     let alertwnd = "<div id='alertMessage'>";
826
+     alertwnd += "<a id='closeAlertWnd' title='Close this window'></a>";
827
+     alertwnd += "<div id='alertTextWrap'>"+ alertText +"</div>";
828
+     alertwnd += "<input type='submit' id='alertOk' value='OK'>";
829
+     alertwnd += "</div>";
830
+
831
+     $("#content").append("<div id='alertMsgOverlay'></div>");
832
+     $("#content").append(alertwnd);
833
+
834
+     let topDist = parseInt((window.innerHeight / 2).toFixed(2) - 152) +"px";
835
+     let leftDist = parseInt((window.innerWidth / 2).toFixed(2) - 150) +"px";
836
+     $("#alertMessage").css({ "top" : topDist, "left" : leftDist });
837
+
838
+     $("#closeAlertWnd").click(function() { $("#alertMsgOverlay").remove(); $("#alertMessage").remove(); });
839
+     $("#alertMsgOverlay").click(function() { $("#alertMsgOverlay").remove(); $("#alertMessage").remove(); });
840
+     $("#alertOk").click(function() { $("#alertMsgOverlay").remove(); $("#alertMessage").remove(); });
841
+  }
842
+
843
+  function confirmAlert(alertText) {
844
+
845
+     $("#alertMsgOverlay").remove();
846
+     $("#alertConfMessage").remove();
847
+
848
+     let alertwndcf = "<div id='alertConfMessage'>";
849
+     alertwndcf += "<a id='closeAlertWndcf' title='Close this window'></a>";
850
+     alertwndcf += "<div id='alertTextWrap'>"+ alertText +"</div>";
851
+     alertwndcf += "<div id='cancelOkWrap'><input type='submit' id='confirmCancel' value='Cancel'>";
852
+     alertwndcf += "<input type='submit' id='confirmOk' value='OK'></div>";
853
+     alertwndcf += "</div>";
854
+
855
+     $("#content").append("<div id='alertMsgOverlay'></div>");
856
+     $("#content").append(alertwndcf);
857
+
858
+     let topDist = parseInt((window.innerHeight / 2).toFixed(2) - 152) +"px";
859
+     let leftDist = parseInt((window.innerWidth / 2).toFixed(2) - 150) +"px";
860
+     $("#alertConfMessage").css({ "top" : topDist, "left" : leftDist });
861
+
862
+     $("#closeAlertWndcf").click(function() { $("#alertMsgOverlay").remove(); $("#alertConfMessage").remove(); });
863
+     $("#alertMsgOverlay").click(function() { $("#alertMsgOverlay").remove(); $("#alertConfMessage").remove(); });
864
+  }
865
+
866
+});
Browse code

removed files to implement CSS changes required by Nextcloud 28

DoubleBastionAdmin authored on 17/12/2023 00:56:54
Showing 1 changed files
1 1
deleted file mode 100644
... ...
@@ -1,866 +0,0 @@
1
-/**
2
- * @copyright 2021 Double Bastion LLC <www.doublebastion.com>
3
- *
4
- * @author Double Bastion LLC
5
- *
6
- * @license GNU AGPL version 3 or any later version
7
- *
8
- * This program is free software; you can redistribute it and/or
9
- * modify it under the terms of the GNU AFFERO GENERAL PUBLIC LICENSE
10
- * License as published by the Free Software Foundation; either
11
- * version 3 of the License, or any later version.
12
- *
13
- * This program is distributed in the hope that it will be useful,
14
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
15
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
16
- * GNU AFFERO GENERAL PUBLIC LICENSE for more details.
17
- *
18
- * You should have received a copy of the GNU Affero General Public
19
- * License along with this program.  If not, see <http://www.gnu.org/licenses/>.
20
- *
21
- */
22
-
23
-$(document).ready(function() {
24
-
25
-  var userid = "<?php p($userId); ?>";
26
-  var isadm = '';
27
-
28
-  // Get personal settings
29
-  var baseUrlget = OC.generateUrl('/apps/sms_relentless/user/getsettings');
30
-
31
-  $.ajax({
32
-     method: 'GET',
33
-     url: baseUrlget + '/' + userid,
34
-     contentType: 'application/json',
35
-     success: function(settingsfromdb) {
36
-
37
-         // Add the webhook URLs section, if the user is not an admin
38
-         if (settingsfromdb.adminornot == 'reguser') {
39
-
40
-             isadm = 'reguser';
41
-
42
-             $("#appTitlePrg").append('<p id="settings-dscr"><h3>Enter your options in the fields from below. As a non-admin user, you can use any of the SMS service providers from \
43
-                  below (Telnyx/Plivo/Twilio/Flowroute), on the condition that an admin has shared with you his API keys for that provider. If an admin has shared with you his API \
44
-                  keys for a provider, to be able to use them properly, you will have to generate the two webhook URLs for that provider by clicking the corresponding \
45
-                  "Generate new webhook URL ..." buttons from below, then click "Save" at the bottom of this page:</h3></p><br>');
46
-
47
-             $("#nadmProvSection").append('<div class="providerSettings"><p><label for="telapi_url_rec" class="setlabeltext"><b>Telnyx webhook URL for incoming SMS/MMS</b> (Generate \
48
-                  the URL by pressing the button from below. Don\'t forget to also click the \'Save\' button at the bottom of this page after entering all the options, to save \
49
-                  all the settings to the database.)</label></p> \
50
-                  <input type="button" id="generate_tel_rcpt" class="generateUrl" value="Generate new webhook URL for incoming SMS/MMS" /> \
51
-                  <input type="text" class="smsr_textboxspec" id="telapi_url_rec" name="telapi_url_rec" autocomplete="false" /> \
52
-                  <span id="copyToClipboardtel" class="icon icon-clippy" title="Copy to clipboard"></span><br><br> \
53
-                  \
54
-                  <p><label for="telapi_url" class="setlabeltext"><b>Telnyx webhook URL for delivery receipts</b> (This URL will be included by SMS Relentless in message sending \
55
-                  requests, so that Telnyx will know where to send the delivery receipts. Just generate it by pressing the button from below. Don\'t forget to click the \'Save\' \
56
-                  button at the bottom of this page after entering all the options, to save all the settings to the database.)</label></p> \
57
-                  <input type="button" id="generate_tel_delrcpt" class="generateUrl" value="Generate new webhook URL for delivery receipts" /> \
58
-                  <input type="text" id="telapi_url" name="telapi_url" autocomplete="false" /></div><br><br> \
59
-                  \
60
-                  <div class="providerSettings"><p><label for="nexapi_url_rec" class="setlabeltext"><b>Plivo webhook URL for incoming SMS/MMS</b> (Generate the URL by pressing \
61
-                  the button from below. Don\'t forget to also click the \'Save\' button at the bottom of this page after entering all the options, to save all the settings \
62
-                  to the database.)</label></p> \
63
-                  <input type="button" id="generate_nex_rcpt" class="generateUrl" value="Generate new webhook URL for incoming SMS/MMS" /> \
64
-                  <input type="text" class="smsr_textboxspec" id="nexapi_url_rec" name="nexapi_url_rec" autocomplete="false" /> \
65
-                  <span id="copyToClipboardnex" class="icon icon-clippy" title="Copy to clipboard"></span><br><br> \
66
-                  \
67
-                  <p><label for="nexapi_url" class="setlabeltext"><b>Plivo webhook URL for delivery receipts</b> (This URL will be included by SMS Relentless in message sending \
68
-                  requests, so that Plivo will know where to send the delivery receipts. Just generate it by pressing the button from below. Don\'t forget to click the \'Save\' \
69
-                  button at the bottom of this page after entering all the options, to save all the settings to the database.)</label></p> \
70
-                  <input type="button" id="generate_nex_delrcpt" class="generateUrl" value="Generate new webhook URL for delivery receipts" /> \
71
-                  <input type="text" id="nexapi_url" name="nexapi_url" autocomplete="false" /></div><br><br> \
72
-                  \
73
-                  <div class="providerSettings"><p><label for="twilapi_url_rec" class="setlabeltext"><b>Twilio webhook URL for incoming SMS/MMS</b> (Generate the URL by pressing \
74
-                  the button from below. Don\'t forget to also click the \'Save\' button at the bottom of this page after entering all the options, to save all the settings to \
75
-                  the database.)</label></p> \
76
-                  <input type="button" id="generate_twil_rcpt" class="generateUrl" value="Generate new webhook URL for incoming SMS/MMS" /> \
77
-                  <input type="text" class="smsr_textboxspec" id="twilapi_url_rec" name="twilapi_url_rec" autocomplete="false" /> \
78
-                  <span id="copyToClipboardtwil" class="icon icon-clippy" title="Copy to clipboard"></span><br><br> \
79
-                  \
80
-                  <p><label for="twilapi_url" class="setlabeltext"><b>Twilio webhook URL for delivery receipts</b> (This URL will be included by SMS Relentless in message sending \
81
-                  requests, so that Twilio will know where to send the delivery receipts. Just generate it by pressing the button from below. Don\'t forget to click the \'Save\' \
82
-                  button at the bottom of this page after entering all the options, to save all the settings to the database.)</label></p> \
83
-                  <input type="button" id="generate_twil_delrcpt" class="generateUrl" value="Generate new webhook URL for delivery receipts" /> \
84
-                  <input type="text" id="twilapi_url" name="twilapi_url" autocomplete="false" /></div><br><br> \
85
-                  \
86
-                  <div class="providerSettings"><p><label for="flowapi_url_rec" class="setlabeltext"><b>Flowroute webhook URL for incoming SMS/MMS</b> (Generate the URL by pressing \
87
-                  the button from below. Don\'t forget to also click the \'Save\' button at the bottom of this page after entering all the options, to save all the settings to \
88
-                  the database.)</label></p> \
89
-                  <input type="button" id="generate_flow_rcpt" class="generateUrl" value="Generate new webhook URL for incoming SMS/MMS" /> \
90
-                  <input type="text" class="smsr_textboxspec" id="flowapi_url_rec" name="flowapi_url_rec" autocomplete="false" /> \
91
-                  <span id="copyToClipboardflow" class="icon icon-clippy" title="Copy to clipboard"></span><br><br> \
92
-                  \
93
-                  <p><label for="flowapi_url" class="setlabeltext"><b>Flowroute webhook URL for delivery receipts</b> (This URL will be included by SMS Relentless in message sending \
94
-                  requests, so that Flowroute will know where to send the delivery receipts. Just generate it by pressing the button from below. Don\'t forget to click the \'Save\' \
95
-                  button at the bottom of this page after entering all the options, to save all the settings to the database.)</label></p> \
96
-                  <input type="button" id="generate_flow_delrcpt" class="generateUrl" value="Generate new webhook URL for delivery receipts" /> \
97
-                  <input type="text" id="flowapi_url" name="flowapi_url" autocomplete="false" /><br><br> \
98
-                  Flowroute only supports sending/receiving SMS/MMS messages within USA and Canada and it doesn\'t support Alphanumeric Sender IDs.</div><br>');
99
-
100
-
101
-		  $("#telapi_url_rec").val(settingsfromdb.telapi_url_rec);
102
-		  $("#telapi_url").val(settingsfromdb.telapi_url);
103
-		  $("#nexapi_url_rec").val(settingsfromdb.nexapi_url_rec);
104
-		  $("#nexapi_url").val(settingsfromdb.nexapi_url);
105
-		  $("#twilapi_url_rec").val(settingsfromdb.twilapi_url_rec);
106
-		  $("#twilapi_url").val(settingsfromdb.twilapi_url);
107
-		  $("#flowapi_url_rec").val(settingsfromdb.flowapi_url_rec);
108
-		  $("#flowapi_url").val(settingsfromdb.flowapi_url);
109
-		  $("#messagesperpage").val(settingsfromdb.messagesperpage);
110
-
111
-		  if (settingsfromdb.get_notify == 1) {
112
-		      $("#get_notify").attr('checked', true);
113
-		  } else {
114
-		      $("#get_notify").attr('checked', false);
115
-		  }
116
-
117
-		  $("#notification_email").val(settingsfromdb.notification_email);
118
-
119
-		  if (settingsfromdb.getsmsinemail == 1) {
120
-		      $("#includesmsinemail").attr('checked', true);
121
-		  } else {
122
-		      $("#includesmsinemail").attr('checked', false);
123
-		  }
124
-
125
-		  if (settingsfromdb.show_display_names == 1) {
126
-		      $("#showdisplaynames").attr('checked', true);
127
-		  } else {
128
-		      $("#showdisplaynames").attr('checked', false);
129
-		  }
130
-
131
-		  if (settingsfromdb.add_display_names == 1) {
132
-		      $("#adddisplaynames").attr('checked', true);
133
-		  } else {
134
-		      $("#adddisplaynames").attr('checked', false);
135
-		  }
136
-
137
-		  function randomStr(strlength) {
138
-			var fintext = "";
139
-			var keyspace = '0123456789abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ';
140
-			for (var i = 0; i < strlength; i++) {
141
-			     fintext += keyspace.charAt(Math.floor(Math.random() * keyspace.length));
142
-			}
143
-			return fintext;
144
-		  }
145
-
146
-		  $("#generate_tel_rcpt").on("click", function(event) {
147
-
148
-		     var teltokenrec = randomStr(70);
149
-		     var telnyxwhurlrec = window.location.origin + OC.generateUrl('/apps/sms_relentless/api/recsmstel?telrecparam=') + teltokenrec;
150
-
151
-		     $("#telapi_url_rec").val(telnyxwhurlrec);
152
-		  });
153
-
154
-		  $("#copyToClipboardtel").on("click", function(event) {
155
-		     var $tempEl = $("<input>");
156
-		     $("body").append($tempEl);
157
-		     $tempEl.val($("#telapi_url_rec").val()).select();
158
-		     document.execCommand("Copy");
159
-		     $tempEl.remove();
160
-		     showAlert("The link has been copied to your clipboard!");
161
-		  });
162
-
163
-		  $("#generate_tel_delrcpt").on("click", function(event) {
164
-
165
-		     var teltoken = randomStr(70);
166
-		     var telnyxwhurl = window.location.origin + OC.generateUrl('/apps/sms_relentless/api/recdeliverytel?teldrparam=') + teltoken;
167
-
168
-		     $("#telapi_url").val(telnyxwhurl);
169
-		  });
170
-
171
-
172
-		  $("#generate_nex_rcpt").on("click", function(event) {
173
-
174
-		     var plivotokenrec = randomStr(70);
175
-		     var plivowhurlrec = window.location.origin + OC.generateUrl('/apps/sms_relentless/api/recsmsnex?plivorecparam=') + plivotokenrec;
176
-
177
-		     $("#nexapi_url_rec").val(plivowhurlrec);
178
-		  });
179
-
180
-		  $("#copyToClipboardnex").on("click", function(event) {
181
-		     var $tempElpl = $("<input>");
182
-		     $("body").append($tempElpl);
183
-		     $tempElpl.val($("#nexapi_url_rec").val()).select();
184
-		     document.execCommand("Copy");
185
-		     $tempElpl.remove();
186
-		     showAlert("The link has been copied to your clipboard!");
187
-		  });
188
-
189
-		  $("#generate_nex_delrcpt").on("click", function(event) {
190
-
191
-		     var plivotoken = randomStr(70);
192
-		     var plivodrwhurl = window.location.origin + OC.generateUrl('/apps/sms_relentless/api/recdeliverynex?plivodrparam=') + plivotoken;
193
-
194
-		     $("#nexapi_url").val(plivodrwhurl);
195
-		  });
196
-
197
-
198
-		  $("#generate_twil_rcpt").on("click", function(event) {
199
-
200
-		     var twiltokenrec = randomStr(35);
201
-		     var twilwhurlrec = window.location.origin + OC.generateUrl('/apps/sms_relentless/api/recsmstwil?twilrecparam=') + twiltokenrec;
202
-
203
-		     $("#twilapi_url_rec").val(twilwhurlrec);
204
-		  });
205
-
206
-		  $("#copyToClipboardtwil").on("click", function(event) {
207
-		     var $tempElpl = $("<input>");
208
-		     $("body").append($tempElpl);
209
-		     $tempElpl.val($("#twilapi_url_rec").val()).select();
210
-		     document.execCommand("Copy");
211
-		     $tempElpl.remove();
212
-		     showAlert("The link has been copied to your clipboard!");
213
-		  });
214
-
215
-		  $("#generate_twil_delrcpt").on("click", function(event) {
216
-
217
-		     var twiltoken = randomStr(35);
218
-		     var twildrwhurl = window.location.origin + OC.generateUrl('/apps/sms_relentless/api/recdeliverytwil?twildrparam=') + twiltoken;
219
-
220
-		     $("#twilapi_url").val(twildrwhurl);
221
-		  });
222
-
223
-
224
-		  $("#generate_flow_rcpt").on("click", function(event) {
225
-
226
-		     var flowtokenrec = randomStr(70);
227
-		     var flowwhurlrec = window.location.origin + OC.generateUrl('/apps/sms_relentless/api/recsmsflow?flowrecparam=') + flowtokenrec;
228
-
229
-		     $("#flowapi_url_rec").val(flowwhurlrec);
230
-		  });
231
-
232
-		  $("#copyToClipboardflow").on("click", function(event) {
233
-		     var $tempElpl = $("<input>");
234
-		     $("body").append($tempElpl);
235
-		     $tempElpl.val($("#flowapi_url_rec").val()).select();
236
-		     document.execCommand("Copy");
237
-		     $tempElpl.remove();
238
-		     showAlert("The link has been copied to your clipboard!");
239
-		  });
240
-
241
-		  $("#generate_flow_delrcpt").on("click", function(event) {
242
-
243
-		     var flowtoken = randomStr(70);
244
-		     var flowdrwhurl = window.location.origin + OC.generateUrl('/apps/sms_relentless/api/recdeliveryflow?flowdrparam=') + flowtoken;
245
-
246
-		     $("#flowapi_url").val(flowdrwhurl);
247
-		  });
248
-
249
-
250
-         } else if (settingsfromdb.adminornot == 'admin') {
251
-
252
-                  $("#appTitlePrg").append('<p id="settings-dscr"><h3>First enter your credentials and options on the admin settings page (on the left panel, under Administration, \
253
-                                            click on SMS Relentless), then enter your options in the fields from below:</h3></p><br>');
254
-                  isadm = 'admin';
255
-
256
-		  $("#messagesperpage").val(settingsfromdb.messagesperpage);
257
-
258
-		  if (settingsfromdb.get_notify == 1) {
259
-		      $("#get_notify").attr('checked', true);
260
-		  } else {
261
-		      $("#get_notify").attr('checked', false);
262
-		  }
263
-
264
-		  $("#notification_email").val(settingsfromdb.notification_email);
265
-
266
-		  if (settingsfromdb.getsmsinemail == 1) {
267
-		      $("#includesmsinemail").attr('checked', true);
268
-		  } else {
269
-		      $("#includesmsinemail").attr('checked', false);
270
-		  }
271
-
272
-		  if (settingsfromdb.show_display_names == 1) {
273
-		      $("#showdisplaynames").attr('checked', true);
274
-		  } else {
275
-		      $("#showdisplaynames").attr('checked', false);
276
-		  }
277
-
278
-		  if (settingsfromdb.add_display_names == 1) {
279
-		      $("#adddisplaynames").attr('checked', true);
280
-		  } else {
281
-		      $("#adddisplaynames").attr('checked', false);
282
-		  }
283
-         }
284
-
285
-
286
-         // Auto-reply settings
287
-
288
-         // Get the available phone numbers from all providers associated with the access keys entered on the Settings page (restrictions are applied to numbers for non-admins)
289
-         $("#autoRplPhoneNb").addClass('icon-loading');
290
-         var getnumbersUrl = OC.generateUrl("/apps/sms_relentless/user/getautoreplyconf");
291
-
292
-	 $.ajax({
293
-		  url: getnumbersUrl + '/' + userid,
294
-		  type: "GET",
295
-                  contentType: 'application/json',
296
-		  success: function(autoreplydata) {
297
-
298
-                                    $("#autoRplPhoneNb").removeClass('icon-loading');
299
-                                    var cusrDisplayName = autoreplydata.userdisplayname;
300
-                                    var availPhoneNmbrs = autoreplydata.phonenumbers;
301
-                                    var autorpldata = autoreplydata.autoreplies;
302
-
303
-				    if (autorpldata.length > 0) { 
304
-				        var arplNmb = autorpldata.length;
305
-				    } else { 
306
-				        var arplNmb = 0; 
307
-				    }
308
-
309
-				    // List the auto-replies for the phone numbers available for the current user
310
-				    if (arplNmb == 0) {
311
-
312
-				        $("#autoReplyTbl").append("<tr><td><input type='text' class='arplAuthor' value='"+ cusrDisplayName +"' disabled></td><td><select id='arpphn-"+ arplNmb +"' class='arplPhoneNmbr'></select></td><td><div id='arplmode-"+ arplNmb +"' class='arplMode'><select id='modeselect-"+ arplNmb +"' class='selectArplMode'><option value='' selected>Select mode</option><option value='daily'>Daily mode</option><option value='vacation'>Vacation mode</option></select><div id='modecont-"+ arplNmb +"' class='modeContent'></div></div></td><td><textarea id='arpltxt-"+ arplNmb +"' class='arplText' rows='20' cols='40' placeholder='Enter the auto-reply message here.'></textarea></td><td><img id='rmRow-"+ arplNmb +"' class='removeRow' src='/apps/sms_relentless/img/closewnd.svg' title='Remove this row from the database' style='cursor:pointer;margin:9px 8px 0px 18px;'></td><td><input type='submit' id='arplsave-"+ arplNmb +"' class='saveAutoReply' value='Save' title='Save Row' /></td></tr>");
313
-				        $("#autoReplyTbl").append("<div><img id='addArplRow' src='/apps/sms_relentless/img/add.svg' title='Add Row'></div>");
314
-
315
-				    } else {
316
-
317
-				        for (k = 0; k < arplNmb; k++) {
318
-
319
-                                             if (autorpldata[k].days_of_week != '') {
320
-
321
-                                                 var slctdMode = "<option value=''>Select mode</option><option value='daily' selected>Daily mode</option><option value='vacation'>Vacation mode</option>";
322
-                                                 var dailyStartArr = autorpldata[k].daily_start.split(":");
323
-                                                 var dailyEndArr = autorpldata[k].daily_end.split(":");
324
-
325
-		                                 var dlHrStartOptions = "";
326
-			                         for (var hr = 0; hr < 24; hr++) {
327
-		                                      if (dailyStartArr[0] != hr.toLocaleString('en-US', {minimumIntegerDigits: 2, useGrouping:false})) {
328
-			                                  dlHrStartOptions += "<option value='"+ hr.toLocaleString('en-US', {minimumIntegerDigits: 2, useGrouping:false}) +"'>"+ hr.toLocaleString('en-US', {minimumIntegerDigits: 2, useGrouping:false}) +"</option>";
329
-		                                      } else {
330
-			                                  dlHrStartOptions += "<option value='"+ hr.toLocaleString('en-US', {minimumIntegerDigits: 2, useGrouping:false}) +"' selected>"+ hr.toLocaleString('en-US', {minimumIntegerDigits: 2, useGrouping:false}) +"</option>";
331
-		                                      }
332
-			                         }
333
-
334
-		                                 var dlMnStartOptions = "";
335
-			                         for (var mn = 0; mn < 60; mn++) {
336
-		                                      if (dailyStartArr[1] != mn.toLocaleString('en-US', {minimumIntegerDigits: 2, useGrouping:false})) {
337
-			                                  dlMnStartOptions += "<option value='"+ mn.toLocaleString('en-US', {minimumIntegerDigits: 2, useGrouping:false}) +"'>"+ mn.toLocaleString('en-US', {minimumIntegerDigits: 2, useGrouping:false}) +"</option>";
338
-		                                      } else {
339
-			                                  dlMnStartOptions += "<option value='"+ mn.toLocaleString('en-US', {minimumIntegerDigits: 2, useGrouping:false}) +"' selected>"+ mn.toLocaleString('en-US', {minimumIntegerDigits: 2, useGrouping:false}) +"</option>";
340
-		                                      }
341
-			                         }
342
-
343
-		                                 var dlHrEndOptions = "";
344
-			                         for (var hr = 0; hr < 24; hr++) {
345
-		                                      if (dailyEndArr[0] != hr.toLocaleString('en-US', {minimumIntegerDigits: 2, useGrouping:false})) {
346
-			                                  dlHrEndOptions += "<option value='"+ hr.toLocaleString('en-US', {minimumIntegerDigits: 2, useGrouping:false}) +"'>"+ hr.toLocaleString('en-US', {minimumIntegerDigits: 2, useGrouping:false}) +"</option>";
347
-		                                      } else {
348
-			                                  dlHrEndOptions += "<option value='"+ hr.toLocaleString('en-US', {minimumIntegerDigits: 2, useGrouping:false}) +"' selected>"+ hr.toLocaleString('en-US', {minimumIntegerDigits: 2, useGrouping:false}) +"</option>";
349
-		                                      }
350
-			                         }
351
-
352
-		                                 var dlMnEndOptions = "";
353
-			                         for (var mn = 0; mn < 60; mn++) {
354
-		                                      if (dailyEndArr[1] != mn.toLocaleString('en-US', {minimumIntegerDigits: 2, useGrouping:false})) {
355
-			                                  dlMnEndOptions += "<option value='"+ mn.toLocaleString('en-US', {minimumIntegerDigits: 2, useGrouping:false}) +"'>"+ mn.toLocaleString('en-US', {minimumIntegerDigits: 2, useGrouping:false}) +"</option>";
356
-		                                      } else {
357
-			                                  dlMnEndOptions += "<option value='"+ mn.toLocaleString('en-US', {minimumIntegerDigits: 2, useGrouping:false}) +"' selected>"+ mn.toLocaleString('en-US', {minimumIntegerDigits: 2, useGrouping:false}) +"</option>";
358
-		                                      }
359
-			                         }
360
-
361
-                                                 var modeContent = "<div class='daysOfWeek'>Days of the week:<div class='tooltipautoreply'><div id='infoautoreply'>i</div><div class='autorpltooltip'>Enter the order number of the days of the week in which the auto-reply will be sent. For example, to send the auto-reply every day from Monday to Friday outside the time interval specified below, enter 1,2,3,4,5 To send the auto-reply only Monday, Thursday and Friday enter 1,4,5 To send the auto-reply every day of the week enter 1,2,3,4,5,6,7 As an exception, if you want the auto-reply to be sent during an entire day, irrespective of the specified interval, add (full) after the number of that day. For example, if you want the auto-reply to be sent from Monday to Friday outside the interval specified below, and also during the entire days of Saturday and Sunday, enter 1,2,3,4,5,6(full),7(full)</div></div></div><input type='text' id='weekdays-"+ k +"' class='daysInWeek' value='"+ autorpldata[k].days_of_week +"'><div class='chooseTInterval'>Send auto-reply <span style='color:#ad0202'>outside</span> this interval:<div class='tooltipautoreplyst'><div id='infoautoreplyst'>i</div><div class='autorpltooltipst'>These fields specify the time of the server. If the server is located in a time zone that is different from that of the owner/company, the time interval entered here should be adjusted accordingly.</div></div></div><div class='selectArplHours'><select id='dmstarthr-"+ k +"' class='selectHrMin'>"+ dlHrStartOptions +"</select><select id='dmstartmn-"+ k +"' class='selectHrMin'>"+ dlMnStartOptions +"</select><span style='font-weight: 600'> — </span><select id='dmendhr-"+ k +"' class='selectHrMin'>"+ dlHrEndOptions +"</select><select id='dmendmn-"+ k +"' class='selectHrMin'>"+ dlMnEndOptions +"</select></div>";
362
-
363
-                                             } else {
364
-
365
-                                                 var vctnStart = autorpldata[k].vacation_start.split(" ")[0];
366
-                                                 var vctnEnd = autorpldata[k].vacation_end.split(" ")[0];
367
-
368
-                                                 var slctdMode = "<option value=''>Select mode</option><option value='daily'>Daily mode</option><option value='vacation' selected>Vacation mode</option>";
369
-                                                 var modeContent = "<div class='chooseDateIntvl'>Send auto-reply <span style='color:#ad0202'>inside</span> this interval:</div><div class='arplstrtendDates'><div class='stdtTitle'>Start Date</div><input type='text' id='startDT-"+ k +"' class='startDate' placeholder='Pick a date' value='"+ vctnStart +"'><div class='enddtTitle'>End Date</div><input type='text' id='endDT-"+ k +"' class='endDate' placeholder='Pick a date' value='"+ vctnEnd +"'></div>"
370
-                                             }
371
-
372
-				             $("#autoReplyTbl").append("<tr><td><input type='text' class='arplAuthor' value='"+ autorpldata[k].saved_by_dsplname +"' disabled></td><td><select id='arpphn-"+ k +"' class='arplPhoneNmbr' style='pointer-events:none'><option selected>"+ autorpldata[k].phone_number +"</option></select></td><td><div id='arplmode-"+ k +"' class='arplMode'><select id='modeselect-"+ k +"' class='selectArplMode'>"+ slctdMode +"</select><div id='modecont-"+ k +"' class='modeContent'>"+ modeContent +"</div></div></td><td><textarea id='arpltxt-"+ k +"' class='arplText' rows='20' cols='40' placeholder='Enter the auto-reply message here.'>"+ autorpldata[k].message_text +"</textarea></td><td><img id='rmRow-"+ k +"' class='removeRow' src='/apps/sms_relentless/img/closewnd.svg' title='Remove this row from the database' style='cursor:pointer;margin:9px 8px 0px 18px;'></td><td><input type='submit' id='arplsave-"+ k +"' class='saveAutoReply' value='Edit' title='Edit Row' /></td></tr>");
373
-				        }
374
-				        $("#autoReplyTbl").append("<div><img id='addArplRow' src='/apps/sms_relentless/img/add.svg' title='Add Row'></div>");
375
-				    }
376
-
377
-
378
-				    // Create a list with all the available phone numbers
379
-                                    var numbersListItems = "<option value='' selected>Select phone number</option>";
380
-
381
-				    $.each(availPhoneNmbrs, function(key, indsmsnmb) {
382
-				           numbersListItems += "<option value='"+ indsmsnmb +"'>"+ indsmsnmb +"</option>";
383
-				    });
384
-
385
-                                    if (arplNmb == 0) {
386
-				        $("#arpphn-"+ arplNmb).append(numbersListItems);
387
-                                    }
388
-
389
-                                    // Initialize the date picker
390
-			            $('[id^="endDT-"]').datepicker({ dateFormat: "yy-mm-dd" });
391
-			            $('[id^="startDT-"]').datepicker({ dateFormat: "yy-mm-dd" });
392
-
393
-
394
-                                    // Select the auto-reply mode
395
-                                    function selectMode() {
396
-
397
-		                            $('[id^="modeselect-"]').change(function() {
398
-
399
-		                               var crtnmbr = $(this).attr("id").replace("modeselect-", "");
400
-
401
-		                               var dailyHrStart = "";
402
-		                               for (var h = 0; h < 24; h++) {
403
-		                                    dailyHrStart += "<option value='"+ h.toLocaleString('en-US', {minimumIntegerDigits: 2, useGrouping:false}) +"'>"+ h.toLocaleString('en-US', {minimumIntegerDigits: 2, useGrouping:false}) +"</option>";
404
-		                               }
405
-
406
-		                               var dailyMnStart = "";
407
-		                               for (var m = 0; m < 60; m++) {
408
-		                                    dailyMnStart += "<option value='"+ m.toLocaleString('en-US', {minimumIntegerDigits: 2, useGrouping:false}) +"'>"+ m.toLocaleString('en-US', {minimumIntegerDigits: 2, useGrouping:false}) +"</option>";
409
-		                               }
410
-
411
-		                               var dailyHrEnd = dailyHrStart;
412
-		                               var dailyMnEnd = dailyMnStart;
413
-
414
-		                               if ($(this).val() == 'daily') {
415
-		                                   $("#modecont-"+ crtnmbr).empty();
416
-		                                   $("#modecont-"+ crtnmbr).append("<div class='daysOfWeek'>Days of the week:<div class='tooltipautoreply'><div id='infoautoreply'>i</div><div class='autorpltooltip'>Enter the order number of the days of the week in which the auto-reply will be sent. For example, to send the auto-reply every day from Monday to Friday outside the time interval specified below, enter 1,2,3,4,5 To send the auto-reply only Monday, Thursday and Friday enter 1,4,5 To send the auto-reply every day of the week enter 1,2,3,4,5,6,7 As an exception, if you want the auto-reply to be sent during an entire day, irrespective of the specified interval, add (full) after the number of that day. For example, if you want the auto-reply to be sent from Monday to Friday outside the interval specified below, and also during the entire days of Saturday and Sunday, enter 1,2,3,4,5,6(full),7(full)</div></div></div><input type='text' id='weekdays-"+ crtnmbr +"' class='daysInWeek'><div class='chooseTInterval'>Send auto-reply <span style='color:#ad0202'>outside</span> this interval:<div class='tooltipautoreplyst'><div id='infoautoreplyst'>i</div><div class='autorpltooltipst'>These fields specify the time of the server. If the server is located in a time zone that is different from that of the owner/company, the time interval entered here should be adjusted accordingly.</div></div></div><div class='selectArplHours'><select id='dmstarthr-"+ crtnmbr +"' class='selectHrMin'>"+ dailyHrStart +"</select><select id='dmstartmn-"+ crtnmbr +"' class='selectHrMin'>"+ dailyMnStart +"</select><span style='font-weight: 600'> — </span><select id='dmendhr-"+ crtnmbr +"' class='selectHrMin'>"+ dailyHrEnd +"</select><select id='dmendmn-"+ crtnmbr +"' class='selectHrMin'>"+ dailyMnEnd +"</select></div>");
417
-		                               } else if ($(this).val() == 'vacation') {
418
-		                                   $("#modecont-"+ crtnmbr).empty();
419
-		                                   $("#modecont-"+ crtnmbr).append("<div class='chooseDateIntvl'>Send auto-reply <span style='color:#ad0202'>inside</span> this interval:</div><div class='arplstrtendDates'><div class='stdtTitle'>Start Date</div><input type='text' id='startDT-"+ crtnmbr +"' class='startDate' placeholder='Pick a date'><div class='enddtTitle'>End Date</div><input type='text' id='endDT-"+ crtnmbr +"' class='endDate' placeholder='Pick a date' /></div>");
420
-		                               }
421
-
422
-					       $("#endDT-"+ crtnmbr +"").datepicker({ dateFormat: "yy-mm-dd" });
423
-					       $("#startDT-"+ crtnmbr +"").datepicker({ dateFormat: "yy-mm-dd" });
424
-		                          });
425
-                                  }
426
-                                  selectMode();
427
-
428
-				  // Save the data
429
-				  function saveArplRow() {
430
-
431
-				     $('[id^="arplsave-"]').unbind("click");
432
-				     $('[id^="arplsave-"]').click(function(event) {
433
-
434
-				        event.preventDefault();
435
-				        var crntrwnmbr = $(this).attr("id").replace("arplsave-", "");
436
-
437
-				        if ($(this).attr("value") == "Save") {
438
-
439
-				            var phoneNmbr = $("#arpphn-"+ crntrwnmbr).val();
440
-				            var arplText = $("#arpltxt-"+ crntrwnmbr).val();
441
-				            var slctdMode = $("#modeselect-"+ crntrwnmbr).val();
442
-
443
-				            var slctddmDays = "";
444
-				            var slctdHrStart = "";
445
-				            var slctdMnStart = "";
446
-				            var slctdHrEnd = "";
447
-				            var slctdMnEnd = "";
448
-
449
-				            var vcStartDate = null;
450
-				            var vcEndDate = null;
451
-
452
-				            if (slctdMode == 'daily') {
453
-
454
-				                slctddmDays = $("#weekdays-"+ crntrwnmbr).val().trim();
455
-				                slctdHrStart = $("#dmstarthr-"+ crntrwnmbr).val().trim();
456
-				                slctdMnStart = $("#dmstartmn-"+ crntrwnmbr).val().trim();
457
-				                slctdHrEnd = $("#dmendhr-"+ crntrwnmbr).val().trim();
458
-				                slctdMnEnd = $("#dmendmn-"+ crntrwnmbr).val().trim();
459
-
460
-                                                if (slctdHrStart != '' && slctdMnStart != '') {
461
-                                                    var hrmnStartComp = slctdHrStart +":"+ slctdMnStart;
462
-                                                } else { var hrmnStartComp = ""; }
463
-
464
-                                                if (slctdHrEnd != '' && slctdMnEnd != '') {
465
-                                                    var hrmnEndComp = slctdHrEnd +":"+ slctdMnEnd;
466
-                                                } else { var hrmnEndComp = ""; }
467
-
468
-                                                if (!(/^[1-7ful\,\(\)]+$/.test(slctddmDays))) {
469
-				                    showAlert("The 'Days of the week' field can contain only digits from 1 to 7, the lowercase letters f, u and l, round brackets ()() and commas (,).");
470
-				                    return;
471
-                                                }
472
-
473
-                                                if (!(/^[0-9]+$/.test(slctdHrStart + slctdMnStart + slctdHrEnd + slctdMnEnd))) {
474
-				                    showAlert("The starting and ending values of the time interval for the 'Daily mode' can contain only digits from 0 to 9.");
475
-				                    return;
476
-                                                }
477
-
478
-                                                if (slctddmDays.trim() == '' || (slctdHrStart == slctdHrEnd && slctdMnStart == slctdMnEnd)) {
479
-				                    showAlert("For the 'Daily mode', you have to enter the order number of the days of the week for which you want the auto-reply to be sent, and you have to set a starting time that is different from the ending time!");
480
-				                    return;
481
-                                                }
482
-
483
-				            } else if (slctdMode == 'vacation') {
484
-		
485
-                                                if ($("#startDT-"+ crntrwnmbr).val().trim() == '' || $("#endDT-"+ crntrwnmbr).val().trim() == '') {
486
-
487
-				                    showAlert("For the 'Vacation mode', you have to enter both a start date and an end date.");
488
-				                    return;
489
-
490
-                                                } else {
491
-
492
-                                                    if (!(/^[0-9\-]+$/.test($("#startDT-"+ crntrwnmbr).val().trim() + $("#endDT-"+ crntrwnmbr).val().trim()))) {
493
-				                        showAlert("The start date and end date values for the 'Vacation mode' can contain only digits from 0 to 9 and hyphens (-).");
494
-				                        return;
495
-                                                    }
496
-
497
-		                                    vcStartDate = $("#startDT-"+ crntrwnmbr).val().trim() +" 00:00:00";
498
-				                    vcEndDate = $("#endDT-"+ crntrwnmbr).val().trim() +" 23:59:59";
499
-				                    var strtDateCmp = new Date(vcStartDate).toJSON().slice(0, 10) +" 00:00:00";
500
-				                    var endDateCmp = new Date(vcEndDate).toJSON().slice(0, 10) +" 23:59:59";
501
-				                    var crntDate = new Date().toJSON().slice(0, 10) +" 23:59:59";
502
-
503
-                                                    if (vcStartDate.trim() == "" || vcEndDate.trim() == "" || (strtDateCmp >= endDateCmp || ((strtDateCmp < crntDate) && (endDateCmp < crntDate)))) {
504
-				                        showAlert("For 'Vacation mode', you have to enter both a start date and an end date, the start date must be before the end date and at least the ending of the time interval must be in the future.");
505
-				                        return;
506
-                                                    }
507
-                                                }
508
-				            }
509
-
510
-
511
-				            if (phoneNmbr != '') {
512
-
513
-				              if (arplText.trim() != '') {
514
-
515
-				                if (slctdMode != '') {
516
-
517
-				                    var saveArplUrl = OC.generateUrl('/apps/sms_relentless/user/updateautoreplies');
518
-				                    var arpldata = {
519
-				                         userId: userid,
520
-				                         savedByDsplname: cusrDisplayName,
521
-				                         phoneNumber: phoneNmbr,
522
-				                         daysOfWeek: slctddmDays,
523
-				                         dailyStart: hrmnStartComp,
524
-				                         dailyEnd: hrmnEndComp,
525
-				                         vacationStart: vcStartDate,
526
-				                         vacationEnd: vcEndDate,
527
-				                         messageText: arplText
528
-				                    };
529
-
530
-					            $.ajax({
531
-					              method: 'PUT',
532
-					              url: saveArplUrl + '/' + userid,
533
-					              contentType: 'application/json',
534
-					              data: JSON.stringify(arpldata),
535
-				                      success: function(messagereceived) {
536
-
537
-				                                   if (messagereceived == 'success') {
538
-				                                       showAlert('The auto-reply has been successfully saved to the database!');
539
-				                                   } else if (messagereceived == 'failure') {
540
-				                                       showAlert('Error while trying to save the auto-reply!');
541
-				                                   } else if (messagereceived == 'not allowed') {
542
-                                                                       showAlert('You cannot change an auto-reply that was saved by a different user.');
543
-                                                                   }
544
-				                      },
545
-					              error: function() {
546
-						                   showAlert('Error while attempting to save the auto-reply! You can check the Nextcloud log to find more details about this issue.');
547
-					              }
548
-					            });
549
-
550
-
551
-                                                } else { showAlert("Please select the auto-reply mode."); return; }
552
-
553
-                                              } else { showAlert("Please enter the text of the auto-reply."); return; }
554
-
555
-                                            } else { showAlert("Please select a phone number if at least one number is available in the 'Phone Number' drop-down list. Otherwise, you should contact the administrator."); return; }
556
-
557
-                                            $(this).attr("value", "Edit");
558
-
559
-                                        } else {
560
-                                            $("#arplsave-"+ crntrwnmbr).attr("value", "Save");
561
-                                        }
562
-
563
-                                     });
564
-
565
-				  }
566
-                                  saveArplRow();
567
-
568
-
569
-				  // Remove a row
570
-				  function removeArplRow() {
571
-				       $('[id^="rmRow-"]').click(function() {
572
-
573
-					  var slctRowRm = $(this).attr("id").replace("rmRow-", "");
574
-					  var crntPhnNmbr = $("#arpphn-"+ slctRowRm).val();
575
-
576
-				          confirmAlert("Do you really want to remove this row from the database ?");
577
-
578
-				          $("#confirmCancel").click(function() { $("#alertMsgOverlay").remove(); $("#alertConfMessage").remove(); });
579
-
580
-				          $("#confirmOk").click(function() {
581
-
582
-				              $("#alertMsgOverlay").remove();
583
-				              $("#alertConfMessage").remove();
584
-
585
-					      var rmvArplUrl = OC.generateUrl('/apps/sms_relentless/user/removeautoreplies');
586
-					      $.ajax({
587
-						   url: rmvArplUrl + '/' + userid,
588
-						   method: "POST",
589
-						   dataType: "text",
590
-						   data: { phoneNumber: crntPhnNmbr },
591
-						   success: function(delresult) {
592
-
593
-						                     if (delresult.indexOf("success") > -1) {
594
-						                         showAlert("The auto-reply has been removed successfully!");
595
-						                         $("#arpphn-"+ slctRowRm).closest("tr").remove();
596
-						                     } else if (delresult.indexOf("failure") > -1) {
597
-						                         showAlert("Error while trying to remove auto-reply data!");
598
-						                     } else if (delresult.indexOf("not allowed") > -1) {
599
-                                                                         showAlert("You cannot remove the auto-reply saved by another user.");
600
-                                                                     }
601
-						   },
602
-						   error: function() { showAlert("Error while attempting to remove auto-reply data! You can check the Nextcloud log to find more details about this issue."); }
603
-					       });
604
-					  });
605
-				       });
606
-				  }
607
-				  removeArplRow();
608
-
609
-                                  // Add a new row
610
-                                  $("#addArplRow").click(function() {
611
-
612
-                                     if ($("#autoReplyTbl").find("tr:last-child").find(".arplPhoneNmbr").length > 0) {
613
-                                         var lastarpl = $("#autoReplyTbl").find("tr:last-child").find(".arplPhoneNmbr").attr("id").replace("arpphn-", "");
614
-                                         var indArplAdd = parseInt(lastarpl + 1);
615
-                                     } else { var indArplAdd = 0; }
616
-			             $("#autoReplyTbl").append("<tr><td><input type='text' class='arplAuthor' value='"+ cusrDisplayName +"' disabled></td><td><select id='arpphn-"+ indArplAdd +"' class='arplPhoneNmbr'>"+ numbersListItems +"</select></td><td><div id='arplmode-"+ indArplAdd +"' class='arplMode'><select id='modeselect-"+ indArplAdd +"' class='selectArplMode'><option value='' selected>Select mode</option><option value='daily'>Daily mode</option><option value='vacation'>Vacation mode</option></select><div id='modecont-"+ indArplAdd +"' class='modeContent'></div></div></td><td><textarea id='arpltxt-"+ indArplAdd +"' class='arplText' rows='20' cols='40' placeholder='Enter the auto-reply message here.'></textarea></td><td><img id='rmRow-"+ indArplAdd +"' class='removeRow' src='/apps/sms_relentless/img/closewnd.svg' title='Remove this row from the database' style='cursor:pointer;margin:9px 8px 0px 18px;'></td><td><input type='submit' id='arplsave-"+ indArplAdd +"' class='saveAutoReply' value='Save' title='Save Row' /></td></tr>");
617
-
618
-                                     selectMode();
619
-                                     saveArplRow();
620
-                                     removeArplRow();
621
-
622
-			             // Check if there is an auto-reply set for the same phone number
623
-				     $("#arpphn-"+ indArplAdd).change(function() {
624
-					 var selectedPhNb = $("#arpphn-"+ indArplAdd).val();
625
-					 var allArplPhNmbrs = $("#autoReplyTbl").find("tr").find(".arplPhoneNmbr");
626
-					 var phNbChck = 0;
627
-					 allArplPhNmbrs.each(function() {
628
-					    var slctphnb = ($(this).val())? $(this).val() : $(this).text();
629
-					    if (selectedPhNb == slctphnb) { phNbChck++; }
630
-					 });
631
-
632
-					 if (phNbChck == 2) {
633
-					     showAlert("There is already an auto-reply set up for this phone number. Please edit its own row, or choose a different phone number.");
634
-					     $(this).val('');
635
-					     return;
636
-					 }
637
-				     });
638
-                                  });
639
-
640
-		  },
641
-		  error: function() {
642
-                                    $("#autoRplPhoneNb").removeClass('icon-loading'); 
643
-                                    showAlert("Error while attempting to get the auto-reply settings! You can check the Nextcloud log to find more details about this issue.");
644
-                  }
645
-         });
646
-
647
-     },
648
-     error: function() {
649
-                  showAlert('Error while getting the settings! You can check the Nextcloud log to find more details about this issue.');
650
-     }
651
-  });
652
-
653
-
654
-
655
-  // Save personal settings for non-admin users
656
-  $("#save_sms_settings").on("click", function(event) {
657
-
658
-     if (isadm == 'reguser') {
659
-
660
-	    event.preventDefault();
661
-	    var baseUrlsave = OC.generateUrl('/apps/sms_relentless/user/updatesettings');
662
-
663
-	    var messagesperpageinit = $("#messagesperpage").val();
664
-	    var messagesperpagesec = messagesperpageinit.replace(/[^0-9]/g, '');
665
-
666
-	    if (messagesperpagesec != '') {
667
-		var messagesperpageproc = messagesperpagesec;
668
-	    } else {
669
-		var messagesperpageproc = 100;
670
-	    }
671
-
672
-	    var getnotify = 0;
673
-
674
-	    if ($("#get_notify").is(':checked')) {
675
-		getnotify = 1;
676
-	    }
677
-
678
-	    var emailaddressinit = $("#notification_email").val();
679
-
680
-	    function validate_email($email) {
681
-		var email_reg = /^([\w-\.]+@([\w-]+\.)+[\w-]{2,4})?$/;
682
-		return email_reg.test($email);
683
-	    }
684
-
685
-	    if (validate_email(emailaddressinit)) {
686
-		 var notifyemail = emailaddressinit;
687
-	    } else {
688
-		 var notifyemail = '';
689
-	    }
690
-
691
-	    var includesmsinemail = 0;
692
-	    if ($("#includesmsinemail").is(':checked')) {
693
-		includesmsinemail = 1;
694
-                if ($("#notification_email").val().trim() == '') {
695
-                    showAlert("Please enter an email address in the field: 'I want to receive a notification to the email address from below ...', or uncheck the checkbox: 'Include the SMS/MMS message in the email notification itself'.");
696
-                    return;
697
-                }
698
-	    }
699
-
700
-	    var showdisplaynm = 0;
701
-	    if ($("#showdisplaynames").is(':checked')) {
702
-		showdisplaynm = 1;
703
-	    }
704
-
705
-	    var adddisplaynm = 0;
706
-	    if ($("#adddisplaynames").is(':checked')) {
707
-		adddisplaynm = 1;
708
-	    }
709
-
710
-	    var datatosave = {
711
-			      userId: userid,
712
-		              telapiUrlRec: $("#telapi_url_rec").val(),
713
-		              telapiUrl: $("#telapi_url").val(),
714
-		              nexapiUrlRec: $("#nexapi_url_rec").val(),
715
-		              nexapiUrl: $("#nexapi_url").val(),
716
-		              twilapiUrlRec: $("#twilapi_url_rec").val(),
717
-		              twilapiUrl: $("#twilapi_url").val(),
718
-		              flowapiUrlRec: $("#flowapi_url_rec").val(),
719
-		              flowapiUrl: $("#flowapi_url").val(),
720
-			      messagesperpage: messagesperpageproc,
721
-			      getNotify: getnotify,
722
-			      notificationEmail: notifyemail,
723
-			      getsmsinemail: includesmsinemail,
724
-			      showDisplayNames: showdisplaynm,
725
-                              addDisplayNames: adddisplaynm
726
-	    };
727
-
728
-
729
-	    $.ajax({
730
-	       method: 'PUT',
731
-	       url: baseUrlsave + '/' + userid,
732
-	       contentType: 'application/json',
733
-	       data: JSON.stringify(datatosave),
734
-	       success: function() {
735
-                               OC.msg.startAction('#smsr_save_msg', t('sms_relentless', 'Saved'));
736
-	       },
737
-	       error: function() {
738
-		    showAlert('Error while attempting to save the settings! You can check the Nextcloud log to find more details about this issue.');
739
-	       }
740
-	    });
741
-
742
-
743
-     } else if (isadm == 'admin') {
744
-
745
-	    // Save personal settings for admins
746
-	    event.preventDefault();
747
-	    var baseUrlsaveadm = OC.generateUrl('/apps/sms_relentless/user/updatepersadmnsettings');
748
-
749
-	    var messagesperpageinit = $("#messagesperpage").val();
750
-	    var messagesperpagesec = messagesperpageinit.replace(/[^0-9]/g, '');
751
-
752
-	    if (messagesperpagesec != '') {
753
-		var messagesperpageproc = messagesperpagesec;
754
-	    } else {
755
-		var messagesperpageproc = 100;
756
-	    }
757
-
758
-	    var getnotify = 0;
759
-
760
-	    if ($("#get_notify").is(':checked')) {
761
-		getnotify = 1;
762
-	    }
763
-
764
-	    var emailaddressinit = $("#notification_email").val();
765
-
766
-	    function validate_email($email) {
767
-		var email_reg = /^([\w-\.]+@([\w-]+\.)+[\w-]{2,4})?$/;
768
-		return email_reg.test($email);
769
-	    }
770
-
771
-	    if (validate_email(emailaddressinit)) {
772
-		 var notifyemail = emailaddressinit;
773
-	    } else {
774
-		 var notifyemail = '';
775
-	    }
776
-
777
-	    var includesmsinemail = 0;
778
-	    if ($("#includesmsinemail").is(':checked')) {
779
-		includesmsinemail = 1;
780
-                if ($("#notification_email").val().trim() == '') {
781
-                    showAlert("Please enter an email address in the field: 'I want to receive a notification to the email address from below ...', or uncheck the checkbox: 'Include the SMS/MMS message in the email notification itself'.");
782
-                    return;
783
-                }
784
-	    }
785
-
786
-	    var showdisplaynm = 0;
787
-	    if ($("#showdisplaynames").is(':checked')) {
788
-		showdisplaynm = 1;
789
-	    }
790
-
791
-	    var adddisplaynm = 0;
792
-	    if ($("#adddisplaynames").is(':checked')) {
793
-		adddisplaynm = 1;
794
-	    }
795
-
796
-	    var datatosave = {
797
-			      userId: userid,
798
-			      messagesperpage: messagesperpageproc,
799
-			      getNotify: getnotify,
800
-			      notificationEmail: notifyemail,
801
-			      getsmsinemail: includesmsinemail,
802
-			      showDisplayNames: showdisplaynm,
803
-                              addDisplayNames: adddisplaynm
804
-	    };
805
-
806
-
807
-	    $.ajax({
808
-	       method: 'PUT',
809
-	       url: baseUrlsaveadm + '/' + userid,
810
-	       contentType: 'application/json',
811
-	       data: JSON.stringify(datatosave),
812
-	       success: function() {
813
-                               OC.msg.startAction('#smsr_save_msg', t('sms_relentless', 'Saved'));
814
-	       },
815
-	       error: function() {
816
-		    showAlert('Error while attempting to save the settings! You can check the Nextcloud log to find more details about this issue.');
817
-	       }
818
-	    });
819
-
820
-     }
821
-  });
822
-
823
-  function showAlert(alertText) {
824
-
825
-     let alertwnd = "<div id='alertMessage'>";
826
-     alertwnd += "<a id='closeAlertWnd' title='Close this window'></a>";
827
-     alertwnd += "<div id='alertTextWrap'>"+ alertText +"</div>";
828
-     alertwnd += "<input type='submit' id='alertOk' value='OK'>";
829
-     alertwnd += "</div>";
830
-
831
-     $("#content").append("<div id='alertMsgOverlay'></div>");
832
-     $("#content").append(alertwnd);
833
-
834
-     let topDist = parseInt((window.innerHeight / 2).toFixed(2) - 152) +"px";
835
-     let leftDist = parseInt((window.innerWidth / 2).toFixed(2) - 150) +"px";
836
-     $("#alertMessage").css({ "top" : topDist, "left" : leftDist });
837
-
838
-     $("#closeAlertWnd").click(function() { $("#alertMsgOverlay").remove(); $("#alertMessage").remove(); });
839
-     $("#alertMsgOverlay").click(function() { $("#alertMsgOverlay").remove(); $("#alertMessage").remove(); });
840
-     $("#alertOk").click(function() { $("#alertMsgOverlay").remove(); $("#alertMessage").remove(); });
841
-  }
842
-
843
-  function confirmAlert(alertText) {
844
-
845
-     $("#alertMsgOverlay").remove();
846
-     $("#alertConfMessage").remove();
847
-
848
-     let alertwndcf = "<div id='alertConfMessage'>";
849
-     alertwndcf += "<a id='closeAlertWndcf' title='Close this window'></a>";
850
-     alertwndcf += "<div id='alertTextWrap'>"+ alertText +"</div>";
851
-     alertwndcf += "<div id='cancelOkWrap'><input type='submit' id='confirmCancel' value='Cancel'>";
852
-     alertwndcf += "<input type='submit' id='confirmOk' value='OK'></div>";
853
-     alertwndcf += "</div>";
854
-
855
-     $("#content").append("<div id='alertMsgOverlay'></div>");
856
-     $("#content").append(alertwndcf);
857
-
858
-     let topDist = parseInt((window.innerHeight / 2).toFixed(2) - 152) +"px";
859
-     let leftDist = parseInt((window.innerWidth / 2).toFixed(2) - 150) +"px";
860
-     $("#alertConfMessage").css({ "top" : topDist, "left" : leftDist });
861
-
862
-     $("#closeAlertWndcf").click(function() { $("#alertMsgOverlay").remove(); $("#alertConfMessage").remove(); });
863
-     $("#alertMsgOverlay").click(function() { $("#alertMsgOverlay").remove(); $("#alertConfMessage").remove(); });
864
-  }
865
-
866
-});
Browse code

added CHANGELOG.txt appinfo/info.xml appinfo/signature.json css/style.css js/settings.js lib/Service/SmsrelentlessService.php lib/Controller/AuthorApiController.php templates/settings/admin.php

DoubleBastionAdmin authored on 03/11/2023 19:56:13
Showing 1 changed files
1 1
new file mode 100644
... ...
@@ -0,0 +1,866 @@
1
+/**
2
+ * @copyright 2021 Double Bastion LLC <www.doublebastion.com>
3
+ *
4
+ * @author Double Bastion LLC
5
+ *
6
+ * @license GNU AGPL version 3 or any later version
7
+ *
8
+ * This program is free software; you can redistribute it and/or
9
+ * modify it under the terms of the GNU AFFERO GENERAL PUBLIC LICENSE
10
+ * License as published by the Free Software Foundation; either
11
+ * version 3 of the License, or any later version.
12
+ *
13
+ * This program is distributed in the hope that it will be useful,
14
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
15
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
16
+ * GNU AFFERO GENERAL PUBLIC LICENSE for more details.
17
+ *
18
+ * You should have received a copy of the GNU Affero General Public
19
+ * License along with this program.  If not, see <http://www.gnu.org/licenses/>.
20
+ *
21
+ */
22
+
23
+$(document).ready(function() {
24
+
25
+  var userid = "<?php p($userId); ?>";
26
+  var isadm = '';
27
+
28
+  // Get personal settings
29
+  var baseUrlget = OC.generateUrl('/apps/sms_relentless/user/getsettings');
30
+
31
+  $.ajax({
32
+     method: 'GET',
33
+     url: baseUrlget + '/' + userid,
34
+     contentType: 'application/json',
35
+     success: function(settingsfromdb) {
36
+
37
+         // Add the webhook URLs section, if the user is not an admin
38
+         if (settingsfromdb.adminornot == 'reguser') {
39
+
40
+             isadm = 'reguser';
41
+
42
+             $("#appTitlePrg").append('<p id="settings-dscr"><h3>Enter your options in the fields from below. As a non-admin user, you can use any of the SMS service providers from \
43
+                  below (Telnyx/Plivo/Twilio/Flowroute), on the condition that an admin has shared with you his API keys for that provider. If an admin has shared with you his API \
44
+                  keys for a provider, to be able to use them properly, you will have to generate the two webhook URLs for that provider by clicking the corresponding \
45
+                  "Generate new webhook URL ..." buttons from below, then click "Save" at the bottom of this page:</h3></p><br>');
46
+
47
+             $("#nadmProvSection").append('<div class="providerSettings"><p><label for="telapi_url_rec" class="setlabeltext"><b>Telnyx webhook URL for incoming SMS/MMS</b> (Generate \
48
+                  the URL by pressing the button from below. Don\'t forget to also click the \'Save\' button at the bottom of this page after entering all the options, to save \
49
+                  all the settings to the database.)</label></p> \
50
+                  <input type="button" id="generate_tel_rcpt" class="generateUrl" value="Generate new webhook URL for incoming SMS/MMS" /> \
51
+                  <input type="text" class="smsr_textboxspec" id="telapi_url_rec" name="telapi_url_rec" autocomplete="false" /> \
52
+                  <span id="copyToClipboardtel" class="icon icon-clippy" title="Copy to clipboard"></span><br><br> \
53
+                  \
54
+                  <p><label for="telapi_url" class="setlabeltext"><b>Telnyx webhook URL for delivery receipts</b> (This URL will be included by SMS Relentless in message sending \
55
+                  requests, so that Telnyx will know where to send the delivery receipts. Just generate it by pressing the button from below. Don\'t forget to click the \'Save\' \
56
+                  button at the bottom of this page after entering all the options, to save all the settings to the database.)</label></p> \
57
+                  <input type="button" id="generate_tel_delrcpt" class="generateUrl" value="Generate new webhook URL for delivery receipts" /> \
58
+                  <input type="text" id="telapi_url" name="telapi_url" autocomplete="false" /></div><br><br> \
59
+                  \
60
+                  <div class="providerSettings"><p><label for="nexapi_url_rec" class="setlabeltext"><b>Plivo webhook URL for incoming SMS/MMS</b> (Generate the URL by pressing \
61
+                  the button from below. Don\'t forget to also click the \'Save\' button at the bottom of this page after entering all the options, to save all the settings \
62
+                  to the database.)</label></p> \
63
+                  <input type="button" id="generate_nex_rcpt" class="generateUrl" value="Generate new webhook URL for incoming SMS/MMS" /> \
64
+                  <input type="text" class="smsr_textboxspec" id="nexapi_url_rec" name="nexapi_url_rec" autocomplete="false" /> \
65
+                  <span id="copyToClipboardnex" class="icon icon-clippy" title="Copy to clipboard"></span><br><br> \
66
+                  \
67
+                  <p><label for="nexapi_url" class="setlabeltext"><b>Plivo webhook URL for delivery receipts</b> (This URL will be included by SMS Relentless in message sending \
68
+                  requests, so that Plivo will know where to send the delivery receipts. Just generate it by pressing the button from below. Don\'t forget to click the \'Save\' \
69
+                  button at the bottom of this page after entering all the options, to save all the settings to the database.)</label></p> \
70
+                  <input type="button" id="generate_nex_delrcpt" class="generateUrl" value="Generate new webhook URL for delivery receipts" /> \
71
+                  <input type="text" id="nexapi_url" name="nexapi_url" autocomplete="false" /></div><br><br> \
72
+                  \
73
+                  <div class="providerSettings"><p><label for="twilapi_url_rec" class="setlabeltext"><b>Twilio webhook URL for incoming SMS/MMS</b> (Generate the URL by pressing \
74
+                  the button from below. Don\'t forget to also click the \'Save\' button at the bottom of this page after entering all the options, to save all the settings to \
75
+                  the database.)</label></p> \
76
+                  <input type="button" id="generate_twil_rcpt" class="generateUrl" value="Generate new webhook URL for incoming SMS/MMS" /> \
77
+                  <input type="text" class="smsr_textboxspec" id="twilapi_url_rec" name="twilapi_url_rec" autocomplete="false" /> \
78
+                  <span id="copyToClipboardtwil" class="icon icon-clippy" title="Copy to clipboard"></span><br><br> \
79
+                  \
80
+                  <p><label for="twilapi_url" class="setlabeltext"><b>Twilio webhook URL for delivery receipts</b> (This URL will be included by SMS Relentless in message sending \
81
+                  requests, so that Twilio will know where to send the delivery receipts. Just generate it by pressing the button from below. Don\'t forget to click the \'Save\' \
82
+                  button at the bottom of this page after entering all the options, to save all the settings to the database.)</label></p> \
83
+                  <input type="button" id="generate_twil_delrcpt" class="generateUrl" value="Generate new webhook URL for delivery receipts" /> \
84
+                  <input type="text" id="twilapi_url" name="twilapi_url" autocomplete="false" /></div><br><br> \
85
+                  \
86
+                  <div class="providerSettings"><p><label for="flowapi_url_rec" class="setlabeltext"><b>Flowroute webhook URL for incoming SMS/MMS</b> (Generate the URL by pressing \
87
+                  the button from below. Don\'t forget to also click the \'Save\' button at the bottom of this page after entering all the options, to save all the settings to \
88
+                  the database.)</label></p> \
89
+                  <input type="button" id="generate_flow_rcpt" class="generateUrl" value="Generate new webhook URL for incoming SMS/MMS" /> \
90
+                  <input type="text" class="smsr_textboxspec" id="flowapi_url_rec" name="flowapi_url_rec" autocomplete="false" /> \
91
+                  <span id="copyToClipboardflow" class="icon icon-clippy" title="Copy to clipboard"></span><br><br> \
92
+                  \
93
+                  <p><label for="flowapi_url" class="setlabeltext"><b>Flowroute webhook URL for delivery receipts</b> (This URL will be included by SMS Relentless in message sending \
94
+                  requests, so that Flowroute will know where to send the delivery receipts. Just generate it by pressing the button from below. Don\'t forget to click the \'Save\' \
95
+                  button at the bottom of this page after entering all the options, to save all the settings to the database.)</label></p> \
96
+                  <input type="button" id="generate_flow_delrcpt" class="generateUrl" value="Generate new webhook URL for delivery receipts" /> \
97
+                  <input type="text" id="flowapi_url" name="flowapi_url" autocomplete="false" /><br><br> \
98
+                  Flowroute only supports sending/receiving SMS/MMS messages within USA and Canada and it doesn\'t support Alphanumeric Sender IDs.</div><br>');
99
+
100
+
101
+		  $("#telapi_url_rec").val(settingsfromdb.telapi_url_rec);
102
+		  $("#telapi_url").val(settingsfromdb.telapi_url);
103
+		  $("#nexapi_url_rec").val(settingsfromdb.nexapi_url_rec);
104
+		  $("#nexapi_url").val(settingsfromdb.nexapi_url);
105
+		  $("#twilapi_url_rec").val(settingsfromdb.twilapi_url_rec);
106
+		  $("#twilapi_url").val(settingsfromdb.twilapi_url);
107
+		  $("#flowapi_url_rec").val(settingsfromdb.flowapi_url_rec);
108
+		  $("#flowapi_url").val(settingsfromdb.flowapi_url);
109
+		  $("#messagesperpage").val(settingsfromdb.messagesperpage);
110
+
111
+		  if (settingsfromdb.get_notify == 1) {
112
+		      $("#get_notify").attr('checked', true);
113
+		  } else {
114
+		      $("#get_notify").attr('checked', false);
115
+		  }
116
+
117
+		  $("#notification_email").val(settingsfromdb.notification_email);
118
+
119
+		  if (settingsfromdb.getsmsinemail == 1) {
120
+		      $("#includesmsinemail").attr('checked', true);
121
+		  } else {
122
+		      $("#includesmsinemail").attr('checked', false);
123
+		  }
124
+
125
+		  if (settingsfromdb.show_display_names == 1) {
126
+		      $("#showdisplaynames").attr('checked', true);
127
+		  } else {
128
+		      $("#showdisplaynames").attr('checked', false);
129
+		  }
130
+
131
+		  if (settingsfromdb.add_display_names == 1) {
132
+		      $("#adddisplaynames").attr('checked', true);
133
+		  } else {
134
+		      $("#adddisplaynames").attr('checked', false);
135
+		  }
136
+
137
+		  function randomStr(strlength) {
138
+			var fintext = "";
139
+			var keyspace = '0123456789abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ';
140
+			for (var i = 0; i < strlength; i++) {
141
+			     fintext += keyspace.charAt(Math.floor(Math.random() * keyspace.length));
142
+			}
143
+			return fintext;
144
+		  }
145
+
146
+		  $("#generate_tel_rcpt").on("click", function(event) {
147
+
148
+		     var teltokenrec = randomStr(70);
149
+		     var telnyxwhurlrec = window.location.origin + OC.generateUrl('/apps/sms_relentless/api/recsmstel?telrecparam=') + teltokenrec;
150
+
151
+		     $("#telapi_url_rec").val(telnyxwhurlrec);
152
+		  });
153
+
154
+		  $("#copyToClipboardtel").on("click", function(event) {
155
+		     var $tempEl = $("<input>");
156
+		     $("body").append($tempEl);
157
+		     $tempEl.val($("#telapi_url_rec").val()).select();
158
+		     document.execCommand("Copy");
159
+		     $tempEl.remove();
160
+		     showAlert("The link has been copied to your clipboard!");
161
+		  });
162
+
163
+		  $("#generate_tel_delrcpt").on("click", function(event) {
164
+
165
+		     var teltoken = randomStr(70);
166
+		     var telnyxwhurl = window.location.origin + OC.generateUrl('/apps/sms_relentless/api/recdeliverytel?teldrparam=') + teltoken;
167
+
168
+		     $("#telapi_url").val(telnyxwhurl);
169
+		  });
170
+
171
+
172
+		  $("#generate_nex_rcpt").on("click", function(event) {
173
+
174
+		     var plivotokenrec = randomStr(70);
175
+		     var plivowhurlrec = window.location.origin + OC.generateUrl('/apps/sms_relentless/api/recsmsnex?plivorecparam=') + plivotokenrec;
176
+
177
+		     $("#nexapi_url_rec").val(plivowhurlrec);
178
+		  });
179
+
180
+		  $("#copyToClipboardnex").on("click", function(event) {
181
+		     var $tempElpl = $("<input>");
182
+		     $("body").append($tempElpl);
183
+		     $tempElpl.val($("#nexapi_url_rec").val()).select();
184
+		     document.execCommand("Copy");
185
+		     $tempElpl.remove();
186
+		     showAlert("The link has been copied to your clipboard!");
187
+		  });
188
+
189
+		  $("#generate_nex_delrcpt").on("click", function(event) {
190
+
191
+		     var plivotoken = randomStr(70);
192
+		     var plivodrwhurl = window.location.origin + OC.generateUrl('/apps/sms_relentless/api/recdeliverynex?plivodrparam=') + plivotoken;
193
+
194
+		     $("#nexapi_url").val(plivodrwhurl);
195
+		  });
196
+
197
+
198
+		  $("#generate_twil_rcpt").on("click", function(event) {
199
+
200
+		     var twiltokenrec = randomStr(35);
201
+		     var twilwhurlrec = window.location.origin + OC.generateUrl('/apps/sms_relentless/api/recsmstwil?twilrecparam=') + twiltokenrec;
202
+
203
+		     $("#twilapi_url_rec").val(twilwhurlrec);
204
+		  });
205
+
206
+		  $("#copyToClipboardtwil").on("click", function(event) {
207
+		     var $tempElpl = $("<input>");
208
+		     $("body").append($tempElpl);
209
+		     $tempElpl.val($("#twilapi_url_rec").val()).select();
210
+		     document.execCommand("Copy");
211
+		     $tempElpl.remove();
212
+		     showAlert("The link has been copied to your clipboard!");
213
+		  });
214
+
215
+		  $("#generate_twil_delrcpt").on("click", function(event) {
216
+
217
+		     var twiltoken = randomStr(35);
218
+		     var twildrwhurl = window.location.origin + OC.generateUrl('/apps/sms_relentless/api/recdeliverytwil?twildrparam=') + twiltoken;
219
+
220
+		     $("#twilapi_url").val(twildrwhurl);
221
+		  });
222
+
223
+
224
+		  $("#generate_flow_rcpt").on("click", function(event) {
225
+
226
+		     var flowtokenrec = randomStr(70);
227
+		     var flowwhurlrec = window.location.origin + OC.generateUrl('/apps/sms_relentless/api/recsmsflow?flowrecparam=') + flowtokenrec;
228
+
229
+		     $("#flowapi_url_rec").val(flowwhurlrec);
230
+		  });
231
+
232
+		  $("#copyToClipboardflow").on("click", function(event) {
233
+		     var $tempElpl = $("<input>");
234
+		     $("body").append($tempElpl);
235
+		     $tempElpl.val($("#flowapi_url_rec").val()).select();
236
+		     document.execCommand("Copy");
237
+		     $tempElpl.remove();
238
+		     showAlert("The link has been copied to your clipboard!");
239
+		  });
240
+
241
+		  $("#generate_flow_delrcpt").on("click", function(event) {
242
+
243
+		     var flowtoken = randomStr(70);
244
+		     var flowdrwhurl = window.location.origin + OC.generateUrl('/apps/sms_relentless/api/recdeliveryflow?flowdrparam=') + flowtoken;
245
+
246
+		     $("#flowapi_url").val(flowdrwhurl);
247
+		  });
248
+
249
+
250
+         } else if (settingsfromdb.adminornot == 'admin') {
251
+
252
+                  $("#appTitlePrg").append('<p id="settings-dscr"><h3>First enter your credentials and options on the admin settings page (on the left panel, under Administration, \
253
+                                            click on SMS Relentless), then enter your options in the fields from below:</h3></p><br>');
254
+                  isadm = 'admin';
255
+
256
+		  $("#messagesperpage").val(settingsfromdb.messagesperpage);
257
+
258
+		  if (settingsfromdb.get_notify == 1) {
259
+		      $("#get_notify").attr('checked', true);
260
+		  } else {
261
+		      $("#get_notify").attr('checked', false);
262
+		  }
263
+
264
+		  $("#notification_email").val(settingsfromdb.notification_email);
265
+
266
+		  if (settingsfromdb.getsmsinemail == 1) {
267
+		      $("#includesmsinemail").attr('checked', true);
268
+		  } else {
269
+		      $("#includesmsinemail").attr('checked', false);
270
+		  }
271
+
272
+		  if (settingsfromdb.show_display_names == 1) {
273
+		      $("#showdisplaynames").attr('checked', true);
274
+		  } else {
275
+		      $("#showdisplaynames").attr('checked', false);
276
+		  }
277
+
278
+		  if (settingsfromdb.add_display_names == 1) {
279
+		      $("#adddisplaynames").attr('checked', true);
280
+		  } else {
281
+		      $("#adddisplaynames").attr('checked', false);
282
+		  }
283
+         }
284
+
285
+
286
+         // Auto-reply settings
287
+
288
+         // Get the available phone numbers from all providers associated with the access keys entered on the Settings page (restrictions are applied to numbers for non-admins)
289
+         $("#autoRplPhoneNb").addClass('icon-loading');
290
+         var getnumbersUrl = OC.generateUrl("/apps/sms_relentless/user/getautoreplyconf");
291
+
292
+	 $.ajax({
293
+		  url: getnumbersUrl + '/' + userid,
294
+		  type: "GET",
295
+                  contentType: 'application/json',
296
+		  success: function(autoreplydata) {
297
+
298
+                                    $("#autoRplPhoneNb").removeClass('icon-loading');
299
+                                    var cusrDisplayName = autoreplydata.userdisplayname;
300
+                                    var availPhoneNmbrs = autoreplydata.phonenumbers;
301
+                                    var autorpldata = autoreplydata.autoreplies;
302
+
303
+				    if (autorpldata.length > 0) { 
304
+				        var arplNmb = autorpldata.length;
305
+				    } else { 
306
+				        var arplNmb = 0; 
307
+				    }
308
+
309
+				    // List the auto-replies for the phone numbers available for the current user
310
+				    if (arplNmb == 0) {
311
+
312
+				        $("#autoReplyTbl").append("<tr><td><input type='text' class='arplAuthor' value='"+ cusrDisplayName +"' disabled></td><td><select id='arpphn-"+ arplNmb +"' class='arplPhoneNmbr'></select></td><td><div id='arplmode-"+ arplNmb +"' class='arplMode'><select id='modeselect-"+ arplNmb +"' class='selectArplMode'><option value='' selected>Select mode</option><option value='daily'>Daily mode</option><option value='vacation'>Vacation mode</option></select><div id='modecont-"+ arplNmb +"' class='modeContent'></div></div></td><td><textarea id='arpltxt-"+ arplNmb +"' class='arplText' rows='20' cols='40' placeholder='Enter the auto-reply message here.'></textarea></td><td><img id='rmRow-"+ arplNmb +"' class='removeRow' src='/apps/sms_relentless/img/closewnd.svg' title='Remove this row from the database' style='cursor:pointer;margin:9px 8px 0px 18px;'></td><td><input type='submit' id='arplsave-"+ arplNmb +"' class='saveAutoReply' value='Save' title='Save Row' /></td></tr>");
313
+				        $("#autoReplyTbl").append("<div><img id='addArplRow' src='/apps/sms_relentless/img/add.svg' title='Add Row'></div>");
314
+
315
+				    } else {
316
+
317
+				        for (k = 0; k < arplNmb; k++) {
318
+
319
+                                             if (autorpldata[k].days_of_week != '') {
320
+
321
+                                                 var slctdMode = "<option value=''>Select mode</option><option value='daily' selected>Daily mode</option><option value='vacation'>Vacation mode</option>";
322
+                                                 var dailyStartArr = autorpldata[k].daily_start.split(":");
323
+                                                 var dailyEndArr = autorpldata[k].daily_end.split(":");
324
+
325
+		                                 var dlHrStartOptions = "";
326
+			                         for (var hr = 0; hr < 24; hr++) {
327
+		                                      if (dailyStartArr[0] != hr.toLocaleString('en-US', {minimumIntegerDigits: 2, useGrouping:false})) {
328
+			                                  dlHrStartOptions += "<option value='"+ hr.toLocaleString('en-US', {minimumIntegerDigits: 2, useGrouping:false}) +"'>"+ hr.toLocaleString('en-US', {minimumIntegerDigits: 2, useGrouping:false}) +"</option>";
329
+		                                      } else {
330
+			                                  dlHrStartOptions += "<option value='"+ hr.toLocaleString('en-US', {minimumIntegerDigits: 2, useGrouping:false}) +"' selected>"+ hr.toLocaleString('en-US', {minimumIntegerDigits: 2, useGrouping:false}) +"</option>";
331
+		                                      }
332
+			                         }
333
+
334
+		                                 var dlMnStartOptions = "";
335
+			                         for (var mn = 0; mn < 60; mn++) {
336
+		                                      if (dailyStartArr[1] != mn.toLocaleString('en-US', {minimumIntegerDigits: 2, useGrouping:false})) {
337
+			                                  dlMnStartOptions += "<option value='"+ mn.toLocaleString('en-US', {minimumIntegerDigits: 2, useGrouping:false}) +"'>"+ mn.toLocaleString('en-US', {minimumIntegerDigits: 2, useGrouping:false}) +"</option>";
338
+		                                      } else {
339
+			                                  dlMnStartOptions += "<option value='"+ mn.toLocaleString('en-US', {minimumIntegerDigits: 2, useGrouping:false}) +"' selected>"+ mn.toLocaleString('en-US', {minimumIntegerDigits: 2, useGrouping:false}) +"</option>";
340
+		                                      }
341
+			                         }
342
+
343
+		                                 var dlHrEndOptions = "";
344
+			                         for (var hr = 0; hr < 24; hr++) {
345
+		                                      if (dailyEndArr[0] != hr.toLocaleString('en-US', {minimumIntegerDigits: 2, useGrouping:false})) {
346
+			                                  dlHrEndOptions += "<option value='"+ hr.toLocaleString('en-US', {minimumIntegerDigits: 2, useGrouping:false}) +"'>"+ hr.toLocaleString('en-US', {minimumIntegerDigits: 2, useGrouping:false}) +"</option>";
347
+		                                      } else {
348
+			                                  dlHrEndOptions += "<option value='"+ hr.toLocaleString('en-US', {minimumIntegerDigits: 2, useGrouping:false}) +"' selected>"+ hr.toLocaleString('en-US', {minimumIntegerDigits: 2, useGrouping:false}) +"</option>";
349
+		                                      }
350
+			                         }
351
+
352
+		                                 var dlMnEndOptions = "";
353
+			                         for (var mn = 0; mn < 60; mn++) {
354
+		                                      if (dailyEndArr[1] != mn.toLocaleString('en-US', {minimumIntegerDigits: 2, useGrouping:false})) {
355
+			                                  dlMnEndOptions += "<option value='"+ mn.toLocaleString('en-US', {minimumIntegerDigits: 2, useGrouping:false}) +"'>"+ mn.toLocaleString('en-US', {minimumIntegerDigits: 2, useGrouping:false}) +"</option>";
356
+		                                      } else {
357
+			                                  dlMnEndOptions += "<option value='"+ mn.toLocaleString('en-US', {minimumIntegerDigits: 2, useGrouping:false}) +"' selected>"+ mn.toLocaleString('en-US', {minimumIntegerDigits: 2, useGrouping:false}) +"</option>";
358
+		                                      }
359
+			                         }
360
+
361
+                                                 var modeContent = "<div class='daysOfWeek'>Days of the week:<div class='tooltipautoreply'><div id='infoautoreply'>i</div><div class='autorpltooltip'>Enter the order number of the days of the week in which the auto-reply will be sent. For example, to send the auto-reply every day from Monday to Friday outside the time interval specified below, enter 1,2,3,4,5 To send the auto-reply only Monday, Thursday and Friday enter 1,4,5 To send the auto-reply every day of the week enter 1,2,3,4,5,6,7 As an exception, if you want the auto-reply to be sent during an entire day, irrespective of the specified interval, add (full) after the number of that day. For example, if you want the auto-reply to be sent from Monday to Friday outside the interval specified below, and also during the entire days of Saturday and Sunday, enter 1,2,3,4,5,6(full),7(full)</div></div></div><input type='text' id='weekdays-"+ k +"' class='daysInWeek' value='"+ autorpldata[k].days_of_week +"'><div class='chooseTInterval'>Send auto-reply <span style='color:#ad0202'>outside</span> this interval:<div class='tooltipautoreplyst'><div id='infoautoreplyst'>i</div><div class='autorpltooltipst'>These fields specify the time of the server. If the server is located in a time zone that is different from that of the owner/company, the time interval entered here should be adjusted accordingly.</div></div></div><div class='selectArplHours'><select id='dmstarthr-"+ k +"' class='selectHrMin'>"+ dlHrStartOptions +"</select><select id='dmstartmn-"+ k +"' class='selectHrMin'>"+ dlMnStartOptions +"</select><span style='font-weight: 600'> — </span><select id='dmendhr-"+ k +"' class='selectHrMin'>"+ dlHrEndOptions +"</select><select id='dmendmn-"+ k +"' class='selectHrMin'>"+ dlMnEndOptions +"</select></div>";
362
+
363
+                                             } else {
364
+
365
+                                                 var vctnStart = autorpldata[k].vacation_start.split(" ")[0];
366
+                                                 var vctnEnd = autorpldata[k].vacation_end.split(" ")[0];
367
+
368
+                                                 var slctdMode = "<option value=''>Select mode</option><option value='daily'>Daily mode</option><option value='vacation' selected>Vacation mode</option>";
369
+                                                 var modeContent = "<div class='chooseDateIntvl'>Send auto-reply <span style='color:#ad0202'>inside</span> this interval:</div><div class='arplstrtendDates'><div class='stdtTitle'>Start Date</div><input type='text' id='startDT-"+ k +"' class='startDate' placeholder='Pick a date' value='"+ vctnStart +"'><div class='enddtTitle'>End Date</div><input type='text' id='endDT-"+ k +"' class='endDate' placeholder='Pick a date' value='"+ vctnEnd +"'></div>"
370
+                                             }
371
+
372
+				             $("#autoReplyTbl").append("<tr><td><input type='text' class='arplAuthor' value='"+ autorpldata[k].saved_by_dsplname +"' disabled></td><td><select id='arpphn-"+ k +"' class='arplPhoneNmbr' style='pointer-events:none'><option selected>"+ autorpldata[k].phone_number +"</option></select></td><td><div id='arplmode-"+ k +"' class='arplMode'><select id='modeselect-"+ k +"' class='selectArplMode'>"+ slctdMode +"</select><div id='modecont-"+ k +"' class='modeContent'>"+ modeContent +"</div></div></td><td><textarea id='arpltxt-"+ k +"' class='arplText' rows='20' cols='40' placeholder='Enter the auto-reply message here.'>"+ autorpldata[k].message_text +"</textarea></td><td><img id='rmRow-"+ k +"' class='removeRow' src='/apps/sms_relentless/img/closewnd.svg' title='Remove this row from the database' style='cursor:pointer;margin:9px 8px 0px 18px;'></td><td><input type='submit' id='arplsave-"+ k +"' class='saveAutoReply' value='Edit' title='Edit Row' /></td></tr>");
373
+				        }
374
+				        $("#autoReplyTbl").append("<div><img id='addArplRow' src='/apps/sms_relentless/img/add.svg' title='Add Row'></div>");
375
+				    }
376
+
377
+
378
+				    // Create a list with all the available phone numbers
379
+                                    var numbersListItems = "<option value='' selected>Select phone number</option>";
380
+
381
+				    $.each(availPhoneNmbrs, function(key, indsmsnmb) {
382
+				           numbersListItems += "<option value='"+ indsmsnmb +"'>"+ indsmsnmb +"</option>";
383
+				    });
384
+
385
+                                    if (arplNmb == 0) {
386
+				        $("#arpphn-"+ arplNmb).append(numbersListItems);
387
+                                    }
388
+
389
+                                    // Initialize the date picker
390
+			            $('[id^="endDT-"]').datepicker({ dateFormat: "yy-mm-dd" });
391
+			            $('[id^="startDT-"]').datepicker({ dateFormat: "yy-mm-dd" });
392
+
393
+
394
+                                    // Select the auto-reply mode
395
+                                    function selectMode() {
396
+
397
+		                            $('[id^="modeselect-"]').change(function() {
398
+
399
+		                               var crtnmbr = $(this).attr("id").replace("modeselect-", "");
400
+
401
+		                               var dailyHrStart = "";
402
+		                               for (var h = 0; h < 24; h++) {
403
+		                                    dailyHrStart += "<option value='"+ h.toLocaleString('en-US', {minimumIntegerDigits: 2, useGrouping:false}) +"'>"+ h.toLocaleString('en-US', {minimumIntegerDigits: 2, useGrouping:false}) +"</option>";
404
+		                               }
405
+
406
+		                               var dailyMnStart = "";
407
+		                               for (var m = 0; m < 60; m++) {
408
+		                                    dailyMnStart += "<option value='"+ m.toLocaleString('en-US', {minimumIntegerDigits: 2, useGrouping:false}) +"'>"+ m.toLocaleString('en-US', {minimumIntegerDigits: 2, useGrouping:false}) +"</option>";
409
+		                               }
410
+
411
+		                               var dailyHrEnd = dailyHrStart;
412
+		                               var dailyMnEnd = dailyMnStart;
413
+
414
+		                               if ($(this).val() == 'daily') {
415
+		                                   $("#modecont-"+ crtnmbr).empty();
416
+		                                   $("#modecont-"+ crtnmbr).append("<div class='daysOfWeek'>Days of the week:<div class='tooltipautoreply'><div id='infoautoreply'>i</div><div class='autorpltooltip'>Enter the order number of the days of the week in which the auto-reply will be sent. For example, to send the auto-reply every day from Monday to Friday outside the time interval specified below, enter 1,2,3,4,5 To send the auto-reply only Monday, Thursday and Friday enter 1,4,5 To send the auto-reply every day of the week enter 1,2,3,4,5,6,7 As an exception, if you want the auto-reply to be sent during an entire day, irrespective of the specified interval, add (full) after the number of that day. For example, if you want the auto-reply to be sent from Monday to Friday outside the interval specified below, and also during the entire days of Saturday and Sunday, enter 1,2,3,4,5,6(full),7(full)</div></div></div><input type='text' id='weekdays-"+ crtnmbr +"' class='daysInWeek'><div class='chooseTInterval'>Send auto-reply <span style='color:#ad0202'>outside</span> this interval:<div class='tooltipautoreplyst'><div id='infoautoreplyst'>i</div><div class='autorpltooltipst'>These fields specify the time of the server. If the server is located in a time zone that is different from that of the owner/company, the time interval entered here should be adjusted accordingly.</div></div></div><div class='selectArplHours'><select id='dmstarthr-"+ crtnmbr +"' class='selectHrMin'>"+ dailyHrStart +"</select><select id='dmstartmn-"+ crtnmbr +"' class='selectHrMin'>"+ dailyMnStart +"</select><span style='font-weight: 600'> — </span><select id='dmendhr-"+ crtnmbr +"' class='selectHrMin'>"+ dailyHrEnd +"</select><select id='dmendmn-"+ crtnmbr +"' class='selectHrMin'>"+ dailyMnEnd +"</select></div>");
417
+		                               } else if ($(this).val() == 'vacation') {
418
+		                                   $("#modecont-"+ crtnmbr).empty();
419
+		                                   $("#modecont-"+ crtnmbr).append("<div class='chooseDateIntvl'>Send auto-reply <span style='color:#ad0202'>inside</span> this interval:</div><div class='arplstrtendDates'><div class='stdtTitle'>Start Date</div><input type='text' id='startDT-"+ crtnmbr +"' class='startDate' placeholder='Pick a date'><div class='enddtTitle'>End Date</div><input type='text' id='endDT-"+ crtnmbr +"' class='endDate' placeholder='Pick a date' /></div>");
420
+		                               }
421
+
422
+					       $("#endDT-"+ crtnmbr +"").datepicker({ dateFormat: "yy-mm-dd" });
423
+					       $("#startDT-"+ crtnmbr +"").datepicker({ dateFormat: "yy-mm-dd" });
424
+		                          });
425
+                                  }
426
+                                  selectMode();
427
+
428
+				  // Save the data
429
+				  function saveArplRow() {
430
+
431
+				     $('[id^="arplsave-"]').unbind("click");
432
+				     $('[id^="arplsave-"]').click(function(event) {
433
+
434
+				        event.preventDefault();
435
+				        var crntrwnmbr = $(this).attr("id").replace("arplsave-", "");
436
+
437
+				        if ($(this).attr("value") == "Save") {
438
+
439
+				            var phoneNmbr = $("#arpphn-"+ crntrwnmbr).val();
440
+				            var arplText = $("#arpltxt-"+ crntrwnmbr).val();
441
+				            var slctdMode = $("#modeselect-"+ crntrwnmbr).val();
442
+
443
+				            var slctddmDays = "";
444
+				            var slctdHrStart = "";
445
+				            var slctdMnStart = "";
446
+				            var slctdHrEnd = "";
447
+				            var slctdMnEnd = "";
448
+
449
+				            var vcStartDate = null;
450
+				            var vcEndDate = null;
451
+
452
+				            if (slctdMode == 'daily') {
453
+
454
+				                slctddmDays = $("#weekdays-"+ crntrwnmbr).val().trim();
455
+				                slctdHrStart = $("#dmstarthr-"+ crntrwnmbr).val().trim();
456
+				                slctdMnStart = $("#dmstartmn-"+ crntrwnmbr).val().trim();
457
+				                slctdHrEnd = $("#dmendhr-"+ crntrwnmbr).val().trim();
458
+				                slctdMnEnd = $("#dmendmn-"+ crntrwnmbr).val().trim();
459
+
460
+                                                if (slctdHrStart != '' && slctdMnStart != '') {
461
+                                                    var hrmnStartComp = slctdHrStart +":"+ slctdMnStart;
462
+                                                } else { var hrmnStartComp = ""; }
463
+
464
+                                                if (slctdHrEnd != '' && slctdMnEnd != '') {
465
+                                                    var hrmnEndComp = slctdHrEnd +":"+ slctdMnEnd;
466
+                                                } else { var hrmnEndComp = ""; }
467
+
468
+                                                if (!(/^[1-7ful\,\(\)]+$/.test(slctddmDays))) {
469
+				                    showAlert("The 'Days of the week' field can contain only digits from 1 to 7, the lowercase letters f, u and l, round brackets ()() and commas (,).");
470
+				                    return;
471
+                                                }
472
+
473
+                                                if (!(/^[0-9]+$/.test(slctdHrStart + slctdMnStart + slctdHrEnd + slctdMnEnd))) {
474
+				                    showAlert("The starting and ending values of the time interval for the 'Daily mode' can contain only digits from 0 to 9.");
475
+				                    return;
476
+                                                }
477
+
478
+                                                if (slctddmDays.trim() == '' || (slctdHrStart == slctdHrEnd && slctdMnStart == slctdMnEnd)) {
479
+				                    showAlert("For the 'Daily mode', you have to enter the order number of the days of the week for which you want the auto-reply to be sent, and you have to set a starting time that is different from the ending time!");
480
+				                    return;
481
+                                                }
482
+
483
+				            } else if (slctdMode == 'vacation') {
484
+		
485
+                                                if ($("#startDT-"+ crntrwnmbr).val().trim() == '' || $("#endDT-"+ crntrwnmbr).val().trim() == '') {
486
+
487
+				                    showAlert("For the 'Vacation mode', you have to enter both a start date and an end date.");
488
+				                    return;
489
+
490
+                                                } else {
491
+
492
+                                                    if (!(/^[0-9\-]+$/.test($("#startDT-"+ crntrwnmbr).val().trim() + $("#endDT-"+ crntrwnmbr).val().trim()))) {
493
+				                        showAlert("The start date and end date values for the 'Vacation mode' can contain only digits from 0 to 9 and hyphens (-).");
494
+				                        return;
495
+                                                    }
496
+
497
+		                                    vcStartDate = $("#startDT-"+ crntrwnmbr).val().trim() +" 00:00:00";
498
+				                    vcEndDate = $("#endDT-"+ crntrwnmbr).val().trim() +" 23:59:59";
499
+				                    var strtDateCmp = new Date(vcStartDate).toJSON().slice(0, 10) +" 00:00:00";
500
+				                    var endDateCmp = new Date(vcEndDate).toJSON().slice(0, 10) +" 23:59:59";
501
+				                    var crntDate = new Date().toJSON().slice(0, 10) +" 23:59:59";
502
+
503
+                                                    if (vcStartDate.trim() == "" || vcEndDate.trim() == "" || (strtDateCmp >= endDateCmp || ((strtDateCmp < crntDate) && (endDateCmp < crntDate)))) {
504
+				                        showAlert("For 'Vacation mode', you have to enter both a start date and an end date, the start date must be before the end date and at least the ending of the time interval must be in the future.");
505
+				                        return;
506
+                                                    }
507
+                                                }
508
+				            }
509
+
510
+
511
+				            if (phoneNmbr != '') {
512
+
513
+				              if (arplText.trim() != '') {
514
+
515
+				                if (slctdMode != '') {
516
+
517
+				                    var saveArplUrl = OC.generateUrl('/apps/sms_relentless/user/updateautoreplies');
518
+				                    var arpldata = {
519
+				                         userId: userid,
520
+				                         savedByDsplname: cusrDisplayName,
521
+				                         phoneNumber: phoneNmbr,
522
+				                         daysOfWeek: slctddmDays,
523
+				                         dailyStart: hrmnStartComp,
524
+				                         dailyEnd: hrmnEndComp,
525
+				                         vacationStart: vcStartDate,
526
+				                         vacationEnd: vcEndDate,
527
+				                         messageText: arplText
528
+				                    };
529
+
530
+					            $.ajax({
531
+					              method: 'PUT',
532
+					              url: saveArplUrl + '/' + userid,
533
+					              contentType: 'application/json',
534
+					              data: JSON.stringify(arpldata),
535
+				                      success: function(messagereceived) {
536
+
537
+				                                   if (messagereceived == 'success') {
538
+				                                       showAlert('The auto-reply has been successfully saved to the database!');
539
+				                                   } else if (messagereceived == 'failure') {
540
+				                                       showAlert('Error while trying to save the auto-reply!');
541
+				                                   } else if (messagereceived == 'not allowed') {
542
+                                                                       showAlert('You cannot change an auto-reply that was saved by a different user.');
543
+                                                                   }
544
+				                      },
545
+					              error: function() {
546
+						                   showAlert('Error while attempting to save the auto-reply! You can check the Nextcloud log to find more details about this issue.');
547
+					              }
548
+					            });
549
+
550
+
551
+                                                } else { showAlert("Please select the auto-reply mode."); return; }
552
+
553
+                                              } else { showAlert("Please enter the text of the auto-reply."); return; }
554
+
555
+                                            } else { showAlert("Please select a phone number if at least one number is available in the 'Phone Number' drop-down list. Otherwise, you should contact the administrator."); return; }
556
+
557
+                                            $(this).attr("value", "Edit");
558
+
559
+                                        } else {
560
+                                            $("#arplsave-"+ crntrwnmbr).attr("value", "Save");
561
+                                        }
562
+
563
+                                     });
564
+
565
+				  }
566
+                                  saveArplRow();
567
+
568
+
569
+				  // Remove a row
570
+				  function removeArplRow() {
571
+				       $('[id^="rmRow-"]').click(function() {
572
+
573
+					  var slctRowRm = $(this).attr("id").replace("rmRow-", "");
574
+					  var crntPhnNmbr = $("#arpphn-"+ slctRowRm).val();
575
+
576
+				          confirmAlert("Do you really want to remove this row from the database ?");
577
+
578
+				          $("#confirmCancel").click(function() { $("#alertMsgOverlay").remove(); $("#alertConfMessage").remove(); });
579
+
580
+				          $("#confirmOk").click(function() {
581
+
582
+				              $("#alertMsgOverlay").remove();
583
+				              $("#alertConfMessage").remove();
584
+
585
+					      var rmvArplUrl = OC.generateUrl('/apps/sms_relentless/user/removeautoreplies');
586
+					      $.ajax({
587
+						   url: rmvArplUrl + '/' + userid,
588
+						   method: "POST",
589
+						   dataType: "text",
590
+						   data: { phoneNumber: crntPhnNmbr },
591
+						   success: function(delresult) {
592
+
593
+						                     if (delresult.indexOf("success") > -1) {
594
+						                         showAlert("The auto-reply has been removed successfully!");
595
+						                         $("#arpphn-"+ slctRowRm).closest("tr").remove();
596
+						                     } else if (delresult.indexOf("failure") > -1) {
597
+						                         showAlert("Error while trying to remove auto-reply data!");
598
+						                     } else if (delresult.indexOf("not allowed") > -1) {
599
+                                                                         showAlert("You cannot remove the auto-reply saved by another user.");
600
+                                                                     }
601
+						   },
602
+						   error: function() { showAlert("Error while attempting to remove auto-reply data! You can check the Nextcloud log to find more details about this issue."); }
603
+					       });
604
+					  });
605
+				       });
606
+				  }
607
+				  removeArplRow();
608
+
609
+                                  // Add a new row
610
+                                  $("#addArplRow").click(function() {
611
+
612
+                                     if ($("#autoReplyTbl").find("tr:last-child").find(".arplPhoneNmbr").length > 0) {
613
+                                         var lastarpl = $("#autoReplyTbl").find("tr:last-child").find(".arplPhoneNmbr").attr("id").replace("arpphn-", "");
614
+                                         var indArplAdd = parseInt(lastarpl + 1);
615
+                                     } else { var indArplAdd = 0; }
616
+			             $("#autoReplyTbl").append("<tr><td><input type='text' class='arplAuthor' value='"+ cusrDisplayName +"' disabled></td><td><select id='arpphn-"+ indArplAdd +"' class='arplPhoneNmbr'>"+ numbersListItems +"</select></td><td><div id='arplmode-"+ indArplAdd +"' class='arplMode'><select id='modeselect-"+ indArplAdd +"' class='selectArplMode'><option value='' selected>Select mode</option><option value='daily'>Daily mode</option><option value='vacation'>Vacation mode</option></select><div id='modecont-"+ indArplAdd +"' class='modeContent'></div></div></td><td><textarea id='arpltxt-"+ indArplAdd +"' class='arplText' rows='20' cols='40' placeholder='Enter the auto-reply message here.'></textarea></td><td><img id='rmRow-"+ indArplAdd +"' class='removeRow' src='/apps/sms_relentless/img/closewnd.svg' title='Remove this row from the database' style='cursor:pointer;margin:9px 8px 0px 18px;'></td><td><input type='submit' id='arplsave-"+ indArplAdd +"' class='saveAutoReply' value='Save' title='Save Row' /></td></tr>");
617
+
618
+                                     selectMode();
619
+                                     saveArplRow();
620
+                                     removeArplRow();
621
+
622
+			             // Check if there is an auto-reply set for the same phone number
623
+				     $("#arpphn-"+ indArplAdd).change(function() {
624
+					 var selectedPhNb = $("#arpphn-"+ indArplAdd).val();
625
+					 var allArplPhNmbrs = $("#autoReplyTbl").find("tr").find(".arplPhoneNmbr");
626
+					 var phNbChck = 0;
627
+					 allArplPhNmbrs.each(function() {
628
+					    var slctphnb = ($(this).val())? $(this).val() : $(this).text();
629
+					    if (selectedPhNb == slctphnb) { phNbChck++; }
630
+					 });
631
+
632
+					 if (phNbChck == 2) {
633
+					     showAlert("There is already an auto-reply set up for this phone number. Please edit its own row, or choose a different phone number.");
634
+					     $(this).val('');
635
+					     return;
636
+					 }
637
+				     });
638
+                                  });
639
+
640
+		  },
641
+		  error: function() {
642
+                                    $("#autoRplPhoneNb").removeClass('icon-loading'); 
643
+                                    showAlert("Error while attempting to get the auto-reply settings! You can check the Nextcloud log to find more details about this issue.");
644
+                  }
645
+         });
646
+
647
+     },
648
+     error: function() {
649
+                  showAlert('Error while getting the settings! You can check the Nextcloud log to find more details about this issue.');
650
+     }
651
+  });
652
+
653
+
654
+
655
+  // Save personal settings for non-admin users
656
+  $("#save_sms_settings").on("click", function(event) {
657
+
658
+     if (isadm == 'reguser') {
659
+
660
+	    event.preventDefault();
661
+	    var baseUrlsave = OC.generateUrl('/apps/sms_relentless/user/updatesettings');
662
+
663
+	    var messagesperpageinit = $("#messagesperpage").val();
664
+	    var messagesperpagesec = messagesperpageinit.replace(/[^0-9]/g, '');
665
+
666
+	    if (messagesperpagesec != '') {
667
+		var messagesperpageproc = messagesperpagesec;
668
+	    } else {
669
+		var messagesperpageproc = 100;
670
+	    }
671
+
672
+	    var getnotify = 0;
673
+
674
+	    if ($("#get_notify").is(':checked')) {
675
+		getnotify = 1;
676
+	    }
677
+
678
+	    var emailaddressinit = $("#notification_email").val();
679
+
680
+	    function validate_email($email) {
681
+		var email_reg = /^([\w-\.]+@([\w-]+\.)+[\w-]{2,4})?$/;
682
+		return email_reg.test($email);
683
+	    }
684
+
685
+	    if (validate_email(emailaddressinit)) {
686
+		 var notifyemail = emailaddressinit;
687
+	    } else {
688
+		 var notifyemail = '';
689
+	    }
690
+
691
+	    var includesmsinemail = 0;
692
+	    if ($("#includesmsinemail").is(':checked')) {
693
+		includesmsinemail = 1;
694
+                if ($("#notification_email").val().trim() == '') {
695
+                    showAlert("Please enter an email address in the field: 'I want to receive a notification to the email address from below ...', or uncheck the checkbox: 'Include the SMS/MMS message in the email notification itself'.");
696
+                    return;
697
+                }
698
+	    }
699
+
700
+	    var showdisplaynm = 0;
701
+	    if ($("#showdisplaynames").is(':checked')) {
702
+		showdisplaynm = 1;
703
+	    }
704
+
705
+	    var adddisplaynm = 0;
706
+	    if ($("#adddisplaynames").is(':checked')) {
707
+		adddisplaynm = 1;
708
+	    }
709
+
710
+	    var datatosave = {
711
+			      userId: userid,
712
+		              telapiUrlRec: $("#telapi_url_rec").val(),
713
+		              telapiUrl: $("#telapi_url").val(),
714
+		              nexapiUrlRec: $("#nexapi_url_rec").val(),
715
+		              nexapiUrl: $("#nexapi_url").val(),
716
+		              twilapiUrlRec: $("#twilapi_url_rec").val(),
717
+		              twilapiUrl: $("#twilapi_url").val(),
718
+		              flowapiUrlRec: $("#flowapi_url_rec").val(),
719
+		              flowapiUrl: $("#flowapi_url").val(),
720
+			      messagesperpage: messagesperpageproc,
721
+			      getNotify: getnotify,
722
+			      notificationEmail: notifyemail,
723
+			      getsmsinemail: includesmsinemail,
724
+			      showDisplayNames: showdisplaynm,
725
+                              addDisplayNames: adddisplaynm
726
+	    };
727
+
728
+
729
+	    $.ajax({
730
+	       method: 'PUT',
731
+	       url: baseUrlsave + '/' + userid,
732
+	       contentType: 'application/json',
733
+	       data: JSON.stringify(datatosave),
734
+	       success: function() {
735
+                               OC.msg.startAction('#smsr_save_msg', t('sms_relentless', 'Saved'));
736
+	       },
737
+	       error: function() {
738
+		    showAlert('Error while attempting to save the settings! You can check the Nextcloud log to find more details about this issue.');
739
+	       }
740
+	    });
741
+
742
+
743
+     } else if (isadm == 'admin') {
744
+
745
+	    // Save personal settings for admins
746
+	    event.preventDefault();
747
+	    var baseUrlsaveadm = OC.generateUrl('/apps/sms_relentless/user/updatepersadmnsettings');
748
+
749
+	    var messagesperpageinit = $("#messagesperpage").val();
750
+	    var messagesperpagesec = messagesperpageinit.replace(/[^0-9]/g, '');
751
+
752
+	    if (messagesperpagesec != '') {
753
+		var messagesperpageproc = messagesperpagesec;
754
+	    } else {
755
+		var messagesperpageproc = 100;
756
+	    }
757
+
758
+	    var getnotify = 0;
759
+
760
+	    if ($("#get_notify").is(':checked')) {
761
+		getnotify = 1;
762
+	    }
763
+
764
+	    var emailaddressinit = $("#notification_email").val();
765
+
766
+	    function validate_email($email) {
767
+		var email_reg = /^([\w-\.]+@([\w-]+\.)+[\w-]{2,4})?$/;
768
+		return email_reg.test($email);
769
+	    }
770
+
771
+	    if (validate_email(emailaddressinit)) {
772
+		 var notifyemail = emailaddressinit;
773
+	    } else {
774
+		 var notifyemail = '';
775
+	    }
776
+
777
+	    var includesmsinemail = 0;
778
+	    if ($("#includesmsinemail").is(':checked')) {
779
+		includesmsinemail = 1;
780
+                if ($("#notification_email").val().trim() == '') {
781
+                    showAlert("Please enter an email address in the field: 'I want to receive a notification to the email address from below ...', or uncheck the checkbox: 'Include the SMS/MMS message in the email notification itself'.");
782
+                    return;
783
+                }
784
+	    }
785
+
786
+	    var showdisplaynm = 0;
787
+	    if ($("#showdisplaynames").is(':checked')) {
788
+		showdisplaynm = 1;
789
+	    }
790
+
791
+	    var adddisplaynm = 0;
792
+	    if ($("#adddisplaynames").is(':checked')) {
793
+		adddisplaynm = 1;
794
+	    }
795
+
796
+	    var datatosave = {
797
+			      userId: userid,
798
+			      messagesperpage: messagesperpageproc,
799
+			      getNotify: getnotify,
800
+			      notificationEmail: notifyemail,
801
+			      getsmsinemail: includesmsinemail,
802
+			      showDisplayNames: showdisplaynm,
803
+                              addDisplayNames: adddisplaynm
804
+	    };
805
+
806
+
807
+	    $.ajax({
808
+	       method: 'PUT',
809
+	       url: baseUrlsaveadm + '/' + userid,
810
+	       contentType: 'application/json',
811
+	       data: JSON.stringify(datatosave),
812
+	       success: function() {
813
+                               OC.msg.startAction('#smsr_save_msg', t('sms_relentless', 'Saved'));
814
+	       },
815
+	       error: function() {
816
+		    showAlert('Error while attempting to save the settings! You can check the Nextcloud log to find more details about this issue.');
817
+	       }
818
+	    });
819
+
820
+     }
821
+  });
822
+
823
+  function showAlert(alertText) {
824
+
825
+     let alertwnd = "<div id='alertMessage'>";
826
+     alertwnd += "<a id='closeAlertWnd' title='Close this window'></a>";
827
+     alertwnd += "<div id='alertTextWrap'>"+ alertText +"</div>";
828
+     alertwnd += "<input type='submit' id='alertOk' value='OK'>";
829
+     alertwnd += "</div>";
830
+
831
+     $("#content").append("<div id='alertMsgOverlay'></div>");
832
+     $("#content").append(alertwnd);
833
+
834
+     let topDist = parseInt((window.innerHeight / 2).toFixed(2) - 152) +"px";
835
+     let leftDist = parseInt((window.innerWidth / 2).toFixed(2) - 150) +"px";
836
+     $("#alertMessage").css({ "top" : topDist, "left" : leftDist });
837
+
838
+     $("#closeAlertWnd").click(function() { $("#alertMsgOverlay").remove(); $("#alertMessage").remove(); });
839
+     $("#alertMsgOverlay").click(function() { $("#alertMsgOverlay").remove(); $("#alertMessage").remove(); });
840
+     $("#alertOk").click(function() { $("#alertMsgOverlay").remove(); $("#alertMessage").remove(); });
841
+  }
842
+
843
+  function confirmAlert(alertText) {
844
+
845
+     $("#alertMsgOverlay").remove();
846
+     $("#alertConfMessage").remove();
847
+
848
+     let alertwndcf = "<div id='alertConfMessage'>";
849
+     alertwndcf += "<a id='closeAlertWndcf' title='Close this window'></a>";
850
+     alertwndcf += "<div id='alertTextWrap'>"+ alertText +"</div>";
851
+     alertwndcf += "<div id='cancelOkWrap'><input type='submit' id='confirmCancel' value='Cancel'>";
852
+     alertwndcf += "<input type='submit' id='confirmOk' value='OK'></div>";
853
+     alertwndcf += "</div>";
854
+
855
+     $("#content").append("<div id='alertMsgOverlay'></div>");
856
+     $("#content").append(alertwndcf);
857
+
858
+     let topDist = parseInt((window.innerHeight / 2).toFixed(2) - 152) +"px";
859
+     let leftDist = parseInt((window.innerWidth / 2).toFixed(2) - 150) +"px";
860
+     $("#alertConfMessage").css({ "top" : topDist, "left" : leftDist });
861
+
862
+     $("#closeAlertWndcf").click(function() { $("#alertMsgOverlay").remove(); $("#alertConfMessage").remove(); });
863
+     $("#alertMsgOverlay").click(function() { $("#alertMsgOverlay").remove(); $("#alertConfMessage").remove(); });
864
+  }
865
+
866
+});
Browse code

removed CHANGELOG.txt appinfo/info.xml appinfo/signature.json css/style.css js/settings.js lib/Service/SmsrelentlessService.php lib/Controller/AuthorApiController.php templates/settings/admin.php

DoubleBastionAdmin authored on 03/11/2023 19:51:29
Showing 1 changed files
1 1
deleted file mode 100644
... ...
@@ -1,865 +0,0 @@
1
-/**
2
- * @copyright 2021 Double Bastion LLC <www.doublebastion.com>
3
- *
4
- * @author Double Bastion LLC
5
- *
6
- * @license GNU AGPL version 3 or any later version
7
- *
8
- * This program is free software; you can redistribute it and/or
9
- * modify it under the terms of the GNU AFFERO GENERAL PUBLIC LICENSE
10
- * License as published by the Free Software Foundation; either
11
- * version 3 of the License, or any later version.
12
- *
13
- * This program is distributed in the hope that it will be useful,
14
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
15
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
16
- * GNU AFFERO GENERAL PUBLIC LICENSE for more details.
17
- *
18
- * You should have received a copy of the GNU Affero General Public
19
- * License along with this program.  If not, see <http://www.gnu.org/licenses/>.
20
- *
21
- */
22
-
23
-$(document).ready(function() {
24
-
25
-  var userid = "<?php p($userId); ?>";
26
-  var isadm = '';
27
-
28
-  // Get personal settings
29
-  var baseUrlget = OC.generateUrl('/apps/sms_relentless/user/getsettings');
30
-
31
-  $.ajax({
32
-     method: 'GET',
33
-     url: baseUrlget + '/' + userid,
34
-     contentType: 'application/json',
35
-     success: function(settingsfromdb) {
36
-
37
-         // Add the webhook URLs section, if the user is not an admin
38
-         if (settingsfromdb.adminornot == 'reguser') {
39
-
40
-             isadm = 'reguser';
41
-
42
-             $("#appTitlePrg").append('<p id="settings-dscr"><h3>Enter your options in the fields from below. As a non-admin user, you can use any of the SMS service providers from \
43
-                  below (Telnyx/Plivo/Twilio/Flowroute), on the condition that an admin has shared with you his API keys for that provider. If an admin has shared with you his API \
44
-                  keys for a provider, to be able to use them properly, you will have to generate the two webhook URLs for that provider by clicking the corresponding \
45
-                  "Generate new webhook URL ..." buttons from below, then click "Save" at the bottom of this page:</h3></p><br>');
46
-
47
-             $("#nadmProvSection").append('<div class="providerSettings"><p><label for="telapi_url_rec" class="setlabeltext"><b>Telnyx webhook URL for incoming SMS/MMS</b> (Generate \
48
-                  the URL by pressing the button from below. Don\'t forget to also click the \'Save\' button at the bottom of this page after entering all the options, to save \
49
-                  all the settings to the database.)</label></p> \
50
-                  <input type="button" id="generate_tel_rcpt" class="generateUrl" value="Generate new webhook URL for incoming SMS/MMS" /> \
51
-                  <input type="text" class="smsr_textboxspec" id="telapi_url_rec" name="telapi_url_rec" autocomplete="false" /> \
52
-                  <span id="copyToClipboardtel" class="icon icon-clippy" title="Copy to clipboard"></span><br><br> \
53
-                  \
54
-                  <p><label for="telapi_url" class="setlabeltext"><b>Telnyx webhook URL for delivery receipts</b> (This URL will be included by SMS Relentless in message sending \
55
-                  requests, so that Telnyx will know where to send the delivery receipts. Just generate it by pressing the button from below. Don\'t forget to click the \'Save\' \
56
-                  button at the bottom of this page after entering all the options, to save all the settings to the database.)</label></p> \
57
-                  <input type="button" id="generate_tel_delrcpt" class="generateUrl" value="Generate new webhook URL for delivery receipts" /> \
58
-                  <input type="text" id="telapi_url" name="telapi_url" autocomplete="false" /></div><br><br> \
59
-                  \
60
-                  <div class="providerSettings"><p><label for="nexapi_url_rec" class="setlabeltext"><b>Plivo webhook URL for incoming SMS/MMS</b> (Generate the URL by pressing \
61
-                  the button from below. Don\'t forget to also click the \'Save\' button at the bottom of this page after entering all the options, to save all the settings \
62
-                  to the database.)</label></p> \
63
-                  <input type="button" id="generate_nex_rcpt" class="generateUrl" value="Generate new webhook URL for incoming SMS/MMS" /> \
64
-                  <input type="text" class="smsr_textboxspec" id="nexapi_url_rec" name="nexapi_url_rec" autocomplete="false" /> \
65
-                  <span id="copyToClipboardnex" class="icon icon-clippy" title="Copy to clipboard"></span><br><br> \
66
-                  \
67
-                  <p><label for="nexapi_url" class="setlabeltext"><b>Plivo webhook URL for delivery receipts</b> (This URL will be included by SMS Relentless in message sending \
68
-                  requests, so that Plivo will know where to send the delivery receipts. Just generate it by pressing the button from below. Don\'t forget to click the \'Save\' \
69
-                  button at the bottom of this page after entering all the options, to save all the settings to the database.)</label></p> \
70
-                  <input type="button" id="generate_nex_delrcpt" class="generateUrl" value="Generate new webhook URL for delivery receipts" /> \
71
-                  <input type="text" id="nexapi_url" name="nexapi_url" autocomplete="false" /></div><br><br> \
72
-                  \
73
-                  <div class="providerSettings"><p><label for="twilapi_url_rec" class="setlabeltext"><b>Twilio webhook URL for incoming SMS/MMS</b> (Generate the URL by pressing \
74
-                  the button from below. Don\'t forget to also click the \'Save\' button at the bottom of this page after entering all the options, to save all the settings to \
75
-                  the database.)</label></p> \
76
-                  <input type="button" id="generate_twil_rcpt" class="generateUrl" value="Generate new webhook URL for incoming SMS/MMS" /> \
77
-                  <input type="text" class="smsr_textboxspec" id="twilapi_url_rec" name="twilapi_url_rec" autocomplete="false" /> \
78
-                  <span id="copyToClipboardtwil" class="icon icon-clippy" title="Copy to clipboard"></span><br><br> \
79
-                  \
80
-                  <p><label for="twilapi_url" class="setlabeltext"><b>Twilio webhook URL for delivery receipts</b> (This URL will be included by SMS Relentless in message sending \
81
-                  requests, so that Twilio will know where to send the delivery receipts. Just generate it by pressing the button from below. Don\'t forget to click the \'Save\' \
82
-                  button at the bottom of this page after entering all the options, to save all the settings to the database.)</label></p> \
83
-                  <input type="button" id="generate_twil_delrcpt" class="generateUrl" value="Generate new webhook URL for delivery receipts" /> \
84
-                  <input type="text" id="twilapi_url" name="twilapi_url" autocomplete="false" /></div><br><br> \
85
-                  \
86
-                  <div class="providerSettings"><p><label for="flowapi_url_rec" class="setlabeltext"><b>Flowroute webhook URL for incoming SMS/MMS</b> (Generate the URL by pressing \
87
-                  the button from below. Don\'t forget to also click the \'Save\' button at the bottom of this page after entering all the options, to save all the settings to \
88
-                  the database.)</label></p> \
89
-                  <input type="button" id="generate_flow_rcpt" class="generateUrl" value="Generate new webhook URL for incoming SMS/MMS" /> \
90
-                  <input type="text" class="smsr_textboxspec" id="flowapi_url_rec" name="flowapi_url_rec" autocomplete="false" /> \
91
-                  <span id="copyToClipboardflow" class="icon icon-clippy" title="Copy to clipboard"></span><br><br> \
92
-                  \
93
-                  <p><label for="flowapi_url" class="setlabeltext"><b>Flowroute webhook URL for delivery receipts</b> (This URL will be included by SMS Relentless in message sending \
94
-                  requests, so that Flowroute will know where to send the delivery receipts. Just generate it by pressing the button from below. Don\'t forget to click the \'Save\' \
95
-                  button at the bottom of this page after entering all the options, to save all the settings to the database.)</label></p> \
96
-                  <input type="button" id="generate_flow_delrcpt" class="generateUrl" value="Generate new webhook URL for delivery receipts" /> \
97
-                  <input type="text" id="flowapi_url" name="flowapi_url" autocomplete="false" /><br><br> \
98
-                  Flowroute only supports sending/receiving SMS/MMS messages within USA and Canada and it doesn\'t support Alphanumeric Sender IDs.</div><br>');
99
-
100
-
101
-		  $("#telapi_url_rec").val(settingsfromdb.telapi_url_rec);
102
-		  $("#telapi_url").val(settingsfromdb.telapi_url);
103
-		  $("#nexapi_url_rec").val(settingsfromdb.nexapi_url_rec);
104
-		  $("#nexapi_url").val(settingsfromdb.nexapi_url);
105
-		  $("#twilapi_url_rec").val(settingsfromdb.twilapi_url_rec);
106
-		  $("#twilapi_url").val(settingsfromdb.twilapi_url);
107
-		  $("#flowapi_url_rec").val(settingsfromdb.flowapi_url_rec);
108
-		  $("#flowapi_url").val(settingsfromdb.flowapi_url);
109
-		  $("#messagesperpage").val(settingsfromdb.messagesperpage);
110
-
111
-		  if (settingsfromdb.get_notify == 1) {
112
-		      $("#get_notify").attr('checked', true);
113
-		  } else {
114
-		      $("#get_notify").attr('checked', false);
115
-		  }
116
-
117
-		  $("#notification_email").val(settingsfromdb.notification_email);
118
-
119
-		  if (settingsfromdb.getsmsinemail == 1) {
120
-		      $("#includesmsinemail").attr('checked', true);
121
-		  } else {
122
-		      $("#includesmsinemail").attr('checked', false);
123
-		  }
124
-
125
-		  if (settingsfromdb.show_display_names == 1) {
126
-		      $("#showdisplaynames").attr('checked', true);
127
-		  } else {
128
-		      $("#showdisplaynames").attr('checked', false);
129
-		  }
130
-
131
-		  if (settingsfromdb.add_display_names == 1) {
132
-		      $("#adddisplaynames").attr('checked', true);
133
-		  } else {
134
-		      $("#adddisplaynames").attr('checked', false);
135
-		  }
136
-
137
-		  function randomStr(strlength) {
138
-			var fintext = "";
139
-			var keyspace = '0123456789abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ';
140
-			for (var i = 0; i < strlength; i++) {
141
-			     fintext += keyspace.charAt(Math.floor(Math.random() * keyspace.length));
142
-			}
143
-			return fintext;
144
-		  }
145
-
146
-		  $("#generate_tel_rcpt").on("click", function(event) {
147
-
148
-		     var teltokenrec = randomStr(70);
149
-		     var telnyxwhurlrec = window.location.origin + OC.generateUrl('/apps/sms_relentless/api/recsmstel?telrecparam=') + teltokenrec;
150
-
151
-		     $("#telapi_url_rec").val(telnyxwhurlrec);
152
-		  });
153
-
154
-		  $("#copyToClipboardtel").on("click", function(event) {
155
-		     var $tempEl = $("<input>");
156
-		     $("body").append($tempEl);
157
-		     $tempEl.val($("#telapi_url_rec").val()).select();
158
-		     document.execCommand("Copy");
159
-		     $tempEl.remove();
160
-		     showAlert("The link has been copied to your clipboard!");
161
-		  });
162
-
163
-		  $("#generate_tel_delrcpt").on("click", function(event) {
164
-
165
-		     var teltoken = randomStr(70);
166
-		     var telnyxwhurl = window.location.origin + OC.generateUrl('/apps/sms_relentless/api/recdeliverytel?teldrparam=') + teltoken;
167
-
168
-		     $("#telapi_url").val(telnyxwhurl);
169
-		  });
170
-
171
-
172
-		  $("#generate_nex_rcpt").on("click", function(event) {
173
-
174
-		     var plivotokenrec = randomStr(70);
175
-		     var plivowhurlrec = window.location.origin + OC.generateUrl('/apps/sms_relentless/api/recsmsnex?plivorecparam=') + plivotokenrec;
176
-
177
-		     $("#nexapi_url_rec").val(plivowhurlrec);
178
-		  });
179
-
180
-		  $("#copyToClipboardnex").on("click", function(event) {
181
-		     var $tempElpl = $("<input>");
182
-		     $("body").append($tempElpl);
183
-		     $tempElpl.val($("#nexapi_url_rec").val()).select();
184
-		     document.execCommand("Copy");
185
-		     $tempElpl.remove();
186
-		     showAlert("The link has been copied to your clipboard!");
187
-		  });
188
-
189
-		  $("#generate_nex_delrcpt").on("click", function(event) {
190
-
191
-		     var plivotoken = randomStr(70);
192
-		     var plivodrwhurl = window.location.origin + OC.generateUrl('/apps/sms_relentless/api/recdeliverynex?plivodrparam=') + plivotoken;
193
-
194
-		     $("#nexapi_url").val(plivodrwhurl);
195
-		  });
196
-
197
-
198
-		  $("#generate_twil_rcpt").on("click", function(event) {
199
-
200
-		     var twiltokenrec = randomStr(35);
201
-		     var twilwhurlrec = window.location.origin + OC.generateUrl('/apps/sms_relentless/api/recsmstwil?twilrecparam=') + twiltokenrec;
202
-
203
-		     $("#twilapi_url_rec").val(twilwhurlrec);
204
-		  });
205
-
206
-		  $("#copyToClipboardtwil").on("click", function(event) {
207
-		     var $tempElpl = $("<input>");
208
-		     $("body").append($tempElpl);
209
-		     $tempElpl.val($("#twilapi_url_rec").val()).select();
210
-		     document.execCommand("Copy");
211
-		     $tempElpl.remove();
212
-		     showAlert("The link has been copied to your clipboard!");
213
-		  });
214
-
215
-		  $("#generate_twil_delrcpt").on("click", function(event) {
216
-
217
-		     var twiltoken = randomStr(35);
218
-		     var twildrwhurl = window.location.origin + OC.generateUrl('/apps/sms_relentless/api/recdeliverytwil?twildrparam=') + twiltoken;
219
-
220
-		     $("#twilapi_url").val(twildrwhurl);
221
-		  });
222
-
223
-
224
-		  $("#generate_flow_rcpt").on("click", function(event) {
225
-
226
-		     var flowtokenrec = randomStr(70);
227
-		     var flowwhurlrec = window.location.origin + OC.generateUrl('/apps/sms_relentless/api/recsmsflow?flowrecparam=') + flowtokenrec;
228
-
229
-		     $("#flowapi_url_rec").val(flowwhurlrec);
230
-		  });
231
-
232
-		  $("#copyToClipboardflow").on("click", function(event) {
233
-		     var $tempElpl = $("<input>");
234
-		     $("body").append($tempElpl);
235
-		     $tempElpl.val($("#flowapi_url_rec").val()).select();
236
-		     document.execCommand("Copy");
237
-		     $tempElpl.remove();
238
-		     showAlert("The link has been copied to your clipboard!");
239
-		  });
240
-
241
-		  $("#generate_flow_delrcpt").on("click", function(event) {
242
-
243
-		     var flowtoken = randomStr(70);
244
-		     var flowdrwhurl = window.location.origin + OC.generateUrl('/apps/sms_relentless/api/recdeliveryflow?flowdrparam=') + flowtoken;
245
-
246
-		     $("#flowapi_url").val(flowdrwhurl);
247
-		  });
248
-
249
-
250
-         } else if (settingsfromdb.adminornot == 'admin') {
251
-
252
-                  $("#appTitlePrg").append('<p id="settings-dscr"><h3>Enter your options in the fields from below:</h3></p><br>');
253
-                  isadm = 'admin';
254
-
255
-		  $("#messagesperpage").val(settingsfromdb.messagesperpage);
256
-
257
-		  if (settingsfromdb.get_notify == 1) {
258
-		      $("#get_notify").attr('checked', true);
259
-		  } else {
260
-		      $("#get_notify").attr('checked', false);
261
-		  }
262
-
263
-		  $("#notification_email").val(settingsfromdb.notification_email);
264
-
265
-		  if (settingsfromdb.getsmsinemail == 1) {
266
-		      $("#includesmsinemail").attr('checked', true);
267
-		  } else {
268
-		      $("#includesmsinemail").attr('checked', false);
269
-		  }
270
-
271
-		  if (settingsfromdb.show_display_names == 1) {
272
-		      $("#showdisplaynames").attr('checked', true);
273
-		  } else {
274
-		      $("#showdisplaynames").attr('checked', false);
275
-		  }
276
-
277
-		  if (settingsfromdb.add_display_names == 1) {
278
-		      $("#adddisplaynames").attr('checked', true);
279
-		  } else {
280
-		      $("#adddisplaynames").attr('checked', false);
281
-		  }
282
-         }
283
-
284
-
285
-         // Auto-reply settings
286
-
287
-         // Get the available phone numbers from all providers associated with the access keys entered on the Settings page (restrictions are applied to numbers for non-admins)
288
-         $("#autoRplPhoneNb").addClass('icon-loading');
289
-         var getnumbersUrl = OC.generateUrl("/apps/sms_relentless/user/getautoreplyconf");
290
-
291
-	 $.ajax({
292
-		  url: getnumbersUrl + '/' + userid,
293
-		  type: "GET",
294
-                  contentType: 'application/json',
295
-		  success: function(autoreplydata) {
296
-
297
-                                    $("#autoRplPhoneNb").removeClass('icon-loading');
298
-                                    var cusrDisplayName = autoreplydata.userdisplayname;
299
-                                    var availPhoneNmbrs = autoreplydata.phonenumbers;
300
-                                    var autorpldata = autoreplydata.autoreplies;
301
-
302
-				    if (autorpldata.length > 0) { 
303
-				        var arplNmb = autorpldata.length;
304
-				    } else { 
305
-				        var arplNmb = 0; 
306
-				    }
307
-
308
-				    // List the auto-replies for the phone numbers available for the current user
309
-				    if (arplNmb == 0) {
310
-
311
-				        $("#autoReplyTbl").append("<tr><td><input type='text' class='arplAuthor' value='"+ cusrDisplayName +"' disabled></td><td><select id='arpphn-"+ arplNmb +"' class='arplPhoneNmbr'></select></td><td><div id='arplmode-"+ arplNmb +"' class='arplMode'><select id='modeselect-"+ arplNmb +"' class='selectArplMode'><option value='' selected>Select mode</option><option value='daily'>Daily mode</option><option value='vacation'>Vacation mode</option></select><div id='modecont-"+ arplNmb +"' class='modeContent'></div></div></td><td><textarea id='arpltxt-"+ arplNmb +"' class='arplText' rows='20' cols='40' placeholder='Enter the auto-reply message here.'></textarea></td><td><img id='rmRow-"+ arplNmb +"' class='removeRow' src='/apps/sms_relentless/img/closewnd.svg' title='Remove this row from the database' style='cursor:pointer;margin:9px 8px 0px 18px;'></td><td><input type='submit' id='arplsave-"+ arplNmb +"' class='saveAutoReply' value='Save' title='Save Row' /></td></tr>");
312
-				        $("#autoReplyTbl").append("<div><img id='addArplRow' src='/apps/sms_relentless/img/add.svg' title='Add Row'></div>");
313
-
314
-				    } else {
315
-
316
-				        for (k = 0; k < arplNmb; k++) {
317
-
318
-                                             if (autorpldata[k].days_of_week != '') {
319
-
320
-                                                 var slctdMode = "<option value=''>Select mode</option><option value='daily' selected>Daily mode</option><option value='vacation'>Vacation mode</option>";
321
-                                                 var dailyStartArr = autorpldata[k].daily_start.split(":");
322
-                                                 var dailyEndArr = autorpldata[k].daily_end.split(":");
323
-
324
-		                                 var dlHrStartOptions = "";
325
-			                         for (var hr = 0; hr < 24; hr++) {
326
-		                                      if (dailyStartArr[0] != hr.toLocaleString('en-US', {minimumIntegerDigits: 2, useGrouping:false})) {
327
-			                                  dlHrStartOptions += "<option value='"+ hr.toLocaleString('en-US', {minimumIntegerDigits: 2, useGrouping:false}) +"'>"+ hr.toLocaleString('en-US', {minimumIntegerDigits: 2, useGrouping:false}) +"</option>";
328
-		                                      } else {
329
-			                                  dlHrStartOptions += "<option value='"+ hr.toLocaleString('en-US', {minimumIntegerDigits: 2, useGrouping:false}) +"' selected>"+ hr.toLocaleString('en-US', {minimumIntegerDigits: 2, useGrouping:false}) +"</option>";
330
-		                                      }
331
-			                         }
332
-
333
-		                                 var dlMnStartOptions = "";
334
-			                         for (var mn = 0; mn < 60; mn++) {
335
-		                                      if (dailyStartArr[1] != mn.toLocaleString('en-US', {minimumIntegerDigits: 2, useGrouping:false})) {
336
-			                                  dlMnStartOptions += "<option value='"+ mn.toLocaleString('en-US', {minimumIntegerDigits: 2, useGrouping:false}) +"'>"+ mn.toLocaleString('en-US', {minimumIntegerDigits: 2, useGrouping:false}) +"</option>";
337
-		                                      } else {
338
-			                                  dlMnStartOptions += "<option value='"+ mn.toLocaleString('en-US', {minimumIntegerDigits: 2, useGrouping:false}) +"' selected>"+ mn.toLocaleString('en-US', {minimumIntegerDigits: 2, useGrouping:false}) +"</option>";
339
-		                                      }
340
-			                         }
341
-
342
-		                                 var dlHrEndOptions = "";
343
-			                         for (var hr = 0; hr < 24; hr++) {
344
-		                                      if (dailyEndArr[0] != hr.toLocaleString('en-US', {minimumIntegerDigits: 2, useGrouping:false})) {
345
-			                                  dlHrEndOptions += "<option value='"+ hr.toLocaleString('en-US', {minimumIntegerDigits: 2, useGrouping:false}) +"'>"+ hr.toLocaleString('en-US', {minimumIntegerDigits: 2, useGrouping:false}) +"</option>";
346
-		                                      } else {
347
-			                                  dlHrEndOptions += "<option value='"+ hr.toLocaleString('en-US', {minimumIntegerDigits: 2, useGrouping:false}) +"' selected>"+ hr.toLocaleString('en-US', {minimumIntegerDigits: 2, useGrouping:false}) +"</option>";
348
-		                                      }
349
-			                         }
350
-
351
-		                                 var dlMnEndOptions = "";
352
-			                         for (var mn = 0; mn < 60; mn++) {
353
-		                                      if (dailyEndArr[1] != mn.toLocaleString('en-US', {minimumIntegerDigits: 2, useGrouping:false})) {
354
-			                                  dlMnEndOptions += "<option value='"+ mn.toLocaleString('en-US', {minimumIntegerDigits: 2, useGrouping:false}) +"'>"+ mn.toLocaleString('en-US', {minimumIntegerDigits: 2, useGrouping:false}) +"</option>";
355
-		                                      } else {
356
-			                                  dlMnEndOptions += "<option value='"+ mn.toLocaleString('en-US', {minimumIntegerDigits: 2, useGrouping:false}) +"' selected>"+ mn.toLocaleString('en-US', {minimumIntegerDigits: 2, useGrouping:false}) +"</option>";
357
-		                                      }
358
-			                         }
359
-
360
-                                                 var modeContent = "<div class='daysOfWeek'>Days of the week:<div class='tooltipautoreply'><div id='infoautoreply'>i</div><div class='autorpltooltip'>Enter the order number of the days of the week in which the auto-reply will be sent. For example, to send the auto-reply every day from Monday to Friday outside the time interval specified below, enter 1,2,3,4,5 To send the auto-reply only Monday, Thursday and Friday enter 1,4,5 To send the auto-reply every day of the week enter 1,2,3,4,5,6,7 As an exception, if you want the auto-reply to be sent during an entire day, irrespective of the specified interval, add (full) after the number of that day. For example, if you want the auto-reply to be sent from Monday to Friday outside the interval specified below, and also during the entire days of Saturday and Sunday, enter 1,2,3,4,5,6(full),7(full)</div></div></div><input type='text' id='weekdays-"+ k +"' class='daysInWeek' value='"+ autorpldata[k].days_of_week +"'><div class='chooseTInterval'>Send auto-reply <span style='color:#ad0202'>outside</span> this interval:<div class='tooltipautoreplyst'><div id='infoautoreplyst'>i</div><div class='autorpltooltipst'>These fields specify the time of the server. If the server is located in a time zone that is different from that of the owner/company, the time interval entered here should be adjusted accordingly.</div></div></div><div class='selectArplHours'><select id='dmstarthr-"+ k +"' class='selectHrMin'>"+ dlHrStartOptions +"</select><select id='dmstartmn-"+ k +"' class='selectHrMin'>"+ dlMnStartOptions +"</select><span style='font-weight: 600'> — </span><select id='dmendhr-"+ k +"' class='selectHrMin'>"+ dlHrEndOptions +"</select><select id='dmendmn-"+ k +"' class='selectHrMin'>"+ dlMnEndOptions +"</select></div>";
361
-
362
-                                             } else {
363
-
364
-                                                 var vctnStart = autorpldata[k].vacation_start.split(" ")[0];
365
-                                                 var vctnEnd = autorpldata[k].vacation_end.split(" ")[0];
366
-
367
-                                                 var slctdMode = "<option value=''>Select mode</option><option value='daily'>Daily mode</option><option value='vacation' selected>Vacation mode</option>";
368
-                                                 var modeContent = "<div class='chooseDateIntvl'>Send auto-reply <span style='color:#ad0202'>inside</span> this interval:</div><div class='arplstrtendDates'><div class='stdtTitle'>Start Date</div><input type='text' id='startDT-"+ k +"' class='startDate' placeholder='Pick a date' value='"+ vctnStart +"'><div class='enddtTitle'>End Date</div><input type='text' id='endDT-"+ k +"' class='endDate' placeholder='Pick a date' value='"+ vctnEnd +"'></div>"
369
-                                             }
370
-
371
-				             $("#autoReplyTbl").append("<tr><td><input type='text' class='arplAuthor' value='"+ autorpldata[k].saved_by_dsplname +"' disabled></td><td><select id='arpphn-"+ k +"' class='arplPhoneNmbr' style='pointer-events:none'><option selected>"+ autorpldata[k].phone_number +"</option></select></td><td><div id='arplmode-"+ k +"' class='arplMode'><select id='modeselect-"+ k +"' class='selectArplMode'>"+ slctdMode +"</select><div id='modecont-"+ k +"' class='modeContent'>"+ modeContent +"</div></div></td><td><textarea id='arpltxt-"+ k +"' class='arplText' rows='20' cols='40' placeholder='Enter the auto-reply message here.'>"+ autorpldata[k].message_text +"</textarea></td><td><img id='rmRow-"+ k +"' class='removeRow' src='/apps/sms_relentless/img/closewnd.svg' title='Remove this row from the database' style='cursor:pointer;margin:9px 8px 0px 18px;'></td><td><input type='submit' id='arplsave-"+ k +"' class='saveAutoReply' value='Edit' title='Edit Row' /></td></tr>");
372
-				        }
373
-				        $("#autoReplyTbl").append("<div><img id='addArplRow' src='/apps/sms_relentless/img/add.svg' title='Add Row'></div>");
374
-				    }
375
-
376
-
377
-				    // Create a list with all the available phone numbers
378
-                                    var numbersListItems = "<option value='' selected>Select phone number</option>";
379
-
380
-				    $.each(availPhoneNmbrs, function(key, indsmsnmb) {
381
-				           numbersListItems += "<option value='"+ indsmsnmb +"'>"+ indsmsnmb +"</option>";
382
-				    });
383
-
384
-                                    if (arplNmb == 0) {
385
-				        $("#arpphn-"+ arplNmb).append(numbersListItems);
386
-                                    }
387
-
388
-                                    // Initialize the date picker
389
-			            $('[id^="endDT-"]').datepicker({ dateFormat: "yy-mm-dd" });
390
-			            $('[id^="startDT-"]').datepicker({ dateFormat: "yy-mm-dd" });
391
-
392
-
393
-                                    // Select the auto-reply mode
394
-                                    function selectMode() {
395
-
396
-		                            $('[id^="modeselect-"]').change(function() {
397
-
398
-		                               var crtnmbr = $(this).attr("id").replace("modeselect-", "");
399
-
400
-		                               var dailyHrStart = "";
401
-		                               for (var h = 0; h < 24; h++) {
402
-		                                    dailyHrStart += "<option value='"+ h.toLocaleString('en-US', {minimumIntegerDigits: 2, useGrouping:false}) +"'>"+ h.toLocaleString('en-US', {minimumIntegerDigits: 2, useGrouping:false}) +"</option>";
403
-		                               }
404
-
405
-		                               var dailyMnStart = "";
406
-		                               for (var m = 0; m < 60; m++) {
407
-		                                    dailyMnStart += "<option value='"+ m.toLocaleString('en-US', {minimumIntegerDigits: 2, useGrouping:false}) +"'>"+ m.toLocaleString('en-US', {minimumIntegerDigits: 2, useGrouping:false}) +"</option>";
408
-		                               }
409
-
410
-		                               var dailyHrEnd = dailyHrStart;
411
-		                               var dailyMnEnd = dailyMnStart;
412
-
413
-		                               if ($(this).val() == 'daily') {
414
-		                                   $("#modecont-"+ crtnmbr).empty();
415
-		                                   $("#modecont-"+ crtnmbr).append("<div class='daysOfWeek'>Days of the week:<div class='tooltipautoreply'><div id='infoautoreply'>i</div><div class='autorpltooltip'>Enter the order number of the days of the week in which the auto-reply will be sent. For example, to send the auto-reply every day from Monday to Friday outside the time interval specified below, enter 1,2,3,4,5 To send the auto-reply only Monday, Thursday and Friday enter 1,4,5 To send the auto-reply every day of the week enter 1,2,3,4,5,6,7 As an exception, if you want the auto-reply to be sent during an entire day, irrespective of the specified interval, add (full) after the number of that day. For example, if you want the auto-reply to be sent from Monday to Friday outside the interval specified below, and also during the entire days of Saturday and Sunday, enter 1,2,3,4,5,6(full),7(full)</div></div></div><input type='text' id='weekdays-"+ crtnmbr +"' class='daysInWeek'><div class='chooseTInterval'>Send auto-reply <span style='color:#ad0202'>outside</span> this interval:<div class='tooltipautoreplyst'><div id='infoautoreplyst'>i</div><div class='autorpltooltipst'>These fields specify the time of the server. If the server is located in a time zone that is different from that of the owner/company, the time interval entered here should be adjusted accordingly.</div></div></div><div class='selectArplHours'><select id='dmstarthr-"+ crtnmbr +"' class='selectHrMin'>"+ dailyHrStart +"</select><select id='dmstartmn-"+ crtnmbr +"' class='selectHrMin'>"+ dailyMnStart +"</select><span style='font-weight: 600'> — </span><select id='dmendhr-"+ crtnmbr +"' class='selectHrMin'>"+ dailyHrEnd +"</select><select id='dmendmn-"+ crtnmbr +"' class='selectHrMin'>"+ dailyMnEnd +"</select></div>");
416
-		                               } else if ($(this).val() == 'vacation') {
417
-		                                   $("#modecont-"+ crtnmbr).empty();
418
-		                                   $("#modecont-"+ crtnmbr).append("<div class='chooseDateIntvl'>Send auto-reply <span style='color:#ad0202'>inside</span> this interval:</div><div class='arplstrtendDates'><div class='stdtTitle'>Start Date</div><input type='text' id='startDT-"+ crtnmbr +"' class='startDate' placeholder='Pick a date'><div class='enddtTitle'>End Date</div><input type='text' id='endDT-"+ crtnmbr +"' class='endDate' placeholder='Pick a date' /></div>");
419
-		                               }
420
-
421
-					       $("#endDT-"+ crtnmbr +"").datepicker({ dateFormat: "yy-mm-dd" });
422
-					       $("#startDT-"+ crtnmbr +"").datepicker({ dateFormat: "yy-mm-dd" });
423
-		                          });
424
-                                  }
425
-                                  selectMode();
426
-
427
-				  // Save the data
428
-				  function saveArplRow() {
429
-
430
-				     $('[id^="arplsave-"]').unbind("click");
431
-				     $('[id^="arplsave-"]').click(function(event) {
432
-
433
-				        event.preventDefault();
434
-				        var crntrwnmbr = $(this).attr("id").replace("arplsave-", "");
435
-
436
-				        if ($(this).attr("value") == "Save") {
437
-
438
-				            var phoneNmbr = $("#arpphn-"+ crntrwnmbr).val();
439
-				            var arplText = $("#arpltxt-"+ crntrwnmbr).val();
440
-				            var slctdMode = $("#modeselect-"+ crntrwnmbr).val();
441
-
442
-				            var slctddmDays = "";
443
-				            var slctdHrStart = "";
444
-				            var slctdMnStart = "";
445
-				            var slctdHrEnd = "";
446
-				            var slctdMnEnd = "";
447
-
448
-				            var vcStartDate = null;
449
-				            var vcEndDate = null;
450
-
451
-				            if (slctdMode == 'daily') {
452
-
453
-				                slctddmDays = $("#weekdays-"+ crntrwnmbr).val().trim();
454
-				                slctdHrStart = $("#dmstarthr-"+ crntrwnmbr).val().trim();
455
-				                slctdMnStart = $("#dmstartmn-"+ crntrwnmbr).val().trim();
456
-				                slctdHrEnd = $("#dmendhr-"+ crntrwnmbr).val().trim();
457
-				                slctdMnEnd = $("#dmendmn-"+ crntrwnmbr).val().trim();
458
-
459
-                                                if (slctdHrStart != '' && slctdMnStart != '') {
460
-                                                    var hrmnStartComp = slctdHrStart +":"+ slctdMnStart;
461
-                                                } else { var hrmnStartComp = ""; }
462
-
463
-                                                if (slctdHrEnd != '' && slctdMnEnd != '') {
464
-                                                    var hrmnEndComp = slctdHrEnd +":"+ slctdMnEnd;
465
-                                                } else { var hrmnEndComp = ""; }
466
-
467
-                                                if (!(/^[1-7ful\,\(\)]+$/.test(slctddmDays))) {
468
-				                    showAlert("The 'Days of the week' field can contain only digits from 1 to 7, the lowercase letters f, u and l, round brackets ()() and commas (,).");
469
-				                    return;
470
-                                                }
471
-
472
-                                                if (!(/^[0-9]+$/.test(slctdHrStart + slctdMnStart + slctdHrEnd + slctdMnEnd))) {
473
-				                    showAlert("The starting and ending values of the time interval for the 'Daily mode' can contain only digits from 0 to 9.");
474
-				                    return;
475
-                                                }
476
-
477
-                                                if (slctddmDays.trim() == '' || (slctdHrStart == slctdHrEnd && slctdMnStart == slctdMnEnd)) {
478
-				                    showAlert("For the 'Daily mode', you have to enter the order number of the days of the week for which you want the auto-reply to be sent, and you have to set a starting time that is different from the ending time!");
479
-				                    return;
480
-                                                }
481
-
482
-				            } else if (slctdMode == 'vacation') {
483
-		
484
-                                                if ($("#startDT-"+ crntrwnmbr).val().trim() == '' || $("#endDT-"+ crntrwnmbr).val().trim() == '') {
485
-
486
-				                    showAlert("For the 'Vacation mode', you have to enter both a start date and an end date.");
487
-				                    return;
488
-
489
-                                                } else {
490
-
491
-                                                    if (!(/^[0-9\-]+$/.test($("#startDT-"+ crntrwnmbr).val().trim() + $("#endDT-"+ crntrwnmbr).val().trim()))) {
492
-				                        showAlert("The start date and end date values for the 'Vacation mode' can contain only digits from 0 to 9 and hyphens (-).");
493
-				                        return;
494
-                                                    }
495
-
496
-		                                    vcStartDate = $("#startDT-"+ crntrwnmbr).val().trim() +" 00:00:00";
497
-				                    vcEndDate = $("#endDT-"+ crntrwnmbr).val().trim() +" 23:59:59";
498
-				                    var strtDateCmp = new Date(vcStartDate).toJSON().slice(0, 10) +" 00:00:00";
499
-				                    var endDateCmp = new Date(vcEndDate).toJSON().slice(0, 10) +" 23:59:59";
500
-				                    var crntDate = new Date().toJSON().slice(0, 10) +" 23:59:59";
501
-
502
-                                                    if (vcStartDate.trim() == "" || vcEndDate.trim() == "" || (strtDateCmp >= endDateCmp || ((strtDateCmp < crntDate) && (endDateCmp < crntDate)))) {
503
-				                        showAlert("For 'Vacation mode', you have to enter both a start date and an end date, the start date must be before the end date and at least the ending of the time interval must be in the future.");
504
-				                        return;
505
-                                                    }
506
-                                                }
507
-				            }
508
-
509
-
510
-				            if (phoneNmbr != '') {
511
-
512
-				              if (arplText.trim() != '') {
513
-
514
-				                if (slctdMode != '') {
515
-
516
-				                    var saveArplUrl = OC.generateUrl('/apps/sms_relentless/user/updateautoreplies');
517
-				                    var arpldata = {
518
-				                         userId: userid,
519
-				                         savedByDsplname: cusrDisplayName,
520
-				                         phoneNumber: phoneNmbr,
521
-				                         daysOfWeek: slctddmDays,
522
-				                         dailyStart: hrmnStartComp,
523
-				                         dailyEnd: hrmnEndComp,
524
-				                         vacationStart: vcStartDate,
525
-				                         vacationEnd: vcEndDate,
526
-				                         messageText: arplText
527
-				                    };
528
-
529
-					            $.ajax({
530
-					              method: 'PUT',
531
-					              url: saveArplUrl + '/' + userid,
532
-					              contentType: 'application/json',
533
-					              data: JSON.stringify(arpldata),
534
-				                      success: function(messagereceived) {
535
-
536
-				                                   if (messagereceived == 'success') {
537
-				                                       showAlert('The auto-reply has been successfully saved to the database!');
538
-				                                   } else if (messagereceived == 'failure') {
539
-				                                       showAlert('Error while trying to save the auto-reply!');
540
-				                                   } else if (messagereceived == 'not allowed') {
541
-                                                                       showAlert('You cannot change an auto-reply that was saved by a different user.');
542
-                                                                   }
543
-				                      },
544
-					              error: function() {
545
-						                   showAlert('Error while attempting to save the auto-reply! You can check the Nextcloud log to find more details about this issue.');
546
-					              }
547
-					            });
548
-
549
-
550
-                                                } else { showAlert("Please select the auto-reply mode."); return; }
551
-
552
-                                              } else { showAlert("Please enter the text of the auto-reply."); return; }
553
-
554
-                                            } else { showAlert("Please select a phone number if at least one number is available in the 'Phone Number' drop-down list. Otherwise, you should contact the administrator."); return; }
555
-
556
-                                            $(this).attr("value", "Edit");
557
-
558
-                                        } else {
559
-                                            $("#arplsave-"+ crntrwnmbr).attr("value", "Save");
560
-                                        }
561
-
562
-                                     });
563
-
564
-				  }
565
-                                  saveArplRow();
566
-
567
-
568
-				  // Remove a row
569
-				  function removeArplRow() {
570
-				       $('[id^="rmRow-"]').click(function() {
571
-
572
-					  var slctRowRm = $(this).attr("id").replace("rmRow-", "");
573
-					  var crntPhnNmbr = $("#arpphn-"+ slctRowRm).val();
574
-
575
-				          confirmAlert("Do you really want to remove this row from the database ?");
576
-
577
-				          $("#confirmCancel").click(function() { $("#alertMsgOverlay").remove(); $("#alertConfMessage").remove(); });
578
-
579
-				          $("#confirmOk").click(function() {
580
-
581
-				              $("#alertMsgOverlay").remove();
582
-				              $("#alertConfMessage").remove();
583
-
584
-					      var rmvArplUrl = OC.generateUrl('/apps/sms_relentless/user/removeautoreplies');
585
-					      $.ajax({
586
-						   url: rmvArplUrl + '/' + userid,
587
-						   method: "POST",
588
-						   dataType: "text",
589
-						   data: { phoneNumber: crntPhnNmbr },
590
-						   success: function(delresult) {
591
-
592
-						                     if (delresult.indexOf("success") > -1) {
593
-						                         showAlert("The auto-reply has been removed successfully!");
594
-						                         $("#arpphn-"+ slctRowRm).closest("tr").remove();
595
-						                     } else if (delresult.indexOf("failure") > -1) {
596
-						                         showAlert("Error while trying to remove auto-reply data!");
597
-						                     } else if (delresult.indexOf("not allowed") > -1) {
598
-                                                                         showAlert("You cannot remove the auto-reply saved by another user.");
599
-                                                                     }
600
-						   },
601
-						   error: function() { showAlert("Error while attempting to remove auto-reply data! You can check the Nextcloud log to find more details about this issue."); }
602
-					       });
603
-					  });
604
-				       });
605
-				  }
606
-				  removeArplRow();
607
-
608
-                                  // Add a new row
609
-                                  $("#addArplRow").click(function() {
610
-
611
-                                     if ($("#autoReplyTbl").find("tr:last-child").find(".arplPhoneNmbr").length > 0) {
612
-                                         var lastarpl = $("#autoReplyTbl").find("tr:last-child").find(".arplPhoneNmbr").attr("id").replace("arpphn-", "");
613
-                                         var indArplAdd = parseInt(lastarpl + 1);
614
-                                     } else { var indArplAdd = 0; }
615
-			             $("#autoReplyTbl").append("<tr><td><input type='text' class='arplAuthor' value='"+ cusrDisplayName +"' disabled></td><td><select id='arpphn-"+ indArplAdd +"' class='arplPhoneNmbr'>"+ numbersListItems +"</select></td><td><div id='arplmode-"+ indArplAdd +"' class='arplMode'><select id='modeselect-"+ indArplAdd +"' class='selectArplMode'><option value='' selected>Select mode</option><option value='daily'>Daily mode</option><option value='vacation'>Vacation mode</option></select><div id='modecont-"+ indArplAdd +"' class='modeContent'></div></div></td><td><textarea id='arpltxt-"+ indArplAdd +"' class='arplText' rows='20' cols='40' placeholder='Enter the auto-reply message here.'></textarea></td><td><img id='rmRow-"+ indArplAdd +"' class='removeRow' src='/apps/sms_relentless/img/closewnd.svg' title='Remove this row from the database' style='cursor:pointer;margin:9px 8px 0px 18px;'></td><td><input type='submit' id='arplsave-"+ indArplAdd +"' class='saveAutoReply' value='Save' title='Save Row' /></td></tr>");
616
-
617
-                                     selectMode();
618
-                                     saveArplRow();
619
-                                     removeArplRow();
620
-
621
-			             // Check if there is an auto-reply set for the same phone number
622
-				     $("#arpphn-"+ indArplAdd).change(function() {
623
-					 var selectedPhNb = $("#arpphn-"+ indArplAdd).val();
624
-					 var allArplPhNmbrs = $("#autoReplyTbl").find("tr").find(".arplPhoneNmbr");
625
-					 var phNbChck = 0;
626
-					 allArplPhNmbrs.each(function() {
627
-					    var slctphnb = ($(this).val())? $(this).val() : $(this).text();
628
-					    if (selectedPhNb == slctphnb) { phNbChck++; }
629
-					 });
630
-
631
-					 if (phNbChck == 2) {
632
-					     showAlert("There is already an auto-reply set up for this phone number. Please edit its own row, or choose a different phone number.");
633
-					     $(this).val('');
634
-					     return;
635
-					 }
636
-				     });
637
-                                  });
638
-
639
-		  },
640
-		  error: function() {
641
-                                    $("#autoRplPhoneNb").removeClass('icon-loading'); 
642
-                                    showAlert("Error while attempting to get the auto-reply settings! You can check the Nextcloud log to find more details about this issue.");
643
-                  }
644
-         });
645
-
646
-     },
647
-     error: function() {
648
-                  showAlert('Error while getting the settings! You can check the Nextcloud log to find more details about this issue.');
649
-     }
650
-  });
651
-
652
-
653
-
654
-  // Save personal settings for non-admin users
655
-  $("#save_sms_settings").on("click", function(event) {
656
-
657
-     if (isadm == 'reguser') {
658
-
659
-	    event.preventDefault();
660
-	    var baseUrlsave = OC.generateUrl('/apps/sms_relentless/user/updatesettings');
661
-
662
-	    var messagesperpageinit = $("#messagesperpage").val();
663
-	    var messagesperpagesec = messagesperpageinit.replace(/[^0-9]/g, '');
664
-
665
-	    if (messagesperpagesec != '') {
666
-		var messagesperpageproc = messagesperpagesec;
667
-	    } else {
668
-		var messagesperpageproc = 100;
669
-	    }
670
-
671
-	    var getnotify = 0;
672
-
673
-	    if ($("#get_notify").is(':checked')) {
674
-		getnotify = 1;
675
-	    }
676
-
677
-	    var emailaddressinit = $("#notification_email").val();
678
-
679
-	    function validate_email($email) {
680
-		var email_reg = /^([\w-\.]+@([\w-]+\.)+[\w-]{2,4})?$/;
681
-		return email_reg.test($email);
682
-	    }
683
-
684
-	    if (validate_email(emailaddressinit)) {
685
-		 var notifyemail = emailaddressinit;
686
-	    } else {
687
-		 var notifyemail = '';
688
-	    }
689
-
690
-	    var includesmsinemail = 0;
691
-	    if ($("#includesmsinemail").is(':checked')) {
692
-		includesmsinemail = 1;
693
-                if ($("#notification_email").val().trim() == '') {
694
-                    showAlert("Please enter an email address in the field: 'I want to receive a notification to the email address from below ...', or uncheck the checkbox: 'Include the SMS/MMS message in the email notification itself'.");
695
-                    return;
696
-                }
697
-	    }
698
-
699
-	    var showdisplaynm = 0;
700
-	    if ($("#showdisplaynames").is(':checked')) {
701
-		showdisplaynm = 1;
702
-	    }
703
-
704
-	    var adddisplaynm = 0;
705
-	    if ($("#adddisplaynames").is(':checked')) {
706
-		adddisplaynm = 1;
707
-	    }
708
-
709
-	    var datatosave = {
710
-			      userId: userid,
711
-		              telapiUrlRec: $("#telapi_url_rec").val(),
712
-		              telapiUrl: $("#telapi_url").val(),
713
-		              nexapiUrlRec: $("#nexapi_url_rec").val(),
714
-		              nexapiUrl: $("#nexapi_url").val(),
715
-		              twilapiUrlRec: $("#twilapi_url_rec").val(),
716
-		              twilapiUrl: $("#twilapi_url").val(),
717
-		              flowapiUrlRec: $("#flowapi_url_rec").val(),
718
-		              flowapiUrl: $("#flowapi_url").val(),
719
-			      messagesperpage: messagesperpageproc,
720
-			      getNotify: getnotify,
721
-			      notificationEmail: notifyemail,
722
-			      getsmsinemail: includesmsinemail,
723
-			      showDisplayNames: showdisplaynm,
724
-                              addDisplayNames: adddisplaynm
725
-	    };
726
-
727
-
728
-	    $.ajax({
729
-	       method: 'PUT',
730
-	       url: baseUrlsave + '/' + userid,
731
-	       contentType: 'application/json',
732
-	       data: JSON.stringify(datatosave),
733
-	       success: function() {
734
-                               OC.msg.startAction('#smsr_save_msg', t('sms_relentless', 'Saved'));
735
-	       },
736
-	       error: function() {
737
-		    showAlert('Error while attempting to save the settings! You can check the Nextcloud log to find more details about this issue.');
738
-	       }
739
-	    });
740
-
741
-
742
-     } else if (isadm == 'admin') {
743
-
744
-	    // Save personal settings for admins
745
-	    event.preventDefault();
746
-	    var baseUrlsaveadm = OC.generateUrl('/apps/sms_relentless/user/updatepersadmnsettings');
747
-
748
-	    var messagesperpageinit = $("#messagesperpage").val();
749
-	    var messagesperpagesec = messagesperpageinit.replace(/[^0-9]/g, '');
750
-
751
-	    if (messagesperpagesec != '') {
752
-		var messagesperpageproc = messagesperpagesec;
753
-	    } else {
754
-		var messagesperpageproc = 100;
755
-	    }
756
-
757
-	    var getnotify = 0;
758
-
759
-	    if ($("#get_notify").is(':checked')) {
760
-		getnotify = 1;
761
-	    }
762
-
763
-	    var emailaddressinit = $("#notification_email").val();
764
-
765
-	    function validate_email($email) {
766
-		var email_reg = /^([\w-\.]+@([\w-]+\.)+[\w-]{2,4})?$/;
767
-		return email_reg.test($email);
768
-	    }
769
-
770
-	    if (validate_email(emailaddressinit)) {
771
-		 var notifyemail = emailaddressinit;
772
-	    } else {
773
-		 var notifyemail = '';
774
-	    }
775
-
776
-	    var includesmsinemail = 0;
777
-	    if ($("#includesmsinemail").is(':checked')) {
778
-		includesmsinemail = 1;
779
-                if ($("#notification_email").val().trim() == '') {
780
-                    showAlert("Please enter an email address in the field: 'I want to receive a notification to the email address from below ...', or uncheck the checkbox: 'Include the SMS/MMS message in the email notification itself'.");
781
-                    return;
782
-                }
783
-	    }
784
-
785
-	    var showdisplaynm = 0;
786
-	    if ($("#showdisplaynames").is(':checked')) {
787
-		showdisplaynm = 1;
788
-	    }
789
-
790
-	    var adddisplaynm = 0;
791
-	    if ($("#adddisplaynames").is(':checked')) {
792
-		adddisplaynm = 1;
793
-	    }
794
-
795
-	    var datatosave = {
796
-			      userId: userid,
797
-			      messagesperpage: messagesperpageproc,
798
-			      getNotify: getnotify,
799
-			      notificationEmail: notifyemail,
800
-			      getsmsinemail: includesmsinemail,
801
-			      showDisplayNames: showdisplaynm,
802
-                              addDisplayNames: adddisplaynm
803
-	    };
804
-
805
-
806
-	    $.ajax({
807
-	       method: 'PUT',
808
-	       url: baseUrlsaveadm + '/' + userid,
809
-	       contentType: 'application/json',
810
-	       data: JSON.stringify(datatosave),
811
-	       success: function() {
812
-                               OC.msg.startAction('#smsr_save_msg', t('sms_relentless', 'Saved'));
813
-	       },
814
-	       error: function() {
815
-		    showAlert('Error while attempting to save the settings! You can check the Nextcloud log to find more details about this issue.');
816
-	       }
817
-	    });
818
-
819
-     }
820
-  });
821
-
822
-  function showAlert(alertText) {
823
-
824
-     let alertwnd = "<div id='alertMessage'>";
825
-     alertwnd += "<a id='closeAlertWnd' title='Close this window'></a>";
826
-     alertwnd += "<div id='alertTextWrap'>"+ alertText +"</div>";
827
-     alertwnd += "<input type='submit' id='alertOk' value='OK'>";
828
-     alertwnd += "</div>";
829
-
830
-     $("#content").append("<div id='alertMsgOverlay'></div>");
831
-     $("#content").append(alertwnd);
832
-
833
-     let topDist = parseInt((window.innerHeight / 2).toFixed(2) - 152) +"px";
834
-     let leftDist = parseInt((window.innerWidth / 2).toFixed(2) - 150) +"px";
835
-     $("#alertMessage").css({ "top" : topDist, "left" : leftDist });
836
-
837
-     $("#closeAlertWnd").click(function() { $("#alertMsgOverlay").remove(); $("#alertMessage").remove(); });
838
-     $("#alertMsgOverlay").click(function() { $("#alertMsgOverlay").remove(); $("#alertMessage").remove(); });
839
-     $("#alertOk").click(function() { $("#alertMsgOverlay").remove(); $("#alertMessage").remove(); });
840
-  }
841
-
842
-  function confirmAlert(alertText) {
843
-
844
-     $("#alertMsgOverlay").remove();
845
-     $("#alertConfMessage").remove();
846
-
847
-     let alertwndcf = "<div id='alertConfMessage'>";
848
-     alertwndcf += "<a id='closeAlertWndcf' title='Close this window'></a>";
849
-     alertwndcf += "<div id='alertTextWrap'>"+ alertText +"</div>";
850
-     alertwndcf += "<div id='cancelOkWrap'><input type='submit' id='confirmCancel' value='Cancel'>";
851
-     alertwndcf += "<input type='submit' id='confirmOk' value='OK'></div>";
852
-     alertwndcf += "</div>";
853
-
854
-     $("#content").append("<div id='alertMsgOverlay'></div>");
855
-     $("#content").append(alertwndcf);
856
-
857
-     let topDist = parseInt((window.innerHeight / 2).toFixed(2) - 152) +"px";
858
-     let leftDist = parseInt((window.innerWidth / 2).toFixed(2) - 150) +"px";
859
-     $("#alertConfMessage").css({ "top" : topDist, "left" : leftDist });
860
-
861
-     $("#closeAlertWndcf").click(function() { $("#alertMsgOverlay").remove(); $("#alertConfMessage").remove(); });
862
-     $("#alertMsgOverlay").click(function() { $("#alertMsgOverlay").remove(); $("#alertConfMessage").remove(); });
863
-  }
864
-
865
-});
Browse code

added CHANGELOG.txt README.md appinfo/info.xml appinfo/signature.json img/sms_relentless_screenshot.png css/style.css js/showsmstables.js js/settings.js templates/settings/admin.php templates/settings/personal.php templates/navigation/index.php

DoubleBastionAdmin authored on 30/10/2023 14:55:39
Showing 1 changed files
1 1
new file mode 100644
... ...
@@ -0,0 +1,865 @@
1
+/**
2
+ * @copyright 2021 Double Bastion LLC <www.doublebastion.com>
3
+ *
4
+ * @author Double Bastion LLC
5
+ *
6
+ * @license GNU AGPL version 3 or any later version
7
+ *
8
+ * This program is free software; you can redistribute it and/or
9
+ * modify it under the terms of the GNU AFFERO GENERAL PUBLIC LICENSE
10
+ * License as published by the Free Software Foundation; either
11
+ * version 3 of the License, or any later version.
12
+ *
13
+ * This program is distributed in the hope that it will be useful,
14
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
15
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
16
+ * GNU AFFERO GENERAL PUBLIC LICENSE for more details.
17
+ *
18
+ * You should have received a copy of the GNU Affero General Public
19
+ * License along with this program.  If not, see <http://www.gnu.org/licenses/>.
20
+ *
21
+ */
22
+
23
+$(document).ready(function() {
24
+
25
+  var userid = "<?php p($userId); ?>";
26
+  var isadm = '';
27
+
28
+  // Get personal settings
29
+  var baseUrlget = OC.generateUrl('/apps/sms_relentless/user/getsettings');
30
+
31
+  $.ajax({
32
+     method: 'GET',
33
+     url: baseUrlget + '/' + userid,
34
+     contentType: 'application/json',
35
+     success: function(settingsfromdb) {
36
+
37
+         // Add the webhook URLs section, if the user is not an admin
38
+         if (settingsfromdb.adminornot == 'reguser') {
39
+
40
+             isadm = 'reguser';
41
+
42
+             $("#appTitlePrg").append('<p id="settings-dscr"><h3>Enter your options in the fields from below. As a non-admin user, you can use any of the SMS service providers from \
43
+                  below (Telnyx/Plivo/Twilio/Flowroute), on the condition that an admin has shared with you his API keys for that provider. If an admin has shared with you his API \
44
+                  keys for a provider, to be able to use them properly, you will have to generate the two webhook URLs for that provider by clicking the corresponding \
45
+                  "Generate new webhook URL ..." buttons from below, then click "Save" at the bottom of this page:</h3></p><br>');
46
+
47
+             $("#nadmProvSection").append('<div class="providerSettings"><p><label for="telapi_url_rec" class="setlabeltext"><b>Telnyx webhook URL for incoming SMS/MMS</b> (Generate \
48
+                  the URL by pressing the button from below. Don\'t forget to also click the \'Save\' button at the bottom of this page after entering all the options, to save \
49
+                  all the settings to the database.)</label></p> \
50
+                  <input type="button" id="generate_tel_rcpt" class="generateUrl" value="Generate new webhook URL for incoming SMS/MMS" /> \
51
+                  <input type="text" class="smsr_textboxspec" id="telapi_url_rec" name="telapi_url_rec" autocomplete="false" /> \
52
+                  <span id="copyToClipboardtel" class="icon icon-clippy" title="Copy to clipboard"></span><br><br> \
53
+                  \
54
+                  <p><label for="telapi_url" class="setlabeltext"><b>Telnyx webhook URL for delivery receipts</b> (This URL will be included by SMS Relentless in message sending \
55
+                  requests, so that Telnyx will know where to send the delivery receipts. Just generate it by pressing the button from below. Don\'t forget to click the \'Save\' \
56
+                  button at the bottom of this page after entering all the options, to save all the settings to the database.)</label></p> \
57
+                  <input type="button" id="generate_tel_delrcpt" class="generateUrl" value="Generate new webhook URL for delivery receipts" /> \
58
+                  <input type="text" id="telapi_url" name="telapi_url" autocomplete="false" /></div><br><br> \
59
+                  \
60
+                  <div class="providerSettings"><p><label for="nexapi_url_rec" class="setlabeltext"><b>Plivo webhook URL for incoming SMS/MMS</b> (Generate the URL by pressing \
61
+                  the button from below. Don\'t forget to also click the \'Save\' button at the bottom of this page after entering all the options, to save all the settings \
62
+                  to the database.)</label></p> \
63
+                  <input type="button" id="generate_nex_rcpt" class="generateUrl" value="Generate new webhook URL for incoming SMS/MMS" /> \
64
+                  <input type="text" class="smsr_textboxspec" id="nexapi_url_rec" name="nexapi_url_rec" autocomplete="false" /> \
65
+                  <span id="copyToClipboardnex" class="icon icon-clippy" title="Copy to clipboard"></span><br><br> \
66
+                  \
67
+                  <p><label for="nexapi_url" class="setlabeltext"><b>Plivo webhook URL for delivery receipts</b> (This URL will be included by SMS Relentless in message sending \
68
+                  requests, so that Plivo will know where to send the delivery receipts. Just generate it by pressing the button from below. Don\'t forget to click the \'Save\' \
69
+                  button at the bottom of this page after entering all the options, to save all the settings to the database.)</label></p> \
70
+                  <input type="button" id="generate_nex_delrcpt" class="generateUrl" value="Generate new webhook URL for delivery receipts" /> \
71
+                  <input type="text" id="nexapi_url" name="nexapi_url" autocomplete="false" /></div><br><br> \
72
+                  \
73
+                  <div class="providerSettings"><p><label for="twilapi_url_rec" class="setlabeltext"><b>Twilio webhook URL for incoming SMS/MMS</b> (Generate the URL by pressing \
74
+                  the button from below. Don\'t forget to also click the \'Save\' button at the bottom of this page after entering all the options, to save all the settings to \
75
+                  the database.)</label></p> \
76
+                  <input type="button" id="generate_twil_rcpt" class="generateUrl" value="Generate new webhook URL for incoming SMS/MMS" /> \
77
+                  <input type="text" class="smsr_textboxspec" id="twilapi_url_rec" name="twilapi_url_rec" autocomplete="false" /> \
78
+                  <span id="copyToClipboardtwil" class="icon icon-clippy" title="Copy to clipboard"></span><br><br> \
79
+                  \
80
+                  <p><label for="twilapi_url" class="setlabeltext"><b>Twilio webhook URL for delivery receipts</b> (This URL will be included by SMS Relentless in message sending \
81
+                  requests, so that Twilio will know where to send the delivery receipts. Just generate it by pressing the button from below. Don\'t forget to click the \'Save\' \
82
+                  button at the bottom of this page after entering all the options, to save all the settings to the database.)</label></p> \
83
+                  <input type="button" id="generate_twil_delrcpt" class="generateUrl" value="Generate new webhook URL for delivery receipts" /> \
84
+                  <input type="text" id="twilapi_url" name="twilapi_url" autocomplete="false" /></div><br><br> \
85
+                  \
86
+                  <div class="providerSettings"><p><label for="flowapi_url_rec" class="setlabeltext"><b>Flowroute webhook URL for incoming SMS/MMS</b> (Generate the URL by pressing \
87
+                  the button from below. Don\'t forget to also click the \'Save\' button at the bottom of this page after entering all the options, to save all the settings to \
88
+                  the database.)</label></p> \
89
+                  <input type="button" id="generate_flow_rcpt" class="generateUrl" value="Generate new webhook URL for incoming SMS/MMS" /> \
90
+                  <input type="text" class="smsr_textboxspec" id="flowapi_url_rec" name="flowapi_url_rec" autocomplete="false" /> \
91
+                  <span id="copyToClipboardflow" class="icon icon-clippy" title="Copy to clipboard"></span><br><br> \
92
+                  \
93
+                  <p><label for="flowapi_url" class="setlabeltext"><b>Flowroute webhook URL for delivery receipts</b> (This URL will be included by SMS Relentless in message sending \
94
+                  requests, so that Flowroute will know where to send the delivery receipts. Just generate it by pressing the button from below. Don\'t forget to click the \'Save\' \
95
+                  button at the bottom of this page after entering all the options, to save all the settings to the database.)</label></p> \
96
+                  <input type="button" id="generate_flow_delrcpt" class="generateUrl" value="Generate new webhook URL for delivery receipts" /> \
97
+                  <input type="text" id="flowapi_url" name="flowapi_url" autocomplete="false" /><br><br> \
98
+                  Flowroute only supports sending/receiving SMS/MMS messages within USA and Canada and it doesn\'t support Alphanumeric Sender IDs.</div><br>');
99
+
100
+
101
+		  $("#telapi_url_rec").val(settingsfromdb.telapi_url_rec);
102
+		  $("#telapi_url").val(settingsfromdb.telapi_url);
103
+		  $("#nexapi_url_rec").val(settingsfromdb.nexapi_url_rec);
104
+		  $("#nexapi_url").val(settingsfromdb.nexapi_url);
105
+		  $("#twilapi_url_rec").val(settingsfromdb.twilapi_url_rec);
106
+		  $("#twilapi_url").val(settingsfromdb.twilapi_url);
107
+		  $("#flowapi_url_rec").val(settingsfromdb.flowapi_url_rec);
108
+		  $("#flowapi_url").val(settingsfromdb.flowapi_url);
109
+		  $("#messagesperpage").val(settingsfromdb.messagesperpage);
110
+
111
+		  if (settingsfromdb.get_notify == 1) {
112
+		      $("#get_notify").attr('checked', true);
113
+		  } else {
114
+		      $("#get_notify").attr('checked', false);
115
+		  }
116
+
117
+		  $("#notification_email").val(settingsfromdb.notification_email);
118
+
119
+		  if (settingsfromdb.getsmsinemail == 1) {
120
+		      $("#includesmsinemail").attr('checked', true);
121
+		  } else {
122
+		      $("#includesmsinemail").attr('checked', false);
123
+		  }
124
+
125
+		  if (settingsfromdb.show_display_names == 1) {
126
+		      $("#showdisplaynames").attr('checked', true);
127
+		  } else {
128
+		      $("#showdisplaynames").attr('checked', false);
129
+		  }
130
+
131
+		  if (settingsfromdb.add_display_names == 1) {
132
+		      $("#adddisplaynames").attr('checked', true);
133
+		  } else {
134
+		      $("#adddisplaynames").attr('checked', false);
135
+		  }
136
+
137
+		  function randomStr(strlength) {
138
+			var fintext = "";
139
+			var keyspace = '0123456789abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ';
140
+			for (var i = 0; i < strlength; i++) {
141
+			     fintext += keyspace.charAt(Math.floor(Math.random() * keyspace.length));
142
+			}
143
+			return fintext;
144
+		  }
145
+
146
+		  $("#generate_tel_rcpt").on("click", function(event) {
147
+
148
+		     var teltokenrec = randomStr(70);
149
+		     var telnyxwhurlrec = window.location.origin + OC.generateUrl('/apps/sms_relentless/api/recsmstel?telrecparam=') + teltokenrec;
150
+
151
+		     $("#telapi_url_rec").val(telnyxwhurlrec);
152
+		  });
153
+
154
+		  $("#copyToClipboardtel").on("click", function(event) {
155
+		     var $tempEl = $("<input>");
156
+		     $("body").append($tempEl);
157
+		     $tempEl.val($("#telapi_url_rec").val()).select();
158
+		     document.execCommand("Copy");
159
+		     $tempEl.remove();
160
+		     showAlert("The link has been copied to your clipboard!");
161
+		  });
162
+
163
+		  $("#generate_tel_delrcpt").on("click", function(event) {
164
+
165
+		     var teltoken = randomStr(70);
166
+		     var telnyxwhurl = window.location.origin + OC.generateUrl('/apps/sms_relentless/api/recdeliverytel?teldrparam=') + teltoken;
167
+
168
+		     $("#telapi_url").val(telnyxwhurl);
169
+		  });
170
+
171
+
172
+		  $("#generate_nex_rcpt").on("click", function(event) {
173
+
174
+		     var plivotokenrec = randomStr(70);
175
+		     var plivowhurlrec = window.location.origin + OC.generateUrl('/apps/sms_relentless/api/recsmsnex?plivorecparam=') + plivotokenrec;
176
+
177
+		     $("#nexapi_url_rec").val(plivowhurlrec);
178
+		  });
179
+
180
+		  $("#copyToClipboardnex").on("click", function(event) {
181
+		     var $tempElpl = $("<input>");
182
+		     $("body").append($tempElpl);
183
+		     $tempElpl.val($("#nexapi_url_rec").val()).select();
184
+		     document.execCommand("Copy");
185
+		     $tempElpl.remove();
186
+		     showAlert("The link has been copied to your clipboard!");
187
+		  });
188
+
189
+		  $("#generate_nex_delrcpt").on("click", function(event) {
190
+
191
+		     var plivotoken = randomStr(70);
192
+		     var plivodrwhurl = window.location.origin + OC.generateUrl('/apps/sms_relentless/api/recdeliverynex?plivodrparam=') + plivotoken;
193
+
194
+		     $("#nexapi_url").val(plivodrwhurl);
195
+		  });
196
+
197
+
198
+		  $("#generate_twil_rcpt").on("click", function(event) {
199
+
200
+		     var twiltokenrec = randomStr(35);
201
+		     var twilwhurlrec = window.location.origin + OC.generateUrl('/apps/sms_relentless/api/recsmstwil?twilrecparam=') + twiltokenrec;
202
+
203
+		     $("#twilapi_url_rec").val(twilwhurlrec);
204
+		  });
205
+
206
+		  $("#copyToClipboardtwil").on("click", function(event) {
207
+		     var $tempElpl = $("<input>");
208
+		     $("body").append($tempElpl);
209
+		     $tempElpl.val($("#twilapi_url_rec").val()).select();
210
+		     document.execCommand("Copy");
211
+		     $tempElpl.remove();
212
+		     showAlert("The link has been copied to your clipboard!");
213
+		  });
214
+
215
+		  $("#generate_twil_delrcpt").on("click", function(event) {
216
+
217
+		     var twiltoken = randomStr(35);
218
+		     var twildrwhurl = window.location.origin + OC.generateUrl('/apps/sms_relentless/api/recdeliverytwil?twildrparam=') + twiltoken;
219
+
220
+		     $("#twilapi_url").val(twildrwhurl);
221
+		  });
222
+
223
+
224
+		  $("#generate_flow_rcpt").on("click", function(event) {
225
+
226
+		     var flowtokenrec = randomStr(70);
227
+		     var flowwhurlrec = window.location.origin + OC.generateUrl('/apps/sms_relentless/api/recsmsflow?flowrecparam=') + flowtokenrec;
228
+
229
+		     $("#flowapi_url_rec").val(flowwhurlrec);
230
+		  });
231
+
232
+		  $("#copyToClipboardflow").on("click", function(event) {
233
+		     var $tempElpl = $("<input>");
234
+		     $("body").append($tempElpl);
235
+		     $tempElpl.val($("#flowapi_url_rec").val()).select();
236
+		     document.execCommand("Copy");
237
+		     $tempElpl.remove();
238
+		     showAlert("The link has been copied to your clipboard!");
239
+		  });
240
+
241
+		  $("#generate_flow_delrcpt").on("click", function(event) {
242
+
243
+		     var flowtoken = randomStr(70);
244
+		     var flowdrwhurl = window.location.origin + OC.generateUrl('/apps/sms_relentless/api/recdeliveryflow?flowdrparam=') + flowtoken;
245
+
246
+		     $("#flowapi_url").val(flowdrwhurl);
247
+		  });
248
+
249
+
250
+         } else if (settingsfromdb.adminornot == 'admin') {
251
+
252
+                  $("#appTitlePrg").append('<p id="settings-dscr"><h3>Enter your options in the fields from below:</h3></p><br>');
253
+                  isadm = 'admin';
254
+
255
+		  $("#messagesperpage").val(settingsfromdb.messagesperpage);
256
+
257
+		  if (settingsfromdb.get_notify == 1) {
258
+		      $("#get_notify").attr('checked', true);
259
+		  } else {
260
+		      $("#get_notify").attr('checked', false);
261
+		  }
262
+
263
+		  $("#notification_email").val(settingsfromdb.notification_email);
264
+
265
+		  if (settingsfromdb.getsmsinemail == 1) {
266
+		      $("#includesmsinemail").attr('checked', true);
267
+		  } else {
268
+		      $("#includesmsinemail").attr('checked', false);
269
+		  }
270
+
271
+		  if (settingsfromdb.show_display_names == 1) {
272
+		      $("#showdisplaynames").attr('checked', true);
273
+		  } else {
274
+		      $("#showdisplaynames").attr('checked', false);
275
+		  }
276
+
277
+		  if (settingsfromdb.add_display_names == 1) {
278
+		      $("#adddisplaynames").attr('checked', true);
279
+		  } else {
280
+		      $("#adddisplaynames").attr('checked', false);
281
+		  }
282
+         }
283
+
284
+
285
+         // Auto-reply settings
286
+
287
+         // Get the available phone numbers from all providers associated with the access keys entered on the Settings page (restrictions are applied to numbers for non-admins)
288
+         $("#autoRplPhoneNb").addClass('icon-loading');
289
+         var getnumbersUrl = OC.generateUrl("/apps/sms_relentless/user/getautoreplyconf");
290
+
291
+	 $.ajax({
292
+		  url: getnumbersUrl + '/' + userid,
293
+		  type: "GET",
294
+                  contentType: 'application/json',
295
+		  success: function(autoreplydata) {
296
+
297
+                                    $("#autoRplPhoneNb").removeClass('icon-loading');
298
+                                    var cusrDisplayName = autoreplydata.userdisplayname;
299
+                                    var availPhoneNmbrs = autoreplydata.phonenumbers;
300
+                                    var autorpldata = autoreplydata.autoreplies;
301
+
302
+				    if (autorpldata.length > 0) { 
303
+				        var arplNmb = autorpldata.length;
304
+				    } else { 
305
+				        var arplNmb = 0; 
306
+				    }
307
+
308
+				    // List the auto-replies for the phone numbers available for the current user
309
+				    if (arplNmb == 0) {
310
+
311
+				        $("#autoReplyTbl").append("<tr><td><input type='text' class='arplAuthor' value='"+ cusrDisplayName +"' disabled></td><td><select id='arpphn-"+ arplNmb +"' class='arplPhoneNmbr'></select></td><td><div id='arplmode-"+ arplNmb +"' class='arplMode'><select id='modeselect-"+ arplNmb +"' class='selectArplMode'><option value='' selected>Select mode</option><option value='daily'>Daily mode</option><option value='vacation'>Vacation mode</option></select><div id='modecont-"+ arplNmb +"' class='modeContent'></div></div></td><td><textarea id='arpltxt-"+ arplNmb +"' class='arplText' rows='20' cols='40' placeholder='Enter the auto-reply message here.'></textarea></td><td><img id='rmRow-"+ arplNmb +"' class='removeRow' src='/apps/sms_relentless/img/closewnd.svg' title='Remove this row from the database' style='cursor:pointer;margin:9px 8px 0px 18px;'></td><td><input type='submit' id='arplsave-"+ arplNmb +"' class='saveAutoReply' value='Save' title='Save Row' /></td></tr>");
312
+				        $("#autoReplyTbl").append("<div><img id='addArplRow' src='/apps/sms_relentless/img/add.svg' title='Add Row'></div>");
313
+
314
+				    } else {
315
+
316
+				        for (k = 0; k < arplNmb; k++) {
317
+
318
+                                             if (autorpldata[k].days_of_week != '') {
319
+
320
+                                                 var slctdMode = "<option value=''>Select mode</option><option value='daily' selected>Daily mode</option><option value='vacation'>Vacation mode</option>";
321
+                                                 var dailyStartArr = autorpldata[k].daily_start.split(":");
322
+                                                 var dailyEndArr = autorpldata[k].daily_end.split(":");
323
+
324
+		                                 var dlHrStartOptions = "";
325
+			                         for (var hr = 0; hr < 24; hr++) {
326
+		                                      if (dailyStartArr[0] != hr.toLocaleString('en-US', {minimumIntegerDigits: 2, useGrouping:false})) {
327
+			                                  dlHrStartOptions += "<option value='"+ hr.toLocaleString('en-US', {minimumIntegerDigits: 2, useGrouping:false}) +"'>"+ hr.toLocaleString('en-US', {minimumIntegerDigits: 2, useGrouping:false}) +"</option>";
328
+		                                      } else {
329
+			                                  dlHrStartOptions += "<option value='"+ hr.toLocaleString('en-US', {minimumIntegerDigits: 2, useGrouping:false}) +"' selected>"+ hr.toLocaleString('en-US', {minimumIntegerDigits: 2, useGrouping:false}) +"</option>";
330
+		                                      }
331
+			                         }
332
+
333
+		                                 var dlMnStartOptions = "";
334
+			                         for (var mn = 0; mn < 60; mn++) {
335
+		                                      if (dailyStartArr[1] != mn.toLocaleString('en-US', {minimumIntegerDigits: 2, useGrouping:false})) {
336
+			                                  dlMnStartOptions += "<option value='"+ mn.toLocaleString('en-US', {minimumIntegerDigits: 2, useGrouping:false}) +"'>"+ mn.toLocaleString('en-US', {minimumIntegerDigits: 2, useGrouping:false}) +"</option>";
337
+		                                      } else {
338
+			                                  dlMnStartOptions += "<option value='"+ mn.toLocaleString('en-US', {minimumIntegerDigits: 2, useGrouping:false}) +"' selected>"+ mn.toLocaleString('en-US', {minimumIntegerDigits: 2, useGrouping:false}) +"</option>";
339
+		                                      }
340
+			                         }
341
+
342
+		                                 var dlHrEndOptions = "";
343
+			                         for (var hr = 0; hr < 24; hr++) {
344
+		                                      if (dailyEndArr[0] != hr.toLocaleString('en-US', {minimumIntegerDigits: 2, useGrouping:false})) {
345
+			                                  dlHrEndOptions += "<option value='"+ hr.toLocaleString('en-US', {minimumIntegerDigits: 2, useGrouping:false}) +"'>"+ hr.toLocaleString('en-US', {minimumIntegerDigits: 2, useGrouping:false}) +"</option>";
346
+		                                      } else {
347
+			                                  dlHrEndOptions += "<option value='"+ hr.toLocaleString('en-US', {minimumIntegerDigits: 2, useGrouping:false}) +"' selected>"+ hr.toLocaleString('en-US', {minimumIntegerDigits: 2, useGrouping:false}) +"</option>";
348
+		                                      }
349
+			                         }
350
+
351
+		                                 var dlMnEndOptions = "";
352
+			                         for (var mn = 0; mn < 60; mn++) {
353
+		                                      if (dailyEndArr[1] != mn.toLocaleString('en-US', {minimumIntegerDigits: 2, useGrouping:false})) {
354
+			                                  dlMnEndOptions += "<option value='"+ mn.toLocaleString('en-US', {minimumIntegerDigits: 2, useGrouping:false}) +"'>"+ mn.toLocaleString('en-US', {minimumIntegerDigits: 2, useGrouping:false}) +"</option>";
355
+		                                      } else {
356
+			                                  dlMnEndOptions += "<option value='"+ mn.toLocaleString('en-US', {minimumIntegerDigits: 2, useGrouping:false}) +"' selected>"+ mn.toLocaleString('en-US', {minimumIntegerDigits: 2, useGrouping:false}) +"</option>";
357
+		                                      }
358
+			                         }
359
+
360
+                                                 var modeContent = "<div class='daysOfWeek'>Days of the week:<div class='tooltipautoreply'><div id='infoautoreply'>i</div><div class='autorpltooltip'>Enter the order number of the days of the week in which the auto-reply will be sent. For example, to send the auto-reply every day from Monday to Friday outside the time interval specified below, enter 1,2,3,4,5 To send the auto-reply only Monday, Thursday and Friday enter 1,4,5 To send the auto-reply every day of the week enter 1,2,3,4,5,6,7 As an exception, if you want the auto-reply to be sent during an entire day, irrespective of the specified interval, add (full) after the number of that day. For example, if you want the auto-reply to be sent from Monday to Friday outside the interval specified below, and also during the entire days of Saturday and Sunday, enter 1,2,3,4,5,6(full),7(full)</div></div></div><input type='text' id='weekdays-"+ k +"' class='daysInWeek' value='"+ autorpldata[k].days_of_week +"'><div class='chooseTInterval'>Send auto-reply <span style='color:#ad0202'>outside</span> this interval:<div class='tooltipautoreplyst'><div id='infoautoreplyst'>i</div><div class='autorpltooltipst'>These fields specify the time of the server. If the server is located in a time zone that is different from that of the owner/company, the time interval entered here should be adjusted accordingly.</div></div></div><div class='selectArplHours'><select id='dmstarthr-"+ k +"' class='selectHrMin'>"+ dlHrStartOptions +"</select><select id='dmstartmn-"+ k +"' class='selectHrMin'>"+ dlMnStartOptions +"</select><span style='font-weight: 600'> — </span><select id='dmendhr-"+ k +"' class='selectHrMin'>"+ dlHrEndOptions +"</select><select id='dmendmn-"+ k +"' class='selectHrMin'>"+ dlMnEndOptions +"</select></div>";
361
+
362
+                                             } else {
363
+
364
+                                                 var vctnStart = autorpldata[k].vacation_start.split(" ")[0];
365
+                                                 var vctnEnd = autorpldata[k].vacation_end.split(" ")[0];
366
+
367
+                                                 var slctdMode = "<option value=''>Select mode</option><option value='daily'>Daily mode</option><option value='vacation' selected>Vacation mode</option>";
368
+                                                 var modeContent = "<div class='chooseDateIntvl'>Send auto-reply <span style='color:#ad0202'>inside</span> this interval:</div><div class='arplstrtendDates'><div class='stdtTitle'>Start Date</div><input type='text' id='startDT-"+ k +"' class='startDate' placeholder='Pick a date' value='"+ vctnStart +"'><div class='enddtTitle'>End Date</div><input type='text' id='endDT-"+ k +"' class='endDate' placeholder='Pick a date' value='"+ vctnEnd +"'></div>"
369
+                                             }
370
+
371
+				             $("#autoReplyTbl").append("<tr><td><input type='text' class='arplAuthor' value='"+ autorpldata[k].saved_by_dsplname +"' disabled></td><td><select id='arpphn-"+ k +"' class='arplPhoneNmbr' style='pointer-events:none'><option selected>"+ autorpldata[k].phone_number +"</option></select></td><td><div id='arplmode-"+ k +"' class='arplMode'><select id='modeselect-"+ k +"' class='selectArplMode'>"+ slctdMode +"</select><div id='modecont-"+ k +"' class='modeContent'>"+ modeContent +"</div></div></td><td><textarea id='arpltxt-"+ k +"' class='arplText' rows='20' cols='40' placeholder='Enter the auto-reply message here.'>"+ autorpldata[k].message_text +"</textarea></td><td><img id='rmRow-"+ k +"' class='removeRow' src='/apps/sms_relentless/img/closewnd.svg' title='Remove this row from the database' style='cursor:pointer;margin:9px 8px 0px 18px;'></td><td><input type='submit' id='arplsave-"+ k +"' class='saveAutoReply' value='Edit' title='Edit Row' /></td></tr>");
372
+				        }
373
+				        $("#autoReplyTbl").append("<div><img id='addArplRow' src='/apps/sms_relentless/img/add.svg' title='Add Row'></div>");
374
+				    }
375
+
376
+
377
+				    // Create a list with all the available phone numbers
378
+                                    var numbersListItems = "<option value='' selected>Select phone number</option>";
379
+
380
+				    $.each(availPhoneNmbrs, function(key, indsmsnmb) {
381
+				           numbersListItems += "<option value='"+ indsmsnmb +"'>"+ indsmsnmb +"</option>";
382
+				    });
383
+
384
+                                    if (arplNmb == 0) {
385
+				        $("#arpphn-"+ arplNmb).append(numbersListItems);
386
+                                    }
387
+
388
+                                    // Initialize the date picker
389
+			            $('[id^="endDT-"]').datepicker({ dateFormat: "yy-mm-dd" });
390
+			            $('[id^="startDT-"]').datepicker({ dateFormat: "yy-mm-dd" });
391
+
392
+
393
+                                    // Select the auto-reply mode
394
+                                    function selectMode() {
395
+
396
+		                            $('[id^="modeselect-"]').change(function() {
397
+
398
+		                               var crtnmbr = $(this).attr("id").replace("modeselect-", "");
399
+
400
+		                               var dailyHrStart = "";
401
+		                               for (var h = 0; h < 24; h++) {
402
+		                                    dailyHrStart += "<option value='"+ h.toLocaleString('en-US', {minimumIntegerDigits: 2, useGrouping:false}) +"'>"+ h.toLocaleString('en-US', {minimumIntegerDigits: 2, useGrouping:false}) +"</option>";
403
+		                               }
404
+
405
+		                               var dailyMnStart = "";
406
+		                               for (var m = 0; m < 60; m++) {
407
+		                                    dailyMnStart += "<option value='"+ m.toLocaleString('en-US', {minimumIntegerDigits: 2, useGrouping:false}) +"'>"+ m.toLocaleString('en-US', {minimumIntegerDigits: 2, useGrouping:false}) +"</option>";
408
+		                               }
409
+
410
+		                               var dailyHrEnd = dailyHrStart;
411
+		                               var dailyMnEnd = dailyMnStart;
412
+
413
+		                               if ($(this).val() == 'daily') {
414
+		                                   $("#modecont-"+ crtnmbr).empty();
415
+		                                   $("#modecont-"+ crtnmbr).append("<div class='daysOfWeek'>Days of the week:<div class='tooltipautoreply'><div id='infoautoreply'>i</div><div class='autorpltooltip'>Enter the order number of the days of the week in which the auto-reply will be sent. For example, to send the auto-reply every day from Monday to Friday outside the time interval specified below, enter 1,2,3,4,5 To send the auto-reply only Monday, Thursday and Friday enter 1,4,5 To send the auto-reply every day of the week enter 1,2,3,4,5,6,7 As an exception, if you want the auto-reply to be sent during an entire day, irrespective of the specified interval, add (full) after the number of that day. For example, if you want the auto-reply to be sent from Monday to Friday outside the interval specified below, and also during the entire days of Saturday and Sunday, enter 1,2,3,4,5,6(full),7(full)</div></div></div><input type='text' id='weekdays-"+ crtnmbr +"' class='daysInWeek'><div class='chooseTInterval'>Send auto-reply <span style='color:#ad0202'>outside</span> this interval:<div class='tooltipautoreplyst'><div id='infoautoreplyst'>i</div><div class='autorpltooltipst'>These fields specify the time of the server. If the server is located in a time zone that is different from that of the owner/company, the time interval entered here should be adjusted accordingly.</div></div></div><div class='selectArplHours'><select id='dmstarthr-"+ crtnmbr +"' class='selectHrMin'>"+ dailyHrStart +"</select><select id='dmstartmn-"+ crtnmbr +"' class='selectHrMin'>"+ dailyMnStart +"</select><span style='font-weight: 600'> — </span><select id='dmendhr-"+ crtnmbr +"' class='selectHrMin'>"+ dailyHrEnd +"</select><select id='dmendmn-"+ crtnmbr +"' class='selectHrMin'>"+ dailyMnEnd +"</select></div>");
416
+		                               } else if ($(this).val() == 'vacation') {
417
+		                                   $("#modecont-"+ crtnmbr).empty();
418
+		                                   $("#modecont-"+ crtnmbr).append("<div class='chooseDateIntvl'>Send auto-reply <span style='color:#ad0202'>inside</span> this interval:</div><div class='arplstrtendDates'><div class='stdtTitle'>Start Date</div><input type='text' id='startDT-"+ crtnmbr +"' class='startDate' placeholder='Pick a date'><div class='enddtTitle'>End Date</div><input type='text' id='endDT-"+ crtnmbr +"' class='endDate' placeholder='Pick a date' /></div>");
419
+		                               }
420
+
421
+					       $("#endDT-"+ crtnmbr +"").datepicker({ dateFormat: "yy-mm-dd" });
422
+					       $("#startDT-"+ crtnmbr +"").datepicker({ dateFormat: "yy-mm-dd" });
423
+		                          });
424
+                                  }
425
+                                  selectMode();
426
+
427
+				  // Save the data
428
+				  function saveArplRow() {
429
+
430
+				     $('[id^="arplsave-"]').unbind("click");
431
+				     $('[id^="arplsave-"]').click(function(event) {
432
+
433
+				        event.preventDefault();
434
+				        var crntrwnmbr = $(this).attr("id").replace("arplsave-", "");
435
+
436
+				        if ($(this).attr("value") == "Save") {
437
+
438
+				            var phoneNmbr = $("#arpphn-"+ crntrwnmbr).val();
439
+				            var arplText = $("#arpltxt-"+ crntrwnmbr).val();
440
+				            var slctdMode = $("#modeselect-"+ crntrwnmbr).val();
441
+
442
+				            var slctddmDays = "";
443
+				            var slctdHrStart = "";
444
+				            var slctdMnStart = "";
445
+				            var slctdHrEnd = "";
446
+				            var slctdMnEnd = "";
447
+
448
+				            var vcStartDate = null;
449
+				            var vcEndDate = null;
450
+
451
+				            if (slctdMode == 'daily') {
452
+
453
+				                slctddmDays = $("#weekdays-"+ crntrwnmbr).val().trim();
454
+				                slctdHrStart = $("#dmstarthr-"+ crntrwnmbr).val().trim();
455
+				                slctdMnStart = $("#dmstartmn-"+ crntrwnmbr).val().trim();
456
+				                slctdHrEnd = $("#dmendhr-"+ crntrwnmbr).val().trim();
457
+				                slctdMnEnd = $("#dmendmn-"+ crntrwnmbr).val().trim();
458
+
459
+                                                if (slctdHrStart != '' && slctdMnStart != '') {
460
+                                                    var hrmnStartComp = slctdHrStart +":"+ slctdMnStart;
461
+                                                } else { var hrmnStartComp = ""; }
462
+
463
+                                                if (slctdHrEnd != '' && slctdMnEnd != '') {
464
+                                                    var hrmnEndComp = slctdHrEnd +":"+ slctdMnEnd;
465
+                                                } else { var hrmnEndComp = ""; }
466
+
467
+                                                if (!(/^[1-7ful\,\(\)]+$/.test(slctddmDays))) {
468
+				                    showAlert("The 'Days of the week' field can contain only digits from 1 to 7, the lowercase letters f, u and l, round brackets ()() and commas (,).");
469
+				                    return;
470
+                                                }
471
+
472
+                                                if (!(/^[0-9]+$/.test(slctdHrStart + slctdMnStart + slctdHrEnd + slctdMnEnd))) {
473
+				                    showAlert("The starting and ending values of the time interval for the 'Daily mode' can contain only digits from 0 to 9.");
474
+				                    return;
475
+                                                }
476
+
477
+                                                if (slctddmDays.trim() == '' || (slctdHrStart == slctdHrEnd && slctdMnStart == slctdMnEnd)) {
478
+				                    showAlert("For the 'Daily mode', you have to enter the order number of the days of the week for which you want the auto-reply to be sent, and you have to set a starting time that is different from the ending time!");
479
+				                    return;
480
+                                                }
481
+
482
+				            } else if (slctdMode == 'vacation') {
483
+		
484
+                                                if ($("#startDT-"+ crntrwnmbr).val().trim() == '' || $("#endDT-"+ crntrwnmbr).val().trim() == '') {
485
+
486
+				                    showAlert("For the 'Vacation mode', you have to enter both a start date and an end date.");
487
+				                    return;
488
+
489
+                                                } else {
490
+
491
+                                                    if (!(/^[0-9\-]+$/.test($("#startDT-"+ crntrwnmbr).val().trim() + $("#endDT-"+ crntrwnmbr).val().trim()))) {
492
+				                        showAlert("The start date and end date values for the 'Vacation mode' can contain only digits from 0 to 9 and hyphens (-).");
493
+				                        return;
494
+                                                    }
495
+
496
+		                                    vcStartDate = $("#startDT-"+ crntrwnmbr).val().trim() +" 00:00:00";
497
+				                    vcEndDate = $("#endDT-"+ crntrwnmbr).val().trim() +" 23:59:59";
498
+				                    var strtDateCmp = new Date(vcStartDate).toJSON().slice(0, 10) +" 00:00:00";
499
+				                    var endDateCmp = new Date(vcEndDate).toJSON().slice(0, 10) +" 23:59:59";
500
+				                    var crntDate = new Date().toJSON().slice(0, 10) +" 23:59:59";
501
+
502
+                                                    if (vcStartDate.trim() == "" || vcEndDate.trim() == "" || (strtDateCmp >= endDateCmp || ((strtDateCmp < crntDate) && (endDateCmp < crntDate)))) {
503
+				                        showAlert("For 'Vacation mode', you have to enter both a start date and an end date, the start date must be before the end date and at least the ending of the time interval must be in the future.");
504
+				                        return;
505
+                                                    }
506
+                                                }
507
+				            }
508
+
509
+
510
+				            if (phoneNmbr != '') {
511
+
512
+				              if (arplText.trim() != '') {
513
+
514
+				                if (slctdMode != '') {
515
+
516
+				                    var saveArplUrl = OC.generateUrl('/apps/sms_relentless/user/updateautoreplies');
517
+				                    var arpldata = {
518
+				                         userId: userid,
519
+				                         savedByDsplname: cusrDisplayName,
520
+				                         phoneNumber: phoneNmbr,
521
+				                         daysOfWeek: slctddmDays,
522
+				                         dailyStart: hrmnStartComp,
523
+				                         dailyEnd: hrmnEndComp,
524
+				                         vacationStart: vcStartDate,
525
+				                         vacationEnd: vcEndDate,
526
+				                         messageText: arplText
527
+				                    };
528
+
529
+					            $.ajax({
530
+					              method: 'PUT',
531
+					              url: saveArplUrl + '/' + userid,
532
+					              contentType: 'application/json',
533
+					              data: JSON.stringify(arpldata),
534
+				                      success: function(messagereceived) {
535
+
536
+				                                   if (messagereceived == 'success') {
537
+				                                       showAlert('The auto-reply has been successfully saved to the database!');
538
+				                                   } else if (messagereceived == 'failure') {
539
+				                                       showAlert('Error while trying to save the auto-reply!');
540
+				                                   } else if (messagereceived == 'not allowed') {
541
+                                                                       showAlert('You cannot change an auto-reply that was saved by a different user.');
542
+                                                                   }
543
+				                      },
544
+					              error: function() {
545
+						                   showAlert('Error while attempting to save the auto-reply! You can check the Nextcloud log to find more details about this issue.');
546
+					              }
547
+					            });
548
+
549
+
550
+                                                } else { showAlert("Please select the auto-reply mode."); return; }
551
+
552
+                                              } else { showAlert("Please enter the text of the auto-reply."); return; }
553
+
554
+                                            } else { showAlert("Please select a phone number if at least one number is available in the 'Phone Number' drop-down list. Otherwise, you should contact the administrator."); return; }
555
+
556
+                                            $(this).attr("value", "Edit");
557
+
558
+                                        } else {
559
+                                            $("#arplsave-"+ crntrwnmbr).attr("value", "Save");
560
+                                        }
561
+
562
+                                     });
563
+
564
+				  }
565
+                                  saveArplRow();
566
+
567
+
568
+				  // Remove a row
569
+				  function removeArplRow() {
570
+				       $('[id^="rmRow-"]').click(function() {
571
+
572
+					  var slctRowRm = $(this).attr("id").replace("rmRow-", "");
573
+					  var crntPhnNmbr = $("#arpphn-"+ slctRowRm).val();
574
+
575
+				          confirmAlert("Do you really want to remove this row from the database ?");
576
+
577
+				          $("#confirmCancel").click(function() { $("#alertMsgOverlay").remove(); $("#alertConfMessage").remove(); });
578
+
579
+				          $("#confirmOk").click(function() {
580
+
581
+				              $("#alertMsgOverlay").remove();
582
+				              $("#alertConfMessage").remove();
583
+
584
+					      var rmvArplUrl = OC.generateUrl('/apps/sms_relentless/user/removeautoreplies');
585
+					      $.ajax({
586
+						   url: rmvArplUrl + '/' + userid,
587
+						   method: "POST",
588
+						   dataType: "text",
589
+						   data: { phoneNumber: crntPhnNmbr },
590
+						   success: function(delresult) {
591
+
592
+						                     if (delresult.indexOf("success") > -1) {
593
+						                         showAlert("The auto-reply has been removed successfully!");
594
+						                         $("#arpphn-"+ slctRowRm).closest("tr").remove();
595
+						                     } else if (delresult.indexOf("failure") > -1) {
596
+						                         showAlert("Error while trying to remove auto-reply data!");
597
+						                     } else if (delresult.indexOf("not allowed") > -1) {
598
+                                                                         showAlert("You cannot remove the auto-reply saved by another user.");
599
+                                                                     }
600
+						   },
601
+						   error: function() { showAlert("Error while attempting to remove auto-reply data! You can check the Nextcloud log to find more details about this issue."); }
602
+					       });
603
+					  });
604
+				       });
605
+				  }
606
+				  removeArplRow();
607
+
608
+                                  // Add a new row
609
+                                  $("#addArplRow").click(function() {
610
+
611
+                                     if ($("#autoReplyTbl").find("tr:last-child").find(".arplPhoneNmbr").length > 0) {
612
+                                         var lastarpl = $("#autoReplyTbl").find("tr:last-child").find(".arplPhoneNmbr").attr("id").replace("arpphn-", "");
613
+                                         var indArplAdd = parseInt(lastarpl + 1);
614
+                                     } else { var indArplAdd = 0; }
615
+			             $("#autoReplyTbl").append("<tr><td><input type='text' class='arplAuthor' value='"+ cusrDisplayName +"' disabled></td><td><select id='arpphn-"+ indArplAdd +"' class='arplPhoneNmbr'>"+ numbersListItems +"</select></td><td><div id='arplmode-"+ indArplAdd +"' class='arplMode'><select id='modeselect-"+ indArplAdd +"' class='selectArplMode'><option value='' selected>Select mode</option><option value='daily'>Daily mode</option><option value='vacation'>Vacation mode</option></select><div id='modecont-"+ indArplAdd +"' class='modeContent'></div></div></td><td><textarea id='arpltxt-"+ indArplAdd +"' class='arplText' rows='20' cols='40' placeholder='Enter the auto-reply message here.'></textarea></td><td><img id='rmRow-"+ indArplAdd +"' class='removeRow' src='/apps/sms_relentless/img/closewnd.svg' title='Remove this row from the database' style='cursor:pointer;margin:9px 8px 0px 18px;'></td><td><input type='submit' id='arplsave-"+ indArplAdd +"' class='saveAutoReply' value='Save' title='Save Row' /></td></tr>");
616
+
617
+                                     selectMode();
618
+                                     saveArplRow();
619
+                                     removeArplRow();
620
+
621
+			             // Check if there is an auto-reply set for the same phone number
622
+				     $("#arpphn-"+ indArplAdd).change(function() {
623
+					 var selectedPhNb = $("#arpphn-"+ indArplAdd).val();
624
+					 var allArplPhNmbrs = $("#autoReplyTbl").find("tr").find(".arplPhoneNmbr");
625
+					 var phNbChck = 0;
626
+					 allArplPhNmbrs.each(function() {
627
+					    var slctphnb = ($(this).val())? $(this).val() : $(this).text();
628
+					    if (selectedPhNb == slctphnb) { phNbChck++; }
629
+					 });
630
+
631
+					 if (phNbChck == 2) {
632
+					     showAlert("There is already an auto-reply set up for this phone number. Please edit its own row, or choose a different phone number.");
633
+					     $(this).val('');
634
+					     return;
635
+					 }
636
+				     });
637
+                                  });
638
+
639
+		  },
640
+		  error: function() {
641
+                                    $("#autoRplPhoneNb").removeClass('icon-loading'); 
642
+                                    showAlert("Error while attempting to get the auto-reply settings! You can check the Nextcloud log to find more details about this issue.");
643
+                  }
644
+         });
645
+
646
+     },
647
+     error: function() {
648
+                  showAlert('Error while getting the settings! You can check the Nextcloud log to find more details about this issue.');
649
+     }
650
+  });
651
+
652
+
653
+
654
+  // Save personal settings for non-admin users
655
+  $("#save_sms_settings").on("click", function(event) {
656
+
657
+     if (isadm == 'reguser') {
658
+
659
+	    event.preventDefault();
660
+	    var baseUrlsave = OC.generateUrl('/apps/sms_relentless/user/updatesettings');
661
+
662
+	    var messagesperpageinit = $("#messagesperpage").val();
663
+	    var messagesperpagesec = messagesperpageinit.replace(/[^0-9]/g, '');
664
+
665
+	    if (messagesperpagesec != '') {
666
+		var messagesperpageproc = messagesperpagesec;
667
+	    } else {
668
+		var messagesperpageproc = 100;
669
+	    }
670
+
671
+	    var getnotify = 0;
672
+
673
+	    if ($("#get_notify").is(':checked')) {
674
+		getnotify = 1;
675
+	    }
676
+
677
+	    var emailaddressinit = $("#notification_email").val();
678
+
679
+	    function validate_email($email) {
680
+		var email_reg = /^([\w-\.]+@([\w-]+\.)+[\w-]{2,4})?$/;
681
+		return email_reg.test($email);
682
+	    }
683
+
684
+	    if (validate_email(emailaddressinit)) {
685
+		 var notifyemail = emailaddressinit;
686
+	    } else {
687
+		 var notifyemail = '';
688
+	    }
689
+
690
+	    var includesmsinemail = 0;
691
+	    if ($("#includesmsinemail").is(':checked')) {
692
+		includesmsinemail = 1;
693
+                if ($("#notification_email").val().trim() == '') {
694
+                    showAlert("Please enter an email address in the field: 'I want to receive a notification to the email address from below ...', or uncheck the checkbox: 'Include the SMS/MMS message in the email notification itself'.");
695
+                    return;
696
+                }
697
+	    }
698
+
699
+	    var showdisplaynm = 0;
700
+	    if ($("#showdisplaynames").is(':checked')) {
701
+		showdisplaynm = 1;
702
+	    }
703
+
704
+	    var adddisplaynm = 0;
705
+	    if ($("#adddisplaynames").is(':checked')) {
706
+		adddisplaynm = 1;
707
+	    }
708
+
709
+	    var datatosave = {
710
+			      userId: userid,
711
+		              telapiUrlRec: $("#telapi_url_rec").val(),
712
+		              telapiUrl: $("#telapi_url").val(),
713
+		              nexapiUrlRec: $("#nexapi_url_rec").val(),
714
+		              nexapiUrl: $("#nexapi_url").val(),
715
+		              twilapiUrlRec: $("#twilapi_url_rec").val(),
716
+		              twilapiUrl: $("#twilapi_url").val(),
717
+		              flowapiUrlRec: $("#flowapi_url_rec").val(),
718
+		              flowapiUrl: $("#flowapi_url").val(),
719
+			      messagesperpage: messagesperpageproc,
720
+			      getNotify: getnotify,
721
+			      notificationEmail: notifyemail,
722
+			      getsmsinemail: includesmsinemail,
723
+			      showDisplayNames: showdisplaynm,
724
+                              addDisplayNames: adddisplaynm
725
+	    };
726
+
727
+
728
+	    $.ajax({
729
+	       method: 'PUT',
730
+	       url: baseUrlsave + '/' + userid,
731
+	       contentType: 'application/json',
732
+	       data: JSON.stringify(datatosave),
733
+	       success: function() {
734
+                               OC.msg.startAction('#smsr_save_msg', t('sms_relentless', 'Saved'));
735
+	       },
736
+	       error: function() {
737
+		    showAlert('Error while attempting to save the settings! You can check the Nextcloud log to find more details about this issue.');
738
+	       }
739
+	    });
740
+
741
+
742
+     } else if (isadm == 'admin') {
743
+
744
+	    // Save personal settings for admins
745
+	    event.preventDefault();
746
+	    var baseUrlsaveadm = OC.generateUrl('/apps/sms_relentless/user/updatepersadmnsettings');
747
+
748
+	    var messagesperpageinit = $("#messagesperpage").val();
749
+	    var messagesperpagesec = messagesperpageinit.replace(/[^0-9]/g, '');
750
+
751
+	    if (messagesperpagesec != '') {
752
+		var messagesperpageproc = messagesperpagesec;
753
+	    } else {
754
+		var messagesperpageproc = 100;
755
+	    }
756
+
757
+	    var getnotify = 0;
758
+
759
+	    if ($("#get_notify").is(':checked')) {
760
+		getnotify = 1;
761
+	    }
762
+
763
+	    var emailaddressinit = $("#notification_email").val();
764
+
765
+	    function validate_email($email) {
766
+		var email_reg = /^([\w-\.]+@([\w-]+\.)+[\w-]{2,4})?$/;
767
+		return email_reg.test($email);
768
+	    }
769
+
770
+	    if (validate_email(emailaddressinit)) {
771
+		 var notifyemail = emailaddressinit;
772
+	    } else {
773
+		 var notifyemail = '';
774
+	    }
775
+
776
+	    var includesmsinemail = 0;
777
+	    if ($("#includesmsinemail").is(':checked')) {
778
+		includesmsinemail = 1;
779
+                if ($("#notification_email").val().trim() == '') {
780
+                    showAlert("Please enter an email address in the field: 'I want to receive a notification to the email address from below ...', or uncheck the checkbox: 'Include the SMS/MMS message in the email notification itself'.");
781
+                    return;
782
+                }
783
+	    }
784
+
785
+	    var showdisplaynm = 0;
786
+	    if ($("#showdisplaynames").is(':checked')) {
787
+		showdisplaynm = 1;
788
+	    }
789
+
790
+	    var adddisplaynm = 0;
791
+	    if ($("#adddisplaynames").is(':checked')) {
792
+		adddisplaynm = 1;
793
+	    }
794
+
795
+	    var datatosave = {
796
+			      userId: userid,
797
+			      messagesperpage: messagesperpageproc,
798
+			      getNotify: getnotify,
799
+			      notificationEmail: notifyemail,
800
+			      getsmsinemail: includesmsinemail,
801
+			      showDisplayNames: showdisplaynm,
802
+                              addDisplayNames: adddisplaynm
803
+	    };
804
+
805
+
806
+	    $.ajax({
807
+	       method: 'PUT',
808
+	       url: baseUrlsaveadm + '/' + userid,
809
+	       contentType: 'application/json',
810
+	       data: JSON.stringify(datatosave),
811
+	       success: function() {
812
+                               OC.msg.startAction('#smsr_save_msg', t('sms_relentless', 'Saved'));
813
+	       },
814
+	       error: function() {
815
+		    showAlert('Error while attempting to save the settings! You can check the Nextcloud log to find more details about this issue.');
816
+	       }
817
+	    });
818
+
819
+     }
820
+  });
821
+
822
+  function showAlert(alertText) {
823
+
824
+     let alertwnd = "<div id='alertMessage'>";
825
+     alertwnd += "<a id='closeAlertWnd' title='Close this window'></a>";
826
+     alertwnd += "<div id='alertTextWrap'>"+ alertText +"</div>";
827
+     alertwnd += "<input type='submit' id='alertOk' value='OK'>";
828
+     alertwnd += "</div>";
829
+
830
+     $("#content").append("<div id='alertMsgOverlay'></div>");
831
+     $("#content").append(alertwnd);
832
+
833
+     let topDist = parseInt((window.innerHeight / 2).toFixed(2) - 152) +"px";
834
+     let leftDist = parseInt((window.innerWidth / 2).toFixed(2) - 150) +"px";
835
+     $("#alertMessage").css({ "top" : topDist, "left" : leftDist });
836
+
837
+     $("#closeAlertWnd").click(function() { $("#alertMsgOverlay").remove(); $("#alertMessage").remove(); });
838
+     $("#alertMsgOverlay").click(function() { $("#alertMsgOverlay").remove(); $("#alertMessage").remove(); });
839
+     $("#alertOk").click(function() { $("#alertMsgOverlay").remove(); $("#alertMessage").remove(); });
840
+  }
841
+
842
+  function confirmAlert(alertText) {
843
+
844
+     $("#alertMsgOverlay").remove();
845
+     $("#alertConfMessage").remove();
846
+
847
+     let alertwndcf = "<div id='alertConfMessage'>";
848
+     alertwndcf += "<a id='closeAlertWndcf' title='Close this window'></a>";
849
+     alertwndcf += "<div id='alertTextWrap'>"+ alertText +"</div>";
850
+     alertwndcf += "<div id='cancelOkWrap'><input type='submit' id='confirmCancel' value='Cancel'>";
851
+     alertwndcf += "<input type='submit' id='confirmOk' value='OK'></div>";
852
+     alertwndcf += "</div>";
853
+
854
+     $("#content").append("<div id='alertMsgOverlay'></div>");
855
+     $("#content").append(alertwndcf);
856
+
857
+     let topDist = parseInt((window.innerHeight / 2).toFixed(2) - 152) +"px";
858
+     let leftDist = parseInt((window.innerWidth / 2).toFixed(2) - 150) +"px";
859
+     $("#alertConfMessage").css({ "top" : topDist, "left" : leftDist });
860
+
861
+     $("#closeAlertWndcf").click(function() { $("#alertMsgOverlay").remove(); $("#alertConfMessage").remove(); });
862
+     $("#alertMsgOverlay").click(function() { $("#alertMsgOverlay").remove(); $("#alertConfMessage").remove(); });
863
+  }
864
+
865
+});
Browse code

removed CHANGELOG.txt README.md appinfo/info.xml appinfo/signature.json img/sms_relentless_screenshot.png css/style.css js/showsmstables.js js/settings.js templates/settings/admin.php templates/settings/personal.php templates/navigation/index.php

DoubleBastionAdmin authored on 30/10/2023 14:44:44
Showing 1 changed files
1 1
deleted file mode 100644
... ...
@@ -1,863 +0,0 @@
1
-/**
2
- * @copyright 2021 Double Bastion LLC <www.doublebastion.com>
3
- *
4
- * @author Double Bastion LLC
5
- *
6
- * @license GNU AGPL version 3 or any later version
7
- *
8
- * This program is free software; you can redistribute it and/or
9
- * modify it under the terms of the GNU AFFERO GENERAL PUBLIC LICENSE
10
- * License as published by the Free Software Foundation; either
11
- * version 3 of the License, or any later version.
12
- *
13
- * This program is distributed in the hope that it will be useful,
14
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
15
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
16
- * GNU AFFERO GENERAL PUBLIC LICENSE for more details.
17
- *
18
- * You should have received a copy of the GNU Affero General Public
19
- * License along with this program.  If not, see <http://www.gnu.org/licenses/>.
20
- *
21
- */
22
-
23
-$(document).ready(function() {
24
-
25
-  var userid = "<?php p($userId); ?>";
26
-  var isadm = '';
27
-
28
-  // Get personal settings
29
-  var baseUrlget = OC.generateUrl('/apps/sms_relentless/user/getsettings');
30
-
31
-  $.ajax({
32
-     method: 'GET',
33
-     url: baseUrlget + '/' + userid,
34
-     contentType: 'application/json',
35
-     success: function(settingsfromdb) {
36
-
37
-         // Add the webhook URLs section, if the user is not an admin
38
-         if (settingsfromdb.adminornot == 'reguser') {
39
-
40
-             isadm = 'reguser';
41
-
42
-             $("#appTitlePrg").append('<p id="settings-dscr"><h3>Enter your options in the fields from below. As a non-admin user, you can use any of the SMS service providers from \
43
-                  below, on the condition that an admin has shared with you his API keys for that provider:</h3></p><br>');
44
-
45
-             $("#nadmProvSection").append('<div class="providerSettings"><p><label for="telapi_url_rec" class="setlabeltext"><b>Telnyx webhook URL for incoming SMS/MMS</b> (Generate \
46
-                  the URL by pressing the button from below. Don\'t forget to also click the \'Save\' button at the bottom of this page after entering all the options, to save \
47
-                  all the settings to the database.)</label></p> \
48
-                  <input type="button" id="generate_tel_rcpt" class="generateUrl" value="Generate new webhook URL for incoming SMS/MMS" /> \
49
-                  <input type="text" class="smsr_textboxspec" id="telapi_url_rec" name="telapi_url_rec" autocomplete="false" /> \
50
-                  <span id="copyToClipboardtel" class="icon icon-clippy" title="Copy to clipboard"></span><br><br> \
51
-                  \
52
-                  <p><label for="telapi_url" class="setlabeltext"><b>Telnyx webhook URL for delivery receipts</b> (This URL will be included by SMS Relentless in message sending \
53
-                  requests, so that Telnyx will know where to send the delivery receipts. Just generate it by pressing the button from below. Don\'t forget to click the \'Save\' \
54
-                  button at the bottom of this page after entering all the options, to save all the settings to the database.)</label></p> \
55
-                  <input type="button" id="generate_tel_delrcpt" class="generateUrl" value="Generate new webhook URL for delivery receipts" /> \
56
-                  <input type="text" id="telapi_url" name="telapi_url" autocomplete="false" /></div><br><br> \
57
-                  \
58
-                  <div class="providerSettings"><p><label for="nexapi_url_rec" class="setlabeltext"><b>Plivo webhook URL for incoming SMS/MMS</b> (Generate the URL by pressing \
59
-                  the button from below. Don\'t forget to also click the \'Save\' button at the bottom of this page after entering all the options, to save all the settings \
60
-                  to the database.)</label></p> \
61
-                  <input type="button" id="generate_nex_rcpt" class="generateUrl" value="Generate new webhook URL for incoming SMS/MMS" /> \
62
-                  <input type="text" class="smsr_textboxspec" id="nexapi_url_rec" name="nexapi_url_rec" autocomplete="false" /> \
63
-                  <span id="copyToClipboardnex" class="icon icon-clippy" title="Copy to clipboard"></span><br><br> \
64
-                  \
65
-                  <p><label for="nexapi_url" class="setlabeltext"><b>Plivo webhook URL for delivery receipts</b> (This URL will be included by SMS Relentless in message sending \
66
-                  requests, so that Plivo will know where to send the delivery receipts. Just generate it by pressing the button from below. Don\'t forget to click the \'Save\' \
67
-                  button at the bottom of this page after entering all the options, to save all the settings to the database.)</label></p> \
68
-                  <input type="button" id="generate_nex_delrcpt" class="generateUrl" value="Generate new webhook URL for delivery receipts" /> \
69
-                  <input type="text" id="nexapi_url" name="nexapi_url" autocomplete="false" /></div><br><br> \
70
-                  \
71
-                  <div class="providerSettings"><p><label for="twilapi_url_rec" class="setlabeltext"><b>Twilio webhook URL for incoming SMS/MMS</b> (Generate the URL by pressing \
72
-                  the button from below. Don\'t forget to also click the \'Save\' button at the bottom of this page after entering all the options, to save all the settings to \
73
-                  the database.)</label></p> \
74
-                  <input type="button" id="generate_twil_rcpt" class="generateUrl" value="Generate new webhook URL for incoming SMS/MMS" /> \
75
-                  <input type="text" class="smsr_textboxspec" id="twilapi_url_rec" name="twilapi_url_rec" autocomplete="false" /> \
76
-                  <span id="copyToClipboardtwil" class="icon icon-clippy" title="Copy to clipboard"></span><br><br> \
77
-                  \
78
-                  <p><label for="twilapi_url" class="setlabeltext"><b>Twilio webhook URL for delivery receipts</b> (This URL will be included by SMS Relentless in message sending \
79
-                  requests, so that Twilio will know where to send the delivery receipts. Just generate it by pressing the button from below. Don\'t forget to click the \'Save\' \
80
-                  button at the bottom of this page after entering all the options, to save all the settings to the database.)</label></p> \
81
-                  <input type="button" id="generate_twil_delrcpt" class="generateUrl" value="Generate new webhook URL for delivery receipts" /> \
82
-                  <input type="text" id="twilapi_url" name="twilapi_url" autocomplete="false" /></div><br><br> \
83
-                  \
84
-                  <div class="providerSettings"><p><label for="flowapi_url_rec" class="setlabeltext"><b>Flowroute webhook URL for incoming SMS/MMS</b> (Generate the URL by pressing \
85
-                  the button from below. Don\'t forget to also click the \'Save\' button at the bottom of this page after entering all the options, to save all the settings to \
86
-                  the database.)</label></p> \
87
-                  <input type="button" id="generate_flow_rcpt" class="generateUrl" value="Generate new webhook URL for incoming SMS/MMS" /> \
88
-                  <input type="text" class="smsr_textboxspec" id="flowapi_url_rec" name="flowapi_url_rec" autocomplete="false" /> \
89
-                  <span id="copyToClipboardflow" class="icon icon-clippy" title="Copy to clipboard"></span><br><br> \
90
-                  \
91
-                  <p><label for="flowapi_url" class="setlabeltext"><b>Flowroute webhook URL for delivery receipts</b> (This URL will be included by SMS Relentless in message sending \
92
-                  requests, so that Flowroute will know where to send the delivery receipts. Just generate it by pressing the button from below. Don\'t forget to click the \'Save\' \
93
-                  button at the bottom of this page after entering all the options, to save all the settings to the database.)</label></p> \
94
-                  <input type="button" id="generate_flow_delrcpt" class="generateUrl" value="Generate new webhook URL for delivery receipts" /> \
95
-                  <input type="text" id="flowapi_url" name="flowapi_url" autocomplete="false" /><br><br> \
96
-                  Flowroute only supports sending/receiving SMS/MMS messages within USA and Canada and it doesn\'t support Alphanumeric Sender IDs.</div><br>');
97
-
98
-
99
-		  $("#telapi_url_rec").val(settingsfromdb.telapi_url_rec);
100
-		  $("#telapi_url").val(settingsfromdb.telapi_url);
101
-		  $("#nexapi_url_rec").val(settingsfromdb.nexapi_url_rec);
102
-		  $("#nexapi_url").val(settingsfromdb.nexapi_url);
103
-		  $("#twilapi_url_rec").val(settingsfromdb.twilapi_url_rec);
104
-		  $("#twilapi_url").val(settingsfromdb.twilapi_url);
105
-		  $("#flowapi_url_rec").val(settingsfromdb.flowapi_url_rec);
106
-		  $("#flowapi_url").val(settingsfromdb.flowapi_url);
107
-		  $("#messagesperpage").val(settingsfromdb.messagesperpage);
108
-
109
-		  if (settingsfromdb.get_notify == 1) {
110
-		      $("#get_notify").attr('checked', true);
111
-		  } else {
112
-		      $("#get_notify").attr('checked', false);
113
-		  }
114
-
115
-		  $("#notification_email").val(settingsfromdb.notification_email);
116
-
117
-		  if (settingsfromdb.getsmsinemail == 1) {
118
-		      $("#includesmsinemail").attr('checked', true);
119
-		  } else {
120
-		      $("#includesmsinemail").attr('checked', false);
121
-		  }
122
-
123
-		  if (settingsfromdb.show_display_names == 1) {
124
-		      $("#showdisplaynames").attr('checked', true);
125
-		  } else {
126
-		      $("#showdisplaynames").attr('checked', false);
127
-		  }
128
-
129
-		  if (settingsfromdb.add_display_names == 1) {
130
-		      $("#adddisplaynames").attr('checked', true);
131
-		  } else {
132
-		      $("#adddisplaynames").attr('checked', false);
133
-		  }
134
-
135
-		  function randomStr(strlength) {
136
-			var fintext = "";
137
-			var keyspace = '0123456789abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ';
138
-			for (var i = 0; i < strlength; i++) {
139
-			     fintext += keyspace.charAt(Math.floor(Math.random() * keyspace.length));
140
-			}
141
-			return fintext;
142
-		  }
143
-
144
-		  $("#generate_tel_rcpt").on("click", function(event) {
145
-
146
-		     var teltokenrec = randomStr(70);
147
-		     var telnyxwhurlrec = window.location.origin + OC.generateUrl('/apps/sms_relentless/api/recsmstel?telrecparam=') + teltokenrec;
148
-
149
-		     $("#telapi_url_rec").val(telnyxwhurlrec);
150
-		  });
151
-
152
-		  $("#copyToClipboardtel").on("click", function(event) {
153
-		     var $tempEl = $("<input>");
154
-		     $("body").append($tempEl);
155
-		     $tempEl.val($("#telapi_url_rec").val()).select();
156
-		     document.execCommand("Copy");
157
-		     $tempEl.remove();
158
-		     showAlert("The link has been copied to your clipboard!");
159
-		  });
160
-
161
-		  $("#generate_tel_delrcpt").on("click", function(event) {
162
-
163
-		     var teltoken = randomStr(70);
164
-		     var telnyxwhurl = window.location.origin + OC.generateUrl('/apps/sms_relentless/api/recdeliverytel?teldrparam=') + teltoken;
165
-
166
-		     $("#telapi_url").val(telnyxwhurl);
167
-		  });
168
-
169
-
170
-		  $("#generate_nex_rcpt").on("click", function(event) {
171
-
172
-		     var plivotokenrec = randomStr(70);
173
-		     var plivowhurlrec = window.location.origin + OC.generateUrl('/apps/sms_relentless/api/recsmsnex?plivorecparam=') + plivotokenrec;
174
-
175
-		     $("#nexapi_url_rec").val(plivowhurlrec);
176
-		  });
177
-
178
-		  $("#copyToClipboardnex").on("click", function(event) {
179
-		     var $tempElpl = $("<input>");
180
-		     $("body").append($tempElpl);
181
-		     $tempElpl.val($("#nexapi_url_rec").val()).select();
182
-		     document.execCommand("Copy");
183
-		     $tempElpl.remove();
184
-		     showAlert("The link has been copied to your clipboard!");
185
-		  });
186
-
187
-		  $("#generate_nex_delrcpt").on("click", function(event) {
188
-
189
-		     var plivotoken = randomStr(70);
190
-		     var plivodrwhurl = window.location.origin + OC.generateUrl('/apps/sms_relentless/api/recdeliverynex?plivodrparam=') + plivotoken;
191
-
192
-		     $("#nexapi_url").val(plivodrwhurl);
193
-		  });
194
-
195
-
196
-		  $("#generate_twil_rcpt").on("click", function(event) {
197
-
198
-		     var twiltokenrec = randomStr(35);
199
-		     var twilwhurlrec = window.location.origin + OC.generateUrl('/apps/sms_relentless/api/recsmstwil?twilrecparam=') + twiltokenrec;
200
-
201
-		     $("#twilapi_url_rec").val(twilwhurlrec);
202
-		  });
203
-
204
-		  $("#copyToClipboardtwil").on("click", function(event) {
205
-		     var $tempElpl = $("<input>");
206
-		     $("body").append($tempElpl);
207
-		     $tempElpl.val($("#twilapi_url_rec").val()).select();
208
-		     document.execCommand("Copy");
209
-		     $tempElpl.remove();
210
-		     showAlert("The link has been copied to your clipboard!");
211
-		  });
212
-
213
-		  $("#generate_twil_delrcpt").on("click", function(event) {
214
-
215
-		     var twiltoken = randomStr(35);
216
-		     var twildrwhurl = window.location.origin + OC.generateUrl('/apps/sms_relentless/api/recdeliverytwil?twildrparam=') + twiltoken;
217
-
218
-		     $("#twilapi_url").val(twildrwhurl);
219
-		  });
220
-
221
-
222
-		  $("#generate_flow_rcpt").on("click", function(event) {
223
-
224
-		     var flowtokenrec = randomStr(70);
225
-		     var flowwhurlrec = window.location.origin + OC.generateUrl('/apps/sms_relentless/api/recsmsflow?flowrecparam=') + flowtokenrec;
226
-
227
-		     $("#flowapi_url_rec").val(flowwhurlrec);
228
-		  });
229
-
230
-		  $("#copyToClipboardflow").on("click", function(event) {
231
-		     var $tempElpl = $("<input>");
232
-		     $("body").append($tempElpl);
233
-		     $tempElpl.val($("#flowapi_url_rec").val()).select();
234
-		     document.execCommand("Copy");
235
-		     $tempElpl.remove();
236
-		     showAlert("The link has been copied to your clipboard!");
237
-		  });
238
-
239
-		  $("#generate_flow_delrcpt").on("click", function(event) {
240
-
241
-		     var flowtoken = randomStr(70);
242
-		     var flowdrwhurl = window.location.origin + OC.generateUrl('/apps/sms_relentless/api/recdeliveryflow?flowdrparam=') + flowtoken;
243
-
244
-		     $("#flowapi_url").val(flowdrwhurl);
245
-		  });
246
-
247
-
248
-         } else if (settingsfromdb.adminornot == 'admin') {
249
-
250
-                  $("#appTitlePrg").append('<p id="settings-dscr"><h3>Enter your options in the fields from below:</h3></p><br>');
251
-                  isadm = 'admin';
252
-
253
-		  $("#messagesperpage").val(settingsfromdb.messagesperpage);
254
-
255
-		  if (settingsfromdb.get_notify == 1) {
256
-		      $("#get_notify").attr('checked', true);
257
-		  } else {
258
-		      $("#get_notify").attr('checked', false);
259
-		  }
260
-
261
-		  $("#notification_email").val(settingsfromdb.notification_email);
262
-
263
-		  if (settingsfromdb.getsmsinemail == 1) {
264
-		      $("#includesmsinemail").attr('checked', true);
265
-		  } else {
266
-		      $("#includesmsinemail").attr('checked', false);
267
-		  }
268
-
269
-		  if (settingsfromdb.show_display_names == 1) {
270
-		      $("#showdisplaynames").attr('checked', true);
271
-		  } else {
272
-		      $("#showdisplaynames").attr('checked', false);
273
-		  }
274
-
275
-		  if (settingsfromdb.add_display_names == 1) {
276
-		      $("#adddisplaynames").attr('checked', true);
277
-		  } else {
278
-		      $("#adddisplaynames").attr('checked', false);
279
-		  }
280
-         }
281
-
282
-
283
-         // Auto-reply settings
284
-
285
-         // Get the available phone numbers from all providers associated with the access keys entered on the Settings page (restrictions are applied to numbers for non-admins)
286
-         $("#autoRplPhoneNb").addClass('icon-loading');
287
-         var getnumbersUrl = OC.generateUrl("/apps/sms_relentless/user/getautoreplyconf");
288
-
289
-	 $.ajax({
290
-		  url: getnumbersUrl + '/' + userid,
291
-		  type: "GET",
292
-                  contentType: 'application/json',
293
-		  success: function(autoreplydata) {
294
-
295
-                                    $("#autoRplPhoneNb").removeClass('icon-loading');
296
-                                    var cusrDisplayName = autoreplydata.userdisplayname;
297
-                                    var availPhoneNmbrs = autoreplydata.phonenumbers;
298
-                                    var autorpldata = autoreplydata.autoreplies;
299
-
300
-				    if (autorpldata.length > 0) { 
301
-				        var arplNmb = autorpldata.length;
302
-				    } else { 
303
-				        var arplNmb = 0; 
304
-				    }
305
-
306
-				    // List the auto-replies for the phone numbers available for the current user
307
-				    if (arplNmb == 0) {
308
-
309
-				        $("#autoReplyTbl").append("<tr><td><input type='text' class='arplAuthor' value='"+ cusrDisplayName +"' disabled></td><td><select id='arpphn-"+ arplNmb +"' class='arplPhoneNmbr'></select></td><td><div id='arplmode-"+ arplNmb +"' class='arplMode'><select id='modeselect-"+ arplNmb +"' class='selectArplMode'><option value='' selected>Select mode</option><option value='daily'>Daily mode</option><option value='vacation'>Vacation mode</option></select><div id='modecont-"+ arplNmb +"' class='modeContent'></div></div></td><td><textarea id='arpltxt-"+ arplNmb +"' class='arplText' rows='20' cols='40' placeholder='Enter the auto-reply message here.'></textarea></td><td><img id='rmRow-"+ arplNmb +"' class='removeRow' src='/apps/sms_relentless/img/closewnd.svg' title='Remove this row from the database' style='cursor:pointer;margin:9px 8px 0px 18px;'></td><td><input type='submit' id='arplsave-"+ arplNmb +"' class='saveAutoReply' value='Save' title='Save Row' /></td></tr>");
310
-				        $("#autoReplyTbl").append("<div><img id='addArplRow' src='/apps/sms_relentless/img/add.svg' title='Add Row'></div>");
311
-
312
-				    } else {
313
-
314
-				        for (k = 0; k < arplNmb; k++) {
315
-
316
-                                             if (autorpldata[k].days_of_week != '') {
317
-
318
-                                                 var slctdMode = "<option value=''>Select mode</option><option value='daily' selected>Daily mode</option><option value='vacation'>Vacation mode</option>";
319
-                                                 var dailyStartArr = autorpldata[k].daily_start.split(":");
320
-                                                 var dailyEndArr = autorpldata[k].daily_end.split(":");
321
-
322
-		                                 var dlHrStartOptions = "";
323
-			                         for (var hr = 0; hr < 24; hr++) {
324
-		                                      if (dailyStartArr[0] != hr.toLocaleString('en-US', {minimumIntegerDigits: 2, useGrouping:false})) {
325
-			                                  dlHrStartOptions += "<option value='"+ hr.toLocaleString('en-US', {minimumIntegerDigits: 2, useGrouping:false}) +"'>"+ hr.toLocaleString('en-US', {minimumIntegerDigits: 2, useGrouping:false}) +"</option>";
326
-		                                      } else {
327
-			                                  dlHrStartOptions += "<option value='"+ hr.toLocaleString('en-US', {minimumIntegerDigits: 2, useGrouping:false}) +"' selected>"+ hr.toLocaleString('en-US', {minimumIntegerDigits: 2, useGrouping:false}) +"</option>";
328
-		                                      }
329
-			                         }
330
-
331
-		                                 var dlMnStartOptions = "";
332
-			                         for (var mn = 0; mn < 60; mn++) {
333
-		                                      if (dailyStartArr[1] != mn.toLocaleString('en-US', {minimumIntegerDigits: 2, useGrouping:false})) {
334
-			                                  dlMnStartOptions += "<option value='"+ mn.toLocaleString('en-US', {minimumIntegerDigits: 2, useGrouping:false}) +"'>"+ mn.toLocaleString('en-US', {minimumIntegerDigits: 2, useGrouping:false}) +"</option>";
335
-		                                      } else {
336
-			                                  dlMnStartOptions += "<option value='"+ mn.toLocaleString('en-US', {minimumIntegerDigits: 2, useGrouping:false}) +"' selected>"+ mn.toLocaleString('en-US', {minimumIntegerDigits: 2, useGrouping:false}) +"</option>";
337
-		                                      }
338
-			                         }
339
-
340
-		                                 var dlHrEndOptions = "";
341
-			                         for (var hr = 0; hr < 24; hr++) {
342
-		                                      if (dailyEndArr[0] != hr.toLocaleString('en-US', {minimumIntegerDigits: 2, useGrouping:false})) {
343
-			                                  dlHrEndOptions += "<option value='"+ hr.toLocaleString('en-US', {minimumIntegerDigits: 2, useGrouping:false}) +"'>"+ hr.toLocaleString('en-US', {minimumIntegerDigits: 2, useGrouping:false}) +"</option>";
344
-		                                      } else {
345
-			                                  dlHrEndOptions += "<option value='"+ hr.toLocaleString('en-US', {minimumIntegerDigits: 2, useGrouping:false}) +"' selected>"+ hr.toLocaleString('en-US', {minimumIntegerDigits: 2, useGrouping:false}) +"</option>";
346
-		                                      }
347
-			                         }
348
-
349
-		                                 var dlMnEndOptions = "";
350
-			                         for (var mn = 0; mn < 60; mn++) {
351
-		                                      if (dailyEndArr[1] != mn.toLocaleString('en-US', {minimumIntegerDigits: 2, useGrouping:false})) {
352
-			                                  dlMnEndOptions += "<option value='"+ mn.toLocaleString('en-US', {minimumIntegerDigits: 2, useGrouping:false}) +"'>"+ mn.toLocaleString('en-US', {minimumIntegerDigits: 2, useGrouping:false}) +"</option>";
353
-		                                      } else {
354
-			                                  dlMnEndOptions += "<option value='"+ mn.toLocaleString('en-US', {minimumIntegerDigits: 2, useGrouping:false}) +"' selected>"+ mn.toLocaleString('en-US', {minimumIntegerDigits: 2, useGrouping:false}) +"</option>";
355
-		                                      }
356
-			                         }
357
-
358
-                                                 var modeContent = "<div class='daysOfWeek'>Days of the week:<div class='tooltipautoreply'><div id='infoautoreply'>i</div><div class='autorpltooltip'>Enter the order number of the days of the week in which the auto-reply will be sent. For example, to send the auto-reply every day from Monday to Friday outside the time interval specified below, enter 1,2,3,4,5 To send the auto-reply only Monday, Thursday and Friday enter 1,4,5 To send the auto-reply every day of the week enter 1,2,3,4,5,6,7 As an exception, if you want the auto-reply to be sent during an entire day, irrespective of the specified interval, add (full) after the number of that day. For example, if you want the auto-reply to be sent from Monday to Friday outside the interval specified below, and also during the entire days of Saturday and Sunday, enter 1,2,3,4,5,6(full),7(full)</div></div></div><input type='text' id='weekdays-"+ k +"' class='daysInWeek' value='"+ autorpldata[k].days_of_week +"'><div class='chooseTInterval'>Send auto-reply <span style='color:#ad0202'>outside</span> this interval:<div class='tooltipautoreplyst'><div id='infoautoreplyst'>i</div><div class='autorpltooltipst'>These fields specify the time of the server. If the server is located in a time zone that is different from that of the owner/company, the time interval entered here should be adjusted accordingly.</div></div></div><div class='selectArplHours'><select id='dmstarthr-"+ k +"' class='selectHrMin'>"+ dlHrStartOptions +"</select><select id='dmstartmn-"+ k +"' class='selectHrMin'>"+ dlMnStartOptions +"</select><span style='font-weight: 600'> — </span><select id='dmendhr-"+ k +"' class='selectHrMin'>"+ dlHrEndOptions +"</select><select id='dmendmn-"+ k +"' class='selectHrMin'>"+ dlMnEndOptions +"</select></div>";
359
-
360
-                                             } else {
361
-
362
-                                                 var vctnStart = autorpldata[k].vacation_start.split(" ")[0];
363
-                                                 var vctnEnd = autorpldata[k].vacation_end.split(" ")[0];
364
-
365
-                                                 var slctdMode = "<option value=''>Select mode</option><option value='daily'>Daily mode</option><option value='vacation' selected>Vacation mode</option>";
366
-                                                 var modeContent = "<div class='chooseDateIntvl'>Send auto-reply <span style='color:#ad0202'>inside</span> this interval:</div><div class='arplstrtendDates'><div class='stdtTitle'>Start Date</div><input type='text' id='startDT-"+ k +"' class='startDate' placeholder='Pick a date' value='"+ vctnStart +"'><div class='enddtTitle'>End Date</div><input type='text' id='endDT-"+ k +"' class='endDate' placeholder='Pick a date' value='"+ vctnEnd +"'></div>"
367
-                                             }
368
-
369
-				             $("#autoReplyTbl").append("<tr><td><input type='text' class='arplAuthor' value='"+ autorpldata[k].saved_by_dsplname +"' disabled></td><td><select id='arpphn-"+ k +"' class='arplPhoneNmbr' style='pointer-events:none'><option selected>"+ autorpldata[k].phone_number +"</option></select></td><td><div id='arplmode-"+ k +"' class='arplMode'><select id='modeselect-"+ k +"' class='selectArplMode'>"+ slctdMode +"</select><div id='modecont-"+ k +"' class='modeContent'>"+ modeContent +"</div></div></td><td><textarea id='arpltxt-"+ k +"' class='arplText' rows='20' cols='40' placeholder='Enter the auto-reply message here.'>"+ autorpldata[k].message_text +"</textarea></td><td><img id='rmRow-"+ k +"' class='removeRow' src='/apps/sms_relentless/img/closewnd.svg' title='Remove this row from the database' style='cursor:pointer;margin:9px 8px 0px 18px;'></td><td><input type='submit' id='arplsave-"+ k +"' class='saveAutoReply' value='Edit' title='Edit Row' /></td></tr>");
370
-				        }
371
-				        $("#autoReplyTbl").append("<div><img id='addArplRow' src='/apps/sms_relentless/img/add.svg' title='Add Row'></div>");
372
-				    }
373
-
374
-
375
-				    // Create a list with all the available phone numbers
376
-                                    var numbersListItems = "<option value='' selected>Select phone number</option>";
377
-
378
-				    $.each(availPhoneNmbrs, function(key, indsmsnmb) {
379
-				           numbersListItems += "<option value='"+ indsmsnmb +"'>"+ indsmsnmb +"</option>";
380
-				    });
381
-
382
-                                    if (arplNmb == 0) {
383
-				        $("#arpphn-"+ arplNmb).append(numbersListItems);
384
-                                    }
385
-
386
-                                    // Initialize the date picker
387
-			            $('[id^="endDT-"]').datepicker({ dateFormat: "yy-mm-dd" });
388
-			            $('[id^="startDT-"]').datepicker({ dateFormat: "yy-mm-dd" });
389
-
390
-
391
-                                    // Select the auto-reply mode
392
-                                    function selectMode() {
393
-
394
-		                            $('[id^="modeselect-"]').change(function() {
395
-
396
-		                               var crtnmbr = $(this).attr("id").replace("modeselect-", "");
397
-
398
-		                               var dailyHrStart = "";
399
-		                               for (var h = 0; h < 24; h++) {
400
-		                                    dailyHrStart += "<option value='"+ h.toLocaleString('en-US', {minimumIntegerDigits: 2, useGrouping:false}) +"'>"+ h.toLocaleString('en-US', {minimumIntegerDigits: 2, useGrouping:false}) +"</option>";
401
-		                               }
402
-
403
-		                               var dailyMnStart = "";
404
-		                               for (var m = 0; m < 60; m++) {
405
-		                                    dailyMnStart += "<option value='"+ m.toLocaleString('en-US', {minimumIntegerDigits: 2, useGrouping:false}) +"'>"+ m.toLocaleString('en-US', {minimumIntegerDigits: 2, useGrouping:false}) +"</option>";
406
-		                               }
407
-
408
-		                               var dailyHrEnd = dailyHrStart;
409
-		                               var dailyMnEnd = dailyMnStart;
410
-
411
-		                               if ($(this).val() == 'daily') {
412
-		                                   $("#modecont-"+ crtnmbr).empty();
413
-		                                   $("#modecont-"+ crtnmbr).append("<div class='daysOfWeek'>Days of the week:<div class='tooltipautoreply'><div id='infoautoreply'>i</div><div class='autorpltooltip'>Enter the order number of the days of the week in which the auto-reply will be sent. For example, to send the auto-reply every day from Monday to Friday outside the time interval specified below, enter 1,2,3,4,5 To send the auto-reply only Monday, Thursday and Friday enter 1,4,5 To send the auto-reply every day of the week enter 1,2,3,4,5,6,7 As an exception, if you want the auto-reply to be sent during an entire day, irrespective of the specified interval, add (full) after the number of that day. For example, if you want the auto-reply to be sent from Monday to Friday outside the interval specified below, and also during the entire days of Saturday and Sunday, enter 1,2,3,4,5,6(full),7(full)</div></div></div><input type='text' id='weekdays-"+ crtnmbr +"' class='daysInWeek'><div class='chooseTInterval'>Send auto-reply <span style='color:#ad0202'>outside</span> this interval:<div class='tooltipautoreplyst'><div id='infoautoreplyst'>i</div><div class='autorpltooltipst'>These fields specify the time of the server. If the server is located in a time zone that is different from that of the owner/company, the time interval entered here should be adjusted accordingly.</div></div></div><div class='selectArplHours'><select id='dmstarthr-"+ crtnmbr +"' class='selectHrMin'>"+ dailyHrStart +"</select><select id='dmstartmn-"+ crtnmbr +"' class='selectHrMin'>"+ dailyMnStart +"</select><span style='font-weight: 600'> — </span><select id='dmendhr-"+ crtnmbr +"' class='selectHrMin'>"+ dailyHrEnd +"</select><select id='dmendmn-"+ crtnmbr +"' class='selectHrMin'>"+ dailyMnEnd +"</select></div>");
414
-		                               } else if ($(this).val() == 'vacation') {
415
-		                                   $("#modecont-"+ crtnmbr).empty();
416
-		                                   $("#modecont-"+ crtnmbr).append("<div class='chooseDateIntvl'>Send auto-reply <span style='color:#ad0202'>inside</span> this interval:</div><div class='arplstrtendDates'><div class='stdtTitle'>Start Date</div><input type='text' id='startDT-"+ crtnmbr +"' class='startDate' placeholder='Pick a date'><div class='enddtTitle'>End Date</div><input type='text' id='endDT-"+ crtnmbr +"' class='endDate' placeholder='Pick a date' /></div>");
417
-		                               }
418
-
419
-					       $("#endDT-"+ crtnmbr +"").datepicker({ dateFormat: "yy-mm-dd" });
420
-					       $("#startDT-"+ crtnmbr +"").datepicker({ dateFormat: "yy-mm-dd" });
421
-		                          });
422
-                                  }
423
-                                  selectMode();
424
-
425
-				  // Save the data
426
-				  function saveArplRow() {
427
-
428
-				     $('[id^="arplsave-"]').unbind("click");
429
-				     $('[id^="arplsave-"]').click(function(event) {
430
-
431
-				        event.preventDefault();
432
-				        var crntrwnmbr = $(this).attr("id").replace("arplsave-", "");
433
-
434
-				        if ($(this).attr("value") == "Save") {
435
-
436
-				            var phoneNmbr = $("#arpphn-"+ crntrwnmbr).val();
437
-				            var arplText = $("#arpltxt-"+ crntrwnmbr).val();
438
-				            var slctdMode = $("#modeselect-"+ crntrwnmbr).val();
439
-
440
-				            var slctddmDays = "";
441
-				            var slctdHrStart = "";
442
-				            var slctdMnStart = "";
443
-				            var slctdHrEnd = "";
444
-				            var slctdMnEnd = "";
445
-
446
-				            var vcStartDate = null;
447
-				            var vcEndDate = null;
448
-
449
-				            if (slctdMode == 'daily') {
450
-
451
-				                slctddmDays = $("#weekdays-"+ crntrwnmbr).val().trim();
452
-				                slctdHrStart = $("#dmstarthr-"+ crntrwnmbr).val().trim();
453
-				                slctdMnStart = $("#dmstartmn-"+ crntrwnmbr).val().trim();
454
-				                slctdHrEnd = $("#dmendhr-"+ crntrwnmbr).val().trim();
455
-				                slctdMnEnd = $("#dmendmn-"+ crntrwnmbr).val().trim();
456
-
457
-                                                if (slctdHrStart != '' && slctdMnStart != '') {
458
-                                                    var hrmnStartComp = slctdHrStart +":"+ slctdMnStart;
459
-                                                } else { var hrmnStartComp = ""; }
460
-
461
-                                                if (slctdHrEnd != '' && slctdMnEnd != '') {
462
-                                                    var hrmnEndComp = slctdHrEnd +":"+ slctdMnEnd;
463
-                                                } else { var hrmnEndComp = ""; }
464
-
465
-                                                if (!(/^[1-7ful\,\(\)]+$/.test(slctddmDays))) {
466
-				                    showAlert("The 'Days of the week' field can contain only digits from 1 to 7, the lowercase letters f, u and l, round brackets ()() and commas (,).");
467
-				                    return;
468
-                                                }
469
-
470
-                                                if (!(/^[0-9]+$/.test(slctdHrStart + slctdMnStart + slctdHrEnd + slctdMnEnd))) {
471
-				                    showAlert("The starting and ending values of the time interval for the 'Daily mode' can contain only digits from 0 to 9.");
472
-				                    return;
473
-                                                }
474
-
475
-                                                if (slctddmDays.trim() == '' || (slctdHrStart == slctdHrEnd && slctdMnStart == slctdMnEnd)) {
476
-				                    showAlert("For the 'Daily mode', you have to enter the order number of the days of the week for which you want the auto-reply to be sent, and you have to set a starting time that is different from the ending time!");
477
-				                    return;
478
-                                                }
479
-
480
-				            } else if (slctdMode == 'vacation') {
481
-		
482
-                                                if ($("#startDT-"+ crntrwnmbr).val().trim() == '' || $("#endDT-"+ crntrwnmbr).val().trim() == '') {
483
-
484
-				                    showAlert("For the 'Vacation mode', you have to enter both a start date and an end date.");
485
-				                    return;
486
-
487
-                                                } else {
488
-
489
-                                                    if (!(/^[0-9\-]+$/.test($("#startDT-"+ crntrwnmbr).val().trim() + $("#endDT-"+ crntrwnmbr).val().trim()))) {
490
-				                        showAlert("The start date and end date values for the 'Vacation mode' can contain only digits from 0 to 9 and hyphens (-).");
491
-				                        return;
492
-                                                    }
493
-
494
-		                                    vcStartDate = $("#startDT-"+ crntrwnmbr).val().trim() +" 00:00:00";
495
-				                    vcEndDate = $("#endDT-"+ crntrwnmbr).val().trim() +" 23:59:59";
496
-				                    var strtDateCmp = new Date(vcStartDate).toJSON().slice(0, 10) +" 00:00:00";
497
-				                    var endDateCmp = new Date(vcEndDate).toJSON().slice(0, 10) +" 23:59:59";
498
-				                    var crntDate = new Date().toJSON().slice(0, 10) +" 23:59:59";
499
-
500
-                                                    if (vcStartDate.trim() == "" || vcEndDate.trim() == "" || (strtDateCmp >= endDateCmp || ((strtDateCmp < crntDate) && (endDateCmp < crntDate)))) {
501
-				                        showAlert("For 'Vacation mode', you have to enter both a start date and an end date, the start date must be before the end date and at least the ending of the time interval must be in the future.");
502
-				                        return;
503
-                                                    }
504
-                                                }
505
-				            }
506
-
507
-
508
-				            if (phoneNmbr != '') {
509
-
510
-				              if (arplText.trim() != '') {
511
-
512
-				                if (slctdMode != '') {
513
-
514
-				                    var saveArplUrl = OC.generateUrl('/apps/sms_relentless/user/updateautoreplies');
515
-				                    var arpldata = {
516
-				                         userId: userid,
517
-				                         savedByDsplname: cusrDisplayName,
518
-				                         phoneNumber: phoneNmbr,
519
-				                         daysOfWeek: slctddmDays,
520
-				                         dailyStart: hrmnStartComp,
521
-				                         dailyEnd: hrmnEndComp,
522
-				                         vacationStart: vcStartDate,
523
-				                         vacationEnd: vcEndDate,
524
-				                         messageText: arplText
525
-				                    };
526
-
527
-					            $.ajax({
528
-					              method: 'PUT',
529
-					              url: saveArplUrl + '/' + userid,
530
-					              contentType: 'application/json',
531
-					              data: JSON.stringify(arpldata),
532
-				                      success: function(messagereceived) {
533
-
534
-				                                   if (messagereceived == 'success') {
535
-				                                       showAlert('The auto-reply has been successfully saved to the database!');
536
-				                                   } else if (messagereceived == 'failure') {
537
-				                                       showAlert('Error while trying to save the auto-reply!');
538
-				                                   } else if (messagereceived == 'not allowed') {
539
-                                                                       showAlert('You cannot change an auto-reply that was saved by a different user.');
540
-                                                                   }
541
-				                      },
542
-					              error: function() {
543
-						                   showAlert('Error while attempting to save the auto-reply! You can check the Nextcloud log to find more details about this issue.');
544
-					              }
545
-					            });
546
-
547
-
548
-                                                } else { showAlert("Please select the auto-reply mode."); return; }
549
-
550
-                                              } else { showAlert("Please enter the text of the auto-reply."); return; }
551
-
552
-                                            } else { showAlert("Please select a phone number if at least one number is available in the 'Phone Number' drop-down list. Otherwise, you should contact the administrator."); return; }
553
-
554
-                                            $(this).attr("value", "Edit");
555
-
556
-                                        } else {
557
-                                            $("#arplsave-"+ crntrwnmbr).attr("value", "Save");
558
-                                        }
559
-
560
-                                     });
561
-
562
-				  }
563
-                                  saveArplRow();
564
-
565
-
566
-				  // Remove a row
567
-				  function removeArplRow() {
568
-				       $('[id^="rmRow-"]').click(function() {
569
-
570
-					  var slctRowRm = $(this).attr("id").replace("rmRow-", "");
571
-					  var crntPhnNmbr = $("#arpphn-"+ slctRowRm).val();
572
-
573
-				          confirmAlert("Do you really want to remove this row from the database ?");
574
-
575
-				          $("#confirmCancel").click(function() { $("#alertMsgOverlay").remove(); $("#alertConfMessage").remove(); });
576
-
577
-				          $("#confirmOk").click(function() {
578
-
579
-				              $("#alertMsgOverlay").remove();
580
-				              $("#alertConfMessage").remove();
581
-
582
-					      var rmvArplUrl = OC.generateUrl('/apps/sms_relentless/user/removeautoreplies');
583
-					      $.ajax({
584
-						   url: rmvArplUrl + '/' + userid,
585
-						   method: "POST",
586
-						   dataType: "text",
587
-						   data: { phoneNumber: crntPhnNmbr },
588
-						   success: function(delresult) {
589
-
590
-						                     if (delresult.indexOf("success") > -1) {
591
-						                         showAlert("The auto-reply has been removed successfully!");
592
-						                         $("#arpphn-"+ slctRowRm).closest("tr").remove();
593
-						                     } else if (delresult.indexOf("failure") > -1) {
594
-						                         showAlert("Error while trying to remove auto-reply data!");
595
-						                     } else if (delresult.indexOf("not allowed") > -1) {
596
-                                                                         showAlert("You cannot remove the auto-reply saved by another user.");
597
-                                                                     }
598
-						   },
599
-						   error: function() { showAlert("Error while attempting to remove auto-reply data! You can check the Nextcloud log to find more details about this issue."); }
600
-					       });
601
-					  });
602
-				       });
603
-				  }
604
-				  removeArplRow();
605
-
606
-                                  // Add a new row
607
-                                  $("#addArplRow").click(function() {
608
-
609
-                                     if ($("#autoReplyTbl").find("tr:last-child").find(".arplPhoneNmbr").length > 0) {
610
-                                         var lastarpl = $("#autoReplyTbl").find("tr:last-child").find(".arplPhoneNmbr").attr("id").replace("arpphn-", "");
611
-                                         var indArplAdd = parseInt(lastarpl + 1);
612
-                                     } else { var indArplAdd = 0; }
613
-			             $("#autoReplyTbl").append("<tr><td><input type='text' class='arplAuthor' value='"+ cusrDisplayName +"' disabled></td><td><select id='arpphn-"+ indArplAdd +"' class='arplPhoneNmbr'>"+ numbersListItems +"</select></td><td><div id='arplmode-"+ indArplAdd +"' class='arplMode'><select id='modeselect-"+ indArplAdd +"' class='selectArplMode'><option value='' selected>Select mode</option><option value='daily'>Daily mode</option><option value='vacation'>Vacation mode</option></select><div id='modecont-"+ indArplAdd +"' class='modeContent'></div></div></td><td><textarea id='arpltxt-"+ indArplAdd +"' class='arplText' rows='20' cols='40' placeholder='Enter the auto-reply message here.'></textarea></td><td><img id='rmRow-"+ indArplAdd +"' class='removeRow' src='/apps/sms_relentless/img/closewnd.svg' title='Remove this row from the database' style='cursor:pointer;margin:9px 8px 0px 18px;'></td><td><input type='submit' id='arplsave-"+ indArplAdd +"' class='saveAutoReply' value='Save' title='Save Row' /></td></tr>");
614
-
615
-                                     selectMode();
616
-                                     saveArplRow();
617
-                                     removeArplRow();
618
-
619
-			             // Check if there is an auto-reply set for the same phone number
620
-				     $("#arpphn-"+ indArplAdd).change(function() {
621
-					 var selectedPhNb = $("#arpphn-"+ indArplAdd).val();
622
-					 var allArplPhNmbrs = $("#autoReplyTbl").find("tr").find(".arplPhoneNmbr");
623
-					 var phNbChck = 0;
624
-					 allArplPhNmbrs.each(function() {
625
-					    var slctphnb = ($(this).val())? $(this).val() : $(this).text();
626
-					    if (selectedPhNb == slctphnb) { phNbChck++; }
627
-					 });
628
-
629
-					 if (phNbChck == 2) {
630
-					     showAlert("There is already an auto-reply set up for this phone number. Please edit its own row, or choose a different phone number.");
631
-					     $(this).val('');
632
-					     return;
633
-					 }
634
-				     });
635
-                                  });
636
-
637
-		  },
638
-		  error: function() {
639
-                                    $("#autoRplPhoneNb").removeClass('icon-loading'); 
640
-                                    showAlert("Error while attempting to get the auto-reply settings! You can check the Nextcloud log to find more details about this issue.");
641
-                  }
642
-         });
643
-
644
-     },
645
-     error: function() {
646
-                  showAlert('Error while getting the settings! You can check the Nextcloud log to find more details about this issue.');
647
-     }
648
-  });
649
-
650
-
651
-
652
-  // Save personal settings for non-admin users
653
-  $("#save_sms_settings").on("click", function(event) {
654
-
655
-     if (isadm == 'reguser') {
656
-
657
-	    event.preventDefault();
658
-	    var baseUrlsave = OC.generateUrl('/apps/sms_relentless/user/updatesettings');
659
-
660
-	    var messagesperpageinit = $("#messagesperpage").val();
661
-	    var messagesperpagesec = messagesperpageinit.replace(/[^0-9]/g, '');
662
-
663
-	    if (messagesperpagesec != '') {
664
-		var messagesperpageproc = messagesperpagesec;
665
-	    } else {
666
-		var messagesperpageproc = 100;
667
-	    }
668
-
669
-	    var getnotify = 0;
670
-
671
-	    if ($("#get_notify").is(':checked')) {
672
-		getnotify = 1;
673
-	    }
674
-
675
-	    var emailaddressinit = $("#notification_email").val();
676
-
677
-	    function validate_email($email) {
678
-		var email_reg = /^([\w-\.]+@([\w-]+\.)+[\w-]{2,4})?$/;
679
-		return email_reg.test($email);
680
-	    }
681
-
682
-	    if (validate_email(emailaddressinit)) {
683
-		 var notifyemail = emailaddressinit;
684
-	    } else {
685
-		 var notifyemail = '';
686
-	    }
687
-
688
-	    var includesmsinemail = 0;
689
-	    if ($("#includesmsinemail").is(':checked')) {
690
-		includesmsinemail = 1;
691
-                if ($("#notification_email").val().trim() == '') {
692
-                    showAlert("Please enter an email address in the field: 'I want to receive a notification to the email address from below ...', or uncheck the checkbox: 'Include the SMS/MMS message in the email notification itself'.");
693
-                    return;
694
-                }
695
-	    }
696
-
697
-	    var showdisplaynm = 0;
698
-	    if ($("#showdisplaynames").is(':checked')) {
699
-		showdisplaynm = 1;
700
-	    }
701
-
702
-	    var adddisplaynm = 0;
703
-	    if ($("#adddisplaynames").is(':checked')) {
704
-		adddisplaynm = 1;
705
-	    }
706
-
707
-	    var datatosave = {
708
-			      userId: userid,
709
-		              telapiUrlRec: $("#telapi_url_rec").val(),
710
-		              telapiUrl: $("#telapi_url").val(),
711
-		              nexapiUrlRec: $("#nexapi_url_rec").val(),
712
-		              nexapiUrl: $("#nexapi_url").val(),
713
-		              twilapiUrlRec: $("#twilapi_url_rec").val(),
714
-		              twilapiUrl: $("#twilapi_url").val(),
715
-		              flowapiUrlRec: $("#flowapi_url_rec").val(),
716
-		              flowapiUrl: $("#flowapi_url").val(),
717
-			      messagesperpage: messagesperpageproc,
718
-			      getNotify: getnotify,
719
-			      notificationEmail: notifyemail,
720
-			      getsmsinemail: includesmsinemail,
721
-			      showDisplayNames: showdisplaynm,
722
-                              addDisplayNames: adddisplaynm
723
-	    };
724
-
725
-
726
-	    $.ajax({
727
-	       method: 'PUT',
728
-	       url: baseUrlsave + '/' + userid,
729
-	       contentType: 'application/json',
730
-	       data: JSON.stringify(datatosave),
731
-	       success: function() {
732
-                               OC.msg.startAction('#smsr_save_msg', t('sms_relentless', 'Saved'));
733
-	       },
734
-	       error: function() {
735
-		    showAlert('Error while attempting to save the settings! You can check the Nextcloud log to find more details about this issue.');
736
-	       }
737
-	    });
738
-
739
-
740
-     } else if (isadm == 'admin') {
741
-
742
-	    // Save personal settings for admins
743
-	    event.preventDefault();
744
-	    var baseUrlsaveadm = OC.generateUrl('/apps/sms_relentless/user/updatepersadmnsettings');
745
-
746
-	    var messagesperpageinit = $("#messagesperpage").val();
747
-	    var messagesperpagesec = messagesperpageinit.replace(/[^0-9]/g, '');
748
-
749
-	    if (messagesperpagesec != '') {
750
-		var messagesperpageproc = messagesperpagesec;
751
-	    } else {
752
-		var messagesperpageproc = 100;
753
-	    }
754
-
755
-	    var getnotify = 0;
756
-
757
-	    if ($("#get_notify").is(':checked')) {
758
-		getnotify = 1;
759
-	    }
760
-
761
-	    var emailaddressinit = $("#notification_email").val();
762
-
763
-	    function validate_email($email) {
764
-		var email_reg = /^([\w-\.]+@([\w-]+\.)+[\w-]{2,4})?$/;
765
-		return email_reg.test($email);
766
-	    }
767
-
768
-	    if (validate_email(emailaddressinit)) {
769
-		 var notifyemail = emailaddressinit;
770
-	    } else {
771
-		 var notifyemail = '';
772
-	    }
773
-
774
-	    var includesmsinemail = 0;
775
-	    if ($("#includesmsinemail").is(':checked')) {
776
-		includesmsinemail = 1;
777
-                if ($("#notification_email").val().trim() == '') {
778
-                    showAlert("Please enter an email address in the field: 'I want to receive a notification to the email address from below ...', or uncheck the checkbox: 'Include the SMS/MMS message in the email notification itself'.");
779
-                    return;
780
-                }
781
-	    }
782
-
783
-	    var showdisplaynm = 0;
784
-	    if ($("#showdisplaynames").is(':checked')) {
785
-		showdisplaynm = 1;
786
-	    }
787
-
788
-	    var adddisplaynm = 0;
789
-	    if ($("#adddisplaynames").is(':checked')) {
790
-		adddisplaynm = 1;
791
-	    }
792
-
793
-	    var datatosave = {
794
-			      userId: userid,
795
-			      messagesperpage: messagesperpageproc,
796
-			      getNotify: getnotify,
797
-			      notificationEmail: notifyemail,
798
-			      getsmsinemail: includesmsinemail,
799
-			      showDisplayNames: showdisplaynm,
800
-                              addDisplayNames: adddisplaynm
801
-	    };
802
-
803
-
804
-	    $.ajax({
805
-	       method: 'PUT',
806
-	       url: baseUrlsaveadm + '/' + userid,
807
-	       contentType: 'application/json',
808
-	       data: JSON.stringify(datatosave),
809
-	       success: function() {
810
-                               OC.msg.startAction('#smsr_save_msg', t('sms_relentless', 'Saved'));
811
-	       },
812
-	       error: function() {
813
-		    showAlert('Error while attempting to save the settings! You can check the Nextcloud log to find more details about this issue.');
814
-	       }
815
-	    });
816
-
817
-     }
818
-  });
819
-
820
-  function showAlert(alertText) {
821
-
822
-     let alertwnd = "<div id='alertMessage'>";
823
-     alertwnd += "<a id='closeAlertWnd' title='Close this window'></a>";
824
-     alertwnd += "<div id='alertTextWrap'>"+ alertText +"</div>";
825
-     alertwnd += "<input type='submit' id='alertOk' value='OK'>";
826
-     alertwnd += "</div>";
827
-
828
-     $("#content").append("<div id='alertMsgOverlay'></div>");
829
-     $("#content").append(alertwnd);
830
-
831
-     let topDist = parseInt((window.innerHeight / 2).toFixed(2) - 152) +"px";
832
-     let leftDist = parseInt((window.innerWidth / 2).toFixed(2) - 150) +"px";
833
-     $("#alertMessage").css({ "top" : topDist, "left" : leftDist });
834
-
835
-     $("#closeAlertWnd").click(function() { $("#alertMsgOverlay").remove(); $("#alertMessage").remove(); });
836
-     $("#alertMsgOverlay").click(function() { $("#alertMsgOverlay").remove(); $("#alertMessage").remove(); });
837
-     $("#alertOk").click(function() { $("#alertMsgOverlay").remove(); $("#alertMessage").remove(); });
838
-  }
839
-
840
-  function confirmAlert(alertText) {
841
-
842
-     $("#alertMsgOverlay").remove();
843
-     $("#alertConfMessage").remove();
844
-
845
-     let alertwndcf = "<div id='alertConfMessage'>";
846
-     alertwndcf += "<a id='closeAlertWndcf' title='Close this window'></a>";
847
-     alertwndcf += "<div id='alertTextWrap'>"+ alertText +"</div>";
848
-     alertwndcf += "<div id='cancelOkWrap'><input type='submit' id='confirmCancel' value='Cancel'>";
849
-     alertwndcf += "<input type='submit' id='confirmOk' value='OK'></div>";
850
-     alertwndcf += "</div>";
851
-
852
-     $("#content").append("<div id='alertMsgOverlay'></div>");
853
-     $("#content").append(alertwndcf);
854
-
855
-     let topDist = parseInt((window.innerHeight / 2).toFixed(2) - 152) +"px";
856
-     let leftDist = parseInt((window.innerWidth / 2).toFixed(2) - 150) +"px";
857
-     $("#alertConfMessage").css({ "top" : topDist, "left" : leftDist });
858
-
859
-     $("#closeAlertWndcf").click(function() { $("#alertMsgOverlay").remove(); $("#alertConfMessage").remove(); });
860
-     $("#alertMsgOverlay").click(function() { $("#alertMsgOverlay").remove(); $("#alertConfMessage").remove(); });
861
-  }
862
-
863
-});
Browse code

added CHANGELOG.txt appinfo/info.xml appinfo/signature.json appinfo/routes.php css/style.css js/adminsettings.js js/deleteoldsms.js js/sendsms.js js/settings.js js/showsmstables.js lib/Controller/AuthorApiController.php lib/Controller/SmsrelentlessController.php lib/Service/SmsrelentlessService.php providers/Telnyx/lib/ApiResource.php

DoubleBastionAdmin authored on 15/07/2023 22:05:06
Showing 1 changed files
1 1
new file mode 100644
... ...
@@ -0,0 +1,863 @@
1
+/**
2
+ * @copyright 2021 Double Bastion LLC <www.doublebastion.com>
3
+ *
4
+ * @author Double Bastion LLC
5
+ *
6
+ * @license GNU AGPL version 3 or any later version
7
+ *
8
+ * This program is free software; you can redistribute it and/or
9
+ * modify it under the terms of the GNU AFFERO GENERAL PUBLIC LICENSE
10
+ * License as published by the Free Software Foundation; either
11
+ * version 3 of the License, or any later version.
12
+ *
13
+ * This program is distributed in the hope that it will be useful,
14
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
15
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
16
+ * GNU AFFERO GENERAL PUBLIC LICENSE for more details.
17
+ *
18
+ * You should have received a copy of the GNU Affero General Public
19
+ * License along with this program.  If not, see <http://www.gnu.org/licenses/>.
20
+ *
21
+ */
22
+
23
+$(document).ready(function() {
24
+
25
+  var userid = "<?php p($userId); ?>";
26
+  var isadm = '';
27
+
28
+  // Get personal settings
29
+  var baseUrlget = OC.generateUrl('/apps/sms_relentless/user/getsettings');
30
+
31
+  $.ajax({
32
+     method: 'GET',
33
+     url: baseUrlget + '/' + userid,
34
+     contentType: 'application/json',
35
+     success: function(settingsfromdb) {
36
+
37
+         // Add the webhook URLs section, if the user is not an admin
38
+         if (settingsfromdb.adminornot == 'reguser') {
39
+
40
+             isadm = 'reguser';
41
+
42
+             $("#appTitlePrg").append('<p id="settings-dscr"><h3>Enter your options in the fields from below. As a non-admin user, you can use any of the SMS service providers from \
43
+                  below, on the condition that an admin has shared with you his API keys for that provider:</h3></p><br>');
44
+
45
+             $("#nadmProvSection").append('<div class="providerSettings"><p><label for="telapi_url_rec" class="setlabeltext"><b>Telnyx webhook URL for incoming SMS/MMS</b> (Generate \
46
+                  the URL by pressing the button from below. Don\'t forget to also click the \'Save\' button at the bottom of this page after entering all the options, to save \
47
+                  all the settings to the database.)</label></p> \
48
+                  <input type="button" id="generate_tel_rcpt" class="generateUrl" value="Generate new webhook URL for incoming SMS/MMS" /> \
49
+                  <input type="text" class="smsr_textboxspec" id="telapi_url_rec" name="telapi_url_rec" autocomplete="false" /> \
50
+                  <span id="copyToClipboardtel" class="icon icon-clippy" title="Copy to clipboard"></span><br><br> \
51
+                  \
52
+                  <p><label for="telapi_url" class="setlabeltext"><b>Telnyx webhook URL for delivery receipts</b> (This URL will be included by SMS Relentless in message sending \
53
+                  requests, so that Telnyx will know where to send the delivery receipts. Just generate it by pressing the button from below. Don\'t forget to click the \'Save\' \
54
+                  button at the bottom of this page after entering all the options, to save all the settings to the database.)</label></p> \
55
+                  <input type="button" id="generate_tel_delrcpt" class="generateUrl" value="Generate new webhook URL for delivery receipts" /> \
56
+                  <input type="text" id="telapi_url" name="telapi_url" autocomplete="false" /></div><br><br> \
57
+                  \
58
+                  <div class="providerSettings"><p><label for="nexapi_url_rec" class="setlabeltext"><b>Plivo webhook URL for incoming SMS/MMS</b> (Generate the URL by pressing \
59
+                  the button from below. Don\'t forget to also click the \'Save\' button at the bottom of this page after entering all the options, to save all the settings \
60
+                  to the database.)</label></p> \
61
+                  <input type="button" id="generate_nex_rcpt" class="generateUrl" value="Generate new webhook URL for incoming SMS/MMS" /> \
62
+                  <input type="text" class="smsr_textboxspec" id="nexapi_url_rec" name="nexapi_url_rec" autocomplete="false" /> \
63
+                  <span id="copyToClipboardnex" class="icon icon-clippy" title="Copy to clipboard"></span><br><br> \
64
+                  \
65
+                  <p><label for="nexapi_url" class="setlabeltext"><b>Plivo webhook URL for delivery receipts</b> (This URL will be included by SMS Relentless in message sending \
66
+                  requests, so that Plivo will know where to send the delivery receipts. Just generate it by pressing the button from below. Don\'t forget to click the \'Save\' \
67
+                  button at the bottom of this page after entering all the options, to save all the settings to the database.)</label></p> \
68
+                  <input type="button" id="generate_nex_delrcpt" class="generateUrl" value="Generate new webhook URL for delivery receipts" /> \
69
+                  <input type="text" id="nexapi_url" name="nexapi_url" autocomplete="false" /></div><br><br> \
70
+                  \
71
+                  <div class="providerSettings"><p><label for="twilapi_url_rec" class="setlabeltext"><b>Twilio webhook URL for incoming SMS/MMS</b> (Generate the URL by pressing \
72
+                  the button from below. Don\'t forget to also click the \'Save\' button at the bottom of this page after entering all the options, to save all the settings to \
73
+                  the database.)</label></p> \
74
+                  <input type="button" id="generate_twil_rcpt" class="generateUrl" value="Generate new webhook URL for incoming SMS/MMS" /> \
75
+                  <input type="text" class="smsr_textboxspec" id="twilapi_url_rec" name="twilapi_url_rec" autocomplete="false" /> \
76
+                  <span id="copyToClipboardtwil" class="icon icon-clippy" title="Copy to clipboard"></span><br><br> \
77
+                  \
78
+                  <p><label for="twilapi_url" class="setlabeltext"><b>Twilio webhook URL for delivery receipts</b> (This URL will be included by SMS Relentless in message sending \
79
+                  requests, so that Twilio will know where to send the delivery receipts. Just generate it by pressing the button from below. Don\'t forget to click the \'Save\' \
80
+                  button at the bottom of this page after entering all the options, to save all the settings to the database.)</label></p> \
81
+                  <input type="button" id="generate_twil_delrcpt" class="generateUrl" value="Generate new webhook URL for delivery receipts" /> \
82
+                  <input type="text" id="twilapi_url" name="twilapi_url" autocomplete="false" /></div><br><br> \
83
+                  \
84
+                  <div class="providerSettings"><p><label for="flowapi_url_rec" class="setlabeltext"><b>Flowroute webhook URL for incoming SMS/MMS</b> (Generate the URL by pressing \
85
+                  the button from below. Don\'t forget to also click the \'Save\' button at the bottom of this page after entering all the options, to save all the settings to \
86
+                  the database.)</label></p> \
87
+                  <input type="button" id="generate_flow_rcpt" class="generateUrl" value="Generate new webhook URL for incoming SMS/MMS" /> \
88
+                  <input type="text" class="smsr_textboxspec" id="flowapi_url_rec" name="flowapi_url_rec" autocomplete="false" /> \
89
+                  <span id="copyToClipboardflow" class="icon icon-clippy" title="Copy to clipboard"></span><br><br> \
90
+                  \
91
+                  <p><label for="flowapi_url" class="setlabeltext"><b>Flowroute webhook URL for delivery receipts</b> (This URL will be included by SMS Relentless in message sending \
92
+                  requests, so that Flowroute will know where to send the delivery receipts. Just generate it by pressing the button from below. Don\'t forget to click the \'Save\' \
93
+                  button at the bottom of this page after entering all the options, to save all the settings to the database.)</label></p> \
94
+                  <input type="button" id="generate_flow_delrcpt" class="generateUrl" value="Generate new webhook URL for delivery receipts" /> \
95
+                  <input type="text" id="flowapi_url" name="flowapi_url" autocomplete="false" /><br><br> \
96
+                  Flowroute only supports sending/receiving SMS/MMS messages within USA and Canada and it doesn\'t support Alphanumeric Sender IDs.</div><br>');
97
+
98
+
99
+		  $("#telapi_url_rec").val(settingsfromdb.telapi_url_rec);
100
+		  $("#telapi_url").val(settingsfromdb.telapi_url);
101
+		  $("#nexapi_url_rec").val(settingsfromdb.nexapi_url_rec);
102
+		  $("#nexapi_url").val(settingsfromdb.nexapi_url);
103
+		  $("#twilapi_url_rec").val(settingsfromdb.twilapi_url_rec);
104
+		  $("#twilapi_url").val(settingsfromdb.twilapi_url);
105
+		  $("#flowapi_url_rec").val(settingsfromdb.flowapi_url_rec);
106
+		  $("#flowapi_url").val(settingsfromdb.flowapi_url);
107
+		  $("#messagesperpage").val(settingsfromdb.messagesperpage);
108
+
109
+		  if (settingsfromdb.get_notify == 1) {
110
+		      $("#get_notify").attr('checked', true);
111
+		  } else {
112
+		      $("#get_notify").attr('checked', false);
113
+		  }
114
+
115
+		  $("#notification_email").val(settingsfromdb.notification_email);
116
+
117
+		  if (settingsfromdb.getsmsinemail == 1) {
118
+		      $("#includesmsinemail").attr('checked', true);
119
+		  } else {
120
+		      $("#includesmsinemail").attr('checked', false);
121
+		  }
122
+
123
+		  if (settingsfromdb.show_display_names == 1) {
124
+		      $("#showdisplaynames").attr('checked', true);
125
+		  } else {
126
+		      $("#showdisplaynames").attr('checked', false);
127
+		  }
128
+
129
+		  if (settingsfromdb.add_display_names == 1) {
130
+		      $("#adddisplaynames").attr('checked', true);
131
+		  } else {
132
+		      $("#adddisplaynames").attr('checked', false);
133
+		  }
134
+
135
+		  function randomStr(strlength) {
136
+			var fintext = "";
137
+			var keyspace = '0123456789abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ';
138
+			for (var i = 0; i < strlength; i++) {
139
+			     fintext += keyspace.charAt(Math.floor(Math.random() * keyspace.length));
140
+			}
141
+			return fintext;
142
+		  }
143
+
144
+		  $("#generate_tel_rcpt").on("click", function(event) {
145
+
146
+		     var teltokenrec = randomStr(70);
147
+		     var telnyxwhurlrec = window.location.origin + OC.generateUrl('/apps/sms_relentless/api/recsmstel?telrecparam=') + teltokenrec;
148
+
149
+		     $("#telapi_url_rec").val(telnyxwhurlrec);
150
+		  });
151
+
152
+		  $("#copyToClipboardtel").on("click", function(event) {
153
+		     var $tempEl = $("<input>");
154
+		     $("body").append($tempEl);
155
+		     $tempEl.val($("#telapi_url_rec").val()).select();
156
+		     document.execCommand("Copy");
157
+		     $tempEl.remove();
158
+		     showAlert("The link has been copied to your clipboard!");
159
+		  });
160
+
161
+		  $("#generate_tel_delrcpt").on("click", function(event) {
162
+
163
+		     var teltoken = randomStr(70);
164
+		     var telnyxwhurl = window.location.origin + OC.generateUrl('/apps/sms_relentless/api/recdeliverytel?teldrparam=') + teltoken;
165
+
166
+		     $("#telapi_url").val(telnyxwhurl);
167
+		  });
168
+
169
+
170
+		  $("#generate_nex_rcpt").on("click", function(event) {
171
+
172
+		     var plivotokenrec = randomStr(70);
173
+		     var plivowhurlrec = window.location.origin + OC.generateUrl('/apps/sms_relentless/api/recsmsnex?plivorecparam=') + plivotokenrec;
174
+
175
+		     $("#nexapi_url_rec").val(plivowhurlrec);
176
+		  });
177
+
178
+		  $("#copyToClipboardnex").on("click", function(event) {
179
+		     var $tempElpl = $("<input>");
180
+		     $("body").append($tempElpl);
181
+		     $tempElpl.val($("#nexapi_url_rec").val()).select();
182
+		     document.execCommand("Copy");
183
+		     $tempElpl.remove();
184
+		     showAlert("The link has been copied to your clipboard!");
185
+		  });
186
+
187
+		  $("#generate_nex_delrcpt").on("click", function(event) {
188
+
189
+		     var plivotoken = randomStr(70);
190
+		     var plivodrwhurl = window.location.origin + OC.generateUrl('/apps/sms_relentless/api/recdeliverynex?plivodrparam=') + plivotoken;
191
+
192
+		     $("#nexapi_url").val(plivodrwhurl);
193
+		  });
194
+
195
+
196
+		  $("#generate_twil_rcpt").on("click", function(event) {
197
+
198
+		     var twiltokenrec = randomStr(35);
199
+		     var twilwhurlrec = window.location.origin + OC.generateUrl('/apps/sms_relentless/api/recsmstwil?twilrecparam=') + twiltokenrec;
200
+
201
+		     $("#twilapi_url_rec").val(twilwhurlrec);
202
+		  });
203
+
204
+		  $("#copyToClipboardtwil").on("click", function(event) {
205
+		     var $tempElpl = $("<input>");
206
+		     $("body").append($tempElpl);
207
+		     $tempElpl.val($("#twilapi_url_rec").val()).select();
208
+		     document.execCommand("Copy");
209
+		     $tempElpl.remove();
210
+		     showAlert("The link has been copied to your clipboard!");
211
+		  });
212
+
213
+		  $("#generate_twil_delrcpt").on("click", function(event) {
214
+
215
+		     var twiltoken = randomStr(35);
216
+		     var twildrwhurl = window.location.origin + OC.generateUrl('/apps/sms_relentless/api/recdeliverytwil?twildrparam=') + twiltoken;
217
+
218
+		     $("#twilapi_url").val(twildrwhurl);
219
+		  });
220
+
221
+
222
+		  $("#generate_flow_rcpt").on("click", function(event) {
223
+
224
+		     var flowtokenrec = randomStr(70);
225
+		     var flowwhurlrec = window.location.origin + OC.generateUrl('/apps/sms_relentless/api/recsmsflow?flowrecparam=') + flowtokenrec;
226
+
227
+		     $("#flowapi_url_rec").val(flowwhurlrec);
228
+		  });
229
+
230
+		  $("#copyToClipboardflow").on("click", function(event) {
231
+		     var $tempElpl = $("<input>");
232
+		     $("body").append($tempElpl);
233
+		     $tempElpl.val($("#flowapi_url_rec").val()).select();
234
+		     document.execCommand("Copy");
235
+		     $tempElpl.remove();
236
+		     showAlert("The link has been copied to your clipboard!");
237
+		  });
238
+
239
+		  $("#generate_flow_delrcpt").on("click", function(event) {
240
+
241
+		     var flowtoken = randomStr(70);
242
+		     var flowdrwhurl = window.location.origin + OC.generateUrl('/apps/sms_relentless/api/recdeliveryflow?flowdrparam=') + flowtoken;
243
+
244
+		     $("#flowapi_url").val(flowdrwhurl);
245
+		  });
246
+
247
+
248
+         } else if (settingsfromdb.adminornot == 'admin') {
249
+
250
+                  $("#appTitlePrg").append('<p id="settings-dscr"><h3>Enter your options in the fields from below:</h3></p><br>');
251
+                  isadm = 'admin';
252
+
253
+		  $("#messagesperpage").val(settingsfromdb.messagesperpage);
254
+
255
+		  if (settingsfromdb.get_notify == 1) {
256
+		      $("#get_notify").attr('checked', true);
257
+		  } else {
258
+		      $("#get_notify").attr('checked', false);
259
+		  }
260
+
261
+		  $("#notification_email").val(settingsfromdb.notification_email);
262
+
263
+		  if (settingsfromdb.getsmsinemail == 1) {
264
+		      $("#includesmsinemail").attr('checked', true);
265
+		  } else {
266
+		      $("#includesmsinemail").attr('checked', false);
267
+		  }
268
+
269
+		  if (settingsfromdb.show_display_names == 1) {
270
+		      $("#showdisplaynames").attr('checked', true);
271
+		  } else {
272
+		      $("#showdisplaynames").attr('checked', false);
273
+		  }
274
+
275
+		  if (settingsfromdb.add_display_names == 1) {
276
+		      $("#adddisplaynames").attr('checked', true);
277
+		  } else {
278
+		      $("#adddisplaynames").attr('checked', false);
279
+		  }
280
+         }
281
+
282
+
283
+         // Auto-reply settings
284
+
285
+         // Get the available phone numbers from all providers associated with the access keys entered on the Settings page (restrictions are applied to numbers for non-admins)
286
+         $("#autoRplPhoneNb").addClass('icon-loading');
287
+         var getnumbersUrl = OC.generateUrl("/apps/sms_relentless/user/getautoreplyconf");
288
+
289
+	 $.ajax({
290
+		  url: getnumbersUrl + '/' + userid,
291
+		  type: "GET",
292
+                  contentType: 'application/json',
293
+		  success: function(autoreplydata) {
294
+
295
+                                    $("#autoRplPhoneNb").removeClass('icon-loading');
296
+                                    var cusrDisplayName = autoreplydata.userdisplayname;
297
+                                    var availPhoneNmbrs = autoreplydata.phonenumbers;
298
+                                    var autorpldata = autoreplydata.autoreplies;
299
+
300
+				    if (autorpldata.length > 0) { 
301
+				        var arplNmb = autorpldata.length;
302
+				    } else { 
303
+				        var arplNmb = 0; 
304
+				    }
305
+
306
+				    // List the auto-replies for the phone numbers available for the current user
307
+				    if (arplNmb == 0) {
308
+
309
+				        $("#autoReplyTbl").append("<tr><td><input type='text' class='arplAuthor' value='"+ cusrDisplayName +"' disabled></td><td><select id='arpphn-"+ arplNmb +"' class='arplPhoneNmbr'></select></td><td><div id='arplmode-"+ arplNmb +"' class='arplMode'><select id='modeselect-"+ arplNmb +"' class='selectArplMode'><option value='' selected>Select mode</option><option value='daily'>Daily mode</option><option value='vacation'>Vacation mode</option></select><div id='modecont-"+ arplNmb +"' class='modeContent'></div></div></td><td><textarea id='arpltxt-"+ arplNmb +"' class='arplText' rows='20' cols='40' placeholder='Enter the auto-reply message here.'></textarea></td><td><img id='rmRow-"+ arplNmb +"' class='removeRow' src='/apps/sms_relentless/img/closewnd.svg' title='Remove this row from the database' style='cursor:pointer;margin:9px 8px 0px 18px;'></td><td><input type='submit' id='arplsave-"+ arplNmb +"' class='saveAutoReply' value='Save' title='Save Row' /></td></tr>");
310
+				        $("#autoReplyTbl").append("<div><img id='addArplRow' src='/apps/sms_relentless/img/add.svg' title='Add Row'></div>");
311
+
312
+				    } else {
313
+
314
+				        for (k = 0; k < arplNmb; k++) {
315
+
316
+                                             if (autorpldata[k].days_of_week != '') {
317
+
318
+                                                 var slctdMode = "<option value=''>Select mode</option><option value='daily' selected>Daily mode</option><option value='vacation'>Vacation mode</option>";
319
+                                                 var dailyStartArr = autorpldata[k].daily_start.split(":");
320
+                                                 var dailyEndArr = autorpldata[k].daily_end.split(":");
321
+
322
+		                                 var dlHrStartOptions = "";
323
+			                         for (var hr = 0; hr < 24; hr++) {
324
+		                                      if (dailyStartArr[0] != hr.toLocaleString('en-US', {minimumIntegerDigits: 2, useGrouping:false})) {
325
+			                                  dlHrStartOptions += "<option value='"+ hr.toLocaleString('en-US', {minimumIntegerDigits: 2, useGrouping:false}) +"'>"+ hr.toLocaleString('en-US', {minimumIntegerDigits: 2, useGrouping:false}) +"</option>";
326
+		                                      } else {
327
+			                                  dlHrStartOptions += "<option value='"+ hr.toLocaleString('en-US', {minimumIntegerDigits: 2, useGrouping:false}) +"' selected>"+ hr.toLocaleString('en-US', {minimumIntegerDigits: 2, useGrouping:false}) +"</option>";
328
+		                                      }
329
+			                         }
330
+
331
+		                                 var dlMnStartOptions = "";
332
+			                         for (var mn = 0; mn < 60; mn++) {
333
+		                                      if (dailyStartArr[1] != mn.toLocaleString('en-US', {minimumIntegerDigits: 2, useGrouping:false})) {
334
+			                                  dlMnStartOptions += "<option value='"+ mn.toLocaleString('en-US', {minimumIntegerDigits: 2, useGrouping:false}) +"'>"+ mn.toLocaleString('en-US', {minimumIntegerDigits: 2, useGrouping:false}) +"</option>";
335
+		                                      } else {
336
+			                                  dlMnStartOptions += "<option value='"+ mn.toLocaleString('en-US', {minimumIntegerDigits: 2, useGrouping:false}) +"' selected>"+ mn.toLocaleString('en-US', {minimumIntegerDigits: 2, useGrouping:false}) +"</option>";
337
+		                                      }
338
+			                         }
339
+
340
+		                                 var dlHrEndOptions = "";
341
+			                         for (var hr = 0; hr < 24; hr++) {
342
+		                                      if (dailyEndArr[0] != hr.toLocaleString('en-US', {minimumIntegerDigits: 2, useGrouping:false})) {
343
+			                                  dlHrEndOptions += "<option value='"+ hr.toLocaleString('en-US', {minimumIntegerDigits: 2, useGrouping:false}) +"'>"+ hr.toLocaleString('en-US', {minimumIntegerDigits: 2, useGrouping:false}) +"</option>";
344
+		                                      } else {
345
+			                                  dlHrEndOptions += "<option value='"+ hr.toLocaleString('en-US', {minimumIntegerDigits: 2, useGrouping:false}) +"' selected>"+ hr.toLocaleString('en-US', {minimumIntegerDigits: 2, useGrouping:false}) +"</option>";
346
+		                                      }
347
+			                         }
348
+
349
+		                                 var dlMnEndOptions = "";
350
+			                         for (var mn = 0; mn < 60; mn++) {
351
+		                                      if (dailyEndArr[1] != mn.toLocaleString('en-US', {minimumIntegerDigits: 2, useGrouping:false})) {
352
+			                                  dlMnEndOptions += "<option value='"+ mn.toLocaleString('en-US', {minimumIntegerDigits: 2, useGrouping:false}) +"'>"+ mn.toLocaleString('en-US', {minimumIntegerDigits: 2, useGrouping:false}) +"</option>";
353
+		                                      } else {
354
+			                                  dlMnEndOptions += "<option value='"+ mn.toLocaleString('en-US', {minimumIntegerDigits: 2, useGrouping:false}) +"' selected>"+ mn.toLocaleString('en-US', {minimumIntegerDigits: 2, useGrouping:false}) +"</option>";
355
+		                                      }
356
+			                         }
357
+
358
+                                                 var modeContent = "<div class='daysOfWeek'>Days of the week:<div class='tooltipautoreply'><div id='infoautoreply'>i</div><div class='autorpltooltip'>Enter the order number of the days of the week in which the auto-reply will be sent. For example, to send the auto-reply every day from Monday to Friday outside the time interval specified below, enter 1,2,3,4,5 To send the auto-reply only Monday, Thursday and Friday enter 1,4,5 To send the auto-reply every day of the week enter 1,2,3,4,5,6,7 As an exception, if you want the auto-reply to be sent during an entire day, irrespective of the specified interval, add (full) after the number of that day. For example, if you want the auto-reply to be sent from Monday to Friday outside the interval specified below, and also during the entire days of Saturday and Sunday, enter 1,2,3,4,5,6(full),7(full)</div></div></div><input type='text' id='weekdays-"+ k +"' class='daysInWeek' value='"+ autorpldata[k].days_of_week +"'><div class='chooseTInterval'>Send auto-reply <span style='color:#ad0202'>outside</span> this interval:<div class='tooltipautoreplyst'><div id='infoautoreplyst'>i</div><div class='autorpltooltipst'>These fields specify the time of the server. If the server is located in a time zone that is different from that of the owner/company, the time interval entered here should be adjusted accordingly.</div></div></div><div class='selectArplHours'><select id='dmstarthr-"+ k +"' class='selectHrMin'>"+ dlHrStartOptions +"</select><select id='dmstartmn-"+ k +"' class='selectHrMin'>"+ dlMnStartOptions +"</select><span style='font-weight: 600'> — </span><select id='dmendhr-"+ k +"' class='selectHrMin'>"+ dlHrEndOptions +"</select><select id='dmendmn-"+ k +"' class='selectHrMin'>"+ dlMnEndOptions +"</select></div>";
359
+
360
+                                             } else {
361
+
362
+                                                 var vctnStart = autorpldata[k].vacation_start.split(" ")[0];
363
+                                                 var vctnEnd = autorpldata[k].vacation_end.split(" ")[0];
364
+
365
+                                                 var slctdMode = "<option value=''>Select mode</option><option value='daily'>Daily mode</option><option value='vacation' selected>Vacation mode</option>";
366
+                                                 var modeContent = "<div class='chooseDateIntvl'>Send auto-reply <span style='color:#ad0202'>inside</span> this interval:</div><div class='arplstrtendDates'><div class='stdtTitle'>Start Date</div><input type='text' id='startDT-"+ k +"' class='startDate' placeholder='Pick a date' value='"+ vctnStart +"'><div class='enddtTitle'>End Date</div><input type='text' id='endDT-"+ k +"' class='endDate' placeholder='Pick a date' value='"+ vctnEnd +"'></div>"
367
+                                             }
368
+
369
+				             $("#autoReplyTbl").append("<tr><td><input type='text' class='arplAuthor' value='"+ autorpldata[k].saved_by_dsplname +"' disabled></td><td><select id='arpphn-"+ k +"' class='arplPhoneNmbr' style='pointer-events:none'><option selected>"+ autorpldata[k].phone_number +"</option></select></td><td><div id='arplmode-"+ k +"' class='arplMode'><select id='modeselect-"+ k +"' class='selectArplMode'>"+ slctdMode +"</select><div id='modecont-"+ k +"' class='modeContent'>"+ modeContent +"</div></div></td><td><textarea id='arpltxt-"+ k +"' class='arplText' rows='20' cols='40' placeholder='Enter the auto-reply message here.'>"+ autorpldata[k].message_text +"</textarea></td><td><img id='rmRow-"+ k +"' class='removeRow' src='/apps/sms_relentless/img/closewnd.svg' title='Remove this row from the database' style='cursor:pointer;margin:9px 8px 0px 18px;'></td><td><input type='submit' id='arplsave-"+ k +"' class='saveAutoReply' value='Edit' title='Edit Row' /></td></tr>");
370
+				        }
371
+				        $("#autoReplyTbl").append("<div><img id='addArplRow' src='/apps/sms_relentless/img/add.svg' title='Add Row'></div>");
372
+				    }
373
+
374
+
375
+				    // Create a list with all the available phone numbers
376
+                                    var numbersListItems = "<option value='' selected>Select phone number</option>";
377
+
378
+				    $.each(availPhoneNmbrs, function(key, indsmsnmb) {
379
+				           numbersListItems += "<option value='"+ indsmsnmb +"'>"+ indsmsnmb +"</option>";
380
+				    });
381
+
382
+                                    if (arplNmb == 0) {
383
+				        $("#arpphn-"+ arplNmb).append(numbersListItems);
384
+                                    }
385
+
386
+                                    // Initialize the date picker
387
+			            $('[id^="endDT-"]').datepicker({ dateFormat: "yy-mm-dd" });
388
+			            $('[id^="startDT-"]').datepicker({ dateFormat: "yy-mm-dd" });
389
+
390
+
391
+                                    // Select the auto-reply mode
392
+                                    function selectMode() {
393
+
394
+		                            $('[id^="modeselect-"]').change(function() {
395
+
396
+		                               var crtnmbr = $(this).attr("id").replace("modeselect-", "");
397
+
398
+		                               var dailyHrStart = "";
399
+		                               for (var h = 0; h < 24; h++) {
400
+		                                    dailyHrStart += "<option value='"+ h.toLocaleString('en-US', {minimumIntegerDigits: 2, useGrouping:false}) +"'>"+ h.toLocaleString('en-US', {minimumIntegerDigits: 2, useGrouping:false}) +"</option>";
401
+		                               }
402
+
403
+		                               var dailyMnStart = "";
404
+		                               for (var m = 0; m < 60; m++) {
405
+		                                    dailyMnStart += "<option value='"+ m.toLocaleString('en-US', {minimumIntegerDigits: 2, useGrouping:false}) +"'>"+ m.toLocaleString('en-US', {minimumIntegerDigits: 2, useGrouping:false}) +"</option>";
406
+		                               }
407
+
408
+		                               var dailyHrEnd = dailyHrStart;
409
+		                               var dailyMnEnd = dailyMnStart;
410
+
411
+		                               if ($(this).val() == 'daily') {
412
+		                                   $("#modecont-"+ crtnmbr).empty();
413
+		                                   $("#modecont-"+ crtnmbr).append("<div class='daysOfWeek'>Days of the week:<div class='tooltipautoreply'><div id='infoautoreply'>i</div><div class='autorpltooltip'>Enter the order number of the days of the week in which the auto-reply will be sent. For example, to send the auto-reply every day from Monday to Friday outside the time interval specified below, enter 1,2,3,4,5 To send the auto-reply only Monday, Thursday and Friday enter 1,4,5 To send the auto-reply every day of the week enter 1,2,3,4,5,6,7 As an exception, if you want the auto-reply to be sent during an entire day, irrespective of the specified interval, add (full) after the number of that day. For example, if you want the auto-reply to be sent from Monday to Friday outside the interval specified below, and also during the entire days of Saturday and Sunday, enter 1,2,3,4,5,6(full),7(full)</div></div></div><input type='text' id='weekdays-"+ crtnmbr +"' class='daysInWeek'><div class='chooseTInterval'>Send auto-reply <span style='color:#ad0202'>outside</span> this interval:<div class='tooltipautoreplyst'><div id='infoautoreplyst'>i</div><div class='autorpltooltipst'>These fields specify the time of the server. If the server is located in a time zone that is different from that of the owner/company, the time interval entered here should be adjusted accordingly.</div></div></div><div class='selectArplHours'><select id='dmstarthr-"+ crtnmbr +"' class='selectHrMin'>"+ dailyHrStart +"</select><select id='dmstartmn-"+ crtnmbr +"' class='selectHrMin'>"+ dailyMnStart +"</select><span style='font-weight: 600'> — </span><select id='dmendhr-"+ crtnmbr +"' class='selectHrMin'>"+ dailyHrEnd +"</select><select id='dmendmn-"+ crtnmbr +"' class='selectHrMin'>"+ dailyMnEnd +"</select></div>");
414
+		                               } else if ($(this).val() == 'vacation') {
415
+		                                   $("#modecont-"+ crtnmbr).empty();
416
+		                                   $("#modecont-"+ crtnmbr).append("<div class='chooseDateIntvl'>Send auto-reply <span style='color:#ad0202'>inside</span> this interval:</div><div class='arplstrtendDates'><div class='stdtTitle'>Start Date</div><input type='text' id='startDT-"+ crtnmbr +"' class='startDate' placeholder='Pick a date'><div class='enddtTitle'>End Date</div><input type='text' id='endDT-"+ crtnmbr +"' class='endDate' placeholder='Pick a date' /></div>");
417
+		                               }
418
+
419
+					       $("#endDT-"+ crtnmbr +"").datepicker({ dateFormat: "yy-mm-dd" });
420
+					       $("#startDT-"+ crtnmbr +"").datepicker({ dateFormat: "yy-mm-dd" });
421
+		                          });
422
+                                  }
423
+                                  selectMode();
424
+
425
+				  // Save the data
426
+				  function saveArplRow() {
427
+
428
+				     $('[id^="arplsave-"]').unbind("click");
429
+				     $('[id^="arplsave-"]').click(function(event) {
430
+
431
+				        event.preventDefault();
432
+				        var crntrwnmbr = $(this).attr("id").replace("arplsave-", "");
433
+
434
+				        if ($(this).attr("value") == "Save") {
435
+
436
+				            var phoneNmbr = $("#arpphn-"+ crntrwnmbr).val();
437
+				            var arplText = $("#arpltxt-"+ crntrwnmbr).val();
438
+				            var slctdMode = $("#modeselect-"+ crntrwnmbr).val();
439
+
440
+				            var slctddmDays = "";
441
+				            var slctdHrStart = "";
442
+				            var slctdMnStart = "";
443
+				            var slctdHrEnd = "";
444
+				            var slctdMnEnd = "";
445
+
446
+				            var vcStartDate = null;
447
+				            var vcEndDate = null;
448
+
449
+				            if (slctdMode == 'daily') {
450
+
451
+				                slctddmDays = $("#weekdays-"+ crntrwnmbr).val().trim();
452
+				                slctdHrStart = $("#dmstarthr-"+ crntrwnmbr).val().trim();
453
+				                slctdMnStart = $("#dmstartmn-"+ crntrwnmbr).val().trim();
454
+				                slctdHrEnd = $("#dmendhr-"+ crntrwnmbr).val().trim();
455
+				                slctdMnEnd = $("#dmendmn-"+ crntrwnmbr).val().trim();
456
+
457
+                                                if (slctdHrStart != '' && slctdMnStart != '') {
458
+                                                    var hrmnStartComp = slctdHrStart +":"+ slctdMnStart;
459
+                                                } else { var hrmnStartComp = ""; }
460
+
461
+                                                if (slctdHrEnd != '' && slctdMnEnd != '') {
462
+                                                    var hrmnEndComp = slctdHrEnd +":"+ slctdMnEnd;
463
+                                                } else { var hrmnEndComp = ""; }
464
+
465
+                                                if (!(/^[1-7ful\,\(\)]+$/.test(slctddmDays))) {
466
+				                    showAlert("The 'Days of the week' field can contain only digits from 1 to 7, the lowercase letters f, u and l, round brackets ()() and commas (,).");
467
+				                    return;
468
+                                                }
469
+
470
+                                                if (!(/^[0-9]+$/.test(slctdHrStart + slctdMnStart + slctdHrEnd + slctdMnEnd))) {
471
+				                    showAlert("The starting and ending values of the time interval for the 'Daily mode' can contain only digits from 0 to 9.");
472
+				                    return;
473
+                                                }
474
+
475
+                                                if (slctddmDays.trim() == '' || (slctdHrStart == slctdHrEnd && slctdMnStart == slctdMnEnd)) {
476
+				                    showAlert("For the 'Daily mode', you have to enter the order number of the days of the week for which you want the auto-reply to be sent, and you have to set a starting time that is different from the ending time!");
477
+				                    return;
478
+                                                }
479
+
480
+				            } else if (slctdMode == 'vacation') {
481
+		
482
+                                                if ($("#startDT-"+ crntrwnmbr).val().trim() == '' || $("#endDT-"+ crntrwnmbr).val().trim() == '') {
483
+
484
+				                    showAlert("For the 'Vacation mode', you have to enter both a start date and an end date.");
485
+				                    return;
486
+
487
+                                                } else {
488
+
489
+                                                    if (!(/^[0-9\-]+$/.test($("#startDT-"+ crntrwnmbr).val().trim() + $("#endDT-"+ crntrwnmbr).val().trim()))) {
490
+				                        showAlert("The start date and end date values for the 'Vacation mode' can contain only digits from 0 to 9 and hyphens (-).");
491
+				                        return;
492
+                                                    }
493
+
494
+		                                    vcStartDate = $("#startDT-"+ crntrwnmbr).val().trim() +" 00:00:00";
495
+				                    vcEndDate = $("#endDT-"+ crntrwnmbr).val().trim() +" 23:59:59";
496
+				                    var strtDateCmp = new Date(vcStartDate).toJSON().slice(0, 10) +" 00:00:00";
497
+				                    var endDateCmp = new Date(vcEndDate).toJSON().slice(0, 10) +" 23:59:59";
498
+				                    var crntDate = new Date().toJSON().slice(0, 10) +" 23:59:59";
499
+
500
+                                                    if (vcStartDate.trim() == "" || vcEndDate.trim() == "" || (strtDateCmp >= endDateCmp || ((strtDateCmp < crntDate) && (endDateCmp < crntDate)))) {
501
+				                        showAlert("For 'Vacation mode', you have to enter both a start date and an end date, the start date must be before the end date and at least the ending of the time interval must be in the future.");
502
+				                        return;
503
+                                                    }
504
+                                                }
505
+				            }
506
+
507
+
508
+				            if (phoneNmbr != '') {
509
+
510
+				              if (arplText.trim() != '') {
511
+
512
+				                if (slctdMode != '') {
513
+
514
+				                    var saveArplUrl = OC.generateUrl('/apps/sms_relentless/user/updateautoreplies');
515
+				                    var arpldata = {
516
+				                         userId: userid,
517
+				                         savedByDsplname: cusrDisplayName,
518
+				                         phoneNumber: phoneNmbr,
519
+				                         daysOfWeek: slctddmDays,
520
+				                         dailyStart: hrmnStartComp,
521
+				                         dailyEnd: hrmnEndComp,
522
+				                         vacationStart: vcStartDate,
523
+				                         vacationEnd: vcEndDate,
524
+				                         messageText: arplText
525
+				                    };
526
+
527
+					            $.ajax({
528
+					              method: 'PUT',
529
+					              url: saveArplUrl + '/' + userid,
530
+					              contentType: 'application/json',
531
+					              data: JSON.stringify(arpldata),
532
+				                      success: function(messagereceived) {
533
+
534
+				                                   if (messagereceived == 'success') {
535
+				                                       showAlert('The auto-reply has been successfully saved to the database!');
536
+				                                   } else if (messagereceived == 'failure') {
537
+				                                       showAlert('Error while trying to save the auto-reply!');
538
+				                                   } else if (messagereceived == 'not allowed') {
539
+                                                                       showAlert('You cannot change an auto-reply that was saved by a different user.');
540
+                                                                   }
541
+				                      },
542
+					              error: function() {
543
+						                   showAlert('Error while attempting to save the auto-reply! You can check the Nextcloud log to find more details about this issue.');
544
+					              }
545
+					            });
546
+
547
+
548
+                                                } else { showAlert("Please select the auto-reply mode."); return; }
549
+
550
+                                              } else { showAlert("Please enter the text of the auto-reply."); return; }
551
+
552
+                                            } else { showAlert("Please select a phone number if at least one number is available in the 'Phone Number' drop-down list. Otherwise, you should contact the administrator."); return; }
553
+
554
+                                            $(this).attr("value", "Edit");
555
+
556
+                                        } else {
557
+                                            $("#arplsave-"+ crntrwnmbr).attr("value", "Save");
558
+                                        }
559
+
560
+                                     });
561
+
562
+				  }
563
+                                  saveArplRow();
564
+
565
+
566
+				  // Remove a row
567
+				  function removeArplRow() {
568
+				       $('[id^="rmRow-"]').click(function() {
569
+
570
+					  var slctRowRm = $(this).attr("id").replace("rmRow-", "");
571
+					  var crntPhnNmbr = $("#arpphn-"+ slctRowRm).val();
572
+
573
+				          confirmAlert("Do you really want to remove this row from the database ?");
574
+
575
+				          $("#confirmCancel").click(function() { $("#alertMsgOverlay").remove(); $("#alertConfMessage").remove(); });
576
+
577
+				          $("#confirmOk").click(function() {
578
+
579
+				              $("#alertMsgOverlay").remove();
580
+				              $("#alertConfMessage").remove();
581
+
582
+					      var rmvArplUrl = OC.generateUrl('/apps/sms_relentless/user/removeautoreplies');
583
+					      $.ajax({
584
+						   url: rmvArplUrl + '/' + userid,
585
+						   method: "POST",
586
+						   dataType: "text",
587
+						   data: { phoneNumber: crntPhnNmbr },
588
+						   success: function(delresult) {
589
+
590
+						                     if (delresult.indexOf("success") > -1) {
591
+						                         showAlert("The auto-reply has been removed successfully!");
592
+						                         $("#arpphn-"+ slctRowRm).closest("tr").remove();
593
+						                     } else if (delresult.indexOf("failure") > -1) {
594
+						                         showAlert("Error while trying to remove auto-reply data!");
595
+						                     } else if (delresult.indexOf("not allowed") > -1) {
596
+                                                                         showAlert("You cannot remove the auto-reply saved by another user.");
597
+                                                                     }
598
+						   },
599
+						   error: function() { showAlert("Error while attempting to remove auto-reply data! You can check the Nextcloud log to find more details about this issue."); }
600
+					       });
601
+					  });
602
+				       });
603
+				  }
604
+				  removeArplRow();
605
+
606
+                                  // Add a new row
607
+                                  $("#addArplRow").click(function() {
608
+
609
+                                     if ($("#autoReplyTbl").find("tr:last-child").find(".arplPhoneNmbr").length > 0) {
610
+                                         var lastarpl = $("#autoReplyTbl").find("tr:last-child").find(".arplPhoneNmbr").attr("id").replace("arpphn-", "");
611
+                                         var indArplAdd = parseInt(lastarpl + 1);
612
+                                     } else { var indArplAdd = 0; }
613
+			             $("#autoReplyTbl").append("<tr><td><input type='text' class='arplAuthor' value='"+ cusrDisplayName +"' disabled></td><td><select id='arpphn-"+ indArplAdd +"' class='arplPhoneNmbr'>"+ numbersListItems +"</select></td><td><div id='arplmode-"+ indArplAdd +"' class='arplMode'><select id='modeselect-"+ indArplAdd +"' class='selectArplMode'><option value='' selected>Select mode</option><option value='daily'>Daily mode</option><option value='vacation'>Vacation mode</option></select><div id='modecont-"+ indArplAdd +"' class='modeContent'></div></div></td><td><textarea id='arpltxt-"+ indArplAdd +"' class='arplText' rows='20' cols='40' placeholder='Enter the auto-reply message here.'></textarea></td><td><img id='rmRow-"+ indArplAdd +"' class='removeRow' src='/apps/sms_relentless/img/closewnd.svg' title='Remove this row from the database' style='cursor:pointer;margin:9px 8px 0px 18px;'></td><td><input type='submit' id='arplsave-"+ indArplAdd +"' class='saveAutoReply' value='Save' title='Save Row' /></td></tr>");
614
+
615
+                                     selectMode();
616
+                                     saveArplRow();
617
+                                     removeArplRow();
618
+
619
+			             // Check if there is an auto-reply set for the same phone number
620
+				     $("#arpphn-"+ indArplAdd).change(function() {
621
+					 var selectedPhNb = $("#arpphn-"+ indArplAdd).val();
622
+					 var allArplPhNmbrs = $("#autoReplyTbl").find("tr").find(".arplPhoneNmbr");
623
+					 var phNbChck = 0;
624
+					 allArplPhNmbrs.each(function() {
625
+					    var slctphnb = ($(this).val())? $(this).val() : $(this).text();
626
+					    if (selectedPhNb == slctphnb) { phNbChck++; }
627
+					 });
628
+
629
+					 if (phNbChck == 2) {
630
+					     showAlert("There is already an auto-reply set up for this phone number. Please edit its own row, or choose a different phone number.");
631
+					     $(this).val('');
632
+					     return;
633
+					 }
634
+				     });
635
+                                  });
636
+
637
+		  },
638
+		  error: function() {
639
+                                    $("#autoRplPhoneNb").removeClass('icon-loading'); 
640
+                                    showAlert("Error while attempting to get the auto-reply settings! You can check the Nextcloud log to find more details about this issue.");
641
+                  }
642
+         });
643
+
644
+     },
645
+     error: function() {
646
+                  showAlert('Error while getting the settings! You can check the Nextcloud log to find more details about this issue.');
647
+     }
648
+  });
649
+
650
+
651
+
652
+  // Save personal settings for non-admin users
653
+  $("#save_sms_settings").on("click", function(event) {
654
+
655
+     if (isadm == 'reguser') {
656
+
657
+	    event.preventDefault();
658
+	    var baseUrlsave = OC.generateUrl('/apps/sms_relentless/user/updatesettings');
659
+
660
+	    var messagesperpageinit = $("#messagesperpage").val();
661
+	    var messagesperpagesec = messagesperpageinit.replace(/[^0-9]/g, '');
662
+
663
+	    if (messagesperpagesec != '') {
664
+		var messagesperpageproc = messagesperpagesec;
665
+	    } else {
666
+		var messagesperpageproc = 100;
667
+	    }
668
+
669
+	    var getnotify = 0;
670
+
671
+	    if ($("#get_notify").is(':checked')) {
672
+		getnotify = 1;
673
+	    }
674
+
675
+	    var emailaddressinit = $("#notification_email").val();
676
+
677
+	    function validate_email($email) {
678
+		var email_reg = /^([\w-\.]+@([\w-]+\.)+[\w-]{2,4})?$/;
679
+		return email_reg.test($email);
680
+	    }
681
+
682
+	    if (validate_email(emailaddressinit)) {
683
+		 var notifyemail = emailaddressinit;
684
+	    } else {
685
+		 var notifyemail = '';
686
+	    }
687
+
688
+	    var includesmsinemail = 0;
689
+	    if ($("#includesmsinemail").is(':checked')) {
690
+		includesmsinemail = 1;
691
+                if ($("#notification_email").val().trim() == '') {
692
+                    showAlert("Please enter an email address in the field: 'I want to receive a notification to the email address from below ...', or uncheck the checkbox: 'Include the SMS/MMS message in the email notification itself'.");
693
+                    return;
694
+                }
695
+	    }
696
+
697
+	    var showdisplaynm = 0;
698
+	    if ($("#showdisplaynames").is(':checked')) {
699
+		showdisplaynm = 1;
700
+	    }
701
+
702
+	    var adddisplaynm = 0;
703
+	    if ($("#adddisplaynames").is(':checked')) {
704
+		adddisplaynm = 1;
705
+	    }
706
+
707
+	    var datatosave = {
708
+			      userId: userid,
709
+		              telapiUrlRec: $("#telapi_url_rec").val(),
710
+		              telapiUrl: $("#telapi_url").val(),
711
+		              nexapiUrlRec: $("#nexapi_url_rec").val(),
712
+		              nexapiUrl: $("#nexapi_url").val(),
713
+		              twilapiUrlRec: $("#twilapi_url_rec").val(),
714
+		              twilapiUrl: $("#twilapi_url").val(),
715
+		              flowapiUrlRec: $("#flowapi_url_rec").val(),
716
+		              flowapiUrl: $("#flowapi_url").val(),
717
+			      messagesperpage: messagesperpageproc,
718
+			      getNotify: getnotify,
719
+			      notificationEmail: notifyemail,
720
+			      getsmsinemail: includesmsinemail,
721
+			      showDisplayNames: showdisplaynm,
722
+                              addDisplayNames: adddisplaynm
723
+	    };
724
+
725
+
726
+	    $.ajax({
727
+	       method: 'PUT',
728
+	       url: baseUrlsave + '/' + userid,
729
+	       contentType: 'application/json',
730
+	       data: JSON.stringify(datatosave),
731
+	       success: function() {
732
+                               OC.msg.startAction('#smsr_save_msg', t('sms_relentless', 'Saved'));
733
+	       },
734
+	       error: function() {
735
+		    showAlert('Error while attempting to save the settings! You can check the Nextcloud log to find more details about this issue.');
736
+	       }
737
+	    });
738
+
739
+
740
+     } else if (isadm == 'admin') {
741
+
742
+	    // Save personal settings for admins
743
+	    event.preventDefault();
744
+	    var baseUrlsaveadm = OC.generateUrl('/apps/sms_relentless/user/updatepersadmnsettings');
745
+
746
+	    var messagesperpageinit = $("#messagesperpage").val();
747
+	    var messagesperpagesec = messagesperpageinit.replace(/[^0-9]/g, '');
748
+
749
+	    if (messagesperpagesec != '') {
750
+		var messagesperpageproc = messagesperpagesec;
751
+	    } else {
752
+		var messagesperpageproc = 100;
753
+	    }
754
+
755
+	    var getnotify = 0;
756
+
757
+	    if ($("#get_notify").is(':checked')) {
758
+		getnotify = 1;
759
+	    }
760
+
761
+	    var emailaddressinit = $("#notification_email").val();
762
+
763
+	    function validate_email($email) {
764
+		var email_reg = /^([\w-\.]+@([\w-]+\.)+[\w-]{2,4})?$/;
765
+		return email_reg.test($email);
766
+	    }
767
+
768
+	    if (validate_email(emailaddressinit)) {
769
+		 var notifyemail = emailaddressinit;
770
+	    } else {
771
+		 var notifyemail = '';
772
+	    }
773
+
774
+	    var includesmsinemail = 0;
775
+	    if ($("#includesmsinemail").is(':checked')) {
776
+		includesmsinemail = 1;
777
+                if ($("#notification_email").val().trim() == '') {
778
+                    showAlert("Please enter an email address in the field: 'I want to receive a notification to the email address from below ...', or uncheck the checkbox: 'Include the SMS/MMS message in the email notification itself'.");
779
+                    return;
780
+                }
781
+	    }
782
+
783
+	    var showdisplaynm = 0;
784
+	    if ($("#showdisplaynames").is(':checked')) {
785
+		showdisplaynm = 1;
786
+	    }
787
+
788
+	    var adddisplaynm = 0;
789
+	    if ($("#adddisplaynames").is(':checked')) {
790
+		adddisplaynm = 1;
791
+	    }
792
+
793
+	    var datatosave = {
794
+			      userId: userid,
795
+			      messagesperpage: messagesperpageproc,
796
+			      getNotify: getnotify,
797
+			      notificationEmail: notifyemail,
798
+			      getsmsinemail: includesmsinemail,
799
+			      showDisplayNames: showdisplaynm,
800
+                              addDisplayNames: adddisplaynm
801
+	    };
802
+
803
+
804
+	    $.ajax({
805
+	       method: 'PUT',
806
+	       url: baseUrlsaveadm + '/' + userid,
807
+	       contentType: 'application/json',
808
+	       data: JSON.stringify(datatosave),
809
+	       success: function() {
810
+                               OC.msg.startAction('#smsr_save_msg', t('sms_relentless', 'Saved'));
811
+	       },
812
+	       error: function() {
813
+		    showAlert('Error while attempting to save the settings! You can check the Nextcloud log to find more details about this issue.');
814
+	       }
815
+	    });
816
+
817
+     }
818
+  });
819
+
820
+  function showAlert(alertText) {
821
+
822
+     let alertwnd = "<div id='alertMessage'>";
823
+     alertwnd += "<a id='closeAlertWnd' title='Close this window'></a>";
824
+     alertwnd += "<div id='alertTextWrap'>"+ alertText +"</div>";
825
+     alertwnd += "<input type='submit' id='alertOk' value='OK'>";
826
+     alertwnd += "</div>";
827
+
828
+     $("#content").append("<div id='alertMsgOverlay'></div>");
829
+     $("#content").append(alertwnd);
830
+
831
+     let topDist = parseInt((window.innerHeight / 2).toFixed(2) - 152) +"px";
832
+     let leftDist = parseInt((window.innerWidth / 2).toFixed(2) - 150) +"px";
833
+     $("#alertMessage").css({ "top" : topDist, "left" : leftDist });
834
+
835
+     $("#closeAlertWnd").click(function() { $("#alertMsgOverlay").remove(); $("#alertMessage").remove(); });
836
+     $("#alertMsgOverlay").click(function() { $("#alertMsgOverlay").remove(); $("#alertMessage").remove(); });
837
+     $("#alertOk").click(function() { $("#alertMsgOverlay").remove(); $("#alertMessage").remove(); });
838
+  }
839
+
840
+  function confirmAlert(alertText) {
841
+
842
+     $("#alertMsgOverlay").remove();
843
+     $("#alertConfMessage").remove();
844
+
845
+     let alertwndcf = "<div id='alertConfMessage'>";
846
+     alertwndcf += "<a id='closeAlertWndcf' title='Close this window'></a>";
847
+     alertwndcf += "<div id='alertTextWrap'>"+ alertText +"</div>";
848
+     alertwndcf += "<div id='cancelOkWrap'><input type='submit' id='confirmCancel' value='Cancel'>";
849
+     alertwndcf += "<input type='submit' id='confirmOk' value='OK'></div>";
850
+     alertwndcf += "</div>";
851
+
852
+     $("#content").append("<div id='alertMsgOverlay'></div>");
853
+     $("#content").append(alertwndcf);
854
+
855
+     let topDist = parseInt((window.innerHeight / 2).toFixed(2) - 152) +"px";
856
+     let leftDist = parseInt((window.innerWidth / 2).toFixed(2) - 150) +"px";
857
+     $("#alertConfMessage").css({ "top" : topDist, "left" : leftDist });
858
+
859
+     $("#closeAlertWndcf").click(function() { $("#alertMsgOverlay").remove(); $("#alertConfMessage").remove(); });
860
+     $("#alertMsgOverlay").click(function() { $("#alertMsgOverlay").remove(); $("#alertConfMessage").remove(); });
861
+  }
862
+
863
+});
Browse code

removed CHANGELOG.txt appinfo/info.xml appinfo/signature.json appinfo/routes.php css/style.css js/adminsettings.js js/deleteoldsms.js js/sendsms.js js/settings.js js/showsmstables.js lib/Controller/AuthorApiController.php lib/Controller/SmsrelentlessController.php lib/Service/SmsrelentlessService.php providers/Telnyx/lib/ApiResource.php

DoubleBastionAdmin authored on 15/07/2023 21:56:42
Showing 1 changed files
1 1
deleted file mode 100644
... ...
@@ -1,860 +0,0 @@
1
-/**
2
- * @copyright 2021 Double Bastion LLC <www.doublebastion.com>
3
- *
4
- * @author Double Bastion LLC
5
- *
6
- * @license GNU AGPL version 3 or any later version
7
- *
8
- * This program is free software; you can redistribute it and/or
9
- * modify it under the terms of the GNU AFFERO GENERAL PUBLIC LICENSE
10
- * License as published by the Free Software Foundation; either
11
- * version 3 of the License, or any later version.
12
- *
13
- * This program is distributed in the hope that it will be useful,
14
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
15
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
16
- * GNU AFFERO GENERAL PUBLIC LICENSE for more details.
17
- *
18
- * You should have received a copy of the GNU Affero General Public
19
- * License along with this program.  If not, see <http://www.gnu.org/licenses/>.
20
- *
21
- */
22
-
23
-$(document).ready(function() {
24
-
25
-  var userid = "<?php p($userId); ?>";
26
-  var isadm = '';
27
-
28
-  // Get personal settings
29
-  var baseUrlget = OC.generateUrl('/apps/sms_relentless/user/getsettings');
30
-
31
-  $.ajax({
32
-     method: 'GET',
33
-     url: baseUrlget + '/' + userid,
34
-     contentType: 'application/json',
35
-     success: function(settingsfromdb) {
36
-
37
-         // Add the webhook URLs section, if the user is not an admin
38
-         if (settingsfromdb.adminornot == 'reguser') {
39
-
40
-             isadm = 'reguser';
41
-
42
-             $("#appTitlePrg").append('<p id="settings-dscr"><h3>Enter your options in the fields from below. As a non-admin user, you can use any of the SMS service providers from \
43
-                  below, on the condition that an admin has shared with you his API keys for that provider:</h3></p><br>');
44
-
45
-             $("#nadmProvSection").append('<div class="providerSettings"><p><label for="telapi_url_rec" class="setlabeltext"><b>Telnyx webhook URL for incoming SMS/MMS</b> (Generate \
46
-                  the URL by pressing the button from below. Don\'t forget to also click the \'Save\' button at the bottom of this page after entering all the options, to save \
47
-                  all the settings to the database.)</label></p> \
48
-                  <input type="button" id="generate_tel_rcpt" class="generateUrl" value="Generate new webhook URL for incoming SMS/MMS" /> \
49
-                  <input type="text" class="smsr_textboxspec" id="telapi_url_rec" name="telapi_url_rec" autocomplete="false" /> \
50
-                  <span id="copyToClipboardtel" class="icon icon-clippy" title="Copy to clipboard"></span><br><br> \
51
-                  \
52
-                  <p><label for="telapi_url" class="setlabeltext"><b>Telnyx webhook URL for delivery receipts</b> (This URL will be included by SMS Relentless in message sending \
53
-                  requests, so that Telnyx will know where to send the delivery receipts. Just generate it by pressing the button from below. Don\'t forget to click the \'Save\' \
54
-                  button at the bottom of this page after entering all the options, to save all the settings to the database.)</label></p> \
55
-                  <input type="button" id="generate_tel_delrcpt" class="generateUrl" value="Generate new webhook URL for delivery receipts" /> \
56
-                  <input type="text" id="telapi_url" name="telapi_url" autocomplete="false" /></div><br><br> \
57
-                  \
58
-                  <div class="providerSettings"><p><label for="nexapi_url_rec" class="setlabeltext"><b>Plivo webhook URL for incoming SMS/MMS</b> (Generate the URL by pressing \
59
-                  the button from below. Don\'t forget to also click the \'Save\' button at the bottom of this page after entering all the options, to save all the settings \
60
-                  to the database.)</label></p> \
61
-                  <input type="button" id="generate_nex_rcpt" class="generateUrl" value="Generate new webhook URL for incoming SMS/MMS" /> \
62
-                  <input type="text" class="smsr_textboxspec" id="nexapi_url_rec" name="nexapi_url_rec" autocomplete="false" /> \
63
-                  <span id="copyToClipboardnex" class="icon icon-clippy" title="Copy to clipboard"></span><br><br> \
64
-                  \
65
-                  <p><label for="nexapi_url" class="setlabeltext"><b>Plivo webhook URL for delivery receipts</b> (This URL will be included by SMS Relentless in message sending \
66
-                  requests, so that Plivo will know where to send the delivery receipts. Just generate it by pressing the button from below. Don\'t forget to click the \'Save\' \
67
-                  button at the bottom of this page after entering all the options, to save all the settings to the database.)</label></p> \
68
-                  <input type="button" id="generate_nex_delrcpt" class="generateUrl" value="Generate new webhook URL for delivery receipts" /> \
69
-                  <input type="text" id="nexapi_url" name="nexapi_url" autocomplete="false" /></div><br><br> \
70
-                  \
71
-                  <div class="providerSettings"><p><label for="twilapi_url_rec" class="setlabeltext"><b>Twilio webhook URL for incoming SMS/MMS</b> (Generate the URL by pressing \
72
-                  the button from below. Don\'t forget to also click the \'Save\' button at the bottom of this page after entering all the options, to save all the settings to \
73
-                  the database.)</label></p> \
74
-                  <input type="button" id="generate_twil_rcpt" class="generateUrl" value="Generate new webhook URL for incoming SMS/MMS" /> \
75
-                  <input type="text" class="smsr_textboxspec" id="twilapi_url_rec" name="twilapi_url_rec" autocomplete="false" /> \
76
-                  <span id="copyToClipboardtwil" class="icon icon-clippy" title="Copy to clipboard"></span><br><br> \
77
-                  \
78
-                  <p><label for="twilapi_url" class="setlabeltext"><b>Twilio webhook URL for delivery receipts</b> (This URL will be included by SMS Relentless in message sending \
79
-                  requests, so that Twilio will know where to send the delivery receipts. Just generate it by pressing the button from below. Don\'t forget to click the \'Save\' \
80
-                  button at the bottom of this page after entering all the options, to save all the settings to the database.)</label></p> \
81
-                  <input type="button" id="generate_twil_delrcpt" class="generateUrl" value="Generate new webhook URL for delivery receipts" /> \
82
-                  <input type="text" id="twilapi_url" name="twilapi_url" autocomplete="false" /></div><br><br> \
83
-                  \
84
-                  <div class="providerSettings"><p><label for="flowapi_url_rec" class="setlabeltext"><b>Flowroute webhook URL for incoming SMS/MMS</b> (Generate the URL by pressing \
85
-                  the button from below. Don\'t forget to also click the \'Save\' button at the bottom of this page after entering all the options, to save all the settings to \
86
-                  the database.)</label></p> \
87
-                  <input type="button" id="generate_flow_rcpt" class="generateUrl" value="Generate new webhook URL for incoming SMS/MMS" /> \
88
-                  <input type="text" class="smsr_textboxspec" id="flowapi_url_rec" name="flowapi_url_rec" autocomplete="false" /> \
89
-                  <span id="copyToClipboardflow" class="icon icon-clippy" title="Copy to clipboard"></span><br><br> \
90
-                  \
91
-                  <p><label for="flowapi_url" class="setlabeltext"><b>Flowroute webhook URL for delivery receipts</b> (This URL will be included by SMS Relentless in message sending \
92
-                  requests, so that Flowroute will know where to send the delivery receipts. Just generate it by pressing the button from below. Don\'t forget to click the \'Save\' \
93
-                  button at the bottom of this page after entering all the options, to save all the settings to the database.)</label></p> \
94
-                  <input type="button" id="generate_flow_delrcpt" class="generateUrl" value="Generate new webhook URL for delivery receipts" /> \
95
-                  <input type="text" id="flowapi_url" name="flowapi_url" autocomplete="false" /><br><br> \
96
-                  Flowroute only supports sending/receiving SMS/MMS messages within USA and Canada and it doesn\'t support Alphanumeric Sender IDs.</div><br>');
97
-
98
-
99
-		  $("#telapi_url_rec").val(settingsfromdb.telapi_url_rec);
100
-		  $("#telapi_url").val(settingsfromdb.telapi_url);
101
-		  $("#nexapi_url_rec").val(settingsfromdb.nexapi_url_rec);
102
-		  $("#nexapi_url").val(settingsfromdb.nexapi_url);
103
-		  $("#twilapi_url_rec").val(settingsfromdb.twilapi_url_rec);
104
-		  $("#twilapi_url").val(settingsfromdb.twilapi_url);
105
-		  $("#flowapi_url_rec").val(settingsfromdb.flowapi_url_rec);
106
-		  $("#flowapi_url").val(settingsfromdb.flowapi_url);
107
-		  $("#messagesperpage").val(settingsfromdb.messagesperpage);
108
-
109
-		  if (settingsfromdb.get_notify == 1) {
110
-		      $("#get_notify").attr('checked', true);
111
-		  } else {
112
-		      $("#get_notify").attr('checked', false);
113
-		  }
114
-
115
-		  $("#notification_email").val(settingsfromdb.notification_email);
116
-
117
-		  if (settingsfromdb.getsmsinemail == 1) {
118
-		      $("#includesmsinemail").attr('checked', true);
119
-		  } else {
120
-		      $("#includesmsinemail").attr('checked', false);
121
-		  }
122
-
123
-		  if (settingsfromdb.show_display_names == 1) {
124
-		      $("#showdisplaynames").attr('checked', true);
125
-		  } else {
126
-		      $("#showdisplaynames").attr('checked', false);
127
-		  }
128
-
129
-		  if (settingsfromdb.add_display_names == 1) {
130
-		      $("#adddisplaynames").attr('checked', true);
131
-		  } else {
132
-		      $("#adddisplaynames").attr('checked', false);
133
-		  }
134
-
135
-		  function randomStr(strlength) {
136
-			var fintext = "";
137
-			var keyspace = '0123456789abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ';
138
-			for (var i = 0; i < strlength; i++) {
139
-			     fintext += keyspace.charAt(Math.floor(Math.random() * keyspace.length));
140
-			}
141
-			return fintext;
142
-		  }
143
-
144
-		  $("#generate_tel_rcpt").on("click", function(event) {
145
-
146
-		     var teltokenrec = randomStr(70);
147
-		     var telnyxwhurlrec = window.location.origin + OC.generateUrl('/apps/sms_relentless/api/recsmstel?telrecparam=') + teltokenrec;
148
-
149
-		     $("#telapi_url_rec").val(telnyxwhurlrec);
150
-		  });
151
-
152
-		  $("#copyToClipboardtel").on("click", function(event) {
153
-		     var $tempEl = $("<input>");
154
-		     $("body").append($tempEl);
155
-		     $tempEl.val($("#telapi_url_rec").val()).select();
156
-		     document.execCommand("Copy");
157
-		     $tempEl.remove();
158
-		     showAlert("The link has been copied to your clipboard!");
159
-		  });
160
-
161
-		  $("#generate_tel_delrcpt").on("click", function(event) {
162
-
163
-		     var teltoken = randomStr(70);
164
-		     var telnyxwhurl = window.location.origin + OC.generateUrl('/apps/sms_relentless/api/recdeliverytel?teldrparam=') + teltoken;
165
-
166
-		     $("#telapi_url").val(telnyxwhurl);
167
-		  });
168
-
169
-
170
-		  $("#generate_nex_rcpt").on("click", function(event) {
171
-
172
-		     var plivotokenrec = randomStr(70);
173
-		     var plivowhurlrec = window.location.origin + OC.generateUrl('/apps/sms_relentless/api/recsmsnex?plivorecparam=') + plivotokenrec;
174
-
175
-		     $("#nexapi_url_rec").val(plivowhurlrec);
176
-		  });
177
-
178
-		  $("#copyToClipboardnex").on("click", function(event) {
179
-		     var $tempElpl = $("<input>");
180
-		     $("body").append($tempElpl);
181
-		     $tempElpl.val($("#nexapi_url_rec").val()).select();
182
-		     document.execCommand("Copy");
183
-		     $tempElpl.remove();
184
-		     showAlert("The link has been copied to your clipboard!");
185
-		  });
186
-
187
-		  $("#generate_nex_delrcpt").on("click", function(event) {
188
-
189
-		     var plivotoken = randomStr(70);
190
-		     var plivodrwhurl = window.location.origin + OC.generateUrl('/apps/sms_relentless/api/recdeliverynex?plivodrparam=') + plivotoken;
191
-
192
-		     $("#nexapi_url").val(plivodrwhurl);
193
-		  });
194
-
195
-
196
-		  $("#generate_twil_rcpt").on("click", function(event) {
197
-
198
-		     var twiltokenrec = randomStr(35);
199
-		     var twilwhurlrec = window.location.origin + OC.generateUrl('/apps/sms_relentless/api/recsmstwil?twilrecparam=') + twiltokenrec;
200
-
201
-		     $("#twilapi_url_rec").val(twilwhurlrec);
202
-		  });
203
-
204
-		  $("#copyToClipboardtwil").on("click", function(event) {
205
-		     var $tempElpl = $("<input>");
206
-		     $("body").append($tempElpl);
207
-		     $tempElpl.val($("#twilapi_url_rec").val()).select();
208
-		     document.execCommand("Copy");
209
-		     $tempElpl.remove();
210
-		     showAlert("The link has been copied to your clipboard!");
211
-		  });
212
-
213
-		  $("#generate_twil_delrcpt").on("click", function(event) {
214
-
215
-		     var twiltoken = randomStr(35);
216
-		     var twildrwhurl = window.location.origin + OC.generateUrl('/apps/sms_relentless/api/recdeliverytwil?twildrparam=') + twiltoken;
217
-
218
-		     $("#twilapi_url").val(twildrwhurl);
219
-		  });
220
-
221
-
222
-		  $("#generate_flow_rcpt").on("click", function(event) {
223
-
224
-		     var flowtokenrec = randomStr(70);
225
-		     var flowwhurlrec = window.location.origin + OC.generateUrl('/apps/sms_relentless/api/recsmsflow?flowrecparam=') + flowtokenrec;
226
-
227
-		     $("#flowapi_url_rec").val(flowwhurlrec);
228
-		  });
229
-
230
-		  $("#copyToClipboardflow").on("click", function(event) {
231
-		     var $tempElpl = $("<input>");
232
-		     $("body").append($tempElpl);
233
-		     $tempElpl.val($("#flowapi_url_rec").val()).select();
234
-		     document.execCommand("Copy");
235
-		     $tempElpl.remove();
236
-		     showAlert("The link has been copied to your clipboard!");
237
-		  });
238
-
239
-		  $("#generate_flow_delrcpt").on("click", function(event) {
240
-
241
-		     var flowtoken = randomStr(70);
242
-		     var flowdrwhurl = window.location.origin + OC.generateUrl('/apps/sms_relentless/api/recdeliveryflow?flowdrparam=') + flowtoken;
243
-
244
-		     $("#flowapi_url").val(flowdrwhurl);
245
-		  });
246
-
247
-
248
-         } else if (settingsfromdb.adminornot == 'admin') {
249
-
250
-                  $("#appTitlePrg").append('<p id="settings-dscr"><h3>Enter your options in the fields from below:</h3></p><br>');
251
-                  isadm = 'admin';
252
-
253
-		  $("#messagesperpage").val(settingsfromdb.messagesperpage);
254
-
255
-		  if (settingsfromdb.get_notify == 1) {
256
-		      $("#get_notify").attr('checked', true);
257
-		  } else {
258
-		      $("#get_notify").attr('checked', false);
259
-		  }
260
-
261
-		  $("#notification_email").val(settingsfromdb.notification_email);
262
-
263
-		  if (settingsfromdb.getsmsinemail == 1) {
264
-		      $("#includesmsinemail").attr('checked', true);
265
-		  } else {
266
-		      $("#includesmsinemail").attr('checked', false);
267
-		  }
268
-
269
-		  if (settingsfromdb.show_display_names == 1) {
270
-		      $("#showdisplaynames").attr('checked', true);
271
-		  } else {
272
-		      $("#showdisplaynames").attr('checked', false);
273
-		  }
274
-
275
-		  if (settingsfromdb.add_display_names == 1) {
276
-		      $("#adddisplaynames").attr('checked', true);
277
-		  } else {
278
-		      $("#adddisplaynames").attr('checked', false);
279
-		  }
280
-         }
281
-
282
-
283
-         // Auto-reply settings
284
-
285
-         // Get the available phone numbers from all providers associated with the access keys entered on the Settings page (restrictions are applied to numbers for non-admins)
286
-         $("#autoRplPhoneNb").addClass('icon-loading');
287
-         var getnumbersUrl = OC.generateUrl("/apps/sms_relentless/user/getautoreplyconf");
288
-
289
-	 $.ajax({
290
-		  url: getnumbersUrl + '/' + userid,
291
-		  type: "GET",
292
-                  contentType: 'application/json',
293
-		  success: function(autoreplydata) {
294
-
295
-                                    $("#autoRplPhoneNb").removeClass('icon-loading');
296
-                                    var cusrDisplayName = autoreplydata.userdisplayname;
297
-                                    var availPhoneNmbrs = autoreplydata.phonenumbers;
298
-                                    var autorpldata = autoreplydata.autoreplies;
299
-
300
-				    if (autorpldata.length > 0) { 
301
-				        var arplNmb = autorpldata.length;
302
-				    } else { 
303
-				        var arplNmb = 0; 
304
-				    }
305
-
306
-				    // List the auto-replies for the phone numbers available for the current user
307
-				    if (arplNmb == 0) {
308
-
309
-				        $("#autoReplyTbl").append("<tr><td><input type='text' class='arplAuthor' value='"+ cusrDisplayName +"' disabled></td><td><select id='arpphn-"+ arplNmb +"' class='arplPhoneNmbr'></select></td><td><div id='arplmode-"+ arplNmb +"' class='arplMode'><select id='modeselect-"+ arplNmb +"' class='selectArplMode'><option value='' selected>Select mode</option><option value='daily'>Daily mode</option><option value='vacation'>Vacation mode</option></select><div id='modecont-"+ arplNmb +"' class='modeContent'></div></div></td><td><textarea id='arpltxt-"+ arplNmb +"' class='arplText' rows='20' cols='40' placeholder='Enter the auto-reply message here.'></textarea></td><td><img id='rmRow-"+ arplNmb +"' class='removeRow' src='/apps/sms_relentless/img/closewnd.svg' title='Remove this row from the database' style='cursor:pointer;margin:9px 8px 0px 18px;'></td><td><input type='submit' id='arplsave-"+ arplNmb +"' class='saveAutoReply' value='Save' title='Save Row' /></td></tr>");
310
-				        $("#autoReplyTbl").append("<div><img id='addArplRow' src='/apps/sms_relentless/img/add.svg' title='Add Row'></div>");
311
-
312
-				    } else {
313
-
314
-				        for (k = 0; k < arplNmb; k++) {
315
-
316
-                                             if (autorpldata[k].days_of_week != '') {
317
-
318
-                                                 var slctdMode = "<option value=''>Select mode</option><option value='daily' selected>Daily mode</option><option value='vacation'>Vacation mode</option>";
319
-                                                 var dailyStartArr = autorpldata[k].daily_start.split(":");
320
-                                                 var dailyEndArr = autorpldata[k].daily_end.split(":");
321
-
322
-		                                 var dlHrStartOptions = "";
323
-			                         for (var hr = 0; hr < 24; hr++) {
324
-		                                      if (dailyStartArr[0] != hr.toLocaleString('en-US', {minimumIntegerDigits: 2, useGrouping:false})) {
325
-			                                  dlHrStartOptions += "<option value='"+ hr.toLocaleString('en-US', {minimumIntegerDigits: 2, useGrouping:false}) +"'>"+ hr.toLocaleString('en-US', {minimumIntegerDigits: 2, useGrouping:false}) +"</option>";
326
-		                                      } else {
327
-			                                  dlHrStartOptions += "<option value='"+ hr.toLocaleString('en-US', {minimumIntegerDigits: 2, useGrouping:false}) +"' selected>"+ hr.toLocaleString('en-US', {minimumIntegerDigits: 2, useGrouping:false}) +"</option>";
328
-		                                      }
329
-			                         }
330
-
331
-		                                 var dlMnStartOptions = "";
332
-			                         for (var mn = 0; mn < 60; mn++) {
333
-		                                      if (dailyStartArr[0] != mn.toLocaleString('en-US', {minimumIntegerDigits: 2, useGrouping:false})) {
334
-			                                  dlMnStartOptions += "<option value='"+ mn.toLocaleString('en-US', {minimumIntegerDigits: 2, useGrouping:false}) +"'>"+ mn.toLocaleString('en-US', {minimumIntegerDigits: 2, useGrouping:false}) +"</option>";
335
-		                                      } else {
336
-			                                  dlMnStartOptions += "<option value='"+ mn.toLocaleString('en-US', {minimumIntegerDigits: 2, useGrouping:false}) +"' selected>"+ mn.toLocaleString('en-US', {minimumIntegerDigits: 2, useGrouping:false}) +"</option>";
337
-		                                      }
338
-			                         }
339
-
340
-		                                 var dlHrEndOptions = "";
341
-			                         for (var hr = 0; hr < 24; hr++) {
342
-		                                      if (dailyEndArr[0] != hr.toLocaleString('en-US', {minimumIntegerDigits: 2, useGrouping:false})) {
343
-			                                  dlHrEndOptions += "<option value='"+ hr.toLocaleString('en-US', {minimumIntegerDigits: 2, useGrouping:false}) +"'>"+ hr.toLocaleString('en-US', {minimumIntegerDigits: 2, useGrouping:false}) +"</option>";
344
-		                                      } else {
345
-			                                  dlHrEndOptions += "<option value='"+ hr.toLocaleString('en-US', {minimumIntegerDigits: 2, useGrouping:false}) +"' selected>"+ hr.toLocaleString('en-US', {minimumIntegerDigits: 2, useGrouping:false}) +"</option>";
346
-		                                      }
347
-			                         }
348
-
349
-		                                 var dlMnEndOptions = "";
350
-			                         for (var mn = 0; mn < 60; mn++) {
351
-		                                      if (dailyEndArr[1] != mn.toLocaleString('en-US', {minimumIntegerDigits: 2, useGrouping:false})) {
352
-			                                  dlMnEndOptions += "<option value='"+ mn.toLocaleString('en-US', {minimumIntegerDigits: 2, useGrouping:false}) +"'>"+ mn.toLocaleString('en-US', {minimumIntegerDigits: 2, useGrouping:false}) +"</option>";
353
-		                                      } else {
354
-			                                  dlMnEndOptions += "<option value='"+ mn.toLocaleString('en-US', {minimumIntegerDigits: 2, useGrouping:false}) +"' selected>"+ mn.toLocaleString('en-US', {minimumIntegerDigits: 2, useGrouping:false}) +"</option>";
355
-		                                      }
356
-			                         }
357
-
358
-                                                 var modeContent = "<div class='daysOfWeek'>Days of the week:<div class='tooltipautoreply'><div id='infoautoreply'>i</div><div class='autorpltooltip'>Enter the order number of the days of the week in which the auto-reply will be sent. For example, to send the auto-reply every day from Monday to Friday (outside the time interval specified below), enter 1,2,3,4,5 To send the auto-reply only Monday, Thursday and Friday enter 1,4,5 To send the auto-reply every day of the week enter 1,2,3,4,5,6,7</div></div></div><input type='text' id='weekdays-"+ k +"' class='daysInWeek' value='"+ autorpldata[k].days_of_week +"'><div class='chooseTInterval'>Send auto-reply <span style='color:#ad0202'>outside</span> this interval:<div class='tooltipautoreplyst'><div id='infoautoreplyst'>i</div><div class='autorpltooltipst'>These fields specify the time of the server. If the server is located in a time zone that is different from that of the owner/company, the time interval entered here should be adjusted accordingly.</div></div></div><div class='selectArplHours'><select id='dmstarthr-"+ k +"' class='selectHrMin'>"+ dlHrStartOptions +"</select><select id='dmstartmn-"+ k +"' class='selectHrMin'>"+ dlMnStartOptions +"</select><span style='font-weight: 600'> — </span><select id='dmendhr-"+ k +"' class='selectHrMin'>"+ dlHrEndOptions +"</select><select id='dmendmn-"+ k +"' class='selectHrMin'>"+ dlMnEndOptions +"</select></div>";
359
-
360
-                                             } else {
361
-
362
-                                                 var vctnStart = autorpldata[k].vacation_start.split(" ")[0];
363
-                                                 var vctnEnd = autorpldata[k].vacation_end.split(" ")[0];
364
-
365
-                                                 var slctdMode = "<option value=''>Select mode</option><option value='daily'>Daily mode</option><option value='vacation' selected>Vacation mode</option>";
366
-                                                 var modeContent = "<div class='chooseDateIntvl'>Send auto-reply <span style='color:#ad0202'>inside</span> this interval:</div><div class='arplstrtendDates'><div class='stdtTitle'>Start Date</div><input type='text' id='startDT-"+ k +"' class='startDate' placeholder='Pick a date' value='"+ vctnStart +"'><div class='enddtTitle'>End Date</div><input type='text' id='endDT-"+ k +"' class='endDate' placeholder='Pick a date' value='"+ vctnEnd +"'></div>"
367
-                                             }
368
-
369
-				             $("#autoReplyTbl").append("<tr><td><input type='text' class='arplAuthor' value='"+ autorpldata[k].saved_by_dsplname +"' disabled></td><td><select id='arpphn-"+ k +"' class='arplPhoneNmbr' style='pointer-events:none'><option selected>"+ autorpldata[k].phone_number +"</option></select></td><td><div id='arplmode-"+ k +"' class='arplMode'><select id='modeselect-"+ k +"' class='selectArplMode'>"+ slctdMode +"</select><div id='modecont-"+ k +"' class='modeContent'>"+ modeContent +"</div></div></td><td><textarea id='arpltxt-"+ k +"' class='arplText' rows='20' cols='40' placeholder='Enter the auto-reply message here.'>"+ autorpldata[k].message_text +"</textarea></td><td><img id='rmRow-"+ k +"' class='removeRow' src='/apps/sms_relentless/img/closewnd.svg' title='Remove this row from the database' style='cursor:pointer;margin:9px 8px 0px 18px;'></td><td><input type='submit' id='arplsave-"+ k +"' class='saveAutoReply' value='Edit' title='Edit Row' /></td></tr>");
370
-				        }
371
-				        $("#autoReplyTbl").append("<div><img id='addArplRow' src='/apps/sms_relentless/img/add.svg' title='Add Row'></div>");
372
-				    }
373
-
374
-
375
-				    // Create a list with all the available phone numbers
376
-                                    var numbersListItems = "<option value='' selected>Select phone number</option>";
377
-
378
-				    $.each(availPhoneNmbrs, function(key, indsmsnmb) {
379
-				           numbersListItems += "<option value='"+ indsmsnmb +"'>"+ indsmsnmb +"</option>";
380
-				    });
381
-
382
-                                    if (arplNmb == 0) {
383
-				        $("#arpphn-"+ arplNmb).append(numbersListItems);
384
-                                    }
385
-
386
-                                    // Initialize the date picker
387
-			            $('[id^="endDT-"]').datepicker({ dateFormat: "yy-mm-dd" });
388
-			            $('[id^="startDT-"]').datepicker({ dateFormat: "yy-mm-dd" });
389
-
390
-
391
-                                    // Select the auto-reply mode
392
-                                    function selectMode() {
393
-
394
-		                            $('[id^="modeselect-"]').change(function() {
395
-
396
-		                               var crtnmbr = $(this).attr("id").replace("modeselect-", "");
397
-
398
-		                               var dailyHrStart = "";
399
-		                               for (var h = 0; h < 24; h++) {
400
-		                                    dailyHrStart += "<option value='"+ h.toLocaleString('en-US', {minimumIntegerDigits: 2, useGrouping:false}) +"'>"+ h.toLocaleString('en-US', {minimumIntegerDigits: 2, useGrouping:false}) +"</option>";
401
-		                               }
402
-
403
-		                               var dailyMnStart = "";
404
-		                               for (var m = 0; m < 60; m++) {
405
-		                                    dailyMnStart += "<option value='"+ m.toLocaleString('en-US', {minimumIntegerDigits: 2, useGrouping:false}) +"'>"+ m.toLocaleString('en-US', {minimumIntegerDigits: 2, useGrouping:false}) +"</option>";
406
-		                               }
407
-
408
-		                               var dailyHrEnd = dailyHrStart;
409
-		                               var dailyMnEnd = dailyMnStart;
410
-
411
-		                               if ($(this).val() == 'daily') {
412
-		                                   $("#modecont-"+ crtnmbr).empty();
413
-		                                   $("#modecont-"+ crtnmbr).append("<div class='daysOfWeek'>Days of the week:<div class='tooltipautoreply'><div id='infoautoreply'>i</div><div class='autorpltooltip'>Enter the order number of the days of the week. For example, to send the auto-reply every day from Monday to Friday outside the specified time interval, enter 1,2,3,4,5 To send the auto-reply only Monday, Thursday and Friday enter 1,4,5 To send the auto-reply every day of the week enter 1,2,3,4,5,6,7</div></div></div><input type='text' id='weekdays-"+ crtnmbr +"' class='daysInWeek'><div class='chooseTInterval'>Send auto-reply <span style='color:#ad0202'>outside</span> this interval:<div class='tooltipautoreplyst'><div id='infoautoreplyst'>i</div><div class='autorpltooltipst'>These fields specify the time of the server. If the server is located in a time zone that is different from that of the owner/company, the time interval entered here should be adjusted accordingly.</div></div></div><div class='selectArplHours'><select id='dmstarthr-"+ crtnmbr +"' class='selectHrMin'>"+ dailyHrStart +"</select><select id='dmstartmn-"+ crtnmbr +"' class='selectHrMin'>"+ dailyMnStart +"</select><span style='font-weight: 600'> — </span><select id='dmendhr-"+ crtnmbr +"' class='selectHrMin'>"+ dailyHrEnd +"</select><select id='dmendmn-"+ crtnmbr +"' class='selectHrMin'>"+ dailyMnEnd +"</select></div>");
414
-		                               } else if ($(this).val() == 'vacation') {
415
-		                                   $("#modecont-"+ crtnmbr).empty();
416
-		                                   $("#modecont-"+ crtnmbr).append("<div class='chooseDateIntvl'>Send auto-reply <span style='color:#ad0202'>inside</span> this interval:</div><div class='arplstrtendDates'><div class='stdtTitle'>Start Date</div><input type='text' id='startDT-"+ crtnmbr +"' class='startDate' placeholder='Pick a date'><div class='enddtTitle'>End Date</div><input type='text' id='endDT-"+ crtnmbr +"' class='endDate' placeholder='Pick a date' /></div>");
417
-		                               }
418
-
419
-					       $("#endDT-"+ crtnmbr +"").datepicker({ dateFormat: "yy-mm-dd" });
420
-					       $("#startDT-"+ crtnmbr +"").datepicker({ dateFormat: "yy-mm-dd" });
421
-		                          });
422
-                                  }
423
-                                  selectMode();
424
-
425
-				  // Save the data
426
-				  function saveArplRow() {
427
-
428
-				     $('[id^="arplsave-"]').unbind("click");
429
-				     $('[id^="arplsave-"]').click(function(event) {
430
-
431
-				        event.preventDefault();
432
-				        var crntrwnmbr = $(this).attr("id").replace("arplsave-", "");
433
-
434
-				        if ($(this).attr("value") == "Save") {
435
-
436
-				            var phoneNmbr = $("#arpphn-"+ crntrwnmbr).val();
437
-				            var arplText = $("#arpltxt-"+ crntrwnmbr).val();
438
-				            var slctdMode = $("#modeselect-"+ crntrwnmbr).val();
439
-
440
-				            var slctddmDays = "";
441
-				            var slctdHrStart = "";
442
-				            var slctdMnStart = "";
443
-				            var slctdHrEnd = "";
444
-				            var slctdMnEnd = "";
445
-
446
-				            var vcStartDate = null;
447
-				            var vcEndDate = null;
448
-
449
-				            if (slctdMode == 'daily') {
450
-
451
-				                slctddmDays = $("#weekdays-"+ crntrwnmbr).val().trim();
452
-				                slctdHrStart = $("#dmstarthr-"+ crntrwnmbr).val().trim();
453
-				                slctdMnStart = $("#dmstartmn-"+ crntrwnmbr).val().trim();
454
-				                slctdHrEnd = $("#dmendhr-"+ crntrwnmbr).val().trim();
455
-				                slctdMnEnd = $("#dmendmn-"+ crntrwnmbr).val().trim();
456
-
457
-                                                if (slctdHrStart != '' && slctdMnStart != '') {
458
-                                                    var hrmnStartComp = slctdHrStart +":"+ slctdMnStart;
459
-                                                } else { var hrmnStartComp = ""; }
460
-
461
-                                                if (slctdHrEnd != '' && slctdMnEnd != '') {
462
-                                                    var hrmnEndComp = slctdHrEnd +":"+ slctdMnEnd;
463
-                                                } else { var hrmnEndComp = ""; }
464
-
465
-                                                if (!(/^[1-7\,]+$/.test(slctddmDays))) {
466
-				                    showAlert("The 'Days of the week' field can contain only digits from 1 to 7 and commas (,).");
467
-				                    return;
468
-                                                }
469
-
470
-                                                if (!(/^[0-9]+$/.test(slctdHrStart + slctdMnStart + slctdHrEnd + slctdMnEnd))) {
471
-				                    showAlert("The starting and ending values of the time interval for the 'Daily mode' can contain only digits from 0 to 9.");
472
-				                    return;
473
-                                                }
474
-
475
-                                                if (slctddmDays.trim() == '' || (slctdHrStart == slctdHrEnd && slctdMnStart == slctdMnEnd)) {
476
-				                    showAlert("For the 'Daily mode', you have to enter the order number of the days of the week for which you want the auto-reply to be sent, and you have to set a starting time that is different from the ending time!");
477
-				                    return;
478
-                                                }
479
-
480
-				            } else if (slctdMode == 'vacation') {
481
-		
482
-                                                if ($("#startDT-"+ crntrwnmbr).val().trim() == '' || $("#endDT-"+ crntrwnmbr).val().trim() == '') {
483
-
484
-				                    showAlert("For the 'Vacation mode', you have to enter both a start date and an end date.");
485
-				                    return;
486
-
487
-                                                } else {
488
-
489
-                                                    if (!(/^[0-9\-]+$/.test($("#startDT-"+ crntrwnmbr).val().trim() + $("#endDT-"+ crntrwnmbr).val().trim()))) {
490
-				                        showAlert("The start date and end date values for the 'Vacation mode' can contain only digits from 0 to 9 and hyphens (-).");
491
-				                        return;
492
-                                                    }
493
-
494
-		                                    vcStartDate = $("#startDT-"+ crntrwnmbr).val().trim() +" 00:00:00";
495
-				                    vcEndDate = $("#endDT-"+ crntrwnmbr).val().trim() +" 23:59:59";
496
-				                    var strtDateCmp = new Date(vcStartDate).toJSON().slice(0, 10) +" 00:00:00";
497
-				                    var endDateCmp = new Date(vcEndDate).toJSON().slice(0, 10) +" 23:59:59";
498
-				                    var crntDate = new Date().toJSON().slice(0, 10) +" 23:59:59";
499
-
500
-                                                    if (vcStartDate.trim() == "" || vcEndDate.trim() == "" || (strtDateCmp >= endDateCmp || ((strtDateCmp < crntDate) && (endDateCmp < crntDate)))) {
501
-				                        showAlert("For 'Vacation mode', you have to enter both a start date and an end date, the start date must be before the end date and at least the ending of the time interval must be in the future.");
502
-				                        return;
503
-                                                    }
504
-                                                }
505
-				            }
506
-
507
-
508
-				            if (phoneNmbr != '') {
509
-
510
-				              if (arplText.trim() != '') {
511
-
512
-				                if (slctdMode != '') {
513
-
514
-				                    var saveArplUrl = OC.generateUrl('/apps/sms_relentless/user/updateautoreplies');
515
-				                    var arpldata = {
516
-				                         userId: userid,
517
-				                         savedByDsplname: cusrDisplayName,
518
-				                         phoneNumber: phoneNmbr,
519
-				                         daysOfWeek: slctddmDays,
520
-				                         dailyStart: hrmnStartComp,
521
-				                         dailyEnd: hrmnEndComp,
522
-				                         vacationStart: vcStartDate,
523
-				                         vacationEnd: vcEndDate,
524
-				                         messageText: arplText
525
-				                    };
526
-
527
-					            $.ajax({
528
-					              method: 'PUT',
529
-					              url: saveArplUrl + '/' + userid,
530
-					              contentType: 'application/json',
531
-					              data: JSON.stringify(arpldata),
532
-				                      success: function(messagereceived) {
533
-
534
-				                                   if (messagereceived == 'success') {
535
-				                                       showAlert('The auto-reply has been successfully saved to the database!');
536
-				                                   } else if (messagereceived == 'failure') {
537
-				                                       showAlert('Error while trying to save the auto-reply!');
538
-				                                   } else if (messagereceived == 'not allowed') {
539
-                                                                       showAlert('You cannot change an auto-reply that was saved by a different user.');
540
-                                                                   }
541
-				                      },
542
-					              error: function() {
543
-						                   showAlert('Error while attempting to save the auto-reply! You can check the Nextcloud log to find more details about this issue.');
544
-					              }
545
-					            });
546
-
547
-
548
-                                                } else { showAlert("Please select the auto-reply mode."); return; }
549
-
550
-                                              } else { showAlert("Please enter the text of the auto-reply."); return; }
551
-
552
-                                            } else { showAlert("Please select a phone number if at least one number is available in the 'Phone Number' drop-down list. Otherwise, you should contact the administrator."); return; }
553
-
554
-                                            $(this).attr("value", "Edit");
555
-
556
-                                        } else {
557
-                                            $("#arplsave-"+ crntrwnmbr).attr("value", "Save");
558
-                                        }
559
-
560
-                                     });
561
-
562
-				  }
563
-                                  saveArplRow();
564
-
565
-
566
-				  // Remove a row
567
-				  function removeArplRow() {
568
-				       $('[id^="rmRow-"]').click(function() {
569
-
570
-					  var slctRowRm = $(this).attr("id").replace("rmRow-", "");
571
-					  var crntPhnNmbr = $("#arpphn-"+ slctRowRm).val();
572
-
573
-				          confirmAlert("Do you really want to remove this row from the database ?");
574
-
575
-				          $("#confirmCancel").click(function() { $("#alertMsgOverlay").remove(); $("#alertConfMessage").remove(); });
576
-
577
-				          $("#confirmOk").click(function() {
578
-
579
-				              $("#alertMsgOverlay").remove();
580
-				              $("#alertConfMessage").remove();
581
-
582
-					      var rmvArplUrl = OC.generateUrl('/apps/sms_relentless/user/removeautoreplies');
583
-					      $.ajax({
584
-						   url: rmvArplUrl + '/' + userid,
585
-						   method: "POST",
586
-						   dataType: "text",
587
-						   data: { phoneNumber: crntPhnNmbr },
588
-						   success: function(delresult) {
589
-
590
-						                     if (delresult.indexOf("success") > -1) {
591
-						                         showAlert("The auto-reply has been removed successfully!");
592
-						                         $("#arpphn-"+ slctRowRm).closest("tr").remove();
593
-						                     } else if (delresult.indexOf("failure") > -1) {
594
-						                         showAlert("Error while trying to remove auto-reply data!");
595
-						                     } else if (delresult.indexOf("not allowed") > -1) {
596
-                                                                         showAlert("You cannot remove the auto-reply saved by another user.");
597
-                                                                     }
598
-						   },
599
-						   error: function() { showAlert("Error while attempting to remove auto-reply data! You can check the Nextcloud log to find more details about this issue."); }
600
-					       });
601
-					  });
602
-				       });
603
-				  }
604
-				  removeArplRow();
605
-
606
-                                  // Add a new row
607
-                                  $("#addArplRow").click(function() {
608
-
609
-                                     if ($("#autoReplyTbl").find("tr:last-child").find(".arplPhoneNmbr").length > 0) {
610
-                                         var lastarpl = $("#autoReplyTbl").find("tr:last-child").find(".arplPhoneNmbr").attr("id").replace("arpphn-", "");
611
-                                         var indArplAdd = parseInt(lastarpl + 1);
612
-                                     } else { var indArplAdd = 0; }
613
-			             $("#autoReplyTbl").append("<tr><td><input type='text' class='arplAuthor' value='"+ cusrDisplayName +"' disabled></td><td><select id='arpphn-"+ indArplAdd +"' class='arplPhoneNmbr'>"+ numbersListItems +"</select></td><td><div id='arplmode-"+ indArplAdd +"' class='arplMode'><select id='modeselect-"+ indArplAdd +"' class='selectArplMode'><option value='' selected>Select mode</option><option value='daily'>Daily mode</option><option value='vacation'>Vacation mode</option></select><div id='modecont-"+ indArplAdd +"' class='modeContent'></div></div></td><td><textarea id='arpltxt-"+ indArplAdd +"' class='arplText' rows='20' cols='40' placeholder='Enter the auto-reply message here.'></textarea></td><td><img id='rmRow-"+ indArplAdd +"' class='removeRow' src='/apps/sms_relentless/img/closewnd.svg' title='Remove this row from the database' style='cursor:pointer;margin:9px 8px 0px 18px;'></td><td><input type='submit' id='arplsave-"+ indArplAdd +"' class='saveAutoReply' value='Save' title='Save Row' /></td></tr>");
614
-
615
-                                     selectMode();
616
-                                     saveArplRow();
617
-                                     removeArplRow();
618
-
619
-			             // Check if there is an auto-reply set for the same phone number
620
-				     $("#arpphn-"+ indArplAdd).change(function() {
621
-					 var selectedPhNb = $("#arpphn-"+ indArplAdd).val();
622
-					 var allArplPhNmbrs = $("#autoReplyTbl").find("tr").find(".arplPhoneNmbr");
623
-					 var phNbChck = 0;
624
-					 allArplPhNmbrs.each(function() {
625
-					    var slctphnb = ($(this).val())? $(this).val() : $(this).text();
626
-					    if (selectedPhNb == slctphnb) { phNbChck++; }
627
-					 });
628
-
629
-					 if (phNbChck == 2) {
630
-					     showAlert("There is already an auto-reply set up for this phone number. Please edit its own row, or choose a different phone number.");
631
-					     $(this).val('');
632
-					     return;
633
-					 }
634
-				     });
635
-                                  });
636
-
637
-		  },
638
-		  error: function() {
639
-                                    $("#autoRplPhoneNb").removeClass('icon-loading'); 
640
-                                    showAlert("Error while attempting to get the auto-reply settings! You can check the Nextcloud log to find more details about this issue.");
641
-                  }
642
-         });
643
-
644
-     },
645
-     error: function() {
646
-                  showAlert('Error while getting the settings! You can check the Nextcloud log to find more details about this issue.');
647
-     }
648
-  });
649
-
650
-
651
-
652
-  // Save personal settings for non-admin users
653
-  $("#save_sms_settings").on("click", function(event) {
654
-
655
-     if (isadm == 'reguser') {
656
-
657
-	    event.preventDefault();
658
-	    var baseUrlsave = OC.generateUrl('/apps/sms_relentless/user/updatesettings');
659
-
660
-	    var messagesperpageinit = $("#messagesperpage").val();
661
-	    var messagesperpagesec = messagesperpageinit.replace(/[^0-9]/g, '');
662
-
663
-	    if (messagesperpagesec != '') {
664
-		var messagesperpageproc = messagesperpagesec;
665
-	    } else {
666
-		var messagesperpageproc = 100;
667
-	    }
668
-
669
-	    var getnotify = 0;
670
-
671
-	    if ($("#get_notify").is(':checked')) {
672
-		getnotify = 1;
673
-	    }
674
-
675
-	    var emailaddressinit = $("#notification_email").val();
676
-
677
-	    function validate_email($email) {
678
-		var email_reg = /^([\w-\.]+@([\w-]+\.)+[\w-]{2,4})?$/;
679
-		return email_reg.test($email);
680
-	    }
681
-
682
-	    if (validate_email(emailaddressinit)) {
683
-		 var notifyemail = emailaddressinit;
684
-	    } else {
685
-		 var notifyemail = '';
686
-	    }
687
-
688
-	    var includesmsinemail = 0;
689
-	    if ($("#includesmsinemail").is(':checked')) {
690
-		includesmsinemail = 1;
691
-                if ($("#notification_email").val().trim() == '') {
692
-                    showAlert("Please enter an email address in the field: 'I want to receive a notification to the email address from below ...', or uncheck the checkbox: 'Include the SMS/MMS message in the email notification itself'.");
693
-                    return;
694
-                }
695
-	    }
696
-
697
-	    var showdisplaynm = 0;
698
-	    if ($("#showdisplaynames").is(':checked')) {
699
-		showdisplaynm = 1;
700
-	    }
701
-
702
-	    var adddisplaynm = 0;
703
-	    if ($("#adddisplaynames").is(':checked')) {
704
-		adddisplaynm = 1;
705
-	    }
706
-
707
-	    var datatosave = {
708
-			      userId: userid,
709
-		              telapiUrlRec: $("#telapi_url_rec").val(),
710
-		              telapiUrl: $("#telapi_url").val(),
711
-		              nexapiUrlRec: $("#nexapi_url_rec").val(),
712
-		              nexapiUrl: $("#nexapi_url").val(),
713
-		              twilapiUrlRec: $("#twilapi_url_rec").val(),
714
-		              twilapiUrl: $("#twilapi_url").val(),
715
-		              flowapiUrlRec: $("#flowapi_url_rec").val(),
716
-		              flowapiUrl: $("#flowapi_url").val(),
717
-			      messagesperpage: messagesperpageproc,
718
-			      getNotify: getnotify,
719
-			      notificationEmail: notifyemail,
720
-			      getsmsinemail: includesmsinemail,
721
-			      showDisplayNames: showdisplaynm,
722
-                              addDisplayNames: adddisplaynm
723
-	    };
724
-
725
-
726
-	    $.ajax({
727
-	       method: 'PUT',
728
-	       url: baseUrlsave + '/' + userid,
729
-	       contentType: 'application/json',
730
-	       data: JSON.stringify(datatosave),
731
-	       success: function() {
732
-                               OC.msg.startAction('#smsr_save_msg', t('sms_relentless', 'Saved'));
733
-	       },
734
-	       error: function() {
735
-		    showAlert('Error while attempting to save the settings! You can check the Nextcloud log to find more details about this issue.');
736
-	       }
737
-	    });
738
-
739
-
740
-     } else if (isadm == 'admin') {
741
-
742
-	    // Save personal settings for admins
743
-	    event.preventDefault();
744
-	    var baseUrlsaveadm = OC.generateUrl('/apps/sms_relentless/user/updatepersadmnsettings');
745
-
746
-	    var messagesperpageinit = $("#messagesperpage").val();
747
-	    var messagesperpagesec = messagesperpageinit.replace(/[^0-9]/g, '');
748
-
749
-	    if (messagesperpagesec != '') {
750
-		var messagesperpageproc = messagesperpagesec;
751
-	    } else {
752
-		var messagesperpageproc = 100;
753
-	    }
754
-
755
-	    var getnotify = 0;
756
-
757
-	    if ($("#get_notify").is(':checked')) {
758
-		getnotify = 1;
759
-	    }
760
-
761
-	    var emailaddressinit = $("#notification_email").val();
762
-
763
-	    function validate_email($email) {
764
-		var email_reg = /^([\w-\.]+@([\w-]+\.)+[\w-]{2,4})?$/;
765
-		return email_reg.test($email);
766
-	    }
767
-
768
-	    if (validate_email(emailaddressinit)) {
769
-		 var notifyemail = emailaddressinit;
770
-	    } else {
771
-		 var notifyemail = '';
772
-	    }
773
-
774
-	    var includesmsinemail = 0;
775
-	    if ($("#includesmsinemail").is(':checked')) {
776
-		includesmsinemail = 1;
777
-                if ($("#notification_email").val().trim() == '') {
778
-                    showAlert("Please enter an email address in the field: 'I want to receive a notification to the email address from below ...', or uncheck the checkbox: 'Include the SMS/MMS message in the email notification itself'.");
779
-                    return;
780
-                }
781
-	    }
782
-
783
-	    var showdisplaynm = 0;
784
-	    if ($("#showdisplaynames").is(':checked')) {
785
-		showdisplaynm = 1;
786
-	    }
787
-
788
-	    var adddisplaynm = 0;
789
-	    if ($("#adddisplaynames").is(':checked')) {
790
-		adddisplaynm = 1;
791
-	    }
792
-
793
-	    var datatosave = {
794
-			      userId: userid,
795
-			      messagesperpage: messagesperpageproc,
796
-			      getNotify: getnotify,
797
-			      notificationEmail: notifyemail,
798
-			      getsmsinemail: includesmsinemail,
799
-			      showDisplayNames: showdisplaynm,
800
-                              addDisplayNames: adddisplaynm
801
-	    };
802
-
803
-
804
-	    $.ajax({
805
-	       method: 'PUT',
806
-	       url: baseUrlsaveadm + '/' + userid,
807
-	       contentType: 'application/json',
808
-	       data: JSON.stringify(datatosave),
809
-	       success: function() {
810
-                               OC.msg.startAction('#smsr_save_msg', t('sms_relentless', 'Saved'));
811
-	       },
812
-	       error: function() {
813
-		    showAlert('Error while attempting to save the settings! You can check the Nextcloud log to find more details about this issue.');
814
-	       }
815
-	    });
816
-
817
-     }
818
-  });
819
-
820
-  function showAlert(alertText) {
821
-
822
-     let alertwnd = "<div id='alertMessage'>";
823
-     alertwnd += "<a id='closeAlertWnd' title='Close this window'></a>";
824
-     alertwnd += "<div id='alertTextWrap'>"+ alertText +"</div>";
825
-     alertwnd += "<input type='submit' id='alertOk' value='OK'>";
826
-     alertwnd += "</div>";
827
-
828
-     $("#content").append("<div id='alertMsgOverlay'></div>");
829
-     $("#content").append(alertwnd);
830
-
831
-     let topDist = parseInt((window.innerHeight / 2).toFixed(2) - 152) +"px";
832
-     let leftDist = parseInt((window.innerWidth / 2).toFixed(2) - 150) +"px";
833
-     $("#alertMessage").css({ "top" : topDist, "left" : leftDist });
834
-
835
-     $("#closeAlertWnd").click(function() { $("#alertMsgOverlay").remove(); $("#alertMessage").remove(); });
836
-     $("#alertMsgOverlay").click(function() { $("#alertMsgOverlay").remove(); $("#alertMessage").remove(); });
837
-     $("#alertOk").click(function() { $("#alertMsgOverlay").remove(); $("#alertMessage").remove(); });
838
-  }
839
-
840
-  function confirmAlert(alertText) {
841
-
842
-     let alertwndcf = "<div id='alertConfMessage'>";
843
-     alertwndcf += "<a id='closeAlertWndcf' title='Close this window'></a>";
844
-     alertwndcf += "<div id='alertTextWrap'>"+ alertText +"</div>";
845
-     alertwndcf += "<div id='cancelOkWrap'><input type='submit' id='confirmCancel' value='Cancel'>";
846
-     alertwndcf += "<input type='submit' id='confirmOk' value='OK'></div>";
847
-     alertwndcf += "</div>";
848
-
849
-     $("#content").append("<div id='alertMsgOverlay'></div>");
850
-     $("#content").append(alertwndcf);
851
-
852
-     let topDist = parseInt((window.innerHeight / 2).toFixed(2) - 152) +"px";
853
-     let leftDist = parseInt((window.innerWidth / 2).toFixed(2) - 150) +"px";
854
-     $("#alertConfMessage").css({ "top" : topDist, "left" : leftDist });
855
-
856
-     $("#closeAlertWndcf").click(function() { $("#alertMsgOverlay").remove(); $("#alertConfMessage").remove(); });
857
-     $("#alertMsgOverlay").click(function() { $("#alertMsgOverlay").remove(); $("#alertConfMessage").remove(); });
858
-  }
859
-
860
-});
Browse code

added CHANGELOG.txt appinfo/info.xml appinfo/signature.json js/settings.js js/showsmstables.js js/sendsms.js lib/Controller/SmsrelentlessController.php lib/Controller/AuthorApiController.php lib/Service/SmsrelentlessService.php templates/settings/personal.php lib/Migration/Version125Date20230603224815.php

DoubleBastionAdmin authored on 04/06/2023 00:54:42
Showing 1 changed files
1 1
new file mode 100644
... ...
@@ -0,0 +1,860 @@
1
+/**
2
+ * @copyright 2021 Double Bastion LLC <www.doublebastion.com>
3
+ *
4
+ * @author Double Bastion LLC
5
+ *
6
+ * @license GNU AGPL version 3 or any later version
7
+ *
8
+ * This program is free software; you can redistribute it and/or
9
+ * modify it under the terms of the GNU AFFERO GENERAL PUBLIC LICENSE
10
+ * License as published by the Free Software Foundation; either
11
+ * version 3 of the License, or any later version.
12
+ *
13
+ * This program is distributed in the hope that it will be useful,
14
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
15
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
16
+ * GNU AFFERO GENERAL PUBLIC LICENSE for more details.
17
+ *
18
+ * You should have received a copy of the GNU Affero General Public
19
+ * License along with this program.  If not, see <http://www.gnu.org/licenses/>.
20
+ *
21
+ */
22
+
23
+$(document).ready(function() {
24
+
25
+  var userid = "<?php p($userId); ?>";
26
+  var isadm = '';
27
+
28
+  // Get personal settings
29
+  var baseUrlget = OC.generateUrl('/apps/sms_relentless/user/getsettings');
30
+
31
+  $.ajax({
32
+     method: 'GET',
33
+     url: baseUrlget + '/' + userid,
34
+     contentType: 'application/json',
35
+     success: function(settingsfromdb) {
36
+
37
+         // Add the webhook URLs section, if the user is not an admin
38
+         if (settingsfromdb.adminornot == 'reguser') {
39
+
40
+             isadm = 'reguser';
41
+
42
+             $("#appTitlePrg").append('<p id="settings-dscr"><h3>Enter your options in the fields from below. As a non-admin user, you can use any of the SMS service providers from \
43
+                  below, on the condition that an admin has shared with you his API keys for that provider:</h3></p><br>');
44
+
45
+             $("#nadmProvSection").append('<div class="providerSettings"><p><label for="telapi_url_rec" class="setlabeltext"><b>Telnyx webhook URL for incoming SMS/MMS</b> (Generate \
46
+                  the URL by pressing the button from below. Don\'t forget to also click the \'Save\' button at the bottom of this page after entering all the options, to save \
47
+                  all the settings to the database.)</label></p> \
48
+                  <input type="button" id="generate_tel_rcpt" class="generateUrl" value="Generate new webhook URL for incoming SMS/MMS" /> \
49
+                  <input type="text" class="smsr_textboxspec" id="telapi_url_rec" name="telapi_url_rec" autocomplete="false" /> \
50
+                  <span id="copyToClipboardtel" class="icon icon-clippy" title="Copy to clipboard"></span><br><br> \
51
+                  \
52
+                  <p><label for="telapi_url" class="setlabeltext"><b>Telnyx webhook URL for delivery receipts</b> (This URL will be included by SMS Relentless in message sending \
53
+                  requests, so that Telnyx will know where to send the delivery receipts. Just generate it by pressing the button from below. Don\'t forget to click the \'Save\' \
54
+                  button at the bottom of this page after entering all the options, to save all the settings to the database.)</label></p> \
55
+                  <input type="button" id="generate_tel_delrcpt" class="generateUrl" value="Generate new webhook URL for delivery receipts" /> \
56
+                  <input type="text" id="telapi_url" name="telapi_url" autocomplete="false" /></div><br><br> \
57
+                  \
58
+                  <div class="providerSettings"><p><label for="nexapi_url_rec" class="setlabeltext"><b>Plivo webhook URL for incoming SMS/MMS</b> (Generate the URL by pressing \
59
+                  the button from below. Don\'t forget to also click the \'Save\' button at the bottom of this page after entering all the options, to save all the settings \
60
+                  to the database.)</label></p> \
61
+                  <input type="button" id="generate_nex_rcpt" class="generateUrl" value="Generate new webhook URL for incoming SMS/MMS" /> \
62
+                  <input type="text" class="smsr_textboxspec" id="nexapi_url_rec" name="nexapi_url_rec" autocomplete="false" /> \
63
+                  <span id="copyToClipboardnex" class="icon icon-clippy" title="Copy to clipboard"></span><br><br> \
64
+                  \
65
+                  <p><label for="nexapi_url" class="setlabeltext"><b>Plivo webhook URL for delivery receipts</b> (This URL will be included by SMS Relentless in message sending \
66
+                  requests, so that Plivo will know where to send the delivery receipts. Just generate it by pressing the button from below. Don\'t forget to click the \'Save\' \
67
+                  button at the bottom of this page after entering all the options, to save all the settings to the database.)</label></p> \
68
+                  <input type="button" id="generate_nex_delrcpt" class="generateUrl" value="Generate new webhook URL for delivery receipts" /> \
69
+                  <input type="text" id="nexapi_url" name="nexapi_url" autocomplete="false" /></div><br><br> \
70
+                  \
71
+                  <div class="providerSettings"><p><label for="twilapi_url_rec" class="setlabeltext"><b>Twilio webhook URL for incoming SMS/MMS</b> (Generate the URL by pressing \
72
+                  the button from below. Don\'t forget to also click the \'Save\' button at the bottom of this page after entering all the options, to save all the settings to \
73
+                  the database.)</label></p> \
74
+                  <input type="button" id="generate_twil_rcpt" class="generateUrl" value="Generate new webhook URL for incoming SMS/MMS" /> \
75
+                  <input type="text" class="smsr_textboxspec" id="twilapi_url_rec" name="twilapi_url_rec" autocomplete="false" /> \
76
+                  <span id="copyToClipboardtwil" class="icon icon-clippy" title="Copy to clipboard"></span><br><br> \
77
+                  \
78
+                  <p><label for="twilapi_url" class="setlabeltext"><b>Twilio webhook URL for delivery receipts</b> (This URL will be included by SMS Relentless in message sending \
79
+                  requests, so that Twilio will know where to send the delivery receipts. Just generate it by pressing the button from below. Don\'t forget to click the \'Save\' \
80
+                  button at the bottom of this page after entering all the options, to save all the settings to the database.)</label></p> \
81
+                  <input type="button" id="generate_twil_delrcpt" class="generateUrl" value="Generate new webhook URL for delivery receipts" /> \
82
+                  <input type="text" id="twilapi_url" name="twilapi_url" autocomplete="false" /></div><br><br> \
83
+                  \
84
+                  <div class="providerSettings"><p><label for="flowapi_url_rec" class="setlabeltext"><b>Flowroute webhook URL for incoming SMS/MMS</b> (Generate the URL by pressing \
85
+                  the button from below. Don\'t forget to also click the \'Save\' button at the bottom of this page after entering all the options, to save all the settings to \
86
+                  the database.)</label></p> \
87
+                  <input type="button" id="generate_flow_rcpt" class="generateUrl" value="Generate new webhook URL for incoming SMS/MMS" /> \
88
+                  <input type="text" class="smsr_textboxspec" id="flowapi_url_rec" name="flowapi_url_rec" autocomplete="false" /> \
89
+                  <span id="copyToClipboardflow" class="icon icon-clippy" title="Copy to clipboard"></span><br><br> \
90
+                  \
91
+                  <p><label for="flowapi_url" class="setlabeltext"><b>Flowroute webhook URL for delivery receipts</b> (This URL will be included by SMS Relentless in message sending \
92
+                  requests, so that Flowroute will know where to send the delivery receipts. Just generate it by pressing the button from below. Don\'t forget to click the \'Save\' \
93
+                  button at the bottom of this page after entering all the options, to save all the settings to the database.)</label></p> \
94
+                  <input type="button" id="generate_flow_delrcpt" class="generateUrl" value="Generate new webhook URL for delivery receipts" /> \
95
+                  <input type="text" id="flowapi_url" name="flowapi_url" autocomplete="false" /><br><br> \
96
+                  Flowroute only supports sending/receiving SMS/MMS messages within USA and Canada and it doesn\'t support Alphanumeric Sender IDs.</div><br>');
97
+
98
+
99
+		  $("#telapi_url_rec").val(settingsfromdb.telapi_url_rec);
100
+		  $("#telapi_url").val(settingsfromdb.telapi_url);
101
+		  $("#nexapi_url_rec").val(settingsfromdb.nexapi_url_rec);
102
+		  $("#nexapi_url").val(settingsfromdb.nexapi_url);
103
+		  $("#twilapi_url_rec").val(settingsfromdb.twilapi_url_rec);
104
+		  $("#twilapi_url").val(settingsfromdb.twilapi_url);
105
+		  $("#flowapi_url_rec").val(settingsfromdb.flowapi_url_rec);
106
+		  $("#flowapi_url").val(settingsfromdb.flowapi_url);
107
+		  $("#messagesperpage").val(settingsfromdb.messagesperpage);
108
+
109
+		  if (settingsfromdb.get_notify == 1) {
110
+		      $("#get_notify").attr('checked', true);
111
+		  } else {
112
+		      $("#get_notify").attr('checked', false);
113
+		  }
114
+
115
+		  $("#notification_email").val(settingsfromdb.notification_email);
116
+
117
+		  if (settingsfromdb.getsmsinemail == 1) {
118
+		      $("#includesmsinemail").attr('checked', true);
119
+		  } else {
120
+		      $("#includesmsinemail").attr('checked', false);
121
+		  }
122
+
123
+		  if (settingsfromdb.show_display_names == 1) {
124
+		      $("#showdisplaynames").attr('checked', true);
125
+		  } else {
126
+		      $("#showdisplaynames").attr('checked', false);
127
+		  }
128
+
129
+		  if (settingsfromdb.add_display_names == 1) {
130
+		      $("#adddisplaynames").attr('checked', true);
131
+		  } else {
132
+		      $("#adddisplaynames").attr('checked', false);
133
+		  }
134
+
135
+		  function randomStr(strlength) {
136
+			var fintext = "";
137
+			var keyspace = '0123456789abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ';
138
+			for (var i = 0; i < strlength; i++) {
139
+			     fintext += keyspace.charAt(Math.floor(Math.random() * keyspace.length));
140
+			}
141
+			return fintext;
142
+		  }
143
+
144
+		  $("#generate_tel_rcpt").on("click", function(event) {
145
+
146
+		     var teltokenrec = randomStr(70);
147
+		     var telnyxwhurlrec = window.location.origin + OC.generateUrl('/apps/sms_relentless/api/recsmstel?telrecparam=') + teltokenrec;
148
+
149
+		     $("#telapi_url_rec").val(telnyxwhurlrec);
150
+		  });
151
+
152
+		  $("#copyToClipboardtel").on("click", function(event) {
153
+		     var $tempEl = $("<input>");
154
+		     $("body").append($tempEl);
155
+		     $tempEl.val($("#telapi_url_rec").val()).select();
156
+		     document.execCommand("Copy");
157
+		     $tempEl.remove();
158
+		     showAlert("The link has been copied to your clipboard!");
159
+		  });
160
+
161
+		  $("#generate_tel_delrcpt").on("click", function(event) {
162
+
163
+		     var teltoken = randomStr(70);
164
+		     var telnyxwhurl = window.location.origin + OC.generateUrl('/apps/sms_relentless/api/recdeliverytel?teldrparam=') + teltoken;
165
+
166
+		     $("#telapi_url").val(telnyxwhurl);
167
+		  });
168
+
169
+
170
+		  $("#generate_nex_rcpt").on("click", function(event) {
171
+
172
+		     var plivotokenrec = randomStr(70);
173
+		     var plivowhurlrec = window.location.origin + OC.generateUrl('/apps/sms_relentless/api/recsmsnex?plivorecparam=') + plivotokenrec;
174
+
175
+		     $("#nexapi_url_rec").val(plivowhurlrec);
176
+		  });
177
+
178
+		  $("#copyToClipboardnex").on("click", function(event) {
179
+		     var $tempElpl = $("<input>");
180
+		     $("body").append($tempElpl);
181
+		     $tempElpl.val($("#nexapi_url_rec").val()).select();
182
+		     document.execCommand("Copy");
183
+		     $tempElpl.remove();
184
+		     showAlert("The link has been copied to your clipboard!");
185
+		  });
186
+
187
+		  $("#generate_nex_delrcpt").on("click", function(event) {
188
+
189
+		     var plivotoken = randomStr(70);
190
+		     var plivodrwhurl = window.location.origin + OC.generateUrl('/apps/sms_relentless/api/recdeliverynex?plivodrparam=') + plivotoken;
191
+
192
+		     $("#nexapi_url").val(plivodrwhurl);
193
+		  });
194
+
195
+
196
+		  $("#generate_twil_rcpt").on("click", function(event) {
197
+
198
+		     var twiltokenrec = randomStr(35);
199
+		     var twilwhurlrec = window.location.origin + OC.generateUrl('/apps/sms_relentless/api/recsmstwil?twilrecparam=') + twiltokenrec;
200
+
201
+		     $("#twilapi_url_rec").val(twilwhurlrec);
202
+		  });
203
+
204
+		  $("#copyToClipboardtwil").on("click", function(event) {
205
+		     var $tempElpl = $("<input>");
206
+		     $("body").append($tempElpl);
207
+		     $tempElpl.val($("#twilapi_url_rec").val()).select();
208
+		     document.execCommand("Copy");
209
+		     $tempElpl.remove();
210
+		     showAlert("The link has been copied to your clipboard!");
211
+		  });
212
+
213
+		  $("#generate_twil_delrcpt").on("click", function(event) {
214
+
215
+		     var twiltoken = randomStr(35);
216
+		     var twildrwhurl = window.location.origin + OC.generateUrl('/apps/sms_relentless/api/recdeliverytwil?twildrparam=') + twiltoken;
217
+
218
+		     $("#twilapi_url").val(twildrwhurl);
219
+		  });
220
+
221
+
222
+		  $("#generate_flow_rcpt").on("click", function(event) {
223
+
224
+		     var flowtokenrec = randomStr(70);
225
+		     var flowwhurlrec = window.location.origin + OC.generateUrl('/apps/sms_relentless/api/recsmsflow?flowrecparam=') + flowtokenrec;
226
+
227
+		     $("#flowapi_url_rec").val(flowwhurlrec);
228
+		  });
229
+
230
+		  $("#copyToClipboardflow").on("click", function(event) {
231
+		     var $tempElpl = $("<input>");
232
+		     $("body").append($tempElpl);
233
+		     $tempElpl.val($("#flowapi_url_rec").val()).select();
234
+		     document.execCommand("Copy");
235
+		     $tempElpl.remove();
236
+		     showAlert("The link has been copied to your clipboard!");
237
+		  });
238
+
239
+		  $("#generate_flow_delrcpt").on("click", function(event) {
240
+
241
+		     var flowtoken = randomStr(70);
242
+		     var flowdrwhurl = window.location.origin + OC.generateUrl('/apps/sms_relentless/api/recdeliveryflow?flowdrparam=') + flowtoken;
243
+
244
+		     $("#flowapi_url").val(flowdrwhurl);
245
+		  });
246
+
247
+
248
+         } else if (settingsfromdb.adminornot == 'admin') {
249
+
250
+                  $("#appTitlePrg").append('<p id="settings-dscr"><h3>Enter your options in the fields from below:</h3></p><br>');
251
+                  isadm = 'admin';
252
+
253
+		  $("#messagesperpage").val(settingsfromdb.messagesperpage);
254
+
255
+		  if (settingsfromdb.get_notify == 1) {
256
+		      $("#get_notify").attr('checked', true);
257
+		  } else {
258
+		      $("#get_notify").attr('checked', false);
259
+		  }
260
+
261
+		  $("#notification_email").val(settingsfromdb.notification_email);
262
+
263
+		  if (settingsfromdb.getsmsinemail == 1) {
264
+		      $("#includesmsinemail").attr('checked', true);
265
+		  } else {
266
+		      $("#includesmsinemail").attr('checked', false);
267
+		  }
268
+
269
+		  if (settingsfromdb.show_display_names == 1) {
270
+		      $("#showdisplaynames").attr('checked', true);
271
+		  } else {
272
+		      $("#showdisplaynames").attr('checked', false);
273
+		  }
274
+
275
+		  if (settingsfromdb.add_display_names == 1) {
276
+		      $("#adddisplaynames").attr('checked', true);
277
+		  } else {
278
+		      $("#adddisplaynames").attr('checked', false);
279
+		  }
280
+         }
281
+
282
+
283
+         // Auto-reply settings
284
+
285
+         // Get the available phone numbers from all providers associated with the access keys entered on the Settings page (restrictions are applied to numbers for non-admins)
286
+         $("#autoRplPhoneNb").addClass('icon-loading');
287
+         var getnumbersUrl = OC.generateUrl("/apps/sms_relentless/user/getautoreplyconf");
288
+
289
+	 $.ajax({
290
+		  url: getnumbersUrl + '/' + userid,
291
+		  type: "GET",
292
+                  contentType: 'application/json',
293
+		  success: function(autoreplydata) {
294
+
295
+                                    $("#autoRplPhoneNb").removeClass('icon-loading');
296
+                                    var cusrDisplayName = autoreplydata.userdisplayname;
297
+                                    var availPhoneNmbrs = autoreplydata.phonenumbers;
298
+                                    var autorpldata = autoreplydata.autoreplies;
299
+
300
+				    if (autorpldata.length > 0) { 
301
+				        var arplNmb = autorpldata.length;
302
+				    } else { 
303
+				        var arplNmb = 0; 
304
+				    }
305
+
306
+				    // List the auto-replies for the phone numbers available for the current user
307
+				    if (arplNmb == 0) {
308
+
309
+				        $("#autoReplyTbl").append("<tr><td><input type='text' class='arplAuthor' value='"+ cusrDisplayName +"' disabled></td><td><select id='arpphn-"+ arplNmb +"' class='arplPhoneNmbr'></select></td><td><div id='arplmode-"+ arplNmb +"' class='arplMode'><select id='modeselect-"+ arplNmb +"' class='selectArplMode'><option value='' selected>Select mode</option><option value='daily'>Daily mode</option><option value='vacation'>Vacation mode</option></select><div id='modecont-"+ arplNmb +"' class='modeContent'></div></div></td><td><textarea id='arpltxt-"+ arplNmb +"' class='arplText' rows='20' cols='40' placeholder='Enter the auto-reply message here.'></textarea></td><td><img id='rmRow-"+ arplNmb +"' class='removeRow' src='/apps/sms_relentless/img/closewnd.svg' title='Remove this row from the database' style='cursor:pointer;margin:9px 8px 0px 18px;'></td><td><input type='submit' id='arplsave-"+ arplNmb +"' class='saveAutoReply' value='Save' title='Save Row' /></td></tr>");
310
+				        $("#autoReplyTbl").append("<div><img id='addArplRow' src='/apps/sms_relentless/img/add.svg' title='Add Row'></div>");
311
+
312
+				    } else {
313
+
314
+				        for (k = 0; k < arplNmb; k++) {
315
+
316
+                                             if (autorpldata[k].days_of_week != '') {
317
+
318
+                                                 var slctdMode = "<option value=''>Select mode</option><option value='daily' selected>Daily mode</option><option value='vacation'>Vacation mode</option>";
319
+                                                 var dailyStartArr = autorpldata[k].daily_start.split(":");
320
+                                                 var dailyEndArr = autorpldata[k].daily_end.split(":");
321
+
322
+		                                 var dlHrStartOptions = "";
323
+			                         for (var hr = 0; hr < 24; hr++) {
324
+		                                      if (dailyStartArr[0] != hr.toLocaleString('en-US', {minimumIntegerDigits: 2, useGrouping:false})) {
325
+			                                  dlHrStartOptions += "<option value='"+ hr.toLocaleString('en-US', {minimumIntegerDigits: 2, useGrouping:false}) +"'>"+ hr.toLocaleString('en-US', {minimumIntegerDigits: 2, useGrouping:false}) +"</option>";
326
+		                                      } else {
327
+			                                  dlHrStartOptions += "<option value='"+ hr.toLocaleString('en-US', {minimumIntegerDigits: 2, useGrouping:false}) +"' selected>"+ hr.toLocaleString('en-US', {minimumIntegerDigits: 2, useGrouping:false}) +"</option>";
328
+		                                      }
329
+			                         }
330
+
331
+		                                 var dlMnStartOptions = "";
332
+			                         for (var mn = 0; mn < 60; mn++) {
333
+		                                      if (dailyStartArr[0] != mn.toLocaleString('en-US', {minimumIntegerDigits: 2, useGrouping:false})) {
334
+			                                  dlMnStartOptions += "<option value='"+ mn.toLocaleString('en-US', {minimumIntegerDigits: 2, useGrouping:false}) +"'>"+ mn.toLocaleString('en-US', {minimumIntegerDigits: 2, useGrouping:false}) +"</option>";
335
+		                                      } else {
336
+			                                  dlMnStartOptions += "<option value='"+ mn.toLocaleString('en-US', {minimumIntegerDigits: 2, useGrouping:false}) +"' selected>"+ mn.toLocaleString('en-US', {minimumIntegerDigits: 2, useGrouping:false}) +"</option>";
337
+		                                      }
338
+			                         }
339
+
340
+		                                 var dlHrEndOptions = "";
341
+			                         for (var hr = 0; hr < 24; hr++) {
342
+		                                      if (dailyEndArr[0] != hr.toLocaleString('en-US', {minimumIntegerDigits: 2, useGrouping:false})) {
343
+			                                  dlHrEndOptions += "<option value='"+ hr.toLocaleString('en-US', {minimumIntegerDigits: 2, useGrouping:false}) +"'>"+ hr.toLocaleString('en-US', {minimumIntegerDigits: 2, useGrouping:false}) +"</option>";
344
+		                                      } else {
345
+			                                  dlHrEndOptions += "<option value='"+ hr.toLocaleString('en-US', {minimumIntegerDigits: 2, useGrouping:false}) +"' selected>"+ hr.toLocaleString('en-US', {minimumIntegerDigits: 2, useGrouping:false}) +"</option>";
346
+		                                      }
347
+			                         }
348
+
349
+		                                 var dlMnEndOptions = "";
350
+			                         for (var mn = 0; mn < 60; mn++) {
351
+		                                      if (dailyEndArr[1] != mn.toLocaleString('en-US', {minimumIntegerDigits: 2, useGrouping:false})) {
352
+			                                  dlMnEndOptions += "<option value='"+ mn.toLocaleString('en-US', {minimumIntegerDigits: 2, useGrouping:false}) +"'>"+ mn.toLocaleString('en-US', {minimumIntegerDigits: 2, useGrouping:false}) +"</option>";
353
+		                                      } else {
354
+			                                  dlMnEndOptions += "<option value='"+ mn.toLocaleString('en-US', {minimumIntegerDigits: 2, useGrouping:false}) +"' selected>"+ mn.toLocaleString('en-US', {minimumIntegerDigits: 2, useGrouping:false}) +"</option>";
355
+		                                      }
356
+			                         }
357
+
358
+                                                 var modeContent = "<div class='daysOfWeek'>Days of the week:<div class='tooltipautoreply'><div id='infoautoreply'>i</div><div class='autorpltooltip'>Enter the order number of the days of the week in which the auto-reply will be sent. For example, to send the auto-reply every day from Monday to Friday (outside the time interval specified below), enter 1,2,3,4,5 To send the auto-reply only Monday, Thursday and Friday enter 1,4,5 To send the auto-reply every day of the week enter 1,2,3,4,5,6,7</div></div></div><input type='text' id='weekdays-"+ k +"' class='daysInWeek' value='"+ autorpldata[k].days_of_week +"'><div class='chooseTInterval'>Send auto-reply <span style='color:#ad0202'>outside</span> this interval:<div class='tooltipautoreplyst'><div id='infoautoreplyst'>i</div><div class='autorpltooltipst'>These fields specify the time of the server. If the server is located in a time zone that is different from that of the owner/company, the time interval entered here should be adjusted accordingly.</div></div></div><div class='selectArplHours'><select id='dmstarthr-"+ k +"' class='selectHrMin'>"+ dlHrStartOptions +"</select><select id='dmstartmn-"+ k +"' class='selectHrMin'>"+ dlMnStartOptions +"</select><span style='font-weight: 600'> — </span><select id='dmendhr-"+ k +"' class='selectHrMin'>"+ dlHrEndOptions +"</select><select id='dmendmn-"+ k +"' class='selectHrMin'>"+ dlMnEndOptions +"</select></div>";
359
+
360
+                                             } else {
361
+
362
+                                                 var vctnStart = autorpldata[k].vacation_start.split(" ")[0];
363
+                                                 var vctnEnd = autorpldata[k].vacation_end.split(" ")[0];
364
+
365
+                                                 var slctdMode = "<option value=''>Select mode</option><option value='daily'>Daily mode</option><option value='vacation' selected>Vacation mode</option>";
366
+                                                 var modeContent = "<div class='chooseDateIntvl'>Send auto-reply <span style='color:#ad0202'>inside</span> this interval:</div><div class='arplstrtendDates'><div class='stdtTitle'>Start Date</div><input type='text' id='startDT-"+ k +"' class='startDate' placeholder='Pick a date' value='"+ vctnStart +"'><div class='enddtTitle'>End Date</div><input type='text' id='endDT-"+ k +"' class='endDate' placeholder='Pick a date' value='"+ vctnEnd +"'></div>"
367
+                                             }
368
+
369
+				             $("#autoReplyTbl").append("<tr><td><input type='text' class='arplAuthor' value='"+ autorpldata[k].saved_by_dsplname +"' disabled></td><td><select id='arpphn-"+ k +"' class='arplPhoneNmbr' style='pointer-events:none'><option selected>"+ autorpldata[k].phone_number +"</option></select></td><td><div id='arplmode-"+ k +"' class='arplMode'><select id='modeselect-"+ k +"' class='selectArplMode'>"+ slctdMode +"</select><div id='modecont-"+ k +"' class='modeContent'>"+ modeContent +"</div></div></td><td><textarea id='arpltxt-"+ k +"' class='arplText' rows='20' cols='40' placeholder='Enter the auto-reply message here.'>"+ autorpldata[k].message_text +"</textarea></td><td><img id='rmRow-"+ k +"' class='removeRow' src='/apps/sms_relentless/img/closewnd.svg' title='Remove this row from the database' style='cursor:pointer;margin:9px 8px 0px 18px;'></td><td><input type='submit' id='arplsave-"+ k +"' class='saveAutoReply' value='Edit' title='Edit Row' /></td></tr>");
370
+				        }
371
+				        $("#autoReplyTbl").append("<div><img id='addArplRow' src='/apps/sms_relentless/img/add.svg' title='Add Row'></div>");
372
+				    }
373
+
374
+
375
+				    // Create a list with all the available phone numbers
376
+                                    var numbersListItems = "<option value='' selected>Select phone number</option>";
377
+
378
+				    $.each(availPhoneNmbrs, function(key, indsmsnmb) {
379
+				           numbersListItems += "<option value='"+ indsmsnmb +"'>"+ indsmsnmb +"</option>";
380
+				    });
381
+
382
+                                    if (arplNmb == 0) {
383
+				        $("#arpphn-"+ arplNmb).append(numbersListItems);
384
+                                    }
385
+
386
+                                    // Initialize the date picker
387
+			            $('[id^="endDT-"]').datepicker({ dateFormat: "yy-mm-dd" });
388
+			            $('[id^="startDT-"]').datepicker({ dateFormat: "yy-mm-dd" });
389
+
390
+
391
+                                    // Select the auto-reply mode
392
+                                    function selectMode() {
393
+
394
+		                            $('[id^="modeselect-"]').change(function() {
395
+
396
+		                               var crtnmbr = $(this).attr("id").replace("modeselect-", "");
397
+
398
+		                               var dailyHrStart = "";
399
+		                               for (var h = 0; h < 24; h++) {
400
+		                                    dailyHrStart += "<option value='"+ h.toLocaleString('en-US', {minimumIntegerDigits: 2, useGrouping:false}) +"'>"+ h.toLocaleString('en-US', {minimumIntegerDigits: 2, useGrouping:false}) +"</option>";
401
+		                               }
402
+
403
+		                               var dailyMnStart = "";
404
+		                               for (var m = 0; m < 60; m++) {
405
+		                                    dailyMnStart += "<option value='"+ m.toLocaleString('en-US', {minimumIntegerDigits: 2, useGrouping:false}) +"'>"+ m.toLocaleString('en-US', {minimumIntegerDigits: 2, useGrouping:false}) +"</option>";
406
+		                               }
407
+
408
+		                               var dailyHrEnd = dailyHrStart;
409
+		                               var dailyMnEnd = dailyMnStart;
410
+
411
+		                               if ($(this).val() == 'daily') {
412
+		                                   $("#modecont-"+ crtnmbr).empty();
413
+		                                   $("#modecont-"+ crtnmbr).append("<div class='daysOfWeek'>Days of the week:<div class='tooltipautoreply'><div id='infoautoreply'>i</div><div class='autorpltooltip'>Enter the order number of the days of the week. For example, to send the auto-reply every day from Monday to Friday outside the specified time interval, enter 1,2,3,4,5 To send the auto-reply only Monday, Thursday and Friday enter 1,4,5 To send the auto-reply every day of the week enter 1,2,3,4,5,6,7</div></div></div><input type='text' id='weekdays-"+ crtnmbr +"' class='daysInWeek'><div class='chooseTInterval'>Send auto-reply <span style='color:#ad0202'>outside</span> this interval:<div class='tooltipautoreplyst'><div id='infoautoreplyst'>i</div><div class='autorpltooltipst'>These fields specify the time of the server. If the server is located in a time zone that is different from that of the owner/company, the time interval entered here should be adjusted accordingly.</div></div></div><div class='selectArplHours'><select id='dmstarthr-"+ crtnmbr +"' class='selectHrMin'>"+ dailyHrStart +"</select><select id='dmstartmn-"+ crtnmbr +"' class='selectHrMin'>"+ dailyMnStart +"</select><span style='font-weight: 600'> — </span><select id='dmendhr-"+ crtnmbr +"' class='selectHrMin'>"+ dailyHrEnd +"</select><select id='dmendmn-"+ crtnmbr +"' class='selectHrMin'>"+ dailyMnEnd +"</select></div>");
414
+		                               } else if ($(this).val() == 'vacation') {
415
+		                                   $("#modecont-"+ crtnmbr).empty();
416
+		                                   $("#modecont-"+ crtnmbr).append("<div class='chooseDateIntvl'>Send auto-reply <span style='color:#ad0202'>inside</span> this interval:</div><div class='arplstrtendDates'><div class='stdtTitle'>Start Date</div><input type='text' id='startDT-"+ crtnmbr +"' class='startDate' placeholder='Pick a date'><div class='enddtTitle'>End Date</div><input type='text' id='endDT-"+ crtnmbr +"' class='endDate' placeholder='Pick a date' /></div>");
417
+		                               }
418
+
419
+					       $("#endDT-"+ crtnmbr +"").datepicker({ dateFormat: "yy-mm-dd" });
420
+					       $("#startDT-"+ crtnmbr +"").datepicker({ dateFormat: "yy-mm-dd" });
421
+		                          });
422
+                                  }
423
+                                  selectMode();
424
+
425
+				  // Save the data
426
+				  function saveArplRow() {
427
+
428
+				     $('[id^="arplsave-"]').unbind("click");
429
+				     $('[id^="arplsave-"]').click(function(event) {
430
+
431
+				        event.preventDefault();
432
+				        var crntrwnmbr = $(this).attr("id").replace("arplsave-", "");
433
+
434
+				        if ($(this).attr("value") == "Save") {
435
+
436
+				            var phoneNmbr = $("#arpphn-"+ crntrwnmbr).val();
437
+				            var arplText = $("#arpltxt-"+ crntrwnmbr).val();
438
+				            var slctdMode = $("#modeselect-"+ crntrwnmbr).val();
439
+
440
+				            var slctddmDays = "";
441
+				            var slctdHrStart = "";
442
+				            var slctdMnStart = "";
443
+				            var slctdHrEnd = "";
444
+				            var slctdMnEnd = "";
445
+
446
+				            var vcStartDate = null;
447
+				            var vcEndDate = null;
448
+
449
+				            if (slctdMode == 'daily') {
450
+
451
+				                slctddmDays = $("#weekdays-"+ crntrwnmbr).val().trim();
452
+				                slctdHrStart = $("#dmstarthr-"+ crntrwnmbr).val().trim();
453
+				                slctdMnStart = $("#dmstartmn-"+ crntrwnmbr).val().trim();
454
+				                slctdHrEnd = $("#dmendhr-"+ crntrwnmbr).val().trim();
455
+				                slctdMnEnd = $("#dmendmn-"+ crntrwnmbr).val().trim();
456
+
457
+                                                if (slctdHrStart != '' && slctdMnStart != '') {
458
+                                                    var hrmnStartComp = slctdHrStart +":"+ slctdMnStart;
459
+                                                } else { var hrmnStartComp = ""; }
460
+
461
+                                                if (slctdHrEnd != '' && slctdMnEnd != '') {
462
+                                                    var hrmnEndComp = slctdHrEnd +":"+ slctdMnEnd;
463
+                                                } else { var hrmnEndComp = ""; }
464
+
465
+                                                if (!(/^[1-7\,]+$/.test(slctddmDays))) {
466
+				                    showAlert("The 'Days of the week' field can contain only digits from 1 to 7 and commas (,).");
467
+				                    return;
468
+                                                }
469
+
470
+                                                if (!(/^[0-9]+$/.test(slctdHrStart + slctdMnStart + slctdHrEnd + slctdMnEnd))) {
471
+				                    showAlert("The starting and ending values of the time interval for the 'Daily mode' can contain only digits from 0 to 9.");
472
+				                    return;
473
+                                                }
474
+
475
+                                                if (slctddmDays.trim() == '' || (slctdHrStart == slctdHrEnd && slctdMnStart == slctdMnEnd)) {
476
+				                    showAlert("For the 'Daily mode', you have to enter the order number of the days of the week for which you want the auto-reply to be sent, and you have to set a starting time that is different from the ending time!");
477
+				                    return;
478
+                                                }
479
+
480
+				            } else if (slctdMode == 'vacation') {
481
+		
482
+                                                if ($("#startDT-"+ crntrwnmbr).val().trim() == '' || $("#endDT-"+ crntrwnmbr).val().trim() == '') {
483
+
484
+				                    showAlert("For the 'Vacation mode', you have to enter both a start date and an end date.");
485
+				                    return;
486
+
487
+                                                } else {
488
+
489
+                                                    if (!(/^[0-9\-]+$/.test($("#startDT-"+ crntrwnmbr).val().trim() + $("#endDT-"+ crntrwnmbr).val().trim()))) {
490
+				                        showAlert("The start date and end date values for the 'Vacation mode' can contain only digits from 0 to 9 and hyphens (-).");
491
+				                        return;
492
+                                                    }
493
+
494
+		                                    vcStartDate = $("#startDT-"+ crntrwnmbr).val().trim() +" 00:00:00";
495
+				                    vcEndDate = $("#endDT-"+ crntrwnmbr).val().trim() +" 23:59:59";
496
+				                    var strtDateCmp = new Date(vcStartDate).toJSON().slice(0, 10) +" 00:00:00";
497
+				                    var endDateCmp = new Date(vcEndDate).toJSON().slice(0, 10) +" 23:59:59";
498
+				                    var crntDate = new Date().toJSON().slice(0, 10) +" 23:59:59";
499
+
500
+                                                    if (vcStartDate.trim() == "" || vcEndDate.trim() == "" || (strtDateCmp >= endDateCmp || ((strtDateCmp < crntDate) && (endDateCmp < crntDate)))) {
501
+				                        showAlert("For 'Vacation mode', you have to enter both a start date and an end date, the start date must be before the end date and at least the ending of the time interval must be in the future.");
502
+				                        return;
503
+                                                    }
504
+                                                }
505
+				            }
506
+
507
+
508
+				            if (phoneNmbr != '') {
509
+
510
+				              if (arplText.trim() != '') {
511
+
512
+				                if (slctdMode != '') {
513
+
514
+				                    var saveArplUrl = OC.generateUrl('/apps/sms_relentless/user/updateautoreplies');
515
+				                    var arpldata = {
516
+				                         userId: userid,
517
+				                         savedByDsplname: cusrDisplayName,
518
+				                         phoneNumber: phoneNmbr,
519
+				                         daysOfWeek: slctddmDays,
520
+				                         dailyStart: hrmnStartComp,
521
+				                         dailyEnd: hrmnEndComp,
522
+				                         vacationStart: vcStartDate,
523
+				                         vacationEnd: vcEndDate,
524
+				                         messageText: arplText
525
+				                    };
526
+
527
+					            $.ajax({
528
+					              method: 'PUT',
529
+					              url: saveArplUrl + '/' + userid,
530
+					              contentType: 'application/json',
531
+					              data: JSON.stringify(arpldata),
532
+				                      success: function(messagereceived) {
533
+
534
+				                                   if (messagereceived == 'success') {
535
+				                                       showAlert('The auto-reply has been successfully saved to the database!');
536
+				                                   } else if (messagereceived == 'failure') {
537
+				                                       showAlert('Error while trying to save the auto-reply!');
538
+				                                   } else if (messagereceived == 'not allowed') {
539
+                                                                       showAlert('You cannot change an auto-reply that was saved by a different user.');
540
+                                                                   }
541
+				                      },
542
+					              error: function() {
543
+						                   showAlert('Error while attempting to save the auto-reply! You can check the Nextcloud log to find more details about this issue.');
544
+					              }
545
+					            });
546
+
547
+
548
+                                                } else { showAlert("Please select the auto-reply mode."); return; }
549
+
550
+                                              } else { showAlert("Please enter the text of the auto-reply."); return; }
551
+
552
+                                            } else { showAlert("Please select a phone number if at least one number is available in the 'Phone Number' drop-down list. Otherwise, you should contact the administrator."); return; }
553
+
554
+                                            $(this).attr("value", "Edit");
555
+
556
+                                        } else {
557
+                                            $("#arplsave-"+ crntrwnmbr).attr("value", "Save");
558
+                                        }
559
+
560
+                                     });
561
+
562
+				  }
563
+                                  saveArplRow();
564
+
565
+
566
+				  // Remove a row
567
+				  function removeArplRow() {
568
+				       $('[id^="rmRow-"]').click(function() {
569
+
570
+					  var slctRowRm = $(this).attr("id").replace("rmRow-", "");
571
+					  var crntPhnNmbr = $("#arpphn-"+ slctRowRm).val();
572
+
573
+				          confirmAlert("Do you really want to remove this row from the database ?");
574
+
575
+				          $("#confirmCancel").click(function() { $("#alertMsgOverlay").remove(); $("#alertConfMessage").remove(); });
576
+
577
+				          $("#confirmOk").click(function() {
578
+
579
+				              $("#alertMsgOverlay").remove();
580
+				              $("#alertConfMessage").remove();
581
+
582
+					      var rmvArplUrl = OC.generateUrl('/apps/sms_relentless/user/removeautoreplies');
583
+					      $.ajax({
584
+						   url: rmvArplUrl + '/' + userid,
585
+						   method: "POST",
586
+						   dataType: "text",
587
+						   data: { phoneNumber: crntPhnNmbr },
588
+						   success: function(delresult) {
589
+
590
+						                     if (delresult.indexOf("success") > -1) {
591
+						                         showAlert("The auto-reply has been removed successfully!");
592
+						                         $("#arpphn-"+ slctRowRm).closest("tr").remove();
593
+						                     } else if (delresult.indexOf("failure") > -1) {
594
+						                         showAlert("Error while trying to remove auto-reply data!");
595
+						                     } else if (delresult.indexOf("not allowed") > -1) {
596
+                                                                         showAlert("You cannot remove the auto-reply saved by another user.");
597
+                                                                     }
598
+						   },
599
+						   error: function() { showAlert("Error while attempting to remove auto-reply data! You can check the Nextcloud log to find more details about this issue."); }
600
+					       });
601
+					  });
602
+				       });
603
+				  }
604
+				  removeArplRow();
605
+
606
+                                  // Add a new row
607
+                                  $("#addArplRow").click(function() {
608
+
609
+                                     if ($("#autoReplyTbl").find("tr:last-child").find(".arplPhoneNmbr").length > 0) {
610
+                                         var lastarpl = $("#autoReplyTbl").find("tr:last-child").find(".arplPhoneNmbr").attr("id").replace("arpphn-", "");
611
+                                         var indArplAdd = parseInt(lastarpl + 1);
612
+                                     } else { var indArplAdd = 0; }
613
+			             $("#autoReplyTbl").append("<tr><td><input type='text' class='arplAuthor' value='"+ cusrDisplayName +"' disabled></td><td><select id='arpphn-"+ indArplAdd +"' class='arplPhoneNmbr'>"+ numbersListItems +"</select></td><td><div id='arplmode-"+ indArplAdd +"' class='arplMode'><select id='modeselect-"+ indArplAdd +"' class='selectArplMode'><option value='' selected>Select mode</option><option value='daily'>Daily mode</option><option value='vacation'>Vacation mode</option></select><div id='modecont-"+ indArplAdd +"' class='modeContent'></div></div></td><td><textarea id='arpltxt-"+ indArplAdd +"' class='arplText' rows='20' cols='40' placeholder='Enter the auto-reply message here.'></textarea></td><td><img id='rmRow-"+ indArplAdd +"' class='removeRow' src='/apps/sms_relentless/img/closewnd.svg' title='Remove this row from the database' style='cursor:pointer;margin:9px 8px 0px 18px;'></td><td><input type='submit' id='arplsave-"+ indArplAdd +"' class='saveAutoReply' value='Save' title='Save Row' /></td></tr>");
614
+
615
+                                     selectMode();
616
+                                     saveArplRow();
617
+                                     removeArplRow();
618
+
619
+			             // Check if there is an auto-reply set for the same phone number
620
+				     $("#arpphn-"+ indArplAdd).change(function() {
621
+					 var selectedPhNb = $("#arpphn-"+ indArplAdd).val();
622
+					 var allArplPhNmbrs = $("#autoReplyTbl").find("tr").find(".arplPhoneNmbr");
623
+					 var phNbChck = 0;
624
+					 allArplPhNmbrs.each(function() {
625
+					    var slctphnb = ($(this).val())? $(this).val() : $(this).text();
626
+					    if (selectedPhNb == slctphnb) { phNbChck++; }
627
+					 });
628
+
629
+					 if (phNbChck == 2) {
630
+					     showAlert("There is already an auto-reply set up for this phone number. Please edit its own row, or choose a different phone number.");
631
+					     $(this).val('');
632
+					     return;
633
+					 }
634
+				     });
635
+                                  });
636
+
637
+		  },
638
+		  error: function() {
639
+                                    $("#autoRplPhoneNb").removeClass('icon-loading'); 
640
+                                    showAlert("Error while attempting to get the auto-reply settings! You can check the Nextcloud log to find more details about this issue.");
641
+                  }
642
+         });
643
+
644
+     },
645
+     error: function() {
646
+                  showAlert('Error while getting the settings! You can check the Nextcloud log to find more details about this issue.');
647
+     }
648
+  });
649
+
650
+
651
+
652
+  // Save personal settings for non-admin users
653
+  $("#save_sms_settings").on("click", function(event) {
654
+
655
+     if (isadm == 'reguser') {
656
+
657
+	    event.preventDefault();
658
+	    var baseUrlsave = OC.generateUrl('/apps/sms_relentless/user/updatesettings');
659
+
660
+	    var messagesperpageinit = $("#messagesperpage").val();
661
+	    var messagesperpagesec = messagesperpageinit.replace(/[^0-9]/g, '');
662
+
663
+	    if (messagesperpagesec != '') {
664
+		var messagesperpageproc = messagesperpagesec;
665
+	    } else {
666
+		var messagesperpageproc = 100;
667
+	    }
668
+
669
+	    var getnotify = 0;
670
+
671
+	    if ($("#get_notify").is(':checked')) {
672
+		getnotify = 1;
673
+	    }
674
+
675
+	    var emailaddressinit = $("#notification_email").val();
676
+
677
+	    function validate_email($email) {
678
+		var email_reg = /^([\w-\.]+@([\w-]+\.)+[\w-]{2,4})?$/;
679
+		return email_reg.test($email);
680
+	    }
681
+
682
+	    if (validate_email(emailaddressinit)) {
683
+		 var notifyemail = emailaddressinit;
684
+	    } else {
685
+		 var notifyemail = '';
686
+	    }
687
+
688
+	    var includesmsinemail = 0;
689
+	    if ($("#includesmsinemail").is(':checked')) {
690
+		includesmsinemail = 1;
691
+                if ($("#notification_email").val().trim() == '') {
692
+                    showAlert("Please enter an email address in the field: 'I want to receive a notification to the email address from below ...', or uncheck the checkbox: 'Include the SMS/MMS message in the email notification itself'.");
693
+                    return;
694
+                }
695
+	    }
696
+
697
+	    var showdisplaynm = 0;
698
+	    if ($("#showdisplaynames").is(':checked')) {
699
+		showdisplaynm = 1;
700
+	    }
701
+
702
+	    var adddisplaynm = 0;
703
+	    if ($("#adddisplaynames").is(':checked')) {
704
+		adddisplaynm = 1;
705
+	    }
706
+
707
+	    var datatosave = {
708
+			      userId: userid,
709
+		              telapiUrlRec: $("#telapi_url_rec").val(),
710
+		              telapiUrl: $("#telapi_url").val(),
711
+		              nexapiUrlRec: $("#nexapi_url_rec").val(),
712
+		              nexapiUrl: $("#nexapi_url").val(),
713
+		              twilapiUrlRec: $("#twilapi_url_rec").val(),
714
+		              twilapiUrl: $("#twilapi_url").val(),
715
+		              flowapiUrlRec: $("#flowapi_url_rec").val(),
716
+		              flowapiUrl: $("#flowapi_url").val(),
717
+			      messagesperpage: messagesperpageproc,
718
+			      getNotify: getnotify,
719
+			      notificationEmail: notifyemail,
720
+			      getsmsinemail: includesmsinemail,
721
+			      showDisplayNames: showdisplaynm,
722
+                              addDisplayNames: adddisplaynm
723
+	    };
724
+
725
+
726
+	    $.ajax({
727
+	       method: 'PUT',
728
+	       url: baseUrlsave + '/' + userid,
729
+	       contentType: 'application/json',
730
+	       data: JSON.stringify(datatosave),
731
+	       success: function() {
732
+                               OC.msg.startAction('#smsr_save_msg', t('sms_relentless', 'Saved'));
733
+	       },
734
+	       error: function() {
735
+		    showAlert('Error while attempting to save the settings! You can check the Nextcloud log to find more details about this issue.');
736
+	       }
737
+	    });
738
+
739
+
740
+     } else if (isadm == 'admin') {
741
+
742
+	    // Save personal settings for admins
743
+	    event.preventDefault();
744
+	    var baseUrlsaveadm = OC.generateUrl('/apps/sms_relentless/user/updatepersadmnsettings');
745
+
746
+	    var messagesperpageinit = $("#messagesperpage").val();
747
+	    var messagesperpagesec = messagesperpageinit.replace(/[^0-9]/g, '');
748
+
749
+	    if (messagesperpagesec != '') {
750
+		var messagesperpageproc = messagesperpagesec;
751
+	    } else {
752
+		var messagesperpageproc = 100;
753
+	    }
754
+
755
+	    var getnotify = 0;
756
+
757
+	    if ($("#get_notify").is(':checked')) {
758
+		getnotify = 1;
759
+	    }
760
+
761
+	    var emailaddressinit = $("#notification_email").val();
762
+
763
+	    function validate_email($email) {
764
+		var email_reg = /^([\w-\.]+@([\w-]+\.)+[\w-]{2,4})?$/;
765
+		return email_reg.test($email);
766
+	    }
767
+
768
+	    if (validate_email(emailaddressinit)) {
769
+		 var notifyemail = emailaddressinit;
770
+	    } else {
771
+		 var notifyemail = '';
772
+	    }
773
+
774
+	    var includesmsinemail = 0;
775
+	    if ($("#includesmsinemail").is(':checked')) {
776
+		includesmsinemail = 1;
777
+                if ($("#notification_email").val().trim() == '') {
778
+                    showAlert("Please enter an email address in the field: 'I want to receive a notification to the email address from below ...', or uncheck the checkbox: 'Include the SMS/MMS message in the email notification itself'.");
779
+                    return;
780
+                }
781
+	    }
782
+
783
+	    var showdisplaynm = 0;
784
+	    if ($("#showdisplaynames").is(':checked')) {
785
+		showdisplaynm = 1;
786
+	    }
787
+
788
+	    var adddisplaynm = 0;
789
+	    if ($("#adddisplaynames").is(':checked')) {
790
+		adddisplaynm = 1;
791
+	    }
792
+
793
+	    var datatosave = {
794
+			      userId: userid,
795
+			      messagesperpage: messagesperpageproc,
796
+			      getNotify: getnotify,
797
+			      notificationEmail: notifyemail,
798
+			      getsmsinemail: includesmsinemail,
799
+			      showDisplayNames: showdisplaynm,
800
+                              addDisplayNames: adddisplaynm
801
+	    };
802
+
803
+
804
+	    $.ajax({
805
+	       method: 'PUT',
806
+	       url: baseUrlsaveadm + '/' + userid,
807
+	       contentType: 'application/json',
808
+	       data: JSON.stringify(datatosave),
809
+	       success: function() {
810
+                               OC.msg.startAction('#smsr_save_msg', t('sms_relentless', 'Saved'));
811
+	       },
812
+	       error: function() {
813
+		    showAlert('Error while attempting to save the settings! You can check the Nextcloud log to find more details about this issue.');
814
+	       }
815
+	    });
816
+
817
+     }
818
+  });
819
+
820
+  function showAlert(alertText) {
821
+
822
+     let alertwnd = "<div id='alertMessage'>";
823
+     alertwnd += "<a id='closeAlertWnd' title='Close this window'></a>";
824
+     alertwnd += "<div id='alertTextWrap'>"+ alertText +"</div>";
825
+     alertwnd += "<input type='submit' id='alertOk' value='OK'>";
826
+     alertwnd += "</div>";
827
+
828
+     $("#content").append("<div id='alertMsgOverlay'></div>");
829
+     $("#content").append(alertwnd);
830
+
831
+     let topDist = parseInt((window.innerHeight / 2).toFixed(2) - 152) +"px";
832
+     let leftDist = parseInt((window.innerWidth / 2).toFixed(2) - 150) +"px";
833
+     $("#alertMessage").css({ "top" : topDist, "left" : leftDist });
834
+
835
+     $("#closeAlertWnd").click(function() { $("#alertMsgOverlay").remove(); $("#alertMessage").remove(); });
836
+     $("#alertMsgOverlay").click(function() { $("#alertMsgOverlay").remove(); $("#alertMessage").remove(); });
837
+     $("#alertOk").click(function() { $("#alertMsgOverlay").remove(); $("#alertMessage").remove(); });
838
+  }
839
+
840
+  function confirmAlert(alertText) {
841
+
842
+     let alertwndcf = "<div id='alertConfMessage'>";
843
+     alertwndcf += "<a id='closeAlertWndcf' title='Close this window'></a>";
844
+     alertwndcf += "<div id='alertTextWrap'>"+ alertText +"</div>";
845
+     alertwndcf += "<div id='cancelOkWrap'><input type='submit' id='confirmCancel' value='Cancel'>";
846
+     alertwndcf += "<input type='submit' id='confirmOk' value='OK'></div>";
847
+     alertwndcf += "</div>";
848
+
849
+     $("#content").append("<div id='alertMsgOverlay'></div>");
850
+     $("#content").append(alertwndcf);
851
+
852
+     let topDist = parseInt((window.innerHeight / 2).toFixed(2) - 152) +"px";
853
+     let leftDist = parseInt((window.innerWidth / 2).toFixed(2) - 150) +"px";
854
+     $("#alertConfMessage").css({ "top" : topDist, "left" : leftDist });
855
+
856
+     $("#closeAlertWndcf").click(function() { $("#alertMsgOverlay").remove(); $("#alertConfMessage").remove(); });
857
+     $("#alertMsgOverlay").click(function() { $("#alertMsgOverlay").remove(); $("#alertConfMessage").remove(); });
858
+  }
859
+
860
+});
Browse code

CHANGELOG.txt appinfo/info.xml appinfo/signature.json js/settings.js js/showsmstables.js js/sendsms.js lib/Controller/SmsrelentlessController.php lib/Controller/AuthorApiController.php lib/Service/SmsrelentlessService.php templates/settings/personal.php

DoubleBastionAdmin authored on 04/06/2023 00:49:12
Showing 1 changed files
1 1
deleted file mode 100644
... ...
@@ -1,836 +0,0 @@
1
-/**
2
- * @copyright 2021 Double Bastion LLC <www.doublebastion.com>
3
- *
4
- * @author Double Bastion LLC
5
- *
6
- * @license GNU AGPL version 3 or any later version
7
- *
8
- * This program is free software; you can redistribute it and/or
9
- * modify it under the terms of the GNU AFFERO GENERAL PUBLIC LICENSE
10
- * License as published by the Free Software Foundation; either
11
- * version 3 of the License, or any later version.
12
- *
13
- * This program is distributed in the hope that it will be useful,
14
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
15
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
16
- * GNU AFFERO GENERAL PUBLIC LICENSE for more details.
17
- *
18
- * You should have received a copy of the GNU Affero General Public
19
- * License along with this program.  If not, see <http://www.gnu.org/licenses/>.
20
- *
21
- */
22
-
23
-$(document).ready(function() {
24
-
25
-  var userid = "<?php p($userId); ?>";
26
-  var isadm = '';
27
-
28
-  // Get personal settings
29
-  var baseUrlget = OC.generateUrl('/apps/sms_relentless/user/getsettings');
30
-
31
-  $.ajax({
32
-     method: 'GET',
33
-     url: baseUrlget + '/' + userid,
34
-     contentType: 'application/json',
35
-     success: function(settingsfromdb) {
36
-
37
-         // Add the webhook URLs section, if the user is not an admin
38
-         if (settingsfromdb.adminornot == 'reguser') {
39
-
40
-             isadm = 'reguser';
41
-
42
-             $("#appTitlePrg").append('<p id="settings-dscr"><h3>Enter your options in the fields from below. As a non-admin user, you can use any of the SMS service providers from \
43
-                  below, on the condition that an admin has shared with you his API keys for that provider:</h3></p><br>');
44
-
45
-             $("#nadmProvSection").append('<div class="providerSettings"><p><label for="telapi_url_rec" class="setlabeltext"><b>Telnyx webhook URL for incoming SMS/MMS</b> (Generate \
46
-                  the URL by pressing the button from below. Don\'t forget to also click the \'Save\' button at the bottom of this page after entering all the options, to save \
47
-                  all the settings to the database.)</label></p> \
48
-                  <input type="button" id="generate_tel_rcpt" class="generateUrl" value="Generate new webhook URL for incoming SMS/MMS" /> \
49
-                  <input type="text" class="smsr_textboxspec" id="telapi_url_rec" name="telapi_url_rec" autocomplete="false" /> \
50
-                  <span id="copyToClipboardtel" class="icon icon-clippy" title="Copy to clipboard"></span><br><br> \
51
-                  \
52
-                  <p><label for="telapi_url" class="setlabeltext"><b>Telnyx webhook URL for delivery receipts</b> (This URL will be included by SMS Relentless in message sending \
53
-                  requests, so that Telnyx will know where to send the delivery receipts. Just generate it by pressing the button from below. Don\'t forget to click the \'Save\' \
54
-                  button at the bottom of this page after entering all the options, to save all the settings to the database.)</label></p> \
55
-                  <input type="button" id="generate_tel_delrcpt" class="generateUrl" value="Generate new webhook URL for delivery receipts" /> \
56
-                  <input type="text" id="telapi_url" name="telapi_url" autocomplete="false" /></div><br><br> \
57
-                  \
58
-                  <div class="providerSettings"><p><label for="nexapi_url_rec" class="setlabeltext"><b>Plivo webhook URL for incoming SMS/MMS</b> (Generate the URL by pressing \
59
-                  the button from below. Don\'t forget to also click the \'Save\' button at the bottom of this page after entering all the options, to save all the settings \
60
-                  to the database.)</label></p> \
61
-                  <input type="button" id="generate_nex_rcpt" class="generateUrl" value="Generate new webhook URL for incoming SMS/MMS" /> \
62
-                  <input type="text" class="smsr_textboxspec" id="nexapi_url_rec" name="nexapi_url_rec" autocomplete="false" /> \
63
-                  <span id="copyToClipboardnex" class="icon icon-clippy" title="Copy to clipboard"></span><br><br> \
64
-                  \
65
-                  <p><label for="nexapi_url" class="setlabeltext"><b>Plivo webhook URL for delivery receipts</b> (This URL will be included by SMS Relentless in message sending \
66
-                  requests, so that Plivo will know where to send the delivery receipts. Just generate it by pressing the button from below. Don\'t forget to click the \'Save\' \
67
-                  button at the bottom of this page after entering all the options, to save all the settings to the database.)</label></p> \
68
-                  <input type="button" id="generate_nex_delrcpt" class="generateUrl" value="Generate new webhook URL for delivery receipts" /> \
69
-                  <input type="text" id="nexapi_url" name="nexapi_url" autocomplete="false" /></div><br><br> \
70
-                  \
71
-                  <div class="providerSettings"><p><label for="twilapi_url_rec" class="setlabeltext"><b>Twilio webhook URL for incoming SMS/MMS</b> (Generate the URL by pressing \
72
-                  the button from below. Don\'t forget to also click the \'Save\' button at the bottom of this page after entering all the options, to save all the settings to \
73
-                  the database.)</label></p> \
74
-                  <input type="button" id="generate_twil_rcpt" class="generateUrl" value="Generate new webhook URL for incoming SMS/MMS" /> \
75
-                  <input type="text" class="smsr_textboxspec" id="twilapi_url_rec" name="twilapi_url_rec" autocomplete="false" /> \
76
-                  <span id="copyToClipboardtwil" class="icon icon-clippy" title="Copy to clipboard"></span><br><br> \
77
-                  \
78
-                  <p><label for="twilapi_url" class="setlabeltext"><b>Twilio webhook URL for delivery receipts</b> (This URL will be included by SMS Relentless in message sending \
79
-                  requests, so that Twilio will know where to send the delivery receipts. Just generate it by pressing the button from below. Don\'t forget to click the \'Save\' \
80
-                  button at the bottom of this page after entering all the options, to save all the settings to the database.)</label></p> \
81
-                  <input type="button" id="generate_twil_delrcpt" class="generateUrl" value="Generate new webhook URL for delivery receipts" /> \
82
-                  <input type="text" id="twilapi_url" name="twilapi_url" autocomplete="false" /></div><br><br> \
83
-                  \
84
-                  <div class="providerSettings"><p><label for="flowapi_url_rec" class="setlabeltext"><b>Flowroute webhook URL for incoming SMS/MMS</b> (Generate the URL by pressing \
85
-                  the button from below. Don\'t forget to also click the \'Save\' button at the bottom of this page after entering all the options, to save all the settings to \
86
-                  the database.)</label></p> \
87
-                  <input type="button" id="generate_flow_rcpt" class="generateUrl" value="Generate new webhook URL for incoming SMS/MMS" /> \
88
-                  <input type="text" class="smsr_textboxspec" id="flowapi_url_rec" name="flowapi_url_rec" autocomplete="false" /> \
89
-                  <span id="copyToClipboardflow" class="icon icon-clippy" title="Copy to clipboard"></span><br><br> \
90
-                  \
91
-                  <p><label for="flowapi_url" class="setlabeltext"><b>Flowroute webhook URL for delivery receipts</b> (This URL will be included by SMS Relentless in message sending \
92
-                  requests, so that Flowroute will know where to send the delivery receipts. Just generate it by pressing the button from below. Don\'t forget to click the \'Save\' \
93
-                  button at the bottom of this page after entering all the options, to save all the settings to the database.)</label></p> \
94
-                  <input type="button" id="generate_flow_delrcpt" class="generateUrl" value="Generate new webhook URL for delivery receipts" /> \
95
-                  <input type="text" id="flowapi_url" name="flowapi_url" autocomplete="false" /><br><br> \
96
-                  Flowroute only supports sending/receiving SMS/MMS messages within USA and Canada and it doesn\'t support Alphanumeric Sender IDs.</div><br>');
97
-
98
-
99
-		  $("#telapi_url_rec").val(settingsfromdb.telapi_url_rec);
100
-		  $("#telapi_url").val(settingsfromdb.telapi_url);
101
-		  $("#nexapi_url_rec").val(settingsfromdb.nexapi_url_rec);
102
-		  $("#nexapi_url").val(settingsfromdb.nexapi_url);
103
-		  $("#twilapi_url_rec").val(settingsfromdb.twilapi_url_rec);
104
-		  $("#twilapi_url").val(settingsfromdb.twilapi_url);
105
-		  $("#flowapi_url_rec").val(settingsfromdb.flowapi_url_rec);
106
-		  $("#flowapi_url").val(settingsfromdb.flowapi_url);
107
-		  $("#messagesperpage").val(settingsfromdb.messagesperpage);
108
-
109
-		  if (settingsfromdb.get_notify == 1) {
110
-		      $("#get_notify").attr('checked', true);
111
-		  } else {
112
-		      $("#get_notify").attr('checked', false);
113
-		  }
114
-
115
-		  $("#notification_email").val(settingsfromdb.notification_email);
116
-
117
-		  if (settingsfromdb.getsmsinemail == 1) {
118
-		      $("#includesmsinemail").attr('checked', true);
119
-		  } else {
120
-		      $("#includesmsinemail").attr('checked', false);
121
-		  }
122
-
123
-		  if (settingsfromdb.show_display_names == 1) {
124
-		      $("#showdisplaynames").attr('checked', true);
125
-		  } else {
126
-		      $("#showdisplaynames").attr('checked', false);
127
-		  }
128
-
129
-		  function randomStr(strlength) {
130
-			var fintext = "";
131
-			var keyspace = '0123456789abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ';
132
-			for (var i = 0; i < strlength; i++) {
133
-			     fintext += keyspace.charAt(Math.floor(Math.random() * keyspace.length));
134
-			}
135
-			return fintext;
136
-		  }
137
-
138
-		  $("#generate_tel_rcpt").on("click", function(event) {
139
-
140
-		     var teltokenrec = randomStr(70);
141
-		     var telnyxwhurlrec = window.location.origin + OC.generateUrl('/apps/sms_relentless/api/recsmstel?telrecparam=') + teltokenrec;
142
-
143
-		     $("#telapi_url_rec").val(telnyxwhurlrec);
144
-		  });
145
-
146
-		  $("#copyToClipboardtel").on("click", function(event) {
147
-		     var $tempEl = $("<input>");
148
-		     $("body").append($tempEl);
149
-		     $tempEl.val($("#telapi_url_rec").val()).select();
150
-		     document.execCommand("Copy");
151
-		     $tempEl.remove();
152
-		     showAlert("The link has been copied to your clipboard!");
153
-		  });
154
-
155
-		  $("#generate_tel_delrcpt").on("click", function(event) {
156
-
157
-		     var teltoken = randomStr(70);
158
-		     var telnyxwhurl = window.location.origin + OC.generateUrl('/apps/sms_relentless/api/recdeliverytel?teldrparam=') + teltoken;
159
-
160
-		     $("#telapi_url").val(telnyxwhurl);
161
-		  });
162
-
163
-
164
-		  $("#generate_nex_rcpt").on("click", function(event) {
165
-
166
-		     var plivotokenrec = randomStr(70);
167
-		     var plivowhurlrec = window.location.origin + OC.generateUrl('/apps/sms_relentless/api/recsmsnex?plivorecparam=') + plivotokenrec;
168
-
169
-		     $("#nexapi_url_rec").val(plivowhurlrec);
170
-		  });
171
-
172
-		  $("#copyToClipboardnex").on("click", function(event) {
173
-		     var $tempElpl = $("<input>");
174
-		     $("body").append($tempElpl);
175
-		     $tempElpl.val($("#nexapi_url_rec").val()).select();
176
-		     document.execCommand("Copy");
177
-		     $tempElpl.remove();
178
-		     showAlert("The link has been copied to your clipboard!");
179
-		  });
180
-
181
-		  $("#generate_nex_delrcpt").on("click", function(event) {
182
-
183
-		     var plivotoken = randomStr(70);
184
-		     var plivodrwhurl = window.location.origin + OC.generateUrl('/apps/sms_relentless/api/recdeliverynex?plivodrparam=') + plivotoken;
185
-
186
-		     $("#nexapi_url").val(plivodrwhurl);
187
-		  });
188
-
189
-
190
-		  $("#generate_twil_rcpt").on("click", function(event) {
191
-
192
-		     var twiltokenrec = randomStr(35);
193
-		     var twilwhurlrec = window.location.origin + OC.generateUrl('/apps/sms_relentless/api/recsmstwil?twilrecparam=') + twiltokenrec;
194
-
195
-		     $("#twilapi_url_rec").val(twilwhurlrec);
196
-		  });
197
-
198
-		  $("#copyToClipboardtwil").on("click", function(event) {
199
-		     var $tempElpl = $("<input>");
200
-		     $("body").append($tempElpl);
201
-		     $tempElpl.val($("#twilapi_url_rec").val()).select();
202
-		     document.execCommand("Copy");
203
-		     $tempElpl.remove();
204
-		     showAlert("The link has been copied to your clipboard!");
205
-		  });
206
-
207
-		  $("#generate_twil_delrcpt").on("click", function(event) {
208
-
209
-		     var twiltoken = randomStr(35);
210
-		     var twildrwhurl = window.location.origin + OC.generateUrl('/apps/sms_relentless/api/recdeliverytwil?twildrparam=') + twiltoken;
211
-
212
-		     $("#twilapi_url").val(twildrwhurl);
213
-		  });
214
-
215
-
216
-		  $("#generate_flow_rcpt").on("click", function(event) {
217
-
218
-		     var flowtokenrec = randomStr(70);
219
-		     var flowwhurlrec = window.location.origin + OC.generateUrl('/apps/sms_relentless/api/recsmsflow?flowrecparam=') + flowtokenrec;
220
-
221
-		     $("#flowapi_url_rec").val(flowwhurlrec);
222
-		  });
223
-
224
-		  $("#copyToClipboardflow").on("click", function(event) {
225
-		     var $tempElpl = $("<input>");
226
-		     $("body").append($tempElpl);
227
-		     $tempElpl.val($("#flowapi_url_rec").val()).select();
228
-		     document.execCommand("Copy");
229
-		     $tempElpl.remove();
230
-		     showAlert("The link has been copied to your clipboard!");
231
-		  });
232
-
233
-		  $("#generate_flow_delrcpt").on("click", function(event) {
234
-
235
-		     var flowtoken = randomStr(70);
236
-		     var flowdrwhurl = window.location.origin + OC.generateUrl('/apps/sms_relentless/api/recdeliveryflow?flowdrparam=') + flowtoken;
237
-
238
-		     $("#flowapi_url").val(flowdrwhurl);
239
-		  });
240
-
241
-
242
-         } else if (settingsfromdb.adminornot == 'admin') {
243
-
244
-                  $("#appTitlePrg").append('<p id="settings-dscr"><h3>Enter your options in the fields from below:</h3></p><br>');
245
-                  isadm = 'admin';
246
-
247
-		  $("#messagesperpage").val(settingsfromdb.messagesperpage);
248
-
249
-		  if (settingsfromdb.get_notify == 1) {
250
-		      $("#get_notify").attr('checked', true);
251
-		  } else {
252
-		      $("#get_notify").attr('checked', false);
253
-		  }
254
-
255
-		  $("#notification_email").val(settingsfromdb.notification_email);
256
-
257
-		  if (settingsfromdb.getsmsinemail == 1) {
258
-		      $("#includesmsinemail").attr('checked', true);
259
-		  } else {
260
-		      $("#includesmsinemail").attr('checked', false);
261
-		  }
262
-
263
-		  if (settingsfromdb.show_display_names == 1) {
264
-		      $("#showdisplaynames").attr('checked', true);
265
-		  } else {
266
-		      $("#showdisplaynames").attr('checked', false);
267
-		  }
268
-         }
269
-
270
-
271
-         // Auto-reply settings
272
-
273
-         // Get the available phone numbers from all providers associated with the access keys entered on the Settings page (restrictions are applied to numbers for non-admins)
274
-         $("#autoRplPhoneNb").addClass('icon-loading');
275
-         var getnumbersUrl = OC.generateUrl("/apps/sms_relentless/user/getautoreplyconf");
276
-
277
-	 $.ajax({
278
-		  url: getnumbersUrl + '/' + userid,
279
-		  type: "GET",
280
-                  contentType: 'application/json',
281
-		  success: function(autoreplydata) {
282
-
283
-                                    $("#autoRplPhoneNb").removeClass('icon-loading');
284
-                                    var cusrDisplayName = autoreplydata.userdisplayname;
285
-                                    var availPhoneNmbrs = autoreplydata.phonenumbers;
286
-                                    var autorpldata = autoreplydata.autoreplies;
287
-
288
-				    if (autorpldata.length > 0) { 
289
-				        var arplNmb = autorpldata.length;
290
-				    } else { 
291
-				        var arplNmb = 0; 
292
-				    }
293
-
294
-				    // List the auto-replies for the phone numbers available for the current user
295
-				    if (arplNmb == 0) {
296
-
297
-				        $("#autoReplyTbl").append("<tr><td><input type='text' class='arplAuthor' value='"+ cusrDisplayName +"' disabled></td><td><select id='arpphn-"+ arplNmb +"' class='arplPhoneNmbr'></select></td><td><div id='arplmode-"+ arplNmb +"' class='arplMode'><select id='modeselect-"+ arplNmb +"' class='selectArplMode'><option value='' selected>Select mode</option><option value='daily'>Daily mode</option><option value='vacation'>Vacation mode</option></select><div id='modecont-"+ arplNmb +"' class='modeContent'></div></div></td><td><textarea id='arpltxt-"+ arplNmb +"' class='arplText' rows='20' cols='40' placeholder='Enter the auto-reply message here.'></textarea></td><td><img id='rmRow-"+ arplNmb +"' class='removeRow' src='/apps/sms_relentless/img/closewnd.svg' title='Remove this row from the database' style='cursor:pointer;margin:9px 8px 0px 18px;'></td><td><input type='submit' id='arplsave-"+ arplNmb +"' class='saveAutoReply' value='Save' title='Save Row' /></td></tr>");
298
-				        $("#autoReplyTbl").append("<div><img id='addArplRow' src='/apps/sms_relentless/img/add.svg' title='Add Row'></div>");
299
-
300
-				    } else {
301
-
302
-				        for (k = 0; k < arplNmb; k++) {
303
-
304
-                                             if (autorpldata[k].days_of_week != '') {
305
-
306
-                                                 var slctdMode = "<option value=''>Select mode</option><option value='daily' selected>Daily mode</option><option value='vacation'>Vacation mode</option>";
307
-                                                 var dailyStartArr = autorpldata[k].daily_start.split(":");
308
-                                                 var dailyEndArr = autorpldata[k].daily_end.split(":");
309
-
310
-		                                 var dlHrStartOptions = "";
311
-			                         for (var hr = 0; hr < 24; hr++) {
312
-		                                      if (dailyStartArr[0] != hr.toLocaleString('en-US', {minimumIntegerDigits: 2, useGrouping:false})) {
313
-			                                  dlHrStartOptions += "<option value='"+ hr.toLocaleString('en-US', {minimumIntegerDigits: 2, useGrouping:false}) +"'>"+ hr.toLocaleString('en-US', {minimumIntegerDigits: 2, useGrouping:false}) +"</option>";
314
-		                                      } else {
315
-			                                  dlHrStartOptions += "<option value='"+ hr.toLocaleString('en-US', {minimumIntegerDigits: 2, useGrouping:false}) +"' selected>"+ hr.toLocaleString('en-US', {minimumIntegerDigits: 2, useGrouping:false}) +"</option>";
316
-		                                      }
317
-			                         }
318
-
319
-		                                 var dlMnStartOptions = "";
320
-			                         for (var mn = 0; mn < 60; mn++) {
321
-		                                      if (dailyStartArr[0] != mn.toLocaleString('en-US', {minimumIntegerDigits: 2, useGrouping:false})) {
322
-			                                  dlMnStartOptions += "<option value='"+ mn.toLocaleString('en-US', {minimumIntegerDigits: 2, useGrouping:false}) +"'>"+ mn.toLocaleString('en-US', {minimumIntegerDigits: 2, useGrouping:false}) +"</option>";
323
-		                                      } else {
324
-			                                  dlMnStartOptions += "<option value='"+ mn.toLocaleString('en-US', {minimumIntegerDigits: 2, useGrouping:false}) +"' selected>"+ mn.toLocaleString('en-US', {minimumIntegerDigits: 2, useGrouping:false}) +"</option>";
325
-		                                      }
326
-			                         }
327
-
328
-		                                 var dlHrEndOptions = "";
329
-			                         for (var hr = 0; hr < 24; hr++) {
330
-		                                      if (dailyEndArr[0] != hr.toLocaleString('en-US', {minimumIntegerDigits: 2, useGrouping:false})) {
331
-			                                  dlHrEndOptions += "<option value='"+ hr.toLocaleString('en-US', {minimumIntegerDigits: 2, useGrouping:false}) +"'>"+ hr.toLocaleString('en-US', {minimumIntegerDigits: 2, useGrouping:false}) +"</option>";
332
-		                                      } else {
333
-			                                  dlHrEndOptions += "<option value='"+ hr.toLocaleString('en-US', {minimumIntegerDigits: 2, useGrouping:false}) +"' selected>"+ hr.toLocaleString('en-US', {minimumIntegerDigits: 2, useGrouping:false}) +"</option>";
334
-		                                      }
335
-			                         }
336
-
337
-		                                 var dlMnEndOptions = "";
338
-			                         for (var mn = 0; mn < 60; mn++) {
339
-		                                      if (dailyEndArr[1] != mn.toLocaleString('en-US', {minimumIntegerDigits: 2, useGrouping:false})) {
340
-			                                  dlMnEndOptions += "<option value='"+ mn.toLocaleString('en-US', {minimumIntegerDigits: 2, useGrouping:false}) +"'>"+ mn.toLocaleString('en-US', {minimumIntegerDigits: 2, useGrouping:false}) +"</option>";
341
-		                                      } else {
342
-			                                  dlMnEndOptions += "<option value='"+ mn.toLocaleString('en-US', {minimumIntegerDigits: 2, useGrouping:false}) +"' selected>"+ mn.toLocaleString('en-US', {minimumIntegerDigits: 2, useGrouping:false}) +"</option>";
343
-		                                      }
344
-			                         }
345
-
346
-                                                 var modeContent = "<div class='daysOfWeek'>Days of the week:<div class='tooltipautoreply'><div id='infoautoreply'>i</div><div class='autorpltooltip'>Enter the order number of the days of the week in which the auto-reply will be sent. For example, to send the auto-reply every day from Monday to Friday (outside the time interval specified below), enter 1,2,3,4,5 To send the auto-reply only Monday, Thursday and Friday enter 1,4,5 To send the auto-reply every day of the week enter 1,2,3,4,5,6,7</div></div></div><input type='text' id='weekdays-"+ k +"' class='daysInWeek' value='"+ autorpldata[k].days_of_week +"'><div class='chooseTInterval'>Send auto-reply <span style='color:#ad0202'>outside</span> this interval:<div class='tooltipautoreplyst'><div id='infoautoreplyst'>i</div><div class='autorpltooltipst'>These fields specify the time of the server. If the server is located in a time zone that is different from that of the owner/company, the time interval entered here should be adjusted accordingly.</div></div></div><div class='selectArplHours'><select id='dmstarthr-"+ k +"' class='selectHrMin'>"+ dlHrStartOptions +"</select><select id='dmstartmn-"+ k +"' class='selectHrMin'>"+ dlMnStartOptions +"</select><span style='font-weight: 600'> — </span><select id='dmendhr-"+ k +"' class='selectHrMin'>"+ dlHrEndOptions +"</select><select id='dmendmn-"+ k +"' class='selectHrMin'>"+ dlMnEndOptions +"</select></div>";
347
-
348
-                                             } else {
349
-
350
-                                                 var vctnStart = autorpldata[k].vacation_start.split(" ")[0];
351
-                                                 var vctnEnd = autorpldata[k].vacation_end.split(" ")[0];
352
-
353
-                                                 var slctdMode = "<option value=''>Select mode</option><option value='daily'>Daily mode</option><option value='vacation' selected>Vacation mode</option>";
354
-                                                 var modeContent = "<div class='chooseDateIntvl'>Send auto-reply <span style='color:#ad0202'>inside</span> this interval:</div><div class='arplstrtendDates'><div class='stdtTitle'>Start Date</div><input type='text' id='startDT-"+ k +"' class='startDate' placeholder='Pick a date' value='"+ vctnStart +"'><div class='enddtTitle'>End Date</div><input type='text' id='endDT-"+ k +"' class='endDate' placeholder='Pick a date' value='"+ vctnEnd +"'></div>"
355
-                                             }
356
-
357
-				             $("#autoReplyTbl").append("<tr><td><input type='text' class='arplAuthor' value='"+ autorpldata[k].saved_by_dsplname +"' disabled></td><td><select id='arpphn-"+ k +"' class='arplPhoneNmbr' style='pointer-events:none'><option selected>"+ autorpldata[k].phone_number +"</option></select></td><td><div id='arplmode-"+ k +"' class='arplMode'><select id='modeselect-"+ k +"' class='selectArplMode'>"+ slctdMode +"</select><div id='modecont-"+ k +"' class='modeContent'>"+ modeContent +"</div></div></td><td><textarea id='arpltxt-"+ k +"' class='arplText' rows='20' cols='40' placeholder='Enter the auto-reply message here.'>"+ autorpldata[k].message_text +"</textarea></td><td><img id='rmRow-"+ k +"' class='removeRow' src='/apps/sms_relentless/img/closewnd.svg' title='Remove this row from the database' style='cursor:pointer;margin:9px 8px 0px 18px;'></td><td><input type='submit' id='arplsave-"+ k +"' class='saveAutoReply' value='Edit' title='Edit Row' /></td></tr>");
358
-				        }
359
-				        $("#autoReplyTbl").append("<div><img id='addArplRow' src='/apps/sms_relentless/img/add.svg' title='Add Row'></div>");
360
-				    }
361
-
362
-
363
-				    // Create a list with all the available phone numbers
364
-                                    var numbersListItems = "<option value='' selected>Select phone number</option>";
365
-
366
-				    $.each(availPhoneNmbrs, function(key, indsmsnmb) {
367
-				           numbersListItems += "<option value='"+ indsmsnmb +"'>"+ indsmsnmb +"</option>";
368
-				    });
369
-
370
-                                    if (arplNmb == 0) {
371
-				        $("#arpphn-"+ arplNmb).append(numbersListItems);
372
-                                    }
373
-
374
-                                    // Initialize the date picker
375
-			            $('[id^="endDT-"]').datepicker({ dateFormat: "yy-mm-dd" });
376
-			            $('[id^="startDT-"]').datepicker({ dateFormat: "yy-mm-dd" });
377
-
378
-
379
-                                    // Select the auto-reply mode
380
-                                    function selectMode() {
381
-
382
-		                            $('[id^="modeselect-"]').change(function() {
383
-
384
-		                               var crtnmbr = $(this).attr("id").replace("modeselect-", "");
385
-
386
-		                               var dailyHrStart = "";
387
-		                               for (var h = 0; h < 24; h++) {
388
-		                                    dailyHrStart += "<option value='"+ h.toLocaleString('en-US', {minimumIntegerDigits: 2, useGrouping:false}) +"'>"+ h.toLocaleString('en-US', {minimumIntegerDigits: 2, useGrouping:false}) +"</option>";
389
-		                               }
390
-
391
-		                               var dailyMnStart = "";
392
-		                               for (var m = 0; m < 60; m++) {
393
-		                                    dailyMnStart += "<option value='"+ m.toLocaleString('en-US', {minimumIntegerDigits: 2, useGrouping:false}) +"'>"+ m.toLocaleString('en-US', {minimumIntegerDigits: 2, useGrouping:false}) +"</option>";
394
-		                               }
395
-
396
-		                               var dailyHrEnd = dailyHrStart;
397
-		                               var dailyMnEnd = dailyMnStart;
398
-
399
-		                               if ($(this).val() == 'daily') {
400
-		                                   $("#modecont-"+ crtnmbr).empty();
401
-		                                   $("#modecont-"+ crtnmbr).append("<div class='daysOfWeek'>Days of the week:<div class='tooltipautoreply'><div id='infoautoreply'>i</div><div class='autorpltooltip'>Enter the order number of the days of the week. For example, to send the auto-reply every day from Monday to Friday outside the specified time interval, enter 1,2,3,4,5 To send the auto-reply only Monday, Thursday and Friday enter 1,4,5 To send the auto-reply every day of the week enter 1,2,3,4,5,6,7</div></div></div><input type='text' id='weekdays-"+ crtnmbr +"' class='daysInWeek'><div class='chooseTInterval'>Send auto-reply <span style='color:#ad0202'>outside</span> this interval:<div class='tooltipautoreplyst'><div id='infoautoreplyst'>i</div><div class='autorpltooltipst'>These fields specify the time of the server. If the server is located in a time zone that is different from that of the owner/company, the time interval entered here should be adjusted accordingly.</div></div></div><div class='selectArplHours'><select id='dmstarthr-"+ crtnmbr +"' class='selectHrMin'>"+ dailyHrStart +"</select><select id='dmstartmn-"+ crtnmbr +"' class='selectHrMin'>"+ dailyMnStart +"</select><span style='font-weight: 600'> — </span><select id='dmendhr-"+ crtnmbr +"' class='selectHrMin'>"+ dailyHrEnd +"</select><select id='dmendmn-"+ crtnmbr +"' class='selectHrMin'>"+ dailyMnEnd +"</select></div>");
402
-		                               } else if ($(this).val() == 'vacation') {
403
-		                                   $("#modecont-"+ crtnmbr).empty();
404
-		                                   $("#modecont-"+ crtnmbr).append("<div class='chooseDateIntvl'>Send auto-reply <span style='color:#ad0202'>inside</span> this interval:</div><div class='arplstrtendDates'><div class='stdtTitle'>Start Date</div><input type='text' id='startDT-"+ crtnmbr +"' class='startDate' placeholder='Pick a date'><div class='enddtTitle'>End Date</div><input type='text' id='endDT-"+ crtnmbr +"' class='endDate' placeholder='Pick a date' /></div>");
405
-		                               }
406
-
407
-					       $("#endDT-"+ crtnmbr +"").datepicker({ dateFormat: "yy-mm-dd" });
408
-					       $("#startDT-"+ crtnmbr +"").datepicker({ dateFormat: "yy-mm-dd" });
409
-		                          });
410
-                                  }
411
-                                  selectMode();
412
-
413
-				  // Save the data
414
-				  function saveArplRow() {
415
-
416
-				     $('[id^="arplsave-"]').unbind("click");
417
-				     $('[id^="arplsave-"]').click(function(event) {
418
-
419
-				        event.preventDefault();
420
-				        var crntrwnmbr = $(this).attr("id").replace("arplsave-", "");
421
-
422
-				        if ($(this).attr("value") == "Save") {
423
-
424
-				            var phoneNmbr = $("#arpphn-"+ crntrwnmbr).val();
425
-				            var arplText = $("#arpltxt-"+ crntrwnmbr).val();
426
-				            var slctdMode = $("#modeselect-"+ crntrwnmbr).val();
427
-
428
-				            var slctddmDays = "";
429
-				            var slctdHrStart = "";
430
-				            var slctdMnStart = "";
431
-				            var slctdHrEnd = "";
432
-				            var slctdMnEnd = "";
433
-
434
-				            var vcStartDate = null;
435
-				            var vcEndDate = null;
436
-
437
-				            if (slctdMode == 'daily') {
438
-
439
-				                slctddmDays = $("#weekdays-"+ crntrwnmbr).val().trim();
440
-				                slctdHrStart = $("#dmstarthr-"+ crntrwnmbr).val().trim();
441
-				                slctdMnStart = $("#dmstartmn-"+ crntrwnmbr).val().trim();
442
-				                slctdHrEnd = $("#dmendhr-"+ crntrwnmbr).val().trim();
443
-				                slctdMnEnd = $("#dmendmn-"+ crntrwnmbr).val().trim();
444
-
445
-                                                if (slctdHrStart != '' && slctdMnStart != '') {
446
-                                                    var hrmnStartComp = slctdHrStart +":"+ slctdMnStart;
447
-                                                } else { var hrmnStartComp = ""; }
448
-
449
-                                                if (slctdHrEnd != '' && slctdMnEnd != '') {
450
-                                                    var hrmnEndComp = slctdHrEnd +":"+ slctdMnEnd;
451
-                                                } else { var hrmnEndComp = ""; }
452
-
453
-                                                if (!(/^[1-7\,]+$/.test(slctddmDays))) {
454
-				                    showAlert("The 'Days of the week' field can contain only digits from 1 to 7 and commas (,).");
455
-				                    return;
456
-                                                }
457
-
458
-                                                if (!(/^[0-9]+$/.test(slctdHrStart + slctdMnStart + slctdHrEnd + slctdMnEnd))) {
459
-				                    showAlert("The starting and ending values of the time interval for the 'Daily mode' can contain only digits from 0 to 9.");
460
-				                    return;
461
-                                                }
462
-
463
-                                                if (slctddmDays.trim() == '' || (slctdHrStart == slctdHrEnd && slctdMnStart == slctdMnEnd)) {
464
-				                    showAlert("For the 'Daily mode', you have to enter the order number of the days of the week for which you want the auto-reply to be sent, and you have to set a starting time that is different from the ending time!");
465
-				                    return;
466
-                                                }
467
-
468
-				            } else if (slctdMode == 'vacation') {
469
-		
470
-                                                if ($("#startDT-"+ crntrwnmbr).val().trim() == '' || $("#endDT-"+ crntrwnmbr).val().trim() == '') {
471
-
472
-				                    showAlert("For the 'Vacation mode', you have to enter both a start date and an end date.");
473
-				                    return;
474
-
475
-                                                } else {
476
-
477
-                                                    if (!(/^[0-9\-]+$/.test($("#startDT-"+ crntrwnmbr).val().trim() + $("#endDT-"+ crntrwnmbr).val().trim()))) {
478
-				                        showAlert("The start date and end date values for the 'Vacation mode' can contain only digits from 0 to 9 and hyphens (-).");
479
-				                        return;
480
-                                                    }
481
-
482
-		                                    vcStartDate = $("#startDT-"+ crntrwnmbr).val().trim() +" 00:00:00";
483
-				                    vcEndDate = $("#endDT-"+ crntrwnmbr).val().trim() +" 23:59:59";
484
-				                    var strtDateCmp = new Date(vcStartDate).toJSON().slice(0, 10) +" 00:00:00";
485
-				                    var endDateCmp = new Date(vcEndDate).toJSON().slice(0, 10) +" 23:59:59";
486
-				                    var crntDate = new Date().toJSON().slice(0, 10) +" 23:59:59";
487
-
488
-                                                    if (vcStartDate.trim() == "" || vcEndDate.trim() == "" || (strtDateCmp >= endDateCmp || ((strtDateCmp < crntDate) && (endDateCmp < crntDate)))) {
489
-				                        showAlert("For 'Vacation mode', you have to enter both a start date and an end date, the start date must be before the end date and at least the ending of the time interval must be in the future.");
490
-				                        return;
491
-                                                    }
492
-                                                }
493
-				            }
494
-
495
-
496
-				            if (phoneNmbr != '') {
497
-
498
-				              if (arplText.trim() != '') {
499
-
500
-				                if (slctdMode != '') {
501
-
502
-				                    var saveArplUrl = OC.generateUrl('/apps/sms_relentless/user/updateautoreplies');
503
-				                    var arpldata = {
504
-				                         userId: userid,
505
-				                         savedByDsplname: cusrDisplayName,
506
-				                         phoneNumber: phoneNmbr,
507
-				                         daysOfWeek: slctddmDays,
508
-				                         dailyStart: hrmnStartComp,
509
-				                         dailyEnd: hrmnEndComp,
510
-				                         vacationStart: vcStartDate,
511
-				                         vacationEnd: vcEndDate,
512
-				                         messageText: arplText
513
-				                    };
514
-
515
-					            $.ajax({
516
-					              method: 'PUT',
517
-					              url: saveArplUrl + '/' + userid,
518
-					              contentType: 'application/json',
519
-					              data: JSON.stringify(arpldata),
520
-				                      success: function(messagereceived) {
521
-
522
-				                                   if (messagereceived == 'success') {
523
-				                                       showAlert('The auto-reply has been successfully saved to the database!');
524
-				                                   } else if (messagereceived == 'failure') {
525
-				                                       showAlert('Error while trying to save the auto-reply!');
526
-				                                   } else if (messagereceived == 'not allowed') {
527
-                                                                       showAlert('You cannot change an auto-reply that was saved by a different user.');
528
-                                                                   }
529
-				                      },
530
-					              error: function() {
531
-						                   showAlert('Error while attempting to save the auto-reply! You can check the Nextcloud log to find more details about this issue.');
532
-					              }
533
-					            });
534
-
535
-
536
-                                                } else { showAlert("Please select the auto-reply mode."); return; }
537
-
538
-                                              } else { showAlert("Please enter the text of the auto-reply."); return; }
539
-
540
-                                            } else { showAlert("Please select a phone number if at least one number is available in the 'Phone Number' drop-down list. Otherwise, you should contact the administrator."); return; }
541
-
542
-                                            $(this).attr("value", "Edit");
543
-
544
-                                        } else {
545
-                                            $("#arplsave-"+ crntrwnmbr).attr("value", "Save");
546
-                                        }
547
-
548
-                                     });
549
-
550
-				  }
551
-                                  saveArplRow();
552
-
553
-
554
-				  // Remove a row
555
-				  function removeArplRow() {
556
-				       $('[id^="rmRow-"]').click(function() {
557
-
558
-					  var slctRowRm = $(this).attr("id").replace("rmRow-", "");
559
-					  var crntPhnNmbr = $("#arpphn-"+ slctRowRm).val();
560
-
561
-				          confirmAlert("Do you really want to remove this row from the database ?");
562
-
563
-				          $("#confirmCancel").click(function() { $("#alertMsgOverlay").remove(); $("#alertConfMessage").remove(); });
564
-
565
-				          $("#confirmOk").click(function() {
566
-
567
-				              $("#alertMsgOverlay").remove();
568
-				              $("#alertConfMessage").remove();
569
-
570
-					      var rmvArplUrl = OC.generateUrl('/apps/sms_relentless/user/removeautoreplies');
571
-					      $.ajax({
572
-						   url: rmvArplUrl + '/' + userid,
573
-						   method: "POST",
574
-						   dataType: "text",
575
-						   data: { phoneNumber: crntPhnNmbr },
576
-						   success: function(delresult) {
577
-
578
-						                     if (delresult.indexOf("success") > -1) {
579
-						                         showAlert("The auto-reply has been removed successfully!");
580
-						                         $("#arpphn-"+ slctRowRm).closest("tr").remove();
581
-						                     } else if (delresult.indexOf("failure") > -1) {
582
-						                         showAlert("Error while trying to remove auto-reply data!");
583
-						                     } else if (delresult.indexOf("not allowed") > -1) {
584
-                                                                         showAlert("You cannot remove the auto-reply saved by another user.");
585
-                                                                     }
586
-						   },
587
-						   error: function() { showAlert("Error while attempting to remove auto-reply data! You can check the Nextcloud log to find more details about this issue."); }
588
-					       });
589
-					  });
590
-				       });
591
-				  }
592
-				  removeArplRow();
593
-
594
-                                  // Add a new row
595
-                                  $("#addArplRow").click(function() {
596
-
597
-                                     if ($("#autoReplyTbl").find("tr:last-child").find(".arplPhoneNmbr").length > 0) {
598
-                                         var lastarpl = $("#autoReplyTbl").find("tr:last-child").find(".arplPhoneNmbr").attr("id").replace("arpphn-", "");
599
-                                         var indArplAdd = parseInt(lastarpl + 1);
600
-                                     } else { var indArplAdd = 0; }
601
-			             $("#autoReplyTbl").append("<tr><td><input type='text' class='arplAuthor' value='"+ cusrDisplayName +"' disabled></td><td><select id='arpphn-"+ indArplAdd +"' class='arplPhoneNmbr'>"+ numbersListItems +"</select></td><td><div id='arplmode-"+ indArplAdd +"' class='arplMode'><select id='modeselect-"+ indArplAdd +"' class='selectArplMode'><option value='' selected>Select mode</option><option value='daily'>Daily mode</option><option value='vacation'>Vacation mode</option></select><div id='modecont-"+ indArplAdd +"' class='modeContent'></div></div></td><td><textarea id='arpltxt-"+ indArplAdd +"' class='arplText' rows='20' cols='40' placeholder='Enter the auto-reply message here.'></textarea></td><td><img id='rmRow-"+ indArplAdd +"' class='removeRow' src='/apps/sms_relentless/img/closewnd.svg' title='Remove this row from the database' style='cursor:pointer;margin:9px 8px 0px 18px;'></td><td><input type='submit' id='arplsave-"+ indArplAdd +"' class='saveAutoReply' value='Save' title='Save Row' /></td></tr>");
602
-
603
-                                     selectMode();
604
-                                     saveArplRow();
605
-                                     removeArplRow();
606
-
607
-			             // Check if there is an auto-reply set for the same phone number
608
-				     $("#arpphn-"+ indArplAdd).change(function() {
609
-					 var selectedPhNb = $("#arpphn-"+ indArplAdd).val();
610
-					 var allArplPhNmbrs = $("#autoReplyTbl").find("tr").find(".arplPhoneNmbr");
611
-					 var phNbChck = 0;
612
-					 allArplPhNmbrs.each(function() {
613
-					    var slctphnb = ($(this).val())? $(this).val() : $(this).text();
614
-					    if (selectedPhNb == slctphnb) { phNbChck++; }
615
-					 });
616
-
617
-					 if (phNbChck == 2) {
618
-					     showAlert("There is already an auto-reply set up for this phone number. Please edit its own row, or choose a different phone number.");
619
-					     $(this).val('');
620
-					     return;
621
-					 }
622
-				     });
623
-                                  });
624
-
625
-		  },
626
-		  error: function() {
627
-                                    $("#autoRplPhoneNb").removeClass('icon-loading'); 
628
-                                    showAlert("Error while attempting to get the auto-reply settings! You can check the Nextcloud log to find more details about this issue.");
629
-                  }
630
-         });
631
-
632
-     },
633
-     error: function() {
634
-                  showAlert('Error while getting the settings! You can check the Nextcloud log to find more details about this issue.');
635
-     }
636
-  });
637
-
638
-
639
-
640
-  // Save personal settings for non-admin users
641
-  $("#save_sms_settings").on("click", function(event) {
642
-
643
-     if (isadm == 'reguser') {
644
-
645
-	    event.preventDefault();
646
-	    var baseUrlsave = OC.generateUrl('/apps/sms_relentless/user/updatesettings');
647
-
648
-	    var messagesperpageinit = $("#messagesperpage").val();
649
-	    var messagesperpagesec = messagesperpageinit.replace(/[^0-9]/g, '');
650
-
651
-	    if (messagesperpagesec != '') {
652
-		var messagesperpageproc = messagesperpagesec;
653
-	    } else {
654
-		var messagesperpageproc = 100;
655
-	    }
656
-
657
-	    var getnotify = 0;
658
-
659
-	    if ($("#get_notify").is(':checked')) {
660
-		getnotify = 1;
661
-	    }
662
-
663
-	    var emailaddressinit = $("#notification_email").val();
664
-
665
-	    function validate_email($email) {
666
-		var email_reg = /^([\w-\.]+@([\w-]+\.)+[\w-]{2,4})?$/;
667
-		return email_reg.test($email);
668
-	    }
669
-
670
-	    if (validate_email(emailaddressinit)) {
671
-		 var notifyemail = emailaddressinit;
672
-	    } else {
673
-		 var notifyemail = '';
674
-	    }
675
-
676
-	    var includesmsinemail = 0;
677
-	    if ($("#includesmsinemail").is(':checked')) {
678
-		includesmsinemail = 1;
679
-                if ($("#notification_email").val().trim() == '') {
680
-                    showAlert("Please enter an email address in the field: 'I want to receive a notification to the email address from below ...', or uncheck the checkbox: 'Include the SMS/MMS message in the email notification itself'.");
681
-                    return;
682
-                }
683
-	    }
684
-
685
-	    var showdisplaynm = 0;
686
-	    if ($("#showdisplaynames").is(':checked')) {
687
-		showdisplaynm = 1;
688
-	    }
689
-
690
-	    var datatosave = {
691
-			      userId: userid,
692
-		              telapiUrlRec: $("#telapi_url_rec").val(),
693
-		              telapiUrl: $("#telapi_url").val(),
694
-		              nexapiUrlRec: $("#nexapi_url_rec").val(),
695
-		              nexapiUrl: $("#nexapi_url").val(),
696
-		              twilapiUrlRec: $("#twilapi_url_rec").val(),
697
-		              twilapiUrl: $("#twilapi_url").val(),
698
-		              flowapiUrlRec: $("#flowapi_url_rec").val(),
699
-		              flowapiUrl: $("#flowapi_url").val(),
700
-			      messagesperpage: messagesperpageproc,
701
-			      getNotify: getnotify,
702
-			      notificationEmail: notifyemail,
703
-			      getsmsinemail: includesmsinemail,
704
-			      showDisplayNames: showdisplaynm
705
-	    };
706
-
707
-
708
-	    $.ajax({
709
-	       method: 'PUT',
710
-	       url: baseUrlsave + '/' + userid,
711
-	       contentType: 'application/json',
712
-	       data: JSON.stringify(datatosave),
713
-	       success: function() {
714
-                               OC.msg.startAction('#smsr_save_msg', t('sms_relentless', 'Saved'));
715
-	       },
716
-	       error: function() {
717
-		    showAlert('Error while attempting to save the settings! You can check the Nextcloud log to find more details about this issue.');
718
-	       }
719
-	    });
720
-
721
-
722
-     } else if (isadm == 'admin') {
723
-
724
-	    // Save personal settings for admins
725
-	    event.preventDefault();
726
-	    var baseUrlsaveadm = OC.generateUrl('/apps/sms_relentless/user/updatepersadmnsettings');
727
-
728
-	    var messagesperpageinit = $("#messagesperpage").val();
729
-	    var messagesperpagesec = messagesperpageinit.replace(/[^0-9]/g, '');
730
-
731
-	    if (messagesperpagesec != '') {
732
-		var messagesperpageproc = messagesperpagesec;
733
-	    } else {
734
-		var messagesperpageproc = 100;
735
-	    }
736
-
737
-	    var getnotify = 0;
738
-
739
-	    if ($("#get_notify").is(':checked')) {
740
-		getnotify = 1;
741
-	    }
742
-
743
-	    var emailaddressinit = $("#notification_email").val();
744
-
745
-	    function validate_email($email) {
746
-		var email_reg = /^([\w-\.]+@([\w-]+\.)+[\w-]{2,4})?$/;
747
-		return email_reg.test($email);
748
-	    }
749
-
750
-	    if (validate_email(emailaddressinit)) {
751
-		 var notifyemail = emailaddressinit;
752
-	    } else {
753
-		 var notifyemail = '';
754
-	    }
755
-
756
-	    var includesmsinemail = 0;
757
-	    if ($("#includesmsinemail").is(':checked')) {
758
-		includesmsinemail = 1;
759
-                if ($("#notification_email").val().trim() == '') {
760
-                    showAlert("Please enter an email address in the field: 'I want to receive a notification to the email address from below ...', or uncheck the checkbox: 'Include the SMS/MMS message in the email notification itself'.");
761
-                    return;
762
-                }
763
-	    }
764
-
765
-	    var showdisplaynm = 0;
766
-	    if ($("#showdisplaynames").is(':checked')) {
767
-		showdisplaynm = 1;
768
-	    }
769
-
770
-	    var datatosave = {
771
-			      userId: userid,
772
-			      messagesperpage: messagesperpageproc,
773
-			      getNotify: getnotify,
774
-			      notificationEmail: notifyemail,
775
-			      getsmsinemail: includesmsinemail,
776
-			      showDisplayNames: showdisplaynm
777
-	    };
778
-
779
-
780
-	    $.ajax({
781
-	       method: 'PUT',
782
-	       url: baseUrlsaveadm + '/' + userid,
783
-	       contentType: 'application/json',
784
-	       data: JSON.stringify(datatosave),
785
-	       success: function() {
786
-                               OC.msg.startAction('#smsr_save_msg', t('sms_relentless', 'Saved'));
787
-	       },
788
-	       error: function() {
789
-		    showAlert('Error while attempting to save the settings! You can check the Nextcloud log to find more details about this issue.');
790
-	       }
791
-	    });
792
-
793
-     }
794
-  });
795
-
796
-  function showAlert(alertText) {
797
-
798
-     let alertwnd = "<div id='alertMessage'>";
799
-     alertwnd += "<a id='closeAlertWnd' title='Close this window'></a>";
800
-     alertwnd += "<div id='alertTextWrap'>"+ alertText +"</div>";
801
-     alertwnd += "<input type='submit' id='alertOk' value='OK'>";
802
-     alertwnd += "</div>";
803
-
804
-     $("#content").append("<div id='alertMsgOverlay'></div>");
805
-     $("#content").append(alertwnd);
806
-
807
-     let topDist = parseInt((window.innerHeight / 2).toFixed(2) - 152) +"px";
808
-     let leftDist = parseInt((window.innerWidth / 2).toFixed(2) - 150) +"px";
809
-     $("#alertMessage").css({ "top" : topDist, "left" : leftDist });
810
-
811
-     $("#closeAlertWnd").click(function() { $("#alertMsgOverlay").remove(); $("#alertMessage").remove(); });
812
-     $("#alertMsgOverlay").click(function() { $("#alertMsgOverlay").remove(); $("#alertMessage").remove(); });
813
-     $("#alertOk").click(function() { $("#alertMsgOverlay").remove(); $("#alertMessage").remove(); });
814
-  }
815
-
816
-  function confirmAlert(alertText) {
817
-
818
-     let alertwndcf = "<div id='alertConfMessage'>";
819
-     alertwndcf += "<a id='closeAlertWndcf' title='Close this window'></a>";
820
-     alertwndcf += "<div id='alertTextWrap'>"+ alertText +"</div>";
821
-     alertwndcf += "<div id='cancelOkWrap'><input type='submit' id='confirmCancel' value='Cancel'>";
822
-     alertwndcf += "<input type='submit' id='confirmOk' value='OK'></div>";
823
-     alertwndcf += "</div>";
824
-
825
-     $("#content").append("<div id='alertMsgOverlay'></div>");
826
-     $("#content").append(alertwndcf);
827
-
828
-     let topDist = parseInt((window.innerHeight / 2).toFixed(2) - 152) +"px";
829
-     let leftDist = parseInt((window.innerWidth / 2).toFixed(2) - 150) +"px";
830
-     $("#alertConfMessage").css({ "top" : topDist, "left" : leftDist });
831
-
832
-     $("#closeAlertWndcf").click(function() { $("#alertMsgOverlay").remove(); $("#alertConfMessage").remove(); });
833
-     $("#alertMsgOverlay").click(function() { $("#alertMsgOverlay").remove(); $("#alertConfMessage").remove(); });
834
-  }
835
-
836
-});
Browse code

added CHANGELOG.txt appinfo/info.xml appinfo/signature.json css/style.css img/closewnd.svg js/adminsettings.js js/deleteoldsms.js ...

DoubleBastionAdmin authored on 23/05/2023 19:00:54
Showing 1 changed files
1 1
new file mode 100644
... ...
@@ -0,0 +1,836 @@
1
+/**
2
+ * @copyright 2021 Double Bastion LLC <www.doublebastion.com>
3
+ *
4
+ * @author Double Bastion LLC
5
+ *
6
+ * @license GNU AGPL version 3 or any later version
7
+ *
8
+ * This program is free software; you can redistribute it and/or
9
+ * modify it under the terms of the GNU AFFERO GENERAL PUBLIC LICENSE
10
+ * License as published by the Free Software Foundation; either
11
+ * version 3 of the License, or any later version.
12
+ *
13
+ * This program is distributed in the hope that it will be useful,
14
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
15
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
16
+ * GNU AFFERO GENERAL PUBLIC LICENSE for more details.
17
+ *
18
+ * You should have received a copy of the GNU Affero General Public
19
+ * License along with this program.  If not, see <http://www.gnu.org/licenses/>.
20
+ *
21
+ */
22
+
23
+$(document).ready(function() {
24
+
25
+  var userid = "<?php p($userId); ?>";
26
+  var isadm = '';
27
+
28
+  // Get personal settings
29
+  var baseUrlget = OC.generateUrl('/apps/sms_relentless/user/getsettings');
30
+
31
+  $.ajax({
32
+     method: 'GET',
33
+     url: baseUrlget + '/' + userid,
34
+     contentType: 'application/json',
35
+     success: function(settingsfromdb) {
36
+
37
+         // Add the webhook URLs section, if the user is not an admin
38
+         if (settingsfromdb.adminornot == 'reguser') {
39
+
40
+             isadm = 'reguser';
41
+
42
+             $("#appTitlePrg").append('<p id="settings-dscr"><h3>Enter your options in the fields from below. As a non-admin user, you can use any of the SMS service providers from \
43
+                  below, on the condition that an admin has shared with you his API keys for that provider:</h3></p><br>');
44
+
45
+             $("#nadmProvSection").append('<div class="providerSettings"><p><label for="telapi_url_rec" class="setlabeltext"><b>Telnyx webhook URL for incoming SMS/MMS</b> (Generate \
46
+                  the URL by pressing the button from below. Don\'t forget to also click the \'Save\' button at the bottom of this page after entering all the options, to save \
47
+                  all the settings to the database.)</label></p> \
48
+                  <input type="button" id="generate_tel_rcpt" class="generateUrl" value="Generate new webhook URL for incoming SMS/MMS" /> \
49
+                  <input type="text" class="smsr_textboxspec" id="telapi_url_rec" name="telapi_url_rec" autocomplete="false" /> \
50
+                  <span id="copyToClipboardtel" class="icon icon-clippy" title="Copy to clipboard"></span><br><br> \
51
+                  \
52
+                  <p><label for="telapi_url" class="setlabeltext"><b>Telnyx webhook URL for delivery receipts</b> (This URL will be included by SMS Relentless in message sending \
53
+                  requests, so that Telnyx will know where to send the delivery receipts. Just generate it by pressing the button from below. Don\'t forget to click the \'Save\' \
54
+                  button at the bottom of this page after entering all the options, to save all the settings to the database.)</label></p> \
55
+                  <input type="button" id="generate_tel_delrcpt" class="generateUrl" value="Generate new webhook URL for delivery receipts" /> \
56
+                  <input type="text" id="telapi_url" name="telapi_url" autocomplete="false" /></div><br><br> \
57
+                  \
58
+                  <div class="providerSettings"><p><label for="nexapi_url_rec" class="setlabeltext"><b>Plivo webhook URL for incoming SMS/MMS</b> (Generate the URL by pressing \
59
+                  the button from below. Don\'t forget to also click the \'Save\' button at the bottom of this page after entering all the options, to save all the settings \
60
+                  to the database.)</label></p> \
61
+                  <input type="button" id="generate_nex_rcpt" class="generateUrl" value="Generate new webhook URL for incoming SMS/MMS" /> \
62
+                  <input type="text" class="smsr_textboxspec" id="nexapi_url_rec" name="nexapi_url_rec" autocomplete="false" /> \
63
+                  <span id="copyToClipboardnex" class="icon icon-clippy" title="Copy to clipboard"></span><br><br> \
64
+                  \
65
+                  <p><label for="nexapi_url" class="setlabeltext"><b>Plivo webhook URL for delivery receipts</b> (This URL will be included by SMS Relentless in message sending \
66
+                  requests, so that Plivo will know where to send the delivery receipts. Just generate it by pressing the button from below. Don\'t forget to click the \'Save\' \
67
+                  button at the bottom of this page after entering all the options, to save all the settings to the database.)</label></p> \
68
+                  <input type="button" id="generate_nex_delrcpt" class="generateUrl" value="Generate new webhook URL for delivery receipts" /> \
69
+                  <input type="text" id="nexapi_url" name="nexapi_url" autocomplete="false" /></div><br><br> \
70
+                  \
71
+                  <div class="providerSettings"><p><label for="twilapi_url_rec" class="setlabeltext"><b>Twilio webhook URL for incoming SMS/MMS</b> (Generate the URL by pressing \
72
+                  the button from below. Don\'t forget to also click the \'Save\' button at the bottom of this page after entering all the options, to save all the settings to \
73
+                  the database.)</label></p> \
74
+                  <input type="button" id="generate_twil_rcpt" class="generateUrl" value="Generate new webhook URL for incoming SMS/MMS" /> \
75
+                  <input type="text" class="smsr_textboxspec" id="twilapi_url_rec" name="twilapi_url_rec" autocomplete="false" /> \
76
+                  <span id="copyToClipboardtwil" class="icon icon-clippy" title="Copy to clipboard"></span><br><br> \
77
+                  \
78
+                  <p><label for="twilapi_url" class="setlabeltext"><b>Twilio webhook URL for delivery receipts</b> (This URL will be included by SMS Relentless in message sending \
79
+                  requests, so that Twilio will know where to send the delivery receipts. Just generate it by pressing the button from below. Don\'t forget to click the \'Save\' \
80
+                  button at the bottom of this page after entering all the options, to save all the settings to the database.)</label></p> \
81
+                  <input type="button" id="generate_twil_delrcpt" class="generateUrl" value="Generate new webhook URL for delivery receipts" /> \
82
+                  <input type="text" id="twilapi_url" name="twilapi_url" autocomplete="false" /></div><br><br> \
83
+                  \
84
+                  <div class="providerSettings"><p><label for="flowapi_url_rec" class="setlabeltext"><b>Flowroute webhook URL for incoming SMS/MMS</b> (Generate the URL by pressing \
85
+                  the button from below. Don\'t forget to also click the \'Save\' button at the bottom of this page after entering all the options, to save all the settings to \
86
+                  the database.)</label></p> \
87
+                  <input type="button" id="generate_flow_rcpt" class="generateUrl" value="Generate new webhook URL for incoming SMS/MMS" /> \
88
+                  <input type="text" class="smsr_textboxspec" id="flowapi_url_rec" name="flowapi_url_rec" autocomplete="false" /> \
89
+                  <span id="copyToClipboardflow" class="icon icon-clippy" title="Copy to clipboard"></span><br><br> \
90
+                  \
91
+                  <p><label for="flowapi_url" class="setlabeltext"><b>Flowroute webhook URL for delivery receipts</b> (This URL will be included by SMS Relentless in message sending \
92
+                  requests, so that Flowroute will know where to send the delivery receipts. Just generate it by pressing the button from below. Don\'t forget to click the \'Save\' \
93
+                  button at the bottom of this page after entering all the options, to save all the settings to the database.)</label></p> \
94
+                  <input type="button" id="generate_flow_delrcpt" class="generateUrl" value="Generate new webhook URL for delivery receipts" /> \
95
+                  <input type="text" id="flowapi_url" name="flowapi_url" autocomplete="false" /><br><br> \
96
+                  Flowroute only supports sending/receiving SMS/MMS messages within USA and Canada and it doesn\'t support Alphanumeric Sender IDs.</div><br>');
97
+
98
+
99
+		  $("#telapi_url_rec").val(settingsfromdb.telapi_url_rec);
100
+		  $("#telapi_url").val(settingsfromdb.telapi_url);
101
+		  $("#nexapi_url_rec").val(settingsfromdb.nexapi_url_rec);
102
+		  $("#nexapi_url").val(settingsfromdb.nexapi_url);
103
+		  $("#twilapi_url_rec").val(settingsfromdb.twilapi_url_rec);
104
+		  $("#twilapi_url").val(settingsfromdb.twilapi_url);
105
+		  $("#flowapi_url_rec").val(settingsfromdb.flowapi_url_rec);
106
+		  $("#flowapi_url").val(settingsfromdb.flowapi_url);
107
+		  $("#messagesperpage").val(settingsfromdb.messagesperpage);
108
+
109
+		  if (settingsfromdb.get_notify == 1) {
110
+		      $("#get_notify").attr('checked', true);
111
+		  } else {
112
+		      $("#get_notify").attr('checked', false);
113
+		  }
114
+
115
+		  $("#notification_email").val(settingsfromdb.notification_email);
116
+
117
+		  if (settingsfromdb.getsmsinemail == 1) {
118
+		      $("#includesmsinemail").attr('checked', true);
119
+		  } else {
120
+		      $("#includesmsinemail").attr('checked', false);
121
+		  }
122
+
123
+		  if (settingsfromdb.show_display_names == 1) {
124
+		      $("#showdisplaynames").attr('checked', true);
125
+		  } else {
126
+		      $("#showdisplaynames").attr('checked', false);
127
+		  }
128
+
129
+		  function randomStr(strlength) {
130
+			var fintext = "";
131
+			var keyspace = '0123456789abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ';
132
+			for (var i = 0; i < strlength; i++) {
133
+			     fintext += keyspace.charAt(Math.floor(Math.random() * keyspace.length));
134
+			}
135
+			return fintext;
136
+		  }
137
+
138
+		  $("#generate_tel_rcpt").on("click", function(event) {
139
+
140
+		     var teltokenrec = randomStr(70);
141
+		     var telnyxwhurlrec = window.location.origin + OC.generateUrl('/apps/sms_relentless/api/recsmstel?telrecparam=') + teltokenrec;
142
+
143
+		     $("#telapi_url_rec").val(telnyxwhurlrec);
144
+		  });
145
+
146
+		  $("#copyToClipboardtel").on("click", function(event) {
147
+		     var $tempEl = $("<input>");
148
+		     $("body").append($tempEl);
149
+		     $tempEl.val($("#telapi_url_rec").val()).select();
150
+		     document.execCommand("Copy");
151
+		     $tempEl.remove();
152
+		     showAlert("The link has been copied to your clipboard!");
153
+		  });
154
+
155
+		  $("#generate_tel_delrcpt").on("click", function(event) {
156
+
157
+		     var teltoken = randomStr(70);
158
+		     var telnyxwhurl = window.location.origin + OC.generateUrl('/apps/sms_relentless/api/recdeliverytel?teldrparam=') + teltoken;
159
+
160
+		     $("#telapi_url").val(telnyxwhurl);
161
+		  });
162
+
163
+
164
+		  $("#generate_nex_rcpt").on("click", function(event) {
165
+
166
+		     var plivotokenrec = randomStr(70);
167
+		     var plivowhurlrec = window.location.origin + OC.generateUrl('/apps/sms_relentless/api/recsmsnex?plivorecparam=') + plivotokenrec;
168
+
169
+		     $("#nexapi_url_rec").val(plivowhurlrec);
170
+		  });
171
+
172
+		  $("#copyToClipboardnex").on("click", function(event) {
173
+		     var $tempElpl = $("<input>");
174
+		     $("body").append($tempElpl);
175
+		     $tempElpl.val($("#nexapi_url_rec").val()).select();
176
+		     document.execCommand("Copy");
177
+		     $tempElpl.remove();
178
+		     showAlert("The link has been copied to your clipboard!");
179
+		  });
180
+
181
+		  $("#generate_nex_delrcpt").on("click", function(event) {
182
+
183
+		     var plivotoken = randomStr(70);
184
+		     var plivodrwhurl = window.location.origin + OC.generateUrl('/apps/sms_relentless/api/recdeliverynex?plivodrparam=') + plivotoken;
185
+
186
+		     $("#nexapi_url").val(plivodrwhurl);
187
+		  });
188
+
189
+
190
+		  $("#generate_twil_rcpt").on("click", function(event) {
191
+
192
+		     var twiltokenrec = randomStr(35);
193
+		     var twilwhurlrec = window.location.origin + OC.generateUrl('/apps/sms_relentless/api/recsmstwil?twilrecparam=') + twiltokenrec;
194
+
195
+		     $("#twilapi_url_rec").val(twilwhurlrec);
196
+		  });
197
+
198
+		  $("#copyToClipboardtwil").on("click", function(event) {
199
+		     var $tempElpl = $("<input>");
200
+		     $("body").append($tempElpl);
201
+		     $tempElpl.val($("#twilapi_url_rec").val()).select();
202
+		     document.execCommand("Copy");
203
+		     $tempElpl.remove();
204
+		     showAlert("The link has been copied to your clipboard!");
205
+		  });
206
+
207
+		  $("#generate_twil_delrcpt").on("click", function(event) {
208
+
209
+		     var twiltoken = randomStr(35);
210
+		     var twildrwhurl = window.location.origin + OC.generateUrl('/apps/sms_relentless/api/recdeliverytwil?twildrparam=') + twiltoken;
211
+
212
+		     $("#twilapi_url").val(twildrwhurl);
213
+		  });
214
+
215
+
216
+		  $("#generate_flow_rcpt").on("click", function(event) {
217
+
218
+		     var flowtokenrec = randomStr(70);
219
+		     var flowwhurlrec = window.location.origin + OC.generateUrl('/apps/sms_relentless/api/recsmsflow?flowrecparam=') + flowtokenrec;
220
+
221
+		     $("#flowapi_url_rec").val(flowwhurlrec);
222
+		  });
223
+
224
+		  $("#copyToClipboardflow").on("click", function(event) {
225
+		     var $tempElpl = $("<input>");
226
+		     $("body").append($tempElpl);
227
+		     $tempElpl.val($("#flowapi_url_rec").val()).select();
228
+		     document.execCommand("Copy");
229
+		     $tempElpl.remove();
230
+		     showAlert("The link has been copied to your clipboard!");
231
+		  });
232
+
233
+		  $("#generate_flow_delrcpt").on("click", function(event) {
234
+
235
+		     var flowtoken = randomStr(70);
236
+		     var flowdrwhurl = window.location.origin + OC.generateUrl('/apps/sms_relentless/api/recdeliveryflow?flowdrparam=') + flowtoken;
237
+
238
+		     $("#flowapi_url").val(flowdrwhurl);
239
+		  });
240
+
241
+
242
+         } else if (settingsfromdb.adminornot == 'admin') {
243
+
244
+                  $("#appTitlePrg").append('<p id="settings-dscr"><h3>Enter your options in the fields from below:</h3></p><br>');
245
+                  isadm = 'admin';
246
+
247
+		  $("#messagesperpage").val(settingsfromdb.messagesperpage);
248
+
249
+		  if (settingsfromdb.get_notify == 1) {
250
+		      $("#get_notify").attr('checked', true);
251
+		  } else {
252
+		      $("#get_notify").attr('checked', false);
253
+		  }
254
+
255
+		  $("#notification_email").val(settingsfromdb.notification_email);
256
+
257
+		  if (settingsfromdb.getsmsinemail == 1) {
258
+		      $("#includesmsinemail").attr('checked', true);
259
+		  } else {
260
+		      $("#includesmsinemail").attr('checked', false);
261
+		  }
262
+
263
+		  if (settingsfromdb.show_display_names == 1) {
264
+		      $("#showdisplaynames").attr('checked', true);
265
+		  } else {
266
+		      $("#showdisplaynames").attr('checked', false);
267
+		  }
268
+         }
269
+
270
+
271
+         // Auto-reply settings
272
+
273
+         // Get the available phone numbers from all providers associated with the access keys entered on the Settings page (restrictions are applied to numbers for non-admins)
274
+         $("#autoRplPhoneNb").addClass('icon-loading');
275
+         var getnumbersUrl = OC.generateUrl("/apps/sms_relentless/user/getautoreplyconf");
276
+
277
+	 $.ajax({
278
+		  url: getnumbersUrl + '/' + userid,
279
+		  type: "GET",
280
+                  contentType: 'application/json',
281
+		  success: function(autoreplydata) {
282
+
283
+                                    $("#autoRplPhoneNb").removeClass('icon-loading');
284
+                                    var cusrDisplayName = autoreplydata.userdisplayname;
285
+                                    var availPhoneNmbrs = autoreplydata.phonenumbers;
286
+                                    var autorpldata = autoreplydata.autoreplies;
287
+
288
+				    if (autorpldata.length > 0) { 
289
+				        var arplNmb = autorpldata.length;
290
+				    } else { 
291
+				        var arplNmb = 0; 
292
+				    }
293
+
294
+				    // List the auto-replies for the phone numbers available for the current user
295
+				    if (arplNmb == 0) {
296
+
297
+				        $("#autoReplyTbl").append("<tr><td><input type='text' class='arplAuthor' value='"+ cusrDisplayName +"' disabled></td><td><select id='arpphn-"+ arplNmb +"' class='arplPhoneNmbr'></select></td><td><div id='arplmode-"+ arplNmb +"' class='arplMode'><select id='modeselect-"+ arplNmb +"' class='selectArplMode'><option value='' selected>Select mode</option><option value='daily'>Daily mode</option><option value='vacation'>Vacation mode</option></select><div id='modecont-"+ arplNmb +"' class='modeContent'></div></div></td><td><textarea id='arpltxt-"+ arplNmb +"' class='arplText' rows='20' cols='40' placeholder='Enter the auto-reply message here.'></textarea></td><td><img id='rmRow-"+ arplNmb +"' class='removeRow' src='/apps/sms_relentless/img/closewnd.svg' title='Remove this row from the database' style='cursor:pointer;margin:9px 8px 0px 18px;'></td><td><input type='submit' id='arplsave-"+ arplNmb +"' class='saveAutoReply' value='Save' title='Save Row' /></td></tr>");
298
+				        $("#autoReplyTbl").append("<div><img id='addArplRow' src='/apps/sms_relentless/img/add.svg' title='Add Row'></div>");
299
+
300
+				    } else {
301
+
302
+				        for (k = 0; k < arplNmb; k++) {
303
+
304
+                                             if (autorpldata[k].days_of_week != '') {
305
+
306
+                                                 var slctdMode = "<option value=''>Select mode</option><option value='daily' selected>Daily mode</option><option value='vacation'>Vacation mode</option>";
307
+                                                 var dailyStartArr = autorpldata[k].daily_start.split(":");
308
+                                                 var dailyEndArr = autorpldata[k].daily_end.split(":");
309
+
310
+		                                 var dlHrStartOptions = "";
311
+			                         for (var hr = 0; hr < 24; hr++) {
312
+		                                      if (dailyStartArr[0] != hr.toLocaleString('en-US', {minimumIntegerDigits: 2, useGrouping:false})) {
313
+			                                  dlHrStartOptions += "<option value='"+ hr.toLocaleString('en-US', {minimumIntegerDigits: 2, useGrouping:false}) +"'>"+ hr.toLocaleString('en-US', {minimumIntegerDigits: 2, useGrouping:false}) +"</option>";
314
+		                                      } else {
315
+			                                  dlHrStartOptions += "<option value='"+ hr.toLocaleString('en-US', {minimumIntegerDigits: 2, useGrouping:false}) +"' selected>"+ hr.toLocaleString('en-US', {minimumIntegerDigits: 2, useGrouping:false}) +"</option>";
316
+		                                      }
317
+			                         }
318
+
319
+		                                 var dlMnStartOptions = "";
320
+			                         for (var mn = 0; mn < 60; mn++) {
321
+		                                      if (dailyStartArr[0] != mn.toLocaleString('en-US', {minimumIntegerDigits: 2, useGrouping:false})) {
322
+			                                  dlMnStartOptions += "<option value='"+ mn.toLocaleString('en-US', {minimumIntegerDigits: 2, useGrouping:false}) +"'>"+ mn.toLocaleString('en-US', {minimumIntegerDigits: 2, useGrouping:false}) +"</option>";
323
+		                                      } else {
324
+			                                  dlMnStartOptions += "<option value='"+ mn.toLocaleString('en-US', {minimumIntegerDigits: 2, useGrouping:false}) +"' selected>"+ mn.toLocaleString('en-US', {minimumIntegerDigits: 2, useGrouping:false}) +"</option>";
325
+		                                      }
326
+			                         }
327
+
328
+		                                 var dlHrEndOptions = "";
329
+			                         for (var hr = 0; hr < 24; hr++) {
330
+		                                      if (dailyEndArr[0] != hr.toLocaleString('en-US', {minimumIntegerDigits: 2, useGrouping:false})) {
331
+			                                  dlHrEndOptions += "<option value='"+ hr.toLocaleString('en-US', {minimumIntegerDigits: 2, useGrouping:false}) +"'>"+ hr.toLocaleString('en-US', {minimumIntegerDigits: 2, useGrouping:false}) +"</option>";
332
+		                                      } else {
333
+			                                  dlHrEndOptions += "<option value='"+ hr.toLocaleString('en-US', {minimumIntegerDigits: 2, useGrouping:false}) +"' selected>"+ hr.toLocaleString('en-US', {minimumIntegerDigits: 2, useGrouping:false}) +"</option>";
334
+		                                      }
335
+			                         }
336
+
337
+		                                 var dlMnEndOptions = "";
338
+			                         for (var mn = 0; mn < 60; mn++) {
339
+		                                      if (dailyEndArr[1] != mn.toLocaleString('en-US', {minimumIntegerDigits: 2, useGrouping:false})) {
340
+			                                  dlMnEndOptions += "<option value='"+ mn.toLocaleString('en-US', {minimumIntegerDigits: 2, useGrouping:false}) +"'>"+ mn.toLocaleString('en-US', {minimumIntegerDigits: 2, useGrouping:false}) +"</option>";
341
+		                                      } else {
342
+			                                  dlMnEndOptions += "<option value='"+ mn.toLocaleString('en-US', {minimumIntegerDigits: 2, useGrouping:false}) +"' selected>"+ mn.toLocaleString('en-US', {minimumIntegerDigits: 2, useGrouping:false}) +"</option>";
343
+		                                      }
344
+			                         }
345
+
346
+                                                 var modeContent = "<div class='daysOfWeek'>Days of the week:<div class='tooltipautoreply'><div id='infoautoreply'>i</div><div class='autorpltooltip'>Enter the order number of the days of the week in which the auto-reply will be sent. For example, to send the auto-reply every day from Monday to Friday (outside the time interval specified below), enter 1,2,3,4,5 To send the auto-reply only Monday, Thursday and Friday enter 1,4,5 To send the auto-reply every day of the week enter 1,2,3,4,5,6,7</div></div></div><input type='text' id='weekdays-"+ k +"' class='daysInWeek' value='"+ autorpldata[k].days_of_week +"'><div class='chooseTInterval'>Send auto-reply <span style='color:#ad0202'>outside</span> this interval:<div class='tooltipautoreplyst'><div id='infoautoreplyst'>i</div><div class='autorpltooltipst'>These fields specify the time of the server. If the server is located in a time zone that is different from that of the owner/company, the time interval entered here should be adjusted accordingly.</div></div></div><div class='selectArplHours'><select id='dmstarthr-"+ k +"' class='selectHrMin'>"+ dlHrStartOptions +"</select><select id='dmstartmn-"+ k +"' class='selectHrMin'>"+ dlMnStartOptions +"</select><span style='font-weight: 600'> — </span><select id='dmendhr-"+ k +"' class='selectHrMin'>"+ dlHrEndOptions +"</select><select id='dmendmn-"+ k +"' class='selectHrMin'>"+ dlMnEndOptions +"</select></div>";
347
+
348
+                                             } else {
349
+
350
+                                                 var vctnStart = autorpldata[k].vacation_start.split(" ")[0];
351
+                                                 var vctnEnd = autorpldata[k].vacation_end.split(" ")[0];
352
+
353
+                                                 var slctdMode = "<option value=''>Select mode</option><option value='daily'>Daily mode</option><option value='vacation' selected>Vacation mode</option>";
354
+                                                 var modeContent = "<div class='chooseDateIntvl'>Send auto-reply <span style='color:#ad0202'>inside</span> this interval:</div><div class='arplstrtendDates'><div class='stdtTitle'>Start Date</div><input type='text' id='startDT-"+ k +"' class='startDate' placeholder='Pick a date' value='"+ vctnStart +"'><div class='enddtTitle'>End Date</div><input type='text' id='endDT-"+ k +"' class='endDate' placeholder='Pick a date' value='"+ vctnEnd +"'></div>"
355
+                                             }
356
+
357
+				             $("#autoReplyTbl").append("<tr><td><input type='text' class='arplAuthor' value='"+ autorpldata[k].saved_by_dsplname +"' disabled></td><td><select id='arpphn-"+ k +"' class='arplPhoneNmbr' style='pointer-events:none'><option selected>"+ autorpldata[k].phone_number +"</option></select></td><td><div id='arplmode-"+ k +"' class='arplMode'><select id='modeselect-"+ k +"' class='selectArplMode'>"+ slctdMode +"</select><div id='modecont-"+ k +"' class='modeContent'>"+ modeContent +"</div></div></td><td><textarea id='arpltxt-"+ k +"' class='arplText' rows='20' cols='40' placeholder='Enter the auto-reply message here.'>"+ autorpldata[k].message_text +"</textarea></td><td><img id='rmRow-"+ k +"' class='removeRow' src='/apps/sms_relentless/img/closewnd.svg' title='Remove this row from the database' style='cursor:pointer;margin:9px 8px 0px 18px;'></td><td><input type='submit' id='arplsave-"+ k +"' class='saveAutoReply' value='Edit' title='Edit Row' /></td></tr>");
358
+				        }
359
+				        $("#autoReplyTbl").append("<div><img id='addArplRow' src='/apps/sms_relentless/img/add.svg' title='Add Row'></div>");
360
+				    }
361
+
362
+
363
+				    // Create a list with all the available phone numbers
364
+                                    var numbersListItems = "<option value='' selected>Select phone number</option>";
365
+
366
+				    $.each(availPhoneNmbrs, function(key, indsmsnmb) {
367
+				           numbersListItems += "<option value='"+ indsmsnmb +"'>"+ indsmsnmb +"</option>";
368
+				    });
369
+
370
+                                    if (arplNmb == 0) {
371
+				        $("#arpphn-"+ arplNmb).append(numbersListItems);
372
+                                    }
373
+
374
+                                    // Initialize the date picker
375
+			            $('[id^="endDT-"]').datepicker({ dateFormat: "yy-mm-dd" });
376
+			            $('[id^="startDT-"]').datepicker({ dateFormat: "yy-mm-dd" });
377
+
378
+
379
+                                    // Select the auto-reply mode
380
+                                    function selectMode() {
381
+
382
+		                            $('[id^="modeselect-"]').change(function() {
383
+
384
+		                               var crtnmbr = $(this).attr("id").replace("modeselect-", "");
385
+
386
+		                               var dailyHrStart = "";
387
+		                               for (var h = 0; h < 24; h++) {
388
+		                                    dailyHrStart += "<option value='"+ h.toLocaleString('en-US', {minimumIntegerDigits: 2, useGrouping:false}) +"'>"+ h.toLocaleString('en-US', {minimumIntegerDigits: 2, useGrouping:false}) +"</option>";
389
+		                               }
390
+
391
+		                               var dailyMnStart = "";
392
+		                               for (var m = 0; m < 60; m++) {
393
+		                                    dailyMnStart += "<option value='"+ m.toLocaleString('en-US', {minimumIntegerDigits: 2, useGrouping:false}) +"'>"+ m.toLocaleString('en-US', {minimumIntegerDigits: 2, useGrouping:false}) +"</option>";
394
+		                               }
395
+
396
+		                               var dailyHrEnd = dailyHrStart;
397
+		                               var dailyMnEnd = dailyMnStart;
398
+
399
+		                               if ($(this).val() == 'daily') {
400
+		                                   $("#modecont-"+ crtnmbr).empty();
401
+		                                   $("#modecont-"+ crtnmbr).append("<div class='daysOfWeek'>Days of the week:<div class='tooltipautoreply'><div id='infoautoreply'>i</div><div class='autorpltooltip'>Enter the order number of the days of the week. For example, to send the auto-reply every day from Monday to Friday outside the specified time interval, enter 1,2,3,4,5 To send the auto-reply only Monday, Thursday and Friday enter 1,4,5 To send the auto-reply every day of the week enter 1,2,3,4,5,6,7</div></div></div><input type='text' id='weekdays-"+ crtnmbr +"' class='daysInWeek'><div class='chooseTInterval'>Send auto-reply <span style='color:#ad0202'>outside</span> this interval:<div class='tooltipautoreplyst'><div id='infoautoreplyst'>i</div><div class='autorpltooltipst'>These fields specify the time of the server. If the server is located in a time zone that is different from that of the owner/company, the time interval entered here should be adjusted accordingly.</div></div></div><div class='selectArplHours'><select id='dmstarthr-"+ crtnmbr +"' class='selectHrMin'>"+ dailyHrStart +"</select><select id='dmstartmn-"+ crtnmbr +"' class='selectHrMin'>"+ dailyMnStart +"</select><span style='font-weight: 600'> — </span><select id='dmendhr-"+ crtnmbr +"' class='selectHrMin'>"+ dailyHrEnd +"</select><select id='dmendmn-"+ crtnmbr +"' class='selectHrMin'>"+ dailyMnEnd +"</select></div>");
402
+		                               } else if ($(this).val() == 'vacation') {
403
+		                                   $("#modecont-"+ crtnmbr).empty();
404
+		                                   $("#modecont-"+ crtnmbr).append("<div class='chooseDateIntvl'>Send auto-reply <span style='color:#ad0202'>inside</span> this interval:</div><div class='arplstrtendDates'><div class='stdtTitle'>Start Date</div><input type='text' id='startDT-"+ crtnmbr +"' class='startDate' placeholder='Pick a date'><div class='enddtTitle'>End Date</div><input type='text' id='endDT-"+ crtnmbr +"' class='endDate' placeholder='Pick a date' /></div>");
405
+		                               }
406
+
407
+					       $("#endDT-"+ crtnmbr +"").datepicker({ dateFormat: "yy-mm-dd" });
408
+					       $("#startDT-"+ crtnmbr +"").datepicker({ dateFormat: "yy-mm-dd" });
409
+		                          });
410
+                                  }
411
+                                  selectMode();
412
+
413
+				  // Save the data
414
+				  function saveArplRow() {
415
+
416
+				     $('[id^="arplsave-"]').unbind("click");
417
+				     $('[id^="arplsave-"]').click(function(event) {
418
+
419
+				        event.preventDefault();
420
+				        var crntrwnmbr = $(this).attr("id").replace("arplsave-", "");
421
+
422
+				        if ($(this).attr("value") == "Save") {
423
+
424
+				            var phoneNmbr = $("#arpphn-"+ crntrwnmbr).val();
425
+				            var arplText = $("#arpltxt-"+ crntrwnmbr).val();
426
+				            var slctdMode = $("#modeselect-"+ crntrwnmbr).val();
427
+
428
+				            var slctddmDays = "";
429
+				            var slctdHrStart = "";
430
+				            var slctdMnStart = "";
431
+				            var slctdHrEnd = "";
432
+				            var slctdMnEnd = "";
433
+
434
+				            var vcStartDate = null;
435
+				            var vcEndDate = null;
436
+
437
+				            if (slctdMode == 'daily') {
438
+
439
+				                slctddmDays = $("#weekdays-"+ crntrwnmbr).val().trim();
440
+				                slctdHrStart = $("#dmstarthr-"+ crntrwnmbr).val().trim();
441
+				                slctdMnStart = $("#dmstartmn-"+ crntrwnmbr).val().trim();
442
+				                slctdHrEnd = $("#dmendhr-"+ crntrwnmbr).val().trim();
443
+				                slctdMnEnd = $("#dmendmn-"+ crntrwnmbr).val().trim();
444
+
445
+                                                if (slctdHrStart != '' && slctdMnStart != '') {
446
+                                                    var hrmnStartComp = slctdHrStart +":"+ slctdMnStart;
447
+                                                } else { var hrmnStartComp = ""; }
448
+
449
+                                                if (slctdHrEnd != '' && slctdMnEnd != '') {
450
+                                                    var hrmnEndComp = slctdHrEnd +":"+ slctdMnEnd;
451
+                                                } else { var hrmnEndComp = ""; }
452
+
453
+                                                if (!(/^[1-7\,]+$/.test(slctddmDays))) {
454
+				                    showAlert("The 'Days of the week' field can contain only digits from 1 to 7 and commas (,).");
455
+				                    return;
456
+                                                }
457
+
458
+                                                if (!(/^[0-9]+$/.test(slctdHrStart + slctdMnStart + slctdHrEnd + slctdMnEnd))) {
459
+				                    showAlert("The starting and ending values of the time interval for the 'Daily mode' can contain only digits from 0 to 9.");
460
+				                    return;
461
+                                                }
462
+
463
+                                                if (slctddmDays.trim() == '' || (slctdHrStart == slctdHrEnd && slctdMnStart == slctdMnEnd)) {
464
+				                    showAlert("For the 'Daily mode', you have to enter the order number of the days of the week for which you want the auto-reply to be sent, and you have to set a starting time that is different from the ending time!");
465
+				                    return;
466
+                                                }
467
+
468
+				            } else if (slctdMode == 'vacation') {
469
+		
470
+                                                if ($("#startDT-"+ crntrwnmbr).val().trim() == '' || $("#endDT-"+ crntrwnmbr).val().trim() == '') {
471
+
472
+				                    showAlert("For the 'Vacation mode', you have to enter both a start date and an end date.");
473
+				                    return;
474
+
475
+                                                } else {
476
+
477
+                                                    if (!(/^[0-9\-]+$/.test($("#startDT-"+ crntrwnmbr).val().trim() + $("#endDT-"+ crntrwnmbr).val().trim()))) {
478
+				                        showAlert("The start date and end date values for the 'Vacation mode' can contain only digits from 0 to 9 and hyphens (-).");
479
+				                        return;
480
+                                                    }
481
+
482
+		                                    vcStartDate = $("#startDT-"+ crntrwnmbr).val().trim() +" 00:00:00";
483
+				                    vcEndDate = $("#endDT-"+ crntrwnmbr).val().trim() +" 23:59:59";
484
+				                    var strtDateCmp = new Date(vcStartDate).toJSON().slice(0, 10) +" 00:00:00";
485
+				                    var endDateCmp = new Date(vcEndDate).toJSON().slice(0, 10) +" 23:59:59";
486
+				                    var crntDate = new Date().toJSON().slice(0, 10) +" 23:59:59";
487
+
488
+                                                    if (vcStartDate.trim() == "" || vcEndDate.trim() == "" || (strtDateCmp >= endDateCmp || ((strtDateCmp < crntDate) && (endDateCmp < crntDate)))) {
489
+				                        showAlert("For 'Vacation mode', you have to enter both a start date and an end date, the start date must be before the end date and at least the ending of the time interval must be in the future.");
490
+				                        return;
491
+                                                    }
492
+                                                }
493
+				            }
494
+
495
+
496
+				            if (phoneNmbr != '') {
497
+
498
+				              if (arplText.trim() != '') {
499
+
500
+				                if (slctdMode != '') {
501
+
502
+				                    var saveArplUrl = OC.generateUrl('/apps/sms_relentless/user/updateautoreplies');
503
+				                    var arpldata = {
504
+				                         userId: userid,
505
+				                         savedByDsplname: cusrDisplayName,
506
+				                         phoneNumber: phoneNmbr,
507
+				                         daysOfWeek: slctddmDays,
508
+				                         dailyStart: hrmnStartComp,
509
+				                         dailyEnd: hrmnEndComp,
510
+				                         vacationStart: vcStartDate,
511
+				                         vacationEnd: vcEndDate,
512
+				                         messageText: arplText
513
+				                    };
514
+
515
+					            $.ajax({
516
+					              method: 'PUT',
517
+					              url: saveArplUrl + '/' + userid,
518
+					              contentType: 'application/json',
519
+					              data: JSON.stringify(arpldata),
520
+				                      success: function(messagereceived) {
521
+
522
+				                                   if (messagereceived == 'success') {
523
+				                                       showAlert('The auto-reply has been successfully saved to the database!');
524
+				                                   } else if (messagereceived == 'failure') {
525
+				                                       showAlert('Error while trying to save the auto-reply!');
526
+				                                   } else if (messagereceived == 'not allowed') {
527
+                                                                       showAlert('You cannot change an auto-reply that was saved by a different user.');
528
+                                                                   }
529
+				                      },
530
+					              error: function() {
531
+						                   showAlert('Error while attempting to save the auto-reply! You can check the Nextcloud log to find more details about this issue.');
532
+					              }
533
+					            });
534
+
535
+
536
+                                                } else { showAlert("Please select the auto-reply mode."); return; }
537
+
538
+                                              } else { showAlert("Please enter the text of the auto-reply."); return; }
539
+
540
+                                            } else { showAlert("Please select a phone number if at least one number is available in the 'Phone Number' drop-down list. Otherwise, you should contact the administrator."); return; }
541
+
542
+                                            $(this).attr("value", "Edit");
543
+
544
+                                        } else {
545
+                                            $("#arplsave-"+ crntrwnmbr).attr("value", "Save");
546
+                                        }
547
+
548
+                                     });
549
+
550
+				  }
551
+                                  saveArplRow();
552
+
553
+
554
+				  // Remove a row
555
+				  function removeArplRow() {
556
+				       $('[id^="rmRow-"]').click(function() {
557
+
558
+					  var slctRowRm = $(this).attr("id").replace("rmRow-", "");
559
+					  var crntPhnNmbr = $("#arpphn-"+ slctRowRm).val();
560
+
561
+				          confirmAlert("Do you really want to remove this row from the database ?");
562
+
563
+				          $("#confirmCancel").click(function() { $("#alertMsgOverlay").remove(); $("#alertConfMessage").remove(); });
564
+
565
+				          $("#confirmOk").click(function() {
566
+
567
+				              $("#alertMsgOverlay").remove();
568
+				              $("#alertConfMessage").remove();
569
+
570
+					      var rmvArplUrl = OC.generateUrl('/apps/sms_relentless/user/removeautoreplies');
571
+					      $.ajax({
572
+						   url: rmvArplUrl + '/' + userid,
573
+						   method: "POST",
574
+						   dataType: "text",
575
+						   data: { phoneNumber: crntPhnNmbr },
576
+						   success: function(delresult) {
577
+
578
+						                     if (delresult.indexOf("success") > -1) {
579
+						                         showAlert("The auto-reply has been removed successfully!");
580
+						                         $("#arpphn-"+ slctRowRm).closest("tr").remove();
581
+						                     } else if (delresult.indexOf("failure") > -1) {
582
+						                         showAlert("Error while trying to remove auto-reply data!");
583
+						                     } else if (delresult.indexOf("not allowed") > -1) {
584
+                                                                         showAlert("You cannot remove the auto-reply saved by another user.");
585
+                                                                     }
586
+						   },
587
+						   error: function() { showAlert("Error while attempting to remove auto-reply data! You can check the Nextcloud log to find more details about this issue."); }
588
+					       });
589
+					  });
590
+				       });
591
+				  }
592
+				  removeArplRow();
593
+
594
+                                  // Add a new row
595
+                                  $("#addArplRow").click(function() {
596
+
597
+                                     if ($("#autoReplyTbl").find("tr:last-child").find(".arplPhoneNmbr").length > 0) {
598
+                                         var lastarpl = $("#autoReplyTbl").find("tr:last-child").find(".arplPhoneNmbr").attr("id").replace("arpphn-", "");
599
+                                         var indArplAdd = parseInt(lastarpl + 1);
600
+                                     } else { var indArplAdd = 0; }
601
+			             $("#autoReplyTbl").append("<tr><td><input type='text' class='arplAuthor' value='"+ cusrDisplayName +"' disabled></td><td><select id='arpphn-"+ indArplAdd +"' class='arplPhoneNmbr'>"+ numbersListItems +"</select></td><td><div id='arplmode-"+ indArplAdd +"' class='arplMode'><select id='modeselect-"+ indArplAdd +"' class='selectArplMode'><option value='' selected>Select mode</option><option value='daily'>Daily mode</option><option value='vacation'>Vacation mode</option></select><div id='modecont-"+ indArplAdd +"' class='modeContent'></div></div></td><td><textarea id='arpltxt-"+ indArplAdd +"' class='arplText' rows='20' cols='40' placeholder='Enter the auto-reply message here.'></textarea></td><td><img id='rmRow-"+ indArplAdd +"' class='removeRow' src='/apps/sms_relentless/img/closewnd.svg' title='Remove this row from the database' style='cursor:pointer;margin:9px 8px 0px 18px;'></td><td><input type='submit' id='arplsave-"+ indArplAdd +"' class='saveAutoReply' value='Save' title='Save Row' /></td></tr>");
602
+
603
+                                     selectMode();
604
+                                     saveArplRow();
605
+                                     removeArplRow();
606
+
607
+			             // Check if there is an auto-reply set for the same phone number
608
+				     $("#arpphn-"+ indArplAdd).change(function() {
609
+					 var selectedPhNb = $("#arpphn-"+ indArplAdd).val();
610
+					 var allArplPhNmbrs = $("#autoReplyTbl").find("tr").find(".arplPhoneNmbr");
611
+					 var phNbChck = 0;
612
+					 allArplPhNmbrs.each(function() {
613
+					    var slctphnb = ($(this).val())? $(this).val() : $(this).text();
614
+					    if (selectedPhNb == slctphnb) { phNbChck++; }
615
+					 });
616
+
617
+					 if (phNbChck == 2) {
618
+					     showAlert("There is already an auto-reply set up for this phone number. Please edit its own row, or choose a different phone number.");
619
+					     $(this).val('');
620
+					     return;
621
+					 }
622
+				     });
623
+                                  });
624
+
625
+		  },
626
+		  error: function() {
627
+                                    $("#autoRplPhoneNb").removeClass('icon-loading'); 
628
+                                    showAlert("Error while attempting to get the auto-reply settings! You can check the Nextcloud log to find more details about this issue.");
629
+                  }
630
+         });
631
+
632
+     },
633
+     error: function() {
634
+                  showAlert('Error while getting the settings! You can check the Nextcloud log to find more details about this issue.');
635
+     }
636
+  });
637
+
638
+
639
+
640
+  // Save personal settings for non-admin users
641
+  $("#save_sms_settings").on("click", function(event) {
642
+
643
+     if (isadm == 'reguser') {
644
+
645
+	    event.preventDefault();
646
+	    var baseUrlsave = OC.generateUrl('/apps/sms_relentless/user/updatesettings');
647
+
648
+	    var messagesperpageinit = $("#messagesperpage").val();
649
+	    var messagesperpagesec = messagesperpageinit.replace(/[^0-9]/g, '');
650
+
651
+	    if (messagesperpagesec != '') {
652
+		var messagesperpageproc = messagesperpagesec;
653
+	    } else {
654
+		var messagesperpageproc = 100;
655
+	    }
656
+
657
+	    var getnotify = 0;
658
+
659
+	    if ($("#get_notify").is(':checked')) {
660
+		getnotify = 1;
661
+	    }
662
+
663
+	    var emailaddressinit = $("#notification_email").val();
664
+
665
+	    function validate_email($email) {
666
+		var email_reg = /^([\w-\.]+@([\w-]+\.)+[\w-]{2,4})?$/;
667
+		return email_reg.test($email);
668
+	    }
669
+
670
+	    if (validate_email(emailaddressinit)) {
671
+		 var notifyemail = emailaddressinit;
672
+	    } else {
673
+		 var notifyemail = '';
674
+	    }
675
+
676
+	    var includesmsinemail = 0;
677
+	    if ($("#includesmsinemail").is(':checked')) {
678
+		includesmsinemail = 1;
679
+                if ($("#notification_email").val().trim() == '') {
680
+                    showAlert("Please enter an email address in the field: 'I want to receive a notification to the email address from below ...', or uncheck the checkbox: 'Include the SMS/MMS message in the email notification itself'.");
681
+                    return;
682
+                }
683
+	    }
684
+
685
+	    var showdisplaynm = 0;
686
+	    if ($("#showdisplaynames").is(':checked')) {
687
+		showdisplaynm = 1;
688
+	    }
689
+
690
+	    var datatosave = {
691
+			      userId: userid,
692
+		              telapiUrlRec: $("#telapi_url_rec").val(),
693
+		              telapiUrl: $("#telapi_url").val(),
694
+		              nexapiUrlRec: $("#nexapi_url_rec").val(),
695
+		              nexapiUrl: $("#nexapi_url").val(),
696
+		              twilapiUrlRec: $("#twilapi_url_rec").val(),
697
+		              twilapiUrl: $("#twilapi_url").val(),
698
+		              flowapiUrlRec: $("#flowapi_url_rec").val(),
699
+		              flowapiUrl: $("#flowapi_url").val(),
700
+			      messagesperpage: messagesperpageproc,
701
+			      getNotify: getnotify,
702
+			      notificationEmail: notifyemail,
703
+			      getsmsinemail: includesmsinemail,
704
+			      showDisplayNames: showdisplaynm
705
+	    };
706
+
707
+
708
+	    $.ajax({
709
+	       method: 'PUT',
710
+	       url: baseUrlsave + '/' + userid,
711
+	       contentType: 'application/json',
712
+	       data: JSON.stringify(datatosave),
713
+	       success: function() {
714
+                               OC.msg.startAction('#smsr_save_msg', t('sms_relentless', 'Saved'));
715
+	       },
716
+	       error: function() {
717
+		    showAlert('Error while attempting to save the settings! You can check the Nextcloud log to find more details about this issue.');
718
+	       }
719
+	    });
720
+
721
+
722
+     } else if (isadm == 'admin') {
723
+
724
+	    // Save personal settings for admins
725
+	    event.preventDefault();
726
+	    var baseUrlsaveadm = OC.generateUrl('/apps/sms_relentless/user/updatepersadmnsettings');
727
+
728
+	    var messagesperpageinit = $("#messagesperpage").val();
729
+	    var messagesperpagesec = messagesperpageinit.replace(/[^0-9]/g, '');
730
+
731
+	    if (messagesperpagesec != '') {
732
+		var messagesperpageproc = messagesperpagesec;
733
+	    } else {
734
+		var messagesperpageproc = 100;
735
+	    }
736
+
737
+	    var getnotify = 0;
738
+
739
+	    if ($("#get_notify").is(':checked')) {
740
+		getnotify = 1;
741
+	    }
742
+
743
+	    var emailaddressinit = $("#notification_email").val();
744
+
745
+	    function validate_email($email) {
746
+		var email_reg = /^([\w-\.]+@([\w-]+\.)+[\w-]{2,4})?$/;
747
+		return email_reg.test($email);
748
+	    }
749
+
750
+	    if (validate_email(emailaddressinit)) {
751
+		 var notifyemail = emailaddressinit;
752
+	    } else {
753
+		 var notifyemail = '';
754
+	    }
755
+
756
+	    var includesmsinemail = 0;
757
+	    if ($("#includesmsinemail").is(':checked')) {
758
+		includesmsinemail = 1;
759
+                if ($("#notification_email").val().trim() == '') {
760
+                    showAlert("Please enter an email address in the field: 'I want to receive a notification to the email address from below ...', or uncheck the checkbox: 'Include the SMS/MMS message in the email notification itself'.");
761
+                    return;
762
+                }
763
+	    }
764
+
765
+	    var showdisplaynm = 0;
766
+	    if ($("#showdisplaynames").is(':checked')) {
767
+		showdisplaynm = 1;
768
+	    }
769
+
770
+	    var datatosave = {
771
+			      userId: userid,
772
+			      messagesperpage: messagesperpageproc,
773
+			      getNotify: getnotify,
774
+			      notificationEmail: notifyemail,
775
+			      getsmsinemail: includesmsinemail,
776
+			      showDisplayNames: showdisplaynm
777
+	    };
778
+
779
+
780
+	    $.ajax({
781
+	       method: 'PUT',
782
+	       url: baseUrlsaveadm + '/' + userid,
783
+	       contentType: 'application/json',
784
+	       data: JSON.stringify(datatosave),
785
+	       success: function() {
786
+                               OC.msg.startAction('#smsr_save_msg', t('sms_relentless', 'Saved'));
787
+	       },
788
+	       error: function() {
789
+		    showAlert('Error while attempting to save the settings! You can check the Nextcloud log to find more details about this issue.');
790
+	       }
791
+	    });
792
+
793
+     }
794
+  });
795
+
796
+  function showAlert(alertText) {
797
+
798
+     let alertwnd = "<div id='alertMessage'>";
799
+     alertwnd += "<a id='closeAlertWnd' title='Close this window'></a>";
800
+     alertwnd += "<div id='alertTextWrap'>"+ alertText +"</div>";
801
+     alertwnd += "<input type='submit' id='alertOk' value='OK'>";
802
+     alertwnd += "</div>";
803
+
804
+     $("#content").append("<div id='alertMsgOverlay'></div>");
805
+     $("#content").append(alertwnd);
806
+
807
+     let topDist = parseInt((window.innerHeight / 2).toFixed(2) - 152) +"px";
808
+     let leftDist = parseInt((window.innerWidth / 2).toFixed(2) - 150) +"px";
809
+     $("#alertMessage").css({ "top" : topDist, "left" : leftDist });
810
+
811
+     $("#closeAlertWnd").click(function() { $("#alertMsgOverlay").remove(); $("#alertMessage").remove(); });
812
+     $("#alertMsgOverlay").click(function() { $("#alertMsgOverlay").remove(); $("#alertMessage").remove(); });
813
+     $("#alertOk").click(function() { $("#alertMsgOverlay").remove(); $("#alertMessage").remove(); });
814
+  }
815
+
816
+  function confirmAlert(alertText) {
817
+
818
+     let alertwndcf = "<div id='alertConfMessage'>";
819
+     alertwndcf += "<a id='closeAlertWndcf' title='Close this window'></a>";
820
+     alertwndcf += "<div id='alertTextWrap'>"+ alertText +"</div>";
821
+     alertwndcf += "<div id='cancelOkWrap'><input type='submit' id='confirmCancel' value='Cancel'>";
822
+     alertwndcf += "<input type='submit' id='confirmOk' value='OK'></div>";
823
+     alertwndcf += "</div>";
824
+
825
+     $("#content").append("<div id='alertMsgOverlay'></div>");
826
+     $("#content").append(alertwndcf);
827
+
828
+     let topDist = parseInt((window.innerHeight / 2).toFixed(2) - 152) +"px";
829
+     let leftDist = parseInt((window.innerWidth / 2).toFixed(2) - 150) +"px";
830
+     $("#alertConfMessage").css({ "top" : topDist, "left" : leftDist });
831
+
832
+     $("#closeAlertWndcf").click(function() { $("#alertMsgOverlay").remove(); $("#alertConfMessage").remove(); });
833
+     $("#alertMsgOverlay").click(function() { $("#alertMsgOverlay").remove(); $("#alertConfMessage").remove(); });
834
+  }
835
+
836
+});
Browse code

removed CHANGELOG.txt appinfo/info.xml appinfo/signature.json css/style.css img/closewnd.svg ...

DoubleBastionAdmin authored on 23/05/2023 18:50:19
Showing 1 changed files
1 1
deleted file mode 100644
... ...
@@ -1,823 +0,0 @@
1
-/**
2
- * @copyright 2021 Double Bastion LLC <www.doublebastion.com>
3
- *
4
- * @author Double Bastion LLC
5
- *
6
- * @license GNU AGPL version 3 or any later version
7
- *
8
- * This program is free software; you can redistribute it and/or
9
- * modify it under the terms of the GNU AFFERO GENERAL PUBLIC LICENSE
10
- * License as published by the Free Software Foundation; either
11
- * version 3 of the License, or any later version.
12
- *
13
- * This program is distributed in the hope that it will be useful,
14
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
15
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
16
- * GNU AFFERO GENERAL PUBLIC LICENSE for more details.
17
- *
18
- * You should have received a copy of the GNU Affero General Public
19
- * License along with this program.  If not, see <http://www.gnu.org/licenses/>.
20
- *
21
- */
22
-
23
-$(document).ready(function() {
24
-
25
-  var userid = "<?php p($userId); ?>";
26
-  var isadm = '';
27
-
28
-  // Get personal settings
29
-  var baseUrlget = OC.generateUrl('/apps/sms_relentless/user/getsettings');
30
-
31
-  $.ajax({
32
-     method: 'GET',
33
-     url: baseUrlget + '/' + userid,
34
-     contentType: 'application/json',
35
-     success: function(settingsfromdb) {
36
-
37
-         // Add the webhook URLs section, if the user is not an admin
38
-         if (settingsfromdb.adminornot == 'reguser') {
39
-
40
-             isadm = 'reguser';
41
-
42
-             $("#appTitlePrg").append('<p id="settings-dscr"><h3>Enter your options in the fields from below. As a non-admin user, you can use any of the SMS service providers from \
43
-                  below, on the condition that an admin has shared with you his API keys for that provider:</h3></p><br>');
44
-
45
-             $("#nadmProvSection").append('<div class="providerSettings"><p><label for="telapi_url_rec" class="setlabeltext"><b>Telnyx webhook URL for incoming SMS/MMS</b> (Generate \
46
-                  the URL by pressing the button from below. Don\'t forget to also click the \'Save\' button at the bottom of this page after entering all the options, to save \
47
-                  all the settings to the database.)</label></p> \
48
-                  <input type="button" id="generate_tel_rcpt" class="generateUrl" value="Generate new webhook URL for incoming SMS/MMS" /> \
49
-                  <input type="text" class="smsr_textboxspec" id="telapi_url_rec" name="telapi_url_rec" autocomplete="false" /> \
50
-                  <span id="copyToClipboardtel" class="icon icon-clippy" title="Copy to clipboard"></span><br><br> \
51
-                  \
52
-                  <p><label for="telapi_url" class="setlabeltext"><b>Telnyx webhook URL for delivery receipts</b> (This URL will be included by SMS Relentless in message sending \
53
-                  requests, so that Telnyx will know where to send the delivery receipts. Just generate it by pressing the button from below. Don\'t forget to click the \'Save\' \
54
-                  button at the bottom of this page after entering all the options, to save all the settings to the database.)</label></p> \
55
-                  <input type="button" id="generate_tel_delrcpt" class="generateUrl" value="Generate new webhook URL for delivery receipts" /> \
56
-                  <input type="text" id="telapi_url" name="telapi_url" autocomplete="false" /></div><br><br> \
57
-                  \
58
-                  <div class="providerSettings"><p><label for="nexapi_url_rec" class="setlabeltext"><b>Plivo webhook URL for incoming SMS/MMS</b> (Generate the URL by pressing \
59
-                  the button from below. Don\'t forget to also click the \'Save\' button at the bottom of this page after entering all the options, to save all the settings \
60
-                  to the database.)</label></p> \
61
-                  <input type="button" id="generate_nex_rcpt" class="generateUrl" value="Generate new webhook URL for incoming SMS/MMS" /> \
62
-                  <input type="text" class="smsr_textboxspec" id="nexapi_url_rec" name="nexapi_url_rec" autocomplete="false" /> \
63
-                  <span id="copyToClipboardnex" class="icon icon-clippy" title="Copy to clipboard"></span><br><br> \
64
-                  \
65
-                  <p><label for="nexapi_url" class="setlabeltext"><b>Plivo webhook URL for delivery receipts</b> (This URL will be included by SMS Relentless in message sending \
66
-                  requests, so that Plivo will know where to send the delivery receipts. Just generate it by pressing the button from below. Don\'t forget to click the \'Save\' \
67
-                  button at the bottom of this page after entering all the options, to save all the settings to the database.)</label></p> \
68
-                  <input type="button" id="generate_nex_delrcpt" class="generateUrl" value="Generate new webhook URL for delivery receipts" /> \
69
-                  <input type="text" id="nexapi_url" name="nexapi_url" autocomplete="false" /></div><br><br> \
70
-                  \
71
-                  <div class="providerSettings"><p><label for="twilapi_url_rec" class="setlabeltext"><b>Twilio webhook URL for incoming SMS/MMS</b> (Generate the URL by pressing \
72
-                  the button from below. Don\'t forget to also click the \'Save\' button at the bottom of this page after entering all the options, to save all the settings to \
73
-                  the database.)</label></p> \
74
-                  <input type="button" id="generate_twil_rcpt" class="generateUrl" value="Generate new webhook URL for incoming SMS/MMS" /> \
75
-                  <input type="text" class="smsr_textboxspec" id="twilapi_url_rec" name="twilapi_url_rec" autocomplete="false" /> \
76
-                  <span id="copyToClipboardtwil" class="icon icon-clippy" title="Copy to clipboard"></span><br><br> \
77
-                  \
78
-                  <p><label for="twilapi_url" class="setlabeltext"><b>Twilio webhook URL for delivery receipts</b> (This URL will be included by SMS Relentless in message sending \
79
-                  requests, so that Twilio will know where to send the delivery receipts. Just generate it by pressing the button from below. Don\'t forget to click the \'Save\' \
80
-                  button at the bottom of this page after entering all the options, to save all the settings to the database.)</label></p> \
81
-                  <input type="button" id="generate_twil_delrcpt" class="generateUrl" value="Generate new webhook URL for delivery receipts" /> \
82
-                  <input type="text" id="twilapi_url" name="twilapi_url" autocomplete="false" /></div><br><br> \
83
-                  \
84
-                  <div class="providerSettings"><p><label for="flowapi_url_rec" class="setlabeltext"><b>Flowroute webhook URL for incoming SMS/MMS</b> (Generate the URL by pressing \
85
-                  the button from below. Don\'t forget to also click the \'Save\' button at the bottom of this page after entering all the options, to save all the settings to \
86
-                  the database.)</label></p> \
87
-                  <input type="button" id="generate_flow_rcpt" class="generateUrl" value="Generate new webhook URL for incoming SMS/MMS" /> \
88
-                  <input type="text" class="smsr_textboxspec" id="flowapi_url_rec" name="flowapi_url_rec" autocomplete="false" /> \
89
-                  <span id="copyToClipboardflow" class="icon icon-clippy" title="Copy to clipboard"></span><br><br> \
90
-                  \
91
-                  <p><label for="flowapi_url" class="setlabeltext"><b>Flowroute webhook URL for delivery receipts</b> (This URL will be included by SMS Relentless in message sending \
92
-                  requests, so that Flowroute will know where to send the delivery receipts. Just generate it by pressing the button from below. Don\'t forget to click the \'Save\' \
93
-                  button at the bottom of this page after entering all the options, to save all the settings to the database.)</label></p> \
94
-                  <input type="button" id="generate_flow_delrcpt" class="generateUrl" value="Generate new webhook URL for delivery receipts" /> \
95
-                  <input type="text" id="flowapi_url" name="flowapi_url" autocomplete="false" /><br><br> \
96
-                  Flowroute only supports sending/receiving SMS/MMS messages within USA and Canada and it doesn\'t support Alphanumeric Sender IDs.</div><br>');
97
-
98
-
99
-		  $("#telapi_url_rec").val(settingsfromdb.telapi_url_rec);
100
-		  $("#telapi_url").val(settingsfromdb.telapi_url);
101
-		  $("#nexapi_url_rec").val(settingsfromdb.nexapi_url_rec);
102
-		  $("#nexapi_url").val(settingsfromdb.nexapi_url);
103
-		  $("#twilapi_url_rec").val(settingsfromdb.twilapi_url_rec);
104
-		  $("#twilapi_url").val(settingsfromdb.twilapi_url);
105
-		  $("#flowapi_url_rec").val(settingsfromdb.flowapi_url_rec);
106
-		  $("#flowapi_url").val(settingsfromdb.flowapi_url);
107
-		  $("#messagesperpage").val(settingsfromdb.messagesperpage);
108
-
109
-		  if (settingsfromdb.get_notify == 1) {
110
-		      $("#get_notify").attr('checked', true);
111
-		  } else {
112
-		      $("#get_notify").attr('checked', false);
113
-		  }
114
-
115
-		  $("#notification_email").val(settingsfromdb.notification_email);
116
-
117
-		  if (settingsfromdb.getsmsinemail == 1) {
118
-		      $("#includesmsinemail").attr('checked', true);
119
-		  } else {
120
-		      $("#includesmsinemail").attr('checked', false);
121
-		  }
122
-
123
-		  if (settingsfromdb.show_display_names == 1) {
124
-		      $("#showdisplaynames").attr('checked', true);
125
-		  } else {
126
-		      $("#showdisplaynames").attr('checked', false);
127
-		  }
128
-/*
129
-		  var telnyxwhurlrec = '';
130
-		  var telnyxwhurl = '';
131
-		  var plivowhurlrec = '';
132
-		  var plivodrwhurl = '';
133
-		  var twilwhurlrec = '';
134
-		  var twildrwhurl = '';
135
-		  var flowwhurlrec = '';
136
-		  var flowdrwhurl = '';
137
-*/
138
-		  function randomStr(strlength) {
139
-			var fintext = "";
140
-			var keyspace = '0123456789abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ';
141
-			for (var i = 0; i < strlength; i++) {
142
-			     fintext += keyspace.charAt(Math.floor(Math.random() * keyspace.length));
143
-			}
144
-			return fintext;
145
-		  }
146
-
147
-		  $("#generate_tel_rcpt").on("click", function(event) {
148
-
149
-		     var teltokenrec = randomStr(70);
150
-		     var telnyxwhurlrec = window.location.origin + OC.generateUrl('/apps/sms_relentless/api/recsmstel?telrecparam=') + teltokenrec;
151
-
152
-		     $("#telapi_url_rec").val(telnyxwhurlrec);
153
-		  });
154
-
155
-		  $("#copyToClipboardtel").on("click", function(event) {
156
-		     var $tempEl = $("<input>");
157
-		     $("body").append($tempEl);
158
-		     $tempEl.val($("#telapi_url_rec").val()).select();
159
-		     document.execCommand("Copy");
160
-		     $tempEl.remove();
161
-		     showAlert("The link has been copied to your clipboard!");
162
-		  });
163
-
164
-		  $("#generate_tel_delrcpt").on("click", function(event) {
165
-
166
-		     var teltoken = randomStr(70);
167
-		     var telnyxwhurl = window.location.origin + OC.generateUrl('/apps/sms_relentless/api/recdeliverytel?teldrparam=') + teltoken;
168
-
169
-		     $("#telapi_url").val(telnyxwhurl);
170
-		  });
171
-
172
-
173
-		  $("#generate_nex_rcpt").on("click", function(event) {
174
-
175
-		     var plivotokenrec = randomStr(70);
176
-		     var plivowhurlrec = window.location.origin + OC.generateUrl('/apps/sms_relentless/api/recsmsnex?plivorecparam=') + plivotokenrec;
177
-
178
-		     $("#nexapi_url_rec").val(plivowhurlrec);
179
-		  });
180
-
181
-		  $("#copyToClipboardnex").on("click", function(event) {
182
-		     var $tempElpl = $("<input>");
183
-		     $("body").append($tempElpl);
184
-		     $tempElpl.val($("#nexapi_url_rec").val()).select();
185
-		     document.execCommand("Copy");
186
-		     $tempElpl.remove();
187
-		     showAlert("The link has been copied to your clipboard!");
188
-		  });
189
-
190
-		  $("#generate_nex_delrcpt").on("click", function(event) {
191
-
192
-		     var plivotoken = randomStr(70);
193
-		     var plivodrwhurl = window.location.origin + OC.generateUrl('/apps/sms_relentless/api/recdeliverynex?plivodrparam=') + plivotoken;
194
-
195
-		     $("#nexapi_url").val(plivodrwhurl);
196
-		  });
197
-
198
-
199
-		  $("#generate_twil_rcpt").on("click", function(event) {
200
-
201
-		     var twiltokenrec = randomStr(35);
202
-		     var twilwhurlrec = window.location.origin + OC.generateUrl('/apps/sms_relentless/api/recsmstwil?twilrecparam=') + twiltokenrec;
203
-
204
-		     $("#twilapi_url_rec").val(twilwhurlrec);
205
-		  });
206
-
207
-		  $("#copyToClipboardtwil").on("click", function(event) {
208
-		     var $tempElpl = $("<input>");
209
-		     $("body").append($tempElpl);
210
-		     $tempElpl.val($("#twilapi_url_rec").val()).select();
211
-		     document.execCommand("Copy");
212
-		     $tempElpl.remove();
213
-		     showAlert("The link has been copied to your clipboard!");
214
-		  });
215
-
216
-		  $("#generate_twil_delrcpt").on("click", function(event) {
217
-
218
-		     var twiltoken = randomStr(35);
219
-		     var twildrwhurl = window.location.origin + OC.generateUrl('/apps/sms_relentless/api/recdeliverytwil?twildrparam=') + twiltoken;
220
-
221
-		     $("#twilapi_url").val(twildrwhurl);
222
-		  });
223
-
224
-
225
-		  $("#generate_flow_rcpt").on("click", function(event) {
226
-
227
-		     var flowtokenrec = randomStr(70);
228
-		     var flowwhurlrec = window.location.origin + OC.generateUrl('/apps/sms_relentless/api/recsmsflow?flowrecparam=') + flowtokenrec;
229
-
230
-		     $("#flowapi_url_rec").val(flowwhurlrec);
231
-		  });
232
-
233
-		  $("#copyToClipboardflow").on("click", function(event) {
234
-		     var $tempElpl = $("<input>");
235
-		     $("body").append($tempElpl);
236
-		     $tempElpl.val($("#flowapi_url_rec").val()).select();
237
-		     document.execCommand("Copy");
238
-		     $tempElpl.remove();
239
-		     showAlert("The link has been copied to your clipboard!");
240
-		  });
241
-
242
-		  $("#generate_flow_delrcpt").on("click", function(event) {
243
-
244
-		     var flowtoken = randomStr(70);
245
-		     var flowdrwhurl = window.location.origin + OC.generateUrl('/apps/sms_relentless/api/recdeliveryflow?flowdrparam=') + flowtoken;
246
-
247
-		     $("#flowapi_url").val(flowdrwhurl);
248
-		  });
249
-
250
-
251
-         } else if (settingsfromdb.adminornot == 'admin') {
252
-
253
-                  $("#appTitlePrg").append('<p id="settings-dscr"><h3>Enter your options in the fields from below:</h3></p><br>');
254
-                  isadm = 'admin';
255
-
256
-		  $("#messagesperpage").val(settingsfromdb.messagesperpage);
257
-
258
-		  if (settingsfromdb.get_notify == 1) {
259
-		      $("#get_notify").attr('checked', true);
260
-		  } else {
261
-		      $("#get_notify").attr('checked', false);
262
-		  }
263
-
264
-		  $("#notification_email").val(settingsfromdb.notification_email);
265
-
266
-		  if (settingsfromdb.getsmsinemail == 1) {
267
-		      $("#includesmsinemail").attr('checked', true);
268
-		  } else {
269
-		      $("#includesmsinemail").attr('checked', false);
270
-		  }
271
-
272
-		  if (settingsfromdb.show_display_names == 1) {
273
-		      $("#showdisplaynames").attr('checked', true);
274
-		  } else {
275
-		      $("#showdisplaynames").attr('checked', false);
276
-		  }
277
-         }
278
-
279
-
280
-         // Auto-reply settings
281
-
282
-         // Get the available phone numbers from all providers associated with the access keys entered on the Settings page (restrictions are applied to numbers for non-admins)
283
-         $("#autoRplPhoneNb").addClass('icon-loading');
284
-         var getnumbersUrl = OC.generateUrl("/apps/sms_relentless/user/getautoreplyconf");
285
-
286
-	 $.ajax({
287
-		  url: getnumbersUrl + '/' + userid,
288
-		  type: "GET",
289
-                  contentType: 'application/json',
290
-		  success: function(autoreplydata) {
291
-
292
-                                    $("#autoRplPhoneNb").removeClass('icon-loading');
293
-                                    var cusrDisplayName = autoreplydata.userdisplayname;
294
-                                    var availPhoneNmbrs = autoreplydata.phonenumbers;
295
-                                    var autorpldata = autoreplydata.autoreplies;
296
-
297
-				    if (autorpldata.length > 0) { 
298
-				        var arplNmb = autorpldata.length;
299
-				    } else { 
300
-				        var arplNmb = 0; 
301
-				    }
302
-
303
-				    // List the auto-replies for the phone numbers available for the current user
304
-				    if (arplNmb == 0) {
305
-
306
-				        $("#autoReplyTbl").append("<tr><td><input type='text' class='arplAuthor' value='"+ cusrDisplayName +"' disabled></td><td><select id='arpphn-"+ arplNmb +"' class='arplPhoneNmbr'></select></td><td><div id='arplmode-"+ arplNmb +"' class='arplMode'><select id='modeselect-"+ arplNmb +"' class='selectArplMode'><option value='' selected>Select mode</option><option value='daily'>Daily mode</option><option value='vacation'>Vacation mode</option></select><div id='modecont-"+ arplNmb +"' class='modeContent'></div></div></td><td><textarea id='arpltxt-"+ arplNmb +"' class='arplText' rows='20' cols='40' placeholder='Enter the auto-reply message here.'></textarea></td><td><img id='rmRow-"+ arplNmb +"' class='removeRow' src='/apps/sms_relentless/img/closewnd.svg' title='Remove this row from the database' style='cursor:pointer;margin:9px 8px 0px 18px;'></td><td><input type='submit' id='arplsave-"+ arplNmb +"' class='saveAutoReply' value='Save' title='Save Row' /></td></tr>");
307
-				        $("#autoReplyTbl").append("<div><img id='addArplRow' src='/apps/sms_relentless/img/add.svg' title='Add Row'></div>");
308
-
309
-				    } else {
310
-
311
-				        for (k = 0; k < arplNmb; k++) {
312
-
313
-                                             if (autorpldata[k].days_of_week != '') {
314
-
315
-                                                 var slctdMode = "<option value=''>Select mode</option><option value='daily' selected>Daily mode</option><option value='vacation'>Vacation mode</option>";
316
-                                                 var dailyStartArr = autorpldata[k].daily_start.split(":");
317
-                                                 var dailyEndArr = autorpldata[k].daily_end.split(":");
318
-
319
-		                                 var dlHrStartOptions = "";
320
-			                         for (var hr = 0; hr < 24; hr++) {
321
-		                                      if (dailyStartArr[0] != hr.toLocaleString('en-US', {minimumIntegerDigits: 2, useGrouping:false})) {
322
-			                                  dlHrStartOptions += "<option value='"+ hr.toLocaleString('en-US', {minimumIntegerDigits: 2, useGrouping:false}) +"'>"+ hr.toLocaleString('en-US', {minimumIntegerDigits: 2, useGrouping:false}) +"</option>";
323
-		                                      } else {
324
-			                                  dlHrStartOptions += "<option value='"+ hr.toLocaleString('en-US', {minimumIntegerDigits: 2, useGrouping:false}) +"' selected>"+ hr.toLocaleString('en-US', {minimumIntegerDigits: 2, useGrouping:false}) +"</option>";
325
-		                                      }
326
-			                         }
327
-
328
-		                                 var dlMnStartOptions = "";
329
-			                         for (var mn = 0; mn < 60; mn++) {
330
-		                                      if (dailyStartArr[0] != mn.toLocaleString('en-US', {minimumIntegerDigits: 2, useGrouping:false})) {
331
-			                                  dlMnStartOptions += "<option value='"+ mn.toLocaleString('en-US', {minimumIntegerDigits: 2, useGrouping:false}) +"'>"+ mn.toLocaleString('en-US', {minimumIntegerDigits: 2, useGrouping:false}) +"</option>";
332
-		                                      } else {
333
-			                                  dlMnStartOptions += "<option value='"+ mn.toLocaleString('en-US', {minimumIntegerDigits: 2, useGrouping:false}) +"' selected>"+ mn.toLocaleString('en-US', {minimumIntegerDigits: 2, useGrouping:false}) +"</option>";
334
-		                                      }
335
-			                         }
336
-
337
-		                                 var dlHrEndOptions = "";
338
-			                         for (var hr = 0; hr < 24; hr++) {
339
-		                                      if (dailyEndArr[0] != hr.toLocaleString('en-US', {minimumIntegerDigits: 2, useGrouping:false})) {
340
-			                                  dlHrEndOptions += "<option value='"+ hr.toLocaleString('en-US', {minimumIntegerDigits: 2, useGrouping:false}) +"'>"+ hr.toLocaleString('en-US', {minimumIntegerDigits: 2, useGrouping:false}) +"</option>";
341
-		                                      } else {
342
-			                                  dlHrEndOptions += "<option value='"+ hr.toLocaleString('en-US', {minimumIntegerDigits: 2, useGrouping:false}) +"' selected>"+ hr.toLocaleString('en-US', {minimumIntegerDigits: 2, useGrouping:false}) +"</option>";
343
-		                                      }
344
-			                         }
345
-
346
-		                                 var dlMnEndOptions = "";
347
-			                         for (var mn = 0; mn < 60; mn++) {
348
-		                                      if (dailyEndArr[1] != mn.toLocaleString('en-US', {minimumIntegerDigits: 2, useGrouping:false})) {
349
-			                                  dlMnEndOptions += "<option value='"+ mn.toLocaleString('en-US', {minimumIntegerDigits: 2, useGrouping:false}) +"'>"+ mn.toLocaleString('en-US', {minimumIntegerDigits: 2, useGrouping:false}) +"</option>";
350
-		                                      } else {
351
-			                                  dlMnEndOptions += "<option value='"+ mn.toLocaleString('en-US', {minimumIntegerDigits: 2, useGrouping:false}) +"' selected>"+ mn.toLocaleString('en-US', {minimumIntegerDigits: 2, useGrouping:false}) +"</option>";
352
-		                                      }
353
-			                         }
354
-
355
-                                                 var modeContent = "<div class='daysOfWeek'>Days of the week:<div class='tooltipautoreply'><div id='infoautoreply'>i</div><div class='autorpltooltip'>Enter the order number of the days of the week in which the auto-reply will be sent. For example, to send the auto-reply every day from Monday to Friday (outside the time interval specified below), enter 1,2,3,4,5 To send the auto-reply only Monday, Thursday and Friday enter 1,4,5 To send the auto-reply every day of the week enter 1,2,3,4,5,6,7</div></div></div><input type='text' id='weekdays-"+ k +"' class='daysInWeek' value='"+ autorpldata[k].days_of_week +"'><div class='chooseTInterval'>Send auto-reply <span style='color:#ad0202'>outside</span> this interval:<div class='tooltipautoreplyst'><div id='infoautoreplyst'>i</div><div class='autorpltooltipst'>These fields specify the time of the server. If the server is located in a time zone that is different from that of the owner/company, the time interval entered here should be adjusted accordingly.</div></div></div><div class='selectArplHours'><select id='dmstarthr-"+ k +"' class='selectHrMin'>"+ dlHrStartOptions +"</select><select id='dmstartmn-"+ k +"' class='selectHrMin'>"+ dlMnStartOptions +"</select><span style='font-weight: 600'> — </span><select id='dmendhr-"+ k +"' class='selectHrMin'>"+ dlHrEndOptions +"</select><select id='dmendmn-"+ k +"' class='selectHrMin'>"+ dlMnEndOptions +"</select></div>";
356
-
357
-                                             } else {
358
-
359
-                                                 var vctnStart = autorpldata[k].vacation_start.split(" ")[0];
360
-                                                 var vctnEnd = autorpldata[k].vacation_end.split(" ")[0];
361
-
362
-                                                 var slctdMode = "<option value=''>Select mode</option><option value='daily'>Daily mode</option><option value='vacation' selected>Vacation mode</option>";
363
-                                                 var modeContent = "<div class='chooseDateIntvl'>Send auto-reply <span style='color:#ad0202'>inside</span> this interval:</div><div class='arplstrtendDates'><div class='stdtTitle'>Start Date</div><input type='text' id='startDT-"+ k +"' class='startDate' placeholder='Pick a date' value='"+ vctnStart +"'><div class='enddtTitle'>End Date</div><input type='text' id='endDT-"+ k +"' class='endDate' placeholder='Pick a date' value='"+ vctnEnd +"'></div>"
364
-                                             }
365
-
366
-				             $("#autoReplyTbl").append("<tr><td><input type='text' class='arplAuthor' value='"+ autorpldata[k].saved_by_dsplname +"' disabled></td><td><select id='arpphn-"+ k +"' class='arplPhoneNmbr' style='pointer-events:none'><option selected>"+ autorpldata[k].phone_number +"</option></select></td><td><div id='arplmode-"+ k +"' class='arplMode'><select id='modeselect-"+ k +"' class='selectArplMode'>"+ slctdMode +"</select><div id='modecont-"+ k +"' class='modeContent'>"+ modeContent +"</div></div></td><td><textarea id='arpltxt-"+ k +"' class='arplText' rows='20' cols='40' placeholder='Enter the auto-reply message here.'>"+ autorpldata[k].message_text +"</textarea></td><td><img id='rmRow-"+ k +"' class='removeRow' src='/apps/sms_relentless/img/closewnd.svg' title='Remove this row from the database' style='cursor:pointer;margin:9px 8px 0px 18px;'></td><td><input type='submit' id='arplsave-"+ k +"' class='saveAutoReply' value='Edit' title='Edit Row' /></td></tr>");
367
-				        }
368
-				        $("#autoReplyTbl").append("<div><img id='addArplRow' src='/apps/sms_relentless/img/add.svg' title='Add Row'></div>");
369
-				    }
370
-
371
-
372
-				    // Create a list with all the available phone numbers
373
-                                    var numbersListItems = "<option value='' selected>Select phone number</option>";
374
-
375
-				    $.each(availPhoneNmbrs, function(key, indsmsnmb) {
376
-				           numbersListItems += "<option value='"+ indsmsnmb +"'>"+ indsmsnmb +"</option>";
377
-				    });
378
-
379
-                                    if (arplNmb == 0) {
380
-				        $("#arpphn-"+ arplNmb).append(numbersListItems);
381
-                                    }
382
-
383
-                                    // Initialize the date picker
384
-			            $('[id^="endDT-"]').datepicker({ dateFormat: "yy-mm-dd" });
385
-			            $('[id^="startDT-"]').datepicker({ dateFormat: "yy-mm-dd" });
386
-
387
-
388
-                                    // Select the auto-reply mode
389
-                                    function selectMode() {
390
-
391
-		                            $('[id^="modeselect-"]').change(function() {
392
-
393
-		                               var crtnmbr = $(this).attr("id").replace("modeselect-", "");
394
-
395
-		                               var dailyHrStart = "";
396
-		                               for (var h = 0; h < 24; h++) {
397
-		                                    dailyHrStart += "<option value='"+ h.toLocaleString('en-US', {minimumIntegerDigits: 2, useGrouping:false}) +"'>"+ h.toLocaleString('en-US', {minimumIntegerDigits: 2, useGrouping:false}) +"</option>";
398
-		                               }
399
-
400
-		                               var dailyMnStart = "";
401
-		                               for (var m = 0; m < 60; m++) {
402
-		                                    dailyMnStart += "<option value='"+ m.toLocaleString('en-US', {minimumIntegerDigits: 2, useGrouping:false}) +"'>"+ m.toLocaleString('en-US', {minimumIntegerDigits: 2, useGrouping:false}) +"</option>";
403
-		                               }
404
-
405
-		                               var dailyHrEnd = dailyHrStart;
406
-		                               var dailyMnEnd = dailyMnStart;
407
-
408
-		                               if ($(this).val() == 'daily') {
409
-		                                   $("#modecont-"+ crtnmbr).empty();
410
-		                                   $("#modecont-"+ crtnmbr).append("<div class='daysOfWeek'>Days of the week:<div class='tooltipautoreply'><div id='infoautoreply'>i</div><div class='autorpltooltip'>Enter the order number of the days of the week. For example, to send the auto-reply every day from Monday to Friday outside the specified time interval, enter 1,2,3,4,5 To send the auto-reply only Monday, Thursday and Friday enter 1,4,5 To send the auto-reply every day of the week enter 1,2,3,4,5,6,7</div></div></div><input type='text' id='weekdays-"+ crtnmbr +"' class='daysInWeek'><div class='chooseTInterval'>Send auto-reply <span style='color:#ad0202'>outside</span> this interval:<div class='tooltipautoreplyst'><div id='infoautoreplyst'>i</div><div class='autorpltooltipst'>These fields specify the time of the server. If the server is located in a time zone that is different from that of the owner/company, the time interval entered here should be adjusted accordingly.</div></div></div><div class='selectArplHours'><select id='dmstarthr-"+ crtnmbr +"' class='selectHrMin'>"+ dailyHrStart +"</select><select id='dmstartmn-"+ crtnmbr +"' class='selectHrMin'>"+ dailyMnStart +"</select><span style='font-weight: 600'> — </span><select id='dmendhr-"+ crtnmbr +"' class='selectHrMin'>"+ dailyHrEnd +"</select><select id='dmendmn-"+ crtnmbr +"' class='selectHrMin'>"+ dailyMnEnd +"</select></div>");
411
-		                               } else if ($(this).val() == 'vacation') {
412
-		                                   $("#modecont-"+ crtnmbr).empty();
413
-		                                   $("#modecont-"+ crtnmbr).append("<div class='chooseDateIntvl'>Send auto-reply <span style='color:#ad0202'>inside</span> this interval:</div><div class='arplstrtendDates'><div class='stdtTitle'>Start Date</div><input type='text' id='startDT-"+ crtnmbr +"' class='startDate' placeholder='Pick a date'><div class='enddtTitle'>End Date</div><input type='text' id='endDT-"+ crtnmbr +"' class='endDate' placeholder='Pick a date' /></div>");
414
-		                               }
415
-
416
-					       $("#endDT-"+ crtnmbr +"").datepicker({ dateFormat: "yy-mm-dd" });
417
-					       $("#startDT-"+ crtnmbr +"").datepicker({ dateFormat: "yy-mm-dd" });
418
-		                          });
419
-                                  }
420
-                                  selectMode();
421
-
422
-				  // Save the data
423
-				  function saveArplRow() {
424
-
425
-				     $('[id^="arplsave-"]').unbind("click");
426
-				     $('[id^="arplsave-"]').click(function(event) {
427
-
428
-				        event.preventDefault();
429
-				        var crntrwnmbr = $(this).attr("id").replace("arplsave-", "");
430
-
431
-				        if ($(this).attr("value") == "Save") {
432
-
433
-				            var phoneNmbr = $("#arpphn-"+ crntrwnmbr).val();
434
-				            var arplText = $("#arpltxt-"+ crntrwnmbr).val();
435
-				            var slctdMode = $("#modeselect-"+ crntrwnmbr).val();
436
-
437
-				            var slctddmDays = "";
438
-				            var slctdHrStart = "";
439
-				            var slctdMnStart = "";
440
-				            var slctdHrEnd = "";
441
-				            var slctdMnEnd = "";
442
-
443
-				            var vcStartDate = null;
444
-				            var vcEndDate = null;
445
-
446
-				            if (slctdMode == 'daily') {
447
-
448
-				                slctddmDays = $("#weekdays-"+ crntrwnmbr).val().trim();
449
-				                slctdHrStart = $("#dmstarthr-"+ crntrwnmbr).val().trim();
450
-				                slctdMnStart = $("#dmstartmn-"+ crntrwnmbr).val().trim();
451
-				                slctdHrEnd = $("#dmendhr-"+ crntrwnmbr).val().trim();
452
-				                slctdMnEnd = $("#dmendmn-"+ crntrwnmbr).val().trim();
453
-
454
-                                                if (slctdHrStart != '' && slctdMnStart != '') {
455
-                                                    var hrmnStartComp = slctdHrStart +":"+ slctdMnStart;
456
-                                                } else { var hrmnStartComp = ""; }
457
-
458
-                                                if (slctdHrEnd != '' && slctdMnEnd != '') {
459
-                                                    var hrmnEndComp = slctdHrEnd +":"+ slctdMnEnd;
460
-                                                } else { var hrmnEndComp = ""; }
461
-
462
-                                                if (!(/^[1-7\,]+$/.test(slctddmDays))) {
463
-				                    showAlert("The 'Days of the week' field can contain only digits from 1 to 7 and commas (,).");
464
-				                    return;
465
-                                                }
466
-
467
-                                                if (!(/^[0-9]+$/.test(slctdHrStart + slctdMnStart + slctdHrEnd + slctdMnEnd))) {
468
-				                    showAlert("The starting and ending values of the time interval for the 'Daily mode' can contain only digits from 0 to 9.");
469
-				                    return;
470
-                                                }
471
-
472
-                                                if (slctddmDays.trim() == '' || (slctdHrStart == slctdHrEnd && slctdMnStart == slctdMnEnd)) {
473
-				                    showAlert("For the 'Daily mode', you have to enter the order number of the days of the week for which you want the auto-reply to be sent, and you have to set a starting time that is different from the ending time!");
474
-				                    return;
475
-                                                }
476
-
477
-				            } else if (slctdMode == 'vacation') {
478
-		
479
-                                                if ($("#startDT-"+ crntrwnmbr).val().trim() == '' || $("#endDT-"+ crntrwnmbr).val().trim() == '') {
480
-
481
-				                    showAlert("For the 'Vacation mode', you have to enter both a start date and an end date.");
482
-				                    return;
483
-
484
-                                                } else {
485
-
486
-                                                    if (!(/^[0-9\-]+$/.test($("#startDT-"+ crntrwnmbr).val().trim() + $("#endDT-"+ crntrwnmbr).val().trim()))) {
487
-				                        showAlert("The start date and end date values for the 'Vacation mode' can contain only digits from 0 to 9 and hyphens (-).");
488
-				                        return;
489
-                                                    }
490
-
491
-		                                    vcStartDate = $("#startDT-"+ crntrwnmbr).val().trim() +" 00:00:00";
492
-				                    vcEndDate = $("#endDT-"+ crntrwnmbr).val().trim() +" 23:59:59";
493
-				                    var strtDateCmp = new Date(vcStartDate).toJSON().slice(0, 10) +" 00:00:00";
494
-				                    var endDateCmp = new Date(vcEndDate).toJSON().slice(0, 10) +" 23:59:59";
495
-				                    var crntDate = new Date().toJSON().slice(0, 10) +" 23:59:59";
496
-
497
-                                                    if (vcStartDate.trim() == "" || vcEndDate.trim() == "" || (strtDateCmp >= endDateCmp || ((strtDateCmp < crntDate) && (endDateCmp < crntDate)))) {
498
-				                        showAlert("For 'Vacation mode', you have to enter both a start date and an end date, the start date must be before the end date and at least the ending of the time interval must be in the future.");
499
-				                        return;
500
-                                                    }
501
-                                                }
502
-				            }
503
-
504
-
505
-				            if (phoneNmbr != '') {
506
-
507
-				              if (arplText.trim() != '') {
508
-
509
-				                if (slctdMode != '') {
510
-
511
-				                    var saveArplUrl = OC.generateUrl('/apps/sms_relentless/user/updateautoreplies');
512
-				                    var arpldata = {
513
-				                         userId: userid,
514
-				                         savedByDsplname: cusrDisplayName,
515
-				                         phoneNumber: phoneNmbr,
516
-				                         daysOfWeek: slctddmDays,
517
-				                         dailyStart: hrmnStartComp,
518
-				                         dailyEnd: hrmnEndComp,
519
-				                         vacationStart: vcStartDate,
520
-				                         vacationEnd: vcEndDate,
521
-				                         messageText: arplText
522
-				                    };
523
-
524
-					            $.ajax({
525
-					              method: 'PUT',
526
-					              url: saveArplUrl + '/' + userid,
527
-					              contentType: 'application/json',
528
-					              data: JSON.stringify(arpldata),
529
-				                      success: function(messagereceived) {
530
-
531
-				                                   if (messagereceived == 'success') {
532
-				                                       showAlert('The auto-reply has been successfully saved to the database!');
533
-				                                   } else if (messagereceived == 'failure') {
534
-				                                       showAlert('Error while trying to save the auto-reply!');
535
-				                                   } else if (messagereceived == 'not allowed') {
536
-                                                                       showAlert('You cannot change an auto-reply that was saved by a different user.');
537
-                                                                   }
538
-				                      },
539
-					              error: function() {
540
-						                   showAlert('Error while attempting to save the auto-reply! You can check the Nextcloud log to find more details about this issue.');
541
-					              }
542
-					            });
543
-
544
-
545
-                                                } else { showAlert("Please select the auto-reply mode."); return; }
546
-
547
-                                              } else { showAlert("Please enter the text of the auto-reply."); return; }
548
-
549
-                                            } else { showAlert("Please select a phone number if at least one number is available in the 'Phone Number' drop-down list. Otherwise, you should contact the administrator."); return; }
550
-
551
-                                            $(this).attr("value", "Edit");
552
-
553
-                                        } else {
554
-                                            $("#arplsave-"+ crntrwnmbr).attr("value", "Save");
555
-                                        }
556
-
557
-                                     });
558
-
559
-				  }
560
-                                  saveArplRow();
561
-
562
-
563
-				  // Remove a row
564
-				  function removeArplRow() {
565
-				       $('[id^="rmRow-"]').click(function() {
566
-
567
-					  var slctRowRm = $(this).attr("id").replace("rmRow-", "");
568
-					  var crntPhnNmbr = $("#arpphn-"+ slctRowRm).val();
569
-
570
-					  if (confirm("Do you really want to remove this row from the database ?")) {
571
-
572
-					      var rmvArplUrl = OC.generateUrl('/apps/sms_relentless/user/removeautoreplies');
573
-					      $.ajax({
574
-						   url: rmvArplUrl + '/' + userid,
575
-						   method: "POST",
576
-						   dataType: "text",
577
-						   data: { phoneNumber: crntPhnNmbr },
578
-						   success: function(delresult) {
579
-
580
-						                     if (delresult.indexOf("success") > -1) {
581
-						                         showAlert("The auto-reply has been removed successfully!");
582
-						                         $("#arpphn-"+ slctRowRm).closest("tr").remove();
583
-						                     } else if (delresult.indexOf("failure") > -1) {
584
-						                         showAlert("Error while trying to remove auto-reply data!");
585
-						                     } else if (delresult.indexOf("not allowed") > -1) {
586
-                                                                         showAlert("You cannot remove the auto-reply saved by another user.");
587
-                                                                     }
588
-						   },
589
-						   error: function() { showAlert("Error while attempting to remove auto-reply data! You can check the Nextcloud log to find more details about this issue."); }
590
-					       });
591
-					  }
592
-				       });
593
-				  }
594
-				  removeArplRow();
595
-
596
-                                  // Add a new row
597
-                                  $("#addArplRow").click(function() {
598
-
599
-                                     if ($("#autoReplyTbl").find("tr:last-child").find(".arplPhoneNmbr").length > 0) {
600
-                                         var lastarpl = $("#autoReplyTbl").find("tr:last-child").find(".arplPhoneNmbr").attr("id").replace("arpphn-", "");
601
-                                         var indArplAdd = parseInt(lastarpl + 1);
602
-                                     } else { var indArplAdd = 0; }
603
-			             $("#autoReplyTbl").append("<tr><td><input type='text' class='arplAuthor' value='"+ cusrDisplayName +"' disabled></td><td><select id='arpphn-"+ indArplAdd +"' class='arplPhoneNmbr'>"+ numbersListItems +"</select></td><td><div id='arplmode-"+ indArplAdd +"' class='arplMode'><select id='modeselect-"+ indArplAdd +"' class='selectArplMode'><option value='' selected>Select mode</option><option value='daily'>Daily mode</option><option value='vacation'>Vacation mode</option></select><div id='modecont-"+ indArplAdd +"' class='modeContent'></div></div></td><td><textarea id='arpltxt-"+ indArplAdd +"' class='arplText' rows='20' cols='40' placeholder='Enter the auto-reply message here.'></textarea></td><td><img id='rmRow-"+ indArplAdd +"' class='removeRow' src='/apps/sms_relentless/img/closewnd.svg' title='Remove this row from the database' style='cursor:pointer;margin:9px 8px 0px 18px;'></td><td><input type='submit' id='arplsave-"+ indArplAdd +"' class='saveAutoReply' value='Save' title='Save Row' /></td></tr>");
604
-
605
-                                     selectMode();
606
-                                     saveArplRow();
607
-                                     removeArplRow();
608
-
609
-			             // Check if there is an auto-reply set for the same phone number
610
-				     $("#arpphn-"+ indArplAdd).change(function() {
611
-					 var selectedPhNb = $("#arpphn-"+ indArplAdd).val();
612
-					 var allArplPhNmbrs = $("#autoReplyTbl").find("tr").find(".arplPhoneNmbr");
613
-					 var phNbChck = 0;
614
-					 allArplPhNmbrs.each(function() {
615
-					    var slctphnb = ($(this).val())? $(this).val() : $(this).text();
616
-					    if (selectedPhNb == slctphnb) { phNbChck++; }
617
-					 });
618
-
619
-					 if (phNbChck == 2) {
620
-					     showAlert("There is already an auto-reply set up for this phone number. Please edit its own row, or choose a different phone number.");
621
-					     $(this).val('');
622
-					     return;
623
-					 }
624
-				     });
625
-                                  });
626
-
627
-		  },
628
-		  error: function() {
629
-                                    $("#autoRplPhoneNb").removeClass('icon-loading'); 
630
-                                    showAlert("Error while attempting to get the auto-reply settings! You can check the Nextcloud log to find more details about this issue.");
631
-                  }
632
-         });
633
-
634
-     },
635
-     error: function() {
636
-                  showAlert('Error while getting the settings! You can check the Nextcloud log to find more details about this issue.');
637
-     }
638
-  });
639
-
640
-
641
-
642
-  // Save personal settings for non-admin users
643
-  $("#save_sms_settings").on("click", function(event) {
644
-
645
-     if (isadm == 'reguser') {
646
-
647
-	    event.preventDefault();
648
-//	    OC.msg.startAction('#smsr_save_msg', t('sms_relentless', 'Saved'));
649
-
650
-	    var baseUrlsave = OC.generateUrl('/apps/sms_relentless/user/updatesettings');
651
-
652
-	    var messagesperpageinit = $("#messagesperpage").val();
653
-	    var messagesperpagesec = messagesperpageinit.replace(/[^0-9]/g, '');
654
-
655
-	    if (messagesperpagesec != '') {
656
-		var messagesperpageproc = messagesperpagesec;
657
-	    } else {
658
-		var messagesperpageproc = 100;
659
-	    }
660
-
661
-	    var getnotify = 0;
662
-
663
-	    if ($("#get_notify").is(':checked')) {
664
-		getnotify = 1;
665
-	    }
666
-
667
-	    var emailaddressinit = $("#notification_email").val();
668
-
669
-	    function validate_email($email) {
670
-		var email_reg = /^([\w-\.]+@([\w-]+\.)+[\w-]{2,4})?$/;
671
-		return email_reg.test($email);
672
-	    }
673
-
674
-	    if (validate_email(emailaddressinit)) {
675
-		 var notifyemail = emailaddressinit;
676
-	    } else {
677
-		 var notifyemail = '';
678
-	    }
679
-
680
-	    var includesmsinemail = 0;
681
-	    if ($("#includesmsinemail").is(':checked')) {
682
-		includesmsinemail = 1;
683
-                if ($("#notification_email").val().trim() == '') {
684
-                    showAlert("Please enter an email address in the field: 'I want to receive a notification to the email address from below ...', or uncheck the checkbox: 'Include the SMS/MMS message in the email notification itself'.");
685
-                    return;
686
-                }
687
-	    }
688
-
689
-	    var showdisplaynm = 0;
690
-	    if ($("#showdisplaynames").is(':checked')) {
691
-		showdisplaynm = 1;
692
-	    }
693
-
694
-	    var datatosave = {
695
-			      userId: userid,
696
-		              telapiUrlRec: $("#telapi_url_rec").val(),
697
-		              telapiUrl: $("#telapi_url").val(),
698
-		              nexapiUrlRec: $("#nexapi_url_rec").val(),
699
-		              nexapiUrl: $("#nexapi_url").val(),
700
-		              twilapiUrlRec: $("#twilapi_url_rec").val(),
701
-		              twilapiUrl: $("#twilapi_url").val(),
702
-		              flowapiUrlRec: $("#flowapi_url_rec").val(),
703
-		              flowapiUrl: $("#flowapi_url").val(),
704
-			      messagesperpage: messagesperpageproc,
705
-			      getNotify: getnotify,
706
-			      notificationEmail: notifyemail,
707
-			      getsmsinemail: includesmsinemail,
708
-			      showDisplayNames: showdisplaynm
709
-	    };
710
-
711
-
712
-	    $.ajax({
713
-	       method: 'PUT',
714
-	       url: baseUrlsave + '/' + userid,
715
-	       contentType: 'application/json',
716
-	       data: JSON.stringify(datatosave),
717
-	       success: function() {
718
-                               OC.msg.startAction('#smsr_save_msg', t('sms_relentless', 'Saved'));
719
-	       },
720
-	       error: function() {
721
-		    showAlert('Error while attempting to save the settings! You can check the Nextcloud log to find more details about this issue.');
722
-	       }
723
-	    });
724
-
725
-
726
-     } else if (isadm == 'admin') {
727
-
728
-	    // Save personal settings for admins
729
-	    event.preventDefault();
730
-//	    OC.msg.startAction('#smsr_save_msg', t('sms_relentless', 'Saved'));
731
-
732
-	    var baseUrlsaveadm = OC.generateUrl('/apps/sms_relentless/user/updatepersadmnsettings');
733
-
734
-	    var messagesperpageinit = $("#messagesperpage").val();
735
-	    var messagesperpagesec = messagesperpageinit.replace(/[^0-9]/g, '');
736
-
737
-	    if (messagesperpagesec != '') {
738
-		var messagesperpageproc = messagesperpagesec;
739
-	    } else {
740
-		var messagesperpageproc = 100;
741
-	    }
742
-
743
-	    var getnotify = 0;
744
-
745
-	    if ($("#get_notify").is(':checked')) {
746
-		getnotify = 1;
747
-	    }
748
-
749
-	    var emailaddressinit = $("#notification_email").val();
750
-
751
-	    function validate_email($email) {
752
-		var email_reg = /^([\w-\.]+@([\w-]+\.)+[\w-]{2,4})?$/;
753
-		return email_reg.test($email);
754
-	    }
755
-
756
-	    if (validate_email(emailaddressinit)) {
757
-		 var notifyemail = emailaddressinit;
758
-	    } else {
759
-		 var notifyemail = '';
760
-	    }
761
-
762
-	    var includesmsinemail = 0;
763
-	    if ($("#includesmsinemail").is(':checked')) {
764
-		includesmsinemail = 1;
765
-                if ($("#notification_email").val().trim() == '') {
766
-                    showAlert("Please enter an email address in the field: 'I want to receive a notification to the email address from below ...', or uncheck the checkbox: 'Include the SMS/MMS message in the email notification itself'.");
767
-                    return;
768
-                }
769
-	    }
770
-
771
-	    var showdisplaynm = 0;
772
-	    if ($("#showdisplaynames").is(':checked')) {
773
-		showdisplaynm = 1;
774
-	    }
775
-
776
-	    var datatosave = {
777
-			      userId: userid,
778
-			      messagesperpage: messagesperpageproc,
779
-			      getNotify: getnotify,
780
-			      notificationEmail: notifyemail,
781
-			      getsmsinemail: includesmsinemail,
782
-			      showDisplayNames: showdisplaynm
783
-	    };
784
-
785
-
786
-	    $.ajax({
787
-	       method: 'PUT',
788
-	       url: baseUrlsaveadm + '/' + userid,
789
-	       contentType: 'application/json',
790
-	       data: JSON.stringify(datatosave),
791
-	       success: function() {
792
-                               OC.msg.startAction('#smsr_save_msg', t('sms_relentless', 'Saved'));
793
-	       },
794
-	       error: function() {
795
-		    showAlert('Error while attempting to save the settings! You can check the Nextcloud log to find more details about this issue.');
796
-	       }
797
-	    });
798
-
799
-     }
800
-  });
801
-
802
-  function showAlert(alertText) {
803
-
804
-     let alertwnd = "<div id='alertMessage'>";
805
-     alertwnd += "<a id='closeAlertWnd' title='Close this window'></a>";
806
-     alertwnd += "<div id='alertTextWrap'>"+ alertText +"</div>";
807
-     alertwnd += "<input type='submit' id='alertOk' value='OK'>";
808
-     alertwnd += "</div>";
809
-
810
-     $("#content").append("<div id='alertMsgOverlay'></div>");
811
-     $("#content").append(alertwnd);
812
-
813
-     let topDist = parseInt((window.innerHeight / 2).toFixed(2) - 152) +"px";
814
-     let leftDist = parseInt((window.innerWidth / 2).toFixed(2) - 150) +"px";
815
-     $("#alertMessage").css({ "top" : topDist, "left" : leftDist });
816
-
817
-     $("#closeAlertWnd").click(function() { $("#alertMsgOverlay").remove(); $("#alertMessage").remove(); });
818
-     $("#alertMsgOverlay").click(function() { $("#alertMsgOverlay").remove(); $("#alertMessage").remove(); });
819
-     $("#alertOk").click(function() { $("#alertMsgOverlay").remove(); $("#alertMessage").remove(); });
820
-  }
821
-
822
-
823
-});
Browse code

added files to implement pop-up windows, etc.

DoubleBastionAdmin authored on 20/05/2023 01:06:57
Showing 1 changed files
1 1
new file mode 100644
... ...
@@ -0,0 +1,823 @@
1
+/**
2
+ * @copyright 2021 Double Bastion LLC <www.doublebastion.com>
3
+ *
4
+ * @author Double Bastion LLC
5
+ *
6
+ * @license GNU AGPL version 3 or any later version
7
+ *
8
+ * This program is free software; you can redistribute it and/or
9
+ * modify it under the terms of the GNU AFFERO GENERAL PUBLIC LICENSE
10
+ * License as published by the Free Software Foundation; either
11
+ * version 3 of the License, or any later version.
12
+ *
13
+ * This program is distributed in the hope that it will be useful,
14
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
15
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
16
+ * GNU AFFERO GENERAL PUBLIC LICENSE for more details.
17
+ *
18
+ * You should have received a copy of the GNU Affero General Public
19
+ * License along with this program.  If not, see <http://www.gnu.org/licenses/>.
20
+ *
21
+ */
22
+
23
+$(document).ready(function() {
24
+
25
+  var userid = "<?php p($userId); ?>";
26
+  var isadm = '';
27
+
28
+  // Get personal settings
29
+  var baseUrlget = OC.generateUrl('/apps/sms_relentless/user/getsettings');
30
+
31
+  $.ajax({
32
+     method: 'GET',
33
+     url: baseUrlget + '/' + userid,
34
+     contentType: 'application/json',
35
+     success: function(settingsfromdb) {
36
+
37
+         // Add the webhook URLs section, if the user is not an admin
38
+         if (settingsfromdb.adminornot == 'reguser') {
39
+
40
+             isadm = 'reguser';
41
+
42
+             $("#appTitlePrg").append('<p id="settings-dscr"><h3>Enter your options in the fields from below. As a non-admin user, you can use any of the SMS service providers from \
43
+                  below, on the condition that an admin has shared with you his API keys for that provider:</h3></p><br>');
44
+
45
+             $("#nadmProvSection").append('<div class="providerSettings"><p><label for="telapi_url_rec" class="setlabeltext"><b>Telnyx webhook URL for incoming SMS/MMS</b> (Generate \
46
+                  the URL by pressing the button from below. Don\'t forget to also click the \'Save\' button at the bottom of this page after entering all the options, to save \
47
+                  all the settings to the database.)</label></p> \
48
+                  <input type="button" id="generate_tel_rcpt" class="generateUrl" value="Generate new webhook URL for incoming SMS/MMS" /> \
49
+                  <input type="text" class="smsr_textboxspec" id="telapi_url_rec" name="telapi_url_rec" autocomplete="false" /> \
50
+                  <span id="copyToClipboardtel" class="icon icon-clippy" title="Copy to clipboard"></span><br><br> \
51
+                  \
52
+                  <p><label for="telapi_url" class="setlabeltext"><b>Telnyx webhook URL for delivery receipts</b> (This URL will be included by SMS Relentless in message sending \
53
+                  requests, so that Telnyx will know where to send the delivery receipts. Just generate it by pressing the button from below. Don\'t forget to click the \'Save\' \
54
+                  button at the bottom of this page after entering all the options, to save all the settings to the database.)</label></p> \
55
+                  <input type="button" id="generate_tel_delrcpt" class="generateUrl" value="Generate new webhook URL for delivery receipts" /> \
56
+                  <input type="text" id="telapi_url" name="telapi_url" autocomplete="false" /></div><br><br> \
57
+                  \
58
+                  <div class="providerSettings"><p><label for="nexapi_url_rec" class="setlabeltext"><b>Plivo webhook URL for incoming SMS/MMS</b> (Generate the URL by pressing \
59
+                  the button from below. Don\'t forget to also click the \'Save\' button at the bottom of this page after entering all the options, to save all the settings \
60
+                  to the database.)</label></p> \
61
+                  <input type="button" id="generate_nex_rcpt" class="generateUrl" value="Generate new webhook URL for incoming SMS/MMS" /> \
62
+                  <input type="text" class="smsr_textboxspec" id="nexapi_url_rec" name="nexapi_url_rec" autocomplete="false" /> \
63
+                  <span id="copyToClipboardnex" class="icon icon-clippy" title="Copy to clipboard"></span><br><br> \
64
+                  \
65
+                  <p><label for="nexapi_url" class="setlabeltext"><b>Plivo webhook URL for delivery receipts</b> (This URL will be included by SMS Relentless in message sending \
66
+                  requests, so that Plivo will know where to send the delivery receipts. Just generate it by pressing the button from below. Don\'t forget to click the \'Save\' \
67
+                  button at the bottom of this page after entering all the options, to save all the settings to the database.)</label></p> \
68
+                  <input type="button" id="generate_nex_delrcpt" class="generateUrl" value="Generate new webhook URL for delivery receipts" /> \
69
+                  <input type="text" id="nexapi_url" name="nexapi_url" autocomplete="false" /></div><br><br> \
70
+                  \
71
+                  <div class="providerSettings"><p><label for="twilapi_url_rec" class="setlabeltext"><b>Twilio webhook URL for incoming SMS/MMS</b> (Generate the URL by pressing \
72
+                  the button from below. Don\'t forget to also click the \'Save\' button at the bottom of this page after entering all the options, to save all the settings to \
73
+                  the database.)</label></p> \
74
+                  <input type="button" id="generate_twil_rcpt" class="generateUrl" value="Generate new webhook URL for incoming SMS/MMS" /> \
75
+                  <input type="text" class="smsr_textboxspec" id="twilapi_url_rec" name="twilapi_url_rec" autocomplete="false" /> \
76
+                  <span id="copyToClipboardtwil" class="icon icon-clippy" title="Copy to clipboard"></span><br><br> \
77
+                  \
78
+                  <p><label for="twilapi_url" class="setlabeltext"><b>Twilio webhook URL for delivery receipts</b> (This URL will be included by SMS Relentless in message sending \
79
+                  requests, so that Twilio will know where to send the delivery receipts. Just generate it by pressing the button from below. Don\'t forget to click the \'Save\' \
80
+                  button at the bottom of this page after entering all the options, to save all the settings to the database.)</label></p> \
81
+                  <input type="button" id="generate_twil_delrcpt" class="generateUrl" value="Generate new webhook URL for delivery receipts" /> \
82
+                  <input type="text" id="twilapi_url" name="twilapi_url" autocomplete="false" /></div><br><br> \
83
+                  \
84
+                  <div class="providerSettings"><p><label for="flowapi_url_rec" class="setlabeltext"><b>Flowroute webhook URL for incoming SMS/MMS</b> (Generate the URL by pressing \
85
+                  the button from below. Don\'t forget to also click the \'Save\' button at the bottom of this page after entering all the options, to save all the settings to \
86
+                  the database.)</label></p> \
87
+                  <input type="button" id="generate_flow_rcpt" class="generateUrl" value="Generate new webhook URL for incoming SMS/MMS" /> \
88
+                  <input type="text" class="smsr_textboxspec" id="flowapi_url_rec" name="flowapi_url_rec" autocomplete="false" /> \
89
+                  <span id="copyToClipboardflow" class="icon icon-clippy" title="Copy to clipboard"></span><br><br> \
90
+                  \
91
+                  <p><label for="flowapi_url" class="setlabeltext"><b>Flowroute webhook URL for delivery receipts</b> (This URL will be included by SMS Relentless in message sending \
92
+                  requests, so that Flowroute will know where to send the delivery receipts. Just generate it by pressing the button from below. Don\'t forget to click the \'Save\' \
93
+                  button at the bottom of this page after entering all the options, to save all the settings to the database.)</label></p> \
94
+                  <input type="button" id="generate_flow_delrcpt" class="generateUrl" value="Generate new webhook URL for delivery receipts" /> \
95
+                  <input type="text" id="flowapi_url" name="flowapi_url" autocomplete="false" /><br><br> \
96
+                  Flowroute only supports sending/receiving SMS/MMS messages within USA and Canada and it doesn\'t support Alphanumeric Sender IDs.</div><br>');
97
+
98
+
99
+		  $("#telapi_url_rec").val(settingsfromdb.telapi_url_rec);
100
+		  $("#telapi_url").val(settingsfromdb.telapi_url);
101
+		  $("#nexapi_url_rec").val(settingsfromdb.nexapi_url_rec);
102
+		  $("#nexapi_url").val(settingsfromdb.nexapi_url);
103
+		  $("#twilapi_url_rec").val(settingsfromdb.twilapi_url_rec);
104
+		  $("#twilapi_url").val(settingsfromdb.twilapi_url);
105
+		  $("#flowapi_url_rec").val(settingsfromdb.flowapi_url_rec);
106
+		  $("#flowapi_url").val(settingsfromdb.flowapi_url);
107
+		  $("#messagesperpage").val(settingsfromdb.messagesperpage);
108
+
109
+		  if (settingsfromdb.get_notify == 1) {
110
+		      $("#get_notify").attr('checked', true);
111
+		  } else {
112
+		      $("#get_notify").attr('checked', false);
113
+		  }
114
+
115
+		  $("#notification_email").val(settingsfromdb.notification_email);
116
+
117
+		  if (settingsfromdb.getsmsinemail == 1) {
118
+		      $("#includesmsinemail").attr('checked', true);
119
+		  } else {
120
+		      $("#includesmsinemail").attr('checked', false);
121
+		  }
122
+
123
+		  if (settingsfromdb.show_display_names == 1) {
124
+		      $("#showdisplaynames").attr('checked', true);
125
+		  } else {
126
+		      $("#showdisplaynames").attr('checked', false);
127
+		  }
128
+/*
129
+		  var telnyxwhurlrec = '';
130
+		  var telnyxwhurl = '';
131
+		  var plivowhurlrec = '';
132
+		  var plivodrwhurl = '';
133
+		  var twilwhurlrec = '';
134
+		  var twildrwhurl = '';
135
+		  var flowwhurlrec = '';
136
+		  var flowdrwhurl = '';
137
+*/
138
+		  function randomStr(strlength) {
139
+			var fintext = "";
140
+			var keyspace = '0123456789abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ';
141
+			for (var i = 0; i < strlength; i++) {
142
+			     fintext += keyspace.charAt(Math.floor(Math.random() * keyspace.length));
143
+			}
144
+			return fintext;
145
+		  }
146
+
147
+		  $("#generate_tel_rcpt").on("click", function(event) {
148
+
149
+		     var teltokenrec = randomStr(70);
150
+		     var telnyxwhurlrec = window.location.origin + OC.generateUrl('/apps/sms_relentless/api/recsmstel?telrecparam=') + teltokenrec;
151
+
152
+		     $("#telapi_url_rec").val(telnyxwhurlrec);
153
+		  });
154
+
155
+		  $("#copyToClipboardtel").on("click", function(event) {
156
+		     var $tempEl = $("<input>");
157
+		     $("body").append($tempEl);
158
+		     $tempEl.val($("#telapi_url_rec").val()).select();
159
+		     document.execCommand("Copy");
160
+		     $tempEl.remove();
161
+		     showAlert("The link has been copied to your clipboard!");
162
+		  });
163
+
164
+		  $("#generate_tel_delrcpt").on("click", function(event) {
165
+
166
+		     var teltoken = randomStr(70);
167
+		     var telnyxwhurl = window.location.origin + OC.generateUrl('/apps/sms_relentless/api/recdeliverytel?teldrparam=') + teltoken;
168
+
169
+		     $("#telapi_url").val(telnyxwhurl);
170
+		  });
171
+
172
+
173
+		  $("#generate_nex_rcpt").on("click", function(event) {
174
+
175
+		     var plivotokenrec = randomStr(70);
176
+		     var plivowhurlrec = window.location.origin + OC.generateUrl('/apps/sms_relentless/api/recsmsnex?plivorecparam=') + plivotokenrec;
177
+
178
+		     $("#nexapi_url_rec").val(plivowhurlrec);
179
+		  });
180
+
181
+		  $("#copyToClipboardnex").on("click", function(event) {
182
+		     var $tempElpl = $("<input>");
183
+		     $("body").append($tempElpl);
184
+		     $tempElpl.val($("#nexapi_url_rec").val()).select();
185
+		     document.execCommand("Copy");
186
+		     $tempElpl.remove();
187
+		     showAlert("The link has been copied to your clipboard!");
188
+		  });
189
+
190
+		  $("#generate_nex_delrcpt").on("click", function(event) {
191
+
192
+		     var plivotoken = randomStr(70);
193
+		     var plivodrwhurl = window.location.origin + OC.generateUrl('/apps/sms_relentless/api/recdeliverynex?plivodrparam=') + plivotoken;
194
+
195
+		     $("#nexapi_url").val(plivodrwhurl);
196
+		  });
197
+
198
+
199
+		  $("#generate_twil_rcpt").on("click", function(event) {
200
+
201
+		     var twiltokenrec = randomStr(35);
202
+		     var twilwhurlrec = window.location.origin + OC.generateUrl('/apps/sms_relentless/api/recsmstwil?twilrecparam=') + twiltokenrec;
203
+
204
+		     $("#twilapi_url_rec").val(twilwhurlrec);
205
+		  });
206
+
207
+		  $("#copyToClipboardtwil").on("click", function(event) {
208
+		     var $tempElpl = $("<input>");
209
+		     $("body").append($tempElpl);
210
+		     $tempElpl.val($("#twilapi_url_rec").val()).select();
211
+		     document.execCommand("Copy");
212
+		     $tempElpl.remove();
213
+		     showAlert("The link has been copied to your clipboard!");
214
+		  });
215
+
216
+		  $("#generate_twil_delrcpt").on("click", function(event) {
217
+
218
+		     var twiltoken = randomStr(35);
219
+		     var twildrwhurl = window.location.origin + OC.generateUrl('/apps/sms_relentless/api/recdeliverytwil?twildrparam=') + twiltoken;
220
+
221
+		     $("#twilapi_url").val(twildrwhurl);
222
+		  });
223
+
224
+
225
+		  $("#generate_flow_rcpt").on("click", function(event) {
226
+
227
+		     var flowtokenrec = randomStr(70);
228
+		     var flowwhurlrec = window.location.origin + OC.generateUrl('/apps/sms_relentless/api/recsmsflow?flowrecparam=') + flowtokenrec;
229
+
230
+		     $("#flowapi_url_rec").val(flowwhurlrec);
231
+		  });
232
+
233
+		  $("#copyToClipboardflow").on("click", function(event) {
234
+		     var $tempElpl = $("<input>");
235
+		     $("body").append($tempElpl);
236
+		     $tempElpl.val($("#flowapi_url_rec").val()).select();
237
+		     document.execCommand("Copy");
238
+		     $tempElpl.remove();
239
+		     showAlert("The link has been copied to your clipboard!");
240
+		  });
241
+
242
+		  $("#generate_flow_delrcpt").on("click", function(event) {
243
+
244
+		     var flowtoken = randomStr(70);
245
+		     var flowdrwhurl = window.location.origin + OC.generateUrl('/apps/sms_relentless/api/recdeliveryflow?flowdrparam=') + flowtoken;
246
+
247
+		     $("#flowapi_url").val(flowdrwhurl);
248
+		  });
249
+
250
+
251
+         } else if (settingsfromdb.adminornot == 'admin') {
252
+
253
+                  $("#appTitlePrg").append('<p id="settings-dscr"><h3>Enter your options in the fields from below:</h3></p><br>');
254
+                  isadm = 'admin';
255
+
256
+		  $("#messagesperpage").val(settingsfromdb.messagesperpage);
257
+
258
+		  if (settingsfromdb.get_notify == 1) {
259
+		      $("#get_notify").attr('checked', true);
260
+		  } else {
261
+		      $("#get_notify").attr('checked', false);
262
+		  }
263
+
264
+		  $("#notification_email").val(settingsfromdb.notification_email);
265
+
266
+		  if (settingsfromdb.getsmsinemail == 1) {
267
+		      $("#includesmsinemail").attr('checked', true);
268
+		  } else {
269
+		      $("#includesmsinemail").attr('checked', false);
270
+		  }
271
+
272
+		  if (settingsfromdb.show_display_names == 1) {
273
+		      $("#showdisplaynames").attr('checked', true);
274
+		  } else {
275
+		      $("#showdisplaynames").attr('checked', false);
276
+		  }
277
+         }
278
+
279
+
280
+         // Auto-reply settings
281
+
282
+         // Get the available phone numbers from all providers associated with the access keys entered on the Settings page (restrictions are applied to numbers for non-admins)
283
+         $("#autoRplPhoneNb").addClass('icon-loading');
284
+         var getnumbersUrl = OC.generateUrl("/apps/sms_relentless/user/getautoreplyconf");
285
+
286
+	 $.ajax({
287
+		  url: getnumbersUrl + '/' + userid,
288
+		  type: "GET",
289
+                  contentType: 'application/json',
290
+		  success: function(autoreplydata) {
291
+
292
+                                    $("#autoRplPhoneNb").removeClass('icon-loading');
293
+                                    var cusrDisplayName = autoreplydata.userdisplayname;
294
+                                    var availPhoneNmbrs = autoreplydata.phonenumbers;
295
+                                    var autorpldata = autoreplydata.autoreplies;
296
+
297
+				    if (autorpldata.length > 0) { 
298
+				        var arplNmb = autorpldata.length;
299
+				    } else { 
300
+				        var arplNmb = 0; 
301
+				    }
302
+
303
+				    // List the auto-replies for the phone numbers available for the current user
304
+				    if (arplNmb == 0) {
305
+
306
+				        $("#autoReplyTbl").append("<tr><td><input type='text' class='arplAuthor' value='"+ cusrDisplayName +"' disabled></td><td><select id='arpphn-"+ arplNmb +"' class='arplPhoneNmbr'></select></td><td><div id='arplmode-"+ arplNmb +"' class='arplMode'><select id='modeselect-"+ arplNmb +"' class='selectArplMode'><option value='' selected>Select mode</option><option value='daily'>Daily mode</option><option value='vacation'>Vacation mode</option></select><div id='modecont-"+ arplNmb +"' class='modeContent'></div></div></td><td><textarea id='arpltxt-"+ arplNmb +"' class='arplText' rows='20' cols='40' placeholder='Enter the auto-reply message here.'></textarea></td><td><img id='rmRow-"+ arplNmb +"' class='removeRow' src='/apps/sms_relentless/img/closewnd.svg' title='Remove this row from the database' style='cursor:pointer;margin:9px 8px 0px 18px;'></td><td><input type='submit' id='arplsave-"+ arplNmb +"' class='saveAutoReply' value='Save' title='Save Row' /></td></tr>");
307
+				        $("#autoReplyTbl").append("<div><img id='addArplRow' src='/apps/sms_relentless/img/add.svg' title='Add Row'></div>");
308
+
309
+				    } else {
310
+
311
+				        for (k = 0; k < arplNmb; k++) {
312
+
313
+                                             if (autorpldata[k].days_of_week != '') {
314
+
315
+                                                 var slctdMode = "<option value=''>Select mode</option><option value='daily' selected>Daily mode</option><option value='vacation'>Vacation mode</option>";
316
+                                                 var dailyStartArr = autorpldata[k].daily_start.split(":");
317
+                                                 var dailyEndArr = autorpldata[k].daily_end.split(":");
318
+
319
+		                                 var dlHrStartOptions = "";
320
+			                         for (var hr = 0; hr < 24; hr++) {
321
+		                                      if (dailyStartArr[0] != hr.toLocaleString('en-US', {minimumIntegerDigits: 2, useGrouping:false})) {
322
+			                                  dlHrStartOptions += "<option value='"+ hr.toLocaleString('en-US', {minimumIntegerDigits: 2, useGrouping:false}) +"'>"+ hr.toLocaleString('en-US', {minimumIntegerDigits: 2, useGrouping:false}) +"</option>";
323
+		                                      } else {
324
+			                                  dlHrStartOptions += "<option value='"+ hr.toLocaleString('en-US', {minimumIntegerDigits: 2, useGrouping:false}) +"' selected>"+ hr.toLocaleString('en-US', {minimumIntegerDigits: 2, useGrouping:false}) +"</option>";
325
+		                                      }
326
+			                         }
327
+
328
+		                                 var dlMnStartOptions = "";
329
+			                         for (var mn = 0; mn < 60; mn++) {
330
+		                                      if (dailyStartArr[0] != mn.toLocaleString('en-US', {minimumIntegerDigits: 2, useGrouping:false})) {
331
+			                                  dlMnStartOptions += "<option value='"+ mn.toLocaleString('en-US', {minimumIntegerDigits: 2, useGrouping:false}) +"'>"+ mn.toLocaleString('en-US', {minimumIntegerDigits: 2, useGrouping:false}) +"</option>";
332
+		                                      } else {
333
+			                                  dlMnStartOptions += "<option value='"+ mn.toLocaleString('en-US', {minimumIntegerDigits: 2, useGrouping:false}) +"' selected>"+ mn.toLocaleString('en-US', {minimumIntegerDigits: 2, useGrouping:false}) +"</option>";
334
+		                                      }
335
+			                         }
336
+
337
+		                                 var dlHrEndOptions = "";
338
+			                         for (var hr = 0; hr < 24; hr++) {
339
+		                                      if (dailyEndArr[0] != hr.toLocaleString('en-US', {minimumIntegerDigits: 2, useGrouping:false})) {
340
+			                                  dlHrEndOptions += "<option value='"+ hr.toLocaleString('en-US', {minimumIntegerDigits: 2, useGrouping:false}) +"'>"+ hr.toLocaleString('en-US', {minimumIntegerDigits: 2, useGrouping:false}) +"</option>";
341
+		                                      } else {
342
+			                                  dlHrEndOptions += "<option value='"+ hr.toLocaleString('en-US', {minimumIntegerDigits: 2, useGrouping:false}) +"' selected>"+ hr.toLocaleString('en-US', {minimumIntegerDigits: 2, useGrouping:false}) +"</option>";
343
+		                                      }
344
+			                         }
345
+
346
+		                                 var dlMnEndOptions = "";
347
+			                         for (var mn = 0; mn < 60; mn++) {
348
+		                                      if (dailyEndArr[1] != mn.toLocaleString('en-US', {minimumIntegerDigits: 2, useGrouping:false})) {
349
+			                                  dlMnEndOptions += "<option value='"+ mn.toLocaleString('en-US', {minimumIntegerDigits: 2, useGrouping:false}) +"'>"+ mn.toLocaleString('en-US', {minimumIntegerDigits: 2, useGrouping:false}) +"</option>";
350
+		                                      } else {
351
+			                                  dlMnEndOptions += "<option value='"+ mn.toLocaleString('en-US', {minimumIntegerDigits: 2, useGrouping:false}) +"' selected>"+ mn.toLocaleString('en-US', {minimumIntegerDigits: 2, useGrouping:false}) +"</option>";
352
+		                                      }
353
+			                         }
354
+
355
+                                                 var modeContent = "<div class='daysOfWeek'>Days of the week:<div class='tooltipautoreply'><div id='infoautoreply'>i</div><div class='autorpltooltip'>Enter the order number of the days of the week in which the auto-reply will be sent. For example, to send the auto-reply every day from Monday to Friday (outside the time interval specified below), enter 1,2,3,4,5 To send the auto-reply only Monday, Thursday and Friday enter 1,4,5 To send the auto-reply every day of the week enter 1,2,3,4,5,6,7</div></div></div><input type='text' id='weekdays-"+ k +"' class='daysInWeek' value='"+ autorpldata[k].days_of_week +"'><div class='chooseTInterval'>Send auto-reply <span style='color:#ad0202'>outside</span> this interval:<div class='tooltipautoreplyst'><div id='infoautoreplyst'>i</div><div class='autorpltooltipst'>These fields specify the time of the server. If the server is located in a time zone that is different from that of the owner/company, the time interval entered here should be adjusted accordingly.</div></div></div><div class='selectArplHours'><select id='dmstarthr-"+ k +"' class='selectHrMin'>"+ dlHrStartOptions +"</select><select id='dmstartmn-"+ k +"' class='selectHrMin'>"+ dlMnStartOptions +"</select><span style='font-weight: 600'> — </span><select id='dmendhr-"+ k +"' class='selectHrMin'>"+ dlHrEndOptions +"</select><select id='dmendmn-"+ k +"' class='selectHrMin'>"+ dlMnEndOptions +"</select></div>";
356
+
357
+                                             } else {
358
+
359
+                                                 var vctnStart = autorpldata[k].vacation_start.split(" ")[0];
360
+                                                 var vctnEnd = autorpldata[k].vacation_end.split(" ")[0];
361
+
362
+                                                 var slctdMode = "<option value=''>Select mode</option><option value='daily'>Daily mode</option><option value='vacation' selected>Vacation mode</option>";
363
+                                                 var modeContent = "<div class='chooseDateIntvl'>Send auto-reply <span style='color:#ad0202'>inside</span> this interval:</div><div class='arplstrtendDates'><div class='stdtTitle'>Start Date</div><input type='text' id='startDT-"+ k +"' class='startDate' placeholder='Pick a date' value='"+ vctnStart +"'><div class='enddtTitle'>End Date</div><input type='text' id='endDT-"+ k +"' class='endDate' placeholder='Pick a date' value='"+ vctnEnd +"'></div>"
364
+                                             }
365
+
366
+				             $("#autoReplyTbl").append("<tr><td><input type='text' class='arplAuthor' value='"+ autorpldata[k].saved_by_dsplname +"' disabled></td><td><select id='arpphn-"+ k +"' class='arplPhoneNmbr' style='pointer-events:none'><option selected>"+ autorpldata[k].phone_number +"</option></select></td><td><div id='arplmode-"+ k +"' class='arplMode'><select id='modeselect-"+ k +"' class='selectArplMode'>"+ slctdMode +"</select><div id='modecont-"+ k +"' class='modeContent'>"+ modeContent +"</div></div></td><td><textarea id='arpltxt-"+ k +"' class='arplText' rows='20' cols='40' placeholder='Enter the auto-reply message here.'>"+ autorpldata[k].message_text +"</textarea></td><td><img id='rmRow-"+ k +"' class='removeRow' src='/apps/sms_relentless/img/closewnd.svg' title='Remove this row from the database' style='cursor:pointer;margin:9px 8px 0px 18px;'></td><td><input type='submit' id='arplsave-"+ k +"' class='saveAutoReply' value='Edit' title='Edit Row' /></td></tr>");
367
+				        }
368
+				        $("#autoReplyTbl").append("<div><img id='addArplRow' src='/apps/sms_relentless/img/add.svg' title='Add Row'></div>");
369
+				    }
370
+
371
+
372
+				    // Create a list with all the available phone numbers
373
+                                    var numbersListItems = "<option value='' selected>Select phone number</option>";
374
+
375
+				    $.each(availPhoneNmbrs, function(key, indsmsnmb) {
376
+				           numbersListItems += "<option value='"+ indsmsnmb +"'>"+ indsmsnmb +"</option>";
377
+				    });
378
+
379
+                                    if (arplNmb == 0) {
380
+				        $("#arpphn-"+ arplNmb).append(numbersListItems);
381
+                                    }
382
+
383
+                                    // Initialize the date picker
384
+			            $('[id^="endDT-"]').datepicker({ dateFormat: "yy-mm-dd" });
385
+			            $('[id^="startDT-"]').datepicker({ dateFormat: "yy-mm-dd" });
386
+
387
+
388
+                                    // Select the auto-reply mode
389
+                                    function selectMode() {
390
+
391
+		                            $('[id^="modeselect-"]').change(function() {
392
+
393
+		                               var crtnmbr = $(this).attr("id").replace("modeselect-", "");
394
+
395
+		                               var dailyHrStart = "";
396
+		                               for (var h = 0; h < 24; h++) {
397
+		                                    dailyHrStart += "<option value='"+ h.toLocaleString('en-US', {minimumIntegerDigits: 2, useGrouping:false}) +"'>"+ h.toLocaleString('en-US', {minimumIntegerDigits: 2, useGrouping:false}) +"</option>";
398
+		                               }
399
+
400
+		                               var dailyMnStart = "";
401
+		                               for (var m = 0; m < 60; m++) {
402
+		                                    dailyMnStart += "<option value='"+ m.toLocaleString('en-US', {minimumIntegerDigits: 2, useGrouping:false}) +"'>"+ m.toLocaleString('en-US', {minimumIntegerDigits: 2, useGrouping:false}) +"</option>";
403
+		                               }
404
+
405
+		                               var dailyHrEnd = dailyHrStart;
406
+		                               var dailyMnEnd = dailyMnStart;
407
+
408
+		                               if ($(this).val() == 'daily') {
409
+		                                   $("#modecont-"+ crtnmbr).empty();
410
+		                                   $("#modecont-"+ crtnmbr).append("<div class='daysOfWeek'>Days of the week:<div class='tooltipautoreply'><div id='infoautoreply'>i</div><div class='autorpltooltip'>Enter the order number of the days of the week. For example, to send the auto-reply every day from Monday to Friday outside the specified time interval, enter 1,2,3,4,5 To send the auto-reply only Monday, Thursday and Friday enter 1,4,5 To send the auto-reply every day of the week enter 1,2,3,4,5,6,7</div></div></div><input type='text' id='weekdays-"+ crtnmbr +"' class='daysInWeek'><div class='chooseTInterval'>Send auto-reply <span style='color:#ad0202'>outside</span> this interval:<div class='tooltipautoreplyst'><div id='infoautoreplyst'>i</div><div class='autorpltooltipst'>These fields specify the time of the server. If the server is located in a time zone that is different from that of the owner/company, the time interval entered here should be adjusted accordingly.</div></div></div><div class='selectArplHours'><select id='dmstarthr-"+ crtnmbr +"' class='selectHrMin'>"+ dailyHrStart +"</select><select id='dmstartmn-"+ crtnmbr +"' class='selectHrMin'>"+ dailyMnStart +"</select><span style='font-weight: 600'> — </span><select id='dmendhr-"+ crtnmbr +"' class='selectHrMin'>"+ dailyHrEnd +"</select><select id='dmendmn-"+ crtnmbr +"' class='selectHrMin'>"+ dailyMnEnd +"</select></div>");
411
+		                               } else if ($(this).val() == 'vacation') {
412
+		                                   $("#modecont-"+ crtnmbr).empty();
413
+		                                   $("#modecont-"+ crtnmbr).append("<div class='chooseDateIntvl'>Send auto-reply <span style='color:#ad0202'>inside</span> this interval:</div><div class='arplstrtendDates'><div class='stdtTitle'>Start Date</div><input type='text' id='startDT-"+ crtnmbr +"' class='startDate' placeholder='Pick a date'><div class='enddtTitle'>End Date</div><input type='text' id='endDT-"+ crtnmbr +"' class='endDate' placeholder='Pick a date' /></div>");
414
+		                               }
415
+
416
+					       $("#endDT-"+ crtnmbr +"").datepicker({ dateFormat: "yy-mm-dd" });
417
+					       $("#startDT-"+ crtnmbr +"").datepicker({ dateFormat: "yy-mm-dd" });
418
+		                          });
419
+                                  }
420
+                                  selectMode();
421
+
422
+				  // Save the data
423
+				  function saveArplRow() {
424
+
425
+				     $('[id^="arplsave-"]').unbind("click");
426
+				     $('[id^="arplsave-"]').click(function(event) {
427
+
428
+				        event.preventDefault();
429
+				        var crntrwnmbr = $(this).attr("id").replace("arplsave-", "");
430
+
431
+				        if ($(this).attr("value") == "Save") {
432
+
433
+				            var phoneNmbr = $("#arpphn-"+ crntrwnmbr).val();
434
+				            var arplText = $("#arpltxt-"+ crntrwnmbr).val();
435
+				            var slctdMode = $("#modeselect-"+ crntrwnmbr).val();
436
+
437
+				            var slctddmDays = "";
438
+				            var slctdHrStart = "";
439
+				            var slctdMnStart = "";
440
+				            var slctdHrEnd = "";
441
+				            var slctdMnEnd = "";
442
+
443
+				            var vcStartDate = null;
444
+				            var vcEndDate = null;
445
+
446
+				            if (slctdMode == 'daily') {
447
+
448
+				                slctddmDays = $("#weekdays-"+ crntrwnmbr).val().trim();
449
+				                slctdHrStart = $("#dmstarthr-"+ crntrwnmbr).val().trim();
450
+				                slctdMnStart = $("#dmstartmn-"+ crntrwnmbr).val().trim();
451
+				                slctdHrEnd = $("#dmendhr-"+ crntrwnmbr).val().trim();
452
+				                slctdMnEnd = $("#dmendmn-"+ crntrwnmbr).val().trim();
453
+
454
+                                                if (slctdHrStart != '' && slctdMnStart != '') {
455
+                                                    var hrmnStartComp = slctdHrStart +":"+ slctdMnStart;
456
+                                                } else { var hrmnStartComp = ""; }
457
+
458
+                                                if (slctdHrEnd != '' && slctdMnEnd != '') {
459
+                                                    var hrmnEndComp = slctdHrEnd +":"+ slctdMnEnd;
460
+                                                } else { var hrmnEndComp = ""; }
461
+
462
+                                                if (!(/^[1-7\,]+$/.test(slctddmDays))) {
463
+				                    showAlert("The 'Days of the week' field can contain only digits from 1 to 7 and commas (,).");
464
+				                    return;
465
+                                                }
466
+
467
+                                                if (!(/^[0-9]+$/.test(slctdHrStart + slctdMnStart + slctdHrEnd + slctdMnEnd))) {
468
+				                    showAlert("The starting and ending values of the time interval for the 'Daily mode' can contain only digits from 0 to 9.");
469
+				                    return;
470
+                                                }
471
+
472
+                                                if (slctddmDays.trim() == '' || (slctdHrStart == slctdHrEnd && slctdMnStart == slctdMnEnd)) {
473
+				                    showAlert("For the 'Daily mode', you have to enter the order number of the days of the week for which you want the auto-reply to be sent, and you have to set a starting time that is different from the ending time!");
474
+				                    return;
475
+                                                }
476
+
477
+				            } else if (slctdMode == 'vacation') {
478
+		
479
+                                                if ($("#startDT-"+ crntrwnmbr).val().trim() == '' || $("#endDT-"+ crntrwnmbr).val().trim() == '') {
480
+
481
+				                    showAlert("For the 'Vacation mode', you have to enter both a start date and an end date.");
482
+				                    return;
483
+
484
+                                                } else {
485
+
486
+                                                    if (!(/^[0-9\-]+$/.test($("#startDT-"+ crntrwnmbr).val().trim() + $("#endDT-"+ crntrwnmbr).val().trim()))) {
487
+				                        showAlert("The start date and end date values for the 'Vacation mode' can contain only digits from 0 to 9 and hyphens (-).");
488
+				                        return;
489
+                                                    }
490
+
491
+		                                    vcStartDate = $("#startDT-"+ crntrwnmbr).val().trim() +" 00:00:00";
492
+				                    vcEndDate = $("#endDT-"+ crntrwnmbr).val().trim() +" 23:59:59";
493
+				                    var strtDateCmp = new Date(vcStartDate).toJSON().slice(0, 10) +" 00:00:00";
494
+				                    var endDateCmp = new Date(vcEndDate).toJSON().slice(0, 10) +" 23:59:59";
495
+				                    var crntDate = new Date().toJSON().slice(0, 10) +" 23:59:59";
496
+
497
+                                                    if (vcStartDate.trim() == "" || vcEndDate.trim() == "" || (strtDateCmp >= endDateCmp || ((strtDateCmp < crntDate) && (endDateCmp < crntDate)))) {
498
+				                        showAlert("For 'Vacation mode', you have to enter both a start date and an end date, the start date must be before the end date and at least the ending of the time interval must be in the future.");
499
+				                        return;
500
+                                                    }
501
+                                                }
502
+				            }
503
+
504
+
505
+				            if (phoneNmbr != '') {
506
+
507
+				              if (arplText.trim() != '') {
508
+
509
+				                if (slctdMode != '') {
510
+
511
+				                    var saveArplUrl = OC.generateUrl('/apps/sms_relentless/user/updateautoreplies');
512
+				                    var arpldata = {
513
+				                         userId: userid,
514
+				                         savedByDsplname: cusrDisplayName,
515
+				                         phoneNumber: phoneNmbr,
516
+				                         daysOfWeek: slctddmDays,
517
+				                         dailyStart: hrmnStartComp,
518
+				                         dailyEnd: hrmnEndComp,
519
+				                         vacationStart: vcStartDate,
520
+				                         vacationEnd: vcEndDate,
521
+				                         messageText: arplText
522
+				                    };
523
+
524
+					            $.ajax({
525
+					              method: 'PUT',
526
+					              url: saveArplUrl + '/' + userid,
527
+					              contentType: 'application/json',
528
+					              data: JSON.stringify(arpldata),
529
+				                      success: function(messagereceived) {
530
+
531
+				                                   if (messagereceived == 'success') {
532
+				                                       showAlert('The auto-reply has been successfully saved to the database!');
533
+				                                   } else if (messagereceived == 'failure') {
534
+				                                       showAlert('Error while trying to save the auto-reply!');
535
+				                                   } else if (messagereceived == 'not allowed') {
536
+                                                                       showAlert('You cannot change an auto-reply that was saved by a different user.');
537
+                                                                   }
538
+				                      },
539
+					              error: function() {
540
+						                   showAlert('Error while attempting to save the auto-reply! You can check the Nextcloud log to find more details about this issue.');
541
+					              }
542
+					            });
543
+
544
+
545
+                                                } else { showAlert("Please select the auto-reply mode."); return; }
546
+
547
+                                              } else { showAlert("Please enter the text of the auto-reply."); return; }
548
+
549
+                                            } else { showAlert("Please select a phone number if at least one number is available in the 'Phone Number' drop-down list. Otherwise, you should contact the administrator."); return; }
550
+
551
+                                            $(this).attr("value", "Edit");
552
+
553
+                                        } else {
554
+                                            $("#arplsave-"+ crntrwnmbr).attr("value", "Save");
555
+                                        }
556
+
557
+                                     });
558
+
559
+				  }
560
+                                  saveArplRow();
561
+
562
+
563
+				  // Remove a row
564
+				  function removeArplRow() {
565
+				       $('[id^="rmRow-"]').click(function() {
566
+
567
+					  var slctRowRm = $(this).attr("id").replace("rmRow-", "");
568
+					  var crntPhnNmbr = $("#arpphn-"+ slctRowRm).val();
569
+
570
+					  if (confirm("Do you really want to remove this row from the database ?")) {
571
+
572
+					      var rmvArplUrl = OC.generateUrl('/apps/sms_relentless/user/removeautoreplies');
573
+					      $.ajax({
574
+						   url: rmvArplUrl + '/' + userid,
575
+						   method: "POST",
576
+						   dataType: "text",
577
+						   data: { phoneNumber: crntPhnNmbr },
578
+						   success: function(delresult) {
579
+
580
+						                     if (delresult.indexOf("success") > -1) {
581
+						                         showAlert("The auto-reply has been removed successfully!");
582
+						                         $("#arpphn-"+ slctRowRm).closest("tr").remove();
583
+						                     } else if (delresult.indexOf("failure") > -1) {
584
+						                         showAlert("Error while trying to remove auto-reply data!");
585
+						                     } else if (delresult.indexOf("not allowed") > -1) {
586
+                                                                         showAlert("You cannot remove the auto-reply saved by another user.");
587
+                                                                     }
588
+						   },
589
+						   error: function() { showAlert("Error while attempting to remove auto-reply data! You can check the Nextcloud log to find more details about this issue."); }
590
+					       });
591
+					  }
592
+				       });
593
+				  }
594
+				  removeArplRow();
595
+
596
+                                  // Add a new row
597
+                                  $("#addArplRow").click(function() {
598
+
599
+                                     if ($("#autoReplyTbl").find("tr:last-child").find(".arplPhoneNmbr").length > 0) {
600
+                                         var lastarpl = $("#autoReplyTbl").find("tr:last-child").find(".arplPhoneNmbr").attr("id").replace("arpphn-", "");
601
+                                         var indArplAdd = parseInt(lastarpl + 1);
602
+                                     } else { var indArplAdd = 0; }
603
+			             $("#autoReplyTbl").append("<tr><td><input type='text' class='arplAuthor' value='"+ cusrDisplayName +"' disabled></td><td><select id='arpphn-"+ indArplAdd +"' class='arplPhoneNmbr'>"+ numbersListItems +"</select></td><td><div id='arplmode-"+ indArplAdd +"' class='arplMode'><select id='modeselect-"+ indArplAdd +"' class='selectArplMode'><option value='' selected>Select mode</option><option value='daily'>Daily mode</option><option value='vacation'>Vacation mode</option></select><div id='modecont-"+ indArplAdd +"' class='modeContent'></div></div></td><td><textarea id='arpltxt-"+ indArplAdd +"' class='arplText' rows='20' cols='40' placeholder='Enter the auto-reply message here.'></textarea></td><td><img id='rmRow-"+ indArplAdd +"' class='removeRow' src='/apps/sms_relentless/img/closewnd.svg' title='Remove this row from the database' style='cursor:pointer;margin:9px 8px 0px 18px;'></td><td><input type='submit' id='arplsave-"+ indArplAdd +"' class='saveAutoReply' value='Save' title='Save Row' /></td></tr>");
604
+
605
+                                     selectMode();
606
+                                     saveArplRow();
607
+                                     removeArplRow();
608
+
609
+			             // Check if there is an auto-reply set for the same phone number
610
+				     $("#arpphn-"+ indArplAdd).change(function() {
611
+					 var selectedPhNb = $("#arpphn-"+ indArplAdd).val();
612
+					 var allArplPhNmbrs = $("#autoReplyTbl").find("tr").find(".arplPhoneNmbr");
613
+					 var phNbChck = 0;
614
+					 allArplPhNmbrs.each(function() {
615
+					    var slctphnb = ($(this).val())? $(this).val() : $(this).text();
616
+					    if (selectedPhNb == slctphnb) { phNbChck++; }
617
+					 });
618
+
619
+					 if (phNbChck == 2) {
620
+					     showAlert("There is already an auto-reply set up for this phone number. Please edit its own row, or choose a different phone number.");
621
+					     $(this).val('');
622
+					     return;
623
+					 }
624
+				     });
625
+                                  });
626
+
627
+		  },
628
+		  error: function() {
629
+                                    $("#autoRplPhoneNb").removeClass('icon-loading'); 
630
+                                    showAlert("Error while attempting to get the auto-reply settings! You can check the Nextcloud log to find more details about this issue.");
631
+                  }
632
+         });
633
+
634
+     },
635
+     error: function() {
636
+                  showAlert('Error while getting the settings! You can check the Nextcloud log to find more details about this issue.');
637
+     }
638
+  });
639
+
640
+
641
+
642
+  // Save personal settings for non-admin users
643
+  $("#save_sms_settings").on("click", function(event) {
644
+
645
+     if (isadm == 'reguser') {
646
+
647
+	    event.preventDefault();
648
+//	    OC.msg.startAction('#smsr_save_msg', t('sms_relentless', 'Saved'));
649
+
650
+	    var baseUrlsave = OC.generateUrl('/apps/sms_relentless/user/updatesettings');
651
+
652
+	    var messagesperpageinit = $("#messagesperpage").val();
653
+	    var messagesperpagesec = messagesperpageinit.replace(/[^0-9]/g, '');
654
+
655
+	    if (messagesperpagesec != '') {
656
+		var messagesperpageproc = messagesperpagesec;
657
+	    } else {
658
+		var messagesperpageproc = 100;
659
+	    }
660
+
661
+	    var getnotify = 0;
662
+
663
+	    if ($("#get_notify").is(':checked')) {
664
+		getnotify = 1;
665
+	    }
666
+
667
+	    var emailaddressinit = $("#notification_email").val();
668
+
669
+	    function validate_email($email) {
670
+		var email_reg = /^([\w-\.]+@([\w-]+\.)+[\w-]{2,4})?$/;
671
+		return email_reg.test($email);
672
+	    }
673
+
674
+	    if (validate_email(emailaddressinit)) {
675
+		 var notifyemail = emailaddressinit;
676
+	    } else {
677
+		 var notifyemail = '';
678
+	    }
679
+
680
+	    var includesmsinemail = 0;
681
+	    if ($("#includesmsinemail").is(':checked')) {
682
+		includesmsinemail = 1;
683
+                if ($("#notification_email").val().trim() == '') {
684
+                    showAlert("Please enter an email address in the field: 'I want to receive a notification to the email address from below ...', or uncheck the checkbox: 'Include the SMS/MMS message in the email notification itself'.");
685
+                    return;
686
+                }
687
+	    }
688
+
689
+	    var showdisplaynm = 0;
690
+	    if ($("#showdisplaynames").is(':checked')) {
691
+		showdisplaynm = 1;
692
+	    }
693
+
694
+	    var datatosave = {
695
+			      userId: userid,
696
+		              telapiUrlRec: $("#telapi_url_rec").val(),
697
+		              telapiUrl: $("#telapi_url").val(),
698
+		              nexapiUrlRec: $("#nexapi_url_rec").val(),
699
+		              nexapiUrl: $("#nexapi_url").val(),
700
+		              twilapiUrlRec: $("#twilapi_url_rec").val(),
701
+		              twilapiUrl: $("#twilapi_url").val(),
702
+		              flowapiUrlRec: $("#flowapi_url_rec").val(),
703
+		              flowapiUrl: $("#flowapi_url").val(),
704
+			      messagesperpage: messagesperpageproc,
705
+			      getNotify: getnotify,
706
+			      notificationEmail: notifyemail,
707
+			      getsmsinemail: includesmsinemail,
708
+			      showDisplayNames: showdisplaynm
709
+	    };
710
+
711
+
712
+	    $.ajax({
713
+	       method: 'PUT',
714
+	       url: baseUrlsave + '/' + userid,
715
+	       contentType: 'application/json',
716
+	       data: JSON.stringify(datatosave),
717
+	       success: function() {
718
+                               OC.msg.startAction('#smsr_save_msg', t('sms_relentless', 'Saved'));
719
+	       },
720
+	       error: function() {
721
+		    showAlert('Error while attempting to save the settings! You can check the Nextcloud log to find more details about this issue.');
722
+	       }
723
+	    });
724
+
725
+
726
+     } else if (isadm == 'admin') {
727
+
728
+	    // Save personal settings for admins
729
+	    event.preventDefault();
730
+//	    OC.msg.startAction('#smsr_save_msg', t('sms_relentless', 'Saved'));
731
+
732
+	    var baseUrlsaveadm = OC.generateUrl('/apps/sms_relentless/user/updatepersadmnsettings');
733
+
734
+	    var messagesperpageinit = $("#messagesperpage").val();
735
+	    var messagesperpagesec = messagesperpageinit.replace(/[^0-9]/g, '');
736
+
737
+	    if (messagesperpagesec != '') {
738
+		var messagesperpageproc = messagesperpagesec;
739
+	    } else {
740
+		var messagesperpageproc = 100;
741
+	    }
742
+
743
+	    var getnotify = 0;
744
+
745
+	    if ($("#get_notify").is(':checked')) {
746
+		getnotify = 1;
747
+	    }
748
+
749
+	    var emailaddressinit = $("#notification_email").val();
750
+
751
+	    function validate_email($email) {
752
+		var email_reg = /^([\w-\.]+@([\w-]+\.)+[\w-]{2,4})?$/;
753
+		return email_reg.test($email);
754
+	    }
755
+
756
+	    if (validate_email(emailaddressinit)) {
757
+		 var notifyemail = emailaddressinit;
758
+	    } else {
759
+		 var notifyemail = '';
760
+	    }
761
+
762
+	    var includesmsinemail = 0;
763
+	    if ($("#includesmsinemail").is(':checked')) {
764
+		includesmsinemail = 1;
765
+                if ($("#notification_email").val().trim() == '') {
766
+                    showAlert("Please enter an email address in the field: 'I want to receive a notification to the email address from below ...', or uncheck the checkbox: 'Include the SMS/MMS message in the email notification itself'.");
767
+                    return;
768
+                }
769
+	    }
770
+
771
+	    var showdisplaynm = 0;
772
+	    if ($("#showdisplaynames").is(':checked')) {
773
+		showdisplaynm = 1;
774
+	    }
775
+
776
+	    var datatosave = {
777
+			      userId: userid,
778
+			      messagesperpage: messagesperpageproc,
779
+			      getNotify: getnotify,
780
+			      notificationEmail: notifyemail,
781
+			      getsmsinemail: includesmsinemail,
782
+			      showDisplayNames: showdisplaynm
783
+	    };
784
+
785
+
786
+	    $.ajax({
787
+	       method: 'PUT',
788
+	       url: baseUrlsaveadm + '/' + userid,
789
+	       contentType: 'application/json',
790
+	       data: JSON.stringify(datatosave),
791
+	       success: function() {
792
+                               OC.msg.startAction('#smsr_save_msg', t('sms_relentless', 'Saved'));
793
+	       },
794
+	       error: function() {
795
+		    showAlert('Error while attempting to save the settings! You can check the Nextcloud log to find more details about this issue.');
796
+	       }
797
+	    });
798
+
799
+     }
800
+  });
801
+
802
+  function showAlert(alertText) {
803
+
804
+     let alertwnd = "<div id='alertMessage'>";
805
+     alertwnd += "<a id='closeAlertWnd' title='Close this window'></a>";
806
+     alertwnd += "<div id='alertTextWrap'>"+ alertText +"</div>";
807
+     alertwnd += "<input type='submit' id='alertOk' value='OK'>";
808
+     alertwnd += "</div>";
809
+
810
+     $("#content").append("<div id='alertMsgOverlay'></div>");
811
+     $("#content").append(alertwnd);
812
+
813
+     let topDist = parseInt((window.innerHeight / 2).toFixed(2) - 152) +"px";
814
+     let leftDist = parseInt((window.innerWidth / 2).toFixed(2) - 150) +"px";
815
+     $("#alertMessage").css({ "top" : topDist, "left" : leftDist });
816
+
817
+     $("#closeAlertWnd").click(function() { $("#alertMsgOverlay").remove(); $("#alertMessage").remove(); });
818
+     $("#alertMsgOverlay").click(function() { $("#alertMsgOverlay").remove(); $("#alertMessage").remove(); });
819
+     $("#alertOk").click(function() { $("#alertMsgOverlay").remove(); $("#alertMessage").remove(); });
820
+  }
821
+
822
+
823
+});
Browse code

removed files to implement auto-reply fix, etc.

DoubleBastionAdmin authored on 20/05/2023 00:46:30
Showing 1 changed files
1 1
deleted file mode 100644
... ...
@@ -1,656 +0,0 @@
1
-/**
2
- * @copyright 2021 Double Bastion LLC <www.doublebastion.com>
3
- *
4
- * @author Double Bastion LLC
5
- *
6
- * @license GNU AGPL version 3 or any later version
7
- *
8
- * This program is free software; you can redistribute it and/or
9
- * modify it under the terms of the GNU AFFERO GENERAL PUBLIC LICENSE
10
- * License as published by the Free Software Foundation; either
11
- * version 3 of the License, or any later version.
12
- *
13
- * This program is distributed in the hope that it will be useful,
14
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
15
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
16
- * GNU AFFERO GENERAL PUBLIC LICENSE for more details.
17
- *
18
- * You should have received a copy of the GNU Affero General Public
19
- * License along with this program.  If not, see <http://www.gnu.org/licenses/>.
20
- *
21
- */
22
-
23
-$(document).ready(function() {
24
-
25
-  var userid = "<?php p($userId); ?>";
26
-  var strlength;
27
-
28
-  function randomStr(strlength) {
29
-        var fintext = "";
30
-        var keyspace = '0123456789abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ';
31
-        for (var i = 0; i < strlength; i++) {
32
-             fintext += keyspace.charAt(Math.floor(Math.random() * keyspace.length));
33
-        }
34
-        return fintext;
35
-  }
36
-
37
-  $("#generate_tel_rcpt").on("click", function(event) {
38
-
39
-     var teltokenrec = randomStr(70);
40
-     var telnyxwhurlrec = window.location.origin + OC.generateUrl('/apps/sms_relentless/api/recsmstel?telrecparam=') + teltokenrec;
41
-
42
-     $("#telapi_url_rec").val(telnyxwhurlrec);
43
-  });
44
-
45
-  $("#copyToClipboardtel").on("click", function(event) {
46
-     var $tempEl = $("<input>");
47
-     $("body").append($tempEl);
48
-     $tempEl.val($("#telapi_url_rec").val()).select();
49
-     document.execCommand("Copy");
50
-     $tempEl.remove();
51
-     alert("The link has been copied to your clipboard!");
52
-  });
53
-
54
-  $("#generate_tel_delrcpt").on("click", function(event) {
55
-
56
-     var teltoken = randomStr(70);
57
-     var telnyxwhurl = window.location.origin + OC.generateUrl('/apps/sms_relentless/api/recdeliverytel?teldrparam=') + teltoken;
58
-
59
-     $("#telapi_url").val(telnyxwhurl);
60
-  });
61
-
62
-
63
-  $("#generate_nex_rcpt").on("click", function(event) {
64
-
65
-     var plivotokenrec = randomStr(70);
66
-     var plivowhurlrec = window.location.origin + OC.generateUrl('/apps/sms_relentless/api/recsmsnex?plivorecparam=') + plivotokenrec;
67
-
68
-     $("#nexapi_url_rec").val(plivowhurlrec);
69
-  });
70
-
71
-  $("#copyToClipboardnex").on("click", function(event) {
72
-     var $tempElpl = $("<input>");
73
-     $("body").append($tempElpl);
74
-     $tempElpl.val($("#nexapi_url_rec").val()).select();
75
-     document.execCommand("Copy");
76
-     $tempElpl.remove();
77
-     alert("The link has been copied to your clipboard!");
78
-  });
79
-
80
-  $("#generate_nex_delrcpt").on("click", function(event) {
81
-
82
-     var plivotoken = randomStr(70);
83
-     var plivodrwhurl = window.location.origin + OC.generateUrl('/apps/sms_relentless/api/recdeliverynex?plivodrparam=') + plivotoken;
84
-
85
-     $("#nexapi_url").val(plivodrwhurl);
86
-  });
87
-
88
-
89
-  $("#generate_twil_rcpt").on("click", function(event) {
90
-
91
-     var twiltokenrec = randomStr(35);
92
-     var twilwhurlrec = window.location.origin + OC.generateUrl('/apps/sms_relentless/api/recsmstwil?twilrecparam=') + twiltokenrec;
93
-
94
-     $("#twilapi_url_rec").val(twilwhurlrec);
95
-  });
96
-
97
-  $("#copyToClipboardtwil").on("click", function(event) {
98
-     var $tempElpl = $("<input>");
99
-     $("body").append($tempElpl);
100
-     $tempElpl.val($("#twilapi_url_rec").val()).select();
101
-     document.execCommand("Copy");
102
-     $tempElpl.remove();
103
-     alert("The link has been copied to your clipboard!");
104
-  });
105
-
106
-  $("#generate_twil_delrcpt").on("click", function(event) {
107
-
108
-     var twiltoken = randomStr(35);
109
-     var twildrwhurl = window.location.origin + OC.generateUrl('/apps/sms_relentless/api/recdeliverytwil?twildrparam=') + twiltoken;
110
-
111
-     $("#twilapi_url").val(twildrwhurl);
112
-  });
113
-
114
-
115
-  $("#generate_flow_rcpt").on("click", function(event) {
116
-
117
-     var flowtokenrec = randomStr(70);
118
-     var flowwhurlrec = window.location.origin + OC.generateUrl('/apps/sms_relentless/api/recsmsflow?flowrecparam=') + flowtokenrec;
119
-
120
-     $("#flowapi_url_rec").val(flowwhurlrec);
121
-  });
122
-
123
-  $("#copyToClipboardflow").on("click", function(event) {
124
-     var $tempElpl = $("<input>");
125
-     $("body").append($tempElpl);
126
-     $tempElpl.val($("#flowapi_url_rec").val()).select();
127
-     document.execCommand("Copy");
128
-     $tempElpl.remove();
129
-     alert("The link has been copied to your clipboard!");
130
-  });
131
-
132
-  $("#generate_flow_delrcpt").on("click", function(event) {
133
-
134
-     var flowtoken = randomStr(70);
135
-     var flowdrwhurl = window.location.origin + OC.generateUrl('/apps/sms_relentless/api/recdeliveryflow?flowdrparam=') + flowtoken;
136
-
137
-     $("#flowapi_url").val(flowdrwhurl);
138
-  });
139
-
140
-
141
-  $("#save_sms_settings").on("click", function(event) {
142
-
143
-    event.preventDefault();
144
-    OC.msg.startAction('#smsr_save_msg', t('sms_relentless', 'Saved'));
145
-
146
-    var baseUrl = OC.generateUrl('/apps/sms_relentless/user/updatesettings');
147
-
148
-    var messagesperpageinit = $("#messagesperpage").val();
149
-    var messagesperpagesec = messagesperpageinit.replace(/[^0-9]/g, '');
150
-
151
-    if (messagesperpagesec != '') {
152
-        var messagesperpageproc = messagesperpagesec;
153
-    } else {
154
-        var messagesperpageproc = 100;
155
-    }
156
-
157
-    var getnotify = 0;
158
-
159
-    if ($("#get_notify").is(':checked')) {
160
-        getnotify = 1;
161
-    }
162
-
163
-    var emailaddressinit = $("#notification_email").val();
164
-
165
-    function validate_email($email) {
166
-        var email_reg = /^([\w-\.]+@([\w-]+\.)+[\w-]{2,4})?$/;
167
-        return email_reg.test($email);
168
-    }
169
-
170
-    if (validate_email(emailaddressinit)) {
171
-         var notifyemail = emailaddressinit;
172
-    } else {
173
-         var notifyemail = '';
174
-    }
175
-
176
-    var telsenderinit = $("#tel_sender_name").val();
177
-    var telsenderproc = telsenderinit.replace(/[^A-Za-z 0-9]/g, '');
178
-
179
-    var nexsenderinit = $("#nex_sender_name").val();
180
-    var nexsenderproc = nexsenderinit.replace(/[^A-Za-z 0-9]/g, '');
181
-
182
-    var twilsenderinit = $("#twil_sender_name").val();
183
-    var twilsenderproc = twilsenderinit.replace(/[^A-Za-z 0-9]/g, '');
184
-
185
-    var includesmsinemail = 0;
186
-    if ($("#includesmsinemail").is(':checked')) {
187
-        includesmsinemail = 1;
188
-    }
189
-
190
-    var showdisplaynm = 0;
191
-    if ($("#showdisplaynames").is(':checked')) {
192
-        showdisplaynm = 1;
193
-    }
194
-
195
-    var datatosave = {
196
-                      userId: userid,
197
-                      telapiKey: $("#telapi_key").val(),
198
-                      telPubKey: $("#tel_pub_key").val(),
199
-                      telapiUrlRec: $("#telapi_url_rec").val(),
200
-                      telapiUrl: $("#telapi_url").val(),
201
-                      messagingProfileId: $("#messaging_profile_id").val(),
202
-                      nexapiKey: $("#nexapi_key").val(),
203
-                      nexapiSecret: $("#nexapi_secret").val(),
204
-                      nexapiUrlRec: $("#nexapi_url_rec").val(),
205
-                      nexapiUrl: $("#nexapi_url").val(),
206
-                      twilapiKey: $("#twilapi_key").val(),
207
-                      twilapiSecret: $("#twilapi_secret").val(),
208
-                      twilapiUrlRec: $("#twilapi_url_rec").val(),
209
-                      twilapiUrl: $("#twilapi_url").val(),
210
-                      flowapiKey: $("#flowapi_key").val(),
211
-                      flowapiSecret: $("#flowapi_secret").val(),
212
-                      flowapiUrlRec: $("#flowapi_url_rec").val(),
213
-                      flowapiUrl: $("#flowapi_url").val(),
214
-                      telSenderName: telsenderproc,
215
-                      nexSenderName: nexsenderproc,
216
-                      twilSenderName: twilsenderproc,
217
-                      messagesperpage: messagesperpageproc,
218
-                      getNotify: getnotify,
219
-                      notificationEmail: notifyemail,
220
-                      getsmsinemail: includesmsinemail,
221
-                      showDisplayNames: showdisplaynm
222
-    };
223
-
224
-
225
-    $.ajax({
226
-       method: 'PUT',
227
-       url: baseUrl + '/' + userid,
228
-       contentType: 'application/json',
229
-       data: JSON.stringify(datatosave),
230
-       success: function() {
231
-       },
232
-       error: function() {
233
-            alert('Error while attempting to save the settings! You can check the Nextcloud log to find more details about this issue.');
234
-       }
235
-    });
236
-
237
-  });
238
-
239
-
240
-  var baseUrlget = OC.generateUrl('/apps/sms_relentless/user/getsettings');
241
-
242
-  $.ajax({
243
-     method: 'GET',
244
-     url: baseUrlget + '/' + userid,
245
-     contentType: 'application/json',
246
-     success: function(settingsfromdb) {
247
-         $("#telapi_key").val(settingsfromdb.telapi_key);
248
-         $("#tel_pub_key").val(settingsfromdb.tel_pub_key);
249
-         $("#telapi_url_rec").val(settingsfromdb.telapi_url_rec);
250
-         $("#telapi_url").val(settingsfromdb.telapi_url);
251
-         $("#messaging_profile_id").val(settingsfromdb.messaging_profile_id);
252
-         $("#nexapi_key").val(settingsfromdb.nexapi_key);
253
-         $("#nexapi_secret").val(settingsfromdb.nexapi_secret);
254
-         $("#nexapi_url_rec").val(settingsfromdb.nexapi_url_rec);
255
-         $("#nexapi_url").val(settingsfromdb.nexapi_url);
256
-         $("#twilapi_key").val(settingsfromdb.twilapi_key);
257
-         $("#twilapi_secret").val(settingsfromdb.twilapi_secret);
258
-         $("#twilapi_url_rec").val(settingsfromdb.twilapi_url_rec);
259
-         $("#twilapi_url").val(settingsfromdb.twilapi_url);
260
-         $("#flowapi_key").val(settingsfromdb.flowapi_key);
261
-         $("#flowapi_secret").val(settingsfromdb.flowapi_secret);
262
-         $("#flowapi_url_rec").val(settingsfromdb.flowapi_url_rec);
263
-         $("#flowapi_url").val(settingsfromdb.flowapi_url);
264
-         $("#tel_sender_name").val(settingsfromdb.tel_sender_name);
265
-         $("#nex_sender_name").val(settingsfromdb.nex_sender_name);
266
-         $("#twil_sender_name").val(settingsfromdb.twil_sender_name);
267
-         $("#messagesperpage").val(settingsfromdb.messagesperpage);
268
-
269
-         if (settingsfromdb.get_notify == 1) {
270
-             $("#get_notify").attr('checked', true);
271
-         } else {
272
-             $("#get_notify").attr('checked', false);
273
-         }
274
-
275
-         $("#notification_email").val(settingsfromdb.notification_email);
276
-
277
-         if (settingsfromdb.getsmsinemail == 1) {
278
-             $("#includesmsinemail").attr('checked', true);
279
-         } else {
280
-             $("#includesmsinemail").attr('checked', false);
281
-         }
282
-
283
-         if (settingsfromdb.show_display_names == 1) {
284
-             $("#showdisplaynames").attr('checked', true);
285
-         } else {
286
-             $("#showdisplaynames").attr('checked', false);
287
-         }
288
-
289
-
290
-         // Auto-reply settings
291
-
292
-         // Get the available phone numbers from all providers associated with the access keys entered on the Settings page (restrictions are applied to numbers for non-admins)
293
-         $("#autoRplPhoneNb").addClass('icon-loading');
294
-         var getnumbersUrl = OC.generateUrl("/apps/sms_relentless/user/getautoreplyconf");
295
-
296
-	 $.ajax({
297
-		  url: getnumbersUrl + '/' + userid,
298
-		  type: "GET",
299
-                  contentType: 'application/json',
300
-		  success: function(autoreplydata) {
301
-
302
-                                    $("#autoRplPhoneNb").removeClass('icon-loading');
303
-                                    var cusrDisplayName = autoreplydata.userdisplayname;
304
-                                    var availPhoneNmbrs = autoreplydata.phonenumbers;
305
-                                    var autorpldata = autoreplydata.autoreplies;
306
-
307
-				    if (autorpldata.length > 0) { 
308
-				        var arplNmb = autorpldata.length;
309
-				    } else { 
310
-				        var arplNmb = 0; 
311
-				    }
312
-
313
-				    // List the auto-replies for the phone numbers available for the current user
314
-				    if (arplNmb == 0) {
315
-
316
-				        $("#autoReplyTbl").append("<tr><td><input type='text' class='arplAuthor' value='"+ cusrDisplayName +"' disabled></td><td><select id='arpphn-"+ arplNmb +"' class='arplPhoneNmbr'></select></td><td><div id='arplmode-"+ arplNmb +"' class='arplMode'><select id='modeselect-"+ arplNmb +"' class='selectArplMode'><option value='' selected>Select mode</option><option value='daily'>Daily mode</option><option value='vacation'>Vacation mode</option></select><div id='modecont-"+ arplNmb +"' class='modeContent'></div></div></td><td><textarea id='arpltxt-"+ arplNmb +"' class='arplText' rows='20' cols='40' placeholder='Enter the auto-reply message here.'></textarea></td><td><img id='rmRow-"+ arplNmb +"' class='removeRow' src='/core/img/actions/close.svg' title='Remove this row from the database' style='cursor:pointer;margin:9px 8px 0px 18px;'></td><td><input type='submit' id='arplsave-"+ arplNmb +"' class='saveAutoReply' value='Save' title='Save Row' /></td></tr>");
317
-				        $("#autoReplyTbl").append("<div><img id='addArplRow' src='/core/img/actions/add.svg' title='Add Row'></div>");
318
-
319
-				    } else {
320
-
321
-				        for (k = 0; k < arplNmb; k++) {
322
-
323
-                                             if (autorpldata[k].days_of_week != '') {
324
-
325
-                                                 var slctdMode = "<option value=''>Select mode</option><option value='daily' selected>Daily mode</option><option value='vacation'>Vacation mode</option>";
326
-                                                 var dailyStartArr = autorpldata[k].daily_start.split(":");
327
-                                                 var dailyEndArr = autorpldata[k].daily_end.split(":");
328
-
329
-		                                 var dlHrStartOptions = "";
330
-			                         for (var hr = 0; hr < 24; hr++) {
331
-		                                      if (dailyStartArr[0] != hr.toLocaleString('en-US', {minimumIntegerDigits: 2, useGrouping:false})) {
332
-			                                  dlHrStartOptions += "<option value='"+ hr.toLocaleString('en-US', {minimumIntegerDigits: 2, useGrouping:false}) +"'>"+ hr.toLocaleString('en-US', {minimumIntegerDigits: 2, useGrouping:false}) +"</option>";
333
-		                                      } else {
334
-			                                  dlHrStartOptions += "<option value='"+ hr.toLocaleString('en-US', {minimumIntegerDigits: 2, useGrouping:false}) +"' selected>"+ hr.toLocaleString('en-US', {minimumIntegerDigits: 2, useGrouping:false}) +"</option>";
335
-		                                      }
336
-			                         }
337
-
338
-		                                 var dlMnStartOptions = "";
339
-			                         for (var mn = 0; mn < 24; mn++) {
340
-		                                      if (dailyStartArr[1] != hr.toLocaleString('en-US', {minimumIntegerDigits: 2, useGrouping:false})) {
341
-			                                  dlMnStartOptions += "<option value='"+ mn.toLocaleString('en-US', {minimumIntegerDigits: 2, useGrouping:false}) +"'>"+ mn.toLocaleString('en-US', {minimumIntegerDigits: 2, useGrouping:false}) +"</option>";
342
-		                                      } else {
343
-			                                  dlMnStartOptions += "<option value='"+ mn.toLocaleString('en-US', {minimumIntegerDigits: 2, useGrouping:false}) +"' selected>"+ mn.toLocaleString('en-US', {minimumIntegerDigits: 2, useGrouping:false}) +"</option>";
344
-		                                      }
345
-			                         }
346
-
347
-		                                 var dlHrEndOptions = "";
348
-			                         for (var hr = 0; hr < 24; hr++) {
349
-		                                      if (dailyEndArr[0] != hr.toLocaleString('en-US', {minimumIntegerDigits: 2, useGrouping:false})) {
350
-			                                  dlHrEndOptions += "<option value='"+ hr.toLocaleString('en-US', {minimumIntegerDigits: 2, useGrouping:false}) +"'>"+ hr.toLocaleString('en-US', {minimumIntegerDigits: 2, useGrouping:false}) +"</option>";
351
-		                                      } else {
352
-			                                  dlHrEndOptions += "<option value='"+ hr.toLocaleString('en-US', {minimumIntegerDigits: 2, useGrouping:false}) +"' selected>"+ hr.toLocaleString('en-US', {minimumIntegerDigits: 2, useGrouping:false}) +"</option>";
353
-		                                      }
354
-			                         }
355
-
356
-		                                 var dlMnEndOptions = "";
357
-			                         for (var mn = 0; mn < 24; mn++) {
358
-		                                      if (dailyEndArr[1] != hr.toLocaleString('en-US', {minimumIntegerDigits: 2, useGrouping:false})) {
359
-			                                  dlMnEndOptions += "<option value='"+ mn.toLocaleString('en-US', {minimumIntegerDigits: 2, useGrouping:false}) +"'>"+ mn.toLocaleString('en-US', {minimumIntegerDigits: 2, useGrouping:false}) +"</option>";
360
-		                                      } else {
361
-			                                  dlMnEndOptions += "<option value='"+ mn.toLocaleString('en-US', {minimumIntegerDigits: 2, useGrouping:false}) +"' selected>"+ mn.toLocaleString('en-US', {minimumIntegerDigits: 2, useGrouping:false}) +"</option>";
362
-		                                      }
363
-			                         }
364
-
365
-                                                 var modeContent = "<div class='daysOfWeek'>Days of the week:<div class='tooltipautoreply'><div id='infoautoreply'>i</div><div class='autorpltooltip'>Enter the order number of the days of the week in which the auto-reply will be sent. For example, to send the auto-reply every day from Monday to Friday (outside the time interval specified below), enter 1,2,3,4,5 To send the auto-reply only Monday, Thursday and Friday enter 1,4,5 To send the auto-reply every day of the week enter 1,2,3,4,5,6,7</div></div></div><input type='text' id='weekdays-"+ k +"' class='daysInWeek' value='"+ autorpldata[k].days_of_week +"'><div class='chooseTInterval'>Send auto-reply <span style='color:#ad0202'>outside</span> this interval:<div class='tooltipautoreplyst'><div id='infoautoreplyst'>i</div><div class='autorpltooltipst'>These fields specify the time of the server. If the server is located in a time zone that is different from that of the owner/company, the time interval entered here should be adjusted accordingly.</div></div></div><div class='selectArplHours'><select id='dmstarthr-"+ k +"' class='selectHrMin'>"+ dlHrStartOptions +"</select><select id='dmstartmn-"+ k +"' class='selectHrMin'>"+ dlMnStartOptions +"</select><span style='font-weight: 600'> — </span><select id='dmendhr-"+ k +"' class='selectHrMin'>"+ dlHrEndOptions +"</select><select id='dmendmn-"+ k +"' class='selectHrMin'>"+ dlMnEndOptions +"</select></div>";
366
-
367
-                                             } else {
368
-
369
-                                                 var vctnStart = autorpldata[k].vacation_start.split(" ")[0];
370
-                                                 var vctnEnd = autorpldata[k].vacation_end.split(" ")[0];
371
-
372
-                                                 var slctdMode = "<option value=''>Select mode</option><option value='daily'>Daily mode</option><option value='vacation' selected>Vacation mode</option>";
373
-                                                 var modeContent = "<div class='chooseDateIntvl'>Send auto-reply <span style='color:#ad0202'>inside</span> this interval:</div><div class='arplstrtendDates'><div class='stdtTitle'>Start Date</div><input type='text' id='startDT-"+ k +"' class='startDate' placeholder='Pick a date' value='"+ vctnStart +"'><div class='enddtTitle'>End Date</div><input type='text' id='endDT-"+ k +"' class='endDate' placeholder='Pick a date' value='"+ vctnEnd +"'></div>"
374
-                                             }
375
-
376
-				             $("#autoReplyTbl").append("<tr><td><input type='text' class='arplAuthor' value='"+ autorpldata[k].saved_by_dsplname +"' disabled></td><td><select id='arpphn-"+ k +"' class='arplPhoneNmbr' style='pointer-events:none'><option selected>"+ autorpldata[k].phone_number +"</option></select></td><td><div id='arplmode-"+ k +"' class='arplMode'><select id='modeselect-"+ k +"' class='selectArplMode'>"+ slctdMode +"</select><div id='modecont-"+ k +"' class='modeContent'>"+ modeContent +"</div></div></td><td><textarea id='arpltxt-"+ k +"' class='arplText' rows='20' cols='40' placeholder='Enter the auto-reply message here.'>"+ autorpldata[k].message_text +"</textarea></td><td><img id='rmRow-"+ k +"' class='removeRow' src='/core/img/actions/close.svg' title='Remove this row from the database' style='cursor:pointer;margin:9px 8px 0px 18px;'></td><td><input type='submit' id='arplsave-"+ k +"' class='saveAutoReply' value='Edit' title='Edit Row' /></td></tr>");
377
-				        }
378
-				        $("#autoReplyTbl").append("<div><img id='addArplRow' src='/core/img/actions/add.svg' title='Add Row'></div>");
379
-				    }
380
-
381
-
382
-				    // Create a list with all the available phone numbers
383
-                                    var numbersListItems = "<option value='' selected>Select phone number</option>";
384
-
385
-				    $.each(availPhoneNmbrs, function(key, indsmsnmb) {
386
-					 var emptyinit = indsmsnmb.split(":");
387
-					 var emptysec = emptyinit[1];
388
-					 var emptycheck = emptysec.replace(" ", "").replace("+", "");
389
-
390
-					 if (emptycheck != '') {
391
-					     numbersListItems += "<option value='"+ indsmsnmb +"'>"+ indsmsnmb +"</option>";
392
-					 }
393
-				    });
394
-
395
-                                    if (arplNmb == 0) {
396
-				        $("#arpphn-"+ arplNmb).append(numbersListItems);
397
-                                    }
398
-
399
-                                    // Initialize the date picker
400
-			            $('[id^="endDT-"]').datepicker({ dateFormat: "yy-mm-dd" });
401
-			            $('[id^="startDT-"]').datepicker({ dateFormat: "yy-mm-dd" });
402
-
403
-
404
-                                    // Select the auto-reply mode
405
-                                    function selectMode() {
406
-
407
-		                            $('[id^="modeselect-"]').change(function() {
408
-
409
-		                               var crtnmbr = $(this).attr("id").replace("modeselect-", "");
410
-
411
-		                               var dailyHrStart = "";
412
-		                               for (var h = 0; h < 24; h++) {
413
-		                                    dailyHrStart += "<option value='"+ h.toLocaleString('en-US', {minimumIntegerDigits: 2, useGrouping:false}) +"'>"+ h.toLocaleString('en-US', {minimumIntegerDigits: 2, useGrouping:false}) +"</option>";
414
-		                               }
415
-
416
-		                               var dailyMnStart = "";
417
-		                               for (var m = 0; m < 60; m++) {
418
-		                                    dailyMnStart += "<option value='"+ m.toLocaleString('en-US', {minimumIntegerDigits: 2, useGrouping:false}) +"'>"+ m.toLocaleString('en-US', {minimumIntegerDigits: 2, useGrouping:false}) +"</option>";
419
-		                               }
420
-
421
-		                               var dailyHrEnd = dailyHrStart;
422
-		                               var dailyMnEnd = dailyMnStart;
423
-
424
-		                               if ($(this).val() == 'daily') {
425
-		                                   $("#modecont-"+ crtnmbr).empty();
426
-		                                   $("#modecont-"+ crtnmbr).append("<div class='daysOfWeek'>Days of the week:<div class='tooltipautoreply'><div id='infoautoreply'>i</div><div class='autorpltooltip'>Enter the order number of the days of the week. For example, to send the auto-reply every day from Monday to Friday outside the specified time interval, enter 1,2,3,4,5 To send the auto-reply only Monday, Thursday and Friday enter 1,4,5 To send the auto-reply every day of the week enter 1,2,3,4,5,6,7</div></div></div><input type='text' id='weekdays-"+ crtnmbr +"' class='daysInWeek'><div class='chooseTInterval'>Send auto-reply <span style='color:#ad0202'>outside</span> this interval:<div class='tooltipautoreplyst'><div id='infoautoreplyst'>i</div><div class='autorpltooltipst'>These fields specify the time of the server. If the server is located in a time zone that is different from that of the owner/company, the time interval entered here should be adjusted accordingly.</div></div></div><div class='selectArplHours'><select id='dmstarthr-"+ crtnmbr +"' class='selectHrMin'>"+ dailyHrStart +"</select><select id='dmstartmn-"+ crtnmbr +"' class='selectHrMin'>"+ dailyMnStart +"</select><span style='font-weight: 600'> — </span><select id='dmendhr-"+ crtnmbr +"' class='selectHrMin'>"+ dailyHrEnd +"</select><select id='dmendmn-"+ crtnmbr +"' class='selectHrMin'>"+ dailyMnEnd +"</select></div>");
427
-		                               } else if ($(this).val() == 'vacation') {
428
-		                                   $("#modecont-"+ crtnmbr).empty();
429
-		                                   $("#modecont-"+ crtnmbr).append("<div class='chooseDateIntvl'>Send auto-reply <span style='color:#ad0202'>inside</span> this interval:</div><div class='arplstrtendDates'><div class='stdtTitle'>Start Date</div><input type='text' id='startDT-"+ crtnmbr +"' class='startDate' placeholder='Pick a date'><div class='enddtTitle'>End Date</div><input type='text' id='endDT-"+ crtnmbr +"' class='endDate' placeholder='Pick a date' /></div>");
430
-		                               }
431
-
432
-					       $("#endDT-"+ crtnmbr +"").datepicker({ dateFormat: "yy-mm-dd" });
433
-					       $("#startDT-"+ crtnmbr +"").datepicker({ dateFormat: "yy-mm-dd" });
434
-		                          });
435
-                                  }
436
-                                  selectMode();
437
-
438
-				  // Save the data
439
-				  function saveArplRow() {
440
-
441
-				     $('[id^="arplsave-"]').unbind("click");
442
-				     $('[id^="arplsave-"]').click(function(event) {
443
-
444
-				        event.preventDefault();
445
-				        var crntrwnmbr = $(this).attr("id").replace("arplsave-", "");
446
-
447
-				        if ($(this).attr("value") == "Save") {
448
-
449
-				            var phoneNmbr = $("#arpphn-"+ crntrwnmbr).val();
450
-				            var arplText = $("#arpltxt-"+ crntrwnmbr).val();
451
-				            var slctdMode = $("#modeselect-"+ crntrwnmbr).val();
452
-
453
-				            var slctddmDays = "";
454
-				            var slctdHrStart = "";
455
-				            var slctdMnStart = "";
456
-				            var slctdHrEnd = "";
457
-				            var slctdMnEnd = "";
458
-
459
-				            var vcStartDate = null;
460
-				            var vcEndDate = null;
461
-
462
-				            if (slctdMode == 'daily') {
463
-
464
-				                slctddmDays = $("#weekdays-"+ crntrwnmbr).val().trim();
465
-				                slctdHrStart = $("#dmstarthr-"+ crntrwnmbr).val().trim();
466
-				                slctdMnStart = $("#dmstartmn-"+ crntrwnmbr).val().trim();
467
-				                slctdHrEnd = $("#dmendhr-"+ crntrwnmbr).val().trim();
468
-				                slctdMnEnd = $("#dmendmn-"+ crntrwnmbr).val().trim();
469
-
470
-                                                if (slctdHrStart != '' && slctdMnStart != '') {
471
-                                                    var hrmnStartComp = slctdHrStart +":"+ slctdMnStart;
472
-                                                } else { var hrmnStartComp = ""; }
473
-
474
-                                                if (slctdHrEnd != '' && slctdMnEnd != '') {
475
-                                                    var hrmnEndComp = slctdHrEnd +":"+ slctdMnEnd;
476
-                                                } else { var hrmnEndComp = ""; }
477
-
478
-                                                if (!(/^[1-7\,]+$/.test(slctddmDays))) {
479
-				                    alert("The 'Days of the week' field can contain only digits from 1 to 7 and commas (,).");
480
-				                    return;
481
-                                                }
482
-
483
-                                                if (!(/^[0-9]+$/.test(slctdHrStart + slctdMnStart + slctdHrEnd + slctdMnEnd))) {
484
-				                    alert("The starting and ending values of the time interval for the 'Daily mode' can contain only digits from 0 to 9.");
485
-				                    return;
486
-                                                }
487
-
488
-                                                if (slctddmDays.trim() == '' || (slctdHrStart == slctdHrEnd && slctdMnStart == slctdMnEnd)) {
489
-				                    alert("For the 'Daily mode', you have to enter the order number of the days of the week for which you want the auto-reply to be sent, and you have to set a starting time that is different from the ending time!");
490
-				                    return;
491
-                                                }
492
-
493
-				            } else if (slctdMode == 'vacation') {
494
-		
495
-                                                if ($("#startDT-"+ crntrwnmbr).val().trim() == '' || $("#endDT-"+ crntrwnmbr).val().trim() == '') {
496
-
497
-				                    alert("For the 'Vacation mode', you have to enter both a start date and an end date.");
498
-				                    return;
499
-
500
-                                                } else {
501
-
502
-                                                    if (!(/^[0-9\-]+$/.test($("#startDT-"+ crntrwnmbr).val().trim() + $("#endDT-"+ crntrwnmbr).val().trim()))) {
503
-				                        alert("The start date and end date values for the 'Vacation mode' can contain only digits from 0 to 9 and hyphens (-).");
504
-				                        return;
505
-                                                    }
506
-
507
-		                                    vcStartDate = $("#startDT-"+ crntrwnmbr).val().trim() +" 00:00:00";
508
-				                    vcEndDate = $("#endDT-"+ crntrwnmbr).val().trim() +" 23:59:59";
509
-				                    var strtDateCmp = new Date(vcStartDate).toJSON().slice(0, 10) +" 00:00:00";
510
-				                    var endDateCmp = new Date(vcEndDate).toJSON().slice(0, 10) +" 23:59:59";
511
-				                    var crntDate = new Date().toJSON().slice(0, 10) +" 23:59:59";
512
-
513
-                                                    if (vcStartDate.trim() == "" || vcEndDate.trim() == "" || (strtDateCmp >= endDateCmp || ((strtDateCmp < crntDate) && (endDateCmp < crntDate)))) {
514
-				                        alert("For 'Vacation mode', you have to enter both a start date and an end date, the start date must be before the end date and at least the ending of the time interval must be in the future.");
515
-				                        return;
516
-                                                    }
517
-                                                }
518
-				            }
519
-
520
-
521
-				            if (phoneNmbr != '') {
522
-
523
-				              if (arplText.trim() != '') {
524
-
525
-				                if (slctdMode != '') {
526
-
527
-				                    var saveArplUrl = OC.generateUrl('/apps/sms_relentless/user/updateautoreplies');
528
-				                    var arpldata = {
529
-				                         userId: userid,
530
-				                         savedByDsplname: cusrDisplayName,
531
-				                         phoneNumber: phoneNmbr,
532
-				                         daysOfWeek: slctddmDays,
533
-				                         dailyStart: hrmnStartComp,
534
-				                         dailyEnd: hrmnEndComp,
535
-				                         vacationStart: vcStartDate,
536
-				                         vacationEnd: vcEndDate,
537
-				                         messageText: arplText
538
-				                    };
539
-
540
-					            $.ajax({
541
-					              method: 'PUT',
542
-					              url: saveArplUrl + '/' + userid,
543
-					              contentType: 'application/json',
544
-					              data: JSON.stringify(arpldata),
545
-				                      success: function(messagereceived) {
546
-
547
-				                                   if (messagereceived == 'success') {
548
-				                                       alert('The auto-reply has been successfully saved to the database!');
549
-				                                   } else if (messagereceived == 'failure') {
550
-				                                       alert('Error while trying to save the auto-reply!');
551
-				                                   } else if (messagereceived == 'not allowed') {
552
-                                                                       alert('You cannot change an auto-reply that was saved by a different user.');
553
-                                                                   }
554
-				                      },
555
-					              error: function() {
556
-						                   alert('Error while attempting to save the auto-reply! You can check the Nextcloud log to find more details about this issue.');
557
-					              }
558
-					            });
559
-
560
-
561
-                                                } else { alert("Please select the auto-reply mode."); return; }
562
-
563
-                                              } else { alert("Please enter the text of the auto-reply."); return; }
564
-
565
-                                            } else { alert("Please select a phone number if at least one number is available in the 'Phone Number' drop-down list. Otherwise, you should contact the administrator."); return; }
566
-
567
-                                            $(this).attr("value", "Edit");
568
-
569
-                                        } else {
570
-                                            $("#arplsave-"+ crntrwnmbr).attr("value", "Save");
571
-                                        }
572
-
573
-                                     });
574
-
575
-				  }
576
-                                  saveArplRow();
577
-
578
-
579
-				  // Remove a row
580
-				  function removeArplRow() {
581
-				       $('[id^="rmRow-"]').click(function() {
582
-
583
-					  var slctRowRm = $(this).attr("id").replace("rmRow-", "");
584
-					  var crntPhnNmbr = $("#arpphn-"+ slctRowRm).val();
585
-
586
-					  if (confirm("Do you really want to remove this row from the database ?")) {
587
-
588
-					      var rmvArplUrl = OC.generateUrl('/apps/sms_relentless/user/removeautoreplies');
589
-					      $.ajax({
590
-						   url: rmvArplUrl + '/' + userid,
591
-						   method: "POST",
592
-						   dataType: "text",
593
-						   data: { phoneNumber: crntPhnNmbr },
594
-						   success: function(delresult) {
595
-
596
-						                     if (delresult.indexOf("success") > -1) {
597
-						                         alert("The auto-reply has been removed successfully!");
598
-						                         $("#arpphn-"+ slctRowRm).closest("tr").remove();
599
-						                     } else if (delresult.indexOf("failure") > -1) {
600
-						                         alert("Error while trying to remove auto-reply data!");
601
-						                     } else if (delresult.indexOf("not allowed") > -1) {
602
-                                                                         alert("You cannot remove the auto-reply saved by another user.");
603
-                                                                     }
604
-						   },
605
-						   error: function() { alert("Error while attempting to remove auto-reply data! You can check the Nextcloud log to find more details about this issue."); }
606
-					       });
607
-					  }
608
-				       });
609
-				  }
610
-				  removeArplRow();
611
-
612
-                                  // Add new row
613
-                                  $("#addArplRow").click(function() {
614
-
615
-                                     if ($("#autoReplyTbl").find("tr:last-child").find(".arplPhoneNmbr").length > 0) {
616
-                                         var lastarpl = $("#autoReplyTbl").find("tr:last-child").find(".arplPhoneNmbr").attr("id").replace("arpphn-", "");
617
-                                         var indArplAdd = parseInt(lastarpl + 1);
618
-                                     } else { var indArplAdd = 0; }
619
-			             $("#autoReplyTbl").append("<tr><td><input type='text' class='arplAuthor' value='"+ cusrDisplayName +"' disabled></td><td><select id='arpphn-"+ indArplAdd +"' class='arplPhoneNmbr'>"+ numbersListItems +"</select></td><td><div id='arplmode-"+ indArplAdd +"' class='arplMode'><select id='modeselect-"+ indArplAdd +"' class='selectArplMode'><option value='' selected>Select mode</option><option value='daily'>Daily mode</option><option value='vacation'>Vacation mode</option></select><div id='modecont-"+ indArplAdd +"' class='modeContent'></div></div></td><td><textarea id='arpltxt-"+ indArplAdd +"' class='arplText' rows='20' cols='40' placeholder='Enter the auto-reply message here.'></textarea></td><td><img id='rmRow-"+ indArplAdd +"' class='removeRow' src='/core/img/actions/close.svg' title='Remove this row from the database' style='cursor:pointer;margin:9px 8px 0px 18px;'></td><td><input type='submit' id='arplsave-"+ indArplAdd +"' class='saveAutoReply' value='Save' title='Save Row' /></td></tr>");
620
-
621
-                                     selectMode();
622
-                                     saveArplRow();
623
-                                     removeArplRow();
624
-
625
-			             // Check if there is an auto-reply set for the same phone number
626
-				     $("#arpphn-"+ indArplAdd).change(function() {
627
-					 var selectedPhNb = $("#arpphn-"+ indArplAdd).val();
628
-					 var allArplPhNmbrs = $("#autoReplyTbl").find("tr").find(".arplPhoneNmbr");
629
-					 var phNbChck = 0;
630
-					 allArplPhNmbrs.each(function() {
631
-					    var slctphnb = ($(this).val())? $(this).val() : $(this).text();
632
-					    if (selectedPhNb == slctphnb) { phNbChck++; }
633
-					 });
634
-
635
-					 if (phNbChck == 2) {
636
-					     alert("There is already an auto-reply set up for this phone number. Please edit its own row, or choose a different phone number.");
637
-					     $(this).val('');
638
-					     return;
639
-					 }
640
-				     });
641
-                                  });
642
-
643
-		  },
644
-		  error: function() {
645
-                                    $("#autoRplPhoneNb").removeClass('icon-loading'); 
646
-                                    alert("Error while attempting to get the auto-reply settings! You can check the Nextcloud log to find more details about this issue.");
647
-                  }
648
-         });
649
-
650
-     },
651
-     error: function() {
652
-                  alert('Error while getting the settings! You can check the Nextcloud log to find more details about this issue.');
653
-     }
654
-  });
655
-
656
-});
Browse code

added changes for origination, auto-reply, etc.

DoubleBastionAdmin authored on 08/05/2023 20:50:18
Showing 1 changed files
1 1
new file mode 100644
... ...
@@ -0,0 +1,656 @@
1
+/**
2
+ * @copyright 2021 Double Bastion LLC <www.doublebastion.com>
3
+ *
4
+ * @author Double Bastion LLC
5
+ *
6
+ * @license GNU AGPL version 3 or any later version
7
+ *
8
+ * This program is free software; you can redistribute it and/or
9
+ * modify it under the terms of the GNU AFFERO GENERAL PUBLIC LICENSE
10
+ * License as published by the Free Software Foundation; either
11
+ * version 3 of the License, or any later version.
12
+ *
13
+ * This program is distributed in the hope that it will be useful,
14
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
15
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
16
+ * GNU AFFERO GENERAL PUBLIC LICENSE for more details.
17
+ *
18
+ * You should have received a copy of the GNU Affero General Public
19
+ * License along with this program.  If not, see <http://www.gnu.org/licenses/>.
20
+ *
21
+ */
22
+
23
+$(document).ready(function() {
24
+
25
+  var userid = "<?php p($userId); ?>";
26
+  var strlength;
27
+
28
+  function randomStr(strlength) {
29
+        var fintext = "";
30
+        var keyspace = '0123456789abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ';
31
+        for (var i = 0; i < strlength; i++) {
32
+             fintext += keyspace.charAt(Math.floor(Math.random() * keyspace.length));
33
+        }
34
+        return fintext;
35
+  }
36
+
37
+  $("#generate_tel_rcpt").on("click", function(event) {
38
+
39
+     var teltokenrec = randomStr(70);
40
+     var telnyxwhurlrec = window.location.origin + OC.generateUrl('/apps/sms_relentless/api/recsmstel?telrecparam=') + teltokenrec;
41
+
42
+     $("#telapi_url_rec").val(telnyxwhurlrec);
43
+  });
44
+
45
+  $("#copyToClipboardtel").on("click", function(event) {
46
+     var $tempEl = $("<input>");
47
+     $("body").append($tempEl);
48
+     $tempEl.val($("#telapi_url_rec").val()).select();
49
+     document.execCommand("Copy");
50
+     $tempEl.remove();
51
+     alert("The link has been copied to your clipboard!");
52
+  });
53
+
54
+  $("#generate_tel_delrcpt").on("click", function(event) {
55
+
56
+     var teltoken = randomStr(70);
57
+     var telnyxwhurl = window.location.origin + OC.generateUrl('/apps/sms_relentless/api/recdeliverytel?teldrparam=') + teltoken;
58
+
59
+     $("#telapi_url").val(telnyxwhurl);
60
+  });
61
+
62
+
63
+  $("#generate_nex_rcpt").on("click", function(event) {
64
+
65
+     var plivotokenrec = randomStr(70);
66
+     var plivowhurlrec = window.location.origin + OC.generateUrl('/apps/sms_relentless/api/recsmsnex?plivorecparam=') + plivotokenrec;
67
+
68
+     $("#nexapi_url_rec").val(plivowhurlrec);
69
+  });
70
+
71
+  $("#copyToClipboardnex").on("click", function(event) {
72
+     var $tempElpl = $("<input>");
73
+     $("body").append($tempElpl);
74
+     $tempElpl.val($("#nexapi_url_rec").val()).select();
75
+     document.execCommand("Copy");
76
+     $tempElpl.remove();
77
+     alert("The link has been copied to your clipboard!");
78
+  });
79
+
80
+  $("#generate_nex_delrcpt").on("click", function(event) {
81
+
82
+     var plivotoken = randomStr(70);
83
+     var plivodrwhurl = window.location.origin + OC.generateUrl('/apps/sms_relentless/api/recdeliverynex?plivodrparam=') + plivotoken;
84
+
85
+     $("#nexapi_url").val(plivodrwhurl);
86
+  });
87
+
88
+
89
+  $("#generate_twil_rcpt").on("click", function(event) {
90
+
91
+     var twiltokenrec = randomStr(35);
92
+     var twilwhurlrec = window.location.origin + OC.generateUrl('/apps/sms_relentless/api/recsmstwil?twilrecparam=') + twiltokenrec;
93
+
94
+     $("#twilapi_url_rec").val(twilwhurlrec);
95
+  });
96
+
97
+  $("#copyToClipboardtwil").on("click", function(event) {
98
+     var $tempElpl = $("<input>");
99
+     $("body").append($tempElpl);
100
+     $tempElpl.val($("#twilapi_url_rec").val()).select();
101
+     document.execCommand("Copy");
102
+     $tempElpl.remove();
103
+     alert("The link has been copied to your clipboard!");
104
+  });
105
+
106
+  $("#generate_twil_delrcpt").on("click", function(event) {
107
+
108
+     var twiltoken = randomStr(35);
109
+     var twildrwhurl = window.location.origin + OC.generateUrl('/apps/sms_relentless/api/recdeliverytwil?twildrparam=') + twiltoken;
110
+
111
+     $("#twilapi_url").val(twildrwhurl);
112
+  });
113
+
114
+
115
+  $("#generate_flow_rcpt").on("click", function(event) {
116
+
117
+     var flowtokenrec = randomStr(70);
118
+     var flowwhurlrec = window.location.origin + OC.generateUrl('/apps/sms_relentless/api/recsmsflow?flowrecparam=') + flowtokenrec;
119
+
120
+     $("#flowapi_url_rec").val(flowwhurlrec);
121
+  });
122
+
123
+  $("#copyToClipboardflow").on("click", function(event) {
124
+     var $tempElpl = $("<input>");
125
+     $("body").append($tempElpl);
126
+     $tempElpl.val($("#flowapi_url_rec").val()).select();
127
+     document.execCommand("Copy");
128
+     $tempElpl.remove();
129
+     alert("The link has been copied to your clipboard!");
130
+  });
131
+
132
+  $("#generate_flow_delrcpt").on("click", function(event) {
133
+
134
+     var flowtoken = randomStr(70);
135
+     var flowdrwhurl = window.location.origin + OC.generateUrl('/apps/sms_relentless/api/recdeliveryflow?flowdrparam=') + flowtoken;
136
+
137
+     $("#flowapi_url").val(flowdrwhurl);
138
+  });
139
+
140
+
141
+  $("#save_sms_settings").on("click", function(event) {
142
+
143
+    event.preventDefault();
144
+    OC.msg.startAction('#smsr_save_msg', t('sms_relentless', 'Saved'));
145
+
146
+    var baseUrl = OC.generateUrl('/apps/sms_relentless/user/updatesettings');
147
+
148
+    var messagesperpageinit = $("#messagesperpage").val();
149
+    var messagesperpagesec = messagesperpageinit.replace(/[^0-9]/g, '');
150
+
151
+    if (messagesperpagesec != '') {
152
+        var messagesperpageproc = messagesperpagesec;
153
+    } else {
154
+        var messagesperpageproc = 100;
155
+    }
156
+
157
+    var getnotify = 0;
158
+
159
+    if ($("#get_notify").is(':checked')) {
160
+        getnotify = 1;
161
+    }
162
+
163
+    var emailaddressinit = $("#notification_email").val();
164
+
165
+    function validate_email($email) {
166
+        var email_reg = /^([\w-\.]+@([\w-]+\.)+[\w-]{2,4})?$/;
167
+        return email_reg.test($email);
168
+    }
169
+
170
+    if (validate_email(emailaddressinit)) {
171
+         var notifyemail = emailaddressinit;
172
+    } else {
173
+         var notifyemail = '';
174
+    }
175
+
176
+    var telsenderinit = $("#tel_sender_name").val();
177
+    var telsenderproc = telsenderinit.replace(/[^A-Za-z 0-9]/g, '');
178
+
179
+    var nexsenderinit = $("#nex_sender_name").val();
180
+    var nexsenderproc = nexsenderinit.replace(/[^A-Za-z 0-9]/g, '');
181
+
182
+    var twilsenderinit = $("#twil_sender_name").val();
183
+    var twilsenderproc = twilsenderinit.replace(/[^A-Za-z 0-9]/g, '');
184
+
185
+    var includesmsinemail = 0;
186
+    if ($("#includesmsinemail").is(':checked')) {
187
+        includesmsinemail = 1;
188
+    }
189
+
190
+    var showdisplaynm = 0;
191
+    if ($("#showdisplaynames").is(':checked')) {
192
+        showdisplaynm = 1;
193
+    }
194
+
195
+    var datatosave = {
196
+                      userId: userid,
197
+                      telapiKey: $("#telapi_key").val(),
198
+                      telPubKey: $("#tel_pub_key").val(),
199
+                      telapiUrlRec: $("#telapi_url_rec").val(),
200
+                      telapiUrl: $("#telapi_url").val(),
201
+                      messagingProfileId: $("#messaging_profile_id").val(),
202
+                      nexapiKey: $("#nexapi_key").val(),
203
+                      nexapiSecret: $("#nexapi_secret").val(),
204
+                      nexapiUrlRec: $("#nexapi_url_rec").val(),
205
+                      nexapiUrl: $("#nexapi_url").val(),
206
+                      twilapiKey: $("#twilapi_key").val(),
207
+                      twilapiSecret: $("#twilapi_secret").val(),
208
+                      twilapiUrlRec: $("#twilapi_url_rec").val(),
209
+                      twilapiUrl: $("#twilapi_url").val(),
210
+                      flowapiKey: $("#flowapi_key").val(),
211
+                      flowapiSecret: $("#flowapi_secret").val(),
212
+                      flowapiUrlRec: $("#flowapi_url_rec").val(),
213
+                      flowapiUrl: $("#flowapi_url").val(),
214
+                      telSenderName: telsenderproc,
215
+                      nexSenderName: nexsenderproc,
216
+                      twilSenderName: twilsenderproc,
217
+                      messagesperpage: messagesperpageproc,
218
+                      getNotify: getnotify,
219
+                      notificationEmail: notifyemail,
220
+                      getsmsinemail: includesmsinemail,
221
+                      showDisplayNames: showdisplaynm
222
+    };
223
+
224
+
225
+    $.ajax({
226
+       method: 'PUT',
227
+       url: baseUrl + '/' + userid,
228
+       contentType: 'application/json',
229
+       data: JSON.stringify(datatosave),
230
+       success: function() {
231
+       },
232
+       error: function() {
233
+            alert('Error while attempting to save the settings! You can check the Nextcloud log to find more details about this issue.');
234
+       }
235
+    });
236
+
237
+  });
238
+
239
+
240
+  var baseUrlget = OC.generateUrl('/apps/sms_relentless/user/getsettings');
241
+
242
+  $.ajax({
243
+     method: 'GET',
244
+     url: baseUrlget + '/' + userid,
245
+     contentType: 'application/json',
246
+     success: function(settingsfromdb) {
247
+         $("#telapi_key").val(settingsfromdb.telapi_key);
248
+         $("#tel_pub_key").val(settingsfromdb.tel_pub_key);
249
+         $("#telapi_url_rec").val(settingsfromdb.telapi_url_rec);
250
+         $("#telapi_url").val(settingsfromdb.telapi_url);
251
+         $("#messaging_profile_id").val(settingsfromdb.messaging_profile_id);
252
+         $("#nexapi_key").val(settingsfromdb.nexapi_key);
253
+         $("#nexapi_secret").val(settingsfromdb.nexapi_secret);
254
+         $("#nexapi_url_rec").val(settingsfromdb.nexapi_url_rec);
255
+         $("#nexapi_url").val(settingsfromdb.nexapi_url);
256
+         $("#twilapi_key").val(settingsfromdb.twilapi_key);
257
+         $("#twilapi_secret").val(settingsfromdb.twilapi_secret);
258
+         $("#twilapi_url_rec").val(settingsfromdb.twilapi_url_rec);
259
+         $("#twilapi_url").val(settingsfromdb.twilapi_url);
260
+         $("#flowapi_key").val(settingsfromdb.flowapi_key);
261
+         $("#flowapi_secret").val(settingsfromdb.flowapi_secret);
262
+         $("#flowapi_url_rec").val(settingsfromdb.flowapi_url_rec);
263
+         $("#flowapi_url").val(settingsfromdb.flowapi_url);
264
+         $("#tel_sender_name").val(settingsfromdb.tel_sender_name);
265
+         $("#nex_sender_name").val(settingsfromdb.nex_sender_name);
266
+         $("#twil_sender_name").val(settingsfromdb.twil_sender_name);
267
+         $("#messagesperpage").val(settingsfromdb.messagesperpage);
268
+
269
+         if (settingsfromdb.get_notify == 1) {
270
+             $("#get_notify").attr('checked', true);
271
+         } else {
272
+             $("#get_notify").attr('checked', false);
273
+         }
274
+
275
+         $("#notification_email").val(settingsfromdb.notification_email);
276
+
277
+         if (settingsfromdb.getsmsinemail == 1) {
278
+             $("#includesmsinemail").attr('checked', true);
279
+         } else {
280
+             $("#includesmsinemail").attr('checked', false);
281
+         }
282
+
283
+         if (settingsfromdb.show_display_names == 1) {
284
+             $("#showdisplaynames").attr('checked', true);
285
+         } else {
286
+             $("#showdisplaynames").attr('checked', false);
287
+         }
288
+
289
+
290
+         // Auto-reply settings
291
+
292
+         // Get the available phone numbers from all providers associated with the access keys entered on the Settings page (restrictions are applied to numbers for non-admins)
293
+         $("#autoRplPhoneNb").addClass('icon-loading');
294
+         var getnumbersUrl = OC.generateUrl("/apps/sms_relentless/user/getautoreplyconf");
295
+
296
+	 $.ajax({
297
+		  url: getnumbersUrl + '/' + userid,
298
+		  type: "GET",
299
+                  contentType: 'application/json',
300
+		  success: function(autoreplydata) {
301
+
302
+                                    $("#autoRplPhoneNb").removeClass('icon-loading');
303
+                                    var cusrDisplayName = autoreplydata.userdisplayname;
304
+                                    var availPhoneNmbrs = autoreplydata.phonenumbers;
305
+                                    var autorpldata = autoreplydata.autoreplies;
306
+
307
+				    if (autorpldata.length > 0) { 
308
+				        var arplNmb = autorpldata.length;
309
+				    } else { 
310
+				        var arplNmb = 0; 
311
+				    }
312
+
313
+				    // List the auto-replies for the phone numbers available for the current user
314
+				    if (arplNmb == 0) {
315
+
316
+				        $("#autoReplyTbl").append("<tr><td><input type='text' class='arplAuthor' value='"+ cusrDisplayName +"' disabled></td><td><select id='arpphn-"+ arplNmb +"' class='arplPhoneNmbr'></select></td><td><div id='arplmode-"+ arplNmb +"' class='arplMode'><select id='modeselect-"+ arplNmb +"' class='selectArplMode'><option value='' selected>Select mode</option><option value='daily'>Daily mode</option><option value='vacation'>Vacation mode</option></select><div id='modecont-"+ arplNmb +"' class='modeContent'></div></div></td><td><textarea id='arpltxt-"+ arplNmb +"' class='arplText' rows='20' cols='40' placeholder='Enter the auto-reply message here.'></textarea></td><td><img id='rmRow-"+ arplNmb +"' class='removeRow' src='/core/img/actions/close.svg' title='Remove this row from the database' style='cursor:pointer;margin:9px 8px 0px 18px;'></td><td><input type='submit' id='arplsave-"+ arplNmb +"' class='saveAutoReply' value='Save' title='Save Row' /></td></tr>");
317
+				        $("#autoReplyTbl").append("<div><img id='addArplRow' src='/core/img/actions/add.svg' title='Add Row'></div>");
318
+
319
+				    } else {
320
+
321
+				        for (k = 0; k < arplNmb; k++) {
322
+
323
+                                             if (autorpldata[k].days_of_week != '') {
324
+
325
+                                                 var slctdMode = "<option value=''>Select mode</option><option value='daily' selected>Daily mode</option><option value='vacation'>Vacation mode</option>";
326
+                                                 var dailyStartArr = autorpldata[k].daily_start.split(":");
327
+                                                 var dailyEndArr = autorpldata[k].daily_end.split(":");
328
+
329
+		                                 var dlHrStartOptions = "";
330
+			                         for (var hr = 0; hr < 24; hr++) {
331
+		                                      if (dailyStartArr[0] != hr.toLocaleString('en-US', {minimumIntegerDigits: 2, useGrouping:false})) {
332
+			                                  dlHrStartOptions += "<option value='"+ hr.toLocaleString('en-US', {minimumIntegerDigits: 2, useGrouping:false}) +"'>"+ hr.toLocaleString('en-US', {minimumIntegerDigits: 2, useGrouping:false}) +"</option>";
333
+		                                      } else {
334
+			                                  dlHrStartOptions += "<option value='"+ hr.toLocaleString('en-US', {minimumIntegerDigits: 2, useGrouping:false}) +"' selected>"+ hr.toLocaleString('en-US', {minimumIntegerDigits: 2, useGrouping:false}) +"</option>";
335
+		                                      }
336
+			                         }
337
+
338
+		                                 var dlMnStartOptions = "";
339
+			                         for (var mn = 0; mn < 24; mn++) {
340
+		                                      if (dailyStartArr[1] != hr.toLocaleString('en-US', {minimumIntegerDigits: 2, useGrouping:false})) {
341
+			                                  dlMnStartOptions += "<option value='"+ mn.toLocaleString('en-US', {minimumIntegerDigits: 2, useGrouping:false}) +"'>"+ mn.toLocaleString('en-US', {minimumIntegerDigits: 2, useGrouping:false}) +"</option>";
342
+		                                      } else {
343
+			                                  dlMnStartOptions += "<option value='"+ mn.toLocaleString('en-US', {minimumIntegerDigits: 2, useGrouping:false}) +"' selected>"+ mn.toLocaleString('en-US', {minimumIntegerDigits: 2, useGrouping:false}) +"</option>";
344
+		                                      }
345
+			                         }
346
+
347
+		                                 var dlHrEndOptions = "";
348
+			                         for (var hr = 0; hr < 24; hr++) {
349
+		                                      if (dailyEndArr[0] != hr.toLocaleString('en-US', {minimumIntegerDigits: 2, useGrouping:false})) {
350
+			                                  dlHrEndOptions += "<option value='"+ hr.toLocaleString('en-US', {minimumIntegerDigits: 2, useGrouping:false}) +"'>"+ hr.toLocaleString('en-US', {minimumIntegerDigits: 2, useGrouping:false}) +"</option>";
351
+		                                      } else {
352
+			                                  dlHrEndOptions += "<option value='"+ hr.toLocaleString('en-US', {minimumIntegerDigits: 2, useGrouping:false}) +"' selected>"+ hr.toLocaleString('en-US', {minimumIntegerDigits: 2, useGrouping:false}) +"</option>";
353
+		                                      }
354
+			                         }
355
+
356
+		                                 var dlMnEndOptions = "";
357
+			                         for (var mn = 0; mn < 24; mn++) {
358
+		                                      if (dailyEndArr[1] != hr.toLocaleString('en-US', {minimumIntegerDigits: 2, useGrouping:false})) {
359
+			                                  dlMnEndOptions += "<option value='"+ mn.toLocaleString('en-US', {minimumIntegerDigits: 2, useGrouping:false}) +"'>"+ mn.toLocaleString('en-US', {minimumIntegerDigits: 2, useGrouping:false}) +"</option>";
360
+		                                      } else {
361
+			                                  dlMnEndOptions += "<option value='"+ mn.toLocaleString('en-US', {minimumIntegerDigits: 2, useGrouping:false}) +"' selected>"+ mn.toLocaleString('en-US', {minimumIntegerDigits: 2, useGrouping:false}) +"</option>";
362
+		                                      }
363
+			                         }
364
+
365
+                                                 var modeContent = "<div class='daysOfWeek'>Days of the week:<div class='tooltipautoreply'><div id='infoautoreply'>i</div><div class='autorpltooltip'>Enter the order number of the days of the week in which the auto-reply will be sent. For example, to send the auto-reply every day from Monday to Friday (outside the time interval specified below), enter 1,2,3,4,5 To send the auto-reply only Monday, Thursday and Friday enter 1,4,5 To send the auto-reply every day of the week enter 1,2,3,4,5,6,7</div></div></div><input type='text' id='weekdays-"+ k +"' class='daysInWeek' value='"+ autorpldata[k].days_of_week +"'><div class='chooseTInterval'>Send auto-reply <span style='color:#ad0202'>outside</span> this interval:<div class='tooltipautoreplyst'><div id='infoautoreplyst'>i</div><div class='autorpltooltipst'>These fields specify the time of the server. If the server is located in a time zone that is different from that of the owner/company, the time interval entered here should be adjusted accordingly.</div></div></div><div class='selectArplHours'><select id='dmstarthr-"+ k +"' class='selectHrMin'>"+ dlHrStartOptions +"</select><select id='dmstartmn-"+ k +"' class='selectHrMin'>"+ dlMnStartOptions +"</select><span style='font-weight: 600'> — </span><select id='dmendhr-"+ k +"' class='selectHrMin'>"+ dlHrEndOptions +"</select><select id='dmendmn-"+ k +"' class='selectHrMin'>"+ dlMnEndOptions +"</select></div>";
366
+
367
+                                             } else {
368
+
369
+                                                 var vctnStart = autorpldata[k].vacation_start.split(" ")[0];
370
+                                                 var vctnEnd = autorpldata[k].vacation_end.split(" ")[0];
371
+
372
+                                                 var slctdMode = "<option value=''>Select mode</option><option value='daily'>Daily mode</option><option value='vacation' selected>Vacation mode</option>";
373
+                                                 var modeContent = "<div class='chooseDateIntvl'>Send auto-reply <span style='color:#ad0202'>inside</span> this interval:</div><div class='arplstrtendDates'><div class='stdtTitle'>Start Date</div><input type='text' id='startDT-"+ k +"' class='startDate' placeholder='Pick a date' value='"+ vctnStart +"'><div class='enddtTitle'>End Date</div><input type='text' id='endDT-"+ k +"' class='endDate' placeholder='Pick a date' value='"+ vctnEnd +"'></div>"
374
+                                             }
375
+
376
+				             $("#autoReplyTbl").append("<tr><td><input type='text' class='arplAuthor' value='"+ autorpldata[k].saved_by_dsplname +"' disabled></td><td><select id='arpphn-"+ k +"' class='arplPhoneNmbr' style='pointer-events:none'><option selected>"+ autorpldata[k].phone_number +"</option></select></td><td><div id='arplmode-"+ k +"' class='arplMode'><select id='modeselect-"+ k +"' class='selectArplMode'>"+ slctdMode +"</select><div id='modecont-"+ k +"' class='modeContent'>"+ modeContent +"</div></div></td><td><textarea id='arpltxt-"+ k +"' class='arplText' rows='20' cols='40' placeholder='Enter the auto-reply message here.'>"+ autorpldata[k].message_text +"</textarea></td><td><img id='rmRow-"+ k +"' class='removeRow' src='/core/img/actions/close.svg' title='Remove this row from the database' style='cursor:pointer;margin:9px 8px 0px 18px;'></td><td><input type='submit' id='arplsave-"+ k +"' class='saveAutoReply' value='Edit' title='Edit Row' /></td></tr>");
377
+				        }
378
+				        $("#autoReplyTbl").append("<div><img id='addArplRow' src='/core/img/actions/add.svg' title='Add Row'></div>");
379
+				    }
380
+
381
+
382
+				    // Create a list with all the available phone numbers
383
+                                    var numbersListItems = "<option value='' selected>Select phone number</option>";
384
+
385
+				    $.each(availPhoneNmbrs, function(key, indsmsnmb) {
386
+					 var emptyinit = indsmsnmb.split(":");
387
+					 var emptysec = emptyinit[1];
388
+					 var emptycheck = emptysec.replace(" ", "").replace("+", "");
389
+
390
+					 if (emptycheck != '') {
391
+					     numbersListItems += "<option value='"+ indsmsnmb +"'>"+ indsmsnmb +"</option>";
392
+					 }
393
+				    });
394
+
395
+                                    if (arplNmb == 0) {
396
+				        $("#arpphn-"+ arplNmb).append(numbersListItems);
397
+                                    }
398
+
399
+                                    // Initialize the date picker
400
+			            $('[id^="endDT-"]').datepicker({ dateFormat: "yy-mm-dd" });
401
+			            $('[id^="startDT-"]').datepicker({ dateFormat: "yy-mm-dd" });
402
+
403
+
404
+                                    // Select the auto-reply mode
405
+                                    function selectMode() {
406
+
407
+		                            $('[id^="modeselect-"]').change(function() {
408
+
409
+		                               var crtnmbr = $(this).attr("id").replace("modeselect-", "");
410
+
411
+		                               var dailyHrStart = "";
412
+		                               for (var h = 0; h < 24; h++) {
413
+		                                    dailyHrStart += "<option value='"+ h.toLocaleString('en-US', {minimumIntegerDigits: 2, useGrouping:false}) +"'>"+ h.toLocaleString('en-US', {minimumIntegerDigits: 2, useGrouping:false}) +"</option>";
414
+		                               }
415
+
416
+		                               var dailyMnStart = "";
417
+		                               for (var m = 0; m < 60; m++) {
418
+		                                    dailyMnStart += "<option value='"+ m.toLocaleString('en-US', {minimumIntegerDigits: 2, useGrouping:false}) +"'>"+ m.toLocaleString('en-US', {minimumIntegerDigits: 2, useGrouping:false}) +"</option>";
419
+		                               }
420
+
421
+		                               var dailyHrEnd = dailyHrStart;
422
+		                               var dailyMnEnd = dailyMnStart;
423
+
424
+		                               if ($(this).val() == 'daily') {
425
+		                                   $("#modecont-"+ crtnmbr).empty();
426
+		                                   $("#modecont-"+ crtnmbr).append("<div class='daysOfWeek'>Days of the week:<div class='tooltipautoreply'><div id='infoautoreply'>i</div><div class='autorpltooltip'>Enter the order number of the days of the week. For example, to send the auto-reply every day from Monday to Friday outside the specified time interval, enter 1,2,3,4,5 To send the auto-reply only Monday, Thursday and Friday enter 1,4,5 To send the auto-reply every day of the week enter 1,2,3,4,5,6,7</div></div></div><input type='text' id='weekdays-"+ crtnmbr +"' class='daysInWeek'><div class='chooseTInterval'>Send auto-reply <span style='color:#ad0202'>outside</span> this interval:<div class='tooltipautoreplyst'><div id='infoautoreplyst'>i</div><div class='autorpltooltipst'>These fields specify the time of the server. If the server is located in a time zone that is different from that of the owner/company, the time interval entered here should be adjusted accordingly.</div></div></div><div class='selectArplHours'><select id='dmstarthr-"+ crtnmbr +"' class='selectHrMin'>"+ dailyHrStart +"</select><select id='dmstartmn-"+ crtnmbr +"' class='selectHrMin'>"+ dailyMnStart +"</select><span style='font-weight: 600'> — </span><select id='dmendhr-"+ crtnmbr +"' class='selectHrMin'>"+ dailyHrEnd +"</select><select id='dmendmn-"+ crtnmbr +"' class='selectHrMin'>"+ dailyMnEnd +"</select></div>");
427
+		                               } else if ($(this).val() == 'vacation') {
428
+		                                   $("#modecont-"+ crtnmbr).empty();
429
+		                                   $("#modecont-"+ crtnmbr).append("<div class='chooseDateIntvl'>Send auto-reply <span style='color:#ad0202'>inside</span> this interval:</div><div class='arplstrtendDates'><div class='stdtTitle'>Start Date</div><input type='text' id='startDT-"+ crtnmbr +"' class='startDate' placeholder='Pick a date'><div class='enddtTitle'>End Date</div><input type='text' id='endDT-"+ crtnmbr +"' class='endDate' placeholder='Pick a date' /></div>");
430
+		                               }
431
+
432
+					       $("#endDT-"+ crtnmbr +"").datepicker({ dateFormat: "yy-mm-dd" });
433
+					       $("#startDT-"+ crtnmbr +"").datepicker({ dateFormat: "yy-mm-dd" });
434
+		                          });
435
+                                  }
436
+                                  selectMode();
437
+
438
+				  // Save the data
439
+				  function saveArplRow() {
440
+
441
+				     $('[id^="arplsave-"]').unbind("click");
442
+				     $('[id^="arplsave-"]').click(function(event) {
443
+
444
+				        event.preventDefault();
445
+				        var crntrwnmbr = $(this).attr("id").replace("arplsave-", "");
446
+
447
+				        if ($(this).attr("value") == "Save") {
448
+
449
+				            var phoneNmbr = $("#arpphn-"+ crntrwnmbr).val();
450
+				            var arplText = $("#arpltxt-"+ crntrwnmbr).val();
451
+				            var slctdMode = $("#modeselect-"+ crntrwnmbr).val();
452
+
453
+				            var slctddmDays = "";
454
+				            var slctdHrStart = "";
455
+				            var slctdMnStart = "";
456
+				            var slctdHrEnd = "";
457
+				            var slctdMnEnd = "";
458
+
459
+				            var vcStartDate = null;
460
+				            var vcEndDate = null;
461
+
462
+				            if (slctdMode == 'daily') {
463
+
464
+				                slctddmDays = $("#weekdays-"+ crntrwnmbr).val().trim();
465
+				                slctdHrStart = $("#dmstarthr-"+ crntrwnmbr).val().trim();
466
+				                slctdMnStart = $("#dmstartmn-"+ crntrwnmbr).val().trim();
467
+				                slctdHrEnd = $("#dmendhr-"+ crntrwnmbr).val().trim();
468
+				                slctdMnEnd = $("#dmendmn-"+ crntrwnmbr).val().trim();
469
+
470
+                                                if (slctdHrStart != '' && slctdMnStart != '') {
471
+                                                    var hrmnStartComp = slctdHrStart +":"+ slctdMnStart;
472
+                                                } else { var hrmnStartComp = ""; }
473
+
474
+                                                if (slctdHrEnd != '' && slctdMnEnd != '') {
475
+                                                    var hrmnEndComp = slctdHrEnd +":"+ slctdMnEnd;
476
+                                                } else { var hrmnEndComp = ""; }
477
+
478
+                                                if (!(/^[1-7\,]+$/.test(slctddmDays))) {
479
+				                    alert("The 'Days of the week' field can contain only digits from 1 to 7 and commas (,).");
480
+				                    return;
481
+                                                }
482
+
483
+                                                if (!(/^[0-9]+$/.test(slctdHrStart + slctdMnStart + slctdHrEnd + slctdMnEnd))) {
484
+				                    alert("The starting and ending values of the time interval for the 'Daily mode' can contain only digits from 0 to 9.");
485
+				                    return;
486
+                                                }
487
+
488
+                                                if (slctddmDays.trim() == '' || (slctdHrStart == slctdHrEnd && slctdMnStart == slctdMnEnd)) {
489
+				                    alert("For the 'Daily mode', you have to enter the order number of the days of the week for which you want the auto-reply to be sent, and you have to set a starting time that is different from the ending time!");
490
+				                    return;
491
+                                                }
492
+
493
+				            } else if (slctdMode == 'vacation') {
494
+		
495
+                                                if ($("#startDT-"+ crntrwnmbr).val().trim() == '' || $("#endDT-"+ crntrwnmbr).val().trim() == '') {
496
+
497
+				                    alert("For the 'Vacation mode', you have to enter both a start date and an end date.");
498
+				                    return;
499
+
500
+                                                } else {
501
+
502
+                                                    if (!(/^[0-9\-]+$/.test($("#startDT-"+ crntrwnmbr).val().trim() + $("#endDT-"+ crntrwnmbr).val().trim()))) {
503
+				                        alert("The start date and end date values for the 'Vacation mode' can contain only digits from 0 to 9 and hyphens (-).");
504
+				                        return;
505
+                                                    }
506
+
507
+		                                    vcStartDate = $("#startDT-"+ crntrwnmbr).val().trim() +" 00:00:00";
508
+				                    vcEndDate = $("#endDT-"+ crntrwnmbr).val().trim() +" 23:59:59";
509
+				                    var strtDateCmp = new Date(vcStartDate).toJSON().slice(0, 10) +" 00:00:00";
510
+				                    var endDateCmp = new Date(vcEndDate).toJSON().slice(0, 10) +" 23:59:59";
511
+				                    var crntDate = new Date().toJSON().slice(0, 10) +" 23:59:59";
512
+
513
+                                                    if (vcStartDate.trim() == "" || vcEndDate.trim() == "" || (strtDateCmp >= endDateCmp || ((strtDateCmp < crntDate) && (endDateCmp < crntDate)))) {
514
+				                        alert("For 'Vacation mode', you have to enter both a start date and an end date, the start date must be before the end date and at least the ending of the time interval must be in the future.");
515
+				                        return;
516
+                                                    }
517
+                                                }
518
+				            }
519
+
520
+
521
+				            if (phoneNmbr != '') {
522
+
523
+				              if (arplText.trim() != '') {
524
+
525
+				                if (slctdMode != '') {
526
+
527
+				                    var saveArplUrl = OC.generateUrl('/apps/sms_relentless/user/updateautoreplies');
528
+				                    var arpldata = {
529
+				                         userId: userid,
530
+				                         savedByDsplname: cusrDisplayName,
531
+				                         phoneNumber: phoneNmbr,
532
+				                         daysOfWeek: slctddmDays,
533
+				                         dailyStart: hrmnStartComp,
534
+				                         dailyEnd: hrmnEndComp,
535
+				                         vacationStart: vcStartDate,
536
+				                         vacationEnd: vcEndDate,
537
+				                         messageText: arplText
538
+				                    };
539
+
540
+					            $.ajax({
541
+					              method: 'PUT',
542
+					              url: saveArplUrl + '/' + userid,
543
+					              contentType: 'application/json',
544
+					              data: JSON.stringify(arpldata),
545
+				                      success: function(messagereceived) {
546
+
547
+				                                   if (messagereceived == 'success') {
548
+				                                       alert('The auto-reply has been successfully saved to the database!');
549
+				                                   } else if (messagereceived == 'failure') {
550
+				                                       alert('Error while trying to save the auto-reply!');
551
+				                                   } else if (messagereceived == 'not allowed') {
552
+                                                                       alert('You cannot change an auto-reply that was saved by a different user.');
553
+                                                                   }
554
+				                      },
555
+					              error: function() {
556
+						                   alert('Error while attempting to save the auto-reply! You can check the Nextcloud log to find more details about this issue.');
557
+					              }
558
+					            });
559
+
560
+
561
+                                                } else { alert("Please select the auto-reply mode."); return; }
562
+
563
+                                              } else { alert("Please enter the text of the auto-reply."); return; }
564
+
565
+                                            } else { alert("Please select a phone number if at least one number is available in the 'Phone Number' drop-down list. Otherwise, you should contact the administrator."); return; }
566
+
567
+                                            $(this).attr("value", "Edit");
568
+
569
+                                        } else {
570
+                                            $("#arplsave-"+ crntrwnmbr).attr("value", "Save");
571
+                                        }
572
+
573
+                                     });
574
+
575
+				  }
576
+                                  saveArplRow();
577
+
578
+
579
+				  // Remove a row
580
+				  function removeArplRow() {
581
+				       $('[id^="rmRow-"]').click(function() {
582
+
583
+					  var slctRowRm = $(this).attr("id").replace("rmRow-", "");
584
+					  var crntPhnNmbr = $("#arpphn-"+ slctRowRm).val();
585
+
586
+					  if (confirm("Do you really want to remove this row from the database ?")) {
587
+
588
+					      var rmvArplUrl = OC.generateUrl('/apps/sms_relentless/user/removeautoreplies');
589
+					      $.ajax({
590
+						   url: rmvArplUrl + '/' + userid,
591
+						   method: "POST",
592
+						   dataType: "text",
593
+						   data: { phoneNumber: crntPhnNmbr },
594
+						   success: function(delresult) {
595
+
596
+						                     if (delresult.indexOf("success") > -1) {
597
+						                         alert("The auto-reply has been removed successfully!");
598
+						                         $("#arpphn-"+ slctRowRm).closest("tr").remove();
599
+						                     } else if (delresult.indexOf("failure") > -1) {
600
+						                         alert("Error while trying to remove auto-reply data!");
601
+						                     } else if (delresult.indexOf("not allowed") > -1) {
602
+                                                                         alert("You cannot remove the auto-reply saved by another user.");
603
+                                                                     }
604
+						   },
605
+						   error: function() { alert("Error while attempting to remove auto-reply data! You can check the Nextcloud log to find more details about this issue."); }
606
+					       });
607
+					  }
608
+				       });
609
+				  }
610
+				  removeArplRow();
611
+
612
+                                  // Add new row
613
+                                  $("#addArplRow").click(function() {
614
+
615
+                                     if ($("#autoReplyTbl").find("tr:last-child").find(".arplPhoneNmbr").length > 0) {
616
+                                         var lastarpl = $("#autoReplyTbl").find("tr:last-child").find(".arplPhoneNmbr").attr("id").replace("arpphn-", "");
617
+                                         var indArplAdd = parseInt(lastarpl + 1);
618
+                                     } else { var indArplAdd = 0; }
619
+			             $("#autoReplyTbl").append("<tr><td><input type='text' class='arplAuthor' value='"+ cusrDisplayName +"' disabled></td><td><select id='arpphn-"+ indArplAdd +"' class='arplPhoneNmbr'>"+ numbersListItems +"</select></td><td><div id='arplmode-"+ indArplAdd +"' class='arplMode'><select id='modeselect-"+ indArplAdd +"' class='selectArplMode'><option value='' selected>Select mode</option><option value='daily'>Daily mode</option><option value='vacation'>Vacation mode</option></select><div id='modecont-"+ indArplAdd +"' class='modeContent'></div></div></td><td><textarea id='arpltxt-"+ indArplAdd +"' class='arplText' rows='20' cols='40' placeholder='Enter the auto-reply message here.'></textarea></td><td><img id='rmRow-"+ indArplAdd +"' class='removeRow' src='/core/img/actions/close.svg' title='Remove this row from the database' style='cursor:pointer;margin:9px 8px 0px 18px;'></td><td><input type='submit' id='arplsave-"+ indArplAdd +"' class='saveAutoReply' value='Save' title='Save Row' /></td></tr>");
620
+
621
+                                     selectMode();
622
+                                     saveArplRow();
623
+                                     removeArplRow();
624
+
625
+			             // Check if there is an auto-reply set for the same phone number
626
+				     $("#arpphn-"+ indArplAdd).change(function() {
627
+					 var selectedPhNb = $("#arpphn-"+ indArplAdd).val();
628
+					 var allArplPhNmbrs = $("#autoReplyTbl").find("tr").find(".arplPhoneNmbr");
629
+					 var phNbChck = 0;
630
+					 allArplPhNmbrs.each(function() {
631
+					    var slctphnb = ($(this).val())? $(this).val() : $(this).text();
632
+					    if (selectedPhNb == slctphnb) { phNbChck++; }
633
+					 });
634
+
635
+					 if (phNbChck == 2) {
636
+					     alert("There is already an auto-reply set up for this phone number. Please edit its own row, or choose a different phone number.");
637
+					     $(this).val('');
638
+					     return;
639
+					 }
640
+				     });
641
+                                  });
642
+
643
+		  },
644
+		  error: function() {
645
+                                    $("#autoRplPhoneNb").removeClass('icon-loading'); 
646
+                                    alert("Error while attempting to get the auto-reply settings! You can check the Nextcloud log to find more details about this issue.");
647
+                  }
648
+         });
649
+
650
+     },
651
+     error: function() {
652
+                  alert('Error while getting the settings! You can check the Nextcloud log to find more details about this issue.');
653
+     }
654
+  });
655
+
656
+});
Browse code

removed a substantial number of files

DoubleBastionAdmin authored on 08/05/2023 20:27:04
Showing 1 changed files
1 1
deleted file mode 100644
... ...
@@ -1,283 +0,0 @@
1
-/**
2
- * @copyright 2021 Double Bastion LLC <www.doublebastion.com>
3
- *
4
- * @author Double Bastion LLC
5
- *
6
- * @license GNU AGPL version 3 or any later version
7
- *
8
- * This program is free software; you can redistribute it and/or
9
- * modify it under the terms of the GNU AFFERO GENERAL PUBLIC LICENSE
10
- * License as published by the Free Software Foundation; either
11
- * version 3 of the License, or any later version.
12
- *
13
- * This program is distributed in the hope that it will be useful,
14
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
15
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
16
- * GNU AFFERO GENERAL PUBLIC LICENSE for more details.
17
- *
18
- * You should have received a copy of the GNU Affero General Public
19
- * License along with this program.  If not, see <http://www.gnu.org/licenses/>.
20
- *
21
- */
22
-
23
-$(document).ready(function() {
24
-
25
-  var userid = "<?php p($userId); ?>";
26
-  var strlength;
27
-
28
-  function randomStr(strlength) {
29
-        var fintext = "";
30
-        var keyspace = '0123456789abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ';
31
-        for (var i = 0; i < strlength; i++) {
32
-             fintext += keyspace.charAt(Math.floor(Math.random() * keyspace.length));
33
-        }
34
-        return fintext;
35
-  }
36
-
37
-  $("#generate_tel_rcpt").on("click", function(event) {
38
-
39
-     var teltokenrec = randomStr(70);
40
-     var telnyxwhurlrec = window.location.origin + OC.generateUrl('/apps/sms_relentless/api/recsmstel?telrecparam=') + teltokenrec;
41
-
42
-     $("#telapi_url_rec").val(telnyxwhurlrec);
43
-  });
44
-
45
-  $("#copyToClipboardtel").on("click", function(event) {
46
-     var $tempEl = $("<input>");
47
-     $("body").append($tempEl);
48
-     $tempEl.val($("#telapi_url_rec").val()).select();
49
-     document.execCommand("Copy");
50
-     $tempEl.remove();
51
-     alert("The link has been copied to your clipboard!");
52
-  });
53
-
54
-  $("#generate_tel_delrcpt").on("click", function(event) {
55
-
56
-     var teltoken = randomStr(70);
57
-     var telnyxwhurl = window.location.origin + OC.generateUrl('/apps/sms_relentless/api/recdeliverytel?teldrparam=') + teltoken;
58
-
59
-     $("#telapi_url").val(telnyxwhurl);
60
-  });
61
-
62
-
63
-  $("#generate_nex_rcpt").on("click", function(event) {
64
-
65
-     var plivotokenrec = randomStr(70);
66
-     var plivowhurlrec = window.location.origin + OC.generateUrl('/apps/sms_relentless/api/recsmsnex?plivorecparam=') + plivotokenrec;
67
-
68
-     $("#nexapi_url_rec").val(plivowhurlrec);
69
-  });
70
-
71
-  $("#copyToClipboardnex").on("click", function(event) {
72
-     var $tempElpl = $("<input>");
73
-     $("body").append($tempElpl);
74
-     $tempElpl.val($("#nexapi_url_rec").val()).select();
75
-     document.execCommand("Copy");
76
-     $tempElpl.remove();
77
-     alert("The link has been copied to your clipboard!");
78
-  });
79
-
80
-  $("#generate_nex_delrcpt").on("click", function(event) {
81
-
82
-     var plivotoken = randomStr(70);
83
-     var plivodrwhurl = window.location.origin + OC.generateUrl('/apps/sms_relentless/api/recdeliverynex?plivodrparam=') + plivotoken;
84
-
85
-     $("#nexapi_url").val(plivodrwhurl);
86
-  });
87
-
88
-
89
-  $("#generate_twil_rcpt").on("click", function(event) {
90
-
91
-     var twiltokenrec = randomStr(35);
92
-     var twilwhurlrec = window.location.origin + OC.generateUrl('/apps/sms_relentless/api/recsmstwil?twilrecparam=') + twiltokenrec;
93
-
94
-     $("#twilapi_url_rec").val(twilwhurlrec);
95
-  });
96
-
97
-  $("#copyToClipboardtwil").on("click", function(event) {
98
-     var $tempElpl = $("<input>");
99
-     $("body").append($tempElpl);
100
-     $tempElpl.val($("#twilapi_url_rec").val()).select();
101
-     document.execCommand("Copy");
102
-     $tempElpl.remove();
103
-     alert("The link has been copied to your clipboard!");
104
-  });
105
-
106
-  $("#generate_twil_delrcpt").on("click", function(event) {
107
-
108
-     var twiltoken = randomStr(35);
109
-     var twildrwhurl = window.location.origin + OC.generateUrl('/apps/sms_relentless/api/recdeliverytwil?twildrparam=') + twiltoken;
110
-
111
-     $("#twilapi_url").val(twildrwhurl);
112
-  });
113
-
114
-
115
-  $("#generate_flow_rcpt").on("click", function(event) {
116
-
117
-     var flowtokenrec = randomStr(70);
118
-     var flowwhurlrec = window.location.origin + OC.generateUrl('/apps/sms_relentless/api/recsmsflow?flowrecparam=') + flowtokenrec;
119
-
120
-     $("#flowapi_url_rec").val(flowwhurlrec);
121
-  });
122
-
123
-  $("#copyToClipboardflow").on("click", function(event) {
124
-     var $tempElpl = $("<input>");
125
-     $("body").append($tempElpl);
126
-     $tempElpl.val($("#flowapi_url_rec").val()).select();
127
-     document.execCommand("Copy");
128
-     $tempElpl.remove();
129
-     alert("The link has been copied to your clipboard!");
130
-  });
131
-
132
-  $("#generate_flow_delrcpt").on("click", function(event) {
133
-
134
-     var flowtoken = randomStr(70);
135
-     var flowdrwhurl = window.location.origin + OC.generateUrl('/apps/sms_relentless/api/recdeliveryflow?flowdrparam=') + flowtoken;
136
-
137
-     $("#flowapi_url").val(flowdrwhurl);
138
-  });
139
-
140
-
141
-  $("#save_sms_settings").on("click", function(event) {
142
-
143
-    event.preventDefault();
144
-    OC.msg.startAction('#smsr_save_msg', t('sms_relentless', 'Saved'));
145
-
146
-    var baseUrl = OC.generateUrl('/apps/sms_relentless/user/updatesettings');
147
-
148
-    var messagesperpageinit = $("#messagesperpage").val();
149
-    var messagesperpagesec = messagesperpageinit.replace(/[^0-9]/g, '');
150
-
151
-    if (messagesperpagesec != '') {
152
-        var messagesperpageproc = messagesperpagesec;
153
-    } else {
154
-        var messagesperpageproc = 100;
155
-    }
156
-
157
-    var getnotify = 0;
158
-
159
-    if ($("#get_notify").is(':checked')) {
160
-        getnotify = 1;
161
-    }
162
-
163
-    var emailaddressinit = $("#notification_email").val();
164
-
165
-    function validate_email($email) {
166
-        var email_reg = /^([\w-\.]+@([\w-]+\.)+[\w-]{2,4})?$/;
167
-        return email_reg.test($email);
168
-    }
169
-
170
-    if (validate_email(emailaddressinit)) {
171
-         var notifyemail = emailaddressinit;
172
-    } else {
173
-         var notifyemail = '';
174
-    }
175
-
176
-    var telsenderinit = $("#tel_sender_name").val();
177
-    var telsenderproc = telsenderinit.replace(/[^A-Za-z 0-9]/g, '');
178
-
179
-    var nexsenderinit = $("#nex_sender_name").val();
180
-    var nexsenderproc = nexsenderinit.replace(/[^A-Za-z 0-9]/g, '');
181
-
182
-    var twilsenderinit = $("#twil_sender_name").val();
183
-    var twilsenderproc = twilsenderinit.replace(/[^A-Za-z 0-9]/g, '');
184
-
185
-    //  var flowsenderinit = $("#flow_sender_name").val();
186
-    //  var flowsenderproc = flowsenderinit.replace(/[^A-Za-z 0-9]/g, '');
187
-
188
-    var includesmsinemail = 0;
189
-
190
-    if ($("#includesmsinemail").is(':checked')) {
191
-        includesmsinemail = 1;
192
-    }
193
-
194
-    var datatosave = {
195
-                      userId: userid,
196
-                      telapiKey: $("#telapi_key").val(),
197
-                      telPubKey: $("#tel_pub_key").val(),
198
-                      telapiUrlRec: $("#telapi_url_rec").val(),
199
-                      telapiUrl: $("#telapi_url").val(),
200
-                      messagingProfileId: $("#messaging_profile_id").val(),
201
-                      nexapiKey: $("#nexapi_key").val(),
202
-                      nexapiSecret: $("#nexapi_secret").val(),
203
-                      nexapiUrlRec: $("#nexapi_url_rec").val(),
204
-                      nexapiUrl: $("#nexapi_url").val(),
205
-                      twilapiKey: $("#twilapi_key").val(),
206
-                      twilapiSecret: $("#twilapi_secret").val(),
207
-                      twilapiUrlRec: $("#twilapi_url_rec").val(),
208
-                      twilapiUrl: $("#twilapi_url").val(),
209
-                      flowapiKey: $("#flowapi_key").val(),
210
-                      flowapiSecret: $("#flowapi_secret").val(),
211
-                      flowapiUrlRec: $("#flowapi_url_rec").val(),
212
-                      flowapiUrl: $("#flowapi_url").val(),
213
-                      telSenderName: telsenderproc,
214
-                      nexSenderName: nexsenderproc,
215
-                      twilSenderName: twilsenderproc,
216
-                      //  flowSenderName: flowsenderproc,
217
-                      messagesperpage: messagesperpageproc,
218
-                      getNotify: getnotify,
219
-                      notificationEmail: notifyemail,
220
-                      getsmsinemail: includesmsinemail
221
-    };
222
-
223
-
224
-    $.ajax({
225
-       method: 'PUT',
226
-       url: baseUrl + '/' + userid,
227
-       contentType: 'application/json',
228
-       data: JSON.stringify(datatosave),
229
-       error: function(resp) {
230
-            alert('Error ! Please check your settings !');
231
-       }
232
-    });
233
-
234
-  });
235
-
236
-
237
-  var baseUrlget = OC.generateUrl('/apps/sms_relentless/user/getsettings');
238
-
239
-  $.ajax({
240
-     method: 'GET',
241
-     url: baseUrlget + '/' + userid,
242
-     contentType: 'application/json',
243
-     success: function(settingsfromdb) {
244
-         $("#telapi_key").val(settingsfromdb.telapi_key);
245
-         $("#tel_pub_key").val(settingsfromdb.tel_pub_key);
246
-         $("#telapi_url_rec").val(settingsfromdb.telapi_url_rec);
247
-         $("#telapi_url").val(settingsfromdb.telapi_url);
248
-         $("#messaging_profile_id").val(settingsfromdb.messaging_profile_id);
249
-         $("#nexapi_key").val(settingsfromdb.nexapi_key);
250
-         $("#nexapi_secret").val(settingsfromdb.nexapi_secret);
251
-         $("#nexapi_url_rec").val(settingsfromdb.nexapi_url_rec);
252
-         $("#nexapi_url").val(settingsfromdb.nexapi_url);
253
-         $("#twilapi_key").val(settingsfromdb.twilapi_key);
254
-         $("#twilapi_secret").val(settingsfromdb.twilapi_secret);
255
-         $("#twilapi_url_rec").val(settingsfromdb.twilapi_url_rec);
256
-         $("#twilapi_url").val(settingsfromdb.twilapi_url);
257
-         $("#flowapi_key").val(settingsfromdb.flowapi_key);
258
-         $("#flowapi_secret").val(settingsfromdb.flowapi_secret);
259
-         $("#flowapi_url_rec").val(settingsfromdb.flowapi_url_rec);
260
-         $("#flowapi_url").val(settingsfromdb.flowapi_url);
261
-         $("#tel_sender_name").val(settingsfromdb.tel_sender_name);
262
-         $("#nex_sender_name").val(settingsfromdb.nex_sender_name);
263
-         $("#twil_sender_name").val(settingsfromdb.twil_sender_name);
264
-         //  $("#flow_sender_name").val(settingsfromdb.flow_sender_name);
265
-         $("#messagesperpage").val(settingsfromdb.messagesperpage);
266
-
267
-         if (settingsfromdb.get_notify == 1) {
268
-             $("#get_notify").attr('checked', true);
269
-         } else {
270
-             $("#get_notify").attr('checked', false);
271
-         }
272
-
273
-         $("#notification_email").val(settingsfromdb.notification_email);
274
-
275
-         if (settingsfromdb.getsmsinemail == 1) {
276
-             $("#includesmsinemail").attr('checked', true);
277
-         } else {
278
-             $("#includesmsinemail").attr('checked', false);
279
-         }
280
-     }
281
-  });
282
-
283
-});
Browse code

added CHANGELOG.txt appinfo/info.xml appinfo/signature.json js/settings.js templates/settings.php lib/Controller/AuthorApiController.php lib/Controller/SmsrelentlessController.php lib/Service/SmsrelentlessService.php

DoubleBastionAdmin authored on 08/09/2022 21:56:39
Showing 1 changed files
1 1
new file mode 100644
... ...
@@ -0,0 +1,283 @@
1
+/**
2
+ * @copyright 2021 Double Bastion LLC <www.doublebastion.com>
3
+ *
4
+ * @author Double Bastion LLC
5
+ *
6
+ * @license GNU AGPL version 3 or any later version
7
+ *
8
+ * This program is free software; you can redistribute it and/or
9
+ * modify it under the terms of the GNU AFFERO GENERAL PUBLIC LICENSE
10
+ * License as published by the Free Software Foundation; either
11
+ * version 3 of the License, or any later version.
12
+ *
13
+ * This program is distributed in the hope that it will be useful,
14
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
15
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
16
+ * GNU AFFERO GENERAL PUBLIC LICENSE for more details.
17
+ *
18
+ * You should have received a copy of the GNU Affero General Public
19
+ * License along with this program.  If not, see <http://www.gnu.org/licenses/>.
20
+ *
21
+ */
22
+
23
+$(document).ready(function() {
24
+
25
+  var userid = "<?php p($userId); ?>";
26
+  var strlength;
27
+
28
+  function randomStr(strlength) {
29
+        var fintext = "";
30
+        var keyspace = '0123456789abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ';
31
+        for (var i = 0; i < strlength; i++) {
32
+             fintext += keyspace.charAt(Math.floor(Math.random() * keyspace.length));
33
+        }
34
+        return fintext;
35
+  }
36
+
37
+  $("#generate_tel_rcpt").on("click", function(event) {
38
+
39
+     var teltokenrec = randomStr(70);
40
+     var telnyxwhurlrec = window.location.origin + OC.generateUrl('/apps/sms_relentless/api/recsmstel?telrecparam=') + teltokenrec;
41
+
42
+     $("#telapi_url_rec").val(telnyxwhurlrec);
43
+  });
44
+
45
+  $("#copyToClipboardtel").on("click", function(event) {
46
+     var $tempEl = $("<input>");
47
+     $("body").append($tempEl);
48
+     $tempEl.val($("#telapi_url_rec").val()).select();
49
+     document.execCommand("Copy");
50
+     $tempEl.remove();
51
+     alert("The link has been copied to your clipboard!");
52
+  });
53
+
54
+  $("#generate_tel_delrcpt").on("click", function(event) {
55
+
56
+     var teltoken = randomStr(70);
57
+     var telnyxwhurl = window.location.origin + OC.generateUrl('/apps/sms_relentless/api/recdeliverytel?teldrparam=') + teltoken;
58
+
59
+     $("#telapi_url").val(telnyxwhurl);
60
+  });
61
+
62
+
63
+  $("#generate_nex_rcpt").on("click", function(event) {
64
+
65
+     var plivotokenrec = randomStr(70);
66
+     var plivowhurlrec = window.location.origin + OC.generateUrl('/apps/sms_relentless/api/recsmsnex?plivorecparam=') + plivotokenrec;
67
+
68
+     $("#nexapi_url_rec").val(plivowhurlrec);
69
+  });
70
+
71
+  $("#copyToClipboardnex").on("click", function(event) {
72
+     var $tempElpl = $("<input>");
73
+     $("body").append($tempElpl);
74
+     $tempElpl.val($("#nexapi_url_rec").val()).select();
75
+     document.execCommand("Copy");
76
+     $tempElpl.remove();
77
+     alert("The link has been copied to your clipboard!");
78
+  });
79
+
80
+  $("#generate_nex_delrcpt").on("click", function(event) {
81
+
82
+     var plivotoken = randomStr(70);
83
+     var plivodrwhurl = window.location.origin + OC.generateUrl('/apps/sms_relentless/api/recdeliverynex?plivodrparam=') + plivotoken;
84
+
85
+     $("#nexapi_url").val(plivodrwhurl);
86
+  });
87
+
88
+
89
+  $("#generate_twil_rcpt").on("click", function(event) {
90
+
91
+     var twiltokenrec = randomStr(35);
92
+     var twilwhurlrec = window.location.origin + OC.generateUrl('/apps/sms_relentless/api/recsmstwil?twilrecparam=') + twiltokenrec;
93
+
94
+     $("#twilapi_url_rec").val(twilwhurlrec);
95
+  });
96
+
97
+  $("#copyToClipboardtwil").on("click", function(event) {
98
+     var $tempElpl = $("<input>");
99
+     $("body").append($tempElpl);
100
+     $tempElpl.val($("#twilapi_url_rec").val()).select();
101
+     document.execCommand("Copy");
102
+     $tempElpl.remove();
103
+     alert("The link has been copied to your clipboard!");
104
+  });
105
+
106
+  $("#generate_twil_delrcpt").on("click", function(event) {
107
+
108
+     var twiltoken = randomStr(35);
109
+     var twildrwhurl = window.location.origin + OC.generateUrl('/apps/sms_relentless/api/recdeliverytwil?twildrparam=') + twiltoken;
110
+
111
+     $("#twilapi_url").val(twildrwhurl);
112
+  });
113
+
114
+
115
+  $("#generate_flow_rcpt").on("click", function(event) {
116
+
117
+     var flowtokenrec = randomStr(70);
118
+     var flowwhurlrec = window.location.origin + OC.generateUrl('/apps/sms_relentless/api/recsmsflow?flowrecparam=') + flowtokenrec;
119
+
120
+     $("#flowapi_url_rec").val(flowwhurlrec);
121
+  });
122
+
123
+  $("#copyToClipboardflow").on("click", function(event) {
124
+     var $tempElpl = $("<input>");
125
+     $("body").append($tempElpl);
126
+     $tempElpl.val($("#flowapi_url_rec").val()).select();
127
+     document.execCommand("Copy");
128
+     $tempElpl.remove();
129
+     alert("The link has been copied to your clipboard!");
130
+  });
131
+
132
+  $("#generate_flow_delrcpt").on("click", function(event) {
133
+
134
+     var flowtoken = randomStr(70);
135
+     var flowdrwhurl = window.location.origin + OC.generateUrl('/apps/sms_relentless/api/recdeliveryflow?flowdrparam=') + flowtoken;
136
+
137
+     $("#flowapi_url").val(flowdrwhurl);
138
+  });
139
+
140
+
141
+  $("#save_sms_settings").on("click", function(event) {
142
+
143
+    event.preventDefault();
144
+    OC.msg.startAction('#smsr_save_msg', t('sms_relentless', 'Saved'));
145
+
146
+    var baseUrl = OC.generateUrl('/apps/sms_relentless/user/updatesettings');
147
+
148
+    var messagesperpageinit = $("#messagesperpage").val();
149
+    var messagesperpagesec = messagesperpageinit.replace(/[^0-9]/g, '');
150
+
151
+    if (messagesperpagesec != '') {
152
+        var messagesperpageproc = messagesperpagesec;
153
+    } else {
154
+        var messagesperpageproc = 100;
155
+    }
156
+
157
+    var getnotify = 0;
158
+
159
+    if ($("#get_notify").is(':checked')) {
160
+        getnotify = 1;
161
+    }
162
+
163
+    var emailaddressinit = $("#notification_email").val();
164
+
165
+    function validate_email($email) {
166
+        var email_reg = /^([\w-\.]+@([\w-]+\.)+[\w-]{2,4})?$/;
167
+        return email_reg.test($email);
168
+    }
169
+
170
+    if (validate_email(emailaddressinit)) {
171
+         var notifyemail = emailaddressinit;
172
+    } else {
173
+         var notifyemail = '';
174
+    }
175
+
176
+    var telsenderinit = $("#tel_sender_name").val();
177
+    var telsenderproc = telsenderinit.replace(/[^A-Za-z 0-9]/g, '');
178
+
179
+    var nexsenderinit = $("#nex_sender_name").val();
180
+    var nexsenderproc = nexsenderinit.replace(/[^A-Za-z 0-9]/g, '');
181
+
182
+    var twilsenderinit = $("#twil_sender_name").val();
183
+    var twilsenderproc = twilsenderinit.replace(/[^A-Za-z 0-9]/g, '');
184
+
185
+    //  var flowsenderinit = $("#flow_sender_name").val();
186
+    //  var flowsenderproc = flowsenderinit.replace(/[^A-Za-z 0-9]/g, '');
187
+
188
+    var includesmsinemail = 0;
189
+
190
+    if ($("#includesmsinemail").is(':checked')) {
191
+        includesmsinemail = 1;
192
+    }
193
+
194
+    var datatosave = {
195
+                      userId: userid,
196
+                      telapiKey: $("#telapi_key").val(),
197
+                      telPubKey: $("#tel_pub_key").val(),
198
+                      telapiUrlRec: $("#telapi_url_rec").val(),
199
+                      telapiUrl: $("#telapi_url").val(),
200
+                      messagingProfileId: $("#messaging_profile_id").val(),
201
+                      nexapiKey: $("#nexapi_key").val(),
202
+                      nexapiSecret: $("#nexapi_secret").val(),
203
+                      nexapiUrlRec: $("#nexapi_url_rec").val(),
204
+                      nexapiUrl: $("#nexapi_url").val(),
205
+                      twilapiKey: $("#twilapi_key").val(),
206
+                      twilapiSecret: $("#twilapi_secret").val(),
207
+                      twilapiUrlRec: $("#twilapi_url_rec").val(),
208
+                      twilapiUrl: $("#twilapi_url").val(),
209
+                      flowapiKey: $("#flowapi_key").val(),
210
+                      flowapiSecret: $("#flowapi_secret").val(),
211
+                      flowapiUrlRec: $("#flowapi_url_rec").val(),
212
+                      flowapiUrl: $("#flowapi_url").val(),
213
+                      telSenderName: telsenderproc,
214
+                      nexSenderName: nexsenderproc,
215
+                      twilSenderName: twilsenderproc,
216
+                      //  flowSenderName: flowsenderproc,
217
+                      messagesperpage: messagesperpageproc,
218
+                      getNotify: getnotify,
219
+                      notificationEmail: notifyemail,
220
+                      getsmsinemail: includesmsinemail
221
+    };
222
+
223
+
224
+    $.ajax({
225
+       method: 'PUT',
226
+       url: baseUrl + '/' + userid,
227
+       contentType: 'application/json',
228
+       data: JSON.stringify(datatosave),
229
+       error: function(resp) {
230
+            alert('Error ! Please check your settings !');
231
+       }
232
+    });
233
+
234
+  });
235
+
236
+
237
+  var baseUrlget = OC.generateUrl('/apps/sms_relentless/user/getsettings');
238
+
239
+  $.ajax({
240
+     method: 'GET',
241
+     url: baseUrlget + '/' + userid,
242
+     contentType: 'application/json',
243
+     success: function(settingsfromdb) {
244
+         $("#telapi_key").val(settingsfromdb.telapi_key);
245
+         $("#tel_pub_key").val(settingsfromdb.tel_pub_key);
246
+         $("#telapi_url_rec").val(settingsfromdb.telapi_url_rec);
247
+         $("#telapi_url").val(settingsfromdb.telapi_url);
248
+         $("#messaging_profile_id").val(settingsfromdb.messaging_profile_id);
249
+         $("#nexapi_key").val(settingsfromdb.nexapi_key);
250
+         $("#nexapi_secret").val(settingsfromdb.nexapi_secret);
251
+         $("#nexapi_url_rec").val(settingsfromdb.nexapi_url_rec);
252
+         $("#nexapi_url").val(settingsfromdb.nexapi_url);
253
+         $("#twilapi_key").val(settingsfromdb.twilapi_key);
254
+         $("#twilapi_secret").val(settingsfromdb.twilapi_secret);
255
+         $("#twilapi_url_rec").val(settingsfromdb.twilapi_url_rec);
256
+         $("#twilapi_url").val(settingsfromdb.twilapi_url);
257
+         $("#flowapi_key").val(settingsfromdb.flowapi_key);
258
+         $("#flowapi_secret").val(settingsfromdb.flowapi_secret);
259
+         $("#flowapi_url_rec").val(settingsfromdb.flowapi_url_rec);
260
+         $("#flowapi_url").val(settingsfromdb.flowapi_url);
261
+         $("#tel_sender_name").val(settingsfromdb.tel_sender_name);
262
+         $("#nex_sender_name").val(settingsfromdb.nex_sender_name);
263
+         $("#twil_sender_name").val(settingsfromdb.twil_sender_name);
264
+         //  $("#flow_sender_name").val(settingsfromdb.flow_sender_name);
265
+         $("#messagesperpage").val(settingsfromdb.messagesperpage);
266
+
267
+         if (settingsfromdb.get_notify == 1) {
268
+             $("#get_notify").attr('checked', true);
269
+         } else {
270
+             $("#get_notify").attr('checked', false);
271
+         }
272
+
273
+         $("#notification_email").val(settingsfromdb.notification_email);
274
+
275
+         if (settingsfromdb.getsmsinemail == 1) {
276
+             $("#includesmsinemail").attr('checked', true);
277
+         } else {
278
+             $("#includesmsinemail").attr('checked', false);
279
+         }
280
+     }
281
+  });
282
+
283
+});
Browse code

removed CHANGELOG.txt appinfo/info.xml appinfo/signature.json js/settings.js templates/settings.php lib/Controller/AuthorApiController.php lib/Controller/SmsrelentlessController.php lib/Service/SmsrelentlessService.php

DoubleBastionAdmin authored on 08/09/2022 21:52:34
Showing 1 changed files
1 1
deleted file mode 100644
... ...
@@ -1,283 +0,0 @@
1
-/**
2
- * @copyright 2021 Double Bastion LLC <www.doublebastion.com>
3
- *
4
- * @author Double Bastion LLC
5
- *
6
- * @license GNU AGPL version 3 or any later version
7
- *
8
- * This program is free software; you can redistribute it and/or
9
- * modify it under the terms of the GNU AFFERO GENERAL PUBLIC LICENSE
10
- * License as published by the Free Software Foundation; either
11
- * version 3 of the License, or any later version.
12
- *
13
- * This program is distributed in the hope that it will be useful,
14
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
15
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
16
- * GNU AFFERO GENERAL PUBLIC LICENSE for more details.
17
- *
18
- * You should have received a copy of the GNU Affero General Public
19
- * License along with this program.  If not, see <http://www.gnu.org/licenses/>.
20
- *
21
- */
22
-
23
-$(document).ready(function() {
24
-
25
-  var userid = "<?php p($userId); ?>";
26
-  var strlength;
27
-
28
-  function randomStr(strlength) {
29
-        var fintext = "";
30
-        var keyspace = '0123456789abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ';
31
-        for (var i = 0; i < strlength; i++) {
32
-             fintext += keyspace.charAt(Math.floor(Math.random() * keyspace.length));
33
-        }
34
-        return fintext;
35
-  }
36
-
37
-  $("#generate_tel_rcpt").on("click", function(event) {
38
-
39
-     var teltokenrec = randomStr(70);
40
-     var telnyxwhurlrec = window.location.origin + OC.generateUrl('/apps/sms_relentless/api/recsmstel?telrecparam=') + teltokenrec;
41
-
42
-     $("#telapi_url_rec").val(telnyxwhurlrec);
43
-  });
44
-
45
-  $("#copyToClipboardtel").on("click", function(event) {
46
-     var $tempEl = $("<input>");
47
-     $("body").append($tempEl);
48
-     $tempEl.val($("#telapi_url_rec").val()).select();
49
-     document.execCommand("Copy");
50
-     $tempEl.remove();
51
-     alert("The link has been copied to your clipboard!");
52
-  });
53
-
54
-  $("#generate_tel_delrcpt").on("click", function(event) {
55
-
56
-     var teltoken = randomStr(70);
57
-     var telnyxwhurl = window.location.origin + OC.generateUrl('/apps/sms_relentless/api/recdeliverytel?teldrparam=') + teltoken;
58
-
59
-     $("#telapi_url").val(telnyxwhurl);
60
-  });
61
-
62
-
63
-  $("#generate_nex_rcpt").on("click", function(event) {
64
-
65
-     var plivotokenrec = randomStr(70);
66
-     var plivowhurlrec = window.location.origin + OC.generateUrl('/apps/sms_relentless/api/recsmsnex?plivorecparam=') + plivotokenrec;
67
-
68
-     $("#nexapi_url_rec").val(plivowhurlrec);
69
-  });
70
-
71
-  $("#copyToClipboardnex").on("click", function(event) {
72
-     var $tempElpl = $("<input>");
73
-     $("body").append($tempElpl);
74
-     $tempElpl.val($("#nexapi_url_rec").val()).select();
75
-     document.execCommand("Copy");
76
-     $tempElpl.remove();
77
-     alert("The link has been copied to your clipboard!");
78
-  });
79
-
80
-  $("#generate_nex_delrcpt").on("click", function(event) {
81
-
82
-     var plivotoken = randomStr(70);
83
-     var plivodrwhurl = window.location.origin + OC.generateUrl('/apps/sms_relentless/api/recdeliverynex?plivodrparam=') + plivotoken;
84
-
85
-     $("#nexapi_url").val(plivodrwhurl);
86
-  });
87
-
88
-
89
-  $("#generate_twil_rcpt").on("click", function(event) {
90
-
91
-     var twiltokenrec = randomStr(35);
92
-     var twilwhurlrec = window.location.origin + OC.generateUrl('/apps/sms_relentless/api/recsmstwil?twilrecparam=') + twiltokenrec;
93
-
94
-     $("#twilapi_url_rec").val(twilwhurlrec);
95
-  });
96
-
97
-  $("#copyToClipboardtwil").on("click", function(event) {
98
-     var $tempElpl = $("<input>");
99
-     $("body").append($tempElpl);
100
-     $tempElpl.val($("#twilapi_url_rec").val()).select();
101
-     document.execCommand("Copy");
102
-     $tempElpl.remove();
103
-     alert("The link has been copied to your clipboard!");
104
-  });
105
-
106
-  $("#generate_twil_delrcpt").on("click", function(event) {
107
-
108
-     var twiltoken = randomStr(35);
109
-     var twildrwhurl = window.location.origin + OC.generateUrl('/apps/sms_relentless/api/recdeliverytwil?twildrparam=') + twiltoken;
110
-
111
-     $("#twilapi_url").val(twildrwhurl);
112
-  });
113
-
114
-
115
-  $("#generate_flow_rcpt").on("click", function(event) {
116
-
117
-     var flowtokenrec = randomStr(70);
118
-     var flowwhurlrec = window.location.origin + OC.generateUrl('/apps/sms_relentless/api/recsmsflow?flowrecparam=') + flowtokenrec;
119
-
120
-     $("#flowapi_url_rec").val(flowwhurlrec);
121
-  });
122
-
123
-  $("#copyToClipboardflow").on("click", function(event) {
124
-     var $tempElpl = $("<input>");
125
-     $("body").append($tempElpl);
126
-     $tempElpl.val($("#flowapi_url_rec").val()).select();
127
-     document.execCommand("Copy");
128
-     $tempElpl.remove();
129
-     alert("The link has been copied to your clipboard!");
130
-  });
131
-
132
-  $("#generate_flow_delrcpt").on("click", function(event) {
133
-
134
-     var flowtoken = randomStr(70);
135
-     var flowdrwhurl = window.location.origin + OC.generateUrl('/apps/sms_relentless/api/recdeliveryflow?flowdrparam=') + flowtoken;
136
-
137
-     $("#flowapi_url").val(flowdrwhurl);
138
-  });
139
-
140
-
141
-  $("#save_sms_settings").on("click", function(event) {
142
-
143
-    event.preventDefault();
144
-    OC.msg.startAction('#smsr_save_msg', t('sms_relentless', 'Saved'));
145
-
146
-    var baseUrl = OC.generateUrl('/apps/sms_relentless/user/updatesettings');
147
-
148
-    var messagesperpageinit = $("#messagesperpage").val();
149
-    var messagesperpagesec = messagesperpageinit.replace(/[^0-9]/g, '');
150
-
151
-    if (messagesperpagesec != '') {
152
-        var messagesperpageproc = messagesperpagesec;
153
-    } else {
154
-        var messagesperpageproc = 100;
155
-    }
156
-
157
-    var getnotify = 0;
158
-
159
-    if ($("#get_notify").is(':checked')) {
160
-        getnotify = 1;
161
-    }
162
-
163
-    var emailaddressinit = $("#notification_email").val();
164
-
165
-    function validate_email($email) {
166
-        var email_reg = /^([\w-\.]+@([\w-]+\.)+[\w-]{2,4})?$/;
167
-        return email_reg.test($email);
168
-    }
169
-
170
-    if (validate_email(emailaddressinit)) {
171
-         var notifyemail = emailaddressinit;
172
-    } else {
173
-         var notifyemail = '';
174
-    }
175
-
176
-    var telsenderinit = $("#tel_sender_name").val();
177
-    var telsenderproc = telsenderinit.replace(/[^A-Za-z 0-9]/g, '');
178
-
179
-    var nexsenderinit = $("#nex_sender_name").val();
180
-    var nexsenderproc = nexsenderinit.replace(/[^A-Za-z 0-9]/g, '');
181
-
182
-    var twilsenderinit = $("#twil_sender_name").val();
183
-    var twilsenderproc = twilsenderinit.replace(/[^A-Za-z 0-9]/g, '');
184
-
185
-    var flowsenderinit = $("#flow_sender_name").val();
186
-    var flowsenderproc = flowsenderinit.replace(/[^A-Za-z 0-9]/g, '');
187
-
188
-    var includesmsinemail = 0;
189
-
190
-    if ($("#includesmsinemail").is(':checked')) {
191
-        includesmsinemail = 1;
192
-    }
193
-
194
-    var datatosave = {
195
-                      userId: userid,
196
-                      telapiKey: $("#telapi_key").val(),
197
-                      telPubKey: $("#tel_pub_key").val(),
198
-                      telapiUrlRec: $("#telapi_url_rec").val(),
199
-                      telapiUrl: $("#telapi_url").val(),
200
-                      messagingProfileId: $("#messaging_profile_id").val(),
201
-                      nexapiKey: $("#nexapi_key").val(),
202
-                      nexapiSecret: $("#nexapi_secret").val(),
203
-                      nexapiUrlRec: $("#nexapi_url_rec").val(),
204
-                      nexapiUrl: $("#nexapi_url").val(),
205
-                      twilapiKey: $("#twilapi_key").val(),
206
-                      twilapiSecret: $("#twilapi_secret").val(),
207
-                      twilapiUrlRec: $("#twilapi_url_rec").val(),
208
-                      twilapiUrl: $("#twilapi_url").val(),
209
-                      flowapiKey: $("#flowapi_key").val(),
210
-                      flowapiSecret: $("#flowapi_secret").val(),
211
-                      flowapiUrlRec: $("#flowapi_url_rec").val(),
212
-                      flowapiUrl: $("#flowapi_url").val(),
213
-                      telSenderName: telsenderproc,
214
-                      nexSenderName: nexsenderproc,
215
-                      twilSenderName: twilsenderproc,
216
-                      flowSenderName: flowsenderproc,
217
-                      messagesperpage: messagesperpageproc,
218
-                      getNotify: getnotify,
219
-                      notificationEmail: notifyemail,
220
-                      getsmsinemail: includesmsinemail
221
-    };
222
-
223
-
224
-    $.ajax({
225
-       method: 'PUT',
226
-       url: baseUrl + '/' + userid,
227
-       contentType: 'application/json',
228
-       data: JSON.stringify(datatosave),
229
-       error: function(resp) {
230
-            alert('Error ! Please check your settings !');
231
-       }
232
-    });
233
-
234
-  });
235
-
236
-
237
-  var baseUrlget = OC.generateUrl('/apps/sms_relentless/user/getsettings');
238
-
239
-  $.ajax({
240
-     method: 'GET',
241
-     url: baseUrlget + '/' + userid,
242
-     contentType: 'application/json',
243
-     success: function(settingsfromdb) {
244
-         $("#telapi_key").val(settingsfromdb.telapi_key);
245
-         $("#tel_pub_key").val(settingsfromdb.tel_pub_key);
246
-         $("#telapi_url_rec").val(settingsfromdb.telapi_url_rec);
247
-         $("#telapi_url").val(settingsfromdb.telapi_url);
248
-         $("#messaging_profile_id").val(settingsfromdb.messaging_profile_id);
249
-         $("#nexapi_key").val(settingsfromdb.nexapi_key);
250
-         $("#nexapi_secret").val(settingsfromdb.nexapi_secret);
251
-         $("#nexapi_url_rec").val(settingsfromdb.nexapi_url_rec);
252
-         $("#nexapi_url").val(settingsfromdb.nexapi_url);
253
-         $("#twilapi_key").val(settingsfromdb.twilapi_key);
254
-         $("#twilapi_secret").val(settingsfromdb.twilapi_secret);
255
-         $("#twilapi_url_rec").val(settingsfromdb.twilapi_url_rec);
256
-         $("#twilapi_url").val(settingsfromdb.twilapi_url);
257
-         $("#flowapi_key").val(settingsfromdb.flowapi_key);
258
-         $("#flowapi_secret").val(settingsfromdb.flowapi_secret);
259
-         $("#flowapi_url_rec").val(settingsfromdb.flowapi_url_rec);
260
-         $("#flowapi_url").val(settingsfromdb.flowapi_url);
261
-         $("#tel_sender_name").val(settingsfromdb.tel_sender_name);
262
-         $("#nex_sender_name").val(settingsfromdb.nex_sender_name);
263
-         $("#twil_sender_name").val(settingsfromdb.twil_sender_name);
264
-         $("#flow_sender_name").val(settingsfromdb.flow_sender_name);
265
-         $("#messagesperpage").val(settingsfromdb.messagesperpage);
266
-
267
-         if (settingsfromdb.get_notify == 1) {
268
-             $("#get_notify").attr('checked', true);
269
-         } else {
270
-             $("#get_notify").attr('checked', false);
271
-         }
272
-
273
-         $("#notification_email").val(settingsfromdb.notification_email);
274
-
275
-         if (settingsfromdb.getsmsinemail == 1) {
276
-             $("#includesmsinemail").attr('checked', true);
277
-         } else {
278
-             $("#includesmsinemail").attr('checked', false);
279
-         }
280
-     }
281
-  });
282
-
283
-});
Browse code

added README.md CHANGELOG.txt appinfo/info.xml appinfo/routes.php appinfo/signature.json css/style.css js/settings.js js/sendsms.js js/showsmstables.js lib/Controller/AuthorApiController.php lib/Controller/SmsrelentlessController.php templates/navigation/index.php templates/content/index.php templates/settings.php js/tiff.min.js img/nextcloud_logo.svg img/nextcloud_logo_bright.svg img/sms_relentless_mms_sending.png

DoubleBastionAdmin authored on 02/09/2022 23:19:37
Showing 1 changed files
1 1
new file mode 100644
... ...
@@ -0,0 +1,283 @@
1
+/**
2
+ * @copyright 2021 Double Bastion LLC <www.doublebastion.com>
3
+ *
4
+ * @author Double Bastion LLC
5
+ *
6
+ * @license GNU AGPL version 3 or any later version
7
+ *
8
+ * This program is free software; you can redistribute it and/or
9
+ * modify it under the terms of the GNU AFFERO GENERAL PUBLIC LICENSE
10
+ * License as published by the Free Software Foundation; either
11
+ * version 3 of the License, or any later version.
12
+ *
13
+ * This program is distributed in the hope that it will be useful,
14
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
15
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
16
+ * GNU AFFERO GENERAL PUBLIC LICENSE for more details.
17
+ *
18
+ * You should have received a copy of the GNU Affero General Public
19
+ * License along with this program.  If not, see <http://www.gnu.org/licenses/>.
20
+ *
21
+ */
22
+
23
+$(document).ready(function() {
24
+
25
+  var userid = "<?php p($userId); ?>";
26
+  var strlength;
27
+
28
+  function randomStr(strlength) {
29
+        var fintext = "";
30
+        var keyspace = '0123456789abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ';
31
+        for (var i = 0; i < strlength; i++) {
32
+             fintext += keyspace.charAt(Math.floor(Math.random() * keyspace.length));
33
+        }
34
+        return fintext;
35
+  }
36
+
37
+  $("#generate_tel_rcpt").on("click", function(event) {
38
+
39
+     var teltokenrec = randomStr(70);
40
+     var telnyxwhurlrec = window.location.origin + OC.generateUrl('/apps/sms_relentless/api/recsmstel?telrecparam=') + teltokenrec;
41
+
42
+     $("#telapi_url_rec").val(telnyxwhurlrec);
43
+  });
44
+
45
+  $("#copyToClipboardtel").on("click", function(event) {
46
+     var $tempEl = $("<input>");
47
+     $("body").append($tempEl);
48
+     $tempEl.val($("#telapi_url_rec").val()).select();
49
+     document.execCommand("Copy");
50
+     $tempEl.remove();
51
+     alert("The link has been copied to your clipboard!");
52
+  });
53
+
54
+  $("#generate_tel_delrcpt").on("click", function(event) {
55
+
56
+     var teltoken = randomStr(70);
57
+     var telnyxwhurl = window.location.origin + OC.generateUrl('/apps/sms_relentless/api/recdeliverytel?teldrparam=') + teltoken;
58
+
59
+     $("#telapi_url").val(telnyxwhurl);
60
+  });
61
+
62
+
63
+  $("#generate_nex_rcpt").on("click", function(event) {
64
+
65
+     var plivotokenrec = randomStr(70);
66
+     var plivowhurlrec = window.location.origin + OC.generateUrl('/apps/sms_relentless/api/recsmsnex?plivorecparam=') + plivotokenrec;
67
+
68
+     $("#nexapi_url_rec").val(plivowhurlrec);
69
+  });
70
+
71
+  $("#copyToClipboardnex").on("click", function(event) {
72
+     var $tempElpl = $("<input>");
73
+     $("body").append($tempElpl);
74
+     $tempElpl.val($("#nexapi_url_rec").val()).select();
75
+     document.execCommand("Copy");
76
+     $tempElpl.remove();
77
+     alert("The link has been copied to your clipboard!");
78
+  });
79
+
80
+  $("#generate_nex_delrcpt").on("click", function(event) {
81
+
82
+     var plivotoken = randomStr(70);
83
+     var plivodrwhurl = window.location.origin + OC.generateUrl('/apps/sms_relentless/api/recdeliverynex?plivodrparam=') + plivotoken;
84
+
85
+     $("#nexapi_url").val(plivodrwhurl);
86
+  });
87
+
88
+
89
+  $("#generate_twil_rcpt").on("click", function(event) {
90
+
91
+     var twiltokenrec = randomStr(35);
92
+     var twilwhurlrec = window.location.origin + OC.generateUrl('/apps/sms_relentless/api/recsmstwil?twilrecparam=') + twiltokenrec;
93
+
94
+     $("#twilapi_url_rec").val(twilwhurlrec);
95
+  });
96
+
97
+  $("#copyToClipboardtwil").on("click", function(event) {
98
+     var $tempElpl = $("<input>");
99
+     $("body").append($tempElpl);
100
+     $tempElpl.val($("#twilapi_url_rec").val()).select();
101
+     document.execCommand("Copy");
102
+     $tempElpl.remove();
103
+     alert("The link has been copied to your clipboard!");
104
+  });
105
+
106
+  $("#generate_twil_delrcpt").on("click", function(event) {
107
+
108
+     var twiltoken = randomStr(35);
109
+     var twildrwhurl = window.location.origin + OC.generateUrl('/apps/sms_relentless/api/recdeliverytwil?twildrparam=') + twiltoken;
110
+
111
+     $("#twilapi_url").val(twildrwhurl);
112
+  });
113
+
114
+
115
+  $("#generate_flow_rcpt").on("click", function(event) {
116
+
117
+     var flowtokenrec = randomStr(70);
118
+     var flowwhurlrec = window.location.origin + OC.generateUrl('/apps/sms_relentless/api/recsmsflow?flowrecparam=') + flowtokenrec;
119
+
120
+     $("#flowapi_url_rec").val(flowwhurlrec);
121
+  });
122
+
123
+  $("#copyToClipboardflow").on("click", function(event) {
124
+     var $tempElpl = $("<input>");
125
+     $("body").append($tempElpl);
126
+     $tempElpl.val($("#flowapi_url_rec").val()).select();
127
+     document.execCommand("Copy");
128
+     $tempElpl.remove();
129
+     alert("The link has been copied to your clipboard!");
130
+  });
131
+
132
+  $("#generate_flow_delrcpt").on("click", function(event) {
133
+
134
+     var flowtoken = randomStr(70);
135
+     var flowdrwhurl = window.location.origin + OC.generateUrl('/apps/sms_relentless/api/recdeliveryflow?flowdrparam=') + flowtoken;
136
+
137
+     $("#flowapi_url").val(flowdrwhurl);
138
+  });
139
+
140
+
141
+  $("#save_sms_settings").on("click", function(event) {
142
+
143
+    event.preventDefault();
144
+    OC.msg.startAction('#smsr_save_msg', t('sms_relentless', 'Saved'));
145
+
146
+    var baseUrl = OC.generateUrl('/apps/sms_relentless/user/updatesettings');
147
+
148
+    var messagesperpageinit = $("#messagesperpage").val();
149
+    var messagesperpagesec = messagesperpageinit.replace(/[^0-9]/g, '');
150
+
151
+    if (messagesperpagesec != '') {
152
+        var messagesperpageproc = messagesperpagesec;
153
+    } else {
154
+        var messagesperpageproc = 100;
155
+    }
156
+
157
+    var getnotify = 0;
158
+
159
+    if ($("#get_notify").is(':checked')) {
160
+        getnotify = 1;
161
+    }
162
+
163
+    var emailaddressinit = $("#notification_email").val();
164
+
165
+    function validate_email($email) {
166
+        var email_reg = /^([\w-\.]+@([\w-]+\.)+[\w-]{2,4})?$/;
167
+        return email_reg.test($email);
168
+    }
169
+
170
+    if (validate_email(emailaddressinit)) {
171
+         var notifyemail = emailaddressinit;
172
+    } else {
173
+         var notifyemail = '';
174
+    }
175
+
176
+    var telsenderinit = $("#tel_sender_name").val();
177
+    var telsenderproc = telsenderinit.replace(/[^A-Za-z 0-9]/g, '');
178
+
179
+    var nexsenderinit = $("#nex_sender_name").val();
180
+    var nexsenderproc = nexsenderinit.replace(/[^A-Za-z 0-9]/g, '');
181
+
182
+    var twilsenderinit = $("#twil_sender_name").val();
183
+    var twilsenderproc = twilsenderinit.replace(/[^A-Za-z 0-9]/g, '');
184
+
185
+    var flowsenderinit = $("#flow_sender_name").val();
186
+    var flowsenderproc = flowsenderinit.replace(/[^A-Za-z 0-9]/g, '');
187
+
188
+    var includesmsinemail = 0;
189
+
190
+    if ($("#includesmsinemail").is(':checked')) {
191
+        includesmsinemail = 1;
192
+    }
193
+
194
+    var datatosave = {
195
+                      userId: userid,
196
+                      telapiKey: $("#telapi_key").val(),
197
+                      telPubKey: $("#tel_pub_key").val(),
198
+                      telapiUrlRec: $("#telapi_url_rec").val(),
199
+                      telapiUrl: $("#telapi_url").val(),
200
+                      messagingProfileId: $("#messaging_profile_id").val(),
201
+                      nexapiKey: $("#nexapi_key").val(),
202
+                      nexapiSecret: $("#nexapi_secret").val(),
203
+                      nexapiUrlRec: $("#nexapi_url_rec").val(),
204
+                      nexapiUrl: $("#nexapi_url").val(),
205
+                      twilapiKey: $("#twilapi_key").val(),
206
+                      twilapiSecret: $("#twilapi_secret").val(),
207
+                      twilapiUrlRec: $("#twilapi_url_rec").val(),
208
+                      twilapiUrl: $("#twilapi_url").val(),
209
+                      flowapiKey: $("#flowapi_key").val(),
210
+                      flowapiSecret: $("#flowapi_secret").val(),
211
+                      flowapiUrlRec: $("#flowapi_url_rec").val(),
212
+                      flowapiUrl: $("#flowapi_url").val(),
213
+                      telSenderName: telsenderproc,
214
+                      nexSenderName: nexsenderproc,
215
+                      twilSenderName: twilsenderproc,
216
+                      flowSenderName: flowsenderproc,
217
+                      messagesperpage: messagesperpageproc,
218
+                      getNotify: getnotify,
219
+                      notificationEmail: notifyemail,
220
+                      getsmsinemail: includesmsinemail
221
+    };
222
+
223
+
224
+    $.ajax({
225
+       method: 'PUT',
226
+       url: baseUrl + '/' + userid,
227
+       contentType: 'application/json',
228
+       data: JSON.stringify(datatosave),
229
+       error: function(resp) {
230
+            alert('Error ! Please check your settings !');
231
+       }
232
+    });
233
+
234
+  });
235
+
236
+
237
+  var baseUrlget = OC.generateUrl('/apps/sms_relentless/user/getsettings');
238
+
239
+  $.ajax({
240
+     method: 'GET',
241
+     url: baseUrlget + '/' + userid,
242
+     contentType: 'application/json',
243
+     success: function(settingsfromdb) {
244
+         $("#telapi_key").val(settingsfromdb.telapi_key);
245
+         $("#tel_pub_key").val(settingsfromdb.tel_pub_key);
246
+         $("#telapi_url_rec").val(settingsfromdb.telapi_url_rec);
247
+         $("#telapi_url").val(settingsfromdb.telapi_url);
248
+         $("#messaging_profile_id").val(settingsfromdb.messaging_profile_id);
249
+         $("#nexapi_key").val(settingsfromdb.nexapi_key);
250
+         $("#nexapi_secret").val(settingsfromdb.nexapi_secret);
251
+         $("#nexapi_url_rec").val(settingsfromdb.nexapi_url_rec);
252
+         $("#nexapi_url").val(settingsfromdb.nexapi_url);
253
+         $("#twilapi_key").val(settingsfromdb.twilapi_key);
254
+         $("#twilapi_secret").val(settingsfromdb.twilapi_secret);
255
+         $("#twilapi_url_rec").val(settingsfromdb.twilapi_url_rec);
256
+         $("#twilapi_url").val(settingsfromdb.twilapi_url);
257
+         $("#flowapi_key").val(settingsfromdb.flowapi_key);
258
+         $("#flowapi_secret").val(settingsfromdb.flowapi_secret);
259
+         $("#flowapi_url_rec").val(settingsfromdb.flowapi_url_rec);
260
+         $("#flowapi_url").val(settingsfromdb.flowapi_url);
261
+         $("#tel_sender_name").val(settingsfromdb.tel_sender_name);
262
+         $("#nex_sender_name").val(settingsfromdb.nex_sender_name);
263
+         $("#twil_sender_name").val(settingsfromdb.twil_sender_name);
264
+         $("#flow_sender_name").val(settingsfromdb.flow_sender_name);
265
+         $("#messagesperpage").val(settingsfromdb.messagesperpage);
266
+
267
+         if (settingsfromdb.get_notify == 1) {
268
+             $("#get_notify").attr('checked', true);
269
+         } else {
270
+             $("#get_notify").attr('checked', false);
271
+         }
272
+
273
+         $("#notification_email").val(settingsfromdb.notification_email);
274
+
275
+         if (settingsfromdb.getsmsinemail == 1) {
276
+             $("#includesmsinemail").attr('checked', true);
277
+         } else {
278
+             $("#includesmsinemail").attr('checked', false);
279
+         }
280
+     }
281
+  });
282
+
283
+});
Browse code

removed README.md CHANGELOG.txt appinfo/info.xml appinfo/routes.php appinfo/signature.json css/style.css js/settings.js js/sendsms.js js/showsmstables.js lib/Controller/AuthorApiController.php lib/Controller/SmsrelentlessController.php templates/navigation/index.php templates/content/index.php templates/settings.php

DoubleBastionAdmin authored on 02/09/2022 23:09:46
Showing 1 changed files
1 1
deleted file mode 100644
... ...
@@ -1,283 +0,0 @@
1
-/**
2
- * @copyright 2021 Double Bastion LLC <www.doublebastion.com>
3
- *
4
- * @author Double Bastion LLC
5
- *
6
- * @license GNU AGPL version 3 or any later version
7
- *
8
- * This program is free software; you can redistribute it and/or
9
- * modify it under the terms of the GNU AFFERO GENERAL PUBLIC LICENSE
10
- * License as published by the Free Software Foundation; either
11
- * version 3 of the License, or any later version.
12
- *
13
- * This program is distributed in the hope that it will be useful,
14
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
15
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
16
- * GNU AFFERO GENERAL PUBLIC LICENSE for more details.
17
- *
18
- * You should have received a copy of the GNU Affero General Public
19
- * License along with this program.  If not, see <http://www.gnu.org/licenses/>.
20
- *
21
- */
22
-
23
-$(document).ready(function() {
24
-
25
-  var userid = "<?php p($userId); ?>";
26
-  var strlength;
27
-
28
-  function randomStr(strlength) {
29
-        var fintext = "";
30
-        var keyspace = '0123456789abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ';
31
-        for (var i = 0; i < strlength; i++) {
32
-             fintext += keyspace.charAt(Math.floor(Math.random() * keyspace.length));
33
-        }
34
-        return fintext;
35
-  }
36
-
37
-  $("#generate_tel_rcpt").on("click", function(event) {
38
-
39
-     var teltokenrec = randomStr(70);
40
-     var telnyxwhurlrec = window.location.origin + OC.generateUrl('/apps/sms_relentless/api/recsmstel?telrecparam=') + teltokenrec;
41
-
42
-     $("#telapi_url_rec").val(telnyxwhurlrec);
43
-  });
44
-
45
-  $("#copyToClipboardtel").on("click", function(event) {
46
-     var $tempEl = $("<input>");
47
-     $("body").append($tempEl);
48
-     $tempEl.val($("#telapi_url_rec").val()).select();
49
-     document.execCommand("Copy");
50
-     $tempEl.remove();
51
-     alert("The link has been copied to your clipboard!");
52
-  });
53
-
54
-  $("#generate_tel_delrcpt").on("click", function(event) {
55
-
56
-     var teltoken = randomStr(70);
57
-     var telnyxwhurl = window.location.origin + OC.generateUrl('/apps/sms_relentless/api/recdeliverytel?teldrparam=') + teltoken;
58
-
59
-     $("#telapi_url").val(telnyxwhurl);
60
-  });
61
-
62
-
63
-  $("#generate_nex_rcpt").on("click", function(event) {
64
-
65
-     var plivotokenrec = randomStr(70);
66
-     var plivowhurlrec = window.location.origin + OC.generateUrl('/apps/sms_relentless/api/recsmsnex?plivorecparam=') + plivotokenrec;
67
-
68
-     $("#nexapi_url_rec").val(plivowhurlrec);
69
-  });
70
-
71
-  $("#copyToClipboardnex").on("click", function(event) {
72
-     var $tempElpl = $("<input>");
73
-     $("body").append($tempElpl);
74
-     $tempElpl.val($("#nexapi_url_rec").val()).select();
75
-     document.execCommand("Copy");
76
-     $tempElpl.remove();
77
-     alert("The link has been copied to your clipboard!");
78
-  });
79
-
80
-  $("#generate_nex_delrcpt").on("click", function(event) {
81
-
82
-     var plivotoken = randomStr(70);
83
-     var plivodrwhurl = window.location.origin + OC.generateUrl('/apps/sms_relentless/api/recdeliverynex?plivodrparam=') + plivotoken;
84
-
85
-     $("#nexapi_url").val(plivodrwhurl);
86
-  });
87
-
88
-
89
-  $("#generate_twil_rcpt").on("click", function(event) {
90
-
91
-     var twiltokenrec = randomStr(35);
92
-     var twilwhurlrec = window.location.origin + OC.generateUrl('/apps/sms_relentless/api/recsmstwil?twilrecparam=') + twiltokenrec;
93
-
94
-     $("#twilapi_url_rec").val(twilwhurlrec);
95
-  });
96
-
97
-  $("#copyToClipboardtwil").on("click", function(event) {
98
-     var $tempElpl = $("<input>");
99
-     $("body").append($tempElpl);
100
-     $tempElpl.val($("#twilapi_url_rec").val()).select();
101
-     document.execCommand("Copy");
102
-     $tempElpl.remove();
103
-     alert("The link has been copied to your clipboard!");
104
-  });
105
-
106
-  $("#generate_twil_delrcpt").on("click", function(event) {
107
-
108
-     var twiltoken = randomStr(35);
109
-     var twildrwhurl = window.location.origin + OC.generateUrl('/apps/sms_relentless/api/recdeliverytwil?twildrparam=') + twiltoken;
110
-
111
-     $("#twilapi_url").val(twildrwhurl);
112
-  });
113
-
114
-
115
-  $("#generate_flow_rcpt").on("click", function(event) {
116
-
117
-     var flowtokenrec = randomStr(70);
118
-     var flowwhurlrec = window.location.origin + OC.generateUrl('/apps/sms_relentless/api/recsmsflow?flowrecparam=') + flowtokenrec;
119
-
120
-     $("#flowapi_url_rec").val(flowwhurlrec);
121
-  });
122
-
123
-  $("#copyToClipboardflow").on("click", function(event) {
124
-     var $tempElpl = $("<input>");
125
-     $("body").append($tempElpl);
126
-     $tempElpl.val($("#flowapi_url_rec").val()).select();
127
-     document.execCommand("Copy");
128
-     $tempElpl.remove();
129
-     alert("The link has been copied to your clipboard!");
130
-  });
131
-
132
-  $("#generate_flow_delrcpt").on("click", function(event) {
133
-
134
-     var flowtoken = randomStr(70);
135
-     var flowdrwhurl = window.location.origin + OC.generateUrl('/apps/sms_relentless/api/recdeliveryflow?flowdrparam=') + flowtoken;
136
-
137
-     $("#flowapi_url").val(flowdrwhurl);
138
-  });
139
-
140
-
141
-  $("#save_sms_settings").on("click", function(event) {
142
-
143
-    event.preventDefault();
144
-    OC.msg.startAction('#smsr_save_msg', t('sms_relentless', 'Saved'));
145
-
146
-    var baseUrl = OC.generateUrl('/apps/sms_relentless/user/updatesettings');
147
-
148
-    var messagesperpageinit = $("#messagesperpage").val();
149
-    var messagesperpagesec = messagesperpageinit.replace(/[^0-9]/g, '');
150
-
151
-    if (messagesperpagesec != '') {
152
-        var messagesperpageproc = messagesperpagesec;
153
-    } else {
154
-        var messagesperpageproc = 100;
155
-    }
156
-
157
-    var getnotify = 0;
158
-
159
-    if ($("#get_notify").is(':checked')) {
160
-        getnotify = 1;
161
-    }
162
-
163
-    var emailaddressinit = $("#notification_email").val();
164
-
165
-    function validate_email($email) {
166
-        var email_reg = /^([\w-\.]+@([\w-]+\.)+[\w-]{2,4})?$/;
167
-        return email_reg.test($email);
168
-    }
169
-
170
-    if (validate_email(emailaddressinit)) {
171
-         var notifyemail = emailaddressinit;
172
-    } else {
173
-         var notifyemail = '';
174
-    }
175
-
176
-    var telsenderinit = $("#tel_sender_name").val();
177
-    var telsenderproc = telsenderinit.replace(/[^A-Za-z 0-9]/g, '');
178
-
179
-    var nexsenderinit = $("#nex_sender_name").val();
180
-    var nexsenderproc = nexsenderinit.replace(/[^A-Za-z 0-9]/g, '');
181
-
182
-    var twilsenderinit = $("#twil_sender_name").val();
183
-    var twilsenderproc = twilsenderinit.replace(/[^A-Za-z 0-9]/g, '');
184
-
185
-    var flowsenderinit = $("#flow_sender_name").val();
186
-    var flowsenderproc = flowsenderinit.replace(/[^A-Za-z 0-9]/g, '');
187
-
188
-    var includesmsinemail = 0;
189
-
190
-    if ($("#includesmsinemail").is(':checked')) {
191
-        includesmsinemail = 1;
192
-    }
193
-
194
-    var datatosave = {
195
-                      userId: userid,
196
-                      telapiKey: $("#telapi_key").val(),
197
-                      telPubKey: $("#tel_pub_key").val(),
198
-                      telapiUrlRec: $("#telapi_url_rec").val(),
199
-                      telapiUrl: $("#telapi_url").val(),
200
-                      messagingProfileId: $("#messaging_profile_id").val(),
201
-                      nexapiKey: $("#nexapi_key").val(),
202
-                      nexapiSecret: $("#nexapi_secret").val(),
203
-                      nexapiUrlRec: $("#nexapi_url_rec").val(),
204
-                      nexapiUrl: $("#nexapi_url").val(),
205
-                      twilapiKey: $("#twilapi_key").val(),
206
-                      twilapiSecret: $("#twilapi_secret").val(),
207
-                      twilapiUrlRec: $("#twilapi_url_rec").val(),
208
-                      twilapiUrl: $("#twilapi_url").val(),
209
-                      flowapiKey: $("#flowapi_key").val(),
210
-                      flowapiSecret: $("#flowapi_secret").val(),
211
-                      flowapiUrlRec: $("#flowapi_url_rec").val(),
212
-                      flowapiUrl: $("#flowapi_url").val(),
213
-                      telSenderName: telsenderproc,
214
-                      nexSenderName: nexsenderproc,
215
-                      twilSenderName: twilsenderproc,
216
-                      flowSenderName: flowsenderproc,
217
-                      messagesperpage: messagesperpageproc,
218
-                      getNotify: getnotify,
219
-                      notificationEmail: notifyemail,
220
-                      getsmsinemail: includesmsinemail
221
-    };
222
-
223
-
224
-    $.ajax({
225
-       method: 'PUT',
226
-       url: baseUrl + '/' + userid,
227
-       contentType: 'application/json',
228
-       data: JSON.stringify(datatosave),
229
-       error: function(resp) {
230
-            alert('Error ! Please check your settings !');
231
-       }
232
-    });
233
-
234
-  });
235
-
236
-
237
-  var baseUrlget = OC.generateUrl('/apps/sms_relentless/user/getsettings');
238
-
239
-  $.ajax({
240
-     method: 'GET',
241
-     url: baseUrlget + '/' + userid,
242
-     contentType: 'application/json',
243
-     success: function(settingsfromdb) {
244
-         $("#telapi_key").val(settingsfromdb.telapi_key);
245
-         $("#tel_pub_key").val(settingsfromdb.tel_pub_key);
246
-         $("#telapi_url_rec").val(settingsfromdb.telapi_url_rec);
247
-         $("#telapi_url").val(settingsfromdb.telapi_url);
248
-         $("#messaging_profile_id").val(settingsfromdb.messaging_profile_id);
249
-         $("#nexapi_key").val(settingsfromdb.nexapi_key);
250
-         $("#nexapi_secret").val(settingsfromdb.nexapi_secret);
251
-         $("#nexapi_url_rec").val(settingsfromdb.nexapi_url_rec);
252
-         $("#nexapi_url").val(settingsfromdb.nexapi_url);
253
-         $("#twilapi_key").val(settingsfromdb.twilapi_key);
254
-         $("#twilapi_secret").val(settingsfromdb.twilapi_secret);
255
-         $("#twilapi_url_rec").val(settingsfromdb.twilapi_url_rec);
256
-         $("#twilapi_url").val(settingsfromdb.twilapi_url);
257
-         $("#flowapi_key").val(settingsfromdb.flowapi_key);
258
-         $("#flowapi_secret").val(settingsfromdb.flowapi_secret);
259
-         $("#flowapi_url_rec").val(settingsfromdb.flowapi_url_rec);
260
-         $("#flowapi_url").val(settingsfromdb.flowapi_url);
261
-         $("#tel_sender_name").val(settingsfromdb.tel_sender_name);
262
-         $("#nex_sender_name").val(settingsfromdb.nex_sender_name);
263
-         $("#twil_sender_name").val(settingsfromdb.twil_sender_name);
264
-         $("#flow_sender_name").val(settingsfromdb.flow_sender_name);
265
-         $("#messagesperpage").val(settingsfromdb.messagesperpage);
266
-
267
-         if (settingsfromdb.get_notify == 1) {
268
-             $("#get_notify").attr('checked', true);
269
-         } else {
270
-             $("#get_notify").attr('checked', false);
271
-         }
272
-
273
-         $("#notification_email").val(settingsfromdb.notification_email);
274
-
275
-         if (settingsfromdb.getsmsinemail == 1) {
276
-             $("#includesmsinemail").attr('checked', true);
277
-         } else {
278
-             $("#includesmsinemail").attr('checked', false);
279
-         }
280
-     }
281
-  });
282
-
283
-});
Browse code

added README.md CHANGELOG.txt appinfo/info.xml appinfo/signature.json js/settings.js lib/AppInfo/Application.php lib/Controller/SmsrelentlessController.php lib/Controller/AuthorApiController.php lib/Migration/Version108Date20220823132408.php providers/Twilio

DoubleBastionAdmin authored on 23/08/2022 10:48:04
Showing 1 changed files
1 1
new file mode 100644
... ...
@@ -0,0 +1,283 @@
1
+/**
2
+ * @copyright 2021 Double Bastion LLC <www.doublebastion.com>
3
+ *
4
+ * @author Double Bastion LLC
5
+ *
6
+ * @license GNU AGPL version 3 or any later version
7
+ *
8
+ * This program is free software; you can redistribute it and/or
9
+ * modify it under the terms of the GNU AFFERO GENERAL PUBLIC LICENSE
10
+ * License as published by the Free Software Foundation; either
11
+ * version 3 of the License, or any later version.
12
+ *
13
+ * This program is distributed in the hope that it will be useful,
14
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
15
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
16
+ * GNU AFFERO GENERAL PUBLIC LICENSE for more details.
17
+ *
18
+ * You should have received a copy of the GNU Affero General Public
19
+ * License along with this program.  If not, see <http://www.gnu.org/licenses/>.
20
+ *
21
+ */
22
+
23
+$(document).ready(function() {
24
+
25
+  var userid = "<?php p($userId); ?>";
26
+  var strlength;
27
+
28
+  function randomStr(strlength) {
29
+        var fintext = "";
30
+        var keyspace = '0123456789abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ';
31
+        for (var i = 0; i < strlength; i++) {
32
+             fintext += keyspace.charAt(Math.floor(Math.random() * keyspace.length));
33
+        }
34
+        return fintext;
35
+  }
36
+
37
+  $("#generate_tel_rcpt").on("click", function(event) {
38
+
39
+     var teltokenrec = randomStr(70);
40
+     var telnyxwhurlrec = window.location.origin + OC.generateUrl('/apps/sms_relentless/api/recsmstel?telrecparam=') + teltokenrec;
41
+
42
+     $("#telapi_url_rec").val(telnyxwhurlrec);
43
+  });
44
+
45
+  $("#copyToClipboardtel").on("click", function(event) {
46
+     var $tempEl = $("<input>");
47
+     $("body").append($tempEl);
48
+     $tempEl.val($("#telapi_url_rec").val()).select();
49
+     document.execCommand("Copy");
50
+     $tempEl.remove();
51
+     alert("The link has been copied to your clipboard!");
52
+  });
53
+
54
+  $("#generate_tel_delrcpt").on("click", function(event) {
55
+
56
+     var teltoken = randomStr(70);
57
+     var telnyxwhurl = window.location.origin + OC.generateUrl('/apps/sms_relentless/api/recdeliverytel?teldrparam=') + teltoken;
58
+
59
+     $("#telapi_url").val(telnyxwhurl);
60
+  });
61
+
62
+
63
+  $("#generate_nex_rcpt").on("click", function(event) {
64
+
65
+     var plivotokenrec = randomStr(70);
66
+     var plivowhurlrec = window.location.origin + OC.generateUrl('/apps/sms_relentless/api/recsmsnex?plivorecparam=') + plivotokenrec;
67
+
68
+     $("#nexapi_url_rec").val(plivowhurlrec);
69
+  });
70
+
71
+  $("#copyToClipboardnex").on("click", function(event) {
72
+     var $tempElpl = $("<input>");
73
+     $("body").append($tempElpl);
74
+     $tempElpl.val($("#nexapi_url_rec").val()).select();
75
+     document.execCommand("Copy");
76
+     $tempElpl.remove();
77
+     alert("The link has been copied to your clipboard!");
78
+  });
79
+
80
+  $("#generate_nex_delrcpt").on("click", function(event) {
81
+
82
+     var plivotoken = randomStr(70);
83
+     var plivodrwhurl = window.location.origin + OC.generateUrl('/apps/sms_relentless/api/recdeliverynex?plivodrparam=') + plivotoken;
84
+
85
+     $("#nexapi_url").val(plivodrwhurl);
86
+  });
87
+
88
+
89
+  $("#generate_twil_rcpt").on("click", function(event) {
90
+
91
+     var twiltokenrec = randomStr(35);
92
+     var twilwhurlrec = window.location.origin + OC.generateUrl('/apps/sms_relentless/api/recsmstwil?twilrecparam=') + twiltokenrec;
93
+
94
+     $("#twilapi_url_rec").val(twilwhurlrec);
95
+  });
96
+
97
+  $("#copyToClipboardtwil").on("click", function(event) {
98
+     var $tempElpl = $("<input>");
99
+     $("body").append($tempElpl);
100
+     $tempElpl.val($("#twilapi_url_rec").val()).select();
101
+     document.execCommand("Copy");
102
+     $tempElpl.remove();
103
+     alert("The link has been copied to your clipboard!");
104
+  });
105
+
106
+  $("#generate_twil_delrcpt").on("click", function(event) {
107
+
108
+     var twiltoken = randomStr(35);
109
+     var twildrwhurl = window.location.origin + OC.generateUrl('/apps/sms_relentless/api/recdeliverytwil?twildrparam=') + twiltoken;
110
+
111
+     $("#twilapi_url").val(twildrwhurl);
112
+  });
113
+
114
+
115
+  $("#generate_flow_rcpt").on("click", function(event) {
116
+
117
+     var flowtokenrec = randomStr(70);
118
+     var flowwhurlrec = window.location.origin + OC.generateUrl('/apps/sms_relentless/api/recsmsflow?flowrecparam=') + flowtokenrec;
119
+
120
+     $("#flowapi_url_rec").val(flowwhurlrec);
121
+  });
122
+
123
+  $("#copyToClipboardflow").on("click", function(event) {
124
+     var $tempElpl = $("<input>");
125
+     $("body").append($tempElpl);
126
+     $tempElpl.val($("#flowapi_url_rec").val()).select();
127
+     document.execCommand("Copy");
128
+     $tempElpl.remove();
129
+     alert("The link has been copied to your clipboard!");
130
+  });
131
+
132
+  $("#generate_flow_delrcpt").on("click", function(event) {
133
+
134
+     var flowtoken = randomStr(70);
135
+     var flowdrwhurl = window.location.origin + OC.generateUrl('/apps/sms_relentless/api/recdeliveryflow?flowdrparam=') + flowtoken;
136
+
137
+     $("#flowapi_url").val(flowdrwhurl);
138
+  });
139
+
140
+
141
+  $("#save_sms_settings").on("click", function(event) {
142
+
143
+    event.preventDefault();
144
+    OC.msg.startAction('#smsr_save_msg', t('sms_relentless', 'Saved'));
145
+
146
+    var baseUrl = OC.generateUrl('/apps/sms_relentless/user/updatesettings');
147
+
148
+    var messagesperpageinit = $("#messagesperpage").val();
149
+    var messagesperpagesec = messagesperpageinit.replace(/[^0-9]/g, '');
150
+
151
+    if (messagesperpagesec != '') {
152
+        var messagesperpageproc = messagesperpagesec;
153
+    } else {
154
+        var messagesperpageproc = 100;
155
+    }
156
+
157
+    var getnotify = 0;
158
+
159
+    if ($("#get_notify").is(':checked')) {
160
+        getnotify = 1;
161
+    }
162
+
163
+    var emailaddressinit = $("#notification_email").val();
164
+
165
+    function validate_email($email) {
166
+        var email_reg = /^([\w-\.]+@([\w-]+\.)+[\w-]{2,4})?$/;
167
+        return email_reg.test($email);
168
+    }
169
+
170
+    if (validate_email(emailaddressinit)) {
171
+         var notifyemail = emailaddressinit;
172
+    } else {
173
+         var notifyemail = '';
174
+    }
175
+
176
+    var telsenderinit = $("#tel_sender_name").val();
177
+    var telsenderproc = telsenderinit.replace(/[^A-Za-z 0-9]/g, '');
178
+
179
+    var nexsenderinit = $("#nex_sender_name").val();
180
+    var nexsenderproc = nexsenderinit.replace(/[^A-Za-z 0-9]/g, '');
181
+
182
+    var twilsenderinit = $("#twil_sender_name").val();
183
+    var twilsenderproc = twilsenderinit.replace(/[^A-Za-z 0-9]/g, '');
184
+
185
+    var flowsenderinit = $("#flow_sender_name").val();
186
+    var flowsenderproc = flowsenderinit.replace(/[^A-Za-z 0-9]/g, '');
187
+
188
+    var includesmsinemail = 0;
189
+
190
+    if ($("#includesmsinemail").is(':checked')) {
191
+        includesmsinemail = 1;
192
+    }
193
+
194
+    var datatosave = {
195
+                      userId: userid,
196
+                      telapiKey: $("#telapi_key").val(),
197
+                      telPubKey: $("#tel_pub_key").val(),
198
+                      telapiUrlRec: $("#telapi_url_rec").val(),
199
+                      telapiUrl: $("#telapi_url").val(),
200
+                      messagingProfileId: $("#messaging_profile_id").val(),
201
+                      nexapiKey: $("#nexapi_key").val(),
202
+                      nexapiSecret: $("#nexapi_secret").val(),
203
+                      nexapiUrlRec: $("#nexapi_url_rec").val(),
204
+                      nexapiUrl: $("#nexapi_url").val(),
205
+                      twilapiKey: $("#twilapi_key").val(),
206
+                      twilapiSecret: $("#twilapi_secret").val(),
207
+                      twilapiUrlRec: $("#twilapi_url_rec").val(),
208
+                      twilapiUrl: $("#twilapi_url").val(),
209
+                      flowapiKey: $("#flowapi_key").val(),
210
+                      flowapiSecret: $("#flowapi_secret").val(),
211
+                      flowapiUrlRec: $("#flowapi_url_rec").val(),
212
+                      flowapiUrl: $("#flowapi_url").val(),
213
+                      telSenderName: telsenderproc,
214
+                      nexSenderName: nexsenderproc,
215
+                      twilSenderName: twilsenderproc,
216
+                      flowSenderName: flowsenderproc,
217
+                      messagesperpage: messagesperpageproc,
218
+                      getNotify: getnotify,
219
+                      notificationEmail: notifyemail,
220
+                      getsmsinemail: includesmsinemail
221
+    };
222
+
223
+
224
+    $.ajax({
225
+       method: 'PUT',
226
+       url: baseUrl + '/' + userid,
227
+       contentType: 'application/json',
228
+       data: JSON.stringify(datatosave),
229
+       error: function(resp) {
230
+            alert('Error ! Please check your settings !');
231
+       }
232
+    });
233
+
234
+  });
235
+
236
+
237
+  var baseUrlget = OC.generateUrl('/apps/sms_relentless/user/getsettings');
238
+
239
+  $.ajax({
240
+     method: 'GET',
241
+     url: baseUrlget + '/' + userid,
242
+     contentType: 'application/json',
243
+     success: function(settingsfromdb) {
244
+         $("#telapi_key").val(settingsfromdb.telapi_key);
245
+         $("#tel_pub_key").val(settingsfromdb.tel_pub_key);
246
+         $("#telapi_url_rec").val(settingsfromdb.telapi_url_rec);
247
+         $("#telapi_url").val(settingsfromdb.telapi_url);
248
+         $("#messaging_profile_id").val(settingsfromdb.messaging_profile_id);
249
+         $("#nexapi_key").val(settingsfromdb.nexapi_key);
250
+         $("#nexapi_secret").val(settingsfromdb.nexapi_secret);
251
+         $("#nexapi_url_rec").val(settingsfromdb.nexapi_url_rec);
252
+         $("#nexapi_url").val(settingsfromdb.nexapi_url);
253
+         $("#twilapi_key").val(settingsfromdb.twilapi_key);
254
+         $("#twilapi_secret").val(settingsfromdb.twilapi_secret);
255
+         $("#twilapi_url_rec").val(settingsfromdb.twilapi_url_rec);
256
+         $("#twilapi_url").val(settingsfromdb.twilapi_url);
257
+         $("#flowapi_key").val(settingsfromdb.flowapi_key);
258
+         $("#flowapi_secret").val(settingsfromdb.flowapi_secret);
259
+         $("#flowapi_url_rec").val(settingsfromdb.flowapi_url_rec);
260
+         $("#flowapi_url").val(settingsfromdb.flowapi_url);
261
+         $("#tel_sender_name").val(settingsfromdb.tel_sender_name);
262
+         $("#nex_sender_name").val(settingsfromdb.nex_sender_name);
263
+         $("#twil_sender_name").val(settingsfromdb.twil_sender_name);
264
+         $("#flow_sender_name").val(settingsfromdb.flow_sender_name);
265
+         $("#messagesperpage").val(settingsfromdb.messagesperpage);
266
+
267
+         if (settingsfromdb.get_notify == 1) {
268
+             $("#get_notify").attr('checked', true);
269
+         } else {
270
+             $("#get_notify").attr('checked', false);
271
+         }
272
+
273
+         $("#notification_email").val(settingsfromdb.notification_email);
274
+
275
+         if (settingsfromdb.getsmsinemail == 1) {
276
+             $("#includesmsinemail").attr('checked', true);
277
+         } else {
278
+             $("#includesmsinemail").attr('checked', false);
279
+         }
280
+     }
281
+  });
282
+
283
+});
Browse code

removed README.md CHANGELOG.txt appinfo/info.xml appinfo/signature.json js/settings.js lib/AppInfo/Application.php lib/Controller/SmsrelentlessController.php lib/Controller/AuthorApiController.php lib/Migration/Version108Date20220820204512.php providers/Twilio

DoubleBastionAdmin authored on 23/08/2022 10:40:23
Showing 1 changed files
1 1
deleted file mode 100644
... ...
@@ -1,281 +0,0 @@
1
-/**
2
- * @copyright 2021 Double Bastion LLC <www.doublebastion.com>
3
- *
4
- * @author Double Bastion LLC
5
- *
6
- * @license GNU AGPL version 3 or any later version
7
- *
8
- * This program is free software; you can redistribute it and/or
9
- * modify it under the terms of the GNU AFFERO GENERAL PUBLIC LICENSE
10
- * License as published by the Free Software Foundation; either
11
- * version 3 of the License, or any later version.
12
- *
13
- * This program is distributed in the hope that it will be useful,
14
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
15
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
16
- * GNU AFFERO GENERAL PUBLIC LICENSE for more details.
17
- *
18
- * You should have received a copy of the GNU Affero General Public
19
- * License along with this program.  If not, see <http://www.gnu.org/licenses/>.
20
- *
21
- */
22
-
23
-$(document).ready(function() {
24
-
25
-  var userid = "<?php p($userId); ?>";
26
-  var strlength;
27
-
28
-  function randomStr(strlength) {
29
-        var fintext = "";
30
-        var keyspace = '0123456789abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ';
31
-        for (var i = 0; i < strlength; i++) {
32
-             fintext += keyspace.charAt(Math.floor(Math.random() * keyspace.length));
33
-        }
34
-        return fintext;
35
-  }
36
-
37
-  $("#generate_tel_rcpt").on("click", function(event) {
38
-     var teltokenrec = randomStr(70);
39
-     var telnyxwhurlrec = window.location.origin + OC.generateUrl('/apps/sms_relentless/api/recsmstel?telrecparam=') + teltokenrec;
40
-
41
-     $("#telapi_url_rec").val(telnyxwhurlrec);
42
-  });
43
-
44
-  $("#copyToClipboardtel").on("click", function(event) {
45
-     var $tempEl = $("<input>");
46
-     $("body").append($tempEl);
47
-     $tempEl.val($("#telapi_url_rec").val()).select();
48
-     document.execCommand("Copy");
49
-     $tempEl.remove();
50
-     alert("The link has been copied to your clipboard!");
51
-  });
52
-
53
-  $("#generate_tel_delrcpt").on("click", function(event) {
54
-
55
-     var teltoken = randomStr(70);
56
-     var telnyxwhurl = window.location.origin + OC.generateUrl('/apps/sms_relentless/api/recdeliverytel?teldrparam=') + teltoken;
57
-
58
-     $("#telapi_url").val(telnyxwhurl);
59
-  });
60
-
61
-
62
-  $("#generate_nex_rcpt").on("click", function(event) {
63
-
64
-     var plivotokenrec = randomStr(70);
65
-
66
-     var plivowhurlrec = window.location.origin + OC.generateUrl('/apps/sms_relentless/api/recsmsnex?plivorecparam=') + plivotokenrec;
67
-
68
-     $("#nexapi_url_rec").val(plivowhurlrec);
69
-  });
70
-
71
-  $("#copyToClipboardnex").on("click", function(event) {
72
-     var $tempElpl = $("<input>");
73
-     $("body").append($tempElpl);
74
-     $tempElpl.val($("#nexapi_url_rec").val()).select();
75
-     document.execCommand("Copy");
76
-     $tempElpl.remove();
77
-     alert("The link has been copied to your clipboard!");
78
-  });
79
-
80
-  $("#generate_nex_delrcpt").on("click", function(event) {
81
-
82
-     var plivotoken = randomStr(70);
83
-     var plivodrwhurl = window.location.origin + OC.generateUrl('/apps/sms_relentless/api/recdeliverynex?plivodrparam=') + plivotoken;
84
-
85
-     $("#nexapi_url").val(plivodrwhurl);
86
-  });
87
-
88
-
89
-  $("#generate_twil_rcpt").on("click", function(event) {
90
-
91
-     var twilwhurlrec = window.location.origin + OC.generateUrl('/apps/sms_relentless/api/recsmstwil');
92
-
93
-     $("#twilapi_url_rec").val(twilwhurlrec);
94
-  });
95
-
96
-  $("#copyToClipboardtwil").on("click", function(event) {
97
-     var $tempElpl = $("<input>");
98
-     $("body").append($tempElpl);
99
-     $tempElpl.val($("#twilapi_url_rec").val()).select();
100
-     document.execCommand("Copy");
101
-     $tempElpl.remove();
102
-     alert("The link has been copied to your clipboard!");
103
-  });
104
-
105
-  $("#generate_twil_delrcpt").on("click", function(event) {
106
-
107
-     var twildrwhurl = window.location.origin + OC.generateUrl('/apps/sms_relentless/api/recdeliverytwil');
108
-
109
-     $("#twilapi_url").val(twildrwhurl);
110
-  });
111
-
112
-
113
-  $("#generate_flow_rcpt").on("click", function(event) {
114
-
115
-     var flowtokenrec = randomStr(70);
116
-     var flowwhurlrec = window.location.origin + OC.generateUrl('/apps/sms_relentless/api/recsmsflow?flowrecparam=') + flowtokenrec;
117
-
118
-     $("#flowapi_url_rec").val(flowwhurlrec);
119
-  });
120
-
121
-  $("#copyToClipboardflow").on("click", function(event) {
122
-     var $tempElpl = $("<input>");
123
-     $("body").append($tempElpl);
124
-     $tempElpl.val($("#flowapi_url_rec").val()).select();
125
-     document.execCommand("Copy");
126
-     $tempElpl.remove();
127
-     alert("The link has been copied to your clipboard!");
128
-  });
129
-
130
-  $("#generate_flow_delrcpt").on("click", function(event) {
131
-
132
-     var flowtoken = randomStr(70);
133
-     var flowdrwhurl = window.location.origin + OC.generateUrl('/apps/sms_relentless/api/recdeliveryflow?flowdrparam=') + flowtoken;
134
-
135
-     $("#flowapi_url").val(flowdrwhurl);
136
-  });
137
-
138
-
139
-  $("#save_sms_settings").on("click", function(event) {
140
-
141
-    event.preventDefault();
142
-    OC.msg.startAction('#smsr_save_msg', t('sms_relentless', 'Saved'));
143
-
144
-    var baseUrl = OC.generateUrl('/apps/sms_relentless/user/updatesettings');
145
-
146
-    var messagesperpageinit = $("#messagesperpage").val();
147
-    var messagesperpagesec = messagesperpageinit.replace(/[^0-9]/g, '');
148
-
149
-    if (messagesperpagesec != '') {
150
-        var messagesperpageproc = messagesperpagesec;
151
-    } else {
152
-        var messagesperpageproc = 100;
153
-    }
154
-
155
-    var getnotify = 0;
156
-
157
-    if ($("#get_notify").is(':checked')) {
158
-        getnotify = 1;
159
-    }
160
-
161
-    var emailaddressinit = $("#notification_email").val();
162
-
163
-    function validate_email($email) {
164
-        var email_reg = /^([\w-\.]+@([\w-]+\.)+[\w-]{2,4})?$/;
165
-        return email_reg.test($email);
166
-    }
167
-
168
-    if (validate_email(emailaddressinit)) {
169
-         var notifyemail = emailaddressinit;
170
-    } else {
171
-         var notifyemail = '';
172
-    }
173
-
174
-    var telsenderinit = $("#tel_sender_name").val();
175
-    var telsenderproc = telsenderinit.replace(/[^A-Za-z 0-9]/g, '');
176
-
177
-    var nexsenderinit = $("#nex_sender_name").val();
178
-    var nexsenderproc = nexsenderinit.replace(/[^A-Za-z 0-9]/g, '');
179
-
180
-    var twilsenderinit = $("#twil_sender_name").val();
181
-    var twilsenderproc = twilsenderinit.replace(/[^A-Za-z 0-9]/g, '');
182
-
183
-    var flowsenderinit = $("#flow_sender_name").val();
184
-    var flowsenderproc = flowsenderinit.replace(/[^A-Za-z 0-9]/g, '');
185
-
186
-    var includesmsinemail = 0;
187
-
188
-    if ($("#includesmsinemail").is(':checked')) {
189
-        includesmsinemail = 1;
190
-    }
191
-
192
-    var datatosave = {
193
-                      userId: userid,
194
-                      telapiKey: $("#telapi_key").val(),
195
-                      telPubKey: $("#tel_pub_key").val(),
196
-                      telapiUrlRec: $("#telapi_url_rec").val(),
197
-                      telapiUrl: $("#telapi_url").val(),
198
-                      messagingProfileId: $("#messaging_profile_id").val(),
199
-                      nexapiKey: $("#nexapi_key").val(),
200
-                      nexapiSecret: $("#nexapi_secret").val(),
201
-                      nexapiUrlRec: $("#nexapi_url_rec").val(),
202
-                      nexapiUrl: $("#nexapi_url").val(),
203
-                      twilapiKey: $("#twilapi_key").val(),
204
-                      twilapiSecret: $("#twilapi_secret").val(),
205
-                      twilapiUrlRec: $("#twilapi_url_rec").val(),
206
-                      twilapiUrl: $("#twilapi_url").val(),
207
-                      flowapiKey: $("#flowapi_key").val(),
208
-                      flowapiSecret: $("#flowapi_secret").val(),
209
-                      flowapiUrlRec: $("#flowapi_url_rec").val(),
210
-                      flowapiUrl: $("#flowapi_url").val(),
211
-                      telSenderName: telsenderproc,
212
-                      nexSenderName: nexsenderproc,
213
-                      twilSenderName: twilsenderproc,
214
-                      flowSenderName: flowsenderproc,
215
-                      messagesperpage: messagesperpageproc,
216
-                      getNotify: getnotify,
217
-                      notificationEmail: notifyemail,
218
-                      getsmsinemail: includesmsinemail
219
-    };
220
-
221
-
222
-    $.ajax({
223
-       method: 'PUT',
224
-       url: baseUrl + '/' + userid,
225
-       contentType: 'application/json',
226
-       data: JSON.stringify(datatosave),
227
-       error: function(resp) {
228
-            alert('Error ! Please check your settings !');
229
-       }
230
-    });
231
-
232
-  });
233
-
234
-
235
-  var baseUrlget = OC.generateUrl('/apps/sms_relentless/user/getsettings');
236
-
237
-  $.ajax({
238
-     method: 'GET',
239
-     url: baseUrlget + '/' + userid,
240
-     contentType: 'application/json',
241
-     success: function(settingsfromdb) {
242
-         $("#telapi_key").val(settingsfromdb.telapi_key);
243
-         $("#tel_pub_key").val(settingsfromdb.tel_pub_key);
244
-         $("#telapi_url_rec").val(settingsfromdb.telapi_url_rec);
245
-         $("#telapi_url").val(settingsfromdb.telapi_url);
246
-         $("#messaging_profile_id").val(settingsfromdb.messaging_profile_id);
247
-         $("#nexapi_key").val(settingsfromdb.nexapi_key);
248
-         $("#nexapi_secret").val(settingsfromdb.nexapi_secret);
249
-         $("#nexapi_url_rec").val(settingsfromdb.nexapi_url_rec);
250
-         $("#nexapi_url").val(settingsfromdb.nexapi_url);
251
-         $("#twilapi_key").val(settingsfromdb.twilapi_key);
252
-         $("#twilapi_secret").val(settingsfromdb.twilapi_secret);
253
-         $("#twilapi_url_rec").val(settingsfromdb.twilapi_url_rec);
254
-         $("#twilapi_url").val(settingsfromdb.twilapi_url);
255
-         $("#flowapi_key").val(settingsfromdb.flowapi_key);
256
-         $("#flowapi_secret").val(settingsfromdb.flowapi_secret);
257
-         $("#flowapi_url_rec").val(settingsfromdb.flowapi_url_rec);
258
-         $("#flowapi_url").val(settingsfromdb.flowapi_url);
259
-         $("#tel_sender_name").val(settingsfromdb.tel_sender_name);
260
-         $("#nex_sender_name").val(settingsfromdb.nex_sender_name);
261
-         $("#twil_sender_name").val(settingsfromdb.twil_sender_name);
262
-         $("#flow_sender_name").val(settingsfromdb.flow_sender_name);
263
-         $("#messagesperpage").val(settingsfromdb.messagesperpage);
264
-
265
-         if (settingsfromdb.get_notify == 1) {
266
-             $("#get_notify").attr('checked', true);
267
-         } else {
268
-             $("#get_notify").attr('checked', false);
269
-         }
270
-
271
-         $("#notification_email").val(settingsfromdb.notification_email);
272
-
273
-         if (settingsfromdb.getsmsinemail == 1) {
274
-             $("#includesmsinemail").attr('checked', true);
275
-         } else {
276
-             $("#includesmsinemail").attr('checked', false);
277
-         }
278
-     }
279
-  });
280
-
281
-});
Browse code

added CHANGELOG.txt README.md appinfo/info.xml appinfo/routes.php appinfo/signature.json css/style.css js/sendsms.js js/settings.js lib/AppInfo/Application.php lib/Controller/AuthorApiController.php lib/Controller/SmsrelentlessController.php lib/Service/SmsrelentlessService.php templates/navigation/index.php templates/settings.php lib/Migration/Version108Date20220818235106.php

DoubleBastionAdmin authored on 18/08/2022 21:30:17
Showing 1 changed files
1 1
new file mode 100644
... ...
@@ -0,0 +1,281 @@
1
+/**
2
+ * @copyright 2021 Double Bastion LLC <www.doublebastion.com>
3
+ *
4
+ * @author Double Bastion LLC
5
+ *
6
+ * @license GNU AGPL version 3 or any later version
7
+ *
8
+ * This program is free software; you can redistribute it and/or
9
+ * modify it under the terms of the GNU AFFERO GENERAL PUBLIC LICENSE
10
+ * License as published by the Free Software Foundation; either
11
+ * version 3 of the License, or any later version.
12
+ *
13
+ * This program is distributed in the hope that it will be useful,
14
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
15
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
16
+ * GNU AFFERO GENERAL PUBLIC LICENSE for more details.
17
+ *
18
+ * You should have received a copy of the GNU Affero General Public
19
+ * License along with this program.  If not, see <http://www.gnu.org/licenses/>.
20
+ *
21
+ */
22
+
23
+$(document).ready(function() {
24
+
25
+  var userid = "<?php p($userId); ?>";
26
+  var strlength;
27
+
28
+  function randomStr(strlength) {
29
+        var fintext = "";
30
+        var keyspace = '0123456789abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ';
31
+        for (var i = 0; i < strlength; i++) {
32
+             fintext += keyspace.charAt(Math.floor(Math.random() * keyspace.length));
33
+        }
34
+        return fintext;
35
+  }
36
+
37
+  $("#generate_tel_rcpt").on("click", function(event) {
38
+     var teltokenrec = randomStr(70);
39
+     var telnyxwhurlrec = window.location.origin + OC.generateUrl('/apps/sms_relentless/api/recsmstel?telrecparam=') + teltokenrec;
40
+
41
+     $("#telapi_url_rec").val(telnyxwhurlrec);
42
+  });
43
+
44
+  $("#copyToClipboardtel").on("click", function(event) {
45
+     var $tempEl = $("<input>");
46
+     $("body").append($tempEl);
47
+     $tempEl.val($("#telapi_url_rec").val()).select();
48
+     document.execCommand("Copy");
49
+     $tempEl.remove();
50
+     alert("The link has been copied to your clipboard!");
51
+  });
52
+
53
+  $("#generate_tel_delrcpt").on("click", function(event) {
54
+
55
+     var teltoken = randomStr(70);
56
+     var telnyxwhurl = window.location.origin + OC.generateUrl('/apps/sms_relentless/api/recdeliverytel?teldrparam=') + teltoken;
57
+
58
+     $("#telapi_url").val(telnyxwhurl);
59
+  });
60
+
61
+
62
+  $("#generate_nex_rcpt").on("click", function(event) {
63
+
64
+     var plivotokenrec = randomStr(70);
65
+
66
+     var plivowhurlrec = window.location.origin + OC.generateUrl('/apps/sms_relentless/api/recsmsnex?plivorecparam=') + plivotokenrec;
67
+
68
+     $("#nexapi_url_rec").val(plivowhurlrec);
69
+  });
70
+
71
+  $("#copyToClipboardnex").on("click", function(event) {
72
+     var $tempElpl = $("<input>");
73
+     $("body").append($tempElpl);
74
+     $tempElpl.val($("#nexapi_url_rec").val()).select();
75
+     document.execCommand("Copy");
76
+     $tempElpl.remove();
77
+     alert("The link has been copied to your clipboard!");
78
+  });
79
+
80
+  $("#generate_nex_delrcpt").on("click", function(event) {
81
+
82
+     var plivotoken = randomStr(70);
83
+     var plivodrwhurl = window.location.origin + OC.generateUrl('/apps/sms_relentless/api/recdeliverynex?plivodrparam=') + plivotoken;
84
+
85
+     $("#nexapi_url").val(plivodrwhurl);
86
+  });
87
+
88
+
89
+  $("#generate_twil_rcpt").on("click", function(event) {
90
+
91
+     var twilwhurlrec = window.location.origin + OC.generateUrl('/apps/sms_relentless/api/recsmstwil');
92
+
93
+     $("#twilapi_url_rec").val(twilwhurlrec);
94
+  });
95
+
96
+  $("#copyToClipboardtwil").on("click", function(event) {
97
+     var $tempElpl = $("<input>");
98
+     $("body").append($tempElpl);
99
+     $tempElpl.val($("#twilapi_url_rec").val()).select();
100
+     document.execCommand("Copy");
101
+     $tempElpl.remove();
102
+     alert("The link has been copied to your clipboard!");
103
+  });
104
+
105
+  $("#generate_twil_delrcpt").on("click", function(event) {
106
+
107
+     var twildrwhurl = window.location.origin + OC.generateUrl('/apps/sms_relentless/api/recdeliverytwil');
108
+
109
+     $("#twilapi_url").val(twildrwhurl);
110
+  });
111
+
112
+
113
+  $("#generate_flow_rcpt").on("click", function(event) {
114
+
115
+     var flowtokenrec = randomStr(70);
116
+     var flowwhurlrec = window.location.origin + OC.generateUrl('/apps/sms_relentless/api/recsmsflow?flowrecparam=') + flowtokenrec;
117
+
118
+     $("#flowapi_url_rec").val(flowwhurlrec);
119
+  });
120
+
121
+  $("#copyToClipboardflow").on("click", function(event) {
122
+     var $tempElpl = $("<input>");
123
+     $("body").append($tempElpl);
124
+     $tempElpl.val($("#flowapi_url_rec").val()).select();
125
+     document.execCommand("Copy");
126
+     $tempElpl.remove();
127
+     alert("The link has been copied to your clipboard!");
128
+  });
129
+
130
+  $("#generate_flow_delrcpt").on("click", function(event) {
131
+
132
+     var flowtoken = randomStr(70);
133
+     var flowdrwhurl = window.location.origin + OC.generateUrl('/apps/sms_relentless/api/recdeliveryflow?flowdrparam=') + flowtoken;
134
+
135
+     $("#flowapi_url").val(flowdrwhurl);
136
+  });
137
+
138
+
139
+  $("#save_sms_settings").on("click", function(event) {
140
+
141
+    event.preventDefault();
142
+    OC.msg.startAction('#smsr_save_msg', t('sms_relentless', 'Saved'));
143
+
144
+    var baseUrl = OC.generateUrl('/apps/sms_relentless/user/updatesettings');
145
+
146
+    var messagesperpageinit = $("#messagesperpage").val();
147
+    var messagesperpagesec = messagesperpageinit.replace(/[^0-9]/g, '');
148
+
149
+    if (messagesperpagesec != '') {
150
+        var messagesperpageproc = messagesperpagesec;
151
+    } else {
152
+        var messagesperpageproc = 100;
153
+    }
154
+
155
+    var getnotify = 0;
156
+
157
+    if ($("#get_notify").is(':checked')) {
158
+        getnotify = 1;
159
+    }
160
+
161
+    var emailaddressinit = $("#notification_email").val();
162
+
163
+    function validate_email($email) {
164
+        var email_reg = /^([\w-\.]+@([\w-]+\.)+[\w-]{2,4})?$/;
165
+        return email_reg.test($email);
166
+    }
167
+
168
+    if (validate_email(emailaddressinit)) {
169
+         var notifyemail = emailaddressinit;
170
+    } else {
171
+         var notifyemail = '';
172
+    }
173
+
174
+    var telsenderinit = $("#tel_sender_name").val();
175
+    var telsenderproc = telsenderinit.replace(/[^A-Za-z 0-9]/g, '');
176
+
177
+    var nexsenderinit = $("#nex_sender_name").val();
178
+    var nexsenderproc = nexsenderinit.replace(/[^A-Za-z 0-9]/g, '');
179
+
180
+    var twilsenderinit = $("#twil_sender_name").val();
181
+    var twilsenderproc = twilsenderinit.replace(/[^A-Za-z 0-9]/g, '');
182
+
183
+    var flowsenderinit = $("#flow_sender_name").val();
184
+    var flowsenderproc = flowsenderinit.replace(/[^A-Za-z 0-9]/g, '');
185
+
186
+    var includesmsinemail = 0;
187
+
188
+    if ($("#includesmsinemail").is(':checked')) {
189
+        includesmsinemail = 1;
190
+    }
191
+
192
+    var datatosave = {
193
+                      userId: userid,
194
+                      telapiKey: $("#telapi_key").val(),
195
+                      telPubKey: $("#tel_pub_key").val(),
196
+                      telapiUrlRec: $("#telapi_url_rec").val(),
197
+                      telapiUrl: $("#telapi_url").val(),
198
+                      messagingProfileId: $("#messaging_profile_id").val(),
199
+                      nexapiKey: $("#nexapi_key").val(),
200
+                      nexapiSecret: $("#nexapi_secret").val(),
201
+                      nexapiUrlRec: $("#nexapi_url_rec").val(),
202
+                      nexapiUrl: $("#nexapi_url").val(),
203
+                      twilapiKey: $("#twilapi_key").val(),
204
+                      twilapiSecret: $("#twilapi_secret").val(),
205
+                      twilapiUrlRec: $("#twilapi_url_rec").val(),
206
+                      twilapiUrl: $("#twilapi_url").val(),
207
+                      flowapiKey: $("#flowapi_key").val(),
208
+                      flowapiSecret: $("#flowapi_secret").val(),
209
+                      flowapiUrlRec: $("#flowapi_url_rec").val(),
210
+                      flowapiUrl: $("#flowapi_url").val(),
211
+                      telSenderName: telsenderproc,
212
+                      nexSenderName: nexsenderproc,
213
+                      twilSenderName: twilsenderproc,
214
+                      flowSenderName: flowsenderproc,
215
+                      messagesperpage: messagesperpageproc,
216
+                      getNotify: getnotify,
217
+                      notificationEmail: notifyemail,
218
+                      getsmsinemail: includesmsinemail
219
+    };
220
+
221
+
222
+    $.ajax({
223
+       method: 'PUT',
224
+       url: baseUrl + '/' + userid,
225
+       contentType: 'application/json',
226
+       data: JSON.stringify(datatosave),
227
+       error: function(resp) {
228
+            alert('Error ! Please check your settings !');
229
+       }
230
+    });
231
+
232
+  });
233
+
234
+
235
+  var baseUrlget = OC.generateUrl('/apps/sms_relentless/user/getsettings');
236
+
237
+  $.ajax({
238
+     method: 'GET',
239
+     url: baseUrlget + '/' + userid,
240
+     contentType: 'application/json',
241
+     success: function(settingsfromdb) {
242
+         $("#telapi_key").val(settingsfromdb.telapi_key);
243
+         $("#tel_pub_key").val(settingsfromdb.tel_pub_key);
244
+         $("#telapi_url_rec").val(settingsfromdb.telapi_url_rec);
245
+         $("#telapi_url").val(settingsfromdb.telapi_url);
246
+         $("#messaging_profile_id").val(settingsfromdb.messaging_profile_id);
247
+         $("#nexapi_key").val(settingsfromdb.nexapi_key);
248
+         $("#nexapi_secret").val(settingsfromdb.nexapi_secret);
249
+         $("#nexapi_url_rec").val(settingsfromdb.nexapi_url_rec);
250
+         $("#nexapi_url").val(settingsfromdb.nexapi_url);
251
+         $("#twilapi_key").val(settingsfromdb.twilapi_key);
252
+         $("#twilapi_secret").val(settingsfromdb.twilapi_secret);
253
+         $("#twilapi_url_rec").val(settingsfromdb.twilapi_url_rec);
254
+         $("#twilapi_url").val(settingsfromdb.twilapi_url);
255
+         $("#flowapi_key").val(settingsfromdb.flowapi_key);
256
+         $("#flowapi_secret").val(settingsfromdb.flowapi_secret);
257
+         $("#flowapi_url_rec").val(settingsfromdb.flowapi_url_rec);
258
+         $("#flowapi_url").val(settingsfromdb.flowapi_url);
259
+         $("#tel_sender_name").val(settingsfromdb.tel_sender_name);
260
+         $("#nex_sender_name").val(settingsfromdb.nex_sender_name);
261
+         $("#twil_sender_name").val(settingsfromdb.twil_sender_name);
262
+         $("#flow_sender_name").val(settingsfromdb.flow_sender_name);
263
+         $("#messagesperpage").val(settingsfromdb.messagesperpage);
264
+
265
+         if (settingsfromdb.get_notify == 1) {
266
+             $("#get_notify").attr('checked', true);
267
+         } else {
268
+             $("#get_notify").attr('checked', false);
269
+         }
270
+
271
+         $("#notification_email").val(settingsfromdb.notification_email);
272
+
273
+         if (settingsfromdb.getsmsinemail == 1) {
274
+             $("#includesmsinemail").attr('checked', true);
275
+         } else {
276
+             $("#includesmsinemail").attr('checked', false);
277
+         }
278
+     }
279
+  });
280
+
281
+});
Browse code

deleted CHANGELOG.txt README.md appinfo/info.xml appinfo/routes.php appinfo/signature.json css/style.css js/sendsms.js js/settings.js lib/AppInfo/Application.php lib/Controller/AuthorApiController.php lib/Controller/SmsrelentlessController.php lib/Service/SmsrelentlessService.php templates/navigation/index.php templates/settings.php

DoubleBastionAdmin authored on 18/08/2022 21:08:00
Showing 1 changed files
1 1
deleted file mode 100644
... ...
@@ -1,242 +0,0 @@
1
-/**
2
- * @copyright 2021 Double Bastion LLC <www.doublebastion.com>
3
- *
4
- * @author Double Bastion LLC
5
- *
6
- * @license GNU AGPL version 3 or any later version
7
- *
8
- * This program is free software; you can redistribute it and/or
9
- * modify it under the terms of the GNU AFFERO GENERAL PUBLIC LICENSE
10
- * License as published by the Free Software Foundation; either
11
- * version 3 of the License, or any later version.
12
- *
13
- * This program is distributed in the hope that it will be useful,
14
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
15
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
16
- * GNU AFFERO GENERAL PUBLIC LICENSE for more details.
17
- *
18
- * You should have received a copy of the GNU Affero General Public
19
- * License along with this program.  If not, see <http://www.gnu.org/licenses/>.
20
- *
21
- */
22
-
23
-$(document).ready(function() {
24
-
25
-  var userid = "<?php p($userId); ?>";
26
-  var strlength;
27
-
28
-  function randomStr(strlength) {
29
-        var fintext = "";
30
-        var keyspace = '0123456789abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ';
31
-        for (var i = 0; i < strlength; i++) {
32
-             fintext += keyspace.charAt(Math.floor(Math.random() * keyspace.length));
33
-        }
34
-        return fintext;
35
-  }
36
-
37
-  $("#generate_tel_rcpt").on("click", function(event) {
38
-     var teltokenrec = randomStr(70);
39
-     var telnyxwhurlrec = window.location.origin + OC.generateUrl('/apps/sms_relentless/api/recsmstel?telrecparam=') + teltokenrec;
40
-
41
-     $("#telapi_url_rec").val(telnyxwhurlrec);
42
-  });
43
-
44
-  $("#copyToClipboardtel").on("click", function(event) {
45
-     var $tempEl = $("<input>");
46
-     $("body").append($tempEl);
47
-     $tempEl.val($("#telapi_url_rec").val()).select();
48
-     document.execCommand("Copy");
49
-     $tempEl.remove();
50
-     alert("The link has been copied to your clipboard!");
51
-  });
52
-
53
-  $("#generate_tel_delrcpt").on("click", function(event) {
54
-
55
-     var teltoken = randomStr(70);
56
-     var telnyxwhurl = window.location.origin + OC.generateUrl('/apps/sms_relentless/api/recdeliverytel?teldrparam=') + teltoken;
57
-
58
-     $("#telapi_url").val(telnyxwhurl);
59
-  });
60
-
61
-
62
-  $("#generate_nex_rcpt").on("click", function(event) {
63
-
64
-     var plivotokenrec = randomStr(70);
65
-
66
-     var plivowhurlrec = window.location.origin + OC.generateUrl('/apps/sms_relentless/api/recsmsnex?plivorecparam=') + plivotokenrec;
67
-
68
-     $("#nexapi_url_rec").val(plivowhurlrec);
69
-  });
70
-
71
-  $("#copyToClipboardnex").on("click", function(event) {
72
-     var $tempElpl = $("<input>");
73
-     $("body").append($tempElpl);
74
-     $tempElpl.val($("#nexapi_url_rec").val()).select();
75
-     document.execCommand("Copy");
76
-     $tempElpl.remove();
77
-     alert("The link has been copied to your clipboard!");
78
-  });
79
-
80
-  $("#generate_nex_delrcpt").on("click", function(event) {
81
-
82
-     var plivotoken = randomStr(70);
83
-     var plivodrwhurl = window.location.origin + OC.generateUrl('/apps/sms_relentless/api/recdeliverynex?plivodrparam=') + plivotoken;
84
-
85
-     $("#nexapi_url").val(plivodrwhurl);
86
-  });
87
-
88
-
89
-  $("#generate_twil_rcpt").on("click", function(event) {
90
-
91
-     var twilwhurlrec = window.location.origin + OC.generateUrl('/apps/sms_relentless/api/recsmstwil');
92
-
93
-     $("#twilapi_url_rec").val(twilwhurlrec);
94
-  });
95
-
96
-  $("#copyToClipboardtwil").on("click", function(event) {
97
-     var $tempElpl = $("<input>");
98
-     $("body").append($tempElpl);
99
-     $tempElpl.val($("#twilapi_url_rec").val()).select();
100
-     document.execCommand("Copy");
101
-     $tempElpl.remove();
102
-     alert("The link has been copied to your clipboard!");
103
-  });
104
-
105
-  $("#generate_twil_delrcpt").on("click", function(event) {
106
-
107
-     var twildrwhurl = window.location.origin + OC.generateUrl('/apps/sms_relentless/api/recdeliverytwil');
108
-
109
-     $("#twilapi_url").val(twildrwhurl);
110
-  });
111
-
112
-
113
-  $("#save_sms_settings").on("click", function(event) {
114
-
115
-    event.preventDefault();
116
-    OC.msg.startAction('#smsr_save_msg', t('sms_relentless', 'Saved'));
117
-
118
-    var baseUrl = OC.generateUrl('/apps/sms_relentless/user/updatesettings');
119
-
120
-    var messagesperpageinit = $("#messagesperpage").val();
121
-    var messagesperpagesec = messagesperpageinit.replace(/[^0-9]/g, '');
122
-
123
-    if (messagesperpagesec != '') {
124
-        var messagesperpageproc = messagesperpagesec;
125
-    } else {
126
-        var messagesperpageproc = 100;
127
-    }
128
-
129
-    var getnotify = 0;
130
-
131
-    if ($("#get_notify").is(':checked')) {
132
-        getnotify = 1;
133
-    }
134
-
135
-    var emailaddressinit = $("#notification_email").val();
136
-
137
-    function validate_email($email) {
138
-        var email_reg = /^([\w-\.]+@([\w-]+\.)+[\w-]{2,4})?$/;
139
-        return email_reg.test($email);
140
-    }
141
-
142
-    if (validate_email(emailaddressinit)) {
143
-         var notifyemail = emailaddressinit;
144
-    } else {
145
-         var notifyemail = '';
146
-    }
147
-
148
-    var telsenderinit = $("#tel_sender_name").val();
149
-    var telsenderproc = telsenderinit.replace(/[^A-Za-z 0-9]/g, '');
150
-
151
-    var nexsenderinit = $("#nex_sender_name").val();
152
-    var nexsenderproc = nexsenderinit.replace(/[^A-Za-z 0-9]/g, '');
153
-
154
-    var twilsenderinit = $("#twil_sender_name").val();
155
-    var twilsenderproc = twilsenderinit.replace(/[^A-Za-z 0-9]/g, '');
156
-
157
-    var includesmsinemail = 0;
158
-
159
-    if ($("#includesmsinemail").is(':checked')) {
160
-        includesmsinemail = 1;
161
-    }
162
-
163
-    var datatosave = {
164
-                      userId: userid,
165
-                      telapiKey: $("#telapi_key").val(),
166
-                      telPubKey: $("#tel_pub_key").val(),
167
-                      telapiUrlRec: $("#telapi_url_rec").val(),
168
-                      telapiUrl: $("#telapi_url").val(),
169
-                      messagingProfileId: $("#messaging_profile_id").val(),
170
-                      nexapiKey: $("#nexapi_key").val(),
171
-                      nexapiSecret: $("#nexapi_secret").val(),
172
-                      nexapiUrlRec: $("#nexapi_url_rec").val(),
173
-                      nexapiUrl: $("#nexapi_url").val(),
174
-                      twilapiKey: $("#twilapi_key").val(),
175
-                      twilapiSecret: $("#twilapi_secret").val(),
176
-                      twilapiUrlRec: $("#twilapi_url_rec").val(),
177
-                      twilapiUrl: $("#twilapi_url").val(),
178
-                      telSenderName: telsenderproc,
179
-                      nexSenderName: nexsenderproc,
180
-                      twilSenderName: twilsenderproc,
181
-                      messagesperpage: messagesperpageproc,
182
-                      getNotify: getnotify,
183
-                      notificationEmail: notifyemail,
184
-                      getsmsinemail: includesmsinemail
185
-    };
186
-
187
-
188
-    $.ajax({
189
-       method: 'PUT',
190
-       url: baseUrl + '/' + userid,
191
-       contentType: 'application/json',
192
-       data: JSON.stringify(datatosave),
193
-       error: function(resp) {
194
-            alert('Error ! Please check your settings !');
195
-       }
196
-    });
197
-
198
-  });
199
-
200
-
201
-  var baseUrlget = OC.generateUrl('/apps/sms_relentless/user/getsettings');
202
-
203
-  $.ajax({
204
-     method: 'GET',
205
-     url: baseUrlget + '/' + userid,
206
-     contentType: 'application/json',
207
-     success: function(settingsfromdb) {
208
-         $("#telapi_key").val(settingsfromdb.telapi_key);
209
-         $("#tel_pub_key").val(settingsfromdb.tel_pub_key);
210
-         $("#telapi_url_rec").val(settingsfromdb.telapi_url_rec);
211
-         $("#telapi_url").val(settingsfromdb.telapi_url);
212
-         $("#messaging_profile_id").val(settingsfromdb.messaging_profile_id);
213
-         $("#nexapi_key").val(settingsfromdb.nexapi_key);
214
-         $("#nexapi_secret").val(settingsfromdb.nexapi_secret);
215
-         $("#nexapi_url_rec").val(settingsfromdb.nexapi_url_rec);
216
-         $("#nexapi_url").val(settingsfromdb.nexapi_url);
217
-         $("#twilapi_key").val(settingsfromdb.twilapi_key);
218
-         $("#twilapi_secret").val(settingsfromdb.twilapi_secret);
219
-         $("#twilapi_url_rec").val(settingsfromdb.twilapi_url_rec);
220
-         $("#twilapi_url").val(settingsfromdb.twilapi_url);
221
-         $("#tel_sender_name").val(settingsfromdb.tel_sender_name);
222
-         $("#nex_sender_name").val(settingsfromdb.nex_sender_name);
223
-         $("#twil_sender_name").val(settingsfromdb.twil_sender_name);
224
-         $("#messagesperpage").val(settingsfromdb.messagesperpage);
225
-
226
-         if (settingsfromdb.get_notify == 1) {
227
-             $("#get_notify").attr('checked', true);
228
-         } else {
229
-             $("#get_notify").attr('checked', false);
230
-         }
231
-
232
-         $("#notification_email").val(settingsfromdb.notification_email);
233
-
234
-         if (settingsfromdb.getsmsinemail == 1) {
235
-             $("#includesmsinemail").attr('checked', true);
236
-         } else {
237
-             $("#includesmsinemail").attr('checked', false);
238
-         }
239
-     }
240
-  });
241
-
242
-});
Browse code

added CHANGELOG.txt README.md appinfo/info.xml appinfo/routes.php appinfo/signature.json css/style.css js/sendsms.js js/settings.js lib/AppInfo/Application.php lib/Controller/AuthorApiController.php lib/Controller/SmsrelentlessController.php lib/Service/SmsrelentlessService.php img/sms_relentless_screenshot.png lib/Migration/Version106Date20220813144231.php

DoubleBastionAdmin authored on 13/08/2022 12:43:51
Showing 1 changed files
1 1
new file mode 100644
... ...
@@ -0,0 +1,242 @@
1
+/**
2
+ * @copyright 2021 Double Bastion LLC <www.doublebastion.com>
3
+ *
4
+ * @author Double Bastion LLC
5
+ *
6
+ * @license GNU AGPL version 3 or any later version
7
+ *
8
+ * This program is free software; you can redistribute it and/or
9
+ * modify it under the terms of the GNU AFFERO GENERAL PUBLIC LICENSE
10
+ * License as published by the Free Software Foundation; either
11
+ * version 3 of the License, or any later version.
12
+ *
13
+ * This program is distributed in the hope that it will be useful,
14
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
15
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
16
+ * GNU AFFERO GENERAL PUBLIC LICENSE for more details.
17
+ *
18
+ * You should have received a copy of the GNU Affero General Public
19
+ * License along with this program.  If not, see <http://www.gnu.org/licenses/>.
20
+ *
21
+ */
22
+
23
+$(document).ready(function() {
24
+
25
+  var userid = "<?php p($userId); ?>";
26
+  var strlength;
27
+
28
+  function randomStr(strlength) {
29
+        var fintext = "";
30
+        var keyspace = '0123456789abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ';
31
+        for (var i = 0; i < strlength; i++) {
32
+             fintext += keyspace.charAt(Math.floor(Math.random() * keyspace.length));
33
+        }
34
+        return fintext;
35
+  }
36
+
37
+  $("#generate_tel_rcpt").on("click", function(event) {
38
+     var teltokenrec = randomStr(70);
39
+     var telnyxwhurlrec = window.location.origin + OC.generateUrl('/apps/sms_relentless/api/recsmstel?telrecparam=') + teltokenrec;
40
+
41
+     $("#telapi_url_rec").val(telnyxwhurlrec);
42
+  });
43
+
44
+  $("#copyToClipboardtel").on("click", function(event) {
45
+     var $tempEl = $("<input>");
46
+     $("body").append($tempEl);
47
+     $tempEl.val($("#telapi_url_rec").val()).select();
48
+     document.execCommand("Copy");
49
+     $tempEl.remove();
50
+     alert("The link has been copied to your clipboard!");
51
+  });
52
+
53
+  $("#generate_tel_delrcpt").on("click", function(event) {
54
+
55
+     var teltoken = randomStr(70);
56
+     var telnyxwhurl = window.location.origin + OC.generateUrl('/apps/sms_relentless/api/recdeliverytel?teldrparam=') + teltoken;
57
+
58
+     $("#telapi_url").val(telnyxwhurl);
59
+  });
60
+
61
+
62
+  $("#generate_nex_rcpt").on("click", function(event) {
63
+
64
+     var plivotokenrec = randomStr(70);
65
+
66
+     var plivowhurlrec = window.location.origin + OC.generateUrl('/apps/sms_relentless/api/recsmsnex?plivorecparam=') + plivotokenrec;
67
+
68
+     $("#nexapi_url_rec").val(plivowhurlrec);
69
+  });
70
+
71
+  $("#copyToClipboardnex").on("click", function(event) {
72
+     var $tempElpl = $("<input>");
73
+     $("body").append($tempElpl);
74
+     $tempElpl.val($("#nexapi_url_rec").val()).select();
75
+     document.execCommand("Copy");
76
+     $tempElpl.remove();
77
+     alert("The link has been copied to your clipboard!");
78
+  });
79
+
80
+  $("#generate_nex_delrcpt").on("click", function(event) {
81
+
82
+     var plivotoken = randomStr(70);
83
+     var plivodrwhurl = window.location.origin + OC.generateUrl('/apps/sms_relentless/api/recdeliverynex?plivodrparam=') + plivotoken;
84
+
85
+     $("#nexapi_url").val(plivodrwhurl);
86
+  });
87
+
88
+
89
+  $("#generate_twil_rcpt").on("click", function(event) {
90
+
91
+     var twilwhurlrec = window.location.origin + OC.generateUrl('/apps/sms_relentless/api/recsmstwil');
92
+
93
+     $("#twilapi_url_rec").val(twilwhurlrec);
94
+  });
95
+
96
+  $("#copyToClipboardtwil").on("click", function(event) {
97
+     var $tempElpl = $("<input>");
98
+     $("body").append($tempElpl);
99
+     $tempElpl.val($("#twilapi_url_rec").val()).select();
100
+     document.execCommand("Copy");
101
+     $tempElpl.remove();
102
+     alert("The link has been copied to your clipboard!");
103
+  });
104
+
105
+  $("#generate_twil_delrcpt").on("click", function(event) {
106
+
107
+     var twildrwhurl = window.location.origin + OC.generateUrl('/apps/sms_relentless/api/recdeliverytwil');
108
+
109
+     $("#twilapi_url").val(twildrwhurl);
110
+  });
111
+
112
+
113
+  $("#save_sms_settings").on("click", function(event) {
114
+
115
+    event.preventDefault();
116
+    OC.msg.startAction('#smsr_save_msg', t('sms_relentless', 'Saved'));
117
+
118
+    var baseUrl = OC.generateUrl('/apps/sms_relentless/user/updatesettings');
119
+
120
+    var messagesperpageinit = $("#messagesperpage").val();
121
+    var messagesperpagesec = messagesperpageinit.replace(/[^0-9]/g, '');
122
+
123
+    if (messagesperpagesec != '') {
124
+        var messagesperpageproc = messagesperpagesec;
125
+    } else {
126
+        var messagesperpageproc = 100;
127
+    }
128
+
129
+    var getnotify = 0;
130
+
131
+    if ($("#get_notify").is(':checked')) {
132
+        getnotify = 1;
133
+    }
134
+
135
+    var emailaddressinit = $("#notification_email").val();
136
+
137
+    function validate_email($email) {
138
+        var email_reg = /^([\w-\.]+@([\w-]+\.)+[\w-]{2,4})?$/;
139
+        return email_reg.test($email);
140
+    }
141
+
142
+    if (validate_email(emailaddressinit)) {
143
+         var notifyemail = emailaddressinit;
144
+    } else {
145
+         var notifyemail = '';
146
+    }
147
+
148
+    var telsenderinit = $("#tel_sender_name").val();
149
+    var telsenderproc = telsenderinit.replace(/[^A-Za-z 0-9]/g, '');
150
+
151
+    var nexsenderinit = $("#nex_sender_name").val();
152
+    var nexsenderproc = nexsenderinit.replace(/[^A-Za-z 0-9]/g, '');
153
+
154
+    var twilsenderinit = $("#twil_sender_name").val();
155
+    var twilsenderproc = twilsenderinit.replace(/[^A-Za-z 0-9]/g, '');
156
+
157
+    var includesmsinemail = 0;
158
+
159
+    if ($("#includesmsinemail").is(':checked')) {
160
+        includesmsinemail = 1;
161
+    }
162
+
163
+    var datatosave = {
164
+                      userId: userid,
165
+                      telapiKey: $("#telapi_key").val(),
166
+                      telPubKey: $("#tel_pub_key").val(),
167
+                      telapiUrlRec: $("#telapi_url_rec").val(),
168
+                      telapiUrl: $("#telapi_url").val(),
169
+                      messagingProfileId: $("#messaging_profile_id").val(),
170
+                      nexapiKey: $("#nexapi_key").val(),
171
+                      nexapiSecret: $("#nexapi_secret").val(),
172
+                      nexapiUrlRec: $("#nexapi_url_rec").val(),
173
+                      nexapiUrl: $("#nexapi_url").val(),
174
+                      twilapiKey: $("#twilapi_key").val(),
175
+                      twilapiSecret: $("#twilapi_secret").val(),
176
+                      twilapiUrlRec: $("#twilapi_url_rec").val(),
177
+                      twilapiUrl: $("#twilapi_url").val(),
178
+                      telSenderName: telsenderproc,
179
+                      nexSenderName: nexsenderproc,
180
+                      twilSenderName: twilsenderproc,
181
+                      messagesperpage: messagesperpageproc,
182
+                      getNotify: getnotify,
183
+                      notificationEmail: notifyemail,
184
+                      getsmsinemail: includesmsinemail
185
+    };
186
+
187
+
188
+    $.ajax({
189
+       method: 'PUT',
190
+       url: baseUrl + '/' + userid,
191
+       contentType: 'application/json',
192
+       data: JSON.stringify(datatosave),
193
+       error: function(resp) {
194
+            alert('Error ! Please check your settings !');
195
+       }
196
+    });
197
+
198
+  });
199
+
200
+
201
+  var baseUrlget = OC.generateUrl('/apps/sms_relentless/user/getsettings');
202
+
203
+  $.ajax({
204
+     method: 'GET',
205
+     url: baseUrlget + '/' + userid,
206
+     contentType: 'application/json',
207
+     success: function(settingsfromdb) {
208
+         $("#telapi_key").val(settingsfromdb.telapi_key);
209
+         $("#tel_pub_key").val(settingsfromdb.tel_pub_key);
210
+         $("#telapi_url_rec").val(settingsfromdb.telapi_url_rec);
211
+         $("#telapi_url").val(settingsfromdb.telapi_url);
212
+         $("#messaging_profile_id").val(settingsfromdb.messaging_profile_id);
213
+         $("#nexapi_key").val(settingsfromdb.nexapi_key);
214
+         $("#nexapi_secret").val(settingsfromdb.nexapi_secret);
215
+         $("#nexapi_url_rec").val(settingsfromdb.nexapi_url_rec);
216
+         $("#nexapi_url").val(settingsfromdb.nexapi_url);
217
+         $("#twilapi_key").val(settingsfromdb.twilapi_key);
218
+         $("#twilapi_secret").val(settingsfromdb.twilapi_secret);
219
+         $("#twilapi_url_rec").val(settingsfromdb.twilapi_url_rec);
220
+         $("#twilapi_url").val(settingsfromdb.twilapi_url);
221
+         $("#tel_sender_name").val(settingsfromdb.tel_sender_name);
222
+         $("#nex_sender_name").val(settingsfromdb.nex_sender_name);
223
+         $("#twil_sender_name").val(settingsfromdb.twil_sender_name);
224
+         $("#messagesperpage").val(settingsfromdb.messagesperpage);
225
+
226
+         if (settingsfromdb.get_notify == 1) {
227
+             $("#get_notify").attr('checked', true);
228
+         } else {
229
+             $("#get_notify").attr('checked', false);
230
+         }
231
+
232
+         $("#notification_email").val(settingsfromdb.notification_email);
233
+
234
+         if (settingsfromdb.getsmsinemail == 1) {
235
+             $("#includesmsinemail").attr('checked', true);
236
+         } else {
237
+             $("#includesmsinemail").attr('checked', false);
238
+         }
239
+     }
240
+  });
241
+
242
+});
Browse code

removed CHANGELOG.txt README.md appinfo/info.xml appinfo/routes.php appinfo/signature.json css/style.css lib/js/sendsms.js lib/js/settings.js lib/AppInfo/Application.php lib/Controller/AuthorApiController.php lib/Controller/SmsrelentlessController.php lib/Service/SmsrelentlessService.php img/sms_relentless_screenshot.png

DoubleBastionAdmin authored on 13/08/2022 12:33:36
Showing 1 changed files
1 1
deleted file mode 100644
... ...
@@ -1,212 +0,0 @@
1
-/**
2
- * @copyright 2021 Double Bastion LLC <www.doublebastion.com>
3
- *
4
- * @author Double Bastion LLC
5
- *
6
- * @license GNU AGPL version 3 or any later version
7
- *
8
- * This program is free software; you can redistribute it and/or
9
- * modify it under the terms of the GNU AFFERO GENERAL PUBLIC LICENSE
10
- * License as published by the Free Software Foundation; either
11
- * version 3 of the License, or any later version.
12
- *
13
- * This program is distributed in the hope that it will be useful,
14
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
15
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
16
- * GNU AFFERO GENERAL PUBLIC LICENSE for more details.
17
- *
18
- * You should have received a copy of the GNU Affero General Public
19
- * License along with this program.  If not, see <http://www.gnu.org/licenses/>.
20
- *
21
- */
22
-
23
-$(document).ready(function() {
24
-
25
-  var userid = "<?php p($userId); ?>";
26
-  var strlength;
27
-
28
-  function randomStr(strlength) {
29
-        var fintext = "";
30
-        var keyspace = '0123456789abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ';
31
-        for (var i = 0; i < strlength; i++) {
32
-             fintext += keyspace.charAt(Math.floor(Math.random() * keyspace.length));
33
-        }
34
-        return fintext;
35
-  }
36
-
37
-  $("#generate_tel_rcpt").on("click", function(event) {
38
-     var teltokenrec = randomStr(70);
39
-     var telnyxwhurlrec = window.location.origin + OC.generateUrl('/apps/sms_relentless/api/recsmstel?telrecparam=') + teltokenrec;
40
-
41
-     $("#telapi_url_rec").val(telnyxwhurlrec);
42
-  });
43
-
44
-  $("#copyToClipboardtel").on("click", function(event) {
45
-     var $tempEl = $("<input>");
46
-     $("body").append($tempEl);
47
-     $tempEl.val($("#telapi_url_rec").val()).select();
48
-     document.execCommand("Copy");
49
-     $tempEl.remove();
50
-     alert("The link has been copied to your clipboard!");
51
-  });
52
-
53
-  $("#generate_tel_delrcpt").on("click", function(event) {
54
-
55
-     var teltoken = randomStr(70);
56
-     var telnyxwhurl = window.location.origin + OC.generateUrl('/apps/sms_relentless/api/recdeliverytel?teldrparam=') + teltoken;
57
-
58
-     $("#telapi_url").val(telnyxwhurl);
59
-  });
60
-
61
-
62
-  $("#generate_nex_rcpt").on("click", function(event) {
63
-
64
-     var plivotokenrec = randomStr(70);
65
-
66
-     var plivowhurlrec = window.location.origin + OC.generateUrl('/apps/sms_relentless/api/recsmsnex?plivorecparam=') + plivotokenrec;
67
-
68
-     $("#nexapi_url_rec").val(plivowhurlrec);
69
-  });
70
-
71
-  $("#copyToClipboardnex").on("click", function(event) {
72
-     var $tempElpl = $("<input>");
73
-     $("body").append($tempElpl);
74
-     $tempElpl.val($("#nexapi_url_rec").val()).select();
75
-     document.execCommand("Copy");
76
-     $tempElpl.remove();
77
-     alert("The link has been copied to your clipboard!");
78
-  });
79
-
80
-  $("#generate_nex_delrcpt").on("click", function(event) {
81
-
82
-     var plivotoken = randomStr(70);
83
-     var plivodrwhurl = window.location.origin + OC.generateUrl('/apps/sms_relentless/api/recdeliverynex?plivodrparam=') + plivotoken;
84
-
85
-     $("#nexapi_url").val(plivodrwhurl);
86
-  });
87
-
88
-
89
-  $("#save_sms_settings").on("click", function(event) {
90
-
91
-    event.preventDefault();
92
-    OC.msg.startAction('#smsr_save_msg', t('sms_relentless', 'Saved'));
93
-
94
-    var baseUrl = OC.generateUrl('/apps/sms_relentless/user/updatesettings');
95
-
96
-    var messagesperpageinit = $("#messagesperpage").val();
97
-    var messagesperpagesec = messagesperpageinit.replace(/[^0-9]/g, '');
98
-
99
-    if (messagesperpagesec != '') {
100
-        var messagesperpageproc = messagesperpagesec;
101
-    } else {
102
-        var messagesperpageproc = 100;
103
-    }
104
-
105
-    var getnotify = 0;
106
-
107
-    if ($("#get_notify").is(':checked')) {
108
-        getnotify = 1;
109
-    }
110
-
111
-    var telnyxemailinit = $("#telnyx_email").val();
112
-    var emailaddressinit = $("#notification_email").val();
113
-
114
-    function validate_email($email) {
115
-        var email_reg = /^([\w-\.]+@([\w-]+\.)+[\w-]{2,4})?$/;
116
-        return email_reg.test($email);
117
-    }
118
-
119
-    if (validate_email(telnyxemailinit)) {
120
-         var telnyxemail = telnyxemailinit;
121
-    } else {
122
-         var telnyxemail = '';
123
-    }
124
-
125
-    if (validate_email(emailaddressinit)) {
126
-         var notifyemail = emailaddressinit;
127
-    } else {
128
-         var notifyemail = '';
129
-    }
130
-
131
-    var telsenderinit = $("#tel_sender_name").val();
132
-    var telsenderproc = telsenderinit.replace(/[^A-Za-z 0-9]/g, '');
133
-
134
-    var nexsenderinit = $("#nex_sender_name").val();
135
-    var nexsenderproc = nexsenderinit.replace(/[^A-Za-z 0-9]/g, '');
136
-
137
-    var includesmsinemail = 0;
138
-
139
-    if ($("#includesmsinemail").is(':checked')) {
140
-        includesmsinemail = 1;
141
-    }
142
-
143
-    var datatosave = {
144
-                      userId: userid,
145
-                      telapiKey: $("#telapi_key").val(),
146
-                      telPubKey: $("#tel_pub_key").val(),
147
-                      telapiUrlRec: $("#telapi_url_rec").val(),
148
-                      telapiUrl: $("#telapi_url").val(),
149
-                      messagingProfileId: $("#messaging_profile_id").val(),
150
-                      nexapiKey: $("#nexapi_key").val(),
151
-                      nexapiSecret: $("#nexapi_secret").val(),
152
-                      nexapiUrlRec: $("#nexapi_url_rec").val(),
153
-                      nexapiUrl: $("#nexapi_url").val(),
154
-                      telSenderName: telsenderproc,
155
-                      nexSenderName: nexsenderproc,
156
-                      messagesperpage: messagesperpageproc,
157
-                      getNotify: getnotify,
158
-                      notificationEmail: notifyemail,
159
-                      getsmsinemail: includesmsinemail
160
-    };
161
-
162
-
163
-    $.ajax({
164
-       method: 'PUT',
165
-       url: baseUrl + '/' + userid,
166
-       contentType: 'application/json',
167
-       data: JSON.stringify(datatosave),
168
-       error: function(resp) {
169
-            alert('Error ! Please check your settings !');
170
-       }
171
-    });
172
-
173
-  });
174
-
175
-
176
-  var baseUrlget = OC.generateUrl('/apps/sms_relentless/user/getsettings');
177
-
178
-  $.ajax({
179
-     method: 'GET',
180
-     url: baseUrlget + '/' + userid,
181
-     contentType: 'application/json',
182
-     success: function(settingsfromdb) {
183
-         $("#telapi_key").val(settingsfromdb.telapi_key);
184
-         $("#tel_pub_key").val(settingsfromdb.tel_pub_key);
185
-         $("#telapi_url_rec").val(settingsfromdb.telapi_url_rec);
186
-         $("#telapi_url").val(settingsfromdb.telapi_url);
187
-         $("#messaging_profile_id").val(settingsfromdb.messaging_profile_id);
188
-         $("#nexapi_key").val(settingsfromdb.nexapi_key);
189
-         $("#nexapi_secret").val(settingsfromdb.nexapi_secret);
190
-         $("#nexapi_url_rec").val(settingsfromdb.nexapi_url_rec);
191
-         $("#nexapi_url").val(settingsfromdb.nexapi_url);
192
-         $("#tel_sender_name").val(settingsfromdb.tel_sender_name);
193
-         $("#nex_sender_name").val(settingsfromdb.nex_sender_name);
194
-         $("#messagesperpage").val(settingsfromdb.messagesperpage);
195
-
196
-         if (settingsfromdb.get_notify == 1) {
197
-             $("#get_notify").attr('checked', true);
198
-         } else {
199
-             $("#get_notify").attr('checked', false);
200
-         }
201
-
202
-         $("#notification_email").val(settingsfromdb.notification_email);
203
-
204
-         if (settingsfromdb.getsmsinemail == 1) {
205
-             $("#includesmsinemail").attr('checked', true);
206
-         } else {
207
-             $("#includesmsinemail").attr('checked', false);
208
-         }
209
-     }
210
-  });
211
-
212
-});
Browse code

added CHANGELOG.txt appinfo/info.xml appinfo/signature.json lib/Migration/Version105Date20220509201842.php lib/Service/SmsrelentlessService.php lib/Controller/AuthorApiController.php lib/Controller/SmsrelentlessController.php js/settings.js

DoubleBastionAdmin authored on 09/05/2022 15:12:45
Showing 1 changed files
1 1
new file mode 100644
... ...
@@ -0,0 +1,212 @@
1
+/**
2
+ * @copyright 2021 Double Bastion LLC <www.doublebastion.com>
3
+ *
4
+ * @author Double Bastion LLC
5
+ *
6
+ * @license GNU AGPL version 3 or any later version
7
+ *
8
+ * This program is free software; you can redistribute it and/or
9
+ * modify it under the terms of the GNU AFFERO GENERAL PUBLIC LICENSE
10
+ * License as published by the Free Software Foundation; either
11
+ * version 3 of the License, or any later version.
12
+ *
13
+ * This program is distributed in the hope that it will be useful,
14
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
15
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
16
+ * GNU AFFERO GENERAL PUBLIC LICENSE for more details.
17
+ *
18
+ * You should have received a copy of the GNU Affero General Public
19
+ * License along with this program.  If not, see <http://www.gnu.org/licenses/>.
20
+ *
21
+ */
22
+
23
+$(document).ready(function() {
24
+
25
+  var userid = "<?php p($userId); ?>";
26
+  var strlength;
27
+
28
+  function randomStr(strlength) {
29
+        var fintext = "";
30
+        var keyspace = '0123456789abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ';
31
+        for (var i = 0; i < strlength; i++) {
32
+             fintext += keyspace.charAt(Math.floor(Math.random() * keyspace.length));
33
+        }
34
+        return fintext;
35
+  }
36
+
37
+  $("#generate_tel_rcpt").on("click", function(event) {
38
+     var teltokenrec = randomStr(70);
39
+     var telnyxwhurlrec = window.location.origin + OC.generateUrl('/apps/sms_relentless/api/recsmstel?telrecparam=') + teltokenrec;
40
+
41
+     $("#telapi_url_rec").val(telnyxwhurlrec);
42
+  });
43
+
44
+  $("#copyToClipboardtel").on("click", function(event) {
45
+     var $tempEl = $("<input>");
46
+     $("body").append($tempEl);
47
+     $tempEl.val($("#telapi_url_rec").val()).select();
48
+     document.execCommand("Copy");
49
+     $tempEl.remove();
50
+     alert("The link has been copied to your clipboard!");
51
+  });
52
+
53
+  $("#generate_tel_delrcpt").on("click", function(event) {
54
+
55
+     var teltoken = randomStr(70);
56
+     var telnyxwhurl = window.location.origin + OC.generateUrl('/apps/sms_relentless/api/recdeliverytel?teldrparam=') + teltoken;
57
+
58
+     $("#telapi_url").val(telnyxwhurl);
59
+  });
60
+
61
+
62
+  $("#generate_nex_rcpt").on("click", function(event) {
63
+
64
+     var plivotokenrec = randomStr(70);
65
+
66
+     var plivowhurlrec = window.location.origin + OC.generateUrl('/apps/sms_relentless/api/recsmsnex?plivorecparam=') + plivotokenrec;
67
+
68
+     $("#nexapi_url_rec").val(plivowhurlrec);
69
+  });
70
+
71
+  $("#copyToClipboardnex").on("click", function(event) {
72
+     var $tempElpl = $("<input>");
73
+     $("body").append($tempElpl);
74
+     $tempElpl.val($("#nexapi_url_rec").val()).select();
75
+     document.execCommand("Copy");
76
+     $tempElpl.remove();
77
+     alert("The link has been copied to your clipboard!");
78
+  });
79
+
80
+  $("#generate_nex_delrcpt").on("click", function(event) {
81
+
82
+     var plivotoken = randomStr(70);
83
+     var plivodrwhurl = window.location.origin + OC.generateUrl('/apps/sms_relentless/api/recdeliverynex?plivodrparam=') + plivotoken;
84
+
85
+     $("#nexapi_url").val(plivodrwhurl);
86
+  });
87
+
88
+
89
+  $("#save_sms_settings").on("click", function(event) {
90
+
91
+    event.preventDefault();
92
+    OC.msg.startAction('#smsr_save_msg', t('sms_relentless', 'Saved'));
93
+
94
+    var baseUrl = OC.generateUrl('/apps/sms_relentless/user/updatesettings');
95
+
96
+    var messagesperpageinit = $("#messagesperpage").val();
97
+    var messagesperpagesec = messagesperpageinit.replace(/[^0-9]/g, '');
98
+
99
+    if (messagesperpagesec != '') {
100
+        var messagesperpageproc = messagesperpagesec;
101
+    } else {
102
+        var messagesperpageproc = 100;
103
+    }
104
+
105
+    var getnotify = 0;
106
+
107
+    if ($("#get_notify").is(':checked')) {
108
+        getnotify = 1;
109
+    }
110
+
111
+    var telnyxemailinit = $("#telnyx_email").val();
112
+    var emailaddressinit = $("#notification_email").val();
113
+
114
+    function validate_email($email) {
115
+        var email_reg = /^([\w-\.]+@([\w-]+\.)+[\w-]{2,4})?$/;
116
+        return email_reg.test($email);
117
+    }
118
+
119
+    if (validate_email(telnyxemailinit)) {
120
+         var telnyxemail = telnyxemailinit;
121
+    } else {
122
+         var telnyxemail = '';
123
+    }
124
+
125
+    if (validate_email(emailaddressinit)) {
126
+         var notifyemail = emailaddressinit;
127
+    } else {
128
+         var notifyemail = '';
129
+    }
130
+
131
+    var telsenderinit = $("#tel_sender_name").val();
132
+    var telsenderproc = telsenderinit.replace(/[^A-Za-z 0-9]/g, '');
133
+
134
+    var nexsenderinit = $("#nex_sender_name").val();
135
+    var nexsenderproc = nexsenderinit.replace(/[^A-Za-z 0-9]/g, '');
136
+
137
+    var includesmsinemail = 0;
138
+
139
+    if ($("#includesmsinemail").is(':checked')) {
140
+        includesmsinemail = 1;
141
+    }
142
+
143
+    var datatosave = {
144
+                      userId: userid,
145
+                      telapiKey: $("#telapi_key").val(),
146
+                      telPubKey: $("#tel_pub_key").val(),
147
+                      telapiUrlRec: $("#telapi_url_rec").val(),
148
+                      telapiUrl: $("#telapi_url").val(),
149
+                      messagingProfileId: $("#messaging_profile_id").val(),
150
+                      nexapiKey: $("#nexapi_key").val(),
151
+                      nexapiSecret: $("#nexapi_secret").val(),
152
+                      nexapiUrlRec: $("#nexapi_url_rec").val(),
153
+                      nexapiUrl: $("#nexapi_url").val(),
154
+                      telSenderName: telsenderproc,
155
+                      nexSenderName: nexsenderproc,
156
+                      messagesperpage: messagesperpageproc,
157
+                      getNotify: getnotify,
158
+                      notificationEmail: notifyemail,
159
+                      getsmsinemail: includesmsinemail
160
+    };
161
+
162
+
163
+    $.ajax({
164
+       method: 'PUT',
165
+       url: baseUrl + '/' + userid,
166
+       contentType: 'application/json',
167
+       data: JSON.stringify(datatosave),
168
+       error: function(resp) {
169
+            alert('Error ! Please check your settings !');
170
+       }
171
+    });
172
+
173
+  });
174
+
175
+
176
+  var baseUrlget = OC.generateUrl('/apps/sms_relentless/user/getsettings');
177
+
178
+  $.ajax({
179
+     method: 'GET',
180
+     url: baseUrlget + '/' + userid,
181
+     contentType: 'application/json',
182
+     success: function(settingsfromdb) {
183
+         $("#telapi_key").val(settingsfromdb.telapi_key);
184
+         $("#tel_pub_key").val(settingsfromdb.tel_pub_key);
185
+         $("#telapi_url_rec").val(settingsfromdb.telapi_url_rec);
186
+         $("#telapi_url").val(settingsfromdb.telapi_url);
187
+         $("#messaging_profile_id").val(settingsfromdb.messaging_profile_id);
188
+         $("#nexapi_key").val(settingsfromdb.nexapi_key);
189
+         $("#nexapi_secret").val(settingsfromdb.nexapi_secret);
190
+         $("#nexapi_url_rec").val(settingsfromdb.nexapi_url_rec);
191
+         $("#nexapi_url").val(settingsfromdb.nexapi_url);
192
+         $("#tel_sender_name").val(settingsfromdb.tel_sender_name);
193
+         $("#nex_sender_name").val(settingsfromdb.nex_sender_name);
194
+         $("#messagesperpage").val(settingsfromdb.messagesperpage);
195
+
196
+         if (settingsfromdb.get_notify == 1) {
197
+             $("#get_notify").attr('checked', true);
198
+         } else {
199
+             $("#get_notify").attr('checked', false);
200
+         }
201
+
202
+         $("#notification_email").val(settingsfromdb.notification_email);
203
+
204
+         if (settingsfromdb.getsmsinemail == 1) {
205
+             $("#includesmsinemail").attr('checked', true);
206
+         } else {
207
+             $("#includesmsinemail").attr('checked', false);
208
+         }
209
+     }
210
+  });
211
+
212
+});
Browse code

removed CHANGELOG.txt appinfo/info.xml appinfo/signature.json lib/Migration/Version104Date20220507234521.php lib/Service/SmsrelentlessService.php lib/Controller/AuthorApiController.php lib/Controller/SmsrelentlessController.php js/settings.js

DoubleBastionAdmin authored on 09/05/2022 15:03:46
Showing 1 changed files
1 1
deleted file mode 100644
... ...
@@ -1,212 +0,0 @@
1
-/**
2
- * @copyright 2021 Double Bastion LLC <www.doublebastion.com>
3
- *
4
- * @author Double Bastion LLC
5
- *
6
- * @license GNU AGPL version 3 or any later version
7
- *
8
- * This program is free software; you can redistribute it and/or
9
- * modify it under the terms of the GNU AFFERO GENERAL PUBLIC LICENSE
10
- * License as published by the Free Software Foundation; either
11
- * version 3 of the License, or any later version.
12
- *
13
- * This program is distributed in the hope that it will be useful,
14
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
15
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
16
- * GNU AFFERO GENERAL PUBLIC LICENSE for more details.
17
- *
18
- * You should have received a copy of the GNU Affero General Public
19
- * License along with this program.  If not, see <http://www.gnu.org/licenses/>.
20
- *
21
- */
22
-
23
-$(document).ready(function() {
24
-
25
-  var userid = "<?php p($userId); ?>";
26
-  var strlength;
27
-
28
-  function randomStr(strlength) {
29
-        var fintext = "";
30
-        var keyspace = '0123456789abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ';
31
-        for (var i = 0; i < strlength; i++) {
32
-             fintext += keyspace.charAt(Math.floor(Math.random() * keyspace.length));
33
-        }
34
-        return fintext;
35
-  }
36
-
37
-  $("#generate_tel_rcpt").on("click", function(event) {
38
-     var teltokenrec = randomStr(70);
39
-     var telnyxwhurlrec = 'https://'+window.location.host+'/apps/sms_relentless/api/recsmstel?telrecparam='+teltokenrec;
40
-     $("#telapi_url_rec").val(telnyxwhurlrec);
41
-  });
42
-
43
-  $("#copyToClipboardtel").on("click", function(event) {
44
-     var $tempEl = $("<input>");
45
-     $("body").append($tempEl);
46
-     $tempEl.val($("#telapi_url_rec").val()).select();
47
-     document.execCommand("Copy");
48
-     $tempEl.remove();
49
-     alert("The link has been copied to your clipboard!");
50
-  });
51
-
52
-  $("#generate_tel_delrcpt").on("click", function(event) {
53
-
54
-     var teltoken = randomStr(70);
55
-     var telnyxwhurl = 'https://'+window.location.host+'/apps/sms_relentless/api/recdeliverytel?teldrparam='+teltoken;
56
-
57
-     $("#telapi_url").val(telnyxwhurl);
58
-  });
59
-
60
-
61
-  $("#generate_nex_rcpt").on("click", function(event) {
62
-
63
-     var plivotokenrec = randomStr(70);
64
-
65
-     var plivowhurlrec = 'https://'+window.location.host+'/apps/sms_relentless/api/recsmsnex?plivorecparam='+plivotokenrec;
66
-
67
-     $("#nexapi_url_rec").val(plivowhurlrec);
68
-  });
69
-
70
-  $("#copyToClipboardnex").on("click", function(event) {
71
-     var $tempElpl = $("<input>");
72
-     $("body").append($tempElpl);
73
-     $tempElpl.val($("#nexapi_url_rec").val()).select();
74
-     document.execCommand("Copy");
75
-     $tempElpl.remove();
76
-     alert("The link has been copied to your clipboard!");
77
-  });
78
-
79
-  $("#generate_nex_delrcpt").on("click", function(event) {
80
-
81
-     var plivotoken = randomStr(70);
82
-     var plivodrwhurl = 'https://'+window.location.host+'/apps/sms_relentless/api/recdeliverynex?plivodrparam='+plivotoken;
83
-
84
-     $("#nexapi_url").val(plivodrwhurl);
85
-  });
86
-
87
-
88
-  $("#save_sms_settings").on("click", function(event) {
89
-
90
-    event.preventDefault();
91
-    OC.msg.startAction('#smsr_save_msg', t('sms_relentless', 'Saved'));
92
-
93
-    var baseUrl = OC.generateUrl('/apps/sms_relentless/user/updatesettings');
94
-
95
-    var messagesperpageinit = $("#messagesperpage").val();
96
-    var messagesperpagesec = messagesperpageinit.replace(/[^0-9]/g, '');
97
-
98
-    if (messagesperpagesec != '') {
99
-        var messagesperpageproc = messagesperpagesec;
100
-    } else {
101
-        alert('Please enter a valid natural number in the "Number of messages per page" field. Otherwise, the default of 100 will be used.');
102
-        var messagesperpageproc = 100;
103
-    }
104
-
105
-    var getnotify = 0;
106
-
107
-    if ($("#get_notify").is(':checked')) {
108
-        getnotify = 1;
109
-    }
110
-
111
-    var telnyxemailinit = $("#telnyx_email").val();
112
-    var emailaddressinit = $("#notification_email").val();
113
-
114
-    function validate_email($email) {
115
-        var email_reg = /^([\w-\.]+@([\w-]+\.)+[\w-]{2,4})?$/;
116
-        return email_reg.test($email);
117
-    }
118
-
119
-    if (validate_email(telnyxemailinit)) {
120
-         var telnyxemail = telnyxemailinit;
121
-    } else {
122
-         var telnyxemail = '';
123
-    }
124
-
125
-    if (validate_email(emailaddressinit)) {
126
-         var notifyemail = emailaddressinit;
127
-    } else {
128
-         var notifyemail = '';
129
-    }
130
-
131
-    var telsenderinit = $("#tel_sender_name").val();
132
-    var telsenderproc = telsenderinit.replace(/[^A-Za-z 0-9]/g, '');
133
-
134
-    var nexsenderinit = $("#nex_sender_name").val();
135
-    var nexsenderproc = nexsenderinit.replace(/[^A-Za-z 0-9]/g, '');
136
-
137
-    var includesmsinemail = 0;
138
-
139
-    if ($("#includesmsinemail").is(':checked')) {
140
-        includesmsinemail = 1;
141
-    }
142
-
143
-    var datatosave = {
144
-                      userId: userid,
145
-                      telapiKey: $("#telapi_key").val(),
146
-                      telPubKey: $("#tel_pub_key").val(),
147
-                      telapiUrlRec: $("#telapi_url_rec").val(),
148
-                      telapiUrl: $("#telapi_url").val(),
149
-                      messagingProfileId: $("#messaging_profile_id").val(),
150
-                      nexapiKey: $("#nexapi_key").val(),
151
-                      nexapiSecret: $("#nexapi_secret").val(),
152
-                      nexapiUrlRec: $("#nexapi_url_rec").val(),
153
-                      nexapiUrl: $("#nexapi_url").val(),
154
-                      telSenderName: telsenderproc,
155
-                      nexSenderName: nexsenderproc,
156
-                      messagesperpage: messagesperpageproc,
157
-                      getNotify: getnotify,
158
-                      notificationEmail: notifyemail,
159
-                      getsmsinemail: includesmsinemail
160
-    };
161
-
162
-
163
-    $.ajax({
164
-       method: 'PUT',
165
-       url: baseUrl + '/' + userid,
166
-       contentType: 'application/json',
167
-       data: JSON.stringify(datatosave),
168
-       error: function(resp) {
169
-            alert('Error ! Please check your settings !');
170
-       }
171
-    });
172
-
173
-  });
174
-
175
-
176
-  var baseUrlget = OC.generateUrl('/apps/sms_relentless/user/getsettings');
177
-
178
-  $.ajax({
179
-     method: 'GET',
180
-     url: baseUrlget + '/' + userid,
181
-     contentType: 'application/json',
182
-     success: function(settingsfromdb) {
183
-         $("#telapi_key").val(settingsfromdb.telapi_key);
184
-         $("#tel_pub_key").val(settingsfromdb.tel_pub_key);
185
-         $("#telapi_url_rec").val(settingsfromdb.telapi_url_rec);
186
-         $("#telapi_url").val(settingsfromdb.telapi_url);
187
-         $("#messaging_profile_id").val(settingsfromdb.messaging_profile_id);
188
-         $("#nexapi_key").val(settingsfromdb.nexapi_key);
189
-         $("#nexapi_secret").val(settingsfromdb.nexapi_secret);
190
-         $("#nexapi_url_rec").val(settingsfromdb.nexapi_url_rec);
191
-         $("#nexapi_url").val(settingsfromdb.nexapi_url);
192
-         $("#tel_sender_name").val(settingsfromdb.tel_sender_name);
193
-         $("#nex_sender_name").val(settingsfromdb.nex_sender_name);
194
-         $("#messagesperpage").val(settingsfromdb.messagesperpage);
195
-
196
-         if (settingsfromdb.get_notify == 1) {
197
-             $("#get_notify").attr('checked', true);
198
-         } else {
199
-             $("#get_notify").attr('checked', false);
200
-         }
201
-
202
-         $("#notification_email").val(settingsfromdb.notification_email);
203
-
204
-         if (settingsfromdb.getsmsinemail == 1) {
205
-             $("#includesmsinemail").attr('checked', true);
206
-         } else {
207
-             $("#includesmsinemail").attr('checked', false);
208
-         }
209
-     }
210
-  });
211
-
212
-});
Browse code

Created repository.

DoubleBastionAdmin authored on 01/03/2022 23:47:00
Showing 1 changed files
1 1
new file mode 100644
... ...
@@ -0,0 +1,212 @@
1
+/**
2
+ * @copyright 2021 Double Bastion LLC <www.doublebastion.com>
3
+ *
4
+ * @author Double Bastion LLC
5
+ *
6
+ * @license GNU AGPL version 3 or any later version
7
+ *
8
+ * This program is free software; you can redistribute it and/or
9
+ * modify it under the terms of the GNU AFFERO GENERAL PUBLIC LICENSE
10
+ * License as published by the Free Software Foundation; either
11
+ * version 3 of the License, or any later version.
12
+ *
13
+ * This program is distributed in the hope that it will be useful,
14
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
15
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
16
+ * GNU AFFERO GENERAL PUBLIC LICENSE for more details.
17
+ *
18
+ * You should have received a copy of the GNU Affero General Public
19
+ * License along with this program.  If not, see <http://www.gnu.org/licenses/>.
20
+ *
21
+ */
22
+
23
+$(document).ready(function() {
24
+
25
+  var userid = "<?php p($userId); ?>";
26
+  var strlength;
27
+
28
+  function randomStr(strlength) {
29
+        var fintext = "";
30
+        var keyspace = '0123456789abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ';
31
+        for (var i = 0; i < strlength; i++) {
32
+             fintext += keyspace.charAt(Math.floor(Math.random() * keyspace.length));
33
+        }
34
+        return fintext;
35
+  }
36
+
37
+  $("#generate_tel_rcpt").on("click", function(event) {
38
+     var teltokenrec = randomStr(70);
39
+     var telnyxwhurlrec = 'https://'+window.location.host+'/apps/sms_relentless/api/recsmstel?telrecparam='+teltokenrec;
40
+     $("#telapi_url_rec").val(telnyxwhurlrec);
41
+  });
42
+
43
+  $("#copyToClipboardtel").on("click", function(event) {
44
+     var $tempEl = $("<input>");
45
+     $("body").append($tempEl);
46
+     $tempEl.val($("#telapi_url_rec").val()).select();
47
+     document.execCommand("Copy");
48
+     $tempEl.remove();
49
+     alert("The link has been copied to your clipboard!");
50
+  });
51
+
52
+  $("#generate_tel_delrcpt").on("click", function(event) {
53
+
54
+     var teltoken = randomStr(70);
55
+     var telnyxwhurl = 'https://'+window.location.host+'/apps/sms_relentless/api/recdeliverytel?teldrparam='+teltoken;
56
+
57
+     $("#telapi_url").val(telnyxwhurl);
58
+  });
59
+
60
+
61
+  $("#generate_nex_rcpt").on("click", function(event) {
62
+
63
+     var plivotokenrec = randomStr(70);
64
+
65
+     var plivowhurlrec = 'https://'+window.location.host+'/apps/sms_relentless/api/recsmsnex?plivorecparam='+plivotokenrec;
66
+
67
+     $("#nexapi_url_rec").val(plivowhurlrec);
68
+  });
69
+
70
+  $("#copyToClipboardnex").on("click", function(event) {
71
+     var $tempElpl = $("<input>");
72
+     $("body").append($tempElpl);
73
+     $tempElpl.val($("#nexapi_url_rec").val()).select();
74
+     document.execCommand("Copy");
75
+     $tempElpl.remove();
76
+     alert("The link has been copied to your clipboard!");
77
+  });
78
+
79
+  $("#generate_nex_delrcpt").on("click", function(event) {
80
+
81
+     var plivotoken = randomStr(70);
82
+     var plivodrwhurl = 'https://'+window.location.host+'/apps/sms_relentless/api/recdeliverynex?plivodrparam='+plivotoken;
83
+
84
+     $("#nexapi_url").val(plivodrwhurl);
85
+  });
86
+
87
+
88
+  $("#save_sms_settings").on("click", function(event) {
89
+
90
+    event.preventDefault();
91
+    OC.msg.startAction('#smsr_save_msg', t('sms_relentless', 'Saved'));
92
+
93
+    var baseUrl = OC.generateUrl('/apps/sms_relentless/user/updatesettings');
94
+
95
+    var messagesperpageinit = $("#messagesperpage").val();
96
+    var messagesperpagesec = messagesperpageinit.replace(/[^0-9]/g, '');
97
+
98
+    if (messagesperpagesec != '') {
99
+        var messagesperpageproc = messagesperpagesec;
100
+    } else {
101
+        alert('Please enter a valid natural number in the "Number of messages per page" field. Otherwise, the default of 100 will be used.');
102
+        var messagesperpageproc = 100;
103
+    }
104
+
105
+    var getnotify = 0;
106
+
107
+    if ($("#get_notify").is(':checked')) {
108
+        getnotify = 1;
109
+    }
110
+
111
+    var telnyxemailinit = $("#telnyx_email").val();
112
+    var emailaddressinit = $("#notification_email").val();
113
+
114
+    function validate_email($email) {
115
+        var email_reg = /^([\w-\.]+@([\w-]+\.)+[\w-]{2,4})?$/;
116
+        return email_reg.test($email);
117
+    }
118
+
119
+    if (validate_email(telnyxemailinit)) {
120
+         var telnyxemail = telnyxemailinit;
121
+    } else {
122
+         var telnyxemail = '';
123
+    }
124
+
125
+    if (validate_email(emailaddressinit)) {
126
+         var notifyemail = emailaddressinit;
127
+    } else {
128
+         var notifyemail = '';
129
+    }
130
+
131
+    var telsenderinit = $("#tel_sender_name").val();
132
+    var telsenderproc = telsenderinit.replace(/[^A-Za-z 0-9]/g, '');
133
+
134
+    var nexsenderinit = $("#nex_sender_name").val();
135
+    var nexsenderproc = nexsenderinit.replace(/[^A-Za-z 0-9]/g, '');
136
+
137
+    var includesmsinemail = 0;
138
+
139
+    if ($("#includesmsinemail").is(':checked')) {
140
+        includesmsinemail = 1;
141
+    }
142
+
143
+    var datatosave = {
144
+                      userId: userid,
145
+                      telapiKey: $("#telapi_key").val(),
146
+                      telPubKey: $("#tel_pub_key").val(),
147
+                      telapiUrlRec: $("#telapi_url_rec").val(),
148
+                      telapiUrl: $("#telapi_url").val(),
149
+                      messagingProfileId: $("#messaging_profile_id").val(),
150
+                      nexapiKey: $("#nexapi_key").val(),
151
+                      nexapiSecret: $("#nexapi_secret").val(),
152
+                      nexapiUrlRec: $("#nexapi_url_rec").val(),
153
+                      nexapiUrl: $("#nexapi_url").val(),
154
+                      telSenderName: telsenderproc,
155
+                      nexSenderName: nexsenderproc,
156
+                      messagesperpage: messagesperpageproc,
157
+                      getNotify: getnotify,
158
+                      notificationEmail: notifyemail,
159
+                      getsmsinemail: includesmsinemail
160
+    };
161
+
162
+
163
+    $.ajax({
164
+       method: 'PUT',
165
+       url: baseUrl + '/' + userid,
166
+       contentType: 'application/json',
167
+       data: JSON.stringify(datatosave),
168
+       error: function(resp) {
169
+            alert('Error ! Please check your settings !');
170
+       }
171
+    });
172
+
173
+  });
174
+
175
+
176
+  var baseUrlget = OC.generateUrl('/apps/sms_relentless/user/getsettings');
177
+
178
+  $.ajax({
179
+     method: 'GET',
180
+     url: baseUrlget + '/' + userid,
181
+     contentType: 'application/json',
182
+     success: function(settingsfromdb) {
183
+         $("#telapi_key").val(settingsfromdb.telapi_key);
184
+         $("#tel_pub_key").val(settingsfromdb.tel_pub_key);
185
+         $("#telapi_url_rec").val(settingsfromdb.telapi_url_rec);
186
+         $("#telapi_url").val(settingsfromdb.telapi_url);
187
+         $("#messaging_profile_id").val(settingsfromdb.messaging_profile_id);
188
+         $("#nexapi_key").val(settingsfromdb.nexapi_key);
189
+         $("#nexapi_secret").val(settingsfromdb.nexapi_secret);
190
+         $("#nexapi_url_rec").val(settingsfromdb.nexapi_url_rec);
191
+         $("#nexapi_url").val(settingsfromdb.nexapi_url);
192
+         $("#tel_sender_name").val(settingsfromdb.tel_sender_name);
193
+         $("#nex_sender_name").val(settingsfromdb.nex_sender_name);
194
+         $("#messagesperpage").val(settingsfromdb.messagesperpage);
195
+
196
+         if (settingsfromdb.get_notify == 1) {
197
+             $("#get_notify").attr('checked', true);
198
+         } else {
199
+             $("#get_notify").attr('checked', false);
200
+         }
201
+
202
+         $("#notification_email").val(settingsfromdb.notification_email);
203
+
204
+         if (settingsfromdb.getsmsinemail == 1) {
205
+             $("#includesmsinemail").attr('checked', true);
206
+         } else {
207
+             $("#includesmsinemail").attr('checked', false);
208
+         }
209
+     }
210
+  });
211
+
212
+});