/** * Process the form after the input has been submitted and validated. */ public function postProcess() { if (!$this->_exportFormat) { $params = $this->exportValues(); $this->_exportFormat = $params['export_format']; } if ($this->_id) { $batchIds = array($this->_id); } elseif (!empty($this->_batchIds)) { $batchIds = explode(',', $this->_batchIds); } // Recalculate totals $totals = CRM_Batch_BAO_Batch::batchTotals($batchIds); // build batch params $session = CRM_Core_Session::singleton(); $batchParams['modified_date'] = date('YmdHis'); $batchParams['modified_id'] = $session->get('userID'); $batchParams['status_id'] = $this->_exportStatusId; $ids = array(); foreach ($batchIds as $batchId) { $batchParams['id'] = $ids['batchID'] = $batchId; // Update totals $batchParams = array_merge($batchParams, $totals[$batchId]); CRM_Batch_BAO_Batch::create($batchParams, $ids, 'financialBatch'); } CRM_Batch_BAO_Batch::exportFinancialBatch($batchIds, $this->_exportFormat); }