Skip to content

Commit

Permalink
Fix batch transaction export on D8/9
Browse files Browse the repository at this point in the history
  • Loading branch information
MegaphoneJon committed Mar 8, 2021
1 parent ed362c6 commit 10c5467
Show file tree
Hide file tree
Showing 4 changed files with 7 additions and 24 deletions.
4 changes: 2 additions & 2 deletions CRM/Batch/BAO/Batch.php
Original file line number Diff line number Diff line change
Expand Up @@ -450,8 +450,8 @@ public function links($context = NULL) {
'export' => [
'name' => ts('Export'),
'title' => ts('Export Batch'),
'url' => '#',
'extra' => 'rel="export"',
'url' => 'civicrm/financial/batch/export',
'qs' => 'reset=1&id=%%id%%&status=1',
],
'reopen' => [
'name' => ts('Re-open'),
Expand Down
2 changes: 0 additions & 2 deletions CRM/Financial/Form/Search.php
Original file line number Diff line number Diff line change
Expand Up @@ -41,8 +41,6 @@ public function setDefaultValues() {
}

public function buildQuickForm() {
CRM_Core_Resources::singleton()
->addScriptFile('civicrm', 'packages/jquery/plugins/jquery.redirect.min.js', 0, 'html-header');
$attributes = CRM_Core_DAO::getAttribute('CRM_Batch_DAO_Batch');
$attributes['total']['class'] = $attributes['item_count']['class'] = 'number';
$this->add('text', 'title', ts('Batch Name'), $attributes['title']);
Expand Down
4 changes: 0 additions & 4 deletions CRM/Financial/Page/AJAX.php
Original file line number Diff line number Diff line change
Expand Up @@ -198,10 +198,6 @@ public static function assignRemove() {
$params['id'] = $recordID;
break;

case 'export':
CRM_Utils_System::redirect("civicrm/financial/batch/export?reset=1&id=$recordID");
break;

case 'delete':
$params = $recordID;
break;
Expand Down
21 changes: 5 additions & 16 deletions templates/CRM/Financial/Form/Search.tpl
Original file line number Diff line number Diff line change
Expand Up @@ -214,9 +214,6 @@ CRM.$(function($) {
}

function saveRecords(records, op) {
if (op == 'export') {
return exportRecords(records);
}
var postUrl = CRM.url('civicrm/ajax/rest', 'className=CRM_Financial_Page_AJAX&fnName=assignRemove');
//post request and get response
$.post(postUrl, {records: records, recordBAO: 'CRM_Batch_BAO_Batch', op: op, key: {/literal}"{crmKey name='civicrm/ajax/ar'}"{literal}},
Expand All @@ -234,19 +231,6 @@ CRM.$(function($) {
'json').error(serverError);
}

function exportRecords(records) {
var query = {'batch_id': records, 'export_format': $('select.export-format').val()};
var exportUrl = CRM.url('civicrm/financial/batch/export', 'reset=1');
// jQuery redirect expects all query args as an object, so extract them from crm url
var urlParts = exportUrl.split('?');
$.each(urlParts[1].split('&'), function(key, val) {
var q = val.split('=');
query[q[0]] = q[1];
});
$().redirect(urlParts[0], query, 'GET');
setTimeout(function() {batchSelector.fnDraw();}, 4000);
}

function validateOp(records, op) {
switch (op) {
case 'reopen':
Expand Down Expand Up @@ -302,6 +286,11 @@ CRM.$(function($) {
$("input.select-row:checked").each(function() {
records.push($(this).attr('id').replace('check_', ''));
});
if (op == 'export') {
// No need for the modal pop-up, just proceed to the next screen.
window.location = CRM.url("civicrm/financial/batch/export", {reset: 1, id: records[0], status: 1});
return false;
}
editRecords(records, op);
}
return false;
Expand Down

0 comments on commit 10c5467

Please sign in to comment.