reverted erroneous previous commit ecaf3a658c94eb6af81fa0b1989a9b60d3d318b0
[openemr.git] / interface / main / dated_reminders / dated_reminders.php
blob27a01771a6ff89cd48d0dbff4ac2a12b321be986
1 <?php
2 /**
3 * Used for displaying dated reminders.
5 * Copyright (C) 2012 tajemo.co.za <http://www.tajemo.co.za/>
7 * LICENSE: This program is free software; you can redistribute it and/or
8 * modify it under the terms of the GNU General Public License
9 * as published by the Free Software Foundation; either version 3
10 * of the License, or (at your option) any later version.
11 * This program is distributed in the hope that it will be useful,
12 * but WITHOUT ANY WARRANTY; without even the implied warranty of
13 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14 * GNU General Public License for more details.
15 * You should have received a copy of the GNU General Public License
16 * along with this program. If not, see <http://opensource.org/licenses/gpl-license.php>;.
18 * @package OpenEMR
19 * @author Craig Bezuidenhout <http://www.tajemo.co.za/>
20 * @link http://www.open-emr.org
23 // removed as jquery is already called in messages page (if you need to use jQuery, uncomment it futher down)
24 // not neeeded as messages page handles this
25 // $fake_register_globals=false;
26 // $sanitize_all_escapes=true;
27 require_once('../../globals.php');
28 require_once("$srcdir/htmlspecialchars.inc.php");
29 require_once("$srcdir/dated_reminder_functions.php");
31 $days_to_show = 5;
32 $alerts_to_show = 5;
33 $updateDelay = 60; // time is seconds
36 // ----- get time stamp for start of today, this is used to check for due and overdue reminders
37 $today = strtotime(date('Y/m/d'));
39 // ----- set $hasAlerts to false, this is used for auto-hiding reminders if there are no due or overdue reminders
40 $hasAlerts = false;
42 // mulitply $updateDelay by 1000 to get miliseconds
43 $updateDelay = $updateDelay * 1000;
45 //-----------------------------------------------------------------------------
46 // HANDEL AJAX TO MARK REMINDERS AS READ
47 // Javascript will send a post
48 // ----------------------------------------------------------------------------
49 if(isset($_POST['drR'])){
50 // set as processed
51 setReminderAsProcessed($_POST['drR']);
52 // ----- get updated data
53 $reminders = RemindersArray($days_to_show,$today,$alerts_to_show);
54 // ----- echo for ajax to use
55 echo getRemindersHTML($reminders,$today);
56 // stop any other output
57 exit;
59 //-----------------------------------------------------------------------------
60 // END HANDEL AJAX TO MARK REMINDERS AS READ
61 // ----------------------------------------------------------------------------
63 $reminders = RemindersArray($days_to_show,$today,$alerts_to_show);
65 ?>
67 <style type="text/css">
68 div.dr{
69 margin:0;
70 font-size:0.6em;
72 .dr_container a{
73 font-size:0.6em;
75 .dr_container{
76 padding:5px 5px 8px 5px;
78 .dr_container p{
79 margin:6px 0 0 0;
81 .patLink{
82 font-weight: bolder;
83 cursor:pointer;
84 text-decoration: none;
86 .patLink:hover{
87 font-weight: bolder;
88 cursor:pointer;
89 text-decoration: underline;
91 </style>
92 <script type="text/javascript">
93 $(document).ready(function (){
94 <?php if(!$hasAlerts) echo '$(".hideDR").html("<span>'.xla('Show Reminders').'</span>"); $(".drHide").hide();'; ?>
95 $(".hideDR").click(function(){
96 if($(this).html() == "<span><?php echo xla('Hide Reminders') ?></span>"){
97 $(this).html("<span><?php echo xla('Show Reminders') ?></span>");
98 $(".drHide").slideUp("slow");
100 else{
101 $(this).html("<span><?php echo xla('Hide Reminders') ?></span>");
102 $(".drHide").slideDown("slow");
105 // run updater after 30 seconds
106 var updater = setTimeout("updateme(0)", 1);
109 function openAddScreen(id){
110 if(id == 0){
111 top.restoreSession();
112 dlgopen('<?php echo $GLOBALS['webroot']; ?>/interface/main/dated_reminders/dated_reminders_add.php', '_drAdd', 700, 500);
113 }else{
114 top.restoreSession();
115 dlgopen('<?php echo $GLOBALS['webroot']; ?>/interface/main/dated_reminders/dated_reminders_add.php?mID='+id, '_drAdd', 700, 500);
119 function updateme(id){
120 refreshInterval = <?php echo $updateDelay ?>;
121 if(id > 0){
122 $(".drTD").html('<p style="text-size:3em; margin-left:200px; color:black; font-weight:bold;"><?php echo xla("Processing") ?>...</p>');
124 if(id == 'new'){
125 $(".drTD").html('<p style="text-size:3em; margin-left:200px; color:black; font-weight:bold;"><?php echo xla("Processing") ?>...</p>');
127 top.restoreSession();
128 // Send the skip_timeout_reset parameter to not count this as a manual entry in the
129 // timing out mechanism in OpenEMR.
130 $.post("<?php echo $GLOBALS['webroot']; ?>/interface/main/dated_reminders/dated_reminders.php",
131 { drR: id, skip_timeout_reset: "1" },
132 function(data) {
133 if(data == 'error'){
134 alert("<?php echo addslashes(xl('Error Removing Message')) ?>");
135 }else{
136 if(id > 0){
137 $(".drTD").html('<p style="text-size:3em; margin-left:200px; color:black; font-weight:bold;"><?php echo xla("Refreshing Reminders") ?> ...</p>');
139 $(".drTD").html(data);
141 // run updater every refreshInterval seconds
142 var repeater = setTimeout("updateme(0)", refreshInterval);
146 function openLogScreen(){
147 top.restoreSession();
148 dlgopen('<?php echo $GLOBALS['webroot']; ?>/interface/main/dated_reminders/dated_reminders_log.php', '_drLog', 700, 500);
152 function goPid(pid) {
153 top.restoreSession();
154 <?php
155 if ($GLOBALS['concurrent_layout']){
156 echo " top.RTop.location = '../../patient_file/summary/demographics.php' " .
157 "+ '?set_pid=' + pid;\n";
158 } else{
159 echo " top.location = '../../patient_file/patient_file.php' " .
160 "+ '?set_pid=' + pid + '&pid=' + pid;\n";
164 </script>
166 <?php
167 // initialize html string
168 $pdHTML = '<div class="dr_container"><table><tr><td valign="top">
169 <p><a class="hideDR css_button_small" href="#"><span>'.xlt('Hide Reminders').'</span></a><br /></p>
170 <div class="drHide">'.
171 '<p><a title="'.xla('View Past and Future Reminders').'" onclick="openLogScreen()" class="css_button_small" href="#"><span>'.xlt('View Log').'</span></a><br /></p>'
172 .'<p><a onclick="openAddScreen(0)" class="css_button_small" href="#"><span>'.xlt('Send A Dated Reminder').'</span></a></p></div>
173 </td><td class="drHide drTD">';
175 $pdHTML .= getRemindersHTML($reminders,$today);
176 $pdHTML .= '</td></tr></table></div>';
177 // print output
178 echo $pdHTML;