/** * Build all the data structures needed to build the form. */ public function preProcess() { $this->_batchId = CRM_Utils_Request::retrieve('id', 'Positive', $this, TRUE); $this->_action = CRM_Utils_Request::retrieve('action', 'String', $this, FALSE, 'browse'); if (empty($this->_batchInfo)) { $params = array('id' => $this->_batchId); CRM_Batch_BAO_Batch::retrieve($params, $this->_batchInfo); $this->assign('batchTotal', !empty($this->_batchInfo['total']) ? $this->_batchInfo['total'] : NULL); $this->assign('batchType', $this->_batchInfo['type_id']); // get the profile id associted with this batch type $this->_profileId = CRM_Batch_BAO_Batch::getProfileId($this->_batchInfo['type_id']); } CRM_Core_Resources::singleton()->addScriptFile('civicrm', 'templates/CRM/Batch/Form/Entry.js', 1, 'html-header')->addSetting(array('batch' => array('type_id' => $this->_batchInfo['type_id'])))->addSetting(array('setting' => array('monetaryThousandSeparator' => CRM_Core_Config::singleton()->monetaryThousandSeparator)))->addSetting(array('setting' => array('monetaryDecimalPoint' => CRM_Core_Config::singleton()->monetaryDecimalPoint))); }
/** * @param $batchIds * @param string $fileName * * @throws CRM_Core_Exception */ public static function createActivityExport($batchIds, $fileName) { $session = CRM_Core_Session::singleton(); $values = array(); $params = array('id' => $batchIds); CRM_Batch_BAO_Batch::retrieve($params, $values); $createdBy = CRM_Contact_BAO_Contact::displayName($values['created_id']); $modifiedBy = CRM_Contact_BAO_Contact::displayName($values['modified_id']); $values['payment_instrument_id'] = ''; if (isset($values['payment_instrument_id'])) { $paymentInstrument = array_flip(CRM_Contribute_PseudoConstant::paymentInstrument('label')); $values['payment_instrument_id'] = array_search($values['payment_instrument_id'], $paymentInstrument); } $details = '<p>' . ts('Record:') . ' ' . $values['title'] . '</p><p>' . ts('Description:') . '</p><p>' . ts('Created By:') . " {$createdBy}" . '</p><p>' . ts('Created Date:') . ' ' . $values['created_date'] . '</p><p>' . ts('Last Modified By:') . ' ' . $modifiedBy . '</p><p>' . ts('Payment Instrument:') . ' ' . $values['payment_instrument_id'] . '</p>'; $subject = ''; if (!empty($values['total'])) { $subject .= ts('Total') . '[' . CRM_Utils_Money::format($values['total']) . '],'; } if (!empty($values['item_count'])) { $subject .= ' ' . ts('Count') . '[' . $values['item_count'] . '],'; } //create activity. $subject .= ' ' . ts('Batch') . '[' . $values['title'] . ']'; $activityTypes = CRM_Core_PseudoConstant::activityType(TRUE, FALSE, FALSE, 'name'); $activityParams = array('activity_type_id' => array_search('Export Accounting Batch', $activityTypes), 'subject' => $subject, 'status_id' => 2, 'activity_date_time' => date('YmdHis'), 'source_contact_id' => $session->get('userID'), 'source_record_id' => $values['id'], 'target_contact_id' => $session->get('userID'), 'details' => $details, 'attachFile_1' => array('uri' => $fileName, 'type' => 'text/csv', 'location' => $fileName, 'upload_date' => date('YmdHis'))); CRM_Activity_BAO_Activity::create($activityParams); }
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); }
/** * 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; }