+ /**
+ * Check if the values in the date range are in correct chronological order.
+ *
+ * @param array $fields
+ * @param array $files
+ * @param CRM_Core_Form $form
+ *
+ * @return bool|array
+ */
+ public static function formRule($fields, $files, $form) {
+ $errors = array();
+
+ 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']))) {
+ return TRUE;
+ }
+ $lowDate = strtotime($fields['event_start_date_low']);
+ $highDate = strtotime($fields['event_end_date_high']);
+
+ if ($lowDate > $highDate) {
+ $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;
+ }
+