2 // Copyright (C) 2006 Rod Roark <rod@sunsetsystems.com>
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 use OpenEMR\Core\Header
;
16 'D' => xl('Sent successfully'),
19 'R' => xl('Send in progress'),
20 'S' => xl('Sleeping'),
21 'T' => xl('Suspended'),
29 if ($GLOBALS['enable_hylafax']) {
30 // Get the recvq entries, parse and sort by filename.
32 exec("faxstat -r -l -h " . escapeshellarg($GLOBALS['hylafax_server']), $statlines);
33 foreach ($statlines as $line) {
34 // This gets pagecount, sender, time, filename. We are expecting the
35 // string to start with "-rw-rw-" so as to exclude faxes not yet fully
36 // received, for which permissions are "-rw----".
37 if (preg_match('/^-r\S\Sr\S\S\s+(\d+)\s+\S+\s+(.+)\s+(\S+)\s+(\S+)\s*$/', $line, $matches)) {
38 $mlines[$matches[4]] = $matches;
44 // Get the doneq entries, parse and sort by job ID
46 JID Pri S Owner Number Pages Dials TTS Status
47 155 123 D nobody 6158898622 1:1 5:12
48 153 124 D nobody 6158896439 1:1 4:12
49 154 124 F nobody 6153551807 0:1 4:12 No carrier detected
52 exec("faxstat -s -d -l -h " . escapeshellarg($GLOBALS['hylafax_server']), $donelines);
53 foreach ($donelines as $line) {
54 // This gets jobid, priority, statchar, owner, phone, pages, dials and tts/status.
55 if (preg_match('/^(\d+)\s+(\d+)\s+(\S)\s+(\S+)\s+(\S+)\s+(\d+:\d+)\s+(\d+:\d+)(.*)$/', $line, $matches)) {
56 $dlines[$matches[1]] = $matches;
63 $scandir = $GLOBALS['scanner_output_directory'];
64 if ($scandir && $GLOBALS['enable_scanner']) {
65 // Get the directory entries, parse and sort by date and time.
66 $dh = opendir($scandir);
68 die("Cannot read " . text($scandir));
71 while (false !== ($sfname = readdir($dh))) {
72 if (substr($sfname, 0, 1) == '.') {
76 $tmp = stat("$scandir/$sfname");
77 $tmp[0] = $sfname; // put filename in slot 0 which we don't otherwise need
78 $slines[$tmp[9] . $tmp[1]] = $tmp; // key is file mod time and inode number
90 <?php Header
::setupHeader(['opener']);?
>
91 <title
><?php
echo xlt('Received Faxes'); ?
></title
>
95 font
-family
: Arial
, Helvetica
, sans
-serif
;
99 a
, a
:visited
, a
:hover
{
104 background
-color
:#cccccc;
118 <script language
="JavaScript">
120 // Process click on a tab.
121 function tabclick(tabname
) {
122 var tabs
= new Array('faxin', 'faxout', 'scanin');
123 var visdisp
= document
.getElementById('bigtable').style
.display
;
124 for (var i in tabs
) {
125 var thistd
= document
.getElementById('td_tab_' + tabs
[i
]);
126 var thistable
= document
.getElementById('table_' + tabs
[i
]);
127 if (tabs
[i
] == tabname
) {
128 // thistd.style.borderBottom = '0px solid #000000';
129 thistd
.style
.borderBottom
= '2px solid transparent';
130 thistd
.style
.color
= '#cc0000';
131 thistd
.style
.cursor
= 'default';
132 thistable
.style
.display
= visdisp
;
134 thistd
.style
.borderBottom
= '2px solid #000000';
135 thistd
.style
.color
= '#777777';
136 thistd
.style
.cursor
= 'pointer';
137 thistable
.style
.display
= 'none';
142 // Callback from popups to refresh this display.
143 function refreshme() {
147 // Process click on filename to view.
148 function dodclick(ffname
) {
149 cascwin('fax_view.php?file=' +
encodeURIComponent(ffname
) +
'&csrf_token_form=<?php echo attr(urlencode(collectCsrfToken())); ?>', '_blank', 600, 475,
150 "resizable=1,scrollbars=1");
154 // Process click on Job ID to view.
155 function dojclick(jobid
) {
156 cascwin('fax_view.php?jid=' +
encodeURIComponent(jobid
) +
'&csrf_token_form=<?php echo attr(urlencode(collectCsrfToken())); ?>', '_blank', 600, 475,
157 "resizable=1,scrollbars=1");
161 // Process scanned document filename to view.
162 function dosvclick(sfname
) {
163 cascwin('fax_view.php?scan=' +
encodeURIComponent(sfname
) +
'&csrf_token_form=<?php echo attr(urlencode(collectCsrfToken())); ?>', '_blank', 600, 475,
164 "resizable=1,scrollbars=1");
168 // Process click to pop up the fax dispatch window.
169 function domclick(ffname
) {
170 dlgopen('fax_dispatch.php?file=' +
encodeURIComponent(ffname
) +
'&csrf_token_form=<?php echo attr(urlencode(collectCsrfToken())); ?>', '_blank', 850, 550, '', 'Fax Dispatch');
173 // Process click to pop up the scanned document dispatch window.
174 function dosdclick(sfname
) {
175 dlgopen('fax_dispatch.php?scan=' +
encodeURIComponent(sfname
) +
'&csrf_token_form=<?php echo attr(urlencode(collectCsrfToken())); ?>', '_blank', 850, 550, '', 'Scanned Dispatch');
182 <body
class="body_top">
183 <table cellspacing
='0' cellpadding
='0' style
='margin: 0 0 0 0; border: 2px solid #000000;'
184 id
='bigtable' width
='100%' height
='100%'>
185 <tr style
='height: 20px;'>
186 <td width
='33%' id
='td_tab_faxin' class='tabhead'
187 <?php
if ($GLOBALS['enable_hylafax']) { ?
>
188 style
='color: #cc0000; border-right: 2px solid #000000; border-bottom: 2px solid transparent;'
190 style
='color: #777777; border-right: 2px solid #000000; border-bottom: 2px solid #000000; cursor: pointer; display:none;'
192 onclick
='tabclick("faxin")'><?php
echo xlt('Faxes In'); ?
></td
>
193 <td width
='33%' id
='td_tab_faxout' class='tabhead'
194 <?php
if ($GLOBALS['enable_hylafax']) { ?
>
195 style
='color: #777777; border-right: 2px solid #000000; border-bottom: 2px solid #000000; cursor: pointer;'
197 style
='color: #777777; border-right: 2px solid #000000; border-bottom: 2px solid #000000; cursor: pointer; display:none;'
199 onclick
='tabclick("faxout")'><?php
echo xlt('Faxes Out'); ?
></td
>
200 <td width
='34%' id
='td_tab_scanin' class='tabhead'
201 <?php
if ($GLOBALS['enable_scanner']) { ?
>
202 style
='color: #777777; border-bottom: 2px solid #000000; cursor: pointer;'
204 style
='color: #cc0000; border-bottom: 2px solid transparent; display:none;'
206 onclick
='tabclick("scanin")'><?php
echo xlt('Scanner In'); ?
></td
>
209 <td colspan
='3' style
='padding: 5px;' valign
='top'>
211 <form method
='post' action
='faxq.php'>
213 <table width
='100%' cellpadding
='1' cellspacing
='2' id
='table_faxin'
214 <?php
if (!$GLOBALS['enable_hylafax']) {
215 echo "style='display:none;'";
218 <td colspan
='2' title
='Click to view'><?php
echo xlt('Document'); ?
></td
>
219 <td
><?php
echo xlt('Received'); ?
></td
>
220 <td
><?php
echo xlt('From'); ?
></td
>
221 <td align
='right'><?php
echo xlt('Pages'); ?
></td
>
226 foreach ($mlines as $matches) {
228 $ffname = $matches[4];
229 $ffbase = basename("/$ffname", '.tif');
230 $bgcolor = "#" . (($encount & 1) ?
"ddddff" : "ffdddd");
231 echo " <tr class='detail' bgcolor='" . attr($bgcolor) . "'>\n";
232 echo " <td onclick='dodclick(\"" . attr(addslashes($ffname)) . "\")'>";
233 echo "<a href='fax_view.php?file=" . attr(urlencode($ffname)) . "&csrf_token_form=" . attr(urlencode(collectCsrfToken())) . "' onclick='return false'>" . text($ffbase) . "</a></td>\n";
234 echo " <td onclick='domclick(\"" . attr(addslashes($ffname)) . "\")'>";
235 echo "<a href='fax_dispatch.php?file=" . attr(urlencode($ffname)) . "&csrf_token_form=" . attr(urlencode(collectCsrfToken())) . "' onclick='return false'>" . xlt('Dispatch') . "</a></td>\n";
236 echo " <td>" . text($matches[3]) . "</td>\n";
237 echo " <td>" . text($matches[2]) . "</td>\n";
238 echo " <td align='right'>" . text($matches[1]) . "</td>\n";
244 <table width
='100%' cellpadding
='1' cellspacing
='2' id
='table_faxout'
245 style
='display:none;'>
247 <td title
='Click to view'><?php
echo xlt('Job ID'); ?
></td
>
248 <td
><?php
echo xlt('To'); ?
></td
>
249 <td
><?php
echo xlt('Pages'); ?
></td
>
250 <td
><?php
echo xlt('Dials'); ?
></td
>
251 <td
><?php
echo xlt('TTS'); ?
></td
>
252 <td
><?php
echo xlt('Status'); ?
></td
>
256 foreach ($dlines as $matches) {
258 $jobid = $matches[1];
259 $ffstatus = $faxstats[$matches[3]];
261 $ffstatend = trim($matches[8]);
262 if (preg_match('/^(\d+:\d+)\s*(.*)$/', $ffstatend, $tmp)) {
264 $ffstatend = $tmp[2];
268 $ffstatus .= ': ' . $ffstatend;
271 $bgcolor = "#" . (($encount & 1) ?
"ddddff" : "ffdddd");
272 echo " <tr class='detail' bgcolor='" . attr($bgcolor) . "'>\n";
273 echo " <td onclick='dojclick(\"" . attr(addslashes($jobid)) . "\")'>" .
274 "<a href='fax_view.php?jid=" . attr(urlencode($jobid)) . "&csrf_token_form=" . attr(urlencode(collectCsrfToken())) . "' onclick='return false'>" .
276 echo " <td>" . text($matches[5]) . "</td>\n";
277 echo " <td>" . text($matches[6]) . "</td>\n";
278 echo " <td>" . text($matches[7]) . "</td>\n";
279 echo " <td>" . text($fftts) . "</td>\n";
280 echo " <td>" . text($ffstatus) . "</td>\n";
286 <table width
='100%' cellpadding
='1' cellspacing
='2' id
='table_scanin'
287 <?php
if ($GLOBALS['enable_hylafax']) {
288 echo "style='display:none;'";
291 <td colspan
='2' title
='Click to view'><?php
echo xlt('Filename'); ?
></td
>
292 <td
><?php
echo xlt('Scanned'); ?
></td
>
293 <td align
='right'><?php
echo xlt('Length'); ?
></td
>
297 foreach ($slines as $sline) {
299 $bgcolor = "#" . (($encount & 1) ?
"ddddff" : "ffdddd");
300 $sfname = $sline[0]; // filename
301 $sfdate = date('Y-m-d H:i', $sline[9]);
302 echo " <tr class='detail' bgcolor='" . attr($bgcolor) . "'>\n";
303 echo " <td onclick='dosvclick(\"" . attr(addslashes($sfname)) . "\")'>" .
304 "<a href='fax_view.php?scan=" . attr(urlencode($sfname)) . "&csrf_token_form=" . attr(urlencode(collectCsrfToken())) . "' onclick='return false'>" .
305 "$sfname</a></td>\n";
306 echo " <td onclick='dosdclick(\"" . attr(addslashes($sfname)) . "\")'>";
307 echo "<a href='fax_dispatch.php?scan=" . attr(urlencode($sfname)) . "&csrf_token_form=" . attr(urlencode(collectCsrfToken())) . "' onclick='return false'>" . xlt('Dispatch') . "</a></td>\n";
308 echo " <td>". text($sfdate) . "</td>\n";
309 echo " <td align='right'>" . text($sline[7]) . "</td>\n";