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++
)
148 if(isset($_REQUEST['chk'.$out['check_number'.$check_count]]))
150 $check_date=$out['check_date'.$check_count]?
$out['check_date'.$check_count]:$_REQUEST['paydate'];
151 $post_to_date=$_REQUEST['post_to_date']!=''?
$_REQUEST['post_to_date']:date('Y-m-d');
152 $deposit_date=$_REQUEST['deposit_date']!=''?
$_REQUEST['deposit_date']:date('Y-m-d');
153 $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);
160 function era_callback(&$out) {
161 global $encount, $debug, $claim_status_codes, $adjustment_reasons, $remark_codes;
162 global $invoice_total, $last_code, $paydate, $INTEGRATED_AR;
163 global $InsertionId;//last inserted ID of
166 // Some heading information.
167 $chk_123=$out['check_number'];
168 $chk_123=str_replace(' ','_',$chk_123);
169 if(isset($_REQUEST['chk'.$chk_123])){
171 writeMessageLine('#ffffff', 'infdetail',
172 "Payer: " . htmlspecialchars($out['payer_name'], ENT_QUOTES
));
174 writeMessageLine('#ffffff', 'infdetail',
175 "WITHOUT UPDATE is selected; no changes will be applied.");
180 $invoice_total = 0.00;
181 $bgcolor = (++
$encount & 1) ?
"#ddddff" : "#ffdddd";
182 list($pid, $encounter, $invnumber) = slInvoiceNumber($out);
184 // Get details, if we have them, for the invoice.
187 if ($pid && $encounter) {
188 // Get invoice data into $arrow or $ferow.
189 if ($INTEGRATED_AR) {
190 $ferow = sqlQuery("SELECT e.*, p.fname, p.mname, p.lname " .
191 "FROM form_encounter AS e, patient_data AS p WHERE " .
192 "e.pid = '$pid' AND e.encounter = '$encounter' AND ".
195 $pid = $encounter = 0;
196 $invnumber = $out['our_claim_id'];
199 $codes = ar_get_invoice_summary($pid, $encounter, true);
200 // $svcdate = substr($ferow['date'], 0, 10);
202 } // end internal a/r
204 $arres = SLQuery("SELECT ar.id, ar.notes, ar.shipvia, customer.name " .
205 "FROM ar, customer WHERE ar.invnumber = '$invnumber' AND " .
206 "customer.id = ar.customer_id");
207 if ($sl_err) die($sl_err);
208 $arrow = SLGetRow($arres, 0);
211 $codes = get_invoice_summary($arrow['id'], true);
212 } else { // oops, no such invoice
213 $pid = $encounter = 0;
214 $invnumber = $out['our_claim_id'];
216 } // end not internal a/r
219 // Show the claim status.
220 $csc = $out['claim_status_code'];
222 if ($csc == '1' ||
$csc == '19') $inslabel = 'Ins1';
223 if ($csc == '2' ||
$csc == '20') $inslabel = 'Ins2';
224 if ($csc == '3' ||
$csc == '21') $inslabel = 'Ins3';
225 $primary = ($inslabel == 'Ins1');
226 writeMessageLine($bgcolor, 'infdetail',
227 "Claim status $csc: " . $claim_status_codes[$csc]);
229 // Show an error message if the claim is missing or already posted.
231 writeMessageLine($bgcolor, 'errdetail',
232 "The following claim is not in our database");
235 // Skip this test. Claims can get multiple CLPs from the same payer!
237 // $insdone = strtolower($arrow['shipvia']);
238 // if (strpos($insdone, 'ins1') !== false) {
240 // writeMessageLine($bgcolor, 'errdetail',
241 // "Primary insurance EOB was already posted for the following claim");
245 if ($csc == '4') {//Denial case, code is stored in the claims table for display in the billing manager screen with reason explained.
248 if ($pid && $encounter) {
250 foreach ($out['svc'] as $svc) {
251 foreach ($svc['adj'] as $adj) {//Per code and modifier the reason will be showed in the billing manager.
252 $code_value .= $svc['code'].'_'.$svc['mod'].'_'.$adj['group_code'].'_'.$adj['reason_code'].',';
255 $code_value = substr($code_value,0,-1);
256 //We store the reason code to display it with description in the billing manager screen.
257 //process_file is used as for the denial case file name will not be there, and extra field(to store reason) can be avoided.
258 updateClaim(true, $pid, $encounter, $_REQUEST['InsId'], substr($inslabel,3),7,0,$code_value);
261 writeMessageLine($bgcolor, 'errdetail',
262 "Not posting adjustments for denied claims, please follow up manually!");
264 else if ($csc == '22') {
266 writeMessageLine($bgcolor, 'errdetail',
267 "Payment reversals are not automated, please enter manually!");
270 if ($out['warnings']) {
271 writeMessageLine($bgcolor, 'infdetail', nl2br(rtrim($out['warnings'])));
274 // Simplify some claim attributes for cleaner code.
275 $service_date = parse_date($out['dos']);
276 $check_date = $paydate ?
$paydate : parse_date($out['check_date']);
277 $production_date = $paydate ?
$paydate : parse_date($out['production_date']);
279 if ($INTEGRATED_AR) {
280 $insurance_id = arGetPayerID($pid, $service_date, substr($inslabel, 3));
281 if (empty($ferow['lname'])) {
282 $patient_name = $out['patient_fname'] . ' ' . $out['patient_lname'];
284 $patient_name = $ferow['fname'] . ' ' . $ferow['lname'];
288 foreach ($codes as $cdata) {
290 $insurance_id = $cdata['ins'];
294 $patient_name = $arrow['name'] ?
$arrow['name'] :
295 ($out['patient_fname'] . ' ' . $out['patient_lname']);
300 // This loops once for each service item in this claim.
301 foreach ($out['svc'] as $svc) {
303 // Treat a modifier in the remit data as part of the procedure key.
304 // This key will then make its way into SQL-Ledger.
305 $codekey = $svc['code'];
306 if ($svc['mod']) $codekey .= ':' . $svc['mod'];
307 $prev = $codes[$codekey];
309 // This reports detail lines already on file for this service item.
311 writeOldDetail($prev, $patient_name, $invnumber, $service_date, $codekey, $bgcolor);
312 // Check for sanity in amount charged.
313 $prevchg = sprintf("%.2f", $prev['chg'] +
$prev['adj']);
314 if ($prevchg != abs($svc['chg'])) {
315 writeMessageLine($bgcolor, 'errdetail',
316 "EOB charge amount " . $svc['chg'] . " for this code does not match our invoice");
320 // Check for already-existing primary remittance activity.
321 // Removed this check because it was not allowing for copays manually
322 // entered into the invoice under a non-copay billing code.
324 if ((sprintf("%.2f",$prev['chg']) != sprintf("%.2f",$prev['bal']) ||
325 $prev['adj'] != 0) && $primary)
327 writeMessageLine($bgcolor, 'errdetail',
328 "This service item already has primary payments and/or adjustments!");
333 unset($codes[$codekey]);
336 // If the service item is not in our database...
339 // This is not an error. If we are not in error mode and not debugging,
340 // insert the service item into SL. Then display it (in green if it
341 // was inserted, or in red if we are in error mode).
342 $description = "CPT4:$codekey Added by $inslabel $production_date";
343 if (!$error && !$debug) {
344 if ($INTEGRATED_AR) {
345 arPostCharge($pid, $encounter, 0, $svc['chg'], 1, $service_date,
346 $codekey, $description, $debug);
348 slPostCharge($arrow['id'], $svc['chg'], 1, $service_date, $codekey,
349 $insurance_id, $description, $debug);
351 $invoice_total +
= $svc['chg'];
353 $class = $error ?
'errdetail' : 'newdetail';
354 writeDetailLine($bgcolor, $class, $patient_name, $invnumber,
355 $codekey, $production_date, $description,
356 $svc['chg'], ($error ?
'' : $invoice_total));
360 $class = $error ?
'errdetail' : 'newdetail';
362 // Report Allowed Amount.
363 if ($svc['allowed']) {
364 // A problem here is that some payers will include an adjustment
365 // reflecting the allowed amount, others not. So here we need to
366 // check if the adjustment exists, and if not then create it. We
367 // assume that any nonzero CO (Contractual Obligation) or PI
368 // (Payer Initiated) adjustment is good enough.
369 $contract_adj = sprintf("%.2f", $svc['chg'] - $svc['allowed']);
370 foreach ($svc['adj'] as $adj) {
371 if (($adj['group_code'] == 'CO' ||
$adj['group_code'] == 'PI') && $adj['amount'] != 0)
374 if ($contract_adj > 0) {
375 $svc['adj'][] = array('group_code' => 'CO', 'reason_code' => 'A2',
376 'amount' => $contract_adj);
378 writeMessageLine($bgcolor, 'infdetail',
379 'Allowed amount is ' . sprintf("%.2f", $svc['allowed']));
382 // Report miscellaneous remarks.
383 if ($svc['remark']) {
384 $rmk = $svc['remark'];
385 writeMessageLine($bgcolor, 'infdetail', "$rmk: " . $remark_codes[$rmk]);
388 // Post and report the payment for this service item from the ERA.
389 // By the way a 'Claim' level payment is probably going to be negative,
390 // i.e. a payment reversal.
392 if (!$error && !$debug) {
393 if ($INTEGRATED_AR) {
394 arPostPayment($pid, $encounter,$InsertionId[$out['check_number']], $svc['paid'],//$InsertionId[$out['check_number']] gives the session id
395 $codekey, substr($inslabel,3), $out['check_number'], $debug);
397 slPostPayment($arrow['id'], $svc['paid'], $check_date,
398 "$inslabel/" . $out['check_number'], $codekey, $insurance_id, $debug);
400 $invoice_total -= $svc['paid'];
402 $description = "$inslabel/" . $out['check_number'] . ' payment';
403 if ($svc['paid'] < 0) $description .= ' reversal';
404 writeDetailLine($bgcolor, $class, $patient_name, $invnumber,
405 $codekey, $check_date, $description,
406 0 - $svc['paid'], ($error ?
'' : $invoice_total));
409 // Post and report adjustments from this ERA. Posted adjustment reasons
410 // must be 25 characters or less in order to fit on patient statements.
411 foreach ($svc['adj'] as $adj) {
412 $description = $adj['reason_code'] . ': ' . $adjustment_reasons[$adj['reason_code']];
413 if ($adj['group_code'] == 'PR' ||
!$primary) {
414 // Group code PR is Patient Responsibility. Enter these as zero
415 // adjustments to retain the note without crediting the claim.
418 $reason = 'Pt resp: '; // Reasons should be 25 chars or less.
419 if ($adj['reason_code'] == '1') $reason = 'To deductible: ';
420 else if ($adj['reason_code'] == '2') $reason = 'Coinsurance: ';
421 else if ($adj['reason_code'] == '3') $reason = 'Co-pay: ';
423 $reason = "$inslabel ptresp: "; // Reasons should be 25 chars or less.
424 if ($adj['reason_code'] == '1') $reason = "$inslabel dedbl: ";
425 else if ($adj['reason_code'] == '2') $reason = "$inslabel coins: ";
426 else if ($adj['reason_code'] == '3') $reason = "$inslabel copay: ";
428 // Non-primary insurance adjustments are garbage, either repeating
429 // the primary or are not adjustments at all. Report them as notes
430 // but do not post any amounts.
432 $reason = "$inslabel note " . $adj['reason_code'] . ': ';
434 $reason .= sprintf("%.2f", $adj['amount']);
437 $reason .= sprintf("%.2f", $adj['amount']);
438 // Post a zero-dollar adjustment just to save it as a comment.
439 if (!$error && !$debug) {
440 if ($INTEGRATED_AR) {
441 arPostAdjustment($pid, $encounter, $InsertionId[$out['check_number']], 0, $codekey,//$InsertionId[$out['check_number']] gives the session id
442 substr($inslabel,3), $reason, $debug);
444 slPostAdjustment($arrow['id'], 0, $production_date,
445 $out['check_number'], $codekey, $insurance_id,
449 writeMessageLine($bgcolor, $class, $description . ' ' .
450 sprintf("%.2f", $adj['amount']));
452 // Other group codes for primary insurance are real adjustments.
454 if (!$error && !$debug) {
455 if ($INTEGRATED_AR) {
456 arPostAdjustment($pid, $encounter, $InsertionId[$out['check_number']], $adj['amount'],//$InsertionId[$out['check_number']] gives the session id
457 $codekey, substr($inslabel,3),
458 "Adjust code " . $adj['reason_code'], $debug);
460 slPostAdjustment($arrow['id'], $adj['amount'], $production_date,
461 $out['check_number'], $codekey, $insurance_id,
462 "$inslabel adjust code " . $adj['reason_code'], $debug);
464 $invoice_total -= $adj['amount'];
466 writeDetailLine($bgcolor, $class, $patient_name, $invnumber,
467 $codekey, $production_date, $description,
468 0 - $adj['amount'], ($error ?
'' : $invoice_total));
472 } // End of service item
474 // Report any existing service items not mentioned in the ERA, and
475 // determine if any of them are still missing an insurance response
476 // (if so, then insurance is not yet done with the claim).
477 $insurance_done = true;
478 foreach ($codes as $code => $prev) {
479 // writeOldDetail($prev, $arrow['name'], $invnumber, $service_date, $code, $bgcolor);
480 writeOldDetail($prev, $patient_name, $invnumber, $service_date, $code, $bgcolor);
481 $got_response = false;
482 foreach ($prev['dtl'] as $ddata) {
483 if ($ddata['pmt'] ||
$ddata['rsn']) $got_response = true;
485 if (!$got_response) $insurance_done = false;
488 // Cleanup: If all is well, mark Ins<x> done and check for secondary billing.
489 if (!$error && !$debug && $insurance_done) {
490 if ($INTEGRATED_AR) {
491 $level_done = 0 +
substr($inslabel, 3);
493 if($out['crossover']==1)
494 {//Automatic forward case.So need not again bill from the billing manager screen.
495 sqlStatement("UPDATE form_encounter " .
496 "SET last_level_closed = $level_done,last_level_billed=".$level_done." WHERE " .
497 "pid = '$pid' AND encounter = '$encounter'");
498 writeMessageLine($bgcolor, 'infdetail',
499 'This claim is processed by Insurance '.$level_done.' and automatically forwarded to Insurance '.($level_done+
1) .' for processing. ');
503 "UPDATE form_encounter " .
504 "SET last_level_closed = $level_done WHERE " .
505 "pid = '$pid' AND encounter = '$encounter'";
507 // Check for secondary insurance.
508 if ($primary && arGetPayerID($pid, $service_date, 2)) {
509 arSetupSecondary($pid, $encounter, $debug,$out['crossover']);
511 if($out['crossover']<>1)
513 writeMessageLine($bgcolor, 'infdetail',
514 'This claim is now re-queued for secondary paper billing');
518 $shipvia = 'Done: Ins1';
519 if ($inslabel != 'Ins1') $shipvia .= ',Ins2';
520 if ($inslabel == 'Ins3') $shipvia .= ',Ins3';
521 $query = "UPDATE ar SET shipvia = '$shipvia' WHERE id = " . $arrow['id'];
523 if ($sl_err) die($sl_err);
524 // Check for secondary insurance.
525 $insgot = strtolower($arrow['notes']);
526 if ($primary && strpos($insgot, 'ins2') !== false) {
527 slSetupSecondary($arrow['id'], $debug);
528 if($out['crossover']<>1)
530 writeMessageLine($bgcolor, 'infdetail',
531 'This claim is now re-queued for secondary paper billing');
539 /////////////////////////// End Functions ////////////////////////////
543 $eraname = $_GET['eraname'];
544 if (! $eraname) die(xl("You cannot access this page directly."));
546 // Open the output file early so that in case it fails, we do not post a
547 // bunch of stuff without saving the report. Also be sure to retain any old
548 // report files. Do not save the report if this is a no-update situation.
551 $nameprefix = $GLOBALS['OE_SITE_DIR'] . "/era/$eraname";
553 for ($i = 1; is_file("$nameprefix$namesuffix.html"); ++
$i) {
556 $fnreport = "$nameprefix$namesuffix.html";
557 $fhreport = fopen($fnreport, 'w');
558 if (!$fhreport) die(xl("Cannot create") . " '$fnreport'");
561 if (!$INTEGRATED_AR) slInitialize();
565 <?php
html_header_show();?
>
566 <link rel
=stylesheet href
="<?php echo $css_header;?>" type
="text/css">
567 <style type
="text/css">
568 body
{ font
-family
:sans
-serif
; font
-size
:8pt
; font
-weight
:normal
}
569 .dehead
{ color
:#000000; font-family:sans-serif; font-size:9pt; font-weight:bold }
570 .olddetail
{ color
:#000000; font-family:sans-serif; font-size:9pt; font-weight:normal }
571 .newdetail
{ color
:#00dd00; font-family:sans-serif; font-size:9pt; font-weight:normal }
572 .errdetail
{ color
:#dd0000; font-family:sans-serif; font-size:9pt; font-weight:normal }
573 .infdetail
{ color
:#0000ff; font-family:sans-serif; font-size:9pt; font-weight:normal }
575 <title
><?php
xl('EOB Posting - Electronic Remittances','e')?
></title
>
576 <script language
="JavaScript">
579 <body leftmargin
='0' topmargin
='0' marginwidth
='0' marginheight
='0'>
580 <form action
="sl_eob_process.php" method
="get" >
583 if($_GET['original']=='original')
585 $alertmsg = parse_era_for_check($GLOBALS['OE_SITE_DIR'] . "/era/$eraname.edi", 'era_callback');
591 <table border
='0' cellpadding
='2' cellspacing
='0' width
='100%'>
593 <tr bgcolor
="#cccccc">
595 <?php
echo htmlspecialchars( xl('Patient'), ENT_QUOTES
) ?
>
598 <?php
echo htmlspecialchars( xl('Invoice'), ENT_QUOTES
) ?
>
601 <?php
echo htmlspecialchars( xl('Code'), ENT_QUOTES
) ?
>
604 <?php
echo htmlspecialchars( xl('Date'), ENT_QUOTES
) ?
>
607 <?php
echo htmlspecialchars( xl('Description'), ENT_QUOTES
) ?
>
609 <td
class="dehead" align
="right">
610 <?php
echo htmlspecialchars( xl('Amount'), ENT_QUOTES
) ?
> 
;
612 <td
class="dehead" align
="right">
613 <?php
echo htmlspecialchars( xl('Balance'), ENT_QUOTES
) ?
> 
;
620 $eraname=$_REQUEST['eraname'];
621 $alertmsg = parse_era_for_check($GLOBALS['OE_SITE_DIR'] . "/era/$eraname.edi");
622 $alertmsg = parse_era($GLOBALS['OE_SITE_DIR'] . "/era/$eraname.edi", 'era_callback');
625 $StringIssue=htmlspecialchars( xl("Total Distribution for following check number is not full"), ENT_QUOTES
).': ';
627 foreach($InsertionId as $key => $value)
629 $rs= sqlQ("select pay_total from ar_session where session_id='$value'");
630 $row=sqlFetchArray($rs);
631 $pay_total=$row['pay_total'];
632 $rs= sqlQ("select sum(pay_amount) sum_pay_amount from ar_activity where session_id='$value'");
633 $row=sqlFetchArray($rs);
634 $pay_amount=$row['sum_pay_amount'];
636 if(($pay_total-$pay_amount)<>0)
638 $StringIssue.=$key.' ';
642 if($StringPrint=='Yes')
643 echo "<script>alert('$StringIssue')</script>";
646 if (!$INTEGRATED_AR) slTerminate();
654 <script language
="JavaScript">
656 if ($alertmsg) echo " alert('" . htmlspecialchars($alertmsg, ENT_QUOTES
) . "');\n";
659 <input type
="hidden" name
="paydate" value
="<?php echo DateToYYYYMMDD($_REQUEST['paydate']);?>" />
660 <input type
="hidden" name
="post_to_date" value
="<?php echo DateToYYYYMMDD($_REQUEST['post_to_date']);?>" />
661 <input type
="hidden" name
="deposit_date" value
="<?php echo DateToYYYYMMDD($_REQUEST['deposit_date']);?>" />
662 <input type
="hidden" name
="debug" value
="<?php echo $_REQUEST['debug'];?>" />
663 <input type
="hidden" name
="InsId" value
="<?php echo $_REQUEST['InsId'];?>" />
664 <input type
="hidden" name
="eraname" value
="<?php echo $eraname?>" />
669 // Save all of this script's output to a report file.
671 fwrite($fhreport, ob_get_contents());