Merge pull request #826 from abhishek-webkul/gli-1532

Updated: Filter by Places panel removed and added advanced filters and room type positioning on Manage Room Types page at back office
This commit is contained in:
Rohit Jain
2024-03-15 12:25:27 +05:30
committed by GitHub
11 changed files with 889 additions and 108 deletions

View File

@@ -875,7 +875,9 @@ class AdminControllerCore extends Controller
if ($field = $this->filterToField($key, $filter)) {
$type = (array_key_exists('filter_type', $field) ? $field['filter_type'] : (array_key_exists('type', $field) ? $field['type'] : false));
if (($type == 'date' || $type == 'datetime' || $type == 'range') && is_string($value)) {
if ((($type == 'date' || $type == 'datetime' || $type == 'range') || ($type == 'select' && (isset($field['multiple']) && $field['multiple'])))
&& is_string($value)
) {
$value = json_decode($value, true);
}
$key = isset($tmp_tab[1]) ? $tmp_tab[0].'.`'.$tmp_tab[1].'`' : '`'.$tmp_tab[0].'`';
@@ -893,21 +895,35 @@ class AdminControllerCore extends Controller
} else {
$sql_filter = & $this->_filter;
}
/* Only for date filtering (from, to) */
if (is_array($value)) {
if ($type == 'range') {
if (isset($value[0]) && !empty($value[0])) {
if (!Validate::isUnsignedInt($value[0])) {
if ($type == 'select' && (isset($field['multiple']) && $field['multiple']) && isset($field['operator'])) {
if ($field['operator'] == 'and') {
$sql_filter .= ' AND '.pSQL($key).' IN ('.pSQL(implode(',', $value)).')';
$this->_filterHaving .= ' AND COUNT(DISTINCT '.pSQL($key).') = '.(int) count($value);
} elseif ($field['operator'] == 'or') {
$sql_filter .= ' AND '.pSQL($key).' IN ('.pSQL(implode(',', $value)).')';
}
} elseif ($type == 'range') {
// set validation type
if (isset($field['validation']) && $field['validation'] && method_exists('Validate', $field['validation'])) {
$validation = $field['validation'];
} else {
$validation = 'isUnsignedInt';
}
if (isset($value[0]) && ($value[0] !== '' || $value[0] === 0)) {
if (!Validate::$validation($value[0])) {
$this->errors[] = Tools::displayError('The \'From\' value is invalid');
} else {
$sql_filter .= ' AND '.pSQL($key).' >= '.pSQL($value[0]);
}
}
if (isset($value[1]) && !empty($value[1])) {
if (!Validate::isUnsignedInt($value[1])) {
$this->errors[] = Tools::displayError('The \'From\' value is invalid');
} elseif (isset($value[0]) && !empty($value[0]) && $value[0] > $value[1]) {
$this->errors[] = Tools::displayError('The \'To\' value cannot be less than from value');
if (isset($value[1]) && ($value[1] !== '' || $value[1] === 0)) {
if (!Validate::$validation($value[1])) {
$this->errors[] = Tools::displayError('The \'To\' value is invalid');
} elseif ((isset($value[0]) && ($value[0] !== '' || $value[0] === 0)) && $value[0] > $value[1]) {
$this->errors[] = Tools::displayError('The \'To\' value cannot be less than \'From\' value');
} else {
$sql_filter .= ' AND '.pSQL($key).' <= '.pSQL($value[1]);
}