fix: faxsms psr7 vendor fix (#7794)
[openemr.git] / interface / reports / services_by_category.php
blob7ce27971311c614f7a1b8e2bd5a1c8c0a00a148c
1 <?php
3 /**
4 * Services by category report.
6 * @package OpenEMR
7 * @link http://www.open-emr.org
8 * @author Rod Roark <rod@sunsetsystems.com>
9 * @author Brady Miller <brady.g.miller@gmail.com>
10 * @copyright Copyright (c) 2008-2016 Rod Roark <rod@sunsetsystems.com>
11 * @copyright Copyright (c) 2017-2018 Brady Miller <brady.g.miller@gmail.com>
12 * @license https://github.com/openemr/openemr/blob/master/LICENSE GNU General Public License 3
15 require_once("../globals.php");
16 require_once("../../custom/code_types.inc.php");
18 use OpenEMR\Common\Csrf\CsrfUtils;
19 use OpenEMR\Common\Utils\FormatMoney;
20 use OpenEMR\Core\Header;
22 if (!empty($_POST)) {
23 if (!CsrfUtils::verifyCsrfToken($_POST["csrf_token_form"])) {
24 CsrfUtils::csrfNotVerified();
29 <html>
30 <head>
31 <title><?php echo xlt('Services by Category'); ?></title>
33 <?php Header::setupHeader(['datetime-picker', 'report-helper']); ?>
35 <style>
36 /* specifically include & exclude from printing */
37 @media print {
38 #report_parameters {
39 visibility: hidden;
40 display: none;
42 #report_parameters_daterange {
43 visibility: visible;
44 display: inline;
46 #report_results table {
47 margin-top: 0px;
51 /* specifically exclude some from the screen */
52 @media screen {
53 #report_parameters_daterange {
54 visibility: hidden;
55 display: none;
59 table.mymaintable,
60 table.mymaintable td,
61 table.mymaintable th {
62 border-collapse: collapse;
64 table.mymaintable td, table.mymaintable th {
65 padding: 1pt 4pt 1pt 4pt;
67 </style>
69 <script>
71 $(function () {
72 oeFixedHeaderSetup(document.getElementById('mymaintable'));
73 var win = top.printLogSetup ? top : opener.top;
74 win.printLogSetup(document.getElementById('printbutton'));
75 });
76 </script>
77 </head>
79 <body class="body_top">
81 <span class='title'><?php echo xlt('Report'); ?> - <?php echo xlt('Services by Category'); ?></span>
83 <form method='post' action='services_by_category.php' name='theform' id='theform' onsubmit='return top.restoreSession()'>
84 <input type="hidden" name="csrf_token_form" value="<?php echo attr(CsrfUtils::collectCsrfToken()); ?>" />
86 <div id="report_parameters">
88 <input type='hidden' name='form_refresh' id='form_refresh' value=''/>
90 <table>
91 <tr>
92 <td width='280px'>
93 <div style='float:left'>
95 <table class='text'>
96 <tr>
97 <td>
98 <select name='filter' class='form-control'>
99 <option value='0'><?php echo xlt('All'); ?></option>
100 <?php
101 foreach ($code_types as $key => $value) {
102 echo "<option value='" . attr($value['id']) . "'";
103 if (!empty($filter) && ($value['id'] == $filter)) {
104 echo " selected";
107 echo ">" . text($key) . "</option>\n";
110 </select>
111 </td>
112 <td>
113 <div class="checkbox">
114 <label><input type='checkbox' name='include_uncat' value='1'<?php echo (!empty($_REQUEST['include_uncat'])) ? " checked" : ""; ?> />
115 <?php echo xlt('Include Uncategorized'); ?></label>
116 </div>
117 </td>
118 </tr>
119 </table>
121 </div>
123 </td>
124 <td class='h-100' align='left' valign='middle'>
125 <table class='w-100 h-100' style='border-left:1px solid;'>
126 <tr>
127 <td>
128 <div class="text-center">
129 <div class="btn-group" role="group">
130 <a href='#' class='btn btn-secondary btn-save' onclick='$("#form_refresh").attr("value","true"); $("#theform").submit();'>
131 <?php echo xlt('Submit'); ?>
132 </a>
133 <?php if (!empty($_POST['form_refresh'])) { ?>
134 <a href='#' class='btn btn-secondary btn-print' id='printbutton'>
135 <?php echo xlt('Print'); ?>
136 </a>
137 <?php } ?>
138 </div>
139 </div>
140 </td>
141 </tr>
142 </table>
143 </td>
144 </tr>
145 </table>
146 </div> <!-- end of parameters -->
148 <?php
149 if (!empty($_POST['form_refresh'])) {
152 <div id="report_results">
155 <table width='98%' id='mymaintable' class='table table-striped mymaintable'>
156 <thead class='thead-light'>
157 <tr>
158 <th class='bold'><?php echo xlt('Category'); ?></th>
159 <th class='bold'><?php echo xlt('Type'); ?></th>
160 <th class='bold'><?php echo xlt('Code'); ?></th>
161 <th class='bold'><?php echo xlt('Mod'); ?></th>
162 <th class='bold'><?php echo xlt('Units'); ?></th>
163 <th class='bold'><?php echo xlt('Description'); ?></th>
164 <?php if (related_codes_are_used()) { ?>
165 <th class='bold'><?php echo xlt('Related'); ?></th>
166 <?php } ?>
167 <?php
168 $pres = sqlStatement("SELECT title FROM list_options " .
169 "WHERE list_id = 'pricelevel' AND activity = 1 ORDER BY seq");
170 while ($prow = sqlFetchArray($pres)) {
171 // Added 5-09 by BM - Translate label if applicable
172 echo " <th class='bold' align='right' nowrap>" . text(xl_list_label($prow['title'])) . "</th>\n";
175 </tr>
176 </thead>
177 <tbody>
178 <?php
180 $sqlBindArray = array();
181 $filter = sanitizeNumber($_REQUEST['filter']);
182 $where = "c.active = 1";
183 if ($filter) {
184 $where .= " AND c.code_type = ?";
185 array_push($sqlBindArray, $filter);
187 if (empty($_REQUEST['include_uncat'])) {
188 $where .= " AND c.superbill != '' AND c.superbill != '0'";
191 $res = sqlStatement("SELECT c.*, lo.title FROM codes AS c " .
192 "LEFT OUTER JOIN list_options AS lo ON lo.list_id = 'superbill' " .
193 "AND lo.option_id = c.superbill AND lo.activity = 1 " .
194 "WHERE $where ORDER BY lo.title, c.code_type, c.code, c.modifier", $sqlBindArray);
196 $last_category = '';
197 $irow = 0;
198 while ($row = sqlFetchArray($res)) {
199 $category = $row['title'] ? $row['title'] : xl('Uncategorized');
200 $disp_category = ' ';
201 if ($category !== $last_category) {
202 $last_category = $category;
203 $disp_category = $category;
204 ++$irow;
207 foreach ($code_types as $key => $value) {
208 if ($value['id'] == $row['code_type']) {
209 break;
213 echo " <tr>\n";
214 // Added 5-09 by BM - Translate label if applicable
215 echo " <td class='text'>" . text(xl_list_label($disp_category)) . "</td>\n";
216 echo " <td class='text'>" . text($key) . "</td>\n";
217 echo " <td class='text'>" . text($row['code']) . "</td>\n";
218 echo " <td class='text'>" . text($row['modifier']) . "</td>\n";
219 echo " <td class='text'>" . text($row['units']) . "</td>\n";
220 echo " <td class='text'>" . text($row['code_text']) . "</td>\n";
222 if (related_codes_are_used()) {
223 // Show related codes.
224 echo " <td class='text'>";
225 $arel = explode(';', $row['related_code']);
226 foreach ($arel as $tmp) {
227 list($reltype, $relcode) = explode(':', $tmp);
228 $reltype = $code_types[$reltype]['id'];
229 $relrow = sqlQuery("SELECT code_text FROM codes WHERE " .
230 "code_type = ? AND code = ? LIMIT 1", array($reltype, $relcode));
231 echo text($relcode) . ' ' . text(trim($relrow['code_text'])) . '<br />';
234 echo "</td>\n";
237 $pres = sqlStatement("SELECT p.pr_price " .
238 "FROM list_options AS lo LEFT OUTER JOIN prices AS p ON " .
239 "p.pr_id = ? AND p.pr_selector = '' " .
240 "AND p.pr_level = lo.option_id " .
241 "WHERE lo.list_id = 'pricelevel' AND lo.activity = 1 ORDER BY lo.seq", array($row['id']));
242 while ($prow = sqlFetchArray($pres)) {
243 echo " <td class='text' align='right'>" . text(FormatMoney::getBucks($prow['pr_price'])) . "</td>\n";
246 echo " </tr>\n";
249 </tbody>
250 </table>
252 <?php } // end of submit logic ?>
253 </div>
255 </body>
256 </html>