added gacl config files to upgrade instructions
[openemr.git] / interface / reports / services_by_category.php
blob90721ab0070350414c5a51f3edac427cb8a6eb52
1 <?php
2 // Copyright (C) 2008 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 include_once("../globals.php");
10 include_once("../../custom/code_types.inc.php");
11 include_once("$srcdir/sql.inc");
13 // Format dollars for display.
15 function bucks($amount) {
16 if ($amount) {
17 $amount = sprintf("%.2f", $amount);
18 if ($amount != 0.00) return $amount;
20 return '';
23 $filter = $_REQUEST['filter'] + 0;
24 $where = "1 = 1";
25 if ($filter) $where .= " AND c.code_type = '$filter'";
26 if (empty($_REQUEST['include_uncat']))
27 $where .= " AND c.superbill != '' AND c.superbill != '0'";
29 <html>
30 <head>
31 <?php html_header_show(); ?>
32 <link rel="stylesheet" href="<?php echo $css_header;?>" type="text/css">
33 </head>
34 <body>
35 <center>
37 <form method='post' action='services_by_category.php' name='theform'>
38 <table border='0' cellpadding='5' cellspacing='0' width='98%'>
39 <tr>
40 <td class='title'>
41 <?php xl('Services by Category','e'); ?>
42 </td>
43 <td class='text' align='right'>
44 <select name='filter'>
45 <option value='0'>All</option>
46 <?php
47 foreach ($code_types as $key => $value) {
48 echo "<option value='" . $value['id'] . "'";
49 if ($value['id'] == $filter) echo " selected";
50 echo ">$key</option>\n";
53 </select>
54 &nbsp;
55 <input type='checkbox' name='include_uncat' value='1'<?php if (!empty($_REQUEST['include_uncat'])) echo " checked"; ?> />
56 Include Uncategorized
57 &nbsp;
58 <input type="submit" name="form_submit" value="Refresh">
59 &nbsp;
60 <input type="button" value="Print" onclick="window.print()">
61 </td>
62 </tr>
63 </table>
64 </form>
66 <?php if ($_POST['form_submit']) { ?>
68 <table border='0' cellpadding='1' cellspacing='2' width='98%'>
69 <thead style='display:table-header-group'>
70 <tr bgcolor="#dddddd">
71 <th class='bold'><?php xl('Category' ,'e'); ?></th>
72 <th class='bold'><?php xl('Type' ,'e'); ?></th>
73 <th class='bold'><?php xl('Code' ,'e'); ?></th>
74 <th class='bold'><?php xl('Mod' ,'e'); ?></th>
75 <th class='bold'><?php xl('Units' ,'e'); ?></th>
76 <th class='bold'><?php xl('Description','e'); ?></th>
77 <?php
78 $pres = sqlStatement("SELECT title FROM list_options " .
79 "WHERE list_id = 'pricelevel' ORDER BY seq");
80 while ($prow = sqlFetchArray($pres)) {
81 echo " <th class='bold' align='right' nowrap>" . $prow['title'] . "</th>\n";
84 </tr>
85 </thead>
86 <tbody>
87 <?php
88 $res = sqlStatement("SELECT c.*, lo.title FROM codes AS c " .
89 "LEFT OUTER JOIN list_options AS lo ON lo.list_id = 'superbill' " .
90 "AND lo.option_id = c.superbill " .
91 "WHERE $where ORDER BY lo.title, c.code_type, c.code, c.modifier");
93 $last_category = '';
94 $irow = 0;
95 while ($row = sqlFetchArray($res)) {
96 $category = $row['title'] ? $row['title'] : 'Uncategorized';
97 $disp_category = '&nbsp';
98 if ($category !== $last_category) {
99 $last_category = $category;
100 $disp_category = $category;
101 ++$irow;
103 foreach ($code_types as $key => $value) {
104 if ($value['id'] == $row['code_type']) {
105 break;
108 $bgcolor = (($irow & 1) ? "#ffdddd" : "#ddddff");
109 echo " <tr bgcolor='$bgcolor'>\n";
110 echo " <td class='text'>$disp_category</td>\n";
111 echo " <td class='text'>$key</td>\n";
112 echo " <td class='text'>" . $row['code'] . "</td>\n";
113 echo " <td class='text'>" . $row['modifier'] . "</td>\n";
114 echo " <td class='text'>" . $row['units'] . "</td>\n";
115 echo " <td class='text'>" . $row['code_text'] . "</td>\n";
116 $pres = sqlStatement("SELECT p.pr_price " .
117 "FROM list_options AS lo LEFT OUTER JOIN prices AS p ON " .
118 "p.pr_id = '" . $row['id'] . "' AND p.pr_selector = '' " .
119 "AND p.pr_level = lo.option_id " .
120 "WHERE list_id = 'pricelevel' ORDER BY lo.seq");
121 while ($prow = sqlFetchArray($pres)) {
122 echo " <td class='text' align='right'>" . bucks($prow['pr_price']) . "</td>\n";
124 echo " </tr>\n";
127 </tbody>
128 </table>
130 <?php } // end of submit logic ?>
132 </center>
134 </body>
135 </html>