Merge branch 'master' of git://github.com/openemr/openemr
[openemr.git] / interface / orders / types_ajax.php
blobc9d3cd97565796246e0bda61f746c6db0cbe39cc
1 <?php
2 // Copyright (C) 2010 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");
10 require_once("$srcdir/formdata.inc.php");
12 $id = formData('id','G') + 0;
13 $order = formData('order','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 $row['name'] . "</td>";
50 echo "<td class=\"col2\">";
51 if (substr($row['procedure_type'], 0, 3) == 'ord') {
52 if ($order) {
53 echo "<input type=\"radio\" name=\"form_order\" value=\"$chid\"";
54 if ($chid == $order) echo " checked";
55 echo " />";
57 else {
58 echo xl('Yes');
61 else {
62 echo '&nbsp;';
64 echo "</td>";
66 echo "<td class=\"col3\">" . $row['procedure_code'] . "</td>";
67 echo "<td class=\"col4\">" . $row['description'] . "</td>";
68 echo "<td class=\"col5\">";
69 echo "<span onclick=\"enode($chid)\" class=\"haskids\">[" . xl('Edit') . "]</span>";
70 echo "<span onclick=\"anode($chid)\" class=\"haskids\"> [" . xl('Add') . "]</span>";
71 echo "</td>";
72 echo "</tr>";
75 echo "</table>');\n"; // end of html argument
77 echo "nextOpen();\n";