Simplified code from previous commit
[openemr.git] / contrib / forms / cricket_injury_audit / view.php
blob6eabba2f41d2eda506892e9ab5054a2b8b4c30b9
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-2007 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('cia.inc.php');
26 $row = array();
28 if (! $encounter) { // comes from globals.php
29 die("Internal error: we do not seem to be in an encounter!");
32 function rbvalue($rbname) {
33 $tmp = $_POST[$rbname];
34 if (! $tmp) $tmp = '0';
35 return "'$tmp'";
38 function cbvalue($cbname) {
39 return $_POST[$cbname] ? '1' : '0';
42 function invalue($inname) {
43 return (int) trim($_POST[$inname]);
46 function txvalue($txname) {
47 return "'" . trim($_POST[$txname]) . "'";
50 function rbinput($name, $value, $desc, $colname) {
51 global $row;
52 $ret = "<input type='radio' name='$name' value='$value'";
53 if ($row[$colname] == $value) $ret .= " checked";
54 $ret .= " />$desc";
55 return $ret;
58 function rbcell($name, $value, $desc, $colname) {
59 return " <td width='25%' nowrap>" . rbinput($name, $value, $desc, $colname) . "</td>\n";
62 function cbinput($name, $colname) {
63 global $row;
64 $ret = "<input type='checkbox' name='$name' value='1'";
65 if ($row[$colname]) $ret .= " checked";
66 $ret .= " />";
67 return $ret;
70 function cbcell($name, $desc, $colname) {
71 return " <td width='25%' nowrap>" . cbinput($name, $colname) .
72 "$desc</td>\n";
75 // Generate HTML table entries for the designated set of radio buttons.
77 function genRadios($group, &$arr) {
78 $i = 0;
79 foreach ($arr as $key => $value) {
80 if (($i % 4) == 0) {
81 if ($i) echo " </tr>\n";
82 echo " <tr>\n";
84 echo rbcell("form_$group", $key, $value, "ci$group");
85 ++$i;
87 while ($i % 4) {
88 echo " <td width='25%'>&nbsp;</td>\n";
89 ++$i;
91 if ($i) echo " </tr>\n";
94 $formid = $_GET['id'];
96 // If Save was clicked, save the info.
98 if ($_POST['bn_save']) {
99 $fiinjmin = (int) $_POST['form_injmin'];
101 // If updating an existing form...
103 if ($formid) {
104 $query = "UPDATE form_cricket_injury_audit SET " .
105 "cicounty = " . rbvalue('form_county') . ", " .
106 "citeam = " . rbvalue('form_team') . ", " .
107 "ciduration = " . rbvalue('form_duration') . ", " .
108 "cirole = " . rbvalue('form_role') . ", " .
109 "cimatchtype = " . rbvalue('form_matchtype') . ", " .
110 "cicause = " . rbvalue('form_cause') . ", " .
111 "ciactivity = " . rbvalue('form_activity') . ", " .
112 "cibatside = " . rbvalue('form_batside') . ", " .
113 "cibowlside = " . rbvalue('form_bowlside') . ", " .
114 "cibowltype = " . rbvalue('form_bowltype') . " " .
115 "WHERE id = '$formid'";
116 sqlStatement($query);
119 // If adding a new form...
121 else {
122 $query = "INSERT INTO form_cricket_injury_audit ( " .
123 "cicounty, citeam, ciduration, cirole, cimatchtype, cicause, " .
124 "ciactivity, cibatside, cibowlside, cibowltype " .
125 ") VALUES ( " .
126 rbvalue('form_county') . ", " .
127 rbvalue('form_team') . ", " .
128 rbvalue('form_duration') . ", " .
129 rbvalue('form_role') . ", " .
130 rbvalue('form_matchtype') . ", " .
131 rbvalue('form_cause') . ", " .
132 rbvalue('form_activity') . ", " .
133 rbvalue('form_batside') . ", " .
134 rbvalue('form_bowlside') . ", " .
135 rbvalue('form_bowltype') . " " .
136 ")";
137 $newid = sqlInsert($query);
138 addForm($encounter, "Cricket Injury Audit", $newid, "cricket_injury_audit", $pid, $userauthorized);
141 formHeader("Redirecting....");
142 formJump();
143 formFooter();
144 exit;
147 if ($formid) {
148 $row = sqlQuery ("SELECT * FROM form_cricket_injury_audit WHERE " .
149 "id = '$formid' AND activity = '1'") ;
152 <html>
153 <head>
154 <?php html_header_show();?>
155 <link rel=stylesheet href="<?echo $css_header;?>" type="text/css">
156 <style>
157 .billcell { font-family: sans-serif; font-size: 10pt }
158 </style>
160 <script type="text/javascript" src="../../../library/dialog.js"></script>
162 <script language="JavaScript">
164 // Pop up the coding window.
165 function docoding() {
166 var width = screen.width - 50;
167 if (!isNaN(top.screenX)) {
168 width -= top.screenX;
169 } else if (!isNaN(top.screenLeft)) {
170 width -= top.screenLeft;
172 if (width > 1000) width = 1000;
173 dlgopen('../../patient_file/encounter/coding_popup.php', '_blank', width, 550);
176 </script>
177 </head>
179 <body <?echo $top_bg_line;?> topmargin="0" rightmargin="0" leftmargin="2" bottommargin="0" marginwidth="2" marginheight="0">
180 <form method="post" action="<?php echo $rootdir ?>/forms/cricket_injury_audit/new.php?id=<?php echo $formid ?>"
181 onsubmit="return top.restoreSession()">
183 <center>
185 <p class='title' style='margin-top:8px;margin-bottom:8px'>Cricket Injury Statistics</p>
187 <table border='1' width='98%'>
189 <tr bgcolor='#dddddd'>
190 <td colspan='2' align='center'><b>Match Information</b></td>
191 </tr>
193 <tr>
194 <td nowrap>County</td>
195 <td nowrap>
196 <table width='100%'>
197 <?php genRadios('county', $arr_county); ?>
198 </table>
199 </td>
200 </tr>
202 <tr>
203 <td nowrap>Team ATI</td>
204 <td nowrap>
205 <table width='100%'>
206 <?php genRadios('team', $arr_team); ?>
207 </table>
208 </td>
209 </tr>
211 <tr>
212 <td nowrap>Match Duration</td>
213 <td nowrap>
214 <table width='100%'>
215 <?php genRadios('duration', $arr_duration); ?>
216 </table>
217 </td>
218 </tr>
220 <tr>
221 <td nowrap>Main Role in Team</td>
222 <td nowrap>
223 <table width='100%'>
224 <?php genRadios('role', $arr_role); ?>
225 </table>
226 </td>
227 </tr>
229 <tr>
230 <td nowrap>Injured In</td>
231 <td nowrap>
232 <table width='100%'>
233 <?php genRadios('matchtype', $arr_matchtype); ?>
234 </table>
235 </td>
236 </tr>
238 <tr bgcolor='#dddddd'>
239 <td colspan='2' align='center'><b>Mechanism of Injury</b></td>
240 </tr>
242 <tr>
243 <td nowrap>Cause</td>
244 <td nowrap>
245 <table width='100%'>
246 <?php genRadios('cause', $arr_cause); ?>
247 </table>
248 </td>
249 </tr>
251 <tr>
252 <td nowrap>Activity ATI</td>
253 <td nowrap>
254 <table width='100%'>
255 <?php genRadios('activity', $arr_activity); ?>
256 </table>
257 </td>
258 </tr>
260 <tr bgcolor='#dddddd'>
261 <td colspan='2' align='center'><b>Conditions</b></td>
262 </tr>
264 <tr>
265 <td nowrap>Batting Side</td>
266 <td nowrap>
267 <table width='100%'>
268 <?php genRadios('batside', $arr_batside); ?>
269 </table>
270 </td>
271 </tr>
273 <tr>
274 <td nowrap>Bowling Side</td>
275 <td nowrap>
276 <table width='100%'>
277 <?php genRadios('bowlside', $arr_bowlside); ?>
278 </table>
279 </td>
280 </tr>
282 <tr>
283 <td nowrap>Bowling Type</td>
284 <td nowrap>
285 <table width='100%'>
286 <?php genRadios('bowltype', $arr_bowltype); ?>
287 </table>
288 </td>
289 </tr>
291 </table>
294 <input type='submit' name='bn_save' value='Save' />
295 &nbsp;
296 <input type='button' value='Cancel' onclick="top.restoreSession();location='<?php echo $GLOBALS['form_exit_url']; ?>'" />
297 &nbsp;
298 <input type='button' value='Add Injury Diagnosis...' onclick='docoding();'
299 title='Add or change coding for this encounter'
300 style='background-color:#ffff00;' />
301 </p>
303 </center>
305 </form>
306 <?php
308 // TBD: If $alertmsg, display it with a JavaScript alert().
311 </body>
312 </html>