Added a new billing widget and following related changes:
[openemr.git] / interface / super / edit_layout.php
blobdd691ac93720197f9c3d62e1b12e9eba0b215b5e
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"),
56 function nextGroupOrder($order) {
57 if ($order == '9') $order = 'A';
58 else if ($order == 'Z') $order = 'a';
59 else $order = chr(ord($order) + 1);
60 return $order;
63 // Check authorization.
64 $thisauth = acl_check('admin', 'super');
65 if (!$thisauth) die(xl('Not authorized'));
67 // The layout ID identifies the layout to be edited.
68 $layout_id = empty($_REQUEST['layout_id']) ? '' : $_REQUEST['layout_id'];
70 // Handle the Form actions
72 if ($_POST['formaction'] == "save" && $layout_id) {
73 // If we are saving, then save.
74 $fld = $_POST['fld'];
75 for ($lino = 1; isset($fld[$lino]['id']); ++$lino) {
76 $iter = $fld[$lino];
77 $field_id = formTrim($iter['id']);
78 $data_type = formTrim($iter['data_type']);
79 // For a textarea (data type 3) max_length has a special meaning, to
80 // specify its height (in rows). This kludge assigns a fixed height,
81 // but this GUI really needs to support max_length directly.
82 $max_length = $data_type == 3 ? 3 : 255;
83 if ($field_id) {
84 sqlStatement("UPDATE layout_options SET " .
85 "title = '" . formTrim($iter['title']) . "', " .
86 "group_name = '" . formTrim($iter['group']) . "', " .
87 "seq = '" . formTrim($iter['seq']) . "', " .
88 "uor = '" . formTrim($iter['uor']) . "', " .
89 "fld_length = '" . formTrim($iter['length']) . "', " .
90 "max_length = '$max_length', " .
91 "titlecols = '" . formTrim($iter['titlecols']) . "', " .
92 "datacols = '" . formTrim($iter['datacols']) . "', " .
93 "data_type= '$data_type', " .
94 "list_id= '" . formTrim($iter['list_id']) . "', " .
95 "edit_options = '" . formTrim($iter['edit_options']) . "', " .
96 "default_value = '" . formTrim($iter['default']) . "', " .
97 "description = '" . formTrim($iter['desc']) . "' " .
98 "WHERE form_id = '$layout_id' AND field_id = '$field_id'");
103 else if ($_POST['formaction'] == "addfield" && $layout_id) {
104 // Add a new field to a specific group
105 $data_type = formTrim($_POST['newdatatype']);
106 $max_length = $data_type == 3 ? 3 : 255;
107 sqlStatement("INSERT INTO layout_options (" .
108 " form_id, field_id, title, group_name, seq, uor, fld_length" .
109 ", titlecols, datacols, data_type, edit_options, default_value, description" .
110 ", max_length, list_id " .
111 ") VALUES ( " .
112 "'" . formTrim($_POST['layout_id'] ) . "'" .
113 ",'" . formTrim($_POST['newid'] ) . "'" .
114 ",'" . formTrim($_POST['newtitle'] ) . "'" .
115 ",'" . formTrim($_POST['newfieldgroupid']) . "'" .
116 ",'" . formTrim($_POST['newseq'] ) . "'" .
117 ",'" . formTrim($_POST['newuor'] ) . "'" .
118 ",'" . formTrim($_POST['newlength'] ) . "'" .
119 ",'" . formTrim($_POST['newtitlecols'] ) . "'" .
120 ",'" . formTrim($_POST['newdatacols'] ) . "'" .
121 ",'$data_type'" .
122 ",'" . formTrim($_POST['newedit_options']) . "'" .
123 ",'" . formTrim($_POST['newdefault'] ) . "'" .
124 ",'" . formTrim($_POST['newdesc'] ) . "'" .
125 ",'$max_length'" .
126 ",'" . formTrim($_POST['newlistid'] ) . "'" .
127 " )");
129 if (substr($layout_id,0,3) != 'LBF') {
130 // Add the field to the table too (this is critical)
131 if ($layout_id == "DEM") { $tablename = "patient_data"; }
132 else if ($layout_id == "HIS") { $tablename = "history_data"; }
133 else if ($layout_id == "REF") { $tablename = "transactions"; }
134 else if ($layout_id == "SRH") { $tablename = "lists_ippf_srh"; }
135 else if ($layout_id == "CON") { $tablename = "lists_ippf_con"; }
136 else if ($layout_id == "GCA") { $tablename = "lists_ippf_gcac"; }
137 sqlStatement("ALTER TABLE `" . $tablename . "` ADD ".
138 "`" . formTrim($_POST['newid']) . "`" .
139 " VARCHAR( 255 )");
140 newEvent("alter_table", $_SESSION['authUser'], $_SESSION['authProvider'], 1,
141 $tablename . " ADD " . formTrim($_POST['newid']));
145 else if ($_POST['formaction'] == "movefields" && $layout_id) {
146 // Move field(s) to a new group in the layout
147 $sqlstmt = "UPDATE layout_options SET ".
148 " group_name='". $_POST['targetgroup']."' ".
149 " WHERE ".
150 " form_id = '".$_POST['layout_id']."' ".
151 " AND field_id IN (";
152 $comma = "";
153 foreach (explode(" ", $_POST['selectedfields']) as $onefield) {
154 $sqlstmt .= $comma."'".$onefield."'";
155 $comma = ", ";
157 $sqlstmt .= ")";
158 //echo $sqlstmt;
159 sqlStatement($sqlstmt);
162 else if ($_POST['formaction'] == "deletefields" && $layout_id) {
163 // Delete a field from a specific group
164 $sqlstmt = "DELETE FROM layout_options WHERE ".
165 " form_id = '".$_POST['layout_id']."' ".
166 " AND field_id IN (";
167 $comma = "";
168 foreach (explode(" ", $_POST['selectedfields']) as $onefield) {
169 $sqlstmt .= $comma."'".$onefield."'";
170 $comma = ", ";
172 $sqlstmt .= ")";
173 sqlStatement($sqlstmt);
175 if (substr($layout_id,0,3) != 'LBF') {
176 // drop the field from the table too (this is critical)
177 if ($layout_id == "DEM") { $tablename = "patient_data"; }
178 else if ($layout_id == "HIS") { $tablename = "history_data"; }
179 else if ($layout_id == "REF") { $tablename = "transactions"; }
180 else if ($layout_id == "SRH") { $tablename = "lists_ippf_srh"; }
181 else if ($layout_id == "CON") { $tablename = "lists_ippf_con"; }
182 else if ($layout_id == "GCA") { $tablename = "lists_ippf_gcac"; }
183 foreach (explode(" ", $_POST['selectedfields']) as $onefield) {
184 sqlStatement("ALTER TABLE `".$tablename."` DROP `".$onefield."`");
185 newEvent("alter_table", $_SESSION['authUser'], $_SESSION['authProvider'], 1, $tablename." DROP ".$onefield);
190 else if ($_POST['formaction'] == "addgroup" && $layout_id) {
191 // all group names are prefixed with a number indicating their display order
192 // this new group is prefixed with the net highest number given the
193 // layout_id
194 $results = sqlStatement("select distinct(group_name) as gname ".
195 " from layout_options where ".
196 " form_id = '".$_POST['layout_id']."'"
198 $maxnum = '1';
199 while ($result = sqlFetchArray($results)) {
200 $tmp = substr($result['gname'], 0, 1);
201 if ($tmp >= $maxnum) $maxnum = nextGroupOrder($tmp);
204 $data_type = formTrim($_POST['gnewdatatype']);
205 $max_length = $data_type == 3 ? 3 : 255;
207 // add a new group to the layout, with the defined field
208 sqlStatement("INSERT INTO layout_options (" .
209 " form_id, field_id, title, group_name, seq, uor, fld_length" .
210 ", titlecols, datacols, data_type, edit_options, default_value, description" .
211 ", max_length, list_id " .
212 ") VALUES ( " .
213 "'" . formTrim($_POST['layout_id'] ) . "'" .
214 ",'" . formTrim($_POST['gnewid'] ) . "'" .
215 ",'" . formTrim($_POST['gnewtitle'] ) . "'" .
216 ",'" . formTrim($maxnum . $_POST['newgroupname']) . "'" .
217 ",'" . formTrim($_POST['gnewseq'] ) . "'" .
218 ",'" . formTrim($_POST['gnewuor'] ) . "'" .
219 ",'" . formTrim($_POST['gnewlength'] ) . "'" .
220 ",'" . formTrim($_POST['gnewtitlecols'] ) . "'" .
221 ",'" . formTrim($_POST['gnewdatacols'] ) . "'" .
222 ",'$data_type'" .
223 ",'" . formTrim($_POST['gnewedit_options']) . "'" .
224 ",'" . formTrim($_POST['gnewdefault'] ) . "'" .
225 ",'" . formTrim($_POST['gnewdesc'] ) . "'" .
226 ",'$max_length'" .
227 ",'" . formTrim($_POST['gnewlistid'] ) . "'" .
228 " )");
230 if (substr($layout_id,0,3) != 'LBF') {
231 // Add the field to the table too (this is critical)
232 if ($layout_id == "DEM") { $tablename = "patient_data"; }
233 else if ($layout_id == "HIS") { $tablename = "history_data"; }
234 else if ($layout_id == "REF") { $tablename = "transactions"; }
235 else if ($layout_id == "SRH") { $tablename = "lists_ippf_srh"; }
236 else if ($layout_id == "CON") { $tablename = "lists_ippf_con"; }
237 else if ($layout_id == "GCA") { $tablename = "lists_ippf_gcac"; }
238 sqlStatement("ALTER TABLE `" . $tablename . "` ADD ".
239 "`" . formTrim($_POST['gnewid']) . "`" .
240 " VARCHAR( 255 )");
241 newEvent("alter_table", $_SESSION['authUser'], $_SESSION['authProvider'], 1,
242 $tablename . " ADD " . formTrim($_POST['gnewid']));
246 else if ($_POST['formaction'] == "deletegroup" && $layout_id) {
247 // drop the fields from the related table (this is critical)
248 if (substr($layout_id,0,3) != 'LBF') {
249 $res = sqlStatement("SELECT field_id FROM layout_options WHERE " .
250 " form_id = '".$_POST['layout_id']."' ".
251 " AND group_name = '".$_POST['deletegroupname']."'"
253 while ($row = sqlFetchArray($res)) {
254 // drop the field from the table too (this is critical)
255 if ($layout_id == "DEM") { $tablename = "patient_data"; }
256 else if ($layout_id == "HIS") { $tablename = "history_data"; }
257 else if ($layout_id == "REF") { $tablename = "transactions"; }
258 else if ($layout_id == "SRH") { $tablename = "lists_ippf_srh"; }
259 else if ($layout_id == "CON") { $tablename = "lists_ippf_con"; }
260 else if ($layout_id == "GCA") { $tablename = "lists_ippf_gcac"; }
261 sqlStatement("ALTER TABLE `".$tablename."` DROP `".$row['field_id']."`");
262 newEvent("alter_table", $_SESSION['authUser'], $_SESSION['authProvider'], 1, $tablename." DROP ".trim($row['field_id']));
266 // Delete an entire group from the form
267 sqlStatement("DELETE FROM layout_options WHERE ".
268 " form_id = '".$_POST['layout_id']."' ".
269 " AND group_name = '".$_POST['deletegroupname']."'"
273 else if ($_POST['formaction'] == "movegroup" && $layout_id) {
274 $results = sqlStatement("SELECT DISTINCT(group_name) AS gname " .
275 "FROM layout_options WHERE form_id = '$layout_id' " .
276 "ORDER BY gname");
277 $garray = array();
278 $i = 0;
279 while ($result = sqlFetchArray($results)) {
280 if ($result['gname'] == $_POST['movegroupname']) {
281 if ($_POST['movedirection'] == 'up') { // moving up
282 if ($i > 0) {
283 $garray[$i] = $garray[$i - 1];
284 $garray[$i - 1] = $result['gname'];
285 $i++;
287 else {
288 $garray[$i++] = $result['gname'];
291 else { // moving down
292 $garray[$i++] = '';
293 $garray[$i++] = $result['gname'];
296 else if ($i > 1 && $garray[$i - 2] == '') {
297 $garray[$i - 2] = $result['gname'];
299 else {
300 $garray[$i++] = $result['gname'];
303 $nextord = '1';
304 foreach ($garray as $value) {
305 if ($value === '') continue;
306 $newname = $nextord . substr($value, 1);
307 sqlStatement("UPDATE layout_options SET " .
308 "group_name = '$newname' WHERE " .
309 "form_id = '$layout_id' AND " .
310 "group_name = '$value'");
311 $nextord = nextGroupOrder($nextord);
315 else if ($_POST['formaction'] == "renamegroup" && $layout_id) {
316 $currpos = substr($_POST['renameoldgroupname'], 0, 1);
317 // update the database rows
318 sqlStatement("UPDATE layout_options SET " .
319 "group_name = '" . $currpos . $_POST['renamegroupname'] . "' ".
320 "WHERE form_id = '$layout_id' AND ".
321 "group_name = '" . $_POST['renameoldgroupname'] . "'");
324 // Get the selected form's elements.
325 if ($layout_id) {
326 $res = sqlStatement("SELECT * FROM layout_options WHERE " .
327 "form_id = '$layout_id' ORDER BY group_name, seq");
330 // global counter for field numbers
331 $fld_line_no = 0;
333 // Write one option line to the form.
335 function writeFieldLine($linedata) {
336 global $fld_line_no;
337 ++$fld_line_no;
338 $checked = $linedata['default_value'] ? " checked" : "";
340 //echo " <tr bgcolor='$bgcolor'>\n";
341 echo " <tr id='fld[$fld_line_no]' class='".($fld_line_no % 2 ? 'even' : 'odd')."'>\n";
343 echo " <td class='optcell' nowrap>";
344 // tuck the group_name INPUT in here
345 echo "<input type='hidden' name='fld[$fld_line_no][group]' value='" .
346 htmlspecialchars($linedata['group_name'], ENT_QUOTES) . "' class='optin' />";
348 echo "<input type='checkbox' class='selectfield' ".
349 "name='".$linedata['group_name']."~".$linedata['field_id']."' ".
350 "id='".$linedata['group_name']."~".$linedata['field_id']."' ".
351 "title='".htmlspecialchars(xl('Select field', ENT_QUOTES))."'>";
353 echo "<input type='text' name='fld[$fld_line_no][seq]' id='fld[$fld_line_no][seq]' value='" .
354 htmlspecialchars($linedata['seq'], ENT_QUOTES) . "' size='2' maxlength='3' class='optin' />";
355 echo "</td>\n";
357 echo " <td align='left' class='optcell'>";
358 echo "<input type='text' name='fld[$fld_line_no][id]' value='" .
359 htmlspecialchars($linedata['field_id'], ENT_QUOTES) . "' size='15' maxlength='63' class='optin noselect' />";
361 echo "<input type='hidden' name='fld[$fld_line_no][id]' value='" .
362 htmlspecialchars($linedata['field_id'], ENT_QUOTES) . "' />";
363 echo htmlspecialchars($linedata['field_id'], ENT_QUOTES);
365 echo "</td>\n";
367 echo " <td align='center' class='optcell'>";
368 echo "<input type='text' id='fld[$fld_line_no][title]' name='fld[$fld_line_no][title]' value='" .
369 htmlspecialchars($linedata['title'], ENT_QUOTES) . "' size='15' maxlength='63' class='optin' />";
370 echo "</td>\n";
372 // if not english and set to translate layout labels, then show the translation
373 if ($GLOBALS['translate_layout'] && $_SESSION['language_choice'] > 1) {
374 echo "<td align='center' class='translation'>" . htmlspecialchars(xl($linedata['title']), ENT_QUOTES) . "</td>\n";
377 echo " <td align='center' class='optcell'>";
378 echo "<select name='fld[$fld_line_no][uor]' class='optin'>";
379 foreach (array(0 =>xl('Unused'), 1 =>xl('Optional'), 2 =>xl('Required')) as $key => $value) {
380 echo "<option value='$key'";
381 if ($key == $linedata['uor']) echo " selected";
382 echo ">$value</option>\n";
384 echo "</select>";
385 echo "</td>\n";
387 echo " <td align='center' class='optcell'>";
388 echo "<select name='fld[$fld_line_no][data_type]' id='fld[$fld_line_no][data_type]'>";
389 echo "<option value=''></option>";
390 GLOBAL $datatypes;
391 foreach ($datatypes as $key=>$value) {
392 if ($linedata['data_type'] == $key)
393 echo "<option value='$key' selected>$value</option>";
394 else
395 echo "<option value='$key'>$value</option>";
397 echo "</select>";
398 echo " </td>";
400 echo " <td align='center' class='optcell'>";
401 if ($linedata['data_type'] == 2 || $linedata['data_type'] == 3 ||
402 $linedata['data_type'] == 21 || $linedata['data_type'] == 22 ||
403 $linedata['data_type'] == 23 || $linedata['data_type'] == 25 ||
404 $linedata['data_type'] == 27 || $linedata['data_type'] == 28)
406 echo "<input type='text' name='fld[$fld_line_no][length]' value='" .
407 htmlspecialchars($linedata['fld_length'], ENT_QUOTES) .
408 "' size='1' maxlength='10' class='optin' />";
410 else {
411 // all other data_types
412 echo "<input type='hidden' name='fld[$fld_line_no][length]' value=''>";
414 echo "</td>\n";
416 echo " <td align='center' class='optcell'>";
417 if ($linedata['data_type'] == 1 || $linedata['data_type'] == 21 ||
418 $linedata['data_type'] == 22 || $linedata['data_type'] == 23 ||
419 $linedata['data_type'] == 25 || $linedata['data_type'] == 26 ||
420 $linedata['data_type'] == 27)
422 echo "<input type='text' name='fld[$fld_line_no][list_id]' value='" .
423 htmlspecialchars($linedata['list_id'], ENT_QUOTES) . "'".
424 "size='6' maxlength='30' class='optin listid' style='cursor: pointer'".
425 "title='". xl('Choose list') . "' />";
427 else {
428 // all other data_types
429 echo "<input type='hidden' name='fld[$fld_line_no][list_id]' value=''>";
431 echo "</td>\n";
433 echo " <td align='center' class='optcell'>";
434 echo "<input type='text' name='fld[$fld_line_no][titlecols]' value='" .
435 htmlspecialchars($linedata['titlecols'], ENT_QUOTES) . "' size='3' maxlength='10' class='optin' />";
436 echo "</td>\n";
438 echo " <td align='center' class='optcell'>";
439 echo "<input type='text' name='fld[$fld_line_no][datacols]' value='" .
440 htmlspecialchars($linedata['datacols'], ENT_QUOTES) . "' size='3' maxlength='10' class='optin' />";
441 echo "</td>\n";
443 echo " <td align='center' class='optcell' title='C = ".xl('Capitalize').", D = ".xl('Dup Check').", N = ".xl('New Patient Form').", O = ".xl('Order Processor').", V = ".xl('Vendor')."'>";
444 echo "<input type='text' name='fld[$fld_line_no][edit_options]' value='" .
445 htmlspecialchars($linedata['edit_options'], ENT_QUOTES) . "' size='3' maxlength='36' class='optin' />";
446 echo "</td>\n";
448 /*****************************************************************
449 echo " <td align='center' class='optcell'>";
450 if ($linedata['data_type'] == 2) {
451 echo "<input type='text' name='fld[$fld_line_no][default]' value='" .
452 htmlspecialchars($linedata['default_value'], ENT_QUOTES) . "' size='10' maxlength='63' class='optin' />";
453 } else {
454 echo "&nbsp;";
456 echo "</td>\n";
458 echo " <td align='center' class='optcell'>";
459 echo "<input type='text' name='fld[$fld_line_no][desc]' value='" .
460 htmlspecialchars($linedata['description'], ENT_QUOTES) . "' size='20' maxlength='63' class='optin' />";
461 echo "</td>\n";
463 // if not english and showing layout labels, then show the translation of Description
464 if ($GLOBALS['translate_layout'] && $_SESSION['language_choice'] > 1) {
465 echo "<td align='center' class='translation'>" . htmlspecialchars(xl($linedata['description']), ENT_QUOTES) . "</td>\n";
467 *****************************************************************/
469 if ($linedata['data_type'] == 31) {
470 echo " <td align='center' class='optcell'>";
471 echo "<textarea name='fld[$fld_line_no][desc]' rows='3' cols='35' class='optin'>" .
472 $linedata['description'] . "</textarea>";
473 echo "<input type='hidden' name='fld[$fld_line_no][default]' value='" .
474 htmlspecialchars($linedata['default_value'], ENT_QUOTES) . "' />";
475 echo "</td>\n";
477 else {
478 echo " <td align='center' class='optcell'>";
479 echo "<input type='text' name='fld[$fld_line_no][desc]' value='" .
480 htmlspecialchars($linedata['description'], ENT_QUOTES) .
481 "' size='30' maxlength='63' class='optin' />";
482 echo "<input type='hidden' name='fld[$fld_line_no][default]' value='" .
483 htmlspecialchars($linedata['default_value'], ENT_QUOTES) . "' />";
484 echo "</td>\n";
485 // if not english and showing layout labels, then show the translation of Description
486 if ($GLOBALS['translate_layout'] && $_SESSION['language_choice'] > 1) {
487 echo "<td align='center' class='translation'>" .
488 htmlspecialchars(xl($linedata['description']), ENT_QUOTES) . "</td>\n";
492 echo " </tr>\n";
495 <html>
497 <head>
498 <?php html_header_show();?>
500 <!-- supporting javascript code -->
501 <script type="text/javascript" src="<?php echo $GLOBALS['webroot'] ?>/library/js/jquery.js"></script>
503 <link rel="stylesheet" href='<?php echo $css_header ?>' type='text/css'>
505 <title><?php xl('Layout Editor','e'); ?></title>
507 <style>
508 tr.head { font-size:10pt; background-color:#cccccc; }
509 tr.detail { font-size:10pt; }
510 td { font-size:10pt; }
511 input { font-size:10pt; }
512 a, a:visited, a:hover { color:#0000cc; }
513 .optcell { }
514 .optin { background: transparent; }
515 .group {
516 margin: 0pt 0pt 8pt 0pt;
517 padding: 0;
518 width: 100%;
520 .group table {
521 border-collapse: collapse;
522 width: 100%;
524 .odd td {
525 background-color: #ddddff;
526 padding: 3px 0px 3px 0px;
528 .even td {
529 background-color: #ffdddd;
530 padding: 3px 0px 3px 0px;
532 .help { cursor: help; }
533 .layouts_title { font-size: 110%; }
534 .translation {
535 color: green;
536 font-size:10pt;
538 .highlight * {
539 border: 2px solid blue;
540 background-color: yellow;
541 color: black;
543 </style>
545 </head>
547 <body class="body_top">
549 <form method='post' name='theform' id='theform' action='edit_layout.php'>
550 <input type="hidden" name="formaction" id="formaction" value="">
551 <!-- elements used to identify a field to delete -->
552 <input type="hidden" name="deletefieldid" id="deletefieldid" value="">
553 <input type="hidden" name="deletefieldgroup" id="deletefieldgroup" value="">
554 <!-- elements used to identify a group to delete -->
555 <input type="hidden" name="deletegroupname" id="deletegroupname" value="">
556 <!-- elements used to change the group order -->
557 <input type="hidden" name="movegroupname" id="movegroupname" value="">
558 <input type="hidden" name="movedirection" id="movedirection" value="">
559 <!-- elements used to select more than one field -->
560 <input type="hidden" name="selectedfields" id="selectedfields" value="">
561 <input type="hidden" id="targetgroup" name="targetgroup" value="">
563 <p><b><?php xl('Edit layout','e'); ?>:</b>&nbsp;
564 <select name='layout_id' id='layout_id'>
565 <option value=''>-- <?php echo xl('Select') ?> --</option>
566 <?php
567 foreach ($layouts as $key => $value) {
568 echo " <option value='$key'";
569 if ($key == $layout_id) echo " selected";
570 echo ">$value</option>\n";
573 </select></p>
575 <?php if ($layout_id) { ?>
576 <div style='margin: 0 0 8pt 0;'>
577 <input type='button' class='addgroup' id='addgroup' value=<?php xl('Add Group','e','\'','\''); ?>/>
578 </div>
579 <?php } ?>
581 <?php
582 $prevgroup = "!@#asdf1234"; // an unlikely group name
583 $firstgroup = true; // flag indicates it's the first group to be displayed
584 while ($row = sqlFetchArray($res)) {
585 if ($row['group_name'] != $prevgroup) {
586 if ($firstgroup == false) { echo "</tbody></table></div>\n"; }
587 echo "<div id='".$row['group_name']."' class='group'>";
588 echo "<div class='text bold layouts_title' style='position:relative; background-color: #eef'>";
589 // echo preg_replace("/^\d+/", "", $row['group_name']);
590 echo substr($row['group_name'], 1);
591 echo "&nbsp; ";
592 // if not english and set to translate layout labels, then show the translation of group name
593 if ($GLOBALS['translate_layout'] && $_SESSION['language_choice'] > 1) {
594 // echo "<span class='translation'>>>&nbsp; " . xl(preg_replace("/^\d+/", "", $row['group_name'])) . "</span>";
595 echo "<span class='translation'>>>&nbsp; " . xl(substr($row['group_name'], 1)) . "</span>";
596 echo "&nbsp; ";
598 echo "&nbsp; ";
599 echo " <input type='button' class='addfield' id='addto~".$row['group_name']."' value='" . xl('Add Field') . "'/>";
600 echo "&nbsp; &nbsp; ";
601 echo " <input type='button' class='renamegroup' id='".$row['group_name']."' value='" . xl('Rename Group') . "'/>";
602 echo "&nbsp; &nbsp; ";
603 echo " <input type='button' class='deletegroup' id='".$row['group_name']."' value='" . xl('Delete Group') . "'/>";
604 echo "&nbsp; &nbsp; ";
605 echo " <input type='button' class='movegroup' id='".$row['group_name']."~up' value='" . xl('Move Up') . "'/>";
606 echo "&nbsp; &nbsp; ";
607 echo " <input type='button' class='movegroup' id='".$row['group_name']."~down' value='" . xl('Move Down') . "'/>";
608 echo "</div>";
609 $firstgroup = false;
612 <table>
613 <thead>
614 <tr class='head'>
615 <th><?php xl('Order','e'); ?></th>
616 <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>
617 <th><?php xl('Label','e'); ?> <span class="help" title=<?php xl('The label that appears to the user on the form','e','\'','\''); ?> >(?)</span></th>
618 <?php // if not english and showing layout label translations, then show translation header for title
619 if ($GLOBALS['translate_layout'] && $_SESSION['language_choice'] > 1) {
620 echo "<th>" . xl('Translation')."<span class='help' title='" . xl('The translated label that will appear on the form in current language') . "'> (?)</span></th>";
621 } ?>
622 <th><?php xl('UOR','e'); ?></th>
623 <th><?php xl('Data Type','e'); ?></th>
624 <th><?php xl('Size','e'); ?></th>
625 <th><?php xl('List','e'); ?></th>
626 <th><?php xl('Label Cols','e'); ?></th>
627 <th><?php xl('Data Cols','e'); ?></th>
628 <th><?php xl('Options','e'); ?></th>
629 <th><?php xl('Description','e'); ?></th>
630 <?php // if not english and showing layout label translations, then show translation header for description
631 if ($GLOBALS['translate_layout'] && $_SESSION['language_choice'] > 1) {
632 echo "<th>" . xl('Translation')."<span class='help' title='" . xl('The translation of description in current language')."'> (?)</span></th>";
633 } ?>
634 </tr>
635 </thead>
636 <tbody>
638 <?php
639 } // end if-group_name
641 writeFieldLine($row);
642 $prevgroup = $row['group_name'];
644 } // end while loop
647 </tbody>
648 </table></div>
650 <?php if ($layout_id) { ?>
651 <span style="font-size:90%">
652 <?php xl('With selected:', 'e');?>
653 <input type='button' name='deletefields' id='deletefields' value='<?php xl('Delete','e'); ?>' style="font-size:90%" disabled="disabled" />
654 <input type='button' name='movefields' id='movefields' value='<?php xl('Move to...','e'); ?>' style="font-size:90%" disabled="disabled" />
655 </span>
657 <input type='button' name='save' id='save' value='<?php xl('Save Changes','e'); ?>' />
658 </p>
659 <?php } ?>
661 </form>
663 <!-- template DIV that appears when user chooses to rename an existing group -->
664 <div id="renamegroupdetail" style="border: 1px solid black; padding: 3px; display: none; visibility: hidden; background-color: lightgrey;">
665 <input type="hidden" name="renameoldgroupname" id="renameoldgroupname" value="">
666 <?php xl('Group Name','e'); ?>: <input type="textbox" size="20" maxlength="30" name="renamegroupname" id="renamegroupname">
667 <br>
668 <input type="button" class="saverenamegroup" value=<?php xl('Rename Group','e','\'','\''); ?>>
669 <input type="button" class="cancelrenamegroup" value=<?php xl('Cancel','e','\'','\''); ?>>
670 </div>
672 <!-- template DIV that appears when user chooses to add a new group -->
673 <div id="groupdetail" style="border: 1px solid black; padding: 3px; display: none; visibility: hidden; background-color: lightgrey;">
674 <span class='bold'>
675 <?php xl('Group Name','e'); ?>: <input type="textbox" size="20" maxlength="30" name="newgroupname" id="newgroupname">
676 <br>
677 <table style="border-collapse: collapse; margin-top: 5px;">
678 <thead>
679 <tr class='head'>
680 <th><?php xl('Order','e'); ?></th>
681 <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>
682 <th><?php xl('Label','e'); ?> <span class="help" title=<?php xl('The label that appears to the user on the form','e','\'','\''); ?> >(?)</span></th>
683 <th><?php xl('UOR','e'); ?></th>
684 <th><?php xl('Data Type','e'); ?></th>
685 <th><?php xl('Size','e'); ?></th>
686 <th><?php xl('List','e'); ?></th>
687 <th><?php xl('Label Cols','e'); ?></th>
688 <th><?php xl('Data Cols','e'); ?></th>
689 <th><?php xl('Options','e'); ?></th>
690 <th><?php xl('Description','e'); ?></th>
691 </tr>
692 </thead>
693 <tbody>
694 <tr class='center'>
695 <td ><input type="textbox" name="gnewseq" id="gnewseq" value="" size="2" maxlength="3"> </td>
696 <td ><input type="textbox" name="gnewid" id="gnewid" value="" size="10" maxlength="20"> </td>
697 <td><input type="textbox" name="gnewtitle" id="gnewtitle" value="" size="20" maxlength="63"> </td>
698 <td>
699 <select name="gnewuor" id="gnewuor">
700 <option value="0"><?php xl('Unused','e'); ?></option>
701 <option value="1" selected><?php xl('Optional','e'); ?></option>
702 <option value="2"><?php xl('Required','e'); ?></option>
703 </select>
704 </td>
705 <td align='center'>
706 <select name='gnewdatatype' id='gnewdatatype'>
707 <option value=''></option>
708 <?php
709 global $datatypes;
710 foreach ($datatypes as $key=>$value) {
711 echo "<option value='$key'>$value</option>";
714 </select>
715 </td>
716 <td><input type="textbox" name="gnewlength" id="gnewlength" value="" size="1" maxlength="3"> </td>
717 <td><input type="textbox" name="gnewlistid" id="gnewlistid" value="" size="8" maxlength="31" class="listid"> </td>
718 <td><input type="textbox" name="gnewtitlecols" id="gnewtitlecols" value="" size="3" maxlength="3"> </td>
719 <td><input type="textbox" name="gnewdatacols" id="gnewdatacols" value="" size="3" maxlength="3"> </td>
720 <td><input type="textbox" name="gnewedit_options" id="gnewedit_options" value="" size="3" maxlength="36">
721 <input type="hidden" name="gnewdefault" id="gnewdefault" value="" /> </td>
722 <td><input type="textbox" name="gnewdesc" id="gnewdesc" value="" size="30" maxlength="63"> </td>
723 </tr>
724 </tbody>
725 </table>
726 <br>
727 <input type="button" class="savenewgroup" value=<?php xl('Save New Group','e','\'','\''); ?>>
728 <input type="button" class="cancelnewgroup" value=<?php xl('Cancel','e','\'','\''); ?>>
729 </span>
730 </div>
732 <!-- template DIV that appears when user chooses to add a new field to a group -->
733 <div id="fielddetail" class="fielddetail" style="display: none; visibility: hidden">
734 <input type="hidden" name="newfieldgroupid" id="newfieldgroupid" value="">
735 <table style="border-collapse: collapse;">
736 <thead>
737 <tr class='head'>
738 <th><?php xl('Order','e'); ?></th>
739 <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>
740 <th><?php xl('Label','e'); ?> <span class="help" title=<?php xl('The label that appears to the user on the form','e','\'','\''); ?> >(?)</span></th>
741 <th><?php xl('UOR','e'); ?></th>
742 <th><?php xl('Data Type','e'); ?></th>
743 <th><?php xl('Size','e'); ?></th>
744 <th><?php xl('List','e'); ?></th>
745 <th><?php xl('Label Cols','e'); ?></th>
746 <th><?php xl('Data Cols','e'); ?></th>
747 <th><?php xl('Options','e'); ?></th>
748 <th><?php xl('Description','e'); ?></th>
749 </tr>
750 </thead>
751 <tbody>
752 <tr class='center'>
753 <td ><input type="textbox" name="newseq" id="newseq" value="" size="2" maxlength="3"> </td>
754 <td ><input type="textbox" name="newid" id="newid" value="" size="10" maxlength="20"> </td>
755 <td><input type="textbox" name="newtitle" id="newtitle" value="" size="20" maxlength="63"> </td>
756 <td>
757 <select name="newuor" id="newuor">
758 <option value="0"><?php xl('Unused','e'); ?></option>
759 <option value="1" selected><?php xl('Optional','e'); ?></option>
760 <option value="2"><?php xl('Required','e'); ?></option>
761 </select>
762 </td>
763 <td align='center'>
764 <select name='newdatatype' id='newdatatype'>
765 <option value=''></option>
766 <?php
767 global $datatypes;
768 foreach ($datatypes as $key=>$value) {
769 echo " <option value='$key'>$value</option>\n";
772 </select>
773 </td>
774 <td><input type="textbox" name="newlength" id="newlength" value="" size="1" maxlength="3"> </td>
775 <td><input type="textbox" name="newlistid" id="newlistid" value="" size="8" maxlength="31" class="listid"> </td>
776 <td><input type="textbox" name="newtitlecols" id="newtitlecols" value="" size="3" maxlength="3"> </td>
777 <td><input type="textbox" name="newdatacols" id="newdatacols" value="" size="3" maxlength="3"> </td>
778 <td><input type="textbox" name="newedit_options" id="newedit_options" value="" size="3" maxlength="36">
779 <input type="hidden" name="newdefault" id="newdefault" value="" /> </td>
780 <td><input type="textbox" name="newdesc" id="newdesc" value="" size="30" maxlength="63"> </td>
781 </tr>
782 <tr>
783 <td colspan="9">
784 <input type="button" class="savenewfield" value=<?php xl('Save New Field','e','\'','\''); ?>>
785 <input type="button" class="cancelnewfield" value=<?php xl('Cancel','e','\'','\''); ?>>
786 </td>
787 </tr>
788 </tbody>
789 </table>
790 </div>
792 </body>
794 <script language="javascript">
796 // used when selecting a list-name for a field
797 var selectedfield;
799 // jQuery stuff to make the page a little easier to use
801 $(document).ready(function(){
802 $("#save").click(function() { SaveChanges(); });
803 $("#layout_id").change(function() { $('#theform').submit(); });
805 $(".addgroup").click(function() { AddGroup(this); });
806 $(".savenewgroup").click(function() { SaveNewGroup(this); });
807 $(".deletegroup").click(function() { DeleteGroup(this); });
808 $(".cancelnewgroup").click(function() { CancelNewGroup(this); });
810 $(".movegroup").click(function() { MoveGroup(this); });
812 $(".renamegroup").click(function() { RenameGroup(this); });
813 $(".saverenamegroup").click(function() { SaveRenameGroup(this); });
814 $(".cancelrenamegroup").click(function() { CancelRenameGroup(this); });
816 $(".addfield").click(function() { AddField(this); });
817 $("#deletefields").click(function() { DeleteFields(this); });
818 $(".selectfield").click(function() {
819 var TRparent = $(this).parent().parent();
820 $(TRparent).children("td").toggleClass("highlight");
821 // disable the delete-move buttons
822 $("#deletefields").attr("disabled", "disabled");
823 $("#movefields").attr("disabled", "disabled");
824 $(".selectfield").each(function(i) {
825 // if any field is selected, enable the delete-move buttons
826 if ($(this).attr("checked") == true) {
827 $("#deletefields").removeAttr("disabled");
828 $("#movefields").removeAttr("disabled");
832 $("#movefields").click(function() { ShowGroups(this); });
833 $(".savenewfield").click(function() { SaveNewField(this); });
834 $(".cancelnewfield").click(function() { CancelNewField(this); });
835 $("#newtitle").blur(function() { if ($("#newid").val() == "") $("#newid").val($("#newtitle").val()); });
837 $(".listid").click(function() { ShowLists(this); });
839 // special class that skips the element
840 $(".noselect").focus(function() { $(this).blur(); });
842 // Save the changes made to the form
843 var SaveChanges = function () {
844 $("#formaction").val("save");
845 $("#theform").submit();
848 /****************************************************/
849 /************ Group functions ***********************/
850 /****************************************************/
852 // display the 'new group' DIV
853 var AddGroup = function(btnObj) {
854 // show the field details DIV
855 $('#groupdetail').css('visibility', 'visible');
856 $('#groupdetail').css('display', 'block');
857 $(btnObj).parent().append($("#groupdetail"));
858 $('#groupdetail > #newgroupname').focus();
861 // save the new group to the form
862 var SaveNewGroup = function(btnObj) {
863 // the group name field can only have letters, numbers, spaces and underscores
864 // AND it cannot start with a number
865 if ($("#newgroupname").val() == "") {
866 alert("<?php xl('Group names cannot be blank', 'e'); ?>");
867 return false;
869 if ($("#newgroupname").val().match(/^(\d+|\s+)/)) {
870 alert("<?php xl('Group names cannot start with numbers or spaces.','e'); ?>");
871 return false;
873 var validname = $("#newgroupname").val().replace(/[^A-za-z0-9 ]/g, "_"); // match any non-word characters and replace them
874 $("#newgroupname").val(validname);
876 // now, check the first group field values
878 // seq must be numeric and less than 999
879 if (! IsNumeric($("#gnewseq").val(), 0, 999)) {
880 alert("<?php xl('Order must be a number between 1 and 999','e'); ?>");
881 return false;
883 // length must be numeric and less than 999
884 if (! IsNumeric($("#gnewlength").val(), 0, 999)) {
885 alert("<?php xl('Size must be a number between 1 and 999','e'); ?>");
886 return false;
888 // titlecols must be numeric and less than 100
889 if (! IsNumeric($("#gnewtitlecols").val(), 0, 999)) {
890 alert("<?php xl('LabelCols must be a number between 1 and 999','e'); ?>");
891 return false;
893 // datacols must be numeric and less than 100
894 if (! IsNumeric($("#gnewdatacols").val(), 0, 999)) {
895 alert("<?php xl('DataCols must be a number between 1 and 999','e'); ?>");
896 return false;
898 // some fields cannot be blank
899 if ($("#gnewtitle").val() == "") {
900 alert("<?php xl('Label cannot be blank','e'); ?>");
901 return false;
903 // the id field can only have letters, numbers and underscores
904 if ($("#gnewid").val() == "") {
905 alert("<?php xl('ID cannot be blank', 'e'); ?>");
906 return false;
908 var validid = $("#gnewid").val().replace(/(\s|\W)/g, "_"); // match any non-word characters and replace them
909 $("#gnewid").val(validid);
910 // similarly with the listid field
911 validid = $("#gnewlistid").val().replace(/(\s|\W)/g, "_");
912 $("#gnewlistid").val(validid);
914 // submit the form to add a new field to a specific group
915 $("#formaction").val("addgroup");
916 $("#theform").submit();
919 // actually delete an entire group from the database
920 var DeleteGroup = function(btnObj) {
921 var parts = $(btnObj).attr("id");
922 var groupname = parts.replace(/^\d+/, "");
923 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+"'?")) {
924 // submit the form to add a new field to a specific group
925 $("#formaction").val("deletegroup");
926 $("#deletegroupname").val(parts);
927 $("#theform").submit();
931 // just hide the new field DIV
932 var CancelNewGroup = function(btnObj) {
933 // hide the field details DIV
934 $('#groupdetail').css('visibility', 'hidden');
935 $('#groupdetail').css('display', 'none');
936 // reset the new group values to a default
937 $('#groupdetail > #newgroupname').val("");
940 // display the 'new field' DIV
941 var MoveGroup = function(btnObj) {
942 var btnid = $(btnObj).attr("id");
943 var parts = btnid.split("~");
944 var groupid = parts[0];
945 var direction = parts[1];
947 // submit the form to change group order
948 $("#formaction").val("movegroup");
949 $("#movegroupname").val(groupid);
950 $("#movedirection").val(direction);
951 $("#theform").submit();
954 // show the rename group DIV
955 var RenameGroup = function(btnObj) {
956 $('#renamegroupdetail').css('visibility', 'visible');
957 $('#renamegroupdetail').css('display', 'block');
958 $(btnObj).parent().append($("#renamegroupdetail"));
959 $('#renameoldgroupname').val($(btnObj).attr("id"));
960 $('#renamegroupname').val($(btnObj).attr("id").replace(/^\d+/, ""));
963 // save the new group to the form
964 var SaveRenameGroup = function(btnObj) {
965 // the group name field can only have letters, numbers, spaces and underscores
966 // AND it cannot start with a number
967 if ($("#renamegroupname").val().match(/^\d+/)) {
968 alert("<?php xl('Group names cannot start with numbers.','e'); ?>");
969 return false;
971 var validname = $("#renamegroupname").val().replace(/[^A-za-z0-9 ]/g, "_"); // match any non-word characters and replace them
972 $("#renamegroupname").val(validname);
974 // submit the form to add a new field to a specific group
975 $("#formaction").val("renamegroup");
976 $("#theform").submit();
979 // just hide the new field DIV
980 var CancelRenameGroup = function(btnObj) {
981 // hide the field details DIV
982 $('#renamegroupdetail').css('visibility', 'hidden');
983 $('#renamegroupdetail').css('display', 'none');
984 // reset the rename group values to a default
985 $('#renameoldgroupname').val("");
986 $('#renamegroupname').val("");
989 /****************************************************/
990 /************ Field functions ***********************/
991 /****************************************************/
993 // display the 'new field' DIV
994 var AddField = function(btnObj) {
995 // update the fieldgroup value to be the groupid
996 var btnid = $(btnObj).attr("id");
997 var parts = btnid.split("~");
998 var groupid = parts[1];
999 $('#fielddetail > #newfieldgroupid').attr('value', groupid);
1001 // show the field details DIV
1002 $('#fielddetail').css('visibility', 'visible');
1003 $('#fielddetail').css('display', 'block');
1004 $(btnObj).parent().append($("#fielddetail"));
1007 var DeleteFields = function(btnObj) {
1008 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'); ?>")) {
1009 var delim = "";
1010 $(".selectfield").each(function(i) {
1011 // build a list of selected field names to be moved
1012 if ($(this).attr("checked") == true) {
1013 var parts = this.id.split("~");
1014 var currval = $("#selectedfields").val();
1015 $("#selectedfields").val(currval+delim+parts[1]);
1016 delim = " ";
1019 // submit the form to delete the field(s)
1020 $("#formaction").val("deletefields");
1021 $("#theform").submit();
1025 // save the new field to the form
1026 var SaveNewField = function(btnObj) {
1027 // check the new field values for correct formatting
1029 // seq must be numeric and less than 999
1030 if (! IsNumeric($("#newseq").val(), 0, 999)) {
1031 alert("<?php xl('Order must be a number between 1 and 999','e'); ?>");
1032 return false;
1034 // length must be numeric and less than 999
1035 if (! IsNumeric($("#newlength").val(), 0, 999)) {
1036 alert("<?php xl('Size must be a number between 1 and 999','e'); ?>");
1037 return false;
1039 // titlecols must be numeric and less than 100
1040 if (! IsNumeric($("#newtitlecols").val(), 0, 999)) {
1041 alert("<?php xl('LabelCols must be a number between 1 and 999','e'); ?>");
1042 return false;
1044 // datacols must be numeric and less than 100
1045 if (! IsNumeric($("#newdatacols").val(), 0, 999)) {
1046 alert("<?php xl('DataCols must be a number between 1 and 999','e'); ?>");
1047 return false;
1049 // some fields cannot be blank
1050 if ($("#newtitle").val() == "") {
1051 alert("<?php xl('Label cannot be blank','e'); ?>");
1052 return false;
1054 // the id field can only have letters, numbers and underscores
1055 var validid = $("#newid").val().replace(/(\s|\W)/g, "_"); // match any non-word characters and replace them
1056 $("#newid").val(validid);
1057 // similarly with the listid field
1058 validid = $("#newlistid").val().replace(/(\s|\W)/g, "_");
1059 $("#newlistid").val(validid);
1061 // submit the form to add a new field to a specific group
1062 $("#formaction").val("addfield");
1063 $("#theform").submit();
1066 // just hide the new field DIV
1067 var CancelNewField = function(btnObj) {
1068 // hide the field details DIV
1069 $('#fielddetail').css('visibility', 'hidden');
1070 $('#fielddetail').css('display', 'none');
1071 // reset the new field values to a default
1072 ResetNewFieldValues();
1075 // show the popup choice of lists
1076 var ShowLists = function(btnObj) {
1077 window.open("./show_lists_popup.php", "lists", "width=300,height=500,scrollbars=yes");
1078 selectedfield = btnObj;
1081 // show the popup choice of groups
1082 var ShowGroups = function(btnObj) {
1083 window.open("./show_groups_popup.php?layout_id=<?php echo $layout_id;?>", "groups", "width=300,height=300,scrollbars=yes");
1088 function SetList(listid) { $(selectedfield).val(listid); }
1091 /* this is called after the user chooses a new group from the popup window
1092 * it will submit the page so the selected fields can be moved into
1093 * the target group
1095 function MoveFields(targetgroup) {
1096 $("#targetgroup").val(targetgroup);
1097 var delim = "";
1098 $(".selectfield").each(function(i) {
1099 // build a list of selected field names to be moved
1100 if ($(this).attr("checked") == true) {
1101 var parts = this.id.split("~");
1102 var currval = $("#selectedfields").val();
1103 $("#selectedfields").val(currval+delim+parts[1]);
1104 delim = " ";
1107 $("#formaction").val("movefields");
1108 $("#theform").submit();
1112 // set the new-field values to a default state
1113 function ResetNewFieldValues () {
1114 $("#newseq").val("");
1115 $("#newid").val("");
1116 $("#newtitle").val("");
1117 $("#newuor").val(1);
1118 $("#newlength").val("");
1119 $("#newdatatype").val("");
1120 $("#newlistid").val("");
1121 $("#newtitlecols").val("");
1122 $("#newdatacols").val("");
1123 $("#newedit_options").val("");
1124 $("#newdefault").val("");
1125 $("#newdesc").val("");
1128 // is value an integer and between min and max
1129 function IsNumeric(value, min, max) {
1130 if (value == "" || value == null) return false;
1131 if (! IsN(value) ||
1132 parseInt(value) < min ||
1133 parseInt(value) > max)
1134 return false;
1136 return true;
1139 /****************************************************/
1140 /****************************************************/
1141 /****************************************************/
1143 // tell if num is an Integer
1144 function IsN(num) { return !/\D/.test(num); }
1145 </script>
1147 </html>