update message codes
[openemr.git] / interface / fax / faxq.php
blob31b2e29545dc3424172f3e794b044ef78d4b9550
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['enable_hylafax']) {
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 && $GLOBALS['enable_scanner']) {
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>
78 <?php html_header_show();?>
80 <link rel="stylesheet" href='<?php echo $css_header ?>' type='text/css'>
81 <title><?php xl('Received Faxes','e'); ?></title>
83 <style>
84 td {
85 font-family: Arial, Helvetica, sans-serif;
86 padding-left: 4px;
87 padding-right: 4px;
89 a, a:visited, a:hover {
90 color:#0000cc;
92 tr.head {
93 font-size:10pt;
94 background-color:#cccccc;
95 font-weight: bold;
97 tr.detail {
98 font-size:10pt;
100 td.tabhead {
101 font-size: 11pt;
102 font-weight: bold;
103 height: 20pt;
104 text-align: center;
106 </style>
108 <script type="text/javascript" src="../../library/dialog.js"></script>
110 <script language="JavaScript">
112 // Process click on a tab.
113 function tabclick(tabname) {
114 var tabs = new Array('faxin', 'faxout', 'scanin');
115 var visdisp = document.getElementById('bigtable').style.display;
116 for (var i in tabs) {
117 var thistd = document.getElementById('td_tab_' + tabs[i]);
118 var thistable = document.getElementById('table_' + tabs[i]);
119 if (tabs[i] == tabname) {
120 // thistd.style.borderBottom = '0px solid #000000';
121 thistd.style.borderBottom = '2px solid transparent';
122 thistd.style.color = '#cc0000';
123 thistd.style.cursor = 'default';
124 thistable.style.display = visdisp;
125 } else {
126 thistd.style.borderBottom = '2px solid #000000';
127 thistd.style.color = '#777777';
128 thistd.style.cursor = 'pointer';
129 thistable.style.display = 'none';
134 // Callback from popups to refresh this display.
135 function refreshme() {
136 location.reload();
139 // Process click on filename to view.
140 function dodclick(ffname) {
141 cascwin('fax_view.php?file=' + ffname, '_blank', 600, 475,
142 "resizable=1,scrollbars=1");
143 return false;
146 // Process click on Job ID to view.
147 function dojclick(jobid) {
148 cascwin('fax_view.php?jid=' + jobid, '_blank', 600, 475,
149 "resizable=1,scrollbars=1");
150 return false;
153 // Process scanned document filename to view.
154 function dosvclick(sfname) {
155 cascwin('fax_view.php?scan=' + sfname, '_blank', 600, 475,
156 "resizable=1,scrollbars=1");
157 return false;
160 // Process click to pop up the fax dispatch window.
161 function domclick(ffname) {
162 cascwin('fax_dispatch.php?file=' + ffname, '_blank', 850, 550,
163 "resizable=1,scrollbars=1");
166 // Process click to pop up the scanned document dispatch window.
167 function dosdclick(sfname) {
168 cascwin('fax_dispatch.php?scan=' + sfname, '_blank', 850, 550,
169 "resizable=1,scrollbars=1");
172 </script>
174 </head>
176 <body class="body_top">
177 <table cellspacing='0' cellpadding='0' style='margin: 0 0 0 0; border: 2px solid #000000;'
178 id='bigtable' width='100%' height='100%'>
179 <tr style='height: 20px;'>
180 <td width='33%' id='td_tab_faxin' class='tabhead'
181 <?php if ($GLOBALS['enable_hylafax']) { ?>
182 style='color: #cc0000; border-right: 2px solid #000000; border-bottom: 2px solid transparent;'
183 <?php } else { ?>
184 style='color: #777777; border-right: 2px solid #000000; border-bottom: 2px solid #000000; cursor: pointer; display:none;'
185 <?php } ?>
186 onclick='tabclick("faxin")'><?php xl('Faxes In','e'); ?></td>
187 <td width='33%' id='td_tab_faxout' class='tabhead'
188 <?php if ($GLOBALS['enable_hylafax']) { ?>
189 style='color: #777777; border-right: 2px solid #000000; border-bottom: 2px solid #000000; cursor: pointer;'
190 <?php } else { ?>
191 style='color: #777777; border-right: 2px solid #000000; border-bottom: 2px solid #000000; cursor: pointer; display:none;'
192 <?php } ?>
193 onclick='tabclick("faxout")'><?php xl('Faxes Out','e'); ?></td>
194 <td width='34%' id='td_tab_scanin' class='tabhead'
195 <?php if ($GLOBALS['enable_scanner']) { ?>
196 style='color: #777777; border-bottom: 2px solid #000000; cursor: pointer;'
197 <?php } else { ?>
198 style='color: #cc0000; border-bottom: 2px solid transparent; display:none;'
199 <?php } ?>
200 onclick='tabclick("scanin")'><?php xl('Scanner In','e'); ?></td>
201 </tr>
202 <tr>
203 <td colspan='3' style='padding: 5px;' valign='top'>
205 <form method='post' action='faxq.php'>
207 <table width='100%' cellpadding='1' cellspacing='2' id='table_faxin'
208 <?php if (!$GLOBALS['enable_hylafax']) echo "style='display:none;'"; ?>>
209 <tr class='head'>
210 <td colspan='2' title='Click to view'><?php xl('Document','e'); ?></td>
211 <td><?php xl('Received','e'); ?></td>
212 <td><?php xl('From','e'); ?></td>
213 <td align='right'><?php xl('Pages','e'); ?></td>
214 </tr>
215 <?php
217 $encount = 0;
218 foreach ($mlines as $matches) {
219 ++$encount;
220 $ffname = $matches[4];
221 $ffbase = basename("/$ffname", '.tif');
222 $bgcolor = "#" . (($encount & 1) ? "ddddff" : "ffdddd");
223 echo " <tr class='detail' bgcolor='$bgcolor'>\n";
224 echo " <td onclick='dodclick(\"$ffname\")'>";
225 echo "<a href='fax_view.php?file=$ffname' onclick='return false'>$ffbase</a></td>\n";
226 echo " <td onclick='domclick(\"$ffname\")'>";
227 echo "<a href='fax_dispatch.php?file=$ffname' onclick='return false'>" . xl('Dispatch','e') . "</a></td>\n";
228 echo " <td>" . htmlentities($matches[3]) . "</td>\n";
229 echo " <td>" . htmlentities($matches[2]) . "</td>\n";
230 echo " <td align='right'>" . htmlentities($matches[1]) . "</td>\n";
231 echo " </tr>\n";
234 </table>
236 <table width='100%' cellpadding='1' cellspacing='2' id='table_faxout'
237 style='display:none;'>
238 <tr class='head'>
239 <td title='Click to view'><?php xl('Job ID','e'); ?></td>
240 <td><?php xl('To','e'); ?></td>
241 <td><?php xl('Pages','e'); ?></td>
242 <td><?php xl('Dials','e'); ?></td>
243 <td><?php xl('TTS','e'); ?></td>
244 <td><?php xl('Status','e'); ?></td>
245 </tr>
246 <?php
247 $encount = 0;
248 foreach ($dlines as $matches) {
249 ++$encount;
250 $jobid = $matches[1];
251 $ffstatus = $faxstats[$matches[3]];
252 $fftts = '';
253 $ffstatend = trim($matches[8]);
254 if (preg_match('/^(\d+:\d+)\s*(.*)$/', $ffstatend, $tmp)) {
255 $fftts = $tmp[1];
256 $ffstatend = $tmp[2];
258 if ($ffstatend) $ffstatus .= ': ' . $ffstatend;
259 $bgcolor = "#" . (($encount & 1) ? "ddddff" : "ffdddd");
260 echo " <tr class='detail' bgcolor='$bgcolor'>\n";
261 echo " <td onclick='dojclick(\"$jobid\")'>" .
262 "<a href='fax_view.php?jid=$jobid' onclick='return false'>" .
263 "$jobid</a></td>\n";
264 echo " <td>" . htmlentities($matches[5]) . "</td>\n";
265 echo " <td>" . htmlentities($matches[6]) . "</td>\n";
266 echo " <td>" . htmlentities($matches[7]) . "</td>\n";
267 echo " <td>" . htmlentities($fftts) . "</td>\n";
268 echo " <td>" . htmlentities($ffstatus) . "</td>\n";
269 echo " </tr>\n";
272 </table>
274 <table width='100%' cellpadding='1' cellspacing='2' id='table_scanin'
275 <?php if ($GLOBALS['enable_hylafax']) echo "style='display:none;'"; ?>>
276 <tr class='head'>
277 <td colspan='2' title='Click to view'><?php xl('Filename','e'); ?></td>
278 <td><?php xl('Scanned','e'); ?></td>
279 <td align='right'><?php xl('Length','e'); ?></td>
280 </tr>
281 <?php
282 $encount = 0;
283 foreach ($slines as $sline) {
284 ++$encount;
285 $bgcolor = "#" . (($encount & 1) ? "ddddff" : "ffdddd");
286 $sfname = $sline[0]; // filename
287 $sfdate = date('Y-m-d H:i', $sline[9]);
288 echo " <tr class='detail' bgcolor='$bgcolor'>\n";
289 echo " <td onclick='dosvclick(\"$sfname\")'>" .
290 "<a href='fax_view.php?scan=$sfname' onclick='return false'>" .
291 "$sfname</a></td>\n";
292 echo " <td onclick='dosdclick(\"$sfname\")'>";
293 echo "<a href='fax_dispatch.php?scan=$sfname' onclick='return false'>" . xl('Dispatch','e') . "</a></td>\n";
294 echo " <td>$sfdate</td>\n";
295 echo " <td align='right'>" . $sline[7] . "</td>\n";
296 echo " </tr>\n";
299 </table>
301 </form>
303 </td>
304 </tr>
305 </table>
306 </body>
307 </html>