From 2693e5db6dd39a988d7a0baaf4280fffeb42f3fd Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Wed, 29 Nov 2017 16:23:11 +0100 Subject: [PATCH] Fix the trigger COMPANY_MODIFY provide information of thirdparty merged --- htdocs/societe/card.php | 26 +++++++++++++++++++------- htdocs/societe/class/societe.class.php | 2 +- 2 files changed, 20 insertions(+), 8 deletions(-) diff --git a/htdocs/societe/card.php b/htdocs/societe/card.php index fd3830a00ad..2d9d76d8b2b 100644 --- a/htdocs/societe/card.php +++ b/htdocs/societe/card.php @@ -146,15 +146,16 @@ if (empty($reshook)) $object->client = $object->client | $soc_origin->client; $object->fournisseur = $object->fournisseur | $soc_origin->fournisseur; $listofproperties=array( - 'address', 'zip', 'town', 'state_id', 'country_id', 'phone', 'phone_pro', 'fax', 'email', 'skype', 'url', 'barcode', 'idprof1', 'idprof2', 'idprof3', 'idprof4', 'idprof5', 'idprof6', - 'tva_intra', 'effectif_id', 'forme_juridique', 'remise_percent', 'mode_reglement_supplier_id', 'cond_reglement_supplier_id', 'name_bis', - 'stcomm_id', 'outstanding_limit', 'price_level', 'parent', 'default_lang', 'ref', 'ref_ext', 'import_key', 'fk_incoterms', 'fk_multicurrency', - 'code_client', 'code_fournisseur', 'code_compta', 'code_compta_fournisseur', - 'model_pdf', 'fk_projet' + 'address', 'zip', 'town', 'state_id', 'country_id', 'phone', 'phone_pro', 'fax', 'email', 'skype', 'url', 'barcode', + 'idprof1', 'idprof2', 'idprof3', 'idprof4', 'idprof5', 'idprof6', + 'tva_intra', 'effectif_id', 'forme_juridique', 'remise_percent', 'mode_reglement_supplier_id', 'cond_reglement_supplier_id', 'name_bis', + 'stcomm_id', 'outstanding_limit', 'price_level', 'parent', 'default_lang', 'ref', 'ref_ext', 'import_key', 'fk_incoterms', 'fk_multicurrency', + 'code_client', 'code_fournisseur', 'code_compta', 'code_compta_fournisseur', + 'model_pdf', 'fk_projet' ); foreach ($listofproperties as $property) { - if (empty($object->$property)) $object->$property = $soc_origin->$property; + if (empty($object->$property)) $object->$property = $soc_origin->$property; } // Concat some data @@ -183,7 +184,7 @@ if (empty($reshook)) $object->setCategories($suppcats, 'supplier'); // Update - $object->update($object->id, $user); + $object->update($object->id, $user, 0); // Move links $objects = array( @@ -237,6 +238,17 @@ if (empty($reshook)) } } + + if (! $error && $call_trigger) + { + $object->context=array('merge'=>1, 'mergefromid'=>$soc_origin->id); + + // Call trigger + $result=$object->call_trigger('COMPANY_MODIFY',$user); + if ($result < 0) $error++; + // End call triggers + } + if (!$errors) { //We finally remove the old thirdparty diff --git a/htdocs/societe/class/societe.class.php b/htdocs/societe/class/societe.class.php index 2594a4c9466..f147aedc5a5 100644 --- a/htdocs/societe/class/societe.class.php +++ b/htdocs/societe/class/societe.class.php @@ -727,7 +727,7 @@ class Societe extends CommonObject * * @param int $id Id of company (deprecated, use 0 here and call update on an object loaded by a fetch) * @param User $user Utilisateur qui demande la mise a jour - * @param int $call_trigger 0=non, 1=oui + * @param int $call_trigger 0=no, 1=yes * @param int $allowmodcodeclient Inclut modif code client et code compta * @param int $allowmodcodefournisseur Inclut modif code fournisseur et code compta fournisseur * @param string $action 'add' or 'update'