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 type
="text/javascript" src
="<?php echo $webroot ?>/interface/main/tabs/js/include_opener.js"></script
>
33 <script language
="JavaScript">
34 if (opener
.closed ||
! opener
.set_proc_type
) {
35 alert('<?php xl('The destination form was closed
; I cannot act on your selection
.','e
'); ?>');
38 opener
.set_proc_type(<?php
echo "$form_order, '$name'" ?
>);
40 // This is to generate the "Questions at Order Entry" for the Procedure Order form.
41 // GET parms needed for this are: formid, formseq.
42 if (isset($_GET['formid'])) {
43 require_once("qoe.inc.php");
44 $qoe_init_javascript = '';
45 echo ' opener.set_proc_html("';
46 echo generate_qoe_html($form_order, intval($_GET['formid']), 0, intval($_GET['formseq']));
47 echo '", "' . $qoe_init_javascript . '");' . "\n";
51 window
.close(); // comment out for debugging
63 <title
><?php
xl('Order and Result Types','e'); ?
></title
>
65 <link rel
="stylesheet" href
='<?php echo $css_header ?>' type
='text/css'>
67 <style type
="text/css">
69 font
-family
:sans
-serif
;
72 padding
: 5px
3px
5px
3px
;
81 font
-family
:sans
-serif
;
85 font
-family
:monospace
;
95 background
-color
:#cccccc;
99 background
-color
:#ddddff;
102 background
-color
:#ffffff;
112 <script src
="<?php echo $GLOBALS['assets_static_relative']; ?>/jquery-min-1-2-2/index.js" type
="text/javascript"></script
>
113 <?php
if ($popup) { ?
>
114 <script type
="text/javascript" src
="../../library/topdialog.js"></script
>
116 <script type
="text/javascript" src
="../../library/dialog.js"></script
>
118 <script language
="JavaScript">
120 <?php
if ($popup) require($GLOBALS['srcdir'] . "/restoreSession.php"); ?
>
123 // Create array of IDs to pre-select, leaf to top.
125 echo $order > 0 ?
$order : 0;
126 for ($parentid = $order; $parentid > 0;) {
127 $row = sqlQuery("SELECT parent FROM procedure_type WHERE procedure_type_id = '$parentid'");
128 $parentid = $row['parent'] +
0;
134 // initiate by loading the top-level nodes
135 $
(document
).ready(function(){
139 // This is called repeatedly at initialization until all desired nodes
141 function nextOpen() {
142 if (preopen
.length
) {
143 var thisid
= preopen
.pop();
144 if (thisid
== 0 || preopen
.length
> 0) {
148 $
.getScript('types_ajax.php?id=' + thisid +
'&order=<?php echo $order; ?>' +
'&labid=<?php echo $labid; ?>');
159 // toggle expansion indicator from + to - or vice versa
160 function swapsign(td1
, from
, to
) {
162 var i
= s
.indexOf('>' + from +
'<');
163 if (i
>= 0) td1
.html(s
.substring(0,i+
1) + to + s
.substring(i+
2));
166 // onclick handler to expand or collapse a node
167 function toggle(id
) {
168 var td1
= $
('#td' + id
);
169 if (!td1
.hasClass('haskids')) return;
170 if (td1
.hasClass('isExpanded')) {
171 $
('#con' + id
).remove();
172 td1
.removeClass('isExpanded');
173 swapsign(td1
, '-', '+');
177 td1
.parent().after('<tr class="outertr"><td colspan="5" id="con' + id +
'" style="padding:0">Loading...</td></tr>');
178 td1
.addClass('isExpanded');
179 swapsign(td1
, '+', '-');
180 $
.getScript('types_ajax.php?id=' + id +
'&order=<?php echo $order; ?>' +
'&labid=<?php echo $labid; ?>');
184 // Called by the edit window to refresh a given node's children
185 function refreshFamily(id
, haskids
) {
186 if (id
) { // id == 0 means top level
187 var td1
= $
('#td' + id
);
188 if (td1
.hasClass('isExpanded')) {
189 $
('#con' + id
).remove();
190 td1
.removeClass('isExpanded');
191 swapsign(td1
, '-', '+');
193 if (td1
.hasClass('haskids') && !haskids
) {
194 td1
.removeClass('haskids');
195 // swapsign(td1, '+', '.');
196 swapsign(td1
, '+', '|');
199 if (!td1
.hasClass('haskids') && haskids
) {
200 td1
.addClass('haskids');
201 // swapsign(td1, '.', '+');
202 swapsign(td1
, '|', '+');
205 td1
.parent().after('<tr class="outertr"><td colspan="5" id="con' + id +
'" style="padding:0">Loading...</td></tr>');
206 td1
.addClass('isExpanded');
207 swapsign(td1
, '+', '-');
211 $
.getScript('types_ajax.php?id=' + id +
'&order=<?php echo $order; ?>' +
'&labid=<?php echo $labid; ?>');
218 dlgopen('types_edit.php?parent=0&typeid=' + id
, '_blank', 700, 550);
223 dlgopen('types_edit.php?typeid=0&parent=' + id
, '_blank', 700, 550);
226 // call this to alternate row colors when anything changes the number of rows
229 $
('#con0 tr').each(function(index
) {
230 // skip any row that contains other rows
231 if ($
(this
).hasClass('outertr')) return;
232 this
.className
= (i++
& 1) ?
"evenrow" : "oddrow";
240 <body
class="body_nav">
243 <h3 style
='margin-top:0'><?php
xl('Types of Orders and Results','e') ?
></h3
>
245 <form method
='post' name
='theform' action
='types.php?popup=<?php echo $popup ?>&order=<?php
247 if (isset($_GET['formid
' ])) echo '&formid
=' . $_GET['formid
'];
248 if (isset($_GET['formseq
'])) echo '&formseq
=' . $_GET['formseq
'];
251 <table width
='100%' cellspacing
='0' cellpadding
='0' border
='0'>
253 <th
class='col1' align
='left'> 
; 
;<?php
xl('Name','e') ?
></th
>
254 <th
class='col2' align
='left'><?php
xl('Order','e') ?
></th
>
255 <th
class='col3' align
='left'><?php
xl('Code','e') ?
></th
>
256 <th
class='col4' align
='left'><?php
xl('Description','e') ?
></th
>
257 <th
class='col5' align
='left'> 
;</th
>
265 <?php
if ($popup) { ?
>
266 <input type
='submit' name
='form_save' value
='<?php xl('Save
','e
'); ?>' />
268 <input type
='button' value
=<?php
xl('Cancel','e'); ?
> onclick
='window.close()' />
271 <input type
='button' value
='<?php xl('Add Top Level
','e
'); ?>' onclick
='anode(0)' />