// Stock : fixed bugs on cover/instant state/warehouse/management
git-svn-id: http://dev.prestashop.com/svn/v1/branches/1.5.x@10150 b9a71923-0436-4b27-9f14-aed3839534dd
This commit is contained in:
@@ -48,9 +48,9 @@ $id_lang = (int)Context::getContext()->language->id;
|
||||
$query = new DbQuery();
|
||||
$query->select('
|
||||
CONCAT(p.id_product, \'_\', IFNULL(pa.id_product_attribute, \'0\')) as id,
|
||||
p.reference,
|
||||
IFNULL(p.ean13, \'\') as ean13,
|
||||
IFNULL(p.upc, \'\') as upc,
|
||||
IFNULL(pa.reference, IFNULL(p.reference, \'\')) as reference,
|
||||
IFNULL(pa.ean13, IFNULL(p.ean13, \'\')) as ean13,
|
||||
IFNULL(pa.upc, IFNULL(p.upc, \'\')) as upc,
|
||||
md5(CONCAT(\''._COOKIE_KEY_.'\', p.id_product, \'_\', IFNULL(pa.id_product_attribute, \'0\'))) as checksum,
|
||||
IFNULL(CONCAT(pl.name, \' : \', GROUP_CONCAT(agl.name, \' - \', al.name SEPARATOR \', \')), pl.name) as name
|
||||
');
|
||||
|
||||
@@ -30,6 +30,7 @@
|
||||
<p> </p>
|
||||
|
||||
<input type="hidden" id="product_ids" name="product_ids" value="{$product_ids}" />
|
||||
<input type="hidden" id="product_ids_to_delete" name="product_ids_to_delete" value="{$product_ids_to_delete}" />
|
||||
<input type="hidden" name="updatesupply_order" value="1" />
|
||||
|
||||
<fieldset>
|
||||
@@ -122,6 +123,12 @@
|
||||
else
|
||||
product_ids = $('#product_ids').val().split('|');
|
||||
|
||||
if ($('#product_ids_to_delete').val() == '')
|
||||
product_ids_to_delete = [];
|
||||
else
|
||||
product_ids_to_delete = $('#product_ids_to_delete').val().split('|');
|
||||
|
||||
|
||||
function addProduct()
|
||||
{
|
||||
// check if it's possible to add the product
|
||||
@@ -134,9 +141,9 @@
|
||||
// add a new line in the products table
|
||||
$('#products_in_supply_order > tbody:last').append(
|
||||
'<tr style="height:50px;">'+
|
||||
'<td>'+product_infos.reference+'<input type="hidden" name="input_check_'+product_infos.id+'" value="'+product_infos.checksum+'" /><input type="hidden" name="input_name_'+product_infos.id+'" value="'+product_infos.reference+'" /></td>'+
|
||||
'<td>'+product_infos.reference+'<input type="hidden" name="input_check_'+product_infos.id+'" value="'+product_infos.checksum+'" /><input type="hidden" name="input_reference_'+product_infos.id+'" value="'+product_infos.reference+'" /></td>'+
|
||||
'<td>'+product_infos.ean13+'<input type="hidden" name="input_ean13_'+product_infos.id+'" value="'+product_infos.ean13+'" /></td>'+
|
||||
'<td>'+product_infos.upc+'<input type="hidden" name="input_ean13_'+product_infos.id+'" value="'+product_infos.upc+'" /></td>'+
|
||||
'<td>'+product_infos.upc+'<input type="hidden" name="input_upc_'+product_infos.id+'" value="'+product_infos.upc+'" /></td>'+
|
||||
'<td>'+product_infos.name+'<input type="hidden" name="input_name_displayed_'+product_infos.id+'" value="'+product_infos.name+'" /></td>'+
|
||||
'<td class="center">{$currency->prefix} <input type="text" name="input_unit_price_te_'+product_infos.id+'" value="0" size="8" /> {$currency->suffix}</td>'+
|
||||
'<td class="center"><input type="text" name="input_quantity_expected_'+product_infos.id+'" value="0" size="5" /></td>'+
|
||||
@@ -167,20 +174,22 @@
|
||||
|
||||
var id = $(this).attr('id');
|
||||
var product_id = id.split('|')[1];
|
||||
|
||||
|
||||
//find the position of the product id in product_id array
|
||||
var position = product_ids.indexOf(product_id);
|
||||
console.log(product_ids);
|
||||
console.log(product_id);
|
||||
console.log(position);
|
||||
if (position != -1)
|
||||
{
|
||||
console.log('test3');
|
||||
//remove the id from the array
|
||||
product_ids.splice(position, 1);
|
||||
|
||||
|
||||
var input_id = $('input[name~="input_id_'+product_id+'"]');
|
||||
if (input_id.length > 0)
|
||||
product_ids_to_delete.push(product_id);
|
||||
|
||||
// update the product_ids hidden field
|
||||
$('#product_ids').val(product_ids.join('|'));
|
||||
$('#product_ids_to_delete').val(product_ids_to_delete.join('|'));
|
||||
|
||||
//remove the table row
|
||||
$(this).parents('tr:eq(0)').remove();
|
||||
|
||||
@@ -27,7 +27,7 @@
|
||||
{extends file="helper/view/view.tpl"}
|
||||
{block name="override_tpl"}
|
||||
{if isset($warehouse)}
|
||||
<div style="margin-top: 20px">
|
||||
<div>
|
||||
<fieldset>
|
||||
<legend><img src="/img/t/AdminPreferences.gif" alt="" /> {l s='General informations'}</legend>
|
||||
<table style="width: 400px;" classe="table">
|
||||
|
||||
@@ -141,11 +141,15 @@ class StockCore extends ObjectModel
|
||||
$this->upc = $row['upc'];
|
||||
}
|
||||
}
|
||||
else {
|
||||
else
|
||||
{
|
||||
$product = new Product((int)$this->id_product);
|
||||
$this->reference = $product->reference;
|
||||
$this->ean13 = $product->ean13;
|
||||
$this->upc = $product->upc;
|
||||
if (Validate::isLoadedObject($product))
|
||||
{
|
||||
$this->reference = $product->reference;
|
||||
$this->ean13 = $product->ean13;
|
||||
$this->upc = $product->upc;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -51,7 +51,7 @@ class StockManagerCore implements StockManagerInterface
|
||||
$id_stock_mvt_reason,
|
||||
$price_te,
|
||||
$is_usable = true,
|
||||
$id_supplier_order = null)
|
||||
$id_supply_order = null)
|
||||
{
|
||||
if (!Validate::isLoadedObject($warehouse) || !$price_te || !$quantity || !$id_product)
|
||||
return false;
|
||||
@@ -67,7 +67,7 @@ class StockManagerCore implements StockManagerInterface
|
||||
'id_stock' => null,
|
||||
'physical_quantity' => $quantity,
|
||||
'id_stock_mvt_reason' => $id_stock_mvt_reason,
|
||||
'id_supplier_order' => $id_supplier_order,
|
||||
'id_supply_order' => $id_supply_order,
|
||||
'price_te' => $price_te,
|
||||
'last_wa' => null,
|
||||
'current_wa' => null,
|
||||
@@ -452,21 +452,21 @@ class StockManagerCore implements StockManagerInterface
|
||||
$query->where('o.valid = 1');
|
||||
$client_orders_qty = (int)Db::getInstance(_PS_USE_SQL_SLAVE_)->getValue($query);
|
||||
|
||||
// Gets supplier_orders_qty
|
||||
// Gets supply_orders_qty
|
||||
$query = new DbQuery();
|
||||
$query->select('SUM(sod.quantity_expected)');
|
||||
$query->from('supplier_order so');
|
||||
$query->leftjoin('supplier_order_detail sod ON (sod.id_supplier_order = so.id_supplier_order)');
|
||||
$query->leftjoin('supplier_order_state sos ON (sos.id_supplier_order_state = so.id_supplier_order_state)');
|
||||
$query->from('supply_order so');
|
||||
$query->leftjoin('supply_order_detail sod ON (sod.id_supply_order = so.id_supply_order)');
|
||||
$query->leftjoin('supply_order_state sos ON (sos.id_supply_order_state = so.id_supply_order_state)');
|
||||
$query->where('sos.pending_receipt = 1');
|
||||
$query->where('sod.id_product = '.(int)$id_product.' AND sod.id_product_attribute = '.(int)$id_product_attribute);
|
||||
$supplier_orders_qty = (int)Db::getInstance(_PS_USE_SQL_SLAVE_)->getValue($query);
|
||||
$supply_orders_qty = (int)Db::getInstance(_PS_USE_SQL_SLAVE_)->getValue($query);
|
||||
|
||||
// Gets {physical OR usable}_qty
|
||||
$qty = $this->getProductPhysicalQuantities($id_product, $id_product_attribute, $ids_warehouse, $usable);
|
||||
|
||||
// real qty = actual qty in stock - current client orders + current supplier orders
|
||||
return ($qty - $client_orders_qty + $supplier_orders_qty);
|
||||
// real qty = actual qty in stock - current client orders + current supply orders
|
||||
return ($qty - $client_orders_qty + $supply_orders_qty);
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
@@ -49,10 +49,10 @@ interface StockManagerInterface
|
||||
* @param int $id_stock_movement_reason
|
||||
* @param float $price_te
|
||||
* @param bool $is_usable
|
||||
* @param int $id_supplier_order optionnal
|
||||
* @param int $id_supply_order optionnal
|
||||
* @return bool
|
||||
*/
|
||||
public function addProduct($id_product, $id_product_attribute, Warehouse $warehouse, $quantity, $id_stock_movement_reason, $price_te, $is_usable = true, $id_supplier_order = null);
|
||||
public function addProduct($id_product, $id_product_attribute, Warehouse $warehouse, $quantity, $id_stock_movement_reason, $price_te, $is_usable = true, $id_supply_order = null);
|
||||
|
||||
/**
|
||||
* For a given product, removes a given quantity
|
||||
@@ -83,8 +83,8 @@ interface StockManagerInterface
|
||||
/**
|
||||
* For a given product, returns its real quantity
|
||||
* If the given product has combinations and $id_product_attribute is null, returns the sum for all combinations
|
||||
* Real quantity : (physical_qty + supplier_orders_qty - client_orders_qty)
|
||||
* If $usable is defined, real quantity: usable_qty + supplier_orders_qty - client_orders_qty
|
||||
* Real quantity : (physical_qty + supply_orders_qty - client_orders_qty)
|
||||
* If $usable is defined, real quantity: usable_qty + supply_orders_qty - client_orders_qty
|
||||
*
|
||||
* @param int $id_product
|
||||
* @param int $id_product_attribute
|
||||
|
||||
@@ -53,6 +53,12 @@ class AdminStockCoverControllerCore extends AdminController
|
||||
'width' => 100,
|
||||
'filter_key' => 'a!ean13'
|
||||
),
|
||||
'upc' => array(
|
||||
'title' => $this->l('UPC'),
|
||||
'align' => 'center',
|
||||
'width' => 100,
|
||||
'filter_key' => 'a!upc'
|
||||
),
|
||||
'name' => array(
|
||||
'title' => $this->l('Name'),
|
||||
'filter_key' => 'b!name'
|
||||
@@ -99,24 +105,32 @@ class AdminStockCoverControllerCore extends AdminController
|
||||
{
|
||||
$this->lang = false;
|
||||
$lang_id = (int)$this->context->language->id;
|
||||
$product_id = (int)Tools::getValue('id');
|
||||
$id_product = (int)Tools::getValue('id');
|
||||
$period = (Tools::getValue('period') ? (int)Tools::getValue('period') : 7);
|
||||
$warehouse = (Tools::getValue('id_warehouse') ? (int)Tools::getValue('id_warehouse') : -1);
|
||||
|
||||
$query = '
|
||||
SELECT a.id_product_attribute as id, a.id_product, a.reference, a.ean13,
|
||||
IFNULL(CONCAT(pl.name, \' : \', GROUP_CONCAT(agl.`name`, \' - \', al.name SEPARATOR \', \')),pl.name) as name,
|
||||
IFNULL(s.physical_quantity, 0) as stock
|
||||
FROM '._DB_PREFIX_.'product_attribute a
|
||||
INNER JOIN '._DB_PREFIX_.'product_lang pl ON (pl.id_product = a.id_product AND pl.id_lang = '.$lang_id.')
|
||||
LEFT JOIN '._DB_PREFIX_.'product_attribute_combination pac ON (pac.id_product_attribute = a.id_product_attribute)
|
||||
LEFT JOIN '._DB_PREFIX_.'attribute atr ON (atr.id_attribute = pac.id_attribute)
|
||||
LEFT JOIN '._DB_PREFIX_.'attribute_lang al ON (al.id_attribute = atr.id_attribute AND al.id_lang = '.$lang_id.')
|
||||
LEFT JOIN '._DB_PREFIX_.'attribute_group_lang agl ON (agl.id_attribute_group = atr.id_attribute_group AND agl.id_lang = '.$lang_id.')
|
||||
INNER JOIN '._DB_PREFIX_.'stock s ON (a.id_product_attribute = s.id_product_attribute)
|
||||
WHERE a.id_product = '.$product_id.
|
||||
($warehouse != -1 ? ' AND s.id_warehouse = '.(int)$warehouse : ' ').'
|
||||
GROUP BY a.id_product_attribute';
|
||||
$query = new DbQuery();
|
||||
$query->select('pa.id_product_attribute as id, pa.id_product, stock_view.reference, stock_view.ean13,
|
||||
stock_view.upc, stock_view.usable_quantity as stock,
|
||||
IFNULL(CONCAT(pl.name, \' : \', GROUP_CONCAT(agl.`name`, \' - \', al.name SEPARATOR \', \')),pl.name) as name');
|
||||
$query->from('product_attribute pa
|
||||
INNER JOIN
|
||||
(
|
||||
SELECT SUM(s.usable_quantity) as usable_quantity, s.id_product_attribute, s.reference, s.ean13, s.upc
|
||||
FROM '._DB_PREFIX_.'stock s
|
||||
WHERE s.id_product = '.($id_product).'
|
||||
GROUP BY s.id_product_attribute
|
||||
)
|
||||
stock_view ON (stock_view.id_product_attribute = pa.id_product_attribute)');
|
||||
$query->innerJoin('product_lang pl ON (pl.id_product = pa.id_product AND pl.id_lang = '.$lang_id.')');
|
||||
$query->leftJoin('product_attribute_combination pac ON (pac.id_product_attribute = pa.id_product_attribute)');
|
||||
$query->leftJoin('attribute atr ON (atr.id_attribute = pac.id_attribute)');
|
||||
$query->leftJoin('attribute_lang al ON (al.id_attribute = atr.id_attribute AND al.id_lang = '.$lang_id.')');
|
||||
$query->leftJoin('attribute_group_lang agl ON (agl.id_attribute_group = atr.id_attribute_group AND agl.id_lang = '.$lang_id.')');
|
||||
$query->where('pa.id_product = '.$id_product);
|
||||
if ($warehouse != -1)
|
||||
$query->where('s.id_warehouse = '.(int)$warehouse);
|
||||
$query->groupBy('pa.id_product_attribute');
|
||||
|
||||
$datas = Db::getInstance(_PS_USE_SQL_SLAVE_)->executeS($query);
|
||||
foreach ($datas as &$data)
|
||||
@@ -145,7 +159,7 @@ class AdminStockCoverControllerCore extends AdminController
|
||||
$this->list_no_link = true;
|
||||
|
||||
// query
|
||||
$this->_select = 'a.id_product as id, COUNT(pa.id_product_attribute) as variations, s.physical_quantity as stock';
|
||||
$this->_select = 'a.id_product as id, COUNT(pa.id_product_attribute) as variations, SUM(s.usable_quantity) as stock';
|
||||
$this->_join = 'LEFT JOIN `'._DB_PREFIX_.'product_attribute` pa ON (pa.id_product = a.id_product)
|
||||
INNER JOIN `'._DB_PREFIX_.'stock` s ON (s.id_product = a.id_product)';
|
||||
if ($this->getCurrentCoverageWarehouse() != -1)
|
||||
@@ -195,7 +209,12 @@ class AdminStockCoverControllerCore extends AdminController
|
||||
$this->addRowActionSkipList('details', array($item['id']));
|
||||
}
|
||||
else
|
||||
{
|
||||
$item['stock'] = 'See details';
|
||||
$item['reference'] = '--';
|
||||
$item['ean13'] = '--';
|
||||
$item['upc'] = '--';
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -35,9 +35,9 @@ class AdminStockInstantStateControllerCore extends AdminController
|
||||
public function __construct()
|
||||
{
|
||||
$this->context = Context::getContext();
|
||||
$this->table = 'product';
|
||||
$this->className = 'Product';
|
||||
$this->lang = true;
|
||||
$this->table = 'stock';
|
||||
$this->className = 'Stock';
|
||||
$this->lang = false;
|
||||
|
||||
$this->fieldsDisplay = array(
|
||||
'reference' => array(
|
||||
@@ -50,14 +50,19 @@ class AdminStockInstantStateControllerCore extends AdminController
|
||||
'align' => 'center',
|
||||
'width' => 100,
|
||||
),
|
||||
'upc' => array(
|
||||
'title' => $this->l('UPC'),
|
||||
'align' => 'center',
|
||||
'width' => 100,
|
||||
),
|
||||
'name' => array(
|
||||
'title' => $this->l('Name'),
|
||||
'filter_key' => 'b!name'
|
||||
'havingFilter' => true
|
||||
),
|
||||
'price_te' => array(
|
||||
'title' => $this->l('Price (te)'),
|
||||
'width' => 150,
|
||||
'orderby' => false,
|
||||
'orderby' => true,
|
||||
'search' => false,
|
||||
'type' => 'price',
|
||||
'currency' => true,
|
||||
@@ -65,19 +70,19 @@ class AdminStockInstantStateControllerCore extends AdminController
|
||||
'physical_quantity' => array(
|
||||
'title' => $this->l('Physical quantity'),
|
||||
'width' => 80,
|
||||
'orderby' => false,
|
||||
'orderby' => true,
|
||||
'search' => false
|
||||
),
|
||||
'usable_quantity' => array(
|
||||
'title' => $this->l('Usable quantity'),
|
||||
'width' => 80,
|
||||
'orderby' => false,
|
||||
'orderby' => true,
|
||||
'search' => false,
|
||||
),
|
||||
'real_quantity' => array(
|
||||
'title' => $this->l('Real quantity'),
|
||||
'width' => 80,
|
||||
'orderby' => false,
|
||||
'orderby' => true,
|
||||
'search' => false,
|
||||
'hint' => $this->l('Pysical qty,
|
||||
in combination with the quantity you ordered (atm) from your supplier,
|
||||
@@ -91,61 +96,6 @@ class AdminStockInstantStateControllerCore extends AdminController
|
||||
parent::__construct();
|
||||
}
|
||||
|
||||
/**
|
||||
* Method called when an ajax request is made
|
||||
* @see AdminController::postProcess()
|
||||
*/
|
||||
public function ajaxProcess()
|
||||
{
|
||||
if (Tools::isSubmit('id')) // if a product id is submit
|
||||
{
|
||||
$this->lang = false;
|
||||
$lang_id = (int)$this->context->language->id;
|
||||
$id_product = (int)Tools::getValue('id');
|
||||
$warehouse = (Tools::getValue('id_warehouse') ? (int)Tools::getValue('id_warehouse') : -1);
|
||||
|
||||
$query = '
|
||||
SELECT a.id_product_attribute as id, a.id_product, a.reference, a.ean13,
|
||||
IFNULL(CONCAT(pl.name, \' : \', GROUP_CONCAT(agl.`name`, \' - \', al.name SEPARATOR \', \')),pl.name) as name,
|
||||
IFNULL(s.physical_quantity, 0) as physical_quantity,
|
||||
IFNULL(s.usable_quantity, 0) as usable_quantity,
|
||||
s.price_te,
|
||||
w.id_currency as id_currency
|
||||
FROM '._DB_PREFIX_.'product_attribute a
|
||||
INNER JOIN '._DB_PREFIX_.'product_lang pl ON (pl.id_product = a.id_product AND pl.id_lang = '.$lang_id.')
|
||||
LEFT JOIN '._DB_PREFIX_.'product_attribute_combination pac ON (pac.id_product_attribute = a.id_product_attribute)
|
||||
LEFT JOIN '._DB_PREFIX_.'attribute atr ON (atr.id_attribute = pac.id_attribute)
|
||||
LEFT JOIN '._DB_PREFIX_.'attribute_lang al ON (al.id_attribute = atr.id_attribute AND al.id_lang = '.$lang_id.')
|
||||
LEFT JOIN '._DB_PREFIX_.'attribute_group_lang agl ON (agl.id_attribute_group = atr.id_attribute_group AND agl.id_lang = '.$lang_id.')
|
||||
INNER JOIN '._DB_PREFIX_.'stock s ON (a.id_product_attribute = s.id_product_attribute)
|
||||
LEFT JOIN `'._DB_PREFIX_.'warehouse` w ON (w.id_warehouse = s.id_warehouse)
|
||||
WHERE a.id_product = '.$id_product.
|
||||
($warehouse != -1 ? ' AND s.id_warehouse = '.(int)$warehouse : ' ').'
|
||||
GROUP BY a.id_product_attribute';
|
||||
|
||||
// gets stock manager
|
||||
$manager = StockManagerFactory::getManager();
|
||||
|
||||
// queries
|
||||
$datas = Db::getInstance(_PS_USE_SQL_SLAVE_)->executeS($query);
|
||||
|
||||
foreach ($datas as &$data)
|
||||
{
|
||||
// retrieves real quantity for each product
|
||||
$data['real_quantity'] = $manager->getProductRealQuantities($data['id_product'],
|
||||
$data['id'],
|
||||
($warehouse == -1 ? null : array($warehouse)), // all or selected warehouse(s)
|
||||
true);
|
||||
|
||||
// display price correctly
|
||||
$data['price_te'] = Tools::displayPrice($data['price_te'], (int)$data['id_currency']);
|
||||
}
|
||||
|
||||
echo Tools::jsonEncode(array('data'=> $datas, 'fields_display' => $this->fieldsDisplay));
|
||||
}
|
||||
die;
|
||||
}
|
||||
|
||||
/**
|
||||
* AdminController::initList() override
|
||||
* @see AdminController::initList()
|
||||
@@ -154,26 +104,36 @@ class AdminStockInstantStateControllerCore extends AdminController
|
||||
{
|
||||
// query
|
||||
$this->_select = '
|
||||
a.id_product as id,
|
||||
COUNT(pa.id_product_attribute) as variations,
|
||||
s.physical_quantity as physical_quantity,
|
||||
s.usable_quantity as usable_quantity,
|
||||
s.price_te as price_te,
|
||||
w.id_currency as id_currency';
|
||||
CONCAT(pl.name, \' \', GROUP_CONCAT(IFNULL(al.name, \'\'), \'\')) as name,
|
||||
a.reference,
|
||||
a.ean13,
|
||||
a.upc,
|
||||
w.id_currency,
|
||||
a.physical_quantity,
|
||||
a.usable_quantity,
|
||||
COUNT(a.id_stock) as multiple_prices';
|
||||
|
||||
$this->_join = 'LEFT JOIN `'._DB_PREFIX_.'product_attribute` pa ON (pa.id_product = a.id_product)
|
||||
INNER JOIN `'._DB_PREFIX_.'stock` s ON (s.id_product = a.id_product)
|
||||
LEFT JOIN `'._DB_PREFIX_.'warehouse` w ON (w.id_warehouse = s.id_warehouse)';
|
||||
$this->_join = 'INNER JOIN '._DB_PREFIX_.'stock stock ON a.id_stock = stock.id_stock
|
||||
LEFT JOIN `'._DB_PREFIX_.'product_lang` pl ON (
|
||||
stock.id_product = pl.id_product
|
||||
AND pl.id_lang = '.(int)$this->context->language->id.$this->context->shop->addSqlRestrictionOnLang('pl').'
|
||||
)
|
||||
LEFT JOIN `'._DB_PREFIX_.'warehouse` w ON (w.id_warehouse = stock.id_warehouse)
|
||||
LEFT JOIN `'._DB_PREFIX_.'product_attribute_combination` pac ON (pac.id_product_attribute = stock.id_product_attribute)
|
||||
LEFT JOIN `'._DB_PREFIX_.'attribute_lang` al ON (
|
||||
al.id_attribute = pac.id_attribute
|
||||
AND al.id_lang = '.(int)$this->context->language->id.'
|
||||
)';
|
||||
$this->_group = 'GROUP BY a.id_stock, a.id_product, a.id_product_attribute';
|
||||
|
||||
if ($this->getCurrentCoverageWarehouse() != -1)
|
||||
$this->_where .= ' AND s.id_warehouse = '.$this->getCurrentCoverageWarehouse();
|
||||
$this->_where .= ' AND a.id_warehouse = '.$this->getCurrentCoverageWarehouse();
|
||||
|
||||
// toolbar btn
|
||||
$this->toolbar_btn = array();
|
||||
// disables link
|
||||
$this->list_no_link = true;
|
||||
// adds action
|
||||
$this->addRowAction('details');
|
||||
|
||||
// smarty
|
||||
$this->tpl_list_vars['stock_instant_state_warehouses'] = $this->stock_instant_state_warehouses;
|
||||
$this->tpl_list_vars['stock_instant_state_cur_warehouse'] = $this->getCurrentCoverageWarehouse();
|
||||
@@ -198,27 +158,15 @@ class AdminStockInstantStateControllerCore extends AdminController
|
||||
for ($i = 0; $i < $nb_items; ++$i)
|
||||
{
|
||||
$item = &$this->_list[$i];
|
||||
if ((int)$item['variations'] <= 0) // if this product does not have combinations
|
||||
{
|
||||
// removes 'details' action on products without attributes
|
||||
$this->addRowActionSkipList('details', array($item['id']));
|
||||
|
||||
// gets stock manager
|
||||
$manager = StockManagerFactory::getManager();
|
||||
// gets stock manager
|
||||
$manager = StockManagerFactory::getManager();
|
||||
|
||||
// gets real_quantity depending on the warehouse
|
||||
$item['real_quantity'] = $manager->getProductRealQuantities($item['id'],
|
||||
0,
|
||||
($this->getCurrentCoverageWarehouse() == -1 ? null : array($this->getCurrentCoverageWarehouse())),
|
||||
true);
|
||||
}
|
||||
else // else, this product does have combinations, hence we do not display informations
|
||||
{
|
||||
$item['price_te'] = '--';
|
||||
$item['physical_quantity'] = '--';
|
||||
$item['usable_quantity'] = '--';
|
||||
$item['real_quantity'] = '--';
|
||||
}
|
||||
// gets real_quantity depending on the warehouse
|
||||
$item['real_quantity'] = $manager->getProductRealQuantities($item['id_product'],
|
||||
$item['id_product_attribute'],
|
||||
($this->getCurrentCoverageWarehouse() == -1 ? null : array($this->getCurrentCoverageWarehouse())),
|
||||
true);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -239,4 +187,5 @@ class AdminStockInstantStateControllerCore extends AdminController
|
||||
}
|
||||
return $warehouse;
|
||||
}
|
||||
|
||||
}
|
||||
@@ -50,6 +50,12 @@ class AdminStockManagementControllerCore extends AdminController
|
||||
'filter_key' => 'a!ean13',
|
||||
'width' => 100
|
||||
),
|
||||
'upc' => array(
|
||||
'title' => $this->l('UPC'),
|
||||
'align' => 'center',
|
||||
'filter_key' => 'a!upc',
|
||||
'width' => 100
|
||||
),
|
||||
'name' => array(
|
||||
'title' => $this->l('Name'),
|
||||
),
|
||||
@@ -161,6 +167,13 @@ class AdminStockManagementControllerCore extends AdminController
|
||||
'size' => 15,
|
||||
'disabled' => true,
|
||||
),
|
||||
array(
|
||||
'type' => 'text',
|
||||
'label' => $this->l('UPC:'),
|
||||
'name' => 'upc',
|
||||
'size' => 15,
|
||||
'disabled' => true,
|
||||
),
|
||||
array(
|
||||
'type' => 'text',
|
||||
'label' => $this->l('Name :'),
|
||||
@@ -767,7 +780,7 @@ class AdminStockManagementControllerCore extends AdminController
|
||||
// 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,
|
||||
$this->_select = 'a.id_product_attribute as id, a.id_product, a.reference, a.ean13, a.upc,
|
||||
IFNULL(CONCAT(pl.name, \' : \', GROUP_CONCAT(agl.`name`, \' - \', al.name SEPARATOR \', \')),pl.name) as name';
|
||||
|
||||
$this->_join = '
|
||||
@@ -836,6 +849,11 @@ class AdminStockManagementControllerCore extends AdminController
|
||||
$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
|
||||
{
|
||||
@@ -915,6 +933,7 @@ class AdminStockManagementControllerCore extends AdminController
|
||||
$id_product = $combination->id_product;
|
||||
$reference = $combination->reference;
|
||||
$ean13 = $combination->ean13;
|
||||
$upc = $combination->upc;
|
||||
$manufacturer_reference = $combination->supplier_reference;
|
||||
|
||||
// get the full name for this combination
|
||||
@@ -941,6 +960,7 @@ class AdminStockManagementControllerCore extends AdminController
|
||||
$product_is_valid = true;
|
||||
$reference = $product->reference;
|
||||
$ean13 = $product->ean13;
|
||||
$upc = $product->upc;
|
||||
$name = $product->name;
|
||||
$manufacturer_reference = $product->supplier_reference;
|
||||
$is_pack = $product->cache_is_pack;
|
||||
@@ -974,6 +994,7 @@ class AdminStockManagementControllerCore extends AdminController
|
||||
'manufacturer_reference' => $manufacturer_reference,
|
||||
'name' => $name,
|
||||
'ean13' => $ean13,
|
||||
'upc' => $upc,
|
||||
'check' => md5(_COOKIE_KEY_.$id_product.$id_product_attribute),
|
||||
'quantity' => Tools::getValue('quantity', ''),
|
||||
'id_warehouse' => Tools::getValue('id_warehouse', ''),
|
||||
|
||||
@@ -743,6 +743,7 @@ class AdminSupplyOrdersControllerCore extends AdminController
|
||||
|
||||
$this->tpl_form_vars['products_list'] = $products;
|
||||
$this->tpl_form_vars['product_ids'] = implode($product_ids, '|');
|
||||
$this->tpl_form_vars['product_ids_to_delete'] = '';
|
||||
$this->tpl_form_vars['supplier_id'] = $supply_order->id_supplier;
|
||||
$this->tpl_form_vars['currency'] = $currency;
|
||||
}
|
||||
@@ -961,6 +962,27 @@ class AdminSupplyOrdersControllerCore extends AdminController
|
||||
// gets all product ids to manage
|
||||
$product_ids_str = Tools::getValue('product_ids', null);
|
||||
$product_ids = explode('|', $product_ids_str);
|
||||
$product_ids_to_delete_str = Tools::getValue('product_ids_to_delete', null);
|
||||
$product_ids_to_delete = array_unique(explode('|', $product_ids_to_delete_str));
|
||||
|
||||
//delete products that are not managed anymore
|
||||
foreach ($products_already_in_order as $paio)
|
||||
{
|
||||
$product_ok = false;
|
||||
|
||||
foreach ($product_ids_to_delete as $id)
|
||||
{
|
||||
$id_check = $paio['id_product'].'_'.$paio['id_product_attribute'];
|
||||
if ($id_check == $id)
|
||||
$product_ok = true;
|
||||
}
|
||||
|
||||
if ($product_ok === true)
|
||||
{
|
||||
$entry = new SupplyOrderDetail($paio['id_supply_order_detail']);
|
||||
$entry->delete();
|
||||
}
|
||||
}
|
||||
|
||||
// manage each product
|
||||
foreach ($product_ids as $id)
|
||||
@@ -1042,25 +1064,6 @@ class AdminSupplyOrdersControllerCore extends AdminController
|
||||
else
|
||||
$entry->save();
|
||||
}
|
||||
|
||||
//delete products that are not managed anymore
|
||||
foreach ($products_already_in_order as $paio)
|
||||
{
|
||||
$product_ok = false;
|
||||
|
||||
foreach ($product_ids as $id)
|
||||
{
|
||||
$id_check = $paio['id_product'].'_'.$paio['id_product_attribute'];
|
||||
if ($id_check == $id)
|
||||
$product_ok = true;
|
||||
}
|
||||
|
||||
if ($product_ok === false)
|
||||
{
|
||||
$entry = new SupplyOrderDetail($paio['id_supply_order_detail']);
|
||||
$entry->delete();
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -275,7 +275,7 @@ class AdminWarehousesControllerCore extends AdminController
|
||||
);
|
||||
|
||||
// It is not possible to change currency valuation and management type
|
||||
if (Tools::isSubmit('addwarehouse'))
|
||||
if (Tools::isSubmit('addwarehouse') || Tools::isSubmit('submitAddwarehouse'))
|
||||
{
|
||||
$this->fields_form['input'][] = array(
|
||||
'type' => 'select',
|
||||
@@ -314,7 +314,9 @@ class AdminWarehousesControllerCore extends AdminController
|
||||
'name' => 'name'
|
||||
)
|
||||
);
|
||||
} else {
|
||||
}
|
||||
else
|
||||
{
|
||||
$this->fields_form['input'][] = array(
|
||||
'type' => 'hidden',
|
||||
'name' => 'management_type'
|
||||
|
||||
Reference in New Issue
Block a user