initial support for multiple browser windows
[openemr.git] / contrib / forms / cricket_injury_audit / view.php
blob12d7ac028b1a6c5aa35dca448710fcb56eac15b8
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 <link rel=stylesheet href="<?echo $css_header;?>" type="text/css">
155 <style>
156 .billcell { font-family: sans-serif; font-size: 10pt }
157 </style>
159 <script type="text/javascript" src="../../../library/dialog.js"></script>
161 <script language="JavaScript">
163 // Pop up the coding window.
164 function docoding() {
165 var width = screen.width - 50;
166 if (!isNaN(top.screenX)) {
167 width -= top.screenX;
168 } else if (!isNaN(top.screenLeft)) {
169 width -= top.screenLeft;
171 if (width > 1000) width = 1000;
172 dlgopen('../../patient_file/encounter/coding_popup.php', '_blank', width, 550);
175 </script>
176 </head>
178 <body <?echo $top_bg_line;?> topmargin="0" rightmargin="0" leftmargin="2" bottommargin="0" marginwidth="2" marginheight="0">
179 <form method="post" action="<? echo $rootdir ?>/forms/cricket_injury_audit/new.php?id=<? echo $formid ?>"
180 onsubmit="return top.restoreSession()">
182 <center>
184 <p class='title' style='margin-top:8px;margin-bottom:8px'>Cricket Injury Statistics</p>
186 <table border='1' width='98%'>
188 <tr bgcolor='#dddddd'>
189 <td colspan='2' align='center'><b>Match Information</b></td>
190 </tr>
192 <tr>
193 <td nowrap>County</td>
194 <td nowrap>
195 <table width='100%'>
196 <?php genRadios('county', $arr_county); ?>
197 </table>
198 </td>
199 </tr>
201 <tr>
202 <td nowrap>Team ATI</td>
203 <td nowrap>
204 <table width='100%'>
205 <?php genRadios('team', $arr_team); ?>
206 </table>
207 </td>
208 </tr>
210 <tr>
211 <td nowrap>Match Duration</td>
212 <td nowrap>
213 <table width='100%'>
214 <?php genRadios('duration', $arr_duration); ?>
215 </table>
216 </td>
217 </tr>
219 <tr>
220 <td nowrap>Main Role in Team</td>
221 <td nowrap>
222 <table width='100%'>
223 <?php genRadios('role', $arr_role); ?>
224 </table>
225 </td>
226 </tr>
228 <tr>
229 <td nowrap>Injured In</td>
230 <td nowrap>
231 <table width='100%'>
232 <?php genRadios('matchtype', $arr_matchtype); ?>
233 </table>
234 </td>
235 </tr>
237 <tr bgcolor='#dddddd'>
238 <td colspan='2' align='center'><b>Mechanism of Injury</b></td>
239 </tr>
241 <tr>
242 <td nowrap>Cause</td>
243 <td nowrap>
244 <table width='100%'>
245 <?php genRadios('cause', $arr_cause); ?>
246 </table>
247 </td>
248 </tr>
250 <tr>
251 <td nowrap>Activity ATI</td>
252 <td nowrap>
253 <table width='100%'>
254 <?php genRadios('activity', $arr_activity); ?>
255 </table>
256 </td>
257 </tr>
259 <tr bgcolor='#dddddd'>
260 <td colspan='2' align='center'><b>Conditions</b></td>
261 </tr>
263 <tr>
264 <td nowrap>Batting Side</td>
265 <td nowrap>
266 <table width='100%'>
267 <?php genRadios('batside', $arr_batside); ?>
268 </table>
269 </td>
270 </tr>
272 <tr>
273 <td nowrap>Bowling Side</td>
274 <td nowrap>
275 <table width='100%'>
276 <?php genRadios('bowlside', $arr_bowlside); ?>
277 </table>
278 </td>
279 </tr>
281 <tr>
282 <td nowrap>Bowling Type</td>
283 <td nowrap>
284 <table width='100%'>
285 <?php genRadios('bowltype', $arr_bowltype); ?>
286 </table>
287 </td>
288 </tr>
290 </table>
293 <input type='submit' name='bn_save' value='Save' />
294 &nbsp;
295 <input type='button' value='Cancel' onclick="top.restoreSession();location='<?php echo $GLOBALS['form_exit_url']; ?>'" />
296 &nbsp;
297 <input type='button' value='Add Injury Diagnosis...' onclick='docoding();'
298 title='Add or change coding for this encounter'
299 style='background-color:#ffff00;' />
300 </p>
302 </center>
304 </form>
305 <?php
307 // TBD: If $alertmsg, display it with a JavaScript alert().
310 </body>
311 </html>