Skip to content

Commit

Permalink
php8 fixes for batch payments (openemr#5819)
Browse files Browse the repository at this point in the history
* more php8 fixes for batch payments

* one more int cast

* broken link in search payments

* remove unused script
  • Loading branch information
stephenwaite authored Oct 11, 2022
1 parent 1475375 commit 85bc939
Show file tree
Hide file tree
Showing 3 changed files with 21 additions and 27 deletions.
33 changes: 16 additions & 17 deletions interface/billing/edit_payment.php
Original file line number Diff line number Diff line change
Expand Up @@ -141,7 +141,7 @@
"'";

$where = "$where1 AND pay_amount > 0";
if (isset($_POST["Payment$CountRow"]) && $_POST["Payment$CountRow"] * 1 > 0) {
if (!empty($_POST["Payment$CountRow"])) {
if (trim($_POST['type_name']) == 'insurance') {
if (trim($_POST["HiddenIns$CountRow"]) == 1) {
$AccountCode = "IPP";
Expand Down Expand Up @@ -227,7 +227,7 @@
//==============================================================================================================================

$where = "$where1 AND (memo LIKE 'Deductable%' OR memo LIKE 'Deductible%')";
if (isset($_POST["Deductible$CountRow"]) && $_POST["Deductible$CountRow"] * 1 > 0) {
if (!empty($_POST["Deductible$CountRow"])) {
$resPayment = sqlStatement("SELECT * from ar_activity $where");
if (sqlNumRows($resPayment) > 0) {
sqlStatement("update ar_activity set deleted = NOW() $where");
Expand Down Expand Up @@ -259,7 +259,7 @@
//==============================================================================================================================

$where = "$where1 AND pay_amount < 0";
if (isset($_POST["Takeback$CountRow"]) && $_POST["Takeback$CountRow"] * 1 > 0) {
if (!empty($_POST["Takeback$CountRow"])) {
$resPayment = sqlStatement("SELECT * from ar_activity $where");
if (sqlNumRows($resPayment) > 0) {
sqlStatement("update ar_activity set deleted = NOW() $where");
Expand Down Expand Up @@ -337,7 +337,10 @@
}

if ($_REQUEST['global_amount'] == 'yes') {
sqlStatement("update ar_session set global_amount=? where session_id =?", [(isset($_POST["HidUnappliedAmount"]) ? trim($_POST["HidUnappliedAmount"]) * 1 : ''), $payment_id]);
sqlStatement(
"update ar_session set global_amount=? where session_id =?",
[(isset($_POST["HidUnappliedAmount"]) ? floatval($_POST["HidUnappliedAmount"]) : 0), $payment_id]
);
} elseif ($_REQUEST['global_reset'] == '-0.00') {
sqlStatement("update ar_session set global_amount=? where session_id =?", [0, $payment_id]);
}
Expand All @@ -354,7 +357,7 @@
//==============================================================================
//Search Code
//===============================================================================
$payment_id = ($payment_id ?? null) * 1 > 0 ? $payment_id : $_REQUEST['payment_id'];
$payment_id = !empty($payment_id) ? (int) $payment_id : (int) $_REQUEST['payment_id'];
$ResultSearchSub = sqlStatement(
"SELECT DISTINCT encounter, code_type, code, modifier, pid " .
"FROM ar_activity WHERE deleted IS NULL AND session_id = ? " .
Expand Down Expand Up @@ -625,22 +628,22 @@ function DeletePaymentDistribution(DeleteId) {//Confirms deletion of payment dis
}
?>
<?php
if ($payment_id * 1 == 0) {
if (empty($payment_id)) {
$onclick = "top.restoreSession();return SavePayment();";
} else {
$onclick = "return false;";
}
?>
<form class="form" name='new_payment' method='post' action="edit_payment.php" onsubmit='<?php echo $onclick; ?>'>
<?php
if ($payment_id * 1 > 0) { ?>
if (!empty($payment_id)) { ?>
<fieldset>
<?php
require_once("payment_master.inc.php"); //Check/cash details are entered here.
?>
<?php }//End of if($payment_id*1>0) ?>
<?php
if ($payment_id * 1 > 0) {//Distribution rows already in the database are displayed.
if (!empty($payment_id)) {//Distribution rows already in the database are displayed.
?>
<?php //
$resCount = sqlStatement(
Expand Down Expand Up @@ -884,8 +887,7 @@ function DeletePaymentDistribution(DeleteId) {//Confirms deletion of payment dis
[$payment_id, $PId, $Encounter, $Codetype, $Code, $Modifier]
);
$rowPayment = sqlFetchArray($resPayment);
$PaymentDB = $rowPayment['pay_amount'] ?? null * 1;
$PaymentDB = $PaymentDB == 0 ? '' : $PaymentDB;
$PaymentDB = floatval($rowPayment['pay_amount'] ?? null);

$resPayment = sqlStatement(
"SELECT pay_amount FROM ar_activity WHERE " .
Expand All @@ -894,8 +896,7 @@ function DeletePaymentDistribution(DeleteId) {//Confirms deletion of payment dis
[$payment_id, $PId, $Encounter, $Codetype, $Code, $Modifier]
);
$rowPayment = sqlFetchArray($resPayment);
$TakebackDB = ($rowPayment['pay_amount'] ?? null) * -1;
$TakebackDB = $TakebackDB == 0 ? '' : $TakebackDB;
$TakebackDB = floatval($rowPayment['pay_amount'] ?? null);

$resPayment = sqlStatement(
"SELECT adj_amount FROM ar_activity WHERE " .
Expand All @@ -904,8 +905,7 @@ function DeletePaymentDistribution(DeleteId) {//Confirms deletion of payment dis
[$payment_id, $PId, $Encounter, $Codetype, $Code, $Modifier]
);
$rowPayment = sqlFetchArray($resPayment);
$AdjAmountDB = $rowPayment['adj_amount'] * 1;
$AdjAmountDB = $AdjAmountDB == 0 ? '' : $AdjAmountDB;
$AdjAmountDB = floatval($rowPayment['adj_amount'] ?? null);

$resPayment = sqlStatement(
"SELECT memo FROM ar_activity WHERE " .
Expand Down Expand Up @@ -943,7 +943,6 @@ function DeletePaymentDistribution(DeleteId) {//Confirms deletion of payment dis
} else {
$AllowedDB = 0;
}
$AllowedDB = $AllowedDB === 0 ? '' : $AllowedDB;

if ($Ins == 1) {
$bgcolor = '#ddddff';
Expand Down Expand Up @@ -1072,8 +1071,8 @@ function DeletePaymentDistribution(DeleteId) {//Confirms deletion of payment dis
<input type='hidden' name='global_amount' id='global_amount' value='' />
<input type='hidden' name='DeletePaymentDistributionId' id='DeletePaymentDistributionId' value='' />
<input type="hidden" name="ActionStatus" id="ActionStatus" value="<?php echo attr($Message ?? ''); ?>" />
<input type='hidden' name='CountIndexAbove' id='CountIndexAbove' value='<?php echo attr($CountIndexAbove * 1); ?>' />
<input type='hidden' name='CountIndexBelow' id='CountIndexBelow' value='<?php echo attr($CountIndexBelow * 1); ?>' />
<input type='hidden' name='CountIndexAbove' id='CountIndexAbove' value='<?php echo (int) attr($CountIndexAbove); ?>' />
<input type='hidden' name='CountIndexBelow' id='CountIndexBelow' value='<?php echo (int) attr($CountIndexBelow); ?>' />
<input type="hidden" name="ParentPage" id="ParentPage" value="<?php echo attr($_REQUEST['ParentPage'] ?? ''); ?>" />
</div>
</form>
Expand Down
8 changes: 4 additions & 4 deletions interface/billing/payment_pat_sel.inc.php
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@
//===============================================================================
if (isset($_POST["mode"])) {
if (
($_POST["mode"] == "search") || ($_POST["default_search_patient"] == "default_search_patient") &&
($_POST["mode"] == "search") || (($_POST["default_search_patient"] ?? null) == "default_search_patient") &&
isset($_REQUEST['hidden_patient_code']) &&
(int)$_REQUEST['hidden_patient_code'] > 0
) {
Expand All @@ -46,9 +46,9 @@
$res = sqlStatement("SELECT fname,lname,mname FROM patient_data
where pid =?", array($hidden_patient_code));
$row = sqlFetchArray($res);
$fname = $row['fname'];
$lname = $row['lname'];
$mname = $row['mname'];
$fname = $row['fname'] ?? '';
$lname = $row['lname'] ?? '';
$mname = $row['mname'] ?? '';
$NameNew = $lname . ' ' . $fname . ' ' . $mname;
}
}
Expand Down
7 changes: 1 addition & 6 deletions interface/billing/search_payments.php
Original file line number Diff line number Diff line change
Expand Up @@ -533,7 +533,7 @@ function SearchPayingEntityAction() {
</td>
<td>
<!--<a class='iframe medium_modal' href="edit_payment.php?payment_id=<?php echo htmlspecialchars($RowSearch['session_id']); ?>"><?php echo $Payer == '' ? '&nbsp;' : htmlspecialchars($Payer); ?></a>-->
<a class="medium_modal" data-target="#myModal1" data-toggle="modal" onclick="loadiframe('edit_payment.php?payment_id=<?php echo attr_url($RowSearch['session_id']); ?>"><?php echo $Payer == '' ? '&nbsp;' : text($Payer); ?></a><!--link to iframe-->
<a class="medium_modal" href='edit_payment.php?payment_id=<?php echo attr_url($RowSearch['session_id']); ?>')"><?php echo $Payer == '' ? '&nbsp;' : text($Payer); ?></a><!--link to iframe-->
</td>
<td>
<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']) : '&nbsp;'; ?></a>
Expand Down Expand Up @@ -608,10 +608,5 @@ function SearchPayingEntityAction() {
</div>
</div><!--end of container div-->
<?php $oemr_ui->oeBelowContainerDiv(); ?>
<script>
function loadiframe(htmlHref) { //load iframe
document.getElementById('targetiframe1').src = htmlHref;
}
</script>
</body>
</html>

0 comments on commit 85bc939

Please sign in to comment.