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.
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
'); ?>');
37 opener
.set_proc_type(<?php
echo "$form_order, '$name'" ?
>);
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
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">
68 font
-family
:sans
-serif
;
71 padding
: 5px
3px
5px
3px
;
80 font
-family
:sans
-serif
;
84 font
-family
:monospace
;
94 background
-color
:#cccccc;
98 background
-color
:#ddddff;
101 background
-color
:#ffffff;
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
>
115 <script type
="text/javascript" src
="../../library/dialog.js"></script
>
117 <script language
="JavaScript">
119 <?php
if ($popup) require($GLOBALS['srcdir'] . "/restoreSession.php"); ?
>
122 // Create array of IDs to pre-select, leaf to top.
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;
133 // initiate by loading the top-level nodes
134 $
(document
).ready(function(){
138 // This is called repeatedly at initialization until all desired nodes
140 function nextOpen() {
141 if (preopen
.length
) {
142 var thisid
= preopen
.pop();
143 if (thisid
== 0 || preopen
.length
> 0) {
147 $
.getScript('types_ajax.php?id=' + thisid +
'&order=<?php echo $order; ?>' +
'&labid=<?php echo $labid; ?>');
158 // toggle expansion indicator from + to - or vice versa
159 function swapsign(td1
, from
, to
) {
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
, '-', '+');
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
, '+', '|');
198 if (!td1
.hasClass('haskids') && haskids
) {
199 td1
.addClass('haskids');
200 // swapsign(td1, '.', '+');
201 swapsign(td1
, '|', '+');
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
, '+', '-');
210 $
.getScript('types_ajax.php?id=' + id +
'&order=<?php echo $order; ?>' +
'&labid=<?php echo $labid; ?>');
217 dlgopen('types_edit.php?parent=0&typeid=' + id
, '_blank', 700, 550);
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
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";
239 <body
class="body_nav">
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
246 if (isset($_GET['formid
' ])) echo '&formid
=' . $_GET['formid
'];
247 if (isset($_GET['formseq
'])) echo '&formseq
=' . $_GET['formseq
'];
250 <table width
='100%' cellspacing
='0' cellpadding
='0' border
='0'>
252 <th
class='col1' align
='left'> 
; 
;<?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'> 
;</th
>
264 <?php
if ($popup) { ?
>
265 <input type
='submit' name
='form_save' value
='<?php xl('Save
','e
'); ?>' />
267 <input type
='button' value
=<?php
xl('Cancel','e'); ?
> onclick
='window.close()' />
270 <input type
='button' value
='<?php xl('Add Top Level
','e
'); ?>' onclick
='anode(0)' />