From 691e3df1c0dddfb57fe520edba93c9ad09aec522 Mon Sep 17 00:00:00 2001 From: All3kcis Date: Tue, 10 Apr 2018 09:59:07 +0200 Subject: [PATCH 1/4] Add insertExtraFields in create --- .../product/stock/class/productlot.class.php | 19 ++++++++++++++++++- 1 file changed, 18 insertions(+), 1 deletion(-) diff --git a/htdocs/product/stock/class/productlot.class.php b/htdocs/product/stock/class/productlot.class.php index 31c28eaa5b3..7cf0c966a23 100644 --- a/htdocs/product/stock/class/productlot.class.php +++ b/htdocs/product/stock/class/productlot.class.php @@ -156,7 +156,24 @@ class Productlot extends CommonObject if (!$error) { $this->id = $this->db->last_insert_id(MAIN_DB_PREFIX . $this->table_element); - if (!$notrigger) { + // Actions on extra fields (by external module or standard code) + $hookmanager->initHooks(array('productlotdao')); + $parameters=array('id'=>$this->id); + $reshook=$hookmanager->executeHooks('insertExtraFields',$parameters,$this,$action); // Note that $action and $object may have been modified by some hooks + if (empty($reshook)) + { + if (empty($conf->global->MAIN_EXTRAFIELDS_DISABLED)) // For avoid conflicts if trigger used + { + $result=$this->insertExtraFields(); + if ($result < 0) + { + $error++; + } + } + } + else if ($reshook < 0) $error++; + + if (!$error AND !$notrigger) { // Uncomment this and change MYOBJECT to your own tag if you // want this action to call a trigger. From 3cc3816391351bfaaac45b24ed087bcf5656d845 Mon Sep 17 00:00:00 2001 From: All3kcis Date: Tue, 10 Apr 2018 10:17:06 +0200 Subject: [PATCH 2/4] Add $action before insertExtrafields hook --- .../product/stock/class/productlot.class.php | 19 +++++++++++++++++++ 1 file changed, 19 insertions(+) diff --git a/htdocs/product/stock/class/productlot.class.php b/htdocs/product/stock/class/productlot.class.php index 7cf0c966a23..c46bb4ffa78 100644 --- a/htdocs/product/stock/class/productlot.class.php +++ b/htdocs/product/stock/class/productlot.class.php @@ -156,6 +156,7 @@ class Productlot extends CommonObject if (!$error) { $this->id = $this->db->last_insert_id(MAIN_DB_PREFIX . $this->table_element); + $action='create'; // Actions on extra fields (by external module or standard code) $hookmanager->initHooks(array('productlotdao')); $parameters=array('id'=>$this->id); @@ -330,6 +331,24 @@ class Productlot extends CommonObject dol_syslog(__METHOD__ . ' ' . join(',', $this->errors), LOG_ERR); } + $action='update'; + // Actions on extra fields (by external module or standard code) + $hookmanager->initHooks(array('productlotdao')); + $parameters=array('id'=>$this->id); + $reshook=$hookmanager->executeHooks('insertExtraFields',$parameters,$this,$action); // Note that $action and $object may have been modified by some hooks + if (empty($reshook)) + { + if (empty($conf->global->MAIN_EXTRAFIELDS_DISABLED)) // For avoid conflicts if trigger used + { + $result=$this->insertExtraFields(); + if ($result < 0) + { + $error++; + } + } + } + else if ($reshook < 0) $error++; + if (!$error && !$notrigger) { // Uncomment this and change MYOBJECT to your own tag if you // want this action calls a trigger. From 00c85935670661831c6fe20b8cf798e34b381d10 Mon Sep 17 00:00:00 2001 From: All3kcis Date: Wed, 11 Apr 2018 14:09:30 +0200 Subject: [PATCH 3/4] remove hook --- .../product/stock/class/productlot.class.php | 36 ++++++------------- 1 file changed, 10 insertions(+), 26 deletions(-) diff --git a/htdocs/product/stock/class/productlot.class.php b/htdocs/product/stock/class/productlot.class.php index c46bb4ffa78..0e15194713a 100644 --- a/htdocs/product/stock/class/productlot.class.php +++ b/htdocs/product/stock/class/productlot.class.php @@ -156,23 +156,15 @@ class Productlot extends CommonObject if (!$error) { $this->id = $this->db->last_insert_id(MAIN_DB_PREFIX . $this->table_element); - $action='create'; - // Actions on extra fields (by external module or standard code) - $hookmanager->initHooks(array('productlotdao')); - $parameters=array('id'=>$this->id); - $reshook=$hookmanager->executeHooks('insertExtraFields',$parameters,$this,$action); // Note that $action and $object may have been modified by some hooks - if (empty($reshook)) + // Actions on extra fields + if (empty($conf->global->MAIN_EXTRAFIELDS_DISABLED)) // For avoid conflicts if trigger used { - if (empty($conf->global->MAIN_EXTRAFIELDS_DISABLED)) // For avoid conflicts if trigger used + $result=$this->insertExtraFields(); + if ($result < 0) { - $result=$this->insertExtraFields(); - if ($result < 0) - { - $error++; - } + $error++; } } - else if ($reshook < 0) $error++; if (!$error AND !$notrigger) { // Uncomment this and change MYOBJECT to your own tag if you @@ -331,23 +323,15 @@ class Productlot extends CommonObject dol_syslog(__METHOD__ . ' ' . join(',', $this->errors), LOG_ERR); } - $action='update'; - // Actions on extra fields (by external module or standard code) - $hookmanager->initHooks(array('productlotdao')); - $parameters=array('id'=>$this->id); - $reshook=$hookmanager->executeHooks('insertExtraFields',$parameters,$this,$action); // Note that $action and $object may have been modified by some hooks - if (empty($reshook)) + // Actions on extra fields + if (empty($conf->global->MAIN_EXTRAFIELDS_DISABLED)) // For avoid conflicts if trigger used { - if (empty($conf->global->MAIN_EXTRAFIELDS_DISABLED)) // For avoid conflicts if trigger used + $result=$this->insertExtraFields(); + if ($result < 0) { - $result=$this->insertExtraFields(); - if ($result < 0) - { - $error++; - } + $error++; } } - else if ($reshook < 0) $error++; if (!$error && !$notrigger) { // Uncomment this and change MYOBJECT to your own tag if you From 701aa53bdd789e15fd53a71886d4b4c40b2228ad Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Wed, 11 Apr 2018 16:33:12 +0200 Subject: [PATCH 4/4] Update productlot.class.php --- htdocs/product/stock/class/productlot.class.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/htdocs/product/stock/class/productlot.class.php b/htdocs/product/stock/class/productlot.class.php index 0e15194713a..56c9e1cebe4 100644 --- a/htdocs/product/stock/class/productlot.class.php +++ b/htdocs/product/stock/class/productlot.class.php @@ -166,7 +166,7 @@ class Productlot extends CommonObject } } - if (!$error AND !$notrigger) { + if (! $error && ! $notrigger) { // Uncomment this and change MYOBJECT to your own tag if you // want this action to call a trigger.