4 * Used for displaying dated reminders.
7 * @link https://www.open-emr.org
8 * @author Craig Bezuidenhout <http://www.tajemo.co.za/>
9 * @author Brady Miller <brady.g.miller@gmail.com>
10 * @copyright Copyright (c) 2012 tajemo.co.za <http://www.tajemo.co.za/>
11 * @copyright Copyright (c) 2018 Brady Miller <brady.g.miller@gmail.com>
12 * @license https://github.com/openemr/openemr/blob/master/LICENSE GNU General Public License 3
15 // removed as jquery is already called in messages page (if you need to use jQuery, uncomment it futher down)
16 require_once(__DIR__
. '/../../globals.php');
17 require_once("$srcdir/dated_reminder_functions.php");
19 use OpenEMR\Common\Csrf\CsrfUtils
;
22 $alerts_to_show = $GLOBALS['dated_reminders_max_alerts_to_show'];
23 $updateDelay = 60; // time is seconds
26 // ----- get time stamp for start of today, this is used to check for due and overdue reminders
27 $today = strtotime(date('Y/m/d'));
29 // ----- set $hasAlerts to false, this is used for auto-hiding reminders if there are no due or overdue reminders
32 // mulitply $updateDelay by 1000 to get miliseconds
33 $updateDelay = $updateDelay * 1000;
35 //-----------------------------------------------------------------------------
36 // HANDLE AJAX TO MARK REMINDERS AS READ
37 // Javascript will send a post
38 // ----------------------------------------------------------------------------
39 if (isset($_POST['drR'])) {
40 if (!CsrfUtils
::verifyCsrfToken($_POST["csrf_token_form"])) {
41 CsrfUtils
::csrfNotVerified();
45 setReminderAsProcessed($_POST['drR']);
46 // ----- get updated data
47 $reminders = RemindersArray($days_to_show, $today, $alerts_to_show);
48 // ----- echo for ajax to use
49 echo getRemindersHTML($today, $reminders);
50 // stop any other output
54 //-----------------------------------------------------------------------------
55 // END HANDLE AJAX TO MARK REMINDERS AS READ
56 // ----------------------------------------------------------------------------
58 $reminders = RemindersArray($days_to_show, $today, $alerts_to_show);
71 padding
:5px
5px
8px
5px
;
79 text
-decoration
: none
;
84 text
-decoration
: underline
;
90 $
(".hideDR").click(function(){
91 if($
(this
).html() == "<span><?php echo xla('Hide Reminders') ?></span>"){
92 $
(this
).html("<span><?php echo xla('Show Reminders') ?></span>");
93 $
(".drHide").slideUp("slow");
96 $
(this
).html("<span><?php echo xla('Hide Reminders') ?></span>");
97 $
(".drHide").slideDown("slow");
101 // run updater after 30 seconds
102 var updater
= setTimeout("updateme(0)", 1);
105 function openAddScreen(id
){
107 top
.restoreSession();
108 dlgopen('<?php echo $GLOBALS['webroot
']; ?>/interface/main/dated_reminders/dated_reminders_add.php', '_drAdd', 700, 500);
110 top
.restoreSession();
111 dlgopen('<?php echo $GLOBALS['webroot
']; ?>/interface/main/dated_reminders/dated_reminders_add.php?mID='+
encodeURIComponent(id
)+
'&csrf_token_form=<?php echo attr_url(CsrfUtils::collectCsrfToken()); ?>', '_drAdd', 700, 500);
115 function updateme(id
){
116 refreshInterval
= <?php
echo attr($updateDelay); ?
>;
118 $
(".drTD").html('<p class="text-body font-weight-bold" style="font-size: 3rem; margin-left: 200px;"><?php echo xla("Processing") ?>...</p>');
122 $
(".drTD").html('<p class="text-body font-weight-bold" style="font-size: 3rem; margin-left: 200px;"><?php echo xla("Processing") ?>...</p>');
125 top
.restoreSession();
127 // Send the skip_timeout_reset parameter to not count this as a manual entry in the
128 // timing out mechanism in OpenEMR.
129 $
.post("<?php echo $GLOBALS['webroot']; ?>/interface/main/dated_reminders/dated_reminders.php",
132 skip_timeout_reset
: "1",
133 csrf_token_form
: "<?php echo attr(CsrfUtils::collectCsrfToken()); ?>"
136 if (data
== 'error') {
137 alert("<?php echo xls('Error Removing Message') ?>");
140 $
(".drTD").html('<p class="text-body font-weight-bold" style="font-size: 3rem; margin-left: 200px;"><?php echo xla("Refreshing Reminders") ?> ...</p>');
142 $
(".drTD").html(data
);
145 // run updater every refreshInterval seconds
146 var repeater
= setTimeout("updateme(0)", refreshInterval
);
150 function openLogScreen(){
151 top
.restoreSession();
152 dlgopen('<?php echo $GLOBALS['webroot
']; ?>/interface/main/dated_reminders/dated_reminders_log.php', '_drLog', 'modal-mlg', 850);
155 function goPid(pid
) {
156 top
.restoreSession();
157 <?php
echo " top.RTop.location = '../../patient_file/summary/demographics.php' " .
158 "+ '?set_pid=' + pid;\n"; ?
>
164 // initialize html string
165 $pdHTML = '<div class="container">
166 <div class="drHide col-12">' .
167 '<a title="' . xla('View Past and Future Reminders') . '" onclick="openLogScreen()" class="btn btn-secondary btn-sm btn-show" href="#">' . xlt('View Log') . '</a> ' . '<a onclick="openAddScreen(0)" class="btn btn-primary btn-sm btn-add" href="#">' . xlt('Create A Dated Reminder') . '</a>
169 <div class="col-12 pre-scrollable oe-margin-t-10">
171 <legend>' . xla('Dated Reminders') . '</legend>
172 <table class="table-sm">
174 <td class="drHide drTD">';
176 $pdHTML .= getRemindersHTML($today, $reminders);
177 $pdHTML .= '</td></tr></table></fieldset></div></div>';