Adjusted default left nav width to fit the sliding menu labels
[openemr.git] / interface / super / edit_layout.php
blob652e9cd6f9da18975763a3b8f0f43ce101ac3781
1 <?php
2 // Copyright (C) 2007-2010 Rod Roark <rod@sunsetsystems.com>
3 //
4 // This program is free software; you can redistribute it and/or
5 // modify it under the terms of the GNU General Public License
6 // as published by the Free Software Foundation; either version 2
7 // of the License, or (at your option) any later version.
9 require_once("../globals.php");
10 require_once("$srcdir/acl.inc");
11 require_once("$srcdir/log.inc");
12 require_once("$srcdir/formdata.inc.php");
14 $layouts = array(
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
33 $datatypes = array(
34 "1" => xl("List box"),
35 "2" => xl("Textbox"),
36 "3" => xl("Textarea"),
37 "4" => xl("Text-date"),
38 "10" => xl("Providers"),
39 "11" => xl("Providers NPI"),
40 "12" => xl("Pharmacies"),
41 "13" => xl("Squads"),
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"), // add for smoking status task
52 "31" => xl("Static Text"),
53 "32" => xl("Smoking Status"),
54 "33" => xl("Race and Ethnicity"),
57 function nextGroupOrder($order) {
58 if ($order == '9') $order = 'A';
59 else if ($order == 'Z') $order = 'a';
60 else $order = chr(ord($order) + 1);
61 return $order;
64 // Check authorization.
65 $thisauth = acl_check('admin', 'super');
66 if (!$thisauth) die(xl('Not authorized'));
68 // The layout ID identifies the layout to be edited.
69 $layout_id = empty($_REQUEST['layout_id']) ? '' : $_REQUEST['layout_id'];
71 // Handle the Form actions
73 if ($_POST['formaction'] == "save" && $layout_id) {
74 // If we are saving, then save.
75 $fld = $_POST['fld'];
76 for ($lino = 1; isset($fld[$lino]['id']); ++$lino) {
77 $iter = $fld[$lino];
78 $field_id = formTrim($iter['id']);
79 $data_type = formTrim($iter['data_type']);
80 // For a textarea (data type 3) max_length has a special meaning, to
81 // specify its height (in rows). This kludge assigns a fixed height,
82 // but this GUI really needs to support max_length directly.
83 $max_length = $data_type == 3 ? 3 : 255;
84 if ($field_id) {
85 sqlStatement("UPDATE layout_options SET " .
86 "title = '" . formTrim($iter['title']) . "', " .
87 "group_name = '" . formTrim($iter['group']) . "', " .
88 "seq = '" . formTrim($iter['seq']) . "', " .
89 "uor = '" . formTrim($iter['uor']) . "', " .
90 "fld_length = '" . formTrim($iter['length']) . "', " .
91 "max_length = '$max_length', " .
92 "titlecols = '" . formTrim($iter['titlecols']) . "', " .
93 "datacols = '" . formTrim($iter['datacols']) . "', " .
94 "data_type= '$data_type', " .
95 "list_id= '" . formTrim($iter['list_id']) . "', " .
96 "edit_options = '" . formTrim($iter['edit_options']) . "', " .
97 "default_value = '" . formTrim($iter['default']) . "', " .
98 "description = '" . formTrim($iter['desc']) . "' " .
99 "WHERE form_id = '$layout_id' AND field_id = '$field_id'");
104 else if ($_POST['formaction'] == "addfield" && $layout_id) {
105 // Add a new field to a specific group
106 $data_type = formTrim($_POST['newdatatype']);
107 $max_length = $data_type == 3 ? 3 : 255;
108 sqlStatement("INSERT INTO layout_options (" .
109 " form_id, field_id, title, group_name, seq, uor, fld_length" .
110 ", titlecols, datacols, data_type, edit_options, default_value, description" .
111 ", max_length, list_id " .
112 ") VALUES ( " .
113 "'" . formTrim($_POST['layout_id'] ) . "'" .
114 ",'" . formTrim($_POST['newid'] ) . "'" .
115 ",'" . formTrim($_POST['newtitle'] ) . "'" .
116 ",'" . formTrim($_POST['newfieldgroupid']) . "'" .
117 ",'" . formTrim($_POST['newseq'] ) . "'" .
118 ",'" . formTrim($_POST['newuor'] ) . "'" .
119 ",'" . formTrim($_POST['newlength'] ) . "'" .
120 ",'" . formTrim($_POST['newtitlecols'] ) . "'" .
121 ",'" . formTrim($_POST['newdatacols'] ) . "'" .
122 ",'$data_type'" .
123 ",'" . formTrim($_POST['newedit_options']) . "'" .
124 ",'" . formTrim($_POST['newdefault'] ) . "'" .
125 ",'" . formTrim($_POST['newdesc'] ) . "'" .
126 ",'$max_length'" .
127 ",'" . formTrim($_POST['newlistid'] ) . "'" .
128 " )");
130 if (substr($layout_id,0,3) != 'LBF') {
131 // Add the field to the table too (this is critical)
132 if ($layout_id == "DEM") { $tablename = "patient_data"; }
133 else if ($layout_id == "HIS") { $tablename = "history_data"; }
134 else if ($layout_id == "REF") { $tablename = "transactions"; }
135 else if ($layout_id == "SRH") { $tablename = "lists_ippf_srh"; }
136 else if ($layout_id == "CON") { $tablename = "lists_ippf_con"; }
137 else if ($layout_id == "GCA") { $tablename = "lists_ippf_gcac"; }
138 sqlStatement("ALTER TABLE `" . $tablename . "` ADD ".
139 "`" . formTrim($_POST['newid']) . "`" .
140 " VARCHAR( 255 )");
141 newEvent("alter_table", $_SESSION['authUser'], $_SESSION['authProvider'], 1,
142 $tablename . " ADD " . formTrim($_POST['newid']));
146 else if ($_POST['formaction'] == "movefields" && $layout_id) {
147 // Move field(s) to a new group in the layout
148 $sqlstmt = "UPDATE layout_options SET ".
149 " group_name='". $_POST['targetgroup']."' ".
150 " WHERE ".
151 " form_id = '".$_POST['layout_id']."' ".
152 " AND field_id IN (";
153 $comma = "";
154 foreach (explode(" ", $_POST['selectedfields']) as $onefield) {
155 $sqlstmt .= $comma."'".$onefield."'";
156 $comma = ", ";
158 $sqlstmt .= ")";
159 //echo $sqlstmt;
160 sqlStatement($sqlstmt);
163 else if ($_POST['formaction'] == "deletefields" && $layout_id) {
164 // Delete a field from a specific group
165 $sqlstmt = "DELETE FROM layout_options WHERE ".
166 " form_id = '".$_POST['layout_id']."' ".
167 " AND field_id IN (";
168 $comma = "";
169 foreach (explode(" ", $_POST['selectedfields']) as $onefield) {
170 $sqlstmt .= $comma."'".$onefield."'";
171 $comma = ", ";
173 $sqlstmt .= ")";
174 sqlStatement($sqlstmt);
176 if (substr($layout_id,0,3) != 'LBF') {
177 // drop the field from the table too (this is critical)
178 if ($layout_id == "DEM") { $tablename = "patient_data"; }
179 else if ($layout_id == "HIS") { $tablename = "history_data"; }
180 else if ($layout_id == "REF") { $tablename = "transactions"; }
181 else if ($layout_id == "SRH") { $tablename = "lists_ippf_srh"; }
182 else if ($layout_id == "CON") { $tablename = "lists_ippf_con"; }
183 else if ($layout_id == "GCA") { $tablename = "lists_ippf_gcac"; }
184 foreach (explode(" ", $_POST['selectedfields']) as $onefield) {
185 sqlStatement("ALTER TABLE `".$tablename."` DROP `".$onefield."`");
186 newEvent("alter_table", $_SESSION['authUser'], $_SESSION['authProvider'], 1, $tablename." DROP ".$onefield);
191 else if ($_POST['formaction'] == "addgroup" && $layout_id) {
192 // all group names are prefixed with a number indicating their display order
193 // this new group is prefixed with the net highest number given the
194 // layout_id
195 $results = sqlStatement("select distinct(group_name) as gname ".
196 " from layout_options where ".
197 " form_id = '".$_POST['layout_id']."'"
199 $maxnum = '1';
200 while ($result = sqlFetchArray($results)) {
201 $tmp = substr($result['gname'], 0, 1);
202 if ($tmp >= $maxnum) $maxnum = nextGroupOrder($tmp);
205 $data_type = formTrim($_POST['gnewdatatype']);
206 $max_length = $data_type == 3 ? 3 : 255;
208 // add a new group to the layout, with the defined field
209 sqlStatement("INSERT INTO layout_options (" .
210 " form_id, field_id, title, group_name, seq, uor, fld_length" .
211 ", titlecols, datacols, data_type, edit_options, default_value, description" .
212 ", max_length, list_id " .
213 ") VALUES ( " .
214 "'" . formTrim($_POST['layout_id'] ) . "'" .
215 ",'" . formTrim($_POST['gnewid'] ) . "'" .
216 ",'" . formTrim($_POST['gnewtitle'] ) . "'" .
217 ",'" . formTrim($maxnum . $_POST['newgroupname']) . "'" .
218 ",'" . formTrim($_POST['gnewseq'] ) . "'" .
219 ",'" . formTrim($_POST['gnewuor'] ) . "'" .
220 ",'" . formTrim($_POST['gnewlength'] ) . "'" .
221 ",'" . formTrim($_POST['gnewtitlecols'] ) . "'" .
222 ",'" . formTrim($_POST['gnewdatacols'] ) . "'" .
223 ",'$data_type'" .
224 ",'" . formTrim($_POST['gnewedit_options']) . "'" .
225 ",'" . formTrim($_POST['gnewdefault'] ) . "'" .
226 ",'" . formTrim($_POST['gnewdesc'] ) . "'" .
227 ",'$max_length'" .
228 ",'" . formTrim($_POST['gnewlistid'] ) . "'" .
229 " )");
231 if (substr($layout_id,0,3) != 'LBF') {
232 // Add the field to the table too (this is critical)
233 if ($layout_id == "DEM") { $tablename = "patient_data"; }
234 else if ($layout_id == "HIS") { $tablename = "history_data"; }
235 else if ($layout_id == "REF") { $tablename = "transactions"; }
236 else if ($layout_id == "SRH") { $tablename = "lists_ippf_srh"; }
237 else if ($layout_id == "CON") { $tablename = "lists_ippf_con"; }
238 else if ($layout_id == "GCA") { $tablename = "lists_ippf_gcac"; }
239 sqlStatement("ALTER TABLE `" . $tablename . "` ADD ".
240 "`" . formTrim($_POST['gnewid']) . "`" .
241 " VARCHAR( 255 )");
242 newEvent("alter_table", $_SESSION['authUser'], $_SESSION['authProvider'], 1,
243 $tablename . " ADD " . formTrim($_POST['gnewid']));
247 else if ($_POST['formaction'] == "deletegroup" && $layout_id) {
248 // drop the fields from the related table (this is critical)
249 if (substr($layout_id,0,3) != 'LBF') {
250 $res = sqlStatement("SELECT field_id FROM layout_options WHERE " .
251 " form_id = '".$_POST['layout_id']."' ".
252 " AND group_name = '".$_POST['deletegroupname']."'"
254 while ($row = sqlFetchArray($res)) {
255 // drop the field from the table too (this is critical)
256 if ($layout_id == "DEM") { $tablename = "patient_data"; }
257 else if ($layout_id == "HIS") { $tablename = "history_data"; }
258 else if ($layout_id == "REF") { $tablename = "transactions"; }
259 else if ($layout_id == "SRH") { $tablename = "lists_ippf_srh"; }
260 else if ($layout_id == "CON") { $tablename = "lists_ippf_con"; }
261 else if ($layout_id == "GCA") { $tablename = "lists_ippf_gcac"; }
262 sqlStatement("ALTER TABLE `".$tablename."` DROP `".$row['field_id']."`");
263 newEvent("alter_table", $_SESSION['authUser'], $_SESSION['authProvider'], 1, $tablename." DROP ".trim($row['field_id']));
267 // Delete an entire group from the form
268 sqlStatement("DELETE FROM layout_options WHERE ".
269 " form_id = '".$_POST['layout_id']."' ".
270 " AND group_name = '".$_POST['deletegroupname']."'"
274 else if ($_POST['formaction'] == "movegroup" && $layout_id) {
275 $results = sqlStatement("SELECT DISTINCT(group_name) AS gname " .
276 "FROM layout_options WHERE form_id = '$layout_id' " .
277 "ORDER BY gname");
278 $garray = array();
279 $i = 0;
280 while ($result = sqlFetchArray($results)) {
281 if ($result['gname'] == $_POST['movegroupname']) {
282 if ($_POST['movedirection'] == 'up') { // moving up
283 if ($i > 0) {
284 $garray[$i] = $garray[$i - 1];
285 $garray[$i - 1] = $result['gname'];
286 $i++;
288 else {
289 $garray[$i++] = $result['gname'];
292 else { // moving down
293 $garray[$i++] = '';
294 $garray[$i++] = $result['gname'];
297 else if ($i > 1 && $garray[$i - 2] == '') {
298 $garray[$i - 2] = $result['gname'];
300 else {
301 $garray[$i++] = $result['gname'];
304 $nextord = '1';
305 foreach ($garray as $value) {
306 if ($value === '') continue;
307 $newname = $nextord . substr($value, 1);
308 sqlStatement("UPDATE layout_options SET " .
309 "group_name = '$newname' WHERE " .
310 "form_id = '$layout_id' AND " .
311 "group_name = '$value'");
312 $nextord = nextGroupOrder($nextord);
316 else if ($_POST['formaction'] == "renamegroup" && $layout_id) {
317 $currpos = substr($_POST['renameoldgroupname'], 0, 1);
318 // update the database rows
319 sqlStatement("UPDATE layout_options SET " .
320 "group_name = '" . $currpos . $_POST['renamegroupname'] . "' ".
321 "WHERE form_id = '$layout_id' AND ".
322 "group_name = '" . $_POST['renameoldgroupname'] . "'");
325 // Get the selected form's elements.
326 if ($layout_id) {
327 $res = sqlStatement("SELECT * FROM layout_options WHERE " .
328 "form_id = '$layout_id' ORDER BY group_name, seq");
331 // global counter for field numbers
332 $fld_line_no = 0;
334 // Write one option line to the form.
336 function writeFieldLine($linedata) {
337 global $fld_line_no;
338 ++$fld_line_no;
339 $checked = $linedata['default_value'] ? " checked" : "";
341 //echo " <tr bgcolor='$bgcolor'>\n";
342 echo " <tr id='fld[$fld_line_no]' class='".($fld_line_no % 2 ? 'even' : 'odd')."'>\n";
344 echo " <td class='optcell' nowrap>";
345 // tuck the group_name INPUT in here
346 echo "<input type='hidden' name='fld[$fld_line_no][group]' value='" .
347 htmlspecialchars($linedata['group_name'], ENT_QUOTES) . "' class='optin' />";
349 echo "<input type='checkbox' class='selectfield' ".
350 "name='".$linedata['group_name']."~".$linedata['field_id']."' ".
351 "id='".$linedata['group_name']."~".$linedata['field_id']."' ".
352 "title='".htmlspecialchars(xl('Select field', ENT_QUOTES))."'>";
354 echo "<input type='text' name='fld[$fld_line_no][seq]' id='fld[$fld_line_no][seq]' value='" .
355 htmlspecialchars($linedata['seq'], ENT_QUOTES) . "' size='2' maxlength='3' class='optin' />";
356 echo "</td>\n";
358 echo " <td align='left' class='optcell'>";
359 echo "<input type='text' name='fld[$fld_line_no][id]' value='" .
360 htmlspecialchars($linedata['field_id'], ENT_QUOTES) . "' size='15' maxlength='63' class='optin noselect' />";
362 echo "<input type='hidden' name='fld[$fld_line_no][id]' value='" .
363 htmlspecialchars($linedata['field_id'], ENT_QUOTES) . "' />";
364 echo htmlspecialchars($linedata['field_id'], ENT_QUOTES);
366 echo "</td>\n";
368 echo " <td align='center' class='optcell'>";
369 echo "<input type='text' id='fld[$fld_line_no][title]' name='fld[$fld_line_no][title]' value='" .
370 htmlspecialchars($linedata['title'], ENT_QUOTES) . "' size='15' maxlength='63' class='optin' />";
371 echo "</td>\n";
373 // if not english and set to translate layout labels, then show the translation
374 if ($GLOBALS['translate_layout'] && $_SESSION['language_choice'] > 1) {
375 echo "<td align='center' class='translation'>" . htmlspecialchars(xl($linedata['title']), ENT_QUOTES) . "</td>\n";
378 echo " <td align='center' class='optcell'>";
379 echo "<select name='fld[$fld_line_no][uor]' class='optin'>";
380 foreach (array(0 =>xl('Unused'), 1 =>xl('Optional'), 2 =>xl('Required')) as $key => $value) {
381 echo "<option value='$key'";
382 if ($key == $linedata['uor']) echo " selected";
383 echo ">$value</option>\n";
385 echo "</select>";
386 echo "</td>\n";
388 echo " <td align='center' class='optcell'>";
389 echo "<select name='fld[$fld_line_no][data_type]' id='fld[$fld_line_no][data_type]'>";
390 echo "<option value=''></option>";
391 GLOBAL $datatypes;
392 foreach ($datatypes as $key=>$value) {
393 if ($linedata['data_type'] == $key)
394 echo "<option value='$key' selected>$value</option>";
395 else
396 echo "<option value='$key'>$value</option>";
398 echo "</select>";
399 echo " </td>";
401 echo " <td align='center' class='optcell'>";
402 if ($linedata['data_type'] == 2 || $linedata['data_type'] == 3 ||
403 $linedata['data_type'] == 21 || $linedata['data_type'] == 22 ||
404 $linedata['data_type'] == 23 || $linedata['data_type'] == 25 ||
405 $linedata['data_type'] == 27 || $linedata['data_type'] == 28)
407 echo "<input type='text' name='fld[$fld_line_no][length]' value='" .
408 htmlspecialchars($linedata['fld_length'], ENT_QUOTES) .
409 "' size='1' maxlength='10' class='optin' />";
411 else {
412 // all other data_types
413 echo "<input type='hidden' name='fld[$fld_line_no][length]' value=''>";
415 echo "</td>\n";
417 echo " <td align='center' class='optcell'>";
418 if ($linedata['data_type'] == 1 || $linedata['data_type'] == 21 ||
419 $linedata['data_type'] == 22 || $linedata['data_type'] == 23 ||
420 $linedata['data_type'] == 25 || $linedata['data_type'] == 26 ||
421 $linedata['data_type'] == 27 || $linedata['data_type'] == 33)
423 echo "<input type='text' name='fld[$fld_line_no][list_id]' value='" .
424 htmlspecialchars($linedata['list_id'], ENT_QUOTES) . "'".
425 "size='6' maxlength='30' class='optin listid' style='cursor: pointer'".
426 "title='". xl('Choose list') . "' />";
428 else {
429 // all other data_types
430 echo "<input type='hidden' name='fld[$fld_line_no][list_id]' value=''>";
432 echo "</td>\n";
434 echo " <td align='center' class='optcell'>";
435 echo "<input type='text' name='fld[$fld_line_no][titlecols]' value='" .
436 htmlspecialchars($linedata['titlecols'], ENT_QUOTES) . "' size='3' maxlength='10' class='optin' />";
437 echo "</td>\n";
439 echo " <td align='center' class='optcell'>";
440 echo "<input type='text' name='fld[$fld_line_no][datacols]' value='" .
441 htmlspecialchars($linedata['datacols'], ENT_QUOTES) . "' size='3' maxlength='10' class='optin' />";
442 echo "</td>\n";
444 echo " <td align='center' class='optcell' title='C = " . xl('Capitalize') .
445 ", D = " . xl('Dup Check') . ", G = " . xl('Graphable') .
446 ", N = " . xl('New Patient Form') . ", O = " . xl('Order Processor') .
447 ", V = " . xl('Vendor') . "'>";
448 echo "<input type='text' name='fld[$fld_line_no][edit_options]' value='" .
449 htmlspecialchars($linedata['edit_options'], ENT_QUOTES) . "' size='3' maxlength='36' class='optin' />";
450 echo "</td>\n";
452 /*****************************************************************
453 echo " <td align='center' class='optcell'>";
454 if ($linedata['data_type'] == 2) {
455 echo "<input type='text' name='fld[$fld_line_no][default]' value='" .
456 htmlspecialchars($linedata['default_value'], ENT_QUOTES) . "' size='10' maxlength='63' class='optin' />";
457 } else {
458 echo "&nbsp;";
460 echo "</td>\n";
462 echo " <td align='center' class='optcell'>";
463 echo "<input type='text' name='fld[$fld_line_no][desc]' value='" .
464 htmlspecialchars($linedata['description'], ENT_QUOTES) . "' size='20' maxlength='63' class='optin' />";
465 echo "</td>\n";
467 // if not english and showing layout labels, then show the translation of Description
468 if ($GLOBALS['translate_layout'] && $_SESSION['language_choice'] > 1) {
469 echo "<td align='center' class='translation'>" . htmlspecialchars(xl($linedata['description']), ENT_QUOTES) . "</td>\n";
471 *****************************************************************/
473 if ($linedata['data_type'] == 31) {
474 echo " <td align='center' class='optcell'>";
475 echo "<textarea name='fld[$fld_line_no][desc]' rows='3' cols='35' class='optin'>" .
476 $linedata['description'] . "</textarea>";
477 echo "<input type='hidden' name='fld[$fld_line_no][default]' value='" .
478 htmlspecialchars($linedata['default_value'], ENT_QUOTES) . "' />";
479 echo "</td>\n";
481 else {
482 echo " <td align='center' class='optcell'>";
483 echo "<input type='text' name='fld[$fld_line_no][desc]' value='" .
484 htmlspecialchars($linedata['description'], ENT_QUOTES) .
485 "' size='30' maxlength='63' class='optin' />";
486 echo "<input type='hidden' name='fld[$fld_line_no][default]' value='" .
487 htmlspecialchars($linedata['default_value'], ENT_QUOTES) . "' />";
488 echo "</td>\n";
489 // if not english and showing layout labels, then show the translation of Description
490 if ($GLOBALS['translate_layout'] && $_SESSION['language_choice'] > 1) {
491 echo "<td align='center' class='translation'>" .
492 htmlspecialchars(xl($linedata['description']), ENT_QUOTES) . "</td>\n";
496 echo " </tr>\n";
499 <html>
501 <head>
502 <?php html_header_show();?>
504 <!-- supporting javascript code -->
505 <script type="text/javascript" src="<?php echo $GLOBALS['webroot'] ?>/library/js/jquery.js"></script>
507 <link rel="stylesheet" href='<?php echo $css_header ?>' type='text/css'>
509 <title><?php xl('Layout Editor','e'); ?></title>
511 <style>
512 tr.head { font-size:10pt; background-color:#cccccc; }
513 tr.detail { font-size:10pt; }
514 td { font-size:10pt; }
515 input { font-size:10pt; }
516 a, a:visited, a:hover { color:#0000cc; }
517 .optcell { }
518 .optin { background: transparent; }
519 .group {
520 margin: 0pt 0pt 8pt 0pt;
521 padding: 0;
522 width: 100%;
524 .group table {
525 border-collapse: collapse;
526 width: 100%;
528 .odd td {
529 background-color: #ddddff;
530 padding: 3px 0px 3px 0px;
532 .even td {
533 background-color: #ffdddd;
534 padding: 3px 0px 3px 0px;
536 .help { cursor: help; }
537 .layouts_title { font-size: 110%; }
538 .translation {
539 color: green;
540 font-size:10pt;
542 .highlight * {
543 border: 2px solid blue;
544 background-color: yellow;
545 color: black;
547 </style>
549 </head>
551 <body class="body_top">
553 <form method='post' name='theform' id='theform' action='edit_layout.php'>
554 <input type="hidden" name="formaction" id="formaction" value="">
555 <!-- elements used to identify a field to delete -->
556 <input type="hidden" name="deletefieldid" id="deletefieldid" value="">
557 <input type="hidden" name="deletefieldgroup" id="deletefieldgroup" value="">
558 <!-- elements used to identify a group to delete -->
559 <input type="hidden" name="deletegroupname" id="deletegroupname" value="">
560 <!-- elements used to change the group order -->
561 <input type="hidden" name="movegroupname" id="movegroupname" value="">
562 <input type="hidden" name="movedirection" id="movedirection" value="">
563 <!-- elements used to select more than one field -->
564 <input type="hidden" name="selectedfields" id="selectedfields" value="">
565 <input type="hidden" id="targetgroup" name="targetgroup" value="">
567 <p><b><?php xl('Edit layout','e'); ?>:</b>&nbsp;
568 <select name='layout_id' id='layout_id'>
569 <option value=''>-- <?php echo xl('Select') ?> --</option>
570 <?php
571 foreach ($layouts as $key => $value) {
572 echo " <option value='$key'";
573 if ($key == $layout_id) echo " selected";
574 echo ">$value</option>\n";
577 </select></p>
579 <?php if ($layout_id) { ?>
580 <div style='margin: 0 0 8pt 0;'>
581 <input type='button' class='addgroup' id='addgroup' value=<?php xl('Add Group','e','\'','\''); ?>/>
582 </div>
583 <?php } ?>
585 <?php
586 $prevgroup = "!@#asdf1234"; // an unlikely group name
587 $firstgroup = true; // flag indicates it's the first group to be displayed
588 while ($row = sqlFetchArray($res)) {
589 if ($row['group_name'] != $prevgroup) {
590 if ($firstgroup == false) { echo "</tbody></table></div>\n"; }
591 echo "<div id='".$row['group_name']."' class='group'>";
592 echo "<div class='text bold layouts_title' style='position:relative; background-color: #eef'>";
593 // echo preg_replace("/^\d+/", "", $row['group_name']);
594 echo substr($row['group_name'], 1);
595 echo "&nbsp; ";
596 // if not english and set to translate layout labels, then show the translation of group name
597 if ($GLOBALS['translate_layout'] && $_SESSION['language_choice'] > 1) {
598 // echo "<span class='translation'>>>&nbsp; " . xl(preg_replace("/^\d+/", "", $row['group_name'])) . "</span>";
599 echo "<span class='translation'>>>&nbsp; " . xl(substr($row['group_name'], 1)) . "</span>";
600 echo "&nbsp; ";
602 echo "&nbsp; ";
603 echo " <input type='button' class='addfield' id='addto~".$row['group_name']."' value='" . xl('Add Field') . "'/>";
604 echo "&nbsp; &nbsp; ";
605 echo " <input type='button' class='renamegroup' id='".$row['group_name']."' value='" . xl('Rename Group') . "'/>";
606 echo "&nbsp; &nbsp; ";
607 echo " <input type='button' class='deletegroup' id='".$row['group_name']."' value='" . xl('Delete Group') . "'/>";
608 echo "&nbsp; &nbsp; ";
609 echo " <input type='button' class='movegroup' id='".$row['group_name']."~up' value='" . xl('Move Up') . "'/>";
610 echo "&nbsp; &nbsp; ";
611 echo " <input type='button' class='movegroup' id='".$row['group_name']."~down' value='" . xl('Move Down') . "'/>";
612 echo "</div>";
613 $firstgroup = false;
616 <table>
617 <thead>
618 <tr class='head'>
619 <th><?php xl('Order','e'); ?></th>
620 <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>
621 <th><?php xl('Label','e'); ?> <span class="help" title=<?php xl('The label that appears to the user on the form','e','\'','\''); ?> >(?)</span></th>
622 <?php // if not english and showing layout label translations, then show translation header for title
623 if ($GLOBALS['translate_layout'] && $_SESSION['language_choice'] > 1) {
624 echo "<th>" . xl('Translation')."<span class='help' title='" . xl('The translated label that will appear on the form in current language') . "'> (?)</span></th>";
625 } ?>
626 <th><?php xl('UOR','e'); ?></th>
627 <th><?php xl('Data Type','e'); ?></th>
628 <th><?php xl('Size','e'); ?></th>
629 <th><?php xl('List','e'); ?></th>
630 <th><?php xl('Label Cols','e'); ?></th>
631 <th><?php xl('Data Cols','e'); ?></th>
632 <th><?php xl('Options','e'); ?></th>
633 <th><?php xl('Description','e'); ?></th>
634 <?php // if not english and showing layout label translations, then show translation header for description
635 if ($GLOBALS['translate_layout'] && $_SESSION['language_choice'] > 1) {
636 echo "<th>" . xl('Translation')."<span class='help' title='" . xl('The translation of description in current language')."'> (?)</span></th>";
637 } ?>
638 </tr>
639 </thead>
640 <tbody>
642 <?php
643 } // end if-group_name
645 writeFieldLine($row);
646 $prevgroup = $row['group_name'];
648 } // end while loop
651 </tbody>
652 </table></div>
654 <?php if ($layout_id) { ?>
655 <span style="font-size:90%">
656 <?php xl('With selected:', 'e');?>
657 <input type='button' name='deletefields' id='deletefields' value='<?php xl('Delete','e'); ?>' style="font-size:90%" disabled="disabled" />
658 <input type='button' name='movefields' id='movefields' value='<?php xl('Move to...','e'); ?>' style="font-size:90%" disabled="disabled" />
659 </span>
661 <input type='button' name='save' id='save' value='<?php xl('Save Changes','e'); ?>' />
662 </p>
663 <?php } ?>
665 </form>
667 <!-- template DIV that appears when user chooses to rename an existing group -->
668 <div id="renamegroupdetail" style="border: 1px solid black; padding: 3px; display: none; visibility: hidden; background-color: lightgrey;">
669 <input type="hidden" name="renameoldgroupname" id="renameoldgroupname" value="">
670 <?php xl('Group Name','e'); ?>: <input type="textbox" size="20" maxlength="30" name="renamegroupname" id="renamegroupname">
671 <br>
672 <input type="button" class="saverenamegroup" value=<?php xl('Rename Group','e','\'','\''); ?>>
673 <input type="button" class="cancelrenamegroup" value=<?php xl('Cancel','e','\'','\''); ?>>
674 </div>
676 <!-- template DIV that appears when user chooses to add a new group -->
677 <div id="groupdetail" style="border: 1px solid black; padding: 3px; display: none; visibility: hidden; background-color: lightgrey;">
678 <span class='bold'>
679 <?php xl('Group Name','e'); ?>: <input type="textbox" size="20" maxlength="30" name="newgroupname" id="newgroupname">
680 <br>
681 <table style="border-collapse: collapse; margin-top: 5px;">
682 <thead>
683 <tr class='head'>
684 <th><?php xl('Order','e'); ?></th>
685 <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>
686 <th><?php xl('Label','e'); ?> <span class="help" title=<?php xl('The label that appears to the user on the form','e','\'','\''); ?> >(?)</span></th>
687 <th><?php xl('UOR','e'); ?></th>
688 <th><?php xl('Data Type','e'); ?></th>
689 <th><?php xl('Size','e'); ?></th>
690 <th><?php xl('List','e'); ?></th>
691 <th><?php xl('Label Cols','e'); ?></th>
692 <th><?php xl('Data Cols','e'); ?></th>
693 <th><?php xl('Options','e'); ?></th>
694 <th><?php xl('Description','e'); ?></th>
695 </tr>
696 </thead>
697 <tbody>
698 <tr class='center'>
699 <td ><input type="textbox" name="gnewseq" id="gnewseq" value="" size="2" maxlength="3"> </td>
700 <td ><input type="textbox" name="gnewid" id="gnewid" value="" size="10" maxlength="20"> </td>
701 <td><input type="textbox" name="gnewtitle" id="gnewtitle" value="" size="20" maxlength="63"> </td>
702 <td>
703 <select name="gnewuor" id="gnewuor">
704 <option value="0"><?php xl('Unused','e'); ?></option>
705 <option value="1" selected><?php xl('Optional','e'); ?></option>
706 <option value="2"><?php xl('Required','e'); ?></option>
707 </select>
708 </td>
709 <td align='center'>
710 <select name='gnewdatatype' id='gnewdatatype'>
711 <option value=''></option>
712 <?php
713 global $datatypes;
714 foreach ($datatypes as $key=>$value) {
715 echo "<option value='$key'>$value</option>";
718 </select>
719 </td>
720 <td><input type="textbox" name="gnewlength" id="gnewlength" value="" size="1" maxlength="3"> </td>
721 <td><input type="textbox" name="gnewlistid" id="gnewlistid" value="" size="8" maxlength="31" class="listid"> </td>
722 <td><input type="textbox" name="gnewtitlecols" id="gnewtitlecols" value="" size="3" maxlength="3"> </td>
723 <td><input type="textbox" name="gnewdatacols" id="gnewdatacols" value="" size="3" maxlength="3"> </td>
724 <td><input type="textbox" name="gnewedit_options" id="gnewedit_options" value="" size="3" maxlength="36">
725 <input type="hidden" name="gnewdefault" id="gnewdefault" value="" /> </td>
726 <td><input type="textbox" name="gnewdesc" id="gnewdesc" value="" size="30" maxlength="63"> </td>
727 </tr>
728 </tbody>
729 </table>
730 <br>
731 <input type="button" class="savenewgroup" value=<?php xl('Save New Group','e','\'','\''); ?>>
732 <input type="button" class="cancelnewgroup" value=<?php xl('Cancel','e','\'','\''); ?>>
733 </span>
734 </div>
736 <!-- template DIV that appears when user chooses to add a new field to a group -->
737 <div id="fielddetail" class="fielddetail" style="display: none; visibility: hidden">
738 <input type="hidden" name="newfieldgroupid" id="newfieldgroupid" value="">
739 <table style="border-collapse: collapse;">
740 <thead>
741 <tr class='head'>
742 <th><?php xl('Order','e'); ?></th>
743 <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>
744 <th><?php xl('Label','e'); ?> <span class="help" title=<?php xl('The label that appears to the user on the form','e','\'','\''); ?> >(?)</span></th>
745 <th><?php xl('UOR','e'); ?></th>
746 <th><?php xl('Data Type','e'); ?></th>
747 <th><?php xl('Size','e'); ?></th>
748 <th><?php xl('List','e'); ?></th>
749 <th><?php xl('Label Cols','e'); ?></th>
750 <th><?php xl('Data Cols','e'); ?></th>
751 <th><?php xl('Options','e'); ?></th>
752 <th><?php xl('Description','e'); ?></th>
753 </tr>
754 </thead>
755 <tbody>
756 <tr class='center'>
757 <td ><input type="textbox" name="newseq" id="newseq" value="" size="2" maxlength="3"> </td>
758 <td ><input type="textbox" name="newid" id="newid" value="" size="10" maxlength="20"> </td>
759 <td><input type="textbox" name="newtitle" id="newtitle" value="" size="20" maxlength="63"> </td>
760 <td>
761 <select name="newuor" id="newuor">
762 <option value="0"><?php xl('Unused','e'); ?></option>
763 <option value="1" selected><?php xl('Optional','e'); ?></option>
764 <option value="2"><?php xl('Required','e'); ?></option>
765 </select>
766 </td>
767 <td align='center'>
768 <select name='newdatatype' id='newdatatype'>
769 <option value=''></option>
770 <?php
771 global $datatypes;
772 foreach ($datatypes as $key=>$value) {
773 echo " <option value='$key'>$value</option>\n";
776 </select>
777 </td>
778 <td><input type="textbox" name="newlength" id="newlength" value="" size="1" maxlength="3"> </td>
779 <td><input type="textbox" name="newlistid" id="newlistid" value="" size="8" maxlength="31" class="listid"> </td>
780 <td><input type="textbox" name="newtitlecols" id="newtitlecols" value="" size="3" maxlength="3"> </td>
781 <td><input type="textbox" name="newdatacols" id="newdatacols" value="" size="3" maxlength="3"> </td>
782 <td><input type="textbox" name="newedit_options" id="newedit_options" value="" size="3" maxlength="36">
783 <input type="hidden" name="newdefault" id="newdefault" value="" /> </td>
784 <td><input type="textbox" name="newdesc" id="newdesc" value="" size="30" maxlength="63"> </td>
785 </tr>
786 <tr>
787 <td colspan="9">
788 <input type="button" class="savenewfield" value=<?php xl('Save New Field','e','\'','\''); ?>>
789 <input type="button" class="cancelnewfield" value=<?php xl('Cancel','e','\'','\''); ?>>
790 </td>
791 </tr>
792 </tbody>
793 </table>
794 </div>
796 </body>
798 <script language="javascript">
800 // used when selecting a list-name for a field
801 var selectedfield;
803 // jQuery stuff to make the page a little easier to use
805 $(document).ready(function(){
806 $("#save").click(function() { SaveChanges(); });
807 $("#layout_id").change(function() { $('#theform').submit(); });
809 $(".addgroup").click(function() { AddGroup(this); });
810 $(".savenewgroup").click(function() { SaveNewGroup(this); });
811 $(".deletegroup").click(function() { DeleteGroup(this); });
812 $(".cancelnewgroup").click(function() { CancelNewGroup(this); });
814 $(".movegroup").click(function() { MoveGroup(this); });
816 $(".renamegroup").click(function() { RenameGroup(this); });
817 $(".saverenamegroup").click(function() { SaveRenameGroup(this); });
818 $(".cancelrenamegroup").click(function() { CancelRenameGroup(this); });
820 $(".addfield").click(function() { AddField(this); });
821 $("#deletefields").click(function() { DeleteFields(this); });
822 $(".selectfield").click(function() {
823 var TRparent = $(this).parent().parent();
824 $(TRparent).children("td").toggleClass("highlight");
825 // disable the delete-move buttons
826 $("#deletefields").attr("disabled", "disabled");
827 $("#movefields").attr("disabled", "disabled");
828 $(".selectfield").each(function(i) {
829 // if any field is selected, enable the delete-move buttons
830 if ($(this).attr("checked") == true) {
831 $("#deletefields").removeAttr("disabled");
832 $("#movefields").removeAttr("disabled");
836 $("#movefields").click(function() { ShowGroups(this); });
837 $(".savenewfield").click(function() { SaveNewField(this); });
838 $(".cancelnewfield").click(function() { CancelNewField(this); });
839 $("#newtitle").blur(function() { if ($("#newid").val() == "") $("#newid").val($("#newtitle").val()); });
841 $(".listid").click(function() { ShowLists(this); });
843 // special class that skips the element
844 $(".noselect").focus(function() { $(this).blur(); });
846 // Save the changes made to the form
847 var SaveChanges = function () {
848 $("#formaction").val("save");
849 $("#theform").submit();
852 /****************************************************/
853 /************ Group functions ***********************/
854 /****************************************************/
856 // display the 'new group' DIV
857 var AddGroup = function(btnObj) {
858 // show the field details DIV
859 $('#groupdetail').css('visibility', 'visible');
860 $('#groupdetail').css('display', 'block');
861 $(btnObj).parent().append($("#groupdetail"));
862 $('#groupdetail > #newgroupname').focus();
865 // save the new group to the form
866 var SaveNewGroup = function(btnObj) {
867 // the group name field can only have letters, numbers, spaces and underscores
868 // AND it cannot start with a number
869 if ($("#newgroupname").val() == "") {
870 alert("<?php xl('Group names cannot be blank', 'e'); ?>");
871 return false;
873 if ($("#newgroupname").val().match(/^(\d+|\s+)/)) {
874 alert("<?php xl('Group names cannot start with numbers or spaces.','e'); ?>");
875 return false;
877 var validname = $("#newgroupname").val().replace(/[^A-za-z0-9 ]/g, "_"); // match any non-word characters and replace them
878 $("#newgroupname").val(validname);
880 // now, check the first group field values
882 // seq must be numeric and less than 999
883 if (! IsNumeric($("#gnewseq").val(), 0, 999)) {
884 alert("<?php xl('Order must be a number between 1 and 999','e'); ?>");
885 return false;
887 // length must be numeric and less than 999
888 if (! IsNumeric($("#gnewlength").val(), 0, 999)) {
889 alert("<?php xl('Size must be a number between 1 and 999','e'); ?>");
890 return false;
892 // titlecols must be numeric and less than 100
893 if (! IsNumeric($("#gnewtitlecols").val(), 0, 999)) {
894 alert("<?php xl('LabelCols must be a number between 1 and 999','e'); ?>");
895 return false;
897 // datacols must be numeric and less than 100
898 if (! IsNumeric($("#gnewdatacols").val(), 0, 999)) {
899 alert("<?php xl('DataCols must be a number between 1 and 999','e'); ?>");
900 return false;
902 // some fields cannot be blank
903 if ($("#gnewtitle").val() == "") {
904 alert("<?php xl('Label cannot be blank','e'); ?>");
905 return false;
907 // the id field can only have letters, numbers and underscores
908 if ($("#gnewid").val() == "") {
909 alert("<?php xl('ID cannot be blank', 'e'); ?>");
910 return false;
912 var validid = $("#gnewid").val().replace(/(\s|\W)/g, "_"); // match any non-word characters and replace them
913 $("#gnewid").val(validid);
914 // similarly with the listid field
915 validid = $("#gnewlistid").val().replace(/(\s|\W)/g, "_");
916 $("#gnewlistid").val(validid);
918 // submit the form to add a new field to a specific group
919 $("#formaction").val("addgroup");
920 $("#theform").submit();
923 // actually delete an entire group from the database
924 var DeleteGroup = function(btnObj) {
925 var parts = $(btnObj).attr("id");
926 var groupname = parts.replace(/^\d+/, "");
927 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+"'?")) {
928 // submit the form to add a new field to a specific group
929 $("#formaction").val("deletegroup");
930 $("#deletegroupname").val(parts);
931 $("#theform").submit();
935 // just hide the new field DIV
936 var CancelNewGroup = function(btnObj) {
937 // hide the field details DIV
938 $('#groupdetail').css('visibility', 'hidden');
939 $('#groupdetail').css('display', 'none');
940 // reset the new group values to a default
941 $('#groupdetail > #newgroupname').val("");
944 // display the 'new field' DIV
945 var MoveGroup = function(btnObj) {
946 var btnid = $(btnObj).attr("id");
947 var parts = btnid.split("~");
948 var groupid = parts[0];
949 var direction = parts[1];
951 // submit the form to change group order
952 $("#formaction").val("movegroup");
953 $("#movegroupname").val(groupid);
954 $("#movedirection").val(direction);
955 $("#theform").submit();
958 // show the rename group DIV
959 var RenameGroup = function(btnObj) {
960 $('#renamegroupdetail').css('visibility', 'visible');
961 $('#renamegroupdetail').css('display', 'block');
962 $(btnObj).parent().append($("#renamegroupdetail"));
963 $('#renameoldgroupname').val($(btnObj).attr("id"));
964 $('#renamegroupname').val($(btnObj).attr("id").replace(/^\d+/, ""));
967 // save the new group to the form
968 var SaveRenameGroup = function(btnObj) {
969 // the group name field can only have letters, numbers, spaces and underscores
970 // AND it cannot start with a number
971 if ($("#renamegroupname").val().match(/^\d+/)) {
972 alert("<?php xl('Group names cannot start with numbers.','e'); ?>");
973 return false;
975 var validname = $("#renamegroupname").val().replace(/[^A-za-z0-9 ]/g, "_"); // match any non-word characters and replace them
976 $("#renamegroupname").val(validname);
978 // submit the form to add a new field to a specific group
979 $("#formaction").val("renamegroup");
980 $("#theform").submit();
983 // just hide the new field DIV
984 var CancelRenameGroup = function(btnObj) {
985 // hide the field details DIV
986 $('#renamegroupdetail').css('visibility', 'hidden');
987 $('#renamegroupdetail').css('display', 'none');
988 // reset the rename group values to a default
989 $('#renameoldgroupname').val("");
990 $('#renamegroupname').val("");
993 /****************************************************/
994 /************ Field functions ***********************/
995 /****************************************************/
997 // display the 'new field' DIV
998 var AddField = function(btnObj) {
999 // update the fieldgroup value to be the groupid
1000 var btnid = $(btnObj).attr("id");
1001 var parts = btnid.split("~");
1002 var groupid = parts[1];
1003 $('#fielddetail > #newfieldgroupid').attr('value', groupid);
1005 // show the field details DIV
1006 $('#fielddetail').css('visibility', 'visible');
1007 $('#fielddetail').css('display', 'block');
1008 $(btnObj).parent().append($("#fielddetail"));
1011 var DeleteFields = function(btnObj) {
1012 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'); ?>")) {
1013 var delim = "";
1014 $(".selectfield").each(function(i) {
1015 // build a list of selected field names to be moved
1016 if ($(this).attr("checked") == true) {
1017 var parts = this.id.split("~");
1018 var currval = $("#selectedfields").val();
1019 $("#selectedfields").val(currval+delim+parts[1]);
1020 delim = " ";
1023 // submit the form to delete the field(s)
1024 $("#formaction").val("deletefields");
1025 $("#theform").submit();
1029 // save the new field to the form
1030 var SaveNewField = function(btnObj) {
1031 // check the new field values for correct formatting
1033 // seq must be numeric and less than 999
1034 if (! IsNumeric($("#newseq").val(), 0, 999)) {
1035 alert("<?php xl('Order must be a number between 1 and 999','e'); ?>");
1036 return false;
1038 // length must be numeric and less than 999
1039 if (! IsNumeric($("#newlength").val(), 0, 999)) {
1040 alert("<?php xl('Size must be a number between 1 and 999','e'); ?>");
1041 return false;
1043 // titlecols must be numeric and less than 100
1044 if (! IsNumeric($("#newtitlecols").val(), 0, 999)) {
1045 alert("<?php xl('LabelCols must be a number between 1 and 999','e'); ?>");
1046 return false;
1048 // datacols must be numeric and less than 100
1049 if (! IsNumeric($("#newdatacols").val(), 0, 999)) {
1050 alert("<?php xl('DataCols must be a number between 1 and 999','e'); ?>");
1051 return false;
1053 // some fields cannot be blank
1054 if ($("#newtitle").val() == "") {
1055 alert("<?php xl('Label cannot be blank','e'); ?>");
1056 return false;
1058 // the id field can only have letters, numbers and underscores
1059 var validid = $("#newid").val().replace(/(\s|\W)/g, "_"); // match any non-word characters and replace them
1060 $("#newid").val(validid);
1061 // similarly with the listid field
1062 validid = $("#newlistid").val().replace(/(\s|\W)/g, "_");
1063 $("#newlistid").val(validid);
1065 // submit the form to add a new field to a specific group
1066 $("#formaction").val("addfield");
1067 $("#theform").submit();
1070 // just hide the new field DIV
1071 var CancelNewField = function(btnObj) {
1072 // hide the field details DIV
1073 $('#fielddetail').css('visibility', 'hidden');
1074 $('#fielddetail').css('display', 'none');
1075 // reset the new field values to a default
1076 ResetNewFieldValues();
1079 // show the popup choice of lists
1080 var ShowLists = function(btnObj) {
1081 window.open("./show_lists_popup.php", "lists", "width=300,height=500,scrollbars=yes");
1082 selectedfield = btnObj;
1085 // show the popup choice of groups
1086 var ShowGroups = function(btnObj) {
1087 window.open("./show_groups_popup.php?layout_id=<?php echo $layout_id;?>", "groups", "width=300,height=300,scrollbars=yes");
1092 function SetList(listid) { $(selectedfield).val(listid); }
1095 /* this is called after the user chooses a new group from the popup window
1096 * it will submit the page so the selected fields can be moved into
1097 * the target group
1099 function MoveFields(targetgroup) {
1100 $("#targetgroup").val(targetgroup);
1101 var delim = "";
1102 $(".selectfield").each(function(i) {
1103 // build a list of selected field names to be moved
1104 if ($(this).attr("checked") == true) {
1105 var parts = this.id.split("~");
1106 var currval = $("#selectedfields").val();
1107 $("#selectedfields").val(currval+delim+parts[1]);
1108 delim = " ";
1111 $("#formaction").val("movefields");
1112 $("#theform").submit();
1116 // set the new-field values to a default state
1117 function ResetNewFieldValues () {
1118 $("#newseq").val("");
1119 $("#newid").val("");
1120 $("#newtitle").val("");
1121 $("#newuor").val(1);
1122 $("#newlength").val("");
1123 $("#newdatatype").val("");
1124 $("#newlistid").val("");
1125 $("#newtitlecols").val("");
1126 $("#newdatacols").val("");
1127 $("#newedit_options").val("");
1128 $("#newdefault").val("");
1129 $("#newdesc").val("");
1132 // is value an integer and between min and max
1133 function IsNumeric(value, min, max) {
1134 if (value == "" || value == null) return false;
1135 if (! IsN(value) ||
1136 parseInt(value) < min ||
1137 parseInt(value) > max)
1138 return false;
1140 return true;
1143 /****************************************************/
1144 /****************************************************/
1145 /****************************************************/
1147 // tell if num is an Integer
1148 function IsN(num) { return !/\D/.test(num); }
1149 </script>
1151 </html>