diff --git a/htdocs/langs/en_US/stocks.lang b/htdocs/langs/en_US/stocks.lang index f789ce283e5..3ee38749b10 100644 --- a/htdocs/langs/en_US/stocks.lang +++ b/htdocs/langs/en_US/stocks.lang @@ -317,3 +317,4 @@ StockTransferRightRead=Read stocks transfers StockTransferRightCreateUpdate=Create/Update stocks transfers StockTransferRightDelete=Delete stocks transfers BatchNotFound=Lot / serial not found for this product +WarningThisWIllAlsoDeleteStock=Warning, this will also destroy all quantities in stock in the warehouse \ No newline at end of file diff --git a/htdocs/partnership/partnership_card.php b/htdocs/partnership/partnership_card.php index 7679b63da09..bf51b1fe5df 100644 --- a/htdocs/partnership/partnership_card.php +++ b/htdocs/partnership/partnership_card.php @@ -391,7 +391,7 @@ if ($object->id > 0 && (empty($action) || ($action != 'edit' && $action != 'crea // )); // } - $formconfirm = $form->formconfirm($_SERVER["PHP_SELF"].'?id='.$object->id, $langs->trans('ToRefuse'), $text, 'confirm_refuse', $formquestion, '', 1, 250); + $formconfirm = $form->formconfirm($_SERVER["PHP_SELF"].'?id='.$object->id, $langs->trans('ToRefuse'), '', 'confirm_refuse', $formquestion, '', 1, 250); } // Call Hook formConfirm diff --git a/htdocs/product/stock/card.php b/htdocs/product/stock/card.php index 1412ea2fcf5..6543fe47c10 100644 --- a/htdocs/product/stock/card.php +++ b/htdocs/product/stock/card.php @@ -413,7 +413,10 @@ if ($action == 'create') { // Confirm delete warehouse if ($action == 'delete') { - $formconfirm = $form->formconfirm($_SERVER["PHP_SELF"]."?id=".$object->id, $langs->trans("DeleteAWarehouse"), $langs->trans("ConfirmDeleteWarehouse", $object->label), "confirm_delete", '', 0, 2); + $formquestion = array( + array('type' => 'other', 'name' => 'info', 'label' => img_warning('').$langs->trans("WarningThisWIllAlsoDeleteStock"), 'morecss'=>'warning') + ); + $formconfirm = $form->formconfirm($_SERVER["PHP_SELF"]."?id=".$object->id, $langs->trans("DeleteAWarehouse"), $langs->trans("ConfirmDeleteWarehouse", $object->label), "confirm_delete", $formquestion, 0, 2); } // Call Hook formConfirm diff --git a/htdocs/product/stock/class/entrepot.class.php b/htdocs/product/stock/class/entrepot.class.php index 55e365f07da..edb51647a1f 100644 --- a/htdocs/product/stock/class/entrepot.class.php +++ b/htdocs/product/stock/class/entrepot.class.php @@ -367,16 +367,28 @@ class Entrepot extends CommonObject // End call triggers } - $elements = array('stock_mouvement', 'product_stock', 'product_warehouse_properties'); - foreach ($elements as $table) { - if (!$error) { - $sql = "DELETE FROM ".$this->db->prefix().$table; - $sql .= " WHERE fk_entrepot = ".((int) $this->id); + if (!$error) { + $sql = "DELETE FROM ".$this->db->prefix()."product_batch"; + $sql .= " WHERE fk_product_stock IN (SELECT rowid FROM ".$this->db->prefix()."product_stock as ps WHERE ps.fk_entrepot = ".((int) $this->id).")"; + $result = $this->db->query($sql); + if (!$result) { + $error++; + $this->errors[] = $this->db->lasterror(); + } + } - $result = $this->db->query($sql); - if (!$result) { - $error++; - $this->errors[] = $this->db->lasterror(); + if (!$error) { + $elements = array('stock_mouvement', 'product_stock'); + foreach ($elements as $table) { + if (!$error) { + $sql = "DELETE FROM ".$this->db->prefix().$table; + $sql .= " WHERE fk_entrepot = ".((int) $this->id); + + $result = $this->db->query($sql); + if (!$result) { + $error++; + $this->errors[] = $this->db->lasterror(); + } } } }