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
|
||||
with third party type.
|
||||
- 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 #27891
|
||||
- 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> ?
|
||||
CloneContentProduct=Clone all main informations of product/service
|
||||
ClonePricesProduct=Clone main informations and prices
|
||||
ProductIsUsed=This product is used
|
||||
@ -66,4 +66,6 @@ WarehousesAndProducts=Warehouses and products
|
||||
AverageUnitPricePMPShort=Average input price
|
||||
AverageUnitPricePMP=Average input price
|
||||
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> ?
|
||||
CloneContentProduct=Cloner les informations générales du produit/service uniquement
|
||||
ClonePricesProduct=Cloner les informations générales et les prix
|
||||
ProductIsUsed=Ce produit est utilisé
|
||||
@ -66,4 +66,6 @@ WarehousesAndProducts=Entrepôts et produits
|
||||
AverageUnitPricePMPShort=Prix moyen pondéré (PMP)
|
||||
AverageUnitPricePMP=Prix moyen pondéré (PMP) d'aquisition
|
||||
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
|
||||
* \param id id de l'entrepot <EFBFBD> modifier
|
||||
/**
|
||||
* \brief Update properties of a warehouse
|
||||
* \param id id of warehouse to modify
|
||||
* \param user
|
||||
*/
|
||||
function update($id, $user)
|
||||
@ -147,68 +147,125 @@ class Entrepot extends CommonObject
|
||||
$sql .= ",fk_pays = " . $this->pays_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)
|
||||
{
|
||||
return 1;
|
||||
$this->db->commit();
|
||||
return 1;
|
||||
}
|
||||
else
|
||||
{
|
||||
$this->error=$this->db->error()." sql=$sql";;
|
||||
dol_syslog("Entrepot::Update return -1");
|
||||
dol_syslog("Entrepot::Update ".$this->error, LOG_ERR);
|
||||
return -1;
|
||||
$this->db->rollback();
|
||||
$this->error=$this->db->lasterror();
|
||||
dol_syslog("Entrepot::update ".$this->error, LOG_ERR);
|
||||
return -1;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* \brief Recup<EFBFBD>eration de la base d'un entrepot
|
||||
* \param id id de l'entrepot a r<EFBFBD>cup<EFBFBD>rer
|
||||
* \brief Delete a warehouse
|
||||
* \param user
|
||||
* \return int <0 if KO, >0 if OK
|
||||
*/
|
||||
function fetch ($id)
|
||||
function delete($user)
|
||||
{
|
||||
$sql = "SELECT rowid, label, description, statut, lieu, address, cp, ville, fk_pays";
|
||||
$sql .= " FROM ".MAIN_DB_PREFIX."entrepot";
|
||||
$sql .= " WHERE rowid = $id";
|
||||
|
||||
$result = $this->db->query($sql);
|
||||
if ($result)
|
||||
$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)
|
||||
{
|
||||
$obj=$this->db->fetch_object($result);
|
||||
|
||||
$this->id = $obj->rowid;
|
||||
$this->ref = $obj->rowid;
|
||||
$this->libelle = $obj->label;
|
||||
$this->description = $obj->description;
|
||||
$this->statut = $obj->statut;
|
||||
$this->lieu = $obj->lieu;
|
||||
$this->address = $obj->address;
|
||||
$this->cp = $obj->cp;
|
||||
$this->ville = $obj->ville;
|
||||
$this->pays_id = $obj->fk_pays;
|
||||
|
||||
if ($this->pays_id)
|
||||
{
|
||||
$sqlp = "SELECT libelle from ".MAIN_DB_PREFIX."c_pays where rowid = ".$this->pays_id;
|
||||
$resql=$this->db->query($sqlp);
|
||||
if ($resql)
|
||||
{
|
||||
$objp = $this->db->fetch_object($resql);
|
||||
}
|
||||
else
|
||||
{
|
||||
dol_print_error($db);
|
||||
}
|
||||
$this->pays=$objp->libelle;
|
||||
}
|
||||
|
||||
$this->db->free($result);
|
||||
return 1;
|
||||
$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->error=$this->db->error();
|
||||
return -1;
|
||||
$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 .= " FROM ".MAIN_DB_PREFIX."entrepot";
|
||||
$sql .= " WHERE rowid = ".$id;
|
||||
|
||||
dol_syslog("Entrepot::fetch sql=".$sql);
|
||||
$result = $this->db->query($sql);
|
||||
if ($result)
|
||||
{
|
||||
$obj=$this->db->fetch_object($result);
|
||||
|
||||
$this->id = $obj->rowid;
|
||||
$this->ref = $obj->rowid;
|
||||
$this->libelle = $obj->label;
|
||||
$this->description = $obj->description;
|
||||
$this->statut = $obj->statut;
|
||||
$this->lieu = $obj->lieu;
|
||||
$this->address = $obj->address;
|
||||
$this->cp = $obj->cp;
|
||||
$this->ville = $obj->ville;
|
||||
$this->pays_id = $obj->fk_pays;
|
||||
|
||||
if ($this->pays_id)
|
||||
{
|
||||
$sqlp = "SELECT libelle from ".MAIN_DB_PREFIX."c_pays where rowid = ".$this->pays_id;
|
||||
$resql=$this->db->query($sqlp);
|
||||
if ($resql)
|
||||
{
|
||||
$objp = $this->db->fetch_object($resql);
|
||||
}
|
||||
else
|
||||
{
|
||||
dol_print_error($db);
|
||||
}
|
||||
$this->pays=$objp->libelle;
|
||||
}
|
||||
|
||||
$this->db->free($result);
|
||||
return 1;
|
||||
}
|
||||
else
|
||||
{
|
||||
$this->error=$this->db->error();
|
||||
return -1;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@ -49,7 +49,7 @@ $mesg = '';
|
||||
*/
|
||||
|
||||
// Ajout entrepot
|
||||
if ($_POST["action"] == 'add')
|
||||
if ($_POST["action"] == 'add' && $user->rights->stock->creer)
|
||||
{
|
||||
$entrepot = new Entrepot($db);
|
||||
|
||||
@ -65,8 +65,10 @@ if ($_POST["action"] == 'add')
|
||||
|
||||
if ($entrepot->libelle) {
|
||||
$id = $entrepot->create($user);
|
||||
if ($id > 0) {
|
||||
Header("Location: fiche.php?id=$id");
|
||||
if ($id > 0)
|
||||
{
|
||||
header("Location: fiche.php?id=".$id);
|
||||
exit;
|
||||
}
|
||||
|
||||
$_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
|
||||
if ($_POST["action"] == 'update' && $_POST["cancel"] <> $langs->trans("Cancel"))
|
||||
{
|
||||
@ -214,7 +234,14 @@ else
|
||||
|
||||
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%">';
|
||||
|
||||
// Ref
|
||||
|
||||
@ -962,7 +962,7 @@ else
|
||||
if ($_GET["action"] == 'delete')
|
||||
{
|
||||
$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>';
|
||||
}
|
||||
|
||||
|
||||
Loading…
Reference in New Issue
Block a user