UTF8 encoding support
[openemr.git] / contrib / forms / scanned_notes / view.php
blob701187b3043568e65a33738aad7de2bda3b12d87
1 <?php
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.
7 //
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");
26 $row = array();
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...
41 if ($formid) {
42 $query = "UPDATE form_scanned_notes SET " .
43 "notes = '" . $_POST['form_notes'] . "' " .
44 "WHERE id = '$formid'";
45 sqlStatement($query);
48 // If adding a new form...
50 else {
51 $query = "INSERT INTO form_scanned_notes ( " .
52 "notes " .
53 ") VALUES ( " .
54 "'" . $_POST['form_notes'] . "' " .
55 ")";
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 if (is_file($imagepath)) unlink($imagepath);
72 $tmp_name = $_FILES['form_image']['tmp_name'];
73 // $cmd = "convert '$tmp_name' '$imagepath'"; // default density is 72 dpi
74 $cmd = "convert -density 96 '$tmp_name' -append '$imagepath'";
75 $tmp0 = exec($cmd, $tmp1, $tmp2);
76 if ($tmp2) die("\"$cmd\" returned $tmp2: $tmp0");
79 // formHeader("Redirecting....");
80 // formJump();
81 // formFooter();
82 // exit;
85 $imagepath = "$imagedir/${encounter}_$formid.jpg";
86 $imageurl = "$web_root/documents/$pid/encounters/${encounter}_$formid.jpg";
88 if ($formid) {
89 $row = sqlQuery("SELECT * FROM form_scanned_notes WHERE " .
90 "id = '$formid' AND activity = '1'");
91 $formrow = sqlQuery("SELECT id FROM forms WHERE " .
92 "form_id = '$formid' AND formdir = 'scanned_notes'");
95 <html>
96 <head>
97 <? html_header_show();?>
98 <link rel=stylesheet href="<?echo $css_header;?>" type="text/css">
99 <style type="text/css">
100 body { font-family:sans-serif; font-size:10pt; font-weight:normal }
101 .dehead { color:#000000; font-family:sans-serif; font-size:10pt; font-weight:bold }
102 .detail { color:#000000; font-family:sans-serif; font-size:10pt; font-weight:normal }
103 </style>
104 <script type="text/javascript" src="../../../library/dialog.js"></script>
106 <script language='JavaScript'>
108 function newEvt() {
109 dlgopen('../../main/calendar/add_edit_event.php?patientid=<? echo $pid ?>',
110 '_blank', 550, 270);
111 return false;
114 // Process click on Delete button.
115 function deleteme() {
116 dlgopen('../../patient_file/deleter.php?formid=<?php echo $formrow['id'] ?>', '_blank', 500, 450);
117 return false;
120 // Called by the deleteme.php window on a successful delete.
121 function imdeleted() {
122 top.restoreSession();
123 location = '<?php echo $GLOBALS['form_exit_url']; ?>';
126 </script>
128 </head>
130 <body <?echo $top_bg_line;?> topmargin="0" rightmargin="0" leftmargin="2"
131 bottommargin="0" marginwidth="2" marginheight="0">
133 <form method="post" enctype="multipart/form-data"
134 action="<? echo $rootdir ?>/forms/scanned_notes/new.php?id=<? echo $formid ?>"
135 onsubmit="return top.restoreSession()">
137 <center>
140 <table border='1' width='95%'>
142 <tr bgcolor='#dddddd' class='dehead'>
143 <td colspan='2' align='center'>Scanned Encounter Notes</td>
144 </tr>
146 <tr>
147 <td width='5%' class='dehead' nowrap>&nbsp;Comments&nbsp;</td>
148 <td width='95%' class='detail' nowrap>
149 <textarea name='form_notes' rows='4' style='width:100%'><? echo $row['notes'] ?></textarea>
150 </td>
151 </tr>
153 <tr>
154 <td class='dehead' nowrap>&nbsp;Document&nbsp;</td>
155 <td class='detail' nowrap>
156 <?php
157 if ($formid && is_file($imagepath)) {
158 echo " <img src='$imageurl' />\n";
161 <p>&nbsp;
162 <?php xl('Upload this file:','e') ?>
163 <input type="hidden" name="MAX_FILE_SIZE" value="12000000" />
164 <input name="form_image" type="file" />
165 <br />&nbsp;</p>
166 </td>
167 </tr>
169 </table>
172 <input type='submit' name='bn_save' value='Save' />
173 &nbsp;
174 <input type='button' value='Add Appointment' onclick='newEvt()' />
175 &nbsp;
176 <input type='button' value='Back' onclick="top.restoreSession();location='<?php echo $GLOBALS['form_exit_url']; ?>'" />
177 <?php if ($formrow['id'] && acl_check('admin', 'super')) { ?>
178 &nbsp;
179 <input type='button' value='Delete' onclick='deleteme()' style='color:red' />
180 <?php } ?>
181 </p>
183 </center>
185 </form>
186 </body>
187 </html>