From: Pradeep Nayak Date: Sat, 20 May 2017 23:40:04 +0000 (+0530) Subject: CRM-20615 Export only those batches whose status is exported X-Git-Url: https://vcs.fsf.org/?a=commitdiff_plain;h=f091b037fdb37119f4137f89dca7717d891f5d84;p=civicrm-core.git 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 --- 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); + } } /**