Support for optional logging of print actions.
[openemr.git] / interface / reports / services_by_category.php
blob92f19f9d55bbacbcab832072cbfc55816fbe3aca
1 <?php
2 // Copyright (C) 2008-2015 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/sql.inc");
12 require_once("$srcdir/formatting.inc.php");
14 // Format dollars for display.
16 function bucks($amount) {
17 if (empty($amount)) return '';
18 return oeFormatMoney($amount);
21 $filter = $_REQUEST['filter'] + 0;
22 $where = "c.active = 1";
23 if ($filter) $where .= " AND c.code_type = '$filter'";
24 if (empty($_REQUEST['include_uncat']))
25 $where .= " AND c.superbill != '' AND c.superbill != '0'";
27 <html>
28 <head>
29 <?php html_header_show(); ?>
30 <link rel="stylesheet" href="<?php echo $css_header;?>" type="text/css">
31 <style type="text/css">
33 /* specifically include & exclude from printing */
34 @media print {
35 #report_parameters {
36 visibility: hidden;
37 display: none;
39 #report_parameters_daterange {
40 visibility: visible;
41 display: inline;
43 #report_results table {
44 margin-top: 0px;
48 /* specifically exclude some from the screen */
49 @media screen {
50 #report_parameters_daterange {
51 visibility: hidden;
52 display: none;
55 </style>
56 <title><?php xl('Services by Category','e'); ?></title>
58 <script type="text/javascript" src="../../library/overlib_mini.js"></script>
59 <script type="text/javascript" src="../../library/textformat.js"></script>
60 <script type="text/javascript" src="../../library/dialog.js"></script>
61 <script type="text/javascript" src="../../library/js/jquery.1.3.2.js"></script>
63 <script language="JavaScript">
64 $(document).ready(function() {
65 var win = top.printLogSetup ? top : opener.top;
66 win.printLogSetup(document.getElementById('printbutton'));
67 });
68 </script>
70 </head>
72 <body class="body_top">
74 <span class='title'><?php xl('Report','e'); ?> - <?php xl('Services by Category','e'); ?></span>
76 <form method='post' action='services_by_category.php' name='theform' id='theform'>
78 <div id="report_parameters">
80 <input type='hidden' name='form_refresh' id='form_refresh' value=''/>
82 <table>
83 <tr>
84 <td width='280px'>
85 <div style='float:left'>
87 <table class='text'>
88 <tr>
89 <td>
90 <select name='filter'>
91 <option value='0'><?php xl('All','e'); ?></option>
92 <?php
93 foreach ($code_types as $key => $value) {
94 echo "<option value='" . $value['id'] . "'";
95 if ($value['id'] == $filter) echo " selected";
96 echo ">$key</option>\n";
99 </select>
100 </td>
101 <td>
102 <input type='checkbox' name='include_uncat' value='1'<?php if (!empty($_REQUEST['include_uncat'])) echo " checked"; ?> />
103 <?php xl('Include Uncategorized','e'); ?>
104 </td>
105 </tr>
106 </table>
108 </div>
110 </td>
111 <td align='left' valign='middle' height="100%">
112 <table style='border-left:1px solid; width:100%; height:100%' >
113 <tr>
114 <td>
115 <div style='margin-left:15px'>
116 <a href='#' class='css_button' onclick='$("#form_refresh").attr("value","true"); $("#theform").submit();'>
117 <span>
118 <?php xl('Submit','e'); ?>
119 </span>
120 </a>
122 <?php if ($_POST['form_refresh']) { ?>
123 <a href='#' class='css_button' id='printbutton'>
124 <span>
125 <?php xl('Print','e'); ?>
126 </span>
127 </a>
128 <?php } ?>
129 </div>
130 </td>
131 </tr>
132 </table>
133 </td>
134 </tr>
135 </table>
136 </div> <!-- end of parameters -->
138 <?php
139 if ($_POST['form_refresh']) {
142 <div id="report_results">
145 <table border='0' cellpadding='1' cellspacing='2' width='98%'>
146 <thead style='display:table-header-group'>
147 <tr bgcolor="#dddddd">
148 <th class='bold'><?php xl('Category' ,'e'); ?></th>
149 <th class='bold'><?php xl('Type' ,'e'); ?></th>
150 <th class='bold'><?php xl('Code' ,'e'); ?></th>
151 <th class='bold'><?php xl('Mod' ,'e'); ?></th>
152 <th class='bold'><?php xl('Units' ,'e'); ?></th>
153 <th class='bold'><?php xl('Description','e'); ?></th>
154 <?php if (related_codes_are_used()) { ?>
155 <th class='bold'><?php xl('Related' ,'e'); ?></th>
156 <?php } ?>
157 <?php
158 $pres = sqlStatement("SELECT title FROM list_options " .
159 "WHERE list_id = 'pricelevel' ORDER BY seq");
160 while ($prow = sqlFetchArray($pres)) {
161 // Added 5-09 by BM - Translate label if applicable
162 echo " <th class='bold' align='right' nowrap>" . xl_list_label($prow['title']) . "</th>\n";
165 </tr>
166 </thead>
167 <tbody>
168 <?php
169 $res = sqlStatement("SELECT c.*, lo.title FROM codes AS c " .
170 "LEFT OUTER JOIN list_options AS lo ON lo.list_id = 'superbill' " .
171 "AND lo.option_id = c.superbill " .
172 "WHERE $where ORDER BY lo.title, c.code_type, c.code, c.modifier");
174 $last_category = '';
175 $irow = 0;
176 while ($row = sqlFetchArray($res)) {
177 $category = $row['title'] ? $row['title'] : 'Uncategorized';
178 $disp_category = '&nbsp';
179 if ($category !== $last_category) {
180 $last_category = $category;
181 $disp_category = $category;
182 ++$irow;
184 foreach ($code_types as $key => $value) {
185 if ($value['id'] == $row['code_type']) {
186 break;
189 $bgcolor = (($irow & 1) ? "#ffdddd" : "#ddddff");
190 echo " <tr bgcolor='$bgcolor'>\n";
191 // Added 5-09 by BM - Translate label if applicable
192 echo " <td class='text'>" . xl_list_label($disp_category) . "</td>\n";
193 echo " <td class='text'>$key</td>\n";
194 echo " <td class='text'>" . $row['code'] . "</td>\n";
195 echo " <td class='text'>" . $row['modifier'] . "</td>\n";
196 echo " <td class='text'>" . $row['units'] . "</td>\n";
197 echo " <td class='text'>" . $row['code_text'] . "</td>\n";
199 if (related_codes_are_used()) {
200 // Show related codes.
201 echo " <td class='text'>";
202 $arel = explode(';', $row['related_code']);
203 foreach ($arel as $tmp) {
204 list($reltype, $relcode) = explode(':', $tmp);
205 $reltype = $code_types[$reltype]['id'];
206 $relrow = sqlQuery("SELECT code_text FROM codes WHERE " .
207 "code_type = '$reltype' AND code = '$relcode' LIMIT 1");
208 echo $relcode . ' ' . trim($relrow['code_text']) . '<br />';
210 echo "</td>\n";
213 $pres = sqlStatement("SELECT p.pr_price " .
214 "FROM list_options AS lo LEFT OUTER JOIN prices AS p ON " .
215 "p.pr_id = '" . $row['id'] . "' AND p.pr_selector = '' " .
216 "AND p.pr_level = lo.option_id " .
217 "WHERE list_id = 'pricelevel' ORDER BY lo.seq");
218 while ($prow = sqlFetchArray($pres)) {
219 echo " <td class='text' align='right'>" . bucks($prow['pr_price']) . "</td>\n";
221 echo " </tr>\n";
224 </tbody>
225 </table>
227 <?php } // end of submit logic ?>
228 </div>
230 </body>
231 </html>