-
Notifications
You must be signed in to change notification settings - Fork 6
/
setup.php
159 lines (156 loc) · 8.26 KB
/
setup.php
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
<?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\Modules\FaxSMS\Controllers\AppDispatch;
use OpenEMR\Core\Header;
// kick off app endpoints controller
$clientApp = AppDispatch::getApiService();
$service = $clientApp::getServiceType();
$c = $clientApp->getCredentials();
echo "<script>var pid=" . js_escape($pid) . "</script>";
?>
<!DOCTYPE html>
<html>
<head>
<title>Setup</title>
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<?php Header::setupHeader();
echo "<script>var Service=" . js_escape($service) . ";</script>";
?>
<script>
$(function () {
$('#setup-form').on('submit', function (e) {
if (!e.isDefaultPrevented()) {
$(window).scrollTop(0);
let wait = '<i class="fa fa-cog fa-spin fa-4x"></i>';
let url = 'saveSetup';
$.ajax({
type: "POST",
url: url,
data: $(this).serialize(),
success: function (data) {
var err = (data.search(/Exception/) !== -1 ? 1 : 0);
if (!err) {
err = (data.search(/Error:/) !== -1 ? 1 : 0);
}
var messageAlert = 'alert-' + (err !== 0 ? 'danger' : 'success');
var messageText = data;
var alertBox = '<div class="alert ' + messageAlert + ' alert-dismissable"><button type="button" ' +
'class="close" data-dismiss="alert" aria-hidden="true">×</button>' + messageText + '</div>';
if (messageAlert && messageText) {
// inject the alert to .messages div in our form
$('#setup-form').find('.messages').html(alertBox);
if (!err) {
// empty the form
$('#setup-form')[0].reset();
setTimeout(function () {
$('#setup-form').find('.messages').remove();
<?php if (!$module_config) { ?>
dlgclose();
<?php } else { ?>
location.reload();
<?php } ?>
}, 2000);
}
}
}
});
return false;
}
});
if (Service === '2') {
$(".ringcentral").hide();
} else {
$(".twilio").hide();
}
});
</script>
</head>
<body>
<div class="container-fluid">
<?php if ($module_config) { ?>
<h4>Setup Credentials</h4>
<?php } ?>
<form class="form" id="setup-form" role="form">
<div class="messages"></div>
<div class="row">
<div class="col-md-12">
<div class="checkbox">
<label>
<input id="form_production" type="checkbox" name="production" <?php echo attr($c['production']) ? ' checked' : '' ?>>
<?php echo xlt("Production Check") ?>
</label>
</div>
<div class="col-md-6">
<div class="form-group">
<label for="form_username"><?php echo xlt("Username, Phone or Account Sid") ?> *</label>
<input id="form_username" type="text" name="username" class="form-control"
required="required" value='<?php echo attr($c['username']) ?>'>
</div>
<div class="form-group">
<label for="form_extension"><?php echo xlt("Phone Number or Extension") ?></label>
<input id="form_extension" type="text" name="extension" class="form-control"
required="required" value='<?php echo attr($c['extension']) ?>'>
</div>
<div class="form-group">
<label for="form_password"><?php echo xlt("Password or Auth Token") ?> *</label>
<input id="form_password" type="text" name="password" class="form-control"
required="required" value='<?php echo attr($c['password']) ?>'>
</div>
<div class="form-group">
<label for="form_smsnumber"><?php echo xlt("SMS Number") ?></label>
<input id="form_smsnumber" type="text" name="smsnumber" class="form-control"
value='<?php echo attr($c['smsNumber']) ?>'>
</div>
</div>
<div class="col-md-6">
<div class="form-group">
<label for="form_key"><?php echo xlt("Client ID") ?> *</label>
<input id="form_key" type="text" name="key" class="form-control"
required="required" value='<?php echo attr($c['appKey']) ?>'>
</div>
<div class="form-group">
<label for="form_secret"><?php echo xlt("Client Secret") ?> *</label>
<input id="form_secret" type="text" name="secret" class="form-control"
required="required" value='<?php echo attr($c['appSecret']) ?>'>
</div>
<div class="form-group">
<label class="ringcentral" for="form_redirect_url"><?php echo xlt("OAuth Redirect URI") ?></label>
<input id="form_redirect_url" type="text" name="redirect_url" class="form-control ringcentral"
placeholder="<?php echo xlt('From RingCentral Account') ?>"
value='<?php echo attr($c['redirect_url']) ?>'>
</div>
<div class=" form-group">
<label for="form_nhours"><?php echo xlt("Appointments Advance Notify (Hours)") ?> *</label>
<input id="form_nhours" type="text" name="smshours" class="form-control"
placeholder="<?php echo xlt('Please enter number of hours before appointment') ?> *"
required="required" value='<?php echo attr($c['smsHours']) ?>'>
</div>
</div>
<div class="col-md-12">
<div class="form-group">
<label for="form_message"><?php echo xlt("Message Template") ?> *</label>
<span style="font-size:12px;font-style: italic">
<?php echo xlt("Tags") ?>: ***NAME***, ***PROVIDER***, ***DATE***, ***STARTTIME***, ***ENDTIME***, ***ORG***</span>
<textarea id="form_message" type="text" rows="3" name="smsmessage" class="form-control"
required="required" value='<?php echo attr($c['smsMessage']) ?>'><?php echo attr($c['smsMessage']) ?></textarea>
</div>
</div>
<div>
<p class="text-muted"><strong>*</strong> <?php echo xlt("These fields are required.") ?> </p>
</div>
<button type="submit" class="btn btn-success btn-sm pull-right" value=""><?php echo xlt("Save") ?></button>
</div>
</div>
</form>
</div>
</body>
</html>