2 // Copyright (C) 2007-2009 Rod Roark <rod@sunsetsystems.com>
4 // This program is free software; you can redistribute it and/or
5 // modify it under the terms of the GNU General Public License
6 // as published by the Free Software Foundation; either version 2
7 // of the License, or (at your option) any later version.
9 // Functions for managing the lists and layouts
11 // Note: there are translation wrappers for the lists and layout labels
12 // at library/translation.inc.php. The functions are titled
13 // xl_list_label() and xl_layout_label() and are controlled by the
14 // $GLOBALS['translate_lists'] and $GLOBALS['translate_layout']
15 // flags in globals.php
17 require_once("formdata.inc.php");
21 function get_pharmacies() {
22 return sqlStatement("SELECT d.id, d.name, a.line1, a.city, " .
23 "p.area_code, p.prefix, p.number FROM pharmacies AS d " .
24 "LEFT OUTER JOIN addresses AS a ON a.foreign_id = d.id " .
25 "LEFT OUTER JOIN phone_numbers AS p ON p.foreign_id = d.id " .
27 "ORDER BY name, area_code, prefix, number");
30 function generate_form_field($frow, $currvalue) {
31 global $rootdir, $date_init;
33 $currescaped = htmlspecialchars($currvalue, ENT_QUOTES
);
35 $data_type = $frow['data_type'];
36 $field_id = $frow['field_id'];
37 $list_id = $frow['list_id'];
39 // Added 5-09 by BM - Translate description if applicable
40 $description = htmlspecialchars(xl_layout_label($frow['description']), ENT_QUOTES
);
42 // added 5-2009 by BM to allow modification of the 'empty' text title field.
43 // Can pass $frow['empty_title'] with this variable, otherwise
44 // will default to 'Unassigned'.
45 // modified 6-2009 by BM to allow complete skipping of the 'empty' text title
46 // if make $frow['empty_title'] equal to 'SKIP'
48 if (isset($frow['empty_title'])) {
49 if ($frow['empty_title'] == "SKIP") {
50 //do not display an 'empty' choice
52 $empty_title = "Unassigned";
55 $empty_title = $frow['empty_title'];
59 $empty_title = "Unassigned";
62 // generic single-selection list
63 if ($data_type == 1) {
64 echo "<select name='form_$field_id' id='form_$field_id' title='$description'>";
65 if ($showEmpty) echo "<option value=''>" . xl($empty_title) . "</option>";
66 $lres = sqlStatement("SELECT * FROM list_options " .
67 "WHERE list_id = '$list_id' ORDER BY seq, title");
68 $got_selected = FALSE;
69 while ($lrow = sqlFetchArray($lres)) {
70 echo "<option value='" . $lrow['option_id'] . "'";
71 if ((strlen($currvalue) == 0 && $lrow['is_default']) ||
72 (strlen($currvalue) > 0 && $lrow['option_id'] == $currvalue))
78 // Added 5-09 by BM - Translate label if applicable
79 echo ">" . xl_list_label($lrow['title']) . "</option>\n";
82 if (!$got_selected && strlen($currvalue) > 0) {
83 echo "<option value='$currescaped' selected>* $currescaped *</option>";
85 echo " <font color='red' title='" . xl('Please choose a valid selection from the list.') . "'>" . xl('Fix this') . "!</font>";
93 else if ($data_type == 2) {
94 echo "<input type='text'" .
95 " name='form_$field_id'" .
96 " id='form_$field_id'" .
97 " size='" . $frow['fld_length'] . "'" .
98 " maxlength='" . $frow['max_length'] . "'" .
99 " title='$description'" .
100 " value='$currescaped'";
101 if (strpos($frow['edit_options'], 'C') !== FALSE)
102 echo " onchange='capitalizeMe(this)'";
106 // long or multi-line text field
107 else if ($data_type == 3) {
109 " name='form_$field_id'" .
110 " id='form_$field_id'" .
111 " title='$description'" .
112 " cols='" . $frow['fld_length'] . "'" .
113 " rows='" . $frow['max_length'] . "'>" .
114 $currescaped . "</textarea>";
118 else if ($data_type == 4) {
119 echo "<input type='text' size='10' name='form_$field_id' id='form_$field_id'" .
120 " value='$currescaped'" .
121 " title='$description'" .
122 " onkeyup='datekeyup(this,mypcc)' onblur='dateblur(this,mypcc)' />" .
123 "<img src='$rootdir/pic/show_calendar.gif' align='absbottom' width='24' height='22'" .
124 " id='img_$field_id' border='0' alt='[?]' style='cursor:pointer'" .
125 " title='" . xl('Click here to choose a date') . "' />";
126 $date_init .= " Calendar.setup({inputField:'form_$field_id', ifFormat:'%Y-%m-%d', button:'img_$field_id'});\n";
129 // provider list, local providers only
130 else if ($data_type == 10) {
131 $ures = sqlStatement("SELECT id, fname, lname, specialty FROM users " .
132 "WHERE active = 1 AND ( info IS NULL OR info NOT LIKE '%Inactive%' ) " .
133 "AND authorized = 1 " .
134 "ORDER BY lname, fname");
135 echo "<select name='form_$field_id' id='form_$field_id' title='$description'>";
136 echo "<option value=''>" . xl('Unassigned') . "</option>";
137 while ($urow = sqlFetchArray($ures)) {
138 $uname = $urow['fname'] . ' ' . $urow['lname'];
139 echo "<option value='" . $urow['id'] . "'";
140 if ($urow['id'] == $currvalue) echo " selected";
141 echo ">$uname</option>";
146 // provider list, including address book entries with an NPI number
147 else if ($data_type == 11) {
148 $ures = sqlStatement("SELECT id, fname, lname, specialty FROM users " .
149 "WHERE active = 1 AND ( info IS NULL OR info NOT LIKE '%Inactive%' ) " .
150 "AND ( authorized = 1 OR ( username = '' AND npi != '' ) ) " .
151 "ORDER BY lname, fname");
152 echo "<select name='form_$field_id' id='form_$field_id' title='$description'>";
153 echo "<option value=''>" . xl('Unassigned') . "</option>";
154 while ($urow = sqlFetchArray($ures)) {
155 $uname = $urow['fname'] . ' ' . $urow['lname'];
156 echo "<option value='" . $urow['id'] . "'";
157 if ($urow['id'] == $currvalue) echo " selected";
158 echo ">$uname</option>";
164 else if ($data_type == 12) {
165 echo "<select name='form_$field_id' id='form_$field_id' title='$description'>";
166 echo "<option value='0'></option>";
167 $pres = get_pharmacies();
168 while ($prow = sqlFetchArray($pres)) {
170 echo "<option value='$key'";
171 if ($currvalue == $key) echo " selected";
172 echo '>' . $prow['name'] . ' ' . $prow['area_code'] . '-' .
173 $prow['prefix'] . '-' . $prow['number'] . ' / ' .
174 $prow['line1'] . ' / ' . $prow['city'] . "</option>";
180 else if ($data_type == 13) {
181 echo "<select name='form_$field_id' id='form_$field_id' title='$description'>";
182 echo "<option value=''> </option>";
183 $squads = acl_get_squads();
185 foreach ($squads as $key => $value) {
186 echo "<option value='$key'";
187 if ($currvalue == $key) echo " selected";
188 echo ">" . $value[3] . "</option>\n";
194 // Address book, preferring organization name if it exists and is not in
195 // parentheses, and excluding local users who are not providers.
196 // Supports "referred to" practitioners and facilities.
197 else if ($data_type == 14) {
198 $ures = sqlStatement("SELECT id, fname, lname, organization, username FROM users " .
199 "WHERE active = 1 AND ( info IS NULL OR info NOT LIKE '%Inactive%' ) " .
200 "AND ( username = '' OR authorized = 1 ) " .
201 "ORDER BY organization, lname, fname");
202 echo "<select name='form_$field_id' id='form_$field_id' title='$description'>";
203 echo "<option value=''>" . xl('Unassigned') . "</option>";
204 while ($urow = sqlFetchArray($ures)) {
205 $uname = $urow['organization'];
206 if (empty($uname) ||
substr($uname, 0, 1) == '(') {
207 $uname = $urow['lname'];
208 if ($urow['fname']) $uname .= ", " . $urow['fname'];
210 echo "<option value='" . $urow['id'] . "'";
211 $title = $urow['username'] ?
xl('Local') : xl('External');
212 echo " title='$title'";
213 if ($urow['id'] == $currvalue) echo " selected";
214 echo ">$uname</option>";
219 // a billing code (only one of these allowed!)
220 else if ($data_type == 15) {
221 echo "<input type='text'" .
222 " name='form_$field_id'" .
223 " id='form_related_code'" .
224 " size='" . $frow['fld_length'] . "'" .
225 " maxlength='" . $frow['max_length'] . "'" .
226 " title='$description'" .
227 " value='$currescaped'" .
228 " onclick='sel_related()' readonly" .
232 // a set of labeled checkboxes
233 else if ($data_type == 21) {
234 // In this special case, fld_length is the number of columns generated.
235 $cols = max(1, $frow['fld_length']);
236 $avalue = explode('|', $currvalue);
237 $lres = sqlStatement("SELECT * FROM list_options " .
238 "WHERE list_id = '$list_id' ORDER BY seq, title");
239 echo "<table cellpadding='0' cellspacing='0' width='100%'>";
240 $tdpct = (int) (100 / $cols);
241 for ($count = 0; $lrow = sqlFetchArray($lres); ++
$count) {
242 $option_id = $lrow['option_id'];
243 // if ($count) echo "<br />";
244 if ($count %
$cols == 0) {
245 if ($count) echo "</tr>";
248 echo "<td width='$tdpct%'>";
249 echo "<input type='checkbox' name='form_{$field_id}[$option_id]' id='form_{$field_id}[$option_id]' value='1'";
250 if (in_array($option_id, $avalue)) echo " checked";
252 // Added 5-09 by BM - Translate label if applicable
253 echo ">" . xl_list_label($lrow['title']);
259 if ($count > $cols) {
260 // Add some space after multiple rows of checkboxes.
261 echo "<tr><td colspan='$cols' style='height:0.7em'></td></tr>";
267 // a set of labeled text input fields
268 else if ($data_type == 22) {
269 $tmp = explode('|', $currvalue);
271 foreach ($tmp as $value) {
272 if (preg_match('/^([^:]+):(.*)$/', $value, $matches)) {
273 $avalue[$matches[1]] = $matches[2];
276 $lres = sqlStatement("SELECT * FROM list_options " .
277 "WHERE list_id = '$list_id' ORDER BY seq, title");
278 echo "<table cellpadding='0' cellspacing='0'>";
279 while ($lrow = sqlFetchArray($lres)) {
280 $option_id = $lrow['option_id'];
281 $maxlength = empty($frow['max_length']) ?
255 : $frow['max_length'];
282 $fldlength = empty($frow['fld_length']) ?
20 : $frow['fld_length'];
284 // Added 5-09 by BM - Translate label if applicable
285 echo "<tr><td>" . xl_list_label($lrow['title']) . " </td>";
287 echo "<td><input type='text'" .
288 " name='form_{$field_id}[$option_id]'" .
289 " id='form_{$field_id}[$option_id]'" .
290 " size='$fldlength'" .
291 " maxlength='$maxlength'" .
292 " value='" . $avalue[$option_id] . "'";
293 echo " /></td></tr>";
298 // a set of exam results; 3 radio buttons and a text field:
299 else if ($data_type == 23) {
300 $tmp = explode('|', $currvalue);
302 foreach ($tmp as $value) {
303 if (preg_match('/^([^:]+):(.*)$/', $value, $matches)) {
304 $avalue[$matches[1]] = $matches[2];
307 $maxlength = empty($frow['max_length']) ?
255 : $frow['max_length'];
308 $fldlength = empty($frow['fld_length']) ?
20 : $frow['fld_length'];
309 $lres = sqlStatement("SELECT * FROM list_options " .
310 "WHERE list_id = '$list_id' ORDER BY seq, title");
311 echo "<table cellpadding='0' cellspacing='0'>";
312 echo "<tr><td> </td><td class='bold'>" . xl('N/A') .
313 " </td><td class='bold'>" . xl('Nor') . " </td>" .
314 "<td class='bold'>" . xl('Abn') . " </td><td class='bold'>" .
315 xl('Date/Notes') . "</td></tr>";
316 while ($lrow = sqlFetchArray($lres)) {
317 $option_id = $lrow['option_id'];
318 $restype = substr($avalue[$option_id], 0, 1);
319 $resnote = substr($avalue[$option_id], 2);
321 // Added 5-09 by BM - Translate label if applicable
322 echo "<tr><td>" . xl_list_label($lrow['title']) . " </td>";
324 for ($i = 0; $i < 3; ++
$i) {
325 echo "<td><input type='radio'" .
326 " name='radio_{$field_id}[$option_id]'" .
327 " id='radio_{$field_id}[$option_id]'" .
329 if ($restype === "$i") echo " checked";
332 echo "<td><input type='text'" .
333 " name='form_{$field_id}[$option_id]'" .
334 " id='form_{$field_id}[$option_id]'" .
335 " size='$fldlength'" .
336 " maxlength='$maxlength'" .
337 " value='$resnote' /></td>";
343 // the list of active allergies for the current patient
344 // this is read-only!
345 else if ($data_type == 24) {
346 $query = "SELECT title, comments FROM lists WHERE " .
347 "pid = '" . $GLOBALS['pid'] . "' AND type = 'allergy' AND enddate IS NULL " .
349 // echo "<!-- $query -->\n"; // debugging
350 $lres = sqlStatement($query);
352 while ($lrow = sqlFetchArray($lres)) {
353 if ($count++
) echo "<br />";
355 if ($lrow['comments']) echo ' (' . $lrow['comments'] . ')';
359 // a set of labeled checkboxes, each with a text field:
360 else if ($data_type == 25) {
361 $tmp = explode('|', $currvalue);
363 foreach ($tmp as $value) {
364 if (preg_match('/^([^:]+):(.*)$/', $value, $matches)) {
365 $avalue[$matches[1]] = $matches[2];
368 $maxlength = empty($frow['max_length']) ?
255 : $frow['max_length'];
369 $fldlength = empty($frow['fld_length']) ?
20 : $frow['fld_length'];
370 $lres = sqlStatement("SELECT * FROM list_options " .
371 "WHERE list_id = '$list_id' ORDER BY seq, title");
372 echo "<table cellpadding='0' cellspacing='0'>";
373 while ($lrow = sqlFetchArray($lres)) {
374 $option_id = $lrow['option_id'];
375 $restype = substr($avalue[$option_id], 0, 1);
376 $resnote = substr($avalue[$option_id], 2);
378 // Added 5-09 by BM - Translate label if applicable
379 echo "<tr><td>" . xl_list_label($lrow['title']) . " </td>";
381 echo "<td><input type='checkbox' name='check_{$field_id}[$option_id]' id='check_{$field_id}[$option_id]' value='1'";
382 if ($restype) echo " checked";
383 echo " /> </td>";
384 echo "<td><input type='text'" .
385 " name='form_{$field_id}[$option_id]'" .
386 " id='form_{$field_id}[$option_id]'" .
387 " size='$fldlength'" .
388 " maxlength='$maxlength'" .
389 " value='$resnote' /></td>";
395 // single-selection list with ability to add to it
396 else if ($data_type == 26) {
397 echo "<select class='addtolistclass_$list_id' name='form_$field_id' id='form_$field_id' title='$description'>";
398 if ($showEmpty) echo "<option value=''>" . xl($empty_title) . "</option>";
399 $lres = sqlStatement("SELECT * FROM list_options " .
400 "WHERE list_id = '$list_id' ORDER BY seq, title");
401 $got_selected = FALSE;
402 while ($lrow = sqlFetchArray($lres)) {
403 echo "<option value='" . $lrow['option_id'] . "'";
404 if ((strlen($currvalue) == 0 && $lrow['is_default']) ||
405 (strlen($currvalue) > 0 && $lrow['option_id'] == $currvalue))
408 $got_selected = TRUE;
410 // Added 5-09 by BM - Translate label if applicable
411 echo ">" . xl_list_label($lrow['title']) . "</option>\n";
413 if (!$got_selected && strlen($currvalue) > 0) {
414 echo "<option value='$currescaped' selected>* $currescaped *</option>";
416 echo " <font color='red' title='" . xl('Please choose a valid selection from the list.') . "'>" . xl('Fix this') . "!</font>";
421 // show the add button if user has access to correct list
422 $outputAddButton = "<input type='button' id='addtolistid_".$list_id."' fieldid='form_".$field_id."' class='addtolist' value='" . xl('Add') . "'>";
423 if (aco_exist('lists', $list_id)) {
424 // a specific aco exist for this list, so ensure access
425 if (acl_check('lists', $list_id)) echo $outputAddButton;
428 // no specific aco exist for this list, so check for access to 'default' list
429 if (acl_check('lists', 'default')) echo $outputAddButton;
433 // a set of labeled radio buttons
434 else if ($data_type == 27) {
435 // In this special case, fld_length is the number of columns generated.
436 $cols = max(1, $frow['fld_length']);
437 $lres = sqlStatement("SELECT * FROM list_options " .
438 "WHERE list_id = '$list_id' ORDER BY seq, title");
439 echo "<table cellpadding='0' cellspacing='0' width='100%'>";
440 $tdpct = (int) (100 / $cols);
441 $got_selected = FALSE;
442 for ($count = 0; $lrow = sqlFetchArray($lres); ++
$count) {
443 $option_id = $lrow['option_id'];
444 if ($count %
$cols == 0) {
445 if ($count) echo "</tr>";
448 echo "<td width='$tdpct%'>";
449 echo "<input type='radio' name='form_{$field_id}' id='form_{$field_id}[$option_id]' value='$option_id'";
450 if ((strlen($currvalue) == 0 && $lrow['is_default']) ||
451 (strlen($currvalue) > 0 && $option_id == $currvalue))
454 $got_selected = TRUE;
456 echo ">" . xl_list_label($lrow['title']);
461 if ($count > $cols) {
462 // Add some space after multiple rows of radio buttons.
463 echo "<tr><td colspan='$cols' style='height:0.7em'></td></tr>";
467 if (!$got_selected && strlen($currvalue) > 0) {
468 echo "$currvalue <font color='red' title='" . xl('Please choose a valid selection.') . "'>" . xl('Fix this') . "!</font>";
474 function generate_print_field($frow, $currvalue) {
475 global $rootdir, $date_init;
477 $currescaped = htmlspecialchars($currvalue, ENT_QUOTES
);
479 $data_type = $frow['data_type'];
480 $field_id = $frow['field_id'];
481 $list_id = $frow['list_id'];
482 $fld_length = $frow['fld_length'];
484 $description = htmlspecialchars(xl_layout_label($frow['description']), ENT_QUOTES
);
486 // Can pass $frow['empty_title'] with this variable, otherwise
487 // will default to 'Unassigned'.
488 // If it is 'SKIP' then an empty text title is completely skipped.
490 if (isset($frow['empty_title'])) {
491 if ($frow['empty_title'] == "SKIP") {
492 //do not display an 'empty' choice
494 $empty_title = "Unassigned";
497 $empty_title = $frow['empty_title'];
501 $empty_title = "Unassigned";
504 // generic single-selection list
505 if ($data_type == 1 ||
$data_type == 26) {
506 if (empty($fld_length)) {
507 if ($list_id == 'titles') {
515 $lrow = sqlQuery("SELECT title FROM list_options " .
516 "WHERE list_id = '$list_id' AND option_id = '$currvalue'");
517 $tmp = xl_list_label($lrow['title']);
518 if (empty($tmp)) $tmp = "($currvalue)";
520 /*****************************************************************
521 echo "<input type='text'" .
522 " size='$fld_length'" .
526 *****************************************************************/
527 if ($tmp === '') $tmp = ' ';
532 else if ($data_type == 2 ||
$data_type == 15) {
533 /*****************************************************************
534 echo "<input type='text'" .
535 " size='$fld_length'" .
536 " value='$currescaped'" .
539 *****************************************************************/
540 if ($currescaped === '') $currescaped = ' ';
544 // long or multi-line text field
545 else if ($data_type == 3) {
547 " cols='$fld_length'" .
548 " rows='" . $frow['max_length'] . "'>" .
549 $currescaped . "</textarea>";
553 else if ($data_type == 4) {
554 /*****************************************************************
555 echo "<input type='text' size='10'" .
556 " value='$currescaped'" .
557 " title='$description'" .
560 *****************************************************************/
561 if ($currescaped === '') $currescaped = ' ';
566 else if ($data_type == 10 ||
$data_type == 11) {
569 $urow = sqlQuery("SELECT fname, lname, specialty FROM users " .
570 "WHERE id = '$currvalue'");
571 $tmp = ucwords($urow['fname'] . " " . $urow['lname']);
572 if (empty($tmp)) $tmp = "($currvalue)";
574 /*****************************************************************
575 echo "<input type='text'" .
576 " size='$fld_length'" .
580 *****************************************************************/
581 if ($tmp === '') $tmp = ' ';
586 else if ($data_type == 12) {
589 $pres = get_pharmacies();
590 while ($prow = sqlFetchArray($pres)) {
592 if ($currvalue == $key) {
593 $tmp = $prow['name'] . ' ' . $prow['area_code'] . '-' .
594 $prow['prefix'] . '-' . $prow['number'] . ' / ' .
595 $prow['line1'] . ' / ' . $prow['city'];
598 if (empty($tmp)) $tmp = "($currvalue)";
600 /*****************************************************************
601 echo "<input type='text'" .
602 " size='$fld_length'" .
606 *****************************************************************/
607 if ($tmp === '') $tmp = ' ';
612 else if ($data_type == 13) {
615 $squads = acl_get_squads();
617 foreach ($squads as $key => $value) {
618 if ($currvalue == $key) {
623 if (empty($tmp)) $tmp = "($currvalue)";
625 /*****************************************************************
626 echo "<input type='text'" .
627 " size='$fld_length'" .
631 *****************************************************************/
632 if ($tmp === '') $tmp = ' ';
637 else if ($data_type == 14) {
640 $urow = sqlQuery("SELECT fname, lname, specialty FROM users " .
641 "WHERE id = '$currvalue'");
642 $uname = $urow['lname'];
643 if ($urow['fname']) $uname .= ", " . $urow['fname'];
645 if (empty($tmp)) $tmp = "($currvalue)";
647 /*****************************************************************
648 echo "<input type='text'" .
649 " size='$fld_length'" .
653 *****************************************************************/
654 if ($tmp === '') $tmp = ' ';
658 // a set of labeled checkboxes
659 else if ($data_type == 21) {
660 // In this special case, fld_length is the number of columns generated.
661 $cols = max(1, $fld_length);
662 $avalue = explode('|', $currvalue);
663 $lres = sqlStatement("SELECT * FROM list_options " .
664 "WHERE list_id = '$list_id' ORDER BY seq, title");
665 echo "<table cellpadding='0' cellspacing='0' width='100%'>";
666 $tdpct = (int) (100 / $cols);
667 for ($count = 0; $lrow = sqlFetchArray($lres); ++
$count) {
668 $option_id = $lrow['option_id'];
669 if ($count %
$cols == 0) {
670 if ($count) echo "</tr>";
673 echo "<td width='$tdpct%'>";
674 echo "<input type='checkbox'";
675 if (in_array($option_id, $avalue)) echo " checked";
676 echo ">" . xl_list_label($lrow['title']);
681 if ($count > $cols) {
682 // Add some space after multiple rows of checkboxes.
683 echo "<tr><td colspan='$cols' style='height:0.7em'></td></tr>";
689 // a set of labeled text input fields
690 else if ($data_type == 22) {
691 $tmp = explode('|', $currvalue);
693 foreach ($tmp as $value) {
694 if (preg_match('/^([^:]+):(.*)$/', $value, $matches)) {
695 $avalue[$matches[1]] = $matches[2];
698 $lres = sqlStatement("SELECT * FROM list_options " .
699 "WHERE list_id = '$list_id' ORDER BY seq, title");
700 echo "<table cellpadding='0' cellspacing='0'>";
701 while ($lrow = sqlFetchArray($lres)) {
702 $option_id = $lrow['option_id'];
703 $maxlength = empty($frow['max_length']) ?
255 : $frow['max_length'];
704 $fldlength = empty($fld_length) ?
20 : $fld_length;
705 echo "<tr><td>" . xl_list_label($lrow['title']) . " </td>";
706 echo "<td><input type='text'" .
707 " size='$fldlength'" .
708 " value='" . $avalue[$option_id] . "'" .
715 // a set of exam results; 3 radio buttons and a text field:
716 else if ($data_type == 23) {
717 $tmp = explode('|', $currvalue);
719 foreach ($tmp as $value) {
720 if (preg_match('/^([^:]+):(.*)$/', $value, $matches)) {
721 $avalue[$matches[1]] = $matches[2];
724 $maxlength = empty($frow['max_length']) ?
255 : $frow['max_length'];
725 $fldlength = empty($fld_length) ?
20 : $fld_length;
726 $lres = sqlStatement("SELECT * FROM list_options " .
727 "WHERE list_id = '$list_id' ORDER BY seq, title");
728 echo "<table cellpadding='0' cellspacing='0'>";
729 echo "<tr><td> </td><td class='bold'>" . xl('N/A') .
730 " </td><td class='bold'>" . xl('Nor') . " </td>" .
731 "<td class='bold'>" . xl('Abn') . " </td><td class='bold'>" .
732 xl('Date/Notes') . "</td></tr>";
733 while ($lrow = sqlFetchArray($lres)) {
734 $option_id = $lrow['option_id'];
735 $restype = substr($avalue[$option_id], 0, 1);
736 $resnote = substr($avalue[$option_id], 2);
737 echo "<tr><td>" . xl_list_label($lrow['title']) . " </td>";
738 for ($i = 0; $i < 3; ++
$i) {
739 echo "<td><input type='radio'";
740 if ($restype === "$i") echo " checked";
743 echo "<td><input type='text'" .
744 " size='$fldlength'" .
745 " value='$resnote'" .
746 " class='under' /></td>" .
752 // the list of active allergies for the current patient
753 // this is read-only!
754 else if ($data_type == 24) {
755 $query = "SELECT title, comments FROM lists WHERE " .
756 "pid = '" . $GLOBALS['pid'] . "' AND type = 'allergy' AND enddate IS NULL " .
758 $lres = sqlStatement($query);
760 while ($lrow = sqlFetchArray($lres)) {
761 if ($count++
) echo "<br />";
763 if ($lrow['comments']) echo ' (' . $lrow['comments'] . ')';
767 // a set of labeled checkboxes, each with a text field:
768 else if ($data_type == 25) {
769 $tmp = explode('|', $currvalue);
771 foreach ($tmp as $value) {
772 if (preg_match('/^([^:]+):(.*)$/', $value, $matches)) {
773 $avalue[$matches[1]] = $matches[2];
776 $maxlength = empty($frow['max_length']) ?
255 : $frow['max_length'];
777 $fldlength = empty($fld_length) ?
20 : $fld_length;
778 $lres = sqlStatement("SELECT * FROM list_options " .
779 "WHERE list_id = '$list_id' ORDER BY seq, title");
780 echo "<table cellpadding='0' cellspacing='0'>";
781 while ($lrow = sqlFetchArray($lres)) {
782 $option_id = $lrow['option_id'];
783 $restype = substr($avalue[$option_id], 0, 1);
784 $resnote = substr($avalue[$option_id], 2);
785 echo "<tr><td>" . xl_list_label($lrow['title']) . " </td>";
786 echo "<td><input type='checkbox'";
787 if ($restype) echo " checked";
788 echo " /> </td>";
789 echo "<td><input type='text'" .
790 " size='$fldlength'" .
791 " value='$resnote'" .
799 // a set of labeled radio buttons
800 else if ($data_type == 27) {
801 // In this special case, fld_length is the number of columns generated.
802 $cols = max(1, $frow['fld_length']);
803 $lres = sqlStatement("SELECT * FROM list_options " .
804 "WHERE list_id = '$list_id' ORDER BY seq, title");
805 echo "<table cellpadding='0' cellspacing='0' width='100%'>";
806 $tdpct = (int) (100 / $cols);
807 for ($count = 0; $lrow = sqlFetchArray($lres); ++
$count) {
808 $option_id = $lrow['option_id'];
809 if ($count %
$cols == 0) {
810 if ($count) echo "</tr>";
813 echo "<td width='$tdpct%'>";
814 echo "<input type='radio'";
815 if ((strlen($currvalue) == 0 && $lrow['is_default']) ||
816 (strlen($currvalue) > 0 && $option_id == $currvalue))
820 echo ">" . xl_list_label($lrow['title']);
825 if ($count > $cols) {
826 // Add some space after multiple rows of radio buttons.
827 echo "<tr><td colspan='$cols' style='height:0.7em'></td></tr>";
835 function generate_display_field($frow, $currvalue) {
836 $data_type = $frow['data_type'];
837 $field_id = $frow['field_id'];
838 $list_id = $frow['list_id'];
841 // generic selection list or the generic selection list with add on the fly
842 // feature, or radio buttons
843 if ($data_type == 1 ||
$data_type == 26 ||
$data_type == 27) {
844 $lrow = sqlQuery("SELECT title FROM list_options " .
845 "WHERE list_id = '$list_id' AND option_id = '$currvalue'");
846 $s = xl_list_label($lrow['title']);
850 else if ($data_type == 2) {
854 // long or multi-line text field
855 else if ($data_type == 3) {
856 $s = nl2br($currvalue);
860 else if ($data_type == 4) {
865 else if ($data_type == 10 ||
$data_type == 11) {
866 $urow = sqlQuery("SELECT fname, lname, specialty FROM users " .
867 "WHERE id = '$currvalue'");
868 $s = ucwords($urow['fname'] . " " . $urow['lname']);
872 else if ($data_type == 12) {
873 $pres = get_pharmacies();
874 while ($prow = sqlFetchArray($pres)) {
876 if ($currvalue == $key) {
877 $s .= $prow['name'] . ' ' . $prow['area_code'] . '-' .
878 $prow['prefix'] . '-' . $prow['number'] . ' / ' .
879 $prow['line1'] . ' / ' . $prow['city'];
885 else if ($data_type == 13) {
886 $squads = acl_get_squads();
888 foreach ($squads as $key => $value) {
889 if ($currvalue == $key) {
897 else if ($data_type == 14) {
898 $urow = sqlQuery("SELECT fname, lname, specialty FROM users " .
899 "WHERE id = '$currvalue'");
900 $uname = $urow['lname'];
901 if ($urow['fname']) $uname .= ", " . $urow['fname'];
906 else if ($data_type == 15) {
910 // a set of labeled checkboxes
911 else if ($data_type == 21) {
912 $avalue = explode('|', $currvalue);
913 $lres = sqlStatement("SELECT * FROM list_options " .
914 "WHERE list_id = '$list_id' ORDER BY seq, title");
916 while ($lrow = sqlFetchArray($lres)) {
917 $option_id = $lrow['option_id'];
918 if (in_array($option_id, $avalue)) {
919 if ($count++
) $s .= "<br />";
921 // Added 5-09 by BM - Translate label if applicable
922 $s .= xl_list_label($lrow['title']);
928 // a set of labeled text input fields
929 else if ($data_type == 22) {
930 $tmp = explode('|', $currvalue);
932 foreach ($tmp as $value) {
933 if (preg_match('/^([^:]+):(.*)$/', $value, $matches)) {
934 $avalue[$matches[1]] = $matches[2];
937 $lres = sqlStatement("SELECT * FROM list_options " .
938 "WHERE list_id = '$list_id' ORDER BY seq, title");
939 $s .= "<table cellpadding='0' cellspacing='0'>";
940 while ($lrow = sqlFetchArray($lres)) {
941 $option_id = $lrow['option_id'];
942 if (empty($avalue[$option_id])) continue;
944 // Added 5-09 by BM - Translate label if applicable
945 $s .= "<tr><td class='bold' valign='top'>" . xl_list_label($lrow['title']) . ": </td>";
947 $s .= "<td class='text' valign='top'>" . $avalue[$option_id] . "</td></tr>";
952 // a set of exam results; 3 radio buttons and a text field:
953 else if ($data_type == 23) {
954 $tmp = explode('|', $currvalue);
956 foreach ($tmp as $value) {
957 if (preg_match('/^([^:]+):(.*)$/', $value, $matches)) {
958 $avalue[$matches[1]] = $matches[2];
961 $lres = sqlStatement("SELECT * FROM list_options " .
962 "WHERE list_id = '$list_id' ORDER BY seq, title");
963 $s .= "<table cellpadding='0' cellspacing='0'>";
964 while ($lrow = sqlFetchArray($lres)) {
965 $option_id = $lrow['option_id'];
966 $restype = substr($avalue[$option_id], 0, 1);
967 $resnote = substr($avalue[$option_id], 2);
968 if (empty($restype) && empty($resnote)) continue;
970 // Added 5-09 by BM - Translate label if applicable
971 $s .= "<tr><td class='bold' valign='top'>" . xl_list_label($lrow['title']) . " </td>";
973 $restype = ($restype == '1') ?
xl('Normal') : (($restype == '2') ?
xl('Abnormal') : xl('N/A'));
974 // $s .= "<td class='text' valign='top'>$restype</td></tr>";
975 // $s .= "<td class='text' valign='top'>$resnote</td></tr>";
976 $s .= "<td class='text' valign='top'>$restype </td>";
977 $s .= "<td class='text' valign='top'>$resnote</td>";
983 // the list of active allergies for the current patient
984 else if ($data_type == 24) {
985 $query = "SELECT title, comments FROM lists WHERE " .
986 "pid = '" . $GLOBALS['pid'] . "' AND type = 'allergy' AND enddate IS NULL " .
988 // echo "<!-- $query -->\n"; // debugging
989 $lres = sqlStatement($query);
991 while ($lrow = sqlFetchArray($lres)) {
992 if ($count++
) $s .= "<br />";
993 $s .= $lrow['title'];
994 if ($lrow['comments']) $s .= ' (' . $lrow['comments'] . ')';
998 // a set of labeled checkboxes, each with a text field:
999 else if ($data_type == 25) {
1000 $tmp = explode('|', $currvalue);
1002 foreach ($tmp as $value) {
1003 if (preg_match('/^([^:]+):(.*)$/', $value, $matches)) {
1004 $avalue[$matches[1]] = $matches[2];
1007 $lres = sqlStatement("SELECT * FROM list_options " .
1008 "WHERE list_id = '$list_id' ORDER BY seq, title");
1009 $s .= "<table cellpadding='0' cellspacing='0'>";
1010 while ($lrow = sqlFetchArray($lres)) {
1011 $option_id = $lrow['option_id'];
1012 $restype = substr($avalue[$option_id], 0, 1);
1013 $resnote = substr($avalue[$option_id], 2);
1014 if (empty($restype) && empty($resnote)) continue;
1016 // Added 5-09 by BM - Translate label if applicable
1017 $s .= "<tr><td class='bold' valign='top'>" . xl_list_label($lrow['title']) . " </td>";
1019 $restype = $restype ?
xl('Yes') : xl('No');
1020 $s .= "<td class='text' valign='top'>$restype</td></tr>";
1021 $s .= "<td class='text' valign='top'>$resnote</td></tr>";
1030 $CPR = 4; // cells per row of generic data
1035 function disp_end_cell() {
1036 global $item_count, $cell_count;
1037 if ($item_count > 0) {
1043 function disp_end_row() {
1044 global $cell_count, $CPR;
1046 if ($cell_count > 0) {
1047 for (; $cell_count < $CPR; ++
$cell_count) echo "<td></td>";
1053 function disp_end_group() {
1055 if (strlen($last_group) > 0) {
1060 function display_layout_rows($formtype, $result1, $result2='') {
1061 global $item_count, $cell_count, $last_group, $CPR;
1063 $fres = sqlStatement("SELECT * FROM layout_options " .
1064 "WHERE form_id = '$formtype' AND uor > 0 " .
1065 "ORDER BY group_name, seq");
1067 while ($frow = sqlFetchArray($fres)) {
1068 $this_group = $frow['group_name'];
1069 $titlecols = $frow['titlecols'];
1070 $datacols = $frow['datacols'];
1071 $data_type = $frow['data_type'];
1072 $field_id = $frow['field_id'];
1073 $list_id = $frow['list_id'];
1076 if ($formtype == 'DEM') {
1077 if ($GLOBALS['athletic_team']) {
1078 // Skip fitness level and return-to-play date because those appear
1079 // in a special display/update form on this page.
1080 if ($field_id === 'fitness' ||
$field_id === 'userdate1') continue;
1082 if (strpos($field_id, 'em_') === 0) {
1083 // Skip employer related fields, if it's disabled.
1084 if ($GLOBALS['omit_employers']) continue;
1085 $tmp = substr($field_id, 3);
1086 if (isset($result2[$tmp])) $currvalue = $result2[$tmp];
1089 if (isset($result1[$field_id])) $currvalue = $result1[$field_id];
1093 if (isset($result1[$field_id])) $currvalue = $result1[$field_id];
1096 // Handle a data category (group) change.
1097 if (strcmp($this_group, $last_group) != 0) {
1098 $group_name = substr($this_group, 1);
1099 // totally skip generating the employer category, if it's disabled.
1100 if ($group_name === 'Employer' && $GLOBALS['omit_employers']) continue;
1102 $last_group = $this_group;
1105 // Handle starting of a new row.
1106 if (($titlecols > 0 && $cell_count >= $CPR) ||
$cell_count == 0) {
1110 echo "<td class='groupname'>";
1111 //echo "<td class='groupname' style='padding-right:5pt' valign='top'>";
1112 //echo "<font color='#008800'>$group_name</font>";
1114 // Added 5-09 by BM - Translate label if applicable
1115 echo (xl_layout_label($group_name));
1119 //echo "<td class='' style='padding-right:5pt' valign='top'>";
1120 echo "<td valign='top'> ";
1125 if ($item_count == 0 && $titlecols == 0) $titlecols = 1;
1127 // Handle starting of a new label cell.
1128 if ($titlecols > 0) {
1130 //echo "<td class='label' colspan='$titlecols' valign='top'";
1131 echo "<td class='label' colspan='$titlecols' ";
1132 //if ($cell_count == 2) echo " style='padding-left:10pt'";
1134 $cell_count +
= $titlecols;
1138 // Added 5-09 by BM - Translate label if applicable
1139 if ($frow['title']) echo (xl_layout_label($frow['title']).":"); else echo " ";
1141 // Handle starting of a new data cell.
1142 if ($datacols > 0) {
1144 //echo "<td class='text data' colspan='$datacols' valign='top'";
1145 echo "<td class='text data' colspan='$datacols'";
1146 //if ($cell_count > 0) echo " style='padding-left:5pt'";
1148 $cell_count +
= $datacols;
1152 echo generate_display_field($frow, $currvalue);
1158 function display_layout_tabs($formtype, $result1, $result2='') {
1159 global $item_count, $cell_count, $last_group, $CPR;
1161 $fres = sqlStatement("SELECT distinct group_name FROM layout_options " .
1162 "WHERE form_id = '$formtype' AND uor > 0 " .
1163 "ORDER BY group_name, seq");
1166 while ($frow = sqlFetchArray($fres)) {
1167 $this_group = $frow['group_name'];
1168 $group_name = substr($this_group, 1);
1170 <li
<?php
echo $first ?
'class="current"' : '' ?
>>
1171 <a href
="/play/javascript-tabbed-navigation/" id
="header_tab_<?php echo $group_name?>"><?php
echo xl_layout_label($group_name); ?
></a
>
1178 function display_layout_tabs_data($formtype, $result1, $result2='') {
1179 global $item_count, $cell_count, $last_group, $CPR;
1181 $fres = sqlStatement("SELECT distinct group_name FROM layout_options " .
1182 "WHERE form_id = '$formtype' AND uor > 0 " .
1183 "ORDER BY group_name, seq");
1186 while ($frow = sqlFetchArray($fres)) {
1187 $this_group = $frow['group_name'];
1188 $titlecols = $frow['titlecols'];
1189 $datacols = $frow['datacols'];
1190 $data_type = $frow['data_type'];
1191 $field_id = $frow['field_id'];
1192 $list_id = $frow['list_id'];
1195 $group_fields_query = sqlStatement("SELECT * FROM layout_options " .
1196 "WHERE form_id = '$formtype' AND uor > 0 AND group_name = '$this_group' " .
1200 <div
class="tab <?php echo $first ? 'current' : '' ?>">
1201 <table border
='0' cellpadding
='0'>
1204 while ($group_fields = sqlFetchArray($group_fields_query)) {
1206 $titlecols = $group_fields['titlecols'];
1207 $datacols = $group_fields['datacols'];
1208 $data_type = $group_fields['data_type'];
1209 $field_id = $group_fields['field_id'];
1210 $list_id = $group_fields['list_id'];
1213 if ($formtype == 'DEM') {
1214 if ($GLOBALS['athletic_team']) {
1215 // Skip fitness level and return-to-play date because those appear
1216 // in a special display/update form on this page.
1217 if ($field_id === 'fitness' ||
$field_id === 'userdate1') continue;
1219 if (strpos($field_id, 'em_') === 0) {
1220 // Skip employer related fields, if it's disabled.
1221 if ($GLOBALS['omit_employers']) continue;
1222 $tmp = substr($field_id, 3);
1223 if (isset($result2[$tmp])) $currvalue = $result2[$tmp];
1226 if (isset($result1[$field_id])) $currvalue = $result1[$field_id];
1230 if (isset($result1[$field_id])) $currvalue = $result1[$field_id];
1233 // Handle a data category (group) change.
1234 if (strcmp($this_group, $last_group) != 0) {
1235 $group_name = substr($this_group, 1);
1236 // totally skip generating the employer category, if it's disabled.
1237 if ($group_name === 'Employer' && $GLOBALS['omit_employers']) continue;
1238 $last_group = $this_group;
1241 // Handle starting of a new row.
1242 if (($titlecols > 0 && $cell_count >= $CPR) ||
$cell_count == 0) {
1247 if ($item_count == 0 && $titlecols == 0) {
1251 // Handle starting of a new label cell.
1252 if ($titlecols > 0) {
1254 echo "<td class='label' colspan='$titlecols' ";
1256 $cell_count +
= $titlecols;
1260 // Added 5-09 by BM - Translate label if applicable
1261 if ($group_fields['title']) echo (xl_layout_label($group_fields['title']).":"); else echo " ";
1263 // Handle starting of a new data cell.
1264 if ($datacols > 0) {
1266 echo "<td class='text data' colspan='$datacols'";
1268 $cell_count +
= $datacols;
1272 echo generate_display_field($group_fields, $currvalue);
1287 function display_layout_tabs_data_editable($formtype, $result1, $result2='') {
1288 global $item_count, $cell_count, $last_group, $CPR;
1290 $fres = sqlStatement("SELECT distinct group_name FROM layout_options " .
1291 "WHERE form_id = '$formtype' AND uor > 0 " .
1292 "ORDER BY group_name, seq");
1295 while ($frow = sqlFetchArray($fres)) {
1296 $this_group = $frow['group_name'];
1297 $group_name = substr($this_group, 1);
1298 $titlecols = $frow['titlecols'];
1299 $datacols = $frow['datacols'];
1300 $data_type = $frow['data_type'];
1301 $field_id = $frow['field_id'];
1302 $list_id = $frow['list_id'];
1305 $group_fields_query = sqlStatement("SELECT * FROM layout_options " .
1306 "WHERE form_id = '$formtype' AND uor > 0 AND group_name = '$this_group' " .
1310 <div
class="tab <?php echo $first ? 'current' : '' ?>" id
="tab_<?php echo $group_name?>" >
1311 <table border
='0' cellpadding
='0'>
1314 while ($group_fields = sqlFetchArray($group_fields_query)) {
1316 $titlecols = $group_fields['titlecols'];
1317 $datacols = $group_fields['datacols'];
1318 $data_type = $group_fields['data_type'];
1319 $field_id = $group_fields['field_id'];
1320 $list_id = $group_fields['list_id'];
1323 if ($formtype == 'DEM') {
1324 if ($GLOBALS['athletic_team']) {
1325 // Skip fitness level and return-to-play date because those appear
1326 // in a special display/update form on this page.
1327 if ($field_id === 'fitness' ||
$field_id === 'userdate1') continue;
1329 if (strpos($field_id, 'em_') === 0) {
1330 // Skip employer related fields, if it's disabled.
1331 if ($GLOBALS['omit_employers']) continue;
1332 $tmp = substr($field_id, 3);
1333 if (isset($result2[$tmp])) $currvalue = $result2[$tmp];
1336 if (isset($result1[$field_id])) $currvalue = $result1[$field_id];
1340 if (isset($result1[$field_id])) $currvalue = $result1[$field_id];
1343 // Handle a data category (group) change.
1344 if (strcmp($this_group, $last_group) != 0) {
1345 $group_name = substr($this_group, 1);
1346 // totally skip generating the employer category, if it's disabled.
1347 if ($group_name === 'Employer' && $GLOBALS['omit_employers']) continue;
1348 $last_group = $this_group;
1351 // Handle starting of a new row.
1352 if (($titlecols > 0 && $cell_count >= $CPR) ||
$cell_count == 0) {
1357 if ($item_count == 0 && $titlecols == 0) {
1361 // Handle starting of a new label cell.
1362 if ($titlecols > 0) {
1364 echo "<td class='label' colspan='$titlecols' ";
1366 $cell_count +
= $titlecols;
1370 // Added 5-09 by BM - Translate label if applicable
1371 if ($group_fields['title']) echo (xl_layout_label($group_fields['title']).":"); else echo " ";
1373 // Handle starting of a new data cell.
1374 if ($datacols > 0) {
1376 echo "<td class='text data' colspan='$datacols'";
1378 $cell_count +
= $datacols;
1382 echo generate_form_field($group_fields, $currvalue);
1396 // From the currently posted HTML form, this gets the value of the
1397 // field corresponding to the provided layout_options table row.
1399 function get_layout_form_value($frow, $maxlength=255) {
1400 $data_type = $frow['data_type'];
1401 $field_id = $frow['field_id'];
1403 if (isset($_POST["form_$field_id"])) {
1404 if ($data_type == 21) {
1405 // $_POST["form_$field_id"] is an array of checkboxes and its keys
1406 // must be concatenated into a |-separated string.
1407 foreach ($_POST["form_$field_id"] as $key => $val) {
1408 if (strlen($value)) $value .= '|';
1412 else if ($data_type == 22) {
1413 // $_POST["form_$field_id"] is an array of text fields to be imploded
1414 // into "key:value|key:value|...".
1415 foreach ($_POST["form_$field_id"] as $key => $val) {
1416 $val = str_replace('|', ' ', $val);
1417 if (strlen($value)) $value .= '|';
1418 $value .= "$key:$val";
1421 else if ($data_type == 23) {
1422 // $_POST["form_$field_id"] is an array of text fields with companion
1423 // radio buttons to be imploded into "key:n:notes|key:n:notes|...".
1424 foreach ($_POST["form_$field_id"] as $key => $val) {
1425 $restype = $_POST["radio_{$field_id}"][$key];
1426 if (empty($restype)) $restype = '0';
1427 $val = str_replace('|', ' ', $val);
1428 if (strlen($value)) $value .= '|';
1429 $value .= "$key:$restype:$val";
1432 else if ($data_type == 25) {
1433 // $_POST["form_$field_id"] is an array of text fields with companion
1434 // checkboxes to be imploded into "key:n:notes|key:n:notes|...".
1435 foreach ($_POST["form_$field_id"] as $key => $val) {
1436 $restype = empty($_POST["check_{$field_id}"][$key]) ?
'0' : '1';
1437 $val = str_replace('|', ' ', $val);
1438 if (strlen($value)) $value .= '|';
1439 $value .= "$key:$restype:$val";
1443 $value = $_POST["form_$field_id"];
1447 // Better to die than to silently truncate data!
1448 if ($maxlength && $data_type != 3 && strlen($value) > $maxlength)
1449 die(xl('ERROR: Field') . " '$field_id' " . xl('is too long') .
1450 ":<br /> <br />$value");
1452 // Make sure the return value is quote-safe.
1453 return formTrim($value);
1456 // Generate JavaScript validation logic for the required fields.
1458 function generate_layout_validation($form_id) {
1459 $fres = sqlStatement("SELECT * FROM layout_options " .
1460 "WHERE form_id = '$form_id' AND uor > 0 AND field_id != '' " .
1461 "ORDER BY group_name, seq");
1463 while ($frow = sqlFetchArray($fres)) {
1464 if ($frow['uor'] < 2) continue;
1465 $data_type = $frow['data_type'];
1466 $field_id = $frow['field_id'];
1467 $fldtitle = $frow['title'];
1468 if (!$fldtitle) $fldtitle = $frow['description'];
1469 $fldname = "form_$field_id";
1470 switch($data_type) {
1478 " if (f.$fldname.selectedIndex <= 0) {\n" .
1479 " if (f.$fldname.focus) f.$fldname.focus();\n" .
1480 " errMsgs[errMsgs.length] = '". xl_layout_label($fldtitle) . "'; \n" .
1483 case 27: // radio buttons
1486 " for (; i < f.$fldname.length; ++i) if (f.$fldname[i].checked) break;\n" .
1487 " if (i >= f.$fldname.length) {\n" .
1488 " errMsgs[errMsgs.length] = '". xl_layout_label($fldtitle) . "'; \n" .
1496 " if (trimlen(f.$fldname.value) == 0) {\n" .
1497 " if (f.$fldname.focus) f.$fldname.focus();\n" .
1498 " $('#form_" . $field_id . "').parents('div.tab').each( function(){ var tabHeader = $('#header_' + $(this).attr('id') ); tabHeader.css('color','red'); } ); " .
1499 " $('#form_" . $field_id . "').attr('style','background:red'); \n" .
1500 " errMsgs[errMsgs.length] = '". xl_layout_label($fldtitle) . "'; \n" .
1502 " $('#form_" . $field_id . "').attr('style',''); " .
1503 " $('#form_" . $field_id . "').parents('div.tab').each( function(){ var tabHeader = $('#header_' + $(this).attr('id') ); tabHeader.css('color',''); } ); " .