Qual: On supprime la methode de cration des contrats depuis une facture car cette option avait t conserve pour un besoin perso et elle peut se raliser maintenant avec le nouveau mcanisme des triggers.
This commit is contained in:
parent
bb6209d3cb
commit
b40cde5ab5
@ -267,59 +267,6 @@ class Contrat
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* \brief Crée autant de contrats que de lignes de facture, pour une facture donnée
|
||||
* \param factureid id de la facture
|
||||
* \param user utilisateur qui crée
|
||||
* \param socid id société
|
||||
*/
|
||||
function create_from_facture($factureid, $user, $socid)
|
||||
{
|
||||
$sql = "SELECT p.rowid as rowid, fd.rowid as fdrowid FROM ".MAIN_DB_PREFIX."product as p, ".MAIN_DB_PREFIX."facturedet as fd";
|
||||
$sql .= " WHERE p.rowid = fd.fk_product AND p.fk_product_type = 1 AND fd.fk_facture = ".$factureid;
|
||||
|
||||
if ($this->db->query($sql))
|
||||
{
|
||||
$num = $this->db->num_rows();
|
||||
|
||||
if ($num > 0)
|
||||
{
|
||||
$i = 0;
|
||||
|
||||
while ($i < $num)
|
||||
{
|
||||
$objp = $this->db->fetch_object();
|
||||
$prowid[$i] = $objp->rowid;
|
||||
$fdrowid[$i] = $objp->fdrowid;
|
||||
$i++;
|
||||
}
|
||||
|
||||
$this->db->free();
|
||||
while (list($i, $value) = each ($prowid))
|
||||
{
|
||||
$sql = "INSERT INTO ".MAIN_DB_PREFIX."contrat (fk_product, fk_facture, fk_facturedet, fk_soc, fk_user_author)";
|
||||
$sql .= " VALUES (".$prowid[$i].", $factureid, ".$fdrowid[$i].", $socid, $user->id)";
|
||||
if (! $this->db->query($sql))
|
||||
{
|
||||
dolibarr_syslog("Contrat::create_from_facture - 10");
|
||||
dolibarr_print_error($this->db,"Contrat::create_from_facture - 10");
|
||||
}
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
$this->db->free();
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
dolibarr_syslog("Contrat::create_from_facture - 20");
|
||||
dolibarr_print_error($this->db,"Contrat::create_from_facture - 20");
|
||||
}
|
||||
|
||||
return $result;
|
||||
}
|
||||
|
||||
/**
|
||||
* \brief Ajoute une ligne de commande
|
||||
* \return int <0 si KO, =0 si OK
|
||||
|
||||
File diff suppressed because it is too large
Load Diff
@ -43,17 +43,17 @@ class Interfaces
|
||||
function Interfaces($DB)
|
||||
{
|
||||
$this->db = $DB ;
|
||||
$this->dir = DOL_DOCUMENT_ROOT . "/includes/triggers";
|
||||
$this->dir = DOL_DOCUMENT_ROOT . "/includes/triggers";
|
||||
}
|
||||
|
||||
/**
|
||||
* \brief Fonction appelée lors du déclenchement d'un évènement Dolibarr.
|
||||
* \brief Fonction appelée lors du déclenchement d'un évènement Dolibarr.
|
||||
* Cette fonction déclenche tous les triggers trouvés
|
||||
* \param action Code de l'evenement
|
||||
* \param object Objet concern
|
||||
* \param user Objet user
|
||||
* \param lang Objet lang
|
||||
* \param conf Objet conf
|
||||
* \param conf Objet conf
|
||||
* \return int Nbre de triggers déclenchés si pas d'erreurs. Nb en erreur sinon.
|
||||
*/
|
||||
function run_triggers($action,$object,$user,$lang,$conf)
|
||||
@ -62,7 +62,7 @@ class Interfaces
|
||||
$handle=opendir($this->dir);
|
||||
$modules = array();
|
||||
$nbok = $nbko = 0;
|
||||
|
||||
|
||||
while (($file = readdir($handle))!==false)
|
||||
{
|
||||
if (is_readable($this->dir."/".$file) && eregi('interface_(.*).class.php',$file,$reg))
|
||||
@ -72,23 +72,23 @@ class Interfaces
|
||||
if ($modName)
|
||||
{
|
||||
include_once($this->dir."/".$file);
|
||||
$objMod = new $modName($db);
|
||||
if ($objMod)
|
||||
{
|
||||
if ($objMod->run_trigger($action,$object,$user,$lang,$conf) > 0)
|
||||
{
|
||||
$nbok++;
|
||||
}
|
||||
else
|
||||
{
|
||||
$nbko++;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
if ($nbko) return $nbko;
|
||||
return $nbok;
|
||||
$objMod = new $modName($this->db);
|
||||
if ($objMod)
|
||||
{
|
||||
if ($objMod->run_trigger($action,$object,$user,$lang,$conf) > 0)
|
||||
{
|
||||
$nbok++;
|
||||
}
|
||||
else
|
||||
{
|
||||
$nbko++;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
if ($nbko) return $nbko;
|
||||
return $nbok;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
Loading…
Reference in New Issue
Block a user