From 70a44aeedb8ed5474bc62155cc32149636750ede Mon Sep 17 00:00:00 2001 From: Seamus Lee Date: Fri, 30 Nov 2018 22:39:25 +0000 Subject: [PATCH] dev/core#561 Replace jacalendar with datepicker in Price Field Form Update Display of Field dates as well --- CRM/Price/DAO/PriceField.php | 6 ++++-- CRM/Price/Form/Field.php | 27 ++------------------------- templates/CRM/Price/Form/Field.tpl | 4 ++-- templates/CRM/Price/Page/Field.tpl | 4 ++-- xml/schema/Price/PriceField.xml | 4 +++- 5 files changed, 13 insertions(+), 32 deletions(-) diff --git a/CRM/Price/DAO/PriceField.php b/CRM/Price/DAO/PriceField.php index dbf9f8f9b5..b3d89d2854 100644 --- a/CRM/Price/DAO/PriceField.php +++ b/CRM/Price/DAO/PriceField.php @@ -6,7 +6,7 @@ * * Generated from xml/schema/CRM/Price/PriceField.xml * DO NOT EDIT. Generated by CRM_Core_CodeGen - * (GenCodeChecksum:2a85d03f1f7e607a89d20b810d8ead38) + * (GenCodeChecksum:e9ff5a22489167a421efd2f415ba4f58) */ /** @@ -374,7 +374,8 @@ class CRM_Price_DAO_PriceField extends CRM_Core_DAO { 'bao' => 'CRM_Price_BAO_PriceField', 'localizable' => 0, 'html' => [ - 'type' => 'CheckBox', + 'type' => 'Select Date', + 'formatType' => 'activityDateTime', ], ], 'expire_on' => [ @@ -389,6 +390,7 @@ class CRM_Price_DAO_PriceField extends CRM_Core_DAO { 'localizable' => 0, 'html' => [ 'type' => 'Select Date', + 'formatType' => 'activityDateTime', ], ], 'javascript' => [ diff --git a/CRM/Price/Form/Field.php b/CRM/Price/Form/Field.php index 08b36bf6a8..5b158cc8f3 100644 --- a/CRM/Price/Form/Field.php +++ b/CRM/Price/Form/Field.php @@ -115,17 +115,6 @@ class CRM_Price_Form_Field extends CRM_Core_Form { $defaults['is_active'] = $isActive; } - if (!empty($defaults['active_on'])) { - list($defaults['active_on'], - $defaults['active_on_time'] - ) = CRM_Utils_Date::setDateDefaults($defaults['active_on'], 'activityDateTime'); - } - - if (!empty($defaults['expire_on'])) { - list($defaults['expire_on'], - $defaults['expire_on_time'] - ) = CRM_Utils_Date::setDateDefaults($defaults['expire_on'], 'activityDateTime'); - } } else { $defaults['is_active'] = 1; @@ -338,10 +327,10 @@ class CRM_Price_Form_Field extends CRM_Core_Form { CRM_Core_DAO::getAttribute('CRM_Price_DAO_PriceField', 'help_post') ); - $this->addDateTime('active_on', ts('Active On'), FALSE, array('formatType' => 'activityDateTime')); + $this->add('datepicker', 'active_on', ts('Active On'), [], FALSE, array('time' => TRUE)); // expire_on - $this->addDateTime('expire_on', ts('Expire On'), FALSE, array('formatType' => 'activityDateTime')); + $this->add('datepicker', 'expire_on', ts('Expire On'), [], FALSE, array('time' => TRUE)); // is required ? $this->add('checkbox', 'is_required', ts('Required?')); @@ -643,18 +632,6 @@ class CRM_Price_Form_Field extends CRM_Core_Form { $params['is_required'] = CRM_Utils_Array::value('is_required', $params, FALSE); $params['is_active'] = CRM_Utils_Array::value('is_active', $params, FALSE); $params['financial_type_id'] = CRM_Utils_Array::value('financial_type_id', $params, FALSE); - if (isset($params['active_on'])) { - $params['active_on'] = CRM_Utils_Date::processDate($params['active_on'], - CRM_Utils_Array::value('active_on_time', $params), - TRUE - ); - } - if (isset($params['expire_on'])) { - $params['expire_on'] = CRM_Utils_Date::processDate($params['expire_on'], - CRM_Utils_Array::value('expire_on_time', $params), - TRUE - ); - } $params['visibility_id'] = CRM_Utils_Array::value('visibility_id', $params, FALSE); $params['count'] = CRM_Utils_Array::value('count', $params, FALSE); diff --git a/templates/CRM/Price/Form/Field.tpl b/templates/CRM/Price/Form/Field.tpl index 2428a03a97..35a69edc35 100644 --- a/templates/CRM/Price/Form/Field.tpl +++ b/templates/CRM/Price/Form/Field.tpl @@ -205,7 +205,7 @@ {$form.active_on.label} - {include file="CRM/common/jcalendar.tpl" elementName=active_on} + {$form.active_on.html} {if $action neq 4}
{ts}Date this field becomes effective (optional). Used for price set fields that are made available starting on a specific date.{/ts} {/if} @@ -214,7 +214,7 @@ {$form.expire_on.label} - {include file="CRM/common/jcalendar.tpl" elementName=expire_on} + {$form.expire_on.html} {if $action neq 4}
{ts}Date this field expires (optional). Used for price set fields that are no longer available after a specific date (e.g. early-bird pricing).{/ts} {/if} diff --git a/templates/CRM/Price/Page/Field.tpl b/templates/CRM/Price/Page/Field.tpl index fdbfddf01a..0a02c7ee77 100644 --- a/templates/CRM/Price/Page/Field.tpl +++ b/templates/CRM/Price/Page/Field.tpl @@ -79,8 +79,8 @@ {$row.weight} {if $row.is_required eq 1} {ts}Yes{/ts} {else} {ts}No{/ts} {/if} {if $row.is_active eq 1} {ts}Yes{/ts} {else} {ts}No{/ts} {/if} - {if $row.active_on}{$row.active_on|date_format:"%Y-%m-%d %T"}{/if} - {if $row.expire_on}{$row.expire_on|date_format:"%Y-%m-%d %T"}{/if} + {if $row.active_on}{$row.active_on|crmDate}{/if} + {if $row.expire_on}{$row.expire_on|crmDate}{/if} {if $row.html_type eq "Text"}{$row.price|crmMoney}{else}{if $isReserved}{ts}View Price Options{/ts}{else}{ts}Edit Price Options{/ts}{/if}{/if} {if $getTaxDetails} {if $row.tax_rate != '' && $row.html_type eq "Text / Numeric Quantity"} diff --git a/xml/schema/Price/PriceField.xml b/xml/schema/Price/PriceField.xml index ea9bd977aa..57efda8f90 100644 --- a/xml/schema/Price/PriceField.xml +++ b/xml/schema/Price/PriceField.xml @@ -174,7 +174,8 @@ If non-zero, do not show this field before the date specified 1.8 - CheckBox + Select Date + activityDateTime @@ -186,6 +187,7 @@ 1.8 Select Date + activityDateTime -- 2.25.1