Qual: Removed dead code
This commit is contained in:
parent
66a3a28eb2
commit
325b9c9688
@ -414,86 +414,6 @@ class CommandeFournisseur extends CommonOrder
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Set draft status
|
||||
* TODO This method seems to be never called.
|
||||
*
|
||||
* @param User $user Object user that modify
|
||||
* @param int $idwarehouse Id warehouse to use for stock change.
|
||||
* @return int <0 if KO, >0 if OK
|
||||
*/
|
||||
function set_draft($user, $idwarehouse=-1)
|
||||
{
|
||||
global $conf,$langs;
|
||||
|
||||
$error=0;
|
||||
|
||||
// Protection
|
||||
if ($this->statut == 0)
|
||||
{
|
||||
dol_syslog(get_class($this)."::set_draft already draft status", LOG_WARNING);
|
||||
return 0;
|
||||
}
|
||||
|
||||
if (! $user->rights->fournisseur->commande->valider)
|
||||
{
|
||||
$this->error='Permission denied';
|
||||
return -1;
|
||||
}
|
||||
|
||||
$this->db->begin();
|
||||
|
||||
$sql = "UPDATE ".MAIN_DB_PREFIX."commande_fournisseur";
|
||||
$sql.= " SET fk_statut = 0";
|
||||
$sql.= " WHERE rowid = ".$this->id;
|
||||
|
||||
dol_syslog(get_class($this)."::set_draft sql=".$sql, LOG_DEBUG);
|
||||
if ($this->db->query($sql))
|
||||
{
|
||||
// If stock is incremented on validate order, we must redecrement it
|
||||
if (! empty($conf->stock->enabled) && ! empty($conf->global->STOCK_CALCULATE_ON_SUPPLIER_VALIDATE_ORDER))
|
||||
{
|
||||
require_once DOL_DOCUMENT_ROOT.'/product/stock/class/mouvementstock.class.php';
|
||||
|
||||
$num=count($this->lines);
|
||||
for ($i = 0; $i < $num; $i++)
|
||||
{
|
||||
if ($this->lines[$i]->fk_product > 0)
|
||||
{
|
||||
$mouvP = new MouvementStock($this->db);
|
||||
// We increment stock of product (and sub-products)
|
||||
$result=$mouvP->reception($user, $this->lines[$i]->fk_product, $idwarehouse, $this->lines[$i]->qty, $this->lines[$i]->subprice, $langs->trans("OrderBackToDraftInDolibarr",$this->ref));
|
||||
if ($result < 0) { $error++; }
|
||||
}
|
||||
}
|
||||
|
||||
if (!$error)
|
||||
{
|
||||
$this->statut=0;
|
||||
$this->db->commit();
|
||||
return $result;
|
||||
}
|
||||
else
|
||||
{
|
||||
$this->error=$mouvP->error;
|
||||
$this->db->rollback();
|
||||
return $result;
|
||||
}
|
||||
}
|
||||
|
||||
$this->statut=0;
|
||||
$this->db->commit();
|
||||
return 1;
|
||||
}
|
||||
else
|
||||
{
|
||||
$this->error=$this->db->error();
|
||||
$this->db->rollback();
|
||||
dol_syslog($this->error, LOG_ERR);
|
||||
return -1;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Return label of the status of object
|
||||
*
|
||||
|
||||
Loading…
Reference in New Issue
Block a user