Ajout triggers
This commit is contained in:
parent
d98db54c40
commit
34d8443372
@ -188,188 +188,189 @@ class Commande extends CommonObject
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
/** \brief Valide la commande
|
/**
|
||||||
* \param user Utilisateur qui valide
|
* \brief Valide la commande
|
||||||
* \return int <=0 si ko, >0 si ok
|
* \param user Utilisateur qui valide
|
||||||
*/
|
* \return int <=0 si ko, >0 si ok
|
||||||
function valid($user)
|
*/
|
||||||
{
|
function valid($user)
|
||||||
global $conf;
|
{
|
||||||
|
global $conf;
|
||||||
if ($user->rights->commande->valider)
|
|
||||||
{
|
if ($user->rights->commande->valider)
|
||||||
$this->db->begin();
|
{
|
||||||
|
$this->db->begin();
|
||||||
// Definition du nom de module de numerotation de commande
|
|
||||||
$soc = new Societe($this->db);
|
|
||||||
$soc->fetch($this->socid);
|
|
||||||
$num=$this->getNextNumRef($soc);
|
|
||||||
|
|
||||||
// Classe la société rattachée comme client
|
|
||||||
$result=$soc->set_as_client();
|
|
||||||
|
|
||||||
// on vérifie si la commande est en numérotation provisoire
|
|
||||||
$comref = substr($this->ref, 1, 4);
|
|
||||||
if ($comref == 'PROV')
|
|
||||||
{
|
|
||||||
$num = $this->getNextNumRef($soc);
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
$num = $this->ref;
|
|
||||||
}
|
|
||||||
|
|
||||||
$sql = 'UPDATE '.MAIN_DB_PREFIX."commande SET ref='$num', fk_statut = 1, date_valid=now(), fk_user_valid=$user->id";
|
|
||||||
$sql .= " WHERE rowid = $this->id AND fk_statut = 0";
|
|
||||||
|
|
||||||
$resql=$this->db->query($sql);
|
|
||||||
if ($resql)
|
|
||||||
{
|
|
||||||
// On efface le répertoire de pdf provisoire
|
|
||||||
$comref = sanitize_string($this->ref);
|
|
||||||
if ($conf->commande->dir_output)
|
|
||||||
{
|
|
||||||
$dir = $conf->commande->dir_output . "/" . $comref ;
|
|
||||||
$file = $conf->commande->dir_output . "/" . $comref . "/" . $comref . ".pdf";
|
|
||||||
if (file_exists($file))
|
|
||||||
{
|
|
||||||
commande_delete_preview($this->db, $this->id, $this->ref);
|
|
||||||
|
|
||||||
if (!dol_delete_file($file))
|
|
||||||
{
|
|
||||||
$this->error=$langs->trans("ErrorCanNotDeleteFile",$file);
|
|
||||||
$this->db->rollback();
|
|
||||||
return 0;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
if (file_exists($dir))
|
|
||||||
{
|
|
||||||
if (!dol_delete_dir($dir))
|
|
||||||
{
|
|
||||||
$this->error=$langs->trans("ErrorCanNotDeleteDir",$dir);
|
|
||||||
$this->db->rollback();
|
|
||||||
return 0;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
// Appel des triggers
|
|
||||||
include_once(DOL_DOCUMENT_ROOT . "/interfaces.class.php");
|
|
||||||
$interface=new Interfaces($this->db);
|
|
||||||
$result=$interface->run_triggers('ORDER_VALIDATE',$this,$user,$langs,$conf);
|
|
||||||
// Fin appel triggers
|
|
||||||
|
|
||||||
$this->db->commit();
|
|
||||||
return $this->id;
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
$this->db->rollback();
|
|
||||||
$this->error=$this->db->error();
|
|
||||||
return -1;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
$this->error='Autorisation insuffisante';
|
|
||||||
return -1;
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
// Definition du nom de module de numerotation de commande
|
||||||
|
$soc = new Societe($this->db);
|
||||||
|
$soc->fetch($this->socid);
|
||||||
|
$num=$this->getNextNumRef($soc);
|
||||||
|
|
||||||
|
// Classe la société rattachée comme client
|
||||||
|
$result=$soc->set_as_client();
|
||||||
|
|
||||||
|
// on vérifie si la commande est en numérotation provisoire
|
||||||
|
$comref = substr($this->ref, 1, 4);
|
||||||
|
if ($comref == 'PROV')
|
||||||
|
{
|
||||||
|
$num = $this->getNextNumRef($soc);
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
$num = $this->ref;
|
||||||
|
}
|
||||||
|
|
||||||
|
$sql = 'UPDATE '.MAIN_DB_PREFIX."commande SET ref='$num', fk_statut = 1, date_valid=now(), fk_user_valid=$user->id";
|
||||||
|
$sql .= " WHERE rowid = $this->id AND fk_statut = 0";
|
||||||
|
|
||||||
|
$resql=$this->db->query($sql);
|
||||||
|
if ($resql)
|
||||||
|
{
|
||||||
|
// On efface le répertoire de pdf provisoire
|
||||||
|
$comref = sanitize_string($this->ref);
|
||||||
|
if ($conf->commande->dir_output)
|
||||||
|
{
|
||||||
|
$dir = $conf->commande->dir_output . "/" . $comref ;
|
||||||
|
$file = $conf->commande->dir_output . "/" . $comref . "/" . $comref . ".pdf";
|
||||||
|
if (file_exists($file))
|
||||||
|
{
|
||||||
|
commande_delete_preview($this->db, $this->id, $this->ref);
|
||||||
|
|
||||||
|
if (!dol_delete_file($file))
|
||||||
|
{
|
||||||
|
$this->error=$langs->trans("ErrorCanNotDeleteFile",$file);
|
||||||
|
$this->db->rollback();
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
if (file_exists($dir))
|
||||||
|
{
|
||||||
|
if (!dol_delete_dir($dir))
|
||||||
|
{
|
||||||
|
$this->error=$langs->trans("ErrorCanNotDeleteDir",$dir);
|
||||||
|
$this->db->rollback();
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
// Appel des triggers
|
||||||
|
include_once(DOL_DOCUMENT_ROOT . "/interfaces.class.php");
|
||||||
|
$interface=new Interfaces($this->db);
|
||||||
|
$result=$interface->run_triggers('ORDER_VALIDATE',$this,$user,$langs,$conf);
|
||||||
|
// Fin appel triggers
|
||||||
|
|
||||||
|
$this->db->commit();
|
||||||
|
return $this->id;
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
$this->db->rollback();
|
||||||
|
$this->error=$this->db->error();
|
||||||
|
return -1;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
$this->error='Autorisation insuffisante';
|
||||||
|
return -1;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
*
|
*
|
||||||
*
|
*
|
||||||
*/
|
*/
|
||||||
function set_draft($userid)
|
function set_draft($userid)
|
||||||
{
|
{
|
||||||
$sql = "UPDATE ".MAIN_DB_PREFIX."commande SET fk_statut = 0";
|
$sql = "UPDATE ".MAIN_DB_PREFIX."commande SET fk_statut = 0";
|
||||||
|
|
||||||
$sql .= " WHERE rowid = $this->id;";
|
$sql .= " WHERE rowid = $this->id;";
|
||||||
|
|
||||||
if ($this->db->query($sql) )
|
if ($this->db->query($sql) )
|
||||||
{
|
{
|
||||||
return 1;
|
return 1;
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
dolibarr_print_error($this->db);
|
dolibarr_print_error($this->db);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* \brief Cloture la commande
|
* \brief Cloture la commande
|
||||||
* \param user Objet utilisateur qui cloture
|
* \param user Objet utilisateur qui cloture
|
||||||
* \return int <0 si ko, >0 si ok
|
* \return int <0 si ko, >0 si ok
|
||||||
*/
|
*/
|
||||||
function cloture($user)
|
function cloture($user)
|
||||||
{
|
{
|
||||||
global $conf;
|
global $conf;
|
||||||
if ($user->rights->commande->valider)
|
if ($user->rights->commande->valider)
|
||||||
{
|
{
|
||||||
$sql = 'UPDATE '.MAIN_DB_PREFIX.'commande';
|
$sql = 'UPDATE '.MAIN_DB_PREFIX.'commande';
|
||||||
$sql.= ' SET fk_statut = 3,';
|
$sql.= ' SET fk_statut = 3,';
|
||||||
$sql.= ' fk_user_cloture = '.$user->id.',';
|
$sql.= ' fk_user_cloture = '.$user->id.',';
|
||||||
$sql.= ' date_cloture = now()';
|
$sql.= ' date_cloture = now()';
|
||||||
$sql.= " WHERE rowid = $this->id AND fk_statut > 0 ;";
|
$sql.= " WHERE rowid = $this->id AND fk_statut > 0 ;";
|
||||||
|
|
||||||
if ($this->db->query($sql) )
|
if ($this->db->query($sql) )
|
||||||
{
|
{
|
||||||
if($conf->stock->enabled && $conf->global->PRODUIT_SOUSPRODUITS == 1)
|
if($conf->stock->enabled && $conf->global->PRODUIT_SOUSPRODUITS == 1)
|
||||||
{
|
{
|
||||||
require_once(DOL_DOCUMENT_ROOT."/product/stock/mouvementstock.class.php");
|
require_once(DOL_DOCUMENT_ROOT."/product/stock/mouvementstock.class.php");
|
||||||
for ($i = 0 ; $i < sizeof($this->lignes) ; $i++)
|
for ($i = 0 ; $i < sizeof($this->lignes) ; $i++)
|
||||||
{
|
{
|
||||||
$prod = new Product($this->db, $this->lignes[$i]->fk_product);
|
$prod = new Product($this->db, $this->lignes[$i]->fk_product);
|
||||||
$prod -> get_sousproduits_arbo ();
|
$prod -> get_sousproduits_arbo ();
|
||||||
$prods_arbo = $prod->get_each_prod();
|
$prods_arbo = $prod->get_each_prod();
|
||||||
if(sizeof($prods_arbo) > 0)
|
if(sizeof($prods_arbo) > 0)
|
||||||
{
|
{
|
||||||
foreach($prods_arbo as $key => $value)
|
foreach($prods_arbo as $key => $value)
|
||||||
{
|
{
|
||||||
// on décompte le stock de tous les sousproduits
|
// on décompte le stock de tous les sousproduits
|
||||||
$mouvS = new MouvementStock($this->db);
|
$mouvS = new MouvementStock($this->db);
|
||||||
$entrepot_id = "1";
|
$entrepot_id = "1";
|
||||||
$result=$mouvS->livraison($user, $value[1], $entrepot_id, $value[0]);
|
$result=$mouvS->livraison($user, $value[1], $entrepot_id, $value[0]);
|
||||||
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
// on décompte pas le stock du produit principal, ça serait fait manuellement avec l'expédition
|
// on décompte pas le stock du produit principal, ça serait fait manuellement avec l'expédition
|
||||||
// $result=$mouvS->livraison($user, $this->lignes[$i]->fk_product, $entrepot_id, $this->lignes[$i]->qty);
|
// $result=$mouvS->livraison($user, $this->lignes[$i]->fk_product, $entrepot_id, $this->lignes[$i]->qty);
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
return 1;
|
return 1;
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
dolibarr_print_error($this->db);
|
dolibarr_print_error($this->db);
|
||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
/**
|
/**
|
||||||
* Annule la commande
|
* Annule la commande
|
||||||
*
|
*
|
||||||
*/
|
*/
|
||||||
function cancel($user)
|
function cancel($user)
|
||||||
{
|
{
|
||||||
if ($user->rights->commande->valider)
|
if ($user->rights->commande->valider)
|
||||||
{
|
{
|
||||||
$sql = 'UPDATE '.MAIN_DB_PREFIX.'commande SET fk_statut = -1';
|
$sql = 'UPDATE '.MAIN_DB_PREFIX.'commande SET fk_statut = -1';
|
||||||
$sql .= " WHERE rowid = $this->id AND fk_statut = 1 ;";
|
$sql .= " WHERE rowid = $this->id AND fk_statut = 1 ;";
|
||||||
|
|
||||||
if ($this->db->query($sql) )
|
if ($this->db->query($sql) )
|
||||||
{
|
{
|
||||||
return 1;
|
return 1;
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
dolibarr_print_error($this->db);
|
dolibarr_print_error($this->db);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* \brief Créé la commande
|
* \brief Créé la commande
|
||||||
* \param user Objet utilisateur qui crée
|
* \param user Objet utilisateur qui crée
|
||||||
*/
|
*/
|
||||||
function create($user)
|
function create($user)
|
||||||
{
|
{
|
||||||
@ -421,88 +422,88 @@ class Commande extends CommonObject
|
|||||||
if ($resql)
|
if ($resql)
|
||||||
{
|
{
|
||||||
$this->id = $this->db->last_insert_id(MAIN_DB_PREFIX.'commande');
|
$this->id = $this->db->last_insert_id(MAIN_DB_PREFIX.'commande');
|
||||||
|
|
||||||
if ($this->id)
|
if ($this->id)
|
||||||
{
|
{
|
||||||
/*
|
/*
|
||||||
* Insertion du detail des produits dans la base
|
* Insertion du detail des produits dans la base
|
||||||
*/
|
*/
|
||||||
for ($i = 0 ; $i < sizeof($this->lines) ; $i++)
|
for ($i = 0 ; $i < sizeof($this->lines) ; $i++)
|
||||||
{
|
{
|
||||||
$resql = $this->addline(
|
$resql = $this->addline(
|
||||||
$this->id,
|
$this->id,
|
||||||
$this->lines[$i]->desc,
|
$this->lines[$i]->desc,
|
||||||
$this->lines[$i]->subprice,
|
$this->lines[$i]->subprice,
|
||||||
$this->lines[$i]->qty,
|
$this->lines[$i]->qty,
|
||||||
$this->lines[$i]->tva_tx,
|
$this->lines[$i]->tva_tx,
|
||||||
$this->lines[$i]->fk_product,
|
$this->lines[$i]->fk_product,
|
||||||
$this->lines[$i]->remise_percent
|
$this->lines[$i]->remise_percent
|
||||||
);
|
);
|
||||||
|
|
||||||
if ($resql < 0)
|
if ($resql < 0)
|
||||||
{
|
{
|
||||||
$this->error=$this->db->error;
|
$this->error=$this->db->error;
|
||||||
dolibarr_print_error($this->db);
|
dolibarr_print_error($this->db);
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// Mise a jour ref
|
// Mise a jour ref
|
||||||
$sql = 'UPDATE '.MAIN_DB_PREFIX."commande SET ref='(PROV".$this->id.")' WHERE rowid=".$this->id;
|
$sql = 'UPDATE '.MAIN_DB_PREFIX."commande SET ref='(PROV".$this->id.")' WHERE rowid=".$this->id;
|
||||||
if ($this->db->query($sql))
|
if ($this->db->query($sql))
|
||||||
{
|
{
|
||||||
if ($this->id && $this->propale_id)
|
if ($this->id && $this->propale_id)
|
||||||
{
|
{
|
||||||
$sql = 'INSERT INTO '.MAIN_DB_PREFIX.'co_pr (fk_commande, fk_propale) VALUES ('.$this->id.','.$this->propale_id.')';
|
$sql = 'INSERT INTO '.MAIN_DB_PREFIX.'co_pr (fk_commande, fk_propale) VALUES ('.$this->id.','.$this->propale_id.')';
|
||||||
$this->db->query($sql);
|
$this->db->query($sql);
|
||||||
|
|
||||||
// On récupère les différents contact interne et externe
|
// On récupère les différents contact interne et externe
|
||||||
$prop = New Propal($this->db, $this->socid, $this->propale_id);
|
$prop = New Propal($this->db, $this->socid, $this->propale_id);
|
||||||
|
|
||||||
// On récupère le commercial suivi propale
|
// On récupère le commercial suivi propale
|
||||||
$this->userid = $prop->getIdcontact('internal', 'SALESREPFOLL');
|
$this->userid = $prop->getIdcontact('internal', 'SALESREPFOLL');
|
||||||
|
|
||||||
if ($this->userid)
|
if ($this->userid)
|
||||||
{
|
{
|
||||||
//On passe le commercial suivi propale en commercial suivi commande
|
//On passe le commercial suivi propale en commercial suivi commande
|
||||||
$this->add_contact($this->userid[0], 'SALESREPFOLL', 'internal');
|
$this->add_contact($this->userid[0], 'SALESREPFOLL', 'internal');
|
||||||
}
|
}
|
||||||
|
|
||||||
// On récupère le contact client suivi propale
|
// On récupère le contact client suivi propale
|
||||||
$this->contactid = $prop->getIdcontact('external', 'CUSTOMER');
|
$this->contactid = $prop->getIdcontact('external', 'CUSTOMER');
|
||||||
|
|
||||||
if ($this->contactid)
|
if ($this->contactid)
|
||||||
{
|
{
|
||||||
//On passe le contact client suivi propale en contact client suivi commande
|
//On passe le contact client suivi propale en contact client suivi commande
|
||||||
$this->add_contact($this->contactid[0], 'CUSTOMER', 'external');
|
$this->add_contact($this->contactid[0], 'CUSTOMER', 'external');
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// Appel des triggers
|
// Appel des triggers
|
||||||
include_once(DOL_DOCUMENT_ROOT . "/interfaces.class.php");
|
include_once(DOL_DOCUMENT_ROOT . "/interfaces.class.php");
|
||||||
$interface=new Interfaces($this->db);
|
$interface=new Interfaces($this->db);
|
||||||
$result=$interface->run_triggers('ORDER_CREATE',$this,$user,$langs,$conf);
|
$result=$interface->run_triggers('ORDER_CREATE',$this,$user,$langs,$conf);
|
||||||
// Fin appel triggers
|
// Fin appel triggers
|
||||||
|
|
||||||
$this->db->commit();
|
$this->db->commit();
|
||||||
return $this->id;
|
return $this->id;
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
$this->db->rollback();
|
$this->db->rollback();
|
||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
dolibarr_print_error($this->db);
|
dolibarr_print_error($this->db);
|
||||||
$this->db->rollback();
|
$this->db->rollback();
|
||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* \brief Ajout d'un produit dans la commande, en base
|
* \brief Ajout d'un produit dans la commande, en base
|
||||||
* \param commandeid id de la commande
|
* \param commandeid id de la commande
|
||||||
@ -1181,9 +1182,10 @@ 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
|
||||||
$this->update_price();
|
$result = $Ligne->Delete();
|
||||||
return 1;
|
|
||||||
}
|
$this->update_price();
|
||||||
else
|
|
||||||
{
|
return $result;
|
||||||
return -1;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -2092,9 +2092,9 @@ 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
|
||||||
{
|
{
|
||||||
@ -2173,9 +2173,9 @@ class CommandeLigne
|
|||||||
$this->coef = $objp->coef;
|
$this->coef = $objp->coef;
|
||||||
$this->rang = $objp->rang;
|
$this->rang = $objp->rang;
|
||||||
|
|
||||||
$this->ref = $objp->product_ref;
|
$this->ref = $objp->product_ref;
|
||||||
$this->product_libelle= $objp->product_libelle;
|
$this->product_libelle = $objp->product_libelle;
|
||||||
$this->product_desc = $objp->product_desc;
|
$this->product_desc = $objp->product_desc;
|
||||||
|
|
||||||
$this->db->free($result);
|
$this->db->free($result);
|
||||||
}
|
}
|
||||||
@ -2184,13 +2184,42 @@ class CommandeLigne
|
|||||||
dolibarr_print_error($this->db);
|
dolibarr_print_error($this->db);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* \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