3 * smsnotification script.
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
14 require_once("../globals.php");
15 require_once("$srcdir/registry.inc");
16 require_once("../../library/acl.inc");
17 require_once("batchcom.inc.php");
19 use OpenEMR\Core\Header
;
22 if (!acl_check('admin', 'notification')) {
23 echo "<html>\n<body>\n<h1>";
24 echo xlt('You are not authorized for this.');
25 echo "</h1>\n</body>\n</html>\n";
30 $next_app_date = date("Y-m-d");
33 $provider_name="EMR Group";
34 $message="Welcome to EMR Group";
37 if ($_POST['form_action']=='save') {
38 if (!verifyCsrfToken($_POST["csrf_token_form"])) {
42 //validation uses the functions in notification.inc.php
44 if (!check_date_format($_POST['next_app_date'])) {
45 $form_err .= xl('Date format for "Next Appointment" is not valid') . '<br>';
48 // validate selections
49 if ($_POST['sms_gateway_type'] == "") {
50 $form_err .= xl('Error in "SMS Gateway" selection') . '<br>';
54 if ($_POST['provider_name'] == "") {
55 $form_err .= xl('Empty value in "Name of Provider"') . '<br>';
58 if ($_POST['message'] == "") {
59 $form_err .= xl('Empty value in "SMS Text"') . '<br>';
64 $next_app_time = $_POST[hour
].":".$_POST['min'];
65 $sql_text=" ( `notification_id` , `sms_gateway_type` , `next_app_date` , `next_app_time` , `provider_name` , `message` , `email_sender` , `email_subject` , `type` ) ";
66 $sql_value=" (?, ?, ?, ?, ?, ?, ?, 'SMS') ";
67 $values = array($_POST['notification_id'], $_POST['sms_gateway_type'], $_POST['next_app_date'], $next_app_time,
68 $_POST['provider_name'], $_POST['message'], $_POST['email_sender'], $_POST['email_subject']);
69 $query = "REPLACE INTO `automatic_notification` $sql_text VALUES $sql_value";
71 $id = sqlInsert($query);
72 $sql_msg = xl("ERROR!... in Update");
74 $sql_msg = xl("SMS Notification Settings Updated Successfully");
79 // fetch data from table
80 $sql = "select * from automatic_notification where type='SMS'";
81 $result = sqlQuery($sql);
83 $notification_id = $result['notification_id'];
84 $sms_gateway_type = $result['sms_gateway_type'];
85 $next_app_date = $result['next_app_date'];
86 list($hour,$min) = @explode
(":", $result['next_app_time']);
87 $provider_name = $result['provider_name'];
88 $message = $result['message'];
91 // menu arrays (done this way so it's easier to validate input on validate selections)
92 $sms_gateway=array ('CLICKATELL','TMB4');
93 $hour_array =array('00','01','02','03','04','05','06','07','08','09','10','11','12','13','14','15','16','17','18','19','21','21','22','23');
94 $min_array = array('00','05','10','15','20','25','30','35','40','45','50','55');
96 //START OUT OUR PAGE....
100 <?php Header
::setupHeader(); ?
>
101 <title
><?php
echo xlt("SMS Notification"); ?
></title
>
103 <body
class="body_top container">
105 <?php
require_once("batch_navigation.php");?
>
106 <h1
class="col-md-12">
107 <a href
="batchcom.php"><?php
echo xlt('Batch Communication Tool'); ?
></a
>
108 <small
><?php
echo xlt('SMS Notification'); ?
></small
>
114 echo '<div class="alert alert-danger">' . xlt('The following errors occurred') . ': ' . text($form_err) . '</div>';
118 echo '<div class="alert alert-info">' . xlt('The following occurred') . ': ' . text($sql_msg) . '</div>';
121 <form name
="select_form" method
="post" action
="">
122 <input type
="hidden" name
="csrf_token_form" value
="<?php echo attr(collectCsrfToken()); ?>" />
123 <input type
="hidden" name
="type" value
="SMS">
124 <input type
="hidden" name
="notification_id" value
="<?php echo attr($notification_id); ?>">
126 <div
class="col-md-6 form-group">
127 <label
for="sms_gateway_type"><?php
echo xlt('SMS Gateway') ?
>:</label
>
128 <select name
="sms_gateway_type" class="form-control">
129 <option value
=""><?php
echo xlt('Select SMS Gateway'); ?
></option
>
130 <?php
foreach ($sms_gateway as $value) { ?
>
131 <option value
="<?php echo attr($value); ?>"
133 if ($sms_gateway_type == $value) {
143 <div
class="col-md-6 form-group">
144 <label
for="provider_name"><?php
echo xlt('Name of Provider'); ?
>:</label
>
145 <input
class="form-control" type
="text" name
="provider_name" size
="40" value
="<?php echo attr($provider_name); ?>" placeholder
="<?php xla('provider name'); ?>">
149 <div
class="col-md-12 form-group">
150 <label
for="message"><?php
echo xlt('SMS Text, Usable Tags: '); ?
>***NAME
***, ***PROVIDER
***, ***DATE
***, ***STARTTIME
***, ***ENDTIME
*** (i
.e
. Dear
***NAME
***):</label
>
151 <textarea
class="form-control" cols
="35" rows
="8" name
="message"><?php
echo text($message); ?
></textarea
>
155 <div
class="col-md-12 form-group">
156 <button
class="btn btn-default btn-save" type
="submit" name
="form_action" value
="save"><?php
echo xlt('Save'); ?
></button
>