本文整理汇总了PHP中CRM_Utils_Rule::datetime方法的典型用法代码示例。如果您正苦于以下问题:PHP CRM_Utils_Rule::datetime方法的具体用法?PHP CRM_Utils_Rule::datetime怎么用?PHP CRM_Utils_Rule::datetime使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类CRM_Utils_Rule
的用法示例。
在下文中一共展示了CRM_Utils_Rule::datetime方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: _civicrm_pledge_format_params
//.........这里部分代码省略.........
if (array_key_exists('pledge_original_installment_amount', $params)) {
$values['installment_amount'] = $params['pledge_original_installment_amount'];
}
if (array_key_exists('status_id', $params)) {
$values['pledge_status_id'] = $params['status_id'];
}
if ($params['contact_id']) {
//this is validity checked further down to make sure the contact exists
$values['pledge_contact_id'] = $params['contact_id'];
}
if (array_key_exists('id', $params)) {
//retrieve the id key dropped from params. Note we can't use pledge_id because it
//causes an error in CRM_Pledge_BAO_PledgePayment - approx line 302
$values['id'] = $params['id'];
}
if (array_key_exists('pledge_id', $params)) {
//retrieve the id key dropped from params. Note we can't use pledge_id because it
//causes an error in CRM_Pledge_BAO_PledgePayment - approx line 302
$values['id'] = $params['pledge_id'];
unset($values['pledge_id']);
}
if (array_key_exists('status_id', $params)) {
$values['pledge_status_id'] = $params['status_id'];
}
if (empty($values['id'])) {
//at this point both should be the same so unset both if not set - passing in empty
//value causes crash rather creating new - do it before next section as null values ignored in 'switch'
unset($values['id']);
}
if (!empty($params['scheduled_date'])) {
//scheduled date is required to set next payment date - defaults to start date
$values['scheduled_date'] = $params['scheduled_date'];
} elseif (array_key_exists('start_date', $params)) {
$values['scheduled_date'] = $params['start_date'];
}
if (CRM_Utils_Array::value('contribution_type_id', $params)) {
$values['contribution_type_id'] = $params['contribution_type_id'];
}
foreach ($values as $key => $value) {
// ignore empty values or empty arrays etc
if (CRM_Utils_System::isNull($value)) {
continue;
}
switch ($key) {
case 'pledge_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['pledge_contact_id'];
unset($values['pledge_contact_id']);
break;
case 'pledge_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_pledge WHERE id = {$value}", $qParams);
if (!$svq) {
return civicrm_create_error("Invalid Contact ID: There is no contact record with contact_id = {$value}.");
}
break;
case 'create_date':
case 'scheduled_date':
case 'start_date':
if (!CRM_Utils_Rule::datetime($value)) {
return civicrm_create_error("{$key} not a valid date: {$value}");
}
break;
case 'installment_amount':
case '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_id':
require_once 'CRM/Contribute/PseudoConstant.php';
$typeId = CRM_Contribute_PseudoConstant::contributionType($value);
if (!CRM_Utils_Rule::integer($value) || !$typeId) {
return civicrm_create_error("contribution type id is not valid: {$value}");
}
default:
break;
}
}
//format the parameters
_civicrm_custom_format_params($params, $values, 'Pledge');
return array();
}