Highway to PSR2
[openemr.git] / contrib / forms / specialist_notes / new.php
blob4fef639445c07cbe012360b17193694e515116a8
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)
33 return $_POST[$cbname] ? '1' : '0';
36 function cbinput($name, $colname)
38 global $row;
39 $ret = "<input type='checkbox' name='$name' value='1'";
40 if ($row[$colname]) {
41 $ret .= " checked";
44 $ret .= " />";
45 return $ret;
48 function cbcell($name, $desc, $colname)
50 return "<td width='25%' nowrap>" . cbinput($name, $colname) . "$desc</td>\n";
53 $formid = $_GET['id'];
55 // If Save was clicked, save the info.
57 if ($_POST['bn_save']) {
58 $fu_timing = $_POST['fu_timing'];
59 $fu_location = $_POST['fu_location'];
61 // If updating an existing form...
63 if ($formid) {
64 $query = "UPDATE form_specialist_notes SET " .
65 "notes = '" . $_POST['form_notes'] . "', " .
66 "followup_required = " . cbvalue('fu_required') . ", " .
67 "followup_timing = '$fu_timing'" . ", " .
68 "followup_location = '$fu_location'" . " " .
69 "WHERE id = '$formid'";
70 sqlStatement($query);
71 } // If adding a new form...
73 else {
74 $query = "INSERT INTO form_specialist_notes ( " .
75 "notes, followup_required, followup_timing, followup_location " .
76 ") VALUES ( " .
77 "'" . $_POST['form_notes'] . "', " .
78 cbvalue('fu_required') . ", " .
79 "'$fu_timing'" . ", " .
80 "'$fu_location'" . " " .
81 ")";
82 $newid = sqlInsert($query);
83 addForm($encounter, "Specialist Notes", $newid, "specialist_notes", $pid, $userauthorized);
86 formHeader("Redirecting....");
87 formJump();
88 formFooter();
89 exit;
92 if ($formid) {
93 $row = sqlQuery("SELECT * FROM form_specialist_notes WHERE " .
94 "id = '$formid' AND activity = '1'") ;
97 <html>
98 <head>
99 <?php html_header_show();?>
100 <link rel="stylesheet" href="<?php echo $css_header;?>" type="text/css">
101 <script type="text/javascript" src="../../../library/dialog.js?v=<?php echo $v_js_includes; ?>"></script>
102 <script language='JavaScript'>
103 function newEvt() {
104 dlgopen('../../main/calendar/add_edit_event.php?patientid=<?php echo $pid ?>',
105 '_blank', 775, 500);
106 return false;
108 </script>
109 </head>
111 <body class="body_top">
112 <form method="post" action="<?php echo $rootdir ?>/forms/specialist_notes/new.php?id=<?php echo $formid ?>" onsubmit="return top.restoreSession()">
114 <center>
117 <table border='1' width='95%'>
119 <tr bgcolor='#dddddd'>
120 <td colspan='2' align='center'><b>Notes from Specialist</b></td>
121 </tr>
123 <tr>
124 <td width='5%' nowrap> Notes </td>
125 <td width='95%' nowrap>
126 <textarea name='form_notes' rows='18' style='width:100%'><?php echo $row['notes'] ?></textarea>
127 </td>
128 </tr>
130 <tr>
131 <td nowrap>Follow Up</td>
132 <td nowrap>
133 <table width='100%'>
134 <tr>
135 <td width='1%' nowrap>
136 <?php echo cbinput('fu_required', 'followup_required') ?>Required on&nbsp;
137 </td>
138 <td width='49%' nowrap>
139 <input type='text' name='fu_timing' size='10' style='width:100%'
140 title='When to follow up'
141 value='<?php echo addslashes($row['followup_timing']) ?>' />
142 </td>
143 <td width='1%' nowrap>
144 &nbsp;at&nbsp;
145 </td>
146 <td width='49%' nowrap>
147 <input type='text' name='fu_location' size='10' style='width:100%'
148 title='Where to follow up'
149 value='<?php echo addslashes($row['followup_location']) ?>' />
150 </td>
151 </tr>
152 </table>
153 </td>
154 </tr>
156 </table>
159 <input type='submit' name='bn_save' value='Save' />
160 &nbsp;
161 <input type='button' value='Add Appointment' onclick='newEvt()' />
162 &nbsp;
163 <input type='button' value='Cancel' onclick="top.restoreSession();location='<?php echo $GLOBALS['form_exit_url']; ?>'" />
164 </p>
166 </center>
168 </form>
169 </body>
170 </html>