diff --git a/CRM/Contact/BAO/SavedSearch.php b/CRM/Contact/BAO/SavedSearch.php index dd6e6b36bef1..67a61350bac3 100644 --- a/CRM/Contact/BAO/SavedSearch.php +++ b/CRM/Contact/BAO/SavedSearch.php @@ -391,6 +391,7 @@ protected function assignTestValue($fieldName, &$fieldDef, $counter) { * * @param array $queryParams * @param array $formValues + * @deprecated */ public static function saveRelativeDates(&$queryParams, $formValues) { // This is required only until all fields are converted to datepicker fields as the new format is truer to the @@ -398,11 +399,7 @@ public static function saveRelativeDates(&$queryParams, $formValues) { $relativeDates = ['relative_dates' => []]; $specialDateFields = [ 'event_relative', - 'participant_relative', 'log_date_relative', - 'birth_date_relative', - 'deceased_date_relative', - 'relation_date_relative', 'relation_action_date_relative', ]; foreach ($formValues as $id => $value) { diff --git a/CRM/Contact/Form/Search/Criteria.php b/CRM/Contact/Form/Search/Criteria.php index 154331dbe0a5..298db709dbcb 100644 --- a/CRM/Contact/Form/Search/Criteria.php +++ b/CRM/Contact/Form/Search/Criteria.php @@ -540,9 +540,6 @@ public static function relationship(&$form) { } CRM_Core_Form_Date::buildDateRange($form, 'relation_active_period_date', 1, '_low', '_high', ts('From:'), FALSE, FALSE); - // Add reltionship dates - CRM_Core_Form_Date::buildDateRange($form, 'relation_date', 1, '_low', '_high', ts('From:'), FALSE, FALSE); - // add all the custom searchable fields CRM_Core_BAO_Query::addCustomFormFields($form, ['Relationship']); } diff --git a/CRM/Upgrade/Incremental/SmartGroups.php b/CRM/Upgrade/Incremental/SmartGroups.php index a8d2ab7c4900..a5f61cf42be7 100644 --- a/CRM/Upgrade/Incremental/SmartGroups.php +++ b/CRM/Upgrade/Incremental/SmartGroups.php @@ -71,8 +71,8 @@ public function datePickerConversion($fields) { 'case_start_date' => 'case_from', 'case_end_date' => 'case_to', 'mailing_job_start_date' => 'mailing_date', - 'relationship_start_date' => 'relation_start_date', - 'relationship_end_date' => 'relation_end_date', + 'relationship_start_date' => 'relation_start', + 'relationship_end_date' => 'relation_end', ]; foreach ($fields as $field) { diff --git a/tests/phpunit/CRM/Upgrade/Incremental/BaseTest.php b/tests/phpunit/CRM/Upgrade/Incremental/BaseTest.php index be60f5ff4c23..0bbc8303baf2 100644 --- a/tests/phpunit/CRM/Upgrade/Incremental/BaseTest.php +++ b/tests/phpunit/CRM/Upgrade/Incremental/BaseTest.php @@ -156,6 +156,35 @@ public function testSmartGroupMultipleRelatvieDateConversions() { $this->assertEquals('this.week', $savedSearch['form_values'][8][2]); } + /** + * Test converting relationship fields + */ + public function testSmartGroupRelationshipDateConversions() { + $this->callAPISuccess('SavedSearch', 'create', [ + 'form_values' => [ + ['relationship_start_date_low', '=', '20191001000000'], + ['relationship_start_date_high', '=', '20191031235959'], + ['relationship_end_date_low', '=', '20191001000000'], + ['relationship_end_date_high', '=', '20191031235959'], + 'relative_dates' => [ + 'relation_start' => 'this.month', + 'relation_end' => 'this.month', + ], + ], + ]); + $smartGroupConversionObject = new CRM_Upgrade_Incremental_SmartGroups(); + $smartGroupConversionObject->updateGroups([ + 'datepickerConversion' => [ + 'relationship_start_date', + 'relationship_end_date', + ], + ]); + $savedSearch = $this->callAPISuccessGetSingle('SavedSearch', []); + $this->assertEquals([], $savedSearch['form_values']['relative_dates']); + $this->assertEquals(['relationship_start_date_relative', '=', 'this.month'], $savedSearch['form_values'][4]); + $this->assertEquals(['relationship_end_date_relative', '=', 'this.month'], $savedSearch['form_values'][5]); + } + /** * Test conversion of on hold group. */