missing require, missing close tag (#4473)
[openemr.git] / interface / fax / fax_dispatch.php
blob370fe5e0b5f603b7aa0abcdb0c334000f2423e6b
1 <?php
3 /**
4 * fax dispatch
6 * @package OpenEMR
7 * @link http://www.open-emr.org
8 * @author Rod Roark <rod@sunsetsystems.com>
9 * @author Brady Miller <brady.g.miller@gmail.com>
10 * @copyright Copyright (c) 2006-2010 Rod Roark <rod@sunsetsystems.com>
11 * @copyright Copyright (c) 2017-2018 Brady Miller <brady.g.miller@gmail.com>
12 * @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\Common\Crypto\CryptoGen;
23 use OpenEMR\Common\Csrf\CsrfUtils;
24 use OpenEMR\Core\Header;
26 if ($_GET['file']) {
27 if (!CsrfUtils::verifyCsrfToken($_GET["csrf_token_form"])) {
28 CsrfUtils::csrfNotVerified();
31 $mode = 'fax';
32 $filename = $_GET['file'];
34 // ensure the file variable has no illegal characters
35 check_file_dir_name($filename);
37 $filepath = $GLOBALS['hylafax_basedir'] . '/recvq/' . $filename;
38 } elseif ($_GET['scan']) {
39 if (!CsrfUtils::verifyCsrfToken($_GET["csrf_token_form"])) {
40 CsrfUtils::csrfNotVerified();
43 $mode = 'scan';
44 $filename = $_GET['scan'];
46 // ensure the file variable has no illegal characters
47 check_file_dir_name($filename);
49 $filepath = $GLOBALS['scanner_output_directory'] . '/' . $filename;
50 } else {
51 die("No filename was given.");
54 $ext = substr($filename, strrpos($filename, '.'));
55 $filebase = basename("/$filename", $ext);
56 $faxcache = $GLOBALS['OE_SITE_DIR'] . "/faxcache/$mode/$filebase";
58 $info_msg = "";
60 // This function builds an array of document categories recursively.
61 // Kittens are the children of cats, you know. :-)getKittens
63 function getKittens($catid, $catstring, &$categories)
65 $cres = sqlStatement("SELECT id, name FROM categories " .
66 "WHERE parent = ? ORDER BY name", array($catid));
67 $childcount = 0;
68 while ($crow = sqlFetchArray($cres)) {
69 ++$childcount;
70 getKittens($crow['id'], ($catstring ? "$catstring / " : "") .
71 ($catid ? $crow['name'] : ''), $categories);
74 // If no kitties, then this is a leaf node and should be listed.
75 if (!$childcount) {
76 $categories[$catid] = $catstring;
80 // This merges the tiff files for the selected pages into one tiff file.
82 function mergeTiffs()
84 global $faxcache;
85 $msg = '';
86 $inames = '';
87 $tmp1 = array();
88 $tmp2 = 0;
89 // form_images are the checkboxes to the right of the images.
90 foreach ($_POST['form_images'] as $inbase) {
91 check_file_dir_name($inbase);
92 $inames .= ' ' . escapeshellarg("$inbase.tif");
95 if (!$inames) {
96 die(xlt("Internal error - no pages were selected!"));
99 $tmp0 = exec("cd " . escapeshellarg($faxcache) . "; tiffcp $inames temp.tif", $tmp1, $tmp2);
100 if ($tmp2) {
101 $msg .= "tiffcp returned $tmp2: $tmp0 ";
104 return $msg;
107 // If we are submitting...
109 if ($_POST['form_save']) {
110 if (!CsrfUtils::verifyCsrfToken($_POST["csrf_token_form"])) {
111 CsrfUtils::csrfNotVerified();
114 $action_taken = false;
115 $tmp1 = array();
116 $tmp2 = 0;
118 if ($_POST['form_cb_copy']) {
119 $patient_id = (int) $_POST['form_pid'];
120 if (!$patient_id) {
121 die(xlt('Internal error - patient ID was not provided!'));
124 // Compute the name of the target directory and make sure it exists.
125 $docdir = $GLOBALS['OE_SITE_DIR'] . "/documents/" . check_file_dir_name($patient_id);
126 exec("mkdir -p " . escapeshellarg($docdir));
128 // If copying to patient documents...
130 if ($_POST['form_cb_copy_type'] == 1) {
131 // Compute a target filename that does not yet exist.
132 $ffname = check_file_dir_name(trim($_POST['form_filename']));
133 $i = strrpos($ffname, '.');
134 if ($i) {
135 $ffname = trim(substr($ffname, 0, $i));
138 if (!$ffname) {
139 $ffname = $filebase;
142 $ffmod = '';
143 $ffsuff = '.pdf';
144 // If the target filename exists, modify it until it doesn't.
145 $count = 0;
146 while (is_file("$docdir/$ffname$ffmod$ffsuff")) {
147 ++$count;
148 $ffmod = "_$count";
151 $target = "$docdir/$ffname$ffmod$ffsuff";
152 $docdate = fixDate($_POST['form_docdate']);
154 // Create the target PDF. Note that we are relying on the .tif files for
155 // the individual pages to already exist in the faxcache directory.
157 $info_msg .= mergeTiffs();
158 // The -j option here requires that libtiff is configured with libjpeg.
159 // It could be omitted, but the output PDFs would then be quite large.
160 $tmp0 = exec("tiff2pdf -j -p letter -o " . escapeshellarg($target) . " " . escapeshellarg($faxcache . '/temp.tif'), $tmp1, $tmp2);
162 if ($tmp2) {
163 $info_msg .= "tiff2pdf returned $tmp2: $tmp0 ";
164 } else {
165 $newid = generate_id();
166 $fsize = filesize($target);
167 $catid = (int) $_POST['form_category'];
168 // Update the database.
169 $query = "INSERT INTO documents ( " .
170 "id, type, size, date, url, mimetype, foreign_id, docdate" .
171 " ) VALUES ( " .
172 "?, 'file_url', ?, NOW(), ?, " .
173 "'application/pdf', ?, ? " .
174 ")";
175 sqlStatement($query, array($newid, $fsize, 'file://' . $target, $patient_id, $docdate));
176 $query = "INSERT INTO categories_to_documents ( " .
177 "category_id, document_id" .
178 " ) VALUES ( " .
179 "?, ? " .
180 ")";
181 sqlStatement($query, array($catid, $newid));
182 } // end not error
184 // If we are posting a note...
185 if ($_POST['form_cb_note'] && !$info_msg) {
186 // Build note text in a way that identifies the new document.
187 // See pnotes_full.php which uses this to auto-display the document.
188 $note = "$ffname$ffmod$ffsuff";
189 for ($tmp = $catid; $tmp;) {
190 $catrow = sqlQuery("SELECT name, parent FROM categories WHERE id = ?", array($tmp));
191 $note = $catrow['name'] . "/$note";
192 $tmp = $catrow['parent'];
195 $note = "New scanned document $newid: $note";
196 $form_note_message = trim($_POST['form_note_message']);
197 if ($form_note_message) {
198 $note .= "\n" . $form_note_message;
201 $noteid = addPnote(
202 $_POST['form_pid'],
203 $note,
204 $userauthorized,
205 '1',
206 $_POST['form_note_type'],
207 $_POST['form_note_to']
209 // Link the new patient note to the document.
210 setGpRelation(1, $newid, 6, $noteid);
211 } // end post patient note
212 } else { // end copy to documents
213 // Otherwise creating a scanned encounter note...
214 // Get desired $encounter_id.
215 $encounter_id = 0;
216 if (empty($_POST['form_copy_sn_visit'])) {
217 $info_msg .= "This patient has no visits! ";
218 } else {
219 $encounter_id = 0 + $_POST['form_copy_sn_visit'];
222 if (!$info_msg) {
223 // Merge the selected pages.
224 $info_msg .= mergeTiffs();
225 $tmp_name = "$faxcache/temp.tif";
228 if (!$info_msg) {
229 // The following is cloned from contrib/forms/scanned_notes/new.php:
231 $query = "INSERT INTO form_scanned_notes ( notes ) VALUES ( ? )";
232 $formid = sqlInsert($query, array($_POST['form_copy_sn_comments']));
233 addForm(
234 $encounter_id,
235 "Scanned Notes",
236 $formid,
237 "scanned_notes",
238 $patient_id,
239 $userauthorized
242 $imagedir = $GLOBALS['OE_SITE_DIR'] . "/documents/" . check_file_dir_name($patient_id) . "/encounters";
243 $imagepath = "$imagedir/" . check_file_dir_name($encounter_id) . "_" . check_file_dir_name($formid) . ".jpg";
244 if (! is_dir($imagedir)) {
245 $tmp0 = exec('mkdir -p ' . escapeshellarg($imagedir), $tmp1, $tmp2);
246 if ($tmp2) {
247 die("mkdir returned " . text($tmp2) . ": " . text($tmp0));
250 exec("touch " . escapeshellarg($imagedir . "/index.html"));
253 if (is_file($imagepath)) {
254 unlink($imagepath);
257 // TBD: There may be a faster way to create this file, given that
258 // we already have a jpeg for each page in faxcache.
259 $cmd = "convert -resize 800 -density 96 " . escapeshellarg($tmp_name) . " -append " . escapeshellarg($imagepath);
260 $tmp0 = exec($cmd, $tmp1, $tmp2);
261 if ($tmp2) {
262 die("\"" . text($cmd) . "\" returned " . text($tmp2) . ": " . text($tmp0));
266 // If we are posting a patient note...
267 if ($_POST['form_cb_note'] && !$info_msg) {
268 $note = "New scanned encounter note for visit on " . substr($erow['date'], 0, 10);
269 $form_note_message = trim($_POST['form_note_message']);
270 if ($form_note_message) {
271 $note .= "\n" . $form_note_message;
274 addPnote(
275 $patient_id,
276 $note,
277 $userauthorized,
278 '1',
279 $_POST['form_note_type'],
280 $_POST['form_note_to']
282 } // end post patient note
285 $action_taken = true;
286 } // end copy to chart
288 if ($_POST['form_cb_forward']) {
289 $form_from = trim($_POST['form_from']);
290 $form_to = trim($_POST['form_to']);
291 $form_fax = trim($_POST['form_fax']);
292 $form_message = trim($_POST['form_message']);
293 $form_finemode = $_POST['form_finemode'] ? '-m' : '-l';
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 " . escapeshellarg($webserver_root . '/custom') . "; " . escapeshellcmd((new CryptoGen())->decryptStandard($GLOBALS['more_secure']['hylafax_enscript'])) .
318 " -o " . escapeshellarg($tmpfn2) . " " . escapeshellarg($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 " . escapeshellarg($form_finemode) . " -d " .
329 escapeshellarg($form_fax) . " " . escapeshellarg($tmpfn2) . " " . escapeshellarg($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 check_file_dir_name($inbase);
348 unlink($faxcache . "/" . $inbase . ".jpg");
349 $action_taken = true;
352 // Check if any .jpg files remain... if not we'll clean up.
353 if ($action_taken) {
354 $dh = opendir($faxcache);
355 if (! $dh) {
356 die("Cannot read " . text($faxcache));
359 $form_cb_delete = '2';
360 while (false !== ($jfname = readdir($dh))) {
361 if (preg_match('/\.jpg$/', $jfname)) {
362 $form_cb_delete = '1';
366 closedir($dh);
368 } // end delete 1
370 if ($form_cb_delete == '2' && !$info_msg) {
371 // Delete the tiff file, with archiving if desired.
372 if ($GLOBALS['hylafax_archdir'] && $mode == 'fax') {
373 rename($filepath, $GLOBALS['hylafax_archdir'] . '/' . $filename);
374 } else {
375 unlink($filepath);
378 // Erase its cache.
379 if (is_dir($faxcache)) {
380 $dh = opendir($faxcache);
381 while (($tmp = readdir($dh)) !== false) {
382 if (is_file("$faxcache/$tmp")) {
383 unlink("$faxcache/$tmp");
387 closedir($dh);
388 rmdir($faxcache);
391 $action_taken = true;
392 } // end delete 2
394 if (!$action_taken && !$info_msg) {
395 $info_msg = xl('You did not choose any actions.');
398 if ($info_msg || $form_cb_delete != '1') {
399 // Close this window and refresh the fax list.
400 echo "<html>\n<body>\n<script>\n";
401 if ($info_msg) {
402 echo " alert('" . addslashes($info_msg) . "');\n";
405 echo " if (!opener.closed && opener.refreshme) opener.refreshme();\n";
406 echo " window.close();\n";
407 echo "</script>\n</body>\n</html>\n";
408 exit();
410 } // end submit logic
412 // If we get this far then we are displaying the form.
414 // Find out if the scanned_notes form is installed and active.
416 $tmp = sqlQuery("SELECT count(*) AS count FROM registry WHERE " .
417 "directory LIKE 'scanned_notes' AND state = 1 AND sql_run = 1");
418 $using_scanned_notes = $tmp['count'];
420 // If the image cache does not yet exist for this fax, build it.
421 // This will contain a .tif image as well as a .jpg image for each page.
423 if (! is_dir($faxcache)) {
424 $tmp0 = exec('mkdir -p ' . escapeshellarg($faxcache), $tmp1, $tmp2);
425 if ($tmp2) {
426 die("mkdir returned " . text($tmp2) . ": " . text($tmp0));
429 if (strtolower($ext) != '.tif') {
430 // convert's default density for PDF-to-TIFF conversion is 72 dpi which is
431 // not very good, so we upgrade it to "fine mode" fax quality. It's really
432 // better and faster if the scanner produces TIFFs instead of PDFs.
433 $tmp0 = exec("convert -density 203x196 " . escapeshellarg($filepath) . " " . escapeshellarg($faxcache . '/deleteme.tif'), $tmp1, $tmp2);
434 if ($tmp2) {
435 die("convert returned " . text($tmp2) . ": " . text($tmp0));
438 $tmp0 = exec("cd " . escapeshellarg($faxcache) . "; tiffsplit 'deleteme.tif'; rm -f 'deleteme.tif'", $tmp1, $tmp2);
439 if ($tmp2) {
440 die("tiffsplit/rm returned " . text($tmp2) . ": " . text($tmp0));
442 } else {
443 $tmp0 = exec("cd " . escapeshellarg($faxcache) . "; tiffsplit " . escapeshellarg($filepath), $tmp1, $tmp2);
444 if ($tmp2) {
445 die("tiffsplit returned " . text($tmp2) . ": " . text($tmp0));
449 $tmp0 = exec("cd " . escapeshellarg($faxcache) . "; mogrify -resize 750x970 -format jpg *.tif", $tmp1, $tmp2);
450 if ($tmp2) {
451 die("mogrify returned " . text($tmp2) . ": " . text($tmp0) . "; ext is '" . text($ext) . "'; filepath is '" . text($filepath) . "'");
455 // Get the categories list.
456 $categories = array();
457 getKittens(0, '', $categories);
459 // Get the users list.
460 $ures = sqlStatement("SELECT username, fname, lname FROM users " .
461 "WHERE active = 1 AND ( info IS NULL OR info NOT LIKE '%Inactive%' ) " .
462 "ORDER BY lname, fname");
464 <html>
465 <head>
467 <?php Header::setupHeader(['opener', 'datetime-picker']);?>
468 <title><?php echo xlt('Dispatch Received Document'); ?></title>
470 <script>
472 <?php require($GLOBALS['srcdir'] . "/restoreSession.php"); ?>
474 function divclick(cb, divid) {
475 var divstyle = document.getElementById(divid).style;
476 if (cb.checked) {
477 if (divid == 'div_copy_doc') {
478 document.getElementById('div_copy_sn').style.display = 'none';
480 else if (divid == 'div_copy_sn') {
481 document.getElementById('div_copy_doc').style.display = 'none';
483 divstyle.display = 'block';
484 } else {
485 divstyle.display = 'none';
487 return true;
490 // This is for callback by the find-patient popup.
491 function setpatient(pid, lname, fname, dob) {
492 var f = document.forms[0];
493 f.form_patient.value = lname + ', ' + fname;
494 f.form_pid.value = pid;
495 <?php if ($using_scanned_notes) { ?>
496 // This loads the patient's list of recent encounters:
497 f.form_copy_sn_visit.options.length = 0;
498 f.form_copy_sn_visit.options[0] = new Option('Loading...', '0');
499 $.getScript("fax_dispatch_newpid.php?p=" + encodeURIComponent(pid) + "&csrf_token_form=" + <?php echo js_url(CsrfUtils::collectCsrfToken()); ?>);
500 <?php } ?>
503 // This invokes the find-patient popup.
504 function sel_patient() {
505 dlgopen('../main/calendar/find_patient_popup.php', '_blank', 750, 550, false, 'Select Patient');
508 // Check for errors when the form is submitted.
509 function validate() {
510 var f = document.forms[0];
512 if (f.form_cb_copy.checked) {
513 if (! f.form_pid.value) {
514 alert('You have not selected a patient!');
515 return false;
519 if (f.form_cb_forward.checked) {
520 var s = f.form_fax.value;
521 if (! s) {
522 alert('A fax number is required!');
523 return false;
525 var digcount = 0;
526 for (var i = 0; i < s.length; ++i) {
527 var c = s.charAt(i);
528 if (c >= '0' && c <= '9') {
529 ++digcount;
531 else if (digcount == 0 || c != '-') {
532 alert('Invalid character(s) in fax number!');
533 return false;
536 if (digcount == 7) {
537 if (s.charAt(0) < '2') {
538 alert('Local phone number starts with an invalid digit!');
539 return false;
542 else if (digcount == 11) {
543 if (s.charAt(0) != '1') {
544 alert('11-digit number must begin with 1!');
545 return false;
548 else if (digcount == 10) {
549 if (s.charAt(0) < '2') {
550 alert('10-digit number starts with an invalid digit!');
551 return false;
553 f.form_fax.value = '1' + s;
555 else {
556 alert('Invalid number of digits in fax telephone number!');
557 return false;
561 if (f.form_cb_copy.checked || f.form_cb_forward.checked) {
562 var check_count = 0;
563 for (var i = 0; i < f.elements.length; ++i) {
564 if (f.elements[i].name == 'form_images[]' && f.elements[i].checked)
565 ++check_count;
567 if (check_count == 0) {
568 alert('No pages have been selected!');
569 return false;
573 top.restoreSession();
574 return true;
577 function allCheckboxes(issel) {
578 var f = document.forms[0];
579 for (var i = 0; i < f.elements.length; ++i) {
580 if (f.elements[i].name == 'form_images[]') f.elements[i].checked = issel;
584 $(function () {
585 $('.datepicker').datetimepicker({
586 <?php $datetimepicker_timepicker = false; ?>
587 <?php $datetimepicker_showseconds = false; ?>
588 <?php $datetimepicker_formatInput = false; ?>
589 <?php require($GLOBALS['srcdir'] . '/js/xl/jquery-datetimepicker-2-5-4.js.php'); ?>
590 <?php // can add any additional javascript settings to datetimepicker here; need to prepend first setting with a comma ?>
593 </script>
595 </head>
597 <body class="body_top">
598 <h2 class="text-center"><?php echo xlt('Dispatch Received Document'); ?></h2>
600 <form method='post' name='theform'
601 action='fax_dispatch.php?<?php echo ($mode == 'fax') ? 'file' : 'scan'; ?>=<?php echo attr_url($filename); ?>&csrf_token_form=<?php echo attr_url(CsrfUtils::collectCsrfToken()); ?>' onsubmit='return validate()'>
602 <input type="hidden" name="csrf_token_form" value="<?php echo attr(CsrfUtils::collectCsrfToken()); ?>" />
604 <p><input type='checkbox' name='form_cb_copy' value='1'
605 onclick='return divclick(this,"div_copy");' />
606 <span class="font-weight-bold"><?php echo xlt('Copy Pages to Patient Chart'); ?></span></p>
608 <!-- Copy Pages to Patient Chart Section -->
609 <div id='div_copy' class='jumbotron' style='display:none;'>
610 <!-- Patient Section -->
611 <div class="form-row mt-2">
612 <label class="col-2 col-form-label font-weight-bold"><?php echo xlt('Patient'); ?></label>
613 <div class="col-10">
614 <input type='text' size='10' name='form_patient' class='form-control bg-light'
615 value=' (<?php echo xla('Click to select'); ?>)' onclick='sel_patient()'
616 data-toggle='tooltip' data-placement='top'
617 title='<?php echo xla('Click to select patient'); ?>' readonly />
618 <input type='hidden' name='form_pid' value='0' />
619 </div>
620 </div>
621 <!-- Patient Document Section -->
622 <div class="form-row mt-2">
623 <div class="col-12 col-form-label">
624 <input type='radio' name='form_cb_copy_type' value='1'
625 onclick='return divclick(this,"div_copy_doc");' checked />
626 <label class="font-weight-bold"><?php echo xlt('Patient Document'); ?></label>
627 <?php if ($using_scanned_notes) { ?>
628 <input type='radio' name='form_cb_copy_type' value='2'
629 onclick='return divclick(this,"div_copy_sn");' />
630 <label class="font-weight-bold"><?php echo xlt('Scanned Encounter Note'); ?></label>
631 <?php } ?>
632 <!-- div_copy_doc Section -->
633 <div id='div_copy_doc' class='bg-secondary border rounded p-2'>
634 <!-- Category Section -->
635 <div class="form-row mt-2">
636 <label class="col-2 col-form-label font-weight-bold"><?php echo xlt('Category'); ?></label>
637 <div class="col-10">
638 <select name='form_category' class='form-control'>
639 <?php
640 foreach ($categories as $catkey => $catname) {
641 echo " <option value='" . attr($catkey) . "'";
642 echo ">" . text($catname) . "</option>";
645 </select>
646 </div>
647 </div>
648 <!-- Filename Section -->
649 <div class="form-row mt-2">
650 <label class="col-2 col-form-label font-weight-bold"><?php echo xlt('Filename'); ?></label>
651 <div class="col-10">
652 <input type='text' size='10' name='form_filename' class='form-control'
653 value='<?php echo attr($filebase) . ".pdf" ?>'
654 data-toggle='tooltip' data-placement='top'
655 title='Name for this document in the patient chart' />
656 </div>
657 </div>
658 <!-- Document Date Section -->
659 <div class="form-row mt-2">
660 <label class="col-2 col-form-label font-weight-bold"><?php echo xlt('Document Date'); ?></label>
661 <div class="col-10">
662 <input type='text' class='datepicker form-control' size='10' name='form_docdate' id='form_docdate'
663 value='<?php echo date('Y-m-d'); ?>'
664 data-toggle='tooltip' data-placement='top'
665 title='<?php echo xla('yyyy-mm-dd date associated with this document'); ?>' />
666 </div>
667 </div>
668 </div>
669 <!-- div_copy_sn Section -->
670 <div id='div_copy_sn' class='bg-secondary border rounded p-2' style='display:none;margin-top:0.5em;'>
671 <!-- Visit Date Section -->
672 <div class="form-row mt-2">
673 <label class="col-2 col-form-label font-weight-bold"><?php echo xlt('Visit Date'); ?></label>
674 <div class="col-10">
675 <select name='form_copy_sn_visit' class='form-control'>
676 </select>
677 </div>
678 </div>
679 <!-- Comments Section -->
680 <div class="form-row mt-2">
681 <label class="col-2 col-form-label font-weight-bold"><?php echo xlt('Comments'); ?></label>
682 <div class="col-10">
683 <textarea name='form_copy_sn_comments' rows='3' cols='30' class='form-control'
684 data-toggle='tooltip' data-placement='top'
685 title='Comments associated with this scanned note'>
686 </textarea>
687 </div>
688 </div>
689 </div>
690 </div>
691 </div>
692 <!-- Create Patient Note Section -->
693 <div class="form-gruop row">
694 <div class="col-12 col-form-label">
695 <input type='checkbox' name='form_cb_note' value='1'
696 onclick='return divclick(this,"div_note");' />
697 <label class="font-weight-bold"><?php echo xlt('Create Patient Note'); ?></label>
698 <!-- div_note Section -->
699 <div id='div_note' class='bg-secondary border rounded p-2' style='display:none;'>
700 <!-- Type Section -->
701 <div class="form-row mt-2">
702 <label class="col-2 col-form-label font-weight-bold"><?php echo xlt('Type'); ?></label>
703 <div class="col-10">
704 <?php
705 // Added 6/2009 by BM to incorporate the patient notes into the list_options listings
706 generate_form_field(array('data_type' => 1,'field_id' => 'note_type','list_id' => 'note_type','empty_title' => 'SKIP'), '');
708 </div>
709 </div>
710 <!-- To Section -->
711 <div class="form-row mt-2">
712 <label class="col-2 col-form-label font-weight-bold"><?php echo xlt('To'); ?></label>
713 <div class="col-10">
714 <select name='form_note_to' class='form-control'>
715 <?php
716 while ($urow = sqlFetchArray($ures)) {
717 echo " <option value='" . attr($urow['username']) . "'";
718 echo ">" . text($urow['lname']);
719 if ($urow['fname']) {
720 echo ", " . text($urow['fname']);
723 echo "</option>\n";
726 <option value=''>** <?php echo xlt('Close'); ?> **</option>
727 </select>
728 </div>
729 </div>
730 <!-- Message Section -->
731 <div class="form-row mt-2">
732 <label class="col-2 col-form-label font-weight-bold"><?php echo xlt('Message'); ?></label>
733 <div class="col-10">
734 <textarea name='form_note_message' rows='3' cols='30' class='form-control'
735 data-toggle='tooltip' data-placement='top'
736 title='Your comments'>
737 </textarea>
738 </div>
739 </div>
740 </div>
741 </div>
742 </div>
743 </div>
745 <p><input type='checkbox' name='form_cb_forward' value='1'
746 onclick='return divclick(this,"div_forward");' />
747 <span class="font-weight-bold"><?php echo xlt('Forward Pages via Fax'); ?></span></p>
749 <!-- Forward Pages via Fax Section -->
750 <div id='div_forward' class='jumbotron' style='display:none;'>
751 <!-- From Section -->
752 <div class="form-row mt-2">
753 <label class="col-2 col-form-label font-weight-bold"><?php echo xlt('From'); ?></label>
754 <div class="col-10">
755 <input type='text' size='10' name='form_from' class='form-control' data-toggle='tooltip' data-placement='top' title='Type your name here'>
756 </div>
757 </div>
758 <!-- To Section -->
759 <div class="form-row mt-2">
760 <label class="col-2 col-form-label font-weight-bold"><?php echo xlt('To{{Destination}}'); ?></label>
761 <div class="col-10">
762 <input type='text' size='10' name='form_to' class='form-control' data-toggle='tooltip' data-placement='top' title='Type the recipient name here'>
763 </div>
764 </div>
765 <!-- Fax Section -->
766 <div class="form-row mt-2">
767 <label class="col-2 col-form-label font-weight-bold"><?php echo xlt('Fax'); ?></label>
768 <div class="col-10">
769 <input type='text' size='10' name='form_fax' class='form-control' data-toggle='tooltip' data-placement='top' title='The fax phone number to send this to'>
770 </div>
771 </div>
772 <!-- Message Section -->
773 <div class="form-row mt-2">
774 <label class="col-2 col-form-label font-weight-bold"><?php echo xlt('Message'); ?></label>
775 <div class="col-10">
776 <textarea name='form_message' rows='3' cols='30' class='form-control'
777 data-toggle='tooltip' data-placement='top'
778 title='Your comments to include with this message'>
779 </textarea>
780 </div>
781 </div>
782 <!-- Quality Section -->
783 <div class="form-row mt-2">
784 <label class="col-2 col-form-label font-weight-bold"><?php echo xlt('Quality'); ?></label>
785 <div class="col-10">
786 <div class="form-check form-check-inline">
787 <input type='radio' class='form-check-input' name='form_finemode' value=''>
788 <label class="form-check-label"><?php echo xlt('Normal'); ?></label>
789 </div>
790 <div class="form-check form-check-inline">
791 <input type='radio' class='form-check-input' name='form_finemode' value='1' checked>
792 <label class="form-check-label"><?php echo xlt('Fine'); ?></label>
793 </div>
794 </div>
795 </div>
796 </div>
798 <div class="form-group form-inline">
799 <label class="font-weight-bold"><?php echo xlt('Delete Pages'); ?>:</label>
800 <div class="form-check form-check-inline">
801 <input type='radio' class='form-check-input' name='form_cb_delete' value='2' />
802 <label class="form-check-label">All</label>
803 </div>
804 <div class="form-check form-check-inline">
805 <input type='radio' class='form-check-input' name='form_cb_delete' value='1' checked />
806 <label class="form-check-label">Selected</label>
807 </div>
808 <div class="form-check form-check-inline">
809 <input type='radio' class='form-check-input' name='form_cb_delete' value='0' />
810 <label class="form-check-label">None</label>
811 </div>
812 </div>
814 <div class="btn-group">
815 <button type='submit' class='btn btn-primary btn-save' name='form_save' value='<?php echo xla('OK'); ?>'><?php echo xla('OK'); ?></button>
816 <button type='button' class='btn btn-secondary btn-cancel' value='<?php echo xla('Cancel'); ?>' onclick='window.close()'><?php echo xla('Cancel'); ?></button>
817 <button type='button' class='btn btn-secondary' value='<?php echo xla('Select All'); ?>' onclick='allCheckboxes(true)'><?php echo xla('Select All'); ?></button>
818 <button type='button' class='btn btn-secondary' value='<?php echo xla('Clear All'); ?>' onclick='allCheckboxes(false)'><?php echo xla('Clear All'); ?></button>
819 </div>
821 <p class="mt-2 font-weight-bold"><?php echo xlt('Please select the desired pages to copy or forward:'); ?></p>
822 <table>
824 <?php
825 $dh = opendir($faxcache);
826 if (! $dh) {
827 die("Cannot read " . text($faxcache));
830 $jpgarray = array();
831 while (false !== ($jfname = readdir($dh))) {
832 if (preg_match("/^(.*)\.jpg/", $jfname, $matches)) {
833 $jpgarray[$matches[1]] = $jfname;
837 closedir($dh);
838 // readdir does not read in any particular order, we must therefore sort
839 // by filename so the display order matches the original document.
840 ksort($jpgarray);
841 $page = 0;
842 foreach ($jpgarray as $jfnamebase => $jfname) {
843 ++$page;
844 echo " <tr>\n";
845 echo " <td valign='top'>\n";
846 echo " <img src='../../sites/" . attr($_SESSION['site_id']) . "/faxcache/" . attr($mode) . "/" . attr($filebase) . "/" . attr($jfname) . "' />\n";
847 echo " </td>\n";
848 echo " <td align='center' valign='top'>\n";
849 echo " <input type='checkbox' name='form_images[]' value='" . attr($jfnamebase) . "' checked />\n";
850 echo " <br />" . text($page) . "\n";
851 echo " </td>\n";
852 echo " </tr>\n";
856 </table>
857 </form>
858 <script>
859 $(function () {
860 $('[data-toggle="tooltip"]').tooltip();
862 </script>
863 </body>
864 </html>