2 // Copyright (C) 2006-2010 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 $fake_register_globals=false;
10 $sanitize_all_escapes=true;
12 require_once("../globals.php");
13 require_once("$srcdir/acl.inc");
14 require_once("$srcdir/patient.inc");
15 require_once("$srcdir/billing.inc");
16 require_once("$srcdir/forms.inc");
17 require_once("$srcdir/sl_eob.inc.php");
18 require_once("$srcdir/invoice_summary.inc.php");
19 require_once("../../custom/code_types.inc.php");
20 require_once("$srcdir/formatting.inc.php");
21 require_once("$srcdir/options.inc.php");
22 require_once("$srcdir/encounter_events.inc.php");
23 $pid = $_REQUEST['hidden_patient_code'] > 0 ?
$_REQUEST['hidden_patient_code'] : $pid;
25 $INTEGRATED_AR = $GLOBALS['oer_config']['ws_accounting']['enabled'] === 2;
29 <?php
html_header_show();?
>
30 <link rel
='stylesheet' href
='<?php echo $css_header ?>' type
='text/css'>
32 // Format dollars for display.
34 function bucks($amount) {
36 $amount = oeFormatMoney($amount);
42 function rawbucks($amount) {
44 $amount = sprintf("%.2f", $amount);
50 // Display a row of data for an encounter.
53 function echoLine($iname, $date, $charges, $ptpaid, $inspaid, $duept,$encounter=0,$copay=0,$patcopay=0) {
56 $balance = bucks($charges - $ptpaid - $inspaid);
57 $balance = (round($duept,2) != 0) ?
0 : $balance;//if balance is due from patient, then insurance balance is displayed as zero
58 $encounter = $encounter ?
$encounter : '';
59 echo " <tr id='tr_".attr($var_index)."' >\n";
60 echo " <td class='detail'>" . text(oeFormatShortDate($date)) . "</td>\n";
61 echo " <td class='detail' id='".attr($date)."' align='center'>" . htmlspecialchars($encounter, ENT_QUOTES
) . "</td>\n";
62 echo " <td class='detail' align='center' id='td_charges_$var_index' >" . htmlspecialchars(bucks($charges), ENT_QUOTES
) . "</td>\n";
63 echo " <td class='detail' align='center' id='td_inspaid_$var_index' >" . htmlspecialchars(bucks($inspaid*-1), ENT_QUOTES
) . "</td>\n";
64 echo " <td class='detail' align='center' id='td_ptpaid_$var_index' >" . htmlspecialchars(bucks($ptpaid*-1), ENT_QUOTES
) . "</td>\n";
65 echo " <td class='detail' align='center' id='td_patient_copay_$var_index' >" . htmlspecialchars(bucks($patcopay), ENT_QUOTES
) . "</td>\n";
66 echo " <td class='detail' align='center' id='td_copay_$var_index' >" . htmlspecialchars(bucks($copay), ENT_QUOTES
) . "</td>\n";
67 echo " <td class='detail' align='center' id='balance_$var_index'>" . htmlspecialchars(bucks($balance), ENT_QUOTES
) . "</td>\n";
68 echo " <td class='detail' align='center' id='duept_$var_index'>" . htmlspecialchars(bucks(round($duept,2)*1), ENT_QUOTES
) . "</td>\n";
69 echo " <td class='detail' align='right'><input type='text' name='".attr($iname)."' id='paying_".attr($var_index)."' " .
70 " value='" . '' . "' onchange='coloring();calctotal()' autocomplete='off' " .
71 "onkeyup='calctotal()' style='width:50px'/></td>\n";
75 // Post a payment to the payments table.
77 function frontPayment($patient_id, $encounter, $method, $source, $amount1, $amount2) {
79 $tmprow = sqlQuery("SELECT date FROM form_encounter WHERE " .
80 "encounter=? and pid=?",
81 array($encounter,$patient_id));
82 //the manipulation is done to insert the amount paid into payments table in correct order to show in front receipts report,
83 //if the payment is for today's encounter it will be shown in the report under today field and otherwise shown as previous
84 $tmprowArray=explode(' ',$tmprow['date']);
85 if(date('Y-m-d')==$tmprowArray[0])
101 $payid = sqlInsert("INSERT INTO payments ( " .
102 "pid, encounter, dtime, user, method, source, amount1, amount2 " .
103 ") VALUES ( ?, ?, ?, ?, ?, ?, ?, ?)", array($patient_id,$encounter,$timestamp,$_SESSION['authUser'],$method,$source,$amount1,$amount2) );
107 // We use this to put dashes, colons, etc. back into a timestamp.
109 function decorateString($fmt, $str) {
112 $fc = substr($fmt, 0, 1);
113 $fmt = substr($fmt, 1);
115 $res .= substr($str, 0, 1);
116 $str = substr($str, 1);
124 // Compute taxes from a tax rate string and a possibly taxable amount.
126 function calcTaxes($row, $amount) {
128 if (empty($row['taxrates'])) return $total;
129 $arates = explode(':', $row['taxrates']);
130 if (empty($arates)) return $total;
131 foreach ($arates as $value) {
132 if (empty($value)) continue;
133 $trow = sqlQuery("SELECT option_value FROM list_options WHERE " .
134 "list_id = 'taxrate' AND option_id = ? LIMIT 1", array($value) );
135 if (empty($trow['option_value'])) {
136 echo "<!-- Missing tax rate '".text($value)."'! -->\n";
139 $tax = sprintf("%01.2f", $amount * $trow['option_value']);
140 // echo "<!-- Rate = '$value', amount = '$amount', tax = '$tax' -->\n";
147 $today = date('Y-m-d', $now);
148 $timestamp = date('Y-m-d H:i:s', $now);
150 if (!$INTEGRATED_AR) slInitialize();
152 // $patdata = getPatientData($pid, 'fname,lname,pubpid');
154 $patdata = sqlQuery("SELECT " .
155 "p.fname, p.mname, p.lname, p.pubpid,p.pid, i.copay " .
156 "FROM patient_data AS p " .
157 "LEFT OUTER JOIN insurance_data AS i ON " .
158 "i.pid = p.pid AND i.type = 'primary' " .
159 "WHERE p.pid = ? ORDER BY i.date DESC LIMIT 1", array($pid) );
161 $alertmsg = ''; // anything here pops up in an alert box
163 // If the Save button was clicked...
164 if ($_POST['form_save']) {
165 $form_pid = $_POST['form_pid'];
166 $form_method = trim($_POST['form_method']);
167 $form_source = trim($_POST['form_source']);
168 $patdata = getPatientData($form_pid, 'fname,mname,lname,pubpid');
169 $NameNew=$patdata['fname'] . " " .$patdata['lname']. " " .$patdata['mname'];
171 if($_REQUEST['radio_type_of_payment']=='pre_payment')
173 $payment_id = idSqlStatement("insert into ar_session set " .
179 ", check_date = now() , deposit_date = now() " .
181 ", payment_type = 'patient'" .
182 ", description = ?" .
183 ", adjustment_code = 'pre_payment'" .
184 ", post_to_date = now() " .
185 ", payment_method = ?",
186 array(0,$form_pid,$_SESSION['authUserID'],0,$form_source,$_REQUEST['form_prepayment'],$NameNew,$form_method));
188 frontPayment($form_pid, 0, $form_method, $form_source, $_REQUEST['form_prepayment'], 0);//insertion to 'payments' table.
191 if ($_POST['form_upay'] && $_REQUEST['radio_type_of_payment']!='pre_payment') {
192 foreach ($_POST['form_upay'] as $enc => $payment) {
193 if ($amount = 0 +
$payment) {
195 if($_REQUEST['radio_type_of_payment']=='invoice_balance')
203 $enc = calendar_arrived($form_pid);
206 //----------------------------------------------------------------------------------------------------
207 //Fetching the existing code and modifier
208 $ResultSearchNew = sqlStatement("SELECT * FROM billing LEFT JOIN code_types ON billing.code_type=code_types.ct_key ".
209 "WHERE code_types.ct_fee=1 AND billing.activity!=0 AND billing.pid =? AND encounter=? ORDER BY billing.code,billing.modifier",
210 array($form_pid,$enc));
211 if($RowSearch = sqlFetchArray($ResultSearchNew))
213 $Codetype=$RowSearch['code_type'];
214 $Code=$RowSearch['code'];
215 $Modifier=$RowSearch['modifier'];
223 //----------------------------------------------------------------------------------------------------
224 if($_REQUEST['radio_type_of_payment']=='copay')//copay saving to ar_session and ar_activity tables
226 $session_id=idSqlStatement("INSERT INTO ar_session (payer_id,user_id,reference,check_date,deposit_date,pay_total,".
227 " global_amount,payment_type,description,patient_id,payment_method,adjustment_code,post_to_date) ".
228 " VALUES ('0',?,?,now(),now(),?,'','patient','COPAY',?,?,'patient_payment',now())",
229 array($_SESSION['authId'],$form_source,$amount,$form_pid,$form_method));
231 $insrt_id=idSqlStatement("INSERT INTO ar_activity (pid,encounter,code_type,code,modifier,payer_type,post_time,post_user,session_id,pay_amount,account_code)".
232 " VALUES (?,?,?,?,?,0,now(),?,?,?,'PCP')",
233 array($form_pid,$enc,$Codetype,$Code,$Modifier,$_SESSION['authId'],$session_id,$amount));
235 frontPayment($form_pid, $enc, $form_method, $form_source, $amount, 0);//insertion to 'payments' table.
237 if($_REQUEST['radio_type_of_payment']=='invoice_balance' ||
$_REQUEST['radio_type_of_payment']=='cash')
238 { //Payment by patient after insurance paid, cash patients similar to do not bill insurance in feesheet.
239 if($_REQUEST['radio_type_of_payment']=='cash')
241 sqlStatement("update form_encounter set last_level_closed=? where encounter=? and pid=? ",
242 array(4,$enc,$form_pid));
243 sqlStatement("update billing set billed=? where encounter=? and pid=?",
244 array(1,$enc,$form_pid));
246 $adjustment_code='patient_payment';
247 $payment_id = idSqlStatement("insert into ar_session set " .
253 ", check_date = now() , deposit_date = now() " .
255 ", payment_type = 'patient'" .
256 ", description = ?" .
257 ", adjustment_code = ?" .
258 ", post_to_date = now() " .
259 ", payment_method = ?",
260 array(0,$form_pid,$_SESSION['authUserID'],0,$form_source,$amount,$NameNew,$adjustment_code,$form_method));
262 //--------------------------------------------------------------------------------------------------------------------
264 frontPayment($form_pid, $enc, $form_method, $form_source, 0, $amount);//insertion to 'payments' table.
266 //--------------------------------------------------------------------------------------------------------------------
268 $resMoneyGot = sqlStatement("SELECT sum(pay_amount) as PatientPay FROM ar_activity where pid =? and ".
269 "encounter =? and payer_type=0 and account_code='PCP'",
270 array($form_pid,$enc));//new fees screen copay gives account_code='PCP'
271 $rowMoneyGot = sqlFetchArray($resMoneyGot);
272 $Copay=$rowMoneyGot['PatientPay'];
274 //--------------------------------------------------------------------------------------------------------------------
276 //Looping the existing code and modifier
277 $ResultSearchNew = sqlStatement("SELECT * FROM billing LEFT JOIN code_types ON billing.code_type=code_types.ct_key WHERE code_types.ct_fee=1 ".
278 "AND billing.activity!=0 AND billing.pid =? AND encounter=? ORDER BY billing.code,billing.modifier",
279 array($form_pid,$enc));
280 while($RowSearch = sqlFetchArray($ResultSearchNew))
282 $Codetype=$RowSearch['code_type'];
283 $Code=$RowSearch['code'];
284 $Modifier =$RowSearch['modifier'];
285 $Fee =$RowSearch['fee'];
287 $resMoneyGot = sqlStatement("SELECT sum(pay_amount) as MoneyGot FROM ar_activity where pid =? ".
288 "and code_type=? and code=? and modifier=? and encounter =? and !(payer_type=0 and account_code='PCP')",
289 array($form_pid,$Codetype,$Code,$Modifier,$enc));
290 //new fees screen copay gives account_code='PCP'
291 $rowMoneyGot = sqlFetchArray($resMoneyGot);
292 $MoneyGot=$rowMoneyGot['MoneyGot'];
294 $resMoneyAdjusted = sqlStatement("SELECT sum(adj_amount) as MoneyAdjusted FROM ar_activity where ".
295 "pid =? and code_type=? and code=? and modifier=? and encounter =?",
296 array($form_pid,$Codetype,$Code,$Modifier,$enc));
297 $rowMoneyAdjusted = sqlFetchArray($resMoneyAdjusted);
298 $MoneyAdjusted=$rowMoneyAdjusted['MoneyAdjusted'];
300 $Remainder=$Fee-$Copay-$MoneyGot-$MoneyAdjusted;
302 if(round($Remainder,2)!=0 && $amount!=0)
304 if($amount-$Remainder >= 0)
306 $insert_value=$Remainder;
307 $amount=$amount-$Remainder;
311 $insert_value=$amount;
314 sqlStatement("insert into ar_activity set " .
321 ", post_time = now() " .
326 ", account_code = 'PP'",
327 array($form_pid,$enc,$Codetype,$Code,$Modifier,0,$_SESSION['authUserID'],$payment_id,$insert_value,0));
330 if($amount!=0)//if any excess is there.
332 sqlStatement("insert into ar_activity set " .
339 ", post_time = now() " .
344 ", account_code = 'PP'",
345 array($form_pid,$enc,$Codetype,$Code,$Modifier,0,$_SESSION['authUserID'],$payment_id,$amount,0));
348 //--------------------------------------------------------------------------------------------------------------------
350 }//if ($amount = 0 + $payment)
352 }//if ($_POST['form_upay'])
353 }//if ($_POST['form_save'])
355 if ($_POST['form_save'] ||
$_REQUEST['receipt']) {
357 if ($_REQUEST['receipt']) {
358 $form_pid = $_GET['patient'];
359 $timestamp = decorateString('....-..-.. ..:..:..', $_GET['time']);
362 // Get details for what we guess is the primary facility.
363 $frow = sqlQuery("SELECT * FROM facility " .
364 "ORDER BY billing_location DESC, accepts_assignment DESC, id LIMIT 1");
366 // Get the patient's name and chart number.
367 $patdata = getPatientData($form_pid, 'fname,mname,lname,pubpid');
369 // Re-fetch payment info.
370 $payrow = sqlQuery("SELECT " .
371 "SUM(amount1) AS amount1, " .
372 "SUM(amount2) AS amount2, " .
373 "MAX(method) AS method, " .
374 "MAX(source) AS source, " .
375 "MAX(dtime) AS dtime, " .
376 // "MAX(user) AS user " .
377 "MAX(user) AS user, " .
378 "MAX(encounter) as encounter ".
379 "FROM payments WHERE " .
380 "pid = ? AND dtime = ?", array($form_pid,$timestamp) );
382 // Create key for deleting, just in case.
383 $ref_id = ($_REQUEST['radio_type_of_payment']=='copay') ?
$session_id : $payment_id ;
384 $payment_key = $form_pid . '.' . preg_replace('/[^0-9]/', '', $timestamp).'.'.$ref_id;
386 // get facility from encounter
390 WHERE encounter = ?", array($payrow['encounter']) );
391 $frow = sqlQuery("SELECT * FROM facility " .
392 " WHERE id = ?", array($tmprow['facility_id']) );
394 // Now proceed with printing the receipt.
397 <title
><?php
echo xlt('Receipt for Payment'); ?
></title
>
398 <script type
="text/javascript" src
="../../library/dialog.js"></script
>
399 <script language
="JavaScript">
401 <?php
require($GLOBALS['srcdir'] . "/restoreSession.php"); ?
>
403 // Process click on Print button.
405 var divstyle
= document
.getElementById('hideonprint').style
;
406 divstyle
.display
= 'none';
408 // divstyle.display = 'block';
410 // Process click on Delete button.
411 function deleteme() {
412 dlgopen('deleter.php?payment=<?php echo $payment_key ?>', '_blank', 500, 450);
415 // Called by the deleteme.php window on a successful delete.
416 function imdeleted() {
420 // Called to switch to the specified encounter having the specified DOS.
421 // This also closes the popup window.
422 function toencounter(enc
, datestr
, topframe
) {
423 topframe
.restoreSession();
424 <?php
if ($GLOBALS['concurrent_layout']) { ?
>
425 // Hard-coding of RBot for this purpose is awkward, but since this is a
426 // pop-up and our openemr is left_nav, we have no good clue as to whether
427 // the top frame is more appropriate.
428 topframe
.left_nav
.forceDual();
429 topframe
.left_nav
.setEncounter(datestr
, enc
, '');
430 topframe
.left_nav
.setRadio('RBot', 'enc');
431 topframe
.left_nav
.loadFrame('enc2', 'RBot', 'patient_file/encounter/encounter_top.php?set_encounter=' + enc
);
433 topframe
.Title
.location
.href
= 'encounter/encounter_title.php?set_encounter=' + enc
;
434 topframe
.Main
.location
.href
= 'encounter/patient_encounter.php?set_encounter=' + enc
;
441 <body bgcolor
='#ffffff'>
444 <p
><h2
><?php
echo xlt('Receipt for Payment'); ?
></h2
>
446 <p
><?php
echo text($frow['name']) ?
>
447 <br
><?php
echo text($frow['street']) ?
>
448 <br
><?php
echo text($frow['city'] . ', ' . $frow['state']) . ' ' .
449 text($frow['postal_code']) ?
>
450 <br
><?php
echo htmlentities($frow['phone']) ?
>
453 <table border
='0' cellspacing
='8'>
455 <td
><?php
echo xlt('Date'); ?
>:</td
>
456 <td
><?php
echo text(oeFormatSDFT(strtotime($payrow['dtime']))) ?
></td
>
459 <td
><?php
echo xlt('Patient'); ?
>:</td
>
460 <td
><?php
echo text($patdata['fname']) . " " . text($patdata['mname']) . " " .
461 text($patdata['lname']) . " (" . text($patdata['pubpid']) . ")" ?
></td
>
464 <td
><?php
echo xlt('Paid Via'); ?
>:</td
>
465 <td
><?php
echo generate_display_field(array('data_type'=>'1','list_id'=>'payment_method'),$payrow['method']); ?
></td
>
468 <td
><?php
echo xlt('Check/Ref Number'); ?
>:</td
>
469 <td
><?php
echo text($payrow['source']) ?
></td
>
472 <td
><?php
echo xlt('Amount for This Visit'); ?
>:</td
>
473 <td
><?php
echo text(oeFormatMoney($payrow['amount1'])) ?
></td
>
476 <td
><?php
echo xlt('Amount for Past Balance'); ?
>:</td
>
477 <td
><?php
echo text(oeFormatMoney($payrow['amount2'])) ?
></td
>
480 <td
><?php
echo xlt('Received By'); ?
>:</td
>
481 <td
><?php
echo text($payrow['user']) ?
></td
>
485 <div id
='hideonprint'>
487 <input type
='button' value
='<?php echo xla('Print'); ?>' onclick
='printme()' />
490 $todaysenc = todaysEncounterIf($pid);
491 if ($todaysenc && $todaysenc != $encounter) {
492 echo " <input type='button' " .
493 "value='" . xla('Open Today`s Visit') . "' " .
494 "onclick='toencounter($todaysenc,\"$today\",opener.top)' />\n";
498 <?php
if (acl_check('admin', 'super')) { ?
>
500 <input type
='button' value
='<?php xl('Delete
','e
'); ?>' style
='color:red' onclick
='deleteme()' />
509 // End of receipt printing logic.
513 // Here we display the form for data entry.
516 <title
><?php
echo xlt('Record Payment'); ?
></title
>
518 <style type
="text/css">
519 body
{ font
-family
:sans
-serif
; font
-size
:10pt
; font
-weight
:normal
}
520 .dehead
{ color
:#000000; font-family:sans-serif; font-size:10pt; font-weight:bold }
521 .detail
{ color
:#000000; font-family:sans-serif; font-size:10pt; font-weight:normal }
525 background
-color
: #FBFDD0;
526 border
: 1px solid
#ccc;
531 <link rel
="stylesheet" href
="<?php echo $css_header;?>" type
="text/css">
533 <!-- supporting javascript code
-->
534 <script type
="text/javascript" src
="<?php echo $GLOBALS['webroot'] ?>/library/js/jquery.js"></script
>
536 <script type
="text/javascript" src
="<?php echo $GLOBALS['webroot'] ?>/library/dialog.js"></script
>
540 <link rel
="stylesheet" href
="<?php echo $css_header;?>" type
="text/css">
541 <link rel
="stylesheet" type
="text/css" href
="../../library/js/fancybox/jquery.fancybox-1.2.6.css" media
="screen" />
542 <style type
="text/css">@import
url(../../library
/dynarch_calendar
.css
);</style
>
543 <script type
="text/javascript" src
="../../library/textformat.js"></script
>
544 <script type
="text/javascript" src
="../../library/dynarch_calendar.js"></script
>
545 <?php
include_once("{$GLOBALS['srcdir']}/dynarch_calendar_en.inc.php"); ?
>
546 <script type
="text/javascript" src
="../../library/dynarch_calendar_setup.js"></script
>
547 <script type
="text/javascript" src
="../../library/dialog.js"></script
>
548 <script type
="text/javascript" src
="../../library/js/jquery.1.3.2.js"></script
>
549 <script type
="text/javascript" src
="../../library/js/common.js"></script
>
550 <script type
="text/javascript" src
="../../library/js/fancybox/jquery.fancybox-1.2.6.js"></script
>
551 <script type
="text/javascript" src
="../../library/js/jquery.easydrag.handler.beta2.js"></script
>
552 <script language
='JavaScript'>
555 <?php
include_once("{$GLOBALS['srcdir']}/ajax/payment_ajax_jav.inc.php"); ?
>
556 <script language
="javascript" type
="text/javascript">
557 document
.onclick
=HideTheAjaxDivs
;
560 <script type
="text/javascript" src
="../../library/topdialog.js"></script
>
562 <script language
="JavaScript">
563 <?php
require($GLOBALS['srcdir'] . "/restoreSession.php"); ?
>
565 function calctotal() {
566 var f
= document
.forms
[0];
568 for (var i
= 0; i
< f
.elements
.length
; ++i
) {
569 var elem
= f
.elements
[i
];
570 var ename
= elem
.name
;
571 if (ename
.indexOf('form_upay[') == 0 || ename
.indexOf('form_bpay[') == 0) {
572 if (elem
.value
.length
> 0) total +
= Number(elem
.value
);
575 f
.form_paytotal
.value
= Number(total
).toFixed(2);
580 for (var i
= 1; ; ++i
)
582 if(document
.getElementById('paying_'+i
))
584 paying
=document
.getElementById('paying_'+i
).value
*1;
585 patient_balance
=document
.getElementById('duept_'+i
).innerHTML
*1;
586 //balance=document.getElementById('balance_'+i).innerHTML*1;
587 if(patient_balance
>0 && paying
>0)
589 if(paying
>patient_balance
)
591 document
.getElementById('paying_'+i
).style
.background
='#FF0000';
593 else if(paying
<patient_balance
)
595 document
.getElementById('paying_'+i
).style
.background
='#99CC00';
597 else if(paying
==patient_balance
)
599 document
.getElementById('paying_'+i
).style
.background
='#ffffff';
604 document
.getElementById('paying_'+i
).style
.background
='#ffffff';
613 function CheckVisible(MakeBlank
)
614 {//Displays and hides the check number text box.
615 if(document
.getElementById('form_method').options
[document
.getElementById('form_method').selectedIndex
].value
=='check_payment' ||
616 document
.getElementById('form_method').options
[document
.getElementById('form_method').selectedIndex
].value
=='bank_draft' )
618 document
.getElementById('check_number').disabled
=false;
622 document
.getElementById('check_number').disabled
=true;
627 var f
= document
.forms
[0];
629 top
.restoreSession();
631 if(((document
.getElementById('form_method').options
[document
.getElementById('form_method').selectedIndex
].value
=='check_payment' ||
632 document
.getElementById('form_method').options
[document
.getElementById('form_method').selectedIndex
].value
=='bank_draft') &&
633 document
.getElementById('check_number').value
=='' ))
635 alert("<?php echo addslashes( xl('Please Fill the Check/Ref Number')) ?>");
636 document
.getElementById('check_number').focus();
640 if(document
.getElementById('radio_type_of_payment_self1').checked
==false && document
.getElementById('radio_type_of_payment_self2').checked
==false && document
.getElementById('radio_type_of_payment1').checked
==false && document
.getElementById('radio_type_of_payment2').checked
==false && document
.getElementById('radio_type_of_payment5').checked
==false && document
.getElementById('radio_type_of_payment4').checked
==false)
642 alert("<?php echo addslashes( xl('Please Select Type Of Payment.')) ?>");
645 if(document
.getElementById('radio_type_of_payment_self1').checked
==true || document
.getElementById('radio_type_of_payment_self2').checked
==true || document
.getElementById('radio_type_of_payment1').checked
==true || document
.getElementById('radio_type_of_payment5').checked
==true)
647 for (var i
= 0; i
< f
.elements
.length
; ++i
)
649 var elem
= f
.elements
[i
];
650 var ename
= elem
.name
;
651 if (ename
.indexOf('form_upay[0') == 0) //Today is this text box.
654 {//A warning message, if the amount is posted with out encounter.
655 if(confirm("<?php echo addslashes( xl('Are you sure to post for today?')) ?>"))
670 if(document
.getElementById('radio_type_of_payment1').checked
==true)//CO-PAY
673 for (var i
= 0; i
< f
.elements
.length
; ++i
)
675 var elem
= f
.elements
[i
];
676 var ename
= elem
.name
;
677 if (ename
.indexOf('form_upay[') == 0) //Today is this text box.
679 if(f
.form_paytotal
.value
*1!=elem
.value
*1)//Total CO-PAY is not posted against today
680 {//A warning message, if the amount is posted against an old encounter.
681 if(confirm("<?php echo addslashes( xl('You are posting against an old encounter?')) ?>"))
695 else if(document
.getElementById('radio_type_of_payment2').checked
==true)//Invoice Balance
697 if(document
.getElementById('Today').innerHTML
=='')
699 for (var i
= 0; i
< f
.elements
.length
; ++i
)
701 var elem
= f
.elements
[i
];
702 var ename
= elem
.name
;
703 if (ename
.indexOf('form_upay[') == 0)
705 if (elem
.value
*1 > 0)
707 alert("<?php echo addslashes( xl('Invoice Balance cannot be posted. No Encounter is created.')) ?>");
717 if(confirm("<?php echo addslashes( xl('Would you like to save?')) ?>"))
727 function cursor_pointer()
728 {//Point the cursor to the latest encounter(Today)
729 var f
= document
.forms
[0];
731 for (var i
= 0; i
< f
.elements
.length
; ++i
)
733 var elem
= f
.elements
[i
];
734 var ename
= elem
.name
;
735 if (ename
.indexOf('form_upay[') == 0)
742 //=====================================================
743 function make_it_hide_enc_pay()
745 document
.getElementById('td_head_insurance_payment').style
.display
="none";
746 document
.getElementById('td_head_patient_co_pay').style
.display
="none";
747 document
.getElementById('td_head_co_pay').style
.display
="none";
748 document
.getElementById('td_head_insurance_balance').style
.display
="none";
749 for (var i
= 1; ; ++i
)
751 var td_inspaid_elem
= document
.getElementById('td_inspaid_'+i
)
752 var td_patient_copay_elem
= document
.getElementById('td_patient_copay_'+i
)
753 var td_copay_elem
= document
.getElementById('td_copay_'+i
)
754 var balance_elem
= document
.getElementById('balance_'+i
)
757 td_inspaid_elem
.style
.display
="none";
758 td_patient_copay_elem
.style
.display
="none";
759 td_copay_elem
.style
.display
="none";
760 balance_elem
.style
.display
="none";
767 document
.getElementById('td_total_4').style
.display
="none";
768 document
.getElementById('td_total_7').style
.display
="none";
769 document
.getElementById('td_total_8').style
.display
="none";
770 document
.getElementById('td_total_6').style
.display
="none";
772 document
.getElementById('table_display').width
="420px";
775 //=====================================================
776 function make_visible()
778 document
.getElementById('td_head_rep_doc').style
.display
="";
779 document
.getElementById('td_head_description').style
.display
="";
780 document
.getElementById('td_head_total_charge').style
.display
="none";
781 document
.getElementById('td_head_insurance_payment').style
.display
="none";
782 document
.getElementById('td_head_patient_payment').style
.display
="none";
783 document
.getElementById('td_head_patient_co_pay').style
.display
="none";
784 document
.getElementById('td_head_co_pay').style
.display
="none";
785 document
.getElementById('td_head_insurance_balance').style
.display
="none";
786 document
.getElementById('td_head_patient_balance').style
.display
="none";
787 for (var i
= 1; ; ++i
)
789 var td_charges_elem
= document
.getElementById('td_charges_'+i
)
790 var td_inspaid_elem
= document
.getElementById('td_inspaid_'+i
)
791 var td_ptpaid_elem
= document
.getElementById('td_ptpaid_'+i
)
792 var td_patient_copay_elem
= document
.getElementById('td_patient_copay_'+i
)
793 var td_copay_elem
= document
.getElementById('td_copay_'+i
)
794 var balance_elem
= document
.getElementById('balance_'+i
)
795 var duept_elem
= document
.getElementById('duept_'+i
)
798 td_charges_elem
.style
.display
="none";
799 td_inspaid_elem
.style
.display
="none";
800 td_ptpaid_elem
.style
.display
="none";
801 td_patient_copay_elem
.style
.display
="none";
802 td_copay_elem
.style
.display
="none";
803 balance_elem
.style
.display
="none";
804 duept_elem
.style
.display
="none";
811 document
.getElementById('td_total_7').style
.display
="";
812 document
.getElementById('td_total_8').style
.display
="";
813 document
.getElementById('td_total_1').style
.display
="none";
814 document
.getElementById('td_total_2').style
.display
="none";
815 document
.getElementById('td_total_3').style
.display
="none";
816 document
.getElementById('td_total_4').style
.display
="none";
817 document
.getElementById('td_total_5').style
.display
="none";
818 document
.getElementById('td_total_6').style
.display
="none";
820 document
.getElementById('table_display').width
="505px";
822 function make_it_hide()
824 document
.getElementById('td_head_rep_doc').style
.display
="none";
825 document
.getElementById('td_head_description').style
.display
="none";
826 document
.getElementById('td_head_total_charge').style
.display
="";
827 document
.getElementById('td_head_insurance_payment').style
.display
="";
828 document
.getElementById('td_head_patient_payment').style
.display
="";
829 document
.getElementById('td_head_patient_co_pay').style
.display
="";
830 document
.getElementById('td_head_co_pay').style
.display
="";
831 document
.getElementById('td_head_insurance_balance').style
.display
="";
832 document
.getElementById('td_head_patient_balance').style
.display
="";
833 for (var i
= 1; ; ++i
)
835 var td_charges_elem
= document
.getElementById('td_charges_'+i
)
836 var td_inspaid_elem
= document
.getElementById('td_inspaid_'+i
)
837 var td_ptpaid_elem
= document
.getElementById('td_ptpaid_'+i
)
838 var td_patient_copay_elem
= document
.getElementById('td_patient_copay_'+i
)
839 var td_copay_elem
= document
.getElementById('td_copay_'+i
)
840 var balance_elem
= document
.getElementById('balance_'+i
)
841 var duept_elem
= document
.getElementById('duept_'+i
)
844 td_charges_elem
.style
.display
="";
845 td_inspaid_elem
.style
.display
="";
846 td_ptpaid_elem
.style
.display
="";
847 td_patient_copay_elem
.style
.display
="";
848 td_copay_elem
.style
.display
="";
849 balance_elem
.style
.display
="";
850 duept_elem
.style
.display
="";
857 document
.getElementById('td_total_1').style
.display
="";
858 document
.getElementById('td_total_2').style
.display
="";
859 document
.getElementById('td_total_3').style
.display
="";
860 document
.getElementById('td_total_4').style
.display
="";
861 document
.getElementById('td_total_5').style
.display
="";
862 document
.getElementById('td_total_6').style
.display
="";
863 document
.getElementById('td_total_7').style
.display
="";
864 document
.getElementById('td_total_8').style
.display
="";
866 document
.getElementById('table_display').width
="635px";
868 function make_visible_radio()
870 document
.getElementById('tr_radio1').style
.display
="";
871 document
.getElementById('tr_radio2').style
.display
="none";
873 function make_hide_radio()
875 document
.getElementById('tr_radio1').style
.display
="none";
876 document
.getElementById('tr_radio2').style
.display
="";
878 function make_visible_row()
880 document
.getElementById('table_display').style
.display
="";
881 document
.getElementById('table_display_prepayment').style
.display
="none";
883 function make_hide_row()
885 document
.getElementById('table_display').style
.display
="none";
886 document
.getElementById('table_display_prepayment').style
.display
="";
892 make_it_hide_enc_pay();
893 document
.getElementById('radio_type_of_payment_self1').checked
=true;
896 function make_insurance()
901 document
.getElementById('radio_type_of_payment1').checked
=true;
907 <body
class="body_top" onunload
='imclosing()' onLoad
="cursor_pointer();">
910 <form method
='post' action
='front_payment.php<?php if ($payid) echo "?payid=$payid"; ?>'
911 onsubmit
='return validate();'>
912 <input type
='hidden' name
='form_pid' value
='<?php echo attr($pid) ?>' />
915 <table border
='0' cellspacing
='0' cellpadding
="0">
918 <td colspan
="3"> 
;</td
>
922 <td colspan
='3' align
='center' class='text' >
923 <b
><?php
echo htmlspecialchars(xl('Accept Payment for'), ENT_QUOTES
); ?
> 
;: 
; 
;<?php
echo htmlspecialchars($patdata['fname'], ENT_QUOTES
) . " " .
924 htmlspecialchars($patdata['lname'], ENT_QUOTES
) . " " .htmlspecialchars($patdata['mname'], ENT_QUOTES
). " (" . htmlspecialchars($patdata['pid'], ENT_QUOTES
) . ")" ?
></b
>
925 <?php
$NameNew=$patdata['fname'] . " " .$patdata['lname']. " " .$patdata['mname'];?
>
929 <tr height
="15"><td colspan
='3'></td
></tr
>
934 <?php
echo xlt('Payment Method'); ?
>:
937 <select name
="form_method" id
="form_method" class="text" onChange
='CheckVisible("yes")'>
939 $query1112 = "SELECT * FROM list_options where list_id=? ORDER BY seq, title ";
940 $bres1112 = sqlStatement($query1112,array('payment_method'));
941 while ($brow1112 = sqlFetchArray($bres1112))
943 if($brow1112['option_id']=='electronic' ||
$brow1112['option_id']=='bank_draft')
945 echo "<option value='".htmlspecialchars($brow1112['option_id'], ENT_QUOTES
)."'>".htmlspecialchars(xl_list_label($brow1112['title']), ENT_QUOTES
)."</option>";
952 <tr height
="5"><td colspan
='3'></td
></tr
>
956 <?php
echo xla('Check/Ref Number'); ?
>:
958 <td colspan
='2' ><div id
="ajax_div_patient" style
="display:none;"></div
>
959 <input type
='text' id
="check_number" name
='form_source' style
="width:120px" value
='<?php echo htmlspecialchars($payrow['source
'], ENT_QUOTES); ?>'>
962 <tr height
="5"><td colspan
='3'></td
></tr
>
965 <td
class='text' valign
="middle" >
966 <?php
echo htmlspecialchars(xl('Patient Coverage'), ENT_QUOTES
); ?
>:
968 <td
class='text' colspan
="2" ><input type
="radio" name
="radio_type_of_coverage" id
="radio_type_of_coverage1" value
="self" onClick
="make_visible_radio();make_self();"/><?php
echo htmlspecialchars(xl('Self'), ENT_QUOTES
); ?
><input type
="radio" name
="radio_type_of_coverage" id
="radio_type_of_coverag2" value
="insurance" checked
="checked" onClick
="make_hide_radio();make_insurance();"/><?php
echo htmlspecialchars(xl('Insurance'), ENT_QUOTES
); ?
> </td
>
971 <tr height
="5"><td colspan
='3'></td
></tr
>
973 <tr id
="tr_radio1" style
="display:none"><!-- For radio Insurance
-->
974 <td
class='text' valign
="top" >
975 <?php
echo htmlspecialchars(xl('Payment against'), ENT_QUOTES
); ?
>:
977 <td
class='text' colspan
="2" ><input type
="radio" name
="radio_type_of_payment" id
="radio_type_of_payment_self1" value
="cash" onClick
="make_visible_row();make_it_hide_enc_pay();cursor_pointer();"/><?php
echo htmlspecialchars(xl('Encounter Payment'), ENT_QUOTES
); ?
></td
>
979 <tr id
="tr_radio2"><!-- For radio self
-->
980 <td
class='text' valign
="top" >
981 <?php
echo htmlspecialchars(xl('Payment against'), ENT_QUOTES
); ?
>:
983 <td
class='text' colspan
="2" ><input type
="radio" name
="radio_type_of_payment" id
="radio_type_of_payment1" value
="copay" checked
="checked" onClick
="make_visible_row();cursor_pointer();"/><?php
echo htmlspecialchars(xl('Co Pay'), ENT_QUOTES
); ?
><input type
="radio" name
="radio_type_of_payment" id
="radio_type_of_payment2" value
="invoice_balance" onClick
="make_visible_row();"/><?php
echo htmlspecialchars(xl('Invoice Balance'), ENT_QUOTES
); ?
><br
/><input type
="radio" name
="radio_type_of_payment" id
="radio_type_of_payment4" value
="pre_payment" onClick
="make_hide_row();"/><?php
echo htmlspecialchars(xl('Pre Pay'), ENT_QUOTES
); ?
></td
>
986 <tr height
="15"><td colspan
='3'></td
></tr
>
989 <table width
="200" border
="0" cellspacing
="0" cellpadding
="0" id
="table_display_prepayment" style
="display:none">
991 <td
class='detail'><?php
echo htmlspecialchars(xl('Pre Payment'), ENT_QUOTES
); ?
></td
>
992 <td
><input type
='text' name
='form_prepayment' style
='width:100px' /></td
>
996 <table border
='0' id
="table_display" cellpadding
='0' cellspacing
='0' width
='635'>
997 <tr bgcolor
="#cccccc" id
="tr_head">
998 <td
class="dehead" width
="70">
999 <?php
echo htmlspecialchars( xl('DOS'), ENT_QUOTES
) ?
>
1001 <td
class="dehead" width
="65">
1002 <?php
echo htmlspecialchars( xl('Encounter'), ENT_QUOTES
) ?
>
1004 <td
class="dehead" align
="center" width
="80" id
="td_head_total_charge" >
1005 <?php
echo htmlspecialchars( xl('Total Charge'), ENT_QUOTES
) ?
>
1007 <td
class="dehead" align
="center" width
="70" id
="td_head_rep_doc" style
='display:none'>
1008 <?php
echo htmlspecialchars( xl('Report/ Form'), ENT_QUOTES
) ?
>
1010 <td
class="dehead" align
="center" width
="200" id
="td_head_description" style
='display:none'>
1011 <?php
echo htmlspecialchars( xl('Description'), ENT_QUOTES
) ?
>
1013 <td
class="dehead" align
="center" width
="80" id
="td_head_insurance_payment" >
1014 <?php
echo htmlspecialchars( xl('Insurance Payment'), ENT_QUOTES
) ?
>
1016 <td
class="dehead" align
="center" width
="80" id
="td_head_patient_payment" >
1017 <?php
echo htmlspecialchars( xl('Patient Payment'), ENT_QUOTES
) ?
>
1019 <td
class="dehead" align
="center" width
="55" id
="td_head_patient_co_pay" >
1020 <?php
echo htmlspecialchars( xl('Co Pay Paid'), ENT_QUOTES
) ?
>
1022 <td
class="dehead" align
="center" width
="55" id
="td_head_co_pay" >
1023 <?php
echo htmlspecialchars( xl('Required Co Pay'), ENT_QUOTES
) ?
>
1025 <td
class="dehead" align
="center" width
="80" id
="td_head_insurance_balance" >
1026 <?php
echo htmlspecialchars( xl('Insurance Balance'), ENT_QUOTES
) ?
>
1028 <td
class="dehead" align
="center" width
="80" id
="td_head_patient_balance" >
1029 <?php
echo htmlspecialchars( xl('Patient Balance'), ENT_QUOTES
) ?
>
1031 <td
class="dehead" align
="center" width
="50">
1032 <?php
echo htmlspecialchars( xl('Paying'), ENT_QUOTES
) ?
>
1039 // Get the unbilled service charges and payments by encounter for this patient.
1041 $query = "SELECT fe.encounter, b.code_type, b.code, b.modifier, b.fee, " .
1042 "LEFT(fe.date, 10) AS encdate ,fe.last_level_closed " .
1043 "FROM form_encounter AS fe left join billing AS b on " .
1044 "b.pid = ? AND b.activity = 1 AND " .//AND b.billed = 0
1045 "b.code_type != 'TAX' AND b.fee != 0 " .
1046 "AND fe.pid = b.pid AND fe.encounter = b.encounter " .
1047 "where fe.pid = ? " .
1048 "ORDER BY b.encounter";
1049 $bres = sqlStatement($query,array($pid,$pid));
1051 while ($brow = sqlFetchArray($bres)) {
1052 $key = 0 - $brow['encounter'];
1053 if (empty($encs[$key])) {
1054 $encs[$key] = array(
1055 'encounter' => $brow['encounter'],
1056 'date' => $brow['encdate'],
1057 'last_level_closed' => $brow['last_level_closed'],
1061 if ($brow['code_type'] === 'COPAY') {
1062 //$encs[$key]['payments'] -= $brow['fee'];
1064 $encs[$key]['charges'] +
= $brow['fee'];
1067 $query = "SELECT taxrates FROM codes WHERE " .
1068 "code_type = ? AND " .
1070 array_push($sql_array,$code_types[$brow['code_type']]['id'],$brow['code']);
1071 if ($brow['modifier']) {
1072 $query .= "modifier = ?";
1073 array_push($sql_array,$brow['modifier']);
1075 $query .= "(modifier IS NULL OR modifier = '')";
1077 $query .= " LIMIT 1";
1078 $trow = sqlQuery($query,$sql_array);
1079 $encs[$key]['charges'] +
= calcTaxes($trow, $brow['fee']);
1083 // Do the same for unbilled product sales.
1085 $query = "SELECT fe.encounter, s.drug_id, s.fee, " .
1086 "LEFT(fe.date, 10) AS encdate,fe.last_level_closed " .
1087 "FROM form_encounter AS fe left join drug_sales AS s " .
1088 "on s.pid = ? AND s.fee != 0 " .//AND s.billed = 0
1089 "AND fe.pid = s.pid AND fe.encounter = s.encounter " .
1090 "where fe.pid = ? " .
1091 "ORDER BY s.encounter";
1093 $dres = sqlStatement($query,array($pid,$pid));
1095 while ($drow = sqlFetchArray($dres)) {
1096 $key = 0 - $drow['encounter'];
1097 if (empty($encs[$key])) {
1098 $encs[$key] = array(
1099 'encounter' => $drow['encounter'],
1100 'date' => $drow['encdate'],
1101 'last_level_closed' => $drow['last_level_closed'],
1105 $encs[$key]['charges'] +
= $drow['fee'];
1107 $trow = sqlQuery("SELECT taxrates FROM drug_templates WHERE drug_id = ? " .
1108 "ORDER BY selector LIMIT 1", array($drow['drug_id']) );
1109 $encs[$key]['charges'] +
= calcTaxes($trow, $drow['fee']);
1112 ksort($encs, SORT_NUMERIC
);
1114 //Bringing on top the Today always
1115 foreach ($encs as $key => $value) {
1116 $dispdate = $value['date'];
1117 if (strcmp($dispdate, $today) == 0 && !$gottoday) {
1123 // If no billing was entered yet for today, then generate a line for
1124 // entering today's co-pay.
1127 echoLine("form_upay[0]", date("Y-m-d"), 0, 0, 0, 0 /*$duept*/);//No encounter yet defined.
1131 foreach ($encs as $key => $value) {
1132 $enc = $value['encounter'];
1133 $dispdate = $value['date'];
1134 if (strcmp($dispdate, $today) == 0 && !$gottoday) {
1135 $dispdate = date("Y-m-d");
1138 //------------------------------------------------------------------------------------
1139 $inscopay = getCopay($pid, $dispdate);
1140 $patcopay = getPatientCopay($pid, $enc);
1143 $drow = sqlQuery("SELECT SUM(pay_amount) AS payments, " .
1144 "SUM(adj_amount) AS adjustments FROM ar_activity WHERE " .
1145 "pid = ? and encounter = ? and " .
1146 "payer_type != 0 and account_code!='PCP' ",
1148 $dpayment=$drow['payments'];
1149 $dadjustment=$drow['adjustments'];
1152 $drow = sqlQuery("SELECT SUM(pay_amount) AS payments, " .
1153 "SUM(adj_amount) AS adjustments FROM ar_activity WHERE " .
1154 "pid = ? and encounter = ? and " .
1155 "payer_type = 0 and account_code!='PCP' ",
1157 $dpayment_pat=$drow['payments'];
1159 //------------------------------------------------------------------------------------
1161 $ResultNumberOfInsurance = sqlStatement("SELECT COUNT( DISTINCT TYPE ) NumberOfInsurance FROM insurance_data
1162 where pid = ? and provider>0 ",array($pid));
1163 $RowNumberOfInsurance = sqlFetchArray($ResultNumberOfInsurance);
1164 $NumberOfInsurance=$RowNumberOfInsurance['NumberOfInsurance']*1;
1165 //------------------------------------------------------------------------------------
1167 if((($NumberOfInsurance==0 ||
$value['last_level_closed']==4 ||
$NumberOfInsurance== $value['last_level_closed'])))
1169 $brow = sqlQuery("SELECT SUM(fee) AS amount FROM billing WHERE " .
1170 "pid = ? and encounter = ? AND activity = 1",array($pid,$enc));
1171 $srow = sqlQuery("SELECT SUM(fee) AS amount FROM drug_sales WHERE " .
1172 "pid = ? and encounter = ? ",array($pid,$enc));
1173 $drow = sqlQuery("SELECT SUM(pay_amount) AS payments, " .
1174 "SUM(adj_amount) AS adjustments FROM ar_activity WHERE " .
1175 "pid = ? and encounter = ? ",array($pid,$enc));
1176 $duept= $brow['amount'] +
$srow['amount'] - $drow['payments'] - $drow['adjustments'];
1178 echoLine("form_upay[$enc]", $dispdate, $value['charges'],
1179 $dpayment_pat, ($dpayment +
$dadjustment), $duept,$enc,$inscopay,$patcopay);
1183 // Now list previously billed visits.
1185 if ($INTEGRATED_AR) {
1187 } // end $INTEGRATED_AR
1189 // Query for all open invoices.
1190 $query = "SELECT ar.id, ar.invnumber, ar.amount, ar.paid, " .
1191 "ar.intnotes, ar.notes, ar.shipvia, " .
1192 "(SELECT SUM(invoice.sellprice * invoice.qty) FROM invoice WHERE " .
1193 "invoice.trans_id = ar.id AND invoice.sellprice > 0) AS charges, " .
1194 "(SELECT SUM(invoice.sellprice * invoice.qty) FROM invoice WHERE " .
1195 "invoice.trans_id = ar.id AND invoice.sellprice < 0) AS adjustments, " .
1196 "(SELECT SUM(acc_trans.amount) FROM acc_trans WHERE " .
1197 "acc_trans.trans_id = ar.id AND acc_trans.chart_id = ? " .
1198 "AND acc_trans.source NOT LIKE 'Ins%') AS ptpayments " .
1199 "FROM ar WHERE ar.invnumber LIKE ? AND " .
1200 "ar.amount != ar.paid " .
1201 "ORDER BY ar.invnumber";
1202 $ires = SLQuery($query, array($chart_id_cash,$pid."%") );
1203 if ($sl_err) die($sl_err);
1204 $num_invoices = SLRowCount($ires);
1206 for ($ix = 0; $ix < $num_invoices; ++
$ix) {
1207 $irow = SLGetRow($ires, $ix);
1209 // Get encounter ID and date of service.
1210 list($patient_id, $enc) = explode(".", $irow['invnumber']);
1211 $tmp = sqlQuery("SELECT LEFT(date, 10) AS encdate FROM form_encounter " .
1212 "WHERE encounter = ?", array($enc) );
1213 $svcdate = $tmp['encdate'];
1215 // Compute $duncount as in sl_eob_search.php to determine if
1216 // this invoice is at patient responsibility.
1217 $duncount = substr_count(strtolower($irow['intnotes']), "statement sent");
1219 $insgot = strtolower($irow['notes']);
1220 $inseobs = strtolower($irow['shipvia']);
1221 foreach (array('ins1', 'ins2', 'ins3') as $value) {
1222 if (strpos($insgot, $value) !== false &&
1223 strpos($inseobs, $value) === false)
1228 $inspaid = $irow['paid'] +
$irow['ptpayments'] - $irow['adjustments'];
1229 $balance = $irow['amount'] - $irow['paid'];
1230 $duept = ($duncount < 0) ?
0 : $balance;
1232 echoLine("form_bpay[$enc]", $svcdate, $irow['charges'],
1233 0 - $irow['ptpayments'], $inspaid, $duept);
1235 } // end not $INTEGRATED_AR
1237 // Continue with display of the data entry form.
1240 <tr bgcolor
="#cccccc">
1241 <td
class="dehead" id
='td_total_1'></td
>
1242 <td
class="dehead" id
='td_total_2'></td
>
1243 <td
class="dehead" id
='td_total_3'></td
>
1244 <td
class="dehead" id
='td_total_4'></td
>
1245 <td
class="dehead" id
='td_total_5'></td
>
1246 <td
class="dehead" id
='td_total_6'></td
>
1247 <td
class="dehead" id
='td_total_7'></td
>
1248 <td
class="dehead" id
='td_total_8'></td
>
1249 <td
class="dehead" align
="right">
1250 <?php
echo htmlspecialchars( xl('Total'), ENT_QUOTES
);?
>
1252 <td
class="dehead" align
="right">
1253 <input type
='text' name
='form_paytotal' value
=''
1254 style
='color:#00aa00;width:50px' readonly
/>
1261 <input type
='submit' name
='form_save' value
='<?php echo htmlspecialchars( xl('Generate Invoice
'), ENT_QUOTES);?>' />  
;
1262 <input type
='button' value
='<?php echo xla('Cancel
'); ?>' onclick
='window.close()' />
1264 <input type
="hidden" name
="hidden_patient_code" id
="hidden_patient_code" value
="<?php echo attr($pid);?>"/>
1265 <input type
='hidden' name
='ajax_mode' id
='ajax_mode' value
='' />
1266 <input type
='hidden' name
='mode' id
='mode' value
='' />
1268 <script language
="JavaScript">
1276 if (!$INTEGRATED_AR) SLClose();