Corrected Restyled Procedures - Part 2 (#1789)
[openemr.git] / interface / fax / fax_dispatch.php
blob4cc71a070e6a99a3255f1001151aad86b2d8c47d
1 <?php
2 /**
3 * fax dispatch
5 * @package OpenEMR
6 * @link http://www.open-emr.org
7 * @author Rod Roark <rod@sunsetsystems.com>
8 * @author Brady Miller <brady.g.miller@gmail.com>
9 * @copyright Copyright (c) 2006-2010 Rod Roark <rod@sunsetsystems.com>
10 * @copyright Copyright (c) 2017-2018 Brady Miller <brady.g.miller@gmail.com>
11 * @license https://github.com/openemr/openemr/blob/master/LICENSE GNU General Public License 3
15 require_once("../globals.php");
16 require_once("$srcdir/patient.inc");
17 require_once("$srcdir/pnotes.inc");
18 require_once("$srcdir/forms.inc");
19 require_once("$srcdir/options.inc.php");
20 require_once("$srcdir/gprelations.inc.php");
22 use OpenEMR\Core\Header;
24 if ($_GET['file']) {
25 $mode = 'fax';
26 $filename = $_GET['file'];
28 // ensure the file variable has no illegal characters
29 check_file_dir_name($filename);
31 $filepath = $GLOBALS['hylafax_basedir'] . '/recvq/' . $filename;
32 } else if ($_GET['scan']) {
33 $mode = 'scan';
34 $filename = $_GET['scan'];
36 // ensure the file variable has no illegal characters
37 check_file_dir_name($filename);
39 $filepath = $GLOBALS['scanner_output_directory'] . '/' . $filename;
40 } else {
41 die("No filename was given.");
44 $ext = substr($filename, strrpos($filename, '.'));
45 $filebase = basename("/$filename", $ext);
46 $faxcache = $GLOBALS['OE_SITE_DIR'] . "/faxcache/$mode/$filebase";
48 $info_msg = "";
50 // This function builds an array of document categories recursively.
51 // Kittens are the children of cats, you know. :-)getKittens
53 function getKittens($catid, $catstring, &$categories)
55 $cres = sqlStatement("SELECT id, name FROM categories " .
56 "WHERE parent = $catid ORDER BY name");
57 $childcount = 0;
58 while ($crow = sqlFetchArray($cres)) {
59 ++$childcount;
60 getKittens($crow['id'], ($catstring ? "$catstring / " : "") .
61 ($catid ? $crow['name'] : ''), $categories);
64 // If no kitties, then this is a leaf node and should be listed.
65 if (!$childcount) {
66 $categories[$catid] = $catstring;
70 // This merges the tiff files for the selected pages into one tiff file.
72 function mergeTiffs()
74 global $faxcache;
75 $msg = '';
76 $inames = '';
77 $tmp1 = array();
78 $tmp2 = 0;
79 // form_images are the checkboxes to the right of the images.
80 foreach ($_POST['form_images'] as $inbase) {
81 $inames .= ' ' . escapeshellarg("$inbase.tif");
84 if (!$inames) {
85 die(xl("Internal error - no pages were selected!"));
88 $tmp0 = exec("cd '$faxcache'; tiffcp $inames temp.tif", $tmp1, $tmp2);
89 if ($tmp2) {
90 $msg .= "tiffcp returned $tmp2: $tmp0 ";
93 return $msg;
96 // If we are submitting...
98 if ($_POST['form_save']) {
99 $action_taken = false;
100 $tmp1 = array();
101 $tmp2 = 0;
103 if ($_POST['form_cb_copy']) {
104 $patient_id = (int) $_POST['form_pid'];
105 if (!$patient_id) {
106 die(xl('Internal error - patient ID was not provided!'));
109 // Compute the name of the target directory and make sure it exists.
110 $docdir = $GLOBALS['OE_SITE_DIR'] . "/documents/$patient_id";
111 exec("mkdir -p '$docdir'");
113 // If copying to patient documents...
115 if ($_POST['form_cb_copy_type'] == 1) {
116 // Compute a target filename that does not yet exist.
117 $ffname = check_file_dir_name(trim($_POST['form_filename']));
118 $i = strrpos($ffname, '.');
119 if ($i) {
120 $ffname = trim(substr($ffname, 0, $i));
123 if (!$ffname) {
124 $ffname = $filebase;
127 $ffmod = '';
128 $ffsuff = '.pdf';
129 // If the target filename exists, modify it until it doesn't.
130 $count = 0;
131 while (is_file("$docdir/$ffname$ffmod$ffsuff")) {
132 ++$count;
133 $ffmod = "_$count";
136 $target = "$docdir/$ffname$ffmod$ffsuff";
137 $docdate = fixDate($_POST['form_docdate']);
139 // Create the target PDF. Note that we are relying on the .tif files for
140 // the individual pages to already exist in the faxcache directory.
142 $info_msg .= mergeTiffs();
143 // The -j option here requires that libtiff is configured with libjpeg.
144 // It could be omitted, but the output PDFs would then be quite large.
145 $tmp0 = exec("tiff2pdf -j -p letter -o '$target' '$faxcache/temp.tif'", $tmp1, $tmp2);
147 if ($tmp2) {
148 $info_msg .= "tiff2pdf returned $tmp2: $tmp0 ";
149 } else {
150 $newid = generate_id();
151 $fsize = filesize($target);
152 $catid = (int) $_POST['form_category'];
153 // Update the database.
154 $query = "INSERT INTO documents ( " .
155 "id, type, size, date, url, mimetype, foreign_id, docdate" .
156 " ) VALUES ( " .
157 "'$newid', 'file_url', '$fsize', NOW(), 'file://$target', " .
158 "'application/pdf', $patient_id, '$docdate' " .
159 ")";
160 sqlStatement($query);
161 $query = "INSERT INTO categories_to_documents ( " .
162 "category_id, document_id" .
163 " ) VALUES ( " .
164 "'$catid', '$newid' " .
165 ")";
166 sqlStatement($query);
167 } // end not error
169 // If we are posting a note...
170 if ($_POST['form_cb_note'] && !$info_msg) {
171 // Build note text in a way that identifies the new document.
172 // See pnotes_full.php which uses this to auto-display the document.
173 $note = "$ffname$ffmod$ffsuff";
174 for ($tmp = $catid; $tmp;) {
175 $catrow = sqlQuery("SELECT name, parent FROM categories WHERE id = '$tmp'");
176 $note = $catrow['name'] . "/$note";
177 $tmp = $catrow['parent'];
180 $note = "New scanned document $newid: $note";
181 $form_note_message = trim($_POST['form_note_message']);
182 $form_note_message = strip_escape_custom($form_note_message);
183 if ($form_note_message) {
184 $note .= "\n" . $form_note_message;
187 // addPnote() will do its own addslashes().
188 $noteid = addPnote(
189 $_POST['form_pid'],
190 $note,
191 $userauthorized,
192 '1',
193 $_POST['form_note_type'],
194 $_POST['form_note_to']
196 // Link the new patient note to the document.
197 setGpRelation(1, $newid, 6, $noteid);
198 } // end post patient note
199 } // end copy to documents
201 // Otherwise creating a scanned encounter note...
203 else {
204 // Get desired $encounter_id.
205 $encounter_id = 0;
206 if (empty($_POST['form_copy_sn_visit'])) {
207 $info_msg .= "This patient has no visits! ";
208 } else {
209 $encounter_id = 0 + $_POST['form_copy_sn_visit'];
212 if (!$info_msg) {
213 // Merge the selected pages.
214 $info_msg .= mergeTiffs();
215 $tmp_name = "$faxcache/temp.tif";
218 if (!$info_msg) {
219 // The following is cloned from contrib/forms/scanned_notes/new.php:
221 $query = "INSERT INTO form_scanned_notes ( " .
222 "notes " .
223 ") VALUES ( " .
224 "'" . $_POST['form_copy_sn_comments'] . "' " .
225 ")";
226 $formid = sqlInsert($query);
227 addForm(
228 $encounter_id,
229 "Scanned Notes",
230 $formid,
231 "scanned_notes",
232 $patient_id,
233 $userauthorized
236 $imagedir = $GLOBALS['OE_SITE_DIR'] . "/documents/$patient_id/encounters";
237 $imagepath = "$imagedir/${encounter_id}_$formid.jpg";
238 if (! is_dir($imagedir)) {
239 $tmp0 = exec('mkdir -p "' . $imagedir . '"', $tmp1, $tmp2);
240 if ($tmp2) {
241 die("mkdir returned $tmp2: $tmp0");
244 exec("touch '$imagedir/index.html'");
247 if (is_file($imagepath)) {
248 unlink($imagepath);
251 // TBD: There may be a faster way to create this file, given that
252 // we already have a jpeg for each page in faxcache.
253 $cmd = "convert -resize 800 -density 96 '$tmp_name' -append '$imagepath'";
254 $tmp0 = exec($cmd, $tmp1, $tmp2);
255 if ($tmp2) {
256 die("\"$cmd\" returned $tmp2: $tmp0");
260 // If we are posting a patient note...
261 if ($_POST['form_cb_note'] && !$info_msg) {
262 $note = "New scanned encounter note for visit on " . substr($erow['date'], 0, 10);
263 $form_note_message = trim($_POST['form_note_message']);
264 $form_note_message = strip_escape_custom($form_note_message);
265 if ($form_note_message) {
266 $note .= "\n" . $form_note_message;
269 // addPnote() will do its own addslashes().
270 addPnote(
271 $patient_id,
272 $note,
273 $userauthorized,
274 '1',
275 $_POST['form_note_type'],
276 $_POST['form_note_to']
278 } // end post patient note
281 $action_taken = true;
282 } // end copy to chart
284 if ($_POST['form_cb_forward']) {
285 $form_from = trim($_POST['form_from']);
286 $form_to = trim($_POST['form_to']);
287 $form_fax = trim($_POST['form_fax']);
288 $form_message = trim($_POST['form_message']);
289 $form_finemode = $_POST['form_finemode'] ? '-m' : '-l';
291 $form_from = strip_escape_custom($form_from);
292 $form_to = strip_escape_custom($form_to);
293 $form_message = strip_escape_custom($form_message);
295 // Generate a cover page using enscript. This can be a cool thing
296 // to do, as enscript is very powerful.
298 $tmp1 = array();
299 $tmp2 = 0;
300 $tmpfn1 = tempnam("/tmp", "fax1");
301 $tmpfn2 = tempnam("/tmp", "fax2");
302 $tmph = fopen($tmpfn1, "w");
303 $cpstring = '';
304 $fh = fopen($GLOBALS['OE_SITE_DIR'] . "/faxcover.txt", 'r');
305 while (!feof($fh)) {
306 $cpstring .= fread($fh, 8192);
309 fclose($fh);
310 $cpstring = str_replace('{CURRENT_DATE}', date('F j, Y'), $cpstring);
311 $cpstring = str_replace('{SENDER_NAME}', $form_from, $cpstring);
312 $cpstring = str_replace('{RECIPIENT_NAME}', $form_to, $cpstring);
313 $cpstring = str_replace('{RECIPIENT_FAX}', $form_fax, $cpstring);
314 $cpstring = str_replace('{MESSAGE}', $form_message, $cpstring);
315 fwrite($tmph, $cpstring);
316 fclose($tmph);
317 $tmp0 = exec("cd $webserver_root/custom; " . escapeshellcmd($GLOBALS['hylafax_enscript']) .
318 " -o $tmpfn2 $tmpfn1", $tmp1, $tmp2);
319 if ($tmp2) {
320 $info_msg .= "enscript returned $tmp2: $tmp0 ";
323 unlink($tmpfn1);
325 // Send the fax as the cover page followed by the selected pages.
326 $info_msg .= mergeTiffs();
327 $tmp0 = exec(
328 "sendfax -A -n $form_finemode -d " .
329 escapeshellarg($form_fax) . " $tmpfn2 '$faxcache/temp.tif'",
330 $tmp1,
331 $tmp2
333 if ($tmp2) {
334 $info_msg .= "sendfax returned $tmp2: $tmp0 ";
337 unlink($tmpfn2);
339 $action_taken = true;
340 } // end forward
342 $form_cb_delete = $_POST['form_cb_delete'];
344 // If deleting selected, do it and then check if any are left.
345 if ($form_cb_delete == '1' && !$info_msg) {
346 foreach ($_POST['form_images'] as $inbase) {
347 unlink("$faxcache/$inbase.jpg");
348 $action_taken = true;
351 // Check if any .jpg files remain... if not we'll clean up.
352 if ($action_taken) {
353 $dh = opendir($faxcache);
354 if (! $dh) {
355 die("Cannot read $faxcache");
358 $form_cb_delete = '2';
359 while (false !== ($jfname = readdir($dh))) {
360 if (preg_match('/\.jpg$/', $jfname)) {
361 $form_cb_delete = '1';
365 closedir($dh);
367 } // end delete 1
369 if ($form_cb_delete == '2' && !$info_msg) {
370 // Delete the tiff file, with archiving if desired.
371 if ($GLOBALS['hylafax_archdir'] && $mode == 'fax') {
372 rename($filepath, $GLOBALS['hylafax_archdir'] . '/' . $filename);
373 } else {
374 unlink($filepath);
377 // Erase its cache.
378 if (is_dir($faxcache)) {
379 $dh = opendir($faxcache);
380 while (($tmp = readdir($dh)) !== false) {
381 if (is_file("$faxcache/$tmp")) {
382 unlink("$faxcache/$tmp");
386 closedir($dh);
387 rmdir($faxcache);
390 $action_taken = true;
391 } // end delete 2
393 if (!$action_taken && !$info_msg) {
394 $info_msg = xl('You did not choose any actions.');
397 if ($info_msg || $form_cb_delete != '1') {
398 // Close this window and refresh the fax list.
399 echo "<html>\n<body>\n<script language='JavaScript'>\n";
400 if ($info_msg) {
401 echo " alert('$info_msg');\n";
404 echo " if (!opener.closed && opener.refreshme) opener.refreshme();\n";
405 echo " window.close();\n";
406 echo "</script>\n</body>\n</html>\n";
407 exit();
409 } // end submit logic
411 // If we get this far then we are displaying the form.
413 // Find out if the scanned_notes form is installed and active.
415 $tmp = sqlQuery("SELECT count(*) AS count FROM registry WHERE " .
416 "directory LIKE 'scanned_notes' AND state = 1 AND sql_run = 1");
417 $using_scanned_notes = $tmp['count'];
419 // If the image cache does not yet exist for this fax, build it.
420 // This will contain a .tif image as well as a .jpg image for each page.
422 if (! is_dir($faxcache)) {
423 $tmp0 = exec('mkdir -p "' . $faxcache . '"', $tmp1, $tmp2);
424 if ($tmp2) {
425 die("mkdir returned $tmp2: $tmp0");
428 if (strtolower($ext) != '.tif') {
429 // convert's default density for PDF-to-TIFF conversion is 72 dpi which is
430 // not very good, so we upgrade it to "fine mode" fax quality. It's really
431 // better and faster if the scanner produces TIFFs instead of PDFs.
432 $tmp0 = exec("convert -density 203x196 '$filepath' '$faxcache/deleteme.tif'", $tmp1, $tmp2);
433 if ($tmp2) {
434 die("convert returned $tmp2: $tmp0");
437 $tmp0 = exec("cd '$faxcache'; tiffsplit 'deleteme.tif'; rm -f 'deleteme.tif'", $tmp1, $tmp2);
438 if ($tmp2) {
439 die("tiffsplit/rm returned $tmp2: $tmp0");
441 } else {
442 $tmp0 = exec("cd '$faxcache'; tiffsplit '$filepath'", $tmp1, $tmp2);
443 if ($tmp2) {
444 die("tiffsplit returned $tmp2: $tmp0");
448 $tmp0 = exec("cd '$faxcache'; mogrify -resize 750x970 -format jpg *.tif", $tmp1, $tmp2);
449 if ($tmp2) {
450 die("mogrify returned $tmp2: $tmp0; ext is '$ext'; filepath is '$filepath'");
454 // Get the categories list.
455 $categories = array();
456 getKittens(0, '', $categories);
458 // Get the users list.
459 $ures = sqlStatement("SELECT username, fname, lname FROM users " .
460 "WHERE active = 1 AND ( info IS NULL OR info NOT LIKE '%Inactive%' ) " .
461 "ORDER BY lname, fname");
463 <html>
464 <head>
466 <?php Header::setupHeader(['opener', 'datetime-picker', 'jquery-ui',]);?>
467 <title><?php xl('Dispatch Received Document', 'e'); ?></title>
469 <style>
471 td, input, select, textarea {
472 font-size: 10pt;
475 .itemtitle {
476 font-weight: bold;
479 div.section {
480 border: solid;
481 border-width: 1px;
482 border-color: #0000ff;
483 margin-left: 2em;
484 padding: 1em;
487 </style>
489 <script language="JavaScript">
491 <?php require($GLOBALS['srcdir'] . "/restoreSession.php"); ?>
493 function divclick(cb, divid) {
494 var divstyle = document.getElementById(divid).style;
495 if (cb.checked) {
496 if (divid == 'div_copy_doc') {
497 document.getElementById('div_copy_sn').style.display = 'none';
499 else if (divid == 'div_copy_sn') {
500 document.getElementById('div_copy_doc').style.display = 'none';
502 divstyle.display = 'block';
503 } else {
504 divstyle.display = 'none';
506 return true;
509 // This is for callback by the find-patient popup.
510 function setpatient(pid, lname, fname, dob) {
511 var f = document.forms[0];
512 f.form_patient.value = lname + ', ' + fname;
513 f.form_pid.value = pid;
514 <?php if ($using_scanned_notes) { ?>
515 // This loads the patient's list of recent encounters:
516 f.form_copy_sn_visit.options.length = 0;
517 f.form_copy_sn_visit.options[0] = new Option('Loading...', '0');
518 $.getScript("fax_dispatch_newpid.php?p=" + pid);
519 <?php } ?>
522 // This invokes the find-patient popup.
523 function sel_patient() {
524 dlgopen('../main/calendar/find_patient_popup.php', '_blank', 750, 550, false, 'Select Patient');
527 // Check for errors when the form is submitted.
528 function validate() {
529 var f = document.forms[0];
531 if (f.form_cb_copy.checked) {
532 if (! f.form_pid.value) {
533 alert('You have not selected a patient!');
534 return false;
538 if (f.form_cb_forward.checked) {
539 var s = f.form_fax.value;
540 if (! s) {
541 alert('A fax number is required!');
542 return false;
544 var digcount = 0;
545 for (var i = 0; i < s.length; ++i) {
546 var c = s.charAt(i);
547 if (c >= '0' && c <= '9') {
548 ++digcount;
550 else if (digcount == 0 || c != '-') {
551 alert('Invalid character(s) in fax number!');
552 return false;
555 if (digcount == 7) {
556 if (s.charAt(0) < '2') {
557 alert('Local phone number starts with an invalid digit!');
558 return false;
561 else if (digcount == 11) {
562 if (s.charAt(0) != '1') {
563 alert('11-digit number must begin with 1!');
564 return false;
567 else if (digcount == 10) {
568 if (s.charAt(0) < '2') {
569 alert('10-digit number starts with an invalid digit!');
570 return false;
572 f.form_fax.value = '1' + s;
574 else {
575 alert('Invalid number of digits in fax telephone number!');
576 return false;
580 if (f.form_cb_copy.checked || f.form_cb_forward.checked) {
581 var check_count = 0;
582 for (var i = 0; i < f.elements.length; ++i) {
583 if (f.elements[i].name == 'form_images[]' && f.elements[i].checked)
584 ++check_count;
586 if (check_count == 0) {
587 alert('No pages have been selected!');
588 return false;
592 top.restoreSession();
593 return true;
596 function allCheckboxes(issel) {
597 var f = document.forms[0];
598 for (var i = 0; i < f.elements.length; ++i) {
599 if (f.elements[i].name == 'form_images[]') f.elements[i].checked = issel;
603 $(document).ready(function(){
604 $('.datepicker').datetimepicker({
605 <?php $datetimepicker_timepicker = false; ?>
606 <?php $datetimepicker_showseconds = false; ?>
607 <?php $datetimepicker_formatInput = false; ?>
608 <?php require($GLOBALS['srcdir'] . '/js/xl/jquery-datetimepicker-2-5-4.js.php'); ?>
609 <?php // can add any additional javascript settings to datetimepicker here; need to prepend first setting with a comma ?>
612 </script>
614 </head>
616 <body class="body_top" onunload='imclosing()'>
618 <center><h2><?php xl('Dispatch Received Document', 'e'); ?></h2></center>
620 <form method='post' name='theform'
621 action='fax_dispatch.php?<?php echo ($mode == 'fax') ? 'file' : 'scan'; ?>=<?php echo $filename ?>' onsubmit='return validate()'>
623 <p><input type='checkbox' name='form_cb_copy' value='1'
624 onclick='return divclick(this,"div_copy");' />
625 <b><?php xl('Copy Pages to Patient Chart', 'e'); ?></b></p>
627 <div id='div_copy' class='section' style='display:none;'>
628 <table>
629 <tr>
630 <td class='itemtitle' width='1%' nowrap><?php xl('Patient', 'e'); ?></td>
631 <td>
632 <input type='text' size='10' name='form_patient' style='width:100%'
633 value=' (<?php xl('Click to select'); ?>)' onclick='sel_patient()'
634 title='Click to select patient' readonly />
635 <input type='hidden' name='form_pid' value='0' />
636 </td>
637 </tr>
638 <tr>
639 <td colspan='2' style='padding-top:0.5em;'>
640 <input type='radio' name='form_cb_copy_type' value='1'
641 onclick='return divclick(this,"div_copy_doc");' checked />
642 <b><?php xl('Patient Document', 'e'); ?></b>&nbsp;
643 <?php if ($using_scanned_notes) { ?>
644 <input type='radio' name='form_cb_copy_type' value='2'
645 onclick='return divclick(this,"div_copy_sn");' />
646 <b><?php xl('Scanned Encounter Note', 'e'); ?></b>
647 <?php } ?>
648 <div id='div_copy_doc' class='section' style='margin-top:0.5em;'>
649 <table width='100%'>
650 <tr>
651 <td class='itemtitle' nowrap><?php xl('Category', 'e'); ?></td>
652 <td>
653 <select name='form_category' style='width:100%'>
654 <?php
655 foreach ($categories as $catkey => $catname) {
656 echo " <option value='$catkey'";
657 echo ">$catname</option>\n";
660 </select>
661 </td>
662 </tr>
663 <tr>
664 <td class='itemtitle' nowrap><?php xl('Filename', 'e'); ?></td>
665 <td>
666 <input type='text' size='10' name='form_filename' style='width:100%'
667 value='<?php echo "$filebase.pdf" ?>'
668 title='Name for this document in the patient chart' />
669 </td>
670 </tr>
671 <tr>
672 <td class='itemtitle' nowrap><?php xl('Document Date', 'e'); ?></td>
673 <td>
674 <input type='text' class='datepicker' size='10' name='form_docdate' id='form_docdate'
675 value='<?php echo date('Y-m-d'); ?>'
676 title='<?php xl('yyyy-mm-dd date associated with this document', 'e'); ?>' />
677 </td>
678 </tr>
679 </table>
680 </div><!-- end div_copy_doc -->
681 <div id='div_copy_sn' class='section' style='display:none;margin-top:0.5em;'>
682 <table width='100%'>
683 <tr>
684 <td class='itemtitle' width='1%' nowrap><?php xl('Visit Date', 'e'); ?></td>
685 <td>
686 <select name='form_copy_sn_visit' style='width:100%'>
687 </select>
688 </td>
689 </tr>
690 <tr>
691 <td class='itemtitle' width='1%' nowrap><?php xl('Comments', 'e'); ?></td>
692 <td>
693 <textarea name='form_copy_sn_comments' rows='3' cols='30' style='width:100%'
694 title='Comments associated with this scanned note'
695 /></textarea>
696 </td>
697 </tr>
698 </table>
699 </div><!-- end div_copy_sn -->
700 </td>
701 </tr>
702 <tr>
703 <td colspan='2' style='padding-top:0.5em;'>
704 <input type='checkbox' name='form_cb_note' value='1'
705 onclick='return divclick(this,"div_note");' />
706 <b><?php xl('Create Patient Note', 'e'); ?></b>
707 <div id='div_note' class='section' style='display:none;margin-top:0.5em;'>
708 <table>
709 <tr>
710 <td class='itemtitle' width='1%' nowrap><?php xl('Type', 'e'); ?></td>
711 <td>
712 <?php
713 // Added 6/2009 by BM to incorporate the patient notes into the list_options listings
714 generate_form_field(array('data_type'=>1,'field_id'=>'note_type','list_id'=>'note_type','empty_title'=>'SKIP'), '');
716 </td>
717 </tr>
718 <tr>
719 <td class='itemtitle' width='1%' nowrap>To</td>
720 <td>
721 <select name='form_note_to' style='width:100%'>
722 <?php
723 while ($urow = sqlFetchArray($ures)) {
724 echo " <option value='" . $urow['username'] . "'";
725 echo ">" . $urow['lname'];
726 if ($urow['fname']) {
727 echo ", " . $urow['fname'];
730 echo "</option>\n";
733 <option value=''>** <?php xl('Close', 'e'); ?> **</option>
734 </select>
735 </td>
736 </tr>
737 <tr>
738 <td class='itemtitle' nowrap><?php xl('Message', 'e'); ?></td>
739 <td>
740 <textarea name='form_note_message' rows='3' cols='30' style='width:100%'
741 title='Your comments' /></textarea>
742 </td>
743 </tr>
744 </table>
745 </div><!-- end div_note -->
746 </td>
747 </tr>
748 </table>
749 </div><!-- end div_copy -->
751 <p><input type='checkbox' name='form_cb_forward' value='1'
752 onclick='return divclick(this,"div_forward");' />
753 <b><?php xl('Forward Pages via Fax', 'e'); ?></b></p>
755 <div id='div_forward' class='section' style='display:none;'>
756 <table>
757 <tr>
758 <td class='itemtitle' width='1%' nowrap><?php xl('From', 'e'); ?></td>
759 <td>
760 <input type='text' size='10' name='form_from' style='width:100%'
761 title='Type your name here' />
762 </td>
763 </tr>
764 <tr>
765 <td class='itemtitle' nowrap><?php xl('To', 'e'); ?></td>
766 <td>
767 <input type='text' size='10' name='form_to' style='width:100%'
768 title='Type the recipient name here' />
769 </td>
770 </tr>
771 <tr>
772 <td class='itemtitle' nowrap><?php xl('Fax', 'e'); ?></td>
773 <td>
774 <input type='text' size='10' name='form_fax' style='width:100%'
775 title='The fax phone number to send this to' />
776 </td>
777 </tr>
778 <tr>
779 <td class='itemtitle' nowrap><?php xl('Message', 'e'); ?></td>
780 <td>
781 <textarea name='form_message' rows='3' cols='30' style='width:100%'
782 title='Your comments to include with this message' /></textarea>
783 </td>
784 </tr>
785 <tr>
786 <td class='itemtitle' nowrap><?php xl('Quality', 'e'); ?></td>
787 <td>
788 <input type='radio' name='form_finemode' value='' /><?php xl('Normal', 'e'); ?> &nbsp;
789 <input type='radio' name='form_finemode' value='1' checked /><?php xl('Fine', 'e'); ?> &nbsp;
790 </td>
791 </tr>
792 </table>
793 </div><!-- end div_forward -->
795 <p><b><?php xl('Delete Pages', 'e'); ?>:</b>&nbsp;
796 <input type='radio' name='form_cb_delete' value='2' />All&nbsp;
797 <input type='radio' name='form_cb_delete' value='1' checked />Selected&nbsp;
798 <input type='radio' name='form_cb_delete' value='0' />None
799 </p>
801 <center>
803 <input type='submit' name='form_save' value='<?php xl('OK', 'e'); ?>' />
804 &nbsp; &nbsp;
805 <input type='button' value='<?php xl('Cancel', 'e'); ?>' onclick='window.close()' />
806 &nbsp; &nbsp;
807 <input type='button' value='<?php xl('Select All', 'e'); ?>' onclick='allCheckboxes(true)' />
808 &nbsp; &nbsp;
809 <input type='button' value='<?php xl('Clear All', 'e'); ?>' onclick='allCheckboxes(false)' />
810 </p>
812 <p><br /><b><?php xl('Please select the desired pages to copy or forward:', 'e'); ?></b></p>
813 <table>
815 <?php
816 $dh = opendir($faxcache);
817 if (! $dh) {
818 die("Cannot read $faxcache");
821 $jpgarray = array();
822 while (false !== ($jfname = readdir($dh))) {
823 if (preg_match("/^(.*)\.jpg/", $jfname, $matches)) {
824 $jpgarray[$matches[1]] = $jfname;
828 closedir($dh);
829 // readdir does not read in any particular order, we must therefore sort
830 // by filename so the display order matches the original document.
831 ksort($jpgarray);
832 $page = 0;
833 foreach ($jpgarray as $jfnamebase => $jfname) {
834 ++$page;
835 echo " <tr>\n";
836 echo " <td valign='top'>\n";
837 echo " <img src='../../sites/" . $_SESSION['site_id'] . "/faxcache/$mode/$filebase/$jfname' />\n";
838 echo " </td>\n";
839 echo " <td align='center' valign='top'>\n";
840 echo " <input type='checkbox' name='form_images[]' value='$jfnamebase' checked />\n";
841 echo " <br />$page\n";
842 echo " </td>\n";
843 echo " </tr>\n";
847 </table>
848 </center>
849 </form>
850 </body>
851 </html>