internationalization of the date widget, see feature request tracker item 2967294
[openemr.git] / interface / reports / front_receipts_report.php
blob423168afbab1d1ec10b1653bea767ff0015e2284
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 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);
42 </script>
44 <link rel='stylesheet' href='<?php echo $css_header ?>' type='text/css'>
45 <style type="text/css">
46 /* specifically include & exclude from printing */
47 @media print {
48 #report_parameters {
49 visibility: hidden;
50 display: none;
52 #report_parameters_daterange {
53 visibility: visible;
54 display: inline;
56 #report_results {
57 margin-top: 30px;
61 /* specifically exclude some from the screen */
62 @media screen {
63 #report_parameters_daterange {
64 visibility: hidden;
65 display: none;
68 </style>
69 </head>
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)) ." &nbsp; to &nbsp; ". date("d F Y", strtotime($form_to_date)); ?>
80 </div>
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=''/>
88 <table>
89 <tr>
90 <td width='410px'>
91 <div style='float:left'>
93 <table class='text'>
94 <tr>
95 <td class='label'>
96 <?php xl('From','e'); ?>:
97 </td>
98 <td>
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'); ?>'>
104 </td>
105 <td class='label'>
106 <?php xl('To','e'); ?>:
107 </td>
108 <td>
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'); ?>'>
114 </td>
115 </tr>
116 </table>
118 </div>
120 </td>
121 <td align='left' valign='middle' height="100%">
122 <table style='border-left:1px solid; width:100%; height:100%' >
123 <tr>
124 <td>
125 <div style='margin-left:15px'>
126 <a href='#' class='css_button' onclick='$("#form_refresh").attr("value","true"); $("#theform").submit();'>
127 <span>
128 <?php xl('Submit','e'); ?>
129 </span>
130 </a>
132 <?php if ($_POST['form_refresh']) { ?>
133 <a href='#' class='css_button' onclick='window.print()'>
134 <span>
135 <?php xl('Print','e'); ?>
136 </span>
137 </a>
138 <?php } ?>
139 </div>
140 </td>
141 </tr>
142 </table>
143 </td>
144 </tr>
145 </table>
146 </div> <!-- end of parameters -->
148 <?php
149 if ($_POST['form_refresh'] || $_POST['form_orderby']) {
151 <div id="report_results">
152 <table>
153 <thead>
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>
162 </thead>
163 <tbody>
164 <?php
165 if (true || $_POST['form_refresh']) {
166 $total1 = 0.00;
167 $total2 = 0.00;
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 " .
178 "p.pid = r.pid " .
179 "WHERE " .
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']);
191 <tr>
192 <td nowrap>
193 <a href="javascript:show_receipt(<?php echo $row['pid'] . ",'$timestamp'"; ?>)">
194 <?php echo substr($row['dtime'], 0, 16); ?>
195 </a>
196 </td>
197 <td>
198 <?php echo $row['lname'] . ', ' . $row['fname'] . ' ' . $row['mname'] ?>
199 </td>
200 <td>
201 <?php echo $row['pubpid'] ?>
202 </td>
203 <td>
204 <?php echo $row['method'] ?>
205 </td>
206 <td>
207 <?php echo $row['source'] ?>
208 </td>
209 <td align='right'>
210 <?php echo bucks($row['amount1']) ?>
211 </td>
212 <td align='right'>
213 <?php echo bucks($row['amount2']) ?>
214 </td>
215 <td align='right'>
216 <?php echo bucks($row['amount1'] + $row['amount2']) ?>
217 </td>
218 </tr>
219 <?php
220 $total1 += $row['amount1'];
221 $total2 += $row['amount2'];
225 <tr>
226 <td colspan='8'>
227 &nbsp;
228 </td>
229 </tr>
231 <tr class="report_totals">
232 <td colspan='5'>
233 <?php xl('Totals','e'); ?>
234 </td>
235 <td align='right'>
236 <?php echo bucks($total1) ?>
237 </td>
238 <td align='right'>
239 <?php echo bucks($total2) ?>
240 </td>
241 <td align='right'>
242 <?php echo bucks($total1 + $total2) ?>
243 </td>
244 </tr>
246 <?php
249 </tbody>
250 </table>
251 </div> <!-- end of results -->
252 <?php } else { ?>
253 <div class='text'>
254 <?php echo xl('Please input search criteria above, and click Submit to view results.', 'e' ); ?>
255 </div>
256 <?php } ?>
258 </form>
259 </body>
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"});
268 </script>
269 </html>