diff --git a/htdocs/core/actions_extrafields.inc.php b/htdocs/core/actions_extrafields.inc.php index 30e3549e912..278a931b437 100644 --- a/htdocs/core/actions_extrafields.inc.php +++ b/htdocs/core/actions_extrafields.inc.php @@ -337,7 +337,8 @@ if ($action == 'update') (GETPOST('list', 'alpha')?1:0), (GETPOST('ishidden', 'alpha')?1:0), GETPOST('default_value','alpha'), - GETPOST('computed_value','alpha') + GETPOST('computed_value','alpha'), + (GETPOST('entitycurrentorall', 'alpha')?0:'') ); if ($result > 0) { diff --git a/htdocs/core/class/extrafields.class.php b/htdocs/core/class/extrafields.class.php index 835d3758ca9..3fcb909fc51 100644 --- a/htdocs/core/class/extrafields.class.php +++ b/htdocs/core/class/extrafields.class.php @@ -721,6 +721,8 @@ class ExtraFields { $array_name_label[$tab->name]=$tab->label; } + + // Old usage $this->attribute_type[$tab->name]=$tab->type; @@ -737,7 +739,9 @@ class ExtraFields $this->attribute_perms[$tab->name]=$tab->perms; $this->attribute_list[$tab->name]=$tab->list; $this->attribute_hidden[$tab->name]=$tab->ishidden; - $this->attribute_entity[$tab->name]=$tab->entity; + $this->attribute_entityid[$tab->name]=$tab->entity; + + // New usage $this->attributes[$tab->elementtype]['type'][$tab->name]=$tab->type; @@ -754,7 +758,29 @@ class ExtraFields $this->attributes[$tab->elementtype]['perms'][$tab->name]=$tab->perms; $this->attributes[$tab->elementtype]['list'][$tab->name]=$tab->list; $this->attributes[$tab->elementtype]['ishidden'][$tab->name]=$tab->ishidden; - $this->attributes[$tab->elementtype]['entity'][$tab->name]=$tab->entity; + $this->attributes[$tab->elementtype]['entityid'][$tab->name]=$tab->entity; + + + if (!empty($conf->multicompany->enabled)) { + $sql_entity_name='SELECT label FROM '.MAIN_DB_PREFIX.'entity WHERE rowid='.$tab->entity; + $resql_entity_name=$this->db->query($sql_entity_name); + if ($resql_entity_name) + { + if ($this->db->num_rows($resql_entity_name)) + { + if ($obj = $this->db->fetch_object($resql_entity_name)) + { + $this->attribute_entitylabel[$tab->name]=$obj->label; + $this->attributes[$tab->elementtype]['entitylabel'][$tab->name]=$obj->label; + } + } + } + } + else + { + $this->error=$this->db->lasterror(); + dol_syslog(get_class($this)."::fetch_name_optionals_label ".$this->error, LOG_ERR); + } } } if ($elementtype) $this->attributes[$elementtype]['loaded']=1; diff --git a/htdocs/core/tpl/admin_extrafields_edit.tpl.php b/htdocs/core/tpl/admin_extrafields_edit.tpl.php index a1d7e18d09e..5a9a5b43d93 100644 --- a/htdocs/core/tpl/admin_extrafields_edit.tpl.php +++ b/htdocs/core/tpl/admin_extrafields_edit.tpl.php @@ -144,7 +144,7 @@ if (! empty($conf->global->MAIN_CAN_HIDE_EXTRAFIELDS)) { $ishidden=$extrafields->attribute_hidden[$attrname]; } if ($conf->multicompany->enabled) { - $entitycurrentorall=$extrafields->attribute_entity[$attrname]; + $entitycurrentorall=$extrafields->attribute_entityid[$attrname]; } if((($type == 'select') || ($type == 'checkbox') || ($type == 'radio')) && is_array($param)) diff --git a/htdocs/core/tpl/admin_extrafields_view.tpl.php b/htdocs/core/tpl/admin_extrafields_view.tpl.php index 904ff632bcf..f989ce448b5 100644 --- a/htdocs/core/tpl/admin_extrafields_view.tpl.php +++ b/htdocs/core/tpl/admin_extrafields_view.tpl.php @@ -50,7 +50,7 @@ print ''.$langs->trans("Required").''; print ''.$langs->trans("AlwaysEditable").''; if (! empty($conf->global->MAIN_CAN_HIDE_EXTRAFIELDS)) print ''.$langs->trans("Hidden").''; if ($conf->multicompany->enabled) { - print ''.$langs->trans("AllEntities").''; + print ''.$langs->trans("Entities").''; } print ' '; print "\n"; @@ -72,7 +72,7 @@ if (count($extrafields->attribute_type)) print ''.yn($extrafields->attribute_alwayseditable[$key])."\n"; if (! empty($conf->global->MAIN_CAN_HIDE_EXTRAFIELDS)) print ''.yn($extrafields->attribute_hidden[$key])."\n"; // Add hidden option on not working feature. Why hide if user can't see it. if ($conf->multicompany->enabled) { - print ''.($extrafields->attribute_entity[$key]==0?$langs->trans("All"):$langs->trans("Current")).''; + print ''.($extrafields->attribute_entityid[$key]==0?$langs->trans("All"):$extrafields->attribute_entitylabel[$key]).''; } print ''.img_edit().''; print "  ".img_delete()."\n";