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");
14 'D' => xl('Sent successfully'),
17 'R' => xl('Send in progress'),
18 'S' => xl('Sleeping'),
19 'T' => xl('Suspended'),
27 if ($GLOBALS['hylafax_server']) {
28 // Get the recvq entries, parse and sort by filename.
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;
41 // Get the doneq entries, parse and sort by job ID
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
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;
59 $scandir = $GLOBALS['scanner_output_directory'];
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
79 <link rel
=stylesheet href
='<?php echo $css_header ?>' type
='text/css'>
80 <title
><?php
xl('Received Faxes','e'); ?
></title
>
84 font
-family
: Arial
, Helvetica
, sans
-serif
;
88 a
, a
:visited
, a
:hover
{
93 background
-color
:#cccccc;
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
;
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() {
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");
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");
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");
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");
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;'
183 style
='color: #777777; border-right: 2px solid #000000; border-bottom: 2px solid #000000; cursor: pointer;'
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;'
193 style
='color: #cc0000; border-bottom: 2px solid transparent;'
195 onclick
='tabclick("scanin")'><?php
xl('Scanner In','e'); ?
></td
>
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;'"; ?
>>
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
>
212 foreach ($mlines as $matches) {
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";
230 <table width
='100%' cellpadding
='1' cellspacing
='2' id
='table_faxout'
231 style
='display:none;'>
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
>
242 foreach ($dlines as $matches) {
244 $jobid = $matches[1];
245 $ffstatus = $faxstats[$matches[3]];
247 $ffstatend = trim($matches[8]);
248 if (preg_match('/^(\d+:\d+)\s*(.*)$/', $ffstatend, $tmp)) {
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'>" .
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";
268 <table width
='100%' cellpadding
='1' cellspacing
='2' id
='table_scanin'
269 <?php
if ($GLOBALS['hylafax_server']) echo "style='display:none;'"; ?
>>
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
>
277 foreach ($slines as $sline) {
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";