Fix show property "enabled" of extrafields

This commit is contained in:
Laurent Destailleur 2021-02-10 00:18:00 +01:00
parent 33a4355743
commit afeeb40e2e
3 changed files with 15 additions and 1 deletions

View File

@ -839,7 +839,7 @@ class ExtraFields
$array_name_label = array();
// We should not have several time this request. If we have, there is some optimization to do by calling a simple $extrafields->fetch_optionals() in top of code and not into subcode
$sql = "SELECT rowid,name,label,type,size,elementtype,fieldunique,fieldrequired,param,pos,alwayseditable,perms,langs,list,printable,totalizable,fielddefault,fieldcomputed,entity,enabled,help";
$sql = "SELECT rowid, name, label, type, size, elementtype, fieldunique, fieldrequired, param, pos, alwayseditable, perms, langs, list, printable, totalizable, fielddefault, fieldcomputed, entity, enabled, help";
$sql .= " FROM ".MAIN_DB_PREFIX."extrafields";
//$sql.= " WHERE entity IN (0,".$conf->entity.")"; // Filter is done later
if ($elementtype) $sql .= " WHERE elementtype = '".$this->db->escape($elementtype)."'"; // Filed with object->table_element

View File

@ -169,6 +169,7 @@ $totalizable = $extrafields->attributes[$elementtype]['totalizable'][$attrname];
$help = $extrafields->attributes[$elementtype]['help'][$attrname];
$entitycurrentorall = $extrafields->attributes[$elementtype]['entityid'][$attrname];
$printable = $extrafields->attributes[$elementtype]['printable'][$attrname];
$enabled = $extrafields->attributes[$elementtype]['enabled'][$attrname];
if ((($type == 'select') || ($type == 'checkbox') || ($type == 'radio')) && is_array($param))
{
@ -299,6 +300,14 @@ if (in_array($type, array_keys($typewecanchangeinto)))
<!-- Multicompany entity -->
<tr><td><?php echo $langs->trans("AllEntities"); ?></td><td class="valeur"><input id="entitycurrentorall" type="checkbox" name="entitycurrentorall"<?php echo (empty($entitycurrentorall) ? ' checked' : ''); ?>></td></tr>
<?php } ?>
<!-- Show Enabled property when value is not a common value -->
<?php if ($enabled != '1') { ?>
<tr class="help"><td><?php echo $langs->trans("EnabledCondition"); ?></td><td class="valeur">
<?php echo dol_escape_htmltag($enabled); ?>
<?php } ?>
</td></tr>
</table>
<?php print dol_get_fiche_end(); ?>

View File

@ -76,6 +76,11 @@ if (is_array($extrafields->attributes[$elementtype]['type']) && count($extrafiel
{
foreach ($extrafields->attributes[$elementtype]['type'] as $key => $value)
{
/*if (! dol_eval($extrafields->attributes[$elementtype]['enabled'][$key], 1)) {
// TODO Uncomment this to exclude extrafields of modules not enabled. Add a link to "Show extrafields disabled"
// continue;
}*/
// Load language if required
if (!empty($extrafields->attributes[$elementtype]['langfile'][$key])) {
$langs->load($extrafields->attributes[$elementtype]['langfile'][$key]);