Fix: Reopen customer order is done to status 1
This commit is contained in:
parent
f791d145d6
commit
e91e2a3f5b
@ -55,7 +55,7 @@ class Commande extends CommonObject
|
|||||||
var $ref_client;
|
var $ref_client;
|
||||||
var $contactid;
|
var $contactid;
|
||||||
var $fk_project;
|
var $fk_project;
|
||||||
var $statut; // -1=Canceled, 0=Draft, 1=Validated, 2=Accepted/On process, 3=Closed (Sent/Recevied, billed or not)
|
var $statut; // -1=Canceled, 0=Draft, 1=Validated, (2=Accepted/On process not managed for customer orders), 3=Closed (Sent/Received, billed or not)
|
||||||
|
|
||||||
var $facturee; // Facturee ou non
|
var $facturee; // Facturee ou non
|
||||||
var $brouillon;
|
var $brouillon;
|
||||||
@ -386,58 +386,56 @@ class Commande extends CommonObject
|
|||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* \brief Tag the order as opened
|
* Tag the order as validated (opened)
|
||||||
* Function used when order is reopend after being closed.
|
* Function used when order is reopend after being closed.
|
||||||
* \param user Object user that change status
|
* @param user Object user that change status
|
||||||
* \return int <0 if KO, 0 if nothing is done, >0 if OK
|
* @return int <0 if KO, 0 if nothing is done, >0 if OK
|
||||||
*/
|
*/
|
||||||
function set_reopen($user)
|
function set_reopen($user)
|
||||||
{
|
{
|
||||||
global $conf,$langs;
|
global $conf,$langs;
|
||||||
$error=0;
|
$error=0;
|
||||||
|
|
||||||
if ($this->statut == 3)
|
if ($this->statut != 3)
|
||||||
{
|
{
|
||||||
$this->db->begin();
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
$sql = 'UPDATE '.MAIN_DB_PREFIX.'commande';
|
$this->db->begin();
|
||||||
$sql.= ' SET fk_statut=2, facture=0';
|
|
||||||
$sql.= ' WHERE rowid = '.$this->id;
|
|
||||||
|
|
||||||
dol_syslog("Commande::set_reopen sql=".$sql);
|
$sql = 'UPDATE '.MAIN_DB_PREFIX.'commande';
|
||||||
$resql = $this->db->query($sql);
|
$sql.= ' SET fk_statut=1, facture=0';
|
||||||
if ($resql)
|
$sql.= ' WHERE rowid = '.$this->id;
|
||||||
{
|
|
||||||
$this->use_webcal=($conf->global->PHPWEBCALENDAR_BILLSTATUS=='always'?1:0);
|
|
||||||
|
|
||||||
// Appel des triggers
|
dol_syslog("Commande::set_reopen sql=".$sql);
|
||||||
include_once(DOL_DOCUMENT_ROOT . "/core/class/interfaces.class.php");
|
$resql = $this->db->query($sql);
|
||||||
$interface=new Interfaces($this->db);
|
if ($resql)
|
||||||
$result=$interface->run_triggers('BILL_REOPEN',$this,$user,$langs,$conf);
|
{
|
||||||
if ($result < 0) { $error++; $this->errors=$interface->errors; }
|
$this->use_webcal=($conf->global->PHPWEBCALENDAR_BILLSTATUS=='always'?1:0);
|
||||||
// Fin appel triggers
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
$error++;
|
|
||||||
$this->error=$this->db->error();
|
|
||||||
dol_print_error($this->db);
|
|
||||||
}
|
|
||||||
|
|
||||||
if (! $error)
|
// Appel des triggers
|
||||||
{
|
include_once(DOL_DOCUMENT_ROOT . "/core/class/interfaces.class.php");
|
||||||
$this->db->commit();
|
$interface=new Interfaces($this->db);
|
||||||
return 1;
|
$result=$interface->run_triggers('BILL_REOPEN',$this,$user,$langs,$conf);
|
||||||
}
|
if ($result < 0) { $error++; $this->errors=$interface->errors; }
|
||||||
else
|
// Fin appel triggers
|
||||||
{
|
|
||||||
$this->db->rollback();
|
|
||||||
return -1;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
return 0;
|
$error++;
|
||||||
|
$this->error=$this->db->error();
|
||||||
|
dol_print_error($this->db);
|
||||||
|
}
|
||||||
|
|
||||||
|
if (! $error)
|
||||||
|
{
|
||||||
|
$this->db->commit();
|
||||||
|
return 1;
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
$this->db->rollback();
|
||||||
|
return -1;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -2404,7 +2402,7 @@ class Commande extends CommonObject
|
|||||||
function LibStatut($statut,$facturee,$mode)
|
function LibStatut($statut,$facturee,$mode)
|
||||||
{
|
{
|
||||||
global $langs;
|
global $langs;
|
||||||
|
print 'x'.$statut.'-'.$facturee;
|
||||||
if ($mode == 0)
|
if ($mode == 0)
|
||||||
{
|
{
|
||||||
if ($statut==-1) return $langs->trans('StatusOrderCanceled');
|
if ($statut==-1) return $langs->trans('StatusOrderCanceled');
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user