From 9eee5f9509810ed6cefcc17d6c478e0e58b73d6a Mon Sep 17 00:00:00 2001 From: jfefe Date: Wed, 6 Mar 2013 00:18:41 +0100 Subject: [PATCH] Fix : extrafields for propale were note saved after creation --- htdocs/comm/propal.php | 9 +++++++++ htdocs/comm/propal/class/propal.class.php | 20 +++++++++++++++++++- 2 files changed, 28 insertions(+), 1 deletion(-) diff --git a/htdocs/comm/propal.php b/htdocs/comm/propal.php index b2dc55cc67d..4cb99d6395b 100644 --- a/htdocs/comm/propal.php +++ b/htdocs/comm/propal.php @@ -338,6 +338,15 @@ else if ($action == 'add' && $user->rights->propal->creer) } } + // Get extra fields + foreach($_POST as $key => $value) + { + if (preg_match("/^options_/",$key)) + { + $object->array_options[$key]=GETPOST($key); + } + } + $id = $object->create($user); } diff --git a/htdocs/comm/propal/class/propal.class.php b/htdocs/comm/propal/class/propal.class.php index 5e8fac582a6..e10d1ecc0ea 100644 --- a/htdocs/comm/propal/class/propal.class.php +++ b/htdocs/comm/propal/class/propal.class.php @@ -622,7 +622,7 @@ class Propal extends CommonObject */ function create($user='', $notrigger=0) { - global $langs,$conf,$mysoc; + global $langs,$conf,$mysoc,$hookmanager; $error=0; $now=dol_now(); @@ -802,6 +802,24 @@ class Propal extends CommonObject $resql=$this->update_price(1); if ($resql) { + // Actions on extra fields (by external module or standard code) + // FIXME le hook fait double emploi avec le trigger !! + $hookmanager->initHooks(array('propaldao')); + $parameters=array('socid'=>$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 (! $notrigger) { // Appel des triggers