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/log.inc");
12 require_once("$srcdir/formdata.inc.php");
15 'DEM' => xl('Demographics'),
16 'HIS' => xl('History'),
17 'REF' => xl('Referrals'),
19 if ($GLOBALS['ippf_specific']) {
20 $layouts['GCA'] = xl('Abortion Issues');
21 $layouts['CON'] = xl('Contraception Issues');
22 // $layouts['SRH'] = xl('SRH Visit Form');
25 // Include Layout Based Encounter Forms.
26 $lres = sqlStatement("SELECT * FROM list_options " .
27 "WHERE list_id = 'lbfnames' ORDER BY seq, title");
28 while ($lrow = sqlFetchArray($lres)) {
29 $layouts[$lrow['option_id']] = $lrow['title'];
32 // array of the data_types of the fields
34 "1" => xl("List box"),
36 "3" => xl("Textarea"),
37 "4" => xl("Text-date"),
38 "10" => xl("Providers"),
39 "11" => xl("Providers NPI"),
40 "12" => xl("Pharmacies"),
42 "14" => xl("Organizations"),
43 "15" => xl("Billing codes"),
44 "21" => xl("Checkbox list"),
45 "22" => xl("Textbox list"),
46 "23" => xl("Exam results"),
47 "24" => xl("Patient allergies"),
48 "25" => xl("Checkbox w/text"),
49 "26" => xl("List box w/add"),
50 "27" => xl("Radio buttons"),
51 "28" => xl("Lifestyle status"),
52 "31" => xl("Static Text"),
53 "32" => xl("Smoking Status"),
54 "33" => xl("Race and Ethnicity"),
55 "34" => xl("NationNotes"),
58 function nextGroupOrder($order) {
59 if ($order == '9') $order = 'A';
60 else if ($order == 'Z') $order = 'a';
61 else $order = chr(ord($order) +
1);
65 // Check authorization.
66 $thisauth = acl_check('admin', 'super');
67 if (!$thisauth) die(xl('Not authorized'));
69 // The layout ID identifies the layout to be edited.
70 $layout_id = empty($_REQUEST['layout_id']) ?
'' : $_REQUEST['layout_id'];
72 // Handle the Form actions
74 if ($_POST['formaction'] == "save" && $layout_id) {
75 // If we are saving, then save.
77 for ($lino = 1; isset($fld[$lino]['id']); ++
$lino) {
79 $field_id = formTrim($iter['id']);
80 $data_type = formTrim($iter['data_type']);
81 // For a textarea (data type 3) max_length has a special meaning, to
82 // specify its height (in rows). This kludge assigns a fixed height,
83 // but this GUI really needs to support max_length directly.
84 $max_length = $data_type == 3 ?
3 : 255;
85 $listval = $data_type == 34 ?
formTrim($iter['contextName']) : formTrim($iter['list_id']);
87 sqlStatement("UPDATE layout_options SET " .
88 "title = '" . formTrim($iter['title']) . "', " .
89 "group_name = '" . formTrim($iter['group']) . "', " .
90 "seq = '" . formTrim($iter['seq']) . "', " .
91 "uor = '" . formTrim($iter['uor']) . "', " .
92 "fld_length = '" . formTrim($iter['length']) . "', " .
93 "max_length = '$max_length', " .
94 "titlecols = '" . formTrim($iter['titlecols']) . "', " .
95 "datacols = '" . formTrim($iter['datacols']) . "', " .
96 "data_type= '$data_type', " .
97 "list_id= '" . $listval . "', " .
98 "edit_options = '" . formTrim($iter['edit_options']) . "', " .
99 "default_value = '" . formTrim($iter['default']) . "', " .
100 "description = '" . formTrim($iter['desc']) . "' " .
101 "WHERE form_id = '$layout_id' AND field_id = '$field_id'");
106 else if ($_POST['formaction'] == "addfield" && $layout_id) {
107 // Add a new field to a specific group
108 $data_type = formTrim($_POST['newdatatype']);
109 $max_length = $data_type == 3 ?
3 : 255;
110 $listval = $data_type == 34 ?
formTrim($_POST['contextName']) : formTrim($_POST['newlistid']);
111 sqlStatement("INSERT INTO layout_options (" .
112 " form_id, field_id, title, group_name, seq, uor, fld_length" .
113 ", titlecols, datacols, data_type, edit_options, default_value, description" .
114 ", max_length, list_id " .
116 "'" . formTrim($_POST['layout_id'] ) . "'" .
117 ",'" . formTrim($_POST['newid'] ) . "'" .
118 ",'" . formTrim($_POST['newtitle'] ) . "'" .
119 ",'" . formTrim($_POST['newfieldgroupid']) . "'" .
120 ",'" . formTrim($_POST['newseq'] ) . "'" .
121 ",'" . formTrim($_POST['newuor'] ) . "'" .
122 ",'" . formTrim($_POST['newlength'] ) . "'" .
123 ",'" . formTrim($_POST['newtitlecols'] ) . "'" .
124 ",'" . formTrim($_POST['newdatacols'] ) . "'" .
126 ",'" . formTrim($_POST['newedit_options']) . "'" .
127 ",'" . formTrim($_POST['newdefault'] ) . "'" .
128 ",'" . formTrim($_POST['newdesc'] ) . "'" .
130 ",'" . $listval . "'" .
133 if (substr($layout_id,0,3) != 'LBF') {
134 // Add the field to the table too (this is critical)
135 if ($layout_id == "DEM") { $tablename = "patient_data"; }
136 else if ($layout_id == "HIS") { $tablename = "history_data"; }
137 else if ($layout_id == "REF") { $tablename = "transactions"; }
138 else if ($layout_id == "SRH") { $tablename = "lists_ippf_srh"; }
139 else if ($layout_id == "CON") { $tablename = "lists_ippf_con"; }
140 else if ($layout_id == "GCA") { $tablename = "lists_ippf_gcac"; }
141 sqlStatement("ALTER TABLE `" . $tablename . "` ADD ".
142 "`" . formTrim($_POST['newid']) . "`" .
144 newEvent("alter_table", $_SESSION['authUser'], $_SESSION['authProvider'], 1,
145 $tablename . " ADD " . formTrim($_POST['newid']));
149 else if ($_POST['formaction'] == "movefields" && $layout_id) {
150 // Move field(s) to a new group in the layout
151 $sqlstmt = "UPDATE layout_options SET ".
152 " group_name='". $_POST['targetgroup']."' ".
154 " form_id = '".$_POST['layout_id']."' ".
155 " AND field_id IN (";
157 foreach (explode(" ", $_POST['selectedfields']) as $onefield) {
158 $sqlstmt .= $comma."'".$onefield."'";
163 sqlStatement($sqlstmt);
166 else if ($_POST['formaction'] == "deletefields" && $layout_id) {
167 // Delete a field from a specific group
168 $sqlstmt = "DELETE FROM layout_options WHERE ".
169 " form_id = '".$_POST['layout_id']."' ".
170 " AND field_id IN (";
172 foreach (explode(" ", $_POST['selectedfields']) as $onefield) {
173 $sqlstmt .= $comma."'".$onefield."'";
177 sqlStatement($sqlstmt);
179 if (substr($layout_id,0,3) != 'LBF') {
180 // drop the field from the table too (this is critical)
181 if ($layout_id == "DEM") { $tablename = "patient_data"; }
182 else if ($layout_id == "HIS") { $tablename = "history_data"; }
183 else if ($layout_id == "REF") { $tablename = "transactions"; }
184 else if ($layout_id == "SRH") { $tablename = "lists_ippf_srh"; }
185 else if ($layout_id == "CON") { $tablename = "lists_ippf_con"; }
186 else if ($layout_id == "GCA") { $tablename = "lists_ippf_gcac"; }
187 foreach (explode(" ", $_POST['selectedfields']) as $onefield) {
188 sqlStatement("ALTER TABLE `".$tablename."` DROP `".$onefield."`");
189 newEvent("alter_table", $_SESSION['authUser'], $_SESSION['authProvider'], 1, $tablename." DROP ".$onefield);
194 else if ($_POST['formaction'] == "addgroup" && $layout_id) {
195 // all group names are prefixed with a number indicating their display order
196 // this new group is prefixed with the net highest number given the
198 $results = sqlStatement("select distinct(group_name) as gname ".
199 " from layout_options where ".
200 " form_id = '".$_POST['layout_id']."'"
203 while ($result = sqlFetchArray($results)) {
204 $tmp = substr($result['gname'], 0, 1);
205 if ($tmp >= $maxnum) $maxnum = nextGroupOrder($tmp);
208 $data_type = formTrim($_POST['gnewdatatype']);
209 $max_length = $data_type == 3 ?
3 : 255;
210 $listval = $data_type == 34 ?
formTrim($_POST['gcontextName']) : formTrim($_POST['gnewlistid']);
211 // add a new group to the layout, with the defined field
212 sqlStatement("INSERT INTO layout_options (" .
213 " form_id, field_id, title, group_name, seq, uor, fld_length" .
214 ", titlecols, datacols, data_type, edit_options, default_value, description" .
215 ", max_length, list_id " .
217 "'" . formTrim($_POST['layout_id'] ) . "'" .
218 ",'" . formTrim($_POST['gnewid'] ) . "'" .
219 ",'" . formTrim($_POST['gnewtitle'] ) . "'" .
220 ",'" . formTrim($maxnum . $_POST['newgroupname']) . "'" .
221 ",'" . formTrim($_POST['gnewseq'] ) . "'" .
222 ",'" . formTrim($_POST['gnewuor'] ) . "'" .
223 ",'" . formTrim($_POST['gnewlength'] ) . "'" .
224 ",'" . formTrim($_POST['gnewtitlecols'] ) . "'" .
225 ",'" . formTrim($_POST['gnewdatacols'] ) . "'" .
227 ",'" . formTrim($_POST['gnewedit_options']) . "'" .
228 ",'" . formTrim($_POST['gnewdefault'] ) . "'" .
229 ",'" . formTrim($_POST['gnewdesc'] ) . "'" .
231 ",'" . $listval . "'" .
234 if (substr($layout_id,0,3) != 'LBF') {
235 // Add the field to the table too (this is critical)
236 if ($layout_id == "DEM") { $tablename = "patient_data"; }
237 else if ($layout_id == "HIS") { $tablename = "history_data"; }
238 else if ($layout_id == "REF") { $tablename = "transactions"; }
239 else if ($layout_id == "SRH") { $tablename = "lists_ippf_srh"; }
240 else if ($layout_id == "CON") { $tablename = "lists_ippf_con"; }
241 else if ($layout_id == "GCA") { $tablename = "lists_ippf_gcac"; }
242 sqlStatement("ALTER TABLE `" . $tablename . "` ADD ".
243 "`" . formTrim($_POST['gnewid']) . "`" .
245 newEvent("alter_table", $_SESSION['authUser'], $_SESSION['authProvider'], 1,
246 $tablename . " ADD " . formTrim($_POST['gnewid']));
250 else if ($_POST['formaction'] == "deletegroup" && $layout_id) {
251 // drop the fields from the related table (this is critical)
252 if (substr($layout_id,0,3) != 'LBF') {
253 $res = sqlStatement("SELECT field_id FROM layout_options WHERE " .
254 " form_id = '".$_POST['layout_id']."' ".
255 " AND group_name = '".$_POST['deletegroupname']."'"
257 while ($row = sqlFetchArray($res)) {
258 // drop the field from the table too (this is critical)
259 if ($layout_id == "DEM") { $tablename = "patient_data"; }
260 else if ($layout_id == "HIS") { $tablename = "history_data"; }
261 else if ($layout_id == "REF") { $tablename = "transactions"; }
262 else if ($layout_id == "SRH") { $tablename = "lists_ippf_srh"; }
263 else if ($layout_id == "CON") { $tablename = "lists_ippf_con"; }
264 else if ($layout_id == "GCA") { $tablename = "lists_ippf_gcac"; }
265 sqlStatement("ALTER TABLE `".$tablename."` DROP `".$row['field_id']."`");
266 newEvent("alter_table", $_SESSION['authUser'], $_SESSION['authProvider'], 1, $tablename." DROP ".trim($row['field_id']));
270 // Delete an entire group from the form
271 sqlStatement("DELETE FROM layout_options WHERE ".
272 " form_id = '".$_POST['layout_id']."' ".
273 " AND group_name = '".$_POST['deletegroupname']."'"
277 else if ($_POST['formaction'] == "movegroup" && $layout_id) {
278 $results = sqlStatement("SELECT DISTINCT(group_name) AS gname " .
279 "FROM layout_options WHERE form_id = '$layout_id' " .
283 while ($result = sqlFetchArray($results)) {
284 if ($result['gname'] == $_POST['movegroupname']) {
285 if ($_POST['movedirection'] == 'up') { // moving up
287 $garray[$i] = $garray[$i - 1];
288 $garray[$i - 1] = $result['gname'];
292 $garray[$i++
] = $result['gname'];
295 else { // moving down
297 $garray[$i++
] = $result['gname'];
300 else if ($i > 1 && $garray[$i - 2] == '') {
301 $garray[$i - 2] = $result['gname'];
304 $garray[$i++
] = $result['gname'];
308 foreach ($garray as $value) {
309 if ($value === '') continue;
310 $newname = $nextord . substr($value, 1);
311 sqlStatement("UPDATE layout_options SET " .
312 "group_name = '$newname' WHERE " .
313 "form_id = '$layout_id' AND " .
314 "group_name = '$value'");
315 $nextord = nextGroupOrder($nextord);
319 else if ($_POST['formaction'] == "renamegroup" && $layout_id) {
320 $currpos = substr($_POST['renameoldgroupname'], 0, 1);
321 // update the database rows
322 sqlStatement("UPDATE layout_options SET " .
323 "group_name = '" . $currpos . $_POST['renamegroupname'] . "' ".
324 "WHERE form_id = '$layout_id' AND ".
325 "group_name = '" . $_POST['renameoldgroupname'] . "'");
328 // Get the selected form's elements.
330 $res = sqlStatement("SELECT * FROM layout_options WHERE " .
331 "form_id = '$layout_id' ORDER BY group_name, seq");
334 // global counter for field numbers
337 // Write one option line to the form.
339 function writeFieldLine($linedata) {
342 $checked = $linedata['default_value'] ?
" checked" : "";
344 //echo " <tr bgcolor='$bgcolor'>\n";
345 echo " <tr id='fld[$fld_line_no]' class='".($fld_line_no %
2 ?
'even' : 'odd')."'>\n";
347 echo " <td class='optcell' nowrap>";
348 // tuck the group_name INPUT in here
349 echo "<input type='hidden' name='fld[$fld_line_no][group]' value='" .
350 htmlspecialchars($linedata['group_name'], ENT_QUOTES
) . "' class='optin' />";
352 echo "<input type='checkbox' class='selectfield' ".
353 "name='".$linedata['group_name']."~".$linedata['field_id']."' ".
354 "id='".$linedata['group_name']."~".$linedata['field_id']."' ".
355 "title='".htmlspecialchars(xl('Select field', ENT_QUOTES
))."'>";
357 echo "<input type='text' name='fld[$fld_line_no][seq]' id='fld[$fld_line_no][seq]' value='" .
358 htmlspecialchars($linedata['seq'], ENT_QUOTES
) . "' size='2' maxlength='3' class='optin' />";
361 echo " <td align='left' class='optcell'>";
362 echo "<input type='text' name='fld[$fld_line_no][id]' value='" .
363 htmlspecialchars($linedata['field_id'], ENT_QUOTES
) . "' size='15' maxlength='63' class='optin noselect' />";
365 echo "<input type='hidden' name='fld[$fld_line_no][id]' value='" .
366 htmlspecialchars($linedata['field_id'], ENT_QUOTES) . "' />";
367 echo htmlspecialchars($linedata['field_id'], ENT_QUOTES);
371 echo " <td align='center' class='optcell'>";
372 echo "<input type='text' id='fld[$fld_line_no][title]' name='fld[$fld_line_no][title]' value='" .
373 htmlspecialchars($linedata['title'], ENT_QUOTES
) . "' size='15' maxlength='63' class='optin' />";
376 // if not english and set to translate layout labels, then show the translation
377 if ($GLOBALS['translate_layout'] && $_SESSION['language_choice'] > 1) {
378 echo "<td align='center' class='translation'>" . htmlspecialchars(xl($linedata['title']), ENT_QUOTES
) . "</td>\n";
381 echo " <td align='center' class='optcell'>";
382 echo "<select name='fld[$fld_line_no][uor]' class='optin'>";
383 foreach (array(0 =>xl('Unused'), 1 =>xl('Optional'), 2 =>xl('Required')) as $key => $value) {
384 echo "<option value='$key'";
385 if ($key == $linedata['uor']) echo " selected";
386 echo ">$value</option>\n";
391 echo " <td align='center' class='optcell'>";
392 echo "<select name='fld[$fld_line_no][data_type]' id='fld[$fld_line_no][data_type]' onchange=NationNotesContext('".$fld_line_no."',this.value)>";
393 echo "<option value=''></option>";
395 foreach ($datatypes as $key=>$value) {
396 if ($linedata['data_type'] == $key)
397 echo "<option value='$key' selected>$value</option>";
399 echo "<option value='$key'>$value</option>";
404 echo " <td align='center' class='optcell'>";
405 if ($linedata['data_type'] == 2 ||
$linedata['data_type'] == 3 ||
406 $linedata['data_type'] == 21 ||
$linedata['data_type'] == 22 ||
407 $linedata['data_type'] == 23 ||
$linedata['data_type'] == 25 ||
408 $linedata['data_type'] == 27 ||
$linedata['data_type'] == 28 ||
409 $linedata['data_type'] == 32)
411 echo "<input type='text' name='fld[$fld_line_no][length]' value='" .
412 htmlspecialchars($linedata['fld_length'], ENT_QUOTES
) .
413 "' size='1' maxlength='10' class='optin' />";
416 // all other data_types
417 echo "<input type='hidden' name='fld[$fld_line_no][length]' value=''>";
421 echo " <td align='center' class='optcell'>";
422 if ($linedata['data_type'] == 1 ||
$linedata['data_type'] == 21 ||
423 $linedata['data_type'] == 22 ||
$linedata['data_type'] == 23 ||
424 $linedata['data_type'] == 25 ||
$linedata['data_type'] == 26 ||
425 $linedata['data_type'] == 27 ||
$linedata['data_type'] == 32 ||
426 $linedata['data_type'] == 33 ||
$linedata['data_type'] == 34)
429 $disp = "style='display:none'";
430 if($linedata['data_type'] == 34){
431 $type = "style='display:none'";
434 echo "<input type='text' name='fld[$fld_line_no][list_id]' id='fld[$fld_line_no][list_id]' value='" .
435 htmlspecialchars($linedata['list_id'], ENT_QUOTES
) . "'".$type.
436 " size='6' maxlength='30' class='optin listid' style='cursor: pointer'".
437 "title='". xl('Choose list') . "' />";
439 echo "<select name='fld[$fld_line_no][contextName]' id='fld[$fld_line_no][contextName]' ".$disp.">";
440 $res = sqlStatement("SELECT * FROM customlists WHERE cl_list_type=2 AND cl_deleted=0");
441 while($row = sqlFetchArray($res)){
443 if ($linedata['list_id'] == $row['cl_list_item_long'])
445 echo "<option value='".htmlspecialchars($row['cl_list_item_long'],ENT_QUOTES
)."' ".$sel.">".htmlspecialchars($row['cl_list_item_long'],ENT_QUOTES
)."</option>";
450 // all other data_types
451 echo "<input type='hidden' name='fld[$fld_line_no][list_id]' value=''>";
455 echo " <td align='center' class='optcell'>";
456 echo "<input type='text' name='fld[$fld_line_no][titlecols]' value='" .
457 htmlspecialchars($linedata['titlecols'], ENT_QUOTES
) . "' size='3' maxlength='10' class='optin' />";
460 echo " <td align='center' class='optcell'>";
461 echo "<input type='text' name='fld[$fld_line_no][datacols]' value='" .
462 htmlspecialchars($linedata['datacols'], ENT_QUOTES
) . "' size='3' maxlength='10' class='optin' />";
465 echo " <td align='center' class='optcell' title='C = " . xl('Capitalize') .
466 ", D = " . xl('Dup Check') . ", G = " . xl('Graphable') .
467 ", N = " . xl('New Patient Form') . ", O = " . xl('Order Processor') .
468 ", V = " . xl('Vendor') . "'>";
469 echo "<input type='text' name='fld[$fld_line_no][edit_options]' value='" .
470 htmlspecialchars($linedata['edit_options'], ENT_QUOTES
) . "' size='3' maxlength='36' class='optin' />";
473 /*****************************************************************
474 echo " <td align='center' class='optcell'>";
475 if ($linedata['data_type'] == 2) {
476 echo "<input type='text' name='fld[$fld_line_no][default]' value='" .
477 htmlspecialchars($linedata['default_value'], ENT_QUOTES) . "' size='10' maxlength='63' class='optin' />";
483 echo " <td align='center' class='optcell'>";
484 echo "<input type='text' name='fld[$fld_line_no][desc]' value='" .
485 htmlspecialchars($linedata['description'], ENT_QUOTES) . "' size='20' maxlength='63' class='optin' />";
488 // if not english and showing layout labels, then show the translation of Description
489 if ($GLOBALS['translate_layout'] && $_SESSION['language_choice'] > 1) {
490 echo "<td align='center' class='translation'>" . htmlspecialchars(xl($linedata['description']), ENT_QUOTES) . "</td>\n";
492 *****************************************************************/
494 if ($linedata['data_type'] == 31) {
495 echo " <td align='center' class='optcell'>";
496 echo "<textarea name='fld[$fld_line_no][desc]' rows='3' cols='35' class='optin'>" .
497 $linedata['description'] . "</textarea>";
498 echo "<input type='hidden' name='fld[$fld_line_no][default]' value='" .
499 htmlspecialchars($linedata['default_value'], ENT_QUOTES
) . "' />";
503 echo " <td align='center' class='optcell'>";
504 echo "<input type='text' name='fld[$fld_line_no][desc]' value='" .
505 htmlspecialchars($linedata['description'], ENT_QUOTES
) .
506 "' size='30' maxlength='63' class='optin' />";
507 echo "<input type='hidden' name='fld[$fld_line_no][default]' value='" .
508 htmlspecialchars($linedata['default_value'], ENT_QUOTES
) . "' />";
510 // if not english and showing layout labels, then show the translation of Description
511 if ($GLOBALS['translate_layout'] && $_SESSION['language_choice'] > 1) {
512 echo "<td align='center' class='translation'>" .
513 htmlspecialchars(xl($linedata['description']), ENT_QUOTES
) . "</td>\n";
523 <?php
html_header_show();?
>
525 <!-- supporting javascript code
-->
526 <script type
="text/javascript" src
="<?php echo $GLOBALS['webroot'] ?>/library/js/jquery.js"></script
>
528 <link rel
="stylesheet" href
='<?php echo $css_header ?>' type
='text/css'>
530 <title
><?php
xl('Layout Editor','e'); ?
></title
>
533 tr
.head
{ font
-size
:10pt
; background
-color
:#cccccc; }
534 tr
.detail
{ font
-size
:10pt
; }
535 td
{ font
-size
:10pt
; }
536 input
{ font
-size
:10pt
; }
537 a
, a
:visited
, a
:hover
{ color
:#0000cc; }
539 .optin
{ background
: transparent
; }
541 margin
: 0pt
0pt
8pt
0pt
;
546 border
-collapse
: collapse
;
550 background
-color
: #ddddff;
551 padding
: 3px
0px
3px
0px
;
554 background
-color
: #ffdddd;
555 padding
: 3px
0px
3px
0px
;
557 .help
{ cursor
: help
; }
558 .layouts_title
{ font
-size
: 110%
; }
564 border
: 2px solid blue
;
565 background
-color
: yellow
;
572 <body
class="body_top">
574 <form method
='post' name
='theform' id
='theform' action
='edit_layout.php'>
575 <input type
="hidden" name
="formaction" id
="formaction" value
="">
576 <!-- elements used to identify a field to delete
-->
577 <input type
="hidden" name
="deletefieldid" id
="deletefieldid" value
="">
578 <input type
="hidden" name
="deletefieldgroup" id
="deletefieldgroup" value
="">
579 <!-- elements used to identify a group to delete
-->
580 <input type
="hidden" name
="deletegroupname" id
="deletegroupname" value
="">
581 <!-- elements used to change the group order
-->
582 <input type
="hidden" name
="movegroupname" id
="movegroupname" value
="">
583 <input type
="hidden" name
="movedirection" id
="movedirection" value
="">
584 <!-- elements used to select more than one field
-->
585 <input type
="hidden" name
="selectedfields" id
="selectedfields" value
="">
586 <input type
="hidden" id
="targetgroup" name
="targetgroup" value
="">
588 <p
><b
><?php
xl('Edit layout','e'); ?
>:</b
> 
;
589 <select name
='layout_id' id
='layout_id'>
590 <option value
=''>-- <?php
echo xl('Select') ?
> --</option
>
592 foreach ($layouts as $key => $value) {
593 echo " <option value='$key'";
594 if ($key == $layout_id) echo " selected";
595 echo ">$value</option>\n";
600 <?php
if ($layout_id) { ?
>
601 <div style
='margin: 0 0 8pt 0;'>
602 <input type
='button' class='addgroup' id
='addgroup' value
=<?php
xl('Add Group','e','\'','\''); ?
>/>
607 $prevgroup = "!@#asdf1234"; // an unlikely group name
608 $firstgroup = true; // flag indicates it's the first group to be displayed
609 while ($row = sqlFetchArray($res)) {
610 if ($row['group_name'] != $prevgroup) {
611 if ($firstgroup == false) { echo "</tbody></table></div>\n"; }
612 echo "<div id='".$row['group_name']."' class='group'>";
613 echo "<div class='text bold layouts_title' style='position:relative; background-color: #eef'>";
614 // echo preg_replace("/^\d+/", "", $row['group_name']);
615 echo substr($row['group_name'], 1);
617 // if not english and set to translate layout labels, then show the translation of group name
618 if ($GLOBALS['translate_layout'] && $_SESSION['language_choice'] > 1) {
619 // echo "<span class='translation'>>> " . xl(preg_replace("/^\d+/", "", $row['group_name'])) . "</span>";
620 echo "<span class='translation'>>> " . xl(substr($row['group_name'], 1)) . "</span>";
624 echo " <input type='button' class='addfield' id='addto~".$row['group_name']."' value='" . xl('Add Field') . "'/>";
625 echo " ";
626 echo " <input type='button' class='renamegroup' id='".$row['group_name']."' value='" . xl('Rename Group') . "'/>";
627 echo " ";
628 echo " <input type='button' class='deletegroup' id='".$row['group_name']."' value='" . xl('Delete Group') . "'/>";
629 echo " ";
630 echo " <input type='button' class='movegroup' id='".$row['group_name']."~up' value='" . xl('Move Up') . "'/>";
631 echo " ";
632 echo " <input type='button' class='movegroup' id='".$row['group_name']."~down' value='" . xl('Move Down') . "'/>";
640 <th
><?php
xl('Order','e'); ?
></th
>
641 <th
><?php
xl('ID','e'); ?
> <span
class="help" title
=<?php
xl('A unique value to identify this field, not visible to the user','e','\'','\''); ?
> >(?
)</span
></th
>
642 <th
><?php
xl('Label','e'); ?
> <span
class="help" title
=<?php
xl('The label that appears to the user on the form','e','\'','\''); ?
> >(?
)</span
></th
>
643 <?php
// if not english and showing layout label translations, then show translation header for title
644 if ($GLOBALS['translate_layout'] && $_SESSION['language_choice'] > 1) {
645 echo "<th>" . xl('Translation')."<span class='help' title='" . xl('The translated label that will appear on the form in current language') . "'> (?)</span></th>";
647 <th
><?php
xl('UOR','e'); ?
></th
>
648 <th
><?php
xl('Data Type','e'); ?
></th
>
649 <th
><?php
xl('Size','e'); ?
></th
>
650 <th
><?php
xl('List','e'); ?
></th
>
651 <th
><?php
xl('Label Cols','e'); ?
></th
>
652 <th
><?php
xl('Data Cols','e'); ?
></th
>
653 <th
><?php
xl('Options','e'); ?
></th
>
654 <th
><?php
xl('Description','e'); ?
></th
>
655 <?php
// if not english and showing layout label translations, then show translation header for description
656 if ($GLOBALS['translate_layout'] && $_SESSION['language_choice'] > 1) {
657 echo "<th>" . xl('Translation')."<span class='help' title='" . xl('The translation of description in current language')."'> (?)</span></th>";
664 } // end if-group_name
666 writeFieldLine($row);
667 $prevgroup = $row['group_name'];
675 <?php
if ($layout_id) { ?
>
676 <span style
="font-size:90%">
677 <?php
xl('With selected:', 'e');?
>
678 <input type
='button' name
='deletefields' id
='deletefields' value
='<?php xl('Delete
','e
'); ?>' style
="font-size:90%" disabled
="disabled" />
679 <input type
='button' name
='movefields' id
='movefields' value
='<?php xl('Move to
...','e
'); ?>' style
="font-size:90%" disabled
="disabled" />
682 <input type
='button' name
='save' id
='save' value
='<?php xl('Save Changes
','e
'); ?>' />
688 <!-- template DIV that appears when user chooses to rename an existing group
-->
689 <div id
="renamegroupdetail" style
="border: 1px solid black; padding: 3px; display: none; visibility: hidden; background-color: lightgrey;">
690 <input type
="hidden" name
="renameoldgroupname" id
="renameoldgroupname" value
="">
691 <?php
xl('Group Name','e'); ?
>: <input type
="textbox" size
="20" maxlength
="30" name
="renamegroupname" id
="renamegroupname">
693 <input type
="button" class="saverenamegroup" value
=<?php
xl('Rename Group','e','\'','\''); ?
>>
694 <input type
="button" class="cancelrenamegroup" value
=<?php
xl('Cancel','e','\'','\''); ?
>>
697 <!-- template DIV that appears when user chooses to add a
new group
-->
698 <div id
="groupdetail" style
="border: 1px solid black; padding: 3px; display: none; visibility: hidden; background-color: lightgrey;">
700 <?php
xl('Group Name','e'); ?
>: <input type
="textbox" size
="20" maxlength
="30" name
="newgroupname" id
="newgroupname">
702 <table style
="border-collapse: collapse; margin-top: 5px;">
705 <th
><?php
xl('Order','e'); ?
></th
>
706 <th
><?php
xl('ID','e'); ?
> <span
class="help" title
=<?php
xl('A unique value to identify this field, not visible to the user','e','\'','\''); ?
> >(?
)</span
></th
>
707 <th
><?php
xl('Label','e'); ?
> <span
class="help" title
=<?php
xl('The label that appears to the user on the form','e','\'','\''); ?
> >(?
)</span
></th
>
708 <th
><?php
xl('UOR','e'); ?
></th
>
709 <th
><?php
xl('Data Type','e'); ?
></th
>
710 <th
><?php
xl('Size','e'); ?
></th
>
711 <th
><?php
xl('List','e'); ?
></th
>
712 <th
><?php
xl('Label Cols','e'); ?
></th
>
713 <th
><?php
xl('Data Cols','e'); ?
></th
>
714 <th
><?php
xl('Options','e'); ?
></th
>
715 <th
><?php
xl('Description','e'); ?
></th
>
720 <td
><input type
="textbox" name
="gnewseq" id
="gnewseq" value
="" size
="2" maxlength
="3"> </td
>
721 <td
><input type
="textbox" name
="gnewid" id
="gnewid" value
="" size
="10" maxlength
="20"> </td
>
722 <td
><input type
="textbox" name
="gnewtitle" id
="gnewtitle" value
="" size
="20" maxlength
="63"> </td
>
724 <select name
="gnewuor" id
="gnewuor">
725 <option value
="0"><?php
xl('Unused','e'); ?
></option
>
726 <option value
="1" selected
><?php
xl('Optional','e'); ?
></option
>
727 <option value
="2"><?php
xl('Required','e'); ?
></option
>
731 <select name
='gnewdatatype' id
='gnewdatatype'>
732 <option value
=''></option
>
735 foreach ($datatypes as $key=>$value) {
736 echo "<option value='$key'>$value</option>";
741 <td
><input type
="textbox" name
="gnewlength" id
="gnewlength" value
="" size
="1" maxlength
="3"> </td
>
742 <td
><input type
="textbox" name
="gnewlistid" id
="gnewlistid" value
="" size
="8" maxlength
="31" class="listid">
743 <select name
='gcontextName' id
='gcontextName' style
='display:none'>
745 $res = sqlStatement("SELECT * FROM customlists WHERE cl_list_type=2 AND cl_deleted=0");
746 while($row = sqlFetchArray($res)){
747 echo "<option value='".htmlspecialchars($row['cl_list_item_long'],ENT_QUOTES
)."'>".htmlspecialchars($row['cl_list_item_long'],ENT_QUOTES
)."</option>";
752 <td
><input type
="textbox" name
="gnewtitlecols" id
="gnewtitlecols" value
="" size
="3" maxlength
="3"> </td
>
753 <td
><input type
="textbox" name
="gnewdatacols" id
="gnewdatacols" value
="" size
="3" maxlength
="3"> </td
>
754 <td
><input type
="textbox" name
="gnewedit_options" id
="gnewedit_options" value
="" size
="3" maxlength
="36">
755 <input type
="hidden" name
="gnewdefault" id
="gnewdefault" value
="" /> </td
>
756 <td
><input type
="textbox" name
="gnewdesc" id
="gnewdesc" value
="" size
="30" maxlength
="63"> </td
>
761 <input type
="button" class="savenewgroup" value
=<?php
xl('Save New Group','e','\'','\''); ?
>>
762 <input type
="button" class="cancelnewgroup" value
=<?php
xl('Cancel','e','\'','\''); ?
>>
766 <!-- template DIV that appears when user chooses to add a
new field to a group
-->
767 <div id
="fielddetail" class="fielddetail" style
="display: none; visibility: hidden">
768 <input type
="hidden" name
="newfieldgroupid" id
="newfieldgroupid" value
="">
769 <table style
="border-collapse: collapse;">
772 <th
><?php
xl('Order','e'); ?
></th
>
773 <th
><?php
xl('ID','e'); ?
> <span
class="help" title
=<?php
xl('A unique value to identify this field, not visible to the user','e','\'','\''); ?
> >(?
)</span
></th
>
774 <th
><?php
xl('Label','e'); ?
> <span
class="help" title
=<?php
xl('The label that appears to the user on the form','e','\'','\''); ?
> >(?
)</span
></th
>
775 <th
><?php
xl('UOR','e'); ?
></th
>
776 <th
><?php
xl('Data Type','e'); ?
></th
>
777 <th
><?php
xl('Size','e'); ?
></th
>
778 <th
><?php
xl('List','e'); ?
></th
>
779 <th
><?php
xl('Label Cols','e'); ?
></th
>
780 <th
><?php
xl('Data Cols','e'); ?
></th
>
781 <th
><?php
xl('Options','e'); ?
></th
>
782 <th
><?php
xl('Description','e'); ?
></th
>
787 <td
><input type
="textbox" name
="newseq" id
="newseq" value
="" size
="2" maxlength
="3"> </td
>
788 <td
><input type
="textbox" name
="newid" id
="newid" value
="" size
="10" maxlength
="20"> </td
>
789 <td
><input type
="textbox" name
="newtitle" id
="newtitle" value
="" size
="20" maxlength
="63"> </td
>
791 <select name
="newuor" id
="newuor">
792 <option value
="0"><?php
xl('Unused','e'); ?
></option
>
793 <option value
="1" selected
><?php
xl('Optional','e'); ?
></option
>
794 <option value
="2"><?php
xl('Required','e'); ?
></option
>
798 <select name
='newdatatype' id
='newdatatype'>
799 <option value
=''></option
>
802 foreach ($datatypes as $key=>$value) {
803 echo " <option value='$key'>$value</option>\n";
808 <td
><input type
="textbox" name
="newlength" id
="newlength" value
="" size
="1" maxlength
="3"> </td
>
809 <td
><input type
="textbox" name
="newlistid" id
="newlistid" value
="" size
="8" maxlength
="31" class="listid">
810 <select name
='contextName' id
='contextName' style
='display:none'>
812 $res = sqlStatement("SELECT * FROM customlists WHERE cl_list_type=2 AND cl_deleted=0");
813 while($row = sqlFetchArray($res)){
814 echo "<option value='".htmlspecialchars($row['cl_list_item_long'],ENT_QUOTES
)."'>".htmlspecialchars($row['cl_list_item_long'],ENT_QUOTES
)."</option>";
819 <td
><input type
="textbox" name
="newtitlecols" id
="newtitlecols" value
="" size
="3" maxlength
="3"> </td
>
820 <td
><input type
="textbox" name
="newdatacols" id
="newdatacols" value
="" size
="3" maxlength
="3"> </td
>
821 <td
><input type
="textbox" name
="newedit_options" id
="newedit_options" value
="" size
="3" maxlength
="36">
822 <input type
="hidden" name
="newdefault" id
="newdefault" value
="" /> </td
>
823 <td
><input type
="textbox" name
="newdesc" id
="newdesc" value
="" size
="30" maxlength
="63"> </td
>
827 <input type
="button" class="savenewfield" value
=<?php
xl('Save New Field','e','\'','\''); ?
>>
828 <input type
="button" class="cancelnewfield" value
=<?php
xl('Cancel','e','\'','\''); ?
>>
837 <script language
="javascript">
839 // used when selecting a list-name for a field
842 // jQuery stuff to make the page a little easier to use
844 $
(document
).ready(function(){
845 $
("#save").click(function() { SaveChanges(); });
846 $
("#layout_id").change(function() { $
('#theform').submit(); });
848 $
(".addgroup").click(function() { AddGroup(this
); });
849 $
(".savenewgroup").click(function() { SaveNewGroup(this
); });
850 $
(".deletegroup").click(function() { DeleteGroup(this
); });
851 $
(".cancelnewgroup").click(function() { CancelNewGroup(this
); });
853 $
(".movegroup").click(function() { MoveGroup(this
); });
855 $
(".renamegroup").click(function() { RenameGroup(this
); });
856 $
(".saverenamegroup").click(function() { SaveRenameGroup(this
); });
857 $
(".cancelrenamegroup").click(function() { CancelRenameGroup(this
); });
859 $
(".addfield").click(function() { AddField(this
); });
860 $
("#deletefields").click(function() { DeleteFields(this
); });
861 $
(".selectfield").click(function() {
862 var TRparent
= $
(this
).parent().parent();
863 $
(TRparent
).children("td").toggleClass("highlight");
864 // disable the delete-move buttons
865 $
("#deletefields").attr("disabled", "disabled");
866 $
("#movefields").attr("disabled", "disabled");
867 $
(".selectfield").each(function(i
) {
868 // if any field is selected, enable the delete-move buttons
869 if ($
(this
).attr("checked") == true) {
870 $
("#deletefields").removeAttr("disabled");
871 $
("#movefields").removeAttr("disabled");
875 $
("#movefields").click(function() { ShowGroups(this
); });
876 $
(".savenewfield").click(function() { SaveNewField(this
); });
877 $
(".cancelnewfield").click(function() { CancelNewField(this
); });
878 $
("#newtitle").blur(function() { if ($
("#newid").val() == "") $
("#newid").val($
("#newtitle").val()); });
879 $
("#newdatatype").change(function() { ChangeList(this
.value
);});
880 $
("#gnewdatatype").change(function() { ChangeListg(this
.value
);});
881 $
(".listid").click(function() { ShowLists(this
); });
883 // special class that skips the element
884 $
(".noselect").focus(function() { $
(this
).blur(); });
886 // Save the changes made to the form
887 var SaveChanges
= function () {
888 $
("#formaction").val("save");
889 $
("#theform").submit();
892 /****************************************************/
893 /************ Group functions ***********************/
894 /****************************************************/
896 // display the 'new group' DIV
897 var AddGroup
= function(btnObj
) {
898 // show the field details DIV
899 $
('#groupdetail').css('visibility', 'visible');
900 $
('#groupdetail').css('display', 'block');
901 $
(btnObj
).parent().append($
("#groupdetail"));
902 $
('#groupdetail > #newgroupname').focus();
905 // save the new group to the form
906 var SaveNewGroup
= function(btnObj
) {
907 // the group name field can only have letters, numbers, spaces and underscores
908 // AND it cannot start with a number
909 if ($
("#newgroupname").val() == "") {
910 alert("<?php xl('Group names cannot be blank', 'e'); ?>");
913 if ($
("#newgroupname").val().match(/^
(\d+|\s+
)/)) {
914 alert("<?php xl('Group names cannot start with numbers or spaces.','e'); ?>");
917 var validname
= $
("#newgroupname").val().replace(/[^A
-za
-z0
-9 ]/g
, "_"); // match any non-word characters and replace them
918 $
("#newgroupname").val(validname
);
920 // now, check the first group field values
922 // seq must be numeric and less than 999
923 if (! IsNumeric($
("#gnewseq").val(), 0, 999)) {
924 alert("<?php xl('Order must be a number between 1 and 999','e'); ?>");
927 // length must be numeric and less than 999
928 if (! IsNumeric($
("#gnewlength").val(), 0, 999)) {
929 alert("<?php xl('Size must be a number between 1 and 999','e'); ?>");
932 // titlecols must be numeric and less than 100
933 if (! IsNumeric($
("#gnewtitlecols").val(), 0, 999)) {
934 alert("<?php xl('LabelCols must be a number between 1 and 999','e'); ?>");
937 // datacols must be numeric and less than 100
938 if (! IsNumeric($
("#gnewdatacols").val(), 0, 999)) {
939 alert("<?php xl('DataCols must be a number between 1 and 999','e'); ?>");
942 // some fields cannot be blank
943 if ($
("#gnewtitle").val() == "") {
944 alert("<?php xl('Label cannot be blank','e'); ?>");
947 // the id field can only have letters, numbers and underscores
948 if ($
("#gnewid").val() == "") {
949 alert("<?php xl('ID cannot be blank', 'e'); ?>");
952 var validid
= $
("#gnewid").val().replace(/(\s|\W
)/g
, "_"); // match any non-word characters and replace them
953 $
("#gnewid").val(validid
);
954 // similarly with the listid field
955 validid
= $
("#gnewlistid").val().replace(/(\s|\W
)/g
, "_");
956 $
("#gnewlistid").val(validid
);
958 // submit the form to add a new field to a specific group
959 $
("#formaction").val("addgroup");
960 $
("#theform").submit();
963 // actually delete an entire group from the database
964 var DeleteGroup
= function(btnObj
) {
965 var parts
= $
(btnObj
).attr("id");
966 var groupname
= parts
.replace(/^\d+
/, "");
967 if (confirm("<?php xl('WARNING','e','',' - ') . xl('This action cannot be undone.','e','','\n') . xl('Are you sure you wish to delete the entire group named','e','',' '); ?>'"+groupname+
"'?")) {
968 // submit the form to add a new field to a specific group
969 $
("#formaction").val("deletegroup");
970 $
("#deletegroupname").val(parts
);
971 $
("#theform").submit();
975 // just hide the new field DIV
976 var CancelNewGroup
= function(btnObj
) {
977 // hide the field details DIV
978 $
('#groupdetail').css('visibility', 'hidden');
979 $
('#groupdetail').css('display', 'none');
980 // reset the new group values to a default
981 $
('#groupdetail > #newgroupname').val("");
984 // display the 'new field' DIV
985 var MoveGroup
= function(btnObj
) {
986 var btnid
= $
(btnObj
).attr("id");
987 var parts
= btnid
.split("~");
988 var groupid
= parts
[0];
989 var direction
= parts
[1];
991 // submit the form to change group order
992 $
("#formaction").val("movegroup");
993 $
("#movegroupname").val(groupid
);
994 $
("#movedirection").val(direction
);
995 $
("#theform").submit();
998 // show the rename group DIV
999 var RenameGroup
= function(btnObj
) {
1000 $
('#renamegroupdetail').css('visibility', 'visible');
1001 $
('#renamegroupdetail').css('display', 'block');
1002 $
(btnObj
).parent().append($
("#renamegroupdetail"));
1003 $
('#renameoldgroupname').val($
(btnObj
).attr("id"));
1004 $
('#renamegroupname').val($
(btnObj
).attr("id").replace(/^\d+
/, ""));
1007 // save the new group to the form
1008 var SaveRenameGroup
= function(btnObj
) {
1009 // the group name field can only have letters, numbers, spaces and underscores
1010 // AND it cannot start with a number
1011 if ($
("#renamegroupname").val().match(/^\d+
/)) {
1012 alert("<?php xl('Group names cannot start with numbers.','e'); ?>");
1015 var validname
= $
("#renamegroupname").val().replace(/[^A
-za
-z0
-9 ]/g
, "_"); // match any non-word characters and replace them
1016 $
("#renamegroupname").val(validname
);
1018 // submit the form to add a new field to a specific group
1019 $
("#formaction").val("renamegroup");
1020 $
("#theform").submit();
1023 // just hide the new field DIV
1024 var CancelRenameGroup
= function(btnObj
) {
1025 // hide the field details DIV
1026 $
('#renamegroupdetail').css('visibility', 'hidden');
1027 $
('#renamegroupdetail').css('display', 'none');
1028 // reset the rename group values to a default
1029 $
('#renameoldgroupname').val("");
1030 $
('#renamegroupname').val("");
1033 /****************************************************/
1034 /************ Field functions ***********************/
1035 /****************************************************/
1037 // display the 'new field' DIV
1038 var AddField
= function(btnObj
) {
1039 // update the fieldgroup value to be the groupid
1040 var btnid
= $
(btnObj
).attr("id");
1041 var parts
= btnid
.split("~");
1042 var groupid
= parts
[1];
1043 $
('#fielddetail > #newfieldgroupid').attr('value', groupid
);
1045 // show the field details DIV
1046 $
('#fielddetail').css('visibility', 'visible');
1047 $
('#fielddetail').css('display', 'block');
1048 $
(btnObj
).parent().append($
("#fielddetail"));
1051 var DeleteFields
= function(btnObj
) {
1052 if (confirm("<?php xl('WARNING','e','',' - ') . xl('This action cannot be undone.','e','','\n') . xl('Are you sure you wish to delete the selected fields?','e'); ?>")) {
1054 $
(".selectfield").each(function(i
) {
1055 // build a list of selected field names to be moved
1056 if ($
(this
).attr("checked") == true) {
1057 var parts
= this
.id
.split("~");
1058 var currval
= $
("#selectedfields").val();
1059 $
("#selectedfields").val(currval+delim+parts
[1]);
1063 // submit the form to delete the field(s)
1064 $
("#formaction").val("deletefields");
1065 $
("#theform").submit();
1069 // save the new field to the form
1070 var SaveNewField
= function(btnObj
) {
1071 // check the new field values for correct formatting
1073 // seq must be numeric and less than 999
1074 if (! IsNumeric($
("#newseq").val(), 0, 999)) {
1075 alert("<?php xl('Order must be a number between 1 and 999','e'); ?>");
1078 // length must be numeric and less than 999
1079 if (! IsNumeric($
("#newlength").val(), 0, 999)) {
1080 alert("<?php xl('Size must be a number between 1 and 999','e'); ?>");
1083 // titlecols must be numeric and less than 100
1084 if (! IsNumeric($
("#newtitlecols").val(), 0, 999)) {
1085 alert("<?php xl('LabelCols must be a number between 1 and 999','e'); ?>");
1088 // datacols must be numeric and less than 100
1089 if (! IsNumeric($
("#newdatacols").val(), 0, 999)) {
1090 alert("<?php xl('DataCols must be a number between 1 and 999','e'); ?>");
1093 // some fields cannot be blank
1094 if ($
("#newtitle").val() == "") {
1095 alert("<?php xl('Label cannot be blank','e'); ?>");
1098 // the id field can only have letters, numbers and underscores
1099 var validid
= $
("#newid").val().replace(/(\s|\W
)/g
, "_"); // match any non-word characters and replace them
1100 $
("#newid").val(validid
);
1101 // similarly with the listid field
1102 validid
= $
("#newlistid").val().replace(/(\s|\W
)/g
, "_");
1103 $
("#newlistid").val(validid
);
1105 // submit the form to add a new field to a specific group
1106 $
("#formaction").val("addfield");
1107 $
("#theform").submit();
1110 // just hide the new field DIV
1111 var CancelNewField
= function(btnObj
) {
1112 // hide the field details DIV
1113 $
('#fielddetail').css('visibility', 'hidden');
1114 $
('#fielddetail').css('display', 'none');
1115 // reset the new field values to a default
1116 ResetNewFieldValues();
1119 // show the popup choice of lists
1120 var ShowLists
= function(btnObj
) {
1121 window
.open("./show_lists_popup.php", "lists", "width=300,height=500,scrollbars=yes");
1122 selectedfield
= btnObj
;
1125 // show the popup choice of groups
1126 var ShowGroups
= function(btnObj
) {
1127 window
.open("./show_groups_popup.php?layout_id=<?php echo $layout_id;?>", "groups", "width=300,height=300,scrollbars=yes");
1130 // Show context DD for NationNotes
1131 var ChangeList
= function(btnObj
){
1133 $
('#newlistid').hide();
1134 $
('#contextName').show();
1137 $
('#newlistid').show();
1138 $
('#contextName').hide();
1141 var ChangeListg
= function(btnObj
){
1143 $
('#gnewlistid').hide();
1144 $
('#gcontextName').show();
1147 $
('#gnewlistid').show();
1148 $
('#gcontextName').hide();
1154 function NationNotesContext(lineitem
,val
){
1156 document
.getElementById("fld["+lineitem+
"][contextName]").style
.display
='';
1157 document
.getElementById("fld["+lineitem+
"][list_id]").style
.display
='none';
1158 document
.getElementById("fld["+lineitem+
"][list_id]").value
='';
1161 document
.getElementById("fld["+lineitem+
"][list_id]").style
.display
='';
1162 document
.getElementById("fld["+lineitem+
"][contextName]").style
.display
='none';
1163 document
.getElementById("fld["+lineitem+
"][list_id]").value
='';
1166 function SetList(listid
) { $
(selectedfield
).val(listid
); }
1169 /* this is called after the user chooses a new group from the popup window
1170 * it will submit the page so the selected fields can be moved into
1173 function MoveFields(targetgroup
) {
1174 $
("#targetgroup").val(targetgroup
);
1176 $
(".selectfield").each(function(i
) {
1177 // build a list of selected field names to be moved
1178 if ($
(this
).attr("checked") == true) {
1179 var parts
= this
.id
.split("~");
1180 var currval
= $
("#selectedfields").val();
1181 $
("#selectedfields").val(currval+delim+parts
[1]);
1185 $
("#formaction").val("movefields");
1186 $
("#theform").submit();
1190 // set the new-field values to a default state
1191 function ResetNewFieldValues () {
1192 $
("#newseq").val("");
1193 $
("#newid").val("");
1194 $
("#newtitle").val("");
1195 $
("#newuor").val(1);
1196 $
("#newlength").val("");
1197 $
("#newdatatype").val("");
1198 $
("#newlistid").val("");
1199 $
("#newtitlecols").val("");
1200 $
("#newdatacols").val("");
1201 $
("#newedit_options").val("");
1202 $
("#newdefault").val("");
1203 $
("#newdesc").val("");
1206 // is value an integer and between min and max
1207 function IsNumeric(value
, min
, max
) {
1208 if (value
== "" || value
== null) return false;
1210 parseInt(value
) < min ||
1211 parseInt(value
) > max
)
1217 /****************************************************/
1218 /****************************************************/
1219 /****************************************************/
1221 // tell if num is an Integer
1222 function IsN(num
) { return !/\D
/.test(num
); }