2 // Copyright (C) 2006-2010 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 // The OnClick handler for receipt display.
38 function show_receipt(pid
,timestamp
) {
39 dlgopen('../patient_file/front_payment.php?receipt=1&patient=' + pid +
40 '&time=' + timestamp
, '_blank', 550, 400);
45 <link rel
='stylesheet' href
='<?php echo $css_header ?>' type
='text/css'>
46 <style type
="text/css">
47 /* specifically include & exclude from printing */
53 #report_parameters_daterange {
62 /* specifically exclude some from the screen */
64 #report_parameters_daterange {
72 <body
class="body_top">
74 <!-- Required
for the popup date selectors
-->
75 <div id
="overDiv" style
="position:absolute; visibility:hidden; z-index:1000;"></div
>
77 <span
class='title'><?php
xl('Report','e'); ?
> - <?php
xl('Front Office Receipts','e'); ?
></span
>
79 <div id
="report_parameters_daterange">
80 <?php
echo date("d F Y", strtotime($form_from_date)) ." to ". date("d F Y", strtotime($form_to_date)); ?
>
83 <form name
='theform' method
='post' action
='front_receipts_report.php' id
='theform'>
85 <div id
="report_parameters">
87 <input type
='hidden' name
='form_refresh' id
='form_refresh' value
=''/>
92 <div style
='float:left'>
97 <?php
xl('From','e'); ?
>:
100 <input type
='text' name
='form_from_date' id
="form_from_date" size
='10' value
='<?php echo $form_from_date ?>'
101 onkeyup
='datekeyup(this,mypcc)' onblur
='dateblur(this,mypcc)' title
='yyyy-mm-dd'>
102 <img src
='../pic/show_calendar.gif' align
='absbottom' width
='24' height
='22'
103 id
='img_from_date' border
='0' alt
='[?]' style
='cursor:pointer'
104 title
='<?php xl('Click here to choose a date
','e
'); ?>'>
107 <?php
xl('To','e'); ?
>:
110 <input type
='text' name
='form_to_date' id
="form_to_date" size
='10' value
='<?php echo $form_to_date ?>'
111 onkeyup
='datekeyup(this,mypcc)' onblur
='dateblur(this,mypcc)' title
='yyyy-mm-dd'>
112 <img src
='../pic/show_calendar.gif' align
='absbottom' width
='24' height
='22'
113 id
='img_to_date' border
='0' alt
='[?]' style
='cursor:pointer'
114 title
='<?php xl('Click here to choose a date
','e
'); ?>'>
122 <td align
='left' valign
='middle' height
="100%">
123 <table style
='border-left:1px solid; width:100%; height:100%' >
126 <div style
='margin-left:15px'>
127 <a href
='#' class='css_button' onclick
='$("#form_refresh").attr("value","true"); $("#theform").submit();'>
129 <?php
xl('Submit','e'); ?
>
133 <?php
if ($_POST['form_refresh']) { ?
>
134 <a href
='#' class='css_button' onclick
='window.print()'>
136 <?php
xl('Print','e'); ?
>
147 </div
> <!-- end of parameters
-->
150 if ($_POST['form_refresh'] ||
$_POST['form_orderby']) {
152 <div id
="report_results">
155 <th
> <?php
xl('Time','e'); ?
> </th
>
156 <th
> <?php
xl('Patient','e'); ?
> </th
>
157 <th
> <?php
xl('ID','e'); ?
> </th
>
158 <th
> <?php
xl('Method','e'); ?
> </th
>
159 <th
> <?php
xl('Source','e'); ?
> </th
>
160 <th align
='right'> <?php
xl('Today','e'); ?
> </th
>
161 <th align
='right'> <?php
xl('Previous','e'); ?
> </th
>
162 <th align
='right'> <?php
xl('Total','e'); ?
> </th
>
166 if (true ||
$_POST['form_refresh']) {
170 $query = "SELECT r.pid, r.dtime, " .
171 "SUM(r.amount1) AS amount1, " .
172 "SUM(r.amount2) AS amount2, " .
173 "MAX(r.method) AS method, " .
174 "MAX(r.source) AS source, " .
175 "MAX(r.user) AS user, " .
176 "p.fname, p.mname, p.lname, p.pubpid " .
177 "FROM payments AS r " .
178 "LEFT OUTER JOIN patient_data AS p ON " .
181 "r.dtime >= '$from_date 00:00:00' AND " .
182 "r.dtime <= '$to_date 23:59:59' " .
183 "GROUP BY r.dtime, r.pid ORDER BY r.dtime, r.pid";
185 // echo "<!-- $query -->\n"; // debugging
186 $res = sqlStatement($query);
188 while ($row = sqlFetchArray($res)) {
189 // Make the timestamp URL-friendly.
190 $timestamp = preg_replace('/[^0-9]/', '', $row['dtime']);
194 <a href
="javascript:show_receipt(<?php echo $row['pid'] . ",'$timestamp'"; ?>)">
195 <?php
echo oeFormatShortDate(substr($row['dtime'], 0, 10)) . substr($row['dtime'], 10, 6); ?
>
199 <?php
echo $row['lname'] . ', ' . $row['fname'] . ' ' . $row['mname'] ?
>
202 <?php
echo $row['pubpid'] ?
>
205 <?php
echo $row['method'] ?
>
208 <?php
echo $row['source'] ?
>
211 <?php
echo bucks($row['amount1']) ?
>
214 <?php
echo bucks($row['amount2']) ?
>
217 <?php
echo bucks($row['amount1'] +
$row['amount2']) ?
>
221 $total1 +
= $row['amount1'];
222 $total2 +
= $row['amount2'];
232 <tr
class="report_totals">
234 <?php
xl('Totals','e'); ?
>
237 <?php
echo bucks($total1) ?
>
240 <?php
echo bucks($total2) ?
>
243 <?php
echo bucks($total1 +
$total2) ?
>
252 </div
> <!-- end of results
-->
255 <?php
echo xl('Please input search criteria above, and click Submit to view results.', 'e' ); ?
>
261 <!-- stuff
for the popup calendar
-->
262 <style type
="text/css">@import
url(../../library
/dynarch_calendar
.css
);</style
>
263 <script type
="text/javascript" src
="../../library/dynarch_calendar.js"></script
>
264 <?php
include_once("{$GLOBALS['srcdir']}/dynarch_calendar_en.inc.php"); ?
>
265 <script type
="text/javascript" src
="../../library/dynarch_calendar_setup.js"></script
>
266 <script language
="Javascript">
267 Calendar
.setup({inputField
:"form_from_date", ifFormat
:"%Y-%m-%d", button
:"img_from_date"});
268 Calendar
.setup({inputField
:"form_to_date", ifFormat
:"%Y-%m-%d", button
:"img_to_date"});