2 // Copyright (C) 2008-2010 Rod Roark <rod@sunsetsystems.com>
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'";
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 */
39 #report_parameters_daterange {
43 #report_results table {
48 /* specifically exclude some from the screen */
50 #report_parameters_daterange {
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
>
65 <body
class="body_top">
67 <span
class='title'><?php
xl('Report','e'); ?
> - <?php
xl('Services by Category','e'); ?
></span
>
69 <form method
='post' action
='services_by_category.php' name
='theform' id
='theform'>
71 <div id
="report_parameters">
73 <input type
='hidden' name
='form_refresh' id
='form_refresh' value
=''/>
78 <div style
='float:left'>
83 <select name
='filter'>
84 <option value
='0'><?php
xl('All','e'); ?
></option
>
86 foreach ($code_types as $key => $value) {
87 echo "<option value='" . $value['id'] . "'";
88 if ($value['id'] == $filter) echo " selected";
89 echo ">$key</option>\n";
95 <input type
='checkbox' name
='include_uncat' value
='1'<?php
if (!empty($_REQUEST['include_uncat'])) echo " checked"; ?
> />
96 <?php
xl('Include Uncategorized','e'); ?
>
104 <td align
='left' valign
='middle' height
="100%">
105 <table style
='border-left:1px solid; width:100%; height:100%' >
108 <div style
='margin-left:15px'>
109 <a href
='#' class='css_button' onclick
='$("#form_refresh").attr("value","true"); $("#theform").submit();'>
111 <?php
xl('Submit','e'); ?
>
115 <?php
if ($_POST['form_refresh']) { ?
>
116 <a href
='#' class='css_button' onclick
='window.print()'>
118 <?php
xl('Print','e'); ?
>
129 </div
> <!-- end of parameters
-->
132 if ($_POST['form_refresh']) {
135 <div id
="report_results">
138 <table border
='0' cellpadding
='1' cellspacing
='2' width
='98%'>
139 <thead style
='display:table-header-group'>
140 <tr bgcolor
="#dddddd">
141 <th
class='bold'><?php
xl('Category' ,'e'); ?
></th
>
142 <th
class='bold'><?php
xl('Type' ,'e'); ?
></th
>
143 <th
class='bold'><?php
xl('Code' ,'e'); ?
></th
>
144 <th
class='bold'><?php
xl('Mod' ,'e'); ?
></th
>
145 <th
class='bold'><?php
xl('Units' ,'e'); ?
></th
>
146 <th
class='bold'><?php
xl('Description','e'); ?
></th
>
147 <?php
if (related_codes_are_used()) { ?
>
148 <th
class='bold'><?php
xl('Related' ,'e'); ?
></th
>
151 $pres = sqlStatement("SELECT title FROM list_options " .
152 "WHERE list_id = 'pricelevel' ORDER BY seq");
153 while ($prow = sqlFetchArray($pres)) {
154 // Added 5-09 by BM - Translate label if applicable
155 echo " <th class='bold' align='right' nowrap>" . xl_list_label($prow['title']) . "</th>\n";
162 $res = sqlStatement("SELECT c.*, lo.title FROM codes AS c " .
163 "LEFT OUTER JOIN list_options AS lo ON lo.list_id = 'superbill' " .
164 "AND lo.option_id = c.superbill " .
165 "WHERE $where ORDER BY lo.title, c.code_type, c.code, c.modifier");
169 while ($row = sqlFetchArray($res)) {
170 $category = $row['title'] ?
$row['title'] : 'Uncategorized';
171 $disp_category = ' ';
172 if ($category !== $last_category) {
173 $last_category = $category;
174 $disp_category = $category;
177 foreach ($code_types as $key => $value) {
178 if ($value['id'] == $row['code_type']) {
182 $bgcolor = (($irow & 1) ?
"#ffdddd" : "#ddddff");
183 echo " <tr bgcolor='$bgcolor'>\n";
184 // Added 5-09 by BM - Translate label if applicable
185 echo " <td class='text'>" . xl_list_label($disp_category) . "</td>\n";
186 echo " <td class='text'>$key</td>\n";
187 echo " <td class='text'>" . $row['code'] . "</td>\n";
188 echo " <td class='text'>" . $row['modifier'] . "</td>\n";
189 echo " <td class='text'>" . $row['units'] . "</td>\n";
190 echo " <td class='text'>" . $row['code_text'] . "</td>\n";
192 if (related_codes_are_used()) {
193 // Show related codes.
194 echo " <td class='text'>";
195 $arel = explode(';', $row['related_code']);
196 foreach ($arel as $tmp) {
197 list($reltype, $relcode) = explode(':', $tmp);
198 $reltype = $code_types[$reltype]['id'];
199 $relrow = sqlQuery("SELECT code_text FROM codes WHERE " .
200 "code_type = '$reltype' AND code = '$relcode' LIMIT 1");
201 echo $relcode . ' ' . trim($relrow['code_text']) . '<br />';
206 $pres = sqlStatement("SELECT p.pr_price " .
207 "FROM list_options AS lo LEFT OUTER JOIN prices AS p ON " .
208 "p.pr_id = '" . $row['id'] . "' AND p.pr_selector = '' " .
209 "AND p.pr_level = lo.option_id " .
210 "WHERE list_id = 'pricelevel' ORDER BY lo.seq");
211 while ($prow = sqlFetchArray($pres)) {
212 echo " <td class='text' align='right'>" . bucks($prow['pr_price']) . "</td>\n";
220 <?php
} // end of submit logic ?>