Fix 0 in range filters
This commit is contained in:
@@ -97,15 +97,15 @@
|
||||
{elseif $params.type == 'range' && $params.value|is_array}
|
||||
{assign var="filter_value" value=''}
|
||||
{foreach $params.value as $value}
|
||||
{if ($value|is_string && !empty($value))}
|
||||
{if empty($filter_value)}
|
||||
{if (isset($value) && ($value !== '' || $value === 0))}
|
||||
{if !(isset($filter_value) && ($filter_value !== '' || $filter_value === 0))}
|
||||
{assign var="filter_value" value=$value}
|
||||
{else}
|
||||
{assign var="filter_value" value="`$filter_value` - `$value`"}
|
||||
{/if}
|
||||
{/if}
|
||||
{/foreach}
|
||||
{if !empty($filter_value)}
|
||||
{if (isset($filter_value) && ($filter_value !== '' || $filter_value === 0))}
|
||||
<span data-filter_key="{if isset($params.filter_key)}{$params.filter_key}{else}{$key}{/if}" data-filter_type="{$params.type}">
|
||||
{$params['title']|escape:'html':'UTF-8'}: <span class="filter_value">{$filter_value|escape:'html':'UTF-8'}</span>
|
||||
<i class="icon-times"></i>
|
||||
|
||||
@@ -905,18 +905,25 @@ class AdminControllerCore extends Controller
|
||||
$sql_filter .= ' AND '.pSQL($key).' IN ('.pSQL(implode(',', $value)).')';
|
||||
}
|
||||
} elseif ($type == 'range') {
|
||||
if (isset($value[0]) && !empty($value[0])) {
|
||||
if (!Validate::isUnsignedInt($value[0])) {
|
||||
// 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]);
|
||||
}
|
||||
|
||||
@@ -660,13 +660,24 @@ class HelperListCore extends Helper
|
||||
$value = json_decode($value, true);
|
||||
}
|
||||
|
||||
if (isset($value[0]) && !Validate::isUnsignedInt($value[0])) {
|
||||
// set validation type
|
||||
if (isset($params['validation']) && $params['validation'] && method_exists('Validate', $params['validation'])) {
|
||||
$validation = $params['validation'];
|
||||
} else {
|
||||
$validation = 'isUnsignedInt';
|
||||
}
|
||||
|
||||
$hasValueFrom = isset($value[0]) && ($value[0] !== '' || $value[0] === 0);
|
||||
if ($hasValueFrom && !Validate::$validation($value[0])) {
|
||||
$value[0] = '';
|
||||
}
|
||||
if (isset($value[1]) && !Validate::isUnsignedInt($value[1])) {
|
||||
|
||||
$hasValueTo = isset($value[1]) && ($value[1] !== '' || $value[1] === 0);
|
||||
if ($hasValueTo && !Validate::$validation($value[1])) {
|
||||
$value[1] = '';
|
||||
}
|
||||
if (isset($value[0]) && isset($value[1]) && $value[0] > $value[1]) {
|
||||
|
||||
if ($hasValueFrom && $hasValueTo && $value[0] > $value[1]) {
|
||||
$value[1] = '';
|
||||
}
|
||||
break;
|
||||
|
||||
@@ -88,7 +88,6 @@ class AdminProductsControllerCore extends AdminController
|
||||
parent::__construct();
|
||||
|
||||
$this->imageType = 'jpg';
|
||||
$this->_defaultOrderBy = 'position';
|
||||
$this->max_file_size = (int)(Configuration::get('PS_LIMIT_UPLOAD_FILE_VALUE') * 1000000);
|
||||
$this->max_image_size = (int)Configuration::get('PS_PRODUCT_PICTURE_MAX_SIZE');
|
||||
$this->allow_export = true;
|
||||
@@ -270,7 +269,7 @@ class AdminProductsControllerCore extends AdminController
|
||||
'type' => 'range',
|
||||
'align' => 'center',
|
||||
);
|
||||
$this->fields_list['child'] = array(
|
||||
$this->fields_list['children'] = array(
|
||||
'title' => $this->l('Children'),
|
||||
'filter_key' => 'hrt!children',
|
||||
'type' => 'range',
|
||||
@@ -286,8 +285,10 @@ class AdminProductsControllerCore extends AdminController
|
||||
$this->fields_list['price'] = array(
|
||||
'title' => $this->l('Base Price'),
|
||||
'type' => 'range',
|
||||
'validation' => 'isFloat',
|
||||
'align' => 'text-left',
|
||||
'filter_key' => 'a!price'
|
||||
'filter_key' => 'a!price',
|
||||
'callback' => 'displayBasePrice',
|
||||
);
|
||||
$this->fields_list['price_final'] = array(
|
||||
'title' => $this->l('Final price'),
|
||||
@@ -420,6 +421,9 @@ class AdminProductsControllerCore extends AdminController
|
||||
&& (int) $this->id_current_category
|
||||
&& HotelBranchInformation::getHotelIdByIdCategory($this->id_current_category)
|
||||
) {
|
||||
$this->_orderBy = 'position';
|
||||
$this->_orderWay = 'ASC';
|
||||
|
||||
$this->fields_list['position'] = array(
|
||||
'title' => $this->l('Position'),
|
||||
'filter_key' => 'cp!position',
|
||||
@@ -441,6 +445,11 @@ class AdminProductsControllerCore extends AdminController
|
||||
}
|
||||
}
|
||||
|
||||
public static function displayBasePrice($basePrice, $tr)
|
||||
{
|
||||
return Tools::displayPrice($basePrice, (int) Configuration::get('PS_CURRENCY_DEFAULT'));
|
||||
}
|
||||
|
||||
public static function getQuantities($hotelName, $tr)
|
||||
{
|
||||
if ((int)$tr['is_virtual'] == 1 && $tr['nb_downloadable'] == 0) {
|
||||
|
||||
Reference in New Issue
Block a user