dump db version
[openemr.git] / interface / billing / search_payments.php
blob9750fbe2e2762c4c9b753e43df76fcdcf6f68bbb
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;
41 use OpenEMR\OeUI\OemrUI;
43 //===============================================================================
44 //Deletion of payment and its corresponding distributions.
45 //===============================================================================
46 set_time_limit(0);
47 if (isset($_POST["mode"])) {
48 if ($_POST["mode"] == "DeletePayments") {
49 $DeletePaymentId=trim(formData('DeletePaymentId'));
50 $ResultSearch = sqlStatement("SELECT distinct encounter,pid from ar_activity where session_id ='$DeletePaymentId'");
51 if (sqlNumRows($ResultSearch)>0) {
52 while ($RowSearch = sqlFetchArray($ResultSearch)) {
53 $Encounter=$RowSearch['encounter'];
54 $PId=$RowSearch['pid'];
55 sqlStatement("update form_encounter set last_level_closed=last_level_closed - 1 where pid ='$PId' and encounter='$Encounter'");
59 //delete and log that action
60 row_delete("ar_session", "session_id ='$DeletePaymentId'");
61 row_delete("ar_activity", "session_id ='$DeletePaymentId'");
62 $Message='Delete';
63 //------------------
64 $_POST["mode"] = "SearchPayment";
67 //===============================================================================
68 //Search section.
69 //===============================================================================
70 if ($_POST["mode"] == "SearchPayment") {
71 $FromDate=trim(formData('FromDate'));
72 $ToDate=trim(formData('ToDate'));
73 $PaymentMethod=trim(formData('payment_method'));
74 $CheckNumber=trim(formData('check_number'));
75 $PaymentAmount=trim(formData('payment_amount'));
76 $PayingEntity=trim(formData('type_name'));
77 $PaymentCategory=trim(formData('adjustment_code'));
78 $PaymentFrom=trim(formData('hidden_type_code'));
79 $PaymentStatus=trim(formData('PaymentStatus'));
80 $PaymentSortBy=trim(formData('PaymentSortBy'));
81 $PaymentDate=trim(formData('payment_date'));
82 $QueryString.="Select * from ar_session where ";
83 $And='';
85 if ($PaymentDate=='date_val') {
86 $PaymentDateString=' check_date ';
87 } elseif ($PaymentDate=='post_to_date') {
88 $PaymentDateString=' post_to_date ';
89 } elseif ($PaymentDate=='deposit_date') {
90 $PaymentDateString=' deposit_date ';
93 if ($FromDate!='') {
94 $QueryString.=" $And $PaymentDateString >='".DateToYYYYMMDD($FromDate)."'";
95 $And=' and ';
98 if ($ToDate!='') {
99 $QueryString.=" $And $PaymentDateString <='".DateToYYYYMMDD($ToDate)."'";
100 $And=' and ';
103 if ($PaymentMethod!='') {
104 $QueryString.=" $And payment_method ='".$PaymentMethod."'";
105 $And=' and ';
108 if ($CheckNumber!='') {
109 $QueryString.=" $And reference like '%".$CheckNumber."%'";
110 $And=' and ';
113 if ($PaymentAmount!='') {
114 $QueryString.=" $And pay_total ='".$PaymentAmount."'";
115 $And=' and ';
118 if ($PayingEntity!='') {
119 if ($PayingEntity=='insurance') {
120 $QueryString.=" $And payer_id !='0'";
123 if ($PayingEntity=='patient') {
124 $QueryString.=" $And payer_id ='0'";
127 $And=' and ';
130 if ($PaymentCategory!='') {
131 $QueryString.=" $And adjustment_code ='".$PaymentCategory."'";
132 $And=' and ';
135 if ($PaymentFrom!='') {
136 if ($PayingEntity=='insurance' || $PayingEntity=='') {
137 //-------------------
138 $res = sqlStatement("SELECT insurance_companies.name FROM insurance_companies
139 where insurance_companies.id ='$PaymentFrom'");
140 $row = sqlFetchArray($res);
141 $div_after_save=$row['name'];
142 //-------------------
144 $QueryString.=" $And payer_id ='".$PaymentFrom."'";
147 if ($PayingEntity=='patient') {
148 //-------------------
149 $res = sqlStatement("SELECT fname,lname,mname FROM patient_data
150 where pid ='$PaymentFrom'");
151 $row = sqlFetchArray($res);
152 $fname=$row['fname'];
153 $lname=$row['lname'];
154 $mname=$row['mname'];
155 $div_after_save=$lname.' '.$fname.' '.$mname;
156 //-------------------
158 $QueryString.=" $And patient_id ='".$PaymentFrom."'";
161 $And=' and ';
164 if ($PaymentStatus!='') {
165 $QsString="select ar_session.session_id,pay_total,global_amount,sum(pay_amount) sum_pay_amount from ar_session,ar_activity
166 where ar_session.session_id=ar_activity.session_id group by ar_activity.session_id,ar_session.session_id
167 having pay_total-global_amount-sum_pay_amount=0 or pay_total=0";
168 $rs= sqlStatement("$QsString");
169 while ($rowrs=sqlFetchArray($rs)) {
170 $StringSessionId.=$rowrs['session_id'].',';
173 $QsString="select ar_session.session_id from ar_session where pay_total=0";
174 $rs= sqlStatement("$QsString");
175 while ($rowrs=sqlFetchArray($rs)) {
176 $StringSessionId.=$rowrs['session_id'].',';
179 $StringSessionId=substr($StringSessionId, 0, -1);
180 if ($PaymentStatus=='fully_paid') {
181 $QueryString.=" $And session_id in($StringSessionId) ";
182 } elseif ($PaymentStatus=='unapplied') {
183 $QueryString.=" $And session_id not in($StringSessionId) ";
186 $And=' and ';
189 if ($PaymentSortBy!='') {
190 $SortFieldOld=trim(formData('SortFieldOld'));
191 $Sort=trim(formData('Sort'));
192 if ($SortFieldOld==$PaymentSortBy) {
193 if ($Sort=='DESC' || $Sort=='') {
194 $Sort='ASC';
195 } else {
196 $Sort='DESC';
198 } else {
199 $Sort='ASC';
202 $QueryString.=" order by $PaymentSortBy $Sort";
205 $ResultSearch = sqlStatement($QueryString);
209 //===============================================================================
211 <!DOCTYPE html>
212 <html>
213 <head>
215 <?php Header::setupHeader(['jquery-ui', 'datetime-picker']); ?>
217 <?php include_once("{$GLOBALS['srcdir']}/payment_jav.inc.php"); ?>
218 <?php include_once("{$GLOBALS['srcdir']}/ajax/payment_ajax_jav.inc.php"); ?>
220 <script type='text/javascript'>
222 $(document).ready(function() {
223 $(".medium_modal").on('click', function (e) {
224 e.preventDefault();
225 e.stopPropagation();
226 dlgopen('', '', 1050, 350, '', '', {
227 buttons: [
228 {text: '<?php echo xla('Close'); ?>', close: true, style: 'default btn-sm'}
230 onClosed: '',
231 type: 'iframe',
232 url: $(this).attr('href')
236 $('.datepicker').datetimepicker({
237 <?php $datetimepicker_timepicker = false; ?>
238 <?php $datetimepicker_showseconds = false; ?>
239 <?php $datetimepicker_formatInput = true; ?>
240 <?php require($GLOBALS['srcdir'] . '/js/xl/jquery-datetimepicker-2-5-4.js.php'); ?>
241 <?php // can add any additional javascript settings to datetimepicker here; need to prepend first setting with a comma ?>
245 </script>
246 <script language='JavaScript'>
247 var mypcc = '1';
248 </script>
249 <script language='JavaScript'>
250 function SearchPayment()
251 {//Search validations.
252 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=='' )
254 alert("<?php echo htmlspecialchars(xl('Please select any Search Option.'), ENT_QUOTES) ?>");
255 return false;
257 if(document.getElementById('FromDate').value!='' && document.getElementById('ToDate').value!='')
259 if(!DateCheckGreater(document.getElementById('FromDate').value,document.getElementById('ToDate').value,'<?php echo DateFormatRead();?>'))
261 alert("<?php echo htmlspecialchars(xl('From Date Cannot be Greater than To Date.'), ENT_QUOTES) ?>");
262 document.getElementById('FromDate').focus();
263 return false;
266 top.restoreSession();
267 document.getElementById('mode').value='SearchPayment';
268 document.forms[0].submit();
270 function DeletePayments(DeleteId)
271 {//Confirms deletion of payment and all its distribution.
272 if(confirm("<?php echo htmlspecialchars(xl('Would you like to Delete Payments?'), ENT_QUOTES) ?>"))
274 document.getElementById('mode').value='DeletePayments';
275 document.getElementById('DeletePaymentId').value=DeleteId;
276 top.restoreSession();
277 document.forms[0].submit();
279 else
280 return false;
282 function OnloadAction()
283 {//Displays message after deletion.
284 after_value=document.getElementById('after_value').value;
285 if(after_value=='Delete')
287 alert("<?php echo htmlspecialchars(xl('Successfully Deleted'), ENT_QUOTES) ?>")
290 function SearchPayingEntityAction()
292 //Which ajax is to be active(patient,insurance), is decided by the 'Paying Entity' drop down, where this function is called.
293 //So on changing some initialization is need.Done below.
294 document.getElementById('type_code').value='';
295 document.getElementById('hidden_ajax_close_value').value='';
296 document.getElementById('hidden_type_code').value='';
297 document.getElementById('div_insurance_or_patient').innerHTML='&nbsp;';
298 document.getElementById('description').value='';
299 if(document.getElementById('ajax_div_insurance'))
301 $("#ajax_div_patient_error").empty();
302 $("#ajax_div_patient").empty();
303 $("#ajax_div_insurance_error").empty();
304 $("#ajax_div_insurance").empty();
305 $("#ajax_div_insurance").hide();
306 document.getElementById('payment_method').style.display='';
309 </script>
310 <script language="javascript" type="text/javascript">
311 document.onclick=HideTheAjaxDivs;
312 </script>
313 <style>
314 .class1{width:125px;}
315 .class2{width:250px;}
316 .class3{width:100px;}
317 .class4{width:103px;}
318 #ajax_div_insurance {
319 position: absolute;
320 z-index:10;
321 background-color: #FBFDD0;
322 border: 1px solid #ccc;
323 padding: 10px;
325 #ajax_div_patient {
326 position: absolute;
327 z-index:10;
328 background-color: #FBFDD0;
329 border: 1px solid #ccc;
330 padding: 10px;
332 .bottom {
333 border-bottom: 1px solid black;
335 .top {
336 border-top: 1px solid black;
338 .left {
339 border-left: 1px solid black;
341 .right {
342 border-right: 1px solid black;
344 .form-group {
345 margin-bottom: 5px;
347 @media only screen and (max-width: 768px) {
348 [class*="col-"] {
349 width: 100%;
350 text-align: left!Important;
352 .navbar-toggle>span.icon-bar {
353 background-color: #68171A ! Important;
355 .navbar-default .navbar-toggle {
356 border-color: #4a4a4a;
358 .navbar-default .navbar-toggle:focus, .navbar-default .navbar-toggle:hover {
359 background-color: #f2f2f2 !Important;
360 font-weight: 900 !Important;
361 color: #000000 !Important;
363 .navbar-color {
364 background-color: #E5E5E5;
366 .icon-bar {
367 background-color: #68171A;
369 .navbar-header {
370 float: none;
372 .navbar-toggle {
373 display: block;
374 background-color: #f2f2f2;
376 .navbar-nav {
377 float: none!important;
379 .navbar-nav>li {
380 float: none;
382 .navbar-collapse.collapse.in {
383 z-index: 100;
384 background-color: #dfdfdf;
385 font-weight: 700;
386 color: #000000 !Important;
389 .table {
390 margin: auto;
391 width: 90% !important;
393 @media (min-width: 992px) {
394 .modal-lg {
395 width: 1000px !Important;
398 .oe-modal-dialog {
399 width: 65% !Important;
401 .oe-modal-content {
402 padding: 20px 0px 20px 0px;
404 .modalclass {
405 overflow-x: hidden !Important;
407 </style>
408 <title><?php echo xlt("Search Payments"); ?></title>
409 <?php
410 $arrOeUiSettings = array(
411 'heading_title' => xl('Payments'),
412 'include_patient_name' => false,// use only in appropriate pages
413 'expandable' => true,
414 'expandable_files' => array("search_payments_xpd", "new_payment_xpd", "era_payments_xpd"),//all file names need suffix _xpd
415 'action' => "",//conceal, reveal, search, reset, link or back
416 'action_title' => "",
417 'action_href' => "",//only for actions - reset, link or back
418 'show_help_icon' => false,
419 'help_file_name' => ""
421 $oemr_ui = new OemrUI($arrOeUiSettings);
423 </head>
424 <body class="body_top" onload="OnloadAction()">
425 <div id="container_div" class="<?php echo $oemr_ui->oeContainer();?>">
426 <div class="row">
427 <div class="col-sm-12">
428 <div class="page-header">
429 <?php echo $oemr_ui->pageHeading() . "\r\n"; ?>
430 </div>
431 </div>
432 </div>
433 <div class="row">
434 <div class="col-sm-12">
435 <nav class="navbar navbar-default navbar-color navbar-static-top" >
436 <div class="container-fluid">
437 <div class="navbar-header">
438 <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>
439 </div>
440 <div class="collapse navbar-collapse" id="myNavbar" >
441 <ul class="nav navbar-nav" >
442 <li class="oe-bold-black">
443 <a href='new_payment.php' style="font-weight:700; color:#000000"><?php echo xlt('New Payment'); ?></a>
444 </li>
445 <li class="active oe-bold-black" >
446 <a href='search_payments.php' style="font-weight:700; color:#000000"><?php echo xlt('Search Payment'); ?></a>
447 </li>
448 <li class="oe-bold-black">
449 <a href='era_payments.php' style="font-weight:700; color:#000000"><?php echo xlt('ERA Posting'); ?></a>
450 </li>
451 </ul>
452 </div>
453 </div>
454 </nav>
455 </div>
456 </div>
457 <div class="row">
458 <div class="col-sm-12">
459 <form id="new_payment" method='post' name='new_payment' style="display:inline">
460 <fieldset>
461 <div class="col-xs-12 h3">
462 <?php echo xlt('Payment List'); ?>
463 </div>
464 <div class="col-xs-12 oe-custom-line">
465 <div class="forms col-xs-2">
466 <label class="control-label" for="payment_date"><?php echo xlt('Payment date'); ?>:</label>
467 <?php echo generate_select_list("payment_date", "payment_date", "$PaymentDate", "Payment Date", "", "");?>
468 </div>
469 <div class="forms col-xs-2">
470 <label class="control-label" for="FromDate"><?php echo xlt('From'); ?>:</label>
471 <input class="form-control datepicker" id='FromDate' name='FromDate' type='text' value='<?php echo attr($FromDate); ?>'>
472 </div>
473 <div class="forms col-xs-2">
474 <label class="control-label" for="ToDate"><?php echo xlt('To'); ?>:</label>
475 <input class="form-control datepicker" id='ToDate' name='ToDate' type='text' value='<?php echo attr($ToDate); ?>'>
476 </div>
477 <div class="forms col-xs-3">
478 <label class="control-label" for="payment_method"><?php echo xlt('Payment Method'); ?>:</label>
479 <?php echo generate_select_list("payment_method", "payment_method", "$PaymentMethod", "Payment Method", " ", "");?>
480 </div>
481 <div class="forms col-xs-3">
482 <label class="control-label" for="check_number"><?php echo xlt('Check Number'); ?>:</label>
483 <input autocomplete="off" class="form-control" id="check_number" name="check_number" type="text" value="<?php echo htmlspecialchars(formData('check_number'));?>">
484 </div>
485 </div>
486 <div class="col-xs-12 oe-custom-line">
487 <div class="forms col-xs-4">
488 <label class="control-label" for="payment_method"><?php echo xlt('Payment Amount'); ?>:</label>
489 <input autocomplete="off" class="form-control" id="payment_amount" name="payment_amount" onkeyup="ValidateNumeric(this);" type="text" value="<?php echo htmlspecialchars(formData('payment_amount'));?>">
490 </div>
491 <div class="forms col-xs-2">
492 <label class="control-label" for="type_name"><?php echo xlt('Paying Entity'); ?>:</label>
493 <?php echo generate_select_list("type_name", "payment_type", "$type_name", "Paying Entity", " ", "", "SearchPayingEntityAction()");?>
494 </div>
495 <div class="forms col-xs-3">
496 <label class="control-label" for="adjustment_code"><?php echo xlt('Payment Category'); ?>:</label>
497 <?php echo generate_select_list("adjustment_code", "payment_adjustment_code", "$adjustment_code", "Paying Category", " ", "");?>
498 </div>
499 <div class="forms col-xs-3">
500 <label class="control-label" for="PaymentStatus"><?php echo xlt('Pay Status'); ?>:</label>
501 <?php echo generate_select_list("PaymentStatus", "payment_status", "$PaymentStatus", "Pay Status", " ", "");?>
502 </div>
503 </div>
504 <div class="col-xs-12 oe-custom-line">
505 <div class="forms col-xs-4">
506 <label class="control-label" for="type_code"><?php echo xlt('Payment From'); ?>:</label>
507 <input id="hidden_ajax_close_value" type="hidden" value="<?php echo htmlspecialchars($div_after_save);?>">
508 <input autocomplete="off" class="form-control" id='type_code' name='type_code' onkeydown="PreventIt(event)" type="text" value="<?php echo htmlspecialchars($div_after_save);?>">
509 <!--onKeyUp="ajaxFunction(event,'non','search_payments.php');"-->
510 <div id='ajax_div_insurance_section'>
511 <div id='ajax_div_insurance_error'></div>
512 <div id="ajax_div_insurance" style="display:none;"></div>
513 </div>
514 </div>
515 <div class="forms col-xs-2">
516 <label class="control-label" for="div_insurance_or_patient"><?php echo xlt('Payor ID'); ?>:</label>
517 <div class="form-control" id="div_insurance_or_patient"><?php echo htmlspecialchars(formData('hidden_type_code'));?></div>
518 <input id="description" name="description" type="hidden">
519 <input id="deposit_date" name="deposit_date" style="display:none" type="text">
520 </div>
521 <div class="forms col-xs-3">
522 <label class="control-label" for="PaymentSortBy"><?php echo xlt('Sort Result by'); ?>:</label>
523 <?php echo generate_select_list("PaymentSortBy", "payment_sort_by", "$PaymentSortBy", "Sort Result by", " ", "");?>
524 </div>
525 </div>
526 </fieldset><!--End of Search-->
527 <?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 ?>
528 <div class="form-group clearfix">
529 <div class="col-sm-12 text-left position-override">
530 <div class="btn-group" role="group">
531 <a class="btn btn-default btn-search" href="#" onclick="javascript:return SearchPayment();"><span><?php echo xlt('Search');?></span></a>
532 </div>
533 </div>
534 </div>
535 <?php
536 if ($_POST["mode"] == "SearchPayment") {
537 echo "&nbsp;" ."<br>"; // do not remove else below div will not display !!
539 <div class = "table-responsive">
540 <table class="table">
541 <?php
542 if (sqlNumRows($ResultSearch)>0) {
544 <thead bgcolor="#DDDDDD" class="">
545 <td class="left top" width="25">&nbsp;</td>
546 <td class="left top"><?php echo htmlspecialchars(xl('ID'), ENT_QUOTES) ?></td>
547 <td class="left top" ><?php echo htmlspecialchars(xl('Date'), ENT_QUOTES) ?></td>
548 <td class="left top" ><?php echo htmlspecialchars(xl('Paying Entity'), ENT_QUOTES) ?></td>
549 <td class="left top" ><?php echo htmlspecialchars(xl('Payer'), ENT_QUOTES) ?></td>
550 <td class="left top" ><?php echo htmlspecialchars(xl('Ins Code'), ENT_QUOTES) ?></td>
551 <td class="left top" ><?php echo htmlspecialchars(xl('Payment Method'), ENT_QUOTES) ?></td>
552 <td class="left top" ><?php echo htmlspecialchars(xl('Check Number'), ENT_QUOTES) ?></td>
553 <td class="left top" ><?php echo htmlspecialchars(xl('Pay Status'), ENT_QUOTES) ?></td>
554 <td class="left top" ><?php echo htmlspecialchars(xl('Payment'), ENT_QUOTES) ?></td>
555 <td class="left top right" ><?php echo htmlspecialchars(xl('Undistributed'), ENT_QUOTES) ?></td>
556 </thead>
557 <?php
558 $CountIndex=0;
559 while ($RowSearch = sqlFetchArray($ResultSearch)) {
560 $Payer='';
561 if ($RowSearch['payer_id']*1 >0) {
562 //-------------------
563 $res = sqlStatement("SELECT insurance_companies.name FROM insurance_companies
564 where insurance_companies.id ='{$RowSearch['payer_id']}'");
565 $row = sqlFetchArray($res);
566 $Payer=$row['name'];
567 //-------------------
568 } elseif ($RowSearch['patient_id']*1 >0) {
569 //-------------------
570 $res = sqlStatement("SELECT fname,lname,mname FROM patient_data
571 where pid ='{$RowSearch['patient_id']}'");
572 $row = sqlFetchArray($res);
573 $fname=$row['fname'];
574 $lname=$row['lname'];
575 $mname=$row['mname'];
576 $Payer=$lname.' '.$fname.' '.$mname;
577 //-------------------
579 //=============================================
580 $CountIndex++;
581 if ($CountIndex==sqlNumRows($ResultSearch)) {
582 $StringClass=' bottom left top ';
583 } else {
584 $StringClass=' left top ';
586 if ($CountIndex%2==1) {
587 $bgcolor='#ddddff';
588 } else {
589 $bgcolor='#ffdddd';
592 <tr bgcolor='<?php echo $bgcolor; ?>' class="text">
593 <td class="<?php echo $StringClass; ?>">
594 <!--<a href="#" onclick="javascript:return DeletePayments(&lt;?php echo htmlspecialchars($RowSearch['session_id']); ?&gt;);"><img border="0" src="../pic/Delete.gif"></a>-->
596 <a href="#" onclick="javascript:return DeletePayments(<?php echo htmlspecialchars($RowSearch['session_id']); ?>);"><img border="0" src="../pic/Delete.gif"></a>
597 </td>
598 <td class="<?php echo $StringClass; ?>">
599 <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>
600 </td>
601 <td class="<?php echo $StringClass; ?>">
602 <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>
603 </td>
604 <td class="<?php echo $StringClass; ?>">
605 <a class="" data-toggle="modal" data-target="#myModal" onclick="loadiframe('edit_payment.php?payment_id=<?php echo htmlspecialchars($RowSearch['session_id']); ?>')">
606 <?php
607 $frow['data_type']=1;
608 $frow['list_id']='payment_type';
609 $PaymentType='';
610 if ($RowSearch['payment_type']=='insurance' || $RowSearch['payer_id']*1 >0) {
611 $PaymentType='insurance';
612 } elseif ($RowSearch['payment_type']=='patient' || $RowSearch['patient_id']*1 >0) {
613 $PaymentType='patient';
614 } elseif (($RowSearch['payer_id']*1 == 0 && $RowSearch['patient_id']*1 == 0)) {
615 $PaymentType='';
617 generate_print_field($frow, $PaymentType);
618 ?></a>
619 </td>
620 <td class="<?php echo $StringClass; ?>">
621 <!--<a class='iframe medium_modal' href="edit_payment.php?payment_id=<?php echo htmlspecialchars($RowSearch['session_id']); ?>"><?php echo $Payer=='' ? '&nbsp;' : htmlspecialchars($Payer) ;?></a>-->
622 <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-->
623 </td>
624 <td class="<?php echo $StringClass; ?>">
625 <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>
626 </td>
627 <td align="left" class="<?php echo $StringClass; ?>">
628 <!--<a class='iframe medium_modal' href="edit_payment.php?payment_id=<?php echo htmlspecialchars($RowSearch['session_id']); ?>"><?php
629 $frow['data_type']=1;
630 $frow['list_id']='payment_method';
631 generate_print_field($frow, $RowSearch['payment_method']);
632 ?></a>-->
633 <a class="" data-toggle="modal" data-target="#myModal" onclick="loadiframe('edit_payment.php?payment_id=<?php echo htmlspecialchars($RowSearch['session_id']); ?>')">
634 <?php
635 $frow['data_type']=1;
636 $frow['list_id']='payment_method';
637 generate_print_field($frow, $RowSearch['payment_method']);
638 ?></a>
639 </td>
640 <td align="left" class="<?php echo $StringClass; ?>">
641 <!--<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>-->
642 <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>
643 </td>
644 <td align="left" class="<?php echo $StringClass; ?>">
645 <a class="" data-toggle="modal" data-target="#myModal" onclick="loadiframe('edit_payment.php?payment_id=<?php echo htmlspecialchars($RowSearch['session_id']); ?>')"><?php
646 $rs= sqlStatement("select pay_total,global_amount from ar_session where session_id='".$RowSearch['session_id']."'");
647 $row=sqlFetchArray($rs);
648 $pay_total=$row['pay_total'];
649 $global_amount=$row['global_amount'];
650 $rs= sqlStatement("select sum(pay_amount) sum_pay_amount from ar_activity where session_id='".$RowSearch['session_id']."'");
651 $row=sqlFetchArray($rs);
652 $pay_amount=$row['sum_pay_amount'];
653 $UndistributedAmount=$pay_total-$pay_amount-$global_amount;
654 echo $UndistributedAmount*1==0 ? htmlspecialchars(xl('Fully Paid'), ENT_QUOTES) : htmlspecialchars(xl('Unapplied'), ENT_QUOTES); ?></a>
655 </td>
656 <td align="right" class="<?php echo $StringClass; ?>">
657 <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>
658 </td>
659 <td align="right" class="<?php echo $StringClass; ?>right">
660 <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>
661 </td>
662 </tr>
663 <?php
664 }//End of while ($RowSearch = sqlFetchArray($ResultSearch))
665 } //End of if(sqlNumRows($ResultSearch)>0)
666 else {
668 <tr>
669 <td class="text" colspan="11"><?php echo htmlspecialchars(xl('No Result Found, for the above search criteria.'), ENT_QUOTES) ?></td>
670 </tr>
671 <?php
672 }// End of else
674 </table>
675 </div><!--End of table-responsive div-->
676 <?php
677 }// End of if ($_POST["mode"] == "SearchPayment")
679 <div class="row">
680 <input id='mode' name='mode' type='hidden' value=''>
681 <input id='ajax_mode' name='ajax_mode' type='hidden' value=''>
682 <input id="hidden_type_code" name="hidden_type_code" type="hidden" value="<?php echo htmlspecialchars(formData('hidden_type_code'));?>">
683 <input id='DeletePaymentId' name='DeletePaymentId' type='hidden' value=''>
684 <input id='SortFieldOld' name='SortFieldOld' type='hidden' value='<?php echo attr($PaymentSortBy);?>'>
685 <input id='Sort' name='Sort' type='hidden' value='<?php echo attr($Sort);?>'>
686 <input id="after_value" name="after_value" type="hidden" value="<?php echo htmlspecialchars($Message);?>">
687 </div>
688 </form>
689 </div>
690 </div>
691 </div><!--end of container div-->
692 <?php $oemr_ui->oeBelowContainerDiv();?>
693 </body>
694 </html>