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 Cheque 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 if(isset($_REQUEST['chk'.$out['check_number']])){
169 writeMessageLine('#ffffff', 'infdetail',
170 "Payer: " . htmlspecialchars($out['payer_name'], ENT_QUOTES
));
172 writeMessageLine('#ffffff', 'infdetail',
173 "WITHOUT UPDATE is selected; no changes will be applied.");
178 $invoice_total = 0.00;
179 $bgcolor = (++
$encount & 1) ?
"#ddddff" : "#ffdddd";
180 list($pid, $encounter, $invnumber) = slInvoiceNumber($out);
182 // Get details, if we have them, for the invoice.
185 if ($pid && $encounter) {
186 // Get invoice data into $arrow or $ferow.
187 if ($INTEGRATED_AR) {
188 $ferow = sqlQuery("SELECT e.*, p.fname, p.mname, p.lname " .
189 "FROM form_encounter AS e, patient_data AS p WHERE " .
190 "e.pid = '$pid' AND e.encounter = '$encounter' AND ".
193 $pid = $encounter = 0;
194 $invnumber = $out['our_claim_id'];
197 $codes = ar_get_invoice_summary($pid, $encounter, true);
198 // $svcdate = substr($ferow['date'], 0, 10);
200 } // end internal a/r
202 $arres = SLQuery("SELECT ar.id, ar.notes, ar.shipvia, customer.name " .
203 "FROM ar, customer WHERE ar.invnumber = '$invnumber' AND " .
204 "customer.id = ar.customer_id");
205 if ($sl_err) die($sl_err);
206 $arrow = SLGetRow($arres, 0);
209 $codes = get_invoice_summary($arrow['id'], true);
210 } else { // oops, no such invoice
211 $pid = $encounter = 0;
212 $invnumber = $out['our_claim_id'];
214 } // end not internal a/r
217 // Show the claim status.
218 $csc = $out['claim_status_code'];
220 if ($csc == '1' ||
$csc == '19') $inslabel = 'Ins1';
221 if ($csc == '2' ||
$csc == '20') $inslabel = 'Ins2';
222 if ($csc == '3' ||
$csc == '21') $inslabel = 'Ins3';
223 $primary = ($inslabel == 'Ins1');
224 writeMessageLine($bgcolor, 'infdetail',
225 "Claim status $csc: " . $claim_status_codes[$csc]);
227 // Show an error message if the claim is missing or already posted.
229 writeMessageLine($bgcolor, 'errdetail',
230 "The following claim is not in our database");
233 // Skip this test. Claims can get multiple CLPs from the same payer!
235 // $insdone = strtolower($arrow['shipvia']);
236 // if (strpos($insdone, 'ins1') !== false) {
238 // writeMessageLine($bgcolor, 'errdetail',
239 // "Primary insurance EOB was already posted for the following claim");
243 if ($csc == '4') {//Denial case, code is stored in the claims table for display in the billing manager screen with reason explained.
246 if ($pid && $encounter) {
248 foreach ($out['svc'] as $svc) {
249 foreach ($svc['adj'] as $adj) {//Per code and modifier the reason will be showed in the billing manager.
250 $code_value .= $svc['code'].'_'.$svc['mod'].'_'.$adj['group_code'].'_'.$adj['reason_code'].',';
253 $code_value = substr($code_value,0,-1);
254 //We store the reason code to display it with description in the billing manager screen.
255 //process_file is used as for the denial case file name will not be there, and extra field(to store reason) can be avoided.
256 updateClaim(true, $pid, $encounter, $_REQUEST['InsId'], substr($inslabel,3),7,0,$code_value);
259 writeMessageLine($bgcolor, 'errdetail',
260 "Not posting adjustments for denied claims, please follow up manually!");
262 else if ($csc == '22') {
264 writeMessageLine($bgcolor, 'errdetail',
265 "Payment reversals are not automated, please enter manually!");
268 if ($out['warnings']) {
269 writeMessageLine($bgcolor, 'infdetail', nl2br(rtrim($out['warnings'])));
272 // Simplify some claim attributes for cleaner code.
273 $service_date = parse_date($out['dos']);
274 $check_date = $paydate ?
$paydate : parse_date($out['check_date']);
275 $production_date = $paydate ?
$paydate : parse_date($out['production_date']);
277 if ($INTEGRATED_AR) {
278 $insurance_id = arGetPayerID($pid, $service_date, substr($inslabel, 3));
279 if (empty($ferow['lname'])) {
280 $patient_name = $out['patient_fname'] . ' ' . $out['patient_lname'];
282 $patient_name = $ferow['fname'] . ' ' . $ferow['lname'];
286 foreach ($codes as $cdata) {
288 $insurance_id = $cdata['ins'];
292 $patient_name = $arrow['name'] ?
$arrow['name'] :
293 ($out['patient_fname'] . ' ' . $out['patient_lname']);
298 // This loops once for each service item in this claim.
299 foreach ($out['svc'] as $svc) {
301 // Treat a modifier in the remit data as part of the procedure key.
302 // This key will then make its way into SQL-Ledger.
303 $codekey = $svc['code'];
304 if ($svc['mod']) $codekey .= ':' . $svc['mod'];
305 $prev = $codes[$codekey];
307 // This reports detail lines already on file for this service item.
309 writeOldDetail($prev, $patient_name, $invnumber, $service_date, $codekey, $bgcolor);
310 // Check for sanity in amount charged.
311 $prevchg = sprintf("%.2f", $prev['chg'] +
$prev['adj']);
312 if ($prevchg != abs($svc['chg'])) {
313 writeMessageLine($bgcolor, 'errdetail',
314 "EOB charge amount " . $svc['chg'] . " for this code does not match our invoice");
318 // Check for already-existing primary remittance activity.
319 // Removed this check because it was not allowing for copays manually
320 // entered into the invoice under a non-copay billing code.
322 if ((sprintf("%.2f",$prev['chg']) != sprintf("%.2f",$prev['bal']) ||
323 $prev['adj'] != 0) && $primary)
325 writeMessageLine($bgcolor, 'errdetail',
326 "This service item already has primary payments and/or adjustments!");
331 unset($codes[$codekey]);
334 // If the service item is not in our database...
337 // This is not an error. If we are not in error mode and not debugging,
338 // insert the service item into SL. Then display it (in green if it
339 // was inserted, or in red if we are in error mode).
340 $description = "CPT4:$codekey Added by $inslabel $production_date";
341 if (!$error && !$debug) {
342 if ($INTEGRATED_AR) {
343 arPostCharge($pid, $encounter, 0, $svc['chg'], 1, $service_date,
344 $codekey, $description, $debug);
346 slPostCharge($arrow['id'], $svc['chg'], 1, $service_date, $codekey,
347 $insurance_id, $description, $debug);
349 $invoice_total +
= $svc['chg'];
351 $class = $error ?
'errdetail' : 'newdetail';
352 writeDetailLine($bgcolor, $class, $patient_name, $invnumber,
353 $codekey, $production_date, $description,
354 $svc['chg'], ($error ?
'' : $invoice_total));
358 $class = $error ?
'errdetail' : 'newdetail';
360 // Report Allowed Amount.
361 if ($svc['allowed']) {
362 // A problem here is that some payers will include an adjustment
363 // reflecting the allowed amount, others not. So here we need to
364 // check if the adjustment exists, and if not then create it. We
365 // assume that any nonzero CO (Contractual Obligation) or PI
366 // (Payer Initiated) adjustment is good enough.
367 $contract_adj = sprintf("%.2f", $svc['chg'] - $svc['allowed']);
368 foreach ($svc['adj'] as $adj) {
369 if (($adj['group_code'] == 'CO' ||
$adj['group_code'] == 'PI') && $adj['amount'] != 0)
372 if ($contract_adj > 0) {
373 $svc['adj'][] = array('group_code' => 'CO', 'reason_code' => 'A2',
374 'amount' => $contract_adj);
376 writeMessageLine($bgcolor, 'infdetail',
377 'Allowed amount is ' . sprintf("%.2f", $svc['allowed']));
380 // Report miscellaneous remarks.
381 if ($svc['remark']) {
382 $rmk = $svc['remark'];
383 writeMessageLine($bgcolor, 'infdetail', "$rmk: " . $remark_codes[$rmk]);
386 // Post and report the payment for this service item from the ERA.
387 // By the way a 'Claim' level payment is probably going to be negative,
388 // i.e. a payment reversal.
390 if (!$error && !$debug) {
391 if ($INTEGRATED_AR) {
392 arPostPayment($pid, $encounter,$InsertionId[$out['check_number']], $svc['paid'],//$InsertionId[$out['check_number']] gives the session id
393 $codekey, substr($inslabel,3), $out['check_number'], $debug);
395 slPostPayment($arrow['id'], $svc['paid'], $check_date,
396 "$inslabel/" . $out['check_number'], $codekey, $insurance_id, $debug);
398 $invoice_total -= $svc['paid'];
400 $description = "$inslabel/" . $out['check_number'] . ' payment';
401 if ($svc['paid'] < 0) $description .= ' reversal';
402 writeDetailLine($bgcolor, $class, $patient_name, $invnumber,
403 $codekey, $check_date, $description,
404 0 - $svc['paid'], ($error ?
'' : $invoice_total));
407 // Post and report adjustments from this ERA. Posted adjustment reasons
408 // must be 25 characters or less in order to fit on patient statements.
409 foreach ($svc['adj'] as $adj) {
410 $description = $adj['reason_code'] . ': ' . $adjustment_reasons[$adj['reason_code']];
411 if ($adj['group_code'] == 'PR' ||
!$primary) {
412 // Group code PR is Patient Responsibility. Enter these as zero
413 // adjustments to retain the note without crediting the claim.
416 $reason = 'Pt resp: '; // Reasons should be 25 chars or less.
417 if ($adj['reason_code'] == '1') $reason = 'To deductible: ';
418 else if ($adj['reason_code'] == '2') $reason = 'Coinsurance: ';
419 else if ($adj['reason_code'] == '3') $reason = 'Co-pay: ';
421 $reason = "$inslabel ptresp: "; // Reasons should be 25 chars or less.
422 if ($adj['reason_code'] == '1') $reason = "$inslabel dedbl: ";
423 else if ($adj['reason_code'] == '2') $reason = "$inslabel coins: ";
424 else if ($adj['reason_code'] == '3') $reason = "$inslabel copay: ";
426 // Non-primary insurance adjustments are garbage, either repeating
427 // the primary or are not adjustments at all. Report them as notes
428 // but do not post any amounts.
430 $reason = "$inslabel note " . $adj['reason_code'] . ': ';
432 $reason .= sprintf("%.2f", $adj['amount']);
435 $reason .= sprintf("%.2f", $adj['amount']);
436 // Post a zero-dollar adjustment just to save it as a comment.
437 if (!$error && !$debug) {
438 if ($INTEGRATED_AR) {
439 arPostAdjustment($pid, $encounter, $InsertionId[$out['check_number']], 0, $codekey,//$InsertionId[$out['check_number']] gives the session id
440 substr($inslabel,3), $reason, $debug);
442 slPostAdjustment($arrow['id'], 0, $production_date,
443 $out['check_number'], $codekey, $insurance_id,
447 writeMessageLine($bgcolor, $class, $description . ' ' .
448 sprintf("%.2f", $adj['amount']));
450 // Other group codes for primary insurance are real adjustments.
452 if (!$error && !$debug) {
453 if ($INTEGRATED_AR) {
454 arPostAdjustment($pid, $encounter, $InsertionId[$out['check_number']], $adj['amount'],//$InsertionId[$out['check_number']] gives the session id
455 $codekey, substr($inslabel,3),
456 "Adjust code " . $adj['reason_code'], $debug);
458 slPostAdjustment($arrow['id'], $adj['amount'], $production_date,
459 $out['check_number'], $codekey, $insurance_id,
460 "$inslabel adjust code " . $adj['reason_code'], $debug);
462 $invoice_total -= $adj['amount'];
464 writeDetailLine($bgcolor, $class, $patient_name, $invnumber,
465 $codekey, $production_date, $description,
466 0 - $adj['amount'], ($error ?
'' : $invoice_total));
470 } // End of service item
472 // Report any existing service items not mentioned in the ERA, and
473 // determine if any of them are still missing an insurance response
474 // (if so, then insurance is not yet done with the claim).
475 $insurance_done = true;
476 foreach ($codes as $code => $prev) {
477 // writeOldDetail($prev, $arrow['name'], $invnumber, $service_date, $code, $bgcolor);
478 writeOldDetail($prev, $patient_name, $invnumber, $service_date, $code, $bgcolor);
479 $got_response = false;
480 foreach ($prev['dtl'] as $ddata) {
481 if ($ddata['pmt'] ||
$ddata['rsn']) $got_response = true;
483 if (!$got_response) $insurance_done = false;
486 // Cleanup: If all is well, mark Ins<x> done and check for secondary billing.
487 if (!$error && !$debug && $insurance_done) {
488 if ($INTEGRATED_AR) {
489 $level_done = 0 +
substr($inslabel, 3);
491 if($out['crossover']==1)
492 {//Automatic forward case.So need not again bill from the billing manager screen.
493 sqlStatement("UPDATE form_encounter " .
494 "SET last_level_closed = $level_done,last_level_billed=".$level_done." WHERE " .
495 "pid = '$pid' AND encounter = '$encounter'");
496 writeMessageLine($bgcolor, 'infdetail',
497 'This claim is processed by Insurance '.$level_done.' and automatically forwarded to Insurance '.($level_done+
1) .' for processing. ');
501 "UPDATE form_encounter " .
502 "SET last_level_closed = $level_done WHERE " .
503 "pid = '$pid' AND encounter = '$encounter'";
505 // Check for secondary insurance.
506 if ($primary && arGetPayerID($pid, $service_date, 2)) {
507 arSetupSecondary($pid, $encounter, $debug,$out['crossover']);
509 if($out['crossover']<>1)
511 writeMessageLine($bgcolor, 'infdetail',
512 'This claim is now re-queued for secondary paper billing');
516 $shipvia = 'Done: Ins1';
517 if ($inslabel != 'Ins1') $shipvia .= ',Ins2';
518 if ($inslabel == 'Ins3') $shipvia .= ',Ins3';
519 $query = "UPDATE ar SET shipvia = '$shipvia' WHERE id = " . $arrow['id'];
521 if ($sl_err) die($sl_err);
522 // Check for secondary insurance.
523 $insgot = strtolower($arrow['notes']);
524 if ($primary && strpos($insgot, 'ins2') !== false) {
525 slSetupSecondary($arrow['id'], $debug);
526 if($out['crossover']<>1)
528 writeMessageLine($bgcolor, 'infdetail',
529 'This claim is now re-queued for secondary paper billing');
537 /////////////////////////// End Functions ////////////////////////////
541 $eraname = $_GET['eraname'];
542 if (! $eraname) die(xl("You cannot access this page directly."));
544 // Open the output file early so that in case it fails, we do not post a
545 // bunch of stuff without saving the report. Also be sure to retain any old
546 // report files. Do not save the report if this is a no-update situation.
549 $nameprefix = $GLOBALS['OE_SITE_DIR'] . "/era/$eraname";
551 for ($i = 1; is_file("$nameprefix$namesuffix.html"); ++
$i) {
554 $fnreport = "$nameprefix$namesuffix.html";
555 $fhreport = fopen($fnreport, 'w');
556 if (!$fhreport) die(xl("Cannot create") . " '$fnreport'");
559 if (!$INTEGRATED_AR) slInitialize();
563 <?
html_header_show();?
>
564 <link rel
=stylesheet href
="<?php echo $css_header;?>" type
="text/css">
565 <style type
="text/css">
566 body
{ font
-family
:sans
-serif
; font
-size
:8pt
; font
-weight
:normal
}
567 .dehead
{ color
:#000000; font-family:sans-serif; font-size:9pt; font-weight:bold }
568 .olddetail
{ color
:#000000; font-family:sans-serif; font-size:9pt; font-weight:normal }
569 .newdetail
{ color
:#00dd00; font-family:sans-serif; font-size:9pt; font-weight:normal }
570 .errdetail
{ color
:#dd0000; font-family:sans-serif; font-size:9pt; font-weight:normal }
571 .infdetail
{ color
:#0000ff; font-family:sans-serif; font-size:9pt; font-weight:normal }
573 <title
><?php
xl('EOB Posting - Electronic Remittances','e')?
></title
>
574 <script language
="JavaScript">
577 <body leftmargin
='0' topmargin
='0' marginwidth
='0' marginheight
='0'>
578 <form action
="sl_eob_process.php" method
="get" >
581 if($_GET['original']=='original')
583 $alertmsg = parse_era_for_check($GLOBALS['OE_SITE_DIR'] . "/era/$eraname.edi", 'era_callback');
589 <table border
='0' cellpadding
='2' cellspacing
='0' width
='100%'>
591 <tr bgcolor
="#cccccc">
593 <?php
echo htmlspecialchars( xl('Patient'), ENT_QUOTES
) ?
>
596 <?php
echo htmlspecialchars( xl('Invoice'), ENT_QUOTES
) ?
>
599 <?php
echo htmlspecialchars( xl('Code'), ENT_QUOTES
) ?
>
602 <?php
echo htmlspecialchars( xl('Date'), ENT_QUOTES
) ?
>
605 <?php
echo htmlspecialchars( xl('Description'), ENT_QUOTES
) ?
>
607 <td
class="dehead" align
="right">
608 <?php
echo htmlspecialchars( xl('Amount'), ENT_QUOTES
) ?
> 
;
610 <td
class="dehead" align
="right">
611 <?php
echo htmlspecialchars( xl('Balance'), ENT_QUOTES
) ?
> 
;
618 $eraname=$_REQUEST['eraname'];
619 $alertmsg = parse_era_for_check($GLOBALS['OE_SITE_DIR'] . "/era/$eraname.edi");
620 $alertmsg = parse_era($GLOBALS['OE_SITE_DIR'] . "/era/$eraname.edi", 'era_callback');
623 $StringIssue=htmlspecialchars( xl("Total Distribution for following check number is not full"), ENT_QUOTES
).': ';
625 foreach($InsertionId as $key => $value)
627 $rs= sqlQ("select pay_total from ar_session where session_id='$value'");
628 $row=sqlFetchArray($rs);
629 $pay_total=$row['pay_total'];
630 $rs= sqlQ("select sum(pay_amount) sum_pay_amount from ar_activity where session_id='$value'");
631 $row=sqlFetchArray($rs);
632 $pay_amount=$row['sum_pay_amount'];
634 if(($pay_total-$pay_amount)<>0)
636 $StringIssue.=$key.' ';
640 if($StringPrint=='Yes')
641 echo "<script>alert('$StringIssue')</script>";
644 if (!$INTEGRATED_AR) slTerminate();
652 <script language
="JavaScript">
654 if ($alertmsg) echo " alert('" . htmlspecialchars($alertmsg, ENT_QUOTES
) . "');\n";
657 <input type
="hidden" name
="paydate" value
="<?php echo DateToYYYYMMDD($_REQUEST['paydate']);?>" />
658 <input type
="hidden" name
="post_to_date" value
="<?php echo DateToYYYYMMDD($_REQUEST['post_to_date']);?>" />
659 <input type
="hidden" name
="deposit_date" value
="<?php echo DateToYYYYMMDD($_REQUEST['deposit_date']);?>" />
660 <input type
="hidden" name
="debug" value
="<?php echo $_REQUEST['debug'];?>" />
661 <input type
="hidden" name
="InsId" value
="<?php echo $_REQUEST['InsId'];?>" />
662 <input type
="hidden" name
="eraname" value
="<?php echo $eraname?>" />
667 // Save all of this script's output to a report file.
669 fwrite($fhreport, ob_get_contents());