2 // Copyright (C) 2006-2007 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 include_once("../globals.php");
12 include_once("$srcdir/patient.inc");
14 $from_date = fixDate($_POST['form_from_date'], date('Y-m-d'));
15 $to_date = fixDate($_POST['form_to_date'], date('Y-m-d'));
17 function bucks($amt) {
18 return ($amt != 0.00) ?
sprintf('%.2f', $amt) : '';
23 <?php
html_header_show();?
>
24 <title
><?php
xl('Front Office Receipts','e'); ?
></title
>
25 <script type
="text/javascript" src
="../../library/overlib_mini.js"></script
>
26 <script type
="text/javascript" src
="../../library/textformat.js"></script
>
27 <script type
="text/javascript" src
="../../library/dialog.js"></script
>
28 <script language
="JavaScript">
30 <?php
require($GLOBALS['srcdir'] . "/restoreSession.php"); ?
>
32 var mypcc
= '<?php echo $GLOBALS['phone_country_code
'] ?>';
34 // The OnClick handler for receipt display.
35 function show_receipt(pid
,timestamp
) {
36 dlgopen('../patient_file/front_payment.php?receipt=1&patient=' + pid +
37 '&time=' + timestamp
, '_blank', 550, 400);
43 <link rel
='stylesheet' href
='<?php echo $css_header ?>' type
='text/css'>
44 <style type
="text/css">
46 /* specifically include & exclude from printing */
48 #recptreport_parameters {
52 #recptreport_parameters_daterange {
58 /* specifically exclude some from the screen */
60 #recptreport_parameters_daterange {
66 #recptreport_parameters {
68 background
-color
: #ddf;
70 #recptreport_parameters table {
72 border
-collapse
: collapse
;
74 #recptreport_parameters table td {
78 #recptreport_results {
82 #recptreport_results table {
83 border
: 1px solid black
;
85 border
-collapse
: collapse
;
87 #recptreport_results table thead {
88 display
: table
-header
-group
;
89 background
-color
: #ddd;
91 #recptreport_results table th {
92 border
-bottom
: 1px solid black
;
94 #recptreport_results table td {
97 border
-bottom
: 1px solid
#eee;
99 .recptreport_totals td
{
100 background
-color
: #77ff77;
106 <body
class="body_top">
108 <!-- Required
for the popup date selectors
-->
109 <div id
="overDiv" style
="position:absolute; visibility:hidden; z-index:1000;"></div
>
113 <h2
><?php
xl('Front Office Receipts','e'); ?
></h2
>
115 <div id
="recptreport_parameters_daterange">
116 <?php
echo date("d F Y", strtotime($form_from_date)) ." to ". date("d F Y", strtotime($form_to_date)); ?
>
119 <div id
="recptreport_parameters">
121 <form name
='theform' method
='post' action
='front_receipts_report.php'>
126 <?php
xl('From','e'); ?
>:
127 <input type
='text' name
='form_from_date' id
="form_from_date" size
='10' value
='<?php echo $from_date ?>'
128 onkeyup
='datekeyup(this,mypcc)' onblur
='dateblur(this,mypcc)' title
='yyyy-mm-dd'>
129 <img src
='../pic/show_calendar.gif' align
='absbottom' width
='24' height
='22'
130 id
='img_from_date' border
='0' alt
='[?]' style
='cursor:pointer'
131 title
='<?php xl('Click here to choose a date
','e
'); ?>'>
132  
;<?php
xl('To','e'); ?
>:
133 <input type
='text' name
='form_to_date' id
="form_to_date" size
='10' value
='<?php echo $to_date ?>'
134 onkeyup
='datekeyup(this,mypcc)' onblur
='dateblur(this,mypcc)' title
='yyyy-mm-dd'>
135 <img src
='../pic/show_calendar.gif' align
='absbottom' width
='24' height
='22'
136 id
='img_to_date' border
='0' alt
='[?]' style
='cursor:pointer'
137 title
='<?php xl('Click here to choose a date
','e
'); ?>'>
139 <input type
='submit' name
='form_refresh' value
=<?php
xl('Refresh','e'); ?
>>
141 <input type
='button' value
='<?php xl('Print','e
'); ?>' onclick
='window.print()' />
145 </div
> <!-- end of parameters
-->
147 <div id
="recptreport_results">
150 <th
> <?php
xl('Time','e'); ?
> </th
>
151 <th
> <?php
xl('Patient','e'); ?
> </th
>
152 <th
> <?php
xl('ID','e'); ?
> </th
>
153 <th
> <?php
xl('Method','e'); ?
> </th
>
154 <th
> <?php
xl('Source','e'); ?
> </th
>
155 <th align
='right'> <?php
xl('Today','e'); ?
> </th
>
156 <th align
='right'> <?php
xl('Previous','e'); ?
> </th
>
157 <th align
='right'> <?php
xl('Total','e'); ?
> </th
>
161 if (true ||
$_POST['form_refresh']) {
165 $query = "SELECT r.pid, r.dtime, " .
166 "SUM(r.amount1) AS amount1, " .
167 "SUM(r.amount2) AS amount2, " .
168 "MAX(r.method) AS method, " .
169 "MAX(r.source) AS source, " .
170 "MAX(r.user) AS user, " .
171 "p.fname, p.mname, p.lname, p.pubpid " .
172 "FROM payments AS r " .
173 "LEFT OUTER JOIN patient_data AS p ON " .
176 "r.dtime >= '$from_date 00:00:00' AND " .
177 "r.dtime <= '$to_date 23:59:59' " .
178 "GROUP BY r.dtime, r.pid ORDER BY r.dtime, r.pid";
180 // echo "<!-- $query -->\n"; // debugging
181 $res = sqlStatement($query);
183 while ($row = sqlFetchArray($res)) {
184 // Make the timestamp URL-friendly.
185 $timestamp = preg_replace('/[^0-9]/', '', $row['dtime']);
189 <a href
='' onclick
="return show_receipt(<?php echo $row['pid'] . ",'$timestamp'"; ?>)">
190 <?php
echo substr($row['dtime'], 0, 16); ?
>
194 <?php
echo $row['lname'] . ', ' . $row['fname'] . ' ' . $row['mname'] ?
>
197 <?php
echo $row['pubpid'] ?
>
200 <?php
echo $row['method'] ?
>
203 <?php
echo $row['source'] ?
>
206 <?php
echo bucks($row['amount1']) ?
>
209 <?php
echo bucks($row['amount2']) ?
>
212 <?php
echo bucks($row['amount1'] +
$row['amount2']) ?
>
216 $total1 +
= $row['amount1'];
217 $total2 +
= $row['amount2'];
227 <tr
class="recptreport_totals">
229 <?php
xl('Totals','e'); ?
>
232 <?php
echo bucks($total1) ?
>
235 <?php
echo bucks($total2) ?
>
238 <?php
echo bucks($total1 +
$total2) ?
>
247 </div
> <!-- end of results
-->
251 <!-- stuff
for the popup calendar
-->
252 <style type
="text/css">@import
url(../../library
/dynarch_calendar
.css
);</style
>
253 <script type
="text/javascript" src
="../../library/dynarch_calendar.js"></script
>
254 <script type
="text/javascript" src
="../../library/dynarch_calendar_en.js"></script
>
255 <script type
="text/javascript" src
="../../library/dynarch_calendar_setup.js"></script
>
256 <script language
="Javascript">
257 Calendar
.setup({inputField
:"form_from_date", ifFormat
:"%Y-%m-%d", button
:"img_from_date"});
258 Calendar
.setup({inputField
:"form_to_date", ifFormat
:"%Y-%m-%d", button
:"img_to_date"});