Feature to add drug-drug interaction checking for the
[openemr.git] / interface / billing / sl_eob_process.php
blobe0d4beb0627a04f18c07cf7349658e259c6d4e35
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/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']);
26 $encount = 0;
28 $last_ptname = '';
29 $last_invnumber = '';
30 $last_code = '';
31 $invoice_total = 0.00;
32 $InsertionId;//last inserted ID of
34 ///////////////////////// Assorted Functions /////////////////////////
36 function parse_date($date) {
37 $date = substr(trim($date), 0, 10);
38 if (preg_match('/^(\d\d\d\d)\D*(\d\d)\D*(\d\d)$/', $date, $matches)) {
39 return $matches[1] . '-' . $matches[2] . '-' . $matches[3];
41 return '';
44 function writeMessageLine($bgcolor, $class, $description) {
45 $dline =
46 " <tr bgcolor='$bgcolor'>\n" .
47 " <td class='$class' colspan='4'>&nbsp;</td>\n" .
48 " <td class='$class'>$description</td>\n" .
49 " <td class='$class' colspan='2'>&nbsp;</td>\n" .
50 " </tr>\n";
51 echo $dline;
54 function writeDetailLine($bgcolor, $class, $ptname, $invnumber,
55 $code, $date, $description, $amount, $balance)
57 global $last_ptname, $last_invnumber, $last_code;
58 if ($ptname == $last_ptname) $ptname = '&nbsp;';
59 else $last_ptname = $ptname;
60 if ($invnumber == $last_invnumber) $invnumber = '&nbsp;';
61 else $last_invnumber = $invnumber;
62 if ($code == $last_code) $code = '&nbsp;';
63 else $last_code = $code;
64 if ($amount ) $amount = sprintf("%.2f", $amount );
65 if ($balance) $balance = sprintf("%.2f", $balance);
66 $dline =
67 " <tr bgcolor='$bgcolor'>\n" .
68 " <td class='$class'>$ptname</td>\n" .
69 " <td class='$class'>$invnumber</td>\n" .
70 " <td class='$class'>$code</td>\n" .
71 " <td class='$class'>" . oeFormatShortDate($date) . "</td>\n" .
72 " <td class='$class'>$description</td>\n" .
73 " <td class='$class' align='right'>" . oeFormatMoney($amount) . "</td>\n" .
74 " <td class='$class' align='right'>" . oeFormatMoney($balance) . "</td>\n" .
75 " </tr>\n";
76 echo $dline;
79 // This writes detail lines that were already in SQL-Ledger for a given
80 // charge item.
82 function writeOldDetail(&$prev, $ptname, $invnumber, $dos, $code, $bgcolor) {
83 global $invoice_total;
84 // $prev['total'] = 0.00; // to accumulate total charges
85 ksort($prev['dtl']);
86 foreach ($prev['dtl'] as $dkey => $ddata) {
87 $ddate = substr($dkey, 0, 10);
88 $description = $ddata['src'] . $ddata['rsn'];
89 if ($ddate == ' ') { // this is the service item
90 $ddate = $dos;
91 $description = 'Service Item';
93 $amount = sprintf("%.2f", $ddata['chg'] - $ddata['pmt']);
94 $invoice_total = sprintf("%.2f", $invoice_total + $amount);
95 writeDetailLine($bgcolor, 'olddetail', $ptname, $invnumber,
96 $code, $ddate, $description, $amount, $invoice_total);
100 // This is called back by parse_era() once per claim.
102 function era_callback_check(&$out)
105 global $InsertionId;//last inserted ID of
106 global $StringToEcho,$debug;
108 if($_GET['original']=='original')
110 $StringToEcho="<br/><br/><br/><br/><br/><br/>";
111 $StringToEcho.="<table border='1' cellpadding='0' cellspacing='0' width='750'>";
112 $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>";
113 $WarningFlag=false;
114 for ($check_count=1;$check_count<=$out['check_count'];$check_count++)
116 if($check_count%2==1)
118 $bgcolor='#ddddff';
120 else
122 $bgcolor='#ffdddd';
124 $rs=sqlQ("select reference from ar_session where reference='".$out['check_number'.$check_count]."'");
125 if(sqlNumRows($rs)>0)
127 $bgcolor='#ff0000';
128 $WarningFlag=true;
130 $StringToEcho.="<tr bgcolor='$bgcolor'>";
131 $StringToEcho.="<td><input type='checkbox' name='chk".$out['check_number'.$check_count]."' value='".$out['check_number'.$check_count]."'/></td>";
132 $StringToEcho.="<td>".htmlspecialchars($out['check_number'.$check_count])."</td>";
133 $StringToEcho.="<td>".htmlspecialchars($out['payee_name'.$check_count])."</td>";
134 $StringToEcho.="<td align='right'>".htmlspecialchars(number_format($out['check_amount'.$check_count],2))."</td>";
135 $StringToEcho.="</tr>";
137 $StringToEcho.="<tr bgcolor='#cccccc'><td colspan='4' align='center'><input type='submit' name='CheckSubmit' value='Submit'/></td></tr>";
138 if($WarningFlag==true)
139 $StringToEcho.="<tr bgcolor='#ff0000'><td colspan='4' align='center'>".htmlspecialchars( xl('Warning, Check Number already exist in the database'), ENT_QUOTES)."</td></tr>";
140 $StringToEcho.="</table>";
142 else
144 for ($check_count=1;$check_count<=$out['check_count'];$check_count++)
146 $chk_num=$out['check_number'.$check_count];
147 $chk_num=str_replace(' ','_',$chk_num);
148 if(isset($_REQUEST['chk'.$chk_num]))
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;
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])){
170 if ($encount == 0) {
171 writeMessageLine('#ffffff', 'infdetail',
172 "Payer: " . htmlspecialchars($out['payer_name'], ENT_QUOTES));
173 if ($debug) {
174 writeMessageLine('#ffffff', 'infdetail',
175 "WITHOUT UPDATE is selected; no changes will be applied.");
179 $last_code = '';
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.
185 $inverror = true;
186 $codes = array();
187 if ($pid && $encounter) {
188 // Get invoice data into $arrow or $ferow.
189 $ferow = sqlQuery("SELECT e.*, p.fname, p.mname, p.lname " .
190 "FROM form_encounter AS e, patient_data AS p WHERE " .
191 "e.pid = '$pid' AND e.encounter = '$encounter' AND ".
192 "p.pid = e.pid");
193 if (empty($ferow)) {
194 $pid = $encounter = 0;
195 $invnumber = $out['our_claim_id'];
196 } else {
197 $inverror = false;
198 $codes = ar_get_invoice_summary($pid, $encounter, true);
199 // $svcdate = substr($ferow['date'], 0, 10);
203 // Show the claim status.
204 $csc = $out['claim_status_code'];
205 $inslabel = 'Ins1';
206 if ($csc == '1' || $csc == '19') $inslabel = 'Ins1';
207 if ($csc == '2' || $csc == '20') $inslabel = 'Ins2';
208 if ($csc == '3' || $csc == '21') $inslabel = 'Ins3';
209 $primary = ($inslabel == 'Ins1');
210 writeMessageLine($bgcolor, 'infdetail',
211 "Claim status $csc: " . $claim_status_codes[$csc]);
213 // Show an error message if the claim is missing or already posted.
214 if ($inverror) {
215 writeMessageLine($bgcolor, 'errdetail',
216 "The following claim is not in our database");
218 else {
219 // Skip this test. Claims can get multiple CLPs from the same payer!
221 // $insdone = strtolower($arrow['shipvia']);
222 // if (strpos($insdone, 'ins1') !== false) {
223 // $inverror = true;
224 // writeMessageLine($bgcolor, 'errdetail',
225 // "Primary insurance EOB was already posted for the following claim");
226 // }
229 if ($csc == '4') {//Denial case, code is stored in the claims table for display in the billing manager screen with reason explained.
230 $inverror = true;
231 if (!$debug) {
232 if ($pid && $encounter) {
233 $code_value = '';
234 foreach ($out['svc'] as $svc) {
235 foreach ($svc['adj'] as $adj) {//Per code and modifier the reason will be showed in the billing manager.
236 $code_value .= $svc['code'].'_'.$svc['mod'].'_'.$adj['group_code'].'_'.$adj['reason_code'].',';
239 $code_value = substr($code_value,0,-1);
240 //We store the reason code to display it with description in the billing manager screen.
241 //process_file is used as for the denial case file name will not be there, and extra field(to store reason) can be avoided.
242 updateClaim(true, $pid, $encounter, $_REQUEST['InsId'], substr($inslabel,3),7,0,$code_value);
245 writeMessageLine($bgcolor, 'errdetail',
246 "Not posting adjustments for denied claims, please follow up manually!");
248 else if ($csc == '22') {
249 $inverror = true;
250 writeMessageLine($bgcolor, 'errdetail',
251 "Payment reversals are not automated, please enter manually!");
254 if ($out['warnings']) {
255 writeMessageLine($bgcolor, 'infdetail', nl2br(rtrim($out['warnings'])));
258 // Simplify some claim attributes for cleaner code.
259 $service_date = parse_date($out['dos']);
260 $check_date = $paydate ? $paydate : parse_date($out['check_date']);
261 $production_date = $paydate ? $paydate : parse_date($out['production_date']);
263 $insurance_id = arGetPayerID($pid, $service_date, substr($inslabel, 3));
264 if (empty($ferow['lname'])) {
265 $patient_name = $out['patient_fname'] . ' ' . $out['patient_lname'];
266 } else {
267 $patient_name = $ferow['fname'] . ' ' . $ferow['lname'];
270 $error = $inverror;
272 // This loops once for each service item in this claim.
273 foreach ($out['svc'] as $svc) {
275 // Treat a modifier in the remit data as part of the procedure key.
276 // This key will then make its way into SQL-Ledger.
277 $codekey = $svc['code'];
278 if ($svc['mod']) $codekey .= ':' . $svc['mod'];
279 $prev = $codes[$codekey];
280 $codetype = ''; //will hold code type, if exists
282 // This reports detail lines already on file for this service item.
283 if ($prev) {
284 $codetype = $codes[$codekey]['code_type']; //store code type
285 writeOldDetail($prev, $patient_name, $invnumber, $service_date, $codekey, $bgcolor);
286 // Check for sanity in amount charged.
287 $prevchg = sprintf("%.2f", $prev['chg'] + $prev['adj']);
288 if ($prevchg != abs($svc['chg'])) {
289 writeMessageLine($bgcolor, 'errdetail',
290 "EOB charge amount " . $svc['chg'] . " for this code does not match our invoice");
291 $error = true;
294 // Check for already-existing primary remittance activity.
295 // Removed this check because it was not allowing for copays manually
296 // entered into the invoice under a non-copay billing code.
297 /****
298 if ((sprintf("%.2f",$prev['chg']) != sprintf("%.2f",$prev['bal']) ||
299 $prev['adj'] != 0) && $primary)
301 writeMessageLine($bgcolor, 'errdetail',
302 "This service item already has primary payments and/or adjustments!");
303 $error = true;
305 ****/
307 unset($codes[$codekey]);
310 // If the service item is not in our database...
311 else {
313 // This is not an error. If we are not in error mode and not debugging,
314 // insert the service item into SL. Then display it (in green if it
315 // was inserted, or in red if we are in error mode).
316 $description = "CPT4:$codekey Added by $inslabel $production_date";
317 if (!$error && !$debug) {
318 arPostCharge($pid, $encounter, 0, $svc['chg'], 1, $service_date,
319 $codekey, $description, $debug,'',$codetype);
320 $invoice_total += $svc['chg'];
322 $class = $error ? 'errdetail' : 'newdetail';
323 writeDetailLine($bgcolor, $class, $patient_name, $invnumber,
324 $codekey, $production_date, $description,
325 $svc['chg'], ($error ? '' : $invoice_total));
329 $class = $error ? 'errdetail' : 'newdetail';
331 // Report Allowed Amount.
332 if ($svc['allowed']) {
333 // A problem here is that some payers will include an adjustment
334 // reflecting the allowed amount, others not. So here we need to
335 // check if the adjustment exists, and if not then create it. We
336 // assume that any nonzero CO (Contractual Obligation) or PI
337 // (Payer Initiated) adjustment is good enough.
338 $contract_adj = sprintf("%.2f", $svc['chg'] - $svc['allowed']);
339 foreach ($svc['adj'] as $adj) {
340 if (($adj['group_code'] == 'CO' || $adj['group_code'] == 'PI') && $adj['amount'] != 0)
341 $contract_adj = 0;
343 if ($contract_adj > 0) {
344 $svc['adj'][] = array('group_code' => 'CO', 'reason_code' => 'A2',
345 'amount' => $contract_adj);
347 writeMessageLine($bgcolor, 'infdetail',
348 'Allowed amount is ' . sprintf("%.2f", $svc['allowed']));
351 // Report miscellaneous remarks.
352 if ($svc['remark']) {
353 $rmk = $svc['remark'];
354 writeMessageLine($bgcolor, 'infdetail', "$rmk: " . $remark_codes[$rmk]);
357 // Post and report the payment for this service item from the ERA.
358 // By the way a 'Claim' level payment is probably going to be negative,
359 // i.e. a payment reversal.
360 if ($svc['paid']) {
361 if (!$error && !$debug) {
362 arPostPayment($pid, $encounter,$InsertionId[$out['check_number']], $svc['paid'],//$InsertionId[$out['check_number']] gives the session id
363 $codekey, substr($inslabel,3), $out['check_number'], $debug,'',$codetype);
364 $invoice_total -= $svc['paid'];
366 $description = "$inslabel/" . $out['check_number'] . ' payment';
367 if ($svc['paid'] < 0) $description .= ' reversal';
368 writeDetailLine($bgcolor, $class, $patient_name, $invnumber,
369 $codekey, $check_date, $description,
370 0 - $svc['paid'], ($error ? '' : $invoice_total));
373 // Post and report adjustments from this ERA. Posted adjustment reasons
374 // must be 25 characters or less in order to fit on patient statements.
375 foreach ($svc['adj'] as $adj) {
376 $description = $adj['reason_code'] . ': ' . $adjustment_reasons[$adj['reason_code']];
377 if ($adj['group_code'] == 'PR' || !$primary) {
378 // Group code PR is Patient Responsibility. Enter these as zero
379 // adjustments to retain the note without crediting the claim.
380 if ($primary) {
381 /****
382 $reason = 'Pt resp: '; // Reasons should be 25 chars or less.
383 if ($adj['reason_code'] == '1') $reason = 'To deductible: ';
384 else if ($adj['reason_code'] == '2') $reason = 'Coinsurance: ';
385 else if ($adj['reason_code'] == '3') $reason = 'Co-pay: ';
386 ****/
387 $reason = "$inslabel ptresp: "; // Reasons should be 25 chars or less.
388 if ($adj['reason_code'] == '1') $reason = "$inslabel dedbl: ";
389 else if ($adj['reason_code'] == '2') $reason = "$inslabel coins: ";
390 else if ($adj['reason_code'] == '3') $reason = "$inslabel copay: ";
392 // Non-primary insurance adjustments are garbage, either repeating
393 // the primary or are not adjustments at all. Report them as notes
394 // but do not post any amounts.
395 else {
396 $reason = "$inslabel note " . $adj['reason_code'] . ': ';
397 /****
398 $reason .= sprintf("%.2f", $adj['amount']);
399 ****/
401 $reason .= sprintf("%.2f", $adj['amount']);
402 // Post a zero-dollar adjustment just to save it as a comment.
403 if (!$error && !$debug) {
404 arPostAdjustment($pid, $encounter, $InsertionId[$out['check_number']], 0, $codekey,//$InsertionId[$out['check_number']] gives the session id
405 substr($inslabel,3), $reason, $debug, '', $codetype);
407 writeMessageLine($bgcolor, $class, $description . ' ' .
408 sprintf("%.2f", $adj['amount']));
410 // Other group codes for primary insurance are real adjustments.
411 else {
412 if (!$error && !$debug) {
413 arPostAdjustment($pid, $encounter, $InsertionId[$out['check_number']], $adj['amount'],//$InsertionId[$out['check_number']] gives the session id
414 $codekey, substr($inslabel,3),
415 "Adjust code " . $adj['reason_code'], $debug, '', $codetype);
416 $invoice_total -= $adj['amount'];
418 writeDetailLine($bgcolor, $class, $patient_name, $invnumber,
419 $codekey, $production_date, $description,
420 0 - $adj['amount'], ($error ? '' : $invoice_total));
424 } // End of service item
426 // Report any existing service items not mentioned in the ERA, and
427 // determine if any of them are still missing an insurance response
428 // (if so, then insurance is not yet done with the claim).
429 $insurance_done = true;
430 foreach ($codes as $code => $prev) {
431 // writeOldDetail($prev, $arrow['name'], $invnumber, $service_date, $code, $bgcolor);
432 writeOldDetail($prev, $patient_name, $invnumber, $service_date, $code, $bgcolor);
433 $got_response = false;
434 foreach ($prev['dtl'] as $ddata) {
435 if ($ddata['pmt'] || $ddata['rsn']) $got_response = true;
437 if (!$got_response) $insurance_done = false;
440 // Cleanup: If all is well, mark Ins<x> done and check for secondary billing.
441 if (!$error && !$debug && $insurance_done) {
442 $level_done = 0 + substr($inslabel, 3);
444 if($out['crossover']==1)
445 {//Automatic forward case.So need not again bill from the billing manager screen.
446 sqlStatement("UPDATE form_encounter " .
447 "SET last_level_closed = $level_done,last_level_billed=".$level_done." WHERE " .
448 "pid = '$pid' AND encounter = '$encounter'");
449 writeMessageLine($bgcolor, 'infdetail',
450 'This claim is processed by Insurance '.$level_done.' and automatically forwarded to Insurance '.($level_done+1) .' for processing. ');
452 else {
453 sqlStatement("UPDATE form_encounter " .
454 "SET last_level_closed = $level_done WHERE " .
455 "pid = '$pid' AND encounter = '$encounter'");
457 // Check for secondary insurance.
458 if ($primary && arGetPayerID($pid, $service_date, 2)) {
459 arSetupSecondary($pid, $encounter, $debug,$out['crossover']);
461 if($out['crossover']<>1)
463 writeMessageLine($bgcolor, 'infdetail',
464 'This claim is now re-queued for secondary paper billing');
471 /////////////////////////// End Functions ////////////////////////////
473 $info_msg = "";
475 $eraname = $_GET['eraname'];
476 if (! $eraname) die(xl("You cannot access this page directly."));
478 // Open the output file early so that in case it fails, we do not post a
479 // bunch of stuff without saving the report. Also be sure to retain any old
480 // report files. Do not save the report if this is a no-update situation.
482 if (!$debug) {
483 $nameprefix = $GLOBALS['OE_SITE_DIR'] . "/era/$eraname";
484 $namesuffix = '';
485 for ($i = 1; is_file("$nameprefix$namesuffix.html"); ++$i) {
486 $namesuffix = "_$i";
488 $fnreport = "$nameprefix$namesuffix.html";
489 $fhreport = fopen($fnreport, 'w');
490 if (!$fhreport) die(xl("Cannot create") . " '$fnreport'");
494 <html>
495 <head>
496 <?php html_header_show();?>
497 <link rel=stylesheet href="<?php echo $css_header;?>" type="text/css">
498 <style type="text/css">
499 body { font-family:sans-serif; font-size:8pt; font-weight:normal }
500 .dehead { color:#000000; font-family:sans-serif; font-size:9pt; font-weight:bold }
501 .olddetail { color:#000000; font-family:sans-serif; font-size:9pt; font-weight:normal }
502 .newdetail { color:#00dd00; font-family:sans-serif; font-size:9pt; font-weight:normal }
503 .errdetail { color:#dd0000; font-family:sans-serif; font-size:9pt; font-weight:normal }
504 .infdetail { color:#0000ff; font-family:sans-serif; font-size:9pt; font-weight:normal }
505 </style>
506 <title><?php xl('EOB Posting - Electronic Remittances','e')?></title>
507 <script language="JavaScript">
508 </script>
509 </head>
510 <body leftmargin='0' topmargin='0' marginwidth='0' marginheight='0'>
511 <form action="sl_eob_process.php" method="get" >
512 <center>
513 <?php
514 if($_GET['original']=='original')
516 $alertmsg = parse_era_for_check($GLOBALS['OE_SITE_DIR'] . "/era/$eraname.edi", 'era_callback');
517 echo $StringToEcho;
519 else
522 <table border='0' cellpadding='2' cellspacing='0' width='100%'>
524 <tr bgcolor="#cccccc">
525 <td class="dehead">
526 <?php echo htmlspecialchars( xl('Patient'), ENT_QUOTES) ?>
527 </td>
528 <td class="dehead">
529 <?php echo htmlspecialchars( xl('Invoice'), ENT_QUOTES) ?>
530 </td>
531 <td class="dehead">
532 <?php echo htmlspecialchars( xl('Code'), ENT_QUOTES) ?>
533 </td>
534 <td class="dehead">
535 <?php echo htmlspecialchars( xl('Date'), ENT_QUOTES) ?>
536 </td>
537 <td class="dehead">
538 <?php echo htmlspecialchars( xl('Description'), ENT_QUOTES) ?>
539 </td>
540 <td class="dehead" align="right">
541 <?php echo htmlspecialchars( xl('Amount'), ENT_QUOTES) ?>&nbsp;
542 </td>
543 <td class="dehead" align="right">
544 <?php echo htmlspecialchars( xl('Balance'), ENT_QUOTES) ?>&nbsp;
545 </td>
546 </tr>
548 <?php
549 global $InsertionId;
551 $eraname=$_REQUEST['eraname'];
552 $alertmsg = parse_era_for_check($GLOBALS['OE_SITE_DIR'] . "/era/$eraname.edi");
553 $alertmsg = parse_era($GLOBALS['OE_SITE_DIR'] . "/era/$eraname.edi", 'era_callback');
554 if(!$debug)
556 $StringIssue=htmlspecialchars( xl("Total Distribution for following check number is not full"), ENT_QUOTES).': ';
557 $StringPrint='No';
558 foreach($InsertionId as $key => $value)
560 $rs= sqlQ("select pay_total from ar_session where session_id='$value'");
561 $row=sqlFetchArray($rs);
562 $pay_total=$row['pay_total'];
563 $rs= sqlQ("select sum(pay_amount) sum_pay_amount from ar_activity where session_id='$value'");
564 $row=sqlFetchArray($rs);
565 $pay_amount=$row['sum_pay_amount'];
567 if(($pay_total-$pay_amount)<>0)
569 $StringIssue.=$key.' ';
570 $StringPrint='Yes';
573 if($StringPrint=='Yes')
574 echo "<script>alert('$StringIssue')</script>";
579 </table>
580 <?php
583 </center>
584 <script language="JavaScript">
585 <?php
586 if ($alertmsg) echo " alert('" . htmlspecialchars($alertmsg, ENT_QUOTES) . "');\n";
588 </script>
589 <input type="hidden" name="paydate" value="<?php echo DateToYYYYMMDD($_REQUEST['paydate']);?>" />
590 <input type="hidden" name="post_to_date" value="<?php echo DateToYYYYMMDD($_REQUEST['post_to_date']);?>" />
591 <input type="hidden" name="deposit_date" value="<?php echo DateToYYYYMMDD($_REQUEST['deposit_date']);?>" />
592 <input type="hidden" name="debug" value="<?php echo $_REQUEST['debug'];?>" />
593 <input type="hidden" name="InsId" value="<?php echo $_REQUEST['InsId'];?>" />
594 <input type="hidden" name="eraname" value="<?php echo $eraname?>" />
595 </form>
596 </body>
597 </html>
598 <?php
599 // Save all of this script's output to a report file.
600 if (!$debug) {
601 fwrite($fhreport, ob_get_contents());
602 fclose($fhreport);
604 ob_end_flush();