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>;.
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'));
35 return ($amt != 0.00) ?
oeFormatMoney($amt) : '';
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 ?>
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, '', '', {
74 <style type
="text/css">
75 /* specifically include & exclude from printing */
81 #report_parameters_daterange {
90 /* specifically exclude some from the screen */
92 #report_parameters_daterange {
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)) ." to ". date("d F Y", strtotime($form_to_date)); ?
>
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
=''/>
120 <div style
='float:left'>
124 <td
class='control-label'>
125 <?php
xl('From', 'e'); ?
>:
128 <input type
='text' class='datepicker form-control' name
='form_from_date' id
="form_from_date" size
='10' value
='<?php echo attr($form_from_date) ?>'
131 <td
class='control-label'>
132 <?php
xl('To', 'e'); ?
>:
135 <input type
='text' class='datepicker form-control' name
='form_to_date' id
="form_to_date" size
='10' value
='<?php echo attr($form_to_date) ?>'
144 <td align
='left' valign
='middle' height
="100%">
145 <table style
='border-left:1px solid; width:100%; height:100%' >
148 <div
class="text-center">
149 <div
class="btn-group" role
="group">
150 <a href
='#' class='btn btn-default btn-save' onclick
='$("#form_refresh").attr("value","true"); $("#theform").submit();'>
151 <?php
echo xlt('Submit'); ?
>
153 <?php
if ($_POST['form_refresh']) { ?
>
154 <a href
='#' class='btn btn-default btn-print' id
='printbutton'>
155 <?php
echo xlt('Print'); ?
>
166 </div
> <!-- end of parameters
-->
169 if ($_POST['form_refresh'] ||
$_POST['form_orderby']) {
171 <div id
="report_results">
174 <th
> <?php
xl('Time', 'e'); ?
> </th
>
175 <th
> <?php
xl('Patient', 'e'); ?
> </th
>
176 <th
> <?php
xl('ID', 'e'); ?
> </th
>
177 <th
> <?php
xl('Method', 'e'); ?
> </th
>
178 <th
> <?php
xl('Source', 'e'); ?
> </th
>
179 <th align
='right'> <?php
xl('Today', 'e'); ?
> </th
>
180 <th align
='right'> <?php
xl('Previous', 'e'); ?
> </th
>
181 <th align
='right'> <?php
xl('Total', 'e'); ?
> </th
>
185 if (true ||
$_POST['form_refresh']) {
189 $query = "SELECT r.pid, r.dtime, " .
190 "SUM(r.amount1) AS amount1, " .
191 "SUM(r.amount2) AS amount2, " .
192 "MAX(r.method) AS method, " .
193 "MAX(r.source) AS source, " .
194 "MAX(r.user) AS user, " .
195 "p.fname, p.mname, p.lname, p.pubpid " .
196 "FROM payments AS r " .
197 "LEFT OUTER JOIN patient_data AS p ON " .
200 "r.dtime >= '$from_date 00:00:00' AND " .
201 "r.dtime <= '$to_date 23:59:59' " .
202 "GROUP BY r.dtime, r.pid ORDER BY r.dtime, r.pid";
204 // echo "<!-- $query -->\n"; // debugging
205 $res = sqlStatement($query);
207 while ($row = sqlFetchArray($res)) {
208 // Make the timestamp URL-friendly.
209 $timestamp = preg_replace('/[^0-9]/', '', $row['dtime']);
213 <a href
="javascript:show_receipt(<?php echo $row['pid'] . ",'$timestamp'"; ?>)">
214 <?php
echo text(oeFormatShortDate(substr($row['dtime'], 0, 10))) . substr($row['dtime'], 10, 6); ?
>
218 <?php
echo $row['lname'] . ', ' . $row['fname'] . ' ' . $row['mname'] ?
>
221 <?php
echo $row['pubpid'] ?
>
224 <?php
echo $row['method'] ?
>
227 <?php
echo $row['source'] ?
>
230 <?php
echo bucks($row['amount1']) ?
>
233 <?php
echo bucks($row['amount2']) ?
>
236 <?php
echo bucks($row['amount1'] +
$row['amount2']) ?
>
240 $total1 +
= $row['amount1'];
241 $total2 +
= $row['amount2'];
251 <tr
class="report_totals">
253 <?php
xl('Totals', 'e'); ?
>
256 <?php
echo bucks($total1) ?
>
259 <?php
echo bucks($total2) ?
>
262 <?php
echo bucks($total1 +
$total2) ?
>
271 </div
> <!-- end of results
-->
274 <?php
echo xl('Please input search criteria above, and click Submit to view results.', 'e'); ?
>