本文整理汇总了PHP中CRM_Pledge_BAO_Pledge::getPaymentDate方法的典型用法代码示例。如果您正苦于以下问题:PHP CRM_Pledge_BAO_Pledge::getPaymentDate方法的具体用法?PHP CRM_Pledge_BAO_Pledge::getPaymentDate怎么用?PHP CRM_Pledge_BAO_Pledge::getPaymentDate使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类CRM_Pledge_BAO_Pledge
的用法示例。
在下文中一共展示了CRM_Pledge_BAO_Pledge::getPaymentDate方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: buildPledgeBlock
/**
* Build Pledge Block in Contribution Pages.
*
* @param CRM_Core_Form $form
*/
public static function buildPledgeBlock($form)
{
//build pledge payment fields.
if (!empty($form->_values['pledge_id'])) {
//get all payments required details.
$allPayments = array();
$returnProperties = array('status_id', 'scheduled_date', 'scheduled_amount', 'currency', 'pledge_start_date');
CRM_Core_DAO::commonRetrieveAll('CRM_Pledge_DAO_PledgePayment', 'pledge_id', $form->_values['pledge_id'], $allPayments, $returnProperties);
// get all status
$allStatus = CRM_Contribute_PseudoConstant::contributionStatus(NULL, 'name');
$nextPayment = array();
$isNextPayment = FALSE;
$overduePayments = array();
foreach ($allPayments as $payID => $value) {
if ($allStatus[$value['status_id']] == 'Overdue') {
$overduePayments[$payID] = array('id' => $payID, 'scheduled_amount' => CRM_Utils_Rule::cleanMoney($value['scheduled_amount']), 'scheduled_amount_currency' => $value['currency'], 'scheduled_date' => CRM_Utils_Date::customFormat($value['scheduled_date'], '%B %d'));
} elseif (!$isNextPayment && $allStatus[$value['status_id']] == 'Pending') {
// get the next payment.
$nextPayment = array('id' => $payID, 'scheduled_amount' => CRM_Utils_Rule::cleanMoney($value['scheduled_amount']), 'scheduled_amount_currency' => $value['currency'], 'scheduled_date' => CRM_Utils_Date::customFormat($value['scheduled_date'], '%B %d'));
$isNextPayment = TRUE;
}
}
// build check box array for payments.
$payments = array();
if (!empty($overduePayments)) {
foreach ($overduePayments as $id => $payment) {
$label = ts("%1 - due on %2 (overdue)", array(1 => CRM_Utils_Money::format(CRM_Utils_Array::value('scheduled_amount', $payment), CRM_Utils_Array::value('scheduled_amount_currency', $payment)), 2 => CRM_Utils_Array::value('scheduled_date', $payment)));
$paymentID = CRM_Utils_Array::value('id', $payment);
$payments[] = $form->createElement('checkbox', $paymentID, NULL, $label, array('amount' => CRM_Utils_Array::value('scheduled_amount', $payment)));
}
}
if (!empty($nextPayment)) {
$label = ts("%1 - due on %2", array(1 => CRM_Utils_Money::format(CRM_Utils_Array::value('scheduled_amount', $nextPayment), CRM_Utils_Array::value('scheduled_amount_currency', $nextPayment)), 2 => CRM_Utils_Array::value('scheduled_date', $nextPayment)));
$paymentID = CRM_Utils_Array::value('id', $nextPayment);
$payments[] = $form->createElement('checkbox', $paymentID, NULL, $label, array('amount' => CRM_Utils_Array::value('scheduled_amount', $nextPayment)));
}
// give error if empty or build form for payment.
if (empty($payments)) {
CRM_Core_Error::fatal(ts("Oops. It looks like there is no valid payment status for online payment."));
} else {
$form->assign('is_pledge_payment', TRUE);
$form->addGroup($payments, 'pledge_amount', ts('Make Pledge Payment(s):'), '<br />');
}
} else {
$pledgeBlock = self::getPledgeBlock($form->_id);
// build form for pledge creation.
$pledgeOptions = array('0' => ts('I want to make a one-time contribution'), '1' => ts('I pledge to contribute this amount every'));
$form->addRadio('is_pledge', ts('Pledge Frequency Interval'), $pledgeOptions, NULL, array('<br/>'));
$form->addElement('text', 'pledge_installments', ts('Installments'), array('size' => 3));
if (!empty($pledgeBlock['is_pledge_interval'])) {
$form->assign('is_pledge_interval', CRM_Utils_Array::value('is_pledge_interval', $pledgeBlock));
$form->addElement('text', 'pledge_frequency_interval', NULL, array('size' => 3));
} else {
$form->add('hidden', 'pledge_frequency_interval', 1);
}
// Frequency unit drop-down label suffixes switch from *ly to *(s)
$freqUnitVals = explode(CRM_Core_DAO::VALUE_SEPARATOR, $pledgeBlock['pledge_frequency_unit']);
$freqUnits = array();
$frequencyUnits = CRM_Core_OptionGroup::values('recur_frequency_units');
foreach ($freqUnitVals as $key => $val) {
if (array_key_exists($val, $frequencyUnits)) {
$freqUnits[$val] = !empty($pledgeBlock['is_pledge_interval']) ? "{$frequencyUnits[$val]}(s)" : $frequencyUnits[$val];
}
}
$form->addElement('select', 'pledge_frequency_unit', NULL, $freqUnits);
// CRM-18854
if (CRM_Utils_Array::value('is_pledge_start_date_visible', $pledgeBlock)) {
if (CRM_Utils_Array::value('pledge_start_date', $pledgeBlock)) {
$defaults = array();
$date = (array) json_decode($pledgeBlock['pledge_start_date']);
list($field, $value) = each($date);
switch ($field) {
case 'contribution_date':
$form->addDate('start_date', ts('First installment payment'));
$paymentDate = $value = date('d/m/Y');
list($defaults['start_date'], $defaults['start_date_time']) = CRM_Utils_Date::setDateDefaults($value);
$form->assign('is_date', TRUE);
break;
case 'calendar_date':
$form->addDate('start_date', ts('First installment payment'));
list($defaults['start_date'], $defaults['start_date_time']) = CRM_Utils_Date::setDateDefaults($value);
$form->assign('is_date', TRUE);
$paymentDate = $value;
break;
case 'calendar_month':
$month = CRM_Utils_Date::getCalendarDayOfMonth();
$form->add('select', 'start_date', ts('Day of month installments paid'), $month);
$paymentDate = CRM_Pledge_BAO_Pledge::getPaymentDate($value);
list($defaults['start_date'], $defaults['start_date_time']) = CRM_Utils_Date::setDateDefaults($paymentDate);
break;
default:
break;
}
$form->setDefaults($defaults);
$form->assign('start_date_display', $paymentDate);
//.........这里部分代码省略.........
示例2: testGetPledgeStartDate
/**
* Test build recur params.
*/
public function testGetPledgeStartDate()
{
$startDate = json_encode(array('calendar_month' => 6));
$params = array('pledge_start_date' => $startDate, 'is_pledge_start_date_editable' => TRUE, 'is_pledge_start_date_visible' => TRUE);
// Try with relative date
$date = CRM_Pledge_BAO_Pledge::getPledgeStartDate(6, $params);
$paymentDate = CRM_Pledge_BAO_Pledge::getPaymentDate(6);
$this->assertEquals(date('m/d/Y', strtotime($date)), $paymentDate, "The two dates do not match");
// Try with fixed date
$params = array('pledge_start_date' => json_encode(array('contribution_date' => '2016-06-10')), 'is_pledge_start_date_visible' => FALSE);
$date = CRM_Pledge_BAO_Pledge::getPledgeStartDate($date, $params);
$this->assertEquals($date, '20160610', "The two dates do not match");
}