2 // Copyright (C) 2007-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");
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) {
86 // Force List Based Form names to start with LBF.
87 if ($list_id == 'lbfnames' && substr($id,0,3) != 'LBF')
89 sqlInsert("INSERT INTO list_options ( " .
90 "list_id, option_id, title, seq, is_default, option_value, mapping, notes " .
94 "'" . formTrim($iter['title']) . "', " .
95 "'" . formTrim($iter['seq']) . "', " .
96 "'" . formTrim($iter['default']) . "', " .
97 "'" . $value . "', " .
98 "'" . formTrim($iter['mapping']) . "', " .
99 "'" . formTrim($iter['notes']) . "' " .
105 else if ($_POST['formaction']=='addlist') {
106 // make a new list ID from the new list name
107 $newlistID = $_POST['newlistname'];
108 $newlistID = preg_replace("/\W/", "_", $newlistID);
110 // determine the position of this new list
111 $row = sqlQuery("SELECT max(seq) as maxseq FROM list_options WHERE list_id= 'lists'");
113 // add the new list to the list-of-lists
114 sqlInsert("INSERT INTO list_options ( " .
115 "list_id, option_id, title, seq, is_default, option_value " .
117 "'lists',". // the master list-of-lists
119 "'".$_POST['newlistname']."', ".
120 "'".($row['maxseq']+
1)."',".
124 else if ($_POST['formaction']=='deletelist') {
125 // delete the lists options
126 sqlStatement("DELETE FROM list_options WHERE list_id = '".$_POST['list_id']."'");
127 // delete the list from the master list-of-lists
128 sqlStatement("DELETE FROM list_options WHERE list_id = 'lists' and option_id='".$_POST['list_id']."'");
133 // Given a string of multiple instances of code_type|code|selector,
134 // make a description for each.
135 function getCodeDescriptions($codes) {
137 $arrcodes = explode('~', $codes);
139 foreach ($arrcodes as $codestring) {
140 if ($codestring === '') continue;
141 $arrcode = explode('|', $codestring);
142 $code_type = $arrcode[0];
144 $selector = $arrcode[2];
146 if ($code_type == 'PROD') {
147 $row = sqlQuery("SELECT name FROM drugs WHERE drug_id = '$code' ");
148 $desc = "$code:$selector " . $row['name'];
151 $row = sqlQuery("SELECT code_text FROM codes WHERE " .
152 "code_type = '" . $code_types[$code_type]['id'] . "' AND " .
153 "code = '$code' ORDER BY modifier LIMIT 1");
154 $desc = "$code_type:$code " . ucfirst(strtolower($row['code_text']));
156 $desc = str_replace('~', ' ', $desc);
163 // Write one option line to the form.
165 function writeOptionLine($option_id, $title, $seq, $default, $value, $mapping='', $notes='') {
166 global $opt_line_no, $list_id;
168 $bgcolor = "#" . (($opt_line_no & 1) ?
"ddddff" : "ffdddd");
169 $checked = $default ?
" checked" : "";
171 echo " <tr bgcolor='$bgcolor'>\n";
173 echo " <td align='center' class='optcell'>";
174 echo "<input type='text' name='opt[$opt_line_no][id]' value='" .
175 htmlspecialchars($option_id, ENT_QUOTES
) . "' size='12' maxlength='63' class='optin' />";
178 echo " <td align='center' class='optcell'>";
179 echo "<input type='text' name='opt[$opt_line_no][title]' value='" .
180 htmlspecialchars($title, ENT_QUOTES
) . "' size='20' maxlength='63' class='optin' />";
183 // if not english and translating lists then show the translation
184 if ($GLOBALS['translate_lists'] && $_SESSION['language_choice'] > 1) {
185 echo " <td align='center' class='translation'>" . (htmlspecialchars( xl($title), ENT_QUOTES
)) . "</td>\n";
188 echo " <td align='center' class='optcell'>";
189 echo "<input type='text' name='opt[$opt_line_no][seq]' value='" .
190 htmlspecialchars($seq, ENT_QUOTES
) . "' size='4' maxlength='10' class='optin' />";
193 echo " <td align='center' class='optcell'>";
194 echo "<input type='checkbox' name='opt[$opt_line_no][default]' value='1' " .
195 "onclick='defClicked($opt_line_no)' class='optin'$checked />";
198 // Tax rates and contraceptive methods have an additional attribute.
200 if ($list_id == 'taxrate' ||
$list_id == 'contrameth') {
201 echo " <td align='center' class='optcell'>";
202 echo "<input type='text' name='opt[$opt_line_no][value]' value='" .
203 htmlspecialchars($value, ENT_QUOTES
) . "' size='8' maxlength='15' class='optin' />";
207 // IPPF includes the ability to map each list item to a "master" identifier.
208 // Sports teams use this for some extra info for fitness levels.
210 if ($GLOBALS['ippf_specific'] ||
$list_id == 'fitness') {
211 echo " <td align='center' class='optcell'>";
212 echo "<input type='text' name='opt[$opt_line_no][mapping]' value='" .
213 htmlspecialchars($mapping, ENT_QUOTES
) . "' size='12' maxlength='15' class='optin' />";
217 echo " <td align='center' class='optcell'>";
218 echo "<input type='text' name='opt[$opt_line_no][notes]' value='" .
219 htmlspecialchars($notes, ENT_QUOTES
) . "' size='25' maxlength='255' class='optin' />";
225 // Write a form line as above but for the special case of the Fee Sheet.
227 function writeFSLine($category, $option, $codes) {
231 $bgcolor = "#" . (($opt_line_no & 1) ?
"ddddff" : "ffdddd");
233 $descs = getCodeDescriptions($codes);
235 echo " <tr bgcolor='$bgcolor'>\n";
237 echo " <td align='center' class='optcell'>";
238 echo "<input type='text' name='opt[$opt_line_no][category]' value='" .
239 htmlspecialchars($category, ENT_QUOTES
) . "' size='20' maxlength='63' class='optin' />";
242 echo " <td align='center' class='optcell'>";
243 echo "<input type='text' name='opt[$opt_line_no][option]' value='" .
244 htmlspecialchars($option, ENT_QUOTES
) . "' size='20' maxlength='63' class='optin' />";
247 echo " <td align='left' class='optcell'>";
248 echo " <div id='codelist_$opt_line_no'>";
249 if (strlen($descs)) {
250 $arrdescs = explode('~', $descs);
252 foreach ($arrdescs as $desc) {
253 echo "<a href='' onclick='return delete_code($opt_line_no,$i)' title='" . xl('Delete') . "'>";
254 echo "[x] </a>$desc<br />";
259 echo "<a href='' onclick='return select_code($opt_line_no)'>";
260 echo "[" . xl('Add') . "]</a>";
262 echo "<input type='hidden' name='opt[$opt_line_no][codes]' value='" .
263 htmlspecialchars($codes, ENT_QUOTES
) . "' />";
264 echo "<input type='hidden' name='opt[$opt_line_no][descs]' value='" .
265 htmlspecialchars($descs, ENT_QUOTES
) . "' />";
271 // Helper functions for writeCTLine():
273 function ctGenCell($opt_line_no, $ct_array, $name, $size, $maxlength, $title='') {
274 $value = isset($ct_array[$name]) ?
$ct_array[$name] : '';
275 $s = " <td align='center' class='optcell'";
276 if ($title) $s .= " title='" . addslashes($title) . "'";
278 $s .= "<input type='text' name='opt[$opt_line_no][$name]' value='";
279 $s .= htmlspecialchars($value, ENT_QUOTES
);
280 $s .= "' size='$size' maxlength='$maxlength' class='optin' />";
285 function ctGenCbox($opt_line_no, $ct_array, $name, $title='') {
286 $checked = empty($ct_array[$name]) ?
'' : 'checked ';
287 $s = " <td align='center' class='optcell'";
288 if ($title) $s .= " title='" . addslashes($title) . "'";
290 $s .= "<input type='checkbox' name='opt[$opt_line_no][$name]' value='1' ";
296 // Write a form line as above but for the special case of Code Types.
298 function writeCTLine($ct_array) {
302 $bgcolor = "#" . (($opt_line_no & 1) ?
"ddddff" : "ffdddd");
304 echo " <tr bgcolor='$bgcolor'>\n";
306 echo ctGenCell($opt_line_no, $ct_array, 'ct_key' , 4, 15,
307 xl('Unique human-readable identifier for this type'));
308 echo ctGenCell($opt_line_no, $ct_array, 'ct_id' , 2, 11,
309 xl('Unique numeric identifier for this type'));
310 echo ctGenCell($opt_line_no, $ct_array, 'ct_seq' , 2, 3,
311 xl('Numeric display order'));
312 echo ctGenCell($opt_line_no, $ct_array, 'ct_mod' , 1, 2,
313 xl('Length of modifier, 0 if none'));
314 echo ctGenCell($opt_line_no, $ct_array, 'ct_just', 4, 15,
315 xl('If billing justification is used enter the name of the diagnosis code type.'));
316 echo ctGenCell($opt_line_no, $ct_array, 'ct_mask', 6, 9,
317 xl('Specifies formatting for codes. # = digit, * = any character. Empty if not used.'));
318 echo ctGenCBox($opt_line_no, $ct_array, 'ct_fee',
319 xl('Are fees charged for this type?'));
320 echo ctGenCBox($opt_line_no, $ct_array, 'ct_rel',
321 xl('Does this type allow related codes?'));
322 echo ctGenCBox($opt_line_no, $ct_array, 'ct_nofs',
323 xl('Is this type hidden in the fee sheet?'));
324 echo ctGenCBox($opt_line_no, $ct_array, 'ct_diag',
325 xl('Is this a diagnosis type?'));
333 <?php
html_header_show();?
>
335 <!-- supporting javascript code
-->
336 <script type
="text/javascript" src
="<?php echo $GLOBALS['webroot'] ?>/library/js/jquery.js"></script
>
338 <link rel
="stylesheet" href
='<?php echo $css_header ?>' type
='text/css'>
339 <title
><?php
xl('List Editor','e'); ?
></title
>
342 tr
.head
{ font
-size
:10pt
; background
-color
:#cccccc; text-align:center; }
343 tr
.detail
{ font
-size
:10pt
; }
344 td
{ font
-size
:10pt
; }
345 input
{ font
-size
:10pt
; }
346 a
, a
:visited
, a
:hover
{ color
:#0000cc; }
348 .optin
{ background
-color
:transparent
; }
349 .help
{ cursor
:help
; }
350 .translation
{ color
:green
; }
353 <script type
="text/javascript" src
="../../library/dialog.js"></script
>
355 <script language
="JavaScript">
357 var current_lino
= 0;
359 // Helper function to set the contents of a div.
360 // This is for Fee Sheet administration.
361 function setDivContent(id
, content
) {
362 if (document
.getElementById
) {
363 var x
= document
.getElementById(id
);
365 x
.innerHTML
= content
;
367 else if (document
.all
) {
368 var x
= document
.all
[id
];
369 x
.innerHTML
= content
;
373 // Given a line number, redisplay its descriptive list of codes.
374 // This is for Fee Sheet administration.
375 function displayCodes(lino
) {
376 var f
= document
.forms
[0];
378 var descs
= f
['opt[' + lino +
'][descs]'].value
;
380 var arrdescs
= descs
.split('~');
381 for (var i
= 0; i
< arrdescs
.length
; ++i
) {
382 s +
= "<a href='' onclick='return delete_code(" + lino +
"," + i +
")' title='<?php xl('Delete','e'); ?>'>";
383 s +
= "[x] </a>" + arrdescs
[i
] +
"<br />";
386 setDivContent('codelist_' + lino
, s
);
389 // Helper function to remove a Fee Sheet code.
390 function dc_substring(s
, i
) {
392 var j
= s
.indexOf('~', i
);
393 if (j
< 0) { // deleting last segment
394 if (i
> 0) r
= s
.substring(0, i
-1); // omits trailing ~
396 else { // not last segment
397 r
= s
.substring(0, i
) + s
.substring(j +
1);
402 // Remove a generated Fee Sheet code.
403 function delete_code(lino
, seqno
) {
404 var f
= document
.forms
[0];
405 var celem
= f
['opt[' + lino +
'][codes]'];
406 var delem
= f
['opt[' + lino +
'][descs]'];
409 for (var i
= 0; i
< seqno
; ++i
) {
410 ci
= celem
.value
.indexOf('~', ci
) +
1;
411 di
= delem
.value
.indexOf('~', di
) +
1;
413 celem
.value
= dc_substring(celem
.value
, ci
);
414 delem
.value
= dc_substring(delem
.value
, di
);
419 // This invokes the find-code popup.
420 // For Fee Sheet administration.
421 function select_code(lino
) {
423 dlgopen('../patient_file/encounter/find_code_popup.php', '_blank', 700, 400);
427 // This is for callback by the find-code popup.
428 // For Fee Sheet administration.
429 function set_related(codetype
, code
, selector
, codedesc
) {
430 var f
= document
.forms
[0];
431 var celem
= f
['opt[' + current_lino +
'][codes]'];
432 var delem
= f
['opt[' + current_lino +
'][descs]'];
434 while ((i
= codedesc
.indexOf('~')) >= 0) {
435 codedesc
= codedesc
.substring(0, i
) +
' ' + codedesc
.substring(i+
1);
442 celem
.value +
= codetype +
'|' + code +
'|' + selector
;
443 if (codetype
== 'PROD') delem
.value +
= code +
':' + selector +
' ' + codedesc
;
444 else delem
.value +
= codetype +
':' + code +
' ' + codedesc
;
449 displayCodes(current_lino
);
452 // Called when a "default" checkbox is clicked. Clears all the others.
453 function defClicked(lino
) {
454 var f
= document
.forms
[0];
455 for (var i
= 1; f
['opt[' + i +
'][default]']; ++i
) {
456 if (i
!= lino
) f
['opt[' + i +
'][default]'].checked
= false;
460 // Form validation and submission.
461 // This needs more validation.
462 function mysubmit() {
463 var f
= document
.forms
[0];
464 if (f
.list_id
.value
== 'code_types') {
465 for (var i
= 1; f
['opt[' + i +
'][ct_key]'].value
; ++i
) {
466 var ikey
= 'opt[' + i +
']';
467 for (var j
= i+
1; f
['opt[' + j +
'][ct_key]'].value
; ++j
) {
468 var jkey
= 'opt[' + j +
']';
469 if (f
[ikey+
'[ct_key]'].value
== f
[jkey+
'[ct_key]'].value
) {
470 alert('<?php echo xl('Error
: duplicated name on line
') ?>' +
' ' + j
);
473 if (parseInt(f
[ikey+
'[ct_id]'].value
) == parseInt(f
[jkey+
'[ct_id]'].value
)) {
474 alert('<?php echo xl('Error
: duplicated ID on line
') ?>' +
' ' + j
);
487 <body
class="body_top">
489 <form method
='post' name
='theform' id
='theform' action
='edit_list.php'>
490 <input type
="hidden" name
="formaction" id
="formaction">
492 <p
><b
><?php
xl('Edit list','e'); ?
>:</b
> 
;
493 <select name
='list_id' id
="list_id">
496 // List order depends on language translation options.
497 $lang_id = empty($_SESSION['language_choice']) ?
'1' : $_SESSION['language_choice'];
499 if (($lang_id == '1' && !empty($GLOBALS['skip_english_translation'])) ||
500 !$GLOBALS['translate_lists'])
502 $res = sqlStatement("SELECT option_id, title FROM list_options WHERE " .
503 "list_id = 'lists' ORDER BY title, seq");
506 // Use and sort by the translated list name.
507 $res = sqlStatement("SELECT lo.option_id, " .
508 "IF(LENGTH(ld.definition),ld.definition,lo.title) AS title " .
509 "FROM list_options AS lo " .
510 "LEFT JOIN lang_constants AS lc ON lc.constant_name = lo.title " .
511 "LEFT JOIN lang_definitions AS ld ON ld.cons_id = lc.cons_id AND " .
512 "ld.lang_id = '$lang_id' " .
513 "WHERE lo.list_id = 'lists' " .
514 "ORDER BY IF(LENGTH(ld.definition),ld.definition,lo.title), lo.seq");
517 while ($row = sqlFetchArray($res)) {
518 $key = $row['option_id'];
519 echo "<option value='$key'";
520 if ($key == $list_id) echo " selected";
521 echo ">" . $row['title'] . "</option>\n";
526 <input type
="button" id
="<?php echo $list_id; ?>" class="deletelist" value
=<?php
xl('Delete List','e','\'','\''); ?
>>
527 <input type
="button" id
="newlist" class="newlist" value
=<?php
xl('New List','e','\'','\''); ?
>>
532 <table cellpadding
='2' cellspacing
='0'>
534 <?php
if ($list_id == 'feesheet') { ?
>
535 <td
><b
><?php
xl('Group' ,'e'); ?
></b
></td
>
536 <td
><b
><?php
xl('Option' ,'e'); ?
></b
></td
>
537 <td
><b
><?php
xl('Generates','e'); ?
></b
></td
>
538 <?php
} else if ($list_id == 'code_types') { ?
>
539 <td
><b
><?php
xl('Name' ,'e'); ?
></b
></td
>
540 <td
><b
><?php
xl('ID' ,'e'); ?
></b
></td
>
541 <td
><b
><?php
xl('Seq' ,'e'); ?
></b
></td
>
542 <td
><b
><?php
xl('ModLength' ,'e'); ?
></b
></td
>
543 <td
><b
><?php
xl('Justify' ,'e'); ?
></b
></td
>
544 <td
><b
><?php
xl('Mask' ,'e'); ?
></b
></td
>
545 <td
><b
><?php
xl('Fees' ,'e'); ?
></b
></td
>
546 <td
><b
><?php
xl('Relations' ,'e'); ?
></b
></td
>
547 <td
><b
><?php
xl('Hide' ,'e'); ?
></b
></td
>
548 <td
><b
><?php
xl('Diagnosis' ,'e'); ?
></b
></td
>
550 <td title
=<?php
xl('Click to edit','e','\'','\''); ?
>><b
><?php
xl('ID','e'); ?
></b
></td
>
551 <td
><b
><?php
xl('Title' ,'e'); ?
></b
></td
>
552 <?php
//show translation column if not english and the translation lists flag is set
553 if ($GLOBALS['translate_lists'] && $_SESSION['language_choice'] > 1) {
554 echo "<td><b>".xl('Translation')."</b><span class='help' title='".xl('The translated Title that will appear in current language')."'> (?)</span></td>";
556 <td
><b
><?php
xl('Order' ,'e'); ?
></b
></td
>
557 <td
><b
><?php
xl('Default','e'); ?
></b
></td
>
558 <?php
if ($list_id == 'taxrate') { ?
>
559 <td
><b
><?php
xl('Rate' ,'e'); ?
></b
></td
>
560 <?php
} else if ($list_id == 'contrameth') { ?
>
561 <td
><b
><?php
xl('Effectiveness','e'); ?
></b
></td
>
562 <?php
} else if ($list_id == 'fitness') { ?
>
563 <td
><b
><?php
xl('Color:Abbr','e'); ?
></b
></td
>
564 <?php
} if ($GLOBALS['ippf_specific']) { ?
>
565 <td
><b
><?php
xl('Global ID','e'); ?
></b
></td
>
567 <td
><b
><?php
xl('Notes','e'); ?
></b
></td
>
568 <?php
} // end not fee sheet ?>
572 // Get the selected list's elements.
574 if ($list_id == 'feesheet') {
575 $res = sqlStatement("SELECT * FROM fee_sheet_options " .
576 "ORDER BY fs_category, fs_option");
577 while ($row = sqlFetchArray($res)) {
578 writeFSLine($row['fs_category'], $row['fs_option'], $row['fs_codes']);
580 for ($i = 0; $i < 3; ++
$i) {
581 writeFSLine('', '', '');
584 else if ($list_id == 'code_types') {
585 $res = sqlStatement("SELECT * FROM code_types " .
586 "ORDER BY ct_seq, ct_key");
587 while ($row = sqlFetchArray($res)) {
590 for ($i = 0; $i < 3; ++
$i) {
591 writeCTLine(array());
595 $res = sqlStatement("SELECT * FROM list_options WHERE " .
596 "list_id = '$list_id' ORDER BY seq,title");
597 while ($row = sqlFetchArray($res)) {
598 writeOptionLine($row['option_id'], $row['title'], $row['seq'],
599 $row['is_default'], $row['option_value'], $row['mapping'],
602 for ($i = 0; $i < 3; ++
$i) {
603 writeOptionLine('', '', '', '', 0);
612 <input type
='button' name
='form_save' id
='form_save' value
='<?php xl('Save
','e
'); ?>' />
618 <!-- template DIV that appears when user chooses to make a
new list -->
619 <div id
="newlistdetail" style
="border: 1px solid black; padding: 3px; display: none; visibility: hidden; background-color: lightgrey;">
620 <?php
xl('List Name','e'); ?
>: <input type
="textbox" size
="20" maxlength
="30" name
="newlistname" id
="newlistname">
622 <input type
="button" class="savenewlist" value
=<?php
xl('Save New List','e','\'','\''); ?
>>
623 <input type
="button" class="cancelnewlist" value
=<?php
xl('Cancel','e','\'','\''); ?
>>
626 <script language
="javascript">
627 // jQuery stuff to make the page a little easier to use
629 $
(document
).ready(function(){
630 $
("#form_save").click(function() { SaveChanges(); });
631 $
("#list_id").change(function() { $
('#theform').submit(); });
633 $
(".newlist").click(function() { NewList(this
); });
634 $
(".savenewlist").click(function() { SaveNewList(this
); });
635 $
(".deletelist").click(function() { DeleteList(this
); });
636 $
(".cancelnewlist").click(function() { CancelNewList(this
); });
638 var SaveChanges
= function() {
639 $
("#formaction").val("save");
640 // $('#theform').submit();
644 // show the DIV to create a new list
645 var NewList
= function(btnObj
) {
646 // show the field details DIV
647 $
('#newlistdetail').css('visibility', 'visible');
648 $
('#newlistdetail').css('display', 'block');
649 $
(btnObj
).parent().append($
("#newlistdetail"));
650 $
('#newlistdetail > #newlistname').focus();
653 var SaveNewList
= function() {
654 // the list name can only have letters, numbers, spaces and underscores
655 // AND it cannot start with a number
656 if ($
("#newlistname").val().match(/^\d+
/)) {
657 alert("<?php xl('List names cannot start with numbers.','e'); ?>");
660 var validname
= $
("#newlistname").val().replace(/[^A
-za
-z0
-9 -]/g
, "_"); // match any non-word characters and replace them
661 if (validname
!= $
("#newlistname").val()) {
662 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',''); ?>"))
667 $
("#newlistname").val(validname
);
669 // submit the form to add a new field to a specific group
670 $
("#formaction").val("addlist");
671 $
("#theform").submit();
673 // actually delete an entire list from the database
674 var DeleteList
= function(btnObj
) {
675 var listid
= $
(btnObj
).attr("id");
676 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+
")?")) {
677 // submit the form to add a new field to a specific group
678 $
("#formaction").val("deletelist");
679 $
("#deletelistname").val(listid
);
680 $
("#theform").submit();
684 // just hide the new list DIV
685 var CancelNewList
= function(btnObj
) {
686 // hide the list details DIV
687 $
('#newlistdetail').css('visibility', 'hidden');
688 $
('#newlistdetail').css('display', 'none');
689 // reset the new group values to a default
690 $
('#newlistdetail > #newlistname').val("");