3 * Copyright (C) 2014-2016 Rod Roark <rod@sunsetsystems.com>
5 * LICENSE: This program is free software; you can redistribute it and/or
6 * modify it under the terms of the GNU General Public License
7 * as published by the Free Software Foundation; either version 2
8 * of the License, or (at your option) any later version.
9 * This program is distributed in the hope that it will be useful,
10 * but WITHOUT ANY WARRANTY; without even the implied warranty of
11 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12 * GNU General Public License for more details.
13 * You should have received a copy of the GNU General Public License
14 * along with this program. If not, see <http://opensource.org/licenses/gpl-license.php>.
17 * @author Rod Roark <rod@sunsetsystems.com>
18 * @link http://www.open-emr.org
21 require_once("../globals.php");
22 require_once("$srcdir/acl.inc");
23 require_once("$srcdir/log.inc");
26 'DEM' => xl('Demographics'),
27 'HIS' => xl('History'),
28 'FACUSR' => xl('Facility Specific User Information')
30 if ($GLOBALS['ippf_specific']) {
31 $layouts['GCA'] = xl('Abortion Issues');
32 $layouts['CON'] = xl('Contraception Issues');
35 // Include Layout Based Transaction Forms.
36 $lres = sqlStatement("SELECT * FROM list_options " .
37 "WHERE list_id = 'transactions' AND activity = 1 ORDER BY seq, title");
38 while ($lrow = sqlFetchArray($lres)) {
39 $layouts[$lrow['option_id']] = xl_list_label($lrow['title']);
42 // Include Layout Based Encounter Forms.
43 $lres = sqlStatement("SELECT * FROM list_options " .
44 "WHERE list_id = 'lbfnames' AND activity = 1 ORDER BY seq, title");
45 while ($lrow = sqlFetchArray($lres)) {
46 $layouts[$lrow['option_id']] = xl_list_label($lrow['title']);
49 // Include predefined Validation Rules from list
50 $validations = array();
51 $lres = sqlStatement("SELECT * FROM list_options " .
52 "WHERE list_id = 'LBF_Validations' AND activity = 1 ORDER BY seq, title");
53 while ($lrow = sqlFetchArray($lres)) {
54 $validations[$lrow['option_id']] = xl_list_label($lrow['title']);
57 // array of the data_types of the fields
59 "1" => xl("List box"),
61 "3" => xl("Textarea"),
62 "4" => xl("Text-date"),
63 "10" => xl("Providers"),
64 "11" => xl("Providers NPI"),
65 "12" => xl("Pharmacies"),
67 "14" => xl("Organizations"),
68 "15" => xl("Billing codes"),
69 "16" => xl("Insurances"),
70 "18" => xl("Visit Categories"),
71 "21" => xl("Checkbox list"),
72 "22" => xl("Textbox list"),
73 "23" => xl("Exam results"),
74 "24" => xl("Patient allergies"),
75 "25" => xl("Checkbox w/text"),
76 "26" => xl("List box w/add"),
77 "27" => xl("Radio buttons"),
78 "28" => xl("Lifestyle status"),
79 "31" => xl("Static Text"),
80 "32" => xl("Smoking Status"),
81 "33" => xl("Race and Ethnicity"),
82 "34" => xl("NationNotes"),
83 "35" => xl("Facilities"),
84 "36" => xl("Multiple Select List"),
85 "40" => xl("Image canvas"),
96 function nextGroupOrder($order)
100 } else if ($order == 'Z') {
103 $order = chr(ord($order) +
1);
109 // Call this when adding or removing a layout field. This will create or drop
110 // the corresponding table column when appropriate. Table columns are not
111 // dropped if they contain any non-empty values.
112 function addOrDeleteColumn($layout_id, $field_id, $add = true)
114 if (substr($layout_id, 0, 3) == 'LBF' ||
substr($layout_id, 0, 3) == 'LBT' ||
$layout_id == "FACUSR") {
118 if ($layout_id == "DEM") {
119 $tablename = "patient_data";
120 } else if ($layout_id == "HIS") {
121 $tablename = "history_data";
122 } else if ($layout_id == "SRH") {
123 $tablename = "lists_ippf_srh";
124 } else if ($layout_id == "CON") {
125 $tablename = "lists_ippf_con";
126 } else if ($layout_id == "GCA") {
127 $tablename = "lists_ippf_gcac";
129 die('Internal error in addOrDeleteColumn()');
132 // Check if the column currently exists.
133 $tmp = sqlQuery("SHOW COLUMNS FROM `$tablename` LIKE '$field_id'");
134 $column_exists = !empty($tmp);
136 if ($add && !$column_exists) {
137 sqlStatement("ALTER TABLE `$tablename` ADD `$field_id` TEXT");
140 $_SESSION['authUser'],
141 $_SESSION['authProvider'],
143 "$tablename ADD $field_id"
145 } else if (!$add && $column_exists) {
146 // Do not drop a column that has any data.
147 $tmp = sqlQuery("SELECT `$field_id` FROM `$tablename` WHERE " .
148 "`$field_id` IS NOT NULL AND `$field_id` != '' LIMIT 1");
149 if (!isset($tmp['field_id'])) {
150 sqlStatement("ALTER TABLE `$tablename` DROP `$field_id`");
153 $_SESSION['authUser'],
154 $_SESSION['authProvider'],
156 "$tablename DROP $field_id "
162 // Check authorization.
163 $thisauth = acl_check('admin', 'super');
165 die(xl('Not authorized'));
168 // The layout ID identifies the layout to be edited.
169 $layout_id = empty($_REQUEST['layout_id']) ?
'' : $_REQUEST['layout_id'];
171 // Tag style for stuff to hide if not an LBF layout. Currently just for the Source column.
172 $lbfonly = substr($layout_id, 0, 3) == 'LBF' ?
"" : "style='display:none;'";
174 // Handle the Form actions
176 if ($_POST['formaction'] == "save" && $layout_id) {
177 // If we are saving, then save.
178 $fld = $_POST['fld'];
179 for ($lino = 1; isset($fld[$lino]['id']); ++
$lino) {
181 $field_id = formTrim($iter['id']);
182 $data_type = formTrim($iter['data_type']);
183 $listval = $data_type == 34 ?
formTrim($iter['contextName']) : formTrim($iter['list_id']);
185 // Skip conditions for the line are stored as a serialized array.
187 for ($cix = 0; !empty($iter['condition_id'][$cix]); ++
$cix) {
188 $andor = empty($iter['condition_andor'][$cix]) ?
'' : $iter['condition_andor'][$cix];
189 $condarr[$cix] = array(
190 'id' => strip_escape_custom($iter['condition_id' ][$cix]),
191 'itemid' => strip_escape_custom($iter['condition_itemid' ][$cix]),
192 'operator' => strip_escape_custom($iter['condition_operator'][$cix]),
193 'value' => strip_escape_custom($iter['condition_value' ][$cix]),
194 'andor' => strip_escape_custom($andor),
198 $conditions = empty($condarr) ?
'' : serialize($condarr);
200 sqlStatement("UPDATE layout_options SET " .
201 "source = '" . formTrim($iter['source']) . "', " .
202 "title = '" . formTrim($iter['title']) . "', " .
203 "group_name = '" . formTrim($iter['group']) . "', " .
204 "seq = '" . formTrim($iter['seq']) . "', " .
205 "uor = '" . formTrim($iter['uor']) . "', " .
206 "fld_length = '" . formTrim($iter['lengthWidth']) . "', " .
207 "fld_rows = '" . formTrim($iter['lengthHeight']) . "', " .
208 "max_length = '" . formTrim($iter['maxSize']) . "', " .
209 "titlecols = '" . formTrim($iter['titlecols']) . "', " .
210 "datacols = '" . formTrim($iter['datacols']) . "', " .
211 "data_type= '$data_type', " .
212 "list_id= '" . $listval . "', " .
213 "list_backup_id= '" . formTrim($iter['list_backup_id']) . "', " .
214 "edit_options = '" . formTrim($iter['edit_options']) . "', " .
215 "default_value = '" . formTrim($iter['default']) . "', " .
216 "description = '" . formTrim($iter['desc']) . "', " .
217 "conditions = '" . add_escape_custom($conditions) . "', " .
218 "validation = '" . formTrim($iter['validation']) . "' " .
219 "WHERE form_id = '$layout_id' AND field_id = '$field_id'");
222 } else if ($_POST['formaction'] == "addfield" && $layout_id) {
223 // Add a new field to a specific group
224 $data_type = formTrim($_POST['newdatatype']);
225 $max_length = $data_type == 3 ?
3 : 255;
226 $listval = $data_type == 34 ?
formTrim($_POST['contextName']) : formTrim($_POST['newlistid']);
227 sqlStatement("INSERT INTO layout_options (" .
228 " form_id, source, field_id, title, group_name, seq, uor, fld_length, fld_rows" .
229 ", titlecols, datacols, data_type, edit_options, default_value, description" .
230 ", max_length, list_id, list_backup_id " .
232 "'" . formTrim($_POST['layout_id']) . "'" .
233 ",'" . formTrim($_POST['newsource']) . "'" .
234 ",'" . formTrim($_POST['newid']) . "'" .
235 ",'" . formTrim($_POST['newtitle']) . "'" .
236 ",'" . formTrim($_POST['newfieldgroupid']) . "'" .
237 ",'" . formTrim($_POST['newseq']) . "'" .
238 ",'" . formTrim($_POST['newuor']) . "'" .
239 ",'" . formTrim($_POST['newlengthWidth']) . "'" .
240 ",'" . formTrim($_POST['newlengthHeight']) . "'" .
241 ",'" . formTrim($_POST['newtitlecols']) . "'" .
242 ",'" . formTrim($_POST['newdatacols']) . "'" .
244 ",'" . formTrim($_POST['newedit_options']) . "'" .
245 ",'" . formTrim($_POST['newdefault']) . "'" .
246 ",'" . formTrim($_POST['newdesc']) . "'" .
247 ",'" . formTrim($_POST['newmaxSize']) . "'" .
248 ",'" . $listval . "'" .
249 ",'" . formTrim($_POST['newbackuplistid']) . "'" .
251 addOrDeleteColumn($layout_id, formTrim($_POST['newid']), true);
252 } else if ($_POST['formaction'] == "movefields" && $layout_id) {
253 // Move field(s) to a new group in the layout
254 $sqlstmt = "UPDATE layout_options SET ".
255 " group_name='". $_POST['targetgroup']."' ".
257 " form_id = '".$_POST['layout_id']."' ".
258 " AND field_id IN (";
260 foreach (explode(" ", $_POST['selectedfields']) as $onefield) {
261 $sqlstmt .= $comma."'".$onefield."'";
267 sqlStatement($sqlstmt);
268 } else if ($_POST['formaction'] == "deletefields" && $layout_id) {
269 // Delete a field from a specific group
270 $sqlstmt = "DELETE FROM layout_options WHERE ".
271 " form_id = '".$_POST['layout_id']."' ".
272 " AND field_id IN (";
274 foreach (explode(" ", $_POST['selectedfields']) as $onefield) {
275 $sqlstmt .= $comma."'".$onefield."'";
280 sqlStatement($sqlstmt);
281 foreach (explode(" ", $_POST['selectedfields']) as $onefield) {
282 addOrDeleteColumn($layout_id, $onefield, false);
284 } else if ($_POST['formaction'] == "addgroup" && $layout_id) {
285 // all group names are prefixed with a number indicating their display order
286 // this new group is prefixed with the net highest number given the
288 $results = sqlStatement("select distinct(group_name) as gname ".
289 " from layout_options where ".
290 " form_id = '".$_POST['layout_id']."'");
292 while ($result = sqlFetchArray($results)) {
293 $tmp = substr($result['gname'], 0, 1);
294 if ($tmp >= $maxnum) {
295 $maxnum = nextGroupOrder($tmp);
299 $data_type = formTrim($_POST['gnewdatatype']);
300 $max_length = $data_type == 3 ?
3 : 255;
301 $listval = $data_type == 34 ?
formTrim($_POST['gcontextName']) : formTrim($_POST['gnewlistid']);
302 // add a new group to the layout, with the defined field
303 sqlStatement("INSERT INTO layout_options (" .
304 " form_id, source, field_id, title, group_name, seq, uor, fld_length, fld_rows" .
305 ", titlecols, datacols, data_type, edit_options, default_value, description" .
306 ", max_length, list_id, list_backup_id " .
308 "'" . formTrim($_POST['layout_id']) . "'" .
309 ",'" . formTrim($_POST['gnewsource']) . "'" .
310 ",'" . formTrim($_POST['gnewid']) . "'" .
311 ",'" . formTrim($_POST['gnewtitle']) . "'" .
312 ",'" . formTrim($maxnum . $_POST['newgroupname']) . "'" .
313 ",'" . formTrim($_POST['gnewseq']) . "'" .
314 ",'" . formTrim($_POST['gnewuor']) . "'" .
315 ",'" . formTrim($_POST['gnewlengthWidth']) . "'" .
316 ",'" . formTrim($_POST['gnewlengthHeight']) . "'" .
317 ",'" . formTrim($_POST['gnewtitlecols']) . "'" .
318 ",'" . formTrim($_POST['gnewdatacols']) . "'" .
320 ",'" . formTrim($_POST['gnewedit_options']) . "'" .
321 ",'" . formTrim($_POST['gnewdefault']) . "'" .
322 ",'" . formTrim($_POST['gnewdesc']) . "'" .
323 ",'" . formTrim($_POST['gnewmaxSize']) . "'" .
324 ",'" . $listval . "'" .
325 ",'" . formTrim($_POST['gnewbackuplistid']) . "'" .
327 addOrDeleteColumn($layout_id, formTrim($_POST['gnewid']), true);
328 } else if ($_POST['formaction'] == "deletegroup" && $layout_id) {
329 // drop the fields from the related table (this is critical)
330 $res = sqlStatement("SELECT field_id FROM layout_options WHERE " .
331 "form_id = '" . $_POST['layout_id'] . "' ".
332 "AND group_name = '" . $_POST['deletegroupname'] . "'");
333 while ($row = sqlFetchArray($res)) {
334 addOrDeleteColumn($layout_id, $row['field_id'], false);
337 // Delete an entire group from the form
338 sqlStatement("DELETE FROM layout_options WHERE ".
339 " form_id = '".$_POST['layout_id']."' ".
340 " AND group_name = '".$_POST['deletegroupname']."'");
341 } else if ($_POST['formaction'] == "movegroup" && $layout_id) {
342 $results = sqlStatement("SELECT DISTINCT(group_name) AS gname " .
343 "FROM layout_options WHERE form_id = '$layout_id' " .
347 while ($result = sqlFetchArray($results)) {
348 if ($result['gname'] == $_POST['movegroupname']) {
349 if ($_POST['movedirection'] == 'up') { // moving up
351 $garray[$i] = $garray[$i - 1];
352 $garray[$i - 1] = $result['gname'];
355 $garray[$i++
] = $result['gname'];
357 } else { // moving down
359 $garray[$i++
] = $result['gname'];
361 } else if ($i > 1 && $garray[$i - 2] == '') {
362 $garray[$i - 2] = $result['gname'];
364 $garray[$i++
] = $result['gname'];
369 foreach ($garray as $value) {
374 $newname = $nextord . substr($value, 1);
375 sqlStatement("UPDATE layout_options SET " .
376 "group_name = '$newname' WHERE " .
377 "form_id = '$layout_id' AND " .
378 "group_name = '$value'");
379 $nextord = nextGroupOrder($nextord);
381 } else if ($_POST['formaction'] == "renamegroup" && $layout_id) {
382 $currpos = substr($_POST['renameoldgroupname'], 0, 1);
383 // update the database rows
384 sqlStatement("UPDATE layout_options SET " .
385 "group_name = '" . $currpos . $_POST['renamegroupname'] . "' ".
386 "WHERE form_id = '$layout_id' AND ".
387 "group_name = '" . $_POST['renameoldgroupname'] . "'");
390 // Get the selected form's elements.
392 $res = sqlStatement("SELECT * FROM layout_options WHERE " .
393 "form_id = '$layout_id' ORDER BY group_name, seq");
396 // global counter for field numbers
401 // This is called to generate a select option list for fields within this form.
402 // Used for selecting a field for testing in a skip condition.
404 function genFieldOptionList($current = '')
407 $option_list = "<option value=''>-- " . xlt('Please Select') . " --</option>";
409 $query = "SELECT field_id FROM layout_options WHERE form_id = ? ORDER BY group_name, seq";
410 $res = sqlStatement($query, array($layout_id));
411 while ($row = sqlFetchArray($res)) {
412 $field_id = $row['field_id'];
413 $option_list .= "<option value='" . attr($field_id) . "'";
414 if ($field_id == $current) {
415 $option_list .= " selected";
418 $option_list .= ">" . text($field_id) . "</option>";
425 // Write one option line to the form.
427 function writeFieldLine($linedata)
429 global $fld_line_no, $sources, $lbfonly, $extra_html,$validations;
431 $checked = $linedata['default_value'] ?
" checked" : "";
433 //echo " <tr bgcolor='$bgcolor'>\n";
434 echo " <tr id='fld[$fld_line_no]' class='".($fld_line_no %
2 ?
'even' : 'odd')."'>\n";
436 echo " <td class='optcell' style='width:4%' nowrap>";
437 // tuck the group_name INPUT in here
438 echo "<input type='hidden' name='fld[$fld_line_no][group]' value='" .
439 htmlspecialchars($linedata['group_name'], ENT_QUOTES
) . "' class='optin' />";
441 echo "<input type='checkbox' class='selectfield' ".
442 "name='".$linedata['group_name']."~".$linedata['field_id']."' ".
443 "id='".$linedata['group_name']."~".$linedata['field_id']."' ".
444 "title='".htmlspecialchars(xl('Select field', ENT_QUOTES
))."'>";
446 echo "<input type='text' name='fld[$fld_line_no][seq]' id='fld[$fld_line_no][seq]' value='" .
447 htmlspecialchars($linedata['seq'], ENT_QUOTES
) . "' size='2' maxlength='3' " .
448 "class='optin' style='width:36pt' />";
451 echo " <td align='center' class='optcell' $lbfonly style='width:3%'>";
452 echo "<select name='fld[$fld_line_no][source]' class='optin noselect' $lbfonly>";
453 foreach ($sources as $key => $value) {
454 echo "<option value='" . attr($key) . "'";
455 if ($key == $linedata['source']) {
459 echo ">" . text($value) . "</option>\n";
465 echo " <td align='left' class='optcell' style='width:10%'>";
466 echo "<input type='text' name='fld[$fld_line_no][id]' value='" .
467 htmlspecialchars($linedata['field_id'], ENT_QUOTES
) . "' size='15' maxlength='63'
468 class='optin noselect' style='width:100%' />";
469 // class='optin noselect' onclick='FieldIDClicked(this)' />";
471 echo "<input type='hidden' name='fld[$fld_line_no][id]' value='" .
472 htmlspecialchars($linedata['field_id'], ENT_QUOTES) . "' />";
473 echo htmlspecialchars($linedata['field_id'], ENT_QUOTES);
477 echo " <td align='center' class='optcell' style='width:12%'>";
478 echo "<input type='text' id='fld[$fld_line_no][title]' name='fld[$fld_line_no][title]' value='" .
479 htmlspecialchars($linedata['title'], ENT_QUOTES
) . "' size='15' maxlength='63' class='optin' style='width:100%' />";
482 // if not english and set to translate layout labels, then show the translation
483 if ($GLOBALS['translate_layout'] && $_SESSION['language_choice'] > 1) {
484 echo "<td align='center' class='translation' style='width:10%'>" . htmlspecialchars(xl($linedata['title']), ENT_QUOTES
) . "</td>\n";
487 echo " <td align='center' class='optcell' style='width:4%'>";
488 echo "<select name='fld[$fld_line_no][uor]' class='optin'>";
489 foreach (array(0 =>xl('Unused'), 1 =>xl('Optional'), 2 =>xl('Required')) as $key => $value) {
490 echo "<option value='$key'";
491 if ($key == $linedata['uor']) {
495 echo ">$value</option>\n";
501 echo " <td align='center' class='optcell' style='width:8%'>";
502 echo "<select name='fld[$fld_line_no][data_type]' id='fld[$fld_line_no][data_type]' onchange=NationNotesContext('".$fld_line_no."',this.value)>";
503 echo "<option value=''></option>";
505 foreach ($datatypes as $key => $value) {
506 if ($linedata['data_type'] == $key) {
507 echo "<option value='$key' selected>$value</option>";
509 echo "<option value='$key'>$value</option>";
516 echo " <td align='center' class='optcell' style='width:4%'>";
517 if ($linedata['data_type'] == 2 ||
$linedata['data_type'] == 3 ||
518 $linedata['data_type'] == 21 ||
$linedata['data_type'] == 22 ||
519 $linedata['data_type'] == 23 ||
$linedata['data_type'] == 25 ||
520 $linedata['data_type'] == 27 ||
$linedata['data_type'] == 28 ||
521 $linedata['data_type'] == 32 ||
$linedata['data_type'] == 15 ||
522 $linedata['data_type'] == 40
524 // Show the width field
525 echo "<input type='text' name='fld[$fld_line_no][lengthWidth]' value='" .
526 htmlspecialchars($linedata['fld_length'], ENT_QUOTES
) .
527 "' size='2' maxlength='10' class='optin' title='" . xla('Width') . "' />";
528 if ($linedata['data_type'] == 3 ||
$linedata['data_type'] == 40) {
529 // Show the height field
530 echo "<input type='text' name='fld[$fld_line_no][lengthHeight]' value='" .
531 htmlspecialchars($linedata['fld_rows'], ENT_QUOTES
) .
532 "' size='2' maxlength='10' class='optin' title='" . xla('Height') . "' />";
534 // Hide the height field
535 echo "<input type='hidden' name='fld[$fld_line_no][lengthHeight]' value=''>";
538 // all other data_types (hide both the width and height fields
539 echo "<input type='hidden' name='fld[$fld_line_no][lengthWidth]' value=''>";
540 echo "<input type='hidden' name='fld[$fld_line_no][lengthHeight]' value=''>";
545 echo " <td align='center' class='optcell' style='width:4%'>";
546 echo "<input type='text' name='fld[$fld_line_no][maxSize]' value='" .
547 htmlspecialchars($linedata['max_length'], ENT_QUOTES
) .
548 "' size='1' maxlength='10' class='optin' style='width:100%' " .
549 "title='" . xla('Maximum Size (entering 0 will allow any size)') . "' />";
552 echo " <td align='center' class='optcell' style='width:8%'>";
553 if ($linedata['data_type'] == 1 ||
$linedata['data_type'] == 21 ||
554 $linedata['data_type'] == 22 ||
$linedata['data_type'] == 23 ||
555 $linedata['data_type'] == 25 ||
$linedata['data_type'] == 26 ||
556 $linedata['data_type'] == 27 ||
$linedata['data_type'] == 32 ||
557 $linedata['data_type'] == 33 ||
$linedata['data_type'] == 34 ||
558 $linedata['data_type'] == 36) {
560 $disp = "style='display:none'";
561 if ($linedata['data_type'] == 34) {
562 $type = "style='display:none'";
566 echo "<input type='text' name='fld[$fld_line_no][list_id]' id='fld[$fld_line_no][list_id]' value='" .
567 htmlspecialchars($linedata['list_id'], ENT_QUOTES
) . "'".$type.
568 " size='6' maxlength='30' class='optin listid' style='width:100%;cursor:pointer'".
569 "title='". xl('Choose list') . "' />";
571 echo "<select name='fld[$fld_line_no][contextName]' id='fld[$fld_line_no][contextName]' ".$disp.">";
572 $res = sqlStatement("SELECT * FROM customlists WHERE cl_list_type=2 AND cl_deleted=0");
573 while ($row = sqlFetchArray($res)) {
575 if ($linedata['list_id'] == $row['cl_list_item_long']) {
579 echo "<option value='".htmlspecialchars($row['cl_list_item_long'], ENT_QUOTES
)."' ".$sel.">".htmlspecialchars($row['cl_list_item_long'], ENT_QUOTES
)."</option>";
584 // all other data_types
585 echo "<input type='hidden' name='fld[$fld_line_no][list_id]' value=''>";
591 echo " <td align='center' class='optcell' style='width:4%'>";
592 if ($linedata['data_type'] == 1 ||
$linedata['data_type'] == 26 ||
593 $linedata['data_type'] == 33 ||
$linedata['data_type'] == 36) {
594 echo "<input type='text' name='fld[$fld_line_no][list_backup_id]' value='" .
595 htmlspecialchars($linedata['list_backup_id'], ENT_QUOTES
) .
596 "' size='3' maxlength='10' class='optin listid' style='cursor:pointer; width:100%' />";
598 echo "<input type='hidden' name='fld[$fld_line_no][list_backup_id]' value=''>";
604 echo " <td align='center' class='optcell' style='width:4%'>";
605 echo "<input type='text' name='fld[$fld_line_no][titlecols]' value='" .
606 htmlspecialchars($linedata['titlecols'], ENT_QUOTES
) . "' size='3' maxlength='10' class='optin' style='width:100%' />";
609 echo " <td align='center' class='optcell' style='width:4%'>";
610 echo "<input type='text' name='fld[$fld_line_no][datacols]' value='" .
611 htmlspecialchars($linedata['datacols'], ENT_QUOTES
) . "' size='3' maxlength='10' class='optin' style='width:100%' />";
614 echo " <td align='center' class='optcell' style='width:5%' title='" .
615 "A = " . xla('Age') .
616 ", B = " . xla('Gestational Age') .
617 ", C = " . xla('Capitalize') .
618 ", D = " . xla('Dup Check') .
619 ", E = " . xla('Dup Check on only Edit') .
620 ", W = " . xla('Dup Check on only New') .
621 ", G = " . xla('Graphable') .
622 ", L = " . xla('Lab Order') .
623 ", N = " . xla('New Patient Form') .
624 ", O = " . xla('Order Processor') .
625 ", P = " . xla('Default to previous value') .
626 ", R = " . xla('Distributor') .
627 ", T = " . xla('Description is default text') .
628 ", U = " . xla('Capitalize all') .
629 ", V = " . xla('Vendor') .
630 ", 0 = " . xla('Read Only') .
631 ", 1 = " . xla('Write Once') .
632 ", 2 = " . xla('Billing Code Descriptions') .
635 echo "<input type='text' name='fld[$fld_line_no][edit_options]' value='" .
636 htmlspecialchars($linedata['edit_options'], ENT_QUOTES
) . "' size='3' " .
637 "maxlength='36' class='optin' style='width:100%' />";
640 /*****************************************************************
641 echo " <td align='center' class='optcell'>";
642 if ($linedata['data_type'] == 2) {
643 echo "<input type='text' name='fld[$fld_line_no][default]' value='" .
644 htmlspecialchars($linedata['default_value'], ENT_QUOTES) . "' size='10' maxlength='63' class='optin' />";
650 echo " <td align='center' class='optcell'>";
651 echo "<input type='text' name='fld[$fld_line_no][desc]' value='" .
652 htmlspecialchars($linedata['description'], ENT_QUOTES) . "' size='20' maxlength='63' class='optin' />";
655 // if not english and showing layout labels, then show the translation of Description
656 if ($GLOBALS['translate_layout'] && $_SESSION['language_choice'] > 1) {
657 echo "<td align='center' class='translation'>" . htmlspecialchars(xl($linedata['description']), ENT_QUOTES) . "</td>\n";
659 *****************************************************************/
661 if ($linedata['data_type'] == 31) {
662 echo " <td align='center' class='optcell' style='width:24%'>";
663 echo "<textarea name='fld[$fld_line_no][desc]' rows='3' cols='35' class='optin' style='width:100%'>" .
664 $linedata['description'] . "</textarea>";
665 echo "<input type='hidden' name='fld[$fld_line_no][default]' value='" .
666 htmlspecialchars($linedata['default_value'], ENT_QUOTES
) . "' />";
669 echo " <td align='center' class='optcell' style='width:24%'>";
670 echo "<input type='text' name='fld[$fld_line_no][desc]' value='" .
671 htmlspecialchars($linedata['description'], ENT_QUOTES
) .
672 "' size='30' class='optin' style='width:100%' />";
673 echo "<input type='hidden' name='fld[$fld_line_no][default]' value='" .
674 htmlspecialchars($linedata['default_value'], ENT_QUOTES
) . "' />";
676 // if not english and showing layout labels, then show the translation of Description
677 if ($GLOBALS['translate_layout'] && $_SESSION['language_choice'] > 1) {
678 echo "<td align='center' class='translation' style='width:10%'>" .
679 htmlspecialchars(xl($linedata['description']), ENT_QUOTES
) . "</td>\n";
683 // The "?" to click on for yet more field attributes.
684 echo " <td class='bold' id='querytd_$fld_line_no' style='cursor:pointer;";
685 if (!empty($linedata['conditions']) ||
!empty($linedata['validation'])) {
686 echo "background-color:#77ff77;";
689 echo "' onclick='extShow($fld_line_no, this)' align='center' ";
690 echo "title='" . xla('Click here to view/edit more details') . "'>";
691 echo " ? ";
696 // Create a floating div for the additional attributes of this field.
697 $conditions = empty($linedata['conditions']) ?
698 array(0 => array('id' => '', 'itemid' => '', 'operator' => '', 'value' => '')) :
699 unserialize($linedata['conditions']);
701 $extra_html .= "<div id='ext_$fld_line_no' " .
702 "style='position:absolute;width:750px;border:1px solid black;" .
703 "padding:2px;background-color:#cccccc;visibility:hidden;" .
704 "z-index:1000;left:-1000px;top:0px;font-size:9pt;'>\n" .
705 "<table width='100%'>\n" .
707 " <th colspan='3' align='left' class='bold'>\"" . text($linedata['field_id']) . "\" " .
708 xlt('will be hidden if') . ":</th>\n" .
709 " <th colspan='2' align='right' class='text'><input type='button' " .
710 "value='" . xla('Close') . "' onclick='extShow($fld_line_no, false)' /> </th>\n" .
713 " <th align='left' class='bold'>" . xlt('Field ID') . "</th>\n" .
714 " <th align='left' class='bold'>" . xlt('List item ID') . "</th>\n" .
715 " <th align='left' class='bold'>" . xlt('Operator') . "</th>\n" .
716 " <th align='left' class='bold'>" . xlt('Value if comparing') . "</th>\n" .
717 " <th align='left' class='bold'> </th>\n" .
719 // There may be multiple condition lines for each field.
720 foreach ($conditions as $i => $condition) {
723 " <td align='left'>\n" .
724 " <select name='fld[$fld_line_no][condition_id][$i]' onchange='cidChanged($fld_line_no, $i)'>" .
725 genFieldOptionList($condition['id']) . " </select>\n" .
727 " <td align='left'>\n" .
728 // List item choices are populated on the client side but will need the current value,
729 // so we insert a temporary option here to hold that value.
730 " <select name='fld[$fld_line_no][condition_itemid][$i]'><option value='" .
731 attr($condition['itemid']) . "'>...</option></select>\n" .
733 " <td align='left'>\n" .
734 " <select name='fld[$fld_line_no][condition_operator][$i]'>\n";
736 'eq' => xl('Equals'),
737 'ne' => xl('Does not equal'),
738 'se' => xl('Is selected'),
739 'ns' => xl('Is not selected'),
740 ) as $key => $value) {
741 $extra_html .= " <option value='$key'";
742 if ($key == $condition['operator']) {
743 $extra_html .= " selected";
746 $extra_html .= ">" . text($value) . "</option>\n";
752 " <td align='left' title='" . xla('Only for comparisons') . "'>\n" .
753 " <input type='text' name='fld[$fld_line_no][condition_value][$i]' value='" .
754 attr($condition['value']) . "' size='15' maxlength='63' />\n" .
756 if (count($conditions) == $i +
1) {
758 " <td align='right' title='" . xla('Add a condition') . "'>\n" .
759 " <input type='button' value='+' onclick='extAddCondition($fld_line_no,this)' />\n" .
763 " <td align='right'>\n" .
764 " <select name='fld[$fld_line_no][condition_andor][$i]'>\n";
768 ) as $key => $value) {
769 $extra_html .= " <option value='$key'";
770 if ($key == $condition['andor']) {
771 $extra_html .= " selected";
774 $extra_html .= ">" . text($value) . "</option>\n";
789 $extra_html .= "<table width='100%'>\n" .
791 " <td colspan='3' align='left' class='bold'>\"" . text($linedata['field_id']) . "\" " .
792 xlt('will have the following validation rules') . ":</td>\n" .
795 " <td align='left' class='bold'>" . xlt('Validation rule') . " </td>\n" .
798 " <td align='left' title='" . xla('Select a validation rule') . "'>\n" .
801 " <select name='fld[$fld_line_no][validation]' onchange='valChanged($fld_line_no)'>\n" .
803 if (empty($linedata['validation'])) {
804 $extra_html .= " selected";
807 $extra_html .= ">-- " . xlt('Please Select') . " --</option>";
808 foreach ($validations as $key => $value) {
809 $extra_html .= " <option value='$key'";
810 if ($key == $linedata['validation']) {
811 $extra_html .= " selected";
814 $extra_html .= ">" . text($value) . "</option>\n";
817 $extra_html .="</select>\n" .
828 <?php
html_header_show();?
>
830 <!-- supporting javascript code
-->
831 <script type
="text/javascript" src
="<?php echo $GLOBALS['assets_static_relative']; ?>/jquery-min-1-2-2/index.js"></script
>
833 <link rel
="stylesheet" href
='<?php echo $css_header ?>' type
='text/css'>
835 <title
><?php
xl('Layout Editor', 'e'); ?
></title
>
838 tr
.head
{ font
-size
:10pt
; background
-color
:#cccccc; }
839 tr
.detail
{ font
-size
:10pt
; }
840 td
{ font
-size
:10pt
; }
841 input
{ font
-size
:10pt
; }
842 a
, a
:visited
, a
:hover
{ color
:#0000cc; }
844 .optin
{ background
: transparent
; }
846 margin
: 0pt
0pt
8pt
0pt
;
852 border
-collapse
: collapse
;
857 background
-color
: #ddddff;
858 padding
: 3px
0px
3px
0px
;
861 background
-color
: #ffdddd;
862 padding
: 3px
0px
3px
0px
;
864 .help
{ cursor
: help
; }
865 .layouts_title
{ font
-size
: 110%
; }
871 border
: 2px solid blue
;
872 background
-color
: yellow
;
878 <script language
="JavaScript">
880 // Helper functions for positioning the floating divs.
881 function extGetX(elem
) {
883 while(elem
!= null) {
884 x +
= elem
.offsetLeft
;
885 elem
= elem
.offsetParent
;
889 function extGetY(elem
) {
891 while(elem
!= null) {
893 elem
= elem
.offsetParent
;
898 // Show or hide the "extras" div for a row.
900 function extShow(lino
, show
) {
901 var thisdiv
= document
.getElementById("ext_" + lino
);
903 extdiv
.style
.visibility
= 'hidden';
904 extdiv
.style
.left
= '-1000px';
905 extdiv
.style
.top
= '0px';
907 if (show
&& thisdiv
!= extdiv
) {
909 var dw
= window
.innerWidth ? window
.innerWidth
- 20 : document
.body
.clientWidth
;
910 x
= dw
- extdiv
.offsetWidth
;
912 var y
= extGetY(show
) + show
.offsetHeight
;
913 extdiv
.style
.left
= x
;
914 extdiv
.style
.top
= y
;
915 extdiv
.style
.visibility
= 'visible';
922 // Add an extra condition line for the given row.
923 function extAddCondition(lino
, btnelem
) {
924 var f
= document
.forms
[0];
927 // Get index of next condition line.
928 while (f
['fld[' + lino +
'][condition_id][' + i +
']']) ++i
;
929 if (i
== 0) alert('f["fld[' + lino +
'][condition_id][' + i +
']"] <?php echo xls('not found
') ?>');
931 // Get containing <td>, <tr> and <table> nodes of the "+" button.
932 var tdplus
= btnelem
.parentNode
;
933 var trelem
= tdplus
.parentNode
;
934 var telem
= trelem
.parentNode
;
936 // Replace contents of the tdplus cell.
938 "<select name='fld[" + lino +
"][condition_andor][" + i +
"]'>" +
939 "<option value='and'><?php echo xls('And') ?></option>" +
940 "<option value='or' ><?php echo xls('Or') ?></option>" +
944 var newtrelem
= telem
.insertRow(i+
2);
945 newtrelem
.innerHTML
=
946 "<td align='left'>" +
947 "<select name='fld[" + lino +
"][condition_id][" + i +
"]' onchange='cidChanged(" + lino +
"," + i +
")'>" +
948 "<?php echo addslashes(genFieldOptionList()) ?>" +
951 "<td align='left'>" +
952 "<select name='fld[" + lino +
"][condition_itemid][" + i +
"]' style='display:none' />" +
954 "<td align='left'>" +
955 "<select name='fld[" + lino +
"][condition_operator][" + i +
"]'>" +
956 "<option value='eq'><?php echo xls('Equals') ?></option>" +
957 "<option value='ne'><?php echo xls('Does not equal') ?></option>" +
958 "<option value='se'><?php echo xls('Is selected') ?></option>" +
959 "<option value='ns'><?php echo xls('Is not selected') ?></option>" +
962 "<td align='left'>" +
963 "<input type='text' name='fld[" + lino +
"][condition_value][" + i +
"]' value='' size='15' maxlength='63' />" +
965 "<td align='right'>" +
966 "<input type='button' value='+' onclick='extAddCondition(" + lino +
",this)' />" +
970 // This is called when a field ID is chosen for testing within a skip condition.
971 // It checks to see if a corresponding list item must also be chosen for the test, and
972 // if so then inserts the dropdown for selecting an item from the appropriate list.
973 function setListItemOptions(lino
, seq
, init
) {
974 var f
= document
.forms
[0];
975 var target
= 'fld[' + lino +
'][condition_itemid][' + seq +
']';
976 // field_id is the ID of the field that the condition will test.
977 var field_id
= f
['fld[' + lino +
'][condition_id][' + seq +
']'].value
;
979 f
[target
].options
.length
= 0;
980 f
[target
].style
.display
= 'none';
983 // Find the occurrence of that field in the layout.
986 var idname
= 'fld[' + i +
'][id]';
988 alert('<?php echo xls('Condition field not found
') ?>: ' + field_id
);
991 if (f
[idname
].value
== field_id
) break;
994 // If this is startup initialization then preserve the current value.
995 var current
= init ? f
[target
].value
: '';
996 f
[target
].options
.length
= 0;
997 // Get the corresponding data type and list ID.
998 var data_type
= f
['fld[' + i +
'][data_type]'].value
;
999 var list_id
= f
['fld[' + i +
'][list_id]'].value
;
1000 // WARNING: If new data types are defined the following test may need enhancing.
1001 // We're getting out if the type does not generate multiple fields with different names.
1002 if (data_type
!= '21' && data_type
!= '22' && data_type
!= '23' && data_type
!= '25') {
1003 f
[target
].style
.display
= 'none';
1006 // OK, list item IDs do apply so go get 'em.
1007 // This happens asynchronously so the generated code needs to stand alone.
1008 f
[target
].style
.display
= '';
1009 $
.getScript('layout_listitems_ajax.php' +
1010 '?listid=' +
encodeURIComponent(list_id
) +
1011 '&target=' +
encodeURIComponent(target
) +
1012 '¤t=' +
encodeURIComponent(current
));
1015 // This is called whenever a condition's field ID selection is changed.
1016 function cidChanged(lino
, seq
) {
1018 setListItemOptions(lino
, seq
, false);
1021 // This is called whenever a validation rule field ID selection is changed.
1022 function valChanged(lino
) {
1026 function changeColor(lino
){
1027 var thisid
= document
.forms
[0]['fld[' + lino +
'][condition_id][0]'].value
;
1028 var thisValId
= document
.forms
[0]['fld[' + lino +
'][validation]'].value
;
1029 var thistd
= document
.getElementById("querytd_" + lino
);
1030 if(thisid
!='' || thisValId
!='') {
1031 thistd
.style
.backgroundColor
= '#77ff77';
1033 thistd
.style
.backgroundColor
='';
1037 // Call this to disable the warning about unsaved changes and submit the form.
1038 function mySubmit() {
1039 somethingChanged
= false;
1040 top
.restoreSession();
1041 document
.forms
[0].submit();
1044 // User is about to do something that would discard any unsaved changes.
1045 // Return true if that is OK.
1046 function myChangeCheck() {
1047 if (somethingChanged
) {
1048 if (!confirm('<?php echo xls('You have unsaved changes
. Abandon them?
'); ?>')) {
1051 // Do not set somethingChanged to false here because if they cancel the
1052 // action then the previously changed values will still be of interest.
1061 <body
class="body_top admin-layout">
1063 <form method
='post' name
='theform' id
='theform' action
='edit_layout.php'>
1064 <input type
="hidden" name
="formaction" id
="formaction" value
="">
1065 <!-- elements used to identify a field to delete
-->
1066 <input type
="hidden" name
="deletefieldid" id
="deletefieldid" value
="">
1067 <input type
="hidden" name
="deletefieldgroup" id
="deletefieldgroup" value
="">
1068 <!-- elements used to identify a group to delete
-->
1069 <input type
="hidden" name
="deletegroupname" id
="deletegroupname" value
="">
1070 <!-- elements used to change the group order
-->
1071 <input type
="hidden" name
="movegroupname" id
="movegroupname" value
="">
1072 <input type
="hidden" name
="movedirection" id
="movedirection" value
="">
1073 <!-- elements used to select more than one field
-->
1074 <input type
="hidden" name
="selectedfields" id
="selectedfields" value
="">
1075 <input type
="hidden" id
="targetgroup" name
="targetgroup" value
="">
1076 <div
class="menubar">
1078 <b
><?php
xl('Edit layout', 'e'); ?
>:</b
> 
;
1079 <select name
='layout_id' id
='layout_id'>
1080 <option value
=''>-- <?php
echo xl('Select') ?
> --</option
>
1082 foreach ($layouts as $key => $value) {
1083 echo " <option value='$key'";
1084 if ($key == $layout_id) {
1088 echo ">$value</option>\n";
1091 </select
></div
><div
><p
>
1092 <?php
if ($layout_id) { ?
>
1093 <input type
='button' class='addgroup' id
='addgroup' value
=<?php
xl('Add Group', 'e', '\'', '\''); ?
>/>
1094 <span style
="font-size:90%">  
;
1095 <input type
='button' name
='save' id
='save' value
='<?php xl('Save Changes
', 'e
'); ?>' /></span
>  
; 
;
1096 <?php
xl('With selected:', 'e');?
>
1097 <input type
='button' name
='deletefields' id
='deletefields' value
='<?php xl('Delete
', 'e
'); ?>' style
="font-size:90%" disabled
="disabled" />
1098 <input type
='button' name
='movefields' id
='movefields' value
='<?php xl('Move to
...', 'e
'); ?>' style
="font-size:90%" disabled
="disabled" /></span
>
1101 <div
class="container">
1104 $prevgroup = "!@#asdf1234"; // an unlikely group name
1105 $firstgroup = true; // flag indicates it's the first group to be displayed
1106 while ($row = sqlFetchArray($res)) {
1107 if ($row['group_name'] != $prevgroup) {
1108 if ($firstgroup == false) {
1109 echo "</tbody></table></div>\n";
1112 echo "<div id='".$row['group_name']."' class='group'>";
1113 echo "<div class='text bold layouts_title' style='position:relative; background-color: #eef'>";
1114 // echo preg_replace("/^\d+/", "", $row['group_name']);
1115 echo substr($row['group_name'], 1);
1117 // if not english and set to translate layout labels, then show the translation of group name
1118 if ($GLOBALS['translate_layout'] && $_SESSION['language_choice'] > 1) {
1119 // echo "<span class='translation'>>> " . xl(preg_replace("/^\d+/", "", $row['group_name'])) . "</span>";
1120 echo "<span class='translation'>>> " . xl(substr($row['group_name'], 1)) . "</span>";
1125 echo " <input type='button' class='addfield' id='addto~".$row['group_name']."' value='" . xl('Add Field') . "'/>";
1126 echo " ";
1127 echo " <input type='button' class='renamegroup' id='".$row['group_name']."' value='" . xl('Rename Group') . "'/>";
1128 echo " ";
1129 echo " <input type='button' class='deletegroup' id='".$row['group_name']."' value='" . xl('Delete Group') . "'/>";
1130 echo " ";
1131 echo " <input type='button' class='movegroup' id='".$row['group_name']."~up' value='" . xl('Move Up') . "'/>";
1132 echo " ";
1133 echo " <input type='button' class='movegroup' id='".$row['group_name']."~down' value='" . xl('Move Down') . "'/>";
1135 $firstgroup = false;
1140 <th
><?php
xl('Order', 'e'); ?
></th
>
1141 <th
<?php
echo " $lbfonly"; ?
>><?php
xl('Source', 'e'); ?
></th
>
1142 <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
>
1143 <th
><?php
xl('Label', 'e'); ?
> 
;<span
class="help" title
=<?php
xl('The label that appears to the user on the form', 'e', '\'', '\''); ?
> >(?
)</span
></th
>
1144 <?php
// if not english and showing layout label translations, then show translation header for title
1145 if ($GLOBALS['translate_layout'] && $_SESSION['language_choice'] > 1) {
1146 echo "<th>" . xl('Translation')."<span class='help' title='" . xl('The translated label that will appear on the form in current language') . "'> (?)</span></th>";
1148 <th
><?php
xl('UOR', 'e'); ?
></th
>
1149 <th
><?php
xl('Data Type', 'e'); ?
></th
>
1150 <th
><?php
xl('Size', 'e'); ?
></th
>
1151 <th
><?php
xl('Max Size', 'e'); ?
></th
>
1152 <th
><?php
xl('List', 'e'); ?
></th
>
1153 <th
><?php
xl('Backup List', 'e'); ?
></th
>
1154 <th
><?php
xl('Label Cols', 'e'); ?
></th
>
1155 <th
><?php
xl('Data Cols', 'e'); ?
></th
>
1156 <th
><?php
xl('Options', 'e'); ?
></th
>
1157 <th
><?php
xl('Description', 'e'); ?
></th
>
1158 <?php
// if not english and showing layout label translations, then show translation header for description
1159 if ($GLOBALS['translate_layout'] && $_SESSION['language_choice'] > 1) {
1160 echo "<th>" . xl('Translation')."<span class='help' title='" . xl('The translation of description in current language')."'> (?)</span></th>";
1162 <th
><?php
echo xlt('?'); ?
></th
>
1168 } // end if-group_name
1170 writeFieldLine($row);
1171 $prevgroup = $row['group_name'];
1178 <?php
echo $extra_html; ?
>
1182 <!-- template DIV that appears when user chooses to rename an existing group
-->
1183 <div id
="renamegroupdetail" style
="border: 1px solid black; padding: 3px; display: none; visibility: hidden; background-color: lightgrey;">
1184 <input type
="hidden" name
="renameoldgroupname" id
="renameoldgroupname" value
="">
1185 <?php
xl('Group Name', 'e'); ?
>: <input type
="textbox" size
="20" maxlength
="30" name
="renamegroupname" id
="renamegroupname">
1187 <input type
="button" class="saverenamegroup" value
=<?php
xl('Rename Group', 'e', '\'', '\''); ?
>>
1188 <input type
="button" class="cancelrenamegroup" value
=<?php
xl('Cancel', 'e', '\'', '\''); ?
>>
1191 <!-- template DIV that appears when user chooses to add a
new group
-->
1192 <div id
="groupdetail" style
="border: 1px solid black; padding: 3px; display: none; visibility: hidden; background-color: lightgrey;">
1194 <?php
xl('Group Name', 'e'); ?
>: <input type
="textbox" size
="20" maxlength
="30" name
="newgroupname" id
="newgroupname">
1196 <table style
="border-collapse: collapse; margin-top: 5px;">
1199 <th
><?php
xl('Order', 'e'); ?
></th
>
1200 <th
<?php
echo " $lbfonly"; ?
>><?php
xl('Source', 'e'); ?
></th
>
1201 <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
>
1202 <th
><?php
xl('Label', 'e'); ?
> 
;<span
class="help" title
=<?php
xl('The label that appears to the user on the form', 'e', '\'', '\''); ?
> >(?
)</span
></th
>
1203 <th
><?php
xl('UOR', 'e'); ?
></th
>
1204 <th
><?php
xl('Data Type', 'e'); ?
></th
>
1205 <th
><?php
xl('Size', 'e'); ?
></th
>
1206 <th
><?php
xl('Max Size', 'e'); ?
></th
>
1207 <th
><?php
xl('List', 'e'); ?
></th
>
1208 <th
><?php
xl('Backup List', 'e'); ?
></th
>
1209 <th
><?php
xl('Label Cols', 'e'); ?
></th
>
1210 <th
><?php
xl('Data Cols', 'e'); ?
></th
>
1211 <th
><?php
xl('Options', 'e'); ?
></th
>
1212 <th
><?php
xl('Description', 'e'); ?
></th
>
1217 <td
><input type
="textbox" name
="gnewseq" id
="gnewseq" value
="" size
="2" maxlength
="3"> </td
>
1218 <td
<?php
echo " $lbfonly"; ?
>>
1219 <select name
='gnewsource' id
='gnewsource'>
1221 foreach ($sources as $key => $value) {
1222 echo "<option value='" . attr($key) . "'>" . text($value) . "</option>\n";
1227 <td
><input type
="textbox" name
="gnewid" id
="gnewid" value
="" size
="10" maxlength
="20"
1228 onclick
='FieldIDClicked(this)'> </td
>
1229 <td
><input type
="textbox" name
="gnewtitle" id
="gnewtitle" value
="" size
="20" maxlength
="63"> </td
>
1231 <select name
="gnewuor" id
="gnewuor">
1232 <option value
="0"><?php
xl('Unused', 'e'); ?
></option
>
1233 <option value
="1" selected
><?php
xl('Optional', 'e'); ?
></option
>
1234 <option value
="2"><?php
xl('Required', 'e'); ?
></option
>
1238 <select name
='gnewdatatype' id
='gnewdatatype'>
1239 <option value
=''></option
>
1242 foreach ($datatypes as $key => $value) {
1243 echo "<option value='$key'>$value</option>";
1248 <td
><input type
="textbox" name
="gnewlengthWidth" id
="gnewlengthWidth" value
="" size
="1" maxlength
="3" title
="<?php echo xla('Width'); ?>">
1249 <input type
="textbox" name
="gnewlengthHeight" id
="gnewlengthHeight" value
="" size
="1" maxlength
="3" title
="<?php echo xla('Height'); ?>"></td
>
1250 <td
><input type
="textbox" name
="gnewmaxSize" id
="gnewmaxSize" value
="" size
="1" maxlength
="3" title
="<?php echo xla('Maximum Size (entering 0 will allow any size)'); ?>"></td
>
1251 <td
><input type
="textbox" name
="gnewlistid" id
="gnewlistid" value
="" size
="8" maxlength
="31" class="listid">
1252 <select name
='gcontextName' id
='gcontextName' style
='display:none'>
1254 $res = sqlStatement("SELECT * FROM customlists WHERE cl_list_type=2 AND cl_deleted=0");
1255 while ($row = sqlFetchArray($res)) {
1256 echo "<option value='".htmlspecialchars($row['cl_list_item_long'], ENT_QUOTES
)."'>".htmlspecialchars($row['cl_list_item_long'], ENT_QUOTES
)."</option>";
1261 <td
><input type
="textbox" name
="gnewbackuplistid" id
="gnewbackuplistid" value
="" size
="8" maxlength
="31" class="listid"></td
>
1262 <td
><input type
="textbox" name
="gnewtitlecols" id
="gnewtitlecols" value
="" size
="3" maxlength
="3"> </td
>
1263 <td
><input type
="textbox" name
="gnewdatacols" id
="gnewdatacols" value
="" size
="3" maxlength
="3"> </td
>
1264 <td
><input type
="textbox" name
="gnewedit_options" id
="gnewedit_options" value
="" size
="3" maxlength
="36">
1265 <input type
="hidden" name
="gnewdefault" id
="gnewdefault" value
="" /> </td
>
1266 <td
><input type
="textbox" name
="gnewdesc" id
="gnewdesc" value
="" size
="30" maxlength
="63"> </td
>
1271 <input type
="button" class="savenewgroup" value
=<?php
xl('Save New Group', 'e', '\'', '\''); ?
>>
1272 <input type
="button" class="cancelnewgroup" value
=<?php
xl('Cancel', 'e', '\'', '\''); ?
>>
1276 <!-- template DIV that appears when user chooses to add a
new field to a group
-->
1277 <div id
="fielddetail" class="fielddetail" style
="display: none; visibility: hidden">
1278 <input type
="hidden" name
="newfieldgroupid" id
="newfieldgroupid" value
="">
1279 <table style
="border-collapse: collapse;">
1282 <th
><?php
xl('Order', 'e'); ?
></th
>
1283 <th
<?php
echo " $lbfonly"; ?
>><?php
xl('Source', 'e'); ?
></th
>
1284 <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
>
1285 <th
><?php
xl('Label', 'e'); ?
> 
;<span
class="help" title
=<?php
xl('The label that appears to the user on the form', 'e', '\'', '\''); ?
> >(?
)</span
></th
>
1286 <th
><?php
xl('UOR', 'e'); ?
></th
>
1287 <th
><?php
xl('Data Type', 'e'); ?
></th
>
1288 <th
><?php
xl('Size', 'e'); ?
></th
>
1289 <th
><?php
xl('Max Size', 'e'); ?
></th
>
1290 <th
><?php
xl('List', 'e'); ?
></th
>
1291 <th
><?php
xl('Backup List', 'e'); ?
></th
>
1292 <th
><?php
xl('Label Cols', 'e'); ?
></th
>
1293 <th
><?php
xl('Data Cols', 'e'); ?
></th
>
1294 <th
><?php
xl('Options', 'e'); ?
></th
>
1295 <th
><?php
xl('Description', 'e'); ?
></th
>
1300 <td
><input type
="textbox" name
="newseq" id
="newseq" value
="" size
="2" maxlength
="3"> </td
>
1301 <td
<?php
echo " $lbfonly"; ?
>>
1302 <select name
='newsource' id
='newsource'>
1304 foreach ($sources as $key => $value) {
1305 echo " <option value='" . attr($key) . "'>" . text($value) . "</option>\n";
1310 <td
><input type
="textbox" name
="newid" id
="newid" value
="" size
="10" maxlength
="20"
1311 onclick
='FieldIDClicked(this)'> </td
>
1312 <td
><input type
="textbox" name
="newtitle" id
="newtitle" value
="" size
="20" maxlength
="63"> </td
>
1314 <select name
="newuor" id
="newuor">
1315 <option value
="0"><?php
xl('Unused', 'e'); ?
></option
>
1316 <option value
="1" selected
><?php
xl('Optional', 'e'); ?
></option
>
1317 <option value
="2"><?php
xl('Required', 'e'); ?
></option
>
1321 <select name
='newdatatype' id
='newdatatype'>
1322 <option value
=''></option
>
1325 foreach ($datatypes as $key => $value) {
1326 echo " <option value='$key'>$value</option>\n";
1331 <td
><input type
="textbox" name
="newlengthWidth" id
="newlengthWidth" value
="" size
="1" maxlength
="3" title
="<?php echo xla('Width'); ?>">
1332 <input type
="textbox" name
="newlengthHeight" id
="newlengthHeight" value
="" size
="1" maxlength
="3" title
="<?php echo xla('Height'); ?>"></td
>
1333 <td
><input type
="textbox" name
="newmaxSize" id
="newmaxSize" value
="" size
="1" maxlength
="3" title
="<?php echo xla('Maximum Size (entering 0 will allow any size)'); ?>"></td
>
1334 <td
><input type
="textbox" name
="newlistid" id
="newlistid" value
="" size
="8" maxlength
="31" class="listid">
1335 <select name
='contextName' id
='contextName' style
='display:none'>
1337 $res = sqlStatement("SELECT * FROM customlists WHERE cl_list_type=2 AND cl_deleted=0");
1338 while ($row = sqlFetchArray($res)) {
1339 echo "<option value='".htmlspecialchars($row['cl_list_item_long'], ENT_QUOTES
)."'>".htmlspecialchars($row['cl_list_item_long'], ENT_QUOTES
)."</option>";
1344 <td
><input type
="textbox" name
="newbackuplistid" id
="newbackuplistid" value
="" size
="8" maxlength
="31" class="listid"></td
>
1345 <td
><input type
="textbox" name
="newtitlecols" id
="newtitlecols" value
="" size
="3" maxlength
="3"> </td
>
1346 <td
><input type
="textbox" name
="newdatacols" id
="newdatacols" value
="" size
="3" maxlength
="3"> </td
>
1347 <td
><input type
="textbox" name
="newedit_options" id
="newedit_options" value
="" size
="3" maxlength
="36">
1348 <input type
="hidden" name
="newdefault" id
="newdefault" value
="" /> </td
>
1349 <td
><input type
="textbox" name
="newdesc" id
="newdesc" value
="" size
="30" maxlength
="63"> </td
>
1353 <input type
="button" class="savenewfield" value
=<?php
xl('Save New Field', 'e', '\'', '\''); ?
>>
1354 <input type
="button" class="cancelnewfield" value
=<?php
xl('Cancel', 'e', '\'', '\''); ?
>>
1363 <script language
="javascript">
1365 // used when selecting a list-name for a field
1368 // Support for beforeunload handler.
1369 var somethingChanged
= false;
1371 // Get the next logical sequence number for a field in the specified group.
1372 // Note it guesses and uses the existing increment value.
1373 function getNextSeq(group
) {
1374 var f
= document
.forms
[0];
1377 for (var i
= 1; true; ++i
) {
1378 var gelem
= f
['fld[' + i +
'][group]'];
1380 if (gelem
.value
!= group
) continue;
1381 var tmp
= parseInt(f
['fld[' + i +
'][seq]'].value
);
1382 if (isNaN(tmp
)) continue;
1383 if (tmp
<= seq
) continue;
1390 // jQuery stuff to make the page a little easier to use
1392 $
(document
).ready(function(){
1393 $
("#save").click(function() { SaveChanges(); });
1394 $
("#layout_id").change(function() {
1395 if (!myChangeCheck()) {
1396 $
("#layout_id").val("<?php echo $layout_id; ?>");
1402 $
(".addgroup").click(function() { AddGroup(this
); });
1403 $
(".savenewgroup").click(function() { SaveNewGroup(this
); });
1404 $
(".deletegroup").click(function() { DeleteGroup(this
); });
1405 $
(".cancelnewgroup").click(function() { CancelNewGroup(this
); });
1406 $
(".movegroup").click(function() { MoveGroup(this
); });
1407 $
(".renamegroup").click(function() { RenameGroup(this
); });
1408 $
(".saverenamegroup").click(function() { SaveRenameGroup(this
); });
1409 $
(".cancelrenamegroup").click(function() { CancelRenameGroup(this
); });
1410 $
(".addfield").click(function() { AddField(this
); });
1411 $
("#deletefields").click(function() { DeleteFields(this
); });
1412 $
(".selectfield").click(function() {
1413 var TRparent
= $
(this
).parent().parent();
1414 $
(TRparent
).children("td").toggleClass("highlight");
1415 // disable the delete-move buttons
1416 $
("#deletefields").attr("disabled", "disabled");
1417 $
("#movefields").attr("disabled", "disabled");
1418 $
(".selectfield").each(function(i
) {
1419 // if any field is selected, enable the delete-move buttons
1420 if ($
(this
).attr("checked") == true) {
1421 $
("#deletefields").removeAttr("disabled");
1422 $
("#movefields").removeAttr("disabled");
1427 $
("#movefields").click(function() { ShowGroups(this
); });
1428 $
(".savenewfield").click(function() { SaveNewField(this
); });
1429 $
(".cancelnewfield").click(function() { CancelNewField(this
); });
1430 $
("#newtitle").blur(function() { if ($
("#newid").val() == "") $
("#newid").val($
("#newtitle").val()); });
1431 $
("#newdatatype").change(function() { ChangeList(this
.value
);});
1432 $
("#gnewdatatype").change(function() { ChangeListg(this
.value
);});
1433 $
(".listid").click(function() { ShowLists(this
); });
1435 // special class that skips the element
1436 $
(".noselect").focus(function() { $
(this
).blur(); });
1438 // Save the changes made to the form
1439 var SaveChanges
= function () {
1440 $
("#formaction").val("save");
1444 /****************************************************/
1445 /************ Group functions ***********************/
1446 /****************************************************/
1448 // display the 'new group' DIV
1449 var AddGroup
= function(btnObj
) {
1450 if (!myChangeCheck()) return;
1451 $
("#save").attr("disabled", true);
1452 // show the field details DIV
1453 $
('#groupdetail').css('visibility', 'visible');
1454 $
('#groupdetail').css('display', 'block');
1455 $
(btnObj
).parent().append($
("#groupdetail"));
1456 $
('#groupdetail > #newgroupname').focus();
1457 // Assign a sensible default sequence number.
1458 $
('#gnewseq').val(10);
1461 // save the new group to the form
1462 var SaveNewGroup
= function(btnObj
) {
1463 // the group name field can only have letters, numbers, spaces and underscores
1464 // AND it cannot start with a number
1465 if ($
("#newgroupname").val() == "") {
1466 alert("<?php xl('Group names cannot be blank', 'e'); ?>");
1469 if ($
("#newgroupname").val().match(/^
(\d+|\s+
)/)) {
1470 alert("<?php xl('Group names cannot start with numbers or spaces.', 'e'); ?>");
1473 var validname
= $
("#newgroupname").val().replace(/[^A
-za
-z0
-9 ]/g
, "_"); // match any non-word characters and replace them
1474 $
("#newgroupname").val(validname
);
1476 // now, check the first group field values
1478 // seq must be numeric and less than 999
1479 if (! IsNumeric($
("#gnewseq").val(), 0, 999)) {
1480 alert("<?php xl('Order must be a number between 1 and 999', 'e'); ?>");
1483 // length must be numeric and less than 999
1484 if (! IsNumeric($
("#gnewlengthWidth").val(), 0, 999)) {
1485 alert("<?php xl('Size must be a number between 1 and 999', 'e'); ?>");
1488 // titlecols must be numeric and less than 100
1489 if (! IsNumeric($
("#gnewtitlecols").val(), 0, 999)) {
1490 alert("<?php xl('LabelCols must be a number between 1 and 999', 'e'); ?>");
1493 // datacols must be numeric and less than 100
1494 if (! IsNumeric($
("#gnewdatacols").val(), 0, 999)) {
1495 alert("<?php xl('DataCols must be a number between 1 and 999', 'e'); ?>");
1498 // some fields cannot be blank
1499 if ($
("#gnewtitle").val() == "") {
1500 alert("<?php xl('Label cannot be blank', 'e'); ?>");
1503 // the id field can only have letters, numbers and underscores
1504 if ($
("#gnewid").val() == "") {
1505 alert("<?php xl('ID cannot be blank', 'e'); ?>");
1508 var validid
= $
("#gnewid").val().replace(/(\s|\W
)/g
, "_"); // match any non-word characters and replace them
1509 $
("#gnewid").val(validid
);
1510 // similarly with the listid field
1511 validid
= $
("#gnewlistid").val().replace(/(\s|\W
)/g
, "_");
1512 $
("#gnewlistid").val(validid
);
1513 // similarly with the backuplistid field
1514 validid
= $
("#gnewbackuplistid").val().replace(/(\s|\W
)/g
, "_");
1515 $
("#gnewbackuplistid").val(validid
);
1518 // submit the form to add a new field to a specific group
1519 $
("#formaction").val("addgroup");
1523 // actually delete an entire group from the database
1524 var DeleteGroup
= function(btnObj
) {
1525 var parts
= $
(btnObj
).attr("id");
1526 var groupname
= parts
.replace(/^\d+
/, "");
1527 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+
"'?")) {
1528 // submit the form to add a new field to a specific group
1529 $
("#formaction").val("deletegroup");
1530 $
("#deletegroupname").val(parts
);
1531 $
("#theform").submit();
1535 // just hide the new field DIV
1536 var CancelNewGroup
= function(btnObj
) {
1537 // hide the field details DIV
1538 $
('#groupdetail').css('visibility', 'hidden');
1539 $
('#groupdetail').css('display', 'none');
1540 // reset the new group values to a default
1541 $
('#groupdetail > #newgroupname').val("");
1542 $
("#save").attr("disabled", false);
1545 // display the 'new field' DIV
1546 var MoveGroup
= function(btnObj
) {
1547 if (!myChangeCheck()) return;
1548 var btnid
= $
(btnObj
).attr("id");
1549 var parts
= btnid
.split("~");
1550 var groupid
= parts
[0];
1551 var direction
= parts
[1];
1552 // submit the form to change group order
1553 $
("#formaction").val("movegroup");
1554 $
("#movegroupname").val(groupid
);
1555 $
("#movedirection").val(direction
);
1559 // show the rename group DIV
1560 var RenameGroup
= function(btnObj
) {
1561 if (!myChangeCheck()) return;
1562 $
("#save").attr("disabled", true);
1563 $
('#renamegroupdetail').css('visibility', 'visible');
1564 $
('#renamegroupdetail').css('display', 'block');
1565 $
(btnObj
).parent().append($
("#renamegroupdetail"));
1566 $
('#renameoldgroupname').val($
(btnObj
).attr("id"));
1567 $
('#renamegroupname').val($
(btnObj
).attr("id").replace(/^\d+
/, ""));
1570 // save the new group to the form
1571 var SaveRenameGroup
= function(btnObj
) {
1572 // the group name field can only have letters, numbers, spaces and underscores
1573 // AND it cannot start with a number
1574 if ($
("#renamegroupname").val().match(/^\d+
/)) {
1575 alert("<?php xl('Group names cannot start with numbers.', 'e'); ?>");
1578 var validname
= $
("#renamegroupname").val().replace(/[^A
-za
-z0
-9 ]/g
, "_"); // match any non-word characters and replace them
1579 $
("#renamegroupname").val(validname
);
1581 // submit the form to add a new field to a specific group
1582 $
("#formaction").val("renamegroup");
1586 // just hide the new field DIV
1587 var CancelRenameGroup
= function(btnObj
) {
1588 // hide the field details DIV
1589 $
('#renamegroupdetail').css('visibility', 'hidden');
1590 $
('#renamegroupdetail').css('display', 'none');
1591 // reset the rename group values to a default
1592 $
('#renameoldgroupname').val("");
1593 $
('#renamegroupname').val("");
1596 /****************************************************/
1597 /************ Field functions ***********************/
1598 /****************************************************/
1600 // display the 'new field' DIV
1601 var AddField
= function(btnObj
) {
1602 if (!myChangeCheck()) return;
1603 $
("#save").attr("disabled", true);
1604 // update the fieldgroup value to be the groupid
1605 var btnid
= $
(btnObj
).attr("id");
1606 var parts
= btnid
.split("~");
1607 var groupid
= parts
[1];
1608 $
('#fielddetail > #newfieldgroupid').attr('value', groupid
);
1609 // show the field details DIV
1610 $
('#fielddetail').css('visibility', 'visible');
1611 $
('#fielddetail').css('display', 'block');
1612 $
(btnObj
).parent().append($
("#fielddetail"));
1613 // Assign a sensible default sequence number.
1614 $
('#newseq').val(getNextSeq(groupid
));
1617 var DeleteFields
= function(btnObj
) {
1618 if (!myChangeCheck()) return;
1619 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'); ?>")) {
1621 $
(".selectfield").each(function(i
) {
1622 // build a list of selected field names to be moved
1623 if ($
(this
).attr("checked") == true) {
1624 var parts
= this
.id
.split("~");
1625 var currval
= $
("#selectedfields").val();
1626 $
("#selectedfields").val(currval+delim+parts
[1]);
1630 // submit the form to delete the field(s)
1631 $
("#formaction").val("deletefields");
1636 // save the new field to the form
1637 var SaveNewField
= function(btnObj
) {
1638 // check the new field values for correct formatting
1640 // seq must be numeric and less than 999
1641 if (! IsNumeric($
("#newseq").val(), 0, 999)) {
1642 alert("<?php xl('Order must be a number between 1 and 999', 'e'); ?>");
1645 // length must be numeric and less than 999
1646 if (! IsNumeric($
("#newlengthWidth").val(), 0, 999)) {
1647 alert("<?php xl('Size must be a number between 1 and 999', 'e'); ?>");
1650 // titlecols must be numeric and less than 100
1651 if (! IsNumeric($
("#newtitlecols").val(), 0, 999)) {
1652 alert("<?php xl('LabelCols must be a number between 1 and 999', 'e'); ?>");
1655 // datacols must be numeric and less than 100
1656 if (! IsNumeric($
("#newdatacols").val(), 0, 999)) {
1657 alert("<?php xl('DataCols must be a number between 1 and 999', 'e'); ?>");
1660 // some fields cannot be blank
1661 if ($
("#newtitle").val() == "") {
1662 alert("<?php xl('Label cannot be blank', 'e'); ?>");
1665 // the id field can only have letters, numbers and underscores
1666 var validid
= $
("#newid").val().replace(/(\s|\W
)/g
, "_"); // match any non-word characters and replace them
1667 $
("#newid").val(validid
);
1668 // similarly with the listid field
1669 validid
= $
("#newlistid").val().replace(/(\s|\W
)/g
, "_");
1670 $
("#newlistid").val(validid
);
1671 // similarly with the backuplistid field
1672 validid
= $
("#newbackuplistid").val().replace(/(\s|\W
)/g
, "_");
1673 $
("#newbackuplistid").val(validid
);
1675 // submit the form to add a new field to a specific group
1676 $
("#formaction").val("addfield");
1680 // just hide the new field DIV
1681 var CancelNewField
= function(btnObj
) {
1682 // hide the field details DIV
1683 $
('#fielddetail').css('visibility', 'hidden');
1684 $
('#fielddetail').css('display', 'none');
1685 // reset the new field values to a default
1686 ResetNewFieldValues();
1687 $
("#save").attr("disabled", false);
1690 // show the popup choice of lists
1691 var ShowLists
= function(btnObj
) {
1692 window
.open("./show_lists_popup.php", "lists", "width=300,height=500,scrollbars=yes");
1693 selectedfield
= btnObj
;
1696 // show the popup choice of groups
1697 var ShowGroups
= function(btnObj
) {
1698 if (!myChangeCheck()) return;
1699 window
.open("./show_groups_popup.php?layout_id=<?php echo $layout_id;?>", "groups", "width=300,height=300,scrollbars=yes");
1702 // Show context DD for NationNotes
1703 var ChangeList
= function(btnObj
){
1705 $
('#newlistid').hide();
1706 $
('#contextName').show();
1709 $
('#newlistid').show();
1710 $
('#contextName').hide();
1713 var ChangeListg
= function(btnObj
){
1715 $
('#gnewlistid').hide();
1716 $
('#gcontextName').show();
1719 $
('#gnewlistid').show();
1720 $
('#gcontextName').hide();
1724 // Initialize the list item selectors in skip conditions.
1725 var f
= document
.forms
[0];
1726 for (var lino
= 1; f
['fld[' + lino +
'][id]']; ++lino
) {
1727 for (var seq
= 0; f
['fld[' + lino +
'][condition_itemid][' + seq +
']']; ++seq
) {
1728 setListItemOptions(lino
, seq
, true);
1732 // Support for beforeunload handler.
1733 $
('tbody input, tbody select, tbody textarea').not('.selectfield').change(function() {
1734 somethingChanged
= true;
1736 window
.addEventListener("beforeunload", function (e
) {
1737 if (somethingChanged
&& !top
.timed_out
) {
1738 var msg
= "<?php echo xls('You have unsaved changes.'); ?>";
1739 e
.returnValue
= msg
; // Gecko, Trident, Chrome 34+
1740 return msg
; // Gecko, WebKit, Chrome <34
1746 function NationNotesContext(lineitem
,val
){
1748 document
.getElementById("fld["+lineitem+
"][contextName]").style
.display
='';
1749 document
.getElementById("fld["+lineitem+
"][list_id]").style
.display
='none';
1750 document
.getElementById("fld["+lineitem+
"][list_id]").value
='';
1753 document
.getElementById("fld["+lineitem+
"][list_id]").style
.display
='';
1754 document
.getElementById("fld["+lineitem+
"][contextName]").style
.display
='none';
1755 document
.getElementById("fld["+lineitem+
"][list_id]").value
='';
1759 function SetList(listid
) {
1760 $
(selectedfield
).val(listid
);
1763 //////////////////////////////////////////////////////////////////////
1764 // The following supports the field ID selection pop-up.
1765 //////////////////////////////////////////////////////////////////////
1767 var fieldselectfield
;
1769 function elemFromPart(part
) {
1770 var ename
= fieldselectfield
.name
;
1771 // ename is like one of the following:
1772 // fld[$fld_line_no][id]
1775 // and "part" is what we substitute for the "id" part.
1776 var i
= ename
.lastIndexOf('id');
1777 ename
= ename
.substr(0, i
) + part + ename
.substr(i+
2);
1778 return document
.forms
[0][ename
];
1781 function FieldIDClicked(elem
) {
1782 <?php
if (substr($layout_id, 0, 3) == 'LBF') { ?
>
1783 fieldselectfield
= elem
;
1784 var srcval
= elemFromPart('source').value
;
1785 // If the field ID is for the local form, allow direct entry.
1786 if (srcval
== 'F') return;
1787 // Otherwise pop up the selection window.
1788 window
.open('./field_id_popup.php?source=' + srcval
, 'fields',
1789 'width=600,height=600,scrollbars=yes');
1793 function SetField(field_id
, title
, data_type
, uor
, fld_length
, max_length
,
1794 list_id
, titlecols
, datacols
, edit_options
, description
, fld_rows
)
1796 fieldselectfield
.value
= field_id
;
1797 elemFromPart('title' ).value
= title
;
1798 elemFromPart('datatype' ).value
= data_type
;
1799 elemFromPart('uor' ).value
= uor
;
1800 elemFromPart('lengthWidth' ).value
= fld_length
;
1801 elemFromPart('maxSize' ).value
= max_length
;
1802 elemFromPart('listid' ).value
= list_id
;
1803 elemFromPart('titlecols' ).value
= titlecols
;
1804 elemFromPart('datacols' ).value
= datacols
;
1805 elemFromPart('edit_options').value
= edit_options
;
1806 elemFromPart('desc' ).value
= description
;
1807 elemFromPart('lengthHeight').value
= fld_rows
;
1810 //////////////////////////////////////////////////////////////////////
1811 // End code for field ID selection pop-up.
1812 //////////////////////////////////////////////////////////////////////
1814 /* this is called after the user chooses a new group from the popup window
1815 * it will submit the page so the selected fields can be moved into
1818 function MoveFields(targetgroup
) {
1819 $
("#targetgroup").val(targetgroup
);
1821 $
(".selectfield").each(function(i
) {
1822 // build a list of selected field names to be moved
1823 if ($
(this
).attr("checked") == true) {
1824 var parts
= this
.id
.split("~");
1825 var currval
= $
("#selectedfields").val();
1826 $
("#selectedfields").val(currval+delim+parts
[1]);
1830 $
("#formaction").val("movefields");
1834 // set the new-field values to a default state
1835 function ResetNewFieldValues () {
1836 $
("#newseq").val("");
1837 $
("#newsource").val("");
1838 $
("#newid").val("");
1839 $
("#newtitle").val("");
1840 $
("#newuor").val(1);
1841 $
("#newlengthWidth").val("");
1842 $
("#newlengthHeight").val("");
1843 $
("#newmaxSize").val("");
1844 $
("#newdatatype").val("");
1845 $
("#newlistid").val("");
1846 $
("#newbackuplistid").val("");
1847 $
("#newtitlecols").val("");
1848 $
("#newdatacols").val("");
1849 $
("#newedit_options").val("");
1850 $
("#newdefault").val("");
1851 $
("#newdesc").val("");
1854 // is value an integer and between min and max
1855 function IsNumeric(value
, min
, max
) {
1856 if (value
== "" || value
== null) return false;
1858 parseInt(value
) < min ||
1859 parseInt(value
) > max
)
1865 /****************************************************/
1866 /****************************************************/
1867 /****************************************************/
1869 // tell if num is an Integer
1870 function IsN(num
) { return !/\D
/.test(num
); }