FIX delete of warehouse
This commit is contained in:
parent
6e0c57263c
commit
5e4edac94d
4 changed files with 27 additions and 11 deletions
|
|
@ -317,3 +317,4 @@ StockTransferRightRead=Read stocks transfers
|
||||||
StockTransferRightCreateUpdate=Create/Update stocks transfers
|
StockTransferRightCreateUpdate=Create/Update stocks transfers
|
||||||
StockTransferRightDelete=Delete stocks transfers
|
StockTransferRightDelete=Delete stocks transfers
|
||||||
BatchNotFound=Lot / serial not found for this product
|
BatchNotFound=Lot / serial not found for this product
|
||||||
|
WarningThisWIllAlsoDeleteStock=Warning, this will also destroy all quantities in stock in the warehouse
|
||||||
|
|
@ -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
|
// Call Hook formConfirm
|
||||||
|
|
|
||||||
|
|
@ -413,7 +413,10 @@ if ($action == 'create') {
|
||||||
|
|
||||||
// Confirm delete warehouse
|
// Confirm delete warehouse
|
||||||
if ($action == 'delete') {
|
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
|
// Call Hook formConfirm
|
||||||
|
|
|
||||||
|
|
@ -367,16 +367,28 @@ class Entrepot extends CommonObject
|
||||||
// End call triggers
|
// End call triggers
|
||||||
}
|
}
|
||||||
|
|
||||||
$elements = array('stock_mouvement', 'product_stock', 'product_warehouse_properties');
|
if (!$error) {
|
||||||
foreach ($elements as $table) {
|
$sql = "DELETE FROM ".$this->db->prefix()."product_batch";
|
||||||
if (!$error) {
|
$sql .= " WHERE fk_product_stock IN (SELECT rowid FROM ".$this->db->prefix()."product_stock as ps WHERE ps.fk_entrepot = ".((int) $this->id).")";
|
||||||
$sql = "DELETE FROM ".$this->db->prefix().$table;
|
$result = $this->db->query($sql);
|
||||||
$sql .= " WHERE fk_entrepot = ".((int) $this->id);
|
if (!$result) {
|
||||||
|
$error++;
|
||||||
|
$this->errors[] = $this->db->lasterror();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
$result = $this->db->query($sql);
|
if (!$error) {
|
||||||
if (!$result) {
|
$elements = array('stock_mouvement', 'product_stock');
|
||||||
$error++;
|
foreach ($elements as $table) {
|
||||||
$this->errors[] = $this->db->lasterror();
|
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();
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue