NEW When creating a user from a member linked to a thirdparty, you can

decide if it is an internal or external (default) user.
This commit is contained in:
Laurent Destailleur 2020-10-14 14:02:07 +02:00
parent 02fcee5d94
commit a0b17635fd
6 changed files with 27 additions and 14 deletions

View File

@ -181,7 +181,12 @@ if (empty($reshook)) {
if ($result > 0) {
// Creation user
$nuser = new User($db);
$result = $nuser->create_from_member($object, GETPOST('login', 'alphanohtml'));
$tmpuser = dol_clone($object);
if (GETPOST('internalorexternal', 'aZ09') == 'internal') {
$tmpuser->fk_soc = 0;
}
$result = $nuser->create_from_member($tmpuser, GETPOST('login', 'alphanohtml'));
if ($result < 0) {
$langs->load("errors");
@ -1279,11 +1284,15 @@ if (is_object($objcanvas) && $objcanvas->displayCanvasExists($action)) {
$formquestion = array(
array('label' => $langs->trans("LoginToCreate"), 'type' => 'text', 'name' => 'login', 'value' => $login)
);
$text = $langs->trans("ConfirmCreateLogin").'<br>';
if (!empty($conf->societe->enabled)) {
if ($object->socid > 0) $text .= $langs->trans("UserWillBeExternalUser");
else $text .= $langs->trans("UserWillBeInternalUser");
if (!empty($conf->societe->enabled) && $object->socid > 0) {
$object->fetch_thirdparty();
$formquestion[] = array('label' => $langs->trans("UserWillBe"), 'type' => 'radio', 'name' => 'internalorexternal', 'default'=>'external', 'values' => array('external'=>$langs->trans("External").' - '.$langs->trans("LinkedToDolibarrThirdParty").' '.$object->thirdparty->getNomUrl(1, '', 0, 1), 'internal'=>$langs->trans("Internal")));
}
$text = '';
if (!empty($conf->societe->enabled) && $object->socid <= 0) {
$text .= $langs->trans("UserWillBeInternalUser").'<br>';
}
$text .= $langs->trans("ConfirmCreateLogin");
print $form->formconfirm($_SERVER["PHP_SELF"]."?rowid=".$object->id, $langs->trans("CreateDolibarrLogin"), $text, "confirm_create_user", $formquestion, 'yes');
}

View File

@ -4213,10 +4213,11 @@ class Form
$more .= '<div class="tagtr">';
if ($i == 0) $more .= '<div class="tagtd'.(empty($input['tdclass']) ? ' tdtop' : (' tdtop '.$input['tdclass'])).'">'.$input['label'].'</div>';
else $more .= '<div clas="tagtd'.(empty($input['tdclass']) ? '' : (' "'.$input['tdclass'])).'">&nbsp;</div>';
$more .= '<div class="tagtd"><input type="radio" class="flat'.$morecss.'" id="'.$input['name'].'" name="'.$input['name'].'" value="'.$selkey.'"'.$moreattr;
$more .= '<div class="tagtd'.($i == 0 ? ' tdtop' : '').'"><input type="radio" class="flat'.$morecss.'" id="'.$input['name'].$selkey.'" name="'.$input['name'].'" value="'.$selkey.'"'.$moreattr;
if ($input['disabled']) $more .= ' disabled';
if (isset($input['default']) && $input['default'] === $selkey) $more .= ' checked="checked"';
$more .= ' /> ';
$more .= $selval;
$more .= '<label for="'.$input['name'].$selkey.'">'.$selval.'</label>';
$more .= '</div></div>'."\n";
$i++;
}

View File

@ -75,6 +75,7 @@ CreateInternalUserDesc=This form allows you to create an internal user in your c
InternalExternalDesc=An <b>internal</b> user is a user that is part of your company/organization.<br>An <b>external</b> user is a customer, vendor or other (Creating an external user for a third-party can be done from the contact record of the third-party).<br><br>In both cases, permissions defines rights on Dolibarr, also external user can have a different menu manager than internal user (See Home - Setup - Display)
PermissionInheritedFromAGroup=Permission granted because inherited from one of a user's group.
Inherited=Inherited
UserWillBe=Created user will be
UserWillBeInternalUser=Created user will be an internal user (because not linked to a particular third party)
UserWillBeExternalUser=Created user will be an external user (because linked to a particular third party)
IdPhoneCaller=Id phone caller

View File

@ -375,7 +375,7 @@ if ((!defined('NOCSRFCHECK') && empty($dolibarr_nocsrfcheck) && !empty($conf->gl
// Check all cases that need a token (all POST actions, all actions and mass actions on pages with CSRFCHECK_WITH_TOKEN set, all sensitive GET actions)
if ($_SERVER['REQUEST_METHOD'] == 'POST' ||
((GETPOSTISSET('action') || GETPOSTISSET('massaction')) && defined('CSRFCHECK_WITH_TOKEN')) ||
in_array(GETPOST('action', 'aZ09'), array('add', 'addtimespent', 'update', 'install', 'delete', 'deleteprof', 'deletepayment')))
in_array(GETPOST('action', 'aZ09'), array('add', 'addtimespent', 'update', 'install', 'delete', 'deleteprof', 'deletepayment', 'confirm_create_user', 'confirm_create_thirdparty')))
{
if (!GETPOSTISSET('token')) {
if (GETPOST('uploadform', 'int')) {

View File

@ -2358,11 +2358,12 @@ class Societe extends CommonObject
$code .= $this->code_fournisseur.' - ';
}
if ($conf->global->SOCIETE_ADD_REF_IN_LIST == 1)
{
$name = $code.' '.$name;
} else {
$name = $code;
if ($code) {
if ($conf->global->SOCIETE_ADD_REF_IN_LIST == 1) {
$name = $code.' '.$name;
} else {
$name = $code;
}
}
}

View File

@ -1318,7 +1318,8 @@ class User extends CommonObject
// phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps
/**
* Create a user into database from a member object
* Create a user into database from a member object.
* If $member->fk_soc is set, it will be an external user.
*
* @param Adherent $member Object member source
* @param string $login Login to force