From 16e9f6db48770a70f433399edf06a20f721656b1 Mon Sep 17 00:00:00 2001 From: jfefe Date: Sun, 17 Feb 2013 14:37:33 +0100 Subject: [PATCH 1/6] Fix : bad name of property when retrieve extrafields for thirdparty --- htdocs/core/class/commondocgenerator.class.php | 2 +- htdocs/societe/class/societe.class.php | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/htdocs/core/class/commondocgenerator.class.php b/htdocs/core/class/commondocgenerator.class.php index ec9ae1d2870..d64a7c2710b 100755 --- a/htdocs/core/class/commondocgenerator.class.php +++ b/htdocs/core/class/commondocgenerator.class.php @@ -169,7 +169,7 @@ abstract class CommonDocGenerator { foreach($object->array_options as $key=>$label) { - $extrafields['company_options_'.$key] = $label; + $extrafields['company_'.$key] = $label; } $array_thirdparty = array_merge($array_thirdparty,$extrafields); } diff --git a/htdocs/societe/class/societe.class.php b/htdocs/societe/class/societe.class.php index dfeec3eaab7..7688eec0d66 100644 --- a/htdocs/societe/class/societe.class.php +++ b/htdocs/societe/class/societe.class.php @@ -865,7 +865,7 @@ class Societe extends CommonObject } foreach($extrafields->attribute_label as $key=>$label) { - $this->array_options[$key]=$label; + $this->array_options['options_'.$key]=$label; } } else From 060060f08ba00e41d499a068bbca6c3a6c17d375 Mon Sep 17 00:00:00 2001 From: jfefe Date: Sun, 17 Feb 2013 20:14:18 +0100 Subject: [PATCH 2/6] Missing object $langs when showing extrafield of type 'price' --- htdocs/core/class/extrafields.class.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/htdocs/core/class/extrafields.class.php b/htdocs/core/class/extrafields.class.php index 4f583a667f9..ec02f906e70 100755 --- a/htdocs/core/class/extrafields.class.php +++ b/htdocs/core/class/extrafields.class.php @@ -669,7 +669,7 @@ class ExtraFields */ function showOutputField($key,$value,$moreparam='') { - global $conf; + global $conf,$langs; $label=$this->attribute_label[$key]; $type=$this->attribute_type[$key]; From 8ebb48cb5c9464865306c33cfec48bea86568398 Mon Sep 17 00:00:00 2001 From: jfefe Date: Sun, 17 Feb 2013 21:14:00 +0100 Subject: [PATCH 3/6] Fix : in ODT show value and not label of company extrafield --- htdocs/core/class/commondocgenerator.class.php | 14 ++++++++++---- 1 file changed, 10 insertions(+), 4 deletions(-) diff --git a/htdocs/core/class/commondocgenerator.class.php b/htdocs/core/class/commondocgenerator.class.php index d64a7c2710b..3b815e962c0 100755 --- a/htdocs/core/class/commondocgenerator.class.php +++ b/htdocs/core/class/commondocgenerator.class.php @@ -164,14 +164,20 @@ abstract class CommonDocGenerator 'company_note'=>$object->note ); - $extrafields = array(); + // Retrieve extrafields if(is_array($object->array_options) && count($object->array_options)) { - foreach($object->array_options as $key=>$label) + if(!class_exists('Extrafields')) + require_once DOL_DOCUMENT_ROOT.'/core/class/extrafields.class.php'; + $extrafields = new ExtraFields($this->db); + $extralabels = $extrafields->fetch_name_optionals_label('company',true); + //Get extrafield values + $object->fetch_optionals($object->id,$extralabels); + + foreach($extrafields->attribute_label as $key=>$label) { - $extrafields['company_'.$key] = $label; + $array_thirdparty=array_merge($array_thirdparty,array('company_options_'.$key => $object->array_options['options_'.$key])); } - $array_thirdparty = array_merge($array_thirdparty,$extrafields); } return $array_thirdparty; } From 3ef8c6e5dd33ed6106155e28a6c87ffc3e35929e Mon Sep 17 00:00:00 2001 From: jfefe Date: Mon, 18 Feb 2013 00:40:49 +0100 Subject: [PATCH 4/6] Missing variable declaration --- htdocs/core/class/extrafields.class.php | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/htdocs/core/class/extrafields.class.php b/htdocs/core/class/extrafields.class.php index ec02f906e70..f72ddc8d6e2 100755 --- a/htdocs/core/class/extrafields.class.php +++ b/htdocs/core/class/extrafields.class.php @@ -44,6 +44,10 @@ class ExtraFields var $attribute_unique; // Array to store if attribute is required or not var $attribute_required; + // Array to store parameters of attribute (used in select type) + var $attribute_param; + // Int to store position of attribute + var $attribute_pos; var $error; var $errno; From bd2d9cdd3e39282dc904e2ab26ee2d482a7d89e7 Mon Sep 17 00:00:00 2001 From: jfefe Date: Mon, 18 Feb 2013 00:41:50 +0100 Subject: [PATCH 5/6] Split extrafields display into 2 columns (thirdparty) --- htdocs/societe/soc.php | 57 ++++++++++++++++++++++++++++++++++-------- 1 file changed, 47 insertions(+), 10 deletions(-) diff --git a/htdocs/societe/soc.php b/htdocs/societe/soc.php index c1dd0c4c09d..ee8f6e984b1 100644 --- a/htdocs/societe/soc.php +++ b/htdocs/societe/soc.php @@ -998,14 +998,25 @@ else $reshook=$hookmanager->executeHooks('formObjectOptions',$parameters,$object,$action); // Note that $action and $object may have been modified by hook if (empty($reshook) && ! empty($extrafields->attribute_label)) { + $e=0; foreach($extrafields->attribute_label as $key=>$label) { + $colspan='3'; $value=(isset($_POST["options_".$key])?$_POST["options_".$key]:(isset($object->array_options["options_".$key])?$object->array_options["options_".$key]:'')); - print ''; + $colspan='0'; + } + print 'attribute_required[$key])) print ' class="fieldrequired"'; - print '>'.$label.''; + print '>'.$label.''; + print ''; print $extrafields->showInputField($key,$value); - print ''."\n"; + print ''; + + if (($e % 2) == 1) print ''."\n"; + $e++; } } @@ -1426,23 +1437,38 @@ else print ''; print ''; } - // Other attributes $parameters=array('colspan' => ' colspan="3"', 'colspanvalue' => '3'); $reshook=$hookmanager->executeHooks('formObjectOptions',$parameters,$object,$action); // Note that $action and $object may have been modified by hook if (empty($reshook) && ! empty($extrafields->attribute_label)) { + $old_pos=0; + $e=0; foreach($extrafields->attribute_label as $key=>$label) { + $colspan = '3'; $value=(isset($_POST["options_".$key])?$_POST["options_".$key]:$object->array_options["options_".$key]); - print ''."\n"; + $colspan = '0'; + } + print 'attribute_required[$key])) print ' class="fieldrequired"'; - print '>'.$label.''; + print '>'.$label.''."\n"; + print ''; print $extrafields->showInputField($key,$value); - print "\n"; + print ""."\n"; + + if (($e % 2) == 1 ) + { + print "\n"; + } + $old_pos = $extrafields->attribute_pos[$key]; + $e++; } } - // Logo print ''; print ''.$langs->trans("Logo").''; @@ -1756,12 +1782,23 @@ else $reshook=$hookmanager->executeHooks('formObjectOptions',$parameters,$object,$action); // Note that $action and $object may have been modified by hook if (empty($reshook) && ! empty($extrafields->attribute_label)) { + $e=0; foreach($extrafields->attribute_label as $key=>$label) { + $colspan='3'; $value=(isset($_POST["options_".$key])?$_POST["options_".$key]:(isset($object->array_options['options_'.$key])?$object->array_options['options_'.$key]:'')); - print ''.$label.''; + if (($e % 2) == 0) + { + print ''; + $colspan='0'; + } + print ''.$label.''; + print ''; print $extrafields->showOutputField($key,$value); - print "\n"; + print ""; + + if (($e % 2) == 1) print ''; + $e++; } } From 71a2b4c8c0a4653ca4cceec3a8b945cdce48b36c Mon Sep 17 00:00:00 2001 From: jfefe Date: Mon, 18 Feb 2013 00:58:40 +0100 Subject: [PATCH 6/6] In ODT document add currency symbol with extrafields of type "price" --- htdocs/core/class/commondocgenerator.class.php | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/htdocs/core/class/commondocgenerator.class.php b/htdocs/core/class/commondocgenerator.class.php index 3b815e962c0..aec9e74dcb8 100755 --- a/htdocs/core/class/commondocgenerator.class.php +++ b/htdocs/core/class/commondocgenerator.class.php @@ -171,11 +171,13 @@ abstract class CommonDocGenerator require_once DOL_DOCUMENT_ROOT.'/core/class/extrafields.class.php'; $extrafields = new ExtraFields($this->db); $extralabels = $extrafields->fetch_name_optionals_label('company',true); - //Get extrafield values - $object->fetch_optionals($object->id,$extralabels); foreach($extrafields->attribute_label as $key=>$label) { + if($extrafields->attribute_type[$key] == 'price') + { + $object->array_options['options_'.$key] = price($object->array_options['options_'.$key]).' '.$outputlangs->getCurrencySymbol($conf->currency); + } $array_thirdparty=array_merge($array_thirdparty,array('company_options_'.$key => $object->array_options['options_'.$key])); } }