Fix: Change status of order to cancel
This commit is contained in:
parent
0fbe769a7f
commit
f83954daef
@ -71,7 +71,6 @@ class Mailing extends CommonObject
|
||||
function Mailing($DB)
|
||||
{
|
||||
$this->db = $DB ;
|
||||
$this->db_table = MAIN_DB_PREFIX."mailing";
|
||||
|
||||
// List of language codes for status
|
||||
$this->statuts[0] = 'MailingStatusDraft';
|
||||
@ -100,7 +99,7 @@ class Mailing extends CommonObject
|
||||
return -1;
|
||||
}
|
||||
|
||||
$sql = "INSERT INTO ".$this->db_table;
|
||||
$sql = "INSERT INTO ".MAIN_DB_PREFIX."mailing";
|
||||
$sql .= " (date_creat, fk_user_creat, entity)";
|
||||
$sql .= " VALUES (".$this->db->idate(mktime()).", ".$user->id.", ".$conf->entity.")";
|
||||
|
||||
@ -113,7 +112,7 @@ class Mailing extends CommonObject
|
||||
$result=$this->db->query($sql);
|
||||
if ($result)
|
||||
{
|
||||
$this->id = $this->db->last_insert_id($this->db_table);
|
||||
$this->id = $this->db->last_insert_id(MAIN_DB_PREFIX."mailing");
|
||||
|
||||
if ($this->update($user) > 0)
|
||||
{
|
||||
|
||||
@ -524,6 +524,8 @@ class Commande extends CommonObject
|
||||
{
|
||||
global $conf;
|
||||
|
||||
$error=0;
|
||||
|
||||
if ($user->rights->commande->valider)
|
||||
{
|
||||
$this->db->begin();
|
||||
@ -533,20 +535,26 @@ class Commande extends CommonObject
|
||||
$sql.= " WHERE rowid = ".$this->id;
|
||||
$sql.= " AND fk_statut = 1";
|
||||
|
||||
if ($this->db->query($sql) )
|
||||
dol_syslog("Commande::cancel sql=".$sql, LOG_DEBUG);
|
||||
if ($this->db->query($sql))
|
||||
{
|
||||
// If stock is decremented on validate order, we must reincrement it
|
||||
if($conf->stock->enabled && $conf->global->STOCK_CALCULATE_ON_VALIDATE_ORDER == 1)
|
||||
if ($conf->stock->enabled && $conf->global->STOCK_CALCULATE_ON_VALIDATE_ORDER == 1)
|
||||
{
|
||||
require_once(DOL_DOCUMENT_ROOT."/product/stock/class/mouvementstock.class.php");
|
||||
|
||||
$mouvP = new MouvementStock($this->db);
|
||||
// We increment stock of product (and sub-products)
|
||||
$entrepot_id = "1"; //Todo: ajouter possibilite de choisir l'entrepot
|
||||
$result=$mouvP->reception($user, $this->lignes[$i]->fk_product, $entrepot_id, $this->lignes[$i]->qty, $this->lignes[$i]->subprice);
|
||||
|
||||
if ($result > 0)
|
||||
if ($this->lignes[$i]->fk_product > 0 && $this->lignes[$i]->product_type == 0)
|
||||
{
|
||||
$mouvP = new MouvementStock($this->db);
|
||||
// We increment stock of product (and sub-products)
|
||||
$entrepot_id = "1"; //Todo: ajouter possibilite de choisir l'entrepot
|
||||
$result=$mouvP->reception($user, $this->lignes[$i]->fk_product, $entrepot_id, $this->lignes[$i]->qty, $this->lignes[$i]->subprice);
|
||||
if ($result < 0) { $error++; }
|
||||
}
|
||||
|
||||
if (! $error)
|
||||
{
|
||||
$this->statut=-1;
|
||||
$this->db->commit();
|
||||
return $result;
|
||||
}
|
||||
|
||||
@ -55,6 +55,8 @@ class MouvementStock
|
||||
$error = 0;
|
||||
dol_syslog("MouvementStock::_create start userid=$user->id, fk_product=$fk_product, warehouse=$entrepot_id, qty=$qty, type=$type, price=$price label=$label");
|
||||
|
||||
$now=dol_now();
|
||||
|
||||
$this->db->begin();
|
||||
|
||||
$product = new Product($this->db);
|
||||
@ -69,7 +71,7 @@ class MouvementStock
|
||||
{
|
||||
$sql = "INSERT INTO ".MAIN_DB_PREFIX."stock_mouvement";
|
||||
$sql.= " (datem, fk_product, fk_entrepot, value, type_mouvement, fk_user_author, label, price)";
|
||||
$sql.= " VALUES (".$this->db->idate(gmmktime()).", ".$fk_product.", ".$entrepot_id.", ".$qty.", ".$type.",";
|
||||
$sql.= " VALUES ('".$this->db->idate($now)."', ".$fk_product.", ".$entrepot_id.", ".$qty.", ".$type.",";
|
||||
$sql.= " ".$user->id.",";
|
||||
$sql.= " '".addslashes($label)."',";
|
||||
$sql.= " '".price2num($price)."')";
|
||||
@ -77,7 +79,7 @@ class MouvementStock
|
||||
dol_syslog("MouvementStock::_create sql=".$sql, LOG_DEBUG);
|
||||
if ($resql = $this->db->query($sql))
|
||||
{
|
||||
$mvid = $this->db->last_insert_id($resql);
|
||||
$mvid = $this->db->last_insert_id(MAIN_DB_PREFIX."stock_mouvement");
|
||||
}
|
||||
else
|
||||
{
|
||||
|
||||
@ -732,8 +732,7 @@ class User extends CommonObject
|
||||
dol_syslog("User::Create sql=".$sql, LOG_DEBUG);
|
||||
if ($result)
|
||||
{
|
||||
$table = "".MAIN_DB_PREFIX."user";
|
||||
$this->id = $this->db->last_insert_id($table);
|
||||
$this->id = $this->db->last_insert_id(MAIN_DB_PREFIX."user");
|
||||
|
||||
// Set default rights
|
||||
if ($this->set_default_rights() < 0)
|
||||
|
||||
Loading…
Reference in New Issue
Block a user