Works on module hook integration

This commit is contained in:
Regis Houssin 2010-09-11 11:54:59 +00:00
parent 618ffee73c
commit da5f21a732
4 changed files with 36 additions and 17 deletions

View File

@ -787,6 +787,8 @@ class Propal extends CommonObject
// Load source object // Load source object
$object->fetch($fromid); $object->fetch($fromid);
$objFrom = $object;
$object->id=0; $object->id=0;
$object->statut=0; $object->statut=0;
@ -833,7 +835,7 @@ class Propal extends CommonObject
{ {
foreach($object->hooks as $module) foreach($object->hooks as $module)
{ {
$result = $module->createFromClone($object); $result = $module->createfrom($objFrom,$result,$object->element);
if ($result < 0) $error++; if ($result < 0) $error++;
} }
} }

View File

@ -711,6 +711,8 @@ class Commande extends CommonObject
// Load source object // Load source object
$object->fetch($fromid); $object->fetch($fromid);
$objFrom = $object;
$object->id=0; $object->id=0;
$object->statut=0; $object->statut=0;
@ -738,7 +740,7 @@ class Commande extends CommonObject
{ {
foreach($object->hooks as $module) foreach($object->hooks as $module)
{ {
$result = $module->createFromClone($object); $result = $module->createfrom($objFrom,$result,$object->element);
if ($result < 0) $error++; if ($result < 0) $error++;
} }
} }

View File

@ -102,7 +102,6 @@ class Facture extends CommonObject
var $lignes=array(); // TODO deprecated var $lignes=array(); // TODO deprecated
var $lines=array(); var $lines=array();
var $line; var $line;
var $clone_fromid;
//! Pour board //! Pour board
var $nbtodo; var $nbtodo;
var $nbtodolate; var $nbtodolate;
@ -273,10 +272,10 @@ class Facture extends CommonObject
* Insert lines of invoices in database * Insert lines of invoices in database
*/ */
//dol_syslog("There is ".sizeof($this->lignes)." lines"); //dol_syslog("There is ".sizeof($this->lignes)." lines");
foreach ($this->lignes as $i => $val) foreach ($this->lines as $i => $val)
{ {
$newinvoiceline=new FactureLigne($this->db); $newinvoiceline=new FactureLigne($this->db);
$newinvoiceline=$this->lignes[$i]; $newinvoiceline=$this->lines[$i];
$newinvoiceline->fk_facture=$this->id; $newinvoiceline->fk_facture=$this->id;
if ($result >= 0 && ($newinvoiceline->info_bits & 0x01) == 0) // We keep only lines with first bit = 0 if ($result >= 0 && ($newinvoiceline->info_bits & 0x01) == 0) // We keep only lines with first bit = 0
{ {
@ -294,12 +293,12 @@ class Facture extends CommonObject
*/ */
if (! $error && $this->fac_rec > 0) if (! $error && $this->fac_rec > 0)
{ {
foreach ($_facrec->lignes as $i => $val) foreach ($_facrec->lines as $i => $val)
{ {
if ($_facrec->lignes[$i]->fk_product) if ($_facrec->lines[$i]->fk_product)
{ {
$prod = new Product($this->db, $_facrec->lignes[$i]->fk_product); $prod = new Product($this->db, $_facrec->lines[$i]->fk_product);
$res=$prod->fetch($_facrec->lignes[$i]->fk_product); $res=$prod->fetch($_facrec->lines[$i]->fk_product);
} }
$tva_tx = get_default_tva($mysoc,$soc,$prod->id); $tva_tx = get_default_tva($mysoc,$soc,$prod->id);
$localtax1_tx=get_localtax($tva_tx,1,$soc); $localtax1_tx=get_localtax($tva_tx,1,$soc);
@ -307,16 +306,16 @@ class Facture extends CommonObject
$result_insert = $this->addline( $result_insert = $this->addline(
$this->id, $this->id,
$_facrec->lignes[$i]->desc, $_facrec->lines[$i]->desc,
$_facrec->lignes[$i]->subprice, $_facrec->lines[$i]->subprice,
$_facrec->lignes[$i]->qty, $_facrec->lines[$i]->qty,
$tva_tx, $tva_tx,
$localtax1_tx, $localtax1_tx,
$localtax2_tx, $localtax2_tx,
$_facrec->lignes[$i]->fk_product, $_facrec->lines[$i]->fk_product,
$_facrec->lignes[$i]->remise_percent, $_facrec->lines[$i]->remise_percent,
'','',0,0,'','HT',0, '','',0,0,'','HT',0,
$_facrec->lignes[$i]->product_type $_facrec->lines[$i]->product_type
); );
if ( $result_insert < 0) if ( $result_insert < 0)
@ -451,9 +450,10 @@ class Facture extends CommonObject
// Load source object // Load source object
$object->fetch($fromid); $object->fetch($fromid);
$objFrom = $object;
$object->id=0; $object->id=0;
$object->statut=0; $object->statut=0;
$object->clone_fromid=$fromid;
// Clear fields // Clear fields
$object->user_author = $user->id; $object->user_author = $user->id;
@ -476,8 +476,14 @@ class Facture extends CommonObject
} }
} }
// FIXME objForm change de valeur apres le create() !!
//var_dump($objFrom->lines[0]);
// Create clone // Create clone
$result=$object->create($user); $result=$object->create($user);
//print '!!!!! after !!!!!<br>';
//var_dump($objFrom->lines[0]);
// Other options // Other options
if ($result < 0) if ($result < 0)
@ -493,7 +499,7 @@ class Facture extends CommonObject
{ {
foreach($object->hooks as $module) foreach($object->hooks as $module)
{ {
$result = $module->createFromClone($object); $result = $module->createfrom($objFrom,$result,$object->element);
if ($result < 0) $error++; if ($result < 0) $error++;
} }
} }

View File

@ -168,6 +168,15 @@ class InterfacePropalWorkflow
if ($ret > 0) if ($ret > 0)
{ {
// Hook of thirdparty module
if (! empty($object->hooks))
{
foreach($object->hooks as $module)
{
$module->createfrom($object,$ret,$order->element);
}
}
// Ne pas passer par la commande provisoire // Ne pas passer par la commande provisoire
if ($conf->global->COMMANDE_VALID_AFTER_CLOSE_PROPAL == 1) if ($conf->global->COMMANDE_VALID_AFTER_CLOSE_PROPAL == 1)
{ {