diff --git a/htdocs/comm/propal.php b/htdocs/comm/propal.php index b208161d7e0..26cc657d6f0 100644 --- a/htdocs/comm/propal.php +++ b/htdocs/comm/propal.php @@ -26,7 +26,7 @@ * \file htdocs/comm/propal.php * \ingroup propale * \brief Page of commercial proposals card and list - * \version $Id: propal.php,v 1.618 2011/08/10 18:05:49 hregis Exp $ + * \version $Id: propal.php,v 1.619 2011/08/10 19:55:22 hregis Exp $ */ require("../main.inc.php"); @@ -101,7 +101,7 @@ if ($action == 'confirm_clone' && $confirm == 'yes') } else { - $result=$object->createFromClone($id,0,GETPOST('socid')); + $result=$object->createFromClone($id,0,GETPOST('socid'),$hookmanager); if ($result > 0) { header("Location: ".$_SERVER['PHP_SELF'].'?id='.$result); @@ -1926,6 +1926,6 @@ else } $db->close(); -llxFooter('$Date: 2011/08/10 18:05:49 $ - $Revision: 1.618 $'); +llxFooter('$Date: 2011/08/10 19:55:22 $ - $Revision: 1.619 $'); ?> diff --git a/htdocs/comm/propal/class/propal.class.php b/htdocs/comm/propal/class/propal.class.php index 3d90dc99837..9f6325841f3 100644 --- a/htdocs/comm/propal/class/propal.class.php +++ b/htdocs/comm/propal/class/propal.class.php @@ -29,7 +29,7 @@ * \author Rodolphe Qiedeville * \author Eric Seigne * \author Laurent Destailleur - * \version $Id: propal.class.php,v 1.111 2011/08/08 01:53:26 eldy Exp $ + * \version $Id: propal.class.php,v 1.112 2011/08/10 19:55:22 hregis Exp $ */ require_once(DOL_DOCUMENT_ROOT ."/core/class/commonobject.class.php"); @@ -826,7 +826,7 @@ class Propal extends CommonObject * @param socid Id of thirdparty * @return int New id of clone */ - function createFromClone($fromid,$invertdetail=0,$socid=0) + function createFromClone($fromid,$invertdetail=0,$socid=0,$hookmanager=false) { global $user,$langs,$conf; @@ -836,12 +836,6 @@ class Propal extends CommonObject $object=new Propal($this->db); - // Instantiate hooks of thirdparty module - if (is_array($conf->hooks_modules) && !empty($conf->hooks_modules)) - { - $object->callHooks('propalcard'); - } - $this->db->begin(); // Load source object @@ -906,24 +900,12 @@ class Propal extends CommonObject if (! $error) { - // Hook for external modules - if (! empty($object->hooks)) - { - foreach($object->hooks as $hook) - { - if (! empty($hook['modules'])) - { - foreach($hook['modules'] as $module) - { - if (method_exists($module,'createfrom')) - { - $result = $module->createfrom($objFrom,$result,$object->element); - if ($result < 0) $error++; - } - } - } - } - } + // Hook of thirdparty module + if (is_object($hookmanager)) + { + $reshook=$hookmanager->executeHooks('createfrom','',$objFrom,$result,$object->element); // Note that $action and $object may have been modified by some hooks + if ($reshook < 0) $error++; + } // Appel des triggers include_once(DOL_DOCUMENT_ROOT . "/core/class/interfaces.class.php"); diff --git a/htdocs/commande/class/commande.class.php b/htdocs/commande/class/commande.class.php index b0a046939f0..c13d1987225 100644 --- a/htdocs/commande/class/commande.class.php +++ b/htdocs/commande/class/commande.class.php @@ -24,7 +24,7 @@ * \file htdocs/commande/class/commande.class.php * \ingroup commande * \brief Fichier des classes de commandes - * \version $Id: commande.class.php,v 1.121 2011/08/08 01:10:07 eldy Exp $ + * \version $Id: commande.class.php,v 1.122 2011/08/10 19:55:22 hregis Exp $ */ require_once(DOL_DOCUMENT_ROOT."/core/class/commonobject.class.php"); require_once(DOL_DOCUMENT_ROOT."/product/class/product.class.php"); @@ -769,7 +769,7 @@ class Commande extends CommonObject * @param socid Id of thirdparty * @return int New id of clone */ - function createFromClone($fromid,$invertdetail=0,$socid=0) + function createFromClone($fromid,$invertdetail=0,$socid=0,$hookmanager=false) { global $conf,$user,$langs; @@ -777,12 +777,6 @@ class Commande extends CommonObject $object=new Commande($this->db); - // Instantiate hooks of thirdparty module - if (is_array($conf->hooks_modules) && !empty($conf->hooks_modules)) - { - $object->callHooks('ordercard'); - } - $this->db->begin(); // Load source object @@ -829,22 +823,10 @@ class Commande extends CommonObject if (! $error) { // Hook of thirdparty module - if (! empty($object->hooks)) + if (is_object($hookmanager)) { - foreach($object->hooks as $hook) - { - if (! empty($hook['modules'])) - { - foreach($hook['modules'] as $module) - { - if (method_exists($module,'createfrom')) - { - $result = $module->createfrom($objFrom,$result,$object->element); - if ($result < 0) $error++; - } - } - } - } + $reshook=$hookmanager->executeHooks('createfrom','',$objFrom,$result,$object->element); // Note that $action and $object may have been modified by some hooks + if ($reshook < 0) $error++; } // Appel des triggers @@ -875,7 +857,7 @@ class Commande extends CommonObject * @param invertdetail Reverse sign of amounts for lines * @return int <0 if KO, 0 if nothing done, 1 if OK */ - function createFromProposal($object,$invertdetail=0) + function createFromProposal($object,$invertdetail=0,$hookmanager=false) { global $conf,$user,$langs; @@ -932,22 +914,10 @@ class Commande extends CommonObject if ($ret > 0) { // Hook of thirdparty module - if (! empty($object->hooks)) + if (is_object($hookmanager)) { - foreach($object->hooks as $hook) - { - if (! empty($hook['modules'])) - { - foreach($hook['modules'] as $module) - { - if (method_exists($module,'createfrom')) - { - $result = $module->createfrom($object,$ret,$this->element); - if ($result < 0) $error++; - } - } - } - } + $reshook=$hookmanager->executeHooks('createfrom','',$object,$ret,$this->element); // Note that $action and $object may have been modified by some hooks + if ($reshook < 0) $error++; } if (! $error) diff --git a/htdocs/commande/fiche.php b/htdocs/commande/fiche.php index cad6b8148ec..a0b897c8a29 100644 --- a/htdocs/commande/fiche.php +++ b/htdocs/commande/fiche.php @@ -25,7 +25,7 @@ * \file htdocs/commande/fiche.php * \ingroup commande * \brief Page to show customer order - * \version $Id: fiche.php,v 1.531 2011/08/10 18:04:58 hregis Exp $ + * \version $Id: fiche.php,v 1.532 2011/08/10 19:55:22 hregis Exp $ */ require("../main.inc.php"); @@ -85,7 +85,7 @@ if ($action == 'confirm_clone' && $confirm == 'yes') } else { - $result=$object->createFromClone($id, 0, GETPOST('socid')); + $result=$object->createFromClone($id, 0, GETPOST('socid'), $hookmanager); if ($result > 0) { header("Location: ".$_SERVER['PHP_SELF'].'?id='.$result); @@ -2063,5 +2063,5 @@ else $db->close(); -llxFooter('$Date: 2011/08/10 18:04:58 $ - $Revision: 1.531 $'); +llxFooter('$Date: 2011/08/10 19:55:22 $ - $Revision: 1.532 $'); ?> diff --git a/htdocs/compta/facture.php b/htdocs/compta/facture.php index f744229f4a8..54e6d2640cc 100644 --- a/htdocs/compta/facture.php +++ b/htdocs/compta/facture.php @@ -25,7 +25,7 @@ * \file htdocs/compta/facture.php * \ingroup facture * \brief Page to create/see an invoice - * \version $Id: facture.php,v 1.852 2011/08/10 18:04:41 hregis Exp $ + * \version $Id: facture.php,v 1.853 2011/08/10 19:55:21 hregis Exp $ */ require('../main.inc.php'); @@ -95,7 +95,7 @@ if ($action == 'confirm_clone' && $confirm == 'yes') } else { - $result=$object->createFromClone($id); + $result=$object->createFromClone($id,0,$hookmanager); if ($result > 0) { header("Location: ".$_SERVER['PHP_SELF'].'?facid='.$result); @@ -3178,5 +3178,5 @@ else $db->close(); -llxFooter('$Date: 2011/08/10 18:04:41 $ - $Revision: 1.852 $'); +llxFooter('$Date: 2011/08/10 19:55:21 $ - $Revision: 1.853 $'); ?> diff --git a/htdocs/compta/facture/class/facture.class.php b/htdocs/compta/facture/class/facture.class.php index d0242e9a77c..256f0f170f0 100644 --- a/htdocs/compta/facture/class/facture.class.php +++ b/htdocs/compta/facture/class/facture.class.php @@ -27,7 +27,7 @@ * \file htdocs/compta/facture/class/facture.class.php * \ingroup facture * \brief Fichier de la classe des factures clients - * \version $Id: facture.class.php,v 1.124 2011/08/03 00:46:25 eldy Exp $ + * \version $Id: facture.class.php,v 1.125 2011/08/10 19:55:21 hregis Exp $ */ require_once(DOL_DOCUMENT_ROOT ."/core/class/commonobject.class.php"); @@ -518,7 +518,7 @@ class Facture extends CommonObject * @param invertdetail Reverse sign of amounts for lines * @return int New id of clone */ - function createFromClone($fromid,$invertdetail=0) + function createFromClone($fromid,$invertdetail=0,$hookmanager=false) { global $conf,$user,$langs; @@ -532,12 +532,6 @@ class Facture extends CommonObject $object=new Facture($this->db); $object->fetch($fromid); - // Instantiate hooks of thirdparty module - if (is_array($conf->hooks_modules) && ! empty($conf->hooks_modules)) - { - $object->callHooks('invoicecard'); - } - $this->db->begin(); $object->id=0; @@ -576,24 +570,12 @@ class Facture extends CommonObject if (! $error) { - // Hook for external modules - if (! empty($object->hooks)) - { - foreach($object->hooks as $hook) - { - if (! empty($hook['modules'])) - { - foreach($hook['modules'] as $module) - { - if (method_exists($module,'createfrom')) - { - $result = $module->createfrom($objFrom,$result,$object->element); - if ($result < 0) $error++; - } - } - } - } - } + // Hook of thirdparty module + if (is_object($hookmanager)) + { + $reshook=$hookmanager->executeHooks('createfrom','',$objFrom,$result,$object->element); // Note that $action and $object may have been modified by some hooks + if ($reshook < 0) $error++; + } // Appel des triggers include_once(DOL_DOCUMENT_ROOT . "/core/class/interfaces.class.php"); @@ -621,7 +603,7 @@ class Facture extends CommonObject * @param object Object source * @return int <0 if KO, 0 if nothing done, 1 if OK */ - function createFromOrder($object) + function createFromOrder($object, $hookmanager=false) { global $conf,$user,$langs; @@ -675,24 +657,12 @@ class Facture extends CommonObject if ($ret > 0) { - // Hook for external modules - if (! empty($object->hooks)) - { - foreach($object->hooks as $hook) - { - if (! empty($hook['modules'])) - { - foreach($hook['modules'] as $module) - { - if (method_exists($module,'createfrom')) - { - $result = $module->createfrom($objFrom,$result,$object->element); - if ($result < 0) $error++; - } - } - } - } - } + // Hook of thirdparty module + if (is_object($hookmanager)) + { + $reshook=$hookmanager->executeHooks('createfrom','',$objFrom,$result,$object->element); // Note that $action and $object may have been modified by some hooks + if ($reshook < 0) $error++; + } if (! $error) { diff --git a/htdocs/compta/facture/fiche-rec.php b/htdocs/compta/facture/fiche-rec.php index 0e188af4810..57115e2d6a8 100644 --- a/htdocs/compta/facture/fiche-rec.php +++ b/htdocs/compta/facture/fiche-rec.php @@ -21,7 +21,7 @@ * \file htdocs/compta/facture/fiche-rec.php * \ingroup facture * \brief Page to show predefined invoice - * \version $Id: fiche-rec.php,v 1.75 2011/07/31 22:23:13 eldy Exp $ + * \version $Id: fiche-rec.php,v 1.76 2011/08/10 19:55:22 hregis Exp $ */ require("../../main.inc.php"); @@ -109,12 +109,6 @@ if ($_GET["action"] == 'create') $facture = new Facture($db); // Source invoice $product_static=new Product($db); - // Instantiate hooks of thirdparty module - if (is_array($conf->hooks_modules) && !empty($conf->hooks_modules)) - { - $facture->callHooks('invoicecard'); - } - if ($facture->fetch($_GET["facid"]) > 0) { print '