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 type
="text/javascript" src
="../../library/js/jquery.1.3.2.js"></script
>
30 <script language
="JavaScript">
32 <?php
require($GLOBALS['srcdir'] . "/restoreSession.php"); ?
>
34 var mypcc
= '<?php echo $GLOBALS['phone_country_code
'] ?>';
36 // The OnClick handler for receipt display.
37 function show_receipt(pid
,timestamp
) {
38 dlgopen('../patient_file/front_payment.php?receipt=1&patient=' + pid +
39 '&time=' + timestamp
, '_blank', 550, 400);
44 <link rel
='stylesheet' href
='<?php echo $css_header ?>' type
='text/css'>
45 <style type
="text/css">
46 /* specifically include & exclude from printing */
52 #report_parameters_daterange {
61 /* specifically exclude some from the screen */
63 #report_parameters_daterange {
71 <body
class="body_top">
73 <!-- Required
for the popup date selectors
-->
74 <div id
="overDiv" style
="position:absolute; visibility:hidden; z-index:1000;"></div
>
76 <span
class='title'><?php
xl('Report','e'); ?
> - <?php
xl('Front Office Receipts','e'); ?
></span
>
78 <div id
="report_parameters_daterange">
79 <?php
echo date("d F Y", strtotime($form_from_date)) ." to ". date("d F Y", strtotime($form_to_date)); ?
>
82 <form name
='theform' method
='post' action
='front_receipts_report.php' id
='theform'>
84 <div id
="report_parameters">
86 <input type
='hidden' name
='form_refresh' id
='form_refresh' value
=''/>
91 <div style
='float:left'>
96 <?php
xl('From','e'); ?
>:
99 <input type
='text' name
='form_from_date' id
="form_from_date" size
='10' value
='<?php echo $form_from_date ?>'
100 onkeyup
='datekeyup(this,mypcc)' onblur
='dateblur(this,mypcc)' title
='yyyy-mm-dd'>
101 <img src
='../pic/show_calendar.gif' align
='absbottom' width
='24' height
='22'
102 id
='img_from_date' border
='0' alt
='[?]' style
='cursor:pointer'
103 title
='<?php xl('Click here to choose a date
','e
'); ?>'>
106 <?php
xl('To','e'); ?
>:
109 <input type
='text' name
='form_to_date' id
="form_to_date" size
='10' value
='<?php echo $form_to_date ?>'
110 onkeyup
='datekeyup(this,mypcc)' onblur
='dateblur(this,mypcc)' title
='yyyy-mm-dd'>
111 <img src
='../pic/show_calendar.gif' align
='absbottom' width
='24' height
='22'
112 id
='img_to_date' border
='0' alt
='[?]' style
='cursor:pointer'
113 title
='<?php xl('Click here to choose a date
','e
'); ?>'>
121 <td align
='left' valign
='middle' height
="100%">
122 <table style
='border-left:1px solid; width:100%; height:100%' >
125 <div style
='margin-left:15px'>
126 <a href
='#' class='css_button' onclick
='$("#form_refresh").attr("value","true"); $("#theform").submit();'>
128 <?php
xl('Submit','e'); ?
>
132 <?php
if ($_POST['form_refresh']) { ?
>
133 <a href
='#' class='css_button' onclick
='window.print()'>
135 <?php
xl('Print','e'); ?
>
146 </div
> <!-- end of parameters
-->
149 if ($_POST['form_refresh'] ||
$_POST['form_orderby']) {
151 <div id
="report_results">
154 <th
> <?php
xl('Time','e'); ?
> </th
>
155 <th
> <?php
xl('Patient','e'); ?
> </th
>
156 <th
> <?php
xl('ID','e'); ?
> </th
>
157 <th
> <?php
xl('Method','e'); ?
> </th
>
158 <th
> <?php
xl('Source','e'); ?
> </th
>
159 <th align
='right'> <?php
xl('Today','e'); ?
> </th
>
160 <th align
='right'> <?php
xl('Previous','e'); ?
> </th
>
161 <th align
='right'> <?php
xl('Total','e'); ?
> </th
>
165 if (true ||
$_POST['form_refresh']) {
169 $query = "SELECT r.pid, r.dtime, " .
170 "SUM(r.amount1) AS amount1, " .
171 "SUM(r.amount2) AS amount2, " .
172 "MAX(r.method) AS method, " .
173 "MAX(r.source) AS source, " .
174 "MAX(r.user) AS user, " .
175 "p.fname, p.mname, p.lname, p.pubpid " .
176 "FROM payments AS r " .
177 "LEFT OUTER JOIN patient_data AS p ON " .
180 "r.dtime >= '$from_date 00:00:00' AND " .
181 "r.dtime <= '$to_date 23:59:59' " .
182 "GROUP BY r.dtime, r.pid ORDER BY r.dtime, r.pid";
184 // echo "<!-- $query -->\n"; // debugging
185 $res = sqlStatement($query);
187 while ($row = sqlFetchArray($res)) {
188 // Make the timestamp URL-friendly.
189 $timestamp = preg_replace('/[^0-9]/', '', $row['dtime']);
193 <a href
="javascript:show_receipt(<?php echo $row['pid'] . ",'$timestamp'"; ?>)">
194 <?php
echo substr($row['dtime'], 0, 16); ?
>
198 <?php
echo $row['lname'] . ', ' . $row['fname'] . ' ' . $row['mname'] ?
>
201 <?php
echo $row['pubpid'] ?
>
204 <?php
echo $row['method'] ?
>
207 <?php
echo $row['source'] ?
>
210 <?php
echo bucks($row['amount1']) ?
>
213 <?php
echo bucks($row['amount2']) ?
>
216 <?php
echo bucks($row['amount1'] +
$row['amount2']) ?
>
220 $total1 +
= $row['amount1'];
221 $total2 +
= $row['amount2'];
231 <tr
class="report_totals">
233 <?php
xl('Totals','e'); ?
>
236 <?php
echo bucks($total1) ?
>
239 <?php
echo bucks($total2) ?
>
242 <?php
echo bucks($total1 +
$total2) ?
>
251 </div
> <!-- end of results
-->
254 <?php
echo xl('Please input search criteria above, and click Submit to view results.', 'e' ); ?
>
260 <!-- stuff
for the popup calendar
-->
261 <style type
="text/css">@import
url(../../library
/dynarch_calendar
.css
);</style
>
262 <script type
="text/javascript" src
="../../library/dynarch_calendar.js"></script
>
263 <?php
include_once("{$GLOBALS['srcdir']}/dynarch_calendar_en.inc.php"); ?
>
264 <script type
="text/javascript" src
="../../library/dynarch_calendar_setup.js"></script
>
265 <script language
="Javascript">
266 Calendar
.setup({inputField
:"form_from_date", ifFormat
:"%Y-%m-%d", button
:"img_from_date"});
267 Calendar
.setup({inputField
:"form_to_date", ifFormat
:"%Y-%m-%d", button
:"img_to_date"});