Пример #1
0
 /**
  * Function for exporting financial accounts, currently we support CSV and IIF format
  * @see http://wiki.civicrm.org/confluence/display/CRM/CiviAccounts+Specifications+-++Batches#CiviAccountsSpecifications-Batches-%C2%A0Overviewofimplementation
  *
  * @param array $batchIds
  *   Associated array of batch ids.
  * @param string $exportFormat
  *   Export format.
  */
 public static function exportFinancialBatch($batchIds, $exportFormat)
 {
     if (empty($batchIds)) {
         CRM_Core_Error::fatal(ts('No batches were selected.'));
         return;
     }
     if (empty($exportFormat)) {
         CRM_Core_Error::fatal(ts('No export format selected.'));
         return;
     }
     self::$_exportFormat = $exportFormat;
     // Instantiate appropriate exporter based on user-selected format.
     $exporterClass = "CRM_Financial_BAO_ExportFormat_" . self::$_exportFormat;
     if (class_exists($exporterClass)) {
         $exporter = new $exporterClass();
     } else {
         CRM_Core_Error::fatal("Could not locate exporter: {$exporterClass}");
     }
     foreach ($batchIds as $batchId) {
         $export[$batchId] = $exporter->generateExportQuery($batchId);
     }
     $exporter->makeExport($export);
 }