Commit 178774fe authored by eileen's avatar eileen

CRM-19490 define non-updated fields in a function for easier transition.

Looking to find a way to migrate these as safely as possible. Defining them in one place seems like a good step
parent e9f229db
......@@ -518,6 +518,9 @@ class CRM_Core_BAO_UFGroup extends CRM_Core_DAO_UFGroup {
);
$formattedField = CRM_Utils_Date::addDateMetadataToField($fieldMetaData, $formattedField);
if (in_array($name, array_keys(self::getNonUpgradedDateFields()))) {
$formattedField['is_legacy_date'] = 1;
}
//adding custom field property
if (substr($field->field_name, 0, 6) == 'custom' ||
......@@ -1905,6 +1908,7 @@ AND ( entity_id IS NULL OR entity_id <= 0 )
$addressOptions = CRM_Core_BAO_Setting::valueOptions(CRM_Core_BAO_Setting::SYSTEM_PREFERENCES_NAME,
'address_options', TRUE, NULL, TRUE
);
$legacyHandledDateFields = self::getNonUpgradedDateFields();
if (substr($fieldName, 0, 14) === 'state_province') {
$form->addChainSelect($name, array('label' => $title, 'required' => $required));
......@@ -1967,15 +1971,8 @@ AND ( entity_id IS NULL OR entity_id <= 0 )
}
}
}
elseif (($fieldName === 'birth_date') || ($fieldName === 'deceased_date')) {
$form->addDate($name, $title, $required, array('formatType' => 'birth'));
}
elseif (in_array($fieldName, array(
'membership_start_date',
'membership_end_date',
'join_date',
))) {
$form->addDate($name, $title, $required, array('formatType' => 'activityDate'));
elseif (isset($legacyHandledDateFields[$fieldName])) {
$form->addDate($name, $title, $required, array('formatType' => $legacyHandledDateFields[$fieldName]));
}
elseif (CRM_Utils_Array::value('name', $field) == 'membership_type') {
list($orgInfo, $types) = CRM_Member_BAO_MembershipType::getMembershipTypeInfo();
......@@ -2151,14 +2148,6 @@ AND ( entity_id IS NULL OR entity_id <= 0 )
CRM_Core_BAO_CustomField::addQuickFormElement($form, $name, $customFieldID, $required, $search, $title);
}
}
elseif (in_array($fieldName, array(
'receive_date',
'receipt_date',
'thankyou_date',
'cancel_date',
))) {
$form->addDateTime($name, $title, $required, array('formatType' => 'activityDateTime'));
}
elseif ($fieldName == 'send_receipt') {
$form->addElement('checkbox', $name, $title);
}
......@@ -2230,9 +2219,6 @@ AND ( entity_id IS NULL OR entity_id <= 0 )
) + CRM_Contribute_PseudoConstant::contributionPage(), $required, 'class="big"'
);
}
elseif ($fieldName == 'participant_register_date') {
$form->addDateTime($name, $title, $required, array('formatType' => 'activityDateTime'));
}
elseif ($fieldName == 'activity_status_id') {
$form->add('select', $name, $title,
array(
......@@ -2247,9 +2233,6 @@ AND ( entity_id IS NULL OR entity_id <= 0 )
) + CRM_Campaign_PseudoConstant::engagementLevel(), $required
);
}
elseif ($fieldName == 'activity_date_time') {
$form->addDateTime($name, $title, $required, array('formatType' => 'activityDateTime'));
}
elseif ($fieldName == 'participant_status') {
$cond = NULL;
if ($online == TRUE) {
......@@ -2347,6 +2330,30 @@ AND ( entity_id IS NULL OR entity_id <= 0 )
}
}
/**
* Get fields that have not been upgraded to use datepicker.
*
* Fields that use the old code have jcalendar in the tpl and
* the form uses a customised format. We are moving towards datepicker
* which among other things passes dates back and forth using a standardised
* format. Remove fields from here as they are tested and converted.
*/
static public function getNonUpgradedDateFields() {
return array(
'birth_date' => 'birth',
'deceased_date' => 'birth',
'membership_start_date' => 'activityDate',
'membership_end_date' => 'activityDate',
'join_date' => 'activityDate',
'receive_date' => 'activityDateTime',
'receipt_date' => 'activityDateTime',
'thankyou_date' => 'activityDateTime',
'cancel_date' => 'activityDateTime',
'participant_register_date' => 'activityDateTime',
'activity_date_time' => 'activityDateTime',
);
}
/**
* Set profile defaults.
*
......
......@@ -57,7 +57,7 @@ function smarty_modifier_crmDate($dateString, $dateFormat = NULL, $onlyTime = FA
$dateFormat = $config->dateformatTime;
}
// Handle possibility we only have a date function style date format.
if ($dateFormat && !stristr('%', $dateFormat)) {
if ($dateFormat && !stristr($dateFormat, '%')) {
return date($dateFormat, strtotime($dateString));
}
......
......@@ -89,19 +89,17 @@
{include file="CRM/Profile/Form/GreetingType.tpl"}
{elseif ($profileFieldName eq 'group' && $form.group) || ($profileFieldName eq 'tag' && $form.tag)}
{include file="CRM/Contact/Form/Edit/TagsAndGroups.tpl" type=$profileFieldName title=null context="profile"}
{elseif ( $profileFieldName|substr:-5:5 eq '_date' ) AND
( $form.formName neq 'Confirm' ) AND
( $form.formName neq 'ThankYou' ) }
{include file="CRM/common/jcalendar.tpl" elementName=$profileFieldName}
{elseif $field.is_datetime_field && $action == 4}
{assign var="date_value" value=$form.$profileFieldName.value}
<span class="crm-frozen-field">
{$date_value|date_format:"%Y-%m-%d"|crmDate:$field.php_datetime_format}
{$date_value|date_format:"%Y-%m-%d"|crmDate:$config->dateformatshortdate}
<input type="hidden"
name="{$form.$profileFieldName.name}"
value="{$form.$profileFieldName.value}" id="{$form.$profileFieldName.name}"
>
</span>
{elseif $field.is_legacy_date}
{include file="CRM/common/jcalendar.tpl" elementName=$profileFieldName}
{elseif $profileFieldName|substr:0:5 eq 'phone'}
{assign var="phone_ext_field" value=$profileFieldName|replace:'phone':'phone_ext'}
{if $prefix}{$form.$prefix.$profileFieldName.html}{else}{$form.$profileFieldName.html}{/if}
......
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