Appointment Report Enhancement Module: Added gpl information to new library file
[openemr.git] / interface / fax / fax_dispatch.php
blobbd2bb903132f4d3d792543a1a9866da68e38315d
1 <?php
2 // Copyright (C) 2006-2010 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");
10 require_once("$srcdir/patient.inc");
11 require_once("$srcdir/pnotes.inc");
12 require_once("$srcdir/forms.inc");
13 require_once("$srcdir/options.inc.php");
14 require_once("$srcdir/gprelations.inc.php");
16 if ($_GET['file']) {
17 $mode = 'fax';
18 $filename = $_GET['file'];
19 $filepath = $GLOBALS['hylafax_basedir'] . '/recvq/' . $filename;
21 else if ($_GET['scan']) {
22 $mode = 'scan';
23 $filename = $_GET['scan'];
24 $filepath = $GLOBALS['scanner_output_directory'] . '/' . $filename;
26 else {
27 die("No filename was given.");
30 $ext = substr($filename, strrpos($filename, '.'));
31 $filebase = basename("/$filename", $ext);
32 $faxcache = $GLOBALS['OE_SITE_DIR'] . "/faxcache/$mode/$filebase";
34 $info_msg = "";
36 // This function builds an array of document categories recursively.
37 // Kittens are the children of cats, you know. :-)
39 function getKittens($catid, $catstring, &$categories) {
40 $cres = sqlStatement("SELECT id, name FROM categories " .
41 "WHERE parent = $catid ORDER BY name");
42 $childcount = 0;
43 while ($crow = sqlFetchArray($cres)) {
44 ++$childcount;
45 getKittens($crow['id'], ($catstring ? "$catstring / " : "") .
46 ($catid ? $crow['name'] : ''), $categories);
48 // If no kitties, then this is a leaf node and should be listed.
49 if (!$childcount) $categories[$catid] = $catstring;
52 // This merges the tiff files for the selected pages into one tiff file.
54 function mergeTiffs() {
55 global $faxcache;
56 $msg = '';
57 $inames = '';
58 $tmp1 = array();
59 $tmp2 = 0;
60 // form_images are the checkboxes to the right of the images.
61 foreach ($_POST['form_images'] as $inbase) {
62 $inames .= ' ' . escapeshellarg("$inbase.tif");
64 if (!$inames) die(xl("Internal error - no pages were selected!"));
65 $tmp0 = exec("cd '$faxcache'; tiffcp $inames temp.tif", $tmp1, $tmp2);
66 if ($tmp2) {
67 $msg .= "tiffcp returned $tmp2: $tmp0 ";
69 return $msg;
72 // If we are submitting...
74 if ($_POST['form_save']) {
75 $action_taken = false;
76 $tmp1 = array();
77 $tmp2 = 0;
79 if ($_POST['form_cb_copy']) {
80 $patient_id = (int) $_POST['form_pid'];
81 if (!$patient_id) die(xl('Internal error - patient ID was not provided!'));
82 // Compute the name of the target directory and make sure it exists.
83 $docdir = $GLOBALS['OE_SITE_DIR'] . "/documents/$patient_id";
84 exec("mkdir -p '$docdir'");
86 // If copying to patient documents...
88 if ($_POST['form_cb_copy_type'] == 1) {
89 // Compute a target filename that does not yet exist.
90 $ffname = trim($_POST['form_filename']);
91 $i = strrpos($ffname, '.');
92 if ($i) $ffname = trim(substr($ffname, 0, $i));
93 if (!$ffname) $ffname = $filebase;
94 $ffmod = '';
95 $ffsuff = '.pdf';
96 // If the target filename exists, modify it until it doesn't.
97 $count = 0;
98 while (is_file("$docdir/$ffname$ffmod$ffsuff")) {
99 ++$count;
100 $ffmod = "_$count";
102 $target = "$docdir/$ffname$ffmod$ffsuff";
103 $docdate = fixDate($_POST['form_docdate']);
105 // Create the target PDF. Note that we are relying on the .tif files for
106 // the individual pages to already exist in the faxcache directory.
108 $info_msg .= mergeTiffs();
109 // The -j option here requires that libtiff is configured with libjpeg.
110 // It could be omitted, but the output PDFs would then be quite large.
111 $tmp0 = exec("tiff2pdf -j -p letter -o '$target' '$faxcache/temp.tif'", $tmp1, $tmp2);
113 if ($tmp2) {
114 $info_msg .= "tiff2pdf returned $tmp2: $tmp0 ";
116 else {
117 $newid = generate_id();
118 $fsize = filesize($target);
119 $catid = (int) $_POST['form_category'];
120 // Update the database.
121 $query = "INSERT INTO documents ( " .
122 "id, type, size, date, url, mimetype, foreign_id, docdate" .
123 " ) VALUES ( " .
124 "'$newid', 'file_url', '$fsize', NOW(), 'file://$target', " .
125 "'application/pdf', $patient_id, '$docdate' " .
126 ")";
127 sqlStatement($query);
128 $query = "INSERT INTO categories_to_documents ( " .
129 "category_id, document_id" .
130 " ) VALUES ( " .
131 "'$catid', '$newid' " .
132 ")";
133 sqlStatement($query);
134 } // end not error
136 // If we are posting a note...
137 if ($_POST['form_cb_note'] && !$info_msg) {
138 // Build note text in a way that identifies the new document.
139 // See pnotes_full.php which uses this to auto-display the document.
140 $note = "$ffname$ffmod$ffsuff";
141 for ($tmp = $catid; $tmp;) {
142 $catrow = sqlQuery("SELECT name, parent FROM categories WHERE id = '$tmp'");
143 $note = $catrow['name'] . "/$note";
144 $tmp = $catrow['parent'];
146 $note = "New scanned document $newid: $note";
147 $form_note_message = trim($_POST['form_note_message']);
148 if (get_magic_quotes_gpc()) $form_note_message = stripslashes($form_note_message);
149 if ($form_note_message) $note .= "\n" . $form_note_message;
150 // addPnote() will do its own addslashes().
151 $noteid = addPnote($_POST['form_pid'], $note, $userauthorized, '1',
152 $_POST['form_note_type'], $_POST['form_note_to']);
153 // Link the new patient note to the document.
154 setGpRelation(1, $newid, 6, $noteid);
155 } // end post patient note
156 } // end copy to documents
158 // Otherwise creating a scanned encounter note...
160 else {
162 // Get desired $encounter_id.
163 $encounter_id = 0;
164 if (empty($_POST['form_copy_sn_visit'])) {
165 $info_msg .= "This patient has no visits! ";
166 } else {
167 $encounter_id = 0 + $_POST['form_copy_sn_visit'];
170 if (!$info_msg) {
171 // Merge the selected pages.
172 $info_msg .= mergeTiffs();
173 $tmp_name = "$faxcache/temp.tif";
176 if (!$info_msg) {
177 // The following is cloned from contrib/forms/scanned_notes/new.php:
179 $query = "INSERT INTO form_scanned_notes ( " .
180 "notes " .
181 ") VALUES ( " .
182 "'" . $_POST['form_copy_sn_comments'] . "' " .
183 ")";
184 $formid = sqlInsert($query);
185 addForm($encounter_id, "Scanned Notes", $formid, "scanned_notes",
186 $patient_id, $userauthorized);
188 $imagedir = $GLOBALS['OE_SITE_DIR'] . "/documents/$patient_id/encounters";
189 $imagepath = "$imagedir/${encounter_id}_$formid.jpg";
191 if (! is_dir($imagedir)) {
192 $tmp0 = exec("mkdir -p '$imagedir'", $tmp1, $tmp2);
193 if ($tmp2) die("mkdir returned $tmp2: $tmp0");
194 exec("touch '$imagedir/index.html'");
196 if (is_file($imagepath)) unlink($imagepath);
197 // TBD: There may be a faster way to create this file, given that
198 // we already have a jpeg for each page in faxcache.
199 $cmd = "convert -resize 800 -density 96 '$tmp_name' -append '$imagepath'";
200 $tmp0 = exec($cmd, $tmp1, $tmp2);
201 if ($tmp2) die("\"$cmd\" returned $tmp2: $tmp0");
204 // If we are posting a patient note...
205 if ($_POST['form_cb_note'] && !$info_msg) {
206 $note = "New scanned encounter note for visit on " . substr($erow['date'], 0, 10);
207 $form_note_message = trim($_POST['form_note_message']);
208 if (get_magic_quotes_gpc()) $form_note_message = stripslashes($form_note_message);
209 if ($form_note_message) $note .= "\n" . $form_note_message;
210 // addPnote() will do its own addslashes().
211 addPnote($patient_id, $note, $userauthorized, '1',
212 $_POST['form_note_type'], $_POST['form_note_to']);
213 } // end post patient note
216 $action_taken = true;
218 } // end copy to chart
220 if ($_POST['form_cb_forward']) {
221 $form_from = trim($_POST['form_from']);
222 $form_to = trim($_POST['form_to']);
223 $form_fax = trim($_POST['form_fax']);
224 $form_message = trim($_POST['form_message']);
225 $form_finemode = $_POST['form_finemode'] ? '-m' : '-l';
227 if (get_magic_quotes_gpc()) {
228 $form_from = stripslashes($form_from);
229 $form_to = stripslashes($form_to);
230 $form_message = stripslashes($form_message);
233 // Generate a cover page using enscript. This can be a cool thing
234 // to do, as enscript is very powerful.
236 $tmp1 = array();
237 $tmp2 = 0;
238 $tmpfn1 = tempnam("/tmp", "fax1");
239 $tmpfn2 = tempnam("/tmp", "fax2");
240 $tmph = fopen($tmpfn1, "w");
241 $cpstring = '';
242 $fh = fopen($GLOBALS['OE_SITE_DIR'] . "/faxcover.txt", 'r');
243 while (!feof($fh)) $cpstring .= fread($fh, 8192);
244 fclose($fh);
245 $cpstring = str_replace('{CURRENT_DATE}' , date('F j, Y'), $cpstring);
246 $cpstring = str_replace('{SENDER_NAME}' , $form_from , $cpstring);
247 $cpstring = str_replace('{RECIPIENT_NAME}', $form_to , $cpstring);
248 $cpstring = str_replace('{RECIPIENT_FAX}' , $form_fax , $cpstring);
249 $cpstring = str_replace('{MESSAGE}' , $form_message , $cpstring);
250 fwrite($tmph, $cpstring);
251 fclose($tmph);
252 $tmp0 = exec("cd $webserver_root/custom; " . $GLOBALS['hylafax_enscript'] .
253 " -o $tmpfn2 $tmpfn1", $tmp1, $tmp2);
254 if ($tmp2) {
255 $info_msg .= "enscript returned $tmp2: $tmp0 ";
257 unlink($tmpfn1);
259 // Send the fax as the cover page followed by the selected pages.
260 $info_msg .= mergeTiffs();
261 $tmp0 = exec("sendfax -A -n $form_finemode -d " .
262 escapeshellarg($form_fax) . " $tmpfn2 '$faxcache/temp.tif'",
263 $tmp1, $tmp2);
264 if ($tmp2) {
265 $info_msg .= "sendfax returned $tmp2: $tmp0 ";
267 unlink($tmpfn2);
269 $action_taken = true;
270 } // end forward
272 $form_cb_delete = $_POST['form_cb_delete'];
274 // If deleting selected, do it and then check if any are left.
275 if ($form_cb_delete == '1' && !$info_msg) {
276 foreach ($_POST['form_images'] as $inbase) {
277 unlink("$faxcache/$inbase.jpg");
278 $action_taken = true;
280 // Check if any .jpg files remain... if not we'll clean up.
281 if ($action_taken) {
282 $dh = opendir($faxcache);
283 if (! $dh) die("Cannot read $faxcache");
284 $form_cb_delete = '2';
285 while (false !== ($jfname = readdir($dh))) {
286 if (preg_match('/\.jpg$/', $jfname)) $form_cb_delete = '1';
288 closedir($dh);
290 } // end delete 1
292 if ($form_cb_delete == '2' && !$info_msg) {
293 // Delete the tiff file, with archiving if desired.
294 if ($GLOBALS['hylafax_archdir'] && $mode == 'fax') {
295 rename($filepath, $GLOBALS['hylafax_archdir'] . '/' . $filename);
296 } else {
297 unlink($filepath);
299 // Erase its cache.
300 if (is_dir($faxcache)) {
301 $dh = opendir($faxcache);
302 while (($tmp = readdir($dh)) !== false) {
303 if (is_file("$faxcache/$tmp")) unlink("$faxcache/$tmp");
305 closedir($dh);
306 rmdir($faxcache);
308 $action_taken = true;
309 } // end delete 2
311 if (!$action_taken && !$info_msg)
312 $info_msg = xl('You did not choose any actions.');
314 if ($info_msg || $form_cb_delete != '1') {
315 // Close this window and refresh the fax list.
316 echo "<html>\n<body>\n<script language='JavaScript'>\n";
317 if ($info_msg) echo " alert('$info_msg');\n";
318 echo " if (!opener.closed && opener.refreshme) opener.refreshme();\n";
319 echo " window.close();\n";
320 echo "</script>\n</body>\n</html>\n";
321 exit();
323 } // end submit logic
325 // If we get this far then we are displaying the form.
327 // Find out if the scanned_notes form is installed and active.
329 $tmp = sqlQuery("SELECT count(*) AS count FROM registry WHERE " .
330 "directory LIKE 'scanned_notes' AND state = 1 AND sql_run = 1");
331 $using_scanned_notes = $tmp['count'];
333 // If the image cache does not yet exist for this fax, build it.
334 // This will contain a .tif image as well as a .jpg image for each page.
336 if (! is_dir($faxcache)) {
337 $tmp0 = exec("mkdir -p '$faxcache'", $tmp1, $tmp2);
338 if ($tmp2) die("mkdir returned $tmp2: $tmp0");
339 if (strtolower($ext) != '.tif') {
340 // convert's default density for PDF-to-TIFF conversion is 72 dpi which is
341 // not very good, so we upgrade it to "fine mode" fax quality. It's really
342 // better and faster if the scanner produces TIFFs instead of PDFs.
343 $tmp0 = exec("convert -density 203x196 '$filepath' '$faxcache/deleteme.tif'", $tmp1, $tmp2);
344 if ($tmp2) die("convert returned $tmp2: $tmp0");
345 $tmp0 = exec("cd '$faxcache'; tiffsplit 'deleteme.tif'; rm -f 'deleteme.tif'", $tmp1, $tmp2);
346 if ($tmp2) die("tiffsplit/rm returned $tmp2: $tmp0");
347 } else {
348 $tmp0 = exec("cd '$faxcache'; tiffsplit '$filepath'", $tmp1, $tmp2);
349 if ($tmp2) die("tiffsplit returned $tmp2: $tmp0");
351 $tmp0 = exec("cd '$faxcache'; mogrify -resize 750x970 -format jpg *.tif", $tmp1, $tmp2);
352 if ($tmp2) die("mogrify returned $tmp2: $tmp0; ext is '$ext'; filepath is '$filepath'");
355 // Get the categories list.
356 $categories = array();
357 getKittens(0, '', $categories);
359 // Get the users list.
360 $ures = sqlStatement("SELECT username, fname, lname FROM users " .
361 "WHERE active = 1 AND ( info IS NULL OR info NOT LIKE '%Inactive%' ) " .
362 "ORDER BY lname, fname");
364 <html>
365 <head>
366 <?php if (function_exists(html_header_show)) html_header_show(); ?>
367 <title><?php xl('Dispatch Received Document','e'); ?></title>
368 <link rel="stylesheet" href='<?php echo $css_header ?>' type='text/css'>
370 <style>
372 td, input, select, textarea {
373 font-size: 10pt;
376 .itemtitle {
377 font-weight: bold;
380 div.section {
381 border: solid;
382 border-width: 1px;
383 border-color: #0000ff;
384 margin-left: 2em;
385 padding: 1em;
388 </style>
390 <style type="text/css">@import url(../../library/dynarch_calendar.css);</style>
392 <script type="text/javascript" src="../../library/topdialog.js"></script>
393 <script type="text/javascript" src="../../library/dialog.js"></script>
394 <script type="text/javascript" src="../../library/textformat.js"></script>
395 <script type="text/javascript" src="../../library/dynarch_calendar.js"></script>
396 <?php include_once("{$GLOBALS['srcdir']}/dynarch_calendar_en.inc.php"); ?>
397 <script type="text/javascript" src="../../library/dynarch_calendar_setup.js"></script>
398 <script type="text/javascript" src="../../library/js/jquery-1.2.2.min.js"></script>
400 <script language="JavaScript">
402 var mypcc = '<?php echo $GLOBALS['phone_country_code'] ?>';
404 <?php require($GLOBALS['srcdir'] . "/restoreSession.php"); ?>
406 function divclick(cb, divid) {
407 var divstyle = document.getElementById(divid).style;
408 if (cb.checked) {
409 if (divid == 'div_copy_doc') {
410 document.getElementById('div_copy_sn').style.display = 'none';
412 else if (divid == 'div_copy_sn') {
413 document.getElementById('div_copy_doc').style.display = 'none';
415 divstyle.display = 'block';
416 } else {
417 divstyle.display = 'none';
419 return true;
422 // This is for callback by the find-patient popup.
423 function setpatient(pid, lname, fname, dob) {
424 var f = document.forms[0];
425 f.form_patient.value = lname + ', ' + fname;
426 f.form_pid.value = pid;
427 <?php if ($using_scanned_notes) { ?>
428 // This loads the patient's list of recent encounters:
429 f.form_copy_sn_visit.options.length = 0;
430 f.form_copy_sn_visit.options[0] = new Option('Loading...', '0');
431 $.getScript("fax_dispatch_newpid.php?p=" + pid);
432 <?php } ?>
435 // This invokes the find-patient popup.
436 function sel_patient() {
437 dlgopen('../main/calendar/find_patient_popup.php', '_blank', 500, 400);
440 // Check for errors when the form is submitted.
441 function validate() {
442 var f = document.forms[0];
444 if (f.form_cb_copy.checked) {
445 if (! f.form_pid.value) {
446 alert('You have not selected a patient!');
447 return false;
451 if (f.form_cb_forward.checked) {
452 var s = f.form_fax.value;
453 if (! s) {
454 alert('A fax number is required!');
455 return false;
457 var digcount = 0;
458 for (var i = 0; i < s.length; ++i) {
459 var c = s.charAt(i);
460 if (c >= '0' && c <= '9') {
461 ++digcount;
463 else if (digcount == 0 || c != '-') {
464 alert('Invalid character(s) in fax number!');
465 return false;
468 if (digcount == 7) {
469 if (s.charAt(0) < '2') {
470 alert('Local phone number starts with an invalid digit!');
471 return false;
474 else if (digcount == 11) {
475 if (s.charAt(0) != '1') {
476 alert('11-digit number must begin with 1!');
477 return false;
480 else if (digcount == 10) {
481 if (s.charAt(0) < '2') {
482 alert('10-digit number starts with an invalid digit!');
483 return false;
485 f.form_fax.value = '1' + s;
487 else {
488 alert('Invalid number of digits in fax telephone number!');
489 return false;
493 if (f.form_cb_copy.checked || f.form_cb_forward.checked) {
494 var check_count = 0;
495 for (var i = 0; i < f.elements.length; ++i) {
496 if (f.elements[i].name == 'form_images[]' && f.elements[i].checked)
497 ++check_count;
499 if (check_count == 0) {
500 alert('No pages have been selected!');
501 return false;
505 top.restoreSession();
506 return true;
509 function allCheckboxes(issel) {
510 var f = document.forms[0];
511 for (var i = 0; i < f.elements.length; ++i) {
512 if (f.elements[i].name == 'form_images[]') f.elements[i].checked = issel;
516 </script>
518 </head>
520 <body class="body_top" onunload='imclosing()'>
522 <center><h2><?php xl('Dispatch Received Document','e'); ?></h2></center>
524 <form method='post' name='theform'
525 action='fax_dispatch.php?<?php echo ($mode == 'fax') ? 'file' : 'scan'; ?>=<?php echo $filename ?>' onsubmit='return validate()'>
527 <p><input type='checkbox' name='form_cb_copy' value='1'
528 onclick='return divclick(this,"div_copy");' />
529 <b><?php xl('Copy Pages to Patient Chart','e'); ?></b></p>
531 <div id='div_copy' class='section' style='display:none;'>
532 <table>
533 <tr>
534 <td class='itemtitle' width='1%' nowrap><?php xl('Patient','e'); ?></td>
535 <td>
536 <input type='text' size='10' name='form_patient' style='width:100%'
537 value=' (<?php xl('Click to select'); ?>)' onclick='sel_patient()'
538 title='Click to select patient' readonly />
539 <input type='hidden' name='form_pid' value='0' />
540 </td>
541 </tr>
542 <tr>
543 <td colspan='2' style='padding-top:0.5em;'>
544 <input type='radio' name='form_cb_copy_type' value='1'
545 onclick='return divclick(this,"div_copy_doc");' checked />
546 <b><?php xl('Patient Document','e'); ?></b>&nbsp;
547 <?php if ($using_scanned_notes) { ?>
548 <input type='radio' name='form_cb_copy_type' value='2'
549 onclick='return divclick(this,"div_copy_sn");' />
550 <b><?php xl('Scanned Encounter Note','e'); ?></b>
551 <?php } ?>
552 <div id='div_copy_doc' class='section' style='margin-top:0.5em;'>
553 <table width='100%'>
554 <tr>
555 <td class='itemtitle' nowrap><?php xl('Category','e'); ?></td>
556 <td>
557 <select name='form_category' style='width:100%'>
558 <?php
559 foreach ($categories as $catkey => $catname) {
560 echo " <option value='$catkey'";
561 echo ">$catname</option>\n";
564 </select>
565 </td>
566 </tr>
567 <tr>
568 <td class='itemtitle' nowrap><?php xl('Filename','e'); ?></td>
569 <td>
570 <input type='text' size='10' name='form_filename' style='width:100%'
571 value='<?php echo "$filebase.pdf" ?>'
572 title='Name for this document in the patient chart' />
573 </td>
574 </tr>
575 <tr>
576 <td class='itemtitle' nowrap><?php xl('Document Date','e'); ?></td>
577 <td>
578 <input type='text' size='10' name='form_docdate' id='form_docdate'
579 value='<?php echo date('Y-m-d'); ?>'
580 title='<?php xl('yyyy-mm-dd date associated with this document','e'); ?>'
581 onkeyup='datekeyup(this,mypcc)' onblur='dateblur(this,mypcc)' />
582 <img src='../pic/show_calendar.gif' align='absbottom' width='24' height='22'
583 id='img_docdate' border='0' alt='[?]' style='cursor:pointer'
584 title='<?php xl('Click here to choose a date','e'); ?>' />
585 </td>
586 </tr>
587 </table>
588 </div><!-- end div_copy_doc -->
589 <div id='div_copy_sn' class='section' style='display:none;margin-top:0.5em;'>
590 <table width='100%'>
591 <tr>
592 <td class='itemtitle' width='1%' nowrap><?php xl('Visit Date','e'); ?></td>
593 <td>
594 <select name='form_copy_sn_visit' style='width:100%'>
595 </select>
596 </td>
597 </tr>
598 <tr>
599 <td class='itemtitle' width='1%' nowrap><?php xl('Comments','e'); ?></td>
600 <td>
601 <textarea name='form_copy_sn_comments' rows='3' cols='30' style='width:100%'
602 title='Comments associated with this scanned note'
603 /></textarea>
604 </td>
605 </tr>
606 </table>
607 </div><!-- end div_copy_sn -->
608 </td>
609 </tr>
610 <tr>
611 <td colspan='2' style='padding-top:0.5em;'>
612 <input type='checkbox' name='form_cb_note' value='1'
613 onclick='return divclick(this,"div_note");' />
614 <b><?php xl('Create Patient Note','e'); ?></b>
615 <div id='div_note' class='section' style='display:none;margin-top:0.5em;'>
616 <table>
617 <tr>
618 <td class='itemtitle' width='1%' nowrap><?php xl('Type','e'); ?></td>
619 <td>
620 <?php
621 // Added 6/2009 by BM to incorporate the patient notes into the list_options listings
622 generate_form_field(array('data_type'=>1,'field_id'=>'note_type','list_id'=>'note_type','empty_title'=>'SKIP'), '');
624 </td>
625 </tr>
626 <tr>
627 <td class='itemtitle' width='1%' nowrap>To</td>
628 <td>
629 <select name='form_note_to' style='width:100%'>
630 <?php
631 while ($urow = sqlFetchArray($ures)) {
632 echo " <option value='" . $urow['username'] . "'";
633 echo ">" . $urow['lname'];
634 if ($urow['fname']) echo ", " . $urow['fname'];
635 echo "</option>\n";
638 <option value=''>** <?php xl('Close','e'); ?> **</option>
639 </select>
640 </td>
641 </tr>
642 <tr>
643 <td class='itemtitle' nowrap><?php xl('Message','e'); ?></td>
644 <td>
645 <textarea name='form_note_message' rows='3' cols='30' style='width:100%'
646 title='Your comments' /></textarea>
647 </td>
648 </tr>
649 </table>
650 </div><!-- end div_note -->
651 </td>
652 </tr>
653 </table>
654 </div><!-- end div_copy -->
656 <p><input type='checkbox' name='form_cb_forward' value='1'
657 onclick='return divclick(this,"div_forward");' />
658 <b><?php xl('Forward Pages via Fax','e'); ?></b></p>
660 <div id='div_forward' class='section' style='display:none;'>
661 <table>
662 <tr>
663 <td class='itemtitle' width='1%' nowrap><?php xl('From','e'); ?></td>
664 <td>
665 <input type='text' size='10' name='form_from' style='width:100%'
666 title='Type your name here' />
667 </td>
668 </tr>
669 <tr>
670 <td class='itemtitle' nowrap><?php xl('To','e'); ?></td>
671 <td>
672 <input type='text' size='10' name='form_to' style='width:100%'
673 title='Type the recipient name here' />
674 </td>
675 </tr>
676 <tr>
677 <td class='itemtitle' nowrap><?php xl('Fax','e'); ?></td>
678 <td>
679 <input type='text' size='10' name='form_fax' style='width:100%'
680 title='The fax phone number to send this to' />
681 </td>
682 </tr>
683 <tr>
684 <td class='itemtitle' nowrap><?php xl('Message','e'); ?></td>
685 <td>
686 <textarea name='form_message' rows='3' cols='30' style='width:100%'
687 title='Your comments to include with this message' /></textarea>
688 </td>
689 </tr>
690 <tr>
691 <td class='itemtitle' nowrap><?php xl('Quality','e'); ?></td>
692 <td>
693 <input type='radio' name='form_finemode' value='' /><?php xl('Normal','e'); ?> &nbsp;
694 <input type='radio' name='form_finemode' value='1' checked /><?php xl('Fine','e'); ?> &nbsp;
695 </td>
696 </tr>
697 </table>
698 </div><!-- end div_forward -->
700 <p><b><?php xl('Delete Pages','e'); ?>:</b>&nbsp;
701 <input type='radio' name='form_cb_delete' value='2' />All&nbsp;
702 <input type='radio' name='form_cb_delete' value='1' checked />Selected&nbsp;
703 <input type='radio' name='form_cb_delete' value='0' />None
704 </p>
706 <center>
708 <input type='submit' name='form_save' value='<?php xl('OK','e'); ?>' />
709 &nbsp; &nbsp;
710 <input type='button' value='<?php xl('Cancel','e'); ?>' onclick='window.close()' />
711 &nbsp; &nbsp;
712 <input type='button' value='<?php xl('Select All','e'); ?>' onclick='allCheckboxes(true)' />
713 &nbsp; &nbsp;
714 <input type='button' value='<?php xl('Clear All','e'); ?>' onclick='allCheckboxes(false)' />
715 </p>
717 <p><br /><b><?php xl('Please select the desired pages to copy or forward:','e'); ?></b></p>
718 <table>
720 <?php
721 $dh = opendir($faxcache);
722 if (! $dh) die("Cannot read $faxcache");
723 $jpgarray = array();
724 while (false !== ($jfname = readdir($dh))) {
725 if (preg_match("/^(.*)\.jpg/", $jfname, $matches)) {
726 $jpgarray[$matches[1]] = $jfname;
729 closedir($dh);
730 // readdir does not read in any particular order, we must therefore sort
731 // by filename so the display order matches the original document.
732 ksort($jpgarray);
733 $page = 0;
734 foreach ($jpgarray as $jfnamebase => $jfname) {
735 ++$page;
736 echo " <tr>\n";
737 echo " <td valign='top'>\n";
738 echo " <img src='../../sites/" . $_SESSION['site_id'] . "/faxcache/$mode/$filebase/$jfname' />\n";
739 echo " </td>\n";
740 echo " <td align='center' valign='top'>\n";
741 echo " <input type='checkbox' name='form_images[]' value='$jfnamebase' checked />\n";
742 echo " <br />$page\n";
743 echo " </td>\n";
744 echo " </tr>\n";
748 </table>
749 </center>
750 </form>
752 <script language='JavaScript'>
753 Calendar.setup({inputField:"form_docdate", ifFormat:"%Y-%m-%d", button:"img_docdate"});
754 </script>
756 </body>
757 </html>