added cache clearing support for dialog.js (#411)
[openemr.git] / interface / reports / front_receipts_report.php
blob7ee19ba93dfddf41d1dcd674b3872f6feeb54815
1 <?php
2 // Copyright (C) 2006-2015 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?v=<?php echo $v_js_includes; ?>"></script>
29 <script type="text/javascript" src="<?php echo $GLOBALS['assets_static_relative']; ?>/jquery-min-1-3-2/index.js"></script>
31 <script language="JavaScript">
33 <?php require($GLOBALS['srcdir'] . "/restoreSession.php"); ?>
35 var mypcc = '<?php echo $GLOBALS['phone_country_code'] ?>';
37 $(document).ready(function() {
38 var win = top.printLogSetup ? top : opener.top;
39 win.printLogSetup(document.getElementById('printbutton'));
40 });
42 // The OnClick handler for receipt display.
43 function show_receipt(pid,timestamp) {
44 dlgopen('../patient_file/front_payment.php?receipt=1&patient=' + pid +
45 '&time=' + timestamp, '_blank', 550, 400);
48 </script>
50 <link rel='stylesheet' href='<?php echo $css_header ?>' type='text/css'>
51 <style type="text/css">
52 /* specifically include & exclude from printing */
53 @media print {
54 #report_parameters {
55 visibility: hidden;
56 display: none;
58 #report_parameters_daterange {
59 visibility: visible;
60 display: inline;
62 #report_results {
63 margin-top: 30px;
67 /* specifically exclude some from the screen */
68 @media screen {
69 #report_parameters_daterange {
70 visibility: hidden;
71 display: none;
74 </style>
75 </head>
77 <body class="body_top">
79 <!-- Required for the popup date selectors -->
80 <div id="overDiv" style="position:absolute; visibility:hidden; z-index:1000;"></div>
82 <span class='title'><?php xl('Report','e'); ?> - <?php xl('Front Office Receipts','e'); ?></span>
84 <div id="report_parameters_daterange">
85 <?php echo date("d F Y", strtotime($form_from_date)) ." &nbsp; to &nbsp; ". date("d F Y", strtotime($form_to_date)); ?>
86 </div>
88 <form name='theform' method='post' action='front_receipts_report.php' id='theform'>
90 <div id="report_parameters">
92 <input type='hidden' name='form_refresh' id='form_refresh' value=''/>
94 <table>
95 <tr>
96 <td width='410px'>
97 <div style='float:left'>
99 <table class='text'>
100 <tr>
101 <td class='label'>
102 <?php xl('From','e'); ?>:
103 </td>
104 <td>
105 <input type='text' name='form_from_date' id="form_from_date" size='10' value='<?php echo attr($form_from_date) ?>'
106 onkeyup='datekeyup(this,mypcc)' onblur='dateblur(this,mypcc)' title='yyyy-mm-dd'>
107 <img src='../pic/show_calendar.gif' align='absbottom' width='24' height='22'
108 id='img_from_date' border='0' alt='[?]' style='cursor:pointer'
109 title='<?php xl('Click here to choose a date','e'); ?>'>
110 </td>
111 <td class='label'>
112 <?php xl('To','e'); ?>:
113 </td>
114 <td>
115 <input type='text' name='form_to_date' id="form_to_date" size='10' value='<?php echo attr($form_to_date) ?>'
116 onkeyup='datekeyup(this,mypcc)' onblur='dateblur(this,mypcc)' title='yyyy-mm-dd'>
117 <img src='../pic/show_calendar.gif' align='absbottom' width='24' height='22'
118 id='img_to_date' border='0' alt='[?]' style='cursor:pointer'
119 title='<?php xl('Click here to choose a date','e'); ?>'>
120 </td>
121 </tr>
122 </table>
124 </div>
126 </td>
127 <td align='left' valign='middle' height="100%">
128 <table style='border-left:1px solid; width:100%; height:100%' >
129 <tr>
130 <td>
131 <div style='margin-left:15px'>
132 <a href='#' class='css_button' onclick='$("#form_refresh").attr("value","true"); $("#theform").submit();'>
133 <span>
134 <?php xl('Submit','e'); ?>
135 </span>
136 </a>
138 <?php if ($_POST['form_refresh']) { ?>
139 <a href='#' class='css_button' id='printbutton'>
140 <span>
141 <?php xl('Print','e'); ?>
142 </span>
143 </a>
144 <?php } ?>
145 </div>
146 </td>
147 </tr>
148 </table>
149 </td>
150 </tr>
151 </table>
152 </div> <!-- end of parameters -->
154 <?php
155 if ($_POST['form_refresh'] || $_POST['form_orderby']) {
157 <div id="report_results">
158 <table>
159 <thead>
160 <th> <?php xl('Time','e'); ?> </th>
161 <th> <?php xl('Patient','e'); ?> </th>
162 <th> <?php xl('ID','e'); ?> </th>
163 <th> <?php xl('Method','e'); ?> </th>
164 <th> <?php xl('Source','e'); ?> </th>
165 <th align='right'> <?php xl('Today','e'); ?> </th>
166 <th align='right'> <?php xl('Previous','e'); ?> </th>
167 <th align='right'> <?php xl('Total','e'); ?> </th>
168 </thead>
169 <tbody>
170 <?php
171 if (true || $_POST['form_refresh']) {
172 $total1 = 0.00;
173 $total2 = 0.00;
175 $query = "SELECT r.pid, r.dtime, " .
176 "SUM(r.amount1) AS amount1, " .
177 "SUM(r.amount2) AS amount2, " .
178 "MAX(r.method) AS method, " .
179 "MAX(r.source) AS source, " .
180 "MAX(r.user) AS user, " .
181 "p.fname, p.mname, p.lname, p.pubpid " .
182 "FROM payments AS r " .
183 "LEFT OUTER JOIN patient_data AS p ON " .
184 "p.pid = r.pid " .
185 "WHERE " .
186 "r.dtime >= '$from_date 00:00:00' AND " .
187 "r.dtime <= '$to_date 23:59:59' " .
188 "GROUP BY r.dtime, r.pid ORDER BY r.dtime, r.pid";
190 // echo "<!-- $query -->\n"; // debugging
191 $res = sqlStatement($query);
193 while ($row = sqlFetchArray($res)) {
194 // Make the timestamp URL-friendly.
195 $timestamp = preg_replace('/[^0-9]/', '', $row['dtime']);
197 <tr>
198 <td nowrap>
199 <a href="javascript:show_receipt(<?php echo $row['pid'] . ",'$timestamp'"; ?>)">
200 <?php echo oeFormatShortDate(substr($row['dtime'], 0, 10)) . substr($row['dtime'], 10, 6); ?>
201 </a>
202 </td>
203 <td>
204 <?php echo $row['lname'] . ', ' . $row['fname'] . ' ' . $row['mname'] ?>
205 </td>
206 <td>
207 <?php echo $row['pubpid'] ?>
208 </td>
209 <td>
210 <?php echo $row['method'] ?>
211 </td>
212 <td>
213 <?php echo $row['source'] ?>
214 </td>
215 <td align='right'>
216 <?php echo bucks($row['amount1']) ?>
217 </td>
218 <td align='right'>
219 <?php echo bucks($row['amount2']) ?>
220 </td>
221 <td align='right'>
222 <?php echo bucks($row['amount1'] + $row['amount2']) ?>
223 </td>
224 </tr>
225 <?php
226 $total1 += $row['amount1'];
227 $total2 += $row['amount2'];
231 <tr>
232 <td colspan='8'>
233 &nbsp;
234 </td>
235 </tr>
237 <tr class="report_totals">
238 <td colspan='5'>
239 <?php xl('Totals','e'); ?>
240 </td>
241 <td align='right'>
242 <?php echo bucks($total1) ?>
243 </td>
244 <td align='right'>
245 <?php echo bucks($total2) ?>
246 </td>
247 <td align='right'>
248 <?php echo bucks($total1 + $total2) ?>
249 </td>
250 </tr>
252 <?php
255 </tbody>
256 </table>
257 </div> <!-- end of results -->
258 <?php } else { ?>
259 <div class='text'>
260 <?php echo xl('Please input search criteria above, and click Submit to view results.', 'e' ); ?>
261 </div>
262 <?php } ?>
264 </form>
265 </body>
266 <!-- stuff for the popup calendar -->
267 <style type="text/css">@import url(../../library/dynarch_calendar.css);</style>
268 <script type="text/javascript" src="../../library/dynarch_calendar.js"></script>
269 <?php include_once("{$GLOBALS['srcdir']}/dynarch_calendar_en.inc.php"); ?>
270 <script type="text/javascript" src="../../library/dynarch_calendar_setup.js"></script>
271 <script language="Javascript">
272 Calendar.setup({inputField:"form_from_date", ifFormat:"%Y-%m-%d", button:"img_from_date"});
273 Calendar.setup({inputField:"form_to_date", ifFormat:"%Y-%m-%d", button:"img_to_date"});
274 </script>
275 </html>