2 //////////////////////////////////////////////////////////////////////
3 // ------------------ DO NOT MODIFY VIEW.PHP !!! ---------------------
4 // View.php is an exact duplicate of new.php. If you wish to make
5 // any changes, then change new.php and either (recommended) make
6 // view.php a symbolic link to new.php, or copy new.php to view.php.
8 // And if you check in a change to either module, be sure to check
9 // in the other (identical) module also.
11 // This nonsense will go away if we ever move to subversion.
12 //////////////////////////////////////////////////////////////////////
14 // Copyright (C) 2006 Rod Roark <rod@sunsetsystems.com>
16 // This program is free software; you can redistribute it and/or
17 // modify it under the terms of the GNU General Public License
18 // as published by the Free Software Foundation; either version 2
19 // of the License, or (at your option) any later version.
21 include_once("../../globals.php");
22 include_once("$srcdir/api.inc");
23 include_once("$srcdir/forms.inc");
24 include_once("$srcdir/acl.inc");
28 if (! $encounter) { // comes from globals.php
29 die("Internal error: we do not seem to be in an encounter!");
32 $formid = $_GET['id'];
33 $imagedir = "$webserver_root/documents/$pid/encounters";
35 // If Save was clicked, save the info.
37 if ($_POST['bn_save']) {
39 // If updating an existing form...
42 $query = "UPDATE form_scanned_notes SET " .
43 "notes = '" . $_POST['form_notes'] . "' " .
44 "WHERE id = '$formid'";
48 // If adding a new form...
51 $query = "INSERT INTO form_scanned_notes ( " .
54 "'" . $_POST['form_notes'] . "' " .
56 $formid = sqlInsert($query);
57 addForm($encounter, "Scanned Notes", $formid, "scanned_notes", $pid, $userauthorized);
60 $imagepath = "$imagedir/${encounter}_$formid.jpg";
62 // Upload new or replacement document.
63 // Always convert it to jpeg.
64 if ($_FILES['form_image']['size']) {
65 // If the patient's encounter image directory does not yet exist, create it.
66 if (! is_dir($imagedir)) {
67 $tmp0 = exec("mkdir -p '$imagedir'", $tmp1, $tmp2);
68 if ($tmp2) die("mkdir returned $tmp2: $tmp0");
69 exec("touch '$imagedir/index.html'");
71 $tmp_name = $_FILES['form_image']['tmp_name'];
72 // $cmd = "convert '$tmp_name' '$imagepath'"; // default density is 72 dpi
73 $cmd = "convert -density 96 '$tmp_name' '$imagepath'";
74 $tmp0 = exec($cmd, $tmp1, $tmp2);
75 if ($tmp2) die("\"$cmd\" returned $tmp2: $tmp0");
78 // formHeader("Redirecting....");
84 $imagepath = "$imagedir/${encounter}_$formid.jpg";
85 $imageurl = "$web_root/documents/$pid/encounters/${encounter}_$formid.jpg";
88 $row = sqlQuery("SELECT * FROM form_scanned_notes WHERE " .
89 "id = '$formid' AND activity = '1'");
90 $formrow = sqlQuery("SELECT id FROM forms WHERE " .
91 "form_id = '$formid' AND formdir = 'scanned_notes'");
96 <link rel
=stylesheet href
="<?echo $css_header;?>" type
="text/css">
97 <style type
="text/css">
98 body
{ font
-family
:sans
-serif
; font
-size
:10pt
; font
-weight
:normal
}
99 .dehead
{ color
:#000000; font-family:sans-serif; font-size:10pt; font-weight:bold }
100 .detail
{ color
:#000000; font-family:sans-serif; font-size:10pt; font-weight:normal }
102 <script type
="text/javascript" src
="../../../library/dialog.js"></script
>
104 <script language
='JavaScript'>
107 dlgopen('../../main/calendar/add_edit_event.php?patientid=<? echo $pid ?>',
112 // Process click on Delete button.
113 function deleteme() {
114 dlgopen('../../patient_file/deleter.php?formid=<?php echo $formrow['id
'] ?>', '_blank', 500, 450);
118 // Called by the deleteme.php window on a successful delete.
119 function imdeleted() {
120 top
.restoreSession();
121 location
= '<?php echo $GLOBALS['form_exit_url
']; ?>';
128 <body
<?
echo $top_bg_line;?
> topmargin
="0" rightmargin
="0" leftmargin
="2"
129 bottommargin
="0" marginwidth
="2" marginheight
="0">
131 <form method
="post" enctype
="multipart/form-data"
132 action
="<? echo $rootdir ?>/forms/scanned_notes/new.php?id=<? echo $formid ?>"
133 onsubmit
="return top.restoreSession()">
138 <table border
='1' width
='95%'>
140 <tr bgcolor
='#dddddd' class='dehead'>
141 <td colspan
='2' align
='center'>Scanned Encounter Notes
</td
>
145 <td width
='5%' class='dehead' nowrap
> 
;Comments
 
;</td
>
146 <td width
='95%' class='detail' nowrap
>
147 <textarea name
='form_notes' rows
='4' style
='width:100%'><?
echo $row['notes'] ?
></textarea
>
152 <td
class='dehead' nowrap
> 
;Document
 
;</td
>
153 <td
class='detail' nowrap
>
155 if ($formid && is_file($imagepath)) {
156 echo " <img src='$imageurl' />\n";
160 <?php
xl('Upload this file:','e') ?
>
161 <input type
="hidden" name
="MAX_FILE_SIZE" value
="12000000" />
162 <input name
="form_image" type
="file" />
170 <input type
='submit' name
='bn_save' value
='Save' />
172 <input type
='button' value
='Add Appointment' onclick
='newEvt()' />
174 <input type
='button' value
='Back' onclick
="top.restoreSession();location='<?php echo $GLOBALS['form_exit_url']; ?>'" />
175 <?php
if ($formrow['id'] && acl_check('admin', 'super')) { ?
>
177 <input type
='button' value
='Delete' onclick
='deleteme()' style
='color:red' />