2 // Copyright (C) 2007-2011 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");
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) {
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 " .
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 if (strlen($ct_key) > 0 && $ct_id > 0) {
59 sqlInsert("INSERT INTO code_types ( " .
60 "ct_key, ct_id, ct_seq, ct_mod, ct_just, ct_mask, ct_fee, ct_rel, ct_nofs, ct_diag " .
79 // erase lists options and recreate them from the submitted form data
80 sqlStatement("DELETE FROM list_options WHERE list_id = '$list_id'");
81 for ($lino = 1; isset($opt["$lino"]['id']); ++
$lino) {
82 $iter = $opt["$lino"];
83 $value = empty($iter['value']) ?
0 : (formTrim($iter['value']) +
0);
84 $id = formTrim($iter['id']);
85 if (strlen($id) > 0) {
87 // Special processing for the immunizations list
88 // Map the entered cvx codes into the immunizations table cvx_code
89 sqlStatement ("UPDATE `immunizations` " .
90 "SET `cvx_code`='".$value."' " .
91 "WHERE `immunization_id`='".$id."'");
93 // Force List Based Form names to start with LBF.
94 if ($list_id == 'lbfnames' && substr($id,0,3) != 'LBF')
96 sqlInsert("INSERT INTO list_options ( " .
97 "list_id, option_id, title, seq, is_default, option_value, mapping, notes " .
101 "'" . formTrim($iter['title']) . "', " .
102 "'" . formTrim($iter['seq']) . "', " .
103 "'" . formTrim($iter['default']) . "', " .
104 "'" . $value . "', " .
105 "'" . formTrim($iter['mapping']) . "', " .
106 "'" . formTrim($iter['notes']) . "' " .
112 else if ($_POST['formaction']=='addlist') {
113 // make a new list ID from the new list name
114 $newlistID = $_POST['newlistname'];
115 $newlistID = preg_replace("/\W/", "_", $newlistID);
117 // determine the position of this new list
118 $row = sqlQuery("SELECT max(seq) as maxseq FROM list_options WHERE list_id= 'lists'");
120 // add the new list to the list-of-lists
121 sqlInsert("INSERT INTO list_options ( " .
122 "list_id, option_id, title, seq, is_default, option_value " .
124 "'lists',". // the master list-of-lists
126 "'".$_POST['newlistname']."', ".
127 "'".($row['maxseq']+
1)."',".
131 else if ($_POST['formaction']=='deletelist') {
132 // delete the lists options
133 sqlStatement("DELETE FROM list_options WHERE list_id = '".$_POST['list_id']."'");
134 // delete the list from the master list-of-lists
135 sqlStatement("DELETE FROM list_options WHERE list_id = 'lists' and option_id='".$_POST['list_id']."'");
140 // Given a string of multiple instances of code_type|code|selector,
141 // make a description for each.
142 function getCodeDescriptions($codes) {
144 $arrcodes = explode('~', $codes);
146 foreach ($arrcodes as $codestring) {
147 if ($codestring === '') continue;
148 $arrcode = explode('|', $codestring);
149 $code_type = $arrcode[0];
151 $selector = $arrcode[2];
153 if ($code_type == 'PROD') {
154 $row = sqlQuery("SELECT name FROM drugs WHERE drug_id = '$code' ");
155 $desc = "$code:$selector " . $row['name'];
158 $row = sqlQuery("SELECT code_text FROM codes WHERE " .
159 "code_type = '" . $code_types[$code_type]['id'] . "' AND " .
160 "code = '$code' ORDER BY modifier LIMIT 1");
161 $desc = "$code_type:$code " . ucfirst(strtolower($row['code_text']));
163 $desc = str_replace('~', ' ', $desc);
170 // Write one option line to the form.
172 function writeOptionLine($option_id, $title, $seq, $default, $value, $mapping='', $notes='') {
173 global $opt_line_no, $list_id;
175 $bgcolor = "#" . (($opt_line_no & 1) ?
"ddddff" : "ffdddd");
176 $checked = $default ?
" checked" : "";
178 echo " <tr bgcolor='$bgcolor'>\n";
180 echo " <td align='center' class='optcell'>";
181 echo "<input type='text' name='opt[$opt_line_no][id]' value='" .
182 htmlspecialchars($option_id, ENT_QUOTES
) . "' size='12' maxlength='63' class='optin' />";
185 echo " <td align='center' class='optcell'>";
186 echo "<input type='text' name='opt[$opt_line_no][title]' value='" .
187 htmlspecialchars($title, ENT_QUOTES
) . "' size='20' maxlength='63' class='optin' />";
190 // if not english and translating lists then show the translation
191 if ($GLOBALS['translate_lists'] && $_SESSION['language_choice'] > 1) {
192 echo " <td align='center' class='translation'>" . (htmlspecialchars( xl($title), ENT_QUOTES
)) . "</td>\n";
195 echo " <td align='center' class='optcell'>";
196 echo "<input type='text' name='opt[$opt_line_no][seq]' value='" .
197 htmlspecialchars($seq, ENT_QUOTES
) . "' size='4' maxlength='10' class='optin' />";
200 echo " <td align='center' class='optcell'>";
201 echo "<input type='checkbox' name='opt[$opt_line_no][default]' value='1' " .
202 "onclick='defClicked($opt_line_no)' class='optin'$checked />";
205 // Tax rates, contraceptive methods and LBF names have an additional attribute.
207 if ($list_id == 'taxrate' ||
$list_id == 'contrameth' ||
$list_id == 'lbfnames') {
208 echo " <td align='center' class='optcell'>";
209 echo "<input type='text' name='opt[$opt_line_no][value]' value='" .
210 htmlspecialchars($value, ENT_QUOTES
) . "' size='8' maxlength='15' class='optin' />";
214 // Adjustment reasons use option_value as a reason category. This is
215 // needed to distinguish between adjustments that change the invoice
216 // balance and those that just shift responsibility of payment or
217 // are used as comments.
219 else if ($list_id == 'adjreason') {
220 echo " <td align='center' class='optcell'>";
221 echo "<select name='opt[$opt_line_no][value]' class='optin'>";
223 1 => xl('Charge adjustment'),
224 2 => xl('Coinsurance'),
225 3 => xl('Deductible'),
226 4 => xl('Other pt resp'),
228 ) as $key => $desc) {
229 echo "<option value='$key'";
230 if ($key == $value) echo " selected";
231 echo ">" . htmlspecialchars($desc) . "</option>";
237 // Address book categories use option_value to flag category as a
238 // person-centric vs company-centric vs indifferent.
240 else if ($list_id == 'abook_type') {
241 echo " <td align='center' class='optcell'>";
242 echo "<select name='opt[$opt_line_no][value]' class='optin'>";
244 1 => xl('Unassigned'),
247 ) as $key => $desc) {
248 echo "<option value='$key'";
249 if ($key == $value) echo " selected";
250 echo ">" . htmlspecialchars($desc) . "</option>";
256 // Immunization categories use option_value to map list items
259 else if ($list_id == 'immunizations') {
260 echo " <td align='center' class='optcell'>";
261 echo "<input type='text' size='10' name='opt[$opt_line_no][value]' " .
262 "value='" . htmlspecialchars($value,ENT_QUOTES
) . "' onclick='sel_cvxcode(this)' " .
263 "title='" . htmlspecialchars( xl('Click to select or change CVX code'), ENT_QUOTES
) . "'/>";
267 // IPPF includes the ability to map each list item to a "master" identifier.
268 // Sports teams use this for some extra info for fitness levels.
270 if ($GLOBALS['ippf_specific'] ||
$list_id == 'fitness') {
271 echo " <td align='center' class='optcell'>";
272 echo "<input type='text' name='opt[$opt_line_no][mapping]' value='" .
273 htmlspecialchars($mapping, ENT_QUOTES
) . "' size='12' maxlength='15' class='optin' />";
277 echo " <td align='center' class='optcell'>";
278 echo "<input type='text' name='opt[$opt_line_no][notes]' value='" .
279 htmlspecialchars($notes, ENT_QUOTES
) . "' size='25' maxlength='255' class='optin' />";
285 // Write a form line as above but for the special case of the Fee Sheet.
287 function writeFSLine($category, $option, $codes) {
291 $bgcolor = "#" . (($opt_line_no & 1) ?
"ddddff" : "ffdddd");
293 $descs = getCodeDescriptions($codes);
295 echo " <tr bgcolor='$bgcolor'>\n";
297 echo " <td align='center' class='optcell'>";
298 echo "<input type='text' name='opt[$opt_line_no][category]' value='" .
299 htmlspecialchars($category, ENT_QUOTES
) . "' size='20' maxlength='63' class='optin' />";
302 echo " <td align='center' class='optcell'>";
303 echo "<input type='text' name='opt[$opt_line_no][option]' value='" .
304 htmlspecialchars($option, ENT_QUOTES
) . "' size='20' maxlength='63' class='optin' />";
307 echo " <td align='left' class='optcell'>";
308 echo " <div id='codelist_$opt_line_no'>";
309 if (strlen($descs)) {
310 $arrdescs = explode('~', $descs);
312 foreach ($arrdescs as $desc) {
313 echo "<a href='' onclick='return delete_code($opt_line_no,$i)' title='" . xl('Delete') . "'>";
314 echo "[x] </a>$desc<br />";
319 echo "<a href='' onclick='return select_code($opt_line_no)'>";
320 echo "[" . xl('Add') . "]</a>";
322 echo "<input type='hidden' name='opt[$opt_line_no][codes]' value='" .
323 htmlspecialchars($codes, ENT_QUOTES
) . "' />";
324 echo "<input type='hidden' name='opt[$opt_line_no][descs]' value='" .
325 htmlspecialchars($descs, ENT_QUOTES
) . "' />";
331 // Helper functions for writeCTLine():
333 function ctGenCell($opt_line_no, $ct_array, $name, $size, $maxlength, $title='') {
334 $value = isset($ct_array[$name]) ?
$ct_array[$name] : '';
335 $s = " <td align='center' class='optcell'";
336 if ($title) $s .= " title='" . addslashes($title) . "'";
338 $s .= "<input type='text' name='opt[$opt_line_no][$name]' value='";
339 $s .= htmlspecialchars($value, ENT_QUOTES
);
340 $s .= "' size='$size' maxlength='$maxlength' class='optin' />";
345 function ctGenCbox($opt_line_no, $ct_array, $name, $title='') {
346 $checked = empty($ct_array[$name]) ?
'' : 'checked ';
347 $s = " <td align='center' class='optcell'";
348 if ($title) $s .= " title='" . addslashes($title) . "'";
350 $s .= "<input type='checkbox' name='opt[$opt_line_no][$name]' value='1' ";
356 // Write a form line as above but for the special case of Code Types.
358 function writeCTLine($ct_array) {
362 $bgcolor = "#" . (($opt_line_no & 1) ?
"ddddff" : "ffdddd");
364 echo " <tr bgcolor='$bgcolor'>\n";
366 echo ctGenCell($opt_line_no, $ct_array, 'ct_key' , 4, 15,
367 xl('Unique human-readable identifier for this type'));
368 echo ctGenCell($opt_line_no, $ct_array, 'ct_id' , 2, 11,
369 xl('Unique numeric identifier for this type'));
370 echo ctGenCell($opt_line_no, $ct_array, 'ct_seq' , 2, 3,
371 xl('Numeric display order'));
372 echo ctGenCell($opt_line_no, $ct_array, 'ct_mod' , 1, 2,
373 xl('Length of modifier, 0 if none'));
374 echo ctGenCell($opt_line_no, $ct_array, 'ct_just', 4, 15,
375 xl('If billing justification is used enter the name of the diagnosis code type.'));
376 echo ctGenCell($opt_line_no, $ct_array, 'ct_mask', 6, 9,
377 xl('Specifies formatting for codes. # = digit, @ = alpha, * = any character. Empty if not used.'));
378 echo ctGenCBox($opt_line_no, $ct_array, 'ct_fee',
379 xl('Are fees charged for this type?'));
380 echo ctGenCBox($opt_line_no, $ct_array, 'ct_rel',
381 xl('Does this type allow related codes?'));
382 echo ctGenCBox($opt_line_no, $ct_array, 'ct_nofs',
383 xl('Is this type hidden in the fee sheet?'));
384 echo ctGenCBox($opt_line_no, $ct_array, 'ct_diag',
385 xl('Is this a diagnosis type?'));
393 <?php
html_header_show();?
>
395 <!-- supporting javascript code
-->
396 <script type
="text/javascript" src
="<?php echo $GLOBALS['webroot'] ?>/library/js/jquery.js"></script
>
398 <link rel
="stylesheet" href
='<?php echo $css_header ?>' type
='text/css'>
399 <title
><?php
xl('List Editor','e'); ?
></title
>
402 tr
.head
{ font
-size
:10pt
; background
-color
:#cccccc; text-align:center; }
403 tr
.detail
{ font
-size
:10pt
; }
404 td
{ font
-size
:10pt
; }
405 input
{ font
-size
:10pt
; }
406 a
, a
:visited
, a
:hover
{ color
:#0000cc; }
408 .optin
{ background
-color
:transparent
; }
409 .help
{ cursor
:help
; }
410 .translation
{ color
:green
; }
413 <script type
="text/javascript" src
="../../library/dialog.js"></script
>
415 <script language
="JavaScript">
417 var current_lino
= 0;
419 // Helper function to set the contents of a div.
420 // This is for Fee Sheet administration.
421 function setDivContent(id
, content
) {
422 if (document
.getElementById
) {
423 var x
= document
.getElementById(id
);
425 x
.innerHTML
= content
;
427 else if (document
.all
) {
428 var x
= document
.all
[id
];
429 x
.innerHTML
= content
;
433 // Given a line number, redisplay its descriptive list of codes.
434 // This is for Fee Sheet administration.
435 function displayCodes(lino
) {
436 var f
= document
.forms
[0];
438 var descs
= f
['opt[' + lino +
'][descs]'].value
;
440 var arrdescs
= descs
.split('~');
441 for (var i
= 0; i
< arrdescs
.length
; ++i
) {
442 s +
= "<a href='' onclick='return delete_code(" + lino +
"," + i +
")' title='<?php xl('Delete','e'); ?>'>";
443 s +
= "[x] </a>" + arrdescs
[i
] +
"<br />";
446 setDivContent('codelist_' + lino
, s
);
449 // Helper function to remove a Fee Sheet code.
450 function dc_substring(s
, i
) {
452 var j
= s
.indexOf('~', i
);
453 if (j
< 0) { // deleting last segment
454 if (i
> 0) r
= s
.substring(0, i
-1); // omits trailing ~
456 else { // not last segment
457 r
= s
.substring(0, i
) + s
.substring(j +
1);
462 // Remove a generated Fee Sheet code.
463 function delete_code(lino
, seqno
) {
464 var f
= document
.forms
[0];
465 var celem
= f
['opt[' + lino +
'][codes]'];
466 var delem
= f
['opt[' + lino +
'][descs]'];
469 for (var i
= 0; i
< seqno
; ++i
) {
470 ci
= celem
.value
.indexOf('~', ci
) +
1;
471 di
= delem
.value
.indexOf('~', di
) +
1;
473 celem
.value
= dc_substring(celem
.value
, ci
);
474 delem
.value
= dc_substring(delem
.value
, di
);
479 // This invokes the find-code popup.
480 // For Fee Sheet administration.
481 function select_code(lino
) {
483 dlgopen('../patient_file/encounter/find_code_popup.php', '_blank', 700, 400);
487 // This is for callback by the find-code popup.
488 // For Fee Sheet administration.
489 function set_related(codetype
, code
, selector
, codedesc
) {
490 var f
= document
.forms
[0];
491 var celem
= f
['opt[' + current_lino +
'][codes]'];
492 var delem
= f
['opt[' + current_lino +
'][descs]'];
494 while ((i
= codedesc
.indexOf('~')) >= 0) {
495 codedesc
= codedesc
.substring(0, i
) +
' ' + codedesc
.substring(i+
1);
502 celem
.value +
= codetype +
'|' + code +
'|' + selector
;
503 if (codetype
== 'PROD') delem
.value +
= code +
':' + selector +
' ' + codedesc
;
504 else delem
.value +
= codetype +
':' + code +
' ' + codedesc
;
509 displayCodes(current_lino
);
512 // Called when a "default" checkbox is clicked. Clears all the others.
513 function defClicked(lino
) {
514 var f
= document
.forms
[0];
515 for (var i
= 1; f
['opt[' + i +
'][default]']; ++i
) {
516 if (i
!= lino
) f
['opt[' + i +
'][default]'].checked
= false;
520 // Form validation and submission.
521 // This needs more validation.
522 function mysubmit() {
523 var f
= document
.forms
[0];
524 if (f
.list_id
.value
== 'code_types') {
525 for (var i
= 1; f
['opt[' + i +
'][ct_key]'].value
; ++i
) {
526 var ikey
= 'opt[' + i +
']';
527 for (var j
= i+
1; f
['opt[' + j +
'][ct_key]'].value
; ++j
) {
528 var jkey
= 'opt[' + j +
']';
529 if (f
[ikey+
'[ct_key]'].value
== f
[jkey+
'[ct_key]'].value
) {
530 alert('<?php echo xl('Error
: duplicated name on line
') ?>' +
' ' + j
);
533 if (parseInt(f
[ikey+
'[ct_id]'].value
) == parseInt(f
[jkey+
'[ct_id]'].value
)) {
534 alert('<?php echo xl('Error
: duplicated ID on line
') ?>' +
' ' + j
);
543 // This invokes the find-code popup.
544 function sel_cvxcode(e
) {
545 current_sel_name
= e
.name
;
546 dlgopen('../patient_file/encounter/find_code_popup.php?codetype=CVX', '_blank', 500, 400);
549 //This is for callback by the find-code popup.
550 //Appends to or erases the current list of diagnoses.
551 function set_related(codetype
, code
, selector
, codedesc
) {
552 var f
= document
.forms
[0][current_sel_name
];
569 <body
class="body_top">
571 <form method
='post' name
='theform' id
='theform' action
='edit_list.php'>
572 <input type
="hidden" name
="formaction" id
="formaction">
574 <p
><b
><?php
xl('Edit list','e'); ?
>:</b
> 
;
575 <select name
='list_id' id
="list_id">
578 // List order depends on language translation options.
579 $lang_id = empty($_SESSION['language_choice']) ?
'1' : $_SESSION['language_choice'];
581 if (($lang_id == '1' && !empty($GLOBALS['skip_english_translation'])) ||
582 !$GLOBALS['translate_lists'])
584 $res = sqlStatement("SELECT option_id, title FROM list_options WHERE " .
585 "list_id = 'lists' ORDER BY title, seq");
588 // Use and sort by the translated list name.
589 $res = sqlStatement("SELECT lo.option_id, " .
590 "IF(LENGTH(ld.definition),ld.definition,lo.title) AS title " .
591 "FROM list_options AS lo " .
592 "LEFT JOIN lang_constants AS lc ON lc.constant_name = lo.title " .
593 "LEFT JOIN lang_definitions AS ld ON ld.cons_id = lc.cons_id AND " .
594 "ld.lang_id = '$lang_id' " .
595 "WHERE lo.list_id = 'lists' " .
596 "ORDER BY IF(LENGTH(ld.definition),ld.definition,lo.title), lo.seq");
599 while ($row = sqlFetchArray($res)) {
600 $key = $row['option_id'];
601 echo "<option value='$key'";
602 if ($key == $list_id) echo " selected";
603 echo ">" . $row['title'] . "</option>\n";
608 <input type
="button" id
="<?php echo $list_id; ?>" class="deletelist" value
=<?php
xl('Delete List','e','\'','\''); ?
>>
609 <input type
="button" id
="newlist" class="newlist" value
=<?php
xl('New List','e','\'','\''); ?
>>
614 <table cellpadding
='2' cellspacing
='0'>
616 <?php
if ($list_id == 'feesheet') { ?
>
617 <td
><b
><?php
xl('Group' ,'e'); ?
></b
></td
>
618 <td
><b
><?php
xl('Option' ,'e'); ?
></b
></td
>
619 <td
><b
><?php
xl('Generates','e'); ?
></b
></td
>
620 <?php
} else if ($list_id == 'code_types') { ?
>
621 <td
><b
><?php
xl('Name' ,'e'); ?
></b
></td
>
622 <td
><b
><?php
xl('ID' ,'e'); ?
></b
></td
>
623 <td
><b
><?php
xl('Seq' ,'e'); ?
></b
></td
>
624 <td
><b
><?php
xl('ModLength' ,'e'); ?
></b
></td
>
625 <td
><b
><?php
xl('Justify' ,'e'); ?
></b
></td
>
626 <td
><b
><?php
xl('Mask' ,'e'); ?
></b
></td
>
627 <td
><b
><?php
xl('Fees' ,'e'); ?
></b
></td
>
628 <td
><b
><?php
xl('Relations' ,'e'); ?
></b
></td
>
629 <td
><b
><?php
xl('Hide' ,'e'); ?
></b
></td
>
630 <td
><b
><?php
xl('Diagnosis' ,'e'); ?
></b
></td
>
632 <td title
=<?php
xl('Click to edit','e','\'','\''); ?
>><b
><?php
xl('ID','e'); ?
></b
></td
>
633 <td
><b
><?php
xl('Title' ,'e'); ?
></b
></td
>
634 <?php
//show translation column if not english and the translation lists flag is set
635 if ($GLOBALS['translate_lists'] && $_SESSION['language_choice'] > 1) {
636 echo "<td><b>".xl('Translation')."</b><span class='help' title='".xl('The translated Title that will appear in current language')."'> (?)</span></td>";
638 <td
><b
><?php
xl('Order' ,'e'); ?
></b
></td
>
639 <td
><b
><?php
xl('Default','e'); ?
></b
></td
>
640 <?php
if ($list_id == 'taxrate') { ?
>
641 <td
><b
><?php
xl('Rate' ,'e'); ?
></b
></td
>
642 <?php
} else if ($list_id == 'contrameth') { ?
>
643 <td
><b
><?php
xl('Effectiveness','e'); ?
></b
></td
>
644 <?php
} else if ($list_id == 'lbfnames') { ?
>
645 <td title
='<?php xl('Number of past history columns
','e
'); ?>'><b
><?php
xl('Repeats','e'); ?
></b
></td
>
646 <?php
} else if ($list_id == 'fitness') { ?
>
647 <td
><b
><?php
xl('Color:Abbr','e'); ?
></b
></td
>
648 <?php
} else if ($list_id == 'adjreason' ||
$list_id == 'abook_type') { ?
>
649 <td
><b
><?php
xl('Type','e'); ?
></b
></td
>
650 <?php
} else if ($list_id == 'immunizations') { ?
>
651 <td
><b
> 
; 
; 
; 
;<?php
xl('CVX Code Mapping','e'); ?
></b
></td
>
652 <?php
} if ($GLOBALS['ippf_specific']) { ?
>
653 <td
><b
><?php
xl('Global ID','e'); ?
></b
></td
>
655 <td
><b
><?php
xl('Notes','e'); ?
></b
></td
>
656 <?php
} // end not fee sheet ?>
660 // Get the selected list's elements.
662 if ($list_id == 'feesheet') {
663 $res = sqlStatement("SELECT * FROM fee_sheet_options " .
664 "ORDER BY fs_category, fs_option");
665 while ($row = sqlFetchArray($res)) {
666 writeFSLine($row['fs_category'], $row['fs_option'], $row['fs_codes']);
668 for ($i = 0; $i < 3; ++
$i) {
669 writeFSLine('', '', '');
672 else if ($list_id == 'code_types') {
673 $res = sqlStatement("SELECT * FROM code_types " .
674 "ORDER BY ct_seq, ct_key");
675 while ($row = sqlFetchArray($res)) {
678 for ($i = 0; $i < 3; ++
$i) {
679 writeCTLine(array());
683 $res = sqlStatement("SELECT * FROM list_options WHERE " .
684 "list_id = '$list_id' ORDER BY seq,title");
685 while ($row = sqlFetchArray($res)) {
686 writeOptionLine($row['option_id'], $row['title'], $row['seq'],
687 $row['is_default'], $row['option_value'], $row['mapping'],
690 for ($i = 0; $i < 3; ++
$i) {
691 writeOptionLine('', '', '', '', 0);
700 <input type
='button' name
='form_save' id
='form_save' value
='<?php xl('Save
','e
'); ?>' />
706 <!-- template DIV that appears when user chooses to make a
new list -->
707 <div id
="newlistdetail" style
="border: 1px solid black; padding: 3px; display: none; visibility: hidden; background-color: lightgrey;">
708 <?php
xl('List Name','e'); ?
>: <input type
="textbox" size
="20" maxlength
="30" name
="newlistname" id
="newlistname">
710 <input type
="button" class="savenewlist" value
=<?php
xl('Save New List','e','\'','\''); ?
>>
711 <input type
="button" class="cancelnewlist" value
=<?php
xl('Cancel','e','\'','\''); ?
>>
714 <script language
="javascript">
715 // jQuery stuff to make the page a little easier to use
717 $
(document
).ready(function(){
718 $
("#form_save").click(function() { SaveChanges(); });
719 $
("#list_id").change(function() { $
('#theform').submit(); });
721 $
(".newlist").click(function() { NewList(this
); });
722 $
(".savenewlist").click(function() { SaveNewList(this
); });
723 $
(".deletelist").click(function() { DeleteList(this
); });
724 $
(".cancelnewlist").click(function() { CancelNewList(this
); });
726 var SaveChanges
= function() {
727 $
("#formaction").val("save");
728 // $('#theform').submit();
732 // show the DIV to create a new list
733 var NewList
= function(btnObj
) {
734 // show the field details DIV
735 $
('#newlistdetail').css('visibility', 'visible');
736 $
('#newlistdetail').css('display', 'block');
737 $
(btnObj
).parent().append($
("#newlistdetail"));
738 $
('#newlistdetail > #newlistname').focus();
741 var SaveNewList
= function() {
742 // the list name can only have letters, numbers, spaces and underscores
743 // AND it cannot start with a number
744 if ($
("#newlistname").val().match(/^\d+
/)) {
745 alert("<?php xl('List names cannot start with numbers.','e'); ?>");
748 var validname
= $
("#newlistname").val().replace(/[^A
-za
-z0
-9 -]/g
, "_"); // match any non-word characters and replace them
749 if (validname
!= $
("#newlistname").val()) {
750 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',''); ?>"))
755 $
("#newlistname").val(validname
);
757 // submit the form to add a new field to a specific group
758 $
("#formaction").val("addlist");
759 $
("#theform").submit();
761 // actually delete an entire list from the database
762 var DeleteList
= function(btnObj
) {
763 var listid
= $
(btnObj
).attr("id");
764 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+
")?")) {
765 // submit the form to add a new field to a specific group
766 $
("#formaction").val("deletelist");
767 $
("#deletelistname").val(listid
);
768 $
("#theform").submit();
772 // just hide the new list DIV
773 var CancelNewList
= function(btnObj
) {
774 // hide the list details DIV
775 $
('#newlistdetail').css('visibility', 'hidden');
776 $
('#newlistdetail').css('display', 'none');
777 // reset the new group values to a default
778 $
('#newlistdetail > #newlistname').val("");