2 // Copyright (C) 2010-2012 Rod Roark <rod@sunsetsystems.com>
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/acl.inc");
11 require_once("$srcdir/formdata.inc.php");
13 // This script can be run either inside the OpenEMR frameset for order catalog
14 // maintenance, or as a popup window for selecting an item to order. In the
15 // popup case the GET variables 'popup' (a boolean) and 'order' (an optional
16 // item ID to select) will be provided, and maintenance may also be permitted.
18 $popup = empty($_GET['popup']) ?
0 : 1;
19 $order = formData('order', 'G') +
0;
20 $labid = formData('labid', 'G') +
0;
22 // If Save was clicked, set the result, close the window and exit.
24 if ($popup && $_POST['form_save']) {
25 $form_order = formData('form_order') +
0;
26 $ptrow = sqlQuery("SELECT name FROM procedure_type WHERE " .
27 "procedure_type_id = '$form_order'");
28 $name = addslashes($ptrow['name']);
30 <script language
="JavaScript">
31 if (opener
.closed ||
! opener
.set_proc_type
) {
32 alert('<?php xl('The destination form was closed
; I cannot act on your selection
.','e
'); ?>');
35 opener
.set_proc_type(<?php
echo "$form_order, '$name'" ?
>);
37 // This is to generate the "Questions at Order Entry" for the Procedure Order form.
38 // GET parms needed for this are: formid, formseq.
39 if (isset($_GET['formid'])) {
40 require_once("qoe.inc.php");
41 $qoe_init_javascript = '';
42 echo ' opener.set_proc_html("';
43 echo generate_qoe_html($form_order, intval($_GET['formid']), 0, intval($_GET['formseq']));
44 echo '", "' . $qoe_init_javascript . '");' . "\n";
48 window
.close(); // comment out for debugging
60 <title
><?php
xl('Order and Result Types','e'); ?
></title
>
62 <link rel
="stylesheet" href
='<?php echo $css_header ?>' type
='text/css'>
64 <style type
="text/css">
66 font
-family
:sans
-serif
;
69 padding
: 5px
3px
5px
3px
;
78 font
-family
:sans
-serif
;
82 font
-family
:monospace
;
92 background
-color
:#cccccc;
96 background
-color
:#ddddff;
99 background
-color
:#ffffff;
109 <script src
="../../library/js/jquery-1.2.2.min.js" type
="text/javascript"></script
>
110 <?php
if ($popup) { ?
>
111 <script type
="text/javascript" src
="../../library/topdialog.js"></script
>
113 <script type
="text/javascript" src
="../../library/dialog.js"></script
>
115 <script language
="JavaScript">
117 <?php
if ($popup) require($GLOBALS['srcdir'] . "/restoreSession.php"); ?
>
120 // Create array of IDs to pre-select, leaf to top.
122 echo $order > 0 ?
$order : 0;
123 for ($parentid = $order; $parentid > 0;) {
124 $row = sqlQuery("SELECT parent FROM procedure_type WHERE procedure_type_id = '$parentid'");
125 $parentid = $row['parent'] +
0;
131 // initiate by loading the top-level nodes
132 $
(document
).ready(function(){
136 // This is called repeatedly at initialization until all desired nodes
138 function nextOpen() {
139 if (preopen
.length
) {
140 var thisid
= preopen
.pop();
141 if (thisid
== 0 || preopen
.length
> 0) {
145 $
.getScript('types_ajax.php?id=' + thisid +
'&order=<?php echo $order; ?>' +
'&labid=<?php echo $labid; ?>');
156 // toggle expansion indicator from + to - or vice versa
157 function swapsign(td1
, from
, to
) {
159 var i
= s
.indexOf('>' + from +
'<');
160 if (i
>= 0) td1
.html(s
.substring(0,i+
1) + to + s
.substring(i+
2));
163 // onclick handler to expand or collapse a node
164 function toggle(id
) {
165 var td1
= $
('#td' + id
);
166 if (!td1
.hasClass('haskids')) return;
167 if (td1
.hasClass('isExpanded')) {
168 $
('#con' + id
).remove();
169 td1
.removeClass('isExpanded');
170 swapsign(td1
, '-', '+');
174 td1
.parent().after('<tr class="outertr"><td colspan="5" id="con' + id +
'" style="padding:0">Loading...</td></tr>');
175 td1
.addClass('isExpanded');
176 swapsign(td1
, '+', '-');
177 $
.getScript('types_ajax.php?id=' + id +
'&order=<?php echo $order; ?>' +
'&labid=<?php echo $labid; ?>');
181 // Called by the edit window to refresh a given node's children
182 function refreshFamily(id
, haskids
) {
183 if (id
) { // id == 0 means top level
184 var td1
= $
('#td' + id
);
185 if (td1
.hasClass('isExpanded')) {
186 $
('#con' + id
).remove();
187 td1
.removeClass('isExpanded');
188 swapsign(td1
, '-', '+');
190 if (td1
.hasClass('haskids') && !haskids
) {
191 td1
.removeClass('haskids');
192 // swapsign(td1, '+', '.');
193 swapsign(td1
, '+', '|');
196 if (!td1
.hasClass('haskids') && haskids
) {
197 td1
.addClass('haskids');
198 // swapsign(td1, '.', '+');
199 swapsign(td1
, '|', '+');
202 td1
.parent().after('<tr class="outertr"><td colspan="5" id="con' + id +
'" style="padding:0">Loading...</td></tr>');
203 td1
.addClass('isExpanded');
204 swapsign(td1
, '+', '-');
208 $
.getScript('types_ajax.php?id=' + id +
'&order=<?php echo $order; ?>' +
'&labid=<?php echo $labid; ?>');
215 dlgopen('types_edit.php?parent=0&typeid=' + id
, '_blank', 700, 550);
220 dlgopen('types_edit.php?typeid=0&parent=' + id
, '_blank', 700, 550);
223 // call this to alternate row colors when anything changes the number of rows
226 $
('#con0 tr').each(function(index
) {
227 // skip any row that contains other rows
228 if ($
(this
).hasClass('outertr')) return;
229 this
.className
= (i++
& 1) ?
"evenrow" : "oddrow";
237 <body
class="body_nav">
240 <h3 style
='margin-top:0'><?php
xl('Types of Orders and Results','e') ?
></h3
>
242 <form method
='post' name
='theform' action
='types.php?popup=<?php echo $popup ?>&order=<?php
244 if (isset($_GET['formid
' ])) echo '&formid
=' . $_GET['formid
'];
245 if (isset($_GET['formseq
'])) echo '&formseq
=' . $_GET['formseq
'];
248 <table width
='100%' cellspacing
='0' cellpadding
='0' border
='0'>
250 <th
class='col1' align
='left'> 
; 
;<?php
xl('Name','e') ?
></th
>
251 <th
class='col2' align
='left'><?php
xl('Order','e') ?
></th
>
252 <th
class='col3' align
='left'><?php
xl('Code','e') ?
></th
>
253 <th
class='col4' align
='left'><?php
xl('Description','e') ?
></th
>
254 <th
class='col5' align
='left'> 
;</th
>
262 <?php
if ($popup) { ?
>
263 <input type
='submit' name
='form_save' value
='<?php xl('Save
','e
'); ?>' />
265 <input type
='button' value
=<?php
xl('Cancel','e'); ?
> onclick
='window.close()' />
268 <input type
='button' value
='<?php xl('Add Top Level
','e
'); ?>' onclick
='anode(0)' />