From 7d8f464af2faee7a009a31925e776ae4908f0ce0 Mon Sep 17 00:00:00 2001 From: eileen Date: Thu, 31 Oct 2019 20:35:00 +1300 Subject: [PATCH] Jcalendar converstion on relation_active_period_date Same as https://github.com/civicrm/civicrm-core/pull/15661 Conversion excluded for now --- CRM/Contact/BAO/Query.php | 11 +++++++++++ CRM/Contact/BAO/SavedSearch.php | 1 - CRM/Contact/Form/Search/Criteria.php | 13 ++++++++++++- .../Contact/Form/Search/Criteria/Relationship.tpl | 2 +- 4 files changed, 24 insertions(+), 3 deletions(-) diff --git a/CRM/Contact/BAO/Query.php b/CRM/Contact/BAO/Query.php index ed641932bc..ab90299b2d 100644 --- a/CRM/Contact/BAO/Query.php +++ b/CRM/Contact/BAO/Query.php @@ -513,6 +513,16 @@ class CRM_Contact_BAO_Query { } $relationMetadata = CRM_Contact_BAO_Relationship::fields(); $relationFields = array_intersect_key($relationMetadata, array_fill_keys(['relationship_start_date', 'relationship_end_date'], 1)); + // No good option other than hard-coding metadata for this 'special' field in. + $relationFields['relation_active_period_date'] = [ + 'name' => 'relation_active_period_date', + 'type' => CRM_Utils_Type::T_DATE + CRM_Utils_Type::T_TIME, + 'title' => ts('Active Period'), + 'table_name' => 'civicrm_relationship', + 'where' => 'civicrm_relationship.start_date', + 'where_end' => 'civicrm_relationship.end_date', + 'html' => ['type' => 'SelectDate', 'formatType' => 'activityDateTime'], + ]; $this->_fields = array_merge($relationFields, $this->_fields); $fields = CRM_Core_Component::getQueryFields(!$this->_skipPermission); @@ -1608,6 +1618,7 @@ class CRM_Contact_BAO_Query { 'mailing_job_start_date_relative', 'birth_date_relative', 'deceased_date_relative', + 'relation_active_period_date_relative', ]; // Handle relative dates first foreach (array_keys($formValues) as $id) { diff --git a/CRM/Contact/BAO/SavedSearch.php b/CRM/Contact/BAO/SavedSearch.php index 414de20abc..c929be0e91 100644 --- a/CRM/Contact/BAO/SavedSearch.php +++ b/CRM/Contact/BAO/SavedSearch.php @@ -399,7 +399,6 @@ LEFT JOIN civicrm_email ON (contact_a.id = civicrm_email.contact_id AND civicrm_ $relativeDates = ['relative_dates' => []]; $specialDateFields = [ 'log_date_relative', - 'relation_action_date_relative', ]; foreach ($formValues as $id => $value) { if (in_array($id, $specialDateFields) && !empty($value)) { diff --git a/CRM/Contact/Form/Search/Criteria.php b/CRM/Contact/Form/Search/Criteria.php index 267f2b6406..243286cdfc 100644 --- a/CRM/Contact/Form/Search/Criteria.php +++ b/CRM/Contact/Form/Search/Criteria.php @@ -268,7 +268,19 @@ class CRM_Contact_Form_Search_Criteria { 'is_deceased' => ['is_deceased', 'template_grouping' => 'demographic'], 'relationship_start_date' => ['name' => 'relationship_start_date', 'template_grouping' => 'relationship'], 'relationship_end_date' => ['name' => 'relationship_end_date', 'template_grouping' => 'relationship'], + // PseudoRelationship date field. + 'relation_active_period_date' => [ + 'name' => 'relation_active_period_date', + 'type' => CRM_Utils_Type::T_DATE + CRM_Utils_Type::T_TIME, + 'title' => ts('Active Period'), + 'table_name' => 'civicrm_relationship', + 'where' => 'civicrm_relationship.start_date', + 'where_end' => 'civicrm_relationship.end_date', + 'html' => ['type' => 'SelectDate', 'formatType' => 'activityDateTime'], + 'template_grouping' => 'relationship', + ], ]; + $metadata = civicrm_api3('Relationship', 'getfields', [])['values']; $metadata = array_merge($metadata, civicrm_api3('Contact', 'getfields', [])['values']); foreach ($fields as $fieldName => $field) { @@ -539,7 +551,6 @@ class CRM_Contact_Form_Search_Criteria { ['id' => 'relation_target_group', 'multiple' => 'multiple', 'class' => 'crm-select2'] ); } - CRM_Core_Form_Date::buildDateRange($form, 'relation_active_period_date', 1, '_low', '_high', ts('From:'), FALSE, FALSE); // add all the custom searchable fields CRM_Core_BAO_Query::addCustomFormFields($form, ['Relationship']); diff --git a/templates/CRM/Contact/Form/Search/Criteria/Relationship.tpl b/templates/CRM/Contact/Form/Search/Criteria/Relationship.tpl index 676c44c2bc..103f63a8a6 100644 --- a/templates/CRM/Contact/Form/Search/Criteria/Relationship.tpl +++ b/templates/CRM/Contact/Form/Search/Criteria/Relationship.tpl @@ -69,7 +69,7 @@ {help id="id-relationship-active-period" file="CRM/Contact/Form/Search/Advanced.hlp"}
- {include file="CRM/Core/DateRange.tpl" fieldName="relation_active_period_date" from='_low' to='_high'} + {include file="CRM/Core/DatePickerRangeWrapper.tpl" fieldName="relation_active_period_date" hideRelativeLabel=1} {if $relationshipGroupTree} -- 2.25.1