// StockManagement : updated the warehouse list displayed when {adding, removing, transfering} stock
git-svn-id: http://dev.prestashop.com/svn/v1/branches/1.5.x@10127 b9a71923-0436-4b27-9f14-aed3839534dd
This commit is contained in:
@@ -283,9 +283,10 @@ class WarehouseCore extends ObjectModel
|
|||||||
$id_shop = Context::getContext()->shop->getID(true);
|
$id_shop = Context::getContext()->shop->getID(true);
|
||||||
|
|
||||||
$query = new DbQuery();
|
$query = new DbQuery();
|
||||||
$query->select('w.id_warehouse, name');
|
$query->select('w.id_warehouse, CONCAT(reference, \' - \', name) as name');
|
||||||
$query->from('warehouse w');
|
$query->from('warehouse w');
|
||||||
$query->where('deleted = 0');
|
$query->where('deleted = 0');
|
||||||
|
$query->orderBy('reference ASC');
|
||||||
if (!$ignore_shop)
|
if (!$ignore_shop)
|
||||||
$query->innerJoin('warehouse_shop ws ON ws.id_warehouse = w.id_warehouse AND ws.id_shop = '.(int)$id_shop);
|
$query->innerJoin('warehouse_shop ws ON ws.id_warehouse = w.id_warehouse AND ws.id_shop = '.(int)$id_shop);
|
||||||
|
|
||||||
@@ -359,4 +360,29 @@ class WarehouseCore extends ObjectModel
|
|||||||
|
|
||||||
return Db::getInstance(_PS_USE_SQL_SLAVE_)->executeS($query);
|
return Db::getInstance(_PS_USE_SQL_SLAVE_)->executeS($query);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* For a given product, returns the warehouses it is stored in
|
||||||
|
*
|
||||||
|
* @param int $id_product
|
||||||
|
* @param int $id_product_attribute
|
||||||
|
* @return array
|
||||||
|
*/
|
||||||
|
public static function getWarehousesByProductId($id_product, $id_product_attribute)
|
||||||
|
{
|
||||||
|
if (!$id_product && !$id_product_attribute)
|
||||||
|
return array();
|
||||||
|
|
||||||
|
$query = new DbQuery();
|
||||||
|
$query->select('w.id_warehouse, CONCAT(w.reference, " - ", w.name) as name');
|
||||||
|
$query->from('warehouse w');
|
||||||
|
$query->leftJoin('stock s ON (s.id_warehouse = w.id_warehouse)');
|
||||||
|
if ($id_product)
|
||||||
|
$query->where('s.id_product = '.(int)$id_product);
|
||||||
|
if ($id_product_attribute)
|
||||||
|
$query->where('s.id_product_attribute = '.(int)$id_product_attribute);
|
||||||
|
$query->orderBy('w.reference ASC');
|
||||||
|
|
||||||
|
return Db::getInstance(_PS_USE_SQL_SLAVE_)->executeS($query);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
@@ -106,11 +106,12 @@ class AdminStockManagementControllerCore extends AdminController
|
|||||||
*/
|
*/
|
||||||
public function initForm()
|
public function initForm()
|
||||||
{
|
{
|
||||||
//get warehouses list
|
$id_product = (int)Tools::getValue('id_product');
|
||||||
$warehouses = Db::getInstance(_PS_USE_SQL_SLAVE_)->executeS('
|
$id_product_attribute = (int)Tools::getValue('id_product_attribute');
|
||||||
SELECT `id_warehouse`, CONCAT(`reference`, " - ", `name`) as name
|
|
||||||
FROM `'._DB_PREFIX_.'warehouse`
|
// gets warehouses
|
||||||
ORDER BY `reference` ASC');
|
$warehouses_add = Warehouse::getWarehouses(true);
|
||||||
|
$warehouses_remove = Warehouse::getWarehousesByProductId($id_product, $id_product_attribute);
|
||||||
|
|
||||||
$currencies = Currency::getCurrencies();
|
$currencies = Currency::getCurrencies();
|
||||||
|
|
||||||
@@ -203,7 +204,7 @@ class AdminStockManagementControllerCore extends AdminController
|
|||||||
'name' => 'id_warehouse',
|
'name' => 'id_warehouse',
|
||||||
'required' => true,
|
'required' => true,
|
||||||
'options' => array(
|
'options' => array(
|
||||||
'query' => $warehouses,
|
'query' => $warehouses_add,
|
||||||
'id' => 'id_warehouse',
|
'id' => 'id_warehouse',
|
||||||
'name' => 'name'
|
'name' => 'name'
|
||||||
),
|
),
|
||||||
@@ -339,7 +340,7 @@ class AdminStockManagementControllerCore extends AdminController
|
|||||||
'name' => 'id_warehouse',
|
'name' => 'id_warehouse',
|
||||||
'required' => true,
|
'required' => true,
|
||||||
'options' => array(
|
'options' => array(
|
||||||
'query' => $warehouses,
|
'query' => $warehouses_remove,
|
||||||
'id' => 'id_warehouse',
|
'id' => 'id_warehouse',
|
||||||
'name' => 'name'
|
'name' => 'name'
|
||||||
),
|
),
|
||||||
@@ -425,7 +426,7 @@ class AdminStockManagementControllerCore extends AdminController
|
|||||||
'size' => 10,
|
'size' => 10,
|
||||||
'maxlength' => 6,
|
'maxlength' => 6,
|
||||||
'required' => true,
|
'required' => true,
|
||||||
'p' => $this->l('Physical quantity to transfer for this product')
|
'p' => $this->l('Physical quantity to transfer.')
|
||||||
),
|
),
|
||||||
array(
|
array(
|
||||||
'type' => 'select',
|
'type' => 'select',
|
||||||
@@ -433,15 +434,15 @@ class AdminStockManagementControllerCore extends AdminController
|
|||||||
'name' => 'id_warehouse_from',
|
'name' => 'id_warehouse_from',
|
||||||
'required' => true,
|
'required' => true,
|
||||||
'options' => array(
|
'options' => array(
|
||||||
'query' => $warehouses,
|
'query' => $warehouses_remove,
|
||||||
'id' => 'id_warehouse',
|
'id' => 'id_warehouse',
|
||||||
'name' => 'name'
|
'name' => 'name'
|
||||||
),
|
),
|
||||||
'p' => $this->l('Select the warehouse from where you want to transfer the product')
|
'p' => $this->l('Select the warehouse want to transfer the product from.')
|
||||||
),
|
),
|
||||||
array(
|
array(
|
||||||
'type' => 'radio',
|
'type' => 'radio',
|
||||||
'label' => $this->l('Usable for sale in source warehouse ?:'),
|
'label' => $this->l('Usable for sale in source warehouse ?'),
|
||||||
'name' => 'usable_from',
|
'name' => 'usable_from',
|
||||||
'required' => true,
|
'required' => true,
|
||||||
'class' => 't',
|
'class' => 't',
|
||||||
@@ -458,7 +459,7 @@ class AdminStockManagementControllerCore extends AdminController
|
|||||||
'label' => $this->l('Disabled')
|
'label' => $this->l('Disabled')
|
||||||
)
|
)
|
||||||
),
|
),
|
||||||
'p' => $this->l('Do you want to transfer this quantity from usable quantity for sale on shops in the source warehouse ?:')
|
'p' => $this->l('Is this a usable quantity for sale?')
|
||||||
),
|
),
|
||||||
array(
|
array(
|
||||||
'type' => 'select',
|
'type' => 'select',
|
||||||
@@ -466,15 +467,15 @@ class AdminStockManagementControllerCore extends AdminController
|
|||||||
'name' => 'id_warehouse_to',
|
'name' => 'id_warehouse_to',
|
||||||
'required' => true,
|
'required' => true,
|
||||||
'options' => array(
|
'options' => array(
|
||||||
'query' => $warehouses,
|
'query' => $warehouses_add,
|
||||||
'id' => 'id_warehouse',
|
'id' => 'id_warehouse',
|
||||||
'name' => 'name'
|
'name' => 'name'
|
||||||
),
|
),
|
||||||
'p' => $this->l('Select the warehouse where you want to transfer the product')
|
'p' => $this->l('Select the warehouse to transfer the product to.')
|
||||||
),
|
),
|
||||||
array(
|
array(
|
||||||
'type' => 'radio',
|
'type' => 'radio',
|
||||||
'label' => $this->l('Usable for sale in destination warehosue ?:'),
|
'label' => $this->l('Usable for sale in destination warehouse ?'),
|
||||||
'name' => 'usable_to',
|
'name' => 'usable_to',
|
||||||
'required' => true,
|
'required' => true,
|
||||||
'class' => 't',
|
'class' => 't',
|
||||||
@@ -491,7 +492,7 @@ class AdminStockManagementControllerCore extends AdminController
|
|||||||
'label' => $this->l('Disabled')
|
'label' => $this->l('Disabled')
|
||||||
)
|
)
|
||||||
),
|
),
|
||||||
'p' => $this->l('Do you want to transfer this quantity as usable quantity for sale on shops in the destination warehouse ?:')
|
'p' => $this->l('Do you want it to be usable for sale?')
|
||||||
),
|
),
|
||||||
),
|
),
|
||||||
'submit' => array(
|
'submit' => array(
|
||||||
|
|||||||
Reference in New Issue
Block a user