Skip to content

Commit

Permalink
CRM-20614 Don't download export file until asked
Browse files Browse the repository at this point in the history
----------------------------------------
* CRM-20614: Donot Download Export file for Financial Batch
  https://issues.civicrm.org/jira/browse/CRM-20614
  • Loading branch information
pradpnayak committed May 22, 2017
1 parent fe25253 commit aeb7ff7
Show file tree
Hide file tree
Showing 3 changed files with 13 additions and 2 deletions.
5 changes: 4 additions & 1 deletion CRM/Batch/BAO/Batch.php
Original file line number Diff line number Diff line change
Expand Up @@ -574,8 +574,10 @@ public static function displayTotals($actual, $expected) {
* Associated array of batch ids.
* @param string $exportFormat
* Export format.
* @param bool $downloadFile
* Download export file?.
*/
public static function exportFinancialBatch($batchIds, $exportFormat) {
public static function exportFinancialBatch($batchIds, $exportFormat, $downloadFile) {
if (empty($batchIds)) {
CRM_Core_Error::fatal(ts('No batches were selected.'));
return;
Expand All @@ -594,6 +596,7 @@ public static function exportFinancialBatch($batchIds, $exportFormat) {
else {
CRM_Core_Error::fatal("Could not locate exporter: $exporterClass");
}
$exporter->_isDownloadFile = $downloadFile;
foreach ($batchIds as $batchId) {
$export[$batchId] = $exporter->generateExportQuery($batchId);
}
Expand Down
3 changes: 3 additions & 0 deletions CRM/Financial/BAO/ExportFormat.php
Original file line number Diff line number Diff line change
Expand Up @@ -141,6 +141,9 @@ public static function format($s, $type = 'string') {
}

public function initiateDownload() {
if (!$this->_isDownloadFile) {
return NULL;
}
$config = CRM_Core_Config::singleton();
// zip files if more than one.
if (count($this->_downloadFile) > 1) {
Expand Down
7 changes: 6 additions & 1 deletion CRM/Financial/Form/Export.php
Original file line number Diff line number Diff line change
Expand Up @@ -60,6 +60,11 @@ class CRM_Financial_Form_Export extends CRM_Core_Form {
*/
protected $_exportFormat;

/**
* Download export File.
*/
protected $_downloadFile = TRUE;

/**
* Build all the data structures needed to build the form.
*/
Expand Down Expand Up @@ -175,7 +180,7 @@ public function postProcess() {
CRM_Batch_BAO_Batch::create($batchParams, $ids, 'financialBatch');
}

CRM_Batch_BAO_Batch::exportFinancialBatch($batchIds, $this->_exportFormat);
CRM_Batch_BAO_Batch::exportFinancialBatch($batchIds, $this->_exportFormat, $this->_downloadFile);
}

}

0 comments on commit aeb7ff7

Please sign in to comment.