Centralized formatting.inc.php include
[openemr.git] / interface / billing / sl_eob_process.php
blob28b4d4c8ce3432bb4912c19ffa250876359b4788
1 <?php
2 // Copyright (C) 2006-2010 Rod Roark <rod@sunsetsystems.com>
3 //
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.
12 ob_start();
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/billing.inc");
23 $debug = $_GET['debug'] ? 1 : 0; // set to 1 for debugging mode
24 $paydate = parse_date($_GET['paydate']);
25 $encount = 0;
27 $last_ptname = '';
28 $last_invnumber = '';
29 $last_code = '';
30 $invoice_total = 0.00;
31 $InsertionId;//last inserted ID of
33 ///////////////////////// Assorted Functions /////////////////////////
35 function parse_date($date) {
36 $date = substr(trim($date), 0, 10);
37 if (preg_match('/^(\d\d\d\d)\D*(\d\d)\D*(\d\d)$/', $date, $matches)) {
38 return $matches[1] . '-' . $matches[2] . '-' . $matches[3];
40 return '';
43 function writeMessageLine($bgcolor, $class, $description) {
44 $dline =
45 " <tr bgcolor='$bgcolor'>\n" .
46 " <td class='$class' colspan='4'>&nbsp;</td>\n" .
47 " <td class='$class'>$description</td>\n" .
48 " <td class='$class' colspan='2'>&nbsp;</td>\n" .
49 " </tr>\n";
50 echo $dline;
53 function writeDetailLine($bgcolor, $class, $ptname, $invnumber,
54 $code, $date, $description, $amount, $balance)
56 global $last_ptname, $last_invnumber, $last_code;
57 if ($ptname == $last_ptname) $ptname = '&nbsp;';
58 else $last_ptname = $ptname;
59 if ($invnumber == $last_invnumber) $invnumber = '&nbsp;';
60 else $last_invnumber = $invnumber;
61 if ($code == $last_code) $code = '&nbsp;';
62 else $last_code = $code;
63 if ($amount ) $amount = sprintf("%.2f", $amount );
64 if ($balance) $balance = sprintf("%.2f", $balance);
65 $dline =
66 " <tr bgcolor='$bgcolor'>\n" .
67 " <td class='$class'>$ptname</td>\n" .
68 " <td class='$class'>$invnumber</td>\n" .
69 " <td class='$class'>$code</td>\n" .
70 " <td class='$class'>" . oeFormatShortDate($date) . "</td>\n" .
71 " <td class='$class'>$description</td>\n" .
72 " <td class='$class' align='right'>" . oeFormatMoney($amount) . "</td>\n" .
73 " <td class='$class' align='right'>" . oeFormatMoney($balance) . "</td>\n" .
74 " </tr>\n";
75 echo $dline;
78 // This writes detail lines that were already in SQL-Ledger for a given
79 // charge item.
81 function writeOldDetail(&$prev, $ptname, $invnumber, $dos, $code, $bgcolor) {
82 global $invoice_total;
83 // $prev['total'] = 0.00; // to accumulate total charges
84 ksort($prev['dtl']);
85 foreach ($prev['dtl'] as $dkey => $ddata) {
86 $ddate = substr($dkey, 0, 10);
87 $description = $ddata['src'] . $ddata['rsn'];
88 if ($ddate == ' ') { // this is the service item
89 $ddate = $dos;
90 $description = 'Service Item';
92 $amount = sprintf("%.2f", $ddata['chg'] - $ddata['pmt']);
93 $invoice_total = sprintf("%.2f", $invoice_total + $amount);
94 writeDetailLine($bgcolor, 'olddetail', $ptname, $invnumber,
95 $code, $ddate, $description, $amount, $invoice_total);
99 // This is called back by parse_era() once per claim.
101 function era_callback_check(&$out)
104 global $InsertionId;//last inserted ID of
105 global $StringToEcho,$debug;
107 if($_GET['original']=='original')
109 $StringToEcho="<br/><br/><br/><br/><br/><br/>";
110 $StringToEcho.="<table border='1' cellpadding='0' cellspacing='0' width='750'>";
111 $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>";
112 $WarningFlag=false;
113 for ($check_count=1;$check_count<=$out['check_count'];$check_count++)
115 if($check_count%2==1)
117 $bgcolor='#ddddff';
119 else
121 $bgcolor='#ffdddd';
123 $rs=sqlQ("select reference from ar_session where reference='".$out['check_number'.$check_count]."'");
124 if(sqlNumRows($rs)>0)
126 $bgcolor='#ff0000';
127 $WarningFlag=true;
129 $StringToEcho.="<tr bgcolor='$bgcolor'>";
130 $StringToEcho.="<td><input type='checkbox' name='chk".$out['check_number'.$check_count]."' value='".$out['check_number'.$check_count]."'/></td>";
131 $StringToEcho.="<td>".htmlspecialchars($out['check_number'.$check_count])."</td>";
132 $StringToEcho.="<td>".htmlspecialchars($out['payee_name'.$check_count])."</td>";
133 $StringToEcho.="<td align='right'>".htmlspecialchars(number_format($out['check_amount'.$check_count],2))."</td>";
134 $StringToEcho.="</tr>";
136 $StringToEcho.="<tr bgcolor='#cccccc'><td colspan='4' align='center'><input type='submit' name='CheckSubmit' value='Submit'/></td></tr>";
137 if($WarningFlag==true)
138 $StringToEcho.="<tr bgcolor='#ff0000'><td colspan='4' align='center'>".htmlspecialchars( xl('Warning, Check Number already exist in the database'), ENT_QUOTES)."</td></tr>";
139 $StringToEcho.="</table>";
141 else
143 for ($check_count=1;$check_count<=$out['check_count'];$check_count++)
145 $chk_num=$out['check_number'.$check_count];
146 $chk_num=str_replace(' ','_',$chk_num);
147 if(isset($_REQUEST['chk'.$chk_num]))
149 $check_date=$out['check_date'.$check_count]?$out['check_date'.$check_count]:$_REQUEST['paydate'];
150 $post_to_date=$_REQUEST['post_to_date']!=''?$_REQUEST['post_to_date']:date('Y-m-d');
151 $deposit_date=$_REQUEST['deposit_date']!=''?$_REQUEST['deposit_date']:date('Y-m-d');
152 $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);
159 function era_callback(&$out) {
160 global $encount, $debug, $claim_status_codes, $adjustment_reasons, $remark_codes;
161 global $invoice_total, $last_code, $paydate;
162 global $InsertionId;//last inserted ID of
165 // Some heading information.
166 $chk_123=$out['check_number'];
167 $chk_123=str_replace(' ','_',$chk_123);
168 if(isset($_REQUEST['chk'.$chk_123])){
169 if ($encount == 0) {
170 writeMessageLine('#ffffff', 'infdetail',
171 "Payer: " . htmlspecialchars($out['payer_name'], ENT_QUOTES));
172 if ($debug) {
173 writeMessageLine('#ffffff', 'infdetail',
174 "WITHOUT UPDATE is selected; no changes will be applied.");
178 $last_code = '';
179 $invoice_total = 0.00;
180 $bgcolor = (++$encount & 1) ? "#ddddff" : "#ffdddd";
181 list($pid, $encounter, $invnumber) = slInvoiceNumber($out);
183 // Get details, if we have them, for the invoice.
184 $inverror = true;
185 $codes = array();
186 if ($pid && $encounter) {
187 // Get invoice data into $arrow or $ferow.
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 ".
191 "p.pid = e.pid");
192 if (empty($ferow)) {
193 $pid = $encounter = 0;
194 $invnumber = $out['our_claim_id'];
195 } else {
196 $inverror = false;
197 $codes = ar_get_invoice_summary($pid, $encounter, true);
198 // $svcdate = substr($ferow['date'], 0, 10);
202 // Show the claim status.
203 $csc = $out['claim_status_code'];
204 $inslabel = 'Ins1';
205 if ($csc == '1' || $csc == '19') $inslabel = 'Ins1';
206 if ($csc == '2' || $csc == '20') $inslabel = 'Ins2';
207 if ($csc == '3' || $csc == '21') $inslabel = 'Ins3';
208 $primary = ($inslabel == 'Ins1');
209 writeMessageLine($bgcolor, 'infdetail',
210 "Claim status $csc: " . $claim_status_codes[$csc]);
212 // Show an error message if the claim is missing or already posted.
213 if ($inverror) {
214 writeMessageLine($bgcolor, 'errdetail',
215 "The following claim is not in our database");
217 else {
218 // Skip this test. Claims can get multiple CLPs from the same payer!
220 // $insdone = strtolower($arrow['shipvia']);
221 // if (strpos($insdone, 'ins1') !== false) {
222 // $inverror = true;
223 // writeMessageLine($bgcolor, 'errdetail',
224 // "Primary insurance EOB was already posted for the following claim");
225 // }
228 if ($csc == '4') {//Denial case, code is stored in the claims table for display in the billing manager screen with reason explained.
229 $inverror = true;
230 if (!$debug) {
231 if ($pid && $encounter) {
232 $code_value = '';
233 foreach ($out['svc'] as $svc) {
234 foreach ($svc['adj'] as $adj) {//Per code and modifier the reason will be showed in the billing manager.
235 $code_value .= $svc['code'].'_'.$svc['mod'].'_'.$adj['group_code'].'_'.$adj['reason_code'].',';
238 $code_value = substr($code_value,0,-1);
239 //We store the reason code to display it with description in the billing manager screen.
240 //process_file is used as for the denial case file name will not be there, and extra field(to store reason) can be avoided.
241 updateClaim(true, $pid, $encounter, $_REQUEST['InsId'], substr($inslabel,3),7,0,$code_value);
244 writeMessageLine($bgcolor, 'errdetail',
245 "Not posting adjustments for denied claims, please follow up manually!");
247 else if ($csc == '22') {
248 $inverror = true;
249 writeMessageLine($bgcolor, 'errdetail',
250 "Payment reversals are not automated, please enter manually!");
253 if ($out['warnings']) {
254 writeMessageLine($bgcolor, 'infdetail', nl2br(rtrim($out['warnings'])));
257 // Simplify some claim attributes for cleaner code.
258 $service_date = parse_date($out['dos']);
259 $check_date = $paydate ? $paydate : parse_date($out['check_date']);
260 $production_date = $paydate ? $paydate : parse_date($out['production_date']);
262 $insurance_id = arGetPayerID($pid, $service_date, substr($inslabel, 3));
263 if (empty($ferow['lname'])) {
264 $patient_name = $out['patient_fname'] . ' ' . $out['patient_lname'];
265 } else {
266 $patient_name = $ferow['fname'] . ' ' . $ferow['lname'];
269 $error = $inverror;
271 // This loops once for each service item in this claim.
272 foreach ($out['svc'] as $svc) {
274 // Treat a modifier in the remit data as part of the procedure key.
275 // This key will then make its way into SQL-Ledger.
276 $codekey = $svc['code'];
277 if ($svc['mod']) $codekey .= ':' . $svc['mod'];
278 $prev = $codes[$codekey];
279 $codetype = ''; //will hold code type, if exists
281 // This reports detail lines already on file for this service item.
282 if ($prev) {
283 $codetype = $codes[$codekey]['code_type']; //store code type
284 writeOldDetail($prev, $patient_name, $invnumber, $service_date, $codekey, $bgcolor);
285 // Check for sanity in amount charged.
286 $prevchg = sprintf("%.2f", $prev['chg'] + $prev['adj']);
287 if ($prevchg != abs($svc['chg'])) {
288 writeMessageLine($bgcolor, 'errdetail',
289 "EOB charge amount " . $svc['chg'] . " for this code does not match our invoice");
290 $error = true;
293 // Check for already-existing primary remittance activity.
294 // Removed this check because it was not allowing for copays manually
295 // entered into the invoice under a non-copay billing code.
296 /****
297 if ((sprintf("%.2f",$prev['chg']) != sprintf("%.2f",$prev['bal']) ||
298 $prev['adj'] != 0) && $primary)
300 writeMessageLine($bgcolor, 'errdetail',
301 "This service item already has primary payments and/or adjustments!");
302 $error = true;
304 ****/
306 unset($codes[$codekey]);
309 // If the service item is not in our database...
310 else {
312 // This is not an error. If we are not in error mode and not debugging,
313 // insert the service item into SL. Then display it (in green if it
314 // was inserted, or in red if we are in error mode).
315 $description = "CPT4:$codekey Added by $inslabel $production_date";
316 if (!$error && !$debug) {
317 arPostCharge($pid, $encounter, 0, $svc['chg'], 1, $service_date,
318 $codekey, $description, $debug,'',$codetype);
319 $invoice_total += $svc['chg'];
321 $class = $error ? 'errdetail' : 'newdetail';
322 writeDetailLine($bgcolor, $class, $patient_name, $invnumber,
323 $codekey, $production_date, $description,
324 $svc['chg'], ($error ? '' : $invoice_total));
328 $class = $error ? 'errdetail' : 'newdetail';
330 // Report Allowed Amount.
331 if ($svc['allowed']) {
332 // A problem here is that some payers will include an adjustment
333 // reflecting the allowed amount, others not. So here we need to
334 // check if the adjustment exists, and if not then create it. We
335 // assume that any nonzero CO (Contractual Obligation) or PI
336 // (Payer Initiated) adjustment is good enough.
337 $contract_adj = sprintf("%.2f", $svc['chg'] - $svc['allowed']);
338 foreach ($svc['adj'] as $adj) {
339 if (($adj['group_code'] == 'CO' || $adj['group_code'] == 'PI') && $adj['amount'] != 0)
340 $contract_adj = 0;
342 if ($contract_adj > 0) {
343 $svc['adj'][] = array('group_code' => 'CO', 'reason_code' => 'A2',
344 'amount' => $contract_adj);
346 writeMessageLine($bgcolor, 'infdetail',
347 'Allowed amount is ' . sprintf("%.2f", $svc['allowed']));
350 // Report miscellaneous remarks.
351 if ($svc['remark']) {
352 $rmk = $svc['remark'];
353 writeMessageLine($bgcolor, 'infdetail', "$rmk: " . $remark_codes[$rmk]);
356 // Post and report the payment for this service item from the ERA.
357 // By the way a 'Claim' level payment is probably going to be negative,
358 // i.e. a payment reversal.
359 if ($svc['paid']) {
360 if (!$error && !$debug) {
361 arPostPayment($pid, $encounter,$InsertionId[$out['check_number']], $svc['paid'],//$InsertionId[$out['check_number']] gives the session id
362 $codekey, substr($inslabel,3), $out['check_number'], $debug,'',$codetype);
363 $invoice_total -= $svc['paid'];
365 $description = "$inslabel/" . $out['check_number'] . ' payment';
366 if ($svc['paid'] < 0) $description .= ' reversal';
367 writeDetailLine($bgcolor, $class, $patient_name, $invnumber,
368 $codekey, $check_date, $description,
369 0 - $svc['paid'], ($error ? '' : $invoice_total));
372 // Post and report adjustments from this ERA. Posted adjustment reasons
373 // must be 25 characters or less in order to fit on patient statements.
374 foreach ($svc['adj'] as $adj) {
375 $description = $adj['reason_code'] . ': ' . $adjustment_reasons[$adj['reason_code']];
376 if ($adj['group_code'] == 'PR' || !$primary) {
377 // Group code PR is Patient Responsibility. Enter these as zero
378 // adjustments to retain the note without crediting the claim.
379 if ($primary) {
380 /****
381 $reason = 'Pt resp: '; // Reasons should be 25 chars or less.
382 if ($adj['reason_code'] == '1') $reason = 'To deductible: ';
383 else if ($adj['reason_code'] == '2') $reason = 'Coinsurance: ';
384 else if ($adj['reason_code'] == '3') $reason = 'Co-pay: ';
385 ****/
386 $reason = "$inslabel ptresp: "; // Reasons should be 25 chars or less.
387 if ($adj['reason_code'] == '1') $reason = "$inslabel dedbl: ";
388 else if ($adj['reason_code'] == '2') $reason = "$inslabel coins: ";
389 else if ($adj['reason_code'] == '3') $reason = "$inslabel copay: ";
391 // Non-primary insurance adjustments are garbage, either repeating
392 // the primary or are not adjustments at all. Report them as notes
393 // but do not post any amounts.
394 else {
395 $reason = "$inslabel note " . $adj['reason_code'] . ': ';
396 /****
397 $reason .= sprintf("%.2f", $adj['amount']);
398 ****/
400 $reason .= sprintf("%.2f", $adj['amount']);
401 // Post a zero-dollar adjustment just to save it as a comment.
402 if (!$error && !$debug) {
403 arPostAdjustment($pid, $encounter, $InsertionId[$out['check_number']], 0, $codekey,//$InsertionId[$out['check_number']] gives the session id
404 substr($inslabel,3), $reason, $debug, '', $codetype);
406 writeMessageLine($bgcolor, $class, $description . ' ' .
407 sprintf("%.2f", $adj['amount']));
409 // Other group codes for primary insurance are real adjustments.
410 else {
411 if (!$error && !$debug) {
412 arPostAdjustment($pid, $encounter, $InsertionId[$out['check_number']], $adj['amount'],//$InsertionId[$out['check_number']] gives the session id
413 $codekey, substr($inslabel,3),
414 "Adjust code " . $adj['reason_code'], $debug, '', $codetype);
415 $invoice_total -= $adj['amount'];
417 writeDetailLine($bgcolor, $class, $patient_name, $invnumber,
418 $codekey, $production_date, $description,
419 0 - $adj['amount'], ($error ? '' : $invoice_total));
423 } // End of service item
425 // Report any existing service items not mentioned in the ERA, and
426 // determine if any of them are still missing an insurance response
427 // (if so, then insurance is not yet done with the claim).
428 $insurance_done = true;
429 foreach ($codes as $code => $prev) {
430 // writeOldDetail($prev, $arrow['name'], $invnumber, $service_date, $code, $bgcolor);
431 writeOldDetail($prev, $patient_name, $invnumber, $service_date, $code, $bgcolor);
432 $got_response = false;
433 foreach ($prev['dtl'] as $ddata) {
434 if ($ddata['pmt'] || $ddata['rsn']) $got_response = true;
436 if (!$got_response) $insurance_done = false;
439 // Cleanup: If all is well, mark Ins<x> done and check for secondary billing.
440 if (!$error && !$debug && $insurance_done) {
441 $level_done = 0 + substr($inslabel, 3);
443 if($out['crossover']==1)
444 {//Automatic forward case.So need not again bill from the billing manager screen.
445 sqlStatement("UPDATE form_encounter " .
446 "SET last_level_closed = $level_done,last_level_billed=".$level_done." WHERE " .
447 "pid = '$pid' AND encounter = '$encounter'");
448 writeMessageLine($bgcolor, 'infdetail',
449 'This claim is processed by Insurance '.$level_done.' and automatically forwarded to Insurance '.($level_done+1) .' for processing. ');
451 else {
452 sqlStatement("UPDATE form_encounter " .
453 "SET last_level_closed = $level_done WHERE " .
454 "pid = '$pid' AND encounter = '$encounter'");
456 // Check for secondary insurance.
457 if ($primary && arGetPayerID($pid, $service_date, 2)) {
458 arSetupSecondary($pid, $encounter, $debug,$out['crossover']);
460 if($out['crossover']<>1)
462 writeMessageLine($bgcolor, 'infdetail',
463 'This claim is now re-queued for secondary paper billing');
470 /////////////////////////// End Functions ////////////////////////////
472 $info_msg = "";
474 $eraname = $_GET['eraname'];
475 if (! $eraname) die(xl("You cannot access this page directly."));
477 // Open the output file early so that in case it fails, we do not post a
478 // bunch of stuff without saving the report. Also be sure to retain any old
479 // report files. Do not save the report if this is a no-update situation.
481 if (!$debug) {
482 $nameprefix = $GLOBALS['OE_SITE_DIR'] . "/era/$eraname";
483 $namesuffix = '';
484 for ($i = 1; is_file("$nameprefix$namesuffix.html"); ++$i) {
485 $namesuffix = "_$i";
487 $fnreport = "$nameprefix$namesuffix.html";
488 $fhreport = fopen($fnreport, 'w');
489 if (!$fhreport) die(xl("Cannot create") . " '$fnreport'");
493 <html>
494 <head>
495 <?php html_header_show();?>
496 <link rel=stylesheet href="<?php echo $css_header;?>" type="text/css">
497 <style type="text/css">
498 body { font-family:sans-serif; font-size:8pt; font-weight:normal }
499 .dehead { color:#000000; font-family:sans-serif; font-size:9pt; font-weight:bold }
500 .olddetail { color:#000000; font-family:sans-serif; font-size:9pt; font-weight:normal }
501 .newdetail { color:#00dd00; font-family:sans-serif; font-size:9pt; font-weight:normal }
502 .errdetail { color:#dd0000; font-family:sans-serif; font-size:9pt; font-weight:normal }
503 .infdetail { color:#0000ff; font-family:sans-serif; font-size:9pt; font-weight:normal }
504 </style>
505 <title><?php xl('EOB Posting - Electronic Remittances','e')?></title>
506 <script language="JavaScript">
507 </script>
508 </head>
509 <body leftmargin='0' topmargin='0' marginwidth='0' marginheight='0'>
510 <form action="sl_eob_process.php" method="get" >
511 <center>
512 <?php
513 if($_GET['original']=='original')
515 $alertmsg = parse_era_for_check($GLOBALS['OE_SITE_DIR'] . "/era/$eraname.edi", 'era_callback');
516 echo $StringToEcho;
518 else
521 <table border='0' cellpadding='2' cellspacing='0' width='100%'>
523 <tr bgcolor="#cccccc">
524 <td class="dehead">
525 <?php echo htmlspecialchars( xl('Patient'), ENT_QUOTES) ?>
526 </td>
527 <td class="dehead">
528 <?php echo htmlspecialchars( xl('Invoice'), ENT_QUOTES) ?>
529 </td>
530 <td class="dehead">
531 <?php echo htmlspecialchars( xl('Code'), ENT_QUOTES) ?>
532 </td>
533 <td class="dehead">
534 <?php echo htmlspecialchars( xl('Date'), ENT_QUOTES) ?>
535 </td>
536 <td class="dehead">
537 <?php echo htmlspecialchars( xl('Description'), ENT_QUOTES) ?>
538 </td>
539 <td class="dehead" align="right">
540 <?php echo htmlspecialchars( xl('Amount'), ENT_QUOTES) ?>&nbsp;
541 </td>
542 <td class="dehead" align="right">
543 <?php echo htmlspecialchars( xl('Balance'), ENT_QUOTES) ?>&nbsp;
544 </td>
545 </tr>
547 <?php
548 global $InsertionId;
550 $eraname=$_REQUEST['eraname'];
551 $alertmsg = parse_era_for_check($GLOBALS['OE_SITE_DIR'] . "/era/$eraname.edi");
552 $alertmsg = parse_era($GLOBALS['OE_SITE_DIR'] . "/era/$eraname.edi", 'era_callback');
553 if(!$debug)
555 $StringIssue=htmlspecialchars( xl("Total Distribution for following check number is not full"), ENT_QUOTES).': ';
556 $StringPrint='No';
557 foreach($InsertionId as $key => $value)
559 $rs= sqlQ("select pay_total from ar_session where session_id='$value'");
560 $row=sqlFetchArray($rs);
561 $pay_total=$row['pay_total'];
562 $rs= sqlQ("select sum(pay_amount) sum_pay_amount from ar_activity where session_id='$value'");
563 $row=sqlFetchArray($rs);
564 $pay_amount=$row['sum_pay_amount'];
566 if(($pay_total-$pay_amount)<>0)
568 $StringIssue.=$key.' ';
569 $StringPrint='Yes';
572 if($StringPrint=='Yes')
573 echo "<script>alert('$StringIssue')</script>";
578 </table>
579 <?php
582 </center>
583 <script language="JavaScript">
584 <?php
585 if ($alertmsg) echo " alert('" . htmlspecialchars($alertmsg, ENT_QUOTES) . "');\n";
587 </script>
588 <input type="hidden" name="paydate" value="<?php echo DateToYYYYMMDD($_REQUEST['paydate']);?>" />
589 <input type="hidden" name="post_to_date" value="<?php echo DateToYYYYMMDD($_REQUEST['post_to_date']);?>" />
590 <input type="hidden" name="deposit_date" value="<?php echo DateToYYYYMMDD($_REQUEST['deposit_date']);?>" />
591 <input type="hidden" name="debug" value="<?php echo $_REQUEST['debug'];?>" />
592 <input type="hidden" name="InsId" value="<?php echo $_REQUEST['InsId'];?>" />
593 <input type="hidden" name="eraname" value="<?php echo $eraname?>" />
594 </form>
595 </body>
596 </html>
597 <?php
598 // Save all of this script's output to a report file.
599 if (!$debug) {
600 fwrite($fhreport, ob_get_contents());
601 fclose($fhreport);
603 ob_end_flush();