script to install and configure cvs demo
[openemr.git] / library / options.inc.php
blob4960bf1fa1fcfef0e80f8a8dc363ee19ed20394c
1 <?php
3 $date_init = "";
5 function get_pharmacies() {
6 return sqlStatement("SELECT d.id, d.name, a.line1, a.city, " .
7 "p.area_code, p.prefix, p.number FROM pharmacies AS d " .
8 "LEFT OUTER JOIN addresses AS a ON a.foreign_id = d.id " .
9 "LEFT OUTER JOIN phone_numbers AS p ON p.foreign_id = d.id " .
10 "AND p.type = 2 " .
11 "ORDER BY name, area_code, prefix, number");
14 function generate_form_field($frow, $currvalue) {
15 global $rootdir, $date_init;
17 $currescaped = htmlspecialchars($currvalue, ENT_QUOTES);
19 $data_type = $frow['data_type'];
20 $field_id = $frow['field_id'];
21 $list_id = $frow['list_id'];
22 $description = htmlspecialchars($frow['description'], ENT_QUOTES);
24 // generic single-selection list
25 if ($data_type == 1) {
26 echo "<select name='form_$field_id' title='$description'>";
27 echo "<option value=''>" . xl('Unassigned') . "</option>";
28 $lres = sqlStatement("SELECT * FROM list_options " .
29 "WHERE list_id = '$list_id' ORDER BY seq");
30 $got_selected = FALSE;
31 while ($lrow = sqlFetchArray($lres)) {
32 echo "<option value='" . $lrow['option_id'] . "'";
33 if ((strlen($currvalue) == 0 && $lrow['is_default']) ||
34 (strlen($currvalue) > 0 && $lrow['option_id'] == $currvalue))
36 echo " selected";
37 $got_selected = TRUE;
39 echo ">" . $lrow['title'] . "</option>\n";
41 if (!$got_selected && strlen($currvalue) > 0) {
42 echo "<option value='$currescaped' selected>* $currescaped *</option>";
43 echo "</select>";
44 echo " <font color='red' title='Please choose a valid selection " .
45 "from the list'>Fix this!</font>";
47 else {
48 echo "</select>";
52 // simple text field
53 else if ($data_type == 2) {
54 echo "<input type='text'" .
55 " name='form_$field_id'" .
56 " size='" . $frow['fld_length'] . "'" .
57 " maxlength='" . $frow['max_length'] . "'" .
58 " title='$description'" .
59 " value='$currescaped'";
60 if (strpos($frow['edit_options'], 'C') !== FALSE)
61 echo " onchange='capitalizeMe(this)'";
62 echo " />";
65 // long or multi-line text field
66 else if ($data_type == 3) {
67 echo "<textarea" .
68 " name='form_$field_id'" .
69 " title='$description'" .
70 " cols='" . $frow['fld_length'] . "'" .
71 " rows='" . $frow['max_length'] . "'>" .
72 $currescaped . "</textarea>";
75 // date
76 else if ($data_type == 4) {
77 echo "<input type='text' size='10' name='form_$field_id' id='form_$field_id'" .
78 " value='$currescaped'" .
79 " title='$description'" .
80 " onkeyup='datekeyup(this,mypcc)' onblur='dateblur(this,mypcc)' />" .
81 "<img src='$rootdir/pic/show_calendar.gif' align='absbottom' width='24' height='22'" .
82 " id='img_$field_id' border='0' alt='[?]' style='cursor:pointer'" .
83 " title='" . xl('Click here to choose a date') . "' />";
84 $date_init .= " Calendar.setup({inputField:'form_$field_id', ifFormat:'%Y-%m-%d', button:'img_$field_id'});\n";
87 // provider list, local providers only
88 else if ($data_type == 10) {
89 $ures = sqlStatement("SELECT id, fname, lname, specialty FROM users " .
90 "WHERE active = 1 AND ( info IS NULL OR info NOT LIKE '%Inactive%' ) " .
91 "AND authorized = 1 " .
92 "ORDER BY lname, fname");
93 echo "<select name='form_$field_id' title='$description'>";
94 echo "<option value=''>" . xl('Unassigned') . "</option>";
95 while ($urow = sqlFetchArray($ures)) {
96 $uname = $urow['fname'] . ' ' . $urow['lname'];
97 echo "<option value='" . $urow['id'] . "'";
98 if ($urow['id'] == $currvalue) echo " selected";
99 echo ">$uname</option>";
101 echo "</select>";
104 // provider list, including address book entries with an NPI number
105 else if ($data_type == 11) {
106 $ures = sqlStatement("SELECT id, fname, lname, specialty FROM users " .
107 "WHERE active = 1 AND ( info IS NULL OR info NOT LIKE '%Inactive%' ) " .
108 "AND ( authorized = 1 OR ( username = '' AND npi != '' ) ) " .
109 "ORDER BY lname, fname");
110 echo "<select name='form_$field_id' title='$description'>";
111 echo "<option value=''>" . xl('Unassigned') . "</option>";
112 while ($urow = sqlFetchArray($ures)) {
113 $uname = $urow['fname'] . ' ' . $urow['lname'];
114 echo "<option value='" . $urow['id'] . "'";
115 if ($urow['id'] == $currvalue) echo " selected";
116 echo ">$uname</option>";
118 echo "</select>";
121 // pharmacy list
122 else if ($data_type == 12) {
123 echo "<select name='form_$field_id' title='$description'>";
124 echo "<option value='0'></option>";
125 $pres = get_pharmacies();
126 while ($prow = sqlFetchArray($pres)) {
127 $key = $prow['id'];
128 echo "<option value='$key'";
129 if ($currvalue == $key) echo " selected";
130 echo '>' . $prow['name'] . ' ' . $prow['area_code'] . '-' .
131 $prow['prefix'] . '-' . $prow['number'] . ' / ' .
132 $prow['line1'] . ' / ' . $prow['city'] . "</option>";
134 echo "</select>";
137 // squads
138 else if ($data_type == 13) {
139 echo "<select name='form_$field_id' title='$description'>";
140 echo "<option value=''>&nbsp;</option>";
141 $squads = acl_get_squads();
142 if ($squads) {
143 foreach ($squads as $key => $value) {
144 echo "<option value='$key'";
145 if ($currvalue == $key) echo " selected";
146 echo ">" . $value[3] . "</option>\n";
149 echo "</select>";
152 // address book, preferring organization name if it exists and is not in parentheses
153 else if ($data_type == 14) {
154 $ures = sqlStatement("SELECT id, fname, lname, organization FROM users " .
155 "WHERE active = 1 AND ( info IS NULL OR info NOT LIKE '%Inactive%' ) " .
156 "ORDER BY organization, lname, fname");
157 echo "<select name='form_$field_id' title='$description'>";
158 echo "<option value=''>" . xl('Unassigned') . "</option>";
159 while ($urow = sqlFetchArray($ures)) {
160 $uname = $urow['organization'];
161 if (empty($uname) || substr($uname, 0, 1) == '(') {
162 $uname = $urow['lname'];
163 if ($urow['fname']) $uname .= ", " . $urow['fname'];
165 echo "<option value='" . $urow['id'] . "'";
166 if ($urow['id'] == $currvalue) echo " selected";
167 echo ">$uname</option>";
169 echo "</select>";
172 // a billing code (only one of these allowed!)
173 else if ($data_type == 15) {
174 echo "<input type='text'" .
175 " name='form_$field_id'" .
176 " id='form_related_code'" .
177 " size='" . $frow['fld_length'] . "'" .
178 " maxlength='" . $frow['max_length'] . "'" .
179 " title='$description'" .
180 " value='$currescaped'" .
181 " onclick='sel_related()' readonly" .
182 " />";
185 // a set of labeled checkboxes
186 else if ($data_type == 21) {
187 // In this special case, fld_length is the number of columns generated.
188 $cols = max(1, $frow['fld_length']);
189 $avalue = explode('|', $currvalue);
190 $lres = sqlStatement("SELECT * FROM list_options " .
191 "WHERE list_id = '$list_id' ORDER BY seq");
192 echo "<table cellpadding='0' cellspacing='0' width='100%'>";
193 $tdpct = (int) (100 / $cols);
194 for ($count = 0; $lrow = sqlFetchArray($lres); ++$count) {
195 $option_id = $lrow['option_id'];
196 // if ($count) echo "<br />";
197 if ($count % $cols == 0) {
198 if ($count) echo "</tr>";
199 echo "<tr>";
201 echo "<td width='$tdpct%'>";
202 echo "<input type='checkbox' name='form_{$field_id}[$option_id]' value='1'";
203 if (in_array($option_id, $avalue)) echo " checked";
204 echo ">" . $lrow['title'];
205 echo "</td>";
207 if ($count) {
208 echo "</tr>";
209 if ($count > $cols) {
210 // Add some space after multiple rows of checkboxes.
211 echo "<tr><td colspan='$cols' style='height:0.7em'></td></tr>";
214 echo "</table>";
217 // a set of labeled text input fields
218 else if ($data_type == 22) {
219 $tmp = explode('|', $currvalue);
220 $avalue = array();
221 foreach ($tmp as $value) {
222 if (preg_match('/^(\w+?):(.*)$/', $value, $matches)) {
223 $avalue[$matches[1]] = $matches[2];
226 $lres = sqlStatement("SELECT * FROM list_options " .
227 "WHERE list_id = '$list_id' ORDER BY seq");
228 echo "<table cellpadding='0' cellspacing='0'>";
229 while ($lrow = sqlFetchArray($lres)) {
230 $option_id = $lrow['option_id'];
231 $maxlength = empty($frow['max_length']) ? 255 : $frow['max_length'];
232 $fldlength = empty($frow['fld_length']) ? 20 : $frow['fld_length'];
233 echo "<tr><td>" . $lrow['title'] . "&nbsp;</td>";
234 echo "<td><input type='text'" .
235 " name='form_{$field_id}[$option_id]'" .
236 " size='$fldlength'" .
237 " maxlength='$maxlength'" .
238 " value='" . $avalue[$option_id] . "'";
239 echo " /></td></tr>";
241 echo "</table>";
244 // a set of exam results; 3 radio buttons and a text field:
245 else if ($data_type == 23) {
246 $tmp = explode('|', $currvalue);
247 $avalue = array();
248 foreach ($tmp as $value) {
249 if (preg_match('/^(\w+?):(.*)$/', $value, $matches)) {
250 $avalue[$matches[1]] = $matches[2];
253 $maxlength = empty($frow['max_length']) ? 255 : $frow['max_length'];
254 $fldlength = empty($frow['fld_length']) ? 20 : $frow['fld_length'];
255 $lres = sqlStatement("SELECT * FROM list_options " .
256 "WHERE list_id = '$list_id' ORDER BY seq");
257 echo "<table cellpadding='0' cellspacing='0'>";
258 echo "<tr><td>&nbsp;</td><td class='bold'>N/A&nbsp;</td><td class='bold'>Nor&nbsp;</td>" .
259 "<td class='bold'>Abn&nbsp;</td><td class='bold'>Date/Notes</td></tr>";
260 while ($lrow = sqlFetchArray($lres)) {
261 $option_id = $lrow['option_id'];
262 $restype = substr($avalue[$option_id], 0, 1);
263 $resnote = substr($avalue[$option_id], 2);
264 echo "<tr><td>" . $lrow['title'] . "&nbsp;</td>";
265 for ($i = 0; $i < 3; ++$i) {
266 echo "<td><input type='radio'" .
267 " name='radio_{$field_id}[$option_id]'" .
268 " value='$i'";
269 if ($restype === "$i") echo " checked";
270 echo " /></td>";
272 echo "<td><input type='text'" .
273 " name='form_{$field_id}[$option_id]'" .
274 " size='$fldlength'" .
275 " maxlength='$maxlength'" .
276 " value='$resnote' /></td>";
277 echo "</tr>";
279 echo "</table>";
282 // the list of active allergies for the current patient
283 // this is read-only!
284 else if ($data_type == 24) {
285 $query = "SELECT title, comments FROM lists WHERE " .
286 "pid = '" . $GLOBALS['pid'] . "' AND type = 'allergy' AND enddate IS NULL " .
287 "ORDER BY begdate";
288 // echo "<!-- $query -->\n"; // debugging
289 $lres = sqlStatement($query);
290 $count = 0;
291 while ($lrow = sqlFetchArray($lres)) {
292 if ($count++) echo "<br />";
293 echo $lrow['title'];
294 if ($lrow['comments']) echo ' (' . $lrow['comments'] . ')';
298 // a set of labeled checkboxes, each with a text field:
299 else if ($data_type == 25) {
300 $tmp = explode('|', $currvalue);
301 $avalue = array();
302 foreach ($tmp as $value) {
303 if (preg_match('/^(\w+?):(.*)$/', $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");
311 echo "<table cellpadding='0' cellspacing='0'>";
312 while ($lrow = sqlFetchArray($lres)) {
313 $option_id = $lrow['option_id'];
314 $restype = substr($avalue[$option_id], 0, 1);
315 $resnote = substr($avalue[$option_id], 2);
316 echo "<tr><td>" . $lrow['title'] . "&nbsp;</td>";
317 echo "<td><input type='checkbox' name='check_{$field_id}[$option_id]' value='1'";
318 if ($restype) echo " checked";
319 echo " />&nbsp;</td>";
320 echo "<td><input type='text'" .
321 " name='form_{$field_id}[$option_id]'" .
322 " size='$fldlength'" .
323 " maxlength='$maxlength'" .
324 " value='$resnote' /></td>";
325 echo "</tr>";
327 echo "</table>";
332 function generate_display_field($frow, $currvalue) {
333 $data_type = $frow['data_type'];
334 $field_id = $frow['field_id'];
335 $list_id = $frow['list_id'];
336 $s = '';
338 // generic selection list
339 if ($data_type == 1) {
340 $lrow = sqlQuery("SELECT title FROM list_options " .
341 "WHERE list_id = '$list_id' AND option_id = '$currvalue'");
342 $s = $lrow['title'];
345 // simple text field
346 else if ($data_type == 2) {
347 $s = $currvalue;
350 // long or multi-line text field
351 else if ($data_type == 3) {
352 $s = nl2br($currvalue);
355 // date
356 else if ($data_type == 4) {
357 $s = $currvalue;
360 // provider
361 else if ($data_type == 10 || $data_type == 11) {
362 $urow = sqlQuery("SELECT fname, lname, specialty FROM users " .
363 "WHERE id = '$currvalue'");
364 $s = ucwords($urow['fname'] . " " . $urow['lname']);
367 // pharmacy list
368 else if ($data_type == 12) {
369 $pres = get_pharmacies();
370 while ($prow = sqlFetchArray($pres)) {
371 $key = $prow['id'];
372 if ($currvalue == $key) {
373 $s .= $prow['name'] . ' ' . $prow['area_code'] . '-' .
374 $prow['prefix'] . '-' . $prow['number'] . ' / ' .
375 $prow['line1'] . ' / ' . $prow['city'];
380 // squads
381 else if ($data_type == 13) {
382 $squads = acl_get_squads();
383 if ($squads) {
384 foreach ($squads as $key => $value) {
385 if ($currvalue == $key) {
386 $s .= $value[3];
392 // address book
393 else if ($data_type == 14) {
394 $urow = sqlQuery("SELECT fname, lname, specialty FROM users " .
395 "WHERE id = '$currvalue'");
396 $uname = $urow['lname'];
397 if ($urow['fname']) $uname .= ", " . $urow['fname'];
398 $s = $uname;
401 // billing code
402 else if ($data_type == 15) {
403 $s = $currvalue;
406 // a set of labeled checkboxes
407 else if ($data_type == 21) {
408 $avalue = explode('|', $currvalue);
409 $lres = sqlStatement("SELECT * FROM list_options " .
410 "WHERE list_id = '$list_id' ORDER BY seq");
411 $count = 0;
412 while ($lrow = sqlFetchArray($lres)) {
413 $option_id = $lrow['option_id'];
414 if (in_array($option_id, $avalue)) {
415 if ($count++) $s .= "<br />";
416 $s .= $lrow['title'];
421 // a set of labeled text input fields
422 else if ($data_type == 22) {
423 $tmp = explode('|', $currvalue);
424 $avalue = array();
425 foreach ($tmp as $value) {
426 if (preg_match('/^(\w+?):(.*)$/', $value, $matches)) {
427 $avalue[$matches[1]] = $matches[2];
430 $lres = sqlStatement("SELECT * FROM list_options " .
431 "WHERE list_id = '$list_id' ORDER BY seq");
432 $s .= "<table cellpadding='0' cellspacing='0'>";
433 while ($lrow = sqlFetchArray($lres)) {
434 $option_id = $lrow['option_id'];
435 if (empty($avalue[$option_id])) continue;
436 $s .= "<tr><td class='bold' valign='top'>" . $lrow['title'] . ":&nbsp;</td>";
437 $s .= "<td class='text' valign='top'>" . $avalue[$option_id] . "</td></tr>";
439 $s .= "</table>";
442 // a set of exam results; 3 radio buttons and a text field:
443 else if ($data_type == 23) {
444 $tmp = explode('|', $currvalue);
445 $avalue = array();
446 foreach ($tmp as $value) {
447 if (preg_match('/^(\w+?):(.*)$/', $value, $matches)) {
448 $avalue[$matches[1]] = $matches[2];
451 $lres = sqlStatement("SELECT * FROM list_options " .
452 "WHERE list_id = '$list_id' ORDER BY seq");
453 $s .= "<table cellpadding='0' cellspacing='0'>";
454 while ($lrow = sqlFetchArray($lres)) {
455 $option_id = $lrow['option_id'];
456 $restype = substr($avalue[$option_id], 0, 1);
457 $resnote = substr($avalue[$option_id], 2);
458 if (empty($restype) && empty($resnote)) continue;
459 $s .= "<tr><td class='bold' valign='top'>" . $lrow['title'] . "&nbsp;</td>";
460 $restype = ($restype == '1') ? 'Normal' : (($restype == '2') ? 'Abnormal' : 'N/A');
461 $s .= "<td class='text' valign='top'>$restype</td></tr>";
462 $s .= "<td class='text' valign='top'>$resnote</td></tr>";
463 $s .= "</tr>";
465 $s .= "</table>";
468 // the list of active allergies for the current patient
469 else if ($data_type == 24) {
470 $query = "SELECT title, comments FROM lists WHERE " .
471 "pid = '" . $GLOBALS['pid'] . "' AND type = 'allergy' AND enddate IS NULL " .
472 "ORDER BY begdate";
473 // echo "<!-- $query -->\n"; // debugging
474 $lres = sqlStatement($query);
475 $count = 0;
476 while ($lrow = sqlFetchArray($lres)) {
477 if ($count++) $s .= "<br />";
478 $s .= $lrow['title'];
479 if ($lrow['comments']) $s .= ' (' . $lrow['comments'] . ')';
483 // a set of labeled checkboxes, each with a text field:
484 else if ($data_type == 25) {
485 $tmp = explode('|', $currvalue);
486 $avalue = array();
487 foreach ($tmp as $value) {
488 if (preg_match('/^(\w+?):(.*)$/', $value, $matches)) {
489 $avalue[$matches[1]] = $matches[2];
492 $lres = sqlStatement("SELECT * FROM list_options " .
493 "WHERE list_id = '$list_id' ORDER BY seq");
494 $s .= "<table cellpadding='0' cellspacing='0'>";
495 while ($lrow = sqlFetchArray($lres)) {
496 $option_id = $lrow['option_id'];
497 $restype = substr($avalue[$option_id], 0, 1);
498 $resnote = substr($avalue[$option_id], 2);
499 if (empty($restype) && empty($resnote)) continue;
500 $s .= "<tr><td class='bold' valign='top'>" . $lrow['title'] . "&nbsp;</td>";
501 $restype = $restype ? 'Yes' : 'No';
502 $s .= "<td class='text' valign='top'>$restype</td></tr>";
503 $s .= "<td class='text' valign='top'>$resnote</td></tr>";
504 $s .= "</tr>";
506 $s .= "</table>";
509 return $s;
512 $CPR = 4; // cells per row of generic data
513 $last_group = '';
514 $cell_count = 0;
515 $item_count = 0;
517 function disp_end_cell() {
518 global $item_count, $cell_count;
519 if ($item_count > 0) {
520 echo "</td>";
521 $item_count = 0;
525 function disp_end_row() {
526 global $cell_count, $CPR;
527 disp_end_cell();
528 if ($cell_count > 0) {
529 for (; $cell_count < $CPR; ++$cell_count) echo "<td></td>";
530 echo "</tr>\n";
531 $cell_count = 0;
535 function disp_end_group() {
536 global $last_group;
537 if (strlen($last_group) > 0) {
538 disp_end_row();
542 function display_layout_rows($formtype, $result1, $result2='') {
543 global $item_count, $cell_count, $last_group, $CPR;
545 $fres = sqlStatement("SELECT * FROM layout_options " .
546 "WHERE form_id = '$formtype' AND uor > 0 " .
547 "ORDER BY group_name, seq");
549 while ($frow = sqlFetchArray($fres)) {
550 $this_group = $frow['group_name'];
551 $titlecols = $frow['titlecols'];
552 $datacols = $frow['datacols'];
553 $data_type = $frow['data_type'];
554 $field_id = $frow['field_id'];
555 $list_id = $frow['list_id'];
556 $currvalue = '';
558 if ($formtype == 'DEM') {
559 if ($GLOBALS['athletic_team']) {
560 // Skip fitness level and return-to-play date because those appear
561 // in a special display/update form on this page.
562 if ($field_id === 'fitness' || $field_id === 'userdate1') continue;
564 if (strpos($field_id, 'em_') === 0) {
565 $tmp = substr($field_id, 3);
566 if (isset($result2[$tmp])) $currvalue = $result2[$tmp];
568 else {
569 if (isset($result1[$field_id])) $currvalue = $result1[$field_id];
572 else {
573 if (isset($result1[$field_id])) $currvalue = $result1[$field_id];
576 // Handle a data category (group) change.
577 if (strcmp($this_group, $last_group) != 0) {
578 disp_end_group();
579 $group_name = substr($this_group, 1);
580 $last_group = $this_group;
583 // Handle starting of a new row.
584 if (($titlecols > 0 && $cell_count >= $CPR) || $cell_count == 0) {
585 disp_end_row();
586 echo "<tr>";
587 if ($group_name) {
588 echo "<td class='groupname'>";
589 //echo "<td class='groupname' style='padding-right:5pt' valign='top'>";
590 //echo "<font color='#008800'>$group_name</font>";
591 echo $group_name;
592 $group_name = '';
593 } else {
594 //echo "<td class='' style='padding-right:5pt' valign='top'>";
595 echo '<td>&nbsp;';
597 echo "</td>";
600 if ($item_count == 0 && $titlecols == 0) $titlecols = 1;
602 // Handle starting of a new label cell.
603 if ($titlecols > 0) {
604 disp_end_cell();
605 //echo "<td class='label' colspan='$titlecols' valign='top'";
606 echo "<td class='label' colspan='$titlecols' ";
607 //if ($cell_count == 2) echo " style='padding-left:10pt'";
608 echo ">";
609 $cell_count += $titlecols;
611 ++$item_count;
613 if ($frow['title']) echo $frow['title'] . ":"; else echo "&nbsp;";
615 // Handle starting of a new data cell.
616 if ($datacols > 0) {
617 disp_end_cell();
618 //echo "<td class='text data' colspan='$datacols' valign='top'";
619 echo "<td class='text data' colspan='$datacols'";
620 //if ($cell_count > 0) echo " style='padding-left:5pt'";
621 echo ">";
622 $cell_count += $datacols;
625 ++$item_count;
626 echo generate_display_field($frow, $currvalue);
629 disp_end_group();
632 // From the currently posted HTML form, this gets the value of the
633 // field corresponding to the provided layout_options table row.
635 function get_layout_form_value($frow) {
636 $data_type = $frow['data_type'];
637 $field_id = $frow['field_id'];
638 $value = '';
639 if (isset($_POST["form_$field_id"])) {
640 if ($data_type == 21) {
641 // $_POST["form_$field_id"] is an array of checkboxes and its keys
642 // must be concatenated into a |-separated string.
643 foreach ($_POST["form_$field_id"] as $key => $val) {
644 if (strlen($value)) $value .= '|';
645 $value .= $key;
648 else if ($data_type == 22) {
649 // $_POST["form_$field_id"] is an array of text fields to be imploded
650 // into "key:value|key:value|...".
651 foreach ($_POST["form_$field_id"] as $key => $val) {
652 $val = str_replace('|', ' ', $val);
653 if (strlen($value)) $value .= '|';
654 $value .= "$key:$val";
657 else if ($data_type == 23) {
658 // $_POST["form_$field_id"] is an array of text fields with companion
659 // radio buttons to be imploded into "key:n:notes|key:n:notes|...".
660 foreach ($_POST["form_$field_id"] as $key => $val) {
661 $restype = $_POST["radio_{$field_id}"][$key];
662 if (empty($restype)) $restype = '0';
663 $val = str_replace('|', ' ', $val);
664 if (strlen($value)) $value .= '|';
665 $value .= "$key:$restype:$val";
668 else if ($data_type == 25) {
669 // $_POST["form_$field_id"] is an array of text fields with companion
670 // checkboxes to be imploded into "key:n:notes|key:n:notes|...".
671 foreach ($_POST["form_$field_id"] as $key => $val) {
672 $restype = empty($_POST["check_{$field_id}"][$key]) ? '0' : '1';
673 $val = str_replace('|', ' ', $val);
674 if (strlen($value)) $value .= '|';
675 $value .= "$key:$restype:$val";
678 else {
679 $value = $_POST["form_$field_id"];
682 return $value;