3 * This report lists front office receipts for a given date range.
6 * @link http://www.open-emr.org
7 * @author Rod Roark <rod@sunsetsystems.com>
8 * @author Brady Miller <brady.g.miller@gmail.com>
9 * @copyright Copyright (c) 2006-2015 Rod Roark <rod@sunsetsystems.com>
10 * @copyright Copyright (c) 2017-2018 Brady Miller <brady.g.miller@gmail.com>
11 * @license https://github.com/openemr/openemr/blob/master/LICENSE GNU General Public License 3
15 require_once("../globals.php");
16 require_once("$srcdir/patient.inc");
18 use OpenEMR\Core\Header
;
20 $from_date = (isset($_POST['form_from_date'])) ?
DateToYYYYMMDD($_POST['form_from_date']) : date('Y-m-d');
21 $to_date = (isset($_POST['form_to_date'])) ?
DateToYYYYMMDD($_POST['form_to_date']) : date('Y-m-d');
25 return ($amt != 0.00) ?
oeFormatMoney($amt) : '';
31 <title
><?php
echo xlt('Front Office Receipts'); ?
></title
>
33 <?php Header
::setupHeader('datetime-picker'); ?
>
35 <script language
="JavaScript">
36 <?php
require($GLOBALS['srcdir'] . "/restoreSession.php"); ?
>
38 $
(document
).ready(function() {
39 var win
= top
.printLogSetup ? top
: opener
.top
;
40 win
.printLogSetup(document
.getElementById('printbutton'));
42 $
('.datepicker').datetimepicker({
43 <?php
$datetimepicker_timepicker = false; ?
>
44 <?php
$datetimepicker_showseconds = false; ?
>
45 <?php
$datetimepicker_formatInput = true; ?
>
46 <?php
require($GLOBALS['srcdir'] . '/js/xl/jquery-datetimepicker-2-5-4.js.php'); ?
>
47 <?php
// can add any additional javascript settings to datetimepicker here; need to prepend first setting with a comma ?>
51 // The OnClick handler for receipt display.
52 function show_receipt(pid
,timestamp
) {
53 dlgopen('../patient_file/front_payment.php?receipt=1&patient=' + pid +
54 '&time=' + timestamp
, '_blank', 550, 400, '', '', {
60 <style type
="text/css">
61 /* specifically include & exclude from printing */
67 #report_parameters_daterange {
76 /* specifically exclude some from the screen */
78 #report_parameters_daterange {
86 <body
class="body_top">
88 <!-- Required
for the popup date selectors
-->
89 <div id
="overDiv" style
="position:absolute; visibility:hidden; z-index:1000;"></div
>
91 <span
class='title'><?php
echo xlt('Report'); ?
> - <?php
echo xlt('Front Office Receipts'); ?
></span
>
93 <div id
="report_parameters_daterange">
94 <?php
echo text(oeFormatShortDate($from_date)) ." " . xlt("to") . " ". text(oeFormatShortDate($to_date)); ?
>
97 <form name
='theform' method
='post' action
='front_receipts_report.php' id
='theform' onsubmit
='return top.restoreSession()'>
99 <div id
="report_parameters">
101 <input type
='hidden' name
='form_refresh' id
='form_refresh' value
=''/>
106 <div style
='float:left'>
110 <td
class='control-label'>
111 <?php
echo xlt('From'); ?
>:
114 <input type
='text' class='datepicker form-control' name
='form_from_date' id
="form_from_date" size
='10' value
='<?php echo attr(oeFormatShortDate($from_date)); ?>'>
116 <td
class='control-label'>
117 <?php
xl('To', 'e'); ?
>:
120 <input type
='text' class='datepicker form-control' name
='form_to_date' id
="form_to_date" size
='10' value
='<?php echo attr(oeFormatShortDate($to_date)); ?>'>
128 <td align
='left' valign
='middle' height
="100%">
129 <table style
='border-left:1px solid; width:100%; height:100%' >
132 <div
class="text-center">
133 <div
class="btn-group" role
="group">
134 <a href
='#' class='btn btn-default btn-save' onclick
='$("#form_refresh").attr("value","true"); $("#theform").submit();'>
135 <?php
echo xlt('Submit'); ?
>
137 <?php
if ($_POST['form_refresh']) { ?
>
138 <a href
='#' class='btn btn-default btn-print' id
='printbutton'>
139 <?php
echo xlt('Print'); ?
>
150 </div
> <!-- end of parameters
-->
153 if ($_POST['form_refresh'] ||
$_POST['form_orderby']) {
155 <div id
="report_results">
158 <th
> <?php
echo xlt('Time'); ?
> </th
>
159 <th
> <?php
echo xlt('Patient'); ?
> </th
>
160 <th
> <?php
echo xlt('ID'); ?
> </th
>
161 <th
> <?php
echo xlt('Method'); ?
> </th
>
162 <th
> <?php
echo xlt('Source'); ?
> </th
>
163 <th align
='right'> <?php
echo xlt('Today'); ?
> </th
>
164 <th align
='right'> <?php
echo xlt('Previous'); ?
> </th
>
165 <th align
='right'> <?php
echo xlt('Total'); ?
> </th
>
169 if (true ||
$_POST['form_refresh']) {
173 $query = "SELECT r.pid, r.dtime, " .
174 "SUM(r.amount1) AS amount1, " .
175 "SUM(r.amount2) AS amount2, " .
176 "MAX(r.method) AS method, " .
177 "MAX(r.source) AS source, " .
178 "MAX(r.user) AS user, " .
179 "p.fname, p.mname, p.lname, p.pubpid " .
180 "FROM payments AS r " .
181 "LEFT OUTER JOIN patient_data AS p ON " .
184 "r.dtime >= ? AND " .
186 "GROUP BY r.dtime, r.pid ORDER BY r.dtime, r.pid";
188 // echo "<!-- $query -->\n"; // debugging
189 $res = sqlStatement($query, array($from_date.' 00:00:00', $to_date.' 23:59:59'));
191 while ($row = sqlFetchArray($res)) {
192 // Make the timestamp URL-friendly.
193 $timestamp = preg_replace('/[^0-9]/', '', $row['dtime']);
197 <a href
="javascript:show_receipt(<?php echo $row['pid'] . ",'$timestamp'"; ?>)">
198 <?php
echo text(oeFormatShortDate(substr($row['dtime'], 0, 10))) . text(substr($row['dtime'], 10, 6)); ?
>
202 <?php
echo text($row['lname']) . ', ' . text($row['fname']) . ' ' . text($row['mname']); ?
>
205 <?php
echo text($row['pubpid']); ?
>
208 <?php
echo text($row['method']); ?
>
211 <?php
echo text($row['source']); ?
>
214 <?php
echo text(bucks($row['amount1'])); ?
>
217 <?php
echo text(bucks($row['amount2'])); ?
>
220 <?php
echo text(bucks($row['amount1'] +
$row['amount2'])); ?
>
224 $total1 +
= $row['amount1'];
225 $total2 +
= $row['amount2'];
235 <tr
class="report_totals">
237 <?php
echo xlt('Totals'); ?
>
240 <?php
echo text(bucks($total1)); ?
>
243 <?php
echo text(bucks($total2)); ?
>
246 <?php
echo text(bucks($total1 +
$total2)); ?
>
255 </div
> <!-- end of results
-->
258 <?php
echo xlt('Please input search criteria above, and click Submit to view results.'); ?
>