4 * emailnotification script.
8 * @author Jason 'Toolbox' Oettinger <jason@oettinger.email>
9 * @link http://www.open-emr.org
10 * @copyright Copyright (c) 2008 cfapress
11 * @copyright Copyright (c) 2017 Jason 'Toolbox' Oettinger <jason@oettinger.email>
12 * @license https://github.com/openemr/openemr/blob/master/LICENSE GNU General Public License 3
15 require_once("../globals.php");
16 require_once("$srcdir/registry.inc.php");
17 require_once("batchcom.inc.php");
19 use OpenEMR\Common\Acl\AclMain
;
20 use OpenEMR\Common\Csrf\CsrfUtils
;
21 use OpenEMR\Common\Twig\TwigContainer
;
22 use OpenEMR\Core\Header
;
25 if (!AclMain
::aclCheckCore('admin', 'notification')) {
26 echo (new TwigContainer(null, $GLOBALS['kernel']))->getTwig()->render('core/unauthorized.html.twig', ['pageTitle' => xl("Email Notification")]);
31 if (!empty($_POST['form_action']) && ($_POST['form_action'] == 'save')) {
32 if (!CsrfUtils
::verifyCsrfToken($_POST["csrf_token_form"])) {
33 CsrfUtils
::csrfNotVerified();
36 if (! is_numeric($_POST['notification_id'])) { // shouldn't happen
37 $form_err .= xl('Missing/invalid notification id') . '<br />';
40 if (empty($_POST['email_sender'])) {
41 $form_err .= xl('Empty value in "Email Sender"') . '<br />';
44 if (empty($_POST['email_subject'])) {
45 $form_err .= xl('Empty value in "Email Subject"') . '<br />';
48 if (empty($_POST['provider_name'])) {
49 $form_err .= xl('Empty value in "Name of Provider"') . '<br />';
52 if (empty($_POST['message'])) {
53 $form_err .= xl('Empty value in "Email Text"') . '<br />';
56 // Store the new settings. sms_gateway_type is not used for email.
57 // notification_id is the pk, and should always be 2 for email settings.
60 $sql_text = " ( `notification_id` , `sms_gateway_type` , `provider_name` , `message` , `email_sender` , `email_subject` , `type` ) ";
61 $sql_value = " (?, ?, ?, ?, ?, ?, ?) ";
62 $values = array($_POST['notification_id'], '', $_POST['provider_name'],
63 $_POST['message'], $_POST['email_sender'],
64 $_POST['email_subject'], 'Email');
65 $query = "REPLACE INTO `automatic_notification` $sql_text VALUES $sql_value";
67 $id = sqlInsert($query, $values);
68 $sql_msg = xl("ERROR!... in Update");
70 $sql_msg = xl("Email Notification Settings Updated Successfully");
75 // fetch email config from table. This should never fail, because one row
76 // of each type is seeded when the db is created.
77 $sql = "select * from automatic_notification where type='Email'";
78 $result = sqlQuery($sql);
80 $notification_id = $result['notification_id'];
81 $provider_name = $result['provider_name'];
82 $email_sender = $result['email_sender'];
83 $email_subject = $result['email_subject'];
84 $message = $result['message'];
86 $sql_msg = xl('Missing email config record');
89 //my_print_r($result);
91 //START OUT OUR PAGE....
95 <?php Header
::setupHeader(); ?
>
96 <title
><?php
echo xlt("Email Notification"); ?
></title
>
98 <body
class="body_top container">
100 <?php
require_once("batch_navigation.php");?
>
101 <h1
class="col-md-12">
102 <a href
="batchcom.php"><?php
echo xlt('Batch Communication Tool'); ?
></a
>
103 <small
><?php
echo xlt('Email Notification'); ?
></small
>
108 if (!empty($form_err)) {
109 echo '<div class="alert alert-danger">' . xlt('The following errors occurred') . ': ' . text($form_err) . '</div>';
112 if (!empty($sql_msg)) {
113 echo '<div class="alert alert-info">' . xlt('The following occurred') . ': ' . text($sql_msg) . '</div>';
116 <form name
="select_form" method
="post" action
="">
117 <input type
="hidden" name
="csrf_token_form" value
="<?php echo attr(CsrfUtils::collectCsrfToken()); ?>" />
118 <input type
="Hidden" name
="type" value
="Email">
119 <input type
="Hidden" name
="notification_id" value
="<?php echo attr($notification_id);?>">
121 <div
class="col-md-4 form-group">
122 <label
for="email_sender"><?php
echo xlt('Email Sender')?
>:</label
>
123 <input
class="form-control" type
="text" name
="email_sender" size
="40" value
="<?php echo attr($email_sender); ?>" placeholder
="<?php xla('sender name'); ?>">
125 <div
class="col-md-4 form-group">
126 <label
for="email_subject"><?php
echo xlt('Email Subject')?
>:</label
>
127 <input
class="form-control" type
="text" name
="email_subject" size
="40" value
="<?php echo attr($email_subject); ?>" placeholder
="<?php xla('email subject'); ?>">
129 <div
class="col-md-4 form-group">
130 <label
for="provider_name"><?php
echo xlt('Name of Provider')?
>:</label
>
131 <input
class="form-control" type
="text" name
="provider_name" size
="40" value
="<?php echo attr($provider_name); ?>" placeholder
="<?php xla('provider name'); ?>">
135 <div
class="col-md-12 form-group">
136 <label
for="message"><?php
echo xlt('Email Text Usable Tags'); ?
>: ***NAME
***, ***PROVIDER
***, ***DATE
***, ***STARTTIME
***, ***ENDTIME
*** (i
.e
. Dear
***NAME
***):</label
>
137 <textarea
class="form-control" cols
="35" rows
="8" name
="message"><?php
echo text($message); ?
></textarea
>
141 <div
class="col-md-12 form-group">
142 <button
class="btn btn-secondary btn-save" type
="submit" name
="form_action" value
="save"><?php
echo xlt('Save'); ?
></button
>