4 * Payments in database can be searched through this screen and edit popup is also its part.
5 * Deletion of the payment is done with logging.
9 * @link http://www.open-emr.org
10 * @author Eldho Chacko <eldho@zhservices.com>
11 * @author Paul Simon K <paul@zhservices.com>
12 * @author Brady Miller <brady.g.miller@gmail.com>
13 * @author Rod Roark <rod@sunsetsystems.com>
14 * @copyright Copyright (c) 2010 Z&H Consultancy Services Private Limited <sam@zhservices.com>
15 * @copyright Copyright (c) 2019-2020 Brady Miller <brady.g.miller@gmail.com>
16 * @copyright Copyright (c) 2020 Rod Roark <rod@sunsetsystems.com>
17 * @license https://github.com/openemr/openemr/blob/master/LICENSE GNU General Public License 3
20 require_once("../globals.php");
21 require_once("../../custom/code_types.inc.php");
22 require_once("$srcdir/patient.inc.php");
23 require_once("$srcdir/options.inc.php");
24 require_once("$srcdir/payment.inc.php");
26 use OpenEMR\Common\Acl\AclMain
;
27 use OpenEMR\Common\Twig\TwigContainer
;
28 use OpenEMR\Core\Header
;
29 use OpenEMR\Events\Billing\Payments\DeletePayment
;
30 use OpenEMR\OeUI\OemrUI
;
32 if (!AclMain
::aclCheckCore('acct', 'bill', '', 'write') && !AclMain
::aclCheckCore('acct', 'eob', '', 'write')) {
33 echo (new TwigContainer(null, $GLOBALS['kernel']))->getTwig()->render('core/unauthorized.html.twig', ['pageTitle' => xl("Search Payment")]);
38 * @var EventDispatcherInterface $eventDispatcher
40 $eventDispatcher = $GLOBALS['kernel']->getEventDispatcher();
42 //===============================================================================
43 //Deletion of payment and its corresponding distributions.
44 //===============================================================================
46 if (isset($_POST["mode"])) {
47 if ($_POST["mode"] == "DeletePayments") {
48 $DeletePaymentId = isset($_POST['DeletePaymentId']) ?
trim($_POST['DeletePaymentId']) : '';
49 $ResultSearch = sqlStatement(
50 "SELECT distinct encounter, pid from ar_activity where deleted IS NULL AND session_id = ?",
53 if (sqlNumRows($ResultSearch) > 0) {
54 while ($RowSearch = sqlFetchArray($ResultSearch)) {
55 $Encounter = $RowSearch['encounter'];
56 $PId = $RowSearch['pid'];
57 sqlStatement("update form_encounter set last_level_closed=last_level_closed - 1 where pid =? and encounter=?", [$PId, $Encounter]);
60 //dispatch this payment is being deleted trigger refund process
61 $eventDispatcher->dispatch(new DeletePayment($DeletePaymentId), DeletePayment
::ACTION_DELETE_PAYMENT
, 10);
62 //delete and log that action
63 row_delete("ar_session", "session_id ='" . add_escape_custom($DeletePaymentId) . "'");
64 row_modify("ar_activity", "deleted = NOW()", "deleted IS NULL AND session_id = '" . add_escape_custom($DeletePaymentId) . "'");
67 $_POST["mode"] = "SearchPayment";
70 //===============================================================================
72 //===============================================================================
73 if ($_POST["mode"] == "SearchPayment") {
74 $FromDate = isset($_POST['FromDate']) ?
trim($_POST['FromDate']) : '';
75 $ToDate = isset($_POST['ToDate']) ?
trim($_POST['ToDate']) : '';
76 $PaymentMethod = isset($_POST['payment_method']) ?
trim($_POST['payment_method']) : '';
77 $CheckNumber = isset($_POST['check_number']) ?
trim($_POST['check_number']) : '';
78 $PaymentAmount = isset($_POST['payment_amount']) ?
trim($_POST['payment_amount']) : '';
79 $PayingEntity = isset($_POST['type_name']) ?
trim($_POST['type_name']) : '';
80 $PaymentCategory = isset($_POST['adjustment_code']) ?
trim($_POST['adjustment_code']) : '';
81 $PaymentFrom = isset($_POST['hidden_type_code']) ?
trim($_POST['hidden_type_code']) : '';
82 $PaymentStatus = isset($_POST['PaymentStatus']) ?
trim($_POST['PaymentStatus']) : '';
83 $PaymentSortBy = isset($_POST['PaymentSortBy']) ?
trim($_POST['PaymentSortBy']) : '';
84 $PaymentDate = isset($_POST['payment_date']) ?
trim($_POST['payment_date']) : '';
85 $QueryString = "Select * from ar_session where ";
88 $sqlBindArray = array();
90 if ($PaymentDate == 'date_val') {
91 $PaymentDateString = ' check_date ';
92 } elseif ($PaymentDate == 'post_to_date') {
93 $PaymentDateString = ' post_to_date ';
94 } elseif ($PaymentDate == 'deposit_date') {
95 $PaymentDateString = ' deposit_date ';
98 if ($FromDate != '') {
99 $QueryString .= " $And $PaymentDateString >=?";
101 $sqlBindArray[] = DateToYYYYMMDD($FromDate);
105 $QueryString .= " $And $PaymentDateString <=?";
107 $sqlBindArray[] = DateToYYYYMMDD($ToDate);
110 if ($PaymentMethod != '') {
111 $QueryString .= " $And payment_method =?";
113 $sqlBindArray[] = $PaymentMethod;
116 if ($CheckNumber != '') {
117 $QueryString .= " $And reference like ?";
119 $sqlBindArray[] = '%' . $CheckNumber . '%';
122 if ($PaymentAmount != '') {
123 $QueryString .= " $And pay_total =?";
125 $sqlBindArray[] = $PaymentAmount;
128 if ($PayingEntity != '') {
129 if ($PayingEntity == 'insurance') {
130 $QueryString .= " $And payer_id !='0'";
133 if ($PayingEntity == 'patient') {
134 $QueryString .= " $And payer_id ='0'";
140 if ($PaymentCategory != '') {
141 $QueryString .= " $And adjustment_code =?";
143 $sqlBindArray[] = $PaymentCategory;
146 if ($PaymentFrom != '') {
147 if ($PayingEntity == 'insurance' ||
$PayingEntity == '') {
148 //-------------------
149 $res = sqlStatement("SELECT insurance_companies.name FROM insurance_companies
150 where insurance_companies.id =?", [$PaymentFrom]);
151 $row = sqlFetchArray($res);
152 $div_after_save = $row['name'];
153 //-------------------
155 $QueryString .= " $And payer_id =?";
156 $sqlBindArray[] = $PaymentFrom;
159 if ($PayingEntity == 'patient') {
160 //-------------------
161 $res = sqlStatement("SELECT fname,lname,mname FROM patient_data
162 where pid =?", [$PaymentFrom]);
163 $row = sqlFetchArray($res);
164 $fname = $row['fname'];
165 $lname = $row['lname'];
166 $mname = $row['mname'];
167 $div_after_save = $lname . ' ' . $fname . ' ' . $mname;
168 //-------------------
170 $QueryString .= " $And patient_id =?";
171 $sqlBindArray[] = $PaymentFrom;
177 if ($PaymentStatus != '') {
178 $QsString = "select ar_session.session_id, pay_total, global_amount, sum(pay_amount) sum_pay_amount " .
179 "from ar_session,ar_activity WHERE " .
180 "ar_activity.deleted IS NULL AND ar_session.session_id = ar_activity.session_id " .
181 "group by ar_activity.session_id, ar_session.session_id " .
182 "having pay_total - global_amount - sum_pay_amount = 0 or pay_total = 0";
183 $rs = sqlStatement($QsString);
184 while ($rowrs = sqlFetchArray($rs)) {
185 $StringSessionId .= $rowrs['session_id'] . ',';
188 $QsString = "select ar_session.session_id from ar_session where pay_total=0";
189 $rs = sqlStatement($QsString);
190 while ($rowrs = sqlFetchArray($rs)) {
191 $StringSessionId .= $rowrs['session_id'] . ',';
194 $StringSessionId = substr($StringSessionId, 0, -1);
195 if ($PaymentStatus == 'fully_paid') {
196 $QueryString .= " $And session_id in(" . add_escape_custom($StringSessionId) . ") ";
197 } elseif ($PaymentStatus == 'unapplied') {
198 $QueryString .= " $And session_id not in(" . add_escape_custom($StringSessionId) . ") ";
204 if ($PaymentSortBy != '') {
205 $SortFieldOld = isset($_POST['SortFieldOld']) ?
trim($_POST['SortFieldOld']) : '';
206 $Sort = isset($_POST['Sort']) ?
trim($_POST['Sort']) : '';
207 if ($SortFieldOld == $PaymentSortBy) {
208 if ($Sort == 'DESC' ||
$Sort == '') {
217 $QueryString .= " order by " . escape_sql_column_name($PaymentSortBy, ['ar_session']) . " " . escape_sort_order($Sort);
220 $ResultSearch = sqlStatement($QueryString, $sqlBindArray);
224 //===============================================================================
229 <title
><?php
echo xlt("Search Payment") ?
></title
>
230 <?php Header
::setupHeader(['datetime-picker']); ?
>
232 <?php
include_once("{$GLOBALS['srcdir']}/payment_jav.inc.php"); ?
>
233 <?php
include_once("{$GLOBALS['srcdir']}/ajax/payment_ajax_jav.inc.php"); ?
>
236 function refreshSearch() {
237 top
.restoreSession();
242 <?php
if (!empty($_POST['mode']) && ($_POST['mode'] == 'SearchPayment')) { ?
>
243 $
("html").animate({ scrollTop
: $
("div table.table").offset().top
}, 800);
246 $
(".medium_modal").on('click', function (e
) {
249 dlgopen('', '', 'modal-full', 800, '', '', {
251 {text
: <?php
echo xlj('Close'); ?
>, close
: true, style
: 'default btn-sm'}
254 onClosed
: 'refreshSearch',
256 url
: $
(this
).attr('href')
260 $
('.datepicker').datetimepicker({
261 <?php
$datetimepicker_timepicker = false; ?
>
262 <?php
$datetimepicker_showseconds = false; ?
>
263 <?php
$datetimepicker_formatInput = true; ?
>
264 <?php
require($GLOBALS['srcdir'] . '/js/xl/jquery-datetimepicker-2-5-4.js.php'); ?
>
265 <?php
// can add any additional javascript settings to datetimepicker here; need to prepend first setting with a comma ?>
271 function SearchPayment() {
272 // Search validations.
273 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
== '') {
274 alert(<?php
echo xlj('Please select any Search Option.'); ?
>);
277 if (document
.getElementById('FromDate').value
!= '' && document
.getElementById('ToDate').value
!= '') {
278 if (!DateCheckGreater(document
.getElementById('FromDate').value
, document
.getElementById('ToDate').value
, '<?php echo DateFormatRead();?>')) {
279 alert(<?php
echo xlj('From Date Cannot be Greater than To Date.'); ?
>);
280 document
.getElementById('FromDate').focus();
284 top
.restoreSession();
285 document
.getElementById('mode').value
= 'SearchPayment';
286 document
.forms
[0].submit();
289 function DeletePayments(DeleteId
) {
290 // Confirms deletion of payment and all its distribution.
291 if (confirm(<?php
echo xlj('Would you like to Delete Payments?'); ?
>)) {
292 document
.getElementById('mode').value
= 'DeletePayments';
293 document
.getElementById('DeletePaymentId').value
= DeleteId
;
294 top
.restoreSession();
295 document
.forms
[0].submit();
300 function OnloadAction() {
301 // Displays message after deletion.
302 after_value
= document
.getElementById('after_value').value
;
303 if (after_value
== 'Delete') {
304 alert(<?php
echo xlj('Successfully Deleted'); ?
>)
308 function SearchPayingEntityAction() {
309 // Which ajax is to be active(patient,insurance), is decided by the 'Paying Entity' drop down, where this function is called.
310 // So on changing some initialization is need.Done below.
311 document
.getElementById('type_code').value
= '';
312 document
.getElementById('hidden_ajax_close_value').value
= '';
313 document
.getElementById('hidden_type_code').value
= '';
314 document
.getElementById('div_insurance_or_patient').innerHTML
= ' ';
315 document
.getElementById('description').value
= '';
316 if (document
.getElementById('ajax_div_insurance')) {
317 $
("#ajax_div_patient_error").empty();
318 $
("#ajax_div_patient").empty();
319 $
("#ajax_div_insurance_error").empty();
320 $
("#ajax_div_insurance").empty();
321 $
("#ajax_div_insurance").hide();
322 document
.getElementById('payment_method').style
.display
= '';
326 document
.onclick
= HideTheAjaxDivs
;
330 #ajax_div_insurance {
333 background
-color
: #FBFDD0;
334 border
: 1px solid
var(--gray
);
338 @media
(min
-width
: 992px
) {
340 width
: 1000px
!Important
;
345 $arrOeUiSettings = array(
346 'heading_title' => xl('Payments'),
347 'include_patient_name' => false,// use only in appropriate pages
348 'expandable' => true,
349 'expandable_files' => array("search_payments_xpd", "new_payment_xpd", "era_payments_xpd"),//all file names need suffix _xpd
350 'action' => "",//conceal, reveal, search, reset, link or back
351 'action_title' => "",
352 'action_href' => "",//only for actions - reset, link or back
353 'show_help_icon' => false,
354 'help_file_name' => ""
356 $oemr_ui = new OemrUI($arrOeUiSettings);
359 <body onload
="OnloadAction()">
360 <div id
="container_div" class="<?php echo attr($oemr_ui->oeContainer()); ?> mt-3">
362 <div
class="col-sm-12">
363 <?php
echo $oemr_ui->pageHeading() . "\r\n"; ?
>
366 <nav
class="navbar navbar-nav navbar-expand-md navbar-light text-body bg-light mb-4 p-4">
367 <button
class="navbar-toggler icon-bar" data
-target
="#myNavbar" data
-toggle
="collapse" type
="button"><span
class="navbar-toggler-icon"></span
></button
>
368 <div
class="collapse navbar-collapse" id
="myNavbar">
369 <ul
class="navbar-nav mr-auto">
370 <li
class="nav-item">
371 <a
class="nav-link font-weight-bold" href
='new_payment.php'><?php
echo xlt('New Payment'); ?
></a
>
373 <li
class="nav-item">
374 <a
class="nav-link active font-weight-bold" href
='search_payments.php'><?php
echo xlt('Search Payment'); ?
></a
>
376 <li
class="nav-item">
377 <a
class="nav-link font-weight-bold" href
='era_payments.php'><?php
echo xlt('ERA Posting'); ?
></a
>
383 <div
class="col-sm-12">
384 <form id
="new_payment" method
='post' name
='new_payment'>
386 <div
class="jumbotron py-4">
388 <?php
echo xlt('Payment List'); ?
>
390 <div
class="row oe-custom-line">
391 <div
class="forms col-2">
392 <label
class="control-label" for="payment_date"><?php
echo xlt('Payment date'); ?
>:</label
>
393 <?php
echo generate_select_list("payment_date", "payment_date", ($PaymentDate ??
''), "Payment Date", "", ""); ?
>
395 <div
class="forms col-2">
396 <label
class="control-label" for="FromDate"><?php
echo xlt('From'); ?
>:</label
>
397 <input
class="form-control datepicker" id
='FromDate' name
='FromDate' type
='text' value
='<?php echo attr($FromDate ?? ''); ?>' autocomplete
="off" />
399 <div
class="forms col-2">
400 <label
class="control-label" for="ToDate"><?php
echo xlt('To{{Range}}'); ?
>:</label
>
401 <input
class="form-control datepicker" id
='ToDate' name
='ToDate' type
='text' value
='<?php echo attr($ToDate ?? ''); ?>' autocomplete
="off" />
403 <div
class="forms col-3">
404 <label
class="control-label" for="payment_method"><?php
echo xlt('Payment Method'); ?
>:</label
>
405 <?php
echo generate_select_list("payment_method", "payment_method", ($PaymentMethod ??
''), "Payment Method", " ", ""); ?
>
407 <div
class="forms col-3">
408 <label
class="control-label" for="check_number"><?php
echo xlt('Check Number'); ?
>:</label
>
409 <input autocomplete
="off" class="form-control" id
="check_number" name
="check_number" type
="text" value
="<?php echo attr($_POST['check_number'] ?? ''); ?>" />
412 <div
class="row oe-custom-line">
413 <div
class="forms col-4">
414 <label
class="control-label" for="payment_method"><?php
echo xlt('Payment Amount'); ?
>:</label
>
415 <input autocomplete
="off" class="form-control" id
="payment_amount" name
="payment_amount" onkeyup
="ValidateNumeric(this);" type
="text" value
="<?php echo attr($_POST['payment_amount'] ?? ''); ?>" />
417 <div
class="forms col-2">
418 <label
class="control-label" for="type_name"><?php
echo xlt('Paying Entity'); ?
>:</label
>
419 <?php
echo generate_select_list("type_name", "payment_type", ($type_name ??
''), "Paying Entity", " ", "", "SearchPayingEntityAction()"); ?
>
421 <div
class="forms col-3">
422 <label
class="control-label" for="adjustment_code"><?php
echo xlt('Payment Category'); ?
>:</label
>
423 <?php
echo generate_select_list("adjustment_code", "payment_adjustment_code", ($adjustment_code ??
''), "Paying Category", " ", ""); ?
>
425 <div
class="forms col-3">
426 <label
class="control-label" for="PaymentStatus"><?php
echo xlt('Pay Status'); ?
>:</label
>
427 <?php
echo generate_select_list("PaymentStatus", "payment_status", ($PaymentStatus ??
''), "Pay Status", " ", ""); ?
>
430 <div
class="row oe-custom-line">
431 <div
class="forms col-4">
432 <label
class="control-label" for="type_code"><?php
echo xlt('Payment From'); ?
>:</label
>
433 <input id
="hidden_ajax_close_value" type
="hidden" value
="<?php echo attr($div_after_save ?? ''); ?>" />
434 <input autocomplete
="off" class="form-control" id
='type_code' name
='type_code' onkeydown
="PreventIt(event)" type
="text" value
="<?php echo attr($div_after_save ?? ''); ?>" />
435 <!--onKeyUp
="ajaxFunction(event,'non','search_payments.php');"-->
436 <div id
='ajax_div_insurance_section'>
437 <div id
='ajax_div_insurance_error'></div
>
438 <div id
="ajax_div_insurance" style
="display:none;"></div
>
441 <div
class="forms col-2">
442 <label
class="control-label" for="div_insurance_or_patient"><?php
echo xlt('Payor ID'); ?
>:</label
>
443 <div
class="form-control" id
="div_insurance_or_patient"><?php
echo attr($_POST['hidden_type_code'] ??
''); ?
></div
>
444 <input id
="description" name
="description" type
="hidden" />
445 <input id
="deposit_date" name
="deposit_date" style
="display:none" type
="text" />
447 <div
class="forms col-3">
448 <label
class="control-label" for="PaymentSortBy"><?php
echo xlt('Sort Result by'); ?
>:</label
>
449 <?php
echo generate_select_list("PaymentSortBy", "payment_sort_by", ($PaymentSortBy ??
''), "Sort Result by", " ", ""); ?
>
452 <!-- 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
-->
453 <div
class="form-group mt-3">
454 <div
class="col-sm-12 text-left position-override">
455 <div
class="btn-group" role
="group">
456 <a
class="btn btn-primary btn-search" href
="#" onclick
="javascript:return SearchPayment();"><span
><?php
echo xlt('Search'); ?
></span
></a
>
461 </fieldset
><!--End of Search
-->
463 if (!empty($_POST["mode"]) && ($_POST["mode"] == "SearchPayment")) {
464 echo " " . "<br />"; // do not remove else below div will not display !!
466 <div
class="table-responsive-sm">
467 <table
class="table table-sm table-bordered">
469 if (sqlNumRows($ResultSearch) > 0) { ?
>
470 <thead
class="bg-dark text-light">
473 <th
><?php
echo xlt('ID'); ?
></th
>
474 <th
><?php
echo xlt('Date'); ?
></th
>
475 <th
><?php
echo xlt('Paying Entity'); ?
></th
>
476 <th
><?php
echo xlt('Payer'); ?
></th
>
477 <th
><?php
echo xlt('Ins Code'); ?
></th
>
478 <th
><?php
echo xlt('Payment Method'); ?
></th
>
479 <th
><?php
echo xlt('Check Number'); ?
></th
>
480 <th
><?php
echo xlt('Pay Status'); ?
></th
>
481 <th
><?php
echo xlt('Payment'); ?
></th
>
482 <th
><?php
echo xlt('Undistributed'); ?
></th
>
487 while ($RowSearch = sqlFetchArray($ResultSearch)) {
489 if ($RowSearch['payer_id'] * 1 > 0) {
490 //-------------------
491 $res = sqlStatement("SELECT insurance_companies.name FROM insurance_companies
492 where insurance_companies.id =?", [$RowSearch['payer_id']]);
493 $row = sqlFetchArray($res);
494 $Payer = $row['name'];
495 //-------------------
496 } elseif ($RowSearch['patient_id'] * 1 > 0) {
497 //-------------------
498 $res = sqlStatement("SELECT fname,lname,mname FROM patient_data
499 where pid =?", [$RowSearch['patient_id']]);
500 $row = sqlFetchArray($res);
501 $fname = $row['fname'];
502 $lname = $row['lname'];
503 $mname = $row['mname'];
504 $Payer = $lname . ' ' . $fname . ' ' . $mname;
505 //-------------------
507 //=============================================
509 if ($CountIndex %
2 == 1) {
510 $bgcolor = '#ddddff';
512 $bgcolor = '#ffdddd';
515 <tr bgcolor
='<?php echo attr($bgcolor); ?>' class="text">
517 <a href
="#" onclick
="javascript:return DeletePayments(<?php echo attr_js($RowSearch['session_id']); ?>);"><img border
="0" src
="../pic/Delete.gif"></a
>
520 <a
class="medium_modal" href
="edit_payment.php?payment_id=<?php echo attr_url($RowSearch['session_id']); ?>"><?php
echo text($RowSearch['session_id']); ?
></a
>
523 <a
class="medium_modal" href
='edit_payment.php?payment_id=<?php echo attr_url($RowSearch['session_id
']); ?>'"><?php echo $RowSearch['check_date'] == '0000-00-00' ? ' ' : text(oeFormatShortDate($RowSearch['check_date'])); ?></a>
526 <a class="medium_modal
" href='edit_payment.php?payment_id=<?php echo attr_url($RowSearch['session_id']); ?>'">
528 $frow['data_type'] = 1;
529 $frow['list_id'] = 'payment_type';
531 if ($RowSearch['payment_type'] == 'insurance' ||
$RowSearch['payer_id'] * 1 > 0) {
532 $PaymentType = 'insurance';
533 } elseif ($RowSearch['payment_type'] == 'patient' ||
$RowSearch['patient_id'] * 1 > 0) {
534 $PaymentType = 'patient';
535 } elseif (($RowSearch['payer_id'] * 1 == 0 && $RowSearch['patient_id'] * 1 == 0)) {
538 generate_print_field($frow, $PaymentType);
542 <!--<a
class='iframe medium_modal' href
="edit_payment.php?payment_id=<?php echo htmlspecialchars($RowSearch['session_id']); ?>"><?php
echo $Payer == '' ?
' ' : htmlspecialchars($Payer); ?
></a
>-->
543 <a
class="medium_modal" href
='edit_payment.php?payment_id=<?php echo attr_url($RowSearch['session_id
']); ?>')"><?php echo $Payer == '' ? ' ' : text($Payer); ?></a><!--link to iframe-->
546 <a class="medium_modal
" href='edit_payment.php?payment_id=<?php echo attr_url($RowSearch['session_id']); ?>'><?php echo $RowSearch['payer_id'] * 1 > 0 ? text($RowSearch['payer_id']) : ' '; ?></a>
548 <td class="text
-left
">
549 <!--<a class='iframe medium_modal' href="edit_payment
.php?payment_id
=<?php
echo attr_url($RowSearch['session_id']); ?
>"><?php
550 $frow['data_type'] = 1;
551 $frow['list_id'] = 'payment_method';
552 generate_print_field($frow, $RowSearch['payment_method']);
554 <a class="medium_modal
" href='edit_payment.php?payment_id=<?php echo attr_url($RowSearch['session_id']); ?>'">
556 $frow['data_type'] = 1;
557 $frow['list_id'] = 'payment_method';
558 generate_print_field($frow, $RowSearch['payment_method']);
561 <td
class="text-left">
562 <!--<a
class='iframe medium_modal' href
="edit_payment.php?payment_id=<?php echo attr_url($RowSearch['session_id']); ?>"><?php
echo $RowSearch['reference'] == '' ?
' ' : text($RowSearch['reference']); ?
></a
>-->
563 <a
class="medium_modal" href
='edit_payment.php?payment_id=<?php echo attr_url($RowSearch['session_id
']); ?>'"><?php echo $RowSearch['reference'] == '' ? ' ' : text($RowSearch['reference']); ?></a>
565 <td class="text
-left
">
566 <a class="medium_modal
" href='edit_payment.php?payment_id=<?php echo attr_url($RowSearch['session_id']); ?>'">
568 $rs = sqlStatement("select pay_total,global_amount from ar_session where session_id=?", [$RowSearch['session_id']]);
569 $row = sqlFetchArray($rs);
570 $pay_total = $row['pay_total'];
571 $global_amount = $row['global_amount'];
573 "select sum(pay_amount) sum_pay_amount from ar_activity where " .
574 "deleted IS NULL AND session_id = ?",
575 [$RowSearch['session_id']]
577 $row = sqlFetchArray($rs);
578 $pay_amount = $row['sum_pay_amount'];
579 $UndistributedAmount = $pay_total - $pay_amount - $global_amount;
580 echo $UndistributedAmount * 1 == 0 ?
xlt('Fully Paid') : xlt('Unapplied'); ?
></a
>
582 <td
class="text-right">
583 <a
class="medium_modal" href
='edit_payment.php?payment_id=<?php echo attr_url($RowSearch['session_id
']); ?>'"><?php echo text($RowSearch['pay_total']); ?></a>
585 <td class="<?php
echo attr($StringClass ??
''); ?
>right text
-right
">
586 <a class="medium_modal
" href='edit_payment.php?payment_id=<?php echo attr_url($RowSearch['session_id']); ?>'"><?php
echo text(number_format($UndistributedAmount, 2)); ?
></a
>
590 }// End of while ($RowSearch = sqlFetchArray($ResultSearch))
591 } else { // End of if(sqlNumRows($ResultSearch)>0)
594 <td
class="text" colspan
="11"><?php
echo xlt('No Result Found, for the above search criteria.'); ?
></td
>
600 </div
><!--End of table
-responsive div
-->
602 }// End of if ($_POST["mode"] == "SearchPayment")
605 <input id
='mode' name
='mode' type
='hidden' value
='' />
606 <input id
='ajax_mode' name
='ajax_mode' type
='hidden' value
='' />
607 <input id
="hidden_type_code" name
="hidden_type_code" type
="hidden" value
="<?php echo attr($_POST['hidden_type_code'] ?? ''); ?>" />
608 <input id
='DeletePaymentId' name
='DeletePaymentId' type
='hidden' value
='' />
609 <input id
='SortFieldOld' name
='SortFieldOld' type
='hidden' value
='<?php echo attr($PaymentSortBy ?? ''); ?>' />
610 <input id
='Sort' name
='Sort' type
='hidden' value
='<?php echo attr($Sort ?? ''); ?>' />
611 <input id
="after_value" name
="after_value" type
="hidden" value
="<?php echo attr($Message ?? ''); ?>" />
616 </div
><!--end of container div
-->
617 <?php
$oemr_ui->oeBelowContainerDiv(); ?
>