Change formatting of initial comment block.
[openemr.git] / contrib / forms / scanned_notes / new.php
blobdb5a3f4291348db27f8757a9d50d1343d8c47d56
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-2010 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 = $GLOBALS['OE_SITE_DIR'] . "/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 // Remove any previous image files for this encounter and form ID.
72 for ($i = -1; true; ++$i) {
73 $suffix = ($i < 0) ? "" : "-$i";
74 $path = "$imagedir/${encounter}_$formid$suffix.jpg";
75 if (is_file($path)) {
76 unlink($path);
78 else {
79 if ($i >= 0) break;
82 $tmp_name = $_FILES['form_image']['tmp_name'];
83 // default density is 72 dpi, we change to 96. And -append was removed
84 // to create a separate image file for each page.
85 $cmd = "convert -density 96 '$tmp_name' '$imagepath'";
86 $tmp0 = exec($cmd, $tmp1, $tmp2);
87 if ($tmp2) die("\"$cmd\" returned $tmp2: $tmp0");
90 // formHeader("Redirecting....");
91 // formJump();
92 // formFooter();
93 // exit;
96 $imagepath = "$imagedir/${encounter}_$formid.jpg";
97 $imageurl = "$web_root/sites/" . $_SESSION['site_id'] .
98 "/documents/$pid/encounters/${encounter}_$formid.jpg";
100 if ($formid) {
101 $row = sqlQuery("SELECT * FROM form_scanned_notes WHERE " .
102 "id = '$formid' AND activity = '1'");
103 $formrow = sqlQuery("SELECT id FROM forms WHERE " .
104 "form_id = '$formid' AND formdir = 'scanned_notes'");
107 <html>
108 <head>
109 <?php html_header_show();?>
110 <link rel="stylesheet" href="<?php echo $css_header;?>" type="text/css">
111 <style type="text/css">
112 .dehead { color:#000000; font-family:sans-serif; font-size:10pt; font-weight:bold }
113 .detail { color:#000000; font-family:sans-serif; font-size:10pt; font-weight:normal }
114 </style>
115 <script type="text/javascript" src="../../../library/dialog.js"></script>
117 <script language='JavaScript'>
119 function newEvt() {
120 dlgopen('../../main/calendar/add_edit_event.php?patientid=<?php echo $pid ?>',
121 '_blank', 550, 270);
122 return false;
125 // Process click on Delete button.
126 function deleteme() {
127 dlgopen('../../patient_file/deleter.php?formid=<?php echo $formrow['id'] ?>', '_blank', 500, 450);
128 return false;
131 // Called by the deleteme.php window on a successful delete.
132 function imdeleted() {
133 top.restoreSession();
134 location = '<?php echo $GLOBALS['form_exit_url']; ?>';
137 </script>
139 </head>
141 <body class="body_top">
143 <form method="post" enctype="multipart/form-data"
144 action="<?php echo $rootdir ?>/forms/scanned_notes/new.php?id=<?php echo $formid ?>"
145 onsubmit="return top.restoreSession()">
147 <center>
150 <table border='1' width='95%'>
152 <tr bgcolor='#dddddd' class='dehead'>
153 <td colspan='2' align='center'>Scanned Encounter Notes</td>
154 </tr>
156 <tr>
157 <td width='5%' class='dehead' nowrap>&nbsp;Comments&nbsp;</td>
158 <td width='95%' class='detail' nowrap>
159 <textarea name='form_notes' rows='4' style='width:100%'><?php echo $row['notes'] ?></textarea>
160 </td>
161 </tr>
163 <tr>
164 <td class='dehead' nowrap>&nbsp;Document&nbsp;</td>
165 <td class='detail' nowrap>
166 <?php
167 if ($formid && is_file($imagepath)) {
168 echo " <img src='$imageurl' />\n";
171 <p>&nbsp;
172 <?php xl('Upload this file:','e') ?>
173 <input type="hidden" name="MAX_FILE_SIZE" value="12000000" />
174 <input name="form_image" type="file" />
175 <br />&nbsp;</p>
176 </td>
177 </tr>
179 </table>
182 <input type='submit' name='bn_save' value='Save' />
183 &nbsp;
184 <input type='button' value='Add Appointment' onclick='newEvt()' />
185 &nbsp;
186 <input type='button' value='Back' onclick="top.restoreSession();location='<?php echo $GLOBALS['form_exit_url']; ?>'" />
187 <?php if ($formrow['id'] && acl_check('admin', 'super')) { ?>
188 &nbsp;
189 <input type='button' value='Delete' onclick='deleteme()' style='color:red' />
190 <?php } ?>
191 </p>
193 </center>
195 </form>
196 </body>
197 </html>