// StockInstantState: fixed bug on names. AdminOrders: fixed bug on return
This commit is contained in:
1 parent
7db77da99e
commit
df463cad79
2 files changed
+19
-8
No files matched your search
@@ -434,15 +434,15 @@ class AdminOrdersControllerCore extends AdminController
|
|||||||
// Reinject product
|
// Reinject product
|
||||||
if (!$order->hasBeenDelivered() OR ($order->hasBeenDelivered() AND Tools::isSubmit('reinjectQuantities')))
|
if (!$order->hasBeenDelivered() OR ($order->hasBeenDelivered() AND Tools::isSubmit('reinjectQuantities')))
|
||||||
{
|
{
|
||||||
$reinjectable_quantity = (int)$qty_cancel_product->product_quantity - (int)$qty_cancel_product->product_quantity_reinjected;
|
$reinjectable_quantity = (int)$order_detail->product_quantity - (int)$order_detail->product_quantity_reinjected;
|
||||||
$quantity_to_reinject = $qty_cancel_product > $reinjectable_quantity ? $reinjectable_quantity : $qty_cancel_product;
|
$quantity_to_reinject = $qty_cancel_product > $reinjectable_quantity ? $reinjectable_quantity : $qty_cancel_product;
|
||||||
|
|
||||||
// @since 1.5.0 : Advanced Stock Management
|
// @since 1.5.0 : Advanced Stock Management
|
||||||
$product_to_inject = new Product($qty_cancel_product->product_id, false, $this->context->language->id, $order->id_shop);
|
$product_to_inject = new Product($order_detail->product_id, false, $this->context->language->id, $order->id_shop);
|
||||||
if (Configuration::get('PS_ADVANCED_STOCK_MANAGEMENT') && $qty_cancel_product->id_warehouse != 0)
|
if (Configuration::get('PS_ADVANCED_STOCK_MANAGEMENT') && $order_detail->id_warehouse != 0)
|
||||||
{
|
{
|
||||||
$id_supplier = $product_to_inject->id_supplier;
|
$id_supplier = $product_to_inject->id_supplier;
|
||||||
$price = ProductSupplier::getProductPrice($id_supplier, $qty_cancel_product->product_id, $order_detail->product_attribute_id);
|
$price = ProductSupplier::getProductPrice($id_supplier, $order_detail->product_id, $order_detail->product_attribute_id);
|
||||||
$price_te = $price['price_te'];
|
$price_te = $price['price_te'];
|
||||||
$id_currency = $price['id_currency'];
|
$id_currency = $price['id_currency'];
|
||||||
$warehouse = new Warehouse($id_warehouse);
|
$warehouse = new Warehouse($id_warehouse);
|
||||||
|
|||||||
@@ -115,9 +115,6 @@ class AdminStockInstantStateControllerCore extends AdminController
|
|||||||
// query
|
// query
|
||||||
$this->_select = '
|
$this->_select = '
|
||||||
IFNULL(CONCAT(pl.name, \' : \', GROUP_CONCAT(DISTINCT agl.`name`, \' - \', al.name SEPARATOR \', \')),pl.name) as name,
|
IFNULL(CONCAT(pl.name, \' : \', GROUP_CONCAT(DISTINCT agl.`name`, \' - \', al.name SEPARATOR \', \')),pl.name) as name,
|
||||||
SUM(a.physical_quantity) as physical_quantity,
|
|
||||||
SUM(a.usable_quantity) as usable_quantity,
|
|
||||||
SUM(a.price_te * a.physical_quantity) as valuation,
|
|
||||||
w.id_currency';
|
w.id_currency';
|
||||||
|
|
||||||
$this->_group = 'GROUP BY a.id_product, a.id_product_attribute';
|
$this->_group = 'GROUP BY a.id_product, a.id_product_attribute';
|
||||||
@@ -125,7 +122,7 @@ class AdminStockInstantStateControllerCore extends AdminController
|
|||||||
$this->_join = 'LEFT JOIN `'._DB_PREFIX_.'warehouse` w ON (w.id_warehouse = a.id_warehouse)';
|
$this->_join = 'LEFT JOIN `'._DB_PREFIX_.'warehouse` w ON (w.id_warehouse = a.id_warehouse)';
|
||||||
$this->_join .= ' LEFT JOIN `'._DB_PREFIX_.'product_lang` pl ON (
|
$this->_join .= ' LEFT JOIN `'._DB_PREFIX_.'product_lang` pl ON (
|
||||||
a.id_product = pl.id_product
|
a.id_product = pl.id_product
|
||||||
AND pl.id_lang = '.(int)$this->context->language->id.$this->context->shop->addSqlRestrictionOnLang('pl').'
|
AND pl.id_lang = '.(int)$this->context->language->id.'
|
||||||
)';
|
)';
|
||||||
$this->_join .= ' LEFT JOIN `'._DB_PREFIX_.'product_attribute_combination` pac ON (pac.id_product_attribute = a.id_product_attribute)';
|
$this->_join .= ' LEFT JOIN `'._DB_PREFIX_.'product_attribute_combination` pac ON (pac.id_product_attribute = a.id_product_attribute)';
|
||||||
$this->_join .= ' LEFT JOIN `'._DB_PREFIX_.'attribute` atr ON (atr.id_attribute = pac.id_attribute)';
|
$this->_join .= ' LEFT JOIN `'._DB_PREFIX_.'attribute` atr ON (atr.id_attribute = pac.id_attribute)';
|
||||||
@@ -192,6 +189,18 @@ class AdminStockInstantStateControllerCore extends AdminController
|
|||||||
// gets stock manager
|
// gets stock manager
|
||||||
$manager = StockManagerFactory::getManager();
|
$manager = StockManagerFactory::getManager();
|
||||||
|
|
||||||
|
// gets quantities and valuation
|
||||||
|
$query = new DbQuery();
|
||||||
|
$query->select('SUM(physical_quantity) as physical_quantity');
|
||||||
|
$query->select('SUM(usable_quantity) as usable_quantity');
|
||||||
|
$query->select('SUM(price_te * physical_quantity) as valuation');
|
||||||
|
$query->from('stock');
|
||||||
|
$query->where('id_product = '.(int)$item['id_product'].' AND id_product_attribute = '.(int)$item['id_product_attribute']);
|
||||||
|
$res = Db::getInstance(_PS_USE_SQL_SLAVE_)->getRow($query);
|
||||||
|
|
||||||
|
$item['physical_quantity'] = $res['physical_quantity'];
|
||||||
|
$item['usable_quantity'] = $res['usable_quantity'];
|
||||||
|
|
||||||
// gets real_quantity depending on the warehouse
|
// gets real_quantity depending on the warehouse
|
||||||
$item['real_quantity'] = $manager->getProductRealQuantities($item['id_product'],
|
$item['real_quantity'] = $manager->getProductRealQuantities($item['id_product'],
|
||||||
$item['id_product_attribute'],
|
$item['id_product_attribute'],
|
||||||
@@ -201,6 +210,8 @@ class AdminStockInstantStateControllerCore extends AdminController
|
|||||||
// removes the valuation if the filter corresponds to 'all warehouses'
|
// removes the valuation if the filter corresponds to 'all warehouses'
|
||||||
if ($this->getCurrentCoverageWarehouse() == -1)
|
if ($this->getCurrentCoverageWarehouse() == -1)
|
||||||
$item['valuation'] = 'N/A';
|
$item['valuation'] = 'N/A';
|
||||||
|
else
|
||||||
|
$item['valuation'] = $res['valuation'];
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Reference in new issue
Block a user