added comment
[openemr.git] / interface / fax / faxq.php
blob3c84d83b81b4b6435c91bb214578309ecb01ea11
1 <?php
2 // Copyright (C) 2006 Rod Roark <rod@sunsetsystems.com>
3 //
4 // This program is free software; you can redistribute it and/or
5 // modify it under the terms of the GNU General Public License
6 // as published by the Free Software Foundation; either version 2
7 // of the License, or (at your option) any later version.
9 require_once("../globals.php");
10 require_once("$srcdir/acl.inc");
12 $faxstats = array(
13 'B' => xl('Blocked'),
14 'D' => xl('Sent successfully'),
15 'F' => xl('Failed'),
16 'P' => xl('Pending'),
17 'R' => xl('Send in progress'),
18 'S' => xl('Sleeping'),
19 'T' => xl('Suspended'),
20 'W' => xl('Waiting')
23 $mlines = array();
24 $dlines = array();
25 $slines = array();
27 if ($GLOBALS['hylafax_server']) {
28 // Get the recvq entries, parse and sort by filename.
29 $statlines = array();
30 exec("faxstat -r -l -h " . $GLOBALS['hylafax_server'], $statlines);
31 foreach ($statlines as $line) {
32 // This gets pagecount, sender, time, filename. We are expecting the
33 // string to start with "-rw-rw-" so as to exclude faxes not yet fully
34 // received, for which permissions are "-rw----".
35 if (preg_match('/^-r\S\Sr\S\S\s+(\d+)\s+\S+\s+(.+)\s+(\S+)\s+(\S+)\s*$/', $line, $matches)) {
36 $mlines[$matches[4]] = $matches;
39 ksort($mlines);
41 // Get the doneq entries, parse and sort by job ID
42 /* for example:
43 JID Pri S Owner Number Pages Dials TTS Status
44 155 123 D nobody 6158898622 1:1 5:12
45 153 124 D nobody 6158896439 1:1 4:12
46 154 124 F nobody 6153551807 0:1 4:12 No carrier detected
48 $donelines = array();
49 exec("faxstat -s -d -l -h " . $GLOBALS['hylafax_server'], $donelines);
50 foreach ($donelines as $line) {
51 // This gets jobid, priority, statchar, owner, phone, pages, dials and tts/status.
52 if (preg_match('/^(\d+)\s+(\d+)\s+(\S)\s+(\S+)\s+(\S+)\s+(\d+:\d+)\s+(\d+:\d+)(.*)$/', $line, $matches)) {
53 $dlines[$matches[1]] = $matches;
56 ksort($dlines);
59 $scandir = $GLOBALS['scanner_output_directory'];
60 if ($scandir) {
61 // Get the directory entries, parse and sort by date and time.
62 $dh = opendir($scandir);
63 if (! $dh) die("Cannot read $scandir");
64 while (false !== ($sfname = readdir($dh))) {
65 if (substr($sfname, 0, 1) == '.') continue;
66 $tmp = stat("$scandir/$sfname");
67 $tmp[0] = $sfname; // put filename in slot 0 which we don't otherwise need
68 $slines[$tmp[9] . $tmp[1]] = $tmp; // key is file mod time and inode number
70 closedir($dh);
71 ksort($slines);
75 <html>
77 <head>
79 <link rel=stylesheet href='<?php echo $css_header ?>' type='text/css'>
80 <title><?php xl('Received Faxes','e'); ?></title>
82 <style>
83 td {
84 font-family: Arial, Helvetica, sans-serif;
85 padding-left: 4px;
86 padding-right: 4px;
88 a, a:visited, a:hover {
89 color:#0000cc;
91 tr.head {
92 font-size:10pt;
93 background-color:#cccccc;
94 font-weight: bold;
96 tr.detail {
97 font-size:10pt;
99 td.tabhead {
100 font-size: 11pt;
101 font-weight: bold;
102 height: 20pt;
103 text-align: center;
105 </style>
107 <script type="text/javascript" src="../../library/dialog.js"></script>
109 <script language="JavaScript">
111 // Process click on a tab.
112 function tabclick(tabname) {
113 var tabs = new Array('faxin', 'faxout', 'scanin');
114 var visdisp = document.getElementById('bigtable').style.display;
115 for (var i in tabs) {
116 var thistd = document.getElementById('td_tab_' + tabs[i]);
117 var thistable = document.getElementById('table_' + tabs[i]);
118 if (tabs[i] == tabname) {
119 // thistd.style.borderBottom = '0px solid #000000';
120 thistd.style.borderBottom = '2px solid transparent';
121 thistd.style.color = '#cc0000';
122 thistd.style.cursor = 'default';
123 thistable.style.display = visdisp;
124 } else {
125 thistd.style.borderBottom = '2px solid #000000';
126 thistd.style.color = '#777777';
127 thistd.style.cursor = 'pointer';
128 thistable.style.display = 'none';
133 // Callback from popups to refresh this display.
134 function refreshme() {
135 location.reload();
138 // Process click on filename to view.
139 function dodclick(ffname) {
140 cascwin('fax_view.php?file=' + ffname, '_blank', 600, 475,
141 "resizable=1,scrollbars=1");
142 return false;
145 // Process click on Job ID to view.
146 function dojclick(jobid) {
147 cascwin('fax_view.php?jid=' + jobid, '_blank', 600, 475,
148 "resizable=1,scrollbars=1");
149 return false;
152 // Process scanned document filename to view.
153 function dosvclick(sfname) {
154 cascwin('fax_view.php?scan=' + sfname, '_blank', 600, 475,
155 "resizable=1,scrollbars=1");
156 return false;
159 // Process click to pop up the fax dispatch window.
160 function domclick(ffname) {
161 cascwin('fax_dispatch.php?file=' + ffname, '_blank', 850, 550,
162 "resizable=1,scrollbars=1");
165 // Process click to pop up the scanned document dispatch window.
166 function dosdclick(sfname) {
167 cascwin('fax_dispatch.php?scan=' + sfname, '_blank', 850, 550,
168 "resizable=1,scrollbars=1");
171 </script>
173 </head>
175 <body <?php echo $top_bg_line;?>>
176 <table cellspacing='0' cellpadding='0' style='margin: 0 0 0 0; border: 2px solid #000000;'
177 id='bigtable' width='100%' height='100%'>
178 <tr style='height: 20px;'>
179 <td width='33%' id='td_tab_faxin' class='tabhead'
180 <?php if ($GLOBALS['hylafax_server']) { ?>
181 style='color: #cc0000; border-right: 2px solid #000000; border-bottom: 2px solid transparent;'
182 <?php } else { ?>
183 style='color: #777777; border-right: 2px solid #000000; border-bottom: 2px solid #000000; cursor: pointer;'
184 <?php } ?>
185 onclick='tabclick("faxin")'><?php xl('Faxes In','e'); ?></td>
186 <td width='33%' id='td_tab_faxout' class='tabhead'
187 style='color: #777777; border-right: 2px solid #000000; border-bottom: 2px solid #000000; cursor: pointer;'
188 onclick='tabclick("faxout")'><?php xl('Faxes Out','e'); ?></td>
189 <td width='34%' id='td_tab_scanin' class='tabhead'
190 <?php if ($GLOBALS['hylafax_server']) { ?>
191 style='color: #777777; border-bottom: 2px solid #000000; cursor: pointer;'
192 <?php } else { ?>
193 style='color: #cc0000; border-bottom: 2px solid transparent;'
194 <?php } ?>
195 onclick='tabclick("scanin")'><?php xl('Scanner In','e'); ?></td>
196 </tr>
197 <tr>
198 <td colspan='3' style='padding: 5px;' valign='top'>
200 <form method='post' action='faxq.php'>
202 <table width='100%' cellpadding='1' cellspacing='2' id='table_faxin'
203 <?php if (!$GLOBALS['hylafax_server']) echo "style='display:none;'"; ?>>
204 <tr class='head'>
205 <td colspan='2' title='Click to view'><?php xl('Document','e'); ?></td>
206 <td><?php xl('Received','e'); ?></td>
207 <td><?php xl('From','e'); ?></td>
208 <td align='right'><?php xl('Pages','e'); ?></td>
209 </tr>
211 $encount = 0;
212 foreach ($mlines as $matches) {
213 ++$encount;
214 $ffname = $matches[4];
215 $ffbase = basename("/$ffname", '.tif');
216 $bgcolor = "#" . (($encount & 1) ? "ddddff" : "ffdddd");
217 echo " <tr class='detail' bgcolor='$bgcolor'>\n";
218 echo " <td onclick='dodclick(\"$ffname\")'>";
219 echo "<a href='fax_view.php?file=$ffname' onclick='return false'>$ffbase</a></td>\n";
220 echo " <td onclick='domclick(\"$ffname\")'>";
221 echo "<a href='fax_dispatch.php?file=$ffname' onclick='return false'>" . xl('Dispatch','e') . "</a></td>\n";
222 echo " <td>" . htmlentities($matches[3]) . "</td>\n";
223 echo " <td>" . htmlentities($matches[2]) . "</td>\n";
224 echo " <td align='right'>" . htmlentities($matches[1]) . "</td>\n";
225 echo " </tr>\n";
228 </table>
230 <table width='100%' cellpadding='1' cellspacing='2' id='table_faxout'
231 style='display:none;'>
232 <tr class='head'>
233 <td title='Click to view'><?php xl('Job ID','e'); ?></td>
234 <td><?php xl('To','e'); ?></td>
235 <td><?php xl('Pages','e'); ?></td>
236 <td><?php xl('Dials','e'); ?></td>
237 <td><?php xl('TTS','e'); ?></td>
238 <td><?php xl('Status','e'); ?></td>
239 </tr>
241 $encount = 0;
242 foreach ($dlines as $matches) {
243 ++$encount;
244 $jobid = $matches[1];
245 $ffstatus = $faxstats[$matches[3]];
246 $fftts = '';
247 $ffstatend = trim($matches[8]);
248 if (preg_match('/^(\d+:\d+)\s*(.*)$/', $ffstatend, $tmp)) {
249 $fftts = $tmp[1];
250 $ffstatend = $tmp[2];
252 if ($ffstatend) $ffstatus .= ': ' . $ffstatend;
253 $bgcolor = "#" . (($encount & 1) ? "ddddff" : "ffdddd");
254 echo " <tr class='detail' bgcolor='$bgcolor'>\n";
255 echo " <td onclick='dojclick(\"$jobid\")'>" .
256 "<a href='fax_view.php?jid=$jobid' onclick='return false'>" .
257 "$jobid</a></td>\n";
258 echo " <td>" . htmlentities($matches[5]) . "</td>\n";
259 echo " <td>" . htmlentities($matches[6]) . "</td>\n";
260 echo " <td>" . htmlentities($matches[7]) . "</td>\n";
261 echo " <td>" . htmlentities($fftts) . "</td>\n";
262 echo " <td>" . htmlentities($ffstatus) . "</td>\n";
263 echo " </tr>\n";
266 </table>
268 <table width='100%' cellpadding='1' cellspacing='2' id='table_scanin'
269 <?php if ($GLOBALS['hylafax_server']) echo "style='display:none;'"; ?>>
270 <tr class='head'>
271 <td colspan='2' title='Click to view'><?php xl('Filename','e'); ?></td>
272 <td><?php xl('Scanned','e'); ?></td>
273 <td align='right'><?php xl('Length','e'); ?></td>
274 </tr>
276 $encount = 0;
277 foreach ($slines as $sline) {
278 ++$encount;
279 $bgcolor = "#" . (($encount & 1) ? "ddddff" : "ffdddd");
280 $sfname = $sline[0]; // filename
281 $sfdate = date('Y-m-d H:i', $sline[9]);
282 echo " <tr class='detail' bgcolor='$bgcolor'>\n";
283 echo " <td onclick='dosvclick(\"$sfname\")'>" .
284 "<a href='fax_view.php?scan=$sfname' onclick='return false'>" .
285 "$sfname</a></td>\n";
286 echo " <td onclick='dosdclick(\"$sfname\")'>";
287 echo "<a href='fax_dispatch.php?scan=$sfname' onclick='return false'>" . xl('Dispatch','e') . "</a></td>\n";
288 echo " <td>$sfdate</td>\n";
289 echo " <td align='right'>" . $sline[7] . "</td>\n";
290 echo " </tr>\n";
293 </table>
295 </form>
297 </td>
298 </tr>
299 </table>
300 </body>
301 </html>