Centralized formatting.inc.php include
[openemr.git] / interface / reports / front_receipts_report.php
blobd0460f9233a92e6d4744296c69d63e32d4fae088
1 <?php
2 /**
3 * This report lists front office receipts for a given date range.
5 * Copyright (C) 2006-2015 Rod Roark <rod@sunsetsystems.com>
6 * Copyright (C) 2017 Brady Miller <brady.g.miller@gmail.com>
8 * LICENSE: This program is free software; you can redistribute it and/or
9 * modify it under the terms of the GNU General Public License
10 * as published by the Free Software Foundation; either version 2
11 * of the License, or (at your option) any later version.
12 * This program is distributed in the hope that it will be useful,
13 * but WITHOUT ANY WARRANTY; without even the implied warranty of
14 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15 * GNU General Public License for more details.
16 * You should have received a copy of the GNU General Public License
17 * along with this program. If not, see <http://opensource.org/licenses/gpl-license.php>;.
19 * @package OpenEMR
20 * @author Rod Roark <rod@sunsetsystems.com>
21 * @author Brady Miller <brady.g.miller@gmail.com>
22 * @link http://www.open-emr.org
25 require_once("../globals.php");
26 require_once("$srcdir/patient.inc");
28 $from_date = fixDate($_POST['form_from_date'], date('Y-m-d'));
29 $to_date = fixDate($_POST['form_to_date'], date('Y-m-d'));
31 function bucks($amt) {
32 return ($amt != 0.00) ? oeFormatMoney($amt) : '';
35 <html>
36 <head>
37 <?php html_header_show();?>
38 <title><?php xl('Front Office Receipts','e'); ?></title>
39 <script type="text/javascript" src="../../library/overlib_mini.js"></script>
40 <script type="text/javascript" src="../../library/textformat.js?v=<?php echo $v_js_includes; ?>"></script>
41 <script type="text/javascript" src="../../library/dialog.js?v=<?php echo $v_js_includes; ?>"></script>
42 <script type="text/javascript" src="<?php echo $GLOBALS['assets_static_relative']; ?>/jquery-min-3-1-1/index.js"></script>
43 <script type="text/javascript" src="<?php echo $GLOBALS['assets_static_relative']; ?>/jquery-datetimepicker-2-5-4/build/jquery.datetimepicker.full.min.js"></script>
45 <script language="JavaScript">
47 <?php require($GLOBALS['srcdir'] . "/restoreSession.php"); ?>
49 var mypcc = '<?php echo $GLOBALS['phone_country_code'] ?>';
51 $(document).ready(function() {
52 var win = top.printLogSetup ? top : opener.top;
53 win.printLogSetup(document.getElementById('printbutton'));
55 $('.datepicker').datetimepicker({
56 <?php $datetimepicker_timepicker = false; ?>
57 <?php $datetimepicker_formatInput = false; ?>
58 <?php require($GLOBALS['srcdir'] . '/js/xl/jquery-datetimepicker-2-5-4.js.php'); ?>
59 <?php // can add any additional javascript settings to datetimepicker here; need to prepend first setting with a comma ?>
60 });
61 });
63 // The OnClick handler for receipt display.
64 function show_receipt(pid,timestamp) {
65 dlgopen('../patient_file/front_payment.php?receipt=1&patient=' + pid +
66 '&time=' + timestamp, '_blank', 550, 400);
69 </script>
71 <link rel='stylesheet' href='<?php echo $css_header ?>' type='text/css'>
72 <link rel="stylesheet" href="<?php echo $GLOBALS['assets_static_relative']; ?>/jquery-datetimepicker-2-5-4/build/jquery.datetimepicker.min.css">
74 <style type="text/css">
75 /* specifically include & exclude from printing */
76 @media print {
77 #report_parameters {
78 visibility: hidden;
79 display: none;
81 #report_parameters_daterange {
82 visibility: visible;
83 display: inline;
85 #report_results {
86 margin-top: 30px;
90 /* specifically exclude some from the screen */
91 @media screen {
92 #report_parameters_daterange {
93 visibility: hidden;
94 display: none;
97 </style>
98 </head>
100 <body class="body_top">
102 <!-- Required for the popup date selectors -->
103 <div id="overDiv" style="position:absolute; visibility:hidden; z-index:1000;"></div>
105 <span class='title'><?php xl('Report','e'); ?> - <?php xl('Front Office Receipts','e'); ?></span>
107 <div id="report_parameters_daterange">
108 <?php echo date("d F Y", strtotime($form_from_date)) ." &nbsp; to &nbsp; ". date("d F Y", strtotime($form_to_date)); ?>
109 </div>
111 <form name='theform' method='post' action='front_receipts_report.php' id='theform'>
113 <div id="report_parameters">
115 <input type='hidden' name='form_refresh' id='form_refresh' value=''/>
117 <table>
118 <tr>
119 <td width='410px'>
120 <div style='float:left'>
122 <table class='text'>
123 <tr>
124 <td class='label'>
125 <?php xl('From','e'); ?>:
126 </td>
127 <td>
128 <input type='text' class='datepicker' name='form_from_date' id="form_from_date" size='10' value='<?php echo attr($form_from_date) ?>'
129 title='yyyy-mm-dd'>
130 </td>
131 <td class='label'>
132 <?php xl('To','e'); ?>:
133 </td>
134 <td>
135 <input type='text' class='datepicker' name='form_to_date' id="form_to_date" size='10' value='<?php echo attr($form_to_date) ?>'
136 title='yyyy-mm-dd'>
137 </td>
138 </tr>
139 </table>
141 </div>
143 </td>
144 <td align='left' valign='middle' height="100%">
145 <table style='border-left:1px solid; width:100%; height:100%' >
146 <tr>
147 <td>
148 <div style='margin-left:15px'>
149 <a href='#' class='css_button' onclick='$("#form_refresh").attr("value","true"); $("#theform").submit();'>
150 <span>
151 <?php xl('Submit','e'); ?>
152 </span>
153 </a>
155 <?php if ($_POST['form_refresh']) { ?>
156 <a href='#' class='css_button' id='printbutton'>
157 <span>
158 <?php xl('Print','e'); ?>
159 </span>
160 </a>
161 <?php } ?>
162 </div>
163 </td>
164 </tr>
165 </table>
166 </td>
167 </tr>
168 </table>
169 </div> <!-- end of parameters -->
171 <?php
172 if ($_POST['form_refresh'] || $_POST['form_orderby']) {
174 <div id="report_results">
175 <table>
176 <thead>
177 <th> <?php xl('Time','e'); ?> </th>
178 <th> <?php xl('Patient','e'); ?> </th>
179 <th> <?php xl('ID','e'); ?> </th>
180 <th> <?php xl('Method','e'); ?> </th>
181 <th> <?php xl('Source','e'); ?> </th>
182 <th align='right'> <?php xl('Today','e'); ?> </th>
183 <th align='right'> <?php xl('Previous','e'); ?> </th>
184 <th align='right'> <?php xl('Total','e'); ?> </th>
185 </thead>
186 <tbody>
187 <?php
188 if (true || $_POST['form_refresh']) {
189 $total1 = 0.00;
190 $total2 = 0.00;
192 $query = "SELECT r.pid, r.dtime, " .
193 "SUM(r.amount1) AS amount1, " .
194 "SUM(r.amount2) AS amount2, " .
195 "MAX(r.method) AS method, " .
196 "MAX(r.source) AS source, " .
197 "MAX(r.user) AS user, " .
198 "p.fname, p.mname, p.lname, p.pubpid " .
199 "FROM payments AS r " .
200 "LEFT OUTER JOIN patient_data AS p ON " .
201 "p.pid = r.pid " .
202 "WHERE " .
203 "r.dtime >= '$from_date 00:00:00' AND " .
204 "r.dtime <= '$to_date 23:59:59' " .
205 "GROUP BY r.dtime, r.pid ORDER BY r.dtime, r.pid";
207 // echo "<!-- $query -->\n"; // debugging
208 $res = sqlStatement($query);
210 while ($row = sqlFetchArray($res)) {
211 // Make the timestamp URL-friendly.
212 $timestamp = preg_replace('/[^0-9]/', '', $row['dtime']);
214 <tr>
215 <td nowrap>
216 <a href="javascript:show_receipt(<?php echo $row['pid'] . ",'$timestamp'"; ?>)">
217 <?php echo oeFormatShortDate(substr($row['dtime'], 0, 10)) . substr($row['dtime'], 10, 6); ?>
218 </a>
219 </td>
220 <td>
221 <?php echo $row['lname'] . ', ' . $row['fname'] . ' ' . $row['mname'] ?>
222 </td>
223 <td>
224 <?php echo $row['pubpid'] ?>
225 </td>
226 <td>
227 <?php echo $row['method'] ?>
228 </td>
229 <td>
230 <?php echo $row['source'] ?>
231 </td>
232 <td align='right'>
233 <?php echo bucks($row['amount1']) ?>
234 </td>
235 <td align='right'>
236 <?php echo bucks($row['amount2']) ?>
237 </td>
238 <td align='right'>
239 <?php echo bucks($row['amount1'] + $row['amount2']) ?>
240 </td>
241 </tr>
242 <?php
243 $total1 += $row['amount1'];
244 $total2 += $row['amount2'];
248 <tr>
249 <td colspan='8'>
250 &nbsp;
251 </td>
252 </tr>
254 <tr class="report_totals">
255 <td colspan='5'>
256 <?php xl('Totals','e'); ?>
257 </td>
258 <td align='right'>
259 <?php echo bucks($total1) ?>
260 </td>
261 <td align='right'>
262 <?php echo bucks($total2) ?>
263 </td>
264 <td align='right'>
265 <?php echo bucks($total1 + $total2) ?>
266 </td>
267 </tr>
269 <?php
272 </tbody>
273 </table>
274 </div> <!-- end of results -->
275 <?php } else { ?>
276 <div class='text'>
277 <?php echo xl('Please input search criteria above, and click Submit to view results.', 'e' ); ?>
278 </div>
279 <?php } ?>
281 </form>
282 </body>
283 </html>