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' => 'Sent successfully',
17 'R' => 'Send in progress',
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; // key is file mod time
79 <link rel
=stylesheet href
='<? echo $css_header ?>' type
='text/css'>
80 <title
><?
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 dlgopen('fax_dispatch.php?file=' + ffname
, '_blank', 850, 550);
164 // Process click to pop up the scanned document dispatch window.
165 function dosdclick(sfname
) {
166 dlgopen('fax_dispatch.php?scan=' + sfname
, '_blank', 850, 550);
173 <body
<?
echo $top_bg_line;?
>>
174 <table cellspacing
='0' cellpadding
='0' style
='margin: 0 0 0 0; border: 2px solid #000000;'
175 id
='bigtable' width
='100%' height
='100%'>
176 <tr style
='height: 20px;'>
177 <td width
='33%' id
='td_tab_faxin' class='tabhead'
178 <?php
if ($GLOBALS['hylafax_server']) { ?
>
179 style
='color: #cc0000; border-right: 2px solid #000000; border-bottom: 2px solid transparent;'
181 style
='color: #777777; border-right: 2px solid #000000; border-bottom: 2px solid #000000; cursor: pointer;'
183 onclick
='tabclick("faxin")'>Faxes In
</td
>
184 <td width
='33%' id
='td_tab_faxout' class='tabhead'
185 style
='color: #777777; border-right: 2px solid #000000; border-bottom: 2px solid #000000; cursor: pointer;'
186 onclick
='tabclick("faxout")'>Faxes Out
</td
>
187 <td width
='34%' id
='td_tab_scanin' class='tabhead'
188 <?php
if ($GLOBALS['hylafax_server']) { ?
>
189 style
='color: #777777; border-bottom: 2px solid #000000; cursor: pointer;'
191 style
='color: #cc0000; border-bottom: 2px solid transparent;'
193 onclick
='tabclick("scanin")'>Scanner In
</td
>
196 <td colspan
='3' style
='padding: 5px;' valign
='top'>
198 <form method
='post' action
='faxq.php'>
200 <table width
='100%' cellpadding
='1' cellspacing
='2' id
='table_faxin'
201 <?php
if (!$GLOBALS['hylafax_server']) echo "style='display:none;'"; ?
>>
203 <td colspan
='2' title
='Click to view'><?
xl('Document','e'); ?
></td
>
204 <td
><?
xl('Received','e'); ?
></td
>
205 <td
><?
xl('From','e'); ?
></td
>
206 <td align
='right'><?
xl('Pages','e'); ?
></td
>
210 foreach ($mlines as $matches) {
212 $ffname = $matches[4];
213 $ffbase = basename("/$ffname", '.tif');
214 $bgcolor = "#" . (($encount & 1) ?
"ddddff" : "ffdddd");
215 echo " <tr class='detail' bgcolor='$bgcolor'>\n";
216 echo " <td onclick='dodclick(\"$ffname\")'>";
217 echo "<a href='fax_view.php?file=$ffname' onclick='return false'>$ffbase</a></td>\n";
218 echo " <td onclick='domclick(\"$ffname\")'>";
219 echo "<a href='fax_dispatch.php?file=$ffname' onclick='return false'>Dispatch</a></td>\n";
220 echo " <td>" . htmlentities($matches[3]) . "</td>\n";
221 echo " <td>" . htmlentities($matches[2]) . "</td>\n";
222 echo " <td align='right'>" . htmlentities($matches[1]) . "</td>\n";
228 <table width
='100%' cellpadding
='1' cellspacing
='2' id
='table_faxout'
229 style
='display:none;'>
231 <td title
='Click to view'><?
xl('Job ID','e'); ?
></td
>
232 <td
><?
xl('To','e'); ?
></td
>
233 <td
><?
xl('Pages','e'); ?
></td
>
234 <td
><?
xl('Dials','e'); ?
></td
>
235 <td
><?
xl('TTS','e'); ?
></td
>
236 <td
><?
xl('Status','e'); ?
></td
>
240 foreach ($dlines as $matches) {
242 $jobid = $matches[1];
243 $ffstatus = $faxstats[$matches[3]];
245 $ffstatend = trim($matches[8]);
246 if (preg_match('/^(\d+:\d+)\s*(.*)$/', $ffstatend, $tmp)) {
248 $ffstatend = $tmp[2];
250 if ($ffstatend) $ffstatus .= ': ' . $ffstatend;
251 $bgcolor = "#" . (($encount & 1) ?
"ddddff" : "ffdddd");
252 echo " <tr class='detail' bgcolor='$bgcolor'>\n";
253 echo " <td onclick='dojclick(\"$jobid\")'>" .
254 "<a href='fax_view.php?jid=$jobid' onclick='return false'>" .
256 echo " <td>" . htmlentities($matches[5]) . "</td>\n";
257 echo " <td>" . htmlentities($matches[6]) . "</td>\n";
258 echo " <td>" . htmlentities($matches[7]) . "</td>\n";
259 echo " <td>" . htmlentities($fftts) . "</td>\n";
260 echo " <td>" . htmlentities($ffstatus) . "</td>\n";
266 <table width
='100%' cellpadding
='1' cellspacing
='2' id
='table_scanin'
267 <?php
if ($GLOBALS['hylafax_server']) echo "style='display:none;'"; ?
>>
269 <td colspan
='2' title
='Click to view'><?
xl('Filename','e'); ?
></td
>
270 <td
><?
xl('Scanned','e'); ?
></td
>
271 <td align
='right'><?
xl('Length','e'); ?
></td
>
275 foreach ($slines as $sline) {
277 $bgcolor = "#" . (($encount & 1) ?
"ddddff" : "ffdddd");
278 $sfname = $sline[0]; // filename
279 $sfdate = date('Y-m-d H:i', $sline[9]);
280 echo " <tr class='detail' bgcolor='$bgcolor'>\n";
281 echo " <td onclick='dosvclick(\"$sfname\")'>" .
282 "<a href='fax_view.php?scan=$sfname' onclick='return false'>" .
283 "$sfname</a></td>\n";
284 echo " <td onclick='dosdclick(\"$sfname\")'>";
285 echo "<a href='fax_dispatch.php?scan=$sfname' onclick='return false'>Dispatch</a></td>\n";
286 echo " <td>$sfdate</td>\n";
287 echo " <td align='right'>" . $sline[7] . "</td>\n";