2 // Copyright (C) 2006-2015 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 // This report lists front office receipts for a given date range.
11 require_once("../globals.php");
12 require_once("$srcdir/patient.inc");
13 require_once("$srcdir/formatting.inc.php");
15 $from_date = fixDate($_POST['form_from_date'], date('Y-m-d'));
16 $to_date = fixDate($_POST['form_to_date'], date('Y-m-d'));
18 function bucks($amt) {
19 return ($amt != 0.00) ?
oeFormatMoney($amt) : '';
24 <?php
html_header_show();?
>
25 <title
><?php
xl('Front Office Receipts','e'); ?
></title
>
26 <script type
="text/javascript" src
="../../library/overlib_mini.js"></script
>
27 <script type
="text/javascript" src
="../../library/textformat.js"></script
>
28 <script type
="text/javascript" src
="../../library/dialog.js"></script
>
29 <script type
="text/javascript" src
="../../library/js/jquery.1.3.2.js"></script
>
31 <script language
="JavaScript">
33 <?php
require($GLOBALS['srcdir'] . "/restoreSession.php"); ?
>
35 var mypcc
= '<?php echo $GLOBALS['phone_country_code
'] ?>';
37 $
(document
).ready(function() {
38 var win
= top
.printLogSetup ? top
: opener
.top
;
39 win
.printLogSetup(document
.getElementById('printbutton'));
42 // The OnClick handler for receipt display.
43 function show_receipt(pid
,timestamp
) {
44 dlgopen('../patient_file/front_payment.php?receipt=1&patient=' + pid +
45 '&time=' + timestamp
, '_blank', 550, 400);
50 <link rel
='stylesheet' href
='<?php echo $css_header ?>' type
='text/css'>
51 <style type
="text/css">
52 /* specifically include & exclude from printing */
58 #report_parameters_daterange {
67 /* specifically exclude some from the screen */
69 #report_parameters_daterange {
77 <body
class="body_top">
79 <!-- Required
for the popup date selectors
-->
80 <div id
="overDiv" style
="position:absolute; visibility:hidden; z-index:1000;"></div
>
82 <span
class='title'><?php
xl('Report','e'); ?
> - <?php
xl('Front Office Receipts','e'); ?
></span
>
84 <div id
="report_parameters_daterange">
85 <?php
echo date("d F Y", strtotime($form_from_date)) ." to ". date("d F Y", strtotime($form_to_date)); ?
>
88 <form name
='theform' method
='post' action
='front_receipts_report.php' id
='theform'>
90 <div id
="report_parameters">
92 <input type
='hidden' name
='form_refresh' id
='form_refresh' value
=''/>
97 <div style
='float:left'>
102 <?php
xl('From','e'); ?
>:
105 <input type
='text' name
='form_from_date' id
="form_from_date" size
='10' value
='<?php echo attr($form_from_date) ?>'
106 onkeyup
='datekeyup(this,mypcc)' onblur
='dateblur(this,mypcc)' title
='yyyy-mm-dd'>
107 <img src
='../pic/show_calendar.gif' align
='absbottom' width
='24' height
='22'
108 id
='img_from_date' border
='0' alt
='[?]' style
='cursor:pointer'
109 title
='<?php xl('Click here to choose a date
','e
'); ?>'>
112 <?php
xl('To','e'); ?
>:
115 <input type
='text' name
='form_to_date' id
="form_to_date" size
='10' value
='<?php echo attr($form_to_date) ?>'
116 onkeyup
='datekeyup(this,mypcc)' onblur
='dateblur(this,mypcc)' title
='yyyy-mm-dd'>
117 <img src
='../pic/show_calendar.gif' align
='absbottom' width
='24' height
='22'
118 id
='img_to_date' border
='0' alt
='[?]' style
='cursor:pointer'
119 title
='<?php xl('Click here to choose a date
','e
'); ?>'>
127 <td align
='left' valign
='middle' height
="100%">
128 <table style
='border-left:1px solid; width:100%; height:100%' >
131 <div style
='margin-left:15px'>
132 <a href
='#' class='css_button' onclick
='$("#form_refresh").attr("value","true"); $("#theform").submit();'>
134 <?php
xl('Submit','e'); ?
>
138 <?php
if ($_POST['form_refresh']) { ?
>
139 <a href
='#' class='css_button' id
='printbutton'>
141 <?php
xl('Print','e'); ?
>
152 </div
> <!-- end of parameters
-->
155 if ($_POST['form_refresh'] ||
$_POST['form_orderby']) {
157 <div id
="report_results">
160 <th
> <?php
xl('Time','e'); ?
> </th
>
161 <th
> <?php
xl('Patient','e'); ?
> </th
>
162 <th
> <?php
xl('ID','e'); ?
> </th
>
163 <th
> <?php
xl('Method','e'); ?
> </th
>
164 <th
> <?php
xl('Source','e'); ?
> </th
>
165 <th align
='right'> <?php
xl('Today','e'); ?
> </th
>
166 <th align
='right'> <?php
xl('Previous','e'); ?
> </th
>
167 <th align
='right'> <?php
xl('Total','e'); ?
> </th
>
171 if (true ||
$_POST['form_refresh']) {
175 $query = "SELECT r.pid, r.dtime, " .
176 "SUM(r.amount1) AS amount1, " .
177 "SUM(r.amount2) AS amount2, " .
178 "MAX(r.method) AS method, " .
179 "MAX(r.source) AS source, " .
180 "MAX(r.user) AS user, " .
181 "p.fname, p.mname, p.lname, p.pubpid " .
182 "FROM payments AS r " .
183 "LEFT OUTER JOIN patient_data AS p ON " .
186 "r.dtime >= '$from_date 00:00:00' AND " .
187 "r.dtime <= '$to_date 23:59:59' " .
188 "GROUP BY r.dtime, r.pid ORDER BY r.dtime, r.pid";
190 // echo "<!-- $query -->\n"; // debugging
191 $res = sqlStatement($query);
193 while ($row = sqlFetchArray($res)) {
194 // Make the timestamp URL-friendly.
195 $timestamp = preg_replace('/[^0-9]/', '', $row['dtime']);
199 <a href
="javascript:show_receipt(<?php echo $row['pid'] . ",'$timestamp'"; ?>)">
200 <?php
echo oeFormatShortDate(substr($row['dtime'], 0, 10)) . substr($row['dtime'], 10, 6); ?
>
204 <?php
echo $row['lname'] . ', ' . $row['fname'] . ' ' . $row['mname'] ?
>
207 <?php
echo $row['pubpid'] ?
>
210 <?php
echo $row['method'] ?
>
213 <?php
echo $row['source'] ?
>
216 <?php
echo bucks($row['amount1']) ?
>
219 <?php
echo bucks($row['amount2']) ?
>
222 <?php
echo bucks($row['amount1'] +
$row['amount2']) ?
>
226 $total1 +
= $row['amount1'];
227 $total2 +
= $row['amount2'];
237 <tr
class="report_totals">
239 <?php
xl('Totals','e'); ?
>
242 <?php
echo bucks($total1) ?
>
245 <?php
echo bucks($total2) ?
>
248 <?php
echo bucks($total1 +
$total2) ?
>
257 </div
> <!-- end of results
-->
260 <?php
echo xl('Please input search criteria above, and click Submit to view results.', 'e' ); ?
>
266 <!-- stuff
for the popup calendar
-->
267 <style type
="text/css">@import
url(../../library
/dynarch_calendar
.css
);</style
>
268 <script type
="text/javascript" src
="../../library/dynarch_calendar.js"></script
>
269 <?php
include_once("{$GLOBALS['srcdir']}/dynarch_calendar_en.inc.php"); ?
>
270 <script type
="text/javascript" src
="../../library/dynarch_calendar_setup.js"></script
>
271 <script language
="Javascript">
272 Calendar
.setup({inputField
:"form_from_date", ifFormat
:"%Y-%m-%d", button
:"img_from_date"});
273 Calendar
.setup({inputField
:"form_to_date", ifFormat
:"%Y-%m-%d", button
:"img_to_date"});