translation patches from Dr. Bosman and his crew
[openemr.git] / interface / patient_file / front_payment.php
blob3f7af0e615481ab4602f4742cfcd8e26f2c1ef48
1 <?php
2 // Copyright (C) 2006 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 include_once("../globals.php");
10 include_once("$srcdir/patient.inc");
12 <html>
13 <head>
14 <link rel='stylesheet' href='<?php echo $css_header ?>' type='text/css'>
15 <?php
16 $payment_methods = array(
17 xl('Cash'),
18 xl('Check'),
19 xl('MC'),
20 xl('VISA'),
21 xl('AMEX'),
22 xl('DISC'),
23 xl('Other'));
25 // $patdata = getPatientData($pid, 'fname,lname,pubpid');
27 $patdata = sqlQuery("SELECT " .
28 "p.fname, p.mname, p.lname, p.pubpid, i.copay " .
29 "FROM patient_data AS p " .
30 "LEFT OUTER JOIN insurance_data AS i ON " .
31 "i.pid = p.pid AND i.type = 'primary' " .
32 "WHERE p.pid = '$pid' LIMIT 1");
34 $alertmsg = ''; // anything here pops up in an alert box
36 // If the Save button was clicked...
37 if ($_POST['form_save']) {
38 $form_pid = $_POST['form_pid'];
39 $payid = $_REQUEST['payid'];
41 if ($payid) {
42 sqlStatement("UPDATE payments SET " .
43 "dtime = NOW(), " .
44 "user = '" . $_SESSION['authUser'] . "', " .
45 "method = '" . $_POST['form_method'] . "', " .
46 "source = '" . $_POST['form_source'] . "', " .
47 "amount1 = '" . $_POST['form_amount1'] . "', " .
48 "amount2 = '" . $_POST['form_amount2'] . "' " .
49 "WHERE id = '$payid'");
50 } else {
51 $payid = sqlInsert("INSERT INTO payments ( " .
52 "pid, dtime, user, method, source, amount1, amount2 " .
53 ") VALUES ( " .
54 "'$form_pid', " .
55 "NOW(), " .
56 "'" . $_SESSION['authUser'] . "', " .
57 "'" . $_POST['form_method'] . "', " .
58 "'" . $_POST['form_source'] . "', " .
59 "'" . $_POST['form_amount1'] . "', " .
60 "'" . $_POST['form_amount2'] . "' " .
61 ")");
66 <?php
67 if ($_POST['form_save'] || $_REQUEST['receipt']) {
69 // Get details for what we guess is the primary facility.
70 $frow = sqlQuery("SELECT * FROM facility " .
71 "ORDER BY billing_location DESC, accepts_assignment DESC, id LIMIT 1");
73 // Re-fetch info for this payment.
74 $payrow = sqlQuery("SELECT * FROM payments WHERE id = '$payid'");
76 // Get the patient's name and chart number.
77 $patdata = getPatientData($payrow['pid'], 'fname,mname,lname,pubpid');
79 // Now proceed with printing the receipt.
82 <title><? xl('Receipt for Payment','e'); ?></title>
83 <body bgcolor='#ffffff'>
84 <center>
86 <p><h2><? xl('Receipt for Payment','e'); ?></h2>
88 <p><?php echo htmlentities($frow['name']) ?>
89 <br><?php echo htmlentities($frow['street']) ?>
90 <br><?php echo htmlentities($frow['city'] . ', ' . $frow['state']) . ' ' .
91 $frow['postal_code'] ?>
92 <br><?php echo htmlentities($frow['phone']) ?>
94 <p>
95 <table border='0' cellspacing='8'>
96 <tr>
97 <td><? xl('Date','e'); ?>:</td>
98 <td><?php echo date('Y-m-d', strtotime($payrow['dtime'])) ?></td>
99 </tr>
100 <tr>
101 <td><? xl('Patient','e'); ?>:</td>
102 <td><?php echo $patdata['fname'] . " " . $patdata['mname'] . " " .
103 $patdata['lname'] . " (" . $patdata['pubpid'] . ")" ?></td>
104 </tr>
105 <tr>
106 <td><? xl('Paid Via','e'); ?>:</td>
107 <td><?php echo $payrow['method'] ?></td>
108 </tr>
109 <tr>
110 <td><? xl('Check/Ref Number','e'); ?>:</td>
111 <td><?php echo $payrow['source'] ?></td>
112 </tr>
113 <tr>
114 <td><? xl('Amount for This Visit','e'); ?>:</td>
115 <td><?php echo $payrow['amount1'] ?></td>
116 </tr>
117 <tr>
118 <td><? xl('Amount for Past Balance','e'); ?>:</td>
119 <td><?php echo $payrow['amount2'] ?></td>
120 </tr>
121 <tr>
122 <td><? xl('Received By','e'); ?>:</td>
123 <td><?php echo $payrow['user'] ?></td>
124 </tr>
125 </table>
127 </center>
129 <p>&nbsp;<br>
130 <a href='' class='link_submit' onclick='window.print();return false;'><? xl('Print','e'); ?></a>
132 </body>
134 <?php
135 } else {
137 // This is the case where we display the form for data entry.
139 $payrow = array('amount1' => $patdata['copay']);
140 if ($_REQUEST['payid']) {
141 $payrow = sqlQuery("SELECT * FROM payments WHERE id = '" .
142 $_REQUEST['payid'] . "'");
144 // Continue with display of the data entry form.
146 <title><? xl('Record Payment','e'); ?></title>
148 <style>
149 </style>
151 <script type="text/javascript" src="../../library/topdialog.js"></script>
152 <script type="text/javascript" src="../../library/dialog.js"></script>
154 <script language="JavaScript">
155 </script>
157 </head>
159 <body <?echo $top_bg_line;?> leftmargin='0' topmargin='0' marginwidth='0'
160 marginheight='0' onunload='imclosing()'>
162 <form method='post' action='front_payment.php<?php if ($payid) echo "?payid=$payid"; ?>'>
163 <input type='hidden' name='form_pid' value='<?php echo $pid ?>' />
165 <center>
167 <table border='0' cellspacing='8'>
169 <tr>
170 <td colspan='2' align='center'>
171 &nbsp;<br>
172 <b><? xl('Accept Payment for ','e'); ?><?php echo $patdata['fname'] . " " .
173 $patdata['lname'] . " (" . $patdata['pubpid'] . ")" ?></b>
174 <br>&nbsp;
175 </td>
176 </tr>
178 <tr>
179 <td>
180 <? xl('Payment Method','e'); ?>:
181 </td>
182 <td>
183 <select name='form_method'>
185 foreach ($payment_methods as $value) {
186 echo " <option value='$value'";
187 if ($value == $payrow['method']) echo " selected";
188 echo ">$value</option>\n";
191 </select>
192 </td>
193 </tr>
195 <tr>
196 <td>
197 <? xl('Check/Reference Number','e'); ?>:
198 </td>
199 <td>
200 <input type='text' name='form_source' size='10' value='<?php echo $payrow['source'] ?>'>
201 </td>
202 </tr>
204 <tr>
205 <td>
206 <? xl('Amount for Todays Visit','e'); ?>:
207 </td>
208 <td>
209 <input type='text' name='form_amount1' size='10' value='<?php echo $payrow['amount1'] ?>'>
210 </td>
211 </tr>
213 <tr>
214 <td>
215 <? xl('Amount for Prior Balance','e'); ?>:
216 </td>
217 <td>
218 <input type='text' name='form_amount2' size='10' value='<?php echo $payrow['amount2'] ?>'>
219 </td>
220 </tr>
222 <tr>
223 <td colspan='2' align='center'>
224 &nbsp;<br>
225 <input type='submit' name='form_save' value='<?php xl('Save','e'); ?>' /> &nbsp;
226 <input type='button' value='<?php xl('Cancel','e'); ?>' onclick='window.close()' />
227 </td>
228 </tr>
230 </table>
231 </center>
233 </form>
235 </body>
237 <?php
240 </html>