Unverified Commit b91fc8bb authored by Seamus Lee's avatar Seamus Lee Committed by GitHub

Merge pull request #13206 from eileenmcnaughton/pledge_jcal

#561 Convert Pledge Payment form to use datepicker rather tha…
parents 4f4a7d1f ff25152a
......@@ -6,7 +6,7 @@
*
* Generated from xml/schema/CRM/Pledge/PledgePayment.xml
* DO NOT EDIT. Generated by CRM_Core_CodeGen
* (GenCodeChecksum:42d1945b887c431b77bd52ed461acd81)
* (GenCodeChecksum:79875dd118415179172c3ac425758b29)
*/
/**
......@@ -240,6 +240,10 @@ class CRM_Pledge_DAO_PledgePayment extends CRM_Core_DAO {
'entity' => 'PledgePayment',
'bao' => 'CRM_Pledge_BAO_PledgePayment',
'localizable' => 0,
'html' => [
'type' => 'Select Date',
'formatType' => 'activityDate',
],
],
'pledge_payment_reminder_date' => [
'name' => 'reminder_date',
......
......@@ -43,6 +43,20 @@ class CRM_Pledge_Form_Payment extends CRM_Core_Form {
*/
public $_id;
/**
* Explicitly declare the entity api name.
*/
public function getDefaultEntity() {
return 'PledgePayment';
}
/**
* Explicitly declare the form context.
*/
public function getDefaultContext() {
return 'create';
}
/**
* Set variables up before form is built.
*/
......@@ -66,7 +80,6 @@ class CRM_Pledge_Form_Payment extends CRM_Core_Form {
if ($this->_id) {
$params['id'] = $this->_id;
CRM_Pledge_BAO_PledgePayment::retrieve($params, $defaults);
list($defaults['scheduled_date']) = CRM_Utils_Date::setDateDefaults($defaults['scheduled_date']);
if (isset($defaults['contribution_id'])) {
$this->assign('pledgePayment', TRUE);
}
......@@ -82,7 +95,7 @@ class CRM_Pledge_Form_Payment extends CRM_Core_Form {
*/
public function buildQuickForm() {
// add various dates
$this->addDate('scheduled_date', ts('Scheduled Date'), TRUE);
$this->addField('scheduled_date', [], TRUE, FALSE);
$this->addMoney('scheduled_amount',
ts('Scheduled Amount'), TRUE,
......@@ -122,29 +135,24 @@ class CRM_Pledge_Form_Payment extends CRM_Core_Form {
* Process the form submission.
*/
public function postProcess() {
// get the submitted form values.
$formValues = $this->controller->exportValues($this->_name);
$params = array();
$formValues['scheduled_date'] = CRM_Utils_Date::processDate($formValues['scheduled_date']);
$params['scheduled_date'] = CRM_Utils_Date::format($formValues['scheduled_date']);
$params['currency'] = CRM_Utils_Array::value('currency', $formValues);
$now = date('Ymd');
$params = [
'id' => $this->_id,
'scheduled_date' => $formValues['scheduled_date'],
'currency' => $formValues['currency'],
];
if (CRM_Utils_Date::overdue(CRM_Utils_Date::customFormat($params['scheduled_date'], '%Y%m%d'), $now)) {
if (CRM_Utils_Date::overdue($params['scheduled_date'])) {
$params['status_id'] = CRM_Core_PseudoConstant::getKey('CRM_Pledge_BAO_Pledge', 'status_id', 'Overdue');
}
else {
$params['status_id'] = CRM_Core_PseudoConstant::getKey('CRM_Pledge_BAO_Pledge', 'status_id', 'Pending');
}
$params['id'] = $this->_id;
$pledgeId = CRM_Core_DAO::getFieldValue('CRM_Pledge_DAO_PledgePayment', $params['id'], 'pledge_id');
CRM_Pledge_BAO_PledgePayment::add($params);
$adjustTotalAmount = FALSE;
if (CRM_Utils_Array::value('option_type', $formValues) == 2) {
$adjustTotalAmount = TRUE;
}
$adjustTotalAmount = (CRM_Utils_Array::value('option_type', $formValues) == 2);
$pledgeScheduledAmount = CRM_Core_DAO::getFieldValue('CRM_Pledge_DAO_PledgePayment',
$params['id'],
......
......@@ -788,7 +788,7 @@ class CRM_Utils_Date {
$now = self::isoToMysql($now);
}
return ($mysqlDate >= $now) ? FALSE : TRUE;
return (strtotime($mysqlDate) >= strtotime($now)) ? FALSE : TRUE;
}
/**
......
......@@ -32,7 +32,7 @@
</tr>
<tr>
<td class="label">{$form.scheduled_date.label}</td>
<td>{include file="CRM/common/jcalendar.tpl" elementName=scheduled_date}</td>
<td>{$form.scheduled_date.html}</td>
</tr>
<tr>
<td class="label">{$form.scheduled_amount.label}</td>
......
......@@ -101,6 +101,10 @@
<required>true</required>
<comment>The date the pledge payment is supposed to happen.</comment>
<add>2.1</add>
<html>
<type>Select Date</type>
<formatType>activityDate</formatType>
</html>
</field>
<field>
<name>reminder_date</name>
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment