Skip to content

Commit

Permalink
Jcalendar converstion on relation_active_period_date
Browse files Browse the repository at this point in the history
Same as civicrm#15661

Conversion excluded for now
  • Loading branch information
eileenmcnaughton authored and magnolia61 committed Nov 1, 2019
1 parent 2ce3324 commit cf3f11f
Show file tree
Hide file tree
Showing 4 changed files with 24 additions and 3 deletions.
11 changes: 11 additions & 0 deletions CRM/Contact/BAO/Query.php
Original file line number Diff line number Diff line change
Expand Up @@ -513,6 +513,16 @@ public function __construct(
}
$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);
Expand Down Expand Up @@ -1608,6 +1618,7 @@ public static function convertFormValues(&$formValues, $wildcard = 0, $useEquals
'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) {
Expand Down
1 change: 0 additions & 1 deletion CRM/Contact/BAO/SavedSearch.php
Original file line number Diff line number Diff line change
Expand Up @@ -399,7 +399,6 @@ public static function saveRelativeDates(&$queryParams, $formValues) {
$relativeDates = ['relative_dates' => []];
$specialDateFields = [
'log_date_relative',
'relation_action_date_relative',
];
foreach ($formValues as $id => $value) {
if (in_array($id, $specialDateFields) && !empty($value)) {
Expand Down
13 changes: 12 additions & 1 deletion CRM/Contact/Form/Search/Criteria.php
Original file line number Diff line number Diff line change
Expand Up @@ -268,7 +268,19 @@ public static function getSearchFieldMetadata() {
'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) {
Expand Down Expand Up @@ -539,7 +551,6 @@ public static function relationship(&$form) {
['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']);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -69,7 +69,7 @@
<td colspan="2"><label>{ts}Active Period{/ts}</label> {help id="id-relationship-active-period" file="CRM/Contact/Form/Search/Advanced.hlp"}<br /></td>
</tr>
<tr>
{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}
</tr>
{if $relationshipGroupTree}
<tr>
Expand Down

0 comments on commit cf3f11f

Please sign in to comment.