Fix: déplacement de la fonction fetch_adresse_livraison dans la partie commune
This commit is contained in:
parent
4505ad579c
commit
65a25a448b
@ -1163,20 +1163,7 @@ class Commande extends CommonObject
|
|||||||
if ($ligne->fk_product_type == 0) $nb++;
|
if ($ligne->fk_product_type == 0) $nb++;
|
||||||
}
|
}
|
||||||
return $nb;
|
return $nb;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
|
||||||
*
|
|
||||||
*
|
|
||||||
*/
|
|
||||||
function fetch_adresse_livraison($id)
|
|
||||||
{
|
|
||||||
$idadresse = $id;
|
|
||||||
$adresse = new Societe($this->db);
|
|
||||||
$adresse->fetch_adresse_livraison($idadresse);
|
|
||||||
$this->adresse = $adresse;
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* \brief Charge tableau avec les expéditions par ligne
|
* \brief Charge tableau avec les expéditions par ligne
|
||||||
@ -1303,8 +1290,8 @@ class Commande extends CommonObject
|
|||||||
{
|
{
|
||||||
if ($this->statut == 0)
|
if ($this->statut == 0)
|
||||||
{
|
{
|
||||||
$this->db->begin();
|
$this->db->begin();
|
||||||
|
|
||||||
$sql = "SELECT fk_product, qty";
|
$sql = "SELECT fk_product, qty";
|
||||||
$sql.= " FROM ".MAIN_DB_PREFIX."commandedet";
|
$sql.= " FROM ".MAIN_DB_PREFIX."commandedet";
|
||||||
$sql.= " WHERE rowid = '$idligne'";
|
$sql.= " WHERE rowid = '$idligne'";
|
||||||
@ -1313,59 +1300,59 @@ class Commande extends CommonObject
|
|||||||
if ($result)
|
if ($result)
|
||||||
{
|
{
|
||||||
$obj = $this->db->fetch_object($result);
|
$obj = $this->db->fetch_object($result);
|
||||||
|
|
||||||
if ($obj)
|
if ($obj)
|
||||||
{
|
{
|
||||||
$product = new Product($this->db);
|
$product = new Product($this->db);
|
||||||
$product->id = $obj->fk_product;
|
$product->id = $obj->fk_product;
|
||||||
|
|
||||||
$result=$product->ajust_stock_commande($obj->qty, 1);
|
$result=$product->ajust_stock_commande($obj->qty, 1);
|
||||||
|
|
||||||
// Supprime ligne
|
// Supprime ligne
|
||||||
$ligne = new CommandeLigne($this->db);
|
$ligne = new CommandeLigne($this->db);
|
||||||
$ligne->id = $idligne;
|
$ligne->id = $idligne;
|
||||||
$ligne->fk_commande = $this->id; // On en a besoin dans les triggers
|
$ligne->fk_commande = $this->id; // On en a besoin dans les triggers
|
||||||
$result=$ligne->delete();
|
$result=$ligne->delete();
|
||||||
|
|
||||||
if ($result > 0)
|
if ($result > 0)
|
||||||
{
|
{
|
||||||
$result=$this->update_price();
|
$result=$this->update_price();
|
||||||
|
|
||||||
if ($result > 0)
|
if ($result > 0)
|
||||||
{
|
{
|
||||||
$this->db->commit();
|
$this->db->commit();
|
||||||
return 1;
|
return 1;
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
$this->db->rollback();
|
$this->db->rollback();
|
||||||
$this->error=$this->db->lasterror();
|
$this->error=$this->db->lasterror();
|
||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
$this->db->rollback();
|
|
||||||
$this->error=$this->db->lasterror();
|
|
||||||
return -1;
|
|
||||||
}
|
}
|
||||||
}
|
else
|
||||||
else
|
{
|
||||||
{
|
$this->db->rollback();
|
||||||
$this->db->rollback();
|
$this->error=$this->db->lasterror();
|
||||||
return 0;
|
return -1;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
$this->db->rollback();
|
$this->db->rollback();
|
||||||
$this->error=$this->db->lasterror();
|
return 0;
|
||||||
return -1;
|
}
|
||||||
}
|
}
|
||||||
}
|
else
|
||||||
else
|
{
|
||||||
{
|
$this->db->rollback();
|
||||||
return -1;
|
$this->error=$this->db->lasterror();
|
||||||
|
return -1;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
return -1;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -1908,7 +1895,7 @@ class Commande extends CommonObject
|
|||||||
{
|
{
|
||||||
global $conf, $lang;
|
global $conf, $lang;
|
||||||
|
|
||||||
$err = 0;
|
$err = 0;
|
||||||
|
|
||||||
$this->db->begin();
|
$this->db->begin();
|
||||||
|
|
||||||
@ -2411,9 +2398,9 @@ class CommandeLigne
|
|||||||
global $langs, $conf, $user;
|
global $langs, $conf, $user;
|
||||||
|
|
||||||
$sql = 'DELETE FROM '.MAIN_DB_PREFIX."commandedet WHERE rowid='".$this->id."';";
|
$sql = 'DELETE FROM '.MAIN_DB_PREFIX."commandedet WHERE rowid='".$this->id."';";
|
||||||
|
|
||||||
dolibarr_syslog("CommandeLigne::delete sql=".$sql);
|
dolibarr_syslog("CommandeLigne::delete sql=".$sql);
|
||||||
$resql=$this->db->query($sql);
|
$resql=$this->db->query($sql);
|
||||||
if ($resql)
|
if ($resql)
|
||||||
{
|
{
|
||||||
// Appel des triggers
|
// Appel des triggers
|
||||||
@ -2425,7 +2412,7 @@ class CommandeLigne
|
|||||||
return 1;
|
return 1;
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
$this->error=$this->db->lasterror();
|
$this->error=$this->db->lasterror();
|
||||||
dolibarr_syslog("CommandeLigne::delete ".$this->error);
|
dolibarr_syslog("CommandeLigne::delete ".$this->error);
|
||||||
return -1;
|
return -1;
|
||||||
|
|||||||
@ -363,6 +363,17 @@ class CommonObject
|
|||||||
$user->fetch();
|
$user->fetch();
|
||||||
$this->user = $user;
|
$this->user = $user;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* \brief Charge l'adresse de livraison d'id $this->adresse_livraison_id dans this->adresse
|
||||||
|
* \param userid Id du contact
|
||||||
|
*/
|
||||||
|
function fetch_adresse_livraison($deliveryaddressid)
|
||||||
|
{
|
||||||
|
$address = new Societe($this->db);
|
||||||
|
$address->fetch_adresse_livraison($deliveryaddressid);
|
||||||
|
$this->deliveryaddress = $address;
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@ -427,20 +427,6 @@ class Propal extends CommonObject
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
/**
|
|
||||||
*
|
|
||||||
*
|
|
||||||
*/
|
|
||||||
function fetch_adresse_livraison($id)
|
|
||||||
{
|
|
||||||
$idadresse = $id;
|
|
||||||
$adresse = new Societe($this->db);
|
|
||||||
$adresse->fetch_adresse_livraison($idadresse);
|
|
||||||
$this->adresse = $adresse;
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* \brief Supprime une ligne de detail
|
* \brief Supprime une ligne de detail
|
||||||
* \param idligne Id de la ligne detail à supprimer
|
* \param idligne Id de la ligne detail à supprimer
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user