quick minor path updates (#1968)
[openemr.git] / interface / main / daemon_frame.php
blob90b1a9f3672de8aac68d91308cc8d6e164c5be4d
1 <?php
2 /**
3 * This script runs in a hidden frame, reloads itself periodically,
4 * and does whatever might need doing in the background.
6 * @package OpenEMR
7 * @link http://www.open-emr.org
8 * @author Rod Roark <rod@sunsetsystems.com>
9 * @author Brady Miller <brady.g.miller@gmail.com>
10 * @copyright Copyright (c) 2006 Rod Roark <rod@sunsetsystems.com>
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
16 // Tell auth.inc that this is the daemon script; this is so that
17 // inactivity timeouts will still work, and to avoid logging an
18 // event every time we run.
19 $GLOBALS['DAEMON_FLAG'] = true;
21 require_once("../globals.php");
23 $daemon_interval = 120; // Interval in seconds between reloads.
24 $colorh = '#ff0000'; // highlight color
25 $colorn = '#000000'; // normal color
27 // Check if there are faxes in the recvq.
28 $faxcount = 0;
29 if ($GLOBALS['enable_hylafax']) {
30 $statlines = array();
31 exec("faxstat -r -l -h " . escapeshellarg($GLOBALS['hylafax_server']), $statlines);
32 foreach ($statlines as $line) {
33 if (substr($line, 0, 1) == '-') {
34 ++$faxcount;
39 $color_fax = $faxcount ? $colorh : $colorn;
41 // Check if this user has any active patient notes assigned to them.
42 $row = sqlQuery("SELECT count(*) AS count FROM pnotes WHERE " .
43 "activity = 1 ".
44 " AND deleted != 1 ". // exlude ALL deleted notes
45 " AND assigned_to = ?", array($_SESSION['authUser']));
46 $color_aun = $row['count'] ? $colorh : $colorn;
48 <html>
49 <body bgcolor="#000000">
50 <script language='JavaScript'>
52 function timerint() {
53 location.reload();
54 return;
57 var ld = parent.left_nav.document;
59 if (ld && ld.getElementById('searchFields')) {
60 setTimeout('timerint()', <?php echo attr(($daemon_interval * 1000)); ?>);
62 var elem = ld.getElementById('lbl_fax');
63 if (elem) elem.style.color = '<?php echo attr($color_fax); ?>';
65 elem = ld.getElementById('lbl_aun');
66 if (elem) elem.style.color = '<?php echo attr($color_aun); ?>';
68 else {
69 // Nav frame is not fully loaded yet, so wait a few secs.
70 setTimeout('timerint()', 5000);
73 </script>
74 </body>
75 </html>