Ajout triggers
This commit is contained in:
parent
d98db54c40
commit
34d8443372
@ -188,7 +188,8 @@ class Commande extends CommonObject
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
/** \brief Valide la commande
|
/**
|
||||||
|
* \brief Valide la commande
|
||||||
* \param user Utilisateur qui valide
|
* \param user Utilisateur qui valide
|
||||||
* \return int <=0 si ko, >0 si ok
|
* \return int <=0 si ko, >0 si ok
|
||||||
*/
|
*/
|
||||||
@ -1184,6 +1185,7 @@ class Commande extends CommonObject
|
|||||||
* \brief Supprime une ligne de la commande
|
* \brief Supprime une ligne de la commande
|
||||||
* \param idligne Id de la ligne à supprimer
|
* \param idligne Id de la ligne à supprimer
|
||||||
* \return int >0 si ok, <0 si ko
|
* \return int >0 si ok, <0 si ko
|
||||||
|
* \todo ajouter une transaction SQL
|
||||||
*/
|
*/
|
||||||
function delete_line($idligne)
|
function delete_line($idligne)
|
||||||
{
|
{
|
||||||
@ -1205,16 +1207,14 @@ class Commande extends CommonObject
|
|||||||
$this->db->free($result);
|
$this->db->free($result);
|
||||||
}
|
}
|
||||||
|
|
||||||
$sql = 'DELETE FROM '.MAIN_DB_PREFIX."commandedet WHERE rowid = '$idligne';";
|
$Ligne = new CommandeLigne($this->db);
|
||||||
if ($this->db->query($sql) )
|
$Ligne->id = $idligne;
|
||||||
{
|
$Ligne->fk_commande = $this->id; // On en a besoin dans les triggers
|
||||||
|
$result = $Ligne->Delete();
|
||||||
|
|
||||||
$this->update_price();
|
$this->update_price();
|
||||||
return 1;
|
|
||||||
}
|
return $result;
|
||||||
else
|
|
||||||
{
|
|
||||||
return -1;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -2092,8 +2092,8 @@ class Commande extends CommonObject
|
|||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
\class CommandeLigne
|
* \class CommandeLigne
|
||||||
\brief Classe de gestion des lignes de commande
|
* \brief Classe de gestion des lignes de commande
|
||||||
*/
|
*/
|
||||||
|
|
||||||
class CommandeLigne
|
class CommandeLigne
|
||||||
@ -2185,12 +2185,41 @@ class CommandeLigne
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* \brief Supprime la ligne de commande en base
|
||||||
|
* \return int <0 si ko, 0 si ok
|
||||||
|
*/
|
||||||
|
function Delete()
|
||||||
|
{
|
||||||
|
global $langs, $conf;
|
||||||
|
|
||||||
|
dolibarr_syslog("CommandeLigne::Delete id=".$this->id);
|
||||||
|
|
||||||
|
$sql = 'DELETE FROM '.MAIN_DB_PREFIX."commandedet WHERE rowid='".$this->id."';";
|
||||||
|
if ($this->db->query($sql) )
|
||||||
|
{
|
||||||
|
// Appel des triggers
|
||||||
|
include_once(DOL_DOCUMENT_ROOT . "/interfaces.class.php");
|
||||||
|
$interface=new Interfaces($this->db);
|
||||||
|
$result=$interface->run_triggers('LINEORDER_DELETE',$this,$user,$langs,$conf);
|
||||||
|
// Fin appel triggers
|
||||||
|
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
dolibarr_syslog("CommandeLigne::Delete id=".$this->id." ERROR SQL $sql");
|
||||||
|
return -1;
|
||||||
|
}
|
||||||
|
}
|
||||||
/**
|
/**
|
||||||
* \brief Insère l'objet ligne de commande en base
|
* \brief Insère l'objet ligne de commande en base
|
||||||
* \return int <0 si ko, >0 si ok
|
* \return int <0 si ko, >0 si ok
|
||||||
*/
|
*/
|
||||||
function insert()
|
function insert()
|
||||||
{
|
{
|
||||||
|
global $langs, $conf;
|
||||||
|
|
||||||
dolibarr_syslog("CommandeLigne.class::insert rang=".$this->rang);
|
dolibarr_syslog("CommandeLigne.class::insert rang=".$this->rang);
|
||||||
$this->db->begin();
|
$this->db->begin();
|
||||||
|
|
||||||
@ -2250,10 +2279,15 @@ class CommandeLigne
|
|||||||
$product->ajust_stock_commande($this->qty, 0);
|
$product->ajust_stock_commande($this->qty, 0);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
$resql=$this->db->query($sql);
|
$resql=$this->db->query($sql);
|
||||||
if ($resql)
|
if ($resql)
|
||||||
{
|
{
|
||||||
|
// Appel des triggers
|
||||||
|
include_once(DOL_DOCUMENT_ROOT . "/interfaces.class.php");
|
||||||
|
$interface=new Interfaces($this->db);
|
||||||
|
$result=$interface->run_triggers('LINEORDER_INSERT',$this,$user,$langs,$conf);
|
||||||
|
// Fin appel triggers
|
||||||
|
|
||||||
$this->db->commit();
|
$this->db->commit();
|
||||||
return 1;
|
return 1;
|
||||||
}
|
}
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user