diff --git a/htdocs/comm/propal/class/propal.class.php b/htdocs/comm/propal/class/propal.class.php index c4f63024293bf75430b34830025a66313e449931..8e11086ac79283e9bf18d57f4d3ec03a52562ef8 100644 --- a/htdocs/comm/propal/class/propal.class.php +++ b/htdocs/comm/propal/class/propal.class.php @@ -787,6 +787,8 @@ class Propal extends CommonObject // Load source object $object->fetch($fromid); + $objFrom = $object; + $object->id=0; $object->statut=0; @@ -833,7 +835,7 @@ class Propal extends CommonObject { foreach($object->hooks as $module) { - $result = $module->createFromClone($object); + $result = $module->createfrom($objFrom,$result,$object->element); if ($result < 0) $error++; } } diff --git a/htdocs/commande/class/commande.class.php b/htdocs/commande/class/commande.class.php index 32e1970a2f34d5b9722c4112799f633ac0f2badd..2561fe882e412232e3d853f12eb86bd1cecdf050 100644 --- a/htdocs/commande/class/commande.class.php +++ b/htdocs/commande/class/commande.class.php @@ -711,6 +711,8 @@ class Commande extends CommonObject // Load source object $object->fetch($fromid); + $objFrom = $object; + $object->id=0; $object->statut=0; @@ -738,7 +740,7 @@ class Commande extends CommonObject { foreach($object->hooks as $module) { - $result = $module->createFromClone($object); + $result = $module->createfrom($objFrom,$result,$object->element); if ($result < 0) $error++; } } diff --git a/htdocs/compta/facture/class/facture.class.php b/htdocs/compta/facture/class/facture.class.php index da45c447480ecdabde9fbfd9ec31b3db15ed4c5c..5d10331e02a0af785a5e45629b571a95d8271ac4 100644 --- a/htdocs/compta/facture/class/facture.class.php +++ b/htdocs/compta/facture/class/facture.class.php @@ -102,7 +102,6 @@ class Facture extends CommonObject var $lignes=array(); // TODO deprecated var $lines=array(); var $line; - var $clone_fromid; //! Pour board var $nbtodo; var $nbtodolate; @@ -273,10 +272,10 @@ class Facture extends CommonObject * Insert lines of invoices in database */ //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=$this->lignes[$i]; + $newinvoiceline=$this->lines[$i]; $newinvoiceline->fk_facture=$this->id; 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) { - 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); - $res=$prod->fetch($_facrec->lignes[$i]->fk_product); + $prod = new Product($this->db, $_facrec->lines[$i]->fk_product); + $res=$prod->fetch($_facrec->lines[$i]->fk_product); } $tva_tx = get_default_tva($mysoc,$soc,$prod->id); $localtax1_tx=get_localtax($tva_tx,1,$soc); @@ -307,16 +306,16 @@ class Facture extends CommonObject $result_insert = $this->addline( $this->id, - $_facrec->lignes[$i]->desc, - $_facrec->lignes[$i]->subprice, - $_facrec->lignes[$i]->qty, + $_facrec->lines[$i]->desc, + $_facrec->lines[$i]->subprice, + $_facrec->lines[$i]->qty, $tva_tx, $localtax1_tx, $localtax2_tx, - $_facrec->lignes[$i]->fk_product, - $_facrec->lignes[$i]->remise_percent, + $_facrec->lines[$i]->fk_product, + $_facrec->lines[$i]->remise_percent, '','',0,0,'','HT',0, - $_facrec->lignes[$i]->product_type + $_facrec->lines[$i]->product_type ); if ( $result_insert < 0) @@ -451,9 +450,10 @@ class Facture extends CommonObject // Load source object $object->fetch($fromid); + $objFrom = $object; + $object->id=0; $object->statut=0; - $object->clone_fromid=$fromid; // Clear fields $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 $result=$object->create($user); + + //print '!!!!! after !!!!!<br>'; + //var_dump($objFrom->lines[0]); // Other options if ($result < 0) @@ -493,7 +499,7 @@ class Facture extends CommonObject { foreach($object->hooks as $module) { - $result = $module->createFromClone($object); + $result = $module->createfrom($objFrom,$result,$object->element); if ($result < 0) $error++; } } diff --git a/htdocs/includes/triggers/interface_modPropale_PropalWorkflow.class.php b/htdocs/includes/triggers/interface_modPropale_PropalWorkflow.class.php index 196e6904035e2db4d02598e345158d4e42945a2c..8cda5f4121d9ce98275acc65dea8d18e7f2350cb 100644 --- a/htdocs/includes/triggers/interface_modPropale_PropalWorkflow.class.php +++ b/htdocs/includes/triggers/interface_modPropale_PropalWorkflow.class.php @@ -168,6 +168,15 @@ class InterfacePropalWorkflow 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 if ($conf->global->COMMANDE_VALID_AFTER_CLOSE_PROPAL == 1) {