forked from openemr/openemr
-
Notifications
You must be signed in to change notification settings - Fork 0
/
new_form.php
96 lines (86 loc) · 2.93 KB
/
new_form.php
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
<?php
// This program is free software; you can redistribute it and/or
// modify it under the terms of the GNU General Public License
// as published by the Free Software Foundation; either version 2
// of the License, or (at your option) any later version.
include_once("../../globals.php");
?>
<html>
<head>
<?php html_header_show();?>
<link rel="stylesheet" href="<?php echo $css_header; ?>" type="text/css">
<script language="JavaScript">
function openNewForm(sel) {
top.restoreSession();
<?php if ($GLOBALS['concurrent_layout']) { ?>
parent.location.href = sel.options[sel.selectedIndex].value;
<?php } else { ?>
top.frames['Main'].location.href = sel.options[sel.selectedIndex].value;
<?php } ?>
}
</script>
</head>
<body class="body_top">
<dl>
<?php //DYNAMIC FORM RETREIVAL
include_once("$srcdir/registry.inc");
function myGetRegistered($state="1", $limit="unlimited", $offset="0") {
$sql = "SELECT category, nickname, name, state, directory, id, sql_run, " .
"unpackaged, date FROM registry WHERE " .
"state LIKE \"$state\" ORDER BY category, priority, name";
if ($limit != "unlimited") $sql .= " limit $limit, $offset";
$res = sqlStatement($sql);
if ($res) {
for($iter=0; $row=sqlFetchArray($res); $iter++) {
$all[$iter] = $row;
}
}
else {
return false;
}
return $all;
}
$reg = myGetRegistered();
$old_category = '';
echo "<FORM METHOD=POST NAME='choose'>\n";
if (!empty($reg)) {
foreach ($reg as $entry) {
$new_category = trim($entry['category']);
$new_nickname = trim($entry['nickname']);
if ($new_category == '') {$new_category = 'miscellaneous';}
if ($new_nickname != '') {$nickname = $new_nickname;}
else {$nickname = $entry['name'];}
if ($old_category != $new_category) {
$new_category_ = $new_category;
$new_category_ = str_replace(' ','_',$new_category_);
if ($old_category != '') {echo "</select>\n";}
echo "<select name=" . $new_category_ . " onchange='openNewForm(this)'>\n";
echo " <option value=" . $new_category_ . ">" . $new_category . "</option>\n";
$old_category = $new_category;
}
echo " <option value='" . $rootdir .
'/patient_file/encounter/load_form.php?formname=' .
urlencode($entry['directory']) . "'>" . xl_form_title($nickname) . "</option>\n";
}
echo "</select>\n";
}
// This shows Layout Based Form names just like the above.
//
$lres = sqlStatement("SELECT * FROM list_options " .
"WHERE list_id = 'lbfnames' ORDER BY seq, title");
if (sqlNumRows($lres)) {
echo "<select name='lbfnames' onchange='openNewForm(this)'>\n";
echo "<option value='lbfnames'>" . xl('Layout Based') . "</option>\n";
while ($lrow = sqlFetchArray($lres)) {
$option_id = $lrow['option_id']; // should start with LBF
$title = $lrow['title'];
echo "<option value='$rootdir/patient_file/encounter/load_form.php?" .
"formname=$option_id'>" . xl_form_title($title) . "</option>\n";
}
echo "</select>\n";
}
echo "</FORM>\n";
?>
</dl>
</body>
</html>