'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'),
}
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']);
}
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}},
'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':
$("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;