diff --git a/date/date_views/includes/date_views_filter_handler_simple.inc b/date/date_views/includes/date_views_filter_handler_simple.inc index 8ac23cc..260592e 100644 --- a/date/date_views/includes/date_views_filter_handler_simple.inc +++ b/date/date_views/includes/date_views_filter_handler_simple.inc @@ -118,16 +118,30 @@ class date_views_filter_handler_simple extends views_handler_filter_date { $min_value = $this->get_filter_value('min', $this->value['min']); $max_value = $this->get_filter_value('max', $this->value['max']); - $field = $this->date_handler->sql_field($field, $this->offset); - $field = $this->date_handler->sql_format($this->format, $field); + $field_from = $this->date_handler->sql_field($field, $this->offset); + $field_from = $this->date_handler->sql_format($this->format, $field_from); $placeholder_min = $this->placeholder(); $placeholder_max = $this->placeholder(); $group = !empty($this->options['date_group']) ? $this->options['date_group'] : $this->options['group']; - if ($this->operator == 'between') { - $this->query->add_where_expression($group, "$field >= $placeholder_min AND $field <= $placeholder_max", array($placeholder_min => $min_value, $placeholder_max => $max_value)); + + if (isset($this->definition['additional fields'][1]) && substr($this->definition['additional fields'][1], -7) == '_value2') { + $field_to = $this->date_handler->sql_field($field . '2', $this->offset); + $field_to = $this->date_handler->sql_format($this->format, $field_to); + + if ($this->operator == 'between') { + $this->query->add_where_expression($group, "$field_to >= $placeholder_min AND $field_from <= $placeholder_max", array($placeholder_min => $min_value, $placeholder_max => $max_value)); + } + else { + $this->query->add_where_expression($group, "$field_to <= $placeholder_min OR $field_from >= $placeholder_max", array($placeholder_min => $min_value, $placeholder_max => $max_value)); + } } else { - $this->query->add_where_expression($group, "$field <= $placeholder_min OR $field >= $placeholder_max", array($placeholder_min => $min_value, $placeholder_max => $max_value)); + if ($this->operator == 'between') { + $this->query->add_where_expression($group, "$field_from >= $placeholder_min AND $field_from <= $placeholder_max", array($placeholder_min => $min_value, $placeholder_max => $max_value)); + } + else { + $this->query->add_where_expression($group, "$field_from <= $placeholder_min OR $field_from >= $placeholder_max", array($placeholder_min => $min_value, $placeholder_max => $max_value)); + } } }