chore: complete integration of flex-3.20 (alpine 3.20) into ci (#7538)
[openemr.git] / interface / main / dated_reminders / dated_reminders.php
blobc7d4444f05856fcc294131bfba81b82baecc9329
1 <?php
3 /**
4 * Used for displaying dated reminders.
6 * @package OpenEMR
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;
21 $days_to_show = 30;
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
30 $hasAlerts = false;
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();
44 // set as processed
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
51 exit;
54 //-----------------------------------------------------------------------------
55 // END HANDLE AJAX TO MARK REMINDERS AS READ
56 // ----------------------------------------------------------------------------
58 $reminders = RemindersArray($days_to_show, $today, $alerts_to_show);
62 <style>
63 div.dr {
64 margin: 0;
65 font-size: 0.6rem;
67 .dr_container a {
68 font-size: 0.8rem;
70 .dr_container {
71 padding:5px 5px 8px 5px;
73 .dr_container p {
74 margin: 6px 0 0 0;
76 .patLink {
77 font-weight: bolder;
78 cursor: pointer;
79 text-decoration: none;
81 .patLink:hover{
82 font-weight: bolder;
83 cursor: pointer;
84 text-decoration: underline;
86 </style>
88 <script>
89 $(function () {
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");
95 else{
96 $(this).html("<span><?php echo xla('Hide Reminders') ?></span>");
97 $(".drHide").slideDown("slow");
99 });
101 // run updater after 30 seconds
102 var updater = setTimeout("updateme(0)", 1);
105 function openAddScreen(id){
106 if (id == 0){
107 top.restoreSession();
108 dlgopen('<?php echo $GLOBALS['webroot']; ?>/interface/main/dated_reminders/dated_reminders_add.php', '_drAdd', 700, 500);
109 } else {
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); ?>;
117 if (id > 0) {
118 $(".drTD").html('<p class="text-body font-weight-bold" style="font-size: 3rem; margin-left: 200px;"><?php echo xla("Processing") ?>...</p>');
121 if (id == 'new') {
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",
131 drR: id,
132 skip_timeout_reset: "1",
133 csrf_token_form: "<?php echo attr(CsrfUtils::collectCsrfToken()); ?>"
135 function(data) {
136 if (data == 'error') {
137 alert("<?php echo xls('Error Removing Message') ?>");
138 } else {
139 if (id > 0) {
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"; ?>
161 </script>
163 <?php
164 // initialize html string
165 $pdHTML = '<div class="">
166 <div class="drHide">' .
167 '<a title="' . xla('View Past and Future Reminders') . '" onclick="openLogScreen()" class="btn btn-secondary btn-sm btn-show" href="#">' . xlt('View Log') . '</a>&nbsp;' . '<a onclick="openAddScreen(0)" class="btn btn-primary btn-sm btn-add" href="#">' . xlt('Create A Dated Reminder') . '</a>
168 </div>
169 <div class="pre-scrollable mt-3">
170 <fieldset>
171 <legend>' . xla('Dated Reminders') . '</legend>
172 <table class="table-sm">
173 </tr>
174 <td class="drHide drTD">';
176 $pdHTML .= getRemindersHTML($today, $reminders);
177 $pdHTML .= '</td></tr></table></fieldset></div></div>';
178 // print output
179 echo $pdHTML;