/** * Makes an array of the batch's summary and returns array to parent getBatchSummary() function. * * @param $batchID * @param $params * * @return array */ public static function makeBatchSummary($batchID, $params) { $batchInfo = CRM_Batch_BAO_Batch::retrieve($params, $value); $batchTotals = CRM_Batch_BAO_Batch::batchTotals(array($batchID)); $batchSummary = array('created_by' => CRM_Contact_BAO_Contact::displayName($batchInfo->created_id), 'status' => CRM_Core_PseudoConstant::getLabel('CRM_Batch_BAO_Batch', 'status_id', $batchInfo->status_id), 'description' => $batchInfo->description, 'payment_instrument' => CRM_Core_PseudoConstant::getLabel('CRM_Batch_BAO_Batch', 'payment_instrument_id', $batchInfo->payment_instrument_id), 'item_count' => $batchInfo->item_count, 'assigned_item_count' => $batchTotals[$batchID]['item_count'], 'total' => CRM_Utils_Money::format($batchInfo->total), 'assigned_total' => CRM_Utils_Money::format($batchTotals[$batchID]['total']), 'opened_date' => CRM_Utils_Date::customFormat($batchInfo->created_date)); return $batchSummary; }
public static function getBatchSummary() { $batchID = CRM_Utils_Type::escape($_REQUEST['batchID'], 'String'); $params = array('id' => $batchID); $batchInfo = CRM_Batch_BAO_Batch::retrieve($params, $value); $batchTotals = CRM_Batch_BAO_Batch::batchTotals(array($batchID)); $batchSummary = array('created_by' => CRM_Contact_BAO_Contact::displayName($batchInfo->created_id), 'status' => CRM_Core_OptionGroup::getLabel('batch_status', $batchInfo->status_id), 'description' => $batchInfo->description, 'payment_instrument' => CRM_Core_OptionGroup::getLabel('payment_instrument', $batchInfo->payment_instrument_id), 'item_count' => $batchInfo->item_count, 'assigned_item_count' => $batchTotals[$batchID]['item_count'], 'total' => CRM_Utils_Money::format($batchInfo->total), 'assigned_total' => CRM_Utils_Money::format($batchTotals[$batchID]['total']), 'opened_date' => CRM_Utils_Date::customFormat($batchInfo->created_date)); CRM_Utils_JSON::output($batchSummary); }
/** * 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); }