move jquery-1.2.2.min.js to assets
[openemr.git] / interface / super / field_id_popup.php
blobe11940a9faf23aecd9d7b657c4be77b379117013
1 <?php
2 /**
3 * This popup is called when choosing a foreign field ID for a form layout.
5 * Copyright (C) 2014 Rod Roark <rod@sunsetsystems.com>
7 * LICENSE: This program is free software; you can redistribute it and/or
8 * modify it under the terms of the GNU General Public License
9 * as published by the Free Software Foundation; either version 2
10 * of the License, or (at your option) any later version.
11 * This program is distributed in the hope that it will be useful,
12 * but WITHOUT ANY WARRANTY; without even the implied warranty of
13 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14 * GNU General Public License for more details.
15 * You should have received a copy of the GNU General Public License
16 * along with this program. If not, see <http://opensource.org/licenses/gpl-license.php>.
18 * @package OpenEMR
19 * @author Rod Roark <rod@sunsetsystems.com>
20 * @link http://www.open-emr.org
23 $sanitize_all_escapes = true;
24 $fake_register_globals = false;
26 include_once("../globals.php");
28 $form_encounter_layout = array(
29 array('field_id' => 'date',
30 'title' => xl('Visit Date'),
31 'uor' => '1',
32 'data_type' => '4', // Text-date
33 'list_id' => '',
34 'edit_options' => '',
36 array('field_id' => 'facility_id',
37 'title' => xl('Service Facility'),
38 'uor' => '1',
39 'data_type' => '35', // Facilities
40 'list_id' => '',
41 'edit_options' => '',
43 array('field_id' => 'pc_catid',
44 'title' => xl('Visit Category'),
45 'uor' => '1',
46 'data_type' => '18', // Visit Category
47 'list_id' => '',
48 'edit_options' => '',
50 array('field_id' => 'reason',
51 'title' => xl('Reason for Visit'),
52 'uor' => '1',
53 'data_type' => '2', // Text
54 'list_id' => '',
55 'edit_options' => '',
57 array('field_id' => 'onset_date',
58 'title' => xl('Date of Onset'),
59 'uor' => '1',
60 'data_type' => '4', // Text-date
61 'list_id' => '',
62 'edit_options' => '',
64 array('field_id' => 'referral_source',
65 'title' => xl('Referral Source'),
66 'uor' => '1',
67 'data_type' => '1', // List
68 'list_id' => 'refsource',
69 'edit_options' => '',
71 array('field_id' => 'shift',
72 'title' => xl('Shift'),
73 'uor' => '1',
74 'data_type' => '1', // List
75 'list_id' => 'shift',
76 'edit_options' => '',
78 array('field_id' => 'billing_facility',
79 'title' => xl('Billing Facility'),
80 'uor' => '1',
81 'data_type' => '35', // Facilities
82 'list_id' => '',
83 'edit_options' => '',
85 array('field_id' => 'voucher_number',
86 'title' => xl('Voucher Number'),
87 'uor' => '1',
88 'data_type' => '2', // Text
89 'list_id' => '',
90 'edit_options' => '',
94 $source = empty($_REQUEST['source']) ? 'D' : $_REQUEST['source'];
96 function gsr_fixup(&$row, $fldid, $default='') {
97 if (isset($row[$fldid])) {
98 return addslashes($row[$fldid]);
100 return $default;
103 function gen_sel_row($row) {
104 echo " <tr class='oneresult' onclick='selectField(";
105 echo '"' . gsr_fixup($row, 'field_id' ) . '",';
106 echo '"' . gsr_fixup($row, 'title' ) . '",';
107 echo '"' . gsr_fixup($row, 'data_type' ) . '",';
108 echo '"' . gsr_fixup($row, 'uor' ) . '",';
109 echo '"' . gsr_fixup($row, 'fld_length', 20) . '",';
110 echo '"' . gsr_fixup($row, 'max_length', 0) . '",';
111 echo '"' . gsr_fixup($row, 'list_id' ) . '",';
112 echo '"' . gsr_fixup($row, 'titlecols' , 1) . '",';
113 echo '"' . gsr_fixup($row, 'datacols' , 3) . '",';
114 echo '"' . gsr_fixup($row, 'edit_options' ) . '",';
115 echo '"' . gsr_fixup($row, 'description' ) . '",';
116 echo '"' . gsr_fixup($row, 'fld_rows' , 0) . '"';
117 echo ")'>";
118 echo "<td>" . text($row['field_id']) . "</td>";
119 echo "<td>" . text($row['title' ]) . "</td>";
120 echo "</tr>\n";
123 <html>
124 <head>
125 <?php html_header_show(); ?>
126 <title><?php echo xlt('List layout items'); ?></title>
127 <link rel="stylesheet" href='<?php echo $css_header ?>' type='text/css'>
129 <script type="text/javascript" src="<?php echo $GLOBALS['assets_static_relative']; ?>/jquery-min-1-2-2/index.js"></script>
131 <script language="javascript">
133 function selectField(field_id, title, data_type, uor, fld_length, max_length,
134 list_id, titlecols, datacols, edit_options, description, fld_rows)
136 if (opener.closed || ! opener.SetField) {
137 alert('<?php echo xls('The destination form was closed; I cannot act on your selection.'); ?>');
139 else {
140 opener.SetField(field_id, title, data_type, uor, fld_length, max_length,
141 list_id, titlecols, datacols, edit_options, description, fld_rows);
143 window.close();
144 return false;
147 function newField() {
148 return selectField(document.forms[0].new_field_id.value, '', 2, 1, 10, 255,
149 '', 1, 3, '', '', 0);
152 $(document).ready(function(){
154 $('.oneresult').mouseover(function() { $(this).toggleClass('highlight'); });
155 $('.oneresult').mouseout(function() { $(this).toggleClass('highlight'); });
157 // $('.oneresult').click(function() { SelectField(this); });
158 // var SelectField = function(obj) {
159 // return setAFieldID($(obj).attr('id'));
160 // };
164 </script>
166 <style>
167 h1 {
168 font-size: 120%;
169 padding: 3px;
170 margin: 3px;
172 ul {
173 list-style: none;
174 padding: 3px;
175 margin: 3px;
177 li {
178 cursor: pointer;
179 border-bottom: 1px solid #ccc;
180 background-color: white;
182 .highlight {
183 background-color: #336699;
184 color: white;
186 </style>
188 </head>
190 <body class="body_top text">
191 <div id="lists">
193 <h1>
194 <?php
195 // F should never happen, but just in case.
196 if ($source == 'F') echo xlt('Fields in This Form' ); else
197 if ($source == 'D') echo xlt('Demographics Fields' ); else
198 if ($source == 'H') echo xlt('History Fields' ); else
199 if ($source == 'E') echo xlt('Visit Attributes' ); else
200 if ($source == 'V') echo xlt('Visit Form Attributes');
202 </h1>
204 <?php
205 echo "<table>\n";
206 if ($source == 'V') {
207 foreach ($form_encounter_layout as $lrow) {
208 gen_sel_row($lrow);
211 else {
212 if ($source == 'D' || $source == 'H') {
213 $res = sqlStatement("SELECT * FROM layout_options " .
214 "WHERE form_id = ? AND uor > 0 ORDER BY field_id",
215 array($source == 'D' ? 'DEM' : 'HIS'));
217 else {
218 $res = sqlStatement("SELECT * FROM layout_options WHERE " .
219 "form_id LIKE ? AND uor > 0 AND source = ? ORDER BY field_id, form_id",
220 array('LBF%', 'E'));
222 $last_field_id = '';
223 while ($row = sqlFetchArray($res)) {
224 if ($row['field_id'] === $last_field_id) continue;
225 $last_field_id = $row['field_id'];
226 gen_sel_row($row);
229 echo "</table>\n";
232 <?php if ($source == 'E') { ?>
234 <form>
235 <center>
236 <input type='text' name='new_field_id' size='20' />&nbsp;
237 <input type='button' value='<?php echo xla('Or create this new field ID') ?>' onclick='newField()' />
238 </center>
239 </form>
240 </p>
241 <?php } ?>
243 </div>
244 </body>
245 </html>