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 // This processes X12 835 remittances and produces a report.
11 // Buffer all output so we can archive it to a file.
14 require_once("../globals.php");
15 require_once("$srcdir/invoice_summary.inc.php");
16 require_once("$srcdir/sl_eob.inc.php");
17 require_once("$srcdir/parse_era.inc.php");
18 require_once("claim_status_codes.php");
19 require_once("adjustment_reason_codes.php");
20 require_once("remark_codes.php");
21 require_once("$srcdir/formatting.inc.php");
22 require_once("$srcdir/billing.inc");
24 $debug = $_GET['debug'] ?
1 : 0; // set to 1 for debugging mode
25 $paydate = parse_date($_GET['paydate']);
31 $invoice_total = 0.00;
32 $InsertionId;//last inserted ID of
33 $INTEGRATED_AR = $GLOBALS['oer_config']['ws_accounting']['enabled'] === 2;
35 ///////////////////////// Assorted Functions /////////////////////////
37 function parse_date($date) {
38 $date = substr(trim($date), 0, 10);
39 if (preg_match('/^(\d\d\d\d)\D*(\d\d)\D*(\d\d)$/', $date, $matches)) {
40 return $matches[1] . '-' . $matches[2] . '-' . $matches[3];
45 function writeMessageLine($bgcolor, $class, $description) {
47 " <tr bgcolor='$bgcolor'>\n" .
48 " <td class='$class' colspan='4'> </td>\n" .
49 " <td class='$class'>$description</td>\n" .
50 " <td class='$class' colspan='2'> </td>\n" .
55 function writeDetailLine($bgcolor, $class, $ptname, $invnumber,
56 $code, $date, $description, $amount, $balance)
58 global $last_ptname, $last_invnumber, $last_code;
59 if ($ptname == $last_ptname) $ptname = ' ';
60 else $last_ptname = $ptname;
61 if ($invnumber == $last_invnumber) $invnumber = ' ';
62 else $last_invnumber = $invnumber;
63 if ($code == $last_code) $code = ' ';
64 else $last_code = $code;
65 if ($amount ) $amount = sprintf("%.2f", $amount );
66 if ($balance) $balance = sprintf("%.2f", $balance);
68 " <tr bgcolor='$bgcolor'>\n" .
69 " <td class='$class'>$ptname</td>\n" .
70 " <td class='$class'>$invnumber</td>\n" .
71 " <td class='$class'>$code</td>\n" .
72 " <td class='$class'>" . oeFormatShortDate($date) . "</td>\n" .
73 " <td class='$class'>$description</td>\n" .
74 " <td class='$class' align='right'>" . oeFormatMoney($amount) . "</td>\n" .
75 " <td class='$class' align='right'>" . oeFormatMoney($balance) . "</td>\n" .
80 // This writes detail lines that were already in SQL-Ledger for a given
83 function writeOldDetail(&$prev, $ptname, $invnumber, $dos, $code, $bgcolor) {
84 global $invoice_total;
85 // $prev['total'] = 0.00; // to accumulate total charges
87 foreach ($prev['dtl'] as $dkey => $ddata) {
88 $ddate = substr($dkey, 0, 10);
89 $description = $ddata['src'] . $ddata['rsn'];
90 if ($ddate == ' ') { // this is the service item
92 $description = 'Service Item';
94 $amount = sprintf("%.2f", $ddata['chg'] - $ddata['pmt']);
95 $invoice_total = sprintf("%.2f", $invoice_total +
$amount);
96 writeDetailLine($bgcolor, 'olddetail', $ptname, $invnumber,
97 $code, $ddate, $description, $amount, $invoice_total);
101 // This is called back by parse_era() once per claim.
103 function era_callback_check(&$out)
106 global $InsertionId;//last inserted ID of
107 global $StringToEcho,$debug;
109 if($_GET['original']=='original')
111 $StringToEcho="<br/><br/><br/><br/><br/><br/>";
112 $StringToEcho.="<table border='1' cellpadding='0' cellspacing='0' width='750'>";
113 $StringToEcho.="<tr bgcolor='#cccccc'><td width='50'></td><td class='dehead' width='150' align='center'>".htmlspecialchars( xl('Check Number'), ENT_QUOTES
)."</td><td class='dehead' width='400' align='center'>".htmlspecialchars( xl('Payee Name'), ENT_QUOTES
)."</td><td class='dehead' width='150' align='center'>".htmlspecialchars( xl('Check Amount'), ENT_QUOTES
)."</td></tr>";
115 for ($check_count=1;$check_count<=$out['check_count'];$check_count++
)
117 if($check_count%2
==1)
125 $rs=sqlQ("select reference from ar_session where reference='".$out['check_number'.$check_count]."'");
126 if(sqlNumRows($rs)>0)
131 $StringToEcho.="<tr bgcolor='$bgcolor'>";
132 $StringToEcho.="<td><input type='checkbox' name='chk".$out['check_number'.$check_count]."' value='".$out['check_number'.$check_count]."'/></td>";
133 $StringToEcho.="<td>".htmlspecialchars($out['check_number'.$check_count])."</td>";
134 $StringToEcho.="<td>".htmlspecialchars($out['payee_name'.$check_count])."</td>";
135 $StringToEcho.="<td align='right'>".htmlspecialchars(number_format($out['check_amount'.$check_count],2))."</td>";
136 $StringToEcho.="</tr>";
138 $StringToEcho.="<tr bgcolor='#cccccc'><td colspan='4' align='center'><input type='submit' name='CheckSubmit' value='Submit'/></td></tr>";
139 if($WarningFlag==true)
140 $StringToEcho.="<tr bgcolor='#ff0000'><td colspan='4' align='center'>".htmlspecialchars( xl('Warning, Check Number already exist in the database'), ENT_QUOTES
)."</td></tr>";
141 $StringToEcho.="</table>";
145 for ($check_count=1;$check_count<=$out['check_count'];$check_count++
)
147 $chk_num=$out['check_number'.$check_count];
148 $chk_num=str_replace(' ','_',$chk_num);
149 if(isset($_REQUEST['chk'.$chk_num]))
151 $check_date=$out['check_date'.$check_count]?
$out['check_date'.$check_count]:$_REQUEST['paydate'];
152 $post_to_date=$_REQUEST['post_to_date']!=''?
$_REQUEST['post_to_date']:date('Y-m-d');
153 $deposit_date=$_REQUEST['deposit_date']!=''?
$_REQUEST['deposit_date']:date('Y-m-d');
154 $InsertionId[$out['check_number'.$check_count]]=arPostSession($_REQUEST['InsId'],$out['check_number'.$check_count],$out['check_date'.$check_count],$out['check_amount'.$check_count],$post_to_date,$deposit_date,$debug);
161 function era_callback(&$out) {
162 global $encount, $debug, $claim_status_codes, $adjustment_reasons, $remark_codes;
163 global $invoice_total, $last_code, $paydate, $INTEGRATED_AR;
164 global $InsertionId;//last inserted ID of
167 // Some heading information.
168 $chk_123=$out['check_number'];
169 $chk_123=str_replace(' ','_',$chk_123);
170 if(isset($_REQUEST['chk'.$chk_123])){
172 writeMessageLine('#ffffff', 'infdetail',
173 "Payer: " . htmlspecialchars($out['payer_name'], ENT_QUOTES
));
175 writeMessageLine('#ffffff', 'infdetail',
176 "WITHOUT UPDATE is selected; no changes will be applied.");
181 $invoice_total = 0.00;
182 $bgcolor = (++
$encount & 1) ?
"#ddddff" : "#ffdddd";
183 list($pid, $encounter, $invnumber) = slInvoiceNumber($out);
185 // Get details, if we have them, for the invoice.
188 if ($pid && $encounter) {
189 // Get invoice data into $arrow or $ferow.
190 if ($INTEGRATED_AR) {
191 $ferow = sqlQuery("SELECT e.*, p.fname, p.mname, p.lname " .
192 "FROM form_encounter AS e, patient_data AS p WHERE " .
193 "e.pid = '$pid' AND e.encounter = '$encounter' AND ".
196 $pid = $encounter = 0;
197 $invnumber = $out['our_claim_id'];
200 $codes = ar_get_invoice_summary($pid, $encounter, true);
201 // $svcdate = substr($ferow['date'], 0, 10);
203 } // end internal a/r
205 $arres = SLQuery("SELECT ar.id, ar.notes, ar.shipvia, customer.name " .
206 "FROM ar, customer WHERE ar.invnumber = '$invnumber' AND " .
207 "customer.id = ar.customer_id");
208 if ($sl_err) die($sl_err);
209 $arrow = SLGetRow($arres, 0);
212 $codes = get_invoice_summary($arrow['id'], true);
213 } else { // oops, no such invoice
214 $pid = $encounter = 0;
215 $invnumber = $out['our_claim_id'];
217 } // end not internal a/r
220 // Show the claim status.
221 $csc = $out['claim_status_code'];
223 if ($csc == '1' ||
$csc == '19') $inslabel = 'Ins1';
224 if ($csc == '2' ||
$csc == '20') $inslabel = 'Ins2';
225 if ($csc == '3' ||
$csc == '21') $inslabel = 'Ins3';
226 $primary = ($inslabel == 'Ins1');
227 writeMessageLine($bgcolor, 'infdetail',
228 "Claim status $csc: " . $claim_status_codes[$csc]);
230 // Show an error message if the claim is missing or already posted.
232 writeMessageLine($bgcolor, 'errdetail',
233 "The following claim is not in our database");
236 // Skip this test. Claims can get multiple CLPs from the same payer!
238 // $insdone = strtolower($arrow['shipvia']);
239 // if (strpos($insdone, 'ins1') !== false) {
241 // writeMessageLine($bgcolor, 'errdetail',
242 // "Primary insurance EOB was already posted for the following claim");
246 if ($csc == '4') {//Denial case, code is stored in the claims table for display in the billing manager screen with reason explained.
249 if ($pid && $encounter) {
251 foreach ($out['svc'] as $svc) {
252 foreach ($svc['adj'] as $adj) {//Per code and modifier the reason will be showed in the billing manager.
253 $code_value .= $svc['code'].'_'.$svc['mod'].'_'.$adj['group_code'].'_'.$adj['reason_code'].',';
256 $code_value = substr($code_value,0,-1);
257 //We store the reason code to display it with description in the billing manager screen.
258 //process_file is used as for the denial case file name will not be there, and extra field(to store reason) can be avoided.
259 updateClaim(true, $pid, $encounter, $_REQUEST['InsId'], substr($inslabel,3),7,0,$code_value);
262 writeMessageLine($bgcolor, 'errdetail',
263 "Not posting adjustments for denied claims, please follow up manually!");
265 else if ($csc == '22') {
267 writeMessageLine($bgcolor, 'errdetail',
268 "Payment reversals are not automated, please enter manually!");
271 if ($out['warnings']) {
272 writeMessageLine($bgcolor, 'infdetail', nl2br(rtrim($out['warnings'])));
275 // Simplify some claim attributes for cleaner code.
276 $service_date = parse_date($out['dos']);
277 $check_date = $paydate ?
$paydate : parse_date($out['check_date']);
278 $production_date = $paydate ?
$paydate : parse_date($out['production_date']);
280 if ($INTEGRATED_AR) {
281 $insurance_id = arGetPayerID($pid, $service_date, substr($inslabel, 3));
282 if (empty($ferow['lname'])) {
283 $patient_name = $out['patient_fname'] . ' ' . $out['patient_lname'];
285 $patient_name = $ferow['fname'] . ' ' . $ferow['lname'];
289 foreach ($codes as $cdata) {
291 $insurance_id = $cdata['ins'];
295 $patient_name = $arrow['name'] ?
$arrow['name'] :
296 ($out['patient_fname'] . ' ' . $out['patient_lname']);
301 // This loops once for each service item in this claim.
302 foreach ($out['svc'] as $svc) {
304 // Treat a modifier in the remit data as part of the procedure key.
305 // This key will then make its way into SQL-Ledger.
306 $codekey = $svc['code'];
307 if ($svc['mod']) $codekey .= ':' . $svc['mod'];
308 $prev = $codes[$codekey];
309 $codetype = ''; //will hold code type, if exists
311 // This reports detail lines already on file for this service item.
313 $codetype = $codes[$codekey]['code_type']; //store code type
314 writeOldDetail($prev, $patient_name, $invnumber, $service_date, $codekey, $bgcolor);
315 // Check for sanity in amount charged.
316 $prevchg = sprintf("%.2f", $prev['chg'] +
$prev['adj']);
317 if ($prevchg != abs($svc['chg'])) {
318 writeMessageLine($bgcolor, 'errdetail',
319 "EOB charge amount " . $svc['chg'] . " for this code does not match our invoice");
323 // Check for already-existing primary remittance activity.
324 // Removed this check because it was not allowing for copays manually
325 // entered into the invoice under a non-copay billing code.
327 if ((sprintf("%.2f",$prev['chg']) != sprintf("%.2f",$prev['bal']) ||
328 $prev['adj'] != 0) && $primary)
330 writeMessageLine($bgcolor, 'errdetail',
331 "This service item already has primary payments and/or adjustments!");
336 unset($codes[$codekey]);
339 // If the service item is not in our database...
342 // This is not an error. If we are not in error mode and not debugging,
343 // insert the service item into SL. Then display it (in green if it
344 // was inserted, or in red if we are in error mode).
345 $description = "CPT4:$codekey Added by $inslabel $production_date";
346 if (!$error && !$debug) {
347 if ($INTEGRATED_AR) {
348 arPostCharge($pid, $encounter, 0, $svc['chg'], 1, $service_date,
349 $codekey, $description, $debug,'',$codetype);
351 slPostCharge($arrow['id'], $svc['chg'], 1, $service_date, $codekey,
352 $insurance_id, $description, $debug);
354 $invoice_total +
= $svc['chg'];
356 $class = $error ?
'errdetail' : 'newdetail';
357 writeDetailLine($bgcolor, $class, $patient_name, $invnumber,
358 $codekey, $production_date, $description,
359 $svc['chg'], ($error ?
'' : $invoice_total));
363 $class = $error ?
'errdetail' : 'newdetail';
365 // Report Allowed Amount.
366 if ($svc['allowed']) {
367 // A problem here is that some payers will include an adjustment
368 // reflecting the allowed amount, others not. So here we need to
369 // check if the adjustment exists, and if not then create it. We
370 // assume that any nonzero CO (Contractual Obligation) or PI
371 // (Payer Initiated) adjustment is good enough.
372 $contract_adj = sprintf("%.2f", $svc['chg'] - $svc['allowed']);
373 foreach ($svc['adj'] as $adj) {
374 if (($adj['group_code'] == 'CO' ||
$adj['group_code'] == 'PI') && $adj['amount'] != 0)
377 if ($contract_adj > 0) {
378 $svc['adj'][] = array('group_code' => 'CO', 'reason_code' => 'A2',
379 'amount' => $contract_adj);
381 writeMessageLine($bgcolor, 'infdetail',
382 'Allowed amount is ' . sprintf("%.2f", $svc['allowed']));
385 // Report miscellaneous remarks.
386 if ($svc['remark']) {
387 $rmk = $svc['remark'];
388 writeMessageLine($bgcolor, 'infdetail', "$rmk: " . $remark_codes[$rmk]);
391 // Post and report the payment for this service item from the ERA.
392 // By the way a 'Claim' level payment is probably going to be negative,
393 // i.e. a payment reversal.
395 if (!$error && !$debug) {
396 if ($INTEGRATED_AR) {
397 arPostPayment($pid, $encounter,$InsertionId[$out['check_number']], $svc['paid'],//$InsertionId[$out['check_number']] gives the session id
398 $codekey, substr($inslabel,3), $out['check_number'], $debug,'',$codetype);
400 slPostPayment($arrow['id'], $svc['paid'], $check_date,
401 "$inslabel/" . $out['check_number'], $codekey, $insurance_id, $debug);
403 $invoice_total -= $svc['paid'];
405 $description = "$inslabel/" . $out['check_number'] . ' payment';
406 if ($svc['paid'] < 0) $description .= ' reversal';
407 writeDetailLine($bgcolor, $class, $patient_name, $invnumber,
408 $codekey, $check_date, $description,
409 0 - $svc['paid'], ($error ?
'' : $invoice_total));
412 // Post and report adjustments from this ERA. Posted adjustment reasons
413 // must be 25 characters or less in order to fit on patient statements.
414 foreach ($svc['adj'] as $adj) {
415 $description = $adj['reason_code'] . ': ' . $adjustment_reasons[$adj['reason_code']];
416 if ($adj['group_code'] == 'PR' ||
!$primary) {
417 // Group code PR is Patient Responsibility. Enter these as zero
418 // adjustments to retain the note without crediting the claim.
421 $reason = 'Pt resp: '; // Reasons should be 25 chars or less.
422 if ($adj['reason_code'] == '1') $reason = 'To deductible: ';
423 else if ($adj['reason_code'] == '2') $reason = 'Coinsurance: ';
424 else if ($adj['reason_code'] == '3') $reason = 'Co-pay: ';
426 $reason = "$inslabel ptresp: "; // Reasons should be 25 chars or less.
427 if ($adj['reason_code'] == '1') $reason = "$inslabel dedbl: ";
428 else if ($adj['reason_code'] == '2') $reason = "$inslabel coins: ";
429 else if ($adj['reason_code'] == '3') $reason = "$inslabel copay: ";
431 // Non-primary insurance adjustments are garbage, either repeating
432 // the primary or are not adjustments at all. Report them as notes
433 // but do not post any amounts.
435 $reason = "$inslabel note " . $adj['reason_code'] . ': ';
437 $reason .= sprintf("%.2f", $adj['amount']);
440 $reason .= sprintf("%.2f", $adj['amount']);
441 // Post a zero-dollar adjustment just to save it as a comment.
442 if (!$error && !$debug) {
443 if ($INTEGRATED_AR) {
444 arPostAdjustment($pid, $encounter, $InsertionId[$out['check_number']], 0, $codekey,//$InsertionId[$out['check_number']] gives the session id
445 substr($inslabel,3), $reason, $debug, '', $codetype);
447 slPostAdjustment($arrow['id'], 0, $production_date,
448 $out['check_number'], $codekey, $insurance_id,
452 writeMessageLine($bgcolor, $class, $description . ' ' .
453 sprintf("%.2f", $adj['amount']));
455 // Other group codes for primary insurance are real adjustments.
457 if (!$error && !$debug) {
458 if ($INTEGRATED_AR) {
459 arPostAdjustment($pid, $encounter, $InsertionId[$out['check_number']], $adj['amount'],//$InsertionId[$out['check_number']] gives the session id
460 $codekey, substr($inslabel,3),
461 "Adjust code " . $adj['reason_code'], $debug, '', $codetype);
463 slPostAdjustment($arrow['id'], $adj['amount'], $production_date,
464 $out['check_number'], $codekey, $insurance_id,
465 "$inslabel adjust code " . $adj['reason_code'], $debug);
467 $invoice_total -= $adj['amount'];
469 writeDetailLine($bgcolor, $class, $patient_name, $invnumber,
470 $codekey, $production_date, $description,
471 0 - $adj['amount'], ($error ?
'' : $invoice_total));
475 } // End of service item
477 // Report any existing service items not mentioned in the ERA, and
478 // determine if any of them are still missing an insurance response
479 // (if so, then insurance is not yet done with the claim).
480 $insurance_done = true;
481 foreach ($codes as $code => $prev) {
482 // writeOldDetail($prev, $arrow['name'], $invnumber, $service_date, $code, $bgcolor);
483 writeOldDetail($prev, $patient_name, $invnumber, $service_date, $code, $bgcolor);
484 $got_response = false;
485 foreach ($prev['dtl'] as $ddata) {
486 if ($ddata['pmt'] ||
$ddata['rsn']) $got_response = true;
488 if (!$got_response) $insurance_done = false;
491 // Cleanup: If all is well, mark Ins<x> done and check for secondary billing.
492 if (!$error && !$debug && $insurance_done) {
493 if ($INTEGRATED_AR) {
494 $level_done = 0 +
substr($inslabel, 3);
496 if($out['crossover']==1)
497 {//Automatic forward case.So need not again bill from the billing manager screen.
498 sqlStatement("UPDATE form_encounter " .
499 "SET last_level_closed = $level_done,last_level_billed=".$level_done." WHERE " .
500 "pid = '$pid' AND encounter = '$encounter'");
501 writeMessageLine($bgcolor, 'infdetail',
502 'This claim is processed by Insurance '.$level_done.' and automatically forwarded to Insurance '.($level_done+
1) .' for processing. ');
505 sqlStatement("UPDATE form_encounter " .
506 "SET last_level_closed = $level_done WHERE " .
507 "pid = '$pid' AND encounter = '$encounter'");
509 // Check for secondary insurance.
510 if ($primary && arGetPayerID($pid, $service_date, 2)) {
511 arSetupSecondary($pid, $encounter, $debug,$out['crossover']);
513 if($out['crossover']<>1)
515 writeMessageLine($bgcolor, 'infdetail',
516 'This claim is now re-queued for secondary paper billing');
520 $shipvia = 'Done: Ins1';
521 if ($inslabel != 'Ins1') $shipvia .= ',Ins2';
522 if ($inslabel == 'Ins3') $shipvia .= ',Ins3';
523 $query = "UPDATE ar SET shipvia = '$shipvia' WHERE id = " . $arrow['id'];
525 if ($sl_err) die($sl_err);
526 // Check for secondary insurance.
527 $insgot = strtolower($arrow['notes']);
528 if ($primary && strpos($insgot, 'ins2') !== false) {
529 slSetupSecondary($arrow['id'], $debug);
530 if($out['crossover']<>1)
532 writeMessageLine($bgcolor, 'infdetail',
533 'This claim is now re-queued for secondary paper billing');
541 /////////////////////////// End Functions ////////////////////////////
545 $eraname = $_GET['eraname'];
546 if (! $eraname) die(xl("You cannot access this page directly."));
548 // Open the output file early so that in case it fails, we do not post a
549 // bunch of stuff without saving the report. Also be sure to retain any old
550 // report files. Do not save the report if this is a no-update situation.
553 $nameprefix = $GLOBALS['OE_SITE_DIR'] . "/era/$eraname";
555 for ($i = 1; is_file("$nameprefix$namesuffix.html"); ++
$i) {
558 $fnreport = "$nameprefix$namesuffix.html";
559 $fhreport = fopen($fnreport, 'w');
560 if (!$fhreport) die(xl("Cannot create") . " '$fnreport'");
563 if (!$INTEGRATED_AR) slInitialize();
567 <?php
html_header_show();?
>
568 <link rel
=stylesheet href
="<?php echo $css_header;?>" type
="text/css">
569 <style type
="text/css">
570 body
{ font
-family
:sans
-serif
; font
-size
:8pt
; font
-weight
:normal
}
571 .dehead
{ color
:#000000; font-family:sans-serif; font-size:9pt; font-weight:bold }
572 .olddetail
{ color
:#000000; font-family:sans-serif; font-size:9pt; font-weight:normal }
573 .newdetail
{ color
:#00dd00; font-family:sans-serif; font-size:9pt; font-weight:normal }
574 .errdetail
{ color
:#dd0000; font-family:sans-serif; font-size:9pt; font-weight:normal }
575 .infdetail
{ color
:#0000ff; font-family:sans-serif; font-size:9pt; font-weight:normal }
577 <title
><?php
xl('EOB Posting - Electronic Remittances','e')?
></title
>
578 <script language
="JavaScript">
581 <body leftmargin
='0' topmargin
='0' marginwidth
='0' marginheight
='0'>
582 <form action
="sl_eob_process.php" method
="get" >
585 if($_GET['original']=='original')
587 $alertmsg = parse_era_for_check($GLOBALS['OE_SITE_DIR'] . "/era/$eraname.edi", 'era_callback');
593 <table border
='0' cellpadding
='2' cellspacing
='0' width
='100%'>
595 <tr bgcolor
="#cccccc">
597 <?php
echo htmlspecialchars( xl('Patient'), ENT_QUOTES
) ?
>
600 <?php
echo htmlspecialchars( xl('Invoice'), ENT_QUOTES
) ?
>
603 <?php
echo htmlspecialchars( xl('Code'), ENT_QUOTES
) ?
>
606 <?php
echo htmlspecialchars( xl('Date'), ENT_QUOTES
) ?
>
609 <?php
echo htmlspecialchars( xl('Description'), ENT_QUOTES
) ?
>
611 <td
class="dehead" align
="right">
612 <?php
echo htmlspecialchars( xl('Amount'), ENT_QUOTES
) ?
> 
;
614 <td
class="dehead" align
="right">
615 <?php
echo htmlspecialchars( xl('Balance'), ENT_QUOTES
) ?
> 
;
622 $eraname=$_REQUEST['eraname'];
623 $alertmsg = parse_era_for_check($GLOBALS['OE_SITE_DIR'] . "/era/$eraname.edi");
624 $alertmsg = parse_era($GLOBALS['OE_SITE_DIR'] . "/era/$eraname.edi", 'era_callback');
627 $StringIssue=htmlspecialchars( xl("Total Distribution for following check number is not full"), ENT_QUOTES
).': ';
629 foreach($InsertionId as $key => $value)
631 $rs= sqlQ("select pay_total from ar_session where session_id='$value'");
632 $row=sqlFetchArray($rs);
633 $pay_total=$row['pay_total'];
634 $rs= sqlQ("select sum(pay_amount) sum_pay_amount from ar_activity where session_id='$value'");
635 $row=sqlFetchArray($rs);
636 $pay_amount=$row['sum_pay_amount'];
638 if(($pay_total-$pay_amount)<>0)
640 $StringIssue.=$key.' ';
644 if($StringPrint=='Yes')
645 echo "<script>alert('$StringIssue')</script>";
648 if (!$INTEGRATED_AR) slTerminate();
656 <script language
="JavaScript">
658 if ($alertmsg) echo " alert('" . htmlspecialchars($alertmsg, ENT_QUOTES
) . "');\n";
661 <input type
="hidden" name
="paydate" value
="<?php echo DateToYYYYMMDD($_REQUEST['paydate']);?>" />
662 <input type
="hidden" name
="post_to_date" value
="<?php echo DateToYYYYMMDD($_REQUEST['post_to_date']);?>" />
663 <input type
="hidden" name
="deposit_date" value
="<?php echo DateToYYYYMMDD($_REQUEST['deposit_date']);?>" />
664 <input type
="hidden" name
="debug" value
="<?php echo $_REQUEST['debug'];?>" />
665 <input type
="hidden" name
="InsId" value
="<?php echo $_REQUEST['InsId'];?>" />
666 <input type
="hidden" name
="eraname" value
="<?php echo $eraname?>" />
671 // Save all of this script's output to a report file.
673 fwrite($fhreport, ob_get_contents());