2 // Copyright (C) 2006 Rod Roark <rod@sunsetsystems.com>
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");
14 <link rel
='stylesheet' href
='<?php echo $css_header ?>' type
='text/css'>
16 $payment_methods = array(
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'];
42 sqlStatement("UPDATE payments SET " .
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'");
51 $payid = sqlInsert("INSERT INTO payments ( " .
52 "pid, dtime, user, method, source, amount1, amount2 " .
56 "'" . $_SESSION['authUser'] . "', " .
57 "'" . $_POST['form_method'] . "', " .
58 "'" . $_POST['form_source'] . "', " .
59 "'" . $_POST['form_amount1'] . "', " .
60 "'" . $_POST['form_amount2'] . "' " .
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'>
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']) ?
>
95 <table border
='0' cellspacing
='8'>
97 <td
><?
xl('Date','e'); ?
>:</td
>
98 <td
><?php
echo date('Y-m-d', strtotime($payrow['dtime'])) ?
></td
>
101 <td
><?
xl('Patient','e'); ?
>:</td
>
102 <td
><?php
echo $patdata['fname'] . " " . $patdata['mname'] . " " .
103 $patdata['lname'] . " (" . $patdata['pubpid'] . ")" ?
></td
>
106 <td
><?
xl('Paid Via','e'); ?
>:</td
>
107 <td
><?php
echo $payrow['method'] ?
></td
>
110 <td
><?
xl('Check/Ref Number','e'); ?
>:</td
>
111 <td
><?php
echo $payrow['source'] ?
></td
>
114 <td
><?
xl('Amount for This Visit','e'); ?
>:</td
>
115 <td
><?php
echo $payrow['amount1'] ?
></td
>
118 <td
><?
xl('Amount for Past Balance','e'); ?
>:</td
>
119 <td
><?php
echo $payrow['amount2'] ?
></td
>
122 <td
><?
xl('Received By','e'); ?
>:</td
>
123 <td
><?php
echo $payrow['user'] ?
></td
>
130 <a href
='' class='link_submit' onclick
='window.print();return false;'><?
xl('Print','e'); ?
></a
>
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
>
151 <script type
="text/javascript" src
="../../library/topdialog.js"></script
>
152 <script type
="text/javascript" src
="../../library/dialog.js"></script
>
154 <script language
="JavaScript">
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 ?>' />
167 <table border
='0' cellspacing
='8'>
170 <td colspan
='2' align
='center'>
172 <b
><?
xl('Accept Payment for ','e'); ?
><?php
echo $patdata['fname'] . " " .
173 $patdata['lname'] . " (" . $patdata['pubpid'] . ")" ?
></b
>
180 <?
xl('Payment Method','e'); ?
>:
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";
197 <?
xl('Check/Reference Number','e'); ?
>:
200 <input type
='text' name
='form_source' size
='10' value
='<?php echo $payrow['source
'] ?>'>
206 <?
xl('Amount for Todays Visit','e'); ?
>:
209 <input type
='text' name
='form_amount1' size
='10' value
='<?php echo $payrow['amount1
'] ?>'>
215 <?
xl('Amount for Prior Balance','e'); ?
>:
218 <input type
='text' name
='form_amount2' size
='10' value
='<?php echo $payrow['amount2
'] ?>'>
223 <td colspan
='2' align
='center'>
225 <input type
='submit' name
='form_save' value
='<?php xl('Save
','e
'); ?>' />  
;
226 <input type
='button' value
='<?php xl('Cancel
','e
'); ?>' onclick
='window.close()' />