本文整理汇总了PHP中CRM_Batch_BAO_Batch::create方法的典型用法代码示例。如果您正苦于以下问题:PHP CRM_Batch_BAO_Batch::create方法的具体用法?PHP CRM_Batch_BAO_Batch::create怎么用?PHP CRM_Batch_BAO_Batch::create使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类CRM_Batch_BAO_Batch
的用法示例。
在下文中一共展示了CRM_Batch_BAO_Batch::create方法的7个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: postProcess
/**
* Process the form after the input has been submitted and validated.
*
*
* @return void
*/
public function postProcess()
{
$params = $this->controller->exportValues($this->_name);
$params['actualBatchTotal'] = 0;
// get the profile information
$batchTypes = CRM_Core_Pseudoconstant::get('CRM_Batch_DAO_Batch', 'type_id', array('flip' => 1), 'validate');
if (in_array($this->_batchInfo['type_id'], array($batchTypes['Pledge Payment'], $batchTypes['Contribution']))) {
$this->processContribution($params);
} elseif ($this->_batchInfo['type_id'] == $batchTypes['Membership']) {
$this->processMembership($params);
}
// update batch to close status
$paramValues = array('id' => $this->_batchId, 'status_id' => CRM_Core_OptionGroup::getValue('batch_status', 'Closed', 'name'), 'total' => $params['actualBatchTotal']);
CRM_Batch_BAO_Batch::create($paramValues);
// set success status
CRM_Core_Session::setStatus("", ts("Batch Processed."), "success");
CRM_Utils_System::redirect(CRM_Utils_System::url('civicrm/batch', 'reset=1'));
}
示例2: postProcess
/**
* process the form after the input has been submitted and validated
*
* @access public
*
* @return void
*/
public function postProcess()
{
$params = $this->controller->exportValues($this->_name);
$params['actualBatchTotal'] = 0;
// get the profile information
if ($this->_batchInfo['type_id'] == 1) {
$this->processContribution($params);
} else {
$this->processMembership($params);
}
// update batch to close status
$paramValues = array('id' => $this->_batchId, 'status_id' => CRM_Core_OptionGroup::getValue('batch_status', 'Closed', 'name'), 'total' => $params['actualBatchTotal']);
CRM_Batch_BAO_Batch::create($paramValues);
// set success status
CRM_Core_Session::setStatus("", ts("Batch Processed."), "success");
CRM_Utils_System::redirect(CRM_Utils_System::url('civicrm/batch', 'reset=1'));
}
示例3: postProcess
/**
* process the form after the input has been submitted and validated
*
* @access public
* @return None
*/
public function postProcess()
{
$params = $this->controller->exportValues();
$batchParams = array();
$batchParams['title'] = $params['title'];
$batchParams['name'] = CRM_Utils_String::titleToVar($params['title'], 63);
$batchParams['description'] = $params['description'];
$batchParams['batch_type'] = "Gift Aid";
$session =& CRM_Core_Session::singleton();
$batchParams['created_id'] = $session->get('userID');
$batchParams['created_date'] = date("YmdHis");
$batchParams['status_id'] = 0;
$batchMode = CRM_Core_PseudoConstant::get('CRM_Batch_DAO_Batch', 'mode_id', array('labelColumn' => 'name'));
$batchParams['mode_id'] = CRM_Utils_Array::key('Manual Batch', $batchMode);
$batchParams['modified_date'] = date('YmdHis');
$batchParams['modified_id'] = $session->get('userID');
require_once 'CRM/Core/Transaction.php';
$transaction = new CRM_Core_Transaction();
//require_once 'CRM/Core/BAO/Batch.php'; //version 4.2
require_once 'CRM/Batch/BAO/Batch.php';
$createdBatch = CRM_Batch_BAO_Batch::create($batchParams);
$batchID = $createdBatch->id;
$batchLabel = $batchParams['title'];
// Save current settings for the batch
CRM_Civigiftaid_BAO_BatchSettings::create(array('batch_id' => $batchID));
require_once 'CRM/Civigiftaid/Utils/Contribution.php';
list($total, $added, $notAdded) = CRM_Civigiftaid_Utils_Contribution::addContributionToBatch($this->_contributionIds, $batchID);
if ($added <= 0) {
// rollback since there were no contributions added, and we might not want to keep an empty batch
$transaction->rollback();
$status = ts('Could not create batch "%1", as there were no valid contribution(s) to be added.', array(1 => $batchLabel));
} else {
$status = array(ts('Added Contribution(s) to %1', array(1 => $batchLabel)), ts('Total Selected Contribution(s): %1', array(1 => $total)));
if ($added) {
$status[] = ts('Total Contribution(s) added to batch: %1', array(1 => $added));
}
if ($notAdded) {
$status[] = ts('Total Contribution(s) already in batch or not valid: %1', array(1 => $notAdded));
}
$status = implode('<br/>', $status);
}
$transaction->commit();
CRM_Core_Session::setStatus($status);
}
示例4: postProcess
/**
* Process the form submission.
*
* @return void
*/
public function postProcess()
{
$session = CRM_Core_Session::singleton();
$ids = array();
$params = $this->exportValues();
$batchStatus = CRM_Core_PseudoConstant::get('CRM_Batch_DAO_Batch', 'status_id');
if ($this->_id) {
$ids['batchID'] = $this->_id;
$params['id'] = $this->_id;
}
// store the submitted values in an array
$params['modified_date'] = date('YmdHis');
$params['modified_id'] = $session->get('userID');
if (!empty($params['created_date'])) {
$params['created_date'] = CRM_Utils_Date::processDate($params['created_date']);
}
if ($this->_action & CRM_Core_Action::ADD) {
$batchMode = CRM_Core_PseudoConstant::get('CRM_Batch_DAO_Batch', 'mode_id', array('labelColumn' => 'name'));
$params['mode_id'] = CRM_Utils_Array::key('Manual Batch', $batchMode);
$params['status_id'] = CRM_Utils_Array::key('Open', $batchStatus);
$params['created_date'] = date('YmdHis');
$params['created_id'] = $session->get('userID');
$details = "{$params['title']} batch has been created by this contact.";
$activityTypeName = 'Create Batch';
} elseif ($this->_action & CRM_Core_Action::UPDATE && $this->_id) {
$details = "{$params['title']} batch has been edited by this contact.";
if (CRM_Utils_Array::value($params['status_id'], $batchStatus) == 'Closed') {
$details = "{$params['title']} batch has been closed by this contact.";
}
$activityTypeName = 'Edit Batch';
}
$batch = CRM_Batch_BAO_Batch::create($params, $ids, 'financialBatch');
$activityTypes = CRM_Core_PseudoConstant::activityType(TRUE, FALSE, FALSE, 'name');
//create activity.
$activityParams = array('activity_type_id' => array_search($activityTypeName, $activityTypes), 'subject' => $batch->title . "- Batch", 'status_id' => 2, 'priority_id' => 2, 'activity_date_time' => date('YmdHis'), 'source_contact_id' => $session->get('userID'), 'source_contact_qid' => $session->get('userID'), 'details' => $details);
CRM_Activity_BAO_Activity::create($activityParams);
$buttonName = $this->controller->getButtonName();
$context = $this->get("context");
if ($batch->title) {
CRM_Core_Session::setStatus(ts("'%1' batch has been saved.", array(1 => $batch->title)), ts('Saved'), 'success');
}
if ($buttonName == $this->getButtonName('next', 'new') & $this->_action == CRM_Core_Action::UPDATE) {
$session->replaceUserContext(CRM_Utils_System::url('civicrm/financial/batch', "reset=1&action=add&context=1"));
} elseif ($buttonName == $this->getButtonName('next', 'new')) {
$session->replaceUserContext(CRM_Utils_System::url('civicrm/financial/batch', "reset=1&action=add"));
} elseif (CRM_Utils_Array::value($batch->status_id, $batchStatus) == 'Closed') {
$session->replaceUserContext(CRM_Utils_System::url('civicrm', 'reset=1'));
} elseif ($buttonName == $this->getButtonName('next') & $this->_action == CRM_Core_Action::UPDATE || $buttonName == $this->getButtonName('next') & $this->_action == CRM_Core_Action::ADD & $context == 1) {
$session->replaceUserContext(CRM_Utils_System::url('civicrm/financial/financialbatches', "reset=1&batchStatus=1"));
} else {
$session->replaceUserContext(CRM_Utils_System::url('civicrm/batchtransaction', "reset=1&bid={$batch->id}"));
}
}
示例5: postProcess
/**
* 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);
}
示例6: postProcess
/**
* Process the form submission.
*/
public function postProcess()
{
$params = $this->controller->exportValues($this->_name);
if ($this->_action & CRM_Core_Action::DELETE) {
CRM_Core_Session::setStatus("", ts("Batch Deleted"), "success");
CRM_Batch_BAO_Batch::deleteBatch($this->_id);
return;
}
if ($this->_id) {
$params['id'] = $this->_id;
} else {
$session = CRM_Core_Session::singleton();
$params['created_id'] = $session->get('userID');
$params['created_date'] = CRM_Utils_Date::processDate(date("Y-m-d"), date("H:i:s"));
}
// always create with data entry status
$params['status_id'] = CRM_Core_OptionGroup::getValue('batch_status', 'Data Entry', 'name');
$batch = CRM_Batch_BAO_Batch::create($params);
// redirect to batch entry page.
$session = CRM_Core_Session::singleton();
if ($this->_action & CRM_Core_Action::ADD) {
$session->replaceUserContext(CRM_Utils_System::url('civicrm/batch/entry', "id={$batch->id}&reset=1&action=add"));
} else {
$session->replaceUserContext(CRM_Utils_System::url('civicrm/batch/entry', "id={$batch->id}&reset=1"));
}
}
示例7: createBatch
static function createBatch(array $batchDetails)
{
//check mandatory $params
foreach (array('banking_date', 'banking_account', 'batch_status', 'exclude_from_posting', 'payment_instrument_id') as $param) {
if (!isset($batchDetails[$param])) {
throw new InvalidArgumentException("No param[{$param}]");
}
}
// PS Commented out this way of creating the batch
// Replaced with using the batch description and tidying
//$batch_sql = "SELECT max(id) as max_id FROM civicrm_batch";
//$batch_dao = CRM_Core_DAO::executeQuery($batch_sql);
//$batch_dao->fetch();
//$nextId = $batch_dao->max_id + 1;
$session =& CRM_Core_Session::singleton();
//$nextId = CRM_Utils_String::titleToVar($batchDetails['description']);
if (!isset($batchDetails['batch_title'])) {
$batchDetails['batch_title'] = 'Contrib Batch ' . CRM_Utils_Date::currentDBDate();
}
$batchParams = array('title' => $batchDetails['batch_title'], 'description' => $batchDetails['description'], 'created_id' => $session->get('userID'), 'created_date' => CRM_Utils_Date::currentDBDate(), 'type_id' => 1, 'status_id' => 2);
// Create the batch
require_once 'CRM/Batch/BAO/Batch.php';
$createdBatch =& CRM_Batch_BAO_Batch::create($batchParams);
$batchDetails['batch_id'] = $createdBatch->id;
require_once 'CRM/Utils/Date.php';
$batchDetails['banking_date'] = CRM_Utils_Date::processDate($batchDetails['banking_date']);
// require_once 'CRM/Finance/BAO/BatchType.php';
$expectedPostingDate = CRM_Finance_BAO_BatchType::getBatchTypeExpectedPostingDate();
//matusz: copied from CRM_Batch_Page_AJAX::getContributionTypeForCampaign()
//$batchDetails['contribution_type_id']
$campaignId = null;
if (!empty($batchDetails['campaign_id'])) {
$campaignId = $batchDetails['campaign_id'];
}
/*
$contributionTypeId = null;
if($campaignId !== null) {
$select_dao = CRM_Core_DAO::executeQuery("SELECT * FROM ".CIVICRM_MTL_CAMPAIGN_FUND_CODE." WHERE campaign_id = %0", array(
array($campaignId, 'Int')
));
if (!$select_dao->fetch()){
throw new Exception("No contribution_type_id found by using campaign id '$campaignId'");
}
$batchDetails['contribution_type_id'] = $select_dao->contribution_type_id;
}
*/
if (empty($batchDetails['contribution_type_id'])) {
$batchDetails['contribution_type_id'] = 0;
}
$batchDetails['exclude_from_posting'] = empty($batchDetails['exclude_from_posting']) ? 0 : 1;
$sqlParams = array(array($batchDetails['payment_instrument_id'], 'Int'), array($expectedPostingDate, 'Timestamp'), array($batchDetails['exclude_from_posting'], 'Boolean'), array($batchDetails['banking_date'], 'Timestamp'), array($batchDetails['banking_account'], 'Int'), array($batchDetails['contribution_type_id'], 'Int'), array((string) $batchDetails['batch_title'], 'String'));
$batchDetailsSql = " UPDATE civicrm_batch SET ";
$batchDetailsSql .= " payment_instrument_id = %0 ";
$batchDetailsSql .= " , expected_posting_date = %1 ";
$batchDetailsSql .= " , exclude_from_posting = %2 ";
$batchDetailsSql .= " , banking_date = %3 ";
$batchDetailsSql .= " , banking_account = %4 ";
$batchDetailsSql .= " , contribution_type_id = %5 ";
$batchDetailsSql .= " , title = %6 ";
$parameterIndex = 6;
if ($campaignId !== null) {
$parameterIndex = $parameterIndex + 1;
$batchDetailsSql .= ", campaign_id = %{$parameterIndex} ";
$sqlParams[] = array($campaignId, 'Int');
}
/*
if(isset($batchDetails['expected_entries'])) {
$parameterIndex = $parameterIndex + 1;
$batchDetailsSql .= ", expected_entries = %$parameterIndex ";
$sqlParams[] = array($batchDetails['expected_entries'], 'Int');
}
if(isset($batchDetails['expected_value'])) {
$parameterIndex = $parameterIndex + 1;
$batchDetailsSql .= ", expected_value = %$parameterIndex ";
$sqlParams[] = array($batchDetails['expected_value'], 'Money');
}
*/
if (isset($batchDetails['entity_type'])) {
$parameterIndex = $parameterIndex + 1;
$batchDetailsSql .= ", entity_type = %{$parameterIndex} ";
$sqlParams[] = array($batchDetails['entity_type'], 'String');
}
$parameterIndex = $parameterIndex + 1;
$batchDetailsSql .= " WHERE id = %{$parameterIndex} ";
$sqlParams[] = array($batchDetails['batch_id'], 'Int');
CRM_Core_DAO::executeQuery($batchDetailsSql, $sqlParams);
return $batchDetails;
}