From ad5ada56fc812d4956e7d97b824c872c98a50798 Mon Sep 17 00:00:00 2001 From: demeritcowboy Date: Tue, 19 Jul 2022 19:36:55 -0400 Subject: [PATCH] fix crash removing an entry from a batch --- CRM/Financial/Page/BatchTransaction.php | 2 +- .../CRM/Financial/Page/BatchTransaction.tpl | 17 +++++++++++++++++ 2 files changed, 18 insertions(+), 1 deletion(-) diff --git a/CRM/Financial/Page/BatchTransaction.php b/CRM/Financial/Page/BatchTransaction.php index 9f2221fb02..381e5cdf21 100644 --- a/CRM/Financial/Page/BatchTransaction.php +++ b/CRM/Financial/Page/BatchTransaction.php @@ -67,7 +67,7 @@ class CRM_Financial_Page_BatchTransaction extends CRM_Core_Page_Basic { 'remove' => [ 'name' => ts('Remove'), 'title' => ts('Remove Transaction'), - 'extra' => 'onclick = "assignRemove( %%id%%,\'' . 'remove' . '\' );"', + 'extra' => 'onclick = "removeFromBatch(%%id%%);"', ], ]; } diff --git a/templates/CRM/Financial/Page/BatchTransaction.tpl b/templates/CRM/Financial/Page/BatchTransaction.tpl index 1b1519723e..3ef7cb77d6 100644 --- a/templates/CRM/Financial/Page/BatchTransaction.tpl +++ b/templates/CRM/Financial/Page/BatchTransaction.tpl @@ -114,6 +114,23 @@ function assignRemove(recordID, op) { } } +function removeFromBatch(financial_trxn_id) { + var entityID = "{/literal}{$entityID}{literal}"; + if (financial_trxn_id && entityID) { + CRM.api4("EntityBatch", "delete", {where: [ + ["entity_id", "=", financial_trxn_id], + ["entity_table", "=", "civicrm_financial_trxn"], + ["batch_id", "=", entityID] + ]}).then(function(batch) { + buildTransactionSelectorAssign(true); + buildTransactionSelectorRemove(); + batchSummary(entityID); + }, function(failure) { + CRM.alert({/literal}'{ts escape="js"}Error removing from batch.{/ts}', '{ts escape="js"}Api Error{/ts}'{literal}, 'error'); + }); + } +} + function noServerResponse() { CRM.alert({/literal}'{ts escape="js"}No response from the server. Check your internet connection and try reloading the page.{/ts}', '{ts escape="js"}Network Error{/ts}'{literal}, 'error'); } -- 2.25.1