New: task #9782 : Add possibility to delete a warehouse
This commit is contained in:
parent
ca1eda531e
commit
31d8054124
@ -10,6 +10,7 @@ For users:
|
|||||||
- New: Can use {tttt} in numbering mask setup. It will be replaced
|
- New: Can use {tttt} in numbering mask setup. It will be replaced
|
||||||
with third party type.
|
with third party type.
|
||||||
- New: VAT number is stored in one field. This is more "international".
|
- New: VAT number is stored in one field. This is more "international".
|
||||||
|
- New: task #9782 : Add possibility to delete a warehouse
|
||||||
- Fix: bug #28055 : Unable to modify the date of a cloned command
|
- Fix: bug #28055 : Unable to modify the date of a cloned command
|
||||||
- Fix: bug #27891
|
- Fix: bug #27891
|
||||||
- Fix: Change of numbering module was not effective
|
- Fix: Change of numbering module was not effective
|
||||||
|
|||||||
@ -151,3 +151,4 @@ CloneProduct=Clone product or service
|
|||||||
ConfirmCloneProduct=Are you sure you want to clone product or service <b>%s</b> ?
|
ConfirmCloneProduct=Are you sure you want to clone product or service <b>%s</b> ?
|
||||||
CloneContentProduct=Clone all main informations of product/service
|
CloneContentProduct=Clone all main informations of product/service
|
||||||
ClonePricesProduct=Clone main informations and prices
|
ClonePricesProduct=Clone main informations and prices
|
||||||
|
ProductIsUsed=This product is used
|
||||||
@ -67,3 +67,5 @@ AverageUnitPricePMPShort=Average input price
|
|||||||
AverageUnitPricePMP=Average input price
|
AverageUnitPricePMP=Average input price
|
||||||
EstimatedStockValueShort=Estimated value of stock
|
EstimatedStockValueShort=Estimated value of stock
|
||||||
EstimatedStockValue=Estimated value of stock
|
EstimatedStockValue=Estimated value of stock
|
||||||
|
DeleteAWarehouse=Delete a warehouse
|
||||||
|
ConfirmDeleteWarehouse=Are you sure you want to delete the warehouse <b>%s</b> ?
|
||||||
@ -151,3 +151,4 @@ CloneProduct=Cloner produit/service
|
|||||||
ConfirmCloneProduct=Etes-vous sur de vouloir cloner le produit ou service <b>%s</b> ?
|
ConfirmCloneProduct=Etes-vous sur de vouloir cloner le produit ou service <b>%s</b> ?
|
||||||
CloneContentProduct=Cloner les informations générales du produit/service uniquement
|
CloneContentProduct=Cloner les informations générales du produit/service uniquement
|
||||||
ClonePricesProduct=Cloner les informations générales et les prix
|
ClonePricesProduct=Cloner les informations générales et les prix
|
||||||
|
ProductIsUsed=Ce produit est utilisé
|
||||||
@ -67,3 +67,5 @@ AverageUnitPricePMPShort=Prix moyen pondéré (PMP)
|
|||||||
AverageUnitPricePMP=Prix moyen pondéré (PMP) d'aquisition
|
AverageUnitPricePMP=Prix moyen pondéré (PMP) d'aquisition
|
||||||
EstimatedStockValueShort=Valorisation (PMP)
|
EstimatedStockValueShort=Valorisation (PMP)
|
||||||
EstimatedStockValue=Valorisation aquisition stock (PMP)
|
EstimatedStockValue=Valorisation aquisition stock (PMP)
|
||||||
|
DeleteAWarehouse=Supprimer un entrepôt
|
||||||
|
ConfirmDeleteWarehouse=Etes-vous sur de vouloir supprimer l'entrepôt <b>%s</b> ?
|
||||||
@ -120,9 +120,9 @@ class Entrepot extends CommonObject
|
|||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/*
|
/**
|
||||||
* \brief Mise a jour des information d'un entrepot
|
* \brief Update properties of a warehouse
|
||||||
* \param id id de l'entrepot <EFBFBD> modifier
|
* \param id id of warehouse to modify
|
||||||
* \param user
|
* \param user
|
||||||
*/
|
*/
|
||||||
function update($id, $user)
|
function update($id, $user)
|
||||||
@ -147,30 +147,87 @@ class Entrepot extends CommonObject
|
|||||||
$sql .= ",fk_pays = " . $this->pays_id;
|
$sql .= ",fk_pays = " . $this->pays_id;
|
||||||
$sql .= " WHERE rowid = " . $id;
|
$sql .= " WHERE rowid = " . $id;
|
||||||
|
|
||||||
if ( $this->db->query($sql) )
|
$this->db->begin();
|
||||||
|
|
||||||
|
dol_syslog("Entrepot::update sql=".$sql);
|
||||||
|
$resql=$this->db->query($sql);
|
||||||
|
if ($resql)
|
||||||
{
|
{
|
||||||
|
$this->db->commit();
|
||||||
return 1;
|
return 1;
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
$this->error=$this->db->error()." sql=$sql";;
|
$this->db->rollback();
|
||||||
dol_syslog("Entrepot::Update return -1");
|
$this->error=$this->db->lasterror();
|
||||||
dol_syslog("Entrepot::Update ".$this->error, LOG_ERR);
|
dol_syslog("Entrepot::update ".$this->error, LOG_ERR);
|
||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* \brief Recup<EFBFBD>eration de la base d'un entrepot
|
* \brief Delete a warehouse
|
||||||
* \param id id de l'entrepot a r<EFBFBD>cup<EFBFBD>rer
|
* \param user
|
||||||
|
* \return int <0 if KO, >0 if OK
|
||||||
*/
|
*/
|
||||||
function fetch ($id)
|
function delete($user)
|
||||||
|
{
|
||||||
|
|
||||||
|
$this->db->begin();
|
||||||
|
|
||||||
|
$sql = "DELETE FROM ".MAIN_DB_PREFIX."stock_mouvement";
|
||||||
|
$sql.= " WHERE fk_entrepot = " . $this->id;
|
||||||
|
dol_syslog("Entrepot::delete sql=".$sql);
|
||||||
|
$resql1=$this->db->query($sql);
|
||||||
|
|
||||||
|
$sql = "DELETE FROM ".MAIN_DB_PREFIX."product_stock";
|
||||||
|
$sql.= " WHERE fk_entrepot = " . $this->id;
|
||||||
|
dol_syslog("Entrepot::delete sql=".$sql);
|
||||||
|
$resql2=$this->db->query($sql);
|
||||||
|
|
||||||
|
if ($resql1 && $resql2)
|
||||||
|
{
|
||||||
|
$sql = "DELETE FROM ".MAIN_DB_PREFIX."entrepot";
|
||||||
|
$sql.= " WHERE rowid = " . $this->id;
|
||||||
|
|
||||||
|
dol_syslog("Entrepot::delete sql=".$sql);
|
||||||
|
$resql=$this->db->query($sql);
|
||||||
|
if ($resql)
|
||||||
|
{
|
||||||
|
$this->db->commit();
|
||||||
|
return 1;
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
$this->db->rollback();
|
||||||
|
$this->error=$this->db->lasterror();
|
||||||
|
dol_syslog("Entrepot::delete ".$this->error, LOG_ERR);
|
||||||
|
return -1;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
$this->db->rollback();
|
||||||
|
$this->error=$this->db->lasterror();
|
||||||
|
dol_syslog("Entrepot::delete ".$this->error, LOG_ERR);
|
||||||
|
return -1;
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
* \brief Recuperation de la base d'un entrepot
|
||||||
|
* \param id id de l'entrepot a recuperer
|
||||||
|
*/
|
||||||
|
function fetch($id)
|
||||||
{
|
{
|
||||||
$sql = "SELECT rowid, label, description, statut, lieu, address, cp, ville, fk_pays";
|
$sql = "SELECT rowid, label, description, statut, lieu, address, cp, ville, fk_pays";
|
||||||
$sql .= " FROM ".MAIN_DB_PREFIX."entrepot";
|
$sql .= " FROM ".MAIN_DB_PREFIX."entrepot";
|
||||||
$sql .= " WHERE rowid = $id";
|
$sql .= " WHERE rowid = ".$id;
|
||||||
|
|
||||||
|
dol_syslog("Entrepot::fetch sql=".$sql);
|
||||||
$result = $this->db->query($sql);
|
$result = $this->db->query($sql);
|
||||||
if ($result)
|
if ($result)
|
||||||
{
|
{
|
||||||
|
|||||||
@ -49,7 +49,7 @@ $mesg = '';
|
|||||||
*/
|
*/
|
||||||
|
|
||||||
// Ajout entrepot
|
// Ajout entrepot
|
||||||
if ($_POST["action"] == 'add')
|
if ($_POST["action"] == 'add' && $user->rights->stock->creer)
|
||||||
{
|
{
|
||||||
$entrepot = new Entrepot($db);
|
$entrepot = new Entrepot($db);
|
||||||
|
|
||||||
@ -65,8 +65,10 @@ if ($_POST["action"] == 'add')
|
|||||||
|
|
||||||
if ($entrepot->libelle) {
|
if ($entrepot->libelle) {
|
||||||
$id = $entrepot->create($user);
|
$id = $entrepot->create($user);
|
||||||
if ($id > 0) {
|
if ($id > 0)
|
||||||
Header("Location: fiche.php?id=$id");
|
{
|
||||||
|
header("Location: fiche.php?id=".$id);
|
||||||
|
exit;
|
||||||
}
|
}
|
||||||
|
|
||||||
$_GET["action"] = 'create';
|
$_GET["action"] = 'create';
|
||||||
@ -78,6 +80,24 @@ if ($_POST["action"] == 'add')
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Delete warehouse
|
||||||
|
if ($_REQUEST["action"] == 'confirm_delete' && $_REQUEST["confirm"] == 'yes' && $user->rights->stock->supprimer)
|
||||||
|
{
|
||||||
|
$entrepot = new Entrepot($db);
|
||||||
|
$entrepot->fetch($_REQUEST["id"]);
|
||||||
|
$result=$entrepot->delete($user);
|
||||||
|
if ($result > 0)
|
||||||
|
{
|
||||||
|
header("Location: ".DOL_URL_ROOT.'/product/stock/liste.php');
|
||||||
|
exit;
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
$mesg='<div class="error">'.$entrepot->error.'</div>';
|
||||||
|
$_REQUEST['action']='';
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
// Modification entrepot
|
// Modification entrepot
|
||||||
if ($_POST["action"] == 'update' && $_POST["cancel"] <> $langs->trans("Cancel"))
|
if ($_POST["action"] == 'update' && $_POST["cancel"] <> $langs->trans("Cancel"))
|
||||||
{
|
{
|
||||||
@ -214,6 +234,13 @@ else
|
|||||||
|
|
||||||
dol_fiche_head($head, 'card', $langs->trans("Warehouse"), 0, 'stock');
|
dol_fiche_head($head, 'card', $langs->trans("Warehouse"), 0, 'stock');
|
||||||
|
|
||||||
|
// Confirm delete third party
|
||||||
|
if ($_GET["action"] == 'delete')
|
||||||
|
{
|
||||||
|
$html = new Form($db);
|
||||||
|
$ret=$html->form_confirm($_SERVER["PHP_SELF"]."?id=".$entrepot->id,$langs->trans("DeleteAWarehouse"),$langs->trans("ConfirmDeleteWarehouse",$entrepot->libelle),"confirm_delete",'',0,2);
|
||||||
|
if ($ret == 'html') print '<br>';
|
||||||
|
}
|
||||||
|
|
||||||
print '<table class="border" width="100%">';
|
print '<table class="border" width="100%">';
|
||||||
|
|
||||||
|
|||||||
@ -962,7 +962,7 @@ else
|
|||||||
if ($_GET["action"] == 'delete')
|
if ($_GET["action"] == 'delete')
|
||||||
{
|
{
|
||||||
$html = new Form($db);
|
$html = new Form($db);
|
||||||
$ret=$html->form_confirm("soc.php?socid=".$soc->id,$langs->trans("DeleteACompany"),$langs->trans("ConfirmDeleteCompany"),"confirm_delete",'',0,2);
|
$ret=$html->form_confirm($_SERVER["PHP_SELF"]."?socid=".$soc->id,$langs->trans("DeleteACompany"),$langs->trans("ConfirmDeleteCompany"),"confirm_delete",'',0,2);
|
||||||
if ($ret == 'html') print '<br>';
|
if ($ret == 'html') print '<br>';
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user