* @link http://www.open-emr.org * @copyright Copyright (c) 2008 cfapress * @copyright Copyright (c) 2017 Jason 'Toolbox' Oettinger * @license https://github.com/openemr/openemr/blob/master/LICENSE GNU General Public License 3 */ require_once("../globals.php"); require_once("$srcdir/registry.inc"); require_once("batchcom.inc.php"); use OpenEMR\Common\Acl\AclMain; use OpenEMR\Common\Csrf\CsrfUtils; use OpenEMR\Common\Twig\TwigContainer; use OpenEMR\Core\Header; // gacl control if (!AclMain::aclCheckCore('admin', 'notification')) { echo (new TwigContainer(null, $GLOBALS['kernel']))->getTwig()->render('core/unauthorized.html.twig', ['pageTitle' => xl("Email Notification")]); exit; } // process form if (!empty($_POST['form_action']) && ($_POST['form_action'] == 'save')) { if (!CsrfUtils::verifyCsrfToken($_POST["csrf_token_form"])) { CsrfUtils::csrfNotVerified(); } if (! is_numeric($_POST['notification_id'])) { // shouldn't happen $form_err .= xl('Missing/invalid notification id') . '
'; } if (empty($_POST['email_sender'])) { $form_err .= xl('Empty value in "Email Sender"') . '
'; } if (empty($_POST['email_subject'])) { $form_err .= xl('Empty value in "Email Subject"') . '
'; } if (empty($_POST['provider_name'])) { $form_err .= xl('Empty value in "Name of Provider"') . '
'; } if (empty($_POST['message'])) { $form_err .= xl('Empty value in "Email Text"') . '
'; } // Store the new settings. sms_gateway_type is not used for email. // notification_id is the pk, and should always be 2 for email settings. if (!$form_err) { $sql_text = " ( `notification_id` , `sms_gateway_type` , `provider_name` , `message` , `email_sender` , `email_subject` , `type` ) "; $sql_value = " (?, ?, ?, ?, ?, ?, ?) "; $values = array($_POST['notification_id'], '', $_POST['provider_name'], $_POST['message'], $_POST['email_sender'], $_POST['email_subject'], 'Email'); $query = "REPLACE INTO `automatic_notification` $sql_text VALUES $sql_value"; //echo $query; $id = sqlInsert($query, $values); $sql_msg = xl("ERROR!... in Update"); if ($id) { $sql_msg = xl("Email Notification Settings Updated Successfully"); } } } // fetch email config from table. This should never fail, because one row // of each type is seeded when the db is created. $sql = "select * from automatic_notification where type='Email'"; $result = sqlQuery($sql); if ($result) { $notification_id = $result['notification_id']; $provider_name = $result['provider_name']; $email_sender = $result['email_sender']; $email_subject = $result['email_subject']; $message = $result['message']; } else { $sql_msg = xl('Missing email config record'); } //my_print_r($result); //START OUT OUR PAGE.... ?> <?php echo xlt("Email Notification"); ?>

' . xlt('The following errors occurred') . ': ' . text($form_err) . ''; } if (!empty($sql_msg)) { echo '
' . xlt('The following occurred') . ': ' . text($sql_msg) . '
'; } ?>