Highway to PSR2
[openemr.git] / interface / orders / types_ajax.php
blob4544b64b5eaee971162ad8d52e7b2664d44359ce
1 <?php
2 // Copyright (C) 2010-2012 Rod Roark <rod@sunsetsystems.com>
3 //
4 // This program is free software; you can redistribute it and/or
5 // modify it under the terms of the GNU General Public License
6 // as published by the Free Software Foundation; either version 2
7 // of the License, or (at your option) any later version.
9 require_once("../globals.php");
11 $id = formData('id', 'G') + 0;
12 $order = formData('order', 'G') + 0;
13 $labid = formData('labid', 'G') + 0;
15 echo "$('#con$id').html('<table width=\"100%\" cellspacing=\"0\">";
17 // Determine indentation level for this container.
18 for ($level = 0, $parentid = $id; $parentid; ++$level) {
19 $row = sqlQuery("SELECT parent FROM procedure_type WHERE procedure_type_id = '$parentid'");
20 $parentid = $row['parent'] + 0;
23 $res = sqlStatement("SELECT * FROM procedure_type WHERE parent = '$id' " .
24 "ORDER BY seq, name, procedure_type_id");
26 $encount = 0;
28 // Generate a table row for each immediate child.
29 while ($row = sqlFetchArray($res)) {
30 $chid = $row['procedure_type_id'] + 0;
32 // Find out if this child has any children.
33 $trow = sqlQuery("SELECT procedure_type_id FROM procedure_type WHERE parent = '$chid' LIMIT 1");
34 $iscontainer = !empty($trow['procedure_type_id']);
36 $classes = 'col1';
37 if ($iscontainer) {
38 $classes .= ' haskids';
41 echo "<tr>";
42 echo "<td id=\"td$chid\"";
43 echo " onclick=\"toggle($chid)\"";
44 echo " class=\"$classes\">";
45 echo "<span style=\"margin:0 4 0 " . ($level * 9) . "pt\" class=\"plusminus\">";
46 echo $iscontainer ? "+" : '|';
47 echo "</span>";
48 echo htmlspecialchars($row['name'], ENT_QUOTES) . "</td>";
50 echo "<td class=\"col2\">";
51 if (substr($row['procedure_type'], 0, 3) == 'ord') {
52 if ($order && ($labid == 0 || $row['lab_id'] == $labid)) {
53 echo "<input type=\"radio\" name=\"form_order\" value=\"$chid\"";
54 if ($chid == $order) {
55 echo " checked";
58 echo " />";
59 } else {
60 echo xl('Yes');
62 } else {
63 echo '&nbsp;';
66 echo "</td>";
68 echo "<td class=\"col3\">" . htmlspecialchars($row['procedure_code'], ENT_QUOTES) . "</td>";
69 echo "<td class=\"col4\">" . htmlspecialchars($row['description'], ENT_QUOTES) . "</td>";
70 echo "<td class=\"col5\">";
71 echo "<span onclick=\"enode($chid)\" class=\"haskids\">[" . xl('Edit') . "]</span>";
72 echo "<span onclick=\"anode($chid)\" class=\"haskids\"> [" . xl('Add') . "]</span>";
73 echo "</td>";
74 echo "</tr>";
77 echo "</table>');\n";
78 echo "nextOpen();\n";