Highway to PSR2
[openemr.git] / interface / forms / LBF / printable.php
blob5d93f5ab60d1a25e8b6012de06c05953b3b98921
1 <?php
2 // Copyright (C) 2009-2017 Rod Roark <rod@sunsetsystems.com>
3 //
4 // This program is free software; you can redistribute it and/or
5 // modify it under the terms of the GNU General Public License
6 // as published by the Free Software Foundation; either version 2
7 // of the License, or (at your option) any later version.
11 require_once("../../globals.php");
12 require_once("$srcdir/acl.inc");
13 require_once("$srcdir/options.inc.php");
14 require_once("$srcdir/patient.inc");
16 $CPR = 4; // cells per row
18 // The form name is passed to us as a GET parameter.
19 $formname = isset($_GET['formname']) ? $_GET['formname'] : '';
21 $tmp = sqlQuery("SELECT title, notes FROM list_options WHERE " .
22 "list_id = 'lbfnames' AND option_id = ? AND activity = 1 LIMIT 1", array($formname));
23 $formtitle = $tmp['title'];
25 // Extract parameters from this form's list item entry.
26 $jobj = json_decode($tmp['notes'], true);
27 if (!empty($jobj['columns'])) {
28 $CPR = intval($jobj['columns']);
31 if (!empty($jobj['size' ])) {
32 $FONTSIZE = intval($jobj['size']);
35 // Check access control.
36 if (!empty($jobj['aco'])) {
37 $LBF_ACO = explode('|', $jobj['aco']);
40 if (!acl_check('admin', 'super') && !empty($LBF_ACO)) {
41 if (!acl_check($LBF_ACO[0], $LBF_ACO[1])) {
42 die(xlt('Access denied'));
46 $fres = sqlStatement("SELECT * FROM layout_options " .
47 "WHERE form_id = ? AND uor > 0 " .
48 "ORDER BY group_name, seq", array($formname));
50 <html>
51 <head>
52 <?php html_header_show();?>
54 <style>
55 body, td {
56 font-family: Arial, Helvetica, sans-serif;
57 font-weight: normal;
58 font-size: 9pt;
61 body {
62 padding: 5pt 5pt 5pt 5pt;
65 div.section {
66 border-style: solid;
67 border-width: 1px;
68 border-color: #000000;
69 margin: 0 0 0 10pt;
70 padding: 5pt;
73 .mainhead {
74 font-weight: bold;
75 font-size: 14pt;
76 text-align: center;
79 .subhead {
80 font-weight: bold;
81 font-size: 8pt;
84 .under {
85 border-style: solid;
86 border-width: 0 0 1px 0;
87 border-color: #999999;
90 .ftitletable {
91 width: 100%;
92 margin: 0 0 8pt 0;
94 .ftitlecell1 {
95 vertical-align: top;
96 text-align: left;
97 font-size: 14pt;
98 font-weight: bold;
100 .ftitlecell2 {
101 vertical-align: top;
102 text-align: right;
103 font-size: 9pt;
105 </style>
106 </head>
108 <body bgcolor='#ffffff'>
109 <form>
111 <?php echo genFacilityTitle($formtitle, -1); ?>
113 <span class='subhead'>
114 <?php echo xlt('Patient') ?>: ________________________________________ &nbsp;
115 <?php echo xlt('Clinic') ?>: ____________________ &nbsp;
116 <?php echo xlt('Date') ?>: ____________________<br />&nbsp;<br />
117 </span>
119 <?php
121 function end_cell()
123 global $item_count, $cell_count;
124 if ($item_count > 0) {
125 echo "</td>";
126 $item_count = 0;
130 function end_row()
132 global $cell_count, $CPR;
133 end_cell();
134 if ($cell_count > 0) {
135 for (; $cell_count < $CPR;
136 ++$cell_count) {
137 echo "<td></td>";
140 echo "</tr>\n";
141 $cell_count = 0;
145 function end_group()
147 global $last_group;
148 if (strlen($last_group) > 0) {
149 end_row();
150 echo " </table>\n";
151 echo "</div>\n";
155 $last_group = '';
156 $cell_count = 0;
157 $item_count = 0;
159 while ($frow = sqlFetchArray($fres)) {
160 $this_group = $frow['group_name'];
161 $titlecols = $frow['titlecols'];
162 $datacols = $frow['datacols'];
163 $data_type = $frow['data_type'];
164 $field_id = $frow['field_id'];
165 $list_id = $frow['list_id'];
166 $currvalue = '';
168 // if (isset($result[$field_id])) $currvalue = $result[$field_id];
170 // Handle a data category (group) change.
171 if (strcmp($this_group, $last_group) != 0) {
172 end_group();
173 if (strlen($last_group) > 0) {
174 echo "<br />\n";
177 $group_name = substr($this_group, 1);
178 $last_group = $this_group;
179 echo "<b>" . text(xl_layout_label($group_name)) . "</b>\n";
181 echo "<div class='section'>\n";
182 echo " <table border='0' cellpadding='0'>\n";
185 // Handle starting of a new row.
186 if (($titlecols > 0 && $cell_count >= $CPR) || $cell_count == 0) {
187 end_row();
188 echo " <tr style='height:30pt'>";
191 if ($item_count == 0 && $titlecols == 0) {
192 $titlecols = 1;
195 // Handle starting of a new label cell.
196 if ($titlecols > 0) {
197 end_cell();
198 echo "<td colspan='" . attr($titlecols) . "' width='10%'";
199 echo ($frow['uor'] == 2) ? " class='required'" : " class='bold'";
200 if ($cell_count == 2) {
201 echo " style='padding-left:10pt'";
204 echo ">";
205 $cell_count += $titlecols;
208 ++$item_count;
210 echo "<b>";
212 if ($frow['title']) {
213 echo (text(xl_layout_label($frow['title'])) . ":");
214 } else {
215 echo "&nbsp;";
218 echo "</b>";
220 // Handle starting of a new data cell.
221 if ($datacols > 0) {
222 end_cell();
223 echo "<td colspan='" . attr($datacols) . "' width='40%'";
224 if ($data_type < 21 || $data_type > 25) {
225 echo " class='under'";
228 if ($cell_count > 0) {
229 echo " style='padding-left:5pt;'";
232 echo ">";
233 $cell_count += $datacols;
236 ++$item_count;
237 generate_print_field($frow, $currvalue);
240 end_group();
243 </form>
245 <!-- This should really be in the onload handler but that seems to be unreliable and can crash Firefox 3. -->
246 <script language='JavaScript'>
247 var win = top.printLogPrint ? top : opener.top;
248 win.printLogPrint(window);
249 </script>
251 </body>
252 </html>