2 // +-----------------------------------------------------------------------------+
3 // Copyright (C) 2010 Z&H Consultancy Services Private Limited <sam@zhservices.com>
6 // This program is free software; you can redistribute it and/or
7 // modify it under the terms of the GNU General Public License
8 // as published by the Free Software Foundation; either version 2
9 // of the License, or (at your option) any later version.
12 // This program is distributed in the hope that it will be useful,
13 // but WITHOUT ANY WARRANTY; without even the implied warranty of
14 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15 // GNU General Public License for more details.
18 // A copy of the GNU General Public License is included along with this program:
19 // openemr/interface/login/GnuGPL.html
20 // For more information write to the Free Software
21 // Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
23 // Author: Eldho Chacko <eldho@zhservices.com>
24 // Paul Simon K <paul@zhservices.com>
26 // +------------------------------------------------------------------------------+
27 //===============================================================================
28 //Payments in database can be searched through this screen and edit popup is also its part.
29 //Deletion of the payment is done with logging.
30 //===============================================================================
31 require_once("../globals.php");
32 require_once("$srcdir/log.inc");
33 require_once("../../library/acl.inc");
34 require_once("../../custom/code_types.inc.php");
35 require_once("$srcdir/patient.inc");
36 require_once("$srcdir/billrep.inc");
37 require_once(dirname(__FILE__
) . "/../../library/classes/OFX.class.php");
38 require_once(dirname(__FILE__
) . "/../../library/classes/X12Partner.class.php");
39 require_once("$srcdir/options.inc.php");
40 require_once("$srcdir/formatting.inc.php");
41 require_once("$srcdir/payment.inc.php");
42 //===============================================================================
43 //Deletion of payment and its corresponding distributions.
44 //===============================================================================
46 if (isset($_POST["mode"]))
48 if ($_POST["mode"] == "DeletePayments")
50 $DeletePaymentId=trim(formData('DeletePaymentId' ));
51 $ResultSearch = sqlStatement("SELECT distinct encounter,pid from ar_activity where session_id ='$DeletePaymentId'");
52 if(sqlNumRows($ResultSearch)>0)
54 while ($RowSearch = sqlFetchArray($ResultSearch))
56 $Encounter=$RowSearch['encounter'];
57 $PId=$RowSearch['pid'];
58 sqlStatement("update form_encounter set last_level_closed=last_level_closed - 1 where pid ='$PId' and encounter='$Encounter'" );
61 //delete and log that action
62 row_delete("ar_session", "session_id ='$DeletePaymentId'");
63 row_delete("ar_activity", "session_id ='$DeletePaymentId'");
66 $_POST["mode"] = "SearchPayment";
68 //===============================================================================
70 //===============================================================================
71 if ($_POST["mode"] == "SearchPayment")
73 $FromDate=trim(formData('FromDate' ));
74 $ToDate=trim(formData('ToDate' ));
75 $PaymentMethod=trim(formData('payment_method' ));
76 $CheckNumber=trim(formData('check_number' ));
77 $PaymentAmount=trim(formData('payment_amount' ));
78 $PayingEntity=trim(formData('type_name' ));
79 $PaymentCategory=trim(formData('adjustment_code' ));
80 $PaymentFrom=trim(formData('hidden_type_code' ));
81 $PaymentStatus=trim(formData('PaymentStatus' ));
82 $PaymentSortBy=trim(formData('PaymentSortBy' ));
83 $PaymentDate=trim(formData('payment_date' ));
84 $QueryString.="Select * from ar_session where ";
87 if($PaymentDate=='date_val')
89 $PaymentDateString=' check_date ';
91 elseif($PaymentDate=='post_to_date')
93 $PaymentDateString=' post_to_date ';
95 elseif($PaymentDate=='deposit_date')
97 $PaymentDateString=' deposit_date ';
102 $QueryString.=" $And $PaymentDateString >='".DateToYYYYMMDD($FromDate)."'";
107 $QueryString.=" $And $PaymentDateString <='".DateToYYYYMMDD($ToDate)."'";
110 if($PaymentMethod!='')
112 $QueryString.=" $And payment_method ='".$PaymentMethod."'";
117 $QueryString.=" $And reference like '%".$CheckNumber."%'";
120 if($PaymentAmount!='')
122 $QueryString.=" $And pay_total ='".$PaymentAmount."'";
125 if($PayingEntity!='')
127 if($PayingEntity=='insurance')
129 $QueryString.=" $And payer_id !='0'";
131 if($PayingEntity=='patient')
133 $QueryString.=" $And payer_id ='0'";
137 if($PaymentCategory!='')
139 $QueryString.=" $And adjustment_code ='".$PaymentCategory."'";
144 if($PayingEntity=='insurance' ||
$PayingEntity=='')
146 //-------------------
147 $res = sqlStatement("SELECT insurance_companies.name FROM insurance_companies
148 where insurance_companies.id ='$PaymentFrom'");
149 $row = sqlFetchArray($res);
150 $div_after_save=$row['name'];
151 //-------------------
153 $QueryString.=" $And payer_id ='".$PaymentFrom."'";
155 if($PayingEntity=='patient')
157 //-------------------
158 $res = sqlStatement("SELECT fname,lname,mname FROM patient_data
159 where pid ='$PaymentFrom'");
160 $row = sqlFetchArray($res);
161 $fname=$row['fname'];
162 $lname=$row['lname'];
163 $mname=$row['mname'];
164 $div_after_save=$lname.' '.$fname.' '.$mname;
165 //-------------------
167 $QueryString.=" $And patient_id ='".$PaymentFrom."'";
172 if($PaymentStatus!='')
174 $QsString="select ar_session.session_id,pay_total,global_amount,sum(pay_amount) sum_pay_amount from ar_session,ar_activity
175 where ar_session.session_id=ar_activity.session_id group by ar_activity.session_id,ar_session.session_id
176 having pay_total-global_amount-sum_pay_amount=0 or pay_total=0";
177 $rs= sqlStatement("$QsString");
178 while($rowrs=sqlFetchArray($rs))
180 $StringSessionId.=$rowrs['session_id'].',';
182 $QsString="select ar_session.session_id from ar_session where pay_total=0";
183 $rs= sqlStatement("$QsString");
184 while($rowrs=sqlFetchArray($rs))
186 $StringSessionId.=$rowrs['session_id'].',';
188 $StringSessionId=substr($StringSessionId, 0, -1);
189 if($PaymentStatus=='fully_paid')
191 $QueryString.=" $And session_id in($StringSessionId) ";
193 elseif($PaymentStatus=='unapplied')
195 $QueryString.=" $And session_id not in($StringSessionId) ";
199 if($PaymentSortBy!='')
201 $SortFieldOld=trim(formData('SortFieldOld' ));
202 $Sort=trim(formData('Sort' ));
203 if($SortFieldOld==$PaymentSortBy)
205 if($Sort=='DESC' ||
$Sort=='')
214 $QueryString.=" order by $PaymentSortBy $Sort";
216 $ResultSearch = sqlStatement($QueryString);
219 //===============================================================================
220 $DateFormat=DateFormatRead();
224 <?php
if (function_exists('html_header_show')) html_header_show(); ?
>
226 <link rel
="stylesheet" href
="<?php echo $css_header;?>" type
="text/css">
228 <script type
="text/javascript" src
="<?php echo $GLOBALS['webroot'] ?>/library/dialog.js"></script
>
229 <link rel
="stylesheet" href
="<?php echo $css_header;?>" type
="text/css">
230 <link rel
="stylesheet" type
="text/css" href
="../../library/js/fancybox/jquery.fancybox-1.2.6.css" media
="screen" />
231 <style type
="text/css">@import
url(../../library
/dynarch_calendar
.css
);</style
>
233 <script type
="text/javascript" src
="../../library/textformat.js"></script
>
234 <script type
="text/javascript" src
="../../library/dynarch_calendar.js"></script
>
235 <?php
include_once("{$GLOBALS['srcdir']}/dynarch_calendar_en.inc.php"); ?
>
236 <script type
="text/javascript" src
="../../library/dynarch_calendar_setup.js"></script
>
237 <script type
="text/javascript" src
="../../library/dialog.js"></script
>
239 <?php
include_once("{$GLOBALS['srcdir']}/payment_jav.inc.php"); ?
>
240 <script type
="text/javascript" src
="../../library/js/jquery.1.3.2.js"></script
>
241 <?php
include_once("{$GLOBALS['srcdir']}/ajax/payment_ajax_jav.inc.php"); ?
>
242 <script type
="text/javascript" src
="../../library/js/common.js"></script
>
243 <script type
="text/javascript" src
="../../library/js/fancybox/jquery.fancybox-1.2.6.js"></script
>
245 <script type
='text/javascript'>
246 //For different browsers there was disparity in width.So this code is used to adjust the width.
247 if (/MSIE (\d+\
.\d+
);/.test(navigator
.userAgent
)){ //test for MSIE x.x;
248 var ieversion
=new Number(RegExp
.$1) // capture x.x portion and store as a number
249 if (ieversion
>=5 && ieversion
<=8)
251 $
(document
).ready(function() {
254 $
(".medium_modal").fancybox( {
255 'overlayOpacity' : 0.0,
256 'showCloseButton' : true,
259 'centerOnScroll' : false
265 $
(document
).ready(function() {
268 $
(".medium_modal").fancybox( {
269 'overlayOpacity' : 0.0,
270 'showCloseButton' : true,
273 'centerOnScroll' : false
280 $
(document
).ready(function() {
283 $
(".medium_modal").fancybox( {
284 'overlayOpacity' : 0.0,
285 'showCloseButton' : true,
288 'centerOnScroll' : false
293 <script language
='JavaScript'>
296 <script language
='JavaScript'>
297 function SearchPayment()
298 {//Search validations.
299 if(document
.getElementById('FromDate').value
=='' && document
.getElementById('ToDate').value
=='' && document
.getElementById('PaymentStatus').selectedIndex
==0 && document
.getElementById('payment_method').selectedIndex
==0 && document
.getElementById('type_name').selectedIndex
==0 && document
.getElementById('adjustment_code').selectedIndex
==0 && document
.getElementById('check_number').value
=='' && document
.getElementById('payment_amount').value
=='' && document
.getElementById('hidden_type_code').value
=='' )
301 alert("<?php echo htmlspecialchars( xl('Please select any Search Option.'), ENT_QUOTES) ?>");
304 if(document
.getElementById('FromDate').value
!='' && document
.getElementById('ToDate').value
!='')
306 if(!DateCheckGreater(document
.getElementById('FromDate').value
,document
.getElementById('ToDate').value
,'<?php echo DateFormatRead();?>'))
308 alert("<?php echo htmlspecialchars( xl('From Date Cannot be Greater than To Date.'), ENT_QUOTES) ?>");
309 document
.getElementById('FromDate').focus();
313 top
.restoreSession();
314 document
.getElementById('mode').value
='SearchPayment';
315 document
.forms
[0].submit();
317 function DeletePayments(DeleteId
)
318 {//Confirms deletion of payment and all its distribution.
319 if(confirm("<?php echo htmlspecialchars( xl('Would you like to Delete Payments?'), ENT_QUOTES) ?>"))
321 document
.getElementById('mode').value
='DeletePayments';
322 document
.getElementById('DeletePaymentId').value
=DeleteId
;
323 top
.restoreSession();
324 document
.forms
[0].submit();
329 function OnloadAction()
330 {//Displays message after deletion.
331 after_value
=document
.getElementById('after_value').value
;
332 if(after_value
=='Delete')
334 alert("<?php echo htmlspecialchars( xl('Successfully Deleted'), ENT_QUOTES) ?>")
337 function SearchPayingEntityAction()
339 //Which ajax is to be active(patient,insurance), is decided by the 'Paying Entity' drop down, where this function is called.
340 //So on changing some initialization is need.Done below.
341 document
.getElementById('type_code').value
='';
342 document
.getElementById('hidden_ajax_close_value').value
='';
343 document
.getElementById('hidden_type_code').value
='';
344 document
.getElementById('div_insurance_or_patient').innerHTML
=' ';
345 document
.getElementById('description').value
='';
346 if(document
.getElementById('ajax_div_insurance'))
348 $
("#ajax_div_patient_error").empty();
349 $
("#ajax_div_patient").empty();
350 $
("#ajax_div_insurance_error").empty();
351 $
("#ajax_div_insurance").empty();
352 $
("#ajax_div_insurance").hide();
353 document
.getElementById('payment_method').style
.display
='';
357 <script language
="javascript" type
="text/javascript">
358 document
.onclick
=HideTheAjaxDivs
;
361 .class1
{width
:125px
;}
362 .class2
{width
:250px
;}
363 .class3
{width
:100px
;}
364 .class4
{width
:103px
;}
365 #ajax_div_insurance {
368 background
-color
: #FBFDD0;
369 border
: 1px solid
#ccc;
375 background
-color
: #FBFDD0;
376 border
: 1px solid
#ccc;
379 .bottom
{border
-bottom
:1px solid black
;}
380 .top
{border
-top
:1px solid black
;}
381 .left
{border
-left
:1px solid black
;}
382 .right
{border
-right
:1px solid black
;}
385 <body
class="body_top" onLoad
="OnloadAction()">
386 <form name
='new_payment' method
='post' style
="display:inline" >
387 <table width
="560" border
="0" cellspacing
="0" cellpadding
="0">
389 <td colspan
="3" align
="left"><b
><?php
echo htmlspecialchars( xl('Payments'), ENT_QUOTES
) ?
></b
></td
>
392 <td colspan
="3" align
="left" ></td
>
395 <td colspan
="3" align
="left">
397 <li
><a href
='new_payment.php'><?php
echo htmlspecialchars( xl('New Payment'), ENT_QUOTES
) ?
></a
></li
>
398 <li
class='current'><a href
='search_payments.php'><?php
echo htmlspecialchars( xl('Search Payment'), ENT_QUOTES
) ?
></a
></li
>
399 <li
><a href
='era_payments.php'><?php
echo htmlspecialchars( xl('ERA Posting'), ENT_QUOTES
) ?
></a
></li
>
403 <td colspan
="3" align
="left" >
404 <table width
="974" border
="0" cellspacing
="0" cellpadding
="10" bgcolor
="#DEDEDE"><tr
><td
>
405 <table width
="954" border
="0" style
="border:1px solid black" cellspacing
="0" cellpadding
="0">
407 <td width
="954" colspan
="6" align
="left" ></td
>
410 <td colspan
="6" align
="left"> 
;<font
class='title'><?php
echo htmlspecialchars( xl('Payment List'), ENT_QUOTES
) ?
></font
></td
>
413 <td colspan
="6" align
="left" ></td
>
416 <td colspan
="6" align
="left" ><table width
="954" border
="0" cellspacing
="0" cellpadding
="0">
419 <td width
="106"></td
>
420 <td width
="128"></td
>
423 <td width
="128"></td
>
425 <td width
="113"></td
>
426 <td width
="125"></td
>
429 <td width
="162"></td
>
432 <td align
="right"></td
>
433 <td align
="left" class="text"><?php
echo generate_select_list("payment_date", "payment_date", "$PaymentDate", "Payment Date","","class4 text");?
></td
>
435 <table border
="0" cellspacing
="0" cellpadding
="0">
437 <td align
="left" class="text"><?php
echo htmlspecialchars( xl('From'), ENT_QUOTES
).':' ?
></td
>
438 <td
><input type
='text' style
="width:90px;" name
='FromDate' id
='FromDate' class="text" value
='<?php echo htmlspecialchars($FromDate); ?>' />
439 <img src
='../../interface/main/calendar/modules/PostCalendar/pntemplates/default/images/new.jpg' align
="texttop"
440 id
='img_FromDate' border
='0' alt
='[?]' style
='cursor:pointer'
441 title
='<?php echo htmlspecialchars( xl('Click here to choose a date
'), ENT_QUOTES); ?>' />
443 Calendar
.setup({inputField
:"FromDate", ifFormat
:"<?php echo $DateFormat; ?>", button
:"img_FromDate"});
445 <td width
="53"> 
;</td
>
446 <td align
="left" class="text"><?php
echo htmlspecialchars( xl('To'), ENT_QUOTES
).':' ?
></td
>
447 <td
><input type
='text' style
="width:103px;" name
='ToDate' id
='ToDate' class="text" value
='<?php echo htmlspecialchars($ToDate); ?>' />
448 <img src
='../../interface/main/calendar/modules/PostCalendar/pntemplates/default/images/new.jpg' align
="texttop"
449 id
='img_ToDate' border
='0' alt
='[?]' style
='cursor:pointer'
450 title
='<?php echo htmlspecialchars( xl('Click here to choose a date
'), ENT_QUOTES); ?>' />
452 Calendar
.setup({inputField
:"ToDate", ifFormat
:"<?php echo $DateFormat; ?>", button
:"img_ToDate"});
457 <td
class="text"></td
>
458 <td align
="left" class="text"><?php
echo htmlspecialchars( xl('Payment Method'), ENT_QUOTES
).':' ?
></td
>
459 <td align
="left"><?php
echo generate_select_list("payment_method", "payment_method", "$PaymentMethod", "Payment Method"," ","class1 text");?
></td
>
461 <td align
="left" class="text"><?php
echo htmlspecialchars( xl('Check Number'), ENT_QUOTES
).':' ?
></td
>
462 <td
><input type
="text" name
="check_number" autocomplete
="off" value
="<?php echo htmlspecialchars(formData('check_number'));?>" id
="check_number" class=" class1 text " /></td
>
465 <td align
="right"></td
>
466 <td align
="left" class="text"><?php
echo htmlspecialchars( xl('Payment Amount'), ENT_QUOTES
).':' ?
></td
>
467 <td align
="left"><input type
="text" name
="payment_amount" autocomplete
="off" id
="payment_amount" onKeyUp
="ValidateNumeric(this);" value
="<?php echo htmlspecialchars(formData('payment_amount'));?>" style
="text-align:right" class="class1 text " /></td
>
468 <td align
="left" ></td
>
469 <td align
="left" class="text"><?php
echo htmlspecialchars( xl('Paying Entity'), ENT_QUOTES
).':' ?
></td
>
470 <td align
="left"><?php
echo generate_select_list("type_name", "payment_type", "$type_name","Paying Entity"," ","class1 text","SearchPayingEntityAction()");?
> </td
>
471 <td align
="left" ></td
>
472 <td align
="left" class="text"><?php
echo htmlspecialchars( xl('Payment Category'), ENT_QUOTES
).':' ?
></td
>
473 <td align
="left"><?php
echo generate_select_list("adjustment_code", "payment_adjustment_code", "$adjustment_code","Paying Category"," ","class1 text");?
> </td
>
475 <td align
="left" class=" text " ><?php
echo htmlspecialchars( xl('Pay Status'), ENT_QUOTES
).':' ?
></td
>
476 <td align
="left" ><?php
echo generate_select_list("PaymentStatus", "payment_status", "$PaymentStatus","Pay Status"," ","class1 text");?
></td
>
479 <td align
="right"></td
>
480 <td align
="left" class="text"><?php
echo htmlspecialchars( xl('Payment From'), ENT_QUOTES
).':' ?
></td
>
481 <td align
="left" colspan
="5" >
483 <table width
="335" border
="0" cellspacing
="0" cellpadding
="0">
486 <input type
="hidden" id
="hidden_ajax_close_value" value
="<?php echo htmlspecialchars($div_after_save);?>" /><input name
='type_code' id
='type_code' class="text "
487 style
=" width:280px;" onKeyDown
="PreventIt(event)" value
="<?php echo htmlspecialchars($div_after_save);?>" autocomplete
="off" /><br
>
488 <!--onKeyUp
="ajaxFunction(event,'non','search_payments.php');"-->
489 <div id
='ajax_div_insurance_section'>
490 <div id
='ajax_div_insurance_error'> </div
>
491 <div id
="ajax_div_insurance" style
="display:none;"></div
>
494 <td width
="50" style
="padding-left:5px;"><div name
="div_insurance_or_patient" id
="div_insurance_or_patient" class="text" style
="border:1px solid black; padding-left:5px; width:50px; height:17px;"><?php
echo htmlspecialchars(formData('hidden_type_code'));?
></div
><input type
="hidden" name
="description" id
="description" /><input type
="text" name
="deposit_date" id
="deposit_date" style
="display:none"/></td
>
497 <td align
="left" class="text"><?php
echo htmlspecialchars( xl('Sort Result by'), ENT_QUOTES
).':' ?
></td
>
498 <td align
="left" class="text"><?php
echo generate_select_list("PaymentSortBy", "payment_sort_by", "$PaymentSortBy","Sort Result by"," ","class1 text");?
> </td
>
499 <td align
="left" class="text"></td
>
500 <td align
="left" class="text"><table border
="0" cellspacing
="0" cellpadding
="0">
502 <td
><a href
="#" class="css_button" onClick
="javascript:return SearchPayment();" ><span
><?php
echo htmlspecialchars( xl('Search'), ENT_QUOTES
);?
></span
></a
></td
>
505 <td align
="left"></td
>
508 <td colspan
="12" align
="left" ></td
>
517 if ($_POST["mode"] == "SearchPayment")
522 <table border
="0" cellspacing
="0" cellpadding
="0">
524 if(sqlNumRows($ResultSearch)>0)
527 <tr
class="text" bgcolor
="#dddddd">
528 <td width
="25" class="left top" > 
;</td
>
529 <td width
="60" class="left top" ><?php
echo htmlspecialchars( xl('ID'), ENT_QUOTES
) ?
></td
>
530 <td width
="70" class="left top" ><?php
echo htmlspecialchars( xl('Date'), ENT_QUOTES
) ?
></td
>
531 <td width
="83" class="left top" ><?php
echo htmlspecialchars( xl('Paying Entity'), ENT_QUOTES
) ?
></td
>
532 <td width
="245" class="left top" ><?php
echo htmlspecialchars( xl('Payer'), ENT_QUOTES
) ?
></td
>
533 <td width
="57" class="left top" ><?php
echo htmlspecialchars( xl('Ins Code'), ENT_QUOTES
) ?
></td
>
534 <td width
="110" class="left top" ><?php
echo htmlspecialchars( xl('Payment Method'), ENT_QUOTES
) ?
></td
>
535 <td width
="130" class="left top" ><?php
echo htmlspecialchars( xl('Check Number'), ENT_QUOTES
) ?
></td
>
536 <td width
="70" class="left top" ><?php
echo htmlspecialchars( xl('Pay Status'), ENT_QUOTES
) ?
></td
>
537 <td width
="50" class="left top" ><?php
echo htmlspecialchars( xl('Payment'), ENT_QUOTES
) ?
></td
>
538 <td width
="70" class="left top right" ><?php
echo htmlspecialchars( xl('Undistributed'), ENT_QUOTES
) ?
></td
>
542 while ($RowSearch = sqlFetchArray($ResultSearch))
545 if($RowSearch['payer_id']*1 > 0)
547 //-------------------
548 $res = sqlStatement("SELECT insurance_companies.name FROM insurance_companies
549 where insurance_companies.id ='{$RowSearch['payer_id']}'");
550 $row = sqlFetchArray($res);
552 //-------------------
554 elseif($RowSearch['patient_id']*1 > 0)
556 //-------------------
557 $res = sqlStatement("SELECT fname,lname,mname FROM patient_data
558 where pid ='{$RowSearch['patient_id']}'");
559 $row = sqlFetchArray($res);
560 $fname=$row['fname'];
561 $lname=$row['lname'];
562 $mname=$row['mname'];
563 $Payer=$lname.' '.$fname.' '.$mname;
564 //-------------------
566 //=============================================
568 if($CountIndex==sqlNumRows($ResultSearch))
570 $StringClass=' bottom left top ';
574 $StringClass=' left top ';
585 <tr
class="text" bgcolor
='<?php echo $bgcolor; ?>'>
586 <td
class="<?php echo $StringClass; ?>" ><a href
="#" onClick
="javascript:return DeletePayments(<?php echo htmlspecialchars($RowSearch['session_id']); ?>);" ><img src
="../pic/Delete.gif" border
="0"/></a
></td
>
587 <td
class="<?php echo $StringClass; ?>" ><a href
="edit_payment.php?payment_id=<?php echo htmlspecialchars($RowSearch['session_id']); ?>" class='iframe medium_modal' ><?php
echo htmlspecialchars($RowSearch['session_id']); ?
></a
></td
>
588 <td
class="<?php echo $StringClass; ?>" ><a href
="edit_payment.php?payment_id=<?php echo htmlspecialchars($RowSearch['session_id']); ?>" class='iframe medium_modal' ><?php
echo $RowSearch['check_date']=='0000-00-00' ?
' ' : htmlspecialchars(oeFormatShortDate($RowSearch['check_date'])); ?
></a
></td
>
589 <td
class="<?php echo $StringClass; ?>" ><a href
="edit_payment.php?payment_id=<?php echo htmlspecialchars($RowSearch['session_id']); ?>" class='iframe medium_modal' ><?php
590 $frow['data_type']=1;
591 $frow['list_id']='payment_type';
593 if($RowSearch['payment_type']=='insurance' ||
$RowSearch['payer_id']*1 > 0)
595 $PaymentType='insurance';
597 elseif($RowSearch['payment_type']=='patient' ||
$RowSearch['patient_id']*1 > 0)
599 $PaymentType='patient';
601 elseif(($RowSearch['payer_id']*1 == 0 && $RowSearch['patient_id']*1 == 0))
606 generate_print_field($frow, $PaymentType);
608 <td
class="<?php echo $StringClass; ?>" ><a href
="edit_payment.php?payment_id=<?php echo htmlspecialchars($RowSearch['session_id']); ?>" class='iframe medium_modal' ><?php
echo $Payer=='' ?
' ' : htmlspecialchars($Payer) ;?
></a
></td
>
609 <td
class="<?php echo $StringClass; ?>" ><a href
="edit_payment.php?payment_id=<?php echo htmlspecialchars($RowSearch['session_id']); ?>" class='iframe medium_modal' ><?php
echo $RowSearch['payer_id']*1 > 0 ?
htmlspecialchars($RowSearch['payer_id']) : ' '; ?
></a
></td
>
610 <td align
="left" class="<?php echo $StringClass; ?> " ><a href
="edit_payment.php?payment_id=<?php echo htmlspecialchars($RowSearch['session_id']); ?>" class='iframe medium_modal' ><?php
611 $frow['data_type']=1;
612 $frow['list_id']='payment_method';
613 generate_print_field($frow, $RowSearch['payment_method']);
615 <td align
="left" class="<?php echo $StringClass; ?> " ><a href
="edit_payment.php?payment_id=<?php echo htmlspecialchars($RowSearch['session_id']); ?>" class='iframe medium_modal' ><?php
echo $RowSearch['reference']=='' ?
' ' : htmlspecialchars($RowSearch['reference']); ?
></a
></td
>
616 <td align
="left" class="<?php echo $StringClass; ?> " ><a href
="edit_payment.php?payment_id=<?php echo htmlspecialchars($RowSearch['session_id']); ?>" class='iframe medium_modal' ><?php
617 $rs= sqlStatement("select pay_total,global_amount from ar_session where session_id='".$RowSearch['session_id']."'");
618 $row=sqlFetchArray($rs);
619 $pay_total=$row['pay_total'];
620 $global_amount=$row['global_amount'];
621 $rs= sqlStatement("select sum(pay_amount) sum_pay_amount from ar_activity where session_id='".$RowSearch['session_id']."'");
622 $row=sqlFetchArray($rs);
623 $pay_amount=$row['sum_pay_amount'];
624 $UndistributedAmount=$pay_total-$pay_amount-$global_amount;
625 echo $UndistributedAmount*1==0 ?
htmlspecialchars( xl('Fully Paid'), ENT_QUOTES
) : htmlspecialchars( xl('Unapplied'), ENT_QUOTES
); ?
></a
></td
>
626 <td align
="right" class="<?php echo $StringClass; ?>" ><a href
="edit_payment.php?payment_id=<?php echo htmlspecialchars($RowSearch['session_id']); ?>" class='iframe medium_modal' ><?php
echo htmlspecialchars($RowSearch['pay_total']); ?
></a
></td
>
627 <td align
="right" class="<?php echo $StringClass; ?> right" ><a href
="edit_payment.php?payment_id=<?php echo htmlspecialchars($RowSearch['session_id']); ?>" class='iframe medium_modal' ><?php
echo htmlspecialchars(number_format($UndistributedAmount,2)); ?
></a
></td
>
630 }//while ($RowSearch = sqlFetchArray($ResultSearch))
631 }//if(sqlNumRows($ResultSearch)>0)
636 <td colspan
="11" class="text"><?php
echo htmlspecialchars( xl('No Result Found, for the above search criteria.'), ENT_QUOTES
) ?
></td
>
645 }//if ($_POST["mode"] == "SearchPayment")
651 <input type
='hidden' name
='mode' id
='mode' value
='' />
652 <input type
='hidden' name
='ajax_mode' id
='ajax_mode' value
='' />
653 <input type
="hidden" name
="hidden_type_code" id
="hidden_type_code" value
="<?php echo htmlspecialchars(formData('hidden_type_code'));?>"/>
654 <input type
='hidden' name
='DeletePaymentId' id
='DeletePaymentId' value
='' />
655 <input type
='hidden' name
='SortFieldOld' id
='SortFieldOld' value
='<?php echo htmlspecialchars($PaymentSortBy);?>' />
656 <input type
='hidden' name
='Sort' id
='Sort' value
='<?php echo htmlspecialchars($Sort);?>' />
657 <input type
="hidden" name
="after_value" id
="after_value" value
="<?php echo htmlspecialchars($Message);?>"/>