Changed query that gets the date of the last encounter for date calculations. It...
[openemr.git] / contrib / forms / specialist_notes / new.php
blob175353323481e24ec6a66062a9d8316e0b617ac4
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) 2005 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");
25 $row = array();
27 if (! $encounter) { // comes from globals.php
28 die("Internal error: we do not seem to be in an encounter!");
31 function cbvalue($cbname) {
32 return $_POST[$cbname] ? '1' : '0';
35 function cbinput($name, $colname) {
36 global $row;
37 $ret = "<input type='checkbox' name='$name' value='1'";
38 if ($row[$colname]) $ret .= " checked";
39 $ret .= " />";
40 return $ret;
43 function cbcell($name, $desc, $colname) {
44 return "<td width='25%' nowrap>" . cbinput($name, $colname) . "$desc</td>\n";
47 $formid = $_GET['id'];
49 // If Save was clicked, save the info.
51 if ($_POST['bn_save']) {
53 $fu_timing = $_POST['fu_timing'];
54 $fu_location = $_POST['fu_location'];
56 // If updating an existing form...
58 if ($formid) {
59 $query = "UPDATE form_specialist_notes SET " .
60 "notes = '" . $_POST['form_notes'] . "', " .
61 "followup_required = " . cbvalue('fu_required') . ", " .
62 "followup_timing = '$fu_timing'" . ", " .
63 "followup_location = '$fu_location'" . " " .
64 "WHERE id = '$formid'";
65 sqlStatement($query);
68 // If adding a new form...
70 else {
71 $query = "INSERT INTO form_specialist_notes ( " .
72 "notes, followup_required, followup_timing, followup_location " .
73 ") VALUES ( " .
74 "'" . $_POST['form_notes'] . "', " .
75 cbvalue('fu_required') . ", " .
76 "'$fu_timing'" . ", " .
77 "'$fu_location'" . " " .
78 ")";
79 $newid = sqlInsert($query);
80 addForm($encounter, "Specialist Notes", $newid, "specialist_notes", $pid, $userauthorized);
83 formHeader("Redirecting....");
84 formJump();
85 formFooter();
86 exit;
89 if ($formid) {
90 $row = sqlQuery ("SELECT * FROM form_specialist_notes WHERE " .
91 "id = '$formid' AND activity = '1'") ;
94 <html>
95 <head>
96 <link rel=stylesheet href="<?echo $css_header;?>" type="text/css">
97 <script type="text/javascript" src="../../../library/dialog.js"></script>
98 <script language='JavaScript'>
99 function newEvt() {
100 dlgopen('../../main/calendar/add_edit_event.php?patientid=<? echo $pid ?>',
101 '_blank', 550, 270);
102 return false;
104 </script>
105 </head>
107 <body <?echo $top_bg_line;?> topmargin="0" rightmargin="0" leftmargin="2"
108 bottommargin="0" marginwidth="2" marginheight="0">
109 <form method="post" action="<? echo $rootdir ?>/forms/specialist_notes/new.php?id=<? echo $formid ?>"
110 onsubmit="return top.restoreSession()">
112 <center>
115 <table border='1' width='95%'>
117 <tr bgcolor='#dddddd'>
118 <td colspan='2' align='center'><b>Notes from Specialist</b></td>
119 </tr>
121 <tr>
122 <td width='5%' nowrap> Notes </td>
123 <td width='95%' nowrap>
124 <textarea name='form_notes' rows='18' style='width:100%'><? echo $row['notes'] ?></textarea>
125 </td>
126 </tr>
128 <tr>
129 <td nowrap>Follow Up</td>
130 <td nowrap>
131 <table width='100%'>
132 <tr>
133 <td width='1%' nowrap>
134 <? echo cbinput('fu_required', 'followup_required') ?>Required on&nbsp;
135 </td>
136 <td width='49%' nowrap>
137 <input type='text' name='fu_timing' size='10' style='width:100%'
138 title='When to follow up'
139 value='<? echo addslashes($row['followup_timing']) ?>' />
140 </td>
141 <td width='1%' nowrap>
142 &nbsp;at&nbsp;
143 </td>
144 <td width='49%' nowrap>
145 <input type='text' name='fu_location' size='10' style='width:100%'
146 title='Where to follow up'
147 value='<? echo addslashes($row['followup_location']) ?>' />
148 </td>
149 </tr>
150 </table>
151 </td>
152 </tr>
154 </table>
157 <input type='submit' name='bn_save' value='Save' />
158 &nbsp;
159 <input type='button' value='Add Appointment' onclick='newEvt()' />
160 &nbsp;
161 <input type='button' value='Cancel' onclick="top.restoreSession();location='<?php echo $GLOBALS['form_exit_url']; ?>'" />
162 </p>
164 </center>
166 </form>
167 </body>
168 </html>