minor cosmetic fix
[openemr.git] / interface / reports / front_receipts_report.php
blob46363b611f2315ad0184c8df02e3e952e4ed2f7a
1 <?
2 // Copyright (C) 2006 Rod Roark <rod@sunsetsystems.com>
3 //
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) : '';
21 <html>
22 <head>
23 <title>Front Office Receipts</title>
24 <link rel='stylesheet' href='<?php echo $css_header ?>' type='text/css'>
25 <script type="text/javascript" src="../../library/overlib_mini.js"></script>
26 <script type="text/javascript" src="../../library/calendar.js"></script>
27 <script type="text/javascript" src="../../library/textformat.js"></script>
28 <script type="text/javascript" src="../../library/dialog.js"></script>
29 <script language="JavaScript">
31 var mypcc = '<? echo $GLOBALS['phone_country_code'] ?>';
33 // The OnClick handler for receipt display.
34 function show_receipt(payid) {
35 dlgopen('../patient_file/front_payment.php?receipt=1&payid=' + payid, '_blank', 550, 400);
36 return false;
39 </script>
40 </head>
42 <body leftmargin='0' topmargin='0' marginwidth='0' marginheight='0'>
44 <!-- Required for the popup date selectors -->
45 <div id="overDiv" style="position:absolute; visibility:hidden; z-index:1000;"></div>
47 <center>
49 <h2>Front Office Receipts</h2>
51 <form name='theform' method='post' action='front_receipts_report.php'>
53 <table border='0' cellpadding='3'>
55 <tr>
56 <td>
57 From:
58 <input type='text' name='form_from_date' size='10' value='<? echo $from_date ?>'
59 onkeyup='datekeyup(this,mypcc)' onblur='dateblur(this,mypcc)' title='yyyy-mm-dd'>
60 <a href="javascript:show_calendar('theform.form_from_date')"
61 title="Click here to choose a date"
62 ><img src='../pic/show_calendar.gif' align='absbottom' width='24' height='22' border='0'></a>
63 &nbsp;To:
64 <input type='text' name='form_to_date' size='10' value='<? echo $to_date ?>'
65 onkeyup='datekeyup(this,mypcc)' onblur='dateblur(this,mypcc)' title='yyyy-mm-dd'>
66 <a href="javascript:show_calendar('theform.form_to_date')"
67 title="Click here to choose a date"
68 ><img src='../pic/show_calendar.gif' align='absbottom' width='24' height='22' border='0'></a>
69 &nbsp;
70 <input type='submit' name='form_refresh' value='Refresh'>
71 </td>
72 </tr>
74 <tr>
75 <td height="1">
76 </td>
77 </tr>
79 </table>
81 <table border='0' cellpadding='1' cellspacing='2' width='98%'>
83 <tr bgcolor="#dddddd">
84 <td class="dehead">
85 Time
86 </td>
87 <td class='dehead'>
88 Patient
89 </td>
90 <td class='dehead'>
92 </td>
93 <td class='dehead'>
94 Method
95 </td>
96 <td class='dehead'>
97 Source
98 </td>
99 <td class='dehead' align='right'>
100 Today
101 </td>
102 <td class='dehead' align='right'>
103 Previous
104 </td>
105 <td class='dehead' align='right'>
106 Total
107 </td>
108 </tr>
110 if (true || $_POST['form_refresh']) {
111 $total1 = 0.00;
112 $total2 = 0.00;
114 $query = "SELECT " .
115 "r.id, r.dtime, r.method, r.source, r.amount1, r.amount2, " .
116 "p.fname, p.mname, p.lname, p.pubpid " .
117 "FROM payments AS r " .
118 "LEFT OUTER JOIN patient_data AS p ON " .
119 "p.pid = r.pid " .
120 "WHERE " .
121 "r.dtime >= '$from_date 00:00:00' AND " .
122 "r.dtime <= '$to_date 23:59:59' " .
123 "ORDER BY r.dtime";
125 // echo "<!-- $query -->\n"; // debugging
126 $res = sqlStatement($query);
128 while ($row = sqlFetchArray($res)) {
130 <tr>
131 <td class='detail'>
132 <a href='' onclick='return show_receipt(<?php echo $row['id'] ?>)'>
133 <?php echo substr($row['dtime'], 0, 16) ?>
134 </a>
135 </td>
136 <td class='detail'>
137 <?php echo $row['lname'] . ', ' . $row['fname'] . ' ' . $row['mname'] ?>
138 </td>
139 <td class='detail'>
140 <?php echo $row['pubpid'] ?>
141 </td>
142 <td class='detail'>
143 <?php echo $row['method'] ?>
144 </td>
145 <td class='detail'>
146 <?php echo $row['source'] ?>
147 </td>
148 <td class='detail' align='right'>
149 <?php echo bucks($row['amount1']) ?>
150 </td>
151 <td class='detail' align='right'>
152 <?php echo bucks($row['amount2']) ?>
153 </td>
154 <td class='detail' align='right'>
155 <?php echo bucks($row['amount1'] + $row['amount2']) ?>
156 </td>
157 </tr>
158 <?php
159 $total1 += $row['amount1'];
160 $total2 += $row['amount2'];
164 <tr>
165 <td class='dehead' colspan='8'>
166 &nbsp;
167 </td>
168 </tr>
170 <tr>
171 <td class='dehead' colspan='5'>
172 Totals
173 </td>
174 <td class='detail' align='right'>
175 <?php echo bucks($total1) ?>
176 </td>
177 <td class='detail' align='right'>
178 <?php echo bucks($total2) ?>
179 </td>
180 <td class='detail' align='right'>
181 <?php echo bucks($total1 + $total2) ?>
182 </td>
183 </tr>
185 <?php
189 </table>
190 </form>
191 </center>
192 </body>
193 </html>