Centralized formatting.inc.php include
[openemr.git] / interface / reports / services_by_category.php
blob4cc65e84d00a7c433202cd9205d49f7fce89622a
1 <?php
2 // Copyright (C) 2008-2016 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.
9 require_once("../globals.php");
10 require_once("../../custom/code_types.inc.php");
12 // Format dollars for display.
14 function bucks($amount) {
15 if (empty($amount)) return '';
16 return oeFormatMoney($amount);
19 $filter = $_REQUEST['filter'] + 0;
20 $where = "c.active = 1";
21 if ($filter) $where .= " AND c.code_type = '$filter'";
22 if (empty($_REQUEST['include_uncat']))
23 $where .= " AND c.superbill != '' AND c.superbill != '0'";
25 <html>
26 <head>
27 <?php html_header_show(); ?>
28 <link rel="stylesheet" href="<?php echo $css_header;?>" type="text/css">
32 <style type="text/css">
34 /* specifically include & exclude from printing */
35 @media print {
36 #report_parameters {
37 visibility: hidden;
38 display: none;
40 #report_parameters_daterange {
41 visibility: visible;
42 display: inline;
44 #report_results table {
45 margin-top: 0px;
49 /* specifically exclude some from the screen */
50 @media screen {
51 #report_parameters_daterange {
52 visibility: hidden;
53 display: none;
57 table.mymaintable, table.mymaintable td, table.mymaintable th {
58 border: 1px solid #aaaaaa;
59 border-collapse: collapse;
61 table.mymaintable td, table.mymaintable th {
62 padding: 1pt 4pt 1pt 4pt;
64 </style>
65 <title><?php xl('Services by Category','e'); ?></title>
67 <script type="text/javascript" src="../../library/overlib_mini.js"></script>
68 <script type="text/javascript" src="../../library/textformat.js"></script>
69 <script type="text/javascript" src="../../library/dialog.js?v=<?php echo $v_js_includes; ?>"></script>
70 <script type="text/javascript" src="<?php echo $GLOBALS['assets_static_relative']; ?>/jquery-min-1-9-1/index.js"></script>
71 <script type="text/javascript" src="../../library/js/report_helper.js?v=<?php echo $v_js_includes; ?>"></script>
73 <script language="JavaScript">
75 $(document).ready(function() {
76 oeFixedHeaderSetup(document.getElementById('mymaintable'));
77 var win = top.printLogSetup ? top : opener.top;
78 win.printLogSetup(document.getElementById('printbutton'));
79 });
81 </script>
83 </head>
85 <body class="body_top">
87 <span class='title'><?php xl('Report','e'); ?> - <?php xl('Services by Category','e'); ?></span>
89 <form method='post' action='services_by_category.php' name='theform' id='theform'>
91 <div id="report_parameters">
93 <input type='hidden' name='form_refresh' id='form_refresh' value=''/>
95 <table>
96 <tr>
97 <td width='280px'>
98 <div style='float:left'>
100 <table class='text'>
101 <tr>
102 <td>
103 <select name='filter'>
104 <option value='0'><?php xl('All','e'); ?></option>
105 <?php
106 foreach ($code_types as $key => $value) {
107 echo "<option value='" . $value['id'] . "'";
108 if ($value['id'] == $filter) echo " selected";
109 echo ">$key</option>\n";
112 </select>
113 </td>
114 <td>
115 <input type='checkbox' name='include_uncat' value='1'<?php if (!empty($_REQUEST['include_uncat'])) echo " checked"; ?> />
116 <?php xl('Include Uncategorized','e'); ?>
117 </td>
118 </tr>
119 </table>
121 </div>
123 </td>
124 <td align='left' valign='middle' height="100%">
125 <table style='border-left:1px solid; width:100%; height:100%' >
126 <tr>
127 <td>
128 <div style='margin-left:15px'>
129 <a href='#' class='css_button' onclick='$("#form_refresh").attr("value","true"); $("#theform").submit();'>
130 <span>
131 <?php xl('Submit','e'); ?>
132 </span>
133 </a>
135 <?php if ($_POST['form_refresh']) { ?>
136 <a href='#' class='css_button' id='printbutton'>
137 <span>
138 <?php xl('Print','e'); ?>
139 </span>
140 </a>
141 <?php } ?>
142 </div>
143 </td>
144 </tr>
145 </table>
146 </td>
147 </tr>
148 </table>
149 </div> <!-- end of parameters -->
151 <?php
152 if ($_POST['form_refresh']) {
155 <div id="report_results">
158 <table width='98%' id='mymaintable' class='mymaintable'>
159 <thead style='display:table-header-group'>
160 <tr bgcolor="#dddddd">
161 <th class='bold'><?php xl('Category' ,'e'); ?></th>
162 <th class='bold'><?php xl('Type' ,'e'); ?></th>
163 <th class='bold'><?php xl('Code' ,'e'); ?></th>
164 <th class='bold'><?php xl('Mod' ,'e'); ?></th>
165 <th class='bold'><?php xl('Units' ,'e'); ?></th>
166 <th class='bold'><?php xl('Description','e'); ?></th>
167 <?php if (related_codes_are_used()) { ?>
168 <th class='bold'><?php xl('Related' ,'e'); ?></th>
169 <?php } ?>
170 <?php
171 $pres = sqlStatement("SELECT title FROM list_options " .
172 "WHERE list_id = 'pricelevel' AND activity = 1 ORDER BY seq");
173 while ($prow = sqlFetchArray($pres)) {
174 // Added 5-09 by BM - Translate label if applicable
175 echo " <th class='bold' align='right' nowrap>" . xl_list_label($prow['title']) . "</th>\n";
178 </tr>
179 </thead>
180 <tbody>
181 <?php
182 $res = sqlStatement("SELECT c.*, lo.title FROM codes AS c " .
183 "LEFT OUTER JOIN list_options AS lo ON lo.list_id = 'superbill' " .
184 "AND lo.option_id = c.superbill AND lo.activity = 1 " .
185 "WHERE $where ORDER BY lo.title, c.code_type, c.code, c.modifier");
187 $last_category = '';
188 $irow = 0;
189 while ($row = sqlFetchArray($res)) {
190 $category = $row['title'] ? $row['title'] : 'Uncategorized';
191 $disp_category = '&nbsp';
192 if ($category !== $last_category) {
193 $last_category = $category;
194 $disp_category = $category;
195 ++$irow;
197 foreach ($code_types as $key => $value) {
198 if ($value['id'] == $row['code_type']) {
199 break;
202 $bgcolor = (($irow & 1) ? "#ffdddd" : "#ddddff");
203 echo " <tr bgcolor='$bgcolor'>\n";
204 // Added 5-09 by BM - Translate label if applicable
205 echo " <td class='text'>" . xl_list_label($disp_category) . "</td>\n";
206 echo " <td class='text'>$key</td>\n";
207 echo " <td class='text'>" . $row['code'] . "</td>\n";
208 echo " <td class='text'>" . $row['modifier'] . "</td>\n";
209 echo " <td class='text'>" . $row['units'] . "</td>\n";
210 echo " <td class='text'>" . $row['code_text'] . "</td>\n";
212 if (related_codes_are_used()) {
213 // Show related codes.
214 echo " <td class='text'>";
215 $arel = explode(';', $row['related_code']);
216 foreach ($arel as $tmp) {
217 list($reltype, $relcode) = explode(':', $tmp);
218 $reltype = $code_types[$reltype]['id'];
219 $relrow = sqlQuery("SELECT code_text FROM codes WHERE " .
220 "code_type = '$reltype' AND code = '$relcode' LIMIT 1");
221 echo $relcode . ' ' . trim($relrow['code_text']) . '<br />';
223 echo "</td>\n";
226 $pres = sqlStatement("SELECT p.pr_price " .
227 "FROM list_options AS lo LEFT OUTER JOIN prices AS p ON " .
228 "p.pr_id = '" . $row['id'] . "' AND p.pr_selector = '' " .
229 "AND p.pr_level = lo.option_id " .
230 "WHERE lo.list_id = 'pricelevel' AND lo.activity = 1 ORDER BY lo.seq");
231 while ($prow = sqlFetchArray($pres)) {
232 echo " <td class='text' align='right'>" . bucks($prow['pr_price']) . "</td>\n";
234 echo " </tr>\n";
237 </tbody>
238 </table>
240 <?php } // end of submit logic ?>
241 </div>
243 </body>
244 </html>