|
|
|
@@ -34,6 +34,7 @@ class AdminStockManagementControllerCore extends AdminController
|
|
|
|
|
$this->bootstrap = true;
|
|
|
|
|
$this->context = Context::getContext();
|
|
|
|
|
$this->table = 'product';
|
|
|
|
|
$this->list_id = 'product';
|
|
|
|
|
$this->className = 'Product';
|
|
|
|
|
$this->lang = true;
|
|
|
|
|
$this->multishop_context = Shop::CONTEXT_ALL;
|
|
|
|
@@ -41,17 +42,14 @@ class AdminStockManagementControllerCore extends AdminController
|
|
|
|
|
$this->fields_list = array(
|
|
|
|
|
'reference' => array(
|
|
|
|
|
'title' => $this->l('Product reference'),
|
|
|
|
|
'align' => 'center',
|
|
|
|
|
'filter_key' => 'a!reference'
|
|
|
|
|
),
|
|
|
|
|
'ean13' => array(
|
|
|
|
|
'title' => $this->l('EAN13'),
|
|
|
|
|
'align' => 'center',
|
|
|
|
|
'filter_key' => 'a!ean13'
|
|
|
|
|
),
|
|
|
|
|
'upc' => array(
|
|
|
|
|
'title' => $this->l('UPC'),
|
|
|
|
|
'align' => 'center',
|
|
|
|
|
'filter_key' => 'a!upc'
|
|
|
|
|
),
|
|
|
|
|
'name' => array(
|
|
|
|
@@ -80,7 +78,15 @@ class AdminStockManagementControllerCore extends AdminController
|
|
|
|
|
|
|
|
|
|
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();
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
@@ -94,7 +100,9 @@ class AdminStockManagementControllerCore extends AdminController
|
|
|
|
|
$this->addRowAction('details');
|
|
|
|
|
$this->addRowAction('addstock');
|
|
|
|
|
$this->addRowAction('removestock');
|
|
|
|
|
$this->addRowAction('transferstock');
|
|
|
|
|
|
|
|
|
|
if (count(Warehouse::getWarehouses()) > 1)
|
|
|
|
|
$this->addRowAction('transferstock');
|
|
|
|
|
|
|
|
|
|
// no link on list rows
|
|
|
|
|
$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
|
|
|
|
|
$this->identifier = 'id_product_attribute';
|
|
|
|
|
$this->display = 'list';
|
|
|
|
|
$this->list_id = 'product_attribute';
|
|
|
|
|
$this->lang = false;
|
|
|
|
|
|
|
|
|
|
$this->addRowAction('addstock');
|
|
|
|
|
$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
|
|
|
|
|
$lang_id = (int)$this->context->language->id;
|
|
|
|
|
|
|
|
|
|
// Get product id
|
|
|
|
|
$product_id = (int)Tools::getValue('id');
|
|
|
|
|
$product_id = (int)Tools::getValue('id_product');
|
|
|
|
|
|
|
|
|
|
// Load product attributes with sql override
|
|
|
|
|
$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->_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);
|
|
|
|
|
$this->fields_list = array(
|
|
|
|
|
'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
|
|
|
|
|
$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);
|
|
|
|
|
|
|
|
|
|
return parent::renderView();
|
|
|
|
|
self::$currentIndex = self::$currentIndex.'&id_product='.(int)$product_id.'&detailsproduct';
|
|
|
|
|
$this->processFilter();
|
|
|
|
|
return parent::renderList();
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* 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
|
|
|
|
|
* @see AdminController::getList()
|
|
|
|
@@ -904,54 +879,52 @@ class AdminStockManagementControllerCore extends AdminController
|
|
|
|
|
{
|
|
|
|
|
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
|
|
|
|
|
$nb_items = count($this->_list);
|
|
|
|
|
$item = &$this->_list[$i];
|
|
|
|
|
|
|
|
|
|
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
|
|
|
|
|
if ($this->ajax == '1')
|
|
|
|
|
{
|
|
|
|
|
$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);
|
|
|
|
|
|
|
|
|
|
// 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
|
|
|
|
|
{
|
|
|
|
|
$this->display = 'list';
|
|
|
|
|
//$this->display = 'list';
|
|
|
|
|
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.');
|
|
|
|
|
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();
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|