Commit 8a6fde27 authored by eileen's avatar eileen

[jcalendar] remove jcalendar usage from participant_register_date on event search

This removes one more place where legacy jcalendar is used. There is actually still one left on the form (event date)
which I left out for now as it involves thinking about the fact event is a different entity & might warrant different
representation in the arrays
parent 61b4d091
......@@ -1553,23 +1553,21 @@ class CRM_Contact_BAO_Query {
}
self::filterCountryFromValuesIfStateExists($formValues);
// We shouldn't have to whitelist fields to not hack but here we are, for now.
$nonLegacyDateFields = ['participant_register_date_relative'];
// Handle relative dates first
foreach (array_keys($formValues) as $id) {
if (preg_match('/_date_relative$/', $id) ||
if (
!in_array($id, $nonLegacyDateFields) && (
preg_match('/_date_relative$/', $id) ||
$id == 'event_relative' ||
$id == 'case_from_relative' ||
$id == 'case_to_relative' ||
$id == 'participant_relative'
$id == 'case_to_relative')
) {
if ($id == 'event_relative') {
$fromRange = 'event_start_date_low';
$toRange = 'event_end_date_high';
}
elseif ($id == 'participant_relative') {
$fromRange = 'participant_register_date_low';
$toRange = 'participant_register_date_high';
}
elseif ($id == 'case_from_relative') {
$fromRange = 'case_from_start_date_low';
$toRange = 'case_from_start_date_high';
......@@ -1647,11 +1645,12 @@ class CRM_Contact_BAO_Query {
) {
self::convertCustomRelativeFields($formValues, $params, $values, $id);
}
elseif (preg_match('/_date_relative$/', $id) ||
$id == 'event_relative' ||
$id == 'case_from_relative' ||
$id == 'case_to_relative' ||
$id == 'participant_relative'
elseif (
!in_array($id, $nonLegacyDateFields) && (
preg_match('/_date_relative$/', $id) ||
$id == 'event_relative' ||
$id == 'case_from_relative' ||
$id == 'case_to_relative')
) {
// Already handled in previous loop
continue;
......
......@@ -95,8 +95,6 @@ class CRM_Contact_BAO_SavedSearch extends CRM_Contact_DAO_SavedSearch {
$specialDateFields = [
'event_start_date_low' => 'event_date_low',
'event_end_date_high' => 'event_date_high',
'participant_register_date_low' => 'participant_date_low',
'participant_register_date_high' => 'participant_date_high',
'case_from_start_date_low' => 'case_from_date_low',
'case_from_start_date_high' => 'case_from_date_high',
'case_to_end_date_low' => 'case_to_date_low',
......
......@@ -186,7 +186,7 @@ class CRM_Core_Form_Search extends CRM_Core_Form {
foreach ($form->getSearchFieldMetadata() as $entity => $spec) {
foreach ($spec as $fieldName => $fieldSpec) {
if ($fieldSpec['type'] === CRM_Utils_Type::T_DATE || $fieldSpec['type'] === (CRM_Utils_Type::T_DATE + CRM_Utils_Type::T_TIME)) {
if (isset($fields[$fieldName . '_high']) && isset($fields[$fieldName . '_low']) && empty($fields[$fieldName . '_relative'])) {
if (!empty($fields[$fieldName . '_high']) && !empty($fields[$fieldName . '_low']) && empty($fields[$fieldName . '_relative'])) {
if (strtotime($fields[$fieldName . '_low']) > strtotime($fields[$fieldName . '_high'])) {
$errors[$fieldName . '_low'] = ts('%1: Please check that your date range is in correct chronological order.', [1 => $fieldSpec['title']]);
}
......
......@@ -582,6 +582,7 @@ class CRM_Event_BAO_Query extends CRM_Core_BAO_Query {
public static function getSearchFieldMetadata() {
$fields = [
'participant_status_id',
'participant_register_date',
];
$metadata = civicrm_api3('Participant', 'getfields', [])['values'];
return array_intersect_key($metadata, array_flip($fields));
......@@ -628,10 +629,7 @@ class CRM_Event_BAO_Query extends CRM_Core_BAO_Query {
CRM_Core_Form_Date::buildDateRange($form, 'event', 1, '_start_date_low', '_end_date_high', ts('From'), FALSE);
CRM_Core_Form_Date::buildDateRange($form, 'participant', 1, '_register_date_low', '_register_date_high', ts('From'), FALSE);
$form->addElement('hidden', 'event_date_range_error');
$form->addElement('hidden', 'participant_date_range_error');
$form->addFormRule(['CRM_Event_BAO_Query', 'formRule'], $form);
$form->addElement('checkbox', "event_include_repeating_events", NULL, ts('Include participants from all events in the %1 series', [1 => '<em>%1</em>']));
......@@ -686,7 +684,7 @@ class CRM_Event_BAO_Query extends CRM_Core_BAO_Query {
public static function formRule($fields, $files, $form) {
$errors = [];
if ((empty($fields['event_start_date_low']) || empty($fields['event_end_date_high'])) && (empty($fields['participant_register_date_low']) || empty($fields['participant_register_date_high']))) {
if ((empty($fields['event_start_date_low']) || empty($fields['event_end_date_high']))) {
return TRUE;
}
$lowDate = strtotime($fields['event_start_date_low']);
......@@ -696,12 +694,6 @@ class CRM_Event_BAO_Query extends CRM_Core_BAO_Query {
$errors['event_date_range_error'] = ts('Please check that your Event Date Range is in correct chronological order.');
}
$lowDate1 = strtotime($fields['participant_register_date_low']);
$highDate1 = strtotime($fields['participant_register_date_high']);
if ($lowDate1 > $highDate1) {
$errors['participant_date_range_error'] = ts('Please check that your Registration Date Range is in correct chronological order.');
}
return empty($errors) ? TRUE : $errors;
}
......
......@@ -77,8 +77,9 @@ class CRM_Event_Form_Search extends CRM_Core_Form_Search {
*/
protected $searchFieldMetadata = [];
/**
* Get the default entity for the form.
*
* @return string
*/
public function getDefaultEntity() {
......
......@@ -76,6 +76,11 @@ class CRM_Upgrade_Incremental_php_FiveFifteen extends CRM_Upgrade_Incremental_Ba
$this->addTask(ts('Upgrade DB to %1: SQL', [1 => $rev]), 'runSql', $rev);
$this->addTask('Fix errant deferred revenue settings', 'updateContributeSettings');
$this->addTask('Fix cache key column name in prev next cache', 'fixCacheKeyColumnNamePrevNext');
$this->addTask('Update smart groups where jcalendar fields have been converted to datepicker', 'updateSmartGroups', [
'datepickerConversion' => [
'participant_register_date',
],
]);
}
public static function fixCacheKeyColumnNamePrevNext() {
......
......@@ -36,7 +36,7 @@
{include file="CRM/Core/DateRange.tpl" fieldName="event" from='_start_date_low' to='_end_date_high' label="<label>Event Dates</label>"}
</tr>
<tr>
{include file="CRM/Core/DateRange.tpl" fieldName="participant" from='_register_date_low' to='_register_date_high' label="<label>Registration Date</label>"}
{include file="CRM/Core/DatePickerRangeWrapper.tpl" fieldName="participant_register_date" colspan="2"}
</tr>
<tr>
<td class="crm-event-form-block-participant_status"><label>{$form.participant_status_id.label}</label>
......
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