Merge branch 'development' of https://github.com/PrestaShop/PrestaShop into bootstrap
Conflicts: admin-dev/themes/default/template/controllers/customers/helpers/view/view.tpl admin-dev/themes/default/template/controllers/modules_positions/form.tpl admin-dev/themes/default/template/controllers/orders/helpers/view/view.tpl admin-dev/themes/default/template/controllers/products/input_text_lang.tpl admin-dev/themes/default/template/controllers/products/shipping.tpl admin-dev/themes/default/template/controllers/shipping/content.tpl admin-dev/themes/default/template/helpers/form/form.tpl admin-dev/themes/default/template/helpers/list/list_header.tpl admin-dev/themes/default/template/toolbar.tpl classes/helper/HelperList.php controllers/admin/AdminCategoriesController.php controllers/admin/AdminManufacturersController.php controllers/admin/AdminModulesPositionsController.php controllers/admin/AdminPerformanceController.php controllers/admin/AdminStockInstantStateController.php css/admin.css js/admin-products.js js/admin.js
This commit is contained in:
@@ -48,6 +48,8 @@ class AdminControllerCore extends Controller
|
||||
/** @var string Associated table name */
|
||||
public $table;
|
||||
|
||||
public $list_id;
|
||||
|
||||
/** @var string Object identifier inside the associated table */
|
||||
protected $identifier = false;
|
||||
|
||||
@@ -380,6 +382,39 @@ class AdminControllerCore extends Controller
|
||||
break;
|
||||
}
|
||||
$this->toolbar_title = $bread_extended;
|
||||
|
||||
if (Tools::isSubmit('submitFilter'))
|
||||
{
|
||||
$filter = '';
|
||||
foreach ($this->fields_list AS $field => $t)
|
||||
{
|
||||
if ($val = Tools::getValue($this->table.'Filter_'.$field))
|
||||
{
|
||||
if(!is_array($val) && !empty($val))
|
||||
$filter .= ($filter ? ', ' : $this->l(' filter by ')).$t['title'].' : ';
|
||||
|
||||
if (isset($t['type']) && $t['type'] == 'bool')
|
||||
$filter .= ((bool)$val) ? $this->l('yes') : $this->l('no');
|
||||
elseif(is_string($val))
|
||||
$filter .= $val;
|
||||
elseif(is_array($val))
|
||||
{
|
||||
$tmp = '';
|
||||
foreach($val as $v)
|
||||
if(is_string($v) && !empty($v))
|
||||
$tmp .= ' - '.$v;
|
||||
if(Tools::strlen($tmp))
|
||||
{
|
||||
$tmp = ltrim($tmp, ' - ');
|
||||
$filter .= ($filter ? ', ' : $this->l(' filter by ')).$t['title'].' : ';
|
||||
$filter .= $tmp;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
if ($filter)
|
||||
$this->toolbar_title[] = $filter;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -430,29 +465,33 @@ class AdminControllerCore extends Controller
|
||||
*/
|
||||
public function processFilter()
|
||||
{
|
||||
if (!isset($this->list_id))
|
||||
$this->list_id = $this->table;
|
||||
|
||||
$prefix = str_replace(array('admin', 'controller'), '', Tools::strtolower(get_class($this)));
|
||||
// Filter memorization
|
||||
if (isset($_POST) && !empty($_POST) && isset($this->table))
|
||||
if (isset($_POST) && !empty($_POST) && isset($this->list_id))
|
||||
foreach ($_POST as $key => $value)
|
||||
{
|
||||
if (stripos($key, $this->table.'Filter_') === 0)
|
||||
if (stripos($key, $this->list_id.'Filter_') === 0)
|
||||
$this->context->cookie->{$prefix.$key} = !is_array($value) ? $value : serialize($value);
|
||||
elseif(stripos($key, 'submitFilter') === 0)
|
||||
$this->context->cookie->$key = !is_array($value) ? $value : serialize($value);
|
||||
}
|
||||
|
||||
if (isset($_GET) && !empty($_GET) && isset($this->table))
|
||||
if (isset($_GET) && !empty($_GET) && isset($this->list_id))
|
||||
foreach ($_GET as $key => $value)
|
||||
if (stripos($key, $this->table.'OrderBy') === 0 || stripos($key, $this->table.'Orderway') === 0)
|
||||
if (stripos($key, $this->list_id.'OrderBy') === 0 || stripos($key, $this->list_id.'Orderway') === 0)
|
||||
$this->context->cookie->{$prefix.$key} = $value;
|
||||
|
||||
$filters = $this->context->cookie->getFamily($prefix.$this->table.'Filter_');
|
||||
$filters = $this->context->cookie->getFamily($prefix.$this->list_id.'Filter_');
|
||||
|
||||
foreach ($filters as $key => $value)
|
||||
{
|
||||
/* Extracting filters from $_POST on key filter_ */
|
||||
if ($value != null && !strncmp($key, $prefix.$this->table.'Filter_', 7 + Tools::strlen($prefix.$this->table)))
|
||||
if ($value != null && !strncmp($key, $prefix.$this->list_id.'Filter_', 7 + Tools::strlen($prefix.$this->list_id)))
|
||||
{
|
||||
$key = Tools::substr($key, 7 + Tools::strlen($prefix.$this->table));
|
||||
$key = Tools::substr($key, 7 + Tools::strlen($prefix.$this->list_id));
|
||||
/* Table alias could be specified using a ! eg. alias!field */
|
||||
$tmp_tab = explode('!', $key);
|
||||
$filter = count($tmp_tab) > 1 ? $tmp_tab[1] : $tmp_tab[0];
|
||||
@@ -888,30 +927,32 @@ class AdminControllerCore extends Controller
|
||||
/**
|
||||
* Cancel all filters for this tab
|
||||
*/
|
||||
public function processResetFilters()
|
||||
public function processResetFilters($list_id = null)
|
||||
{
|
||||
if (!isset($list_id))
|
||||
$list_id = isset($this->list_id) ? $this->list_id : $this->table;
|
||||
|
||||
$prefix = str_replace(array('admin', 'controller'), '', Tools::strtolower(get_class($this)));
|
||||
$filters = $this->context->cookie->getFamily($prefix.$this->table.'Filter_');
|
||||
$filters = $this->context->cookie->getFamily($prefix.$list_id.'Filter_');
|
||||
|
||||
foreach ($filters as $cookie_key => $filter)
|
||||
if (strncmp($cookie_key, $prefix.$this->table.'Filter_', 7 + Tools::strlen($prefix.$this->table)) == 0)
|
||||
if (strncmp($cookie_key, $prefix.$list_id.'Filter_', 7 + Tools::strlen($prefix.$list_id)) == 0)
|
||||
{
|
||||
$key = substr($cookie_key, 7 + Tools::strlen($prefix.$this->table));
|
||||
/* Table alias could be specified using a ! eg. alias!field */
|
||||
$tmp_tab = explode('!', $key);
|
||||
$key = (count($tmp_tab) > 1 ? $tmp_tab[1] : $tmp_tab[0]);
|
||||
$key = substr($cookie_key, 7 + Tools::strlen($prefix.$list_id));
|
||||
|
||||
if (is_array($this->fields_list) && array_key_exists($key, $this->fields_list))
|
||||
$this->context->cookie->$cookie_key = null;
|
||||
unset($this->context->cookie->$cookie_key);
|
||||
}
|
||||
|
||||
if (isset($this->context->cookie->{'submitFilter'.$this->table}))
|
||||
unset($this->context->cookie->{'submitFilter'.$this->table});
|
||||
if (isset($this->context->cookie->{'submitFilter'.$list_id}))
|
||||
unset($this->context->cookie->{'submitFilter'.$list_id});
|
||||
|
||||
if (isset($this->context->cookie->{$prefix.$this->table.'Orderby'}))
|
||||
unset($this->context->cookie->{$prefix.$this->table.'Orderby'});
|
||||
if (isset($this->context->cookie->{$prefix.$list_id.'Orderby'}))
|
||||
unset($this->context->cookie->{$prefix.$list_id.'Orderby'});
|
||||
|
||||
if (isset($this->context->cookie->{$prefix.$this->table.'Orderway'}))
|
||||
unset($this->context->cookie->{$prefix.$this->table.'Orderway'});
|
||||
if (isset($this->context->cookie->{$prefix.$list_id.'Orderway'}))
|
||||
unset($this->context->cookie->{$prefix.$list_id.'Orderway'});
|
||||
|
||||
unset($_POST);
|
||||
$this->_filter = false;
|
||||
@@ -1287,7 +1328,7 @@ class AdminControllerCore extends Controller
|
||||
$current_id = Tab::getCurrentParentId();
|
||||
foreach ($tabs as $index => $tab)
|
||||
{
|
||||
if ($tab['class_name'] == 'AdminStock' && Configuration::get('PS_ADVANCED_STOCK_MANAGEMENT') == 0)
|
||||
if (($tab['class_name'] == 'AdminStock' && Configuration::get('PS_ADVANCED_STOCK_MANAGEMENT') == 0) || $tab['class_name'] == 'AdminCarrierWizard')
|
||||
{
|
||||
unset($tabs[$index]);
|
||||
continue;
|
||||
@@ -1327,7 +1368,7 @@ class AdminControllerCore extends Controller
|
||||
foreach ($sub_tabs as $index2 => $sub_tab)
|
||||
{
|
||||
// class_name is the name of the class controller
|
||||
if (Tab::checkTabRights($sub_tab['id_tab']) === true && (bool)$sub_tab['active'])
|
||||
if (Tab::checkTabRights($sub_tab['id_tab']) === true && (bool)$sub_tab['active'] && $sub_tab['class_name'] != 'AdminCarrierWizard')
|
||||
{
|
||||
$sub_tabs[$index2]['href'] = $this->context->link->getAdminLink($sub_tab['class_name']);
|
||||
$sub_tabs[$index2]['current'] = ($sub_tab['class_name'].'Controller' == get_class($this));
|
||||
@@ -1471,6 +1512,8 @@ class AdminControllerCore extends Controller
|
||||
*/
|
||||
protected function initTabModuleList()
|
||||
{
|
||||
if (!$this->isFresh(Module::CACHE_FILE_MUST_HAVE_MODULES_LIST, 86400))
|
||||
@file_put_contents(_PS_ROOT_DIR_.Module::CACHE_FILE_MUST_HAVE_MODULES_LIST, Tools::addonsRequest('must-have'));
|
||||
if (!$this->isFresh(Module::CACHE_FILE_TAB_MODULES_LIST, 604800))
|
||||
$this->refresh(Module::CACHE_FILE_TAB_MODULES_LIST, 'http://'.Tab::TAB_MODULE_LIST_URL);
|
||||
|
||||
@@ -1691,6 +1734,7 @@ class AdminControllerCore extends Controller
|
||||
$helper->row_hover = $this->row_hover;
|
||||
$helper->position_identifier = $this->position_identifier;
|
||||
$helper->controller_name = $this->controller_name;
|
||||
$helper->list_id = isset($this->list_id) ? $this->list_id : $this->table;
|
||||
|
||||
// For each action, try to add the corresponding skip elements list
|
||||
$helper->list_skip_actions = $this->list_skip_actions;
|
||||
@@ -1898,11 +1942,14 @@ class AdminControllerCore extends Controller
|
||||
*/
|
||||
public function initProcess()
|
||||
{
|
||||
if (!isset($this->list_id))
|
||||
$this->list_id = $this->table;
|
||||
|
||||
// Manage list filtering
|
||||
if (Tools::isSubmit('submitFilter'.$this->table)
|
||||
|| $this->context->cookie->{'submitFilter'.$this->table} !== false
|
||||
|| Tools::getValue($this->table.'Orderby')
|
||||
|| Tools::getValue($this->table.'Orderway'))
|
||||
if (Tools::isSubmit('submitFilter'.$this->list_id)
|
||||
|| $this->context->cookie->{'submitFilter'.$this->list_id} !== false
|
||||
|| Tools::getValue($this->list_id.'Orderby')
|
||||
|| Tools::getValue($this->list_id.'Orderway'))
|
||||
$this->filter = true;
|
||||
|
||||
$this->id_object = (int)Tools::getValue($this->identifier);
|
||||
@@ -2004,7 +2051,7 @@ class AdminControllerCore extends Controller
|
||||
$this->action = 'export';
|
||||
}
|
||||
/* Cancel all filters for this tab */
|
||||
elseif (isset($_POST['submitReset'.$this->table]))
|
||||
elseif (isset($_POST['submitReset'.$this->list_id]))
|
||||
$this->action = 'reset_filters';
|
||||
/* Submit options list */
|
||||
elseif (Tools::getValue('submitOptions'.$this->table) || Tools::getValue('submitOptions'))
|
||||
@@ -2058,14 +2105,17 @@ class AdminControllerCore extends Controller
|
||||
*/
|
||||
public function getList($id_lang, $order_by = null, $order_way = null, $start = 0, $limit = null, $id_lang_shop = false)
|
||||
{
|
||||
if (!isset($this->list_id))
|
||||
$this->list_id = $this->table;
|
||||
|
||||
/* Manage default params values */
|
||||
$use_limit = true;
|
||||
if ($limit === false)
|
||||
$use_limit = false;
|
||||
elseif (empty($limit))
|
||||
{
|
||||
if (isset($this->context->cookie->{$this->table.'_pagination'}) && $this->context->cookie->{$this->table.'_pagination'})
|
||||
$limit = $this->context->cookie->{$this->table.'_pagination'};
|
||||
if (isset($this->context->cookie->{$this->list_id.'_pagination'}) && $this->context->cookie->{$this->list_id.'_pagination'})
|
||||
$limit = $this->context->cookie->{$this->list_id.'_pagination'};
|
||||
else
|
||||
$limit = $this->_pagination[1];
|
||||
}
|
||||
@@ -2075,8 +2125,8 @@ class AdminControllerCore extends Controller
|
||||
$prefix = str_replace(array('admin', 'controller'), '', Tools::strtolower(get_class($this)));
|
||||
if (empty($order_by))
|
||||
{
|
||||
if ($this->context->cookie->{$prefix.$this->table.'Orderby'})
|
||||
$order_by = $this->context->cookie->{$prefix.$this->table.'Orderby'};
|
||||
if ($this->context->cookie->{$prefix.$this->list_id.'Orderby'})
|
||||
$order_by = $this->context->cookie->{$prefix.$this->list_id.'Orderby'};
|
||||
elseif ($this->_orderBy)
|
||||
$order_by = $this->_orderBy;
|
||||
else
|
||||
@@ -2085,16 +2135,16 @@ class AdminControllerCore extends Controller
|
||||
|
||||
if (empty($order_way))
|
||||
{
|
||||
if ($this->context->cookie->{$prefix.$this->table.'Orderway'})
|
||||
$order_way = $this->context->cookie->{$prefix.$this->table.'Orderway'};
|
||||
if ($this->context->cookie->{$prefix.$this->list_id.'Orderway'})
|
||||
$order_way = $this->context->cookie->{$prefix.$this->list_id.'Orderway'};
|
||||
elseif ($this->_orderWay)
|
||||
$order_way = $this->_orderWay;
|
||||
else
|
||||
$order_way = $this->_defaultOrderWay;
|
||||
}
|
||||
|
||||
$limit = (int)Tools::getValue('pagination', $limit);
|
||||
$this->context->cookie->{$this->table.'_pagination'} = $limit;
|
||||
$limit = (int)Tools::getValue($this->list_id.'_pagination', $limit);
|
||||
$this->context->cookie->{$this->list_id.'_pagination'} = $limit;
|
||||
|
||||
/* Check params validity */
|
||||
if (!Validate::isOrderBy($order_by) || !Validate::isOrderWay($order_way)
|
||||
@@ -2106,24 +2156,23 @@ class AdminControllerCore extends Controller
|
||||
$order_by = $this->fields_list[$order_by]['filter_key'];
|
||||
|
||||
/* Determine offset from current page */
|
||||
if ((isset($_POST['submitFilter'.$this->table]) ||
|
||||
isset($_POST['submitFilter'.$this->table.'_x']) ||
|
||||
isset($_POST['submitFilter'.$this->table.'_y'])) &&
|
||||
!empty($_POST['submitFilter'.$this->table]) &&
|
||||
is_numeric($_POST['submitFilter'.$this->table]))
|
||||
$start = ((int)$_POST['submitFilter'.$this->table] - 1) * $limit;
|
||||
if ((isset($_POST['submitFilter'.$this->list_id]) ||
|
||||
isset($_POST['submitFilter'.$this->list_id.'_x']) ||
|
||||
isset($_POST['submitFilter'.$this->list_id.'_y'])) &&
|
||||
!empty($_POST['submitFilter'.$this->list_id]) &&
|
||||
is_numeric($_POST['submitFilter'.$this->list_id]))
|
||||
$start = ((int)$_POST['submitFilter'.$this->list_id] - 1) * $limit;
|
||||
|
||||
/* Cache */
|
||||
$this->_lang = (int)$id_lang;
|
||||
$this->_orderBy = $order_by;
|
||||
|
||||
if (preg_match('/[.!]/', $order_by))
|
||||
{
|
||||
$order_by_split = preg_split('/[.!]/', $order_by);
|
||||
$order_by = pSQL($order_by_split[0]).'.`'.pSQL($order_by_split[1]).'`';
|
||||
$this->_orderBy = (isset($order_by_split) && isset($order_by_split[1])) ? $order_by_split[1] : $order_by;
|
||||
}
|
||||
else
|
||||
$this->_orderBy = $order_by;
|
||||
|
||||
$this->_orderWay = Tools::strtoupper($order_way);
|
||||
|
||||
/* SQL table : orders, but class name is Order */
|
||||
@@ -2222,6 +2271,7 @@ class AdminControllerCore extends Controller
|
||||
($this->_tmpTableFilter ? ') tmpTable WHERE 1'.$this->_tmpTableFilter : '').
|
||||
(($use_limit === true) ? ' LIMIT '.(int)$start.','.(int)$limit : '');
|
||||
|
||||
$this->_listTotal = 0;
|
||||
if (!($this->_list = Db::getInstance()->executeS($this->_listsql)))
|
||||
$this->_list_error = Db::getInstance()->getMsgError();
|
||||
else
|
||||
@@ -2384,7 +2434,7 @@ class AdminControllerCore extends Controller
|
||||
foreach ($rules['required'] as $field)
|
||||
if (($value = Tools::getValue($field)) == false && (string)$value != '0')
|
||||
if (!Tools::getValue($this->identifier) || ($field != 'passwd' && $field != 'no-picture'))
|
||||
$this->errors[] = sprintf(
|
||||
$this->errors[$field] = sprintf(
|
||||
Tools::displayError('The %s field is required.'),
|
||||
call_user_func(array($class_name, 'displayFieldName'), $field, $class_name)
|
||||
);
|
||||
@@ -2393,7 +2443,7 @@ class AdminControllerCore extends Controller
|
||||
if (isset($rules['requiredLang']) && is_array($rules['requiredLang']))
|
||||
foreach ($rules['requiredLang'] as $field_lang)
|
||||
if (($empty = Tools::getValue($field_lang.'_'.$default_language->id)) === false || $empty !== '0' && empty($empty))
|
||||
$this->errors[] = sprintf(
|
||||
$this->errors[$field_lang.'_'.$default_language->id] = sprintf(
|
||||
Tools::displayError('The field %1$s is required at least in %2$s.'),
|
||||
call_user_func(array($class_name, 'displayFieldName'), $field_lang, $class_name),
|
||||
$default_language->name
|
||||
@@ -2403,7 +2453,7 @@ class AdminControllerCore extends Controller
|
||||
if (isset($rules['size']) && is_array($rules['size']))
|
||||
foreach ($rules['size'] as $field => $max_length)
|
||||
if (Tools::getValue($field) !== false && Tools::strlen(Tools::getValue($field)) > $max_length)
|
||||
$this->errors[] = sprintf(
|
||||
$this->errors[$field] = sprintf(
|
||||
Tools::displayError('The %1$s field is too long (%2$d chars max).'),
|
||||
call_user_func(array($class_name, 'displayFieldName'), $field, $class_name),
|
||||
$max_length
|
||||
@@ -2416,7 +2466,7 @@ class AdminControllerCore extends Controller
|
||||
{
|
||||
$field_lang_value = Tools::getValue($field_lang.'_'.$language['id_lang']);
|
||||
if ($field_lang_value !== false && Tools::strlen($field_lang_value) > $max_length)
|
||||
$this->errors[] = sprintf(
|
||||
$this->errors[$field_lang.'_'.$language['id_lang']] = sprintf(
|
||||
Tools::displayError('The field %1$s (%2$s) is too long (%3$d chars max, html chars including).'),
|
||||
call_user_func(array($class_name, 'displayFieldName'), $field_lang, $class_name),
|
||||
$language['name'],
|
||||
@@ -2431,7 +2481,7 @@ class AdminControllerCore extends Controller
|
||||
foreach ($rules['validate'] as $field => $function)
|
||||
if (($value = Tools::getValue($field)) !== false && ($field != 'passwd'))
|
||||
if (!Validate::$function($value) && !empty($value))
|
||||
$this->errors[] = sprintf(
|
||||
$this->errors[$field] = sprintf(
|
||||
Tools::displayError('The %s field is invalid.'),
|
||||
call_user_func(array($class_name, 'displayFieldName'), $field, $class_name)
|
||||
);
|
||||
@@ -2440,12 +2490,12 @@ class AdminControllerCore extends Controller
|
||||
if (($value = Tools::getValue('passwd')) != false)
|
||||
{
|
||||
if ($class_name == 'Employee' && !Validate::isPasswdAdmin($value))
|
||||
$this->errors[] = sprintf(
|
||||
$this->errors['passwd'] = sprintf(
|
||||
Tools::displayError('The %s field is invalid.'),
|
||||
call_user_func(array($class_name, 'displayFieldName'), 'passwd', $class_name)
|
||||
);
|
||||
elseif ($class_name == 'Customer' && !Validate::isPasswd($value))
|
||||
$this->errors[] = sprintf(
|
||||
$this->errors['passwd'] = sprintf(
|
||||
Tools::displayError('The %s field is invalid.'),
|
||||
call_user_func(array($class_name, 'displayFieldName'), 'passwd', $class_name)
|
||||
);
|
||||
@@ -2457,7 +2507,7 @@ class AdminControllerCore extends Controller
|
||||
foreach ($languages as $language)
|
||||
if (($value = Tools::getValue($field_lang.'_'.$language['id_lang'])) !== false && !empty($value))
|
||||
if (!Validate::$function($value))
|
||||
$this->errors[] = sprintf(
|
||||
$this->errors[$field_lang.'_'.$language['id_lang']] = sprintf(
|
||||
Tools::displayError('The %1$s field (%2$s) is invalid.'),
|
||||
call_user_func(array($class_name, 'displayFieldName'), $field_lang, $class_name),
|
||||
$language['name']
|
||||
|
||||
Reference in New Issue
Block a user