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'),
18 'FACUSR' => xl('Facility Specific User Information')
20 if ($GLOBALS['ippf_specific']) {
21 $layouts['GCA'] = xl('Abortion Issues');
22 $layouts['CON'] = xl('Contraception Issues');
23 // $layouts['SRH'] = xl('SRH Visit Form');
26 // Include Layout Based Encounter Forms.
27 $lres = sqlStatement("SELECT * FROM list_options " .
28 "WHERE list_id = 'lbfnames' ORDER BY seq, title");
29 while ($lrow = sqlFetchArray($lres)) {
30 $layouts[$lrow['option_id']] = $lrow['title'];
33 // array of the data_types of the fields
35 "1" => xl("List box"),
37 "3" => xl("Textarea"),
38 "4" => xl("Text-date"),
39 "10" => xl("Providers"),
40 "11" => xl("Providers NPI"),
41 "12" => xl("Pharmacies"),
43 "14" => xl("Organizations"),
44 "15" => xl("Billing codes"),
45 "21" => xl("Checkbox list"),
46 "22" => xl("Textbox list"),
47 "23" => xl("Exam results"),
48 "24" => xl("Patient allergies"),
49 "25" => xl("Checkbox w/text"),
50 "26" => xl("List box w/add"),
51 "27" => xl("Radio buttons"),
52 "28" => xl("Lifestyle status"),
53 "31" => xl("Static Text"),
54 "32" => xl("Smoking Status"),
55 "33" => xl("Race and Ethnicity"),
56 "34" => xl("NationNotes"),
57 "35" => xl("Facilities")
60 function nextGroupOrder($order) {
61 if ($order == '9') $order = 'A';
62 else if ($order == 'Z') $order = 'a';
63 else $order = chr(ord($order) +
1);
67 // Check authorization.
68 $thisauth = acl_check('admin', 'super');
69 if (!$thisauth) die(xl('Not authorized'));
71 // The layout ID identifies the layout to be edited.
72 $layout_id = empty($_REQUEST['layout_id']) ?
'' : $_REQUEST['layout_id'];
74 // Handle the Form actions
76 if ($_POST['formaction'] == "save" && $layout_id) {
77 // If we are saving, then save.
79 for ($lino = 1; isset($fld[$lino]['id']); ++
$lino) {
81 $field_id = formTrim($iter['id']);
82 $data_type = formTrim($iter['data_type']);
83 // For a textarea (data type 3) max_length has a special meaning, to
84 // specify its height (in rows). This kludge assigns a fixed height,
85 // but this GUI really needs to support max_length directly.
86 $max_length = $data_type == 3 ?
3 : 255;
87 $listval = $data_type == 34 ?
formTrim($iter['contextName']) : formTrim($iter['list_id']);
89 sqlStatement("UPDATE layout_options SET " .
90 "title = '" . formTrim($iter['title']) . "', " .
91 "group_name = '" . formTrim($iter['group']) . "', " .
92 "seq = '" . formTrim($iter['seq']) . "', " .
93 "uor = '" . formTrim($iter['uor']) . "', " .
94 "fld_length = '" . formTrim($iter['length']) . "', " .
95 "max_length = '$max_length', " .
96 "titlecols = '" . formTrim($iter['titlecols']) . "', " .
97 "datacols = '" . formTrim($iter['datacols']) . "', " .
98 "data_type= '$data_type', " .
99 "list_id= '" . $listval . "', " .
100 "edit_options = '" . formTrim($iter['edit_options']) . "', " .
101 "default_value = '" . formTrim($iter['default']) . "', " .
102 "description = '" . formTrim($iter['desc']) . "' " .
103 "WHERE form_id = '$layout_id' AND field_id = '$field_id'");
108 else if ($_POST['formaction'] == "addfield" && $layout_id) {
109 // Add a new field to a specific group
110 $data_type = formTrim($_POST['newdatatype']);
111 $max_length = $data_type == 3 ?
3 : 255;
112 $listval = $data_type == 34 ?
formTrim($_POST['contextName']) : formTrim($_POST['newlistid']);
113 sqlStatement("INSERT INTO layout_options (" .
114 " form_id, field_id, title, group_name, seq, uor, fld_length" .
115 ", titlecols, datacols, data_type, edit_options, default_value, description" .
116 ", max_length, list_id " .
118 "'" . formTrim($_POST['layout_id'] ) . "'" .
119 ",'" . formTrim($_POST['newid'] ) . "'" .
120 ",'" . formTrim($_POST['newtitle'] ) . "'" .
121 ",'" . formTrim($_POST['newfieldgroupid']) . "'" .
122 ",'" . formTrim($_POST['newseq'] ) . "'" .
123 ",'" . formTrim($_POST['newuor'] ) . "'" .
124 ",'" . formTrim($_POST['newlength'] ) . "'" .
125 ",'" . formTrim($_POST['newtitlecols'] ) . "'" .
126 ",'" . formTrim($_POST['newdatacols'] ) . "'" .
128 ",'" . formTrim($_POST['newedit_options']) . "'" .
129 ",'" . formTrim($_POST['newdefault'] ) . "'" .
130 ",'" . formTrim($_POST['newdesc'] ) . "'" .
132 ",'" . $listval . "'" .
135 if (substr($layout_id,0,3) != 'LBF' && $layout_id != "FACUSR") {
136 // Add the field to the table too (this is critical)
137 if ($layout_id == "DEM") { $tablename = "patient_data"; }
138 else if ($layout_id == "HIS") { $tablename = "history_data"; }
139 else if ($layout_id == "REF") { $tablename = "transactions"; }
140 else if ($layout_id == "SRH") { $tablename = "lists_ippf_srh"; }
141 else if ($layout_id == "CON") { $tablename = "lists_ippf_con"; }
142 else if ($layout_id == "GCA") { $tablename = "lists_ippf_gcac"; }
143 sqlStatement("ALTER TABLE `" . $tablename . "` ADD ".
144 "`" . formTrim($_POST['newid']) . "`" .
146 newEvent("alter_table", $_SESSION['authUser'], $_SESSION['authProvider'], 1,
147 $tablename . " ADD " . formTrim($_POST['newid']));
151 else if ($_POST['formaction'] == "movefields" && $layout_id) {
152 // Move field(s) to a new group in the layout
153 $sqlstmt = "UPDATE layout_options SET ".
154 " group_name='". $_POST['targetgroup']."' ".
156 " form_id = '".$_POST['layout_id']."' ".
157 " AND field_id IN (";
159 foreach (explode(" ", $_POST['selectedfields']) as $onefield) {
160 $sqlstmt .= $comma."'".$onefield."'";
165 sqlStatement($sqlstmt);
168 else if ($_POST['formaction'] == "deletefields" && $layout_id) {
169 // Delete a field from a specific group
170 $sqlstmt = "DELETE FROM layout_options WHERE ".
171 " form_id = '".$_POST['layout_id']."' ".
172 " AND field_id IN (";
174 foreach (explode(" ", $_POST['selectedfields']) as $onefield) {
175 $sqlstmt .= $comma."'".$onefield."'";
179 sqlStatement($sqlstmt);
181 if (substr($layout_id,0,3) != 'LBF' && $layout_id != "FACUSR") {
182 // drop the field from the table too (this is critical)
183 if ($layout_id == "DEM") { $tablename = "patient_data"; }
184 else if ($layout_id == "HIS") { $tablename = "history_data"; }
185 else if ($layout_id == "REF") { $tablename = "transactions"; }
186 else if ($layout_id == "SRH") { $tablename = "lists_ippf_srh"; }
187 else if ($layout_id == "CON") { $tablename = "lists_ippf_con"; }
188 else if ($layout_id == "GCA") { $tablename = "lists_ippf_gcac"; }
189 foreach (explode(" ", $_POST['selectedfields']) as $onefield) {
190 sqlStatement("ALTER TABLE `".$tablename."` DROP `".$onefield."`");
191 newEvent("alter_table", $_SESSION['authUser'], $_SESSION['authProvider'], 1, $tablename." DROP ".$onefield);
196 else if ($_POST['formaction'] == "addgroup" && $layout_id) {
197 // all group names are prefixed with a number indicating their display order
198 // this new group is prefixed with the net highest number given the
200 $results = sqlStatement("select distinct(group_name) as gname ".
201 " from layout_options where ".
202 " form_id = '".$_POST['layout_id']."'"
205 while ($result = sqlFetchArray($results)) {
206 $tmp = substr($result['gname'], 0, 1);
207 if ($tmp >= $maxnum) $maxnum = nextGroupOrder($tmp);
210 $data_type = formTrim($_POST['gnewdatatype']);
211 $max_length = $data_type == 3 ?
3 : 255;
212 $listval = $data_type == 34 ?
formTrim($_POST['gcontextName']) : formTrim($_POST['gnewlistid']);
213 // add a new group to the layout, with the defined field
214 sqlStatement("INSERT INTO layout_options (" .
215 " form_id, field_id, title, group_name, seq, uor, fld_length" .
216 ", titlecols, datacols, data_type, edit_options, default_value, description" .
217 ", max_length, list_id " .
219 "'" . formTrim($_POST['layout_id'] ) . "'" .
220 ",'" . formTrim($_POST['gnewid'] ) . "'" .
221 ",'" . formTrim($_POST['gnewtitle'] ) . "'" .
222 ",'" . formTrim($maxnum . $_POST['newgroupname']) . "'" .
223 ",'" . formTrim($_POST['gnewseq'] ) . "'" .
224 ",'" . formTrim($_POST['gnewuor'] ) . "'" .
225 ",'" . formTrim($_POST['gnewlength'] ) . "'" .
226 ",'" . formTrim($_POST['gnewtitlecols'] ) . "'" .
227 ",'" . formTrim($_POST['gnewdatacols'] ) . "'" .
229 ",'" . formTrim($_POST['gnewedit_options']) . "'" .
230 ",'" . formTrim($_POST['gnewdefault'] ) . "'" .
231 ",'" . formTrim($_POST['gnewdesc'] ) . "'" .
233 ",'" . $listval . "'" .
236 if (substr($layout_id,0,3) != 'LBF' && $layout_id != "FACUSR") {
237 // Add the field to the table too (this is critical)
238 if ($layout_id == "DEM") { $tablename = "patient_data"; }
239 else if ($layout_id == "HIS") { $tablename = "history_data"; }
240 else if ($layout_id == "REF") { $tablename = "transactions"; }
241 else if ($layout_id == "SRH") { $tablename = "lists_ippf_srh"; }
242 else if ($layout_id == "CON") { $tablename = "lists_ippf_con"; }
243 else if ($layout_id == "GCA") { $tablename = "lists_ippf_gcac"; }
244 sqlStatement("ALTER TABLE `" . $tablename . "` ADD ".
245 "`" . formTrim($_POST['gnewid']) . "`" .
247 newEvent("alter_table", $_SESSION['authUser'], $_SESSION['authProvider'], 1,
248 $tablename . " ADD " . formTrim($_POST['gnewid']));
252 else if ($_POST['formaction'] == "deletegroup" && $layout_id) {
253 // drop the fields from the related table (this is critical)
254 if (substr($layout_id,0,3) != 'LBF' && $layout_id != "FACUSR") {
255 $res = sqlStatement("SELECT field_id FROM layout_options WHERE " .
256 " form_id = '".$_POST['layout_id']."' ".
257 " AND group_name = '".$_POST['deletegroupname']."'"
259 while ($row = sqlFetchArray($res)) {
260 // drop the field from the table too (this is critical)
261 if ($layout_id == "DEM") { $tablename = "patient_data"; }
262 else if ($layout_id == "HIS") { $tablename = "history_data"; }
263 else if ($layout_id == "REF") { $tablename = "transactions"; }
264 else if ($layout_id == "SRH") { $tablename = "lists_ippf_srh"; }
265 else if ($layout_id == "CON") { $tablename = "lists_ippf_con"; }
266 else if ($layout_id == "GCA") { $tablename = "lists_ippf_gcac"; }
267 sqlStatement("ALTER TABLE `".$tablename."` DROP `".$row['field_id']."`");
268 newEvent("alter_table", $_SESSION['authUser'], $_SESSION['authProvider'], 1, $tablename." DROP ".trim($row['field_id']));
272 // Delete an entire group from the form
273 sqlStatement("DELETE FROM layout_options WHERE ".
274 " form_id = '".$_POST['layout_id']."' ".
275 " AND group_name = '".$_POST['deletegroupname']."'"
279 else if ($_POST['formaction'] == "movegroup" && $layout_id) {
280 $results = sqlStatement("SELECT DISTINCT(group_name) AS gname " .
281 "FROM layout_options WHERE form_id = '$layout_id' " .
285 while ($result = sqlFetchArray($results)) {
286 if ($result['gname'] == $_POST['movegroupname']) {
287 if ($_POST['movedirection'] == 'up') { // moving up
289 $garray[$i] = $garray[$i - 1];
290 $garray[$i - 1] = $result['gname'];
294 $garray[$i++
] = $result['gname'];
297 else { // moving down
299 $garray[$i++
] = $result['gname'];
302 else if ($i > 1 && $garray[$i - 2] == '') {
303 $garray[$i - 2] = $result['gname'];
306 $garray[$i++
] = $result['gname'];
310 foreach ($garray as $value) {
311 if ($value === '') continue;
312 $newname = $nextord . substr($value, 1);
313 sqlStatement("UPDATE layout_options SET " .
314 "group_name = '$newname' WHERE " .
315 "form_id = '$layout_id' AND " .
316 "group_name = '$value'");
317 $nextord = nextGroupOrder($nextord);
321 else if ($_POST['formaction'] == "renamegroup" && $layout_id) {
322 $currpos = substr($_POST['renameoldgroupname'], 0, 1);
323 // update the database rows
324 sqlStatement("UPDATE layout_options SET " .
325 "group_name = '" . $currpos . $_POST['renamegroupname'] . "' ".
326 "WHERE form_id = '$layout_id' AND ".
327 "group_name = '" . $_POST['renameoldgroupname'] . "'");
330 // Get the selected form's elements.
332 $res = sqlStatement("SELECT * FROM layout_options WHERE " .
333 "form_id = '$layout_id' ORDER BY group_name, seq");
336 // global counter for field numbers
339 // Write one option line to the form.
341 function writeFieldLine($linedata) {
344 $checked = $linedata['default_value'] ?
" checked" : "";
346 //echo " <tr bgcolor='$bgcolor'>\n";
347 echo " <tr id='fld[$fld_line_no]' class='".($fld_line_no %
2 ?
'even' : 'odd')."'>\n";
349 echo " <td class='optcell' nowrap>";
350 // tuck the group_name INPUT in here
351 echo "<input type='hidden' name='fld[$fld_line_no][group]' value='" .
352 htmlspecialchars($linedata['group_name'], ENT_QUOTES
) . "' class='optin' />";
354 echo "<input type='checkbox' class='selectfield' ".
355 "name='".$linedata['group_name']."~".$linedata['field_id']."' ".
356 "id='".$linedata['group_name']."~".$linedata['field_id']."' ".
357 "title='".htmlspecialchars(xl('Select field', ENT_QUOTES
))."'>";
359 echo "<input type='text' name='fld[$fld_line_no][seq]' id='fld[$fld_line_no][seq]' value='" .
360 htmlspecialchars($linedata['seq'], ENT_QUOTES
) . "' size='2' maxlength='3' class='optin' />";
363 echo " <td align='left' class='optcell'>";
364 echo "<input type='text' name='fld[$fld_line_no][id]' value='" .
365 htmlspecialchars($linedata['field_id'], ENT_QUOTES
) . "' size='15' maxlength='63' class='optin noselect' />";
367 echo "<input type='hidden' name='fld[$fld_line_no][id]' value='" .
368 htmlspecialchars($linedata['field_id'], ENT_QUOTES) . "' />";
369 echo htmlspecialchars($linedata['field_id'], ENT_QUOTES);
373 echo " <td align='center' class='optcell'>";
374 echo "<input type='text' id='fld[$fld_line_no][title]' name='fld[$fld_line_no][title]' value='" .
375 htmlspecialchars($linedata['title'], ENT_QUOTES
) . "' size='15' maxlength='63' class='optin' />";
378 // if not english and set to translate layout labels, then show the translation
379 if ($GLOBALS['translate_layout'] && $_SESSION['language_choice'] > 1) {
380 echo "<td align='center' class='translation'>" . htmlspecialchars(xl($linedata['title']), ENT_QUOTES
) . "</td>\n";
383 echo " <td align='center' class='optcell'>";
384 echo "<select name='fld[$fld_line_no][uor]' class='optin'>";
385 foreach (array(0 =>xl('Unused'), 1 =>xl('Optional'), 2 =>xl('Required')) as $key => $value) {
386 echo "<option value='$key'";
387 if ($key == $linedata['uor']) echo " selected";
388 echo ">$value</option>\n";
393 echo " <td align='center' class='optcell'>";
394 echo "<select name='fld[$fld_line_no][data_type]' id='fld[$fld_line_no][data_type]' onchange=NationNotesContext('".$fld_line_no."',this.value)>";
395 echo "<option value=''></option>";
397 foreach ($datatypes as $key=>$value) {
398 if ($linedata['data_type'] == $key)
399 echo "<option value='$key' selected>$value</option>";
401 echo "<option value='$key'>$value</option>";
406 echo " <td align='center' class='optcell'>";
407 if ($linedata['data_type'] == 2 ||
$linedata['data_type'] == 3 ||
408 $linedata['data_type'] == 21 ||
$linedata['data_type'] == 22 ||
409 $linedata['data_type'] == 23 ||
$linedata['data_type'] == 25 ||
410 $linedata['data_type'] == 27 ||
$linedata['data_type'] == 28 ||
411 $linedata['data_type'] == 32)
413 echo "<input type='text' name='fld[$fld_line_no][length]' value='" .
414 htmlspecialchars($linedata['fld_length'], ENT_QUOTES
) .
415 "' size='1' maxlength='10' class='optin' />";
418 // all other data_types
419 echo "<input type='hidden' name='fld[$fld_line_no][length]' value=''>";
423 echo " <td align='center' class='optcell'>";
424 if ($linedata['data_type'] == 1 ||
$linedata['data_type'] == 21 ||
425 $linedata['data_type'] == 22 ||
$linedata['data_type'] == 23 ||
426 $linedata['data_type'] == 25 ||
$linedata['data_type'] == 26 ||
427 $linedata['data_type'] == 27 ||
$linedata['data_type'] == 32 ||
428 $linedata['data_type'] == 33 ||
$linedata['data_type'] == 34)
431 $disp = "style='display:none'";
432 if($linedata['data_type'] == 34){
433 $type = "style='display:none'";
436 echo "<input type='text' name='fld[$fld_line_no][list_id]' id='fld[$fld_line_no][list_id]' value='" .
437 htmlspecialchars($linedata['list_id'], ENT_QUOTES
) . "'".$type.
438 " size='6' maxlength='30' class='optin listid' style='cursor: pointer'".
439 "title='". xl('Choose list') . "' />";
441 echo "<select name='fld[$fld_line_no][contextName]' id='fld[$fld_line_no][contextName]' ".$disp.">";
442 $res = sqlStatement("SELECT * FROM customlists WHERE cl_list_type=2 AND cl_deleted=0");
443 while($row = sqlFetchArray($res)){
445 if ($linedata['list_id'] == $row['cl_list_item_long'])
447 echo "<option value='".htmlspecialchars($row['cl_list_item_long'],ENT_QUOTES
)."' ".$sel.">".htmlspecialchars($row['cl_list_item_long'],ENT_QUOTES
)."</option>";
452 // all other data_types
453 echo "<input type='hidden' name='fld[$fld_line_no][list_id]' value=''>";
457 echo " <td align='center' class='optcell'>";
458 echo "<input type='text' name='fld[$fld_line_no][titlecols]' value='" .
459 htmlspecialchars($linedata['titlecols'], ENT_QUOTES
) . "' size='3' maxlength='10' class='optin' />";
462 echo " <td align='center' class='optcell'>";
463 echo "<input type='text' name='fld[$fld_line_no][datacols]' value='" .
464 htmlspecialchars($linedata['datacols'], ENT_QUOTES
) . "' size='3' maxlength='10' class='optin' />";
467 echo " <td align='center' class='optcell' title='C = " . xl('Capitalize') .
468 ", D = " . xl('Dup Check') . ", G = " . xl('Graphable') .
469 ", N = " . xl('New Patient Form') . ", O = " . xl('Order Processor') .
470 ", V = " . xl('Vendor') . "'>";
471 echo "<input type='text' name='fld[$fld_line_no][edit_options]' value='" .
472 htmlspecialchars($linedata['edit_options'], ENT_QUOTES
) . "' size='3' maxlength='36' class='optin' />";
475 /*****************************************************************
476 echo " <td align='center' class='optcell'>";
477 if ($linedata['data_type'] == 2) {
478 echo "<input type='text' name='fld[$fld_line_no][default]' value='" .
479 htmlspecialchars($linedata['default_value'], ENT_QUOTES) . "' size='10' maxlength='63' class='optin' />";
485 echo " <td align='center' class='optcell'>";
486 echo "<input type='text' name='fld[$fld_line_no][desc]' value='" .
487 htmlspecialchars($linedata['description'], ENT_QUOTES) . "' size='20' maxlength='63' class='optin' />";
490 // if not english and showing layout labels, then show the translation of Description
491 if ($GLOBALS['translate_layout'] && $_SESSION['language_choice'] > 1) {
492 echo "<td align='center' class='translation'>" . htmlspecialchars(xl($linedata['description']), ENT_QUOTES) . "</td>\n";
494 *****************************************************************/
496 if ($linedata['data_type'] == 31) {
497 echo " <td align='center' class='optcell'>";
498 echo "<textarea name='fld[$fld_line_no][desc]' rows='3' cols='35' class='optin'>" .
499 $linedata['description'] . "</textarea>";
500 echo "<input type='hidden' name='fld[$fld_line_no][default]' value='" .
501 htmlspecialchars($linedata['default_value'], ENT_QUOTES
) . "' />";
505 echo " <td align='center' class='optcell'>";
506 echo "<input type='text' name='fld[$fld_line_no][desc]' value='" .
507 htmlspecialchars($linedata['description'], ENT_QUOTES
) .
508 "' size='30' maxlength='63' class='optin' />";
509 echo "<input type='hidden' name='fld[$fld_line_no][default]' value='" .
510 htmlspecialchars($linedata['default_value'], ENT_QUOTES
) . "' />";
512 // if not english and showing layout labels, then show the translation of Description
513 if ($GLOBALS['translate_layout'] && $_SESSION['language_choice'] > 1) {
514 echo "<td align='center' class='translation'>" .
515 htmlspecialchars(xl($linedata['description']), ENT_QUOTES
) . "</td>\n";
525 <?php
html_header_show();?
>
527 <!-- supporting javascript code
-->
528 <script type
="text/javascript" src
="<?php echo $GLOBALS['webroot'] ?>/library/js/jquery.js"></script
>
530 <link rel
="stylesheet" href
='<?php echo $css_header ?>' type
='text/css'>
532 <title
><?php
xl('Layout Editor','e'); ?
></title
>
535 tr
.head
{ font
-size
:10pt
; background
-color
:#cccccc; }
536 tr
.detail
{ font
-size
:10pt
; }
537 td
{ font
-size
:10pt
; }
538 input
{ font
-size
:10pt
; }
539 a
, a
:visited
, a
:hover
{ color
:#0000cc; }
541 .optin
{ background
: transparent
; }
543 margin
: 0pt
0pt
8pt
0pt
;
548 border
-collapse
: collapse
;
552 background
-color
: #ddddff;
553 padding
: 3px
0px
3px
0px
;
556 background
-color
: #ffdddd;
557 padding
: 3px
0px
3px
0px
;
559 .help
{ cursor
: help
; }
560 .layouts_title
{ font
-size
: 110%
; }
566 border
: 2px solid blue
;
567 background
-color
: yellow
;
574 <body
class="body_top">
576 <form method
='post' name
='theform' id
='theform' action
='edit_layout.php'>
577 <input type
="hidden" name
="formaction" id
="formaction" value
="">
578 <!-- elements used to identify a field to delete
-->
579 <input type
="hidden" name
="deletefieldid" id
="deletefieldid" value
="">
580 <input type
="hidden" name
="deletefieldgroup" id
="deletefieldgroup" value
="">
581 <!-- elements used to identify a group to delete
-->
582 <input type
="hidden" name
="deletegroupname" id
="deletegroupname" value
="">
583 <!-- elements used to change the group order
-->
584 <input type
="hidden" name
="movegroupname" id
="movegroupname" value
="">
585 <input type
="hidden" name
="movedirection" id
="movedirection" value
="">
586 <!-- elements used to select more than one field
-->
587 <input type
="hidden" name
="selectedfields" id
="selectedfields" value
="">
588 <input type
="hidden" id
="targetgroup" name
="targetgroup" value
="">
590 <p
><b
><?php
xl('Edit layout','e'); ?
>:</b
> 
;
591 <select name
='layout_id' id
='layout_id'>
592 <option value
=''>-- <?php
echo xl('Select') ?
> --</option
>
594 foreach ($layouts as $key => $value) {
595 echo " <option value='$key'";
596 if ($key == $layout_id) echo " selected";
597 echo ">$value</option>\n";
602 <?php
if ($layout_id) { ?
>
603 <div style
='margin: 0 0 8pt 0;'>
604 <input type
='button' class='addgroup' id
='addgroup' value
=<?php
xl('Add Group','e','\'','\''); ?
>/>
609 $prevgroup = "!@#asdf1234"; // an unlikely group name
610 $firstgroup = true; // flag indicates it's the first group to be displayed
611 while ($row = sqlFetchArray($res)) {
612 if ($row['group_name'] != $prevgroup) {
613 if ($firstgroup == false) { echo "</tbody></table></div>\n"; }
614 echo "<div id='".$row['group_name']."' class='group'>";
615 echo "<div class='text bold layouts_title' style='position:relative; background-color: #eef'>";
616 // echo preg_replace("/^\d+/", "", $row['group_name']);
617 echo substr($row['group_name'], 1);
619 // if not english and set to translate layout labels, then show the translation of group name
620 if ($GLOBALS['translate_layout'] && $_SESSION['language_choice'] > 1) {
621 // echo "<span class='translation'>>> " . xl(preg_replace("/^\d+/", "", $row['group_name'])) . "</span>";
622 echo "<span class='translation'>>> " . xl(substr($row['group_name'], 1)) . "</span>";
626 echo " <input type='button' class='addfield' id='addto~".$row['group_name']."' value='" . xl('Add Field') . "'/>";
627 echo " ";
628 echo " <input type='button' class='renamegroup' id='".$row['group_name']."' value='" . xl('Rename Group') . "'/>";
629 echo " ";
630 echo " <input type='button' class='deletegroup' id='".$row['group_name']."' value='" . xl('Delete Group') . "'/>";
631 echo " ";
632 echo " <input type='button' class='movegroup' id='".$row['group_name']."~up' value='" . xl('Move Up') . "'/>";
633 echo " ";
634 echo " <input type='button' class='movegroup' id='".$row['group_name']."~down' value='" . xl('Move Down') . "'/>";
642 <th
><?php
xl('Order','e'); ?
></th
>
643 <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
>
644 <th
><?php
xl('Label','e'); ?
> <span
class="help" title
=<?php
xl('The label that appears to the user on the form','e','\'','\''); ?
> >(?
)</span
></th
>
645 <?php
// if not english and showing layout label translations, then show translation header for title
646 if ($GLOBALS['translate_layout'] && $_SESSION['language_choice'] > 1) {
647 echo "<th>" . xl('Translation')."<span class='help' title='" . xl('The translated label that will appear on the form in current language') . "'> (?)</span></th>";
649 <th
><?php
xl('UOR','e'); ?
></th
>
650 <th
><?php
xl('Data Type','e'); ?
></th
>
651 <th
><?php
xl('Size','e'); ?
></th
>
652 <th
><?php
xl('List','e'); ?
></th
>
653 <th
><?php
xl('Label Cols','e'); ?
></th
>
654 <th
><?php
xl('Data Cols','e'); ?
></th
>
655 <th
><?php
xl('Options','e'); ?
></th
>
656 <th
><?php
xl('Description','e'); ?
></th
>
657 <?php
// if not english and showing layout label translations, then show translation header for description
658 if ($GLOBALS['translate_layout'] && $_SESSION['language_choice'] > 1) {
659 echo "<th>" . xl('Translation')."<span class='help' title='" . xl('The translation of description in current language')."'> (?)</span></th>";
666 } // end if-group_name
668 writeFieldLine($row);
669 $prevgroup = $row['group_name'];
677 <?php
if ($layout_id) { ?
>
678 <span style
="font-size:90%">
679 <?php
xl('With selected:', 'e');?
>
680 <input type
='button' name
='deletefields' id
='deletefields' value
='<?php xl('Delete
','e
'); ?>' style
="font-size:90%" disabled
="disabled" />
681 <input type
='button' name
='movefields' id
='movefields' value
='<?php xl('Move to
...','e
'); ?>' style
="font-size:90%" disabled
="disabled" />
684 <input type
='button' name
='save' id
='save' value
='<?php xl('Save Changes
','e
'); ?>' />
690 <!-- template DIV that appears when user chooses to rename an existing group
-->
691 <div id
="renamegroupdetail" style
="border: 1px solid black; padding: 3px; display: none; visibility: hidden; background-color: lightgrey;">
692 <input type
="hidden" name
="renameoldgroupname" id
="renameoldgroupname" value
="">
693 <?php
xl('Group Name','e'); ?
>: <input type
="textbox" size
="20" maxlength
="30" name
="renamegroupname" id
="renamegroupname">
695 <input type
="button" class="saverenamegroup" value
=<?php
xl('Rename Group','e','\'','\''); ?
>>
696 <input type
="button" class="cancelrenamegroup" value
=<?php
xl('Cancel','e','\'','\''); ?
>>
699 <!-- template DIV that appears when user chooses to add a
new group
-->
700 <div id
="groupdetail" style
="border: 1px solid black; padding: 3px; display: none; visibility: hidden; background-color: lightgrey;">
702 <?php
xl('Group Name','e'); ?
>: <input type
="textbox" size
="20" maxlength
="30" name
="newgroupname" id
="newgroupname">
704 <table style
="border-collapse: collapse; margin-top: 5px;">
707 <th
><?php
xl('Order','e'); ?
></th
>
708 <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
>
709 <th
><?php
xl('Label','e'); ?
> <span
class="help" title
=<?php
xl('The label that appears to the user on the form','e','\'','\''); ?
> >(?
)</span
></th
>
710 <th
><?php
xl('UOR','e'); ?
></th
>
711 <th
><?php
xl('Data Type','e'); ?
></th
>
712 <th
><?php
xl('Size','e'); ?
></th
>
713 <th
><?php
xl('List','e'); ?
></th
>
714 <th
><?php
xl('Label Cols','e'); ?
></th
>
715 <th
><?php
xl('Data Cols','e'); ?
></th
>
716 <th
><?php
xl('Options','e'); ?
></th
>
717 <th
><?php
xl('Description','e'); ?
></th
>
722 <td
><input type
="textbox" name
="gnewseq" id
="gnewseq" value
="" size
="2" maxlength
="3"> </td
>
723 <td
><input type
="textbox" name
="gnewid" id
="gnewid" value
="" size
="10" maxlength
="20"> </td
>
724 <td
><input type
="textbox" name
="gnewtitle" id
="gnewtitle" value
="" size
="20" maxlength
="63"> </td
>
726 <select name
="gnewuor" id
="gnewuor">
727 <option value
="0"><?php
xl('Unused','e'); ?
></option
>
728 <option value
="1" selected
><?php
xl('Optional','e'); ?
></option
>
729 <option value
="2"><?php
xl('Required','e'); ?
></option
>
733 <select name
='gnewdatatype' id
='gnewdatatype'>
734 <option value
=''></option
>
737 foreach ($datatypes as $key=>$value) {
738 echo "<option value='$key'>$value</option>";
743 <td
><input type
="textbox" name
="gnewlength" id
="gnewlength" value
="" size
="1" maxlength
="3"> </td
>
744 <td
><input type
="textbox" name
="gnewlistid" id
="gnewlistid" value
="" size
="8" maxlength
="31" class="listid">
745 <select name
='gcontextName' id
='gcontextName' style
='display:none'>
747 $res = sqlStatement("SELECT * FROM customlists WHERE cl_list_type=2 AND cl_deleted=0");
748 while($row = sqlFetchArray($res)){
749 echo "<option value='".htmlspecialchars($row['cl_list_item_long'],ENT_QUOTES
)."'>".htmlspecialchars($row['cl_list_item_long'],ENT_QUOTES
)."</option>";
754 <td
><input type
="textbox" name
="gnewtitlecols" id
="gnewtitlecols" value
="" size
="3" maxlength
="3"> </td
>
755 <td
><input type
="textbox" name
="gnewdatacols" id
="gnewdatacols" value
="" size
="3" maxlength
="3"> </td
>
756 <td
><input type
="textbox" name
="gnewedit_options" id
="gnewedit_options" value
="" size
="3" maxlength
="36">
757 <input type
="hidden" name
="gnewdefault" id
="gnewdefault" value
="" /> </td
>
758 <td
><input type
="textbox" name
="gnewdesc" id
="gnewdesc" value
="" size
="30" maxlength
="63"> </td
>
763 <input type
="button" class="savenewgroup" value
=<?php
xl('Save New Group','e','\'','\''); ?
>>
764 <input type
="button" class="cancelnewgroup" value
=<?php
xl('Cancel','e','\'','\''); ?
>>
768 <!-- template DIV that appears when user chooses to add a
new field to a group
-->
769 <div id
="fielddetail" class="fielddetail" style
="display: none; visibility: hidden">
770 <input type
="hidden" name
="newfieldgroupid" id
="newfieldgroupid" value
="">
771 <table style
="border-collapse: collapse;">
774 <th
><?php
xl('Order','e'); ?
></th
>
775 <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
>
776 <th
><?php
xl('Label','e'); ?
> <span
class="help" title
=<?php
xl('The label that appears to the user on the form','e','\'','\''); ?
> >(?
)</span
></th
>
777 <th
><?php
xl('UOR','e'); ?
></th
>
778 <th
><?php
xl('Data Type','e'); ?
></th
>
779 <th
><?php
xl('Size','e'); ?
></th
>
780 <th
><?php
xl('List','e'); ?
></th
>
781 <th
><?php
xl('Label Cols','e'); ?
></th
>
782 <th
><?php
xl('Data Cols','e'); ?
></th
>
783 <th
><?php
xl('Options','e'); ?
></th
>
784 <th
><?php
xl('Description','e'); ?
></th
>
789 <td
><input type
="textbox" name
="newseq" id
="newseq" value
="" size
="2" maxlength
="3"> </td
>
790 <td
><input type
="textbox" name
="newid" id
="newid" value
="" size
="10" maxlength
="20"> </td
>
791 <td
><input type
="textbox" name
="newtitle" id
="newtitle" value
="" size
="20" maxlength
="63"> </td
>
793 <select name
="newuor" id
="newuor">
794 <option value
="0"><?php
xl('Unused','e'); ?
></option
>
795 <option value
="1" selected
><?php
xl('Optional','e'); ?
></option
>
796 <option value
="2"><?php
xl('Required','e'); ?
></option
>
800 <select name
='newdatatype' id
='newdatatype'>
801 <option value
=''></option
>
804 foreach ($datatypes as $key=>$value) {
805 echo " <option value='$key'>$value</option>\n";
810 <td
><input type
="textbox" name
="newlength" id
="newlength" value
="" size
="1" maxlength
="3"> </td
>
811 <td
><input type
="textbox" name
="newlistid" id
="newlistid" value
="" size
="8" maxlength
="31" class="listid">
812 <select name
='contextName' id
='contextName' style
='display:none'>
814 $res = sqlStatement("SELECT * FROM customlists WHERE cl_list_type=2 AND cl_deleted=0");
815 while($row = sqlFetchArray($res)){
816 echo "<option value='".htmlspecialchars($row['cl_list_item_long'],ENT_QUOTES
)."'>".htmlspecialchars($row['cl_list_item_long'],ENT_QUOTES
)."</option>";
821 <td
><input type
="textbox" name
="newtitlecols" id
="newtitlecols" value
="" size
="3" maxlength
="3"> </td
>
822 <td
><input type
="textbox" name
="newdatacols" id
="newdatacols" value
="" size
="3" maxlength
="3"> </td
>
823 <td
><input type
="textbox" name
="newedit_options" id
="newedit_options" value
="" size
="3" maxlength
="36">
824 <input type
="hidden" name
="newdefault" id
="newdefault" value
="" /> </td
>
825 <td
><input type
="textbox" name
="newdesc" id
="newdesc" value
="" size
="30" maxlength
="63"> </td
>
829 <input type
="button" class="savenewfield" value
=<?php
xl('Save New Field','e','\'','\''); ?
>>
830 <input type
="button" class="cancelnewfield" value
=<?php
xl('Cancel','e','\'','\''); ?
>>
839 <script language
="javascript">
841 // used when selecting a list-name for a field
844 // jQuery stuff to make the page a little easier to use
846 $
(document
).ready(function(){
847 $
("#save").click(function() { SaveChanges(); });
848 $
("#layout_id").change(function() { $
('#theform').submit(); });
850 $
(".addgroup").click(function() { AddGroup(this
); });
851 $
(".savenewgroup").click(function() { SaveNewGroup(this
); });
852 $
(".deletegroup").click(function() { DeleteGroup(this
); });
853 $
(".cancelnewgroup").click(function() { CancelNewGroup(this
); });
855 $
(".movegroup").click(function() { MoveGroup(this
); });
857 $
(".renamegroup").click(function() { RenameGroup(this
); });
858 $
(".saverenamegroup").click(function() { SaveRenameGroup(this
); });
859 $
(".cancelrenamegroup").click(function() { CancelRenameGroup(this
); });
861 $
(".addfield").click(function() { AddField(this
); });
862 $
("#deletefields").click(function() { DeleteFields(this
); });
863 $
(".selectfield").click(function() {
864 var TRparent
= $
(this
).parent().parent();
865 $
(TRparent
).children("td").toggleClass("highlight");
866 // disable the delete-move buttons
867 $
("#deletefields").attr("disabled", "disabled");
868 $
("#movefields").attr("disabled", "disabled");
869 $
(".selectfield").each(function(i
) {
870 // if any field is selected, enable the delete-move buttons
871 if ($
(this
).attr("checked") == true) {
872 $
("#deletefields").removeAttr("disabled");
873 $
("#movefields").removeAttr("disabled");
877 $
("#movefields").click(function() { ShowGroups(this
); });
878 $
(".savenewfield").click(function() { SaveNewField(this
); });
879 $
(".cancelnewfield").click(function() { CancelNewField(this
); });
880 $
("#newtitle").blur(function() { if ($
("#newid").val() == "") $
("#newid").val($
("#newtitle").val()); });
881 $
("#newdatatype").change(function() { ChangeList(this
.value
);});
882 $
("#gnewdatatype").change(function() { ChangeListg(this
.value
);});
883 $
(".listid").click(function() { ShowLists(this
); });
885 // special class that skips the element
886 $
(".noselect").focus(function() { $
(this
).blur(); });
888 // Save the changes made to the form
889 var SaveChanges
= function () {
890 $
("#formaction").val("save");
891 $
("#theform").submit();
894 /****************************************************/
895 /************ Group functions ***********************/
896 /****************************************************/
898 // display the 'new group' DIV
899 var AddGroup
= function(btnObj
) {
900 // show the field details DIV
901 $
('#groupdetail').css('visibility', 'visible');
902 $
('#groupdetail').css('display', 'block');
903 $
(btnObj
).parent().append($
("#groupdetail"));
904 $
('#groupdetail > #newgroupname').focus();
907 // save the new group to the form
908 var SaveNewGroup
= function(btnObj
) {
909 // the group name field can only have letters, numbers, spaces and underscores
910 // AND it cannot start with a number
911 if ($
("#newgroupname").val() == "") {
912 alert("<?php xl('Group names cannot be blank', 'e'); ?>");
915 if ($
("#newgroupname").val().match(/^
(\d+|\s+
)/)) {
916 alert("<?php xl('Group names cannot start with numbers or spaces.','e'); ?>");
919 var validname
= $
("#newgroupname").val().replace(/[^A
-za
-z0
-9 ]/g
, "_"); // match any non-word characters and replace them
920 $
("#newgroupname").val(validname
);
922 // now, check the first group field values
924 // seq must be numeric and less than 999
925 if (! IsNumeric($
("#gnewseq").val(), 0, 999)) {
926 alert("<?php xl('Order must be a number between 1 and 999','e'); ?>");
929 // length must be numeric and less than 999
930 if (! IsNumeric($
("#gnewlength").val(), 0, 999)) {
931 alert("<?php xl('Size must be a number between 1 and 999','e'); ?>");
934 // titlecols must be numeric and less than 100
935 if (! IsNumeric($
("#gnewtitlecols").val(), 0, 999)) {
936 alert("<?php xl('LabelCols must be a number between 1 and 999','e'); ?>");
939 // datacols must be numeric and less than 100
940 if (! IsNumeric($
("#gnewdatacols").val(), 0, 999)) {
941 alert("<?php xl('DataCols must be a number between 1 and 999','e'); ?>");
944 // some fields cannot be blank
945 if ($
("#gnewtitle").val() == "") {
946 alert("<?php xl('Label cannot be blank','e'); ?>");
949 // the id field can only have letters, numbers and underscores
950 if ($
("#gnewid").val() == "") {
951 alert("<?php xl('ID cannot be blank', 'e'); ?>");
954 var validid
= $
("#gnewid").val().replace(/(\s|\W
)/g
, "_"); // match any non-word characters and replace them
955 $
("#gnewid").val(validid
);
956 // similarly with the listid field
957 validid
= $
("#gnewlistid").val().replace(/(\s|\W
)/g
, "_");
958 $
("#gnewlistid").val(validid
);
960 // submit the form to add a new field to a specific group
961 $
("#formaction").val("addgroup");
962 $
("#theform").submit();
965 // actually delete an entire group from the database
966 var DeleteGroup
= function(btnObj
) {
967 var parts
= $
(btnObj
).attr("id");
968 var groupname
= parts
.replace(/^\d+
/, "");
969 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+
"'?")) {
970 // submit the form to add a new field to a specific group
971 $
("#formaction").val("deletegroup");
972 $
("#deletegroupname").val(parts
);
973 $
("#theform").submit();
977 // just hide the new field DIV
978 var CancelNewGroup
= function(btnObj
) {
979 // hide the field details DIV
980 $
('#groupdetail').css('visibility', 'hidden');
981 $
('#groupdetail').css('display', 'none');
982 // reset the new group values to a default
983 $
('#groupdetail > #newgroupname').val("");
986 // display the 'new field' DIV
987 var MoveGroup
= function(btnObj
) {
988 var btnid
= $
(btnObj
).attr("id");
989 var parts
= btnid
.split("~");
990 var groupid
= parts
[0];
991 var direction
= parts
[1];
993 // submit the form to change group order
994 $
("#formaction").val("movegroup");
995 $
("#movegroupname").val(groupid
);
996 $
("#movedirection").val(direction
);
997 $
("#theform").submit();
1000 // show the rename group DIV
1001 var RenameGroup
= function(btnObj
) {
1002 $
('#renamegroupdetail').css('visibility', 'visible');
1003 $
('#renamegroupdetail').css('display', 'block');
1004 $
(btnObj
).parent().append($
("#renamegroupdetail"));
1005 $
('#renameoldgroupname').val($
(btnObj
).attr("id"));
1006 $
('#renamegroupname').val($
(btnObj
).attr("id").replace(/^\d+
/, ""));
1009 // save the new group to the form
1010 var SaveRenameGroup
= function(btnObj
) {
1011 // the group name field can only have letters, numbers, spaces and underscores
1012 // AND it cannot start with a number
1013 if ($
("#renamegroupname").val().match(/^\d+
/)) {
1014 alert("<?php xl('Group names cannot start with numbers.','e'); ?>");
1017 var validname
= $
("#renamegroupname").val().replace(/[^A
-za
-z0
-9 ]/g
, "_"); // match any non-word characters and replace them
1018 $
("#renamegroupname").val(validname
);
1020 // submit the form to add a new field to a specific group
1021 $
("#formaction").val("renamegroup");
1022 $
("#theform").submit();
1025 // just hide the new field DIV
1026 var CancelRenameGroup
= function(btnObj
) {
1027 // hide the field details DIV
1028 $
('#renamegroupdetail').css('visibility', 'hidden');
1029 $
('#renamegroupdetail').css('display', 'none');
1030 // reset the rename group values to a default
1031 $
('#renameoldgroupname').val("");
1032 $
('#renamegroupname').val("");
1035 /****************************************************/
1036 /************ Field functions ***********************/
1037 /****************************************************/
1039 // display the 'new field' DIV
1040 var AddField
= function(btnObj
) {
1041 // update the fieldgroup value to be the groupid
1042 var btnid
= $
(btnObj
).attr("id");
1043 var parts
= btnid
.split("~");
1044 var groupid
= parts
[1];
1045 $
('#fielddetail > #newfieldgroupid').attr('value', groupid
);
1047 // show the field details DIV
1048 $
('#fielddetail').css('visibility', 'visible');
1049 $
('#fielddetail').css('display', 'block');
1050 $
(btnObj
).parent().append($
("#fielddetail"));
1053 var DeleteFields
= function(btnObj
) {
1054 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'); ?>")) {
1056 $
(".selectfield").each(function(i
) {
1057 // build a list of selected field names to be moved
1058 if ($
(this
).attr("checked") == true) {
1059 var parts
= this
.id
.split("~");
1060 var currval
= $
("#selectedfields").val();
1061 $
("#selectedfields").val(currval+delim+parts
[1]);
1065 // submit the form to delete the field(s)
1066 $
("#formaction").val("deletefields");
1067 $
("#theform").submit();
1071 // save the new field to the form
1072 var SaveNewField
= function(btnObj
) {
1073 // check the new field values for correct formatting
1075 // seq must be numeric and less than 999
1076 if (! IsNumeric($
("#newseq").val(), 0, 999)) {
1077 alert("<?php xl('Order must be a number between 1 and 999','e'); ?>");
1080 // length must be numeric and less than 999
1081 if (! IsNumeric($
("#newlength").val(), 0, 999)) {
1082 alert("<?php xl('Size must be a number between 1 and 999','e'); ?>");
1085 // titlecols must be numeric and less than 100
1086 if (! IsNumeric($
("#newtitlecols").val(), 0, 999)) {
1087 alert("<?php xl('LabelCols must be a number between 1 and 999','e'); ?>");
1090 // datacols must be numeric and less than 100
1091 if (! IsNumeric($
("#newdatacols").val(), 0, 999)) {
1092 alert("<?php xl('DataCols must be a number between 1 and 999','e'); ?>");
1095 // some fields cannot be blank
1096 if ($
("#newtitle").val() == "") {
1097 alert("<?php xl('Label cannot be blank','e'); ?>");
1100 // the id field can only have letters, numbers and underscores
1101 var validid
= $
("#newid").val().replace(/(\s|\W
)/g
, "_"); // match any non-word characters and replace them
1102 $
("#newid").val(validid
);
1103 // similarly with the listid field
1104 validid
= $
("#newlistid").val().replace(/(\s|\W
)/g
, "_");
1105 $
("#newlistid").val(validid
);
1107 // submit the form to add a new field to a specific group
1108 $
("#formaction").val("addfield");
1109 $
("#theform").submit();
1112 // just hide the new field DIV
1113 var CancelNewField
= function(btnObj
) {
1114 // hide the field details DIV
1115 $
('#fielddetail').css('visibility', 'hidden');
1116 $
('#fielddetail').css('display', 'none');
1117 // reset the new field values to a default
1118 ResetNewFieldValues();
1121 // show the popup choice of lists
1122 var ShowLists
= function(btnObj
) {
1123 window
.open("./show_lists_popup.php", "lists", "width=300,height=500,scrollbars=yes");
1124 selectedfield
= btnObj
;
1127 // show the popup choice of groups
1128 var ShowGroups
= function(btnObj
) {
1129 window
.open("./show_groups_popup.php?layout_id=<?php echo $layout_id;?>", "groups", "width=300,height=300,scrollbars=yes");
1132 // Show context DD for NationNotes
1133 var ChangeList
= function(btnObj
){
1135 $
('#newlistid').hide();
1136 $
('#contextName').show();
1139 $
('#newlistid').show();
1140 $
('#contextName').hide();
1143 var ChangeListg
= function(btnObj
){
1145 $
('#gnewlistid').hide();
1146 $
('#gcontextName').show();
1149 $
('#gnewlistid').show();
1150 $
('#gcontextName').hide();
1156 function NationNotesContext(lineitem
,val
){
1158 document
.getElementById("fld["+lineitem+
"][contextName]").style
.display
='';
1159 document
.getElementById("fld["+lineitem+
"][list_id]").style
.display
='none';
1160 document
.getElementById("fld["+lineitem+
"][list_id]").value
='';
1163 document
.getElementById("fld["+lineitem+
"][list_id]").style
.display
='';
1164 document
.getElementById("fld["+lineitem+
"][contextName]").style
.display
='none';
1165 document
.getElementById("fld["+lineitem+
"][list_id]").value
='';
1168 function SetList(listid
) { $
(selectedfield
).val(listid
); }
1171 /* this is called after the user chooses a new group from the popup window
1172 * it will submit the page so the selected fields can be moved into
1175 function MoveFields(targetgroup
) {
1176 $
("#targetgroup").val(targetgroup
);
1178 $
(".selectfield").each(function(i
) {
1179 // build a list of selected field names to be moved
1180 if ($
(this
).attr("checked") == true) {
1181 var parts
= this
.id
.split("~");
1182 var currval
= $
("#selectedfields").val();
1183 $
("#selectedfields").val(currval+delim+parts
[1]);
1187 $
("#formaction").val("movefields");
1188 $
("#theform").submit();
1192 // set the new-field values to a default state
1193 function ResetNewFieldValues () {
1194 $
("#newseq").val("");
1195 $
("#newid").val("");
1196 $
("#newtitle").val("");
1197 $
("#newuor").val(1);
1198 $
("#newlength").val("");
1199 $
("#newdatatype").val("");
1200 $
("#newlistid").val("");
1201 $
("#newtitlecols").val("");
1202 $
("#newdatacols").val("");
1203 $
("#newedit_options").val("");
1204 $
("#newdefault").val("");
1205 $
("#newdesc").val("");
1208 // is value an integer and between min and max
1209 function IsNumeric(value
, min
, max
) {
1210 if (value
== "" || value
== null) return false;
1212 parseInt(value
) < min ||
1213 parseInt(value
) > max
)
1219 /****************************************************/
1220 /****************************************************/
1221 /****************************************************/
1223 // tell if num is an Integer
1224 function IsN(num
) { return !/\D
/.test(num
); }