ongoing internationalization of date widget
[openemr.git] / interface / reports / front_receipts_report.php
blob2e37f6e6da3931a80874e2124fa684cebde4ec4c
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 use OpenEMR\Core\Header;
27 require_once("../globals.php");
28 require_once("$srcdir/patient.inc");
30 $from_date = fixDate($_POST['form_from_date'], date('Y-m-d'));
31 $to_date = fixDate($_POST['form_to_date'], date('Y-m-d'));
33 function bucks($amt)
35 return ($amt != 0.00) ? oeFormatMoney($amt) : '';
38 <html>
39 <head>
41 <title><?php xl('Front Office Receipts', 'e'); ?></title>
43 <?php Header::setupHeader('datetime-picker'); ?>
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_showseconds = false; ?>
58 <?php $datetimepicker_formatInput = false; ?>
59 <?php require($GLOBALS['srcdir'] . '/js/xl/jquery-datetimepicker-2-5-4.js.php'); ?>
60 <?php // can add any additional javascript settings to datetimepicker here; need to prepend first setting with a comma ?>
61 });
62 });
64 // The OnClick handler for receipt display.
65 function show_receipt(pid,timestamp) {
66 dlgopen('../patient_file/front_payment.php?receipt=1&patient=' + pid +
67 '&time=' + timestamp, '_blank', 550, 400);
70 </script>
72 <style type="text/css">
73 /* specifically include & exclude from printing */
74 @media print {
75 #report_parameters {
76 visibility: hidden;
77 display: none;
79 #report_parameters_daterange {
80 visibility: visible;
81 display: inline;
83 #report_results {
84 margin-top: 30px;
88 /* specifically exclude some from the screen */
89 @media screen {
90 #report_parameters_daterange {
91 visibility: hidden;
92 display: none;
95 </style>
96 </head>
98 <body class="body_top">
100 <!-- Required for the popup date selectors -->
101 <div id="overDiv" style="position:absolute; visibility:hidden; z-index:1000;"></div>
103 <span class='title'><?php xl('Report', 'e'); ?> - <?php xl('Front Office Receipts', 'e'); ?></span>
105 <div id="report_parameters_daterange">
106 <?php echo date("d F Y", strtotime($form_from_date)) ." &nbsp; to &nbsp; ". date("d F Y", strtotime($form_to_date)); ?>
107 </div>
109 <form name='theform' method='post' action='front_receipts_report.php' id='theform'>
111 <div id="report_parameters">
113 <input type='hidden' name='form_refresh' id='form_refresh' value=''/>
115 <table>
116 <tr>
117 <td width='410px'>
118 <div style='float:left'>
120 <table class='text'>
121 <tr>
122 <td class='control-label'>
123 <?php xl('From', 'e'); ?>:
124 </td>
125 <td>
126 <input type='text' class='datepicker form-control' name='form_from_date' id="form_from_date" size='10' value='<?php echo attr($form_from_date) ?>'
127 title='yyyy-mm-dd'>
128 </td>
129 <td class='control-label'>
130 <?php xl('To', 'e'); ?>:
131 </td>
132 <td>
133 <input type='text' class='datepicker form-control' name='form_to_date' id="form_to_date" size='10' value='<?php echo attr($form_to_date) ?>'
134 title='yyyy-mm-dd'>
135 </td>
136 </tr>
137 </table>
139 </div>
141 </td>
142 <td align='left' valign='middle' height="100%">
143 <table style='border-left:1px solid; width:100%; height:100%' >
144 <tr>
145 <td>
146 <div class="text-center">
147 <div class="btn-group" role="group">
148 <a href='#' class='btn btn-default btn-save' onclick='$("#form_refresh").attr("value","true"); $("#theform").submit();'>
149 <?php echo xlt('Submit'); ?>
150 </a>
151 <?php if ($_POST['form_refresh']) { ?>
152 <a href='#' class='btn btn-default btn-print' id='printbutton'>
153 <?php echo xlt('Print'); ?>
154 </a>
155 <?php } ?>
156 </div>
157 </div>
158 </td>
159 </tr>
160 </table>
161 </td>
162 </tr>
163 </table>
164 </div> <!-- end of parameters -->
166 <?php
167 if ($_POST['form_refresh'] || $_POST['form_orderby']) {
169 <div id="report_results">
170 <table>
171 <thead>
172 <th> <?php xl('Time', 'e'); ?> </th>
173 <th> <?php xl('Patient', 'e'); ?> </th>
174 <th> <?php xl('ID', 'e'); ?> </th>
175 <th> <?php xl('Method', 'e'); ?> </th>
176 <th> <?php xl('Source', 'e'); ?> </th>
177 <th align='right'> <?php xl('Today', 'e'); ?> </th>
178 <th align='right'> <?php xl('Previous', 'e'); ?> </th>
179 <th align='right'> <?php xl('Total', 'e'); ?> </th>
180 </thead>
181 <tbody>
182 <?php
183 if (true || $_POST['form_refresh']) {
184 $total1 = 0.00;
185 $total2 = 0.00;
187 $query = "SELECT r.pid, r.dtime, " .
188 "SUM(r.amount1) AS amount1, " .
189 "SUM(r.amount2) AS amount2, " .
190 "MAX(r.method) AS method, " .
191 "MAX(r.source) AS source, " .
192 "MAX(r.user) AS user, " .
193 "p.fname, p.mname, p.lname, p.pubpid " .
194 "FROM payments AS r " .
195 "LEFT OUTER JOIN patient_data AS p ON " .
196 "p.pid = r.pid " .
197 "WHERE " .
198 "r.dtime >= '$from_date 00:00:00' AND " .
199 "r.dtime <= '$to_date 23:59:59' " .
200 "GROUP BY r.dtime, r.pid ORDER BY r.dtime, r.pid";
202 // echo "<!-- $query -->\n"; // debugging
203 $res = sqlStatement($query);
205 while ($row = sqlFetchArray($res)) {
206 // Make the timestamp URL-friendly.
207 $timestamp = preg_replace('/[^0-9]/', '', $row['dtime']);
209 <tr>
210 <td nowrap>
211 <a href="javascript:show_receipt(<?php echo $row['pid'] . ",'$timestamp'"; ?>)">
212 <?php echo oeFormatShortDate(substr($row['dtime'], 0, 10)) . substr($row['dtime'], 10, 6); ?>
213 </a>
214 </td>
215 <td>
216 <?php echo $row['lname'] . ', ' . $row['fname'] . ' ' . $row['mname'] ?>
217 </td>
218 <td>
219 <?php echo $row['pubpid'] ?>
220 </td>
221 <td>
222 <?php echo $row['method'] ?>
223 </td>
224 <td>
225 <?php echo $row['source'] ?>
226 </td>
227 <td align='right'>
228 <?php echo bucks($row['amount1']) ?>
229 </td>
230 <td align='right'>
231 <?php echo bucks($row['amount2']) ?>
232 </td>
233 <td align='right'>
234 <?php echo bucks($row['amount1'] + $row['amount2']) ?>
235 </td>
236 </tr>
237 <?php
238 $total1 += $row['amount1'];
239 $total2 += $row['amount2'];
243 <tr>
244 <td colspan='8'>
245 &nbsp;
246 </td>
247 </tr>
249 <tr class="report_totals">
250 <td colspan='5'>
251 <?php xl('Totals', 'e'); ?>
252 </td>
253 <td align='right'>
254 <?php echo bucks($total1) ?>
255 </td>
256 <td align='right'>
257 <?php echo bucks($total2) ?>
258 </td>
259 <td align='right'>
260 <?php echo bucks($total1 + $total2) ?>
261 </td>
262 </tr>
264 <?php
267 </tbody>
268 </table>
269 </div> <!-- end of results -->
270 <?php } else { ?>
271 <div class='text'>
272 <?php echo xl('Please input search criteria above, and click Submit to view results.', 'e'); ?>
273 </div>
274 <?php } ?>
276 </form>
277 </body>
278 </html>