removed call time *pass by reference* and made sure pass by reference specified in...
[openemr.git] / interface / super / edit_list.php
blob25a9ee07856a5851411469ed02bbde7bd6b78d0a
1 <?php
2 // Copyright (C) 2007-2011 Rod Roark <rod@sunsetsystems.com>
3 //
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");
12 require_once("../../custom/code_types.inc.php");
14 $list_id = empty($_REQUEST['list_id']) ? 'language' : $_REQUEST['list_id'];
16 // Check authorization.
17 $thisauth = acl_check('admin', 'super');
18 if (!$thisauth) die(xl('Not authorized'));
20 // If we are saving, then save.
22 if ($_POST['formaction']=='save' && $list_id) {
23 $opt = $_POST['opt'];
24 if ($list_id == 'feesheet') {
25 // special case for the feesheet list
26 sqlStatement("DELETE FROM fee_sheet_options");
27 for ($lino = 1; isset($opt["$lino"]['category']); ++$lino) {
28 $iter = $opt["$lino"];
29 $category = formTrim($iter['category']);
30 $option = formTrim($iter['option']);
31 $codes = formTrim($iter['codes']);
32 if (strlen($category) > 0 && strlen($option) > 0) {
33 sqlInsert("INSERT INTO fee_sheet_options ( " .
34 "fs_category, fs_option, fs_codes " .
35 ") VALUES ( " .
36 "'$category', " .
37 "'$option', " .
38 "'$codes' " .
39 ")");
43 else if ($list_id == 'code_types') {
44 // special case for code types
45 sqlStatement("DELETE FROM code_types");
46 for ($lino = 1; isset($opt["$lino"]['ct_key']); ++$lino) {
47 $iter = $opt["$lino"];
48 $ct_key = formTrim($iter['ct_key']);
49 $ct_id = formTrim($iter['ct_id']) + 0;
50 $ct_seq = formTrim($iter['ct_seq']) + 0;
51 $ct_mod = formTrim($iter['ct_mod']) + 0;
52 $ct_just = formTrim($iter['ct_just']);
53 $ct_mask = formTrim($iter['ct_mask']);
54 $ct_fee = empty($iter['ct_fee' ]) ? 0 : 1;
55 $ct_rel = empty($iter['ct_rel' ]) ? 0 : 1;
56 $ct_nofs = empty($iter['ct_nofs']) ? 0 : 1;
57 $ct_diag = empty($iter['ct_diag']) ? 0 : 1;
58 $ct_active = empty($iter['ct_active' ]) ? 0 : 1;
59 $ct_label = formTrim($iter['ct_label']);
60 $ct_external = formTrim($iter['ct_external']) + 0;
61 if (strlen($ct_key) > 0 && $ct_id > 0) {
62 sqlInsert("INSERT INTO code_types ( " .
63 "ct_key, ct_id, ct_seq, ct_mod, ct_just, ct_mask, ct_fee, ct_rel, ct_nofs, ct_diag, ct_active, ct_label, ct_external " .
64 ") VALUES ( " .
65 "'$ct_key' , " .
66 "'$ct_id' , " .
67 "'$ct_seq' , " .
68 "'$ct_mod' , " .
69 "'$ct_just', " .
70 "'$ct_mask', " .
71 "'$ct_fee' , " .
72 "'$ct_rel' , " .
73 "'$ct_nofs', " .
74 "'$ct_diag', " .
75 "'$ct_active', " .
76 "'$ct_label', " .
77 "'$ct_external' " .
78 ")");
82 else {
83 // all other lists
85 // erase lists options and recreate them from the submitted form data
86 sqlStatement("DELETE FROM list_options WHERE list_id = '$list_id'");
87 for ($lino = 1; isset($opt["$lino"]['id']); ++$lino) {
88 $iter = $opt["$lino"];
89 $value = empty($iter['value']) ? 0 : (formTrim($iter['value']) + 0);
90 $id = formTrim($iter['id']);
91 if (strlen($id) > 0) {
93 // Special processing for the immunizations list
94 // Map the entered cvx codes into the immunizations table cvx_code
95 sqlStatement ("UPDATE `immunizations` " .
96 "SET `cvx_code`='".$value."' " .
97 "WHERE `immunization_id`='".$id."'");
99 // Force List Based Form names to start with LBF.
100 if ($list_id == 'lbfnames' && substr($id,0,3) != 'LBF')
101 $id = "LBF$id";
102 sqlInsert("INSERT INTO list_options ( " .
103 "list_id, option_id, title, seq, is_default, option_value, mapping, notes " .
104 ") VALUES ( " .
105 "'$list_id', " .
106 "'" . $id . "', " .
107 "'" . formTrim($iter['title']) . "', " .
108 "'" . formTrim($iter['seq']) . "', " .
109 "'" . formTrim($iter['default']) . "', " .
110 "'" . $value . "', " .
111 "'" . formTrim($iter['mapping']) . "', " .
112 "'" . formTrim($iter['notes']) . "' " .
113 ")");
118 else if ($_POST['formaction']=='addlist') {
119 // make a new list ID from the new list name
120 $newlistID = $_POST['newlistname'];
121 $newlistID = preg_replace("/\W/", "_", $newlistID);
123 // determine the position of this new list
124 $row = sqlQuery("SELECT max(seq) as maxseq FROM list_options WHERE list_id= 'lists'");
126 // add the new list to the list-of-lists
127 sqlInsert("INSERT INTO list_options ( " .
128 "list_id, option_id, title, seq, is_default, option_value " .
129 ") VALUES ( " .
130 "'lists',". // the master list-of-lists
131 "'".$newlistID."',".
132 "'".$_POST['newlistname']."', ".
133 "'".($row['maxseq']+1)."',".
134 "'1', '0')"
137 else if ($_POST['formaction']=='deletelist') {
138 // delete the lists options
139 sqlStatement("DELETE FROM list_options WHERE list_id = '".$_POST['list_id']."'");
140 // delete the list from the master list-of-lists
141 sqlStatement("DELETE FROM list_options WHERE list_id = 'lists' and option_id='".$_POST['list_id']."'");
144 $opt_line_no = 0;
146 // Given a string of multiple instances of code_type|code|selector,
147 // make a description for each.
148 function getCodeDescriptions($codes) {
149 global $code_types;
150 $arrcodes = explode('~', $codes);
151 $s = '';
152 foreach ($arrcodes as $codestring) {
153 if ($codestring === '') continue;
154 $arrcode = explode('|', $codestring);
155 $code_type = $arrcode[0];
156 $code = $arrcode[1];
157 $selector = $arrcode[2];
158 $desc = '';
159 if ($code_type == 'PROD') {
160 $row = sqlQuery("SELECT name FROM drugs WHERE drug_id = '$code' ");
161 $desc = "$code:$selector " . $row['name'];
163 else {
164 $row = sqlQuery("SELECT code_text FROM codes WHERE " .
165 "code_type = '" . $code_types[$code_type]['id'] . "' AND " .
166 "code = '$code' ORDER BY modifier LIMIT 1");
167 $desc = "$code_type:$code " . ucfirst(strtolower($row['code_text']));
169 $desc = str_replace('~', ' ', $desc);
170 if ($s) $s .= '~';
171 $s .= $desc;
173 return $s;
176 // Write one option line to the form.
178 function writeOptionLine($option_id, $title, $seq, $default, $value, $mapping='', $notes='') {
179 global $opt_line_no, $list_id;
180 ++$opt_line_no;
181 $bgcolor = "#" . (($opt_line_no & 1) ? "ddddff" : "ffdddd");
182 $checked = $default ? " checked" : "";
184 echo " <tr bgcolor='$bgcolor'>\n";
186 echo " <td align='center' class='optcell'>";
187 echo "<input type='text' name='opt[$opt_line_no][id]' value='" .
188 htmlspecialchars($option_id, ENT_QUOTES) . "' size='12' maxlength='63' class='optin' />";
189 echo "</td>\n";
191 echo " <td align='center' class='optcell'>";
192 echo "<input type='text' name='opt[$opt_line_no][title]' value='" .
193 htmlspecialchars($title, ENT_QUOTES) . "' size='20' maxlength='63' class='optin' />";
194 echo "</td>\n";
196 // if not english and translating lists then show the translation
197 if ($GLOBALS['translate_lists'] && $_SESSION['language_choice'] > 1) {
198 echo " <td align='center' class='translation'>" . (htmlspecialchars( xl($title), ENT_QUOTES)) . "</td>\n";
201 echo " <td align='center' class='optcell'>";
202 echo "<input type='text' name='opt[$opt_line_no][seq]' value='" .
203 htmlspecialchars($seq, ENT_QUOTES) . "' size='4' maxlength='10' class='optin' />";
204 echo "</td>\n";
206 echo " <td align='center' class='optcell'>";
207 echo "<input type='checkbox' name='opt[$opt_line_no][default]' value='1' " .
208 "onclick='defClicked($opt_line_no)' class='optin'$checked />";
209 echo "</td>\n";
211 // Tax rates, contraceptive methods and LBF names have an additional attribute.
213 if ($list_id == 'taxrate' || $list_id == 'contrameth' || $list_id == 'lbfnames') {
214 echo " <td align='center' class='optcell'>";
215 echo "<input type='text' name='opt[$opt_line_no][value]' value='" .
216 htmlspecialchars($value, ENT_QUOTES) . "' size='8' maxlength='15' class='optin' />";
217 echo "</td>\n";
220 // Adjustment reasons use option_value as a reason category. This is
221 // needed to distinguish between adjustments that change the invoice
222 // balance and those that just shift responsibility of payment or
223 // are used as comments.
225 else if ($list_id == 'adjreason') {
226 echo " <td align='center' class='optcell'>";
227 echo "<select name='opt[$opt_line_no][value]' class='optin'>";
228 foreach (array(
229 1 => xl('Charge adjustment'),
230 2 => xl('Coinsurance'),
231 3 => xl('Deductible'),
232 4 => xl('Other pt resp'),
233 5 => xl('Comment'),
234 ) as $key => $desc) {
235 echo "<option value='$key'";
236 if ($key == $value) echo " selected";
237 echo ">" . htmlspecialchars($desc) . "</option>";
239 echo "</select>";
240 echo "</td>\n";
243 // Address book categories use option_value to flag category as a
244 // person-centric vs company-centric vs indifferent.
246 else if ($list_id == 'abook_type') {
247 echo " <td align='center' class='optcell'>";
248 echo "<select name='opt[$opt_line_no][value]' class='optin'>";
249 foreach (array(
250 1 => xl('Unassigned'),
251 2 => xl('Person'),
252 3 => xl('Company'),
253 ) as $key => $desc) {
254 echo "<option value='$key'";
255 if ($key == $value) echo " selected";
256 echo ">" . htmlspecialchars($desc) . "</option>";
258 echo "</select>";
259 echo "</td>\n";
262 // Immunization categories use option_value to map list items
263 // to CVX codes.
265 else if ($list_id == 'immunizations') {
266 echo " <td align='center' class='optcell'>";
267 echo "<input type='text' size='10' name='opt[$opt_line_no][value]' " .
268 "value='" . htmlspecialchars($value,ENT_QUOTES) . "' onclick='sel_cvxcode(this)' " .
269 "title='" . htmlspecialchars( xl('Click to select or change CVX code'), ENT_QUOTES) . "'/>";
270 echo "</td>\n";
273 // IPPF includes the ability to map each list item to a "master" identifier.
274 // Sports teams use this for some extra info for fitness levels.
276 if ($GLOBALS['ippf_specific'] || $list_id == 'fitness') {
277 echo " <td align='center' class='optcell'>";
278 echo "<input type='text' name='opt[$opt_line_no][mapping]' value='" .
279 htmlspecialchars($mapping, ENT_QUOTES) . "' size='12' maxlength='15' class='optin' />";
280 echo "</td>\n";
283 echo " <td align='center' class='optcell'>";
284 echo "<input type='text' name='opt[$opt_line_no][notes]' value='" .
285 htmlspecialchars($notes, ENT_QUOTES) . "' size='25' maxlength='255' class='optin' />";
286 echo "</td>\n";
288 echo " </tr>\n";
291 // Write a form line as above but for the special case of the Fee Sheet.
293 function writeFSLine($category, $option, $codes) {
294 global $opt_line_no;
296 ++$opt_line_no;
297 $bgcolor = "#" . (($opt_line_no & 1) ? "ddddff" : "ffdddd");
299 $descs = getCodeDescriptions($codes);
301 echo " <tr bgcolor='$bgcolor'>\n";
303 echo " <td align='center' class='optcell'>";
304 echo "<input type='text' name='opt[$opt_line_no][category]' value='" .
305 htmlspecialchars($category, ENT_QUOTES) . "' size='20' maxlength='63' class='optin' />";
306 echo "</td>\n";
308 echo " <td align='center' class='optcell'>";
309 echo "<input type='text' name='opt[$opt_line_no][option]' value='" .
310 htmlspecialchars($option, ENT_QUOTES) . "' size='20' maxlength='63' class='optin' />";
311 echo "</td>\n";
313 echo " <td align='left' class='optcell'>";
314 echo " <div id='codelist_$opt_line_no'>";
315 if (strlen($descs)) {
316 $arrdescs = explode('~', $descs);
317 $i = 0;
318 foreach ($arrdescs as $desc) {
319 echo "<a href='' onclick='return delete_code($opt_line_no,$i)' title='" . xl('Delete') . "'>";
320 echo "[x]&nbsp;</a>$desc<br />";
321 ++$i;
324 echo "</div>";
325 echo "<a href='' onclick='return select_code($opt_line_no)'>";
326 echo "[" . xl('Add') . "]</a>";
328 echo "<input type='hidden' name='opt[$opt_line_no][codes]' value='" .
329 htmlspecialchars($codes, ENT_QUOTES) . "' />";
330 echo "<input type='hidden' name='opt[$opt_line_no][descs]' value='" .
331 htmlspecialchars($descs, ENT_QUOTES) . "' />";
332 echo "</td>\n";
334 echo " </tr>\n";
337 // Helper functions for writeCTLine():
339 function ctGenCell($opt_line_no, $ct_array, $name, $size, $maxlength, $title='') {
340 $value = isset($ct_array[$name]) ? $ct_array[$name] : '';
341 $s = " <td align='center' class='optcell'";
342 if ($title) $s .= " title='" . addslashes($title) . "'";
343 $s .= ">";
344 $s .= "<input type='text' name='opt[$opt_line_no][$name]' value='";
345 $s .= htmlspecialchars($value, ENT_QUOTES);
346 $s .= "' size='$size' maxlength='$maxlength' class='optin' />";
347 $s .= "</td>\n";
348 return $s;
351 function ctGenCbox($opt_line_no, $ct_array, $name, $title='') {
352 $checked = empty($ct_array[$name]) ? '' : 'checked ';
353 $s = " <td align='center' class='optcell'";
354 if ($title) $s .= " title='" . addslashes($title) . "'";
355 $s .= ">";
356 $s .= "<input type='checkbox' name='opt[$opt_line_no][$name]' value='1' ";
357 $s .= "$checked/>";
358 $s .= "</td>\n";
359 return $s;
362 // Write a form line as above but for the special case of Code Types.
364 function writeCTLine($ct_array) {
365 global $opt_line_no;
367 ++$opt_line_no;
368 $bgcolor = "#" . (($opt_line_no & 1) ? "ddddff" : "ffdddd");
370 echo " <tr bgcolor='$bgcolor'>\n";
372 echo ctGenCBox($opt_line_no, $ct_array, 'ct_active',
373 xl('Is this code type active?'));
374 echo ctGenCell($opt_line_no, $ct_array, 'ct_key' , 6, 15,
375 xl('Unique human-readable identifier for this type'));
376 echo ctGenCell($opt_line_no, $ct_array, 'ct_id' , 2, 11,
377 xl('Unique numeric identifier for this type'));
378 echo ctGenCell($opt_line_no, $ct_array, 'ct_label' , 6, 30,
379 xl('Label for this type'));
380 echo ctGenCell($opt_line_no, $ct_array, 'ct_seq' , 2, 3,
381 xl('Numeric display order'));
382 echo ctGenCell($opt_line_no, $ct_array, 'ct_mod' , 1, 2,
383 xl('Length of modifier, 0 if none'));
384 echo ctGenCell($opt_line_no, $ct_array, 'ct_just', 4, 15,
385 xl('If billing justification is used enter the name of the diagnosis code type.'));
386 echo ctGenCell($opt_line_no, $ct_array, 'ct_mask', 6, 9,
387 xl('Specifies formatting for codes. # = digit, @ = alpha, * = any character. Empty if not used.'));
388 echo ctGenCBox($opt_line_no, $ct_array, 'ct_fee',
389 xl('Are fees charged for this type?'));
390 echo ctGenCBox($opt_line_no, $ct_array, 'ct_rel',
391 xl('Does this type allow related codes?'));
392 echo ctGenCBox($opt_line_no, $ct_array, 'ct_nofs',
393 xl('Is this type hidden in the fee sheet?'));
394 echo ctGenCBox($opt_line_no, $ct_array, 'ct_diag',
395 xl('Is this a diagnosis type?'));
396 echo ctGenCell($opt_line_no, $ct_array, 'ct_external' , 1, 2,
397 xl('Are the codes stored in external sql tables (0-No, 1-ICD10, 2-SNOMED(RF1), 3-SNOMED(RF2)) ?'));
399 echo " </tr>\n";
402 <html>
404 <head>
405 <?php html_header_show();?>
407 <!-- supporting javascript code -->
408 <script type="text/javascript" src="<?php echo $GLOBALS['webroot'] ?>/library/js/jquery.js"></script>
410 <link rel="stylesheet" href='<?php echo $css_header ?>' type='text/css'>
411 <title><?php xl('List Editor','e'); ?></title>
413 <style>
414 tr.head { font-size:10pt; background-color:#cccccc; text-align:center; }
415 tr.detail { font-size:10pt; }
416 td { font-size:10pt; }
417 input { font-size:10pt; }
418 a, a:visited, a:hover { color:#0000cc; }
419 .optcell { }
420 .optin { background-color:transparent; }
421 .help { cursor:help; }
422 .translation { color:green; }
423 </style>
425 <script type="text/javascript" src="../../library/dialog.js"></script>
427 <script language="JavaScript">
429 var current_lino = 0;
431 // Helper function to set the contents of a div.
432 // This is for Fee Sheet administration.
433 function setDivContent(id, content) {
434 if (document.getElementById) {
435 var x = document.getElementById(id);
436 x.innerHTML = '';
437 x.innerHTML = content;
439 else if (document.all) {
440 var x = document.all[id];
441 x.innerHTML = content;
445 // Given a line number, redisplay its descriptive list of codes.
446 // This is for Fee Sheet administration.
447 function displayCodes(lino) {
448 var f = document.forms[0];
449 var s = '';
450 var descs = f['opt[' + lino + '][descs]'].value;
451 if (descs.length) {
452 var arrdescs = descs.split('~');
453 for (var i = 0; i < arrdescs.length; ++i) {
454 s += "<a href='' onclick='return delete_code(" + lino + "," + i + ")' title='<?php xl('Delete','e'); ?>'>";
455 s += "[x]&nbsp;</a>" + arrdescs[i] + "<br />";
458 setDivContent('codelist_' + lino, s);
461 // Helper function to remove a Fee Sheet code.
462 function dc_substring(s, i) {
463 var r = '';
464 var j = s.indexOf('~', i);
465 if (j < 0) { // deleting last segment
466 if (i > 0) r = s.substring(0, i-1); // omits trailing ~
468 else { // not last segment
469 r = s.substring(0, i) + s.substring(j + 1);
471 return r;
474 // Remove a generated Fee Sheet code.
475 function delete_code(lino, seqno) {
476 var f = document.forms[0];
477 var celem = f['opt[' + lino + '][codes]'];
478 var delem = f['opt[' + lino + '][descs]'];
479 var ci = 0;
480 var di = 0;
481 for (var i = 0; i < seqno; ++i) {
482 ci = celem.value.indexOf('~', ci) + 1;
483 di = delem.value.indexOf('~', di) + 1;
485 celem.value = dc_substring(celem.value, ci);
486 delem.value = dc_substring(delem.value, di);
487 displayCodes(lino);
488 return false;
491 // This invokes the find-code popup.
492 // For Fee Sheet administration.
493 function select_code(lino) {
494 current_lino = lino;
495 dlgopen('../patient_file/encounter/find_code_popup.php', '_blank', 700, 400);
496 return false;
499 // This is for callback by the find-code popup.
500 function set_related(codetype, code, selector, codedesc) {
501 if (typeof(current_sel_name) == 'undefined')
503 // Coming from Fee Sheet edit
504 var f = document.forms[0];
505 var celem = f['opt[' + current_lino + '][codes]'];
506 var delem = f['opt[' + current_lino + '][descs]'];
507 var i = 0;
508 while ((i = codedesc.indexOf('~')) >= 0) {
509 codedesc = codedesc.substring(0, i) + ' ' + codedesc.substring(i+1);
511 if (code) {
512 if (celem.value) {
513 celem.value += '~';
514 delem.value += '~';
516 celem.value += codetype + '|' + code + '|' + selector;
517 if (codetype == 'PROD') delem.value += code + ':' + selector + ' ' + codedesc;
518 else delem.value += codetype + ':' + code + ' ' + codedesc;
519 } else {
520 celem.value = '';
521 delem.value = '';
523 displayCodes(current_lino);
525 else
527 // Coming from Immunizations edit
528 var f = document.forms[0][current_sel_name];
529 var s = f.value;
530 if (code) {
531 s = code;
533 else {
534 s = '0';
536 f.value = s;
540 // Called when a "default" checkbox is clicked. Clears all the others.
541 function defClicked(lino) {
542 var f = document.forms[0];
543 for (var i = 1; f['opt[' + i + '][default]']; ++i) {
544 if (i != lino) f['opt[' + i + '][default]'].checked = false;
548 // Form validation and submission.
549 // This needs more validation.
550 function mysubmit() {
551 var f = document.forms[0];
552 if (f.list_id.value == 'code_types') {
553 for (var i = 1; f['opt[' + i + '][ct_key]'].value; ++i) {
554 var ikey = 'opt[' + i + ']';
555 for (var j = i+1; f['opt[' + j + '][ct_key]'].value; ++j) {
556 var jkey = 'opt[' + j + ']';
557 if (f[ikey+'[ct_key]'].value == f[jkey+'[ct_key]'].value) {
558 alert('<?php echo xl('Error: duplicated name on line') ?>' + ' ' + j);
559 return;
561 if (parseInt(f[ikey+'[ct_id]'].value) == parseInt(f[jkey+'[ct_id]'].value)) {
562 alert('<?php echo xl('Error: duplicated ID on line') ?>' + ' ' + j);
563 return;
568 f.submit();
571 // This invokes the find-code popup.
572 function sel_cvxcode(e) {
573 current_sel_name = e.name;
574 dlgopen('../patient_file/encounter/find_code_popup.php?codetype=CVX', '_blank', 500, 400);
577 </script>
579 </head>
581 <body class="body_top">
583 <form method='post' name='theform' id='theform' action='edit_list.php'>
584 <input type="hidden" name="formaction" id="formaction">
586 <p><b><?php xl('Edit list','e'); ?>:</b>&nbsp;
587 <select name='list_id' id="list_id">
588 <?php
590 // List order depends on language translation options.
591 $lang_id = empty($_SESSION['language_choice']) ? '1' : $_SESSION['language_choice'];
593 if (($lang_id == '1' && !empty($GLOBALS['skip_english_translation'])) ||
594 !$GLOBALS['translate_lists'])
596 $res = sqlStatement("SELECT option_id, title FROM list_options WHERE " .
597 "list_id = 'lists' ORDER BY title, seq");
599 else {
600 // Use and sort by the translated list name.
601 $res = sqlStatement("SELECT lo.option_id, " .
602 "IF(LENGTH(ld.definition),ld.definition,lo.title) AS title " .
603 "FROM list_options AS lo " .
604 "LEFT JOIN lang_constants AS lc ON lc.constant_name = lo.title " .
605 "LEFT JOIN lang_definitions AS ld ON ld.cons_id = lc.cons_id AND " .
606 "ld.lang_id = '$lang_id' " .
607 "WHERE lo.list_id = 'lists' " .
608 "ORDER BY IF(LENGTH(ld.definition),ld.definition,lo.title), lo.seq");
611 while ($row = sqlFetchArray($res)) {
612 $key = $row['option_id'];
613 echo "<option value='$key'";
614 if ($key == $list_id) echo " selected";
615 echo ">" . $row['title'] . "</option>\n";
619 </select>
620 <input type="button" id="<?php echo $list_id; ?>" class="deletelist" value=<?php xl('Delete List','e','\'','\''); ?>>
621 <input type="button" id="newlist" class="newlist" value=<?php xl('New List','e','\'','\''); ?>>
622 </p>
624 <center>
626 <table cellpadding='2' cellspacing='0'>
627 <tr class='head'>
628 <?php if ($list_id == 'feesheet') { ?>
629 <td><b><?php xl('Group' ,'e'); ?></b></td>
630 <td><b><?php xl('Option' ,'e'); ?></b></td>
631 <td><b><?php xl('Generates','e'); ?></b></td>
632 <?php } else if ($list_id == 'code_types') { ?>
633 <td><b><?php xl('Active' ,'e'); ?></b></td>
634 <td><b><?php xl('Key' ,'e'); ?></b></td>
635 <td><b><?php xl('ID' ,'e'); ?></b></td>
636 <td><b><?php xl('Label' ,'e'); ?></b></td>
637 <td><b><?php xl('Seq' ,'e'); ?></b></td>
638 <td><b><?php xl('ModLength' ,'e'); ?></b></td>
639 <td><b><?php xl('Justify' ,'e'); ?></b></td>
640 <td><b><?php xl('Mask' ,'e'); ?></b></td>
641 <td><b><?php xl('Fees' ,'e'); ?></b></td>
642 <td><b><?php xl('Relations' ,'e'); ?></b></td>
643 <td><b><?php xl('Hide' ,'e'); ?></b></td>
644 <td><b><?php xl('Diagnosis' ,'e'); ?></b></td>
645 <td><b><?php xl('External' ,'e'); ?></b></td>
646 <?php } else { ?>
647 <td title=<?php xl('Click to edit','e','\'','\''); ?>><b><?php xl('ID','e'); ?></b></td>
648 <td><b><?php xl('Title' ,'e'); ?></b></td>
649 <?php //show translation column if not english and the translation lists flag is set
650 if ($GLOBALS['translate_lists'] && $_SESSION['language_choice'] > 1) {
651 echo "<td><b>".xl('Translation')."</b><span class='help' title='".xl('The translated Title that will appear in current language')."'> (?)</span></td>";
652 } ?>
653 <td><b><?php xl('Order' ,'e'); ?></b></td>
654 <td><b><?php xl('Default','e'); ?></b></td>
655 <?php if ($list_id == 'taxrate') { ?>
656 <td><b><?php xl('Rate' ,'e'); ?></b></td>
657 <?php } else if ($list_id == 'contrameth') { ?>
658 <td><b><?php xl('Effectiveness','e'); ?></b></td>
659 <?php } else if ($list_id == 'lbfnames') { ?>
660 <td title='<?php xl('Number of past history columns','e'); ?>'><b><?php xl('Repeats','e'); ?></b></td>
661 <?php } else if ($list_id == 'fitness') { ?>
662 <td><b><?php xl('Color:Abbr','e'); ?></b></td>
663 <?php } else if ($list_id == 'adjreason' || $list_id == 'abook_type') { ?>
664 <td><b><?php xl('Type','e'); ?></b></td>
665 <?php } else if ($list_id == 'immunizations') { ?>
666 <td><b>&nbsp;&nbsp;&nbsp;&nbsp;<?php xl('CVX Code Mapping','e'); ?></b></td>
667 <?php } if ($GLOBALS['ippf_specific']) { ?>
668 <td><b><?php xl('Global ID','e'); ?></b></td>
669 <?php } ?>
670 <td><b><?php xl('Notes','e'); ?></b></td>
671 <?php } // end not fee sheet ?>
672 </tr>
674 <?php
675 // Get the selected list's elements.
676 if ($list_id) {
677 if ($list_id == 'feesheet') {
678 $res = sqlStatement("SELECT * FROM fee_sheet_options " .
679 "ORDER BY fs_category, fs_option");
680 while ($row = sqlFetchArray($res)) {
681 writeFSLine($row['fs_category'], $row['fs_option'], $row['fs_codes']);
683 for ($i = 0; $i < 3; ++$i) {
684 writeFSLine('', '', '');
687 else if ($list_id == 'code_types') {
688 $res = sqlStatement("SELECT * FROM code_types " .
689 "ORDER BY ct_seq, ct_key");
690 while ($row = sqlFetchArray($res)) {
691 writeCTLine($row);
693 for ($i = 0; $i < 3; ++$i) {
694 writeCTLine(array());
697 else {
698 $res = sqlStatement("SELECT * FROM list_options WHERE " .
699 "list_id = '$list_id' ORDER BY seq,title");
700 while ($row = sqlFetchArray($res)) {
701 writeOptionLine($row['option_id'], $row['title'], $row['seq'],
702 $row['is_default'], $row['option_value'], $row['mapping'],
703 $row['notes']);
705 for ($i = 0; $i < 3; ++$i) {
706 writeOptionLine('', '', '', '', 0);
712 </table>
715 <input type='button' name='form_save' id='form_save' value='<?php xl('Save','e'); ?>' />
716 </p>
717 </center>
719 </form>
721 <!-- template DIV that appears when user chooses to make a new list -->
722 <div id="newlistdetail" style="border: 1px solid black; padding: 3px; display: none; visibility: hidden; background-color: lightgrey;">
723 <?php xl('List Name','e'); ?>: <input type="textbox" size="20" maxlength="30" name="newlistname" id="newlistname">
724 <br>
725 <input type="button" class="savenewlist" value=<?php xl('Save New List','e','\'','\''); ?>>
726 <input type="button" class="cancelnewlist" value=<?php xl('Cancel','e','\'','\''); ?>>
727 </div>
728 </body>
729 <script language="javascript">
730 // jQuery stuff to make the page a little easier to use
732 $(document).ready(function(){
733 $("#form_save").click(function() { SaveChanges(); });
734 $("#list_id").change(function() { $('#theform').submit(); });
736 $(".newlist").click(function() { NewList(this); });
737 $(".savenewlist").click(function() { SaveNewList(this); });
738 $(".deletelist").click(function() { DeleteList(this); });
739 $(".cancelnewlist").click(function() { CancelNewList(this); });
741 var SaveChanges = function() {
742 $("#formaction").val("save");
743 // $('#theform').submit();
744 mysubmit();
747 // show the DIV to create a new list
748 var NewList = function(btnObj) {
749 // show the field details DIV
750 $('#newlistdetail').css('visibility', 'visible');
751 $('#newlistdetail').css('display', 'block');
752 $(btnObj).parent().append($("#newlistdetail"));
753 $('#newlistdetail > #newlistname').focus();
755 // save the new list
756 var SaveNewList = function() {
757 // the list name can only have letters, numbers, spaces and underscores
758 // AND it cannot start with a number
759 if ($("#newlistname").val().match(/^\d+/)) {
760 alert("<?php xl('List names cannot start with numbers.','e'); ?>");
761 return false;
763 var validname = $("#newlistname").val().replace(/[^A-za-z0-9 -]/g, "_"); // match any non-word characters and replace them
764 if (validname != $("#newlistname").val()) {
765 if (! confirm("<?php xl('Your list name has been changed to meet naming requirements.','e','','\n') . xl('Please compare the new name','e','',', \''); ?>"+validname+"<?php xl('with the old name','e','\' ',', \''); ?>"+$("#newlistname").val()+"<?php xl('Do you wish to continue with the new name?','e','\'.\n',''); ?>"))
767 return false;
770 $("#newlistname").val(validname);
772 // submit the form to add a new field to a specific group
773 $("#formaction").val("addlist");
774 $("#theform").submit();
776 // actually delete an entire list from the database
777 var DeleteList = function(btnObj) {
778 var listid = $(btnObj).attr("id");
779 if (confirm("<?php xl('WARNING','e','',' - ') . xl('This action cannot be undone.','e','','\n') . xl('Are you sure you wish to delete the entire list','e',' ','('); ?>"+listid+")?")) {
780 // submit the form to add a new field to a specific group
781 $("#formaction").val("deletelist");
782 $("#deletelistname").val(listid);
783 $("#theform").submit();
787 // just hide the new list DIV
788 var CancelNewList = function(btnObj) {
789 // hide the list details DIV
790 $('#newlistdetail').css('visibility', 'hidden');
791 $('#newlistdetail').css('display', 'none');
792 // reset the new group values to a default
793 $('#newlistdetail > #newlistname').val("");
797 </script>
799 </html>