more organization of autoloaded files (#424)
[openemr.git] / interface / batchcom / smsnotification.php
blobce05b56eae7c16b5366b359527ca8ff0c316dc6b
1 <?php
2 //INCLUDES, DO ANY ACTIONS, THEN GET OUR DATA
3 include_once("../globals.php");
4 include_once("$srcdir/registry.inc");
5 include_once("../../library/acl.inc");
6 include_once("batchcom.inc.php");
8 // gacl control
9 $thisauth = acl_check('admin', 'notification');
11 if (!$thisauth) {
12 echo "<html>\n<body>\n";
13 echo "<p>".xl('You are not authorized for this.','','','</p>')."\n";
14 echo "</body>\n</html>\n";
15 exit();
18 // default value
19 $next_app_date = date("Y-m-d");
20 $hour="12";
21 $min="15";
22 $provider_name="EMR Group";
23 $message="Welcome to EMR Group";
24 $type = "SMS";
26 // process form
27 if ($_POST['form_action']=='Save')
29 //validation uses the functions in notification.inc.php
30 //validate dates
31 if (!check_date_format($_POST['next_app_date'])) $form_err.=xl('Date format for "Next Appointment" is not valid','','<br>');
32 // validate selections
33 if ($_POST['sms_gateway_type']=="") $form_err.=xl('Error in "SMS Gateway" selection','','<br>');
34 // validates and or
35 if ($_POST['provider_name']=="") $form_err.=xl('Empty value in "Name of Provider"','','<br>');
36 if ($_POST['message']=="") $form_err.=xl('Empty value in "SMS Text"','','<br>');
37 //process sql
38 if (!$form_err)
40 $next_app_time = $_POST[hour].":".$_POST['min'];
41 $sql_text=" ( `notification_id` , `sms_gateway_type` , `next_app_date` , `next_app_time` , `provider_name` , `message` , `email_sender` , `email_subject` , `type` ) ";
42 $sql_value=" ( '".$_POST[notification_id]."' , '".$_POST[sms_gateway_type]."' , '".$_POST[next_app_date]."' , '".$next_app_time."' , '".$_POST[provider_name]."' , '".$_POST[message]."' , '".$_POST[email_sender]."' , '".$_POST[email_subject]."' , '".$type."' ) ";
43 $query = "REPLACE INTO `automatic_notification` $sql_text VALUES $sql_value";
44 //echo $query;
45 $id = sqlInsert($query);
46 $sql_msg="ERROR!... in Update";
47 if($id) $sql_msg="SMS Notification Settings Updated Successfully";
51 // fetch data from table
52 $sql="select * from automatic_notification where type='$type'";
53 $result = sqlQuery($sql);
54 if($result)
56 $notification_id = $result[notification_id];
57 $sms_gateway_type = $result[sms_gateway_type];
58 $next_app_date = $result[next_app_date];
59 list($hour,$min) = @explode(":",$result[next_app_time]);
60 $provider_name=$result[provider_name];
61 $message=$result[message];
63 //my_print_r($result);
65 // menu arrays (done this way so it's easier to validate input on validate selections)
66 $sms_gateway=Array ('CLICKATELL','TMB4');
67 $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');
68 $min_array = array('00','05','10','15','20','25','30','35','40','45','50','55');
70 //START OUT OUR PAGE....
72 <html>
73 <head>
74 <link rel="stylesheet" href="<?php echo $css_header;?>" type="text/css">
75 <link rel="stylesheet" href="batchcom.css" type="text/css">
76 <script type="text/javascript" src="../../library/overlib_mini.js"></script>
77 <script type="text/javascript" src="../../library/calendar.js"></script>
80 </head>
81 <body class="body_top">
82 <span class="title"><?php include_once("batch_navigation.php");?></span>
83 <span class="title"><?php xl('SMS Notification','e')?></span>
84 <br><br>
85 <!-- for the popup date selector -->
86 <div id="overDiv" style="position:absolute; visibility:hidden; z-index:1000;"></div>
87 <FORM name="select_form" METHOD=POST ACTION="">
88 <input type="Hidden" name="type" value="<?php echo $type;?>">
89 <input type="Hidden" name="notification_id" value="<?php echo $notification_id;?>">
90 <div class="text">
91 <div class="main_box">
92 <?php
93 if ($form_err) {
94 echo ("The following errors occurred<br>$form_err<br><br>");
96 if ($sql_msg) {
97 echo ("$sql_msg<br><br>");
99 xl('SMS Gateway','e')?>:
100 <SELECT NAME="sms_gateway_type">
101 <option value="">Select SMS Gateway</option>
102 <?php foreach ($sms_gateway as $value) {?>
103 <option value="<?php echo $value;?>" <?php if ($sms_gateway_type == $value) {echo "selected";}?>><?php echo $value;?></option>
104 <?php }?>
105 </SELECT>
106 <br>
108 <?php xl('Name of Provider','e')?> :
109 <INPUT TYPE="text" NAME="provider_name" size="40" value="<?php echo $provider_name?>">
110 <br>
111 <?php xl('SMS Text, Usable Tag: ***NAME***, ***PROVIDER***, ***DATE***, ***STARTTIME***, ***ENDTIME***<br> i.e. Dear ***NAME***','e')?>
112 <br>
113 <TEXTAREA NAME="message" ROWS="8" COLS="35"><?php echo $message?></TEXTAREA>
114 <br><br>
115 <INPUT TYPE="submit" name="form_action" value="Save">
116 </div>
117 </div>
118 </FORM>