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