// Advanced stock management details list
This commit is contained in:
1 parent
43c874e06e
commit
a891c9277a
4 files changed
+137
-130
No files matched your search
@@ -23,6 +23,6 @@
|
|||||||
* International Registered Trademark & Property of PrestaShop SA
|
* International Registered Trademark & Property of PrestaShop SA
|
||||||
*}
|
*}
|
||||||
|
|
||||||
<a href="#" id="details_{$params.action}_{$id}" title="{$action}" onclick="display_action_details('{$id}', '{$controller}', '{$token}', '{$params.action}', {$json_params|escape}); return false" class="">
|
<a href="{$href}" id="details_{$params.action}_{$id}" title="{$action}" class="">
|
||||||
<i class="icon-collapse"></i> {$action}
|
<i class="icon-tasks"></i> {$action}
|
||||||
</a>
|
</a>
|
||||||
@@ -1528,7 +1528,7 @@ class AdminControllerCore extends Controller
|
|||||||
$this->errors[] = Tools::displayError('You do not have permission to view this.');
|
$this->errors[] = Tools::displayError('You do not have permission to view this.');
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
$this->getLanguages();
|
$this->getLanguages();
|
||||||
// toolbar (save, cancel, new, ..)
|
// toolbar (save, cancel, new, ..)
|
||||||
$this->initToolbar();
|
$this->initToolbar();
|
||||||
@@ -1547,6 +1547,10 @@ class AdminControllerCore extends Controller
|
|||||||
$this->loadObject(true);
|
$this->loadObject(true);
|
||||||
$this->content .= $this->renderView();
|
$this->content .= $this->renderView();
|
||||||
}
|
}
|
||||||
|
elseif ($this->display == 'details')
|
||||||
|
{
|
||||||
|
$this->content .= $this->renderDetails();
|
||||||
|
}
|
||||||
elseif (!$this->ajax)
|
elseif (!$this->ajax)
|
||||||
{
|
{
|
||||||
$this->content .= $this->renderModulesList();
|
$this->content .= $this->renderModulesList();
|
||||||
@@ -1722,6 +1726,14 @@ class AdminControllerCore extends Controller
|
|||||||
return $view;
|
return $view;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Override to render the view page
|
||||||
|
*/
|
||||||
|
public function renderDetails()
|
||||||
|
{
|
||||||
|
return $this->renderList();
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Function used to render the form for this controller
|
* Function used to render the form for this controller
|
||||||
*/
|
*/
|
||||||
@@ -2147,6 +2159,16 @@ class AdminControllerCore extends Controller
|
|||||||
else
|
else
|
||||||
$this->errors[] = Tools::displayError('You do not have permission to view this.');
|
$this->errors[] = Tools::displayError('You do not have permission to view this.');
|
||||||
}
|
}
|
||||||
|
elseif (isset($_GET['details'.$this->table]))
|
||||||
|
{
|
||||||
|
if ($this->tabAccess['view'] === '1')
|
||||||
|
{
|
||||||
|
$this->display = 'details';
|
||||||
|
$this->action = 'details';
|
||||||
|
}
|
||||||
|
else
|
||||||
|
$this->errors[] = Tools::displayError('You do not have permission to view this.');
|
||||||
|
}
|
||||||
elseif (isset($_GET['export'.$this->table]))
|
elseif (isset($_GET['export'.$this->table]))
|
||||||
{
|
{
|
||||||
if ($this->tabAccess['view'] === '1')
|
if ($this->tabAccess['view'] === '1')
|
||||||
|
|||||||
@@ -388,6 +388,7 @@ class HelperListCore extends Helper
|
|||||||
|
|
||||||
$tpl->assign(array(
|
$tpl->assign(array(
|
||||||
'id' => Tools::safeOutput($id),
|
'id' => Tools::safeOutput($id),
|
||||||
|
'href' => Tools::safeOutput($this->currentIndex.'&'.$this->identifier.'='.$id.'&details'.$this->table.'&token='.($token != null ? $token : $this->token)),
|
||||||
'controller' => str_replace('Controller', '', get_class($this->context->controller)),
|
'controller' => str_replace('Controller', '', get_class($this->context->controller)),
|
||||||
'token' => Tools::safeOutput($token != null ? $token : $this->token),
|
'token' => Tools::safeOutput($token != null ? $token : $this->token),
|
||||||
'action' => self::$cache_lang['Details'],
|
'action' => self::$cache_lang['Details'],
|
||||||
|
|||||||
@@ -34,6 +34,7 @@ class AdminStockManagementControllerCore extends AdminController
|
|||||||
$this->bootstrap = true;
|
$this->bootstrap = true;
|
||||||
$this->context = Context::getContext();
|
$this->context = Context::getContext();
|
||||||
$this->table = 'product';
|
$this->table = 'product';
|
||||||
|
$this->list_id = 'product';
|
||||||
$this->className = 'Product';
|
$this->className = 'Product';
|
||||||
$this->lang = true;
|
$this->lang = true;
|
||||||
$this->multishop_context = Shop::CONTEXT_ALL;
|
$this->multishop_context = Shop::CONTEXT_ALL;
|
||||||
@@ -41,17 +42,14 @@ class AdminStockManagementControllerCore extends AdminController
|
|||||||
$this->fields_list = array(
|
$this->fields_list = array(
|
||||||
'reference' => array(
|
'reference' => array(
|
||||||
'title' => $this->l('Product reference'),
|
'title' => $this->l('Product reference'),
|
||||||
'align' => 'center',
|
|
||||||
'filter_key' => 'a!reference'
|
'filter_key' => 'a!reference'
|
||||||
),
|
),
|
||||||
'ean13' => array(
|
'ean13' => array(
|
||||||
'title' => $this->l('EAN13'),
|
'title' => $this->l('EAN13'),
|
||||||
'align' => 'center',
|
|
||||||
'filter_key' => 'a!ean13'
|
'filter_key' => 'a!ean13'
|
||||||
),
|
),
|
||||||
'upc' => array(
|
'upc' => array(
|
||||||
'title' => $this->l('UPC'),
|
'title' => $this->l('UPC'),
|
||||||
'align' => 'center',
|
|
||||||
'filter_key' => 'a!upc'
|
'filter_key' => 'a!upc'
|
||||||
),
|
),
|
||||||
'name' => array(
|
'name' => array(
|
||||||
@@ -80,7 +78,15 @@ class AdminStockManagementControllerCore extends AdminController
|
|||||||
|
|
||||||
public function initPageHeaderToolbar()
|
public function initPageHeaderToolbar()
|
||||||
{
|
{
|
||||||
$this->page_header_toolbar_title = $this->l('Stock management');
|
$this->page_header_toolbar_title = $this->l('Stock management');
|
||||||
|
|
||||||
|
if ($this->display == 'details')
|
||||||
|
$this->page_header_toolbar_btn['back_to_list'] = array(
|
||||||
|
'href' => Context::getContext()->link->getAdminLink('AdminStockManagement'),
|
||||||
|
'desc' => $this->l('Back to list'),
|
||||||
|
'icon' => 'process-icon-back'
|
||||||
|
);
|
||||||
|
|
||||||
parent::initPageHeaderToolbar();
|
parent::initPageHeaderToolbar();
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -94,7 +100,9 @@ class AdminStockManagementControllerCore extends AdminController
|
|||||||
$this->addRowAction('details');
|
$this->addRowAction('details');
|
||||||
$this->addRowAction('addstock');
|
$this->addRowAction('addstock');
|
||||||
$this->addRowAction('removestock');
|
$this->addRowAction('removestock');
|
||||||
$this->addRowAction('transferstock');
|
|
||||||
|
if (count(Warehouse::getWarehouses()) > 1)
|
||||||
|
$this->addRowAction('transferstock');
|
||||||
|
|
||||||
// no link on list rows
|
// no link on list rows
|
||||||
$this->list_no_link = true;
|
$this->list_no_link = true;
|
||||||
@@ -793,109 +801,76 @@ class AdminStockManagementControllerCore extends AdminController
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public function renderView()
|
public function renderDetails()
|
||||||
{
|
{
|
||||||
if (Tools::isSubmit('id'))
|
if (Tools::isSubmit('id_product'))
|
||||||
{
|
{
|
||||||
// override attributes
|
// override attributes
|
||||||
$this->identifier = 'id_product_attribute';
|
$this->identifier = 'id_product_attribute';
|
||||||
$this->display = 'list';
|
$this->list_id = 'product_attribute';
|
||||||
$this->lang = false;
|
$this->lang = false;
|
||||||
|
|
||||||
$this->addRowAction('addstock');
|
$this->addRowAction('addstock');
|
||||||
$this->addRowAction('removestock');
|
$this->addRowAction('removestock');
|
||||||
$this->addRowAction('transferstock');
|
|
||||||
|
if (count(Warehouse::getWarehouses()) > 1)
|
||||||
|
$this->addRowAction('transferstock');
|
||||||
|
|
||||||
|
// no link on list rows
|
||||||
|
$this->list_no_link = true;
|
||||||
|
|
||||||
|
// inits toolbar
|
||||||
|
$this->toolbar_btn = array();
|
||||||
|
|
||||||
// get current lang id
|
// get current lang id
|
||||||
$lang_id = (int)$this->context->language->id;
|
$lang_id = (int)$this->context->language->id;
|
||||||
|
|
||||||
// Get product id
|
// Get product id
|
||||||
$product_id = (int)Tools::getValue('id');
|
$product_id = (int)Tools::getValue('id_product');
|
||||||
|
|
||||||
// Load product attributes with sql override
|
// Load product attributes with sql override
|
||||||
$this->table = 'product_attribute';
|
$this->table = 'product_attribute';
|
||||||
|
$this->list_id = 'product_attribute';
|
||||||
$this->_select = 'a.id_product_attribute as id, a.id_product, a.reference, a.ean13, a.upc';
|
$this->_select = 'a.id_product_attribute as id, a.id_product, a.reference, a.ean13, a.upc';
|
||||||
|
|
||||||
$this->_where = 'AND a.id_product = '.$product_id;
|
$this->_where = 'AND a.id_product = '.$product_id;
|
||||||
$this->_group = 'GROUP BY a.id_product_attribute';
|
$this->_group = 'GROUP BY a.id_product_attribute';
|
||||||
|
|
||||||
// get list and force no limit clause in the request
|
$this->fields_list = array(
|
||||||
$this->getList($this->context->language->id, null, null, 0, false);
|
'reference' => array(
|
||||||
|
'title' => $this->l('Product reference'),
|
||||||
|
'filter_key' => 'a!reference'
|
||||||
|
),
|
||||||
|
'ean13' => array(
|
||||||
|
'title' => $this->l('EAN13'),
|
||||||
|
'filter_key' => 'a!ean13'
|
||||||
|
),
|
||||||
|
'upc' => array(
|
||||||
|
'title' => $this->l('UPC'),
|
||||||
|
'filter_key' => 'a!upc'
|
||||||
|
),
|
||||||
|
'name' => array(
|
||||||
|
'title' => $this->l('Name'),
|
||||||
|
'orderby' => false,
|
||||||
|
'filter' => false,
|
||||||
|
'search' => false
|
||||||
|
),
|
||||||
|
'stock' => array(
|
||||||
|
'title' => $this->l('Quantity'),
|
||||||
|
'orderby' => false,
|
||||||
|
'filter' => false,
|
||||||
|
'search' => false,
|
||||||
|
'class' => 'fixed-width-sm',
|
||||||
|
'align' => 'center',
|
||||||
|
'hint' => $this->l('Quantitity total for all warehouses.')
|
||||||
|
),
|
||||||
|
);
|
||||||
|
|
||||||
// Render list
|
self::$currentIndex = self::$currentIndex.'&id_product='.(int)$product_id.'&detailsproduct';
|
||||||
$helper = new HelperList();
|
$this->processFilter();
|
||||||
$helper->bulk_actions = array();
|
return parent::renderList();
|
||||||
$helper->toolbar_scroll = $this->toolbar_scroll;
|
|
||||||
$helper->show_toolbar = false;
|
|
||||||
$helper->actions = $this->actions;
|
|
||||||
$helper->list_skip_actions = $this->list_skip_actions;
|
|
||||||
$helper->no_link = true;
|
|
||||||
$helper->shopLinkType = '';
|
|
||||||
$helper->identifier = $this->identifier;
|
|
||||||
// Force render - no filter, form, js, sorting ...
|
|
||||||
$helper->simple_header = true;
|
|
||||||
$content = $helper->generateList($this->_list, $this->fields_list);
|
|
||||||
|
|
||||||
return parent::renderView();
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
|
||||||
* method call when ajax request is made with the details row action
|
|
||||||
* @see AdminController::postProcess()
|
|
||||||
*/
|
|
||||||
public function ajaxProcess()
|
|
||||||
{
|
|
||||||
// test if an id is submit
|
|
||||||
if (Tools::isSubmit('id'))
|
|
||||||
{
|
|
||||||
// override attributes
|
|
||||||
$this->identifier = 'id_product_attribute';
|
|
||||||
$this->display = 'list';
|
|
||||||
$this->lang = false;
|
|
||||||
|
|
||||||
$this->addRowAction('addstock');
|
|
||||||
$this->addRowAction('removestock');
|
|
||||||
$this->addRowAction('transferstock');
|
|
||||||
|
|
||||||
// get current lang id
|
|
||||||
$lang_id = (int)$this->context->language->id;
|
|
||||||
|
|
||||||
// Get product id
|
|
||||||
$product_id = (int)Tools::getValue('id');
|
|
||||||
|
|
||||||
// Load product attributes with sql override
|
|
||||||
$this->table = 'product_attribute';
|
|
||||||
|
|
||||||
$this->_select = 'a.id_product_attribute as id, a.id_product, a.reference, a.ean13, a.upc';
|
|
||||||
|
|
||||||
$this->_where = 'AND a.id_product = '.$product_id;
|
|
||||||
$this->_group = 'GROUP BY a.id_product_attribute';
|
|
||||||
|
|
||||||
// get list and force no limit clause in the request
|
|
||||||
$this->getList($this->context->language->id, null, null, 0, false);
|
|
||||||
|
|
||||||
// Render list
|
|
||||||
$helper = new HelperList();
|
|
||||||
$helper->bulk_actions = array();
|
|
||||||
$helper->toolbar_scroll = $this->toolbar_scroll;
|
|
||||||
$helper->show_toolbar = false;
|
|
||||||
$helper->actions = $this->actions;
|
|
||||||
$helper->list_skip_actions = $this->list_skip_actions;
|
|
||||||
$helper->no_link = true;
|
|
||||||
$helper->shopLinkType = '';
|
|
||||||
$helper->identifier = $this->identifier;
|
|
||||||
// Force render - no filter, form, js, sorting ...
|
|
||||||
$helper->simple_header = true;
|
|
||||||
$content = $helper->generateList($this->_list, $this->fields_list);
|
|
||||||
|
|
||||||
echo Tools::jsonEncode(array('use_parent_structure' => false, 'data' => $content));
|
|
||||||
}
|
|
||||||
|
|
||||||
die;
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* AdminController::getList() override
|
* AdminController::getList() override
|
||||||
* @see AdminController::getList()
|
* @see AdminController::getList()
|
||||||
@@ -904,54 +879,52 @@ class AdminStockManagementControllerCore extends AdminController
|
|||||||
{
|
{
|
||||||
parent::getList($id_lang, $order_by, $order_way, $start, $limit, $id_lang_shop);
|
parent::getList($id_lang, $order_by, $order_way, $start, $limit, $id_lang_shop);
|
||||||
|
|
||||||
if ($this->display == 'list')
|
// Check each row to see if there are combinations and get the correct action in consequence
|
||||||
|
$nb_items = count($this->_list);
|
||||||
|
|
||||||
|
for ($i = 0; $i < $nb_items; $i++)
|
||||||
{
|
{
|
||||||
// Check each row to see if there are combinations and get the correct action in consequence
|
$item = &$this->_list[$i];
|
||||||
$nb_items = count($this->_list);
|
|
||||||
|
|
||||||
for ($i = 0; $i < $nb_items; $i++)
|
// if it's an ajax request we have to consider manipulating a product variation
|
||||||
|
if (Tools::isSubmit('id_product'))
|
||||||
{
|
{
|
||||||
$item = &$this->_list[$i];
|
$item['name'] = Product::getProductName($item['id_product'], $item['id']);
|
||||||
|
// no details for this row
|
||||||
|
$this->addRowActionSkipList('details', array($item['id']));
|
||||||
|
|
||||||
// if it's an ajax request we have to consider manipulating a product variation
|
// specify actions in function of stock
|
||||||
if ($this->ajax == '1')
|
$this->skipActionByStock($item, true);
|
||||||
{
|
|
||||||
$item['name'] = Product::getProductName($item['id_product'], $item['id']);
|
|
||||||
// no details for this row
|
|
||||||
$this->addRowActionSkipList('details', array($item['id']));
|
|
||||||
|
|
||||||
// specify actions in function of stock
|
|
||||||
$this->skipActionByStock($item, true);
|
|
||||||
}
|
|
||||||
// If current product has variations
|
|
||||||
else if ((int)$item['variations'] > 0)
|
|
||||||
{
|
|
||||||
// we have to desactivate stock actions on current row
|
|
||||||
$this->addRowActionSkipList('addstock', array($item['id']));
|
|
||||||
$this->addRowActionSkipList('removestock', array($item['id']));
|
|
||||||
$this->addRowActionSkipList('transferstock', array($item['id']));
|
|
||||||
|
|
||||||
// does not display these informaions because this product has combinations
|
|
||||||
$item['reference'] = '--';
|
|
||||||
$item['ean13'] = '--';
|
|
||||||
$item['upc'] = '--';
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
//there are no variations of current product, so we don't want to show details action
|
|
||||||
$this->addRowActionSkipList('details', array($item['id']));
|
|
||||||
|
|
||||||
// specify actions in function of stock
|
|
||||||
$this->skipActionByStock($item, false);
|
|
||||||
}
|
|
||||||
// Checks access
|
|
||||||
if (!($this->tabAccess['add'] === '1'))
|
|
||||||
$this->addRowActionSkipList('addstock', array($item['id']));
|
|
||||||
if (!($this->tabAccess['delete'] === '1'))
|
|
||||||
$this->addRowActionSkipList('removestock', array($item['id']));
|
|
||||||
if (!($this->tabAccess['edit'] === '1'))
|
|
||||||
$this->addRowActionSkipList('transferstock', array($item['id']));
|
|
||||||
}
|
}
|
||||||
|
// If current product has variations
|
||||||
|
else if (array_key_exists('variations', $item) && (int)$item['variations'] > 0)
|
||||||
|
{
|
||||||
|
// we have to desactivate stock actions on current row
|
||||||
|
$this->addRowActionSkipList('addstock', array($item['id']));
|
||||||
|
$this->addRowActionSkipList('removestock', array($item['id']));
|
||||||
|
$this->addRowActionSkipList('transferstock', array($item['id']));
|
||||||
|
|
||||||
|
// does not display these informaions because this product has combinations
|
||||||
|
$item['reference'] = '--';
|
||||||
|
$item['ean13'] = '--';
|
||||||
|
$item['upc'] = '--';
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
//there are no variations of current product, so we don't want to show details action
|
||||||
|
$this->addRowActionSkipList('details', array($item['id']));
|
||||||
|
|
||||||
|
// specify actions in function of stock
|
||||||
|
$this->skipActionByStock($item, false);
|
||||||
|
}
|
||||||
|
// Checks access
|
||||||
|
if (!($this->tabAccess['add'] === '1'))
|
||||||
|
$this->addRowActionSkipList('addstock', array($item['id']));
|
||||||
|
if (!($this->tabAccess['delete'] === '1'))
|
||||||
|
$this->addRowActionSkipList('removestock', array($item['id']));
|
||||||
|
if (!($this->tabAccess['edit'] === '1'))
|
||||||
|
$this->addRowActionSkipList('transferstock', array($item['id']));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -1115,7 +1088,7 @@ class AdminStockManagementControllerCore extends AdminController
|
|||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
$this->display = 'list';
|
//$this->display = 'list';
|
||||||
parent::initContent();
|
parent::initContent();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -1190,6 +1163,17 @@ class AdminStockManagementControllerCore extends AdminController
|
|||||||
$this->warnings[md5('PS_ADVANCED_STOCK_MANAGEMENT')] = $this->l('You need to activate advanced stock management prior to using this feature.');
|
$this->warnings[md5('PS_ADVANCED_STOCK_MANAGEMENT')] = $this->l('You need to activate advanced stock management prior to using this feature.');
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (Tools::getIsset('detailsproduct'))
|
||||||
|
{
|
||||||
|
$this->list_id = 'product_attribute';
|
||||||
|
|
||||||
|
if (isset($_POST['submitReset'.$this->list_id]))
|
||||||
|
$this->processResetFilters();
|
||||||
|
}
|
||||||
|
else
|
||||||
|
$this->list_id = 'product';
|
||||||
|
|
||||||
parent::initProcess();
|
parent::initProcess();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
Reference in new issue
Block a user