3 // Copyright (C) 2006 Rod Roark <rod@sunsetsystems.com>
5 // This program is free software; you can redistribute it and/or
6 // modify it under the terms of the GNU General Public License
7 // as published by the Free Software Foundation; either version 2
8 // of the License, or (at your option) any later version.
10 require_once("../globals.php");
12 use OpenEMR\Common\Csrf\CsrfUtils
;
13 use OpenEMR\Core\Header
;
17 'D' => xl('Sent successfully'),
20 'R' => xl('Send in progress'),
21 'S' => xl('Sleeping'),
22 'T' => xl('Suspended'),
30 if ($GLOBALS['enable_hylafax']) {
31 // Get the recvq entries, parse and sort by filename.
33 exec("faxstat -r -l -h " . escapeshellarg($GLOBALS['hylafax_server']), $statlines);
34 foreach ($statlines as $line) {
35 // This gets pagecount, sender, time, filename. We are expecting the
36 // string to start with "-rw-rw-" so as to exclude faxes not yet fully
37 // received, for which permissions are "-rw----".
38 if (preg_match('/^-r\S\Sr\S\S\s+(\d+)\s+\S+\s+(.+)\s+(\S+)\s+(\S+)\s*$/', $line, $matches)) {
39 $mlines[$matches[4]] = $matches;
45 // Get the doneq entries, parse and sort by job ID
47 JID Pri S Owner Number Pages Dials TTS Status
48 155 123 D nobody 6158898622 1:1 5:12
49 153 124 D nobody 6158896439 1:1 4:12
50 154 124 F nobody 6153551807 0:1 4:12 No carrier detected
53 exec("faxstat -s -d -l -h " . escapeshellarg($GLOBALS['hylafax_server']), $donelines);
54 foreach ($donelines as $line) {
55 // This gets jobid, priority, statchar, owner, phone, pages, dials and tts/status.
56 if (preg_match('/^(\d+)\s+(\d+)\s+(\S)\s+(\S+)\s+(\S+)\s+(\d+:\d+)\s+(\d+:\d+)(.*)$/', $line, $matches)) {
57 $dlines[$matches[1]] = $matches;
64 $scandir = $GLOBALS['scanner_output_directory'];
65 if ($scandir && $GLOBALS['enable_scanner']) {
66 // Get the directory entries, parse and sort by date and time.
67 $dh = opendir($scandir);
69 die("Cannot read " . text($scandir));
72 while (false !== ($sfname = readdir($dh))) {
73 if (substr($sfname, 0, 1) == '.') {
77 $tmp = stat("$scandir/$sfname");
78 $tmp[0] = $sfname; // put filename in slot 0 which we don't otherwise need
79 $slines[$tmp[9] . $tmp[1]] = $tmp; // key is file mod time and inode number
91 <?php Header
::setupHeader(['opener']);?
>
92 <title
><?php
echo xlt('Received Faxes'); ?
></title
>
96 font
-family
: "Arial", "Helvetica", sans
-serif
;
101 font
-size
: 0.8125rem
;
102 background
-color
: var(--light
);
106 font
-size
: 0.8125rem
;
109 font
-size
: 0.9375rem
;
118 // Process click on a tab.
119 function tabclick(tabname
) {
120 var tabs
= new Array('faxin', 'faxout', 'scanin');
121 var visdisp
= document
.getElementById('bigtable').style
.display
;
122 for (var i in tabs
) {
123 var thistd
= document
.getElementById('td_tab_' + tabs
[i
]);
124 var thistable
= document
.getElementById('table_' + tabs
[i
]);
125 if (tabs
[i
] == tabname
) {
126 // thistd.style.borderBottom = '0px solid var(--black)';
127 thistd
.style
.borderBottom
= '2px solid transparent';
128 thistd
.style
.color
= 'var(--danger)';
129 thistd
.style
.cursor
= 'default';
130 thistable
.style
.display
= visdisp
;
132 thistd
.style
.borderBottom
= '2px solid var(--black)';
133 thistd
.style
.color
= 'var(--gray)';
134 thistd
.style
.cursor
= 'pointer';
135 thistable
.style
.display
= 'none';
140 // Callback from popups to refresh this display.
141 function refreshme() {
145 // Process click on filename to view.
146 function dodclick(ffname
) {
147 cascwin('fax_view.php?file=' +
encodeURIComponent(ffname
) +
'&csrf_token_form=' +
<?php
echo js_url(CsrfUtils
::collectCsrfToken()); ?
>, '_blank', 600, 475,
148 "resizable=1,scrollbars=1");
152 // Process click on Job ID to view.
153 function dojclick(jobid
) {
154 cascwin('fax_view.php?jid=' +
encodeURIComponent(jobid
) +
'&csrf_token_form=' +
<?php
echo js_url(CsrfUtils
::collectCsrfToken()); ?
>, '_blank', 600, 475,
155 "resizable=1,scrollbars=1");
159 // Process scanned document filename to view.
160 function dosvclick(sfname
) {
161 cascwin('fax_view.php?scan=' +
encodeURIComponent(sfname
) +
'&csrf_token_form=' +
<?php
echo js_url(CsrfUtils
::collectCsrfToken()); ?
>, '_blank', 600, 475,
162 "resizable=1,scrollbars=1");
166 // Process click to pop up the fax dispatch window.
167 function domclick(ffname
) {
168 dlgopen('fax_dispatch.php?file=' +
encodeURIComponent(ffname
) +
'&csrf_token_form=' +
<?php
echo js_url(CsrfUtils
::collectCsrfToken()); ?
>, '_blank', 850, 550, '', 'Fax Dispatch');
171 // Process click to pop up the scanned document dispatch window.
172 function dosdclick(sfname
) {
173 dlgopen('fax_dispatch.php?scan=' +
encodeURIComponent(sfname
) +
'&csrf_token_form=' +
<?php
echo js_url(CsrfUtils
::collectCsrfToken()); ?
>, '_blank', 850, 550, '', 'Scanned Dispatch');
180 <body
class="body_top">
181 <table
class='w-100 h-100' cellspacing
='0' cellpadding
='0' style
='margin: 0; border: 2px solid var(--black);' id
='bigtable'>
182 <tr style
='height: 20px;'>
183 <td width
='33%' id
='td_tab_faxin' class='tabhead'
184 <?php
if ($GLOBALS['enable_hylafax']) { ?
>
185 style
='color: var(--danger); border-right: 2px solid var(--black); border-bottom: 2px solid transparent;'
187 style
='color: var(--gray); border-right: 2px solid var(--black); border-bottom: 2px solid var(--black); cursor: pointer; display:none;'
189 onclick
='tabclick("faxin")'><?php
echo xlt('Faxes In'); ?
></td
>
190 <td width
='33%' id
='td_tab_faxout' class='tabhead'
191 <?php
if ($GLOBALS['enable_hylafax']) { ?
>
192 style
='color: var(--gray); border-right: 2px solid var(--black); border-bottom: 2px solid var(--black); cursor: pointer;'
194 style
='color: var(--gray); border-right: 2px solid var(--black); border-bottom: 2px solid var(--black); cursor: pointer; display:none;'
196 onclick
='tabclick("faxout")'><?php
echo xlt('Faxes Out'); ?
></td
>
197 <td width
='34%' id
='td_tab_scanin' class='tabhead'
198 <?php
if ($GLOBALS['enable_scanner']) { ?
>
199 style
='color: var(--gray); border-bottom: 2px solid var(--black); cursor: pointer;'
201 style
='color: var(--danger); border-bottom: 2px solid transparent; display:none;'
203 onclick
='tabclick("scanin")'><?php
echo xlt('Scanner In'); ?
></td
>
206 <td colspan
='3' style
='padding: 5px;' valign
='top'>
208 <form method
='post' action
='faxq.php'>
210 <table
class='w-100' cellpadding
='1' cellspacing
='2' id
='table_faxin'
211 <?php
if (!$GLOBALS['enable_hylafax']) {
212 echo "style='display:none;'";
215 <td colspan
='2' title
='Click to view'><?php
echo xlt('Document'); ?
></td
>
216 <td
><?php
echo xlt('Received'); ?
></td
>
217 <td
><?php
echo xlt('From'); ?
></td
>
218 <td align
='right'><?php
echo xlt('Pages'); ?
></td
>
223 foreach ($mlines as $matches) {
225 $ffname = $matches[4];
226 $ffbase = basename("/$ffname", '.tif');
227 $bgcolor = (($encount & 1) ?
"#ddddff" : "#ffdddd");
228 echo " <tr class='detail' bgcolor='" . attr($bgcolor) . "'>\n";
229 echo " <td onclick='dodclick(\"" . attr(addslashes($ffname)) . "\")'>";
230 echo "<a href='fax_view.php?file=" . attr_url($ffname) . "&csrf_token_form=" . attr_url(CsrfUtils
::collectCsrfToken()) . "' onclick='return false'>" . text($ffbase) . "</a></td>\n";
231 echo " <td onclick='domclick(\"" . attr(addslashes($ffname)) . "\")'>";
232 echo "<a href='fax_dispatch.php?file=" . attr_url($ffname) . "&csrf_token_form=" . attr_url(CsrfUtils
::collectCsrfToken()) . "' onclick='return false'>" . xlt('Dispatch') . "</a></td>\n";
233 echo " <td>" . text($matches[3]) . "</td>\n";
234 echo " <td>" . text($matches[2]) . "</td>\n";
235 echo " <td align='right'>" . text($matches[1]) . "</td>\n";
241 <table
class='w-100' cellpadding
='1' cellspacing
='2' id
='table_faxout'
242 style
='display:none;'>
244 <td title
='Click to view'><?php
echo xlt('Job ID'); ?
></td
>
245 <td
><?php
echo xlt('To{{Destination}}'); ?
></td
>
246 <td
><?php
echo xlt('Pages'); ?
></td
>
247 <td
><?php
echo xlt('Dials'); ?
></td
>
248 <td
><?php
echo xlt('TTS'); ?
></td
>
249 <td
><?php
echo xlt('Status'); ?
></td
>
253 foreach ($dlines as $matches) {
255 $jobid = $matches[1];
256 $ffstatus = $faxstats[$matches[3]];
258 $ffstatend = trim($matches[8]);
259 if (preg_match('/^(\d+:\d+)\s*(.*)$/', $ffstatend, $tmp)) {
261 $ffstatend = $tmp[2];
265 $ffstatus .= ': ' . $ffstatend;
268 $bgcolor = (($encount & 1) ?
"#ddddff" : "#ffdddd");
269 echo " <tr class='detail' bgcolor='" . attr($bgcolor) . "'>\n";
270 echo " <td onclick='dojclick(\"" . attr(addslashes($jobid)) . "\")'>" .
271 "<a href='fax_view.php?jid=" . attr_url($jobid) . "&csrf_token_form=" . attr_url(CsrfUtils
::collectCsrfToken()) . "' onclick='return false'>" .
273 echo " <td>" . text($matches[5]) . "</td>\n";
274 echo " <td>" . text($matches[6]) . "</td>\n";
275 echo " <td>" . text($matches[7]) . "</td>\n";
276 echo " <td>" . text($fftts) . "</td>\n";
277 echo " <td>" . text($ffstatus) . "</td>\n";
283 <table
class='w-100' cellpadding
='1' cellspacing
='2' id
='table_scanin'
284 <?php
if ($GLOBALS['enable_hylafax']) {
285 echo "style='display:none;'";
288 <td colspan
='2' title
='Click to view'><?php
echo xlt('Filename'); ?
></td
>
289 <td
><?php
echo xlt('Scanned'); ?
></td
>
290 <td align
='right'><?php
echo xlt('Length'); ?
></td
>
294 foreach ($slines as $sline) {
296 $bgcolor = (($encount & 1) ?
"#ddddff" : "#ffdddd");
297 $sfname = $sline[0]; // filename
298 $sfdate = date('Y-m-d H:i', $sline[9]);
299 echo " <tr class='detail' bgcolor='" . attr($bgcolor) . "'>\n";
300 echo " <td onclick='dosvclick(\"" . attr(addslashes($sfname)) . "\")'>" .
301 "<a href='fax_view.php?scan=" . attr_url($sfname) . "&csrf_token_form=" . attr_url(CsrfUtils
::collectCsrfToken()) . "' onclick='return false'>" .
302 "$sfname</a></td>\n";
303 echo " <td onclick='dosdclick(\"" . attr(addslashes($sfname)) . "\")'>";
304 echo "<a href='fax_dispatch.php?scan=" . attr_url($sfname) . "&csrf_token_form=" . attr_url(CsrfUtils
::collectCsrfToken()) . "' onclick='return false'>" . xlt('Dispatch') . "</a></td>\n";
305 echo " <td>" . text($sfdate) . "</td>\n";
306 echo " <td align='right'>" . text($sline[7]) . "</td>\n";