FIX: expedition: reset status on rollback + replace hardcoded status with const
This commit is contained in:
parent
dbf7ae4c25
commit
64739098ae
@ -538,7 +538,7 @@ class Expedition extends CommonObject
|
|||||||
|
|
||||||
$this->db->free($result);
|
$this->db->free($result);
|
||||||
|
|
||||||
if ($this->statut == 0) $this->brouillon = 1;
|
if ($this->statut == self::STATUS_DRAFT) $this->brouillon = 1;
|
||||||
|
|
||||||
// Tracking url
|
// Tracking url
|
||||||
$this->GetUrlTrackingStatus($obj->tracking_number);
|
$this->GetUrlTrackingStatus($obj->tracking_number);
|
||||||
@ -783,7 +783,7 @@ class Expedition extends CommonObject
|
|||||||
if (! $error)
|
if (! $error)
|
||||||
{
|
{
|
||||||
$this->ref = $numref;
|
$this->ref = $numref;
|
||||||
$this->statut = 1;
|
$this->statut = self::STATUS_VALIDATED;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (! $error)
|
if (! $error)
|
||||||
@ -816,7 +816,7 @@ class Expedition extends CommonObject
|
|||||||
|
|
||||||
if ($conf->livraison_bon->enabled)
|
if ($conf->livraison_bon->enabled)
|
||||||
{
|
{
|
||||||
if ($this->statut == 1 || $this->statut == 2)
|
if ($this->statut == self::STATUS_VALIDATED || $this->statut == self::STATUS_CLOSED)
|
||||||
{
|
{
|
||||||
// Expedition validee
|
// Expedition validee
|
||||||
include_once DOL_DOCUMENT_ROOT.'/livraison/class/livraison.class.php';
|
include_once DOL_DOCUMENT_ROOT.'/livraison/class/livraison.class.php';
|
||||||
@ -1111,7 +1111,7 @@ class Expedition extends CommonObject
|
|||||||
|
|
||||||
$this->db->begin();
|
$this->db->begin();
|
||||||
// Stock control
|
// Stock control
|
||||||
if ($conf->stock->enabled && $conf->global->STOCK_CALCULATE_ON_SHIPMENT && $this->statut > 0)
|
if ($conf->stock->enabled && $conf->global->STOCK_CALCULATE_ON_SHIPMENT && $this->statut > self::STATUS_DRAFT)
|
||||||
{
|
{
|
||||||
require_once(DOL_DOCUMENT_ROOT."/product/stock/class/mouvementstock.class.php");
|
require_once(DOL_DOCUMENT_ROOT."/product/stock/class/mouvementstock.class.php");
|
||||||
|
|
||||||
@ -1663,7 +1663,7 @@ class Expedition extends CommonObject
|
|||||||
$this->id=0;
|
$this->id=0;
|
||||||
$this->ref = 'SPECIMEN';
|
$this->ref = 'SPECIMEN';
|
||||||
$this->specimen=1;
|
$this->specimen=1;
|
||||||
$this->statut = 1;
|
$this->statut = self::STATUS_VALIDATED;
|
||||||
$this->livraison_id = 0;
|
$this->livraison_id = 0;
|
||||||
$this->date = $now;
|
$this->date = $now;
|
||||||
$this->date_creation = $now;
|
$this->date_creation = $now;
|
||||||
@ -2037,6 +2037,7 @@ class Expedition extends CommonObject
|
|||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
|
$this->statut = self::STATUS_VALIDATED;
|
||||||
$this->db->rollback();
|
$this->db->rollback();
|
||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
@ -2060,7 +2061,7 @@ class Expedition extends CommonObject
|
|||||||
$resql=$this->db->query($sql);
|
$resql=$this->db->query($sql);
|
||||||
if ($resql)
|
if ($resql)
|
||||||
{
|
{
|
||||||
$this->statut=2;
|
$this->statut=self::STATUS_CLOSED;
|
||||||
$this->billed=1;
|
$this->billed=1;
|
||||||
|
|
||||||
// Call trigger
|
// Call trigger
|
||||||
@ -2080,6 +2081,8 @@ class Expedition extends CommonObject
|
|||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
|
$this->statut=self::STATUS_VALIDATED;
|
||||||
|
$this->billed=0;
|
||||||
$this->db->rollback();
|
$this->db->rollback();
|
||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
@ -2104,13 +2107,15 @@ class Expedition extends CommonObject
|
|||||||
|
|
||||||
$this->db->begin();
|
$this->db->begin();
|
||||||
|
|
||||||
|
$oldbilled=$this->billed;
|
||||||
|
|
||||||
$sql = 'UPDATE '.MAIN_DB_PREFIX.'expedition SET fk_statut=1';
|
$sql = 'UPDATE '.MAIN_DB_PREFIX.'expedition SET fk_statut=1';
|
||||||
$sql .= ' WHERE rowid = '.$this->id.' AND fk_statut > 0';
|
$sql .= ' WHERE rowid = '.$this->id.' AND fk_statut > 0';
|
||||||
|
|
||||||
$resql=$this->db->query($sql);
|
$resql=$this->db->query($sql);
|
||||||
if ($resql)
|
if ($resql)
|
||||||
{
|
{
|
||||||
$this->statut=1;
|
$this->statut=self::STATUS_VALIDATED;
|
||||||
$this->billed=0;
|
$this->billed=0;
|
||||||
|
|
||||||
// If stock increment is done on closing
|
// If stock increment is done on closing
|
||||||
@ -2208,6 +2213,8 @@ class Expedition extends CommonObject
|
|||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
|
$this->statut=self::STATUS_CLOSED;
|
||||||
|
$this->billed=$oldbilled;
|
||||||
$this->db->rollback();
|
$this->db->rollback();
|
||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user