added gacl config files to upgrade instructions
[openemr.git] / interface / reports / front_receipts_report.php
blob4cecf93401f33bf51696eff0dc58c21bea07001d
1 <?php
2 // Copyright (C) 2006-2007 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 <?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);
40 </script>
42 <link rel='stylesheet' href='<?php echo $css_header ?>' type='text/css'>
43 <style type="text/css">
45 /* specifically include & exclude from printing */
46 @media print {
47 #recptreport_parameters {
48 visibility: hidden;
49 display: none;
51 #recptreport_parameters_daterange {
52 visibility: visible;
53 display: inline;
57 /* specifically exclude some from the screen */
58 @media screen {
59 #recptreport_parameters_daterange {
60 visibility: hidden;
61 display: none;
65 #recptreport_parameters {
66 width: 100%;
67 background-color: #ddf;
69 #recptreport_parameters table {
70 border: none;
71 border-collapse: collapse;
73 #recptreport_parameters table td {
74 padding: 3px;
77 #recptreport_results {
78 width: 100%;
79 margin-top: 10px;
81 #recptreport_results table {
82 border: 1px solid black;
83 width: 98%;
84 border-collapse: collapse;
86 #recptreport_results table thead {
87 display: table-header-group;
88 background-color: #ddd;
90 #recptreport_results table th {
91 border-bottom: 1px solid black;
93 #recptreport_results table td {
94 padding: 1px;
95 margin: 2px;
96 border-bottom: 1px solid #eee;
98 .recptreport_totals td {
99 background-color: #77ff77;
100 font-weight: bold;
102 </style>
103 </head>
105 <body class="body_top">
107 <!-- Required for the popup date selectors -->
108 <div id="overDiv" style="position:absolute; visibility:hidden; z-index:1000;"></div>
110 <center>
112 <h2><?php xl('Front Office Receipts','e'); ?></h2>
114 <div id="recptreport_parameters_daterange">
115 <?php echo date("d F Y", strtotime($form_from_date)) ." &nbsp; to &nbsp; ". date("d F Y", strtotime($form_to_date)); ?>
116 </div>
118 <div id="recptreport_parameters">
120 <form name='theform' method='post' action='front_receipts_report.php'>
122 <table>
123 <tr>
124 <td>
125 <?php xl('From','e'); ?>:
126 <input type='text' name='form_from_date' id="form_from_date" size='10' value='<?php echo $from_date ?>'
127 onkeyup='datekeyup(this,mypcc)' onblur='dateblur(this,mypcc)' title='yyyy-mm-dd'>
128 <img src='../pic/show_calendar.gif' align='absbottom' width='24' height='22'
129 id='img_from_date' border='0' alt='[?]' style='cursor:pointer'
130 title='<?php xl('Click here to choose a date','e'); ?>'>
131 &nbsp;<?php xl('To','e'); ?>:
132 <input type='text' name='form_to_date' id="form_to_date" size='10' value='<?php echo $to_date ?>'
133 onkeyup='datekeyup(this,mypcc)' onblur='dateblur(this,mypcc)' title='yyyy-mm-dd'>
134 <img src='../pic/show_calendar.gif' align='absbottom' width='24' height='22'
135 id='img_to_date' border='0' alt='[?]' style='cursor:pointer'
136 title='<?php xl('Click here to choose a date','e'); ?>'>
137 &nbsp;
138 <input type='submit' name='form_refresh' value=<?php xl('Refresh','e'); ?>>
139 &nbsp;
140 <input type='button' value='<?php xl('Print','e'); ?>' onclick='window.print()' />
141 </td>
142 </tr>
143 </table>
144 </div> <!-- end of parameters -->
146 <div id="recptreport_results">
147 <table>
148 <thead>
149 <th> <?php xl('Time','e'); ?> </th>
150 <th> <?php xl('Patient','e'); ?> </th>
151 <th> <?php xl('ID','e'); ?> </th>
152 <th> <?php xl('Method','e'); ?> </th>
153 <th> <?php xl('Source','e'); ?> </th>
154 <th align='right'> <?php xl('Today','e'); ?> </th>
155 <th align='right'> <?php xl('Previous','e'); ?> </th>
156 <th align='right'> <?php xl('Total','e'); ?> </th>
157 </thead>
158 <tbody>
159 <?php
160 if (true || $_POST['form_refresh']) {
161 $total1 = 0.00;
162 $total2 = 0.00;
164 $query = "SELECT r.pid, r.dtime, " .
165 "SUM(r.amount1) AS amount1, " .
166 "SUM(r.amount2) AS amount2, " .
167 "MAX(r.method) AS method, " .
168 "MAX(r.source) AS source, " .
169 "MAX(r.user) AS user, " .
170 "p.fname, p.mname, p.lname, p.pubpid " .
171 "FROM payments AS r " .
172 "LEFT OUTER JOIN patient_data AS p ON " .
173 "p.pid = r.pid " .
174 "WHERE " .
175 "r.dtime >= '$from_date 00:00:00' AND " .
176 "r.dtime <= '$to_date 23:59:59' " .
177 "GROUP BY r.dtime, r.pid ORDER BY r.dtime, r.pid";
179 // echo "<!-- $query -->\n"; // debugging
180 $res = sqlStatement($query);
182 while ($row = sqlFetchArray($res)) {
183 // Make the timestamp URL-friendly.
184 $timestamp = preg_replace('/[^0-9]/', '', $row['dtime']);
186 <tr>
187 <td nowrap>
188 <a href="javascript:show_receipt(<?php echo $row['pid'] . ",'$timestamp'"; ?>)">
189 <?php echo substr($row['dtime'], 0, 16); ?>
190 </a>
191 </td>
192 <td>
193 <?php echo $row['lname'] . ', ' . $row['fname'] . ' ' . $row['mname'] ?>
194 </td>
195 <td>
196 <?php echo $row['pubpid'] ?>
197 </td>
198 <td>
199 <?php echo $row['method'] ?>
200 </td>
201 <td>
202 <?php echo $row['source'] ?>
203 </td>
204 <td align='right'>
205 <?php echo bucks($row['amount1']) ?>
206 </td>
207 <td align='right'>
208 <?php echo bucks($row['amount2']) ?>
209 </td>
210 <td align='right'>
211 <?php echo bucks($row['amount1'] + $row['amount2']) ?>
212 </td>
213 </tr>
214 <?php
215 $total1 += $row['amount1'];
216 $total2 += $row['amount2'];
220 <tr>
221 <td colspan='8'>
222 &nbsp;
223 </td>
224 </tr>
226 <tr class="recptreport_totals">
227 <td colspan='5'>
228 <?php xl('Totals','e'); ?>
229 </td>
230 <td align='right'>
231 <?php echo bucks($total1) ?>
232 </td>
233 <td align='right'>
234 <?php echo bucks($total2) ?>
235 </td>
236 <td align='right'>
237 <?php echo bucks($total1 + $total2) ?>
238 </td>
239 </tr>
241 <?php
244 </tbody>
245 </table>
246 </div> <!-- end of results -->
247 </form>
248 </center>
249 </body>
250 <!-- stuff for the popup calendar -->
251 <style type="text/css">@import url(../../library/dynarch_calendar.css);</style>
252 <script type="text/javascript" src="../../library/dynarch_calendar.js"></script>
253 <script type="text/javascript" src="../../library/dynarch_calendar_en.js"></script>
254 <script type="text/javascript" src="../../library/dynarch_calendar_setup.js"></script>
255 <script language="Javascript">
256 Calendar.setup({inputField:"form_from_date", ifFormat:"%Y-%m-%d", button:"img_from_date"});
257 Calendar.setup({inputField:"form_to_date", ifFormat:"%Y-%m-%d", button:"img_to_date"});
258 </script>
259 </html>