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