From 3269b463bbff82f87fe5613433b7164d8bd1ca2f Mon Sep 17 00:00:00 2001 From: Maxime Kohlhaas Date: Tue, 24 Jun 2014 15:02:09 +0200 Subject: [PATCH 1/5] Fix / New : return on project page after task deletion instead of task list --- htdocs/projet/tasks/task.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/htdocs/projet/tasks/task.php b/htdocs/projet/tasks/task.php index dd83cf57d8f..0b3e98e94e0 100644 --- a/htdocs/projet/tasks/task.php +++ b/htdocs/projet/tasks/task.php @@ -110,7 +110,7 @@ if ($action == 'confirm_delete' && $confirm == "yes" && $user->rights->projet->s if ($object->delete($user) > 0) { - header("Location: index.php"); + header('Location: '.DOL_URL_ROOT.'/projet/tasks.php?id='.$projectstatic->id); exit; } else From d2b2f29e4bd458a34e6550f6fd072ccb6675bbd3 Mon Sep 17 00:00:00 2001 From: Maxime Kohlhaas Date: Thu, 24 Jul 2014 09:01:47 +0200 Subject: [PATCH 2/5] Start to replace all $conf->entity by getEntity() --- htdocs/categories/class/categorie.class.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/htdocs/categories/class/categorie.class.php b/htdocs/categories/class/categorie.class.php index 8d2c4ceed46..9bd5034a6d5 100644 --- a/htdocs/categories/class/categorie.class.php +++ b/htdocs/categories/class/categorie.class.php @@ -84,7 +84,7 @@ class Categorie extends CommonObject else { - if ($label) $sql.= " WHERE label = '".$this->db->escape($label)."' AND entity=".$conf->entity;; + if ($label) $sql.= " WHERE label = '".$this->db->escape($label)."' AND entity IN (".getEntity('category',1).")"; } dol_syslog(get_class($this)."::fetch sql=".$sql); From 393f32097b3cbcf7581e8d44cb584cb561caee9f Mon Sep 17 00:00:00 2001 From: Maxime Kohlhaas Date: Fri, 25 Jul 2014 13:57:41 +0200 Subject: [PATCH 3/5] class fichinterligne was not extending common object => error with trigger call --- htdocs/fichinter/class/fichinter.class.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/htdocs/fichinter/class/fichinter.class.php b/htdocs/fichinter/class/fichinter.class.php index 7a792dbc4ad..6e5f79ad44f 100644 --- a/htdocs/fichinter/class/fichinter.class.php +++ b/htdocs/fichinter/class/fichinter.class.php @@ -998,7 +998,7 @@ class Fichinter extends CommonObject /** * Classe permettant la gestion des lignes d'intervention */ -class FichinterLigne +class FichinterLigne extends CommonObject { var $db; var $error; From 6349e5e4a21a738b295f1059462d6c1cfa22f519 Mon Sep 17 00:00:00 2001 From: Maxime Kohlhaas Date: Tue, 29 Jul 2014 15:45:53 +0200 Subject: [PATCH 4/5] Class MouvementStock was not extending CommonObject so error on call_trigger function --- htdocs/product/stock/class/mouvementstock.class.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/htdocs/product/stock/class/mouvementstock.class.php b/htdocs/product/stock/class/mouvementstock.class.php index 8219da2b814..9e508f41461 100644 --- a/htdocs/product/stock/class/mouvementstock.class.php +++ b/htdocs/product/stock/class/mouvementstock.class.php @@ -28,7 +28,7 @@ /** * Class to manage stock movements */ -class MouvementStock +class MouvementStock extends CommonObject { var $error; var $db; From 94fee7af70314578ce689d9acbc0f69543b22619 Mon Sep 17 00:00:00 2001 From: Maxime Kohlhaas Date: Fri, 1 Aug 2014 08:59:08 +0200 Subject: [PATCH 5/5] Call trigger added in commonobjectline --- htdocs/core/class/commonobjectline.class.php | 28 ++++++++++++++++++++ htdocs/fichinter/class/fichinter.class.php | 3 ++- 2 files changed, 30 insertions(+), 1 deletion(-) diff --git a/htdocs/core/class/commonobjectline.class.php b/htdocs/core/class/commonobjectline.class.php index bb253d2eded..675e1cf0794 100644 --- a/htdocs/core/class/commonobjectline.class.php +++ b/htdocs/core/class/commonobjectline.class.php @@ -28,6 +28,34 @@ */ abstract class CommonObjectLine { + /** + * Call trigger based on this instance + * NB: Error from trigger are stacked in interface->errors + * NB2: If return code of triggers are < 0, action calling trigger should cancel all transaction. + * + * @param string $trigger_name trigger's name to execute + * @param User $user Object user + * @return int Result of run_triggers + */ + function call_trigger($trigger_name, $user) + { + global $langs,$conf; + include_once DOL_DOCUMENT_ROOT . '/core/class/interfaces.class.php'; + $interface=new Interfaces($this->db); + $result=$interface->run_triggers($trigger_name,$this,$user,$langs,$conf); + if ($result < 0) + { + if (!empty($this->errors)) + { + $this->errors=array_merge($this->errors,$interface->errors); + } + else + { + $this->errors=$interface->errors; + } + } + return $result; + } } diff --git a/htdocs/fichinter/class/fichinter.class.php b/htdocs/fichinter/class/fichinter.class.php index 916f69d850b..930f9371522 100644 --- a/htdocs/fichinter/class/fichinter.class.php +++ b/htdocs/fichinter/class/fichinter.class.php @@ -24,6 +24,7 @@ * \brief Fichier de la classe des gestion des fiches interventions */ require_once DOL_DOCUMENT_ROOT .'/core/class/commonobject.class.php'; +require_once DOL_DOCUMENT_ROOT .'/core/class/commonobjectline.class.php'; /** @@ -998,7 +999,7 @@ class Fichinter extends CommonObject /** * Classe permettant la gestion des lignes d'intervention */ -class FichinterLigne extends CommonObject +class FichinterLigne extends CommonObjectLine { var $db; var $error;