Add back popup dialogs for tabs U.I. (#1434)
[openemr.git] / interface / batchcom / emailnotification.php
blobdb52fd59cfc19cfe472e8a12939e662ac584f487
1 <?php
2 /**
3 * emailnotification 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 // default value
28 $next_app_date = date("Y-m-d");
29 $hour="12";
30 $min="15";
31 $provider_name="EMR Group";
32 $message="Welcome to EMR Group";
33 $type = "Email";
34 $email_sender = "EMR Group";
35 $email_subject = "Welcome to EMR Group";
36 // process form
37 if ($_POST['form_action']=='save') {
38 //validation uses the functions in notification.inc.php
39 if ($_POST['email_sender']=="") {
40 $form_err .= xl('Empty value in "Email Sender"') . '<br>';
43 if ($_POST['email_subject']=="") {
44 $form_err .= xl('Empty value in "Email Subject"') . '<br>';
47 //validate dates
48 if (!check_date_format($_POST['next_app_date'])) {
49 $form_err .= xl('Date format for "Next Appointment" is not valid') . '<br>';
52 // validates and or
53 if ($_POST['provider_name']=="") {
54 $form_err .= xl('Empty value in "Name of Provider"') . '<br>';
57 if ($_POST['message']=="") {
58 $form_err .= xl('Empty value in "Email Text"') . '<br>';
61 //process sql
62 if (!$form_err) {
63 $next_app_time = $_POST['hour'].":".$_POST['min'];
64 $sql_text = " ( `notification_id` , `sms_gateway_type` , `next_app_date` , `next_app_time` , `provider_name` , `message` , `email_sender` , `email_subject` , `type` ) ";
65 $sql_value = " (?, ?, ?, ?, ?, ?, ?, ?, ?) ";
66 $values = array($_POST['notification_id'], $_POST['sms_gateway_type'], $_POST['next_app_date'], $next_app_time,
67 $_POST['provider_name'], $_POST['message'], $_POST['email_sender'], $_POST['email_subject'],
68 $type);
69 $query = "REPLACE INTO `automatic_notification` $sql_text VALUES $sql_value";
70 //echo $query;
71 $id = sqlInsert($query, $values);
72 $sql_msg = xl("ERROR!... in Update");
73 if ($id) {
74 $sql_msg = xl("Email Notification Settings Updated Successfully");
79 // fetch data from table
80 $sql="select * from automatic_notification where type='Email'";
81 $result = sqlQuery($sql);
82 if ($result) {
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 $email_sender = $result['email_sender'];
89 $email_subject = $result['email_subject'];
90 $message = $result['message'];
93 //my_print_r($result);
95 // menu arrays (done this way so it's easier to validate input on validate selections)
96 $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');
97 $min_array = array('00','05','10','15','20','25','30','35','40','45','50','55');
99 //START OUT OUR PAGE....
101 <html>
102 <head>
103 <?php Header::setupHeader(); ?>
104 <title><?php echo xlt("Email Notification"); ?></title>
105 </head>
106 <body class="body_top container">
107 <header class="row">
108 <?php require_once("batch_navigation.php");?>
109 <h1 class="col-md-12">
110 <a href="batchcom.php"><?php echo xlt('Batch Communication Tool'); ?></a>
111 <small><?php echo xlt('Email Notification'); ?></small>
112 </h1>
113 </header>
114 <main>
115 <?php
116 if ($form_err) {
117 echo '<div class="alert alert-danger">' . xlt('The following errors occurred') . ': ' . text($form_err) . '</div>';
120 if ($sql_msg) {
121 echo '<div class="alert alert-info">' . xlt('The following errors occurred') . ': ' . text($sql_msg) . '</div>';
124 <form name="select_form" method="post" action="">
125 <input type="Hidden" name="type" value="Email">
126 <input type="Hidden" name="notification_id" value="<?php echo attr($notification_id);?>">
127 <div class="row">
128 <div class="col-md-4 form-group">
129 <label for="email_sender"><?php echo xlt('Email Sender')?>:</label>
130 <input class="form-control" type="text" name="email_sender" size="40" value="<?php echo attr($email_sender); ?>" placeholder="<?php xla('sender name'); ?>">
131 </div>
132 <div class="col-md-4 form-group">
133 <label for="email_subject"><?php echo xlt('Email Subject')?>:</label>
134 <input class="form-control" type="text" name="email_subject" size="40" value="<?php echo attr($email_subject); ?>" placeholder="<?php xla('email subject'); ?>">
135 </div>
136 <div class="col-md-4 form-group">
137 <label for="provider_name"><?php echo xlt('Name of Provider')?>:</label>
138 <input class="form-control" type="text" name="provider_name" size="40" value="<?php echo attr($provider_name); ?>" placeholder="<?php xla('provider name'); ?>">
139 </div>
140 </div>
141 <div class="row">
142 <div class="col-md-12 form-group">
143 <label for="message"><?php echo xlt('SMS Text Usable Tags'); ?>: ***NAME***, ***PROVIDER***, ***DATE***, ***STARTTIME***, ***ENDTIME*** (i.e. Dear ***NAME***):</label>
144 <textarea class="form-control" cols="35" rows="8" name="message"><?php echo text($message); ?></textarea>
145 </div>
146 </div>
147 <div class="row">
148 <div class="col-md-12 form-group">
149 <button class="btn btn-default btn-save" type="submit" name="form_action" value="save"><?php echo xlt('Save'); ?></button>
150 </div>
151 </div>
152 </form>
153 </main>
154 </body>
155 </html>