bug fix march continued (#1921)
[openemr.git] / interface / batchcom / settingsnotification.php
blob4de902a4d603e62d824578dff0a32518be2dda6b
1 <?php
2 /**
3 * Notification Settings Script
5 * @package OpenEMR
6 * @author cfapress
7 * @author Jason 'Toolbox' Oettinger <jason@oettinger.email>
8 * @link http://www.open-emr.org
9 * @copyright Copyright (c) 2008 cfapress
10 * @copyright Copyright (c) 2017 Jason 'Toolbox' Oettinger <jason@oettinger.email>
11 * @license https://github.com/openemr/openemr/blob/master/LICENSE GNU General Public License 3
13 require_once("../globals.php");
14 require_once("$srcdir/registry.inc");
15 require_once("../../library/acl.inc");
16 require_once("batchcom.inc.php");
17 use OpenEMR\Core\Header;
19 // gacl control
20 if (!acl_check('admin', 'notification')) {
21 echo "<html>\n<body>\n<h1>";
22 echo xlt('You are not authorized for this.');
23 echo "</h1>\n</body>\n</html>\n";
24 exit();
27 $type = 'SMS/Email Settings';
28 // process form
29 if ($_POST['form_action']=='save') {
30 if (!verifyCsrfToken($_POST["csrf_token_form"])) {
31 csrfNotVerified();
34 if ($_POST['Send_SMS_Before_Hours']=="") {
35 $form_err .= xl('Empty value in "SMS Hours"') . '<br>';
38 if ($_POST['Send_Email_Before_Hours']=="") {
39 $form_err .= xl('Empty value in "Email Hours"') . '<br>';
42 if ($_POST['SMS_gateway_username']=="") {
43 $form_err .= xl('Empty value in "Username"') . '<br>';
46 if ($_POST['SMS_gateway_password']=="") {
47 $form_err .= xl('Empty value in "Password"') . '<br>';
50 //process sql
51 if (!$form_err) {
52 $sql_text = " ( `SettingsId` , `Send_SMS_Before_Hours` , `Send_Email_Before_Hours` , `SMS_gateway_password` , `SMS_gateway_apikey` , `SMS_gateway_username` , `type` ) ";
53 $sql_value = " (?, ?, ?, ?, ?, ?, ?) ";
54 $values = array($_POST['SettingsId'], $_POST['Send_SMS_Before_Hours'], $_POST['Send_Email_Before_Hours'],
55 $_POST['SMS_gateway_password'], $_POST['SMS_gateway_apikey'], $_POST['SMS_gateway_username'],
56 $type);
57 $query = "REPLACE INTO `notification_settings` $sql_text VALUES $sql_value";
58 //echo $query;
59 $id = sqlInsert($query, $values);
60 $sql_msg = xl("ERROR!... in Update");
61 if ($id) {
62 $sql_msg = xl("SMS/Email Alert Settings Updated Successfully");
67 // fetch data from table
68 $sql="select * from notification_settings where type='SMS/Email Settings'";
69 $result = sqlQuery($sql);
70 if ($result) {
71 $SettingsId = $result['SettingsId'];
72 $Send_SMS_Before_Hours = $result['Send_SMS_Before_Hours'];
73 $Send_Email_Before_Hours = $result['Send_Email_Before_Hours'];
74 $SMS_gateway_password = $result['SMS_gateway_password'];
75 $SMS_gateway_username = $result['SMS_gateway_username'];
76 $SMS_gateway_apikey = $result['SMS_gateway_apikey'];
79 //my_print_r($result);
80 //START OUT OUR PAGE....
82 <html>
83 <head>
84 <?php Header::setupHeader(); ?>
85 <title><?php echo xlt("Notification Settings"); ?></title>
86 </head>
87 <body class="body_top container">
88 <header class="row">
89 <?php require_once("batch_navigation.php");?>
90 <h1 class="col-md-12">
91 <a href="batchcom.php"><?php echo xlt('Batch Communication Tool'); ?></a>
92 <small><?php echo xlt('SMS/Email Alert Settings'); ?></small>
93 </h1>
94 </header>
95 <main>
96 <?php
97 if ($form_err) {
98 echo '<div class="alert alert-danger">' . xlt('The following errors occurred') . ': ' . text($form_err) . '</div>';
101 if ($sql_msg) {
102 echo '<div class="alert alert-info">' . xlt('The following occurred') . ': ' . text($sql_msg) . '</div>';
105 <form name="select_form" method="post" action="">
106 <input type="hidden" name="csrf_token_form" value="<?php echo attr(collectCsrfToken()); ?>" />
107 <input type="hidden" name="type" value="SMS">
108 <input type="Hidden" name="SettingsId" value="<?php echo attr($SettingsId);?>">
110 <div class="row">
111 <div class="col-md-6 form-group">
112 <label for="Send_SMS_Before_Hours"><?php echo xlt('SMS send before')?>:</label>
113 <input class="form-control" type="num" name="Send_SMS_Before_Hours" size="10" maxlength="3" value="<?php echo attr($Send_SMS_Before_Hours); ?>" placeholder="###">
114 </div>
115 <div class="col-md-6 form-group">
116 <label for="Send_Email_Before_Hours"><?php echo xlt('Email send before')?>:</label>
117 <input class="form-control" type="num" name="Send_Email_Before_Hours" size="10" maxlength="3" value="<?php echo attr($Send_Email_Before_Hours); ?>" placeholder="###">
118 </div>
119 </div>
120 <div class="row">
121 <div class="col-md-6 form-group">
122 <label for="SMS_gateway_username"><?php echo xlt('Username for SMS Gateway')?>:</label>
123 <input class="form-control" type="text" name="SMS_gateway_username" size="40" value="<?php echo attr($SMS_gateway_username); ?>" placeholder="<?php echo xla('username'); ?>">
124 </div>
125 <div class="col-md-6 form-group">
126 <label for="SMS_gateway_password"><?php echo xlt('Password for SMS Gateway')?>:</label>
127 <input class="form-control" type="password" name="SMS_gateway_password" size="40" value="<?php echo attr($SMS_gateway_password); ?>" placeholder="<?php echo xla('password'); ?>">
128 </div>
129 </div>
130 <div class="row">
131 <div class="col-md-12 form-group">
132 <label for="SMS_gateway_apikey"><?php echo xlt('SMS Gateway API key')?>:</label>
133 <input class="form-control" type="text" name="SMS_gateway_apikey" size="40" value="<?php echo attr($SMS_gateway_apikey); ?>" placeholder="<?php echo xla('key'); ?>">
134 </div>
135 </div>
136 <div class="row">
137 <div class="col-md-12 form-group">
138 <button class="btn btn-default btn-save" type="submit" name="form_action" value="save"><?php echo xlt('Save'); ?></button>
139 </div>
140 </div>
142 </form>
143 </main>
145 </body>
146 </html>