Fix backward compatibility with old multicompany module

This commit is contained in:
Laurent Destailleur 2018-07-05 22:15:55 +02:00
parent b369585e61
commit af3ab84ebb

View File

@ -1053,22 +1053,23 @@ if ($action == 'create' || $action == 'adduserldap')
} }
// Multicompany // Multicompany
// This is now done with hook formObjectOptions if (! empty($conf->multicompany->enabled) && is_object($mc))
/* {
if (! empty($conf->multicompany->enabled) && is_object($mc)) // This is now done with hook formObjectOptions. Keep this code for backward compatibility with old multicompany module
{ if (! method_exists($mc, 'formObjectOptions'))
if (empty($conf->global->MULTICOMPANY_TRANSVERSE_MODE) && $conf->entity == 1 && $user->admin && ! $user->entity) // condition must be same for create and edit mode {
{ if (empty($conf->global->MULTICOMPANY_TRANSVERSE_MODE) && $conf->entity == 1 && $user->admin && ! $user->entity) // condition must be same for create and edit mode
print "<tr>".'<td>'.$langs->trans("Entity").'</td>'; {
print "<td>".$mc->select_entities($conf->entity); print "<tr>".'<td>'.$langs->trans("Entity").'</td>';
print "</td></tr>\n"; print "<td>".$mc->select_entities($conf->entity);
} print "</td></tr>\n";
else }
{ else
print '<input type="hidden" name="entity" value="'.$conf->entity.'" />'; {
} print '<input type="hidden" name="entity" value="'.$conf->entity.'" />';
} }
*/ }
}
// Other attributes // Other attributes
$parameters=array('objectsrc' => $objectsrc, 'colspan' => ' colspan="3"'); $parameters=array('objectsrc' => $objectsrc, 'colspan' => ' colspan="3"');
@ -1558,23 +1559,25 @@ else
print '<td>'.dol_print_date($object->datepreviouslogin,"dayhour").'</td>'; print '<td>'.dol_print_date($object->datepreviouslogin,"dayhour").'</td>';
print "</tr>\n"; print "</tr>\n";
// Multicompany // Multicompany
// This is now done with hook formObjectOptions (included into /core/tpl/extrafields_view.tpl.php) if (! empty($conf->multicompany->enabled) && is_object($mc))
/* {
if (! empty($conf->multicompany->enabled) && is_object($mc)) // This is now done with hook formObjectOptions. Keep this code for backward compatibility with old multicompany module
{ if (! method_exists($mc, 'formObjectOptions'))
if (! empty($conf->multicompany->enabled) && empty($conf->global->MULTICOMPANY_TRANSVERSE_MODE) && $conf->entity == 1 && $user->admin && ! $user->entity) {
{ if (! empty($conf->multicompany->enabled) && empty($conf->global->MULTICOMPANY_TRANSVERSE_MODE) && $conf->entity == 1 && $user->admin && ! $user->entity)
print '<tr><td>' . $langs->trans("Entity") . '</td><td>'; {
if (empty($object->entity)) { print '<tr><td>' . $langs->trans("Entity") . '</td><td>';
print $langs->trans("AllEntities"); if (empty($object->entity)) {
} else { print $langs->trans("AllEntities");
$mc->getInfo($object->entity); } else {
print $mc->label; $mc->getInfo($object->entity);
} print $mc->label;
print "</td></tr>\n"; }
} print "</td></tr>\n";
}*/ }
}
}
// Other attributes // Other attributes
include DOL_DOCUMENT_ROOT . '/core/tpl/extrafields_view.tpl.php'; include DOL_DOCUMENT_ROOT . '/core/tpl/extrafields_view.tpl.php';
@ -1731,7 +1734,7 @@ else
} }
} }
} }
print "</div>\n"; print "</div>\n";
@ -2322,24 +2325,25 @@ else
print "</tr>\n"; print "</tr>\n";
} }
// Multicompany // Multicompany
// This is now done with hook formObjectOptions
/*
// TODO check if user not linked with the current entity before change entity (thirdparty, invoice, etc.) !! // TODO check if user not linked with the current entity before change entity (thirdparty, invoice, etc.) !!
if (! empty($conf->multicompany->enabled) && is_object($mc)) if (! empty($conf->multicompany->enabled) && is_object($mc))
{ {
if (empty($conf->multicompany->transverse_mode) && $conf->entity == 1 && $user->admin && ! $user->entity) // This is now done with hook formObjectOptions. Keep this code for backward compatibility with old multicompany module
if (! method_exists($mc, 'formObjectOptions'))
{ {
print "<tr>".'<td>'.$langs->trans("Entity").'</td>'; if (empty($conf->multicompany->transverse_mode) && $conf->entity == 1 && $user->admin && ! $user->entity)
print "<td>".$mc->select_entities($object->entity, 'entity', '', 0, 1); // last parameter 1 means, show also a choice 0=>'all entities' {
print "</td></tr>\n"; print "<tr>".'<td>'.$langs->trans("Entity").'</td>';
} print "<td>".$mc->select_entities($object->entity, 'entity', '', 0, 1); // last parameter 1 means, show also a choice 0=>'all entities'
else print "</td></tr>\n";
{ }
print '<input type="hidden" name="entity" value="'.$conf->entity.'" />'; else
} {
} print '<input type="hidden" name="entity" value="'.$conf->entity.'" />';
*/ }
}
}
// Other attributes // Other attributes
$parameters=array('colspan' => ' colspan="2"'); $parameters=array('colspan' => ' colspan="2"');