Dated Reminders Module Improvements:
[openemr.git] / interface / main / dated_reminders / dated_reminders.php
blob62dec26f803e2f8e9520088b9546141bdaaba754
1 <?php
2 // ------------------------------------------------------------------------ //
3 // OpenEMR Electronic Medical Records System //
4 // Copyright (c) 2012 tajemo.co.za //
5 // <http://www.tajemo.co.za/> //
6 // ------------------------------------------------------------------------ //
7 // This program is free software; you can redistribute it and/or modify //
8 // it under the terms of the GNU General Public License as published by //
9 // the Free Software Foundation; either version 2 of the License, or //
10 // (at your option) any later version. //
11 // //
12 // You may not change or alter any portion of this comment or credits //
13 // of supporting developers from this source code or any supporting //
14 // source code which is considered copyrighted (c) material of the //
15 // original comment or credit authors. //
16 // //
17 // This program is distributed in the hope that it will be useful, //
18 // but WITHOUT ANY WARRANTY; without even the implied warranty of //
19 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the //
20 // GNU General Public License for more details. //
21 // //
22 // You should have received a copy of the GNU General Public License //
23 // along with this program; if not, write to the Free Software //
24 // Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA //
25 // --------------------------------------------------------------------------//
26 // Original Author of this file: Craig Bezuidenhout (Tajemo Enterprises) //
27 // Purpose of this file: Used for displaying dated reminders //
28 // --------------------------------------------------------------------------//
30 // removed as jquery is already called in messages page (if you need to use jQuery, uncomment it futher down)
31 // not neeeded as messages page handles this
32 // $fake_register_globals=false;
33 // $sanitize_all_escapes=true;
34 require_once("../../globals.php");
35 require_once("$srcdir/htmlspecialchars.inc.php");
36 require_once("$srcdir/dated_reminders.php");
38 $days_to_show = 5;
39 $alerts_to_show = 5;
40 $updateDelay = 60; // time is seconds
43 // ----- get time stamp for start of today, this is used to check for due and overdue reminders
44 $today = strtotime(date('Y/m/d'));
46 // ----- set $hasAlerts to false, this is used for auto-hiding reminders if there are no due or overdue reminders
47 $hasAlerts = false;
49 // mulitply $updateDelay by 1000 to get miliseconds
50 $updateDelay = $updateDelay * 1000;
52 //-----------------------------------------------------------------------------
53 // HANDEL AJAX TO MARK REMINDERS AS READ
54 // Javascript will send a post
55 // ----------------------------------------------------------------------------
56 if(isset($_POST['drR'])){
57 // set as processed
58 setReminderAsProcessed($_POST['drR']);
59 // ----- get updated data
60 $reminders = RemindersArray($days_to_show,$today,$alerts_to_show);
61 // ----- echo for ajax to use
62 echo getRemindersHTML($reminders,$today);
63 // stop any other output
64 exit;
66 //-----------------------------------------------------------------------------
67 // END HANDEL AJAX TO MARK REMINDERS AS READ
68 // ----------------------------------------------------------------------------
70 $reminders = RemindersArray($days_to_show,$today,$alerts_to_show);
72 ?>
74 <style type="text/css">
75 div.dr{
76 margin:0;
77 font-size:0.6em;
79 .dr_container a{
80 font-size:0.6em;
82 .dr_container{
83 padding:5px 5px 8px 5px;
85 .dr_container p{
86 margin:6px 0 0 0;
88 .patLink{
89 font-weight: bolder;
90 cursor:pointer;
91 text-decoration: none;
93 .patLink:hover{
94 font-weight: bolder;
95 cursor:pointer;
96 text-decoration: underline;
98 </style>
99 <script type="text/javascript">
100 $(document).ready(function (){
101 <?php if(!$hasAlerts) echo '$(".hideDR").html("<span>'.xla('Show Reminders').'</span>"); $(".drHide").hide();'; ?>
102 $(".hideDR").click(function(){
103 if($(this).html() == "<span><?php echo xla('Hide Reminders') ?></span>"){
104 $(this).html("<span><?php echo xla('Show Reminders') ?></span>");
105 $(".drHide").slideUp("slow");
107 else{
108 $(this).html("<span><?php echo xla('Hide Reminders') ?></span>");
109 $(".drHide").slideDown("slow");
112 // run updater after 30 seconds
113 var updater = setTimeout("updateme(0)", 1);
116 function openAddScreen(id){
117 if(id == 0){
118 top.restoreSession();
119 dlgopen('<?php echo $GLOBALS['webroot']; ?>/interface/main/dated_reminders/dated_reminders_add.php', '_drAdd', 700, 500);
120 }else{
121 top.restoreSession();
122 dlgopen('<?php echo $GLOBALS['webroot']; ?>/interface/main/dated_reminders/dated_reminders_add.php?mID='+id, '_drAdd', 700, 500);
126 function updateme(id){
127 refreshInterval = <?php echo $updateDelay ?>;
128 if(id > 0){
129 $(".drTD").html('<p style="text-size:3em; margin-left:200px; color:black; font-weight:bold;"><?php echo xla("Processing") ?>...</p>');
131 if(id == 'new'){
132 $(".drTD").html('<p style="text-size:3em; margin-left:200px; color:black; font-weight:bold;"><?php echo xla("Processing") ?>...</p>');
134 top.restoreSession();
135 // Send the skip_timeout_reset parameter to not count this as a manual entry in the
136 // timing out mechanism in OpenEMR.
137 $.post("<?php echo $GLOBALS['webroot']; ?>/interface/main/dated_reminders/dated_reminders.php",
138 { drR: id, skip_timeout_reset: "1" },
139 function(data) {
140 if(data == 'error'){
141 alert("<?php echo addslashes(xl('Error Removing Message')) ?>");
142 }else{
143 if(id > 0){
144 $(".drTD").html('<p style="text-size:3em; margin-left:200px; color:black; font-weight:bold;"><?php echo xla("Refreshing Reminders") ?> ...</p>');
146 $(".drTD").html(data);
148 // run updater every refreshInterval seconds
149 var repeater = setTimeout("updateme(0)", refreshInterval);
153 function openLogScreen(){
154 top.restoreSession();
155 dlgopen('<?php echo $GLOBALS['webroot']; ?>/interface/main/dated_reminders/dated_reminders_log.php', '_drLog', 700, 500);
159 function goPid(pid) {
160 top.restoreSession();
161 <?php
162 if ($GLOBALS['concurrent_layout']){
163 echo " top.RTop.location = '../../patient_file/summary/demographics.php' " .
164 "+ '?set_pid=' + pid;\n";
165 } else{
166 echo " top.location = '../../patient_file/patient_file.php' " .
167 "+ '?set_pid=' + pid + '&pid=' + pid;\n";
171 </script>
173 <?php
174 // initialize html string
175 $pdHTML = '<div class="dr_container"><table><tr><td valign="top">
176 <p><a class="hideDR css_button_small" href="#"><span>'.xlt('Hide Reminders').'</span></a><br /></p>
177 <div class="drHide">'.
178 '<p><a title="'.xla('View Past and Future Reminders').'" onclick="openLogScreen()" class="css_button_small" href="#"><span>'.xlt('View Log').'</span></a><br /></p>'
179 .'<p><a onclick="openAddScreen(0)" class="css_button_small" href="#"><span>'.xlt('Send A Dated Reminder').'</span></a></p></div>
180 </td><td class="drHide drTD">';
182 $pdHTML .= getRemindersHTML($reminders,$today);
183 $pdHTML .= '</td></tr></table></div>';
184 // print output
185 echo $pdHTML;