Fix for editing current event in a recurring appointment
[openemr.git] / interface / reports / front_receipts_report.php
blob5e15e929303032abf90b28cb92bb9a450253202d
1 <?php
2 // Copyright (C) 2006-2010 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 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) : '';
22 <html>
23 <head>
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);
43 </script>
45 <link rel='stylesheet' href='<?php echo $css_header ?>' type='text/css'>
46 <style type="text/css">
47 /* specifically include & exclude from printing */
48 @media print {
49 #report_parameters {
50 visibility: hidden;
51 display: none;
53 #report_parameters_daterange {
54 visibility: visible;
55 display: inline;
57 #report_results {
58 margin-top: 30px;
62 /* specifically exclude some from the screen */
63 @media screen {
64 #report_parameters_daterange {
65 visibility: hidden;
66 display: none;
69 </style>
70 </head>
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)) ." &nbsp; to &nbsp; ". date("d F Y", strtotime($form_to_date)); ?>
81 </div>
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=''/>
89 <table>
90 <tr>
91 <td width='410px'>
92 <div style='float:left'>
94 <table class='text'>
95 <tr>
96 <td class='label'>
97 <?php xl('From','e'); ?>:
98 </td>
99 <td>
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'); ?>'>
105 </td>
106 <td class='label'>
107 <?php xl('To','e'); ?>:
108 </td>
109 <td>
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'); ?>'>
115 </td>
116 </tr>
117 </table>
119 </div>
121 </td>
122 <td align='left' valign='middle' height="100%">
123 <table style='border-left:1px solid; width:100%; height:100%' >
124 <tr>
125 <td>
126 <div style='margin-left:15px'>
127 <a href='#' class='css_button' onclick='$("#form_refresh").attr("value","true"); $("#theform").submit();'>
128 <span>
129 <?php xl('Submit','e'); ?>
130 </span>
131 </a>
133 <?php if ($_POST['form_refresh']) { ?>
134 <a href='#' class='css_button' onclick='window.print()'>
135 <span>
136 <?php xl('Print','e'); ?>
137 </span>
138 </a>
139 <?php } ?>
140 </div>
141 </td>
142 </tr>
143 </table>
144 </td>
145 </tr>
146 </table>
147 </div> <!-- end of parameters -->
149 <?php
150 if ($_POST['form_refresh'] || $_POST['form_orderby']) {
152 <div id="report_results">
153 <table>
154 <thead>
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>
163 </thead>
164 <tbody>
165 <?php
166 if (true || $_POST['form_refresh']) {
167 $total1 = 0.00;
168 $total2 = 0.00;
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 " .
179 "p.pid = r.pid " .
180 "WHERE " .
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']);
192 <tr>
193 <td nowrap>
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); ?>
196 </a>
197 </td>
198 <td>
199 <?php echo $row['lname'] . ', ' . $row['fname'] . ' ' . $row['mname'] ?>
200 </td>
201 <td>
202 <?php echo $row['pubpid'] ?>
203 </td>
204 <td>
205 <?php echo $row['method'] ?>
206 </td>
207 <td>
208 <?php echo $row['source'] ?>
209 </td>
210 <td align='right'>
211 <?php echo bucks($row['amount1']) ?>
212 </td>
213 <td align='right'>
214 <?php echo bucks($row['amount2']) ?>
215 </td>
216 <td align='right'>
217 <?php echo bucks($row['amount1'] + $row['amount2']) ?>
218 </td>
219 </tr>
220 <?php
221 $total1 += $row['amount1'];
222 $total2 += $row['amount2'];
226 <tr>
227 <td colspan='8'>
228 &nbsp;
229 </td>
230 </tr>
232 <tr class="report_totals">
233 <td colspan='5'>
234 <?php xl('Totals','e'); ?>
235 </td>
236 <td align='right'>
237 <?php echo bucks($total1) ?>
238 </td>
239 <td align='right'>
240 <?php echo bucks($total2) ?>
241 </td>
242 <td align='right'>
243 <?php echo bucks($total1 + $total2) ?>
244 </td>
245 </tr>
247 <?php
250 </tbody>
251 </table>
252 </div> <!-- end of results -->
253 <?php } else { ?>
254 <div class='text'>
255 <?php echo xl('Please input search criteria above, and click Submit to view results.', 'e' ); ?>
256 </div>
257 <?php } ?>
259 </form>
260 </body>
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"});
269 </script>
270 </html>