-
Notifications
You must be signed in to change notification settings - Fork 5
Expand file tree
/
Copy pathmessageUI.php
More file actions
479 lines (460 loc) · 22.7 KB
/
Copy pathmessageUI.php
File metadata and controls
479 lines (460 loc) · 22.7 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
<?php
/**
* Fax SMS Module Member
*
* @package OpenEMR
* @link http://www.open-emr.org
* @author Jerry Padgett <sjpadgett@gmail.com>
* @copyright Copyright (c) 2018-2019 Jerry Padgett <sjpadgett@gmail.com>
* @license https://github.com/openemr/openemr/blob/master/LICENSE GNU General Public License 3
*/
require_once(__DIR__ . "/../../../globals.php");
use OpenEMR\Core\Header;
use OpenEMR\Modules\FaxSMS\Controllers\AppDispatch;
$clientApp = AppDispatch::getApiService();
$logged_in = $clientApp->authenticate();
$service = $clientApp::getServiceType();
$title = $service == "1" ? 'RingCentral' : 'Twilio';
?>
<!DOCTYPE html>
<html>
<head>
<title><?php echo xlt('Fax Module'); ?></title>
<link rel="stylesheet" href="<?php echo $GLOBALS['assets_static_relative']; ?>/dropzone/dist/dropzone.css">
<?php
Header::setupHeader(['opener', 'datetime-picker']);
echo "<script>var pid=" . js_escape($pid) . ";var portalUrl=" . js_escape($clientApp->portalUrl) .
";var Service=" . js_escape($service) . ";</script>";
?>
<script type="text/javascript" src="<?php echo $GLOBALS['assets_static_relative']; ?>/dropzone/dist/dropzone.js"></script>
<script>
const queueMsg = '' + <?php echo xlj('Fax Queue. Drop files or Click here to Fax.') ?>;
Dropzone.autoDiscover = false;
$(function () {
fileTypes = '';
if (Service === '2') {
fileTypes = 'application/pdf';
}
var faxQueue = new Dropzone("#faxQueue", {
paramName: 'fax',
url: 'faxProcessUploads',
dictDefaultMessage: queueMsg,
clickable: true,
enqueueForUpload: true,
maxFilesize: 25,
acceptedFiles: fileTypes,
uploadMultiple: false,
addRemoveLinks: true,
init: function (e) {
let ofile = '';
this.on("addedfile", function (file) {
console.log('new file added ', file);
ofile = file;
});
this.on("sending", function (file) {
console.log('upload started ', file);
$('.meter').show();
});
this.on("success", function (file, response) {
let thisFile = response;
console.log('upload success ', thisFile);
sendFax(thisFile, 'queue');
});
this.on("queuecomplete", function (progress) {
$('.meter').delay(999).slideUp(999);
});
this.on("removedfile", function (file) {
console.log(file);
});
}
});
});
$(function () {
$('.datepicker').datetimepicker({
<?php
$datetimepicker_timepicker = false;
$datetimepicker_showseconds = false;
$datetimepicker_formatInput = false;
require($GLOBALS['srcdir'] . '/js/xl/jquery-datetimepicker-2-5-4.js.php');
?>
});
var dateRange = new Date(new Date().setDate(new Date().getDate() - 7));
$("#fromdate").val(dateRange.toJSON().slice(0, 10));
$("#todate").val(new Date().toJSON().slice(0, 10));
if (Service === '2') {
$(".ringcentral").hide();
} else {
$(".twilio").hide();
}
// populate
retrieveMsgs();
$('#received').tab('show');
});
var wait = '<span id="wait"><?php echo xlt("Fetching Remote") . '..';?><i class="fa fa-cog fa-spin fa-2x"></i></span>';
var sendFax = function (filePath, from = '') {
let btnClose = <?php echo xlj("Cancel"); ?>;
let title = <?php echo xlj("Send To Contact"); ?>;
let url = top.webroot_url + '/interface/modules/custom_modules/oe-module-faxsms/contact.php?isDocuments=false&isQueue=' +
encodeURIComponent(from) + '&file=' + filePath; // do not encode filePath
// leave dialog name param empty so send dialogs can cascade.
dlgopen(url, '', 'modal-md', 250, '', title, { // dialog restores session
buttons: [
{text: btnClose, close: true, style: 'default btn-sm'}
]
});
};
var docInfo = function (e, ppath) {
top.restoreSession();
let msg = <?php echo xlj('Your Account Portal') ?>;
dlgopen(ppath, '_blank', 1240, 900, true, msg)
};
var popNotify = function (e, ppath) {
top.restoreSession();
let msg = <?php echo xlj('Are you sure you wish to send all scheduled reminders now.') ?>;
if (e === 'live') {
let yn = confirm(msg);
if (!yn) return false;
}
let msg1 = <?php echo xlj('Appointment Reminder Alerts') ?>;
dlgopen(ppath, '_blank', 1240, 900, true, msg1)
};
var doSetup = function (e) {
top.restoreSession();
e.preventDefault();
let msg = <?php echo xlj('Credentials and SMS Notifications') ?>;
dlgopen('', 'setup', 'modal-md', 500, '', msg, {
buttons: [
{text: 'Cancel', close: true, style: 'default btn-sm'}
],
url: 'setup.php'
});
};
// For use with window cascade popup Twilio
function viewDocument(e = '', docuri) {
top.restoreSession();
if (e) {
e.preventDefault();
}
let width = window.innerWidth ? window.innerWidth : document.documentElement.clientWidth ?
document.documentElement.clientWidth : screen.width;
let height = window.innerHeight ? window.innerHeight : document.documentElement.clientHeight ?
document.documentElement.clientHeight : screen.height;
height = screen.height ? screen.height * 0.95 : height;
cascwin(docuri, '', width / 2, (height), "resizable=1,scrollbars=1,location=0,toolbar=0");
}
function getDocument(e, docuri, docid, downFlag) {
top.restoreSession();
e.preventDefault();
let wait = '<span id="wait"><?php echo xlt("Fetching Document") . '..';?><i class="fa fa-cog fa-spin fa-2x"></i></span>';
let actionUrl = 'viewFax';
$("#brand").addClass('fa-spin');
return $.post(actionUrl, {
'docuri': docuri,
'docid': docid,
'pid': pid,
'download': downFlag
}).done(function (data) {
$("#brand").removeClass('fa-spin');
if (downFlag === 'true') {
location.href = "disposeDoc";
return false;
}
viewDocument('', data);
});
}
// Fax and SMS status
function retrieveMsgs(e = '', req = '') {
top.restoreSession();
if (e) {
e.preventDefault();
}
let actionUrl = 'getPending';
let id = pid;
let datefrom = $('#fromdate').val();
let dateto = $('#todate').val();
let data = [];
$("#brand").addClass('fa-spin');
$("#rcvdetails tbody").empty();
$("#sentdetails tbody").empty();
$("#msgdetails tbody").empty();
return $.post(actionUrl,
{
'pid': pid,
'datefrom': datefrom,
'dateto': dateto
}, function () {
}, 'json').done(function (data) {
if (data.error) {
$("#brand").removeClass('fa-spin');
alertMsg(data.error);
return false;
}
// populate our panels
$("#rcvdetails tbody").empty().append(data[0]);
$("#sentdetails tbody").empty().append(data[1]);
$("#msgdetails tbody").empty().append(data[2]);
// get call logs
getLogs();
}).fail(function (xhr, status, error) {
alertMsg(<?php echo xlj('Not Authenticated. Restart from Modules menu or ensure credentials are setup from Activity menu.') ?>, 5000)
}).always(function () {
$("#brand").removeClass('fa-spin');
});
}
// Our Call Logs.
function getLogs() {
top.restoreSession();
let actionUrl = 'getCallLogs';
let id = pid;
let datefrom = $('#fromdate').val();
let dateto = $('#todate').val();
$("#brand").addClass('fa-spin');
return $.post(actionUrl, {
'pid': pid,
'datefrom': datefrom,
'dateto': dateto
}).done(function (data) {
var err = (data.search(/Exception/) !== -1 ? 1 : 0);
if (!err) {
err = (data.search(/Error:/) !== -1 ? 1 : 0);
}
if (err) {
alertMsg(data);
}
$("#logdetails tbody").empty().append(data);
// Get SMS appointments notifications
getNotificationLog();
}).always(function () {
$("#brand").removeClass('fa-spin');
});
}
function getNotificationLog() {
top.restoreSession();
let actionUrl = 'getNotificationLog';
let id = pid;
let datefrom = $('#fromdate').val() + " 00:00:00";
let dateto = $('#todate').val() + " 23:59:59";
$("#brand").addClass('fa-spin');
return $.post(actionUrl, {
'pid': pid,
'datefrom': datefrom,
'dateto': dateto
}).done(function (data) {
var err = (data.search(/Exception/) !== -1 ? 1 : 0);
if (!err) {
err = (data.search(/Error:/) !== -1 ? 1 : 0);
}
if (err) {
alertMsg(data);
}
$("#alertdetails tbody").empty().append(data);
}).always(function () {
$("#brand").removeClass('fa-spin');
});
}
function getSelResource() {
return $('#resource option:selected').val();
}
</script>
<style>
</style>
</head>
<body>
<nav class="navbar navbar-default navbar-fixed-top">
<div class="container">
<div class="navbar-header">
<button type="button" class="navbar-toggle collapsed" data-toggle="collapse" data-target="#nav-header-collapse">
<span class="sr-only"><?php echo xlt('Toggle'); ?></span>
<span class="icon-bar"></span>
<span class="icon-bar"></span>
<span class="icon-bar"></span>
</button>
<a class="navbar-brand" href="#">
<?php echo "Fax SMS ($title)"; ?>
</a>
</div>
<div class="collapse navbar-collapse" id="nav-header-collapse">
<form class="navbar-form navbar-left form-inline" method="GET" role="search">
<div class="form-group">
<label for="formdate"><?php echo xlt('Activities From Date:') ?></label>
<input type="text" id="fromdate" name="fromdate" class="form-control input-sm datepicker" placeholder="YYYY-MM-DD" value=''>
</div>
<div class="form-group">
<label for="todate"><?php echo xlt('To Date:') ?></label>
<input type="text" id="todate" name="todate" class="form-control input-sm datepicker" placeholder="YYYY-MM-DD" value=''>
</div>
<div class="form-group">
<button type="button" class="btn btn-default" onclick="retrieveMsgs(event,this)" title="<?php echo xla('Click to get current history.') ?>">
<i id="brand" class="fa fa-refresh"></i></button>
<span ></span>
</div>
</form>
<ul class="nav navbar-nav navbar-right">
<li class="dropdown ">
<a href="#" class="dropdown-toggle" data-toggle="dropdown" role="button" aria-expanded="false">
<?php echo xlt('Actions'); ?>
<span class="caret"></span></a>
<ul class="dropdown-menu" role="menu">
<li class=""><a href="#" onclick="doSetup(event)"><?php echo xlt('Account Credentials'); ?></a></li>
<li class=""><a href="#" onclick="popNotify('', './rc_sms_notification.php?dryrun=1&site=<?php echo $_SESSION['site_id'] ?>')"><?php echo xlt('Test SMS Reminders'); ?></a></li>
<li class=""><a href="#" onclick="popNotify('live', './rc_sms_notification.php?site=<?php echo $_SESSION['site_id'] ?>')"><?php echo xlt('Send SMS Reminders'); ?></a></li>
<li class="ringcentral"><a href="#" onclick="docInfo(event, portalUrl)"><?php echo xlt('Portal Gateway'); ?></a></li>
</ul>
</li>
<li class="ringcentral">
<a class="ringcentral" href="#" onclick="docInfo(event, portalUrl)"><?php echo xlt('Visit Account Portal'); ?></a>
</li>
</ul>
</div><!-- /.navbar-collapse -->
</div><!-- /.container-fluid -->
</nav>
<div class="container-fluid main-container" style="margin-top:50px">
<div class="col-md-10 col-md-offset-1 content">
<h3><?php echo xlt("Activities") ?></h3>
<div id="dashboard" class="panel">
<!-- Nav tabs -->
<ul id="tab-menu" class="nav nav-tabs" role="tablist">
<li role="presentation"><a href="#received" aria-controls="received" role="tab" data-toggle="tab"><?php echo xlt("Received") ?></a></li>
<li role="presentation"><a href="#sent" aria-controls="sent" role="tab" data-toggle="tab"><?php echo xlt("Sent") ?></a></li>
<li class="ringcentral" role="presentation"><a href="#messages" aria-controls="messages" role="tab" data-toggle="tab"><?php echo xlt("SMS Log") ?></a></li>
<li class="ringcentral" role="presentation"><a href="#logs" aria-controls="logs" role="tab" data-toggle="tab"><?php echo xlt("Call Log") ?></a></li>
<li role="presentation">
<a href="#alertlogs" aria-controls="alertlogs" role="tab" data-toggle="tab"><?php echo xlt("Notifications Log") ?>
<span class="glyphicon glyphicon-refresh" onclick="getNotificationLog(event,this)"
title="<?php echo xla('Click to refresh using current date range. Refreshing just this tab.') ?>"></span></a>
</li>
<li class="active" role="presentation"><a href="#upLoad" aria-controls="logs" role="tab" data-toggle="tab"><?php echo xlt("Upload Fax") ?></a></li>
</ul>
<!-- Tab panes -->
<div class="tab-content">
<div role="tabpanel" class="container-fluid tab-pane fade" id="received">
<div class="table-responsive">
<table class="table table-condensed table-striped" id="rcvdetails">
<thead>
<tr>
<th><?php echo xlt("Start Time") ?></th>
<th class="twilio"><?php echo xlt("End Time") ?></th>
<th class="ringcentral"><?php echo xlt("Type") ?></th>
<th><?php echo xlt("Pages") ?></th>
<th><?php echo xlt("From") ?></th>
<th><?php echo xlt("To") ?></th>
<th><?php echo xlt("Result") ?></th>
<th class="ringcentral"><?php echo xlt("Download") ?></th>
<th><?php echo xlt("View") ?></th>
</tr>
</thead>
<tbody>
<tr>
<td><?php echo xlt("No Items Try Refresh") ?></td>
</tr>
</tbody>
</table>
</div>
</div>
<div role="tabpanel" class="container-fluid tab-pane fade" id="sent">
<div class="table-responsive">
<table class="table table-condensed table-striped" id="sentdetails">
<thead>
<tr>
<th><?php echo xlt("Start Time") ?></th>
<th class="twilio"><?php echo xlt("End Time") ?></th>
<th class="ringcentral"><?php echo xlt("Type") ?></th>
<th><?php echo xlt("Pages") ?></th>
<th><?php echo xlt("From") ?></th>
<th><?php echo xlt("To") ?></th>
<th><?php echo xlt("Result") ?></th>
<th class="ringcentral"><?php echo xlt("Download") ?></th>
<th><?php echo xlt("View") ?></th>
</tr>
</thead>
<tbody>
<tr>
<td><?php echo xlt("No Items Try Refresh") ?></td>
</tr>
</tbody>
</table>
</div>
</div>
<div role="tabpanel" class="container-fluid tab-pane fade" id="messages">
<div class="table-responsive">
<table class="table table-condensed table-striped" id="msgdetails">
<thead>
<tr>
<th><?php echo xlt("Date") ?></th>
<th><?php echo xlt("Type") ?></th>
<th><?php echo xlt("From") ?></th>
<th><?php echo xlt("To") ?></th>
<th><?php echo xlt("Result") ?></th>
<th><?php echo xlt("Download") ?></th>
<th><?php echo xlt("View") ?></th>
</tr>
</thead>
<tbody>
<tr>
<td><?php echo xlt("No Items Try Refresh") ?></td>
</tr>
</tbody>
</table>
</div>
</div>
<div role="tabpanel" class="container-fluid tab-pane fade" id="logs">
<div class="table-responsive">
<table class="table table-condensed table-striped" id="logdetails">
<thead>
<tr>
<th><?php echo xlt("Date") ?></th>
<th><?php echo xlt("Type") ?></th>
<th><?php echo xlt("From") ?></th>
<th><?php echo xlt("To") ?></th>
<th><?php echo xlt("Action") ?></th>
<th><?php echo xlt("Result") ?></th>
<th><?php echo xlt("Id") ?></th>
</tr>
</thead>
<tbody>
<tr>
<td><?php echo xlt("No Items Try Refresh") ?></td>
</tr>
</tbody>
</table>
</div>
</div>
<div role="tabpanel" class="container-fluid tab-pane fade" id="alertlogs">
<div class="table-responsive">
<table class="table table-condensed table-striped" id="alertdetails">
<thead>
<tr>
<th><?php echo xlt("Id") ?></th>
<th><?php echo xlt("Date Sent") ?></th>
<th><?php echo xlt("Appt Date Time") ?></th>
<th><?php echo xlt("Patient") ?></th>
<th><?php echo xlt("Message") ?></th>
</tr>
</thead>
<tbody>
<tr>
<td><?php echo xlt("No Items") ?></td>
</tr>
</tbody>
</table>
</div>
</div>
<div role="tabpanel" class="container-fluid tab-pane fade in active" id="upLoad">
<div class="panel container-fluid">
<div id="fax-queue-container">
<div id="fax-queue">
<form id="faxQueue" method="post" enctype="multipart/form-data" class="dropzone"></form>
</div>
</div>
</div>
</div>
</div>
<!--</div>-->
<footer class="pull-left footer">
<p class="col-md-12">
<hr class="divider">
</p>
</footer>
</div>
</body>
</html>