本文整理汇总了PHP中CRM_Pledge_BAO_PledgePayment::deletePayments方法的典型用法代码示例。如果您正苦于以下问题:PHP CRM_Pledge_BAO_PledgePayment::deletePayments方法的具体用法?PHP CRM_Pledge_BAO_PledgePayment::deletePayments怎么用?PHP CRM_Pledge_BAO_PledgePayment::deletePayments使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类CRM_Pledge_BAO_PledgePayment
的用法示例。
在下文中一共展示了CRM_Pledge_BAO_PledgePayment::deletePayments方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: array
/**
* takes an associative array and creates a pledge object
*
* @param array $params (reference ) an assoc array of name/value pairs
*
* @return object CRM_Pledge_BAO_Pledge object
* @access public
* @static
*/
static function &create(&$params)
{
//FIXME: a cludgy hack to fix the dates to MySQL format
$dateFields = array('start_date', 'create_date', 'acknowledge_date', 'modified_date', 'cancel_date', 'end_date');
foreach ($dateFields as $df) {
if (isset($params[$df])) {
$params[$df] = CRM_Utils_Date::isoToMysql($params[$df]);
}
}
$transaction = new CRM_Core_Transaction();
$paymentParams = array();
$paymentParams['status_id'] = CRM_Utils_Array::value('status_id', $params);
if (CRM_Utils_Array::value('installment_amount', $params)) {
$params['amount'] = $params['installment_amount'] * $params['installments'];
}
//get All Payments status types.
$paymentStatusTypes = CRM_Contribute_PseudoConstant::contributionStatus(NULL, 'name');
//update the pledge status only if it does NOT come from form
if (!isset($params['pledge_status_id'])) {
if (isset($params['contribution_id'])) {
if ($params['installments'] > 1) {
$params['status_id'] = array_search('In Progress', $paymentStatusTypes);
}
} else {
if (!empty($params['id'])) {
$params['status_id'] = CRM_Pledge_BAO_PledgePayment::calculatePledgeStatus($params['id']);
} else {
$params['status_id'] = array_search('Pending', $paymentStatusTypes);
}
}
}
$pledge = self::add($params);
if (is_a($pledge, 'CRM_Core_Error')) {
$pledge->rollback();
return $pledge;
}
//handle custom data.
if (CRM_Utils_Array::value('custom', $params) && is_array($params['custom'])) {
CRM_Core_BAO_CustomValueTable::store($params['custom'], 'civicrm_pledge', $pledge->id);
}
// skip payment stuff inedit mode
if (!isset($params['id']) || CRM_Utils_Array::value('is_pledge_pending', $params)) {
//if pledge is pending delete all payments and recreate.
if (CRM_Utils_Array::value('is_pledge_pending', $params)) {
CRM_Pledge_BAO_PledgePayment::deletePayments($pledge->id);
}
//building payment params
$paymentParams['pledge_id'] = $pledge->id;
$paymentKeys = array('amount', 'installments', 'scheduled_date', 'frequency_unit', 'currency', 'frequency_day', 'frequency_interval', 'contribution_id', 'installment_amount', 'actual_amount');
foreach ($paymentKeys as $key) {
$paymentParams[$key] = CRM_Utils_Array::value($key, $params, NULL);
}
CRM_Pledge_BAO_PledgePayment::create($paymentParams);
}
$transaction->commit();
$url = CRM_Utils_System::url('civicrm/contact/view/pledge', "action=view&reset=1&id={$pledge->id}&cid={$pledge->contact_id}&context=home");
$recentOther = array();
if (CRM_Core_Permission::checkActionPermission('CiviPledge', CRM_Core_Action::UPDATE)) {
$recentOther['editUrl'] = CRM_Utils_System::url('civicrm/contact/view/pledge', "action=update&reset=1&id={$pledge->id}&cid={$pledge->contact_id}&context=home");
}
if (CRM_Core_Permission::checkActionPermission('CiviPledge', CRM_Core_Action::DELETE)) {
$recentOther['deleteUrl'] = CRM_Utils_System::url('civicrm/contact/view/pledge', "action=delete&reset=1&id={$pledge->id}&cid={$pledge->contact_id}&context=home");
}
$contributionTypes = CRM_Contribute_PseudoConstant::financialType();
$title = CRM_Contact_BAO_Contact::displayName($pledge->contact_id) . ' - (' . ts('Pledged') . ' ' . CRM_Utils_Money::format($pledge->amount, $pledge->currency) . ' - ' . CRM_Utils_Array::value($pledge->financial_type_id, $contributionTypes) . ')';
// add the recently created Pledge
CRM_Utils_Recent::add($title, $url, $pledge->id, 'Pledge', $pledge->contact_id, NULL, $recentOther);
return $pledge;
}
示例2: testDeletePaymentsZeroId
/**
* Pass Zero Id for a payment deletion for one pledge
*/
function testDeletePaymentsZeroId()
{
$payment = CRM_Core_DAO::createTestObject('CRM_Pledge_BAO_PledgePayment');
$paymentid = CRM_Pledge_BAO_PledgePayment::deletePayments(0);
$result = CRM_Pledge_BAO_Pledge::deletePledge($payment->pledge_id);
}