Skip to content
Snippets Groups Projects
Commit 267fb11a authored by Seamus Lee's avatar Seamus Lee Committed by eileen
Browse files

#561 Convert Pledge Payment form to use datepicker rather than jcalendar

parent f90d376c
Branches
Tags
No related merge requests found
......@@ -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'],
......
......@@ -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>
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment