From f091b037fdb37119f4137f89dca7717d891f5d84 Mon Sep 17 00:00:00 2001 From: Pradeep Nayak Date: Sun, 21 May 2017 05:10:04 +0530 Subject: [PATCH] CRM-20615 Export only those batches whose status is exported ---------------------------------------- * CRM-20615: Export only those batches having status Exported https://issues.civicrm.org/jira/browse/CRM-20615 --- CRM/Batch/BAO/Batch.php | 13 ++++++++++++- 1 file changed, 12 insertions(+), 1 deletion(-) diff --git a/CRM/Batch/BAO/Batch.php b/CRM/Batch/BAO/Batch.php index 6dda28ebb5..64380c5a59 100644 --- a/CRM/Batch/BAO/Batch.php +++ b/CRM/Batch/BAO/Batch.php @@ -594,10 +594,21 @@ class CRM_Batch_BAO_Batch extends CRM_Batch_DAO_Batch { else { CRM_Core_Error::fatal("Could not locate exporter: $exporterClass"); } + $export = array(); foreach ($batchIds as $batchId) { + // export only batches whose status is set to Exported. + $result = civicrm_api3('Batch', 'getcount', array( + 'id' => $batchId, + 'status_id' => "Exported", + )); + if (!$result) { + continue; + } $export[$batchId] = $exporter->generateExportQuery($batchId); } - $exporter->makeExport($export); + if ($export) { + $exporter->makeExport($export); + } } /** -- 2.25.1