continued bug fixes (#1876)
[openemr.git] / interface / billing / search_payments.php
blob61a9cb3e3944218bf74e91799a18c4defcf2b953
1 <?php
2 // +-----------------------------------------------------------------------------+
3 // Copyright (C) 2010 Z&H Consultancy Services Private Limited <sam@zhservices.com>
4 //
5 //
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");
40 use OpenEMR\Core\Header;
42 //===============================================================================
43 //Deletion of payment and its corresponding distributions.
44 //===============================================================================
45 set_time_limit(0);
46 if (isset($_POST["mode"])) {
47 if ($_POST["mode"] == "DeletePayments") {
48 $DeletePaymentId=trim(formData('DeletePaymentId'));
49 $ResultSearch = sqlStatement("SELECT distinct encounter,pid from ar_activity where session_id ='$DeletePaymentId'");
50 if (sqlNumRows($ResultSearch)>0) {
51 while ($RowSearch = sqlFetchArray($ResultSearch)) {
52 $Encounter=$RowSearch['encounter'];
53 $PId=$RowSearch['pid'];
54 sqlStatement("update form_encounter set last_level_closed=last_level_closed - 1 where pid ='$PId' and encounter='$Encounter'");
58 //delete and log that action
59 row_delete("ar_session", "session_id ='$DeletePaymentId'");
60 row_delete("ar_activity", "session_id ='$DeletePaymentId'");
61 $Message='Delete';
62 //------------------
63 $_POST["mode"] = "SearchPayment";
66 //===============================================================================
67 //Search section.
68 //===============================================================================
69 if ($_POST["mode"] == "SearchPayment") {
70 $FromDate=trim(formData('FromDate'));
71 $ToDate=trim(formData('ToDate'));
72 $PaymentMethod=trim(formData('payment_method'));
73 $CheckNumber=trim(formData('check_number'));
74 $PaymentAmount=trim(formData('payment_amount'));
75 $PayingEntity=trim(formData('type_name'));
76 $PaymentCategory=trim(formData('adjustment_code'));
77 $PaymentFrom=trim(formData('hidden_type_code'));
78 $PaymentStatus=trim(formData('PaymentStatus'));
79 $PaymentSortBy=trim(formData('PaymentSortBy'));
80 $PaymentDate=trim(formData('payment_date'));
81 $QueryString.="Select * from ar_session where ";
82 $And='';
84 if ($PaymentDate=='date_val') {
85 $PaymentDateString=' check_date ';
86 } elseif ($PaymentDate=='post_to_date') {
87 $PaymentDateString=' post_to_date ';
88 } elseif ($PaymentDate=='deposit_date') {
89 $PaymentDateString=' deposit_date ';
92 if ($FromDate!='') {
93 $QueryString.=" $And $PaymentDateString >='".DateToYYYYMMDD($FromDate)."'";
94 $And=' and ';
97 if ($ToDate!='') {
98 $QueryString.=" $And $PaymentDateString <='".DateToYYYYMMDD($ToDate)."'";
99 $And=' and ';
102 if ($PaymentMethod!='') {
103 $QueryString.=" $And payment_method ='".$PaymentMethod."'";
104 $And=' and ';
107 if ($CheckNumber!='') {
108 $QueryString.=" $And reference like '%".$CheckNumber."%'";
109 $And=' and ';
112 if ($PaymentAmount!='') {
113 $QueryString.=" $And pay_total ='".$PaymentAmount."'";
114 $And=' and ';
117 if ($PayingEntity!='') {
118 if ($PayingEntity=='insurance') {
119 $QueryString.=" $And payer_id !='0'";
122 if ($PayingEntity=='patient') {
123 $QueryString.=" $And payer_id ='0'";
126 $And=' and ';
129 if ($PaymentCategory!='') {
130 $QueryString.=" $And adjustment_code ='".$PaymentCategory."'";
131 $And=' and ';
134 if ($PaymentFrom!='') {
135 if ($PayingEntity=='insurance' || $PayingEntity=='') {
136 //-------------------
137 $res = sqlStatement("SELECT insurance_companies.name FROM insurance_companies
138 where insurance_companies.id ='$PaymentFrom'");
139 $row = sqlFetchArray($res);
140 $div_after_save=$row['name'];
141 //-------------------
143 $QueryString.=" $And payer_id ='".$PaymentFrom."'";
146 if ($PayingEntity=='patient') {
147 //-------------------
148 $res = sqlStatement("SELECT fname,lname,mname FROM patient_data
149 where pid ='$PaymentFrom'");
150 $row = sqlFetchArray($res);
151 $fname=$row['fname'];
152 $lname=$row['lname'];
153 $mname=$row['mname'];
154 $div_after_save=$lname.' '.$fname.' '.$mname;
155 //-------------------
157 $QueryString.=" $And patient_id ='".$PaymentFrom."'";
160 $And=' and ';
163 if ($PaymentStatus!='') {
164 $QsString="select ar_session.session_id,pay_total,global_amount,sum(pay_amount) sum_pay_amount from ar_session,ar_activity
165 where ar_session.session_id=ar_activity.session_id group by ar_activity.session_id,ar_session.session_id
166 having pay_total-global_amount-sum_pay_amount=0 or pay_total=0";
167 $rs= sqlStatement("$QsString");
168 while ($rowrs=sqlFetchArray($rs)) {
169 $StringSessionId.=$rowrs['session_id'].',';
172 $QsString="select ar_session.session_id from ar_session where pay_total=0";
173 $rs= sqlStatement("$QsString");
174 while ($rowrs=sqlFetchArray($rs)) {
175 $StringSessionId.=$rowrs['session_id'].',';
178 $StringSessionId=substr($StringSessionId, 0, -1);
179 if ($PaymentStatus=='fully_paid') {
180 $QueryString.=" $And session_id in($StringSessionId) ";
181 } elseif ($PaymentStatus=='unapplied') {
182 $QueryString.=" $And session_id not in($StringSessionId) ";
185 $And=' and ';
188 if ($PaymentSortBy!='') {
189 $SortFieldOld=trim(formData('SortFieldOld'));
190 $Sort=trim(formData('Sort'));
191 if ($SortFieldOld==$PaymentSortBy) {
192 if ($Sort=='DESC' || $Sort=='') {
193 $Sort='ASC';
194 } else {
195 $Sort='DESC';
197 } else {
198 $Sort='ASC';
201 $QueryString.=" order by $PaymentSortBy $Sort";
204 $ResultSearch = sqlStatement($QueryString);
208 //===============================================================================
210 <!DOCTYPE html>
211 <html>
212 <head>
214 <?php Header::setupHeader(['jquery-ui', 'datetime-picker']); ?>
216 <?php include_once("{$GLOBALS['srcdir']}/payment_jav.inc.php"); ?>
217 <?php include_once("{$GLOBALS['srcdir']}/ajax/payment_ajax_jav.inc.php"); ?>
219 <script type='text/javascript'>
221 $(document).ready(function() {
222 $(".medium_modal").on('click', function (e) {
223 e.preventDefault();
224 e.stopPropagation();
225 dlgopen('', '', 1050, 350, '', '', {
226 buttons: [
227 {text: '<?php echo xla('Close'); ?>', close: true, style: 'default btn-sm'}
229 onClosed: '',
230 type: 'iframe',
231 url: $(this).attr('href')
235 $('.datepicker').datetimepicker({
236 <?php $datetimepicker_timepicker = false; ?>
237 <?php $datetimepicker_showseconds = false; ?>
238 <?php $datetimepicker_formatInput = true; ?>
239 <?php require($GLOBALS['srcdir'] . '/js/xl/jquery-datetimepicker-2-5-4.js.php'); ?>
240 <?php // can add any additional javascript settings to datetimepicker here; need to prepend first setting with a comma ?>
244 </script>
245 <script language='JavaScript'>
246 var mypcc = '1';
247 </script>
248 <script language='JavaScript'>
249 function SearchPayment()
250 {//Search validations.
251 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=='' )
253 alert("<?php echo htmlspecialchars(xl('Please select any Search Option.'), ENT_QUOTES) ?>");
254 return false;
256 if(document.getElementById('FromDate').value!='' && document.getElementById('ToDate').value!='')
258 if(!DateCheckGreater(document.getElementById('FromDate').value,document.getElementById('ToDate').value,'<?php echo DateFormatRead();?>'))
260 alert("<?php echo htmlspecialchars(xl('From Date Cannot be Greater than To Date.'), ENT_QUOTES) ?>");
261 document.getElementById('FromDate').focus();
262 return false;
265 top.restoreSession();
266 document.getElementById('mode').value='SearchPayment';
267 document.forms[0].submit();
269 function DeletePayments(DeleteId)
270 {//Confirms deletion of payment and all its distribution.
271 if(confirm("<?php echo htmlspecialchars(xl('Would you like to Delete Payments?'), ENT_QUOTES) ?>"))
273 document.getElementById('mode').value='DeletePayments';
274 document.getElementById('DeletePaymentId').value=DeleteId;
275 top.restoreSession();
276 document.forms[0].submit();
278 else
279 return false;
281 function OnloadAction()
282 {//Displays message after deletion.
283 after_value=document.getElementById('after_value').value;
284 if(after_value=='Delete')
286 alert("<?php echo htmlspecialchars(xl('Successfully Deleted'), ENT_QUOTES) ?>")
289 function SearchPayingEntityAction()
291 //Which ajax is to be active(patient,insurance), is decided by the 'Paying Entity' drop down, where this function is called.
292 //So on changing some initialization is need.Done below.
293 document.getElementById('type_code').value='';
294 document.getElementById('hidden_ajax_close_value').value='';
295 document.getElementById('hidden_type_code').value='';
296 document.getElementById('div_insurance_or_patient').innerHTML='&nbsp;';
297 document.getElementById('description').value='';
298 if(document.getElementById('ajax_div_insurance'))
300 $("#ajax_div_patient_error").empty();
301 $("#ajax_div_patient").empty();
302 $("#ajax_div_insurance_error").empty();
303 $("#ajax_div_insurance").empty();
304 $("#ajax_div_insurance").hide();
305 document.getElementById('payment_method').style.display='';
308 </script>
309 <script language="javascript" type="text/javascript">
310 document.onclick=HideTheAjaxDivs;
311 </script>
312 <style>
313 .class1{width:125px;}
314 .class2{width:250px;}
315 .class3{width:100px;}
316 .class4{width:103px;}
317 #ajax_div_insurance {
318 position: absolute;
319 z-index:10;
320 background-color: #FBFDD0;
321 border: 1px solid #ccc;
322 padding: 10px;
324 #ajax_div_patient {
325 position: absolute;
326 z-index:10;
327 background-color: #FBFDD0;
328 border: 1px solid #ccc;
329 padding: 10px;
331 .bottom {
332 border-bottom: 1px solid black;
334 .top {
335 border-top: 1px solid black;
337 .left {
338 border-left: 1px solid black;
340 .right {
341 border-right: 1px solid black;
343 .form-group {
344 margin-bottom: 5px;
346 @media only screen and (max-width: 768px) {
347 [class*="col-"] {
348 width: 100%;
349 text-align: left!Important;
351 .navbar-toggle>span.icon-bar {
352 background-color: #68171A ! Important;
354 .navbar-default .navbar-toggle {
355 border-color: #4a4a4a;
357 .navbar-default .navbar-toggle:focus, .navbar-default .navbar-toggle:hover {
358 background-color: #f2f2f2 !Important;
359 font-weight: 900 !Important;
360 color: #000000 !Important;
362 .navbar-color {
363 background-color: #E5E5E5;
365 .icon-bar {
366 background-color: #68171A;
368 .navbar-header {
369 float: none;
371 .navbar-toggle {
372 display: block;
373 background-color: #f2f2f2;
375 .navbar-nav {
376 float: none!important;
378 .navbar-nav>li {
379 float: none;
381 .navbar-collapse.collapse.in {
382 z-index: 100;
383 background-color: #dfdfdf;
384 font-weight: 700;
385 color: #000000 !Important;
388 .table {
389 margin: auto;
390 width: 90% !important;
392 @media (min-width: 992px) {
393 .modal-lg {
394 width: 1000px !Important;
397 .oe-modal-dialog {
398 width: 65% !Important;
400 .oe-modal-content {
401 padding: 20px 0px 20px 0px;
403 .modalclass {
404 overflow-x: hidden !Important;
406 </style>
407 </head>
408 <body class="body_top" onload="OnloadAction()">
409 <div class="container">
410 <div class="row">
411 <div class="page-header">
412 <h2><?php echo xlt('Payments'); ?></h2>
413 </div>
414 </div>
415 <div class="row">
416 <nav class="navbar navbar-default navbar-color navbar-static-top" >
417 <div class="container">
418 <div class="navbar-header">
419 <button class="navbar-toggle" data-target="#myNavbar" data-toggle="collapse" type="button"><span class="icon-bar"></span><span class="icon-bar"></span><span class="icon-bar"></span></button>
420 </div>
421 <div class="collapse navbar-collapse" id="myNavbar" >
422 <ul class="nav navbar-nav" >
423 <li class="oe-bold-black">
424 <a href='new_payment.php' style="font-weight:700; color:#000000"><?php echo xlt('New Payment'); ?></a>
425 </li>
426 <li class="active oe-bold-black" >
427 <a href='search_payments.php' style="font-weight:700; color:#000000"><?php echo xlt('Search Payment'); ?></a>
428 </li>
429 <li class="oe-bold-black">
430 <a href='era_payments.php' style="font-weight:700; color:#000000"><?php echo xlt('ERA Posting'); ?></a>
431 </li>
432 </ul>
433 </div>
434 </div>
435 </nav>
436 </div>
437 <div class="row">
438 <form id="new_payment" method='post' name='new_payment' style="display:inline">
439 <fieldset>
440 <div class="col-xs-12 h3">
441 <?php echo xlt('Payment List'); ?>
442 </div>
443 <div class="col-xs-12 oe-custom-line">
444 <div class="forms col-xs-2">
445 <label class="control-label" for="payment_date"><?php echo xlt('Payment date'); ?>:</label>
446 <?php echo generate_select_list("payment_date", "payment_date", "$PaymentDate", "Payment Date", "", "");?>
447 </div>
448 <div class="forms col-xs-2">
449 <label class="control-label" for="FromDate"><?php echo xlt('From'); ?>:</label>
450 <input class="form-control datepicker" id='FromDate' name='FromDate' type='text' value='<?php echo attr($FromDate); ?>'>
451 </div>
452 <div class="forms col-xs-2">
453 <label class="control-label" for="ToDate"><?php echo xlt('To'); ?>:</label>
454 <input class="form-control datepicker" id='ToDate' name='ToDate' type='text' value='<?php echo attr($ToDate); ?>'>
455 </div>
456 <div class="forms col-xs-3">
457 <label class="control-label" for="payment_method"><?php echo xlt('Payment Method'); ?>:</label>
458 <?php echo generate_select_list("payment_method", "payment_method", "$PaymentMethod", "Payment Method", " ", "");?>
459 </div>
460 <div class="forms col-xs-3">
461 <label class="control-label" for="check_number"><?php echo xlt('Check Number'); ?>:</label>
462 <input autocomplete="off" class="form-control" id="check_number" name="check_number" type="text" value="<?php echo htmlspecialchars(formData('check_number'));?>">
463 </div>
464 </div>
465 <div class="col-xs-12 oe-custom-line">
466 <div class="forms col-xs-4">
467 <label class="control-label" for="payment_method"><?php echo xlt('Payment Amount'); ?>:</label>
468 <input autocomplete="off" class="form-control" id="payment_amount" name="payment_amount" onkeyup="ValidateNumeric(this);" type="text" value="<?php echo htmlspecialchars(formData('payment_amount'));?>">
469 </div>
470 <div class="forms col-xs-2">
471 <label class="control-label" for="type_name"><?php echo xlt('Paying Entity'); ?>:</label>
472 <?php echo generate_select_list("type_name", "payment_type", "$type_name", "Paying Entity", " ", "", "SearchPayingEntityAction()");?>
473 </div>
474 <div class="forms col-xs-3">
475 <label class="control-label" for="adjustment_code"><?php echo xlt('Payment Category'); ?>:</label>
476 <?php echo generate_select_list("adjustment_code", "payment_adjustment_code", "$adjustment_code", "Paying Category", " ", "");?>
477 </div>
478 <div class="forms col-xs-3">
479 <label class="control-label" for="PaymentStatus"><?php echo xlt('Pay Status'); ?>:</label>
480 <?php echo generate_select_list("PaymentStatus", "payment_status", "$PaymentStatus", "Pay Status", " ", "");?>
481 </div>
482 </div>
483 <div class="col-xs-12 oe-custom-line">
484 <div class="forms col-xs-4">
485 <label class="control-label" for="type_code"><?php echo xlt('Payment From'); ?>:</label>
486 <input id="hidden_ajax_close_value" type="hidden" value="<?php echo htmlspecialchars($div_after_save);?>">
487 <input autocomplete="off" class="form-control" id='type_code' name='type_code' onkeydown="PreventIt(event)" type="text" value="<?php echo htmlspecialchars($div_after_save);?>">
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>
492 </div>
493 </div>
494 <div class="forms col-xs-2">
495 <label class="control-label" for="div_insurance_or_patient"><?php echo xlt('Payor ID'); ?>:</label>
496 <div class="form-control" id="div_insurance_or_patient"><?php echo htmlspecialchars(formData('hidden_type_code'));?></div>
497 <input id="description" name="description" type="hidden">
498 <input id="deposit_date" name="deposit_date" style="display:none" type="text">
499 </div>
500 <div class="forms col-xs-3">
501 <label class="control-label" for="PaymentSortBy"><?php echo xlt('Sort Result by'); ?>:</label>
502 <?php echo generate_select_list("PaymentSortBy", "payment_sort_by", "$PaymentSortBy", "Sort Result by", " ", "");?>
503 </div>
504 </div>
505 </fieldset><!--End of Search-->
506 <?php //can change position of buttons by creating a class 'position-override' and adding rule text-align:center or right as the case may be in individual stylesheets ?>
507 <div class="form-group clearfix">
508 <div class="col-sm-12 text-left position-override">
509 <div class="btn-group" role="group">
510 <a class="btn btn-default btn-search" href="#" onclick="javascript:return SearchPayment();"><span><?php echo xlt('Search');?></span></a>
511 </div>
512 </div>
513 </div>
514 <?php
515 if ($_POST["mode"] == "SearchPayment") {
516 echo "&nbsp;" ."<br>"; // do not remove else below div will not display !!
518 <div class = "table-responsive">
519 <table class="table">
520 <?php
521 if (sqlNumRows($ResultSearch)>0) {
523 <thead bgcolor="#DDDDDD" class="">
524 <td class="left top" width="25">&nbsp;</td>
525 <td class="left top"><?php echo htmlspecialchars(xl('ID'), ENT_QUOTES) ?></td>
526 <td class="left top" ><?php echo htmlspecialchars(xl('Date'), ENT_QUOTES) ?></td>
527 <td class="left top" ><?php echo htmlspecialchars(xl('Paying Entity'), ENT_QUOTES) ?></td>
528 <td class="left top" ><?php echo htmlspecialchars(xl('Payer'), ENT_QUOTES) ?></td>
529 <td class="left top" ><?php echo htmlspecialchars(xl('Ins Code'), ENT_QUOTES) ?></td>
530 <td class="left top" ><?php echo htmlspecialchars(xl('Payment Method'), ENT_QUOTES) ?></td>
531 <td class="left top" ><?php echo htmlspecialchars(xl('Check Number'), ENT_QUOTES) ?></td>
532 <td class="left top" ><?php echo htmlspecialchars(xl('Pay Status'), ENT_QUOTES) ?></td>
533 <td class="left top" ><?php echo htmlspecialchars(xl('Payment'), ENT_QUOTES) ?></td>
534 <td class="left top right" ><?php echo htmlspecialchars(xl('Undistributed'), ENT_QUOTES) ?></td>
535 </thead>
536 <?php
537 $CountIndex=0;
538 while ($RowSearch = sqlFetchArray($ResultSearch)) {
539 $Payer='';
540 if ($RowSearch['payer_id']*1 >0) {
541 //-------------------
542 $res = sqlStatement("SELECT insurance_companies.name FROM insurance_companies
543 where insurance_companies.id ='{$RowSearch['payer_id']}'");
544 $row = sqlFetchArray($res);
545 $Payer=$row['name'];
546 //-------------------
547 } elseif ($RowSearch['patient_id']*1 >0) {
548 //-------------------
549 $res = sqlStatement("SELECT fname,lname,mname FROM patient_data
550 where pid ='{$RowSearch['patient_id']}'");
551 $row = sqlFetchArray($res);
552 $fname=$row['fname'];
553 $lname=$row['lname'];
554 $mname=$row['mname'];
555 $Payer=$lname.' '.$fname.' '.$mname;
556 //-------------------
558 //=============================================
559 $CountIndex++;
560 if ($CountIndex==sqlNumRows($ResultSearch)) {
561 $StringClass=' bottom left top ';
562 } else {
563 $StringClass=' left top ';
565 if ($CountIndex%2==1) {
566 $bgcolor='#ddddff';
567 } else {
568 $bgcolor='#ffdddd';
571 <tr bgcolor='<?php echo $bgcolor; ?>' class="text">
572 <td class="<?php echo $StringClass; ?>">
573 <!--<a href="#" onclick="javascript:return DeletePayments(&lt;?php echo htmlspecialchars($RowSearch['session_id']); ?&gt;);"><img border="0" src="../pic/Delete.gif"></a>-->
575 <a href="#" onclick="javascript:return DeletePayments(<?php echo htmlspecialchars($RowSearch['session_id']); ?>);"><img border="0" src="../pic/Delete.gif"></a>
576 </td>
577 <td class="<?php echo $StringClass; ?>">
578 <a class="" data-toggle="modal" data-target="#myModal" onclick="loadiframe('edit_payment.php?payment_id=<?php echo htmlspecialchars($RowSearch['session_id']); ?>')"><?php echo htmlspecialchars($RowSearch['session_id']); ?></a>
579 </td>
580 <td class="<?php echo $StringClass; ?>">
581 <a class="" data-toggle="modal" data-target="#myModal" onclick="loadiframe('edit_payment.php?payment_id=<?php echo htmlspecialchars($RowSearch['session_id']); ?>')"><?php echo $RowSearch['check_date']=='0000-00-00' ? '&nbsp;' : htmlspecialchars(oeFormatShortDate($RowSearch['check_date'])); ?></a>
582 </td>
583 <td class="<?php echo $StringClass; ?>">
584 <a class="" data-toggle="modal" data-target="#myModal" onclick="loadiframe('edit_payment.php?payment_id=<?php echo htmlspecialchars($RowSearch['session_id']); ?>')">
585 <?php
586 $frow['data_type']=1;
587 $frow['list_id']='payment_type';
588 $PaymentType='';
589 if ($RowSearch['payment_type']=='insurance' || $RowSearch['payer_id']*1 >0) {
590 $PaymentType='insurance';
591 } elseif ($RowSearch['payment_type']=='patient' || $RowSearch['patient_id']*1 >0) {
592 $PaymentType='patient';
593 } elseif (($RowSearch['payer_id']*1 == 0 && $RowSearch['patient_id']*1 == 0)) {
594 $PaymentType='';
596 generate_print_field($frow, $PaymentType);
597 ?></a>
598 </td>
599 <td class="<?php echo $StringClass; ?>">
600 <!--<a class='iframe medium_modal' href="edit_payment.php?payment_id=<?php echo htmlspecialchars($RowSearch['session_id']); ?>"><?php echo $Payer=='' ? '&nbsp;' : htmlspecialchars($Payer) ;?></a>-->
601 <a class="" data-target="#myModal" data-toggle="modal" onclick="loadiframe('edit_payment.php?payment_id=<?php echo htmlspecialchars($RowSearch['session_id']); ?>')"><?php echo $Payer=='' ? '&nbsp;' : htmlspecialchars($Payer) ;?></a><!--link to iframe-->
602 </td>
603 <td class="<?php echo $StringClass; ?>">
604 <a class="" data-toggle="modal" data-target="#myModal" onclick="loadiframe('edit_payment.php?payment_id=<?php echo htmlspecialchars($RowSearch['session_id']); ?>')"><?php echo $RowSearch['payer_id']*1 >0 ? htmlspecialchars($RowSearch['payer_id']) : '&nbsp;'; ?></a>
605 </td>
606 <td align="left" class="<?php echo $StringClass; ?>">
607 <!--<a class='iframe medium_modal' href="edit_payment.php?payment_id=<?php echo htmlspecialchars($RowSearch['session_id']); ?>"><?php
608 $frow['data_type']=1;
609 $frow['list_id']='payment_method';
610 generate_print_field($frow, $RowSearch['payment_method']);
611 ?></a>-->
612 <a class="" data-toggle="modal" data-target="#myModal" onclick="loadiframe('edit_payment.php?payment_id=<?php echo htmlspecialchars($RowSearch['session_id']); ?>')">
613 <?php
614 $frow['data_type']=1;
615 $frow['list_id']='payment_method';
616 generate_print_field($frow, $RowSearch['payment_method']);
617 ?></a>
618 </td>
619 <td align="left" class="<?php echo $StringClass; ?>">
620 <!--<a class='iframe medium_modal' href="edit_payment.php?payment_id=<?php echo htmlspecialchars($RowSearch['session_id']); ?>"><?php echo $RowSearch['reference']=='' ? '&nbsp;' : htmlspecialchars($RowSearch['reference']); ?></a>-->
621 <a class="" data-toggle="modal" data-target="#myModal" onclick="loadiframe('edit_payment.php?payment_id=<?php echo htmlspecialchars($RowSearch['session_id']); ?>')"><?php echo $RowSearch['reference']=='' ? '&nbsp;' : htmlspecialchars($RowSearch['reference']); ?></a>
622 </td>
623 <td align="left" class="<?php echo $StringClass; ?>">
624 <a class="" data-toggle="modal" data-target="#myModal" onclick="loadiframe('edit_payment.php?payment_id=<?php echo htmlspecialchars($RowSearch['session_id']); ?>')"><?php
625 $rs= sqlStatement("select pay_total,global_amount from ar_session where session_id='".$RowSearch['session_id']."'");
626 $row=sqlFetchArray($rs);
627 $pay_total=$row['pay_total'];
628 $global_amount=$row['global_amount'];
629 $rs= sqlStatement("select sum(pay_amount) sum_pay_amount from ar_activity where session_id='".$RowSearch['session_id']."'");
630 $row=sqlFetchArray($rs);
631 $pay_amount=$row['sum_pay_amount'];
632 $UndistributedAmount=$pay_total-$pay_amount-$global_amount;
633 echo $UndistributedAmount*1==0 ? htmlspecialchars(xl('Fully Paid'), ENT_QUOTES) : htmlspecialchars(xl('Unapplied'), ENT_QUOTES); ?></a>
634 </td>
635 <td align="right" class="<?php echo $StringClass; ?>">
636 <a class="" data-toggle="modal" data-target="#myModal" onclick="loadiframe('edit_payment.php?payment_id=<?php echo htmlspecialchars($RowSearch['session_id']); ?>')"><?php echo htmlspecialchars($RowSearch['pay_total']); ?></a>
637 </td>
638 <td align="right" class="<?php echo $StringClass; ?>right">
639 <a class="" data-toggle="modal" data-target="#myModal" onclick="loadiframe('edit_payment.php?payment_id=<?php echo htmlspecialchars($RowSearch['session_id']); ?>')"><?php echo htmlspecialchars(number_format($UndistributedAmount, 2)); ?></a>
640 </td>
641 </tr>
642 <?php
643 }//End of while ($RowSearch = sqlFetchArray($ResultSearch))
644 } //End of if(sqlNumRows($ResultSearch)>0)
645 else {
647 <tr>
648 <td class="text" colspan="11"><?php echo htmlspecialchars(xl('No Result Found, for the above search criteria.'), ENT_QUOTES) ?></td>
649 </tr>
650 <?php
651 }// End of else
653 </table>
654 </div><!--End of table-responsive div-->
655 <?php
656 }// End of if ($_POST["mode"] == "SearchPayment")
658 <div class="row">
659 <input id='mode' name='mode' type='hidden' value=''>
660 <input id='ajax_mode' name='ajax_mode' type='hidden' value=''>
661 <input id="hidden_type_code" name="hidden_type_code" type="hidden" value="<?php echo htmlspecialchars(formData('hidden_type_code'));?>">
662 <input id='DeletePaymentId' name='DeletePaymentId' type='hidden' value=''>
663 <input id='SortFieldOld' name='SortFieldOld' type='hidden' value='<?php echo attr($PaymentSortBy);?>'>
664 <input id='Sort' name='Sort' type='hidden' value='<?php echo attr($Sort);?>'>
665 <input id="after_value" name="after_value" type="hidden" value="<?php echo htmlspecialchars($Message);?>">
666 </div>
667 </form>
668 </div>
670 </div>
671 <div class="row">
672 <div class="modal fade" id="myModal" tabindex="-1" role="dialog" aria-labelledby="myModalLabel" aria-hidden="true">
673 <div class="modal-dialog oe-modal-dialog modal-lg">
674 <div class="modal-content oe-modal-content">
675 <!--<div class="modal-header" style="border:hidden"></div>-->
676 <div class="modal-body">
677 <iframe src="" id="targetiframe" style="height:650px; width:100%; overflow-x: hidden; border:none" allowtransparency="true"></iframe>
678 </div>
679 <div class="modal-footer" style="margin-top:0px;">
680 <button class="btn btn-link btn-cancel pull-right" data-dismiss="modal" type="button"><?php echo xlt('close'); ?></button>
681 </div>
682 </div>
683 </div>
684 </div>
685 </div>
686 <script>
687 function loadiframe(htmlHref) { //load iframe
688 document.getElementById('targetiframe').src = htmlHref;
690 </script>
691 </body>
692 </html>