New billing Manager with new method of search criteria.
[openemr.git] / interface / fax / fax_view.php
blobc9858812a5c853a7b128f585761eb2be5499da51
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");
11 $ffname = '';
12 $jobid = $_GET['jid'];
13 if ($jobid) {
14 $jfname = $GLOBALS['hylafax_basedir'] . "/sendq/q$jobid";
15 if (!file_exists($jfname))
16 $jfname = $GLOBALS['hylafax_basedir'] . "/doneq/q$jobid";
17 $jfhandle = fopen($jfname, 'r');
18 if (!$jfhandle) {
19 echo "I am in these groups: ";
20 passthru("groups");
21 echo "<br />";
22 die(xl("Cannot open ") . $jfname);
24 while (!feof($jfhandle)) {
25 $line = trim(fgets($jfhandle));
26 if (substr($line, 0, 12) == '!postscript:') {
27 $ffname = $GLOBALS['hylafax_basedir'] . '/' .
28 substr($line, strrpos($line, ':') + 1);
29 break;
32 fclose($jfhandle);
33 if (!$ffname) {
34 die(xl("Cannot find postscript document reference in ") . $jfname);
37 else if ($_GET['scan']) {
38 $ffname = $GLOBALS['scanner_output_directory'] . '/' . $_GET['scan'];
40 else {
41 $ffname = $GLOBALS['hylafax_basedir'] . '/recvq/' . $_GET['file'];
44 if (!file_exists($ffname)) {
45 die(xl("Cannot find ") . $ffname);
48 if (!is_readable($ffname)) {
49 die(xl("I do not have permission to read ") . $ffname);
52 ob_start();
54 $ext = substr($ffname, strrpos($ffname, '.'));
55 if ($ext == '.ps')
56 passthru("TMPDIR=/tmp ps2pdf '$ffname' -");
57 else if ($ext == '.pdf' || $ext == '.PDF')
58 readfile($ffname);
59 else
60 passthru("tiff2pdf '$ffname'");
62 header("Pragma: public");
63 header("Expires: 0");
64 header("Cache-Control: must-revalidate, post-check=0, pre-check=0");
65 header("Content-Type: application/pdf");
66 header("Content-Length: " . ob_get_length());
67 header("Content-Disposition: inline; filename=" . basename($ffname, $ext) . '.pdf');
69 ob_end_flush();
71 exit;