2 // Copyright (C) 2010 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;
21 // If Save was clicked, set the result, close the window and exit.
23 if ($popup && $_POST['form_save']) {
24 $form_order = formData('form_order') +
0;
25 $ptrow = sqlQuery("SELECT name FROM procedure_type WHERE " .
26 "procedure_type_id = '$form_order'");
27 $name = addslashes($ptrow['name']);
29 <script language
="JavaScript">
30 if (opener
.closed ||
! opener
.set_proc_type
)
31 alert('<?php xl('The destination form was closed
; I cannot act on your selection
.','e
'); ?>');
33 opener
.set_proc_type(<?php
echo "$form_order, '$name'" ?
>);
46 <title
><?php
xl('Order and Result Types','e'); ?
></title
>
48 <link rel
="stylesheet" href
='<?php echo $css_header ?>' type
='text/css'>
50 <style type
="text/css">
52 font
-family
:sans
-serif
;
55 padding
: 5px
3px
5px
3px
;
64 font
-family
:sans
-serif
;
68 font
-family
:monospace
;
78 background
-color
:#cccccc;
82 background
-color
:#ddddff;
85 background
-color
:#ffffff;
95 <script src
="../../library/js/jquery-1.2.2.min.js" type
="text/javascript"></script
>
96 <?php
if ($popup) { ?
>
97 <script type
="text/javascript" src
="../../library/topdialog.js"></script
>
99 <script type
="text/javascript" src
="../../library/dialog.js"></script
>
101 <script language
="JavaScript">
103 <?php
if ($popup) require($GLOBALS['srcdir'] . "/restoreSession.php"); ?
>
106 // Create array of IDs to pre-select, leaf to top.
108 echo $order > 0 ?
$order : 0;
109 for ($parentid = $order; $parentid > 0;) {
110 $row = sqlQuery("SELECT parent FROM procedure_type WHERE procedure_type_id = '$parentid'");
111 $parentid = $row['parent'] +
0;
117 // initiate by loading the top-level nodes
118 $
(document
).ready(function(){
122 // This is called repeatedly at initialization until all desired nodes
124 function nextOpen() {
125 if (preopen
.length
) {
126 var thisid
= preopen
.pop();
127 if (thisid
== 0 || preopen
.length
> 0) {
131 $
.getScript('types_ajax.php?id=' + thisid +
'&order=<?php echo $order; ?>');
142 // toggle expansion indicator from + to - or vice versa
143 function swapsign(td1
, from
, to
) {
145 var i
= s
.indexOf('>' + from +
'<');
146 if (i
>= 0) td1
.html(s
.substring(0,i+
1) + to + s
.substring(i+
2));
149 // onclick handler to expand or collapse a node
150 function toggle(id
) {
151 var td1
= $
('#td' + id
);
152 if (!td1
.hasClass('haskids')) return;
153 if (td1
.hasClass('isExpanded')) {
154 $
('#con' + id
).remove();
155 td1
.removeClass('isExpanded');
156 swapsign(td1
, '-', '+');
160 td1
.parent().after('<tr class="outertr"><td colspan="5" id="con' + id +
'" style="padding:0">Loading...</td></tr>');
161 td1
.addClass('isExpanded');
162 swapsign(td1
, '+', '-');
163 $
.getScript('types_ajax.php?id=' + id +
'&order=<?php echo $order; ?>');
167 // Called by the edit window to refresh a given node's children
168 function refreshFamily(id
, haskids
) {
169 if (id
) { // id == 0 means top level
170 var td1
= $
('#td' + id
);
171 if (td1
.hasClass('isExpanded')) {
172 $
('#con' + id
).remove();
173 td1
.removeClass('isExpanded');
174 swapsign(td1
, '-', '+');
176 if (td1
.hasClass('haskids') && !haskids
) {
177 td1
.removeClass('haskids');
178 // swapsign(td1, '+', '.');
179 swapsign(td1
, '+', '|');
182 if (!td1
.hasClass('haskids') && haskids
) {
183 td1
.addClass('haskids');
184 // swapsign(td1, '.', '+');
185 swapsign(td1
, '|', '+');
188 td1
.parent().after('<tr class="outertr"><td colspan="5" id="con' + id +
'" style="padding:0">Loading...</td></tr>');
189 td1
.addClass('isExpanded');
190 swapsign(td1
, '+', '-');
194 $
.getScript('types_ajax.php?id=' + id +
'&order=<?php echo $order; ?>');
201 dlgopen('types_edit.php?parent=0&typeid=' + id
, '_blank', 700, 550);
206 dlgopen('types_edit.php?typeid=0&parent=' + id
, '_blank', 700, 550);
209 // call this to alternate row colors when anything changes the number of rows
212 $
('#con0 tr').each(function(index
) {
213 // skip any row that contains other rows
214 if ($
(this
).hasClass('outertr')) return;
215 this
.className
= (i++
& 1) ?
"evenrow" : "oddrow";
223 <body
class="body_nav">
226 <h3 style
='margin-top:0'><?php
xl('Types of Orders and Results','e') ?
></h3
>
228 <form method
='post' name
='theform' action
='types.php?popup=<?php echo $popup ?>&order=<?php echo $order ?>'>
230 <table width
='100%' cellspacing
='0' cellpadding
='0' border
='0'>
232 <th
class='col1' align
='left'> 
; 
;<?php
xl('Name','e') ?
></th
>
233 <th
class='col2' align
='left'><?php
xl('Order','e') ?
></th
>
234 <th
class='col3' align
='left'><?php
xl('Code','e') ?
></th
>
235 <th
class='col4' align
='left'><?php
xl('Description','e') ?
></th
>
236 <th
class='col5' align
='left'> 
;</th
>
244 <?php
if ($popup) { ?
>
245 <input type
='submit' name
='form_save' value
='<?php xl('Save
','e
'); ?>' />
247 <input type
='button' value
=<?php
xl('Cancel','e'); ?
> onclick
='window.close()' />
250 <input type
='button' value
='<?php xl('Add Top Level
','e
'); ?>' onclick
='anode(0)' />