From 8b54a805935b2766f3d41d3c56803875e68428f2 Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Tue, 20 Feb 2018 19:20:03 +0100 Subject: [PATCH] Fix oldcopy not saved before calling trigger --- htdocs/contrat/card.php | 3 +++ htdocs/contrat/class/contrat.class.php | 13 +++++-------- 2 files changed, 8 insertions(+), 8 deletions(-) diff --git a/htdocs/contrat/card.php b/htdocs/contrat/card.php index cdbcb46f815..0bbb509b7fa 100644 --- a/htdocs/contrat/card.php +++ b/htdocs/contrat/card.php @@ -94,6 +94,7 @@ $permissionnote=$user->rights->contrat->creer; // Used by the include of actions $permissiondellink=$user->rights->contrat->creer; // Used by the include of actions_dellink.inc.php + /* * Actions */ @@ -875,6 +876,8 @@ if (empty($reshook)) } else if ($action == 'update_extras') { + $object->oldcopy = dol_clone($object); + // Fill array 'array_options' with data from update form $extralabels = $extrafields->fetch_name_optionals_label($object->table_element); $ret = $extrafields->setOptionalsFromPost($extralabels, $object, GETPOST('attribute')); diff --git a/htdocs/contrat/class/contrat.class.php b/htdocs/contrat/class/contrat.class.php index cf809adfc6c..537e37071bc 100644 --- a/htdocs/contrat/class/contrat.class.php +++ b/htdocs/contrat/class/contrat.class.php @@ -609,7 +609,7 @@ class Contrat extends CommonObject $this->mise_en_service = $this->db->jdate($result["datemise"]); $this->date_contrat = $this->db->jdate($result["datecontrat"]); - $this->date_creation = $this->db->jdate($result["datecontrat"]); + $this->date_creation = $this->db->jdate($result["datecontrat"]); $this->fin_validite = $this->db->jdate($result["fin_validite"]); $this->date_cloture = $this->db->jdate($result["date_cloture"]); @@ -634,16 +634,13 @@ class Contrat extends CommonObject $this->db->free($resql); - // Retreive all extrafield for thirdparty - // fetch optionals attributes and labels - require_once(DOL_DOCUMENT_ROOT.'/core/class/extrafields.class.php'); - $extrafields=new ExtraFields($this->db); - $extralabels=$extrafields->fetch_name_optionals_label($this->table_element,true); - $this->fetch_optionals($this->id,$extralabels); + + $this->fetch_optionals($this->id, null); + /* * Lines - */ + */ $this->lines = array();