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