本文整理匯總了PHP中CRM_Contribute_DAO_Contribution::fields方法的典型用法代碼示例。如果您正苦於以下問題:PHP CRM_Contribute_DAO_Contribution::fields方法的具體用法?PHP CRM_Contribute_DAO_Contribution::fields怎麽用?PHP CRM_Contribute_DAO_Contribution::fields使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類CRM_Contribute_DAO_Contribution
的用法示例。
在下文中一共展示了CRM_Contribute_DAO_Contribution::fields方法的6個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的PHP代碼示例。
示例1: alterActionScheduleQuery
public function alterActionScheduleQuery(\Civi\ActionSchedule\Event\MailingQueryEvent $e)
{
if ($e->mapping->getEntity() !== 'civicrm_contribution') {
return;
}
$fields = CRM_Contribute_DAO_Contribution::fields();
foreach ($this->getPassthruTokens() as $token) {
$e->query->select("e." . $fields[$token]['name'] . " AS contrib_{$token}");
}
foreach ($this->getAliasTokens() as $alias => $orig) {
$e->query->select("e." . $fields[$orig]['name'] . " AS contrib_{$alias}");
}
}
示例2: _civicrm_api3_deprecated_formatted_param
/**
* take the input parameter list as specified in the data model and
* convert it into the same format that we use in QF and BAO object
*
* @param array $params
* Associative array of property name/value.
* pairs to insert in new contact.
* @param array $values
* The reformatted properties that we can use internally.
* '
*
* @param bool $create
* @param null $onDuplicate
*
* @return array|CRM_Error
*/
function _civicrm_api3_deprecated_formatted_param($params, &$values, $create = FALSE, $onDuplicate = NULL)
{
// copy all the contribution fields as is
$fields = CRM_Contribute_DAO_Contribution::fields();
_civicrm_api3_store_values($fields, $params, $values);
require_once 'CRM/Core/OptionGroup.php';
$customFields = CRM_Core_BAO_CustomField::getFields('Contribution', FALSE, FALSE, NULL, NULL, FALSE, FALSE, FALSE);
foreach ($params as $key => $value) {
// ignore empty values or empty arrays etc
if (CRM_Utils_System::isNull($value)) {
continue;
}
// Handling Custom Data
if ($customFieldID = CRM_Core_BAO_CustomField::getKeyID($key)) {
$values[$key] = $value;
$type = $customFields[$customFieldID]['html_type'];
if ($type == 'CheckBox' || $type == 'Multi-Select') {
$mulValues = explode(',', $value);
$customOption = CRM_Core_BAO_CustomOption::getCustomOption($customFieldID, TRUE);
$values[$key] = array();
foreach ($mulValues as $v1) {
foreach ($customOption as $customValueID => $customLabel) {
$customValue = $customLabel['value'];
if (strtolower($customLabel['label']) == strtolower(trim($v1)) || strtolower($customValue) == strtolower(trim($v1))) {
if ($type == 'CheckBox') {
$values[$key][$customValue] = 1;
} else {
$values[$key][] = $customValue;
}
}
}
}
} elseif ($type == 'Select' || $type == 'Radio' || $type == 'Autocomplete-Select' && $customFields[$customFieldID]['data_type'] == 'String') {
$customOption = CRM_Core_BAO_CustomOption::getCustomOption($customFieldID, TRUE);
foreach ($customOption as $customFldID => $customValue) {
$val = CRM_Utils_Array::value('value', $customValue);
$label = CRM_Utils_Array::value('label', $customValue);
$label = strtolower($label);
$value = strtolower(trim($value));
if ($value == $label || $value == strtolower($val)) {
$values[$key] = $val;
}
}
}
}
switch ($key) {
case 'contribution_contact_id':
if (!CRM_Utils_Rule::integer($value)) {
return civicrm_api3_create_error("contact_id not valid: {$value}");
}
$dao = new CRM_Core_DAO();
$qParams = array();
$svq = $dao->singleValueQuery("SELECT is_deleted FROM civicrm_contact WHERE id = {$value}", $qParams);
if (!isset($svq)) {
return civicrm_api3_create_error("Invalid Contact ID: There is no contact record with contact_id = {$value}.");
} elseif ($svq == 1) {
return civicrm_api3_create_error("Invalid Contact ID: contact_id {$value} is a soft-deleted contact.");
}
$values['contact_id'] = $values['contribution_contact_id'];
unset($values['contribution_contact_id']);
break;
case 'contact_type':
// import contribution record according to select contact type
require_once 'CRM/Contact/DAO/Contact.php';
$contactType = new CRM_Contact_DAO_Contact();
// when insert mode check contact id or external identifier
if (!empty($params['contribution_contact_id']) || !empty($params['external_identifier'])) {
if (!empty($params['contribution_contact_id'])) {
$contactType->id = CRM_Utils_Array::value('contribution_contact_id', $params);
} elseif (!empty($params['external_identifier'])) {
$contactType->external_identifier = $params['external_identifier'];
}
if ($contactType->find(TRUE)) {
if ($params['contact_type'] != $contactType->contact_type) {
return civicrm_api3_create_error("Contact Type is wrong: {$contactType->contact_type}");
}
}
} elseif (!empty($params['contribution_id']) || !empty($params['trxn_id']) || !empty($params['invoice_id'])) {
// when update mode check contribution id or trxn id or
// invoice id
$contactId = new CRM_Contribute_DAO_Contribution();
if (!empty($params['contribution_id'])) {
$contactId->id = $params['contribution_id'];
} elseif (!empty($params['trxn_id'])) {
//.........這裏部分代碼省略.........
示例3: _crm_format_contrib_params
/**
* take the input parameter list as specified in the data model and
* convert it into the same format that we use in QF and BAO object
*
* @param array $params Associative array of property name/value
* pairs to insert in new contact.
* @param array $values The reformatted properties that we can use internally
* '
* @return array|CRM_Error
* @access public
*/
function _crm_format_contrib_params(&$params, &$values, $create = false)
{
// copy all the contribution fields as is
$fields =& CRM_Contribute_DAO_Contribution::fields();
_crm_store_values($fields, $params, $values);
foreach ($params as $key => $value) {
// ignore empty values or empty arrays etc
if (CRM_Utils_System::isNull($value)) {
continue;
}
switch ($key) {
case 'contribution_contact_id':
if (!CRM_Utils_Rule::integer($value)) {
return _crm_error("contact_id not valid: {$value}");
}
$dao =& new CRM_Core_DAO();
$qParams = array();
$svq = $dao->singleValueQuery("SELECT id FROM civicrm_contact WHERE id = {$value}", $qParams);
if (!$svq) {
return _crm_error("Invalid Contact ID: There is no contact record with contact_id = {$value}.");
}
$values['contact_id'] = $values['contribution_contact_id'];
unset($values['contribution_contact_id']);
break;
case 'receive_date':
case 'cancel_date':
case 'receipt_date':
case 'thankyou_date':
if (!CRM_Utils_Rule::date($value)) {
return _crm_error("{$key} not a valid date: {$value}");
}
break;
case 'non_deductible_amount':
case 'total_amount':
case 'fee_amount':
case 'net_amount':
if (!CRM_Utils_Rule::money($value)) {
return _crm_error("{$key} not a valid amount: {$value}");
}
break;
case 'currency':
if (!CRM_Utils_Rule::currencyCode($value)) {
return _crm_error("currency not a valid code: {$value}");
}
break;
case 'contribution_type':
require_once 'CRM/Contribute/PseudoConstant.php';
$values['contribution_type_id'] = CRM_Utils_Array::key(ucfirst($value), CRM_Contribute_PseudoConstant::contributionType());
break;
case 'payment_instrument':
require_once 'CRM/Core/OptionGroup.php';
$values['payment_instrument_id'] = CRM_Core_OptionGroup::getValue('payment_instrument', $value);
break;
case 'contribution_status_id':
require_once 'CRM/Core/OptionGroup.php';
$values['contribution_status_id'] = CRM_Core_OptionGroup::getValue('contribution_status', $value);
break;
default:
break;
}
}
if (array_key_exists('note', $params)) {
$values['note'] = $params['note'];
}
_crm_format_custom_params($params, $values, 'Contribution');
if ($create) {
// CRM_Contribute_BAO_Contribution::add() handles contribution_source
// So, if $values contains contribution_source, convert it to source
$changes = array('contribution_source' => 'source');
foreach ($changes as $orgVal => $changeVal) {
if (isset($values[$orgVal])) {
$values[$changeVal] = $values[$orgVal];
unset($values[$orgVal]);
}
}
}
return null;
}
示例4: _crm_add_formatted_contrib_param
/**
* This function adds the contribution variable in $values to the
* parameter list $params. For most cases, $values should have length 1.
*
* @param array $values The variable(s) to be added
* @param array $params The structured parameter list
*
* @return bool|CRM_Utils_Error
* @access public
*/
function _crm_add_formatted_contrib_param(&$values, &$params)
{
/* Cache the various object fields */
static $fields = null;
if ($fields == null) {
$fields = array();
}
//print_r($values);
//print_r($params);
if (isset($values['contribution_type'])) {
$params['contribution_type'] = $values['contribution_type'];
return true;
}
if (isset($values['payment_instrument'])) {
$params['payment_instrument'] = $values['payment_instrument'];
return true;
}
/* Check for custom field values */
if ($fields['custom'] == null) {
$fields['custom'] =& CRM_Core_BAO_CustomField::getFields('Contribution');
}
foreach ($values as $key => $value) {
if ($customFieldID = CRM_Core_BAO_CustomField::getKeyID($key)) {
/* check if it's a valid custom field id */
if (!array_key_exists($customFieldID, $fields['custom'])) {
return _crm_error('Invalid custom field ID');
}
if (!isset($params['custom'])) {
$params['custom'] = array();
}
// fixed for Import
$newMulValues = array();
if ($fields['custom'][$customFieldID][3] == 'CheckBox' || $fields['custom'][$customFieldID][3] == 'Multi-Select') {
$value = str_replace("|", ",", $value);
$mulValues = explode(',', $value);
$custuomOption = CRM_Core_BAO_CustomOption::getCustomOption($customFieldID, true);
foreach ($mulValues as $v1) {
foreach ($custuomOption as $v2) {
if (strtolower($v2['label']) == strtolower(trim($v1))) {
$newMulValues[] = $v2['value'];
}
}
}
$value = implode(CRM_CORE_BAO_CUSTOMOPTION_VALUE_SEPERATOR, $newMulValues);
} else {
if ($fields['custom'][$customFieldID][3] == 'Select' || $fields['custom'][$customFieldID][3] == 'Radio') {
$custuomOption = CRM_Core_BAO_CustomOption::getCustomOption($customFieldID, true);
foreach ($custuomOption as $v2) {
if (strtolower($v2['label']) == strtolower(trim($value))) {
$value = $v2['value'];
break;
}
}
}
}
$customBlock = count($params['custom']) + 1;
$params['custom'][$customBlock] = array('custom_field_id' => $customFieldID, 'value' => $value, 'type' => $fields['custom'][$customFieldID][2], 'name' => $fields['custom'][$customFieldID][0]);
}
}
/* Finally, check for contribution fields */
if (!isset($fields['Contribution'])) {
$fields['Contribution'] =& CRM_Contribute_DAO_Contribution::fields();
}
_crm_store_values($fields['Contribution'], $values, $params);
}
示例5: array
/**
* returns the list of fields that can be exported
*
* @access public
* return array
*/
function &export($prefix = false)
{
if (!$GLOBALS['_CRM_CONTRIBUTE_DAO_CONTRIBUTION']['_export']) {
$GLOBALS['_CRM_CONTRIBUTE_DAO_CONTRIBUTION']['_export'] = array();
$fields =& CRM_Contribute_DAO_Contribution::fields();
foreach ($fields as $name => $field) {
if (CRM_Utils_Array::value('export', $field)) {
if ($prefix) {
$GLOBALS['_CRM_CONTRIBUTE_DAO_CONTRIBUTION']['_export']['contribution'] =& $fields[$name];
} else {
$GLOBALS['_CRM_CONTRIBUTE_DAO_CONTRIBUTION']['_export'][$name] =& $fields[$name];
}
}
}
$GLOBALS['_CRM_CONTRIBUTE_DAO_CONTRIBUTION']['_export'] = array_merge($GLOBALS['_CRM_CONTRIBUTE_DAO_CONTRIBUTION']['_export'], CRM_Contribute_DAO_ContributionType::export(true));
$GLOBALS['_CRM_CONTRIBUTE_DAO_CONTRIBUTION']['_export'] = array_merge($GLOBALS['_CRM_CONTRIBUTE_DAO_CONTRIBUTION']['_export'], CRM_Contribute_DAO_PaymentInstrument::export(true));
}
return $GLOBALS['_CRM_CONTRIBUTE_DAO_CONTRIBUTION']['_export'];
}
示例6: _civicrm_contribute_formatted_param
/**
* take the input parameter list as specified in the data model and
* convert it into the same format that we use in QF and BAO object
*
* @param array $params Associative array of property name/value
* pairs to insert in new contact.
* @param array $values The reformatted properties that we can use internally
* '
*
* @return array|CRM_Error
* @access public
*/
function _civicrm_contribute_formatted_param(&$params, &$values, $create = FALSE)
{
// copy all the contribution fields as is
$fields = CRM_Contribute_DAO_Contribution::fields();
_civicrm_store_values($fields, $params, $values);
require_once 'CRM/Core/OptionGroup.php';
$customFields = CRM_Core_BAO_CustomField::getFields('Contribution');
foreach ($params as $key => $value) {
// ignore empty values or empty arrays etc
if (CRM_Utils_System::isNull($value)) {
continue;
}
//Handling Custom Data
_civicrm_generic_handle_custom_data($key, $value, $values, $customFields);
switch ($key) {
case 'contribution_contact_id':
if (!CRM_Utils_Rule::integer($value)) {
return civicrm_create_error("contact_id not valid: {$value}");
}
$dao = new CRM_Core_DAO();
$qParams = array();
$svq = $dao->singleValueQuery("SELECT id FROM civicrm_contact WHERE id = {$value}", $qParams);
if (!$svq) {
return civicrm_create_error("Invalid Contact ID: There is no contact record with contact_id = {$value}.");
}
$values['contact_id'] = $values['contribution_contact_id'];
unset($values['contribution_contact_id']);
break;
case 'contact_type':
//import contribution record according to select contact type
require_once 'CRM/Contact/DAO/Contact.php';
$contactType = new CRM_Contact_DAO_Contact();
//when insert mode check contact id or external identifire
if ($params['contribution_contact_id'] || $params['external_identifier']) {
if ($params['contribution_contact_id']) {
$contactType->id = $params['contribution_contact_id'];
} elseif ($params['external_identifier']) {
$contactType->external_identifier = $params['external_identifier'];
}
if ($contactType->find(TRUE)) {
if ($params['contact_type'] != $contactType->contact_type) {
return civicrm_create_error("Contact Type is wrong: {$contactType->contact_type}");
}
}
} elseif ($params['contribution_id'] || $params['trxn_id'] || $params['invoice_id']) {
//when update mode check contribution id or trxn id or
//invoice id
$contactId = new CRM_Contribute_DAO_Contribution();
if ($params['contribution_id']) {
$contactId->id = $params['contribution_id'];
} elseif ($params['trxn_id']) {
$contactId->trxn_id = $params['trxn_id'];
} elseif ($params['invoice_id']) {
$contactId->invoice_id = $params['invoice_id'];
}
if ($contactId->find(TRUE)) {
$contactType->id = $contactId->contact_id;
if ($contactType->find(TRUE)) {
if ($params['contact_type'] != $contactType->contact_type) {
return civicrm_create_error("Contact Type is wrong: {$contactType->contact_type}");
}
}
}
}
break;
case 'receive_date':
case 'cancel_date':
case 'receipt_date':
case 'thankyou_date':
if (!CRM_Utils_Rule::date($value)) {
return civicrm_create_error("{$key} not a valid date: {$value}");
}
break;
case 'non_deductible_amount':
case 'total_amount':
case 'fee_amount':
case 'net_amount':
if (!CRM_Utils_Rule::money($value)) {
return civicrm_create_error("{$key} not a valid amount: {$value}");
}
break;
case 'currency':
if (!CRM_Utils_Rule::currencyCode($value)) {
return civicrm_create_error("currency not a valid code: {$value}");
}
break;
case 'contribution_type':
require_once 'CRM/Contribute/PseudoConstant.php';
//.........這裏部分代碼省略.........