Fix batch transaction export on D8/9
authorJon Goldberg <jon@megaphonetech.com>
Mon, 8 Mar 2021 22:53:51 +0000 (17:53 -0500)
committerJon Goldberg <jon@megaphonetech.com>
Mon, 8 Mar 2021 23:44:18 +0000 (18:44 -0500)
CRM/Batch/BAO/Batch.php
CRM/Financial/Form/Search.php
CRM/Financial/Page/AJAX.php
templates/CRM/Financial/Form/Search.tpl

index 3bb93f140b70980255282f987bf5c2a0d85476ec..1f420a0c57787e8db840b464b0c7390d2300284a 100644 (file)
@@ -450,8 +450,8 @@ class CRM_Batch_BAO_Batch extends CRM_Batch_DAO_Batch {
         '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'),
index 069c6e0a9abdbf9a21f17a6e1ce0554df208d2c5..db9af59260b457010be88f9e3fa1dc46d610e17b 100644 (file)
@@ -41,8 +41,6 @@ class CRM_Financial_Form_Search extends CRM_Core_Form {
   }
 
   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']);
index bc2e2f7b5324ef8774965c666315c1240a1ca939..484d7a41d1cfc3fb5446b77e20b996dfdb770de8 100644 (file)
@@ -198,10 +198,6 @@ class CRM_Financial_Page_AJAX {
             $params['id'] = $recordID;
             break;
 
-          case 'export':
-            CRM_Utils_System::redirect("civicrm/financial/batch/export?reset=1&id=$recordID");
-            break;
-
           case 'delete':
             $params = $recordID;
             break;
index 3cc7b90473e29a9a712d6d77670bf018148f573e..3c10417481ff58fa3ed772e58f9b61053a4e189c 100644 (file)
@@ -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}},
@@ -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':
@@ -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;