Change formatting of initial comment block.
[openemr.git] / interface / orders / types.php
blob7c6f00398406baf84c44854784e6895cb1722d14
1 <?php
2 /**
3 * Copyright (C) 2010-2012 Rod Roark <rod@sunsetsystems.com>
5 * This program is free software; you can redistribute it and/or
6 * modify it under the terms of the GNU General Public License
7 * as published by the Free Software Foundation; either version 2
8 * of the License, or (at your option) any later version.
9 */
11 require_once("../globals.php");
12 require_once("$srcdir/acl.inc");
13 require_once("$srcdir/formdata.inc.php");
15 // This script can be run either inside the OpenEMR frameset for order catalog
16 // maintenance, or as a popup window for selecting an item to order. In the
17 // popup case the GET variables 'popup' (a boolean) and 'order' (an optional
18 // item ID to select) will be provided, and maintenance may also be permitted.
20 $popup = empty($_GET['popup']) ? 0 : 1;
21 $order = formData('order', 'G') + 0;
22 $labid = formData('labid', 'G') + 0;
24 // If Save was clicked, set the result, close the window and exit.
26 if ($popup && $_POST['form_save']) {
27 $form_order = formData('form_order') + 0;
28 $ptrow = sqlQuery("SELECT name FROM procedure_type WHERE " .
29 "procedure_type_id = '$form_order'");
30 $name = addslashes($ptrow['name']);
32 <script language="JavaScript">
33 if (opener.closed || ! opener.set_proc_type) {
34 alert('<?php xl('The destination form was closed; I cannot act on your selection.','e'); ?>');
36 else {
37 opener.set_proc_type(<?php echo "$form_order, '$name'" ?>);
38 <?php
39 // This is to generate the "Questions at Order Entry" for the Procedure Order form.
40 // GET parms needed for this are: formid, formseq.
41 if (isset($_GET['formid'])) {
42 require_once("qoe.inc.php");
43 $qoe_init_javascript = '';
44 echo ' opener.set_proc_html("';
45 echo generate_qoe_html($form_order, intval($_GET['formid']), 0, intval($_GET['formseq']));
46 echo '", "' . $qoe_init_javascript . '");' . "\n";
50 window.close(); // comment out for debugging
51 </script>
52 <?php
53 exit();
55 // end Save logic
58 <html>
60 <head>
62 <title><?php xl('Order and Result Types','e'); ?></title>
64 <link rel="stylesheet" href='<?php echo $css_header ?>' type='text/css'>
66 <style type="text/css">
67 body {
68 font-family:sans-serif;
69 font-size:9pt;
70 font-weight:normal;
71 padding: 5px 3px 5px 3px;
73 #con0 table {
74 margin:0;
75 padding:0;
76 width:100%;
78 #con0 td {
79 padding:0pt;
80 font-family:sans-serif;
81 font-size:9pt;
83 .plusminus {
84 font-family:monospace;
85 font-size:10pt;
87 .haskids {
88 color:#0000dd;
89 cursor:pointer;
90 cursor:hand;
92 tr.head {
93 font-size:10pt;
94 background-color:#cccccc;
95 font-weight:bold;
97 tr.evenrow {
98 background-color:#ddddff;
100 tr.oddrow {
101 background-color:#ffffff;
104 .col1 {width:35%}
105 .col2 {width:8%}
106 .col3 {width:12%}
107 .col4 {width:35%}
108 .col5 {width:10%}
109 </style>
111 <script src="../../library/js/jquery-1.2.2.min.js" type="text/javascript"></script>
112 <?php if ($popup) { ?>
113 <script type="text/javascript" src="../../library/topdialog.js"></script>
114 <?php } ?>
115 <script type="text/javascript" src="../../library/dialog.js"></script>
117 <script language="JavaScript">
119 <?php if ($popup) require($GLOBALS['srcdir'] . "/restoreSession.php"); ?>
121 <?php
122 // Create array of IDs to pre-select, leaf to top.
123 echo "preopen = [";
124 echo $order > 0 ? $order : 0;
125 for ($parentid = $order; $parentid > 0;) {
126 $row = sqlQuery("SELECT parent FROM procedure_type WHERE procedure_type_id = '$parentid'");
127 $parentid = $row['parent'] + 0;
128 echo ", $parentid";
130 echo "];\n";
133 // initiate by loading the top-level nodes
134 $(document).ready(function(){
135 nextOpen();
138 // This is called repeatedly at initialization until all desired nodes
139 // have been opened.
140 function nextOpen() {
141 if (preopen.length) {
142 var thisid = preopen.pop();
143 if (thisid == 0 || preopen.length > 0) {
144 if (thisid > 0)
145 toggle(thisid);
146 else
147 $.getScript('types_ajax.php?id=' + thisid + '&order=<?php echo $order; ?>' + '&labid=<?php echo $labid; ?>');
149 else {
150 recolor();
153 else {
154 recolor();
158 // toggle expansion indicator from + to - or vice versa
159 function swapsign(td1, from, to) {
160 var s = td1.html();
161 var i = s.indexOf('>' + from + '<');
162 if (i >= 0) td1.html(s.substring(0,i+1) + to + s.substring(i+2));
165 // onclick handler to expand or collapse a node
166 function toggle(id) {
167 var td1 = $('#td' + id);
168 if (!td1.hasClass('haskids')) return;
169 if (td1.hasClass('isExpanded')) {
170 $('#con' + id).remove();
171 td1.removeClass('isExpanded');
172 swapsign(td1, '-', '+');
173 recolor();
175 else {
176 td1.parent().after('<tr class="outertr"><td colspan="5" id="con' + id + '" style="padding:0">Loading...</td></tr>');
177 td1.addClass('isExpanded');
178 swapsign(td1, '+', '-');
179 $.getScript('types_ajax.php?id=' + id + '&order=<?php echo $order; ?>' + '&labid=<?php echo $labid; ?>');
183 // Called by the edit window to refresh a given node's children
184 function refreshFamily(id, haskids) {
185 if (id) { // id == 0 means top level
186 var td1 = $('#td' + id);
187 if (td1.hasClass('isExpanded')) {
188 $('#con' + id).remove();
189 td1.removeClass('isExpanded');
190 swapsign(td1, '-', '+');
192 if (td1.hasClass('haskids') && !haskids) {
193 td1.removeClass('haskids');
194 // swapsign(td1, '+', '.');
195 swapsign(td1, '+', '|');
196 return;
198 if (!td1.hasClass('haskids') && haskids) {
199 td1.addClass('haskids');
200 // swapsign(td1, '.', '+');
201 swapsign(td1, '|', '+');
203 if (haskids) {
204 td1.parent().after('<tr class="outertr"><td colspan="5" id="con' + id + '" style="padding:0">Loading...</td></tr>');
205 td1.addClass('isExpanded');
206 swapsign(td1, '+', '-');
209 if (haskids)
210 $.getScript('types_ajax.php?id=' + id + '&order=<?php echo $order; ?>' + '&labid=<?php echo $labid; ?>');
211 else
212 recolor();
215 // edit a node
216 function enode(id) {
217 dlgopen('types_edit.php?parent=0&typeid=' + id, '_blank', 700, 550);
220 // add a node
221 function anode(id) {
222 dlgopen('types_edit.php?typeid=0&parent=' + id, '_blank', 700, 550);
225 // call this to alternate row colors when anything changes the number of rows
226 function recolor() {
227 var i = 0;
228 $('#con0 tr').each(function(index) {
229 // skip any row that contains other rows
230 if ($(this).hasClass('outertr')) return;
231 this.className = (i++ & 1) ? "evenrow" : "oddrow";
235 </script>
237 </head>
239 <body class="body_nav">
240 <center>
242 <h3 style='margin-top:0'><?php xl('Types of Orders and Results','e') ?></h3>
244 <form method='post' name='theform' action='types.php?popup=<?php echo $popup ?>&order=<?php
245 echo $order;
246 if (isset($_GET['formid' ])) echo '&formid=' . $_GET['formid'];
247 if (isset($_GET['formseq'])) echo '&formseq=' . $_GET['formseq'];
248 ?>'>
250 <table width='100%' cellspacing='0' cellpadding='0' border='0'>
251 <tr class='head'>
252 <th class='col1' align='left'>&nbsp;&nbsp;<?php xl('Name','e') ?></th>
253 <th class='col2' align='left'><?php xl('Order','e') ?></th>
254 <th class='col3' align='left'><?php xl('Code','e') ?></th>
255 <th class='col4' align='left'><?php xl('Description','e') ?></th>
256 <th class='col5' align='left'>&nbsp;</th>
257 </tr>
258 </table>
260 <div id="con0">
261 </div>
264 <?php if ($popup) { ?>
265 <input type='submit' name='form_save' value='<?php xl('Save','e'); ?>' />
266 &nbsp;
267 <input type='button' value=<?php xl('Cancel','e'); ?> onclick='window.close()' />
268 &nbsp;
269 <?php } ?>
270 <input type='button' value='<?php xl('Add Top Level','e'); ?>' onclick='anode(0)' />
271 </p>
273 </form>
275 </center>
277 </body>
278 </html>