From 73a09574ec7cf124e4e67ac842f8b4d3af0da2f3 Mon Sep 17 00:00:00 2001 From: bMancone Date: Thu, 22 Dec 2011 13:58:16 +0000 Subject: [PATCH] // Warehouse: when being flaged as deleted, fixed deletion of associations with carriers, products, shops. StockInterfaces: fixed size of the filters --- admin-dev/themes/default/admin.css | 10 +++++++--- .../themes/template/stock_cover/list_header.tpl | 2 +- .../themes/template/supply_orders/list_header.tpl | 2 +- classes/stock/Warehouse.php | 14 ++++++++++++++ controllers/admin/AdminWarehousesController.php | 9 ++++++++- 5 files changed, 31 insertions(+), 6 deletions(-) diff --git a/admin-dev/themes/default/admin.css b/admin-dev/themes/default/admin.css index b06603f9c..9baafba7f 100644 --- a/admin-dev/themes/default/admin.css +++ b/admin-dev/themes/default/admin.css @@ -228,13 +228,17 @@ form#product_form h4 { font-size:18px; font-weight:normal;} .filter-module .button-filter { float:right;} /*FILTER STOCK*/ -.filter-stock { background-color:#ebedf4; border:1px solid #c2c4d9; margin-bottom:15px; padding:10px; display:block; min-height:65px;} -.filter-stock #stock_cover {float:left; margin-right:30px;} +.filter-stock { background-color:#ebedf4; border:1px solid #c2c4d9; margin-bottom:15px; padding:10px; display:block; min-height:25px;} .filter-stock #stock_instant_state {float:left; margin-right:30px;} -.filter-stock #supply_orders {float:left; margin-right:30px;} .filter-stock label {width:auto;} .filter-stock .select-filter { float:left;} .filter-stock .button-filter { float:right;} +.filter-stock-extended { background-color:#ebedf4; border:1px solid #c2c4d9; margin-bottom:15px; padding:10px; display:block; min-height:65px;} +.filter-stock-extended #stock_cover {float:left; margin-right:30px;} +.filter-stock-extended #supply_orders {float:left; margin-right:30px;} +.filter-stock-extended label {width:auto;} +.filter-stock-extended .select-filter { float:left;} +.filter-stock-extended .button-filter { float:right;} /*ADDONS LOGIN*/ #addons_login_div { background: #EBEDF4 url(lock.png) no-repeat scroll left 5px;} diff --git a/admin-dev/themes/template/stock_cover/list_header.tpl b/admin-dev/themes/template/stock_cover/list_header.tpl index 67e4155fc..fc2489889 100644 --- a/admin-dev/themes/template/stock_cover/list_header.tpl +++ b/admin-dev/themes/template/stock_cover/list_header.tpl @@ -25,7 +25,7 @@ *} {extends file="helper/list/list_header.tpl"} {block name=override_header} -
+
diff --git a/admin-dev/themes/template/supply_orders/list_header.tpl b/admin-dev/themes/template/supply_orders/list_header.tpl index be2318592..4030af281 100644 --- a/admin-dev/themes/template/supply_orders/list_header.tpl +++ b/admin-dev/themes/template/supply_orders/list_header.tpl @@ -26,7 +26,7 @@ {extends file="helper/list/list_header.tpl"} {block name=override_header} {if isset($warehouses) && count($warehouses) > 0 && isset($filter_status)} -
+
diff --git a/classes/stock/Warehouse.php b/classes/stock/Warehouse.php index b2c6685cb..2cd8b91dc 100644 --- a/classes/stock/Warehouse.php +++ b/classes/stock/Warehouse.php @@ -134,6 +134,9 @@ class WarehouseCore extends ObjectModel */ public function setShops($ids_shop) { + if (!is_array($ids_shop)) + $ids_shop = array(); + $row_to_insert = array(); foreach ($ids_shop as $id_shop) $row_to_insert[] = array($this->def['primary'] => $this->id, 'id_shop' => (int)$id_shop); @@ -262,6 +265,16 @@ class WarehouseCore extends ObjectModel return (Db::getInstance()->execute($query)); } + /** + * Reset all product locations for this warehouse + */ + public function resetProductsLocations() + { + Db::getInstance()->execute(' + DELETE FROM `'._DB_PREFIX_.'warehouse_product_location` + WHERE `id_warehouse` = '.(int)$this->id); + } + /** * For a given {product, product attribute} gets its location in the given warehouse * @@ -302,6 +315,7 @@ class WarehouseCore extends ObjectModel $query->innerJoin('warehouse', 'w', 'ws.id_warehouse = w.id_warehouse'); $query->where('id_product = '.(int)$id_product); $query->where('id_product_attribute = '.(int)$id_product_attribute); + $query->where('w.deleted = 0'); $query->groupBy('wpl.id_warehouse'); return (Db::getInstance(_PS_USE_SQL_SLAVE_)->executeS($query)); diff --git a/controllers/admin/AdminWarehousesController.php b/controllers/admin/AdminWarehousesController.php index 9d6b66699..fc6939ba4 100644 --- a/controllers/admin/AdminWarehousesController.php +++ b/controllers/admin/AdminWarehousesController.php @@ -437,14 +437,21 @@ class AdminWarehousesControllerCore extends AdminController if (!($obj = $this->loadObject(true))) return; else if ($obj->getQuantitiesOfProducts() > 0) - $this->_errors[] = $this->l('It is not possible to delete a Warehosue when there are products in it.'); + $this->_errors[] = $this->l('It is not possible to delete a Warehouse when there are products in it.'); else if (SupplyOrder::warehouseHasPendingOrders($obj->id)) $this->_errors[] = $this->l('It is not possible to delete a Warehouse if it has pending supply orders.'); else { + // sets the address of the warehouse as deleted $address = new Address($obj->id_address); $address->deleted = 1; $address->save(); + + // removes associations + $obj->setCarriers(array()); + $obj->setShops(array()); + $obj->resetProductsLocations(); + return parent::postProcess(); } }