本文整理汇总了PHP中CRM_Contribute_BAO_Contribution::checkStatusValidation方法的典型用法代码示例。如果您正苦于以下问题:PHP CRM_Contribute_BAO_Contribution::checkStatusValidation方法的具体用法?PHP CRM_Contribute_BAO_Contribution::checkStatusValidation怎么用?PHP CRM_Contribute_BAO_Contribution::checkStatusValidation使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类CRM_Contribute_BAO_Contribution
的用法示例。
在下文中一共展示了CRM_Contribute_BAO_Contribution::checkStatusValidation方法的5个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: civicrm_api3_contribution_create
/**
* Add or update a Contribution.
*
* @param array $params
* Input parameters.
*
* @throws API_Exception
* @return array
* Api result array
*/
function civicrm_api3_contribution_create(&$params)
{
$values = array();
_civicrm_api3_custom_format_params($params, $values, 'Contribution');
$params = array_merge($params, $values);
if (!empty($params['id']) && !empty($params['contribution_status_id'])) {
$error = array();
//throw error for invalid status change such as setting completed back to pending
//@todo this sort of validation belongs in the BAO not the API - if it is not an OK
// action it needs to be blocked there. If it is Ok through a form it needs to be OK through the api
CRM_Contribute_BAO_Contribution::checkStatusValidation(NULL, $params, $error);
if (array_key_exists('contribution_status_id', $error)) {
throw new API_Exception($error['contribution_status_id']);
}
}
if (!empty($params['id']) && !empty($params['financial_type_id'])) {
$error = array();
CRM_Contribute_BAO_Contribution::checkFinancialTypeChange($params['financial_type_id'], $params['id'], $error);
if (array_key_exists('financial_type_id', $error)) {
throw new API_Exception($error['financial_type_id']);
}
}
_civicrm_api3_contribution_create_legacy_support_45($params);
// Make sure tax calculation is handled via api.
$params = CRM_Contribute_BAO_Contribution::checkTaxAmount($params);
return _civicrm_api3_basic_create(_civicrm_api3_get_BAO(__FUNCTION__), $params, 'Contribution');
}
示例2: civicrm_api3_contribution_create
/**
* Add or update a Contribution.
*
* @param array $params
* Input parameters.
*
* @throws API_Exception
* @return array
* Api result array
*/
function civicrm_api3_contribution_create(&$params)
{
$values = array();
_civicrm_api3_custom_format_params($params, $values, 'Contribution');
$params = array_merge($params, $values);
if (CRM_Financial_BAO_FinancialType::isACLFinancialTypeStatus()) {
if (empty($params['id'])) {
$op = CRM_Core_Action::ADD;
} else {
if (empty($params['financial_type_id'])) {
$params['financial_type_id'] = CRM_Core_DAO::getFieldValue('CRM_Contribute_DAO_Contribution', $params['id'], 'financial_type_id');
}
$op = CRM_Core_Action::UPDATE;
}
CRM_Financial_BAO_FinancialType::getAvailableFinancialTypes($types, $op);
if (!in_array($params['financial_type_id'], array_keys($types))) {
return civicrm_api3_create_error('You do not have permission to create this contribution');
}
}
if (!empty($params['id']) && !empty($params['contribution_status_id'])) {
$error = array();
//throw error for invalid status change such as setting completed back to pending
//@todo this sort of validation belongs in the BAO not the API - if it is not an OK
// action it needs to be blocked there. If it is Ok through a form it needs to be OK through the api
CRM_Contribute_BAO_Contribution::checkStatusValidation(NULL, $params, $error);
if (array_key_exists('contribution_status_id', $error)) {
throw new API_Exception($error['contribution_status_id']);
}
}
if (!empty($params['id']) && !empty($params['financial_type_id'])) {
$error = array();
CRM_Contribute_BAO_Contribution::checkFinancialTypeChange($params['financial_type_id'], $params['id'], $error);
if (array_key_exists('financial_type_id', $error)) {
throw new API_Exception($error['financial_type_id']);
}
}
_civicrm_api3_contribution_create_legacy_support_45($params);
// Make sure tax calculation is handled via api.
// @todo this belongs in the BAO NOT the api.
$params = CRM_Contribute_BAO_Contribution::checkTaxAmount($params);
return _civicrm_api3_basic_create(_civicrm_api3_get_BAO(__FUNCTION__), $params, 'Contribution');
}
示例3: civicrm_api3_contribution_create
/**
* Add or update a contribution
*
* @param array $params (reference ) input parameters
*
* @return array Api result array
* @static void
* @access public
* @example ContributionCreate.php
* {@getfields Contribution_create}
*/
function civicrm_api3_contribution_create(&$params)
{
$values = array();
_civicrm_api3_custom_format_params($params, $values, 'Contribution');
$params = array_merge($params, $values);
//legacy soft credit handling - recommended approach is chaining
if (!empty($params['soft_credit_to'])) {
$params['soft_credit'] = array(array('contact_id' => $params['soft_credit_to'], 'amount' => $params['total_amount']));
}
if (CRM_Utils_Array::value('id', $params) && CRM_Utils_Array::value('contribution_status_id', $params)) {
$error = array();
//throw error for invalid status change such as setting completed back to pending
//@todo this sort of validation belongs in the BAO not the API - if it is not an OK
// action it needs to be blocked there. If it is Ok through a form it needs to be OK through the api
CRM_Contribute_BAO_Contribution::checkStatusValidation(NULL, $params, $error);
if (array_key_exists('contribution_status_id', $error)) {
throw new API_Exception($error['contribution_status_id']);
}
}
return _civicrm_api3_basic_create(_civicrm_api3_get_BAO(__FUNCTION__), $params, 'Contribution');
}
示例4: formRule
/**
* Global form rule.
*
* @param array $fields
* The input form values.
* @param array $files
* The uploaded files if any.
* @param $self
*
* @return bool|array
* true if no errors, else array of errors
*/
public static function formRule($fields, $files, $self)
{
$errors = array();
// Check for Credit Card Contribution.
if ($self->_mode) {
if (empty($fields['payment_processor_id'])) {
$errors['payment_processor_id'] = ts('Payment Processor is a required field.');
} else {
// validate payment instrument (e.g. credit card number)
CRM_Core_Payment_Form::validatePaymentInstrument($fields['payment_processor_id'], $fields, $errors, NULL);
}
}
// Do the amount validations.
if (empty($fields['total_amount']) && empty($self->_lineItems)) {
if ($priceSetId = CRM_Utils_Array::value('price_set_id', $fields)) {
CRM_Price_BAO_PriceField::priceSetValidation($priceSetId, $fields, $errors);
}
}
$softErrors = CRM_Contribute_Form_SoftCredit::formRule($fields, $errors, $self);
if (!empty($fields['total_amount']) && (!empty($fields['net_amount']) || !empty($fields['fee_amount']))) {
$sum = CRM_Utils_Rule::cleanMoney($fields['net_amount']) + CRM_Utils_Rule::cleanMoney($fields['fee_amount']);
// For taxable contribution we need to deduct taxable amount from
// (net amount + fee amount) before comparing it with total amount
if (!empty($self->_values['tax_amount'])) {
$componentDetails = CRM_Contribute_BAO_Contribution::getComponentDetails($self->_id);
if (!(CRM_Utils_Array::value('membership', $componentDetails) || CRM_Utils_Array::value('participant', $componentDetails))) {
$sum = CRM_Utils_Money::format($sum - $self->_values['tax_amount'], NULL, '%a');
}
}
if (CRM_Utils_Rule::cleanMoney($fields['total_amount']) != $sum) {
$errors['total_amount'] = ts('The sum of fee amount and net amount must be equal to total amount');
}
}
//CRM-16285 - Function to handle validation errors on form, for recurring contribution field.
CRM_Contribute_BAO_ContributionRecur::validateRecurContribution($fields, $files, $self, $errors);
// Form rule for status http://wiki.civicrm.org/confluence/display/CRM/CiviAccounts+4.3+Data+Flow
if ($self->_action & CRM_Core_Action::UPDATE && $self->_id && $self->_values['contribution_status_id'] != $fields['contribution_status_id']) {
CRM_Contribute_BAO_Contribution::checkStatusValidation($self->_values, $fields, $errors);
}
// CRM-16015, add form-rule to restrict change of financial type if using price field of different financial type
if ($self->_action & CRM_Core_Action::UPDATE && $self->_id && $self->_values['financial_type_id'] != $fields['financial_type_id']) {
CRM_Contribute_BAO_Contribution::checkFinancialTypeChange(NULL, $self->_id, $errors);
}
//FIXME FOR NEW DATA FLOW http://wiki.civicrm.org/confluence/display/CRM/CiviAccounts+4.3+Data+Flow
if (!empty($fields['fee_amount']) && !empty($fields['financial_type_id']) && ($financialType = CRM_Contribute_BAO_Contribution::validateFinancialType($fields['financial_type_id']))) {
$errors['financial_type_id'] = ts("Financial Account of account relationship of 'Expense Account is' is not configured for Financial Type : ") . $financialType;
}
// $trxn_id must be unique CRM-13919
if (!empty($fields['trxn_id'])) {
$queryParams = array(1 => array($fields['trxn_id'], 'String'));
$query = 'select count(*) from civicrm_contribution where trxn_id = %1';
if ($self->_id) {
$queryParams[2] = array((int) $self->_id, 'Integer');
$query .= ' and id !=%2';
}
$tCnt = CRM_Core_DAO::singleValueQuery($query, $queryParams);
if ($tCnt) {
$errors['trxn_id'] = ts('Transaction ID\'s must be unique. Transaction \'%1\' already exists in your database.', array(1 => $fields['trxn_id']));
}
}
$errors = array_merge($errors, $softErrors);
return $errors;
}
示例5: formRule
/**
* global form rule
*
* @param array $fields the input form values
* @param array $files the uploaded files if any
* @param $self
*
* @internal param array $options additional user data
*
* @return true if no errors, else array of errors
* @access public
* @static
*/
static function formRule($fields, $files, $self)
{
$errors = array();
//check for Credit Card Contribution.
if ($self->_mode) {
if (empty($fields['payment_processor_id'])) {
$errors['payment_processor_id'] = ts('Payment Processor is a required field.');
}
}
// do the amount validations.
if (empty($fields['total_amount']) && empty($self->_lineItems)) {
if ($priceSetId = CRM_Utils_Array::value('price_set_id', $fields)) {
CRM_Price_BAO_PriceField::priceSetValidation($priceSetId, $fields, $errors);
}
}
$softErrors = CRM_Contribute_Form_SoftCredit::formRule($fields, $errors, $self);
if (!empty($fields['total_amount']) && (!empty($fields['net_amount']) || !empty($fields['fee_amount']))) {
$sum = CRM_Utils_Rule::cleanMoney($fields['net_amount']) + CRM_Utils_Rule::cleanMoney($fields['fee_amount']);
if (CRM_Utils_Rule::cleanMoney($fields['total_amount']) != $sum) {
$errors['total_amount'] = ts('The sum of fee amount and net amount must be equal to total amount');
}
}
//form rule for status http://wiki.civicrm.org/confluence/display/CRM/CiviAccounts+4.3+Data+Flow
if ($self->_id && $self->_values['contribution_status_id'] != $fields['contribution_status_id']) {
CRM_Contribute_BAO_Contribution::checkStatusValidation($self->_values, $fields, $errors);
}
//FIXME FOR NEW DATA FLOW http://wiki.civicrm.org/confluence/display/CRM/CiviAccounts+4.3+Data+Flow
if (!empty($fields['fee_amount']) && ($financialType = CRM_Contribute_BAO_Contribution::validateFinancialType($fields['financial_type_id']))) {
$errors['financial_type_id'] = ts("Financial Account of account relationship of 'Expense Account is' is not configured for Financial Type : ") . $financialType;
}
// $trxn_id must be unique CRM-13919
if (!empty($fields['trxn_id'])) {
$queryParams = array(1 => array($fields['trxn_id'], 'String'));
$query = 'select count(*) from civicrm_contribution where trxn_id = %1';
if ($self->_id) {
$queryParams[2] = array((int) $self->_id, 'Integer');
$query .= ' and id !=%2';
}
$tCnt = CRM_Core_DAO::singleValueQuery($query, $queryParams);
if ($tCnt) {
$errors['trxn_id'] = ts('Transaction ID\'s must be unique. Transaction \'%1\' already exists in your database.', array(1 => $fields['trxn_id']));
}
}
$errors = array_merge($errors, $softErrors);
return $errors;
}