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("$srcdir/options.inc.php");
38 require_once("$srcdir/payment.inc.php");
39 //===============================================================================
40 //Deletion of payment and its corresponding distributions.
41 //===============================================================================
43 if (isset($_POST["mode"])) {
44 if ($_POST["mode"] == "DeletePayments") {
45 $DeletePaymentId=trim(formData('DeletePaymentId'));
46 $ResultSearch = sqlStatement("SELECT distinct encounter,pid from ar_activity where session_id ='$DeletePaymentId'");
47 if (sqlNumRows($ResultSearch)>0) {
48 while ($RowSearch = sqlFetchArray($ResultSearch)) {
49 $Encounter=$RowSearch['encounter'];
50 $PId=$RowSearch['pid'];
51 sqlStatement("update form_encounter set last_level_closed=last_level_closed - 1 where pid ='$PId' and encounter='$Encounter'");
55 //delete and log that action
56 row_delete("ar_session", "session_id ='$DeletePaymentId'");
57 row_delete("ar_activity", "session_id ='$DeletePaymentId'");
60 $_POST["mode"] = "SearchPayment";
63 //===============================================================================
65 //===============================================================================
66 if ($_POST["mode"] == "SearchPayment") {
67 $FromDate=trim(formData('FromDate'));
68 $ToDate=trim(formData('ToDate'));
69 $PaymentMethod=trim(formData('payment_method'));
70 $CheckNumber=trim(formData('check_number'));
71 $PaymentAmount=trim(formData('payment_amount'));
72 $PayingEntity=trim(formData('type_name'));
73 $PaymentCategory=trim(formData('adjustment_code'));
74 $PaymentFrom=trim(formData('hidden_type_code'));
75 $PaymentStatus=trim(formData('PaymentStatus'));
76 $PaymentSortBy=trim(formData('PaymentSortBy'));
77 $PaymentDate=trim(formData('payment_date'));
78 $QueryString.="Select * from ar_session where ";
81 if ($PaymentDate=='date_val') {
82 $PaymentDateString=' check_date ';
83 } elseif ($PaymentDate=='post_to_date') {
84 $PaymentDateString=' post_to_date ';
85 } elseif ($PaymentDate=='deposit_date') {
86 $PaymentDateString=' deposit_date ';
90 $QueryString.=" $And $PaymentDateString >='".DateToYYYYMMDD($FromDate)."'";
95 $QueryString.=" $And $PaymentDateString <='".DateToYYYYMMDD($ToDate)."'";
99 if ($PaymentMethod!='') {
100 $QueryString.=" $And payment_method ='".$PaymentMethod."'";
104 if ($CheckNumber!='') {
105 $QueryString.=" $And reference like '%".$CheckNumber."%'";
109 if ($PaymentAmount!='') {
110 $QueryString.=" $And pay_total ='".$PaymentAmount."'";
114 if ($PayingEntity!='') {
115 if ($PayingEntity=='insurance') {
116 $QueryString.=" $And payer_id !='0'";
119 if ($PayingEntity=='patient') {
120 $QueryString.=" $And payer_id ='0'";
126 if ($PaymentCategory!='') {
127 $QueryString.=" $And adjustment_code ='".$PaymentCategory."'";
131 if ($PaymentFrom!='') {
132 if ($PayingEntity=='insurance' ||
$PayingEntity=='') {
133 //-------------------
134 $res = sqlStatement("SELECT insurance_companies.name FROM insurance_companies
135 where insurance_companies.id ='$PaymentFrom'");
136 $row = sqlFetchArray($res);
137 $div_after_save=$row['name'];
138 //-------------------
140 $QueryString.=" $And payer_id ='".$PaymentFrom."'";
143 if ($PayingEntity=='patient') {
144 //-------------------
145 $res = sqlStatement("SELECT fname,lname,mname FROM patient_data
146 where pid ='$PaymentFrom'");
147 $row = sqlFetchArray($res);
148 $fname=$row['fname'];
149 $lname=$row['lname'];
150 $mname=$row['mname'];
151 $div_after_save=$lname.' '.$fname.' '.$mname;
152 //-------------------
154 $QueryString.=" $And patient_id ='".$PaymentFrom."'";
160 if ($PaymentStatus!='') {
161 $QsString="select ar_session.session_id,pay_total,global_amount,sum(pay_amount) sum_pay_amount from ar_session,ar_activity
162 where ar_session.session_id=ar_activity.session_id group by ar_activity.session_id,ar_session.session_id
163 having pay_total-global_amount-sum_pay_amount=0 or pay_total=0";
164 $rs= sqlStatement("$QsString");
165 while ($rowrs=sqlFetchArray($rs)) {
166 $StringSessionId.=$rowrs['session_id'].',';
169 $QsString="select ar_session.session_id from ar_session where pay_total=0";
170 $rs= sqlStatement("$QsString");
171 while ($rowrs=sqlFetchArray($rs)) {
172 $StringSessionId.=$rowrs['session_id'].',';
175 $StringSessionId=substr($StringSessionId, 0, -1);
176 if ($PaymentStatus=='fully_paid') {
177 $QueryString.=" $And session_id in($StringSessionId) ";
178 } elseif ($PaymentStatus=='unapplied') {
179 $QueryString.=" $And session_id not in($StringSessionId) ";
185 if ($PaymentSortBy!='') {
186 $SortFieldOld=trim(formData('SortFieldOld'));
187 $Sort=trim(formData('Sort'));
188 if ($SortFieldOld==$PaymentSortBy) {
189 if ($Sort=='DESC' ||
$Sort=='') {
198 $QueryString.=" order by $PaymentSortBy $Sort";
201 $ResultSearch = sqlStatement($QueryString);
205 //===============================================================================
209 <?php
if (function_exists('html_header_show')) {
213 <link rel
="stylesheet" href
="<?php echo $css_header;?>" type
="text/css">
214 <link rel
="stylesheet" type
="text/css" href
="../../library/js/fancybox/jquery.fancybox-1.2.6.css" media
="screen" />
215 <link rel
="stylesheet" href
="<?php echo $GLOBALS['assets_static_relative']; ?>/jquery-datetimepicker-2-5-4/build/jquery.datetimepicker.min.css">
217 <script type
="text/javascript" src
="../../library/textformat.js?v=<?php echo $v_js_includes; ?>"></script
>
218 <script type
="text/javascript" src
="../../library/dialog.js?v=<?php echo $v_js_includes; ?>"></script
>
219 <?php
include_once("{$GLOBALS['srcdir']}/payment_jav.inc.php"); ?
>
220 <script type
="text/javascript" src
="<?php echo $GLOBALS['assets_static_relative']; ?>/jquery-min-1-7-2/index.js"></script
>
221 <?php
include_once("{$GLOBALS['srcdir']}/ajax/payment_ajax_jav.inc.php"); ?
>
222 <script type
="text/javascript" src
="../../library/js/common.js?v=<?php echo $v_js_includes; ?>"></script
>
223 <script type
="text/javascript" src
="../../library/js/fancybox/jquery.fancybox-1.2.6.js"></script
>
224 <script type
="text/javascript" src
="<?php echo $GLOBALS['assets_static_relative']; ?>/jquery-datetimepicker-2-5-4/build/jquery.datetimepicker.full.min.js"></script
>
226 <script type
='text/javascript'>
227 //For different browsers there was disparity in width.So this code is used to adjust the width.
228 if (/MSIE (\d+\
.\d+
);/.test(navigator
.userAgent
)){ //test for MSIE x.x;
229 var ieversion
=new Number(RegExp
.$1) // capture x.x portion and store as a number
230 if (ieversion
>=5 && ieversion
<=8)
232 $
(document
).ready(function() {
235 $
(".medium_modal").fancybox( {
236 'overlayOpacity' : 0.0,
237 'showCloseButton' : true,
240 'centerOnScroll' : false
246 $
(document
).ready(function() {
249 $
(".medium_modal").fancybox( {
250 'overlayOpacity' : 0.0,
251 'showCloseButton' : true,
254 'centerOnScroll' : false
261 $
(document
).ready(function() {
264 $
(".medium_modal").fancybox( {
265 'overlayOpacity' : 0.0,
266 'showCloseButton' : true,
269 'centerOnScroll' : false
274 $
(document
).ready(function() {
275 $
('.datepicker').datetimepicker({
276 <?php
$datetimepicker_timepicker = false; ?
>
277 <?php
$datetimepicker_showseconds = false; ?
>
278 <?php
$datetimepicker_formatInput = true; ?
>
279 <?php
require($GLOBALS['srcdir'] . '/js/xl/jquery-datetimepicker-2-5-4.js.php'); ?
>
280 <?php
// can add any additional javascript settings to datetimepicker here; need to prepend first setting with a comma ?>
285 <script language
='JavaScript'>
288 <script language
='JavaScript'>
289 function SearchPayment()
290 {//Search validations.
291 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
=='' )
293 alert("<?php echo htmlspecialchars(xl('Please select any Search Option.'), ENT_QUOTES) ?>");
296 if(document
.getElementById('FromDate').value
!='' && document
.getElementById('ToDate').value
!='')
298 if(!DateCheckGreater(document
.getElementById('FromDate').value
,document
.getElementById('ToDate').value
,'<?php echo DateFormatRead();?>'))
300 alert("<?php echo htmlspecialchars(xl('From Date Cannot be Greater than To Date.'), ENT_QUOTES) ?>");
301 document
.getElementById('FromDate').focus();
305 top
.restoreSession();
306 document
.getElementById('mode').value
='SearchPayment';
307 document
.forms
[0].submit();
309 function DeletePayments(DeleteId
)
310 {//Confirms deletion of payment and all its distribution.
311 if(confirm("<?php echo htmlspecialchars(xl('Would you like to Delete Payments?'), ENT_QUOTES) ?>"))
313 document
.getElementById('mode').value
='DeletePayments';
314 document
.getElementById('DeletePaymentId').value
=DeleteId
;
315 top
.restoreSession();
316 document
.forms
[0].submit();
321 function OnloadAction()
322 {//Displays message after deletion.
323 after_value
=document
.getElementById('after_value').value
;
324 if(after_value
=='Delete')
326 alert("<?php echo htmlspecialchars(xl('Successfully Deleted'), ENT_QUOTES) ?>")
329 function SearchPayingEntityAction()
331 //Which ajax is to be active(patient,insurance), is decided by the 'Paying Entity' drop down, where this function is called.
332 //So on changing some initialization is need.Done below.
333 document
.getElementById('type_code').value
='';
334 document
.getElementById('hidden_ajax_close_value').value
='';
335 document
.getElementById('hidden_type_code').value
='';
336 document
.getElementById('div_insurance_or_patient').innerHTML
=' ';
337 document
.getElementById('description').value
='';
338 if(document
.getElementById('ajax_div_insurance'))
340 $
("#ajax_div_patient_error").empty();
341 $
("#ajax_div_patient").empty();
342 $
("#ajax_div_insurance_error").empty();
343 $
("#ajax_div_insurance").empty();
344 $
("#ajax_div_insurance").hide();
345 document
.getElementById('payment_method').style
.display
='';
349 <script language
="javascript" type
="text/javascript">
350 document
.onclick
=HideTheAjaxDivs
;
353 .class1
{width
:125px
;}
354 .class2
{width
:250px
;}
355 .class3
{width
:100px
;}
356 .class4
{width
:103px
;}
357 #ajax_div_insurance {
360 background
-color
: #FBFDD0;
361 border
: 1px solid
#ccc;
367 background
-color
: #FBFDD0;
368 border
: 1px solid
#ccc;
371 .bottom
{border
-bottom
:1px solid black
;}
372 .top
{border
-top
:1px solid black
;}
373 .left
{border
-left
:1px solid black
;}
374 .right
{border
-right
:1px solid black
;}
377 <body
class="body_top" onLoad
="OnloadAction()">
378 <form name
='new_payment' method
='post' style
="display:inline" >
379 <table width
="560" border
="0" cellspacing
="0" cellpadding
="0">
381 <td colspan
="3" align
="left"><b
><?php
echo htmlspecialchars(xl('Payments'), ENT_QUOTES
) ?
></b
></td
>
384 <td colspan
="3" align
="left" ></td
>
387 <td colspan
="3" align
="left">
389 <li
><a href
='new_payment.php'><?php
echo htmlspecialchars(xl('New Payment'), ENT_QUOTES
) ?
></a
></li
>
390 <li
class='current'><a href
='search_payments.php'><?php
echo htmlspecialchars(xl('Search Payment'), ENT_QUOTES
) ?
></a
></li
>
391 <li
><a href
='era_payments.php'><?php
echo htmlspecialchars(xl('ERA Posting'), ENT_QUOTES
) ?
></a
></li
>
395 <td colspan
="3" align
="left" >
396 <table width
="974" border
="0" cellspacing
="0" cellpadding
="10" bgcolor
="#DEDEDE"><tr
><td
>
397 <table width
="954" border
="0" style
="border:1px solid black" cellspacing
="0" cellpadding
="0">
399 <td width
="954" colspan
="6" align
="left" ></td
>
402 <td colspan
="6" align
="left"> 
;<font
class='title'><?php
echo htmlspecialchars(xl('Payment List'), ENT_QUOTES
) ?
></font
></td
>
405 <td colspan
="6" align
="left" ></td
>
408 <td colspan
="6" align
="left" ><table width
="954" border
="0" cellspacing
="0" cellpadding
="0">
411 <td width
="106"></td
>
412 <td width
="128"></td
>
415 <td width
="128"></td
>
417 <td width
="113"></td
>
418 <td width
="125"></td
>
421 <td width
="162"></td
>
424 <td align
="right"></td
>
425 <td align
="left" class="text"><?php
echo generate_select_list("payment_date", "payment_date", "$PaymentDate", "Payment Date", "", "class4 text");?
></td
>
427 <table border
="0" cellspacing
="0" cellpadding
="0">
429 <td align
="left" class="text"><?php
echo htmlspecialchars(xl('From'), ENT_QUOTES
).':' ?
></td
>
430 <td
><input type
='text' style
="width:90px;" class='datepicker' name
='FromDate' id
='FromDate' class="text" value
='<?php echo attr($FromDate); ?>' />
432 <td width
="53"> 
;</td
>
433 <td align
="left" class="text"><?php
echo htmlspecialchars(xl('To'), ENT_QUOTES
).':' ?
></td
>
434 <td
><input type
='text' style
="width:103px;" class='datepicker' name
='ToDate' id
='ToDate' class="text" value
='<?php echo attr($ToDate); ?>' />
439 <td
class="text"></td
>
440 <td align
="left" class="text"><?php
echo htmlspecialchars(xl('Payment Method'), ENT_QUOTES
).':' ?
></td
>
441 <td align
="left"><?php
echo generate_select_list("payment_method", "payment_method", "$PaymentMethod", "Payment Method", " ", "class1 text");?
></td
>
443 <td align
="left" class="text"><?php
echo htmlspecialchars(xl('Check Number'), ENT_QUOTES
).':' ?
></td
>
444 <td
><input type
="text" name
="check_number" autocomplete
="off" value
="<?php echo htmlspecialchars(formData('check_number'));?>" id
="check_number" class=" class1 text " /></td
>
447 <td align
="right"></td
>
448 <td align
="left" class="text"><?php
echo htmlspecialchars(xl('Payment Amount'), ENT_QUOTES
).':' ?
></td
>
449 <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
>
450 <td align
="left" ></td
>
451 <td align
="left" class="text"><?php
echo htmlspecialchars(xl('Paying Entity'), ENT_QUOTES
).':' ?
></td
>
452 <td align
="left"><?php
echo generate_select_list("type_name", "payment_type", "$type_name", "Paying Entity", " ", "class1 text", "SearchPayingEntityAction()");?
> </td
>
453 <td align
="left" ></td
>
454 <td align
="left" class="text"><?php
echo htmlspecialchars(xl('Payment Category'), ENT_QUOTES
).':' ?
></td
>
455 <td align
="left"><?php
echo generate_select_list("adjustment_code", "payment_adjustment_code", "$adjustment_code", "Paying Category", " ", "class1 text");?
> </td
>
457 <td align
="left" class=" text " ><?php
echo htmlspecialchars(xl('Pay Status'), ENT_QUOTES
).':' ?
></td
>
458 <td align
="left" ><?php
echo generate_select_list("PaymentStatus", "payment_status", "$PaymentStatus", "Pay Status", " ", "class1 text");?
></td
>
461 <td align
="right"></td
>
462 <td align
="left" class="text"><?php
echo htmlspecialchars(xl('Payment From'), ENT_QUOTES
).':' ?
></td
>
463 <td align
="left" colspan
="5" >
465 <table width
="335" border
="0" cellspacing
="0" cellpadding
="0">
468 <input type
="hidden" id
="hidden_ajax_close_value" value
="<?php echo htmlspecialchars($div_after_save);?>" /><input name
='type_code' id
='type_code' class="text "
469 style
=" width:280px;" onKeyDown
="PreventIt(event)" value
="<?php echo htmlspecialchars($div_after_save);?>" autocomplete
="off" /><br
>
470 <!--onKeyUp
="ajaxFunction(event,'non','search_payments.php');"-->
471 <div id
='ajax_div_insurance_section'>
472 <div id
='ajax_div_insurance_error'> </div
>
473 <div id
="ajax_div_insurance" style
="display:none;"></div
>
476 <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
>
479 <td align
="left" class="text"><?php
echo htmlspecialchars(xl('Sort Result by'), ENT_QUOTES
).':' ?
></td
>
480 <td align
="left" class="text"><?php
echo generate_select_list("PaymentSortBy", "payment_sort_by", "$PaymentSortBy", "Sort Result by", " ", "class1 text");?
> </td
>
481 <td align
="left" class="text"></td
>
482 <td align
="left" class="text"><table border
="0" cellspacing
="0" cellpadding
="0">
484 <td
><a href
="#" class="css_button" onClick
="javascript:return SearchPayment();" ><span
><?php
echo htmlspecialchars(xl('Search'), ENT_QUOTES
);?
></span
></a
></td
>
487 <td align
="left"></td
>
490 <td colspan
="12" align
="left" ></td
>
499 if ($_POST["mode"] == "SearchPayment") {
503 <table border
="0" cellspacing
="0" cellpadding
="0">
505 if (sqlNumRows($ResultSearch)>0) {
507 <tr
class="text" bgcolor
="#dddddd">
508 <td width
="25" class="left top" > 
;</td
>
509 <td width
="60" class="left top" ><?php
echo htmlspecialchars(xl('ID'), ENT_QUOTES
) ?
></td
>
510 <td width
="70" class="left top" ><?php
echo htmlspecialchars(xl('Date'), ENT_QUOTES
) ?
></td
>
511 <td width
="83" class="left top" ><?php
echo htmlspecialchars(xl('Paying Entity'), ENT_QUOTES
) ?
></td
>
512 <td width
="245" class="left top" ><?php
echo htmlspecialchars(xl('Payer'), ENT_QUOTES
) ?
></td
>
513 <td width
="57" class="left top" ><?php
echo htmlspecialchars(xl('Ins Code'), ENT_QUOTES
) ?
></td
>
514 <td width
="110" class="left top" ><?php
echo htmlspecialchars(xl('Payment Method'), ENT_QUOTES
) ?
></td
>
515 <td width
="130" class="left top" ><?php
echo htmlspecialchars(xl('Check Number'), ENT_QUOTES
) ?
></td
>
516 <td width
="70" class="left top" ><?php
echo htmlspecialchars(xl('Pay Status'), ENT_QUOTES
) ?
></td
>
517 <td width
="50" class="left top" ><?php
echo htmlspecialchars(xl('Payment'), ENT_QUOTES
) ?
></td
>
518 <td width
="70" class="left top right" ><?php
echo htmlspecialchars(xl('Undistributed'), ENT_QUOTES
) ?
></td
>
522 while ($RowSearch = sqlFetchArray($ResultSearch)) {
524 if ($RowSearch['payer_id']*1 > 0) {
525 //-------------------
526 $res = sqlStatement("SELECT insurance_companies.name FROM insurance_companies
527 where insurance_companies.id ='{$RowSearch['payer_id']}'");
528 $row = sqlFetchArray($res);
530 //-------------------
531 } elseif ($RowSearch['patient_id']*1 > 0) {
532 //-------------------
533 $res = sqlStatement("SELECT fname,lname,mname FROM patient_data
534 where pid ='{$RowSearch['patient_id']}'");
535 $row = sqlFetchArray($res);
536 $fname=$row['fname'];
537 $lname=$row['lname'];
538 $mname=$row['mname'];
539 $Payer=$lname.' '.$fname.' '.$mname;
540 //-------------------
543 //=============================================
545 if ($CountIndex==sqlNumRows($ResultSearch)) {
546 $StringClass=' bottom left top ';
548 $StringClass=' left top ';
551 if ($CountIndex%2
==1) {
557 <tr
class="text" bgcolor
='<?php echo $bgcolor; ?>'>
558 <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
>
559 <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
>
560 <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
>
561 <td
class="<?php echo $StringClass; ?>" ><a href
="edit_payment.php?payment_id=<?php echo htmlspecialchars($RowSearch['session_id']); ?>" class='iframe medium_modal' ><?php
562 $frow['data_type']=1;
563 $frow['list_id']='payment_type';
565 if ($RowSearch['payment_type']=='insurance' ||
$RowSearch['payer_id']*1 > 0) {
566 $PaymentType='insurance';
567 } elseif ($RowSearch['payment_type']=='patient' ||
$RowSearch['patient_id']*1 > 0) {
568 $PaymentType='patient';
569 } elseif (($RowSearch['payer_id']*1 == 0 && $RowSearch['patient_id']*1 == 0)) {
573 generate_print_field($frow, $PaymentType);
575 <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
>
576 <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
>
577 <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
578 $frow['data_type']=1;
579 $frow['list_id']='payment_method';
580 generate_print_field($frow, $RowSearch['payment_method']);
582 <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
>
583 <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
584 $rs= sqlStatement("select pay_total,global_amount from ar_session where session_id='".$RowSearch['session_id']."'");
585 $row=sqlFetchArray($rs);
586 $pay_total=$row['pay_total'];
587 $global_amount=$row['global_amount'];
588 $rs= sqlStatement("select sum(pay_amount) sum_pay_amount from ar_activity where session_id='".$RowSearch['session_id']."'");
589 $row=sqlFetchArray($rs);
590 $pay_amount=$row['sum_pay_amount'];
591 $UndistributedAmount=$pay_total-$pay_amount-$global_amount;
592 echo $UndistributedAmount*1==0 ?
htmlspecialchars(xl('Fully Paid'), ENT_QUOTES
) : htmlspecialchars(xl('Unapplied'), ENT_QUOTES
); ?
></a
></td
>
593 <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
>
594 <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
>
597 }//while ($RowSearch = sqlFetchArray($ResultSearch))
598 } //if(sqlNumRows($ResultSearch)>0)
602 <td colspan
="11" class="text"><?php
echo htmlspecialchars(xl('No Result Found, for the above search criteria.'), ENT_QUOTES
) ?
></td
>
611 }//if ($_POST["mode"] == "SearchPayment")
617 <input type
='hidden' name
='mode' id
='mode' value
='' />
618 <input type
='hidden' name
='ajax_mode' id
='ajax_mode' value
='' />
619 <input type
="hidden" name
="hidden_type_code" id
="hidden_type_code" value
="<?php echo htmlspecialchars(formData('hidden_type_code'));?>"/>
620 <input type
='hidden' name
='DeletePaymentId' id
='DeletePaymentId' value
='' />
621 <input type
='hidden' name
='SortFieldOld' id
='SortFieldOld' value
='<?php echo attr($PaymentSortBy);?>' />
622 <input type
='hidden' name
='Sort' id
='Sort' value
='<?php echo attr($Sort);?>' />
623 <input type
="hidden" name
="after_value" id
="after_value" value
="<?php echo htmlspecialchars($Message);?>"/>